package p138.p176.p177.p190.p226.p234;

import android.text.TextUtils;
import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.text.SubtitleDecoderException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import p138.p176.p177.p190.p226.AbstractC3947;
import p138.p176.p177.p190.p226.InterfaceC3949;
import p138.p176.p177.p190.p226.p234.C4005;
import p138.p176.p177.p190.p239.C4122;
import p138.p176.p177.p190.p239.C4140;
import p138.p176.p177.p190.p239.C4150;

/* JADX INFO: renamed from: ދ.ހ.֏.ؠ.ໟ.ސ.ބ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C4011 extends AbstractC3947 {

    /* JADX INFO: renamed from: ތ, reason: contains not printable characters */
    public final C4008 f12702;

    /* JADX INFO: renamed from: ލ, reason: contains not printable characters */
    public final C4140 f12703;

    /* JADX INFO: renamed from: ގ, reason: contains not printable characters */
    public final C4005.C4007 f12704;

    /* JADX INFO: renamed from: ޏ, reason: contains not printable characters */
    public final C4001 f12705;

    /* JADX INFO: renamed from: ސ, reason: contains not printable characters */
    public final List<C4004> f12706;

    public C4011() {
        super("WebvttDecoder");
        this.f12702 = new C4008();
        this.f12703 = new C4140();
        this.f12704 = new C4005.C4007();
        this.f12705 = new C4001();
        this.f12706 = new ArrayList();
    }

    /* JADX WARN: Removed duplicated region for block: B:124:0x0231  */
    /* JADX WARN: Removed duplicated region for block: B:125:0x023b  */
    /* JADX WARN: Removed duplicated region for block: B:146:0x0297  */
    /* JADX WARN: Removed duplicated region for block: B:162:0x02d8  */
    /* JADX WARN: Removed duplicated region for block: B:173:0x030d  */
    /* JADX WARN: Removed duplicated region for block: B:60:0x0116  */
    @Override // p138.p176.p177.p190.p226.AbstractC3947
    /* JADX INFO: renamed from: ֏ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public InterfaceC3949 mo6372(byte[] bArr, int i, boolean z) throws SubtitleDecoderException {
        boolean zM6462;
        String strSubstring;
        C4001 c4001;
        String string;
        C4140 c4140 = this.f12703;
        c4140.f13227 = bArr;
        c4140.f13229 = i;
        int i2 = 0;
        c4140.f13228 = 0;
        this.f12704.m6457();
        this.f12706.clear();
        try {
            C4012.m6467(this.f12703);
            while (!TextUtils.isEmpty(this.f12703.m6690())) {
            }
            ArrayList arrayList = new ArrayList();
            while (true) {
                C4140 c41402 = this.f12703;
                int i3 = -1;
                int i4 = 1;
                byte b = -1;
                int i5 = 0;
                while (b == -1) {
                    i5 = c41402.f13228;
                    String strM6690 = c41402.m6690();
                    b = strM6690 == null ? (byte) 0 : "STYLE".equals(strM6690) ? (byte) 2 : strM6690.startsWith("NOTE") ? (byte) 1 : (byte) 3;
                }
                c41402.m6693(i5);
                if (b == 0) {
                    return new C4013(arrayList);
                }
                if (b == 1) {
                    while (!TextUtils.isEmpty(this.f12703.m6690())) {
                    }
                } else {
                    if (b == 2) {
                        if (!arrayList.isEmpty()) {
                            throw new SubtitleDecoderException("A style block was found after the first cue.");
                        }
                        this.f12703.m6690();
                        List<C4004> list = this.f12706;
                        C4001 c40012 = this.f12705;
                        C4140 c41403 = this.f12703;
                        c40012.f12660.setLength(i2);
                        int i6 = c41403.f13228;
                        while (!TextUtils.isEmpty(c41403.m6690())) {
                        }
                        c40012.f12659.m6684(c41403.f13227, c41403.f13228);
                        c40012.f12659.m6693(i6);
                        ArrayList arrayList2 = new ArrayList();
                        while (true) {
                            C4140 c41404 = c40012.f12659;
                            StringBuilder sb = c40012.f12660;
                            C4001.m6452(c41404);
                            if (c41404.m6679() >= 5 && "::cue".equals(c41404.m6687(5))) {
                                int i7 = c41404.f13228;
                                String strM6453 = C4001.m6453(c41404, sb);
                                if (strM6453 != null) {
                                    if ("{".equals(strM6453)) {
                                        c41404.m6693(i7);
                                        strSubstring = "";
                                    } else {
                                        if ("(".equals(strM6453)) {
                                            int i8 = c41404.f13228;
                                            int i9 = c41404.f13229;
                                            boolean z2 = false;
                                            while (i8 < i9 && !z2) {
                                                int i10 = i8 + 1;
                                                z2 = ((char) c41404.f13227[i8]) == ')';
                                                i8 = i10;
                                            }
                                            strSubstring = c41404.m6687((i8 - 1) - c41404.f13228).trim();
                                        } else {
                                            strSubstring = null;
                                        }
                                        if (!")".equals(C4001.m6453(c41404, sb))) {
                                            strSubstring = null;
                                        }
                                    }
                                    if (strSubstring == null || !"{".equals(C4001.m6453(c40012.f12659, c40012.f12660))) {
                                        break;
                                    }
                                    C4004 c4004 = new C4004();
                                    if (!"".equals(strSubstring)) {
                                        int iIndexOf = strSubstring.indexOf(91);
                                        if (iIndexOf != i3) {
                                            Matcher matcher = C4001.f12658.matcher(strSubstring.substring(iIndexOf));
                                            if (matcher.matches()) {
                                                c4004.f12667 = matcher.group(i4);
                                            }
                                            strSubstring = strSubstring.substring(i2, iIndexOf);
                                        }
                                        String[] strArrM6781 = C4150.m6781(strSubstring, "\\.");
                                        String str = strArrM6781[i2];
                                        int iIndexOf2 = str.indexOf(35);
                                        if (iIndexOf2 != i3) {
                                            c4004.f12665 = str.substring(i2, iIndexOf2);
                                            c4004.f12664 = str.substring(iIndexOf2 + 1);
                                        } else {
                                            c4004.f12665 = str;
                                        }
                                        if (strArrM6781.length > i4) {
                                            c4004.f12666 = Arrays.asList((String[]) C4150.m6778(strArrM6781, i4, strArrM6781.length));
                                        }
                                    }
                                    boolean z3 = false;
                                    String str2 = null;
                                    while (!z3) {
                                        C4140 c41405 = c40012.f12659;
                                        int i11 = c41405.f13228;
                                        String strM64532 = C4001.m6453(c41405, c40012.f12660);
                                        boolean z4 = strM64532 == null || "}".equals(strM64532);
                                        if (!z4) {
                                            c40012.f12659.m6693(i11);
                                            C4140 c41406 = c40012.f12659;
                                            StringBuilder sb2 = c40012.f12660;
                                            C4001.m6452(c41406);
                                            String strM6451 = C4001.m6451(c41406, sb2);
                                            if (!"".equals(strM6451) && ":".equals(C4001.m6453(c41406, sb2))) {
                                                C4001.m6452(c41406);
                                                StringBuilder sb3 = new StringBuilder();
                                                boolean z5 = false;
                                                while (true) {
                                                    if (z5) {
                                                        c4001 = c40012;
                                                        string = sb3.toString();
                                                        break;
                                                    }
                                                    c4001 = c40012;
                                                    int i12 = c41406.f13228;
                                                    boolean z6 = z5;
                                                    String strM64533 = C4001.m6453(c41406, sb2);
                                                    if (strM64533 == null) {
                                                        string = null;
                                                        break;
                                                    }
                                                    if ("}".equals(strM64533) || ";".equals(strM64533)) {
                                                        c41406.m6693(i12);
                                                        c40012 = c4001;
                                                        z5 = true;
                                                    } else {
                                                        sb3.append(strM64533);
                                                        c40012 = c4001;
                                                        z5 = z6;
                                                    }
                                                }
                                                if (string != null && !"".equals(string)) {
                                                    int i13 = c41406.f13228;
                                                    String strM64534 = C4001.m6453(c41406, sb2);
                                                    if (";".equals(strM64534)) {
                                                        if (!"color".equals(strM6451)) {
                                                        }
                                                    } else if ("}".equals(strM64534)) {
                                                        c41406.m6693(i13);
                                                        if (!"color".equals(strM6451)) {
                                                            c4004.f12669 = C4122.m6625(string, true);
                                                            c4004.f12670 = true;
                                                        } else if ("background-color".equals(strM6451)) {
                                                            c4004.f12671 = C4122.m6625(string, true);
                                                            c4004.f12672 = true;
                                                        } else if ("text-decoration".equals(strM6451)) {
                                                            if ("underline".equals(string)) {
                                                                c4004.f12674 = 1;
                                                            }
                                                        } else if ("font-family".equals(strM6451)) {
                                                            c4004.f12668 = C4150.m6809(string);
                                                        } else if ("font-weight".equals(strM6451)) {
                                                            if ("bold".equals(string)) {
                                                                c4004.f12675 = 1;
                                                            }
                                                        } else if ("font-style".equals(strM6451) && "italic".equals(string)) {
                                                            c4004.f12676 = 1;
                                                        }
                                                    }
                                                }
                                            } else {
                                                c4001 = c40012;
                                            }
                                        }
                                        str2 = strM64532;
                                        z3 = z4;
                                        c40012 = c4001;
                                    }
                                    C4001 c40013 = c40012;
                                    if ("}".equals(str2)) {
                                        arrayList2.add(c4004);
                                    }
                                    c40012 = c40013;
                                    i2 = 0;
                                    i3 = -1;
                                    i4 = 1;
                                }
                            }
                        }
                        list.addAll(arrayList2);
                    } else if (b == 3) {
                        C4008 c4008 = this.f12702;
                        C4140 c41407 = this.f12703;
                        C4005.C4007 c4007 = this.f12704;
                        List<C4004> list2 = this.f12706;
                        if (c4008 == null) {
                            throw null;
                        }
                        String strM66902 = c41407.m6690();
                        if (strM66902 == null) {
                            zM6462 = false;
                            if (zM6462) {
                                arrayList.add(this.f12704.m6456());
                                this.f12704.m6457();
                            }
                        } else {
                            Matcher matcher2 = C4008.f12692.matcher(strM66902);
                            if (matcher2.matches()) {
                                zM6462 = C4008.m6462(null, matcher2, c41407, c4007, c4008.f12694, list2);
                            } else {
                                String strM66903 = c41407.m6690();
                                if (strM66903 != null) {
                                    Matcher matcher3 = C4008.f12692.matcher(strM66903);
                                    if (matcher3.matches()) {
                                        zM6462 = C4008.m6462(strM66902.trim(), matcher3, c41407, c4007, c4008.f12694, list2);
                                    }
                                }
                            }
                            if (zM6462) {
                            }
                        }
                    }
                    i2 = 0;
                }
            }
        } catch (ParserException e) {
            throw new SubtitleDecoderException(e);
        }
    }
}
