package d3;

import android.os.Bundle;
import java.util.ArrayList;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
import u.AbstractC1563h;

/* JADX INFO: loaded from: classes.dex */
public final class T {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final AtomicReference f11710b = new AtomicReference();

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final AtomicReference f11711c = new AtomicReference();

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final AtomicReference f11712d = new AtomicReference();

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

    public T(C0791i0 c0791i0) {
        this.f11713a = c0791i0;
    }

    public static final String g(String str, String[] strArr, String[] strArr2, AtomicReference atomicReference) {
        String str2;
        P2.w.f(atomicReference);
        P2.w.a(strArr.length == strArr2.length);
        for (int i = 0; i < strArr.length; i++) {
            if (Objects.equals(str, strArr[i])) {
                synchronized (atomicReference) {
                    try {
                        String[] strArr3 = (String[]) atomicReference.get();
                        if (strArr3 == null) {
                            strArr3 = new String[strArr2.length];
                            atomicReference.set(strArr3);
                        }
                        str2 = strArr3[i];
                        if (str2 == null) {
                            str2 = strArr2[i] + "(" + strArr[i] + ")";
                            strArr3[i] = str2;
                        }
                    } catch (Throwable th) {
                        throw th;
                    }
                }
                return str2;
            }
        }
        return str;
    }

    public final String a(Object[] objArr) {
        if (objArr == null) {
            return "[]";
        }
        StringBuilder sbB = AbstractC1563h.b("[");
        for (Object obj : objArr) {
            String strB = obj instanceof Bundle ? b((Bundle) obj) : String.valueOf(obj);
            if (strB != null) {
                if (sbB.length() != 1) {
                    sbB.append(", ");
                }
                sbB.append(strB);
            }
        }
        sbB.append("]");
        return sbB.toString();
    }

    public final String b(Bundle bundle) {
        if (bundle == null) {
            return null;
        }
        if (!this.f11713a.b()) {
            return bundle.toString();
        }
        StringBuilder sbB = AbstractC1563h.b("Bundle[{");
        for (String str : bundle.keySet()) {
            if (sbB.length() != 8) {
                sbB.append(", ");
            }
            sbB.append(e(str));
            sbB.append("=");
            Object obj = bundle.get(str);
            sbB.append(obj instanceof Bundle ? a(new Object[]{obj}) : obj instanceof Object[] ? a((Object[]) obj) : obj instanceof ArrayList ? a(((ArrayList) obj).toArray()) : String.valueOf(obj));
        }
        sbB.append("}]");
        return sbB.toString();
    }

    public final String c(C0828v c0828v) {
        C0791i0 c0791i0 = this.f11713a;
        if (!c0791i0.b()) {
            return c0828v.toString();
        }
        StringBuilder sb = new StringBuilder("origin=");
        sb.append(c0828v.f12195s);
        sb.append(",name=");
        sb.append(d(c0828v.f12193q));
        sb.append(",params=");
        C0825u c0825u = c0828v.f12194r;
        sb.append(c0825u == null ? null : !c0791i0.b() ? c0825u.f12186q.toString() : b(c0825u.a()));
        return sb.toString();
    }

    public final String d(String str) {
        if (str == null) {
            return null;
        }
        return !this.f11713a.b() ? str : g(str, G0.f11465c, G0.f11463a, f11710b);
    }

    public final String e(String str) {
        if (str == null) {
            return null;
        }
        return !this.f11713a.b() ? str : g(str, G0.f11468f, G0.f11467e, f11711c);
    }

    public final String f(String str) {
        if (str == null) {
            return null;
        }
        return !this.f11713a.b() ? str : str.startsWith("_exp_") ? I1.a.p("experiment_id(", str, ")") : g(str, G0.f11471j, G0.i, f11712d);
    }
}
