package km;

import com.fasterxml.jackson.core.json.ByteSourceJsonBootstrapper;
import java.io.EOFException;
import java.math.BigDecimal;
import km.m;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public final class o extends m {
    private static final kr.g B = kr.g.r("'\\");
    private static final kr.g C = kr.g.r("\"\\");
    private static final kr.g D = kr.g.r("{}[]:, \n\t\r\f/\\;#=");
    private static final kr.g E = kr.g.r("\n\r");
    private static final kr.g F = kr.g.r("*/");
    private String A;

    /* renamed from: v, reason: collision with root package name */
    private final kr.f f25946v;

    /* renamed from: w, reason: collision with root package name */
    private final kr.d f25947w;

    /* renamed from: x, reason: collision with root package name */
    private int f25948x = 0;

    /* renamed from: y, reason: collision with root package name */
    private long f25949y;

    /* renamed from: z, reason: collision with root package name */
    private int f25950z;

    /* JADX INFO: Access modifiers changed from: package-private */
    public o(kr.f fVar) {
        if (fVar == null) {
            throw new NullPointerException("source == null");
        }
        this.f25946v = fVar;
        this.f25947w = fVar.k();
        y(6);
    }

    private void L() {
        if (!this.f25942t) {
            throw K("Use JsonReader.setLenient(true) to accept malformed JSON");
        }
    }

    private int N() {
        int[] iArr = this.f25939q;
        int i10 = this.f25938p;
        int i11 = iArr[i10 - 1];
        if (i11 == 1) {
            iArr[i10 - 1] = 2;
        } else if (i11 == 2) {
            int X = X(true);
            this.f25947w.readByte();
            if (X != 44) {
                if (X != 59) {
                    if (X != 93) {
                        throw K("Unterminated array");
                    }
                    this.f25948x = 4;
                    return 4;
                }
                L();
            }
        } else {
            if (i11 == 3 || i11 == 5) {
                iArr[i10 - 1] = 4;
                if (i11 == 5) {
                    int X2 = X(true);
                    this.f25947w.readByte();
                    if (X2 != 44) {
                        if (X2 != 59) {
                            if (X2 != 125) {
                                throw K("Unterminated object");
                            }
                            this.f25948x = 2;
                            return 2;
                        }
                        L();
                    }
                }
                int X3 = X(true);
                if (X3 == 34) {
                    this.f25947w.readByte();
                    this.f25948x = 13;
                    return 13;
                }
                if (X3 == 39) {
                    this.f25947w.readByte();
                    L();
                    this.f25948x = 12;
                    return 12;
                }
                if (X3 != 125) {
                    L();
                    if (!T((char) X3)) {
                        throw K("Expected name");
                    }
                    this.f25948x = 14;
                    return 14;
                }
                if (i11 == 5) {
                    throw K("Expected name");
                }
                this.f25947w.readByte();
                this.f25948x = 2;
                return 2;
            }
            if (i11 == 4) {
                iArr[i10 - 1] = 5;
                int X4 = X(true);
                this.f25947w.readByte();
                if (X4 != 58) {
                    if (X4 != 61) {
                        throw K("Expected ':'");
                    }
                    L();
                    if (this.f25946v.m0(1L) && this.f25947w.p(0L) == 62) {
                        this.f25947w.readByte();
                    }
                }
            } else if (i11 == 6) {
                iArr[i10 - 1] = 7;
            } else if (i11 == 7) {
                if (X(false) == -1) {
                    this.f25948x = 18;
                    return 18;
                }
                L();
            } else if (i11 == 8) {
                throw new IllegalStateException("JsonReader is closed");
            }
        }
        int X5 = X(true);
        if (X5 == 34) {
            this.f25947w.readByte();
            this.f25948x = 9;
            return 9;
        }
        if (X5 == 39) {
            L();
            this.f25947w.readByte();
            this.f25948x = 8;
            return 8;
        }
        if (X5 != 44 && X5 != 59) {
            if (X5 == 91) {
                this.f25947w.readByte();
                this.f25948x = 3;
                return 3;
            }
            if (X5 != 93) {
                if (X5 == 123) {
                    this.f25947w.readByte();
                    this.f25948x = 1;
                    return 1;
                }
                int e02 = e0();
                if (e02 != 0) {
                    return e02;
                }
                int g02 = g0();
                if (g02 != 0) {
                    return g02;
                }
                if (!T(this.f25947w.p(0L))) {
                    throw K("Expected value");
                }
                L();
                this.f25948x = 10;
                return 10;
            }
            if (i11 == 1) {
                this.f25947w.readByte();
                this.f25948x = 4;
                return 4;
            }
        }
        if (i11 != 1 && i11 != 2) {
            throw K("Unexpected value");
        }
        L();
        this.f25948x = 7;
        return 7;
    }

    private int Q(String str, m.a aVar) {
        int length = aVar.f25944a.length;
        for (int i10 = 0; i10 < length; i10++) {
            if (str.equals(aVar.f25944a[i10])) {
                this.f25948x = 0;
                this.f25940r[this.f25938p - 1] = str;
                return i10;
            }
        }
        return -1;
    }

    private int S(String str, m.a aVar) {
        int length = aVar.f25944a.length;
        for (int i10 = 0; i10 < length; i10++) {
            if (str.equals(aVar.f25944a[i10])) {
                this.f25948x = 0;
                int[] iArr = this.f25941s;
                int i11 = this.f25938p - 1;
                iArr[i11] = iArr[i11] + 1;
                return i10;
            }
        }
        return -1;
    }

    private boolean T(int i10) {
        if (i10 == 9 || i10 == 10 || i10 == 12 || i10 == 13 || i10 == 32) {
            return false;
        }
        if (i10 != 35) {
            if (i10 == 44) {
                return false;
            }
            if (i10 != 47 && i10 != 61) {
                if (i10 == 123 || i10 == 125 || i10 == 58) {
                    return false;
                }
                if (i10 != 59) {
                    switch (i10) {
                        case 91:
                        case 93:
                            return false;
                        case 92:
                            break;
                        default:
                            return true;
                    }
                }
            }
        }
        L();
        return false;
    }

    /* JADX WARN: Code restructure failed: missing block: B:14:0x0025, code lost:
    
        r6.f25947w.skip(r3 - 1);
     */
    /* JADX WARN: Code restructure failed: missing block: B:15:0x002f, code lost:
    
        if (r1 != 47) goto L43;
     */
    /* JADX WARN: Code restructure failed: missing block: B:18:0x0076, code lost:
    
        if (r1 != 35) goto L48;
     */
    /* JADX WARN: Code restructure failed: missing block: B:19:0x0078, code lost:
    
        L();
        o0();
     */
    /* JADX WARN: Code restructure failed: missing block: B:23:0x007f, code lost:
    
        return r1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:27:0x0039, code lost:
    
        if (r6.f25946v.m0(2) != false) goto L20;
     */
    /* JADX WARN: Code restructure failed: missing block: B:28:0x003c, code lost:
    
        L();
        r3 = r6.f25947w.p(1);
     */
    /* JADX WARN: Code restructure failed: missing block: B:29:0x0049, code lost:
    
        if (r3 == 42) goto L40;
     */
    /* JADX WARN: Code restructure failed: missing block: B:31:0x005c, code lost:
    
        r6.f25947w.readByte();
        r6.f25947w.readByte();
     */
    /* JADX WARN: Code restructure failed: missing block: B:32:0x006a, code lost:
    
        if (n0() == false) goto L46;
     */
    /* JADX WARN: Code restructure failed: missing block: B:35:0x0073, code lost:
    
        throw K("Unterminated comment");
     */
    /* JADX WARN: Code restructure failed: missing block: B:38:0x004b, code lost:
    
        if (r3 == 47) goto L24;
     */
    /* JADX WARN: Code restructure failed: missing block: B:39:0x004e, code lost:
    
        r6.f25947w.readByte();
        r6.f25947w.readByte();
        o0();
     */
    /* JADX WARN: Code restructure failed: missing block: B:42:0x004d, code lost:
    
        return r1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:44:0x003b, code lost:
    
        return r1;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private int X(boolean z10) {
        while (true) {
            int i10 = 0;
            while (true) {
                int i11 = i10 + 1;
                if (!this.f25946v.m0(i11)) {
                    if (z10) {
                        throw new EOFException("End of input");
                    }
                    return -1;
                }
                byte p10 = this.f25947w.p(i10);
                if (p10 != 10 && p10 != 32 && p10 != 13 && p10 != 9) {
                    break;
                }
                i10 = i11;
            }
        }
    }

    private String Y(kr.g gVar) {
        StringBuilder sb2 = null;
        while (true) {
            long b02 = this.f25946v.b0(gVar);
            if (b02 == -1) {
                throw K("Unterminated string");
            }
            if (this.f25947w.p(b02) != 92) {
                if (sb2 == null) {
                    String S = this.f25947w.S(b02);
                    this.f25947w.readByte();
                    return S;
                }
                sb2.append(this.f25947w.S(b02));
                this.f25947w.readByte();
                return sb2.toString();
            }
            if (sb2 == null) {
                sb2 = new StringBuilder();
            }
            sb2.append(this.f25947w.S(b02));
            this.f25947w.readByte();
            sb2.append(j0());
        }
    }

    private String a0() {
        long b02 = this.f25946v.b0(D);
        kr.d dVar = this.f25947w;
        return b02 != -1 ? dVar.S(b02) : dVar.N();
    }

    private int e0() {
        String str;
        String str2;
        int i10;
        byte p10 = this.f25947w.p(0L);
        if (p10 == 116 || p10 == 84) {
            str = "true";
            str2 = "TRUE";
            i10 = 5;
        } else if (p10 == 102 || p10 == 70) {
            str = "false";
            str2 = "FALSE";
            i10 = 6;
        } else {
            if (p10 != 110 && p10 != 78) {
                return 0;
            }
            str = "null";
            str2 = "NULL";
            i10 = 7;
        }
        int length = str.length();
        int i11 = 1;
        while (i11 < length) {
            int i12 = i11 + 1;
            if (!this.f25946v.m0(i12)) {
                return 0;
            }
            byte p11 = this.f25947w.p(i11);
            if (p11 != str.charAt(i11) && p11 != str2.charAt(i11)) {
                return 0;
            }
            i11 = i12;
        }
        if (this.f25946v.m0(length + 1) && T(this.f25947w.p(length))) {
            return 0;
        }
        this.f25947w.skip(length);
        this.f25948x = i10;
        return i10;
    }

    /* JADX WARN: Code restructure failed: missing block: B:50:0x0081, code lost:
    
        if (T(r11) != false) goto L69;
     */
    /* JADX WARN: Code restructure failed: missing block: B:51:0x0083, code lost:
    
        if (r6 != 2) goto L60;
     */
    /* JADX WARN: Code restructure failed: missing block: B:52:0x0085, code lost:
    
        if (r7 == false) goto L60;
     */
    /* JADX WARN: Code restructure failed: missing block: B:54:0x008b, code lost:
    
        if (r8 != Long.MIN_VALUE) goto L52;
     */
    /* JADX WARN: Code restructure failed: missing block: B:55:0x008d, code lost:
    
        if (r10 == false) goto L60;
     */
    /* JADX WARN: Code restructure failed: missing block: B:57:0x0091, code lost:
    
        if (r8 != 0) goto L55;
     */
    /* JADX WARN: Code restructure failed: missing block: B:58:0x0093, code lost:
    
        if (r10 != false) goto L60;
     */
    /* JADX WARN: Code restructure failed: missing block: B:59:0x0095, code lost:
    
        if (r10 == false) goto L57;
     */
    /* JADX WARN: Code restructure failed: missing block: B:60:0x0098, code lost:
    
        r8 = -r8;
     */
    /* JADX WARN: Code restructure failed: missing block: B:61:0x0099, code lost:
    
        r16.f25949y = r8;
        r16.f25947w.skip(r5);
        r16.f25948x = 16;
     */
    /* JADX WARN: Code restructure failed: missing block: B:62:0x00a5, code lost:
    
        return 16;
     */
    /* JADX WARN: Code restructure failed: missing block: B:63:0x00a6, code lost:
    
        if (r6 == 2) goto L67;
     */
    /* JADX WARN: Code restructure failed: missing block: B:65:0x00a9, code lost:
    
        if (r6 == 4) goto L67;
     */
    /* JADX WARN: Code restructure failed: missing block: B:67:0x00ac, code lost:
    
        if (r6 != 7) goto L66;
     */
    /* JADX WARN: Code restructure failed: missing block: B:68:0x00af, code lost:
    
        return 0;
     */
    /* JADX WARN: Code restructure failed: missing block: B:69:0x00b0, code lost:
    
        r16.f25950z = r5;
        r16.f25948x = 17;
     */
    /* JADX WARN: Code restructure failed: missing block: B:70:0x00b6, code lost:
    
        return 17;
     */
    /* JADX WARN: Code restructure failed: missing block: B:71:0x00b7, code lost:
    
        return 0;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private int g0() {
        char c10;
        boolean z10 = true;
        long j10 = 0;
        int i10 = 0;
        char c11 = 0;
        boolean z11 = false;
        boolean z12 = true;
        while (true) {
            int i11 = i10 + 1;
            if (!this.f25946v.m0(i11)) {
                break;
            }
            byte p10 = this.f25947w.p(i10);
            if (p10 != 43) {
                if (p10 == 69 || p10 == 101) {
                    if (c11 != 2 && c11 != 4) {
                        return 0;
                    }
                    c11 = 5;
                } else if (p10 == 45) {
                    c10 = 6;
                    if (c11 == 0) {
                        c11 = 1;
                        z11 = true;
                    } else if (c11 != 5) {
                        return 0;
                    }
                } else if (p10 != 46) {
                    if (p10 < 48 || p10 > 57) {
                        break;
                    }
                    if (c11 == z10 || c11 == 0) {
                        j10 = -(p10 - 48);
                        c11 = 2;
                    } else if (c11 == 2) {
                        if (j10 == 0) {
                            return 0;
                        }
                        long j11 = (10 * j10) - (p10 - 48);
                        z12 &= j10 > -922337203685477580L || (j10 == -922337203685477580L && j11 < j10);
                        j10 = j11;
                    } else if (c11 == 3) {
                        c11 = 4;
                    } else if (c11 == 5 || c11 == 6) {
                        c11 = 7;
                    }
                } else {
                    if (c11 != 2) {
                        return 0;
                    }
                    c11 = 3;
                }
                i10 = i11;
                z10 = true;
            } else {
                c10 = 6;
                if (c11 != 5) {
                    return 0;
                }
            }
            c11 = c10;
            i10 = i11;
            z10 = true;
        }
    }

    private char j0() {
        int i10;
        int i11;
        if (!this.f25946v.m0(1L)) {
            throw K("Unterminated escape sequence");
        }
        byte readByte = this.f25947w.readByte();
        if (readByte == 10 || readByte == 34 || readByte == 39 || readByte == 47 || readByte == 92) {
            return (char) readByte;
        }
        if (readByte == 98) {
            return '\b';
        }
        if (readByte == 102) {
            return '\f';
        }
        if (readByte == 110) {
            return '\n';
        }
        if (readByte == 114) {
            return '\r';
        }
        if (readByte == 116) {
            return '\t';
        }
        if (readByte != 117) {
            if (this.f25942t) {
                return (char) readByte;
            }
            throw K("Invalid escape sequence: \\" + ((char) readByte));
        }
        if (!this.f25946v.m0(4L)) {
            throw new EOFException("Unterminated escape sequence at path " + getPath());
        }
        char c10 = 0;
        for (int i12 = 0; i12 < 4; i12++) {
            byte p10 = this.f25947w.p(i12);
            char c11 = (char) (c10 << 4);
            if (p10 < 48 || p10 > 57) {
                if (p10 >= 97 && p10 <= 102) {
                    i10 = p10 - 97;
                } else {
                    if (p10 < 65 || p10 > 70) {
                        throw K("\\u" + this.f25947w.S(4L));
                    }
                    i10 = p10 + ByteSourceJsonBootstrapper.UTF8_BOM_3;
                }
                i11 = i10 + 10;
            } else {
                i11 = p10 - 48;
            }
            c10 = (char) (c11 + i11);
        }
        this.f25947w.skip(4L);
        return c10;
    }

    private void k0(kr.g gVar) {
        while (true) {
            long b02 = this.f25946v.b0(gVar);
            if (b02 == -1) {
                throw K("Unterminated string");
            }
            if (this.f25947w.p(b02) != 92) {
                this.f25947w.skip(b02 + 1);
                return;
            } else {
                this.f25947w.skip(b02 + 1);
                j0();
            }
        }
    }

    private boolean n0() {
        long l02 = this.f25946v.l0(F);
        boolean z10 = l02 != -1;
        kr.d dVar = this.f25947w;
        dVar.skip(z10 ? l02 + r1.size() : dVar.X());
        return z10;
    }

    private void o0() {
        long b02 = this.f25946v.b0(E);
        kr.d dVar = this.f25947w;
        dVar.skip(b02 != -1 ? b02 + 1 : dVar.X());
    }

    private void p0() {
        long b02 = this.f25946v.b0(D);
        kr.d dVar = this.f25947w;
        if (b02 == -1) {
            b02 = dVar.X();
        }
        dVar.skip(b02);
    }

    @Override // km.m
    public int A(m.a aVar) {
        int i10 = this.f25948x;
        if (i10 == 0) {
            i10 = N();
        }
        if (i10 < 8 || i10 > 11) {
            return -1;
        }
        if (i10 == 11) {
            return S(this.A, aVar);
        }
        int M0 = this.f25946v.M0(aVar.f25945b);
        if (M0 != -1) {
            this.f25948x = 0;
            int[] iArr = this.f25941s;
            int i11 = this.f25938p - 1;
            iArr[i11] = iArr[i11] + 1;
            return M0;
        }
        String s10 = s();
        int S = S(s10, aVar);
        if (S == -1) {
            this.f25948x = 11;
            this.A = s10;
            this.f25941s[this.f25938p - 1] = r0[r4] - 1;
        }
        return S;
    }

    @Override // km.m
    public void I() {
        if (this.f25943u) {
            throw new j("Cannot skip unexpected " + v() + " at " + getPath());
        }
        int i10 = this.f25948x;
        if (i10 == 0) {
            i10 = N();
        }
        if (i10 == 14) {
            p0();
        } else if (i10 == 13) {
            k0(C);
        } else if (i10 == 12) {
            k0(B);
        } else if (i10 != 15) {
            throw new j("Expected a name but was " + v() + " at path " + getPath());
        }
        this.f25948x = 0;
        this.f25940r[this.f25938p - 1] = "null";
    }

    @Override // km.m
    public void J() {
        if (this.f25943u) {
            throw new j("Cannot skip unexpected " + v() + " at " + getPath());
        }
        int i10 = 0;
        do {
            int i11 = this.f25948x;
            if (i11 == 0) {
                i11 = N();
            }
            if (i11 == 3) {
                y(1);
            } else if (i11 == 1) {
                y(3);
            } else {
                if (i11 == 4) {
                    this.f25938p--;
                } else if (i11 == 2) {
                    this.f25938p--;
                } else {
                    if (i11 == 14 || i11 == 10) {
                        p0();
                    } else if (i11 == 9 || i11 == 13) {
                        k0(C);
                    } else if (i11 == 8 || i11 == 12) {
                        k0(B);
                    } else if (i11 == 17) {
                        this.f25947w.skip(this.f25950z);
                    }
                    this.f25948x = 0;
                }
                i10--;
                this.f25948x = 0;
            }
            i10++;
            this.f25948x = 0;
        } while (i10 != 0);
        int[] iArr = this.f25941s;
        int i12 = this.f25938p;
        int i13 = i12 - 1;
        iArr[i13] = iArr[i13] + 1;
        this.f25940r[i12 - 1] = "null";
    }

    public String V() {
        String str;
        int i10 = this.f25948x;
        if (i10 == 0) {
            i10 = N();
        }
        if (i10 == 14) {
            str = a0();
        } else if (i10 == 13) {
            str = Y(C);
        } else if (i10 == 12) {
            str = Y(B);
        } else {
            if (i10 != 15) {
                throw new j("Expected a name but was " + v() + " at path " + getPath());
            }
            str = this.A;
        }
        this.f25948x = 0;
        this.f25940r[this.f25938p - 1] = str;
        return str;
    }

    @Override // km.m
    public void a() {
        int i10 = this.f25948x;
        if (i10 == 0) {
            i10 = N();
        }
        if (i10 == 3) {
            y(1);
            this.f25941s[this.f25938p - 1] = 0;
            this.f25948x = 0;
        } else {
            throw new j("Expected BEGIN_ARRAY but was " + v() + " at path " + getPath());
        }
    }

    @Override // km.m
    public void b() {
        int i10 = this.f25948x;
        if (i10 == 0) {
            i10 = N();
        }
        if (i10 == 1) {
            y(3);
            this.f25948x = 0;
            return;
        }
        throw new j("Expected BEGIN_OBJECT but was " + v() + " at path " + getPath());
    }

    @Override // km.m
    public void c() {
        int i10 = this.f25948x;
        if (i10 == 0) {
            i10 = N();
        }
        if (i10 != 4) {
            throw new j("Expected END_ARRAY but was " + v() + " at path " + getPath());
        }
        int i11 = this.f25938p - 1;
        this.f25938p = i11;
        int[] iArr = this.f25941s;
        int i12 = i11 - 1;
        iArr[i12] = iArr[i12] + 1;
        this.f25948x = 0;
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public void close() {
        this.f25948x = 0;
        this.f25939q[0] = 8;
        this.f25938p = 1;
        this.f25947w.a();
        this.f25946v.close();
    }

    @Override // km.m
    public void d() {
        int i10 = this.f25948x;
        if (i10 == 0) {
            i10 = N();
        }
        if (i10 != 2) {
            throw new j("Expected END_OBJECT but was " + v() + " at path " + getPath());
        }
        int i11 = this.f25938p - 1;
        this.f25938p = i11;
        this.f25940r[i11] = null;
        int[] iArr = this.f25941s;
        int i12 = i11 - 1;
        iArr[i12] = iArr[i12] + 1;
        this.f25948x = 0;
    }

    @Override // km.m
    public boolean f() {
        int i10 = this.f25948x;
        if (i10 == 0) {
            i10 = N();
        }
        return (i10 == 2 || i10 == 4 || i10 == 18) ? false : true;
    }

    @Override // km.m
    public boolean h() {
        int i10 = this.f25948x;
        if (i10 == 0) {
            i10 = N();
        }
        if (i10 == 5) {
            this.f25948x = 0;
            int[] iArr = this.f25941s;
            int i11 = this.f25938p - 1;
            iArr[i11] = iArr[i11] + 1;
            return true;
        }
        if (i10 == 6) {
            this.f25948x = 0;
            int[] iArr2 = this.f25941s;
            int i12 = this.f25938p - 1;
            iArr2[i12] = iArr2[i12] + 1;
            return false;
        }
        throw new j("Expected a boolean but was " + v() + " at path " + getPath());
    }

    @Override // km.m
    public double j() {
        int i10 = this.f25948x;
        if (i10 == 0) {
            i10 = N();
        }
        if (i10 == 16) {
            this.f25948x = 0;
            int[] iArr = this.f25941s;
            int i11 = this.f25938p - 1;
            iArr[i11] = iArr[i11] + 1;
            return this.f25949y;
        }
        if (i10 == 17) {
            this.A = this.f25947w.S(this.f25950z);
        } else if (i10 == 9) {
            this.A = Y(C);
        } else if (i10 == 8) {
            this.A = Y(B);
        } else if (i10 == 10) {
            this.A = a0();
        } else if (i10 != 11) {
            throw new j("Expected a double but was " + v() + " at path " + getPath());
        }
        this.f25948x = 11;
        try {
            double parseDouble = Double.parseDouble(this.A);
            if (this.f25942t || !(Double.isNaN(parseDouble) || Double.isInfinite(parseDouble))) {
                this.A = null;
                this.f25948x = 0;
                int[] iArr2 = this.f25941s;
                int i12 = this.f25938p - 1;
                iArr2[i12] = iArr2[i12] + 1;
                return parseDouble;
            }
            throw new k("JSON forbids NaN and infinities: " + parseDouble + " at path " + getPath());
        } catch (NumberFormatException unused) {
            throw new j("Expected a double but was " + this.A + " at path " + getPath());
        }
    }

    @Override // km.m
    public int m() {
        int i10 = this.f25948x;
        if (i10 == 0) {
            i10 = N();
        }
        if (i10 == 16) {
            long j10 = this.f25949y;
            int i11 = (int) j10;
            if (j10 == i11) {
                this.f25948x = 0;
                int[] iArr = this.f25941s;
                int i12 = this.f25938p - 1;
                iArr[i12] = iArr[i12] + 1;
                return i11;
            }
            throw new j("Expected an int but was " + this.f25949y + " at path " + getPath());
        }
        if (i10 == 17) {
            this.A = this.f25947w.S(this.f25950z);
        } else if (i10 == 9 || i10 == 8) {
            String Y = i10 == 9 ? Y(C) : Y(B);
            this.A = Y;
            try {
                int parseInt = Integer.parseInt(Y);
                this.f25948x = 0;
                int[] iArr2 = this.f25941s;
                int i13 = this.f25938p - 1;
                iArr2[i13] = iArr2[i13] + 1;
                return parseInt;
            } catch (NumberFormatException unused) {
            }
        } else if (i10 != 11) {
            throw new j("Expected an int but was " + v() + " at path " + getPath());
        }
        this.f25948x = 11;
        try {
            double parseDouble = Double.parseDouble(this.A);
            int i14 = (int) parseDouble;
            if (i14 == parseDouble) {
                this.A = null;
                this.f25948x = 0;
                int[] iArr3 = this.f25941s;
                int i15 = this.f25938p - 1;
                iArr3[i15] = iArr3[i15] + 1;
                return i14;
            }
            throw new j("Expected an int but was " + this.A + " at path " + getPath());
        } catch (NumberFormatException unused2) {
            throw new j("Expected an int but was " + this.A + " at path " + getPath());
        }
    }

    @Override // km.m
    public long p() {
        int i10 = this.f25948x;
        if (i10 == 0) {
            i10 = N();
        }
        if (i10 == 16) {
            this.f25948x = 0;
            int[] iArr = this.f25941s;
            int i11 = this.f25938p - 1;
            iArr[i11] = iArr[i11] + 1;
            return this.f25949y;
        }
        if (i10 == 17) {
            this.A = this.f25947w.S(this.f25950z);
        } else if (i10 == 9 || i10 == 8) {
            String Y = i10 == 9 ? Y(C) : Y(B);
            this.A = Y;
            try {
                long parseLong = Long.parseLong(Y);
                this.f25948x = 0;
                int[] iArr2 = this.f25941s;
                int i12 = this.f25938p - 1;
                iArr2[i12] = iArr2[i12] + 1;
                return parseLong;
            } catch (NumberFormatException unused) {
            }
        } else if (i10 != 11) {
            throw new j("Expected a long but was " + v() + " at path " + getPath());
        }
        this.f25948x = 11;
        try {
            long longValueExact = new BigDecimal(this.A).longValueExact();
            this.A = null;
            this.f25948x = 0;
            int[] iArr3 = this.f25941s;
            int i13 = this.f25938p - 1;
            iArr3[i13] = iArr3[i13] + 1;
            return longValueExact;
        } catch (ArithmeticException | NumberFormatException unused2) {
            throw new j("Expected a long but was " + this.A + " at path " + getPath());
        }
    }

    @Override // km.m
    public Object r() {
        int i10 = this.f25948x;
        if (i10 == 0) {
            i10 = N();
        }
        if (i10 == 7) {
            this.f25948x = 0;
            int[] iArr = this.f25941s;
            int i11 = this.f25938p - 1;
            iArr[i11] = iArr[i11] + 1;
            return null;
        }
        throw new j("Expected null but was " + v() + " at path " + getPath());
    }

    @Override // km.m
    public String s() {
        String S;
        int i10 = this.f25948x;
        if (i10 == 0) {
            i10 = N();
        }
        if (i10 == 10) {
            S = a0();
        } else if (i10 == 9) {
            S = Y(C);
        } else if (i10 == 8) {
            S = Y(B);
        } else if (i10 == 11) {
            S = this.A;
            this.A = null;
        } else if (i10 == 16) {
            S = Long.toString(this.f25949y);
        } else {
            if (i10 != 17) {
                throw new j("Expected a string but was " + v() + " at path " + getPath());
            }
            S = this.f25947w.S(this.f25950z);
        }
        this.f25948x = 0;
        int[] iArr = this.f25941s;
        int i11 = this.f25938p - 1;
        iArr[i11] = iArr[i11] + 1;
        return S;
    }

    public String toString() {
        return "JsonReader(" + this.f25946v + ")";
    }

    @Override // km.m
    public m.b v() {
        int i10 = this.f25948x;
        if (i10 == 0) {
            i10 = N();
        }
        switch (i10) {
            case 1:
                return m.b.BEGIN_OBJECT;
            case 2:
                return m.b.END_OBJECT;
            case 3:
                return m.b.BEGIN_ARRAY;
            case 4:
                return m.b.END_ARRAY;
            case 5:
            case 6:
                return m.b.BOOLEAN;
            case 7:
                return m.b.NULL;
            case 8:
            case 9:
            case 10:
            case 11:
                return m.b.STRING;
            case 12:
            case 13:
            case 14:
            case 15:
                return m.b.NAME;
            case 16:
            case 17:
                return m.b.NUMBER;
            case 18:
                return m.b.END_DOCUMENT;
            default:
                throw new AssertionError();
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    @Override // km.m
    public void w() {
        if (f()) {
            this.A = V();
            this.f25948x = 11;
        }
    }

    @Override // km.m
    public int z(m.a aVar) {
        int i10 = this.f25948x;
        if (i10 == 0) {
            i10 = N();
        }
        if (i10 < 12 || i10 > 15) {
            return -1;
        }
        if (i10 == 15) {
            return Q(this.A, aVar);
        }
        int M0 = this.f25946v.M0(aVar.f25945b);
        if (M0 != -1) {
            this.f25948x = 0;
            this.f25940r[this.f25938p - 1] = aVar.f25944a[M0];
            return M0;
        }
        String str = this.f25940r[this.f25938p - 1];
        String V = V();
        int Q = Q(V, aVar);
        if (Q == -1) {
            this.f25948x = 15;
            this.A = V;
            this.f25940r[this.f25938p - 1] = str;
        }
        return Q;
    }
}
