package O1;

import V4.C0781t;
import java.util.concurrent.atomic.AtomicInteger;
import m3.AbstractC2467b;
import w4.C3137A;

/* JADX INFO: loaded from: classes.dex */
public final class K extends C4.j implements J4.e {

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

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final /* synthetic */ O f5338c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ C4.j f5339d;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    /* JADX WARN: Multi-variable type inference failed */
    public K(O o6, J4.e eVar, A4.d dVar) {
        super(2, dVar);
        this.f5338c = o6;
        this.f5339d = (C4.j) eVar;
    }

    /* JADX WARN: Type inference failed for: r1v0, types: [C4.j, J4.e] */
    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        K k6 = new K(this.f5338c, this.f5339d, dVar);
        k6.f5337b = obj;
        return k6;
    }

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

    /* JADX WARN: Type inference failed for: r6v0, types: [C4.j, J4.e] */
    @Override // C4.a
    public final Object invokeSuspend(Object obj) throws Throwable {
        B4.a aVar = B4.a.f492a;
        int i6 = this.f5336a;
        if (i6 != 0) {
            if (i6 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            AbstractC2467b.l(obj);
            return obj;
        }
        AbstractC2467b.l(obj);
        V4.C c6 = (V4.C) this.f5337b;
        C0781t c0781tB = V4.E.b();
        O o6 = this.f5338c;
        Q q6 = new Q(this.f5339d, c0781tB, o6.f5360g.j(), c6.getCoroutineContext());
        C0.J j4 = o6.f5364k;
        Object objF = ((X4.e) j4.f535d).f(q6);
        if (objF instanceof X4.j) {
            X4.j jVar = objF instanceof X4.j ? (X4.j) objF : null;
            Throwable th = jVar != null ? jVar.f8684a : null;
            if (th == null) {
                throw new X4.p("Channel was closed normally");
            }
            throw th;
        }
        if (objF instanceof X4.k) {
            throw new IllegalStateException("Check failed.");
        }
        if (((AtomicInteger) ((C0.B) j4.f536e).f506b).getAndIncrement() == 0) {
            V4.E.y((V4.C) j4.f533b, null, null, new U(j4, null), 3);
        }
        this.f5336a = 1;
        Object objM = c0781tB.m(this);
        return objM == aVar ? aVar : objM;
    }
}
