package androidx.constraintlayout.utils.widget;

import a0.q;
import a0.y;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.ViewParent;
import androidx.constraintlayout.motion.widget.MotionLayout;
import androidx.constraintlayout.widget.s;
import java.util.HashMap;
import v.b;
import v.r;
import z.f;
import z.k;

/* JADX INFO: loaded from: classes.dex */
public class MotionTelltales extends MockView {
    public final float[] Q;
    public final Matrix R;
    public int S;
    public int T;
    public float U;

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

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

    public MotionTelltales(Context context) {
        super(context);
        this.f1253l = new Paint();
        this.Q = new float[2];
        this.R = new Matrix();
        this.S = 0;
        this.T = -65281;
        this.U = 0.25f;
        b(context, null);
    }

    public final void b(Context context, AttributeSet attributeSet) {
        if (attributeSet != null) {
            TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, s.MotionTelltales);
            int indexCount = typedArrayObtainStyledAttributes.getIndexCount();
            for (int i10 = 0; i10 < indexCount; i10++) {
                int index = typedArrayObtainStyledAttributes.getIndex(i10);
                if (index == s.MotionTelltales_telltales_tailColor) {
                    this.T = typedArrayObtainStyledAttributes.getColor(index, this.T);
                } else if (index == s.MotionTelltales_telltales_velocityMode) {
                    this.S = typedArrayObtainStyledAttributes.getInt(index, this.S);
                } else if (index == s.MotionTelltales_telltales_tailScale) {
                    this.U = typedArrayObtainStyledAttributes.getFloat(index, this.U);
                }
            }
            typedArrayObtainStyledAttributes.recycle();
        }
        int i11 = this.T;
        Paint paint = this.f1253l;
        paint.setColor(i11);
        paint.setStrokeWidth(5.0f);
    }

    @Override // android.view.View
    public final void onAttachedToWindow() {
        super.onAttachedToWindow();
    }

    @Override // androidx.constraintlayout.utils.widget.MockView, android.view.View
    public final void onDraw(Canvas canvas) {
        int i10;
        Matrix matrix;
        int i11;
        float f10;
        float[] fArr;
        int i12;
        int i13;
        float[] fArr2;
        float f11;
        float f12;
        int i14;
        k kVar;
        int i15;
        k kVar2;
        k kVar3;
        k kVar4;
        float[] fArr3;
        float f13;
        float f14;
        double[] dArr;
        r rVar;
        MotionTelltales motionTelltales = this;
        super.onDraw(canvas);
        Matrix matrix2 = getMatrix();
        Matrix matrix3 = motionTelltales.R;
        matrix2.invert(matrix3);
        if (motionTelltales.f1254m == null) {
            ViewParent parent = getParent();
            if (parent instanceof MotionLayout) {
                motionTelltales.f1254m = (MotionLayout) parent;
                return;
            }
            return;
        }
        int width = getWidth();
        int height = getHeight();
        int i16 = 5;
        float[] fArr4 = {0.1f, 0.25f, 0.5f, 0.75f, 0.9f};
        int i17 = 0;
        while (i17 < i16) {
            float f15 = fArr4[i17];
            int i18 = 0;
            while (i18 < i16) {
                float f16 = fArr4[i18];
                MotionLayout motionLayout = motionTelltales.f1254m;
                float[] fArr5 = motionTelltales.Q;
                int i19 = motionTelltales.S;
                float fA = motionLayout.U;
                float interpolation = motionLayout.f1107i0;
                if (motionLayout.S != null) {
                    float fSignum = Math.signum(motionLayout.f1109k0 - interpolation);
                    float interpolation2 = motionLayout.S.getInterpolation(motionLayout.f1107i0 + 1.0E-5f);
                    interpolation = motionLayout.S.getInterpolation(motionLayout.f1107i0);
                    fA = (((interpolation2 - interpolation) / 1.0E-5f) * fSignum) / motionLayout.f1105g0;
                }
                a0.r rVar2 = motionLayout.S;
                if (rVar2 instanceof a0.r) {
                    fA = rVar2.a();
                }
                float f17 = fA;
                q qVar = (q) motionLayout.f1101e0.get(motionTelltales);
                if ((i19 & 1) == 0) {
                    int width2 = getWidth();
                    int height2 = getHeight();
                    float[] fArr6 = qVar.f187v;
                    float fB = qVar.b(fArr6, interpolation);
                    HashMap map = qVar.f190y;
                    fArr = fArr4;
                    if (map == null) {
                        i15 = i19;
                        kVar = null;
                    } else {
                        kVar = (k) map.get("translationX");
                        i15 = i19;
                    }
                    HashMap map2 = qVar.f190y;
                    i12 = i17;
                    if (map2 == null) {
                        i14 = i18;
                        kVar2 = null;
                    } else {
                        kVar2 = (k) map2.get("translationY");
                        i14 = i18;
                    }
                    HashMap map3 = qVar.f190y;
                    i11 = height;
                    if (map3 == null) {
                        i10 = width;
                        kVar3 = null;
                    } else {
                        kVar3 = (k) map3.get("rotation");
                        i10 = width;
                    }
                    HashMap map4 = qVar.f190y;
                    matrix = matrix3;
                    k kVar5 = map4 == null ? null : (k) map4.get("scaleX");
                    HashMap map5 = qVar.f190y;
                    f10 = f17;
                    if (map5 == null) {
                        fArr3 = fArr6;
                        kVar4 = null;
                    } else {
                        kVar4 = (k) map5.get("scaleY");
                        fArr3 = fArr6;
                    }
                    HashMap map6 = qVar.f191z;
                    f fVar = map6 == null ? null : (f) map6.get("translationX");
                    HashMap map7 = qVar.f191z;
                    f fVar2 = map7 == null ? null : (f) map7.get("translationY");
                    HashMap map8 = qVar.f191z;
                    f fVar3 = map8 == null ? null : (f) map8.get("rotation");
                    HashMap map9 = qVar.f191z;
                    f fVar4 = map9 == null ? null : (f) map9.get("scaleX");
                    HashMap map10 = qVar.f191z;
                    f fVar5 = map10 != null ? (f) map10.get("scaleY") : null;
                    r rVar3 = new r();
                    rVar3.f33635e = 0.0f;
                    rVar3.f33634d = 0.0f;
                    rVar3.f33633c = 0.0f;
                    rVar3.f33632b = 0.0f;
                    rVar3.f33631a = 0.0f;
                    if (kVar3 != null) {
                        f13 = f16;
                        f14 = f15;
                        rVar3.f33635e = (float) kVar3.f36997a.h(fB);
                        rVar3.f33636f = kVar3.a(fB);
                    } else {
                        f13 = f16;
                        f14 = f15;
                    }
                    if (kVar != null) {
                        rVar3.f33633c = (float) kVar.f36997a.h(fB);
                    }
                    if (kVar2 != null) {
                        rVar3.f33634d = (float) kVar2.f36997a.h(fB);
                    }
                    if (kVar5 != null) {
                        rVar3.f33631a = (float) kVar5.f36997a.h(fB);
                    }
                    if (kVar4 != null) {
                        rVar3.f33632b = (float) kVar4.f36997a.h(fB);
                    }
                    if (fVar3 != null) {
                        rVar3.f33635e = fVar3.b(fB);
                    }
                    if (fVar != null) {
                        rVar3.f33633c = fVar.b(fB);
                    }
                    if (fVar2 != null) {
                        rVar3.f33634d = fVar2.b(fB);
                    }
                    if (fVar4 != null) {
                        rVar3.f33631a = fVar4.b(fB);
                    }
                    if (fVar5 != null) {
                        rVar3.f33632b = fVar5.b(fB);
                    }
                    b bVar = qVar.f176k;
                    if (bVar != null) {
                        double[] dArr2 = qVar.f181p;
                        if (dArr2.length > 0) {
                            double d10 = fB;
                            bVar.f(d10, dArr2);
                            qVar.f176k.i(d10, qVar.f182q);
                            y yVar = qVar.f171f;
                            int[] iArr = qVar.f180o;
                            double[] dArr3 = qVar.f182q;
                            double[] dArr4 = qVar.f181p;
                            yVar.getClass();
                            rVar = rVar3;
                            i13 = i15;
                            fArr2 = fArr5;
                            f11 = f13;
                            y.h(f13, f14, fArr5, iArr, dArr3, dArr4);
                        } else {
                            rVar = rVar3;
                            fArr2 = fArr5;
                            i13 = i15;
                            f11 = f13;
                        }
                        rVar.a(f11, f14, width2, height2, fArr2);
                    } else {
                        float f18 = f13;
                        if (qVar.f175j != null) {
                            float[] fArr7 = fArr3;
                            double dB = qVar.b(fArr7, fB);
                            qVar.f175j[0].i(dB, qVar.f182q);
                            qVar.f175j[0].f(dB, qVar.f181p);
                            float f19 = fArr7[0];
                            int i20 = 0;
                            while (true) {
                                dArr = qVar.f182q;
                                if (i20 >= dArr.length) {
                                    break;
                                }
                                dArr[i20] = dArr[i20] * ((double) f19);
                                i20++;
                            }
                            y yVar2 = qVar.f171f;
                            int[] iArr2 = qVar.f180o;
                            double[] dArr5 = qVar.f181p;
                            yVar2.getClass();
                            i13 = i15;
                            f11 = f18;
                            y.h(f18, f14, fArr5, iArr2, dArr, dArr5);
                            rVar3.a(f11, f14, width2, height2, fArr5);
                            fArr2 = fArr5;
                        } else {
                            y yVar3 = qVar.f172g;
                            float f20 = yVar3.f225e;
                            y yVar4 = qVar.f171f;
                            f fVar6 = fVar4;
                            float f21 = f20 - yVar4.f225e;
                            f fVar7 = fVar2;
                            float f22 = yVar3.f226f - yVar4.f226f;
                            f fVar8 = fVar;
                            float f23 = yVar3.f227g - yVar4.f227g;
                            float f24 = (yVar3.f228h - yVar4.f228h) + f22;
                            fArr5[0] = ((f23 + f21) * f18) + ((1.0f - f18) * f21);
                            fArr5[1] = (f24 * f14) + ((1.0f - f14) * f22);
                            rVar3.f33635e = 0.0f;
                            rVar3.f33634d = 0.0f;
                            rVar3.f33633c = 0.0f;
                            rVar3.f33632b = 0.0f;
                            rVar3.f33631a = 0.0f;
                            if (kVar3 != null) {
                                rVar3.f33635e = (float) kVar3.f36997a.h(fB);
                                rVar3.f33636f = kVar3.a(fB);
                            }
                            if (kVar != null) {
                                rVar3.f33633c = (float) kVar.f36997a.h(fB);
                            }
                            if (kVar2 != null) {
                                rVar3.f33634d = (float) kVar2.f36997a.h(fB);
                            }
                            if (kVar5 != null) {
                                rVar3.f33631a = (float) kVar5.f36997a.h(fB);
                            }
                            if (kVar4 != null) {
                                rVar3.f33632b = (float) kVar4.f36997a.h(fB);
                            }
                            if (fVar3 != null) {
                                rVar3.f33635e = fVar3.b(fB);
                            }
                            if (fVar8 != null) {
                                rVar3.f33633c = fVar8.b(fB);
                            }
                            if (fVar7 != null) {
                                rVar3.f33634d = fVar7.b(fB);
                            }
                            if (fVar6 != null) {
                                rVar3.f33631a = fVar6.b(fB);
                            }
                            if (fVar5 != null) {
                                rVar3.f33632b = fVar5.b(fB);
                            }
                            i13 = i15;
                            fArr2 = fArr5;
                            f11 = f18;
                            rVar3.a(f18, f14, width2, height2, fArr2);
                        }
                    }
                    f12 = f14;
                } else {
                    i10 = width;
                    matrix = matrix3;
                    i11 = height;
                    f10 = f17;
                    fArr = fArr4;
                    i12 = i17;
                    i13 = i19;
                    fArr2 = fArr5;
                    f11 = f16;
                    f12 = f15;
                    i14 = i18;
                    qVar.d(interpolation, f11, f12, fArr2);
                }
                if (i13 < 2) {
                    fArr2[0] = fArr2[0] * f10;
                    fArr2[1] = fArr2[1] * f10;
                }
                motionTelltales = this;
                float[] fArr8 = motionTelltales.Q;
                Matrix matrix4 = matrix;
                matrix4.mapVectors(fArr8);
                int i21 = i10;
                float f25 = i21 * f11;
                int i22 = i11;
                float f26 = i22 * f12;
                float f27 = fArr8[0];
                float f28 = motionTelltales.U;
                float f29 = f26 - (fArr8[1] * f28);
                matrix4.mapVectors(fArr8);
                canvas.drawLine(f25, f26, f25 - (f27 * f28), f29, motionTelltales.f1253l);
                i18 = i14 + 1;
                f15 = f12;
                width = i21;
                fArr4 = fArr;
                i17 = i12;
                height = i22;
                matrix3 = matrix4;
                i16 = 5;
            }
            i17++;
            matrix3 = matrix3;
            fArr4 = fArr4;
            i16 = 5;
        }
    }

    @Override // android.view.View
    public final void onLayout(boolean z10, int i10, int i11, int i12, int i13) {
        super.onLayout(z10, i10, i11, i12, i13);
        postInvalidate();
    }

    public void setText(CharSequence charSequence) {
        this.f1204f = charSequence.toString();
        requestLayout();
    }

    public MotionTelltales(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.f1253l = new Paint();
        this.Q = new float[2];
        this.R = new Matrix();
        this.S = 0;
        this.T = -65281;
        this.U = 0.25f;
        b(context, attributeSet);
    }

    public MotionTelltales(Context context, AttributeSet attributeSet, int i10) {
        super(context, attributeSet, i10);
        this.f1253l = new Paint();
        this.Q = new float[2];
        this.R = new Matrix();
        this.S = 0;
        this.T = -65281;
        this.U = 0.25f;
        b(context, attributeSet);
    }
}
