package o;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.util.SparseArray;
import android.view.ActionMode;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.autofill.AutofillId;
import android.view.autofill.AutofillManager;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.internal.Preconditions;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Objects;
import java.util.concurrent.Executor;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class S60 implements InterfaceC2251qc, InterfaceC2543tg, InterfaceC2956xx, InterfaceC1823m1, InterfaceC1315gj0, InterfaceC3051yx {
    public static S60 q;
    public final /* synthetic */ int l;
    public Object m;
    public Object n;

    /* renamed from: o, reason: collision with root package name */
    public Object f325o;
    public Object p;

    public /* synthetic */ S60(Object obj, Object obj2, Object obj3, Object obj4, int i) {
        this.l = i;
        this.m = obj;
        this.n = obj2;
        this.f325o = obj3;
        this.p = obj4;
    }

    public static synchronized S60 h() {
        try {
            if (q == null) {
                q = new S60(0);
            }
        } catch (Throwable th) {
            throw th;
        }
        return q;
    }

    @Override // o.InterfaceC1028dj0
    public long b(Y6 y6, Y6 y62, Y6 y63) {
        int iB = y6.b();
        long jMax = 0;
        for (int i = 0; i < iB; i++) {
            jMax = Math.max(jMax, ((WT) this.m).c(i).d(y6.a(i), y62.a(i), y63.a(i)));
        }
        return jMax;
    }

    @Override // o.InterfaceC1823m1
    public boolean c(AbstractC1918n1 abstractC1918n1, Menu menu) {
        ActionMode.Callback callback = (ActionMode.Callback) this.m;
        Ab0 ab0F = f(abstractC1918n1);
        I80 i80 = (I80) this.p;
        Menu menuC1571jP = (Menu) i80.get(menu);
        if (menuC1571jP == null) {
            menuC1571jP = new MenuC1571jP((Context) this.n, (CO) menu);
            i80.put(menu, menuC1571jP);
        }
        return callback.onCreateActionMode(ab0F, menuC1571jP);
    }

    @Override // o.InterfaceC1823m1
    public void d(AbstractC1918n1 abstractC1918n1) {
        ((ActionMode.Callback) this.m).onDestroyActionMode(f(abstractC1918n1));
    }

    @Override // o.InterfaceC1823m1
    public boolean e(AbstractC1918n1 abstractC1918n1, MenuItem menuItem) {
        return ((ActionMode.Callback) this.m).onActionItemClicked(f(abstractC1918n1), new PO((Context) this.n, (Eb0) menuItem));
    }

    public Ab0 f(AbstractC1918n1 abstractC1918n1) {
        ArrayList arrayList = (ArrayList) this.f325o;
        int size = arrayList.size();
        for (int i = 0; i < size; i++) {
            Ab0 ab0 = (Ab0) arrayList.get(i);
            if (ab0 != null && ab0.b == abstractC1918n1) {
                return ab0;
            }
        }
        Ab0 ab02 = new Ab0((Context) this.n, abstractC1918n1);
        arrayList.add(ab02);
        return ab02;
    }

    @Override // o.InterfaceC1823m1
    public boolean g(AbstractC1918n1 abstractC1918n1, Menu menu) {
        ActionMode.Callback callback = (ActionMode.Callback) this.m;
        Ab0 ab0F = f(abstractC1918n1);
        I80 i80 = (I80) this.p;
        Menu menuC1571jP = (Menu) i80.get(menu);
        if (menuC1571jP == null) {
            menuC1571jP = new MenuC1571jP((Context) this.n, (CO) menu);
            i80.put(menu, menuC1571jP);
        }
        return callback.onPrepareActionMode(ab0F, menuC1571jP);
    }

    @Override // o.CZ
    public Object get() {
        switch (this.l) {
            case 4:
                return new C0491Sy((C0076Cy) ((G0) this.m).m, (C2121p70) ((CZ) this.n).get(), (InterfaceC2747vn) ((CZ) this.f325o).get(), (C1931n70) ((BZ) this.p).get());
            default:
                return new C2062oc0((Executor) ((CZ) this.m).get(), (InterfaceC0463Rw) ((CZ) this.n).get(), (C3126zm0) ((C3126zm0) this.f325o).get(), (InterfaceC0918cc0) ((CZ) this.p).get());
        }
    }

    public AbstractC0934ck0 i(C0474Sh c0474Sh, String str) {
        AbstractC0934ck0 abstractC0934ck0;
        boolean zIsInstance;
        AbstractC0934ck0 abstractC0934ck0A;
        C2020o40 c2020o40;
        WK wk;
        synchronized (((BP) this.p)) {
            try {
                abstractC0934ck0 = (AbstractC0934ck0) ((C1413hk0) this.m).a.get(str);
                Class clsQ = c0474Sh.a;
                Integer num = (Integer) C0474Sh.b.get(clsQ);
                if (num != null) {
                    zIsInstance = AbstractC1692kh0.B(num.intValue(), abstractC0934ck0);
                } else {
                    if (clsQ.isPrimitive()) {
                        clsQ = IJ.q(C10.a(clsQ));
                    }
                    zIsInstance = clsQ.isInstance(abstractC0934ck0);
                }
                if (zIsInstance) {
                    InterfaceC1221fk0 interfaceC1221fk0 = (InterfaceC1221fk0) this.n;
                    if ((interfaceC1221fk0 instanceof C2020o40) && (wk = (c2020o40 = (C2020o40) interfaceC1221fk0).d) != null) {
                        F3.e(abstractC0934ck0, c2020o40.e, wk);
                    }
                } else {
                    FQ fq = new FQ((AbstractC0118Eo) this.f325o);
                    fq.a(OD.p, str);
                    InterfaceC1221fk0 interfaceC1221fk02 = (InterfaceC1221fk0) this.n;
                    try {
                        try {
                            abstractC0934ck0A = interfaceC1221fk02.b(c0474Sh, fq);
                        } catch (AbstractMethodError unused) {
                            abstractC0934ck0A = interfaceC1221fk02.c(c0474Sh.a(), fq);
                        }
                    } catch (AbstractMethodError unused2) {
                        abstractC0934ck0A = interfaceC1221fk02.a(c0474Sh.a());
                    }
                    abstractC0934ck0 = abstractC0934ck0A;
                    AbstractC0934ck0 abstractC0934ck02 = (AbstractC0934ck0) ((C1413hk0) this.m).a.put(str, abstractC0934ck0);
                    if (abstractC0934ck02 != null) {
                        abstractC0934ck02.a();
                    }
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        return abstractC0934ck0;
    }

    public boolean k(Context context) {
        if (((Boolean) this.f325o) == null) {
            this.f325o = Boolean.valueOf(context.checkCallingOrSelfPermission("android.permission.ACCESS_NETWORK_STATE") == 0);
        }
        if (!((Boolean) this.n).booleanValue()) {
            Log.isLoggable("FirebaseMessaging", 3);
        }
        return ((Boolean) this.f325o).booleanValue();
    }

    @Override // o.InterfaceC1028dj0
    public Y6 l(long j, Y6 y6, Y6 y62, Y6 y63) {
        if (((Y6) this.f325o) == null) {
            this.f325o = y63.c();
        }
        Y6 y64 = (Y6) this.f325o;
        if (y64 == null) {
            y64 = null;
        }
        int iB = y64.b();
        for (int i = 0; i < iB; i++) {
            Y6 y65 = (Y6) this.f325o;
            if (y65 == null) {
                y65 = null;
            }
            y65.e(i, ((WT) this.m).c(i).c(j, y6.a(i), y62.a(i), y63.a(i)));
        }
        Y6 y66 = (Y6) this.f325o;
        if (y66 == null) {
            return null;
        }
        return y66;
    }

    @Override // o.InterfaceC1028dj0
    public Y6 m(long j, Y6 y6, Y6 y62, Y6 y63) {
        if (((Y6) this.n) == null) {
            this.n = y6.c();
        }
        Y6 y64 = (Y6) this.n;
        if (y64 == null) {
            y64 = null;
        }
        int iB = y64.b();
        for (int i = 0; i < iB; i++) {
            Y6 y65 = (Y6) this.n;
            if (y65 == null) {
                y65 = null;
            }
            y65.e(i, ((WT) this.m).c(i).b(j, y6.a(i), y62.a(i), y63.a(i)));
        }
        Y6 y66 = (Y6) this.n;
        if (y66 == null) {
            return null;
        }
        return y66;
    }

    public boolean n(Context context) {
        if (((Boolean) this.n) == null) {
            this.n = Boolean.valueOf(context.checkCallingOrSelfPermission("android.permission.WAKE_LOCK") == 0);
        }
        if (!((Boolean) this.n).booleanValue()) {
            Log.isLoggable("FirebaseMessaging", 3);
        }
        return ((Boolean) this.n).booleanValue();
    }

    @Override // o.InterfaceC2543tg
    public void onCancel() {
        View view = (View) this.m;
        view.clearAnimation();
        ((ViewGroup) this.n).endViewTransition(view);
        ((androidx.fragment.app.d) this.f325o).a();
        if (androidx.fragment.app.s.F(2)) {
            Objects.toString((androidx.fragment.app.x) this.p);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:51:0x00fe A[Catch: NumberFormatException | JSONException -> 0x010b, NumberFormatException | JSONException -> 0x010b, TRY_LEAVE, TryCatch #0 {NumberFormatException | JSONException -> 0x010b, blocks: (B:10:0x0031, B:24:0x0065, B:24:0x0065, B:26:0x0072, B:26:0x0072, B:28:0x0084, B:28:0x0084, B:29:0x008d, B:29:0x008d, B:51:0x00fe, B:51:0x00fe, B:33:0x009a, B:33:0x009a, B:35:0x00a7, B:35:0x00a7, B:37:0x00b9, B:37:0x00b9, B:38:0x00c2, B:38:0x00c2, B:42:0x00ce, B:42:0x00ce, B:46:0x00de, B:46:0x00de, B:50:0x00f2, B:50:0x00f2), top: B:63:0x0031, outer: #1 }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public android.os.Bundle p() throws org.json.JSONException {
        /*
            Method dump skipped, instructions count: 326
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.S60.p():android.os.Bundle");
    }

    public InterfaceC1991no0 q(C2062oc0 c2062oc0, C1333gs0... c1333gs0Arr) {
        InterfaceC1991no0 interfaceC1991no0E0 = InterfaceC1991no0.d;
        for (C1333gs0 c1333gs0 : c1333gs0Arr) {
            interfaceC1991no0E0 = As0.e0(c1333gs0);
            AbstractC2378rs0.y0((C2062oc0) this.f325o);
            if ((interfaceC1991no0E0 instanceof C2181po0) || (interfaceC1991no0E0 instanceof C1801lo0)) {
                interfaceC1991no0E0 = ((C3031ym0) this.m).h(c2062oc0, interfaceC1991no0E0);
            }
        }
        return interfaceC1991no0E0;
    }

    @Override // o.InterfaceC1028dj0
    public Y6 r(Y6 y6, Y6 y62, Y6 y63) {
        if (((Y6) this.p) == null) {
            this.p = y63.c();
        }
        Y6 y64 = (Y6) this.p;
        if (y64 == null) {
            y64 = null;
        }
        int iB = y64.b();
        for (int i = 0; i < iB; i++) {
            Y6 y65 = (Y6) this.p;
            if (y65 == null) {
                y65 = null;
            }
            y65.e(i, ((WT) this.m).c(i).e(y6.a(i), y62.a(i), y63.a(i)));
        }
        Y6 y66 = (Y6) this.p;
        if (y66 == null) {
            return null;
        }
        return y66;
    }

    public void s(Bundle bundle) throws JSONException {
        String str = (String) this.m;
        C1617jr0 c1617jr0 = (C1617jr0) this.p;
        Bundle bundle2 = bundle == null ? new Bundle() : new Bundle(bundle);
        SharedPreferences sharedPreferencesW = c1617jr0.w();
        Kr0 kr0 = (Kr0) c1617jr0.a;
        SharedPreferences.Editor editorEdit = sharedPreferencesW.edit();
        if (bundle2.size() == 0) {
            editorEdit.remove(str);
        } else {
            JSONArray jSONArray = new JSONArray();
            for (String str2 : bundle2.keySet()) {
                Object obj = bundle2.get(str2);
                if (obj != null) {
                    try {
                        JSONObject jSONObject = new JSONObject();
                        jSONObject.put("n", str2);
                        Xv0.a();
                        if (kr0.d.C(null, AbstractC1900mq0.Q0)) {
                            if (obj instanceof String) {
                                jSONObject.put("v", obj.toString());
                                jSONObject.put("t", "s");
                            } else if (obj instanceof Long) {
                                jSONObject.put("v", obj.toString());
                                jSONObject.put("t", "l");
                            } else if (obj instanceof int[]) {
                                jSONObject.put("v", Arrays.toString((int[]) obj));
                                jSONObject.put("t", "ia");
                            } else if (obj instanceof long[]) {
                                jSONObject.put("v", Arrays.toString((long[]) obj));
                                jSONObject.put("t", "la");
                            } else if (obj instanceof Double) {
                                jSONObject.put("v", obj.toString());
                                jSONObject.put("t", "d");
                            } else {
                                Nq0 nq0 = kr0.f;
                                Kr0.l(nq0);
                                nq0.f.c(obj.getClass(), "Cannot serialize bundle value to SharedPreferences. Type");
                            }
                            jSONArray.put(jSONObject);
                        } else {
                            jSONObject.put("v", obj.toString());
                            if (obj instanceof String) {
                                jSONObject.put("t", "s");
                            } else if (obj instanceof Long) {
                                jSONObject.put("t", "l");
                            } else if (obj instanceof Double) {
                                jSONObject.put("t", "d");
                            } else {
                                Nq0 nq02 = kr0.f;
                                Kr0.l(nq02);
                                nq02.f.c(obj.getClass(), "Cannot serialize bundle value to SharedPreferences. Type");
                            }
                            jSONArray.put(jSONObject);
                        }
                    } catch (JSONException e) {
                        Nq0 nq03 = kr0.f;
                        Kr0.l(nq03);
                        nq03.f.c(e, "Cannot serialize bundle value to SharedPreferences");
                    }
                }
            }
            editorEdit.putString(str, jSONArray.toString());
        }
        editorEdit.apply();
        this.f325o = bundle2;
    }

    public S60(C1617jr0 c1617jr0, String str) {
        this.l = 12;
        this.p = c1617jr0;
        Preconditions.checkNotEmpty(str);
        this.m = str;
        this.n = new Bundle();
    }

    public S60(C1413hk0 c1413hk0, InterfaceC1221fk0 interfaceC1221fk0, AbstractC0118Eo abstractC0118Eo) {
        this.l = 9;
        this.m = c1413hk0;
        this.n = interfaceC1221fk0;
        this.f325o = abstractC0118Eo;
        this.p = new BP(17);
    }

    public S60(C2207q3 c2207q3, C2915xc c2915xc) {
        this.l = 1;
        this.m = c2207q3;
        this.n = c2915xc;
        AutofillManager autofillManagerG = AbstractC2865x0.g(c2207q3.getContext().getSystemService(AbstractC2865x0.k()));
        if (autofillManagerG != null) {
            this.f325o = autofillManagerG;
            c2207q3.setImportantForAutofill(1);
            G0 g0O = IJ.o(c2207q3);
            AutofillId autofillIdE = g0O != null ? AbstractC2440sc.e(g0O.m) : null;
            if (autofillIdE != null) {
                this.p = autofillIdE;
                return;
            }
            throw AbstractC2462sn.q("Required value was null.");
        }
        throw new IllegalStateException("Autofill service could not be located.");
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:128:0x03a8  */
    /* JADX WARN: Type inference failed for: r16v0, types: [java.lang.String] */
    /* JADX WARN: Type inference failed for: r16v2 */
    /* JADX WARN: Type inference failed for: r16v3, types: [java.lang.Throwable] */
    /* JADX WARN: Type inference failed for: r16v4 */
    /* JADX WARN: Type inference failed for: r7v33, types: [android.graphics.drawable.Icon] */
    /* JADX WARN: Type inference failed for: r7v47 */
    /* JADX WARN: Type inference failed for: r7v48 */
    /* JADX WARN: Type inference failed for: r7v6, types: [android.app.Notification$Builder] */
    /* JADX WARN: Type inference failed for: r7v8, types: [android.app.Notification$Builder] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public S60(o.FS r21) {
        /*
            Method dump skipped, instructions count: 1017
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.S60.<init>(o.FS):void");
    }

    public S60(int i) {
        this.l = i;
        switch (i) {
            case 2:
                break;
            case 7:
                this.m = new C1839m9(0);
                this.n = new SparseArray();
                this.f325o = new UM((Object) null);
                this.p = new C1839m9(0);
                break;
            case ConnectionResult.LICENSE_CHECK_FAILED /* 11 */:
                C3031ym0 c3031ym0 = new C3031ym0(12);
                this.m = c3031ym0;
                C2062oc0 c2062oc0 = new C2062oc0((C2062oc0) null, c3031ym0);
                this.f325o = c2062oc0;
                this.n = c2062oc0.j();
                C0559Vo c0559Vo = new C0559Vo(1);
                this.p = c0559Vo;
                c2062oc0.l("require", new Gw0(c0559Vo));
                c0559Vo.a.put("internal.platform", Pp0.a);
                c2062oc0.l("runtime.counter", new Wn0(Double.valueOf(0.0d)));
                break;
            default:
                this.m = null;
                this.n = null;
                this.f325o = null;
                this.p = new ArrayDeque();
                break;
        }
    }

    public S60(Context context, ActionMode.Callback callback) {
        this.l = 6;
        this.n = context;
        this.m = callback;
        this.f325o = new ArrayList();
        this.p = new I80(0);
    }

    public S60(WT wt) {
        this.l = 8;
        this.m = wt;
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public S60(InterfaceC1629jz interfaceC1629jz) {
        this(new WT(29, interfaceC1629jz));
        this.l = 8;
    }
}
