package com.google.android.gms.internal.ads;

import android.graphics.Color;
import android.text.TextUtils;
import androidx.annotation.ColorInt;
import androidx.annotation.Nullable;
import java.util.Locale;

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

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

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final boolean f9442d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final boolean f9443e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final boolean f9444f;

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

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

    @Nullable
    @ColorInt
    public final Integer zzc;

    @Nullable
    @ColorInt
    public final Integer zzd;

    private b9(String str, int i10, @Nullable @ColorInt Integer num, @Nullable @ColorInt Integer num2, float f10, boolean z10, boolean z11, boolean z12, boolean z13, int i11) {
        this.f9439a = str;
        this.f9440b = i10;
        this.zzc = num;
        this.zzd = num2;
        this.f9441c = f10;
        this.f9442d = z10;
        this.f9443e = z11;
        this.f9444f = z12;
        this.f9445g = z13;
        this.f9446h = i11;
    }

    public static boolean a(String str) {
        try {
            int i10 = Integer.parseInt(str);
            return i10 == 1 || i10 == -1;
        } catch (NumberFormatException e10) {
            vt0.zzd("SsaStyle", defpackage.e.p(new StringBuilder(String.valueOf(str).length() + 33), "Failed to parse boolean value: '", str, "'"), e10);
            return false;
        }
    }

    /* JADX WARN: Failed to find 'out' block for switch in B:10:0x0059. Please report as an issue. */
    @Nullable
    public static b9 zza(String str, z8 z8Var) {
        int i10;
        float f10;
        int i11;
        ih1.x(str.startsWith("Style:"));
        String[] strArrSplit = TextUtils.split(str.substring(6), ",");
        int length = strArrSplit.length;
        int i12 = z8Var.f19133k;
        if (length != i12) {
            Object[] objArr = {Integer.valueOf(i12), Integer.valueOf(length), str};
            String str2 = bb1.f9474a;
            vt0.c(String.format(Locale.US, "Skipping malformed 'Style:' line (expected %s values, found %s): '%s'", objArr));
            return null;
        }
        try {
            String strTrim = strArrSplit[z8Var.f19123a].trim();
            int i13 = z8Var.f19124b;
            if (i13 != -1) {
                String strTrim2 = strArrSplit[i13].trim();
                try {
                    i10 = Integer.parseInt(strTrim2.trim());
                } catch (NumberFormatException unused) {
                }
                switch (i10) {
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                    case 6:
                    case 7:
                    case 8:
                    case 9:
                        break;
                    default:
                        vt0.c("Ignoring unknown alignment: ".concat(String.valueOf(strTrim2)));
                        i10 = -1;
                        break;
                }
            } else {
                i10 = -1;
            }
            int i14 = z8Var.f19125c;
            Integer numZzb = i14 != -1 ? zzb(strArrSplit[i14].trim()) : null;
            int i15 = z8Var.f19126d;
            Integer numZzb2 = i15 != -1 ? zzb(strArrSplit[i15].trim()) : null;
            int i16 = z8Var.f19127e;
            if (i16 != -1) {
                String strTrim3 = strArrSplit[i16].trim();
                try {
                    f10 = Float.parseFloat(strTrim3);
                } catch (NumberFormatException e10) {
                    StringBuilder sb = new StringBuilder(String.valueOf(strTrim3).length() + 29);
                    sb.append("Failed to parse font size: '");
                    sb.append(strTrim3);
                    sb.append("'");
                    vt0.zzd("SsaStyle", sb.toString(), e10);
                    f10 = -3.4028235E38f;
                }
            } else {
                f10 = -3.4028235E38f;
            }
            int i17 = z8Var.f19128f;
            boolean z10 = i17 != -1 && a(strArrSplit[i17].trim());
            int i18 = z8Var.f19129g;
            boolean z11 = i18 != -1 && a(strArrSplit[i18].trim());
            int i19 = z8Var.f19130h;
            boolean z12 = i19 != -1 && a(strArrSplit[i19].trim());
            int i20 = z8Var.f19131i;
            boolean z13 = i20 != -1 && a(strArrSplit[i20].trim());
            int i21 = z8Var.f19132j;
            if (i21 != -1) {
                String strTrim4 = strArrSplit[i21].trim();
                try {
                    int i22 = Integer.parseInt(strTrim4.trim());
                    if (i22 == 1 || i22 == 3) {
                        i11 = i22;
                    }
                } catch (NumberFormatException unused2) {
                }
                vt0.c("Ignoring unknown BorderStyle: ".concat(String.valueOf(strTrim4)));
                i11 = -1;
            } else {
                i11 = -1;
            }
            return new b9(strTrim, i10, numZzb, numZzb2, f10, z10, z11, z12, z13, i11);
        } catch (RuntimeException e11) {
            vt0.zzd("SsaStyle", defpackage.e.p(new StringBuilder(str.length() + 36), "Skipping malformed 'Style:' line: '", str, "'"), e11);
            return null;
        }
    }

    @Nullable
    @ColorInt
    public static Integer zzb(String str) {
        try {
            long j10 = str.startsWith("&H") ? Long.parseLong(str.substring(2), 16) : Long.parseLong(str);
            ih1.x(j10 <= 4294967295L);
            return Integer.valueOf(Color.argb(za2.b(((j10 >> 24) & 255) ^ 255), za2.b(j10 & 255), za2.b((j10 >> 8) & 255), za2.b((j10 >> 16) & 255)));
        } catch (IllegalArgumentException e10) {
            vt0.zzd("SsaStyle", defpackage.e.p(new StringBuilder(String.valueOf(str).length() + 36), "Failed to parse color expression: '", str, "'"), e10);
            return null;
        }
    }
}
