package defpackage;

import com.bumptech.glide.load.engine.GlideException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicInteger;

/* JADX INFO: renamed from: ᵧᵡʛ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C3670 implements InterfaceC1485 {

    /* JADX INFO: renamed from: ˈⁱᵡ, reason: contains not printable characters */
    public static final ˉᵠﹳᵘ f13920 = new ˉᵠﹳᵘ(21);

    /* JADX INFO: renamed from: ʽᵡᵢᵾ, reason: contains not printable characters */
    public volatile boolean f13921;

    /* JADX INFO: renamed from: ʿٴˇ, reason: contains not printable characters */
    public C1770 f13922;

    /* JADX INFO: renamed from: ˀᵭ, reason: contains not printable characters */
    public int f13923;

    /* JADX INFO: renamed from: ˁˌᵩ, reason: contains not printable characters */
    public InterfaceC1364 f13924;

    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public final ExecutorServiceC2288 f13925;

    /* JADX INFO: renamed from: ˉᵵᵜ, reason: contains not printable characters */
    public boolean f13926;

    /* JADX INFO: renamed from: ˊᵡᵗʨ, reason: contains not printable characters */
    public GlideException f13927;

    /* JADX INFO: renamed from: ˊᵾʽʼ, reason: contains not printable characters */
    public boolean f13928;

    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    public final ExecutorServiceC2288 f13930;

    /* JADX INFO: renamed from: ˑʢ, reason: contains not printable characters */
    public RunnableC4693 f13931;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public final C3580 f13933;

    /* JADX INFO: renamed from: ᵛˑﹳ, reason: contains not printable characters */
    public boolean f13934;

    /* JADX INFO: renamed from: ᵠˏˏ, reason: contains not printable characters */
    public boolean f13936;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public final InterfaceC4061 f13937;

    /* JADX INFO: renamed from: ᵵᵬᵽ, reason: contains not printable characters */
    public C3144 f13939;

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public final C3580 f13940;

    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    public final ExecutorServiceC2288 f13941;

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final C2675 f13929 = new C2675(new ArrayList(2));

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public final C1655 f13935 = new C1655();

    /* JADX INFO: renamed from: ˑˊᵲ, reason: contains not printable characters */
    public final AtomicInteger f13932 = new AtomicInteger();

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public final ˉᵠﹳᵘ f13938 = f13920;

    public C3670(ExecutorServiceC2288 executorServiceC2288, ExecutorServiceC2288 executorServiceC22882, ExecutorServiceC2288 executorServiceC22883, ExecutorServiceC2288 executorServiceC22884, C3580 c3580, C3580 c35802, ᵯᵨᵲ r9) {
        this.f13925 = executorServiceC2288;
        this.f13930 = executorServiceC22882;
        this.f13941 = executorServiceC22884;
        this.f13940 = c3580;
        this.f13933 = c35802;
        this.f13937 = r9;
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final synchronized void m8276(C4436 c4436, Executor executor) {
        try {
            this.f13935.m4545();
            this.f13929.f10336.add(new C0328(c4436, executor));
            if (this.f13928) {
                m8279(1);
                executor.execute(new ʾˀᵯˁ(11, this, c4436, false));
            } else if (this.f13934) {
                m8279(1);
                executor.execute(new ᵙᵘ(10, this, c4436, false));
            } else {
                ᵿᵽᵤ.ᵲᵶᵳˈ("Cannot add callbacks to a cancelled EngineJob", !this.f13921);
            }
        } catch (Throwable th) {
            throw th;
        }
    }

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public final void m8277() {
        synchronized (this) {
            try {
                this.f13935.m4545();
                if (this.f13921) {
                    this.f13924.mo2291();
                    m8284();
                    return;
                }
                if (this.f13929.f10336.isEmpty()) {
                    throw new IllegalStateException("Received a resource without any callbacks to notify");
                }
                if (this.f13928) {
                    throw new IllegalStateException("Already have resource");
                }
                ˉᵠﹳᵘ r0 = this.f13938;
                InterfaceC1364 interfaceC1364 = this.f13924;
                boolean z = this.f13936;
                C1770 c1770 = this.f13922;
                C3580 c3580 = this.f13933;
                r0.getClass();
                this.f13939 = new C3144(interfaceC1364, z, true, c1770, c3580);
                this.f13928 = true;
                C2675 c2675 = this.f13929;
                c2675.getClass();
                ArrayList arrayList = new ArrayList(c2675.f10336);
                m8279(arrayList.size() + 1);
                this.f13940.m8093(this, this.f13922, this.f13939);
                int size = arrayList.size();
                int i = 0;
                while (i < size) {
                    Object obj = arrayList.get(i);
                    i++;
                    C0328 c0328 = (C0328) obj;
                    c0328.f2044.execute(new ʾˀᵯˁ(11, this, c0328.f2045, false));
                }
                m8283();
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final void m8278() {
        if (m8285()) {
            return;
        }
        this.f13921 = true;
        RunnableC4693 runnableC4693 = this.f13931;
        runnableC4693.f17841 = true;
        InterfaceC3305 interfaceC3305 = runnableC4693.f17831;
        if (interfaceC3305 != null) {
            interfaceC3305.cancel();
        }
        C3580 c3580 = this.f13940;
        C1770 c1770 = this.f13922;
        synchronized (c3580) {
            HashMap map = c3580.f13679.f11275;
            if (this == map.get(c1770)) {
                map.remove(c1770);
            }
        }
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public final synchronized void m8279(int i) {
        C3144 c3144;
        ᵿᵽᵤ.ᵲᵶᵳˈ("Not yet complete!", m8285());
        if (this.f13932.getAndAdd(i) == 0 && (c3144 = this.f13939) != null) {
            c3144.m7250();
        }
    }

    /* JADX INFO: renamed from: ᵱᵽʡᵚ, reason: contains not printable characters */
    public final synchronized void m8280(C4436 c4436) {
        try {
            this.f13935.m4545();
            this.f13929.f10336.remove(new C0328(c4436, ᵷᵸˁ.ᵷᵺʾᵖ));
            if (this.f13929.f10336.isEmpty()) {
                m8278();
                if (this.f13928 || this.f13934) {
                    if (this.f13932.get() == 0) {
                        m8284();
                    }
                }
            }
        } catch (Throwable th) {
            throw th;
        }
    }

    @Override // defpackage.InterfaceC1485
    /* JADX INFO: renamed from: ᵲᵶᵳˈ */
    public final C1655 mo4259() {
        return this.f13935;
    }

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public final void m8281() {
        synchronized (this) {
            try {
                this.f13935.m4545();
                if (this.f13921) {
                    m8284();
                    return;
                }
                if (this.f13929.f10336.isEmpty()) {
                    throw new IllegalStateException("Received an exception without any callbacks to notify");
                }
                if (this.f13934) {
                    throw new IllegalStateException("Already failed once");
                }
                this.f13934 = true;
                C1770 c1770 = this.f13922;
                C2675 c2675 = this.f13929;
                c2675.getClass();
                ArrayList arrayList = new ArrayList(c2675.f10336);
                m8279(arrayList.size() + 1);
                this.f13940.m8093(this, c1770, null);
                int size = arrayList.size();
                int i = 0;
                while (i < size) {
                    Object obj = arrayList.get(i);
                    i++;
                    C0328 c0328 = (C0328) obj;
                    c0328.f2044.execute(new ᵙᵘ(10, this, c0328.f2045, false));
                }
                m8283();
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    /* JADX INFO: renamed from: ᵶᵥᵝ, reason: contains not printable characters */
    public final synchronized void m8282(RunnableC4693 runnableC4693) {
        this.f13931 = runnableC4693;
        int iM9820 = runnableC4693.m9820(1);
        ((iM9820 == 2 || iM9820 == 3) ? this.f13925 : this.f13926 ? this.f13941 : this.f13930).execute(runnableC4693);
    }

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final void m8283() {
        C3144 c3144;
        synchronized (this) {
            try {
                this.f13935.m4545();
                ᵿᵽᵤ.ᵲᵶᵳˈ("Not yet complete!", m8285());
                int iDecrementAndGet = this.f13932.decrementAndGet();
                ᵿᵽᵤ.ᵲᵶᵳˈ("Can't decrement below 0", iDecrementAndGet >= 0);
                if (iDecrementAndGet == 0) {
                    c3144 = this.f13939;
                    m8284();
                } else {
                    c3144 = null;
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        if (c3144 != null) {
            c3144.m7249();
        }
    }

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public final synchronized void m8284() {
        if (this.f13922 == null) {
            throw new IllegalArgumentException();
        }
        this.f13929.f10336.clear();
        this.f13922 = null;
        this.f13939 = null;
        this.f13924 = null;
        this.f13934 = false;
        this.f13921 = false;
        this.f13928 = false;
        this.f13931.m9826();
        this.f13931 = null;
        this.f13927 = null;
        this.f13923 = 0;
        this.f13937.mo8915(this);
    }

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public final boolean m8285() {
        return this.f13934 || this.f13928 || this.f13921;
    }
}
