package com.bytedance.sdk.component.adexpress.dynamic.wN;

import android.text.TextUtils;
import android.widget.TextView;
import com.bytedance.sdk.component.adexpress.dynamic.wN.Sg;
import com.facebook.react.uimanager.ViewProps;
import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.json.JSONObject;
/* loaded from: classes2.dex */
public class eT {
    private static String Sg;
    private static final Set<String> YFl = Collections.unmodifiableSet(new HashSet(Arrays.asList("dislike", "close", "close-fill", "webview-close")));

    public static String YFl() {
        return Sg;
    }

    /* JADX WARN: Can't wrap try/catch for region: R(9:(3:179|(1:182)|183)(2:208|(1:210)(5:211|185|(5:195|196|197|(3:199|(1:205)(1:202)|203)|206)|193|194))|184|185|(3:187|189|191)|195|196|197|(0)|206) */
    /* JADX WARN: Removed duplicated region for block: B:221:0x048d A[Catch: Exception -> 0x049e, TryCatch #2 {Exception -> 0x049e, blocks: (B:219:0x0482, B:221:0x048d, B:226:0x0497), top: B:273:0x0482 }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static com.bytedance.sdk.component.adexpress.dynamic.wN.Sg.tN YFl(java.lang.String r19, java.lang.String r20, java.lang.String r21, boolean r22, boolean r23, int r24, com.bytedance.sdk.component.adexpress.dynamic.AlY.qsH r25, double r26, int r28, double r29, java.lang.String r31, com.bytedance.sdk.component.adexpress.Sg.GA r32) {
        /*
            Method dump skipped, instructions count: 1347
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bytedance.sdk.component.adexpress.dynamic.wN.eT.YFl(java.lang.String, java.lang.String, java.lang.String, boolean, boolean, int, com.bytedance.sdk.component.adexpress.dynamic.AlY.qsH, double, int, double, java.lang.String, com.bytedance.sdk.component.adexpress.Sg.GA):com.bytedance.sdk.component.adexpress.dynamic.wN.Sg$tN");
    }

    public static String YFl(String str) {
        String[] split;
        return (TextUtils.isEmpty(str) || (split = str.split("adx:")) == null || split.length < 2) ? "" : split[1];
    }

    private static Sg.tN YFl(Sg.tN tNVar, String str, String str2, String str3) {
        if (str.contains("union")) {
            tNVar.YFl = 0.0f;
            tNVar.Sg = 0.0f;
        } else {
            if (TextUtils.isEmpty(str3)) {
                str3 = YFl(str);
            }
            if (TextUtils.isEmpty(str3)) {
                tNVar.YFl = 0.0f;
                tNVar.Sg = 0.0f;
            } else {
                return YFl(str3, str2);
            }
        }
        return tNVar;
    }

    public static Sg.tN YFl(String str, String str2) {
        return YFl(str, str2, false);
    }

    public static Sg.tN YFl(String str, String str2, boolean z) {
        Sg.tN tNVar = new Sg.tN();
        try {
            JSONObject jSONObject = new JSONObject(str2);
            int[] YFl2 = YFl(str, (float) Sg(str2), z);
            tNVar.YFl = YFl2[0];
            tNVar.Sg = YFl2[1];
            if (jSONObject.optDouble(ViewProps.LINE_HEIGHT, 1.0d) == FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE) {
                tNVar.Sg = 0.0f;
            }
        } catch (Exception unused) {
        }
        return tNVar;
    }

    public static double Sg(String str) {
        try {
            return Double.parseDouble(new JSONObject(str).optString("fontSize"));
        } catch (Throwable unused) {
            return FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE;
        }
    }

    public static int[] YFl(String str, float f, boolean z) {
        int[] Sg2 = Sg(str, f, z);
        return new int[]{com.bytedance.sdk.component.adexpress.AlY.qsH.Sg(com.bytedance.sdk.component.adexpress.AlY.YFl(), Sg2[0]), com.bytedance.sdk.component.adexpress.AlY.qsH.Sg(com.bytedance.sdk.component.adexpress.AlY.YFl(), Sg2[1])};
    }

    public static int[] Sg(String str, float f, boolean z) {
        try {
            TextView textView = new TextView(com.bytedance.sdk.component.adexpress.AlY.YFl());
            textView.setTextSize(f);
            textView.setText(str);
            textView.setIncludeFontPadding(false);
            if (z) {
                textView.setSingleLine();
            }
            textView.measure(-2, -2);
            return new int[]{textView.getMeasuredWidth() + 2, textView.getMeasuredHeight() + 2};
        } catch (Exception unused) {
            return new int[]{0, 0};
        }
    }

    public static boolean Sg() {
        return !TextUtils.isEmpty(Sg);
    }
}
