package okio;

/* JADX INFO: renamed from: okio.RealBufferedSource, reason: from toString */
/* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
/* JADX INFO: loaded from: E:\ios\vf_dex\classes3.dex */
@kotlin.Metadata(d1 = {"\u0000\u008e\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\t\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\u0004\n\u0002\u0010\u0005\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\u0012\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0010\n\n\u0002\b#\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\r\b\u0000\u0018\u00002\u00020\u0001B\u000f\u0012\u0006\u0010\u0003\u001a\u00020\u0002¢\u0006\u0004\b\u0004\u0010\u0005J\u000f\u0010\u0007\u001a\u00020\u0006H\u0016¢\u0006\u0004\b\u0007\u0010\bJ\u001f\u0010\f\u001a\u00020\n2\u0006\u0010\t\u001a\u00020\u00062\u0006\u0010\u000b\u001a\u00020\nH\u0016¢\u0006\u0004\b\f\u0010\rJ\u000f\u0010\u000f\u001a\u00020\u000eH\u0016¢\u0006\u0004\b\u000f\u0010\u0010J\u0017\u0010\u0012\u001a\u00020\u00112\u0006\u0010\u000b\u001a\u00020\nH\u0016¢\u0006\u0004\b\u0012\u0010\u0013J\u0017\u0010\u0014\u001a\u00020\u000e2\u0006\u0010\u000b\u001a\u00020\nH\u0016¢\u0006\u0004\b\u0014\u0010\u0015J\u000f\u0010\u0017\u001a\u00020\u0016H\u0016¢\u0006\u0004\b\u0017\u0010\u0018J\u000f\u0010\u001a\u001a\u00020\u0019H\u0016¢\u0006\u0004\b\u001a\u0010\u001bJ\u0017\u0010\u001c\u001a\u00020\u00192\u0006\u0010\u000b\u001a\u00020\nH\u0016¢\u0006\u0004\b\u001c\u0010\u001dJ\u0017\u0010!\u001a\u00020 2\u0006\u0010\u001f\u001a\u00020\u001eH\u0016¢\u0006\u0004\b!\u0010\"J\u000f\u0010$\u001a\u00020#H\u0016¢\u0006\u0004\b$\u0010%J\u0017\u0010&\u001a\u00020#2\u0006\u0010\u000b\u001a\u00020\nH\u0016¢\u0006\u0004\b&\u0010'J\u0017\u0010(\u001a\u00020\u00112\u0006\u0010\t\u001a\u00020#H\u0016¢\u0006\u0004\b(\u0010)J\u0017\u0010\f\u001a\u00020 2\u0006\u0010\t\u001a\u00020*H\u0016¢\u0006\u0004\b\f\u0010+J\u001f\u0010,\u001a\u00020\u00112\u0006\u0010\t\u001a\u00020\u00062\u0006\u0010\u000b\u001a\u00020\nH\u0016¢\u0006\u0004\b,\u0010-J\u0017\u0010/\u001a\u00020\n2\u0006\u0010\t\u001a\u00020.H\u0016¢\u0006\u0004\b/\u00100J\u0017\u00102\u001a\u0002012\u0006\u0010\u000b\u001a\u00020\nH\u0016¢\u0006\u0004\b2\u00103J\u0017\u00106\u001a\u0002012\u0006\u00105\u001a\u000204H\u0016¢\u0006\u0004\b6\u00107J\u000f\u00108\u001a\u000201H\u0016¢\u0006\u0004\b8\u00109J\u0017\u0010;\u001a\u0002012\u0006\u0010:\u001a\u00020\nH\u0016¢\u0006\u0004\b;\u00103J\u000f\u0010=\u001a\u00020<H\u0016¢\u0006\u0004\b=\u0010>J\u000f\u0010?\u001a\u00020<H\u0016¢\u0006\u0004\b?\u0010>J\u000f\u0010@\u001a\u00020 H\u0016¢\u0006\u0004\b@\u0010AJ\u000f\u0010B\u001a\u00020 H\u0016¢\u0006\u0004\bB\u0010AJ\u000f\u0010C\u001a\u00020\nH\u0016¢\u0006\u0004\bC\u0010DJ\u000f\u0010E\u001a\u00020\nH\u0016¢\u0006\u0004\bE\u0010DJ\u000f\u0010F\u001a\u00020\nH\u0016¢\u0006\u0004\bF\u0010DJ\u000f\u0010G\u001a\u00020\nH\u0016¢\u0006\u0004\bG\u0010DJ\u0017\u0010H\u001a\u00020\u00112\u0006\u0010\u000b\u001a\u00020\nH\u0016¢\u0006\u0004\bH\u0010\u0013J\u0017\u0010J\u001a\u00020\n2\u0006\u0010I\u001a\u00020\u0016H\u0016¢\u0006\u0004\bJ\u0010KJ'\u0010N\u001a\u00020\n2\u0006\u0010I\u001a\u00020\u00162\u0006\u0010L\u001a\u00020\n2\u0006\u0010M\u001a\u00020\nH\u0016¢\u0006\u0004\bN\u0010OJ\u0017\u0010Q\u001a\u00020\n2\u0006\u0010P\u001a\u00020\u0019H\u0016¢\u0006\u0004\bQ\u0010RJ\u001f\u0010S\u001a\u00020\n2\u0006\u0010P\u001a\u00020\u00192\u0006\u0010L\u001a\u00020\nH\u0016¢\u0006\u0004\bS\u0010TJ\u0017\u0010V\u001a\u00020\n2\u0006\u0010U\u001a\u00020\u0019H\u0016¢\u0006\u0004\bV\u0010RJ\u001f\u0010W\u001a\u00020\n2\u0006\u0010U\u001a\u00020\u00192\u0006\u0010L\u001a\u00020\nH\u0016¢\u0006\u0004\bW\u0010TJ\u001f\u0010Y\u001a\u00020\u000e2\u0006\u0010X\u001a\u00020\n2\u0006\u0010P\u001a\u00020\u0019H\u0016¢\u0006\u0004\bY\u0010ZJ/\u0010\\\u001a\u00020\u000e2\u0006\u0010X\u001a\u00020\n2\u0006\u0010P\u001a\u00020\u00192\u0006\u0010[\u001a\u00020 2\u0006\u0010\u000b\u001a\u00020 H\u0016¢\u0006\u0004\b\\\u0010]J\u000f\u0010^\u001a\u00020\u0001H\u0016¢\u0006\u0004\b^\u0010_J\u000f\u0010a\u001a\u00020`H\u0016¢\u0006\u0004\ba\u0010bJ\u000f\u0010c\u001a\u00020\u000eH\u0016¢\u0006\u0004\bc\u0010\u0010J\u000f\u0010d\u001a\u00020\u0011H\u0016¢\u0006\u0004\bd\u0010eJ\u000f\u0010g\u001a\u00020fH\u0016¢\u0006\u0004\bg\u0010hJ\u000f\u0010i\u001a\u000201H\u0016¢\u0006\u0004\bi\u00109R\u0014\u0010\u0003\u001a\u00020\u00028\u0006X\u0087\u0004¢\u0006\u0006\n\u0004\bJ\u0010jR\u0014\u0010l\u001a\u00020\u00068\u0006X\u0087\u0004¢\u0006\u0006\n\u0004\bI\u0010kR\u0016\u0010o\u001a\u00020\u000e8\u0006@\u0006X\u0087\u000e¢\u0006\u0006\n\u0004\bm\u0010nR\u001b\u0010r\u001a\u00020\u00068Ö\u0002X\u0096\u0004¢\u0006\f\u0012\u0004\bq\u0010e\u001a\u0004\bp\u0010\b¨\u0006s"}, d2 = {"Lokio/RealBufferedSource;", "Lokio/BufferedSource;", "Lokio/Source;", "source", "<init>", "(Lokio/Source;)V", "Lokio/Buffer;", "h1", "()Lokio/Buffer;", "sink", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "byteCount", "read", "(Lokio/Buffer;J)J", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "m2", "()Z", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "b2", "(J)V", "request", "(J)Z", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "readByte", "()B", "Lokio/ByteString;", "N0", "()Lokio/ByteString;", "s0", "(J)Lokio/ByteString;", "Lokio/Options;", "options", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "R2", "(Lokio/Options;)I", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "x0", "()[B", "V1", "(J)[B", "readFully", "([B)V", "Ljava/nio/ByteBuffer;", "(Ljava/nio/ByteBuffer;)I", "s1", "(Lokio/Buffer;J)V", "Lokio/Sink;", "X0", "(Lokio/Sink;)J", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "q0", "(J)Ljava/lang/String;", "Ljava/nio/charset/Charset;", "charset", "K0", "(Ljava/nio/charset/Charset;)Ljava/lang/String;", "S1", "()Ljava/lang/String;", "limit", "w1", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "readShort", "()S", "j0", "readInt", "()I", "E2", "readLong", "()J", "l0", "o2", "d1", "skip", "b", "a", "(B)J", "fromIndex", "toIndex", "d", "(BJJ)J", "bytes", "I", "(Lokio/ByteString;)J", "e", "(Lokio/ByteString;J)J", "targetBytes", "K", "i", "offset", "Q", "(JLokio/ByteString;)Z", "bytesOffset", "k", "(JLokio/ByteString;II)Z", "peek", "()Lokio/BufferedSource;", "Ljava/io/InputStream;", "P2", "()Ljava/io/InputStream;", "isOpen", "close", "()V", "Lokio/Timeout;", "timeout", "()Lokio/Timeout;", "toString", "Lokio/Source;", "Lokio/Buffer;", "bufferField", "c", "Z", "closed", "g", "getBuffer$annotations", "buffer", "okio"}, k = 1, mv = {1, 9, 0}, xi = 48)
@kotlin.jvm.internal.SourceDebugExtension
public final class buffer implements okio.BufferedSource {

    /* JADX INFO: renamed from: a, reason: from kotlin metadata */
    public final okio.Source source;

    /* JADX INFO: renamed from: b, reason: from kotlin metadata */
    public final okio.Buffer bufferField;

    /* JADX INFO: renamed from: c, reason: from kotlin metadata */
    public boolean closed;

    public buffer(okio.Source source) {
        kotlin.jvm.internal.Intrinsics.l(source, "source");
        this.source = source;
        this.bufferField = new okio.Buffer();
    }

    @Override // okio.BufferedSource
    public int E2() throws java.io.EOFException {
        b2(4L);
        return this.bufferField.E2();
    }

    @Override // okio.BufferedSource
    public long I(okio.ByteString bytes) {
        kotlin.jvm.internal.Intrinsics.l(bytes, "bytes");
        return e(bytes, 0L);
    }

    @Override // okio.BufferedSource
    public long K(okio.ByteString targetBytes) {
        kotlin.jvm.internal.Intrinsics.l(targetBytes, "targetBytes");
        return i(targetBytes, 0L);
    }

    @Override // okio.BufferedSource
    public java.lang.String K0(java.nio.charset.Charset charset) {
        kotlin.jvm.internal.Intrinsics.l(charset, "charset");
        this.bufferField.L1(this.source);
        return this.bufferField.K0(charset);
    }

    @Override // okio.BufferedSource
    public okio.ByteString N0() {
        this.bufferField.L1(this.source);
        return this.bufferField.N0();
    }

    @Override // okio.BufferedSource
    public java.io.InputStream P2() {
        return new java.io.InputStream() { // from class: okio.RealBufferedSource$inputStream$1
            @Override // java.io.InputStream
            public int available() throws java.io.IOException {
                okio.buffer bufferVar = this.a;
                if (bufferVar.closed) {
                    throw new java.io.IOException("closed");
                }
                return (int) java.lang.Math.min(bufferVar.bufferField.getSize(), Integer.MAX_VALUE);
            }

            @Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable
            public void close() throws java.io.EOFException {
                this.a.close();
            }

            @Override // java.io.InputStream
            public int read() throws java.io.IOException {
                okio.buffer bufferVar = this.a;
                if (bufferVar.closed) {
                    throw new java.io.IOException("closed");
                }
                if (bufferVar.bufferField.getSize() == 0) {
                    okio.buffer bufferVar2 = this.a;
                    if (bufferVar2.source.read(bufferVar2.bufferField, 8192L) == -1) {
                        return -1;
                    }
                }
                return this.a.bufferField.readByte() & 255;
            }

            public java.lang.String toString() {
                return this.a + ".inputStream()";
            }

            @Override // java.io.InputStream
            public int read(byte[] data, int offset, int byteCount) throws java.io.IOException {
                kotlin.jvm.internal.Intrinsics.l(data, "data");
                if (!this.a.closed) {
                    okio.SegmentedByteString.b(data.length, offset, byteCount);
                    if (this.a.bufferField.getSize() == 0) {
                        okio.buffer bufferVar = this.a;
                        if (bufferVar.source.read(bufferVar.bufferField, 8192L) == -1) {
                            return -1;
                        }
                    }
                    return this.a.bufferField.read(data, offset, byteCount);
                }
                throw new java.io.IOException("closed");
            }
        };
    }

    @Override // okio.BufferedSource
    public boolean Q(long offset, okio.ByteString bytes) {
        kotlin.jvm.internal.Intrinsics.l(bytes, "bytes");
        return k(offset, bytes, 0, bytes.B());
    }

    @Override // okio.BufferedSource
    public int R2(okio.Options options) throws java.io.EOFException {
        kotlin.jvm.internal.Intrinsics.l(options, "options");
        if (this.closed) {
            throw new java.lang.IllegalStateException("closed");
        }
        do {
            int iE = okio.internal.Buffer.e(this.bufferField, options, true);
            if (iE != -2) {
                if (iE == -1) {
                    return -1;
                }
                this.bufferField.skip(options.getByteStrings()[iE].B());
                return iE;
            }
        } while (this.source.read(this.bufferField, 8192L) != -1);
        return -1;
    }

    @Override // okio.BufferedSource
    public java.lang.String S1() {
        return w1(Long.MAX_VALUE);
    }

    @Override // okio.BufferedSource
    public byte[] V1(long byteCount) throws java.io.EOFException {
        b2(byteCount);
        return this.bufferField.V1(byteCount);
    }

    @Override // okio.BufferedSource
    public long X0(okio.Sink sink) {
        kotlin.jvm.internal.Intrinsics.l(sink, "sink");
        long j = 0;
        while (this.source.read(this.bufferField, 8192L) != -1) {
            long jD = this.bufferField.d();
            if (jD > 0) {
                j += jD;
                sink.write(this.bufferField, jD);
            }
        }
        if (this.bufferField.getSize() <= 0) {
            return j;
        }
        long size = j + this.bufferField.getSize();
        okio.Buffer buffer = this.bufferField;
        sink.write(buffer, buffer.getSize());
        return size;
    }

    public long a(byte b) {
        return d(b, 0L, Long.MAX_VALUE);
    }

    @Override // okio.BufferedSource
    public void b2(long byteCount) throws java.io.EOFException {
        if (!request(byteCount)) {
            throw new java.io.EOFException();
        }
    }

    @Override // okio.Source, java.io.Closeable, java.lang.AutoCloseable
    public void close() throws java.io.EOFException {
        if (this.closed) {
            return;
        }
        this.closed = true;
        this.source.close();
        this.bufferField.clear();
    }

    public long d(byte b, long fromIndex, long toIndex) {
        if (this.closed) {
            throw new java.lang.IllegalStateException("closed");
        }
        if (0 > fromIndex || fromIndex > toIndex) {
            throw new java.lang.IllegalArgumentException(("fromIndex=" + fromIndex + " toIndex=" + toIndex).toString());
        }
        long jMax = fromIndex;
        while (jMax < toIndex) {
            byte b2 = b;
            long j = toIndex;
            long jY = this.bufferField.y(b2, jMax, j);
            if (jY != -1) {
                return jY;
            }
            long size = this.bufferField.getSize();
            if (size >= j || this.source.read(this.bufferField, 8192L) == -1) {
                break;
            }
            jMax = java.lang.Math.max(jMax, size);
            b = b2;
            toIndex = j;
        }
        return -1L;
    }

    @Override // okio.BufferedSource
    public long d1() throws java.io.EOFException {
        b2(1L);
        int i = 0;
        while (true) {
            int i2 = i + 1;
            if (!request(i2)) {
                break;
            }
            byte bU = this.bufferField.u(i);
            if ((bU < 48 || bU > 57) && ((bU < 97 || bU > 102) && (bU < 65 || bU > 70))) {
                if (i != 0) {
                    break;
                }
                java.lang.StringBuilder sb = new java.lang.StringBuilder();
                sb.append("Expected leading [0-9a-fA-F] character but was 0x");
                java.lang.String string = java.lang.Integer.toString(bU, kotlin.text.CharsKt.a(16));
                kotlin.jvm.internal.Intrinsics.k(string, "toString(...)");
                sb.append(string);
                throw new java.lang.NumberFormatException(sb.toString());
            }
            i = i2;
        }
        return this.bufferField.d1();
    }

    public long e(okio.ByteString bytes, long fromIndex) {
        kotlin.jvm.internal.Intrinsics.l(bytes, "bytes");
        if (this.closed) {
            throw new java.lang.IllegalStateException("closed");
        }
        while (true) {
            long jC = this.bufferField.C(bytes, fromIndex);
            if (jC != -1) {
                return jC;
            }
            long size = this.bufferField.getSize();
            if (this.source.read(this.bufferField, 8192L) == -1) {
                return -1L;
            }
            fromIndex = java.lang.Math.max(fromIndex, (size - ((long) bytes.B())) + 1);
        }
    }

    @Override // okio.BufferedSource, okio.BufferedSink
    /* JADX INFO: renamed from: g, reason: from getter */
    public okio.Buffer getBufferField() {
        return this.bufferField;
    }

    @Override // okio.BufferedSource
    public okio.Buffer h1() {
        return this.bufferField;
    }

    public long i(okio.ByteString targetBytes, long fromIndex) {
        kotlin.jvm.internal.Intrinsics.l(targetBytes, "targetBytes");
        if (this.closed) {
            throw new java.lang.IllegalStateException("closed");
        }
        while (true) {
            long jG = this.bufferField.G(targetBytes, fromIndex);
            if (jG != -1) {
                return jG;
            }
            long size = this.bufferField.getSize();
            if (this.source.read(this.bufferField, 8192L) == -1) {
                return -1L;
            }
            fromIndex = java.lang.Math.max(fromIndex, size);
        }
    }

    @Override // java.nio.channels.Channel
    public boolean isOpen() {
        return !this.closed;
    }

    @Override // okio.BufferedSource
    public short j0() throws java.io.EOFException {
        b2(2L);
        return this.bufferField.j0();
    }

    public boolean k(long offset, okio.ByteString bytes, int bytesOffset, int byteCount) {
        kotlin.jvm.internal.Intrinsics.l(bytes, "bytes");
        if (this.closed) {
            throw new java.lang.IllegalStateException("closed");
        }
        if (offset < 0 || bytesOffset < 0 || byteCount < 0 || bytes.B() - bytesOffset < byteCount) {
            return false;
        }
        for (int i = 0; i < byteCount; i++) {
            long j = ((long) i) + offset;
            if (!request(1 + j) || this.bufferField.u(j) != bytes.f(bytesOffset + i)) {
                return false;
            }
        }
        return true;
    }

    @Override // okio.BufferedSource
    public long l0() throws java.io.EOFException {
        b2(8L);
        return this.bufferField.l0();
    }

    @Override // okio.BufferedSource
    public boolean m2() {
        if (this.closed) {
            throw new java.lang.IllegalStateException("closed");
        }
        return this.bufferField.m2() && this.source.read(this.bufferField, 8192L) == -1;
    }

    @Override // okio.BufferedSource
    public long o2() throws java.io.EOFException {
        b2(1L);
        long j = 0;
        while (true) {
            long j2 = j + 1;
            if (!request(j2)) {
                break;
            }
            byte bU = this.bufferField.u(j);
            if ((bU < 48 || bU > 57) && !(j == 0 && bU == 45)) {
                if (j != 0) {
                    break;
                }
                java.lang.StringBuilder sb = new java.lang.StringBuilder();
                sb.append("Expected a digit or '-' but was 0x");
                java.lang.String string = java.lang.Integer.toString(bU, kotlin.text.CharsKt.a(16));
                kotlin.jvm.internal.Intrinsics.k(string, "toString(...)");
                sb.append(string);
                throw new java.lang.NumberFormatException(sb.toString());
            }
            j = j2;
        }
        return this.bufferField.o2();
    }

    @Override // okio.BufferedSource
    public okio.BufferedSource peek() {
        return okio.Okio.d(new okio.PeekSource(this));
    }

    @Override // okio.BufferedSource
    public java.lang.String q0(long byteCount) throws java.io.EOFException {
        b2(byteCount);
        return this.bufferField.q0(byteCount);
    }

    @Override // okio.Source
    public long read(okio.Buffer sink, long byteCount) {
        kotlin.jvm.internal.Intrinsics.l(sink, "sink");
        if (byteCount < 0) {
            throw new java.lang.IllegalArgumentException(("byteCount < 0: " + byteCount).toString());
        }
        if (this.closed) {
            throw new java.lang.IllegalStateException("closed");
        }
        if (this.bufferField.getSize() == 0 && this.source.read(this.bufferField, 8192L) == -1) {
            return -1L;
        }
        return this.bufferField.read(sink, java.lang.Math.min(byteCount, this.bufferField.getSize()));
    }

    @Override // okio.BufferedSource
    public byte readByte() throws java.io.EOFException {
        b2(1L);
        return this.bufferField.readByte();
    }

    @Override // okio.BufferedSource
    public void readFully(byte[] sink) throws java.io.EOFException {
        kotlin.jvm.internal.Intrinsics.l(sink, "sink");
        try {
            b2(sink.length);
            this.bufferField.readFully(sink);
        } catch (java.io.EOFException e) {
            int i = 0;
            while (this.bufferField.getSize() > 0) {
                okio.Buffer buffer = this.bufferField;
                int i2 = buffer.read(sink, i, (int) buffer.getSize());
                if (i2 == -1) {
                    throw new java.lang.AssertionError();
                }
                i += i2;
            }
            throw e;
        }
    }

    @Override // okio.BufferedSource
    public int readInt() throws java.io.EOFException {
        b2(4L);
        return this.bufferField.readInt();
    }

    @Override // okio.BufferedSource
    public long readLong() throws java.io.EOFException {
        b2(8L);
        return this.bufferField.readLong();
    }

    @Override // okio.BufferedSource
    public short readShort() throws java.io.EOFException {
        b2(2L);
        return this.bufferField.readShort();
    }

    @Override // okio.BufferedSource
    public boolean request(long byteCount) {
        if (byteCount < 0) {
            throw new java.lang.IllegalArgumentException(("byteCount < 0: " + byteCount).toString());
        }
        if (this.closed) {
            throw new java.lang.IllegalStateException("closed");
        }
        while (this.bufferField.getSize() < byteCount) {
            if (this.source.read(this.bufferField, 8192L) == -1) {
                return false;
            }
        }
        return true;
    }

    @Override // okio.BufferedSource
    public okio.ByteString s0(long byteCount) throws java.io.EOFException {
        b2(byteCount);
        return this.bufferField.s0(byteCount);
    }

    @Override // okio.BufferedSource
    public void s1(okio.Buffer sink, long byteCount) throws java.io.EOFException {
        kotlin.jvm.internal.Intrinsics.l(sink, "sink");
        try {
            b2(byteCount);
            this.bufferField.s1(sink, byteCount);
        } catch (java.io.EOFException e) {
            sink.L1(this.bufferField);
            throw e;
        }
    }

    @Override // okio.BufferedSource
    public void skip(long byteCount) throws java.io.EOFException {
        if (this.closed) {
            throw new java.lang.IllegalStateException("closed");
        }
        while (byteCount > 0) {
            if (this.bufferField.getSize() == 0 && this.source.read(this.bufferField, 8192L) == -1) {
                throw new java.io.EOFException();
            }
            long jMin = java.lang.Math.min(byteCount, this.bufferField.getSize());
            this.bufferField.skip(jMin);
            byteCount -= jMin;
        }
    }

    @Override // okio.Source
    /* JADX INFO: renamed from: timeout */
    public okio.Timeout getTimeout() {
        return this.source.getTimeout();
    }

    public java.lang.String toString() {
        return "buffer(" + this.source + ')';
    }

    @Override // okio.BufferedSource
    public java.lang.String w1(long limit) throws java.io.EOFException {
        if (limit < 0) {
            throw new java.lang.IllegalArgumentException(("limit < 0: " + limit).toString());
        }
        long j = limit == Long.MAX_VALUE ? Long.MAX_VALUE : limit + 1;
        long jD = d((byte) 10, 0L, j);
        if (jD != -1) {
            return okio.internal.Buffer.d(this.bufferField, jD);
        }
        if (j < Long.MAX_VALUE && request(j) && this.bufferField.u(j - 1) == 13 && request(j + 1) && this.bufferField.u(j) == 10) {
            return okio.internal.Buffer.d(this.bufferField, j);
        }
        okio.Buffer buffer = new okio.Buffer();
        okio.Buffer buffer2 = this.bufferField;
        buffer2.i(buffer, 0L, java.lang.Math.min(32, buffer2.getSize()));
        throw new java.io.EOFException("\\n not found: limit=" + java.lang.Math.min(this.bufferField.getSize(), limit) + " content=" + buffer.N0().k() + (char) 8230);
    }

    @Override // okio.BufferedSource
    public byte[] x0() {
        this.bufferField.L1(this.source);
        return this.bufferField.x0();
    }

    @Override // java.nio.channels.ReadableByteChannel
    public int read(java.nio.ByteBuffer sink) {
        kotlin.jvm.internal.Intrinsics.l(sink, "sink");
        if (this.bufferField.getSize() == 0 && this.source.read(this.bufferField, 8192L) == -1) {
            return -1;
        }
        return this.bufferField.read(sink);
    }
}
