package S4;

import x4.AbstractC3239e;
import x4.C3236b;

/* JADX INFO: loaded from: classes3.dex */
public abstract class d {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final int[] f6269a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final long[] f6270b;

    static {
        int[] iArr = new int[256];
        int i6 = 0;
        for (int i7 = 0; i7 < 256; i7++) {
            iArr[i7] = "0123456789abcdef".charAt(i7 & 15) | ("0123456789abcdef".charAt(i7 >> 4) << '\b');
        }
        f6269a = iArr;
        int[] iArr2 = new int[256];
        for (int i8 = 0; i8 < 256; i8++) {
            iArr2[i8] = "0123456789ABCDEF".charAt(i8 & 15) | ("0123456789ABCDEF".charAt(i8 >> 4) << '\b');
        }
        int[] iArr3 = new int[256];
        for (int i9 = 0; i9 < 256; i9++) {
            iArr3[i9] = -1;
        }
        int i10 = 0;
        int i11 = 0;
        while (i10 < "0123456789abcdef".length()) {
            iArr3["0123456789abcdef".charAt(i10)] = i11;
            i10++;
            i11++;
        }
        int i12 = 0;
        int i13 = 0;
        while (i12 < "0123456789ABCDEF".length()) {
            iArr3["0123456789ABCDEF".charAt(i12)] = i13;
            i12++;
            i13++;
        }
        long[] jArr = new long[256];
        for (int i14 = 0; i14 < 256; i14++) {
            jArr[i14] = -1;
        }
        int i15 = 0;
        int i16 = 0;
        while (i15 < "0123456789abcdef".length()) {
            jArr["0123456789abcdef".charAt(i15)] = i16;
            i15++;
            i16++;
        }
        int i17 = 0;
        while (i6 < "0123456789ABCDEF".length()) {
            jArr["0123456789ABCDEF".charAt(i6)] = i17;
            i6++;
            i17++;
        }
        f6270b = jArr;
    }

    public static final void a(int i6, int i7, String str) {
        int i8 = i7 - i6;
        if (i8 < 1) {
            String strSubstring = str.substring(i6, i7);
            kotlin.jvm.internal.o.g(strSubstring, "substring(...)");
            throw new NumberFormatException("Expected at least 1 hexadecimal digits at index " + i6 + ", but was \"" + strSubstring + "\" of length " + i8);
        }
        if (i8 > 16) {
            int i9 = (i8 + i6) - 16;
            while (i6 < i9) {
                if (str.charAt(i6) != '0') {
                    StringBuilder sbR = com.google.android.recaptcha.internal.a.r(i6, "Expected the hexadecimal digit '0' at index ", ", but was '");
                    sbR.append(str.charAt(i6));
                    sbR.append("'.\nThe result won't fit the type being parsed.");
                    throw new NumberFormatException(sbR.toString());
                }
                i6++;
            }
        }
    }

    public static long b(int i6, int i7, String str) {
        g format = g.f6274d;
        kotlin.jvm.internal.o.h(format, "format");
        C3236b c3236b = AbstractC3239e.Companion;
        int length = str.length();
        c3236b.getClass();
        C3236b.a(i6, i7, length);
        if (format.f6277c.f6273a) {
            a(i6, i7, str);
            return c(i6, i7, str);
        }
        if (i7 - i6 > 0) {
            a(i6, i7, str);
            return c(i6, i7, str);
        }
        String strSubstring = str.substring(i6, i7);
        kotlin.jvm.internal.o.g(strSubstring, "substring(...)");
        throw new NumberFormatException("Expected a hexadecimal number with prefix \"\" and suffix \"\", but was ".concat(strSubstring));
    }

    public static final long c(int i6, int i7, String str) {
        long j4 = 0;
        while (i6 < i7) {
            long j6 = j4 << 4;
            char cCharAt = str.charAt(i6);
            if ((cCharAt >>> '\b') == 0) {
                long j7 = f6270b[cCharAt];
                if (j7 >= 0) {
                    j4 = j6 | j7;
                    i6++;
                }
            }
            StringBuilder sbR = com.google.android.recaptcha.internal.a.r(i6, "Expected a hexadecimal digit at index ", ", but was ");
            sbR.append(str.charAt(i6));
            throw new NumberFormatException(sbR.toString());
        }
        return j4;
    }
}
