package j;

import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.ColorFilter;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.SparseArray;
import android.util.StateSet;
import q.g;
import q.h;
import q.j;
import r.AbstractC1481a;

/* JADX INFO: renamed from: j.b, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C1057b extends Drawable.ConstantState {

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    public boolean f13602A;

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    public ColorFilter f13603B;

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    public boolean f13604C;
    public ColorStateList D;

    /* JADX INFO: renamed from: E, reason: collision with root package name */
    public PorterDuff.Mode f13605E;

    /* JADX INFO: renamed from: F, reason: collision with root package name */
    public boolean f13606F;

    /* JADX INFO: renamed from: G, reason: collision with root package name */
    public boolean f13607G;
    public int[][] H;

    /* JADX INFO: renamed from: I, reason: collision with root package name */
    public g f13608I;

    /* JADX INFO: renamed from: J, reason: collision with root package name */
    public j f13609J;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final C1060e f13610a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Resources f13611b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f13612c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f13613d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public int f13614e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public SparseArray f13615f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public Drawable[] f13616g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f13617h;
    public boolean i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public boolean f13618j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public Rect f13619k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public boolean f13620l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public boolean f13621m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public int f13622n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public int f13623o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public int f13624p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public int f13625q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public boolean f13626r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public int f13627s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public boolean f13628t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public boolean f13629u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public boolean f13630v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public boolean f13631w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public int f13632x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public int f13633y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public int f13634z;

    public C1057b(C1057b c1057b, C1060e c1060e, Resources resources) {
        this.i = false;
        this.f13620l = false;
        this.f13631w = true;
        this.f13633y = 0;
        this.f13634z = 0;
        this.f13610a = c1060e;
        this.f13611b = resources != null ? resources : c1057b != null ? c1057b.f13611b : null;
        int i = c1057b != null ? c1057b.f13612c : 0;
        int i5 = C1060e.f13640J;
        i = resources != null ? resources.getDisplayMetrics().densityDpi : i;
        i = i == 0 ? 160 : i;
        this.f13612c = i;
        if (c1057b != null) {
            this.f13613d = c1057b.f13613d;
            this.f13614e = c1057b.f13614e;
            this.f13629u = true;
            this.f13630v = true;
            this.i = c1057b.i;
            this.f13620l = c1057b.f13620l;
            this.f13631w = c1057b.f13631w;
            this.f13632x = c1057b.f13632x;
            this.f13633y = c1057b.f13633y;
            this.f13634z = c1057b.f13634z;
            this.f13602A = c1057b.f13602A;
            this.f13603B = c1057b.f13603B;
            this.f13604C = c1057b.f13604C;
            this.D = c1057b.D;
            this.f13605E = c1057b.f13605E;
            this.f13606F = c1057b.f13606F;
            this.f13607G = c1057b.f13607G;
            if (c1057b.f13612c == i) {
                if (c1057b.f13618j) {
                    this.f13619k = c1057b.f13619k != null ? new Rect(c1057b.f13619k) : null;
                    this.f13618j = true;
                }
                if (c1057b.f13621m) {
                    this.f13622n = c1057b.f13622n;
                    this.f13623o = c1057b.f13623o;
                    this.f13624p = c1057b.f13624p;
                    this.f13625q = c1057b.f13625q;
                    this.f13621m = true;
                }
            }
            if (c1057b.f13626r) {
                this.f13627s = c1057b.f13627s;
                this.f13626r = true;
            }
            if (c1057b.f13628t) {
                this.f13628t = true;
            }
            Drawable[] drawableArr = c1057b.f13616g;
            this.f13616g = new Drawable[drawableArr.length];
            this.f13617h = c1057b.f13617h;
            SparseArray sparseArray = c1057b.f13615f;
            if (sparseArray != null) {
                this.f13615f = sparseArray.clone();
            } else {
                this.f13615f = new SparseArray(this.f13617h);
            }
            int i8 = this.f13617h;
            for (int i9 = 0; i9 < i8; i9++) {
                Drawable drawable = drawableArr[i9];
                if (drawable != null) {
                    Drawable.ConstantState constantState = drawable.getConstantState();
                    if (constantState != null) {
                        this.f13615f.put(i9, constantState);
                    } else {
                        this.f13616g[i9] = drawableArr[i9];
                    }
                }
            }
        } else {
            this.f13616g = new Drawable[10];
            this.f13617h = 0;
        }
        if (c1057b != null) {
            this.H = c1057b.H;
        } else {
            this.H = new int[this.f13616g.length][];
        }
        if (c1057b != null) {
            this.f13608I = c1057b.f13608I;
            this.f13609J = c1057b.f13609J;
        } else {
            this.f13608I = new g();
            this.f13609J = new j(0);
        }
    }

    public final int a(Drawable drawable) {
        int i = this.f13617h;
        if (i >= this.f13616g.length) {
            int i5 = i + 10;
            Drawable[] drawableArr = new Drawable[i5];
            Drawable[] drawableArr2 = this.f13616g;
            if (drawableArr2 != null) {
                System.arraycopy(drawableArr2, 0, drawableArr, 0, i);
            }
            this.f13616g = drawableArr;
            int[][] iArr = new int[i5][];
            System.arraycopy(this.H, 0, iArr, 0, i);
            this.H = iArr;
        }
        drawable.mutate();
        drawable.setVisible(false, true);
        drawable.setCallback(this.f13610a);
        this.f13616g[i] = drawable;
        this.f13617h++;
        this.f13614e = drawable.getChangingConfigurations() | this.f13614e;
        this.f13626r = false;
        this.f13628t = false;
        this.f13619k = null;
        this.f13618j = false;
        this.f13621m = false;
        this.f13629u = false;
        return i;
    }

    public final void b() {
        this.f13621m = true;
        c();
        int i = this.f13617h;
        Drawable[] drawableArr = this.f13616g;
        this.f13623o = -1;
        this.f13622n = -1;
        this.f13625q = 0;
        this.f13624p = 0;
        for (int i5 = 0; i5 < i; i5++) {
            Drawable drawable = drawableArr[i5];
            int intrinsicWidth = drawable.getIntrinsicWidth();
            if (intrinsicWidth > this.f13622n) {
                this.f13622n = intrinsicWidth;
            }
            int intrinsicHeight = drawable.getIntrinsicHeight();
            if (intrinsicHeight > this.f13623o) {
                this.f13623o = intrinsicHeight;
            }
            int minimumWidth = drawable.getMinimumWidth();
            if (minimumWidth > this.f13624p) {
                this.f13624p = minimumWidth;
            }
            int minimumHeight = drawable.getMinimumHeight();
            if (minimumHeight > this.f13625q) {
                this.f13625q = minimumHeight;
            }
        }
    }

    public final void c() {
        SparseArray sparseArray = this.f13615f;
        if (sparseArray != null) {
            int size = sparseArray.size();
            for (int i = 0; i < size; i++) {
                int iKeyAt = this.f13615f.keyAt(i);
                Drawable.ConstantState constantState = (Drawable.ConstantState) this.f13615f.valueAt(i);
                Drawable[] drawableArr = this.f13616g;
                Drawable drawableNewDrawable = constantState.newDrawable(this.f13611b);
                drawableNewDrawable.setLayoutDirection(this.f13632x);
                Drawable drawableMutate = drawableNewDrawable.mutate();
                drawableMutate.setCallback(this.f13610a);
                drawableArr[iKeyAt] = drawableMutate;
            }
            this.f13615f = null;
        }
    }

    @Override // android.graphics.drawable.Drawable.ConstantState
    public final boolean canApplyTheme() {
        int i = this.f13617h;
        Drawable[] drawableArr = this.f13616g;
        for (int i5 = 0; i5 < i; i5++) {
            Drawable drawable = drawableArr[i5];
            if (drawable == null) {
                Drawable.ConstantState constantState = (Drawable.ConstantState) this.f13615f.get(i5);
                if (constantState != null && constantState.canApplyTheme()) {
                    return true;
                }
            } else if (drawable.canApplyTheme()) {
                return true;
            }
        }
        return false;
    }

    public final Drawable d(int i) {
        int iIndexOfKey;
        Drawable drawable = this.f13616g[i];
        if (drawable != null) {
            return drawable;
        }
        SparseArray sparseArray = this.f13615f;
        if (sparseArray == null || (iIndexOfKey = sparseArray.indexOfKey(i)) < 0) {
            return null;
        }
        Drawable drawableNewDrawable = ((Drawable.ConstantState) this.f13615f.valueAt(iIndexOfKey)).newDrawable(this.f13611b);
        drawableNewDrawable.setLayoutDirection(this.f13632x);
        Drawable drawableMutate = drawableNewDrawable.mutate();
        drawableMutate.setCallback(this.f13610a);
        this.f13616g[i] = drawableMutate;
        this.f13615f.removeAt(iIndexOfKey);
        if (this.f13615f.size() == 0) {
            this.f13615f = null;
        }
        return drawableMutate;
    }

    public final int e(int i) {
        Object obj;
        if (i < 0) {
            return 0;
        }
        j jVar = this.f13609J;
        Object obj2 = 0;
        int iA = AbstractC1481a.a(jVar.f16194t, i, jVar.f16192r);
        if (iA >= 0 && (obj = jVar.f16193s[iA]) != h.f16187b) {
            obj2 = obj;
        }
        return ((Integer) obj2).intValue();
    }

    public final int f(int[] iArr) {
        int[][] iArr2 = this.H;
        int i = this.f13617h;
        for (int i5 = 0; i5 < i; i5++) {
            if (StateSet.stateSetMatches(iArr2[i5], iArr)) {
                return i5;
            }
        }
        return -1;
    }

    @Override // android.graphics.drawable.Drawable.ConstantState
    public final int getChangingConfigurations() {
        return this.f13613d | this.f13614e;
    }

    @Override // android.graphics.drawable.Drawable.ConstantState
    public final Drawable newDrawable() {
        return new C1060e(this, null);
    }

    @Override // android.graphics.drawable.Drawable.ConstantState
    public final Drawable newDrawable(Resources resources) {
        return new C1060e(this, resources);
    }
}
