package androidx.privacysandbox.ads.adservices.java.internal;

import androidx.concurrent.futures.h;
import androidx.concurrent.futures.k;
import java.util.concurrent.CancellationException;
import kd.e;
import kotlinx.coroutines.b0;
import kotlinx.coroutines.c0;
import kotlinx.coroutines.g1;
import kotlinx.coroutines.y;
import nb.g;
import sd.l;

/* JADX INFO: loaded from: classes.dex */
public abstract class a {
    /* JADX WARN: Multi-variable type inference failed */
    public static void a(final b0 b0Var, Object obj, final h hVar) {
        g.i(b0Var, "$this_asListenableFuture");
        g.i(hVar, "completer");
        ((g1) b0Var).L(false, true, new l() { // from class: androidx.privacysandbox.ads.adservices.java.internal.CoroutineAdapterKt$asListenableFuture$1$1
            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            {
                super(1);
            }

            @Override // sd.l
            public final Object invoke(Object obj2) {
                Throwable th = (Throwable) obj2;
                if (th == null) {
                    hVar.a(b0Var.g());
                } else if (th instanceof CancellationException) {
                    h hVar2 = hVar;
                    hVar2.f994d = true;
                    k kVar = hVar2.f992b;
                    if (kVar != null && kVar.f997b.cancel(true)) {
                        hVar2.f991a = null;
                        hVar2.f992b = null;
                        hVar2.f993c = null;
                    }
                } else {
                    hVar.b(th);
                }
                return e.f29109a;
            }
        });
    }

    public static k b(c0 c0Var) {
        return y.y(new androidx.media3.exoplayer.analytics.g(c0Var, "Deferred.asListenableFuture", 11));
    }
}
