import { walkFields } from "./treeWalk.js";
export const buildGroupsMap = (fields) => {
    const groups = { root: fields };
    walkFields(fields, (field) => {
        if (field.type === 'section') {
            groups[`section:${field.id}`] = field.fields;
        }
    });
    return groups;
};
export const applyGroupsMap = (groups) => {
    const transform = (fields) => fields.map((field) => {
        if (field.type === 'section') {
            const childGroup = groups[`section:${field.id}`] ?? field.fields;
            return { ...field, fields: transform(childGroup) };
        }
        return field;
    });
    return transform(groups.root ?? []);
};
//# sourceMappingURL=fieldGroups.js.map
