package M5;

import Z6.InterfaceC0382w;
import c7.K;
import com.google.android.gms.internal.measurement.C1;
import com.martsnew.domain.model.Episode;
import com.martsnew.domain.model.Movie;
import com.martsnew.domain.model.Season;
import com.martsnew.domain.type.MediaType;
import java.util.List;
import java.util.ListIterator;
import y5.C1763h;

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

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

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public final /* synthetic */ Movie f4333v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public final /* synthetic */ x f4334w;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public u(E6.d dVar, x xVar, Movie movie) {
        super(2, dVar);
        this.f4333v = movie;
        this.f4334w = xVar;
    }

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

    @Override // G6.a
    public final E6.d m(E6.d dVar, Object obj) {
        return new u(dVar, this.f4334w, this.f4333v);
    }

    /* JADX WARN: Removed duplicated region for block: B:18:0x0054  */
    /* JADX WARN: Removed duplicated region for block: B:24:0x009e  */
    /* JADX WARN: Removed duplicated region for block: B:31:0x00c0  */
    /* JADX WARN: Removed duplicated region for block: B:59:0x013a  */
    /* JADX WARN: Removed duplicated region for block: B:62:0x014d  */
    @Override // G6.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object p(Object obj) throws Throwable {
        Object obj2;
        Object obj3;
        Object objPrevious;
        Object objPrevious2;
        F6.a aVar = F6.a.f2580q;
        int i = this.f4332u;
        o oVar = o.f4320a;
        x xVar = this.f4334w;
        if (i == 0) {
            C1.N(obj);
            Movie movie = this.f4333v;
            int i5 = t.f4331a[movie.f11076x.ordinal()];
            long j8 = movie.f11069q;
            if (i5 == 1) {
                o5.q qVar = xVar.f4343e;
                this.f4332u = 1;
                Object objA = qVar.a(j8, this);
                if (objA != aVar) {
                    obj3 = objA;
                    if (!(obj3 instanceof A6.i)) {
                    }
                    if (A6.j.a(obj3) != null) {
                    }
                }
            } else {
                o5.s sVar = xVar.f4344f;
                MediaType mediaType = MediaType.f11106s;
                this.f4332u = 2;
                Object objA2 = sVar.a(j8, mediaType, this);
                if (objA2 != aVar) {
                    obj2 = objA2;
                    if (!(obj2 instanceof A6.i)) {
                    }
                    if (A6.j.a(obj2) != null) {
                    }
                }
            }
            return aVar;
        }
        if (i == 1) {
            C1.N(obj);
            obj3 = ((A6.j) obj).f449q;
            if (!(obj3 instanceof A6.i)) {
                List list = (List) obj3;
                if (list.isEmpty()) {
                    K k8 = xVar.f4350m;
                    C1763h c1763h = new C1763h(oVar);
                    k8.getClass();
                    k8.g(null, c1763h);
                } else {
                    K k9 = xVar.f4350m;
                    C1763h c1763h2 = new C1763h(new n(((Episode) B6.k.h0(list)).f11023q, ((Episode) B6.k.h0(list)).f11030x, ((Episode) B6.k.h0(list)).f11031y, 0, 0L));
                    k9.getClass();
                    k9.g(null, c1763h2);
                }
            }
            if (A6.j.a(obj3) != null) {
                K k10 = xVar.f4350m;
                C1763h c1763h3 = new C1763h(oVar);
                k10.getClass();
                k10.g(null, c1763h3);
            }
        } else {
            if (i != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            C1.N(obj);
            obj2 = ((A6.j) obj).f449q;
            if (!(obj2 instanceof A6.i)) {
                List list2 = (List) obj2;
                if (!list2.isEmpty()) {
                    ListIterator listIterator = list2.listIterator(list2.size());
                    while (true) {
                        if (!listIterator.hasPrevious()) {
                            objPrevious = null;
                            break;
                        }
                        objPrevious = listIterator.previous();
                        if (((Season) objPrevious).f11083u) {
                            break;
                        }
                    }
                    Season season = (Season) objPrevious;
                    if (season == null) {
                        K k11 = xVar.f4350m;
                        C1763h c1763h4 = new C1763h(oVar);
                        k11.getClass();
                        k11.g(null, c1763h4);
                    } else {
                        List list3 = season.f11084v;
                        ListIterator listIterator2 = list3.listIterator(list3.size());
                        while (true) {
                            if (!listIterator2.hasPrevious()) {
                                objPrevious2 = null;
                                break;
                            }
                            objPrevious2 = listIterator2.previous();
                            if (((Episode) objPrevious2).f11022A) {
                                break;
                            }
                        }
                        Episode episode = (Episode) objPrevious2;
                        if (episode != null) {
                            K k12 = xVar.f4350m;
                            Integer numE = X6.m.E(season.a());
                            C1763h c1763h5 = new C1763h(new n(episode.f11023q, episode.f11030x, episode.f11031y, numE != null ? numE.intValue() : 0, episode.f11028v));
                            k12.getClass();
                            k12.g(null, c1763h5);
                        }
                    }
                }
            }
            if (A6.j.a(obj2) != null) {
                K k13 = xVar.f4350m;
                C1763h c1763h6 = new C1763h(oVar);
                k13.getClass();
                k13.g(null, c1763h6);
            }
        }
        return A6.n.f457a;
    }
}
