package defpackage;

import android.net.Uri;
import androidx.media3.common.ParserException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/* renamed from: ᵶﹶˁ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C4848 {

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

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

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

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public String f18005;

    public C4848(C5543 c5543, String str, Uri uri, int i) {
        this.f18003 = c5543;
        HashMap map = new HashMap();
        this.f18004 = map;
        map.put(str, uri);
        this.f18005 = str;
        ArrayList arrayList = new ArrayList();
        this.f18002 = arrayList;
        if (i != -1) {
            arrayList.add(Integer.valueOf(i));
        }
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public static AbstractC2692 m10177(List list) {
        ArrayList arrayList = new ArrayList();
        HashMap map = new HashMap();
        HashMap map2 = new HashMap();
        for (int i = 0; i < list.size(); i++) {
            C4571 c4571 = (C4571) list.get(i);
            Uri uri = c4571.f16994;
            try {
                m10179(c4571.f16994, null, i, arrayList, new C5543(c4571.f16995, c4571.f16996, c4571.f16993), map, map2);
            } catch (ParserException unused) {
            }
        }
        return AbstractC2692.m6700(arrayList);
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public static AbstractC2692 m10178(List list) throws ParserException {
        ArrayList arrayList = new ArrayList();
        HashMap map = new HashMap();
        HashMap map2 = new HashMap();
        for (int i = 0; i < list.size(); i++) {
            C4286 c4286 = (C4286) list.get(i);
            m10179(c4286.f16078, c4286.f16075, i, arrayList, new C5543(c4286.f16079, c4286.f16080, null), map, map2);
        }
        return AbstractC2692.m6700(arrayList);
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public static void m10179(Uri uri, String str, int i, ArrayList arrayList, C5543 c5543, HashMap map, HashMap map2) throws ParserException {
        int i2;
        String str2;
        Integer num = (Integer) map.get(c5543);
        int i3 = 1;
        if (num == null) {
            map2.put(c5543, 0);
            if (str == null) {
                map2.put(c5543, 1);
                str = ".";
            }
            C4848 c4848 = new C4848(c5543, str, uri, i);
            map.put(c5543, Integer.valueOf(arrayList.size()));
            arrayList.add(c4848);
            return;
        }
        if (str == null) {
            Integer num2 = (Integer) map2.get(c5543);
            num2.getClass();
            int iIntValue = num2.intValue() + 1;
            if (iIntValue <= 1) {
                ᵛᵾˏ.ᵶᵷᵕ(iIntValue, "invalid count: %s", iIntValue >= 0);
                str2 = iIntValue == 0 ? "" : ".";
            } else {
                long j = iIntValue;
                int i4 = (int) j;
                if (i4 != j) {
                    throw new ArrayIndexOutOfBoundsException(AbstractC4737.m10015(j, "Required array size too large: "));
                }
                char[] cArr = new char[i4];
                ".".getChars(0, 1, cArr, 0);
                while (true) {
                    i2 = i4 - i3;
                    if (i3 >= i2) {
                        break;
                    }
                    System.arraycopy(cArr, 0, cArr, i3, i3);
                    i3 <<= 1;
                }
                System.arraycopy(cArr, 0, cArr, i3, i2);
                str2 = new String(cArr);
            }
            map2.put(c5543, Integer.valueOf(iIntValue));
            str = str2;
        }
        C4848 c48482 = (C4848) arrayList.get(num.intValue());
        Uri uri2 = (Uri) c48482.f18004.get(str);
        if (uri2 != null && !uri.equals(uri2)) {
            throw ParserException.m357("Different playlist URLs are found for pathway ID " + str + " within the HlsRedundantGroup", null);
        }
        c48482.f18004.put(str, uri);
        if (i != -1) {
            c48482.f18002.add(Integer.valueOf(i));
        }
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final Uri m10180() {
        Uri uri = (Uri) this.f18004.get(this.f18005);
        uri.getClass();
        return uri;
    }
}
