JavDB.apk(点击下载) / c.java


package f3;

import android.text.Layout;
import com.google.android.exoplayer2.text.SubtitleDecoderException;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import k3.f;
import k3.j0;
import k3.k0;
import k3.p;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
import tv.danmaku.ijk.media.player.BuildConfig;
import y2.g;
import y2.h;

public final class c extends g {

    /* renamed from: p  reason: collision with root package name */
    private static final Pattern f7202p = Pattern.compile("^([0-9][0-9]+):([0-9][0-9]):([0-9][0-9])(?:(\\.[0-9]+)|:([0-9][0-9])(?:\\.([0-9]+))?)?$");

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

    /* renamed from: r  reason: collision with root package name */
    private static final Pattern f7204r = Pattern.compile("^(([0-9]*.)?[0-9]+)(px|em|%)$");

    /* renamed from: s  reason: collision with root package name */
    static final Pattern f7205s = Pattern.compile("^([-+]?\\d+\\.?\\d*?)%$");

    /* renamed from: t  reason: collision with root package name */
    static final Pattern f7206t = Pattern.compile("^(\\d+\\.?\\d*?)% (\\d+\\.?\\d*?)%$");

    /* renamed from: u  reason: collision with root package name */
    private static final Pattern f7207u = Pattern.compile("^(\\d+\\.?\\d*?)px (\\d+\\.?\\d*?)px$");

    /* renamed from: v  reason: collision with root package name */
    private static final Pattern f7208v = Pattern.compile("^(\\d+) (\\d+)$");

    /* renamed from: w  reason: collision with root package name */
    private static final b f7209w = new b(30.0f, 1, 1);

    /* renamed from: x  reason: collision with root package name */
    private static final a f7210x = new a(32, 15);

    /* renamed from: o  reason: collision with root package name */
    private final XmlPullParserFactory f7211o;

    /* access modifiers changed from: private */
    public static final class a {

        /* renamed from: a  reason: collision with root package name */
        final int f7212a;

        /* renamed from: b  reason: collision with root package name */
        final int f7213b;

        a(int i7, int i8) {
            this.f7212a = i7;
            this.f7213b = i8;
        }
    }

    /* access modifiers changed from: private */
    public static final class b {

        /* renamed from: a  reason: collision with root package name */
        final float f7214a;

        /* renamed from: b  reason: collision with root package name */
        final int f7215b;

        /* renamed from: c  reason: collision with root package name */
        final int f7216c;

        b(float f7, int i7, int i8) {
            this.f7214a = f7;
            this.f7215b = i7;
            this.f7216c = i8;
        }
    }

    /* access modifiers changed from: private */
    /* renamed from: f3.c$c  reason: collision with other inner class name */
    public static final class C0119c {

        /* renamed from: a  reason: collision with root package name */
        final int f7217a;

        /* renamed from: b  reason: collision with root package name */
        final int f7218b;

        C0119c(int i7, int i8) {
            this.f7217a = i7;
            this.f7218b = i8;
        }
    }

    public c() {
        super("TtmlDecoder");
        try {
            XmlPullParserFactory newInstance = XmlPullParserFactory.newInstance();
            this.f7211o = newInstance;
            newInstance.setNamespaceAware(true);
        } catch (XmlPullParserException e7) {
            throw new RuntimeException("Couldn't create XmlPullParserFactory instance", e7);
        }
    }

    private static g B(g gVar) {
        return gVar == null ? new g() : gVar;
    }

    private static boolean C(String str) {
        return str.equals("tt") || str.equals("head") || str.equals("body") || str.equals("div") || str.equals("p") || str.equals("span") || str.equals("br") || str.equals("style") || str.equals("styling") || str.equals("layout") || str.equals("region") || str.equals("metadata") || str.equals("image") || str.equals("data") || str.equals("information");
    }

    private static Layout.Alignment D(String str) {
        String e7 = n3.a.e(str);
        e7.hashCode();
        char c7 = 65535;
        switch (e7.hashCode()) {
            case -1364013995:
                if (e7.equals("center")) {
                    c7 = 0;
                    break;
                }
                break;
            case 100571:
                if (e7.equals("end")) {
                    c7 = 1;
                    break;
                }
                break;
            case 3317767:
                if (e7.equals("left")) {
                    c7 = 2;
                    break;
                }
                break;
            case 108511772:
                if (e7.equals("right")) {
                    c7 = 3;
                    break;
                }
                break;
            case 109757538:
                if (e7.equals("start")) {
                    c7 = 4;
                    break;
                }
                break;
        }
        switch (c7) {
            case 0:
                return Layout.Alignment.ALIGN_CENTER;
            case 1:
            case 3:
                return Layout.Alignment.ALIGN_OPPOSITE;
            case 2:
            case 4:
                return Layout.Alignment.ALIGN_NORMAL;
            default:
                return null;
        }
    }

    private static a E(XmlPullParser xmlPullParser, a aVar) throws SubtitleDecoderException {
        String attributeValue = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "cellResolution");
        if (attributeValue == null) {
            return aVar;
        }
        Matcher matcher = f7208v.matcher(attributeValue);
        if (!matcher.matches()) {
            p.i("TtmlDecoder", "Ignoring malformed cell resolution: " + attributeValue);
            return aVar;
        }
        try {
            int parseInt = Integer.parseInt((String) k3.a.e(matcher.group(1)));
            int parseInt2 = Integer.parseInt((String) k3.a.e(matcher.group(2)));
            if (parseInt != 0 && parseInt2 != 0) {
                return new a(parseInt, parseInt2);
            }
            throw new SubtitleDecoderException("Invalid cell resolution " + parseInt + " " + parseInt2);
        } catch (NumberFormatException unused) {
            p.i("TtmlDecoder", "Ignoring malformed cell resolution: " + attributeValue);
            return aVar;
        }
    }

    private static void F(String str, g gVar) throws SubtitleDecoderException {
        Matcher matcher;
        String[] P0 = j0.P0(str, "\\s+");
        if (P0.length == 1) {
            matcher = f7204r.matcher(str);
        } else if (P0.length == 2) {
            matcher = f7204r.matcher(P0[1]);
            p.i("TtmlDecoder", "Multiple values in fontSize attribute. Picking the second value for vertical font size and ignoring the first.");
        } else {
            throw new SubtitleDecoderException("Invalid number of entries for fontSize: " + P0.length + ".");
        }
        if (matcher.matches()) {
            String str2 = (String) k3.a.e(matcher.group(3));
            str2.hashCode();
            char c7 = 65535;
            switch (str2.hashCode()) {
                case 37:
                    if (str2.equals("%")) {
                        c7 = 0;
                        break;
                    }
                    break;
                case 3240:
                    if (str2.equals("em")) {
                        c7 = 1;
                        break;
                    }
                    break;
                case 3592:
                    if (str2.equals("px")) {
                        c7 = 2;
                        break;
                    }
                    break;
            }
            switch (c7) {
                case 0:
                    gVar.z(3);
                    break;
                case 1:
                    gVar.z(2);
                    break;
                case 2:
                    gVar.z(1);
                    break;
                default:
                    throw new SubtitleDecoderException("Invalid unit for fontSize: '" + str2 + "'.");
            }
            gVar.y(Float.parseFloat((String) k3.a.e(matcher.group(1))));
            return;
        }
        throw new SubtitleDecoderException("Invalid expression for fontSize: '" + str + "'.");
    }

    private static b G(XmlPullParser xmlPullParser) throws SubtitleDecoderException {
        String attributeValue = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "frameRate");
        int parseInt = attributeValue != null ? Integer.parseInt(attributeValue) : 30;
        float f7 = 1.0f;
        String attributeValue2 = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "frameRateMultiplier");
        if (attributeValue2 != null) {
            String[] P0 = j0.P0(attributeValue2, " ");
            if (P0.length == 2) {
                f7 = ((float) Integer.parseInt(P0[0])) / ((float) Integer.parseInt(P0[1]));
            } else {
                throw new SubtitleDecoderException("frameRateMultiplier doesn't have 2 parts");
            }
        }
        b bVar = f7209w;
        int i7 = bVar.f7215b;
        String attributeValue3 = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "subFrameRate");
        if (attributeValue3 != null) {
            i7 = Integer.parseInt(attributeValue3);
        }
        int i8 = bVar.f7216c;
        String attributeValue4 = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "tickRate");
        if (attributeValue4 != null) {
            i8 = Integer.parseInt(attributeValue4);
        }
        return new b(((float) parseInt) * f7, i7, i8);
    }

    private static Map<String, g> H(XmlPullParser xmlPullParser, Map<String, g> map, a aVar, C0119c cVar, Map<String, e> map2, Map<String, String> map3) throws IOException, XmlPullParserException {
        do {
            xmlPullParser.next();
            if (k0.f(xmlPullParser, "style")) {
                String a7 = k0.a(xmlPullParser, "style");
                g M = M(xmlPullParser, new g());
                if (a7 != null) {
                    for (String str : N(a7)) {
                        M.a(map.get(str));
                    }
                }
                String g7 = M.g();
                if (g7 != null) {
                    map.put(g7, M);
                }
            } else if (k0.f(xmlPullParser, "region")) {
                e K = K(xmlPullParser, aVar, cVar);
                if (K != null) {
                    map2.put(K.f7232a, K);
                }
            } else if (k0.f(xmlPullParser, "metadata")) {
                I(xmlPullParser, map3);
            }
        } while (!k0.d(xmlPullParser, "head"));
        return map;
    }

    private static void I(XmlPullParser xmlPullParser, Map<String, String> map) throws IOException, XmlPullParserException {
        String a7;
        do {
            xmlPullParser.next();
            if (k0.f(xmlPullParser, "image") && (a7 = k0.a(xmlPullParser, "id")) != null) {
                map.put(a7, xmlPullParser.nextText());
            }
        } while (!k0.d(xmlPullParser, "metadata"));
    }

    /* JADX INFO: Can't fix incorrect switch cases order, some code will duplicate */
    private static d J(XmlPullParser xmlPullParser, d dVar, Map<String, e> map, b bVar) throws SubtitleDecoderException {
        long j7;
        long j8;
        char c7;
        int attributeCount = xmlPullParser.getAttributeCount();
        g M = M(xmlPullParser, null);
        String str = null;
        String str2 = BuildConfig.VERSION_NAME;
        long j9 = -9223372036854775807L;
        long j10 = -9223372036854775807L;
        long j11 = -9223372036854775807L;
        String[] strArr = null;
        for (int i7 = 0; i7 < attributeCount; i7++) {
            String attributeName = xmlPullParser.getAttributeName(i7);
            String attributeValue = xmlPullParser.getAttributeValue(i7);
            attributeName.hashCode();
            switch (attributeName.hashCode()) {
                case -934795532:
                    if (attributeName.equals("region")) {
                        c7 = 0;
                        break;
                    }
                    c7 = 65535;
                    break;
                case 99841:
                    if (attributeName.equals("dur")) {
                        c7 = 1;
                        break;
                    }
                    c7 = 65535;
                    break;
                case 100571:
                    if (attributeName.equals("end")) {
                        c7 = 2;
                        break;
                    }
                    c7 = 65535;
                    break;
                case 93616297:
                    if (attributeName.equals("begin")) {
                        c7 = 3;
                        break;
                    }
                    c7 = 65535;
                    break;
                case 109780401:
                    if (attributeName.equals("style")) {
                        c7 = 4;
                        break;
                    }
                    c7 = 65535;
                    break;
                case 1292595405:
                    if (attributeName.equals("backgroundImage")) {
                        c7 = 5;
                        break;
                    }
                    c7 = 65535;
                    break;
                default:
                    c7 = 65535;
                    break;
            }
            switch (c7) {
                case 0:
                    if (map.containsKey(attributeValue)) {
                        str2 = attributeValue;
                        continue;
                    }
                case 1:
                    j11 = O(attributeValue, bVar);
                    break;
                case 2:
                    j10 = O(attributeValue, bVar);
                    break;
                case 3:
                    j9 = O(attributeValue, bVar);
                    break;
                case 4:
                    String[] N = N(attributeValue);
                    if (N.length > 0) {
                        strArr = N;
                        break;
                    }
                    break;
                case 5:
                    if (attributeValue.startsWith("#")) {
                        str = attributeValue.substring(1);
                        break;
                    }
                    break;
            }
        }
        if (dVar != null) {
            long j12 = dVar.f7222d;
            j7 = -9223372036854775807L;
            if (j12 != -9223372036854775807L) {
                if (j9 != -9223372036854775807L) {
                    j9 += j12;
                }
                if (j10 != -9223372036854775807L) {
                    j10 += j12;
                }
            }
        } else {
            j7 = -9223372036854775807L;
        }
        if (j10 == j7) {
            if (j11 != j7) {
                j8 = j9 + j11;
            } else if (dVar != null) {
                long j13 = dVar.f7223e;
                if (j13 != j7) {
                    j8 = j13;
                }
            }
            return d.c(xmlPullParser.getName(), j9, j8, M, strArr, str2, str, dVar);
        }
        j8 = j10;
        return d.c(xmlPullParser.getName(), j9, j8, M, strArr, str2, str, dVar);
    }

    /* JADX INFO: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARNING: Code restructure failed: missing block: B:60:0x01a7, code lost:
        if (r0.equals("tb") == false) goto L_0x0189;
     */
    /* JADX WARNING: Removed duplicated region for block: B:50:0x017a  */
    private static e K(XmlPullParser xmlPullParser, a aVar, C0119c cVar) {
        float f7;
        float f8;
        float f9;
        float f10;
        int i7;
        float f11;
        String a7;
        int i8;
        String a8 = k0.a(xmlPullParser, "id");
        if (a8 == null) {
            return null;
        }
        String a9 = k0.a(xmlPullParser, "origin");
        if (a9 != null) {
            Pattern pattern = f7206t;
            Matcher matcher = pattern.matcher(a9);
            Pattern pattern2 = f7207u;
            Matcher matcher2 = pattern2.matcher(a9);
            if (matcher.matches()) {
                try {
                    float parseFloat = Float.parseFloat((String) k3.a.e(matcher.group(1))) / 100.0f;
                    f7 = Float.parseFloat((String) k3.a.e(matcher.group(2))) / 100.0f;
                    f8 = parseFloat;
                } catch (NumberFormatException unused) {
                    p.i("TtmlDecoder", "Ignoring region with malformed origin: " + a9);
                    return null;
                }
            } else if (!matcher2.matches()) {
                p.i("TtmlDecoder", "Ignoring region with unsupported origin: " + a9);
                return null;
            } else if (cVar == null) {
                p.i("TtmlDecoder", "Ignoring region with missing tts:extent: " + a9);
                return null;
            } else {
                try {
                    int parseInt = Integer.parseInt((String) k3.a.e(matcher2.group(1)));
                    int parseInt2 = Integer.parseInt((String) k3.a.e(matcher2.group(2)));
                    f8 = ((float) parseInt) / ((float) cVar.f7217a);
                    f7 = ((float) parseInt2) / ((float) cVar.f7218b);
                } catch (NumberFormatException unused2) {
                    p.i("TtmlDecoder", "Ignoring region with malformed origin: " + a9);
                    return null;
                }
            }
            String a10 = k0.a(xmlPullParser, "extent");
            if (a10 != null) {
                Matcher matcher3 = pattern.matcher(a10);
                Matcher matcher4 = pattern2.matcher(a10);
                if (matcher3.matches()) {
                    try {
                        f10 = Float.parseFloat((String) k3.a.e(matcher3.group(1))) / 100.0f;
                        f9 = Float.parseFloat((String) k3.a.e(matcher3.group(2))) / 100.0f;
                    } catch (NumberFormatException unused3) {
                        p.i("TtmlDecoder", "Ignoring region with malformed extent: " + a9);
                        return null;
                    }
                } else if (!matcher4.matches()) {
                    p.i("TtmlDecoder", "Ignoring region with unsupported extent: " + a9);
                    return null;
                } else if (cVar == null) {
                    p.i("TtmlDecoder", "Ignoring region with missing tts:extent: " + a9);
                    return null;
                } else {
                    try {
                        int parseInt3 = Integer.parseInt((String) k3.a.e(matcher4.group(1)));
                        int parseInt4 = Integer.parseInt((String) k3.a.e(matcher4.group(2)));
                        float f12 = ((float) parseInt3) / ((float) cVar.f7217a);
                        f10 = f12;
                        f9 = ((float) parseInt4) / ((float) cVar.f7218b);
                    } catch (NumberFormatException unused4) {
                        p.i("TtmlDecoder", "Ignoring region with malformed extent: " + a9);
                        return null;
                    }
                }
                String a11 = k0.a(xmlPullParser, "displayAlign");
                char c7 = 0;
                if (a11 != null) {
                    String e7 = n3.a.e(a11);
                    e7.hashCode();
                    if (e7.equals("center")) {
                        f11 = f7 + (f9 / 2.0f);
                        i7 = 1;
                    } else if (e7.equals("after")) {
                        f11 = f7 + f9;
                        i7 = 2;
                    }
                    float f13 = 1.0f / ((float) aVar.f7213b);
                    a7 = k0.a(xmlPullParser, "writingMode");
                    if (a7 != null) {
                        String e8 = n3.a.e(a7);
                        e8.hashCode();
                        switch (e8.hashCode()) {
                            case 3694:
                                break;
                            case 3553396:
                                if (e8.equals("tblr")) {
                                    c7 = 1;
                                    break;
                                }
                                c7 = 65535;
                                break;
                            case 3553576:
                                if (e8.equals("tbrl")) {
                                    c7 = 2;
                                    break;
                                }
                                c7 = 65535;
                                break;
                            default:
                                c7 = 65535;
                                break;
                        }
                        switch (c7) {
                            case 0:
                            case 1:
                                i8 = 2;
                                break;
                            case 2:
                                i8 = 1;
                                break;
                        }
                        return new e(a8, f8, f11, 0, i7, f10, f9, 1, f13, i8);
                    }
                    i8 = Integer.MIN_VALUE;
                    return new e(a8, f8, f11, 0, i7, f10, f9, 1, f13, i8);
                }
                f11 = f7;
                i7 = 0;
                float f132 = 1.0f / ((float) aVar.f7213b);
                a7 = k0.a(xmlPullParser, "writingMode");
                if (a7 != null) {
                }
                i8 = Integer.MIN_VALUE;
                return new e(a8, f8, f11, 0, i7, f10, f9, 1, f132, i8);
            }
            p.i("TtmlDecoder", "Ignoring region without an extent");
            return null;
        }
        p.i("TtmlDecoder", "Ignoring region without an origin");
        return null;
    }

    private static float L(String str) {
        Matcher matcher = f7205s.matcher(str);
        if (!matcher.matches()) {
            p.i("TtmlDecoder", "Invalid value for shear: " + str);
            return Float.MAX_VALUE;
        }
        try {
            return Math.min(100.0f, Math.max(-100.0f, Float.parseFloat((String) k3.a.e(matcher.group(1)))));
        } catch (NumberFormatException e7) {
            p.j("TtmlDecoder", "Failed to parse shear: " + str, e7);
            return Float.MAX_VALUE;
        }
    }

    /* JADX INFO: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARNING: Code restructure failed: missing block: B:85:0x01e0, code lost:
        if (r3.equals("text") == false) goto L_0x01d8;
     */
    private static g M(XmlPullParser xmlPullParser, g gVar) {
        char c7;
        int attributeCount = xmlPullParser.getAttributeCount();
        for (int i7 = 0; i7 < attributeCount; i7++) {
            String attributeValue = xmlPullParser.getAttributeValue(i7);
            String attributeName = xmlPullParser.getAttributeName(i7);
            attributeName.hashCode();
            char c8 = 5;
            char c9 = 65535;
            switch (attributeName.hashCode()) {
                case -1550943582:
                    if (attributeName.equals("fontStyle")) {
                        c7 = 0;
                        break;
                    }
                    c7 = 65535;
                    break;
                case -1224696685:
                    if (attributeName.equals("fontFamily")) {
                        c7 = 1;
                        break;
                    }
                    c7 = 65535;
                    break;
                case -1065511464:
                    if (attributeName.equals("textAlign")) {
                        c7 = 2;
                        break;
                    }
                    c7 = 65535;
                    break;
                case -879295043:
                    if (attributeName.equals("textDecoration")) {
                        c7 = 3;
                        break;
                    }
                    c7 = 65535;
                    break;
                case -734428249:
                    if (attributeName.equals("fontWeight")) {
                        c7 = 4;
                        break;
                    }
                    c7 = 65535;
                    break;
                case 3355:
                    if (attributeName.equals("id")) {
                        c7 = 5;
                        break;
                    }
                    c7 = 65535;
                    break;
                case 3511770:
                    if (attributeName.equals("ruby")) {
                        c7 = 6;
                        break;
                    }
                    c7 = 65535;
                    break;
                case 94842723:
                    if (attributeName.equals("color")) {
                        c7 = 7;
                        break;
                    }
                    c7 = 65535;
                    break;
                case 109403361:
                    if (attributeName.equals("shear")) {
                        c7 = '\b';
                        break;
                    }
                    c7 = 65535;
                    break;
                case 110138194:
                    if (attributeName.equals("textCombine")) {
                        c7 = '\t';
                        break;
                    }
                    c7 = 65535;
                    break;
                case 365601008:
                    if (attributeName.equals("fontSize")) {
                        c7 = '\n';
                        break;
                    }
                    c7 = 65535;
                    break;
                case 921125321:
                    if (attributeName.equals("textEmphasis")) {
                        c7 = 11;
                        break;
                    }
                    c7 = 65535;
                    break;
                case 1115953443:
                    if (attributeName.equals("rubyPosition")) {
                        c7 = '\f';
                        break;
                    }
                    c7 = 65535;
                    break;
                case 1287124693:
                    if (attributeName.equals("backgroundColor")) {
                        c7 = '\r';
                        break;
                    }
                    c7 = 65535;
                    break;
                case 1754920356:
                    if (attributeName.equals("multiRowAlign")) {
                        c7 = 14;
                        break;
                    }
                    c7 = 65535;
                    break;
                default:
                    c7 = 65535;
                    break;
            }
            switch (c7) {
                case 0:
                    gVar = B(gVar).B("italic".equalsIgnoreCase(attributeValue));
                    break;
                case 1:
                    gVar = B(gVar).x(attributeValue);
                    break;
                case 2:
                    gVar = B(gVar).H(D(attributeValue));
                    break;
                case 3:
                    String e7 = n3.a.e(attributeValue);
                    e7.hashCode();
                    switch (e7.hashCode()) {
                        case -1461280213:
                            if (e7.equals("nounderline")) {
                                c9 = 0;
                                break;
                            }
                            break;
                        case -1026963764:
                            if (e7.equals("underline")) {
                                c9 = 1;
                                break;
                            }
                            break;
                        case 913457136:
                            if (e7.equals("nolinethrough")) {
                                c9 = 2;
                                break;
                            }
                            break;
                        case 1679736913:
                            if (e7.equals("linethrough")) {
                                c9 = 3;
                                break;
                            }
                            break;
                    }
                    switch (c9) {
                        case 0:
                            gVar = B(gVar).K(false);
                            continue;
                        case 1:
                            gVar = B(gVar).K(true);
                            continue;
                        case 2:
                            gVar = B(gVar).C(false);
                            continue;
                        case 3:
                            gVar = B(gVar).C(true);
                            continue;
                    }
                case 4:
                    gVar = B(gVar).v("bold".equalsIgnoreCase(attributeValue));
                    break;
                case 5:
                    if ("style".equals(xmlPullParser.getName())) {
                        gVar = B(gVar).A(attributeValue);
                        break;
                    } else {
                        break;
                    }
                case 6:
                    String e8 = n3.a.e(attributeValue);
                    e8.hashCode();
                    switch (e8.hashCode()) {
                        case -618561360:
                            if (e8.equals("baseContainer")) {
                                c8 = 0;
                                break;
                            }
                            c8 = 65535;
                            break;
                        case -410956671:
                            if (e8.equals("container")) {
                                c8 = 1;
                                break;
                            }
                            c8 = 65535;
                            break;
                        case -250518009:
                            if (e8.equals("delimiter")) {
                                c8 = 2;
                                break;
                            }
                            c8 = 65535;
                            break;
                        case -136074796:
                            if (e8.equals("textContainer")) {
                                c8 = 3;
                                break;
                            }
                            c8 = 65535;
                            break;
                        case 3016401:
                            if (e8.equals("base")) {
                                c8 = 4;
                                break;
                            }
                            c8 = 65535;
                            break;
                        case 3556653:
                            break;
                        default:
                            c8 = 65535;
                            break;
                    }
                    switch (c8) {
                        case 0:
                        case 4:
                            gVar = B(gVar).F(2);
                            continue;
                        case 1:
                            gVar = B(gVar).F(1);
                            continue;
                        case 2:
                            gVar = B(gVar).F(4);
                            continue;
                        case 3:
                        case 5:
                            gVar = B(gVar).F(3);
                            continue;
                    }
                case 7:
                    gVar = B(gVar);
                    try {
                        gVar.w(f.c(attributeValue));
                        break;
                    } catch (IllegalArgumentException unused) {
                        p.i("TtmlDecoder", "Failed parsing color value: " + attributeValue);
                        break;
                    }
                case '\b':
                    gVar = B(gVar).G(L(attributeValue));
                    break;
                case '\t':
                    String e9 = n3.a.e(attributeValue);
                    e9.hashCode();
                    if (!e9.equals("all")) {
                        if (!e9.equals("none")) {
                            break;
                        } else {
                            gVar = B(gVar).I(false);
                            break;
                        }
                    } else {
                        gVar = B(gVar).I(true);
                        break;
                    }
                case '\n':
                    try {
                        gVar = B(gVar);
                        F(attributeValue, gVar);
                        break;
                    } catch (SubtitleDecoderException unused2) {
                        p.i("TtmlDecoder", "Failed parsing fontSize value: " + attributeValue);
                        break;
                    }
                case 11:
                    gVar = B(gVar).J(b.a(attributeValue));
                    break;
                case '\f':
                    String e10 = n3.a.e(attributeValue);
                    e10.hashCode();
                    if (!e10.equals("before")) {
                        if (!e10.equals("after")) {
                            break;
                        } else {
                            gVar = B(gVar).E(2);
                            break;
                        }
                    } else {
                        gVar = B(gVar).E(1);
                        break;
                    }
                case '\r':
                    gVar = B(gVar);
                    try {
                        gVar.u(f.c(attributeValue));
                        break;
                    } catch (IllegalArgumentException unused3) {
                        p.i("TtmlDecoder", "Failed parsing background value: " + attributeValue);
                        break;
                    }
                case 14:
                    gVar = B(gVar).D(D(attributeValue));
                    break;
            }
        }
        return gVar;
    }

    private static String[] N(String str) {
        String trim = str.trim();
        return trim.isEmpty() ? new String[0] : j0.P0(trim, "\\s+");
    }

    /* JADX INFO: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARNING: Code restructure failed: missing block: B:21:0x00bf, code lost:
        if (r13.equals("ms") == false) goto L_0x00b7;
     */
    private static long O(String str, b bVar) throws SubtitleDecoderException {
        double d7;
        double d8;
        Matcher matcher = f7202p.matcher(str);
        char c7 = 4;
        if (matcher.matches()) {
            double parseLong = ((double) (Long.parseLong((String) k3.a.e(matcher.group(1))) * 3600)) + ((double) (Long.parseLong((String) k3.a.e(matcher.group(2))) * 60)) + ((double) Long.parseLong((String) k3.a.e(matcher.group(3))));
            String group = matcher.group(4);
            double d9 = 0.0d;
            double parseDouble = parseLong + (group != null ? Double.parseDouble(group) : 0.0d);
            String group2 = matcher.group(5);
            double parseLong2 = parseDouble + (group2 != null ? (double) (((float) Long.parseLong(group2)) / bVar.f7214a) : 0.0d);
            String group3 = matcher.group(6);
            if (group3 != null) {
                d9 = (((double) Long.parseLong(group3)) / ((double) bVar.f7215b)) / ((double) bVar.f7214a);
            }
            return (long) ((parseLong2 + d9) * 1000000.0d);
        }
        Matcher matcher2 = f7203q.matcher(str);
        if (matcher2.matches()) {
            double parseDouble2 = Double.parseDouble((String) k3.a.e(matcher2.group(1)));
            String str2 = (String) k3.a.e(matcher2.group(2));
            str2.hashCode();
            switch (str2.hashCode()) {
                case 102:
                    if (str2.equals("f")) {
                        c7 = 0;
                        break;
                    }
                    c7 = 65535;
                    break;
                case 104:
                    if (str2.equals("h")) {
                        c7 = 1;
                        break;
                    }
                    c7 = 65535;
                    break;
                case 109:
                    if (str2.equals("m")) {
                        c7 = 2;
                        break;
                    }
                    c7 = 65535;
                    break;
                case 116:
                    if (str2.equals("t")) {
                        c7 = 3;
                        break;
                    }
                    c7 = 65535;
                    break;
                case 3494:
                    break;
                default:
                    c7 = 65535;
                    break;
            }
            switch (c7) {
                case 0:
                    d7 = (double) bVar.f7214a;
                    parseDouble2 /= d7;
                    return (long) (parseDouble2 * 1000000.0d);
                case 1:
                    d8 = 3600.0d;
                    parseDouble2 *= d8;
                    return (long) (parseDouble2 * 1000000.0d);
                case 2:
                    d8 = 60.0d;
                    parseDouble2 *= d8;
                    return (long) (parseDouble2 * 1000000.0d);
                case 3:
                    d7 = (double) bVar.f7216c;
                    parseDouble2 /= d7;
                    return (long) (parseDouble2 * 1000000.0d);
                case 4:
                    d7 = 1000.0d;
                    parseDouble2 /= d7;
                    return (long) (parseDouble2 * 1000000.0d);
                default:
                    return (long) (parseDouble2 * 1000000.0d);
            }
        } else {
            throw new SubtitleDecoderException("Malformed time expression: " + str);
        }
    }

    private static C0119c P(XmlPullParser xmlPullParser) {
        String a7 = k0.a(xmlPullParser, "extent");
        if (a7 == null) {
            return null;
        }
        Matcher matcher = f7207u.matcher(a7);
        if (!matcher.matches()) {
            p.i("TtmlDecoder", "Ignoring non-pixel tts extent: " + a7);
            return null;
        }
        try {
            return new C0119c(Integer.parseInt((String) k3.a.e(matcher.group(1))), Integer.parseInt((String) k3.a.e(matcher.group(2))));
        } catch (NumberFormatException unused) {
            p.i("TtmlDecoder", "Ignoring malformed tts extent: " + a7);
            return null;
        }
    }

    /* access modifiers changed from: protected */
    @Override // y2.g
    public h A(byte[] bArr, int i7, boolean z6) throws SubtitleDecoderException {
        b bVar;
        try {
            XmlPullParser newPullParser = this.f7211o.newPullParser();
            HashMap hashMap = new HashMap();
            HashMap hashMap2 = new HashMap();
            HashMap hashMap3 = new HashMap();
            hashMap2.put(BuildConfig.VERSION_NAME, new e(BuildConfig.VERSION_NAME));
            C0119c cVar = null;
            newPullParser.setInput(new ByteArrayInputStream(bArr, 0, i7), null);
            ArrayDeque arrayDeque = new ArrayDeque();
            b bVar2 = f7209w;
            a aVar = f7210x;
            h hVar = null;
            int i8 = 0;
            for (int eventType = newPullParser.getEventType(); eventType != 1; eventType = newPullParser.getEventType()) {
                d dVar = (d) arrayDeque.peek();
                if (i8 == 0) {
                    String name = newPullParser.getName();
                    if (eventType == 2) {
                        if ("tt".equals(name)) {
                            bVar2 = G(newPullParser);
                            aVar = E(newPullParser, f7210x);
                            cVar = P(newPullParser);
                        }
                        if (!C(name)) {
                            p.f("TtmlDecoder", "Ignoring unsupported tag: " + newPullParser.getName());
                            i8++;
                            bVar2 = bVar2;
                        } else {
                            if ("head".equals(name)) {
                                bVar = bVar2;
                                H(newPullParser, hashMap, aVar, cVar, hashMap2, hashMap3);
                            } else {
                                bVar = bVar2;
                                try {
                                    d J = J(newPullParser, dVar, hashMap2, bVar);
                                    arrayDeque.push(J);
                                    if (dVar != null) {
                                        dVar.a(J);
                                    }
                                } catch (SubtitleDecoderException e7) {
                                    p.j("TtmlDecoder", "Suppressing parser error", e7);
                                    i8++;
                                }
                            }
                            bVar2 = bVar;
                        }
                        cVar = cVar;
                        aVar = aVar;
                    } else if (eventType == 4) {
                        ((d) k3.a.e(dVar)).a(d.d(newPullParser.getText()));
                    } else if (eventType == 3) {
                        if (newPullParser.getName().equals("tt")) {
                            hVar = new h((d) k3.a.e((d) arrayDeque.peek()), hashMap, hashMap2, hashMap3);
                        }
                        arrayDeque.pop();
                    }
                } else if (eventType == 2) {
                    i8++;
                } else if (eventType == 3) {
                    i8--;
                }
                newPullParser.next();
            }
            if (hVar != null) {
                return hVar;
            }
            throw new SubtitleDecoderException("No TTML subtitles found");
        } catch (XmlPullParserException e8) {
            throw new SubtitleDecoderException("Unable to decode source", e8);
        } catch (IOException e9) {
            throw new IllegalStateException("Unexpected error when reading input.", e9);
        }
    }
}