UNPKG

mermaid

Version:

Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.

1,230 lines (1,228 loc) 256 kB
import { cytoscape as cytoscape2 } from "./chunk-COUQ6RZ3.mjs"; import { selectSvgElement } from "./chunk-OPFOLJEG.mjs"; import { createText } from "./chunk-EECOFZZB.mjs"; import { parseFontSize } from "./chunk-BF2ETNBY.mjs"; import "./chunk-GKOISANM.mjs"; import { darken_default, defaultConfig_default, getConfig2 as getConfig, is_dark_default, lighten_default, log, sanitizeText, select_default, setupGraphViewbox } from "./chunk-SSVL3WCV.mjs"; import "./chunk-HD3LK5B5.mjs"; import { __commonJS, __name, __toESM } from "./chunk-DLQEHMXD.mjs"; // ../../node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js var require_layout_base = __commonJS({ "../../node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js"(exports, module) { "use strict"; (/* @__PURE__ */ __name(function webpackUniversalModuleDefinition(root, factory) { if (typeof exports === "object" && typeof module === "object") module.exports = factory(); else if (typeof define === "function" && define.amd) define([], factory); else if (typeof exports === "object") exports["layoutBase"] = factory(); else root["layoutBase"] = factory(); }, "webpackUniversalModuleDefinition"))(exports, function() { return ( /******/ function(modules) { var installedModules = {}; function __webpack_require__(moduleId) { if (installedModules[moduleId]) { return installedModules[moduleId].exports; } var module2 = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; modules[moduleId].call(module2.exports, module2, module2.exports, __webpack_require__); module2.l = true; return module2.exports; } __name(__webpack_require__, "__webpack_require__"); __webpack_require__.m = modules; __webpack_require__.c = installedModules; __webpack_require__.i = function(value) { return value; }; __webpack_require__.d = function(exports2, name, getter) { if (!__webpack_require__.o(exports2, name)) { Object.defineProperty(exports2, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); } }; __webpack_require__.n = function(module2) { var getter = module2 && module2.__esModule ? ( /******/ /* @__PURE__ */ __name(function getDefault() { return module2["default"]; }, "getDefault") ) : ( /******/ /* @__PURE__ */ __name(function getModuleExports() { return module2; }, "getModuleExports") ); __webpack_require__.d(getter, "a", getter); return getter; }; __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; __webpack_require__.p = ""; return __webpack_require__(__webpack_require__.s = 26); }([ /* 0 */ /***/ function(module2, exports2, __webpack_require__) { "use strict"; function LayoutConstants() { } __name(LayoutConstants, "LayoutConstants"); LayoutConstants.QUALITY = 1; LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED = false; LayoutConstants.DEFAULT_INCREMENTAL = false; LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT = true; LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT = false; LayoutConstants.DEFAULT_ANIMATION_PERIOD = 50; LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES = false; LayoutConstants.DEFAULT_GRAPH_MARGIN = 15; LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = false; LayoutConstants.SIMPLE_NODE_SIZE = 40; LayoutConstants.SIMPLE_NODE_HALF_SIZE = LayoutConstants.SIMPLE_NODE_SIZE / 2; LayoutConstants.EMPTY_COMPOUND_NODE_SIZE = 40; LayoutConstants.MIN_EDGE_LENGTH = 1; LayoutConstants.WORLD_BOUNDARY = 1e6; LayoutConstants.INITIAL_WORLD_BOUNDARY = LayoutConstants.WORLD_BOUNDARY / 1e3; LayoutConstants.WORLD_CENTER_X = 1200; LayoutConstants.WORLD_CENTER_Y = 900; module2.exports = LayoutConstants; }, /* 1 */ /***/ function(module2, exports2, __webpack_require__) { "use strict"; var LGraphObject = __webpack_require__(2); var IGeometry = __webpack_require__(8); var IMath = __webpack_require__(9); function LEdge(source, target, vEdge) { LGraphObject.call(this, vEdge); this.isOverlapingSourceAndTarget = false; this.vGraphObject = vEdge; this.bendpoints = []; this.source = source; this.target = target; } __name(LEdge, "LEdge"); LEdge.prototype = Object.create(LGraphObject.prototype); for (var prop in LGraphObject) { LEdge[prop] = LGraphObject[prop]; } LEdge.prototype.getSource = function() { return this.source; }; LEdge.prototype.getTarget = function() { return this.target; }; LEdge.prototype.isInterGraph = function() { return this.isInterGraph; }; LEdge.prototype.getLength = function() { return this.length; }; LEdge.prototype.isOverlapingSourceAndTarget = function() { return this.isOverlapingSourceAndTarget; }; LEdge.prototype.getBendpoints = function() { return this.bendpoints; }; LEdge.prototype.getLca = function() { return this.lca; }; LEdge.prototype.getSourceInLca = function() { return this.sourceInLca; }; LEdge.prototype.getTargetInLca = function() { return this.targetInLca; }; LEdge.prototype.getOtherEnd = function(node) { if (this.source === node) { return this.target; } else if (this.target === node) { return this.source; } else { throw "Node is not incident with this edge"; } }; LEdge.prototype.getOtherEndInGraph = function(node, graph) { var otherEnd = this.getOtherEnd(node); var root = graph.getGraphManager().getRoot(); while (true) { if (otherEnd.getOwner() == graph) { return otherEnd; } if (otherEnd.getOwner() == root) { break; } otherEnd = otherEnd.getOwner().getParent(); } return null; }; LEdge.prototype.updateLength = function() { var clipPointCoordinates = new Array(4); this.isOverlapingSourceAndTarget = IGeometry.getIntersection(this.target.getRect(), this.source.getRect(), clipPointCoordinates); if (!this.isOverlapingSourceAndTarget) { this.lengthX = clipPointCoordinates[0] - clipPointCoordinates[2]; this.lengthY = clipPointCoordinates[1] - clipPointCoordinates[3]; if (Math.abs(this.lengthX) < 1) { this.lengthX = IMath.sign(this.lengthX); } if (Math.abs(this.lengthY) < 1) { this.lengthY = IMath.sign(this.lengthY); } this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY); } }; LEdge.prototype.updateLengthSimple = function() { this.lengthX = this.target.getCenterX() - this.source.getCenterX(); this.lengthY = this.target.getCenterY() - this.source.getCenterY(); if (Math.abs(this.lengthX) < 1) { this.lengthX = IMath.sign(this.lengthX); } if (Math.abs(this.lengthY) < 1) { this.lengthY = IMath.sign(this.lengthY); } this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY); }; module2.exports = LEdge; }, /* 2 */ /***/ function(module2, exports2, __webpack_require__) { "use strict"; function LGraphObject(vGraphObject) { this.vGraphObject = vGraphObject; } __name(LGraphObject, "LGraphObject"); module2.exports = LGraphObject; }, /* 3 */ /***/ function(module2, exports2, __webpack_require__) { "use strict"; var LGraphObject = __webpack_require__(2); var Integer = __webpack_require__(10); var RectangleD = __webpack_require__(13); var LayoutConstants = __webpack_require__(0); var RandomSeed = __webpack_require__(16); var PointD = __webpack_require__(4); function LNode(gm, loc, size, vNode) { if (size == null && vNode == null) { vNode = loc; } LGraphObject.call(this, vNode); if (gm.graphManager != null) gm = gm.graphManager; this.estimatedSize = Integer.MIN_VALUE; this.inclusionTreeDepth = Integer.MAX_VALUE; this.vGraphObject = vNode; this.edges = []; this.graphManager = gm; if (size != null && loc != null) this.rect = new RectangleD(loc.x, loc.y, size.width, size.height); else this.rect = new RectangleD(); } __name(LNode, "LNode"); LNode.prototype = Object.create(LGraphObject.prototype); for (var prop in LGraphObject) { LNode[prop] = LGraphObject[prop]; } LNode.prototype.getEdges = function() { return this.edges; }; LNode.prototype.getChild = function() { return this.child; }; LNode.prototype.getOwner = function() { return this.owner; }; LNode.prototype.getWidth = function() { return this.rect.width; }; LNode.prototype.setWidth = function(width) { this.rect.width = width; }; LNode.prototype.getHeight = function() { return this.rect.height; }; LNode.prototype.setHeight = function(height) { this.rect.height = height; }; LNode.prototype.getCenterX = function() { return this.rect.x + this.rect.width / 2; }; LNode.prototype.getCenterY = function() { return this.rect.y + this.rect.height / 2; }; LNode.prototype.getCenter = function() { return new PointD(this.rect.x + this.rect.width / 2, this.rect.y + this.rect.height / 2); }; LNode.prototype.getLocation = function() { return new PointD(this.rect.x, this.rect.y); }; LNode.prototype.getRect = function() { return this.rect; }; LNode.prototype.getDiagonal = function() { return Math.sqrt(this.rect.width * this.rect.width + this.rect.height * this.rect.height); }; LNode.prototype.getHalfTheDiagonal = function() { return Math.sqrt(this.rect.height * this.rect.height + this.rect.width * this.rect.width) / 2; }; LNode.prototype.setRect = function(upperLeft, dimension) { this.rect.x = upperLeft.x; this.rect.y = upperLeft.y; this.rect.width = dimension.width; this.rect.height = dimension.height; }; LNode.prototype.setCenter = function(cx, cy) { this.rect.x = cx - this.rect.width / 2; this.rect.y = cy - this.rect.height / 2; }; LNode.prototype.setLocation = function(x, y) { this.rect.x = x; this.rect.y = y; }; LNode.prototype.moveBy = function(dx, dy) { this.rect.x += dx; this.rect.y += dy; }; LNode.prototype.getEdgeListToNode = function(to) { var edgeList = []; var edge; var self = this; self.edges.forEach(function(edge2) { if (edge2.target == to) { if (edge2.source != self) throw "Incorrect edge source!"; edgeList.push(edge2); } }); return edgeList; }; LNode.prototype.getEdgesBetween = function(other) { var edgeList = []; var edge; var self = this; self.edges.forEach(function(edge2) { if (!(edge2.source == self || edge2.target == self)) throw "Incorrect edge source and/or target"; if (edge2.target == other || edge2.source == other) { edgeList.push(edge2); } }); return edgeList; }; LNode.prototype.getNeighborsList = function() { var neighbors = /* @__PURE__ */ new Set(); var self = this; self.edges.forEach(function(edge) { if (edge.source == self) { neighbors.add(edge.target); } else { if (edge.target != self) { throw "Incorrect incidency!"; } neighbors.add(edge.source); } }); return neighbors; }; LNode.prototype.withChildren = function() { var withNeighborsList = /* @__PURE__ */ new Set(); var childNode; var children; withNeighborsList.add(this); if (this.child != null) { var nodes2 = this.child.getNodes(); for (var i = 0; i < nodes2.length; i++) { childNode = nodes2[i]; children = childNode.withChildren(); children.forEach(function(node) { withNeighborsList.add(node); }); } } return withNeighborsList; }; LNode.prototype.getNoOfChildren = function() { var noOfChildren = 0; var childNode; if (this.child == null) { noOfChildren = 1; } else { var nodes2 = this.child.getNodes(); for (var i = 0; i < nodes2.length; i++) { childNode = nodes2[i]; noOfChildren += childNode.getNoOfChildren(); } } if (noOfChildren == 0) { noOfChildren = 1; } return noOfChildren; }; LNode.prototype.getEstimatedSize = function() { if (this.estimatedSize == Integer.MIN_VALUE) { throw "assert failed"; } return this.estimatedSize; }; LNode.prototype.calcEstimatedSize = function() { if (this.child == null) { return this.estimatedSize = (this.rect.width + this.rect.height) / 2; } else { this.estimatedSize = this.child.calcEstimatedSize(); this.rect.width = this.estimatedSize; this.rect.height = this.estimatedSize; return this.estimatedSize; } }; LNode.prototype.scatter = function() { var randomCenterX; var randomCenterY; var minX = -LayoutConstants.INITIAL_WORLD_BOUNDARY; var maxX = LayoutConstants.INITIAL_WORLD_BOUNDARY; randomCenterX = LayoutConstants.WORLD_CENTER_X + RandomSeed.nextDouble() * (maxX - minX) + minX; var minY = -LayoutConstants.INITIAL_WORLD_BOUNDARY; var maxY = LayoutConstants.INITIAL_WORLD_BOUNDARY; randomCenterY = LayoutConstants.WORLD_CENTER_Y + RandomSeed.nextDouble() * (maxY - minY) + minY; this.rect.x = randomCenterX; this.rect.y = randomCenterY; }; LNode.prototype.updateBounds = function() { if (this.getChild() == null) { throw "assert failed"; } if (this.getChild().getNodes().length != 0) { var childGraph = this.getChild(); childGraph.updateBounds(true); this.rect.x = childGraph.getLeft(); this.rect.y = childGraph.getTop(); this.setWidth(childGraph.getRight() - childGraph.getLeft()); this.setHeight(childGraph.getBottom() - childGraph.getTop()); if (LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS) { var width = childGraph.getRight() - childGraph.getLeft(); var height = childGraph.getBottom() - childGraph.getTop(); if (this.labelWidth > width) { this.rect.x -= (this.labelWidth - width) / 2; this.setWidth(this.labelWidth); } if (this.labelHeight > height) { if (this.labelPos == "center") { this.rect.y -= (this.labelHeight - height) / 2; } else if (this.labelPos == "top") { this.rect.y -= this.labelHeight - height; } this.setHeight(this.labelHeight); } } } }; LNode.prototype.getInclusionTreeDepth = function() { if (this.inclusionTreeDepth == Integer.MAX_VALUE) { throw "assert failed"; } return this.inclusionTreeDepth; }; LNode.prototype.transform = function(trans) { var left = this.rect.x; if (left > LayoutConstants.WORLD_BOUNDARY) { left = LayoutConstants.WORLD_BOUNDARY; } else if (left < -LayoutConstants.WORLD_BOUNDARY) { left = -LayoutConstants.WORLD_BOUNDARY; } var top = this.rect.y; if (top > LayoutConstants.WORLD_BOUNDARY) { top = LayoutConstants.WORLD_BOUNDARY; } else if (top < -LayoutConstants.WORLD_BOUNDARY) { top = -LayoutConstants.WORLD_BOUNDARY; } var leftTop = new PointD(left, top); var vLeftTop = trans.inverseTransformPoint(leftTop); this.setLocation(vLeftTop.x, vLeftTop.y); }; LNode.prototype.getLeft = function() { return this.rect.x; }; LNode.prototype.getRight = function() { return this.rect.x + this.rect.width; }; LNode.prototype.getTop = function() { return this.rect.y; }; LNode.prototype.getBottom = function() { return this.rect.y + this.rect.height; }; LNode.prototype.getParent = function() { if (this.owner == null) { return null; } return this.owner.getParent(); }; module2.exports = LNode; }, /* 4 */ /***/ function(module2, exports2, __webpack_require__) { "use strict"; function PointD(x, y) { if (x == null && y == null) { this.x = 0; this.y = 0; } else { this.x = x; this.y = y; } } __name(PointD, "PointD"); PointD.prototype.getX = function() { return this.x; }; PointD.prototype.getY = function() { return this.y; }; PointD.prototype.setX = function(x) { this.x = x; }; PointD.prototype.setY = function(y) { this.y = y; }; PointD.prototype.getDifference = function(pt) { return new DimensionD(this.x - pt.x, this.y - pt.y); }; PointD.prototype.getCopy = function() { return new PointD(this.x, this.y); }; PointD.prototype.translate = function(dim) { this.x += dim.width; this.y += dim.height; return this; }; module2.exports = PointD; }, /* 5 */ /***/ function(module2, exports2, __webpack_require__) { "use strict"; var LGraphObject = __webpack_require__(2); var Integer = __webpack_require__(10); var LayoutConstants = __webpack_require__(0); var LGraphManager = __webpack_require__(6); var LNode = __webpack_require__(3); var LEdge = __webpack_require__(1); var RectangleD = __webpack_require__(13); var Point2 = __webpack_require__(12); var LinkedList = __webpack_require__(11); function LGraph(parent, obj2, vGraph) { LGraphObject.call(this, vGraph); this.estimatedSize = Integer.MIN_VALUE; this.margin = LayoutConstants.DEFAULT_GRAPH_MARGIN; this.edges = []; this.nodes = []; this.isConnected = false; this.parent = parent; if (obj2 != null && obj2 instanceof LGraphManager) { this.graphManager = obj2; } else if (obj2 != null && obj2 instanceof Layout) { this.graphManager = obj2.graphManager; } } __name(LGraph, "LGraph"); LGraph.prototype = Object.create(LGraphObject.prototype); for (var prop in LGraphObject) { LGraph[prop] = LGraphObject[prop]; } LGraph.prototype.getNodes = function() { return this.nodes; }; LGraph.prototype.getEdges = function() { return this.edges; }; LGraph.prototype.getGraphManager = function() { return this.graphManager; }; LGraph.prototype.getParent = function() { return this.parent; }; LGraph.prototype.getLeft = function() { return this.left; }; LGraph.prototype.getRight = function() { return this.right; }; LGraph.prototype.getTop = function() { return this.top; }; LGraph.prototype.getBottom = function() { return this.bottom; }; LGraph.prototype.isConnected = function() { return this.isConnected; }; LGraph.prototype.add = function(obj1, sourceNode, targetNode) { if (sourceNode == null && targetNode == null) { var newNode = obj1; if (this.graphManager == null) { throw "Graph has no graph mgr!"; } if (this.getNodes().indexOf(newNode) > -1) { throw "Node already in graph!"; } newNode.owner = this; this.getNodes().push(newNode); return newNode; } else { var newEdge = obj1; if (!(this.getNodes().indexOf(sourceNode) > -1 && this.getNodes().indexOf(targetNode) > -1)) { throw "Source or target not in graph!"; } if (!(sourceNode.owner == targetNode.owner && sourceNode.owner == this)) { throw "Both owners must be this graph!"; } if (sourceNode.owner != targetNode.owner) { return null; } newEdge.source = sourceNode; newEdge.target = targetNode; newEdge.isInterGraph = false; this.getEdges().push(newEdge); sourceNode.edges.push(newEdge); if (targetNode != sourceNode) { targetNode.edges.push(newEdge); } return newEdge; } }; LGraph.prototype.remove = function(obj) { var node = obj; if (obj instanceof LNode) { if (node == null) { throw "Node is null!"; } if (!(node.owner != null && node.owner == this)) { throw "Owner graph is invalid!"; } if (this.graphManager == null) { throw "Owner graph manager is invalid!"; } var edgesToBeRemoved = node.edges.slice(); var edge; var s = edgesToBeRemoved.length; for (var i = 0; i < s; i++) { edge = edgesToBeRemoved[i]; if (edge.isInterGraph) { this.graphManager.remove(edge); } else { edge.source.owner.remove(edge); } } var index = this.nodes.indexOf(node); if (index == -1) { throw "Node not in owner node list!"; } this.nodes.splice(index, 1); } else if (obj instanceof LEdge) { var edge = obj; if (edge == null) { throw "Edge is null!"; } if (!(edge.source != null && edge.target != null)) { throw "Source and/or target is null!"; } if (!(edge.source.owner != null && edge.target.owner != null && edge.source.owner == this && edge.target.owner == this)) { throw "Source and/or target owner is invalid!"; } var sourceIndex = edge.source.edges.indexOf(edge); var targetIndex = edge.target.edges.indexOf(edge); if (!(sourceIndex > -1 && targetIndex > -1)) { throw "Source and/or target doesn't know this edge!"; } edge.source.edges.splice(sourceIndex, 1); if (edge.target != edge.source) { edge.target.edges.splice(targetIndex, 1); } var index = edge.source.owner.getEdges().indexOf(edge); if (index == -1) { throw "Not in owner's edge list!"; } edge.source.owner.getEdges().splice(index, 1); } }; LGraph.prototype.updateLeftTop = function() { var top = Integer.MAX_VALUE; var left = Integer.MAX_VALUE; var nodeTop; var nodeLeft; var margin; var nodes2 = this.getNodes(); var s = nodes2.length; for (var i = 0; i < s; i++) { var lNode = nodes2[i]; nodeTop = lNode.getTop(); nodeLeft = lNode.getLeft(); if (top > nodeTop) { top = nodeTop; } if (left > nodeLeft) { left = nodeLeft; } } if (top == Integer.MAX_VALUE) { return null; } if (nodes2[0].getParent().paddingLeft != void 0) { margin = nodes2[0].getParent().paddingLeft; } else { margin = this.margin; } this.left = left - margin; this.top = top - margin; return new Point2(this.left, this.top); }; LGraph.prototype.updateBounds = function(recursive) { var left = Integer.MAX_VALUE; var right = -Integer.MAX_VALUE; var top = Integer.MAX_VALUE; var bottom = -Integer.MAX_VALUE; var nodeLeft; var nodeRight; var nodeTop; var nodeBottom; var margin; var nodes2 = this.nodes; var s = nodes2.length; for (var i = 0; i < s; i++) { var lNode = nodes2[i]; if (recursive && lNode.child != null) { lNode.updateBounds(); } nodeLeft = lNode.getLeft(); nodeRight = lNode.getRight(); nodeTop = lNode.getTop(); nodeBottom = lNode.getBottom(); if (left > nodeLeft) { left = nodeLeft; } if (right < nodeRight) { right = nodeRight; } if (top > nodeTop) { top = nodeTop; } if (bottom < nodeBottom) { bottom = nodeBottom; } } var boundingRect = new RectangleD(left, top, right - left, bottom - top); if (left == Integer.MAX_VALUE) { this.left = this.parent.getLeft(); this.right = this.parent.getRight(); this.top = this.parent.getTop(); this.bottom = this.parent.getBottom(); } if (nodes2[0].getParent().paddingLeft != void 0) { margin = nodes2[0].getParent().paddingLeft; } else { margin = this.margin; } this.left = boundingRect.x - margin; this.right = boundingRect.x + boundingRect.width + margin; this.top = boundingRect.y - margin; this.bottom = boundingRect.y + boundingRect.height + margin; }; LGraph.calculateBounds = function(nodes2) { var left = Integer.MAX_VALUE; var right = -Integer.MAX_VALUE; var top = Integer.MAX_VALUE; var bottom = -Integer.MAX_VALUE; var nodeLeft; var nodeRight; var nodeTop; var nodeBottom; var s = nodes2.length; for (var i = 0; i < s; i++) { var lNode = nodes2[i]; nodeLeft = lNode.getLeft(); nodeRight = lNode.getRight(); nodeTop = lNode.getTop(); nodeBottom = lNode.getBottom(); if (left > nodeLeft) { left = nodeLeft; } if (right < nodeRight) { right = nodeRight; } if (top > nodeTop) { top = nodeTop; } if (bottom < nodeBottom) { bottom = nodeBottom; } } var boundingRect = new RectangleD(left, top, right - left, bottom - top); return boundingRect; }; LGraph.prototype.getInclusionTreeDepth = function() { if (this == this.graphManager.getRoot()) { return 1; } else { return this.parent.getInclusionTreeDepth(); } }; LGraph.prototype.getEstimatedSize = function() { if (this.estimatedSize == Integer.MIN_VALUE) { throw "assert failed"; } return this.estimatedSize; }; LGraph.prototype.calcEstimatedSize = function() { var size = 0; var nodes2 = this.nodes; var s = nodes2.length; for (var i = 0; i < s; i++) { var lNode = nodes2[i]; size += lNode.calcEstimatedSize(); } if (size == 0) { this.estimatedSize = LayoutConstants.EMPTY_COMPOUND_NODE_SIZE; } else { this.estimatedSize = size / Math.sqrt(this.nodes.length); } return this.estimatedSize; }; LGraph.prototype.updateConnected = function() { var self = this; if (this.nodes.length == 0) { this.isConnected = true; return; } var queue = new LinkedList(); var visited = /* @__PURE__ */ new Set(); var currentNode = this.nodes[0]; var neighborEdges; var currentNeighbor; var childrenOfNode = currentNode.withChildren(); childrenOfNode.forEach(function(node) { queue.push(node); visited.add(node); }); while (queue.length !== 0) { currentNode = queue.shift(); neighborEdges = currentNode.getEdges(); var size = neighborEdges.length; for (var i = 0; i < size; i++) { var neighborEdge = neighborEdges[i]; currentNeighbor = neighborEdge.getOtherEndInGraph(currentNode, this); if (currentNeighbor != null && !visited.has(currentNeighbor)) { var childrenOfNeighbor = currentNeighbor.withChildren(); childrenOfNeighbor.forEach(function(node) { queue.push(node); visited.add(node); }); } } } this.isConnected = false; if (visited.size >= this.nodes.length) { var noOfVisitedInThisGraph = 0; visited.forEach(function(visitedNode) { if (visitedNode.owner == self) { noOfVisitedInThisGraph++; } }); if (noOfVisitedInThisGraph == this.nodes.length) { this.isConnected = true; } } }; module2.exports = LGraph; }, /* 6 */ /***/ function(module2, exports2, __webpack_require__) { "use strict"; var LGraph; var LEdge = __webpack_require__(1); function LGraphManager(layout) { LGraph = __webpack_require__(5); this.layout = layout; this.graphs = []; this.edges = []; } __name(LGraphManager, "LGraphManager"); LGraphManager.prototype.addRoot = function() { var ngraph = this.layout.newGraph(); var nnode = this.layout.newNode(null); var root = this.add(ngraph, nnode); this.setRootGraph(root); return this.rootGraph; }; LGraphManager.prototype.add = function(newGraph, parentNode, newEdge, sourceNode, targetNode) { if (newEdge == null && sourceNode == null && targetNode == null) { if (newGraph == null) { throw "Graph is null!"; } if (parentNode == null) { throw "Parent node is null!"; } if (this.graphs.indexOf(newGraph) > -1) { throw "Graph already in this graph mgr!"; } this.graphs.push(newGraph); if (newGraph.parent != null) { throw "Already has a parent!"; } if (parentNode.child != null) { throw "Already has a child!"; } newGraph.parent = parentNode; parentNode.child = newGraph; return newGraph; } else { targetNode = newEdge; sourceNode = parentNode; newEdge = newGraph; var sourceGraph = sourceNode.getOwner(); var targetGraph = targetNode.getOwner(); if (!(sourceGraph != null && sourceGraph.getGraphManager() == this)) { throw "Source not in this graph mgr!"; } if (!(targetGraph != null && targetGraph.getGraphManager() == this)) { throw "Target not in this graph mgr!"; } if (sourceGraph == targetGraph) { newEdge.isInterGraph = false; return sourceGraph.add(newEdge, sourceNode, targetNode); } else { newEdge.isInterGraph = true; newEdge.source = sourceNode; newEdge.target = targetNode; if (this.edges.indexOf(newEdge) > -1) { throw "Edge already in inter-graph edge list!"; } this.edges.push(newEdge); if (!(newEdge.source != null && newEdge.target != null)) { throw "Edge source and/or target is null!"; } if (!(newEdge.source.edges.indexOf(newEdge) == -1 && newEdge.target.edges.indexOf(newEdge) == -1)) { throw "Edge already in source and/or target incidency list!"; } newEdge.source.edges.push(newEdge); newEdge.target.edges.push(newEdge); return newEdge; } } }; LGraphManager.prototype.remove = function(lObj) { if (lObj instanceof LGraph) { var graph = lObj; if (graph.getGraphManager() != this) { throw "Graph not in this graph mgr"; } if (!(graph == this.rootGraph || graph.parent != null && graph.parent.graphManager == this)) { throw "Invalid parent node!"; } var edgesToBeRemoved = []; edgesToBeRemoved = edgesToBeRemoved.concat(graph.getEdges()); var edge; var s = edgesToBeRemoved.length; for (var i = 0; i < s; i++) { edge = edgesToBeRemoved[i]; graph.remove(edge); } var nodesToBeRemoved = []; nodesToBeRemoved = nodesToBeRemoved.concat(graph.getNodes()); var node; s = nodesToBeRemoved.length; for (var i = 0; i < s; i++) { node = nodesToBeRemoved[i]; graph.remove(node); } if (graph == this.rootGraph) { this.setRootGraph(null); } var index = this.graphs.indexOf(graph); this.graphs.splice(index, 1); graph.parent = null; } else if (lObj instanceof LEdge) { edge = lObj; if (edge == null) { throw "Edge is null!"; } if (!edge.isInterGraph) { throw "Not an inter-graph edge!"; } if (!(edge.source != null && edge.target != null)) { throw "Source and/or target is null!"; } if (!(edge.source.edges.indexOf(edge) != -1 && edge.target.edges.indexOf(edge) != -1)) { throw "Source and/or target doesn't know this edge!"; } var index = edge.source.edges.indexOf(edge); edge.source.edges.splice(index, 1); index = edge.target.edges.indexOf(edge); edge.target.edges.splice(index, 1); if (!(edge.source.owner != null && edge.source.owner.getGraphManager() != null)) { throw "Edge owner graph or owner graph manager is null!"; } if (edge.source.owner.getGraphManager().edges.indexOf(edge) == -1) { throw "Not in owner graph manager's edge list!"; } var index = edge.source.owner.getGraphManager().edges.indexOf(edge); edge.source.owner.getGraphManager().edges.splice(index, 1); } }; LGraphManager.prototype.updateBounds = function() { this.rootGraph.updateBounds(true); }; LGraphManager.prototype.getGraphs = function() { return this.graphs; }; LGraphManager.prototype.getAllNodes = function() { if (this.allNodes == null) { var nodeList = []; var graphs = this.getGraphs(); var s = graphs.length; for (var i = 0; i < s; i++) { nodeList = nodeList.concat(graphs[i].getNodes()); } this.allNodes = nodeList; } return this.allNodes; }; LGraphManager.prototype.resetAllNodes = function() { this.allNodes = null; }; LGraphManager.prototype.resetAllEdges = function() { this.allEdges = null; }; LGraphManager.prototype.resetAllNodesToApplyGravitation = function() { this.allNodesToApplyGravitation = null; }; LGraphManager.prototype.getAllEdges = function() { if (this.allEdges == null) { var edgeList = []; var graphs = this.getGraphs(); var s = graphs.length; for (var i = 0; i < graphs.length; i++) { edgeList = edgeList.concat(graphs[i].getEdges()); } edgeList = edgeList.concat(this.edges); this.allEdges = edgeList; } return this.allEdges; }; LGraphManager.prototype.getAllNodesToApplyGravitation = function() { return this.allNodesToApplyGravitation; }; LGraphManager.prototype.setAllNodesToApplyGravitation = function(nodeList) { if (this.allNodesToApplyGravitation != null) { throw "assert failed"; } this.allNodesToApplyGravitation = nodeList; }; LGraphManager.prototype.getRoot = function() { return this.rootGraph; }; LGraphManager.prototype.setRootGraph = function(graph) { if (graph.getGraphManager() != this) { throw "Root not in this graph mgr!"; } this.rootGraph = graph; if (graph.parent == null) { graph.parent = this.layout.newNode("Root node"); } }; LGraphManager.prototype.getLayout = function() { return this.layout; }; LGraphManager.prototype.isOneAncestorOfOther = function(firstNode, secondNode) { if (!(firstNode != null && secondNode != null)) { throw "assert failed"; } if (firstNode == secondNode) { return true; } var ownerGraph = firstNode.getOwner(); var parentNode; do { parentNode = ownerGraph.getParent(); if (parentNode == null) { break; } if (parentNode == secondNode) { return true; } ownerGraph = parentNode.getOwner(); if (ownerGraph == null) { break; } } while (true); ownerGraph = secondNode.getOwner(); do { parentNode = ownerGraph.getParent(); if (parentNode == null) { break; } if (parentNode == firstNode) { return true; } ownerGraph = parentNode.getOwner(); if (ownerGraph == null) { break; } } while (true); return false; }; LGraphManager.prototype.calcLowestCommonAncestors = function() { var edge; var sourceNode; var targetNode; var sourceAncestorGraph; var targetAncestorGraph; var edges = this.getAllEdges(); var s = edges.length; for (var i = 0; i < s; i++) { edge = edges[i]; sourceNode = edge.source; targetNode = edge.target; edge.lca = null; edge.sourceInLca = sourceNode; edge.targetInLca = targetNode; if (sourceNode == targetNode) { edge.lca = sourceNode.getOwner(); continue; } sourceAncestorGraph = sourceNode.getOwner(); while (edge.lca == null) { edge.targetInLca = targetNode; targetAncestorGraph = targetNode.getOwner(); while (edge.lca == null) { if (targetAncestorGraph == sourceAncestorGraph) { edge.lca = targetAncestorGraph; break; } if (targetAncestorGraph == this.rootGraph) { break; } if (edge.lca != null) { throw "assert failed"; } edge.targetInLca = targetAncestorGraph.getParent(); targetAncestorGraph = edge.targetInLca.getOwner(); } if (sourceAncestorGraph == this.rootGraph) { break; } if (edge.lca == null) { edge.sourceInLca = sourceAncestorGraph.getParent(); sourceAncestorGraph = edge.sourceInLca.getOwner(); } } if (edge.lca == null) { throw "assert failed"; } } }; LGraphManager.prototype.calcLowestCommonAncestor = function(firstNode, secondNode) { if (firstNode == secondNode) { return firstNode.getOwner(); } var firstOwnerGraph = firstNode.getOwner(); do { if (firstOwnerGraph == null) { break; } var secondOwnerGraph = secondNode.getOwner(); do { if (secondOwnerGraph == null) { break; } if (secondOwnerGraph == firstOwnerGraph) { return secondOwnerGraph; } secondOwnerGraph = secondOwnerGraph.getParent().getOwner(); } while (true); firstOwnerGraph = firstOwnerGraph.getParent().getOwner(); } while (true); return firstOwnerGraph; }; LGraphManager.prototype.calcInclusionTreeDepths = function(graph, depth) { if (graph == null && depth == null) { graph = this.rootGraph; depth = 1; } var node; var nodes2 = graph.getNodes(); var s = nodes2.length; for (var i = 0; i < s; i++) { node = nodes2[i]; node.inclusionTreeDepth = depth; if (node.child != null) { this.calcInclusionTreeDepths(node.child, depth + 1); } } }; LGraphManager.prototype.includesInvalidEdge = function() { var edge; var s = this.edges.length; for (var i = 0; i < s; i++) { edge = this.edges[i]; if (this.isOneAncestorOfOther(edge.source, edge.target)) { return true; } } return false; }; module2.exports = LGraphManager; }, /* 7 */ /***/ function(module2, exports2, __webpack_require__) { "use strict"; var LayoutConstants = __webpack_require__(0); function FDLayoutConstants() { } __name(FDLayoutConstants, "FDLayoutConstants"); for (var prop in LayoutConstants) { FDLayoutConstants[prop] = LayoutConstants[prop]; } FDLayoutConstants.MAX_ITERATIONS = 2500;