package defpackage;

import android.net.Uri;
import android.text.TextUtils;
import java.util.Collections;
import java.util.HashMap;

/* JADX INFO: renamed from: ᵳʼ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C4554 extends AbstractC4986 {
    /* JADX INFO: renamed from: ˑˊᵲ, reason: contains not printable characters */
    public static final boolean m9640(String str) {
        String str2 = (String) AbstractC3818.f14518.m1988(null);
        if (TextUtils.isEmpty(str2)) {
            return false;
        }
        for (String str3 : str2.split(",")) {
            if (str.equalsIgnoreCase(str3.trim())) {
                return true;
            }
        }
        return false;
    }

    /* JADX WARN: Code restructure failed: missing block: B:26:0x0094, code lost:
    
        if (java.lang.Math.abs(r7.hashCode() % 100) < r9.m4278().m6834()) goto L28;
     */
    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final C2788 m9641(String str) {
        C1103 c1103 = (C1103) ((ᵜᵪʾ) this).ˌᴵ;
        C2894 c2894 = this.f18892;
        C1694 c1694 = c2894.f11109;
        C1811 c1811 = c2894.f11104;
        C2894.m6882(c1694);
        C2019 c2019M4596 = c1694.m4596(str);
        EnumC4563 enumC4563 = EnumC4563.f17346;
        C2788 c2788 = null;
        if (c2019M4596 == null || !c2019M4596.m5428()) {
            return new C2788(m9642(str), Collections.EMPTY_MAP, enumC4563, null);
        }
        C1574 c1574M6152 = C2424.m6152();
        c1574M6152.m9868();
        ((C2424) c1574M6152.f17955).m6158(2);
        int iM2406 = AbstractC0659.m2406(c2019M4596.m5412());
        if (iM2406 == 0) {
            C4935.m10233("null reference");
        }
        c1574M6152.m4422(iM2406);
        String strM5396 = c2019M4596.m5396();
        C2894.m6882(c1811);
        C1498 c1498M4971 = c1811.m4971(str);
        if (c1498M4971 != null) {
            C1694 c16942 = c2894.f11109;
            C2894.m6882(c16942);
            C2019 c2019M45962 = c16942.m4596(str);
            if (c2019M45962 != null) {
                if (!c1498M4971.m4280() || c1498M4971.m4278().m6834() != 100) {
                    C3335 c3335 = c1103.f4730;
                    C1103.m3567(c3335);
                    if (!c3335.m7658(str, c2019M45962.m5437())) {
                        if (!TextUtils.isEmpty(strM5396)) {
                        }
                    }
                }
                String strM5415 = c2019M4596.m5415();
                c1574M6152.m9868();
                ((C2424) c1574M6152.f17955).m6158(2);
                C2894.m6882(c1811);
                C1498 c1498M49712 = c1811.m4971(c2019M4596.m5415());
                if (c1498M49712 == null || !c1498M49712.m4280()) {
                    C3485 c3485 = c1103.f4729;
                    C1103.m3564(c3485);
                    c3485.f13414.m4474(strM5415, "[sgtm] Missing sgtm_setting in remote config. appId");
                    c1574M6152.m9868();
                    ((C2424) c1574M6152.f17955).m6159(4);
                } else {
                    HashMap map = new HashMap();
                    if (!TextUtils.isEmpty(c2019M4596.m5437())) {
                        map.put("x-gtm-server-preview", c2019M4596.m5437());
                    }
                    String strM6833 = c1498M49712.m4278().m6833();
                    int iM24062 = AbstractC0659.m2406(c2019M4596.m5412());
                    if (iM24062 != 0 && iM24062 != 2) {
                        c1574M6152.m4422(iM24062);
                    } else if (m9640(c2019M4596.m5415())) {
                        c1574M6152.m4422(11);
                    } else if (TextUtils.isEmpty(strM6833)) {
                        c1574M6152.m4422(12);
                    } else {
                        C3485 c34852 = c1103.f4729;
                        C1103.m3564(c34852);
                        c34852.f13414.m4474(strM5415, "[sgtm] Eligible for client side upload. appId");
                        c1574M6152.m9868();
                        ((C2424) c1574M6152.f17955).m6158(3);
                        c1574M6152.m4422(2);
                        c2788 = new C2788(strM6833, map, EnumC4563.f17348, (C2424) c1574M6152.m9869());
                    }
                    c1498M49712.m4278().getClass();
                    c1498M49712.m4278().getClass();
                    c1103.getClass();
                    C3485 c34853 = c1103.f4729;
                    if (TextUtils.isEmpty(strM6833)) {
                        c1574M6152.m9868();
                        ((C2424) c1574M6152.f17955).m6159(6);
                        C1103.m3564(c34853);
                        c34853.f13414.m4474(c2019M4596.m5415(), "[sgtm] Local service, missing sgtm_server_url");
                    } else {
                        C1103.m3564(c34853);
                        c34853.f13414.m4474(strM5415, "[sgtm] Eligible for local service direct upload. appId");
                        c1574M6152.m9868();
                        ((C2424) c1574M6152.f17955).m6158(5);
                        c1574M6152.m9868();
                        ((C2424) c1574M6152.f17955).m6159(2);
                        c2788 = new C2788(strM6833, map, EnumC4563.f17347, (C2424) c1574M6152.m9869());
                    }
                }
                return c2788 != null ? c2788 : new C2788(m9642(str), Collections.EMPTY_MAP, enumC4563, (C2424) c1574M6152.m9869());
            }
        }
        c1574M6152.m9868();
        ((C2424) c1574M6152.f17955).m6159(3);
        return new C2788(m9642(str), Collections.EMPTY_MAP, enumC4563, (C2424) c1574M6152.m9869());
    }

    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    public final String m9642(String str) {
        C1811 c1811 = this.f18892.f11104;
        C2894.m6882(c1811);
        String strM4966 = c1811.m4966(str);
        if (TextUtils.isEmpty(strM4966)) {
            return (String) AbstractC3818.f14501.m1988(null);
        }
        Uri uri = Uri.parse((String) AbstractC3818.f14501.m1988(null));
        Uri.Builder builderBuildUpon = uri.buildUpon();
        String authority = uri.getAuthority();
        StringBuilder sb = new StringBuilder(String.valueOf(strM4966).length() + 1 + String.valueOf(authority).length());
        sb.append(strM4966);
        sb.append(".");
        sb.append(authority);
        builderBuildUpon.authority(sb.toString());
        return builderBuildUpon.build().toString();
    }
}
