package l;

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;

/* JADX INFO: loaded from: classes.dex */
public final class c0 {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final PorterDuff.Mode f29655b = PorterDuff.Mode.SRC_IN;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static c0 f29656c;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public o2 f29657a;

    public static synchronized c0 a() {
        try {
            if (f29656c == null) {
                d();
            }
        } catch (Throwable th) {
            throw th;
        }
        return f29656c;
    }

    public static synchronized PorterDuffColorFilter c(int i10, PorterDuff.Mode mode) {
        return o2.g(i10, mode);
    }

    public static synchronized void d() {
        if (f29656c == null) {
            c0 c0Var = new c0();
            f29656c = c0Var;
            c0Var.f29657a = o2.c();
            o2 o2Var = f29656c.f29657a;
            b0 b0Var = new b0(0);
            synchronized (o2Var) {
                o2Var.f29796e = b0Var;
            }
        }
    }

    public static void e(Drawable drawable, n3 n3Var, int[] iArr) {
        PorterDuff.Mode mode = o2.f29789f;
        int[] state = drawable.getState();
        if (drawable.mutate() == drawable) {
            if ((drawable instanceof LayerDrawable) && drawable.isStateful()) {
                drawable.setState(new int[0]);
                drawable.setState(state);
            }
            boolean z10 = n3Var.f29785d;
            if (!z10 && !n3Var.f29784c) {
                drawable.clearColorFilter();
                return;
            }
            PorterDuffColorFilter porterDuffColorFilterG = null;
            ColorStateList colorStateList = z10 ? n3Var.f29782a : null;
            PorterDuff.Mode mode2 = n3Var.f29784c ? n3Var.f29783b : o2.f29789f;
            if (colorStateList != null && mode2 != null) {
                porterDuffColorFilterG = o2.g(colorStateList.getColorForState(iArr, 0), mode2);
            }
            drawable.setColorFilter(porterDuffColorFilterG);
        }
    }

    public final synchronized Drawable b(Context context, int i10) {
        return this.f29657a.e(context, i10);
    }
}
