package okhttp3;

import io.netty.handler.ssl.SslUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import javax.net.ssl.SSLSocket;
import kotlin.Metadata;
import kotlin.collections.j;
import kotlin.comparisons.NaturalOrderComparator;
import kotlin.jvm.internal.o;
import okhttp3.CipherSuite;
import okhttp3.n0.c;

/* JADX INFO: renamed from: y.n, reason: from Kotlin metadata */
/* JADX INFO: loaded from: classes2.dex */
@Metadata(d1 = {"\u0000F\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\u0011\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010\b\n\u0002\b\t\u0018\u0000 $2\u00020\u0001:\u0002#$B7\b\u0000\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0003\u0012\u000e\u0010\u0005\u001a\n\u0012\u0004\u0012\u00020\u0007\u0018\u00010\u0006\u0012\u000e\u0010\b\u001a\n\u0012\u0004\u0012\u00020\u0007\u0018\u00010\u0006¢\u0006\u0002\u0010\tJ\u001d\u0010\u0012\u001a\u00020\u00132\u0006\u0010\u0014\u001a\u00020\u00152\u0006\u0010\u0016\u001a\u00020\u0003H\u0000¢\u0006\u0002\b\u0017J\u0015\u0010\n\u001a\n\u0012\u0004\u0012\u00020\f\u0018\u00010\u000bH\u0007¢\u0006\u0002\b\u0018J\u0013\u0010\u0019\u001a\u00020\u00032\b\u0010\u001a\u001a\u0004\u0018\u00010\u0001H\u0096\u0002J\b\u0010\u001b\u001a\u00020\u001cH\u0016J\u000e\u0010\u001d\u001a\u00020\u00032\u0006\u0010\u001e\u001a\u00020\u0015J\u0018\u0010\u001f\u001a\u00020\u00002\u0006\u0010\u0014\u001a\u00020\u00152\u0006\u0010\u0016\u001a\u00020\u0003H\u0002J\r\u0010\u0004\u001a\u00020\u0003H\u0007¢\u0006\u0002\b J\u0015\u0010\u0010\u001a\n\u0012\u0004\u0012\u00020\u0011\u0018\u00010\u000bH\u0007¢\u0006\u0002\b!J\b\u0010\"\u001a\u00020\u0007H\u0016R\u0019\u0010\n\u001a\n\u0012\u0004\u0012\u00020\f\u0018\u00010\u000b8G¢\u0006\u0006\u001a\u0004\b\n\u0010\rR\u0018\u0010\u0005\u001a\n\u0012\u0004\u0012\u00020\u0007\u0018\u00010\u0006X\u0082\u0004¢\u0006\u0004\n\u0002\u0010\u000eR\u0013\u0010\u0002\u001a\u00020\u00038\u0007¢\u0006\b\n\u0000\u001a\u0004\b\u0002\u0010\u000fR\u0013\u0010\u0004\u001a\u00020\u00038\u0007¢\u0006\b\n\u0000\u001a\u0004\b\u0004\u0010\u000fR\u0019\u0010\u0010\u001a\n\u0012\u0004\u0012\u00020\u0011\u0018\u00010\u000b8G¢\u0006\u0006\u001a\u0004\b\u0010\u0010\rR\u0018\u0010\b\u001a\n\u0012\u0004\u0012\u00020\u0007\u0018\u00010\u0006X\u0082\u0004¢\u0006\u0004\n\u0002\u0010\u000e¨\u0006%"}, d2 = {"Lokhttp3/ConnectionSpec;", "", "isTls", "", "supportsTlsExtensions", "cipherSuitesAsString", "", "", "tlsVersionsAsString", "(ZZ[Ljava/lang/String;[Ljava/lang/String;)V", "cipherSuites", "", "Lokhttp3/CipherSuite;", "()Ljava/util/List;", "[Ljava/lang/String;", "()Z", "tlsVersions", "Lokhttp3/TlsVersion;", "apply", "", "sslSocket", "Ljavax/net/ssl/SSLSocket;", "isFallback", "apply$okhttp", "-deprecated_cipherSuites", "equals", "other", "hashCode", "", "isCompatible", "socket", "supportedSpec", "-deprecated_supportsTlsExtensions", "-deprecated_tlsVersions", "toString", "Builder", "Companion", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
public final class ConnectionSpec {
    public static final CipherSuite[] a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final CipherSuite[] f9700b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final ConnectionSpec f9701c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final ConnectionSpec f9702d;

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

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final String[] f9705g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final String[] f9706h;

    /* JADX INFO: renamed from: y.n$a */
    @Metadata(d1 = {"\u00004\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0011\n\u0002\u0010\u000e\n\u0002\b\u0012\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\u0018\u00002\u00020\u0001B\u000f\b\u0010\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004B\u000f\b\u0016\u0012\u0006\u0010\u0005\u001a\u00020\u0006¢\u0006\u0002\u0010\u0007J\u0006\u0010\u0019\u001a\u00020\u0000J\u0006\u0010\u001a\u001a\u00020\u0000J\u0006\u0010\u001b\u001a\u00020\u0006J\u001f\u0010\b\u001a\u00020\u00002\u0012\u0010\b\u001a\n\u0012\u0006\b\u0001\u0012\u00020\n0\t\"\u00020\n¢\u0006\u0002\u0010\u001cJ\u001f\u0010\b\u001a\u00020\u00002\u0012\u0010\b\u001a\n\u0012\u0006\b\u0001\u0012\u00020\u001d0\t\"\u00020\u001d¢\u0006\u0002\u0010\u001eJ\u0010\u0010\u0010\u001a\u00020\u00002\u0006\u0010\u0010\u001a\u00020\u0003H\u0007J\u001f\u0010\u0016\u001a\u00020\u00002\u0012\u0010\u0016\u001a\n\u0012\u0006\b\u0001\u0012\u00020\n0\t\"\u00020\n¢\u0006\u0002\u0010\u001cJ\u001f\u0010\u0016\u001a\u00020\u00002\u0012\u0010\u0016\u001a\n\u0012\u0006\b\u0001\u0012\u00020\u001f0\t\"\u00020\u001f¢\u0006\u0002\u0010 R$\u0010\b\u001a\n\u0012\u0004\u0012\u00020\n\u0018\u00010\tX\u0080\u000e¢\u0006\u0010\n\u0002\u0010\u000f\u001a\u0004\b\u000b\u0010\f\"\u0004\b\r\u0010\u000eR\u001a\u0010\u0010\u001a\u00020\u0003X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0011\u0010\u0012\"\u0004\b\u0013\u0010\u0004R\u001a\u0010\u0002\u001a\u00020\u0003X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0014\u0010\u0012\"\u0004\b\u0015\u0010\u0004R$\u0010\u0016\u001a\n\u0012\u0004\u0012\u00020\n\u0018\u00010\tX\u0080\u000e¢\u0006\u0010\n\u0002\u0010\u000f\u001a\u0004\b\u0017\u0010\f\"\u0004\b\u0018\u0010\u000e¨\u0006!"}, d2 = {"Lokhttp3/ConnectionSpec$Builder;", "", "tls", "", "(Z)V", "connectionSpec", "Lokhttp3/ConnectionSpec;", "(Lokhttp3/ConnectionSpec;)V", "cipherSuites", "", "", "getCipherSuites$okhttp", "()[Ljava/lang/String;", "setCipherSuites$okhttp", "([Ljava/lang/String;)V", "[Ljava/lang/String;", "supportsTlsExtensions", "getSupportsTlsExtensions$okhttp", "()Z", "setSupportsTlsExtensions$okhttp", "getTls$okhttp", "setTls$okhttp", "tlsVersions", "getTlsVersions$okhttp", "setTlsVersions$okhttp", "allEnabledCipherSuites", "allEnabledTlsVersions", "build", "([Ljava/lang/String;)Lokhttp3/ConnectionSpec$Builder;", "Lokhttp3/CipherSuite;", "([Lokhttp3/CipherSuite;)Lokhttp3/ConnectionSpec$Builder;", "Lokhttp3/TlsVersion;", "([Lokhttp3/TlsVersion;)Lokhttp3/ConnectionSpec$Builder;", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
    public static final class a {
        public boolean a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public String[] f9707b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public String[] f9708c;

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

        public a(ConnectionSpec connectionSpec) {
            o.f(connectionSpec, "connectionSpec");
            this.a = connectionSpec.f9703e;
            this.f9707b = connectionSpec.f9705g;
            this.f9708c = connectionSpec.f9706h;
            this.f9709d = connectionSpec.f9704f;
        }

        public a(boolean z2) {
            this.a = z2;
        }

        public final ConnectionSpec a() {
            return new ConnectionSpec(this.a, this.f9709d, this.f9707b, this.f9708c);
        }

        public final a b(String... strArr) {
            o.f(strArr, "cipherSuites");
            if (!this.a) {
                throw new IllegalArgumentException("no cipher suites for cleartext connections".toString());
            }
            if (!(!(strArr.length == 0))) {
                throw new IllegalArgumentException("At least one cipher suite is required".toString());
            }
            this.f9707b = (String[]) strArr.clone();
            return this;
        }

        public final a c(CipherSuite... cipherSuiteArr) {
            o.f(cipherSuiteArr, "cipherSuites");
            if (!this.a) {
                throw new IllegalArgumentException("no cipher suites for cleartext connections".toString());
            }
            ArrayList arrayList = new ArrayList(cipherSuiteArr.length);
            for (CipherSuite cipherSuite : cipherSuiteArr) {
                arrayList.add(cipherSuite.f9688t);
            }
            Object[] array = arrayList.toArray(new String[0]);
            Objects.requireNonNull(array, "null cannot be cast to non-null type kotlin.Array<T of kotlin.collections.ArraysKt__ArraysJVMKt.toTypedArray>");
            String[] strArr = (String[]) array;
            b((String[]) Arrays.copyOf(strArr, strArr.length));
            return this;
        }

        public final a d(boolean z2) {
            if (!this.a) {
                throw new IllegalArgumentException("no TLS extensions for cleartext connections".toString());
            }
            this.f9709d = z2;
            return this;
        }

        public final a e(String... strArr) {
            o.f(strArr, "tlsVersions");
            if (!this.a) {
                throw new IllegalArgumentException("no TLS versions for cleartext connections".toString());
            }
            if (!(!(strArr.length == 0))) {
                throw new IllegalArgumentException("At least one TLS version is required".toString());
            }
            this.f9708c = (String[]) strArr.clone();
            return this;
        }

        public final a f(TlsVersion... tlsVersionArr) {
            o.f(tlsVersionArr, "tlsVersions");
            if (!this.a) {
                throw new IllegalArgumentException("no TLS versions for cleartext connections".toString());
            }
            ArrayList arrayList = new ArrayList(tlsVersionArr.length);
            for (TlsVersion tlsVersion : tlsVersionArr) {
                arrayList.add(tlsVersion.f9699s);
            }
            Object[] array = arrayList.toArray(new String[0]);
            Objects.requireNonNull(array, "null cannot be cast to non-null type kotlin.Array<T of kotlin.collections.ArraysKt__ArraysJVMKt.toTypedArray>");
            String[] strArr = (String[]) array;
            e((String[]) Arrays.copyOf(strArr, strArr.length));
            return this;
        }
    }

    static {
        CipherSuite cipherSuite = CipherSuite.f9685q;
        CipherSuite cipherSuite2 = CipherSuite.f9686r;
        CipherSuite cipherSuite3 = CipherSuite.f9687s;
        CipherSuite cipherSuite4 = CipherSuite.f9679k;
        CipherSuite cipherSuite5 = CipherSuite.f9681m;
        CipherSuite cipherSuite6 = CipherSuite.f9680l;
        CipherSuite cipherSuite7 = CipherSuite.f9682n;
        CipherSuite cipherSuite8 = CipherSuite.f9684p;
        CipherSuite cipherSuite9 = CipherSuite.f9683o;
        CipherSuite[] cipherSuiteArr = {cipherSuite, cipherSuite2, cipherSuite3, cipherSuite4, cipherSuite5, cipherSuite6, cipherSuite7, cipherSuite8, cipherSuite9};
        a = cipherSuiteArr;
        CipherSuite[] cipherSuiteArr2 = {cipherSuite, cipherSuite2, cipherSuite3, cipherSuite4, cipherSuite5, cipherSuite6, cipherSuite7, cipherSuite8, cipherSuite9, CipherSuite.f9677i, CipherSuite.f9678j, CipherSuite.f9675g, CipherSuite.f9676h, CipherSuite.f9673e, CipherSuite.f9674f, CipherSuite.f9672d};
        f9700b = cipherSuiteArr2;
        a aVar = new a(true);
        aVar.c((CipherSuite[]) Arrays.copyOf(cipherSuiteArr, cipherSuiteArr.length));
        TlsVersion tlsVersion = TlsVersion.TLS_1_3;
        TlsVersion tlsVersion2 = TlsVersion.TLS_1_2;
        aVar.f(tlsVersion, tlsVersion2);
        aVar.d(true);
        aVar.a();
        a aVar2 = new a(true);
        aVar2.c((CipherSuite[]) Arrays.copyOf(cipherSuiteArr2, cipherSuiteArr2.length));
        aVar2.f(tlsVersion, tlsVersion2);
        aVar2.d(true);
        f9701c = aVar2.a();
        a aVar3 = new a(true);
        aVar3.c((CipherSuite[]) Arrays.copyOf(cipherSuiteArr2, cipherSuiteArr2.length));
        aVar3.f(tlsVersion, tlsVersion2, TlsVersion.TLS_1_1, TlsVersion.TLS_1_0);
        aVar3.d(true);
        aVar3.a();
        f9702d = new ConnectionSpec(false, false, null, null);
    }

    public ConnectionSpec(boolean z2, boolean z3, String[] strArr, String[] strArr2) {
        this.f9703e = z2;
        this.f9704f = z3;
        this.f9705g = strArr;
        this.f9706h = strArr2;
    }

    public final List<CipherSuite> a() {
        String[] strArr = this.f9705g;
        if (strArr == null) {
            return null;
        }
        ArrayList arrayList = new ArrayList(strArr.length);
        for (String str : strArr) {
            arrayList.add(CipherSuite.a.b(str));
        }
        return j.i0(arrayList);
    }

    public final boolean b(SSLSocket sSLSocket) {
        o.f(sSLSocket, "socket");
        if (!this.f9703e) {
            return false;
        }
        String[] strArr = this.f9706h;
        if (strArr != null) {
            String[] enabledProtocols = sSLSocket.getEnabledProtocols();
            NaturalOrderComparator naturalOrderComparator = NaturalOrderComparator.f6125f;
            o.d(naturalOrderComparator, "null cannot be cast to non-null type java.util.Comparator<T of kotlin.comparisons.ComparisonsKt__ComparisonsKt.naturalOrder>{ kotlin.TypeAliasesKt.Comparator<T of kotlin.comparisons.ComparisonsKt__ComparisonsKt.naturalOrder> }");
            if (!c.k(strArr, enabledProtocols, naturalOrderComparator)) {
                return false;
            }
        }
        String[] strArr2 = this.f9705g;
        if (strArr2 == null) {
            return true;
        }
        String[] enabledCipherSuites = sSLSocket.getEnabledCipherSuites();
        CipherSuite.b bVar = CipherSuite.a;
        CipherSuite.b bVar2 = CipherSuite.a;
        return c.k(strArr2, enabledCipherSuites, CipherSuite.f9670b);
    }

    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    public final List<TlsVersion> c() {
        TlsVersion tlsVersion;
        String[] strArr = this.f9706h;
        if (strArr == null) {
            return null;
        }
        ArrayList arrayList = new ArrayList(strArr.length);
        for (String str : strArr) {
            o.f(str, "javaName");
            int iHashCode = str.hashCode();
            if (iHashCode == 79201641) {
                if (!str.equals(SslUtils.PROTOCOL_SSL_V3)) {
                    throw new IllegalArgumentException(o.l("Unexpected TLS version: ", str));
                }
                tlsVersion = TlsVersion.SSL_3_0;
                arrayList.add(tlsVersion);
            } else if (iHashCode != 79923350) {
                switch (iHashCode) {
                    case -503070503:
                        if (!str.equals(SslUtils.PROTOCOL_TLS_V1_1)) {
                            throw new IllegalArgumentException(o.l("Unexpected TLS version: ", str));
                        }
                        tlsVersion = TlsVersion.TLS_1_1;
                        arrayList.add(tlsVersion);
                        break;
                        break;
                    case -503070502:
                        if (!str.equals(SslUtils.PROTOCOL_TLS_V1_2)) {
                            throw new IllegalArgumentException(o.l("Unexpected TLS version: ", str));
                        }
                        tlsVersion = TlsVersion.TLS_1_2;
                        arrayList.add(tlsVersion);
                        break;
                        break;
                    case -503070501:
                        if (!str.equals("TLSv1.3")) {
                            throw new IllegalArgumentException(o.l("Unexpected TLS version: ", str));
                        }
                        tlsVersion = TlsVersion.TLS_1_3;
                        arrayList.add(tlsVersion);
                        break;
                        break;
                    default:
                        throw new IllegalArgumentException(o.l("Unexpected TLS version: ", str));
                }
            } else {
                if (!str.equals(SslUtils.PROTOCOL_TLS_V1)) {
                    throw new IllegalArgumentException(o.l("Unexpected TLS version: ", str));
                }
                tlsVersion = TlsVersion.TLS_1_0;
                arrayList.add(tlsVersion);
            }
        }
        return j.i0(arrayList);
    }

    public boolean equals(Object other) {
        if (!(other instanceof ConnectionSpec)) {
            return false;
        }
        if (other == this) {
            return true;
        }
        boolean z2 = this.f9703e;
        ConnectionSpec connectionSpec = (ConnectionSpec) other;
        if (z2 != connectionSpec.f9703e) {
            return false;
        }
        return !z2 || (Arrays.equals(this.f9705g, connectionSpec.f9705g) && Arrays.equals(this.f9706h, connectionSpec.f9706h) && this.f9704f == connectionSpec.f9704f);
    }

    public int hashCode() {
        if (!this.f9703e) {
            return 17;
        }
        String[] strArr = this.f9705g;
        int iHashCode = (527 + (strArr == null ? 0 : Arrays.hashCode(strArr))) * 31;
        String[] strArr2 = this.f9706h;
        return ((iHashCode + (strArr2 != null ? Arrays.hashCode(strArr2) : 0)) * 31) + (!this.f9704f ? 1 : 0);
    }

    public String toString() {
        if (!this.f9703e) {
            return "ConnectionSpec()";
        }
        StringBuilder sbF = g.a.a.a.a.F("ConnectionSpec(cipherSuites=");
        sbF.append((Object) Objects.toString(a(), "[all enabled]"));
        sbF.append(", tlsVersions=");
        sbF.append((Object) Objects.toString(c(), "[all enabled]"));
        sbF.append(", supportsTlsExtensions=");
        return g.a.a.a.a.C(sbF, this.f9704f, ')');
    }
}
