package b.c.a.a0.i0; import androidx.annotation.Nullable; import b.c.a.a0.i0.c; import b.d.b.a.a; import g0.e; import g0.g; import java.io.EOFException; import java.io.IOException; import java.util.Objects; import okio.ByteString; /* compiled from: JsonUtf8Reader */ public final class d extends c { public static final ByteString o = ByteString.h("'\\"); public static final ByteString p = ByteString.h("\"\\"); public static final ByteString q = ByteString.h("{}[]:, \n\t\r\f/\\;#="); public static final ByteString r = ByteString.h("\n\r"); /* renamed from: s reason: collision with root package name */ public static final ByteString f330s = ByteString.h("*/"); public final g t; public final e u; public int v = 0; public long w; /* renamed from: x reason: collision with root package name */ public int f331x; @Nullable /* renamed from: y reason: collision with root package name */ public String f332y; public d(g gVar) { Objects.requireNonNull(gVar, "source == null"); this.t = gVar; this.u = gVar.g(); x(6); } @Override // b.c.a.a0.i0.c public void A() throws IOException { int i = this.v; if (i == 0) { i = I(); } if (i == 14) { U(); } else if (i == 13) { T(p); } else if (i == 12) { T(o); } else if (i != 15) { StringBuilder R = a.R("Expected a name but was "); R.append(u()); R.append(" at path "); R.append(getPath()); throw new a(R.toString()); } this.v = 0; this.m[this.k - 1] = "null"; } @Override // b.c.a.a0.i0.c public void C() throws IOException { int i = 0; do { int i2 = this.v; if (i2 == 0) { i2 = I(); } if (i2 == 3) { x(1); } else if (i2 == 1) { x(3); } else { if (i2 == 4) { i--; if (i >= 0) { this.k--; } else { StringBuilder R = a.R("Expected a value but was "); R.append(u()); R.append(" at path "); R.append(getPath()); throw new a(R.toString()); } } else if (i2 == 2) { i--; if (i >= 0) { this.k--; } else { StringBuilder R2 = a.R("Expected a value but was "); R2.append(u()); R2.append(" at path "); R2.append(getPath()); throw new a(R2.toString()); } } else if (i2 == 14 || i2 == 10) { U(); } else if (i2 == 9 || i2 == 13) { T(p); } else if (i2 == 8 || i2 == 12) { T(o); } else if (i2 == 17) { this.u.skip((long) this.f331x); } else if (i2 == 18) { StringBuilder R3 = a.R("Expected a value but was "); R3.append(u()); R3.append(" at path "); R3.append(getPath()); throw new a(R3.toString()); } this.v = 0; } i++; this.v = 0; } while (i != 0); int[] iArr = this.n; int i3 = this.k; int i4 = i3 - 1; iArr[i4] = iArr[i4] + 1; this.m[i3 - 1] = "null"; } public final void H() throws IOException { D("Use JsonReader.setLenient(true) to accept malformed JSON"); throw null; } /* JADX WARNING: Code restructure failed: missing block: B:121:0x01aa, code lost: if (L(r2) != false) goto L_0x0210; */ /* JADX WARNING: Code restructure failed: missing block: B:122:0x01ad, code lost: if (r1 != 2) goto L_0x01d3; */ /* JADX WARNING: Code restructure failed: missing block: B:123:0x01af, code lost: if (r6 == false) goto L_0x01d2; */ /* JADX WARNING: Code restructure failed: missing block: B:125:0x01b5, code lost: if (r7 != Long.MIN_VALUE) goto L_0x01b9; */ /* JADX WARNING: Code restructure failed: missing block: B:126:0x01b7, code lost: if (r9 == false) goto L_0x01d2; */ /* JADX WARNING: Code restructure failed: missing block: B:128:0x01bd, code lost: if (r7 != 0) goto L_0x01c1; */ /* JADX WARNING: Code restructure failed: missing block: B:129:0x01bf, code lost: if (r9 != false) goto L_0x01d2; */ /* JADX WARNING: Code restructure failed: missing block: B:130:0x01c1, code lost: if (r9 == false) goto L_0x01c4; */ /* JADX WARNING: Code restructure failed: missing block: B:131:0x01c4, code lost: r7 = -r7; */ /* JADX WARNING: Code restructure failed: missing block: B:132:0x01c5, code lost: r17.w = r7; r17.u.skip((long) r5); r15 = 16; r17.v = 16; */ /* JADX WARNING: Code restructure failed: missing block: B:133:0x01d2, code lost: r2 = 2; */ /* JADX WARNING: Code restructure failed: missing block: B:134:0x01d3, code lost: if (r1 == r2) goto L_0x01db; */ /* JADX WARNING: Code restructure failed: missing block: B:136:0x01d6, code lost: if (r1 == 4) goto L_0x01db; */ /* JADX WARNING: Code restructure failed: missing block: B:138:0x01d9, code lost: if (r1 != 7) goto L_0x0210; */ /* JADX WARNING: Code restructure failed: missing block: B:139:0x01db, code lost: r17.f331x = r5; r15 = 17; r17.v = 17; */ /* JADX WARNING: Code restructure failed: missing block: B:82:0x0133, code lost: r2 = 2; */ /* JADX WARNING: Removed duplicated region for block: B:78:0x0122 A[RETURN] */ /* JADX WARNING: Removed duplicated region for block: B:79:0x0123 */ public final int I() throws IOException { int i; int i2; String str; String str2; byte q2; int[] iArr = this.l; int i3 = this.k; int i4 = iArr[i3 - 1]; if (i4 == 1) { iArr[i3 - 1] = 2; } else if (i4 == 2) { int N = N(true); this.u.readByte(); if (N != 44) { if (N == 59) { H(); throw null; } else if (N == 93) { this.v = 4; return 4; } else { D("Unterminated array"); throw null; } } } else if (i4 == 3 || i4 == 5) { iArr[i3 - 1] = 4; if (i4 == 5) { int N2 = N(true); this.u.readByte(); if (N2 != 44) { if (N2 == 59) { H(); throw null; } else if (N2 == 125) { this.v = 2; return 2; } else { D("Unterminated object"); throw null; } } } int N3 = N(true); if (N3 == 34) { this.u.readByte(); this.v = 13; return 13; } else if (N3 == 39) { this.u.readByte(); H(); throw null; } else if (N3 != 125) { H(); throw null; } else if (i4 != 5) { this.u.readByte(); this.v = 2; return 2; } else { D("Expected name"); throw null; } } else if (i4 == 4) { iArr[i3 - 1] = 5; int N4 = N(true); this.u.readByte(); if (N4 != 58) { if (N4 != 61) { D("Expected ':'"); throw null; } H(); throw null; } } else if (i4 == 6) { iArr[i3 - 1] = 7; } else if (i4 == 7) { if (N(false) == -1) { this.v = 18; return 18; } H(); throw null; } else if (i4 == 8) { throw new IllegalStateException("JsonReader is closed"); } int N5 = N(true); if (N5 == 34) { this.u.readByte(); this.v = 9; return 9; } else if (N5 != 39) { if (!(N5 == 44 || N5 == 59)) { if (N5 == 91) { this.u.readByte(); this.v = 3; return 3; } else if (N5 != 93) { if (N5 != 123) { byte q3 = this.u.q(0); if (q3 == 116 || q3 == 84) { str2 = "true"; str = "TRUE"; i = 5; } else if (q3 == 102 || q3 == 70) { str2 = "false"; str = "FALSE"; i = 6; } else { if (q3 == 110 || q3 == 78) { str2 = "null"; str = "NULL"; i = 7; } i = 0; if (i == 0) { return i; } long j = 0; char c = 0; int i5 = 0; boolean z2 = true; boolean z3 = false; while (true) { int i6 = i5 + 1; if (!this.t.j((long) i6)) { break; } byte q4 = this.u.q((long) i5); if (q4 != 43) { if (q4 != 69 && q4 != 101) { if (q4 != 45) { if (q4 == 46) { i2 = i6; if (c != 2) { break; } c = 3; i5 = i2; } else if (q4 < 48 || q4 > 57) { break; } else { if (c == 1 || c == 0) { i2 = i6; j = (long) (-(q4 - 48)); c = 2; } else if (c != 2) { i2 = i6; if (c == 3) { c = 4; i5 = i2; } else if (c == 5 || c == 6) { c = 7; } } else if (j == 0) { break; } else { i2 = i6; long j2 = (10 * j) - ((long) (q4 - 48)); int i7 = (j > -922337203685477580L ? 1 : (j == -922337203685477580L ? 0 : -1)); z2 = (i7 > 0 || (i7 == 0 && j2 < j)) & z2; j = j2; } i5 = i2; } } else { i2 = i6; if (c != 0) { if (c != 5) { break; } } else { c = 1; z3 = true; i5 = i2; } } } else { i2 = i6; if (c != 2 && c != 4) { break; } c = 5; i5 = i2; } } else { i2 = i6; if (c != 5) { break; } } c = 6; i5 = i2; } int i8 = 0; if (i8 != 0) { return i8; } if (!L(this.u.q(0))) { D("Expected value"); throw null; } H(); throw null; } int length = str2.length(); int i9 = 1; while (true) { if (i9 < length) { int i10 = i9 + 1; if (!this.t.j((long) i10) || ((q2 = this.u.q((long) i9)) != str2.charAt(i9) && q2 != str.charAt(i9))) { break; } i9 = i10; } else if (!this.t.j((long) (length + 1)) || !L(this.u.q((long) length))) { this.u.skip((long) length); this.v = i; } } i = 0; if (i == 0) { } } else { this.u.readByte(); this.v = 1; return 1; } } else if (i4 == 1) { this.u.readByte(); this.v = 4; return 4; } } if (i4 == 1 || i4 == 2) { H(); throw null; } D("Unexpected value"); throw null; } else { H(); throw null; } } public final int J(String str, c.a aVar) { int length = aVar.a.length; for (int i = 0; i < length; i++) { if (str.equals(aVar.a[i])) { this.v = 0; this.m[this.k - 1] = str; return i; } } return -1; } public final boolean L(int i) throws IOException { if (i == 9 || i == 10 || i == 12 || i == 13 || i == 32) { return false; } if (i != 35) { if (i == 44) { return false; } if (!(i == 47 || i == 61)) { if (i == 123 || i == 125 || i == 58) { return false; } if (i != 59) { switch (i) { case 91: case 93: return false; case 92: break; default: return true; } } } } H(); throw null; } public final int N(boolean z2) throws IOException { int i = 0; while (true) { int i2 = i + 1; if (this.t.j((long) i2)) { byte q2 = this.u.q((long) i); if (q2 == 10 || q2 == 32 || q2 == 13 || q2 == 9) { i = i2; } else { this.u.skip((long) (i2 - 1)); if (q2 == 47) { if (!this.t.j(2)) { return q2; } H(); throw null; } else if (q2 != 35) { return q2; } else { H(); throw null; } } } else if (!z2) { return -1; } else { throw new EOFException("End of input"); } } } public final String O(ByteString byteString) throws IOException { StringBuilder sb = null; while (true) { long E = this.t.E(byteString); if (E == -1) { D("Unterminated string"); throw null; } else if (this.u.q(E) == 92) { if (sb == null) { sb = new StringBuilder(); } sb.append(this.u.H(E)); this.u.readByte(); sb.append(S()); } else if (sb == null) { String H = this.u.H(E); this.u.readByte(); return H; } else { sb.append(this.u.H(E)); this.u.readByte(); return sb.toString(); } } } public final String R() throws IOException { long E = this.t.E(q); return E != -1 ? this.u.H(E) : this.u.D(); } public final char S() throws IOException { int i; int i2; if (this.t.j(1)) { byte readByte = this.u.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) { StringBuilder R = a.R("Invalid escape sequence: \\"); R.append((char) readByte); D(R.toString()); throw null; } else if (this.t.j(4)) { char c = 0; for (int i3 = 0; i3 < 4; i3++) { byte q2 = this.u.q((long) i3); char c2 = (char) (c << 4); if (q2 < 48 || q2 > 57) { if (q2 >= 97 && q2 <= 102) { i2 = q2 - 97; } else if (q2 < 65 || q2 > 70) { StringBuilder R2 = a.R("\\u"); R2.append(this.u.H(4)); D(R2.toString()); throw null; } else { i2 = q2 - 65; } i = i2 + 10; } else { i = q2 - 48; } c = (char) (i + c2); } this.u.skip(4); return c; } else { StringBuilder R3 = a.R("Unterminated escape sequence at path "); R3.append(getPath()); throw new EOFException(R3.toString()); } } else { D("Unterminated escape sequence"); throw null; } } public final void T(ByteString byteString) throws IOException { while (true) { long E = this.t.E(byteString); if (E == -1) { D("Unterminated string"); throw null; } else if (this.u.q(E) == 92) { this.u.skip(E + 1); S(); } else { this.u.skip(E + 1); return; } } } public final void U() throws IOException { long E = this.t.E(q); e eVar = this.u; if (E == -1) { E = eVar.k; } eVar.skip(E); } @Override // b.c.a.a0.i0.c public void a() throws IOException { int i = this.v; if (i == 0) { i = I(); } if (i == 3) { x(1); this.n[this.k - 1] = 0; this.v = 0; return; } StringBuilder R = a.R("Expected BEGIN_ARRAY but was "); R.append(u()); R.append(" at path "); R.append(getPath()); throw new a(R.toString()); } @Override // b.c.a.a0.i0.c public void b() throws IOException { int i = this.v; if (i == 0) { i = I(); } if (i == 1) { x(3); this.v = 0; return; } StringBuilder R = a.R("Expected BEGIN_OBJECT but was "); R.append(u()); R.append(" at path "); R.append(getPath()); throw new a(R.toString()); } @Override // b.c.a.a0.i0.c public void c() throws IOException { int i = this.v; if (i == 0) { i = I(); } if (i == 4) { int i2 = this.k - 1; this.k = i2; int[] iArr = this.n; int i3 = i2 - 1; iArr[i3] = iArr[i3] + 1; this.v = 0; return; } StringBuilder R = a.R("Expected END_ARRAY but was "); R.append(u()); R.append(" at path "); R.append(getPath()); throw new a(R.toString()); } @Override // java.io.Closeable, java.lang.AutoCloseable public void close() throws IOException { this.v = 0; this.l[0] = 8; this.k = 1; e eVar = this.u; eVar.skip(eVar.k); this.t.close(); } @Override // b.c.a.a0.i0.c public void d() throws IOException { int i = this.v; if (i == 0) { i = I(); } if (i == 2) { int i2 = this.k - 1; this.k = i2; this.m[i2] = null; int[] iArr = this.n; int i3 = i2 - 1; iArr[i3] = iArr[i3] + 1; this.v = 0; return; } StringBuilder R = a.R("Expected END_OBJECT but was "); R.append(u()); R.append(" at path "); R.append(getPath()); throw new a(R.toString()); } @Override // b.c.a.a0.i0.c public boolean e() throws IOException { int i = this.v; if (i == 0) { i = I(); } return (i == 2 || i == 4 || i == 18) ? false : true; } @Override // b.c.a.a0.i0.c public boolean f() throws IOException { int i = this.v; if (i == 0) { i = I(); } if (i == 5) { this.v = 0; int[] iArr = this.n; int i2 = this.k - 1; iArr[i2] = iArr[i2] + 1; return true; } else if (i == 6) { this.v = 0; int[] iArr2 = this.n; int i3 = this.k - 1; iArr2[i3] = iArr2[i3] + 1; return false; } else { StringBuilder R = a.R("Expected a boolean but was "); R.append(u()); R.append(" at path "); R.append(getPath()); throw new a(R.toString()); } } @Override // b.c.a.a0.i0.c public double n() throws IOException { int i = this.v; if (i == 0) { i = I(); } if (i == 16) { this.v = 0; int[] iArr = this.n; int i2 = this.k - 1; iArr[i2] = iArr[i2] + 1; return (double) this.w; } if (i == 17) { this.f332y = this.u.H((long) this.f331x); } else if (i == 9) { this.f332y = O(p); } else if (i == 8) { this.f332y = O(o); } else if (i == 10) { this.f332y = R(); } else if (i != 11) { StringBuilder R = a.R("Expected a double but was "); R.append(u()); R.append(" at path "); R.append(getPath()); throw new a(R.toString()); } this.v = 11; try { double parseDouble = Double.parseDouble(this.f332y); if (Double.isNaN(parseDouble) || Double.isInfinite(parseDouble)) { throw new b("JSON forbids NaN and infinities: " + parseDouble + " at path " + getPath()); } this.f332y = null; this.v = 0; int[] iArr2 = this.n; int i3 = this.k - 1; iArr2[i3] = iArr2[i3] + 1; return parseDouble; } catch (NumberFormatException unused) { StringBuilder R2 = a.R("Expected a double but was "); R2.append(this.f332y); R2.append(" at path "); R2.append(getPath()); throw new a(R2.toString()); } } @Override // b.c.a.a0.i0.c public int q() throws IOException { int i = this.v; if (i == 0) { i = I(); } if (i == 16) { long j = this.w; int i2 = (int) j; if (j == ((long) i2)) { this.v = 0; int[] iArr = this.n; int i3 = this.k - 1; iArr[i3] = iArr[i3] + 1; return i2; } StringBuilder R = a.R("Expected an int but was "); R.append(this.w); R.append(" at path "); R.append(getPath()); throw new a(R.toString()); } if (i == 17) { this.f332y = this.u.H((long) this.f331x); } else if (i == 9 || i == 8) { String O = i == 9 ? O(p) : O(o); this.f332y = O; try { int parseInt = Integer.parseInt(O); this.v = 0; int[] iArr2 = this.n; int i4 = this.k - 1; iArr2[i4] = iArr2[i4] + 1; return parseInt; } catch (NumberFormatException unused) { } } else if (i != 11) { StringBuilder R2 = a.R("Expected an int but was "); R2.append(u()); R2.append(" at path "); R2.append(getPath()); throw new a(R2.toString()); } this.v = 11; try { double parseDouble = Double.parseDouble(this.f332y); int i5 = (int) parseDouble; if (((double) i5) == parseDouble) { this.f332y = null; this.v = 0; int[] iArr3 = this.n; int i6 = this.k - 1; iArr3[i6] = iArr3[i6] + 1; return i5; } StringBuilder R3 = a.R("Expected an int but was "); R3.append(this.f332y); R3.append(" at path "); R3.append(getPath()); throw new a(R3.toString()); } catch (NumberFormatException unused2) { StringBuilder R4 = a.R("Expected an int but was "); R4.append(this.f332y); R4.append(" at path "); R4.append(getPath()); throw new a(R4.toString()); } } @Override // b.c.a.a0.i0.c public String s() throws IOException { String str; int i = this.v; if (i == 0) { i = I(); } if (i == 14) { str = R(); } else if (i == 13) { str = O(p); } else if (i == 12) { str = O(o); } else if (i == 15) { str = this.f332y; } else { StringBuilder R = a.R("Expected a name but was "); R.append(u()); R.append(" at path "); R.append(getPath()); throw new a(R.toString()); } this.v = 0; this.m[this.k - 1] = str; return str; } @Override // b.c.a.a0.i0.c public String t() throws IOException { String str; int i = this.v; if (i == 0) { i = I(); } if (i == 10) { str = R(); } else if (i == 9) { str = O(p); } else if (i == 8) { str = O(o); } else if (i == 11) { str = this.f332y; this.f332y = null; } else if (i == 16) { str = Long.toString(this.w); } else if (i == 17) { str = this.u.H((long) this.f331x); } else { StringBuilder R = a.R("Expected a string but was "); R.append(u()); R.append(" at path "); R.append(getPath()); throw new a(R.toString()); } this.v = 0; int[] iArr = this.n; int i2 = this.k - 1; iArr[i2] = iArr[i2] + 1; return str; } @Override // java.lang.Object public String toString() { StringBuilder R = a.R("JsonReader("); R.append(this.t); R.append(")"); return R.toString(); } @Override // b.c.a.a0.i0.c public c.b u() throws IOException { int i = this.v; if (i == 0) { i = I(); } switch (i) { case 1: return c.b.BEGIN_OBJECT; case 2: return c.b.END_OBJECT; case 3: return c.b.BEGIN_ARRAY; case 4: return c.b.END_ARRAY; case 5: case 6: return c.b.BOOLEAN; case 7: return c.b.NULL; case 8: case 9: case 10: case 11: return c.b.STRING; case 12: case 13: case 14: case 15: return c.b.NAME; case 16: case 17: return c.b.NUMBER; case 18: return c.b.END_DOCUMENT; default: throw new AssertionError(); } } @Override // b.c.a.a0.i0.c public int y(c.a aVar) throws IOException { int i = this.v; if (i == 0) { i = I(); } if (i < 12 || i > 15) { return -1; } if (i == 15) { return J(this.f332y, aVar); } int v0 = this.t.v0(aVar.f328b); if (v0 != -1) { this.v = 0; this.m[this.k - 1] = aVar.a[v0]; return v0; } String str = this.m[this.k - 1]; String s2 = s(); int J = J(s2, aVar); if (J == -1) { this.v = 15; this.f332y = s2; this.m[this.k - 1] = str; } return J; } }