export class HierarchyModel {
    describe(root, selectedIds = new Set()) {
        return describeNode(root, selectedIds, 0, "root");
    }
    flatten(root, selectedIds = new Set()) {
        const output = [];
        const visit = (node) => {
            output.push(node);
            for (const child of node.children) {
                visit(child);
            }
        };
        visit(this.describe(root, selectedIds));
        return output;
    }
}
function describeNode(node, selectedIds, depth, fallbackId) {
    const id = node.id ?? fallbackId;
    const name = node.name ?? String(id);
    const visible = node.visible ?? true;
    const children = (node.children ?? []).map((child, index) => describeNode(child, selectedIds, depth + 1, `${id}:${index}`));
    return {
        id,
        name,
        visible,
        selected: selectedIds.has(id),
        depth,
        childCount: children.length,
        children
    };
}
//# sourceMappingURL=HierarchyModel.js.map