package ca.canadapost.module.epostprofile.userprofile;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import androidx.appcompat.widget.SwitchCompat;
import androidx.databinding.f;
import androidx.fragment.app.k;
import androidx.lifecycle.c1;
import androidx.lifecycle.g0;
import ca.canadapost.core.data.model.AMSCheckSteps;
import ca.canadapost.core.data.model.Event;
import ca.canadapost.module.epostprofile.userprofile.UserPreferencesDialogFragment;
import cc.g4;
import dn.l;
import kotlin.Metadata;
import kotlin.jvm.internal.n;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.v;
import n8.m;
import n8.x;
import ob.i;
import ob.j;
import rm.n0;
import u8.g;
import w8.w;
import x4.d;
import zb.w3;

@Metadata(d1 = {"\u0000B\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\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0006\b\u0007\u0018\u00002\u00020\u00012\u00020\u00022\u00020\u0003B\u0007¢\u0006\u0004\b\u0018\u0010\u0019J&\u0010\u000b\u001a\u0004\u0018\u00010\n2\u0006\u0010\u0005\u001a\u00020\u00042\b\u0010\u0007\u001a\u0004\u0018\u00010\u00062\b\u0010\t\u001a\u0004\u0018\u00010\bH\u0016J\u001a\u0010\u000e\u001a\u00020\r2\u0006\u0010\f\u001a\u00020\n2\b\u0010\t\u001a\u0004\u0018\u00010\bH\u0017J\b\u0010\u000f\u001a\u00020\rH\u0016R\u0016\u0010\u0013\u001a\u00020\u00108\u0002@\u0002X\u0082.¢\u0006\u0006\n\u0004\b\u0011\u0010\u0012R\u0016\u0010\u0017\u001a\u00020\u00148\u0002@\u0002X\u0082.¢\u0006\u0006\n\u0004\b\u0015\u0010\u0016¨\u0006\u001a"}, d2 = {"Lca/canadapost/module/epostprofile/userprofile/UserPreferencesDialogFragment;", "Lu8/b;", "", "Ly7/i;", "Landroid/view/LayoutInflater;", "inflater", "Landroid/view/ViewGroup;", "container", "Landroid/os/Bundle;", "savedInstanceState", "Landroid/view/View;", "onCreateView", "view", "Lrm/n0;", "onViewCreated", "onResume", "Lzb/w3;", "s", "Lzb/w3;", "binding", "Lcc/g4;", "t", "Lcc/g4;", "viewModel", "<init>", "()V", "epostprofile_productionRelease"}, k = 1, mv = {1, 9, 0})
/* loaded from: classes4.dex */
public final class UserPreferencesDialogFragment extends u8.b {

    /* renamed from: s, reason: collision with root package name and from kotlin metadata */
    private w3 binding;

    /* renamed from: t, reason: collision with root package name and from kotlin metadata */
    private g4 viewModel;

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

        public final void a(n0 n0Var) {
            d.a(UserPreferencesDialogFragment.this).M(i.f31140a);
        }

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

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class b extends v implements dn.a {
        b() {
            super(0);
        }

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

        /* renamed from: invoke, reason: collision with other method in class */
        public final void m131invoke() {
            UserPreferencesDialogFragment.this.requireActivity().finish();
        }
    }

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

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

        c(l function) {
            t.g(function, "function");
            this.f9112a = function;
        }

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

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

    /* JADX INFO: Access modifiers changed from: private */
    public static final void O(UserPreferencesDialogFragment this$0, View view) {
        t.g(this$0, "this$0");
        w.d(d.a(this$0), i.f31188u, null, null, 6, null);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void P(UserPreferencesDialogFragment this$0, View view) {
        t.g(this$0, "this$0");
        w.d(d.a(this$0), i.f31186t, null, null, 6, null);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void Q(UserPreferencesDialogFragment this$0, Event event) {
        t.g(this$0, "this$0");
        Boolean bool = (Boolean) event.getContentIfNotHandled();
        if (bool == null || !bool.booleanValue()) {
            return;
        }
        g.a aVar = g.f36993k;
        Context requireContext = this$0.requireContext();
        String string = this$0.getString(ob.l.f31243a);
        t.f(string, "getString(...)");
        g j10 = aVar.j(requireContext, string, this$0.getString(ob.l.f31248b));
        j10.o(new b());
        j10.x(this$0.requireContext());
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void R(UserPreferencesDialogFragment this$0, View view) {
        t.g(this$0, "this$0");
        w.d(d.a(this$0), i.f31190v, null, null, 6, null);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void S(UserPreferencesDialogFragment this$0, View view) {
        t.g(this$0, "this$0");
        w3 w3Var = this$0.binding;
        g4 g4Var = null;
        if (w3Var == null) {
            t.y("binding");
            w3Var = null;
        }
        SwitchCompat switchCompat = w3Var.B;
        w3 w3Var2 = this$0.binding;
        if (w3Var2 == null) {
            t.y("binding");
            w3Var2 = null;
        }
        switchCompat.setChecked(!w3Var2.B.isChecked());
        g4 g4Var2 = this$0.viewModel;
        if (g4Var2 == null) {
            t.y("viewModel");
        } else {
            g4Var = g4Var2;
        }
        g4Var.b0();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final boolean T(UserPreferencesDialogFragment this$0, View view, MotionEvent motionEvent) {
        t.g(this$0, "this$0");
        if (motionEvent.getAction() != 0) {
            return false;
        }
        g4 g4Var = this$0.viewModel;
        if (g4Var == null) {
            t.y("viewModel");
            g4Var = null;
        }
        g4Var.b0();
        return true;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void U(UserPreferencesDialogFragment this$0, Boolean bool) {
        t.g(this$0, "this$0");
        w3 w3Var = this$0.binding;
        if (w3Var == null) {
            t.y("binding");
            w3Var = null;
        }
        SwitchCompat switchCompat = w3Var.B;
        t.d(bool);
        switchCompat.setChecked(bool.booleanValue());
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void V(UserPreferencesDialogFragment this$0, Event event) {
        t.g(this$0, "this$0");
        AMSCheckSteps aMSCheckSteps = (AMSCheckSteps) event.getContentIfNotHandled();
        if (aMSCheckSteps != null) {
            if (aMSCheckSteps == AMSCheckSteps.LOGIN) {
                m.a aVar = m.f29859a;
                k requireActivity = this$0.requireActivity();
                t.f(requireActivity, "requireActivity(...)");
                m.a.b(aVar, requireActivity, null, false, 6, null);
                return;
            }
            if (aMSCheckSteps == AMSCheckSteps.CONFIRM_ACCOUNT) {
                x.a aVar2 = x.f29870a;
                k requireActivity2 = this$0.requireActivity();
                t.f(requireActivity2, "requireActivity(...)");
                x.a.b(aVar2, requireActivity2, null, 2, null);
            }
        }
    }

    @Override // androidx.fragment.app.f
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        t.g(inflater, "inflater");
        w3 w3Var = null;
        androidx.databinding.n h10 = f.h(LayoutInflater.from(getContext()), j.f31225m0, null, false);
        t.f(h10, "inflate(...)");
        this.binding = (w3) h10;
        this.viewModel = (g4) new c1(this, y()).a(g4.class);
        w3 w3Var2 = this.binding;
        if (w3Var2 == null) {
            t.y("binding");
            w3Var2 = null;
        }
        g4 g4Var = this.viewModel;
        if (g4Var == null) {
            t.y("viewModel");
            g4Var = null;
        }
        w3Var2.U(g4Var);
        w3 w3Var3 = this.binding;
        if (w3Var3 == null) {
            t.y("binding");
        } else {
            w3Var = w3Var3;
        }
        return w3Var.x();
    }

    @Override // u8.b, androidx.fragment.app.f
    public void onResume() {
        super.onResume();
        g4 g4Var = this.viewModel;
        if (g4Var == null) {
            t.y("viewModel");
            g4Var = null;
        }
        g4Var.a0();
    }

    @Override // u8.b, androidx.fragment.app.f
    public void onViewCreated(View view, Bundle bundle) {
        t.g(view, "view");
        super.onViewCreated(view, bundle);
        w3 w3Var = this.binding;
        g4 g4Var = null;
        if (w3Var == null) {
            t.y("binding");
            w3Var = null;
        }
        w3Var.O(this);
        w3 w3Var2 = this.binding;
        if (w3Var2 == null) {
            t.y("binding");
            w3Var2 = null;
        }
        w3Var2.D.setOnClickListener(new View.OnClickListener() { // from class: cc.i4
            @Override // android.view.View.OnClickListener
            public final void onClick(View view2) {
                UserPreferencesDialogFragment.O(UserPreferencesDialogFragment.this, view2);
            }
        });
        w3 w3Var3 = this.binding;
        if (w3Var3 == null) {
            t.y("binding");
            w3Var3 = null;
        }
        w3Var3.C.setOnClickListener(new View.OnClickListener() { // from class: cc.j4
            @Override // android.view.View.OnClickListener
            public final void onClick(View view2) {
                UserPreferencesDialogFragment.P(UserPreferencesDialogFragment.this, view2);
            }
        });
        w3 w3Var4 = this.binding;
        if (w3Var4 == null) {
            t.y("binding");
            w3Var4 = null;
        }
        w3Var4.A.setOnClickListener(new View.OnClickListener() { // from class: cc.k4
            @Override // android.view.View.OnClickListener
            public final void onClick(View view2) {
                UserPreferencesDialogFragment.R(UserPreferencesDialogFragment.this, view2);
            }
        });
        w3 w3Var5 = this.binding;
        if (w3Var5 == null) {
            t.y("binding");
            w3Var5 = null;
        }
        w3Var5.B.setOnClickListener(new View.OnClickListener() { // from class: cc.l4
            @Override // android.view.View.OnClickListener
            public final void onClick(View view2) {
                UserPreferencesDialogFragment.S(UserPreferencesDialogFragment.this, view2);
            }
        });
        w3 w3Var6 = this.binding;
        if (w3Var6 == null) {
            t.y("binding");
            w3Var6 = null;
        }
        w3Var6.B.setOnTouchListener(new View.OnTouchListener() { // from class: cc.m4
            @Override // android.view.View.OnTouchListener
            public final boolean onTouch(View view2, MotionEvent motionEvent) {
                boolean T;
                T = UserPreferencesDialogFragment.T(UserPreferencesDialogFragment.this, view2, motionEvent);
                return T;
            }
        });
        g4 g4Var2 = this.viewModel;
        if (g4Var2 == null) {
            t.y("viewModel");
            g4Var2 = null;
        }
        g4Var2.U().j(getViewLifecycleOwner(), new g0() { // from class: cc.n4
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                UserPreferencesDialogFragment.U(UserPreferencesDialogFragment.this, (Boolean) obj);
            }
        });
        g4 g4Var3 = this.viewModel;
        if (g4Var3 == null) {
            t.y("viewModel");
            g4Var3 = null;
        }
        g4Var3.W().j(getViewLifecycleOwner(), new c(new a()));
        g4 g4Var4 = this.viewModel;
        if (g4Var4 == null) {
            t.y("viewModel");
            g4Var4 = null;
        }
        g4Var4.V().j(getViewLifecycleOwner(), new g0() { // from class: cc.o4
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                UserPreferencesDialogFragment.V(UserPreferencesDialogFragment.this, (Event) obj);
            }
        });
        g4 g4Var5 = this.viewModel;
        if (g4Var5 == null) {
            t.y("viewModel");
        } else {
            g4Var = g4Var5;
        }
        g4Var.X().j(getViewLifecycleOwner(), new g0() { // from class: cc.p4
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                UserPreferencesDialogFragment.Q(UserPreferencesDialogFragment.this, (Event) obj);
            }
        });
    }
}
