package H5;

import Z6.AbstractC0385z;
import Z6.InterfaceC0382w;
import c7.K;
import com.google.android.gms.internal.measurement.C1;
import com.martsnew.domain.model.Movie;
import com.martsnew.domain.model.Shortcut;
import com.martsnew.domain.model.Vote;
import com.martsnew.domain.type.MediaType;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import k5.C1101a;
import k5.C1104d;
import k5.C1105e;
import k5.C1107g;
import q5.C1468e;

/* JADX INFO: loaded from: classes.dex */
public final class z extends G6.i implements O6.p {

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    public /* synthetic */ Object f3169A;

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    public final /* synthetic */ B f3170B;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public Object f3171u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public Object f3172v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public Object f3173w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public ArrayList f3174x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public P6.m f3175y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public int f3176z;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public z(B b8, E6.d dVar) {
        super(2, dVar);
        this.f3170B = b8;
    }

    @Override // O6.p
    public final Object k(Object obj, Object obj2) {
        return ((z) m((E6.d) obj2, (InterfaceC0382w) obj)).p(A6.n.f457a);
    }

    @Override // G6.a
    public final E6.d m(E6.d dVar, Object obj) {
        z zVar = new z(this.f3170B, dVar);
        zVar.f3169A = obj;
        return zVar;
    }

    /* JADX WARN: Removed duplicated region for block: B:40:0x00ed  */
    /* JADX WARN: Removed duplicated region for block: B:45:0x0113  */
    /* JADX WARN: Removed duplicated region for block: B:50:0x0129  */
    /* JADX WARN: Removed duplicated region for block: B:66:0x0258  */
    /* JADX WARN: Removed duplicated region for block: B:72:0x0279  */
    @Override // G6.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object p(Object obj) throws Throwable {
        Z6.C cD;
        Object objA;
        Z6.C c3;
        List list;
        B b8;
        ArrayList arrayList;
        P6.m mVar;
        Object obj2;
        int size;
        int i;
        int i5;
        Object objJ;
        P6.m mVar2;
        List list2;
        B b9;
        Object obj3;
        F6.a aVar = F6.a.f2580q;
        int i8 = this.f3176z;
        B b10 = this.f3170B;
        int i9 = 1;
        C1468e c1468e = b10.f3104g;
        if (i8 == 0) {
            C1.N(obj);
            cD = c1468e.f16277a.b() ? AbstractC0385z.d((InterfaceC0382w) this.f3169A, new y(b10, null)) : null;
            this.f3169A = cD;
            this.f3176z = 1;
            objA = b10.f3101d.a(this);
            if (objA != aVar) {
            }
            return aVar;
        }
        if (i8 != 1) {
            if (i8 != 2) {
                if (i8 != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                mVar2 = (P6.m) this.f3173w;
                list2 = (List) this.f3172v;
                b9 = (B) this.f3171u;
                C1.N(obj);
                i5 = 1;
                objJ = obj;
                obj3 = ((A6.j) objJ).f449q;
                if (!(obj3 instanceof A6.i)) {
                    C1104d c1104d = (C1104d) obj3;
                    String str = c1104d.f13969a.f11086r;
                    List list3 = c1104d.f13970b;
                    C0143b c0143b = new C0143b(str, null, list3, null);
                    Object obj4 = mVar2.f5535q;
                    if (obj4 != null) {
                        List list4 = ((C0143b) obj4).f3124c;
                        if (list4 != null && list3 != null && list3.size() == list4.size()) {
                            Iterator it = new U6.c(0, list4.size() - 1, i5).iterator();
                            while (((U6.b) it).f6802s) {
                                U6.b bVar = (U6.b) it;
                                int i10 = bVar.f6803t;
                                if (i10 != bVar.f6801r) {
                                    bVar.f6803t = bVar.f6800q + i10;
                                } else {
                                    if (!bVar.f6802s) {
                                        throw new NoSuchElementException();
                                    }
                                    bVar.f6802s = false;
                                }
                                C1101a c1101a = (C1101a) list4.get(i10);
                                C1101a c1101a2 = (C1101a) list3.get(i10);
                                if (c1101a.f13943a == c1101a2.f13943a && c1101a.i == c1101a2.i && c1101a.f13948f == c1101a2.f13948f && c1101a.f13949g == c1101a2.f13949g) {
                                    Movie movie = c1101a.f13952k;
                                    String str2 = movie != null ? movie.f11071s : null;
                                    Movie movie2 = c1101a2.f13952k;
                                    if (!P6.g.a(str2, movie2 != null ? movie2.f11071s : null)) {
                                    }
                                }
                                list2.set(0, c0143b);
                                K k8 = b9.f3108l;
                                k8.getClass();
                                k8.g(null, list2);
                            }
                        }
                    } else {
                        list2.add(0, c0143b);
                        K k9 = b9.f3108l;
                        k9.getClass();
                        k9.g(null, list2);
                    }
                }
                return A6.n.f457a;
            }
            mVar = this.f3175y;
            arrayList = this.f3174x;
            list = (List) this.f3173w;
            b8 = (B) this.f3172v;
            objA = this.f3171u;
            c3 = (Z6.C) this.f3169A;
            C1.N(obj);
            obj2 = ((A6.j) obj).f449q;
            if (!(obj2 instanceof A6.i)) {
                C1104d c1104d2 = (C1104d) obj2;
                C0143b c0143b2 = new C0143b(c1104d2.f13969a.f11086r, null, c1104d2.f13970b, null);
                arrayList.add(c0143b2);
                mVar.f5535q = c0143b2;
            }
            ArrayList arrayList2 = new ArrayList();
            for (Object obj5 : list) {
                if (!(((k5.i) obj5) instanceof C1107g)) {
                    arrayList2.add(obj5);
                }
            }
            size = arrayList2.size();
            i = 0;
            while (i < size) {
                Object obj6 = arrayList2.get(i);
                i++;
                k5.i iVar = (k5.i) obj6;
                if (iVar instanceof C1104d) {
                    C1104d c1104d3 = (C1104d) iVar;
                    Shortcut shortcut = c1104d3.f13969a;
                    ArrayList arrayListY0 = B6.k.y0(c1104d3.f13970b);
                    arrayListY0.add(new C1101a(new Movie(0L, (String) null, (String) null, (String) null, (String) null, (String) null, 0, (MediaType) null, (String) null, (String) null, false, 0, 0, (String) null, 0.0d, 0L, (List) null, (List) null, (List) null, (List) null, false, (Vote) null, 8388606)));
                    arrayList.add(new C0143b(shortcut.f11086r, null, arrayListY0, null));
                } else if (iVar instanceof C1105e) {
                    C1105e c1105e = (C1105e) iVar;
                    Shortcut shortcut2 = c1105e.f13971a;
                    ArrayList arrayListY02 = B6.k.y0(c1105e.f13972b);
                    arrayListY02.add(new Movie(-100L, (String) null, (String) null, c1105e.f13971a.f11085q, (String) null, (String) null, 0, (MediaType) null, (String) null, (String) null, false, 0, 0, (String) null, 0.0d, 0L, (List) null, (List) null, (List) null, (List) null, false, (Vote) null, 8388598));
                    arrayList.add(new C0143b(shortcut2.f11086r, arrayListY02, null, null));
                } else if (iVar instanceof k5.h) {
                    k5.h hVar = (k5.h) iVar;
                    for (k5.o oVar : hVar.f13976b) {
                        Shortcut shortcut3 = hVar.f13975a;
                        ArrayList arrayListY03 = B6.k.y0(oVar.f13988c);
                        arrayListY03.add(new Movie(-100L, (String) null, (String) null, shortcut3.f11085q, (String) null, (String) null, 0, (MediaType) null, (String) null, (String) null, false, 0, 0, (String) null, 0.0d, 0L, (List) null, (List) null, (List) null, (List) null, false, (Vote) null, 8388598));
                        arrayList.add(new C0143b(shortcut3.f11086r, arrayListY03, null, null));
                        i9 = i9;
                    }
                }
                i9 = i9;
            }
            i5 = i9;
            b8.f3108l.f(arrayList);
            if (c3 != null) {
                this.f3169A = objA;
                this.f3171u = b8;
                this.f3172v = arrayList;
                this.f3173w = mVar;
                this.f3174x = null;
                this.f3175y = null;
                this.f3176z = 3;
                objJ = c3.j(this);
                if (objJ != aVar) {
                    mVar2 = mVar;
                    list2 = arrayList;
                    b9 = b8;
                    obj3 = ((A6.j) objJ).f449q;
                    if (!(obj3 instanceof A6.i)) {
                    }
                }
                return aVar;
            }
            return A6.n.f457a;
        }
        cD = (Z6.C) this.f3169A;
        C1.N(obj);
        objA = ((A6.j) obj).f449q;
        c3 = cD;
        if (!(objA instanceof A6.i)) {
            List list5 = (List) objA;
            ArrayList arrayList3 = new ArrayList();
            P6.m mVar3 = new P6.m();
            ArrayList arrayList4 = new ArrayList();
            for (Object obj7 : list5) {
                if (obj7 instanceof C1107g) {
                    arrayList4.add(obj7);
                }
            }
            if (!arrayList4.isEmpty()) {
                b10.f3105h.f(B6.k.h0(arrayList4));
            }
            if (c1468e.f16277a.b()) {
                this.f3169A = c3;
                this.f3171u = objA;
                this.f3172v = b10;
                this.f3173w = list5;
                this.f3174x = arrayList3;
                this.f3175y = mVar3;
                this.f3176z = 2;
                Object objX = b10.f3103f.x(true, this);
                if (objX != aVar) {
                    list = list5;
                    b8 = b10;
                    arrayList = arrayList3;
                    mVar = mVar3;
                    obj2 = objX;
                    if (!(obj2 instanceof A6.i)) {
                    }
                    ArrayList arrayList22 = new ArrayList();
                    while (r7.hasNext()) {
                    }
                    size = arrayList22.size();
                    i = 0;
                    while (i < size) {
                    }
                    i5 = i9;
                    b8.f3108l.f(arrayList);
                    if (c3 != null) {
                    }
                }
                return aVar;
            }
            list = list5;
            b8 = b10;
            arrayList = arrayList3;
            mVar = mVar3;
            ArrayList arrayList222 = new ArrayList();
            while (r7.hasNext()) {
            }
            size = arrayList222.size();
            i = 0;
            while (i < size) {
            }
            i5 = i9;
            b8.f3108l.f(arrayList);
            if (c3 != null) {
            }
        }
        return A6.n.f457a;
    }
}
