package ca.canadapost.module.login.linkemail;

import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import androidx.activity.p;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.lifecycle.c1;
import androidx.lifecycle.e1;
import androidx.lifecycle.g0;
import androidx.lifecycle.u;
import androidx.lifecycle.z0;
import ca.canadapost.core.common.customView.CpcTextInput;
import ca.canadapost.core.data.model.CoreConstants;
import ca.canadapost.core.data.model.RepositoryError;
import ca.canadapost.core.data.model.ResultWrapper;
import ca.canadapost.core.data.model.ValidationError;
import ca.canadapost.module.login.linkemail.LinkEmailClaimOtherUserFragment;
import com.google.android.gms.common.Scopes;
import com.google.firebase.messaging.Constants;
import d9.f;
import kotlin.Metadata;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.v;
import od.q0;
import rm.n0;
import rm.q;
import u7.x;
import vd.m;
import vd.n;
import w8.o;
import w8.y;

@Metadata(d1 = {"\u0000}\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\u0010\u000e\n\u0002\b\t\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\b\n*\u0001<\u0018\u00002\u00020\u00012\b\u0012\u0004\u0012\u00020\u00030\u00022\u00020\u0004B\u0007¢\u0006\u0004\bC\u0010DJ5\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\u001b\u0010\u0016\u001a\u00020\u00152\b\u0010\u0012\u001a\u0004\u0018\u00010\u00112\u0006\u0010\u0014\u001a\u00020\u0013H\u0096\u0001J#\u0010\u0019\u001a\u00020\u00152\u0006\u0010\u0017\u001a\u00020\u00152\b\u0010\u0018\u001a\u0004\u0018\u00010\u00152\u0006\u0010\u0014\u001a\u00020\u0013H\u0096\u0001J\u001b\u0010\u001a\u001a\u00020\u00152\b\u0010\u0012\u001a\u0004\u0018\u00010\u00112\u0006\u0010\u0014\u001a\u00020\u0013H\u0096\u0001J\u0019\u0010\u001b\u001a\u00020\u00152\u0006\u0010\u0017\u001a\u00020\u00152\u0006\u0010\u0014\u001a\u00020\u0013H\u0096\u0001J\u0011\u0010\u001c\u001a\u00020\u00152\u0006\u0010\u0014\u001a\u00020\u0013H\u0096\u0001J\u0011\u0010\u001d\u001a\u00020\u00152\u0006\u0010\u0014\u001a\u00020\u0013H\u0096\u0001J\u0011\u0010\u001e\u001a\u00020\u00152\u0006\u0010\u0014\u001a\u00020\u0013H\u0096\u0001J\u0019\u0010\"\u001a\u00020!2\u0006\u0010 \u001a\u00020\u001f2\u0006\u0010\u0014\u001a\u00020\u0013H\u0096\u0001J\u0019\u0010%\u001a\u00020!2\u0006\u0010$\u001a\u00020#2\u0006\u0010 \u001a\u00020\u001fH\u0096\u0001J\u0011\u0010&\u001a\u00020!2\u0006\u0010\u0014\u001a\u00020\u0013H\u0096\u0001J\u0019\u0010'\u001a\u00020!2\u0006\u0010$\u001a\u00020#2\u0006\u0010 \u001a\u00020\u001fH\u0096\u0001J\u001b\u0010)\u001a\u00020!2\b\u0010(\u001a\u0004\u0018\u00010\u00112\u0006\u0010\u0014\u001a\u00020\u0013H\u0096\u0001J$\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\tH\u0016J\u001a\u0010,\u001a\u00020!2\u0006\u0010+\u001a\u00020\u000f2\b\u0010\n\u001a\u0004\u0018\u00010\tH\u0016J\b\u0010.\u001a\u00020-H\u0016R\"\u00106\u001a\u00020/8\u0004@\u0004X\u0085.¢\u0006\u0012\n\u0004\b0\u00101\u001a\u0004\b2\u00103\"\u0004\b4\u00105R\u001b\u0010\u000e\u001a\u0002078BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b8\u00109\u001a\u0004\b:\u0010;R\u0014\u0010?\u001a\u00020<8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b=\u0010>R\u0014\u0010B\u001a\u00020\u00038\u0016X\u0096\u0005¢\u0006\u0006\u001a\u0004\b@\u0010A¨\u0006E"}, d2 = {"Lca/canadapost/module/login/linkemail/LinkEmailClaimOtherUserFragment;", "Lu8/b;", "", "Lod/q0;", "Lw8/o;", "Landroid/view/LayoutInflater;", "inflater", "Landroid/view/ViewGroup;", "container", "Landroid/os/Bundle;", "savedInstanceState", "Landroidx/lifecycle/u;", "viewLifecycleOwner", "Landroidx/lifecycle/z0;", "viewModel", "Landroid/view/View;", "K", "Lca/canadapost/core/data/model/ValidationError;", "validationError", "Landroid/content/Context;", "context", "", "m", "code", "message", "n", "i", "j", "h", "d", "a", "Lca/canadapost/core/data/model/ResultWrapper$Error;", Constants.IPC_BUNDLE_KEY_SEND_ERROR, "Lrm/n0;", "e", "Landroidx/fragment/app/f;", "fragment", "l", "o", "g", "valError", "k", "onCreateView", "view", "onViewCreated", "", "E", "Lvd/n;", "u", "Lvd/n;", "I", "()Lvd/n;", "setLinkEmailUpdateEmailViewModelFactory", "(Lvd/n;)V", "linkEmailUpdateEmailViewModelFactory", "Lvd/m;", "v", "Lrm/o;", "J", "()Lvd/m;", "ca/canadapost/module/login/linkemail/LinkEmailClaimOtherUserFragment$a", "w", "Lca/canadapost/module/login/linkemail/LinkEmailClaimOtherUserFragment$a;", "onBackPressedCallback", "H", "()Lod/q0;", "binding", "<init>", "()V", "login_productionRelease"}, k = 1, mv = {1, 9, 0})
/* loaded from: classes4.dex */
public final class LinkEmailClaimOtherUserFragment extends u8.b implements o {

    /* renamed from: s, reason: collision with root package name */
    private final /* synthetic */ x f10076s = new x(ld.k.f27962v);

    /* renamed from: t, reason: collision with root package name */
    private final /* synthetic */ w8.k f10077t = new w8.k(null, null, null, 7, null);

    /* renamed from: u, reason: collision with root package name and from kotlin metadata */
    protected n linkEmailUpdateEmailViewModelFactory;

    /* renamed from: v, reason: collision with root package name and from kotlin metadata */
    private final rm.o viewModel;

    /* renamed from: w, reason: collision with root package name and from kotlin metadata */
    private final a onBackPressedCallback;

    /* loaded from: classes4.dex */
    public static final class a extends p {
        a() {
            super(true);
        }

        @Override // androidx.activity.p
        public void d() {
            LinkEmailClaimOtherUserFragment.this.J().k0();
            j(false);
        }
    }

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

        /* JADX INFO: Access modifiers changed from: private */
        public static final void c(ConstraintLayout this_apply) {
            t.g(this_apply, "$this_apply");
            this_apply.performAccessibilityAction(64, null);
            this_apply.sendAccessibilityEvent(32768);
        }

        public final void b(Boolean bool) {
            t.d(bool);
            if (!bool.booleanValue() || LinkEmailClaimOtherUserFragment.this.H().B.getIsError()) {
                return;
            }
            final ConstraintLayout constraintLayout = LinkEmailClaimOtherUserFragment.this.H().C.D;
            new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { // from class: ca.canadapost.module.login.linkemail.b
                @Override // java.lang.Runnable
                public final void run() {
                    LinkEmailClaimOtherUserFragment.b.c(ConstraintLayout.this);
                }
            }, 100L);
        }

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

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

        /* JADX INFO: Access modifiers changed from: private */
        public static final void c(CpcTextInput this_apply) {
            t.g(this_apply, "$this_apply");
            this_apply.performAccessibilityAction(64, null);
            this_apply.sendAccessibilityEvent(32768);
        }

        public final void b(String str) {
            final CpcTextInput cpcTextInput = LinkEmailClaimOtherUserFragment.this.H().B;
            new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { // from class: ca.canadapost.module.login.linkemail.c
                @Override // java.lang.Runnable
                public final void run() {
                    LinkEmailClaimOtherUserFragment.c.c(CpcTextInput.this);
                }
            }, 100L);
        }

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

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

        public final void a(Boolean bool) {
            t.d(bool);
            if (bool.booleanValue()) {
                LinkEmailClaimOtherUserFragment.this.C();
                x4.d.a(LinkEmailClaimOtherUserFragment.this).M(ld.j.H);
            }
        }

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

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

        public final void a(n0 n0Var) {
            Bundle bundle = new Bundle();
            String str = (String) LinkEmailClaimOtherUserFragment.this.J().f0().f();
            if (str == null) {
                str = "";
            }
            bundle.putString(Scopes.EMAIL, str);
            f.a.c(LinkEmailClaimOtherUserFragment.this.J().Z(), "1-1 Email - Step 2 - 2nd user verification link request", null, 2, null);
            x4.d.a(LinkEmailClaimOtherUserFragment.this).N(ld.j.E, bundle);
        }

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

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

        /* JADX INFO: Access modifiers changed from: private */
        public static final void c(CheckBox this_apply) {
            t.g(this_apply, "$this_apply");
            this_apply.performAccessibilityAction(64, null);
            this_apply.sendAccessibilityEvent(32768);
        }

        public final void b(Boolean bool) {
            m J = LinkEmailClaimOtherUserFragment.this.J();
            t.d(bool);
            J.Q(bool.booleanValue());
            if (bool.booleanValue()) {
                final CheckBox checkBox = LinkEmailClaimOtherUserFragment.this.H().C.A;
                new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { // from class: ca.canadapost.module.login.linkemail.d
                    @Override // java.lang.Runnable
                    public final void run() {
                        LinkEmailClaimOtherUserFragment.f.c(checkBox);
                    }
                }, 100L);
            }
        }

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

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

        public final void a(Boolean bool) {
            x4.d.a(LinkEmailClaimOtherUserFragment.this).V(ld.j.G, false);
            LinkEmailClaimOtherUserFragment linkEmailClaimOtherUserFragment = LinkEmailClaimOtherUserFragment.this;
            linkEmailClaimOtherUserFragment.l(linkEmailClaimOtherUserFragment, new ResultWrapper.Error(null, null, RepositoryError.ServiceError, null, 8, null));
            m J = LinkEmailClaimOtherUserFragment.this.J();
            t.d(bool);
            J.Q(bool.booleanValue());
        }

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

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

        public final void a(Boolean bool) {
            x4.d.a(LinkEmailClaimOtherUserFragment.this).V(ld.j.G, false);
            LinkEmailClaimOtherUserFragment linkEmailClaimOtherUserFragment = LinkEmailClaimOtherUserFragment.this;
            linkEmailClaimOtherUserFragment.l(linkEmailClaimOtherUserFragment, new ResultWrapper.Error(null, null, RepositoryError.NoNetworkError, null, 8, null));
            m J = LinkEmailClaimOtherUserFragment.this.J();
            t.d(bool);
            J.Q(bool.booleanValue());
        }

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

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

        public final void a(n0 n0Var) {
            LinkEmailClaimOtherUserFragment.this.requireActivity().finish();
        }

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

    /* loaded from: classes4.dex */
    static final class j implements g0, kotlin.jvm.internal.n {

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

        j(dn.l function) {
            t.g(function, "function");
            this.f10090a = function;
        }

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

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

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

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

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

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

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

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

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

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

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ LinkEmailClaimOtherUserFragment f10093q;

        /* loaded from: classes4.dex */
        public static final class a implements c1.c {

            /* renamed from: b, reason: collision with root package name */
            final /* synthetic */ LinkEmailClaimOtherUserFragment f10094b;

            public a(LinkEmailClaimOtherUserFragment linkEmailClaimOtherUserFragment) {
                this.f10094b = linkEmailClaimOtherUserFragment;
            }

            @Override // androidx.lifecycle.c1.c
            public z0 a(Class modelClass) {
                t.g(modelClass, "modelClass");
                n I = this.f10094b.I();
                Bundle arguments = this.f10094b.getArguments();
                m a10 = I.a(arguments != null ? arguments.getString(Scopes.EMAIL, null) : null, false);
                t.e(a10, "null cannot be cast to non-null type U of ca.canadapost.core.common.utils.KotlinExtensionsKt.viewModels.<no name provided>.invoke.<no name provided>.create");
                return a10;
            }
        }

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public l(dn.a aVar, LinkEmailClaimOtherUserFragment linkEmailClaimOtherUserFragment) {
            super(0);
            this.f10092p = aVar;
            this.f10093q = linkEmailClaimOtherUserFragment;
        }

        @Override // dn.a
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final z0 invoke() {
            return new c1((e1) this.f10092p.invoke(), new a(this.f10093q)).a(m.class);
        }
    }

    public LinkEmailClaimOtherUserFragment() {
        rm.o a10;
        a10 = q.a(new l(new k(this), this));
        this.viewModel = a10;
        this.onBackPressedCallback = new a();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final m J() {
        return (m) this.viewModel.getValue();
    }

    @Override // u8.b
    public boolean E() {
        J().k0();
        return true;
    }

    public q0 H() {
        return (q0) this.f10076s.b();
    }

    protected final n I() {
        n nVar = this.linkEmailUpdateEmailViewModelFactory;
        if (nVar != null) {
            return nVar;
        }
        t.y("linkEmailUpdateEmailViewModelFactory");
        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.f10076s.c(inflater, container, savedInstanceState, viewLifecycleOwner, viewModel);
    }

    @Override // w8.o
    public String a(Context context) {
        t.g(context, "context");
        return this.f10077t.a(context);
    }

    @Override // w8.o
    public String d(Context context) {
        t.g(context, "context");
        return this.f10077t.d(context);
    }

    @Override // w8.o
    public void e(ResultWrapper.Error error, Context context) {
        t.g(error, "error");
        t.g(context, "context");
        this.f10077t.e(error, context);
    }

    @Override // w8.o
    public void g(androidx.fragment.app.f fragment, ResultWrapper.Error error) {
        t.g(fragment, "fragment");
        t.g(error, "error");
        this.f10077t.g(fragment, error);
    }

    @Override // w8.o
    public String h(Context context) {
        t.g(context, "context");
        return this.f10077t.h(context);
    }

    @Override // w8.o
    public String i(ValidationError validationError, Context context) {
        t.g(context, "context");
        return this.f10077t.i(validationError, context);
    }

    @Override // w8.o
    public String j(String code, Context context) {
        t.g(code, "code");
        t.g(context, "context");
        return this.f10077t.j(code, context);
    }

    @Override // w8.o
    public void k(ValidationError validationError, Context context) {
        t.g(context, "context");
        this.f10077t.k(validationError, context);
    }

    @Override // w8.o
    public void l(androidx.fragment.app.f fragment, ResultWrapper.Error error) {
        t.g(fragment, "fragment");
        t.g(error, "error");
        this.f10077t.l(fragment, error);
    }

    @Override // w8.o
    public String m(ValidationError validationError, Context context) {
        t.g(context, "context");
        return this.f10077t.m(validationError, context);
    }

    @Override // w8.o
    public String n(String code, String message, Context context) {
        t.g(code, "code");
        t.g(context, "context");
        return this.f10077t.n(code, message, context);
    }

    @Override // w8.o
    public void o(Context context) {
        t.g(context, "context");
        this.f10077t.o(context);
    }

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

    @Override // u8.b, androidx.fragment.app.f
    public void onViewCreated(View view, Bundle bundle) {
        androidx.activity.q onBackPressedDispatcher;
        t.g(view, "view");
        super.onViewCreated(view, bundle);
        J().S().j(getViewLifecycleOwner(), new j(new b()));
        J().g0().j(getViewLifecycleOwner(), new j(new c()));
        J().e0().j(getViewLifecycleOwner(), new j(new d()));
        J().d0().j(getViewLifecycleOwner(), new j(new e()));
        int i10 = ld.j.G;
        y.a(this, i10, "TNC_AGREED").j(getViewLifecycleOwner(), new j(new f()));
        y.b(this, i10, CoreConstants.NO_NETWORK_CONNECTION);
        y.b(this, i10, CoreConstants.SAD_STEVE);
        y.a(this, i10, CoreConstants.SAD_STEVE).j(getViewLifecycleOwner(), new j(new g()));
        y.a(this, i10, CoreConstants.NO_NETWORK_CONNECTION).j(getViewLifecycleOwner(), new j(new h()));
        androidx.fragment.app.k activity = getActivity();
        if (activity != null && (onBackPressedDispatcher = activity.getOnBackPressedDispatcher()) != null) {
            u viewLifecycleOwner = getViewLifecycleOwner();
            t.f(viewLifecycleOwner, "getViewLifecycleOwner(...)");
            onBackPressedDispatcher.i(viewLifecycleOwner, this.onBackPressedCallback);
        }
        J().c0().j(getViewLifecycleOwner(), new j(new i()));
    }
}
