package xyz.stream.utils.glide;

import android.content.Context;
import androidx.media3.common.C;
import androidx.recyclerview.widget.d;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.h;
import com.bumptech.glide.j;
import com.bumptech.glide.p;
import j5.n;
import java.io.File;
import java.net.Proxy;
import java.security.SecureRandom;
import java.util.Collections;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import o5.a;
import okhttp3.ConnectionPool;
import okhttp3.OkHttpClient;
import okhttp3.Protocol;
import q5.f;
import zf.b;

/* JADX INFO: loaded from: classes3.dex */
@GlideModule
public class UnsafeOkHttpGlideModule extends h implements a {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final long[] f36139a = {250, 1000, C.DEFAULT_MAX_SEEK_TO_PREVIOUS_POSITION_MS};

    public static void E(long j10) {
        if (j10 == 0) {
            return;
        }
        G(Math.abs(j10));
    }

    public static void F(File file, b bVar) {
        if (file == null || !file.exists()) {
            return;
        }
        if (!file.isFile()) {
            File[] fileArrListFiles = file.listFiles();
            if (fileArrListFiles == null) {
                return;
            }
            for (File file2 : fileArrListFiles) {
                F(file2, bVar);
            }
            return;
        }
        long length = file.length();
        String name = file.getName();
        bVar.f37192a += length;
        bVar.f37193b++;
        if ("journal".equals(name) || "journal.tmp".equals(name) || "journal.bkp".equals(name)) {
            bVar.f37196e += length;
            bVar.f37197f++;
        } else if (name.endsWith(".tmp")) {
            bVar.f37198g += length;
            bVar.f37199h++;
        } else if (name.endsWith(".0")) {
            bVar.f37194c += length;
            bVar.f37195d++;
        } else {
            bVar.f37200i += length;
            bVar.f37201j++;
        }
    }

    public static String G(long j10) {
        if (j10 <= 0) {
            return "0 B";
        }
        double d10 = j10 / 1024.0d;
        double d11 = d10 / 1024.0d;
        return d11 >= 1.0d ? String.format(Locale.US, "%.2f MB (%d B)", Double.valueOf(d11), Long.valueOf(j10)) : String.format(Locale.US, "%.2f KB (%d B)", Double.valueOf(d10), Long.valueOf(j10));
    }

    @Override // o5.a
    public final void a(Context context, j jVar) {
        jVar.getClass();
        jVar.f5576l = 6;
        long j10 = 10485760;
        G(j10);
        new File(context.getCacheDir(), "image_manager_disk_cache").getAbsolutePath();
        jVar.setDiskCache(new d(context, j10));
        f fVar = (f) new f().f();
        fVar.getClass();
        jVar.setDefaultRequestOptions((f) fVar.m(n.f28669i, Boolean.FALSE));
    }

    @Override // o5.a
    public final void b(Context context, p pVar) {
        context.getPackageName();
        try {
            zf.a aVar = new zf.a();
            SSLContext sSLContext = SSLContext.getInstance("TLS");
            sSLContext.init(null, new TrustManager[]{aVar}, new SecureRandom());
            SSLSocketFactory socketFactory = sSLContext.getSocketFactory();
            OkHttpClient.Builder builderProxy = new OkHttpClient.Builder().cache(null).proxy(Proxy.NO_PROXY);
            TimeUnit timeUnit = TimeUnit.SECONDS;
            pVar.j(new z4.b(builderProxy.callTimeout(100L, timeUnit).connectTimeout(100L, timeUnit).readTimeout(100L, timeUnit).writeTimeout(100L, timeUnit).sslSocketFactory(socketFactory, aVar).hostnameVerifier(new HostnameVerifier() { // from class: xf.b
                @Override // javax.net.ssl.HostnameVerifier
                public final boolean verify(String str, SSLSession sSLSession) {
                    return true;
                }
            }).connectionPool(new ConnectionPool(32, 5L, TimeUnit.MINUTES)).retryOnConnectionFailure(true).protocols(Collections.singletonList(Protocol.HTTP_1_1)).build()));
        } catch (Exception e10) {
            throw new RuntimeException(e10);
        }
    }
}
