package o;

import android.app.Application;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.common.util.Clock;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class Xs0 extends AbstractC2090oq0 {
    public C0308Lx c;
    public C1390hY d;
    public final CopyOnWriteArraySet e;
    public boolean f;
    public final AtomicReference g;
    public final Object h;
    public boolean i;
    public int j;
    public C3043ys0 k;
    public C3043ys0 l;
    public PriorityQueue m;
    public boolean n;

    /* renamed from: o, reason: collision with root package name */
    public C2284qs0 f417o;
    public final AtomicLong p;
    public long q;
    public final Ir0 r;
    public boolean s;
    public C3043ys0 t;
    public Vs0 u;
    public C3043ys0 v;
    public final C1696kj0 w;

    public Xs0(Kr0 kr0) {
        super(kr0);
        this.e = new CopyOnWriteArraySet();
        this.h = new Object();
        this.i = false;
        this.j = 1;
        this.s = true;
        this.w = new C1696kj0(13, this);
        this.g = new AtomicReference();
        this.f417o = C2284qs0.c;
        this.q = -1L;
        this.p = new AtomicLong(0L);
        this.r = new Ir0(kr0);
    }

    public final void A(long j, Bundle bundle, String str, String str2) {
        r();
        boolean z = true;
        if (this.d != null && !C2574tv0.P(str2)) {
            z = false;
        }
        B(str, str2, j, bundle, true, z, true);
    }

    /* JADX WARN: Removed duplicated region for block: B:206:? A[RETURN, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:89:0x01e8  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void B(java.lang.String r29, java.lang.String r30, long r31, android.os.Bundle r33, boolean r34, boolean r35, boolean r36) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException {
        /*
            Method dump skipped, instructions count: 1237
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.Xs0.B(java.lang.String, java.lang.String, long, android.os.Bundle, boolean, boolean, boolean):void");
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0021  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void C(java.lang.String r12, java.lang.String r13, java.lang.Object r14, boolean r15, long r16) {
        /*
            Method dump skipped, instructions count: 215
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.Xs0.C(java.lang.String, java.lang.String, java.lang.Object, boolean, long):void");
    }

    /* JADX WARN: Removed duplicated region for block: B:16:0x0057  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void D(long r20, java.lang.Object r22, java.lang.String r23, java.lang.String r24) {
        /*
            Method dump skipped, instructions count: 244
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.Xs0.D(long, java.lang.Object, java.lang.String, java.lang.String):void");
    }

    public final void E() {
        r();
        t();
        Kr0 kr0 = (Kr0) this.a;
        if (kr0.h()) {
            C1421ho0 c1421ho0 = kr0.d;
            ((Kr0) c1421ho0.a).getClass();
            Boolean boolE = c1421ho0.E("google_analytics_deferred_deep_link_enabled");
            if (boolE != null && boolE.booleanValue()) {
                Nq0 nq0 = kr0.f;
                Kr0.l(nq0);
                nq0.m.b("Deferred Deep Link feature enabled.");
                Fr0 fr0 = kr0.g;
                Kr0.l(fr0);
                fr0.B(new RunnableC2853ws0(this, 2));
            }
            Vt0 vt0O = kr0.o();
            vt0O.r();
            vt0O.t();
            C1531iw0 c1531iw0I = vt0O.I(true);
            vt0O.E();
            Kr0 kr02 = (Kr0) vt0O.a;
            kr02.d.C(null, AbstractC1900mq0.b1);
            kr02.n().z(3, new byte[0]);
            vt0O.G(new RunnableC2950xt0(vt0O, c1531iw0I, 1));
            this.s = false;
            C1617jr0 c1617jr0 = kr0.e;
            Kr0.j(c1617jr0);
            c1617jr0.r();
            String string = c1617jr0.w().getString("previous_os_version", null);
            ((Kr0) c1617jr0.a).p().u();
            String str = Build.VERSION.RELEASE;
            if (!TextUtils.isEmpty(str) && !str.equals(string)) {
                SharedPreferences.Editor editorEdit = c1617jr0.w().edit();
                editorEdit.putString("previous_os_version", str);
                editorEdit.apply();
            }
            if (TextUtils.isEmpty(string)) {
                return;
            }
            kr0.p().u();
            if (string.equals(str)) {
                return;
            }
            Bundle bundle = new Bundle();
            bundle.putString("_po", string);
            z("auto", "_ou", bundle);
        }
    }

    public final void F(Bundle bundle, long j) {
        Kr0 kr0 = (Kr0) this.a;
        Preconditions.checkNotNull(bundle);
        Bundle bundle2 = new Bundle(bundle);
        if (!TextUtils.isEmpty(bundle2.getString("app_id"))) {
            Nq0 nq0 = kr0.f;
            Kr0.l(nq0);
            nq0.i.b("Package name should be null when calling setConditionalUserProperty");
        }
        bundle2.remove("app_id");
        Preconditions.checkNotNull(bundle2);
        AbstractC2001nt0.O(bundle2, "app_id", String.class, null);
        AbstractC2001nt0.O(bundle2, "origin", String.class, null);
        AbstractC2001nt0.O(bundle2, "name", String.class, null);
        AbstractC2001nt0.O(bundle2, "value", Object.class, null);
        AbstractC2001nt0.O(bundle2, "trigger_event_name", String.class, null);
        AbstractC2001nt0.O(bundle2, "trigger_timeout", Long.class, 0L);
        AbstractC2001nt0.O(bundle2, "timed_out_event_name", String.class, null);
        AbstractC2001nt0.O(bundle2, "timed_out_event_params", Bundle.class, null);
        AbstractC2001nt0.O(bundle2, "triggered_event_name", String.class, null);
        AbstractC2001nt0.O(bundle2, "triggered_event_params", Bundle.class, null);
        AbstractC2001nt0.O(bundle2, "time_to_live", Long.class, 0L);
        AbstractC2001nt0.O(bundle2, "expired_event_name", String.class, null);
        AbstractC2001nt0.O(bundle2, "expired_event_params", Bundle.class, null);
        Preconditions.checkNotEmpty(bundle2.getString("name"));
        Preconditions.checkNotEmpty(bundle2.getString("origin"));
        Preconditions.checkNotNull(bundle2.get("value"));
        bundle2.putLong("creation_timestamp", j);
        String string = bundle2.getString("name");
        Object obj = bundle2.get("value");
        C2574tv0 c2574tv0 = kr0.i;
        Eq0 eq0 = kr0.j;
        Nq0 nq02 = kr0.f;
        Kr0.j(c2574tv0);
        if (c2574tv0.w0(string) != 0) {
            Kr0.l(nq02);
            nq02.f.c(eq0.c(string), "Invalid conditional user property name");
            return;
        }
        Kr0.j(c2574tv0);
        if (c2574tv0.F(obj, string) != 0) {
            Kr0.l(nq02);
            nq02.f.d("Invalid conditional user property value", eq0.c(string), obj);
            return;
        }
        Object objG = c2574tv0.G(obj, string);
        if (objG == null) {
            Kr0.l(nq02);
            nq02.f.d("Unable to normalize conditional user property value", eq0.c(string), obj);
            return;
        }
        AbstractC2001nt0.N(bundle2, objG);
        long j2 = bundle2.getLong("trigger_timeout");
        if (!TextUtils.isEmpty(bundle2.getString("trigger_event_name")) && (j2 > 15552000000L || j2 < 1)) {
            Kr0.l(nq02);
            nq02.f.d("Invalid conditional user property timeout", eq0.c(string), Long.valueOf(j2));
            return;
        }
        long j3 = bundle2.getLong("time_to_live");
        if (j3 > 15552000000L || j3 < 1) {
            Kr0.l(nq02);
            nq02.f.d("Invalid conditional user property time to live", eq0.c(string), Long.valueOf(j3));
        } else {
            Fr0 fr0 = kr0.g;
            Kr0.l(fr0);
            fr0.B(new Is0(this, bundle2, 0));
        }
    }

    public final void G(String str, String str2, Bundle bundle) {
        Kr0 kr0 = (Kr0) this.a;
        long jCurrentTimeMillis = kr0.k.currentTimeMillis();
        Preconditions.checkNotEmpty(str);
        Bundle bundle2 = new Bundle();
        bundle2.putString("name", str);
        bundle2.putLong("creation_timestamp", jCurrentTimeMillis);
        if (str2 != null) {
            bundle2.putString("expired_event_name", str2);
            bundle2.putBundle("expired_event_params", bundle);
        }
        Fr0 fr0 = kr0.g;
        Kr0.l(fr0);
        fr0.B(new Is0(this, bundle2, 1));
    }

    public final String H() {
        Kr0 kr0 = (Kr0) this.a;
        try {
            return AbstractC0662Zn.N(kr0.a, kr0.p);
        } catch (IllegalStateException e) {
            Nq0 nq0 = kr0.f;
            Kr0.l(nq0);
            nq0.f.c(e, "getGoogleAppId failed with exception");
            return null;
        }
    }

    public final void I(C2284qs0 c2284qs0, long j, boolean z) {
        int i = c2284qs0.b;
        r();
        t();
        Kr0 kr0 = (Kr0) this.a;
        C1617jr0 c1617jr0 = kr0.e;
        Nq0 nq0 = kr0.f;
        Kr0.j(c1617jr0);
        C2284qs0 c2284qs0Z = c1617jr0.z();
        if (j <= this.q && C2284qs0.l(c2284qs0Z.b, i)) {
            Kr0.l(nq0);
            nq0.l.c(c2284qs0, "Dropped out-of-date consent setting, proposed settings");
            return;
        }
        C1617jr0 c1617jr02 = kr0.e;
        Kr0.j(c1617jr02);
        c1617jr02.r();
        if (!C2284qs0.l(i, c1617jr02.w().getInt("consent_source", 100))) {
            Kr0.l(nq0);
            nq0.l.c(Integer.valueOf(i), "Lower precedence consent source ignored, proposed source");
            return;
        }
        SharedPreferences.Editor editorEdit = c1617jr02.w().edit();
        editorEdit.putString("consent_settings", c2284qs0.g());
        editorEdit.putInt("consent_source", i);
        editorEdit.apply();
        Kr0.l(nq0);
        nq0.n.c(c2284qs0, "Setting storage consent(FE)");
        this.q = j;
        if (kr0.o().C()) {
            Vt0 vt0O = kr0.o();
            vt0O.r();
            vt0O.t();
            vt0O.G(new Pt0(vt0O, 2));
        } else {
            Vt0 vt0O2 = kr0.o();
            vt0O2.r();
            vt0O2.t();
            if (vt0O2.B()) {
                vt0O2.G(new RunnableC2950xt0(vt0O2, vt0O2.I(false)));
            }
        }
        if (z) {
            kr0.o().w(new AtomicReference());
        }
    }

    public final void J(Boolean bool, boolean z) {
        r();
        t();
        Kr0 kr0 = (Kr0) this.a;
        Nq0 nq0 = kr0.f;
        Kr0.l(nq0);
        nq0.m.c(bool, "Setting app measurement enabled (FE)");
        C1617jr0 c1617jr0 = kr0.e;
        Kr0.j(c1617jr0);
        c1617jr0.r();
        SharedPreferences.Editor editorEdit = c1617jr0.w().edit();
        if (bool != null) {
            editorEdit.putBoolean("measurement_enabled", bool.booleanValue());
        } else {
            editorEdit.remove("measurement_enabled");
        }
        editorEdit.apply();
        if (z) {
            c1617jr0.r();
            SharedPreferences.Editor editorEdit2 = c1617jr0.w().edit();
            if (bool != null) {
                editorEdit2.putBoolean("measurement_enabled_from_api", bool.booleanValue());
            } else {
                editorEdit2.remove("measurement_enabled_from_api");
            }
            editorEdit2.apply();
        }
        Fr0 fr0 = kr0.g;
        Kr0.l(fr0);
        fr0.r();
        if (kr0.z || !(bool == null || bool.booleanValue())) {
            K();
        }
    }

    public final void K() {
        r();
        Kr0 kr0 = (Kr0) this.a;
        C1617jr0 c1617jr0 = kr0.e;
        Nq0 nq0 = kr0.f;
        Clock clock = kr0.k;
        Kr0.j(c1617jr0);
        String strG = c1617jr0.m.g();
        if (strG != null) {
            if ("unset".equals(strG)) {
                D(clock.currentTimeMillis(), null, "app", "_npa");
            } else {
                D(clock.currentTimeMillis(), Long.valueOf(true != "true".equals(strG) ? 0L : 1L), "app", "_npa");
            }
        }
        if (!kr0.a() || !this.s) {
            Kr0.l(nq0);
            nq0.m.b("Updating Scion state (FE)");
            Vt0 vt0O = kr0.o();
            vt0O.r();
            vt0O.t();
            vt0O.G(new RunnableC2950xt0(vt0O, vt0O.I(true), 3));
            return;
        }
        Kr0.l(nq0);
        nq0.m.b("Recording app launch after enabling measurement for the first time (FE)");
        E();
        C2382ru0 c2382ru0 = kr0.h;
        Kr0.k(c2382ru0);
        c2382ru0.e.n();
        Fr0 fr0 = kr0.g;
        Kr0.l(fr0);
        fr0.B(new RunnableC2853ws0(this, 1));
    }

    public final void L() {
        Kr0 kr0 = (Kr0) this.a;
        if (!(kr0.a.getApplicationContext() instanceof Application) || this.c == null) {
            return;
        }
        ((Application) kr0.a.getApplicationContext()).unregisterActivityLifecycleCallbacks(this.c);
    }

    public final void M(Bundle bundle, int i, long j) {
        Boolean bool;
        String string;
        EnumC1809ls0 enumC1809ls0;
        Kr0 kr0 = (Kr0) this.a;
        t();
        C2284qs0 c2284qs0 = C2284qs0.c;
        EnumC2094os0[] enumC2094os0Arr = EnumC1999ns0.STORAGE.l;
        int length = enumC2094os0Arr.length;
        int i2 = 0;
        while (true) {
            bool = null;
            if (i2 >= length) {
                string = null;
                break;
            }
            String str = enumC2094os0Arr[i2].l;
            if (bundle.containsKey(str) && (string = bundle.getString(str)) != null) {
                if ((string.equals("granted") ? Boolean.TRUE : string.equals("denied") ? Boolean.FALSE : null) == null) {
                    break;
                }
            }
            i2++;
        }
        if (string != null) {
            Nq0 nq0 = kr0.f;
            Kr0.l(nq0);
            nq0.k.c(string, "Ignoring invalid consent setting");
            Nq0 nq02 = kr0.f;
            Kr0.l(nq02);
            nq02.k.b("Valid consent values are 'granted', 'denied'");
        }
        Fr0 fr0 = kr0.g;
        Kr0.l(fr0);
        boolean zY = fr0.y();
        C2284qs0 c2284qs0B = C2284qs0.b(i, bundle);
        Iterator it = c2284qs0B.a.values().iterator();
        while (true) {
            boolean zHasNext = it.hasNext();
            enumC1809ls0 = EnumC1809ls0.m;
            if (!zHasNext) {
                break;
            } else if (((EnumC1809ls0) it.next()) != enumC1809ls0) {
                O(c2284qs0B, zY);
                break;
            }
        }
        C3130zo0 c3130zo0C = C3130zo0.c(i, bundle);
        Iterator it2 = c3130zo0C.e.values().iterator();
        while (true) {
            if (!it2.hasNext()) {
                break;
            } else if (((EnumC1809ls0) it2.next()) != enumC1809ls0) {
                N(c3130zo0C, zY);
                break;
            }
        }
        if (bundle != null) {
            int iOrdinal = C2284qs0.d(bundle.getString("ad_personalization")).ordinal();
            if (iOrdinal == 2) {
                bool = Boolean.FALSE;
            } else if (iOrdinal == 3) {
                bool = Boolean.TRUE;
            }
        }
        if (bool != null) {
            String str2 = i == -30 ? "tcf" : "app";
            if (zY) {
                D(j, bool.toString(), str2, "allow_personalized_ads");
            } else {
                C(str2, "allow_personalized_ads", bool.toString(), false, j);
            }
        }
    }

    public final void N(C3130zo0 c3130zo0, boolean z) {
        Js0 js0 = new Js0(2, this, c3130zo0);
        if (z) {
            r();
            js0.run();
        } else {
            Fr0 fr0 = ((Kr0) this.a).g;
            Kr0.l(fr0);
            fr0.B(js0);
        }
    }

    /*  JADX ERROR: JadxRuntimeException in pass: RegionMakerVisitor
        jadx.core.utils.exceptions.JadxRuntimeException: Can't find top splitter block for handler:B:70:0x0116
        	at jadx.core.utils.BlockUtils.getTopSplitterForHandler(BlockUtils.java:1178)
        	at jadx.core.dex.visitors.regions.maker.ExcHandlersRegionMaker.collectHandlerRegions(ExcHandlersRegionMaker.java:53)
        	at jadx.core.dex.visitors.regions.maker.ExcHandlersRegionMaker.process(ExcHandlersRegionMaker.java:38)
        	at jadx.core.dex.visitors.regions.RegionMakerVisitor.visit(RegionMakerVisitor.java:27)
        */
    public final void O(o.C2284qs0 r14, boolean r15) {
        /*
            Method dump skipped, instructions count: 280
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.Xs0.O(o.qs0, boolean):void");
    }

    public final void P() {
        Xv0.a();
        Kr0 kr0 = (Kr0) this.a;
        C1421ho0 c1421ho0 = kr0.d;
        Fr0 fr0 = kr0.g;
        Nq0 nq0 = kr0.f;
        if (c1421ho0.C(null, AbstractC1900mq0.Q0)) {
            Kr0.l(fr0);
            if (fr0.y()) {
                Kr0.l(nq0);
                nq0.f.b("Cannot get trigger URIs from analytics worker thread");
                return;
            }
            if (C2616uQ.x()) {
                Kr0.l(nq0);
                nq0.f.b("Cannot get trigger URIs from main thread");
                return;
            }
            t();
            Kr0.l(nq0);
            nq0.n.b("Getting trigger URIs (FE)");
            AtomicReference atomicReference = new AtomicReference();
            Kr0.l(fr0);
            fr0.C(atomicReference, 10000L, "get trigger URIs", new Hs0(this, atomicReference, 5, false));
            List list = (List) atomicReference.get();
            if (list == null) {
                Kr0.l(nq0);
                nq0.h.b("Timed out waiting for get trigger URIs");
            } else {
                Kr0.l(fr0);
                fr0.B(new Js0(4, this, list));
            }
        }
    }

    public final PriorityQueue Q() {
        if (this.m == null) {
            this.m = new PriorityQueue(Comparator.comparing(Ts0.a, C1746lA.g));
        }
        return this.m;
    }

    public final void R() {
        C2762vu0 c2762vu0;
        r();
        this.n = false;
        if (Q().isEmpty() || this.i || (c2762vu0 = (C2762vu0) Q().poll()) == null) {
            return;
        }
        Kr0 kr0 = (Kr0) this.a;
        C2574tv0 c2574tv0 = kr0.i;
        Kr0.j(c2574tv0);
        C2614uO c2614uOL = c2574tv0.L();
        if (c2614uOL != null) {
            this.i = true;
            Nq0 nq0 = kr0.f;
            Kr0.l(nq0);
            C1984nl c1984nl = nq0.n;
            String str = c2762vu0.l;
            c1984nl.c(str, "Registering trigger URI");
            YL ylE = c2614uOL.e(Uri.parse(str));
            if (ylE != null) {
                ylE.a(new RunnableC0890cD(0, ylE, new Gm0(15, this, c2762vu0)), new ExecutorC1921n20(3, this));
            } else {
                this.i = false;
                Q().add(c2762vu0);
            }
        }
    }

    @Override // o.AbstractC2090oq0
    public final boolean v() {
        return false;
    }

    public final void w(C2284qs0 c2284qs0) {
        r();
        boolean z = (c2284qs0.i(EnumC2094os0.n) && c2284qs0.i(EnumC2094os0.m)) || ((Kr0) this.a).o().B();
        Kr0 kr0 = (Kr0) this.a;
        Fr0 fr0 = kr0.g;
        Kr0.l(fr0);
        fr0.r();
        if (z != kr0.z) {
            Fr0 fr02 = kr0.g;
            Kr0.l(fr02);
            fr02.r();
            kr0.z = z;
            C1617jr0 c1617jr0 = ((Kr0) this.a).e;
            Kr0.j(c1617jr0);
            c1617jr0.r();
            Boolean boolValueOf = c1617jr0.w().contains("measurement_enabled_from_api") ? Boolean.valueOf(c1617jr0.w().getBoolean("measurement_enabled_from_api", true)) : null;
            if (!z || boolValueOf == null || boolValueOf.booleanValue()) {
                J(Boolean.valueOf(z), false);
            }
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:21:0x0055, code lost:
    
        if (r4 > 500) goto L22;
     */
    /* JADX WARN: Code restructure failed: missing block: B:30:0x008c, code lost:
    
        if (r6 > 500) goto L31;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void x(java.lang.String r13, java.lang.String r14, android.os.Bundle r15, boolean r16, boolean r17, long r18) {
        /*
            Method dump skipped, instructions count: 474
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.Xs0.x(java.lang.String, java.lang.String, android.os.Bundle, boolean, boolean, long):void");
    }

    public final void y() {
        Nq0 nq0;
        String str;
        int i;
        int i2;
        int i3;
        int i4;
        C2477su0 c2477su0;
        C2477su0 c2477su02;
        Xs0 xs0;
        int i5;
        int i6;
        int i7;
        int i8;
        int i9;
        int i10;
        String str2;
        char[] cArr;
        Ms0 ms0;
        M10 m10C;
        r();
        Kr0 kr0 = (Kr0) this.a;
        Nq0 nq02 = kr0.f;
        Clock clock = kr0.k;
        Kr0.l(nq02);
        nq02.m.b("Handle tcf update.");
        C1617jr0 c1617jr0 = kr0.e;
        Kr0.j(c1617jr0);
        SharedPreferences sharedPreferencesX = c1617jr0.x();
        HashMap map = new HashMap();
        C1805lq0 c1805lq0 = AbstractC1900mq0.Z0;
        int i11 = 2;
        int i12 = 1;
        if (((Boolean) c1805lq0.a(null)).booleanValue()) {
            H10 h10 = AbstractC2667uu0.a;
            Ls0 ls0 = Ls0.m;
            nq0 = nq02;
            EnumC2572tu0 enumC2572tu0 = EnumC2572tu0.l;
            AbstractMap.SimpleImmutableEntry simpleImmutableEntry = new AbstractMap.SimpleImmutableEntry(ls0, enumC2572tu0);
            Ls0 ls02 = Ls0.n;
            EnumC2572tu0 enumC2572tu02 = EnumC2572tu0.m;
            AbstractMap.SimpleImmutableEntry simpleImmutableEntry2 = new AbstractMap.SimpleImmutableEntry(ls02, enumC2572tu02);
            Ls0 ls03 = Ls0.f216o;
            AbstractMap.SimpleImmutableEntry simpleImmutableEntry3 = new AbstractMap.SimpleImmutableEntry(ls03, enumC2572tu0);
            Ls0 ls04 = Ls0.p;
            AbstractMap.SimpleImmutableEntry simpleImmutableEntry4 = new AbstractMap.SimpleImmutableEntry(ls04, enumC2572tu0);
            Ls0 ls05 = Ls0.q;
            List listAsList = Arrays.asList(simpleImmutableEntry, simpleImmutableEntry2, simpleImmutableEntry3, simpleImmutableEntry4, new AbstractMap.SimpleImmutableEntry(ls05, enumC2572tu02), new AbstractMap.SimpleImmutableEntry(Ls0.r, enumC2572tu02), new AbstractMap.SimpleImmutableEntry(Ls0.s, enumC2572tu02));
            C0692a8 c0692a8 = new C0692a8(listAsList != null ? listAsList.size() : 4, 4);
            c0692a8.n(listAsList);
            M10 m10C2 = c0692a8.c();
            int i13 = UG.n;
            Q80 q80 = new Q80("CH");
            char[] cArr2 = new char[5];
            boolean zContains = sharedPreferencesX.contains("IABTCF_TCString");
            try {
                i5 = sharedPreferencesX.getInt("IABTCF_CmpSdkID", -1);
            } catch (ClassCastException unused) {
                i5 = -1;
            }
            try {
                i6 = sharedPreferencesX.getInt("IABTCF_PolicyVersion", -1);
            } catch (ClassCastException unused2) {
                i6 = -1;
            }
            try {
                i7 = sharedPreferencesX.getInt("IABTCF_gdprApplies", -1);
            } catch (ClassCastException unused3) {
                i7 = -1;
            }
            int i14 = i6;
            try {
                i8 = sharedPreferencesX.getInt("IABTCF_PurposeOneTreatment", -1);
            } catch (ClassCastException unused4) {
                i8 = -1;
            }
            try {
                i9 = sharedPreferencesX.getInt("IABTCF_EnableAdvertiserConsentMode", -1);
            } catch (ClassCastException unused5) {
                i9 = -1;
            }
            String strA = AbstractC2667uu0.a(sharedPreferencesX, "IABTCF_PublisherCC");
            int i15 = i5;
            C0692a8 c0692a82 = new C0692a8(4, 4);
            K10 k10 = m10C2.m;
            if (k10 == null) {
                cArr = cArr2;
                str2 = strA;
                i10 = i8;
                K10 k102 = new K10(m10C2, new L10(m10C2.p, 0, m10C2.q));
                m10C2.m = k102;
                k10 = k102;
            } else {
                i10 = i8;
                str2 = strA;
                cArr = cArr2;
            }
            Sh0 it = k10.iterator();
            while (true) {
                boolean zHasNext = it.hasNext();
                ms0 = Ms0.p;
                if (!zHasNext) {
                    break;
                }
                Ls0 ls06 = (Ls0) it.next();
                int iZza = ls06.zza();
                Sh0 sh0 = it;
                M10 m10 = m10C2;
                StringBuilder sb = new StringBuilder(String.valueOf(iZza).length() + 28);
                sb.append("IABTCF_PublisherRestrictions");
                sb.append(iZza);
                String strA2 = AbstractC2667uu0.a(sharedPreferencesX, sb.toString());
                if (!TextUtils.isEmpty(strA2) && strA2.length() >= 755) {
                    int iDigit = Character.digit(strA2.charAt(754), 10);
                    Ms0 ms02 = Ms0.m;
                    if (iDigit < 0 || iDigit > Ms0.values().length || iDigit == 0) {
                        ms0 = ms02;
                    } else if (iDigit == i12) {
                        ms0 = Ms0.n;
                    } else if (iDigit == i11) {
                        ms0 = Ms0.f245o;
                    }
                }
                c0692a82.m(ls06, ms0);
                it = sh0;
                m10C2 = m10;
                i11 = 2;
                i12 = 1;
            }
            M10 m102 = m10C2;
            M10 m10C3 = c0692a82.c();
            String strA3 = AbstractC2667uu0.a(sharedPreferencesX, "IABTCF_PurposeConsents");
            String strA4 = AbstractC2667uu0.a(sharedPreferencesX, "IABTCF_VendorConsents");
            boolean z = !TextUtils.isEmpty(strA4) && strA4.length() >= 755 && strA4.charAt(754) == '1';
            String strA5 = AbstractC2667uu0.a(sharedPreferencesX, "IABTCF_PurposeLegitimateInterests");
            String strA6 = AbstractC2667uu0.a(sharedPreferencesX, "IABTCF_VendorLegitimateInterests");
            boolean z2 = !TextUtils.isEmpty(strA6) && strA6.length() >= 755 && strA6.charAt(754) == '1';
            cArr[0] = '2';
            if (zContains) {
                Ms0 ms03 = (Ms0) m10C3.get(ls0);
                Ms0 ms04 = (Ms0) m10C3.get(ls03);
                Ms0 ms05 = (Ms0) m10C3.get(ls04);
                Ms0 ms06 = (Ms0) m10C3.get(ls05);
                C0692a8 c0692a83 = new C0692a8(4, 4);
                c0692a83.m("Version", "2");
                boolean z3 = z;
                c0692a83.m("VendorConsent", true != z ? "0" : "1");
                boolean z4 = z2;
                c0692a83.m("VendorLegitimateInterest", true != z2 ? "0" : "1");
                c0692a83.m("gdprApplies", i7 != 1 ? "0" : "1");
                c0692a83.m("EnableAdvertiserConsentMode", i9 != 1 ? "0" : "1");
                c0692a83.m("PolicyVersion", String.valueOf(i14));
                c0692a83.m("CmpSdkID", String.valueOf(i15));
                int i16 = i10;
                c0692a83.m("PurposeOneTreatment", i16 != 1 ? "0" : "1");
                String str3 = str2;
                c0692a83.m("PublisherCC", str3);
                c0692a83.m("PublisherRestrictions1", String.valueOf(ms03 != null ? ms03.zza() : ms0.zza()));
                c0692a83.m("PublisherRestrictions3", String.valueOf(ms04 != null ? ms04.zza() : ms0.zza()));
                c0692a83.m("PublisherRestrictions4", String.valueOf(ms05 != null ? ms05.zza() : ms0.zza()));
                c0692a83.m("PublisherRestrictions7", String.valueOf(ms06 != null ? ms06.zza() : ms0.zza()));
                String strD = AbstractC2667uu0.d(ls0, strA3, strA5);
                String strD2 = AbstractC2667uu0.d(ls03, strA3, strA5);
                String strD3 = AbstractC2667uu0.d(ls04, strA3, strA5);
                String strD4 = AbstractC2667uu0.d(ls05, strA3, strA5);
                F3.j("Purpose1", strD);
                F3.j("Purpose3", strD2);
                F3.j("Purpose4", strD3);
                F3.j("Purpose7", strD4);
                c0692a83.n(M10.b(4, new Object[]{"Purpose1", strD, "Purpose3", strD2, "Purpose4", strD3, "Purpose7", strD4}, null).entrySet());
                int i17 = i9;
                int i18 = i7;
                c0692a83.n(M10.b(5, new Object[]{"AuthorizePurpose1", true != AbstractC2667uu0.b(ls0, m102, m10C3, q80, cArr, i17, i18, i16, str3, strA3, strA5, z3, z4) ? "0" : "1", "AuthorizePurpose3", true != AbstractC2667uu0.b(ls03, m102, m10C3, q80, cArr, i17, i18, i16, str3, strA3, strA5, z3, z4) ? "0" : "1", "AuthorizePurpose4", true != AbstractC2667uu0.b(ls04, m102, m10C3, q80, cArr, i17, i18, i16, str3, strA3, strA5, z3, z4) ? "0" : "1", "AuthorizePurpose7", true != AbstractC2667uu0.b(ls05, m102, m10C3, q80, cArr, i17, i18, i16, str3, strA3, strA5, z3, z4) ? "0" : "1", "PurposeDiagnostics", new String(cArr)}, null).entrySet());
                m10C = c0692a83.c();
            } else {
                m10C = M10.r;
            }
            c2477su0 = new C2477su0(m10C);
            str = "";
        } else {
            nq0 = nq02;
            String strA7 = AbstractC2667uu0.a(sharedPreferencesX, "IABTCF_VendorConsents");
            str = "";
            if (!str.equals(strA7) && strA7.length() > 754) {
                map.put("GoogleConsent", String.valueOf(strA7.charAt(754)));
            }
            try {
                i = sharedPreferencesX.getInt("IABTCF_gdprApplies", -1);
            } catch (ClassCastException unused6) {
                i = -1;
            }
            if (i != -1) {
                map.put("gdprApplies", String.valueOf(i));
            }
            try {
                i2 = sharedPreferencesX.getInt("IABTCF_EnableAdvertiserConsentMode", -1);
            } catch (ClassCastException unused7) {
                i2 = -1;
            }
            if (i2 != -1) {
                map.put("EnableAdvertiserConsentMode", String.valueOf(i2));
            }
            try {
                i3 = sharedPreferencesX.getInt("IABTCF_PolicyVersion", -1);
            } catch (ClassCastException unused8) {
                i3 = -1;
            }
            if (i3 != -1) {
                map.put("PolicyVersion", String.valueOf(i3));
            }
            String strA8 = AbstractC2667uu0.a(sharedPreferencesX, "IABTCF_PurposeConsents");
            if (!str.equals(strA8)) {
                map.put("PurposeConsents", strA8);
            }
            try {
                i4 = sharedPreferencesX.getInt("IABTCF_CmpSdkID", -1);
            } catch (ClassCastException unused9) {
                i4 = -1;
            }
            if (i4 != -1) {
                map.put("CmpSdkID", String.valueOf(i4));
            }
            c2477su0 = new C2477su0(map);
        }
        Kr0.l(nq0);
        Nq0 nq03 = nq0;
        C1984nl c1984nl = nq03.n;
        c1984nl.c(c2477su0, "Tcf preferences read");
        if (!kr0.d.C(null, c1805lq0)) {
            if (c1617jr0.A(c2477su0)) {
                Bundle bundleB = c2477su0.b();
                Kr0.l(nq03);
                c1984nl.c(bundleB, "Consent generated from Tcf");
                if (bundleB != Bundle.EMPTY) {
                    M(bundleB, -30, clock.currentTimeMillis());
                }
                Bundle bundle = new Bundle();
                bundle.putString("_tcfd", c2477su0.c());
                z("auto", "_tcf", bundle);
                return;
            }
            return;
        }
        c1617jr0.r();
        String string = c1617jr0.w().getString("stored_tcf_param", str);
        HashMap map2 = new HashMap();
        if (TextUtils.isEmpty(string)) {
            c2477su02 = new C2477su0(map2);
        } else {
            for (String str4 : string.split(";")) {
                String[] strArrSplit = str4.split("=");
                if (strArrSplit.length >= 2 && AbstractC2667uu0.a.contains(strArrSplit[0])) {
                    map2.put(strArrSplit[0], strArrSplit[1]);
                }
            }
            c2477su02 = new C2477su0(map2);
        }
        if (c1617jr0.A(c2477su0)) {
            Bundle bundleB2 = c2477su0.b();
            Kr0.l(nq03);
            c1984nl.c(bundleB2, "Consent generated from Tcf");
            if (bundleB2 != Bundle.EMPTY) {
                xs0 = this;
                xs0.M(bundleB2, -30, clock.currentTimeMillis());
            } else {
                xs0 = this;
            }
            Bundle bundle2 = new Bundle();
            HashMap map3 = c2477su02.a;
            String str5 = (map3.isEmpty() || ((String) map3.get("Version")) != null) ? "0" : "1";
            Bundle bundleB3 = c2477su0.b();
            Bundle bundleB4 = c2477su02.b();
            bundle2.putString("_tcfm", str5.concat((bundleB3.size() == bundleB4.size() && Objects.equals(bundleB3.getString("ad_storage"), bundleB4.getString("ad_storage")) && Objects.equals(bundleB3.getString("ad_personalization"), bundleB4.getString("ad_personalization")) && Objects.equals(bundleB3.getString("ad_user_data"), bundleB4.getString("ad_user_data"))) ? "0" : "1"));
            String str6 = (String) c2477su0.a.get("PurposeDiagnostics");
            if (TextUtils.isEmpty(str6)) {
                str6 = "200000";
            }
            bundle2.putString("_tcfd2", str6);
            bundle2.putString("_tcfd", c2477su0.c());
            xs0.z("auto", "_tcf", bundle2);
        }
    }

    public final void z(String str, String str2, Bundle bundle) {
        r();
        A(((Kr0) this.a).k.currentTimeMillis(), bundle, str, str2);
    }
}
