package ca.canadapost.module.selfscan.tnc;

import android.app.Activity;
import android.app.Dialog;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.h0;
import androidx.core.view.h1;
import androidx.core.view.s0;
import androidx.fragment.app.r;
import androidx.lifecycle.c1;
import androidx.lifecycle.d1;
import androidx.lifecycle.e1;
import androidx.lifecycle.g0;
import androidx.lifecycle.u;
import androidx.lifecycle.z0;
import bf.q;
import ca.canadapost.core.data.model.CoreConstants;
import ca.canadapost.core.data.model.RepositoryError;
import ca.canadapost.core.data.model.ResultWrapper;
import ca.canadapost.module.selfscan.tnc.SelfScanAcceptTnCDialogFragment;
import kotlin.Metadata;
import kotlin.jvm.internal.n;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.v;
import l8.h;
import rm.c0;
import rm.i;
import rm.n0;
import rm.o;
import u7.x;
import w8.l;
import w8.p0;
import w8.y;

@Metadata(d1 = {"\u0000t\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\n\u0018\u00002\u00020\u00012\b\u0012\u0004\u0012\u00020\u00030\u00022\u00020\u0004B\u0007¢\u0006\u0004\b4\u00105J5\u0010\u0010\u001a\u00020\u000f2\u0006\u0010\u0006\u001a\u00020\u00052\b\u0010\b\u001a\u0004\u0018\u00010\u00072\b\u0010\n\u001a\u0004\u0018\u00010\t2\u0006\u0010\f\u001a\u00020\u000b2\u0006\u0010\u000e\u001a\u00020\rH\u0096\u0001J\u0019\u0010\u0016\u001a\u00020\u00152\u0006\u0010\u0012\u001a\u00020\u00112\u0006\u0010\u0014\u001a\u00020\u0013H\u0096\u0001J\u0019\u0010\u001b\u001a\u00020\u00152\u0006\u0010\u0018\u001a\u00020\u00172\u0006\u0010\u001a\u001a\u00020\u0019H\u0096\u0001J\u0019\u0010\u001c\u001a\u00020\u00152\u0006\u0010\u0014\u001a\u00020\u00132\u0006\u0010\u001a\u001a\u00020\u0019H\u0096\u0001J$\u0010\u001d\u001a\u00020\u000f2\u0006\u0010\u0006\u001a\u00020\u00052\b\u0010\b\u001a\u0004\u0018\u00010\u00072\b\u0010\n\u001a\u0004\u0018\u00010\tH\u0016J\u001a\u0010\u001f\u001a\u00020\u00152\u0006\u0010\u001e\u001a\u00020\u000f2\b\u0010\n\u001a\u0004\u0018\u00010\tH\u0016J\n\u0010!\u001a\u0004\u0018\u00010 H\u0016J\b\u0010#\u001a\u00020\"H\u0016R\"\u0010+\u001a\u00020$8\u0006@\u0006X\u0087.¢\u0006\u0012\n\u0004\b%\u0010&\u001a\u0004\b'\u0010(\"\u0004\b)\u0010*R\u001b\u0010\u000e\u001a\u00020,8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b-\u0010.\u001a\u0004\b/\u00100R\u0014\u00103\u001a\u00020\u00038\u0016X\u0096\u0005¢\u0006\u0006\u001a\u0004\b1\u00102¨\u00066"}, d2 = {"Lca/canadapost/module/selfscan/tnc/SelfScanAcceptTnCDialogFragment;", "Lca/canadapost/core/common/ui/b;", "", "Lbf/q;", "Lw8/p0;", "Landroid/view/LayoutInflater;", "inflater", "Landroid/view/ViewGroup;", "container", "Landroid/os/Bundle;", "savedInstanceState", "Landroidx/lifecycle/u;", "viewLifecycleOwner", "Landroidx/lifecycle/z0;", "viewModel", "Landroid/view/View;", "K", "Ll8/h;", "spinnerVM", "Landroidx/fragment/app/f;", "fragment", "Lrm/n0;", "G", "Landroid/app/Activity;", "activity", "Ll8/h$b;", "event", "c", "p", "onCreateView", "view", "onViewCreated", "Landroidx/appcompat/widget/Toolbar;", "C", "", "B", "Landroidx/lifecycle/c1$c;", "r", "Landroidx/lifecycle/c1$c;", "J", "()Landroidx/lifecycle/c1$c;", "setViewModelFactory", "(Landroidx/lifecycle/c1$c;)V", "viewModelFactory", "Ljf/c;", "s", "Lrm/o;", "I", "()Ljf/c;", "H", "()Lbf/q;", "binding", "<init>", "()V", "selfscan_productionRelease"}, k = 1, mv = {1, 9, 0})
/* loaded from: classes4.dex */
public final class SelfScanAcceptTnCDialogFragment extends ca.canadapost.core.common.ui.b implements p0 {

    /* renamed from: r, reason: collision with root package name and from kotlin metadata */
    public c1.c viewModelFactory;

    /* renamed from: p, reason: collision with root package name */
    private final /* synthetic */ x f10771p = new x(af.d.f357i);

    /* renamed from: q, reason: collision with root package name */
    private final /* synthetic */ l f10772q = new l();

    /* renamed from: s, reason: collision with root package name and from kotlin metadata */
    private final o viewModel = androidx.fragment.app.p0.a(this, kotlin.jvm.internal.p0.b(jf.c.class), new f(new e(this)), new g());

    /* loaded from: classes4.dex */
    static final class a extends v implements dn.l {
        a() {
            super(1);
        }

        public final void a(n0 n0Var) {
            Dialog dialog = SelfScanAcceptTnCDialogFragment.this.getDialog();
            if (dialog != null) {
                dialog.dismiss();
            }
        }

        @Override // dn.l
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            a((n0) obj);
            return n0.f34904a;
        }
    }

    /* loaded from: classes4.dex */
    static final class b extends v implements dn.l {

        /* loaded from: classes4.dex */
        public /* synthetic */ class a {

            /* renamed from: a, reason: collision with root package name */
            public static final /* synthetic */ int[] f10777a;

            static {
                int[] iArr = new int[RepositoryError.values().length];
                try {
                    iArr[RepositoryError.NoNetworkError.ordinal()] = 1;
                } catch (NoSuchFieldError unused) {
                }
                f10777a = iArr;
            }
        }

        b() {
            super(1);
        }

        public final void a(ResultWrapper.Error error) {
            y.c(SelfScanAcceptTnCDialogFragment.this, a.f10777a[error.getError().ordinal()] == 1 ? CoreConstants.NO_NETWORK_CONNECTION : CoreConstants.SAD_STEVE, CoreConstants.AGREE.TRUE.getValue());
        }

        @Override // dn.l
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            a((ResultWrapper.Error) obj);
            return n0.f34904a;
        }
    }

    /* loaded from: classes4.dex */
    static final class c extends v implements dn.l {
        c() {
            super(1);
        }

        public final void a(n0 n0Var) {
            x4.d.a(SelfScanAcceptTnCDialogFragment.this).U();
            SelfScanAcceptTnCDialogFragment selfScanAcceptTnCDialogFragment = SelfScanAcceptTnCDialogFragment.this;
            Boolean bool = Boolean.TRUE;
            r.c(selfScanAcceptTnCDialogFragment, "SELF_SCAN_TnC_ACCEPTED_SCAN_BARCODE", androidx.core.os.c.a(c0.a(CoreConstants.ARG_TnC_ACCEPTED, bool)));
            r.c(SelfScanAcceptTnCDialogFragment.this, "SELF_SCAN_TnC_ACCEPTED_MANUAL_TRACKING", androidx.core.os.c.a(c0.a(CoreConstants.ARG_TnC_ACCEPTED, bool)));
        }

        @Override // dn.l
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            a((n0) obj);
            return n0.f34904a;
        }
    }

    /* loaded from: classes4.dex */
    static final class d implements g0, n {

        /* renamed from: a, reason: collision with root package name */
        private final /* synthetic */ dn.l f10779a;

        d(dn.l function) {
            t.g(function, "function");
            this.f10779a = function;
        }

        @Override // kotlin.jvm.internal.n
        public final i b() {
            return this.f10779a;
        }

        @Override // androidx.lifecycle.g0
        public final /* synthetic */ void d(Object obj) {
            this.f10779a.invoke(obj);
        }

        public final boolean equals(Object obj) {
            if ((obj instanceof g0) && (obj instanceof n)) {
                return t.b(b(), ((n) obj).b());
            }
            return false;
        }

        public final int hashCode() {
            return b().hashCode();
        }
    }

    /* loaded from: classes4.dex */
    public static final class e extends v implements dn.a {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ androidx.fragment.app.f f10780p;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public e(androidx.fragment.app.f fVar) {
            super(0);
            this.f10780p = fVar;
        }

        @Override // dn.a
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final androidx.fragment.app.f invoke() {
            return this.f10780p;
        }
    }

    /* loaded from: classes4.dex */
    public static final class f extends v implements dn.a {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ dn.a f10781p;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public f(dn.a aVar) {
            super(0);
            this.f10781p = aVar;
        }

        @Override // dn.a
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final d1 invoke() {
            d1 viewModelStore = ((e1) this.f10781p.invoke()).getViewModelStore();
            t.f(viewModelStore, "ownerProducer().viewModelStore");
            return viewModelStore;
        }
    }

    /* loaded from: classes4.dex */
    static final class g extends v implements dn.a {
        g() {
            super(0);
        }

        @Override // dn.a
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final c1.c invoke() {
            return SelfScanAcceptTnCDialogFragment.this.J();
        }
    }

    private final jf.c I() {
        return (jf.c) this.viewModel.getValue();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final h1 L(View v10, h1 windowInsets) {
        t.g(v10, "v");
        t.g(windowInsets, "windowInsets");
        androidx.core.graphics.b f10 = windowInsets.f(h1.l.f());
        t.f(f10, "getInsets(...)");
        ViewGroup.LayoutParams layoutParams = v10.getLayoutParams();
        if (layoutParams == null) {
            throw new NullPointerException("null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
        }
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
        marginLayoutParams.bottomMargin = f10.f3727d;
        v10.setLayoutParams(marginLayoutParams);
        return h1.f3850b;
    }

    @Override // ca.canadapost.core.common.ui.b
    public String B() {
        String string = getString(af.f.f377q);
        t.f(string, "getString(...)");
        return string;
    }

    @Override // ca.canadapost.core.common.ui.b
    public Toolbar C() {
        u7.c appBarBinding = H().C.getAppBarBinding();
        if (appBarBinding != null) {
            return appBarBinding.B;
        }
        return null;
    }

    public void G(h spinnerVM, androidx.fragment.app.f fragment) {
        t.g(spinnerVM, "spinnerVM");
        t.g(fragment, "fragment");
        this.f10772q.b(spinnerVM, fragment);
    }

    public q H() {
        return (q) this.f10771p.b();
    }

    public final c1.c J() {
        c1.c cVar = this.viewModelFactory;
        if (cVar != null) {
            return cVar;
        }
        t.y("viewModelFactory");
        return null;
    }

    public View K(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState, u viewLifecycleOwner, z0 viewModel) {
        t.g(inflater, "inflater");
        t.g(viewLifecycleOwner, "viewLifecycleOwner");
        t.g(viewModel, "viewModel");
        return this.f10771p.c(inflater, container, savedInstanceState, viewLifecycleOwner, viewModel);
    }

    @Override // w8.p0
    public void c(Activity activity, h.b event) {
        t.g(activity, "activity");
        t.g(event, "event");
        this.f10772q.c(activity, event);
    }

    @Override // androidx.fragment.app.f
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        t.g(inflater, "inflater");
        LayoutInflater from = LayoutInflater.from(getContext());
        t.f(from, "from(...)");
        u viewLifecycleOwner = getViewLifecycleOwner();
        t.f(viewLifecycleOwner, "getViewLifecycleOwner(...)");
        return K(from, null, savedInstanceState, viewLifecycleOwner, I());
    }

    @Override // ca.canadapost.core.common.ui.b, androidx.fragment.app.f
    public void onViewCreated(View view, Bundle bundle) {
        t.g(view, "view");
        super.onViewCreated(view, bundle);
        G(I(), this);
        jf.c I = I();
        I.U().j(getViewLifecycleOwner(), new d(new a()));
        I.t().j(getViewLifecycleOwner(), new d(new b()));
        I.T().j(getViewLifecycleOwner(), new d(new c()));
        if (Build.VERSION.SDK_INT >= 35) {
            s0.A0(H().B, new h0() { // from class: jf.a
                @Override // androidx.core.view.h0
                public final h1 a(View view2, h1 h1Var) {
                    h1 L;
                    L = SelfScanAcceptTnCDialogFragment.L(view2, h1Var);
                    return L;
                }
            });
        }
    }

    @Override // w8.p0
    public void p(androidx.fragment.app.f fragment, h.b event) {
        t.g(fragment, "fragment");
        t.g(event, "event");
        this.f10772q.p(fragment, event);
    }
}
