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

import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;

/* JADX INFO: loaded from: classes2.dex */
public final class w {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final u.e f20505a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public u.e f20506b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final xyz.stream.utils.t f20507c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final z4 f20508d;

    public w() {
        u.e eVar = new u.e(7);
        this.f20505a = eVar;
        this.f20506b = ((u.e) eVar.f33126b).t();
        this.f20507c = new xyz.stream.utils.t(14);
        this.f20508d = new z4(2);
        final int i10 = 0;
        ((s6) eVar.f33128d).f20410a.put("internal.registerCallback", new Callable(this) { // from class: com.google.android.gms.internal.measurement.a

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

            {
                this.f20095b = this;
            }

            @Override // java.util.concurrent.Callable
            public final Object call() {
                w wVar = this.f20095b;
                switch (i10) {
                    case 0:
                        return new i6(wVar.f20508d);
                    default:
                        return new i6(wVar.f20507c);
                }
            }
        });
        final int i11 = 1;
        ((s6) eVar.f33128d).f20410a.put("internal.eventLogger", new Callable(this) { // from class: com.google.android.gms.internal.measurement.a

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

            {
                this.f20095b = this;
            }

            @Override // java.util.concurrent.Callable
            public final Object call() {
                w wVar = this.f20095b;
                switch (i11) {
                    case 0:
                        return new i6(wVar.f20508d);
                    default:
                        return new i6(wVar.f20507c);
                }
            }
        });
    }

    public final void a(j4 j4Var) {
        j jVar;
        u.e eVar = this.f20505a;
        try {
            this.f20506b = ((u.e) eVar.f33126b).t();
            if (eVar.s(this.f20506b, (k4[]) j4Var.r().toArray(new k4[0])) instanceof h) {
                throw new IllegalStateException("Program loading failed");
            }
            for (i4 i4Var : j4Var.p().s()) {
                k6 k6VarR = i4Var.r();
                String strQ = i4Var.q();
                Iterator it = k6VarR.iterator();
                while (it.hasNext()) {
                    n nVarS = eVar.s(this.f20506b, (k4) it.next());
                    if (!(nVarS instanceof m)) {
                        throw new IllegalArgumentException("Invalid rule definition");
                    }
                    u.e eVar2 = this.f20506b;
                    if (eVar2.w(strQ)) {
                        n nVarR = eVar2.r(strQ);
                        if (!(nVarR instanceof j)) {
                            throw new IllegalStateException("Invalid function name: " + strQ);
                        }
                        jVar = (j) nVarR;
                    } else {
                        jVar = null;
                    }
                    if (jVar == null) {
                        throw new IllegalStateException("Rule function is undefined: " + strQ);
                    }
                    jVar.a(this.f20506b, Collections.singletonList(nVarS));
                }
            }
        } catch (Throwable th) {
            throw new zzc(th);
        }
    }

    public final boolean b(c cVar) throws zzc {
        List list;
        xyz.stream.utils.t tVar = this.f20507c;
        try {
            tVar.f36172b = cVar;
            tVar.f36174d = (c) cVar.clone();
            ((List) tVar.f36173c).clear();
            ((u.e) this.f20505a.f33127c).x("runtime.counter", new g(Double.valueOf(0.0d)));
            this.f20508d.e(this.f20506b.t(), tVar);
            xyz.stream.utils.t tVar2 = this.f20507c;
            if (!(!((c) tVar2.f36174d).equals((c) tVar2.f36172b))) {
                xyz.stream.utils.t tVar3 = this.f20507c;
                switch (tVar3.f36171a) {
                    case 11:
                        list = (List) tVar3.f36173c;
                        break;
                    default:
                        list = (List) tVar3.f36173c;
                        break;
                }
                if (!(!list.isEmpty())) {
                    return false;
                }
            }
            return true;
        } catch (Throwable th) {
            throw new zzc(th);
        }
    }
}
