package Nm6q_10.XDsvEfm_26;

import FSaI4_7.KNBe_11.KNBe_11;
import FSaI4_7.Mqv2r_3;
import FSaI4_7.Xgtqvk_8.QxJ9d_1.IFxWkV_5;
import Nm6q_10.FSaI4_7;
import Nm6q_10.PGPF6hQ_2;
import Nm6q_10.QxJ9d_1;
import java.util.Arrays;
/* compiled from: ByteString.kt */
/* loaded from: classes.dex */
public final class KQgRr5e_0 {

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public static final char[] f349KQgRr5e_0 = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
    public static final FSaI4_7 KQgRr5e_0 = FSaI4_7.KQgRr5e_0.KQgRr5e_0(new byte[0]);

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static final String m184KQgRr5e_0(FSaI4_7 fSaI4_7) {
        IFxWkV_5.QxJ9d_1(fSaI4_7, "$receiver");
        return Nm6q_10.KQgRr5e_0.KQgRr5e_0(fSaI4_7.m162KQgRr5e_0(), null, 1, null);
    }

    public static final String Mqv2r_3(FSaI4_7 fSaI4_7) {
        IFxWkV_5.QxJ9d_1(fSaI4_7, "$receiver");
        String m167QxJ9d_1 = fSaI4_7.m167QxJ9d_1();
        if (m167QxJ9d_1 == null) {
            String KQgRr5e_02 = QxJ9d_1.KQgRr5e_0(fSaI4_7.m168QxJ9d_1());
            fSaI4_7.m160KQgRr5e_0(KQgRr5e_02);
            return KQgRr5e_02;
        }
        return m167QxJ9d_1;
    }

    public static final String PGPF6hQ_2(FSaI4_7 fSaI4_7) {
        IFxWkV_5.QxJ9d_1(fSaI4_7, "$receiver");
        if (fSaI4_7.m162KQgRr5e_0().length == 0) {
            return "[size=0]";
        }
        int KQgRr5e_02 = KQgRr5e_0(fSaI4_7.m162KQgRr5e_0(), 64);
        if (KQgRr5e_02 == -1) {
            if (fSaI4_7.m162KQgRr5e_0().length <= 64) {
                return "[hex=" + fSaI4_7.m164PGPF6hQ_2() + ']';
            }
            return "[size=" + fSaI4_7.m162KQgRr5e_0().length + " hex=" + KQgRr5e_0(fSaI4_7, 0, 64).m164PGPF6hQ_2() + "…]";
        }
        String Mqv2r_32 = fSaI4_7.Mqv2r_3();
        if (Mqv2r_32 != null) {
            String substring = Mqv2r_32.substring(0, KQgRr5e_02);
            IFxWkV_5.KQgRr5e_0((Object) substring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
            String KQgRr5e_03 = KNBe_11.KQgRr5e_0(KNBe_11.KQgRr5e_0(KNBe_11.KQgRr5e_0(substring, "\\", "\\\\", false, 4, (Object) null), "\n", "\\n", false, 4, (Object) null), "\r", "\\r", false, 4, (Object) null);
            if (KQgRr5e_02 < Mqv2r_32.length()) {
                return "[size=" + fSaI4_7.m162KQgRr5e_0().length + " text=" + KQgRr5e_03 + "…]";
            }
            return "[text=" + KQgRr5e_03 + ']';
        }
        throw new Mqv2r_3("null cannot be cast to non-null type java.lang.String");
    }

    /* renamed from: QxJ9d_1  reason: collision with other method in class */
    public static final String m187QxJ9d_1(FSaI4_7 fSaI4_7) {
        byte[] m162KQgRr5e_0;
        IFxWkV_5.QxJ9d_1(fSaI4_7, "$receiver");
        char[] cArr = new char[fSaI4_7.m162KQgRr5e_0().length * 2];
        int i = 0;
        for (byte b : fSaI4_7.m162KQgRr5e_0()) {
            int i2 = i + 1;
            char[] cArr2 = f349KQgRr5e_0;
            cArr[i] = cArr2[(b >> 4) & 15];
            i = i2 + 1;
            cArr[i2] = cArr2[b & 15];
        }
        return new String(cArr);
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static final FSaI4_7 m183KQgRr5e_0(FSaI4_7 fSaI4_7) {
        byte b;
        IFxWkV_5.QxJ9d_1(fSaI4_7, "$receiver");
        for (int i = 0; i < fSaI4_7.m162KQgRr5e_0().length; i++) {
            byte b2 = fSaI4_7.m162KQgRr5e_0()[i];
            byte b3 = (byte) 65;
            if (b2 >= b3 && b2 <= (b = (byte) 90)) {
                byte[] m162KQgRr5e_0 = fSaI4_7.m162KQgRr5e_0();
                byte[] copyOf = Arrays.copyOf(m162KQgRr5e_0, m162KQgRr5e_0.length);
                IFxWkV_5.KQgRr5e_0((Object) copyOf, "java.util.Arrays.copyOf(this, size)");
                copyOf[i] = (byte) (b2 + 32);
                for (int i2 = i + 1; i2 < copyOf.length; i2++) {
                    byte b4 = copyOf[i2];
                    if (b4 >= b3 && b4 <= b) {
                        copyOf[i2] = (byte) (b4 + 32);
                    }
                }
                return new FSaI4_7(copyOf);
            }
        }
        return fSaI4_7;
    }

    /* renamed from: QxJ9d_1  reason: collision with other method in class */
    public static final byte[] m188QxJ9d_1(FSaI4_7 fSaI4_7) {
        IFxWkV_5.QxJ9d_1(fSaI4_7, "$receiver");
        byte[] m162KQgRr5e_0 = fSaI4_7.m162KQgRr5e_0();
        byte[] copyOf = Arrays.copyOf(m162KQgRr5e_0, m162KQgRr5e_0.length);
        IFxWkV_5.KQgRr5e_0((Object) copyOf, "java.util.Arrays.copyOf(this, size)");
        return copyOf;
    }

    public static final int QxJ9d_1(FSaI4_7 fSaI4_7) {
        IFxWkV_5.QxJ9d_1(fSaI4_7, "$receiver");
        int KQgRr5e_02 = fSaI4_7.KQgRr5e_0();
        if (KQgRr5e_02 != 0) {
            return KQgRr5e_02;
        }
        fSaI4_7.m159KQgRr5e_0(Arrays.hashCode(fSaI4_7.m162KQgRr5e_0()));
        return fSaI4_7.KQgRr5e_0();
    }

    public static final FSaI4_7 KQgRr5e_0(FSaI4_7 fSaI4_7, int i, int i2) {
        IFxWkV_5.QxJ9d_1(fSaI4_7, "$receiver");
        if (i >= 0) {
            if (!(i2 <= fSaI4_7.m162KQgRr5e_0().length)) {
                throw new IllegalArgumentException(("endIndex > length(" + fSaI4_7.m162KQgRr5e_0().length + ')').toString());
            }
            int i3 = i2 - i;
            if (i3 >= 0) {
                if (i == 0 && i2 == fSaI4_7.m162KQgRr5e_0().length) {
                    return fSaI4_7;
                }
                byte[] bArr = new byte[i3];
                QxJ9d_1.KQgRr5e_0(fSaI4_7.m162KQgRr5e_0(), i, bArr, 0, i3);
                return new FSaI4_7(bArr);
            }
            throw new IllegalArgumentException("endIndex < beginIndex".toString());
        }
        throw new IllegalArgumentException("beginIndex < 0".toString());
    }

    public static final FSaI4_7 QxJ9d_1(String str) {
        IFxWkV_5.QxJ9d_1(str, "$receiver");
        FSaI4_7 fSaI4_7 = new FSaI4_7(QxJ9d_1.KQgRr5e_0(str));
        fSaI4_7.m160KQgRr5e_0(str);
        return fSaI4_7;
    }

    public static final byte KQgRr5e_0(FSaI4_7 fSaI4_7, int i) {
        IFxWkV_5.QxJ9d_1(fSaI4_7, "$receiver");
        return fSaI4_7.m162KQgRr5e_0()[i];
    }

    public static final int KQgRr5e_0(FSaI4_7 fSaI4_7) {
        IFxWkV_5.QxJ9d_1(fSaI4_7, "$receiver");
        return fSaI4_7.m162KQgRr5e_0().length;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static final byte[] m186KQgRr5e_0(FSaI4_7 fSaI4_7) {
        IFxWkV_5.QxJ9d_1(fSaI4_7, "$receiver");
        return fSaI4_7.m162KQgRr5e_0();
    }

    public static final boolean KQgRr5e_0(FSaI4_7 fSaI4_7, int i, FSaI4_7 fSaI4_72, int i2, int i3) {
        IFxWkV_5.QxJ9d_1(fSaI4_7, "$receiver");
        IFxWkV_5.QxJ9d_1(fSaI4_72, "other");
        return fSaI4_72.KQgRr5e_0(i2, fSaI4_7.m162KQgRr5e_0(), i, i3);
    }

    public static final boolean KQgRr5e_0(FSaI4_7 fSaI4_7, int i, byte[] bArr, int i2, int i3) {
        IFxWkV_5.QxJ9d_1(fSaI4_7, "$receiver");
        IFxWkV_5.QxJ9d_1(bArr, "other");
        return i >= 0 && i <= fSaI4_7.m162KQgRr5e_0().length - i3 && i2 >= 0 && i2 <= bArr.length - i3 && PGPF6hQ_2.KQgRr5e_0(fSaI4_7.m162KQgRr5e_0(), i, bArr, i2, i3);
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public static final boolean m185KQgRr5e_0(FSaI4_7 fSaI4_7, FSaI4_7 fSaI4_72) {
        IFxWkV_5.QxJ9d_1(fSaI4_7, "$receiver");
        IFxWkV_5.QxJ9d_1(fSaI4_72, "prefix");
        return fSaI4_7.KQgRr5e_0(0, fSaI4_72, 0, fSaI4_72.PGPF6hQ_2());
    }

    public static final boolean KQgRr5e_0(FSaI4_7 fSaI4_7, Object obj) {
        IFxWkV_5.QxJ9d_1(fSaI4_7, "$receiver");
        if (obj == fSaI4_7) {
            return true;
        }
        if (obj instanceof FSaI4_7) {
            FSaI4_7 fSaI4_72 = (FSaI4_7) obj;
            if (fSaI4_72.PGPF6hQ_2() == fSaI4_7.m162KQgRr5e_0().length && fSaI4_72.KQgRr5e_0(0, fSaI4_7.m162KQgRr5e_0(), 0, fSaI4_7.m162KQgRr5e_0().length)) {
                return true;
            }
        }
        return false;
    }

    public static final int KQgRr5e_0(FSaI4_7 fSaI4_7, FSaI4_7 fSaI4_72) {
        IFxWkV_5.QxJ9d_1(fSaI4_7, "$receiver");
        IFxWkV_5.QxJ9d_1(fSaI4_72, "other");
        int PGPF6hQ_2 = fSaI4_7.PGPF6hQ_2();
        int PGPF6hQ_22 = fSaI4_72.PGPF6hQ_2();
        int min = Math.min(PGPF6hQ_2, PGPF6hQ_22);
        for (int i = 0; i < min; i++) {
            int KQgRr5e_02 = fSaI4_7.KQgRr5e_0(i) & 255;
            int KQgRr5e_03 = fSaI4_72.KQgRr5e_0(i) & 255;
            if (KQgRr5e_02 != KQgRr5e_03) {
                return KQgRr5e_02 < KQgRr5e_03 ? -1 : 1;
            }
        }
        if (PGPF6hQ_2 == PGPF6hQ_22) {
            return 0;
        }
        return PGPF6hQ_2 < PGPF6hQ_22 ? -1 : 1;
    }

    public static final FSaI4_7 KQgRr5e_0() {
        return KQgRr5e_0;
    }

    public static final FSaI4_7 KQgRr5e_0(byte[] bArr) {
        IFxWkV_5.QxJ9d_1(bArr, "data");
        byte[] copyOf = Arrays.copyOf(bArr, bArr.length);
        IFxWkV_5.KQgRr5e_0((Object) copyOf, "java.util.Arrays.copyOf(this, size)");
        return new FSaI4_7(copyOf);
    }

    public static final FSaI4_7 KQgRr5e_0(String str) {
        IFxWkV_5.QxJ9d_1(str, "$receiver");
        if (str.length() % 2 == 0) {
            int length = str.length() / 2;
            byte[] bArr = new byte[length];
            for (int i = 0; i < length; i++) {
                int i2 = i * 2;
                bArr[i] = (byte) ((KQgRr5e_0(str.charAt(i2)) << 4) + KQgRr5e_0(str.charAt(i2 + 1)));
            }
            return new FSaI4_7(bArr);
        }
        throw new IllegalArgumentException(("Unexpected hex string: " + str).toString());
    }

    public static final int KQgRr5e_0(char c) {
        if ('0' <= c && '9' >= c) {
            return c - '0';
        }
        char c2 = 'a';
        if ('a' > c || 'f' < c) {
            c2 = 'A';
            if ('A' > c || 'F' < c) {
                throw new IllegalArgumentException("Unexpected hex digit: " + c);
            }
        }
        return (c - c2) + 10;
    }

    /* JADX WARN: Code restructure failed: missing block: B:43:0x0068, code lost:
        return -1;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final int KQgRr5e_0(byte[] bArr, int i) {
        int i2;
        int length = bArr.length;
        int i3 = 0;
        int i4 = 0;
        int i5 = 0;
        loop0: while (i3 < length) {
            byte b = bArr[i3];
            if (b >= 0) {
                int i6 = i5 + 1;
                if (i5 == i) {
                    return i4;
                }
                if (b != 10 && b != 13) {
                    if ((b >= 0 && 31 >= b) || (Byte.MAX_VALUE <= b && 159 >= b)) {
                        return -1;
                    }
                }
                if (b == 65533) {
                    return -1;
                }
                i4 += b < 65536 ? 1 : 2;
                i3++;
                while (true) {
                    i5 = i6;
                    if (i3 < length && bArr[i3] >= 0) {
                        int i7 = i3 + 1;
                        byte b2 = bArr[i3];
                        i6 = i5 + 1;
                        if (i5 == i) {
                            return i4;
                        }
                        if (b2 != 10 && b2 != 13) {
                            if ((b2 >= 0 && 31 >= b2) || (Byte.MAX_VALUE <= b2 && 159 >= b2)) {
                                break loop0;
                            }
                        }
                        if (b2 == 65533) {
                            break loop0;
                        }
                        i4 += b2 < 65536 ? 1 : 2;
                        i3 = i7;
                    }
                }
            } else {
                if ((b >> 5) == -2) {
                    int i8 = i3 + 1;
                    if (length <= i8) {
                        if (i5 == i) {
                            return i4;
                        }
                        return -1;
                    }
                    byte b3 = bArr[i3];
                    byte b4 = bArr[i8];
                    if (!((b4 & 192) == 128)) {
                        if (i5 == i) {
                            return i4;
                        }
                        return -1;
                    }
                    int i9 = (b4 ^ 3968) ^ (b3 << 6);
                    if (i9 < 128) {
                        if (i5 == i) {
                            return i4;
                        }
                        return -1;
                    }
                    i2 = i5 + 1;
                    if (i5 == i) {
                        return i4;
                    }
                    if (i9 != 10 && i9 != 13) {
                        if ((i9 >= 0 && 31 >= i9) || (127 <= i9 && 159 >= i9)) {
                            return -1;
                        }
                    }
                    if (i9 == 65533) {
                        return -1;
                    }
                    i4 += i9 < 65536 ? 1 : 2;
                    i3 += 2;
                } else if ((b >> 4) == -2) {
                    int i10 = i3 + 2;
                    if (length <= i10) {
                        if (i5 == i) {
                            return i4;
                        }
                        return -1;
                    }
                    byte b5 = bArr[i3];
                    byte b6 = bArr[i3 + 1];
                    if (!((b6 & 192) == 128)) {
                        if (i5 == i) {
                            return i4;
                        }
                        return -1;
                    }
                    byte b7 = bArr[i10];
                    if (!((b7 & 192) == 128)) {
                        if (i5 == i) {
                            return i4;
                        }
                        return -1;
                    }
                    int i11 = ((b7 ^ (-123008)) ^ (b6 << 6)) ^ (b5 << 12);
                    if (i11 < 2048) {
                        if (i5 == i) {
                            return i4;
                        }
                        return -1;
                    } else if (55296 <= i11 && 57343 >= i11) {
                        if (i5 == i) {
                            return i4;
                        }
                        return -1;
                    } else {
                        i2 = i5 + 1;
                        if (i5 == i) {
                            return i4;
                        }
                        if (i11 != 10 && i11 != 13) {
                            if ((i11 >= 0 && 31 >= i11) || (127 <= i11 && 159 >= i11)) {
                                return -1;
                            }
                        }
                        if (i11 == 65533) {
                            return -1;
                        }
                        i4 += i11 < 65536 ? 1 : 2;
                        i3 += 3;
                    }
                } else if ((b >> 3) != -2) {
                    if (i5 == i) {
                        return i4;
                    }
                    return -1;
                } else {
                    int i12 = i3 + 3;
                    if (length <= i12) {
                        if (i5 == i) {
                            return i4;
                        }
                        return -1;
                    }
                    byte b8 = bArr[i3];
                    byte b9 = bArr[i3 + 1];
                    if (!((b9 & 192) == 128)) {
                        if (i5 == i) {
                            return i4;
                        }
                        return -1;
                    }
                    byte b10 = bArr[i3 + 2];
                    if (!((b10 & 192) == 128)) {
                        if (i5 == i) {
                            return i4;
                        }
                        return -1;
                    }
                    byte b11 = bArr[i12];
                    if (!((b11 & 192) == 128)) {
                        if (i5 == i) {
                            return i4;
                        }
                        return -1;
                    }
                    int i13 = (((b11 ^ 3678080) ^ (b10 << 6)) ^ (b9 << 12)) ^ (b8 << 18);
                    if (i13 > 1114111) {
                        if (i5 == i) {
                            return i4;
                        }
                        return -1;
                    } else if (55296 <= i13 && 57343 >= i13) {
                        if (i5 == i) {
                            return i4;
                        }
                        return -1;
                    } else if (i13 < 65536) {
                        if (i5 == i) {
                            return i4;
                        }
                        return -1;
                    } else {
                        i2 = i5 + 1;
                        if (i5 == i) {
                            return i4;
                        }
                        if (i13 != 10 && i13 != 13) {
                            if ((i13 >= 0 && 31 >= i13) || (127 <= i13 && 159 >= i13)) {
                                return -1;
                            }
                        }
                        if (i13 == 65533) {
                            return -1;
                        }
                        i4 += i13 < 65536 ? 1 : 2;
                        i3 += 4;
                    }
                }
                i5 = i2;
            }
        }
        return i4;
    }
}
