package com.google.android.gms.common.api.internal;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.AvailabilityException;
import com.google.android.gms.common.api.HasApiKey;
import java.util.Iterator;
import java.util.Set;
import o.C1554j9;
import o.C1839m9;
import o.Pc0;
import o.Qc0;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class zal {
    private int zad;
    private final C1839m9 zab = new C1839m9(0);
    private final Qc0 zac = new Qc0();
    private boolean zae = false;
    private final C1839m9 zaa = new C1839m9(0);

    public zal(Iterable iterable) {
        Iterator it = iterable.iterator();
        while (it.hasNext()) {
            this.zaa.put(((HasApiKey) it.next()).getApiKey(), null);
        }
        this.zad = ((C1554j9) this.zaa.keySet()).l.n;
    }

    public final Pc0 zaa() {
        return this.zac.a;
    }

    public final Set zab() {
        return this.zaa.keySet();
    }

    public final void zac(ApiKey apiKey, ConnectionResult connectionResult, String str) {
        this.zaa.put(apiKey, connectionResult);
        this.zab.put(apiKey, str);
        this.zad--;
        if (!connectionResult.isSuccess()) {
            this.zae = true;
        }
        if (this.zad == 0) {
            if (!this.zae) {
                this.zac.b(this.zab);
            } else {
                this.zac.a(new AvailabilityException(this.zaa));
            }
        }
    }
}
