package s3;

import M.J;
import android.animation.TimeInterpolator;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.animation.LinearInterpolator;
import com.google.android.material.textfield.TextInputLayout;
import i3.AbstractC1051a;
import j0.C1061a;
import java.lang.reflect.Field;
import u3.C1596a;

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

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

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

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    public int[] f16793C;
    public boolean D;

    /* JADX INFO: renamed from: E, reason: collision with root package name */
    public final TextPaint f16794E;

    /* JADX INFO: renamed from: F, reason: collision with root package name */
    public final TextPaint f16795F;

    /* JADX INFO: renamed from: G, reason: collision with root package name */
    public LinearInterpolator f16796G;
    public LinearInterpolator H;

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

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

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final Rect f16807d;

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

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public int f16810g = 16;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f16811h = 16;
    public float i = 15.0f;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public float f16812j = 15.0f;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    public b(TextInputLayout textInputLayout) {
        this.f16804a = textInputLayout;
        TextPaint textPaint = new TextPaint(129);
        this.f16794E = textPaint;
        this.f16795F = new TextPaint(textPaint);
        this.f16808e = new Rect();
        this.f16807d = new Rect();
        this.f16809f = new RectF();
    }

    public static int a(float f3, int i, int i5) {
        float f7 = 1.0f - f3;
        return Color.argb((int) ((Color.alpha(i5) * f3) + (Color.alpha(i) * f7)), (int) ((Color.red(i5) * f3) + (Color.red(i) * f7)), (int) ((Color.green(i5) * f3) + (Color.green(i) * f7)), (int) ((Color.blue(i5) * f3) + (Color.blue(i) * f7)));
    }

    public static float e(float f3, float f7, float f8, TimeInterpolator timeInterpolator) {
        if (timeInterpolator != null) {
            f8 = timeInterpolator.getInterpolation(f8);
        }
        return AbstractC1051a.a(f3, f7, f8);
    }

    public final float b() {
        if (this.f16825w == null) {
            return 0.0f;
        }
        TextPaint textPaint = this.f16795F;
        textPaint.setTextSize(this.f16812j);
        textPaint.setTypeface(this.f16821s);
        textPaint.setLetterSpacing(this.f16801M);
        CharSequence charSequence = this.f16825w;
        return textPaint.measureText(charSequence, 0, charSequence.length());
    }

    public final void c(float f3) {
        boolean z8;
        float f7;
        boolean z9;
        if (this.f16825w == null) {
            return;
        }
        float fWidth = this.f16808e.width();
        float fWidth2 = this.f16807d.width();
        if (Math.abs(f3 - this.f16812j) < 0.001f) {
            f7 = this.f16812j;
            this.f16791A = 1.0f;
            Typeface typeface = this.f16823u;
            Typeface typeface2 = this.f16821s;
            if (typeface != typeface2) {
                this.f16823u = typeface2;
                z9 = true;
            } else {
                z9 = false;
            }
        } else {
            float f8 = this.i;
            Typeface typeface3 = this.f16823u;
            Typeface typeface4 = this.f16822t;
            if (typeface3 != typeface4) {
                this.f16823u = typeface4;
                z8 = true;
            } else {
                z8 = false;
            }
            if (Math.abs(f3 - f8) < 0.001f) {
                this.f16791A = 1.0f;
            } else {
                this.f16791A = f3 / this.i;
            }
            float f9 = this.f16812j / this.i;
            fWidth = fWidth2 * f9 > fWidth ? Math.min(fWidth / f9, fWidth2) : fWidth2;
            f7 = f8;
            z9 = z8;
        }
        if (fWidth > 0.0f) {
            z9 = this.f16792B != f7 || this.D || z9;
            this.f16792B = f7;
            this.D = false;
        }
        if (this.f16826x == null || z9) {
            TextPaint textPaint = this.f16794E;
            textPaint.setTextSize(this.f16792B);
            textPaint.setTypeface(this.f16823u);
            textPaint.setLinearText(this.f16791A != 1.0f);
            CharSequence charSequence = this.f16825w;
            Field field = J.f4065a;
            boolean zE = (this.f16804a.getLayoutDirection() == 1 ? K.h.f3528d : K.h.f3527c).e(charSequence.length(), charSequence);
            this.f16827y = zE;
            g gVar = new g(this.f16825w, textPaint, (int) fWidth);
            gVar.f16849k = TextUtils.TruncateAt.END;
            gVar.f16848j = zE;
            gVar.f16844e = Layout.Alignment.ALIGN_NORMAL;
            gVar.i = false;
            gVar.f16845f = 1;
            gVar.f16846g = 1.0f;
            gVar.f16847h = 1;
            StaticLayout staticLayoutA = gVar.a();
            staticLayoutA.getClass();
            this.f16802N = staticLayoutA;
            this.f16826x = staticLayoutA.getText();
        }
    }

    public final int d(ColorStateList colorStateList) {
        if (colorStateList == null) {
            return 0;
        }
        int[] iArr = this.f16793C;
        return iArr != null ? colorStateList.getColorForState(iArr, 0) : colorStateList.getDefaultColor();
    }

    /* JADX WARN: Removed duplicated region for block: B:11:0x001e  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void f() {
        boolean z8;
        Rect rect = this.f16808e;
        if (rect.width() <= 0 || rect.height() <= 0) {
            z8 = false;
        } else {
            Rect rect2 = this.f16807d;
            if (rect2.width() > 0 && rect2.height() > 0) {
                z8 = true;
            }
        }
        this.f16805b = z8;
    }

    public final void g() {
        StaticLayout staticLayout;
        TextInputLayout textInputLayout = this.f16804a;
        if (textInputLayout.getHeight() <= 0 || textInputLayout.getWidth() <= 0) {
            return;
        }
        float f3 = this.f16792B;
        c(this.f16812j);
        CharSequence charSequence = this.f16826x;
        TextPaint textPaint = this.f16794E;
        if (charSequence != null && (staticLayout = this.f16802N) != null) {
            this.f16803O = TextUtils.ellipsize(charSequence, textPaint, staticLayout.getWidth(), TextUtils.TruncateAt.END);
        }
        CharSequence charSequence2 = this.f16803O;
        float fMeasureText = charSequence2 != null ? textPaint.measureText(charSequence2, 0, charSequence2.length()) : 0.0f;
        int absoluteGravity = Gravity.getAbsoluteGravity(this.f16811h, this.f16827y ? 1 : 0);
        int i = absoluteGravity & 112;
        Rect rect = this.f16808e;
        if (i == 48) {
            this.f16816n = rect.top;
        } else if (i != 80) {
            this.f16816n = rect.centerY() - ((textPaint.descent() - textPaint.ascent()) / 2.0f);
        } else {
            this.f16816n = textPaint.ascent() + rect.bottom;
        }
        int i5 = absoluteGravity & 8388615;
        if (i5 == 1) {
            this.f16818p = rect.centerX() - (fMeasureText / 2.0f);
        } else if (i5 != 5) {
            this.f16818p = rect.left;
        } else {
            this.f16818p = rect.right - fMeasureText;
        }
        c(this.i);
        float height = this.f16802N != null ? r3.getHeight() : 0.0f;
        CharSequence charSequence3 = this.f16826x;
        float fMeasureText2 = charSequence3 != null ? textPaint.measureText(charSequence3, 0, charSequence3.length()) : 0.0f;
        StaticLayout staticLayout2 = this.f16802N;
        if (staticLayout2 != null) {
            staticLayout2.getLineLeft(0);
        }
        int absoluteGravity2 = Gravity.getAbsoluteGravity(this.f16810g, this.f16827y ? 1 : 0);
        int i8 = absoluteGravity2 & 112;
        Rect rect2 = this.f16807d;
        if (i8 == 48) {
            this.f16815m = rect2.top;
        } else if (i8 != 80) {
            this.f16815m = rect2.centerY() - (height / 2.0f);
        } else {
            this.f16815m = textPaint.descent() + (rect2.bottom - height);
        }
        int i9 = absoluteGravity2 & 8388615;
        if (i9 == 1) {
            this.f16817o = rect2.centerX() - (fMeasureText2 / 2.0f);
        } else if (i9 != 5) {
            this.f16817o = rect2.left;
        } else {
            this.f16817o = rect2.right - fMeasureText2;
        }
        Bitmap bitmap = this.f16828z;
        if (bitmap != null) {
            bitmap.recycle();
            this.f16828z = null;
        }
        j(f3);
        float f7 = this.f16806c;
        RectF rectF = this.f16809f;
        rectF.left = e(rect2.left, rect.left, f7, this.f16796G);
        rectF.top = e(this.f16815m, this.f16816n, f7, this.f16796G);
        rectF.right = e(rect2.right, rect.right, f7, this.f16796G);
        rectF.bottom = e(rect2.bottom, rect.bottom, f7, this.f16796G);
        this.f16819q = e(this.f16817o, this.f16818p, f7, this.f16796G);
        this.f16820r = e(this.f16815m, this.f16816n, f7, this.f16796G);
        j(e(this.i, this.f16812j, f7, this.H));
        C1061a c1061a = AbstractC1051a.f13506b;
        e(0.0f, 1.0f, 1.0f - f7, c1061a);
        Field field = J.f4065a;
        textInputLayout.postInvalidateOnAnimation();
        e(1.0f, 0.0f, f7, c1061a);
        textInputLayout.postInvalidateOnAnimation();
        ColorStateList colorStateList = this.f16814l;
        ColorStateList colorStateList2 = this.f16813k;
        if (colorStateList != colorStateList2) {
            textPaint.setColor(a(f7, d(colorStateList2), d(this.f16814l)));
        } else {
            textPaint.setColor(d(colorStateList));
        }
        float f8 = this.f16801M;
        if (f8 != 0.0f) {
            textPaint.setLetterSpacing(e(0.0f, f8, f7, c1061a));
        } else {
            textPaint.setLetterSpacing(f8);
        }
        textPaint.setShadowLayer(AbstractC1051a.a(0.0f, this.f16797I, f7), AbstractC1051a.a(0.0f, this.f16798J, f7), AbstractC1051a.a(0.0f, this.f16799K, f7), a(f7, 0, d(this.f16800L)));
        textInputLayout.postInvalidateOnAnimation();
    }

    public final void h(ColorStateList colorStateList) {
        if (this.f16814l != colorStateList) {
            this.f16814l = colorStateList;
            g();
        }
    }

    public final void i(float f3) {
        if (f3 < 0.0f) {
            f3 = 0.0f;
        } else if (f3 > 1.0f) {
            f3 = 1.0f;
        }
        if (f3 != this.f16806c) {
            this.f16806c = f3;
            RectF rectF = this.f16809f;
            float f7 = this.f16807d.left;
            Rect rect = this.f16808e;
            rectF.left = e(f7, rect.left, f3, this.f16796G);
            rectF.top = e(this.f16815m, this.f16816n, f3, this.f16796G);
            rectF.right = e(r3.right, rect.right, f3, this.f16796G);
            rectF.bottom = e(r3.bottom, rect.bottom, f3, this.f16796G);
            this.f16819q = e(this.f16817o, this.f16818p, f3, this.f16796G);
            this.f16820r = e(this.f16815m, this.f16816n, f3, this.f16796G);
            j(e(this.i, this.f16812j, f3, this.H));
            C1061a c1061a = AbstractC1051a.f13506b;
            e(0.0f, 1.0f, 1.0f - f3, c1061a);
            Field field = J.f4065a;
            TextInputLayout textInputLayout = this.f16804a;
            textInputLayout.postInvalidateOnAnimation();
            e(1.0f, 0.0f, f3, c1061a);
            textInputLayout.postInvalidateOnAnimation();
            ColorStateList colorStateList = this.f16814l;
            ColorStateList colorStateList2 = this.f16813k;
            TextPaint textPaint = this.f16794E;
            if (colorStateList != colorStateList2) {
                textPaint.setColor(a(f3, d(colorStateList2), d(this.f16814l)));
            } else {
                textPaint.setColor(d(colorStateList));
            }
            float f8 = this.f16801M;
            if (f8 != 0.0f) {
                textPaint.setLetterSpacing(e(0.0f, f8, f3, c1061a));
            } else {
                textPaint.setLetterSpacing(f8);
            }
            textPaint.setShadowLayer(AbstractC1051a.a(0.0f, this.f16797I, f3), AbstractC1051a.a(0.0f, this.f16798J, f3), AbstractC1051a.a(0.0f, this.f16799K, f3), a(f3, 0, d(this.f16800L)));
            textInputLayout.postInvalidateOnAnimation();
        }
    }

    public final void j(float f3) {
        c(f3);
        Field field = J.f4065a;
        this.f16804a.postInvalidateOnAnimation();
    }
}
