package e.a.r.y;

import e.a.o.k;
import java.util.Arrays;

/* JADX INFO: compiled from: JsonPath.kt */
/* JADX INFO: loaded from: classes.dex */
@d.n
public final class a0 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private Object[] f2996a = new Object[8];

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private int[] f2997b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private int f2998c;

    /* JADX INFO: compiled from: JsonPath.kt */
    @d.n
    private static final class a {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public static final a f2999a = new a();

        private a() {
        }
    }

    public a0() {
        int[] iArr = new int[8];
        for (int i = 0; i < 8; i++) {
            iArr[i] = -1;
        }
        this.f2997b = iArr;
        this.f2998c = -1;
    }

    private final void e() {
        int i = this.f2998c * 2;
        Object[] objArrCopyOf = Arrays.copyOf(this.f2996a, i);
        d.n0.c.s.d(objArrCopyOf, "copyOf(this, newSize)");
        this.f2996a = objArrCopyOf;
        int[] iArrCopyOf = Arrays.copyOf(this.f2997b, i);
        d.n0.c.s.d(iArrCopyOf, "copyOf(this, newSize)");
        this.f2997b = iArrCopyOf;
    }

    public final String a() {
        StringBuilder sb = new StringBuilder();
        sb.append("$");
        int i = this.f2998c + 1;
        for (int i2 = 0; i2 < i; i2++) {
            Object obj = this.f2996a[i2];
            if (obj instanceof e.a.o.f) {
                e.a.o.f fVar = (e.a.o.f) obj;
                if (!d.n0.c.s.a(fVar.e(), k.b.f2793a)) {
                    int i3 = this.f2997b[i2];
                    if (i3 >= 0) {
                        sb.append(".");
                        sb.append(fVar.h(i3));
                    }
                } else if (this.f2997b[i2] != -1) {
                    sb.append("[");
                    sb.append(this.f2997b[i2]);
                    sb.append("]");
                }
            } else if (obj != a.f2999a) {
                sb.append("[");
                sb.append("'");
                sb.append(obj);
                sb.append("'");
                sb.append("]");
            }
        }
        String string = sb.toString();
        d.n0.c.s.d(string, "StringBuilder().apply(builderAction).toString()");
        return string;
    }

    public final void b() {
        int i = this.f2998c;
        int[] iArr = this.f2997b;
        if (iArr[i] == -2) {
            iArr[i] = -1;
            this.f2998c = i - 1;
        }
        int i2 = this.f2998c;
        if (i2 != -1) {
            this.f2998c = i2 - 1;
        }
    }

    public final void c(e.a.o.f fVar) {
        d.n0.c.s.e(fVar, "sd");
        int i = this.f2998c + 1;
        this.f2998c = i;
        if (i == this.f2996a.length) {
            e();
        }
        this.f2996a[i] = fVar;
    }

    public final void d() {
        int[] iArr = this.f2997b;
        int i = this.f2998c;
        if (iArr[i] == -2) {
            this.f2996a[i] = a.f2999a;
        }
    }

    public final void f(Object obj) {
        int[] iArr = this.f2997b;
        int i = this.f2998c;
        if (iArr[i] != -2) {
            int i2 = i + 1;
            this.f2998c = i2;
            if (i2 == this.f2996a.length) {
                e();
            }
        }
        Object[] objArr = this.f2996a;
        int i3 = this.f2998c;
        objArr[i3] = obj;
        this.f2997b[i3] = -2;
    }

    public final void g(int i) {
        this.f2997b[this.f2998c] = i;
    }

    public String toString() {
        return a();
    }
}
