package s7;

import D1.C0080e;
import E1.C0096c;
import E1.F;
import F7.C0138w;
import O6.p;
import Z6.AbstractC0385z;
import Z6.C0369i;
import Z6.C0377q;
import android.animation.ValueAnimator;
import android.app.AppOpsManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Process;
import android.os.Trace;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewOutlineProvider;
import android.view.animation.AccelerateInterpolator;
import androidx.leanback.widget.C0456b0;
import c2.AbstractC0577a;
import com.google.android.gms.internal.measurement.C1;
import com.martsnew.tv.R;
import com.martsnew.tv.customviews.CustomNavigationView;
import e7.q;
import g3.o;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.concurrent.CancellationException;
import y5.AbstractActivityC1764i;

/* JADX INFO: loaded from: classes.dex */
public abstract class d {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final /* synthetic */ int f16916b = 0;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final /* synthetic */ int f16917c = 0;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static SparseArray f16918d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static long f16919e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static Method f16920f;

    public static void A(View view, int i) {
        if (f16918d == null) {
            f16918d = new SparseArray();
        }
        ViewOutlineProvider viewOutlineProvider = (ViewOutlineProvider) f16918d.get(i);
        ViewOutlineProvider viewOutlineProvider2 = viewOutlineProvider;
        if (viewOutlineProvider == null) {
            C0456b0 c0456b0 = new C0456b0();
            c0456b0.f8629a = i;
            viewOutlineProvider2 = c0456b0;
            if (f16918d.size() < 32) {
                f16918d.put(i, c0456b0);
                viewOutlineProvider2 = c0456b0;
            }
        }
        view.setOutlineProvider(viewOutlineProvider2);
        view.setClipToOutline(true);
    }

    public static final Object B(q qVar, q qVar2, p pVar) throws Throwable {
        Object c0377q;
        Object objS;
        try {
            P6.p.b(2, pVar);
            c0377q = pVar.k(qVar2, qVar);
        } catch (Throwable th) {
            c0377q = new C0377q(th, false);
        }
        F6.a aVar = F6.a.f2580q;
        if (c0377q == aVar || (objS = qVar.S(c0377q)) == AbstractC0385z.f7568e) {
            return aVar;
        }
        qVar.j0();
        if (objS instanceof C0377q) {
            throw ((C0377q) objS).f7541a;
        }
        return AbstractC0385z.A(objS);
    }

    public static U6.a C(U6.c cVar, int i) {
        P6.g.e(cVar, "<this>");
        boolean z8 = i > 0;
        Integer numValueOf = Integer.valueOf(i);
        if (z8) {
            if (cVar.f6799s <= 0) {
                i = -i;
            }
            return new U6.a(cVar.f6797q, cVar.f6798r, i);
        }
        throw new IllegalArgumentException("Step must be positive, was: " + numValueOf + '.');
    }

    public static void D(byte[] bArr, long j8, int i) {
        int i5 = 0;
        while (i5 < 4) {
            bArr[i + i5] = (byte) (255 & j8);
            i5++;
            j8 >>= 8;
        }
    }

    public static final String E(int i) {
        int i5 = 0;
        if (i == 0) {
            return "0";
        }
        char[] cArr = y7.b.f19040a;
        char[] cArr2 = {cArr[(i >> 28) & 15], cArr[(i >> 24) & 15], cArr[(i >> 20) & 15], cArr[(i >> 16) & 15], cArr[(i >> 12) & 15], cArr[(i >> 8) & 15], cArr[(i >> 4) & 15], cArr[i & 15]};
        while (i5 < 8 && cArr2[i5] == '0') {
            i5++;
        }
        if (i5 < 0) {
            throw new IndexOutOfBoundsException(I1.a.k(i5, "startIndex: ", ", endIndex: 8, size: 8"));
        }
        if (i5 <= 8) {
            return new String(cArr2, i5, 8 - i5);
        }
        throw new IllegalArgumentException(I1.a.k(i5, "startIndex: ", " > endIndex: 8"));
    }

    public static String F(String str) {
        int length = str.length();
        int i = 0;
        while (i < length) {
            char cCharAt = str.charAt(i);
            if (cCharAt >= 'A' && cCharAt <= 'Z') {
                char[] charArray = str.toCharArray();
                while (i < length) {
                    char c3 = charArray[i];
                    if (c3 >= 'A' && c3 <= 'Z') {
                        charArray[i] = (char) (c3 ^ ' ');
                    }
                    i++;
                }
                return String.valueOf(charArray);
            }
            i++;
        }
        return str;
    }

    public static String G(String str) {
        int length = str.length();
        int i = 0;
        while (i < length) {
            char cCharAt = str.charAt(i);
            if (cCharAt >= 'a' && cCharAt <= 'z') {
                char[] charArray = str.toCharArray();
                while (i < length) {
                    char c3 = charArray[i];
                    if (c3 >= 'a' && c3 <= 'z') {
                        charArray[i] = (char) (c3 ^ ' ');
                    }
                    i++;
                }
                return String.valueOf(charArray);
            }
            i++;
        }
        return str;
    }

    public static U6.c H(int i, int i5) {
        if (i5 > Integer.MIN_VALUE) {
            return new U6.c(i, i5 - 1, 1);
        }
        U6.c cVar = U6.c.f6804t;
        return U6.c.f6804t;
    }

    public static long J(long j8) {
        return (j8 >>> 1) ^ (-(1 & j8));
    }

    public static final void a(n7.a aVar, n7.c cVar, String str) {
        n7.d.i.fine(cVar.f15537b + ' ' + String.format("%-22s", Arrays.copyOf(new Object[]{str}, 1)) + ": " + aVar.f15530a);
    }

    public static void b(CustomNavigationView customNavigationView, ValueAnimator valueAnimator) {
        P6.g.e(customNavigationView, "view");
        valueAnimator.addUpdateListener(new C0080e(customNavigationView, 1));
        valueAnimator.setInterpolator(new AccelerateInterpolator());
        valueAnimator.setDuration(100L);
        valueAnimator.start();
    }

    public static final boolean c(int i, int i5, int i8, byte[] bArr, byte[] bArr2) {
        P6.g.e(bArr, "a");
        P6.g.e(bArr2, "b");
        for (int i9 = 0; i9 < i8; i9++) {
            if (bArr[i9 + i] != bArr2[i9 + i5]) {
                return false;
            }
        }
        return true;
    }

    public static final Object d(o oVar, G6.c cVar) throws Exception {
        if (!oVar.h()) {
            C0369i c0369i = new C0369i(1, C1.A(cVar));
            c0369i.v();
            oVar.f12944b.j(new g3.m(j7.a.f13736q, new C0138w(c0369i, 3)));
            oVar.p();
            return c0369i.u();
        }
        Exception excF = oVar.f();
        if (excF != null) {
            throw excF;
        }
        if (!oVar.f12946d) {
            return oVar.g();
        }
        throw new CancellationException("Task " + oVar + " was cancelled normally.");
    }

    public static void e(String str) {
        if (str.length() > 127) {
            str = str.substring(0, 127);
        }
        Trace.beginSection(str);
    }

    public static final void g(long j8, long j9, long j10) {
        if ((j9 | j10) < 0 || j9 > j8 || j8 - j9 < j10) {
            throw new ArrayIndexOutOfBoundsException("size=" + j8 + " offset=" + j9 + " byteCount=" + j10);
        }
    }

    public static int h(Context context, String str) {
        boolean zA = true;
        if (str == null) {
            throw new NullPointerException("permission must be non-null");
        }
        int i = Build.VERSION.SDK_INT;
        if (i >= 33 || !TextUtils.equals("android.permission.POST_NOTIFICATIONS", str)) {
            return context.checkPermission(str, Process.myPid(), Process.myUid());
        }
        B.n nVar = new B.n(context);
        if (i >= 24) {
            zA = B.g.a(nVar.f506b);
        } else {
            AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService("appops");
            ApplicationInfo applicationInfo = context.getApplicationInfo();
            String packageName = context.getApplicationContext().getPackageName();
            int i5 = applicationInfo.uid;
            try {
                Class<?> cls = Class.forName(AppOpsManager.class.getName());
                Class<?> cls2 = Integer.TYPE;
                Method method = cls.getMethod("checkOpNoThrow", cls2, cls2, String.class);
                Integer num = (Integer) cls.getDeclaredField("OP_POST_NOTIFICATION").get(Integer.class);
                num.getClass();
                if (((Integer) method.invoke(appOpsManager, num, Integer.valueOf(i5), packageName)).intValue() != 0) {
                    zA = false;
                }
            } catch (ClassNotFoundException | IllegalAccessException | NoSuchFieldException | NoSuchMethodException | RuntimeException | InvocationTargetException unused) {
            }
        }
        return zA ? 0 : -1;
    }

    public static int i(int i, int i5) {
        if (i5 < 0) {
            throw new IllegalArgumentException(I1.a.k(i5, "Cannot coerce value to an empty range: maximum ", " is less than minimum 0."));
        }
        if (i < 0) {
            return 0;
        }
        return i > i5 ? i5 : i;
    }

    public static long j(long j8, long j9, long j10) {
        if (j9 <= j10) {
            return j8 < j9 ? j9 : j8 > j10 ? j10 : j8;
        }
        throw new IllegalArgumentException("Cannot coerce value to an empty range: maximum " + j10 + " is less than minimum " + j9 + '.');
    }

    public static byte[] k(byte[] bArr, byte[] bArr2) {
        if (bArr.length != 32) {
            throw new IllegalArgumentException("The key length in bytes must be 32.");
        }
        long jZ = z(0, bArr) & 67108863;
        int i = 3;
        long jZ2 = (z(3, bArr) >> 2) & 67108611;
        long jZ3 = (z(6, bArr) >> 4) & 67092735;
        long jZ4 = (z(9, bArr) >> 6) & 66076671;
        long jZ5 = (z(12, bArr) >> 8) & 1048575;
        long j8 = jZ2 * 5;
        long j9 = jZ3 * 5;
        long j10 = jZ4 * 5;
        long j11 = jZ5 * 5;
        byte[] bArr3 = new byte[17];
        long j12 = 0;
        long j13 = 0;
        long j14 = 0;
        long j15 = 0;
        long j16 = 0;
        int i5 = 0;
        while (i5 < bArr2.length) {
            int iMin = Math.min(16, bArr2.length - i5);
            System.arraycopy(bArr2, i5, bArr3, 0, iMin);
            bArr3[iMin] = 1;
            if (iMin != 16) {
                Arrays.fill(bArr3, iMin + 1, 17, (byte) 0);
            }
            long jZ6 = j16 + (z(0, bArr3) & 67108863);
            long jZ7 = j12 + ((z(i, bArr3) >> 2) & 67108863);
            long jZ8 = j13 + ((z(6, bArr3) >> 4) & 67108863);
            long jZ9 = j14 + ((z(9, bArr3) >> 6) & 67108863);
            long j17 = jZ2;
            long jZ10 = j15 + (((z(12, bArr3) >> 8) & 67108863) | ((long) (bArr3[16] << 24)));
            long j18 = (jZ10 * j8) + (jZ9 * j9) + (jZ8 * j10) + (jZ7 * j11) + (jZ6 * jZ);
            long j19 = (jZ10 * j9) + (jZ9 * j10) + (jZ8 * j11) + (jZ7 * jZ) + (jZ6 * j17);
            long j20 = (jZ10 * j10) + (jZ9 * j11) + (jZ8 * jZ) + (jZ7 * j17) + (jZ6 * jZ3);
            long j21 = (jZ10 * j11) + (jZ9 * jZ) + (jZ8 * j17) + (jZ7 * jZ3) + (jZ6 * jZ4);
            long j22 = jZ9 * j17;
            long j23 = jZ10 * jZ;
            long j24 = j19 + (j18 >> 26);
            long j25 = j20 + (j24 >> 26);
            long j26 = j21 + (j25 >> 26);
            long j27 = j23 + j22 + (jZ8 * jZ3) + (jZ7 * jZ4) + (jZ6 * jZ5) + (j26 >> 26);
            long j28 = j27 >> 26;
            j15 = j27 & 67108863;
            long j29 = (j28 * 5) + (j18 & 67108863);
            i5 += 16;
            j13 = j25 & 67108863;
            j14 = j26 & 67108863;
            j16 = j29 & 67108863;
            j12 = (j24 & 67108863) + (j29 >> 26);
            jZ2 = j17;
            i = 3;
        }
        long j30 = j13 + (j12 >> 26);
        long j31 = j30 & 67108863;
        long j32 = j14 + (j30 >> 26);
        long j33 = j32 & 67108863;
        long j34 = j15 + (j32 >> 26);
        long j35 = j34 & 67108863;
        long j36 = ((j34 >> 26) * 5) + j16;
        long j37 = j36 >> 26;
        long j38 = j36 & 67108863;
        long j39 = (j12 & 67108863) + j37;
        long j40 = j38 + 5;
        long j41 = j40 & 67108863;
        long j42 = j39 + (j40 >> 26);
        long j43 = j31 + (j42 >> 26);
        long j44 = j33 + (j43 >> 26);
        long j45 = j44 & 67108863;
        long j46 = (j35 + (j44 >> 26)) - 67108864;
        long j47 = j46 >> 63;
        long j48 = j38 & j47;
        long j49 = j39 & j47;
        long j50 = j31 & j47;
        long j51 = j33 & j47;
        long j52 = j35 & j47;
        long j53 = ~j47;
        long j54 = j49 | (j42 & 67108863 & j53);
        long j55 = j50 | (j43 & 67108863 & j53);
        long j56 = j51 | (j45 & j53);
        long j57 = (j48 | (j41 & j53) | (j54 << 26)) & 4294967295L;
        long j58 = ((j54 >> 6) | (j55 << 20)) & 4294967295L;
        long j59 = ((j55 >> 12) | (j56 << 14)) & 4294967295L;
        long j60 = ((j56 >> 18) | ((j52 | (j46 & j53)) << 8)) & 4294967295L;
        long jZ11 = z(16, bArr) + j57;
        long j61 = jZ11 & 4294967295L;
        long jZ12 = z(20, bArr) + j58 + (jZ11 >> 32);
        long jZ13 = z(24, bArr) + j59 + (jZ12 >> 32);
        long jZ14 = (z(28, bArr) + j60 + (jZ13 >> 32)) & 4294967295L;
        byte[] bArr4 = new byte[16];
        D(bArr4, j61, 0);
        D(bArr4, jZ12 & 4294967295L, 4);
        D(bArr4, jZ13 & 4294967295L, 8);
        D(bArr4, jZ14, 12);
        return bArr4;
    }

    public static boolean m(String str, String str2) {
        char c3;
        int length = str.length();
        if (str == str2) {
            return true;
        }
        if (length == str2.length()) {
            for (int i = 0; i < length; i++) {
                if (str.charAt(i) == str2.charAt(i) || ((c3 = (char) ((r3 | ' ') - 97)) < 26 && c3 == ((char) ((r4 | ' ') - 97)))) {
                }
            }
            return true;
        }
        return false;
    }

    public static final F n(AbstractActivityC1764i abstractActivityC1764i) {
        View viewFindViewById;
        if (Build.VERSION.SDK_INT >= 28) {
            viewFindViewById = B.a.i(abstractActivityC1764i);
        } else {
            viewFindViewById = abstractActivityC1764i.findViewById(R.id.nav_host_fragment);
            if (viewFindViewById == null) {
                throw new IllegalArgumentException("ID does not reference a View inside this Activity");
            }
        }
        P6.g.d(viewFindViewById, "requireViewById<View>(activity, viewId)");
        F f3 = (F) W6.j.G(W6.j.F(new W6.f(W6.j.H(viewFindViewById, C0096c.f2070y), C0096c.f2071z, 3)));
        if (f3 != null) {
            return f3;
        }
        throw new IllegalStateException("Activity " + abstractActivityC1764i + " does not have a NavController set on 2131427945");
    }

    public static final String o(long j8) {
        return String.format("%6s", Arrays.copyOf(new Object[]{j8 <= -999500000 ? I1.a.q(new StringBuilder(), (j8 - ((long) 500000000)) / ((long) 1000000000), " s ") : j8 <= -999500 ? I1.a.q(new StringBuilder(), (j8 - ((long) 500000)) / ((long) 1000000), " ms") : j8 <= 0 ? I1.a.q(new StringBuilder(), (j8 - ((long) 500)) / ((long) 1000), " µs") : j8 < 999500 ? I1.a.q(new StringBuilder(), (j8 + ((long) 500)) / ((long) 1000), " µs") : j8 < 999500000 ? I1.a.q(new StringBuilder(), (j8 + ((long) 500000)) / ((long) 1000000), " ms") : I1.a.q(new StringBuilder(), (j8 + ((long) 500000000)) / ((long) 1000000000), " s ")}, 1));
    }

    /* JADX WARN: Code restructure failed: missing block: B:20:0x0046, code lost:
    
        if (r5.f1951c == r8.hashCode()) goto L21;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static ColorStateList p(Context context, int i) {
        ColorStateList colorStateListA;
        ColorStateList colorStateList;
        E.h hVar;
        Resources resources = context.getResources();
        Resources.Theme theme = context.getTheme();
        E.i iVar = new E.i(resources, theme);
        synchronized (E.j.f1956c) {
            try {
                SparseArray sparseArray = (SparseArray) E.j.f1955b.get(iVar);
                colorStateListA = null;
                if (sparseArray == null || sparseArray.size() <= 0 || (hVar = (E.h) sparseArray.get(i)) == null) {
                    colorStateList = null;
                } else {
                    if (hVar.f1950b.equals(resources.getConfiguration())) {
                        if (theme != null || hVar.f1951c != 0) {
                            if (theme != null) {
                            }
                        }
                        colorStateList = hVar.f1949a;
                    }
                    sparseArray.remove(i);
                    colorStateList = null;
                }
            } finally {
            }
        }
        if (colorStateList != null) {
            return colorStateList;
        }
        ThreadLocal threadLocal = E.j.f1954a;
        TypedValue typedValue = (TypedValue) threadLocal.get();
        if (typedValue == null) {
            typedValue = new TypedValue();
            threadLocal.set(typedValue);
        }
        resources.getValue(i, typedValue, true);
        int i5 = typedValue.type;
        if (i5 < 28 || i5 > 31) {
            try {
                colorStateListA = E.c.a(resources, resources.getXml(i), theme);
            } catch (Exception e8) {
                Log.w("ResourcesCompat", "Failed to inflate ColorStateList, leaving it to the framework", e8);
            }
        }
        if (colorStateListA == null) {
            return resources.getColorStateList(i, theme);
        }
        E.j.a(iVar, i, colorStateListA, theme);
        return colorStateListA;
    }

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

    public static ColorStateList r(Context context, com.google.android.material.datepicker.c cVar, int i) {
        int resourceId;
        ColorStateList colorStateListP;
        TypedArray typedArray = (TypedArray) cVar.f10220s;
        return (!typedArray.hasValue(i) || (resourceId = typedArray.getResourceId(i, 0)) == 0 || (colorStateListP = p(context, resourceId)) == null) ? cVar.t(i) : colorStateListP;
    }

    public static int s(Context context, TypedArray typedArray, int i, int i5) {
        TypedValue typedValue = new TypedValue();
        if (!typedArray.getValue(i, typedValue) || typedValue.type != 2) {
            return typedArray.getDimensionPixelSize(i, i5);
        }
        TypedArray typedArrayObtainStyledAttributes = context.getTheme().obtainStyledAttributes(new int[]{typedValue.data});
        int dimensionPixelSize = typedArrayObtainStyledAttributes.getDimensionPixelSize(0, i5);
        typedArrayObtainStyledAttributes.recycle();
        return dimensionPixelSize;
    }

    public static void t(G3.c cVar) {
        boolean z8 = false;
        if (!cVar.isDone()) {
            throw new IllegalStateException(U2.a.G("Future was expected to be done: %s", cVar));
        }
        while (true) {
            try {
                cVar.get();
                break;
            } catch (InterruptedException unused) {
                z8 = true;
            } catch (Throwable th) {
                if (z8) {
                    Thread.currentThread().interrupt();
                }
                throw th;
            }
        }
        if (z8) {
            Thread.currentThread().interrupt();
        }
    }

    public static Drawable u(Context context, TypedArray typedArray, int i) {
        int resourceId;
        Drawable drawableL;
        return (!typedArray.hasValue(i) || (resourceId = typedArray.getResourceId(i, 0)) == 0 || (drawableL = android.support.v4.media.session.a.l(context, resourceId)) == null) ? typedArray.getDrawable(i) : drawableL;
    }

    public static boolean w() {
        if (Build.VERSION.SDK_INT >= 29) {
            return AbstractC0577a.a();
        }
        try {
            if (f16920f == null) {
                f16919e = Trace.class.getField("TRACE_TAG_APP").getLong(null);
                f16920f = Trace.class.getMethod("isTagEnabled", Long.TYPE);
            }
            return ((Boolean) f16920f.invoke(null, Long.valueOf(f16919e))).booleanValue();
        } catch (Exception e8) {
            if (!(e8 instanceof InvocationTargetException)) {
                Log.v("Trace", "Unable to call isTagEnabled via reflection", e8);
                return false;
            }
            Throwable cause = e8.getCause();
            if (cause instanceof RuntimeException) {
                throw ((RuntimeException) cause);
            }
            throw new RuntimeException(cause);
        }
    }

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

    public static boolean y(MotionEvent motionEvent, int i) {
        return (motionEvent.getSource() & i) == i;
    }

    public static long z(int i, byte[] bArr) {
        return ((long) (((bArr[i + 3] & 255) << 24) | (bArr[i] & 255) | ((bArr[i + 1] & 255) << 8) | ((bArr[i + 2] & 255) << 16))) & 4294967295L;
    }

    public abstract void I(byte[] bArr, int i, int i5);

    public abstract void f(X1.c cVar, Object obj);

    public abstract String l();

    public void v(X1.a aVar, Object obj) {
        P6.g.e(aVar, "connection");
        X1.c cVarH0 = aVar.h0(l());
        try {
            f(cVarH0, obj);
            cVarH0.W();
            W3.b.j(cVarH0, null);
        } finally {
        }
    }
}
