package u3;

import B4.C0023t;
import B4.InterfaceC0027x;
import G4.q;
import a.AbstractC0212a;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import com.google.android.gms.internal.measurement.C1;
import d4.C0550i;
import e4.C0572p;
import e4.C0576t;
import i4.EnumC0643a;
import j4.AbstractC0806h;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import kotlin.jvm.functions.Function2;
import r4.AbstractC0983h;
import z4.g;

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

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

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public final /* synthetic */ Context f10386l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final /* synthetic */ E3.a f10387m;

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public b(Context context, E3.a aVar, int i, h4.c cVar) {
        super(2, cVar);
        this.f10386l = context;
        this.f10387m = aVar;
        this.f10388n = i;
    }

    @Override // j4.AbstractC0799a
    public final h4.c create(Object obj, h4.c cVar) {
        return new b(this.f10386l, this.f10387m, this.f10388n, cVar);
    }

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

    @Override // j4.AbstractC0799a
    public final Object invokeSuspend(Object obj) throws Throwable {
        Set setSingleton;
        EnumC0643a enumC0643a = EnumC0643a.f6670k;
        int i = this.f10385k;
        if (i == 0) {
            AbstractC0212a.H(obj);
            List<ApplicationInfo> installedApplications = this.f10386l.getPackageManager().getInstalledApplications(128);
            AbstractC0983h.d("getInstalledApplications(...)", installedApplications);
            C1070a c1070a = new C1070a(new g3.c(new w3.b(this.f10387m.f499a)), null);
            this.f10385k = 1;
            G3.b bVar = new G3.b(installedApplications, c1070a, null);
            q qVar = new q(this, getContext());
            obj = C1.B(qVar, qVar, bVar);
            if (obj == enumC0643a) {
                return enumC0643a;
            }
        } else {
            if (i != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            AbstractC0212a.H(obj);
        }
        List list = (List) obj;
        AbstractC0983h.e("<this>", list);
        z4.c cVar = new z4.c(new z4.d(new g(new z4.e(new z4.d(new C0572p(0, list), true, c.f10389k), d.f10390r, new C0023t(6)), e.f10391r, 1), false, new C0023t(7)));
        if (cVar.hasNext()) {
            Object next = cVar.next();
            if (cVar.hasNext()) {
                LinkedHashSet linkedHashSet = new LinkedHashSet();
                linkedHashSet.add(next);
                while (cVar.hasNext()) {
                    linkedHashSet.add(cVar.next());
                }
                setSingleton = linkedHashSet;
            } else {
                setSingleton = Collections.singleton(next);
                AbstractC0983h.d("singleton(...)", setSingleton);
            }
        } else {
            setSingleton = C0576t.f6261k;
        }
        boolean zIsEmpty = setSingleton.isEmpty();
        int i5 = this.f10388n;
        return zIsEmpty ? new C3.a(i5) : new C3.b(i5, new F3.g(setSingleton));
    }
}
