package o;

import java.util.ArrayList;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.d90, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C0982d90 {
    public final C1077e90 a;
    public final int[] b;
    public final int c;
    public Object[] d;
    public final int e;
    public boolean f;
    public int g;
    public int h;
    public int i;
    public final C1564jI j;
    public int k;
    public int l;
    public int m;
    public boolean n;

    public C0982d90(C1077e90 c1077e90) {
        this.a = c1077e90;
        this.b = c1077e90.l;
        int i = c1077e90.m;
        this.c = i;
        this.d = c1077e90.n;
        this.e = c1077e90.f504o;
        this.h = i;
        this.i = -1;
        this.j = new C1564jI();
    }

    public final G2 a(int i) {
        ArrayList arrayList = this.a.t;
        int iE = AbstractC1269g90.e(arrayList, i, this.c);
        if (iE >= 0) {
            return (G2) arrayList.get(iE);
        }
        G2 g2 = new G2(i);
        arrayList.add(-(iE + 1), g2);
        return g2;
    }

    public final Object b(int[] iArr, int i) {
        int i2 = i * 5;
        int i3 = iArr[i2 + 1];
        if ((268435456 & i3) != 0) {
            return this.d[i2 >= iArr.length ? iArr.length : iArr[i2 + 4] + Integer.bitCount(i3 >> 29)];
        }
        return C0140Fk.a;
    }

    public final void c() {
        this.f = true;
        C1077e90 c1077e90 = this.a;
        c1077e90.getClass();
        if (this.a != c1077e90 || c1077e90.p <= 0) {
            AbstractC0373Ok.c("Unexpected reader close()");
        }
        c1077e90.p--;
        this.d = new Object[0];
    }

    public final boolean d(int i) {
        return (this.b[(i * 5) + 1] & 67108864) != 0;
    }

    public final void e() {
        if (this.k == 0) {
            if (!(this.g == this.h)) {
                AbstractC0373Ok.c("endGroup() not called at the end of a group");
            }
            int i = (this.i * 5) + 2;
            int[] iArr = this.b;
            int i2 = iArr[i];
            this.i = i2;
            int i3 = this.c;
            this.h = i2 < 0 ? i3 : AbstractC1269g90.a(iArr, i2) + i2;
            int iB = this.j.b();
            if (iB < 0) {
                this.l = 0;
                this.m = 0;
            } else {
                this.l = iB;
                this.m = i2 >= i3 - 1 ? this.e : iArr[((i2 + 1) * 5) + 4];
            }
        }
    }

    public final Object f() {
        int i = this.g;
        if (i < this.h) {
            return b(this.b, i);
        }
        return 0;
    }

    public final int g() {
        int i = this.g;
        if (i >= this.h) {
            return 0;
        }
        return this.b[i * 5];
    }

    public final Object h(int i, int i2) {
        int[] iArr = this.b;
        int iC = AbstractC1269g90.c(iArr, i);
        int i3 = i + 1;
        int i4 = iC + i2;
        return i4 < (i3 < this.c ? iArr[(i3 * 5) + 4] : this.e) ? this.d[i4] : C0140Fk.a;
    }

    public final int i(int i) {
        return this.b[i * 5];
    }

    public final boolean j(int i) {
        return (this.b[(i * 5) + 1] & 134217728) != 0;
    }

    public final boolean k(int i) {
        return (this.b[(i * 5) + 1] & 536870912) != 0;
    }

    public final boolean l(int i) {
        return (this.b[(i * 5) + 1] & 1073741824) != 0;
    }

    public final Object m() {
        int i;
        if (this.k > 0 || (i = this.l) >= this.m) {
            this.n = false;
            return C0140Fk.a;
        }
        this.n = true;
        Object[] objArr = this.d;
        this.l = i + 1;
        return objArr[i];
    }

    public final Object n(int i) {
        int i2 = i * 5;
        int[] iArr = this.b;
        int i3 = iArr[i2 + 1] & 1073741824;
        if (i3 != 0) {
            return i3 != 0 ? this.d[iArr[i2 + 4]] : C0140Fk.a;
        }
        return null;
    }

    public final int o(int i) {
        return this.b[(i * 5) + 1] & 67108863;
    }

    public final Object p(int[] iArr, int i) {
        int i2 = i * 5;
        int i3 = iArr[i2 + 1];
        if ((536870912 & i3) == 0) {
            return null;
        }
        return this.d[Integer.bitCount(i3 >> 30) + iArr[i2 + 4]];
    }

    public final int q(int i) {
        return this.b[(i * 5) + 2];
    }

    public final void r(int i) {
        if (!(this.k == 0)) {
            AbstractC0373Ok.c("Cannot reposition while in an empty region");
        }
        this.g = i;
        int[] iArr = this.b;
        int i2 = this.c;
        int i3 = i < i2 ? iArr[(i * 5) + 2] : -1;
        if (i3 != this.i) {
            this.i = i3;
            if (i3 < 0) {
                this.h = i2;
            } else {
                this.h = AbstractC1269g90.a(iArr, i3) + i3;
            }
            this.l = 0;
            this.m = 0;
        }
    }

    public final int s() {
        if (!(this.k == 0)) {
            AbstractC0373Ok.c("Cannot skip while in an empty region");
        }
        int i = this.g;
        int[] iArr = this.b;
        int i2 = (iArr[(i * 5) + 1] & 1073741824) == 0 ? iArr[(i * 5) + 1] & 67108863 : 1;
        this.g = AbstractC1269g90.a(iArr, i) + i;
        return i2;
    }

    public final void t() {
        if (!(this.k == 0)) {
            AbstractC0373Ok.c("Cannot skip the enclosing group while in an empty region");
        }
        this.g = this.h;
        this.l = 0;
        this.m = 0;
    }

    public final String toString() {
        StringBuilder sb = new StringBuilder("SlotReader(current=");
        sb.append(this.g);
        sb.append(", key=");
        sb.append(g());
        sb.append(", parent=");
        sb.append(this.i);
        sb.append(", end=");
        return AbstractC2462sn.m(sb, this.h, ')');
    }

    public final void u() {
        if (this.k <= 0) {
            int i = this.i;
            int i2 = this.g;
            int[] iArr = this.b;
            if (!(iArr[(i2 * 5) + 2] == i)) {
                AbstractC1102eY.a("Invalid slot table detected");
            }
            int i3 = this.l;
            int i4 = this.m;
            C1564jI c1564jI = this.j;
            if (i3 == 0 && i4 == 0) {
                c1564jI.c(-1);
            } else {
                c1564jI.c(i3);
            }
            this.i = i2;
            this.h = AbstractC1269g90.a(iArr, i2) + i2;
            int i5 = i2 + 1;
            this.g = i5;
            this.l = AbstractC1269g90.c(iArr, i2);
            this.m = i2 >= this.c - 1 ? this.e : iArr[(i5 * 5) + 4];
        }
    }
}
