package c.c.a.a0.h0; import androidx.annotation.Nullable; import c.c.a.a0.h0.c; import c.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 n = ByteString.h("'\\"); public static final ByteString o = ByteString.h("\"\\"); public static final ByteString p = ByteString.h("{}[]:, \n\t\r\f/\\;#="); public static final ByteString q = ByteString.h("\n\r"); public static final ByteString r = ByteString.h("*/"); /* renamed from: s reason: collision with root package name */ public final g f251s; public final e t; public int u = 0; public long v; public int w; @Nullable /* renamed from: x reason: collision with root package name */ public String f252x; public d(g gVar) { Objects.requireNonNull(gVar, "source == null"); this.f251s = gVar; this.t = gVar.g(); x(6); } @Override // c.c.a.a0.h0.c public void B() throws IOException { int i = this.u; if (i == 0) { i = I(); } if (i == 14) { U(); } else if (i == 13) { T(o); } else if (i == 12) { T(n); } else if (i != 15) { StringBuilder K = a.K("Expected a name but was "); K.append(w()); K.append(" at path "); K.append(getPath()); throw new a(K.toString()); } this.u = 0; this.l[this.j - 1] = "null"; } @Override // c.c.a.a0.h0.c public void C() throws IOException { int i = 0; do { int i2 = this.u; 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.j--; } else { StringBuilder K = a.K("Expected a value but was "); K.append(w()); K.append(" at path "); K.append(getPath()); throw new a(K.toString()); } } else if (i2 == 2) { i--; if (i >= 0) { this.j--; } else { StringBuilder K2 = a.K("Expected a value but was "); K2.append(w()); K2.append(" at path "); K2.append(getPath()); throw new a(K2.toString()); } } else if (i2 == 14 || i2 == 10) { U(); } else if (i2 == 9 || i2 == 13) { T(o); } else if (i2 == 8 || i2 == 12) { T(n); } else if (i2 == 17) { this.t.skip((long) this.w); } else if (i2 == 18) { StringBuilder K3 = a.K("Expected a value but was "); K3.append(w()); K3.append(" at path "); K3.append(getPath()); throw new a(K3.toString()); } this.u = 0; } i++; this.u = 0; } while (i != 0); int[] iArr = this.m; int i3 = this.j; int i4 = i3 - 1; iArr[i4] = iArr[i4] + 1; this.l[i3 - 1] = "null"; } public final void H() throws IOException { G("Use JsonReader.setLenient(true) to accept malformed JSON"); throw null; } /* JADX WARNING: Code restructure failed: missing block: B:121:0x01aa, code lost: if (M(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.v = r7; r17.t.skip((long) r5); r15 = 16; r17.u = 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.w = r5; r15 = 17; r17.u = 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 r2; int[] iArr = this.k; int i3 = this.j; int i4 = iArr[i3 - 1]; if (i4 == 1) { iArr[i3 - 1] = 2; } else if (i4 == 2) { int N = N(true); this.t.readByte(); if (N != 44) { if (N == 59) { H(); throw null; } else if (N == 93) { this.u = 4; return 4; } else { G("Unterminated array"); throw null; } } } else if (i4 == 3 || i4 == 5) { iArr[i3 - 1] = 4; if (i4 == 5) { int N2 = N(true); this.t.readByte(); if (N2 != 44) { if (N2 == 59) { H(); throw null; } else if (N2 == 125) { this.u = 2; return 2; } else { G("Unterminated object"); throw null; } } } int N3 = N(true); if (N3 == 34) { this.t.readByte(); this.u = 13; return 13; } else if (N3 == 39) { this.t.readByte(); H(); throw null; } else if (N3 != 125) { H(); throw null; } else if (i4 != 5) { this.t.readByte(); this.u = 2; return 2; } else { G("Expected name"); throw null; } } else if (i4 == 4) { iArr[i3 - 1] = 5; int N4 = N(true); this.t.readByte(); if (N4 != 58) { if (N4 != 61) { G("Expected ':'"); throw null; } H(); throw null; } } else if (i4 == 6) { iArr[i3 - 1] = 7; } else if (i4 == 7) { if (N(false) == -1) { this.u = 18; return 18; } H(); throw null; } else if (i4 == 8) { throw new IllegalStateException("JsonReader is closed"); } int N5 = N(true); if (N5 == 34) { this.t.readByte(); this.u = 9; return 9; } else if (N5 != 39) { if (!(N5 == 44 || N5 == 59)) { if (N5 == 91) { this.t.readByte(); this.u = 3; return 3; } else if (N5 != 93) { if (N5 != 123) { byte r3 = this.t.r(0); if (r3 == 116 || r3 == 84) { str2 = "true"; str = "TRUE"; i = 5; } else if (r3 == 102 || r3 == 70) { str2 = "false"; str = "FALSE"; i = 6; } else { if (r3 == 110 || r3 == 78) { str2 = "null"; str = "NULL"; i = 7; } i = 0; if (i == 0) { return i; } long j = 0; char c2 = 0; int i5 = 0; boolean z2 = true; boolean z3 = false; while (true) { int i6 = i5 + 1; if (!this.f251s.j((long) i6)) { break; } byte r4 = this.t.r((long) i5); if (r4 != 43) { if (r4 != 69 && r4 != 101) { if (r4 != 45) { if (r4 == 46) { i2 = i6; if (c2 != 2) { break; } c2 = 3; i5 = i2; } else if (r4 < 48 || r4 > 57) { break; } else { if (c2 == 1 || c2 == 0) { i2 = i6; j = (long) (-(r4 - 48)); c2 = 2; } else if (c2 != 2) { i2 = i6; if (c2 == 3) { c2 = 4; i5 = i2; } else if (c2 == 5 || c2 == 6) { c2 = 7; } } else if (j == 0) { break; } else { i2 = i6; long j2 = (10 * j) - ((long) (r4 - 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 (c2 != 0) { if (c2 != 5) { break; } } else { c2 = 1; z3 = true; i5 = i2; } } } else { i2 = i6; if (c2 != 2 && c2 != 4) { break; } c2 = 5; i5 = i2; } } else { i2 = i6; if (c2 != 5) { break; } } c2 = 6; i5 = i2; } int i8 = 0; if (i8 != 0) { return i8; } if (!M(this.t.r(0))) { G("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.f251s.j((long) i10) || ((r2 = this.t.r((long) i9)) != str2.charAt(i9) && r2 != str.charAt(i9))) { break; } i9 = i10; } else if (!this.f251s.j((long) (length + 1)) || !M(this.t.r((long) length))) { this.t.skip((long) length); this.u = i; } } i = 0; if (i == 0) { } } else { this.t.readByte(); this.u = 1; return 1; } } else if (i4 == 1) { this.t.readByte(); this.u = 4; return 4; } } if (i4 == 1 || i4 == 2) { H(); throw null; } G("Unexpected value"); throw null; } else { H(); throw null; } } public final int K(String str, c.a aVar) { int length = aVar.a.length; for (int i = 0; i < length; i++) { if (str.equals(aVar.a[i])) { this.u = 0; this.l[this.j - 1] = str; return i; } } return -1; } public final boolean M(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.f251s.j((long) i2)) { byte r2 = this.t.r((long) i); if (r2 == 10 || r2 == 32 || r2 == 13 || r2 == 9) { i = i2; } else { this.t.skip((long) (i2 - 1)); if (r2 == 47) { if (!this.f251s.j(2)) { return r2; } H(); throw null; } else if (r2 != 35) { return r2; } else { H(); throw null; } } } else if (!z2) { return -1; } else { throw new EOFException("End of input"); } } } public final String Q(ByteString byteString) throws IOException { StringBuilder sb = null; while (true) { long D = this.f251s.D(byteString); if (D == -1) { G("Unterminated string"); throw null; } else if (this.t.r(D) == 92) { if (sb == null) { sb = new StringBuilder(); } sb.append(this.t.H(D)); this.t.readByte(); sb.append(S()); } else if (sb == null) { String H = this.t.H(D); this.t.readByte(); return H; } else { sb.append(this.t.H(D)); this.t.readByte(); return sb.toString(); } } } public final String R() throws IOException { long D = this.f251s.D(p); return D != -1 ? this.t.H(D) : this.t.G(); } public final char S() throws IOException { int i; int i2; if (this.f251s.j(1)) { byte readByte = this.t.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 K = a.K("Invalid escape sequence: \\"); K.append((char) readByte); G(K.toString()); throw null; } else if (this.f251s.j(4)) { char c2 = 0; for (int i3 = 0; i3 < 4; i3++) { byte r2 = this.t.r((long) i3); char c3 = (char) (c2 << 4); if (r2 < 48 || r2 > 57) { if (r2 >= 97 && r2 <= 102) { i2 = r2 - 97; } else if (r2 < 65 || r2 > 70) { StringBuilder K2 = a.K("\\u"); K2.append(this.t.H(4)); G(K2.toString()); throw null; } else { i2 = r2 - 65; } i = i2 + 10; } else { i = r2 - 48; } c2 = (char) (i + c3); } this.t.skip(4); return c2; } else { StringBuilder K3 = a.K("Unterminated escape sequence at path "); K3.append(getPath()); throw new EOFException(K3.toString()); } } else { G("Unterminated escape sequence"); throw null; } } public final void T(ByteString byteString) throws IOException { while (true) { long D = this.f251s.D(byteString); if (D == -1) { G("Unterminated string"); throw null; } else if (this.t.r(D) == 92) { this.t.skip(D + 1); S(); } else { this.t.skip(D + 1); return; } } } public final void U() throws IOException { long D = this.f251s.D(p); e eVar = this.t; if (D == -1) { D = eVar.j; } eVar.skip(D); } @Override // c.c.a.a0.h0.c public void a() throws IOException { int i = this.u; if (i == 0) { i = I(); } if (i == 3) { x(1); this.m[this.j - 1] = 0; this.u = 0; return; } StringBuilder K = a.K("Expected BEGIN_ARRAY but was "); K.append(w()); K.append(" at path "); K.append(getPath()); throw new a(K.toString()); } @Override // c.c.a.a0.h0.c public void b() throws IOException { int i = this.u; if (i == 0) { i = I(); } if (i == 1) { x(3); this.u = 0; return; } StringBuilder K = a.K("Expected BEGIN_OBJECT but was "); K.append(w()); K.append(" at path "); K.append(getPath()); throw new a(K.toString()); } @Override // c.c.a.a0.h0.c public void c() throws IOException { int i = this.u; if (i == 0) { i = I(); } if (i == 4) { int i2 = this.j - 1; this.j = i2; int[] iArr = this.m; int i3 = i2 - 1; iArr[i3] = iArr[i3] + 1; this.u = 0; return; } StringBuilder K = a.K("Expected END_ARRAY but was "); K.append(w()); K.append(" at path "); K.append(getPath()); throw new a(K.toString()); } @Override // java.io.Closeable, java.lang.AutoCloseable public void close() throws IOException { this.u = 0; this.k[0] = 8; this.j = 1; e eVar = this.t; eVar.skip(eVar.j); this.f251s.close(); } @Override // c.c.a.a0.h0.c public void d() throws IOException { int i = this.u; if (i == 0) { i = I(); } if (i == 2) { int i2 = this.j - 1; this.j = i2; this.l[i2] = null; int[] iArr = this.m; int i3 = i2 - 1; iArr[i3] = iArr[i3] + 1; this.u = 0; return; } StringBuilder K = a.K("Expected END_OBJECT but was "); K.append(w()); K.append(" at path "); K.append(getPath()); throw new a(K.toString()); } @Override // c.c.a.a0.h0.c public boolean e() throws IOException { int i = this.u; if (i == 0) { i = I(); } return (i == 2 || i == 4 || i == 18) ? false : true; } @Override // c.c.a.a0.h0.c public boolean f() throws IOException { int i = this.u; if (i == 0) { i = I(); } if (i == 5) { this.u = 0; int[] iArr = this.m; int i2 = this.j - 1; iArr[i2] = iArr[i2] + 1; return true; } else if (i == 6) { this.u = 0; int[] iArr2 = this.m; int i3 = this.j - 1; iArr2[i3] = iArr2[i3] + 1; return false; } else { StringBuilder K = a.K("Expected a boolean but was "); K.append(w()); K.append(" at path "); K.append(getPath()); throw new a(K.toString()); } } @Override // c.c.a.a0.h0.c public double p() throws IOException { int i = this.u; if (i == 0) { i = I(); } if (i == 16) { this.u = 0; int[] iArr = this.m; int i2 = this.j - 1; iArr[i2] = iArr[i2] + 1; return (double) this.v; } if (i == 17) { this.f252x = this.t.H((long) this.w); } else if (i == 9) { this.f252x = Q(o); } else if (i == 8) { this.f252x = Q(n); } else if (i == 10) { this.f252x = R(); } else if (i != 11) { StringBuilder K = a.K("Expected a double but was "); K.append(w()); K.append(" at path "); K.append(getPath()); throw new a(K.toString()); } this.u = 11; try { double parseDouble = Double.parseDouble(this.f252x); if (Double.isNaN(parseDouble) || Double.isInfinite(parseDouble)) { throw new b("JSON forbids NaN and infinities: " + parseDouble + " at path " + getPath()); } this.f252x = null; this.u = 0; int[] iArr2 = this.m; int i3 = this.j - 1; iArr2[i3] = iArr2[i3] + 1; return parseDouble; } catch (NumberFormatException unused) { StringBuilder K2 = a.K("Expected a double but was "); K2.append(this.f252x); K2.append(" at path "); K2.append(getPath()); throw new a(K2.toString()); } } @Override // c.c.a.a0.h0.c public int r() throws IOException { int i = this.u; if (i == 0) { i = I(); } if (i == 16) { long j = this.v; int i2 = (int) j; if (j == ((long) i2)) { this.u = 0; int[] iArr = this.m; int i3 = this.j - 1; iArr[i3] = iArr[i3] + 1; return i2; } StringBuilder K = a.K("Expected an int but was "); K.append(this.v); K.append(" at path "); K.append(getPath()); throw new a(K.toString()); } if (i == 17) { this.f252x = this.t.H((long) this.w); } else if (i == 9 || i == 8) { String Q = i == 9 ? Q(o) : Q(n); this.f252x = Q; try { int parseInt = Integer.parseInt(Q); this.u = 0; int[] iArr2 = this.m; int i4 = this.j - 1; iArr2[i4] = iArr2[i4] + 1; return parseInt; } catch (NumberFormatException unused) { } } else if (i != 11) { StringBuilder K2 = a.K("Expected an int but was "); K2.append(w()); K2.append(" at path "); K2.append(getPath()); throw new a(K2.toString()); } this.u = 11; try { double parseDouble = Double.parseDouble(this.f252x); int i5 = (int) parseDouble; if (((double) i5) == parseDouble) { this.f252x = null; this.u = 0; int[] iArr3 = this.m; int i6 = this.j - 1; iArr3[i6] = iArr3[i6] + 1; return i5; } StringBuilder K3 = a.K("Expected an int but was "); K3.append(this.f252x); K3.append(" at path "); K3.append(getPath()); throw new a(K3.toString()); } catch (NumberFormatException unused2) { StringBuilder K4 = a.K("Expected an int but was "); K4.append(this.f252x); K4.append(" at path "); K4.append(getPath()); throw new a(K4.toString()); } } @Override // c.c.a.a0.h0.c public String s() throws IOException { String str; int i = this.u; if (i == 0) { i = I(); } if (i == 14) { str = R(); } else if (i == 13) { str = Q(o); } else if (i == 12) { str = Q(n); } else if (i == 15) { str = this.f252x; } else { StringBuilder K = a.K("Expected a name but was "); K.append(w()); K.append(" at path "); K.append(getPath()); throw new a(K.toString()); } this.u = 0; this.l[this.j - 1] = str; return str; } @Override // c.c.a.a0.h0.c public String t() throws IOException { String str; int i = this.u; if (i == 0) { i = I(); } if (i == 10) { str = R(); } else if (i == 9) { str = Q(o); } else if (i == 8) { str = Q(n); } else if (i == 11) { str = this.f252x; this.f252x = null; } else if (i == 16) { str = Long.toString(this.v); } else if (i == 17) { str = this.t.H((long) this.w); } else { StringBuilder K = a.K("Expected a string but was "); K.append(w()); K.append(" at path "); K.append(getPath()); throw new a(K.toString()); } this.u = 0; int[] iArr = this.m; int i2 = this.j - 1; iArr[i2] = iArr[i2] + 1; return str; } @Override // java.lang.Object public String toString() { StringBuilder K = a.K("JsonReader("); K.append(this.f251s); K.append(")"); return K.toString(); } @Override // c.c.a.a0.h0.c public c.b w() throws IOException { int i = this.u; 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 // c.c.a.a0.h0.c public int z(c.a aVar) throws IOException { int i = this.u; if (i == 0) { i = I(); } if (i < 12 || i > 15) { return -1; } if (i == 15) { return K(this.f252x, aVar); } int u0 = this.f251s.u0(aVar.b); if (u0 != -1) { this.u = 0; this.l[this.j - 1] = aVar.a[u0]; return u0; } String str = this.l[this.j - 1]; String s2 = s(); int K = K(s2, aVar); if (K == -1) { this.u = 15; this.f252x = s2; this.l[this.j - 1] = str; } return K; } }