package X6FRs_4.PGPF6hQ_2.IFxWkV_5;

import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RadialGradient;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.drawable.Drawable;
/* compiled from: RoundRectDrawableWithShadow.java */
/* loaded from: classes.dex */
public class IMuAHx_6 extends Drawable {
    public static final double KQgRr5e_0 = Math.cos(Math.toRadians(45.0d));

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public static KQgRr5e_0 f1081KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public float f1082KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final int f1083KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public ColorStateList f1084KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public Path f1086KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final RectF f1087KQgRr5e_0;

    /* renamed from: Mqv2r_3  reason: collision with root package name */
    public float f3246Mqv2r_3;
    public float PGPF6hQ_2;

    /* renamed from: PGPF6hQ_2  reason: collision with other field name */
    public final int f1089PGPF6hQ_2;

    /* renamed from: PGPF6hQ_2  reason: collision with other field name */
    public Paint f1090PGPF6hQ_2;
    public float QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public final int f1092QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public Paint f1093QxJ9d_1;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public boolean f1088KQgRr5e_0 = true;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public boolean f1094QxJ9d_1 = true;

    /* renamed from: PGPF6hQ_2  reason: collision with other field name */
    public boolean f1091PGPF6hQ_2 = false;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public Paint f1085KQgRr5e_0 = new Paint(5);

    /* compiled from: RoundRectDrawableWithShadow.java */
    /* loaded from: classes.dex */
    public interface KQgRr5e_0 {
        void KQgRr5e_0(Canvas canvas, RectF rectF, float f, Paint paint);
    }

    public IMuAHx_6(Resources resources, ColorStateList colorStateList, float f, float f2, float f3) {
        this.f1092QxJ9d_1 = resources.getColor(X6FRs_4.PGPF6hQ_2.QxJ9d_1.cardview_shadow_start_color);
        this.f1089PGPF6hQ_2 = resources.getColor(X6FRs_4.PGPF6hQ_2.QxJ9d_1.cardview_shadow_end_color);
        this.f1083KQgRr5e_0 = resources.getDimensionPixelSize(X6FRs_4.PGPF6hQ_2.PGPF6hQ_2.cardview_compat_inset_shadow);
        KQgRr5e_0(colorStateList);
        Paint paint = new Paint(5);
        this.f1093QxJ9d_1 = paint;
        paint.setStyle(Paint.Style.FILL);
        this.f1082KQgRr5e_0 = (int) (f + 0.5f);
        this.f1087KQgRr5e_0 = new RectF();
        Paint paint2 = new Paint(this.f1093QxJ9d_1);
        this.f1090PGPF6hQ_2 = paint2;
        paint2.setAntiAlias(false);
        KQgRr5e_0(f2, f3);
    }

    public static float QxJ9d_1(float f, float f2, boolean z) {
        if (z) {
            double d = f * 1.5f;
            double d2 = f2;
            Double.isNaN(d2);
            Double.isNaN(d);
            return (float) (d + ((1.0d - KQgRr5e_0) * d2));
        }
        return f * 1.5f;
    }

    public final void KQgRr5e_0(ColorStateList colorStateList) {
        if (colorStateList == null) {
            colorStateList = ColorStateList.valueOf(0);
        }
        this.f1084KQgRr5e_0 = colorStateList;
        this.f1085KQgRr5e_0.setColor(colorStateList.getColorForState(getState(), this.f1084KQgRr5e_0.getDefaultColor()));
    }

    public float Mqv2r_3() {
        float f = this.QxJ9d_1;
        return (Math.max(f, this.f1082KQgRr5e_0 + this.f1083KQgRr5e_0 + (f / 2.0f)) * 2.0f) + ((this.QxJ9d_1 + this.f1083KQgRr5e_0) * 2.0f);
    }

    public void PGPF6hQ_2(float f) {
        KQgRr5e_0(f, this.QxJ9d_1);
    }

    public float X6FRs_4() {
        return this.f3246Mqv2r_3;
    }

    @Override // android.graphics.drawable.Drawable
    public void draw(Canvas canvas) {
        if (this.f1088KQgRr5e_0) {
            KQgRr5e_0(getBounds());
            this.f1088KQgRr5e_0 = false;
        }
        canvas.translate(0.0f, this.f3246Mqv2r_3 / 2.0f);
        KQgRr5e_0(canvas);
        canvas.translate(0.0f, (-this.f3246Mqv2r_3) / 2.0f);
        f1081KQgRr5e_0.KQgRr5e_0(canvas, this.f1087KQgRr5e_0, this.f1082KQgRr5e_0, this.f1085KQgRr5e_0);
    }

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

    @Override // android.graphics.drawable.Drawable
    public boolean getPadding(Rect rect) {
        int ceil = (int) Math.ceil(QxJ9d_1(this.QxJ9d_1, this.f1082KQgRr5e_0, this.f1094QxJ9d_1));
        int ceil2 = (int) Math.ceil(KQgRr5e_0(this.QxJ9d_1, this.f1082KQgRr5e_0, this.f1094QxJ9d_1));
        rect.set(ceil2, ceil, ceil2, ceil);
        return true;
    }

    @Override // android.graphics.drawable.Drawable
    public boolean isStateful() {
        ColorStateList colorStateList = this.f1084KQgRr5e_0;
        return (colorStateList != null && colorStateList.isStateful()) || super.isStateful();
    }

    @Override // android.graphics.drawable.Drawable
    public void onBoundsChange(Rect rect) {
        super.onBoundsChange(rect);
        this.f1088KQgRr5e_0 = true;
    }

    @Override // android.graphics.drawable.Drawable
    public boolean onStateChange(int[] iArr) {
        ColorStateList colorStateList = this.f1084KQgRr5e_0;
        int colorForState = colorStateList.getColorForState(iArr, colorStateList.getDefaultColor());
        if (this.f1085KQgRr5e_0.getColor() == colorForState) {
            return false;
        }
        this.f1085KQgRr5e_0.setColor(colorForState);
        this.f1088KQgRr5e_0 = true;
        invalidateSelf();
        return true;
    }

    @Override // android.graphics.drawable.Drawable
    public void setAlpha(int i) {
        this.f1085KQgRr5e_0.setAlpha(i);
        this.f1093QxJ9d_1.setAlpha(i);
        this.f1090PGPF6hQ_2.setAlpha(i);
    }

    @Override // android.graphics.drawable.Drawable
    public void setColorFilter(ColorFilter colorFilter) {
        this.f1085KQgRr5e_0.setColorFilter(colorFilter);
    }

    public float PGPF6hQ_2() {
        float f = this.QxJ9d_1;
        return (Math.max(f, this.f1082KQgRr5e_0 + this.f1083KQgRr5e_0 + ((f * 1.5f) / 2.0f)) * 2.0f) + (((this.QxJ9d_1 * 1.5f) + this.f1083KQgRr5e_0) * 2.0f);
    }

    public void QxJ9d_1(Rect rect) {
        getPadding(rect);
    }

    public final int KQgRr5e_0(float f) {
        int i = (int) (f + 0.5f);
        return i % 2 == 1 ? i - 1 : i;
    }

    public void QxJ9d_1(float f) {
        KQgRr5e_0(this.f3246Mqv2r_3, f);
    }

    public void KQgRr5e_0(boolean z) {
        this.f1094QxJ9d_1 = z;
        invalidateSelf();
    }

    public float QxJ9d_1() {
        return this.QxJ9d_1;
    }

    public void QxJ9d_1(ColorStateList colorStateList) {
        KQgRr5e_0(colorStateList);
        invalidateSelf();
    }

    public final void KQgRr5e_0(float f, float f2) {
        if (f < 0.0f) {
            throw new IllegalArgumentException("Invalid shadow size " + f + ". Must be >= 0");
        } else if (f2 >= 0.0f) {
            float KQgRr5e_02 = KQgRr5e_0(f);
            float KQgRr5e_03 = KQgRr5e_0(f2);
            if (KQgRr5e_02 > KQgRr5e_03) {
                if (!this.f1091PGPF6hQ_2) {
                    this.f1091PGPF6hQ_2 = true;
                }
                KQgRr5e_02 = KQgRr5e_03;
            }
            if (this.f3246Mqv2r_3 == KQgRr5e_02 && this.QxJ9d_1 == KQgRr5e_03) {
                return;
            }
            this.f3246Mqv2r_3 = KQgRr5e_02;
            this.QxJ9d_1 = KQgRr5e_03;
            this.PGPF6hQ_2 = (int) ((KQgRr5e_02 * 1.5f) + this.f1083KQgRr5e_0 + 0.5f);
            this.f1088KQgRr5e_0 = true;
            invalidateSelf();
        } else {
            throw new IllegalArgumentException("Invalid max shadow size " + f2 + ". Must be >= 0");
        }
    }

    public static float KQgRr5e_0(float f, float f2, boolean z) {
        if (z) {
            double d = f;
            double d2 = f2;
            Double.isNaN(d2);
            Double.isNaN(d);
            return (float) (d + ((1.0d - KQgRr5e_0) * d2));
        }
        return f;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public void m520KQgRr5e_0(float f) {
        if (f >= 0.0f) {
            float f2 = (int) (f + 0.5f);
            if (this.f1082KQgRr5e_0 == f2) {
                return;
            }
            this.f1082KQgRr5e_0 = f2;
            this.f1088KQgRr5e_0 = true;
            invalidateSelf();
            return;
        }
        throw new IllegalArgumentException("Invalid radius " + f + ". Must be >= 0");
    }

    public final void KQgRr5e_0(Canvas canvas) {
        float f = this.f1082KQgRr5e_0;
        float f2 = (-f) - this.PGPF6hQ_2;
        float f3 = f + this.f1083KQgRr5e_0 + (this.f3246Mqv2r_3 / 2.0f);
        float f4 = f3 * 2.0f;
        boolean z = this.f1087KQgRr5e_0.width() - f4 > 0.0f;
        boolean z2 = this.f1087KQgRr5e_0.height() - f4 > 0.0f;
        int save = canvas.save();
        RectF rectF = this.f1087KQgRr5e_0;
        canvas.translate(rectF.left + f3, rectF.top + f3);
        canvas.drawPath(this.f1086KQgRr5e_0, this.f1093QxJ9d_1);
        if (z) {
            canvas.drawRect(0.0f, f2, this.f1087KQgRr5e_0.width() - f4, -this.f1082KQgRr5e_0, this.f1090PGPF6hQ_2);
        }
        canvas.restoreToCount(save);
        int save2 = canvas.save();
        RectF rectF2 = this.f1087KQgRr5e_0;
        canvas.translate(rectF2.right - f3, rectF2.bottom - f3);
        canvas.rotate(180.0f);
        canvas.drawPath(this.f1086KQgRr5e_0, this.f1093QxJ9d_1);
        if (z) {
            canvas.drawRect(0.0f, f2, this.f1087KQgRr5e_0.width() - f4, (-this.f1082KQgRr5e_0) + this.PGPF6hQ_2, this.f1090PGPF6hQ_2);
        }
        canvas.restoreToCount(save2);
        int save3 = canvas.save();
        RectF rectF3 = this.f1087KQgRr5e_0;
        canvas.translate(rectF3.left + f3, rectF3.bottom - f3);
        canvas.rotate(270.0f);
        canvas.drawPath(this.f1086KQgRr5e_0, this.f1093QxJ9d_1);
        if (z2) {
            canvas.drawRect(0.0f, f2, this.f1087KQgRr5e_0.height() - f4, -this.f1082KQgRr5e_0, this.f1090PGPF6hQ_2);
        }
        canvas.restoreToCount(save3);
        int save4 = canvas.save();
        RectF rectF4 = this.f1087KQgRr5e_0;
        canvas.translate(rectF4.right - f3, rectF4.top + f3);
        canvas.rotate(90.0f);
        canvas.drawPath(this.f1086KQgRr5e_0, this.f1093QxJ9d_1);
        if (z2) {
            canvas.drawRect(0.0f, f2, this.f1087KQgRr5e_0.height() - f4, -this.f1082KQgRr5e_0, this.f1090PGPF6hQ_2);
        }
        canvas.restoreToCount(save4);
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public final void m519KQgRr5e_0() {
        float f = this.f1082KQgRr5e_0;
        RectF rectF = new RectF(-f, -f, f, f);
        RectF rectF2 = new RectF(rectF);
        float f2 = this.PGPF6hQ_2;
        rectF2.inset(-f2, -f2);
        Path path = this.f1086KQgRr5e_0;
        if (path == null) {
            this.f1086KQgRr5e_0 = new Path();
        } else {
            path.reset();
        }
        this.f1086KQgRr5e_0.setFillType(Path.FillType.EVEN_ODD);
        this.f1086KQgRr5e_0.moveTo(-this.f1082KQgRr5e_0, 0.0f);
        this.f1086KQgRr5e_0.rLineTo(-this.PGPF6hQ_2, 0.0f);
        this.f1086KQgRr5e_0.arcTo(rectF2, 180.0f, 90.0f, false);
        this.f1086KQgRr5e_0.arcTo(rectF, 270.0f, -90.0f, false);
        this.f1086KQgRr5e_0.close();
        float f3 = this.f1082KQgRr5e_0;
        float f4 = f3 / (this.PGPF6hQ_2 + f3);
        Paint paint = this.f1093QxJ9d_1;
        float f5 = this.f1082KQgRr5e_0 + this.PGPF6hQ_2;
        int i = this.f1092QxJ9d_1;
        paint.setShader(new RadialGradient(0.0f, 0.0f, f5, new int[]{i, i, this.f1089PGPF6hQ_2}, new float[]{0.0f, f4, 1.0f}, Shader.TileMode.CLAMP));
        Paint paint2 = this.f1090PGPF6hQ_2;
        float f6 = this.f1082KQgRr5e_0;
        float f7 = this.PGPF6hQ_2;
        int i2 = this.f1092QxJ9d_1;
        paint2.setShader(new LinearGradient(0.0f, (-f6) + f7, 0.0f, (-f6) - f7, new int[]{i2, i2, this.f1089PGPF6hQ_2}, new float[]{0.0f, 0.5f, 1.0f}, Shader.TileMode.CLAMP));
        this.f1090PGPF6hQ_2.setAntiAlias(false);
    }

    public final void KQgRr5e_0(Rect rect) {
        float f = this.QxJ9d_1;
        float f2 = 1.5f * f;
        this.f1087KQgRr5e_0.set(rect.left + f, rect.top + f2, rect.right - f, rect.bottom - f2);
        m519KQgRr5e_0();
    }

    public float KQgRr5e_0() {
        return this.f1082KQgRr5e_0;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public ColorStateList m518KQgRr5e_0() {
        return this.f1084KQgRr5e_0;
    }
}
