package com.mbridge.msdk.out;

import android.net.Uri;
import android.text.TextUtils;
import com.mbridge.msdk.foundation.entity.CampaignEx;
import com.mbridge.msdk.foundation.tools.af;
import com.mbridge.msdk.foundation.tools.z;
import com.mbridge.msdk.system.NoProGuard;
import java.util.concurrent.ConcurrentHashMap;
/* loaded from: classes6.dex */
public class CustomInfoManager implements NoProGuard {
    private static CustomInfoManager INSTANCE = null;
    private static String TAG = "CustomInfoManager";
    public static final int TYPE_BID = 6;
    public static final int TYPE_BIDLOAD = 7;
    public static final int TYPE_LOAD = 8;
    private ConcurrentHashMap<String, String> infoMap = new ConcurrentHashMap<>();

    private CustomInfoManager() {
    }

    public static synchronized CustomInfoManager getInstance() {
        CustomInfoManager customInfoManager;
        synchronized (CustomInfoManager.class) {
            if (INSTANCE == null) {
                synchronized (CustomInfoManager.class) {
                    if (INSTANCE == null) {
                        INSTANCE = new CustomInfoManager();
                    }
                }
            }
            customInfoManager = INSTANCE;
        }
        return customInfoManager;
    }

    public String getCustomInfoByType(String str, int i) {
        return TextUtils.isEmpty(str) ? "" : getCustomInfoByUnitId(str, i);
    }

    public String getCustomInfoByUnitId(String str, String str2) {
        if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) {
            return "";
        }
        try {
            Uri parse = Uri.parse(str2);
            if (parse != null) {
                String host = parse.getHost();
                String path = parse.getPath();
                if (!TextUtils.isEmpty(host) && host.contains(CampaignEx.JSON_KEY_HB) && !TextUtils.isEmpty(path) && path.contains("bid")) {
                    return getCustomInfoByUnitId(str, 6);
                }
                if (!TextUtils.isEmpty(host) && host.contains(CampaignEx.JSON_KEY_HB) && !TextUtils.isEmpty(path) && path.contains("load")) {
                    return getCustomInfoByUnitId(str, 7);
                }
                if (!TextUtils.isEmpty(path) && path.contains("v3")) {
                    return getCustomInfoByUnitId(str, 8);
                }
            }
        } catch (Throwable th) {
            af.b(TAG, "Exception", th);
        }
        return "";
    }

    public String getCustomInfoByUnitId(String str, int i) {
        if (TextUtils.isEmpty(str)) {
            return "";
        }
        if (i != 6) {
            if (i != 7) {
                return i != 8 ? "" : this.infoMap.get(str);
            }
            return this.infoMap.get(str + "_bidload");
        }
        return this.infoMap.get(str + "_bid");
    }

    public void setCustomInfo(String str, int i, String str2) {
        if (TextUtils.isEmpty(str) || str2 == null) {
            return;
        }
        String b = z.b(str2);
        if (i == 6) {
            this.infoMap.put(str + "_bid", b);
        } else if (i == 7) {
            this.infoMap.put(str + "_bidload", b);
        } else if (i != 8) {
        } else {
            this.infoMap.put(str, b);
        }
    }
}
