package ῲ.ῲ.㴹;

import android.annotation.SuppressLint;
import android.graphics.Insets;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.DrawableContainer;
import android.graphics.drawable.ScaleDrawable;
import android.os.Build;
import android.util.Log;
import com.facebook.appevents.internal.ViewHierarchyConstants;
import java.lang.reflect.Field;
import ῲ.ᨨ.ʬ.ᕣ.AbstractC1712;
import ῲ.ᨨ.ʬ.ᕣ.C1710;
import ῲ.ῲ.ʬ.K.C1872;
import K.K.K.ʬ.C2369;

@SuppressLint({"RestrictedAPI"})
/* renamed from: ῲ.ῲ.㴹.ᓣ  reason: contains not printable characters */
/* compiled from: DrawableUtils */
public class C2021 {

    /* renamed from: ʬ  reason: contains not printable characters */
    public static final Rect f6849 = new Rect();

    /* renamed from: ῲ  reason: contains not printable characters */
    public static final int[] f6850 = new int[0];

    /* renamed from: K  reason: contains not printable characters */
    public static final int[] f6851 = {16842912};

    /* renamed from: 㸾  reason: contains not printable characters */
    public static Class<?> f6852;

    static {
        int i = Build.VERSION.SDK_INT;
        try {
            f6852 = Class.forName("android.graphics.Insets");
        } catch (ClassNotFoundException unused) {
        }
    }

    /* renamed from: ʬ  reason: contains not printable characters */
    public static Rect m5240(Drawable drawable) {
        if (Build.VERSION.SDK_INT >= 29) {
            Insets opticalInsets = drawable.getOpticalInsets();
            Rect rect = new Rect();
            rect.left = opticalInsets.left;
            rect.right = opticalInsets.right;
            rect.top = opticalInsets.top;
            rect.bottom = opticalInsets.bottom;
            return rect;
        }
        if (f6852 != null) {
            try {
                Drawable r12 = C2369.m6352(drawable);
                Object invoke = r12.getClass().getMethod("getOpticalInsets", new Class[0]).invoke(r12, new Object[0]);
                if (invoke != null) {
                    Rect rect2 = new Rect();
                    Field[] fields = f6852.getFields();
                    for (Field field : fields) {
                        String name = field.getName();
                        char c = 65535;
                        switch (name.hashCode()) {
                            case -1383228885:
                                if (name.equals("bottom")) {
                                    c = 3;
                                    break;
                                }
                                break;
                            case 115029:
                                if (name.equals(ViewHierarchyConstants.DIMENSION_TOP_KEY)) {
                                    c = 1;
                                    break;
                                }
                                break;
                            case 3317767:
                                if (name.equals(ViewHierarchyConstants.DIMENSION_LEFT_KEY)) {
                                    c = 0;
                                    break;
                                }
                                break;
                            case 108511772:
                                if (name.equals("right")) {
                                    c = 2;
                                    break;
                                }
                                break;
                        }
                        if (c == 0) {
                            rect2.left = field.getInt(invoke);
                        } else if (c == 1) {
                            rect2.top = field.getInt(invoke);
                        } else if (c == 2) {
                            rect2.right = field.getInt(invoke);
                        } else if (c == 3) {
                            rect2.bottom = field.getInt(invoke);
                        }
                    }
                    return rect2;
                }
            } catch (Exception unused) {
                Log.e("DrawableUtils", "Couldn't obtain the optical insets. Ignoring.");
            }
        }
        return f6849;
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public static void m5241(Drawable drawable) {
        int i = Build.VERSION.SDK_INT;
    }

    /* renamed from: K  reason: contains not printable characters */
    public static boolean m5243(Drawable drawable) {
        int i = Build.VERSION.SDK_INT;
        if (drawable instanceof DrawableContainer) {
            Drawable.ConstantState constantState = drawable.getConstantState();
            if (!(constantState instanceof DrawableContainer.DrawableContainerState)) {
                return true;
            }
            for (Drawable drawable2 : ((DrawableContainer.DrawableContainerState) constantState).getChildren()) {
                if (!m5243(drawable2)) {
                    return false;
                }
            }
            return true;
        } else if (drawable instanceof AbstractC1712) {
            return m5243(((C1710) drawable).f6010);
        } else {
            if (drawable instanceof C1872) {
                return m5243(((C1872) drawable).getWrappedDrawable());
            }
            if (drawable instanceof ScaleDrawable) {
                return m5243(((ScaleDrawable) drawable).getDrawable());
            }
            return true;
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public static PorterDuff.Mode m5242(int i, PorterDuff.Mode mode) {
        if (i == 3) {
            return PorterDuff.Mode.SRC_OVER;
        }
        if (i == 5) {
            return PorterDuff.Mode.SRC_IN;
        }
        if (i == 9) {
            return PorterDuff.Mode.SRC_ATOP;
        }
        switch (i) {
            case 14:
                return PorterDuff.Mode.MULTIPLY;
            case 15:
                return PorterDuff.Mode.SCREEN;
            case 16:
                return PorterDuff.Mode.ADD;
            default:
                return mode;
        }
    }
}
