package defpackage;

import android.media.AudioTrack;
import android.os.Bundle;
import android.os.Handler;
import android.util.Pair;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
import androidx.work.impl.WorkDatabase;
import com.parse.ParseException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.atomic.AtomicBoolean;
import org.json.JSONObject;

/* renamed from: ᵖʒᵤ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final /* synthetic */ class RunnableC2331 implements Runnable {

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final /* synthetic */ Object f9135;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final /* synthetic */ int f9136;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public final /* synthetic */ Object f9137;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public final /* synthetic */ Object f9138;

    public /* synthetic */ RunnableC2331(Object obj, Object obj2, Object obj3, int i) {
        this.f9136 = i;
        this.f9135 = obj;
        this.f9138 = obj2;
        this.f9137 = obj3;
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    private final void m6051() {
        boolean zBooleanValue;
        C1812 c1812 = (C1812) this.f9135;
        C2372 c2372 = (C2372) this.f9138;
        C2148 c2148 = (C2148) this.f9137;
        c1812.getClass();
        try {
            zBooleanValue = ((Boolean) c2372.f9296.get()).booleanValue();
        } catch (InterruptedException | ExecutionException unused) {
            zBooleanValue = true;
        }
        synchronized (c1812.f7309) {
            try {
                C3084 c3084M2168 = AbstractC0494.m2168(c2148.f8473);
                String str = c3084M2168.f11772;
                if (c1812.m5133(str) == c2148) {
                    c1812.m5131(str);
                }
                ᵼᵫᵧˀ.ˀᵗᵝᵭ().getClass();
                ArrayList arrayList = c1812.f7308;
                int size = arrayList.size();
                int i = 0;
                while (i < size) {
                    Object obj = arrayList.get(i);
                    i++;
                    ((InterfaceC1924) obj).mo4861(c3084M2168, zBooleanValue);
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    private final void m6052() {
        JSONObject jSONObjectOptJSONObject;
        C1743 c1743 = (C1743) this.f9135;
        String str = (String) this.f9138;
        C2275 c2275 = (C2275) this.f9137;
        C5553 c5553 = c1743.f6954;
        InterfaceC2211 interfaceC2211 = (InterfaceC2211) ((InterfaceC3290) c5553.f20833).get();
        if (interfaceC2211 == null) {
            return;
        }
        JSONObject jSONObject = c2275.f8891;
        if (jSONObject.length() < 1) {
            return;
        }
        JSONObject jSONObject2 = c2275.f8896;
        if (jSONObject2.length() >= 1 && (jSONObjectOptJSONObject = jSONObject.optJSONObject(str)) != null) {
            String strOptString = jSONObjectOptJSONObject.optString("choiceId");
            if (strOptString.isEmpty()) {
                return;
            }
            synchronized (((Map) c5553.f20835)) {
                try {
                    if (strOptString.equals(((Map) c5553.f20835).get(str))) {
                        return;
                    }
                    ((Map) c5553.f20835).put(str, strOptString);
                    Bundle bundle = new Bundle();
                    bundle.putString("arm_key", str);
                    bundle.putString("arm_value", jSONObject2.optString(str));
                    bundle.putString("personalization_id", jSONObjectOptJSONObject.optString("personalizationId"));
                    bundle.putInt("arm_index", jSONObjectOptJSONObject.optInt("armIndex", -1));
                    bundle.putString("group", jSONObjectOptJSONObject.optString("group"));
                    C0818 c0818 = (C0818) interfaceC2211;
                    c0818.m2918("fp", "personalization_assignment", bundle);
                    Bundle bundle2 = new Bundle();
                    bundle2.putString("_fpid", strOptString);
                    c0818.m2918("fp", "_fpc", bundle2);
                } catch (Throwable th) {
                    throw th;
                }
            }
        }
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    private final void m6053() {
        C5054 c5054 = (C5054) this.f9135;
        ᵳʿˉ r1 = (ᵳʿˉ) this.f9138;
        ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) this.f9137;
        try {
            C4482 c4482 = ˁـᵛ.ˇʼʤˎ(c5054.f18881);
            if (c4482 == null) {
                throw new RuntimeException("EmojiCompat font provider not available on this device.");
            }
            C4153 c4153 = (C4153) ((InterfaceC4920) c4482.f18522);
            synchronized (c4153.f15524) {
                c4153.f15519 = threadPoolExecutor;
            }
            ((InterfaceC4920) c4482.f18522).mo9056(new C0160(r1, threadPoolExecutor));
        } catch (Throwable th) {
            r1.ˑᵥˁ(th);
            threadPoolExecutor.shutdown();
        }
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    private final void m6054() {
        C1557 c1557 = (C1557) this.f9135;
        C4997 c4997 = (C4997) this.f9138;
        C1812 c1812 = (C1812) c1557.f6205;
        c1812.getClass();
        C3084 c3084 = c4997.f18549;
        String str = c3084.f11772;
        ArrayList arrayList = new ArrayList();
        int i = 1;
        C3887 c3887 = (C3887) c1812.f7301.m682(new CallableC1751(c1812, arrayList, str, i));
        int i2 = 11;
        if (c3887 == null) {
            ᵼᵫᵧˀ r12 = ᵼᵫᵧˀ.ˀᵗᵝᵭ();
            c3084.toString();
            r12.getClass();
            ((ᵹᵧᵔ) c1812.f7311.f1152).execute(new RunnableC5417(c1812, i2, c3084));
            return;
        }
        synchronized (c1812.f7309) {
            try {
                if (c1812.m5128(str)) {
                    Set set = (Set) c1812.f7310.get(str);
                    if (((C4997) set.iterator().next()).f18549.f11773 == c3084.f11773) {
                        set.add(c4997);
                        ᵼᵫᵧˀ r122 = ᵼᵫᵧˀ.ˀᵗᵝᵭ();
                        c3084.toString();
                        r122.getClass();
                    } else {
                        ((ᵹᵧᵔ) c1812.f7311.f1152).execute(new RunnableC5417(c1812, i2, c3084));
                    }
                    return;
                }
                if (c3887.f14484 != c3084.f11773) {
                    ((ᵹᵧᵔ) c1812.f7311.f1152).execute(new RunnableC5417(c1812, i2, c3084));
                    return;
                }
                C2148 c2148 = new C2148(new ʿˁ(c1812.f7307, c1812.f7304, c1812.f7311, c1812, c1812.f7301, c3887, arrayList));
                AbstractC2687 abstractC2687 = (AbstractC2687) c2148.f8478.f1155;
                C4988 c4988 = ᵭʝʜ.ˏᵙ();
                abstractC2687.getClass();
                C2372 c2372 = ᵛᵾˏ.ᵙᵢᵨᵳ(ˁˈᵸ.ˎˑː(abstractC2687, c4988), new C1950(c2148, null, i));
                c2372.f9296.mo833(new RunnableC2331(c1812, c2372, c2148, 14), (ᵹᵧᵔ) c1812.f7311.f1152);
                c1812.f7302.put(str, c2148);
                HashSet hashSet = new HashSet();
                hashSet.add(c4997);
                c1812.f7310.put(str, hashSet);
                ᵼᵫᵧˀ r123 = ᵼᵫᵧˀ.ˀᵗᵝᵭ();
                c3084.toString();
                r123.getClass();
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // java.lang.Runnable
    public final void run() {
        switch (this.f9136) {
            case 0:
                AudioTrack audioTrack = (AudioTrack) this.f9135;
                Handler handler = (Handler) this.f9138;
                C5128 c5128 = (C5128) this.f9137;
                int i = 6;
                try {
                    audioTrack.flush();
                    audioTrack.release();
                    if (handler.getLooper().getThread().isAlive()) {
                        handler.post(new RunnableC3566(i, c5128));
                    }
                    synchronized (C2361.f9257) {
                        try {
                            int i2 = C2361.f9256 - 1;
                            C2361.f9256 = i2;
                            if (i2 == 0) {
                                ScheduledExecutorService scheduledExecutorService = C2361.f9255;
                                scheduledExecutorService.getClass();
                                scheduledExecutorService.shutdown();
                                C2361.f9255 = null;
                            }
                        } finally {
                        }
                    }
                    return;
                } catch (Throwable th) {
                    if (handler.getLooper().getThread().isAlive()) {
                        handler.post(new RunnableC3566(i, c5128));
                    }
                    synchronized (C2361.f9257) {
                        try {
                            int i3 = C2361.f9256 - 1;
                            C2361.f9256 = i3;
                            if (i3 == 0) {
                                ScheduledExecutorService scheduledExecutorService2 = C2361.f9255;
                                scheduledExecutorService2.getClass();
                                scheduledExecutorService2.shutdown();
                                C2361.f9255 = null;
                            }
                            throw th;
                        } finally {
                        }
                    }
                }
            case 1:
                WorkDatabase workDatabase = (WorkDatabase) this.f9135;
                String str = (String) this.f9138;
                C5205 c5205 = (C5205) this.f9137;
                Iterator it = ((List) ˊˉʤﹳ.ˌᵪ(workDatabase.mo678().f10260, true, false, new C3449(12, str))).iterator();
                while (it.hasNext()) {
                    ᵿᵧ.ᵻᵢﹳᵰ(c5205, (String) it.next());
                }
                return;
            case 2:
                m6052();
                return;
            case 3:
                ᵪᵨ r0 = (ᵪᵨ) this.f9135;
                InterfaceC4086 interfaceC4086 = (InterfaceC4086) this.f9138;
                C2074 c2074 = (C2074) this.f9137;
                C3328 c3328 = (C3328) r0.ᵿʗᵝʽ;
                if (c3328.f12422.mo3300()) {
                    interfaceC4086.mo1689(new IOException("Canceled"));
                    return;
                } else {
                    interfaceC4086.mo1687(c3328, c2074);
                    return;
                }
            case 4:
                ViewGroup viewGroup = (ViewGroup) this.f9135;
                View view = (View) this.f9138;
                C4090 c4090 = (C4090) this.f9137;
                viewGroup.endViewTransition(view);
                ((C0423) ((ᵢˇᵭ) c4090.f15284).ᵧᵾˀˈ).m1968(c4090);
                return;
            case 5:
                C2221 c2221 = (C2221) this.f9135;
                ((InterfaceC4932) this.f9138).mo1932(c2221.f8732, c2221.f8733, (Exception) this.f9137);
                return;
            case C1339.STRING_SET_FIELD_NUMBER /* 6 */:
                C2221 c22212 = (C2221) this.f9135;
                ((InterfaceC4932) this.f9138).mo1947(c22212.f8732, c22212.f8733, (ˉːᵡ) this.f9137);
                return;
            case C1339.DOUBLE_FIELD_NUMBER /* 7 */:
                m6053();
                return;
            case C1339.BYTES_FIELD_NUMBER /* 8 */:
                AtomicBoolean atomicBoolean = (AtomicBoolean) this.f9135;
                C1864 c1864 = (C1864) this.f9138;
                C2610 c2610 = (C2610) this.f9137;
                if (atomicBoolean.get()) {
                    return;
                }
                try {
                    c2610.mo1401();
                    c1864.m5258(null);
                    return;
                } catch (Throwable th2) {
                    c1864.m5259(th2);
                    return;
                }
            case 9:
                C2936 c2936 = (C2936) this.f9135;
                C4704 c4704 = (C4704) this.f9138;
                C2477 c2477 = (C2477) this.f9137;
                C0422 c0422 = c2936.f11381;
                C4471 c4471M9892 = c4704.m9892();
                C3460 c3460 = c0422.f2339;
                InterfaceC0304 interfaceC0304 = c0422.f2332;
                interfaceC0304.getClass();
                c3460.getClass();
                c3460.f12991 = AbstractC2692.m6700(c4471M9892);
                if (!c4471M9892.isEmpty()) {
                    c3460.f12986 = (C2477) c4471M9892.get(0);
                    c2477.getClass();
                    c3460.f12989 = c2477;
                }
                if (((C2477) c3460.f12988) == null) {
                    c3460.f12988 = C3460.m7872(interfaceC0304, (AbstractC2692) c3460.f12991, (C2477) c3460.f12986, (C4479) c3460.f12987);
                }
                c3460.m7883(((C3916) interfaceC0304).m8641());
                return;
            case 10:
                C3118 c3118 = (C3118) this.f9135;
                Pair pair = (Pair) this.f9138;
                ((C0422) c3118.f11879.f2128).mo1947(((Integer) pair.first).intValue(), (C2477) pair.second, (ˉːᵡ) this.f9137);
                return;
            case 11:
                C3118 c31182 = (C3118) this.f9135;
                Pair pair2 = (Pair) this.f9138;
                ((C0422) c31182.f11879.f2128).mo1932(((Integer) pair2.first).intValue(), (C2477) pair2.second, (Exception) this.f9137);
                return;
            case 12:
                ˉʠ r02 = (ˉʠ) this.f9135;
                ˉᵩʽʿ r1 = (ˉᵩʽʿ) this.f9138;
                ᵨˊˆ r6 = (ᵨˊˆ) this.f9137;
                try {
                    Exception parseException = r02.ˎˏʜʾ();
                    if (parseException != null && !(parseException instanceof ParseException)) {
                        parseException = new ParseException(parseException);
                    }
                    r1.ᵥᵯˎ(r02.ᵹᵝᵶ(), (ParseException) parseException);
                    if (r02.ᵝᵵᵺ()) {
                        r6.ᵥᵯˎ();
                        return;
                    } else if (r02.ᵸˑ()) {
                        r6.ᵴᵳ(r02.ˎˏʜʾ());
                        return;
                    } else {
                        r6.ˏᵙ(r02.ᵹᵝᵶ());
                        return;
                    }
                } catch (Throwable th3) {
                    if (r02.ᵝᵵᵺ()) {
                        r6.ᵥᵯˎ();
                    } else if (r02.ᵸˑ()) {
                        r6.ᵴᵳ(r02.ˎˏʜʾ());
                    } else {
                        r6.ˏᵙ(r02.ᵹᵝᵶ());
                    }
                    throw th3;
                }
            case 13:
                C0789.m2884((C0789) this.f9135, (SurfaceView) this.f9138, (RunnableC2357) this.f9137);
                return;
            case 14:
                m6051();
                return;
            case 15:
                C3545 c3545 = (C3545) this.f9135;
                String str2 = (String) this.f9138;
                InterfaceC3048 interfaceC3048 = (InterfaceC3048) this.f9137;
                C1427 c1427 = (C1427) c3545.f13291.ᵢˇᵭ;
                C3896 c3896 = c1427.f5814;
                c1427.f5811 = str2;
                C2020 c2020Mo5553 = interfaceC3048.mo5553();
                if (c2020Mo5553 != null) {
                    c3896.f14526.f9112.f11933.put(Integer.valueOf(interfaceC3048.mo5552()), c2020Mo5553);
                    c3896.f14508 = true;
                }
                c3896.m8552();
                return;
            case 16:
                m6054();
                return;
            default:
                AtomicBoolean atomicBoolean2 = (AtomicBoolean) this.f9135;
                C1864 c18642 = (C1864) this.f9138;
                InterfaceC4622 interfaceC4622 = (InterfaceC4622) this.f9137;
                if (atomicBoolean2.get()) {
                    return;
                }
                try {
                    c18642.m5258(interfaceC4622.mo1401());
                    return;
                } catch (Throwable th4) {
                    c18642.m5259(th4);
                    return;
                }
        }
    }
}
