package o;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.text.Layout;
import android.text.TextUtils;
import android.view.View;
import com.google.android.gms.common.R;
import com.google.android.gms.common.api.Api;
import java.io.File;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.sm0, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public abstract class AbstractC2461sm0 implements InterfaceC0592Wv {
    public static final Object a = new Object();
    public static final Yk0 b = new Yk0(0.31006f, 0.31616f);
    public static final Yk0 c = new Yk0(0.34567f, 0.3585f);
    public static final Yk0 d = new Yk0(0.32168f, 0.33767f);
    public static final Yk0 e = new Yk0(0.31271f, 0.32902f);
    public static final float[] f = {0.964212f, 1.0f, 0.825188f};
    public static final C1755lJ g = new C1755lJ(2);
    public static final C3100zZ h = new C3100zZ(new C0781b40(15));
    public static CG i;
    public static CG j;

    public AbstractC2461sm0() {
        new ConcurrentHashMap();
    }

    /* JADX WARN: Multi-variable type inference failed */
    public static final void A(InterfaceC1905mt interfaceC1905mt) {
        if (((LP) interfaceC1905mt).l.y) {
            AbstractC2539te.Q(interfaceC1905mt, 1).W0();
        }
    }

    public static boolean B(Context context) {
        return context.getResources().getConfiguration().fontScale >= 1.3f;
    }

    public static G60 C(SC sc) {
        G60 g60 = new G60();
        g60.n = AbstractC2539te.u(g60, g60, sc);
        return g60;
    }

    public static final void D(View view, InterfaceC0898cL interfaceC0898cL) {
        view.setTag(R.id.view_tree_lifecycle_owner, interfaceC0898cL);
    }

    public static boolean E(int i2, int i3, int i4, int i5) {
        return (i4 == 1 || i4 == 2 || (i4 == 4 && i2 != 2)) || (i5 == 1 || i5 == 2 || (i5 == 4 && i3 != 2));
    }

    public static final Object F(InterfaceC2747vn interfaceC2747vn, Object obj, Object obj2, SC sc, InterfaceC0220Im interfaceC0220Im) {
        Object objF;
        Object objI = AbstractC1155f00.I(interfaceC2747vn, obj2);
        try {
            C1297ga0 c1297ga0 = new C1297ga0(interfaceC0220Im, interfaceC2747vn);
            if (sc == null) {
                objF = AbstractC2539te.Y(sc, obj, c1297ga0);
            } else {
                AbstractC1692kh0.l(2, sc);
                objF = sc.f(obj, c1297ga0);
            }
            AbstractC1155f00.C(interfaceC2747vn, objI);
            return objF;
        } catch (Throwable th) {
            AbstractC1155f00.C(interfaceC2747vn, objI);
            throw th;
        }
    }

    public static void G(int i2, Object[] objArr) {
        for (int i3 = 0; i3 < i2; i3++) {
            if (objArr[i3] == null) {
                throw new NullPointerException(AbstractC0126Ew.j(i3, "at index "));
            }
        }
    }

    public static final T00 a(UW uw, int i2, C1785lg0 c1785lg0, Ne0 ne0, boolean z, int i3) {
        T00 t00C = ne0 != null ? ne0.c(c1785lg0.b.p(i2)) : T00.e;
        float f2 = t00C.a;
        int iN = uw.N(Fd0.a);
        return new T00(z ? (i3 - f2) - iN : f2, t00C.b, z ? i3 - f2 : iN + f2, t00C.d);
    }

    /* JADX WARN: Removed duplicated region for block: B:11:0x001c  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static final float b(o.UW r6, boolean r7, o.C1751lF[] r8, float r9) {
        /*
            int r0 = r8.length
            r1 = 2143289344(0x7fc00000, float:NaN)
            r2 = 0
            r3 = r2
        L5:
            if (r3 >= r0) goto L20
            r4 = r8[r3]
            float r4 = r6.b(r4)
            boolean r5 = java.lang.Float.isNaN(r1)
            if (r5 != 0) goto L1c
            int r5 = (r4 > r1 ? 1 : (r4 == r1 ? 0 : -1))
            if (r5 <= 0) goto L19
            r5 = 1
            goto L1a
        L19:
            r5 = r2
        L1a:
            if (r7 != r5) goto L1d
        L1c:
            r1 = r4
        L1d:
            int r3 = r3 + 1
            goto L5
        L20:
            boolean r6 = java.lang.Float.isNaN(r1)
            if (r6 == 0) goto L27
            return r9
        L27:
            return r1
        */
        throw new UnsupportedOperationException("Method not decompiled: o.AbstractC2461sm0.b(o.UW, boolean, o.lF[], float):float");
    }

    public static void c(int i2, Object[] objArr) {
        for (int i3 = 0; i3 < i2; i3++) {
            if (objArr[i3] == null) {
                StringBuilder sb = new StringBuilder(20);
                sb.append("at index ");
                sb.append(i3);
                throw new NullPointerException(sb.toString());
            }
        }
    }

    public static final void d(int i2, int i3) {
        if (i2 <= i3) {
            return;
        }
        throw new IndexOutOfBoundsException("toIndex (" + i2 + ") is greater than size (" + i3 + ").");
    }

    /* JADX WARN: Multi-variable type inference failed */
    public static final Object j(InterfaceC0581Wk interfaceC0581Wk, AbstractC3005yZ abstractC3005yZ) {
        if (!((LP) interfaceC0581Wk).l.y) {
            AbstractC2133pH.b("Cannot read CompositionLocal because the Modifier node is not currently attached.");
        }
        C3097zW c3097zW = (C3097zW) AbstractC2539te.S(interfaceC0581Wk).L;
        c3097zW.getClass();
        return AbstractC0940cn0.F(c3097zW, abstractC3005yZ);
    }

    public static Zk0 m(C0530Ul c0530Ul, int i2, ArrayList arrayList, Zk0 zk0) {
        int i3;
        int i4 = i2 == 0 ? c0530Ul.n0 : c0530Ul.o0;
        if (i4 != -1 && (zk0 == null || i4 != zk0.b)) {
            int i5 = 0;
            while (true) {
                if (i5 >= arrayList.size()) {
                    break;
                }
                Zk0 zk02 = (Zk0) arrayList.get(i5);
                if (zk02.b == i4) {
                    if (zk0 != null) {
                        zk0.c(i2, zk02);
                        arrayList.remove(zk0);
                    }
                    zk0 = zk02;
                } else {
                    i5++;
                }
            }
        } else if (i4 != -1) {
            return zk0;
        }
        if (zk0 == null) {
            if (c0530Ul instanceof AbstractC0701aF) {
                AbstractC0701aF abstractC0701aF = (AbstractC0701aF) c0530Ul;
                int i6 = 0;
                while (true) {
                    if (i6 >= abstractC0701aF.r0) {
                        i3 = -1;
                        break;
                    }
                    C0530Ul c0530Ul2 = abstractC0701aF.q0[i6];
                    if ((i2 == 0 && (i3 = c0530Ul2.n0) != -1) || (i2 == 1 && (i3 = c0530Ul2.o0) != -1)) {
                        break;
                    }
                    i6++;
                }
                if (i3 != -1) {
                    int i7 = 0;
                    while (true) {
                        if (i7 >= arrayList.size()) {
                            break;
                        }
                        Zk0 zk03 = (Zk0) arrayList.get(i7);
                        if (zk03.b == i3) {
                            zk0 = zk03;
                            break;
                        }
                        i7++;
                    }
                }
            }
            if (zk0 == null) {
                zk0 = new Zk0();
                zk0.a = new ArrayList();
                zk0.d = null;
                zk0.e = -1;
                int i8 = Zk0.f;
                Zk0.f = i8 + 1;
                zk0.b = i8;
                zk0.c = i2;
            }
            arrayList.add(zk0);
        }
        int i9 = zk0.b;
        ArrayList arrayList2 = zk0.a;
        if (arrayList2.contains(c0530Ul)) {
            return zk0;
        }
        arrayList2.add(c0530Ul);
        if (c0530Ul instanceof C2604uE) {
            C2604uE c2604uE = (C2604uE) c0530Ul;
            c2604uE.t0.c(c2604uE.u0 == 0 ? 1 : 0, arrayList, zk0);
        }
        if (i2 == 0) {
            c0530Ul.n0 = i9;
            c0530Ul.I.c(i2, arrayList, zk0);
            c0530Ul.K.c(i2, arrayList, zk0);
        } else {
            c0530Ul.o0 = i9;
            c0530Ul.J.c(i2, arrayList, zk0);
            c0530Ul.M.c(i2, arrayList, zk0);
            c0530Ul.L.c(i2, arrayList, zk0);
        }
        c0530Ul.P.c(i2, arrayList, zk0);
        return zk0;
    }

    public static final int n(CharSequence charSequence, int i2) {
        int length = charSequence.length();
        while (i2 < length) {
            if (charSequence.charAt(i2) == '\n') {
                return i2;
            }
            i2++;
        }
        return charSequence.length();
    }

    public static final int o(CharSequence charSequence, int i2) {
        while (i2 > 0) {
            if (charSequence.charAt(i2 - 1) == '\n') {
                return i2;
            }
            i2--;
        }
        return 0;
    }

    public static final InterfaceC0898cL p(View view) {
        while (view != null) {
            Object tag = view.getTag(R.id.view_tree_lifecycle_owner);
            InterfaceC0898cL interfaceC0898cL = tag instanceof InterfaceC0898cL ? (InterfaceC0898cL) tag : null;
            if (interfaceC0898cL != null) {
                return interfaceC0898cL;
            }
            Object objV = AbstractC1692kh0.v(view);
            view = objV instanceof View ? (View) objV : null;
        }
        return null;
    }

    public static ColorStateList q(Context context, TypedArray typedArray, int i2) {
        int resourceId;
        ColorStateList colorStateListZ;
        return (!typedArray.hasValue(i2) || (resourceId = typedArray.getResourceId(i2, 0)) == 0 || (colorStateListZ = Co0.z(context, resourceId)) == null) ? typedArray.getColorStateList(i2) : colorStateListZ;
    }

    public static ColorStateList r(Context context, C70 c70, int i2) {
        int resourceId;
        ColorStateList colorStateListZ;
        TypedArray typedArray = (TypedArray) c70.n;
        return (!typedArray.hasValue(i2) || (resourceId = typedArray.getResourceId(i2, 0)) == 0 || (colorStateListZ = Co0.z(context, resourceId)) == null) ? c70.l(i2) : colorStateListZ;
    }

    public static final CG s() {
        CG cg = i;
        if (cg != null) {
            return cg;
        }
        BG bg = new BG("Filled.CreditCard", 24.0f, 24.0f, 24.0f, 24.0f, 0L, 0, false, 96);
        int i2 = Zi0.a;
        Q90 q90 = new Q90(C0190Hi.b);
        KE ke = new KE(1);
        ke.l(20.0f, 4.0f);
        ke.j(4.0f, 4.0f);
        ke.g(-1.11f, 0.0f, -1.99f, 0.89f, -1.99f, 2.0f);
        ke.j(2.0f, 18.0f);
        ke.g(0.0f, 1.11f, 0.89f, 2.0f, 2.0f, 2.0f);
        ke.i(16.0f);
        ke.g(1.11f, 0.0f, 2.0f, -0.89f, 2.0f, -2.0f);
        ke.j(22.0f, 6.0f);
        ke.g(0.0f, -1.11f, -0.89f, -2.0f, -2.0f, -2.0f);
        ke.e();
        ke.l(20.0f, 18.0f);
        ke.j(4.0f, 18.0f);
        ke.r(-6.0f);
        ke.i(16.0f);
        ke.r(6.0f);
        ke.e();
        ke.l(20.0f, 8.0f);
        ke.j(4.0f, 8.0f);
        ke.j(4.0f, 6.0f);
        ke.i(16.0f);
        ke.r(2.0f);
        ke.e();
        BG.a(bg, ke.a, q90);
        CG cgB = bg.b();
        i = cgB;
        return cgB;
    }

    public static Drawable t(Context context, TypedArray typedArray, int i2) {
        int resourceId;
        Drawable drawableX;
        return (!typedArray.hasValue(i2) || (resourceId = typedArray.getResourceId(i2, 0)) == 0 || (drawableX = C80.x(context, resourceId)) == null) ? typedArray.getDrawable(i2) : drawableX;
    }

    public static final float u(Layout layout, int i2, Paint paint) {
        float fAbs;
        float width;
        float lineLeft = layout.getLineLeft(i2);
        C0729ad0 c0729ad0 = Pe0.a;
        if (layout.getEllipsisCount(i2) <= 0 || layout.getParagraphDirection(i2) != 1 || lineLeft >= 0.0f) {
            return 0.0f;
        }
        float fMeasureText = paint.measureText("…") + (layout.getPrimaryHorizontal(layout.getEllipsisStart(i2) + layout.getLineStart(i2)) - lineLeft);
        Layout.Alignment paragraphAlignment = layout.getParagraphAlignment(i2);
        if ((paragraphAlignment == null ? -1 : ZG.a[paragraphAlignment.ordinal()]) == 1) {
            fAbs = Math.abs(lineLeft);
            width = (layout.getWidth() - fMeasureText) / 2.0f;
        } else {
            fAbs = Math.abs(lineLeft);
            width = layout.getWidth() - fMeasureText;
        }
        return width + fAbs;
    }

    public static final float v(Layout layout, int i2, Paint paint) {
        float width;
        float width2;
        C0729ad0 c0729ad0 = Pe0.a;
        if (layout.getEllipsisCount(i2) <= 0) {
            return 0.0f;
        }
        if (layout.getParagraphDirection(i2) != -1 || layout.getWidth() >= layout.getLineRight(i2)) {
            return 0.0f;
        }
        float fMeasureText = paint.measureText("…") + (layout.getLineRight(i2) - layout.getPrimaryHorizontal(layout.getEllipsisStart(i2) + layout.getLineStart(i2)));
        Layout.Alignment paragraphAlignment = layout.getParagraphAlignment(i2);
        if ((paragraphAlignment != null ? ZG.a[paragraphAlignment.ordinal()] : -1) == 1) {
            width = layout.getWidth() - layout.getLineRight(i2);
            width2 = (layout.getWidth() - fMeasureText) / 2.0f;
        } else {
            width = layout.getWidth() - layout.getLineRight(i2);
            width2 = layout.getWidth() - fMeasureText;
        }
        return width - width2;
    }

    public static boolean w() {
        try {
            if (C2207q3.S0 == null) {
                C2207q3.S0 = Class.forName("android.os.SystemProperties");
            }
            if (C2207q3.T0 == null) {
                Class cls = C2207q3.S0;
                C2207q3.T0 = cls != null ? cls.getDeclaredMethod("getBoolean", String.class, Boolean.TYPE) : null;
            }
            Method method = C2207q3.T0;
            Object objInvoke = method != null ? method.invoke(null, "debug.layout", Boolean.FALSE) : null;
            return F3.c(objInvoke instanceof Boolean ? (Boolean) objInvoke : null, Boolean.TRUE);
        } catch (Exception unused) {
            return false;
        }
    }

    public static final int x(Layout layout, int i2, boolean z) {
        if (i2 <= 0) {
            return 0;
        }
        if (i2 >= layout.getText().length()) {
            return layout.getLineCount() - 1;
        }
        int lineForOffset = layout.getLineForOffset(i2);
        int lineStart = layout.getLineStart(lineForOffset);
        int lineEnd = layout.getLineEnd(lineForOffset);
        if (lineStart == i2 || lineEnd == i2) {
            if (lineStart == i2) {
                if (z) {
                    return lineForOffset - 1;
                }
            } else if (!z) {
                return lineForOffset + 1;
            }
        }
        return lineForOffset;
    }

    public static final EJ y(EJ ej) {
        return ej.d().h() ? ej : new ZS(ej);
    }

    public static SharedPreferences z(Context context) {
        Context applicationContext = context.getApplicationContext();
        if (applicationContext != null) {
            context = applicationContext;
        }
        return context.getSharedPreferences("com.google.firebase.messaging", 0);
    }

    public abstract Typeface e(Context context, GA ga, Resources resources, int i2);

    public abstract Typeface f(Context context, QA[] qaArr, int i2);

    public Typeface g(Context context, List list, int i2) {
        throw new IllegalStateException("createFromFontInfoWithFallback must only be called on API 29+");
    }

    public Typeface h(Context context, InputStream inputStream) {
        File fileX = AbstractC2841wm0.x(context);
        if (fileX == null) {
            return null;
        }
        try {
            if (AbstractC2841wm0.n(fileX, inputStream)) {
                return Typeface.createFromFile(fileX.getPath());
            }
            return null;
        } catch (RuntimeException unused) {
            return null;
        } finally {
            fileX.delete();
        }
    }

    public Typeface i(Context context, Resources resources, int i2, String str, int i3) {
        File fileX = AbstractC2841wm0.x(context);
        if (fileX == null) {
            return null;
        }
        try {
            if (AbstractC2841wm0.m(fileX, resources, i2)) {
                return Typeface.createFromFile(fileX.getPath());
            }
            return null;
        } catch (RuntimeException unused) {
            return null;
        } finally {
            fileX.delete();
        }
    }

    public void k(VT vt) {
        List listSingletonList = Collections.singletonList(vt);
        C2651um0 c2651um0 = (C2651um0) this;
        if (listSingletonList.isEmpty()) {
            throw new IllegalArgumentException("enqueue needs at least one WorkRequest.");
        }
        C1797lm0 c1797lm0 = new C1797lm0(c2651um0, listSingletonList);
        if (!c1797lm0.B) {
            c2651um0.n.c(new RunnableC1816lw(c1797lm0));
        } else {
            C0669Zu c0669ZuE = C0669Zu.e();
            TextUtils.join(", ", c1797lm0.z);
            c0669ZuE.getClass();
        }
    }

    public QA l(QA[] qaArr, int i2) {
        new BP(22);
        int i3 = (i2 & 1) == 0 ? 400 : 700;
        boolean z = (i2 & 2) != 0;
        QA qa = null;
        int i4 = Api.BaseClientBuilder.API_PRIORITY_OTHER;
        for (QA qa2 : qaArr) {
            int iAbs = (Math.abs(qa2.c - i3) * 2) + (qa2.d == z ? 0 : 1);
            if (qa == null || i4 > iAbs) {
                qa = qa2;
                i4 = iAbs;
            }
        }
        return qa;
    }
}
