package com.google.android.gms.internal.ads;

import android.text.Layout;
import androidx.annotation.Nullable;
import androidx.media3.common.MimeTypes;
import androidx.media3.exoplayer.upstream.CmcdConfiguration;
import androidx.media3.exoplayer.upstream.CmcdData;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
import xyz.stream.download.config.InnerConstant;

/* JADX INFO: loaded from: classes2.dex */
public final class h9 implements j8 {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final Pattern f12062b = Pattern.compile("^([0-9][0-9]+):([0-9][0-9]):([0-9][0-9])(?:(\\.[0-9]+)|:([0-9][0-9])(?:\\.([0-9]+))?)?$");

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final Pattern f12063c = Pattern.compile("^([0-9]+(?:\\.[0-9]+)?)(h|m|s|ms|f|t)$");

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final Pattern f12064d = Pattern.compile("^(([0-9]*.)?[0-9]+)(px|em|%)$");

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static final Pattern f12065e = Pattern.compile("^([-+]?\\d+\\.?\\d*?)%$");

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final Pattern f12066f = Pattern.compile("^([-+]?\\d+\\.?\\d*?)% ([-+]?\\d+\\.?\\d*?)%$");

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public static final Pattern f12067g = Pattern.compile("^([-+]?\\d+\\.?\\d*?)px ([-+]?\\d+\\.?\\d*?)px$");

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public static final Pattern f12068h = Pattern.compile("^(\\d+) (\\d+)$");

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public static final y3.c f12069i = new y3.c(30.0f, 1, 1);

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final XmlPullParserFactory f12070a;

    public h9() {
        try {
            XmlPullParserFactory xmlPullParserFactoryNewInstance = XmlPullParserFactory.newInstance();
            this.f12070a = xmlPullParserFactoryNewInstance;
            xmlPullParserFactoryNewInstance.setNamespaceAware(true);
        } catch (XmlPullParserException e10) {
            throw new RuntimeException("Couldn't create XmlPullParserFactory instance", e10);
        }
    }

    public static k9 c(XmlPullParser xmlPullParser, k9 k9Var) {
        String attributeValue;
        Matcher matcher;
        String strGroup;
        int attributeCount = xmlPullParser.getAttributeCount();
        boolean z10 = false;
        k9 k9VarZze = k9Var;
        for (int i10 = 0; i10 < attributeCount; i10++) {
            attributeValue = xmlPullParser.getAttributeValue(i10);
            String attributeName = xmlPullParser.getAttributeName(i10);
            attributeName.hashCode();
            switch (attributeName) {
                case "fontStyle":
                    k9VarZze = zze(k9VarZze);
                    k9VarZze.f13176h = "italic".equalsIgnoreCase(attributeValue) ? 1 : 0;
                    continue;
                    break;
                case "extent":
                    k9VarZze = zze(k9VarZze);
                    k9VarZze.zzM(attributeValue);
                    continue;
                    break;
                case "fontFamily":
                    k9VarZze = zze(k9VarZze);
                    k9VarZze.zzi(attributeValue);
                    continue;
                    break;
                case "textAlign":
                    k9VarZze = zze(k9VarZze);
                    k9VarZze.zzz(zzf(attributeValue));
                    continue;
                    break;
                case "origin":
                    k9VarZze = zze(k9VarZze);
                    k9VarZze.zzK(attributeValue);
                    continue;
                    break;
                case "textDecoration":
                    String strR = ih1.r(attributeValue);
                    strR.getClass();
                    strR.hashCode();
                    switch (strR) {
                        case "nounderline":
                            z10 = false;
                            k9VarZze = zze(k9VarZze);
                            k9VarZze.f13174f = 0;
                            continue;
                            break;
                        case "underline":
                            z10 = false;
                            k9VarZze = zze(k9VarZze);
                            k9VarZze.f13174f = 1;
                            continue;
                            break;
                        case "nolinethrough":
                            k9VarZze = zze(k9VarZze);
                            z10 = false;
                            k9VarZze.f13173e = 0;
                            continue;
                            break;
                        case "linethrough":
                            k9VarZze = zze(k9VarZze);
                            k9VarZze.f13173e = 1;
                            break;
                    }
                    break;
                case "fontWeight":
                    k9VarZze = zze(k9VarZze);
                    k9VarZze.f13175g = "bold".equalsIgnoreCase(attributeValue) ? 1 : 0;
                    break;
                case "id":
                    if ("style".equals(xmlPullParser.getName())) {
                        k9VarZze = zze(k9VarZze);
                        k9VarZze.zzs(attributeValue);
                        break;
                    }
                    break;
                case "ruby":
                    String strR2 = ih1.r(attributeValue);
                    strR2.getClass();
                    strR2.hashCode();
                    switch (strR2) {
                        case "baseContainer":
                        case "base":
                            k9VarZze = zze(k9VarZze);
                            k9VarZze.f13179k = 2;
                            break;
                        case "container":
                            k9VarZze = zze(k9VarZze);
                            k9VarZze.f13179k = 1;
                            break;
                        case "delimiter":
                            k9VarZze = zze(k9VarZze);
                            k9VarZze.f13179k = 4;
                            break;
                        case "textContainer":
                        case "text":
                            k9VarZze = zze(k9VarZze);
                            k9VarZze.f13179k = 3;
                            break;
                    }
                    break;
                case "color":
                    k9VarZze = zze(k9VarZze);
                    try {
                        k9VarZze.f13169a = zm0.a(attributeValue, false);
                        k9VarZze.f13170b = true;
                        break;
                    } catch (IllegalArgumentException unused) {
                        com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.p(attributeValue, "Failed parsing color value: ");
                        break;
                    }
                    break;
                case "shear":
                    k9 k9VarZze2 = zze(k9VarZze);
                    Matcher matcher2 = f12065e.matcher(attributeValue);
                    float fMin = Float.MAX_VALUE;
                    if (matcher2.matches()) {
                        try {
                            String strGroup2 = matcher2.group(1);
                            strGroup2.getClass();
                            fMin = Math.min(100.0f, Math.max(-100.0f, Float.parseFloat(strGroup2)));
                        } catch (NumberFormatException e10) {
                            vt0.zzd("TtmlParser", "Failed to parse shear: ".concat(String.valueOf(attributeValue)), e10);
                        }
                    } else {
                        com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.p(attributeValue, "Invalid value for shear: ");
                    }
                    k9VarZze2.f13182n = fMin;
                    k9VarZze = k9VarZze2;
                    break;
                case "textCombine":
                    String strR3 = ih1.r(attributeValue);
                    strR3.getClass();
                    if (!strR3.equals("none")) {
                        if (strR3.equals("all")) {
                            k9VarZze = zze(k9VarZze);
                            k9VarZze.f13181m = 1;
                        }
                        break;
                    } else {
                        k9VarZze = zze(k9VarZze);
                        k9VarZze.f13181m = 0;
                        break;
                    }
                    break;
                case "fontSize":
                    try {
                        k9VarZze = zze(k9VarZze);
                        String str = bb1.f9474a;
                        String[] strArrSplit = attributeValue.split("\\s+", -1);
                        int length = strArrSplit.length;
                        Pattern pattern = f12064d;
                        if (length == 1) {
                            matcher = pattern.matcher(attributeValue);
                        } else {
                            if (length != 2) {
                                StringBuilder sb = new StringBuilder(String.valueOf(length).length() + 41);
                                sb.append("Invalid number of entries for fontSize: ");
                                sb.append(length);
                                sb.append(".");
                                throw new zzamb(sb.toString());
                            }
                            matcher = pattern.matcher(strArrSplit[1]);
                            vt0.c("Multiple values in fontSize attribute. Picking the second value for vertical font size and ignoring the first.");
                        }
                        if (!matcher.matches()) {
                            StringBuilder sb2 = new StringBuilder(attributeValue.length() + 36);
                            sb2.append("Invalid expression for fontSize: '");
                            sb2.append(attributeValue);
                            sb2.append("'.");
                            throw new zzamb(sb2.toString());
                        }
                        strGroup = matcher.group(3);
                        strGroup.getClass();
                        strGroup.hashCode();
                        switch (strGroup) {
                            case "%":
                                k9VarZze.f13177i = 3;
                                break;
                            case "em":
                                k9VarZze.f13177i = 2;
                                break;
                            case "px":
                                k9VarZze.f13177i = 1;
                                break;
                            default:
                                StringBuilder sb3 = new StringBuilder(strGroup.length() + 30);
                                sb3.append("Invalid unit for fontSize: '");
                                sb3.append(strGroup);
                                sb3.append("'.");
                                throw new zzamb(sb3.toString());
                        }
                        String strGroup3 = matcher.group(1);
                        strGroup3.getClass();
                        k9VarZze.f13178j = Float.parseFloat(strGroup3);
                        break;
                    } catch (zzamb unused2) {
                        com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.p(attributeValue, "Failed parsing fontSize value: ");
                        break;
                    }
                    break;
                case "textEmphasis":
                    k9VarZze = zze(k9VarZze);
                    k9VarZze.zzF(f9.zza(attributeValue));
                    continue;
                    break;
                case "rubyPosition":
                    String strR4 = ih1.r(attributeValue);
                    strR4.getClass();
                    if (strR4.equals("after")) {
                        k9VarZze = zze(k9VarZze);
                        k9VarZze.f13180l = 2;
                    } else if (strR4.equals("before")) {
                        k9VarZze = zze(k9VarZze);
                        k9VarZze.f13180l = 1;
                    }
                    break;
                case "backgroundColor":
                    k9VarZze = zze(k9VarZze);
                    try {
                        k9VarZze.f13171c = zm0.a(attributeValue, z10);
                        k9VarZze.f13172d = true;
                        continue;
                    } catch (IllegalArgumentException unused3) {
                        com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.p(attributeValue, "Failed parsing background value: ");
                    }
                    break;
                case "multiRowAlign":
                    k9VarZze = zze(k9VarZze);
                    k9VarZze.zzB(zzf(attributeValue));
                    continue;
                    break;
            }
            z10 = false;
        }
        return k9VarZze;
    }

    /* JADX WARN: Removed duplicated region for block: B:50:0x00f2  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static long d(String str, y3.c cVar) throws zzamb {
        double d10;
        double d11;
        Matcher matcher = f12062b.matcher(str);
        byte b10 = 2;
        if (matcher.matches()) {
            String strGroup = matcher.group(1);
            strGroup.getClass();
            long j10 = Long.parseLong(strGroup) * 3600;
            String strGroup2 = matcher.group(2);
            strGroup2.getClass();
            long j11 = Long.parseLong(strGroup2) * 60;
            String strGroup3 = matcher.group(3);
            strGroup3.getClass();
            double d12 = j10 + j11;
            double d13 = Long.parseLong(strGroup3);
            String strGroup4 = matcher.group(4);
            double d14 = strGroup4 != null ? Double.parseDouble(strGroup4) : 0.0d;
            double d15 = d12 + d13;
            return (long) ((d15 + d14 + (matcher.group(5) != null ? Long.parseLong(r13) / cVar.f36767a : 0.0d) + (matcher.group(6) != null ? (Long.parseLong(r13) / ((double) cVar.f36768b)) / ((double) cVar.f36767a) : 0.0d)) * 1000000.0d);
        }
        Matcher matcher2 = f12063c.matcher(str);
        if (!matcher2.matches()) {
            throw new zzamb("Malformed time expression: ".concat(String.valueOf(str)));
        }
        String strGroup5 = matcher2.group(1);
        strGroup5.getClass();
        double d16 = Double.parseDouble(strGroup5);
        String strGroup6 = matcher2.group(2);
        strGroup6.getClass();
        int iHashCode = strGroup6.hashCode();
        if (iHashCode != 102) {
            if (iHashCode != 104) {
                if (iHashCode != 109) {
                    if (iHashCode != 3494) {
                        if (iHashCode != 115) {
                            b10 = (iHashCode == 116 && strGroup6.equals("t")) ? (byte) 5 : (byte) -1;
                        } else if (!strGroup6.equals(CmcdData.STREAMING_FORMAT_SS)) {
                        }
                    } else if (strGroup6.equals("ms")) {
                        b10 = 3;
                    }
                } else if (strGroup6.equals(CmcdData.OBJECT_TYPE_MANIFEST)) {
                    b10 = 1;
                }
            } else if (strGroup6.equals(CmcdData.STREAMING_FORMAT_HLS)) {
                b10 = 0;
            }
        } else if (strGroup6.equals("f")) {
            b10 = 4;
        }
        if (b10 == 0) {
            d10 = 3600.0d;
        } else {
            if (b10 != 1) {
                if (b10 == 3) {
                    d11 = 1000.0d;
                } else {
                    if (b10 != 4) {
                        if (b10 == 5) {
                            d11 = cVar.f36769c;
                        }
                        return (long) (d16 * 1000000.0d);
                    }
                    d11 = cVar.f36767a;
                }
                d16 /= d11;
                return (long) (d16 * 1000000.0d);
            }
            d10 = 60.0d;
        }
        d16 *= d10;
        return (long) (d16 * 1000000.0d);
    }

    private static k9 zze(@Nullable k9 k9Var) {
        return k9Var == null ? new k9() : k9Var;
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    /* JADX WARN: Removed duplicated region for block: B:20:0x0042  */
    @Nullable
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private static Layout.Alignment zzf(String str) {
        byte b10;
        String strR = ih1.r(str);
        switch (strR.hashCode()) {
            case -1364013995:
                b10 = !strR.equals("center") ? (byte) -1 : (byte) 4;
                break;
            case 100571:
                if (strR.equals("end")) {
                    b10 = 3;
                    break;
                }
                break;
            case 3317767:
                if (strR.equals("left")) {
                    b10 = 0;
                    break;
                }
                break;
            case 108511772:
                if (strR.equals("right")) {
                    b10 = 2;
                    break;
                }
                break;
            case 109757538:
                if (strR.equals("start")) {
                    b10 = 1;
                    break;
                }
                break;
        }
        if (b10 == 0 || b10 == 1) {
            return Layout.Alignment.ALIGN_NORMAL;
        }
        if (b10 == 2 || b10 == 3) {
            return Layout.Alignment.ALIGN_OPPOSITE;
        }
        if (b10 != 4) {
            return null;
        }
        return Layout.Alignment.ALIGN_CENTER;
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Failed to find 'out' block for switch in B:303:0x05fd. Please report as an issue. */
    /* JADX WARN: Removed duplicated region for block: B:155:0x0342  */
    /* JADX WARN: Removed duplicated region for block: B:181:0x03c7  */
    /* JADX WARN: Removed duplicated region for block: B:190:0x03ea A[Catch: IOException -> 0x0099, XmlPullParserException -> 0x009d, TRY_LEAVE, TryCatch #18 {IOException -> 0x0099, XmlPullParserException -> 0x009d, blocks: (B:3:0x0008, B:6:0x0065, B:8:0x0070, B:11:0x007a, B:14:0x008a, B:16:0x0092, B:23:0x00a4, B:25:0x00ac, B:29:0x00c0, B:31:0x00dd, B:33:0x00e7, B:34:0x00eb, B:36:0x00f7, B:37:0x00fb, B:66:0x017f, B:83:0x01d8, B:86:0x01ec, B:88:0x01f2, B:90:0x01fa, B:92:0x0202, B:94:0x020a, B:96:0x0212, B:98:0x021a, B:100:0x0220, B:102:0x0228, B:104:0x0230, B:106:0x0236, B:108:0x023c, B:110:0x0242, B:112:0x024a, B:115:0x0253, B:403:0x0769, B:117:0x0283, B:120:0x028b, B:122:0x0294, B:124:0x02a5, B:126:0x02af, B:128:0x02be, B:130:0x02c4, B:132:0x02da, B:134:0x02e0, B:266:0x055f, B:127:0x02b5, B:136:0x02ed, B:139:0x02fb, B:250:0x0511, B:143:0x0317, B:145:0x031f, B:147:0x0327, B:149:0x032f, B:156:0x0344, B:159:0x0357, B:161:0x035e, B:163:0x036c, B:182:0x03d0, B:184:0x03d6, B:186:0x03dc, B:188:0x03e4, B:190:0x03ea, B:193:0x03f9, B:195:0x0400, B:197:0x040e, B:215:0x0482, B:217:0x048a, B:226:0x04bf, B:228:0x04c9, B:248:0x0504, B:199:0x0419, B:200:0x0426, B:203:0x042e, B:206:0x043c, B:208:0x0443, B:210:0x044f, B:212:0x0462, B:213:0x046f, B:165:0x0375, B:167:0x037f, B:170:0x0389, B:173:0x0392, B:175:0x0399, B:177:0x03a5, B:179:0x03b7, B:180:0x03bf, B:253:0x0524, B:255:0x052f, B:257:0x053a, B:259:0x0540, B:261:0x054c, B:271:0x0581, B:274:0x059e, B:305:0x0601, B:308:0x060a, B:379:0x06f3, B:316:0x0620, B:318:0x062b, B:320:0x0639, B:335:0x066d, B:319:0x0630, B:327:0x0647, B:330:0x064f, B:331:0x0658, B:332:0x0661, B:340:0x0680, B:344:0x068c, B:348:0x0695, B:356:0x06a8, B:363:0x06b9, B:365:0x06c9, B:367:0x06ce, B:369:0x06d2, B:370:0x06d9, B:358:0x06af, B:69:0x018c, B:71:0x0196, B:74:0x019f, B:76:0x01a6, B:78:0x01b2, B:80:0x01be, B:41:0x0114, B:43:0x0120, B:46:0x0129, B:48:0x0130, B:50:0x0137, B:52:0x013e, B:61:0x015b, B:62:0x0170, B:65:0x0177, B:384:0x0715, B:386:0x0721, B:387:0x0728, B:390:0x0731, B:392:0x073b, B:394:0x0746, B:396:0x074c, B:399:0x075f, B:402:0x0765), top: B:445:0x0008, inners: #1, #3, #6, #9, #11 }] */
    /* JADX WARN: Removed duplicated region for block: B:214:0x047e  */
    /* JADX WARN: Removed duplicated region for block: B:217:0x048a A[Catch: IOException -> 0x0099, XmlPullParserException -> 0x009d, TRY_LEAVE, TryCatch #18 {IOException -> 0x0099, XmlPullParserException -> 0x009d, blocks: (B:3:0x0008, B:6:0x0065, B:8:0x0070, B:11:0x007a, B:14:0x008a, B:16:0x0092, B:23:0x00a4, B:25:0x00ac, B:29:0x00c0, B:31:0x00dd, B:33:0x00e7, B:34:0x00eb, B:36:0x00f7, B:37:0x00fb, B:66:0x017f, B:83:0x01d8, B:86:0x01ec, B:88:0x01f2, B:90:0x01fa, B:92:0x0202, B:94:0x020a, B:96:0x0212, B:98:0x021a, B:100:0x0220, B:102:0x0228, B:104:0x0230, B:106:0x0236, B:108:0x023c, B:110:0x0242, B:112:0x024a, B:115:0x0253, B:403:0x0769, B:117:0x0283, B:120:0x028b, B:122:0x0294, B:124:0x02a5, B:126:0x02af, B:128:0x02be, B:130:0x02c4, B:132:0x02da, B:134:0x02e0, B:266:0x055f, B:127:0x02b5, B:136:0x02ed, B:139:0x02fb, B:250:0x0511, B:143:0x0317, B:145:0x031f, B:147:0x0327, B:149:0x032f, B:156:0x0344, B:159:0x0357, B:161:0x035e, B:163:0x036c, B:182:0x03d0, B:184:0x03d6, B:186:0x03dc, B:188:0x03e4, B:190:0x03ea, B:193:0x03f9, B:195:0x0400, B:197:0x040e, B:215:0x0482, B:217:0x048a, B:226:0x04bf, B:228:0x04c9, B:248:0x0504, B:199:0x0419, B:200:0x0426, B:203:0x042e, B:206:0x043c, B:208:0x0443, B:210:0x044f, B:212:0x0462, B:213:0x046f, B:165:0x0375, B:167:0x037f, B:170:0x0389, B:173:0x0392, B:175:0x0399, B:177:0x03a5, B:179:0x03b7, B:180:0x03bf, B:253:0x0524, B:255:0x052f, B:257:0x053a, B:259:0x0540, B:261:0x054c, B:271:0x0581, B:274:0x059e, B:305:0x0601, B:308:0x060a, B:379:0x06f3, B:316:0x0620, B:318:0x062b, B:320:0x0639, B:335:0x066d, B:319:0x0630, B:327:0x0647, B:330:0x064f, B:331:0x0658, B:332:0x0661, B:340:0x0680, B:344:0x068c, B:348:0x0695, B:356:0x06a8, B:363:0x06b9, B:365:0x06c9, B:367:0x06ce, B:369:0x06d2, B:370:0x06d9, B:358:0x06af, B:69:0x018c, B:71:0x0196, B:74:0x019f, B:76:0x01a6, B:78:0x01b2, B:80:0x01be, B:41:0x0114, B:43:0x0120, B:46:0x0129, B:48:0x0130, B:50:0x0137, B:52:0x013e, B:61:0x015b, B:62:0x0170, B:65:0x0177, B:384:0x0715, B:386:0x0721, B:387:0x0728, B:390:0x0731, B:392:0x073b, B:394:0x0746, B:396:0x074c, B:399:0x075f, B:402:0x0765), top: B:445:0x0008, inners: #1, #3, #6, #9, #11 }] */
    /* JADX WARN: Removed duplicated region for block: B:222:0x04a1  */
    /* JADX WARN: Removed duplicated region for block: B:231:0x04d7  */
    /* JADX WARN: Removed duplicated region for block: B:245:0x04fc  */
    /* JADX WARN: Removed duplicated region for block: B:250:0x0511 A[Catch: IOException -> 0x0099, XmlPullParserException -> 0x009d, TryCatch #18 {IOException -> 0x0099, XmlPullParserException -> 0x009d, blocks: (B:3:0x0008, B:6:0x0065, B:8:0x0070, B:11:0x007a, B:14:0x008a, B:16:0x0092, B:23:0x00a4, B:25:0x00ac, B:29:0x00c0, B:31:0x00dd, B:33:0x00e7, B:34:0x00eb, B:36:0x00f7, B:37:0x00fb, B:66:0x017f, B:83:0x01d8, B:86:0x01ec, B:88:0x01f2, B:90:0x01fa, B:92:0x0202, B:94:0x020a, B:96:0x0212, B:98:0x021a, B:100:0x0220, B:102:0x0228, B:104:0x0230, B:106:0x0236, B:108:0x023c, B:110:0x0242, B:112:0x024a, B:115:0x0253, B:403:0x0769, B:117:0x0283, B:120:0x028b, B:122:0x0294, B:124:0x02a5, B:126:0x02af, B:128:0x02be, B:130:0x02c4, B:132:0x02da, B:134:0x02e0, B:266:0x055f, B:127:0x02b5, B:136:0x02ed, B:139:0x02fb, B:250:0x0511, B:143:0x0317, B:145:0x031f, B:147:0x0327, B:149:0x032f, B:156:0x0344, B:159:0x0357, B:161:0x035e, B:163:0x036c, B:182:0x03d0, B:184:0x03d6, B:186:0x03dc, B:188:0x03e4, B:190:0x03ea, B:193:0x03f9, B:195:0x0400, B:197:0x040e, B:215:0x0482, B:217:0x048a, B:226:0x04bf, B:228:0x04c9, B:248:0x0504, B:199:0x0419, B:200:0x0426, B:203:0x042e, B:206:0x043c, B:208:0x0443, B:210:0x044f, B:212:0x0462, B:213:0x046f, B:165:0x0375, B:167:0x037f, B:170:0x0389, B:173:0x0392, B:175:0x0399, B:177:0x03a5, B:179:0x03b7, B:180:0x03bf, B:253:0x0524, B:255:0x052f, B:257:0x053a, B:259:0x0540, B:261:0x054c, B:271:0x0581, B:274:0x059e, B:305:0x0601, B:308:0x060a, B:379:0x06f3, B:316:0x0620, B:318:0x062b, B:320:0x0639, B:335:0x066d, B:319:0x0630, B:327:0x0647, B:330:0x064f, B:331:0x0658, B:332:0x0661, B:340:0x0680, B:344:0x068c, B:348:0x0695, B:356:0x06a8, B:363:0x06b9, B:365:0x06c9, B:367:0x06ce, B:369:0x06d2, B:370:0x06d9, B:358:0x06af, B:69:0x018c, B:71:0x0196, B:74:0x019f, B:76:0x01a6, B:78:0x01b2, B:80:0x01be, B:41:0x0114, B:43:0x0120, B:46:0x0129, B:48:0x0130, B:50:0x0137, B:52:0x013e, B:61:0x015b, B:62:0x0170, B:65:0x0177, B:384:0x0715, B:386:0x0721, B:387:0x0728, B:390:0x0731, B:392:0x073b, B:394:0x0746, B:396:0x074c, B:399:0x075f, B:402:0x0765), top: B:445:0x0008, inners: #1, #3, #6, #9, #11 }] */
    /* JADX WARN: Removed duplicated region for block: B:252:0x0521  */
    /* JADX WARN: Removed duplicated region for block: B:68:0x0189  */
    /* JADX WARN: Removed duplicated region for block: B:69:0x018c A[Catch: IOException -> 0x0099, XmlPullParserException -> 0x009d, TryCatch #18 {IOException -> 0x0099, XmlPullParserException -> 0x009d, blocks: (B:3:0x0008, B:6:0x0065, B:8:0x0070, B:11:0x007a, B:14:0x008a, B:16:0x0092, B:23:0x00a4, B:25:0x00ac, B:29:0x00c0, B:31:0x00dd, B:33:0x00e7, B:34:0x00eb, B:36:0x00f7, B:37:0x00fb, B:66:0x017f, B:83:0x01d8, B:86:0x01ec, B:88:0x01f2, B:90:0x01fa, B:92:0x0202, B:94:0x020a, B:96:0x0212, B:98:0x021a, B:100:0x0220, B:102:0x0228, B:104:0x0230, B:106:0x0236, B:108:0x023c, B:110:0x0242, B:112:0x024a, B:115:0x0253, B:403:0x0769, B:117:0x0283, B:120:0x028b, B:122:0x0294, B:124:0x02a5, B:126:0x02af, B:128:0x02be, B:130:0x02c4, B:132:0x02da, B:134:0x02e0, B:266:0x055f, B:127:0x02b5, B:136:0x02ed, B:139:0x02fb, B:250:0x0511, B:143:0x0317, B:145:0x031f, B:147:0x0327, B:149:0x032f, B:156:0x0344, B:159:0x0357, B:161:0x035e, B:163:0x036c, B:182:0x03d0, B:184:0x03d6, B:186:0x03dc, B:188:0x03e4, B:190:0x03ea, B:193:0x03f9, B:195:0x0400, B:197:0x040e, B:215:0x0482, B:217:0x048a, B:226:0x04bf, B:228:0x04c9, B:248:0x0504, B:199:0x0419, B:200:0x0426, B:203:0x042e, B:206:0x043c, B:208:0x0443, B:210:0x044f, B:212:0x0462, B:213:0x046f, B:165:0x0375, B:167:0x037f, B:170:0x0389, B:173:0x0392, B:175:0x0399, B:177:0x03a5, B:179:0x03b7, B:180:0x03bf, B:253:0x0524, B:255:0x052f, B:257:0x053a, B:259:0x0540, B:261:0x054c, B:271:0x0581, B:274:0x059e, B:305:0x0601, B:308:0x060a, B:379:0x06f3, B:316:0x0620, B:318:0x062b, B:320:0x0639, B:335:0x066d, B:319:0x0630, B:327:0x0647, B:330:0x064f, B:331:0x0658, B:332:0x0661, B:340:0x0680, B:344:0x068c, B:348:0x0695, B:356:0x06a8, B:363:0x06b9, B:365:0x06c9, B:367:0x06ce, B:369:0x06d2, B:370:0x06d9, B:358:0x06af, B:69:0x018c, B:71:0x0196, B:74:0x019f, B:76:0x01a6, B:78:0x01b2, B:80:0x01be, B:41:0x0114, B:43:0x0120, B:46:0x0129, B:48:0x0130, B:50:0x0137, B:52:0x013e, B:61:0x015b, B:62:0x0170, B:65:0x0177, B:384:0x0715, B:386:0x0721, B:387:0x0728, B:390:0x0731, B:392:0x073b, B:394:0x0746, B:396:0x074c, B:399:0x075f, B:402:0x0765), top: B:445:0x0008, inners: #1, #3, #6, #9, #11 }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final l9 a(int i10, int i11, byte[] bArr) {
        String str;
        String str2;
        String str3;
        HashMap map;
        ArrayDeque arrayDeque;
        y3.c cVar;
        l9 l9Var;
        ArrayDeque arrayDeque2;
        g9 g9Var;
        String str4;
        int i12;
        y3.c cVar2;
        zzamb zzambVar;
        g9 g9Var2;
        g9 g9Var3;
        Object obj;
        byte b10;
        String str5;
        String[] strArrSplit;
        String str6;
        String str7;
        String str8;
        String str9;
        String strZzc;
        String str10;
        String str11;
        String strZzL;
        HashMap map2;
        int i13;
        String str12;
        float f10;
        float f11;
        String strZzc2;
        float f12;
        float f13;
        String strZzc3;
        float f14;
        int i14;
        int i15;
        i9 i9Var;
        String strZzc4;
        k9 k9Var;
        k9 k9Var2;
        String str13;
        String[] strArrSplit2;
        float f15;
        int i16;
        int i17;
        boolean z10;
        String strZzc5;
        String str14 = "";
        String str15 = "http://www.w3.org/ns/ttml#parameter";
        String str16 = "Ignoring unsupported tag: ";
        try {
            XmlPullParser xmlPullParserNewPullParser = this.f12070a.newPullParser();
            HashMap map3 = new HashMap();
            HashMap map4 = new HashMap();
            HashMap map5 = new HashMap();
            map4.put("", new i9("", -3.4028235E38f, -3.4028235E38f, Integer.MIN_VALUE, Integer.MIN_VALUE, -3.4028235E38f, -3.4028235E38f, Integer.MIN_VALUE, -3.4028235E38f, Integer.MIN_VALUE));
            xmlPullParserNewPullParser.setInput(new ByteArrayInputStream(bArr, i10, i11), null);
            ArrayDeque arrayDeque3 = new ArrayDeque();
            int eventType = xmlPullParserNewPullParser.getEventType();
            y3.c cVar3 = f12069i;
            l9 l9Var2 = null;
            v2.a aVar = null;
            y3.c cVar4 = cVar3;
            int i18 = 0;
            int i19 = 15;
            while (eventType != 1) {
                g9 g9Var4 = (g9) arrayDeque3.peek();
                if (i18 == 0) {
                    String name = xmlPullParserNewPullParser.getName();
                    str = str14;
                    if (eventType == 2) {
                        boolean zEquals = "tt".equals(name);
                        l9Var = l9Var2;
                        Pattern pattern = f12067g;
                        if (zEquals) {
                            String attributeValue = xmlPullParserNewPullParser.getAttributeValue(str15, "frameRate");
                            int i20 = attributeValue != null ? Integer.parseInt(attributeValue) : 30;
                            str4 = "TtmlParser";
                            String attributeValue2 = xmlPullParserNewPullParser.getAttributeValue(str15, "frameRateMultiplier");
                            if (attributeValue2 != null) {
                                arrayDeque2 = arrayDeque3;
                                String str17 = bb1.f9474a;
                                g9Var = g9Var4;
                                ih1.e0("frameRateMultiplier doesn't have 2 parts", attributeValue2.split(" ", -1).length == 2);
                                f15 = Integer.parseInt(r9[0]) / Integer.parseInt(r9[1]);
                            } else {
                                arrayDeque2 = arrayDeque3;
                                g9Var = g9Var4;
                                f15 = 1.0f;
                            }
                            int i21 = cVar3.f36768b;
                            String attributeValue3 = xmlPullParserNewPullParser.getAttributeValue(str15, "subFrameRate");
                            if (attributeValue3 != null) {
                                i21 = Integer.parseInt(attributeValue3);
                            }
                            int i22 = cVar3.f36769c;
                            cVar = cVar3;
                            String attributeValue4 = xmlPullParserNewPullParser.getAttributeValue(str15, "tickRate");
                            if (attributeValue4 != null) {
                                i22 = Integer.parseInt(attributeValue4);
                            }
                            y3.c cVar5 = new y3.c(i20 * f15, i21, i22);
                            String attributeValue5 = xmlPullParserNewPullParser.getAttributeValue(str15, "cellResolution");
                            if (attributeValue5 == null) {
                                str2 = str15;
                                cVar4 = cVar5;
                                i19 = 15;
                                strZzc5 = ke1.zzc(xmlPullParserNewPullParser, "extent");
                                if (strZzc5 == null) {
                                    aVar = null;
                                } else {
                                    Matcher matcher = pattern.matcher(strZzc5);
                                    if (matcher.matches()) {
                                        try {
                                            String strGroup = matcher.group(1);
                                            strGroup.getClass();
                                            int i23 = Integer.parseInt(strGroup);
                                            String strGroup2 = matcher.group(2);
                                            strGroup2.getClass();
                                            aVar = new v2.a(i23, Integer.parseInt(strGroup2), 2);
                                        } catch (NumberFormatException unused) {
                                            vt0.c("Ignoring malformed tts extent: ".concat(strZzc5));
                                            aVar = null;
                                        }
                                    } else {
                                        vt0.c("Ignoring non-pixel tts extent: ".concat(strZzc5));
                                    }
                                    aVar = null;
                                }
                            } else {
                                Matcher matcher2 = f12068h.matcher(attributeValue5);
                                if (matcher2.matches()) {
                                    try {
                                        String strGroup3 = matcher2.group(1);
                                        strGroup3.getClass();
                                        i16 = Integer.parseInt(strGroup3);
                                        str2 = str15;
                                        try {
                                            String strGroup4 = matcher2.group(2);
                                            strGroup4.getClass();
                                            int i24 = Integer.parseInt(strGroup4);
                                            if (i16 == 0) {
                                                i17 = i24;
                                                cVar4 = cVar5;
                                                z10 = false;
                                            } else if (i24 != 0) {
                                                i17 = i24;
                                                cVar4 = cVar5;
                                                z10 = true;
                                            } else {
                                                cVar4 = cVar5;
                                                z10 = false;
                                                i17 = 0;
                                            }
                                        } catch (NumberFormatException unused2) {
                                            cVar4 = cVar5;
                                            vt0.c("Ignoring malformed cell resolution: ".concat(attributeValue5));
                                            i19 = 15;
                                            strZzc5 = ke1.zzc(xmlPullParserNewPullParser, "extent");
                                            if (strZzc5 == null) {
                                            }
                                            xmlPullParserNewPullParser.next();
                                            eventType = xmlPullParserNewPullParser.getEventType();
                                            arrayDeque3 = arrayDeque;
                                            map5 = map;
                                            str14 = str;
                                            cVar3 = cVar;
                                            str15 = str2;
                                            str16 = str3;
                                        }
                                    } catch (NumberFormatException unused3) {
                                        str2 = str15;
                                    }
                                    if (z10) {
                                        i19 = i17;
                                        strZzc5 = ke1.zzc(xmlPullParserNewPullParser, "extent");
                                        if (strZzc5 == null) {
                                        }
                                    } else {
                                        try {
                                            throw new IllegalArgumentException(ih1.B0("Invalid cell resolution %s %s", Integer.valueOf(i16), Integer.valueOf(i17)));
                                        } catch (NumberFormatException unused4) {
                                            vt0.c("Ignoring malformed cell resolution: ".concat(attributeValue5));
                                            i19 = 15;
                                            strZzc5 = ke1.zzc(xmlPullParserNewPullParser, "extent");
                                            if (strZzc5 == null) {
                                            }
                                            xmlPullParserNewPullParser.next();
                                            eventType = xmlPullParserNewPullParser.getEventType();
                                            arrayDeque3 = arrayDeque;
                                            map5 = map;
                                            str14 = str;
                                            cVar3 = cVar;
                                            str15 = str2;
                                            str16 = str3;
                                        }
                                    }
                                } else {
                                    vt0.c("Ignoring malformed cell resolution: ".concat(attributeValue5));
                                    str2 = str15;
                                    cVar4 = cVar5;
                                    i19 = 15;
                                    strZzc5 = ke1.zzc(xmlPullParserNewPullParser, "extent");
                                    if (strZzc5 == null) {
                                    }
                                }
                            }
                        } else {
                            str2 = str15;
                            arrayDeque2 = arrayDeque3;
                            g9Var = g9Var4;
                            cVar = cVar3;
                            str4 = "TtmlParser";
                        }
                        y3.c cVar6 = cVar4;
                        v2.a aVar2 = aVar;
                        int i25 = i19;
                        boolean zEquals2 = name.equals("tt");
                        String str18 = "region";
                        String str19 = MimeTypes.BASE_TYPE_IMAGE;
                        cVar4 = cVar6;
                        String str20 = "metadata";
                        HashMap map6 = map5;
                        String str21 = "head";
                        if (zEquals2 || name.equals("head") || name.equals("body") || name.equals("div") || name.equals("p") || name.equals("span") || name.equals(CmcdConfiguration.KEY_BITRATE) || name.equals("style") || name.equals("styling") || name.equals("layout") || name.equals("region") || name.equals("metadata") || name.equals(MimeTypes.BASE_TYPE_IMAGE) || name.equals("data") || name.equals("information")) {
                            boolean zEquals3 = "head".equals(name);
                            String str22 = "\\s+";
                            if (zEquals3) {
                                while (true) {
                                    xmlPullParserNewPullParser.next();
                                    if (ke1.b(xmlPullParserNewPullParser, "style")) {
                                        String strZzc6 = ke1.zzc(xmlPullParserNewPullParser, "style");
                                        str3 = str16;
                                        k9 k9VarC = c(xmlPullParserNewPullParser, new k9());
                                        if (strZzc6 != null) {
                                            String strTrim = strZzc6.trim();
                                            if (strTrim.isEmpty()) {
                                                str13 = str21;
                                                strArrSplit2 = new String[0];
                                            } else {
                                                str13 = str21;
                                                String str23 = bb1.f9474a;
                                                strArrSplit2 = strTrim.split(str22, -1);
                                            }
                                            str6 = str22;
                                            int i26 = 0;
                                            for (int length = strArrSplit2.length; i26 < length; length = length) {
                                                k9VarC.zzr((k9) map3.get(strArrSplit2[i26]));
                                                i26++;
                                            }
                                        } else {
                                            str13 = str21;
                                            str6 = str22;
                                        }
                                        String strZzt = k9VarC.zzt();
                                        if (strZzt != null) {
                                            map3.put(strZzt, k9VarC);
                                        }
                                        i12 = i25;
                                        str7 = str18;
                                        str8 = str19;
                                        str9 = str13;
                                        map = map6;
                                    } else {
                                        str3 = str16;
                                        String str24 = str21;
                                        str6 = str22;
                                        if (ke1.b(xmlPullParserNewPullParser, str18)) {
                                            str7 = str18;
                                            String str25 = str19;
                                            String strZzc7 = ke1.zzc(xmlPullParserNewPullParser, InnerConstant.Db.f36069id);
                                            if (strZzc7 == null) {
                                                str11 = str20;
                                                map2 = map4;
                                                i12 = i25;
                                            } else {
                                                String strZzc8 = ke1.zzc(xmlPullParserNewPullParser, "origin");
                                                if (strZzc8 == null) {
                                                    str10 = strZzc8;
                                                    String strZzc9 = ke1.zzc(xmlPullParserNewPullParser, "style");
                                                    if (strZzc9 != null && (k9Var2 = (k9) map3.get(strZzc9)) != null) {
                                                        strZzL = k9Var2.zzL();
                                                        str11 = str20;
                                                    }
                                                    Pattern pattern2 = f12066f;
                                                    if (strZzL == null) {
                                                        map2 = map4;
                                                        Matcher matcher3 = pattern2.matcher(strZzL);
                                                        i13 = i25;
                                                        Matcher matcher4 = pattern.matcher(strZzL);
                                                        if (matcher3.matches()) {
                                                            str12 = "Ignoring region with unsupported extent: ";
                                                            try {
                                                                String strGroup5 = matcher3.group(1);
                                                                strGroup5.getClass();
                                                                float f16 = Float.parseFloat(strGroup5) / 100.0f;
                                                                String strGroup6 = matcher3.group(2);
                                                                strGroup6.getClass();
                                                                f10 = Float.parseFloat(strGroup6) / 100.0f;
                                                                f11 = f16;
                                                            } catch (NumberFormatException unused5) {
                                                                vt0.c("Ignoring region with malformed origin: ".concat(strZzL));
                                                            }
                                                        } else {
                                                            str12 = "Ignoring region with unsupported extent: ";
                                                            if (!matcher4.matches()) {
                                                                vt0.c("Ignoring region with unsupported origin: ".concat(strZzL));
                                                            } else if (aVar2 == null) {
                                                                vt0.c("Ignoring region with missing tts:extent: ".concat(strZzL));
                                                            } else {
                                                                try {
                                                                    String strGroup7 = matcher4.group(1);
                                                                    strGroup7.getClass();
                                                                    int i27 = Integer.parseInt(strGroup7);
                                                                    String strGroup8 = matcher4.group(2);
                                                                    strGroup8.getClass();
                                                                    float f17 = i27 / aVar2.f33652b;
                                                                    f10 = Integer.parseInt(strGroup8) / aVar2.f33653c;
                                                                    f11 = f17;
                                                                } catch (NumberFormatException unused6) {
                                                                    vt0.c("Ignoring region with malformed origin: ".concat(strZzL));
                                                                }
                                                            }
                                                            i12 = i13;
                                                        }
                                                    } else {
                                                        map2 = map4;
                                                        i13 = i25;
                                                        str12 = "Ignoring region with unsupported extent: ";
                                                        f10 = 0.0f;
                                                        f11 = 0.0f;
                                                    }
                                                    strZzc2 = ke1.zzc(xmlPullParserNewPullParser, "extent");
                                                    if (strZzc2 == null && (strZzc4 = ke1.zzc(xmlPullParserNewPullParser, "style")) != null && (k9Var = (k9) map3.get(strZzc4)) != null) {
                                                        strZzc2 = k9Var.zzN();
                                                    }
                                                    if (strZzc2 == null) {
                                                        Matcher matcher5 = pattern2.matcher(strZzc2);
                                                        Matcher matcher6 = pattern.matcher(strZzc2);
                                                        if (matcher5.matches()) {
                                                            try {
                                                                String strGroup9 = matcher5.group(1);
                                                                strGroup9.getClass();
                                                                float f18 = Float.parseFloat(strGroup9) / 100.0f;
                                                                String strGroup10 = matcher5.group(2);
                                                                strGroup10.getClass();
                                                                f13 = Float.parseFloat(strGroup10) / 100.0f;
                                                                f12 = f18;
                                                            } catch (NumberFormatException unused7) {
                                                                vt0.c("Ignoring region with malformed extent: ".concat(String.valueOf(strZzL)));
                                                                i12 = i13;
                                                                i9Var = null;
                                                            }
                                                        } else {
                                                            if (!matcher6.matches()) {
                                                                vt0.c(str12.concat(String.valueOf(strZzL)));
                                                            } else if (aVar2 == null) {
                                                                vt0.c("Ignoring region with missing tts:extent: ".concat(String.valueOf(strZzL)));
                                                            } else {
                                                                try {
                                                                    String strGroup11 = matcher6.group(1);
                                                                    strGroup11.getClass();
                                                                    int i28 = Integer.parseInt(strGroup11);
                                                                    String strGroup12 = matcher6.group(2);
                                                                    strGroup12.getClass();
                                                                    f12 = i28 / aVar2.f33652b;
                                                                    f13 = Integer.parseInt(strGroup12) / aVar2.f33653c;
                                                                } catch (NumberFormatException unused8) {
                                                                    vt0.c("Ignoring region with malformed extent: ".concat(String.valueOf(strZzL)));
                                                                    i12 = i13;
                                                                    i9Var = null;
                                                                }
                                                            }
                                                            i12 = i13;
                                                        }
                                                    } else {
                                                        f12 = 1.0f;
                                                        f13 = 1.0f;
                                                    }
                                                    strZzc3 = ke1.zzc(xmlPullParserNewPullParser, "displayAlign");
                                                    if (strZzc3 == null) {
                                                        String strR = ih1.r(strZzc3);
                                                        strR.getClass();
                                                        if (strR.equals("after")) {
                                                            f14 = f10 + f13;
                                                            i12 = i13;
                                                            i14 = 2;
                                                        } else if (strR.equals("center")) {
                                                            f14 = (f13 / 2.0f) + f10;
                                                            i12 = i13;
                                                            i14 = 1;
                                                        } else {
                                                            f14 = f10;
                                                            i12 = i13;
                                                            i14 = 0;
                                                        }
                                                        float f19 = 1.0f / i12;
                                                        String strZzc10 = ke1.zzc(xmlPullParserNewPullParser, "writingMode");
                                                        if (strZzc10 != null) {
                                                            String strR2 = ih1.r(strZzc10);
                                                            strR2.getClass();
                                                            switch (strR2) {
                                                                case "tb":
                                                                case "tblr":
                                                                    i15 = 2;
                                                                    break;
                                                                case "tbrl":
                                                                    i15 = 1;
                                                                    break;
                                                                default:
                                                                    i15 = Integer.MIN_VALUE;
                                                                    break;
                                                            }
                                                            i9Var = new i9(strZzc7, f11, f14, 0, i14, f12, f13, 1, f19, i15);
                                                            if (i9Var == null) {
                                                                map4 = map2;
                                                                map4.put(i9Var.f12413a, i9Var);
                                                            } else {
                                                                map4 = map2;
                                                            }
                                                            str9 = str24;
                                                            map = map6;
                                                            str8 = str25;
                                                            str20 = str11;
                                                        }
                                                    }
                                                } else {
                                                    str10 = strZzc8;
                                                }
                                                str11 = str20;
                                                strZzL = str10;
                                                Pattern pattern22 = f12066f;
                                                if (strZzL == null) {
                                                }
                                                strZzc2 = ke1.zzc(xmlPullParserNewPullParser, "extent");
                                                if (strZzc2 == null) {
                                                    strZzc2 = k9Var.zzN();
                                                }
                                                if (strZzc2 == null) {
                                                }
                                                strZzc3 = ke1.zzc(xmlPullParserNewPullParser, "displayAlign");
                                                if (strZzc3 == null) {
                                                }
                                            }
                                            i9Var = null;
                                            if (i9Var == null) {
                                            }
                                            str9 = str24;
                                            map = map6;
                                            str8 = str25;
                                            str20 = str11;
                                        } else {
                                            i12 = i25;
                                            str7 = str18;
                                            String str26 = str19;
                                            if (ke1.b(xmlPullParserNewPullParser, str20)) {
                                                while (true) {
                                                    xmlPullParserNewPullParser.next();
                                                    str8 = str26;
                                                    if (!ke1.b(xmlPullParserNewPullParser, str8) || (strZzc = ke1.zzc(xmlPullParserNewPullParser, InnerConstant.Db.f36069id)) == null) {
                                                        map = map6;
                                                    } else {
                                                        map = map6;
                                                        map.put(strZzc, xmlPullParserNewPullParser.nextText());
                                                    }
                                                    if (!ke1.a(xmlPullParserNewPullParser, str20)) {
                                                        str26 = str8;
                                                        map6 = map;
                                                    }
                                                }
                                            } else {
                                                map = map6;
                                                str8 = str26;
                                            }
                                            str9 = str24;
                                        }
                                    }
                                    if (ke1.a(xmlPullParserNewPullParser, str9)) {
                                        cVar2 = cVar4;
                                        arrayDeque = arrayDeque2;
                                    } else {
                                        i25 = i12;
                                        str19 = str8;
                                        map6 = map;
                                        str22 = str6;
                                        str18 = str7;
                                        str21 = str9;
                                        str16 = str3;
                                    }
                                }
                            } else {
                                str3 = str16;
                                i12 = i25;
                                Object obj2 = "region";
                                String str27 = "\\s+";
                                map = map6;
                                try {
                                    int attributeCount = xmlPullParserNewPullParser.getAttributeCount();
                                    k9 k9VarC2 = c(xmlPullParserNewPullParser, null);
                                    long j10 = -9223372036854775807L;
                                    String[] strArr = null;
                                    String strSubstring = null;
                                    long jD = -9223372036854775807L;
                                    long jD2 = -9223372036854775807L;
                                    long jD3 = -9223372036854775807L;
                                    String str28 = str;
                                    int i29 = 0;
                                    while (i29 < attributeCount) {
                                        try {
                                            String attributeName = xmlPullParserNewPullParser.getAttributeName(i29);
                                            String attributeValue6 = xmlPullParserNewPullParser.getAttributeValue(i29);
                                            attributeName.getClass();
                                            switch (attributeName.hashCode()) {
                                                case -934795532:
                                                    obj = obj2;
                                                    b10 = attributeName.equals(obj) ? (byte) 0 : (byte) -1;
                                                    break;
                                                case 99841:
                                                    if (attributeName.equals("dur")) {
                                                        obj = obj2;
                                                        b10 = 1;
                                                    } else {
                                                        obj = obj2;
                                                    }
                                                    break;
                                                case 100571:
                                                    if (attributeName.equals("end")) {
                                                        obj = obj2;
                                                        b10 = 2;
                                                    } else {
                                                        obj = obj2;
                                                    }
                                                    break;
                                                case 93616297:
                                                    if (attributeName.equals("begin")) {
                                                        obj = obj2;
                                                        b10 = 3;
                                                    } else {
                                                        obj = obj2;
                                                    }
                                                    break;
                                                case 109780401:
                                                    if (attributeName.equals("style")) {
                                                        obj = obj2;
                                                        b10 = 4;
                                                    } else {
                                                        obj = obj2;
                                                    }
                                                    break;
                                                case 1292595405:
                                                    if (attributeName.equals("backgroundImage")) {
                                                        b10 = 5;
                                                        obj = obj2;
                                                    } else {
                                                        obj = obj2;
                                                    }
                                                    break;
                                                default:
                                                    obj = obj2;
                                                    break;
                                            }
                                            switch (b10) {
                                                case 0:
                                                    cVar2 = cVar4;
                                                    str5 = str27;
                                                    if (map4.containsKey(attributeValue6)) {
                                                        str28 = attributeValue6;
                                                    }
                                                    i29++;
                                                    cVar4 = cVar2;
                                                    str27 = str5;
                                                    obj2 = obj;
                                                    cVar2 = null;
                                                    break;
                                                case 1:
                                                    cVar2 = cVar4;
                                                    str5 = str27;
                                                    jD3 = d(attributeValue6, cVar2);
                                                    i29++;
                                                    cVar4 = cVar2;
                                                    str27 = str5;
                                                    obj2 = obj;
                                                    cVar2 = null;
                                                    break;
                                                case 2:
                                                    cVar2 = cVar4;
                                                    str5 = str27;
                                                    jD = d(attributeValue6, cVar2);
                                                    i29++;
                                                    cVar4 = cVar2;
                                                    str27 = str5;
                                                    obj2 = obj;
                                                    cVar2 = null;
                                                    break;
                                                case 3:
                                                    cVar2 = cVar4;
                                                    str5 = str27;
                                                    try {
                                                        jD2 = d(attributeValue6, cVar2);
                                                        i29++;
                                                        cVar4 = cVar2;
                                                        str27 = str5;
                                                        obj2 = obj;
                                                        cVar2 = null;
                                                    } catch (zzamb e10) {
                                                        e = e10;
                                                        zzambVar = e;
                                                        arrayDeque = arrayDeque2;
                                                        vt0.zzd(str4, "Suppressing parser error", zzambVar);
                                                        i19 = i12;
                                                        cVar4 = cVar2;
                                                        aVar = aVar2;
                                                        l9Var2 = l9Var;
                                                        i18 = 1;
                                                        xmlPullParserNewPullParser.next();
                                                        eventType = xmlPullParserNewPullParser.getEventType();
                                                        arrayDeque3 = arrayDeque;
                                                        map5 = map;
                                                        str14 = str;
                                                        cVar3 = cVar;
                                                        str15 = str2;
                                                        str16 = str3;
                                                    }
                                                    break;
                                                case 4:
                                                    try {
                                                        String strTrim2 = attributeValue6.trim();
                                                        if (strTrim2.isEmpty()) {
                                                            strArrSplit = new String[0];
                                                            str5 = str27;
                                                        } else {
                                                            String str29 = bb1.f9474a;
                                                            str5 = str27;
                                                            strArrSplit = strTrim2.split(str5, -1);
                                                        }
                                                        if (strArrSplit.length > 0) {
                                                            strArr = strArrSplit;
                                                        }
                                                        cVar2 = cVar4;
                                                        i29++;
                                                        cVar4 = cVar2;
                                                        str27 = str5;
                                                        obj2 = obj;
                                                        cVar2 = null;
                                                    } catch (zzamb e11) {
                                                        e = e11;
                                                        zzambVar = e;
                                                        cVar2 = cVar4;
                                                        arrayDeque = arrayDeque2;
                                                        vt0.zzd(str4, "Suppressing parser error", zzambVar);
                                                        i19 = i12;
                                                        cVar4 = cVar2;
                                                        aVar = aVar2;
                                                        l9Var2 = l9Var;
                                                        i18 = 1;
                                                        xmlPullParserNewPullParser.next();
                                                        eventType = xmlPullParserNewPullParser.getEventType();
                                                        arrayDeque3 = arrayDeque;
                                                        map5 = map;
                                                        str14 = str;
                                                        cVar3 = cVar;
                                                        str15 = str2;
                                                        str16 = str3;
                                                    }
                                                    break;
                                                case 5:
                                                    try {
                                                        if (attributeValue6.startsWith("#")) {
                                                            try {
                                                                strSubstring = attributeValue6.substring(1);
                                                            } catch (zzamb e12) {
                                                                e = e12;
                                                                zzambVar = e;
                                                                cVar2 = cVar4;
                                                                arrayDeque = arrayDeque2;
                                                                vt0.zzd(str4, "Suppressing parser error", zzambVar);
                                                                i19 = i12;
                                                                cVar4 = cVar2;
                                                                aVar = aVar2;
                                                                l9Var2 = l9Var;
                                                                i18 = 1;
                                                                xmlPullParserNewPullParser.next();
                                                                eventType = xmlPullParserNewPullParser.getEventType();
                                                                arrayDeque3 = arrayDeque;
                                                                map5 = map;
                                                                str14 = str;
                                                                cVar3 = cVar;
                                                                str15 = str2;
                                                                str16 = str3;
                                                            }
                                                        }
                                                        break;
                                                    } catch (zzamb e13) {
                                                        e = e13;
                                                    }
                                                default:
                                                    cVar2 = cVar4;
                                                    str5 = str27;
                                                    i29++;
                                                    cVar4 = cVar2;
                                                    str27 = str5;
                                                    obj2 = obj;
                                                    cVar2 = null;
                                                    break;
                                            }
                                        } catch (zzamb e14) {
                                            e = e14;
                                            cVar2 = cVar4;
                                        }
                                    }
                                    cVar2 = cVar4;
                                    if (g9Var != null) {
                                        g9Var2 = g9Var;
                                        long j11 = g9Var2.f11620b;
                                        if (j11 == -9223372036854775807L) {
                                            g9Var3 = g9Var2;
                                        } else {
                                            jD2 = jD2 != -9223372036854775807L ? jD2 + j11 : -9223372036854775807L;
                                            if (jD != -9223372036854775807L) {
                                                jD += j11;
                                                g9Var3 = g9Var2;
                                            } else {
                                                g9Var3 = g9Var2;
                                                jD = -9223372036854775807L;
                                            }
                                        }
                                    } else {
                                        g9Var2 = g9Var;
                                        g9Var3 = null;
                                    }
                                    if (jD != -9223372036854775807L) {
                                        j10 = jD;
                                    } else if (jD3 != -9223372036854775807L) {
                                        j10 = jD2 + jD3;
                                    } else if (g9Var3 != null) {
                                        long j12 = g9Var3.f11621c;
                                        if (j12 != -9223372036854775807L) {
                                            j10 = j12;
                                        }
                                    }
                                    try {
                                        g9 g9VarZzb = g9.zzb(xmlPullParserNewPullParser.getName(), jD2, j10, k9VarC2, strArr, str28, strSubstring, g9Var3);
                                        arrayDeque = arrayDeque2;
                                        try {
                                            arrayDeque.push(g9VarZzb);
                                            if (g9Var2 != null) {
                                                if (g9Var2.f11625g == null) {
                                                    g9Var2.f11625g = new ArrayList();
                                                }
                                                g9Var2.f11625g.add(g9VarZzb);
                                            }
                                        } catch (zzamb e15) {
                                            e = e15;
                                            zzambVar = e;
                                            vt0.zzd(str4, "Suppressing parser error", zzambVar);
                                            i19 = i12;
                                            cVar4 = cVar2;
                                            aVar = aVar2;
                                            l9Var2 = l9Var;
                                            i18 = 1;
                                        }
                                    } catch (zzamb e16) {
                                        e = e16;
                                        arrayDeque = arrayDeque2;
                                        zzambVar = e;
                                        vt0.zzd(str4, "Suppressing parser error", zzambVar);
                                        i19 = i12;
                                        cVar4 = cVar2;
                                        aVar = aVar2;
                                        l9Var2 = l9Var;
                                        i18 = 1;
                                        xmlPullParserNewPullParser.next();
                                        eventType = xmlPullParserNewPullParser.getEventType();
                                        arrayDeque3 = arrayDeque;
                                        map5 = map;
                                        str14 = str;
                                        cVar3 = cVar;
                                        str15 = str2;
                                        str16 = str3;
                                    }
                                } catch (zzamb e17) {
                                    e = e17;
                                    cVar2 = cVar4;
                                }
                            }
                            i19 = i12;
                            cVar4 = cVar2;
                            aVar = aVar2;
                        } else {
                            String name2 = xmlPullParserNewPullParser.getName();
                            StringBuilder sb = new StringBuilder(String.valueOf(name2).length() + 26);
                            sb.append(str16);
                            sb.append(name2);
                            vt0.b(sb.toString());
                            str3 = str16;
                            aVar = aVar2;
                            i19 = i25;
                            l9Var2 = l9Var;
                            arrayDeque = arrayDeque2;
                            map = map6;
                        }
                        i18 = 1;
                    } else {
                        str2 = str15;
                        str3 = str16;
                        map = map5;
                        arrayDeque = arrayDeque3;
                        cVar = cVar3;
                        l9Var = l9Var2;
                        if (eventType == 4) {
                            g9Var4.getClass();
                            g9 g9VarA = g9.a(xmlPullParserNewPullParser.getText());
                            if (g9Var4.f11625g == null) {
                                g9Var4.f11625g = new ArrayList();
                            }
                            g9Var4.f11625g.add(g9VarA);
                        } else if (eventType == 3) {
                            if (xmlPullParserNewPullParser.getName().equals("tt")) {
                                g9 g9Var5 = (g9) arrayDeque.peek();
                                g9Var5.getClass();
                                l9Var2 = new l9(g9Var5, map3, map4, map);
                            } else {
                                l9Var2 = l9Var;
                            }
                            arrayDeque.pop();
                        }
                    }
                    xmlPullParserNewPullParser.next();
                    eventType = xmlPullParserNewPullParser.getEventType();
                    arrayDeque3 = arrayDeque;
                    map5 = map;
                    str14 = str;
                    cVar3 = cVar;
                    str15 = str2;
                    str16 = str3;
                } else {
                    str = str14;
                    str2 = str15;
                    str3 = str16;
                    map = map5;
                    arrayDeque = arrayDeque3;
                    cVar = cVar3;
                    l9Var = l9Var2;
                    if (eventType == 2) {
                        i18++;
                    } else if (eventType == 3) {
                        i18--;
                    }
                }
                l9Var2 = l9Var;
                xmlPullParserNewPullParser.next();
                eventType = xmlPullParserNewPullParser.getEventType();
                arrayDeque3 = arrayDeque;
                map5 = map;
                str14 = str;
                cVar3 = cVar;
                str15 = str2;
                str16 = str3;
            }
            l9 l9Var3 = l9Var2;
            l9Var3.getClass();
            return l9Var3;
        } catch (IOException e18) {
            throw new IllegalStateException("Unexpected error when reading input.", e18);
        } catch (XmlPullParserException e19) {
            throw new IllegalStateException("Unable to decode source", e19);
        }
    }

    @Override // com.google.android.gms.internal.ads.j8
    public final void b(byte[] bArr, int i10, int i11, g7.h hVar) {
        za2.j(a(i10, i11, bArr), hVar);
    }
}
