package x7;

import d5.AbstractC0844a;

/* JADX INFO: loaded from: classes.dex */
public final class y implements H, AutoCloseable {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final InterfaceC1733i f18799q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final C1731g f18800r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public C f18801s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public int f18802t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public boolean f18803u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public long f18804v;

    public y(InterfaceC1733i interfaceC1733i) {
        this.f18799q = interfaceC1733i;
        C1731g c1731gD = interfaceC1733i.d();
        this.f18800r = c1731gD;
        C c3 = c1731gD.f18764q;
        this.f18801s = c3;
        this.f18802t = c3 != null ? c3.f18728b : -1;
    }

    /* JADX WARN: Code restructure failed: missing block: B:11:0x0020, code lost:
    
        if (r3 == r5.f18728b) goto L15;
     */
    @Override // x7.H
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final long M(C1731g c1731g, long j8) {
        C c3;
        P6.g.e(c1731g, "sink");
        if (j8 < 0) {
            throw new IllegalArgumentException(AbstractC0844a.i(j8, "byteCount < 0: ").toString());
        }
        if (this.f18803u) {
            throw new IllegalStateException("closed");
        }
        C c8 = this.f18801s;
        C1731g c1731g2 = this.f18800r;
        if (c8 != null) {
            C c9 = c1731g2.f18764q;
            if (c8 == c9) {
                int i = this.f18802t;
                P6.g.b(c9);
            }
            throw new IllegalStateException("Peek source is invalid because upstream source was used");
        }
        if (j8 == 0) {
            return 0L;
        }
        if (!this.f18799q.C(this.f18804v + 1)) {
            return -1L;
        }
        if (this.f18801s == null && (c3 = c1731g2.f18764q) != null) {
            this.f18801s = c3;
            this.f18802t = c3.f18728b;
        }
        long jMin = Math.min(j8, c1731g2.f18765r - this.f18804v);
        this.f18800r.r(c1731g, this.f18804v, jMin);
        this.f18804v += jMin;
        return jMin;
    }

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

    @Override // x7.H
    public final J f() {
        return this.f18799q.f();
    }
}
