package j5;

import com.martsnew.data.model.response.ContinueWatchResponse;
import com.martsnew.data.model.response.ListEpisodeResponse;
import com.martsnew.data.model.response.ListSeasonResponse;
import com.martsnew.data.model.response.SeasonResponse;
import com.martsnew.domain.model.Season;
import java.util.ArrayList;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public final class s implements p {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final C1079j f13717a;

    public s(C1079j c1079j) {
        P6.g.e(c1079j, "episodeMapper");
        this.f13717a = c1079j;
    }

    @Override // j5.p
    /* JADX INFO: renamed from: b, reason: merged with bridge method [inline-methods] */
    public final k5.k a(ListSeasonResponse listSeasonResponse) {
        List list;
        Long l8;
        P6.g.e(listSeasonResponse, "dto");
        List list2 = listSeasonResponse.f10844b;
        ContinueWatchResponse continueWatchResponse = list2 != null ? (ContinueWatchResponse) B6.k.o0(list2) : null;
        Iterable<SeasonResponse> iterable = listSeasonResponse.f10843a;
        if (iterable == null) {
            iterable = B6.t.f1032q;
        }
        ArrayList arrayList = new ArrayList(B6.m.a0(iterable));
        for (SeasonResponse seasonResponse : iterable) {
            long j8 = seasonResponse.f10918a;
            String str = seasonResponse.f10919b;
            if (str == null) {
                str = "";
            }
            List list3 = seasonResponse.f10923f;
            int size = list3 != null ? list3.size() : 0;
            String str2 = seasonResponse.f10922e;
            String str3 = str2 != null ? str2 : "";
            if (continueWatchResponse == null || (l8 = continueWatchResponse.f10694d) == null) {
                list = list3;
            } else {
                list = list3;
                boolean z8 = l8.longValue() == seasonResponse.f10918a;
                ListEpisodeResponse listEpisodeResponse = new ListEpisodeResponse(list, list2);
                this.f13717a.getClass();
                arrayList.add(new Season(j8, str, size, str3, z8, C1079j.b(listEpisodeResponse).f13977a));
            }
            ListEpisodeResponse listEpisodeResponse2 = new ListEpisodeResponse(list, list2);
            this.f13717a.getClass();
            arrayList.add(new Season(j8, str, size, str3, z8, C1079j.b(listEpisodeResponse2).f13977a));
        }
        return new k5.k(arrayList);
    }
}
