package j5;

import com.martsnew.data.model.response.EpisodeDetailResponse;
import com.martsnew.data.model.response.FileSizeResponse;
import com.martsnew.data.model.response.StreamDataResponse;
import com.martsnew.data.model.response.StreamingResponse;
import com.martsnew.data.model.response.SubResponse;
import com.martsnew.domain.model.EpisodeSource;
import com.martsnew.domain.model.StreamSource;
import com.martsnew.domain.model.StreamUrl;
import com.martsnew.domain.model.SubtitleSource;
import java.util.ArrayList;
import java.util.List;

/* JADX INFO: renamed from: j5.i, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C1078i implements p {
    public static EpisodeSource b(EpisodeDetailResponse episodeDetailResponse) {
        ArrayList arrayList;
        ArrayList arrayList2;
        ArrayList arrayList3;
        ArrayList arrayList4;
        ArrayList arrayList5;
        ArrayList arrayList6;
        List<StreamDataResponse> list;
        List<StreamDataResponse> list2;
        List<StreamDataResponse> list3;
        List<StreamDataResponse> list4;
        List<StreamDataResponse> list5;
        P6.g.e(episodeDetailResponse, "dto");
        String str = episodeDetailResponse.f10735n;
        List listB0 = str != null ? X6.e.b0(str, new String[]{"|"}) : null;
        String str2 = listB0 != null ? (String) B6.k.i0(listB0) : null;
        String str3 = str2 == null ? "" : str2;
        String str4 = listB0 != null ? (String) B6.k.j0(1, listB0) : null;
        if (str4 == null) {
            str4 = "";
        }
        int length = str4.length();
        String str5 = episodeDetailResponse.f10732k;
        String str6 = str5 == null ? "" : str5;
        String str7 = episodeDetailResponse.f10740s;
        String strK = str7 != null ? X6.n.K(str7, "{width}x{height}", "1920x1080") : null;
        String str8 = strK == null ? "" : strK;
        List<SubResponse> list6 = episodeDetailResponse.f10744w;
        if (list6 != null) {
            arrayList = new ArrayList(B6.m.a0(list6));
            for (SubResponse subResponse : list6) {
                long j8 = subResponse.f10950c;
                Long l8 = subResponse.f10948a;
                long jLongValue = l8 != null ? l8.longValue() : 0L;
                String str9 = subResponse.f10955h;
                String str10 = str9 == null ? "" : str9;
                String str11 = subResponse.f10953f;
                String str12 = str11 == null ? "" : str11;
                String str13 = subResponse.f10954g;
                String str14 = str13 == null ? "" : str13;
                Integer num = subResponse.f10952e;
                arrayList.add(new SubtitleSource(j8, jLongValue, str10, str12, str14, num != null && num.intValue() == 1));
            }
        } else {
            arrayList = null;
        }
        B6.t tVar = B6.t.f1032q;
        List list7 = arrayList == null ? tVar : arrayList;
        FileSizeResponse fileSizeResponse = episodeDetailResponse.f10741t;
        StreamingResponse streamingResponse = episodeDetailResponse.f10742u;
        if (streamingResponse == null || (list5 = streamingResponse.f10942b) == null) {
            arrayList2 = null;
        } else {
            arrayList2 = new ArrayList(B6.m.a0(list5));
            for (StreamDataResponse streamDataResponse : list5) {
                arrayList2.add(new StreamUrl(streamDataResponse.f10938c, streamDataResponse.f10937b, fileSizeResponse != null ? fileSizeResponse.f10773d : null));
            }
        }
        List list8 = arrayList2 == null ? tVar : arrayList2;
        if (streamingResponse == null || (list4 = streamingResponse.f10945e) == null) {
            arrayList3 = null;
        } else {
            arrayList3 = new ArrayList(B6.m.a0(list4));
            for (StreamDataResponse streamDataResponse2 : list4) {
                arrayList3.add(new StreamUrl(streamDataResponse2.f10938c, streamDataResponse2.f10937b, fileSizeResponse != null ? fileSizeResponse.f10772c : null));
            }
        }
        List list9 = arrayList3 == null ? tVar : arrayList3;
        if (streamingResponse == null || (list3 = streamingResponse.f10943c) == null) {
            arrayList4 = null;
        } else {
            arrayList4 = new ArrayList(B6.m.a0(list3));
            for (StreamDataResponse streamDataResponse3 : list3) {
                arrayList4.add(new StreamUrl(streamDataResponse3.f10938c, streamDataResponse3.f10937b, fileSizeResponse != null ? fileSizeResponse.f10770a : null));
            }
        }
        List list10 = arrayList4 == null ? tVar : arrayList4;
        if (streamingResponse == null || (list2 = streamingResponse.f10944d) == null) {
            arrayList5 = null;
        } else {
            arrayList5 = new ArrayList(B6.m.a0(list2));
            for (StreamDataResponse streamDataResponse4 : list2) {
                arrayList5.add(new StreamUrl(streamDataResponse4.f10938c, streamDataResponse4.f10937b, fileSizeResponse != null ? fileSizeResponse.f10771b : null));
            }
        }
        List list11 = arrayList5 == null ? tVar : arrayList5;
        if (streamingResponse == null || (list = streamingResponse.f10941a) == null) {
            arrayList6 = null;
        } else {
            ArrayList arrayList7 = new ArrayList(B6.m.a0(list));
            for (StreamDataResponse streamDataResponse5 : list) {
                arrayList7.add(new StreamUrl(streamDataResponse5.f10938c, streamDataResponse5.f10937b, fileSizeResponse != null ? fileSizeResponse.f10773d : null));
            }
            arrayList6 = arrayList7;
        }
        StreamSource streamSource = new StreamSource(list8, list9, list10, list11, arrayList6 == null ? tVar : arrayList6);
        Integer num2 = episodeDetailResponse.f10725c;
        int iIntValue = num2 != null ? num2.intValue() : 1;
        Long l9 = episodeDetailResponse.f10737p;
        long jLongValue2 = l9 != null ? l9.longValue() : -1L;
        Integer num3 = episodeDetailResponse.f10738q;
        return new EpisodeSource(episodeDetailResponse.f10727e, str6, str8, str3, length, list7, streamSource, iIntValue, episodeDetailResponse.f10731j, jLongValue2, num3 != null ? num3.intValue() : 1);
    }

    @Override // j5.p
    public final /* bridge */ /* synthetic */ Object a(Object obj) {
        return b((EpisodeDetailResponse) obj);
    }
}
