package com.google.android.gms.measurement.internal;

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

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

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

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final /* synthetic */ g2 f21662c;

    public /* synthetic */ i2(g2 g2Var, Bundle bundle, int i10) {
        this.f21660a = i10;
        this.f21662c = g2Var;
        this.f21661b = bundle;
    }

    @Override // java.lang.Runnable
    public final void run() {
        Bundle bundleO;
        Bundle bundle = this.f21661b;
        g2 g2Var = this.f21662c;
        switch (this.f21660a) {
            case 0:
                g2Var.getClass();
                if (bundle.isEmpty()) {
                    bundleO = bundle;
                } else {
                    bundleO = g2Var.u().f22008z.o();
                    if (g2Var.s().J(null, z.f22035g1)) {
                        bundleO = new Bundle(bundleO);
                    }
                    Iterator<String> it = bundle.keySet().iterator();
                    while (true) {
                        boolean zHasNext = it.hasNext();
                        h hVar = g2Var.f21637v;
                        if (zHasNext) {
                            String next = it.next();
                            Object obj = bundle.get(next);
                            if (obj != null && !(obj instanceof String) && !(obj instanceof Long) && !(obj instanceof Double)) {
                                g2Var.v();
                                if (n4.f0(obj)) {
                                    g2Var.v();
                                    n4.Y(hVar, null, 27, null, null, 0);
                                }
                                g2Var.zzj().f21839k.a(next, obj, "Invalid default event parameter type. Name, value");
                            } else if (n4.A0(next)) {
                                g2Var.zzj().f21839k.b(next, "Invalid default event parameter name. Name");
                            } else if (obj == null) {
                                bundleO.remove(next);
                            } else if (g2Var.v().h0("param", next, g2Var.s().y(null, false), obj)) {
                                g2Var.v().P(bundleO, next, obj);
                            }
                        } else {
                            g2Var.v();
                            int i10 = g2Var.s().v().m0(201500000) ? 100 : 25;
                            if (bundleO.size() > i10) {
                                int i11 = 0;
                                for (String str : new TreeSet(bundleO.keySet())) {
                                    i11++;
                                    if (i11 > i10) {
                                        bundleO.remove(str);
                                    }
                                }
                                g2Var.v();
                                n4.Y(hVar, null, 26, null, null, 0);
                                g2Var.zzj().f21839k.c("Too many default event parameters set. Discarding beyond event parameter limit");
                            }
                        }
                    }
                }
                g2Var.u().f22008z.u(bundleO);
                if (!bundle.isEmpty() || g2Var.s().J(null, z.f22029e1)) {
                    a3 a3VarB = g2Var.B();
                    a3VarB.w();
                    a3VarB.D();
                    a3VarB.I(new n0.a(a3VarB, a3VarB.S(false), bundleO, 18));
                }
                break;
            case 1:
                g2Var.w();
                g2Var.D();
                com.google.android.gms.common.internal.w.checkNotNull(bundle);
                String strCheckNotEmpty = com.google.android.gms.common.internal.w.checkNotEmpty(bundle.getString("name"));
                if (!((m1) g2Var.f31277a).e()) {
                    g2Var.zzj().f21842n.c("Conditional property not cleared since app measurement is disabled");
                } else {
                    i4 i4Var = new i4(strCheckNotEmpty, 0L, null, "");
                    try {
                        n4 n4VarV = g2Var.v();
                        bundle.getString("app_id");
                        g2Var.B().G(new e(bundle.getString("app_id"), "", i4Var, bundle.getLong("creation_timestamp"), bundle.getBoolean("active"), bundle.getString("trigger_event_name"), null, bundle.getLong("trigger_timeout"), null, bundle.getLong("time_to_live"), n4VarV.J(bundle.getString("expired_event_name"), bundle.getBundle("expired_event_params"), "", bundle.getLong("creation_timestamp"), true)));
                    } catch (IllegalArgumentException unused) {
                        return;
                    }
                }
                break;
            default:
                g2Var.w();
                g2Var.D();
                com.google.android.gms.common.internal.w.checkNotNull(bundle);
                String string = bundle.getString("name");
                String string2 = bundle.getString("origin");
                com.google.android.gms.common.internal.w.checkNotEmpty(string);
                com.google.android.gms.common.internal.w.checkNotEmpty(string2);
                com.google.android.gms.common.internal.w.checkNotNull(bundle.get("value"));
                if (!((m1) g2Var.f31277a).e()) {
                    g2Var.zzj().f21842n.c("Conditional property not set since app measurement is disabled");
                } else {
                    i4 i4Var2 = new i4(string, bundle.getLong("triggered_timestamp"), bundle.get("value"), string2);
                    try {
                        n4 n4VarV2 = g2Var.v();
                        bundle.getString("app_id");
                        y yVarJ = n4VarV2.J(bundle.getString("triggered_event_name"), bundle.getBundle("triggered_event_params"), string2, 0L, true);
                        n4 n4VarV3 = g2Var.v();
                        bundle.getString("app_id");
                        y yVarJ2 = n4VarV3.J(bundle.getString("timed_out_event_name"), bundle.getBundle("timed_out_event_params"), string2, 0L, true);
                        n4 n4VarV4 = g2Var.v();
                        bundle.getString("app_id");
                        g2Var.B().G(new e(bundle.getString("app_id"), string2, i4Var2, bundle.getLong("creation_timestamp"), false, bundle.getString("trigger_event_name"), yVarJ2, bundle.getLong("trigger_timeout"), yVarJ, bundle.getLong("time_to_live"), n4VarV4.J(bundle.getString("expired_event_name"), bundle.getBundle("expired_event_params"), string2, 0L, true)));
                    } catch (IllegalArgumentException unused2) {
                        return;
                    }
                }
                break;
        }
    }
}
