package defpackage;

import android.net.Uri;
import android.os.SystemClock;
import android.util.Pair;
import androidx.media3.exoplayer.source.BehindLiveWindowException;
import j$.util.DesugarCollections;
import j$.util.Objects;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

/* renamed from: ˊᵬ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C1380 {

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final C4848[] f5664;

    /* renamed from: ˌʾˀ, reason: contains not printable characters */
    public Uri f5665;

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public boolean f5666;

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final C1105 f5667;

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final C3446[] f5668;

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final InterfaceC2569 f5669;

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public final List f5670;

    /* renamed from: ᵡʠ, reason: contains not printable characters */
    public boolean f5672;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final C1733 f5673;

    /* renamed from: ᵪʩ, reason: contains not printable characters */
    public BehindLiveWindowException f5674;

    /* renamed from: ᵳٴᵶ, reason: contains not printable characters */
    public Uri f5676;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final InterfaceC2569 f5677;

    /* renamed from: ᵸʓᵠ, reason: contains not printable characters */
    public InterfaceC5264 f5679;

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public final C1545 f5680;

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public final C4010 f5681;

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final C4457 f5682;

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public final ˊᵘʛ f5678 = new ˊᵘʛ(28);

    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public byte[] f5675 = AbstractC3558.f13330;

    /* renamed from: ᵞʡ, reason: contains not printable characters */
    public long f5671 = -9223372036854775807L;

    public C1380(C1733 c1733, C1105 c1105, C4848[] c4848Arr, C3446[] c3446Arr, C2931 c2931, C3873 c3873, C4457 c4457, List list, C1545 c1545) {
        this.f5673 = c1733;
        this.f5667 = c1105;
        this.f5664 = c4848Arr;
        this.f5668 = c3446Arr;
        this.f5682 = c4457;
        this.f5670 = list;
        this.f5680 = c1545;
        InterfaceC2569 interfaceC2569Mo4930 = ((InterfaceC1731) c2931.f11366).mo4930();
        this.f5677 = interfaceC2569Mo4930;
        if (c3873 != null) {
            interfaceC2569Mo4930.mo1415(c3873);
        }
        this.f5669 = ((InterfaceC1731) c2931.f11366).mo4930();
        this.f5681 = new C4010("", c3446Arr);
        ArrayList arrayList = new ArrayList();
        for (int i = 0; i < c4848Arr.length; i++) {
            if ((c3446Arr[i].f12907 & 16384) == 0) {
                arrayList.add(Integer.valueOf(i));
            }
        }
        C4010 c4010 = this.f5681;
        int[] iArr = ˁˈᵸ.ᵙᵢᵨᵳ(arrayList);
        C4292 c4292 = new C4292(c4010, iArr);
        c4292.f16103 = c4292.mo5379(c4010.f15079[iArr[0]]);
        this.f5679 = c4292;
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public static C5241 m4236(C1734 c1734, long j, int i) {
        long j2 = c1734.f6927;
        AbstractC2692 abstractC2692 = c1734.f6917;
        int i2 = (int) (j - j2);
        AbstractC2692 abstractC26922 = c1734.f6926;
        if (i2 == abstractC26922.size()) {
            if (i == -1) {
                i = 0;
            }
            if (i < abstractC2692.size()) {
                return new C5241((AbstractC0046) abstractC2692.get(i), j, i);
            }
            return null;
        }
        C1671 c1671 = (C1671) abstractC26922.get(i2);
        if (i == -1) {
            return new C5241(c1671, j, -1);
        }
        if (i < c1671.f6665.size()) {
            return new C5241((AbstractC0046) c1671.f6665.get(i), j, i);
        }
        int i3 = i2 + 1;
        if (i3 < abstractC26922.size()) {
            return new C5241((AbstractC0046) abstractC26922.get(i3), j + 1, -1);
        }
        if (abstractC2692.isEmpty()) {
            return null;
        }
        return new C5241((AbstractC0046) abstractC2692.get(0), j + 1, 0);
    }

    /* JADX WARN: Removed duplicated region for block: B:48:0x00ad  */
    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final android.util.Pair m4237(defpackage.C3508 r17, boolean r18, defpackage.C1734 r19, long r20, long r22) {
        /*
            Method dump skipped, instructions count: 232
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C1380.m4237(ᵥˑ, boolean, ˎᴵᵫ, long, long):android.util.Pair");
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final C2752 m4238(Uri uri, int i, boolean z) {
        if (uri == null) {
            return null;
        }
        ˊᵘʛ r3 = this.f5678;
        byte[] bArr = (byte[]) ((C3058) r3.ᵢˇᵭ).remove(uri);
        if (bArr != null) {
            return null;
        }
        C4179 c4179 = new C4179(uri, 1, null, Collections.EMPTY_MAP, 0L, -1L, null, 1);
        C3446 c3446 = this.f5668[i];
        int iMo2645 = this.f5679.mo2645();
        Object objMo2648 = this.f5679.mo2648();
        byte[] bArr2 = this.f5675;
        C2752 c2752 = new C2752(this.f5669, c4179, 3, c3446, iMo2645, objMo2648, -9223372036854775807L, -9223372036854775807L);
        if (bArr2 == null) {
            bArr2 = AbstractC3558.f13330;
        }
        c2752.f10633 = bArr2;
        return c2752;
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final int m4239(C3508 c3508) {
        int i = c3508.f13150;
        if (i == -1) {
            return 1;
        }
        C1734 c1734M3518 = this.f5667.m3518(c3508.f13152, false);
        c1734M3518.getClass();
        AbstractC2692 abstractC2692 = c1734M3518.f6926;
        int i2 = (int) (c3508.f12017 - c1734M3518.f6927);
        if (i2 < 0) {
            return 1;
        }
        AbstractC2692 abstractC26922 = i2 < abstractC2692.size() ? ((C1671) abstractC2692.get(i2)).f6665 : c1734M3518.f6917;
        if (i >= abstractC26922.size()) {
            return 2;
        }
        C2875 c2875 = (C2875) abstractC26922.get(i);
        if (c2875.f11142) {
            return 0;
        }
        return Objects.equals(Uri.parse(ˆᴵ.ᵢˇᵭ(c1734M3518.f3741, c2875.f1202)), c3508.f15963.f15620) ? 1 : 2;
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final C3103 m4240(Uri uri) {
        long jElapsedRealtime = SystemClock.elapsedRealtime();
        C1105 c1105 = this.f5667;
        C5426 c5426 = (C5426) c1105.f4768.get(uri);
        C4848 c4848 = c5426 != null ? c5426.f20339 : null;
        c4848.getClass();
        HashMap map = c4848.f18004;
        int size = map.size();
        AbstractC5447 it = AbstractC1559.m4529(map.values()).iterator();
        int i = 0;
        while (it.hasNext()) {
            Uri uri2 = (Uri) it.next();
            C5426 c54262 = (C5426) c1105.f4768.get(uri2);
            if (c54262 != null) {
                C4333 c4333 = (C4333) AbstractC3915.m8585(c54262.f20340, uri2, uri2);
                c4333.getClass();
                if (jElapsedRealtime <= c4333.f16215) {
                    i++;
                }
            }
        }
        return new C3103(size, i, this.f5679.length(), m4242(jElapsedRealtime));
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final InterfaceC2379[] m4241(C3508 c3508, long j) {
        List listUnmodifiableList;
        C1380 c1380 = this;
        C3508 c35082 = c3508;
        int iM8851 = c35082 == null ? -1 : c1380.f5681.m8851(c35082.f15966);
        int length = c1380.f5679.length();
        InterfaceC2379[] interfaceC2379Arr = new InterfaceC2379[length];
        boolean z = false;
        int i = 0;
        while (i < length) {
            int iMo5376 = c1380.f5679.mo5376(i);
            Uri uriM10180 = c1380.f5664[iMo5376].m10180();
            C1105 c1105 = c1380.f5667;
            if (c1105.m3513(uriM10180)) {
                C1734 c1734M3518 = c1105.m3518(uriM10180, z);
                c1734M3518.getClass();
                long j2 = c1734M3518.f6928 - c1105.f4759;
                Pair pairM4237 = c1380.m4237(c35082, iMo5376 != iM8851 ? true : z, c1734M3518, j2, j);
                long jLongValue = ((Long) pairM4237.first).longValue();
                int iIntValue = ((Integer) pairM4237.second).intValue();
                long j3 = c1734M3518.f6927;
                AbstractC2692 abstractC2692 = c1734M3518.f6917;
                AbstractC2692 abstractC26922 = c1734M3518.f6926;
                int i2 = (int) (jLongValue - j3);
                if (i2 < 0 || abstractC26922.size() < i2) {
                    C4421 c4421 = AbstractC2692.f10429;
                    listUnmodifiableList = C4471.f16684;
                } else {
                    ArrayList arrayList = new ArrayList();
                    if (i2 < abstractC26922.size()) {
                        if (iIntValue != -1) {
                            C1671 c1671 = (C1671) abstractC26922.get(i2);
                            if (iIntValue == 0) {
                                arrayList.add(c1671);
                            } else if (iIntValue < c1671.f6665.size()) {
                                AbstractC2692 abstractC26923 = c1671.f6665;
                                arrayList.addAll(abstractC26923.subList(iIntValue, abstractC26923.size()));
                            }
                            i2++;
                        }
                        arrayList.addAll(abstractC26922.subList(i2, abstractC26922.size()));
                        iIntValue = 0;
                    }
                    if (c1734M3518.f6922 != -9223372036854775807L) {
                        if (iIntValue == -1) {
                            iIntValue = 0;
                        }
                        if (iIntValue < abstractC2692.size()) {
                            arrayList.addAll(abstractC2692.subList(iIntValue, abstractC2692.size()));
                        }
                    }
                    listUnmodifiableList = DesugarCollections.unmodifiableList(arrayList);
                }
                interfaceC2379Arr[i] = new C4561(j2, listUnmodifiableList);
            } else {
                interfaceC2379Arr[i] = InterfaceC2379.f9307;
            }
            i++;
            c1380 = this;
            c35082 = c3508;
            z = false;
        }
        return interfaceC2379Arr;
    }

    /* JADX WARN: Removed duplicated region for block: B:8:0x0020  */
    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final int m4242(long r7) {
        /*
            r6 = this;
            ᵼˋᵸ r0 = r6.f5679
            int r1 = r0.length()
            r2 = 0
            r3 = r2
        L8:
            if (r2 >= r1) goto L25
            int r4 = r0.mo5376(r2)
            boolean r5 = r0.mo5363(r7, r2)
            if (r5 != 0) goto L20
            ᵶﹶˁ[] r5 = r6.f5664
            r4 = r5[r4]
            ˈᵵᵚ r5 = r6.f5667
            boolean r4 = r5.m3511(r4, r7)
            if (r4 == 0) goto L22
        L20:
            int r3 = r3 + 1
        L22:
            int r2 = r2 + 1
            goto L8
        L25:
            return r3
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C1380.m4242(long):int");
    }
}
