package m5;

import F.f0;
import java.io.Serializable;
import java.util.ArrayList;
import m1.AbstractC2464a;

/* JADX INFO: loaded from: classes3.dex */
public class y {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f21303a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int f21304b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Object f21305c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public Serializable f21306d;

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final Serializable f21308f;

    public y() {
        this.f21303a = 1;
        this.f21305c = new ArrayList();
        this.f21306d = new ArrayList();
        this.f21307e = new ArrayList();
        this.f21308f = u5.g.f24607r;
        this.f21304b = 1;
    }

    public static /* synthetic */ void m(y yVar, String str, int i6, String str2, int i7) {
        if ((i7 & 2) != 0) {
            i6 = yVar.f21304b;
        }
        if ((i7 & 4) != 0) {
            str2 = "";
        }
        yVar.l(i6, str, str2);
        throw null;
    }

    public int a(CharSequence charSequence, int i6) {
        int i7 = i6 + 4;
        if (i7 < charSequence.length()) {
            ((StringBuilder) this.f21308f).append((char) (o(charSequence, i6 + 3) + (o(charSequence, i6) << 12) + (o(charSequence, i6 + 1) << 8) + (o(charSequence, i6 + 2) << 4)));
            return i7;
        }
        this.f21304b = i6;
        if (i7 < charSequence.length()) {
            return a(charSequence, this.f21304b);
        }
        m(this, "Unexpected EOF during unicode escape", 0, null, 6);
        throw null;
    }

    public boolean b() {
        int i6 = this.f21304b;
        if (i6 == -1) {
            return false;
        }
        while (true) {
            String str = (String) this.f21307e;
            if (i6 >= str.length()) {
                this.f21304b = i6;
                return false;
            }
            char cCharAt = str.charAt(i6);
            if (cCharAt != ' ' && cCharAt != '\n' && cCharAt != '\r' && cCharAt != '\t') {
                this.f21304b = i6;
                return (cCharAt == ',' || cCharAt == ':' || cCharAt == ']' || cCharAt == '}') ? false : true;
            }
            i6++;
        }
    }

    public void c(int i6, String str) {
        String str2 = (String) this.f21307e;
        if (str2.length() - i6 < str.length()) {
            m(this, "Unexpected end of boolean literal", 0, null, 6);
            throw null;
        }
        int length = str.length();
        for (int i7 = 0; i7 < length; i7++) {
            if (str.charAt(i7) != (str2.charAt(i6 + i7) | ' ')) {
                m(this, "Expected valid boolean literal prefix, but had '" + j() + '\'', 0, null, 6);
                throw null;
            }
        }
        this.f21304b = str.length() + i6;
    }

    public String d() {
        g('\"');
        int i6 = this.f21304b;
        String str = (String) this.f21307e;
        int iN0 = S4.p.N0(str, '\"', i6, 4);
        if (iN0 == -1) {
            j();
            n((byte) 1, false);
            throw null;
        }
        int i7 = i6;
        while (i7 < iN0) {
            if (str.charAt(i7) == '\\') {
                int iS = this.f21304b;
                char cCharAt = str.charAt(i7);
                boolean z6 = false;
                while (cCharAt != '\"') {
                    if (cCharAt == '\\') {
                        ((StringBuilder) this.f21308f).append((CharSequence) str, iS, i7);
                        int iS2 = s(i7 + 1);
                        if (iS2 == -1) {
                            m(this, "Expected escape sequence to continue, got EOF", 0, null, 6);
                            throw null;
                        }
                        int iA = iS2 + 1;
                        char cCharAt2 = str.charAt(iS2);
                        if (cCharAt2 == 'u') {
                            iA = a(str, iA);
                        } else {
                            char c6 = cCharAt2 < 'u' ? e.f21246a[cCharAt2] : (char) 0;
                            if (c6 == 0) {
                                m(this, "Invalid escaped char '" + cCharAt2 + '\'', 0, null, 6);
                                throw null;
                            }
                            ((StringBuilder) this.f21308f).append(c6);
                        }
                        iS = s(iA);
                        if (iS == -1) {
                            m(this, "Unexpected EOF", iS, null, 4);
                            throw null;
                        }
                    } else {
                        i7++;
                        if (i7 >= str.length()) {
                            ((StringBuilder) this.f21308f).append((CharSequence) str, iS, i7);
                            iS = s(i7);
                            if (iS == -1) {
                                m(this, "Unexpected EOF", iS, null, 4);
                                throw null;
                            }
                        } else {
                            continue;
                            cCharAt = str.charAt(i7);
                        }
                    }
                    i7 = iS;
                    z6 = true;
                    cCharAt = str.charAt(i7);
                }
                String string = !z6 ? str.subSequence(iS, i7).toString() : k(iS, i7);
                this.f21304b = i7 + 1;
                return string;
            }
            i7++;
        }
        this.f21304b = iN0 + 1;
        String strSubstring = str.substring(i6, iN0);
        kotlin.jvm.internal.o.g(strSubstring, "substring(...)");
        return strSubstring;
    }

    /* JADX WARN: Code restructure failed: missing block: B:18:0x002f, code lost:
    
        r4.f21304b = r3.length();
     */
    /* JADX WARN: Code restructure failed: missing block: B:19:0x0035, code lost:
    
        return 10;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public byte e() {
        int i6 = this.f21304b;
        while (true) {
            String str = (String) this.f21307e;
            if (i6 == -1 || i6 >= str.length()) {
                break;
            }
            int i7 = i6 + 1;
            char cCharAt = str.charAt(i6);
            if (cCharAt != ' ' && cCharAt != '\n' && cCharAt != '\r' && cCharAt != '\t') {
                this.f21304b = i7;
                return l.g(cCharAt);
            }
            i6 = i7;
        }
    }

    public byte f(byte b5) {
        byte bE = e();
        if (bE == b5) {
            return bE;
        }
        n(b5, true);
        throw null;
    }

    public void g(char c6) {
        int i6 = this.f21304b;
        if (i6 == -1) {
            v(c6);
            throw null;
        }
        while (true) {
            String str = (String) this.f21307e;
            if (i6 >= str.length()) {
                this.f21304b = -1;
                v(c6);
                throw null;
            }
            int i7 = i6 + 1;
            char cCharAt = str.charAt(i6);
            if (cCharAt != ' ' && cCharAt != '\n' && cCharAt != '\r' && cCharAt != '\t') {
                this.f21304b = i7;
                if (cCharAt == c6) {
                    return;
                }
                v(c6);
                throw null;
            }
            i6 = i7;
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:100:0x0194, code lost:
    
        throw null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:101:0x0195, code lost:
    
        m(r21, "Numeric value overflow", 0, null, 6);
     */
    /* JADX WARN: Code restructure failed: missing block: B:102:0x019b, code lost:
    
        throw null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:104:0x01a1, code lost:
    
        throw new E3.v();
     */
    /* JADX WARN: Code restructure failed: missing block: B:105:0x01a2, code lost:
    
        if (r20 == false) goto L107;
     */
    /* JADX WARN: Code restructure failed: missing block: B:106:0x01a4, code lost:
    
        return r10;
     */
    /* JADX WARN: Code restructure failed: missing block: B:108:0x01a9, code lost:
    
        if (r10 == Long.MIN_VALUE) goto L111;
     */
    /* JADX WARN: Code restructure failed: missing block: B:110:0x01ac, code lost:
    
        return -r10;
     */
    /* JADX WARN: Code restructure failed: missing block: B:111:0x01ad, code lost:
    
        m(r21, "Numeric value overflow", 0, null, 6);
     */
    /* JADX WARN: Code restructure failed: missing block: B:112:0x01b3, code lost:
    
        throw null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:113:0x01b4, code lost:
    
        m(r21, "Expected numeric literal", 0, null, 6);
     */
    /* JADX WARN: Code restructure failed: missing block: B:114:0x01b9, code lost:
    
        throw null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:63:0x00fa, code lost:
    
        m(r21, "Unexpected symbol '" + r5 + "' in numeric literal", 0, null, 6);
     */
    /* JADX WARN: Code restructure failed: missing block: B:64:0x0113, code lost:
    
        throw null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:66:0x011a, code lost:
    
        if (r12 == r1) goto L68;
     */
    /* JADX WARN: Code restructure failed: missing block: B:67:0x011c, code lost:
    
        r3 = true;
     */
    /* JADX WARN: Code restructure failed: missing block: B:68:0x011e, code lost:
    
        r3 = false;
     */
    /* JADX WARN: Code restructure failed: missing block: B:69:0x011f, code lost:
    
        if (r1 == r12) goto L74;
     */
    /* JADX WARN: Code restructure failed: missing block: B:70:0x0121, code lost:
    
        if (r20 == false) goto L75;
     */
    /* JADX WARN: Code restructure failed: missing block: B:72:0x0125, code lost:
    
        if (r1 == (r12 - 1)) goto L74;
     */
    /* JADX WARN: Code restructure failed: missing block: B:75:0x012d, code lost:
    
        if (r18 == false) goto L84;
     */
    /* JADX WARN: Code restructure failed: missing block: B:76:0x012f, code lost:
    
        if (r3 == false) goto L82;
     */
    /* JADX WARN: Code restructure failed: missing block: B:78:0x0137, code lost:
    
        if (r2.charAt(r12) != '\"') goto L80;
     */
    /* JADX WARN: Code restructure failed: missing block: B:79:0x0139, code lost:
    
        r12 = r12 + 1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:80:0x013c, code lost:
    
        m(r21, "Expected closing quotation mark", 0, null, 6);
     */
    /* JADX WARN: Code restructure failed: missing block: B:81:0x0144, code lost:
    
        throw null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:82:0x0145, code lost:
    
        m(r21, "EOF", 0, null, 6);
     */
    /* JADX WARN: Code restructure failed: missing block: B:83:0x014b, code lost:
    
        throw null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:84:0x014c, code lost:
    
        r21.f21304b = r12;
     */
    /* JADX WARN: Code restructure failed: missing block: B:85:0x014e, code lost:
    
        if (r19 == false) goto L105;
     */
    /* JADX WARN: Code restructure failed: missing block: B:86:0x0150, code lost:
    
        r1 = r10;
     */
    /* JADX WARN: Code restructure failed: missing block: B:87:0x0153, code lost:
    
        if (r15 != false) goto L89;
     */
    /* JADX WARN: Code restructure failed: missing block: B:88:0x0155, code lost:
    
        r3 = java.lang.Math.pow(10.0d, -r8);
     */
    /* JADX WARN: Code restructure failed: missing block: B:90:0x015d, code lost:
    
        if (r15 != true) goto L103;
     */
    /* JADX WARN: Code restructure failed: missing block: B:91:0x015f, code lost:
    
        r3 = java.lang.Math.pow(10.0d, r8);
     */
    /* JADX WARN: Code restructure failed: missing block: B:92:0x0164, code lost:
    
        r1 = r1 * r3;
     */
    /* JADX WARN: Code restructure failed: missing block: B:93:0x0169, code lost:
    
        if (r1 > 9.223372036854776E18d) goto L101;
     */
    /* JADX WARN: Code restructure failed: missing block: B:95:0x016f, code lost:
    
        if (r1 < (-9.223372036854776E18d)) goto L101;
     */
    /* JADX WARN: Code restructure failed: missing block: B:97:0x0177, code lost:
    
        if (java.lang.Math.floor(r1) != r1) goto L99;
     */
    /* JADX WARN: Code restructure failed: missing block: B:98:0x0179, code lost:
    
        r10 = (long) r1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:99:0x017b, code lost:
    
        m(r21, "Can't convert " + r1 + " to Long", 0, null, 6);
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public long h() {
        boolean z6;
        boolean z7;
        boolean z8;
        boolean z9;
        int iS = s(t());
        String str = (String) this.f21307e;
        if (iS < str.length() && iS != -1) {
            if (str.charAt(iS) == '\"') {
                iS++;
                if (iS == str.length()) {
                    m(this, "EOF", 0, null, 6);
                    throw null;
                }
                z6 = true;
            } else {
                z6 = false;
            }
            int i6 = iS;
            boolean z10 = false;
            boolean z11 = false;
            boolean z12 = false;
            long j4 = 0;
            long j6 = 0;
            while (true) {
                if (i6 == str.length()) {
                    z7 = z6;
                    z8 = z10;
                    z9 = z11;
                    break;
                }
                char cCharAt = str.charAt(i6);
                if ((cCharAt != 'e' && cCharAt != 'E') || z10) {
                    z7 = z6;
                    z8 = z10;
                    if (cCharAt == '-' && z8) {
                        if (i6 == iS) {
                            m(this, "Unexpected symbol '-' in numeric literal", 0, null, 6);
                            throw null;
                        }
                        i6++;
                        z6 = z7;
                        z10 = z8;
                        z12 = false;
                    } else if (cCharAt != '+' || !z8) {
                        z9 = z11;
                        if (cCharAt != '-') {
                            if (l.g(cCharAt) != 0) {
                                break;
                            }
                            i6++;
                            int i7 = cCharAt - '0';
                            if (i7 < 0 || i7 >= 10) {
                                break;
                            }
                            if (z8) {
                                j4 = (j4 * ((long) 10)) + ((long) i7);
                            } else {
                                j6 = (j6 * ((long) 10)) - ((long) i7);
                                if (j6 > 0) {
                                    m(this, "Numeric value overflow", 0, null, 6);
                                    throw null;
                                }
                            }
                            z6 = z7;
                            z10 = z8;
                            z11 = z9;
                        } else {
                            if (i6 != iS) {
                                m(this, "Unexpected symbol '-' in numeric literal", 0, null, 6);
                                throw null;
                            }
                            i6++;
                            z6 = z7;
                            z10 = z8;
                            z11 = true;
                        }
                    } else {
                        if (i6 == iS) {
                            m(this, "Unexpected symbol '+' in numeric literal", 0, null, 6);
                            throw null;
                        }
                        i6++;
                        z6 = z7;
                        z10 = z8;
                    }
                } else {
                    if (i6 == iS) {
                        m(this, "Unexpected symbol " + cCharAt + " in numeric literal", 0, null, 6);
                        throw null;
                    }
                    i6++;
                    z10 = true;
                }
                z12 = true;
            }
        } else {
            m(this, "EOF", 0, null, 6);
            throw null;
        }
    }

    public String i() {
        String str = (String) this.f21306d;
        if (str == null) {
            return d();
        }
        kotlin.jvm.internal.o.e(str);
        this.f21306d = null;
        return str;
    }

    public String j() {
        String str = (String) this.f21306d;
        if (str != null) {
            kotlin.jvm.internal.o.e(str);
            this.f21306d = null;
            return str;
        }
        int iT = t();
        String str2 = (String) this.f21307e;
        if (iT >= str2.length() || iT == -1) {
            m(this, "EOF", iT, null, 4);
            throw null;
        }
        byte bG = l.g(str2.charAt(iT));
        if (bG == 1) {
            return i();
        }
        if (bG != 0) {
            m(this, "Expected beginning of the string, but got " + str2.charAt(iT), 0, null, 6);
            throw null;
        }
        boolean z6 = false;
        while (l.g(str2.charAt(iT)) == 0) {
            iT++;
            if (iT >= str2.length()) {
                ((StringBuilder) this.f21308f).append((CharSequence) str2, this.f21304b, iT);
                int iS = s(iT);
                if (iS == -1) {
                    this.f21304b = iT;
                    return k(0, 0);
                }
                iT = iS;
                z6 = true;
            }
        }
        String string = !z6 ? str2.subSequence(this.f21304b, iT).toString() : k(this.f21304b, iT);
        this.f21304b = iT;
        return string;
    }

    public String k(int i6, int i7) {
        ((StringBuilder) this.f21308f).append((CharSequence) this.f21307e, i6, i7);
        StringBuilder sb = (StringBuilder) this.f21308f;
        String string = sb.toString();
        kotlin.jvm.internal.o.g(string, "toString(...)");
        sb.setLength(0);
        return string;
    }

    public void l(int i6, String message, String hint) {
        kotlin.jvm.internal.o.h(message, "message");
        kotlin.jvm.internal.o.h(hint, "hint");
        String strConcat = hint.length() == 0 ? "" : "\n".concat(hint);
        StringBuilder sbB = AbstractC2464a.b(message, " at path: ");
        sbB.append(((f0) this.f21305c).f());
        sbB.append(strConcat);
        throw l.c(i6, (String) this.f21307e, sbB.toString());
    }

    public void n(byte b5, boolean z6) {
        String strR = l.r(b5);
        int i6 = z6 ? this.f21304b - 1 : this.f21304b;
        int i7 = this.f21304b;
        String str = (String) this.f21307e;
        m(this, Z0.o.p("Expected ", strR, ", but had '", (i7 == str.length() || i6 < 0) ? "EOF" : String.valueOf(str.charAt(i6)), "' instead"), i6, null, 4);
        throw null;
    }

    public int o(CharSequence charSequence, int i6) {
        char cCharAt = charSequence.charAt(i6);
        if ('0' <= cCharAt && cCharAt < ':') {
            return cCharAt - '0';
        }
        if ('a' <= cCharAt && cCharAt < 'g') {
            return cCharAt - 'W';
        }
        if ('A' <= cCharAt && cCharAt < 'G') {
            return cCharAt - '7';
        }
        m(this, "Invalid toHexChar char '" + cCharAt + "' in unicode escape", 0, null, 6);
        throw null;
    }

    public String p(String keyToMatch) {
        kotlin.jvm.internal.o.h(keyToMatch, "keyToMatch");
        int i6 = this.f21304b;
        try {
            if (e() != 6) {
                return null;
            }
            if (!kotlin.jvm.internal.o.c(r(), keyToMatch)) {
                return null;
            }
            this.f21306d = null;
            if (e() != 5) {
                return null;
            }
            return r();
        } finally {
            this.f21304b = i6;
            this.f21306d = null;
        }
    }

    public byte q() {
        int i6 = this.f21304b;
        while (true) {
            int iS = s(i6);
            if (iS == -1) {
                this.f21304b = iS;
                return (byte) 10;
            }
            char cCharAt = ((String) this.f21307e).charAt(iS);
            if (cCharAt != '\t' && cCharAt != '\n' && cCharAt != '\r' && cCharAt != ' ') {
                this.f21304b = iS;
                return l.g(cCharAt);
            }
            i6 = iS + 1;
        }
    }

    public String r() {
        if (q() != 1) {
            return null;
        }
        String strI = i();
        this.f21306d = strI;
        return strI;
    }

    public int s(int i6) {
        if (i6 < ((String) this.f21307e).length()) {
            return i6;
        }
        return -1;
    }

    public int t() {
        char cCharAt;
        int i6 = this.f21304b;
        if (i6 == -1) {
            return i6;
        }
        while (true) {
            String str = (String) this.f21307e;
            if (i6 >= str.length() || !((cCharAt = str.charAt(i6)) == ' ' || cCharAt == '\n' || cCharAt == '\r' || cCharAt == '\t')) {
                break;
            }
            i6++;
        }
        this.f21304b = i6;
        return i6;
    }

    public String toString() {
        switch (this.f21303a) {
            case 0:
                StringBuilder sb = new StringBuilder("JsonReader(source='");
                sb.append(this.f21307e);
                sb.append("', currentPosition=");
                return com.google.android.recaptcha.internal.a.m(sb, this.f21304b, ')');
            default:
                return super.toString();
        }
    }

    public boolean u() {
        int iT = t();
        String str = (String) this.f21307e;
        if (iT >= str.length() || iT == -1 || str.charAt(iT) != ',') {
            return false;
        }
        this.f21304b++;
        return true;
    }

    public void v(char c6) {
        int i6 = this.f21304b;
        if (i6 > 0 && c6 == '\"') {
            try {
                this.f21304b = i6 - 1;
                String strJ = j();
                this.f21304b = i6;
                if (kotlin.jvm.internal.o.c(strJ, "null")) {
                    l(this.f21304b - 1, "Expected string literal but 'null' literal was found", "Use 'coerceInputValues = true' in 'Json {}' builder to coerce nulls if property has a default value.");
                    throw null;
                }
            } catch (Throwable th) {
                this.f21304b = i6;
                throw th;
            }
        }
        n(l.g(c6), true);
        throw null;
    }

    public y(String source) {
        this.f21303a = 0;
        kotlin.jvm.internal.o.h(source, "source");
        f0 f0Var = new f0(4);
        f0Var.f1280c = new Object[8];
        int[] iArr = new int[8];
        for (int i6 = 0; i6 < 8; i6++) {
            iArr[i6] = -1;
        }
        f0Var.f1281d = iArr;
        f0Var.f1279b = -1;
        this.f21305c = f0Var;
        this.f21308f = new StringBuilder();
        this.f21307e = source;
    }
}
