package o;

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

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.cp0, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C0944cp0 {
    public final S60 a;
    public C2062oc0 b;
    public final C70 c;
    public final Gm0 d;

    public C0944cp0() {
        S60 s60 = new S60(11);
        this.a = s60;
        this.b = ((C2062oc0) s60.n).j();
        this.c = new C70(8);
        this.d = new Gm0(16);
        final int i = 1;
        Callable callable = new Callable(this) { // from class: o.Fn0
            public final /* synthetic */ C0944cp0 b;

            {
                this.b = this;
            }

            @Override // java.util.concurrent.Callable
            public final /* synthetic */ Object call() {
                switch (i) {
                    case 0:
                        return new Bs0(this.b.c);
                    default:
                        return new Bs0(this.b.d);
                }
            }
        };
        C0559Vo c0559Vo = (C0559Vo) s60.p;
        c0559Vo.a.put("internal.registerCallback", callable);
        final int i2 = 0;
        c0559Vo.a.put("internal.eventLogger", new Callable(this) { // from class: o.Fn0
            public final /* synthetic */ C0944cp0 b;

            {
                this.b = this;
            }

            @Override // java.util.concurrent.Callable
            public final /* synthetic */ Object call() {
                switch (i2) {
                    case 0:
                        return new Bs0(this.b.c);
                    default:
                        return new Bs0(this.b.d);
                }
            }
        });
    }

    public final boolean a(Kn0 kn0) throws C2657up0 {
        C70 c70 = this.c;
        try {
            c70.m = kn0;
            c70.n = kn0.clone();
            ((ArrayList) c70.f65o).clear();
            ((C2062oc0) this.a.f325o).l("runtime.counter", new Wn0(Double.valueOf(0.0d)));
            this.d.p(this.b.j(), c70);
            if (((Kn0) c70.n).equals((Kn0) c70.m)) {
                return !((ArrayList) c70.f65o).isEmpty();
            }
            return true;
        } catch (Throwable th) {
            throw new C2657up0(th);
        }
    }

    public final void b(C1141es0 c1141es0) throws C2657up0 {
        Yn0 yn0;
        try {
            S60 s60 = this.a;
            this.b = ((C2062oc0) s60.n).j();
            if (s60.q(this.b, (C1333gs0[]) c1141es0.p().toArray(new C1333gs0[0])) instanceof Un0) {
                throw new IllegalStateException("Program loading failed");
            }
            for (C0950cs0 c0950cs0 : c1141es0.q().p()) {
                List listQ = c0950cs0.q();
                String strP = c0950cs0.p();
                Iterator it = listQ.iterator();
                while (it.hasNext()) {
                    InterfaceC1991no0 interfaceC1991no0Q = s60.q(this.b, (C1333gs0) it.next());
                    if (!(interfaceC1991no0Q instanceof C1325go0)) {
                        throw new IllegalArgumentException("Invalid rule definition");
                    }
                    C2062oc0 c2062oc0 = this.b;
                    if (c2062oc0.k(strP)) {
                        InterfaceC1991no0 interfaceC1991no0N = c2062oc0.n(strP);
                        if (!(interfaceC1991no0N instanceof Yn0)) {
                            throw new IllegalStateException("Invalid function name: ".concat(String.valueOf(strP)));
                        }
                        yn0 = (Yn0) interfaceC1991no0N;
                    } else {
                        yn0 = null;
                    }
                    if (yn0 == null) {
                        throw new IllegalStateException("Rule function is undefined: ".concat(String.valueOf(strP)));
                    }
                    yn0.g(this.b, Collections.singletonList(interfaceC1991no0Q));
                }
            }
        } catch (Throwable th) {
            throw new C2657up0(th);
        }
    }
}
