package h.b.p.a0;

/* JADX INFO: compiled from: StringJsonLexer.kt */
/* JADX INFO: loaded from: classes.dex */
@g.i
public final class d0 extends a {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final String f4513e;

    public d0(String str) {
        g.h0.c.l.f(str, "source");
        this.f4513e = str;
    }

    @Override // h.b.p.a0.a
    public boolean c() {
        int i2 = this.a;
        if (i2 == -1) {
            return false;
        }
        while (i2 < this.f4513e.length()) {
            char cCharAt = this.f4513e.charAt(i2);
            if (cCharAt != ' ' && cCharAt != '\n' && cCharAt != '\r' && cCharAt != '\t') {
                this.a = i2;
                return !(((cCharAt == '}' || cCharAt == ']') || cCharAt == ':') || cCharAt == ',');
            }
            i2++;
        }
        this.a = i2;
        return false;
    }

    @Override // h.b.p.a0.a
    public String f() {
        j('\"');
        int i2 = this.a;
        int iL = g.m0.f.l(this.f4513e, '\"', i2, false, 4);
        if (iL == -1) {
            r((byte) 1);
            throw null;
        }
        int i3 = i2;
        while (i3 < iL) {
            if (this.f4513e.charAt(i3) == '\\') {
                String str = this.f4513e;
                int iV = this.a;
                g.h0.c.l.f(str, "source");
                char cCharAt = str.charAt(i3);
                boolean z = false;
                while (cCharAt != '\"') {
                    if (cCharAt == '\\') {
                        this.f4490d.append(t(), iV, i3);
                        int iV2 = v(i3 + 1);
                        if (iV2 == -1) {
                            a.q(this, "Expected escape sequence to continue, got EOF", 0, null, 6, null);
                            throw null;
                        }
                        int iA = iV2 + 1;
                        char cCharAt2 = ((String) t()).charAt(iV2);
                        if (cCharAt2 == 'u') {
                            iA = a(t(), iA);
                        } else {
                            char c2 = cCharAt2 < 'u' ? d.f4511b[cCharAt2] : (char) 0;
                            if (c2 == 0) {
                                a.q(this, "Invalid escaped char '" + cCharAt2 + '\'', 0, null, 6, null);
                                throw null;
                            }
                            this.f4490d.append(c2);
                        }
                        iV = v(iA);
                        if (iV == -1) {
                            a.q(this, "EOF", iV, null, 4, null);
                            throw null;
                        }
                    } else {
                        i3++;
                        if (i3 >= str.length()) {
                            b(iV, i3);
                            iV = v(i3);
                            if (iV == -1) {
                                a.q(this, "EOF", iV, null, 4, null);
                                throw null;
                            }
                        } else {
                            continue;
                            cCharAt = str.charAt(i3);
                        }
                    }
                    i3 = iV;
                    z = true;
                    cCharAt = str.charAt(i3);
                }
                String strX = !z ? x(iV, i3) : o(iV, i3);
                this.a = i3 + 1;
                return strX;
            }
            i3++;
        }
        this.a = iL + 1;
        String strSubstring = this.f4513e.substring(i2, iL);
        g.h0.c.l.e(strSubstring, "this as java.lang.String…ing(startIndex, endIndex)");
        return strSubstring;
    }

    @Override // h.b.p.a0.a
    public String g(String str, boolean z) {
        g.h0.c.l.f(str, "keyToMatch");
        int i2 = this.a;
        try {
            if (h() != 6) {
                return null;
            }
            if (!g.h0.c.l.a(z ? f() : n(), str)) {
                return null;
            }
            if (h() != 5) {
                return null;
            }
            return z ? l() : n();
        } finally {
            this.a = i2;
        }
    }

    @Override // h.b.p.a0.a
    public byte h() {
        byte bY;
        String str = this.f4513e;
        do {
            int i2 = this.a;
            if (i2 == -1 || i2 >= str.length()) {
                return (byte) 10;
            }
            int i3 = this.a;
            this.a = i3 + 1;
            bY = f.a.y.a.y(str.charAt(i3));
        } while (bY == 3);
        return bY;
    }

    @Override // h.b.p.a0.a
    public void j(char c2) {
        if (this.a == -1) {
            A(c2);
            throw null;
        }
        String str = this.f4513e;
        while (this.a < str.length()) {
            int i2 = this.a;
            this.a = i2 + 1;
            char cCharAt = str.charAt(i2);
            if (cCharAt != ' ' && cCharAt != '\n' && cCharAt != '\r' && cCharAt != '\t') {
                if (cCharAt == c2) {
                    return;
                }
                A(c2);
                throw null;
            }
        }
        A(c2);
        throw null;
    }

    @Override // h.b.p.a0.a
    public CharSequence t() {
        return this.f4513e;
    }

    @Override // h.b.p.a0.a
    public int v(int i2) {
        if (i2 < this.f4513e.length()) {
            return i2;
        }
        return -1;
    }

    @Override // h.b.p.a0.a
    public int w() {
        char cCharAt;
        int i2 = this.a;
        if (i2 == -1) {
            return i2;
        }
        while (i2 < this.f4513e.length() && ((cCharAt = this.f4513e.charAt(i2)) == ' ' || cCharAt == '\n' || cCharAt == '\r' || cCharAt == '\t')) {
            i2++;
        }
        this.a = i2;
        return i2;
    }

    @Override // h.b.p.a0.a
    public boolean y() {
        int iW = w();
        if (iW == this.f4513e.length() || iW == -1 || this.f4513e.charAt(iW) != ',') {
            return false;
        }
        this.a++;
        return true;
    }
}
