import { isMeasure } from "../../../../utils/index.js";
const dimensionTreeToColumns = (spec, context)=>{
    const { advancedVSeed } = context;
    const dimensionTree = advancedVSeed.dimensionTree;
    const result = {
        ...spec
    };
    const eachNode = (node)=>{
        if (isMeasure(node)) return {
            width: 'auto'
        };
        return {};
    };
    const columns = treeTreeToColumns(dimensionTree, eachNode);
    return {
        ...result,
        columns: [
            ...result.columns || [],
            ...columns
        ]
    };
};
const treeTreeToColumns = (tree, callback)=>{
    const result = tree.map((item)=>{
        if ('children' in item && Array.isArray(item.children)) {
            const groupNode = item;
            const field = groupNode.id;
            const title = groupNode.alias ?? groupNode.id;
            const props = callback?.(groupNode) || {};
            return {
                field,
                title,
                columns: treeTreeToColumns(item.children, callback),
                ...props
            };
        }
        {
            const field = item.id;
            const title = item.alias ?? item.id;
            const props = callback?.(item) || {};
            return {
                field,
                title,
                ...props
            };
        }
    });
    return result || [];
};
export { dimensionTreeToColumns };

//# sourceMappingURL=dimensionsToColumns.js.map