package p000.p001.p002.p008.p009;

import androidx.lifecycle.LiveData;
import ar.tvplayer.core.data.db.dao.ޙ;
import ar.tvplayer.core.data.db.dao.ޞ;
import ar.tvplayer.core.data.db.dao.ޠ;
import ar.tvplayer.core.data.db.dao.ޣ;
import ar.tvplayer.core.data.db.dao.ޥ;
import ar.tvplayer.core.data.db.dao.ࢠ;
import ar.tvplayer.core.data.db.entities.ނ;
import ar.tvplayer.core.data.db.entities.ކ;
import ar.tvplayer.core.data.db.entities.ވ;
import ar.tvplayer.core.data.db.entities.ގ;
import ar.tvplayer.core.data.db.entities.ޜ;
import ar.tvplayer.core.data.db.entities.ޡ;
import ar.tvplayer.core.data.db.entities.ޤ;
import ar.tvplayer.core.data.db.ހ;
import ar.tvplayer.core.data.prefs.ރ;
import ar.tvplayer.core.data.repositories.ʳ;
import ar.tvplayer.core.data.repositories.ޚ;
import ar.tvplayer.core.util.CommonUtilsKt;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CancellationException;
import p000.p001.p021.p023.C1267;
import p025.p026.AbstractC1376;
import p025.p026.C1340;
import p025.p026.C1356;
import p025.p026.InterfaceC1327;
import p025.p026.InterfaceC1363;
import p037.p041.p042.LayoutInflaterFactory2C1494;
import p037.p099.AbstractC2245;
import p037.p099.C2226;
import p037.p099.InterfaceC2230;
import p037.p109.C2409;
import p138.p139.p143.p144.C2803;
import p138.p176.p177.p242.p246.p251.C4303;
import p402.C6549;
import p402.InterfaceC6540;
import p402.p403.C6560;
import p402.p403.C6563;
import p402.p405.InterfaceC6575;
import p402.p405.p406.EnumC6586;
import p402.p405.p407.p408.AbstractC6597;
import p402.p405.p407.p408.InterfaceC6593;
import p402.p411.p412.InterfaceC6618;
import p402.p411.p413.C6635;

/* JADX INFO: renamed from: ނ.֏.֏.ހ.֏.ދ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
@InterfaceC6540
public final class C0804 extends AbstractC2245 {

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public LiveData<List<ނ>> f3340;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public LiveData<ކ> f3341;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public LiveData<List<ޡ>> f3343;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public LiveData<List<ޜ>> f3345;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public final LiveData<Integer> f3346;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public C1267 f3347;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public ގ f3348;

    /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
    public InterfaceC1363 f3349;

    /* JADX INFO: renamed from: ދ, reason: contains not printable characters */
    public InterfaceC1363 f3350;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final C2226<C0806> f3339 = new C2226<>();

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final C2226<Map<Long, List<ޡ>>> f3342 = new C2226<>();

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public final C2226<Map<Long, List<ޜ>>> f3344 = new C2226<>();

    /* JADX INFO: renamed from: ނ.֏.֏.ހ.֏.ދ$֏, reason: contains not printable characters */
    public static final class C0805<T> implements InterfaceC2230<Integer> {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public static final C0805 f3351 = new C0805();

        @Override // p037.p099.InterfaceC2230
        /* JADX INFO: renamed from: ֏ */
        public void mo1576(Integer num) {
        }
    }

    /* JADX INFO: renamed from: ނ.֏.֏.ހ.֏.ދ$ؠ, reason: contains not printable characters */
    public static final class C0806 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final List<ނ> f3352;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final C1267 f3353;

        public C0806(List<ނ> list, C1267 c1267) {
            if (list == null) {
                C6635.m9824("channels");
                throw null;
            }
            if (c1267 == null) {
                C6635.m9824("channelGroup");
                throw null;
            }
            this.f3352 = list;
            this.f3353 = c1267;
        }

        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof C0806)) {
                return false;
            }
            C0806 c0806 = (C0806) obj;
            return C6635.m9825(this.f3352, c0806.f3352) && C6635.m9825(this.f3353, c0806.f3353);
        }

        public int hashCode() {
            List<ނ> list = this.f3352;
            int iHashCode = (list != null ? list.hashCode() : 0) * 31;
            C1267 c1267 = this.f3353;
            return iHashCode + (c1267 != null ? c1267.hashCode() : 0);
        }

        public String toString() {
            StringBuilder sbM4889 = C2803.m4889("ChannelsData(channels=");
            sbM4889.append(this.f3352);
            sbM4889.append(", channelGroup=");
            sbM4889.append(this.f3353);
            sbM4889.append(")");
            return sbM4889.toString();
        }
    }

    /* JADX INFO: Add missing generic type declarations: [S] */
    /* JADX INFO: renamed from: ނ.֏.֏.ހ.֏.ދ$ހ, reason: contains not printable characters */
    public static final class C0807<T, S> implements InterfaceC2230<S> {
        public C0807() {
        }

        @Override // p037.p099.InterfaceC2230
        /* JADX INFO: renamed from: ֏ */
        public void mo1576(Object obj) {
            List list = (List) obj;
            C2226<Map<Long, List<ޜ>>> c2226 = C0804.this.f3344;
            C6635.m9823((Object) list, "recordings");
            LinkedHashMap linkedHashMap = new LinkedHashMap();
            for (T t : list) {
                Long l = ((ޜ) t).ށ;
                Object arrayList = linkedHashMap.get(l);
                if (arrayList == null) {
                    arrayList = new ArrayList();
                    linkedHashMap.put(l, arrayList);
                }
                ((List) arrayList).add(t);
            }
            c2226.mo345(linkedHashMap);
        }
    }

    /* JADX INFO: renamed from: ނ.֏.֏.ހ.֏.ދ$ށ, reason: contains not printable characters */
    @InterfaceC6540
    @InterfaceC6593(c = "ar.tvplayer.tv.base.ui.ChannelsListViewModel$sortChannels$1", f = "ChannelsListViewModel.kt", l = {112}, m = "invokeSuspend")
    public static final class C0808 extends AbstractC6597 implements InterfaceC6618<InterfaceC1327, InterfaceC6575<? super C6549>, Object> {

        /* JADX INFO: renamed from: އ, reason: contains not printable characters */
        public InterfaceC1327 f3355;

        /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
        public Object f3356;

        /* JADX INFO: renamed from: މ, reason: contains not printable characters */
        public Object f3357;

        /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
        public int f3358;

        /* JADX INFO: renamed from: ތ, reason: contains not printable characters */
        public final /* synthetic */ List f3360;

        /* JADX INFO: renamed from: ލ, reason: contains not printable characters */
        public final /* synthetic */ ގ f3361;

        /* JADX INFO: renamed from: ގ, reason: contains not printable characters */
        public final /* synthetic */ ގ f3362;

        /* JADX INFO: renamed from: ނ.֏.֏.ހ.֏.ދ$ށ$֏, reason: contains not printable characters */
        @InterfaceC6593(c = "ar.tvplayer.tv.base.ui.ChannelsListViewModel$sortChannels$1$1", f = "ChannelsListViewModel.kt", l = {}, m = "invokeSuspend")
        public static final class C0809 extends AbstractC6597 implements InterfaceC6618<InterfaceC1327, InterfaceC6575<? super C6549>, Object> {

            /* JADX INFO: renamed from: އ, reason: contains not printable characters */
            public InterfaceC1327 f3363;

            /* JADX INFO: renamed from: މ, reason: contains not printable characters */
            public final /* synthetic */ List f3365;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            public C0809(List list, InterfaceC6575 interfaceC6575) {
                super(2, interfaceC6575);
                this.f3365 = list;
            }

            @Override // p402.p405.p407.p408.AbstractC6589
            /* JADX INFO: renamed from: ֏ */
            public final InterfaceC6575<C6549> mo837(Object obj, InterfaceC6575<?> interfaceC6575) {
                if (interfaceC6575 == null) {
                    C6635.m9824("completion");
                    throw null;
                }
                C0809 c0809 = C0808.this.new C0809(this.f3365, interfaceC6575);
                c0809.f3363 = (InterfaceC1327) obj;
                return c0809;
            }

            @Override // p402.p411.p412.InterfaceC6618
            /* JADX INFO: renamed from: ؠ */
            public final Object mo838(InterfaceC1327 interfaceC1327, InterfaceC6575<? super C6549> interfaceC6575) {
                return ((C0809) mo837(interfaceC1327, interfaceC6575)).mo839(C6549.f19328);
            }

            @Override // p402.p405.p407.p408.AbstractC6589
            /* JADX INFO: renamed from: ށ */
            public final Object mo839(Object obj) {
                EnumC6586 enumC6586 = EnumC6586.COROUTINE_SUSPENDED;
                C4303.m7198(obj);
                C0804 c0804 = C0804.this;
                C1267 c1267 = c0804.f3347;
                if (c1267 == null) {
                    return null;
                }
                c0804.f3339.mo345(new C0806(this.f3365, c1267));
                return C6549.f19328;
            }
        }

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C0808(List list, ގ r3, ގ r4, InterfaceC6575 interfaceC6575) {
            super(2, interfaceC6575);
            this.f3360 = list;
            this.f3361 = r3;
            this.f3362 = r4;
        }

        @Override // p402.p405.p407.p408.AbstractC6589
        /* JADX INFO: renamed from: ֏ */
        public final InterfaceC6575<C6549> mo837(Object obj, InterfaceC6575<?> interfaceC6575) {
            if (interfaceC6575 == null) {
                C6635.m9824("completion");
                throw null;
            }
            C0808 c0808 = C0804.this.new C0808(this.f3360, this.f3361, this.f3362, interfaceC6575);
            c0808.f3355 = (InterfaceC1327) obj;
            return c0808;
        }

        @Override // p402.p411.p412.InterfaceC6618
        /* JADX INFO: renamed from: ؠ */
        public final Object mo838(InterfaceC1327 interfaceC1327, InterfaceC6575<? super C6549> interfaceC6575) {
            return ((C0808) mo837(interfaceC1327, interfaceC6575)).mo839(C6549.f19328);
        }

        @Override // p402.p405.p407.p408.AbstractC6589
        /* JADX INFO: renamed from: ށ */
        public final Object mo839(Object obj) {
            EnumC6586 enumC6586 = EnumC6586.COROUTINE_SUSPENDED;
            int i = this.f3358;
            if (i == 0) {
                C4303.m7198(obj);
                InterfaceC1327 interfaceC1327 = this.f3355;
                List list = this.f3360;
                ގ r3 = this.f3361;
                ގ r4 = this.f3362;
                if (list == null) {
                    C6635.m9824("channels");
                    throw null;
                }
                if (r3 == null) {
                    C6635.m9824("_prevSorting");
                    throw null;
                }
                if (r4 == null) {
                    C6635.m9824("_sorting");
                    throw null;
                }
                List listM9778 = C6560.m9778((Iterable) list, (Comparator) new ވ(r3.ބ(), r4.ބ(), ރ.ߠ.ޣ(), ރ.ߠ.ࠚ()));
                if (C4303.m7134(interfaceC1327)) {
                    AbstractC1376 abstractC1376M2665 = C1340.m2665();
                    C0809 c0809 = new C0809(listM9778, null);
                    this.f3356 = interfaceC1327;
                    this.f3357 = listM9778;
                    this.f3358 = 1;
                    if (C4303.m7018(abstractC1376M2665, c0809, this) == enumC6586) {
                        return enumC6586;
                    }
                }
            } else {
                if (i != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                C4303.m7198(obj);
            }
            return C6549.f19328;
        }
    }

    public C0804() {
        ޙ r0 = ހ.֏().ލ();
        if (r0 == null) {
            throw null;
        }
        this.f3346 = CommonUtilsKt.֏(r0.֏.f7599.m4455(new String[]{"playlists"}, false, new ޞ(r0, C2409.m4490("SELECT COUNT(*) FROM playlists WHERE is_enabled == 1", 0))));
        m2110();
        LiveData<List<ޡ>> liveData = this.f3343;
        if (liveData != null) {
            this.f3342.m4289(liveData);
        }
        ޥ r02 = ހ.֏().ޏ();
        long jCurrentTimeMillis = System.currentTimeMillis() / ((long) 1000);
        ޥ r03 = r02;
        if (r03 == null) {
            throw null;
        }
        C2409 c2409M4490 = C2409.m4490("\n        SELECT id, channel_id, program_start_seconds\n        FROM reminders\n        WHERE program_start_seconds > ?\n        ", 1);
        c2409M4490.bindLong(1, jCurrentTimeMillis);
        LiveData<List<ޡ>> liveData2 = CommonUtilsKt.֏(r03.֏.f7599.m4455(new String[]{"reminders"}, false, new ࢠ(r03, c2409M4490)));
        this.f3343 = liveData2;
        this.f3342.m4290(liveData2, new C0813(this));
        m2111();
        this.f3346.m343(C0805.f3351);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static /* synthetic */ void m2104(C0804 c0804, C1267 c1267, boolean z, boolean z2, Collection collection, int i) {
        if ((i & 2) != 0) {
            z = false;
        }
        if ((i & 4) != 0) {
            z2 = false;
        }
        if ((i & 8) != 0) {
            collection = C6563.f19343;
        }
        if (c1267 == null) {
            C6635.m9824("selectedGroup");
            throw null;
        }
        if (collection == null) {
            C6635.m9824("channelIdsToInclude");
            throw null;
        }
        if ((!C6635.m9825(c0804.f3347, c1267)) || z) {
            c0804.f3347 = c1267;
            c0804.f3348 = null;
            InterfaceC1363 interfaceC1363 = c0804.f3349;
            if (interfaceC1363 != null) {
                C4303.m7098(interfaceC1363, (CancellationException) null, 1, (Object) null);
            }
            InterfaceC1363 interfaceC13632 = c0804.f3350;
            if (interfaceC13632 != null) {
                C4303.m7098(interfaceC13632, (CancellationException) null, 1, (Object) null);
            }
            LiveData<List<ނ>> liveData = c0804.f3340;
            if (liveData != null) {
                c0804.f3339.m4289(liveData);
            }
            LiveData<ކ> liveData2 = c0804.f3341;
            if (liveData2 != null) {
                c0804.f3339.m4289(liveData2);
            }
            c0804.f3349 = CommonUtilsKt.ؠ(LayoutInflaterFactory2C1494.C1505.m2925((AbstractC2245) c0804), new C0811(c0804, z2, collection, null));
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final ޤ m2105(long j, long j2) {
        return ʳ.ނ.ؠ(j, j2);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Object m2106(long j, long j2, InterfaceC6575<? super ޤ> interfaceC6575) {
        return ʳ.ނ.ؠ(j, j2, interfaceC6575);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m2107(ނ r10) {
        if (r10 == null) {
            C6635.m9824("channel");
            throw null;
        }
        C4303.m7160(C1356.f4507, C1340.f4488, null, new ޚ(r10.ބ, !r10.ޛ, (InterfaceC6575) null), 2, null);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m2108(List<ނ> list, ގ r14, ގ r15) {
        InterfaceC1363 interfaceC1363 = this.f3350;
        if (interfaceC1363 != null) {
            C4303.m7098(interfaceC1363, (CancellationException) null, 1, (Object) null);
        }
        this.f3350 = C4303.m7160(LayoutInflaterFactory2C1494.C1505.m2925((AbstractC2245) this), C1340.f4487, null, new C0808(list, r14, r15, null), 2, null);
    }

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final LiveData<ކ> m2109() {
        LiveData<ކ> liveData = this.f3341;
        if (liveData != null) {
            return liveData;
        }
        C6635.m9826("optionsLiveData");
        throw null;
    }

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public final void m2110() {
        C1267 c1267M2559 = C1267.f4383.m2559();
        if (c1267M2559 != null) {
            if (this.f3347 == null) {
                m2104(this, c1267M2559, false, false, null, 14);
            } else if (!C6635.m9825(r0, c1267M2559)) {
                this.f3339.mo345((C0806) null);
                m2104(this, c1267M2559, false, false, null, 14);
            }
        }
    }

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final void m2111() {
        LiveData<List<ޜ>> liveData = this.f3345;
        if (liveData != null) {
            C2226<Map<Long, List<ޜ>>> c2226 = this.f3344;
            if (liveData == null) {
                C6635.m9826("recordingsForTvGuideLiveData");
                throw null;
            }
            c2226.m4289(liveData);
        }
        ޠ r0 = ހ.֏().ގ();
        long jCurrentTimeMillis = System.currentTimeMillis() / ((long) 1000);
        ޠ r02 = r0;
        if (r02 == null) {
            throw null;
        }
        C2409 c2409M4490 = C2409.m4490("\n        SELECT id, start_seconds, stop_seconds, channel_id, program_start_seconds\n        FROM recordings\n        WHERE stop_seconds > ?\n        ", 1);
        c2409M4490.bindLong(1, jCurrentTimeMillis);
        LiveData<List<ޜ>> liveData2 = CommonUtilsKt.֏(r02.֏.f7599.m4455(new String[]{"recordings"}, false, new ޣ(r02, c2409M4490)));
        this.f3345 = liveData2;
        C2226<Map<Long, List<ޜ>>> c22262 = this.f3344;
        if (liveData2 != null) {
            c22262.m4290(liveData2, new C0807());
        } else {
            C6635.m9826("recordingsForTvGuideLiveData");
            throw null;
        }
    }

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final void m2112() {
        C1267 c1267 = this.f3347;
        if (c1267 != null) {
            m2104(this, c1267, true, false, null, 12);
        }
    }
}
