package defpackage;

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 = 176)
@DebugMetadata(c = "kotlinx.coroutines.channels.ChannelsKt__Channels_commonKt", f = "Channels.common.kt", i = {0, 0}, l = {161}, m = "consumeEach", n = {"action", "$this$consume$iv"}, s = {"L$0", "L$1"})
final class cw0<E> extends ContinuationImpl {
    public sq3 a;
    public bv7 b;
    public lv0 c;
    public /* synthetic */ Object d;
    public int e;

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Object invokeSuspend(Object obj) {
        this.d = obj;
        int i = (this.e | Integer.MIN_VALUE) - Integer.MIN_VALUE;
        this.e = i;
        ck1 ck1Var = ck1.a;
        bv7 bv7Var = null;
        if (i == 0) {
            s38.b(obj);
            try {
                throw null;
            } catch (Throwable th) {
                th = th;
            }
        } else {
            if (i != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            lv0 lv0Var = this.c;
            bv7 bv7Var2 = this.b;
            sq3 sq3Var = this.a;
            try {
                s38.b(obj);
                while (((Boolean) obj).booleanValue()) {
                    sq3Var.invoke(lv0Var.next());
                    this.a = sq3Var;
                    this.b = bv7Var2;
                    this.c = lv0Var;
                    this.e = 1;
                    obj = lv0Var.b(this);
                    if (obj == ck1Var) {
                        return ck1Var;
                    }
                }
                bv7Var2.h(null);
                return e6a.a;
            } catch (Throwable th2) {
                th = th2;
                bv7Var = bv7Var2;
            }
        }
        try {
            throw th;
        } catch (Throwable th3) {
            yv0.a(bv7Var, th);
            throw th3;
        }
    }
}
