package F1;

import D.C0135f;
import android.content.Context;
import android.graphics.Typeface;
import android.os.Trace;
import android.view.ActionMode;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import androidx.compose.runtime.MutableState;
import androidx.compose.runtime.collection.MutableVector;
import androidx.lifecycle.C1115y;
import androidx.lifecycle.EnumC1107p;
import androidx.media3.exoplayer.analytics.DefaultAnalyticsCollector;
import androidx.media3.exoplayer.video.CompositingVideoSinkProvider;
import com.google.firebase.firestore.ListenerRegistration;
import com.google.firebase.firestore.core.TransactionRunner;
import com.google.firebase.installations.FirebaseInstallations;
import com.revenuecat.purchases.amazon.AmazonBilling;
import com.revenuecat.purchases.common.Dispatcher;
import com.revenuecat.purchases.simulatedstore.SimulatedStoreBillingWrapper;
import d.DialogC1834m;
import d.ViewTreeObserverOnDrawListenerC1830i;
import d3.C1931v0;
import d3.C1933w;
import d3.v2;
import java.io.IOException;
import java.nio.MappedByteBuffer;
import k4.v0;
import m4.C2512i;
import m4.C2529n1;
import m4.T1;
import m4.U1;
import n.C2566A;
import n2.AbstractC2612c;
import n2.AbstractC2613d;
import w4.C3137A;
import x3.C3221f;
import x3.C3223h;
import y3.C3270g;

/* JADX INFO: loaded from: classes.dex */
public final /* synthetic */ class r implements Runnable {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f1467a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final /* synthetic */ Object f1468b;

    public /* synthetic */ r(Object obj, int i6) {
        this.f1467a = i6;
        this.f1468b = obj;
    }

    private final void a() {
        C1933w c1933w = (C1933w) this.f1468b;
        int i6 = 262144;
        byte[] bArr = new byte[262144];
        long j4 = 0;
        long j6 = 0;
        while (!c1933w.f16136f.get()) {
            try {
                int i7 = c1933w.f16131a.read(bArr, 0, i6);
                if (i7 == -1) {
                    c1933w.f16137g.set(true);
                    synchronized (c1933w.f16138h) {
                        c1933w.f16138h.notifyAll();
                    }
                    return;
                }
                long jCurrentTimeMillis = System.currentTimeMillis();
                c1933w.f16141k = jCurrentTimeMillis;
                if (jCurrentTimeMillis - j4 >= 2000) {
                    j4 = jCurrentTimeMillis;
                }
                int i8 = 0;
                while (i8 < i7 && !c1933w.f16136f.get()) {
                    synchronized (c1933w.f16138h) {
                        while (c1933w.f16135e == c1933w.f16132b.length && !c1933w.f16136f.get()) {
                            try {
                                long jCurrentTimeMillis2 = System.currentTimeMillis();
                                if (jCurrentTimeMillis2 - j6 >= 2000) {
                                    j6 = jCurrentTimeMillis2;
                                }
                                c1933w.f16138h.wait(5L);
                            } catch (InterruptedException unused) {
                                c1933w.f16137g.set(true);
                                c1933w.f16138h.notifyAll();
                                return;
                            }
                        }
                        int iMin = Math.min(c1933w.f16132b.length - c1933w.f16135e, i7 - i8);
                        int iMin2 = Math.min(iMin, c1933w.f16132b.length - c1933w.f16134d);
                        System.arraycopy(bArr, i8, c1933w.f16132b, c1933w.f16134d, iMin2);
                        int i9 = iMin - iMin2;
                        if (i9 > 0) {
                            System.arraycopy(bArr, iMin2 + i8, c1933w.f16132b, 0, i9);
                        }
                        c1933w.f16134d = (c1933w.f16134d + iMin) % c1933w.f16132b.length;
                        c1933w.f16135e += iMin;
                        i8 += iMin;
                        c1933w.f16138h.notifyAll();
                    }
                }
                i6 = 262144;
            } catch (IOException unused2) {
                c1933w.f16137g.set(true);
                synchronized (c1933w.f16138h) {
                    c1933w.f16138h.notifyAll();
                    return;
                }
            } catch (InterruptedException unused3) {
                c1933w.f16137g.set(true);
                synchronized (c1933w.f16138h) {
                    c1933w.f16138h.notifyAll();
                    return;
                }
            } catch (Throwable unused4) {
                c1933w.f16137g.set(true);
                synchronized (c1933w.f16138h) {
                    c1933w.f16138h.notifyAll();
                    return;
                }
            }
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:39:0x00dc  */
    /* JADX WARN: Type inference failed for: r2v11, types: [java.lang.Object, w4.h] */
    /* JADX WARN: Type inference failed for: r3v26, types: [java.lang.Object, w4.h] */
    @Override // java.lang.Runnable
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void run() throws Throwable {
        View viewFindFocus;
        boolean z6;
        boolean z7;
        long[] jArr;
        boolean z8;
        long[] jArr2;
        Boolean bool = null;
        int i6 = 2;
        boolean z9 = true;
        switch (this.f1467a) {
            case 0:
                View view = (View) this.f1468b;
                ((InputMethodManager) view.getContext().getSystemService("input_method")).showSoftInput(view, 0);
                return;
            case 1:
                J0.G g6 = (J0.G) this.f1468b;
                Trace.beginSection("measureAndLayout");
                try {
                    g6.f2857d.t(true);
                    Trace.endSection();
                    Trace.beginSection("checkForSemanticsChanges");
                    try {
                        g6.n();
                        Trace.endSection();
                        g6.f2852M = false;
                        return;
                    } finally {
                    }
                } finally {
                }
            case 2:
                ActionMode actionMode = ((P.h) this.f1468b).f5559h;
                if (actionMode != null) {
                    actionMode.finish();
                    return;
                }
                return;
            case 3:
                T1.o oVar = (T1.o) this.f1468b;
                synchronized (oVar.f6609d) {
                    try {
                        if (oVar.f6613h == null) {
                            return;
                        }
                        try {
                            C1.l lVarC = oVar.c();
                            int i7 = lVarC.f696e;
                            if (i7 == 2) {
                                synchronized (oVar.f6609d) {
                                }
                            }
                            if (i7 != 0) {
                                throw new RuntimeException("fetchFonts result is not OK. (" + i7 + ")");
                            }
                            try {
                                int i8 = B1.i.f450a;
                                Trace.beginSection("EmojiCompat.FontRequestEmojiCompatConfig.buildTypeface");
                                u4.c cVar = oVar.f6608c;
                                Context context = oVar.f6606a;
                                cVar.getClass();
                                C1.l[] lVarArr = {lVarC};
                                AbstractC2612c abstractC2612c = z1.f.f26277a;
                                AbstractC2612c.d("TypefaceCompat.createFromFontInfo");
                                try {
                                    Typeface typefaceG = z1.f.f26277a.g(context, lVarArr, 0);
                                    Trace.endSection();
                                    MappedByteBuffer mappedByteBufferJ = AbstractC2613d.j(oVar.f6606a, lVarC.f692a);
                                    if (mappedByteBufferJ == null || typefaceG == null) {
                                        throw new RuntimeException("Unable to open file.");
                                    }
                                    try {
                                        Trace.beginSection("EmojiCompat.MetadataRepo.create");
                                        C0.J j4 = new C0.J(typefaceG, android.support.v4.media.session.b.F(mappedByteBufferJ));
                                        Trace.endSection();
                                        synchronized (oVar.f6609d) {
                                            try {
                                                L4.a aVar = oVar.f6613h;
                                                if (aVar != null) {
                                                    aVar.a0(j4);
                                                }
                                            } finally {
                                            }
                                            break;
                                        }
                                        oVar.b();
                                        return;
                                    } finally {
                                        int i9 = B1.i.f450a;
                                    }
                                } finally {
                                }
                            } finally {
                            }
                            break;
                        } catch (Throwable th) {
                            synchronized (oVar.f6609d) {
                                try {
                                    L4.a aVar2 = oVar.f6613h;
                                    if (aVar2 != null) {
                                        aVar2.Z(th);
                                    }
                                    oVar.b();
                                    return;
                                } finally {
                                }
                            }
                        }
                    } finally {
                    }
                }
            case 4:
                Z.e.setRippleState$lambda$1((Z.e) this.f1468b);
                return;
            case 5:
                Z0.B b5 = (Z0.B) this.f1468b;
                b5.f9065n = null;
                View view2 = b5.f9053a;
                boolean zIsFocused = view2.isFocused();
                MutableVector mutableVector = b5.f9064m;
                if (!zIsFocused && (viewFindFocus = view2.getRootView().findFocus()) != null && viewFindFocus.onCheckIsTextEditor()) {
                    mutableVector.clear();
                    return;
                }
                Object[] objArr = mutableVector.content;
                int size = mutableVector.getSize();
                Boolean boolValueOf = null;
                for (int i10 = 0; i10 < size; i10++) {
                    Z0.A a6 = (Z0.A) objArr[i10];
                    int iOrdinal = a6.ordinal();
                    if (iOrdinal == 0) {
                        bool = Boolean.TRUE;
                    } else if (iOrdinal == 1) {
                        bool = Boolean.FALSE;
                    } else {
                        if (iOrdinal != 2 && iOrdinal != 3) {
                            throw new E3.v();
                        }
                        if (!kotlin.jvm.internal.o.c(bool, Boolean.FALSE)) {
                            boolValueOf = Boolean.valueOf(a6 == Z0.A.f9050c);
                        }
                    }
                    boolValueOf = bool;
                }
                mutableVector.clear();
                boolean zC = kotlin.jvm.internal.o.c(bool, Boolean.TRUE);
                C4.f fVar = b5.f9054b;
                if (zC) {
                    ((InputMethodManager) fVar.f742c.getValue()).restartInput((View) fVar.f741b);
                }
                if (boolValueOf != null) {
                    if (boolValueOf.booleanValue()) {
                        ((C0.B) ((C0.B) fVar.f743d).f506b).w();
                    } else {
                        ((C0.B) ((C0.B) fVar.f743d).f506b).p();
                    }
                }
                if (kotlin.jvm.internal.o.c(bool, Boolean.FALSE)) {
                    ((InputMethodManager) fVar.f742c.getValue()).restartInput((View) fVar.f741b);
                    return;
                }
                return;
            case 6:
                androidx.lifecycle.K k6 = (androidx.lifecycle.K) this.f1468b;
                int i11 = k6.f12098b;
                C1115y c1115y = k6.f12102f;
                if (i11 == 0) {
                    z6 = true;
                    k6.f12099c = true;
                    c1115y.c(EnumC1107p.ON_PAUSE);
                } else {
                    z6 = true;
                }
                if (k6.f12097a == 0 && k6.f12099c) {
                    c1115y.c(EnumC1107p.ON_STOP);
                    k6.f12100d = z6;
                    return;
                }
                return;
            case 7:
                ((DefaultAnalyticsCollector) this.f1468b).releaseInternal();
                return;
            case 8:
                ((CompositingVideoSinkProvider) this.f1468b).flushInternal();
                return;
            case 9:
                ((ListenerRegistration) this.f1468b).remove();
                return;
            case 10:
                ((TransactionRunner) this.f1468b).lambda$runWithBackoff$2();
                return;
            case 11:
                ((FirebaseInstallations) this.f1468b).lambda$getId$1();
                return;
            case 12:
                ((J4.c) this.f1468b).invoke(null);
                return;
            case 13:
                ((AmazonBilling) this.f1468b).startConnection();
                return;
            case 14:
                Dispatcher.enqueue$lambda$3$lambda$2$lambda$1((Throwable) this.f1468b);
                return;
            case 15:
                ((SimulatedStoreBillingWrapper) this.f1468b).startConnection();
                return;
            case 16:
                ViewTreeObserverOnDrawListenerC1830i viewTreeObserverOnDrawListenerC1830i = (ViewTreeObserverOnDrawListenerC1830i) this.f1468b;
                Runnable runnable = viewTreeObserverOnDrawListenerC1830i.f14484b;
                if (runnable != null) {
                    runnable.run();
                    viewTreeObserverOnDrawListenerC1830i.f14484b = null;
                    return;
                }
                return;
            case 17:
                DialogC1834m.a((DialogC1834m) this.f1468b);
                return;
            case 18:
                a();
                return;
            case 19:
                ((C0135f) this.f1468b).invoke();
                return;
            case 20:
                v2.x((MutableState) this.f1468b, true);
                return;
            case 21:
                ((C1931v0) this.f1468b).invoke();
                return;
            case 22:
                ((B0.b) this.f1468b).invoke();
                return;
            case 23:
                k0.e eVar = (k0.e) this.f1468b;
                boolean zF = eVar.f();
                J0.A a7 = eVar.f19625a;
                if (zF) {
                    Trace.beginSection("ContentCapture:changeChecker");
                    try {
                        a7.t(true);
                        C2566A c2566a = eVar.f19635o;
                        int[] iArr = c2566a.f21457b;
                        long[] jArr3 = c2566a.f21456a;
                        int length = jArr3.length - 2;
                        if (length >= 0) {
                            int i12 = 0;
                            while (true) {
                                long j6 = jArr3[i12];
                                if ((((~j6) << 7) & j6 & (-9187201950435737472L)) != -9187201950435737472L) {
                                    int i13 = 8 - ((~(i12 - length)) >>> 31);
                                    int i14 = 0;
                                    while (i14 < i13) {
                                        if ((255 & j6) < 128) {
                                            int i15 = iArr[(i12 << 3) + i14];
                                            if (eVar.e().a(i15)) {
                                                z8 = z9;
                                                jArr2 = jArr3;
                                            } else {
                                                z8 = z9;
                                                jArr2 = jArr3;
                                                eVar.f19628d.add(new k0.f(i15, eVar.f19634n, k0.g.f19644b, null));
                                                eVar.f19632k.f(C3137A.f25453a);
                                            }
                                        }
                                        j6 >>= 8;
                                        i14++;
                                        z9 = z8;
                                        jArr3 = jArr2;
                                    }
                                    z7 = z9;
                                    jArr = jArr3;
                                    if (i13 == 8) {
                                    }
                                } else {
                                    z7 = z9;
                                    jArr = jArr3;
                                }
                                if (i12 != length) {
                                    i12++;
                                    z9 = z7;
                                    jArr3 = jArr;
                                }
                            }
                        }
                        Trace.beginSection("ContentCapture:sendAppearEvents");
                        eVar.h(a7.getSemanticsOwner().a(), eVar.f19636p);
                        Trace.endSection();
                        eVar.c(eVar.e());
                        eVar.l();
                        eVar.f19637q = false;
                        return;
                    } catch (Throwable th2) {
                        throw th2;
                    } finally {
                    }
                }
                return;
            case 24:
                ((k1.h) this.f1468b).invoke();
                return;
            case 25:
                ((k1.h) this.f1468b).invoke();
                return;
            case 26:
                C2512i c2512i = (C2512i) this.f1468b;
                androidx.recyclerview.widget.i0 i0Var = c2512i.f21052d;
                if (i0Var != null) {
                    v0 v0Var = (v0) i0Var.f13105b;
                    if (!v0Var.f19972c && !v0Var.f19971b) {
                        i0Var.d();
                    }
                }
                c2512i.f21051c = null;
                return;
            case 27:
                ((C2529n1) this.f1468b).e();
                return;
            case 28:
                U1 u12 = ((T1) this.f1468b).f20846e;
                u12.f20879b.a(new I2.K(u12, 15));
                return;
            default:
                C3223h c3223h = (C3223h) this.f1468b;
                c3223h.getClass();
                ((C3270g) c3223h.f26031d).g(new C3221f(c3223h, i6));
                return;
        }
    }
}
