package p447.p448.p452;

import java.io.IOException;
import java.net.ProtocolException;
import p138.p139.p143.p144.C2803;
import p402.InterfaceC6540;
import p402.p411.p413.C6635;
import p447.AbstractC6894;
import p447.AbstractC6930;
import p447.C6926;
import p447.C6933;
import p447.p448.p453.InterfaceC6984;
import p461.AbstractC7110;
import p461.AbstractC7111;
import p461.C7103;
import p461.InterfaceC7127;
import p461.InterfaceC7129;

/* JADX INFO: renamed from: ސ.ޣ.ބ.ހ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
@InterfaceC6540
public final class C6960 {

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

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final C6968 f20234;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final C6964 f20235;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final AbstractC6894 f20236;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public final C6963 f20237;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final InterfaceC6984 f20238;

    /* JADX INFO: renamed from: ސ.ޣ.ބ.ހ$֏, reason: contains not printable characters */
    public final class C6961 extends AbstractC7110 {

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

        /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
        public long f20240;

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

        /* JADX INFO: renamed from: އ, reason: contains not printable characters */
        public final long f20242;

        /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
        public final /* synthetic */ C6960 f20243;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C6961(C6960 c6960, InterfaceC7127 interfaceC7127, long j) {
            super(interfaceC7127);
            if (interfaceC7127 == null) {
                C6635.m9824("delegate");
                throw null;
            }
            this.f20243 = c6960;
            this.f20242 = j;
        }

        @Override // p461.InterfaceC7127, java.io.Closeable, java.lang.AutoCloseable
        public void close() throws IOException {
            if (this.f20241) {
                return;
            }
            this.f20241 = true;
            long j = this.f20242;
            if (j != -1 && this.f20240 != j) {
                throw new ProtocolException("unexpected end of stream");
            }
            try {
                this.f20638.close();
                m10204(null);
            } catch (IOException e) {
                throw m10204(e);
            }
        }

        @Override // p461.InterfaceC7127, java.io.Flushable
        public void flush() throws IOException {
            try {
                this.f20638.flush();
            } catch (IOException e) {
                throw m10204(e);
            }
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final <E extends IOException> E m10204(E e) {
            if (this.f20239) {
                return e;
            }
            this.f20239 = true;
            return (E) this.f20243.m10199(this.f20240, false, true, e);
        }

        @Override // p461.InterfaceC7127
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public void mo10205(C7103 c7103, long j) throws IOException {
            if (c7103 == null) {
                C6635.m9824("source");
                throw null;
            }
            if (!(!this.f20241)) {
                throw new IllegalStateException("closed".toString());
            }
            long j2 = this.f20242;
            if (j2 == -1 || this.f20240 + j <= j2) {
                try {
                    this.f20638.mo10205(c7103, j);
                    this.f20240 += j;
                    return;
                } catch (IOException e) {
                    throw m10204(e);
                }
            }
            StringBuilder sbM4889 = C2803.m4889("expected ");
            sbM4889.append(this.f20242);
            sbM4889.append(" bytes but received ");
            sbM4889.append(this.f20240 + j);
            throw new ProtocolException(sbM4889.toString());
        }
    }

    /* JADX INFO: renamed from: ސ.ޣ.ބ.ހ$ؠ, reason: contains not printable characters */
    public final class C6962 extends AbstractC7111 {

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

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

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

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

        /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
        public final long f20248;

        /* JADX INFO: renamed from: މ, reason: contains not printable characters */
        public final /* synthetic */ C6960 f20249;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C6962(C6960 c6960, InterfaceC7129 interfaceC7129, long j) {
            super(interfaceC7129);
            if (interfaceC7129 == null) {
                C6635.m9824("delegate");
                throw null;
            }
            this.f20249 = c6960;
            this.f20248 = j;
            this.f20245 = true;
            if (j == 0) {
                m10206(null);
            }
        }

        @Override // p461.AbstractC7111, p461.InterfaceC7129, java.io.Closeable, java.lang.AutoCloseable
        public void close() throws IOException {
            if (this.f20247) {
                return;
            }
            this.f20247 = true;
            try {
                this.f20639.close();
                m10206(null);
            } catch (IOException e) {
                throw m10206(e);
            }
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final <E extends IOException> E m10206(E e) {
            if (this.f20246) {
                return e;
            }
            this.f20246 = true;
            if (e == null && this.f20245) {
                this.f20245 = false;
                C6960 c6960 = this.f20249;
                AbstractC6894 abstractC6894 = c6960.f20236;
                C6964 c6964 = c6960.f20235;
                if (abstractC6894 == null) {
                    throw null;
                }
                if (c6964 == null) {
                    C6635.m9824("call");
                    throw null;
                }
            }
            return (E) this.f20249.m10199(this.f20244, true, false, e);
        }

        @Override // p461.AbstractC7111, p461.InterfaceC7129
        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public long mo10207(C7103 c7103, long j) throws IOException {
            if (c7103 == null) {
                C6635.m9824("sink");
                throw null;
            }
            if (!(!this.f20247)) {
                throw new IllegalStateException("closed".toString());
            }
            try {
                long jMo10207 = this.f20639.mo10207(c7103, j);
                if (this.f20245) {
                    this.f20245 = false;
                    AbstractC6894 abstractC6894 = this.f20249.f20236;
                    C6964 c6964 = this.f20249.f20235;
                    if (abstractC6894 == null) {
                        throw null;
                    }
                    if (c6964 == null) {
                        C6635.m9824("call");
                        throw null;
                    }
                }
                if (jMo10207 == -1) {
                    m10206(null);
                    return -1L;
                }
                long j2 = this.f20244 + jMo10207;
                if (this.f20248 != -1 && j2 > this.f20248) {
                    throw new ProtocolException("expected " + this.f20248 + " bytes but received " + j2);
                }
                this.f20244 = j2;
                if (j2 == this.f20248) {
                    m10206(null);
                }
                return jMo10207;
            } catch (IOException e) {
                throw m10206(e);
            }
        }
    }

    public C6960(C6964 c6964, AbstractC6894 abstractC6894, C6963 c6963, InterfaceC6984 interfaceC6984) {
        if (c6964 == null) {
            C6635.m9824("call");
            throw null;
        }
        if (abstractC6894 == null) {
            C6635.m9824("eventListener");
            throw null;
        }
        if (c6963 == null) {
            C6635.m9824("finder");
            throw null;
        }
        if (interfaceC6984 == null) {
            C6635.m9824("codec");
            throw null;
        }
        this.f20235 = c6964;
        this.f20236 = abstractC6894;
        this.f20237 = c6963;
        this.f20238 = interfaceC6984;
        this.f20234 = interfaceC6984.mo10257();
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final <E extends IOException> E m10199(long j, boolean z, boolean z2, E e) {
        if (e != null) {
            m10203(e);
        }
        if (z2) {
            if (e != null) {
                this.f20236.m10058(this.f20235, e);
            } else {
                AbstractC6894 abstractC6894 = this.f20236;
                C6964 c6964 = this.f20235;
                if (abstractC6894 == null) {
                    throw null;
                }
                if (c6964 == null) {
                    C6635.m9824("call");
                    throw null;
                }
            }
        }
        if (z) {
            if (e != null) {
                this.f20236.m10061(this.f20235, e);
            } else {
                AbstractC6894 abstractC68942 = this.f20236;
                C6964 c69642 = this.f20235;
                if (abstractC68942 == null) {
                    throw null;
                }
                if (c69642 == null) {
                    C6635.m9824("call");
                    throw null;
                }
            }
        }
        return (E) this.f20235.m10217(this, z2, z, e);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final C6933.C6934 m10200(boolean z) throws IOException {
        try {
            C6933.C6934 c6934Mo10251 = this.f20238.mo10251(z);
            if (c6934Mo10251 != null) {
                c6934Mo10251.f20171 = this;
            }
            return c6934Mo10251;
        } catch (IOException e) {
            this.f20236.m10061(this.f20235, e);
            m10203(e);
            throw e;
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final InterfaceC7127 m10201(C6926 c6926, boolean z) {
        if (c6926 == null) {
            C6635.m9824("request");
            throw null;
        }
        this.f20233 = z;
        AbstractC6930 abstractC6930 = c6926.f20131;
        if (abstractC6930 == null) {
            C6635.m9822();
            throw null;
        }
        long jContentLength = abstractC6930.contentLength();
        AbstractC6894 abstractC6894 = this.f20236;
        C6964 c6964 = this.f20235;
        if (abstractC6894 == null) {
            throw null;
        }
        if (c6964 != null) {
            return new C6961(this, this.f20238.mo10252(c6926, jContentLength), jContentLength);
        }
        C6635.m9824("call");
        throw null;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m10202() {
        AbstractC6894 abstractC6894 = this.f20236;
        C6964 c6964 = this.f20235;
        if (abstractC6894 == null) {
            throw null;
        }
        if (c6964 != null) {
            return;
        }
        C6635.m9824("call");
        throw null;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m10203(IOException iOException) {
        this.f20237.m10211(iOException);
        this.f20238.mo10257().m10232(this.f20235, iOException);
    }
}
