package h5; import java.io.EOFException; import java.nio.ByteBuffer; import java.nio.charset.Charset; /* loaded from: classes2.dex */ final class t0 implements f { /* renamed from: a, reason: collision with root package name */ public final d f10291a = new d(); /* renamed from: b, reason: collision with root package name */ public final o0 f10292b; /* renamed from: c, reason: collision with root package name */ boolean f10293c; t0(o0 o0Var) { if (o0Var == null) { throw new NullPointerException("source == null"); } this.f10292b = o0Var; } public boolean G(long j10) { d dVar; if (j10 < 0) { throw new IllegalArgumentException("byteCount < 0: " + j10); } if (this.f10293c) { throw new IllegalStateException("closed"); } do { dVar = this.f10291a; if (dVar.f10014b >= j10) { return true; } } while (this.f10292b.H(dVar, 8192L) != -1); return false; } @Override // h5.o0 public long H(d dVar, long j10) { if (dVar == null) { throw new IllegalArgumentException("sink == null"); } if (j10 < 0) { throw new IllegalArgumentException("byteCount < 0: " + j10); } if (this.f10293c) { throw new IllegalStateException("closed"); } d dVar2 = this.f10291a; if (dVar2.f10014b == 0 && this.f10292b.H(dVar2, 8192L) == -1) { return -1L; } return this.f10291a.H(dVar, Math.min(j10, this.f10291a.f10014b)); } @Override // h5.f, h5.e public d a() { return this.f10291a; } @Override // h5.o0 public p0 b() { return this.f10292b.b(); } public long c(byte b10, long j10, long j11) { if (this.f10293c) { throw new IllegalStateException("closed"); } if (j10 < 0 || j11 < j10) { throw new IllegalArgumentException(String.format("fromIndex=%s toIndex=%s", Long.valueOf(j10), Long.valueOf(j11))); } while (j10 < j11) { long d02 = this.f10291a.d0(b10, j10, j11); if (d02 == -1) { d dVar = this.f10291a; long j12 = dVar.f10014b; if (j12 >= j11 || this.f10292b.H(dVar, 8192L) == -1) { break; } j10 = Math.max(j10, j12); } else { return d02; } } return -1L; } @Override // h5.o0, java.io.Closeable, java.lang.AutoCloseable public void close() { if (this.f10293c) { return; } this.f10293c = true; this.f10292b.close(); this.f10291a.P(); } @Override // h5.f public g d(long j10) { s(j10); return this.f10291a.d(j10); } @Override // h5.f public boolean g() { if (this.f10293c) { throw new IllegalStateException("closed"); } return this.f10291a.g() && this.f10292b.H(this.f10291a, 8192L) == -1; } @Override // h5.f public boolean g0(long j10, g gVar) { return z(j10, gVar, 0, gVar.o()); } @Override // h5.f public String i(long j10) { if (j10 < 0) { throw new IllegalArgumentException("limit < 0: " + j10); } long j11 = j10 == Long.MAX_VALUE ? Long.MAX_VALUE : j10 + 1; long c10 = c((byte) 10, 0L, j11); if (c10 != -1) { return this.f10291a.O(c10); } if (j11 < Long.MAX_VALUE && G(j11) && this.f10291a.a0(j11 - 1) == 13 && G(1 + j11) && this.f10291a.a0(j11) == 10) { return this.f10291a.O(j11); } d dVar = new d(); d dVar2 = this.f10291a; dVar2.Y(dVar, 0L, Math.min(32L, dVar2.u0())); throw new EOFException("\\n not found: limit=" + Math.min(this.f10291a.u0(), j10) + " content=" + dVar.m0().j() + (char) 8230); } @Override // java.nio.channels.Channel public boolean isOpen() { return !this.f10293c; } @Override // h5.f public String k(Charset charset) { if (charset == null) { throw new IllegalArgumentException("charset == null"); } this.f10291a.G0(this.f10292b); return this.f10291a.k(charset); } @Override // h5.f public String n() { return i(Long.MAX_VALUE); } @Override // h5.f public int o() { s(4L); return this.f10291a.o(); } @Override // h5.f public byte[] p(long j10) { s(j10); return this.f10291a.p(j10); } @Override // h5.f public short r() { s(2L); return this.f10291a.r(); } @Override // java.nio.channels.ReadableByteChannel public int read(ByteBuffer byteBuffer) { d dVar = this.f10291a; if (dVar.f10014b == 0 && this.f10292b.H(dVar, 8192L) == -1) { return -1; } return this.f10291a.read(byteBuffer); } @Override // h5.f public byte readByte() { s(1L); return this.f10291a.readByte(); } @Override // h5.f public void readFully(byte[] bArr) { try { s(bArr.length); this.f10291a.readFully(bArr); } catch (EOFException e10) { int i10 = 0; while (true) { d dVar = this.f10291a; long j10 = dVar.f10014b; if (j10 <= 0) { throw e10; } int read = dVar.read(bArr, i10, (int) j10); if (read == -1) { throw new AssertionError(); } i10 += read; } } } @Override // h5.f public int readInt() { s(4L); return this.f10291a.readInt(); } @Override // h5.f public short readShort() { s(2L); return this.f10291a.readShort(); } @Override // h5.f public void s(long j10) { if (!G(j10)) { throw new EOFException(); } } @Override // h5.f public void skip(long j10) { if (this.f10293c) { throw new IllegalStateException("closed"); } while (j10 > 0) { d dVar = this.f10291a; if (dVar.f10014b == 0 && this.f10292b.H(dVar, 8192L) == -1) { throw new EOFException(); } long min = Math.min(j10, this.f10291a.u0()); this.f10291a.skip(min); j10 -= min; } } @Override // h5.f public long t(byte b10) { return c(b10, 0L, Long.MAX_VALUE); } public String toString() { return "buffer(" + this.f10292b + ")"; } /* JADX WARN: Code restructure failed: missing block: B:20:0x0032, code lost: if (r1 == 0) goto L21; */ /* JADX WARN: Code restructure failed: missing block: B:22:0x0049, code lost: throw new java.lang.NumberFormatException(java.lang.String.format("Expected leading [0-9a-fA-F] character but was %#x", java.lang.Byte.valueOf(r3))); */ @Override // h5.f /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ public long u() { /* r6 = this; r0 = 1 r6.s(r0) r0 = 0 r1 = 0 L7: int r2 = r1 + 1 long r3 = (long) r2 boolean r3 = r6.G(r3) if (r3 == 0) goto L4a h5.d r3 = r6.f10291a long r4 = (long) r1 byte r3 = r3.a0(r4) r4 = 48 if (r3 < r4) goto L1f r4 = 57 if (r3 <= r4) goto L30 L1f: r4 = 97 if (r3 < r4) goto L27 r4 = 102(0x66, float:1.43E-43) if (r3 <= r4) goto L30 L27: r4 = 65 if (r3 < r4) goto L32 r4 = 70 if (r3 <= r4) goto L30 goto L32 L30: r1 = r2 goto L7 L32: if (r1 == 0) goto L35 goto L4a L35: java.lang.NumberFormatException r1 = new java.lang.NumberFormatException r2 = 1 java.lang.Object[] r2 = new java.lang.Object[r2] java.lang.Byte r3 = java.lang.Byte.valueOf(r3) r2[r0] = r3 java.lang.String r0 = "Expected leading [0-9a-fA-F] character but was %#x" java.lang.String r0 = java.lang.String.format(r0, r2) r1.(r0) throw r1 L4a: h5.d r0 = r6.f10291a long r0 = r0.u() return r0 */ throw new UnsupportedOperationException("Method not decompiled: h5.t0.u():long"); } public boolean z(long j10, g gVar, int i10, int i11) { if (this.f10293c) { throw new IllegalStateException("closed"); } if (j10 < 0 || i10 < 0 || i11 < 0 || gVar.o() - i10 < i11) { return false; } for (int i12 = 0; i12 < i11; i12++) { long j11 = i12 + j10; if (!G(1 + j11) || this.f10291a.a0(j11) != gVar.i(i10 + i12)) { return false; } } return true; } }