package com.google.android.material.shape;

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Matrix;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Region;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Looper;
import android.util.AttributeSet;
import android.util.StateSet;
import android.util.TypedValue;
import androidx.annotation.AttrRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.StyleRes;
import java.util.BitSet;

/* JADX INFO: loaded from: classes2.dex */
public class k extends Drawable implements g0 {

    /* JADX INFO: renamed from: c0, reason: collision with root package name */
    public static final Paint f23091c0;

    /* JADX INFO: renamed from: d0, reason: collision with root package name */
    public static final j[] f23092d0;
    public final Region Q;
    public final Paint R;
    public final Paint S;
    public final t9.a T;
    public final e.y U;
    public final w V;
    public int W;
    public final RectF X;
    public boolean Y;
    public boolean Z;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final nb.c f23093a;

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

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

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    public final e1.m[] f23096b0;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final d0[] f23097c;

    @Nullable
    private e1.n cornerSpringForce;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final d0[] f23098d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final BitSet f23099e;

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

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

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final Matrix f23102h;

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

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

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

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

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final Region f23107m;

    @Nullable
    private i onCornerSizeChangeListener;

    @Nullable
    private float[] springAnimatedCornerSizes;

    @Nullable
    private float[] springAnimatedStrokeCornerSizes;

    @Nullable
    private PorterDuffColorFilter strokeTintFilter;

    @Nullable
    private PorterDuffColorFilter tintFilter;

    static {
        q qVar = new q();
        int i10 = 0;
        com.bumptech.glide.h hVarB = com.bumptech.glide.f.b(0);
        qVar.f23134a = hVarB;
        q.b(hVarB);
        qVar.f23135b = hVarB;
        q.b(hVarB);
        qVar.f23136c = hVarB;
        q.b(hVarB);
        qVar.f23137d = hVarB;
        q.b(hVarB);
        qVar.c(0.0f);
        qVar.a();
        Paint paint = new Paint(1);
        f23091c0 = paint;
        paint.setColor(-1);
        paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
        f23092d0 = new j[4];
        while (true) {
            j[] jVarArr = f23092d0;
            if (i10 >= jVarArr.length) {
                return;
            }
            jVarArr[i10] = new j(i10);
            i10++;
        }
    }

    public k() {
        this(new s());
    }

    @Nullable
    private PorterDuffColorFilter calculatePaintColorTintFilter(@NonNull Paint paint, boolean z10) {
        if (!z10) {
            return null;
        }
        int color = paint.getColor();
        int iF = f(color);
        this.W = iF;
        if (iF != color) {
            return new PorterDuffColorFilter(iF, PorterDuff.Mode.SRC_IN);
        }
        return null;
    }

    private float calculateRoundRectCornerSize(@NonNull RectF rectF, @NonNull s sVar, @Nullable float[] fArr) {
        if (fArr == null) {
            if (sVar.g(rectF)) {
                return sVar.f23155e.a(rectF);
            }
            return -1.0f;
        }
        if (fArr.length > 1) {
            float f10 = fArr[0];
            for (int i10 = 1; i10 < fArr.length; i10++) {
                if (fArr[i10] != f10) {
                    return -1.0f;
                }
            }
        }
        if (sVar.f()) {
            return fArr[0];
        }
        return -1.0f;
    }

    @NonNull
    private PorterDuffColorFilter calculateTintFilter(@Nullable ColorStateList colorStateList, @Nullable PorterDuff.Mode mode, @NonNull Paint paint, boolean z10) {
        if (colorStateList == null || mode == null) {
            return calculatePaintColorTintFilter(paint, z10);
        }
        int colorForState = colorStateList.getColorForState(getState(), 0);
        if (z10) {
            colorForState = f(colorForState);
        }
        this.W = colorForState;
        return new PorterDuffColorFilter(colorForState, mode);
    }

    @NonNull
    public static k createWithElevationOverlay(@NonNull Context context, float f10, @Nullable ColorStateList colorStateList) {
        int color;
        if (colorStateList == null) {
            TypedValue typedValueC = q9.c.c(context, x8.c.colorSurface, k.class.getSimpleName());
            int i10 = typedValueC.resourceId;
            if (i10 != 0) {
                Object obj = g0.d.f26125a;
                color = context.getColor(i10);
            } else {
                color = typedValueC.data;
            }
            colorStateList = ColorStateList.valueOf(color);
        }
        k kVar = new k();
        kVar.s(context);
        kVar.setFillColor(colorStateList);
        kVar.w(f10);
        return kVar;
    }

    private void drawShape(@NonNull Canvas canvas, @NonNull Paint paint, @NonNull Path path, @NonNull s sVar, @Nullable float[] fArr, @NonNull RectF rectF) {
        float fCalculateRoundRectCornerSize = calculateRoundRectCornerSize(rectF, sVar, fArr);
        if (fCalculateRoundRectCornerSize < 0.0f) {
            canvas.drawPath(path, paint);
        } else {
            float f10 = fCalculateRoundRectCornerSize * this.f23095b.f23070c;
            canvas.drawRoundRect(rectF, f10, f10, paint);
        }
    }

    public final void A() {
        this.T.a(-12303292);
        this.f23095b.f23080m = false;
        super.invalidateSelf();
    }

    public final void B(int i10) {
        h hVar = this.f23095b;
        if (hVar.f23076i != i10) {
            hVar.f23076i = i10;
            super.invalidateSelf();
        }
    }

    public final void C(n0 n0Var) {
        h hVar = this.f23095b;
        if (hVar.stateListShapeAppearanceModel != n0Var) {
            hVar.stateListShapeAppearanceModel = n0Var;
            F(getState(), true);
            invalidateSelf();
        }
    }

    public final void D(float f10) {
        this.f23095b.f23071d = f10;
        invalidateSelf();
    }

    public final boolean E(int[] iArr) {
        boolean z10;
        Paint paint;
        int color;
        int colorForState;
        Paint paint2;
        int color2;
        int colorForState2;
        if (this.f23095b.fillColor == null || color2 == (colorForState2 = this.f23095b.fillColor.getColorForState(iArr, (color2 = (paint2 = this.R).getColor())))) {
            z10 = false;
        } else {
            paint2.setColor(colorForState2);
            z10 = true;
        }
        if (this.f23095b.strokeColor == null || color == (colorForState = this.f23095b.strokeColor.getColorForState(iArr, (color = (paint = this.S).getColor())))) {
            return z10;
        }
        paint.setColor(colorForState);
        return true;
    }

    public final void F(int[] iArr, boolean z10) {
        int i10;
        int[][] iArr2;
        s sVarA;
        RectF rectFL = l();
        if (this.f23095b.stateListShapeAppearanceModel == null || rectFL.isEmpty()) {
            return;
        }
        boolean z11 = z10 | (this.cornerSpringForce == null);
        if (this.springAnimatedCornerSizes == null) {
            this.springAnimatedCornerSizes = new float[4];
        }
        n0 n0Var = this.f23095b.stateListShapeAppearanceModel;
        int i11 = 0;
        while (true) {
            int i12 = n0Var.f23127a;
            i10 = -1;
            iArr2 = n0Var.f23129c;
            if (i11 >= i12) {
                i11 = -1;
                break;
            } else if (StateSet.stateSetMatches(iArr2[i11], iArr)) {
                break;
            } else {
                i11++;
            }
        }
        if (i11 < 0) {
            int[] iArr3 = StateSet.WILD_CARD;
            int i13 = 0;
            while (true) {
                if (i13 >= n0Var.f23127a) {
                    break;
                }
                if (StateSet.stateSetMatches(iArr2[i13], iArr3)) {
                    i10 = i13;
                    break;
                }
                i13++;
            }
            i11 = i10;
        }
        l0 l0Var = n0Var.topLeftCornerSizeOverride;
        s[] sVarArr = n0Var.f23130d;
        if (l0Var == null && n0Var.topRightCornerSizeOverride == null && n0Var.bottomLeftCornerSizeOverride == null && n0Var.bottomRightCornerSizeOverride == null) {
            sVarA = sVarArr[i11];
        } else {
            q qVarH = sVarArr[i11].h();
            l0 l0Var2 = n0Var.topLeftCornerSizeOverride;
            if (l0Var2 != null) {
                qVarH.f23138e = l0Var2.d(iArr);
            }
            l0 l0Var3 = n0Var.topRightCornerSizeOverride;
            if (l0Var3 != null) {
                qVarH.f23139f = l0Var3.d(iArr);
            }
            l0 l0Var4 = n0Var.bottomLeftCornerSizeOverride;
            if (l0Var4 != null) {
                qVarH.f23141h = l0Var4.d(iArr);
            }
            l0 l0Var5 = n0Var.bottomRightCornerSizeOverride;
            if (l0Var5 != null) {
                qVarH.f23140g = l0Var5.d(iArr);
            }
            sVarA = qVarH.a();
        }
        for (int i14 = 0; i14 < 4; i14++) {
            this.V.getClass();
            float fA = w.a(i14, sVarA).a(rectFL);
            if (z11) {
                this.springAnimatedCornerSizes[i14] = fA;
            }
            e1.m[] mVarArr = this.f23096b0;
            e1.m mVar = mVarArr[i14];
            if (mVar != null) {
                mVar.c(fA);
                if (z11) {
                    mVarArr[i14].d();
                }
            }
        }
        if (z11) {
            invalidateSelf();
        }
    }

    public final boolean G() {
        PorterDuffColorFilter porterDuffColorFilter = this.tintFilter;
        PorterDuffColorFilter porterDuffColorFilter2 = this.strokeTintFilter;
        h hVar = this.f23095b;
        this.tintFilter = calculateTintFilter(hVar.tintList, hVar.tintMode, this.R, true);
        h hVar2 = this.f23095b;
        this.strokeTintFilter = calculateTintFilter(hVar2.strokeTintList, hVar2.tintMode, this.S, false);
        h hVar3 = this.f23095b;
        if (hVar3.f23080m) {
            this.T.a(hVar3.tintList.getColorForState(getState(), 0));
        }
        return (p0.c.equals(porterDuffColorFilter, this.tintFilter) && p0.c.equals(porterDuffColorFilter2, this.strokeTintFilter)) ? false : true;
    }

    public final void H() {
        h hVar = this.f23095b;
        float f10 = hVar.f23074g + hVar.f23075h;
        hVar.f23077j = (int) Math.ceil(0.75f * f10);
        this.f23095b.f23078k = (int) Math.ceil(f10 * 0.25f);
        G();
        super.invalidateSelf();
    }

    public void a() {
        invalidateSelf();
    }

    public final void d(RectF rectF, Path path) {
        e(rectF, path);
        if (this.f23095b.f23069b != 1.0f) {
            Matrix matrix = this.f23102h;
            matrix.reset();
            float f10 = this.f23095b.f23069b;
            matrix.setScale(f10, f10, rectF.width() / 2.0f, rectF.height() / 2.0f);
            path.transform(matrix);
        }
        path.computeBounds(this.X, true);
    }

    @Override // android.graphics.drawable.Drawable
    public void draw(Canvas canvas) {
        Paint paint = this.R;
        paint.setColorFilter(this.tintFilter);
        int alpha = paint.getAlpha();
        int i10 = this.f23095b.f23072e;
        paint.setAlpha(((i10 + (i10 >>> 7)) * alpha) >>> 8);
        Paint paint2 = this.S;
        paint2.setColorFilter(this.strokeTintFilter);
        paint2.setStrokeWidth(this.f23095b.f23071d);
        int alpha2 = paint2.getAlpha();
        int i11 = this.f23095b.f23072e;
        paint2.setAlpha(((i11 + (i11 >>> 7)) * alpha2) >>> 8);
        Paint.Style style = this.f23095b.f23081n;
        if (style == Paint.Style.FILL_AND_STROKE || style == Paint.Style.FILL) {
            boolean z10 = this.f23100f;
            Path path = this.f23103i;
            if (z10) {
                d(l(), path);
                this.f23100f = false;
            }
            h hVar = this.f23095b;
            int i12 = hVar.f23076i;
            if (i12 != 1 && hVar.f23077j > 0 && (i12 == 2 || (!u() && !path.isConvex() && Build.VERSION.SDK_INT < 29))) {
                canvas.save();
                h hVar2 = this.f23095b;
                canvas.translate((int) (Math.sin(Math.toRadians(hVar2.f23079l)) * ((double) hVar2.f23078k)), n());
                if (this.Y) {
                    RectF rectF = this.X;
                    int iWidth = (int) (rectF.width() - getBounds().width());
                    int iHeight = (int) (rectF.height() - getBounds().height());
                    if (iWidth < 0 || iHeight < 0) {
                        throw new IllegalStateException("Invalid shadow bounds. Check that the treatments result in a valid path.");
                    }
                    Bitmap bitmapCreateBitmap = Bitmap.createBitmap((this.f23095b.f23077j * 2) + ((int) rectF.width()) + iWidth, (this.f23095b.f23077j * 2) + ((int) rectF.height()) + iHeight, Bitmap.Config.ARGB_8888);
                    Canvas canvas2 = new Canvas(bitmapCreateBitmap);
                    float f10 = (getBounds().left - this.f23095b.f23077j) - iWidth;
                    float f11 = (getBounds().top - this.f23095b.f23077j) - iHeight;
                    canvas2.translate(-f10, -f11);
                    g(canvas2);
                    canvas.drawBitmap(bitmapCreateBitmap, f10, f11, (Paint) null);
                    bitmapCreateBitmap.recycle();
                    canvas.restore();
                } else {
                    g(canvas);
                    canvas.restore();
                }
            }
            drawShape(canvas, paint, path, this.f23095b.f23068a, this.springAnimatedCornerSizes, l());
        }
        if (r()) {
            if (this.f23101g) {
                this.f23094a0 = this.f23095b.f23068a.i(this.f23093a);
                float[] fArr = this.springAnimatedCornerSizes;
                if (fArr != null) {
                    if (this.springAnimatedStrokeCornerSizes == null) {
                        this.springAnimatedStrokeCornerSizes = new float[fArr.length];
                    }
                    float fO = o();
                    int i13 = 0;
                    while (true) {
                        float[] fArr2 = this.springAnimatedCornerSizes;
                        if (i13 >= fArr2.length) {
                            break;
                        }
                        this.springAnimatedStrokeCornerSizes[i13] = Math.max(0.0f, fArr2[i13] - fO);
                        i13++;
                    }
                } else {
                    this.springAnimatedStrokeCornerSizes = null;
                }
                w wVar = this.V;
                s sVar = this.f23094a0;
                float[] fArr3 = this.springAnimatedStrokeCornerSizes;
                float f12 = this.f23095b.f23070c;
                RectF rectF2 = this.f23106l;
                rectF2.set(l());
                float fO2 = o();
                rectF2.inset(fO2, fO2);
                wVar.calculatePath(sVar, fArr3, f12, rectF2, null, this.f23104j);
                this.f23101g = false;
            }
            i(canvas);
        }
        paint.setAlpha(alpha);
        paint2.setAlpha(alpha2);
    }

    public final void e(RectF rectF, Path path) {
        w wVar = this.V;
        h hVar = this.f23095b;
        wVar.calculatePath(hVar.f23068a, this.springAnimatedCornerSizes, hVar.f23070c, rectF, this.U, path);
    }

    public final int f(int i10) {
        h hVar = this.f23095b;
        float f10 = hVar.f23074g + hVar.f23075h + hVar.f23073f;
        k9.a aVar = hVar.elevationOverlayProvider;
        return aVar != null ? aVar.a(f10, i10) : i10;
    }

    public final void g(Canvas canvas) {
        this.f23099e.cardinality();
        int i10 = this.f23095b.f23078k;
        Path path = this.f23103i;
        t9.a aVar = this.T;
        if (i10 != 0) {
            canvas.drawPath(path, aVar.f32993a);
        }
        for (int i11 = 0; i11 < 4; i11++) {
            d0 d0Var = this.f23097c[i11];
            int i12 = this.f23095b.f23077j;
            Matrix matrix = d0.f23056b;
            d0Var.a(matrix, aVar, i12, canvas);
            this.f23098d[i11].a(matrix, aVar, this.f23095b.f23077j, canvas);
        }
        if (this.Y) {
            int iSin = (int) (Math.sin(Math.toRadians(r0.f23079l)) * ((double) this.f23095b.f23078k));
            int iN = n();
            canvas.translate(-iSin, -iN);
            canvas.drawPath(path, f23091c0);
            canvas.translate(iSin, iN);
        }
    }

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

    @Override // android.graphics.drawable.Drawable
    @Nullable
    public Drawable.ConstantState getConstantState() {
        return this.f23095b;
    }

    @Nullable
    @RestrictTo({RestrictTo.Scope.f556b})
    public e1.n getCornerSpringForce() {
        return this.cornerSpringForce;
    }

    @Nullable
    public ColorStateList getFillColor() {
        return this.f23095b.fillColor;
    }

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

    @Override // android.graphics.drawable.Drawable
    public void getOutline(Outline outline) {
        if (this.f23095b.f23076i == 2) {
            return;
        }
        RectF rectFL = l();
        if (rectFL.isEmpty()) {
            return;
        }
        float fCalculateRoundRectCornerSize = calculateRoundRectCornerSize(rectFL, this.f23095b.f23068a, this.springAnimatedCornerSizes);
        if (fCalculateRoundRectCornerSize >= 0.0f) {
            outline.setRoundRect(getBounds(), fCalculateRoundRectCornerSize * this.f23095b.f23070c);
            return;
        }
        boolean z10 = this.f23100f;
        Path path = this.f23103i;
        if (z10) {
            d(rectFL, path);
            this.f23100f = false;
        }
        j9.c.b(outline, path);
    }

    @Override // android.graphics.drawable.Drawable
    public final boolean getPadding(Rect rect) {
        Rect rect2 = this.f23095b.padding;
        if (rect2 == null) {
            return super.getPadding(rect);
        }
        rect.set(rect2);
        return true;
    }

    @Nullable
    @Deprecated
    public f0 getShapedViewModel() {
        s sVar = this.f23095b.f23068a;
        return null;
    }

    @Nullable
    @RestrictTo({RestrictTo.Scope.f556b})
    public n0 getStateListShapeAppearanceModel() {
        return this.f23095b.stateListShapeAppearanceModel;
    }

    @Nullable
    public ColorStateList getStrokeColor() {
        return this.f23095b.strokeColor;
    }

    @Nullable
    public ColorStateList getStrokeTintList() {
        return this.f23095b.strokeTintList;
    }

    @Nullable
    public ColorStateList getTintList() {
        return this.f23095b.tintList;
    }

    @Override // android.graphics.drawable.Drawable
    public final Region getTransparentRegion() {
        Rect bounds = getBounds();
        Region region = this.f23107m;
        region.set(bounds);
        RectF rectFL = l();
        Path path = this.f23103i;
        d(rectFL, path);
        Region region2 = this.Q;
        region2.setPath(path, region);
        region.op(region2, Region.Op.DIFFERENCE);
        return region;
    }

    public final void h(Canvas canvas, Paint paint, Path path, RectF rectF) {
        drawShape(canvas, paint, path, this.f23095b.f23068a, this.springAnimatedCornerSizes, rectF);
    }

    public void i(Canvas canvas) {
        Paint paint = this.S;
        Path path = this.f23104j;
        s sVar = this.f23094a0;
        float[] fArr = this.springAnimatedStrokeCornerSizes;
        RectF rectF = this.f23106l;
        rectF.set(l());
        float fO = o();
        rectF.inset(fO, fO);
        drawShape(canvas, paint, path, sVar, fArr, rectF);
    }

    @Override // android.graphics.drawable.Drawable
    public final void invalidateSelf() {
        this.f23100f = true;
        this.f23101g = true;
        super.invalidateSelf();
    }

    @Override // android.graphics.drawable.Drawable
    public boolean isStateful() {
        ColorStateList colorStateList;
        ColorStateList colorStateList2;
        ColorStateList colorStateList3;
        ColorStateList colorStateList4;
        n0 n0Var;
        return super.isStateful() || ((colorStateList = this.f23095b.tintList) != null && colorStateList.isStateful()) || (((colorStateList2 = this.f23095b.strokeTintList) != null && colorStateList2.isStateful()) || (((colorStateList3 = this.f23095b.strokeColor) != null && colorStateList3.isStateful()) || (((colorStateList4 = this.f23095b.fillColor) != null && colorStateList4.isStateful()) || ((n0Var = this.f23095b.stateListShapeAppearanceModel) != null && n0Var.b()))));
    }

    public final float j() {
        float[] fArr = this.springAnimatedCornerSizes;
        return fArr != null ? fArr[2] : this.f23095b.f23068a.f23158h.a(l());
    }

    public final float k() {
        float[] fArr = this.springAnimatedCornerSizes;
        return fArr != null ? fArr[1] : this.f23095b.f23068a.f23157g.a(l());
    }

    public final RectF l() {
        RectF rectF = this.f23105k;
        rectF.set(getBounds());
        return rectF;
    }

    public final float m() {
        float[] fArr = this.springAnimatedCornerSizes;
        if (fArr != null) {
            return (((fArr[3] + fArr[2]) - fArr[1]) - fArr[0]) / 2.0f;
        }
        RectF rectFL = l();
        s sVar = this.f23095b.f23068a;
        this.V.getClass();
        return (((w.a(2, this.f23095b.f23068a).a(rectFL) + w.a(3, sVar).a(rectFL)) - w.a(1, this.f23095b.f23068a).a(rectFL)) - w.a(0, this.f23095b.f23068a).a(rectFL)) / 2.0f;
    }

    @Override // android.graphics.drawable.Drawable
    public Drawable mutate() {
        this.f23095b = new h(this.f23095b);
        return this;
    }

    public final int n() {
        return (int) (Math.cos(Math.toRadians(r0.f23079l)) * ((double) this.f23095b.f23078k));
    }

    public final float o() {
        if (r()) {
            return this.S.getStrokeWidth() / 2.0f;
        }
        return 0.0f;
    }

    @Override // android.graphics.drawable.Drawable
    public void onBoundsChange(Rect rect) {
        this.f23100f = true;
        this.f23101g = true;
        super.onBoundsChange(rect);
        if (this.f23095b.stateListShapeAppearanceModel != null && !rect.isEmpty()) {
            F(getState(), this.Z);
        }
        this.Z = rect.isEmpty();
    }

    @Override // android.graphics.drawable.Drawable
    public boolean onStateChange(int[] iArr) {
        if (this.f23095b.stateListShapeAppearanceModel != null) {
            F(iArr, false);
        }
        boolean z10 = E(iArr) || G();
        if (z10) {
            invalidateSelf();
        }
        return z10;
    }

    public final float p() {
        float[] fArr = this.springAnimatedCornerSizes;
        return fArr != null ? fArr[3] : this.f23095b.f23068a.f23155e.a(l());
    }

    public final float q() {
        float[] fArr = this.springAnimatedCornerSizes;
        return fArr != null ? fArr[0] : this.f23095b.f23068a.f23156f.a(l());
    }

    public final boolean r() {
        Paint.Style style = this.f23095b.f23081n;
        return (style == Paint.Style.FILL_AND_STROKE || style == Paint.Style.STROKE) && this.S.getStrokeWidth() > 0.0f;
    }

    public final void s(Context context) {
        this.f23095b.elevationOverlayProvider = new k9.a(context);
        H();
    }

    @Override // android.graphics.drawable.Drawable
    public void setAlpha(int i10) {
        h hVar = this.f23095b;
        if (hVar.f23072e != i10) {
            hVar.f23072e = i10;
            super.invalidateSelf();
        }
    }

    @Override // android.graphics.drawable.Drawable
    public void setColorFilter(@Nullable ColorFilter colorFilter) {
        this.f23095b.colorFilter = colorFilter;
        super.invalidateSelf();
    }

    public void setFillColor(@Nullable ColorStateList colorStateList) {
        h hVar = this.f23095b;
        if (hVar.fillColor != colorStateList) {
            hVar.fillColor = colorStateList;
            onStateChange(getState());
        }
    }

    @RestrictTo({RestrictTo.Scope.f556b})
    public void setOnCornerSizeChangeListener(@Nullable i iVar) {
        this.onCornerSizeChangeListener = iVar;
    }

    @Override // com.google.android.material.shape.g0
    public final void setShapeAppearanceModel(s sVar) {
        h hVar = this.f23095b;
        hVar.f23068a = sVar;
        hVar.stateListShapeAppearanceModel = null;
        this.springAnimatedCornerSizes = null;
        this.springAnimatedStrokeCornerSizes = null;
        invalidateSelf();
    }

    public void setStroke(float f10, @Nullable ColorStateList colorStateList) {
        D(f10);
        setStrokeColor(colorStateList);
    }

    public void setStrokeColor(@Nullable ColorStateList colorStateList) {
        h hVar = this.f23095b;
        if (hVar.strokeColor != colorStateList) {
            hVar.strokeColor = colorStateList;
            onStateChange(getState());
        }
    }

    @Override // android.graphics.drawable.Drawable
    public final void setTint(int i10) {
        setTintList(ColorStateList.valueOf(i10));
    }

    @Override // android.graphics.drawable.Drawable
    public void setTintList(@Nullable ColorStateList colorStateList) {
        this.f23095b.tintList = colorStateList;
        G();
        super.invalidateSelf();
    }

    @Override // android.graphics.drawable.Drawable
    public void setTintMode(@Nullable PorterDuff.Mode mode) {
        h hVar = this.f23095b;
        if (hVar.tintMode != mode) {
            hVar.tintMode = mode;
            G();
            super.invalidateSelf();
        }
    }

    public final boolean t() {
        k9.a aVar = this.f23095b.elevationOverlayProvider;
        return aVar != null && aVar.f29082a;
    }

    /* JADX WARN: Removed duplicated region for block: B:24:? A[RETURN, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean u() {
        if (this.f23095b.f23068a.g(l())) {
            return true;
        }
        float[] fArr = this.springAnimatedCornerSizes;
        if (fArr != null) {
            if (fArr.length > 1) {
                float f10 = fArr[0];
                for (int i10 = 1; i10 < fArr.length; i10++) {
                    if (fArr[i10] != f10) {
                        break;
                    }
                }
                if (this.f23095b.f23068a.f()) {
                }
            } else if (this.f23095b.f23068a.f()) {
                return true;
            }
        }
        return false;
    }

    public final void v(e1.n nVar) {
        if (this.cornerSpringForce == nVar) {
            return;
        }
        this.cornerSpringForce = nVar;
        int i10 = 0;
        while (true) {
            e1.m[] mVarArr = this.f23096b0;
            if (i10 >= mVarArr.length) {
                F(getState(), true);
                invalidateSelf();
                return;
            }
            if (mVarArr[i10] == null) {
                mVarArr[i10] = new e1.m(this, f23092d0[i10]);
            }
            e1.m mVar = mVarArr[i10];
            e1.n nVar2 = new e1.n();
            nVar2.a((float) nVar.f25435b);
            double d10 = nVar.f25434a;
            nVar2.b((float) (d10 * d10));
            mVar.f25431s = nVar2;
            i10++;
        }
    }

    public final void w(float f10) {
        h hVar = this.f23095b;
        if (hVar.f23074g != f10) {
            hVar.f23074g = f10;
            H();
        }
    }

    public final void x(float f10) {
        h hVar = this.f23095b;
        if (hVar.f23070c != f10) {
            hVar.f23070c = f10;
            this.f23100f = true;
            this.f23101g = true;
            invalidateSelf();
        }
    }

    public final void y(int i10, int i11, int i12, int i13) {
        h hVar = this.f23095b;
        if (hVar.padding == null) {
            hVar.padding = new Rect();
        }
        this.f23095b.padding.set(0, i11, 0, i13);
        invalidateSelf();
    }

    public final void z(Paint.Style style) {
        this.f23095b.f23081n = style;
        super.invalidateSelf();
    }

    public k(s sVar) {
        this(new h(sVar, null));
    }

    public k(h hVar) {
        w wVar;
        this.f23093a = new nb.c(this, 20);
        this.f23097c = new d0[4];
        this.f23098d = new d0[4];
        this.f23099e = new BitSet(8);
        this.f23102h = new Matrix();
        this.f23103i = new Path();
        this.f23104j = new Path();
        this.f23105k = new RectF();
        this.f23106l = new RectF();
        this.f23107m = new Region();
        this.Q = new Region();
        Paint paint = new Paint(1);
        this.R = paint;
        Paint paint2 = new Paint(1);
        this.S = paint2;
        this.T = new t9.a();
        if (Looper.getMainLooper().getThread() == Thread.currentThread()) {
            wVar = t.f23163a;
        } else {
            wVar = new w();
        }
        this.V = wVar;
        this.X = new RectF();
        this.Y = true;
        this.Z = true;
        this.f23096b0 = new e1.m[4];
        this.f23095b = hVar;
        paint2.setStyle(Paint.Style.STROKE);
        paint.setStyle(Paint.Style.FILL);
        G();
        E(getState());
        this.U = new e.y(this);
    }

    public k(@NonNull Context context, @Nullable AttributeSet attributeSet, @AttrRes int i10, @StyleRes int i11) {
        this(s.c(context, attributeSet, i10, i11).a());
    }
}
