package com.google.android.material.internal;

import android.animation.TimeInterpolator;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.os.Build;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import androidx.annotation.ColorInt;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.google.android.gms.measurement.internal.u1;

/* JADX INFO: loaded from: classes2.dex */
public final class e {

    @Nullable
    private static final Paint DEBUG_DRAW_PAINT = null;
    public Typeface A;
    public Typeface B;
    public Typeface C;
    public q9.b D;
    public q9.b E;
    public boolean G;
    public float I;
    public float J;
    public float K;
    public float L;
    public float M;
    public int N;
    public int O;
    public int[] P;
    public boolean Q;
    public final TextPaint R;
    public final TextPaint S;
    public TimeInterpolator T;
    public TimeInterpolator U;
    public float V;
    public float W;
    public float X;
    public ColorStateList Y;
    public float Z;

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

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

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

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

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

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

    @Nullable
    private Rect collapsedBoundsForPlacement;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    @Nullable
    private l0 staticLayoutBuilderConfigurer;

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

    @Nullable
    private CharSequence text;

    @Nullable
    private CharSequence textToDraw;

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

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public float f22742m = 15.0f;
    public TextUtils.TruncateAt F = TextUtils.TruncateAt.END;
    public boolean H = true;

    /* JADX INFO: renamed from: l0, reason: collision with root package name */
    public int f22741l0 = 1;

    /* JADX INFO: renamed from: m0, reason: collision with root package name */
    public int f22743m0 = 1;

    /* JADX INFO: renamed from: n0, reason: collision with root package name */
    public float f22745n0 = 0.0f;

    /* JADX INFO: renamed from: o0, reason: collision with root package name */
    public float f22747o0 = 1.0f;

    /* JADX INFO: renamed from: p0, reason: collision with root package name */
    public int f22749p0 = 1;

    /* JADX INFO: renamed from: q0, reason: collision with root package name */
    public int f22751q0 = -1;

    /* JADX INFO: renamed from: r0, reason: collision with root package name */
    public int f22753r0 = -1;

    public e(View view) {
        this.f22718a = view;
        TextPaint textPaint = new TextPaint(129);
        this.R = textPaint;
        this.S = new TextPaint(textPaint);
        this.f22732h = new Rect();
        this.f22730g = new Rect();
        this.f22734i = new RectF();
        float f10 = this.f22724d;
        this.f22726e = u1.a(1.0f, f10, 0.5f, f10);
        k(view.getContext().getResources().getConfiguration());
    }

    public static int a(float f10, int i10, int i11) {
        float f11 = 1.0f - f10;
        return Color.argb(Math.round((Color.alpha(i11) * f10) + (Color.alpha(i10) * f11)), Math.round((Color.red(i11) * f10) + (Color.red(i10) * f11)), Math.round((Color.green(i11) * f10) + (Color.green(i10) * f11)), Math.round((Color.blue(i11) * f10) + (Color.blue(i10) * f11)));
    }

    @ColorInt
    private int getCurrentColor(@Nullable ColorStateList colorStateList) {
        if (colorStateList == null) {
            return 0;
        }
        int[] iArr = this.P;
        return iArr != null ? colorStateList.getColorForState(iArr, 0) : colorStateList.getDefaultColor();
    }

    private static float lerp(float f10, float f11, float f12, @Nullable TimeInterpolator timeInterpolator) {
        if (timeInterpolator != null) {
            f12 = timeInterpolator.getInterpolation(f12);
        }
        return y8.a.a(f10, f11, f12);
    }

    public static boolean m(Rect rect, int i10, int i11, int i12, int i13) {
        return rect.left == i10 && rect.top == i11 && rect.right == i12 && rect.bottom == i13;
    }

    public final boolean A() {
        return this.f22743m0 == 1;
    }

    public final void B(int i10) {
        TextPaint textPaint = this.S;
        textPaint.setTextSize(this.f22742m);
        textPaint.setTypeface(this.f22759w);
        textPaint.setLetterSpacing(this.f22725d0);
        float f10 = i10;
        this.f22751q0 = e(this.f22743m0, textPaint, this.text, (this.f22742m / this.f22740l) * f10, this.G).getHeight();
        textPaint.setTextSize(this.f22740l);
        textPaint.setTypeface(this.f22762z);
        textPaint.setLetterSpacing(this.f22727e0);
        this.f22753r0 = e(this.f22741l0, textPaint, this.text, f10, this.G).getHeight();
    }

    public final void b() {
        float f10;
        float f11 = this.f22720b;
        boolean z10 = this.f22722c;
        RectF rectF = this.f22734i;
        Rect rect = this.f22732h;
        Rect rect2 = this.f22730g;
        if (z10) {
            if (f11 < this.f22726e) {
                rect = rect2;
            }
            rectF.set(rect);
        } else {
            rectF.left = lerp(rect2.left, rect.left, f11, this.T);
            rectF.top = lerp(this.f22750q, this.f22752r, f11, this.T);
            rectF.right = lerp(rect2.right, rect.right, f11, this.T);
            rectF.bottom = lerp(rect2.bottom, rect.bottom, f11, this.T);
        }
        boolean z11 = this.f22722c;
        View view = this.f22718a;
        if (!z11) {
            this.f22757u = lerp(this.f22754s, this.f22756t, f11, this.T);
            this.f22758v = lerp(this.f22750q, this.f22752r, f11, this.T);
            d(f11, false);
            view.postInvalidateOnAnimation();
            f10 = f11;
        } else if (f11 < this.f22726e) {
            this.f22757u = this.f22754s;
            this.f22758v = this.f22750q;
            d(0.0f, false);
            view.postInvalidateOnAnimation();
            f10 = 0.0f;
        } else {
            this.f22757u = this.f22756t;
            this.f22758v = this.f22752r - Math.max(0, this.f22728f);
            d(1.0f, false);
            view.postInvalidateOnAnimation();
            f10 = 1.0f;
        }
        l1.b bVar = y8.a.f36865b;
        this.f22735i0 = 1.0f - lerp(0.0f, 1.0f, 1.0f - f11, bVar);
        view.postInvalidateOnAnimation();
        this.f22737j0 = lerp(1.0f, 0.0f, f11, bVar);
        view.postInvalidateOnAnimation();
        ColorStateList colorStateList = this.f22746o;
        ColorStateList colorStateList2 = this.f22744n;
        TextPaint textPaint = this.R;
        if (colorStateList != colorStateList2) {
            textPaint.setColor(a(f10, getCurrentColor(colorStateList2), getCurrentColor(this.f22746o)));
        } else {
            textPaint.setColor(getCurrentColor(colorStateList));
        }
        float f12 = this.f22725d0;
        float f13 = this.f22727e0;
        if (f12 != f13) {
            textPaint.setLetterSpacing(lerp(f13, f12, f11, bVar));
        } else {
            textPaint.setLetterSpacing(f12);
        }
        this.K = lerp(this.Z, this.V, f11, null);
        this.L = lerp(this.f22719a0, this.W, f11, null);
        this.M = lerp(this.f22721b0, this.X, f11, null);
        int iA = a(f11, getCurrentColor(this.f22723c0), getCurrentColor(this.Y));
        this.N = iA;
        textPaint.setShadowLayer(this.K, this.L, this.M, iA);
        if (this.f22722c) {
            int alpha = textPaint.getAlpha();
            float f14 = this.f22726e;
            textPaint.setAlpha((int) ((f11 <= f14 ? y8.a.b(1.0f, 0.0f, this.f22724d, f14, f11) : y8.a.b(0.0f, 1.0f, f14, 1.0f, f11)) * alpha));
            if (Build.VERSION.SDK_INT >= 31) {
                textPaint.setShadowLayer(this.K, this.L, this.M, h9.a.a(this.N, textPaint.getAlpha()));
            }
        }
        view.postInvalidateOnAnimation();
    }

    public final boolean c(CharSequence charSequence) {
        boolean z10 = this.f22718a.getLayoutDirection() == 1;
        if (this.H) {
            return (z10 ? o0.k.f31282d : o0.k.f31281c).l(charSequence, charSequence.length());
        }
        return z10;
    }

    public final void d(float f10, boolean z10) {
        float f11;
        Typeface typeface;
        float f12;
        if (this.text == null) {
            return;
        }
        float fWidth = this.f22732h.width();
        float fWidth2 = this.f22730g.width();
        if (Math.abs(f10 - 1.0f) < 1.0E-5f) {
            f11 = A() ? this.f22742m : this.f22740l;
            f12 = A() ? this.f22725d0 : this.f22727e0;
            this.I = A() ? 1.0f : lerp(this.f22740l, this.f22742m, f10, this.U) / this.f22740l;
            if (!A()) {
                fWidth = fWidth2;
            }
            typeface = this.f22759w;
            fWidth2 = fWidth;
        } else {
            f11 = this.f22740l;
            float f13 = this.f22727e0;
            typeface = this.f22762z;
            if (Math.abs(f10 - 0.0f) < 1.0E-5f) {
                this.I = 1.0f;
            } else {
                this.I = lerp(this.f22740l, this.f22742m, f10, this.U) / this.f22740l;
            }
            float f14 = this.f22742m / this.f22740l;
            float f15 = fWidth2 * f14;
            if (!z10 && !this.f22722c && f15 > fWidth && A()) {
                fWidth2 = Math.min(fWidth / f14, fWidth2);
            }
            f12 = f13;
        }
        int i10 = f10 < 0.5f ? this.f22741l0 : this.f22743m0;
        TextPaint textPaint = this.R;
        if (fWidth2 > 0.0f) {
            boolean z11 = this.J != f11;
            boolean z12 = this.f22729f0 != f12;
            boolean z13 = this.C != typeface;
            StaticLayout staticLayout = this.f22731g0;
            boolean z14 = z11 || z12 || (staticLayout != null && (fWidth2 > ((float) staticLayout.getWidth()) ? 1 : (fWidth2 == ((float) staticLayout.getWidth()) ? 0 : -1)) != 0) || z13 || (this.O != i10) || this.Q;
            this.J = f11;
            this.f22729f0 = f12;
            this.C = typeface;
            this.Q = false;
            this.O = i10;
            textPaint.setLinearText(this.I != 1.0f);
            z = z14;
        }
        if (this.textToDraw == null || z) {
            textPaint.setTextSize(this.J);
            textPaint.setTypeface(this.C);
            textPaint.setLetterSpacing(this.f22729f0);
            boolean zC = c(this.text);
            this.G = zC;
            StaticLayout staticLayoutE = e(((this.f22741l0 > 1 || this.f22743m0 > 1) && (!zC || this.f22722c)) ? i10 : 1, textPaint, this.text, fWidth2 * (A() ? 1.0f : this.I), this.G);
            this.f22731g0 = staticLayoutE;
            this.textToDraw = staticLayoutE.getText();
        }
    }

    public final StaticLayout e(int i10, TextPaint textPaint, CharSequence charSequence, float f10, boolean z10) {
        Layout.Alignment alignment;
        if (i10 == 1) {
            alignment = Layout.Alignment.ALIGN_NORMAL;
        } else {
            int absoluteGravity = Gravity.getAbsoluteGravity(this.f22736j, this.G ? 1 : 0) & 7;
            alignment = absoluteGravity != 1 ? absoluteGravity != 5 ? this.G ? Layout.Alignment.ALIGN_OPPOSITE : Layout.Alignment.ALIGN_NORMAL : this.G ? Layout.Alignment.ALIGN_NORMAL : Layout.Alignment.ALIGN_OPPOSITE : Layout.Alignment.ALIGN_CENTER;
        }
        k0 ellipsize = new k0(charSequence, textPaint, (int) f10).setEllipsize(this.F);
        ellipsize.f22786k = z10;
        ellipsize.f22780e = alignment;
        ellipsize.f22785j = false;
        ellipsize.f22781f = i10;
        float f11 = this.f22745n0;
        float f12 = this.f22747o0;
        ellipsize.f22782g = f11;
        ellipsize.f22783h = f12;
        ellipsize.f22784i = this.f22749p0;
        return (StaticLayout) p0.g.checkNotNull(ellipsize.setStaticLayoutBuilderConfigurer(this.staticLayoutBuilderConfigurer).a());
    }

    public final void f(Canvas canvas) {
        int iSave = canvas.save();
        if (this.textToDraw != null) {
            RectF rectF = this.f22734i;
            if (rectF.width() <= 0.0f || rectF.height() <= 0.0f) {
                return;
            }
            TextPaint textPaint = this.R;
            textPaint.setTextSize(this.J);
            float f10 = this.f22757u;
            float f11 = this.f22758v;
            float f12 = this.I;
            if (f12 != 1.0f && !this.f22722c) {
                canvas.scale(f12, f12, f10, f11);
            }
            if ((this.f22741l0 > 1 || this.f22743m0 > 1) && ((!this.G || this.f22722c) && A() && (!this.f22722c || this.f22720b > this.f22726e))) {
                float lineStart = this.f22757u - this.f22731g0.getLineStart(0);
                int alpha = textPaint.getAlpha();
                canvas.translate(lineStart, f11);
                if (!this.f22722c) {
                    textPaint.setAlpha((int) (this.f22737j0 * alpha));
                    if (Build.VERSION.SDK_INT >= 31) {
                        textPaint.setShadowLayer(this.K, this.L, this.M, h9.a.a(this.N, textPaint.getAlpha()));
                    }
                    this.f22731g0.draw(canvas);
                }
                if (!this.f22722c) {
                    textPaint.setAlpha((int) (this.f22735i0 * alpha));
                }
                int i10 = Build.VERSION.SDK_INT;
                if (i10 >= 31) {
                    textPaint.setShadowLayer(this.K, this.L, this.M, h9.a.a(this.N, textPaint.getAlpha()));
                }
                int lineBaseline = this.f22731g0.getLineBaseline(0);
                CharSequence charSequence = this.f22739k0;
                float f13 = lineBaseline;
                canvas.drawText(charSequence, 0, charSequence.length(), 0.0f, f13, textPaint);
                if (i10 >= 31) {
                    textPaint.setShadowLayer(this.K, this.L, this.M, this.N);
                }
                if (!this.f22722c) {
                    String strTrim = this.f22739k0.toString().trim();
                    if (strTrim.endsWith("…")) {
                        strTrim = u1.h(strTrim, 1, 0);
                    }
                    String str = strTrim;
                    textPaint.setAlpha(alpha);
                    canvas.drawText(str, 0, Math.min(this.f22731g0.getLineEnd(0), str.length()), 0.0f, f13, (Paint) textPaint);
                }
            } else {
                canvas.translate(f10, f11);
                this.f22731g0.draw(canvas);
            }
            canvas.restoreToCount(iSave);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:40:0x0076  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void g(RectF rectF, int i10, int i11) {
        float f10;
        float f11;
        float f12;
        float f13;
        int i12;
        int i13;
        boolean zC = c(this.text);
        this.G = zC;
        Rect rect = this.f22732h;
        if (i11 != 17 && (i11 & 7) != 1) {
            if ((i11 & 8388613) == 8388613 || (i11 & 5) == 5) {
                if (zC) {
                    i13 = rect.left;
                    f12 = i13;
                } else {
                    f10 = rect.right;
                    f11 = this.f22733h0;
                }
            } else if (zC) {
                f10 = rect.right;
                f11 = this.f22733h0;
            } else {
                i13 = rect.left;
                f12 = i13;
            }
            float fMax = Math.max(f12, rect.left);
            rectF.left = fMax;
            rectF.top = rect.top;
            if (i11 != 17 || (i11 & 7) == 1) {
                f13 = (i10 / 2.0f) + (this.f22733h0 / 2.0f);
            } else if ((i11 & 8388613) == 8388613 || (i11 & 5) == 5) {
                if (this.G) {
                    f13 = fMax + this.f22733h0;
                } else {
                    i12 = rect.right;
                    f13 = i12;
                }
            } else if (this.G) {
                i12 = rect.right;
                f13 = i12;
            } else {
                f13 = this.f22733h0 + fMax;
            }
            rectF.right = Math.min(f13, rect.right);
            rectF.bottom = h() + rect.top;
            if (this.f22731g0 != null || A()) {
            }
            StaticLayout staticLayout = this.f22731g0;
            float lineWidth = (this.f22742m / this.f22740l) * staticLayout.getLineWidth(staticLayout.getLineCount() - 1);
            if (this.G) {
                rectF.left = rectF.right - lineWidth;
                return;
            } else {
                rectF.right = rectF.left + lineWidth;
                return;
            }
        }
        f10 = i10 / 2.0f;
        f11 = this.f22733h0 / 2.0f;
        f12 = f10 - f11;
        float fMax2 = Math.max(f12, rect.left);
        rectF.left = fMax2;
        rectF.top = rect.top;
        if (i11 != 17) {
            f13 = (i10 / 2.0f) + (this.f22733h0 / 2.0f);
        }
        rectF.right = Math.min(f13, rect.right);
        rectF.bottom = h() + rect.top;
        if (this.f22731g0 != null) {
        }
    }

    @Nullable
    public TimeInterpolator getPositionInterpolator() {
        return this.T;
    }

    @Nullable
    public CharSequence getText() {
        return this.text;
    }

    public final float h() {
        int i10 = this.f22751q0;
        if (i10 != -1) {
            return i10;
        }
        TextPaint textPaint = this.S;
        textPaint.setTextSize(this.f22742m);
        textPaint.setTypeface(this.f22759w);
        textPaint.setLetterSpacing(this.f22725d0);
        return -textPaint.ascent();
    }

    public final int i() {
        return getCurrentColor(this.f22746o);
    }

    public final float j() {
        TextPaint textPaint = this.S;
        textPaint.setTextSize(this.f22740l);
        textPaint.setTypeface(this.f22762z);
        textPaint.setLetterSpacing(this.f22727e0);
        return textPaint.descent() + (-textPaint.ascent());
    }

    public final void k(Configuration configuration) {
        if (Build.VERSION.SDK_INT >= 31) {
            Typeface typeface = this.f22761y;
            if (typeface != null) {
                this.f22760x = q9.i.maybeCopyWithFontWeightAdjustment(configuration, typeface);
            }
            Typeface typeface2 = this.B;
            if (typeface2 != null) {
                this.A = q9.i.maybeCopyWithFontWeightAdjustment(configuration, typeface2);
            }
            Typeface typeface3 = this.f22760x;
            if (typeface3 == null) {
                typeface3 = this.f22761y;
            }
            this.f22759w = typeface3;
            Typeface typeface4 = this.A;
            if (typeface4 == null) {
                typeface4 = this.B;
            }
            this.f22762z = typeface4;
            l(true);
        }
    }

    public final void l(boolean z10) {
        float fMeasureText;
        View view = this.f22718a;
        if ((view.getHeight() <= 0 || view.getWidth() <= 0) && !z10) {
            return;
        }
        d(1.0f, z10);
        CharSequence charSequence = this.textToDraw;
        TextPaint textPaint = this.R;
        if (charSequence != null && this.f22731g0 != null) {
            this.f22739k0 = A() ? TextUtils.ellipsize(this.textToDraw, textPaint, this.f22731g0.getWidth(), this.F) : this.textToDraw;
        }
        CharSequence charSequence2 = this.f22739k0;
        if (charSequence2 != null) {
            this.f22733h0 = textPaint.measureText(charSequence2, 0, charSequence2.length());
        } else {
            this.f22733h0 = 0.0f;
        }
        int absoluteGravity = Gravity.getAbsoluteGravity(this.f22738k, this.G ? 1 : 0);
        Rect rect = this.collapsedBoundsForPlacement;
        Rect rect2 = this.f22732h;
        if (rect == null) {
            rect = rect2;
        }
        int i10 = absoluteGravity & 112;
        if (i10 == 48) {
            this.f22752r = rect.top;
        } else if (i10 != 80) {
            this.f22752r = rect.centerY() - ((textPaint.descent() - textPaint.ascent()) / 2.0f);
        } else {
            this.f22752r = textPaint.ascent() + rect.bottom;
        }
        int i11 = absoluteGravity & 8388615;
        if (i11 == 1) {
            this.f22756t = rect.centerX() - (this.f22733h0 / 2.0f);
        } else if (i11 != 5) {
            this.f22756t = rect.left;
        } else {
            this.f22756t = rect.right - this.f22733h0;
        }
        if (this.f22733h0 <= rect2.width()) {
            float f10 = this.f22756t;
            float fMax = Math.max(0.0f, rect2.left - f10) + f10;
            this.f22756t = fMax;
            this.f22756t = Math.min(0.0f, rect2.right - (this.f22733h0 + fMax)) + fMax;
        }
        TextPaint textPaint2 = this.S;
        textPaint2.setTextSize(this.f22742m);
        textPaint2.setTypeface(this.f22759w);
        textPaint2.setLetterSpacing(this.f22725d0);
        if (textPaint2.descent() + (-textPaint2.ascent()) <= rect2.height()) {
            float f11 = this.f22752r;
            float fMax2 = Math.max(0.0f, rect2.top - f11) + f11;
            this.f22752r = fMax2;
            this.f22752r = Math.min(0.0f, rect2.bottom - (h() + fMax2)) + fMax2;
        }
        d(0.0f, z10);
        float height = this.f22731g0 != null ? r15.getHeight() : 0.0f;
        StaticLayout staticLayout = this.f22731g0;
        if (staticLayout == null || this.f22741l0 <= 1) {
            CharSequence charSequence3 = this.textToDraw;
            fMeasureText = charSequence3 != null ? textPaint.measureText(charSequence3, 0, charSequence3.length()) : 0.0f;
        } else {
            fMeasureText = staticLayout.getWidth();
        }
        StaticLayout staticLayout2 = this.f22731g0;
        this.f22748p = staticLayout2 != null ? staticLayout2.getLineCount() : 0;
        int absoluteGravity2 = Gravity.getAbsoluteGravity(this.f22736j, this.G ? 1 : 0);
        int i12 = absoluteGravity2 & 112;
        Rect rect3 = this.f22730g;
        if (i12 == 48) {
            this.f22750q = rect3.top;
        } else if (i12 != 80) {
            this.f22750q = rect3.centerY() - (height / 2.0f);
        } else {
            this.f22750q = (rect3.bottom - height) + (this.f22755s0 ? textPaint.descent() : 0.0f);
        }
        int i13 = absoluteGravity2 & 8388615;
        if (i13 == 1) {
            this.f22754s = rect3.centerX() - (fMeasureText / 2.0f);
        } else if (i13 != 5) {
            this.f22754s = rect3.left;
        } else {
            this.f22754s = rect3.right - fMeasureText;
        }
        d(this.f22720b, false);
        view.postInvalidateOnAnimation();
        b();
    }

    public final void n(int i10, int i11, int i12, int i13) {
        Rect rect = this.f22732h;
        if (m(rect, i10, i11, i12, i13)) {
            return;
        }
        rect.set(i10, i11, i12, i13);
        this.Q = true;
    }

    public final void o(int i10, int i11, int i12, int i13) {
        if (this.collapsedBoundsForPlacement == null) {
            this.collapsedBoundsForPlacement = new Rect(i10, i11, i12, i13);
            this.Q = true;
        }
        if (m(this.collapsedBoundsForPlacement, i10, i11, i12, i13)) {
            return;
        }
        this.collapsedBoundsForPlacement.set(i10, i11, i12, i13);
        this.Q = true;
    }

    public final void p(int i10) {
        View view = this.f22718a;
        q9.g gVar = new q9.g(view.getContext(), i10);
        if (gVar.getTextColor() != null) {
            this.f22746o = gVar.getTextColor();
        }
        float f10 = gVar.f32262h;
        if (f10 != 0.0f) {
            this.f22742m = f10;
        }
        ColorStateList colorStateList = gVar.shadowColor;
        if (colorStateList != null) {
            this.Y = colorStateList;
        }
        this.W = gVar.f32257c;
        this.X = gVar.f32258d;
        this.V = gVar.f32259e;
        this.f22725d0 = gVar.f32261g;
        q9.b bVar = this.E;
        if (bVar != null) {
            bVar.f32248c = true;
        }
        d dVar = new d(this, 0);
        gVar.a();
        this.E = new q9.b(dVar, gVar.f32266l);
        gVar.b(view.getContext(), this.E);
        l(false);
    }

    public final void q(ColorStateList colorStateList) {
        if (this.f22746o != colorStateList) {
            this.f22746o = colorStateList;
            l(false);
        }
    }

    public final void r(int i10) {
        if (this.f22738k != i10) {
            this.f22738k = i10;
            l(false);
        }
    }

    public final boolean s(Typeface typeface) {
        q9.b bVar = this.E;
        if (bVar != null) {
            bVar.f32248c = true;
        }
        if (this.f22761y == typeface) {
            return false;
        }
        this.f22761y = typeface;
        Typeface typefaceMaybeCopyWithFontWeightAdjustment = q9.i.maybeCopyWithFontWeightAdjustment(this.f22718a.getContext().getResources().getConfiguration(), typeface);
        this.f22760x = typefaceMaybeCopyWithFontWeightAdjustment;
        if (typefaceMaybeCopyWithFontWeightAdjustment == null) {
            typefaceMaybeCopyWithFontWeightAdjustment = this.f22761y;
        }
        this.f22759w = typefaceMaybeCopyWithFontWeightAdjustment;
        return true;
    }

    public void setCollapsedAndExpandedTextColor(@Nullable ColorStateList colorStateList) {
        if (this.f22746o == colorStateList && this.f22744n == colorStateList) {
            return;
        }
        this.f22746o = colorStateList;
        this.f22744n = colorStateList;
        l(false);
    }

    @RequiresApi(23)
    public void setStaticLayoutBuilderConfigurer(@Nullable l0 l0Var) {
        if (this.staticLayoutBuilderConfigurer != l0Var) {
            this.staticLayoutBuilderConfigurer = l0Var;
            l(true);
        }
    }

    public void setText(@Nullable CharSequence charSequence) {
        if (charSequence == null || !TextUtils.equals(this.text, charSequence)) {
            this.text = charSequence;
            this.textToDraw = null;
            l(false);
        }
    }

    public final void t(int i10, int i11, int i12, int i13, boolean z10) {
        Rect rect = this.f22730g;
        if (m(rect, i10, i11, i12, i13) && z10 == this.f22755s0) {
            return;
        }
        rect.set(i10, i11, i12, i13);
        this.Q = true;
        this.f22755s0 = z10;
    }

    public final void u(int i10) {
        if (i10 != this.f22741l0) {
            this.f22741l0 = i10;
            l(false);
        }
    }

    public final void v(int i10) {
        View view = this.f22718a;
        q9.g gVar = new q9.g(view.getContext(), i10);
        if (gVar.getTextColor() != null) {
            this.f22744n = gVar.getTextColor();
        }
        float f10 = gVar.f32262h;
        if (f10 != 0.0f) {
            this.f22740l = f10;
        }
        ColorStateList colorStateList = gVar.shadowColor;
        if (colorStateList != null) {
            this.f22723c0 = colorStateList;
        }
        this.f22719a0 = gVar.f32257c;
        this.f22721b0 = gVar.f32258d;
        this.Z = gVar.f32259e;
        this.f22727e0 = gVar.f32261g;
        q9.b bVar = this.D;
        if (bVar != null) {
            bVar.f32248c = true;
        }
        d dVar = new d(this, 1);
        gVar.a();
        this.D = new q9.b(dVar, gVar.f32266l);
        gVar.b(view.getContext(), this.D);
        l(false);
    }

    public final void w(int i10) {
        if (this.f22736j != i10) {
            this.f22736j = i10;
            l(false);
        }
    }

    public final void x(float f10) {
        if (this.f22740l != f10) {
            this.f22740l = f10;
            l(false);
        }
    }

    public final boolean y(Typeface typeface) {
        q9.b bVar = this.D;
        if (bVar != null) {
            bVar.f32248c = true;
        }
        if (this.B == typeface) {
            return false;
        }
        this.B = typeface;
        Typeface typefaceMaybeCopyWithFontWeightAdjustment = q9.i.maybeCopyWithFontWeightAdjustment(this.f22718a.getContext().getResources().getConfiguration(), typeface);
        this.A = typefaceMaybeCopyWithFontWeightAdjustment;
        if (typefaceMaybeCopyWithFontWeightAdjustment == null) {
            typefaceMaybeCopyWithFontWeightAdjustment = this.B;
        }
        this.f22762z = typefaceMaybeCopyWithFontWeightAdjustment;
        return true;
    }

    public final void z(float f10) {
        float f11 = kotlinx.coroutines.y.f(f10, 0.0f, 1.0f);
        if (f11 != this.f22720b) {
            this.f22720b = f11;
            b();
        }
    }
}
