package androidx.lifecycle;

import kotlin.Metadata;
import org.jetbrains.annotations.NotNull;

/* JADX INFO: loaded from: classes.dex */
@Metadata(d1 = {"\u0000\u001a\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\b\n\u0018\u00002\u00020\u0001J\u0018\u0010\u0007\u001a\u00020\u00062\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0005\u001a\u00020\u0004H\u0016¨\u0006\b"}, d2 = {"androidx/lifecycle/WithLifecycleStateKt$suspendWithStateAtLeastUnchecked$2$observer$1", "Landroidx/lifecycle/LifecycleEventObserver;", "Landroidx/lifecycle/p;", "source", "Landroidx/lifecycle/Lifecycle$Event;", "event", "Lkd/e;", "onStateChanged", "lifecycle-runtime_release"}, k = 1, mv = {1, 8, 0})
public final class WithLifecycleStateKt$suspendWithStateAtLeastUnchecked$2$observer$1 implements LifecycleEventObserver {
    final /* synthetic */ sd.a $block;
    final /* synthetic */ kotlinx.coroutines.g $co;
    final /* synthetic */ Lifecycle$State $state;
    final /* synthetic */ l $this_suspendWithStateAtLeastUnchecked;

    public WithLifecycleStateKt$suspendWithStateAtLeastUnchecked$2$observer$1(Lifecycle$State lifecycle$State, l lVar, kotlinx.coroutines.g gVar, sd.a aVar) {
        this.$state = lifecycle$State;
        this.$this_suspendWithStateAtLeastUnchecked = lVar;
        this.$co = gVar;
        this.$block = aVar;
    }

    @Override // androidx.lifecycle.LifecycleEventObserver
    public void onStateChanged(@NotNull p pVar, @NotNull Lifecycle$Event lifecycle$Event) {
        Object objB;
        nb.g.i(pVar, "source");
        nb.g.i(lifecycle$Event, "event");
        j jVar = Lifecycle$Event.Companion;
        Lifecycle$State lifecycle$State = this.$state;
        jVar.getClass();
        if (lifecycle$Event != j.c(lifecycle$State)) {
            if (lifecycle$Event == Lifecycle$Event.ON_DESTROY) {
                this.$this_suspendWithStateAtLeastUnchecked.b(this);
                this.$co.resumeWith(kotlin.a.b(new LifecycleDestroyedException()));
                return;
            }
            return;
        }
        this.$this_suspendWithStateAtLeastUnchecked.b(this);
        kotlinx.coroutines.g gVar = this.$co;
        try {
            objB = this.$block.invoke();
        } catch (Throwable th) {
            objB = kotlin.a.b(th);
        }
        gVar.resumeWith(objB);
    }
}
