package o3;

import android.R;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.text.SpannableStringBuilder;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.TypedValue;
import com.google.android.material.chip.Chip;
import i3.C1052b;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import u3.C1599d;
import v3.AbstractC1674a;
import x3.C1713a;
import x3.j;

/* JADX INFO: renamed from: o3.e, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C1345e extends x3.g implements Drawable.Callback, s3.h {

    /* JADX INFO: renamed from: V0, reason: collision with root package name */
    public static final int[] f15655V0 = {R.attr.state_enabled};
    public static final ShapeDrawable W0 = new ShapeDrawable(new OvalShape());

    /* JADX INFO: renamed from: A0, reason: collision with root package name */
    public final s3.i f15656A0;

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: J0, reason: collision with root package name */
    public int f15665J0;
    public ColorFilter K0;

    /* JADX INFO: renamed from: L0, reason: collision with root package name */
    public PorterDuffColorFilter f15666L0;

    /* JADX INFO: renamed from: M0, reason: collision with root package name */
    public ColorStateList f15667M0;

    /* JADX INFO: renamed from: N, reason: collision with root package name */
    public ColorStateList f15668N;

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

    /* JADX INFO: renamed from: O, reason: collision with root package name */
    public ColorStateList f15670O;

    /* JADX INFO: renamed from: O0, reason: collision with root package name */
    public int[] f15671O0;

    /* JADX INFO: renamed from: P, reason: collision with root package name */
    public float f15672P;

    /* JADX INFO: renamed from: P0, reason: collision with root package name */
    public ColorStateList f15673P0;

    /* JADX INFO: renamed from: Q, reason: collision with root package name */
    public float f15674Q;

    /* JADX INFO: renamed from: Q0, reason: collision with root package name */
    public WeakReference f15675Q0;

    /* JADX INFO: renamed from: R, reason: collision with root package name */
    public ColorStateList f15676R;

    /* JADX INFO: renamed from: R0, reason: collision with root package name */
    public TextUtils.TruncateAt f15677R0;

    /* JADX INFO: renamed from: S, reason: collision with root package name */
    public float f15678S;

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

    /* JADX INFO: renamed from: T, reason: collision with root package name */
    public ColorStateList f15680T;

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

    /* JADX INFO: renamed from: U, reason: collision with root package name */
    public CharSequence f15682U;

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

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

    /* JADX INFO: renamed from: W, reason: collision with root package name */
    public Drawable f15685W;
    public ColorStateList X;

    /* JADX INFO: renamed from: Y, reason: collision with root package name */
    public float f15686Y;

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

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

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    public Drawable f15689b0;

    /* JADX INFO: renamed from: c0, reason: collision with root package name */
    public RippleDrawable f15690c0;

    /* JADX INFO: renamed from: d0, reason: collision with root package name */
    public ColorStateList f15691d0;

    /* JADX INFO: renamed from: e0, reason: collision with root package name */
    public float f15692e0;

    /* JADX INFO: renamed from: f0, reason: collision with root package name */
    public SpannableStringBuilder f15693f0;

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

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

    /* JADX INFO: renamed from: i0, reason: collision with root package name */
    public Drawable f15696i0;

    /* JADX INFO: renamed from: j0, reason: collision with root package name */
    public ColorStateList f15697j0;

    /* JADX INFO: renamed from: k0, reason: collision with root package name */
    public C1052b f15698k0;

    /* JADX INFO: renamed from: l0, reason: collision with root package name */
    public C1052b f15699l0;

    /* JADX INFO: renamed from: m0, reason: collision with root package name */
    public float f15700m0;

    /* JADX INFO: renamed from: n0, reason: collision with root package name */
    public float f15701n0;

    /* JADX INFO: renamed from: o0, reason: collision with root package name */
    public float f15702o0;

    /* JADX INFO: renamed from: p0, reason: collision with root package name */
    public float f15703p0;
    public float q0;

    /* JADX INFO: renamed from: r0, reason: collision with root package name */
    public float f15704r0;

    /* JADX INFO: renamed from: s0, reason: collision with root package name */
    public float f15705s0;

    /* JADX INFO: renamed from: t0, reason: collision with root package name */
    public float f15706t0;

    /* JADX INFO: renamed from: u0, reason: collision with root package name */
    public final Context f15707u0;

    /* JADX INFO: renamed from: v0, reason: collision with root package name */
    public final Paint f15708v0;

    /* JADX INFO: renamed from: w0, reason: collision with root package name */
    public final Paint.FontMetrics f15709w0;

    /* JADX INFO: renamed from: x0, reason: collision with root package name */
    public final RectF f15710x0;

    /* JADX INFO: renamed from: y0, reason: collision with root package name */
    public final PointF f15711y0;

    /* JADX INFO: renamed from: z0, reason: collision with root package name */
    public final Path f15712z0;

    public C1345e(Context context, AttributeSet attributeSet) {
        super(context, attributeSet, com.martsnew.tv.R.attr.chipStyle, com.martsnew.tv.R.style.Widget_MaterialComponents_Chip_Action);
        this.f15674Q = -1.0f;
        this.f15708v0 = new Paint(1);
        this.f15709w0 = new Paint.FontMetrics();
        this.f15710x0 = new RectF();
        this.f15711y0 = new PointF();
        this.f15712z0 = new Path();
        this.f15665J0 = 255;
        this.f15669N0 = PorterDuff.Mode.SRC_IN;
        this.f15675Q0 = new WeakReference(null);
        g(context);
        this.f15707u0 = context;
        s3.i iVar = new s3.i(this);
        this.f15656A0 = iVar;
        this.f15682U = "";
        iVar.f16850a.density = context.getResources().getDisplayMetrics().density;
        int[] iArr = f15655V0;
        setState(iArr);
        if (!Arrays.equals(this.f15671O0, iArr)) {
            this.f15671O0 = iArr;
            if (S()) {
                u(getState(), iArr);
            }
        }
        this.f15679S0 = true;
        int[] iArr2 = AbstractC1674a.f18096a;
        W0.setTint(-1);
    }

    public static void T(Drawable drawable) {
        if (drawable != null) {
            drawable.setCallback(null);
        }
    }

    public static boolean r(ColorStateList colorStateList) {
        return colorStateList != null && colorStateList.isStateful();
    }

    public static boolean s(Drawable drawable) {
        return drawable != null && drawable.isStateful();
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r0v1 */
    /* JADX WARN: Type inference failed for: r0v2, types: [android.graphics.drawable.Drawable] */
    /* JADX WARN: Type inference failed for: r0v6 */
    /* JADX WARN: Type inference failed for: r0v7 */
    public final void A(Drawable drawable) {
        ?? r02;
        Object obj = this.f15685W;
        if (obj != null) {
            boolean z8 = obj instanceof G.b;
            r02 = obj;
            if (z8) {
                r02 = 0;
            }
        } else {
            r02 = 0;
        }
        if (r02 != drawable) {
            float fO = o();
            this.f15685W = drawable != null ? drawable.mutate() : null;
            float fO2 = o();
            T(r02);
            if (R()) {
                m(this.f15685W);
            }
            invalidateSelf();
            if (fO != fO2) {
                t();
            }
        }
    }

    public final void B(float f3) {
        if (this.f15686Y != f3) {
            float fO = o();
            this.f15686Y = f3;
            float fO2 = o();
            invalidateSelf();
            if (fO != fO2) {
                t();
            }
        }
    }

    public final void C(ColorStateList colorStateList) {
        this.f15687Z = true;
        if (this.X != colorStateList) {
            this.X = colorStateList;
            if (R()) {
                this.f15685W.setTintList(colorStateList);
            }
            onStateChange(getState());
        }
    }

    public final void D(boolean z8) {
        if (this.f15684V != z8) {
            boolean zR = R();
            this.f15684V = z8;
            boolean zR2 = R();
            if (zR != zR2) {
                if (zR2) {
                    m(this.f15685W);
                } else {
                    T(this.f15685W);
                }
                invalidateSelf();
                t();
            }
        }
    }

    public final void E(ColorStateList colorStateList) {
        if (this.f15676R != colorStateList) {
            this.f15676R = colorStateList;
            if (this.f15683U0) {
                x3.f fVar = this.f18614q;
                if (fVar.f18591d != colorStateList) {
                    fVar.f18591d = colorStateList;
                    onStateChange(getState());
                }
            }
            onStateChange(getState());
        }
    }

    public final void F(float f3) {
        if (this.f15678S != f3) {
            this.f15678S = f3;
            this.f15708v0.setStrokeWidth(f3);
            if (this.f15683U0) {
                this.f18614q.f18596j = f3;
                invalidateSelf();
            }
            invalidateSelf();
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r1v1 */
    /* JADX WARN: Type inference failed for: r1v2, types: [android.graphics.drawable.Drawable] */
    /* JADX WARN: Type inference failed for: r1v4 */
    public final void G(Drawable drawable) {
        ?? r12;
        Object obj = this.f15689b0;
        if (obj != null) {
            boolean z8 = obj instanceof G.b;
            r12 = obj;
            if (z8) {
                r12 = 0;
            }
        } else {
            r12 = 0;
        }
        if (r12 != drawable) {
            float fP = p();
            this.f15689b0 = drawable != null ? drawable.mutate() : null;
            int[] iArr = AbstractC1674a.f18096a;
            this.f15690c0 = new RippleDrawable(AbstractC1674a.a(this.f15680T), this.f15689b0, W0);
            float fP2 = p();
            T(r12);
            if (S()) {
                m(this.f15689b0);
            }
            invalidateSelf();
            if (fP != fP2) {
                t();
            }
        }
    }

    public final void H(float f3) {
        if (this.f15705s0 != f3) {
            this.f15705s0 = f3;
            invalidateSelf();
            if (S()) {
                t();
            }
        }
    }

    public final void I(float f3) {
        if (this.f15692e0 != f3) {
            this.f15692e0 = f3;
            invalidateSelf();
            if (S()) {
                t();
            }
        }
    }

    public final void J(float f3) {
        if (this.f15704r0 != f3) {
            this.f15704r0 = f3;
            invalidateSelf();
            if (S()) {
                t();
            }
        }
    }

    public final void K(ColorStateList colorStateList) {
        if (this.f15691d0 != colorStateList) {
            this.f15691d0 = colorStateList;
            if (S()) {
                this.f15689b0.setTintList(colorStateList);
            }
            onStateChange(getState());
        }
    }

    public final void L(boolean z8) {
        if (this.f15688a0 != z8) {
            boolean zS = S();
            this.f15688a0 = z8;
            boolean zS2 = S();
            if (zS != zS2) {
                if (zS2) {
                    m(this.f15689b0);
                } else {
                    T(this.f15689b0);
                }
                invalidateSelf();
                t();
            }
        }
    }

    public final void M(float f3) {
        if (this.f15702o0 != f3) {
            float fO = o();
            this.f15702o0 = f3;
            float fO2 = o();
            invalidateSelf();
            if (fO != fO2) {
                t();
            }
        }
    }

    public final void N(float f3) {
        if (this.f15701n0 != f3) {
            float fO = o();
            this.f15701n0 = f3;
            float fO2 = o();
            invalidateSelf();
            if (fO != fO2) {
                t();
            }
        }
    }

    public final void O(ColorStateList colorStateList) {
        if (this.f15680T != colorStateList) {
            this.f15680T = colorStateList;
            this.f15673P0 = null;
            onStateChange(getState());
        }
    }

    public final void P(C1599d c1599d) {
        s3.i iVar = this.f15656A0;
        if (iVar.f16855f != c1599d) {
            iVar.f16855f = c1599d;
            if (c1599d != null) {
                TextPaint textPaint = iVar.f16850a;
                Context context = this.f15707u0;
                C1341a c1341a = iVar.f16851b;
                c1599d.f(context, textPaint, c1341a);
                s3.h hVar = (s3.h) iVar.f16854e.get();
                if (hVar != null) {
                    textPaint.drawableState = hVar.getState();
                }
                c1599d.e(context, textPaint, c1341a);
                iVar.f16853d = true;
            }
            s3.h hVar2 = (s3.h) iVar.f16854e.get();
            if (hVar2 != null) {
                C1345e c1345e = (C1345e) hVar2;
                c1345e.t();
                c1345e.invalidateSelf();
                c1345e.onStateChange(hVar2.getState());
            }
        }
    }

    public final boolean Q() {
        return this.f15695h0 && this.f15696i0 != null && this.f15663H0;
    }

    public final boolean R() {
        return this.f15684V && this.f15685W != null;
    }

    public final boolean S() {
        return this.f15688a0 && this.f15689b0 != null;
    }

    @Override // x3.g, android.graphics.drawable.Drawable
    public final void draw(Canvas canvas) {
        int i;
        Canvas canvas2;
        int iSaveLayerAlpha;
        float fMeasureText;
        int i5;
        Rect bounds = getBounds();
        if (bounds.isEmpty() || (i = this.f15665J0) == 0) {
            return;
        }
        if (i < 255) {
            canvas2 = canvas;
            iSaveLayerAlpha = canvas2.saveLayerAlpha(bounds.left, bounds.top, bounds.right, bounds.bottom, i);
        } else {
            canvas2 = canvas;
            iSaveLayerAlpha = 0;
        }
        boolean z8 = this.f15683U0;
        Paint paint = this.f15708v0;
        RectF rectF = this.f15710x0;
        if (!z8) {
            paint.setColor(this.f15657B0);
            paint.setStyle(Paint.Style.FILL);
            rectF.set(bounds);
            canvas2.drawRoundRect(rectF, q(), q(), paint);
        }
        if (!this.f15683U0) {
            paint.setColor(this.f15658C0);
            paint.setStyle(Paint.Style.FILL);
            ColorFilter colorFilter = this.K0;
            if (colorFilter == null) {
                colorFilter = this.f15666L0;
            }
            paint.setColorFilter(colorFilter);
            rectF.set(bounds);
            canvas2.drawRoundRect(rectF, q(), q(), paint);
        }
        if (this.f15683U0) {
            super.draw(canvas);
        }
        if (this.f15678S > 0.0f && !this.f15683U0) {
            paint.setColor(this.f15660E0);
            paint.setStyle(Paint.Style.STROKE);
            if (!this.f15683U0) {
                ColorFilter colorFilter2 = this.K0;
                if (colorFilter2 == null) {
                    colorFilter2 = this.f15666L0;
                }
                paint.setColorFilter(colorFilter2);
            }
            float f3 = bounds.left;
            float f7 = this.f15678S / 2.0f;
            rectF.set(f3 + f7, bounds.top + f7, bounds.right - f7, bounds.bottom - f7);
            float f8 = this.f15674Q - (this.f15678S / 2.0f);
            canvas2.drawRoundRect(rectF, f8, f8, paint);
        }
        paint.setColor(this.f15661F0);
        paint.setStyle(Paint.Style.FILL);
        rectF.set(bounds);
        if (this.f15683U0) {
            RectF rectF2 = new RectF(bounds);
            Path path = this.f15712z0;
            x3.f fVar = this.f18614q;
            this.H.b(fVar.f18588a, fVar.i, rectF2, this.f18609G, path);
            d(canvas2, paint, path, this.f18614q.f18588a, e());
        } else {
            canvas2.drawRoundRect(rectF, q(), q(), paint);
        }
        if (R()) {
            n(bounds, rectF);
            float f9 = rectF.left;
            float f10 = rectF.top;
            canvas2.translate(f9, f10);
            this.f15685W.setBounds(0, 0, (int) rectF.width(), (int) rectF.height());
            this.f15685W.draw(canvas2);
            canvas2.translate(-f9, -f10);
        }
        if (Q()) {
            n(bounds, rectF);
            float f11 = rectF.left;
            float f12 = rectF.top;
            canvas2.translate(f11, f12);
            this.f15696i0.setBounds(0, 0, (int) rectF.width(), (int) rectF.height());
            this.f15696i0.draw(canvas2);
            canvas2.translate(-f11, -f12);
        }
        if (this.f15679S0 && this.f15682U != null) {
            PointF pointF = this.f15711y0;
            pointF.set(0.0f, 0.0f);
            Paint.Align align = Paint.Align.LEFT;
            CharSequence charSequence = this.f15682U;
            s3.i iVar = this.f15656A0;
            if (charSequence != null) {
                float fO = o() + this.f15700m0 + this.f15703p0;
                if (getLayoutDirection() == 0) {
                    pointF.x = bounds.left + fO;
                } else {
                    pointF.x = bounds.right - fO;
                    align = Paint.Align.RIGHT;
                }
                float fCenterY = bounds.centerY();
                TextPaint textPaint = iVar.f16850a;
                Paint.FontMetrics fontMetrics = this.f15709w0;
                textPaint.getFontMetrics(fontMetrics);
                pointF.y = fCenterY - ((fontMetrics.descent + fontMetrics.ascent) / 2.0f);
            }
            rectF.setEmpty();
            if (this.f15682U != null) {
                float fO2 = o() + this.f15700m0 + this.f15703p0;
                float fP = p() + this.f15706t0 + this.q0;
                if (getLayoutDirection() == 0) {
                    rectF.left = bounds.left + fO2;
                    rectF.right = bounds.right - fP;
                } else {
                    rectF.left = bounds.left + fP;
                    rectF.right = bounds.right - fO2;
                }
                rectF.top = bounds.top;
                rectF.bottom = bounds.bottom;
            }
            C1599d c1599d = iVar.f16855f;
            TextPaint textPaint2 = iVar.f16850a;
            if (c1599d != null) {
                textPaint2.drawableState = getState();
                iVar.f16855f.e(this.f15707u0, textPaint2, iVar.f16851b);
            }
            textPaint2.setTextAlign(align);
            String string = this.f15682U.toString();
            if (iVar.f16853d) {
                fMeasureText = string == null ? 0.0f : textPaint2.measureText((CharSequence) string, 0, string.length());
                iVar.f16852c = fMeasureText;
                iVar.f16853d = false;
            } else {
                fMeasureText = iVar.f16852c;
            }
            boolean z9 = Math.round(fMeasureText) > Math.round(rectF.width());
            if (z9) {
                int iSave = canvas2.save();
                canvas2.clipRect(rectF);
                i5 = iSave;
            } else {
                i5 = 0;
            }
            CharSequence charSequenceEllipsize = this.f15682U;
            if (z9 && this.f15677R0 != null) {
                charSequenceEllipsize = TextUtils.ellipsize(charSequenceEllipsize, textPaint2, rectF.width(), this.f15677R0);
            }
            canvas.drawText(charSequenceEllipsize, 0, charSequenceEllipsize.length(), pointF.x, pointF.y, textPaint2);
            canvas2 = canvas;
            if (z9) {
                canvas2.restoreToCount(i5);
            }
        }
        if (S()) {
            rectF.setEmpty();
            if (S()) {
                float f13 = this.f15706t0 + this.f15705s0;
                if (getLayoutDirection() == 0) {
                    float f14 = bounds.right - f13;
                    rectF.right = f14;
                    rectF.left = f14 - this.f15692e0;
                } else {
                    float f15 = bounds.left + f13;
                    rectF.left = f15;
                    rectF.right = f15 + this.f15692e0;
                }
                float fExactCenterY = bounds.exactCenterY();
                float f16 = this.f15692e0;
                float f17 = fExactCenterY - (f16 / 2.0f);
                rectF.top = f17;
                rectF.bottom = f17 + f16;
            }
            float f18 = rectF.left;
            float f19 = rectF.top;
            canvas2.translate(f18, f19);
            this.f15689b0.setBounds(0, 0, (int) rectF.width(), (int) rectF.height());
            int[] iArr = AbstractC1674a.f18096a;
            this.f15690c0.setBounds(this.f15689b0.getBounds());
            this.f15690c0.jumpToCurrentState();
            this.f15690c0.draw(canvas2);
            canvas2.translate(-f18, -f19);
        }
        if (this.f15665J0 < 255) {
            canvas2.restoreToCount(iSaveLayerAlpha);
        }
    }

    @Override // android.graphics.drawable.Drawable
    public final int getAlpha() {
        return this.f15665J0;
    }

    @Override // android.graphics.drawable.Drawable
    public final ColorFilter getColorFilter() {
        return this.K0;
    }

    @Override // android.graphics.drawable.Drawable
    public final int getIntrinsicHeight() {
        return (int) this.f15672P;
    }

    @Override // android.graphics.drawable.Drawable
    public final int getIntrinsicWidth() {
        float fMeasureText;
        float fO = o() + this.f15700m0 + this.f15703p0;
        String string = this.f15682U.toString();
        s3.i iVar = this.f15656A0;
        if (iVar.f16853d) {
            fMeasureText = string == null ? 0.0f : iVar.f16850a.measureText((CharSequence) string, 0, string.length());
            iVar.f16852c = fMeasureText;
            iVar.f16853d = false;
        } else {
            fMeasureText = iVar.f16852c;
        }
        return Math.min(Math.round(p() + fMeasureText + fO + this.q0 + this.f15706t0), this.f15681T0);
    }

    @Override // x3.g, android.graphics.drawable.Drawable
    public final int getOpacity() {
        return -3;
    }

    @Override // x3.g, android.graphics.drawable.Drawable
    public final void getOutline(Outline outline) {
        Outline outline2;
        if (this.f15683U0) {
            super.getOutline(outline);
            return;
        }
        Rect bounds = getBounds();
        if (bounds.isEmpty()) {
            outline2 = outline;
            outline2.setRoundRect(0, 0, getIntrinsicWidth(), (int) this.f15672P, this.f15674Q);
        } else {
            outline.setRoundRect(bounds, this.f15674Q);
            outline2 = outline;
        }
        outline2.setAlpha(this.f15665J0 / 255.0f);
    }

    @Override // android.graphics.drawable.Drawable.Callback
    public final void invalidateDrawable(Drawable drawable) {
        Drawable.Callback callback = getCallback();
        if (callback != null) {
            callback.invalidateDrawable(this);
        }
    }

    @Override // x3.g, android.graphics.drawable.Drawable
    public final boolean isStateful() {
        ColorStateList colorStateList;
        if (r(this.f15668N) || r(this.f15670O) || r(this.f15676R)) {
            return true;
        }
        C1599d c1599d = this.f15656A0.f16855f;
        if (c1599d == null || (colorStateList = c1599d.f17473a) == null || !colorStateList.isStateful()) {
            return (this.f15695h0 && this.f15696i0 != null && this.f15694g0) || s(this.f15685W) || s(this.f15696i0) || r(this.f15667M0);
        }
        return true;
    }

    public final void m(Drawable drawable) {
        if (drawable == null) {
            return;
        }
        drawable.setCallback(this);
        drawable.setLayoutDirection(getLayoutDirection());
        drawable.setLevel(getLevel());
        drawable.setVisible(isVisible(), false);
        if (drawable == this.f15689b0) {
            if (drawable.isStateful()) {
                drawable.setState(this.f15671O0);
            }
            drawable.setTintList(this.f15691d0);
            return;
        }
        if (drawable.isStateful()) {
            drawable.setState(getState());
        }
        Drawable drawable2 = this.f15685W;
        if (drawable == drawable2 && this.f15687Z) {
            drawable2.setTintList(this.X);
        }
    }

    public final void n(Rect rect, RectF rectF) {
        rectF.setEmpty();
        if (R() || Q()) {
            float f3 = this.f15700m0 + this.f15701n0;
            Drawable drawable = this.f15663H0 ? this.f15696i0 : this.f15685W;
            float intrinsicWidth = this.f15686Y;
            if (intrinsicWidth <= 0.0f && drawable != null) {
                intrinsicWidth = drawable.getIntrinsicWidth();
            }
            if (getLayoutDirection() == 0) {
                float f7 = rect.left + f3;
                rectF.left = f7;
                rectF.right = f7 + intrinsicWidth;
            } else {
                float f8 = rect.right - f3;
                rectF.right = f8;
                rectF.left = f8 - intrinsicWidth;
            }
            Drawable drawable2 = this.f15663H0 ? this.f15696i0 : this.f15685W;
            float fCeil = this.f15686Y;
            if (fCeil <= 0.0f && drawable2 != null) {
                fCeil = (float) Math.ceil(TypedValue.applyDimension(1, 24, this.f15707u0.getResources().getDisplayMetrics()));
                if (drawable2.getIntrinsicHeight() <= fCeil) {
                    fCeil = drawable2.getIntrinsicHeight();
                }
            }
            float fExactCenterY = rect.exactCenterY() - (fCeil / 2.0f);
            rectF.top = fExactCenterY;
            rectF.bottom = fExactCenterY + fCeil;
        }
    }

    public final float o() {
        if (!R() && !Q()) {
            return 0.0f;
        }
        float f3 = this.f15701n0;
        Drawable drawable = this.f15663H0 ? this.f15696i0 : this.f15685W;
        float intrinsicWidth = this.f15686Y;
        if (intrinsicWidth <= 0.0f && drawable != null) {
            intrinsicWidth = drawable.getIntrinsicWidth();
        }
        return intrinsicWidth + f3 + this.f15702o0;
    }

    @Override // android.graphics.drawable.Drawable
    public final boolean onLayoutDirectionChanged(int i) {
        boolean zOnLayoutDirectionChanged = super.onLayoutDirectionChanged(i);
        if (R()) {
            zOnLayoutDirectionChanged |= this.f15685W.setLayoutDirection(i);
        }
        if (Q()) {
            zOnLayoutDirectionChanged |= this.f15696i0.setLayoutDirection(i);
        }
        if (S()) {
            zOnLayoutDirectionChanged |= this.f15689b0.setLayoutDirection(i);
        }
        if (!zOnLayoutDirectionChanged) {
            return true;
        }
        invalidateSelf();
        return true;
    }

    @Override // android.graphics.drawable.Drawable
    public final boolean onLevelChange(int i) {
        boolean zOnLevelChange = super.onLevelChange(i);
        if (R()) {
            zOnLevelChange |= this.f15685W.setLevel(i);
        }
        if (Q()) {
            zOnLevelChange |= this.f15696i0.setLevel(i);
        }
        if (S()) {
            zOnLevelChange |= this.f15689b0.setLevel(i);
        }
        if (zOnLevelChange) {
            invalidateSelf();
        }
        return zOnLevelChange;
    }

    @Override // x3.g, android.graphics.drawable.Drawable
    public final boolean onStateChange(int[] iArr) {
        if (this.f15683U0) {
            super.onStateChange(iArr);
        }
        return u(iArr, this.f15671O0);
    }

    public final float p() {
        if (S()) {
            return this.f15704r0 + this.f15692e0 + this.f15705s0;
        }
        return 0.0f;
    }

    public final float q() {
        return this.f15683U0 ? this.f18614q.f18588a.f18640e.a(e()) : this.f15674Q;
    }

    @Override // android.graphics.drawable.Drawable.Callback
    public final void scheduleDrawable(Drawable drawable, Runnable runnable, long j8) {
        Drawable.Callback callback = getCallback();
        if (callback != null) {
            callback.scheduleDrawable(this, runnable, j8);
        }
    }

    @Override // x3.g, android.graphics.drawable.Drawable
    public final void setAlpha(int i) {
        if (this.f15665J0 != i) {
            this.f15665J0 = i;
            invalidateSelf();
        }
    }

    @Override // x3.g, android.graphics.drawable.Drawable
    public final void setColorFilter(ColorFilter colorFilter) {
        if (this.K0 != colorFilter) {
            this.K0 = colorFilter;
            invalidateSelf();
        }
    }

    @Override // x3.g, android.graphics.drawable.Drawable
    public final void setTintList(ColorStateList colorStateList) {
        if (this.f15667M0 != colorStateList) {
            this.f15667M0 = colorStateList;
            onStateChange(getState());
        }
    }

    @Override // x3.g, android.graphics.drawable.Drawable
    public final void setTintMode(PorterDuff.Mode mode) {
        if (this.f15669N0 != mode) {
            this.f15669N0 = mode;
            ColorStateList colorStateList = this.f15667M0;
            this.f15666L0 = (colorStateList == null || mode == null) ? null : new PorterDuffColorFilter(colorStateList.getColorForState(getState(), 0), mode);
            invalidateSelf();
        }
    }

    @Override // android.graphics.drawable.Drawable
    public final boolean setVisible(boolean z8, boolean z9) {
        boolean visible = super.setVisible(z8, z9);
        if (R()) {
            visible |= this.f15685W.setVisible(z8, z9);
        }
        if (Q()) {
            visible |= this.f15696i0.setVisible(z8, z9);
        }
        if (S()) {
            visible |= this.f15689b0.setVisible(z8, z9);
        }
        if (visible) {
            invalidateSelf();
        }
        return visible;
    }

    public final void t() {
        InterfaceC1344d interfaceC1344d = (InterfaceC1344d) this.f15675Q0.get();
        if (interfaceC1344d != null) {
            Chip chip = (Chip) interfaceC1344d;
            chip.b(chip.f10190F);
            chip.requestLayout();
            chip.invalidateOutline();
        }
    }

    public final boolean u(int[] iArr, int[] iArr2) {
        boolean z8;
        boolean z9;
        ColorStateList colorStateList;
        boolean state = true;
        boolean zOnStateChange = super.onStateChange(iArr);
        ColorStateList colorStateList2 = this.f15668N;
        int iB = b(colorStateList2 != null ? colorStateList2.getColorForState(iArr, this.f15657B0) : 0);
        if (this.f15657B0 != iB) {
            this.f15657B0 = iB;
            zOnStateChange = true;
        }
        ColorStateList colorStateList3 = this.f15670O;
        int iB2 = b(colorStateList3 != null ? colorStateList3.getColorForState(iArr, this.f15658C0) : 0);
        if (this.f15658C0 != iB2) {
            this.f15658C0 = iB2;
            zOnStateChange = true;
        }
        int iB3 = F.a.b(iB2, iB);
        if ((this.f15659D0 != iB3) | (this.f18614q.f18590c == null)) {
            this.f15659D0 = iB3;
            i(ColorStateList.valueOf(iB3));
            zOnStateChange = true;
        }
        ColorStateList colorStateList4 = this.f15676R;
        int colorForState = colorStateList4 != null ? colorStateList4.getColorForState(iArr, this.f15660E0) : 0;
        if (this.f15660E0 != colorForState) {
            this.f15660E0 = colorForState;
            zOnStateChange = true;
        }
        int colorForState2 = (this.f15673P0 == null || !AbstractC1674a.b(iArr)) ? 0 : this.f15673P0.getColorForState(iArr, this.f15661F0);
        if (this.f15661F0 != colorForState2) {
            this.f15661F0 = colorForState2;
        }
        C1599d c1599d = this.f15656A0.f16855f;
        int colorForState3 = (c1599d == null || (colorStateList = c1599d.f17473a) == null) ? 0 : colorStateList.getColorForState(iArr, this.f15662G0);
        if (this.f15662G0 != colorForState3) {
            this.f15662G0 = colorForState3;
            zOnStateChange = true;
        }
        int[] state2 = getState();
        if (state2 == null) {
            z8 = false;
        } else {
            int length = state2.length;
            int i = 0;
            while (true) {
                if (i >= length) {
                    break;
                }
                if (state2[i] != 16842912) {
                    i++;
                } else if (this.f15694g0) {
                    z8 = true;
                }
            }
            z8 = false;
        }
        if (this.f15663H0 == z8 || this.f15696i0 == null) {
            z9 = false;
        } else {
            float fO = o();
            this.f15663H0 = z8;
            if (fO != o()) {
                zOnStateChange = true;
                z9 = true;
            } else {
                zOnStateChange = true;
                z9 = false;
            }
        }
        ColorStateList colorStateList5 = this.f15667M0;
        int colorForState4 = colorStateList5 != null ? colorStateList5.getColorForState(iArr, this.f15664I0) : 0;
        if (this.f15664I0 != colorForState4) {
            this.f15664I0 = colorForState4;
            ColorStateList colorStateList6 = this.f15667M0;
            PorterDuff.Mode mode = this.f15669N0;
            this.f15666L0 = (colorStateList6 == null || mode == null) ? null : new PorterDuffColorFilter(colorStateList6.getColorForState(getState(), 0), mode);
        } else {
            state = zOnStateChange;
        }
        if (s(this.f15685W)) {
            state |= this.f15685W.setState(iArr);
        }
        if (s(this.f15696i0)) {
            state |= this.f15696i0.setState(iArr);
        }
        if (s(this.f15689b0)) {
            int[] iArr3 = new int[iArr.length + iArr2.length];
            System.arraycopy(iArr, 0, iArr3, 0, iArr.length);
            System.arraycopy(iArr2, 0, iArr3, iArr.length, iArr2.length);
            state |= this.f15689b0.setState(iArr3);
        }
        int[] iArr4 = AbstractC1674a.f18096a;
        if (s(this.f15690c0)) {
            state |= this.f15690c0.setState(iArr2);
        }
        if (state) {
            invalidateSelf();
        }
        if (z9) {
            t();
        }
        return state;
    }

    @Override // android.graphics.drawable.Drawable.Callback
    public final void unscheduleDrawable(Drawable drawable, Runnable runnable) {
        Drawable.Callback callback = getCallback();
        if (callback != null) {
            callback.unscheduleDrawable(this, runnable);
        }
    }

    public final void v(boolean z8) {
        if (this.f15694g0 != z8) {
            this.f15694g0 = z8;
            float fO = o();
            if (!z8 && this.f15663H0) {
                this.f15663H0 = false;
            }
            float fO2 = o();
            invalidateSelf();
            if (fO != fO2) {
                t();
            }
        }
    }

    public final void w(Drawable drawable) {
        if (this.f15696i0 != drawable) {
            float fO = o();
            this.f15696i0 = drawable;
            float fO2 = o();
            T(this.f15696i0);
            m(this.f15696i0);
            invalidateSelf();
            if (fO != fO2) {
                t();
            }
        }
    }

    public final void x(ColorStateList colorStateList) {
        Drawable drawable;
        if (this.f15697j0 != colorStateList) {
            this.f15697j0 = colorStateList;
            if (this.f15695h0 && (drawable = this.f15696i0) != null && this.f15694g0) {
                drawable.setTintList(colorStateList);
            }
            onStateChange(getState());
        }
    }

    public final void y(boolean z8) {
        if (this.f15695h0 != z8) {
            boolean zQ = Q();
            this.f15695h0 = z8;
            boolean zQ2 = Q();
            if (zQ != zQ2) {
                if (zQ2) {
                    m(this.f15696i0);
                } else {
                    T(this.f15696i0);
                }
                invalidateSelf();
                t();
            }
        }
    }

    public final void z(float f3) {
        if (this.f15674Q != f3) {
            this.f15674Q = f3;
            j jVarE = this.f18614q.f18588a.e();
            jVarE.f18629e = new C1713a(f3);
            jVarE.f18630f = new C1713a(f3);
            jVarE.f18631g = new C1713a(f3);
            jVarE.f18632h = new C1713a(f3);
            setShapeAppearanceModel(jVarE.a());
        }
    }
}
