package com.google.android.gms.auth.api.signin;

import android.accounts.Account;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import b8.b;
import com.bumptech.glide.g;
import com.google.android.gms.common.annotation.KeepForSdk;
import com.google.android.gms.common.api.Scope;
import com.google.android.gms.common.api.c;
import com.google.android.gms.common.internal.ReflectedParcelable;
import com.google.android.gms.common.internal.safeparcel.SafeParcelable$Class;
import com.google.android.gms.common.internal.safeparcel.SafeParcelable$Constructor;
import com.google.android.gms.common.internal.safeparcel.SafeParcelable$Field;
import com.google.android.gms.common.internal.safeparcel.SafeParcelable$Param;
import f8.a;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import n7.c4;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
@SafeParcelable$Class(creator = "GoogleSignInOptionsCreator")
@Deprecated
public class GoogleSignInOptions extends a implements c, ReflectedParcelable {

    @NonNull
    public static final Parcelable.Creator<GoogleSignInOptions> CREATOR;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public static final Scope f8171h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public static final Scope f8172i;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final int f8173a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final ArrayList f8174b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final boolean f8175c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final boolean f8176d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final boolean f8177e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final ArrayList f8178f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final Map f8179g;

    @Nullable
    @SafeParcelable$Field(getter = "getAccount", id = 3)
    private Account zai;

    @Nullable
    @SafeParcelable$Field(getter = "getServerClientId", id = 7)
    private String zam;

    @Nullable
    @SafeParcelable$Field(getter = "getHostedDomain", id = 8)
    private String zan;

    @Nullable
    @SafeParcelable$Field(getter = "getLogSessionId", id = 10)
    private String zap;

    static {
        Scope scope = new Scope(1, "profile");
        new Scope(1, "email");
        Scope scope2 = new Scope(1, "openid");
        Scope scope3 = new Scope(1, "https://www.googleapis.com/auth/games_lite");
        f8171h = scope3;
        f8172i = new Scope(1, "https://www.googleapis.com/auth/games");
        a8.a aVar = new a8.a();
        aVar.f396a.add(scope2);
        aVar.f396a.add(scope);
        aVar.a();
        a8.a aVar2 = new a8.a();
        HashSet hashSet = aVar2.f396a;
        hashSet.add(scope3);
        hashSet.addAll(Arrays.asList(new Scope[0]));
        aVar2.a();
        CREATOR = new c4(15);
    }

    private GoogleSignInOptions(int i10, ArrayList arrayList, @Nullable Account account, boolean z10, boolean z11, boolean z12, @Nullable String str, @Nullable String str2, Map map, @Nullable String str3) {
        this.f8173a = i10;
        this.f8174b = arrayList;
        this.zai = account;
        this.f8175c = z10;
        this.f8176d = z11;
        this.f8177e = z12;
        this.zam = str;
        this.zan = str2;
        this.f8178f = new ArrayList(map.values());
        this.f8179g = map;
        this.zap = str3;
    }

    @Nullable
    public static GoogleSignInOptions zab(@Nullable String str) throws JSONException {
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        JSONObject jSONObject = new JSONObject(str);
        HashSet hashSet = new HashSet();
        JSONArray jSONArray = jSONObject.getJSONArray("scopes");
        int length = jSONArray.length();
        for (int i10 = 0; i10 < length; i10++) {
            hashSet.add(new Scope(1, jSONArray.getString(i10)));
        }
        String strOptString = jSONObject.has("accountName") ? jSONObject.optString("accountName") : null;
        return new GoogleSignInOptions(3, new ArrayList(hashSet), !TextUtils.isEmpty(strOptString) ? new Account(strOptString, "com.google") : null, jSONObject.getBoolean("idTokenRequested"), jSONObject.getBoolean("serverAuthRequested"), jSONObject.getBoolean("forceCodeForRefreshToken"), jSONObject.has("serverClientId") ? jSONObject.optString("serverClientId") : null, jSONObject.has("hostedDomain") ? jSONObject.optString("hostedDomain") : null, new HashMap(), (String) null);
    }

    private static Map zam(@Nullable List list) {
        HashMap map = new HashMap();
        if (list != null) {
            Iterator it = list.iterator();
            while (it.hasNext()) {
                b8.a aVar = (b8.a) it.next();
                map.put(Integer.valueOf(aVar.f4768b), aVar);
            }
        }
        return map;
    }

    /* JADX WARN: Removed duplicated region for block: B:24:0x0054 A[Catch: ClassCastException -> 0x008c, TryCatch #0 {ClassCastException -> 0x008c, blocks: (B:5:0x0006, B:7:0x0012, B:10:0x001c, B:12:0x002b, B:15:0x0037, B:17:0x003b, B:22:0x004c, B:24:0x0054, B:30:0x006c, B:32:0x0072, B:34:0x0078, B:36:0x007e, B:27:0x005f, B:20:0x0042), top: B:42:0x0006 }] */
    /* JADX WARN: Removed duplicated region for block: B:27:0x005f A[Catch: ClassCastException -> 0x008c, TryCatch #0 {ClassCastException -> 0x008c, blocks: (B:5:0x0006, B:7:0x0012, B:10:0x001c, B:12:0x002b, B:15:0x0037, B:17:0x003b, B:22:0x004c, B:24:0x0054, B:30:0x006c, B:32:0x0072, B:34:0x0078, B:36:0x007e, B:27:0x005f, B:20:0x0042), top: B:42:0x0006 }] */
    /* JADX WARN: Removed duplicated region for block: B:38:0x008a A[RETURN] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public boolean equals(@Nullable Object obj) {
        ArrayList arrayList = this.f8174b;
        if (obj == null) {
            return false;
        }
        try {
            GoogleSignInOptions googleSignInOptions = (GoogleSignInOptions) obj;
            ArrayList arrayList2 = googleSignInOptions.f8174b;
            if (this.f8178f.isEmpty() && googleSignInOptions.f8178f.isEmpty() && arrayList.size() == new ArrayList(arrayList2).size() && arrayList.containsAll(new ArrayList(arrayList2))) {
                Account account = this.zai;
                if (account == null) {
                    if (googleSignInOptions.getAccount() == null) {
                        if (TextUtils.isEmpty(this.zam)) {
                            if (this.zam.equals(googleSignInOptions.getServerClientId())) {
                                if (this.f8177e == googleSignInOptions.f8177e) {
                                    if (!TextUtils.equals(this.zap, googleSignInOptions.getLogSessionId())) {
                                    }
                                }
                            }
                        } else if (TextUtils.isEmpty(googleSignInOptions.getServerClientId())) {
                            if (this.f8177e == googleSignInOptions.f8177e && this.f8175c == googleSignInOptions.f8175c && this.f8176d == googleSignInOptions.f8176d) {
                                if (!TextUtils.equals(this.zap, googleSignInOptions.getLogSessionId())) {
                                    return true;
                                }
                            }
                        }
                    }
                } else if (account.equals(googleSignInOptions.getAccount())) {
                    if (TextUtils.isEmpty(this.zam)) {
                    }
                }
            }
        } catch (ClassCastException unused) {
        }
        return false;
    }

    @Nullable
    @KeepForSdk
    public Account getAccount() {
        return this.zai;
    }

    @Nullable
    @KeepForSdk
    public String getLogSessionId() {
        return this.zap;
    }

    @Nullable
    @KeepForSdk
    public String getServerClientId() {
        return this.zam;
    }

    public final int hashCode() {
        ArrayList arrayList = new ArrayList();
        ArrayList arrayList2 = this.f8174b;
        int size = arrayList2.size();
        for (int i10 = 0; i10 < size; i10++) {
            arrayList.add(((Scope) arrayList2.get(i10)).f8188b);
        }
        Collections.sort(arrayList);
        b bVar = new b();
        bVar.f4770a = 1;
        bVar.addObject(arrayList);
        bVar.addObject(this.zai);
        bVar.addObject(this.zam);
        bVar.f4770a = (((((bVar.f4770a * 31) + (this.f8177e ? 1 : 0)) * 31) + (this.f8175c ? 1 : 0)) * 31) + (this.f8176d ? 1 : 0);
        bVar.addObject(this.zap);
        return bVar.f4770a;
    }

    @Override // android.os.Parcelable
    public final void writeToParcel(Parcel parcel, int i10) {
        int I = g.I(20293, parcel);
        g.C(parcel, 1, 4);
        parcel.writeInt(this.f8173a);
        g.v(parcel, 2, new ArrayList(this.f8174b));
        g.q(parcel, 3, getAccount(), i10);
        g.C(parcel, 4, 4);
        parcel.writeInt(this.f8175c ? 1 : 0);
        g.C(parcel, 5, 4);
        parcel.writeInt(this.f8176d ? 1 : 0);
        g.C(parcel, 6, 4);
        parcel.writeInt(this.f8177e ? 1 : 0);
        g.r(parcel, 7, getServerClientId());
        g.r(parcel, 8, this.zan);
        g.v(parcel, 9, this.f8178f);
        g.r(parcel, 10, getLogSessionId());
        g.N(I, parcel);
    }

    public /* synthetic */ GoogleSignInOptions(ArrayList arrayList, Account account, String str, String str2, HashMap map, String str3) {
        this(3, arrayList, account, false, false, false, str, str2, (Map) map, str3);
    }

    @SafeParcelable$Constructor
    public GoogleSignInOptions(@SafeParcelable$Param(id = 1) int i10, @SafeParcelable$Param(id = 2) ArrayList arrayList, @Nullable @SafeParcelable$Param(id = 3) Account account, @SafeParcelable$Param(id = 4) boolean z10, @SafeParcelable$Param(id = 5) boolean z11, @SafeParcelable$Param(id = 6) boolean z12, @Nullable @SafeParcelable$Param(id = 7) String str, @Nullable @SafeParcelable$Param(id = 8) String str2, @SafeParcelable$Param(id = 9) ArrayList arrayList2, @Nullable @SafeParcelable$Param(id = 10) String str3) {
        this(i10, arrayList, account, z10, z11, z12, str, str2, zam(arrayList2), str3);
    }
}
