import { preorderTraverse } from "../tree/index.js";
const findMeasureById = (measures = [], id)=>{
    if (!measures) return;
    let result;
    preorderTraverse(measures, (node)=>{
        if (!('children' in node)) {
            if (node.id === id) {
                result = node;
                return true;
            }
        }
        return false;
    });
    return result;
};
const findFirstMeasure = (measures = [])=>{
    if (!measures) return;
    let result;
    preorderTraverse(measures, (node)=>{
        if (!('children' in node)) {
            result = node;
            return true;
        }
        return false;
    });
    return result;
};
const findAllMeasures = (measures = [])=>{
    if (!measures) return [];
    const result = [];
    preorderTraverse(measures, (node)=>{
        if (!('children' in node)) result.push(node);
        return false;
    });
    return result;
};
const hasMultipleMeasureInSingleView = (reshapeMeasures)=>reshapeMeasures.some((m)=>m.length > 1);
const flatReshapeMeasures = (reshapeMeasures)=>reshapeMeasures.flat();
export { findAllMeasures, findFirstMeasure, findMeasureById, flatReshapeMeasures, hasMultipleMeasureInSingleView };

//# sourceMappingURL=find.js.map