package o9; import java.io.Closeable; import java.io.IOException; import java.io.InterruptedIOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.IDN; import java.net.InetAddress; import java.net.Socket; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.security.AccessControlException; import java.security.GeneralSecurityException; import java.security.KeyStore; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.TimeZone; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509TrustManager; import n9.f0; import n9.h0; import n9.x; import n9.y; import x9.o; import x9.v; /* loaded from: classes2.dex */ public abstract class e { /* renamed from: a, reason: collision with root package name */ public static final byte[] f12826a; /* renamed from: d, reason: collision with root package name */ public static final h0 f12829d; /* renamed from: e, reason: collision with root package name */ public static final f0 f12830e; /* renamed from: k, reason: collision with root package name */ private static final Method f12836k; /* renamed from: l, reason: collision with root package name */ private static final Pattern f12837l; /* renamed from: b, reason: collision with root package name */ public static final String[] f12827b = new String[0]; /* renamed from: c, reason: collision with root package name */ public static final x f12828c = x.g(new String[0]); /* renamed from: f, reason: collision with root package name */ private static final o f12831f = o.d(x9.f.d("efbbbf"), x9.f.d("feff"), x9.f.d("fffe"), x9.f.d("0000ffff"), x9.f.d("ffff0000")); /* renamed from: g, reason: collision with root package name */ private static final Charset f12832g = Charset.forName("UTF-32BE"); /* renamed from: h, reason: collision with root package name */ private static final Charset f12833h = Charset.forName("UTF-32LE"); /* renamed from: i, reason: collision with root package name */ public static final TimeZone f12834i = TimeZone.getTimeZone("GMT"); /* renamed from: j, reason: collision with root package name */ public static final Comparator f12835j = new Comparator() { // from class: o9.d @Override // java.util.Comparator public final int compare(Object obj, Object obj2) { return ((String) obj).compareTo((String) obj2); } }; static { byte[] bArr = new byte[0]; f12826a = bArr; Method method = null; f12829d = h0.R(null, bArr); f12830e = f0.d(null, bArr); try { method = Throwable.class.getDeclaredMethod("addSuppressed", Throwable.class); } catch (Exception unused) { } f12836k = method; f12837l = Pattern.compile("([0-9a-fA-F]*:[0-9a-fA-F:.]*)|([\\d.]+)"); } public static boolean A(AssertionError assertionError) { return (assertionError.getCause() == null || assertionError.getMessage() == null || !assertionError.getMessage().contains("getsockname failed")) ? false : true; } /* JADX INFO: Access modifiers changed from: private */ public static /* synthetic */ Thread B(String str, boolean z10, Runnable runnable) { Thread thread = new Thread(runnable, str); thread.setDaemon(z10); return thread; } public static boolean C(Comparator comparator, String[] strArr, String[] strArr2) { if (strArr != null && strArr2 != null && strArr.length != 0 && strArr2.length != 0) { for (String str : strArr) { for (String str2 : strArr2) { if (comparator.compare(str, str2) == 0) { return true; } } } } return false; } public static X509TrustManager D() { try { TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init((KeyStore) null); TrustManager[] trustManagers = trustManagerFactory.getTrustManagers(); if (trustManagers.length == 1) { TrustManager trustManager = trustManagers[0]; if (trustManager instanceof X509TrustManager) { return (X509TrustManager) trustManager; } } throw new IllegalStateException("Unexpected default trust managers:" + Arrays.toString(trustManagers)); } catch (GeneralSecurityException e10) { throw new AssertionError("No System TLS", e10); } } public static boolean E(y yVar, y yVar2) { return yVar.l().equals(yVar2.l()) && yVar.y() == yVar2.y() && yVar.D().equals(yVar2.D()); } public static boolean F(v vVar, int i10, TimeUnit timeUnit) { long nanoTime = System.nanoTime(); long c10 = vVar.b().e() ? vVar.b().c() - nanoTime : Long.MAX_VALUE; vVar.b().d(Math.min(c10, timeUnit.toNanos(i10)) + nanoTime); try { x9.c cVar = new x9.c(); while (vVar.s0(cVar, 8192L) != -1) { cVar.I(); } if (c10 == Long.MAX_VALUE) { vVar.b().a(); return true; } vVar.b().d(nanoTime + c10); return true; } catch (InterruptedIOException unused) { if (c10 == Long.MAX_VALUE) { vVar.b().a(); return false; } vVar.b().d(nanoTime + c10); return false; } catch (Throwable th) { if (c10 == Long.MAX_VALUE) { vVar.b().a(); } else { vVar.b().d(nanoTime + c10); } throw th; } } public static int G(String str, int i10, int i11) { while (i10 < i11) { char charAt = str.charAt(i10); if (charAt != '\t' && charAt != '\n' && charAt != '\f' && charAt != '\r' && charAt != ' ') { return i10; } i10++; } return i11; } public static int H(String str, int i10, int i11) { for (int i12 = i11 - 1; i12 >= i10; i12--) { char charAt = str.charAt(i12); if (charAt != '\t' && charAt != '\n' && charAt != '\f' && charAt != '\r' && charAt != ' ') { return i12 + 1; } } return i10; } public static ThreadFactory I(final String str, final boolean z10) { return new ThreadFactory() { // from class: o9.c @Override // java.util.concurrent.ThreadFactory public final Thread newThread(Runnable runnable) { Thread B; B = e.B(str, z10, runnable); return B; } }; } public static List J(x xVar) { ArrayList arrayList = new ArrayList(); for (int i10 = 0; i10 < xVar.h(); i10++) { arrayList.add(new t9.c(xVar.e(i10), xVar.i(i10))); } return arrayList; } public static x K(List list) { x.a aVar = new x.a(); Iterator it = list.iterator(); while (it.hasNext()) { t9.c cVar = (t9.c) it.next(); a.f12822a.b(aVar, cVar.f14477a.s(), cVar.f14478b.s()); } return aVar.d(); } public static String L(String str, int i10, int i11) { int G = G(str, i10, i11); return str.substring(G, H(str, G, i11)); } public static boolean M(String str) { return f12837l.matcher(str).matches(); } public static void b(Throwable th, Throwable th2) { Method method = f12836k; if (method != null) { try { method.invoke(th, th2); } catch (IllegalAccessException | InvocationTargetException unused) { } } } public static Charset c(x9.e eVar, Charset charset) { int X = eVar.X(f12831f); if (X == -1) { return charset; } if (X == 0) { return StandardCharsets.UTF_8; } if (X == 1) { return StandardCharsets.UTF_16BE; } if (X == 2) { return StandardCharsets.UTF_16LE; } if (X == 3) { return f12832g; } if (X == 4) { return f12833h; } throw new AssertionError(); } public static String d(String str) { if (!str.contains(":")) { try { String lowerCase = IDN.toASCII(str).toLowerCase(Locale.US); if (lowerCase.isEmpty()) { return null; } if (j(lowerCase)) { return null; } return lowerCase; } catch (IllegalArgumentException unused) { return null; } } InetAddress m10 = (str.startsWith("[") && str.endsWith("]")) ? m(str, 1, str.length() - 1) : m(str, 0, str.length()); if (m10 == null) { return null; } byte[] address = m10.getAddress(); if (address.length == 16) { return y(address); } if (address.length == 4) { return m10.getHostAddress(); } throw new AssertionError("Invalid IPv6 address: '" + str + "'"); } public static int e(String str, long j10, TimeUnit timeUnit) { if (j10 < 0) { throw new IllegalArgumentException(str + " < 0"); } if (timeUnit == null) { throw new NullPointerException("unit == null"); } long millis = timeUnit.toMillis(j10); if (millis > 2147483647L) { throw new IllegalArgumentException(str + " too large."); } if (millis != 0 || j10 <= 0) { return (int) millis; } throw new IllegalArgumentException(str + " too small."); } public static void f(long j10, long j11, long j12) { if ((j11 | j12) < 0 || j11 > j10 || j10 - j11 < j12) { throw new ArrayIndexOutOfBoundsException(); } } public static void g(Closeable closeable) { if (closeable != null) { try { closeable.close(); } catch (RuntimeException e10) { throw e10; } catch (Exception unused) { } } } public static void h(Socket socket) { if (socket != null) { try { socket.close(); } catch (AssertionError e10) { if (!A(e10)) { throw e10; } } catch (RuntimeException e11) { throw e11; } catch (Exception unused) { } } } public static String[] i(String[] strArr, String str) { int length = strArr.length + 1; String[] strArr2 = new String[length]; System.arraycopy(strArr, 0, strArr2, 0, strArr.length); strArr2[length - 1] = str; return strArr2; } private static boolean j(String str) { for (int i10 = 0; i10 < str.length(); i10++) { char charAt = str.charAt(i10); if (charAt <= 31 || charAt >= 127 || " #%/:?@[\\]".indexOf(charAt) != -1) { return true; } } return false; } public static int k(char c10) { if (c10 >= '0' && c10 <= '9') { return c10 - '0'; } char c11 = 'a'; if (c10 < 'a' || c10 > 'f') { c11 = 'A'; if (c10 < 'A' || c10 > 'F') { return -1; } } return (c10 - c11) + 10; } private static boolean l(String str, int i10, int i11, byte[] bArr, int i12) { int i13 = i12; while (i10 < i11) { if (i13 == bArr.length) { return false; } if (i13 != i12) { if (str.charAt(i10) != '.') { return false; } i10++; } int i14 = i10; int i15 = 0; while (i14 < i11) { char charAt = str.charAt(i14); if (charAt < '0' || charAt > '9') { break; } if ((i15 == 0 && i10 != i14) || (i15 = ((i15 * 10) + charAt) - 48) > 255) { return false; } i14++; } if (i14 - i10 == 0) { return false; } bArr[i13] = (byte) i15; i13++; i10 = i14; } return i13 == i12 + 4; } /* JADX WARN: Code restructure failed: missing block: B:25:0x0079, code lost: return null; */ /* JADX WARN: Removed duplicated region for block: B:15:0x004f */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ private static java.net.InetAddress m(java.lang.String r11, int r12, int r13) { /* r0 = 16 byte[] r1 = new byte[r0] r2 = 0 r3 = -1 r4 = 0 r5 = -1 r6 = -1 L9: r7 = 0 if (r12 >= r13) goto L7a if (r4 != r0) goto Lf return r7 Lf: int r8 = r12 + 2 if (r8 > r13) goto L27 java.lang.String r9 = "::" r10 = 2 boolean r9 = r11.regionMatches(r12, r9, r2, r10) if (r9 == 0) goto L27 if (r5 == r3) goto L1f return r7 L1f: int r4 = r4 + 2 r5 = r4 if (r8 != r13) goto L25 goto L7a L25: r6 = r8 goto L4b L27: if (r4 == 0) goto L4a java.lang.String r8 = ":" r9 = 1 boolean r8 = r11.regionMatches(r12, r8, r2, r9) if (r8 == 0) goto L35 int r12 = r12 + 1 goto L4a L35: java.lang.String r8 = "." boolean r12 = r11.regionMatches(r12, r8, r2, r9) if (r12 == 0) goto L49 int r12 = r4 + (-2) boolean r11 = l(r11, r6, r13, r1, r12) if (r11 != 0) goto L46 return r7 L46: int r4 = r4 + 2 goto L7a L49: return r7 L4a: r6 = r12 L4b: r12 = r6 r8 = 0 L4d: if (r12 >= r13) goto L60 char r9 = r11.charAt(r12) int r9 = k(r9) if (r9 != r3) goto L5a goto L60 L5a: int r8 = r8 << 4 int r8 = r8 + r9 int r12 = r12 + 1 goto L4d L60: int r9 = r12 - r6 if (r9 == 0) goto L79 r10 = 4 if (r9 <= r10) goto L68 goto L79 L68: int r7 = r4 + 1 int r9 = r8 >>> 8 r9 = r9 & 255(0xff, float:3.57E-43) byte r9 = (byte) r9 r1[r4] = r9 int r4 = r7 + 1 r8 = r8 & 255(0xff, float:3.57E-43) byte r8 = (byte) r8 r1[r7] = r8 goto L9 L79: return r7 L7a: if (r4 == r0) goto L8b if (r5 != r3) goto L7f return r7 L7f: int r11 = r4 - r5 int r12 = 16 - r11 java.lang.System.arraycopy(r1, r5, r1, r12, r11) int r0 = r0 - r4 int r0 = r0 + r5 java.util.Arrays.fill(r1, r5, r0, r2) L8b: java.net.InetAddress r11 = java.net.InetAddress.getByAddress(r1) // Catch: java.net.UnknownHostException -> L90 return r11 L90: java.lang.AssertionError r11 = new java.lang.AssertionError r11.() throw r11 */ throw new UnsupportedOperationException("Method not decompiled: o9.e.m(java.lang.String, int, int):java.net.InetAddress"); } public static int n(String str, int i10, int i11, char c10) { while (i10 < i11) { if (str.charAt(i10) == c10) { return i10; } i10++; } return i11; } public static int o(String str, int i10, int i11, String str2) { while (i10 < i11) { if (str2.indexOf(str.charAt(i10)) != -1) { return i10; } i10++; } return i11; } public static boolean p(v vVar, int i10, TimeUnit timeUnit) { try { return F(vVar, i10, timeUnit); } catch (IOException unused) { return false; } } public static String q(String str, Object... objArr) { return String.format(Locale.US, str, objArr); } public static String r(String str, String str2) { try { String property = System.getProperty(str); return property != null ? property : str2; } catch (AccessControlException unused) { return str2; } } public static String s(y yVar, boolean z10) { String l10; if (yVar.l().contains(":")) { l10 = "[" + yVar.l() + "]"; } else { l10 = yVar.l(); } if (!z10 && yVar.y() == y.d(yVar.D())) { return l10; } return l10 + ":" + yVar.y(); } public static List t(List list) { return Collections.unmodifiableList(new ArrayList(list)); } public static List u(Object... objArr) { return Collections.unmodifiableList(Arrays.asList((Object[]) objArr.clone())); } public static Map v(Map map) { return map.isEmpty() ? Collections.emptyMap() : Collections.unmodifiableMap(new LinkedHashMap(map)); } public static int w(Comparator comparator, String[] strArr, String str) { int length = strArr.length; for (int i10 = 0; i10 < length; i10++) { if (comparator.compare(strArr[i10], str) == 0) { return i10; } } return -1; } public static int x(String str) { int length = str.length(); for (int i10 = 0; i10 < length; i10++) { char charAt = str.charAt(i10); if (charAt <= 31 || charAt >= 127) { return i10; } } return -1; } private static String y(byte[] bArr) { int i10 = -1; int i11 = 0; int i12 = 0; int i13 = 0; while (i12 < bArr.length) { int i14 = i12; while (i14 < 16 && bArr[i14] == 0 && bArr[i14 + 1] == 0) { i14 += 2; } int i15 = i14 - i12; if (i15 > i13 && i15 >= 4) { i10 = i12; i13 = i15; } i12 = i14 + 2; } x9.c cVar = new x9.c(); while (i11 < bArr.length) { if (i11 == i10) { cVar.h(58); i11 += i13; if (i11 == 16) { cVar.h(58); } } else { if (i11 > 0) { cVar.h(58); } cVar.m(((bArr[i11] & 255) << 8) | (bArr[i11 + 1] & 255)); i11 += 2; } } return cVar.m0(); } public static String[] z(Comparator comparator, String[] strArr, String[] strArr2) { ArrayList arrayList = new ArrayList(); for (String str : strArr) { int length = strArr2.length; int i10 = 0; while (true) { if (i10 >= length) { break; } if (comparator.compare(str, strArr2[i10]) == 0) { arrayList.add(str); break; } i10++; } } return (String[]) arrayList.toArray(new String[arrayList.size()]); } }