package V2;

import android.content.Context;
import java.util.concurrent.CancellationException;
import m3.AbstractC2467b;
import org.json.JSONArray;
import w4.C3137A;

/* JADX INFO: renamed from: V2.q, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0709q extends C4.j implements J4.e {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public i3.J f8008a;

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

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

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

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public C0709q(Context context, boolean z6, A4.d dVar) {
        super(2, dVar);
        this.f8011d = context;
        this.f8012e = z6;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        C0709q c0709q = new C0709q(this.f8011d, this.f8012e, dVar);
        c0709q.f8010c = obj;
        return c0709q;
    }

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

    /* JADX WARN: Code restructure failed: missing block: B:33:0x0082, code lost:
    
        if (r1.H(r11) == r0) goto L48;
     */
    @Override // C4.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) throws Throwable {
        Object objD;
        Object objD2;
        i3.K k6;
        Throwable thA;
        i3.J j4;
        V4.C c6;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f8009b;
        C3137A c3137a = C3137A.f25453a;
        Context context = this.f8011d;
        try {
            try {
            } catch (Throwable th) {
                objD2 = AbstractC2467b.d(th);
            }
        } catch (Throwable th2) {
            objD = AbstractC2467b.d(th2);
        }
        if (i6 == 0) {
            AbstractC2467b.l(obj);
            V4.C c7 = (V4.C) this.f8010c;
            Y4.c0 c0Var = z3.f8212a;
            kotlin.jvm.internal.o.e(context);
            String strA = z3.a(context);
            if (strA == null) {
                strA = "main";
            }
            if (C0716s.p(C0716s.f8049a, context, strA)) {
                j4 = new i3.J(context);
                this.f8010c = c7;
                this.f8008a = j4;
                this.f8009b = 1;
                Object objI = j4.I(this);
                if (objI == aVar) {
                    return aVar;
                }
                c6 = c7;
                obj = objI;
            }
            return c3137a;
        }
        if (i6 != 1) {
            if (i6 != 2) {
                if (i6 != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                k6 = (i3.K) this.f8010c;
                AbstractC2467b.l(obj);
                Y4.c0 c0Var2 = C0706p0.f7996a;
                C0706p0.i(k6.f18895a.getString("continue_watching_payload", null));
                objD = c3137a;
                thA = w4.n.a(objD);
                if (thA != null && (thA instanceof CancellationException)) {
                    throw thA;
                }
                return c3137a;
            }
            AbstractC2467b.l(obj);
            objD2 = c3137a;
            Throwable thA2 = w4.n.a(objD2);
            if (thA2 != null && (thA2 instanceof CancellationException)) {
                throw thA2;
            }
            if (this.f8012e) {
                kotlin.jvm.internal.o.e(context);
                i3.K k7 = new i3.K(context);
                k7.f18895a.edit().remove("continue_watching_sync_time").remove("continue_watching_payload").apply();
                i3.J j6 = new i3.J(context);
                this.f8010c = k7;
                this.f8008a = null;
                this.f8009b = 3;
                if (j6.G(this) != aVar) {
                    k6 = k7;
                    Y4.c0 c0Var22 = C0706p0.f7996a;
                    C0706p0.i(k6.f18895a.getString("continue_watching_payload", null));
                    objD = c3137a;
                    thA = w4.n.a(objD);
                    if (thA != null) {
                        throw thA;
                    }
                }
                return aVar;
            }
            return c3137a;
        }
        j4 = this.f8008a;
        c6 = (V4.C) this.f8010c;
        AbstractC2467b.l(obj);
        Y4.c0 c0Var3 = C0706p0.f7996a;
        C0706p0.j((JSONArray) obj);
        this.f8010c = c6;
        this.f8008a = null;
        this.f8009b = 2;
    }
}
