package d3;

import V2.Q2;
import android.content.Context;
import androidx.media3.exoplayer.ExoPlayer;
import com.debridstream.tv.PlayerViewModel;
import m3.AbstractC2467b;
import w4.C3137A;

/* JADX INFO: loaded from: classes.dex */
public final class B1 extends C4.j implements J4.e {

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

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ PlayerViewModel f15028d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final /* synthetic */ ExoPlayer f15029e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final /* synthetic */ Context f15030f;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public B1(A4.d dVar, Context context, ExoPlayer exoPlayer, PlayerViewModel playerViewModel) {
        super(2, dVar);
        this.f15028d = playerViewModel;
        this.f15029e = exoPlayer;
        this.f15030f = context;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        B1 b12 = new B1(dVar, this.f15030f, this.f15029e, this.f15028d);
        b12.f15027c = obj;
        return b12;
    }

    @Override // J4.e
    public final Object invoke(Object obj, Object obj2) {
        return ((B1) create((V4.C) obj, (A4.d) obj2)).invokeSuspend(C3137A.f25453a);
    }

    /* JADX WARN: Path cross not found for [B:58:0x00e3, B:54:0x00ca], limit reached: 64 */
    /* JADX WARN: Removed duplicated region for block: B:16:0x0045  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:59:0x00ef -> B:14:0x003f). Please report as a decompilation issue!!! */
    @Override // C4.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) {
        V4.C c6;
        int i6;
        B4.a aVar = B4.a.f492a;
        int i7 = this.f15026b;
        if (i7 != 0) {
            if (i7 != 1 && i7 != 2) {
                if (i7 == 3) {
                    i6 = this.f15025a;
                    c6 = (V4.C) this.f15027c;
                    AbstractC2467b.l(obj);
                    this.f15027c = c6;
                    this.f15025a = i6;
                    this.f15026b = 4;
                    if (V4.E.l(900L, this) != aVar) {
                    }
                    return aVar;
                }
                if (i7 != 4) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
            }
            i6 = this.f15025a;
            c6 = (V4.C) this.f15027c;
            AbstractC2467b.l(obj);
        } else {
            AbstractC2467b.l(obj);
            c6 = (V4.C) this.f15027c;
            i6 = -1;
        }
        while (V4.E.v(c6)) {
            PlayerViewModel playerViewModel = this.f15028d;
            if (((Q2) playerViewModel.getUiState().getValue()).f7502g != null) {
                ExoPlayer exoPlayer = this.f15029e;
                Long l = new Long(exoPlayer.getDuration());
                if (l.longValue() <= 0) {
                    l = null;
                }
                if ((l != null ? l.longValue() : 0L) <= 0) {
                    this.f15027c = c6;
                    this.f15025a = i6;
                    this.f15026b = 2;
                    if (V4.E.l(500L, this) == aVar) {
                    }
                } else {
                    int iFloor = (int) Math.floor((exoPlayer.getCurrentPosition() >= 0 ? r15 : 0L) / 1000.0d);
                    if (i6 >= 0 && iFloor < i6 - 15) {
                        i6 = iFloor;
                    }
                    boolean z6 = false;
                    if (iFloor >= 60 && i6 >= 0 && iFloor - i6 >= 60) {
                        z6 = true;
                    }
                    if ((i6 < 0 && iFloor >= 60) || z6) {
                        c5.e eVar = V4.N.f8259a;
                        c5.d dVar = c5.d.f13466b;
                        A1 a12 = new A1(null, this.f15030f, exoPlayer, playerViewModel);
                        this.f15027c = c6;
                        this.f15025a = iFloor;
                        this.f15026b = 3;
                        if (V4.E.H(dVar, a12, this) != aVar) {
                            i6 = iFloor;
                        }
                    }
                    this.f15027c = c6;
                    this.f15025a = i6;
                    this.f15026b = 4;
                    if (V4.E.l(900L, this) != aVar) {
                        while (V4.E.v(c6)) {
                        }
                    }
                }
                return aVar;
            }
            this.f15027c = c6;
            this.f15025a = i6;
            this.f15026b = 1;
            if (V4.E.l(1000L, this) == aVar) {
                return aVar;
            }
        }
        return C3137A.f25453a;
    }
}
