package j0;

import android.graphics.Path;
import androidx.annotation.Nullable;
import com.google.android.gms.measurement.internal.u1;
import java.util.ArrayList;

/* JADX INFO: loaded from: classes.dex */
public abstract class g {
    public static float[] a(int i10, float[] fArr) {
        if (i10 < 0) {
            throw new IllegalArgumentException();
        }
        int length = fArr.length;
        if (length < 0) {
            throw new ArrayIndexOutOfBoundsException();
        }
        int iMin = Math.min(i10, length);
        float[] fArr2 = new float[i10];
        System.arraycopy(fArr, 0, fArr2, 0, iMin);
        return fArr2;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:17:0x0043  */
    /* JADX WARN: Removed duplicated region for block: B:41:0x0098 A[FALL_THROUGH] */
    /* JADX WARN: Removed duplicated region for block: B:45:0x00a0 A[Catch: NumberFormatException -> 0x00b6, LOOP:3: B:25:0x006f->B:45:0x00a0, LOOP_END, TryCatch #0 {NumberFormatException -> 0x00b6, blocks: (B:22:0x0055, B:24:0x0068, B:25:0x006f, B:27:0x0075, B:31:0x0081, B:45:0x00a0, B:35:0x008a, B:40:0x0096, B:46:0x00a4, B:48:0x00a8, B:51:0x00b8, B:55:0x00c0, B:56:0x00c3), top: B:71:0x0055 }] */
    /* JADX WARN: Removed duplicated region for block: B:48:0x00a8 A[Catch: NumberFormatException -> 0x00b6, TryCatch #0 {NumberFormatException -> 0x00b6, blocks: (B:22:0x0055, B:24:0x0068, B:25:0x006f, B:27:0x0075, B:31:0x0081, B:45:0x00a0, B:35:0x008a, B:40:0x0096, B:46:0x00a4, B:48:0x00a8, B:51:0x00b8, B:55:0x00c0, B:56:0x00c3), top: B:71:0x0055 }] */
    /* JADX WARN: Removed duplicated region for block: B:53:0x00bc  */
    /* JADX WARN: Removed duplicated region for block: B:55:0x00c0 A[Catch: NumberFormatException -> 0x00b6, TryCatch #0 {NumberFormatException -> 0x00b6, blocks: (B:22:0x0055, B:24:0x0068, B:25:0x006f, B:27:0x0075, B:31:0x0081, B:45:0x00a0, B:35:0x008a, B:40:0x0096, B:46:0x00a4, B:48:0x00a8, B:51:0x00b8, B:55:0x00c0, B:56:0x00c3), top: B:71:0x0055 }] */
    /* JADX WARN: Removed duplicated region for block: B:75:0x00e6 A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:84:0x009f A[SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static f[] b(String str) {
        int i10;
        String strTrim;
        float[] fArrA;
        int i11;
        boolean z10;
        boolean z11;
        boolean z12;
        boolean z13;
        ArrayList arrayList = new ArrayList();
        int i12 = 0;
        int i13 = 1;
        int i14 = 0;
        int i15 = 1;
        while (i15 < str.length()) {
            while (i15 < str.length()) {
                char cCharAt = str.charAt(i15);
                if ((cCharAt - 'Z') * (cCharAt - 'A') > 0) {
                    if ((cCharAt - 'z') * (cCharAt - 'a') > 0) {
                        continue;
                    }
                    i15++;
                }
                if (cCharAt == 'e' || cCharAt == 'E') {
                    i15++;
                } else {
                    strTrim = str.substring(i14, i15).trim();
                    if (!strTrim.isEmpty()) {
                        if (strTrim.charAt(i12) == 'z' || strTrim.charAt(i12) == 'Z') {
                            fArrA = new float[i12];
                            i11 = i12;
                        } else {
                            try {
                                float[] fArr = new float[strTrim.length()];
                                androidx.browser.trusted.f fVar = new androidx.browser.trusted.f(i13);
                                int length = strTrim.length();
                                int i16 = i12;
                                int i17 = i13;
                                boolean z14 = i12;
                                while (i17 < length) {
                                    fVar.f902b = z14;
                                    boolean z15 = z14;
                                    boolean z16 = z15 ? 1 : 0;
                                    boolean z17 = z16 ? 1 : 0;
                                    int i18 = i17;
                                    boolean z18 = z15;
                                    boolean z19 = z16;
                                    while (i18 < strTrim.length()) {
                                        char cCharAt2 = strTrim.charAt(i18);
                                        if (cCharAt2 == ' ') {
                                            z10 = false;
                                            z11 = true;
                                            z12 = z19;
                                            if (z11) {
                                                i18++;
                                                z18 = z10;
                                                z19 = z12;
                                                z17 = z11;
                                            }
                                        } else {
                                            if (cCharAt2 != 'E' && cCharAt2 != 'e') {
                                                switch (cCharAt2) {
                                                    case '-':
                                                        z13 = z17;
                                                        z13 = z17;
                                                        if (i18 != i17 && !z18) {
                                                            fVar.f902b = true;
                                                            break;
                                                        }
                                                        z10 = false;
                                                        z12 = z19;
                                                        z11 = z13;
                                                    case ',':
                                                        break;
                                                    case '.':
                                                        if (!z19) {
                                                            z10 = false;
                                                            z12 = true;
                                                            z11 = z17;
                                                        } else {
                                                            fVar.f902b = true;
                                                            z13 = true;
                                                            z10 = false;
                                                            z12 = z19;
                                                            z11 = z13;
                                                        }
                                                        break;
                                                    default:
                                                        z13 = z17;
                                                        z10 = false;
                                                        z12 = z19;
                                                        z11 = z13;
                                                        break;
                                                }
                                            } else {
                                                z10 = true;
                                                z12 = z19;
                                                z11 = z17;
                                            }
                                            if (z11) {
                                            }
                                        }
                                        fVar.f901a = i18;
                                        int i19 = i16;
                                        if (i17 < i18) {
                                            int i20 = (i16 == true ? 1 : 0) + 1;
                                            fArr[i16 == true ? 1 : 0] = Float.parseFloat(strTrim.substring(i17, i18));
                                            i19 = i20;
                                        }
                                        i17 = !fVar.f902b ? i18 : i18 + 1;
                                        z14 = 0;
                                        i16 = i19;
                                    }
                                    fVar.f901a = i18;
                                    int i192 = i16;
                                    if (i17 < i18) {
                                    }
                                    if (!fVar.f902b) {
                                    }
                                    z14 = 0;
                                    i16 = i192;
                                }
                                fArrA = a(i16 == true ? 1 : 0, fArr);
                                i11 = 0;
                            } catch (NumberFormatException e10) {
                                throw new RuntimeException(u1.k("error in parsing \"", strTrim, "\""), e10);
                            }
                        }
                        arrayList.add(new f(strTrim.charAt(i11), fArrA));
                    }
                    i14 = i15;
                    i13 = 1;
                    i15++;
                    i12 = 0;
                }
            }
            strTrim = str.substring(i14, i15).trim();
            if (!strTrim.isEmpty()) {
            }
            i14 = i15;
            i13 = 1;
            i15++;
            i12 = 0;
        }
        if (i15 - i14 != 1 || i14 >= str.length()) {
            i10 = 0;
        } else {
            i10 = 0;
            arrayList.add(new f(str.charAt(i14), new float[0]));
        }
        return (f[]) arrayList.toArray(new f[i10]);
    }

    public static Path c(String str) {
        Path path = new Path();
        try {
            f.b(b(str), path);
            return path;
        } catch (RuntimeException e10) {
            throw new RuntimeException("Error in parsing ".concat(str), e10);
        }
    }

    public static boolean canMorph(@Nullable f[] fVarArr, @Nullable f[] fVarArr2) {
        if (fVarArr == null || fVarArr2 == null || fVarArr.length != fVarArr2.length) {
            return false;
        }
        for (int i10 = 0; i10 < fVarArr.length; i10++) {
            f fVar = fVarArr[i10];
            char c6 = fVar.f28507a;
            f fVar2 = fVarArr2[i10];
            if (c6 != fVar2.f28507a || fVar.f28508b.length != fVar2.f28508b.length) {
                return false;
            }
        }
        return true;
    }

    public static f[] d(f[] fVarArr) {
        f[] fVarArr2 = new f[fVarArr.length];
        for (int i10 = 0; i10 < fVarArr.length; i10++) {
            fVarArr2[i10] = new f(fVarArr[i10]);
        }
        return fVarArr2;
    }
}
