package h.c0;

import h.x.d.x;
import java.util.Comparator;

/* JADX INFO: Access modifiers changed from: package-private */
/* JADX INFO: compiled from: StringsJVM.kt */
/* JADX INFO: loaded from: classes.dex */
public class p extends o {
    public static byte[] j(String str) {
        h.x.d.k.d(str, "<this>");
        byte[] bytes = str.getBytes(d.b);
        h.x.d.k.c(bytes, "this as java.lang.String).getBytes(charset)");
        return bytes;
    }

    public static final boolean k(String str, String str2, boolean z) {
        h.x.d.k.d(str, "<this>");
        h.x.d.k.d(str2, "suffix");
        return !z ? str.endsWith(str2) : p(str, str.length() - str2.length(), str2, 0, str2.length(), true);
    }

    public static /* synthetic */ boolean l(String str, String str2, boolean z, int i2, Object obj) {
        if ((i2 & 2) != 0) {
            z = false;
        }
        return k(str, str2, z);
    }

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

    public static Comparator<String> n(x xVar) {
        h.x.d.k.d(xVar, "<this>");
        Comparator<String> comparator = String.CASE_INSENSITIVE_ORDER;
        h.x.d.k.c(comparator, "CASE_INSENSITIVE_ORDER");
        return comparator;
    }

    /* JADX WARN: Removed duplicated region for block: B:21:? A[RETURN, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static final boolean o(java.lang.CharSequence r4) {
        /*
            java.lang.String r0 = "<this>"
            h.x.d.k.d(r4, r0)
            int r0 = r4.length()
            r1 = 0
            r2 = 1
            if (r0 == 0) goto L3e
            h.z.h r0 = h.c0.q.I(r4)
            boolean r3 = r0 instanceof java.util.Collection
            if (r3 == 0) goto L20
            r3 = r0
            java.util.Collection r3 = (java.util.Collection) r3
            boolean r3 = r3.isEmpty()
            if (r3 == 0) goto L20
        L1e:
            r4 = 1
            goto L3c
        L20:
            java.util.Iterator r0 = r0.iterator()
        L24:
            boolean r3 = r0.hasNext()
            if (r3 == 0) goto L1e
            r3 = r0
            h.s.z r3 = (h.s.z) r3
            int r3 = r3.a()
            char r3 = r4.charAt(r3)
            boolean r3 = h.c0.b.c(r3)
            if (r3 != 0) goto L24
            r4 = 0
        L3c:
            if (r4 == 0) goto L3f
        L3e:
            r1 = 1
        L3f:
            return r1
        */
        throw new UnsupportedOperationException("Method not decompiled: h.c0.p.o(java.lang.CharSequence):boolean");
    }

    public static final boolean p(String str, int i2, String str2, int i3, int i4, boolean z) {
        h.x.d.k.d(str, "<this>");
        h.x.d.k.d(str2, "other");
        return !z ? str.regionMatches(i2, str2, i3, i4) : str.regionMatches(z, i2, str2, i3, i4);
    }

    public static String r(CharSequence charSequence, int i2) {
        h.x.d.k.d(charSequence, "<this>");
        int i3 = 1;
        if (!(i2 >= 0)) {
            throw new IllegalArgumentException(("Count 'n' must be non-negative, but was " + i2 + '.').toString());
        }
        if (i2 == 0) {
            return "";
        }
        if (i2 == 1) {
            return charSequence.toString();
        }
        int length = charSequence.length();
        if (length == 0) {
            return "";
        }
        if (length == 1) {
            char cCharAt = charSequence.charAt(0);
            char[] cArr = new char[i2];
            for (int i4 = 0; i4 < i2; i4++) {
                cArr[i4] = cCharAt;
            }
            return new String(cArr);
        }
        StringBuilder sb = new StringBuilder(charSequence.length() * i2);
        if (1 <= i2) {
            while (true) {
                sb.append(charSequence);
                if (i3 == i2) {
                    break;
                }
                i3++;
            }
        }
        String string = sb.toString();
        h.x.d.k.c(string, "{\n                    va…tring()\n                }");
        return string;
    }

    public static final String s(String str, char c2, char c3, boolean z) {
        h.x.d.k.d(str, "<this>");
        if (!z) {
            String strReplace = str.replace(c2, c3);
            h.x.d.k.c(strReplace, "this as java.lang.String…replace(oldChar, newChar)");
            return strReplace;
        }
        StringBuilder sb = new StringBuilder(str.length());
        for (int i2 = 0; i2 < str.length(); i2++) {
            char cCharAt = str.charAt(i2);
            if (c.d(cCharAt, c2, z)) {
                cCharAt = c3;
            }
            sb.append(cCharAt);
        }
        String string = sb.toString();
        h.x.d.k.c(string, "StringBuilder(capacity).…builderAction).toString()");
        return string;
    }

    public static final String t(String str, String str2, String str3, boolean z) {
        h.x.d.k.d(str, "<this>");
        h.x.d.k.d(str2, "oldValue");
        h.x.d.k.d(str3, "newValue");
        int i2 = 0;
        int iL = q.L(str, str2, 0, z);
        if (iL < 0) {
            return str;
        }
        int length = str2.length();
        int iB = h.z.n.b(length, 1);
        int length2 = (str.length() - length) + str3.length();
        if (length2 < 0) {
            throw new OutOfMemoryError();
        }
        StringBuilder sb = new StringBuilder(length2);
        do {
            sb.append((CharSequence) str, i2, iL);
            sb.append(str3);
            i2 = iL + length;
            if (iL >= str.length()) {
                break;
            }
            iL = q.L(str, str2, iL + iB, z);
        } while (iL > 0);
        sb.append((CharSequence) str, i2, str.length());
        String string = sb.toString();
        h.x.d.k.c(string, "stringBuilder.append(this, i, length).toString()");
        return string;
    }

    public static /* synthetic */ String u(String str, char c2, char c3, boolean z, int i2, Object obj) {
        if ((i2 & 4) != 0) {
            z = false;
        }
        return s(str, c2, c3, z);
    }

    public static /* synthetic */ String v(String str, String str2, String str3, boolean z, int i2, Object obj) {
        if ((i2 & 4) != 0) {
            z = false;
        }
        return t(str, str2, str3, z);
    }

    public static boolean w(String str, String str2, int i2, boolean z) {
        h.x.d.k.d(str, "<this>");
        h.x.d.k.d(str2, "prefix");
        return !z ? str.startsWith(str2, i2) : p(str, i2, str2, 0, str2.length(), z);
    }

    public static boolean x(String str, String str2, boolean z) {
        h.x.d.k.d(str, "<this>");
        h.x.d.k.d(str2, "prefix");
        return !z ? str.startsWith(str2) : p(str, 0, str2, 0, str2.length(), z);
    }

    public static /* synthetic */ boolean y(String str, String str2, int i2, boolean z, int i3, Object obj) {
        if ((i3 & 4) != 0) {
            z = false;
        }
        return w(str, str2, i2, z);
    }

    public static /* synthetic */ boolean z(String str, String str2, boolean z, int i2, Object obj) {
        if ((i2 & 2) != 0) {
            z = false;
        }
        return x(str, str2, z);
    }
}
