package d2;

import A1.H;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.graphics.PorterDuff;
import android.graphics.Shader;
import java.util.ArrayList;

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

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public static final Matrix f11384p = new Matrix();

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Path f11386b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Matrix f11387c;

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

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

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

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

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public float f11392h;
    public float i;

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

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

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

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

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

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final q.e f11398o;

    public n() {
        this.f11387c = new Matrix();
        this.f11392h = 0.0f;
        this.i = 0.0f;
        this.f11393j = 0.0f;
        this.f11394k = 0.0f;
        this.f11395l = 255;
        this.f11396m = null;
        this.f11397n = null;
        this.f11398o = new q.e(0);
        this.f11391g = new k();
        this.f11385a = new Path();
        this.f11386b = new Path();
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final void a(k kVar, Matrix matrix, Canvas canvas, int i, int i5) {
        char c3;
        float f3;
        float f7;
        int i8;
        k kVar2 = kVar;
        char c8 = 1;
        kVar2.f11371a.set(matrix);
        Matrix matrix2 = kVar2.f11371a;
        matrix2.preConcat(kVar2.f11379j);
        canvas.save();
        char c9 = 0;
        int i9 = 0;
        while (true) {
            ArrayList arrayList = kVar2.f11372b;
            if (i9 >= arrayList.size()) {
                canvas.restore();
                return;
            }
            l lVar = (l) arrayList.get(i9);
            if (lVar instanceof k) {
                a((k) lVar, matrix2, canvas, i, i5);
            } else if (lVar instanceof m) {
                m mVar = (m) lVar;
                float f8 = i / this.f11393j;
                float f9 = i5 / this.f11394k;
                float fMin = Math.min(f8, f9);
                Matrix matrix3 = this.f11387c;
                matrix3.set(matrix2);
                matrix3.postScale(f8, f9);
                float[] fArr = {0.0f, 1.0f, 1.0f, 0.0f};
                matrix2.mapVectors(fArr);
                float fHypot = (float) Math.hypot(fArr[c9], fArr[c8]);
                boolean z8 = c8;
                boolean z9 = c9;
                float fHypot2 = (float) Math.hypot(fArr[2], fArr[3]);
                float f10 = (fArr[z9 ? 1 : 0] * fArr[3]) - (fArr[z8 ? 1 : 0] * fArr[2]);
                float fMax = Math.max(fHypot, fHypot2);
                float fAbs = fMax > 0.0f ? Math.abs(f10) / fMax : 0.0f;
                if (fAbs != 0.0f) {
                    mVar.getClass();
                    Path path = this.f11385a;
                    path.reset();
                    F.d[] dVarArr = mVar.f11381a;
                    if (dVarArr != null) {
                        F.d.b(dVarArr, path);
                    }
                    Path path2 = this.f11386b;
                    path2.reset();
                    if (mVar instanceof i) {
                        path2.setFillType(mVar.f11383c == 0 ? Path.FillType.WINDING : Path.FillType.EVEN_ODD);
                        path2.addPath(path, matrix3);
                        canvas.clipPath(path2);
                    } else {
                        j jVar = (j) mVar;
                        float f11 = jVar.i;
                        if (f11 != 0.0f || jVar.f11366j != 1.0f) {
                            float f12 = jVar.f11367k;
                            float f13 = (f11 + f12) % 1.0f;
                            float f14 = (jVar.f11366j + f12) % 1.0f;
                            if (this.f11390f == null) {
                                this.f11390f = new PathMeasure();
                            }
                            this.f11390f.setPath(path, z9);
                            float length = this.f11390f.getLength();
                            float f15 = f13 * length;
                            float f16 = f14 * length;
                            path.reset();
                            if (f15 > f16) {
                                this.f11390f.getSegment(f15, length, path, z8);
                                f3 = 0.0f;
                                this.f11390f.getSegment(0.0f, f16, path, z8);
                            } else {
                                f3 = 0.0f;
                                this.f11390f.getSegment(f15, f16, path, z8);
                            }
                            path.rLineTo(f3, f3);
                        }
                        path2.addPath(path, matrix3);
                        H h8 = jVar.f11363f;
                        if ((((Shader) h8.f66s) == null && h8.f65r == 0) ? false : true) {
                            if (this.f11389e == null) {
                                i8 = 16777215;
                                Paint paint = new Paint(1);
                                this.f11389e = paint;
                                paint.setStyle(Paint.Style.FILL);
                            } else {
                                i8 = 16777215;
                            }
                            Paint paint2 = this.f11389e;
                            Shader shader = (Shader) h8.f66s;
                            if (shader != null) {
                                shader.setLocalMatrix(matrix3);
                                paint2.setShader(shader);
                                paint2.setAlpha(Math.round(jVar.f11365h * 255.0f));
                                f7 = 255.0f;
                            } else {
                                paint2.setShader(null);
                                paint2.setAlpha(255);
                                int i10 = h8.f65r;
                                float f17 = jVar.f11365h;
                                PorterDuff.Mode mode = q.f11411z;
                                f7 = 255.0f;
                                paint2.setColor((i10 & i8) | (((int) (Color.alpha(i10) * f17)) << 24));
                            }
                            paint2.setColorFilter(null);
                            path2.setFillType(jVar.f11383c == 0 ? Path.FillType.WINDING : Path.FillType.EVEN_ODD);
                            canvas.drawPath(path2, paint2);
                        } else {
                            f7 = 255.0f;
                            i8 = 16777215;
                        }
                        H h9 = jVar.f11361d;
                        if (((Shader) h9.f66s) != null || h9.f65r != 0) {
                            if (this.f11388d == null) {
                                Paint paint3 = new Paint(1);
                                this.f11388d = paint3;
                                paint3.setStyle(Paint.Style.STROKE);
                            }
                            Paint paint4 = this.f11388d;
                            Paint.Join join = jVar.f11369m;
                            if (join != null) {
                                paint4.setStrokeJoin(join);
                            }
                            Paint.Cap cap = jVar.f11368l;
                            if (cap != null) {
                                paint4.setStrokeCap(cap);
                            }
                            paint4.setStrokeMiter(jVar.f11370n);
                            Shader shader2 = (Shader) h9.f66s;
                            if (shader2 != null) {
                                shader2.setLocalMatrix(matrix3);
                                paint4.setShader(shader2);
                                paint4.setAlpha(Math.round(jVar.f11364g * f7));
                            } else {
                                paint4.setShader(null);
                                paint4.setAlpha(255);
                                int i11 = h9.f65r;
                                float f18 = jVar.f11364g;
                                PorterDuff.Mode mode2 = q.f11411z;
                                paint4.setColor((i11 & i8) | (((int) (Color.alpha(i11) * f18)) << 24));
                            }
                            paint4.setColorFilter(null);
                            paint4.setStrokeWidth(jVar.f11362e * fMin * fAbs);
                            canvas.drawPath(path2, paint4);
                        }
                    }
                }
                c3 = 1;
                i9++;
                kVar2 = kVar;
                c8 = c3;
                c9 = 0;
            }
            c3 = c8;
            i9++;
            kVar2 = kVar;
            c8 = c3;
            c9 = 0;
        }
    }

    public float getAlpha() {
        return getRootAlpha() / 255.0f;
    }

    public int getRootAlpha() {
        return this.f11395l;
    }

    public void setAlpha(float f3) {
        setRootAlpha((int) (f3 * 255.0f));
    }

    public void setRootAlpha(int i) {
        this.f11395l = i;
    }

    public n(n nVar) {
        this.f11387c = new Matrix();
        this.f11392h = 0.0f;
        this.i = 0.0f;
        this.f11393j = 0.0f;
        this.f11394k = 0.0f;
        this.f11395l = 255;
        this.f11396m = null;
        this.f11397n = null;
        q.e eVar = new q.e(0);
        this.f11398o = eVar;
        this.f11391g = new k(nVar.f11391g, eVar);
        this.f11385a = new Path(nVar.f11385a);
        this.f11386b = new Path(nVar.f11386b);
        this.f11392h = nVar.f11392h;
        this.i = nVar.i;
        this.f11393j = nVar.f11393j;
        this.f11394k = nVar.f11394k;
        this.f11395l = nVar.f11395l;
        this.f11396m = nVar.f11396m;
        String str = nVar.f11396m;
        if (str != null) {
            eVar.put(str, this);
        }
        this.f11397n = nVar.f11397n;
    }
}
