package androidx.lifecycle;

import androidx.lifecycle.k;
import defpackage.ak1;
import defpackage.ck1;
import defpackage.dr4;
import defpackage.dw7;
import defpackage.e6a;
import defpackage.fx4;
import defpackage.gr3;
import defpackage.rg6;
import defpackage.s38;
import defpackage.ts0;
import defpackage.vx8;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.DebugProbesKt;
import kotlin.coroutines.jvm.internal.SuspendLambda;

/* JADX INFO: loaded from: classes.dex */
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\u008a@¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lak1;", "Le6a;", "<anonymous>", "(Lak1;)V"}, k = 3, mv = {1, 8, 0})
@DebugMetadata(c = "androidx.lifecycle.RepeatOnLifecycleKt$repeatOnLifecycle$3$1", f = "RepeatOnLifecycle.kt", i = {0, 0}, l = {166}, m = "invokeSuspend", n = {"launchedJob", "observer"}, s = {"L$0", "L$1"})
@vx8
final class ag extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public dw7.h a;
    public dw7.h b;
    public ak1 c;
    public int d;
    public final /* synthetic */ k e;
    public final /* synthetic */ ak1 f;
    public final /* synthetic */ SuspendLambda i;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    /* JADX WARN: Multi-variable type inference failed */
    public ag(k kVar, ak1 ak1Var, gr3 gr3Var, Continuation continuation) {
        super(2, continuation);
        this.e = kVar;
        this.f = ak1Var;
        this.i = (SuspendLambda) gr3Var;
    }

    /* JADX WARN: Type inference failed for: r1v0, types: [gr3, kotlin.coroutines.jvm.internal.SuspendLambda] */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Continuation create(Object obj, Continuation continuation) {
        return new ag(this.e, this.f, this.i, continuation);
    }

    @Override // defpackage.gr3
    public final Object invoke(Object obj, Object obj2) {
        return ((ag) create((ak1) obj, (Continuation) obj2)).invokeSuspend(e6a.a);
    }

    /* JADX WARN: Removed duplicated region for block: B:27:0x0085  */
    /* JADX WARN: Removed duplicated region for block: B:30:0x008e  */
    /* JADX WARN: Removed duplicated region for block: B:34:0x0098  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x00a1  */
    /* JADX WARN: Removed duplicated region for block: B:43:? A[SYNTHETIC] */
    /* JADX WARN: Type inference failed for: r13v0, types: [gr3, kotlin.coroutines.jvm.internal.SuspendLambda] */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) throws Throwable {
        dw7.h hVar;
        Throwable th;
        dw7.h hVar2;
        fx4 fx4Var;
        p pVar;
        fx4 fx4Var2;
        p pVar2;
        ck1 ck1Var = ck1.a;
        int i = this.d;
        e6a e6aVar = e6a.a;
        k kVar = this.e;
        if (i == 0) {
            s38.b(obj);
            if (kVar.getD() != k.b.a) {
                dw7.h hVar3 = new dw7.h();
                hVar = new dw7.h();
                try {
                    k.b bVar = k.b.d;
                    ak1 ak1Var = this.f;
                    ?? r13 = this.i;
                    this.a = hVar3;
                    this.b = hVar;
                    this.c = ak1Var;
                    this.d = 1;
                    ts0 ts0Var = new ts0(1, dr4.d(this));
                    ts0Var.r();
                    k.a.INSTANCE.getClass();
                    af afVar = new af(k.a.Companion.b(bVar), hVar3, ak1Var, k.a.Companion.a(bVar), ts0Var, rg6.a(), r13);
                    hVar.a = afVar;
                    kVar.a(afVar);
                    Object objQ = ts0Var.q();
                    if (objQ == ck1Var) {
                        DebugProbesKt.probeCoroutineSuspended(this);
                    }
                    if (objQ == ck1Var) {
                        return ck1Var;
                    }
                    hVar2 = hVar3;
                    fx4Var2 = (fx4) hVar2.a;
                    if (fx4Var2 != null) {
                    }
                    pVar2 = (p) hVar.a;
                    if (pVar2 != null) {
                    }
                } catch (Throwable th2) {
                    th = th2;
                    hVar2 = hVar3;
                    fx4Var = (fx4) hVar2.a;
                    if (fx4Var != null) {
                    }
                    pVar = (p) hVar.a;
                    if (pVar != null) {
                    }
                }
            }
        } else {
            if (i != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            hVar = this.b;
            hVar2 = this.a;
            try {
                s38.b(obj);
                fx4Var2 = (fx4) hVar2.a;
                if (fx4Var2 != null) {
                    fx4Var2.h(null);
                }
                pVar2 = (p) hVar.a;
                if (pVar2 != null) {
                    kVar.c(pVar2);
                }
            } catch (Throwable th3) {
                th = th3;
                fx4Var = (fx4) hVar2.a;
                if (fx4Var != null) {
                    fx4Var.h(null);
                }
                pVar = (p) hVar.a;
                if (pVar != null) {
                    throw th;
                }
                kVar.c(pVar);
                throw th;
            }
        }
        return e6aVar;
    }
}
