package com.bytedance.adsdk.ugeno.lb;

import android.text.TextUtils;
import com.bytedance.adsdk.ugeno.jnr;
import com.bytedance.adsdk.ugeno.lb.fm;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes.dex */
public class ro {
    public static String fm(String str, JSONObject jSONObject) {
        fm fmVarLb;
        fm.InterfaceC0018fm interfaceC0018fmFm;
        if (!TextUtils.isEmpty(str) && jSONObject != null) {
            try {
                return (!str.startsWith("${") || !str.endsWith("}") || (fmVarLb = jnr.fm().lb()) == null || (interfaceC0018fmFm = fmVarLb.fm(str.substring(2, str.length() + (-1)))) == null) ? str : (String) interfaceC0018fmFm.fm(jSONObject);
            } catch (Throwable unused) {
            }
        }
        return str;
    }

    public static Object fm(Object obj, JSONObject jSONObject) {
        if (obj == null) {
            return null;
        }
        String strValueOf = String.valueOf(obj);
        if (TextUtils.isEmpty(strValueOf)) {
            return null;
        }
        return (strValueOf.startsWith("${") && strValueOf.endsWith("}")) ? fm(strValueOf, jSONObject) : obj;
    }
}
