package L1;

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

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

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

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

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final /* synthetic */ C0088c1 f1589m;

    public W0(C0088c1 c0088c1, Bundle bundle, int i) {
        this.f1587k = i;
        switch (i) {
            case 1:
                this.f1588l = bundle;
                Objects.requireNonNull(c0088c1);
                this.f1589m = c0088c1;
                break;
            case 2:
                this.f1589m = c0088c1;
                this.f1588l = bundle;
                break;
            default:
                this.f1588l = bundle;
                Objects.requireNonNull(c0088c1);
                this.f1589m = c0088c1;
                break;
        }
    }

    @Override // java.lang.Runnable
    public final void run() {
        Bundle bundle;
        switch (this.f1587k) {
            case 0:
                C0088c1 c0088c1 = this.f1589m;
                c0088c1.k();
                c0088c1.l();
                Bundle bundle2 = this.f1588l;
                String string = bundle2.getString("name");
                String string2 = bundle2.getString("origin");
                s1.z.d(string);
                s1.z.d(string2);
                s1.z.g(bundle2.get("value"));
                C0146w0 c0146w0 = (C0146w0) c0088c1.f29k;
                if (!c0146w0.c()) {
                    X x5 = c0146w0.p;
                    C0146w0.l(x5);
                    x5.f1631x.b("Conditional property not set since app measurement is disabled");
                } else {
                    Z1 z12 = new Z1(bundle2.getLong("triggered_timestamp"), bundle2.get("value"), string, string2);
                    try {
                        c2 c2Var = c0146w0.f2038s;
                        C0146w0.j(c2Var);
                        bundle2.getString("app_id");
                        C0142v c0142vM = c2Var.M(bundle2.getString("triggered_event_name"), bundle2.getBundle("triggered_event_params"), string2, 0L, true);
                        C0146w0.j(c2Var);
                        bundle2.getString("app_id");
                        C0142v c0142vM2 = c2Var.M(bundle2.getString("timed_out_event_name"), bundle2.getBundle("timed_out_event_params"), string2, 0L, true);
                        bundle2.getString("app_id");
                        c0146w0.o().D(new C0092e(bundle2.getString("app_id"), string2, z12, bundle2.getLong("creation_timestamp"), false, bundle2.getString("trigger_event_name"), c0142vM2, bundle2.getLong("trigger_timeout"), c0142vM, bundle2.getLong("time_to_live"), c2Var.M(bundle2.getString("expired_event_name"), bundle2.getBundle("expired_event_params"), string2, 0L, true)));
                    } catch (IllegalArgumentException unused) {
                        return;
                    }
                }
                break;
            case 1:
                C0088c1 c0088c12 = this.f1589m;
                c0088c12.k();
                c0088c12.l();
                Bundle bundle3 = this.f1588l;
                String string3 = bundle3.getString("name");
                s1.z.d(string3);
                C0146w0 c0146w02 = (C0146w0) c0088c12.f29k;
                if (!c0146w02.c()) {
                    X x6 = c0146w02.p;
                    C0146w0.l(x6);
                    x6.f1631x.b("Conditional property not cleared since app measurement is disabled");
                } else {
                    Z1 z13 = new Z1(0L, null, string3, "");
                    try {
                        c2 c2Var2 = c0146w02.f2038s;
                        C0146w0.j(c2Var2);
                        bundle3.getString("app_id");
                        c0146w02.o().D(new C0092e(bundle3.getString("app_id"), "", z13, bundle3.getLong("creation_timestamp"), bundle3.getBoolean("active"), bundle3.getString("trigger_event_name"), null, bundle3.getLong("trigger_timeout"), null, bundle3.getLong("time_to_live"), c2Var2.M(bundle3.getString("expired_event_name"), bundle3.getBundle("expired_event_params"), "", bundle3.getLong("creation_timestamp"), true)));
                    } catch (IllegalArgumentException unused2) {
                        return;
                    }
                }
                break;
            default:
                C0088c1 c0088c13 = this.f1589m;
                c0088c13.getClass();
                Bundle bundle4 = this.f1588l;
                boolean zIsEmpty = bundle4.isEmpty();
                C0146w0 c0146w03 = (C0146w0) c0088c13.f29k;
                if (zIsEmpty) {
                    bundle = bundle4;
                } else {
                    C0108j0 c0108j0 = c0146w03.f2036o;
                    C0146w0.j(c0108j0);
                    bundle = new Bundle(c0108j0.I.Q());
                    Iterator<String> it = bundle4.keySet().iterator();
                    while (true) {
                        boolean zHasNext = it.hasNext();
                        g3.c cVar = c0088c13.f1731G;
                        C0098g c0098g = c0146w03.f2035n;
                        X x7 = c0146w03.p;
                        c2 c2Var3 = c0146w03.f2038s;
                        if (zHasNext) {
                            String next = it.next();
                            Object obj = bundle4.get(next);
                            if (obj != null && !(obj instanceof String) && !(obj instanceof Long) && !(obj instanceof Double)) {
                                C0146w0.j(c2Var3);
                                if (c2.s0(obj)) {
                                    c2.A(cVar, null, 27, null, null, 0);
                                }
                                C0146w0.l(x7);
                                x7.f1628u.d(next, obj, "Invalid default event parameter type. Name, value");
                            } else if (c2.I(next)) {
                                C0146w0.l(x7);
                                x7.f1628u.c("Invalid default event parameter name. Name", next);
                            } else if (obj == null) {
                                bundle.remove(next);
                            } else {
                                C0146w0.j(c2Var3);
                                c0098g.getClass();
                                if (c2Var3.t0("param", next, 500, obj)) {
                                    c2Var3.z(bundle, next, obj);
                                }
                            }
                        } else {
                            C0146w0.j(c2Var3);
                            c2 c2Var4 = ((C0146w0) c0098g.f29k).f2038s;
                            C0146w0.j(c2Var4);
                            int i = c2Var4.P(201500000) ? 100 : 25;
                            if (bundle.size() > i) {
                                int i5 = 0;
                                for (String str : new TreeSet(bundle.keySet())) {
                                    i5++;
                                    if (i5 > i) {
                                        bundle.remove(str);
                                    }
                                }
                                C0146w0.j(c2Var3);
                                c2.A(cVar, null, 26, null, null, 0);
                                C0146w0.l(x7);
                                x7.f1628u.b("Too many default event parameters set. Discarding beyond event parameter limit");
                            }
                        }
                    }
                }
                C0108j0 c0108j02 = c0146w03.f2036o;
                C0146w0.j(c0108j02);
                c0108j02.I.U(bundle);
                if (bundle4.isEmpty()) {
                    if (!c0146w03.f2035n.u(null, F.f1387W0)) {
                    }
                }
                c0146w03.o().p(bundle);
                break;
        }
    }
}
