package com.applovin.impl; import android.graphics.Color; import android.graphics.PointF; import android.text.TextUtils; import com.applovin.exoplayer2.common.base.Ascii; import com.mbridge.msdk.playercommon.exoplayer2.text.ttml.TtmlNode; import java.util.regex.Matcher; import java.util.regex.Pattern; /* loaded from: classes.dex */ final class zk { public final String a; public final int b; public final Integer c; public final float d; public final boolean e; public final boolean f; public final boolean g; public final boolean h; private static boolean a(int i) { switch (i) { case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: return true; default: return false; } } private zk(String str, int i, Integer num, float f, boolean z, boolean z2, boolean z3, boolean z4) { this.a = str; this.b = i; this.c = num; this.d = f; this.e = z; this.f = z2; this.g = z3; this.h = z4; } /* JADX INFO: Access modifiers changed from: private */ public static int b(String str) { try { int parseInt = Integer.parseInt(str.trim()); if (a(parseInt)) { return parseInt; } } catch (NumberFormatException unused) { } pc.d("SsaStyle", "Ignoring unknown alignment: " + str); return -1; } public static zk a(String str, a aVar) { b1.a(str.startsWith("Style:")); String[] split = TextUtils.split(str.substring(6), ","); int length = split.length; int i = aVar.i; if (length != i) { pc.d("SsaStyle", xp.a("Skipping malformed 'Style:' line (expected %s values, found %s): '%s'", Integer.valueOf(i), Integer.valueOf(split.length), str)); return null; } try { String trim = split[aVar.a].trim(); int i2 = aVar.b; int b2 = i2 != -1 ? b(split[i2].trim()) : -1; int i3 = aVar.c; Integer d = i3 != -1 ? d(split[i3].trim()) : null; int i4 = aVar.d; float e = i4 != -1 ? e(split[i4].trim()) : -3.4028235E38f; int i5 = aVar.e; boolean z = i5 != -1 && c(split[i5].trim()); int i6 = aVar.f; boolean z2 = i6 != -1 && c(split[i6].trim()); int i7 = aVar.g; boolean z3 = i7 != -1 && c(split[i7].trim()); int i8 = aVar.h; return new zk(trim, b2, d, e, z, z2, z3, i8 != -1 && c(split[i8].trim())); } catch (RuntimeException e2) { pc.c("SsaStyle", "Skipping malformed 'Style:' line: '" + str + "'", e2); return null; } } public static Integer d(String str) { long parseLong; try { if (str.startsWith("&H")) { parseLong = Long.parseLong(str.substring(2), 16); } else { parseLong = Long.parseLong(str); } b1.a(parseLong <= 4294967295L); return Integer.valueOf(Color.argb(ub.a(((parseLong >> 24) & 255) ^ 255), ub.a(parseLong & 255), ub.a((parseLong >> 8) & 255), ub.a((parseLong >> 16) & 255))); } catch (IllegalArgumentException e) { pc.c("SsaStyle", "Failed to parse color expression: '" + str + "'", e); return null; } } private static float e(String str) { try { return Float.parseFloat(str); } catch (NumberFormatException e) { pc.c("SsaStyle", "Failed to parse font size: '" + str + "'", e); return -3.4028235E38f; } } private static boolean c(String str) { try { int parseInt = Integer.parseInt(str); return parseInt == 1 || parseInt == -1; } catch (NumberFormatException e) { pc.c("SsaStyle", "Failed to parse boolean value: '" + str + "'", e); return false; } } public static final class a { public final int a; public final int b; public final int c; public final int d; public final int e; public final int f; public final int g; public final int h; public final int i; private a(int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9) { this.a = i; this.b = i2; this.c = i3; this.d = i4; this.e = i5; this.f = i6; this.g = i7; this.h = i8; this.i = i9; } /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */ public static a a(String str) { char c; String[] split = TextUtils.split(str.substring(7), ","); int i = -1; int i2 = -1; int i3 = -1; int i4 = -1; int i5 = -1; int i6 = -1; int i7 = -1; int i8 = -1; for (int i9 = 0; i9 < split.length; i9++) { String lowerCase = Ascii.toLowerCase(split[i9].trim()); lowerCase.hashCode(); switch (lowerCase.hashCode()) { case -1178781136: if (lowerCase.equals(TtmlNode.ITALIC)) { c = 0; break; } c = 65535; break; case -1026963764: if (lowerCase.equals(TtmlNode.UNDERLINE)) { c = 1; break; } c = 65535; break; case -192095652: if (lowerCase.equals("strikeout")) { c = 2; break; } c = 65535; break; case -70925746: if (lowerCase.equals("primarycolour")) { c = 3; break; } c = 65535; break; case 3029637: if (lowerCase.equals(TtmlNode.BOLD)) { c = 4; break; } c = 65535; break; case 3373707: if (lowerCase.equals("name")) { c = 5; break; } c = 65535; break; case 366554320: if (lowerCase.equals("fontsize")) { c = 6; break; } c = 65535; break; case 1767875043: if (lowerCase.equals("alignment")) { c = 7; break; } c = 65535; break; default: c = 65535; break; } switch (c) { case 0: i6 = i9; break; case 1: i7 = i9; break; case 2: i8 = i9; break; case 3: i3 = i9; break; case 4: i5 = i9; break; case 5: i = i9; break; case 6: i4 = i9; break; case 7: i2 = i9; break; } } if (i != -1) { return new a(i, i2, i3, i4, i5, i6, i7, i8, split.length); } return null; } } public static final class b { private static final Pattern c = Pattern.compile("\\{([^}]*)\\}"); private static final Pattern d = Pattern.compile(xp.a("\\\\pos\\((%1$s),(%1$s)\\)", "\\s*\\d+(?:\\.\\d+)?\\s*")); private static final Pattern e = Pattern.compile(xp.a("\\\\move\\(%1$s,%1$s,(%1$s),(%1$s)(?:,%1$s,%1$s)?\\)", "\\s*\\d+(?:\\.\\d+)?\\s*")); private static final Pattern f = Pattern.compile("\\\\an(\\d+)"); public final int a; public final PointF b; private static int a(String str) { Matcher matcher = f.matcher(str); if (matcher.find()) { return zk.b((String) b1.a((Object) matcher.group(1))); } return -1; } private static PointF c(String str) { String group; String group2; Matcher matcher = d.matcher(str); Matcher matcher2 = e.matcher(str); boolean find = matcher.find(); boolean find2 = matcher2.find(); if (find) { if (find2) { pc.c("SsaStyle.Overrides", "Override has both \\pos(x,y) and \\move(x1,y1,x2,y2); using \\pos values. override='" + str + "'"); } group = matcher.group(1); group2 = matcher.group(2); } else { if (!find2) { return null; } group = matcher2.group(1); group2 = matcher2.group(2); } return new PointF(Float.parseFloat(((String) b1.a((Object) group)).trim()), Float.parseFloat(((String) b1.a((Object) group2)).trim())); } public static String d(String str) { return c.matcher(str).replaceAll(""); } private b(int i, PointF pointF) { this.a = i; this.b = pointF; } public static b b(String str) { Matcher matcher = c.matcher(str); PointF pointF = null; int i = -1; while (matcher.find()) { String str2 = (String) b1.a((Object) matcher.group(1)); try { PointF c2 = c(str2); if (c2 != null) { pointF = c2; } } catch (RuntimeException unused) { } try { int a = a(str2); if (a != -1) { i = a; } } catch (RuntimeException unused2) { } } return new b(i, pointF); } } }