package defpackage;

import android.os.SystemClock;
import android.util.Log;
import j$.util.Objects;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.function.Supplier;

/* renamed from: ᵧᵘᵗ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C3652 {

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public static final boolean f13559 = Log.isLoggable("Engine", 2);

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final C4164 f13560;

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final C4782 f13561;

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final C0262 f13562;

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final C4524 f13563;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final C5082 f13564;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final ʾᵠᵦ f13565;

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public final ʽᵡ f13566;

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final C1188 f13567;

    public C3652(C4524 c4524, ˑᵽʾʦ r11, ExecutorServiceC4470 executorServiceC4470, ExecutorServiceC4470 executorServiceC44702, ExecutorServiceC4470 executorServiceC44703, ExecutorServiceC4470 executorServiceC44704) throws Throwable {
        this.f13563 = c4524;
        C0262 c0262 = new C0262(r11);
        this.f13562 = c0262;
        ʽᵡ r112 = new ʽᵡ(3);
        this.f13566 = r112;
        synchronized (this) {
            try {
                try {
                    synchronized (r112) {
                        try {
                            r112.ᵾᵬ = this;
                        } catch (Throwable th) {
                            th = th;
                            while (true) {
                                try {
                                    throw th;
                                } catch (Throwable th2) {
                                    th = th2;
                                }
                            }
                        }
                    }
                    this.f13565 = new ʾᵠᵦ();
                    this.f13564 = new C5082(2);
                    this.f13567 = new C1188(executorServiceC4470, executorServiceC44702, executorServiceC44703, executorServiceC44704, this, this);
                    this.f13561 = new C4782(c0262);
                    this.f13560 = new C4164(7);
                    c4524.f16845 = this;
                } catch (Throwable th3) {
                    th = th3;
                    throw th;
                }
            } catch (Throwable th4) {
                th = th4;
                throw th;
            }
        }
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public static void m8241(InterfaceC1725 interfaceC1725) {
        if (interfaceC1725 instanceof C4744) {
            ((C4744) interfaceC1725).m10025();
        } else {
            ᵹˉᵞ.ˌᵜᵹᵩ("Cannot release anything but an EngineResource");
        }
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final void m8242(InterfaceC4207 interfaceC4207, C4744 c4744) {
        ʽᵡ r0 = this.f13566;
        synchronized (r0) {
            C3312 c3312 = (C3312) ((HashMap) r0.ᵢˇᵭ).remove(interfaceC4207);
            if (c3312 != null) {
                c3312.f12392 = null;
                c3312.clear();
            }
        }
        if (c4744.f17590) {
        } else {
            this.f13560.m9070(c4744, false);
        }
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final ᵧˉʙ m8243(C0520 c0520, Object obj, InterfaceC4207 interfaceC4207, int i, int i2, Class cls, Class cls2, EnumC5505 enumC5505, C3318 c3318, Map map, boolean z, boolean z2, C0210 c0210, boolean z3, boolean z4, C2359 c2359, Executor executor, C3330 c3330, long j) {
        C4732 c4732 = (C4732) this.f13564.f19006.get(c3330);
        if (c4732 != null) {
            c4732.m9989(c2359, executor);
            if (f13559) {
                int i3 = AbstractC4846.f17991;
                SystemClock.elapsedRealtimeNanos();
                Objects.toString(c3330);
            }
            return new ᵧˉʙ(this, c2359, c4732);
        }
        C4732 c47322 = (C4732) ((ʽᵡ) this.f13567.f5063).ˌʾˀ();
        synchronized (c47322) {
            c47322.f17536 = c3330;
            c47322.f17534 = z3;
            c47322.f17538 = z4;
        }
        C4782 c4782 = this.f13561;
        RunnableC2904 runnableC2904 = (RunnableC2904) ((ʽᵡ) c4782.f17767).ˌʾˀ();
        int i4 = c4782.f17765;
        c4782.f17765 = i4 + 1;
        C1101 c1101 = runnableC2904.f11291;
        C0262 c0262 = runnableC2904.f11298;
        c1101.f4726 = c0520;
        c1101.f4738 = obj;
        c1101.f4730 = interfaceC4207;
        c1101.f4721 = i;
        c1101.f4725 = i2;
        c1101.f4722 = c3318;
        c1101.f4724 = cls;
        c1101.f4737 = c0262;
        c1101.f4736 = cls2;
        c1101.f4732 = enumC5505;
        c1101.f4727 = c0210;
        c1101.f4734 = map;
        c1101.f4728 = z;
        c1101.f4735 = z2;
        runnableC2904.f11284 = c0520;
        runnableC2904.f11280 = interfaceC4207;
        runnableC2904.f11277 = enumC5505;
        runnableC2904.f11293 = c3330;
        runnableC2904.f11290 = i;
        runnableC2904.f11296 = i2;
        runnableC2904.f11281 = c3318;
        runnableC2904.f11295 = c0210;
        runnableC2904.f11272 = c47322;
        runnableC2904.f11300 = i4;
        runnableC2904.f11297 = 1;
        runnableC2904.f11282 = obj;
        runnableC2904.f11285 = c0520.f2699;
        runnableC2904.f11279 = (Supplier) c0210.m1488(RunnableC2904.f11268);
        C5082 c5082 = this.f13564;
        c5082.getClass();
        c5082.f19006.put(c3330, c47322);
        c47322.m9989(c2359, executor);
        c47322.m9991(runnableC2904);
        if (f13559) {
            int i5 = AbstractC4846.f17991;
            SystemClock.elapsedRealtimeNanos();
            Objects.toString(c3330);
        }
        return new ᵧˉʙ(this, c2359, c47322);
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final C4744 m8244(C3330 c3330, boolean z, long j) {
        C4744 c4744;
        if (z) {
            ʽᵡ r3 = this.f13566;
            synchronized (r3) {
                C3312 c3312 = (C3312) ((HashMap) r3.ᵢˇᵭ).get(c3330);
                if (c3312 == null) {
                    c4744 = null;
                } else {
                    c4744 = (C4744) c3312.get();
                    if (c4744 == null) {
                        r3.ᵙᵢᵨᵳ(c3312);
                    }
                }
            }
            if (c4744 != null) {
                c4744.m10026();
            }
            if (c4744 != null) {
                if (f13559) {
                    int i = AbstractC4846.f17991;
                    SystemClock.elapsedRealtimeNanos();
                    Objects.toString(c3330);
                }
                return c4744;
            }
            C4744 c4744M8246 = m8246(c3330);
            if (c4744M8246 != null) {
                if (f13559) {
                    int i2 = AbstractC4846.f17991;
                    SystemClock.elapsedRealtimeNanos();
                    Objects.toString(c3330);
                }
                return c4744M8246;
            }
        }
        return null;
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final ᵧˉʙ m8245(C0520 c0520, Object obj, InterfaceC4207 interfaceC4207, int i, int i2, Class cls, Class cls2, EnumC5505 enumC5505, C3318 c3318, C0154 c0154, boolean z, boolean z2, C0210 c0210, boolean z3, boolean z4, C2359 c2359, ExecutorC3609 executorC3609) {
        long jElapsedRealtimeNanos;
        if (f13559) {
            int i3 = AbstractC4846.f17991;
            jElapsedRealtimeNanos = SystemClock.elapsedRealtimeNanos();
        } else {
            jElapsedRealtimeNanos = 0;
        }
        this.f13565.getClass();
        C3330 c3330 = new C3330(obj, interfaceC4207, i, i2, c0154, cls, cls2, c0210);
        synchronized (this) {
            try {
                C4744 c4744M8244 = m8244(c3330, z3, jElapsedRealtimeNanos);
                if (c4744M8244 == null) {
                    return m8243(c0520, obj, interfaceC4207, i, i2, cls, cls2, enumC5505, c3318, c0154, z, z2, c0210, z3, z4, c2359, executorC3609, c3330, jElapsedRealtimeNanos);
                }
                c2359.m6114(c4744M8244, 5);
                return null;
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final C4744 m8246(C3330 c3330) {
        C4744 c4744;
        Object obj;
        C3652 c3652;
        C3330 c33302;
        C4524 c4524 = this.f13563;
        synchronized (c4524) {
            C0604 c0604 = (C0604) ((LinkedHashMap) c4524.f5283).remove(c3330);
            c4744 = null;
            if (c0604 == null) {
                obj = null;
            } else {
                c4524.f5285 -= c0604.f3065;
                obj = c0604.f3064;
            }
        }
        InterfaceC1725 interfaceC1725 = (InterfaceC1725) obj;
        if (interfaceC1725 == null) {
            c3652 = this;
            c33302 = c3330;
        } else if (interfaceC1725 instanceof C4744) {
            c4744 = (C4744) interfaceC1725;
            c3652 = this;
            c33302 = c3330;
        } else {
            c3652 = this;
            c33302 = c3330;
            c4744 = new C4744(interfaceC1725, true, true, c33302, c3652);
        }
        if (c4744 != null) {
            c4744.m10026();
            c3652.f13566.ˑᵥˁ(c33302, c4744);
        }
        return c4744;
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final synchronized void m8247(C4732 c4732, C3330 c3330, C4744 c4744) {
        if (c4744 != null) {
            try {
                if (c4744.f17590) {
                    this.f13566.ˑᵥˁ(c3330, c4744);
                }
            } finally {
            }
        }
        HashMap map = this.f13564.f19006;
        if (c4732 == map.get(c3330)) {
            map.remove(c3330);
        }
    }
}
