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C,UAAU,IAAI;gBACtB,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;YACjD,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;gBAClB,KAAG,CAAC,CAAC,CAAC,CAAC;YACX,CAAC,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC;SACjB;IACL,CAAC;IAEL,eAAC;AAAD,CA7LA,AA6LC,IAAA;AA7LY,4BAAQ","file":"DepGraph.js","sourcesContent":["/**\n * This source code is from https://github.com/jriecken/dependency-graph\n * Just added \"any\" types here, wrapper everything into exported class.\n * We cant use a package itself because we want to package \"everything-in-it\" for the frontend users of TypeORM.\n */\n\n/**\n * A simple dependency graph\n */\n\n/**\n * Helper for creating a Depth-First-Search on\n * a set of edges.\n *\n * Detects cycles and throws an Error if one is detected.\n *\n * @param edges The set of edges to DFS through\n * @param leavesOnly Whether to only return \"leaf\" nodes (ones who have no edges)\n * @param result An array in which the results will be populated\n */\nfunction createDFS(edges: any, leavesOnly: any, result: any) {\n    let currentPath: any[] = [];\n    let visited: any = {};\n    return function DFS(currentNode: any) {\n        visited[currentNode] = true;\n        currentPath.push(currentNode);\n        edges[currentNode].forEach(function (node: any) {\n            if (!visited[node]) {\n                DFS(node);\n            } else if (currentPath.indexOf(node) >= 0) {\n                currentPath.push(node);\n                throw new Error(`Dependency Cycle Found: ${currentPath.join(\" -> \")}`);\n            }\n        });\n        currentPath.pop();\n        if ((!leavesOnly || edges[currentNode].length === 0) && result.indexOf(currentNode) === -1) {\n            result.push(currentNode);\n        }\n    };\n}\n\n\nexport class DepGraph {\n    nodes: any = {};\n    outgoingEdges: any = {}; // Node -> [Dependency Node]\n    incomingEdges: any = {}; // Node -> [Dependant Node]\n\n    /**\n     * Add a node to the dependency graph. If a node already exists, this method will do nothing.\n     */\n    addNode(node: any, data?: any) {\n        if (!this.hasNode(node)) {\n            // Checking the arguments length allows the user to add a node with undefined data\n            if (arguments.length === 2) {\n                this.nodes[node] = data;\n            } else {\n                this.nodes[node] = node;\n            }\n            this.outgoingEdges[node] = [];\n            this.incomingEdges[node] = [];\n        }\n    }\n\n    /**\n     * Remove a node from the dependency graph. If a node does not exist, this method will do nothing.\n     */\n    removeNode(node: any) {\n        if (this.hasNode(node)) {\n            delete this.nodes[node];\n            delete this.outgoingEdges[node];\n            delete this.incomingEdges[node];\n            [this.incomingEdges, this.outgoingEdges].forEach(function (edgeList) {\n                Object.keys(edgeList).forEach(function (key: any) {\n                    let idx = edgeList[key].indexOf(node);\n                    if (idx >= 0) {\n                        edgeList[key].splice(idx, 1);\n                    }\n                }, this);\n            });\n        }\n    }\n\n    /**\n     * Check if a node exists in the graph\n     */\n    hasNode(node: any) {\n        return this.nodes.hasOwnProperty(node);\n    }\n\n    /**\n     * Get the data associated with a node name\n     */\n    getNodeData(node: any) {\n        if (this.hasNode(node)) {\n            return this.nodes[node];\n        } else {\n            throw new Error(`Node does not exist: ${node}`);\n        }\n    }\n\n    /**\n     * Set the associated data for a given node name. If the node does not exist, this method will throw an error\n     */\n    setNodeData(node: any, data: any) {\n        if (this.hasNode(node)) {\n            this.nodes[node] = data;\n        } else {\n            throw new Error(`Node does not exist: ${node}`);\n        }\n    }\n\n    /**\n     * Add a dependency between two nodes. If either of the nodes does not exist,\n     * an Error will be thrown.\n     */\n    addDependency(from: any, to: any) {\n        if (!this.hasNode(from)) {\n            throw new Error(`Node does not exist: ${from}`);\n        }\n        if (!this.hasNode(to)) {\n            throw new Error(`Node does not exist: ${to}`);\n        }\n        if (this.outgoingEdges[from].indexOf(to) === -1) {\n            this.outgoingEdges[from].push(to);\n        }\n        if (this.incomingEdges[to].indexOf(from) === -1) {\n            this.incomingEdges[to].push(from);\n        }\n        return true;\n    }\n\n    /**\n     * Remove a dependency between two nodes.\n     */\n    removeDependency(from: any, to: any) {\n        let idx: any;\n        if (this.hasNode(from)) {\n            idx = this.outgoingEdges[from].indexOf(to);\n            if (idx >= 0) {\n                this.outgoingEdges[from].splice(idx, 1);\n            }\n        }\n\n        if (this.hasNode(to)) {\n            idx = this.incomingEdges[to].indexOf(from);\n            if (idx >= 0) {\n                this.incomingEdges[to].splice(idx, 1);\n            }\n        }\n    }\n\n    /**\n     * Get an array containing the nodes that the specified node depends on (transitively).\n     *\n     * Throws an Error if the graph has a cycle, or the specified node does not exist.\n     *\n     * If `leavesOnly` is true, only nodes that do not depend on any other nodes will be returned\n     * in the array.\n     */\n    dependenciesOf(node: any, leavesOnly: any) {\n        if (this.hasNode(node)) {\n            let result: any[] = [];\n            let DFS = createDFS(this.outgoingEdges, leavesOnly, result);\n            DFS(node);\n            let idx = result.indexOf(node);\n            if (idx >= 0) {\n                result.splice(idx, 1);\n            }\n            return result;\n        }\n        else {\n            throw new Error(`Node does not exist: ${node}`);\n        }\n    }\n\n    /**\n     * get an array containing the nodes that depend on the specified node (transitively).\n     *\n     * Throws an Error if the graph has a cycle, or the specified node does not exist.\n     *\n     * If `leavesOnly` is true, only nodes that do not have any dependants will be returned in the array.\n     */\n    dependantsOf(node: any, leavesOnly: any) {\n        if (this.hasNode(node)) {\n            let result: any[] = [];\n            let DFS = createDFS(this.incomingEdges, leavesOnly, result);\n            DFS(node);\n            let idx = result.indexOf(node);\n            if (idx >= 0) {\n                result.splice(idx, 1);\n            }\n            return result;\n        } else {\n            throw new Error(`Node does not exist: ${node}`);\n        }\n    }\n\n    /**\n     * Construct the overall processing order for the dependency graph.\n     *\n     * Throws an Error if the graph has a cycle.\n     *\n     * If `leavesOnly` is true, only nodes that do not depend on any other nodes will be returned.\n     */\n    overallOrder(leavesOnly?: any) {\n        let self = this;\n        let result: any[] = [];\n        let keys = Object.keys(this.nodes);\n        if (keys.length === 0) {\n            return result; // Empty graph\n        } else {\n            // Look for cycles - we run the DFS starting at all the nodes in case there\n            // are several disconnected subgraphs inside this dependency graph.\n            let CycleDFS = createDFS(this.outgoingEdges, false, []);\n            keys.forEach(function (n: any) {\n                CycleDFS(n);\n            });\n\n            let DFS = createDFS(this.outgoingEdges, leavesOnly, result);\n            // Find all potential starting points (nodes with nothing depending on them) an\n            // run a DFS starting at these points to get the order\n            keys.filter(function (node) {\n                return self.incomingEdges[node].length === 0;\n            }).forEach(function (n) {\n                DFS(n);\n            });\n\n            return result;\n        }\n    }\n\n}"],"sourceRoot":".."}