package h.b.p.a0;

/* JADX INFO: compiled from: AbstractJsonLexer.kt */
/* JADX INFO: loaded from: classes.dex */
@g.i
public abstract class a {
    public int a;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public String f4489c;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final o f4488b = new o();

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public StringBuilder f4490d = new StringBuilder();

    public static /* synthetic */ Void q(a aVar, String str, int i2, String str2, int i3, Object obj) {
        if ((i3 & 2) != 0) {
            i2 = aVar.a;
        }
        if ((i3 & 4) != 0) {
            str2 = "";
        }
        aVar.p(str, i2, str2);
        throw null;
    }

    public final void A(char c2) {
        int i2 = this.a - 1;
        this.a = i2;
        if (i2 >= 0 && c2 == '\"' && g.h0.c.l.a(m(), "null")) {
            p("Expected string literal but 'null' literal was found", this.a - 4, "Use 'coerceInputValues = true' in 'Json {}` builder to coerce nulls to default values.");
            throw null;
        }
        r(f.a.y.a.y(c2));
        throw null;
    }

    public final int a(CharSequence charSequence, int i2) {
        int i3 = i2 + 4;
        if (i3 < charSequence.length()) {
            this.f4490d.append((char) (s(charSequence, i2 + 3) + (s(charSequence, i2) << 12) + (s(charSequence, i2 + 1) << 8) + (s(charSequence, i2 + 2) << 4)));
            return i3;
        }
        this.a = i2;
        if (i3 < charSequence.length()) {
            return a(charSequence, this.a);
        }
        q(this, "Unexpected EOF during unicode escape", 0, null, 6, null);
        throw null;
    }

    public void b(int i2, int i3) {
        this.f4490d.append(t(), i2, i3);
    }

    public abstract boolean c();

    public final boolean d(int i2) {
        int iV = v(i2);
        if (iV >= t().length() || iV == -1) {
            q(this, "EOF", 0, null, 6, null);
            throw null;
        }
        int i3 = iV + 1;
        int iCharAt = t().charAt(iV) | ' ';
        if (iCharAt == 102) {
            e("alse", i3);
            return false;
        }
        if (iCharAt == 116) {
            e("rue", i3);
            return true;
        }
        StringBuilder sbB = d.b.a.a.a.B("Expected valid boolean literal prefix, but had '");
        sbB.append(m());
        sbB.append('\'');
        q(this, sbB.toString(), 0, null, 6, null);
        throw null;
    }

    public final void e(String str, int i2) {
        if (t().length() - i2 < str.length()) {
            q(this, "Unexpected end of boolean literal", 0, null, 6, null);
            throw null;
        }
        int length = str.length();
        for (int i3 = 0; i3 < length; i3++) {
            if (str.charAt(i3) != (t().charAt(i2 + i3) | ' ')) {
                StringBuilder sbB = d.b.a.a.a.B("Expected valid boolean literal prefix, but had '");
                sbB.append(m());
                sbB.append('\'');
                q(this, sbB.toString(), 0, null, 6, null);
                throw null;
            }
        }
        this.a = str.length() + i2;
    }

    public abstract String f();

    public abstract String g(String str, boolean z);

    public abstract byte h();

    public final byte i(byte b2) {
        byte bH = h();
        if (bH == b2) {
            return bH;
        }
        r(b2);
        throw null;
    }

    public abstract void j(char c2);

    public final long k() {
        boolean z;
        int iV = v(w());
        if (iV >= t().length() || iV == -1) {
            q(this, "EOF", 0, null, 6, null);
            throw null;
        }
        if (t().charAt(iV) == '\"') {
            iV++;
            if (iV == t().length()) {
                q(this, "EOF", 0, null, 6, null);
                throw null;
            }
            z = true;
        } else {
            z = false;
        }
        int i2 = iV;
        long j2 = 0;
        boolean z2 = true;
        boolean z3 = false;
        while (z2) {
            char cCharAt = t().charAt(i2);
            if (cCharAt != '-') {
                if (f.a.y.a.y(cCharAt) != 0) {
                    break;
                }
                i2++;
                boolean z4 = i2 != t().length();
                int i3 = cCharAt - '0';
                if (!(i3 >= 0 && i3 < 10)) {
                    q(this, "Unexpected symbol '" + cCharAt + "' in numeric literal", 0, null, 6, null);
                    throw null;
                }
                boolean z5 = z4;
                j2 = (j2 * ((long) 10)) - ((long) i3);
                if (j2 > 0) {
                    q(this, "Numeric value overflow", 0, null, 6, null);
                    throw null;
                }
                z2 = z5;
            } else {
                if (i2 != iV) {
                    q(this, "Unexpected symbol '-' in numeric literal", 0, null, 6, null);
                    throw null;
                }
                i2++;
                z3 = true;
            }
        }
        if (iV == i2 || (z3 && iV == i2 - 1)) {
            q(this, "Expected numeric literal", 0, null, 6, null);
            throw null;
        }
        if (z) {
            if (!z2) {
                q(this, "EOF", 0, null, 6, null);
                throw null;
            }
            if (t().charAt(i2) != '\"') {
                q(this, "Expected closing quotation mark", 0, null, 6, null);
                throw null;
            }
            i2++;
        }
        this.a = i2;
        if (z3) {
            return j2;
        }
        if (j2 != Long.MIN_VALUE) {
            return -j2;
        }
        q(this, "Numeric value overflow", 0, null, 6, null);
        throw null;
    }

    public final String l() {
        String str = this.f4489c;
        if (str == null) {
            return f();
        }
        g.h0.c.l.c(str);
        this.f4489c = null;
        return str;
    }

    public final String m() {
        String str = this.f4489c;
        if (str != null) {
            g.h0.c.l.c(str);
            this.f4489c = null;
            return str;
        }
        int iW = w();
        if (iW >= t().length() || iW == -1) {
            q(this, "EOF", iW, null, 4, null);
            throw null;
        }
        byte bY = f.a.y.a.y(t().charAt(iW));
        if (bY == 1) {
            return l();
        }
        if (bY != 0) {
            StringBuilder sbB = d.b.a.a.a.B("Expected beginning of the string, but got ");
            sbB.append(t().charAt(iW));
            q(this, sbB.toString(), 0, null, 6, null);
            throw null;
        }
        boolean z = false;
        while (f.a.y.a.y(t().charAt(iW)) == 0) {
            iW++;
            if (iW >= t().length()) {
                b(this.a, iW);
                int iV = v(iW);
                if (iV == -1) {
                    this.a = iW;
                    return o(0, 0);
                }
                iW = iV;
                z = true;
            }
        }
        String strX = !z ? x(this.a, iW) : o(this.a, iW);
        this.a = iW;
        return strX;
    }

    public final String n() {
        String strM = m();
        if (g.h0.c.l.a(strM, "null")) {
            if (t().charAt(this.a - 1) != '\"') {
                q(this, "Unexpected 'null' value instead of string literal", 0, null, 6, null);
                throw null;
            }
        }
        return strM;
    }

    public final String o(int i2, int i3) {
        this.f4490d.append(t(), i2, i3);
        String string = this.f4490d.toString();
        g.h0.c.l.e(string, "escapedString.toString()");
        this.f4490d.setLength(0);
        return string;
    }

    public final Void p(String str, int i2, String str2) {
        String str3;
        g.h0.c.l.f(str, "message");
        g.h0.c.l.f(str2, "hint");
        if (str2.length() == 0) {
            str3 = "";
        } else {
            str3 = '\n' + str2;
        }
        StringBuilder sbD = d.b.a.a.a.D(str, " at path: ");
        sbD.append(this.f4488b.a());
        sbD.append(str3);
        throw f.a.y.a.f(i2, sbD.toString(), t());
    }

    public final Void r(byte b2) {
        q(this, "Expected " + (b2 == 1 ? "quotation mark '\"'" : b2 == 4 ? "comma ','" : b2 == 5 ? "colon ':'" : b2 == 6 ? "start of the object '{'" : b2 == 7 ? "end of the object '}'" : b2 == 8 ? "start of the array '['" : b2 == 9 ? "end of the array ']'" : "valid token") + ", but had '" + ((this.a == t().length() || this.a <= 0) ? "EOF" : String.valueOf(t().charAt(this.a - 1))) + "' instead", this.a - 1, null, 4, null);
        throw null;
    }

    public final int s(CharSequence charSequence, int i2) {
        char cCharAt = charSequence.charAt(i2);
        if ('0' <= cCharAt && cCharAt < ':') {
            return cCharAt - '0';
        }
        char c2 = 'a';
        if (!('a' <= cCharAt && cCharAt < 'g')) {
            c2 = 'A';
            if (!('A' <= cCharAt && cCharAt < 'G')) {
                q(this, "Invalid toHexChar char '" + cCharAt + "' in unicode escape", 0, null, 6, null);
                throw null;
            }
        }
        return (cCharAt - c2) + 10;
    }

    public abstract CharSequence t();

    public String toString() {
        StringBuilder sbB = d.b.a.a.a.B("JsonReader(source='");
        sbB.append((Object) t());
        sbB.append("', currentPosition=");
        sbB.append(this.a);
        sbB.append(')');
        return sbB.toString();
    }

    public final byte u() {
        CharSequence charSequenceT = t();
        int i2 = this.a;
        while (true) {
            int iV = v(i2);
            if (iV == -1) {
                this.a = iV;
                return (byte) 10;
            }
            char cCharAt = charSequenceT.charAt(iV);
            if (cCharAt != ' ' && cCharAt != '\n' && cCharAt != '\r' && cCharAt != '\t') {
                this.a = iV;
                return f.a.y.a.y(cCharAt);
            }
            i2 = iV + 1;
        }
    }

    public abstract int v(int i2);

    public abstract int w();

    public String x(int i2, int i3) {
        return t().subSequence(i2, i3).toString();
    }

    public abstract boolean y();

    public final boolean z() {
        int iV = v(w());
        int length = t().length() - iV;
        if (length < 4 || iV == -1) {
            return true;
        }
        for (int i2 = 0; i2 < 4; i2++) {
            if ("null".charAt(i2) != t().charAt(iV + i2)) {
                return true;
            }
        }
        if (length > 4 && f.a.y.a.y(t().charAt(iV + 4)) == 0) {
            return true;
        }
        this.a = iV + 4;
        return false;
    }
}
