import { Forest } from './forest';
import { getNodeKey } from './node-fns';
export function simplify(paths, selectionMap) {
    var forest = new Forest([]);
    paths.forEach(function (p) { return forest.insertPath(p); });
    forest.reduceNode(function (_, node) {
        var k = getNodeKey(node);
        var state = selectionMap.get(k);
        if (state === 'on') {
            node.children = [];
        }
        return _;
    }, null);
    var simplified = forest.reducePath(function (all, path) {
        all.push(path);
        return all;
    }, []);
    return simplified;
}
