package h5; /* loaded from: classes2.dex */ final class v0 { /* renamed from: a, reason: collision with root package name */ final byte[] f10309a; /* renamed from: b, reason: collision with root package name */ int f10310b; /* renamed from: c, reason: collision with root package name */ int f10311c; /* renamed from: d, reason: collision with root package name */ boolean f10312d; /* renamed from: e, reason: collision with root package name */ boolean f10313e; /* renamed from: f, reason: collision with root package name */ v0 f10314f; /* renamed from: g, reason: collision with root package name */ v0 f10315g; v0() { this.f10309a = new byte[8192]; this.f10313e = true; this.f10312d = false; } public final v0 a(int i10) { v0 a10; if (i10 <= 0 || i10 > this.f10311c - this.f10310b) { throw new IllegalArgumentException(); } if (i10 >= 1024) { a10 = f(); } else { a10 = w0.a(); System.arraycopy(this.f10309a, this.f10310b, a10.f10309a, 0, i10); } a10.f10311c = a10.f10310b + i10; this.f10310b += i10; this.f10315g.b(a10); return a10; } public final v0 b(v0 v0Var) { v0Var.f10315g = this; v0Var.f10314f = this.f10314f; this.f10314f.f10315g = v0Var; this.f10314f = v0Var; return v0Var; } public final void c() { v0 v0Var = this.f10315g; if (v0Var == this) { throw new IllegalStateException(); } if (v0Var.f10313e) { int i10 = this.f10311c - this.f10310b; if (i10 > (8192 - v0Var.f10311c) + (v0Var.f10312d ? 0 : v0Var.f10310b)) { return; } d(v0Var, i10); e(); w0.b(this); } } public final void d(v0 v0Var, int i10) { if (!v0Var.f10313e) { throw new IllegalArgumentException(); } int i11 = v0Var.f10311c; int i12 = i11 + i10; if (i12 > 8192) { if (v0Var.f10312d) { throw new IllegalArgumentException(); } int i13 = v0Var.f10310b; if (i12 - i13 > 8192) { throw new IllegalArgumentException(); } byte[] bArr = v0Var.f10309a; System.arraycopy(bArr, i13, bArr, 0, i11 - i13); v0Var.f10311c -= v0Var.f10310b; v0Var.f10310b = 0; } System.arraycopy(this.f10309a, this.f10310b, v0Var.f10309a, v0Var.f10311c, i10); v0Var.f10311c += i10; this.f10310b += i10; } public final v0 e() { v0 v0Var = this.f10314f; v0 v0Var2 = v0Var != this ? v0Var : null; v0 v0Var3 = this.f10315g; v0Var3.f10314f = v0Var; this.f10314f.f10315g = v0Var3; this.f10314f = null; this.f10315g = null; return v0Var2; } final v0 f() { this.f10312d = true; return new v0(this.f10309a, this.f10310b, this.f10311c, true, false); } v0(byte[] bArr, int i10, int i11, boolean z10, boolean z11) { this.f10309a = bArr; this.f10310b = i10; this.f10311c = i11; this.f10312d = z10; this.f10313e = z11; } }