package defpackage;

import androidx.media3.container.NalUnitUtil;
import java.util.NoSuchElementException;
import kotlin.Metadata;
import kotlin.coroutines.jvm.internal.ContinuationImpl;
import kotlin.coroutines.jvm.internal.DebugMetadata;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@DebugMetadata(c = "kotlinx.coroutines.channels.ChannelsKt__DeprecatedKt", f = "Deprecated.kt", i = {0, 0, 1, 1}, l = {166, 169}, m = "single", n = {"$this$consume$iv", "iterator", "$this$consume$iv", "single"}, s = {"L$0", "L$1", "L$0", "L$1"})
final class hx0<E> extends ContinuationImpl {
    public bv7 a;
    public Object b;
    public /* synthetic */ Object c;
    public int d;

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Object invokeSuspend(Object obj) {
        Object obj2;
        bv7 bv7Var;
        this.c = obj;
        int i = (this.d | Integer.MIN_VALUE) - Integer.MIN_VALUE;
        this.d = i;
        ck1 ck1Var = ck1.a;
        bv7 bv7Var2 = null;
        if (i != 0) {
            if (i == 1) {
                lv0 lv0Var = (lv0) this.b;
                bv7 bv7Var3 = this.a;
                try {
                    s38.b(obj);
                    if (!((Boolean) obj).booleanValue()) {
                        throw new NoSuchElementException("ReceiveChannel is empty.");
                    }
                    Object next = lv0Var.next();
                    this.a = bv7Var3;
                    this.b = next;
                    this.d = 2;
                    Object objB = lv0Var.b(this);
                    if (objB == ck1Var) {
                        return ck1Var;
                    }
                    obj2 = next;
                    obj = objB;
                    bv7Var = bv7Var3;
                } catch (Throwable th) {
                    th = th;
                    bv7Var2 = bv7Var3;
                }
            } else {
                if (i != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                obj2 = this.b;
                bv7Var = this.a;
                try {
                    s38.b(obj);
                } catch (Throwable th2) {
                    th = th2;
                    bv7Var2 = bv7Var;
                }
            }
            if (((Boolean) obj).booleanValue()) {
                throw new IllegalArgumentException("ReceiveChannel has more than one element.");
            }
            bv7Var.h(null);
            return obj2;
        }
        s38.b(obj);
        try {
            throw null;
        } catch (Throwable th3) {
            th = th3;
        }
        try {
            throw th;
        } catch (Throwable th4) {
            yv0.a(bv7Var2, th);
            throw th4;
        }
    }
}
