package p461;

import java.io.EOFException;
import java.io.IOException;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
import p138.p139.p143.p144.C2803;
import p402.p411.p413.C6635;

/* JADX INFO: renamed from: ޑ.ފ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C7114 implements InterfaceC7129 {

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public int f20646;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public boolean f20647;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public final InterfaceC7107 f20648;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public final Inflater f20649;

    public C7114(InterfaceC7107 interfaceC7107, Inflater inflater) {
        if (interfaceC7107 == null) {
            C6635.m9824("source");
            throw null;
        }
        if (inflater == null) {
            C6635.m9824("inflater");
            throw null;
        }
        this.f20648 = interfaceC7107;
        this.f20649 = inflater;
    }

    @Override // p461.InterfaceC7129, java.io.Closeable, java.lang.AutoCloseable
    public void close() {
        if (this.f20647) {
            return;
        }
        this.f20649.end();
        this.f20647 = true;
        this.f20648.close();
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final boolean m10467() {
        if (!this.f20649.needsInput()) {
            return false;
        }
        if (this.f20648.mo10436()) {
            return true;
        }
        C7123 c7123 = this.f20648.getBuffer().f20629;
        if (c7123 == null) {
            C6635.m9822();
            throw null;
        }
        int i = c7123.f20667;
        int i2 = c7123.f20666;
        int i3 = i - i2;
        this.f20646 = i3;
        this.f20649.setInput(c7123.f20665, i2, i3);
        return false;
    }

    @Override // p461.InterfaceC7129
    /* JADX INFO: renamed from: ؠ */
    public long mo10207(C7103 c7103, long j) throws IOException {
        long j2;
        if (c7103 == null) {
            C6635.m9824("sink");
            throw null;
        }
        do {
            if (!(j >= 0)) {
                throw new IllegalArgumentException(C2803.m4874("byteCount < 0: ", j).toString());
            }
            if (!(!this.f20647)) {
                throw new IllegalStateException("closed".toString());
            }
            if (j == 0) {
                j2 = 0;
            } else {
                try {
                    C7123 c7123M10423 = c7103.m10423(1);
                    int iMin = (int) Math.min(j, 8192 - c7123M10423.f20667);
                    m10467();
                    int iInflate = this.f20649.inflate(c7123M10423.f20665, c7123M10423.f20667, iMin);
                    int i = this.f20646;
                    if (i != 0) {
                        int remaining = i - this.f20649.getRemaining();
                        this.f20646 -= remaining;
                        this.f20648.skip(remaining);
                    }
                    if (iInflate > 0) {
                        c7123M10423.f20667 += iInflate;
                        j2 = iInflate;
                        c7103.f20630 += j2;
                    } else {
                        if (c7123M10423.f20666 == c7123M10423.f20667) {
                            c7103.f20629 = c7123M10423.m10475();
                            C7125.f20674.m10480(c7123M10423);
                        }
                        j2 = 0;
                    }
                } catch (DataFormatException e) {
                    throw new IOException(e);
                }
            }
            if (j2 > 0) {
                return j2;
            }
            if (this.f20649.finished() || this.f20649.needsDictionary()) {
                return -1L;
            }
        } while (!this.f20648.mo10436());
        throw new EOFException("source exhausted prematurely");
    }

    @Override // p461.InterfaceC7129
    /* JADX INFO: renamed from: ށ */
    public C7130 mo10277() {
        return this.f20648.mo10277();
    }
}
