package W;

import B4.C0020p;
import B4.InterfaceC0027x;
import a.AbstractC0212a;
import d4.C0550i;
import i4.EnumC0643a;
import j4.AbstractC0806h;
import java.util.concurrent.atomic.AtomicInteger;
import kotlin.jvm.functions.Function2;

/* JADX INFO: loaded from: classes.dex */
public final class K extends AbstractC0806h implements Function2 {

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

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

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

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final /* synthetic */ AbstractC0806h f3053n;

    /* 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 o5, Function2 function2, h4.c cVar) {
        super(2, cVar);
        this.f3052m = o5;
        this.f3053n = (AbstractC0806h) function2;
    }

    /* JADX WARN: Type inference failed for: r1v0, types: [j4.h, kotlin.jvm.functions.Function2] */
    @Override // j4.AbstractC0799a
    public final h4.c create(Object obj, h4.c cVar) {
        K k5 = new K(this.f3052m, this.f3053n, cVar);
        k5.f3051l = obj;
        return k5;
    }

    @Override // kotlin.jvm.functions.Function2
    public final Object invoke(Object obj, Object obj2) {
        return ((K) create((InterfaceC0027x) obj, (h4.c) obj2)).invokeSuspend(C0550i.f6143a);
    }

    /* JADX WARN: Type inference failed for: r7v0, types: [j4.h, kotlin.jvm.functions.Function2] */
    @Override // j4.AbstractC0799a
    public final Object invokeSuspend(Object obj) throws Throwable {
        EnumC0643a enumC0643a = EnumC0643a.f6670k;
        int i = this.f3050k;
        if (i != 0) {
            if (i != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            AbstractC0212a.H(obj);
            return obj;
        }
        AbstractC0212a.H(obj);
        InterfaceC0027x interfaceC0027x = (InterfaceC0027x) this.f3051l;
        C0020p c0020p = new C0020p(true);
        c0020p.F(null);
        O o5 = this.f3052m;
        m0 m0VarE = o5.f3073h.E();
        if (m0VarE instanceof C0190d) {
            m0VarE = new d0(((C0190d) m0VarE).f3172a);
        }
        c0 c0Var = new c0(this.f3053n, c0020p, m0VarE, interfaceC0027x.c());
        com.google.firebase.messaging.w wVar = o5.f3076l;
        Object objD = ((D4.c) wVar.f5945m).d(c0Var);
        if (objD instanceof D4.h) {
            D4.h hVar = objD != null ? (D4.h) objD : null;
            Throwable th = hVar != null ? hVar.f480a : null;
            if (th == null) {
                throw new D4.m("Channel was closed normally");
            }
            throw th;
        }
        if (objD instanceof D4.i) {
            throw new IllegalStateException("Check failed.");
        }
        if (((AtomicInteger) ((S.g) wVar.f5946n).f2797k).getAndIncrement() == 0) {
            B4.A.h((InterfaceC0027x) wVar.f5943k, null, new h0(wVar, null), 3);
        }
        this.f3050k = 1;
        Object objP = c0020p.p(this);
        return objP == enumC0643a ? enumC0643a : objP;
    }
}
