import { DEFAULT_PARENT_ID } from "../../../../utils/constant.js";
import { ensureParentIdInitialized, isCommonMeasureEncoding } from "./utils.js";
const buildMeasures = (encodingKeys)=>(advancedVSeed)=>{
        const { measures = [] } = advancedVSeed;
        const measuresByView = {};
        const parentIds = [];
        for(let index = 0; index < measures.length; index++){
            const item = measures[index];
            const encoding = item.encoding;
            const parentId = item.parentId || DEFAULT_PARENT_ID;
            const isOtherEncoding = item.encoding && isCommonMeasureEncoding(encoding);
            ensureParentIdInitialized(parentId, measuresByView, parentIds);
            if (encodingKeys.includes(encoding)) measuresByView[parentId].push(item);
            else if (!isOtherEncoding) {
                item.encoding = encodingKeys[0];
                measuresByView[parentId].push(item);
            }
        }
        advancedVSeed.reshapeMeasures = parentIds.map((pid)=>measuresByView[pid]).filter((m)=>m.length > 0);
        return advancedVSeed;
    };
export { buildMeasures };

//# sourceMappingURL=buildMeasures.js.map