package ca.canadapost.module.login.linkemail;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.activity.p;
import androidx.lifecycle.c1;
import androidx.lifecycle.e1;
import androidx.lifecycle.g0;
import androidx.lifecycle.u;
import androidx.lifecycle.z0;
import ca.canadapost.core.data.model.ResultWrapper;
import ca.canadapost.core.data.model.ValidationError;
import ca.canadapost.module.login.linkemail.LinkEmailVerifyEmailFragment;
import com.google.android.gms.common.Scopes;
import com.google.firebase.messaging.Constants;
import kotlin.Metadata;
import kotlin.jvm.internal.n;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.v;
import l8.h;
import od.y0;
import rm.n0;
import u7.x;
import vd.q;
import vd.r;
import w8.d0;
import w8.k;
import w8.l;
import w8.o;
import w8.p0;

@Metadata(d1 = {"\u0000¡\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0000\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\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\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\u0002\b\u0006\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\u0004\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\b\n*\u0001I\u0018\u00002\u00020\u00012\u00020\u00022\u00020\u00032\b\u0012\u0004\u0012\u00020\u00050\u0004B\u0007¢\u0006\u0004\bP\u0010QJ\u0019\u0010\u000b\u001a\u00020\n2\u0006\u0010\u0007\u001a\u00020\u00062\u0006\u0010\t\u001a\u00020\bH\u0096\u0001J\u0019\u0010\u0010\u001a\u00020\n2\u0006\u0010\r\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u000eH\u0096\u0001J\u0019\u0010\u0011\u001a\u00020\n2\u0006\u0010\t\u001a\u00020\b2\u0006\u0010\u000f\u001a\u00020\u000eH\u0096\u0001J\u0019\u0010\u0014\u001a\u00020\n2\u0006\u0010\u0013\u001a\u00020\u00122\u0006\u0010\t\u001a\u00020\bH\u0096\u0001J\u001b\u0010\u001a\u001a\u00020\u00192\b\u0010\u0016\u001a\u0004\u0018\u00010\u00152\u0006\u0010\u0018\u001a\u00020\u0017H\u0096\u0001J#\u0010\u001d\u001a\u00020\u00192\u0006\u0010\u001b\u001a\u00020\u00192\b\u0010\u001c\u001a\u0004\u0018\u00010\u00192\u0006\u0010\u0018\u001a\u00020\u0017H\u0096\u0001J\u001b\u0010\u001e\u001a\u00020\u00192\b\u0010\u0016\u001a\u0004\u0018\u00010\u00152\u0006\u0010\u0018\u001a\u00020\u0017H\u0096\u0001J\u0019\u0010\u001f\u001a\u00020\u00192\u0006\u0010\u001b\u001a\u00020\u00192\u0006\u0010\u0018\u001a\u00020\u0017H\u0096\u0001J\u0011\u0010 \u001a\u00020\u00192\u0006\u0010\u0018\u001a\u00020\u0017H\u0096\u0001J\u0011\u0010!\u001a\u00020\u00192\u0006\u0010\u0018\u001a\u00020\u0017H\u0096\u0001J\u0011\u0010\"\u001a\u00020\u00192\u0006\u0010\u0018\u001a\u00020\u0017H\u0096\u0001J\u0019\u0010$\u001a\u00020\n2\u0006\u0010\u0013\u001a\u00020#2\u0006\u0010\u0018\u001a\u00020\u0017H\u0096\u0001J\u0019\u0010%\u001a\u00020\n2\u0006\u0010\t\u001a\u00020\b2\u0006\u0010\u0013\u001a\u00020#H\u0096\u0001J\u0011\u0010&\u001a\u00020\n2\u0006\u0010\u0018\u001a\u00020\u0017H\u0096\u0001J\u0019\u0010'\u001a\u00020\n2\u0006\u0010\t\u001a\u00020\b2\u0006\u0010\u0013\u001a\u00020#H\u0096\u0001J\u001b\u0010)\u001a\u00020\n2\b\u0010(\u001a\u0004\u0018\u00010\u00152\u0006\u0010\u0018\u001a\u00020\u0017H\u0096\u0001J5\u00105\u001a\u0002042\u0006\u0010+\u001a\u00020*2\b\u0010-\u001a\u0004\u0018\u00010,2\b\u0010/\u001a\u0004\u0018\u00010.2\u0006\u00101\u001a\u0002002\u0006\u00103\u001a\u000202H\u0096\u0001J$\u00106\u001a\u0002042\u0006\u0010+\u001a\u00020*2\b\u0010-\u001a\u0004\u0018\u00010,2\b\u0010/\u001a\u0004\u0018\u00010.H\u0016J\u001a\u00108\u001a\u00020\n2\u0006\u00107\u001a\u0002042\b\u0010/\u001a\u0004\u0018\u00010.H\u0016J\b\u0010:\u001a\u000209H\u0016J\b\u0010;\u001a\u00020\nH\u0016R\"\u0010C\u001a\u00020<8\u0004@\u0004X\u0085.¢\u0006\u0012\n\u0004\b=\u0010>\u001a\u0004\b?\u0010@\"\u0004\bA\u0010BR\u001b\u00103\u001a\u00020D8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\bE\u0010F\u001a\u0004\bG\u0010HR\u0014\u0010L\u001a\u00020I8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\bJ\u0010KR\u0014\u0010O\u001a\u00020\u00058\u0016X\u0096\u0005¢\u0006\u0006\u001a\u0004\bM\u0010N¨\u0006R"}, d2 = {"Lca/canadapost/module/login/linkemail/LinkEmailVerifyEmailFragment;", "Lu8/b;", "Lw8/p0;", "Lw8/o;", "", "Lod/y0;", "Ll8/h;", "spinnerVM", "Landroidx/fragment/app/f;", "fragment", "Lrm/n0;", "I", "Landroid/app/Activity;", "activity", "Ll8/h$b;", "event", "c", "p", "Ll8/c;", Constants.IPC_BUNDLE_KEY_SEND_ERROR, "H", "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;", "e", "l", "o", "g", "valError", "k", "Landroid/view/LayoutInflater;", "inflater", "Landroid/view/ViewGroup;", "container", "Landroid/os/Bundle;", "savedInstanceState", "Landroidx/lifecycle/u;", "viewLifecycleOwner", "Landroidx/lifecycle/z0;", "viewModel", "Landroid/view/View;", "M", "onCreateView", "view", "onViewCreated", "", "E", "onResume", "Lvd/r;", "v", "Lvd/r;", "K", "()Lvd/r;", "setLinkEmailUpdateEmailViewModelFactory", "(Lvd/r;)V", "linkEmailUpdateEmailViewModelFactory", "Lvd/q;", "w", "Lrm/o;", "L", "()Lvd/q;", "ca/canadapost/module/login/linkemail/LinkEmailVerifyEmailFragment$a", "x", "Lca/canadapost/module/login/linkemail/LinkEmailVerifyEmailFragment$a;", "onBackPressedCallback", "J", "()Lod/y0;", "binding", "<init>", "()V", "login_productionRelease"}, k = 1, mv = {1, 9, 0})
/* loaded from: classes4.dex */
public final class LinkEmailVerifyEmailFragment extends u8.b implements p0, o {

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

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

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

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

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

    /* renamed from: x, 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() {
            LinkEmailVerifyEmailFragment.this.L().c0();
            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(LinkEmailVerifyEmailFragment this$0, String str) {
            t.g(this$0, "this$0");
            androidx.fragment.app.k activity = this$0.getActivity();
            if (activity != null) {
                t.d(str);
                d0.t(activity, str);
            }
        }

        public final void b(final String str) {
            LinkEmailVerifyEmailFragment.this.J().x().announceForAccessibility(str);
            View x10 = LinkEmailVerifyEmailFragment.this.J().x();
            final LinkEmailVerifyEmailFragment linkEmailVerifyEmailFragment = LinkEmailVerifyEmailFragment.this;
            x10.postDelayed(new Runnable() { // from class: ca.canadapost.module.login.linkemail.h
                @Override // java.lang.Runnable
                public final void run() {
                    LinkEmailVerifyEmailFragment.b.c(LinkEmailVerifyEmailFragment.this, str);
                }
            }, 1000L);
        }

        @Override // dn.l
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            b((String) 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) {
            LinkEmailVerifyEmailFragment.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 d implements g0, n {

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

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

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

        @Override // androidx.lifecycle.g0
        public final /* synthetic */ void d(Object obj) {
            this.f10148a.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 f10149p;

        /* 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.f10149p = fVar;
        }

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

    /* 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 f10150p;

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

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

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

            public a(LinkEmailVerifyEmailFragment linkEmailVerifyEmailFragment) {
                this.f10152b = linkEmailVerifyEmailFragment;
            }

            @Override // androidx.lifecycle.c1.c
            public z0 a(Class modelClass) {
                t.g(modelClass, "modelClass");
                r K = this.f10152b.K();
                Bundle arguments = this.f10152b.getArguments();
                String string = arguments != null ? arguments.getString(Scopes.EMAIL, "") : null;
                q a10 = K.a(string != null ? string : "");
                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 f(dn.a aVar, LinkEmailVerifyEmailFragment linkEmailVerifyEmailFragment) {
            super(0);
            this.f10150p = aVar;
            this.f10151q = linkEmailVerifyEmailFragment;
        }

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

    public LinkEmailVerifyEmailFragment() {
        rm.o a10;
        a10 = rm.q.a(new f(new e(this), this));
        this.viewModel = a10;
        this.onBackPressedCallback = new a();
    }

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

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

    public void H(l8.c error, androidx.fragment.app.f fragment) {
        t.g(error, "error");
        t.g(fragment, "fragment");
        this.f10140t.b(error, fragment);
    }

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

    public y0 J() {
        return (y0) this.f10141u.b();
    }

    protected final r K() {
        r rVar = this.linkEmailUpdateEmailViewModelFactory;
        if (rVar != null) {
            return rVar;
        }
        t.y("linkEmailUpdateEmailViewModelFactory");
        return null;
    }

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

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

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

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

    @Override // w8.o
    public void e(ResultWrapper.Error error, Context context) {
        t.g(error, "error");
        t.g(context, "context");
        this.f10140t.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.f10140t.g(fragment, error);
    }

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

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

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

    @Override // w8.o
    public void k(ValidationError validationError, Context context) {
        t.g(context, "context");
        this.f10140t.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.f10140t.l(fragment, error);
    }

    @Override // w8.o
    public String m(ValidationError validationError, Context context) {
        t.g(context, "context");
        return this.f10140t.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.f10140t.n(code, message, context);
    }

    @Override // w8.o
    public void o(Context context) {
        t.g(context, "context");
        this.f10140t.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 M(inflater, container, savedInstanceState, viewLifecycleOwner, L());
    }

    @Override // u8.b, androidx.fragment.app.f
    public void onResume() {
        super.onResume();
        if (L().Z().getBoolean("one_to_one_duplicate_email_flow", true)) {
            return;
        }
        requireActivity().finish();
    }

    @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);
        I(L(), this);
        H(L(), this);
        L().a0().j(getViewLifecycleOwner(), new d(new b()));
        L().Y().j(getViewLifecycleOwner(), new d(new c()));
        androidx.fragment.app.k activity = getActivity();
        if (activity == null || (onBackPressedDispatcher = activity.getOnBackPressedDispatcher()) == null) {
            return;
        }
        u viewLifecycleOwner = getViewLifecycleOwner();
        t.f(viewLifecycleOwner, "getViewLifecycleOwner(...)");
        onBackPressedDispatcher.i(viewLifecycleOwner, this.onBackPressedCallback);
    }

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