package x9; import java.io.EOFException; import java.io.IOException; import java.util.zip.DataFormatException; import java.util.zip.Inflater; /* loaded from: classes2.dex */ public final class m implements v { /* renamed from: a, reason: collision with root package name */ private final e f15490a; /* renamed from: b, reason: collision with root package name */ private final Inflater f15491b; /* renamed from: c, reason: collision with root package name */ private int f15492c; /* renamed from: d, reason: collision with root package name */ private boolean f15493d; m(e eVar, Inflater inflater) { if (eVar == null) { throw new IllegalArgumentException("source == null"); } if (inflater == null) { throw new IllegalArgumentException("inflater == null"); } this.f15490a = eVar; this.f15491b = inflater; } private void z() { int i10 = this.f15492c; if (i10 == 0) { return; } int remaining = i10 - this.f15491b.getRemaining(); this.f15492c -= remaining; this.f15490a.skip(remaining); } @Override // x9.v public w b() { return this.f15490a.b(); } public final boolean c() { if (!this.f15491b.needsInput()) { return false; } z(); if (this.f15491b.getRemaining() != 0) { throw new IllegalStateException("?"); } if (this.f15490a.g()) { return true; } r rVar = this.f15490a.a().f15467a; int i10 = rVar.f15510c; int i11 = rVar.f15509b; int i12 = i10 - i11; this.f15492c = i12; this.f15491b.setInput(rVar.f15508a, i11, i12); return false; } @Override // x9.v, java.io.Closeable, java.lang.AutoCloseable public void close() { if (this.f15493d) { return; } this.f15491b.end(); this.f15493d = true; this.f15490a.close(); } @Override // x9.v public long s0(c cVar, long j10) { boolean c10; if (j10 < 0) { throw new IllegalArgumentException("byteCount < 0: " + j10); } if (this.f15493d) { throw new IllegalStateException("closed"); } if (j10 == 0) { return 0L; } do { c10 = c(); try { r D0 = cVar.D0(1); int inflate = this.f15491b.inflate(D0.f15508a, D0.f15510c, (int) Math.min(j10, 8192 - D0.f15510c)); if (inflate > 0) { D0.f15510c += inflate; long j11 = inflate; cVar.f15468b += j11; return j11; } if (!this.f15491b.finished() && !this.f15491b.needsDictionary()) { } z(); if (D0.f15509b != D0.f15510c) { return -1L; } cVar.f15467a = D0.b(); s.a(D0); return -1L; } catch (DataFormatException e10) { throw new IOException(e10); } } while (!c10); throw new EOFException("source exhausted prematurely"); } }