package o;

import java.io.EOFException;
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
import java.nio.charset.Charset;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.af, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C0732af implements InterfaceC1687kf, InterfaceC1592jf, Cloneable, ByteChannel {
    public C2496t50 l;
    public long m;

    @Override // o.InterfaceC1687kf
    public final String A(long j) throws EOFException {
        if (j < 0) {
            throw new IllegalArgumentException(AbstractC0126Ew.l("limit < 0: ", j).toString());
        }
        long j2 = j != Long.MAX_VALUE ? j + 1 : Long.MAX_VALUE;
        long j3 = j((byte) 10, 0L, j2);
        if (j3 != -1) {
            return AbstractC0771b.a(j3, this);
        }
        if (j2 < this.m && g(j2 - 1) == 13 && g(j2) == 10) {
            return AbstractC0771b.a(j2, this);
        }
        C0732af c0732af = new C0732af();
        d(c0732af, 0L, Math.min(32, this.m));
        throw new EOFException("\\n not found: limit=" + Math.min(this.m, j) + " content=" + c0732af.i(c0732af.m).c() + (char) 8230);
    }

    @Override // o.T90
    public final long C(long j, C0732af c0732af) {
        if (j < 0) {
            throw new IllegalArgumentException(AbstractC0126Ew.l("byteCount < 0: ", j).toString());
        }
        long j2 = this.m;
        if (j2 == 0) {
            return -1L;
        }
        if (j > j2) {
            j = j2;
        }
        c0732af.e(j, this);
        return j;
    }

    public final void D(C0135Ff c0135Ff) {
        c0135Ff.o(this, c0135Ff.b());
    }

    @Override // o.InterfaceC1592jf
    public final /* bridge */ /* synthetic */ InterfaceC1592jf F(int i, byte[] bArr) {
        z(i, bArr);
        return this;
    }

    public final void G(int i) {
        C2496t50 c2496t50Y = y(1);
        byte[] bArr = c2496t50Y.a;
        int i2 = c2496t50Y.c;
        c2496t50Y.c = i2 + 1;
        bArr[i2] = (byte) i;
        this.m++;
    }

    @Override // o.InterfaceC1687kf
    public final long H(C1632k00 c1632k00) {
        long j = this.m;
        if (j > 0) {
            c1632k00.e(j, this);
        }
        return j;
    }

    @Override // o.InterfaceC1687kf
    public final void I(long j) throws EOFException {
        if (this.m < j) {
            throw new EOFException();
        }
    }

    @Override // o.InterfaceC1592jf
    public final /* bridge */ /* synthetic */ InterfaceC1592jf J(String str) {
        V(str);
        return this;
    }

    @Override // o.InterfaceC1592jf
    public final /* bridge */ /* synthetic */ InterfaceC1592jf K(long j) {
        M(j);
        return this;
    }

    public final void M(long j) {
        if (j == 0) {
            G(48);
            return;
        }
        boolean z = false;
        int i = 1;
        if (j < 0) {
            j = -j;
            if (j < 0) {
                U(0, "-9223372036854775808", 20);
                return;
            }
            z = true;
        }
        if (j >= 100000000) {
            i = j < 1000000000000L ? j < 10000000000L ? j < 1000000000 ? 9 : 10 : j < 100000000000L ? 11 : 12 : j < 1000000000000000L ? j < 10000000000000L ? 13 : j < 100000000000000L ? 14 : 15 : j < 100000000000000000L ? j < 10000000000000000L ? 16 : 17 : j < 1000000000000000000L ? 18 : 19;
        } else if (j >= 10000) {
            i = j < 1000000 ? j < 100000 ? 5 : 6 : j < 10000000 ? 7 : 8;
        } else if (j >= 100) {
            i = j < 1000 ? 3 : 4;
        } else if (j >= 10) {
            i = 2;
        }
        if (z) {
            i++;
        }
        C2496t50 c2496t50Y = y(i);
        byte[] bArr = c2496t50Y.a;
        int i2 = c2496t50Y.c + i;
        while (j != 0) {
            long j2 = 10;
            i2--;
            bArr[i2] = AbstractC0771b.a[(int) (j % j2)];
            j /= j2;
        }
        if (z) {
            bArr[i2 - 1] = 45;
        }
        c2496t50Y.c += i;
        this.m += i;
    }

    @Override // o.InterfaceC1592jf
    public final long N(T90 t90) {
        long j = 0;
        while (true) {
            long jC = t90.C(8192L, this);
            if (jC == -1) {
                return j;
            }
            j += jC;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:33:0x0091  */
    /* JADX WARN: Removed duplicated region for block: B:34:0x009b  */
    /* JADX WARN: Removed duplicated region for block: B:36:0x009f  */
    /* JADX WARN: Removed duplicated region for block: B:44:0x00a3 A[EDGE_INSN: B:44:0x00a3->B:38:0x00a3 BREAK  A[LOOP:0: B:5:0x000c->B:46:?], SYNTHETIC] */
    @Override // o.InterfaceC1687kf
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final long O() throws java.io.EOFException {
        /*
            r15 = this;
            long r0 = r15.m
            r2 = 0
            int r0 = (r0 > r2 ? 1 : (r0 == r2 ? 0 : -1))
            if (r0 == 0) goto Laa
            r0 = 0
            r1 = r0
            r6 = r1
            r4 = r2
        Lc:
            o.t50 r7 = r15.l
            byte[] r8 = r7.a
            int r9 = r7.b
            int r10 = r7.c
        L14:
            if (r9 >= r10) goto L8f
            r11 = r8[r9]
            r12 = 48
            if (r11 < r12) goto L23
            r12 = 57
            if (r11 > r12) goto L23
            int r12 = r11 + (-48)
            goto L38
        L23:
            r12 = 97
            if (r11 < r12) goto L2e
            r12 = 102(0x66, float:1.43E-43)
            if (r11 > r12) goto L2e
            int r12 = r11 + (-87)
            goto L38
        L2e:
            r12 = 65
            if (r11 < r12) goto L67
            r12 = 70
            if (r11 > r12) goto L67
            int r12 = r11 + (-55)
        L38:
            r13 = -1152921504606846976(0xf000000000000000, double:-3.105036184601418E231)
            long r13 = r13 & r4
            int r13 = (r13 > r2 ? 1 : (r13 == r2 ? 0 : -1))
            if (r13 != 0) goto L48
            r11 = 4
            long r4 = r4 << r11
            long r11 = (long) r12
            long r4 = r4 | r11
            int r9 = r9 + 1
            int r1 = r1 + 1
            goto L14
        L48:
            o.af r0 = new o.af
            r0.<init>()
            r0.R(r4)
            r0.G(r11)
            java.lang.NumberFormatException r1 = new java.lang.NumberFormatException
            long r2 = r0.m
            java.nio.charset.Charset r4 = o.AbstractC2355rh.a
            java.lang.String r0 = r0.u(r2, r4)
            java.lang.String r2 = "Number too large: "
            java.lang.String r0 = r2.concat(r0)
            r1.<init>(r0)
            throw r1
        L67:
            r6 = 1
            if (r1 == 0) goto L6b
            goto L8f
        L6b:
            java.lang.NumberFormatException r1 = new java.lang.NumberFormatException
            char[] r2 = o.C1884mi0.c
            int r3 = r11 >> 4
            r3 = r3 & 15
            char r3 = r2[r3]
            r4 = r11 & 15
            char r2 = r2[r4]
            r4 = 2
            char[] r4 = new char[r4]
            r4[r0] = r3
            r4[r6] = r2
            java.lang.String r0 = new java.lang.String
            r0.<init>(r4)
            java.lang.String r2 = "Expected leading [0-9a-fA-F] character but was 0x"
            java.lang.String r0 = r2.concat(r0)
            r1.<init>(r0)
            throw r1
        L8f:
            if (r9 != r10) goto L9b
            o.t50 r8 = r7.a()
            r15.l = r8
            o.AbstractC2781w50.a(r7)
            goto L9d
        L9b:
            r7.b = r9
        L9d:
            if (r6 != 0) goto La3
            o.t50 r7 = r15.l
            if (r7 != 0) goto Lc
        La3:
            long r2 = r15.m
            long r0 = (long) r1
            long r2 = r2 - r0
            r15.m = r2
            return r4
        Laa:
            java.io.EOFException r0 = new java.io.EOFException
            r0.<init>()
            throw r0
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C0732af.O():long");
    }

    @Override // o.InterfaceC1687kf
    public final int P(MU mu) {
        int iB = AbstractC0771b.b(this, mu, false);
        if (iB == -1) {
            return -1;
        }
        skip(mu.l[iB].b());
        return iB;
    }

    @Override // o.InterfaceC1687kf
    public final String Q(Charset charset) {
        return u(this.m, charset);
    }

    public final void R(long j) {
        if (j == 0) {
            G(48);
            return;
        }
        long j2 = (j >>> 1) | j;
        long j3 = j2 | (j2 >>> 2);
        long j4 = j3 | (j3 >>> 4);
        long j5 = j4 | (j4 >>> 8);
        long j6 = j5 | (j5 >>> 16);
        long j7 = j6 | (j6 >>> 32);
        long j8 = j7 - ((j7 >>> 1) & 6148914691236517205L);
        long j9 = ((j8 >>> 2) & 3689348814741910323L) + (j8 & 3689348814741910323L);
        long j10 = ((j9 >>> 4) + j9) & 1085102592571150095L;
        long j11 = j10 + (j10 >>> 8);
        long j12 = j11 + (j11 >>> 16);
        int i = (int) ((((j12 & 63) + ((j12 >>> 32) & 63)) + 3) / 4);
        C2496t50 c2496t50Y = y(i);
        byte[] bArr = c2496t50Y.a;
        int i2 = c2496t50Y.c;
        for (int i3 = (i2 + i) - 1; i3 >= i2; i3--) {
            bArr[i3] = AbstractC0771b.a[(int) (15 & j)];
            j >>>= 4;
        }
        c2496t50Y.c += i;
        this.m += i;
    }

    public final void S(int i) {
        C2496t50 c2496t50Y = y(4);
        byte[] bArr = c2496t50Y.a;
        int i2 = c2496t50Y.c;
        bArr[i2] = (byte) ((i >>> 24) & 255);
        bArr[i2 + 1] = (byte) ((i >>> 16) & 255);
        bArr[i2 + 2] = (byte) ((i >>> 8) & 255);
        bArr[i2 + 3] = (byte) (i & 255);
        c2496t50Y.c = i2 + 4;
        this.m += 4;
    }

    public final void T(int i) {
        C2496t50 c2496t50Y = y(2);
        byte[] bArr = c2496t50Y.a;
        int i2 = c2496t50Y.c;
        bArr[i2] = (byte) ((i >>> 8) & 255);
        bArr[i2 + 1] = (byte) (i & 255);
        c2496t50Y.c = i2 + 2;
        this.m += 2;
    }

    public final void U(int i, String str, int i2) {
        char cCharAt;
        if (i < 0) {
            throw new IllegalArgumentException(AbstractC0126Ew.j(i, "beginIndex < 0: ").toString());
        }
        if (i2 < i) {
            throw new IllegalArgumentException(AbstractC0126Ew.i(i2, i, "endIndex < beginIndex: ", " < ").toString());
        }
        if (i2 > str.length()) {
            StringBuilder sbO = AbstractC0126Ew.o(i2, "endIndex > string.length: ", " > ");
            sbO.append(str.length());
            throw new IllegalArgumentException(sbO.toString().toString());
        }
        while (i < i2) {
            char cCharAt2 = str.charAt(i);
            if (cCharAt2 < 128) {
                C2496t50 c2496t50Y = y(1);
                byte[] bArr = c2496t50Y.a;
                int i3 = c2496t50Y.c - i;
                int iMin = Math.min(i2, 8192 - i3);
                int i4 = i + 1;
                bArr[i + i3] = (byte) cCharAt2;
                while (true) {
                    i = i4;
                    if (i >= iMin || (cCharAt = str.charAt(i)) >= 128) {
                        break;
                    }
                    i4 = i + 1;
                    bArr[i + i3] = (byte) cCharAt;
                }
                int i5 = c2496t50Y.c;
                int i6 = (i3 + i) - i5;
                c2496t50Y.c = i5 + i6;
                this.m += i6;
            } else {
                if (cCharAt2 < 2048) {
                    C2496t50 c2496t50Y2 = y(2);
                    byte[] bArr2 = c2496t50Y2.a;
                    int i7 = c2496t50Y2.c;
                    bArr2[i7] = (byte) ((cCharAt2 >> 6) | 192);
                    bArr2[i7 + 1] = (byte) ((cCharAt2 & '?') | 128);
                    c2496t50Y2.c = i7 + 2;
                    this.m += 2;
                } else if (cCharAt2 < 55296 || cCharAt2 > 57343) {
                    C2496t50 c2496t50Y3 = y(3);
                    byte[] bArr3 = c2496t50Y3.a;
                    int i8 = c2496t50Y3.c;
                    bArr3[i8] = (byte) ((cCharAt2 >> '\f') | 224);
                    bArr3[i8 + 1] = (byte) ((63 & (cCharAt2 >> 6)) | 128);
                    bArr3[i8 + 2] = (byte) ((cCharAt2 & '?') | 128);
                    c2496t50Y3.c = i8 + 3;
                    this.m += 3;
                } else {
                    int i9 = i + 1;
                    char cCharAt3 = i9 < i2 ? str.charAt(i9) : (char) 0;
                    if (cCharAt2 > 56319 || 56320 > cCharAt3 || cCharAt3 >= 57344) {
                        G(63);
                        i = i9;
                    } else {
                        int i10 = (((cCharAt2 & 1023) << 10) | (cCharAt3 & 1023)) + 65536;
                        C2496t50 c2496t50Y4 = y(4);
                        byte[] bArr4 = c2496t50Y4.a;
                        int i11 = c2496t50Y4.c;
                        bArr4[i11] = (byte) ((i10 >> 18) | 240);
                        bArr4[i11 + 1] = (byte) (((i10 >> 12) & 63) | 128);
                        bArr4[i11 + 2] = (byte) (((i10 >> 6) & 63) | 128);
                        bArr4[i11 + 3] = (byte) ((i10 & 63) | 128);
                        c2496t50Y4.c = i11 + 4;
                        this.m += 4;
                        i += 2;
                    }
                }
                i++;
            }
        }
    }

    public final void V(String str) {
        U(0, str, str.length());
    }

    public final void W(int i) {
        String str;
        if (i < 128) {
            G(i);
            return;
        }
        if (i < 2048) {
            C2496t50 c2496t50Y = y(2);
            byte[] bArr = c2496t50Y.a;
            int i2 = c2496t50Y.c;
            bArr[i2] = (byte) ((i >> 6) | 192);
            bArr[i2 + 1] = (byte) ((i & 63) | 128);
            c2496t50Y.c = i2 + 2;
            this.m += 2;
            return;
        }
        if (55296 <= i && i < 57344) {
            G(63);
            return;
        }
        if (i < 65536) {
            C2496t50 c2496t50Y2 = y(3);
            byte[] bArr2 = c2496t50Y2.a;
            int i3 = c2496t50Y2.c;
            bArr2[i3] = (byte) ((i >> 12) | 224);
            bArr2[i3 + 1] = (byte) (((i >> 6) & 63) | 128);
            bArr2[i3 + 2] = (byte) ((i & 63) | 128);
            c2496t50Y2.c = i3 + 3;
            this.m += 3;
            return;
        }
        if (i <= 1114111) {
            C2496t50 c2496t50Y3 = y(4);
            byte[] bArr3 = c2496t50Y3.a;
            int i4 = c2496t50Y3.c;
            bArr3[i4] = (byte) ((i >> 18) | 240);
            bArr3[i4 + 1] = (byte) (((i >> 12) & 63) | 128);
            bArr3[i4 + 2] = (byte) (((i >> 6) & 63) | 128);
            bArr3[i4 + 3] = (byte) ((i & 63) | 128);
            c2496t50Y3.c = i4 + 4;
            this.m += 4;
            return;
        }
        StringBuilder sb = new StringBuilder("Unexpected code point: 0x");
        if (i != 0) {
            char[] cArr = C1884mi0.c;
            char[] cArr2 = {cArr[(i >> 28) & 15], cArr[(i >> 24) & 15], cArr[(i >> 20) & 15], cArr[(i >> 16) & 15], cArr[(i >> 12) & 15], cArr[(i >> 8) & 15], cArr[(i >> 4) & 15], cArr[i & 15]};
            int i5 = 0;
            while (i5 < 8 && cArr2[i5] == '0') {
                i5++;
            }
            AbstractC0752ap.u(i5, 8, 8);
            str = new String(cArr2, i5, 8 - i5);
        } else {
            str = "0";
        }
        sb.append(str);
        throw new IllegalArgumentException(sb.toString());
    }

    @Override // o.T90
    public final Cf0 a() {
        return Cf0.d;
    }

    public final void b() {
        skip(this.m);
    }

    public final long c() {
        long j = this.m;
        if (j == 0) {
            return 0L;
        }
        C2496t50 c2496t50 = this.l.g;
        return (c2496t50.c >= 8192 || !c2496t50.e) ? j : j - (r3 - c2496t50.b);
    }

    public final Object clone() {
        C0732af c0732af = new C0732af();
        if (this.m == 0) {
            return c0732af;
        }
        C2496t50 c2496t50 = this.l;
        C2496t50 c2496t50C = c2496t50.c();
        c0732af.l = c2496t50C;
        c2496t50C.g = c2496t50C;
        c2496t50C.f = c2496t50C;
        for (C2496t50 c2496t502 = c2496t50.f; c2496t502 != c2496t50; c2496t502 = c2496t502.f) {
            c2496t50C.g.b(c2496t502.c());
        }
        c0732af.m = this.m;
        return c0732af;
    }

    public final void d(C0732af c0732af, long j, long j2) {
        long j3 = j;
        F3.l(this.m, j3, j2);
        if (j2 == 0) {
            return;
        }
        c0732af.m += j2;
        C2496t50 c2496t50 = this.l;
        while (true) {
            long j4 = c2496t50.c - c2496t50.b;
            if (j3 < j4) {
                break;
            }
            j3 -= j4;
            c2496t50 = c2496t50.f;
        }
        C2496t50 c2496t502 = c2496t50;
        long j5 = j2;
        while (j5 > 0) {
            C2496t50 c2496t50C = c2496t502.c();
            int i = c2496t50C.b + ((int) j3);
            c2496t50C.b = i;
            c2496t50C.c = Math.min(i + ((int) j5), c2496t50C.c);
            C2496t50 c2496t503 = c0732af.l;
            if (c2496t503 == null) {
                c2496t50C.g = c2496t50C;
                c2496t50C.f = c2496t50C;
                c0732af.l = c2496t50C;
            } else {
                c2496t503.g.b(c2496t50C);
            }
            j5 -= c2496t50C.c - c2496t50C.b;
            c2496t502 = c2496t502.f;
            j3 = 0;
        }
    }

    @Override // o.R80
    public final void e(long j, C0732af c0732af) {
        C2496t50 c2496t50B;
        if (c0732af == this) {
            throw new IllegalArgumentException("source == this");
        }
        F3.l(c0732af.m, 0L, j);
        while (j > 0) {
            C2496t50 c2496t50 = c0732af.l;
            int i = c2496t50.c - c2496t50.b;
            if (j < i) {
                C2496t50 c2496t502 = this.l;
                C2496t50 c2496t503 = c2496t502 != null ? c2496t502.g : null;
                if (c2496t503 != null && c2496t503.e) {
                    if ((c2496t503.c + j) - (c2496t503.d ? 0 : c2496t503.b) <= 8192) {
                        c2496t50.d(c2496t503, (int) j);
                        c0732af.m -= j;
                        this.m += j;
                        return;
                    }
                }
                int i2 = (int) j;
                if (i2 <= 0 || i2 > i) {
                    throw new IllegalArgumentException("byteCount out of range");
                }
                if (i2 >= 1024) {
                    c2496t50B = c2496t50.c();
                } else {
                    c2496t50B = AbstractC2781w50.b();
                    byte[] bArr = c2496t50.a;
                    byte[] bArr2 = c2496t50B.a;
                    int i3 = c2496t50.b;
                    AbstractC2219q9.N(bArr, bArr2, i3, i3 + i2);
                }
                c2496t50B.c = c2496t50B.b + i2;
                c2496t50.b += i2;
                c2496t50.g.b(c2496t50B);
                c0732af.l = c2496t50B;
            }
            C2496t50 c2496t504 = c0732af.l;
            long j2 = c2496t504.c - c2496t504.b;
            c0732af.l = c2496t504.a();
            C2496t50 c2496t505 = this.l;
            if (c2496t505 == null) {
                this.l = c2496t504;
                c2496t504.g = c2496t504;
                c2496t504.f = c2496t504;
            } else {
                c2496t505.g.b(c2496t504);
                C2496t50 c2496t506 = c2496t504.g;
                if (c2496t506 == c2496t504) {
                    throw new IllegalStateException("cannot compact");
                }
                if (c2496t506.e) {
                    int i4 = c2496t504.c - c2496t504.b;
                    if (i4 <= (8192 - c2496t506.c) + (c2496t506.d ? 0 : c2496t506.b)) {
                        c2496t504.d(c2496t506, i4);
                        c2496t504.a();
                        AbstractC2781w50.a(c2496t504);
                    }
                }
            }
            c0732af.m -= j2;
            this.m += j2;
            j -= j2;
        }
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof C0732af)) {
            return false;
        }
        long j = this.m;
        C0732af c0732af = (C0732af) obj;
        if (j != c0732af.m) {
            return false;
        }
        if (j == 0) {
            return true;
        }
        C2496t50 c2496t50 = this.l;
        C2496t50 c2496t502 = c0732af.l;
        int i = c2496t50.b;
        int i2 = c2496t502.b;
        long j2 = 0;
        while (j2 < this.m) {
            long jMin = Math.min(c2496t50.c - i, c2496t502.c - i2);
            long j3 = 0;
            while (j3 < jMin) {
                int i3 = i + 1;
                int i4 = i2 + 1;
                if (c2496t50.a[i] != c2496t502.a[i2]) {
                    return false;
                }
                j3++;
                i = i3;
                i2 = i4;
            }
            if (i == c2496t50.c) {
                c2496t50 = c2496t50.f;
                i = c2496t50.b;
            }
            if (i2 == c2496t502.c) {
                c2496t502 = c2496t502.f;
                i2 = c2496t502.b;
            }
            j2 += jMin;
        }
        return true;
    }

    public final boolean f() {
        return this.m == 0;
    }

    public final byte g(long j) {
        F3.l(this.m, j, 1L);
        C2496t50 c2496t50 = this.l;
        c2496t50.getClass();
        long j2 = this.m;
        if (j2 - j < j) {
            while (j2 > j) {
                c2496t50 = c2496t50.g;
                j2 -= c2496t50.c - c2496t50.b;
            }
            return c2496t50.a[(int) ((c2496t50.b + j) - j2)];
        }
        long j3 = 0;
        while (true) {
            int i = c2496t50.c;
            int i2 = c2496t50.b;
            long j4 = (i - i2) + j3;
            if (j4 > j) {
                return c2496t50.a[(int) ((i2 + j) - j3)];
            }
            c2496t50 = c2496t50.f;
            j3 = j4;
        }
    }

    @Override // o.InterfaceC1592jf
    public final /* bridge */ /* synthetic */ InterfaceC1592jf h(long j) {
        R(j);
        return this;
    }

    public final int hashCode() {
        C2496t50 c2496t50 = this.l;
        if (c2496t50 == null) {
            return 0;
        }
        int i = 1;
        do {
            int i2 = c2496t50.c;
            for (int i3 = c2496t50.b; i3 < i2; i3++) {
                i = (i * 31) + c2496t50.a[i3];
            }
            c2496t50 = c2496t50.f;
        } while (c2496t50 != this.l);
        return i;
    }

    @Override // o.InterfaceC1687kf
    public final C0135Ff i(long j) throws EOFException {
        if (j < 0 || j > 2147483647L) {
            throw new IllegalArgumentException(AbstractC0126Ew.l("byteCount: ", j).toString());
        }
        if (this.m < j) {
            throw new EOFException();
        }
        if (j < 4096) {
            return new C0135Ff(q(j));
        }
        C0135Ff c0135FfW = w((int) j);
        skip(j);
        return c0135FfW;
    }

    @Override // java.nio.channels.Channel
    public final boolean isOpen() {
        return true;
    }

    public final long j(byte b, long j, long j2) {
        C2496t50 c2496t50;
        long j3 = 0;
        if (0 > j || j > j2) {
            throw new IllegalArgumentException(("size=" + this.m + " fromIndex=" + j + " toIndex=" + j2).toString());
        }
        long j4 = this.m;
        if (j2 > j4) {
            j2 = j4;
        }
        if (j == j2 || (c2496t50 = this.l) == null) {
            return -1L;
        }
        if (j4 - j < j) {
            while (j4 > j) {
                c2496t50 = c2496t50.g;
                j4 -= c2496t50.c - c2496t50.b;
            }
            while (j4 < j2) {
                byte[] bArr = c2496t50.a;
                int iMin = (int) Math.min(c2496t50.c, (c2496t50.b + j2) - j4);
                for (int i = (int) ((c2496t50.b + j) - j4); i < iMin; i++) {
                    if (bArr[i] == b) {
                        return (i - c2496t50.b) + j4;
                    }
                }
                j4 += c2496t50.c - c2496t50.b;
                c2496t50 = c2496t50.f;
                j = j4;
            }
            return -1L;
        }
        while (true) {
            long j5 = (c2496t50.c - c2496t50.b) + j3;
            if (j5 > j) {
                break;
            }
            c2496t50 = c2496t50.f;
            j3 = j5;
        }
        while (j3 < j2) {
            byte[] bArr2 = c2496t50.a;
            int iMin2 = (int) Math.min(c2496t50.c, (c2496t50.b + j2) - j3);
            for (int i2 = (int) ((c2496t50.b + j) - j3); i2 < iMin2; i2++) {
                if (bArr2[i2] == b) {
                    return (i2 - c2496t50.b) + j3;
                }
            }
            j3 += c2496t50.c - c2496t50.b;
            c2496t50 = c2496t50.f;
            j = j3;
        }
        return -1L;
    }

    public final long l(C0135Ff c0135Ff) {
        int i;
        int i2;
        C2496t50 c2496t50 = this.l;
        if (c2496t50 == null) {
            return -1L;
        }
        long j = this.m;
        long j2 = 0;
        if (j < 0) {
            while (j > 0) {
                c2496t50 = c2496t50.g;
                j -= c2496t50.c - c2496t50.b;
            }
            if (c0135Ff.b() == 2) {
                byte bG = c0135Ff.g(0);
                byte bG2 = c0135Ff.g(1);
                while (j < this.m) {
                    byte[] bArr = c2496t50.a;
                    i = (int) ((c2496t50.b + j2) - j);
                    int i3 = c2496t50.c;
                    while (i < i3) {
                        byte b = bArr[i];
                        if (b == bG || b == bG2) {
                            i2 = c2496t50.b;
                        } else {
                            i++;
                        }
                    }
                    j2 = (c2496t50.c - c2496t50.b) + j;
                    c2496t50 = c2496t50.f;
                    j = j2;
                }
                return -1L;
            }
            byte[] bArrF = c0135Ff.f();
            while (j < this.m) {
                byte[] bArr2 = c2496t50.a;
                i = (int) ((c2496t50.b + j2) - j);
                int i4 = c2496t50.c;
                while (i < i4) {
                    byte b2 = bArr2[i];
                    for (byte b3 : bArrF) {
                        if (b2 == b3) {
                            i2 = c2496t50.b;
                        }
                    }
                    i++;
                }
                j2 = (c2496t50.c - c2496t50.b) + j;
                c2496t50 = c2496t50.f;
                j = j2;
            }
            return -1L;
        }
        j = 0;
        while (true) {
            long j3 = (c2496t50.c - c2496t50.b) + j;
            if (j3 > 0) {
                break;
            }
            c2496t50 = c2496t50.f;
            j = j3;
        }
        if (c0135Ff.b() == 2) {
            byte bG3 = c0135Ff.g(0);
            byte bG4 = c0135Ff.g(1);
            while (j < this.m) {
                byte[] bArr3 = c2496t50.a;
                i = (int) ((c2496t50.b + j2) - j);
                int i5 = c2496t50.c;
                while (i < i5) {
                    byte b4 = bArr3[i];
                    if (b4 == bG3 || b4 == bG4) {
                        i2 = c2496t50.b;
                    } else {
                        i++;
                    }
                }
                j2 = (c2496t50.c - c2496t50.b) + j;
                c2496t50 = c2496t50.f;
                j = j2;
            }
            return -1L;
        }
        byte[] bArrF2 = c0135Ff.f();
        while (j < this.m) {
            byte[] bArr4 = c2496t50.a;
            i = (int) ((c2496t50.b + j2) - j);
            int i6 = c2496t50.c;
            while (i < i6) {
                byte b5 = bArr4[i];
                for (byte b6 : bArrF2) {
                    if (b5 == b6) {
                        i2 = c2496t50.b;
                    }
                }
                i++;
            }
            j2 = (c2496t50.c - c2496t50.b) + j;
            c2496t50 = c2496t50.f;
            j = j2;
        }
        return -1L;
        return (i - i2) + j;
    }

    public final boolean m(C0135Ff c0135Ff) {
        int iB = c0135Ff.b();
        if (iB >= 0 && this.m >= iB && c0135Ff.b() >= iB) {
            for (int i = 0; i < iB; i++) {
                if (g(i) == c0135Ff.g(i)) {
                }
            }
            return true;
        }
        return false;
    }

    @Override // o.InterfaceC1687kf
    public final boolean n(long j) {
        return this.m >= j;
    }

    @Override // o.InterfaceC1592jf
    public final /* bridge */ /* synthetic */ InterfaceC1592jf o(C0135Ff c0135Ff) {
        D(c0135Ff);
        return this;
    }

    public final byte[] q(long j) throws EOFException {
        if (j < 0 || j > 2147483647L) {
            throw new IllegalArgumentException(AbstractC0126Ew.l("byteCount: ", j).toString());
        }
        if (this.m < j) {
            throw new EOFException();
        }
        int i = (int) j;
        byte[] bArr = new byte[i];
        int i2 = 0;
        while (i2 < i) {
            int i3 = read(bArr, i2, i - i2);
            if (i3 == -1) {
                throw new EOFException();
            }
            i2 += i3;
        }
        return bArr;
    }

    @Override // java.nio.channels.ReadableByteChannel
    public final int read(ByteBuffer byteBuffer) {
        C2496t50 c2496t50 = this.l;
        if (c2496t50 == null) {
            return -1;
        }
        int iMin = Math.min(byteBuffer.remaining(), c2496t50.c - c2496t50.b);
        byteBuffer.put(c2496t50.a, c2496t50.b, iMin);
        int i = c2496t50.b + iMin;
        c2496t50.b = i;
        this.m -= iMin;
        if (i == c2496t50.c) {
            this.l = c2496t50.a();
            AbstractC2781w50.a(c2496t50);
        }
        return iMin;
    }

    @Override // o.InterfaceC1687kf
    public final byte readByte() throws EOFException {
        long j = this.m;
        if (j == 0) {
            throw new EOFException();
        }
        C2496t50 c2496t50 = this.l;
        int i = c2496t50.b;
        int i2 = c2496t50.c;
        int i3 = i + 1;
        byte b = c2496t50.a[i];
        this.m = j - 1;
        if (i3 != i2) {
            c2496t50.b = i3;
            return b;
        }
        this.l = c2496t50.a();
        AbstractC2781w50.a(c2496t50);
        return b;
    }

    @Override // o.InterfaceC1687kf
    public final int readInt() throws EOFException {
        long j = this.m;
        if (j < 4) {
            throw new EOFException();
        }
        C2496t50 c2496t50 = this.l;
        int i = c2496t50.b;
        int i2 = c2496t50.c;
        if (i2 - i < 4) {
            return ((readByte() & 255) << 24) | ((readByte() & 255) << 16) | ((readByte() & 255) << 8) | (readByte() & 255);
        }
        byte[] bArr = c2496t50.a;
        int i3 = i + 3;
        int i4 = ((bArr[i + 1] & 255) << 16) | ((bArr[i] & 255) << 24) | ((bArr[i + 2] & 255) << 8);
        int i5 = i + 4;
        int i6 = (bArr[i3] & 255) | i4;
        this.m = j - 4;
        if (i5 != i2) {
            c2496t50.b = i5;
            return i6;
        }
        this.l = c2496t50.a();
        AbstractC2781w50.a(c2496t50);
        return i6;
    }

    @Override // o.InterfaceC1687kf
    public final short readShort() throws EOFException {
        long j = this.m;
        if (j < 2) {
            throw new EOFException();
        }
        C2496t50 c2496t50 = this.l;
        int i = c2496t50.b;
        int i2 = c2496t50.c;
        if (i2 - i < 2) {
            return (short) (((readByte() & 255) << 8) | (readByte() & 255));
        }
        byte[] bArr = c2496t50.a;
        int i3 = i + 1;
        int i4 = (bArr[i] & 255) << 8;
        int i5 = i + 2;
        int i6 = (bArr[i3] & 255) | i4;
        this.m = j - 2;
        if (i5 == i2) {
            this.l = c2496t50.a();
            AbstractC2781w50.a(c2496t50);
        } else {
            c2496t50.b = i5;
        }
        return (short) i6;
    }

    @Override // o.InterfaceC1687kf
    public final String s() {
        return A(Long.MAX_VALUE);
    }

    @Override // o.InterfaceC1687kf
    public final void skip(long j) {
        while (j > 0) {
            C2496t50 c2496t50 = this.l;
            if (c2496t50 == null) {
                throw new EOFException();
            }
            int iMin = (int) Math.min(j, c2496t50.c - c2496t50.b);
            long j2 = iMin;
            this.m -= j2;
            j -= j2;
            int i = c2496t50.b + iMin;
            c2496t50.b = i;
            if (i == c2496t50.c) {
                this.l = c2496t50.a();
                AbstractC2781w50.a(c2496t50);
            }
        }
    }

    @Override // o.InterfaceC1687kf
    public final int t() throws EOFException {
        int i = readInt();
        return ((i & 255) << 24) | (((-16777216) & i) >>> 24) | ((16711680 & i) >>> 8) | ((65280 & i) << 8);
    }

    public final String toString() {
        long j = this.m;
        if (j <= 2147483647L) {
            return w((int) j).toString();
        }
        throw new IllegalStateException(("size > Int.MAX_VALUE: " + this.m).toString());
    }

    public final String u(long j, Charset charset) throws EOFException {
        if (j < 0 || j > 2147483647L) {
            throw new IllegalArgumentException(AbstractC0126Ew.l("byteCount: ", j).toString());
        }
        if (this.m < j) {
            throw new EOFException();
        }
        if (j == 0) {
            return "";
        }
        C2496t50 c2496t50 = this.l;
        int i = c2496t50.b;
        if (i + j > c2496t50.c) {
            return new String(q(j), charset);
        }
        int i2 = (int) j;
        String str = new String(c2496t50.a, i, i2, charset);
        int i3 = c2496t50.b + i2;
        c2496t50.b = i3;
        this.m -= j;
        if (i3 == c2496t50.c) {
            this.l = c2496t50.a();
            AbstractC2781w50.a(c2496t50);
        }
        return str;
    }

    public final C0135Ff w(int i) {
        if (i == 0) {
            return C0135Ff.f122o;
        }
        F3.l(this.m, 0L, i);
        C2496t50 c2496t50 = this.l;
        int i2 = 0;
        int i3 = 0;
        int i4 = 0;
        while (i3 < i) {
            int i5 = c2496t50.c;
            int i6 = c2496t50.b;
            if (i5 == i6) {
                throw new AssertionError("s.limit == s.pos");
            }
            i3 += i5 - i6;
            i4++;
            c2496t50 = c2496t50.f;
        }
        byte[][] bArr = new byte[i4][];
        int[] iArr = new int[i4 * 2];
        C2496t50 c2496t502 = this.l;
        int i7 = 0;
        while (i2 < i) {
            bArr[i7] = c2496t502.a;
            i2 += c2496t502.c - c2496t502.b;
            iArr[i7] = Math.min(i2, i);
            iArr[i7 + i4] = c2496t502.b;
            c2496t502.d = true;
            i7++;
            c2496t502 = c2496t502.f;
        }
        return new C2876x50(bArr, iArr);
    }

    @Override // java.nio.channels.WritableByteChannel
    public final int write(ByteBuffer byteBuffer) {
        int iRemaining = byteBuffer.remaining();
        int i = iRemaining;
        while (i > 0) {
            C2496t50 c2496t50Y = y(1);
            int iMin = Math.min(i, 8192 - c2496t50Y.c);
            byteBuffer.get(c2496t50Y.a, c2496t50Y.c, iMin);
            i -= iMin;
            c2496t50Y.c += iMin;
        }
        this.m += iRemaining;
        return iRemaining;
    }

    @Override // o.InterfaceC1592jf
    public final /* bridge */ /* synthetic */ InterfaceC1592jf writeByte(int i) {
        G(i);
        return this;
    }

    @Override // o.InterfaceC1592jf
    public final /* bridge */ /* synthetic */ InterfaceC1592jf writeInt(int i) {
        S(i);
        return this;
    }

    @Override // o.InterfaceC1592jf
    public final /* bridge */ /* synthetic */ InterfaceC1592jf writeShort(int i) {
        T(i);
        return this;
    }

    @Override // o.InterfaceC1687kf
    public final short x() throws EOFException {
        short s = readShort();
        return (short) (((s & 255) << 8) | ((65280 & s) >>> 8));
    }

    public final C2496t50 y(int i) {
        if (i < 1 || i > 8192) {
            throw new IllegalArgumentException("unexpected capacity");
        }
        C2496t50 c2496t50 = this.l;
        if (c2496t50 == null) {
            C2496t50 c2496t50B = AbstractC2781w50.b();
            this.l = c2496t50B;
            c2496t50B.g = c2496t50B;
            c2496t50B.f = c2496t50B;
            return c2496t50B;
        }
        C2496t50 c2496t502 = c2496t50.g;
        if (c2496t502.c + i <= 8192 && c2496t502.e) {
            return c2496t502;
        }
        C2496t50 c2496t50B2 = AbstractC2781w50.b();
        c2496t502.b(c2496t50B2);
        return c2496t50B2;
    }

    public final void z(int i, byte[] bArr) {
        int i2 = 0;
        long j = i;
        F3.l(bArr.length, 0, j);
        while (i2 < i) {
            C2496t50 c2496t50Y = y(1);
            int iMin = Math.min(i - i2, 8192 - c2496t50Y.c);
            int i3 = i2 + iMin;
            System.arraycopy(bArr, i2, c2496t50Y.a, c2496t50Y.c, i3 - i2);
            c2496t50Y.c += iMin;
            i2 = i3;
        }
        this.m += j;
    }

    @Override // o.InterfaceC1592jf
    public final InterfaceC1592jf write(byte[] bArr) {
        z(bArr.length, bArr);
        return this;
    }

    public final int read(byte[] bArr, int i, int i2) {
        F3.l(bArr.length, i, i2);
        C2496t50 c2496t50 = this.l;
        if (c2496t50 == null) {
            return -1;
        }
        int iMin = Math.min(i2, c2496t50.c - c2496t50.b);
        byte[] bArr2 = c2496t50.a;
        int i3 = c2496t50.b;
        System.arraycopy(bArr2, i3, bArr, i, (i3 + iMin) - i3);
        int i4 = c2496t50.b + iMin;
        c2496t50.b = i4;
        this.m -= iMin;
        if (i4 == c2496t50.c) {
            this.l = c2496t50.a();
            AbstractC2781w50.a(c2496t50);
        }
        return iMin;
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable, java.nio.channels.Channel, o.R80
    public final void close() {
    }

    @Override // o.InterfaceC1592jf, o.R80, java.io.Flushable
    public final void flush() {
    }

    @Override // o.InterfaceC1687kf
    public final C0732af v() {
        return this;
    }
}
