const isMeasureTreeWithChildren = (measures)=>{
    if (!measures) return false;
    return measures.some((measure)=>'children' in measure);
};
const isMeasureTreeWithParentId = (measures)=>{
    if (!measures) return false;
    return measures.some((measure)=>'parentId' in measure);
};
const normalizeMeasureTree = (measures)=>{
    const createEmptyMeasureGroup = ()=>({
            id: 'group',
            alias: '',
            children: []
        });
    let currentGroup = createEmptyMeasureGroup();
    const measureGroups = [];
    for (const measure of measures)if ('children' in measure) {
        if (currentGroup.children?.length) {
            currentGroup.id = [
                currentGroup.id,
                ...currentGroup.children.map((item)=>item.id)
            ].join('-');
            currentGroup.alias = currentGroup.children.map((item)=>item.alias).join('-');
            measureGroups.push(currentGroup);
            currentGroup = createEmptyMeasureGroup();
        }
        measureGroups.push(measure);
    } else currentGroup.children?.push(measure);
    if (currentGroup.children?.length) {
        currentGroup.id = [
            currentGroup.id,
            ...currentGroup.children.map((item)=>item.id)
        ].join('-');
        currentGroup.alias = currentGroup.children.map((item)=>item.alias).join('-');
        measureGroups.push(currentGroup);
        currentGroup = createEmptyMeasureGroup();
    }
    return measureGroups;
};
const isCommonMeasureEncoding = (encoding)=>[
        'color',
        'label',
        'tooltip'
    ].includes(encoding);
const ensureParentIdInitialized = (parentId, measuresByView, parentIds)=>{
    if (!measuresByView[parentId]) {
        measuresByView[parentId] = [];
        parentIds.push(parentId);
    }
};
export { ensureParentIdInitialized, isCommonMeasureEncoding, isMeasureTreeWithChildren, isMeasureTreeWithParentId, normalizeMeasureTree };

//# sourceMappingURL=utils.js.map