package p5;

import java.io.IOException;
import java.io.InputStream;

/* JADX INFO: renamed from: p5.e, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes3.dex */
public final class C2735e implements P {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f23086a = 1;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Object f23087b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Object f23088c;

    public C2735e(InputStream input, S s6) {
        kotlin.jvm.internal.o.h(input, "input");
        this.f23087b = input;
        this.f23088c = s6;
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public final void close() throws IOException {
        switch (this.f23086a) {
            case 0:
                C2735e c2735e = (C2735e) this.f23088c;
                O o6 = (O) this.f23087b;
                o6.h();
                try {
                    c2735e.close();
                    if (o6.i()) {
                        throw o6.k(null);
                    }
                    return;
                } catch (IOException e6) {
                    if (!o6.i()) {
                        throw e6;
                    }
                    throw o6.k(e6);
                } finally {
                    o6.i();
                }
            default:
                ((InputStream) this.f23087b).close();
                return;
        }
    }

    @Override // p5.P
    public final long read(C2740j sink, long j4) throws IOException {
        switch (this.f23086a) {
            case 0:
                kotlin.jvm.internal.o.h(sink, "sink");
                C2735e c2735e = (C2735e) this.f23088c;
                O o6 = (O) this.f23087b;
                o6.h();
                try {
                    long j6 = c2735e.read(sink, j4);
                    if (o6.i()) {
                        throw o6.k(null);
                    }
                    return j6;
                } catch (IOException e6) {
                    if (o6.i()) {
                        throw o6.k(e6);
                    }
                    throw e6;
                } finally {
                    o6.i();
                }
            default:
                kotlin.jvm.internal.o.h(sink, "sink");
                if (j4 == 0) {
                    return 0L;
                }
                if (j4 < 0) {
                    throw new IllegalArgumentException(A0.a.m("byteCount < 0: ", j4).toString());
                }
                try {
                    ((S) this.f23088c).f();
                    K kM = sink.M(1);
                    int i6 = ((InputStream) this.f23087b).read(kM.f23061a, kM.f23063c, (int) Math.min(j4, 8192 - kM.f23063c));
                    if (i6 == -1) {
                        if (kM.f23062b == kM.f23063c) {
                            sink.f23099a = kM.a();
                            L.a(kM);
                        }
                        return -1L;
                    }
                    kM.f23063c += i6;
                    long j7 = i6;
                    sink.f23100b += j7;
                    return j7;
                } catch (AssertionError e7) {
                    if (AbstractC2732b.f(e7)) {
                        throw new IOException(e7);
                    }
                    throw e7;
                }
        }
    }

    @Override // p5.P
    public final S timeout() {
        switch (this.f23086a) {
            case 0:
                return (O) this.f23087b;
            default:
                return (S) this.f23088c;
        }
    }

    public final String toString() {
        switch (this.f23086a) {
            case 0:
                return "AsyncTimeout.source(" + ((C2735e) this.f23088c) + ')';
            default:
                return "source(" + ((InputStream) this.f23087b) + ')';
        }
    }

    public C2735e(O o6, C2735e c2735e) {
        this.f23087b = o6;
        this.f23088c = c2735e;
    }
}
