package o;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.vW, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C2717vW implements T90 {
    public final InterfaceC1687kf l;
    public final C0732af m;
    public C2496t50 n;

    /* renamed from: o, reason: collision with root package name */
    public int f757o;
    public boolean p;
    public long q;

    public C2717vW(InterfaceC1687kf interfaceC1687kf) {
        this.l = interfaceC1687kf;
        C0732af c0732afV = interfaceC1687kf.v();
        this.m = c0732afV;
        C2496t50 c2496t50 = c0732afV.l;
        this.n = c2496t50;
        this.f757o = c2496t50 != null ? c2496t50.b : -1;
    }

    @Override // o.T90
    public final long C(long j, C0732af c0732af) {
        C2496t50 c2496t50;
        C2496t50 c2496t502;
        if (j < 0) {
            throw new IllegalArgumentException(AbstractC0126Ew.l("byteCount < 0: ", j).toString());
        }
        if (this.p) {
            throw new IllegalStateException("closed");
        }
        C2496t50 c2496t503 = this.n;
        C0732af c0732af2 = this.m;
        if (c2496t503 != null && (c2496t503 != (c2496t502 = c0732af2.l) || this.f757o != c2496t502.b)) {
            throw new IllegalStateException("Peek source is invalid because upstream source was used");
        }
        if (j == 0) {
            return 0L;
        }
        if (!this.l.n(this.q + 1)) {
            return -1L;
        }
        if (this.n == null && (c2496t50 = c0732af2.l) != null) {
            this.n = c2496t50;
            this.f757o = c2496t50.b;
        }
        long jMin = Math.min(j, c0732af2.m - this.q);
        this.m.d(c0732af, this.q, jMin);
        this.q += jMin;
        return jMin;
    }

    @Override // o.T90
    public final Cf0 a() {
        return this.l.a();
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public final void close() {
        this.p = true;
    }
}
