package com.bumptech.glide;

import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.gms.measurement.internal.a0;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/* JADX INFO: loaded from: classes.dex */
public final class j {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public com.bumptech.glide.load.engine.q f5567c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public c5.e f5568d;

    @Nullable
    private List<q5.e> defaultRequestListeners;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public c5.b f5569e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public d5.h f5570f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public e5.d f5571g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public e5.d f5572h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public d5.a f5573i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public d5.j f5574j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public n5.d f5575k;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public e5.d f5578n;

    @Nullable
    private n5.k requestManagerFactory;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final androidx.collection.f f5565a = new androidx.collection.f(0);

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final androidx.media3.extractor.p f5566b = new androidx.media3.extractor.p(1);

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public int f5576l = 4;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public b f5577m = new d();

    public final c a(Context context) {
        if (this.f5571g == null) {
            int i10 = e5.d.f25484c;
            e5.a aVar = new e5.a(false);
            if (e5.d.f25484c == 0) {
                e5.d.f25484c = Math.min(4, Runtime.getRuntime().availableProcessors());
            }
            int i11 = e5.d.f25484c;
            aVar.f25473d = i11;
            aVar.f25474e = i11;
            aVar.f25471b = "source";
            this.f5571g = aVar.e();
        }
        if (this.f5572h == null) {
            int i12 = e5.d.f25484c;
            e5.a aVar2 = new e5.a(true);
            aVar2.f25473d = 1;
            aVar2.f25474e = 1;
            aVar2.f25471b = "disk-cache";
            this.f5572h = aVar2.e();
        }
        if (this.f5578n == null) {
            if (e5.d.f25484c == 0) {
                e5.d.f25484c = Math.min(4, Runtime.getRuntime().availableProcessors());
            }
            int i13 = e5.d.f25484c >= 4 ? 2 : 1;
            e5.a aVar3 = new e5.a(true);
            aVar3.f25473d = i13;
            aVar3.f25474e = i13;
            aVar3.f25471b = "animation";
            this.f5578n = aVar3.e();
        }
        if (this.f5574j == null) {
            this.f5574j = new d5.j(new d5.i(context));
        }
        if (this.f5575k == null) {
            this.f5575k = new a0(17);
        }
        if (this.f5568d == null) {
            int i14 = this.f5574j.f24994a;
            if (i14 > 0) {
                this.f5568d = new c5.l(i14);
            } else {
                this.f5568d = new c5.f();
            }
        }
        if (this.f5569e == null) {
            this.f5569e = new c5.k(this.f5574j.f24997d);
        }
        if (this.f5570f == null) {
            this.f5570f = new d5.f(this.f5574j.f24995b);
        }
        if (this.f5573i == null) {
            this.f5573i = new d5.e(context);
        }
        if (this.f5567c == null) {
            this.f5567c = new com.bumptech.glide.load.engine.q(this.f5570f, this.f5573i, this.f5572h, this.f5571g, new e5.d(new ThreadPoolExecutor(0, Integer.MAX_VALUE, e5.d.f25483b, TimeUnit.MILLISECONDS, new SynchronousQueue(), new e5.b(new com.bumptech.glide.load.engine.a(), "source-unlimited", e5.c.E, false))), this.f5578n);
        }
        List<q5.e> list = this.defaultRequestListeners;
        if (list == null) {
            this.defaultRequestListeners = Collections.emptyList();
        } else {
            this.defaultRequestListeners = Collections.unmodifiableList(list);
        }
        androidx.media3.extractor.p pVar = this.f5566b;
        pVar.getClass();
        m mVar = new m(pVar);
        return new c(context, this.f5567c, this.f5570f, this.f5568d, this.f5569e, new n5.l(this.requestManagerFactory, mVar), this.f5575k, this.f5576l, this.f5577m, this.f5565a, this.defaultRequestListeners, mVar);
    }

    @NonNull
    public j setAnimationExecutor(@Nullable e5.d dVar) {
        this.f5578n = dVar;
        return this;
    }

    @NonNull
    public j setArrayPool(@Nullable c5.b bVar) {
        this.f5569e = bVar;
        return this;
    }

    @NonNull
    public j setBitmapPool(@Nullable c5.e eVar) {
        this.f5568d = eVar;
        return this;
    }

    @NonNull
    public j setConnectivityMonitorFactory(@Nullable n5.d dVar) {
        this.f5575k = dVar;
        return this;
    }

    @NonNull
    public j setDefaultRequestOptions(@Nullable q5.f fVar) {
        this.f5577m = (b) t5.n.checkNotNull(new e(fVar));
        return this;
    }

    @NonNull
    public <T> j setDefaultTransitionOptions(@NonNull Class<T> cls, @Nullable v vVar) {
        this.f5565a.put(cls, vVar);
        return this;
    }

    @NonNull
    public j setDiskCache(@Nullable d5.a aVar) {
        this.f5573i = aVar;
        return this;
    }

    @NonNull
    public j setDiskCacheExecutor(@Nullable e5.d dVar) {
        this.f5572h = dVar;
        return this;
    }

    @NonNull
    public j setMemoryCache(@Nullable d5.h hVar) {
        this.f5570f = hVar;
        return this;
    }

    @NonNull
    public j setMemorySizeCalculator(@Nullable d5.j jVar) {
        this.f5574j = jVar;
        return this;
    }

    public void setRequestManagerFactory(@Nullable n5.k kVar) {
        this.requestManagerFactory = kVar;
    }

    @Deprecated
    public j setResizeExecutor(@Nullable e5.d dVar) {
        return setSourceExecutor(dVar);
    }

    @NonNull
    public j setSourceExecutor(@Nullable e5.d dVar) {
        this.f5571g = dVar;
        return this;
    }
}
