package androidx.media3.common.text;

import android.os.Bundle;
import androidx.media3.common.util.BundleCollectionUtil;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util;
import defpackage.av;
import defpackage.bj4;
import defpackage.py6;
import java.util.ArrayList;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public final class CueGroup {
    private static final py6<Cue> CUES_PRIORITY_COMPARATOR = py6.c().f(new av(11));

    @UnstableApi
    public static final CueGroup EMPTY_TIME_ZERO = new CueGroup(bj4.p(), 0);
    private static final String FIELD_CUES = Util.intToStringMaxRadix(0);
    private static final String FIELD_PRESENTATION_TIME_US = Util.intToStringMaxRadix(1);
    public final bj4<Cue> cues;

    @UnstableApi
    public final long presentationTimeUs;

    @UnstableApi
    public CueGroup(List<Cue> list, long j) {
        this.cues = bj4.u(CUES_PRIORITY_COMPARATOR, list);
        this.presentationTimeUs = j;
    }

    private static bj4<Cue> filterOutBitmapCues(List<Cue> list) {
        bj4.a aVarI = bj4.i();
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).bitmap == null) {
                aVarI.h(list.get(i));
            }
        }
        return aVarI.j();
    }

    @UnstableApi
    public static CueGroup fromBundle(Bundle bundle) {
        ArrayList parcelableArrayList = bundle.getParcelableArrayList(FIELD_CUES);
        return new CueGroup(parcelableArrayList == null ? bj4.p() : BundleCollectionUtil.fromBundleList(new av(12), parcelableArrayList), bundle.getLong(FIELD_PRESENTATION_TIME_US));
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static /* synthetic */ Integer lambda$static$0(Cue cue) {
        return Integer.valueOf(cue.zIndex);
    }

    @UnstableApi
    public Bundle toBundle() {
        Bundle bundle = new Bundle();
        bundle.putParcelableArrayList(FIELD_CUES, BundleCollectionUtil.toBundleArrayList(filterOutBitmapCues(this.cues), new av(13)));
        bundle.putLong(FIELD_PRESENTATION_TIME_US, this.presentationTimeUs);
        return bundle;
    }
}
