ranui
Version:
A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.
4,280 lines • 231 kB
JavaScript
import { n as Ve, t as de } from "./rolldown-runtime-9ZSF5uba.js";
import { n as ze } from "./mermaid-parser.core-uIDZYuBu.js";
import { n as lt } from "./chunk-Y2CYZVJY-0JxdZxki.js";
import { m as De, p as $e } from "./src-DtRLxcYO.js";
import { H as Be, J as Ze, K as ke, U as Qe, a as qe, b as Je, f as Ke, v as je, w as _e, x as ve, y as tr, z as er } from "./chunk-WYO6CB5R-DDHkKowO.js";
import { c as rr, i as ir } from "./chunk-ICXQ74PX-DR8rL-xF.js";
import { t as ar } from "./chunk-VAUOI2AC-izt0o4id.js";
import { t as nr } from "./chunk-JWPE2WC7-CGEmUMMZ.js";
import { i as or, r as sr, t as ce } from "./chunk-HOUHSVGY-DRQcQeMT.js";
import { n as pe } from "./chunk-Q4XR5HBZ-3BHjjc9u.js";
import { t as xe } from "./cytoscape.esm-CFq1_DTa.js";
var we = /* @__PURE__ */ de(((L, F) => {
(function(U, N) {
typeof L == "object" && typeof F == "object" ? F.exports = N() : typeof define == "function" && define.amd ? define([], N) : typeof L == "object" ? L.layoutBase = N() : U.layoutBase = N();
})(L, function() {
return (function(w) {
var U = {};
function N(v) {
if (U[v]) return U[v].exports;
var s = U[v] = {
i: v,
l: !1,
exports: {}
};
return w[v].call(s.exports, s, s.exports, N), s.l = !0, s.exports;
}
return N.m = w, N.c = U, N.i = function(v) {
return v;
}, N.d = function(v, s, n) {
N.o(v, s) || Object.defineProperty(v, s, {
configurable: !1,
enumerable: !0,
get: n
});
}, N.n = function(v) {
var s = v && v.__esModule ? function() {
return v.default;
} : function() {
return v;
};
return N.d(s, "a", s), s;
}, N.o = function(v, s) {
return Object.prototype.hasOwnProperty.call(v, s);
}, N.p = "", N(N.s = 28);
})([
(function(w, U, N) {
"use strict";
function v() {
}
v.QUALITY = 1, v.DEFAULT_CREATE_BENDS_AS_NEEDED = !1, v.DEFAULT_INCREMENTAL = !1, v.DEFAULT_ANIMATION_ON_LAYOUT = !0, v.DEFAULT_ANIMATION_DURING_LAYOUT = !1, v.DEFAULT_ANIMATION_PERIOD = 50, v.DEFAULT_UNIFORM_LEAF_NODE_SIZES = !1, v.DEFAULT_GRAPH_MARGIN = 15, v.NODE_DIMENSIONS_INCLUDE_LABELS = !1, v.SIMPLE_NODE_SIZE = 40, v.SIMPLE_NODE_HALF_SIZE = v.SIMPLE_NODE_SIZE / 2, v.EMPTY_COMPOUND_NODE_SIZE = 40, v.MIN_EDGE_LENGTH = 1, v.WORLD_BOUNDARY = 1e6, v.INITIAL_WORLD_BOUNDARY = v.WORLD_BOUNDARY / 1e3, v.WORLD_CENTER_X = 1200, v.WORLD_CENTER_Y = 900, w.exports = v;
}),
(function(w, U, N) {
"use strict";
var v = N(2), s = N(8), n = N(9);
function t(h, e, d) {
v.call(this, d), this.isOverlapingSourceAndTarget = !1, this.vGraphObject = d, this.bendpoints = [], this.source = h, this.target = e;
}
t.prototype = Object.create(v.prototype);
for (var a in v) t[a] = v[a];
t.prototype.getSource = function() {
return this.source;
}, t.prototype.getTarget = function() {
return this.target;
}, t.prototype.isInterGraph = function() {
return this.isInterGraph;
}, t.prototype.getLength = function() {
return this.length;
}, t.prototype.isOverlapingSourceAndTarget = function() {
return this.isOverlapingSourceAndTarget;
}, t.prototype.getBendpoints = function() {
return this.bendpoints;
}, t.prototype.getLca = function() {
return this.lca;
}, t.prototype.getSourceInLca = function() {
return this.sourceInLca;
}, t.prototype.getTargetInLca = function() {
return this.targetInLca;
}, t.prototype.getOtherEnd = function(h) {
if (this.source === h) return this.target;
if (this.target === h) return this.source;
throw "Node is not incident with this edge";
}, t.prototype.getOtherEndInGraph = function(h, e) {
for (var d = this.getOtherEnd(h), r = e.getGraphManager().getRoot(); ; ) {
if (d.getOwner() == e) return d;
if (d.getOwner() == r) break;
d = d.getOwner().getParent();
}
return null;
}, t.prototype.updateLength = function() {
var h = new Array(4);
this.isOverlapingSourceAndTarget = s.getIntersection(this.target.getRect(), this.source.getRect(), h), this.isOverlapingSourceAndTarget || (this.lengthX = h[0] - h[2], this.lengthY = h[1] - h[3], Math.abs(this.lengthX) < 1 && (this.lengthX = n.sign(this.lengthX)), Math.abs(this.lengthY) < 1 && (this.lengthY = n.sign(this.lengthY)), this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY));
}, t.prototype.updateLengthSimple = function() {
this.lengthX = this.target.getCenterX() - this.source.getCenterX(), this.lengthY = this.target.getCenterY() - this.source.getCenterY(), Math.abs(this.lengthX) < 1 && (this.lengthX = n.sign(this.lengthX)), Math.abs(this.lengthY) < 1 && (this.lengthY = n.sign(this.lengthY)), this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY);
}, w.exports = t;
}),
(function(w, U, N) {
"use strict";
function v(s) {
this.vGraphObject = s;
}
w.exports = v;
}),
(function(w, U, N) {
"use strict";
var v = N(2), s = N(10), n = N(13), t = N(0), a = N(16), h = N(5);
function e(r, i, f, l) {
f == null && l == null && (l = i), v.call(this, l), r.graphManager != null && (r = r.graphManager), this.estimatedSize = s.MIN_VALUE, this.inclusionTreeDepth = s.MAX_VALUE, this.vGraphObject = l, this.edges = [], this.graphManager = r, f != null && i != null ? this.rect = new n(i.x, i.y, f.width, f.height) : this.rect = new n();
}
e.prototype = Object.create(v.prototype);
for (var d in v) e[d] = v[d];
e.prototype.getEdges = function() {
return this.edges;
}, e.prototype.getChild = function() {
return this.child;
}, e.prototype.getOwner = function() {
return this.owner;
}, e.prototype.getWidth = function() {
return this.rect.width;
}, e.prototype.setWidth = function(r) {
this.rect.width = r;
}, e.prototype.getHeight = function() {
return this.rect.height;
}, e.prototype.setHeight = function(r) {
this.rect.height = r;
}, e.prototype.getCenterX = function() {
return this.rect.x + this.rect.width / 2;
}, e.prototype.getCenterY = function() {
return this.rect.y + this.rect.height / 2;
}, e.prototype.getCenter = function() {
return new h(this.rect.x + this.rect.width / 2, this.rect.y + this.rect.height / 2);
}, e.prototype.getLocation = function() {
return new h(this.rect.x, this.rect.y);
}, e.prototype.getRect = function() {
return this.rect;
}, e.prototype.getDiagonal = function() {
return Math.sqrt(this.rect.width * this.rect.width + this.rect.height * this.rect.height);
}, e.prototype.getHalfTheDiagonal = function() {
return Math.sqrt(this.rect.height * this.rect.height + this.rect.width * this.rect.width) / 2;
}, e.prototype.setRect = function(r, i) {
this.rect.x = r.x, this.rect.y = r.y, this.rect.width = i.width, this.rect.height = i.height;
}, e.prototype.setCenter = function(r, i) {
this.rect.x = r - this.rect.width / 2, this.rect.y = i - this.rect.height / 2;
}, e.prototype.setLocation = function(r, i) {
this.rect.x = r, this.rect.y = i;
}, e.prototype.moveBy = function(r, i) {
this.rect.x += r, this.rect.y += i;
}, e.prototype.getEdgeListToNode = function(r) {
var i = [], f = this;
return f.edges.forEach(function(l) {
if (l.target == r) {
if (l.source != f) throw "Incorrect edge source!";
i.push(l);
}
}), i;
}, e.prototype.getEdgesBetween = function(r) {
var i = [], f = this;
return f.edges.forEach(function(l) {
if (!(l.source == f || l.target == f)) throw "Incorrect edge source and/or target";
(l.target == r || l.source == r) && i.push(l);
}), i;
}, e.prototype.getNeighborsList = function() {
var r = /* @__PURE__ */ new Set(), i = this;
return i.edges.forEach(function(f) {
if (f.source == i) r.add(f.target);
else {
if (f.target != i) throw "Incorrect incidency!";
r.add(f.source);
}
}), r;
}, e.prototype.withChildren = function() {
var r = /* @__PURE__ */ new Set(), i, f;
if (r.add(this), this.child != null)
for (var l = this.child.getNodes(), p = 0; p < l.length; p++)
i = l[p], f = i.withChildren(), f.forEach(function(g) {
r.add(g);
});
return r;
}, e.prototype.getNoOfChildren = function() {
var r = 0, i;
if (this.child == null) r = 1;
else
for (var f = this.child.getNodes(), l = 0; l < f.length; l++)
i = f[l], r += i.getNoOfChildren();
return r == 0 && (r = 1), r;
}, e.prototype.getEstimatedSize = function() {
if (this.estimatedSize == s.MIN_VALUE) throw "assert failed";
return this.estimatedSize;
}, e.prototype.calcEstimatedSize = function() {
return this.child == null ? this.estimatedSize = (this.rect.width + this.rect.height) / 2 : (this.estimatedSize = this.child.calcEstimatedSize(), this.rect.width = this.estimatedSize, this.rect.height = this.estimatedSize, this.estimatedSize);
}, e.prototype.scatter = function() {
var r, i, f = -t.INITIAL_WORLD_BOUNDARY, l = t.INITIAL_WORLD_BOUNDARY;
r = t.WORLD_CENTER_X + a.nextDouble() * (l - f) + f;
var p = -t.INITIAL_WORLD_BOUNDARY, g = t.INITIAL_WORLD_BOUNDARY;
i = t.WORLD_CENTER_Y + a.nextDouble() * (g - p) + p, this.rect.x = r, this.rect.y = i;
}, e.prototype.updateBounds = function() {
if (this.getChild() == null) throw "assert failed";
if (this.getChild().getNodes().length != 0) {
var r = this.getChild();
if (r.updateBounds(!0), this.rect.x = r.getLeft(), this.rect.y = r.getTop(), this.setWidth(r.getRight() - r.getLeft()), this.setHeight(r.getBottom() - r.getTop()), t.NODE_DIMENSIONS_INCLUDE_LABELS) {
var i = r.getRight() - r.getLeft(), f = r.getBottom() - r.getTop();
this.labelWidth && (this.labelPosHorizontal == "left" ? (this.rect.x -= this.labelWidth, this.setWidth(i + this.labelWidth)) : this.labelPosHorizontal == "center" && this.labelWidth > i ? (this.rect.x -= (this.labelWidth - i) / 2, this.setWidth(this.labelWidth)) : this.labelPosHorizontal == "right" && this.setWidth(i + this.labelWidth)), this.labelHeight && (this.labelPosVertical == "top" ? (this.rect.y -= this.labelHeight, this.setHeight(f + this.labelHeight)) : this.labelPosVertical == "center" && this.labelHeight > f ? (this.rect.y -= (this.labelHeight - f) / 2, this.setHeight(this.labelHeight)) : this.labelPosVertical == "bottom" && this.setHeight(f + this.labelHeight));
}
}
}, e.prototype.getInclusionTreeDepth = function() {
if (this.inclusionTreeDepth == s.MAX_VALUE) throw "assert failed";
return this.inclusionTreeDepth;
}, e.prototype.transform = function(r) {
var i = this.rect.x;
i > t.WORLD_BOUNDARY ? i = t.WORLD_BOUNDARY : i < -t.WORLD_BOUNDARY && (i = -t.WORLD_BOUNDARY);
var f = this.rect.y;
f > t.WORLD_BOUNDARY ? f = t.WORLD_BOUNDARY : f < -t.WORLD_BOUNDARY && (f = -t.WORLD_BOUNDARY);
var l = new h(i, f), p = r.inverseTransformPoint(l);
this.setLocation(p.x, p.y);
}, e.prototype.getLeft = function() {
return this.rect.x;
}, e.prototype.getRight = function() {
return this.rect.x + this.rect.width;
}, e.prototype.getTop = function() {
return this.rect.y;
}, e.prototype.getBottom = function() {
return this.rect.y + this.rect.height;
}, e.prototype.getParent = function() {
return this.owner == null ? null : this.owner.getParent();
}, w.exports = e;
}),
(function(w, U, N) {
"use strict";
var v = N(0);
function s() {
}
for (var n in v) s[n] = v[n];
s.MAX_ITERATIONS = 2500, s.DEFAULT_EDGE_LENGTH = 50, s.DEFAULT_SPRING_STRENGTH = 0.45, s.DEFAULT_REPULSION_STRENGTH = 4500, s.DEFAULT_GRAVITY_STRENGTH = 0.4, s.DEFAULT_COMPOUND_GRAVITY_STRENGTH = 1, s.DEFAULT_GRAVITY_RANGE_FACTOR = 3.8, s.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = 1.5, s.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION = !0, s.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION = !0, s.DEFAULT_COOLING_FACTOR_INCREMENTAL = 0.3, s.COOLING_ADAPTATION_FACTOR = 0.33, s.ADAPTATION_LOWER_NODE_LIMIT = 1e3, s.ADAPTATION_UPPER_NODE_LIMIT = 5e3, s.MAX_NODE_DISPLACEMENT_INCREMENTAL = 100, s.MAX_NODE_DISPLACEMENT = s.MAX_NODE_DISPLACEMENT_INCREMENTAL * 3, s.MIN_REPULSION_DIST = s.DEFAULT_EDGE_LENGTH / 10, s.CONVERGENCE_CHECK_PERIOD = 100, s.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = 0.1, s.MIN_EDGE_LENGTH = 1, s.GRID_CALCULATION_CHECK_PERIOD = 10, w.exports = s;
}),
(function(w, U, N) {
"use strict";
function v(s, n) {
s == null && n == null ? (this.x = 0, this.y = 0) : (this.x = s, this.y = n);
}
v.prototype.getX = function() {
return this.x;
}, v.prototype.getY = function() {
return this.y;
}, v.prototype.setX = function(s) {
this.x = s;
}, v.prototype.setY = function(s) {
this.y = s;
}, v.prototype.getDifference = function(s) {
return new DimensionD(this.x - s.x, this.y - s.y);
}, v.prototype.getCopy = function() {
return new v(this.x, this.y);
}, v.prototype.translate = function(s) {
return this.x += s.width, this.y += s.height, this;
}, w.exports = v;
}),
(function(w, U, N) {
"use strict";
var v = N(2), s = N(10), n = N(0), t = N(7), a = N(3), h = N(1), e = N(13), d = N(12), r = N(11);
function i(l, p, g) {
v.call(this, g), this.estimatedSize = s.MIN_VALUE, this.margin = n.DEFAULT_GRAPH_MARGIN, this.edges = [], this.nodes = [], this.isConnected = !1, this.parent = l, p != null && p instanceof t ? this.graphManager = p : p != null && p instanceof Layout && (this.graphManager = p.graphManager);
}
i.prototype = Object.create(v.prototype);
for (var f in v) i[f] = v[f];
i.prototype.getNodes = function() {
return this.nodes;
}, i.prototype.getEdges = function() {
return this.edges;
}, i.prototype.getGraphManager = function() {
return this.graphManager;
}, i.prototype.getParent = function() {
return this.parent;
}, i.prototype.getLeft = function() {
return this.left;
}, i.prototype.getRight = function() {
return this.right;
}, i.prototype.getTop = function() {
return this.top;
}, i.prototype.getBottom = function() {
return this.bottom;
}, i.prototype.isConnected = function() {
return this.isConnected;
}, i.prototype.add = function(l, p, g) {
if (p == null && g == null) {
var c = l;
if (this.graphManager == null) throw "Graph has no graph mgr!";
if (this.getNodes().indexOf(c) > -1) throw "Node already in graph!";
return c.owner = this, this.getNodes().push(c), c;
} else {
var T = l;
if (!(this.getNodes().indexOf(p) > -1 && this.getNodes().indexOf(g) > -1)) throw "Source or target not in graph!";
if (!(p.owner == g.owner && p.owner == this)) throw "Both owners must be this graph!";
return p.owner != g.owner ? null : (T.source = p, T.target = g, T.isInterGraph = !1, this.getEdges().push(T), p.edges.push(T), g != p && g.edges.push(T), T);
}
}, i.prototype.remove = function(l) {
var p = l;
if (l instanceof a) {
if (p == null) throw "Node is null!";
if (!(p.owner != null && p.owner == this)) throw "Owner graph is invalid!";
if (this.graphManager == null) throw "Owner graph manager is invalid!";
for (var g = p.edges.slice(), c, T = g.length, A = 0; A < T; A++)
c = g[A], c.isInterGraph ? this.graphManager.remove(c) : c.source.owner.remove(c);
var I = this.nodes.indexOf(p);
if (I == -1) throw "Node not in owner node list!";
this.nodes.splice(I, 1);
} else if (l instanceof h) {
var c = l;
if (c == null) throw "Edge is null!";
if (!(c.source != null && c.target != null)) throw "Source and/or target is null!";
if (!(c.source.owner != null && c.target.owner != null && c.source.owner == this && c.target.owner == this)) throw "Source and/or target owner is invalid!";
var S = c.source.edges.indexOf(c), Y = c.target.edges.indexOf(c);
if (!(S > -1 && Y > -1)) throw "Source and/or target doesn't know this edge!";
c.source.edges.splice(S, 1), c.target != c.source && c.target.edges.splice(Y, 1);
var I = c.source.owner.getEdges().indexOf(c);
if (I == -1) throw "Not in owner's edge list!";
c.source.owner.getEdges().splice(I, 1);
}
}, i.prototype.updateLeftTop = function() {
for (var l = s.MAX_VALUE, p = s.MAX_VALUE, g, c, T, A = this.getNodes(), I = A.length, S = 0; S < I; S++) {
var Y = A[S];
g = Y.getTop(), c = Y.getLeft(), l > g && (l = g), p > c && (p = c);
}
return l == s.MAX_VALUE ? null : (A[0].getParent().paddingLeft != null ? T = A[0].getParent().paddingLeft : T = this.margin, this.left = p - T, this.top = l - T, new d(this.left, this.top));
}, i.prototype.updateBounds = function(l) {
for (var p = s.MAX_VALUE, g = -s.MAX_VALUE, c = s.MAX_VALUE, T = -s.MAX_VALUE, A, I, S, Y, V, z = this.nodes, x = z.length, tt = 0; tt < x; tt++) {
var o = z[tt];
l && o.child != null && o.updateBounds(), A = o.getLeft(), I = o.getRight(), S = o.getTop(), Y = o.getBottom(), p > A && (p = A), g < I && (g = I), c > S && (c = S), T < Y && (T = Y);
}
var m = new e(p, c, g - p, T - c);
p == s.MAX_VALUE && (this.left = this.parent.getLeft(), this.right = this.parent.getRight(), this.top = this.parent.getTop(), this.bottom = this.parent.getBottom()), z[0].getParent().paddingLeft != null ? V = z[0].getParent().paddingLeft : V = this.margin, this.left = m.x - V, this.right = m.x + m.width + V, this.top = m.y - V, this.bottom = m.y + m.height + V;
}, i.calculateBounds = function(l) {
for (var p = s.MAX_VALUE, g = -s.MAX_VALUE, c = s.MAX_VALUE, T = -s.MAX_VALUE, A, I, S, Y, V = l.length, z = 0; z < V; z++) {
var x = l[z];
A = x.getLeft(), I = x.getRight(), S = x.getTop(), Y = x.getBottom(), p > A && (p = A), g < I && (g = I), c > S && (c = S), T < Y && (T = Y);
}
return new e(p, c, g - p, T - c);
}, i.prototype.getInclusionTreeDepth = function() {
return this == this.graphManager.getRoot() ? 1 : this.parent.getInclusionTreeDepth();
}, i.prototype.getEstimatedSize = function() {
if (this.estimatedSize == s.MIN_VALUE) throw "assert failed";
return this.estimatedSize;
}, i.prototype.calcEstimatedSize = function() {
for (var l = 0, p = this.nodes, g = p.length, c = 0; c < g; c++) {
var T = p[c];
l += T.calcEstimatedSize();
}
return l == 0 ? this.estimatedSize = n.EMPTY_COMPOUND_NODE_SIZE : this.estimatedSize = l / Math.sqrt(this.nodes.length), this.estimatedSize;
}, i.prototype.updateConnected = function() {
var l = this;
if (this.nodes.length == 0) {
this.isConnected = !0;
return;
}
var p = new r(), g = /* @__PURE__ */ new Set(), c = this.nodes[0], T, A;
for (c.withChildren().forEach(function(V) {
p.push(V), g.add(V);
}); p.length !== 0; ) {
c = p.shift(), T = c.getEdges();
for (var I = T.length, S = 0; S < I; S++)
A = T[S].getOtherEndInGraph(c, this), A != null && !g.has(A) && A.withChildren().forEach(function(V) {
p.push(V), g.add(V);
});
}
if (this.isConnected = !1, g.size >= this.nodes.length) {
var Y = 0;
g.forEach(function(V) {
V.owner == l && Y++;
}), Y == this.nodes.length && (this.isConnected = !0);
}
}, w.exports = i;
}),
(function(w, U, N) {
"use strict";
var v, s = N(1);
function n(t) {
v = N(6), this.layout = t, this.graphs = [], this.edges = [];
}
n.prototype.addRoot = function() {
var t = this.layout.newGraph(), a = this.layout.newNode(null), h = this.add(t, a);
return this.setRootGraph(h), this.rootGraph;
}, n.prototype.add = function(t, a, h, e, d) {
if (h == null && e == null && d == null) {
if (t == null) throw "Graph is null!";
if (a == null) throw "Parent node is null!";
if (this.graphs.indexOf(t) > -1) throw "Graph already in this graph mgr!";
if (this.graphs.push(t), t.parent != null) throw "Already has a parent!";
if (a.child != null) throw "Already has a child!";
return t.parent = a, a.child = t, t;
} else {
d = h, e = a, h = t;
var r = e.getOwner(), i = d.getOwner();
if (!(r != null && r.getGraphManager() == this)) throw "Source not in this graph mgr!";
if (!(i != null && i.getGraphManager() == this)) throw "Target not in this graph mgr!";
if (r == i)
return h.isInterGraph = !1, r.add(h, e, d);
if (h.isInterGraph = !0, h.source = e, h.target = d, this.edges.indexOf(h) > -1) throw "Edge already in inter-graph edge list!";
if (this.edges.push(h), !(h.source != null && h.target != null)) throw "Edge source and/or target is null!";
if (!(h.source.edges.indexOf(h) == -1 && h.target.edges.indexOf(h) == -1)) throw "Edge already in source and/or target incidency list!";
return h.source.edges.push(h), h.target.edges.push(h), h;
}
}, n.prototype.remove = function(t) {
if (t instanceof v) {
var a = t;
if (a.getGraphManager() != this) throw "Graph not in this graph mgr";
if (!(a == this.rootGraph || a.parent != null && a.parent.graphManager == this)) throw "Invalid parent node!";
var h = [];
h = h.concat(a.getEdges());
for (var e, d = h.length, r = 0; r < d; r++)
e = h[r], a.remove(e);
var i = [];
i = i.concat(a.getNodes());
var f;
d = i.length;
for (var r = 0; r < d; r++)
f = i[r], a.remove(f);
a == this.rootGraph && this.setRootGraph(null);
var l = this.graphs.indexOf(a);
this.graphs.splice(l, 1), a.parent = null;
} else if (t instanceof s) {
if (e = t, e == null) throw "Edge is null!";
if (!e.isInterGraph) throw "Not an inter-graph edge!";
if (!(e.source != null && e.target != null)) throw "Source and/or target is null!";
if (!(e.source.edges.indexOf(e) != -1 && e.target.edges.indexOf(e) != -1)) throw "Source and/or target doesn't know this edge!";
var l = e.source.edges.indexOf(e);
if (e.source.edges.splice(l, 1), l = e.target.edges.indexOf(e), e.target.edges.splice(l, 1), !(e.source.owner != null && e.source.owner.getGraphManager() != null)) throw "Edge owner graph or owner graph manager is null!";
if (e.source.owner.getGraphManager().edges.indexOf(e) == -1) throw "Not in owner graph manager's edge list!";
var l = e.source.owner.getGraphManager().edges.indexOf(e);
e.source.owner.getGraphManager().edges.splice(l, 1);
}
}, n.prototype.updateBounds = function() {
this.rootGraph.updateBounds(!0);
}, n.prototype.getGraphs = function() {
return this.graphs;
}, n.prototype.getAllNodes = function() {
if (this.allNodes == null) {
for (var t = [], a = this.getGraphs(), h = a.length, e = 0; e < h; e++) t = t.concat(a[e].getNodes());
this.allNodes = t;
}
return this.allNodes;
}, n.prototype.resetAllNodes = function() {
this.allNodes = null;
}, n.prototype.resetAllEdges = function() {
this.allEdges = null;
}, n.prototype.resetAllNodesToApplyGravitation = function() {
this.allNodesToApplyGravitation = null;
}, n.prototype.getAllEdges = function() {
if (this.allEdges == null) {
var t = [], a = this.getGraphs();
a.length;
for (var h = 0; h < a.length; h++) t = t.concat(a[h].getEdges());
t = t.concat(this.edges), this.allEdges = t;
}
return this.allEdges;
}, n.prototype.getAllNodesToApplyGravitation = function() {
return this.allNodesToApplyGravitation;
}, n.prototype.setAllNodesToApplyGravitation = function(t) {
if (this.allNodesToApplyGravitation != null) throw "assert failed";
this.allNodesToApplyGravitation = t;
}, n.prototype.getRoot = function() {
return this.rootGraph;
}, n.prototype.setRootGraph = function(t) {
if (t.getGraphManager() != this) throw "Root not in this graph mgr!";
this.rootGraph = t, t.parent == null && (t.parent = this.layout.newNode("Root node"));
}, n.prototype.getLayout = function() {
return this.layout;
}, n.prototype.isOneAncestorOfOther = function(t, a) {
if (!(t != null && a != null)) throw "assert failed";
if (t == a) return !0;
var h = t.getOwner(), e;
do {
if (e = h.getParent(), e == null) break;
if (e == a) return !0;
if (h = e.getOwner(), h == null) break;
} while (!0);
h = a.getOwner();
do {
if (e = h.getParent(), e == null) break;
if (e == t) return !0;
if (h = e.getOwner(), h == null) break;
} while (!0);
return !1;
}, n.prototype.calcLowestCommonAncestors = function() {
for (var t, a, h, e, d, r = this.getAllEdges(), i = r.length, f = 0; f < i; f++) {
if (t = r[f], a = t.source, h = t.target, t.lca = null, t.sourceInLca = a, t.targetInLca = h, a == h) {
t.lca = a.getOwner();
continue;
}
for (e = a.getOwner(); t.lca == null; ) {
for (t.targetInLca = h, d = h.getOwner(); t.lca == null; ) {
if (d == e) {
t.lca = d;
break;
}
if (d == this.rootGraph) break;
if (t.lca != null) throw "assert failed";
t.targetInLca = d.getParent(), d = t.targetInLca.getOwner();
}
if (e == this.rootGraph) break;
t.lca == null && (t.sourceInLca = e.getParent(), e = t.sourceInLca.getOwner());
}
if (t.lca == null) throw "assert failed";
}
}, n.prototype.calcLowestCommonAncestor = function(t, a) {
if (t == a) return t.getOwner();
var h = t.getOwner();
do {
if (h == null) break;
var e = a.getOwner();
do {
if (e == null) break;
if (e == h) return e;
e = e.getParent().getOwner();
} while (!0);
h = h.getParent().getOwner();
} while (!0);
return h;
}, n.prototype.calcInclusionTreeDepths = function(t, a) {
t == null && a == null && (t = this.rootGraph, a = 1);
for (var h, e = t.getNodes(), d = e.length, r = 0; r < d; r++)
h = e[r], h.inclusionTreeDepth = a, h.child != null && this.calcInclusionTreeDepths(h.child, a + 1);
}, n.prototype.includesInvalidEdge = function() {
for (var t, a = [], h = this.edges.length, e = 0; e < h; e++)
t = this.edges[e], this.isOneAncestorOfOther(t.source, t.target) && a.push(t);
for (var e = 0; e < a.length; e++) this.remove(a[e]);
return !1;
}, w.exports = n;
}),
(function(w, U, N) {
"use strict";
var v = N(12);
function s() {
}
s.calcSeparationAmount = function(n, t, a, h) {
if (!n.intersects(t)) throw "assert failed";
var e = new Array(2);
this.decideDirectionsForOverlappingNodes(n, t, e), a[0] = Math.min(n.getRight(), t.getRight()) - Math.max(n.x, t.x), a[1] = Math.min(n.getBottom(), t.getBottom()) - Math.max(n.y, t.y), n.getX() <= t.getX() && n.getRight() >= t.getRight() ? a[0] += Math.min(t.getX() - n.getX(), n.getRight() - t.getRight()) : t.getX() <= n.getX() && t.getRight() >= n.getRight() && (a[0] += Math.min(n.getX() - t.getX(), t.getRight() - n.getRight())), n.getY() <= t.getY() && n.getBottom() >= t.getBottom() ? a[1] += Math.min(t.getY() - n.getY(), n.getBottom() - t.getBottom()) : t.getY() <= n.getY() && t.getBottom() >= n.getBottom() && (a[1] += Math.min(n.getY() - t.getY(), t.getBottom() - n.getBottom()));
var d = Math.abs((t.getCenterY() - n.getCenterY()) / (t.getCenterX() - n.getCenterX()));
t.getCenterY() === n.getCenterY() && t.getCenterX() === n.getCenterX() && (d = 1);
var r = d * a[0], i = a[1] / d;
a[0] < i ? i = a[0] : r = a[1], a[0] = -1 * e[0] * (i / 2 + h), a[1] = -1 * e[1] * (r / 2 + h);
}, s.decideDirectionsForOverlappingNodes = function(n, t, a) {
n.getCenterX() < t.getCenterX() ? a[0] = -1 : a[0] = 1, n.getCenterY() < t.getCenterY() ? a[1] = -1 : a[1] = 1;
}, s.getIntersection2 = function(n, t, a) {
var h = n.getCenterX(), e = n.getCenterY(), d = t.getCenterX(), r = t.getCenterY();
if (n.intersects(t))
return a[0] = h, a[1] = e, a[2] = d, a[3] = r, !0;
var i = n.getX(), f = n.getY(), l = n.getRight(), p = n.getX(), g = n.getBottom(), c = n.getRight(), T = n.getWidthHalf(), A = n.getHeightHalf(), I = t.getX(), S = t.getY(), Y = t.getRight(), V = t.getX(), z = t.getBottom(), x = t.getRight(), tt = t.getWidthHalf(), o = t.getHeightHalf(), m = !1, u = !1;
if (h === d) {
if (e > r)
return a[0] = h, a[1] = f, a[2] = d, a[3] = z, !1;
if (e < r)
return a[0] = h, a[1] = g, a[2] = d, a[3] = S, !1;
} else if (e === r) {
if (h > d)
return a[0] = i, a[1] = e, a[2] = Y, a[3] = r, !1;
if (h < d)
return a[0] = l, a[1] = e, a[2] = I, a[3] = r, !1;
} else {
var E = n.height / n.width, y = t.height / t.width, C = (r - e) / (d - h), M = void 0, G = void 0, O = void 0, R = void 0, W = void 0, B = void 0;
if (-E === C ? h > d ? (a[0] = p, a[1] = g, m = !0) : (a[0] = l, a[1] = f, m = !0) : E === C && (h > d ? (a[0] = i, a[1] = f, m = !0) : (a[0] = c, a[1] = g, m = !0)), -y === C ? d > h ? (a[2] = V, a[3] = z, u = !0) : (a[2] = Y, a[3] = S, u = !0) : y === C && (d > h ? (a[2] = I, a[3] = S, u = !0) : (a[2] = x, a[3] = z, u = !0)), m && u) return !1;
if (h > d ? e > r ? (M = this.getCardinalDirection(E, C, 4), G = this.getCardinalDirection(y, C, 2)) : (M = this.getCardinalDirection(-E, C, 3), G = this.getCardinalDirection(-y, C, 1)) : e > r ? (M = this.getCardinalDirection(-E, C, 1), G = this.getCardinalDirection(-y, C, 3)) : (M = this.getCardinalDirection(E, C, 2), G = this.getCardinalDirection(y, C, 4)), !m) switch (M) {
case 1:
R = f, O = h + -A / C, a[0] = O, a[1] = R;
break;
case 2:
O = c, R = e + T * C, a[0] = O, a[1] = R;
break;
case 3:
R = g, O = h + A / C, a[0] = O, a[1] = R;
break;
case 4:
O = p, R = e + -T * C, a[0] = O, a[1] = R;
break;
}
if (!u) switch (G) {
case 1:
B = S, W = d + -o / C, a[2] = W, a[3] = B;
break;
case 2:
W = x, B = r + tt * C, a[2] = W, a[3] = B;
break;
case 3:
B = z, W = d + o / C, a[2] = W, a[3] = B;
break;
case 4:
W = V, B = r + -tt * C, a[2] = W, a[3] = B;
break;
}
}
return !1;
}, s.getCardinalDirection = function(n, t, a) {
return n > t ? a : 1 + a % 4;
}, s.getIntersection = function(n, t, a, h) {
if (h == null) return this.getIntersection2(n, t, a);
var e = n.x, d = n.y, r = t.x, i = t.y, f = a.x, l = a.y, p = h.x, g = h.y, c = void 0, T = void 0, A = void 0, I = void 0, S = void 0, Y = void 0, V = void 0, z = void 0, x = void 0;
return A = i - d, S = e - r, V = r * d - e * i, I = g - l, Y = f - p, z = p * l - f * g, x = A * Y - I * S, x === 0 ? null : (c = (S * z - Y * V) / x, T = (I * V - A * z) / x, new v(c, T));
}, s.angleOfVector = function(n, t, a, h) {
var e = void 0;
return n !== a ? (e = Math.atan((h - t) / (a - n)), a < n ? e += Math.PI : h < t && (e += this.TWO_PI)) : h < t ? e = this.ONE_AND_HALF_PI : e = this.HALF_PI, e;
}, s.doIntersect = function(n, t, a, h) {
var e = n.x, d = n.y, r = t.x, i = t.y, f = a.x, l = a.y, p = h.x, g = h.y, c = (r - e) * (g - l) - (p - f) * (i - d);
if (c === 0) return !1;
var T = ((g - l) * (p - e) + (f - p) * (g - d)) / c, A = ((d - i) * (p - e) + (r - e) * (g - d)) / c;
return 0 < T && T < 1 && 0 < A && A < 1;
}, s.findCircleLineIntersections = function(n, t, a, h, e, d, r) {
var i = (a - n) * (a - n) + (h - t) * (h - t), f = 2 * ((n - e) * (a - n) + (t - d) * (h - t)), l = (n - e) * (n - e) + (t - d) * (t - d) - r * r;
if (f * f - 4 * i * l >= 0) {
var p = (-f + Math.sqrt(f * f - 4 * i * l)) / (2 * i), g = (-f - Math.sqrt(f * f - 4 * i * l)) / (2 * i), c = null;
return p >= 0 && p <= 1 ? [p] : g >= 0 && g <= 1 ? [g] : c;
} else return null;
}, s.HALF_PI = 0.5 * Math.PI, s.ONE_AND_HALF_PI = 1.5 * Math.PI, s.TWO_PI = 2 * Math.PI, s.THREE_PI = 3 * Math.PI, w.exports = s;
}),
(function(w, U, N) {
"use strict";
function v() {
}
v.sign = function(s) {
return s > 0 ? 1 : s < 0 ? -1 : 0;
}, v.floor = function(s) {
return s < 0 ? Math.ceil(s) : Math.floor(s);
}, v.ceil = function(s) {
return s < 0 ? Math.floor(s) : Math.ceil(s);
}, w.exports = v;
}),
(function(w, U, N) {
"use strict";
function v() {
}
v.MAX_VALUE = 2147483647, v.MIN_VALUE = -2147483648, w.exports = v;
}),
(function(w, U, N) {
"use strict";
var v = /* @__PURE__ */ (function() {
function h(e, d) {
for (var r = 0; r < d.length; r++) {
var i = d[r];
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i);
}
}
return function(e, d, r) {
return d && h(e.prototype, d), r && h(e, r), e;
};
})();
function s(h, e) {
if (!(h instanceof e)) throw new TypeError("Cannot call a class as a function");
}
var n = function(e) {
return {
value: e,
next: null,
prev: null
};
}, t = function(e, d, r, i) {
return e !== null ? e.next = d : i.head = d, r !== null ? r.prev = d : i.tail = d, d.prev = e, d.next = r, i.length++, d;
}, a = function(e, d) {
var r = e.prev, i = e.next;
return r !== null ? r.next = i : d.head = i, i !== null ? i.prev = r : d.tail = r, e.prev = e.next = null, d.length--, e;
};
w.exports = (function() {
function h(e) {
var d = this;
s(this, h), this.length = 0, this.head = null, this.tail = null, e?.forEach(function(r) {
return d.push(r);
});
}
return v(h, [
{
key: "size",
value: function() {
return this.length;
}
},
{
key: "insertBefore",
value: function(d, r) {
return t(r.prev, n(d), r, this);
}
},
{
key: "insertAfter",
value: function(d, r) {
return t(r, n(d), r.next, this);
}
},
{
key: "insertNodeBefore",
value: function(d, r) {
return t(r.prev, d, r, this);
}
},
{
key: "insertNodeAfter",
value: function(d, r) {
return t(r, d, r.next, this);
}
},
{
key: "push",
value: function(d) {
return t(this.tail, n(d), null, this);
}
},
{
key: "unshift",
value: function(d) {
return t(null, n(d), this.head, this);
}
},
{
key: "remove",
value: function(d) {
return a(d, this);
}
},
{
key: "pop",
value: function() {
return a(this.tail, this).value;
}
},
{
key: "popNode",
value: function() {
return a(this.tail, this);
}
},
{
key: "shift",
value: function() {
return a(this.head, this).value;
}
},
{
key: "shiftNode",
value: function() {
return a(this.head, this);
}
},
{
key: "get_object_at",
value: function(d) {
if (d <= this.length()) {
for (var r = 1, i = this.head; r < d; )
i = i.next, r++;
return i.value;
}
}
},
{
key: "set_object_at",
value: function(d, r) {
if (d <= this.length()) {
for (var i = 1, f = this.head; i < d; )
f = f.next, i++;
f.value = r;
}
}
}
]), h;
})();
}),
(function(w, U, N) {
"use strict";
function v(s, n, t) {
this.x = null, this.y = null, s == null && n == null && t == null ? (this.x = 0, this.y = 0) : typeof s == "number" && typeof n == "number" && t == null ? (this.x = s, this.y = n) : s.constructor.name == "Point" && n == null && t == null && (t = s, this.x = t.x, this.y = t.y);
}
v.prototype.getX = function() {
return this.x;
}, v.prototype.getY = function() {
return this.y;
}, v.prototype.getLocation = function() {
return new v(this.x, this.y);
}, v.prototype.setLocation = function(s, n, t) {
s.constructor.name == "Point" && n == null && t == null ? (t = s, this.setLocation(t.x, t.y)) : typeof s == "number" && typeof n == "number" && t == null && (parseInt(s) == s && parseInt(n) == n ? this.move(s, n) : (this.x = Math.floor(s + 0.5), this.y = Math.floor(n + 0.5)));
}, v.prototype.move = function(s, n) {
this.x = s, this.y = n;
}, v.prototype.translate = function(s, n) {
this.x += s, this.y += n;
}, v.prototype.equals = function(s) {
if (s.constructor.name == "Point") {
var n = s;
return this.x == n.x && this.y == n.y;
}
return this == s;
}, v.prototype.toString = function() {
return new v().constructor.name + "[x=" + this.x + ",y=" + this.y + "]";
}, w.exports = v;
}),
(function(w, U, N) {
"use strict";
function v(s, n, t, a) {
this.x = 0, this.y = 0, this.width = 0, this.height = 0, s != null && n != null && t != null && a != null && (this.x = s, this.y = n, this.width = t, this.height = a);
}
v.prototype.getX = function() {
return this.x;
}, v.prototype.setX = function(s) {
this.x = s;
}, v.prototype.getY = function() {
return this.y;
}, v.prototype.setY = function(s) {
this.y = s;
}, v.prototype.getWidth = function() {
return this.width;
}, v.prototype.setWidth = function(s) {
this.width = s;
}, v.prototype.getHeight = function() {
return this.height;
}, v.prototype.setHeight = function(s) {
this.height = s;
}, v.prototype.getRight = function() {
return this.x + this.width;
}, v.prototype.getBottom = function() {
return this.y + this.height;
}, v.prototype.intersects = function(s) {
return !(this.getRight() < s.x || this.getBottom() < s.y || s.getRight() < this.x || s.getBottom() < this.y);
}, v.prototype.getCenterX = function() {
return this.x + this.width / 2;
}, v.prototype.getMinX = function() {
return this.getX();
}, v.prototype.getMaxX = function() {
return this.getX() + this.width;
}, v.prototype.getCenterY = function() {
return this.y + this.height / 2;
}, v.prototype.getMinY = function() {
return this.getY();
}, v.prototype.getMaxY = function() {
return this.getY() + this.height;
}, v.prototype.getWidthHalf = function() {
return this.width / 2;
}, v.prototype.getHeightHalf = function() {
return this.height / 2;
}, w.exports = v;
}),
(function(w, U, N) {
"use strict";
var v = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
return typeof n;
} : function(n) {
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
};
function s() {
}
s.lastID = 0, s.createID = function(n) {
return s.isPrimitive(n) ? n : (n.uniqueID != null || (n.uniqueID = s.getString(), s.lastID++), n.uniqueID);
}, s.getString = function(n) {
return n == null && (n = s.lastID), "Object#" + n;
}, s.isPrimitive = function(n) {
var t = typeof n > "u" ? "undefined" : v(n);
return n == null || t != "object" && t != "function";
}, w.exports = s;
}),
(function(w, U, N) {
"use strict";
function v(f) {
if (Array.isArray(f)) {
for (var l = 0, p = Array(f.length); l < f.length; l++) p[l] = f[l];
return p;
} else return Array.from(f);
}
var s = N(0), n = N(7), t = N(3), a = N(1), h = N(6), e = N(5), d = N(17), r = N(29);
function i(f) {
r.call(this), this.layoutQuality = s.QUALITY, this.createBendsAsNeeded = s.DEFAULT_CREATE_BENDS_AS_NEEDED, this.incremental = s.DEFAULT_INCREMENTAL, this.animationOnLayout = s.DEFAULT_ANIMATION_ON_LAYOUT, this.animationDuringLayout = s.DEFAULT_ANIMATION_DURING_LAYOUT, this.animationPeriod = s.DEFAULT_ANIMATION_PERIOD, this.uniformLeafNodeSizes = s.DEFAULT_UNIFORM_LEAF_NODE_SIZES, this.edgeToDummyNodes = /* @__PURE__ */ new Map(), this.graphManager = new n(this), this.isLayoutFinished = !1, this.isSubLayout = !1, this.isRemoteUse = !1, f != null && (this.isRemoteUse = f);
}
i.RANDOM_SEED = 1, i.prototype = Object.create(r.prototype), i.prototype.getGraphManager = function() {
return this.graphManager;
}, i.prototype.getAllNodes = function() {
return this.graphManager.getAllNodes();
}, i.prototype.getAllEdges = function() {
return this.graphManager.getAllEdges();
}, i.prototype.getAllNodesToApplyGravitation = function() {
return this.graphManager.getAllNodesToApplyGravitation();
}, i.prototype.newGraphManager = function() {
var f = new n(this);
return this.graphManager = f, f;
}, i.prototype.newGraph = function(f) {
return new h(null, this.graphManager, f);
}, i.prototype.newNode = function(f) {
return new t(this.graphManager, f);
}, i.prototype.newEdge = function(f) {
return new a(null, null, f);
}, i.prototype.checkLayoutSuccess = function() {
return this.graphManager.getRoot() == null || this.graphManager.getRoot().getNodes().length == 0 || this.graphManager.includesInvalidEdge();
}, i.prototype.runLayout = function() {
this.isLayoutFinished = !1, this.tilingPreLayout && this.tilingPreLayout(), this.initParameters();
var f;
return this.checkLayoutSuccess() ? f = !1 : f = this.layout(), s.ANIMATE === "during" ? !1 : (f && (this.isSubLayout || this.doPostLayout()), this.tilingPostLayout && this.tilingPostLayout(), this.isLayoutFinished = !0, f);
}, i.prototype.doPostLayout = function() {
this.incremental || this.transform(), this.update();
}, i.prototype.update2 = function() {
if (this.createBendsAsNeeded && (this.createBendpointsFromDummyNodes(), this.graphManager.resetAllEdges()), !this.isRemoteUse) {
for (var f = this.graphManager.getAllEdges(), l = 0; l < f.length; l++) f[l];
for (var p = this.graphManager.getRoot().getNodes(), l = 0; l < p.length; l++) p[l];
this.update(this.graphManager.getRoot());
}
}, i.prototype.update = function(f) {
if (f == null) this.update2();
else if (f instanceof t) {
var l = f;
if (l.getChild() != null)
for (var p = l.getChild().getNodes(), g = 0; g < p.length; g++) update(p[g]);
l.vGraphObject != null && l.vGraphObject.update(l);
} else if (f instanceof a) {
var c = f;
c.vGraphObject != null && c.vGraphObject.update(c);
} else if (f instanceof h) {
var T = f;
T.vGraphObject != null && T.vGraphObject.update(T);
}
}, i.prototype.initParameters = function() {
this.isSubLayout || (this.layoutQuality = s.QUALITY, this.animationDuringLayout = s.DEFAULT_ANIMATION_DURING_LAYOUT, this.animationPeriod = s.DEFAULT_ANIMATION_PERIOD, this.animationOnLayout = s.DEFAULT_ANIMATION_ON_LAYOUT, this.incremental = s.DEFAULT_INCREMENTAL, this.createBendsAsNeeded = s.DEFAULT_CREATE_BENDS_AS_NEEDED, this.uniformLeafNodeSizes = s.DEFAULT_UNIFORM_LEAF_NODE_SIZES), this.animationDuringLayout && (this.animationOnLayout = !1);
}, i.prototype.transform = function(f) {
if (f == null) this.transform(new e(0, 0));
else {
var l = new d(), p = this.graphManager.getRoot().updateLeftTop();
if (p != null) {
l.setWorldOrgX(f.x), l.setWorldOrgY(f.y), l.setDeviceOrgX(p.x), l.setDeviceOrgY(p.y);
for (var g = this.getAllNodes(), c, T = 0; T < g.length; T++)
c = g[T], c.transform(l);
}
}
}, i.prototype.positionNodesRandomly = function(f) {
if (f == null)
this.positionNodesRandomly(this.getGraphManager().getRoot()), this.getGraphManager().getRoot().updateBounds(!0);
else
for (var l, p, g = f.getNodes(), c = 0; c < g.length; c++)
l = g[c], p = l.getChild(), p == null || p.getNodes().length == 0 ? l.scatter() : (this.positionNodesRandomly(p), l.updateBounds());
}, i.prototype.getFlatForest = function() {
for (var f = [], l = !0, p = this.graphManager.getRoot().getNodes(), g = !0, c = 0; c < p.length; c++) p[c].getChild() != null && (g = !1);
if (!g) return f;
var T = /* @__PURE__ */ new Set(), A = [], I = /* @__PURE__ */ new Map(), S = [];
for (S = S.concat(p); S.length > 0 && l; ) {
for (A.push(S[0]); A.length > 0 && l; ) {
var Y = A[0];
A.splice(0, 1), T.add(Y);
for (var V = Y.getEdges(), c = 0; c < V.length; c++) {
var z = V[c].getOtherEnd(Y);
if (I.get(Y) != z) if (!T.has(z))
A.push(z), I.set(z, Y);
else {
l = !1;
break;
}
}
}
if (!l) f = [];
else {
var x = [].concat(v(T));
f.push(x);
for (var c = 0; c < x.length; c++) {
var tt = x[c], o = S.indexOf(tt);
o > -1 && S.splice(o, 1);
}
T = /* @__PURE__ */ new Set(), I = /* @__PURE__ */ new Map();
}
}
return f;
}, i.prototype.createDummyNodesForBendpoints = function(f) {
for (var l = [], p = f.source, g = this.graphManager.calcLowestCommonAncestor(f.source, f.target), c = 0; c < f.bendpoints.length; c++) {
var T = this.newNode(null);
T.setRect(new Point(0, 0), new Dimension(1, 1)), g.add(T);
var A = this.newEdge(null);
this.graphManager.add(A, p, T), l.add(T), p = T;
}
var A = this.newEdge(null);
return this.graphManager.add(A, p, f.target), this.edgeToDummyNodes.set(f, l), f.isInterGraph() ? this.graphManager.remove(f) : g.remove(f), l;
}, i.prototype.createBendpointsFromDummyNodes = function() {
var f = [];
f = f.concat(this.graphManager.getAllEdges()), f = [].concat(v(this.edgeToDummyNodes.keys())).concat(f);
for (var l = 0; l < f.length; l++) {
var p = f[l];
if (p.bendpoints.length > 0) {
for (var g = this.edgeToDummyNodes.get(p), c = 0; c < g.length; c++) {
var T = g[c], A = new e(T.getCenterX(), T.getCenterY()), I = p.bendpoints.get(c);
I.x = A.x, I.y = A.y, T.getOwner().remove(T);
}
this.graphManager.add(p, p.source, p.target);
}
}
}, i.transform = function(f, l, p, g) {
if (p != null && g != null) {
var c = l;
if (f <= 50) {
var T = l / p;
c -= (l - T) / 50 * (50 - f);
} else {
var A = l * g;
c += (A - l) / 50 * (f - 50);
}
return c;
} else {
var I, S;
return f <= 50 ? (I = 9 * l / 500, S = l / 10) : (I = 9 * l / 50, S = -8 * l), I * f + S;
}
}, i.findCenterOfTree = function(f) {
var l = [];
l = l.concat(f);
var p = [], g = /* @__PURE__ */ new Map(), c = !1, T = null;
(l.length == 1 || l.length == 2) && (c = !0, T = l[0]);
for (var A = 0; A < l.length; A++) {
var I = l[A], S = I.getNeighborsList().size;
g.set(I, I.getNeighborsList().size), S == 1 && p.push(I);
}
var Y = [];
for (Y = Y.concat(p); !c; ) {
var V = [];
V = V.concat(Y), Y = [];
for (var A = 0; A < l.length; A++) {
var I = l[A], z = l.indexOf(I);
z >= 0 && l.splice(z, 1), I.getNeighborsList().forEach(function(o) {
if (p.indexOf(o) < 0) {
var m = g.get(o) - 1;
m == 1 && Y.push(o), g.set(o, m);
}
});
}
p = p.concat(Y), (l.length == 1 || l.length == 2) && (c = !0, T = l[0]);
}
return T;
}, i.prototype.setGraphManager = function(f) {
this.graphManager = f;
}, w.exports = i;
}),
(function(w, U, N) {
"use strict";
function v() {
}
v.seed = 1, v.x = 0, v.nextDouble = function() {
return v.x = Math.sin(v.seed++) * 1e4, v.x - Math.floor(v.x);
}, w.exports = v;
}),
(function(w, U, N) {
"use strict";
var v = N(5);
function s(n, t) {
this.lworldOrgX = 0, this.lworldOrgY = 0, this.ldeviceOrgX = 0, this.ldeviceOrgY = 0, this.lworldExtX = 1, this.lworldExtY = 1, this.ldeviceExtX = 1, this.ldeviceExtY = 1;
}
s.prototype.getWorldOrgX = function() {
return this.lworldOrgX;
}, s.prototype.setWorldOrgX = function(n) {
this.lworldOrgX = n;
}, s.prototype.getWorldOrgY = function() {
return this.lworldOrgY;
}, s.prototype.setWorldOrgY = function(n) {
this.lworldOrgY = n;
}, s.prototype.getWorldExtX = function() {
return this.lworldExtX;
}, s.prototype.setWorldExtX = function(n) {
this.lworldExtX = n;
}, s.prototype.getWorldExtY = function() {
return this.lworldExtY;
}, s.prototype.setWorldExtY = function(n) {
this.lworldExtY = n;
}, s.prototype.getDeviceOrgX = function() {
return this.ldeviceOrgX;
}, s.prototype.setDeviceOrgX = function(n) {
this.ldeviceOrgX = n;
}, s.prototype.getDeviceOrgY = function() {
return this.ldeviceOrgY;
}, s.prototype.setDeviceOrgY = function(n) {
this.ldeviceOrgY = n;
}, s.prototype.getDeviceExtX = function() {
return this.ldeviceExtX;
}, s.prototype.setDeviceExtX = function(n) {
this.ldeviceExtX = n;
}, s.prototype.getDeviceExtY = function() {
return this.ldeviceExtY;
}, s.prototype.setDeviceExtY = function(n) {
this.ldeviceExtY = n;
}, s.prototype.transformX = function(n) {
var t = 0, a = this.lworldExtX;
return a != 0 && (t = this.ldeviceOrgX + (n - this.lworldOrgX) * this.ldeviceExtX / a), t;
}, s.prototype.transformY = function(n) {
var t = 0, a = this.lworldExtY;
return a != 0 && (t = this.ldeviceOrgY + (n - this.lworldOrgY) * this.ldeviceExtY / a), t;
}, s.prototype.inverseTransformX = function(n) {
var t = 0, a = this.ldeviceExtX;
return a != 0 && (t = this.lworldOrgX + (n - this.ldeviceOrgX) * this.lworldExtX / a), t;
}, s.prototype.inverseTransformY = function(n) {
var t = 0, a = this.ldeviceExtY;
return a != 0 && (t = this.lworldOrgY + (n - this.ldeviceOrgY) * this.lworldExtY / a), t;
}, s.prototype.inverseTransformPoint = function(n) {
return new v(this.inverseTransformX(n.x), this.inverseTransformY(n.y));
}, w.exports = s;
}),
(function(w, U, N) {
"use strict";
function v(r) {
if (Array.isArray(r)) {
for (var i = 0, f = Array(r.length); i < r.length; i++) f[i] = r[i];
return f;
} else return Array.from(r);
}
var s = N(15), n = N(4), t = N(0), a = N(8), h = N(9);
function e() {
s.call(this), this.useSmartIdealEdgeLengthCalculation = n.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION, this.gravityConstant = n.DEFAULT_GRAVITY_STRENGTH, this.compoundGravityConstant = n.DEFAULT_COMPOUND_GRAVITY_STRENGTH, this.gravityRangeFactor = n.DEFAULT_GRAVITY_RANGE_FACTOR, this.compoundGravityRangeFactor = n.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR, this.displacementThresholdPerNode = 3 * n.DEFAULT_EDGE_LENGTH / 100, this.coolingFactor = n.DEFAULT_COOLING_FACTOR_INCREMENTAL, this.initialCoolingFactor = n.DEFAULT_COOLING_FACTOR_INCREMENTAL, this.totalDisplacement = 0, this.oldTotalDisplacement = 0, this.maxIterations = n.MAX_ITERATIONS;
}
e.prototype = Object.create(s.prototype);
for (var d in s) e[d] = s[d];
e.prototype.initParameters = function() {
s.prototype.initParameters.call(this, arguments), this.totalIterations = 0, this.notAnimatedIterations = 0, this.useFRGridVariant = n.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION, this.grid = [];
}, e.prototype.calcIdealEdgeLengths = function() {
for (var r, i, f, l, p, g, c, T = this.getGraphManager().getAllEdges(), A = 0; A < T.length; A++)
r = T[A], i = r.idealLength, r.isInterGraph && (l = r.getSource(), p = r.getTarget(), g = r.getSourceInLca().getEstimatedSize(), c = r.getTargetInLca().getEstimatedSize(), this.useSmartIdealEdgeLengthCalculation && (r.idealLength += g + c - 2 * t.SIMPLE_NODE_SIZE), f = r.getLca().getInclusionTreeDepth(), r.idealLength += i * n.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR * (l.getInclusionTreeDepth() + p.getInclusionTreeDepth() - 2 * f));
}, e.prototype.initSpringEmbedder = function() {
var r = this.getAllNodes().length;
this.incremental ? (r > n.ADAPTATION_LOWER_NODE_LIMIT && (this.coolingFactor = Math.max(this.coolingFactor * n.COOLING_ADAPTATION_FACTOR, this.coolingFactor - (r - n.ADAPTATION_LOWER_NODE_LIMIT) / (n.ADAPTATION_UPPER_NODE_LIMIT - n.ADAPTATION_LOWER_NODE_LIMIT) * this.coolingFactor * (1 - n.COOLING_ADAPTATION_FACTOR))), this.maxNodeDisplacement = n.MAX_NODE_DISPLACEMENT_INCREMENTAL) : (r > n.ADAPTATION_LOWER_NODE_LIMIT ? this.coolingFactor = Math.max(n.COOLING_ADAPTATION_FACTOR, 1 - (r - n.ADAPTATION_LOWER_NODE_LIMIT) / (n.ADAPTATION_UPPER_NODE_LIMIT - n.ADAPTATION_LOWER_NODE_LIMIT) * (1 - n.COOLING_ADAPTATION_FACTOR)) : this.coolingFactor = 1, this.initialCoolingFactor = this.coolingFactor, this.maxNodeDisplacement = n.MAX_NODE_DISPLACEMENT), this.maxIterations = Math.max(this.getAllNodes().length * 5, this.maxIterations), this.displacementThresholdPerNode = 3 * n.DEFAULT_EDGE_LENGTH / 100, this.totalDisplacementThreshold = this.displacementThresholdPerNode * this.getAllNodes().length, this.repulsionRange = this.calcRepulsionRange();
}, e.prototype.calcSpringForces = function() {
for (var r = this.getAllEdges(), i, f = 0; f < r.length; f++)
i = r[f], this.calcSpringForce(i, i.idealLength);
}, e.prototype.calcRepulsionForces = function() {
var r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !0, i = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1, f, l, p, g, c = this.getAllNodes(), T;
if (this.useFRGridVariant)
for (this.totalIterations % n.GRID_CALCULATION_CHECK_PERIOD == 1 && r && this.updateGrid(), T = /* @__PURE__ */ new Set(), f = 0; f < c.length; f++)
p = c[f], this.calculateRepulsionForceOfANode(p, T, r, i), T.add(p);
else for (f = 0; f < c.length; f++)
for (p = c[f], l = f + 1; l < c.length; l++)
g = c[l], p.getOwner() == g.getOwner() && this.calcRepulsionForce(p, g);
}, e.prototype.calcGravitationalForces = function() {
for (var r, i = this.getAllNodesToApplyGravitation(), f = 0; f < i.length; f++)
r = i[f], this.calcGravitationalForce(r);
}, e.prototype.moveNodes = function() {
for (var r = this.getAllNodes(), i, f = 0; f < r.length; f++)
i = r[f], i.move();
}, e.prototype.calcSpringForce = function(r, i) {
var f = r.getSource(), l = r.getTarget(), p, g, c, T;
if (this.uniformLeafNodeSizes && f.getChild() == null && l.getChild() == null) r.updateLengthSimple();
else if (r.updateLength(), r.isOverlapingSourceAndTarget) return;
p = r.getLength(), p != 0 && (g = r.edgeElasticity * (p - i), c = g * (r.lengthX / p), T = g * (r.lengthY / p), f.springForceX += c, f.springForceY += T, l.springForceX -= c, l.springForceY -= T);
}, e.prototype.calcRepulsionForce = function(r, i) {
var f = r.getRect(), l = i.getRect(), p = new Array(2), g = new Array(4), c, T, A, I, S, Y, V;
if (f.intersects(l)) {
a.calcSeparationAmount(f, l, p, n.DEFAULT_EDGE_LENGTH / 2), Y = 2 * p[0], V = 2 * p[1];
var z = r.noOfChildren * i.noOfChildren / (r.noOfChildren + i.noOfChildren);
r.repulsionForceX -= z * Y, r.repulsionForceY -= z * V, i.repulsionForceX += z * Y, i.repulsionForceY += z * V;
} else
this.uniformLeafNodeSizes && r.getChild() == null && i.getChild() == null ? (c = l.getCenterX() - f.getCenterX(), T = l.getCenterY() - f.getCenterY()) : (a.getIntersection(f, l, g), c = g[2] - g[0], T = g[3] - g[1]), Math.abs(c) < n.MIN_REPULSION_DIST && (c = h.sign(c) * n.MIN_REPULSION_DIST), Math.abs(T) < n.MIN_REPULSION_DIST && (T = h.sign(T) * n.MIN_REPULSION_DIST), A = c * c + T * T, I = Math.sqrt(A), S = (r.nodeRepulsion / 2 + i.nodeRepulsion / 2) * r.noOfChildren * i.noOfChildren / A, Y = S * c / I, V = S * T / I, r.repulsionForceX -= Y, r.repulsionForceY -= V, i.repulsionForceX += Y, i.repulsionForceY += V;
}, e.prototype.calcGravitationalForce = function(r) {
var i, f, l, p, g, c, T, A;
i = r.getOwner(), f = (i.getRight() + i.getLeft()) / 2, l = (i.getTop() + i.getBottom()) / 2, p = r.getCenterX() - f, g = r.getCenterY() - l, c = Math.abs(p) + r.getWidth() / 2, T = Math.abs(g) + r.getHeight() / 2, r.getOwner() == this.graphManager.getRoot() ? (A = i.getEstimatedSize() * this.gravityRangeFactor, (c > A || T > A) && (r.gravitationForceX = -this.gravityConstant * p, r.gravitationForceY = -this.gravityConstant * g)) : (A = i.getEstimatedSize() * this.compoundGravityRangeFactor, (c > A || T > A) && (r.gravitationForceX = -this.gravityConstant * p * this.compoundGravityConstant, r.gravitationForceY = -this.gravityConstant * g * this.compoundGravityConstant));
}, e.prototype.isConverged = function() {
var r, i = !1;
return this.totalIterations > this.maxIterations / 3 && (i = Math.abs(this.totalDisplacement - this.oldTotalDisplacement) < 2), r = this.totalDisplacement < this.totalDisplacementThreshold, this.oldTotalDisplacement = this.totalDisplacement, r || i;
}, e.prototype.animate = function() {
this.animationDuringLayout && !this.isSubLayout && (this.notAnimatedIterations == this.animationPeriod ? (this.update(), this.notAnimatedIterations = 0) : this.notAnimatedIterations++);
}, e.prototype.calcNoOfChildrenForAllNodes = function() {
for (var r, i = this.graphManager.getAllNodes(), f = 0; f < i.length; f++)
r = i[f], r.noOfChildren = r.getNoOfChildren();
}, e.prototype.calcGrid = function(r) {
var i = 0, f = 0;
i = parseInt(Math.ceil((r.getRight() - r.getLeft()) / this.repulsionRange)), f = parseInt(Math.ceil((r.getBottom() - r.getTop()) / this.repulsionRange));
for (var l = new Array(i), p = 0; p < i; p++) l[p] = new Array(f);
for (var p = 0; p < i; p++) for (var g = 0; g < f; g++) l[p][g] = new Array();
return l;
}, e.prototype.addNodeToGrid = function(r, i, f) {
var l = 0, p = 0, g = 0, c = 0;
l = parseInt(Math.floor((r.getRect().x - i) / this.repulsionRange)), p = parseInt(Math.floor((r.getRect().width + r.getRect().x - i) / this.repulsionRange)), g = parseInt(Math.floor((r.getRect().y - f) / this.repulsionRange)), c = parseInt(Math.floor((r.getRect().height + r.getRect().y - f) / this.repulsionRange));
for (var T = l; T <= p; T++) for (var A = g; A <= c; A++)
this.grid[T][A].push(r), r.setGridCoordinates(l, p, g, c);
}, e.prototype.updateGrid = function() {
var r, i, f = this.getAllNodes();
for (this.grid = this.calcGrid(this.graphManager.getRoot()), r = 0; r < f.length; r++)
i = f[r], this.addNodeToGrid(i, this.graphManager.getRoot().getLeft(), this.graphManager.getRoot().getTop());
}, e.prototype.calculateRepulsionForceOfANode = function(r, i, f, l) {
if (this.totalIterations % n.GRID_CALCULATION_CHECK_PERIOD == 1 && f || l) {
var p = /* @__PURE__ */ new Set();
r.surrounding = new Array();
for (var g, c = this.grid, T = r.startX - 1; T < r.finishX + 2; T++) for (var A = r.startY - 1; A < r.finishY + 2; A++) if (!(T < 0 || A < 0 || T >= c.length || A >= c[0].length)) {
for (var I = 0; I < c[T][A].length; I++)
if (g = c[T][A][I], !(r.getOwner() != g.getOwner() || r == g) && !i.has(g) && !p.has(g)) {
var S = Math.abs(r.getCenterX() - g.getCenterX()) - (r.getWidth() / 2 + g.getWidth() / 2), Y = Math.abs(r.getCenterY() - g.getCenterY()) - (r.getHeight() / 2 + g.getHeight() / 2);
S <= this.repulsionRange && Y <= this.repulsionRange && p.add(g);
}
}
r.surrounding = [].concat(v(p));
}
for (T = 0; T < r.surrounding.length; T++) this.calcRepulsionForce(r, r.surrounding[T]);
}, e.prototype.calcRepulsionRange = function() {
return 0;
}, w.exports = e;
}),
(function(w, U, N) {
"use strict";
var v = N(1), s = N(4);
function n(a, h, e) {
v.call(this, a, h, e), this.idealLength = s.DEFAULT_EDGE_LENGTH, this.edgeElasticity = s.DEFAULT_SPRING_STRENGTH;
}
n.prototype = Object.create(v.prototype);
for (var t in v) n[t] = v[t];
w.exports = n;
}),
(function(w, U, N) {
"use strict";
var v = N(3), s = N(4);
function n(a, h, e, d) {
v.call(this, a, h, e, d), this.nodeRepulsion = s.DEFAULT_REPULSION_STRENGTH, this.springForceX = 0, this.springForceY = 0, this.repulsionForceX = 0, this.repulsionForceY = 0, this.gravitationForceX = 0, this.gravitationForceY = 0, this.displacementX = 0, this.displacementY = 0, this.startX = 0, this.finishX = 0, this.startY = 0, this.finishY = 0, this.surrounding = [];
}
n.prototype = Object.create(v.prototype);
for (var t in v) n[t] = v[t];
n.prototype.setGridCoordinates = function(a, h, e, d) {
this.startX = a, this.finishX = h, this.startY = e, this.finishY = d;
}, w.exports = n;
}),
(function(w, U, N) {
"use strict";
function v(s, n) {
this.width = 0, this.height = 0, s !== null && n !== null && (this.height = n, this.width = s);
}
v.prototype.getWidth = function() {
return this.width;
}, v.prototype.setWidth = function(s) {
this.width = s;
}, v.prototype.getHeight = function() {
return this.height;
}, v.prototype.setHeight = function(s) {
this.height = s;
}, w.exports = v;
}),
(function(w, U, N) {
"use strict";
var v = N(14);
function s() {
this.map = {}, this.keys = [];
}
s.prototype.put = function(n, t) {
var a = v.createID(n);
this.contains(a) || (this.map[a] = t, this.keys.push(n));
}, s.prototype.contains = function(n) {
return v.createID(n), this.map[n] != null;
}, s.prototype.get = function(n) {
var t = v.createID(n);
return this.map[t];
}, s.prototype.keySet = function() {
return this.keys;
}, w.exports = s;
}),
(function(w, U, N) {
"use strict";
var v = N(14);
function s() {
this.set = {};
}
s.prototype.add = function(n) {
var t = v.createID(n);
this.contains(t) || (this.set[t] = n);
}, s.prototype.remove = function(n) {
delete this.set[v.createID(n)];
}, s.prototype.clear = function() {
this.set = {};
}, s.prototype.contains = function(n) {
return this.set[v.createID(n)] == n;
}, s.prototype.isEmpty = function() {
return this.size() === 0;
}, s.prototype.size = function() {
return Object.keys(this.set).length;
}, s.prototype.addAllTo = function(n) {
for (var t = Object.keys(this.set), a = t.length, h = 0; h < a; h++) n.push(this.set[t[h]]);
}, s.prototype.size = function() {
return Object.keys(this.set).length;
}, s.prototype.addAll = function(n) {
for (var t = n.length, a = 0; a < t; a++) {
var h = n[a];
this.add(h);
}
}, w.exports = s;
}),
(function(w, U, N) {
"use strict";
function v() {
}
v.multMat = function(s, n) {
for (var t = [], a = 0; a < s.length; a++) {
t[a] = [];
for (var h = 0; h < n[0].length; h++) {
t[a][h] = 0;
for (var e = 0; e < s[0].length; e++) t[a][h] += s[a][e] * n[e][h];
}
}
return t;
}, v.transpose = function(s) {
for (var n = [], t = 0; t < s[0].length; t++) {
n[t] = [];
for (var a = 0; a < s.length; a++) n[t][a] = s[a][t];
}
return n;
}, v.multCons = function(s, n) {
for (var t = [], a = 0; a < s.length; a++) t[a] = s[a] * n;
return t;
}, v.minusOp = function(s, n) {
for (var t = [], a = 0; a < s.length; a++) t[a] = s[a] - n[a];
return t;
}, v.dotProduct = function(s, n) {
for (var t = 0, a = 0; a < s.length; a++) t += s[a] * n[a];
return t;
}, v.mag = function(s) {
return Math.sqrt(this.dotProduct(s, s));
}, v.normalize = function(s) {
for (var n = [], t = this.mag(s), a = 0; a < s.length; a++) n[a] = s[a] / t;
return n;
}, v.multGamma = function(s) {
for (var n = [], t = 0, a = 0; a < s.length; a++) t += s[a];
t *= -1 / s.length;
for (var h = 0; h < s.length; h++) n[h] = t + s[h];
return n;
}, v.multL = function(s, n, t) {
for (var a = [], h = [], e = [], d = 0; d < n[0].length; d++) {
for (var r = 0, i = 0; i < n.length; i++) r += -0.5 * n[i][d] * s[i];
h[d] = r;
}
for (var f = 0; f < t.length; f++) {
for (var l = 0, p = 0; p < t.length; p++) l += t[f][p] * h[p];
e[f] = l;
}
for (var g = 0; g < n.length; g++) {
for (var c = 0, T = 0; T < n[0].length; T++) c += n[g][T] * e[T];
a[g] = c;
}
return a;
}, w.exports = v;
}),
(function(w, U, N) {
"use strict";
var v = /* @__PURE__ */ (function() {
function t(a, h) {
for (var e = 0; e < h.length; e++) {
var d = h[e];
d.enumerable = d.enumerable || !1, d.configurable = !0, "value" in d && (d.writable = !0), Object.defineProperty(a, d.key, d);
}
}
return function(a, h, e) {
return h && t(a.prototype, h), e && t(a, e), a;
};
})();
function s(t, a) {
if (!(t instanceof a)) throw new TypeError("Cannot call a class as a function");
}
var n = N(11);
w.exports = (function() {
function t(a, h) {
s(this, t), (h !== null || h !== void 0) && (this.compareFunction = this._defaultCompareFunction);
var e = void 0;
a instanceof n ? e = a.size() : e = a.length, this._quicksort(a, 0, e - 1);
}
return v(t, [
{
key: "_quicksort",
value: function(h, e, d) {
if (e < d) {
var r = this._partition(h, e, d);
this._quicksort(h, e, r), this._quicksort(h, r + 1, d);
}
}
},
{
key: "_partition",
value: function(h, e, d) {
for (var r = this._get(h, e), i = e, f = d; ; ) {
for (; this.compareFunction(r, this._get(h, f)); ) f--;
for (; this.compareFunction(this._get(h, i), r); ) i++;
if (i < f)
this._swap(h, i, f), i++, f--;
else return f;
}
}
},
{
key: "_get",
value: function(h, e) {
return h instanceof n ? h.get_object_at(e) : h[e];
}
},
{
key: "_set",
value: function(h, e, d) {
h instanceof n ? h.set_object_at(e, d) : h[e] = d;
}
},
{
key: "_swap",
value: function(h, e, d) {
var r = this._get(h, e);
this._set(h, e, this._get(h, d)), this._set(h, d, r);
}
},
{
key: "_defaultCompareFunction",
value: function(h, e) {
return e > h;
}
}
]), t;
})();
}),
(function(w, U, N) {
"use strict";
function v() {
}
v.svd = function(s) {
this.U = null, this.V = null, this.s = null, this.m = 0, this.n = 0, this.m = s.length, this.n = s[0].length;
var n = Math.min(this.m, this.n);
this.s = (function(Ot) {
for (var Tt = []; Ot-- > 0; ) Tt.push(0);
return Tt;
})(Math.min(this.m + 1, this.n)), this.U = (function(Ot) {
return (function Tt(Xt) {
if (Xt.length == 0) return 0;
for (var St = [], Ut = 0; Ut < Xt[0]; Ut++) St.push(Tt(Xt.slice(1)));
return St;
})(Ot);
})([this.m, n]), this.V = (function(Ot) {
return (function Tt(Xt) {
if (Xt.length == 0) return 0;
for (var St = [], Ut = 0; Ut < Xt[0]; Ut++) St.push(Tt(Xt.slice(1)));
return St;
})(Ot);
})([this.n, this.n]);
for (var t = (function(Ot) {
for (var Tt = []; Ot-- > 0; ) Tt.push(0);
return Tt;
})(this.n), a = (function(Ot) {
for (var Tt = []; Ot-- > 0; ) Tt.push(0);
return Tt;
})(this.m), h = !0, e = !0, d = Math.min(this.m - 1, this.n), r = Math.max(0, Math.min(this.n - 2, this.m)), i = 0; i < Math.max(d, r); i++) {
if (i < d) {
this.s[i] = 0;
for (var f = i; f < this.m; f++) this.s[i] = v.hypot(this.s[i], s[f][i]);
if (this.s[i] !== 0) {
s[i][i] < 0 && (this.s[i] = -this.s[i]);
for (var l = i; l < this.m; l++) s[l][i] /= this.s[i];
s[i][i] += 1;
}
this.s[i] = -this.s[i];
}
for (var p = i + 1; p < this.n; p++) {
if (/* @__PURE__ */ (function(Ot, Tt) {
return Ot && Tt;
})(i < d, this.s[i] !== 0)) {
for (var g = 0, c = i; c < this.m; c++) g += s[c][i] * s[c][p];
g = -g / s[i][i];
for (var T = i; T < this.m; T++) s[T][p] += g * s[T][i];
}
t[p] = s[i][p];
}
if (/* @__PURE__ */ (function(Ot, Tt) {
return Ot && Tt;
})(h, i < d)) for (var A = i; A < this.m; A++) this.U[A][i] = s[A][i];
if (i < r) {
t[i] = 0;
for (var I = i + 1; I < this.n; I++) t[i] = v.hypot(t[i], t[I]);
if (t[i] !== 0) {
t[i + 1] < 0 && (t[i] = -t[i]);
for (var S = i + 1; S < this.n; S++) t[S] /= t[i];
t[i + 1] += 1;
}
if (t[i] = -t[i], /* @__PURE__ */ (function(Ot, Tt) {
return Ot && Tt;
})(i + 1 < this.m, t[i] !== 0)) {
for (var Y = i + 1; Y < this.m; Y++) a[Y] = 0;
for (var V = i + 1; V < this.n; V++) for (var z = i + 1; z < this.m; z++) a[z] += t[V] * s[z][V];
for (var x = i + 1; x < this.n; x++)
for (var tt = -t[x] / t[i + 1], o = i + 1; o < this.m; o++) s[o][x] += tt * a[o];
}
if (e) for (var m = i + 1; m < this.n; m++) this.V[m][i] = t[m];
}
}
var u = Math.min(this.n, this.m + 1);
if (d < this.n && (this.s[d] = s[d][d]), this.m < u && (this.s[u - 1] = 0), r + 1 < u && (t[r] = s[r][u - 1]), t[u - 1] = 0, h) {
for (var E = d; E < n; E++) {
for (var y = 0; y < this.m; y++) this.U[y][E] = 0;
this.U[E][E] = 1;
}
for (var C = d - 1; C >= 0; C--) if (this.s[C] !== 0) {
for (var M = C + 1; M < n; M++) {
for (var G = 0, O = C; O < this.m; O++) G += this.U[O][C] * this.U[O][M];
G = -G / this.U[C][C];
for (var R = C; R < this.m; R++) this.U[R][M] += G * this.U[R][C];
}
for (var W = C; W < this.m; W++) this.U[W][C] = -this.U[W][C];
this.U[C][C] = 1 + this.U[C][C];
for (var B = 0; B < C - 1; B++) this.U[B][C] = 0;
} else {
for (var rt = 0; rt < this.m; rt++) this.U[rt][C] = 0;
this.U[C][C] = 1;
}
}
if (e) for (var K = this.n - 1; K >= 0; K--) {
if (/* @__PURE__ */ (function(Ot, Tt) {
return Ot && Tt;
})(K < r, t[K] !== 0)) for (var P = K + 1; P < n; P++) {
for (var b = 0, X = K + 1; X < this.n; X++) b += this.V[X][K] * this.V[X][P];
b = -b / this.V[K + 1][K];
for (var J = K + 1; J < this.n; J++) this.V[J][P] += b * this.V[J][K];
}
for (var at = 0; at < this.n; at++) this.V[at][K] = 0;
this.V[K][K] = 1;
}
for (var q = u - 1, Z = 0, Et = Math.pow(2, -52), ft = Math.pow(2, -966); u > 0; ) {
var k = void 0, mt = void 0;
for (k = u - 2; k >= -1 && k !== -1; k--)
if (Math.abs(t[k]) <= ft + Et * (Math.abs(this.s[k]) + Math.abs(this.s[k + 1]))) {
t[k] = 0;
break;
}
if (k === u - 2) mt = 4;
else {
var ot = void 0;
for (ot = u - 1; ot >= k && ot !== k; ot--) {
var wt = (ot !== u ? Math.abs(t[ot]) : 0) + (ot !== k + 1 ? Math.abs(t[ot - 1]) : 0);
if (Math.abs(this.s[ot]) <= ft + Et * wt) {
this.s[ot] = 0;
break;
}
}
ot === k ? mt = 3 : ot === u - 1 ? mt = 1 : (mt = 2, k = ot);
}
switch (k++, mt) {
case 1:
var Wt = t[u - 2];
t[u - 2] = 0;
for (var Dt = u - 2; Dt >= k; Dt--) {
var xt = v.hypot(this.s[Dt], Wt), Gt = this.s[Dt] / xt, Vt = Wt / xt;
if (this.s[Dt] = xt, Dt !== k && (Wt = -Vt * t[Dt - 1], t[Dt - 1] = Gt * t[Dt - 1]), e) for (var Ft = 0; Ft < this.n; Ft++)
xt = Gt * this.V[Ft][Dt] + Vt * this.V[Ft][u - 1], this.V[Ft][u - 1] = -Vt * this.V[Ft][Dt] + Gt * this.V[Ft][u - 1], this.V[Ft][Dt] = xt;
}
break;
case 2:
var $t = t[k - 1];
t[k - 1] = 0;
for (var Yt = k; Yt < u; Yt++) {
var Bt = v.hypot(this.s[Yt], $t), Ct = this.s[Yt] / Bt, gt = $t / Bt;
if (this.s[Yt] = Bt, $t = -gt * t[Yt], t[Yt] = Ct * t[Yt], h) for (var D = 0; D < this.m; D++)
Bt = Ct * this.U[D][Yt] + gt * this.U[D][k - 1], this.U[D][k - 1] = -gt * this.U[D][Yt] + Ct * this.U[D][k - 1], this.U[D][Yt] = Bt;
}
break;
case 3:
var H = Math.max(Math.max(Math.max(Math.max(Math.abs(this.s[u - 1]), Math.abs(this.s[u - 2])), Math.abs(t[u - 2])), Math.abs(this.s[k])), Math.abs(t[k])), $ = this.s[u - 1] / H, _ = this.s[u - 2] / H, Q = t[u - 2] / H, j = this.s[k] / H, pt = t[k] / H, ct = ((_ + $) * (_ - $) + Q * Q) / 2, it = $ * Q * ($ * Q), dt = 0;
/* @__PURE__ */ (function(Ot, Tt) {
return Ot || Tt;
})(ct !== 0, it !== 0) && (dt = Math.sqrt(ct * ct + it), ct < 0 && (dt = -dt), dt = it / (ct + dt));
for (var Lt = (j + $) * (j - $) + dt, Mt = j * pt, et = k; et < u - 1; et++) {
var Nt = v.hypot(Lt, Mt), st = Lt / Nt, nt = Mt / Nt;
if (et !== k && (t[et - 1] = Nt), Lt = st * this.s[et] + nt * t[et], t[et] = st * t[et] - nt * this.s[et], Mt = nt * this.s[et + 1], this.s[et + 1] = st * this.s[et + 1], e) for (var ht = 0; ht < this.n; ht++)
Nt = st * this.V[ht][et] + nt * this.V[ht][et + 1], this.V[ht][et + 1] = -nt * this.V[ht][et] + st * this.V[ht][et + 1], this.V[ht][et] = Nt;
if (Nt = v.hypot(Lt, Mt), st = Lt / Nt, nt = Mt / Nt, this.s[et] = Nt, Lt = st * t[et] + nt * this.s[et + 1], this.s[et + 1] = -nt * t[et] + st * this.s[et + 1], Mt = nt * t[et + 1], t[et + 1] = st * t[et + 1], h && et < this.m - 1) for (var yt = 0; yt < this.m; yt++)
Nt = st * this.U[yt][et] + nt * this.U[yt][et + 1], this.U[yt][et + 1] = -nt * this.U[yt][et] + st * this.U[yt][et + 1], this.U[yt][et] = Nt;
}
t[u - 2] = Lt, Z = Z + 1;
break;
case 4:
if (this.s[k] <= 0 && (this.s[k] = this.s[k] < 0 ? -this.s[k] : 0, e))
for (var ut = 0; ut <= q; ut++) this.V[ut][k] = -this.V[ut][k];
for (; k < q && !(this.s[k] >= this.s[k + 1]); ) {
var Rt = this.s[k];
if (this.s[k] = this.s[k + 1], this.s[k + 1] = Rt, e && k < this.n - 1) for (var It = 0; It < this.n; It++)
Rt = this.V[It][k + 1], this.V[It][k + 1] = this.V[It][k], this.V[It][k] = Rt;
if (h && k < this.m - 1) for (var bt = 0; bt < this.m; bt++)
Rt = this.U[bt][k + 1], this.U[bt][k + 1] = this.U[bt][k], this.U[bt][k] = Rt;
k++;
}
Z = 0, u--;
break;
}
}
return {
U: this.U,
V: this.V,
S: this.s
};
}, v.hypot = function(s, n) {
var t = void 0;
return Math.abs(s) > Math.abs(n) ? (t = n / s, t = Math.abs(s) * Math.sqrt(1 + t * t)) : n != 0 ? (t = s / n, t = Math.abs(n) * Math.sqrt(1 + t * t)) : t = 0, t;
}, w.exports = v;
}),
(function(w, U, N) {
"use strict";
var v = /* @__PURE__ */ (function() {
function n(t, a) {
for (var h = 0; h < a.length; h++) {
var e = a[h];
e.enumerable = e.enumerable || !1, e.configurable = !0, "value" in e && (e.writable = !0), Object.defineProperty(t, e.key, e);
}
}
return function(t, a, h) {
return a && n(t.prototype, a), h && n(t, h), t;
};
})();
function s(n, t) {
if (!(n instanceof t)) throw new TypeError("Cannot call a class as a function");
}
w.exports = (function() {
function n(t, a) {
var h = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1, e = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : -1, d = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : -1;
s(this, n), this.sequence1 = t, this.sequence2 = a, this.match_score = h, this.mismatch_penalty = e, this.gap_penalty = d, this.iMax = t.length + 1, this.jMax = a.length + 1, this.grid = new Array(this.iMax);
for (var r = 0; r < this.iMax; r++) {
this.grid[r] = new Array(this.jMax);
for (var i = 0; i < this.jMax; i++) this.grid[r][i] = 0;
}
this.tracebackGrid = new Array(this.iMax);
for (var f = 0; f < this.iMax; f++) {
this.tracebackGrid[f] = new Array(this.jMax);
for (var l = 0; l < this.jMax; l++) this.tracebackGrid[f][l] = [
null,
null,
null
];
}
this.alignments = [], this.score = -1, this.computeGrids();
}
return v(n, [
{
key: "getScore",
value: function() {
return this.score;
}
},
{
key: "getAlignments",
value: function() {
return this.alignments;
}
},
{
key: "computeGrids",
value: function() {
for (var a = 1; a < this.jMax; a++)
this.grid[0][a] = this.grid[0][a - 1] + this.gap_penalty, this.tracebackGrid[0][a] = [
!1,
!1,
!0
];
for (var h = 1; h < this.iMax; h++)
this.grid[h][0] = this.grid[h - 1][0] + this.gap_penalty, this.tracebackGrid[h][0] = [
!1,
!0,
!1
];
for (var e = 1; e < this.iMax; e++) for (var d = 1; d < this.jMax; d++) {
var r = void 0;
this.sequence1[e - 1] === this.sequence2[d - 1] ? r = this.grid[e - 1][d - 1] + this.match_score : r = this.grid[e - 1][d - 1] + this.mismatch_penalty;
var i = this.grid[e - 1][d] + this.gap_penalty, f = this.grid[e][d - 1] + this.gap_penalty, l = [
r,
i,
f
], p = this.arrayAllMaxIndexes(l);
this.grid[e][d] = l[p[0]], this.tracebackGrid[e][d] = [
p.includes(0),
p.includes(1),
p.includes(2)
];
}
this.score = this.grid[this.iMax - 1][this.jMax - 1];
}
},
{
key: "alignmentTraceback",
value: function() {
var a = [];
for (a.push({
pos: [this.sequence1.length, this.sequence2.length],
seq1: "",
seq2: ""
}); a[0]; ) {
var h = a[0], e = this.tracebackGrid[h.pos[0]][h.pos[1]];
e[0] && a.push({
pos: [h.pos[0] - 1, h.pos[1] - 1],
seq1: this.sequence1[h.pos[0] - 1] + h.seq1,
seq2: this.sequence2[h.pos[1] - 1] + h.seq2
}), e[1] && a.push({
pos: [h.pos[0] - 1, h.pos[1]],
seq1: this.sequence1[h.pos[0] - 1] + h.seq1,
seq2: "-" + h.seq2
}), e[2] && a.push({
pos: [h.pos[0], h.pos[1] - 1],
seq1: "-" + h.seq1,
seq2: this.sequence2[h.pos[1] - 1] + h.seq2
}), h.pos[0] === 0 && h.pos[1] === 0 && this.alignments.push({
sequence1: h.seq1,
sequence2: h.seq2
}), a.shift();
}
return this.alignments;
}
},
{
key: "getAllIndexes",
value: function(a, h) {
for (var e = [], d = -1; (d = a.indexOf(h, d + 1)) !== -1; ) e.push(d);
return e;
}
},
{
key: "arrayAllMaxIndexes",
value: function(a) {
return this.getAllIndexes(a, Math.max.apply(null, a));
}
}
]), n;
})();
}),
(function(w, U, N) {
"use strict";
var v = function() {
};
v.FDLayout = N(18), v.FDLayoutConstants = N(4), v.FDLayoutEdge = N(19), v.FDLayoutNode = N(20), v.DimensionD = N(21), v.HashMap = N(22), v.HashSet = N(23), v.IGeometry = N(8), v.IMath = N(9), v.Integer = N(10), v.Point = N(12), v.PointD = N(5), v.RandomSeed = N(16), v.RectangleD = N(13), v.Transform = N(17), v.UniqueIDGeneretor = N(14), v.Quicksort = N(25), v.LinkedList = N(11), v.LGraphObject = N(2), v.LGraph = N(6), v.LEdge = N(1), v.LGraphManager = N(7), v.LNode = N(3), v.Layout = N(15), v.LayoutConstants = N(0), v.NeedlemanWunsch = N(27), v.Matrix = N(24), v.SVD = N(26), w.exports = v;
}),
(function(w, U, N) {
"use strict";
function v() {
this.listeners = [];
}
var s = v.prototype;
s.addListener = function(n, t) {
this.listeners.push({
event: n,
callback: t
});
}, s.removeListener = function(n, t) {
for (var a = this.listeners.length; a >= 0; a--) {
var h = this.listeners[a];
h.event === n && h.callback === t && this.listeners.splice(a, 1);
}
}, s.emit = function(n, t) {
for (var a = 0; a < this.listeners.length; a++) {
var h = this.listeners[a];
n === h.event && h.callback(t);
}
}, w.exports = v;
})
]);
});
})), Ce = /* @__PURE__ */ de(((L, F) => {
(function(U, N) {
typeof L == "object" && typeof F == "object" ? F.exports = N(we()) : typeof define == "function" && define.amd ? define(["layout-base"], N) : typeof L == "object" ? L.coseBase = N(we()) : U.coseBase = N(U.layoutBase);
})(L, function(w) {
return (() => {
"use strict";
var U = {
45: ((s, n, t) => {
var a = {};
a.layoutBase = t(551), a.CoSEConstants = t(806), a.CoSEEdge = t(767), a.CoSEGraph = t(880), a.CoSEGraphManager = t(578), a.CoSELayout = t(765), a.CoSENode = t(991), a.ConstraintHandler = t(902), s.exports = a;
}),
806: ((s, n, t) => {
var a = t(551).FDLayoutConstants;
function h() {
}
for (var e in a) h[e] = a[e];
h.DEFAULT_USE_MULTI_LEVEL_SCALING = !1, h.DEFAULT_RADIAL_SEPARATION = a.DEFAULT_EDGE_LENGTH, h.DEFAULT_COMPONENT_SEPERATION = 60, h.TILE = !0, h.TILING_PADDING_VERTICAL = 10, h.TILING_PADDING_HORIZONTAL = 10, h.TRANSFORM_ON_CONSTRAINT_HANDLING = !0, h.ENFORCE_CONSTRAINTS = !0, h.APPLY_LAYOUT = !0, h.RELAX_MOVEMENT_ON_CONSTRAINTS = !0, h.TREE_REDUCTION_ON_INCREMENTAL = !0, h.PURE_INCREMENTAL = h.DEFAULT_INCREMENTAL, s.exports = h;
}),
767: ((s, n, t) => {
var a = t(551).FDLayoutEdge;
function h(d, r, i) {
a.call(this, d, r, i);
}
h.prototype = Object.create(a.prototype);
for (var e in a) h[e] = a[e];
s.exports = h;
}),
880: ((s, n, t) => {
var a = t(551).LGraph;
function h(d, r, i) {
a.call(this, d, r, i);
}
h.prototype = Object.create(a.prototype);
for (var e in a) h[e] = a[e];
s.exports = h;
}),
578: ((s, n, t) => {
var a = t(551).LGraphManager;
function h(d) {
a.call(this, d);
}
h.prototype = Object.create(a.prototype);
for (var e in a) h[e] = a[e];
s.exports = h;
}),
765: ((s, n, t) => {
var a = t(551).FDLayout, h = t(578), e = t(880), d = t(991), r = t(767), i = t(806), f = t(902), l = t(551).FDLayoutConstants, p = t(551).LayoutConstants, g = t(551).Point, c = t(551).PointD, T = t(551).DimensionD, A = t(551).Layout, I = t(551).Integer, S = t(551).IGeometry, Y = t(551).LGraph, V = t(551).Transform, z = t(551).LinkedList;
function x() {
a.call(this), this.toBeTiled = {}, this.constraints = {};
}
x.prototype = Object.create(a.prototype);
for (var tt in a) x[tt] = a[tt];
x.prototype.newGraphManager = function() {
var o = new h(this);
return this.graphManager = o, o;
}, x.prototype.newGraph = function(o) {
return new e(null, this.graphManager, o);
}, x.prototype.newNode = function(o) {
return new d(this.graphManager, o);
}, x.prototype.newEdge = function(o) {
return new r(null, null, o);
}, x.prototype.initParameters = function() {
a.prototype.initParameters.call(this, arguments), this.isSubLayout || (i.DEFAULT_EDGE_LENGTH < 10 ? this.idealEdgeLength = 10 : this.idealEdgeLength = i.DEFAULT_EDGE_LENGTH, this.useSmartIdealEdgeLengthCalculation = i.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION, this.gravityConstant = l.DEFAULT_GRAVITY_STRENGTH, this.compoundGravityConstant = l.DEFAULT_COMPOUND_GRAVITY_STRENGTH, this.gravityRangeFactor = l.DEFAULT_GRAVITY_RANGE_FACTOR, this.compoundGravityRangeFactor = l.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR, this.prunedNodesAll = [], this.growTreeIterations = 0, this.afterGrowthIterations = 0, this.isTreeGrowing = !1, this.isGrowthFinished = !1);
}, x.prototype.initSpringEmbedder = function() {
a.prototype.initSpringEmbedder.call(this), this.coolingCycle = 0, this.maxCoolingCycle = this.maxIterations / l.CONVERGENCE_CHECK_PERIOD, this.finalTemperature = 0.04, this.coolingAdjuster = 1;
}, x.prototype.layout = function() {
return p.DEFAULT_CREATE_BENDS_AS_NEEDED && (this.createBendpoints(), this.graphManager.resetAllEdges()), this.level = 0, this.classicLayout();
}, x.prototype.classicLayout = function() {
if (this.nodesWithGravity = this.calculateNodesToApplyGravitationTo(), this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity), this.calcNoOfChildrenForAllNodes(), this.graphManager.calcLowestCommonAncestors(), this.graphManager.calcInclusionTreeDepths(), this.graphManager.getRoot().calcEstimatedSize(), this.calcIdealEdgeLengths(), this.incremental) {
if (i.TREE_REDUCTION_ON_INCREMENTAL) {
this.reduceTrees(), this.graphManager.resetAllNodesToApplyGravitation();
var m = new Set(this.getAllNodes()), u = this.nodesWithGravity.filter(function(C) {
return m.has(C);
});
this.graphManager.setAllNodesToApplyGravitation(u);
}
} else {
var o = this.getFlatForest();
if (o.length > 0) this.positionNodesRadially(o);
else {
this.reduceTrees(), this.graphManager.resetAllNodesToApplyGravitation();
var m = new Set(this.getAllNodes()), u = this.nodesWithGravity.filter(function(E) {
return m.has(E);
});
this.graphManager.setAllNodesToApplyGravitation(u), this.positionNodesRandomly();
}
}
return Object.keys(this.constraints).length > 0 && (f.handleConstraints(this), this.initConstraintVariables()), this.initSpringEmbedder(), i.APPLY_LAYOUT && this.runSpringEmbedder(), !0;
}, x.prototype.tick = function() {
if (this.totalIterations++, this.totalIterations === this.maxIterations && !this.isTreeGrowing && !this.isGrowthFinished) if (this.prunedNodesAll.length > 0) this.isTreeGrowing = !0;
else return !0;
if (this.totalIterations % l.CONVERGENCE_CHECK_PERIOD == 0 && !this.isTreeGrowing && !this.isGrowthFinished) {
if (this.isConverged()) if (this.prunedNodesAll.length > 0) this.isTreeGrowing = !0;
else return !0;
this.coolingCycle++, this.layoutQuality == 0 ? this.coolingAdjuster = this.coolingCycle : this.layoutQuality == 1 && (this.coolingAdjuster = this.coolingCycle / 3), this.coolingFactor = Math.max(this.initialCoolingFactor - Math.pow(this.coolingCycle, Math.log(100 * (this.initialCoolingFactor - this.finalTemperature)) / Math.log(this.maxCoolingCycle)) / 100 * this.coolingAdjuster, this.finalTemperature), this.animationPeriod = Math.ceil(this.initialAnimationPeriod * Math.sqrt(this.coolingFactor));
}
if (this.isTreeGrowing) {
if (this.growTreeIterations % 10 == 0) if (this.prunedNodesAll.length > 0) {
this.graphManager.updateBounds(), this.updateGrid(), this.growTree(this.prunedNodesAll), this.graphManager.resetAllNodesToApplyGravitation();
var o = new Set(this.getAllNodes()), m = this.nodesWithGravity.filter(function(y) {
return o.has(y);
});
this.graphManager.setAllNodesToApplyGravitation(m), this.graphManager.updateBounds(), this.updateGrid(), i.PURE_INCREMENTAL ? this.coolingFactor = l.DEFAULT_COOLING_FACTOR_INCREMENTAL / 2 : this.coolingFactor = l.DEFAULT_COOLING_FACTOR_INCREMENTAL;
} else
this.isTreeGrowing = !1, this.isGrowthFinished = !0;
this.growTreeIterations++;
}
if (this.isGrowthFinished) {
if (this.isConverged()) return !0;
this.afterGrowthIterations % 10 == 0 && (this.graphManager.updateBounds(), this.updateGrid()), i.PURE_INCREMENTAL ? this.coolingFactor = l.DEFAULT_COOLING_FACTOR_INCREMENTAL / 2 * ((100 - this.afterGrowthIterations) / 100) : this.coolingFactor = l.DEFAULT_COOLING_FACTOR_INCREMENTAL * ((100 - this.afterGrowthIterations) / 100), this.afterGrowthIterations++;
}
var u = !this.isTreeGrowing && !this.isGrowthFinished, E = this.growTreeIterations % 10 == 1 && this.isTreeGrowing || this.afterGrowthIterations % 10 == 1 && this.isGrowthFinished;
return this.totalDisplacement = 0, this.graphManager.updateBounds(), this.calcSpringForces(), this.calcRepulsionForces(u, E), this.calcGravitationalForces(), this.moveNodes(), this.animate(), !1;
}, x.prototype.getPositionsData = function() {
for (var o = this.graphManager.getAllNodes(), m = {}, u = 0; u < o.length; u++) {
var E = o[u].rect, y = o[u].id;
m[y] = {
id: y,
x: E.getCenterX(),
y: E.getCenterY(),
w: E.width,
h: E.height
};
}
return m;
}, x.prototype.runSpringEmbedder = function() {
this.initialAnimationPeriod = 25, this.animationPeriod = this.initialAnimationPeriod;
var o = !1;
if (l.ANIMATE === "during") this.emit("layoutstarted");
else {
for (; !o; ) o = this.tick();
this.graphManager.updateBounds();
}
}, x.prototype.moveNodes = function() {
for (var o = this.getAllNodes(), m, u = 0; u < o.length; u++)
m = o[u], m.calculateDisplacement();
Object.keys(this.constraints).length > 0 && this.updateDisplacements();
for (var u = 0; u < o.length; u++)
m = o[u], m.move();
}, x.prototype.initConstraintVariables = function() {
var o = this;
this.idToNodeMap = /* @__PURE__ */ new Map(), this.fixedNodeSet = /* @__PURE__ */ new Set();
for (var m = this.graphManager.getAllNodes(), u = 0; u < m.length; u++) {
var E = m[u];
this.idToNodeMap.set(E.id, E);
}
var y = function b(X) {
for (var J = X.getChild().getNodes(), at, q = 0, Z = 0; Z < J.length; Z++)
at = J[Z], at.getChild() == null ? o.fixedNodeSet.has(at.id) && (q += 100) : q += b(at);
return q;
};
if (this.constraints.fixedNodeConstraint) {
this.constraints.fixedNodeConstraint.forEach(function(J) {
o.fixedNodeSet.add(J.nodeId);
});
for (var m = this.graphManager.getAllNodes(), E, u = 0; u < m.length; u++)
if (E = m[u], E.getChild() != null) {
var C = y(E);
C > 0 && (E.fixedNodeWeight = C);
}
}
if (this.constraints.relativePlacementConstraint) {
var M = /* @__PURE__ */ new Map(), G = /* @__PURE__ */ new Map();
if (this.dummyToNodeForVerticalAlignment = /* @__PURE__ */ new Map(), this.dummyToNodeForHorizontalAlignment = /* @__PURE__ */ new Map(), this.fixedNodesOnHorizontal = /* @__PURE__ */ new Set(), this.fixedNodesOnVertical = /* @__PURE__ */ new Set(), this.fixedNodeSet.forEach(function(b) {
o.fixedNodesOnHorizontal.add(b), o.fixedNodesOnVertical.add(b);
}), this.constraints.alignmentConstraint) {
if (this.constraints.alignmentConstraint.vertical)
for (var O = this.constraints.alignmentConstraint.vertical, u = 0; u < O.length; u++)
this.dummyToNodeForVerticalAlignment.set("dummy" + u, []), O[u].forEach(function(X) {
M.set(X, "dummy" + u), o.dummyToNodeForVerticalAlignment.get("dummy" + u).push(X), o.fixedNodeSet.has(X) && o.fixedNodesOnHorizontal.add("dummy" + u);
});
if (this.constraints.alignmentConstraint.horizontal)
for (var R = this.constraints.alignmentConstraint.horizontal, u = 0; u < R.length; u++)
this.dummyToNodeForHorizontalAlignment.set("dummy" + u, []), R[u].forEach(function(X) {
G.set(X, "dummy" + u), o.dummyToNodeForHorizontalAlignment.get("dummy" + u).push(X), o.fixedNodeSet.has(X) && o.fixedNodesOnVertical.add("dummy" + u);
});
}
if (i.RELAX_MOVEMENT_ON_CONSTRAINTS)
this.shuffle = function(b) {
var X, J, at;
for (at = b.length - 1; at >= 2 * b.length / 3; at--)
X = Math.floor(Math.random() * (at + 1)), J = b[at], b[at] = b[X], b[X] = J;
return b;
}, this.nodesInRelativeHorizontal = [], this.nodesInRelativeVertical = [], this.nodeToRelativeConstraintMapHorizontal = /* @__PURE__ */ new Map(), this.nodeToRelativeConstraintMapVertical = /* @__PURE__ */ new Map(), this.nodeToTempPositionMapHorizontal = /* @__PURE__ */ new Map(), this.nodeToTempPositionMapVertical = /* @__PURE__ */ new Map(), this.constraints.relativePlacementConstraint.forEach(function(b) {
if (b.left) {
var X = M.has(b.left) ? M.get(b.left) : b.left, J = M.has(b.right) ? M.get(b.right) : b.right;
o.nodesInRelativeHorizontal.includes(X) || (o.nodesInRelativeHorizontal.push(X), o.nodeToRelativeConstraintMapHorizontal.set(X, []), o.dummyToNodeForVerticalAlignment.has(X) ? o.nodeToTempPositionMapHorizontal.set(X, o.idToNodeMap.get(o.dummyToNodeForVerticalAlignment.get(X)[0]).getCenterX()) : o.nodeToTempPositionMapHorizontal.set(X, o.idToNodeMap.get(X).getCenterX())), o.nodesInRelativeHorizontal.includes(J) || (o.nodesInRelativeHorizontal.push(J), o.nodeToRelativeConstraintMapHorizontal.set(J, []), o.dummyToNodeForVerticalAlignment.has(J) ? o.nodeToTempPositionMapHorizontal.set(J, o.idToNodeMap.get(o.dummyToNodeForVerticalAlignment.get(J)[0]).getCenterX()) : o.nodeToTempPositionMapHorizontal.set(J, o.idToNodeMap.get(J).getCenterX())), o.nodeToRelativeConstraintMapHorizontal.get(X).push({
right: J,
gap: b.gap
}), o.nodeToRelativeConstraintMapHorizontal.get(J).push({
left: X,
gap: b.gap
});
} else {
var at = G.has(b.top) ? G.get(b.top) : b.top, q = G.has(b.bottom) ? G.get(b.bottom) : b.bottom;
o.nodesInRelativeVertical.includes(at) || (o.nodesInRelativeVertical.push(at), o.nodeToRelativeConstraintMapVertical.set(at, []), o.dummyToNodeForHorizontalAlignment.has(at) ? o.nodeToTempPositionMapVertical.set(at, o.idToNodeMap.get(o.dummyToNodeForHorizontalAlignment.get(at)[0]).getCenterY()) : o.nodeToTempPositionMapVertical.set(at, o.idToNodeMap.get(at).getCenterY())), o.nodesInRelativeVertical.includes(q) || (o.nodesInRelativeVertical.push(q), o.nodeToRelativeConstraintMapVertical.set(q, []), o.dummyToNodeForHorizontalAlignment.has(q) ? o.nodeToTempPositionMapVertical.set(q, o.idToNodeMap.get(o.dummyToNodeForHorizontalAlignment.get(q)[0]).getCenterY()) : o.nodeToTempPositionMapVertical.set(q, o.idToNodeMap.get(q).getCenterY())), o.nodeToRelativeConstraintMapVertical.get(at).push({
bottom: q,
gap: b.gap
}), o.nodeToRelativeConstraintMapVertical.get(q).push({
top: at,
gap: b.gap
});
}
});
else {
var W = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map();
this.constraints.relativePlacementConstraint.forEach(function(b) {
if (b.left) {
var X = M.has(b.left) ? M.get(b.left) : b.left, J = M.has(b.right) ? M.get(b.right) : b.right;
W.has(X) ? W.get(X).push(J) : W.set(X, [J]), W.has(J) ? W.get(J).push(X) : W.set(J, [X]);
} else {
var at = G.has(b.top) ? G.get(b.top) : b.top, q = G.has(b.bottom) ? G.get(b.bottom) : b.bottom;
B.has(at) ? B.get(at).push(q) : B.set(at, [q]), B.has(q) ? B.get(q).push(at) : B.set(q, [at]);
}
});
var rt = function(X, J) {
var at = [], q = [], Z = new z(), Et = /* @__PURE__ */ new Set(), ft = 0;
return X.forEach(function(k, mt) {
if (!Et.has(mt)) {
at[ft] = [], q[ft] = !1;
var ot = mt;
for (Z.push(ot), Et.add(ot), at[ft].push(ot); Z.length != 0; )
ot = Z.shift(), J.has(ot) && (q[ft] = !0), X.get(ot).forEach(function(wt) {
Et.has(wt) || (Z.push(wt), Et.add(wt), at[ft].push(wt));
});
ft++;
}
}), {
components: at,
isFixed: q
};
}, K = rt(W, o.fixedNodesOnHorizontal);
this.componentsOnHorizontal = K.components, this.fixedComponentsOnHorizontal = K.isFixed;
var P = rt(B, o.fixedNodesOnVertical);
this.componentsOnVertical = P.components, this.fixedComponentsOnVertical = P.isFixed;
}
}
}, x.prototype.updateDisplacements = function() {
var o = this;
if (this.constraints.fixedNodeConstraint && this.constraints.fixedNodeConstraint.forEach(function(P) {
var b = o.idToNodeMap.get(P.nodeId);
b.displacementX = 0, b.displacementY = 0;
}), this.constraints.alignmentConstraint) {
if (this.constraints.alignmentConstraint.vertical)
for (var m = this.constraints.alignmentConstraint.vertical, u = 0; u < m.length; u++) {
for (var E = 0, y = 0; y < m[u].length; y++) {
if (this.fixedNodeSet.has(m[u][y])) {
E = 0;
break;
}
E += this.idToNodeMap.get(m[u][y]).displacementX;
}
for (var C = E / m[u].length, y = 0; y < m[u].length; y++) this.idToNodeMap.get(m[u][y]).displacementX = C;
}
if (this.constraints.alignmentConstraint.horizontal)
for (var M = this.constraints.alignmentConstraint.horizontal, u = 0; u < M.length; u++) {
for (var G = 0, y = 0; y < M[u].length; y++) {
if (this.fixedNodeSet.has(M[u][y])) {
G = 0;
break;
}
G += this.idToNodeMap.get(M[u][y]).displacementY;
}
for (var O = G / M[u].length, y = 0; y < M[u].length; y++) this.idToNodeMap.get(M[u][y]).displacementY = O;
}
}
if (this.constraints.relativePlacementConstraint) if (i.RELAX_MOVEMENT_ON_CONSTRAINTS)
this.totalIterations % 10 == 0 && (this.shuffle(this.nodesInRelativeHorizontal), this.shuffle(this.nodesInRelativeVertical)), this.nodesInRelativeHorizontal.forEach(function(P) {
if (!o.fixedNodesOnHorizontal.has(P)) {
var b = 0;
o.dummyToNodeForVerticalAlignment.has(P) ? b = o.idToNodeMap.get(o.dummyToNodeForVerticalAlignment.get(P)[0]).displacementX : b = o.idToNodeMap.get(P).displacementX, o.nodeToRelativeConstraintMapHorizontal.get(P).forEach(function(X) {
if (X.right) {
var J = o.nodeToTempPositionMapHorizontal.get(X.right) - o.nodeToTempPositionMapHorizontal.get(P) - b;
J < X.gap && (b -= X.gap - J);
} else {
var J = o.nodeToTempPositionMapHorizontal.get(P) - o.nodeToTempPositionMapHorizontal.get(X.left) + b;
J < X.gap && (b += X.gap - J);
}
}), o.nodeToTempPositionMapHorizontal.set(P, o.nodeToTempPositionMapHorizontal.get(P) + b), o.dummyToNodeForVerticalAlignment.has(P) ? o.dummyToNodeForVerticalAlignment.get(P).forEach(function(X) {
o.idToNodeMap.get(X).displacementX = b;
}) : o.idToNodeMap.get(P).displacementX = b;
}
}), this.nodesInRelativeVertical.forEach(function(P) {
if (!o.fixedNodesOnHorizontal.has(P)) {
var b = 0;
o.dummyToNodeForHorizontalAlignment.has(P) ? b = o.idToNodeMap.get(o.dummyToNodeForHorizontalAlignment.get(P)[0]).displacementY : b = o.idToNodeMap.get(P).displacementY, o.nodeToRelativeConstraintMapVertical.get(P).forEach(function(X) {
if (X.bottom) {
var J = o.nodeToTempPositionMapVertical.get(X.bottom) - o.nodeToTempPositionMapVertical.get(P) - b;
J < X.gap && (b -= X.gap - J);
} else {
var J = o.nodeToTempPositionMapVertical.get(P) - o.nodeToTempPositionMapVertical.get(X.top) + b;
J < X.gap && (b += X.gap - J);
}
}), o.nodeToTempPositionMapVertical.set(P, o.nodeToTempPositionMapVertical.get(P) + b), o.dummyToNodeForHorizontalAlignment.has(P) ? o.dummyToNodeForHorizontalAlignment.get(P).forEach(function(X) {
o.idToNodeMap.get(X).displacementY = b;
}) : o.idToNodeMap.get(P).displacementY = b;
}
});
else {
for (var u = 0; u < this.componentsOnHorizontal.length; u++) {
var R = this.componentsOnHorizontal[u];
if (this.fixedComponentsOnHorizontal[u]) for (var y = 0; y < R.length; y++) this.dummyToNodeForVerticalAlignment.has(R[y]) ? this.dummyToNodeForVerticalAlignment.get(R[y]).forEach(function(X) {
o.idToNodeMap.get(X).displacementX = 0;
}) : this.idToNodeMap.get(R[y]).displacementX = 0;
else {
for (var W = 0, B = 0, y = 0; y < R.length; y++) if (this.dummyToNodeForVerticalAlignment.has(R[y])) {
var rt = this.dummyToNodeForVerticalAlignment.get(R[y]);
W += rt.length * this.idToNodeMap.get(rt[0]).displacementX, B += rt.length;
} else
W += this.idToNodeMap.get(R[y]).displacementX, B++;
for (var K = W / B, y = 0; y < R.length; y++) this.dummyToNodeForVerticalAlignment.has(R[y]) ? this.dummyToNodeForVerticalAlignment.get(R[y]).forEach(function(X) {
o.idToNodeMap.get(X).displacementX = K;
}) : this.idToNodeMap.get(R[y]).displacementX = K;
}
}
for (var u = 0; u < this.componentsOnVertical.length; u++) {
var R = this.componentsOnVertical[u];
if (this.fixedComponentsOnVertical[u]) for (var y = 0; y < R.length; y++) this.dummyToNodeForHorizontalAlignment.has(R[y]) ? this.dummyToNodeForHorizontalAlignment.get(R[y]).forEach(function(J) {
o.idToNodeMap.get(J).displacementY = 0;
}) : this.idToNodeMap.get(R[y]).displacementY = 0;
else {
for (var W = 0, B = 0, y = 0; y < R.length; y++) if (this.dummyToNodeForHorizontalAlignment.has(R[y])) {
var rt = this.dummyToNodeForHorizontalAlignment.get(R[y]);
W += rt.length * this.idToNodeMap.get(rt[0]).displacementY, B += rt.length;
} else
W += this.idToNodeMap.get(R[y]).displacementY, B++;
for (var K = W / B, y = 0; y < R.length; y++) this.dummyToNodeForHorizontalAlignment.has(R[y]) ? this.dummyToNodeForHorizontalAlignment.get(R[y]).forEach(function(Z) {
o.idToNodeMap.get(Z).displacementY = K;
}) : this.idToNodeMap.get(R[y]).displacementY = K;
}
}
}
}, x.prototype.calculateNodesToApplyGravitationTo = function() {
var o = [], m, u = this.graphManager.getGraphs(), E = u.length, y;
for (y = 0; y < E; y++)
m = u[y], m.updateConnected(), m.isConnected || (o = o.concat(m.getNodes()));
return o;
}, x.prototype.createBendpoints = function() {
var o = [];
o = o.concat(this.graphManager.getAllEdges());
var m = /* @__PURE__ */ new Set(), u;
for (u = 0; u < o.length; u++) {
var E = o[u];
if (!m.has(E)) {
var y = E.getSource(), C = E.getTarget();
if (y == C)
E.getBendpoints().push(new c()), E.getBendpoints().push(new c()), this.createDummyNodesForBendpoints(E), m.add(E);
else {
var M = [];
if (M = M.concat(y.getEdgeListToNode(C)), M = M.concat(C.getEdgeListToNode(y)), !m.has(M[0])) {
if (M.length > 1) {
var G;
for (G = 0; G < M.length; G++) {
var O = M[G];
O.getBendpoints().push(new c()), this.createDummyNodesForBendpoints(O);
}
}
M.forEach(function(R) {
m.add(R);
});
}
}
}
if (m.size == o.length) break;
}
}, x.prototype.positionNodesRadially = function(o) {
for (var m = new g(0, 0), u = Math.ceil(Math.sqrt(o.length)), E = 0, y = 0, C = 0, M = new c(0, 0), G = 0; G < o.length; G++) {
G % u == 0 && (C = 0, y = E, G != 0 && (y += i.DEFAULT_COMPONENT_SEPERATION), E = 0);
var O = o[G], R = A.findCenterOfTree(O);
m.x = C, m.y = y, M = x.radialLayout(O, R, m), M.y > E && (E = Math.floor(M.y)), C = Math.floor(M.x + i.DEFAULT_COMPONENT_SEPERATION);
}
this.transform(new c(p.WORLD_CENTER_X - M.x / 2, p.WORLD_CENTER_Y - M.y / 2));
}, x.radialLayout = function(o, m, u) {
var E = Math.max(this.maxDiagonalInTree(o), i.DEFAULT_RADIAL_SEPARATION);
x.branchRadialLayout(m, null, 0, 359, 0, E);
var y = Y.calculateBounds(o), C = new V();
C.setDeviceOrgX(y.getMinX()), C.setDeviceOrgY(y.getMinY()), C.setWorldOrgX(u.x), C.setWorldOrgY(u.y);
for (var M = 0; M < o.length; M++) o[M].transform(C);
var G = new c(y.getMaxX(), y.getMaxY());
return C.inverseTransformPoint(G);
}, x.branchRadialLayout = function(o, m, u, E, y, C) {
var M = (E - u + 1) / 2;
M < 0 && (M += 180);
var G = (M + u) % 360 * S.TWO_PI / 360, O = y * Math.cos(G), R = y * Math.sin(G);
o.setCenter(O, R);
var W = [];
W = W.concat(o.getEdges());
var B = W.length;
m != null && B--;
for (var rt = 0, K = W.length, P, b = o.getEdgesBetween(m); b.length > 1; ) {
var X = b[0];
b.splice(0, 1);
var J = W.indexOf(X);
J >= 0 && W.splice(J, 1), K--, B--;
}
m != null ? P = (W.indexOf(b[0]) + 1) % K : P = 0;
for (var at = Math.abs(E - u) / B, q = P; rt != B; q = ++q % K) {
var Z = W[q].getOtherEnd(o);
if (Z != m) {
var Et = (u + rt * at) % 360, ft = (Et + at) % 360;
x.branchRadialLayout(Z, o, Et, ft, y + C, C), rt++;
}
}
}, x.maxDiagonalInTree = function(o) {
for (var m = I.MIN_VALUE, u = 0; u < o.length; u++) {
var E = o[u].getDiagonal();
E > m && (m = E);
}
return m;
}, x.prototype.calcRepulsionRange = function() {
return 2 * (this.level + 1) * this.idealEdgeLength;
}, x.prototype.groupZeroDegreeMembers = function() {
var o = this, m = {};
this.memberGroups = {}, this.idToDummyNode = {};
for (var u = [], E = this.graphManager.getAllNodes(), y = 0; y < E.length; y++) {
var C = E[y], M = C.getParent();
this.getNodeDegreeWithChildren(C) === 0 && (M.id == null || !this.getToBeTiled(M)) && u.push(C);
}
for (var y = 0; y < u.length; y++) {
var C = u[y], G = C.getParent().id;
typeof m[G] > "u" && (m[G] = []), m[G] = m[G].concat(C);
}
Object.keys(m).forEach(function(O) {
if (m[O].length > 1) {
var R = "DummyCompound_" + O;
o.memberGroups[R] = m[O];
var W = m[O][0].getParent(), B = new d(o.graphManager);
B.id = R, B.paddingLeft = W.paddingLeft || 0, B.paddingRight = W.paddingRight || 0, B.paddingBottom = W.paddingBottom || 0, B.paddingTop = W.paddingTop || 0, o.idToDummyNode[R] = B;
var rt = o.getGraphManager().add(o.newGraph(), B), K = W.getChild();
K.add(B);
for (var P = 0; P < m[O].length; P++) {
var b = m[O][P];
K.remove(b), rt.add(b);
}
}
});
}, x.prototype.clearCompounds = function() {
var o = {}, m = {};
this.performDFSOnCompounds();
for (var u = 0; u < this.compoundOrder.length; u++)
m[this.compoundOrder[u].id] = this.compoundOrder[u], o[this.compoundOrder[u].id] = [].concat(this.compoundOrder[u].getChild().getNodes()), this.graphManager.remove(this.compoundOrder[u].getChild()), this.compoundOrder[u].child = null;
this.graphManager.resetAllNodes(), this.tileCompoundMembers(o, m);
}, x.prototype.clearZeroDegreeMembers = function() {
var o = this, m = this.tiledZeroDegreePack = [];
Object.keys(this.memberGroups).forEach(function(u) {
var E = o.idToDummyNode[u];
if (m[u] = o.tileNodes(o.memberGroups[u], E.paddingLeft + E.paddingRight), E.rect.width = m[u].width, E.rect.height = m[u].height, E.setCenter(m[u].centerX, m[u].centerY), E.labelMarginLeft = 0, E.labelMarginTop = 0, i.NODE_DIMENSIONS_INCLUDE_LABELS) {
var y = E.rect.width, C = E.rect.height;
E.labelWidth && (E.labelPosHorizontal == "left" ? (E.rect.x -= E.labelWidth, E.setWidth(y + E.labelWidth), E.labelMarginLeft = E.labelWidth) : E.labelPosHorizontal == "center" && E.labelWidth > y ? (E.rect.x -= (E.labelWidth - y) / 2, E.setWidth(E.labelWidth), E.labelMarginLeft = (E.labelWidth - y) / 2) : E.labelPosHorizontal == "right" && E.setWidth(y + E.labelWidth)), E.labelHeight && (E.labelPosVertical == "top" ? (E.rect.y -= E.labelHeight, E.setHeight(C + E.labelHeight), E.labelMarginTop = E.labelHeight) : E.labelPosVertical == "center" && E.labelHeight > C ? (E.rect.y -= (E.labelHeight - C) / 2, E.setHeight(E.labelHeight), E.labelMarginTop = (E.labelHeight - C) / 2) : E.labelPosVertical == "bottom" && E.setHeight(C + E.labelHeight));
}
});
}, x.prototype.repopulateCompounds = function() {
for (var o = this.compoundOrder.length - 1; o >= 0; o--) {
var m = this.compoundOrder[o], u = m.id, E = m.paddingLeft, y = m.paddingTop, C = m.labelMarginLeft, M = m.labelMarginTop;
this.adjustLocations(this.tiledMemberPack[u], m.rect.x, m.rect.y, E, y, C, M);
}
}, x.prototype.repopulateZeroDegreeMembers = function() {
var o = this, m = this.tiledZeroDegreePack;
Object.keys(m).forEach(function(u) {
var E = o.idToDummyNode[u], y = E.paddingLeft, C = E.paddingTop, M = E.labelMarginLeft, G = E.labelMarginTop;
o.adjustLocations(m[u], E.rect.x, E.rect.y, y, C, M, G);
});
}, x.prototype.getToBeTiled = function(o) {
var m = o.id;
if (this.toBeTiled[m] != null) return this.toBeTiled[m];
var u = o.getChild();
if (u == null)
return this.toBeTiled[m] = !1, !1;
for (var E = u.getNodes(), y = 0; y < E.length; y++) {
var C = E[y];
if (this.getNodeDegree(C) > 0)
return this.toBeTiled[m] = !1, !1;
if (C.getChild() == null) {
this.toBeTiled[C.id] = !1;
continue;
}
if (!this.getToBeTiled(C))
return this.toBeTiled[m] = !1, !1;
}
return this.toBeTiled[m] = !0, !0;
}, x.prototype.getNodeDegree = function(o) {
o.id;
for (var m = o.getEdges(), u = 0, E = 0; E < m.length; E++) {
var y = m[E];
y.getSource().id !== y.getTarget().id && (u = u + 1);
}
return u;
}, x.prototype.getNodeDegreeWithChildren = function(o) {
var m = this.getNodeDegree(o);
if (o.getChild() == null) return m;
for (var u = o.getChild().getNodes(), E = 0; E < u.length; E++) {
var y = u[E];
m += this.getNodeDegreeWithChildren(y);
}
return m;
}, x.prototype.performDFSOnCompounds = function() {
this.compoundOrder = [], this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes());
}, x.prototype.fillCompexOrderByDFS = function(o) {
for (var m = 0; m < o.length; m++) {
var u = o[m];
u.getChild() != null && this.fillCompexOrderByDFS(u.getChild().getNodes()), this.getToBeTiled(u) && this.compoundOrder.push(u);
}
}, x.prototype.adjustLocations = function(o, m, u, E, y, C, M) {
m += E + C, u += y + M;
for (var G = m, O = 0; O < o.rows.length; O++) {
var R = o.rows[O];
m = G;
for (var W = 0, B = 0; B < R.length; B++) {
var rt = R[B];
rt.rect.x = m, rt.rect.y = u, m += rt.rect.width + o.horizontalPadding, rt.rect.height > W && (W = rt.rect.height);
}
u += W + o.verticalPadding;
}
}, x.prototype.tileCompoundMembers = function(o, m) {
var u = this;
this.tiledMemberPack = [], Object.keys(o).forEach(function(E) {
var y = m[E];
if (u.tiledMemberPack[E] = u.tileNodes(o[E], y.paddingLeft + y.paddingRight), y.rect.width = u.tiledMemberPack[E].width, y.rect.height = u.tiledMemberPack[E].height, y.setCenter(u.tiledMemberPack[E].centerX, u.tiledMemberPack[E].centerY), y.labelMarginLeft = 0, y.labelMarginTop = 0, i.NODE_DIMENSIONS_INCLUDE_LABELS) {
var C = y.rect.width, M = y.rect.height;
y.labelWidth && (y.labelPosHorizontal == "left" ? (y.rect.x -= y.labelWidth, y.setWidth(C + y.labelWidth), y.labelMarginLeft = y.labelWidth) : y.labelPosHorizontal == "center" && y.labelWidth > C ? (y.rect.x -= (y.labelWidth - C) / 2, y.setWidth(y.labelWidth), y.labelMarginLeft = (y.labelWidth - C) / 2) : y.labelPosHorizontal == "right" && y.setWidth(C + y.labelWidth)), y.labelHeight && (y.labelPosVertical == "top" ? (y.rect.y -= y.labelHeight, y.setHeight(M + y.labelHeight), y.labelMarginTop = y.labelHeight) : y.labelPosVertical == "center" && y.labelHeight > M ? (y.rect.y -= (y.labelHeight - M) / 2, y.setHeight(y.labelHeight), y.labelMarginTop = (y.labelHeight - M) / 2) : y.labelPosVertical == "bottom" && y.setHeight(M + y.labelHeight));
}
});
}, x.prototype.tileNodes = function(o, m) {
var u = this.tileNodesByFavoringDim(o, m, !0), E = this.tileNodesByFavoringDim(o, m, !1), y = this.getOrgRatio(u), C = this.getOrgRatio(E), M;
return C < y ? M = E : M = u, M;
}, x.prototype.getOrgRatio = function(o) {
var m = o.width / o.height;
return m < 1 && (m = 1 / m), m;
}, x.prototype.calcIdealRowWidth = function(o, m) {
var u = i.TILING_PADDING_VERTICAL, E = i.TILING_PADDING_HORIZONTAL, y = o.length, C = 0, M = 0, G = 0;
o.forEach(function(P) {
C += P.getWidth(), M += P.getHeight(), P.getWidth() > G && (G = P.getWidth());
});
var O = C / y, R = M / y, W = Math.pow(u - E, 2) + 4 * (O + E) * (R + u) * y, B = (E - u + Math.sqrt(W)) / (2 * (O + E)), rt;
m ? (rt = Math.ceil(B), rt == B && rt++) : rt = Math.floor(B);
var K = rt * (O + E) - E;
return G > K && (K = G), K += E * 2, K;
}, x.prototype.tileNodesByFavoringDim = function(o, m, u) {
var E = i.TILING_PADDING_VERTICAL, y = i.TILING_PADDING_HORIZONTAL, C = i.TILING_COMPARE_BY, M = {
rows: [],
rowWidth: [],
rowHeight: [],
width: 0,
height: m,
verticalPadding: E,
horizontalPadding: y,
centerX: 0,
centerY: 0
};
C && (M.idealRowWidth = this.calcIdealRowWidth(o, u));
var G = function(b) {
return b.rect.width * b.rect.height;
}, O = function(b, X) {
return G(X) - G(b);
};
o.sort(function(P, b) {
var X = O;
return M.idealRowWidth ? (X = C, X(P.id, b.id)) : X(P, b);
});
for (var R = 0, W = 0, B = 0; B < o.length; B++) {
var rt = o[B];
R += rt.getCenterX(), W += rt.getCenterY();
}
M.centerX = R / o.length, M.centerY = W / o.length;
for (var B = 0; B < o.length; B++) {
var rt = o[B];
if (M.rows.length == 0) this.insertNodeToRow(M, rt, 0, m);
else if (this.canAddHorizontal(M, rt.rect.width, rt.rect.height)) {
var K = M.rows.length - 1;
M.idealRowWidth || (K = this.getShortestRowIndex(M)), this.insertNodeToRow(M, rt, K, m);
} else this.insertNodeToRow(M, rt, M.rows.length, m);
this.shiftToLastRow(M);
}
return M;
}, x.prototype.insertNodeToRow = function(o, m, u, E) {
var y = E;
u == o.rows.length && (o.rows.push([]), o.rowWidth.push(y), o.rowHeight.push(0));
var C = o.rowWidth[u] + m.rect.width;
o.rows[u].length > 0 && (C += o.horizontalPadding), o.rowWidth[u] = C, o.width < C && (o.width = C);
var M = m.rect.height;
u > 0 && (M += o.verticalPadding);
var G = 0;
M > o.rowHeight[u] && (G = o.rowHeight[u], o.rowHeight[u] = M, G = o.rowHeight[u] - G), o.height += G, o.rows[u].push(m);
}, x.prototype.getShortestRowIndex = function(o) {
for (var m = -1, u = Number.MAX_VALUE, E = 0; E < o.rows.length; E++) o.rowWidth[E] < u && (m = E, u = o.rowWidth[E]);
return m;
}, x.prototype.getLongestRowIndex = function(o) {
for (var m = -1, u = Number.MIN_VALUE, E = 0; E < o.rows.length; E++) o.rowWidth[E] > u && (m = E, u = o.rowWidth[E]);
return m;
}, x.prototype.canAddHorizontal = function(o, m, u) {
if (o.idealRowWidth) {
var E = o.rows.length - 1;
return o.rowWidth[E] + m + o.horizontalPadding <= o.idealRowWidth;
}
var y = this.getShortestRowIndex(o);
if (y < 0) return !0;
var C = o.rowWidth[y];
if (C + o.horizontalPadding + m <= o.width) return !0;
var M = 0;
o.rowHeight[y] < u && y > 0 && (M = u + o.verticalPadding - o.rowHeight[y]);
var G;
o.width - C >= m + o.horizontalPadding ? G = (o.height + M) / (C + m + o.horizontalPadding) : G = (o.height + M) / o.width, M = u + o.verticalPadding;
var O;
return o.width < m ? O = (o.height + M) / m : O = (o.height + M) / o.width, O < 1 && (O = 1 / O), G < 1 && (G = 1 / G), G < O;
}, x.prototype.shiftToLastRow = function(o) {
var m = this.getLongestRowIndex(o), u = o.rowWidth.length - 1, E = o.rows[m], y = E[E.length - 1], C = y.width + o.horizontalPadding;
if (o.width - o.rowWidth[u] > C && m != u) {
E.splice(-1, 1), o.rows[u].push(y), o.rowWidth[m] = o.rowWidth[m] - C, o.rowWidth[u] = o.rowWidth[u] + C, o.width = o.rowWidth[instance.getLongestRowIndex(o)];
for (var M = Number.MIN_VALUE, G = 0; G < E.length; G++) E[G].height > M && (M = E[G].height);
m > 0 && (M += o.verticalPadding);
var O = o.rowHeight[m] + o.rowHeight[u];
o.rowHeight[m] = M, o.rowHeight[u] < y.height + o.verticalPadding && (o.rowHeight[u] = y.height + o.verticalPadding);
var R = o.rowHeight[m] + o.rowHeight[u];
o.height += R - O, this.shiftToLastRow(o);
}
}, x.prototype.tilingPreLayout = function() {
i.TILE && (this.groupZeroDegreeMembers(), this.clearCompounds(), this.clearZeroDegreeMembers());
}, x.prototype.tilingPostLayout = function() {
i.TILE && (this.repopulateZeroDegreeMembers(), this.repopulateCompounds());
}, x.prototype.reduceTrees = function() {
for (var o = [], m = !0, u; m; ) {
var E = this.graphManager.getAllNodes(), y = [];
m = !1;
for (var C = 0; C < E.length; C++)
if (u = E[C], u.getEdges().length == 1 && !u.getEdges()[0].isInterGraph && u.getChild() == null) {
if (i.PURE_INCREMENTAL) {
var M = u.getEdges()[0].getOtherEnd(u), G = new T(u.getCenterX() - M.getCenterX(), u.getCenterY() - M.getCenterY());
y.push([
u,
u.getEdges()[0],
u.getOwner(),
G
]);
} else y.push([
u,
u.getEdges()[0],
u.getOwner()
]);
m = !0;
}
if (m == !0) {
for (var O = [], R = 0; R < y.length; R++) y[R][0].getEdges().length == 1 && (O.push(y[R]), y[R][0].getOwner().remove(y[R][0]));
o.push(O), this.graphManager.resetAllNodes(), this.graphManager.resetAllEdges();
}
}
this.prunedNodesAll = o;
}, x.prototype.growTree = function(o) {
for (var m = o[o.length - 1], u, E = 0; E < m.length; E++)
u = m[E], this.findPlaceforPrunedNode(u), u[2].add(u[0]), u[2].add(u[1], u[1].source, u[1].target);
o.splice(o.length - 1, 1), this.graphManager.resetAllNodes(), this.graphManager.resetAllEdges();
}, x.prototype.findPlaceforPrunedNode = function(o) {
var m, u, E = o[0];
if (E == o[1].source ? u = o[1].target : u = o[1].source, i.PURE_INCREMENTAL) E.setCenter(u.getCenterX() + o[3].getWidth(), u.getCenterY() + o[3].getHeight());
else {
var y = u.startX, C = u.finishX, M = u.startY, G = u.finishY, O = [
0,
0,
0,
0
];
if (M > 0) for (var R = y; R <= C; R++) O[0] += this.grid[R][M - 1].length + this.grid[R][M].length - 1;
if (C < this.grid.length - 1) for (var R = M; R <= G; R++) O[1] += this.grid[C + 1][R].length + this.grid[C][R].length - 1;
if (G < this.grid[0].length - 1) for (var R = y; R <= C; R++) O[2] += this.grid[R][G + 1].length + this.grid[R][G].length - 1;
if (y > 0) for (var R = M; R <= G; R++) O[3] += this.grid[y - 1][R].length + this.grid[y][R].length - 1;
for (var W = I.MAX_VALUE, B, rt, K = 0; K < O.length; K++) O[K] < W ? (W = O[K], B = 1, rt = K) : O[K] == W && B++;
if (B == 3 && W == 0)
O[0] == 0 && O[1] == 0 && O[2] == 0 ? m = 1 : O[0] == 0 && O[1] == 0 && O[3] == 0 ? m = 0 : O[0] == 0 && O[2] == 0 && O[3] == 0 ? m = 3 : O[1] == 0 && O[2] == 0 && O[3] == 0 && (m = 2);
else if (B == 2 && W == 0) {
var P = Math.floor(Math.random() * 2);
O[0] == 0 && O[1] == 0 ? P == 0 ? m = 0 : m = 1 : O[0] == 0 && O[2] == 0 ? P == 0 ? m = 0 : m = 2 : O[0] == 0 && O[3] == 0 ? P == 0 ? m = 0 : m = 3 : O[1] == 0 && O[2] == 0 ? P == 0 ? m = 1 : m = 2 : O[1] == 0 && O[3] == 0 ? P == 0 ? m = 1 : m = 3 : P == 0 ? m = 2 : m = 3;
} else if (B == 4 && W == 0) {
var P = Math.floor(Math.random() * 4);
m = P;
} else m = rt;
m == 0 ? E.setCenter(u.getCenterX(), u.getCenterY() - u.getHeight() / 2 - l.DEFAULT_EDGE_LENGTH - E.getHeight() / 2) : m == 1 ? E.setCenter(u.getCenterX() + u.getWidth() / 2 + l.DEFAULT_EDGE_LENGTH + E.getWidth() / 2, u.getCenterY()) : m == 2 ? E.setCenter(u.getCenterX(), u.getCenterY() + u.getHeight() / 2 + l.DEFAULT_EDGE_LENGTH + E.getHeight() / 2) : E.setCenter(u.getCenterX() - u.getWidth() / 2 - l.DEFAULT_EDGE_LENGTH - E.getWidth() / 2, u.getCenterY());
}
}, s.exports = x;
}),
991: ((s, n, t) => {
var a = t(551).FDLayoutNode, h = t(551).IMath;
function e(r, i, f, l) {
a.call(this, r, i, f, l);
}
e.prototype = Object.create(a.prototype);
for (var d in a) e[d] = a[d];
e.prototype.calculateDisplacement = function() {
var r = this.graphManager.getLayout();
this.getChild() != null && this.fixedNodeWeight ? (this.displacementX += r.coolingFactor * (this.springForceX + this.repulsionForceX + this.gravitationForceX) / this.fixedNodeWeight, this.displacementY += r.coolingFactor * (this.springForceY + this.repulsionForceY + this.gravitationForceY) / this.fixedNodeWeight) : (this.displacementX += r.coolingFactor * (this.springForceX + this.repulsionForceX + this.gravitationForceX) / this.noOfChildren, this.displacementY += r.coolingFactor * (this.springForceY + this.repulsionForceY + this.gravitationForceY) / this.noOfChildren), Math.abs(this.displacementX) > r.coolingFactor * r.maxNodeDisplacement && (this.displacementX = r.coolingFactor * r.maxNodeDisplacement * h.sign(this.displacementX)), Math.abs(this.displacementY) > r.coolingFactor * r.maxNodeDisplacement && (this.displacementY = r.coolingFactor * r.maxNodeDisplacement * h.sign(this.displacementY)), this.child && this.child.getNodes().length > 0 && this.propogateDisplacementToChildren(this.displacementX, this.displacementY);
}, e.prototype.propogateDisplacementToChildren = function(r, i) {
for (var f = this.getChild().getNodes(), l, p = 0; p < f.length; p++)
l = f[p], l.getChild() == null ? (l.displacementX += r, l.displacementY += i) : l.propogateDisplacementToChildren(r, i);
}, e.prototype.move = function() {
var r = this.graphManager.getLayout();
(this.child == null || this.child.getNodes().length == 0) && (this.moveBy(this.displacementX, this.displacementY), r.totalDisplacement += Math.abs(this.displacementX) + Math.abs(this.displacementY)), this.springForceX = 0, this.springForceY = 0, this.repulsionForceX = 0, this.repulsionForceY = 0, this.gravitationForceX = 0, this.gravitationForceY = 0, this.displacementX = 0, this.displacementY = 0;
}, e.prototype.setPred1 = function(r) {
this.pred1 = r;
}, e.prototype.getPred1 = function() {
return pred1;
}, e.prototype.getPred2 = function() {
return pred2;
}, e.prototype.setNext = function(r) {
this.next = r;
}, e.prototype.getNext = function() {
return next;
}, e.prototype.setProcessed = function(r) {
this.processed = r;
}, e.prototype.isProcessed = function() {
return processed;
}, s.exports = e;
}),
902: ((s, n, t) => {
function a(f) {
if (Array.isArray(f)) {
for (var l = 0, p = Array(f.length); l < f.length; l++) p[l] = f[l];
return p;
} else return Array.from(f);
}
var h = t(806), e = t(551).LinkedList, d = t(551).Matrix, r = t(551).SVD;
function i() {
}
i.handleConstraints = function(f) {
var l = {};
l.fixedNodeConstraint = f.constraints.fixedNodeConstraint, l.alignmentConstraint = f.constraints.alignmentConstraint, l.relativePlacementConstraint = f.constraints.relativePlacementConstraint;
for (var p = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), c = [], T = [], A = f.getAllNodes(), I = 0, S = 0; S < A.length; S++) {
var Y = A[S];
Y.getChild() == null && (g.set(Y.id, I++), c.push(Y.getCenterX()), T.push(Y.getCenterY()), p.set(Y.id, Y));
}
l.relativePlacementConstraint && l.relativePlacementConstraint.forEach(function(D) {
!D.gap && D.gap != 0 && (D.left ? D.gap = h.DEFAULT_EDGE_LENGTH + p.get(D.left).getWidth() / 2 + p.get(D.right).getWidth() / 2 : D.gap = h.DEFAULT_EDGE_LENGTH + p.get(D.top).getHeight() / 2 + p.get(D.bottom).getHeight() / 2);
});
var V = function(H, $) {
return {
x: H.x - $.x,
y: H.y - $.y
};
}, z = function(H) {
var $ = 0, _ = 0;
return H.forEach(function(Q) {
$ += c[g.get(Q)], _ += T[g.get(Q)];
}), {
x: $ / H.size,
y: _ / H.size
};
}, x = function(H, $, _, Q, j) {
function pt(st, nt) {
var ht = new Set(st), yt = !0, ut = !1, Rt = void 0;
try {
for (var It = nt[Symbol.iterator](), bt; !(yt = (bt = It.next()).done); yt = !0) {
var Ot = bt.value;
ht.add(Ot);
}
} catch (Tt) {
ut = !0, Rt = Tt;
} finally {
try {
!yt && It.return && It.return();
} finally {
if (ut) throw Rt;
}
}
return ht;
}
var ct = /* @__PURE__ */ new Map();
H.forEach(function(st, nt) {
ct.set(nt, 0);
}), H.forEach(function(st, nt) {
st.forEach(function(ht) {
ct.set(ht.id, ct.get(ht.id) + 1);
});
});
var it = /* @__PURE__ */ new Map(), dt = /* @__PURE__ */ new Map(), Lt = new e();
ct.forEach(function(st, nt) {
st == 0 ? (Lt.push(nt), _ || ($ == "horizontal" ? it.set(nt, g.has(nt) ? c[g.get(nt)] : Q.get(nt)) : it.set(nt, g.has(nt) ? T[g.get(nt)] : Q.get(nt)))) : it.set(nt, Number.NEGATIVE_INFINITY), _ && dt.set(nt, /* @__PURE__ */ new Set([nt]));
}), _ && j.forEach(function(st) {
var nt = [];
if (st.forEach(function(ut) {
_.has(ut) && nt.push(ut);
}), nt.length > 0) {
var ht = 0;
nt.forEach(function(ut) {
$ == "horizontal" ? (it.set(ut, g.has(ut) ? c[g.get(ut)] : Q.get(ut)), ht += it.get(ut)) : (it.set(ut, g.has(ut) ? T[g.get(ut)] : Q.get(ut)), ht += it.get(ut));
}), ht = ht / nt.length, st.forEach(function(ut) {
_.has(ut) || it.set(ut, ht);
});
} else {
var yt = 0;
st.forEach(function(ut) {
$ == "horizontal" ? yt += g.has(ut) ? c[g.get(ut)] : Q.get(ut) : yt += g.has(ut) ? T[g.get(ut)] : Q.get(ut);
}), yt = yt / st.length, st.forEach(function(ut) {
it.set(ut, yt);
});
}
});
for (var Mt = function() {
var nt = Lt.shift();
H.get(nt).forEach(function(ht) {
if (it.get(ht.id) < it.get(nt) + ht.gap) if (_ && _.has(ht.id)) {
var yt = void 0;
if ($ == "horizontal" ? yt = g.has(ht.id) ? c[g.get(ht.id)] : Q.get(ht.id) : yt = g.has(ht.id) ? T[g.get(ht.id)] : Q.get(ht.id), it.set(ht.id, yt), yt < it.get(nt) + ht.gap) {
var ut = it.get(nt) + ht.gap - yt;
dt.get(nt).forEach(function(Rt) {
it.set(Rt, it.get(Rt) - ut);
});
}
} else it.set(ht.id, it.get(nt) + ht.gap);
ct.set(ht.id, ct.get(ht.id) - 1), ct.get(ht.id) == 0 && Lt.push(ht.id), _ && dt.set(ht.id, pt(dt.get(nt), dt.get(ht.id)));
});
}; Lt.length != 0; ) Mt();
if (_) {
var et = /* @__PURE__ */ new Set();
H.forEach(function(st, nt) {
st.length == 0 && et.add(nt);
});
var Nt = [];
dt.forEach(function(st, nt) {
if (et.has(nt)) {
var ht = !1, yt = !0, ut = !1, Rt = void 0;
try {
for (var It = st[Symbol.iterator](), bt; !(yt = (bt = It.next()).done); yt = !0) {
var Ot = bt.value;
_.has(Ot) && (ht = !0);
}
} catch (St) {
ut = !0, Rt = St;
} finally {
try {
!yt && It.return && It.return();
} finally {
if (ut) throw Rt;
}
}
if (!ht) {
var Tt = !1, Xt = void 0;
Nt.forEach(function(St, Ut) {
St.has([].concat(a(st))[0]) && (Tt = !0, Xt = Ut);
}), Tt ? st.forEach(function(St) {
Nt[Xt].add(St);
}) : Nt.push(new Set(st));
}
}
}), Nt.forEach(function(st, nt) {
var ht = Number.POSITIVE_INFINITY, yt = Number.POSITIVE_INFINITY, ut = Number.NEGATIVE_INFINITY, Rt = Number.NEGATIVE_INFINITY, It = !0, bt = !1, Ot = void 0;
try {
for (var Tt = st[Symbol.iterator](), Xt; !(It = (Xt = Tt.next()).done); It = !0) {
var St = Xt.value, Ut = void 0;
$ == "horizontal" ? Ut = g.has(St) ? c[g.get(St)] : Q.get(St) : Ut = g.has(St) ? T[g.get(St)] : Q.get(St);
var Jt = it.get(St);
Ut < ht && (ht = Ut), Ut > ut && (ut = Ut), Jt < yt && (yt = Jt), Jt > Rt && (Rt = Jt);
}
} catch (te) {
bt = !0, Ot = te;
} finally {
try {
!It && Tt.return && Tt.return();
} finally {
if (bt) throw Ot;
}
}
var oe = (ht + ut) / 2 - (yt + Rt) / 2, Qt = !0, Kt = !1, jt = void 0;
try {
for (var qt = st[Symbol.iterator](), ae; !(Qt = (ae = qt.next()).done); Qt = !0) {
var _t = ae.value;
it.set(_t, it.get(_t) + oe);
}
} catch (te) {
Kt = !0, jt = te;
} finally {
try {
!Qt && qt.return && qt.return();
} finally {
if (Kt) throw jt;
}
}
});
}
return it;
}, tt = function(H) {
var $ = 0, _ = 0, Q = 0, j = 0;
if (H.forEach(function(dt) {
dt.left ? c[g.get(dt.left)] - c[g.get(dt.right)] >= 0 ? $++ : _++ : T[g.get(dt.top)] - T[g.get(dt.bottom)] >= 0 ? Q++ : j++;
}), $ > _ && Q > j) for (var pt = 0; pt < g.size; pt++)
c[pt] = -1 * c[pt], T[pt] = -1 * T[pt];
else if ($ > _) for (var ct = 0; ct < g.size; ct++) c[ct] = -1 * c[ct];
else if (Q > j) for (var it = 0; it < g.size; it++) T[it] = -1 * T[it];
}, o = function(H) {
var $ = [], _ = new e(), Q = /* @__PURE__ */ new Set(), j = 0;
return H.forEach(function(pt, ct) {
if (!Q.has(ct)) {
$[j] = [];
var it = ct;
for (_.push(it), Q.add(it), $[j].push(it); _.length != 0; )
it = _.shift(), H.get(it).forEach(function(dt) {
Q.has(dt.id) || (_.push(dt.id), Q.add(dt.id), $[j].push(dt.id));
});
j++;
}
}), $;
}, m = function(H) {
var $ = /* @__PURE__ */ new Map();
return H.forEach(function(_, Q) {
$.set(Q, []);
}), H.forEach(function(_, Q) {
_.forEach(function(j) {
$.get(Q).push(j), $.get(j.id).push({
id: Q,
gap: j.gap,
direction: j.direction
});
});
}), $;
}, u = function(H) {
var $ = /* @__PURE__ */ new Map();
return H.forEach(function(_, Q) {
$.set(Q, []);
}), H.forEach(function(_, Q) {
_.forEach(function(j) {
$.get(j.id).push({
id: Q,
gap: j.gap,
direction: j.direction
});
});
}), $;
}, E = [], y = [], C = !1, M = !1, G = /* @__PURE__ */ new Set(), O = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new Map(), W = [];
if (l.fixedNodeConstraint && l.fixedNodeConstraint.forEach(function(D) {
G.add(D.nodeId);
}), l.relativePlacementConstraint && (l.relativePlacementConstraint.forEach(function(D) {
D.left ? (O.has(D.left) ? O.get(D.left).push({
id: D.right,
gap: D.gap,
direction: "horizontal"
}) : O.set(D.left, [{
id: D.right,
gap: D.gap,
direction: "horizontal"
}]), O.has(D.right) || O.set(D.right, [])) : (O.has(D.top) ? O.get(D.top).push({
id: D.bottom,
gap: D.gap,
direction: "vertical"
}) : O.set(D.top, [{
id: D.bottom,
gap: D.gap,
direction: "vertical"
}]), O.has(D.bottom) || O.set(D.bottom, []));
}), R = m(O), W = o(R)), h.TRANSFORM_ON_CONSTRAINT_HANDLING) {
if (l.fixedNodeConstraint && l.fixedNodeConstraint.length > 1)
l.fixedNodeConstraint.forEach(function(D, H) {
E[H] = [D.position.x, D.position.y], y[H] = [c[g.get(D.nodeId)], T[g.get(D.nodeId)]];
}), C = !0;
else if (l.alignmentConstraint) (function() {
var D = 0;
if (l.alignmentConstraint.vertical) {
for (var H = l.alignmentConstraint.vertical, $ = function(it) {
var dt = /* @__PURE__ */ new Set();
H[it].forEach(function(et) {
dt.add(et);
});
var Lt = new Set([].concat(a(dt)).filter(function(et) {
return G.has(et);
})), Mt = void 0;
Lt.size > 0 ? Mt = c[g.get(Lt.values().next().value)] : Mt = z(dt).x, H[it].forEach(function(et) {
E[D] = [Mt, T[g.get(et)]], y[D] = [c[g.get(et)], T[g.get(et)]], D++;
});
}, _ = 0; _ < H.length; _++) $(_);
C = !0;
}
if (l.alignmentConstraint.horizontal) {
for (var Q = l.alignmentConstraint.horizontal, j = function(it) {
var dt = /* @__PURE__ */ new Set();
Q[it].forEach(function(et) {
dt.add(et);
});
var Lt = new Set([].concat(a(dt)).filter(function(et) {
return G.has(et);
})), Mt = void 0;
Lt.size > 0 ? Mt = c[g.get(Lt.values().next().value)] : Mt = z(dt).y, Q[it].forEach(function(et) {
E[D] = [c[g.get(et)], Mt], y[D] = [c[g.get(et)], T[g.get(et)]], D++;
});
}, pt = 0; pt < Q.length; pt++) j(pt);
C = !0;
}
l.relativePlacementConstraint && (M = !0);
})();
else if (l.relativePlacementConstraint) {
for (var B = 0, rt = 0, K = 0; K < W.length; K++) W[K].length > B && (B = W[K].length, rt = K);
if (B < R.size / 2)
tt(l.relativePlacementConstraint), C = !1, M = !1;
else {
var P = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map(), X = [];
W[rt].forEach(function(D) {
O.get(D).forEach(function(H) {
H.direction == "horizontal" ? (P.has(D) ? P.get(D).push(H) : P.set(D, [H]), P.has(H.id) || P.set(H.id, []), X.push({
left: D,
right: H.id
})) : (b.has(D) ? b.get(D).push(H) : b.set(D, [H]), b.has(H.id) || b.set(H.id, []), X.push({
top: D,
bottom: H.id
}));
});
}), tt(X), M = !1;
var J = x(P, "horizontal"), at = x(b, "vertical");
W[rt].forEach(function(D, H) {
y[H] = [c[g.get(D)], T[g.get(D)]], E[H] = [], J.has(D) ? E[H][0] = J.get(D) : E[H][0] = c[g.get(D)], at.has(D) ? E[H][1] = at.get(D) : E[H][1] = T[g.get(D)];
}), C = !0;
}
}
if (C) {
for (var q = void 0, Z = d.transpose(E), Et = d.transpose(y), ft = 0; ft < Z.length; ft++)
Z[ft] = d.multGamma(Z[ft]), Et[ft] = d.multGamma(Et[ft]);
var k = d.multMat(Z, d.transpose(Et)), mt = r.svd(k);
q = d.multMat(mt.V, d.transpose(mt.U));
for (var ot = 0; ot < g.size; ot++) {
var wt = [c[ot], T[ot]], Wt = [q[0][0], q[1][0]], Dt = [q[0][1], q[1][1]];
c[ot] = d.dotProduct(wt, Wt), T[ot] = d.dotProduct(wt, Dt);
}
M && tt(l.relativePlacementConstraint);
}
}
if (h.ENFORCE_CONSTRAINTS) {
if (l.fixedNodeConstraint && l.fixedNodeConstraint.length > 0) {
var xt = {
x: 0,
y: 0
};
l.fixedNodeConstraint.forEach(function(D, H) {
var $ = {
x: c[g.get(D.nodeId)],
y: T[g.get(D.nodeId)]
}, _ = D.position, Q = V(_, $);
xt.x += Q.x, xt.y += Q.y;
}), xt.x /= l.fixedNodeConstraint.length, xt.y /= l.fixedNodeConstraint.length, c.forEach(function(D, H) {
c[H] += xt.x;
}), T.forEach(function(D, H) {
T[H] += xt.y;
}), l.fixedNodeConstraint.forEach(function(D) {
c[g.get(D.nodeId)] = D.position.x, T[g.get(D.nodeId)] = D.position.y;
});
}
if (l.alignmentConstraint) {
if (l.alignmentConstraint.vertical)
for (var Gt = l.alignmentConstraint.vertical, Vt = function(H) {
var $ = /* @__PURE__ */ new Set();
Gt[H].forEach(function(j) {
$.add(j);
});
var _ = new Set([].concat(a($)).filter(function(j) {
return G.has(j);
})), Q = void 0;
_.size > 0 ? Q = c[g.get(_.values().next().value)] : Q = z($).x, $.forEach(function(j) {
G.has(j) || (c[g.get(j)] = Q);
});
}, Ft = 0; Ft < Gt.length; Ft++) Vt(Ft);
if (l.alignmentConstraint.horizontal)
for (var $t = l.alignmentConstraint.horizontal, Yt = function(H) {
var $ = /* @__PURE__ */ new Set();
$t[H].forEach(function(j) {
$.add(j);
});
var _ = new Set([].concat(a($)).filter(function(j) {
return G.has(j);
})), Q = void 0;
_.size > 0 ? Q = T[g.get(_.values().next().value)] : Q = z($).y, $.forEach(function(j) {
G.has(j) || (T[g.get(j)] = Q);
});
}, Bt = 0; Bt < $t.length; Bt++) Yt(Bt);
}
l.relativePlacementConstraint && (function() {
var D = /* @__PURE__ */ new Map(), H = /* @__PURE__ */ new Map(), $ = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map(), Q = /* @__PURE__ */ new Map(), j = /* @__PURE__ */ new Map(), pt = /* @__PURE__ */ new Set(), ct = /* @__PURE__ */ new Set();
if (G.forEach(function(Pt) {
pt.add(Pt), ct.add(Pt);
}), l.alignmentConstraint) {
if (l.alignmentConstraint.vertical)
for (var it = l.alignmentConstraint.vertical, dt = function(vt) {
$.set("dummy" + vt, []), it[vt].forEach(function(At) {
D.set(At, "dummy" + vt), $.get("dummy" + vt).push(At), G.has(At) && pt.add("dummy" + vt);
}), Q.set("dummy" + vt, c[g.get(it[vt][0])]);
}, Lt = 0; Lt < it.length; Lt++) dt(Lt);
if (l.alignmentConstraint.horizontal)
for (var Mt = l.alignmentConstraint.horizontal, et = function(vt) {
_.set("dummy" + vt, []), Mt[vt].forEach(function(At) {
H.set(At, "dummy" + vt), _.get("dummy" + vt).push(At), G.has(At) && ct.add("dummy" + vt);
}), j.set("dummy" + vt, T[g.get(Mt[vt][0])]);
}, Nt = 0; Nt < Mt.length; Nt++) et(Nt);
}
var st = /* @__PURE__ */ new Map(), nt = /* @__PURE__ */ new Map(), ht = function(vt) {
O.get(vt).forEach(function(At) {
var Zt = void 0, zt = void 0;
At.direction == "horizontal" ? (Zt = D.get(vt) ? D.get(vt) : vt, D.get(At.id) ? zt = {
id: D.get(At.id),
gap: At.gap,
direction: At.direction
} : zt = At, st.has(Zt) ? st.get(Zt).push(zt) : st.set(Zt, [zt]), st.has(zt.id) || st.set(zt.id, [])) : (Zt = H.get(vt) ? H.get(vt) : vt, H.get(At.id) ? zt = {
id: H.get(At.id),
gap: At.gap,
direction: At.direction
} : zt = At, nt.has(Zt) ? nt.get(Zt).push(zt) : nt.set(Zt, [zt]), nt.has(zt.id) || nt.set(zt.id, []));
});
}, yt = !0, ut = !1, Rt = void 0;
try {
for (var It = O.keys()[Symbol.iterator](), bt; !(yt = (bt = It.next()).done); yt = !0) {
var Ot = bt.value;
ht(Ot);
}
} catch (Pt) {
ut = !0, Rt = Pt;
} finally {
try {
!yt && It.return && It.return();
} finally {
if (ut) throw Rt;
}
}
var Tt = m(st), Xt = m(nt), St = o(Tt), Ut = o(Xt), Jt = u(st), oe = u(nt), Qt = [], Kt = [];
St.forEach(function(Pt, vt) {
Qt[vt] = [], Pt.forEach(function(At) {
Jt.get(At).length == 0 && Qt[vt].push(At);
});
}), Ut.forEach(function(Pt, vt) {
Kt[vt] = [], Pt.forEach(function(At) {
oe.get(At).length == 0 && Kt[vt].push(At);
});
});
var jt = x(st, "horizontal", pt, Q, Qt), qt = x(nt, "vertical", ct, j, Kt), ae = function(vt) {
$.get(vt) ? $.get(vt).forEach(function(At) {
c[g.get(At)] = jt.get(vt);
}) : c[g.get(vt)] = jt.get(vt);
}, _t = !0, te = !1, me = void 0;
try {
for (var se = jt.keys()[Symbol.iterator](), Ee; !(_t = (Ee = se.next()).done); _t = !0) {
var he = Ee.value;
ae(he);
}
} catch (Pt) {
te = !0, me = Pt;
} finally {
try {
!_t && se.return && se.return();
} finally {
if (te) throw me;
}
}
var We = function(vt) {
_.get(vt) ? _.get(vt).forEach(function(At) {
T[g.get(At)] = qt.get(vt);
}) : T[g.get(vt)] = qt.get(vt);
}, le = !0, Te = !1, Ne = void 0;
try {
for (var fe = qt.keys()[Symbol.iterator](), Le; !(le = (Le = fe.next()).done); le = !0) {
var he = Le.value;
We(he);
}
} catch (Pt) {
Te = !0, Ne = Pt;
} finally {
try {
!le && fe.return && fe.return();
} finally {
if (Te) throw Ne;
}
}
})();
}
for (var Ct = 0; Ct < A.length; Ct++) {
var gt = A[Ct];
gt.getChild() == null && gt.setCenter(c[g.get(gt.id)], T[g.get(gt.id)]);
}
}, s.exports = i;
}),
551: ((s) => {
s.exports = w;
})
}, N = {};
function v(s) {
var n = N[s];
if (n !== void 0) return n.exports;
var t = N[s] = { exports: {} };
return U[s](t, t.exports, v), t.exports;
}
return v(45);
})();
});
})), hr = /* @__PURE__ */ de(((L, F) => {
(function(U, N) {
typeof L == "object" && typeof F == "object" ? F.exports = N(Ce()) : typeof define == "function" && define.amd ? define(["cose-base"], N) : typeof L == "object" ? L.cytoscapeFcose = N(Ce()) : U.cytoscapeFcose = N(U.coseBase);
})(L, function(w) {
return (() => {
"use strict";
var U = {
658: ((s) => {
s.exports = Object.assign != null ? Object.assign.bind(Object) : function(n) {
for (var t = arguments.length, a = Array(t > 1 ? t - 1 : 0), h = 1; h < t; h++) a[h - 1] = arguments[h];
return a.forEach(function(e) {
Object.keys(e).forEach(function(d) {
return n[d] = e[d];
});
}), n;
};
}),
548: ((s, n, t) => {
var a = /* @__PURE__ */ (function() {
function d(r, i) {
var f = [], l = !0, p = !1, g = void 0;
try {
for (var c = r[Symbol.iterator](), T; !(l = (T = c.next()).done) && (f.push(T.value), !(i && f.length === i)); l = !0)
;
} catch (A) {
p = !0, g = A;
} finally {
try {
!l && c.return && c.return();
} finally {
if (p) throw g;
}
}
return f;
}
return function(r, i) {
if (Array.isArray(r)) return r;
if (Symbol.iterator in Object(r)) return d(r, i);
throw new TypeError("Invalid attempt to destructure non-iterable instance");
};
})(), h = t(140).layoutBase.LinkedList, e = {};
e.getTopMostNodes = function(d) {
for (var r = {}, i = 0; i < d.length; i++) r[d[i].id()] = !0;
return d.filter(function(f, l) {
typeof f == "number" && (f = l);
for (var p = f.parent()[0]; p != null; ) {
if (r[p.id()]) return !1;
p = p.parent()[0];
}
return !0;
});
}, e.connectComponents = function(d, r, i, f) {
var l = new h(), p = /* @__PURE__ */ new Set(), g = [], c = void 0, T = void 0, A = void 0, I = !1, S = 1, Y = [], V = [], z = function() {
var tt = d.collection();
V.push(tt);
var o = i[0], m = d.collection();
m.merge(o).merge(o.descendants().intersection(r)), g.push(o), m.forEach(function(y) {
l.push(y), p.add(y), tt.merge(y);
});
for (var u = function() {
o = l.shift();
var C = d.collection();
o.neighborhood().nodes().forEach(function(O) {
r.intersection(o.edgesWith(O)).length > 0 && C.merge(O);
});
for (var M = 0; M < C.length; M++) {
var G = C[M];
c = i.intersection(G.union(G.ancestors())), c != null && !p.has(c[0]) && c.union(c.descendants()).forEach(function(O) {
l.push(O), p.add(O), tt.merge(O), i.has(O) && g.push(O);
});
}
}; l.length != 0; ) u();
if (tt.forEach(function(y) {
r.intersection(y.connectedEdges()).forEach(function(C) {
tt.has(C.source()) && tt.has(C.target()) && tt.merge(C);
});
}), g.length == i.length && (I = !0), !I || I && S > 1) {
T = g[0], A = T.connectedEdges().length, g.forEach(function(y) {
y.connectedEdges().length < A && (A = y.connectedEdges().length, T = y);
}), Y.push(T.id());
var E = d.collection();
E.merge(g[0]), g.forEach(function(y) {
E.merge(y);
}), g = [], i = i.difference(E), S++;
}
};
do
z();
while (!I);
return f && Y.length > 0 && f.set("dummy" + (f.size + 1), Y), V;
}, e.relocateComponent = function(d, r, i) {
if (!i.fixedNodeConstraint) {
var f = Number.POSITIVE_INFINITY, l = Number.NEGATIVE_INFINITY, p = Number.POSITIVE_INFINITY, g = Number.NEGATIVE_INFINITY;
if (i.quality == "draft") {
var c = !0, T = !1, A = void 0;
try {
for (var I = r.nodeIndexes[Symbol.iterator](), S; !(c = (S = I.next()).done); c = !0) {
var Y = S.value, V = a(Y, 2), z = V[0], x = V[1], tt = i.cy.getElementById(z);
if (tt) {
var o = tt.boundingBox(), m = r.xCoords[x] - o.w / 2, u = r.xCoords[x] + o.w / 2, E = r.yCoords[x] - o.h / 2, y = r.yCoords[x] + o.h / 2;
m < f && (f = m), u > l && (l = u), E < p && (p = E), y > g && (g = y);
}
}
} catch (R) {
T = !0, A = R;
} finally {
try {
!c && I.return && I.return();
} finally {
if (T) throw A;
}
}
var C = d.x - (l + f) / 2, M = d.y - (g + p) / 2;
r.xCoords = r.xCoords.map(function(R) {
return R + C;
}), r.yCoords = r.yCoords.map(function(R) {
return R + M;
});
} else {
Object.keys(r).forEach(function(R) {
var W = r[R], B = W.getRect().x, rt = W.getRect().x + W.getRect().width, K = W.getRect().y, P = W.getRect().y + W.getRect().height;
B < f && (f = B), rt > l && (l = rt), K < p && (p = K), P > g && (g = P);
});
var G = d.x - (l + f) / 2, O = d.y - (g + p) / 2;
Object.keys(r).forEach(function(R) {
var W = r[R];
W.setCenter(W.getCenterX() + G, W.getCenterY() + O);
});
}
}
}, e.calcBoundingBox = function(d, r, i, f) {
for (var l = Number.MAX_SAFE_INTEGER, p = Number.MIN_SAFE_INTEGER, g = Number.MAX_SAFE_INTEGER, c = Number.MIN_SAFE_INTEGER, T = void 0, A = void 0, I = void 0, S = void 0, Y = d.descendants().not(":parent"), V = Y.length, z = 0; z < V; z++) {
var x = Y[z];
T = r[f.get(x.id())] - x.width() / 2, A = r[f.get(x.id())] + x.width() / 2, I = i[f.get(x.id())] - x.height() / 2, S = i[f.get(x.id())] + x.height() / 2, l > T && (l = T), p < A && (p = A), g > I && (g = I), c < S && (c = S);
}
var tt = {};
return tt.topLeftX = l, tt.topLeftY = g, tt.width = p - l, tt.height = c - g, tt;
}, e.calcParentsWithoutChildren = function(d, r) {
var i = d.collection();
return r.nodes(":parent").forEach(function(f) {
var l = !1;
f.children().forEach(function(p) {
p.css("display") != "none" && (l = !0);
}), l || i.merge(f);
}), i;
}, s.exports = e;
}),
816: ((s, n, t) => {
var a = t(548), h = t(140).CoSELayout, e = t(140).CoSENode, d = t(140).layoutBase.PointD, r = t(140).layoutBase.DimensionD, i = t(140).layoutBase.LayoutConstants, f = t(140).layoutBase.FDLayoutConstants, l = t(140).CoSEConstants;
s.exports = { coseLayout: function(g, c) {
var T = g.cy, A = g.eles, I = A.nodes(), S = A.edges(), Y = void 0, V = void 0, z = void 0, x = {};
g.randomize && (Y = c.nodeIndexes, V = c.xCoords, z = c.yCoords);
var tt = function(O) {
return typeof O == "function";
}, o = function(O, R) {
return tt(O) ? O(R) : O;
}, m = a.calcParentsWithoutChildren(T, A), u = function G(O, R, W, B) {
for (var rt = R.length, K = 0; K < rt; K++) {
var P = R[K], b = null;
P.intersection(m).length == 0 && (b = P.children());
var X = void 0, J = P.layoutDimensions({ nodeDimensionsIncludeLabels: B.nodeDimensionsIncludeLabels });
if (P.outerWidth() != null && P.outerHeight() != null) if (B.randomize) if (!P.isParent()) X = O.add(new e(W.graphManager, new d(V[Y.get(P.id())] - J.w / 2, z[Y.get(P.id())] - J.h / 2), new r(parseFloat(J.w), parseFloat(J.h))));
else {
var at = a.calcBoundingBox(P, V, z, Y);
P.intersection(m).length == 0 ? X = O.add(new e(W.graphManager, new d(at.topLeftX, at.topLeftY), new r(at.width, at.height))) : X = O.add(new e(W.graphManager, new d(at.topLeftX, at.topLeftY), new r(parseFloat(J.w), parseFloat(J.h))));
}
else X = O.add(new e(W.graphManager, new d(P.position("x") - J.w / 2, P.position("y") - J.h / 2), new r(parseFloat(J.w), parseFloat(J.h))));
else X = O.add(new e(this.graphManager));
if (X.id = P.data("id"), X.nodeRepulsion = o(B.nodeRepulsion, P), X.paddingLeft = parseInt(P.css("padding")), X.paddingTop = parseInt(P.css("padding")), X.paddingRight = parseInt(P.css("padding")), X.paddingBottom = parseInt(P.css("padding")), B.nodeDimensionsIncludeLabels && (X.labelWidth = P.boundingBox({
includeLabels: !0,
includeNodes: !1,
includeOverlays: !1
}).w, X.labelHeight = P.boundingBox({
includeLabels: !0,
includeNodes: !1,
includeOverlays: !1
}).h, X.labelPosVertical = P.css("text-valign"), X.labelPosHorizontal = P.css("text-halign")), x[P.data("id")] = X, isNaN(X.rect.x) && (X.rect.x = 0), isNaN(X.rect.y) && (X.rect.y = 0), b != null && b.length > 0) {
var q = void 0;
q = W.getGraphManager().add(W.newGraph(), X), G(q, b, W, B);
}
}
}, E = function(O, R, W) {
for (var B = 0, rt = 0, K = 0; K < W.length; K++) {
var P = W[K], b = x[P.data("source")], X = x[P.data("target")];
if (b && X && b !== X && b.getEdgesBetween(X).length == 0) {
var J = R.add(O.newEdge(), b, X);
J.id = P.id(), J.idealLength = o(g.idealEdgeLength, P), J.edgeElasticity = o(g.edgeElasticity, P), B += J.idealLength, rt++;
}
}
g.idealEdgeLength != null && (rt > 0 ? l.DEFAULT_EDGE_LENGTH = f.DEFAULT_EDGE_LENGTH = B / rt : tt(g.idealEdgeLength) ? l.DEFAULT_EDGE_LENGTH = f.DEFAULT_EDGE_LENGTH = 50 : l.DEFAULT_EDGE_LENGTH = f.DEFAULT_EDGE_LENGTH = g.idealEdgeLength, l.MIN_REPULSION_DIST = f.MIN_REPULSION_DIST = f.DEFAULT_EDGE_LENGTH / 10, l.DEFAULT_RADIAL_SEPARATION = f.DEFAULT_EDGE_LENGTH);
}, y = function(O, R) {
R.fixedNodeConstraint && (O.constraints.fixedNodeConstraint = R.fixedNodeConstraint), R.alignmentConstraint && (O.constraints.alignmentConstraint = R.alignmentConstraint), R.relativePlacementConstraint && (O.constraints.relativePlacementConstraint = R.relativePlacementConstraint);
};
g.nestingFactor != null && (l.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = f.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = g.nestingFactor), g.gravity != null && (l.DEFAULT_GRAVITY_STRENGTH = f.DEFAULT_GRAVITY_STRENGTH = g.gravity), g.numIter != null && (l.MAX_ITERATIONS = f.MAX_ITERATIONS = g.numIter), g.gravityRange != null && (l.DEFAULT_GRAVITY_RANGE_FACTOR = f.DEFAULT_GRAVITY_RANGE_FACTOR = g.gravityRange), g.gravityCompound != null && (l.DEFAULT_COMPOUND_GRAVITY_STRENGTH = f.DEFAULT_COMPOUND_GRAVITY_STRENGTH = g.gravityCompound), g.gravityRangeCompound != null && (l.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = f.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = g.gravityRangeCompound), g.initialEnergyOnIncremental != null && (l.DEFAULT_COOLING_FACTOR_INCREMENTAL = f.DEFAULT_COOLING_FACTOR_INCREMENTAL = g.initialEnergyOnIncremental), g.tilingCompareBy != null && (l.TILING_COMPARE_BY = g.tilingCompareBy), g.quality == "proof" ? i.QUALITY = 2 : i.QUALITY = 0, l.NODE_DIMENSIONS_INCLUDE_LABELS = f.NODE_DIMENSIONS_INCLUDE_LABELS = i.NODE_DIMENSIONS_INCLUDE_LABELS = g.nodeDimensionsIncludeLabels, l.DEFAULT_INCREMENTAL = f.DEFAULT_INCREMENTAL = i.DEFAULT_INCREMENTAL = !g.randomize, l.ANIMATE = f.ANIMATE = i.ANIMATE = g.animate, l.TILE = g.tile, l.TILING_PADDING_VERTICAL = typeof g.tilingPaddingVertical == "function" ? g.tilingPaddingVertical.call() : g.tilingPaddingVertical, l.TILING_PADDING_HORIZONTAL = typeof g.tilingPaddingHorizontal == "function" ? g.tilingPaddingHorizontal.call() : g.tilingPaddingHorizontal, l.DEFAULT_INCREMENTAL = f.DEFAULT_INCREMENTAL = i.DEFAULT_INCREMENTAL = !0, l.PURE_INCREMENTAL = !g.randomize, i.DEFAULT_UNIFORM_LEAF_NODE_SIZES = g.uniformNodeDimensions, g.step == "transformed" && (l.TRANSFORM_ON_CONSTRAINT_HANDLING = !0, l.ENFORCE_CONSTRAINTS = !1, l.APPLY_LAYOUT = !1), g.step == "enforced" && (l.TRANSFORM_ON_CONSTRAINT_HANDLING = !1, l.ENFORCE_CONSTRAINTS = !0, l.APPLY_LAYOUT = !1), g.step == "cose" && (l.TRANSFORM_ON_CONSTRAINT_HANDLING = !1, l.ENFORCE_CONSTRAINTS = !1, l.APPLY_LAYOUT = !0), g.step == "all" && (g.randomize ? l.TRANSFORM_ON_CONSTRAINT_HANDLING = !0 : l.TRANSFORM_ON_CONSTRAINT_HANDLING = !1, l.ENFORCE_CONSTRAINTS = !0, l.APPLY_LAYOUT = !0), g.fixedNodeConstraint || g.alignmentConstraint || g.relativePlacementConstraint ? l.TREE_REDUCTION_ON_INCREMENTAL = !1 : l.TREE_REDUCTION_ON_INCREMENTAL = !0;
var C = new h(), M = C.newGraphManager();
return u(M.addRoot(), a.getTopMostNodes(I), C, g), E(C, M, S), y(C, g), C.runLayout(), x;
} };
}),
212: ((s, n, t) => {
var a = /* @__PURE__ */ (function() {
function l(p, g) {
for (var c = 0; c < g.length; c++) {
var T = g[c];
T.enumerable = T.enumerable || !1, T.configurable = !0, "value" in T && (T.writable = !0), Object.defineProperty(p, T.key, T);
}
}
return function(p, g, c) {
return g && l(p.prototype, g), c && l(p, c), p;
};
})();
function h(l, p) {
if (!(l instanceof p)) throw new TypeError("Cannot call a class as a function");
}
var e = t(658), d = t(548), r = t(657).spectralLayout, i = t(816).coseLayout, f = Object.freeze({
quality: "default",
randomize: !0,
animate: !0,
animationDuration: 1e3,
animationEasing: void 0,
fit: !0,
padding: 30,
nodeDimensionsIncludeLabels: !1,
uniformNodeDimensions: !1,
packComponents: !0,
step: "all",
samplingType: !0,
sampleSize: 25,
nodeSeparation: 75,
piTol: 1e-7,
nodeRepulsion: function(p) {
return 4500;
},
idealEdgeLength: function(p) {
return 50;
},
edgeElasticity: function(p) {
return 0.45;
},
nestingFactor: 0.1,
gravity: 0.25,
numIter: 2500,
tile: !0,
tilingCompareBy: void 0,
tilingPaddingVertical: 10,
tilingPaddingHorizontal: 10,
gravityRangeCompound: 1.5,
gravityCompound: 1,
gravityRange: 3.8,
initialEnergyOnIncremental: 0.3,
fixedNodeConstraint: void 0,
alignmentConstraint: void 0,
relativePlacementConstraint: void 0,
ready: function() {
},
stop: function() {
}
});
s.exports = (function() {
function l(p) {
h(this, l), this.options = e({}, f, p);
}
return a(l, [{
key: "run",
value: function() {
var g = this, c = this.options, T = c.cy, A = c.eles, I = [], S = [], Y = void 0, V = [];
c.fixedNodeConstraint && (!Array.isArray(c.fixedNodeConstraint) || c.fixedNodeConstraint.length == 0) && (c.fixedNodeConstraint = void 0), c.alignmentConstraint && (c.alignmentConstraint.vertical && (!Array.isArray(c.alignmentConstraint.vertical) || c.alignmentConstraint.vertical.length == 0) && (c.alignmentConstraint.vertical = void 0), c.alignmentConstraint.horizontal && (!Array.isArray(c.alignmentConstraint.horizontal) || c.alignmentConstraint.horizontal.length == 0) && (c.alignmentConstraint.horizontal = void 0)), c.relativePlacementConstraint && (!Array.isArray(c.relativePlacementConstraint) || c.relativePlacementConstraint.length == 0) && (c.relativePlacementConstraint = void 0), (c.fixedNodeConstraint || c.alignmentConstraint || c.relativePlacementConstraint) && (c.tile = !1, c.packComponents = !1);
var z = void 0, x = !1;
if (T.layoutUtilities && c.packComponents && (z = T.layoutUtilities("get"), z || (z = T.layoutUtilities()), x = !0), A.nodes().length > 0) if (x) {
var m = d.getTopMostNodes(c.eles.nodes());
if (Y = d.connectComponents(T, c.eles, m), Y.forEach(function(q) {
var Z = q.boundingBox();
V.push({
x: Z.x1 + Z.w / 2,
y: Z.y1 + Z.h / 2
});
}), c.randomize && Y.forEach(function(q) {
c.eles = q, I.push(r(c));
}), c.quality == "default" || c.quality == "proof") {
var u = T.collection();
if (c.tile) {
var E = /* @__PURE__ */ new Map(), y = [], C = [], M = 0, G = {
nodeIndexes: E,
xCoords: y,
yCoords: C
}, O = [];
if (Y.forEach(function(q, Z) {
q.edges().length == 0 && (q.nodes().forEach(function(Et, ft) {
u.merge(q.nodes()[ft]), Et.isParent() || (G.nodeIndexes.set(q.nodes()[ft].id(), M++), G.xCoords.push(q.nodes()[0].position().x), G.yCoords.push(q.nodes()[0].position().y));
}), O.push(Z));
}), u.length > 1) {
var R = u.boundingBox();
V.push({
x: R.x1 + R.w / 2,
y: R.y1 + R.h / 2
}), Y.push(u), I.push(G);
for (var W = O.length - 1; W >= 0; W--)
Y.splice(O[W], 1), I.splice(O[W], 1), V.splice(O[W], 1);
}
}
Y.forEach(function(q, Z) {
c.eles = q, S.push(i(c, I[Z])), d.relocateComponent(V[Z], S[Z], c);
});
} else Y.forEach(function(q, Z) {
d.relocateComponent(V[Z], I[Z], c);
});
var B = /* @__PURE__ */ new Set();
if (Y.length > 1) {
var rt = [], K = A.filter(function(q) {
return q.css("display") == "none";
});
Y.forEach(function(q, Z) {
var Et = void 0;
if (c.quality == "draft" && (Et = I[Z].nodeIndexes), q.nodes().not(K).length > 0) {
var ft = {};
ft.edges = [], ft.nodes = [];
var k = void 0;
q.nodes().not(K).forEach(function(mt) {
if (c.quality == "draft") if (!mt.isParent())
k = Et.get(mt.id()), ft.nodes.push({
x: I[Z].xCoords[k] - mt.boundingbox().w / 2,
y: I[Z].yCoords[k] - mt.boundingbox().h / 2,
width: mt.boundingbox().w,
height: mt.boundingbox().h
});
else {
var ot = d.calcBoundingBox(mt, I[Z].xCoords, I[Z].yCoords, Et);
ft.nodes.push({
x: ot.topLeftX,
y: ot.topLeftY,
width: ot.width,
height: ot.height
});
}
else S[Z][mt.id()] && ft.nodes.push({
x: S[Z][mt.id()].getLeft(),
y: S[Z][mt.id()].getTop(),
width: S[Z][mt.id()].getWidth(),
height: S[Z][mt.id()].getHeight()
});
}), q.edges().forEach(function(mt) {
var ot = mt.source(), wt = mt.target();
if (ot.css("display") != "none" && wt.css("display") != "none")
if (c.quality == "draft") {
var Wt = Et.get(ot.id()), Dt = Et.get(wt.id()), xt = [], Gt = [];
if (ot.isParent()) {
var Vt = d.calcBoundingBox(ot, I[Z].xCoords, I[Z].yCoords, Et);
xt.push(Vt.topLeftX + Vt.width / 2), xt.push(Vt.topLeftY + Vt.height / 2);
} else
xt.push(I[Z].xCoords[Wt]), xt.push(I[Z].yCoords[Wt]);
if (wt.isParent()) {
var Ft = d.calcBoundingBox(wt, I[Z].xCoords, I[Z].yCoords, Et);
Gt.push(Ft.topLeftX + Ft.width / 2), Gt.push(Ft.topLeftY + Ft.height / 2);
} else
Gt.push(I[Z].xCoords[Dt]), Gt.push(I[Z].yCoords[Dt]);
ft.edges.push({
startX: xt[0],
startY: xt[1],
endX: Gt[0],
endY: Gt[1]
});
} else S[Z][ot.id()] && S[Z][wt.id()] && ft.edges.push({
startX: S[Z][ot.id()].getCenterX(),
startY: S[Z][ot.id()].getCenterY(),
endX: S[Z][wt.id()].getCenterX(),
endY: S[Z][wt.id()].getCenterY()
});
}), ft.nodes.length > 0 && (rt.push(ft), B.add(Z));
}
});
var P = z.packComponents(rt, c.randomize).shifts;
if (c.quality == "draft") I.forEach(function(q, Z) {
var Et = q.xCoords.map(function(k) {
return k + P[Z].dx;
}), ft = q.yCoords.map(function(k) {
return k + P[Z].dy;
});
q.xCoords = Et, q.yCoords = ft;
});
else {
var b = 0;
B.forEach(function(q) {
Object.keys(S[q]).forEach(function(Z) {
var Et = S[q][Z];
Et.setCenter(Et.getCenterX() + P[b].dx, Et.getCenterY() + P[b].dy);
}), b++;
});
}
}
} else {
var tt = c.eles.boundingBox();
if (V.push({
x: tt.x1 + tt.w / 2,
y: tt.y1 + tt.h / 2
}), c.randomize) {
var o = r(c);
I.push(o);
}
c.quality == "default" || c.quality == "proof" ? (S.push(i(c, I[0])), d.relocateComponent(V[0], S[0], c)) : d.relocateComponent(V[0], I[0], c);
}
var X = function(Z, Et) {
if (c.quality == "default" || c.quality == "proof") {
typeof Z == "number" && (Z = Et);
var ft = void 0, k = void 0, mt = Z.data("id");
return S.forEach(function(wt) {
mt in wt && (ft = {
x: wt[mt].getRect().getCenterX(),
y: wt[mt].getRect().getCenterY()
}, k = wt[mt]);
}), c.nodeDimensionsIncludeLabels && (k.labelWidth && (k.labelPosHorizontal == "left" ? ft.x += k.labelWidth / 2 : k.labelPosHorizontal == "right" && (ft.x -= k.labelWidth / 2)), k.labelHeight && (k.labelPosVertical == "top" ? ft.y += k.labelHeight / 2 : k.labelPosVertical == "bottom" && (ft.y -= k.labelHeight / 2))), ft == null && (ft = {
x: Z.position("x"),
y: Z.position("y")
}), {
x: ft.x,
y: ft.y
};
} else {
var ot = void 0;
return I.forEach(function(wt) {
var Wt = wt.nodeIndexes.get(Z.id());
Wt != null && (ot = {
x: wt.xCoords[Wt],
y: wt.yCoords[Wt]
});
}), ot == null && (ot = {
x: Z.position("x"),
y: Z.position("y")
}), {
x: ot.x,
y: ot.y
};
}
};
if (c.quality == "default" || c.quality == "proof" || c.randomize) {
var J = d.calcParentsWithoutChildren(T, A), at = A.filter(function(q) {
return q.css("display") == "none";
});
c.eles = A.not(at), A.nodes().not(":parent").not(at).layoutPositions(g, c, X), J.length > 0 && J.forEach(function(q) {
q.position(X(q));
});
}
}
}]), l;
})();
}),
657: ((s, n, t) => {
var a = t(548), h = t(140).layoutBase.Matrix, e = t(140).layoutBase.SVD;
s.exports = { spectralLayout: function(r) {
var i = r.cy, f = r.eles, l = f.nodes(), p = f.nodes(":parent"), g = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map(), A = [], I = [], S = [], Y = [], V = [], z = [], x = [], tt = [], o = void 0, m = 1e8, u = 1e-9, E = r.piTol, y = r.samplingType, C = r.nodeSeparation, M = void 0, G = function() {
for (var gt = 0, D = 0, H = !1; D < M; ) {
gt = Math.floor(Math.random() * o), H = !1;
for (var $ = 0; $ < D; $++) if (Y[$] == gt) {
H = !0;
break;
}
if (!H)
Y[D] = gt, D++;
else continue;
}
}, O = function(gt, D, H) {
for (var $ = [], _ = 0, Q = 0, j = 0, pt = void 0, ct = [], it = 0, dt = 1, Lt = 0; Lt < o; Lt++) ct[Lt] = m;
for ($[Q] = gt, ct[gt] = 0; Q >= _; ) {
j = $[_++];
for (var Mt = A[j], et = 0; et < Mt.length; et++)
pt = c.get(Mt[et]), ct[pt] == m && (ct[pt] = ct[j] + 1, $[++Q] = pt);
z[j][D] = ct[j] * C;
}
if (H) {
for (var Nt = 0; Nt < o; Nt++) z[Nt][D] < V[Nt] && (V[Nt] = z[Nt][D]);
for (var st = 0; st < o; st++) V[st] > it && (it = V[st], dt = st);
}
return dt;
}, R = function(gt) {
var D = void 0;
if (gt) {
D = Math.floor(Math.random() * o);
for (var $ = 0; $ < o; $++) V[$] = m;
for (var _ = 0; _ < M; _++)
Y[_] = D, D = O(D, _, gt);
} else {
G();
for (var H = 0; H < M; H++) O(Y[H], H, gt, !1);
}
for (var Q = 0; Q < o; Q++) for (var j = 0; j < M; j++) z[Q][j] *= z[Q][j];
for (var pt = 0; pt < M; pt++) x[pt] = [];
for (var ct = 0; ct < M; ct++) for (var it = 0; it < M; it++) x[ct][it] = z[Y[it]][ct];
}, W = function() {
for (var gt = e.svd(x), D = gt.S, H = gt.U, $ = gt.V, _ = D[0] * D[0] * D[0], Q = [], j = 0; j < M; j++) {
Q[j] = [];
for (var pt = 0; pt < M; pt++)
Q[j][pt] = 0, j == pt && (Q[j][pt] = D[j] / (D[j] * D[j] + _ / (D[j] * D[j])));
}
tt = h.multMat(h.multMat($, Q), h.transpose(H));
}, B = function() {
for (var gt = void 0, D = void 0, H = [], $ = [], _ = [], Q = [], j = 0; j < o; j++)
H[j] = Math.random(), $[j] = Math.random();
H = h.normalize(H), $ = h.normalize($);
for (var pt = 0, ct = u, it = u, dt = void 0; ; ) {
pt++;
for (var Lt = 0; Lt < o; Lt++) _[Lt] = H[Lt];
if (H = h.multGamma(h.multL(h.multGamma(_), z, tt)), gt = h.dotProduct(_, H), H = h.normalize(H), ct = h.dotProduct(_, H), dt = Math.abs(ct / it), dt <= 1 + E && dt >= 1) break;
it = ct;
}
for (var Mt = 0; Mt < o; Mt++) _[Mt] = H[Mt];
for (pt = 0, it = u; ; ) {
pt++;
for (var et = 0; et < o; et++) Q[et] = $[et];
if (Q = h.minusOp(Q, h.multCons(_, h.dotProduct(_, Q))), $ = h.multGamma(h.multL(h.multGamma(Q), z, tt)), D = h.dotProduct(Q, $), $ = h.normalize($), ct = h.dotProduct(Q, $), dt = Math.abs(ct / it), dt <= 1 + E && dt >= 1) break;
it = ct;
}
for (var Nt = 0; Nt < o; Nt++) Q[Nt] = $[Nt];
I = h.multCons(_, Math.sqrt(Math.abs(gt))), S = h.multCons(Q, Math.sqrt(Math.abs(D)));
};
a.connectComponents(i, f, a.getTopMostNodes(l), g), p.forEach(function(Ct) {
a.connectComponents(i, f, a.getTopMostNodes(Ct.descendants().intersection(f)), g);
});
for (var rt = 0, K = 0; K < l.length; K++) l[K].isParent() || c.set(l[K].id(), rt++);
var P = !0, b = !1, X = void 0;
try {
for (var J = g.keys()[Symbol.iterator](), at; !(P = (at = J.next()).done); P = !0) {
var q = at.value;
c.set(q, rt++);
}
} catch (Ct) {
b = !0, X = Ct;
} finally {
try {
!P && J.return && J.return();
} finally {
if (b) throw X;
}
}
for (var Z = 0; Z < c.size; Z++) A[Z] = [];
p.forEach(function(Ct) {
for (var gt = Ct.children().intersection(f); gt.nodes(":childless").length == 0; ) gt = gt.nodes()[0].children().intersection(f);
var D = 0, H = gt.nodes(":childless")[0].connectedEdges().length;
gt.nodes(":childless").forEach(function($, _) {
$.connectedEdges().length < H && (H = $.connectedEdges().length, D = _);
}), T.set(Ct.id(), gt.nodes(":childless")[D].id());
}), l.forEach(function(Ct) {
var gt = void 0;
Ct.isParent() ? gt = c.get(T.get(Ct.id())) : gt = c.get(Ct.id()), Ct.neighborhood().nodes().forEach(function(D) {
f.intersection(Ct.edgesWith(D)).length > 0 && (D.isParent() ? A[gt].push(T.get(D.id())) : A[gt].push(D.id()));
});
});
var Et = function(gt) {
var D = c.get(gt), H = void 0;
g.get(gt).forEach(function($) {
i.getElementById($).isParent() ? H = T.get($) : H = $, A[D].push(H), A[c.get(H)].push(gt);
});
}, ft = !0, k = !1, mt = void 0;
try {
for (var ot = g.keys()[Symbol.iterator](), wt; !(ft = (wt = ot.next()).done); ft = !0) {
var Wt = wt.value;
Et(Wt);
}
} catch (Ct) {
k = !0, mt = Ct;
} finally {
try {
!ft && ot.return && ot.return();
} finally {
if (k) throw mt;
}
}
o = c.size;
var Dt = void 0;
if (o > 2) {
M = o < r.sampleSize ? o : r.sampleSize;
for (var xt = 0; xt < o; xt++) z[xt] = [];
for (var Gt = 0; Gt < M; Gt++) tt[Gt] = [];
return r.quality == "draft" || r.step == "all" ? (R(y), W(), B(), Dt = {
nodeIndexes: c,
xCoords: I,
yCoords: S
}) : (c.forEach(function(Ct, gt) {
I.push(i.getElementById(gt).position("x")), S.push(i.getElementById(gt).position("y"));
}), Dt = {
nodeIndexes: c,
xCoords: I,
yCoords: S
}), Dt;
} else {
var Vt = c.keys(), Ft = i.getElementById(Vt.next().value), $t = Ft.position(), Yt = Ft.outerWidth();
if (I.push($t.x), S.push($t.y), o == 2) {
var Bt = i.getElementById(Vt.next().value).outerWidth();
I.push($t.x + Yt / 2 + Bt / 2 + r.idealEdgeLength), S.push($t.y);
}
return Dt = {
nodeIndexes: c,
xCoords: I,
yCoords: S
}, Dt;
}
} };
}),
579: ((s, n, t) => {
var a = t(212), h = function(d) {
d && d("layout", "fcose", a);
};
typeof cytoscape < "u" && h(cytoscape), s.exports = h;
}),
140: ((s) => {
s.exports = w;
})
}, N = {};
function v(s) {
var n = N[s];
if (n !== void 0) return n.exports;
var t = N[s] = { exports: {} };
return U[s](t, t.exports, v), t.exports;
}
return v(579);
})();
});
})), lr = /* @__PURE__ */ Ve(hr(), 1), Ae = {
L: "left",
R: "right",
T: "top",
B: "bottom"
}, Me = {
L: /* @__PURE__ */ lt((L) => `${L},${L / 2} 0,${L} 0,0`, "L"),
R: /* @__PURE__ */ lt((L) => `0,${L / 2} ${L},0 ${L},${L}`, "R"),
T: /* @__PURE__ */ lt((L) => `0,0 ${L},0 ${L / 2},${L}`, "T"),
B: /* @__PURE__ */ lt((L) => `${L / 2},0 ${L},${L} 0,${L}`, "B")
}, ne = {
L: /* @__PURE__ */ lt((L, F) => L - F + 2, "L"),
R: /* @__PURE__ */ lt((L, F) => L - 2, "R"),
T: /* @__PURE__ */ lt((L, F) => L - F + 2, "T"),
B: /* @__PURE__ */ lt((L, F) => L - 2, "B")
}, fr = /* @__PURE__ */ lt(function(L) {
return Ht(L) ? L === "L" ? "R" : "L" : L === "T" ? "B" : "T";
}, "getOppositeArchitectureDirection"), Oe = /* @__PURE__ */ lt(function(L) {
const F = L;
return F === "L" || F === "R" || F === "T" || F === "B";
}, "isArchitectureDirection"), Ht = /* @__PURE__ */ lt(function(L) {
const F = L;
return F === "L" || F === "R";
}, "isArchitectureDirectionX"), kt = /* @__PURE__ */ lt(function(L) {
const F = L;
return F === "T" || F === "B";
}, "isArchitectureDirectionY"), ye = /* @__PURE__ */ lt(function(L, F) {
const w = Ht(L) && kt(F), U = kt(L) && Ht(F);
return w || U;
}, "isArchitectureDirectionXY"), cr = /* @__PURE__ */ lt(function(L) {
const F = L[0], w = L[1], U = Ht(F) && kt(w), N = kt(F) && Ht(w);
return U || N;
}, "isArchitecturePairXY"), gr = /* @__PURE__ */ lt(function(L) {
return L !== "LL" && L !== "RR" && L !== "TT" && L !== "BB";
}, "isValidArchitectureDirectionPair"), ge = /* @__PURE__ */ lt(function(L, F) {
const w = `${L}${F}`;
return gr(w) ? w : void 0;
}, "getArchitectureDirectionPair"), ur = /* @__PURE__ */ lt(function([L, F], w) {
const U = w[0], N = w[1];
return Ht(U) ? kt(N) ? [L + (U === "L" ? -1 : 1), F + (N === "T" ? 1 : -1)] : [L + (U === "L" ? -1 : 1), F] : Ht(N) ? [L + (N === "L" ? 1 : -1), F + (U === "T" ? 1 : -1)] : [L, F + (U === "T" ? 1 : -1)];
}, "shiftPositionByArchitectureDirectionPair"), dr = /* @__PURE__ */ lt(function(L) {
return L === "LT" || L === "TL" ? [1, 1] : L === "BL" || L === "LB" ? [1, -1] : L === "BR" || L === "RB" ? [-1, -1] : [-1, 1];
}, "getArchitectureDirectionXYFactors"), vr = /* @__PURE__ */ lt(function(L, F) {
return ye(L, F) ? "bend" : Ht(L) ? "horizontal" : "vertical";
}, "getArchitectureDirectionAlignment"), pr = /* @__PURE__ */ lt(function(L) {
return L.type === "service";
}, "isArchitectureService"), yr = /* @__PURE__ */ lt(function(L) {
return L.type === "junction";
}, "isArchitectureJunction"), Ie = /* @__PURE__ */ lt((L) => L.data(), "edgeData"), re = /* @__PURE__ */ lt((L) => L.data(), "nodeData"), mr = Ke.architecture, Re = class {
constructor() {
this.nodes = {}, this.groups = {}, this.edges = [], this.layoutHints = [], this.registeredIds = {}, this.elements = {}, this.diagramId = "", this.setAccTitle = Qe, this.getAccTitle = tr, this.setDiagramTitle = ke, this.getDiagramTitle = _e, this.getAccDescription = je, this.setAccDescription = Be, this.clear();
}
static {
lt(this, "ArchitectureDB");
}
setDiagramId(L) {
this.diagramId = L;
}
getDiagramId() {
return this.diagramId;
}
clear() {
this.nodes = {}, this.groups = {}, this.edges = [], this.layoutHints = [], this.registeredIds = {}, this.dataStructures = void 0, this.elements = {}, this.diagramId = "", qe();
}
addService({ id: L, icon: F, in: w, title: U, iconText: N }) {
if (this.registeredIds[L] !== void 0) throw new Error(`The service id [${L}] is already in use by another ${this.registeredIds[L]}`);
if (w !== void 0) {
if (L === w) throw new Error(`The service [${L}] cannot be placed within itself`);
if (this.registeredIds[w] === void 0) throw new Error(`The service [${L}]'s parent does not exist. Please make sure the parent is created before this service`);
if (this.registeredIds[w] === "node") throw new Error(`The service [${L}]'s parent is not a group`);
}
this.registeredIds[L] = "node", this.nodes[L] = {
id: L,
type: "service",
icon: F,
iconText: N,
title: U,
edges: [],
in: w
};
}
getServices() {
return Object.values(this.nodes).filter(pr);
}
addJunction({ id: L, in: F }) {
if (this.registeredIds[L] !== void 0) throw new Error(`The junction id [${L}] is already in use by another ${this.registeredIds[L]}`);
if (F !== void 0) {
if (L === F) throw new Error(`The junction [${L}] cannot be placed within itself`);
if (this.registeredIds[F] === void 0) throw new Error(`The junction [${L}]'s parent does not exist. Please make sure the parent is created before this junction`);
if (this.registeredIds[F] === "node") throw new Error(`The junction [${L}]'s parent is not a group`);
}
this.registeredIds[L] = "node", this.nodes[L] = {
id: L,
type: "junction",
edges: [],
in: F
};
}
getJunctions() {
return Object.values(this.nodes).filter(yr);
}
getNodes() {
return Object.values(this.nodes);
}
getNode(L) {
return this.nodes[L] ?? null;
}
addGroup({ id: L, icon: F, in: w, title: U }) {
if (this.registeredIds?.[L] !== void 0) throw new Error(`The group id [${L}] is already in use by another ${this.registeredIds[L]}`);
if (w !== void 0) {
if (L === w) throw new Error(`The group [${L}] cannot be placed within itself`);
if (this.registeredIds?.[w] === void 0) throw new Error(`The group [${L}]'s parent does not exist. Please make sure the parent is created before this group`);
if (this.registeredIds?.[w] === "node") throw new Error(`The group [${L}]'s parent is not a group`);
}
this.registeredIds[L] = "group", this.groups[L] = {
id: L,
icon: F,
title: U,
in: w
};
}
getGroups() {
return Object.values(this.groups);
}
addEdge({ lhsId: L, rhsId: F, lhsDir: w, rhsDir: U, lhsInto: N, rhsInto: v, lhsGroup: s, rhsGroup: n, title: t }) {
if (!Oe(w)) throw new Error(`Invalid direction given for left hand side of edge ${L}--${F}. Expected (L,R,T,B) got ${String(w)}`);
if (!Oe(U)) throw new Error(`Invalid direction given for right hand side of edge ${L}--${F}. Expected (L,R,T,B) got ${String(U)}`);
if (this.nodes[L] === void 0 && this.groups[L] === void 0) throw new Error(`The left-hand id [${L}] does not yet exist. Please create the service/group before declaring an edge to it.`);
if (this.nodes[F] === void 0 && this.groups[F] === void 0) throw new Error(`The right-hand id [${F}] does not yet exist. Please create the service/group before declaring an edge to it.`);
const a = this.nodes[L].in, h = this.nodes[F].in;
if (s && a && h && a == h) throw new Error(`The left-hand id [${L}] is modified to traverse the group boundary, but the edge does not pass through two groups.`);
if (n && a && h && a == h) throw new Error(`The right-hand id [${F}] is modified to traverse the group boundary, but the edge does not pass through two groups.`);
const e = {
lhsId: L,
lhsDir: w,
lhsInto: N,
lhsGroup: s,
rhsId: F,
rhsDir: U,
rhsInto: v,
rhsGroup: n,
title: t
};
this.edges.push(e), this.nodes[L] && this.nodes[F] && (this.nodes[L].edges.push(this.edges[this.edges.length - 1]), this.nodes[F].edges.push(this.edges[this.edges.length - 1]));
}
getEdges() {
return this.edges;
}
addLayoutHint(L) {
if (L.members.length < 2) throw new Error(`An align directive requires at least two members; got ${L.members.length}`);
const F = /* @__PURE__ */ new Set();
L.members.forEach((w) => {
if (this.registeredIds[w] !== "node") throw new Error(`align ${L.direction} references [${w}], which is not a service or junction`);
if (F.has(w)) throw new Error(`align ${L.direction} lists [${w}] more than once`);
F.add(w);
}), this.layoutHints.push(L);
}
getLayoutHints() {
return this.layoutHints;
}
getDataStructures() {
if (this.dataStructures === void 0) {
const L = {}, F = Object.entries(this.nodes).reduce((n, [t, a]) => (n[t] = a.edges.reduce((h, e) => {
const d = this.getNode(e.lhsId)?.in, r = this.getNode(e.rhsId)?.in;
if (d && r && d !== r) {
const i = vr(e.lhsDir, e.rhsDir);
i !== "bend" && (L[d] ??= {}, L[d][r] = i, L[r] ??= {}, L[r][d] = i);
}
if (e.lhsId === t) {
const i = ge(e.lhsDir, e.rhsDir);
i && (h[i] = e.rhsId);
} else {
const i = ge(e.rhsDir, e.lhsDir);
i && (h[i] = e.lhsId);
}
return h;
}, {}), n), {}), w = Object.keys(F)[0], U = { [w]: 1 }, N = Object.keys(F).reduce((n, t) => t === w ? n : {
...n,
[t]: 1
}, {}), v = /* @__PURE__ */ lt((n) => {
const t = { [n]: [0, 0] }, a = [n];
for (; a.length > 0; ) {
const h = a.shift();
if (h) {
U[h] = 1, delete N[h];
const e = F[h], [d, r] = t[h];
Object.entries(e).forEach(([i, f]) => {
U[f] || (t[f] = ur([d, r], i), a.push(f));
});
}
}
return t;
}, "BFS"), s = [v(w)];
for (; Object.keys(N).length > 0; ) s.push(v(Object.keys(N)[0]));
this.dataStructures = {
adjList: F,
spatialMaps: s,
groupAlignments: L
};
}
return this.dataStructures;
}
setElementForId(L, F) {
this.elements[L] = F;
}
getElementById(L) {
return this.elements[L];
}
getConfig() {
return ir({
...mr,
...Je().architecture
});
}
getConfigField(L) {
return this.getConfig()[L];
}
}, Er = /* @__PURE__ */ lt((L, F) => {
nr(L, F), L.groups.map((w) => F.addGroup(w)), L.services.map((w) => F.addService({
...w,
type: "service"
})), L.junctions.map((w) => F.addJunction({
...w,
type: "junction"
})), L.edges.map((w) => F.addEdge(w)), L.alignments?.map((w) => F.addLayoutHint({
direction: w.direction,
members: [...w.members]
}));
}, "populateDb"), Se = {
parser: { yy: void 0 },
parse: /* @__PURE__ */ lt(async (L) => {
const F = await ze("architecture", L);
De.debug(F);
const w = Se.parser?.yy;
if (!(w instanceof Re)) throw new Error("parser.parser?.yy was not a ArchitectureDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");
Er(F, w);
}, "parse")
}, Tr = /* @__PURE__ */ lt((L) => `
.edge {
stroke-width: ${L.archEdgeWidth};
stroke: ${L.archEdgeColor};
fill: none;
}
.arrow {
fill: ${L.archEdgeArrowColor};
}
.node-bkg {
fill: none;
stroke: ${L.archGroupBorderColor};
stroke-width: ${L.archGroupBorderWidth};
stroke-dasharray: 8;
}
.node-icon-text {
display: flex;
align-items: center;
}
.node-icon-text > div {
color: #fff;
margin: 1px;
height: fit-content;
text-align: center;
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
}
`, "getStyles");
function ue(L, F) {
if (L === 0) return F();
const w = Math.random;
let U = L >>> 0;
Math.random = function() {
U = U + 1831565813 >>> 0;
let N = U;
return N = Math.imul(N ^ N >>> 15, N | 1), N ^= N + Math.imul(N ^ N >>> 7, N | 61), ((N ^ N >>> 14) >>> 0) / 4294967296;
};
try {
return F();
} finally {
Math.random = w;
}
}
lt(ue, "withSeededRandom");
var ee = /* @__PURE__ */ lt((L) => `<g><rect width="80" height="80" style="fill: #087ebf; stroke-width: 0px;"/>${L}</g>`, "wrapIcon"), ie = {
prefix: "mermaid-architecture",
height: 80,
width: 80,
icons: {
database: { body: ee('<path id="b" data-name="4" d="m20,57.86c0,3.94,8.95,7.14,20,7.14s20-3.2,20-7.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><path id="c" data-name="3" d="m20,45.95c0,3.94,8.95,7.14,20,7.14s20-3.2,20-7.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><path id="d" data-name="2" d="m20,34.05c0,3.94,8.95,7.14,20,7.14s20-3.2,20-7.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse id="e" data-name="1" cx="40" cy="22.14" rx="20" ry="7.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="20" y1="57.86" x2="20" y2="22.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="60" y1="57.86" x2="60" y2="22.14" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/>') },
server: { body: ee('<rect x="17.5" y="17.5" width="45" height="45" rx="2" ry="2" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="17.5" y1="32.5" x2="62.5" y2="32.5" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="17.5" y1="47.5" x2="62.5" y2="47.5" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><g><path d="m56.25,25c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: #fff; stroke-width: 0px;"/><path d="m56.25,25c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: none; stroke: #fff; stroke-miterlimit: 10;"/></g><g><path d="m56.25,40c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: #fff; stroke-width: 0px;"/><path d="m56.25,40c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: none; stroke: #fff; stroke-miterlimit: 10;"/></g><g><path d="m56.25,55c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: #fff; stroke-width: 0px;"/><path d="m56.25,55c0,.27-.45.5-1,.5h-10.5c-.55,0-1-.23-1-.5s.45-.5,1-.5h10.5c.55,0,1,.23,1,.5Z" style="fill: none; stroke: #fff; stroke-miterlimit: 10;"/></g><g><circle cx="32.5" cy="25" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="27.5" cy="25" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="22.5" cy="25" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/></g><g><circle cx="32.5" cy="40" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="27.5" cy="40" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="22.5" cy="40" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/></g><g><circle cx="32.5" cy="55" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="27.5" cy="55" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/><circle cx="22.5" cy="55" r=".75" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10;"/></g>') },
disk: { body: ee('<rect x="20" y="15" width="40" height="50" rx="1" ry="1" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="24" cy="19.17" rx=".8" ry=".83" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="56" cy="19.17" rx=".8" ry=".83" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="24" cy="60.83" rx=".8" ry=".83" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="56" cy="60.83" rx=".8" ry=".83" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="40" cy="33.75" rx="14" ry="14.58" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><ellipse cx="40" cy="33.75" rx="4" ry="4.17" style="fill: #fff; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><path d="m37.51,42.52l-4.83,13.22c-.26.71-1.1,1.02-1.76.64l-4.18-2.42c-.66-.38-.81-1.26-.33-1.84l9.01-10.8c.88-1.05,2.56-.08,2.09,1.2Z" style="fill: #fff; stroke-width: 0px;"/>') },
internet: { body: ee('<circle cx="40" cy="40" r="22.5" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="40" y1="17.5" x2="40" y2="62.5" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="17.5" y1="40" x2="62.5" y2="40" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><path d="m39.99,17.51c-15.28,11.1-15.28,33.88,0,44.98" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><path d="m40.01,17.51c15.28,11.1,15.28,33.88,0,44.98" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="19.75" y1="30.1" x2="60.25" y2="30.1" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/><line x1="19.75" y1="49.9" x2="60.25" y2="49.9" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/>') },
cloud: { body: ee('<path d="m65,47.5c0,2.76-2.24,5-5,5H20c-2.76,0-5-2.24-5-5,0-1.87,1.03-3.51,2.56-4.36-.04-.21-.06-.42-.06-.64,0-2.6,2.48-4.74,5.65-4.97,1.65-4.51,6.34-7.76,11.85-7.76.86,0,1.69.08,2.5.23,2.09-1.57,4.69-2.5,7.5-2.5,6.1,0,11.19,4.38,12.28,10.17,2.14.56,3.72,2.51,3.72,4.83,0,.03,0,.07-.01.1,2.29.46,4.01,2.48,4.01,4.9Z" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px;"/>') },
unknown: or,
blank: { body: ee("") }
}
}, Nr = /* @__PURE__ */ lt(async function(L, F, w, U) {
const N = w.getConfigField("padding"), v = w.getConfigField("iconSize"), s = v / 2, n = v / 6, t = n / 2;
await Promise.all(F.edges().map(async (a) => {
const { source: h, sourceDir: e, sourceArrow: d, sourceGroup: r, target: i, targetDir: f, targetArrow: l, targetGroup: p, label: g } = Ie(a);
let { x: c, y: T } = a[0].sourceEndpoint();
const { x: A, y: I } = a[0].midpoint();
let { x: S, y: Y } = a[0].targetEndpoint();
const V = N + 4;
if (r && (Ht(e) ? c += e === "L" ? -V : V : T += e === "T" ? -V : V + 18), p && (Ht(f) ? S += f === "L" ? -V : V : Y += f === "T" ? -V : V + 18), !r && w.getNode(h)?.type === "junction" && (Ht(e) ? c += e === "L" ? s : -s : T += e === "T" ? s : -s), !p && w.getNode(i)?.type === "junction" && (Ht(f) ? S += f === "L" ? s : -s : Y += f === "T" ? s : -s), a[0]._private.rscratch) {
const z = L.insert("g");
if (z.insert("path").attr("d", `M ${c},${T} L ${A},${I} L${S},${Y} `).attr("class", "edge").attr("id", `${U}-${rr(h, i, { prefix: "L" })}`), d) {
const x = Ht(e) ? ne[e](c, n) : c - t, tt = kt(e) ? ne[e](T, n) : T - t;
z.insert("polygon").attr("points", Me[e](n)).attr("transform", `translate(${x},${tt})`).attr("class", "arrow");
}
if (l) {
const x = Ht(f) ? ne[f](S, n) : S - t, tt = kt(f) ? ne[f](Y, n) : Y - t;
z.insert("polygon").attr("points", Me[f](n)).attr("transform", `translate(${x},${tt})`).attr("class", "arrow");
}
if (g) {
const x = ye(e, f) ? "XY" : Ht(e) ? "X" : "Y";
let tt = 0;
x === "X" ? tt = Math.abs(c - S) : x === "Y" ? tt = Math.abs(T - Y) / 1.5 : tt = Math.abs(c - S) / 2;
const o = z.append("g");
if (await pe(o, g, {
useHtmlLabels: !1,
width: tt,
classes: "architecture-service-label"
}, ve()), o.attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle"), x === "X") o.attr("transform", "translate(" + A + ", " + I + ")");
else if (x === "Y") o.attr("transform", "translate(" + A + ", " + I + ") rotate(-90)");
else if (x === "XY") {
const m = ge(e, f);
if (m && cr(m)) {
const u = o.node().getBoundingClientRect(), [E, y] = dr(m);
o.attr("dominant-baseline", "auto").attr("transform", `rotate(${-1 * E * y * 45})`);
const C = o.node().getBoundingClientRect();
o.attr("transform", `
translate(${A}, ${I - u.height / 2})
translate(${E * C.width / 2}, ${y * C.height / 2})
rotate(${-1 * E * y * 45}, 0, ${u.height / 2})
`);
}
}
}
}
}));
}, "drawEdges"), Lr = /* @__PURE__ */ lt(async function(L, F, w, U) {
const N = w.getConfigField("padding") * 0.75, v = w.getConfigField("fontSize"), s = w.getConfigField("iconSize") / 2;
await Promise.all(F.nodes().map(async (n) => {
const t = re(n);
if (t.type === "group") {
const { h: a, w: h, x1: e, y1: d } = n.boundingBox(), r = L.append("rect");
r.attr("id", `${U}-group-${t.id}`).attr("x", e + s).attr("y", d + s).attr("width", h).attr("height", a).attr("class", "node-bkg");
const i = L.append("g");
let f = e, l = d;
if (t.icon) {
const p = i.append("g");
p.html(`<g>${await ce(t.icon, {
height: N,
width: N,
fallbackPrefix: ie.prefix
})}</g>`), p.attr("transform", "translate(" + (f + s + 1) + ", " + (l + s + 1) + ")"), f += N, l += v / 2 - 1 - 2;
}
if (t.label) {
const p = i.append("g");
await pe(p, t.label, {
useHtmlLabels: !1,
width: h,
classes: "architecture-service-label"
}, ve()), p.attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "start").attr("text-anchor", "start"), p.attr("transform", "translate(" + (f + s + 4) + ", " + (l + s + 2) + ")");
}
w.setElementForId(t.id, r);
}
}));
}, "drawGroups"), wr = /* @__PURE__ */ lt(async function(L, F, w, U) {
const N = ve();
for (const v of w) {
const s = F.append("g"), n = L.getConfigField("iconSize");
if (v.title) {
const e = s.append("g");
await pe(e, v.title, {
useHtmlLabels: !1,
width: n * 1.5,
classes: "architecture-service-label"
}, N), e.attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle"), e.attr("transform", "translate(" + n / 2 + ", " + n + ")");
}
const t = s.append("g");
if (v.icon) t.html(`<g>${await ce(v.icon, {
height: n,
width: n,
fallbackPrefix: ie.prefix
})}</g>`);
else if (v.iconText) {
t.html(`<g>${await ce("blank", {
height: n,
width: n,
fallbackPrefix: ie.prefix
})}</g>`);
const e = t.append("g").append("foreignObject").attr("width", n).attr("height", n).append("div").attr("class", "node-icon-text").attr("style", `height: ${n}px;`).append("div").html(er(v.iconText, N)), d = parseInt(window.getComputedStyle(e.node(), null).getPropertyValue("font-size").replace(/\D/g, "")) ?? 16;
e.attr("style", `-webkit-line-clamp: ${Math.floor((n - 2) / d)};`);
} else t.append("path").attr("class", "node-bkg").attr("id", `${U}-node-${v.id}`).attr("d", `M0,${n} V5 Q0,0 5,0 H${n - 5} Q${n},0 ${n},5 V${n} Z`);
s.attr("id", `${U}-service-${v.id}`).attr("class", "architecture-service");
const { width: a, height: h } = s.node().getBBox();
v.width = a, v.height = h, L.setElementForId(v.id, s);
}
return 0;
}, "drawServices"), Cr = /* @__PURE__ */ lt(function(L, F, w, U) {
w.forEach((N) => {
const v = F.append("g"), s = L.getConfigField("iconSize");
v.append("g").append("rect").attr("id", `${U}-node-${N.id}`).attr("fill-opacity", "0").attr("width", s).attr("height", s), v.attr("class", "architecture-junction");
const { width: n, height: t } = v._groups[0][0].getBBox();
v.width = n, v.height = t, L.setElementForId(N.id, v);
});
}, "drawJunctions");
sr([{
name: ie.prefix,
icons: ie
}]);
xe.use(lr.default);
function Fe(L, F, w) {
L.forEach((U) => {
F.add({
group: "nodes",
data: {
type: "service",
id: U.id,
icon: U.icon,
label: U.title,
parent: U.in,
width: w.getConfigField("iconSize"),
height: w.getConfigField("iconSize")
},
classes: "node-service"
});
});
}
lt(Fe, "addServices");
function be(L, F, w) {
L.forEach((U) => {
F.add({
group: "nodes",
data: {
type: "junction",
id: U.id,
parent: U.in,
width: w.getConfigField("iconSize"),
height: w.getConfigField("iconSize")
},
classes: "node-junction"
});
});
}
lt(be, "addJunctions");
function Ge(L, F) {
F.nodes().map((w) => {
const U = re(w);
U.type !== "group" && (U.x = w.position().x, U.y = w.position().y, L.getElementById(U.id).attr("transform", "translate(" + (U.x || 0) + "," + (U.y || 0) + ")"));
});
}
lt(Ge, "positionNodes");
function Pe(L, F) {
L.forEach((w) => {
F.add({
group: "nodes",
data: {
type: "group",
id: w.id,
icon: w.icon,
label: w.title,
parent: w.in
},
classes: "node-group"
});
});
}
lt(Pe, "addGroups");
function Ue(L, F) {
L.forEach((w) => {
const { lhsId: U, rhsId: N, lhsInto: v, lhsGroup: s, rhsInto: n, lhsDir: t, rhsDir: a, rhsGroup: h, title: e } = w, d = ye(w.lhsDir, w.rhsDir) ? "segments" : "straight", r = {
id: `${U}-${N}`,
label: e,
source: U,
sourceDir: t,
sourceArrow: v,
sourceGroup: s,
sourceEndpoint: t === "L" ? "0 50%" : t === "R" ? "100% 50%" : t === "T" ? "50% 0" : "50% 100%",
target: N,
targetDir: a,
targetArrow: n,
targetGroup: h,
targetEndpoint: a === "L" ? "0 50%" : a === "R" ? "100% 50%" : a === "T" ? "50% 0" : "50% 100%"
};
F.add({
group: "edges",
data: r,
classes: d
});
});
}
lt(Ue, "addEdges");
function Ye(L, F, w, U = []) {
const N = /* @__PURE__ */ lt((e, d) => Object.entries(e).reduce((r, [i, f]) => {
let l = 0;
const p = Object.entries(f);
if (p.length === 1)
return r[i] = p[0][1], r;
for (let g = 0; g < p.length - 1; g++) for (let c = g + 1; c < p.length; c++) {
const [T, A] = p[g], [I, S] = p[c];
if (w[T]?.[I] === d)
r[i] ??= [], r[i] = [
...r[i],
...A,
...S
];
else if (T === "default" || I === "default")
r[i] ??= [], r[i] = [
...r[i],
...A,
...S
];
else {
const Y = `${i}-${l++}`;
r[Y] = A;
const V = `${i}-${l++}`;
r[V] = S;
}
}
return r;
}, {}), "flattenAlignments"), [v, s] = F.map((e) => {
const d = {}, r = {};
return Object.entries(e).forEach(([i, [f, l]]) => {
const p = L.getNode(i)?.in ?? "default";
d[l] ??= {}, d[l][p] ??= [], d[l][p].push(i), r[f] ??= {}, r[f][p] ??= [], r[f][p].push(i);
}), {
horiz: Object.values(N(d, "horizontal")).filter((i) => i.length > 1),
vert: Object.values(N(r, "vertical")).filter((i) => i.length > 1)
};
}).reduce(([e, d], { horiz: r, vert: i }) => [[...e, ...r], [...d, ...i]], [[], []]), n = /* @__PURE__ */ new Set();
U.forEach((e) => e.members.forEach((d) => n.add(d)));
const t = /* @__PURE__ */ lt((e) => e.filter((d) => !d.some((r) => n.has(r))), "dropOverlapping"), a = t(v), h = t(s);
return U.forEach((e) => {
e.members.length < 2 || (e.direction === "row" ? a.push([...e.members]) : h.push([...e.members]));
}), {
horizontal: a,
vertical: h
};
}
lt(Ye, "getAlignments");
function Xe(L, F, w = []) {
const U = [], N = F.getConfigField("iconSize"), v = F.getConfigField("idealEdgeLengthMultiplier"), s = v * N, n = /* @__PURE__ */ new Set();
w.forEach((h) => {
for (let e = 0; e < h.members.length - 1; e++) {
const d = h.members[e], r = h.members[e + 1];
n.add(`${d}|${r}`), n.add(`${r}|${d}`), h.direction === "row" ? U.push({
left: d,
right: r,
gap: s
}) : U.push({
top: d,
bottom: r,
gap: s
});
}
});
const t = /* @__PURE__ */ lt((h) => `${h[0]},${h[1]}`, "posToStr"), a = /* @__PURE__ */ lt((h) => h.split(",").map((e) => parseInt(e)), "strToPos");
return L.forEach((h) => {
const e = Object.fromEntries(Object.entries(h).map(([f, l]) => [t(l), f])), d = [t([0, 0])], r = {}, i = {
L: [-1, 0],
R: [1, 0],
T: [0, 1],
B: [0, -1]
};
for (; d.length > 0; ) {
const f = d.shift();
if (f) {
r[f] = 1;
const l = e[f];
if (l) {
const p = a(f);
Object.entries(i).forEach(([g, c]) => {
const T = t([p[0] + c[0], p[1] + c[1]]), A = e[T];
if (A && !r[T]) {
if (d.push(T), n.has(`${l}|${A}`)) return;
U.push({
[Ae[g]]: A,
[Ae[fr(g)]]: l,
gap: v * N
});
}
});
}
}
}
}), U;
}
lt(Xe, "getRelativeConstraints");
function He(L, F, w, U, N, { spatialMaps: v, groupAlignments: s }) {
return new Promise((n) => {
const t = $e("body").append("div").attr("id", "cy").attr("style", "display:none"), a = xe({
container: document.getElementById("cy"),
style: [
{
selector: "edge",
style: {
"curve-style": "straight",
"source-endpoint": "data(sourceEndpoint)",
"target-endpoint": "data(targetEndpoint)"
}
},
{
selector: "edge[label]",
style: { label: "data(label)" }
},
{
selector: "edge.segments",
style: {
"curve-style": "segments",
"segment-weights": "0",
"segment-distances": [0.5],
"edge-distances": "endpoints",
"source-endpoint": "data(sourceEndpoint)",
"target-endpoint": "data(targetEndpoint)"
}
},
{
selector: "node",
style: { "compound-sizing-wrt-labels": "include" }
},
{
selector: "node[label]",
style: {
"text-valign": "bottom",
"text-halign": "center",
"font-size": `${N.getConfigField("fontSize")}px`
}
},
{
selector: ".node-service",
style: {
label: "data(label)",
width: "data(width)",
height: "data(height)"
}
},
{
selector: ".node-junction",
style: {
width: "data(width)",
height: "data(height)"
}
},
{
selector: ".node-group",
style: { padding: `${N.getConfigField("padding")}px` }
}
],
layout: {
name: "grid",
boundingBox: {
x1: 0,
x2: 100,
y1: 0,
y2: 100
}
}
});
t.remove(), Pe(w, a), Fe(L, a, N), be(F, a, N), Ue(U, a);
const h = N.getLayoutHints(), e = Ye(N, v, s, h), d = Xe(v, N, h), r = N.getConfigField("iconSize"), i = N.getConfigField("idealEdgeLengthMultiplier") * r, f = 0.5 * r, l = N.getConfigField("edgeElasticity"), p = N.getConfigField("seed"), g = a.layout({
name: "fcose",
quality: "proof",
randomize: N.getConfigField("randomize"),
nodeSeparation: N.getConfigField("nodeSeparation"),
numIter: N.getConfigField("numIter"),
styleEnabled: !1,
animate: !1,
nodeDimensionsIncludeLabels: !1,
idealEdgeLength(c) {
const [T, A] = c.connectedNodes(), { parent: I } = re(T), { parent: S } = re(A);
return I === S ? i : f;
},
edgeElasticity(c) {
const [T, A] = c.connectedNodes(), { parent: I } = re(T), { parent: S } = re(A);
return I === S ? l : 1e-3;
},
alignmentConstraint: e,
relativePlacementConstraint: d
});
g.one("layoutstop", () => {
function c(T, A, I, S) {
let Y, V;
const { x: z, y: x } = T, { x: tt, y: o } = A;
V = (S - x + (z - I) * (x - o) / (z - tt)) / Math.sqrt(1 + Math.pow((x - o) / (z - tt), 2)), Y = Math.sqrt(Math.pow(S - x, 2) + Math.pow(I - z, 2) - Math.pow(V, 2));
const m = Math.sqrt(Math.pow(tt - z, 2) + Math.pow(o - x, 2));
Y = Y / m;
let u = (tt - z) * (S - x) - (o - x) * (I - z);
switch (!0) {
case u >= 0:
u = 1;
break;
case u < 0:
u = -1;
break;
}
let E = (tt - z) * (I - z) + (o - x) * (S - x);
switch (!0) {
case E >= 0:
E = 1;
break;
case E < 0:
E = -1;
break;
}
return V = Math.abs(V) * u, Y = Y * E, {
distances: V,
weights: Y
};
}
lt(c, "getSegmentWeights"), a.startBatch();
for (const T of Object.values(a.edges())) if (T.data?.()) {
const { x: A, y: I } = T.source().position(), { x: S, y: Y } = T.target().position();
if (A !== S && I !== Y) {
const V = T.sourceEndpoint(), z = T.targetEndpoint(), { sourceDir: x } = Ie(T), [tt, o] = kt(x) ? [V.x, z.y] : [z.x, V.y], { weights: m, distances: u } = c(V, z, tt, o);
T.style("segment-distances", u), T.style("segment-weights", m);
}
}
a.endBatch(), ue(p, () => g.run());
});
try {
ue(p, () => g.run());
} catch (c) {
throw c instanceof RangeError && c.message.includes("Invalid array length") ? new Error("Architecture layout failed: a declared `align row|column` directive likely contradicts the edge directions, or two declared alignments overlap on a shared node. Check that the order of members in each `align` chain is consistent with the edges between them, and that no node appears in two `align` directives along the same axis.") : c;
}
a.ready((c) => {
De.info("Ready", c), n(a);
});
});
}
lt(He, "layoutArchitecture");
var Pr = {
parser: Se,
get db() {
return new Re();
},
renderer: { draw: /* @__PURE__ */ lt(async (L, F, w, U) => {
const N = U.db;
N.setDiagramId(F);
const v = N.getServices(), s = N.getJunctions(), n = N.getGroups(), t = N.getEdges(), a = N.getDataStructures(), h = ar(F), e = h.append("g");
e.attr("class", "architecture-edges");
const d = h.append("g");
d.attr("class", "architecture-services");
const r = h.append("g");
r.attr("class", "architecture-groups"), await wr(N, d, v, F), Cr(N, d, s, F);
const i = await He(v, s, n, t, N, a);
await Nr(e, i, N, F), await Lr(r, i, N, F), Ge(N, i), Ze(void 0, h, N.getConfigField("padding"), N.getConfigField("useMaxWidth"));
}, "draw") },
styles: Tr
};
export {
Pr as diagram
};