package J0;

import Q0.C0586a;
import T0.C0596g;
import android.R;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.inputmethodservice.InputMethodService;
import android.os.Binder;
import android.os.Build;
import android.os.Parcelable;
import android.util.Size;
import android.util.SizeF;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewParent;
import androidx.compose.runtime.SnapshotStateKt;
import androidx.compose.runtime.snapshots.SnapshotMutableState;
import i0.InterfaceC2255s;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import o0.C2632c;
import p0.AbstractC2704j;
import p0.C2702h;
import w4.InterfaceC3143e;
import x4.AbstractC3251q;

/* JADX INFO: loaded from: classes.dex */
public abstract class O implements i1 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final Class[] f2903a = {Serializable.class, Parcelable.class, String.class, SparseArray.class, Binder.class, Size.class, SizeF.class};

    public static final boolean c(View view, View view2) {
        if (view2.equals(view)) {
            return false;
        }
        for (ViewParent parent = view2.getParent(); parent != null; parent = parent.getParent()) {
            if (parent == view) {
                return true;
            }
        }
        return false;
    }

    public static final boolean d(Q0.s sVar) {
        Q0.n nVarK = sVar.k();
        return !nVarK.f5799a.b(Q0.w.f5843i);
    }

    public static final boolean e(Q0.s sVar, Resources resources) {
        Object objD = sVar.f5808d.f5799a.d(Q0.w.f5835a);
        if (objD == null) {
            objD = null;
        }
        List list = (List) objD;
        return !Q0.v.e(sVar) && (sVar.f5808d.f5801c || (sVar.o() && ((list != null ? (String) AbstractC3251q.g0(list) : null) != null || m(sVar) != null || l(sVar, resources) != null || k(sVar))));
    }

    public static final void f(G1.g gVar, Q0.s sVar) {
        Object objD = sVar.f5808d.f5799a.d(Q0.w.f5858y);
        if (objD == null) {
            objD = null;
        }
        Q0.j jVar = (Q0.j) objD;
        if (d(sVar)) {
            if (jVar != null && jVar.f5747a == 8) {
                return;
            }
            Q0.z zVar = Q0.m.f5797y;
            n.N n6 = sVar.f5808d.f5799a;
            Object objD2 = n6.d(zVar);
            if (objD2 == null) {
                objD2 = null;
            }
            C0586a c0586a = (C0586a) objD2;
            if (c0586a != null) {
                gVar.b(new G1.f(null, R.id.accessibilityActionPageUp, c0586a.f5729a, null));
            }
            Object objD3 = n6.d(Q0.m.f5771A);
            if (objD3 == null) {
                objD3 = null;
            }
            C0586a c0586a2 = (C0586a) objD3;
            if (c0586a2 != null) {
                gVar.b(new G1.f(null, R.id.accessibilityActionPageDown, c0586a2.f5729a, null));
            }
            Object objD4 = n6.d(Q0.m.f5798z);
            if (objD4 == null) {
                objD4 = null;
            }
            C0586a c0586a3 = (C0586a) objD4;
            if (c0586a3 != null) {
                gVar.b(new G1.f(null, R.id.accessibilityActionPageLeft, c0586a3.f5729a, null));
            }
            Object objD5 = n6.d(Q0.m.f5772B);
            if (objD5 == null) {
                objD5 = null;
            }
            C0586a c0586a4 = (C0586a) objD5;
            if (c0586a4 != null) {
                gVar.b(new G1.f(null, R.id.accessibilityActionPageRight, c0586a4.f5729a, null));
            }
        }
    }

    public static final void g(G1.g gVar, Q0.s sVar) {
        if (d(sVar)) {
            Object objD = sVar.f5808d.f5799a.d(Q0.m.f5782i);
            if (objD == null) {
                objD = null;
            }
            C0586a c0586a = (C0586a) objD;
            if (c0586a != null) {
                gVar.b(new G1.f(null, R.id.accessibilityActionSetProgress, c0586a.f5729a, null));
            }
        }
    }

    public static final C0397z0 h(View view) {
        Context context = view.getContext();
        Context baseContext = context;
        while (baseContext instanceof ContextWrapper) {
            if ((baseContext instanceof Activity) || (baseContext instanceof InputMethodService) || (baseContext instanceof Application)) {
                break;
            }
            ContextWrapper contextWrapper = (ContextWrapper) baseContext;
            if (contextWrapper.getBaseContext() == null) {
                break;
            }
            baseContext = contextWrapper.getBaseContext();
        }
        baseContext = null;
        if (baseContext == null) {
            Configuration configuration = context.getResources().getConfiguration();
            h1.e eVarD = W.d.d(context);
            long jK = W.b.K(configuration.screenWidthDp, configuration.screenHeightDp);
            long jK0 = eVarD.k0(jK);
            return new C0397z0((((long) ((int) Float.intBitsToFloat((int) (jK0 & 4294967295L)))) & 4294967295L) | (((long) ((int) Float.intBitsToFloat((int) (jK0 >> 32)))) << 32), jK);
        }
        B2.o.f488a.getClass();
        B2.p it = B2.n.f487b;
        kotlin.jvm.internal.o.h(it, "it");
        ContextWrapper contextWrapper2 = (ContextWrapper) baseContext;
        int i6 = Build.VERSION.SDK_INT;
        z2.b bVar = (i6 >= 34 ? F2.f.f1489c : i6 >= 30 ? F2.d.f1487c : F2.c.f1484g).d(contextWrapper2, it.f489b).f484a;
        long jHeight = (4294967295L & ((long) bVar.c().height())) | (((long) bVar.c().width()) << 32);
        return new C0397z0(jHeight, W.d.d(baseContext).o(W0.e.K(jHeight)));
    }

    public static final boolean i(Object obj) {
        if (obj instanceof SnapshotMutableState) {
            SnapshotMutableState snapshotMutableState = (SnapshotMutableState) obj;
            if (snapshotMutableState.getPolicy() != SnapshotStateKt.neverEqualPolicy() && snapshotMutableState.getPolicy() != SnapshotStateKt.structuralEqualityPolicy() && snapshotMutableState.getPolicy() != SnapshotStateKt.referentialEqualityPolicy()) {
                return false;
            }
            T value = snapshotMutableState.getValue();
            if (value == 0) {
                return true;
            }
            return i(value);
        }
        if ((obj instanceof InterfaceC3143e) && (obj instanceof Serializable)) {
            return false;
        }
        Class[] clsArr = f2903a;
        for (int i6 = 0; i6 < 7; i6++) {
            if (clsArr[i6].isInstance(obj)) {
                return true;
            }
        }
        return false;
    }

    public static final float j(int i6, float[] fArr, float[] fArr2, int i7) {
        int i8 = i6 * 4;
        return (fArr[i8 + 3] * fArr2[12 + i7]) + (fArr[i8 + 2] * fArr2[8 + i7]) + (fArr[i8 + 1] * fArr2[4 + i7]) + (fArr[i8] * fArr2[i7]);
    }

    public static final boolean k(Q0.s sVar) {
        Object objD = sVar.f5808d.f5799a.d(Q0.w.f5828J);
        if (objD == null) {
            objD = null;
        }
        S0.a aVar = (S0.a) objD;
        Q0.z zVar = Q0.w.f5858y;
        n.N n6 = sVar.f5808d.f5799a;
        Object objD2 = n6.d(zVar);
        if (objD2 == null) {
            objD2 = null;
        }
        Q0.j jVar = (Q0.j) objD2;
        boolean z6 = aVar != null;
        Object objD3 = n6.d(Q0.w.f5827I);
        if (((Boolean) (objD3 != null ? objD3 : null)) == null || (jVar != null && jVar.f5747a == 4)) {
            return z6;
        }
        return true;
    }

    public static final String l(Q0.s sVar, Resources resources) {
        Object objD = sVar.f5808d.f5799a.d(Q0.w.f5836b);
        String string = null;
        if (objD == null) {
            objD = null;
        }
        Q0.z zVar = Q0.w.f5828J;
        Q0.n nVar = sVar.f5808d;
        n.N n6 = nVar.f5799a;
        Object objD2 = n6.d(zVar);
        if (objD2 == null) {
            objD2 = null;
        }
        S0.a aVar = (S0.a) objD2;
        Object objD3 = n6.d(Q0.w.f5858y);
        if (objD3 == null) {
            objD3 = null;
        }
        Q0.j jVar = (Q0.j) objD3;
        if (aVar != null) {
            int iOrdinal = aVar.ordinal();
            if (iOrdinal != 0) {
                if (iOrdinal != 1) {
                    if (iOrdinal != 2) {
                        throw new E3.v();
                    }
                    if (objD == null) {
                        objD = resources.getString(com.debridstream.tv.R.string.indeterminate);
                    }
                } else if (jVar != null && jVar.f5747a == 2 && objD == null) {
                    objD = resources.getString(com.debridstream.tv.R.string.state_off);
                }
            } else if (jVar != null && jVar.f5747a == 2 && objD == null) {
                objD = resources.getString(com.debridstream.tv.R.string.state_on);
            }
        }
        Object objD4 = n6.d(Q0.w.f5827I);
        if (objD4 == null) {
            objD4 = null;
        }
        Boolean bool = (Boolean) objD4;
        if (bool != null) {
            boolean zBooleanValue = bool.booleanValue();
            if ((jVar == null || jVar.f5747a != 4) && objD == null) {
                objD = zBooleanValue ? resources.getString(com.debridstream.tv.R.string.selected) : resources.getString(com.debridstream.tv.R.string.not_selected);
            }
        }
        Object objD5 = n6.d(Q0.w.f5837c);
        if (objD5 == null) {
            objD5 = null;
        }
        Q0.i iVar = (Q0.i) objD5;
        if (iVar != null) {
            if (iVar != Q0.i.f5743d) {
                if (objD == null) {
                    P4.d dVar = iVar.f5745b;
                    float f6 = dVar.f5675b;
                    float f7 = dVar.f5674a;
                    float f8 = f6 - f7 == 0.0f ? 0.0f : (iVar.f5744a - f7) / (dVar.f5675b - f7);
                    if (f8 < 0.0f) {
                        f8 = 0.0f;
                    }
                    if (f8 > 1.0f) {
                        f8 = 1.0f;
                    }
                    objD = resources.getString(com.debridstream.tv.R.string.template_percent, Integer.valueOf(f8 == 0.0f ? 0 : f8 == 1.0f ? 100 : L4.a.v(Math.round(f8 * 100), 1, 99)));
                }
            } else if (objD == null) {
                objD = resources.getString(com.debridstream.tv.R.string.in_progress);
            }
        }
        Q0.z zVar2 = Q0.w.f5824F;
        if (n6.b(zVar2)) {
            Q0.n nVarK = new Q0.s(sVar.f5805a, true, sVar.f5807c, nVar).k();
            Q0.z zVar3 = Q0.w.f5835a;
            n.N n7 = nVarK.f5799a;
            Object objD6 = n7.d(zVar3);
            if (objD6 == null) {
                objD6 = null;
            }
            Collection collection = (Collection) objD6;
            if (collection == null || collection.isEmpty()) {
                Object objD7 = n7.d(Q0.w.f5820B);
                if (objD7 == null) {
                    objD7 = null;
                }
                Collection collection2 = (Collection) objD7;
                if (collection2 == null || collection2.isEmpty()) {
                    Object objD8 = n7.d(zVar2);
                    if (objD8 == null) {
                        objD8 = null;
                    }
                    CharSequence charSequence = (CharSequence) objD8;
                    if (charSequence == null || charSequence.length() == 0) {
                        string = resources.getString(com.debridstream.tv.R.string.state_empty);
                    }
                }
            }
            objD = string;
        }
        return (String) objD;
    }

    public static final C0596g m(Q0.s sVar) {
        Q0.n nVar = sVar.f5808d;
        Q0.z zVar = Q0.w.f5835a;
        C0596g c0596g = (C0596g) Q0.v.d(nVar, Q0.w.f5824F);
        List list = (List) Q0.v.d(sVar.f5808d, Q0.w.f5820B);
        return c0596g == null ? list != null ? (C0596g) AbstractC3251q.g0(list) : null : c0596g;
    }

    public static boolean n() {
        try {
            if (A.f2695N0 == null) {
                A.f2695N0 = Class.forName("android.os.SystemProperties");
            }
            if (A.f2696O0 == null) {
                Class cls = A.f2695N0;
                A.f2696O0 = cls != null ? cls.getDeclaredMethod("getBoolean", String.class, Boolean.TYPE) : null;
            }
            Method method = A.f2696O0;
            Object objInvoke = method != null ? method.invoke(null, "debug.layout", Boolean.FALSE) : null;
            return kotlin.jvm.internal.o.c(objInvoke instanceof Boolean ? (Boolean) objInvoke : null, Boolean.TRUE);
        } catch (Exception unused) {
            return false;
        }
    }

    public static final T0.L o(Q0.n nVar) {
        J4.c cVar;
        ArrayList arrayList = new ArrayList();
        Object objD = nVar.f5799a.d(Q0.m.f5774a);
        if (objD == null) {
            objD = null;
        }
        C0586a c0586a = (C0586a) objD;
        if (c0586a == null || (cVar = (J4.c) c0586a.f5730b) == null || !((Boolean) cVar.invoke(arrayList)).booleanValue()) {
            return null;
        }
        return (T0.L) arrayList.get(0);
    }

    public static final boolean p(float[] fArr, float[] fArr2) {
        if (fArr.length < 16 || fArr2.length < 16) {
            return false;
        }
        float f6 = fArr[0];
        float f7 = fArr[1];
        float f8 = fArr[2];
        float f9 = fArr[3];
        float f10 = fArr[4];
        float f11 = fArr[5];
        float f12 = fArr[6];
        float f13 = fArr[7];
        float f14 = fArr[8];
        float f15 = fArr[9];
        float f16 = fArr[10];
        float f17 = fArr[11];
        float f18 = fArr[12];
        float f19 = fArr[13];
        float f20 = fArr[14];
        float f21 = fArr[15];
        float f22 = (f6 * f11) - (f7 * f10);
        float f23 = (f6 * f12) - (f8 * f10);
        float f24 = (f6 * f13) - (f9 * f10);
        float f25 = (f7 * f12) - (f8 * f11);
        float f26 = (f7 * f13) - (f9 * f11);
        float f27 = (f8 * f13) - (f9 * f12);
        float f28 = (f14 * f19) - (f15 * f18);
        float f29 = (f14 * f20) - (f16 * f18);
        float f30 = (f14 * f21) - (f17 * f18);
        float f31 = (f15 * f20) - (f16 * f19);
        float f32 = (f15 * f21) - (f17 * f19);
        float f33 = (f16 * f21) - (f17 * f20);
        float f34 = (f27 * f28) + (((f25 * f30) + ((f24 * f31) + ((f22 * f33) - (f23 * f32)))) - (f26 * f29));
        if (f34 != 0.0f) {
            float f35 = 1.0f / f34;
            fArr2[0] = ((f13 * f31) + ((f11 * f33) - (f12 * f32))) * f35;
            fArr2[1] = (((f8 * f32) + ((-f7) * f33)) - (f9 * f31)) * f35;
            fArr2[2] = ((f21 * f25) + ((f19 * f27) - (f20 * f26))) * f35;
            fArr2[3] = (((f16 * f26) + ((-f15) * f27)) - (f17 * f25)) * f35;
            float f36 = -f10;
            fArr2[4] = (((f12 * f30) + (f36 * f33)) - (f13 * f29)) * f35;
            fArr2[5] = ((f9 * f29) + ((f33 * f6) - (f8 * f30))) * f35;
            float f37 = -f18;
            fArr2[6] = (((f20 * f24) + (f37 * f27)) - (f21 * f23)) * f35;
            fArr2[7] = ((f17 * f23) + ((f27 * f14) - (f16 * f24))) * f35;
            fArr2[8] = ((f13 * f28) + ((f10 * f32) - (f11 * f30))) * f35;
            fArr2[9] = (((f30 * f7) + ((-f6) * f32)) - (f9 * f28)) * f35;
            fArr2[10] = ((f21 * f22) + ((f18 * f26) - (f19 * f24))) * f35;
            fArr2[11] = (((f24 * f15) + ((-f14) * f26)) - (f17 * f22)) * f35;
            fArr2[12] = (((f11 * f29) + (f36 * f31)) - (f12 * f28)) * f35;
            fArr2[13] = ((f8 * f28) + ((f6 * f31) - (f7 * f29))) * f35;
            fArr2[14] = (((f19 * f23) + (f37 * f25)) - (f20 * f22)) * f35;
            fArr2[15] = ((f16 * f22) + ((f14 * f25) - (f15 * f23))) * f35;
        }
        return !(f34 == 0.0f);
    }

    public static final boolean q(p0.Q q6, float f6, float f7) {
        C2632c c2632c = new C2632c(f6 - 0.005f, f7 - 0.005f, f6 + 0.005f, f7 + 0.005f);
        C2702h c2702hA = AbstractC2704j.a();
        p0.Q.a(c2702hA, c2632c);
        C2702h c2702hA2 = AbstractC2704j.a();
        c2702hA2.g(q6, c2702hA, 1);
        boolean zIsEmpty = c2702hA2.f22920a.isEmpty();
        c2702hA2.h();
        c2702hA.h();
        return !zIsEmpty;
    }

    public static final boolean r(float f6, float f7, float f8, float f9, long j4) {
        float f10 = f6 - f8;
        float f11 = f7 - f9;
        float fIntBitsToFloat = Float.intBitsToFloat((int) (j4 >> 32));
        float fIntBitsToFloat2 = Float.intBitsToFloat((int) (j4 & 4294967295L));
        return ((f11 * f11) / (fIntBitsToFloat2 * fIntBitsToFloat2)) + ((f10 * f10) / (fIntBitsToFloat * fIntBitsToFloat)) <= 1.0f;
    }

    public static final void s(float[] fArr, float[] fArr2) {
        float fJ = j(0, fArr2, fArr, 0);
        float fJ2 = j(0, fArr2, fArr, 1);
        float fJ3 = j(0, fArr2, fArr, 2);
        float fJ4 = j(0, fArr2, fArr, 3);
        float fJ5 = j(1, fArr2, fArr, 0);
        float fJ6 = j(1, fArr2, fArr, 1);
        float fJ7 = j(1, fArr2, fArr, 2);
        float fJ8 = j(1, fArr2, fArr, 3);
        float fJ9 = j(2, fArr2, fArr, 0);
        float fJ10 = j(2, fArr2, fArr, 1);
        float fJ11 = j(2, fArr2, fArr, 2);
        float fJ12 = j(2, fArr2, fArr, 3);
        float fJ13 = j(3, fArr2, fArr, 0);
        float fJ14 = j(3, fArr2, fArr, 1);
        float fJ15 = j(3, fArr2, fArr, 2);
        float fJ16 = j(3, fArr2, fArr, 3);
        fArr[0] = fJ;
        fArr[1] = fJ2;
        fArr[2] = fJ3;
        fArr[3] = fJ4;
        fArr[4] = fJ5;
        fArr[5] = fJ6;
        fArr[6] = fJ7;
        fArr[7] = fJ8;
        fArr[8] = fJ9;
        fArr[9] = fJ10;
        fArr[10] = fJ11;
        fArr[11] = fJ12;
        fArr[12] = fJ13;
        fArr[13] = fJ14;
        fArr[14] = fJ15;
        fArr[15] = fJ16;
    }

    public static final k1.i t(C0362h0 c0362h0, int i6) {
        Object next;
        Iterator<T> it = c0362h0.getLayoutNodeToHolder().entrySet().iterator();
        while (true) {
            if (!it.hasNext()) {
                next = null;
                break;
            }
            next = it.next();
            if (((I0.H) ((Map.Entry) next).getKey()).f2175b == i6) {
                break;
            }
        }
        Map.Entry entry = (Map.Entry) next;
        if (entry != null) {
            return (k1.i) entry.getValue();
        }
        return null;
    }

    public static final String u(Object obj) {
        String name = obj.getClass().isAnonymousClass() ? obj.getClass().getName() : obj.getClass().getSimpleName();
        StringBuilder sb = new StringBuilder();
        sb.append(name);
        sb.append('@');
        return A0.a.q(new Object[]{Integer.valueOf(System.identityHashCode(obj))}, 1, "%07x", sb);
    }

    public static final InterfaceC2255s v(InterfaceC2255s interfaceC2255s, String str) {
        return interfaceC2255s.then(new C0344a1(str));
    }

    public static final String w(int i6) {
        if (i6 == 0) {
            return "android.widget.Button";
        }
        if (i6 == 1) {
            return "android.widget.CheckBox";
        }
        if (i6 == 3) {
            return "android.widget.RadioButton";
        }
        if (i6 == 5) {
            return "android.widget.ImageView";
        }
        if (i6 == 6) {
            return "android.widget.Spinner";
        }
        if (i6 == 7) {
            return "android.widget.NumberPicker";
        }
        return null;
    }
}
