package d3;

import C3.AbstractC0055q;
import N1.C0215p;
import O1.C0225a;
import P2.C0253j;
import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.SystemClock;
import android.text.TextUtils;
import com.google.android.gms.internal.measurement.J3;
import com.google.android.gms.measurement.internal.AppMeasurementDynamiteService;
import d5.AbstractC0844a;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
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;

/* JADX INFO: loaded from: classes.dex */
public final class Y0 extends F {

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    public P0 f11842A;

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    public P0 f11843B;

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    public PriorityQueue f11844C;
    public boolean D;

    /* JADX INFO: renamed from: E, reason: collision with root package name */
    public F0 f11845E;

    /* JADX INFO: renamed from: F, reason: collision with root package name */
    public final AtomicLong f11846F;

    /* JADX INFO: renamed from: G, reason: collision with root package name */
    public long f11847G;
    public final C0791i0 H;

    /* JADX INFO: renamed from: I, reason: collision with root package name */
    public boolean f11848I;

    /* JADX INFO: renamed from: J, reason: collision with root package name */
    public P0 f11849J;

    /* JADX INFO: renamed from: K, reason: collision with root package name */
    public O0 f11850K;

    /* JADX INFO: renamed from: L, reason: collision with root package name */
    public P0 f11851L;

    /* JADX INFO: renamed from: M, reason: collision with root package name */
    public final V0 f11852M;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public X0 f11853s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public C0225a f11854t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public final CopyOnWriteArraySet f11855u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public boolean f11856v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public final AtomicReference f11857w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public final Object f11858x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public boolean f11859y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public int f11860z;

    public Y0(C0817r0 c0817r0) {
        super(c0817r0);
        this.f11855u = new CopyOnWriteArraySet();
        this.f11858x = new Object();
        this.f11859y = false;
        this.f11860z = 1;
        this.f11848I = true;
        this.f11852M = new V0(0, this);
        this.f11857w = new AtomicReference();
        this.f11845E = F0.f11457c;
        this.f11847G = -1L;
        this.f11846F = new AtomicLong(0L);
        this.H = new C0791i0(c0817r0, 3);
    }

    public static void I(Y0 y02, F0 f02, long j8, boolean z8) {
        y02.E();
        y02.F();
        C0817r0 c0817r0 = (C0817r0) y02.f5146q;
        C0785g0 c0785g0 = c0817r0.f12149x;
        C0817r0.i(c0785g0);
        F0 f0L = c0785g0.L();
        long j9 = y02.f11847G;
        int i = f02.f11459b;
        Z z9 = c0817r0.f12150y;
        if (j8 <= j9 && F0.l(f0L.f11459b, i)) {
            C0817r0.k(z9);
            z9.f11870B.c(f02, "Dropped out-of-date consent setting, proposed settings");
            return;
        }
        C0785g0 c0785g02 = c0817r0.f12149x;
        C0817r0.i(c0785g02);
        c0785g02.E();
        if (!F0.l(i, c0785g02.J().getInt("consent_source", 100))) {
            C0817r0.k(z9);
            z9.f11870B.c(Integer.valueOf(i), "Lower precedence consent source ignored, proposed source");
            return;
        }
        SharedPreferences.Editor editorEdit = c0785g02.J().edit();
        editorEdit.putString("consent_settings", f02.j());
        editorEdit.putInt("consent_source", i);
        editorEdit.apply();
        C0817r0.k(z9);
        z9.D.c(f02, "Setting storage consent(FE)");
        y02.f11847G = j8;
        if (c0817r0.r().Q()) {
            C0824t1 c0824t1R = c0817r0.r();
            c0824t1R.E();
            c0824t1R.F();
            c0824t1R.V(new RunnableC0798k1(c0824t1R, 0));
        } else {
            C0824t1 c0824t1R2 = c0817r0.r();
            c0824t1R2.E();
            c0824t1R2.F();
            if (c0824t1R2.P()) {
                c0824t1R2.V(new RunnableC0813p1(c0824t1R2, c0824t1R2.S(false), 4));
            }
        }
        if (z8) {
            c0817r0.r().K(new AtomicReference());
        }
    }

    @Override // d3.F
    public final boolean H() {
        return false;
    }

    public final void J() {
        E();
        F();
        C0817r0 c0817r0 = (C0817r0) this.f5146q;
        if (c0817r0.g()) {
            C0784g c0784g = c0817r0.f12148w;
            ((C0817r0) c0784g.f5146q).getClass();
            Boolean boolP = c0784g.P("google_analytics_deferred_deep_link_enabled");
            if (boolP != null && boolP.booleanValue()) {
                Z z8 = c0817r0.f12150y;
                C0817r0.k(z8);
                z8.f11871C.b("Deferred Deep Link feature enabled.");
                C0815q0 c0815q0 = c0817r0.f12151z;
                C0817r0.k(c0815q0);
                c0815q0.O(new N0(this, 0));
            }
            C0824t1 c0824t1R = c0817r0.r();
            c0824t1R.E();
            c0824t1R.F();
            X1 x1S = c0824t1R.S(true);
            c0824t1R.W();
            C0817r0 c0817r02 = (C0817r0) c0824t1R.f5146q;
            c0817r02.f12148w.R(null, I.f11570m1);
            c0817r02.o().L(3, new byte[0]);
            c0824t1R.V(new RunnableC0813p1(c0824t1R, x1S, 1));
            this.f11848I = false;
            C0785g0 c0785g0 = c0817r0.f12149x;
            C0817r0.i(c0785g0);
            c0785g0.E();
            String string = c0785g0.J().getString("previous_os_version", null);
            ((C0817r0) c0785g0.f5146q).m().G();
            String str = Build.VERSION.RELEASE;
            if (!TextUtils.isEmpty(str) && !str.equals(string)) {
                SharedPreferences.Editor editorEdit = c0785g0.J().edit();
                editorEdit.putString("previous_os_version", str);
                editorEdit.apply();
            }
            if (TextUtils.isEmpty(string)) {
                return;
            }
            c0817r0.m().G();
            if (string.equals(str)) {
                return;
            }
            Bundle bundle = new Bundle();
            bundle.putString("_po", string);
            P("auto", "_ou", bundle);
        }
    }

    public final void K(String str, String str2, Bundle bundle) {
        C0817r0 c0817r0 = (C0817r0) this.f5146q;
        c0817r0.D.getClass();
        long jCurrentTimeMillis = System.currentTimeMillis();
        P2.w.c(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);
        }
        C0815q0 c0815q0 = c0817r0.f12151z;
        C0817r0.k(c0815q0);
        c0815q0.O(new L0(this, bundle2, 2));
    }

    public final void L() {
        C0817r0 c0817r0 = (C0817r0) this.f5146q;
        if (!(c0817r0.f12142q.getApplicationContext() instanceof Application) || this.f11853s == null) {
            return;
        }
        ((Application) c0817r0.f12142q.getApplicationContext()).unregisterActivityLifecycleCallbacks(this.f11853s);
    }

    public final void M() {
        J3.b();
        C0817r0 c0817r0 = (C0817r0) this.f5146q;
        if (c0817r0.f12148w.R(null, I.f11529X0)) {
            C0815q0 c0815q0 = c0817r0.f12151z;
            C0817r0.k(c0815q0);
            boolean zQ = c0815q0.Q();
            Z z8 = c0817r0.f12150y;
            if (zQ) {
                C0817r0.k(z8);
                z8.f11875v.b("Cannot get trigger URIs from analytics worker thread");
                return;
            }
            if (C0253j.s()) {
                C0817r0.k(z8);
                z8.f11875v.b("Cannot get trigger URIs from main thread");
                return;
            }
            F();
            C0817r0.k(z8);
            z8.D.b("Getting trigger URIs (FE)");
            AtomicReference atomicReference = new AtomicReference();
            C0817r0.k(c0815q0);
            c0815q0.J(atomicReference, 10000L, "get trigger URIs", new K0(this, atomicReference, 0));
            List list = (List) atomicReference.get();
            if (list == null) {
                C0817r0.k(z8);
                z8.f11875v.b("Timed out waiting for get trigger URIs");
            } else {
                C0817r0.k(c0815q0);
                c0815q0.O(new G3.b(this, 12, list));
            }
        }
    }

    public final void N() {
        C0817r0 c0817r0;
        String str;
        B1 b12;
        B1 b13;
        Y0 y02;
        com.google.android.gms.internal.measurement.L1 l12;
        com.google.android.gms.internal.measurement.L1 l13;
        E();
        C0817r0 c0817r02 = (C0817r0) this.f5146q;
        Z z8 = c0817r02.f12150y;
        C0817r0.k(z8);
        z8.f11871C.b("Handle tcf update.");
        C0785g0 c0785g0 = c0817r02.f12149x;
        C0817r0.i(c0785g0);
        SharedPreferences sharedPreferencesI = c0785g0.I();
        HashMap map = new HashMap();
        H h8 = I.f11564k1;
        int i = 2;
        int i5 = 1;
        if (((Boolean) h8.a(null)).booleanValue()) {
            C3.W w4 = D1.f11445a;
            com.google.android.gms.internal.measurement.K1 k12 = com.google.android.gms.internal.measurement.K1.f9623r;
            C1 c12 = C1.f11437q;
            c0817r0 = c0817r02;
            AbstractMap.SimpleImmutableEntry simpleImmutableEntry = new AbstractMap.SimpleImmutableEntry(k12, c12);
            com.google.android.gms.internal.measurement.K1 k13 = com.google.android.gms.internal.measurement.K1.f9624s;
            C1 c13 = C1.f11438r;
            AbstractMap.SimpleImmutableEntry simpleImmutableEntry2 = new AbstractMap.SimpleImmutableEntry(k13, c13);
            com.google.android.gms.internal.measurement.K1 k14 = com.google.android.gms.internal.measurement.K1.f9625t;
            AbstractMap.SimpleImmutableEntry simpleImmutableEntry3 = new AbstractMap.SimpleImmutableEntry(k14, c12);
            com.google.android.gms.internal.measurement.K1 k15 = com.google.android.gms.internal.measurement.K1.f9626u;
            AbstractMap.SimpleImmutableEntry simpleImmutableEntry4 = new AbstractMap.SimpleImmutableEntry(k15, c12);
            com.google.android.gms.internal.measurement.K1 k16 = com.google.android.gms.internal.measurement.K1.f9627v;
            List listAsList = Arrays.asList(simpleImmutableEntry, simpleImmutableEntry2, simpleImmutableEntry3, simpleImmutableEntry4, new AbstractMap.SimpleImmutableEntry(k16, c13), new AbstractMap.SimpleImmutableEntry(com.google.android.gms.internal.measurement.K1.f9628w, c13), new AbstractMap.SimpleImmutableEntry(com.google.android.gms.internal.measurement.K1.f9629x, c13));
            A1.H h9 = new A1.H(AbstractC0844a.w(listAsList) ? listAsList.size() : 4);
            h9.m(listAsList);
            C3.b0 b0VarD = h9.d();
            int i8 = C3.J.f1201s;
            C3.i0 i0Var = new C3.i0("CH");
            char[] cArr = new char[5];
            int iA = D1.a(sharedPreferencesI, "IABTCF_CmpSdkID");
            int iA2 = D1.a(sharedPreferencesI, "IABTCF_PolicyVersion");
            int iA3 = D1.a(sharedPreferencesI, "IABTCF_gdprApplies");
            int iA4 = D1.a(sharedPreferencesI, "IABTCF_PurposeOneTreatment");
            int iA5 = D1.a(sharedPreferencesI, "IABTCF_EnableAdvertiserConsentMode");
            String strB = D1.b(sharedPreferencesI, "IABTCF_PublisherCC");
            A1.H h10 = new A1.H(4);
            C3.k0 it = b0VarD.keySet().iterator();
            while (true) {
                boolean zHasNext = it.hasNext();
                l12 = com.google.android.gms.internal.measurement.L1.f9638u;
                C3.k0 k0Var = it;
                if (!zHasNext) {
                    break;
                }
                com.google.android.gms.internal.measurement.K1 k17 = (com.google.android.gms.internal.measurement.K1) k0Var.next();
                char[] cArr2 = cArr;
                String str2 = strB;
                int i9 = iA4;
                String strB2 = D1.b(sharedPreferencesI, "IABTCF_PublisherRestrictions" + k17.a());
                if (TextUtils.isEmpty(strB2) || strB2.length() < 755) {
                    l13 = l12;
                } else {
                    int iDigit = Character.digit(strB2.charAt(754), 10);
                    l13 = com.google.android.gms.internal.measurement.L1.f9635r;
                    if (iDigit >= 0 && iDigit <= com.google.android.gms.internal.measurement.L1.values().length && iDigit != 0) {
                        if (iDigit == i5) {
                            l12 = com.google.android.gms.internal.measurement.L1.f9636s;
                        } else if (iDigit == i) {
                            l12 = com.google.android.gms.internal.measurement.L1.f9637t;
                        }
                        l13 = l12;
                    }
                }
                h10.l(k17, l13);
                it = k0Var;
                cArr = cArr2;
                iA4 = i9;
                strB = str2;
                i = 2;
                i5 = 1;
            }
            String str3 = strB;
            int i10 = iA4;
            char[] cArr3 = cArr;
            C3.b0 b0VarD2 = h10.d();
            String strB3 = D1.b(sharedPreferencesI, "IABTCF_PurposeConsents");
            String strB4 = D1.b(sharedPreferencesI, "IABTCF_VendorConsents");
            boolean z9 = !TextUtils.isEmpty(strB4) && strB4.length() >= 755 && strB4.charAt(754) == '1';
            String strB5 = D1.b(sharedPreferencesI, "IABTCF_PurposeLegitimateInterests");
            String strB6 = D1.b(sharedPreferencesI, "IABTCF_VendorLegitimateInterests");
            boolean z10 = !TextUtils.isEmpty(strB6) && strB6.length() >= 755 && strB6.charAt(754) == '1';
            cArr3[0] = '2';
            com.google.android.gms.internal.measurement.L1 l14 = (com.google.android.gms.internal.measurement.L1) b0VarD2.get(k12);
            com.google.android.gms.internal.measurement.L1 l15 = (com.google.android.gms.internal.measurement.L1) b0VarD2.get(k14);
            com.google.android.gms.internal.measurement.L1 l16 = (com.google.android.gms.internal.measurement.L1) b0VarD2.get(k15);
            com.google.android.gms.internal.measurement.L1 l17 = (com.google.android.gms.internal.measurement.L1) b0VarD2.get(k16);
            A1.H h11 = new A1.H(4);
            h11.l("Version", "2");
            boolean z11 = z9;
            h11.l("VendorConsent", true != z9 ? "0" : "1");
            boolean z12 = z10;
            h11.l("VendorLegitimateInterest", true != z10 ? "0" : "1");
            h11.l("gdprApplies", iA3 != 1 ? "0" : "1");
            h11.l("EnableAdvertiserConsentMode", iA5 != 1 ? "0" : "1");
            h11.l("PolicyVersion", String.valueOf(iA2));
            h11.l("CmpSdkID", String.valueOf(iA));
            h11.l("PurposeOneTreatment", i10 != 1 ? "0" : "1");
            h11.l("PublisherCC", str3);
            h11.l("PublisherRestrictions1", String.valueOf(l14 != null ? l14.a() : l12.a()));
            h11.l("PublisherRestrictions3", String.valueOf(l15 != null ? l15.a() : l12.a()));
            h11.l("PublisherRestrictions4", String.valueOf(l16 != null ? l16.a() : l12.a()));
            h11.l("PublisherRestrictions7", String.valueOf(l17 != null ? l17.a() : l12.a()));
            String strF = D1.f(k12, strB3, strB5);
            String strF2 = D1.f(k14, strB3, strB5);
            String strF3 = D1.f(k15, strB3, strB5);
            String strF4 = D1.f(k16, strB3, strB5);
            AbstractC0055q.b("Purpose1", strF);
            AbstractC0055q.b("Purpose3", strF2);
            AbstractC0055q.b("Purpose4", strF3);
            AbstractC0055q.b("Purpose7", strF4);
            h11.m(C3.b0.b(4, new Object[]{"Purpose1", strF, "Purpose3", strF2, "Purpose4", strF3, "Purpose7", strF4}, null).entrySet());
            h11.m(C3.b0.b(5, new Object[]{"AuthorizePurpose1", true != D1.c(k12, b0VarD, b0VarD2, i0Var, cArr3, iA5, iA3, i10, str3, strB3, strB5, z11, z12) ? "0" : "1", "AuthorizePurpose3", true != D1.c(k14, b0VarD, b0VarD2, i0Var, cArr3, iA5, iA3, i10, str3, strB3, strB5, z11, z12) ? "0" : "1", "AuthorizePurpose4", true != D1.c(k15, b0VarD, b0VarD2, i0Var, cArr3, iA5, iA3, i10, str3, strB3, strB5, z11, z12) ? "0" : "1", "AuthorizePurpose7", true != D1.c(k16, b0VarD, b0VarD2, i0Var, cArr3, iA5, iA3, i10, str3, strB3, strB5, z11, z12) ? "0" : "1", "PurposeDiagnostics", new String(cArr3)}, null).entrySet());
            b12 = new B1(h11.d());
            str = "";
        } else {
            c0817r0 = c0817r02;
            String strB7 = D1.b(sharedPreferencesI, "IABTCF_VendorConsents");
            str = "";
            if (!str.equals(strB7) && strB7.length() > 754) {
                map.put("GoogleConsent", String.valueOf(strB7.charAt(754)));
            }
            int iA6 = D1.a(sharedPreferencesI, "IABTCF_gdprApplies");
            if (iA6 != -1) {
                map.put("gdprApplies", String.valueOf(iA6));
            }
            int iA7 = D1.a(sharedPreferencesI, "IABTCF_EnableAdvertiserConsentMode");
            if (iA7 != -1) {
                map.put("EnableAdvertiserConsentMode", String.valueOf(iA7));
            }
            int iA8 = D1.a(sharedPreferencesI, "IABTCF_PolicyVersion");
            if (iA8 != -1) {
                map.put("PolicyVersion", String.valueOf(iA8));
            }
            String strB8 = D1.b(sharedPreferencesI, "IABTCF_PurposeConsents");
            if (!str.equals(strB8)) {
                map.put("PurposeConsents", strB8);
            }
            int iA9 = D1.a(sharedPreferencesI, "IABTCF_CmpSdkID");
            if (iA9 != -1) {
                map.put("CmpSdkID", String.valueOf(iA9));
            }
            b12 = new B1(map);
        }
        C0817r0 c0817r03 = c0817r0;
        Z z13 = c0817r03.f12150y;
        C0817r0.k(z13);
        X x8 = z13.D;
        x8.c(b12, "Tcf preferences read");
        boolean zR = c0817r03.f12148w.R(null, h8);
        T2.a aVar = c0817r03.D;
        if (!zR) {
            if (c0785g0.O(b12)) {
                Bundle bundleA = b12.a();
                C0817r0.k(z13);
                x8.c(bundleA, "Consent generated from Tcf");
                if (bundleA != Bundle.EMPTY) {
                    aVar.getClass();
                    U(bundleA, -30, System.currentTimeMillis());
                }
                Bundle bundle = new Bundle();
                bundle.putString("_tcfd", b12.b());
                P("auto", "_tcf", bundle);
                return;
            }
            return;
        }
        c0785g0.E();
        String string = c0785g0.J().getString("stored_tcf_param", str);
        HashMap map2 = new HashMap();
        if (TextUtils.isEmpty(string)) {
            b13 = new B1(map2);
        } else {
            for (String str4 : string.split(";")) {
                String[] strArrSplit = str4.split("=");
                if (strArrSplit.length >= 2 && D1.f11445a.contains(strArrSplit[0])) {
                    map2.put(strArrSplit[0], strArrSplit[1]);
                }
            }
            b13 = new B1(map2);
        }
        if (c0785g0.O(b12)) {
            Bundle bundleA2 = b12.a();
            C0817r0.k(z13);
            x8.c(bundleA2, "Consent generated from Tcf");
            if (bundleA2 != Bundle.EMPTY) {
                aVar.getClass();
                y02 = this;
                y02.U(bundleA2, -30, System.currentTimeMillis());
            } else {
                y02 = this;
            }
            Bundle bundle2 = new Bundle();
            HashMap map3 = b13.f11429a;
            String str5 = (map3.isEmpty() || ((String) map3.get("Version")) != null) ? "0" : "1";
            Bundle bundleA3 = b12.a();
            Bundle bundleA4 = b13.a();
            bundle2.putString("_tcfm", str5.concat((bundleA3.size() == bundleA4.size() && Objects.equals(bundleA3.getString("ad_storage"), bundleA4.getString("ad_storage")) && Objects.equals(bundleA3.getString("ad_personalization"), bundleA4.getString("ad_personalization")) && Objects.equals(bundleA3.getString("ad_user_data"), bundleA4.getString("ad_user_data"))) ? "0" : "1"));
            String str6 = (String) b12.f11429a.get("PurposeDiagnostics");
            if (TextUtils.isEmpty(str6)) {
                str6 = "200000";
            }
            bundle2.putString("_tcfd2", str6);
            bundle2.putString("_tcfd", b12.b());
            y02.P("auto", "_tcf", bundle2);
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:21:0x0059, code lost:
    
        if (r0 > 500) goto L22;
     */
    /* JADX WARN: Code restructure failed: missing block: B:30:0x0090, code lost:
    
        if (r5 > 500) goto L31;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void O(String str, String str2, Bundle bundle, boolean z8, boolean z9, long j8) {
        Bundle bundle2 = bundle == null ? new Bundle() : bundle;
        if (!Objects.equals(str2, "screen_view")) {
            boolean z10 = !z9 || this.f11854t == null || W1.y0(str2);
            if (str == null) {
                str = "app";
            }
            String str3 = str;
            Bundle bundle3 = new Bundle(bundle2);
            for (String str4 : bundle3.keySet()) {
                Object obj = bundle3.get(str4);
                if (obj instanceof Bundle) {
                    bundle3.putBundle(str4, new Bundle((Bundle) obj));
                } else if (obj instanceof Parcelable[]) {
                    Parcelable[] parcelableArr = (Parcelable[]) obj;
                    for (int i = 0; i < parcelableArr.length; i++) {
                        Parcelable parcelable = parcelableArr[i];
                        if (parcelable instanceof Bundle) {
                            parcelableArr[i] = new Bundle((Bundle) parcelable);
                        }
                    }
                } else if (obj instanceof List) {
                    List list = (List) obj;
                    for (int i5 = 0; i5 < list.size(); i5++) {
                        Object obj2 = list.get(i5);
                        if (obj2 instanceof Bundle) {
                            list.set(i5, new Bundle((Bundle) obj2));
                        }
                    }
                }
            }
            C0815q0 c0815q0 = ((C0817r0) this.f5146q).f12151z;
            C0817r0.k(c0815q0);
            c0815q0.O(new T0(this, str3, str2, j8, bundle3, z9, z10, z8));
            return;
        }
        C0795j1 c0795j1 = ((C0817r0) this.f5146q).f12124E;
        C0817r0.j(c0795j1);
        synchronized (c0795j1.f12019B) {
            try {
                if (!c0795j1.f12018A) {
                    Z z11 = ((C0817r0) c0795j1.f5146q).f12150y;
                    C0817r0.k(z11);
                    z11.f11869A.b("Cannot log screen view event when the app is in the background.");
                    return;
                }
                String string = bundle2.getString("screen_name");
                if (string != null) {
                    if (string.length() > 0) {
                        int length = string.length();
                        ((C0817r0) c0795j1.f5146q).f12148w.getClass();
                    }
                    Z z12 = ((C0817r0) c0795j1.f5146q).f12150y;
                    C0817r0.k(z12);
                    z12.f11869A.c(Integer.valueOf(string.length()), "Invalid screen name length for screen view. Length");
                    return;
                }
                String string2 = bundle2.getString("screen_class");
                if (string2 != null) {
                    if (string2.length() > 0) {
                        int length2 = string2.length();
                        ((C0817r0) c0795j1.f5146q).f12148w.getClass();
                    }
                    Z z13 = ((C0817r0) c0795j1.f5146q).f12150y;
                    C0817r0.k(z13);
                    z13.f11869A.c(Integer.valueOf(string2.length()), "Invalid screen class length for screen view. Length");
                    return;
                }
                if (string2 == null) {
                    com.google.android.gms.internal.measurement.W w4 = c0795j1.f12024w;
                    string2 = w4 != null ? c0795j1.M(w4.f9768r) : "Activity";
                }
                String str5 = string2;
                C0786g1 c0786g1 = c0795j1.f12020s;
                if (c0795j1.f12025x && c0786g1 != null) {
                    c0795j1.f12025x = false;
                    boolean zEquals = Objects.equals(c0786g1.f11980b, str5);
                    boolean zEquals2 = Objects.equals(c0786g1.f11979a, string);
                    if (zEquals && zEquals2) {
                        Z z14 = ((C0817r0) c0795j1.f5146q).f12150y;
                        C0817r0.k(z14);
                        z14.f11869A.b("Ignoring call to log screen view event with duplicate parameters.");
                        return;
                    }
                }
                C0817r0 c0817r0 = (C0817r0) c0795j1.f5146q;
                Z z15 = c0817r0.f12150y;
                C0817r0.k(z15);
                z15.D.d("Logging screen view with name, class", string == null ? "null" : string, str5 == null ? "null" : str5);
                C0786g1 c0786g12 = c0795j1.f12020s == null ? c0795j1.f12021t : c0795j1.f12020s;
                W1 w12 = c0817r0.f12122B;
                C0817r0.i(w12);
                C0786g1 c0786g13 = new C0786g1(string, str5, w12.P0(), true, j8);
                c0795j1.f12020s = c0786g13;
                c0795j1.f12021t = c0786g12;
                c0795j1.f12026y = c0786g13;
                c0817r0.D.getClass();
                long jElapsedRealtime = SystemClock.elapsedRealtime();
                C0815q0 c0815q02 = c0817r0.f12151z;
                C0817r0.k(c0815q02);
                c0815q02.O(new RunnableC0829v0(c0795j1, bundle2, c0786g13, c0786g12, jElapsedRealtime, 2));
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final void P(String str, String str2, Bundle bundle) {
        E();
        ((C0817r0) this.f5146q).D.getClass();
        Q(System.currentTimeMillis(), bundle, str, str2);
    }

    public final void Q(long j8, Bundle bundle, String str, String str2) {
        E();
        boolean z8 = true;
        if (this.f11854t != null && !W1.y0(str2)) {
            z8 = false;
        }
        R(str, str2, j8, bundle, true, z8, true);
    }

    public final void R(String str, String str2, long j8, Bundle bundle, boolean z8, boolean z9, boolean z10) {
        Y0 y02;
        T2.a aVar;
        boolean z11;
        Bundle bundle2;
        long j9;
        boolean zB;
        Y0 y03;
        String str3;
        C0817r0 c0817r0;
        long j10;
        long j11;
        boolean zL;
        Bundle[] bundleArr;
        String str4 = str;
        P2.w.c(str4);
        P2.w.f(bundle);
        E();
        F();
        C0817r0 c0817r02 = (C0817r0) this.f5146q;
        boolean zF = c0817r02.f();
        Z z12 = c0817r02.f12150y;
        if (!zF) {
            C0817r0.k(z12);
            z12.f11871C.b("Event not sent since app measurement is disabled");
            return;
        }
        List list = c0817r02.n().f11633A;
        if (list != null && !list.contains(str2)) {
            C0817r0.k(z12);
            z12.f11871C.d("Dropping non-safelisted event. event name, origin", str2, str4);
            return;
        }
        if (!this.f11856v) {
            this.f11856v = true;
            try {
                boolean z13 = c0817r02.f12146u;
                Context context = c0817r02.f12142q;
                try {
                    (!z13 ? Class.forName("com.google.android.gms.tagmanager.TagManagerService", true, context.getClassLoader()) : Class.forName("com.google.android.gms.tagmanager.TagManagerService")).getDeclaredMethod("initialize", Context.class).invoke(null, context);
                } catch (Exception e8) {
                    C0817r0.k(z12);
                    z12.f11878y.c(e8, "Failed to invoke Tag Manager's initialize() method");
                }
            } catch (ClassNotFoundException unused) {
                C0817r0.k(z12);
                z12.f11870B.b("Tag Manager is not found and thus will not be used");
            }
        }
        boolean zEquals = "_cmp".equals(str2);
        T2.a aVar2 = c0817r02.D;
        if (zEquals && bundle.containsKey("gclid")) {
            String string = bundle.getString("gclid");
            aVar2.getClass();
            aVar = aVar2;
            Z(System.currentTimeMillis(), string, "auto", "_lgclid");
            y02 = this;
        } else {
            y02 = this;
            aVar = aVar2;
        }
        W1 w12 = c0817r02.f12122B;
        C0785g0 c0785g0 = c0817r02.f12149x;
        if (z8 && !W1.f11798z[0].equals(str2)) {
            C0817r0.i(w12);
            C0817r0.i(c0785g0);
            w12.V(bundle, c0785g0.f11970P.N());
        }
        V0 v02 = y02.f11852M;
        T t6 = c0817r02.f12123C;
        if (!z10 && !"_iap".equals(str2)) {
            C0817r0.i(w12);
            int i = 2;
            if (w12.s0("event", str2)) {
                if (w12.p0("event", G0.f11463a, G0.f11464b, str2)) {
                    ((C0817r0) w12.f5146q).getClass();
                    if (w12.o0(40, "event", str2)) {
                        i = 0;
                    }
                } else {
                    i = 13;
                }
            }
            if (i != 0) {
                C0817r0.k(z12);
                z12.f11877x.c(t6.d(str2), "Invalid public event name. Event will not be logged (FE)");
                C0817r0.i(w12);
                W1.Y(v02, null, i, "_ev", W1.O(40, str2, true), str2 != null ? str2.length() : 0);
                return;
            }
        }
        C0795j1 c0795j1 = c0817r02.f12124E;
        C0817r0.j(c0795j1);
        C0786g1 c0786g1L = c0795j1.L(false);
        if (c0786g1L != null && !bundle.containsKey("_sc")) {
            c0786g1L.f11982d = true;
        }
        W1.U(c0786g1L, bundle, z8 && !z10);
        boolean zEquals2 = "am".equals(str4);
        boolean zY0 = W1.y0(str2);
        if (!z8 || y02.f11854t == null || zY0) {
            z11 = zEquals2;
            bundle2 = bundle;
        } else {
            if (!zEquals2) {
                C0817r0.k(z12);
                z12.f11871C.d("Passing event to registered event handler (FE)", t6.d(str2), t6.b(bundle));
                P2.w.f(y02.f11854t);
                C0225a c0225a = y02.f11854t;
                c0225a.getClass();
                try {
                    ((com.google.android.gms.internal.measurement.Q) c0225a.f5010r).l(j8, bundle, str4, str2);
                    return;
                } catch (RemoteException e9) {
                    C0817r0 c0817r03 = ((AppMeasurementDynamiteService) c0225a.f5011s).f10093e;
                    if (c0817r03 != null) {
                        Z z14 = c0817r03.f12150y;
                        C0817r0.k(z14);
                        z14.f11878y.c(e9, "Event interceptor threw exception");
                        return;
                    }
                    return;
                }
            }
            bundle2 = bundle;
            z11 = true;
        }
        if (c0817r02.g()) {
            C0817r0.i(w12);
            int iI0 = w12.I0(str2);
            if (iI0 != 0) {
                C0817r0.k(z12);
                z12.f11877x.c(t6.d(str2), "Invalid event name. Event will not be logged (FE)");
                String strO = W1.O(40, str2, true);
                int length = str2 != null ? str2.length() : 0;
                C0817r0.i(w12);
                W1.Y(v02, null, iI0, "_ev", strO, length);
                return;
            }
            Bundle bundleI = w12.I(str2, bundle2, Collections.unmodifiableList(Arrays.asList("_o", "_sn", "_sc", "_si")), z10);
            P2.w.f(bundleI);
            C0817r0.j(c0795j1);
            C0786g1 c0786g1L2 = c0795j1.L(false);
            A1 a1 = c0817r02.f12121A;
            boolean z15 = z11;
            if (c0786g1L2 == null || !"_ae".equals(str2)) {
                j9 = 0;
            } else {
                C0817r0.j(a1);
                L0.X x8 = a1.f11427v;
                ((C0817r0) ((A1) x8.f3746t).f5146q).D.getClass();
                j9 = 0;
                long jElapsedRealtime = SystemClock.elapsedRealtime();
                long j12 = jElapsedRealtime - x8.f3744r;
                x8.f3744r = jElapsedRealtime;
                if (j12 > 0) {
                    w12.S(bundleI, j12);
                }
            }
            boolean zEquals3 = "auto".equals(str4);
            C0817r0 c0817r04 = (C0817r0) w12.f5146q;
            if (!zEquals3 && "_ssr".equals(str2)) {
                String string2 = bundleI.getString("_ffr");
                int i5 = T2.c.f6560a;
                if (string2 == null || string2.trim().isEmpty()) {
                    string2 = null;
                } else if (string2 != null) {
                    string2 = string2.trim();
                }
                C0785g0 c0785g02 = c0817r04.f12149x;
                C0817r0.i(c0785g02);
                if (Objects.equals(string2, c0785g02.f11967M.f())) {
                    Z z16 = c0817r04.f12150y;
                    C0817r0.k(z16);
                    z16.f11871C.b("Not logging duplicate session_start_with_rollout event");
                    return;
                } else {
                    C0785g0 c0785g03 = c0817r04.f12149x;
                    C0817r0.i(c0785g03);
                    c0785g03.f11967M.g(string2);
                }
            } else if ("_ae".equals(str2)) {
                C0785g0 c0785g04 = c0817r04.f12149x;
                C0817r0.i(c0785g04);
                String strF = c0785g04.f11967M.f();
                if (!TextUtils.isEmpty(strF)) {
                    bundleI.putString("_ffr", strF);
                }
            }
            ArrayList arrayList = new ArrayList();
            arrayList.add(bundleI);
            if (c0817r02.f12148w.R(null, I.f11538b1)) {
                C0817r0.j(a1);
                a1.E();
                zB = a1.f11425t;
            } else {
                C0817r0.i(c0785g0);
                zB = c0785g0.f11964J.b();
            }
            C0817r0.i(c0785g0);
            if (c0785g0.f11962G.g() <= j9) {
                y03 = this;
                str3 = "_ae";
                c0817r0 = c0817r02;
                j10 = j9;
                j11 = j8;
            } else if (c0785g0.N(j8) && zB) {
                C0817r0.k(z12);
                z12.D.b("Current session is expired, remove the session number, ID, and engagement time");
                aVar.getClass();
                c0817r0 = c0817r02;
                str3 = "_ae";
                j11 = j8;
                Z(System.currentTimeMillis(), null, "auto", "_sid");
                aVar.getClass();
                Z(System.currentTimeMillis(), null, "auto", "_sno");
                aVar.getClass();
                Z(System.currentTimeMillis(), null, "auto", "_se");
                y03 = this;
                j10 = j9;
                c0785g0.H.h(j10);
            } else {
                y03 = this;
                str3 = "_ae";
                c0817r0 = c0817r02;
                j11 = j8;
                j10 = j9;
            }
            if (bundleI.getLong("extend_session", j10) == 1) {
                C0817r0.k(z12);
                z12.D.b("EXTEND_SESSION param attached: initiate a new session or extend the current active session");
                C0817r0.j(a1);
                a1.f11426u.x(j11);
            }
            ArrayList arrayList2 = new ArrayList(bundleI.keySet());
            Collections.sort(arrayList2);
            int size = arrayList2.size();
            for (int i8 = 0; i8 < size; i8++) {
                String str5 = (String) arrayList2.get(i8);
                if (str5 != null) {
                    C0817r0.i(w12);
                    Object obj = bundleI.get(str5);
                    if (obj instanceof Bundle) {
                        bundleArr = new Bundle[]{(Bundle) obj};
                    } else if (obj instanceof Parcelable[]) {
                        Parcelable[] parcelableArr = (Parcelable[]) obj;
                        bundleArr = (Bundle[]) Arrays.copyOf(parcelableArr, parcelableArr.length, Bundle[].class);
                    } else if (obj instanceof ArrayList) {
                        ArrayList arrayList3 = (ArrayList) obj;
                        bundleArr = (Bundle[]) arrayList3.toArray(new Bundle[arrayList3.size()]);
                    } else {
                        bundleArr = null;
                    }
                    if (bundleArr != null) {
                        bundleI.putParcelableArray(str5, bundleArr);
                    }
                }
            }
            int i9 = 0;
            while (i9 < arrayList.size()) {
                Bundle bundleR0 = (Bundle) arrayList.get(i9);
                String str6 = i9 != 0 ? "_ep" : str2;
                bundleR0.putString("_o", str4);
                if (z9) {
                    bundleR0 = w12.R0(bundleR0);
                }
                Bundle bundle3 = bundleR0;
                W1 w13 = w12;
                C0828v c0828v = new C0828v(str6, new C0825u(bundle3), str4, j11);
                C0824t1 c0824t1R = c0817r0.r();
                c0824t1R.getClass();
                c0824t1R.E();
                c0824t1R.F();
                c0824t1R.W();
                S sO = ((C0817r0) c0824t1R.f5146q).o();
                sO.getClass();
                Parcel parcelObtain = Parcel.obtain();
                com.google.android.material.datepicker.d.a(c0828v, parcelObtain, 0);
                byte[] bArrMarshall = parcelObtain.marshall();
                parcelObtain.recycle();
                if (bArrMarshall.length > 131072) {
                    Z z17 = ((C0817r0) sO.f5146q).f12150y;
                    C0817r0.k(z17);
                    z17.f11876w.b("Event is too long for local database. Sending event directly to service");
                    zL = false;
                } else {
                    zL = sO.L(0, bArrMarshall);
                }
                c0824t1R.V(new RunnableC0810o1(c0824t1R, c0824t1R.S(true), zL, c0828v, 1));
                if (!z15) {
                    Iterator it = y03.f11855u.iterator();
                    while (it.hasNext()) {
                        ((H0) it.next()).a(j8, new Bundle(bundle3), str, str2);
                    }
                }
                i9++;
                j11 = j8;
                w12 = w13;
                str4 = str;
            }
            C0817r0.j(c0795j1);
            if (c0795j1.L(false) == null || !str3.equals(str2)) {
                return;
            }
            C0817r0.j(a1);
            aVar.getClass();
            a1.f11427v.a(true, true, SystemClock.elapsedRealtime());
        }
    }

    public final void S() {
        E1 e12;
        E();
        this.D = false;
        if (c0().isEmpty() || this.f11859y || (e12 = (E1) c0().poll()) == null) {
            return;
        }
        C0817r0 c0817r0 = (C0817r0) this.f5146q;
        W1 w12 = c0817r0.f12122B;
        C0817r0.i(w12);
        J1.d dVarJ = w12.J();
        if (dVarJ != null) {
            this.f11859y = true;
            Z z8 = c0817r0.f12150y;
            C0817r0.k(z8);
            X x8 = z8.D;
            String str = e12.f11453q;
            x8.c(str, "Registering trigger URI");
            G3.c cVarE = dVarJ.e(Uri.parse(str));
            if (cVarE != null) {
                cVarE.a(new G3.b(cVarE, 0, new R0(this, 0, e12)), new Q0(0, this));
            } else {
                this.f11859y = false;
                c0().add(e12);
            }
        }
    }

    public final void T(Bundle bundle, long j8) {
        P2.w.f(bundle);
        Bundle bundle2 = new Bundle(bundle);
        boolean zIsEmpty = TextUtils.isEmpty(bundle2.getString("app_id"));
        C0817r0 c0817r0 = (C0817r0) this.f5146q;
        if (!zIsEmpty) {
            Z z8 = c0817r0.f12150y;
            C0817r0.k(z8);
            z8.f11878y.b("Package name should be null when calling setConditionalUserProperty");
        }
        bundle2.remove("app_id");
        G0.a(bundle2, "app_id", String.class, null);
        G0.a(bundle2, "origin", String.class, null);
        G0.a(bundle2, "name", String.class, null);
        G0.a(bundle2, "value", Object.class, null);
        G0.a(bundle2, "trigger_event_name", String.class, null);
        G0.a(bundle2, "trigger_timeout", Long.class, 0L);
        G0.a(bundle2, "timed_out_event_name", String.class, null);
        G0.a(bundle2, "timed_out_event_params", Bundle.class, null);
        G0.a(bundle2, "triggered_event_name", String.class, null);
        G0.a(bundle2, "triggered_event_params", Bundle.class, null);
        G0.a(bundle2, "time_to_live", Long.class, 0L);
        G0.a(bundle2, "expired_event_name", String.class, null);
        G0.a(bundle2, "expired_event_params", Bundle.class, null);
        P2.w.c(bundle2.getString("name"));
        P2.w.c(bundle2.getString("origin"));
        P2.w.f(bundle2.get("value"));
        bundle2.putLong("creation_timestamp", j8);
        String string = bundle2.getString("name");
        Object obj = bundle2.get("value");
        W1 w12 = c0817r0.f12122B;
        C0817r0.i(w12);
        int iL0 = w12.L0(string);
        T t6 = c0817r0.f12123C;
        Z z9 = c0817r0.f12150y;
        if (iL0 != 0) {
            C0817r0.k(z9);
            z9.f11875v.c(t6.f(string), "Invalid conditional user property name");
            return;
        }
        W1 w13 = c0817r0.f12122B;
        C0817r0.i(w13);
        if (w13.H0(obj, string) != 0) {
            C0817r0.k(z9);
            z9.f11875v.d("Invalid conditional user property value", t6.f(string), obj);
            return;
        }
        Object objM = w13.M(obj, string);
        if (objM == null) {
            C0817r0.k(z9);
            z9.f11875v.d("Unable to normalize conditional user property value", t6.f(string), obj);
            return;
        }
        G0.e(bundle2, objM);
        long j9 = bundle2.getLong("trigger_timeout");
        if (!TextUtils.isEmpty(bundle2.getString("trigger_event_name")) && (j9 > 15552000000L || j9 < 1)) {
            C0817r0.k(z9);
            z9.f11875v.d("Invalid conditional user property timeout", t6.f(string), Long.valueOf(j9));
            return;
        }
        long j10 = bundle2.getLong("time_to_live");
        if (j10 <= 15552000000L && j10 >= 1) {
            C0815q0 c0815q0 = c0817r0.f12151z;
            C0817r0.k(c0815q0);
            c0815q0.O(new L0(this, bundle2, 1));
        } else {
            C0817r0.k(z9);
            z9.f11875v.d("Invalid conditional user property time to live", t6.f(string), Long.valueOf(j10));
        }
    }

    public final void U(Bundle bundle, int i, long j8) {
        Object obj;
        C0 c02;
        String string;
        F();
        F0 f02 = F0.f11457c;
        E0[] e0Arr = D0.STORAGE.f11444q;
        int length = e0Arr.length;
        int i5 = 0;
        while (true) {
            obj = null;
            if (i5 >= length) {
                break;
            }
            String str = e0Arr[i5].f11452q;
            if (bundle.containsKey(str) && (string = bundle.getString(str)) != null) {
                if (string.equals("granted")) {
                    obj = Boolean.TRUE;
                } else if (string.equals("denied")) {
                    obj = Boolean.FALSE;
                }
                if (obj == null) {
                    obj = string;
                    break;
                }
            }
            i5++;
        }
        C0817r0 c0817r0 = (C0817r0) this.f5146q;
        if (obj != null) {
            Z z8 = c0817r0.f12150y;
            C0817r0.k(z8);
            z8.f11869A.c(obj, "Ignoring invalid consent setting");
            Z z9 = c0817r0.f12150y;
            C0817r0.k(z9);
            z9.f11869A.b("Valid consent values are 'granted', 'denied'");
        }
        C0815q0 c0815q0 = c0817r0.f12151z;
        C0817r0.k(c0815q0);
        boolean zQ = c0815q0.Q();
        F0 f0D = F0.d(i, bundle);
        Iterator it = f0D.f11458a.values().iterator();
        while (true) {
            boolean zHasNext = it.hasNext();
            c02 = C0.f11431r;
            if (!zHasNext) {
                break;
            } else if (((C0) it.next()) != c02) {
                X(f0D, zQ);
                break;
            }
        }
        C0811p c0811pA = C0811p.a(i, bundle);
        Iterator it2 = c0811pA.f12094e.values().iterator();
        while (true) {
            if (!it2.hasNext()) {
                break;
            } else if (((C0) it2.next()) != c02) {
                V(c0811pA, zQ);
                break;
            }
        }
        Boolean boolD = C0811p.d(bundle);
        if (boolD != null) {
            String str2 = i == -30 ? "tcf" : "app";
            if (zQ) {
                Z(j8, boolD.toString(), str2, "allow_personalized_ads");
            } else {
                Y(str2, "allow_personalized_ads", boolD.toString(), false, j8);
            }
        }
    }

    public final void V(C0811p c0811p, boolean z8) {
        G3.b bVar = new G3.b(this, c0811p, 15, false);
        if (z8) {
            E();
            bVar.run();
        } else {
            C0815q0 c0815q0 = ((C0817r0) this.f5146q).f12151z;
            C0817r0.k(c0815q0);
            c0815q0.O(bVar);
        }
    }

    public final void W(F0 f02) {
        E();
        boolean z8 = (f02.k(E0.f11448s) && f02.k(E0.f11447r)) || ((C0817r0) this.f5146q).r().P();
        C0817r0 c0817r0 = (C0817r0) this.f5146q;
        C0815q0 c0815q0 = c0817r0.f12151z;
        C0817r0.k(c0815q0);
        c0815q0.E();
        if (z8 != c0817r0.f12137S) {
            C0815q0 c0815q02 = c0817r0.f12151z;
            C0817r0.k(c0815q02);
            c0815q02.E();
            c0817r0.f12137S = z8;
            C0785g0 c0785g0 = ((C0817r0) this.f5146q).f12149x;
            C0817r0.i(c0785g0);
            c0785g0.E();
            Boolean boolValueOf = c0785g0.J().contains("measurement_enabled_from_api") ? Boolean.valueOf(c0785g0.J().getBoolean("measurement_enabled_from_api", true)) : null;
            if (!z8 || boolValueOf == null || boolValueOf.booleanValue()) {
                a0(Boolean.valueOf(z8), false);
            }
        }
    }

    /*  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:1182)
        	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 X(d3.F0 r14, boolean r15) {
        /*
            Method dump skipped, instruction units count: 280
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: d3.Y0.X(d3.F0, boolean):void");
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0021  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void Y(String str, String str2, Object obj, boolean z8, long j8) {
        int iL0;
        int length;
        C0817r0 c0817r0 = (C0817r0) this.f5146q;
        if (z8) {
            W1 w12 = c0817r0.f12122B;
            C0817r0.i(w12);
            iL0 = w12.L0(str2);
        } else {
            W1 w13 = c0817r0.f12122B;
            C0817r0.i(w13);
            if (w13.s0("user property", str2)) {
                if (w13.p0("user property", G0.i, null, str2)) {
                    ((C0817r0) w13.f5146q).getClass();
                    iL0 = !w13.o0(24, "user property", str2) ? 6 : 0;
                } else {
                    iL0 = 15;
                }
            }
        }
        V0 v02 = this.f11852M;
        if (iL0 != 0) {
            C0817r0.i(c0817r0.f12122B);
            String strO = W1.O(24, str2, true);
            length = str2 != null ? str2.length() : 0;
            C0817r0.i(c0817r0.f12122B);
            W1.Y(v02, null, iL0, "_ev", strO, length);
            return;
        }
        String str3 = str == null ? "app" : str;
        if (obj == null) {
            C0815q0 c0815q0 = c0817r0.f12151z;
            C0817r0.k(c0815q0);
            c0815q0.O(new RunnableC0829v0(this, str3, str2, null, j8, 1));
            return;
        }
        W1 w14 = c0817r0.f12122B;
        C0817r0.i(w14);
        int iH0 = w14.H0(obj, str2);
        W1 w15 = c0817r0.f12122B;
        if (iH0 != 0) {
            C0817r0.i(w15);
            String strO2 = W1.O(24, str2, true);
            length = ((obj instanceof String) || (obj instanceof CharSequence)) ? obj.toString().length() : 0;
            C0817r0.i(w15);
            W1.Y(v02, null, iH0, "_ev", strO2, length);
            return;
        }
        C0817r0.i(w15);
        Object objM = w15.M(obj, str2);
        if (objM != null) {
            C0815q0 c0815q02 = c0817r0.f12151z;
            C0817r0.k(c0815q02);
            c0815q02.O(new RunnableC0829v0(this, str3, str2, objM, j8, 1));
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:16:0x0057  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void Z(long j8, Object obj, String str, String str2) {
        String str3;
        boolean zL;
        Object objValueOf = obj;
        P2.w.c(str);
        P2.w.c(str2);
        E();
        F();
        boolean zEquals = "allow_personalized_ads".equals(str2);
        C0817r0 c0817r0 = (C0817r0) this.f5146q;
        if (zEquals) {
            String str4 = "_npa";
            if (objValueOf instanceof String) {
                String str5 = (String) objValueOf;
                if (!TextUtils.isEmpty(str5)) {
                    long j9 = true != "false".equals(str5.toLowerCase(Locale.ENGLISH)) ? 0L : 1L;
                    objValueOf = Long.valueOf(j9);
                    C0785g0 c0785g0 = c0817r0.f12149x;
                    C0817r0.i(c0785g0);
                    c0785g0.D.g(j9 == 1 ? "true" : "false");
                } else if (objValueOf == null) {
                    C0785g0 c0785g02 = c0817r0.f12149x;
                    C0817r0.i(c0785g02);
                    c0785g02.D.g("unset");
                } else {
                    str4 = str2;
                }
                Z z8 = c0817r0.f12150y;
                C0817r0.k(z8);
                z8.D.d("Setting user property(FE)", "non_personalized_ads(_npa)", objValueOf);
                str3 = str4;
            }
        } else {
            str3 = str2;
        }
        Object obj2 = objValueOf;
        if (!c0817r0.f()) {
            Z z9 = c0817r0.f12150y;
            C0817r0.k(z9);
            z9.D.b("User property not set since app measurement is disabled");
            return;
        }
        if (c0817r0.g()) {
            T1 t12 = new T1(j8, obj2, str3, str);
            C0824t1 c0824t1R = c0817r0.r();
            c0824t1R.E();
            c0824t1R.F();
            c0824t1R.W();
            S sO = ((C0817r0) c0824t1R.f5146q).o();
            sO.getClass();
            Parcel parcelObtain = Parcel.obtain();
            com.google.android.material.datepicker.d.b(t12, parcelObtain);
            byte[] bArrMarshall = parcelObtain.marshall();
            parcelObtain.recycle();
            if (bArrMarshall.length > 131072) {
                Z z10 = ((C0817r0) sO.f5146q).f12150y;
                C0817r0.k(z10);
                z10.f11876w.b("User property too long for local database. Sending directly to service");
                zL = false;
            } else {
                zL = sO.L(1, bArrMarshall);
            }
            c0824t1R.V(new RunnableC0810o1(c0824t1R, c0824t1R.S(true), zL, t12, 0));
        }
    }

    public final void a0(Boolean bool, boolean z8) {
        E();
        F();
        C0817r0 c0817r0 = (C0817r0) this.f5146q;
        Z z9 = c0817r0.f12150y;
        C0817r0.k(z9);
        z9.f11871C.c(bool, "Setting app measurement enabled (FE)");
        C0785g0 c0785g0 = c0817r0.f12149x;
        C0817r0.i(c0785g0);
        c0785g0.E();
        SharedPreferences.Editor editorEdit = c0785g0.J().edit();
        if (bool != null) {
            editorEdit.putBoolean("measurement_enabled", bool.booleanValue());
        } else {
            editorEdit.remove("measurement_enabled");
        }
        editorEdit.apply();
        if (z8) {
            c0785g0.E();
            SharedPreferences.Editor editorEdit2 = c0785g0.J().edit();
            if (bool != null) {
                editorEdit2.putBoolean("measurement_enabled_from_api", bool.booleanValue());
            } else {
                editorEdit2.remove("measurement_enabled_from_api");
            }
            editorEdit2.apply();
        }
        C0815q0 c0815q0 = c0817r0.f12151z;
        C0817r0.k(c0815q0);
        c0815q0.E();
        if (c0817r0.f12137S || !(bool == null || bool.booleanValue())) {
            b0();
        }
    }

    public final void b0() {
        E();
        C0817r0 c0817r0 = (C0817r0) this.f5146q;
        C0785g0 c0785g0 = c0817r0.f12149x;
        C0817r0.i(c0785g0);
        String strF = c0785g0.D.f();
        if (strF != null) {
            boolean zEquals = "unset".equals(strF);
            T2.a aVar = c0817r0.D;
            if (zEquals) {
                aVar.getClass();
                Z(System.currentTimeMillis(), null, "app", "_npa");
            } else {
                Long lValueOf = Long.valueOf(true != "true".equals(strF) ? 0L : 1L);
                aVar.getClass();
                Z(System.currentTimeMillis(), lValueOf, "app", "_npa");
            }
        }
        boolean zF = c0817r0.f();
        Z z8 = c0817r0.f12150y;
        if (!zF || !this.f11848I) {
            C0817r0.k(z8);
            z8.f11871C.b("Updating Scion state (FE)");
            C0824t1 c0824t1R = c0817r0.r();
            c0824t1R.E();
            c0824t1R.F();
            c0824t1R.V(new RunnableC0813p1(c0824t1R, c0824t1R.S(true), 3));
            return;
        }
        C0817r0.k(z8);
        z8.f11871C.b("Recording app launch after enabling measurement for the first time (FE)");
        J();
        A1 a1 = c0817r0.f12121A;
        C0817r0.j(a1);
        a1.f11426u.w();
        C0815q0 c0815q0 = c0817r0.f12151z;
        C0817r0.k(c0815q0);
        c0815q0.O(new N0(this, 2));
    }

    public final PriorityQueue c0() {
        if (this.f11844C == null) {
            this.f11844C = c0.t.k(Comparator.comparing(new J0(), new C0215p(6)));
        }
        return this.f11844C;
    }
}
