package defpackage;

import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
import android.graphics.RectF;
import android.graphics.Typeface;
import com.airbnb.lottie.g;
import defpackage.zd2;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/* JADX INFO: loaded from: classes.dex */
public class al9 extends w70 {
    public final StringBuilder ad;
    public final RectF ae;
    public final Matrix af;
    public final Paint ag;
    public final Paint ah;
    public final HashMap ai;
    public final hj5 aj;
    public final ArrayList ak;
    public final yk9 al;
    public final g am;
    public final zj5 an;
    public final cl9 ao;
    public final x51 ap;
    public yea aq;
    public final x51 ar;
    public yea as;
    public final l33 at;
    public yea au;
    public final l33 av;
    public yea aw;
    public final qp4 ax;
    public yea ay;
    public yea az;
    public final qp4 ba;
    public final qp4 bb;
    public final qp4 bc;

    public class a extends Paint {
    }

    public class b extends Paint {
    }

    public static /* synthetic */ class c {
        public static final /* synthetic */ int[] a;

        static {
            int[] iArr = new int[zd2.a.values().length];
            a = iArr;
            try {
                iArr[0] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                a[1] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                a[2] = 3;
            } catch (NoSuchFieldError unused3) {
            }
        }
    }

    public static class d {
        public String a;
        public float b;
    }

    public al9(g gVar, y55 y55Var) {
        uk ukVar;
        uk ukVar2;
        kk kkVar;
        uk ukVar3;
        kk kkVar2;
        uk ukVar4;
        kk kkVar3;
        vk vkVar;
        kk kkVar4;
        vk vkVar2;
        ik ikVar;
        vk vkVar3;
        ik ikVar2;
        vk vkVar4;
        hk hkVar;
        vk vkVar5;
        hk hkVar2;
        super(gVar, y55Var);
        this.ad = new StringBuilder(2);
        this.ae = new RectF();
        this.af = new Matrix();
        a aVar = new a(1);
        aVar.setStyle(Paint.Style.FILL);
        this.ag = aVar;
        b bVar = new b(1);
        bVar.setStyle(Paint.Style.STROKE);
        this.ah = bVar;
        this.ai = new HashMap();
        this.aj = new hj5();
        this.ak = new ArrayList();
        this.ao = cl9.b;
        this.am = gVar;
        this.an = y55Var.b;
        yk9 yk9VarA = y55Var.q.a();
        this.al = yk9VarA;
        yk9VarA.a(this);
        f(yk9VarA);
        sk skVar = y55Var.r;
        if (skVar != null && (vkVar5 = skVar.a) != null && (hkVar2 = vkVar5.a) != null) {
            u70 u70VarA = hkVar2.a();
            this.ap = (x51) u70VarA;
            u70VarA.a(this);
            f(u70VarA);
        }
        if (skVar != null && (vkVar4 = skVar.a) != null && (hkVar = vkVar4.b) != null) {
            u70 u70VarA2 = hkVar.a();
            this.ar = (x51) u70VarA2;
            u70VarA2.a(this);
            f(u70VarA2);
        }
        if (skVar != null && (vkVar3 = skVar.a) != null && (ikVar2 = vkVar3.c) != null) {
            l33 l33VarA = ikVar2.a();
            this.at = l33VarA;
            l33VarA.a(this);
            f(l33VarA);
        }
        if (skVar != null && (vkVar2 = skVar.a) != null && (ikVar = vkVar2.d) != null) {
            l33 l33VarA2 = ikVar.a();
            this.av = l33VarA2;
            l33VarA2.a(this);
            f(l33VarA2);
        }
        if (skVar != null && (vkVar = skVar.a) != null && (kkVar4 = vkVar.e) != null) {
            u70 u70VarA3 = kkVar4.a();
            this.ax = (qp4) u70VarA3;
            u70VarA3.a(this);
            f(u70VarA3);
        }
        if (skVar != null && (ukVar4 = skVar.b) != null && (kkVar3 = ukVar4.a) != null) {
            u70 u70VarA4 = kkVar3.a();
            this.ba = (qp4) u70VarA4;
            u70VarA4.a(this);
            f(u70VarA4);
        }
        if (skVar != null && (ukVar3 = skVar.b) != null && (kkVar2 = ukVar3.b) != null) {
            u70 u70VarA5 = kkVar2.a();
            this.bb = (qp4) u70VarA5;
            u70VarA5.a(this);
            f(u70VarA5);
        }
        if (skVar != null && (ukVar2 = skVar.b) != null && (kkVar = ukVar2.c) != null) {
            u70 u70VarA6 = kkVar.a();
            this.bc = (qp4) u70VarA6;
            u70VarA6.a(this);
            f(u70VarA6);
        }
        if (skVar == null || (ukVar = skVar.b) == null) {
            return;
        }
        this.ao = ukVar.d;
    }

    public static void t(String str, Paint paint, Canvas canvas) {
        if (paint.getColor() == 0) {
            return;
        }
        if (paint.getStyle() == Paint.Style.STROKE && paint.getStrokeWidth() == 0.0f) {
            return;
        }
        canvas.drawText(str, 0, str.length(), 0.0f, 0.0f, paint);
    }

    public static void u(Path path, Paint paint, Canvas canvas) {
        if (paint.getColor() == 0) {
            return;
        }
        if (paint.getStyle() == Paint.Style.STROKE && paint.getStrokeWidth() == 0.0f) {
            return;
        }
        canvas.drawPath(path, paint);
    }

    @Override // defpackage.w70, defpackage.ag2
    public final void e(RectF rectF, Matrix matrix, boolean z) {
        super.e(rectF, matrix, z);
        zj5 zj5Var = this.an;
        rectF.set(0.0f, 0.0f, zj5Var.k.width(), zj5Var.k.height());
    }

    @Override // defpackage.w70, defpackage.j35
    public final void h(hl5 hl5Var, Object obj) {
        super.h(hl5Var, obj);
        PointF pointF = xk5.a;
        if (obj == 1) {
            yea yeaVar = this.aq;
            if (yeaVar != null) {
                o(yeaVar);
            }
            yea yeaVar2 = new yea(hl5Var, null);
            this.aq = yeaVar2;
            yeaVar2.a(this);
            f(this.aq);
            return;
        }
        if (obj == 2) {
            yea yeaVar3 = this.as;
            if (yeaVar3 != null) {
                o(yeaVar3);
            }
            yea yeaVar4 = new yea(hl5Var, null);
            this.as = yeaVar4;
            yeaVar4.a(this);
            f(this.as);
            return;
        }
        if (obj == xk5.n) {
            yea yeaVar5 = this.au;
            if (yeaVar5 != null) {
                o(yeaVar5);
            }
            yea yeaVar6 = new yea(hl5Var, null);
            this.au = yeaVar6;
            yeaVar6.a(this);
            f(this.au);
            return;
        }
        if (obj == xk5.o) {
            yea yeaVar7 = this.aw;
            if (yeaVar7 != null) {
                o(yeaVar7);
            }
            yea yeaVar8 = new yea(hl5Var, null);
            this.aw = yeaVar8;
            yeaVar8.a(this);
            f(this.aw);
            return;
        }
        if (obj == xk5.aa) {
            yea yeaVar9 = this.ay;
            if (yeaVar9 != null) {
                o(yeaVar9);
            }
            yea yeaVar10 = new yea(hl5Var, null);
            this.ay = yeaVar10;
            yeaVar10.a(this);
            f(this.ay);
            return;
        }
        if (obj != xk5.ah) {
            if (obj == xk5.aj) {
                yk9 yk9Var = this.al;
                yk9Var.getClass();
                yk9Var.j(new xk9(new mk5(), hl5Var, new zd2()));
                return;
            }
            return;
        }
        yea yeaVar11 = this.az;
        if (yeaVar11 != null) {
            o(yeaVar11);
        }
        yea yeaVar12 = new yea(hl5Var, null);
        this.az = yeaVar12;
        yeaVar12.a(this);
        f(this.az);
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:103:0x0360  */
    /* JADX WARN: Removed duplicated region for block: B:106:0x0368  */
    /* JADX WARN: Removed duplicated region for block: B:124:0x03ef  */
    /* JADX WARN: Removed duplicated region for block: B:24:0x00ea  */
    /* JADX WARN: Removed duplicated region for block: B:79:0x02e2  */
    @Override // defpackage.w70
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void k(Canvas canvas, Matrix matrix, int i, fg2 fg2Var) {
        yg3 yg3VarI;
        String str;
        String str2;
        Typeface typefaceCreateFromAsset;
        float fFloatValue;
        int size;
        int i2;
        List list;
        int i3;
        float f;
        List list2;
        int i4;
        String string;
        float fFloatValue2;
        int i5;
        List list3;
        String str3;
        int i6;
        int i7;
        int i8;
        g gVar;
        List list4;
        Paint paint;
        Paint paint2;
        Paint paint3;
        Paint paint4;
        Canvas canvas2 = canvas;
        zd2 zd2Var = (zd2) this.al.e();
        zj5 zj5Var = this.an;
        wg3 wg3Var = (wg3) zj5Var.f.get(zd2Var.b);
        if (wg3Var == null) {
            return;
        }
        String str4 = wg3Var.c;
        String str5 = wg3Var.a;
        canvas2.save();
        canvas.concat(matrix);
        s(zd2Var, i, 0);
        g gVar2 = this.am;
        Map map = gVar2.n;
        l33 l33Var = this.av;
        int i9 = 0;
        Paint paint5 = this.ag;
        Paint paint6 = this.ah;
        if (map == null && gVar2.q == null && gVar2.a.h.f() > 0) {
            yea yeaVar = this.ay;
            float fFloatValue3 = yeaVar != null ? ((Float) yeaVar.e()).floatValue() : zd2Var.c;
            float f2 = 0.0f;
            float[] fArr = (float[]) sda.e.get();
            fArr[0] = 0.0f;
            fArr[1] = 0.0f;
            float f3 = sda.f;
            fArr[2] = f3;
            fArr[3] = f3;
            float f4 = fFloatValue3 / 100.0f;
            matrix.mapPoints(fArr);
            Paint paint7 = paint5;
            g gVar3 = gVar2;
            zj5 zj5Var2 = zj5Var;
            String str6 = str4;
            Math.hypot(fArr[2] - fArr[0], fArr[3] - fArr[1]);
            List listAsList = Arrays.asList(zd2Var.a.replaceAll("\r\n", "\r").replaceAll("\u0003", "\r").replaceAll("\n", "\r").split("\r"));
            int size2 = listAsList.size();
            float f5 = zd2Var.e / 10.0f;
            yea yeaVar2 = this.aw;
            if (yeaVar2 != null) {
                fFloatValue2 = ((Float) yeaVar2.e()).floatValue();
            } else {
                if (l33Var != null) {
                    fFloatValue2 = ((Float) l33Var.e()).floatValue();
                }
                float f6 = f5;
                i5 = 0;
                int i10 = -1;
                while (i5 < size2) {
                    String str7 = (String) listAsList.get(i5);
                    PointF pointF = zd2Var.m;
                    float f7 = f4;
                    List listY = y(str7, pointF == null ? f2 : pointF.x, wg3Var, f7, f6, true);
                    int i11 = i9;
                    while (i11 < listY.size()) {
                        d dVar = (d) listY.get(i11);
                        i10++;
                        canvas2.save();
                        if (x(canvas2, zd2Var, i10, dVar.b)) {
                            String str8 = dVar.a;
                            list3 = listY;
                            int i12 = i9;
                            while (i12 < str8.length()) {
                                List list5 = listAsList;
                                String str9 = str6;
                                int i13 = i11;
                                float f8 = f6;
                                zj5 zj5Var3 = zj5Var2;
                                zg3 zg3Var = (zg3) zj5Var3.h.c(zg3.a(str8.charAt(i12), str5, str9));
                                if (zg3Var == null) {
                                    zj5Var2 = zj5Var3;
                                    str3 = str8;
                                    i6 = size2;
                                    i7 = i5;
                                    i8 = i12;
                                    paint = paint6;
                                    gVar = gVar3;
                                    paint2 = paint7;
                                } else {
                                    s(zd2Var, i, i12);
                                    HashMap map2 = this.ai;
                                    if (map2.containsKey(zg3Var)) {
                                        list4 = (List) map2.get(zg3Var);
                                        str3 = str8;
                                        i6 = size2;
                                        i7 = i5;
                                        i8 = i12;
                                        gVar = gVar3;
                                    } else {
                                        str3 = str8;
                                        ArrayList arrayList = zg3Var.a;
                                        i6 = size2;
                                        int size3 = arrayList.size();
                                        i7 = i5;
                                        ArrayList arrayList2 = new ArrayList(size3);
                                        i8 = i12;
                                        int i14 = i9;
                                        while (i14 < size3) {
                                            arrayList2.add(new ce1(gVar3, this, (fp8) arrayList.get(i14), zj5Var3));
                                            size3 = size3;
                                            i14++;
                                            arrayList = arrayList;
                                        }
                                        gVar = gVar3;
                                        map2.put(zg3Var, arrayList2);
                                        list4 = arrayList2;
                                    }
                                    int i15 = i9;
                                    while (i15 < list4.size()) {
                                        Path path = ((ce1) list4.get(i15)).getPath();
                                        zj5 zj5Var4 = zj5Var3;
                                        path.computeBounds(this.ae, i9);
                                        Matrix matrix2 = this.af;
                                        matrix2.reset();
                                        List list6 = list4;
                                        matrix2.preTranslate(f2, (-zd2Var.g) * sda.c());
                                        matrix2.preScale(f7, f7);
                                        path.transform(matrix2);
                                        if (zd2Var.k) {
                                            paint4 = paint7;
                                            u(path, paint4, canvas2);
                                            paint3 = paint6;
                                            u(path, paint3, canvas2);
                                        } else {
                                            paint3 = paint6;
                                            paint4 = paint7;
                                            u(path, paint3, canvas2);
                                            u(path, paint4, canvas2);
                                        }
                                        i15++;
                                        paint6 = paint3;
                                        paint7 = paint4;
                                        list4 = list6;
                                        zj5Var3 = zj5Var4;
                                        i9 = 0;
                                        f2 = 0.0f;
                                    }
                                    zj5Var2 = zj5Var3;
                                    paint = paint6;
                                    paint2 = paint7;
                                    canvas2.translate((sda.c() * ((float) zg3Var.c) * f7) + f8, 0.0f);
                                }
                                f6 = f8;
                                paint6 = paint;
                                str6 = str9;
                                paint7 = paint2;
                                gVar3 = gVar;
                                i11 = i13;
                                listAsList = list5;
                                str8 = str3;
                                size2 = i6;
                                i5 = i7;
                                i9 = 0;
                                f2 = 0.0f;
                                i12 = i8 + 1;
                            }
                        } else {
                            list3 = listY;
                        }
                        int i16 = i11;
                        float f9 = f6;
                        List list7 = listAsList;
                        int i17 = size2;
                        int i18 = i5;
                        Paint paint8 = paint6;
                        g gVar4 = gVar3;
                        Paint paint9 = paint7;
                        String str10 = str6;
                        canvas2.restore();
                        f6 = f9;
                        paint6 = paint8;
                        str6 = str10;
                        paint7 = paint9;
                        gVar3 = gVar4;
                        listAsList = list7;
                        size2 = i17;
                        i5 = i18;
                        i9 = 0;
                        f2 = 0.0f;
                        i11 = i16 + 1;
                        listY = list3;
                    }
                    listAsList = listAsList;
                    i9 = 0;
                    f2 = 0.0f;
                    i5++;
                    f4 = f7;
                }
            }
            f5 += fFloatValue2;
            float f62 = f5;
            i5 = 0;
            int i102 = -1;
            while (i5 < size2) {
            }
        } else {
            yea yeaVar3 = this.az;
            if (yeaVar3 == null || (typefaceCreateFromAsset = (Typeface) yeaVar3.e()) == null) {
                Map map3 = gVar2.n;
                if (map3 == null) {
                    yg3VarI = gVar2.i();
                    if (yg3VarI == null) {
                        jf6 jf6Var = yg3VarI.a;
                        jf6Var.a = str5;
                        jf6Var.b = str4;
                        HashMap map4 = yg3VarI.b;
                        Typeface typeface = (Typeface) map4.get(jf6Var);
                        if (typeface != null) {
                            str2 = "\u0003";
                            typefaceCreateFromAsset = typeface;
                            str = "\n";
                        } else {
                            HashMap map5 = yg3VarI.c;
                            Typeface typeface2 = (Typeface) map5.get(str5);
                            if (typeface2 != null) {
                                str2 = "\u0003";
                                typefaceCreateFromAsset = typeface2;
                                str = "\n";
                            } else {
                                str = "\n";
                                Typeface typeface3 = wg3Var.d;
                                if (typeface3 != null) {
                                    typefaceCreateFromAsset = typeface3;
                                    str2 = "\u0003";
                                } else {
                                    str2 = "\u0003";
                                    typefaceCreateFromAsset = Typeface.createFromAsset(yg3VarI.d, "fonts/" + str5 + yg3VarI.e);
                                    map5.put(str5, typefaceCreateFromAsset);
                                }
                            }
                            boolean zContains = str4.contains("Italic");
                            boolean zContains2 = str4.contains("Bold");
                            int i19 = (zContains && zContains2) ? 3 : zContains ? 2 : zContains2 ? 1 : 0;
                            if (typefaceCreateFromAsset.getStyle() != i19) {
                                typefaceCreateFromAsset = Typeface.create(typefaceCreateFromAsset, i19);
                            }
                            map4.put(jf6Var, typefaceCreateFromAsset);
                        }
                    } else {
                        str = "\n";
                        str2 = "\u0003";
                        typefaceCreateFromAsset = null;
                    }
                    if (typefaceCreateFromAsset == null) {
                        typefaceCreateFromAsset = wg3Var.d;
                    }
                } else {
                    if (map3.containsKey(str5)) {
                        typefaceCreateFromAsset = (Typeface) map3.get(str5);
                    } else {
                        String str11 = wg3Var.b;
                        if (map3.containsKey(str11)) {
                            typefaceCreateFromAsset = (Typeface) map3.get(str11);
                        } else {
                            String strL = vw2.l(str5, "-", str4);
                            if (map3.containsKey(strL)) {
                                typefaceCreateFromAsset = (Typeface) map3.get(strL);
                            }
                            yg3VarI = gVar2.i();
                            if (yg3VarI == null) {
                            }
                            if (typefaceCreateFromAsset == null) {
                            }
                        }
                    }
                    str = "\n";
                    str2 = "\u0003";
                    if (typefaceCreateFromAsset == null) {
                    }
                }
            } else {
                str = "\n";
                str2 = "\u0003";
            }
            if (typefaceCreateFromAsset != null) {
                String str12 = zd2Var.a;
                if (gVar2.q != null) {
                    String str13 = this.p.c;
                }
                paint5.setTypeface(typefaceCreateFromAsset);
                yea yeaVar4 = this.ay;
                float fFloatValue4 = yeaVar4 != null ? ((Float) yeaVar4.e()).floatValue() : zd2Var.c;
                paint5.setTextSize(sda.c() * fFloatValue4);
                paint6.setTypeface(paint5.getTypeface());
                paint6.setTextSize(paint5.getTextSize());
                float f10 = zd2Var.e / 10.0f;
                yea yeaVar5 = this.aw;
                if (yeaVar5 != null) {
                    fFloatValue = ((Float) yeaVar5.e()).floatValue();
                } else {
                    if (l33Var != null) {
                        fFloatValue = ((Float) l33Var.e()).floatValue();
                    }
                    float fC = ((sda.c() * f10) * fFloatValue4) / 100.0f;
                    List listAsList2 = Arrays.asList(str12.replaceAll("\r\n", "\r").replaceAll(str2, "\r").replaceAll(str, "\r").split("\r"));
                    size = listAsList2.size();
                    i2 = 0;
                    int length = 0;
                    int i20 = -1;
                    while (i2 < size) {
                        String str14 = (String) listAsList2.get(i2);
                        PointF pointF2 = zd2Var.m;
                        float f11 = fC;
                        List listY2 = y(str14, pointF2 == null ? 0.0f : pointF2.x, wg3Var, 0.0f, f11, false);
                        int i21 = 0;
                        while (i21 < listY2.size()) {
                            d dVar2 = (d) listY2.get(i21);
                            i20++;
                            canvas.save();
                            if (x(canvas, zd2Var, i20, paint5.measureText(dVar2.a))) {
                                String str15 = dVar2.a;
                                list = listY2;
                                i3 = i21;
                                int length2 = 0;
                                while (length2 < str15.length()) {
                                    int iCodePointAt = str15.codePointAt(length2);
                                    int i22 = length2;
                                    int iCharCount = Character.charCount(iCodePointAt) + length2;
                                    wg3 wg3Var2 = wg3Var;
                                    while (true) {
                                        if (iCharCount >= str15.length()) {
                                            f = f11;
                                            break;
                                        }
                                        int iCodePointAt2 = str15.codePointAt(iCharCount);
                                        f = f11;
                                        if (Character.getType(iCodePointAt2) != 16 && Character.getType(iCodePointAt2) != 27 && Character.getType(iCodePointAt2) != 6 && Character.getType(iCodePointAt2) != 28 && Character.getType(iCodePointAt2) != 8 && Character.getType(iCodePointAt2) != 19) {
                                            break;
                                        }
                                        iCharCount += Character.charCount(iCodePointAt2);
                                        iCodePointAt = (iCodePointAt * 31) + iCodePointAt2;
                                        f11 = f;
                                    }
                                    long j = iCodePointAt;
                                    hj5 hj5Var = this.aj;
                                    if (hj5Var.e(j) >= 0) {
                                        string = (String) hj5Var.c(j);
                                        list2 = listAsList2;
                                        i4 = size;
                                    } else {
                                        list2 = listAsList2;
                                        StringBuilder sb = this.ad;
                                        i4 = size;
                                        sb.setLength(0);
                                        int iCharCount2 = i22;
                                        while (iCharCount2 < iCharCount) {
                                            int i23 = iCharCount;
                                            int iCodePointAt3 = str15.codePointAt(iCharCount2);
                                            sb.appendCodePoint(iCodePointAt3);
                                            iCharCount2 += Character.charCount(iCodePointAt3);
                                            iCharCount = i23;
                                        }
                                        string = sb.toString();
                                        hj5Var.g(j, string);
                                    }
                                    s(zd2Var, i, length + i22);
                                    if (zd2Var.k) {
                                        t(string, paint5, canvas);
                                        t(string, paint6, canvas);
                                    } else {
                                        t(string, paint6, canvas);
                                        t(string, paint5, canvas);
                                    }
                                    canvas.translate(paint5.measureText(string) + f, 0.0f);
                                    length2 = string.length() + i22;
                                    wg3Var = wg3Var2;
                                    listAsList2 = list2;
                                    f11 = f;
                                    size = i4;
                                }
                            } else {
                                list = listY2;
                                i3 = i21;
                            }
                            wg3 wg3Var3 = wg3Var;
                            float f12 = f11;
                            List list8 = listAsList2;
                            int i24 = size;
                            length += dVar2.a.length();
                            canvas.restore();
                            i21 = i3 + 1;
                            listY2 = list;
                            wg3Var = wg3Var3;
                            listAsList2 = list8;
                            f11 = f12;
                            size = i24;
                        }
                        i2++;
                        listAsList2 = listAsList2;
                        fC = f11;
                    }
                }
                f10 += fFloatValue;
                float fC2 = ((sda.c() * f10) * fFloatValue4) / 100.0f;
                List listAsList22 = Arrays.asList(str12.replaceAll("\r\n", "\r").replaceAll(str2, "\r").replaceAll(str, "\r").split("\r"));
                size = listAsList22.size();
                i2 = 0;
                int length3 = 0;
                int i202 = -1;
                while (i2 < size) {
                }
            }
            canvas2 = canvas;
        }
        canvas2.restore();
    }

    public final void s(zd2 zd2Var, int i, int i2) {
        yea yeaVar = this.aq;
        Paint paint = this.ag;
        if (yeaVar != null) {
            paint.setColor(((Integer) yeaVar.e()).intValue());
        } else {
            x51 x51Var = this.ap;
            if (x51Var == null || !w(i2)) {
                paint.setColor(zd2Var.h);
            } else {
                paint.setColor(((Integer) x51Var.e()).intValue());
            }
        }
        yea yeaVar2 = this.as;
        Paint paint2 = this.ah;
        if (yeaVar2 != null) {
            paint2.setColor(((Integer) yeaVar2.e()).intValue());
        } else {
            x51 x51Var2 = this.ar;
            if (x51Var2 == null || !w(i2)) {
                paint2.setColor(zd2Var.i);
            } else {
                paint2.setColor(((Integer) x51Var2.e()).intValue());
            }
        }
        u70 u70Var = this.w.j;
        int iIntValue = 100;
        int iIntValue2 = u70Var == null ? 100 : ((Integer) u70Var.e()).intValue();
        qp4 qp4Var = this.ax;
        if (qp4Var != null && w(i2)) {
            iIntValue = ((Integer) qp4Var.e()).intValue();
        }
        int iRound = Math.round((((iIntValue / 100.0f) * ((iIntValue2 * 255.0f) / 100.0f)) * i) / 255.0f);
        paint.setAlpha(iRound);
        paint2.setAlpha(iRound);
        yea yeaVar3 = this.au;
        if (yeaVar3 != null) {
            paint2.setStrokeWidth(((Float) yeaVar3.e()).floatValue());
            return;
        }
        l33 l33Var = this.at;
        if (l33Var == null || !w(i2)) {
            paint2.setStrokeWidth(sda.c() * zd2Var.j);
        } else {
            paint2.setStrokeWidth(((Float) l33Var.e()).floatValue());
        }
    }

    public final d v(int i) {
        ArrayList arrayList = this.ak;
        for (int size = arrayList.size(); size < i; size++) {
            d dVar = new d();
            dVar.a = "";
            dVar.b = 0.0f;
            arrayList.add(dVar);
        }
        return (d) arrayList.get(i - 1);
    }

    public final boolean w(int i) {
        qp4 qp4Var;
        int length = ((zd2) this.al.e()).a.length();
        qp4 qp4Var2 = this.ba;
        if (qp4Var2 == null || (qp4Var = this.bb) == null) {
            return true;
        }
        int iMin = Math.min(((Integer) qp4Var2.e()).intValue(), ((Integer) qp4Var.e()).intValue());
        int iMax = Math.max(((Integer) qp4Var2.e()).intValue(), ((Integer) qp4Var.e()).intValue());
        qp4 qp4Var3 = this.bc;
        if (qp4Var3 != null) {
            int iIntValue = ((Integer) qp4Var3.e()).intValue();
            iMin += iIntValue;
            iMax += iIntValue;
        }
        if (this.ao == cl9.b) {
            return i >= iMin && i < iMax;
        }
        float f = (i / length) * 100.0f;
        return f >= ((float) iMin) && f < ((float) iMax);
    }

    public final boolean x(Canvas canvas, zd2 zd2Var, int i, float f) {
        PointF pointF = zd2Var.l;
        PointF pointF2 = zd2Var.m;
        float fC = sda.c();
        float f2 = (i * zd2Var.f * fC) + (pointF == null ? 0.0f : (zd2Var.f * fC) + pointF.y);
        if (this.am.aa && pointF2 != null && pointF != null && f2 >= pointF.y + pointF2.y + zd2Var.c) {
            return false;
        }
        float f3 = pointF == null ? 0.0f : pointF.x;
        float f4 = pointF2 != null ? pointF2.x : 0.0f;
        int iOrdinal = zd2Var.d.ordinal();
        if (iOrdinal == 0) {
            canvas.translate(f3, f2);
            return true;
        }
        if (iOrdinal == 1) {
            canvas.translate((f3 + f4) - f, f2);
            return true;
        }
        if (iOrdinal != 2) {
            return true;
        }
        canvas.translate(((f4 / 2.0f) + f3) - (f / 2.0f), f2);
        return true;
    }

    public final List y(String str, float f, wg3 wg3Var, float f2, float f3, boolean z) {
        float fMeasureText;
        int i = 0;
        int i2 = 0;
        boolean z2 = false;
        int i3 = 0;
        float f4 = 0.0f;
        float f5 = 0.0f;
        float f6 = 0.0f;
        for (int i4 = 0; i4 < str.length(); i4++) {
            char cCharAt = str.charAt(i4);
            if (z) {
                zg3 zg3Var = (zg3) this.an.h.c(zg3.a(cCharAt, wg3Var.a, wg3Var.c));
                if (zg3Var != null) {
                    fMeasureText = (sda.c() * ((float) zg3Var.c) * f2) + f3;
                }
            } else {
                fMeasureText = this.ag.measureText(str.substring(i4, i4 + 1)) + f3;
            }
            if (cCharAt == ' ') {
                z2 = true;
                f6 = fMeasureText;
            } else if (z2) {
                z2 = false;
                i3 = i4;
                f5 = fMeasureText;
            } else {
                f5 += fMeasureText;
            }
            f4 += fMeasureText;
            if (f > 0.0f && f4 >= f && cCharAt != ' ') {
                i++;
                d dVarV = v(i);
                if (i3 == i2) {
                    dVarV.a = str.substring(i2, i4).trim();
                    dVarV.b = (f4 - fMeasureText) - ((r10.length() - r8.length()) * f6);
                    i2 = i4;
                    i3 = i2;
                    f4 = fMeasureText;
                    f5 = f4;
                } else {
                    dVarV.a = str.substring(i2, i3 - 1).trim();
                    dVarV.b = ((f4 - f5) - ((r8.length() - r14.length()) * f6)) - f6;
                    f4 = f5;
                    i2 = i3;
                }
            }
        }
        if (f4 > 0.0f) {
            i++;
            d dVarV2 = v(i);
            dVarV2.a = str.substring(i2);
            dVarV2.b = f4;
        }
        return this.ak.subList(0, i);
    }
}
