package d3;

import android.os.Bundle;
import java.util.Iterator;
import java.util.TreeSet;

/* JADX INFO: loaded from: classes.dex */
public final /* synthetic */ class L0 implements Runnable {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final /* synthetic */ int f11616q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final /* synthetic */ Bundle f11617r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final /* synthetic */ Y0 f11618s;

    public /* synthetic */ L0(Y0 y02, Bundle bundle, int i) {
        this.f11616q = i;
        this.f11618s = y02;
        this.f11617r = bundle;
    }

    @Override // java.lang.Runnable
    public final void run() {
        Bundle bundle;
        switch (this.f11616q) {
            case n4.u0.f15495q /* 0 */:
                Bundle bundle2 = this.f11617r;
                boolean zIsEmpty = bundle2.isEmpty();
                Y0 y02 = this.f11618s;
                if (zIsEmpty) {
                    bundle = bundle2;
                } else {
                    C0817r0 c0817r0 = (C0817r0) y02.f5146q;
                    C0785g0 c0785g0 = c0817r0.f12149x;
                    C0817r0.i(c0785g0);
                    bundle = new Bundle(c0785g0.f11970P.N());
                    Iterator<String> it = bundle2.keySet().iterator();
                    while (true) {
                        boolean zHasNext = it.hasNext();
                        V0 v02 = y02.f11852M;
                        C0784g c0784g = c0817r0.f12148w;
                        Z z8 = c0817r0.f12150y;
                        W1 w12 = c0817r0.f12122B;
                        if (zHasNext) {
                            String next = it.next();
                            Object obj = bundle2.get(next);
                            if (obj != null && !(obj instanceof String) && !(obj instanceof Long) && !(obj instanceof Double)) {
                                C0817r0.i(w12);
                                if (W1.v0(obj)) {
                                    W1.Y(v02, null, 27, null, null, 0);
                                }
                                C0817r0.k(z8);
                                z8.f11869A.d("Invalid default event parameter type. Name, value", next, obj);
                            } else if (W1.y0(next)) {
                                C0817r0.k(z8);
                                z8.f11869A.c(next, "Invalid default event parameter name. Name");
                            } else if (obj == null) {
                                bundle.remove(next);
                            } else {
                                C0817r0.i(w12);
                                c0784g.getClass();
                                if (w12.q0("param", next, 500, obj)) {
                                    w12.Z(bundle, next, obj);
                                }
                            }
                        } else {
                            C0817r0.i(w12);
                            W1 w13 = ((C0817r0) c0784g.f5146q).f12122B;
                            C0817r0.i(w13);
                            int i = w13.x0(201500000) ? 100 : 25;
                            if (bundle.size() > i) {
                                int i5 = 0;
                                for (String str : new TreeSet(bundle.keySet())) {
                                    i5++;
                                    if (i5 > i) {
                                        bundle.remove(str);
                                    }
                                }
                                C0817r0.i(w12);
                                W1.Y(v02, null, 26, null, null, 0);
                                C0817r0.k(z8);
                                z8.f11869A.b("Too many default event parameters set. Discarding beyond event parameter limit");
                            }
                        }
                    }
                }
                C0817r0 c0817r02 = (C0817r0) y02.f5146q;
                C0785g0 c0785g02 = c0817r02.f12149x;
                C0817r0.i(c0785g02);
                c0785g02.f11970P.Q(bundle);
                if (bundle2.isEmpty()) {
                    if (!c0817r02.f12148w.R(null, I.f11547e1)) {
                    }
                }
                ((C0817r0) y02.f5146q).r().N(bundle);
                break;
            case 1:
                Y0 y03 = this.f11618s;
                y03.E();
                y03.F();
                Bundle bundle3 = this.f11617r;
                String string = bundle3.getString("name");
                String string2 = bundle3.getString("origin");
                P2.w.c(string);
                P2.w.c(string2);
                P2.w.f(bundle3.get("value"));
                C0817r0 c0817r03 = (C0817r0) y03.f5146q;
                if (!c0817r03.f()) {
                    Z z9 = c0817r03.f12150y;
                    C0817r0.k(z9);
                    z9.D.b("Conditional property not set since app measurement is disabled");
                } else {
                    T1 t12 = new T1(bundle3.getLong("triggered_timestamp"), bundle3.get("value"), string, string2);
                    try {
                        W1 w14 = c0817r03.f12122B;
                        C0817r0.i(w14);
                        bundle3.getString("app_id");
                        C0828v c0828vK = w14.K(bundle3.getString("triggered_event_name"), bundle3.getBundle("triggered_event_params"), string2, 0L, true);
                        C0817r0.i(w14);
                        bundle3.getString("app_id");
                        C0828v c0828vK2 = w14.K(bundle3.getString("timed_out_event_name"), bundle3.getBundle("timed_out_event_params"), string2, 0L, true);
                        bundle3.getString("app_id");
                        c0817r03.r().M(new C0778e(bundle3.getString("app_id"), string2, t12, bundle3.getLong("creation_timestamp"), false, bundle3.getString("trigger_event_name"), c0828vK2, bundle3.getLong("trigger_timeout"), c0828vK, bundle3.getLong("time_to_live"), w14.K(bundle3.getString("expired_event_name"), bundle3.getBundle("expired_event_params"), string2, 0L, true)));
                    } catch (IllegalArgumentException unused) {
                        return;
                    }
                }
                break;
            default:
                Y0 y04 = this.f11618s;
                y04.E();
                y04.F();
                Bundle bundle4 = this.f11617r;
                String string3 = bundle4.getString("name");
                P2.w.c(string3);
                C0817r0 c0817r04 = (C0817r0) y04.f5146q;
                if (!c0817r04.f()) {
                    Z z10 = c0817r04.f12150y;
                    C0817r0.k(z10);
                    z10.D.b("Conditional property not cleared since app measurement is disabled");
                } else {
                    T1 t13 = new T1(0L, null, string3, "");
                    try {
                        W1 w15 = c0817r04.f12122B;
                        C0817r0.i(w15);
                        bundle4.getString("app_id");
                        c0817r04.r().M(new C0778e(bundle4.getString("app_id"), "", t13, bundle4.getLong("creation_timestamp"), bundle4.getBoolean("active"), bundle4.getString("trigger_event_name"), null, bundle4.getLong("trigger_timeout"), null, bundle4.getLong("time_to_live"), w15.K(bundle4.getString("expired_event_name"), bundle4.getBundle("expired_event_params"), "", bundle4.getLong("creation_timestamp"), true)));
                    } catch (IllegalArgumentException unused2) {
                        return;
                    }
                }
                break;
        }
    }
}
