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

import android.accounts.Account;
import android.content.Context;
import android.view.View;
import com.google.android.gms.common.annotation.KeepForSdk;
import com.google.android.gms.common.api.Api;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.Scope;
import com.google.android.gms.signin.SignInOptions;
import defpackage.gt;
import defpackage.hs0;
import defpackage.nq6;
import defpackage.rq6;
import defpackage.vo6;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/* JADX INFO: loaded from: classes2.dex */
@KeepForSdk
public final class ClientSettings {

    @nq6
    private final Account zaa;
    private final Set zab;
    private final Set zac;
    private final Map zad;
    private final int zae;

    @nq6
    private final View zaf;
    private final String zag;
    private final String zah;
    private final SignInOptions zai;
    private Integer zaj;

    @KeepForSdk
    public static final class Builder {

        @nq6
        private Account zaa;
        private gt zab;
        private String zac;
        private String zad;
        private final SignInOptions zae = SignInOptions.zaa;

        @vo6
        @KeepForSdk
        public ClientSettings build() {
            return new ClientSettings(this.zaa, this.zab, null, 0, null, this.zac, this.zad, this.zae, false);
        }

        @vo6
        @hs0
        @KeepForSdk
        public Builder setRealClientPackageName(@vo6 String str) {
            this.zac = str;
            return this;
        }

        @vo6
        @hs0
        public final Builder zaa(@vo6 Collection collection) {
            if (this.zab == null) {
                this.zab = new gt(0);
            }
            this.zab.addAll(collection);
            return this;
        }

        @vo6
        @hs0
        public final Builder zab(@nq6 Account account) {
            this.zaa = account;
            return this;
        }

        @vo6
        @hs0
        public final Builder zac(@vo6 String str) {
            this.zad = str;
            return this;
        }
    }

    @KeepForSdk
    public ClientSettings(@vo6 Account account, @vo6 Set<Scope> set, @vo6 Map<Api<?>, zab> map, int i, @nq6 View view, @vo6 String str, @vo6 String str2, @nq6 SignInOptions signInOptions) {
        this(account, set, map, i, view, str, str2, signInOptions, false);
    }

    @vo6
    @KeepForSdk
    public static ClientSettings createDefault(@vo6 Context context) {
        return new GoogleApiClient.Builder(context).zaa();
    }

    @rq6
    @KeepForSdk
    public Account getAccount() {
        return this.zaa;
    }

    @rq6
    @KeepForSdk
    @Deprecated
    public String getAccountName() {
        Account account = this.zaa;
        if (account != null) {
            return account.name;
        }
        return null;
    }

    @vo6
    @KeepForSdk
    public Account getAccountOrDefault() {
        Account account = this.zaa;
        return account != null ? account : new Account("<<default account>>", "com.google");
    }

    @vo6
    @KeepForSdk
    public Set<Scope> getAllRequestedScopes() {
        return this.zac;
    }

    @vo6
    @KeepForSdk
    public Set<Scope> getApplicableScopes(@vo6 Api<?> api) {
        zab zabVar = (zab) this.zad.get(api);
        if (zabVar == null || zabVar.zaa.isEmpty()) {
            return this.zab;
        }
        HashSet hashSet = new HashSet(this.zab);
        hashSet.addAll(zabVar.zaa);
        return hashSet;
    }

    @KeepForSdk
    public int getGravityForPopups() {
        return this.zae;
    }

    @vo6
    @KeepForSdk
    public String getRealClientPackageName() {
        return this.zag;
    }

    @vo6
    @KeepForSdk
    public Set<Scope> getRequiredScopes() {
        return this.zab;
    }

    @rq6
    @KeepForSdk
    public View getViewForPopups() {
        return this.zaf;
    }

    @vo6
    public final SignInOptions zaa() {
        return this.zai;
    }

    @rq6
    public final Integer zab() {
        return this.zaj;
    }

    @rq6
    public final String zac() {
        return this.zah;
    }

    @vo6
    public final Map zad() {
        return this.zad;
    }

    public final void zae(@vo6 Integer num) {
        this.zaj = num;
    }

    public ClientSettings(@nq6 Account account, @vo6 Set set, @vo6 Map map, int i, @nq6 View view, @vo6 String str, @vo6 String str2, @nq6 SignInOptions signInOptions, boolean z) {
        this.zaa = account;
        Set setUnmodifiableSet = set == null ? Collections.EMPTY_SET : Collections.unmodifiableSet(set);
        this.zab = setUnmodifiableSet;
        map = map == null ? Collections.EMPTY_MAP : map;
        this.zad = map;
        this.zaf = view;
        this.zae = i;
        this.zag = str;
        this.zah = str2;
        this.zai = signInOptions == null ? SignInOptions.zaa : signInOptions;
        HashSet hashSet = new HashSet(setUnmodifiableSet);
        Iterator it = map.values().iterator();
        while (it.hasNext()) {
            hashSet.addAll(((zab) it.next()).zaa);
        }
        this.zac = Collections.unmodifiableSet(hashSet);
    }
}
