package Nm6q_10;

import java.security.MessageDigest;
import java.util.Arrays;
/* compiled from: SegmentedByteString.kt */
/* loaded from: classes.dex */
public final class RfjZ_21 extends FSaI4_7 {
    public static final KQgRr5e_0 KQgRr5e_0 = new KQgRr5e_0(null);

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final transient int[] f343KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final transient byte[][] f344KQgRr5e_0;

    /* compiled from: SegmentedByteString.kt */
    /* loaded from: classes.dex */
    public static final class KQgRr5e_0 {
        public KQgRr5e_0() {
        }

        public final FSaI4_7 KQgRr5e_0(X6FRs_4 x6FRs_4, int i) {
            FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(x6FRs_4, "buffer");
            PGPF6hQ_2.KQgRr5e_0(x6FRs_4.PGPF6hQ_2(), 0L, i);
            BVpCZyH_19 bVpCZyH_19 = x6FRs_4.f348KQgRr5e_0;
            int i2 = 0;
            int i3 = 0;
            int i4 = 0;
            while (i3 < i) {
                if (bVpCZyH_19 != null) {
                    int i5 = bVpCZyH_19.QxJ9d_1;
                    int i6 = bVpCZyH_19.KQgRr5e_0;
                    if (i5 != i6) {
                        i3 += i5 - i6;
                        i4++;
                        bVpCZyH_19 = bVpCZyH_19.f318KQgRr5e_0;
                    } else {
                        throw new AssertionError("s.limit == s.pos");
                    }
                } else {
                    FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                    throw null;
                }
            }
            byte[][] bArr = new byte[i4];
            int[] iArr = new int[i4 * 2];
            BVpCZyH_19 bVpCZyH_192 = x6FRs_4.f348KQgRr5e_0;
            int i7 = 0;
            while (i2 < i) {
                if (bVpCZyH_192 != null) {
                    bArr[i7] = bVpCZyH_192.f320KQgRr5e_0;
                    i2 += bVpCZyH_192.QxJ9d_1 - bVpCZyH_192.KQgRr5e_0;
                    iArr[i7] = Math.min(i2, i);
                    iArr[i7 + i4] = bVpCZyH_192.KQgRr5e_0;
                    bVpCZyH_192.f319KQgRr5e_0 = true;
                    i7++;
                    bVpCZyH_192 = bVpCZyH_192.f318KQgRr5e_0;
                } else {
                    FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                    throw null;
                }
            }
            return new RfjZ_21(bArr, iArr, null);
        }

        public /* synthetic */ KQgRr5e_0(FSaI4_7.Xgtqvk_8.QxJ9d_1.Mqv2r_3 mqv2r_3) {
            this();
        }
    }

    public /* synthetic */ RfjZ_21(byte[][] bArr, int[] iArr, FSaI4_7.Xgtqvk_8.QxJ9d_1.Mqv2r_3 mqv2r_3) {
        this(bArr, iArr);
    }

    @Override // Nm6q_10.FSaI4_7
    public final FSaI4_7 Mqv2r_3() {
        return new FSaI4_7(PGPF6hQ_2());
    }

    @Override // Nm6q_10.FSaI4_7
    public String PGPF6hQ_2() {
        return Mqv2r_3().m164PGPF6hQ_2();
    }

    @Override // Nm6q_10.FSaI4_7
    public byte QxJ9d_1(int i) {
        PGPF6hQ_2.KQgRr5e_0(this.f343KQgRr5e_0[this.f344KQgRr5e_0.length - 1], i, 1L);
        int KQgRr5e_02 = KQgRr5e_0(i);
        int i2 = KQgRr5e_02 == 0 ? 0 : this.f343KQgRr5e_0[KQgRr5e_02 - 1];
        int[] iArr = this.f343KQgRr5e_0;
        byte[][] bArr = this.f344KQgRr5e_0;
        return bArr[KQgRr5e_02][(i - i2) + iArr[bArr.length + KQgRr5e_02]];
    }

    @Override // Nm6q_10.FSaI4_7
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (obj instanceof FSaI4_7) {
            FSaI4_7 fSaI4_7 = (FSaI4_7) obj;
            if (fSaI4_7.PGPF6hQ_2() == PGPF6hQ_2() && KQgRr5e_0(0, fSaI4_7, 0, PGPF6hQ_2())) {
                return true;
            }
        }
        return false;
    }

    @Override // Nm6q_10.FSaI4_7
    public int hashCode() {
        int KQgRr5e_02 = KQgRr5e_0();
        if (KQgRr5e_02 != 0) {
            return KQgRr5e_02;
        }
        int length = KQgRr5e_0().length;
        int i = 0;
        int i2 = 0;
        int i3 = 1;
        while (i < length) {
            int i4 = KQgRr5e_0()[length + i];
            int i5 = KQgRr5e_0()[i];
            byte[] bArr = KQgRr5e_0()[i];
            int i6 = (i5 - i2) + i4;
            while (i4 < i6) {
                i3 = (i3 * 31) + bArr[i4];
                i4++;
            }
            i++;
            i2 = i5;
        }
        m159KQgRr5e_0(i3);
        return i3;
    }

    @Override // Nm6q_10.FSaI4_7
    public String toString() {
        return Mqv2r_3().toString();
    }

    public RfjZ_21(byte[][] bArr, int[] iArr) {
        super(FSaI4_7.f326KQgRr5e_0.m162KQgRr5e_0());
        this.f344KQgRr5e_0 = bArr;
        this.f343KQgRr5e_0 = iArr;
    }

    @Override // Nm6q_10.FSaI4_7
    public final byte[][] KQgRr5e_0() {
        return this.f344KQgRr5e_0;
    }

    @Override // Nm6q_10.FSaI4_7
    public FSaI4_7 PGPF6hQ_2() {
        return Mqv2r_3().m163PGPF6hQ_2();
    }

    @Override // Nm6q_10.FSaI4_7
    public final int[] KQgRr5e_0() {
        return this.f343KQgRr5e_0;
    }

    @Override // Nm6q_10.FSaI4_7
    public byte[] PGPF6hQ_2() {
        byte[] bArr = new byte[PGPF6hQ_2()];
        int length = KQgRr5e_0().length;
        int i = 0;
        int i2 = 0;
        int i3 = 0;
        while (i < length) {
            int i4 = KQgRr5e_0()[length + i];
            int i5 = KQgRr5e_0()[i];
            int i6 = i5 - i2;
            QxJ9d_1.KQgRr5e_0(KQgRr5e_0()[i], i4, bArr, i3, i6);
            i3 += i6;
            i++;
            i2 = i5;
        }
        return bArr;
    }

    @Override // Nm6q_10.FSaI4_7
    public String KQgRr5e_0() {
        return Mqv2r_3().m158KQgRr5e_0();
    }

    @Override // Nm6q_10.FSaI4_7
    public FSaI4_7 KQgRr5e_0(String str) {
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(str, "algorithm");
        MessageDigest messageDigest = MessageDigest.getInstance(str);
        int length = KQgRr5e_0().length;
        int i = 0;
        int i2 = 0;
        while (i < length) {
            int i3 = KQgRr5e_0()[length + i];
            int i4 = KQgRr5e_0()[i];
            messageDigest.update(KQgRr5e_0()[i], i3, i4 - i2);
            i++;
            i2 = i4;
        }
        byte[] digest = messageDigest.digest();
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0((Object) digest, "digest.digest()");
        return new FSaI4_7(digest);
    }

    @Override // Nm6q_10.FSaI4_7
    public int QxJ9d_1() {
        return this.f343KQgRr5e_0[this.f344KQgRr5e_0.length - 1];
    }

    @Override // Nm6q_10.FSaI4_7
    public byte[] QxJ9d_1() {
        return PGPF6hQ_2();
    }

    @Override // Nm6q_10.FSaI4_7
    public final int KQgRr5e_0(int i) {
        int binarySearch = Arrays.binarySearch(this.f343KQgRr5e_0, 0, this.f344KQgRr5e_0.length, i + 1);
        return binarySearch >= 0 ? binarySearch : binarySearch ^ (-1);
    }

    @Override // Nm6q_10.FSaI4_7
    public boolean KQgRr5e_0(int i, FSaI4_7 fSaI4_7, int i2, int i3) {
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(fSaI4_7, "other");
        if (i < 0 || i > PGPF6hQ_2() - i3) {
            return false;
        }
        int i4 = i3 + i;
        int KQgRr5e_02 = KQgRr5e_0(i);
        while (i < i4) {
            int i5 = KQgRr5e_02 == 0 ? 0 : KQgRr5e_0()[KQgRr5e_02 - 1];
            int i6 = KQgRr5e_0()[KQgRr5e_0().length + KQgRr5e_02];
            int min = Math.min(i4, (KQgRr5e_0()[KQgRr5e_02] - i5) + i5) - i;
            if (!fSaI4_7.KQgRr5e_0(i2, KQgRr5e_0()[KQgRr5e_02], i6 + (i - i5), min)) {
                return false;
            }
            i2 += min;
            i += min;
            KQgRr5e_02++;
        }
        return true;
    }

    @Override // Nm6q_10.FSaI4_7
    public boolean KQgRr5e_0(int i, byte[] bArr, int i2, int i3) {
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(bArr, "other");
        if (i < 0 || i > PGPF6hQ_2() - i3 || i2 < 0 || i2 > bArr.length - i3) {
            return false;
        }
        int i4 = i3 + i;
        int KQgRr5e_02 = KQgRr5e_0(i);
        while (i < i4) {
            int i5 = KQgRr5e_02 == 0 ? 0 : KQgRr5e_0()[KQgRr5e_02 - 1];
            int i6 = KQgRr5e_0()[KQgRr5e_0().length + KQgRr5e_02];
            int min = Math.min(i4, (KQgRr5e_0()[KQgRr5e_02] - i5) + i5) - i;
            if (!PGPF6hQ_2.KQgRr5e_0(KQgRr5e_0()[KQgRr5e_02], i6 + (i - i5), bArr, i2, min)) {
                return false;
            }
            i2 += min;
            i += min;
            KQgRr5e_02++;
        }
        return true;
    }

    @Override // Nm6q_10.FSaI4_7
    public void KQgRr5e_0(X6FRs_4 x6FRs_4) {
        FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.QxJ9d_1(x6FRs_4, "buffer");
        int length = KQgRr5e_0().length;
        int i = 0;
        int i2 = 0;
        while (i < length) {
            int i3 = KQgRr5e_0()[length + i];
            int i4 = KQgRr5e_0()[i];
            BVpCZyH_19 bVpCZyH_19 = new BVpCZyH_19(KQgRr5e_0()[i], i3, i3 + (i4 - i2), true, false);
            BVpCZyH_19 bVpCZyH_192 = x6FRs_4.f348KQgRr5e_0;
            if (bVpCZyH_192 == null) {
                bVpCZyH_19.f321QxJ9d_1 = bVpCZyH_19;
                bVpCZyH_19.f318KQgRr5e_0 = bVpCZyH_19;
                x6FRs_4.f348KQgRr5e_0 = bVpCZyH_19;
            } else if (bVpCZyH_192 == null) {
                FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                throw null;
            } else {
                BVpCZyH_19 bVpCZyH_193 = bVpCZyH_192.f321QxJ9d_1;
                if (bVpCZyH_193 == null) {
                    FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5.KQgRr5e_0();
                    throw null;
                }
                bVpCZyH_193.KQgRr5e_0(bVpCZyH_19);
            }
            i++;
            i2 = i4;
        }
        x6FRs_4.m182PGPF6hQ_2(x6FRs_4.PGPF6hQ_2() + PGPF6hQ_2());
    }
}
