package S4;

import a.AbstractC0872a;
import androidx.media3.common.C;

/* JADX INFO: loaded from: classes3.dex */
public abstract class w extends v {
    public static boolean A0(String str, String prefix, boolean z6) {
        kotlin.jvm.internal.o.h(str, "<this>");
        kotlin.jvm.internal.o.h(prefix, "prefix");
        return !z6 ? str.startsWith(prefix) : v0(0, 0, prefix.length(), str, prefix, z6);
    }

    public static Integer B0(String str) {
        boolean z6;
        int i6;
        int i7;
        kotlin.jvm.internal.o.h(str, "<this>");
        AbstractC0872a.w(10);
        int length = str.length();
        if (length == 0) {
            return null;
        }
        int i8 = 0;
        char cCharAt = str.charAt(0);
        int i9 = kotlin.jvm.internal.o.i(cCharAt, 48);
        int i10 = C.RATE_UNSET_INT;
        if (i9 < 0) {
            i6 = 1;
            if (length == 1) {
                return null;
            }
            if (cCharAt == '+') {
                z6 = false;
            } else {
                if (cCharAt != '-') {
                    return null;
                }
                i10 = Integer.MIN_VALUE;
                z6 = true;
            }
        } else {
            z6 = false;
            i6 = 0;
        }
        int i11 = -59652323;
        while (i6 < length) {
            int iDigit = Character.digit((int) str.charAt(i6), 10);
            if (iDigit < 0) {
                return null;
            }
            if ((i8 < i11 && (i11 != -59652323 || i8 < (i11 = i10 / 10))) || (i7 = i8 * 10) < i10 + iDigit) {
                return null;
            }
            i8 = i7 - iDigit;
            i6++;
        }
        return z6 ? Integer.valueOf(i8) : Integer.valueOf(-i8);
    }

    public static Long C0(String str) {
        boolean z6;
        kotlin.jvm.internal.o.h(str, "<this>");
        AbstractC0872a.w(10);
        int length = str.length();
        if (length == 0) {
            return null;
        }
        int i6 = 0;
        char cCharAt = str.charAt(0);
        int i7 = kotlin.jvm.internal.o.i(cCharAt, 48);
        long j4 = C.TIME_UNSET;
        if (i7 < 0) {
            z6 = true;
            if (length == 1) {
                return null;
            }
            if (cCharAt == '+') {
                z6 = false;
                i6 = 1;
            } else {
                if (cCharAt != '-') {
                    return null;
                }
                j4 = Long.MIN_VALUE;
                i6 = 1;
            }
        } else {
            z6 = false;
        }
        long j6 = 0;
        long j7 = -256204778801521550L;
        while (i6 < length) {
            int iDigit = Character.digit((int) str.charAt(i6), 10);
            if (iDigit < 0) {
                return null;
            }
            if (j6 < j7) {
                if (j7 != -256204778801521550L) {
                    return null;
                }
                j7 = j4 / ((long) 10);
                if (j6 < j7) {
                    return null;
                }
            }
            long j8 = j6 * ((long) 10);
            long j9 = iDigit;
            if (j8 < j4 + j9) {
                return null;
            }
            j6 = j8 - j9;
            i6++;
        }
        return z6 ? Long.valueOf(j6) : Long.valueOf(-j6);
    }

    public static boolean s0(String str, String str2, boolean z6) {
        kotlin.jvm.internal.o.h(str, "<this>");
        return !z6 ? str.endsWith(str2) : v0(str.length() - str2.length(), 0, str2.length(), str, str2, true);
    }

    public static boolean t0(String str, String str2, boolean z6) {
        return str == null ? str2 == null : !z6 ? str.equals(str2) : str.equalsIgnoreCase(str2);
    }

    public static final void u0(String str) {
        throw new NumberFormatException(A0.a.k('\'', "Invalid number format: '", str));
    }

    public static boolean v0(int i6, int i7, int i8, String str, String other, boolean z6) {
        kotlin.jvm.internal.o.h(str, "<this>");
        kotlin.jvm.internal.o.h(other, "other");
        return !z6 ? str.regionMatches(i6, other, i7, i8) : str.regionMatches(z6, i6, other, i7, i8);
    }

    public static String w0(int i6, String str) {
        kotlin.jvm.internal.o.h(str, "<this>");
        if (i6 < 0) {
            throw new IllegalArgumentException(("Count 'n' must be non-negative, but was " + i6 + '.').toString());
        }
        if (i6 == 0) {
            return "";
        }
        int i7 = 1;
        if (i6 == 1) {
            return str.toString();
        }
        int length = str.length();
        if (length == 0) {
            return "";
        }
        if (length == 1) {
            char cCharAt = str.charAt(0);
            char[] cArr = new char[i6];
            for (int i8 = 0; i8 < i6; i8++) {
                cArr[i8] = cCharAt;
            }
            return new String(cArr);
        }
        StringBuilder sb = new StringBuilder(str.length() * i6);
        if (1 <= i6) {
            while (true) {
                sb.append((CharSequence) str);
                if (i7 == i6) {
                    break;
                }
                i7++;
            }
        }
        String string = sb.toString();
        kotlin.jvm.internal.o.e(string);
        return string;
    }

    public static String x0(String str, char c6, char c7) {
        kotlin.jvm.internal.o.h(str, "<this>");
        String strReplace = str.replace(c6, c7);
        kotlin.jvm.internal.o.g(strReplace, "replace(...)");
        return strReplace;
    }

    public static String y0(String str, String str2, String newValue) {
        kotlin.jvm.internal.o.h(str, "<this>");
        kotlin.jvm.internal.o.h(newValue, "newValue");
        int iL0 = p.L0(str, str2, 0, false);
        if (iL0 < 0) {
            return str;
        }
        int length = str2.length();
        int i6 = length >= 1 ? length : 1;
        int length2 = newValue.length() + (str.length() - length);
        if (length2 < 0) {
            throw new OutOfMemoryError();
        }
        StringBuilder sb = new StringBuilder(length2);
        int i7 = 0;
        do {
            sb.append((CharSequence) str, i7, iL0);
            sb.append(newValue);
            i7 = iL0 + length;
            if (iL0 >= str.length()) {
                break;
            }
            iL0 = p.L0(str, str2, iL0 + i6, false);
        } while (iL0 > 0);
        sb.append((CharSequence) str, i7, str.length());
        String string = sb.toString();
        kotlin.jvm.internal.o.g(string, "toString(...)");
        return string;
    }

    public static boolean z0(String str, String str2, int i6, boolean z6) {
        kotlin.jvm.internal.o.h(str, "<this>");
        return !z6 ? str.startsWith(str2, i6) : v0(i6, 0, str2.length(), str, str2, z6);
    }
}
