package ca.canadapost.module.registration;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import androidx.appcompat.widget.Toolbar;
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 ca.canadapost.core.common.customView.h0;
import ca.canadapost.core.data.model.CoreConstants;
import ca.canadapost.core.data.model.Event;
import ca.canadapost.core.data.model.ResultWrapper;
import ca.canadapost.core.data.model.ValidationError;
import ca.canadapost.module.registration.RegistrationVerifyEmailDialogFragment;
import com.google.firebase.messaging.Constants;
import dn.p;
import kotlin.Metadata;
import kotlin.jvm.internal.n;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.v;
import l8.h;
import n8.m;
import rm.c0;
import rm.i;
import rm.n0;
import rm.y;
import tp.m0;
import tp.w0;
import u7.x;
import w8.k;
import w8.l;
import w8.o;
import w8.p0;
import we.v0;

@Metadata(d1 = {"\u0000ª\u0001\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\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\u0000\n\u0002\u0010\u000e\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\n\u0018\u00002\u00020\u00012\u00020\u00022\b\u0012\u0004\u0012\u00020\u00040\u00032\u00020\u00052\u00020\u0006B\u0007¢\u0006\u0004\bR\u0010SJ5\u0010\u0012\u001a\u00020\u00112\u0006\u0010\b\u001a\u00020\u00072\b\u0010\n\u001a\u0004\u0018\u00010\t2\b\u0010\f\u001a\u0004\u0018\u00010\u000b2\u0006\u0010\u000e\u001a\u00020\r2\u0006\u0010\u0010\u001a\u00020\u000fH\u0096\u0001J\u0019\u0010\u0018\u001a\u00020\u00172\u0006\u0010\u0014\u001a\u00020\u00132\u0006\u0010\u0016\u001a\u00020\u0015H\u0096\u0001J\u001b\u0010\u001e\u001a\u00020\u001d2\b\u0010\u001a\u001a\u0004\u0018\u00010\u00192\u0006\u0010\u001c\u001a\u00020\u001bH\u0096\u0001J#\u0010!\u001a\u00020\u001d2\u0006\u0010\u001f\u001a\u00020\u001d2\b\u0010 \u001a\u0004\u0018\u00010\u001d2\u0006\u0010\u001c\u001a\u00020\u001bH\u0096\u0001J\u001b\u0010\"\u001a\u00020\u001d2\b\u0010\u001a\u001a\u0004\u0018\u00010\u00192\u0006\u0010\u001c\u001a\u00020\u001bH\u0096\u0001J\u0019\u0010#\u001a\u00020\u001d2\u0006\u0010\u001f\u001a\u00020\u001d2\u0006\u0010\u001c\u001a\u00020\u001bH\u0096\u0001J\u0011\u0010$\u001a\u00020\u001d2\u0006\u0010\u001c\u001a\u00020\u001bH\u0096\u0001J\u0011\u0010%\u001a\u00020\u001d2\u0006\u0010\u001c\u001a\u00020\u001bH\u0096\u0001J\u0011\u0010&\u001a\u00020\u001d2\u0006\u0010\u001c\u001a\u00020\u001bH\u0096\u0001J\u0019\u0010(\u001a\u00020\u00172\u0006\u0010\u0014\u001a\u00020'2\u0006\u0010\u001c\u001a\u00020\u001bH\u0096\u0001J\u0019\u0010)\u001a\u00020\u00172\u0006\u0010\u0016\u001a\u00020\u00152\u0006\u0010\u0014\u001a\u00020'H\u0096\u0001J\u0011\u0010*\u001a\u00020\u00172\u0006\u0010\u001c\u001a\u00020\u001bH\u0096\u0001J\u0019\u0010+\u001a\u00020\u00172\u0006\u0010\u0016\u001a\u00020\u00152\u0006\u0010\u0014\u001a\u00020'H\u0096\u0001J\u001b\u0010-\u001a\u00020\u00172\b\u0010,\u001a\u0004\u0018\u00010\u00192\u0006\u0010\u001c\u001a\u00020\u001bH\u0096\u0001J\u0019\u00100\u001a\u00020\u00172\u0006\u0010/\u001a\u00020.2\u0006\u0010\u0016\u001a\u00020\u0015H\u0096\u0001J\u0019\u00105\u001a\u00020\u00172\u0006\u00102\u001a\u0002012\u0006\u00104\u001a\u000203H\u0096\u0001J\u0019\u00106\u001a\u00020\u00172\u0006\u0010\u0016\u001a\u00020\u00152\u0006\u00104\u001a\u000203H\u0096\u0001J$\u00107\u001a\u00020\u00112\u0006\u0010\b\u001a\u00020\u00072\b\u0010\n\u001a\u0004\u0018\u00010\t2\b\u0010\f\u001a\u0004\u0018\u00010\u000bH\u0016J\u0012\u00109\u001a\u0002082\b\u0010\f\u001a\u0004\u0018\u00010\u000bH\u0016J\b\u0010;\u001a\u00020:H\u0016J\b\u0010<\u001a\u00020\u0017H\u0016J\u001a\u0010>\u001a\u00020\u00172\u0006\u0010=\u001a\u00020\u00112\b\u0010\f\u001a\u0004\u0018\u00010\u000bH\u0016J\n\u0010@\u001a\u0004\u0018\u00010?H\u0016J\b\u0010A\u001a\u00020\u001dH\u0016R\"\u0010I\u001a\u00020B8\u0004@\u0004X\u0085.¢\u0006\u0012\n\u0004\bC\u0010D\u001a\u0004\bE\u0010F\"\u0004\bG\u0010HR\u001b\u0010\u0010\u001a\u00020J8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\bK\u0010L\u001a\u0004\bM\u0010NR\u0014\u0010Q\u001a\u00020\u00048\u0016X\u0096\u0005¢\u0006\u0006\u001a\u0004\bO\u0010P¨\u0006T"}, d2 = {"Lca/canadapost/module/registration/RegistrationVerifyEmailDialogFragment;", "Lca/canadapost/core/common/ui/b;", "Ly7/i;", "", "Lxe/c0;", "Lw8/o;", "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;", "M", "Ll8/c;", Constants.IPC_BUNDLE_KEY_SEND_ERROR, "Landroidx/fragment/app/f;", "fragment", "Lrm/n0;", "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", "Ll8/h;", "spinnerVM", "I", "Landroid/app/Activity;", "activity", "Ll8/h$b;", "event", "c", "p", "onCreateView", "Landroid/app/Dialog;", "onCreateDialog", "", "getTheme", "onStop", "view", "onViewCreated", "Landroidx/appcompat/widget/Toolbar;", "C", "B", "Landroidx/lifecycle/c1$c;", "s", "Landroidx/lifecycle/c1$c;", "L", "()Landroidx/lifecycle/c1$c;", "setViewModelFactory", "(Landroidx/lifecycle/c1$c;)V", "viewModelFactory", "Lwe/v0;", "t", "Lrm/o;", "K", "()Lwe/v0;", "J", "()Lxe/c0;", "binding", "<init>", "()V", "registration_productionRelease"}, k = 1, mv = {1, 9, 0})
/* loaded from: classes4.dex */
public final class RegistrationVerifyEmailDialogFragment extends ca.canadapost.core.common.ui.b implements o, p0 {

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

    /* renamed from: p, reason: collision with root package name */
    private final /* synthetic */ x f10692p = new x(we.e.f49178o);

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

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

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

    /* loaded from: classes4.dex */
    public static final class a extends Dialog {
        a(Context context, int i10) {
            super(context, i10);
        }

        @Override // android.app.Dialog
        public void onBackPressed() {
            RegistrationVerifyEmailDialogFragment.this.K().a0();
            m.a aVar = m.f29859a;
            androidx.fragment.app.k requireActivity = RegistrationVerifyEmailDialogFragment.this.requireActivity();
            t.f(requireActivity, "requireActivity(...)");
            m.a.b(aVar, requireActivity, null, false, 6, null);
        }
    }

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

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

        /* JADX INFO: Access modifiers changed from: package-private */
        /* loaded from: classes4.dex */
        public static final class a extends kotlin.coroutines.jvm.internal.l implements p {

            /* renamed from: p, reason: collision with root package name */
            int f10700p;

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

            /* renamed from: r, reason: collision with root package name */
            final /* synthetic */ View f10702r;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            a(RegistrationVerifyEmailDialogFragment registrationVerifyEmailDialogFragment, View view, vm.d dVar) {
                super(2, dVar);
                this.f10701q = registrationVerifyEmailDialogFragment;
                this.f10702r = view;
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final vm.d create(Object obj, vm.d dVar) {
                return new a(this.f10701q, this.f10702r, dVar);
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final Object invokeSuspend(Object obj) {
                Object f10;
                View view;
                f10 = wm.d.f();
                int i10 = this.f10700p;
                if (i10 == 0) {
                    y.b(obj);
                    this.f10700p = 1;
                    if (w0.a(3500L, this) == f10) {
                        return f10;
                    }
                } else {
                    if (i10 != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    y.b(obj);
                }
                Context context = this.f10701q.getContext();
                if (context != null && (view = this.f10702r) != null) {
                    view.announceForAccessibility(context.getString(we.f.f49185f));
                }
                return n0.f34904a;
            }

            @Override // dn.p
            public final Object invoke(m0 m0Var, vm.d dVar) {
                return ((a) create(m0Var, dVar)).invokeSuspend(n0.f34904a);
            }
        }

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        b(View view) {
            super(1);
            this.f10699q = view;
        }

        public final void a(Event event) {
            Boolean bool = (Boolean) event.getContentIfNotHandled();
            if (bool != null) {
                RegistrationVerifyEmailDialogFragment registrationVerifyEmailDialogFragment = RegistrationVerifyEmailDialogFragment.this;
                View view = this.f10699q;
                if (bool.booleanValue()) {
                    androidx.fragment.app.k activity = registrationVerifyEmailDialogFragment.getActivity();
                    LinearLayout linearLayout = registrationVerifyEmailDialogFragment.J().E;
                    Context context = registrationVerifyEmailDialogFragment.getContext();
                    h0.b(activity, linearLayout, context != null ? context.getString(we.f.f49185f) : null, 0, false, false);
                    u viewLifecycleOwner = registrationVerifyEmailDialogFragment.getViewLifecycleOwner();
                    t.f(viewLifecycleOwner, "getViewLifecycleOwner(...)");
                    tp.k.d(androidx.lifecycle.v.a(viewLifecycleOwner), null, null, new a(registrationVerifyEmailDialogFragment, view, null), 3, null);
                }
            }
        }

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

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

        public final void a(Event event) {
            Boolean bool = (Boolean) event.getContentIfNotHandled();
            if (bool != null) {
                RegistrationVerifyEmailDialogFragment registrationVerifyEmailDialogFragment = RegistrationVerifyEmailDialogFragment.this;
                if (bool.booleanValue()) {
                    androidx.fragment.app.k requireActivity = registrationVerifyEmailDialogFragment.requireActivity();
                    Intent intent = new Intent();
                    intent.putExtra(CoreConstants.NAVIGATE_TO_SIGN_IN, true);
                    n0 n0Var = n0.f34904a;
                    requireActivity.setResult(-1, intent);
                    registrationVerifyEmailDialogFragment.requireActivity().finish();
                }
            }
        }

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

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

        public final void a(Event event) {
            Boolean bool = (Boolean) event.getContentIfNotHandled();
            if (bool != null) {
                RegistrationVerifyEmailDialogFragment registrationVerifyEmailDialogFragment = RegistrationVerifyEmailDialogFragment.this;
                if (bool.booleanValue()) {
                    x4.d.a(registrationVerifyEmailDialogFragment).N(we.d.f49159u, androidx.core.os.c.a(c0.a("error_title", registrationVerifyEmailDialogFragment.getString(we.f.f49187h)), c0.a("error_message", registrationVerifyEmailDialogFragment.getString(we.f.f49193n)), c0.a("button_text", registrationVerifyEmailDialogFragment.getString(we.f.f49184e))));
                }
            }
        }

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

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

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

        e(dn.l function) {
            t.g(function, "function");
            this.f10705a = function;
        }

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

        @Override // androidx.lifecycle.g0
        public final /* synthetic */ void d(Object obj) {
            this.f10705a.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 f extends v implements dn.a {

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

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

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

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

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

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

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

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

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

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

    /* JADX INFO: Access modifiers changed from: private */
    public static final void N(RegistrationVerifyEmailDialogFragment this$0, View view) {
        t.g(this$0, "this$0");
        this$0.K().Z();
    }

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

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

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

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

    public xe.c0 J() {
        return (xe.c0) this.f10692p.b();
    }

    protected final c1.c L() {
        c1.c cVar = this.viewModelFactory;
        if (cVar != null) {
            return cVar;
        }
        t.y("viewModelFactory");
        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.f10692p.c(inflater, container, savedInstanceState, viewLifecycleOwner, viewModel);
    }

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

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

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

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

    @Override // ca.canadapost.core.common.ui.b, androidx.fragment.app.e
    public int getTheme() {
        return we.g.f49206a;
    }

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

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

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

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

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

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

    @Override // androidx.fragment.app.e
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        return new a(requireContext(), getTheme());
    }

    @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, K());
    }

    @Override // androidx.fragment.app.e, androidx.fragment.app.f
    public void onStop() {
        K().a0();
        requireActivity().finish();
        super.onStop();
    }

    @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);
        J().U(K());
        J().O(this);
        I(K(), this);
        H(K(), this);
        K().X().j(getViewLifecycleOwner(), new e(new b(view)));
        K().V().j(getViewLifecycleOwner(), new e(new c()));
        K().Y().j(getViewLifecycleOwner(), new e(new d()));
        J().D.A.setOnClickListener(new View.OnClickListener() { // from class: we.u0
            @Override // android.view.View.OnClickListener
            public final void onClick(View view2) {
                RegistrationVerifyEmailDialogFragment.N(RegistrationVerifyEmailDialogFragment.this, view2);
            }
        });
    }

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