export function cloneComponentData(obj, seen = new WeakSet()) {
    if (obj === null || typeof obj !== "object")
        return obj;
    if (seen.has(obj))
        return undefined; // avoid circular reference
    seen.add(obj);
    if (Array.isArray(obj)) {
        return obj.map((item) => cloneComponentData(item, seen));
    }
    const cloned = {};
    for (const key in obj) {
        const value = obj[key];
        if (typeof value !== "function") {
            try {
                cloned[key] = cloneComponentData(value, seen);
            }
            catch {
                // some properties may throw
            }
        }
    }
    return cloned;
}
