导航菜单

页面标题

页面副标题

Online Loans v421.2.42 - InAppChatFragment.java 源代码

正在查看: Online Loans v421.2.42 应用的 InAppChatFragment.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package org.infobip.mobile.messaging.chat.view;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.hardware.camera2.CameraManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import androidx.activity.q;
import androidx.appcompat.app.a;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.t;
import androidx.lifecycle.j;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.MaterialToolbar;
import f6.AbstractC0205l;
import f6.C0204k;
import java.util.ArrayList;
import java.util.Locale;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.sequences.Sequence;
import kotlin.text.p;
import org.chromium.support_lib_boundary.WebSettingsBoundaryInterface;
import org.infobip.mobile.messaging.api.chat.WidgetInfo;
import org.infobip.mobile.messaging.chat.R;
import org.infobip.mobile.messaging.chat.attachments.InAppChatAttachmentHelper;
import org.infobip.mobile.messaging.chat.attachments.InAppChatMobileAttachment;
import org.infobip.mobile.messaging.chat.core.InAppChatWidgetView;
import org.infobip.mobile.messaging.chat.core.MultithreadStrategy;
import org.infobip.mobile.messaging.chat.core.SessionStorage;
import org.infobip.mobile.messaging.chat.databinding.IbFragmentChatBinding;
import org.infobip.mobile.messaging.chat.models.ContextualData;
import org.infobip.mobile.messaging.chat.utils.LocalizationUtils;
import org.infobip.mobile.messaging.chat.utils.ViewUtilsKt;
import org.infobip.mobile.messaging.chat.view.InAppChatAttachmentPreviewActivity;
import org.infobip.mobile.messaging.chat.view.InAppChatFragment;
import org.infobip.mobile.messaging.chat.view.InAppChatFragmentActivityResultDelegate;
import org.infobip.mobile.messaging.chat.view.InAppChatInputView;
import org.infobip.mobile.messaging.chat.view.InAppChatView;
import org.infobip.mobile.messaging.chat.view.styles.InAppChatToolbarStyle;
import org.infobip.mobile.messaging.chat.view.styles.InAppChatToolbarStyleKt;
import org.infobip.mobile.messaging.chat.view.styles.factory.StyleFactory;
import org.infobip.mobile.messaging.logging.MobileMessagingLogger;
import org.infobip.mobile.messaging.mobileapi.InternalSdkError;
import org.jetbrains.annotations.NotNull;
import s6.k;

@Metadata
public final class InAppChatFragment extends Fragment implements InAppChatFragmentActivityResultDelegate.ResultListener {

    @NotNull
    public static final Companion Companion = new Companion(null);
    public boolean A0;
    public final InAppChatFragment$attachmentHelperListener$1 B0;
    public IbFragmentChatBinding f0;
    public int g0;
    public Boolean h0;
    public LocalizationUtils i0;
    public Uri j0;
    public Uri k0;
    public WidgetInfo l0;
    public InAppChatWidgetView m0;
    public String n0;
    public final q o0 = new q() {
        {
            super(true);
        }

        public void handleOnBackPressed() {
            if (InAppChatFragment.this.getHandleBackPress()) {
                InAppChatFragment.this.N0();
            }
        }
    };
    public final InAppChatInputFinishChecker p0 = new InAppChatInputFinishChecker(new f());
    public final Handler q0 = new Handler(Looper.getMainLooper());
    public InAppChatFragmentLifecycleRegistry r0;
    public InAppChatFragmentActivityResultDelegate s0;
    public EventsListener t0;
    public final ErrorsHandler u0;
    public ErrorsHandler v0;
    public boolean w0;
    public boolean x0;
    public InAppChatActionBarProvider y0;
    public boolean z0;

    @Metadata
    public static final class Companion {
        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        public Companion() {
        }
    }

    @Metadata
    public interface ErrorsHandler extends InAppChatErrorHandler {
    }

    @Metadata
    public interface EventsListener extends InAppChatEventsListener {
        boolean onAttachmentPreviewOpened(String str, String str2, String str3);

        void onExitChatPressed();
    }

    @Metadata
    public interface InAppChatActionBarProvider {
        i.a getOriginalSupportActionBar();

        void onInAppChatBackPressed();
    }

    @Metadata
    public class WhenMappings {
        public static final int[] $EnumSwitchMapping$0;

        static {
            int[] iArr = new int[InAppChatWidgetView.values().length];
            try {
                iArr[InAppChatWidgetView.LOADING.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                iArr[InAppChatWidgetView.THREAD_LIST.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                iArr[InAppChatWidgetView.SINGLE_MODE_THREAD.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                iArr[InAppChatWidgetView.THREAD.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                iArr[InAppChatWidgetView.LOADING_THREAD.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                iArr[InAppChatWidgetView.CLOSED_THREAD.ordinal()] = 6;
            } catch (NoSuchFieldError unused6) {
            }
            $EnumSwitchMapping$0 = iArr;
        }
    }

    public static final class a extends s6.k implements Function1 {
        public final WidgetInfo a;

        public a(WidgetInfo widgetInfo) {
            super(1);
            this.a = widgetInfo;
        }

        public final void a(IbFragmentChatBinding it) {
            Intrinsics.checkNotNullParameter(it, "it");
            it.ibLcChatInput.applyWidgetInfoStyle(this.a);
        }

        @Override
        public Object invoke(Object obj) {
            a((IbFragmentChatBinding) obj);
            return Unit.a;
        }
    }

    public static final class b extends s6.k implements Function1 {
        public final InAppChatToolbarStyle a;

        public b(InAppChatToolbarStyle inAppChatToolbarStyle) {
            super(1);
            this.a = inAppChatToolbarStyle;
        }

        public final void a(IbFragmentChatBinding it) {
            Intrinsics.checkNotNullParameter(it, "it");
            InAppChatToolbarStyleKt.apply(this.a, it.ibLcChatToolbar);
        }

        @Override
        public Object invoke(Object obj) {
            a((IbFragmentChatBinding) obj);
            return Unit.a;
        }
    }

    public static final class c extends s6.k implements Function0 {
        public c() {
            super(0);
        }

        @Override
        public final Boolean invoke() {
            return Boolean.valueOf(InAppChatFragment.this.isHidden());
        }
    }

    public static final class d extends s6.k implements Function1 {
        public final boolean a;
        public final InAppChatFragment b;

        public d(boolean z, InAppChatFragment inAppChatFragment) {
            super(1);
            this.a = z;
            this.b = inAppChatFragment;
        }

        public final void a(IbFragmentChatBinding it) {
            Intrinsics.checkNotNullParameter(it, "it");
            if (!this.a) {
                it.ibLcChatInput.setVisibility(8);
                return;
            }
            this.b.I0();
            this.b.G0();
            this.b.B0();
            this.b.T0(true);
        }

        @Override
        public Object invoke(Object obj) {
            a((IbFragmentChatBinding) obj);
            return Unit.a;
        }
    }

    public static final class e extends s6.k implements Function1 {
        public final boolean a;
        public final InAppChatFragment b;

        public e(boolean z, InAppChatFragment inAppChatFragment) {
            super(1);
            this.a = z;
            this.b = inAppChatFragment;
        }

        public static final void c(InAppChatFragment this$0, View view) {
            Intrinsics.checkNotNullParameter(this$0, "this$0");
            this$0.N0();
        }

        public final void b(IbFragmentChatBinding binding) {
            i.a originalSupportActionBar;
            InAppChatActionBarProvider inAppChatActionBarProvider;
            i.a originalSupportActionBar2;
            Intrinsics.checkNotNullParameter(binding, "binding");
            AppBarLayout appBarLayout = binding.ibLcAppbar;
            Intrinsics.checkNotNullExpressionValue(appBarLayout, "binding.ibLcAppbar");
            ViewUtilsKt.show(appBarLayout, this.a);
            binding.ibLcAppbar.invalidate();
            if (!this.a) {
                binding.ibLcChatToolbar.setNavigationOnClickListener((View.OnClickListener) null);
                return;
            }
            InAppChatActionBarProvider inAppChatActionBarProvider2 = this.b.getInAppChatActionBarProvider();
            if (inAppChatActionBarProvider2 != null && (originalSupportActionBar = inAppChatActionBarProvider2.getOriginalSupportActionBar()) != null && originalSupportActionBar.n() && (inAppChatActionBarProvider = this.b.getInAppChatActionBarProvider()) != null && (originalSupportActionBar2 = inAppChatActionBarProvider.getOriginalSupportActionBar()) != null) {
                originalSupportActionBar2.l();
            }
            MaterialToolbar materialToolbar = binding.ibLcChatToolbar;
            final InAppChatFragment inAppChatFragment = this.b;
            materialToolbar.setNavigationOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    InAppChatFragment.e.c(InAppChatFragment.this, view);
                }
            });
        }

        @Override
        public Object invoke(Object obj) {
            b((IbFragmentChatBinding) obj);
            return Unit.a;
        }
    }

    public static final class f extends s6.k implements Function1 {

        public static final class a extends s6.k implements Function1 {
            public final String a;

            public a(String str) {
                super(1);
                this.a = str;
            }

            public final void a(IbFragmentChatBinding it) {
                Intrinsics.checkNotNullParameter(it, "it");
                it.ibLcChat.sendChatMessageDraft(this.a);
            }

            @Override
            public Object invoke(Object obj) {
                a((IbFragmentChatBinding) obj);
                return Unit.a;
            }
        }

        public f() {
            super(1);
        }

        public final void a(String draft) {
            Intrinsics.checkNotNullParameter(draft, "draft");
            InAppChatFragment.b1(InAppChatFragment.this, null, new a(draft), 1, null);
        }

        @Override
        public Object invoke(Object obj) {
            a((String) obj);
            return Unit.a;
        }
    }

    public static final class g extends s6.k implements Function1 {
        public static final g a = new g();

        public g() {
            super(1);
        }

        public final void a(IbFragmentChatBinding it) {
            Intrinsics.checkNotNullParameter(it, "it");
            it.ibLcChatInput.hideKeyboard();
        }

        @Override
        public Object invoke(Object obj) {
            a((IbFragmentChatBinding) obj);
            return Unit.a;
        }
    }

    public static final class h extends s6.k implements Function1 {
        public final String a;
        public final InAppChatMobileAttachment b;

        public h(String str, InAppChatMobileAttachment inAppChatMobileAttachment) {
            super(1);
            this.a = str;
            this.b = inAppChatMobileAttachment;
        }

        public final void a(IbFragmentChatBinding it) {
            Intrinsics.checkNotNullParameter(it, "it");
            it.ibLcChat.sendChatMessage(this.a, this.b);
        }

        @Override
        public Object invoke(Object obj) {
            a((IbFragmentChatBinding) obj);
            return Unit.a;
        }
    }

    public static final class i extends s6.k implements Function1 {
        public final String a;

        public i(String str) {
            super(1);
            this.a = str;
        }

        public final void a(IbFragmentChatBinding it) {
            Intrinsics.checkNotNullParameter(it, "it");
            it.ibLcChat.sendChatMessageDraft(this.a);
        }

        @Override
        public Object invoke(Object obj) {
            a((IbFragmentChatBinding) obj);
            return Unit.a;
        }
    }

    public static final class j extends s6.k implements Function0 {
        public final String a;
        public final MultithreadStrategy b;

        public j(String str, MultithreadStrategy multithreadStrategy) {
            super(0);
            this.a = str;
            this.b = multithreadStrategy;
        }

        public final void a() {
            SessionStorage.INSTANCE.setContextualData(new ContextualData(this.a, this.b));
            MobileMessagingLogger.d("InAppChatFragment", "Contextual data is stored, will be sent once chat is loaded.");
        }

        @Override
        public Object invoke() {
            a();
            return Unit.a;
        }
    }

    public static final class k extends s6.k implements Function1 {
        public final String a;
        public final MultithreadStrategy b;

        public k(String str, MultithreadStrategy multithreadStrategy) {
            super(1);
            this.a = str;
            this.b = multithreadStrategy;
        }

        public final void a(IbFragmentChatBinding it) {
            Intrinsics.checkNotNullParameter(it, "it");
            it.ibLcChat.sendContextualData(this.a, this.b);
        }

        @Override
        public Object invoke(Object obj) {
            a((IbFragmentChatBinding) obj);
            return Unit.a;
        }
    }

    public static final class l extends s6.k implements Function1 {
        public final boolean b;

        public l(boolean z) {
            super(1);
            this.b = z;
        }

        public final void a(IbFragmentChatBinding binding) {
            Intrinsics.checkNotNullParameter(binding, "binding");
            if (InAppChatFragment.this.getWithInput()) {
                boolean z = this.b && ((InAppChatFragment.this.isMultiThread() && (InAppChatFragment.this.m0 == InAppChatWidgetView.THREAD || InAppChatFragment.this.m0 == InAppChatWidgetView.SINGLE_MODE_THREAD)) || (InAppChatFragment.this.isMultiThread() ^ true));
                ConstraintLayout constraintLayout = binding.ibLcChatInput;
                Intrinsics.checkNotNullExpressionValue(constraintLayout, "binding.ibLcChatInput");
                if ((constraintLayout.getVisibility() == 0) == z) {
                    return;
                }
                binding.ibLcChatInput.show(z);
                EventsListener eventsListener = InAppChatFragment.this.getEventsListener();
                if (eventsListener != null) {
                    eventsListener.onChatControlsVisibilityChanged(z);
                }
            }
        }

        @Override
        public Object invoke(Object obj) {
            a((IbFragmentChatBinding) obj);
            return Unit.a;
        }
    }

    public static final class m extends s6.k implements Function1 {
        public final Locale a;

        public m(Locale locale) {
            super(1);
            this.a = locale;
        }

        public final void a(IbFragmentChatBinding it) {
            Intrinsics.checkNotNullParameter(it, "it");
            it.ibLcChat.setLanguage(this.a);
        }

        @Override
        public Object invoke(Object obj) {
            a((IbFragmentChatBinding) obj);
            return Unit.a;
        }
    }

    public static final class n extends s6.k implements Function1 {
        public final String a;

        public n(String str) {
            super(1);
            this.a = str;
        }

        public final void a(IbFragmentChatBinding it) {
            Intrinsics.checkNotNullParameter(it, "it");
            it.ibLcChat.setWidgetTheme(this.a);
        }

        @Override
        public Object invoke(Object obj) {
            a((IbFragmentChatBinding) obj);
            return Unit.a;
        }
    }

    public static final class o extends s6.k implements Function1 {
        public static final o a = new o();

        public o() {
            super(1);
        }

        public final void a(IbFragmentChatBinding it) {
            Intrinsics.checkNotNullParameter(it, "it");
            it.ibLcChat.showThreadList();
        }

        @Override
        public Object invoke(Object obj) {
            a((IbFragmentChatBinding) obj);
            return Unit.a;
        }
    }

    public InAppChatFragment() {
        InAppChatEventsListener inAppChatEventsListener = SessionStorage.INSTANCE.getInAppChatEventsListener();
        this.t0 = inAppChatEventsListener != null ? X0(inAppChatEventsListener) : null;
        ErrorsHandler errorsHandler = new ErrorsHandler() {

            public static final class a extends k implements Function1 {
                public final String a;

                public a(String str) {
                    super(1);
                    this.a = str;
                }

                public final void a(IbFragmentChatBinding it) {
                    Intrinsics.checkNotNullParameter(it, "it");
                    it.ibLcChat.getDefaultErrorsHandler().handlerError(this.a);
                }

                @Override
                public Object invoke(Object obj) {
                    a((IbFragmentChatBinding) obj);
                    return Unit.a;
                }
            }

            public static final class b extends k implements Function1 {
                public final boolean a;

                public b(boolean z) {
                    super(1);
                    this.a = z;
                }

                public final void a(IbFragmentChatBinding it) {
                    Intrinsics.checkNotNullParameter(it, "it");
                    it.ibLcChat.getDefaultErrorsHandler().handlerNoInternetConnectionError(this.a);
                }

                @Override
                public Object invoke(Object obj) {
                    a((IbFragmentChatBinding) obj);
                    return Unit.a;
                }
            }

            public static final class c extends k implements Function1 {
                public final String a;

                public c(String str) {
                    super(1);
                    this.a = str;
                }

                public final void a(IbFragmentChatBinding it) {
                    Intrinsics.checkNotNullParameter(it, "it");
                    it.ibLcChat.getDefaultErrorsHandler().handlerWidgetError(this.a);
                }

                @Override
                public Object invoke(Object obj) {
                    a((IbFragmentChatBinding) obj);
                    return Unit.a;
                }
            }

            @Override
            public void handlerError(@NotNull String error) {
                Intrinsics.checkNotNullParameter(error, "error");
                InAppChatFragment.b1(InAppChatFragment.this, null, new a(error), 1, null);
            }

            @Override
            public void handlerNoInternetConnectionError(boolean z) {
                InAppChatFragment.b1(InAppChatFragment.this, null, new b(z), 1, null);
            }

            @Override
            public void handlerWidgetError(@NotNull String error) {
                Intrinsics.checkNotNullParameter(error, "error");
                InAppChatFragment.b1(InAppChatFragment.this, null, new c(error), 1, null);
            }
        };
        this.u0 = errorsHandler;
        this.v0 = errorsHandler;
        this.w0 = true;
        this.x0 = true;
        this.A0 = true;
        this.B0 = new InAppChatAttachmentHelper.InAppChatAttachmentHelperListener() {
            @Override
            public void onAttachmentCreated(InAppChatMobileAttachment inAppChatMobileAttachment) {
                LocalizationUtils localizationUtils;
                IbFragmentChatBinding y0;
                LocalizationUtils localizationUtils2 = null;
                if (inAppChatMobileAttachment != null) {
                    MobileMessagingLogger.w("InAppChatFragment", "Attachment created, will send Attachment");
                    y0 = InAppChatFragment.this.y0();
                    y0.ibLcChat.sendChatMessage(null, inAppChatMobileAttachment);
                } else {
                    MobileMessagingLogger.e("InAppChatFragment", "Can't create attachment");
                    Context requireContext = InAppChatFragment.this.requireContext();
                    localizationUtils = InAppChatFragment.this.i0;
                    if (localizationUtils == null) {
                        Intrinsics.r("localizationUtils");
                    } else {
                        localizationUtils2 = localizationUtils;
                    }
                    Toast.makeText(requireContext, localizationUtils2.getString(R.string.ib_chat_cant_create_attachment, new Object[0]), 0).show();
                }
                InAppChatFragment.this.x0();
            }

            @Override
            public void onError(Context context, Exception exc) {
                LocalizationUtils localizationUtils;
                WidgetInfo widgetInfo;
                LocalizationUtils localizationUtils2;
                Intrinsics.c(exc);
                LocalizationUtils localizationUtils3 = null;
                if (Intrinsics.a(exc.getMessage(), InternalSdkError.ERROR_ATTACHMENT_MAX_SIZE_EXCEEDED.get())) {
                    StringBuilder sb = new StringBuilder();
                    sb.append("Maximum allowed attachment size exceeded");
                    widgetInfo = InAppChatFragment.this.l0;
                    sb.append(widgetInfo != null ? Long.valueOf(widgetInfo.getMaxUploadContentSize()) : null);
                    MobileMessagingLogger.e("InAppChatFragment", sb.toString());
                    localizationUtils2 = InAppChatFragment.this.i0;
                    if (localizationUtils2 == null) {
                        Intrinsics.r("localizationUtils");
                    } else {
                        localizationUtils3 = localizationUtils2;
                    }
                    Toast.makeText(context, localizationUtils3.getString(R.string.ib_chat_allowed_attachment_size_exceeded, new Object[0]), 0).show();
                } else {
                    MobileMessagingLogger.e("InAppChatFragment", "Attachment content is not valid.");
                    localizationUtils = InAppChatFragment.this.i0;
                    if (localizationUtils == null) {
                        Intrinsics.r("localizationUtils");
                    } else {
                        localizationUtils3 = localizationUtils;
                    }
                    Toast.makeText(context, localizationUtils3.getString(R.string.ib_chat_cant_create_attachment, new Object[0]), 0).show();
                }
                InAppChatFragment.this.x0();
            }
        };
    }

    public static final void C0(InAppChatFragment this$0, View view) {
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        if (this$0.M0()) {
            this$0.v0(true);
        } else {
            this$0.requestCameraPermissionIfNeeded();
        }
    }

    public static final void H0(InAppChatInputView this_with, InAppChatFragment this$0, View view) {
        Sequence<String> I0;
        boolean s;
        Intrinsics.checkNotNullParameter(this_with, "$this_with");
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        String inputText = this_with.getInputText();
        if (inputText != null) {
            I0 = p.I0(inputText, InAppChatView.MESSAGE_MAX_LENGTH);
            for (String str : I0) {
                s = kotlin.text.n.s(str);
                if (!s) {
                    InAppChatView inAppChatView = this$0.y0().ibLcChat;
                    Intrinsics.checkNotNullExpressionValue(inAppChatView, "binding.ibLcChat");
                    InAppChatView.sendChatMessage$default(inAppChatView, str, null, 2, null);
                }
            }
            this_with.clearInputText();
        }
    }

    public static final void J0(InAppChatFragment this$0, View view, boolean z) {
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        if (z) {
            return;
        }
        this$0.y0().ibLcChatInput.hideKeyboard();
    }

    private final void L0() {
        y0().ibLcChatInput.setEnabled(false);
        E0();
        K0(this.w0);
        F0(this.x0);
    }

    public static final void V0(InAppChatFragment this$0, DialogInterface dialogInterface, int i2) {
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        dialogInterface.dismiss();
        this$0.v0(false);
    }

    public static final void W0(InAppChatFragment this$0, DialogInterface dialogInterface, int i2) {
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        dialogInterface.dismiss();
        InAppChatFragmentActivityResultDelegate inAppChatFragmentActivityResultDelegate = this$0.s0;
        if (inAppChatFragmentActivityResultDelegate == null) {
            Intrinsics.r("activityResultDelegate");
            inAppChatFragmentActivityResultDelegate = null;
        }
        String packageName = this$0.getContext().getPackageName();
        Intrinsics.checkNotNullExpressionValue(packageName, "context.packageName");
        inAppChatFragmentActivityResultDelegate.openAppSettings(packageName);
    }

    public static void b1(InAppChatFragment inAppChatFragment, Function0 function0, Function1 function1, int i2, Object obj) {
        if ((i2 & 1) != 0) {
            function0 = null;
        }
        inAppChatFragment.a1(function0, function1);
    }

    public static void sendChatMessage$default(InAppChatFragment inAppChatFragment, String str, InAppChatMobileAttachment inAppChatMobileAttachment, int i2, Object obj) throws IllegalArgumentException {
        if ((i2 & 2) != 0) {
            inAppChatMobileAttachment = null;
        }
        inAppChatFragment.sendChatMessage(str, inAppChatMobileAttachment);
    }

    public final InAppChatFragmentLifecycleRegistry A0() {
        InAppChatFragmentLifecycleRegistry inAppChatFragmentLifecycleRegistry = this.r0;
        if (inAppChatFragmentLifecycleRegistry != null) {
            return inAppChatFragmentLifecycleRegistry;
        }
        androidx.lifecycle.n viewLifecycleOwner = getViewLifecycleOwner();
        Intrinsics.checkNotNullExpressionValue(viewLifecycleOwner, "viewLifecycleOwner");
        InAppChatFragmentLifecycleRegistryImpl inAppChatFragmentLifecycleRegistryImpl = new InAppChatFragmentLifecycleRegistryImpl(viewLifecycleOwner, new c());
        this.r0 = inAppChatFragmentLifecycleRegistryImpl;
        return inAppChatFragmentLifecycleRegistryImpl;
    }

    public final void B0() {
        y0().ibLcChatInput.setAttachmentButtonClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                InAppChatFragment.C0(InAppChatFragment.this, view);
            }
        });
    }

    public final void D0() {
        requireActivity().getOnBackPressedDispatcher().h(getViewLifecycleOwner(), this.o0);
    }

    public final void E0() {
        y0().ibLcChat.setEventsListener(new InAppChatView.EventsListener() {
            @Override
            public void onAttachmentPreviewOpened(String str, String str2, String str3) {
                Intent startIntent;
                Object b2;
                InAppChatFragment.EventsListener eventsListener = InAppChatFragment.this.getEventsListener();
                if (eventsListener == null || !eventsListener.onAttachmentPreviewOpened(str, str2, str3)) {
                    if (Intrinsics.a(str2, "DOCUMENT")) {
                        startIntent = new Intent("android.intent.action.VIEW");
                        startIntent.setData(Uri.parse(str));
                    } else {
                        InAppChatAttachmentPreviewActivity.Companion companion = InAppChatAttachmentPreviewActivity.Companion;
                        Context requireContext = InAppChatFragment.this.requireContext();
                        Intrinsics.checkNotNullExpressionValue(requireContext, "requireContext()");
                        startIntent = companion.startIntent(requireContext, str, str2, str3);
                    }
                    InAppChatFragment inAppChatFragment = InAppChatFragment.this;
                    try {
                        C0204k.a aVar = C0204k.b;
                        inAppChatFragment.startActivity(startIntent);
                        b2 = C0204k.b(Unit.a);
                    } catch (Throwable th) {
                        C0204k.a aVar2 = C0204k.b;
                        b2 = C0204k.b(AbstractC0205l.a(th));
                    }
                    Throwable d2 = C0204k.d(b2);
                    if (d2 != null) {
                        MobileMessagingLogger.e("InAppChatFragment", "Could not open attachment preview.", d2);
                    }
                }
            }

            @Override
            public void onChatControlsVisibilityChanged(boolean z) {
                InAppChatFragment.this.T0(z);
            }

            @Override
            public void onChatDisconnected() {
                IbFragmentChatBinding y0;
                y0 = InAppChatFragment.this.y0();
                y0.ibLcChatInput.setEnabled(false);
                InAppChatFragment.EventsListener eventsListener = InAppChatFragment.this.getEventsListener();
                if (eventsListener != null) {
                    eventsListener.onChatDisconnected();
                }
            }

            @Override
            public void onChatLoaded(boolean z) {
                IbFragmentChatBinding y0;
                y0 = InAppChatFragment.this.y0();
                y0.ibLcChatInput.setEnabled(z);
                InAppChatFragment.EventsListener eventsListener = InAppChatFragment.this.getEventsListener();
                if (eventsListener != null) {
                    eventsListener.onChatLoaded(z);
                }
            }

            @Override
            public void onChatRawMessageReceived(@NotNull String rawMessage) {
                Intrinsics.checkNotNullParameter(rawMessage, "rawMessage");
                InAppChatFragment.EventsListener eventsListener = InAppChatFragment.this.getEventsListener();
                if (eventsListener != null) {
                    eventsListener.onChatRawMessageReceived(rawMessage);
                }
            }

            @Override
            public void onChatReconnected() {
                IbFragmentChatBinding y0;
                y0 = InAppChatFragment.this.y0();
                y0.ibLcChatInput.setEnabled(true);
                InAppChatFragment.EventsListener eventsListener = InAppChatFragment.this.getEventsListener();
                if (eventsListener != null) {
                    eventsListener.onChatReconnected();
                }
            }

            @Override
            public void onChatViewChanged(@NotNull InAppChatWidgetView widgetView) {
                Intrinsics.checkNotNullParameter(widgetView, "widgetView");
                InAppChatFragment.this.m0 = widgetView;
                InAppChatFragment.this.Y0(widgetView);
                InAppChatFragment.EventsListener eventsListener = InAppChatFragment.this.getEventsListener();
                if (eventsListener != null) {
                    eventsListener.onChatViewChanged(widgetView);
                }
            }

            @Override
            public void onChatWidgetInfoUpdated(@NotNull WidgetInfo widgetInfo) {
                Intrinsics.checkNotNullParameter(widgetInfo, "widgetInfo");
                InAppChatFragment.this.l0 = widgetInfo;
                InAppChatFragment.this.Z0(widgetInfo);
                MobileMessagingLogger.w("InAppChatFragment", "WidgetInfo updated " + widgetInfo);
                InAppChatFragment.EventsListener eventsListener = InAppChatFragment.this.getEventsListener();
                if (eventsListener != null) {
                    eventsListener.onChatWidgetInfoUpdated(widgetInfo);
                }
            }

            @Override
            public void onChatWidgetThemeChanged(@NotNull String widgetThemeName) {
                Intrinsics.checkNotNullParameter(widgetThemeName, "widgetThemeName");
                InAppChatFragment.this.n0 = widgetThemeName;
                InAppChatFragment.EventsListener eventsListener = InAppChatFragment.this.getEventsListener();
                if (eventsListener != null) {
                    eventsListener.onChatWidgetThemeChanged(widgetThemeName);
                }
            }
        });
        y0().ibLcChat.setErrorsHandler(new InAppChatView.ErrorsHandler() {
            @Override
            public void handlerError(@NotNull String error) {
                Intrinsics.checkNotNullParameter(error, "error");
                InAppChatFragment.this.getErrorsHandler().handlerError(error);
            }

            @Override
            public void handlerNoInternetConnectionError(boolean z) {
                InAppChatFragment.this.getErrorsHandler().handlerNoInternetConnectionError(z);
            }

            @Override
            public void handlerWidgetError(@NotNull String error) {
                Intrinsics.checkNotNullParameter(error, "error");
                InAppChatFragment.this.getErrorsHandler().handlerWidgetError(error);
            }
        });
        y0().ibLcChat.init(A0().getLifecycle());
    }

    public final void F0(boolean z) {
        b1(this, null, new d(z, this), 1, null);
    }

    public final void G0() {
        final InAppChatInputView inAppChatInputView = y0().ibLcChatInput;
        inAppChatInputView.setSendButtonClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                InAppChatFragment.H0(InAppChatInputView.this, this, view);
            }
        });
    }

    public final void I0() {
        y0().ibLcChatInput.addInputTextChangeListener(new TextWatcher() {
            @Override
            public void afterTextChanged(@NotNull Editable s) {
                InAppChatInputFinishChecker inAppChatInputFinishChecker;
                Handler handler;
                InAppChatInputFinishChecker inAppChatInputFinishChecker2;
                Intrinsics.checkNotNullParameter(s, "s");
                inAppChatInputFinishChecker = InAppChatFragment.this.p0;
                inAppChatInputFinishChecker.setInputValue(s.toString());
                handler = InAppChatFragment.this.q0;
                inAppChatInputFinishChecker2 = InAppChatFragment.this.p0;
                handler.postDelayed(inAppChatInputFinishChecker2, 250L);
            }

            @Override
            public void beforeTextChanged(@NotNull CharSequence s, int i2, int i3, int i4) {
                Intrinsics.checkNotNullParameter(s, "s");
            }

            @Override
            public void onTextChanged(@NotNull CharSequence s, int i2, int i3, int i4) {
                Handler handler;
                InAppChatInputFinishChecker inAppChatInputFinishChecker;
                IbFragmentChatBinding y0;
                Intrinsics.checkNotNullParameter(s, "s");
                handler = InAppChatFragment.this.q0;
                inAppChatInputFinishChecker = InAppChatFragment.this.p0;
                handler.removeCallbacks(inAppChatInputFinishChecker);
                y0 = InAppChatFragment.this.y0();
                y0.ibLcChatInput.setSendButtonEnabled(s.length() > 0);
            }
        });
        y0().ibLcChatInput.setInputFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public final void onFocusChange(View view, boolean z) {
                InAppChatFragment.J0(InAppChatFragment.this, view, z);
            }
        });
    }

    public final void K0(boolean z) {
        b1(this, null, new e(z, this), 1, null);
    }

    public final boolean M0() {
        return M.a.a(requireContext(), "android.permission.CAMERA") == 0;
    }

    public final void N0() {
        b1(this, null, g.a, 1, null);
        InAppChatWidgetView inAppChatWidgetView = this.m0;
        if (!isMultiThread() || inAppChatWidgetView == null) {
            w0();
        }
        switch (WhenMappings.$EnumSwitchMapping$0[inAppChatWidgetView.ordinal()]) {
            case 1:
            case 2:
            case WebSettingsBoundaryInterface.AttributionBehavior.APP_SOURCE_AND_APP_TRIGGER:
                w0();
                break;
            case 4:
            case 5:
            case 6:
                showThreadList();
                break;
        }
    }

    public final Intent[] O0() {
        PackageManager packageManager = requireActivity().getPackageManager();
        Intrinsics.checkNotNullExpressionValue(packageManager, "requireActivity().packageManager");
        ArrayList arrayList = new ArrayList();
        Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
        int i2 = Build.VERSION.SDK_INT;
        Uri outputImageUri = i2 < 29 ? InAppChatAttachmentHelper.getOutputImageUri(requireActivity()) : InAppChatAttachmentHelper.getOutputImageUrlAPI29(requireActivity());
        this.j0 = outputImageUri;
        intent.putExtra("output", outputImageUri);
        if (intent.resolveActivity(packageManager) != null && this.j0 != null) {
            arrayList.add(intent);
        }
        Intent intent2 = new Intent("android.media.action.VIDEO_CAPTURE");
        if (i2 > 30) {
            Uri outputVideoUrl = InAppChatAttachmentHelper.getOutputVideoUrl(requireActivity());
            this.k0 = outputVideoUrl;
            intent2.putExtra("output", outputVideoUrl);
        }
        if (intent2.resolveActivity(packageManager) != null) {
            arrayList.add(intent2);
        }
        return (Intent[]) arrayList.toArray(new Intent[0]);
    }

    public final Intent P0() {
        Intent intent = new Intent("android.intent.action.GET_CONTENT");
        intent.addCategory("android.intent.category.OPENABLE");
        intent.setType("*/*");
        return intent;
    }

    public final void Q0() {
        this.o0.remove();
    }

    public final void R0() {
        if (this.w0) {
            if (this.g0 != 0) {
                ViewUtilsKt.setStatusBarColor(requireActivity(), Integer.valueOf(this.g0));
            }
            Boolean bool = this.h0;
            if (bool != null) {
                ViewUtilsKt.setLightStatusBarMode(requireActivity(), bool.booleanValue());
            }
        }
    }

    public final void S0() {
        if (this.x0) {
            this.q0.removeCallbacks(this.p0);
            this.q0.post(this.p0);
        }
    }

    public final void T0(boolean z) {
        b1(this, null, new l(z), 1, null);
    }

    public final void U0() {
        new a.a(requireContext(), R.style.IB_Chat_AlertDialog).r(R.string.ib_chat_permissions_not_granted_title).g(R.string.ib_chat_permissions_not_granted_message).d(false).i(org.infobip.mobile.messaging.resources.R.string.mm_button_cancel, new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i2) {
                InAppChatFragment.V0(InAppChatFragment.this, dialogInterface, i2);
            }
        }).o(org.infobip.mobile.messaging.resources.R.string.mm_button_settings, new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i2) {
                InAppChatFragment.W0(InAppChatFragment.this, dialogInterface, i2);
            }
        }).u();
    }

    public final EventsListener X0(final InAppChatEventsListener inAppChatEventsListener) {
        return new EventsListener() {
            @Override
            public boolean onAttachmentPreviewOpened(String str, String str2, String str3) {
                return false;
            }

            @Override
            public void onChatControlsVisibilityChanged(boolean z) {
                InAppChatEventsListener.this.onChatControlsVisibilityChanged(z);
            }

            @Override
            public void onChatDisconnected() {
                InAppChatEventsListener.this.onChatDisconnected();
            }

            @Override
            public void onChatLoaded(boolean z) {
                InAppChatEventsListener.this.onChatLoaded(z);
            }

            @Override
            public void onChatRawMessageReceived(@NotNull String rawMessage) {
                Intrinsics.checkNotNullParameter(rawMessage, "rawMessage");
                InAppChatEventsListener.this.onChatRawMessageReceived(rawMessage);
            }

            @Override
            public void onChatReconnected() {
                InAppChatEventsListener.this.onChatReconnected();
            }

            @Override
            public void onChatViewChanged(@NotNull InAppChatWidgetView widgetView) {
                Intrinsics.checkNotNullParameter(widgetView, "widgetView");
                InAppChatEventsListener.this.onChatViewChanged(widgetView);
            }

            @Override
            public void onChatWidgetInfoUpdated(@NotNull WidgetInfo widgetInfo) {
                Intrinsics.checkNotNullParameter(widgetInfo, "widgetInfo");
                InAppChatEventsListener.this.onChatWidgetInfoUpdated(widgetInfo);
            }

            @Override
            public void onChatWidgetThemeChanged(@NotNull String widgetThemeName) {
                Intrinsics.checkNotNullParameter(widgetThemeName, "widgetThemeName");
                InAppChatEventsListener.this.onChatWidgetThemeChanged(widgetThemeName);
            }

            @Override
            public void onExitChatPressed() {
            }
        };
    }

    public final void Y0(InAppChatWidgetView inAppChatWidgetView) {
        if (this.x0) {
            if (!isMultiThread()) {
                T0(true);
                return;
            }
            switch (WhenMappings.$EnumSwitchMapping$0[inAppChatWidgetView.ordinal()]) {
                case 1:
                case 2:
                case 5:
                case 6:
                    T0(false);
                    break;
                case WebSettingsBoundaryInterface.AttributionBehavior.APP_SOURCE_AND_APP_TRIGGER:
                case 4:
                    T0(true);
                    break;
            }
        }
    }

    public final void Z0(WidgetInfo widgetInfo) {
        u0(widgetInfo);
        s0(widgetInfo);
        if (isMultiThread()) {
            return;
        }
        T0(true);
    }

    public final void a1(kotlin.jvm.functions.Function0 r2, kotlin.jvm.functions.Function1 r3) {
        throw new UnsupportedOperationException("Method not decompiled: org.infobip.mobile.messaging.chat.view.InAppChatFragment.a1(kotlin.jvm.functions.Function0, kotlin.jvm.functions.Function1):void");
    }

    @NotNull
    public Context getContext() {
        t context = super.getContext();
        if (context == null) {
            context = requireActivity();
        }
        Intrinsics.checkNotNullExpressionValue(context, "super.getContext() ?: requireActivity()");
        return new n.d(context, InAppChatThemeResolver.getChatViewTheme(context));
    }

    @NotNull
    public final ErrorsHandler getDefaultErrorsHandler() {
        return this.u0;
    }

    public final boolean getDisconnectChatWhenHidden() {
        return this.z0;
    }

    @NotNull
    public final ErrorsHandler getErrorsHandler() {
        return this.v0;
    }

    public final EventsListener getEventsListener() {
        return this.t0;
    }

    public final boolean getHandleBackPress() {
        return this.A0;
    }

    public final InAppChatActionBarProvider getInAppChatActionBarProvider() {
        InAppChatActionBarProvider inAppChatActionBarProvider = this.y0;
        if (inAppChatActionBarProvider != null) {
            return inAppChatActionBarProvider;
        }
        InAppChatActionBarProvider requireActivity = requireActivity();
        if (requireActivity instanceof InAppChatActionBarProvider) {
            return requireActivity;
        }
        return null;
    }

    public final boolean getWithInput() {
        return this.x0;
    }

    public final boolean getWithToolbar() {
        return this.w0;
    }

    public final boolean isMultiThread() {
        InAppChatView inAppChatView;
        IbFragmentChatBinding ibFragmentChatBinding = this.f0;
        if (ibFragmentChatBinding == null || (inAppChatView = ibFragmentChatBinding.ibLcChat) == null) {
            return false;
        }
        return inAppChatView.isMultiThread();
    }

    public final void navigateBackOrCloseChat() {
        N0();
    }

    @Override
    public void onAttachmentChooserResult(@NotNull f.a result) {
        Intrinsics.checkNotNullParameter(result, "result");
        A0().setEnabled(true);
        if (result.c() != -1) {
            x0();
        } else {
            Intent b2 = result.b();
            InAppChatAttachmentHelper.makeAttachment(requireActivity(), b2, z0(b2), this.B0);
        }
    }

    @Override
    public void onCameraPermissionResult(boolean z) {
        if (z) {
            v0(true);
        } else {
            U0();
        }
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        f.d activityResultRegistry = requireActivity().getActivityResultRegistry();
        Intrinsics.checkNotNullExpressionValue(activityResultRegistry, "requireActivity().activityResultRegistry");
        this.s0 = new InAppChatActivityResultDelegateImpl(activityResultRegistry, this);
        androidx.lifecycle.j lifecycle = getLifecycle();
        androidx.lifecycle.m mVar = this.s0;
        if (mVar == null) {
            Intrinsics.r("activityResultDelegate");
            mVar = null;
        }
        lifecycle.addObserver(mVar);
    }

    @NotNull
    public View onCreateView(@NotNull LayoutInflater inflater, ViewGroup viewGroup, Bundle bundle) {
        Intrinsics.checkNotNullParameter(inflater, "inflater");
        Context requireContext = requireContext();
        Context requireContext2 = requireContext();
        Intrinsics.checkNotNullExpressionValue(requireContext2, "requireContext()");
        IbFragmentChatBinding inflate = IbFragmentChatBinding.inflate(inflater.cloneInContext(new n.d(requireContext, InAppChatThemeResolver.getChatViewTheme(requireContext2))), viewGroup, false);
        this.f0 = inflate;
        ConstraintLayout root = inflate.getRoot();
        Intrinsics.checkNotNullExpressionValue(root, "inflate(\n            inf…so { _binding = it }.root");
        return root;
    }

    public void onDestroyView() {
        super.onDestroyView();
        R0();
        Q0();
        y0().ibLcChat.setEventsListener(null);
        this.f0 = null;
        this.r0 = null;
    }

    public void onHiddenChanged(boolean z) {
        super.onHiddenChanged(z);
        if (this.z0) {
            A0().setState(z ? j.b.c : j.b.e);
        }
        if (!z) {
            K0(this.w0);
            WidgetInfo widgetInfo = this.l0;
            if (widgetInfo != null) {
                Z0(widgetInfo);
            }
        }
        this.o0.setEnabled(!isHidden());
    }

    public void onPause() {
        super.onPause();
        S0();
    }

    @Override
    public void onSettingsResult(@NotNull f.a result) {
        Intrinsics.checkNotNullParameter(result, "result");
        MobileMessagingLogger.d("InAppChatFragment", "Settings intent result " + result.c());
    }

    public void onViewCreated(@NotNull View view, Bundle bundle) {
        Intrinsics.checkNotNullParameter(view, "view");
        super.onViewCreated(view, bundle);
        if (isHidden()) {
            return;
        }
        LocalizationUtils.Companion companion = LocalizationUtils.Companion;
        Context requireContext = requireContext();
        Intrinsics.checkNotNullExpressionValue(requireContext, "requireContext()");
        this.i0 = companion.getInstance(requireContext);
        A0();
        L0();
        D0();
    }

    @SuppressLint({"UnsupportedChromeOsCameraSystemFeature"})
    public final void requestCameraPermissionIfNeeded() {
        boolean hasSystemFeature = requireActivity().getPackageManager().hasSystemFeature("android.hardware.camera.any");
        Object systemService = requireContext().getSystemService("camera");
        Intrinsics.d(systemService, "null cannot be cast to non-null type android.hardware.camera2.CameraManager");
        CameraManager cameraManager = (CameraManager) systemService;
        if (hasSystemFeature) {
            String[] cameraIdList = cameraManager.getCameraIdList();
            Intrinsics.checkNotNullExpressionValue(cameraIdList, "cameraManager.cameraIdList");
            if (!(!(cameraIdList.length == 0)) || M0()) {
                return;
            }
            if (shouldShowRequestPermissionRationale("android.permission.CAMERA")) {
                U0();
                return;
            }
            InAppChatFragmentActivityResultDelegate inAppChatFragmentActivityResultDelegate = this.s0;
            if (inAppChatFragmentActivityResultDelegate == null) {
                Intrinsics.r("activityResultDelegate");
                inAppChatFragmentActivityResultDelegate = null;
            }
            inAppChatFragmentActivityResultDelegate.requestCameraPermission();
        }
    }

    public final void s0(WidgetInfo widgetInfo) {
        b1(this, null, new a(widgetInfo), 1, null);
    }

    public final void sendChatMessage(String str) throws IllegalArgumentException {
        sendChatMessage$default(this, str, null, 2, null);
    }

    public final void sendChatMessageDraft(@NotNull String draft) {
        Intrinsics.checkNotNullParameter(draft, "draft");
        b1(this, null, new i(draft), 1, null);
    }

    public final void sendContextualData(@NotNull String data, boolean z) {
        Intrinsics.checkNotNullParameter(data, "data");
        sendContextualData(data, z ? MultithreadStrategy.ALL : MultithreadStrategy.ACTIVE);
    }

    public final void setDisconnectChatWhenHidden(boolean z) {
        this.z0 = z;
    }

    public final void setErrorsHandler(@NotNull ErrorsHandler errorsHandler) {
        Intrinsics.checkNotNullParameter(errorsHandler, "<set-?>");
        this.v0 = errorsHandler;
    }

    public final void setEventsListener(EventsListener eventsListener) {
        this.t0 = eventsListener;
    }

    public final void setHandleBackPress(boolean z) {
        this.A0 = z;
    }

    public final void setInAppChatActionBarProvider(InAppChatActionBarProvider inAppChatActionBarProvider) {
        this.y0 = inAppChatActionBarProvider;
    }

    public final void setLanguage(@NotNull Locale locale) {
        Intrinsics.checkNotNullParameter(locale, "locale");
        MobileMessagingLogger.d("InAppChatFragment", "setLanguage(" + locale + ')');
        b1(this, null, new m(locale), 1, null);
    }

    public final void setWidgetTheme(@NotNull String widgetThemeName) {
        Intrinsics.checkNotNullParameter(widgetThemeName, "widgetThemeName");
        b1(this, null, new n(widgetThemeName), 1, null);
    }

    public final void setWithInput(boolean z) {
        this.x0 = z;
        if (this.f0 != null) {
            F0(z);
        }
    }

    public final void setWithToolbar(boolean z) {
        this.w0 = z;
        if (this.f0 != null) {
            K0(z);
        }
    }

    public final void showThreadList() {
        b1(this, null, o.a, 1, null);
    }

    public final void t0(InAppChatToolbarStyle inAppChatToolbarStyle) {
        if (this.w0) {
            t requireActivity = requireActivity();
            Integer statusBarColor = ViewUtilsKt.getStatusBarColor(requireActivity);
            int intValue = statusBarColor != null ? statusBarColor.intValue() : 0;
            if (intValue != inAppChatToolbarStyle.getStatusBarBackgroundColor()) {
                this.g0 = intValue;
            }
            ViewUtilsKt.setStatusBarColor(requireActivity, Integer.valueOf(inAppChatToolbarStyle.getStatusBarBackgroundColor()));
            Boolean isLightStatusBarMode = ViewUtilsKt.isLightStatusBarMode(requireActivity);
            if (!Intrinsics.a(isLightStatusBarMode, Boolean.valueOf(!inAppChatToolbarStyle.getLightStatusBarIcons()))) {
                this.h0 = isLightStatusBarMode;
            }
            ViewUtilsKt.setLightStatusBarMode(requireActivity, !inAppChatToolbarStyle.getLightStatusBarIcons());
        }
    }

    public final void u0(WidgetInfo widgetInfo) {
        StyleFactory.Companion companion = StyleFactory.Companion;
        Context requireContext = requireContext();
        Intrinsics.checkNotNullExpressionValue(requireContext, "requireContext()");
        InAppChatToolbarStyle chatToolbarStyle = StyleFactory.Companion.create$default(companion, requireContext, null, widgetInfo, 2, null).chatToolbarStyle();
        b1(this, null, new b(chatToolbarStyle), 1, null);
        t0(chatToolbarStyle);
    }

    public final void v0(boolean z) {
        Intent intent = new Intent("android.intent.action.CHOOSER");
        intent.putExtra("android.intent.extra.INTENT", P0());
        if (z) {
            intent.putExtra("android.intent.extra.INITIAL_INTENTS", O0());
        }
        A0().setEnabled(false);
        InAppChatFragmentActivityResultDelegate inAppChatFragmentActivityResultDelegate = this.s0;
        if (inAppChatFragmentActivityResultDelegate == null) {
            Intrinsics.r("activityResultDelegate");
            inAppChatFragmentActivityResultDelegate = null;
        }
        inAppChatFragmentActivityResultDelegate.openAttachmentChooser(intent);
    }

    public final void w0() {
        InAppChatActionBarProvider inAppChatActionBarProvider;
        i.a originalSupportActionBar;
        R0();
        if (this.w0 && (inAppChatActionBarProvider = getInAppChatActionBarProvider()) != null && (originalSupportActionBar = inAppChatActionBarProvider.getOriginalSupportActionBar()) != null) {
            originalSupportActionBar.A();
        }
        this.o0.setEnabled(false);
        InAppChatActionBarProvider inAppChatActionBarProvider2 = getInAppChatActionBarProvider();
        if (inAppChatActionBarProvider2 != null) {
            inAppChatActionBarProvider2.onInAppChatBackPressed();
        }
        EventsListener eventsListener = this.t0;
        if (eventsListener != null) {
            eventsListener.onExitChatPressed();
        }
    }

    public final void x0() {
        InAppChatAttachmentHelper.deleteEmptyFileByUri(getContext(), this.j0);
        InAppChatAttachmentHelper.deleteEmptyFileByUri(getContext(), this.k0);
    }

    public final IbFragmentChatBinding y0() {
        IbFragmentChatBinding ibFragmentChatBinding = this.f0;
        Intrinsics.c(ibFragmentChatBinding);
        return ibFragmentChatBinding;
    }

    public final Uri z0(Intent intent) {
        Uri data = intent != null ? intent.getData() : null;
        String mimeType = data != null ? InAppChatMobileAttachment.getMimeType(requireActivity(), intent, data) : null;
        if (this.j0 != null && (Intrinsics.a(mimeType, InAppChatAttachmentHelper.MIME_TYPE_IMAGE_JPEG) || Intrinsics.a(InAppChatAttachmentHelper.isUriFileEmpty(requireContext(), this.j0), Boolean.FALSE))) {
            return this.j0;
        }
        if (this.k0 == null) {
            return null;
        }
        if (Intrinsics.a(mimeType, InAppChatAttachmentHelper.MIME_TYPE_VIDEO_MP_4) || Intrinsics.a(InAppChatAttachmentHelper.isUriFileEmpty(requireContext(), this.k0), Boolean.FALSE)) {
            return this.k0;
        }
        return null;
    }

    public final void sendChatMessage(String str, InAppChatMobileAttachment inAppChatMobileAttachment) throws IllegalArgumentException {
        b1(this, null, new h(str, inAppChatMobileAttachment), 1, null);
    }

    public final void sendContextualData(@NotNull String data, @NotNull MultithreadStrategy flag) {
        Intrinsics.checkNotNullParameter(data, "data");
        Intrinsics.checkNotNullParameter(flag, "flag");
        a1(new j(data, flag), new k(data, flag));
    }
}