package defpackage;

import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.IdentityHashMap;

/* JADX INFO: renamed from: ᵡˊᵣ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C3203 implements InterfaceC0472, InterfaceC2682 {

    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public InterfaceC2682 f12173;

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final InterfaceC0472[] f12174;

    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    public C5502 f12175;

    /* JADX INFO: renamed from: ˑˊᵲ, reason: contains not printable characters */
    public C3189 f12176;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public final IdentityHashMap f12177;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public final boolean[] f12178;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public final C3814 f12179;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public final ArrayList f12180 = new ArrayList();

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public final HashMap f12181 = new HashMap();

    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    public InterfaceC0472[] f12182;

    public C3203(C3814 c3814, long[] jArr, InterfaceC0472... interfaceC0472Arr) {
        this.f12179 = c3814;
        this.f12174 = interfaceC0472Arr;
        c3814.getClass();
        C2822 c2822 = AbstractC4509.f17159;
        C2598 c2598 = C2598.f10048;
        this.f12176 = new C3189(c2598, c2598);
        this.f12177 = new IdentityHashMap();
        this.f12182 = new InterfaceC0472[0];
        this.f12178 = new boolean[interfaceC0472Arr.length];
        for (int i = 0; i < interfaceC0472Arr.length; i++) {
            long j = jArr[i];
            if (j != 0) {
                this.f12178[i] = true;
                this.f12174[i] = new C1282(interfaceC0472Arr[i], j);
            }
        }
    }

    @Override // defpackage.InterfaceC2682
    /* JADX INFO: renamed from: ʽˈˋ */
    public final void mo3793(InterfaceC0472 interfaceC0472) {
        ArrayList arrayList = this.f12180;
        arrayList.remove(interfaceC0472);
        if (arrayList.isEmpty()) {
            InterfaceC0472[] interfaceC0472Arr = this.f12174;
            int i = 0;
            for (InterfaceC0472 interfaceC04722 : interfaceC0472Arr) {
                i += interfaceC04722.mo1936().f20789;
            }
            C1882[] c1882Arr = new C1882[i];
            int i2 = 0;
            for (int i3 = 0; i3 < interfaceC0472Arr.length; i3++) {
                C5502 c5502Mo1936 = interfaceC0472Arr[i3].mo1936();
                int i4 = c5502Mo1936.f20789;
                int i5 = 0;
                while (i5 < i4) {
                    C1882 c1882M11142 = c5502Mo1936.m11142(i5);
                    int i6 = c1882M11142.f7462;
                    C5286[] c5286Arr = new C5286[i6];
                    int i7 = 0;
                    while (i7 < i6) {
                        C5286 c5286 = c1882M11142.f7463[i7];
                        C4753 c4753M10878 = c5286.m10878();
                        String str = c5286.f19982;
                        InterfaceC0472[] interfaceC0472Arr2 = interfaceC0472Arr;
                        StringBuilder sb = new StringBuilder();
                        sb.append(i3);
                        sb.append(":");
                        String str2 = c5286.f19992;
                        if (str2 == null) {
                            str2 = "";
                        }
                        sb.append(str2);
                        c4753M10878.f18121 = sb.toString();
                        if (str != null) {
                            c4753M10878.f18117 = i3 + ":" + str;
                        }
                        c5286Arr[i7] = new C5286(c4753M10878);
                        i7++;
                        interfaceC0472Arr = interfaceC0472Arr2;
                    }
                    InterfaceC0472[] interfaceC0472Arr3 = interfaceC0472Arr;
                    C1882 c1882 = new C1882(i3 + ":" + c1882M11142.f7459, c5286Arr);
                    this.f12181.put(c1882, c1882M11142);
                    c1882Arr[i2] = c1882;
                    i5++;
                    i2++;
                    interfaceC0472Arr = interfaceC0472Arr3;
                }
            }
            this.f12175 = new C5502(c1882Arr);
            InterfaceC2682 interfaceC2682 = this.f12173;
            interfaceC2682.getClass();
            interfaceC2682.mo3793(this);
        }
    }

    @Override // defpackage.InterfaceC1137
    /* JADX INFO: renamed from: ˉᵲ */
    public final boolean mo3622(C2348 c2348) {
        ArrayList arrayList = this.f12180;
        if (arrayList.isEmpty()) {
            return this.f12176.mo3622(c2348);
        }
        int size = arrayList.size();
        for (int i = 0; i < size; i++) {
            ((InterfaceC0472) arrayList.get(i)).mo3622(c2348);
        }
        return false;
    }

    @Override // defpackage.InterfaceC4108
    /* JADX INFO: renamed from: ˊᵨᵧ */
    public final void mo3794(InterfaceC1137 interfaceC1137) {
        InterfaceC2682 interfaceC2682 = this.f12173;
        interfaceC2682.getClass();
        interfaceC2682.mo3794(this);
    }

    /* JADX WARN: Code restructure failed: missing block: B:19:0x003f, code lost:
    
        r7 = r10;
     */
    @Override // defpackage.InterfaceC0472
    /* JADX INFO: renamed from: ˋˈ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final long mo1934() {
        long j;
        InterfaceC0472 interfaceC0472;
        InterfaceC0472[] interfaceC0472Arr = this.f12182;
        int length = interfaceC0472Arr.length;
        long j2 = -9223372036854775807L;
        long j3 = -9223372036854775807L;
        int i = 0;
        while (i < length) {
            InterfaceC0472 interfaceC04722 = interfaceC0472Arr[i];
            long jMo1934 = interfaceC04722.mo1934();
            if (jMo1934 == j2) {
                j = j2;
                if (j3 != j && interfaceC04722.mo1941(j3) != j3) {
                    ᵕᵩʽᵲ.ᵪᵹᵥᵻ("Unexpected child seekToUs result.");
                    return 0L;
                }
            } else if (j3 == j2) {
                InterfaceC0472[] interfaceC0472Arr2 = this.f12182;
                int length2 = interfaceC0472Arr2.length;
                int i2 = 0;
                while (true) {
                    j = j2;
                    if (i2 >= length2 || (interfaceC0472 = interfaceC0472Arr2[i2]) == interfaceC04722) {
                        break;
                    }
                    if (interfaceC0472.mo1941(jMo1934) != jMo1934) {
                        ᵕᵩʽᵲ.ᵪᵹᵥᵻ("Unexpected child seekToUs result.");
                        return 0L;
                    }
                    i2++;
                    j2 = j;
                }
            } else {
                j = j2;
                if (jMo1934 != j3) {
                    ᵕᵩʽᵲ.ᵪᵹᵥᵻ("Conflicting discontinuities.");
                    return 0L;
                }
            }
            i++;
            j2 = j;
        }
        return j3;
    }

    @Override // defpackage.InterfaceC1137
    /* JADX INFO: renamed from: ˌᴵ */
    public final void mo3623(long j) {
        this.f12176.mo3623(j);
    }

    @Override // defpackage.InterfaceC1137
    /* JADX INFO: renamed from: ˏːˆ */
    public final long mo3624() {
        return this.f12176.mo3624();
    }

    @Override // defpackage.InterfaceC0472
    /* JADX INFO: renamed from: ːˏᵟᵯ */
    public final long mo1935(long j, C3318 c3318) {
        InterfaceC0472[] interfaceC0472Arr = this.f12182;
        return (interfaceC0472Arr.length > 0 ? interfaceC0472Arr[0] : this.f12174[0]).mo1935(j, c3318);
    }

    @Override // defpackage.InterfaceC0472
    /* JADX INFO: renamed from: ᵟᵹᵙ */
    public final C5502 mo1936() {
        C5502 c5502 = this.f12175;
        c5502.getClass();
        return c5502;
    }

    @Override // defpackage.InterfaceC0472
    /* JADX INFO: renamed from: ᵨᵣ */
    public final long mo1937(InterfaceC2380[] interfaceC2380Arr, boolean[] zArr, InterfaceC4833[] interfaceC4833Arr, boolean[] zArr2, long j) {
        IdentityHashMap identityHashMap;
        int[] iArr;
        int[] iArr2 = new int[interfaceC2380Arr.length];
        int[] iArr3 = new int[interfaceC2380Arr.length];
        int i = 0;
        int i2 = 0;
        while (true) {
            int length = interfaceC2380Arr.length;
            identityHashMap = this.f12177;
            if (i2 >= length) {
                break;
            }
            InterfaceC4833 interfaceC4833 = interfaceC4833Arr[i2];
            Integer num = interfaceC4833 == null ? null : (Integer) identityHashMap.get(interfaceC4833);
            iArr2[i2] = num == null ? -1 : num.intValue();
            InterfaceC2380 interfaceC2380 = interfaceC2380Arr[i2];
            if (interfaceC2380 != null) {
                String str = interfaceC2380.mo3729().f7459;
                iArr3[i2] = Integer.parseInt(str.substring(0, str.indexOf(":")));
            } else {
                iArr3[i2] = -1;
            }
            i2++;
        }
        identityHashMap.clear();
        int length2 = interfaceC2380Arr.length;
        InterfaceC4833[] interfaceC4833Arr2 = new InterfaceC4833[length2];
        InterfaceC4833[] interfaceC4833Arr3 = new InterfaceC4833[interfaceC2380Arr.length];
        InterfaceC2380[] interfaceC2380Arr2 = new InterfaceC2380[interfaceC2380Arr.length];
        InterfaceC0472[] interfaceC0472Arr = this.f12174;
        ArrayList arrayList = new ArrayList(interfaceC0472Arr.length);
        long j2 = j;
        int i3 = 0;
        while (i3 < interfaceC0472Arr.length) {
            int i4 = i;
            while (i4 < interfaceC2380Arr.length) {
                interfaceC4833Arr3[i4] = iArr2[i4] == i3 ? interfaceC4833Arr[i4] : null;
                if (iArr3[i4] == i3) {
                    InterfaceC2380 interfaceC23802 = interfaceC2380Arr[i4];
                    interfaceC23802.getClass();
                    iArr = iArr2;
                    C1882 c1882 = (C1882) this.f12181.get(interfaceC23802.mo3729());
                    c1882.getClass();
                    interfaceC2380Arr2[i4] = new C1245(interfaceC23802, c1882);
                } else {
                    iArr = iArr2;
                    interfaceC2380Arr2[i4] = null;
                }
                i4++;
                iArr2 = iArr;
            }
            int[] iArr4 = iArr2;
            InterfaceC0472[] interfaceC0472Arr2 = interfaceC0472Arr;
            int i5 = i3;
            long jMo1937 = interfaceC0472Arr2[i3].mo1937(interfaceC2380Arr2, zArr, interfaceC4833Arr3, zArr2, j2);
            if (i5 == 0) {
                j2 = jMo1937;
            } else if (jMo1937 != j2) {
                ᵕᵩʽᵲ.ᵪᵹᵥᵻ("Children enabled at different positions.");
                return 0L;
            }
            boolean z = false;
            for (int i6 = 0; i6 < interfaceC2380Arr.length; i6++) {
                if (iArr3[i6] == i5) {
                    InterfaceC4833 interfaceC48332 = interfaceC4833Arr3[i6];
                    interfaceC48332.getClass();
                    interfaceC4833Arr2[i6] = interfaceC4833Arr3[i6];
                    identityHashMap.put(interfaceC48332, Integer.valueOf(i5));
                    z = true;
                } else if (iArr4[i6] == i5) {
                    ᵻᵪ.ˌᴵ(interfaceC4833Arr3[i6] == null);
                }
            }
            if (z) {
                arrayList.add(interfaceC0472Arr2[i5]);
            }
            i3 = i5 + 1;
            interfaceC0472Arr = interfaceC0472Arr2;
            iArr2 = iArr4;
            i = 0;
        }
        int i7 = i;
        System.arraycopy(interfaceC4833Arr2, i7, interfaceC4833Arr, i7, length2);
        this.f12182 = (InterfaceC0472[]) arrayList.toArray(new InterfaceC0472[i7]);
        AbstractList abstractList = ᵫﾞˌ.ᵨᵼⁱ(arrayList, new C3821(14));
        this.f12179.getClass();
        this.f12176 = new C3189(arrayList, abstractList);
        return j2;
    }

    @Override // defpackage.InterfaceC0472
    /* JADX INFO: renamed from: ᵪᵹᵥᵻ */
    public final void mo1938(InterfaceC2682 interfaceC2682, long j) {
        this.f12173 = interfaceC2682;
        ArrayList arrayList = this.f12180;
        InterfaceC0472[] interfaceC0472Arr = this.f12174;
        Collections.addAll(arrayList, interfaceC0472Arr);
        for (InterfaceC0472 interfaceC0472 : interfaceC0472Arr) {
            interfaceC0472.mo1938(this, j);
        }
    }

    @Override // defpackage.InterfaceC1137
    /* JADX INFO: renamed from: ᵮᵣᵗˈ */
    public final boolean mo3625() {
        return this.f12176.mo3625();
    }

    @Override // defpackage.InterfaceC0472
    /* JADX INFO: renamed from: ᵱᵽʡᵚ */
    public final void mo1939(long j) {
        for (InterfaceC0472 interfaceC0472 : this.f12182) {
            interfaceC0472.mo1939(j);
        }
    }

    @Override // defpackage.InterfaceC0472
    /* JADX INFO: renamed from: ᵵᵽ */
    public final void mo1940() {
        for (InterfaceC0472 interfaceC0472 : this.f12174) {
            interfaceC0472.mo1940();
        }
    }

    @Override // defpackage.InterfaceC0472
    /* JADX INFO: renamed from: ᵻʽᵯ */
    public final long mo1941(long j) {
        long jMo1941 = this.f12182[0].mo1941(j);
        int i = 1;
        while (true) {
            InterfaceC0472[] interfaceC0472Arr = this.f12182;
            if (i >= interfaceC0472Arr.length) {
                return jMo1941;
            }
            if (interfaceC0472Arr[i].mo1941(jMo1941) != jMo1941) {
                ᵕᵩʽᵲ.ᵪᵹᵥᵻ("Unexpected child seekToUs result.");
                return 0L;
            }
            i++;
        }
    }

    @Override // defpackage.InterfaceC1137
    /* JADX INFO: renamed from: ᵻˈᵦʼ */
    public final long mo3626() {
        return this.f12176.mo3626();
    }
}
