smart-chat-asp
Version:
smartChat component
22,050 lines • 797 kB
JavaScript
import { az as ro, aA as yv, a1 as Nr, X as ao, aC as mv, ac as bv, aE as En, Y as xn, a0 as wv, bp as Ev, bq as xv, br as Tv, aG as Cv } from "./lib-85d3a8f7.mjs";
import { a as Dv } from "./createText-1719965b-f10f4fe4.mjs";
import "vue";
function Ns(t, e) {
(e == null || e > t.length) && (e = t.length);
for (var r = 0, a = Array(e); r < e; r++)
a[r] = t[r];
return a;
}
function Sv(t) {
if (Array.isArray(t))
return t;
}
function Av(t) {
if (Array.isArray(t))
return Ns(t);
}
function yr(t, e) {
if (!(t instanceof e))
throw new TypeError("Cannot call a class as a function");
}
function Lv(t, e) {
for (var r = 0; r < e.length; r++) {
var a = e[r];
a.enumerable = a.enumerable || !1, a.configurable = !0, "value" in a && (a.writable = !0), Object.defineProperty(t, hf(a.key), a);
}
}
function mr(t, e, r) {
return e && Lv(t.prototype, e), Object.defineProperty(t, "prototype", {
writable: !1
}), t;
}
function At(t, e) {
var r = typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"];
if (!r) {
if (Array.isArray(t) || (r = no(t)) || e) {
r && (t = r);
var a = 0, n = function() {
};
return {
s: n,
n: function() {
return a >= t.length ? {
done: !0
} : {
done: !1,
value: t[a++]
};
},
e: function(u) {
throw u;
},
f: n
};
}
throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
var i, s = !0, o = !1;
return {
s: function() {
r = r.call(t);
},
n: function() {
var u = r.next();
return s = u.done, u;
},
e: function(u) {
o = !0, i = u;
},
f: function() {
try {
s || r.return == null || r.return();
} finally {
if (o)
throw i;
}
}
};
}
function vf(t, e, r) {
return (e = hf(e)) in t ? Object.defineProperty(t, e, {
value: r,
enumerable: !0,
configurable: !0,
writable: !0
}) : t[e] = r, t;
}
function Rv(t) {
if (typeof Symbol < "u" && t[Symbol.iterator] != null || t["@@iterator"] != null)
return Array.from(t);
}
function Iv(t, e) {
var r = t == null ? null : typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"];
if (r != null) {
var a, n, i, s, o = [], u = !0, l = !1;
try {
if (i = (r = r.call(t)).next, e === 0) {
if (Object(r) !== r)
return;
u = !1;
} else
for (; !(u = (a = i.call(r)).done) && (o.push(a.value), o.length !== e); u = !0)
;
} catch (f) {
l = !0, n = f;
} finally {
try {
if (!u && r.return != null && (s = r.return(), Object(s) !== s))
return;
} finally {
if (l)
throw n;
}
}
return o;
}
}
function Pv() {
throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
function Mv() {
throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
function Je(t, e) {
return Sv(t) || Iv(t, e) || no(t, e) || Pv();
}
function Tn(t) {
return Av(t) || Rv(t) || no(t) || Mv();
}
function Ov(t, e) {
if (typeof t != "object" || !t)
return t;
var r = t[Symbol.toPrimitive];
if (r !== void 0) {
var a = r.call(t, e);
if (typeof a != "object")
return a;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return String(t);
}
function hf(t) {
var e = Ov(t, "string");
return typeof e == "symbol" ? e : e + "";
}
function nt(t) {
"@babel/helpers - typeof";
return nt = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
return typeof e;
} : function(e) {
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
}, nt(t);
}
function no(t, e) {
if (t) {
if (typeof t == "string")
return Ns(t, e);
var r = {}.toString.call(t).slice(8, -1);
return r === "Object" && t.constructor && (r = t.constructor.name), r === "Map" || r === "Set" ? Array.from(t) : r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? Ns(t, e) : void 0;
}
}
var tt = typeof window > "u" ? null : window, No = tt ? tt.navigator : null;
tt && tt.document;
var kv = nt(""), df = nt({}), Nv = nt(function() {
}), Bv = typeof HTMLElement > "u" ? "undefined" : nt(HTMLElement), Ba = function(e) {
return e && e.instanceString && Xe(e.instanceString) ? e.instanceString() : null;
}, ge = function(e) {
return e != null && nt(e) == kv;
}, Xe = function(e) {
return e != null && nt(e) === Nv;
}, Ve = function(e) {
return !Lt(e) && (Array.isArray ? Array.isArray(e) : e != null && e instanceof Array);
}, Oe = function(e) {
return e != null && nt(e) === df && !Ve(e) && e.constructor === Object;
}, Fv = function(e) {
return e != null && nt(e) === df;
}, ne = function(e) {
return e != null && nt(e) === nt(1) && !isNaN(e);
}, _v = function(e) {
return ne(e) && Math.floor(e) === e;
}, Cn = function(e) {
if (Bv !== "undefined")
return e != null && e instanceof HTMLElement;
}, Lt = function(e) {
return Fa(e) || gf(e);
}, Fa = function(e) {
return Ba(e) === "collection" && e._private.single;
}, gf = function(e) {
return Ba(e) === "collection" && !e._private.single;
}, io = function(e) {
return Ba(e) === "core";
}, pf = function(e) {
return Ba(e) === "stylesheet";
}, Gv = function(e) {
return Ba(e) === "event";
}, fr = function(e) {
return e == null ? !0 : !!(e === "" || e.match(/^\s+$/));
}, zv = function(e) {
return typeof HTMLElement > "u" ? !1 : e instanceof HTMLElement;
}, Vv = function(e) {
return Oe(e) && ne(e.x1) && ne(e.x2) && ne(e.y1) && ne(e.y2);
}, Uv = function(e) {
return Fv(e) && Xe(e.then);
}, qv = function() {
return No && No.userAgent.match(/msie|trident|edge/i);
}, ta = function(e, r) {
r || (r = function() {
if (arguments.length === 1)
return arguments[0];
if (arguments.length === 0)
return "undefined";
for (var i = [], s = 0; s < arguments.length; s++)
i.push(arguments[s]);
return i.join("$");
});
var a = function() {
var i = this, s = arguments, o, u = r.apply(i, s), l = a.cache;
return (o = l[u]) || (o = l[u] = e.apply(i, s)), o;
};
return a.cache = {}, a;
}, so = ta(function(t) {
return t.replace(/([A-Z])/g, function(e) {
return "-" + e.toLowerCase();
});
}), Fn = ta(function(t) {
return t.replace(/(-\w)/g, function(e) {
return e[1].toUpperCase();
});
}), yf = ta(function(t, e) {
return t + e[0].toUpperCase() + e.substring(1);
}, function(t, e) {
return t + "$" + e;
}), Bo = function(e) {
return fr(e) ? e : e.charAt(0).toUpperCase() + e.substring(1);
}, ir = function(e, r) {
return e.slice(-1 * r.length) === r;
}, at = "(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))", Yv = "rgb[a]?\\((" + at + "[%]?)\\s*,\\s*(" + at + "[%]?)\\s*,\\s*(" + at + "[%]?)(?:\\s*,\\s*(" + at + "))?\\)", Hv = "rgb[a]?\\((?:" + at + "[%]?)\\s*,\\s*(?:" + at + "[%]?)\\s*,\\s*(?:" + at + "[%]?)(?:\\s*,\\s*(?:" + at + "))?\\)", Xv = "hsl[a]?\\((" + at + ")\\s*,\\s*(" + at + "[%])\\s*,\\s*(" + at + "[%])(?:\\s*,\\s*(" + at + "))?\\)", $v = "hsl[a]?\\((?:" + at + ")\\s*,\\s*(?:" + at + "[%])\\s*,\\s*(?:" + at + "[%])(?:\\s*,\\s*(?:" + at + "))?\\)", Wv = "\\#[0-9a-fA-F]{3}", Kv = "\\#[0-9a-fA-F]{6}", mf = function(e, r) {
return e < r ? -1 : e > r ? 1 : 0;
}, Zv = function(e, r) {
return -1 * mf(e, r);
}, be = Object.assign != null ? Object.assign.bind(Object) : function(t) {
for (var e = arguments, r = 1; r < e.length; r++) {
var a = e[r];
if (a != null)
for (var n = Object.keys(a), i = 0; i < n.length; i++) {
var s = n[i];
t[s] = a[s];
}
}
return t;
}, Qv = function(e) {
if (!(!(e.length === 4 || e.length === 7) || e[0] !== "#")) {
var r = e.length === 4, a, n, i, s = 16;
return r ? (a = parseInt(e[1] + e[1], s), n = parseInt(e[2] + e[2], s), i = parseInt(e[3] + e[3], s)) : (a = parseInt(e[1] + e[2], s), n = parseInt(e[3] + e[4], s), i = parseInt(e[5] + e[6], s)), [a, n, i];
}
}, Jv = function(e) {
var r, a, n, i, s, o, u, l;
function f(d, p, g) {
return g < 0 && (g += 1), g > 1 && (g -= 1), g < 1 / 6 ? d + (p - d) * 6 * g : g < 1 / 2 ? p : g < 2 / 3 ? d + (p - d) * (2 / 3 - g) * 6 : d;
}
var c = new RegExp("^" + Xv + "$").exec(e);
if (c) {
if (a = parseInt(c[1]), a < 0 ? a = (360 - -1 * a % 360) % 360 : a > 360 && (a = a % 360), a /= 360, n = parseFloat(c[2]), n < 0 || n > 100 || (n = n / 100, i = parseFloat(c[3]), i < 0 || i > 100) || (i = i / 100, s = c[4], s !== void 0 && (s = parseFloat(s), s < 0 || s > 1)))
return;
if (n === 0)
o = u = l = Math.round(i * 255);
else {
var v = i < 0.5 ? i * (1 + n) : i + n - i * n, h = 2 * i - v;
o = Math.round(255 * f(h, v, a + 1 / 3)), u = Math.round(255 * f(h, v, a)), l = Math.round(255 * f(h, v, a - 1 / 3));
}
r = [o, u, l, s];
}
return r;
}, jv = function(e) {
var r, a = new RegExp("^" + Yv + "$").exec(e);
if (a) {
r = [];
for (var n = [], i = 1; i <= 3; i++) {
var s = a[i];
if (s[s.length - 1] === "%" && (n[i] = !0), s = parseFloat(s), n[i] && (s = s / 100 * 255), s < 0 || s > 255)
return;
r.push(Math.floor(s));
}
var o = n[1] || n[2] || n[3], u = n[1] && n[2] && n[3];
if (o && !u)
return;
var l = a[4];
if (l !== void 0) {
if (l = parseFloat(l), l < 0 || l > 1)
return;
r.push(l);
}
}
return r;
}, eh = function(e) {
return th[e.toLowerCase()];
}, bf = function(e) {
return (Ve(e) ? e : null) || eh(e) || Qv(e) || jv(e) || Jv(e);
}, th = {
// special colour names
transparent: [0, 0, 0, 0],
// NB alpha === 0
// regular colours
aliceblue: [240, 248, 255],
antiquewhite: [250, 235, 215],
aqua: [0, 255, 255],
aquamarine: [127, 255, 212],
azure: [240, 255, 255],
beige: [245, 245, 220],
bisque: [255, 228, 196],
black: [0, 0, 0],
blanchedalmond: [255, 235, 205],
blue: [0, 0, 255],
blueviolet: [138, 43, 226],
brown: [165, 42, 42],
burlywood: [222, 184, 135],
cadetblue: [95, 158, 160],
chartreuse: [127, 255, 0],
chocolate: [210, 105, 30],
coral: [255, 127, 80],
cornflowerblue: [100, 149, 237],
cornsilk: [255, 248, 220],
crimson: [220, 20, 60],
cyan: [0, 255, 255],
darkblue: [0, 0, 139],
darkcyan: [0, 139, 139],
darkgoldenrod: [184, 134, 11],
darkgray: [169, 169, 169],
darkgreen: [0, 100, 0],
darkgrey: [169, 169, 169],
darkkhaki: [189, 183, 107],
darkmagenta: [139, 0, 139],
darkolivegreen: [85, 107, 47],
darkorange: [255, 140, 0],
darkorchid: [153, 50, 204],
darkred: [139, 0, 0],
darksalmon: [233, 150, 122],
darkseagreen: [143, 188, 143],
darkslateblue: [72, 61, 139],
darkslategray: [47, 79, 79],
darkslategrey: [47, 79, 79],
darkturquoise: [0, 206, 209],
darkviolet: [148, 0, 211],
deeppink: [255, 20, 147],
deepskyblue: [0, 191, 255],
dimgray: [105, 105, 105],
dimgrey: [105, 105, 105],
dodgerblue: [30, 144, 255],
firebrick: [178, 34, 34],
floralwhite: [255, 250, 240],
forestgreen: [34, 139, 34],
fuchsia: [255, 0, 255],
gainsboro: [220, 220, 220],
ghostwhite: [248, 248, 255],
gold: [255, 215, 0],
goldenrod: [218, 165, 32],
gray: [128, 128, 128],
grey: [128, 128, 128],
green: [0, 128, 0],
greenyellow: [173, 255, 47],
honeydew: [240, 255, 240],
hotpink: [255, 105, 180],
indianred: [205, 92, 92],
indigo: [75, 0, 130],
ivory: [255, 255, 240],
khaki: [240, 230, 140],
lavender: [230, 230, 250],
lavenderblush: [255, 240, 245],
lawngreen: [124, 252, 0],
lemonchiffon: [255, 250, 205],
lightblue: [173, 216, 230],
lightcoral: [240, 128, 128],
lightcyan: [224, 255, 255],
lightgoldenrodyellow: [250, 250, 210],
lightgray: [211, 211, 211],
lightgreen: [144, 238, 144],
lightgrey: [211, 211, 211],
lightpink: [255, 182, 193],
lightsalmon: [255, 160, 122],
lightseagreen: [32, 178, 170],
lightskyblue: [135, 206, 250],
lightslategray: [119, 136, 153],
lightslategrey: [119, 136, 153],
lightsteelblue: [176, 196, 222],
lightyellow: [255, 255, 224],
lime: [0, 255, 0],
limegreen: [50, 205, 50],
linen: [250, 240, 230],
magenta: [255, 0, 255],
maroon: [128, 0, 0],
mediumaquamarine: [102, 205, 170],
mediumblue: [0, 0, 205],
mediumorchid: [186, 85, 211],
mediumpurple: [147, 112, 219],
mediumseagreen: [60, 179, 113],
mediumslateblue: [123, 104, 238],
mediumspringgreen: [0, 250, 154],
mediumturquoise: [72, 209, 204],
mediumvioletred: [199, 21, 133],
midnightblue: [25, 25, 112],
mintcream: [245, 255, 250],
mistyrose: [255, 228, 225],
moccasin: [255, 228, 181],
navajowhite: [255, 222, 173],
navy: [0, 0, 128],
oldlace: [253, 245, 230],
olive: [128, 128, 0],
olivedrab: [107, 142, 35],
orange: [255, 165, 0],
orangered: [255, 69, 0],
orchid: [218, 112, 214],
palegoldenrod: [238, 232, 170],
palegreen: [152, 251, 152],
paleturquoise: [175, 238, 238],
palevioletred: [219, 112, 147],
papayawhip: [255, 239, 213],
peachpuff: [255, 218, 185],
peru: [205, 133, 63],
pink: [255, 192, 203],
plum: [221, 160, 221],
powderblue: [176, 224, 230],
purple: [128, 0, 128],
red: [255, 0, 0],
rosybrown: [188, 143, 143],
royalblue: [65, 105, 225],
saddlebrown: [139, 69, 19],
salmon: [250, 128, 114],
sandybrown: [244, 164, 96],
seagreen: [46, 139, 87],
seashell: [255, 245, 238],
sienna: [160, 82, 45],
silver: [192, 192, 192],
skyblue: [135, 206, 235],
slateblue: [106, 90, 205],
slategray: [112, 128, 144],
slategrey: [112, 128, 144],
snow: [255, 250, 250],
springgreen: [0, 255, 127],
steelblue: [70, 130, 180],
tan: [210, 180, 140],
teal: [0, 128, 128],
thistle: [216, 191, 216],
tomato: [255, 99, 71],
turquoise: [64, 224, 208],
violet: [238, 130, 238],
wheat: [245, 222, 179],
white: [255, 255, 255],
whitesmoke: [245, 245, 245],
yellow: [255, 255, 0],
yellowgreen: [154, 205, 50]
}, wf = function(e) {
for (var r = e.map, a = e.keys, n = a.length, i = 0; i < n; i++) {
var s = a[i];
if (Oe(s))
throw Error("Tried to set map with object key");
i < a.length - 1 ? (r[s] == null && (r[s] = {}), r = r[s]) : r[s] = e.value;
}
}, Ef = function(e) {
for (var r = e.map, a = e.keys, n = a.length, i = 0; i < n; i++) {
var s = a[i];
if (Oe(s))
throw Error("Tried to get map with object key");
if (r = r[s], r == null)
return r;
}
return r;
}, Za = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function _a(t) {
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
}
var ai, Fo;
function Ga() {
if (Fo)
return ai;
Fo = 1;
function t(e) {
var r = typeof e;
return e != null && (r == "object" || r == "function");
}
return ai = t, ai;
}
var ni, _o;
function rh() {
if (_o)
return ni;
_o = 1;
var t = typeof Za == "object" && Za && Za.Object === Object && Za;
return ni = t, ni;
}
var ii, Go;
function _n() {
if (Go)
return ii;
Go = 1;
var t = rh(), e = typeof self == "object" && self && self.Object === Object && self, r = t || e || Function("return this")();
return ii = r, ii;
}
var si, zo;
function ah() {
if (zo)
return si;
zo = 1;
var t = _n(), e = function() {
return t.Date.now();
};
return si = e, si;
}
var oi, Vo;
function nh() {
if (Vo)
return oi;
Vo = 1;
var t = /\s/;
function e(r) {
for (var a = r.length; a-- && t.test(r.charAt(a)); )
;
return a;
}
return oi = e, oi;
}
var ui, Uo;
function ih() {
if (Uo)
return ui;
Uo = 1;
var t = nh(), e = /^\s+/;
function r(a) {
return a && a.slice(0, t(a) + 1).replace(e, "");
}
return ui = r, ui;
}
var li, qo;
function oo() {
if (qo)
return li;
qo = 1;
var t = _n(), e = t.Symbol;
return li = e, li;
}
var fi, Yo;
function sh() {
if (Yo)
return fi;
Yo = 1;
var t = oo(), e = Object.prototype, r = e.hasOwnProperty, a = e.toString, n = t ? t.toStringTag : void 0;
function i(s) {
var o = r.call(s, n), u = s[n];
try {
s[n] = void 0;
var l = !0;
} catch {
}
var f = a.call(s);
return l && (o ? s[n] = u : delete s[n]), f;
}
return fi = i, fi;
}
var ci, Ho;
function oh() {
if (Ho)
return ci;
Ho = 1;
var t = Object.prototype, e = t.toString;
function r(a) {
return e.call(a);
}
return ci = r, ci;
}
var vi, Xo;
function xf() {
if (Xo)
return vi;
Xo = 1;
var t = oo(), e = sh(), r = oh(), a = "[object Null]", n = "[object Undefined]", i = t ? t.toStringTag : void 0;
function s(o) {
return o == null ? o === void 0 ? n : a : i && i in Object(o) ? e(o) : r(o);
}
return vi = s, vi;
}
var hi, $o;
function uh() {
if ($o)
return hi;
$o = 1;
function t(e) {
return e != null && typeof e == "object";
}
return hi = t, hi;
}
var di, Wo;
function za() {
if (Wo)
return di;
Wo = 1;
var t = xf(), e = uh(), r = "[object Symbol]";
function a(n) {
return typeof n == "symbol" || e(n) && t(n) == r;
}
return di = a, di;
}
var gi, Ko;
function lh() {
if (Ko)
return gi;
Ko = 1;
var t = ih(), e = Ga(), r = za(), a = 0 / 0, n = /^[-+]0x[0-9a-f]+$/i, i = /^0b[01]+$/i, s = /^0o[0-7]+$/i, o = parseInt;
function u(l) {
if (typeof l == "number")
return l;
if (r(l))
return a;
if (e(l)) {
var f = typeof l.valueOf == "function" ? l.valueOf() : l;
l = e(f) ? f + "" : f;
}
if (typeof l != "string")
return l === 0 ? l : +l;
l = t(l);
var c = i.test(l);
return c || s.test(l) ? o(l.slice(2), c ? 2 : 8) : n.test(l) ? a : +l;
}
return gi = u, gi;
}
var pi, Zo;
function fh() {
if (Zo)
return pi;
Zo = 1;
var t = Ga(), e = ah(), r = lh(), a = "Expected a function", n = Math.max, i = Math.min;
function s(o, u, l) {
var f, c, v, h, d, p, g = 0, y = !1, b = !1, m = !0;
if (typeof o != "function")
throw new TypeError(a);
u = r(u) || 0, t(l) && (y = !!l.leading, b = "maxWait" in l, v = b ? n(r(l.maxWait) || 0, u) : v, m = "trailing" in l ? !!l.trailing : m);
function E(R) {
var I = f, M = c;
return f = c = void 0, g = R, h = o.apply(M, I), h;
}
function T(R) {
return g = R, d = setTimeout(x, u), y ? E(R) : h;
}
function S(R) {
var I = R - p, M = R - g, N = u - I;
return b ? i(N, v - M) : N;
}
function w(R) {
var I = R - p, M = R - g;
return p === void 0 || I >= u || I < 0 || b && M >= v;
}
function x() {
var R = e();
if (w(R))
return C(R);
d = setTimeout(x, S(R));
}
function C(R) {
return d = void 0, m && f ? E(R) : (f = c = void 0, h);
}
function D() {
d !== void 0 && clearTimeout(d), g = 0, f = p = c = d = void 0;
}
function A() {
return d === void 0 ? h : C(e());
}
function L() {
var R = e(), I = w(R);
if (f = arguments, c = this, p = R, I) {
if (d === void 0)
return T(p);
if (b)
return clearTimeout(d), d = setTimeout(x, u), E(p);
}
return d === void 0 && (d = setTimeout(x, u)), h;
}
return L.cancel = D, L.flush = A, L;
}
return pi = s, pi;
}
var ch = fh(), Va = /* @__PURE__ */ _a(ch), yi = tt ? tt.performance : null, Tf = yi && yi.now ? function() {
return yi.now();
} : function() {
return Date.now();
}, vh = function() {
if (tt) {
if (tt.requestAnimationFrame)
return function(t) {
tt.requestAnimationFrame(t);
};
if (tt.mozRequestAnimationFrame)
return function(t) {
tt.mozRequestAnimationFrame(t);
};
if (tt.webkitRequestAnimationFrame)
return function(t) {
tt.webkitRequestAnimationFrame(t);
};
if (tt.msRequestAnimationFrame)
return function(t) {
tt.msRequestAnimationFrame(t);
};
}
return function(t) {
t && setTimeout(function() {
t(Tf());
}, 1e3 / 60);
};
}(), Dn = function(e) {
return vh(e);
}, Qt = Tf, Ar = 9261, Cf = 65599, $r = 5381, Df = function(e) {
for (var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Ar, a = r, n; n = e.next(), !n.done; )
a = a * Cf + n.value | 0;
return a;
}, Sa = function(e) {
var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Ar;
return r * Cf + e | 0;
}, Aa = function(e) {
var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : $r;
return (r << 5) + r + e | 0;
}, hh = function(e, r) {
return e * 2097152 + r;
}, rr = function(e) {
return e[0] * 2097152 + e[1];
}, Qa = function(e, r) {
return [Sa(e[0], r[0]), Aa(e[1], r[1])];
}, Qo = function(e, r) {
var a = {
value: 0,
done: !1
}, n = 0, i = e.length, s = {
next: function() {
return n < i ? a.value = e[n++] : a.done = !0, a;
}
};
return Df(s, r);
}, Ir = function(e, r) {
var a = {
value: 0,
done: !1
}, n = 0, i = e.length, s = {
next: function() {
return n < i ? a.value = e.charCodeAt(n++) : a.done = !0, a;
}
};
return Df(s, r);
}, Sf = function() {
return dh(arguments);
}, dh = function(e) {
for (var r, a = 0; a < e.length; a++) {
var n = e[a];
a === 0 ? r = Ir(n) : r = Ir(n, r);
}
return r;
};
function gh(t, e, r, a, n) {
var i = n * Math.PI / 180, s = Math.cos(i) * (t - r) - Math.sin(i) * (e - a) + r, o = Math.sin(i) * (t - r) + Math.cos(i) * (e - a) + a;
return {
x: s,
y: o
};
}
var ph = function(e, r, a, n, i, s) {
return {
x: (e - a) * i + a,
y: (r - n) * s + n
};
};
function yh(t, e, r) {
if (r === 0)
return t;
var a = (e.x1 + e.x2) / 2, n = (e.y1 + e.y2) / 2, i = e.w / e.h, s = 1 / i, o = gh(t.x, t.y, a, n, r), u = ph(o.x, o.y, a, n, i, s);
return {
x: u.x,
y: u.y
};
}
var Jo = !0, mh = console.warn != null, bh = console.trace != null, uo = Number.MAX_SAFE_INTEGER || 9007199254740991, Af = function() {
return !0;
}, Sn = function() {
return !1;
}, jo = function() {
return 0;
}, lo = function() {
}, He = function(e) {
throw new Error(e);
}, Lf = function(e) {
if (e !== void 0)
Jo = !!e;
else
return Jo;
}, Ge = function(e) {
Lf() && (mh ? console.warn(e) : (console.log(e), bh && console.trace()));
}, wh = function(e) {
return be({}, e);
}, Ut = function(e) {
return e == null ? e : Ve(e) ? e.slice() : Oe(e) ? wh(e) : e;
}, Eh = function(e) {
return e.slice();
}, Rf = function(e, r) {
for (
// loop :)
r = e = "";
// b - result , a - numeric letiable
e++ < 36;
//
r += e * 51 & 52 ? (
// return a random number or 4
(e ^ 15 ? (
// generate a random number from 0 to 15
8 ^ Math.random() * (e ^ 20 ? 16 : 4)
) : 4).toString(16)
) : "-"
)
;
return r;
}, xh = {}, If = function() {
return xh;
}, ht = function(e) {
var r = Object.keys(e);
return function(a) {
for (var n = {}, i = 0; i < r.length; i++) {
var s = r[i], o = a == null ? void 0 : a[s];
n[s] = o === void 0 ? e[s] : o;
}
return n;
};
}, cr = function(e, r, a) {
for (var n = e.length - 1; n >= 0; n--)
e[n] === r && e.splice(n, 1);
}, fo = function(e) {
e.splice(0, e.length);
}, Th = function(e, r) {
for (var a = 0; a < r.length; a++) {
var n = r[a];
e.push(n);
}
}, Dt = function(e, r, a) {
return a && (r = yf(a, r)), e[r];
}, Kt = function(e, r, a, n) {
a && (r = yf(a, r)), e[r] = n;
}, Ch = /* @__PURE__ */ function() {
function t() {
yr(this, t), this._obj = {};
}
return mr(t, [{
key: "set",
value: function(r, a) {
return this._obj[r] = a, this;
}
}, {
key: "delete",
value: function(r) {
return this._obj[r] = void 0, this;
}
}, {
key: "clear",
value: function() {
this._obj = {};
}
}, {
key: "has",
value: function(r) {
return this._obj[r] !== void 0;
}
}, {
key: "get",
value: function(r) {
return this._obj[r];
}
}]);
}(), Zt = typeof Map < "u" ? Map : Ch, Dh = "undefined", Sh = /* @__PURE__ */ function() {
function t(e) {
if (yr(this, t), this._obj = /* @__PURE__ */ Object.create(null), this.size = 0, e != null) {
var r;
e.instanceString != null && e.instanceString() === this.instanceString() ? r = e.toArray() : r = e;
for (var a = 0; a < r.length; a++)
this.add(r[a]);
}
}
return mr(t, [{
key: "instanceString",
value: function() {
return "set";
}
}, {
key: "add",
value: function(r) {
var a = this._obj;
a[r] !== 1 && (a[r] = 1, this.size++);
}
}, {
key: "delete",
value: function(r) {
var a = this._obj;
a[r] === 1 && (a[r] = 0, this.size--);
}
}, {
key: "clear",
value: function() {
this._obj = /* @__PURE__ */ Object.create(null);
}
}, {
key: "has",
value: function(r) {
return this._obj[r] === 1;
}
}, {
key: "toArray",
value: function() {
var r = this;
return Object.keys(this._obj).filter(function(a) {
return r.has(a);
});
}
}, {
key: "forEach",
value: function(r, a) {
return this.toArray().forEach(r, a);
}
}]);
}(), na = (typeof Set > "u" ? "undefined" : nt(Set)) !== Dh ? Set : Sh, Gn = function(e, r) {
var a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !0;
if (e === void 0 || r === void 0 || !io(e)) {
He("An element must have a core reference and parameters set");
return;
}
var n = r.group;
if (n == null && (r.data && r.data.source != null && r.data.target != null ? n = "edges" : n = "nodes"), n !== "nodes" && n !== "edges") {
He("An element must be of type `nodes` or `edges`; you specified `" + n + "`");
return;
}
this.length = 1, this[0] = this;
var i = this._private = {
cy: e,
single: !0,
// indicates this is an element
data: r.data || {},
// data object
position: r.position || {
x: 0,
y: 0
},
// (x, y) position pair
autoWidth: void 0,
// width and height of nodes calculated by the renderer when set to special 'auto' value
autoHeight: void 0,
autoPadding: void 0,
compoundBoundsClean: !1,
// whether the compound dimensions need to be recalculated the next time dimensions are read
listeners: [],
// array of bound listeners
group: n,
// string; 'nodes' or 'edges'
style: {},
// properties as set by the style
rstyle: {},
// properties for style sent from the renderer to the core
styleCxts: [],
// applied style contexts from the styler
styleKeys: {},
// per-group keys of style property values
removed: !0,
// whether it's inside the vis; true if removed (set true here since we call restore)
selected: !!r.selected,
// whether it's selected
selectable: r.selectable === void 0 ? !0 : !!r.selectable,
// whether it's selectable
locked: !!r.locked,
// whether the element is locked (cannot be moved)
grabbed: !1,
// whether the element is grabbed by the mouse; renderer sets this privately
grabbable: r.grabbable === void 0 ? !0 : !!r.grabbable,
// whether the element can be grabbed
pannable: r.pannable === void 0 ? n === "edges" : !!r.pannable,
// whether the element has passthrough panning enabled
active: !1,
// whether the element is active from user interaction
classes: new na(),
// map ( className => true )
animation: {
// object for currently-running animations
current: [],
queue: []
},
rscratch: {},
// object in which the renderer can store information
scratch: r.scratch || {},
// scratch objects
edges: [],
// array of connected edges
children: [],
// array of children
parent: r.parent && r.parent.isNode() ? r.parent : null,
// parent ref
traversalCache: {},
// cache of output of traversal functions
backgrounding: !1,
// whether background images are loading
bbCache: null,
// cache of the current bounding box
bbCacheShift: {
x: 0,
y: 0
},
// shift applied to cached bb to be applied on next get
bodyBounds: null,
// bounds cache of element body, w/o overlay
overlayBounds: null,
// bounds cache of element body, including overlay
labelBounds: {
// bounds cache of labels
all: null,
source: null,
target: null,
main: null
},
arrowBounds: {
// bounds cache of edge arrows
source: null,
target: null,
"mid-source": null,
"mid-target": null
}
};
if (i.position.x == null && (i.position.x = 0), i.position.y == null && (i.position.y = 0), r.renderedPosition) {
var s = r.renderedPosition, o = e.pan(), u = e.zoom();
i.position = {
x: (s.x - o.x) / u,
y: (s.y - o.y) / u
};
}
var l = [];
Ve(r.classes) ? l = r.classes : ge(r.classes) && (l = r.classes.split(/\s+/));
for (var f = 0, c = l.length; f < c; f++) {
var v = l[f];
!v || v === "" || i.classes.add(v);
}
this.createEmitter(), (a === void 0 || a) && this.restore();
var h = r.style || r.css;
h && (Ge("Setting a `style` bypass at element creation should be done only when absolutely necessary. Try to use the stylesheet instead."), this.style(h));
}, eu = function(e) {
return e = {
bfs: e.bfs || !e.dfs,
dfs: e.dfs || !e.bfs
}, function(a, n, i) {
var s;
Oe(a) && !Lt(a) && (s = a, a = s.roots || s.root, n = s.visit, i = s.directed), i = arguments.length === 2 && !Xe(n) ? n : i, n = Xe(n) ? n : function() {
};
for (var o = this._private.cy, u = a = ge(a) ? this.filter(a) : a, l = [], f = [], c = {}, v = {}, h = {}, d = 0, p, g = this.byGroup(), y = g.nodes, b = g.edges, m = 0; m < u.length; m++) {
var E = u[m], T = E.id();
E.isNode() && (l.unshift(E), e.bfs && (h[T] = !0, f.push(E)), v[T] = 0);
}
for (var S = function() {
var R = e.bfs ? l.shift() : l.pop(), I = R.id();
if (e.dfs) {
if (h[I])
return 0;
h[I] = !0, f.push(R);
}
var M = v[I], N = c[I], O = N != null ? N.source() : null, k = N != null ? N.target() : null, B = N == null ? void 0 : R.same(O) ? k[0] : O[0], _;
if (_ = n(R, N, B, d++, M), _ === !0)
return p = R, 1;
if (_ === !1)
return 1;
for (var F = R.connectedEdges().filter(function(W) {
return (!i || W.source().same(R)) && b.has(W);
}), G = 0; G < F.length; G++) {
var H = F[G], Y = H.connectedNodes().filter(function(W) {
return !W.same(R) && y.has(W);
}), X = Y.id();
Y.length !== 0 && !h[X] && (Y = Y[0], l.push(Y), e.bfs && (h[X] = !0, f.push(Y)), c[X] = H, v[X] = v[I] + 1);
}
}, w; l.length !== 0 && (w = S(), !(w !== 0 && w === 1)); )
;
for (var x = o.collection(), C = 0; C < f.length; C++) {
var D = f[C], A = c[D.id()];
A != null && x.push(A), x.push(D);
}
return {
path: o.collection(x),
found: o.collection(p)
};
};
}, La = {
breadthFirstSearch: eu({
bfs: !0
}),
depthFirstSearch: eu({
dfs: !0
})
};
La.bfs = La.breadthFirstSearch;
La.dfs = La.depthFirstSearch;
var fn = { exports: {} }, Ah = fn.exports, tu;
function Lh() {
return tu || (tu = 1, function(t, e) {
(function() {
var r, a, n, i, s, o, u, l, f, c, v, h, d, p, g;
n = Math.floor, c = Math.min, a = function(y, b) {
return y < b ? -1 : y > b ? 1 : 0;
}, f = function(y, b, m, E, T) {
var S;
if (m == null && (m = 0), T == null && (T = a), m < 0)
throw new Error("lo must be non-negative");
for (E == null && (E = y.length); m < E; )
S = n((m + E) / 2), T(b, y[S]) < 0 ? E = S : m = S + 1;
return [].splice.apply(y, [m, m - m].concat(b)), b;
}, o = function(y, b, m) {
return m == null && (m = a), y.push(b), p(y, 0, y.length - 1, m);
}, s = function(y, b) {
var m, E;
return b == null && (b = a), m = y.pop(), y.length ? (E = y[0], y[0] = m, g(y, 0, b)) : E = m, E;
}, l = function(y, b, m) {
var E;
return m == null && (m = a), E = y[0], y[0] = b, g(y, 0, m), E;
}, u = function(y, b, m) {
var E;
return m == null && (m = a), y.length && m(y[0], b) < 0 && (E = [y[0], b], b = E[0], y[0] = E[1], g(y, 0, m)), b;
}, i = function(y, b) {
var m, E, T, S, w, x;
for (b == null && (b = a), S = (function() {
x = [];
for (var C = 0, D = n(y.length / 2); 0 <= D ? C < D : C > D; 0 <= D ? C++ : C--)
x.push(C);
return x;
}).apply(this).reverse(), w = [], E = 0, T = S.length; E < T; E++)
m = S[E], w.push(g(y, m, b));
return w;
}, d = function(y, b, m) {
var E;
if (m == null && (m = a), E = y.indexOf(b), E !== -1)
return p(y, 0, E, m), g(y, E, m);
}, v = function(y, b, m) {
var E, T, S, w, x;
if (m == null && (m = a), T = y.slice(0, b), !T.length)
return T;
for (i(T, m), x = y.slice(b), S = 0, w = x.length; S < w; S++)
E = x[S], u(T, E, m);
return T.sort(m).reverse();
}, h = function(y, b, m) {
var E, T, S, w, x, C, D, A, L;
if (m == null && (m = a), b * 10 <= y.length) {
if (S = y.slice(0, b).sort(m), !S.length)
return S;
for (T = S[S.length - 1], D = y.slice(b), w = 0, C = D.length; w < C; w++)
E = D[w], m(E, T) < 0 && (f(S, E, 0, null, m), S.pop(), T = S[S.length - 1]);
return S;
}
for (i(y, m), L = [], x = 0, A = c(b, y.length); 0 <= A ? x < A : x > A; 0 <= A ? ++x : --x)
L.push(s(y, m));
return L;
}, p = function(y, b, m, E) {
var T, S, w;
for (E == null && (E = a), T = y[m]; m > b; ) {
if (w = m - 1 >> 1, S = y[w], E(T, S) < 0) {
y[m] = S, m = w;
continue;
}
break;
}
return y[m] = T;
}, g = function(y, b, m) {
var E, T, S, w, x;
for (m == null && (m = a), T = y.length, x = b, S = y[b], E = 2 * b + 1; E < T; )
w = E + 1, w < T && !(m(y[E], y[w]) < 0) && (E = w), y[b] = y[E], b = E, E = 2 * b + 1;
return y[b] = S, p(y, x, b, m);
}, r = function() {
y.push = o, y.pop = s, y.replace = l, y.pushpop = u, y.heapify = i, y.updateItem = d, y.nlargest = v, y.nsmallest = h;
function y(b) {
this.cmp = b ?? a, this.nodes = [];
}
return y.prototype.push = function(b) {
return o(this.nodes, b, this.cmp);
}, y.prototype.pop = function() {
return s(this.nodes, this.cmp);
}, y.prototype.peek = function() {
return this.nodes[0];
}, y.prototype.contains = function(b) {
return this.nodes.indexOf(b) !== -1;
}, y.prototype.replace = function(b) {
return l(this.nodes, b, this.cmp);
}, y.prototype.pushpop = function(b) {
return u(this.nodes, b, this.cmp);
}, y.prototype.heapify = function() {
return i(this.nodes, this.cmp);
}, y.prototype.updateItem = function(b) {
return d(this.nodes, b, this.cmp);
}, y.prototype.clear = function() {
return this.nodes = [];
}, y.prototype.empty = function() {
return this.nodes.length === 0;
}, y.prototype.size = function() {
return this.nodes.length;
}, y.prototype.clone = function() {
var b;
return b = new y(), b.nodes = this.nodes.slice(0), b;
}, y.prototype.toArray = function() {
return this.nodes.slice(0);
}, y.prototype.insert = y.prototype.push, y.prototype.top = y.prototype.peek, y.prototype.front = y.prototype.peek, y.prototype.has = y.prototype.contains, y.prototype.copy = y.prototype.clone, y;
}(), function(y, b) {
return t.exports = b();
}(this, function() {
return r;
});
}).call(Ah);
}(fn)), fn.exports;
}
var mi, ru;
function Rh() {
return ru || (ru = 1, mi = Lh()), mi;
}
var Ih = Rh(), Ua = /* @__PURE__ */ _a(Ih), Ph = ht({
root: null,
weight: function(e) {
return 1;
},
directed: !1
}), Mh = {
dijkstra: function(e) {
if (!Oe(e)) {
var r = arguments;
e = {
root: r[0],
weight: r[1],
directed: r[2]
};
}
var a = Ph(e), n = a.root, i = a.weight, s = a.directed, o = this, u = i, l = ge(n) ? this.filter(n)[0] : n[0], f = {}, c = {}, v = {}, h = this.byGroup(), d = h.nodes, p = h.edges;
p.unmergeBy(function(M) {
return M.isLoop();
});
for (var g = function(N) {
return f[N.id()];
}, y = function(N, O) {
f[N.id()] = O, b.updateItem(N);
}, b = new Ua(function(M, N) {
return g(M) - g(N);
}), m = 0; m < d.length; m++) {
var E = d[m];
f[E.id()] = E.same(l) ? 0 : 1 / 0, b.push(E);
}
for (var T = function(N, O) {
for (var k = (s ? N.edgesTo(O) : N.edgesWith(O)).intersect(p), B = 1 / 0, _, F = 0; F < k.length; F++) {
var G = k[F], H = u(G);
(H < B || !_) && (B = H, _ = G);
}
return {
edge: _,
dist: B
};
}; b.size() > 0; ) {
var S = b.pop(), w = g(S), x = S.id();
if (v[x] = w, w !== 1 / 0)
for (var C = S.neighborhood().intersect(d), D = 0; D < C.length; D++) {
var A = C[D], L = A.id(), R = T(S, A), I = w + R.dist;
I < g(A) && (y(A, I), c[L] = {
node: S,
edge: R.edge
});
}
}
return {
distanceTo: function(N) {
var O = ge(N) ? d.filter(N)[0] : N[0];
return v[O.id()];
},
pathTo: function(N) {
var O = ge(N) ? d.filter(N)[0] : N[0], k = [], B = O, _ = B.id();
if (O.length > 0)
for (k.unshift(O); c[_]; ) {
var F = c[_];
k.unshift(F.edge), k.unshift(F.node), B = F.node, _ = B.id();
}
return o.spawn(k);
}
};
}
}, Oh = {
// kruskal's algorithm (finds min spanning tree, assuming undirected graph)
// implemented from pseudocode from wikipedia
kruskal: function(e) {
e = e || function(m) {
return 1;
};
for (var r = this.byGroup(), a = r.nodes, n = r.edges, i = a.length, s = new Array(i), o = a, u = function(E) {
for (var T = 0; T < s.length; T++) {
var S = s[T];
if (S.has(E))
return T;
}
}, l = 0; l < i; l++)
s[l] = this.spawn(a[l]);
for (var f = n.sort(function(m, E) {
return e(m) - e(E);
}), c = 0; c < f.length; c++) {
var v = f[c], h = v.source()[0], d = v.target()[0], p = u(h), g = u(d), y = s[p], b = s[g];
p !== g && (o.merge(v), y.merge(b), s.splice(g, 1));
}
return o;
}
}, kh = ht({
root: null,
goal: null,
weight: function(e) {
return 1;
},
heuristic: function(e) {
return 0;
},
directed: !1
}), Nh = {
// Implemented from pseudocode from wikipedia
aStar: function(e) {
var r = this.cy(), a = kh(e), n = a.root, i = a.goal, s = a.heuristic, o = a.directed, u = a.weight;
n = r.collection(n)[0], i = r.collection(i)[0];
var l = n.id(), f = i.id(), c = {}, v = {}, h = {}, d = new Ua(function(_, F) {
return v[_.id()] - v[F.id()];
}), p = new na(), g = {}, y = {}, b = function(F, G) {
d.push(F), p.add(G);
}, m, E, T = function() {
m = d.pop(), E = m.id(), p.delete(E);
}, S = function(F) {
return p.has(F);
};
b(n, l), c[l] = 0, v[l] = s(n);
for (var w = 0; d.size() > 0; ) {
if (T(), w++, E === f) {
for (var x = [], C = i, D = f, A = y[D]; x.unshift(C), A != null && x.unshift(A), C = g[D], C != null; )
D = C.id(), A = y[D];
return {
found: !0,
distance: c[E],
path: this.spawn(x),
steps: w
};
}
h[E] = !0;
for (var L = m._private.edges, R = 0; R < L.length; R++) {
var I = L[R];
if (this.hasElementWithId(I.id()) && !(o && I.data("source") !== E)) {
var M = I.source(), N = I.target(), O = M.id() !== E ? M : N, k = O.id();
if (this.hasElementWithId(k) && !h[k]) {
var B = c[E] + u(I);
if (!S(k)) {
c[k] = B, v[k] = B + s(O), b(O, k), g[k] = m, y[k] = I;
continue;
}
B < c[k] && (c[k] = B, v[k] = B + s(O), g[k] = m, y[k] = I);
}
}
}
}
return {
found: !1,
distance: void 0,
path: void 0,
steps: w
};
}
}, Bh = ht({
weight: function(e) {
return 1;
},
directed: !1
}), Fh = {
// Implemented from pseudocode from wikipedia
floydWarshall: function(e) {
for (var r = this.cy(), a = Bh(e), n = a.weight, i = a.directed, s = n, o = this.byGroup(), u = o.nodes, l = o.edges, f = u.length, c = f * f, v = function(H) {
return u.indexOf(H);
}, h = function(H) {
return u[H];
}, d = new Array(c), p = 0; p < c; p++) {
var g = p % f, y = (p - g) / f;
y === g ? d[p] = 0 : d[p] = 1 / 0;
}
for (var b = new Array(c), m = new Array(c), E = 0; E < l.length; E++) {
var T = l[E], S = T.source()[0], w = T.target()[0];
if (S !== w) {
var x = v(S), C = v(w), D = x * f + C, A = s(T);
if (d[D] > A && (d[D] = A, b[D] = C, m[D] = T), !i) {
var L = C * f + x;
!i && d[L] > A && (d[L] = A, b[L] = x, m[L] = T);
}
}
}
for (var R = 0; R < f; R++)
for (var I = 0; I < f; I++)
for (var M = I * f + R, N = 0; N < f; N++) {
var O = I * f + N, k = R * f + N;
d[M] + d[k] < d[O] && (d[O] = d[M] + d[k], b[O] = b[M]);
}
var B = function(H) {
return (ge(H) ? r.filter(H) : H)[0];
}, _ = function(H) {
return v(B(H));
}, F = {
distance: function(H, Y) {
var X = _(H), W = _(Y);
return d[X * f + W];
},
path: function(H, Y) {
var X = _(H), W = _(Y), ee = h(X);
if (X === W)
return ee.collection();
if (b[X * f + W] == null)
return r.collection();
var ae = r.collection(), J = X, z;
for (ae.merge(ee); X !== W; )
J = X, X = b[X * f + W], z = m[J * f + X], ae.merge(z), ae.merge(h(X));
return ae;
}
};
return F;
}
// floydWarshall
}, _h = ht({
weight: function(e) {
return 1;
},
directed: !1,
root: null
}), Gh = {
// Implemented from pseudocode from wikipedia
bellmanFord: function(e) {
var r = this, a = _h(e), n = a.weight, i = a.directed, s = a.root, o = n, u = this, l = this.cy(), f = this.byGroup(), c = f.edges, v = f.nodes, h = v.length, d = new Zt(), p = !1, g = [];
s = l.collection(s)[0], c.unmergeBy(function(Te) {
return Te.isLoop();
});
for (var y = c.length, b = function(we) {
var ye = d.get(we.id());
return ye || (ye = {}, d.set(we.id(), ye)), ye;
}, m = function(we) {
return (ge(we) ? l.$(we) : we)[0];
}, E = function(we) {
return b(m(we)).dist;
}, T = function(we) {
for (var ye = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : s, ie = m(we), he = [], de = ie; ; ) {
if (de == null)
return r.spawn();
var xe = b(de), pe = xe.edge, De = xe.pred;
if (he.unshift(de[0]), de.same(ye) && he.length > 0)
break;
pe != null && he.unshift(pe), de = De;
}
return u.spawn(he);
}, S = 0; S < h; S++) {
var w = v[S], x = b(w);
w.same(s) ? x.dist = 0 : x.dist = 1 / 0, x.pred = null, x.edge = null;
}
for (var C = !1, D = function(we, ye, ie, he, de, xe) {
var pe = he.dist + xe;
pe < de.dist && !ie.same(he.edge) && (de.dist = pe, de.pred = we, de.edge = ie, C = !0);
}, A = 1; A < h; A++) {
C = !1;
for (var L = 0; L < y; L++) {
var R = c[L], I = R.source(), M = R.target(), N = o(R), O = b(I), k = b(M);
D(I, M, R, O, k, N), i || D(M, I, R, k, O, N);
}
if (!C)
break;
}
if (C)
for (var B = [], _ = 0; _ < y; _++) {
var F = c[_], G = F.source(), H = F.target(), Y = o(F), X = b(G).dist, W = b(H).dist;
if (X + Y < W || !i && W + Y < X)
if (p || (Ge("Graph contains a negative weight cycle for Bellman-Ford"), p = !0), e.findNegativeWeightCycles !== !1) {
var ee = [];
X + Y < W && ee.push(G), !i && W + Y < X && ee.push(H);
for (var ae = ee.length, J = 0; J < ae; J++) {
var z = ee[J], V = [z];
V.push(b(z).edge);
for (var q = b(z).pred; V.indexOf(q) === -1; )
V.push(q), V.push(b(q).edge), q = b(q).pred;
V = V.slice(V.indexOf(q));
for (var Z = V[0].id(), re = 0, ve = 2; ve < V.length; ve += 2)
V[ve].id() < Z && (Z = V[ve].id(), re = ve);
V = V.slice(re).concat(V.slice(0, re)), V.push(V[0]);
var Ie = V.map(function(Te) {
return Te.id();
}).join(",");
B.indexOf(Ie) === -1 && (g.push(u.spawn(V)), B.push(Ie));
}
} else
break;
}
return {
distanceTo: E,
pathTo: T,
hasNegativeWeightCycle: p,
negativeWeightCycles: g
};
}
// bellmanFord
}, zh = Math.sqrt(2), Vh = function(e, r, a) {
a.length === 0 && He("Karger-Stein must be run on a connected (sub)graph");
for (var n = a[e], i = n[1], s = n[2], o = r[i], u = r[s], l = a, f = l.length - 1; f >= 0; f--) {
var c = l[f], v = c[1], h = c[2];
(r[v] === o && r[h] === u || r[v] === u && r[h] === o) && l.splice(f, 1);
}
for (var d = 0; d < l.length; d++) {
var p = l[d];
p[1] === u ? (l[d] = p.slice(), l[d][1] = o) : p[2] === u && (l[d] = p.slice(), l[d][2] = o);
}
for (var g = 0; g < r.length; g++)
r[g] === u && (r[g] = o);
return l;
}, bi = function(e, r, a, n) {
for (; a > n; ) {
var i = Math.floor(Math.random() * r.length);
r = Vh(i, e, r), a--;
}
return r;
}, Uh = {
// Computes the minimum cut of an undirected graph
// Returns the correct answer with high probability
kargerStein: function() {
var e = this, r = this.byGroup(), a = r.nodes, n = r.edges;
n.unmergeBy(function(k) {
return k.isLoop();
});
var i = a.length, s = n.length, o = Math.ceil(Math.pow(Math.log(i) / Math.LN2, 2)), u = Math.floor(i / zh);
if (i < 2) {
He("At least 2 nodes are required for Karger-Stein algorithm");
return;
}
for (var l = [], f = 0; f < s; f++) {
var c = n[f];
l.push([f, a.indexOf(c.source()), a.indexOf(c.target())]);
}
for (var v = 1 / 0, h = [], d = new Array(i), p = new Array(i), g = new Array(i), y = function(B, _) {
for (var F = 0; F < i; F++)
_[F] = B[F];
}, b = 0; b <= o; b++) {
for (var m = 0; m < i; m++)
p[m] = m;
var E = bi(p, l.slice(), i, u), T = E.slice();
y(p, g);
var S = bi(p, E, u, 2), w = bi(g, T, u, 2);
S.length <= w.length && S.length < v ? (v = S.length, h = S, y(p, d)) : w.length <= S.length && w.length < v && (v = w.length, h = w, y(g, d));
}
for (var x = this.spawn(h.map(function(k) {
return n[k[0]];
})), C = this.spawn(), D = this.spawn(), A = d[0], L = 0; L < d.length; L++) {
var R = d[L], I = a[L];
R === A ? C.merge(I) : D.merge(I);
}
var M = function(B) {
var _ = e.spawn();
return B.forEach(function(F) {
_.merge(F), F.connectedEdges().forEach(function(G) {
e.contains(G) && !x.contains(G) && _.merge(G);
});
}), _;
}, N = [M(C), M(D)], O = {
cut: x,
components: N,
// n.b. partitions are included to be compatible with the old api spec
// (could be removed in a future major version)
partition1: C,
partition2: D
};
return O;
}
}, wi, qh = function(e) {
return {
x: e.x,
y: e.y
};
}, zn = function(e, r, a) {
return {
x: e.x * r + a.x,
y: e.y * r + a.y
};
}, Pf = function(e, r, a) {
return {
x: (e.x - a.x) / r,
y: (e.y - a.y) / r
};
}, Wr = function(e) {
return {
x: e[0],
y: e[1]
};
}, Yh = function(e) {
for (var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : e.length, n = 1 / 0, i = r; i < a; i++) {
var s = e[i];
isFinite(s) && (n = Math.min(s, n));
}
return n;
}, Hh = function(e) {
for (var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : e.length, n = -1 / 0, i = r; i < a; i++) {
var s = e[i];
isFinite(s) && (n = Math.max(s, n));
}
return n;
}, Xh = function(e) {
for (var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : e.length, n = 0, i = 0, s = r; s < a; s++) {
var o = e[s];
isFinite(o) && (n += o, i++);
}
return n / i;
}, $h = function(e) {
var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : e.length, n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !0, i = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, s = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : !0;
n ? e = e.slice(r, a) : (a < e.length && e.splice(a, e.length - a), r > 0 && e.splice(0, r));
for (var o = 0, u = e.length - 1; u >= 0; u--) {
var l = e[u];
s ? isFinite(l) || (e[u] = -1 / 0, o++) : e.splice(u, 1);
}
i && e.sort(function(v, h) {
return v - h;
});
var f = e.length, c = Math.floor(f / 2);
return f % 2 !== 0 ? e[c + 1 + o] : (e[c - 1 + o] + e[c + o]) / 2;
}, Wh = function(e) {
return Math.PI * e / 180;
}, Ja = function(e, r) {
return Math.atan2(r, e) - Math.PI / 2;
}, co = Math.log2 || function(t) {
return Math.log(t) / Math.log(2);
}, vo = function(e) {
return e > 0 ? 1 : e < 0 ? -1 : 0;
}, Pr = function(e, r) {
return Math.sqrt(Dr(e, r));
}, Dr = function(e, r) {
var a = r.x - e.x, n = r.y - e.y;
return a * a + n * n;
}, Kh = function(e) {
for (var r = e.length, a = 0, n = 0; n < r; n++)
a += e[n];
for (var i = 0; i < r; i++)
e[i] = e[i] / a;
return e;
}, ot = function(e, r, a, n) {
return (1 - n) * (1 - n) * e + 2 * (1 - n) * n * r + n * n * a;
}, Qr = function(e, r, a, n) {
return {
x: ot(e.x, r.x, a.x, n),
y: ot(e.y, r.y, a.y, n)
};
}, Zh = function(e, r, a, n) {
var i = {
x: r.x - e.x,
y: r.y - e.y
}, s = Pr(e, r), o = {
x: i.x / s,
y: i.y / s
};
return a = a ?? 0, n = n ?? a * s, {
x: e.x + o.x * n,
y: e.y + o.y * n
};
}, Ra = function(e, r, a) {
return Math.max(e, Math.min(a, r));
}, Et = function(e) {
if (e == null)
return {
x1: 1 / 0,
y1: 1 / 0,
x2: -1 / 0,
y2: -1 / 0,
w: 0,
h: 0
};
if (e.x1 != null && e.y1 != null) {
if (e.x2 != null && e.y2 != null && e.x2 >= e.x1 && e.y2 >= e.y1)
return {
x1: e.x1,
y1: e.y1,
x2: e.x2,
y2: e.y2,
w: e.x2 - e.x1,
h: e.y2 - e.y1
};
if (e.w != null && e.h != null && e.w >= 0 && e.h >= 0)
return {
x1: e.x1,
y1: e.y1,
x2: e.x1 + e.w,
y2: e.y1 + e.h,
w: e.w,
h: e.h
};
}
}, Qh = function(e) {
return {
x1: e.x1,
x2: e.x2,
w: e.w,
y1: e.y1,
y2: e.y2,
h: e.h
};
}, Jh = function(e) {
e.x1 = 1 / 0, e.y1 = 1 / 0, e.x2 = -1 / 0, e.y2 = -1 / 0, e.w = 0, e.h = 0;
}, jh = function(e, r) {
e.x1 = Math.min(e.x1, r.x1), e.x2 = Math.max(e.x2, r.x2), e.w = e.x2 - e.x1, e.y1 = Math.min(e.y1, r.y1), e.y2 = Math.max(e.y2, r.y2), e.h = e.y2 - e.y1;
}, Mf = function(e, r, a) {
e.x1 = Math.min(e.x1, r), e.x2 = Math.max(e.x2, r), e.w = e.x2 - e.x1, e.y1 = Math.min(e.y1, a), e.y2 = Math.max(e.y2, a), e.h = e.y2 - e.y1;
}, cn = function(e) {
var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
return e.x1 -= r, e.x2 += r, e.y1 -= r, e.y2 += r, e.w = e.x2 - e.x1, e.h = e.y2 - e.y1, e;
}, vn = function(e) {
var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [0], a, n, i, s;
if (r.length === 1)
a = n = i = s = r[0];
else if (r.length === 2)
a = i = r[0], s = n = r[1];
else if (r.length === 4) {
var o = Je(r, 4);
a = o[0], n = o[1], i = o[2], s = o[3];
}
return e.x1 -= s, e.x2 += n, e.y1 -= a, e.y2 += i, e.w = e.x2 - e.x1, e.h = e.y2 - e.y1, e;
}, au = function(e, r) {
e.x1 = r.x1, e.y1 = r.y1, e.x2 = r.x2, e.y2 = r.y2, e.w = e.x2 - e.x1, e.h = e.y2 - e.y1;
}, ho = function(e, r) {
return !(e.x1 > r.x2 || r.x1 > e.x2 || e.x2 < r.x1 || r.x2 < e.x1 || e.y2 < r.y1 || r.y2 < e.y1 || e.y1 > r.y2 || r.y1 > e.y2);
}, sr = function(e, r, a) {
return e.x1 <= r && r <= e.x2 && e.y1 <= a && a <= e.y2;
}, nu = function(e, r) {
return sr(e, r.x, r.y);
}, Of = function(e, r) {
return sr(e, r.x1, r.y1) && sr(e, r.x2, r.y2);
}, ed = (wi = Math.hypot) !== null && wi !== void 0 ? wi : function(t, e) {
return Math.sqrt(t * t + e * e);
};
function td(t, e) {
if (t.length < 3)
throw new Error("Need at least 3 vertices");
var r = function(x, C) {
return {
x: x.x + C.x,
y: x.y + C.y
};
}, a = function(x, C) {
return {
x: x.x - C.x,
y: x.y - C.y
};
}, n = function(x, C) {
return {
x: x.x * C,
y: x.y * C
};
}, i = function(x, C) {
return x.x * C.y - x.y * C.x;
}, s = function(x) {
var C = ed(x.x, x.y);
return C === 0 ? {
x: 0,
y: 0
} : {
x: x.x / C,
y: x.y / C
};
}, o = function(x) {
for (var C = 0, D = 0; D < x.length; D++) {
var A = x[D], L = x[(D + 1) % x.length];
C += A.x * L.y - L.x * A.y;
}
return C / 2;
}, u = function(x, C, D, A) {
var L = a(C, x), R = a(A, D), I = i(L, R);
if (Math.abs(I) < 1e-9)
return r(x, n(L, 0.5));
var M = i(a(D, x), R) / I;
return r(x, n(L, M));
}, l = t.map(function(w) {
return {
x: w.x,
y: w.y
};
});
o(l) < 0 && l.reverse();
for (var f = l.length, c = [], v = 0; v < f; v++) {
var h = l[v], d = l[(v + 1) % f], p = a(d, h), g = s({
x: p.y,
y: -p.x
});
c.push(g);
}
for (var y = c.map(function(w, x) {
var C = r(l[x], n(w, e)), D = r(l[(x + 1) % f], n(w, e));
return {
p1: C,
p2: D
};
}), b = [], m = 0; m < f; m++) {
var E = y[(m - 1 + f) % f], T = y[m], S = u(E.p1, E.p2, T.p1, T.p2);
b.push(S);
}
return b;
}
function rd(t, e, r, a, n, i) {
var s = cd(t, e, r, a, n), o = td(s, i), u = Et();
return o.forEach(function(l) {
return Mf(u, l.x, l.y);
}), u;
}
var kf = function(e, r, a, n, i, s, o) {
var u = arguments.length > 7 && arguments[7] !== void 0 ? arguments[7] : "auto", l = u === "auto" ? vr(i, s) : u, f = i / 2, c = s / 2;
l = Math.min(l, f, c);
var v = l !== f, h = l !== c, d;
if (v) {
var p = a - f + l - o, g = n - c - o, y = a + f - l + o, b = g;
if (d = or(e, r, a, n, p, g, y, b, !1), d.length > 0)
return d;
}
if (h) {
var m = a + f + o, E = n - c + l - o, T = m, S = n + c - l + o;
if (d = or(e, r, a, n, m, E, T, S, !1), d.length > 0)
return d;
}
if (v) {
var w = a - f + l - o, x = n + c + o, C = a + f - l + o, D = x;
if (d = or(e, r, a, n, w, x, C, D, !1), d.length > 0)
return d;
}
if (h) {
var A = a - f - o, L = n - c + l - o, R = A, I = n + c - l + o;
if (d = or(e, r, a, n, A, L, R, I, !1), d.length > 0)
return d;
}
var M;
{
var N = a - f + l, O = n - c + l;
if (M = wa(e, r, a, n, N, O, l + o), M.length > 0 && M[0] <= N && M[1] <= O)
return [M[0], M[1]];
}
{
var k = a + f - l, B = n - c + l;
if (M = wa(e, r, a, n, k, B, l + o), M.length > 0 && M[0] >= k && M[1] <= B)
return [M[0], M[1]];
}
{
var _ = a + f - l, F = n + c - l;
if (M = wa(e, r, a, n, _, F, l + o), M.length > 0 && M[0] >= _ && M[1] >= F)
return [M[0], M[1]];
}
{
var G = a - f + l, H = n + c - l;
if (M = wa(e, r, a, n, G, H, l + o), M.length > 0 && M[0] <= G && M[1] >= H)
return [M[0], M[1]];
}
return [];
}, ad = function(e, r, a, n, i, s, o) {
var u = o, l = Math.min(a, i), f = Math.max(a, i), c = Math.min(n, s), v = Math.max(n, s);
return l - u <= e && e <= f + u && c - u <= r && r <= v + u;
}, nd = function(e, r, a, n, i, s, o, u, l) {
var f = {
x1: Math.min(a, o, i) - l,
x2: Math.max(a, o, i) + l,
y1: Math.min(n, u, s) - l,
y2: Math.max(n, u, s) + l
};
return !(e < f.x1 || e > f.x2 || r < f.y1 || r > f.y2);
}, id = function(e, r, a, n) {
a -= n;
var i = r * r - 4 * e * a;
if (i < 0)
return [];
var s = Math.sqrt(i), o = 2 * e, u = (-r + s) / o, l = (-r - s) / o;
return [u, l];
}, sd = function(e, r, a, n, i) {
var s = 1e-5;
e === 0 && (e = s), r /= e, a /= e, n /= e;
var o, u, l, f, c, v, h, d;
if (u = (3 * a - r * r) / 9, l = -(27 * n) + r * (9 * a - 2 * (r * r)), l /= 54, o = u * u * u + l * l, i[1] = 0, h = r / 3, o > 0) {
c = l + Math.sqrt(o), c = c < 0 ? -Math.pow(-c, 1 / 3) : Math.pow(c, 1 / 3), v = l - Math.sqrt(o), v = v < 0 ? -Math.pow(-v, 1 / 3) : Math.pow(v, 1 / 3), i[0] = -h + c + v, h += (c + v) / 2, i[4] = i[2] = -h, h = Math.sqrt(3) * (-v + c) / 2, i[3] = h, i[5] = -h;
return;
}
if (i[5] = i[3] = 0, o === 0) {
d = l < 0 ? -Math.pow(-l, 1 / 3) : Math.pow(l, 1 / 3), i[0] = -h + 2 * d, i[4] = i[2] = -(d + h);
return;
}
u = -u, f = u * u * u, f = Math.acos(l / Math.sqrt(f)), d = 2 * Math.sqrt(u), i[0] = -h + d * Math.cos(f / 3), i[2] = -h + d * Math.cos((f + 2 * Math.PI) / 3), i[4] = -h + d * Math.cos((f + 4 * Math.PI) / 3);
}, od = function(e, r, a, n, i, s, o, u) {
var l = 1 * a * a - 4 * a * i + 2 * a * o + 4 * i * i - 4 * i * o + o * o + n * n - 4 * n * s + 2 * n * u + 4 * s * s - 4 * s * u + u * u, f = 1 * 9 * a * i - 3 * a * a - 3 * a * o - 6 * i * i + 3 * i * o + 9 * n * s - 3 * n * n - 3 * n * u - 6 * s * s + 3 * s * u, c = 1 * 3 * a * a - 6 * a * i + a * o - a * e + 2 * i * i + 2 * i * e - o * e + 3 * n * n - 6 * n * s + n * u - n * r + 2 * s * s + 2 * s * r - u * r, v = 1 * a * i - a * a + a * e - i * e + n * s - n * n + n * r - s * r, h = [];
sd(l, f, c, v, h);
for (var d = 1e-7, p = [], g = 0; g < 6; g += 2)
Math.abs(h[g + 1]) < d && h[g] >= 0 && h[g] <= 1 && p.push(h[g]);
p.push(1), p.push(0);
for (var y = -1, b, m, E, T = 0; T < p.length; T++)
b = Math.pow(1 - p[T], 2) * a + 2 * (1 - p[T]) * p[T] * i + p[T] * p[T] * o, m = Math.pow(1 - p[T], 2) * n + 2 * (1 - p[T]) * p[T] * s + p[T] * p[T] * u, E = Math.pow(b - e, 2) + Math.pow(m - r, 2), y >= 0 ? E < y && (y = E) : y = E;
return y;
}, ud = function(e, r, a, n, i, s) {
var o = [e - a, r - n], u = [i - a, s - n], l = u[0] * u[0] + u[1] * u[1], f = o[0] * o[0] + o[1] * o[1], c = o[0] * u[0] + o[1] * u[1], v = c * c / l;
return c < 0 ? f : v > l ? (e - i) * (e - i) + (r - s) * (r - s) : f - v;
}, St = function(e, r, a) {
for (var n, i, s, o, u, l = 0, f = 0; f < a.length / 2; f++)
if (n = a[f * 2], i = a[f * 2 + 1], f + 1 < a.length / 2 ? (s = a[(f + 1) * 2], o = a[(f + 1) * 2 + 1]) : (s = a[(f + 1 - a.length / 2) * 2], o = a[(f + 1 - a.length / 2) * 2 + 1]), !(n == e && s == e))
if (n >= e && e >= s || n <= e && e <= s)
u = (e - n) / (s - n) * (o - i) + i, u > r && l++;
else
continue;
return l % 2 !== 0;
}, Jt = function(e, r, a, n, i, s, o, u, l) {
var f = new Array(a.length), c;
u[0] != null ? (c = Math.atan(u[1] / u[0]), u[0] < 0 ? c = c + Math.PI / 2 : c = -c - Math.PI / 2) : c = u;
for (var v = Math.cos(-c), h = Math.sin(-c), d = 0; d < f.length / 2; d++)
f[d * 2] = s / 2 * (a[d * 2] * v - a[d * 2 + 1] * h), f[d * 2 + 1] = o / 2 * (a[d * 2 + 1] * v + a[d * 2] * h), f[d * 2] += n, f[d * 2 + 1] += i;
var p;
if (l > 0) {
var g = Ln(f, -l);
p = An(g);
} else
p = f;
return St(e, r, p);
}, ld = function(e, r, a, n, i, s, o, u) {
for (var l = new Array(a.length * 2), f = 0; f < u.length; f++) {
var c = u[f];
l[f * 4 + 0] = c.startX, l[f * 4 + 1] = c.startY, l[f * 4 + 2] = c.stopX, l[f * 4 + 3] = c.stopY;
var v = Math.pow(c.cx - e, 2) + Math.pow(c.cy - r, 2);
if (v <= Math.pow(c.radius, 2))
return !0;
}
return St(e, r, l);
}, An = function(e) {
for (var r = new Array(e.length / 2), a, n, i, s, o, u, l, f, c = 0; c < e.length / 4; c++) {
a = e[c * 4], n = e[c * 4 + 1], i = e[c * 4 + 2], s = e[c * 4 + 3], c < e.length / 4 - 1 ? (o = e[(c + 1) * 4], u = e[(c + 1) * 4 + 1], l = e[(c + 1) * 4 + 2], f = e[(c + 1) * 4 + 3]) : (o = e[0], u = e[1], l = e[2], f = e[3]);
var v = or(a, n, i, s, o, u, l, f, !0);
r[c * 2] = v[0], r[c * 2 + 1] = v[1];
}
return r;
}, Ln = function(e, r) {
for (var a = new Array(e.length * 2), n, i, s, o, u = 0; u < e.length / 2; u++) {
n = e[u * 2], i = e[u * 2 + 1], u < e.length / 2 - 1 ? (s = e[(u + 1) * 2], o = e[(u + 1) * 2 + 1]) : (s = e[0], o = e[1]);
var l = o - i, f = -(s - n), c = Math.sqrt(l * l + f * f), v = l / c, h = f / c;
a[u * 4] = n + v * r, a[u * 4 + 1] = i + h * r, a[u * 4 + 2] = s + v * r, a[u * 4 + 3] = o + h * r;
}
return a;
}, fd = function(e, r, a, n, i, s) {
var o = a - e, u = n - r;
o /= i, u /= s;
var l = Math.sqrt(o * o + u * u), f = l - 1;
if (f < 0)
return [];
var c = f / l;
return [(a - e) * c + e, (n - r) * c + r];
}, Rr = function(e, r, a, n, i, s, o) {
return e -= i, r -= s, e /= a / 2 + o, r /= n / 2 + o, e * e + r * r <= 1;
}, wa = function(e, r, a, n, i, s, o) {
var u = [a - e, n - r], l = [e - i, r - s], f = u[0] * u[0] + u[1] * u[1], c = 2 * (l[0] * u[0] + l[1] * u[1]), v = l[0] * l[0] + l[1] * l[1] - o * o, h = c * c - 4 * f * v;
if (h < 0)
return [];
var d = (-c + Math.sqrt(h)) / (2 * f), p = (-c - Math.sqrt(h)) / (2 * f), g = Math.min(d, p), y = Math.max(d, p), b = [];
if (g >= 0 && g <= 1 && b.push(g), y >= 0 && y <= 1 && b.push(y), b.length === 0)
return [];
var m = b[0] * u[0] + e, E = b[0] * u[1] + r;
if (b.length > 1) {
if (b[0] == b[1])
return [m, E];
var T = b[1] * u[0] + e, S = b[1] * u[1] + r;
return [m, E, T, S];
} else
return [m, E];
}, Ei = function(e, r, a) {
return r <= e && e <= a || a <= e && e <= r ? e : e <= r && r <= a || a <= r && r <= e ? r : a;
}, or = function(e, r, a, n, i, s, o, u, l) {
var f = e - i, c = a - e, v = o - i, h = r - s, d = n - r, p = u - s, g = v * h - p * f, y = c * h - d * f, b = p * c - v * d;
if (b !== 0) {
var m = g / b, E = y / b, T = 1e-3, S = 0 - T, w = 1 + T;
return S <= m && m <= w && S <= E && E <= w ? [e + m * c, r + m * d] : l ? [e + m * c, r + m * d] : [];
} else
return g === 0 || y === 0 ? Ei(e, a, o) === o ? [o, u] : Ei(e, a, i) === i ? [i, s] : Ei(i, o, a) === a ? [a, n] : [] : [];
}, cd = function(e, r, a, n, i) {
var s = [], o = n / 2, u = i / 2, l = r, f = a;
s.push({
x: l + o * e[0],
y: f + u * e[1]
});
for (var c = 1; c < e.length / 2; c++)
s.push({
x: l + o * e[c * 2],
y: f + u * e[c * 2 + 1]
});
return s;
}, Ia = function(e, r, a, n, i, s, o, u) {
var l = [], f, c = new Array(a.length), v = !0;
s == null && (v = !1);
var h;
if (v) {
for (var d = 0; d < c.length / 2; d++)
c[d * 2] = a[d * 2] * s + n, c[d * 2 + 1] = a[d * 2 + 1] * o + i;
if (u > 0) {
var p = Ln(c, -u);
h = An(p);
} else
h = c;
} else
h = a;
for (var g, y, b, m, E = 0; E < h.length / 2; E++)
g = h[E * 2], y = h[E * 2 + 1], E < h.length / 2 - 1 ? (b = h[(E + 1) * 2], m = h[(E + 1) * 2 + 1]) : (b = h[0], m = h[1]), f = or(e, r, n, i, g, y, b, m), f.length !== 0 && l.push(f[0], f[1]);
return l;
}, vd = function(e, r, a, n, i, s, o, u, l) {
var f = [], c, v = new Array(a.length * 2);
l.forEach(function(b, m) {
m === 0 ? (v[v.length - 2] = b.startX, v[v.length - 1] = b.startY) : (v[m * 4 - 2] = b.startX, v[m * 4 - 1] = b.startY), v[m * 4] = b.stopX, v[m * 4 + 1] = b.stopY, c = wa(e, r, n, i, b.cx, b.cy, b.radius), c.length !== 0 && f.push(c[0], c[1]);
});
for (var h = 0; h < v.length / 4; h++)
c = or(e, r, n, i, v[h * 4], v[h * 4 + 1], v[h * 4 + 2], v[h * 4 + 3], !1), c.length !== 0 && f.push(c[0], c[1]);
if (f.length > 2) {
for (var d = [f[0], f[1]], p = Math.pow(d[0] - e, 2) + Math.pow(d[1] - r, 2), g = 1; g < f.length / 2; g++) {
var y = Math.pow(f[g * 2] - e, 2) + Math.pow(f[g * 2 + 1] - r, 2);
y <= p && (d[0] = f[g * 2], d[1] = f[g * 2 + 1], p = y);
}
return d;
}
return f;
}, ja = function(e, r, a) {
var n = [e[0] - r[0], e[1] - r[1]], i = Math.sqrt(n[0] * n[0] + n[1] * n[1]), s = (i - a) / i;
return s < 0 && (s = 1e-5), [r[0] + s * n[0], r[1] + s * n[1]];
}, wt = function(e, r) {
var a = Bs(e, r);
return a = Nf(a), a;
}, Nf = function(e) {
for (var r, a, n = e.length / 2, i = 1 / 0, s = 1 / 0, o = -1 / 0, u = -1 / 0, l = 0; l < n; l++)
r = e[2 * l], a = e[2 * l + 1], i = Math.min(i, r), o = Math.max(o, r), s = Math.min(s, a), u = Math.max(u, a);
for (var f = 2 / (o - i), c = 2 / (u - s), v = 0; v < n; v++)
r = e[2 * v] = e[2 * v] * f, a = e[2 * v + 1] = e[2 * v + 1] * c, i = Math.min(i, r), o = Math.max(o, r), s = Math.min(s, a), u = Math.max(u, a);
if (s < -1)
for (var h = 0; h < n; h++)
a = e[2 * h + 1] = e[2 * h + 1] + (-1 - s);
return e;
}, Bs = function(e, r) {
var a = 1 / e * 2 * Math.PI, n = e % 2 === 0 ? Math.PI / 2 + a / 2 : Math.PI / 2;
n += r;
for (var i = new Array(e * 2), s, o = 0; o < e; o++)
s = o * a + n, i[2 * o] = Math.cos(s), i[2 * o + 1] = Math.sin(-s);
return i;
}, vr = function(e, r) {
return Math.min(e / 4, r / 4, 8);
}, Bf = function(e, r) {
return Math.min(e / 10, r / 10, 8);
}, go = function() {
return 8;
}, hd = function(e, r, a) {
return [e - 2 * r + a, 2 * (r - e), e];
}, Fs = function(e, r) {
return {
heightOffset: Math.min(15, 0.05 * r),
widthOffset: Math.min(100, 0.25 * e),
ctrlPtOffsetPct: 0.05
};
};
function xi(t, e) {
function r(c) {
for (var v = [], h = 0; h < c.length; h++) {
var d = c[h], p = c[(h + 1) % c.length], g = {
x: p.x - d.x,
y: p.y - d.y
}, y = {
x: -g.y,
y: g.x
}, b = Math.sqrt(y.x * y.x + y.y * y.y);
v.push({
x: y.x / b,
y: y.y / b
});
}
return v;
}
function a(c, v) {
var h = 1 / 0, d = -1 / 0, p = At(c), g;
try {
for (p.s(); !(g = p.n()).done; ) {
var y = g.value, b = y.x * v.x + y.y * v.y;
h = Math.min(h, b), d = Math.max(d, b);
}
} catch (m) {
p.e(m);
} finally {
p.f();
}
return {
min: h,
max: d
};
}
function n(c, v) {
return !(c.max < v.min || v.max < c.min);
}
var i = [].concat(Tn(r(t)), Tn(r(e))), s = At(i), o;
try {
for (s.s(); !(o = s.n()).done; ) {
var u = o.value, l = a(t, u), f = a(e, u);
if (!n(l, f))
return !1;
}
} catch (c) {
s.e(c);
} finally {
s.f();
}
return !0;
}
var dd = ht({
dampingFactor: 0.8,
precision: 1e-6,
iterations: 200,
weight: function(e) {
return 1;
}
}), gd = {
pageRank: function(e) {
for (var r = dd(e), a = r.dampingFactor, n = r.precision, i = r.iterations, s = r.weight, o = this._private.cy, u = this.byGroup(), l = u.nodes, f = u.edges, c = l.length, v = c * c, h = f.length, d = new Array(v), p = new Array(c), g = (1 - a) / c, y = 0; y < c; y++) {
for (var b = 0; b < c; b++) {
var m = y * c + b;
d[m] = 0;
}
p[y] = 0;
}
for (var E = 0; E < h; E++) {
var T = f[E], S = T.data("source"), w = T.data("target");
if (S !== w) {
var x = l.indexOfId(S), C = l.indexOfId(w), D = s(T), A = C * c + x;
d[A] += D, p[x] += D;
}
}
for (var L = 1 / c + g, R = 0; R < c; R++)
if (p[R] === 0)
for (var I = 0; I < c; I++) {
var M = I * c + R;
d[M] = L;
}
else
for (var N = 0; N < c; N++) {
var O = N * c + R;
d[O] = d[O] / p[R] + g;
}
for (var k = new Array(c), B = new Array(c), _, F = 0; F < c; F++)
k[F] = 1;
for (var G = 0; G < i; G++) {
for (var H = 0; H < c; H++)
B[H] = 0;
for (var Y = 0; Y < c; Y++)
for (var X = 0; X < c; X++) {
var W = Y * c + X;
B[Y] += d[W] * k[X];
}
Kh(B), _ = k, k = B, B = _;
for (var ee = 0, ae = 0; ae < c; ae++) {
var J = _[ae] - k[ae];
ee += J * J;
}
if (ee < n)
break;
}
var z = {
rank: function(q) {
return q = o.collection(q)[0], k[l.indexOf(q)];
}
};
return z;
}
// pageRank
}, iu = ht({
root: null,
weight: function(e) {
return 1;
},
directed: !1,
alpha: 0
}), Jr = {
degreeCentralityNormalized: function(e) {
e = iu(e);
var r = this.cy(), a = this.nodes(), n = a.length;
if (e.directed) {
for (var f = {}, c = {}, v = 0, h = 0, d = 0; d < n; d++) {
var p = a[d], g = p.id();
e.root = p;
var y = this.degreeCentrality(e);
v < y.indegree && (v = y.indegree), h < y.outdegree && (h = y.outdegree), f[g] = y.indegree, c[g] = y.outdegree;
}
return {
indegree: function(m) {
return v == 0 ? 0 : (ge(m) && (m = r.filter(m)), f[m.id()] / v);
},
outdegree: function(m) {
return h === 0 ? 0 : (ge(m) && (m = r.filter(m)), c[m.id()] / h);
}
};
} else {
for (var i = {}, s = 0, o = 0; o < n; o++) {
var u = a[o];
e.root = u;
var l = this.degreeCentrality(e);
s < l.degree && (s = l.degree), i[u.id()] = l.degree;
}
return {
degree: function(m) {
return s === 0 ? 0 : (ge(m) && (m = r.filter(m)), i[m.id()] / s);
}
};
}
},
// degreeCentralityNormalized
// Implemented from the algorithm in Opsahl's paper
// "Node centrality in weighted networks: Generalizing degree and shortest paths"
// check the heading 2 "Degree"
degreeCentrality: function(e) {
e = iu(e);
var r = this.cy(), a = this, n = e, i = n.root, s = n.weight, o = n.directed, u = n.alpha;
if (i = r.collection(i)[0], o) {
for (var h = i.connectedEdges(), d = h.filter(function(S) {
return S.target().same(i) && a.has(S);
}), p = h.filter(function(S) {
return S.source().same(i) && a.has(S);
}), g = d.length, y = p.length, b = 0, m = 0, E = 0; E < d.length; E++)
b += s(d[E]);
for (var T = 0; T < p.length; T++)
m += s(p[T]);
return {
indegree: Math.pow(g, 1 - u) * Math.pow(b, u),
outdegree: Math.pow(y, 1 - u) * Math.pow(m, u)
};
} else {
for (var l = i.connectedEdges().intersection(a), f = l.length, c = 0, v = 0; v < l.length; v++)
c += s(l[v]);
return {
degree: Math.pow(f, 1 - u) * Math.pow(c, u)
};
}
}
// degreeCentrality
};
Jr.dc = Jr.degreeCentrality;
Jr.dcn = Jr.degreeCentralityNormalised = Jr.degreeCentralityNormalized;
var su = ht({
harmonic: !0,
weight: function() {
return 1;
},
directed: !1,
root: null
}), jr = {
closenessCentralityNormalized: function(e) {
for (var r = su(e), a = r.harmonic, n = r.weight, i = r.directed, s = this.cy(), o = {}, u = 0, l = this.nodes(), f = this.floydWarshall({
weight: n,
directed: i
}), c = 0; c < l.length; c++) {
for (var v = 0, h = l[c], d = 0; d < l.length; d++)
if (c !== d) {
var p = f.distance(h, l[d]);
a ? v += 1 / p : v += p;
}
a || (v = 1 / v), u < v && (u = v), o[h.id()] = v;
}
return {
closeness: function(y) {
return u == 0 ? 0 : (ge(y) ? y = s.filter(y)[0].id() : y = y.id(), o[y] / u);
}
};
},
// Implemented from pseudocode from wikipedia
closenessCentrality: function(e) {
var r = su(e), a = r.root, n = r.weight, i = r.directed, s = r.harmonic;
a = this.filter(a)[0];
for (var o = this.dijkstra({
root: a,
weight: n,
directed: i
}), u = 0, l = this.nodes(), f = 0; f < l.length; f++) {
var c = l[f];
if (!c.same(a)) {
var v = o.distanceTo(c);
s ? u += 1 / v : u += v;
}
}
return s ? u : 1 / u;
}
// closenessCentrality
};
jr.cc = jr.closenessCentrality;
jr.ccn = jr.closenessCentralityNormalised = jr.closenessCentralityNormalized;
var pd = ht({
weight: null,
directed: !1
}), _s = {
// Implemented from the algorithm in the paper "On Variants of Shortest-Path Betweenness Centrality and their Generic Computation" by Ulrik Brandes
betweennessCentrality: function(e) {
for (var r = pd(e), a = r.directed, n = r.weight, i = n != null, s = this.cy(), o = this.nodes(), u = {}, l = {}, f = 0, c = {
set: function(m, E) {
l[m] = E, E > f && (f = E);
},
get: function(m) {
return l[m];
}
}, v = 0; v < o.length; v++) {
var h = o[v], d = h.id();
a ? u[d] = h.outgoers().nodes() : u[d] = h.openNeighborhood().nodes(), c.set(d, 0);
}
for (var p = function() {
for (var m = o[g].id(), E = [], T = {}, S = {}, w = {}, x = new Ua(function(Y, X) {
return w[Y] - w[X];
}), C = 0; C < o.length; C++) {
var D = o[C].id();
T[D] = [], S[D] = 0, w[D] = 1 / 0;
}
for (S[m] = 1, w[m] = 0, x.push(m); !x.empty(); ) {
var A = x.pop();
if (E.push(A), i)
for (var L = 0; L < u[A].length; L++) {
var R = u[A][L], I = s.getElementById(A), M = void 0;
I.edgesTo(R).length > 0 ? M = I.edgesTo(R)[0] : M = R.edgesTo(I)[0];
var N = n(M);
R = R.id(), w[R] > w[A] + N && (w[R] = w[A] + N, x.nodes.indexOf(R) < 0 ? x.push(R) : x.updateItem(R), S[R] = 0, T[R] = []), w[R] == w[A] + N && (S[R] = S[R] + S[A], T[R].push(A));
}
else
for (var O = 0; O < u[A].length; O++) {
var k = u[A][O].id();
w[k] == 1 / 0 && (x.push(k), w[k] = w[A] + 1), w[k] == w[A] + 1 && (S[k] = S[k] + S[A], T[k].push(A));
}
}
for (var B = {}, _ = 0; _ < o.length; _++)
B[o[_].id()] = 0;
for (; E.length > 0; ) {
for (var F = E.pop(), G = 0; G < T[F].length; G++) {
var H = T[F][G];
B[H] = B[H] + S[H] / S[F] * (1 + B[F]);
}
F != o[g].id() && c.set(F, c.get(F) + B[F]);
}
}, g = 0; g < o.length; g++)
p();
var y = {
betweenness: function(m) {
var E = s.collection(m).id();
return c.get(E);
},
betweennessNormalized: function(m) {
if (f == 0)
return 0;
var E = s.collection(m).id();
return c.get(E) / f;
}
};
return y.betweennessNormalised = y.betweennessNormalized, y;
}
// betweennessCentrality
};
_s.bc = _s.betweennessCentrality;
var yd = ht({
expandFactor: 2,
// affects time of computation and cluster granularity to some extent: M * M
inflateFactor: 2,
// affects cluster granularity (the greater the value, the more clusters): M(i,j) / E(j)
multFactor: 1,
// optional self loops for each node. Use a neutral value to improve cluster computations.
maxIterations: 20,
// maximum number of iterations of the MCL algorithm in a single run
attributes: [
// attributes/features used to group nodes, ie. similarity values between nodes
function(t) {
return 1;
}
]
}), md = function(e) {
return yd(e);
}, bd = function(e, r) {
for (var a = 0, n = 0; n < r.length; n++)
a += r[n](e);
return a;
}, wd = function(e, r, a) {
for (var n = 0; n < r; n++)
e[n * r + n] = a;
}, Ff = function(e, r) {
for (var a, n = 0; n < r; n++) {
a = 0;
for (var i = 0; i < r; i++)
a += e[i * r + n];
for (var s = 0; s < r; s++)
e[s * r + n] = e[s * r + n] / a;
}
}, Ed = function(e, r, a) {
for (var n = new Array(a * a), i = 0; i < a; i++) {
for (var s = 0; s < a; s++)
n[i * a + s] = 0;
for (var o = 0; o < a; o++)
for (var u = 0; u < a; u++)
n[i * a + u] += e[i * a + o] * r[o * a + u];
}
return n;
}, xd = function(e, r, a) {
for (var n = e.slice(0), i = 1; i < a; i++)
e = Ed(e, n, r);
return e;
}, Td = function(e, r, a) {
for (var n = new Array(r * r), i = 0; i < r * r; i++)
n[i] = Math.pow(e[i], a);
return Ff(n, r), n;
}, Cd = function(e, r, a, n) {
for (var i = 0; i < a; i++) {
var s = Math.round(e[i] * Math.pow(10, n)) / Math.pow(10, n), o = Math.round(r[i] * Math.pow(10, n)) / Math.pow(10, n);
if (s !== o)
return !1;
}
return !0;
}, Dd = function(e, r, a, n) {
for (var i = [], s = 0; s < r; s++) {
for (var o = [], u = 0; u < r; u++)
Math.round(e[s * r + u] * 1e3) / 1e3 > 0 && o.push(a[u]);
o.length !== 0 && i.push(n.collection(o));
}
return i;
}, Sd = function(e, r) {
for (var a = 0; a < e.length; a++)
if (!r[a] || e[a].id() !== r[a].id())
return !1;
return !0;
}, Ad = function(e) {
for (var r = 0; r < e.length; r++)
for (var a = 0; a < e.length; a++)
r != a && Sd(e[r], e[a]) && e.splice(a, 1);
return e;
}, ou = function(e) {
for (var r = this.nodes(), a = this.edges(), n = this.cy(), i = md(e), s = {}, o = 0; o < r.length; o++)
s[r[o].id()] = o;
for (var u = r.length, l = u * u, f = new Array(l), c, v = 0; v < l; v++)
f[v] = 0;
for (var h = 0; h < a.length; h++) {
var d = a[h], p = s[d.source().id()], g = s[d.target().id()], y = bd(d, i.attributes);
f[p * u + g] += y, f[g * u + p] += y;
}
wd(f, u, i.multFactor), Ff(f, u);
for (var b = !0, m = 0; b && m < i.maxIterations; )
b = !1, c = xd(f, u, i.expandFactor), f = Td(c, u, i.inflateFactor), Cd(f, c, l, 4) || (b = !0), m++;
var E = Dd(f, u, r, n);
return E = Ad(E), E;
}, Ld = {
markovClustering: ou,
mcl: ou
}, Rd = function(e) {
return e;
}, _f = function(e, r) {
return Math.abs(r - e);
}, uu = function(e, r, a) {
return e + _f(r, a);
}, lu = function(e, r, a) {
return e + Math.pow(a - r, 2);
}, Id = function(e) {
return Math.sqrt(e);
}, Pd = function(e, r, a) {
return Math.max(e, _f(r, a));
}, ha = function(e, r, a, n, i) {
for (var s = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : Rd, o = n, u, l, f = 0; f < e; f++)
u = r(f), l = a(f), o = i(o, u, l);
return s(o);
}, ra = {
euclidean: function(e, r, a) {
return e >= 2 ? ha(e, r, a, 0, lu, Id) : ha(e, r, a, 0, uu);
},
squaredEuclidean: function(e, r, a) {
return ha(e, r, a, 0, lu);
},
manhattan: function(e, r, a) {
return ha(e, r, a, 0, uu);
},
max: function(e, r, a) {
return ha(e, r, a, -1 / 0, Pd);
}
};
ra["squared-euclidean"] = ra.squaredEuclidean;
ra.squaredeuclidean = ra.squaredEuclidean;
function Vn(t, e, r, a, n, i) {
var s;
return Xe(t) ? s = t : s = ra[t] || ra.euclidean, e === 0 && Xe(t) ? s(n, i) : s(e, r, a, n, i);
}
var Md = ht({
k: 2,
m: 2,
sensitivityThreshold: 1e-4,
distance: "euclidean",
maxIterations: 10,
attributes: [],
testMode: !1,
testCentroids: null
}), po = function(e) {
return Md(e);
}, Rn = function(e, r, a, n, i) {
var s = i !== "kMedoids", o = s ? function(c) {
return a[c];
} : function(c) {
return n[c](a);
}, u = function(v) {
return n[v](r);
}, l = a, f = r;
return Vn(e, n.length, o, u, l, f);
}, Ti = function(e, r, a) {
for (var n = a.length, i = new Array(n), s = new Array(n), o = new Array(r), u = null, l = 0; l < n; l++)
i[l] = e.min(a[l]).value, s[l] = e.max(a[l]).value;
for (var f = 0; f < r; f++) {
u = [];
for (var c = 0; c < n; c++)
u[c] = Math.random() * (s[c] - i[c]) + i[c];
o[f] = u;
}
return o;
}, Gf = function(e, r, a, n, i) {
for (var s = 1 / 0, o = 0, u = 0; u < r.length; u++) {
var l = Rn(a, e, r[u], n, i);
l < s && (s = l, o = u);
}
return o;
}, zf = function(e, r, a) {
for (var n = [], i = null, s = 0; s < r.length; s++)
i = r[s], a[i.id()] === e && n.push(i);
return n;
}, Od = function(e, r, a) {
return Math.abs(r - e) <= a;
}, kd = function(e, r, a) {
for (var n = 0; n < e.length; n++)
for (var i = 0; i < e[n].length; i++) {
var s = Math.abs(e[n][i] - r[n][i]);
if (s > a)
return !1;
}
return !0;
}, Nd = function(e, r, a) {
for (var n = 0; n < a; n++)
if (e === r[n])
return !0;
return !1;
}, fu = function(e, r) {
var a = new Array(r);
if (e.length < 50)
for (var n = 0; n < r; n++) {
for (var i = e[Math.floor(Math.random() * e.length)]; Nd(i, a, n); )
i = e[Math.floor(Math.random() * e.length)];
a[n] = i;
}
else
for (var s = 0; s < r; s++)
a[s] = e[Math.floor(Math.random() * e.length)];
return a;
}, cu = function(e, r, a) {
for (var n = 0, i = 0; i < r.length; i++)
n += Rn("manhattan", r[i], e, a, "kMedoids");
return n;
}, Bd = function(e) {
var r = this.cy(), a = this.nodes(), n = null, i = po(e), s = new Array(i.k), o = {}, u;
i.testMode ? typeof i.testCentroids == "number" ? (i.testCentroids, u = Ti(a, i.k, i.attributes)) : nt(i.testCentroids) === "object" ? u = i.testCentroids : u = Ti(a, i.k, i.attributes) : u = Ti(a, i.k, i.attributes);
for (var l = !0, f = 0; l && f < i.maxIterations; ) {
for (var c = 0; c < a.length; c++)
n = a[c], o[n.id()] = Gf(n, u, i.distance, i.attributes, "kMeans");
l = !1;
for (var v = 0; v < i.k; v++) {
var h = zf(v, a, o);
if (h.length !== 0) {
for (var d = i.attributes.length, p = u[v], g = new Array(d), y = new Array(d), b = 0; b < d; b++) {
y[b] = 0;
for (var m = 0; m < h.length; m++)
n = h[m], y[b] += i.attributes[b](n);
g[b] = y[b] / h.length, Od(g[b], p[b], i.sensitivityThreshold) || (l = !0);
}
u[v] = g, s[v] = r.collection(h);
}
}
f++;
}
return s;
}, Fd = function(e) {
var r = this.cy(), a = this.nodes(), n = null, i = po(e), s = new Array(i.k), o, u = {}, l, f = new Array(i.k);
i.testMode ? typeof i.testCentroids == "number" || (nt(i.testCentroids) === "object" ? o = i.testCentroids : o = fu(a, i.k)) : o = fu(a, i.k);
for (var c = !0, v = 0; c && v < i.maxIterations; ) {
for (var h = 0; h < a.length; h++)
n = a[h], u[n.id()] = Gf(n, o, i.distance, i.attributes, "kMedoids");
c = !1;
for (var d = 0; d < o.length; d++) {
var p = zf(d, a, u);
if (p.length !== 0) {
f[d] = cu(o[d], p, i.attributes);
for (var g = 0; g < p.length; g++)
l = cu(p[g], p, i.attributes), l < f[d] && (f[d] = l, o[d] = p[g], c = !0);
s[d] = r.collection(p);
}
}
v++;
}
return s;
}, _d = function(e, r, a, n, i) {
for (var s, o, u = 0; u < r.length; u++)
for (var l = 0; l < e.length; l++)
n[u][l] = Math.pow(a[u][l], i.m);
for (var f = 0; f < e.length; f++)
for (var c = 0; c < i.attributes.length; c++) {
s = 0, o = 0;
for (var v = 0; v < r.length; v++)
s += n[v][f] * i.attributes[c](r[v]), o += n[v][f];
e[f][c] = s / o;
}
}, Gd = function(e, r, a, n, i) {
for (var s = 0; s < e.length; s++)
r[s] = e[s].slice();
for (var o, u, l, f = 2 / (i.m - 1), c = 0; c < a.length; c++)
for (var v = 0; v < n.length; v++) {
o = 0;
for (var h = 0; h < a.length; h++)
u = Rn(i.distance, n[v], a[c], i.attributes, "cmeans"), l = Rn(i.distance, n[v], a[h], i.attributes, "cmeans"), o += Math.pow(u / l, f);
e[v][c] = 1 / o;
}
}, zd = function(e, r, a, n) {
for (var i = new Array(a.k), s = 0; s < i.length; s++)
i[s] = [];
for (var o, u, l = 0; l < r.length; l++) {
o = -1 / 0, u = -1;
for (var f = 0; f < r[0].length; f++)
r[l][f] > o && (o = r[l][f], u = f);
i[u].push(e[l]);
}
for (var c = 0; c < i.length; c++)
i[c] = n.collection(i[c]);
return i;
}, vu = function(e) {
var r = this.cy(), a = this.nodes(), n = po(e), i, s, o, u, l;
u = new Array(a.length);
for (var f = 0; f < a.length; f++)
u[f] = new Array(n.k);
o = new Array(a.length);
for (var c = 0; c < a.length; c++)
o[c] = new Array(n.k);
for (var v = 0; v < a.length; v++) {
for (var h = 0, d = 0; d < n.k; d++)
o[v][d] = Math.random(), h += o[v][d];
for (var p = 0; p < n.k; p++)
o[v][p] = o[v][p] / h;
}
s = new Array(n.k);
for (var g = 0; g < n.k; g++)
s[g] = new Array(n.attributes.length);
l = new Array(a.length);
for (var y = 0; y < a.length; y++)
l[y] = new Array(n.k);
for (var b = !0, m = 0; b && m < n.maxIterations; )
b = !1, _d(s, a, o, l, n), Gd(o, u, s, a, n), kd(o, u, n.sensitivityThreshold) || (b = !0), m++;
return i = zd(a, o, n, r), {
clusters: i,
degreeOfMembership: o
};
}, Vd = {
kMeans: Bd,
kMedoids: Fd,
fuzzyCMeans: vu,
fcm: vu
}, Ud = ht({
distance: "euclidean",
// distance metric to compare nodes
linkage: "min",
// linkage criterion : how to determine the distance between clusters of nodes
mode: "threshold",
// mode:'threshold' => clusters must be threshold distance apart
threshold: 1 / 0,
// the distance threshold
// mode:'dendrogram' => the nodes are organised as leaves in a tree (siblings are close), merging makes clusters
addDendrogram: !1,
// whether to add the dendrogram to the graph for viz
dendrogramDepth: 0,
// depth at which dendrogram branches are merged into the returned clusters
attributes: []
// array of attr functions
}), qd = {
single: "min",
complete: "max"
}, Yd = function(e) {
var r = Ud(e), a = qd[r.linkage];
return a != null && (r.linkage = a), r;
}, hu = function(e, r, a, n, i) {
for (var s = 0, o = 1 / 0, u, l = i.attributes, f = function(C, D) {
return Vn(i.distance, l.length, function(A) {
return l[A](C);
}, function(A) {
return l[A](D);
}, C, D);
}, c = 0; c < e.length; c++) {
var v = e[c].key, h = a[v][n[v]];
h < o && (s = v, o = h);
}
if (i.mode === "threshold" && o >= i.threshold || i.mode === "dendrogram" && e.length === 1)
return !1;
var d = r[s], p = r[n[s]], g;
i.mode === "dendrogram" ? g = {
left: d,
right: p,
key: d.key
} : g = {
value: d.value.concat(p.value),
key: d.key
}, e[d.index] = g, e.splice(p.index, 1), r[d.key] = g;
for (var y = 0; y < e.length; y++) {
var b = e[y];
d.key === b.key ? u = 1 / 0 : i.linkage === "min" ? (u = a[d.key][b.key], a[d.key][b.key] > a[p.key][b.key] && (u = a[p.key][b.key])) : i.linkage === "max" ? (u = a[d.key][b.key], a[d.key][b.key] < a[p.key][b.key] && (u = a[p.key][b.key])) : i.linkage === "mean" ? u = (a[d.key][b.key] * d.size + a[p.key][b.key] * p.size) / (d.size + p.size) : i.mode === "dendrogram" ? u = f(b.value, d.value) : u = f(b.value[0], d.value[0]), a[d.key][b.key] = a[b.key][d.key] = u;
}
for (var m = 0; m < e.length; m++) {
var E = e[m].key;
if (n[E] === d.key || n[E] === p.key) {
for (var T = E, S = 0; S < e.length; S++) {
var w = e[S].key;
a[E][w] < a[E][T] && (T = w);
}
n[E] = T;
}
e[m].index = m;
}
return d.key = p.key = d.index = p.index = null, !0;
}, Kr = function(e, r, a) {
e && (e.value ? r.push(e.value) : (e.left && Kr(e.left, r), e.right && Kr(e.right, r)));
}, Gs = function(e, r) {
if (!e)
return "";
if (e.left && e.right) {
var a = Gs(e.left, r), n = Gs(e.right, r), i = r.add({
group: "nodes",
data: {
id: a + "," + n
}
});
return r.add({
group: "edges",
data: {
source: a,
target: i.id()
}
}), r.add({
group: "edges",
data: {
source: n,
target: i.id()
}
}), i.id();
} else if (e.value)
return e.value.id();
}, zs = function(e, r, a) {
if (!e)
return [];
var n = [], i = [], s = [];
return r === 0 ? (e.left && Kr(e.left, n), e.right && Kr(e.right, i), s = n.concat(i), [a.collection(s)]) : r === 1 ? e.value ? [a.collection(e.value)] : (e.left && Kr(e.left, n), e.right && Kr(e.right, i), [a.collection(n), a.collection(i)]) : e.value ? [a.collection(e.value)] : (e.left && (n = zs(e.left, r - 1, a)), e.right && (i = zs(e.right, r - 1, a)), n.concat(i));
}, du = function(e) {
for (var r = this.cy(), a = this.nodes(), n = Yd(e), i = n.attributes, s = function(m, E) {
return Vn(n.distance, i.length, function(T) {
return i[T](m);
}, function(T) {
return i[T](E);
}, m, E);
}, o = [], u = [], l = [], f = [], c = 0; c < a.length; c++) {
var v = {
value: n.mode === "dendrogram" ? a[c] : [a[c]],
key: c,
index: c
};
o[c] = v, f[c] = v, u[c] = [], l[c] = 0;
}
for (var h = 0; h < o.length; h++)
for (var d = 0; d <= h; d++) {
var p = void 0;
n.mode === "dendrogram" ? p = h === d ? 1 / 0 : s(o[h].value, o[d].value) : p = h === d ? 1 / 0 : s(o[h].value[0], o[d].value[0]), u[h][d] = p, u[d][h] = p, p < u[h][l[h]] && (l[h] = d);
}
for (var g = hu(o, f, u, l, n); g; )
g = hu(o, f, u, l, n);
var y;
return n.mode === "dendrogram" ? (y = zs(o[0], n.dendrogramDepth, r), n.addDendrogram && Gs(o[0], r)) : (y = new Array(o.length), o.forEach(function(b, m) {
b.key = b.index = null, y[m] = r.collection(b.value);
})), y;
}, Hd = {
hierarchicalClustering: du,
hca: du
}, Xd = ht({
distance: "euclidean",
// distance metric to compare attributes between two nodes
preference: "median",
// suitability of a data point to serve as an exemplar
damping: 0.8,
// damping factor between [0.5, 1)
maxIterations: 1e3,
// max number of iterations to run
minIterations: 100,
// min number of iterations to run in order for clustering to stop
attributes: [
// functions to quantify the similarity between any two points
// e.g. node => node.data('weight')
]
}), $d = function(e) {
var r = e.damping, a = e.preference;
0.5 <= r && r < 1 || He("Damping must range on [0.5, 1). Got: ".concat(r));
var n = ["median", "mean", "min", "max"];
return n.some(function(i) {
return i === a;
}) || ne(a) || He("Preference must be one of [".concat(n.map(function(i) {
return "'".concat(i, "'");
}).join(", "), "] or a number. Got: ").concat(a)), Xd(e);
}, Wd = function(e, r, a, n) {
var i = function(o, u) {
return n[u](o);
};
return -Vn(e, n.length, function(s) {
return i(r, s);
}, function(s) {
return i(a, s);
}, r, a);
}, Kd = function(e, r) {
var a = null;
return r === "median" ? a = $h(e) : r === "mean" ? a = Xh(e) : r === "min" ? a = Yh(e) : r === "max" ? a = Hh(e) : a = r, a;
}, Zd = function(e, r, a) {
for (var n = [], i = 0; i < e; i++)
r[i * e + i] + a[i * e + i] > 0 && n.push(i);
return n;
}, gu = function(e, r, a) {
for (var n = [], i = 0; i < e; i++) {
for (var s = -1, o = -1 / 0, u = 0; u < a.length; u++) {
var l = a[u];
r[i * e + l] > o && (s = l, o = r[i * e + l]);
}
s > 0 && n.push(s);
}
for (var f = 0; f < a.length; f++)
n[a[f]] = a[f];
return n;
}, Qd = function(e, r, a) {
for (var n = gu(e, r, a), i = 0; i < a.length; i++) {
for (var s = [], o = 0; o < n.length; o++)
n[o] === a[i] && s.push(o);
for (var u = -1, l = -1 / 0, f = 0; f < s.length; f++) {
for (var c = 0, v = 0; v < s.length; v++)
c += r[s[v] * e + s[f]];
c > l && (u = f, l = c);
}
a[i] = s[u];
}
return n = gu(e, r, a), n;
}, pu = function(e) {
for (var r = this.cy(), a = this.nodes(), n = $d(e), i = {}, s = 0; s < a.length; s++)
i[a[s].id()] = s;
var o, u, l, f, c, v;
o = a.length, u = o * o, l = new Array(u);
for (var h = 0; h < u; h++)
l[h] = -1 / 0;
for (var d = 0; d < o; d++)
for (var p = 0; p < o; p++)
d !== p && (l[d * o + p] = Wd(n.distance, a[d], a[p], n.attributes));
f = Kd(l, n.preference);
for (var g = 0; g < o; g++)
l[g * o + g] = f;
c = new Array(u);
for (var y = 0; y < u; y++)
c[y] = 0;
v = new Array(u);
for (var b = 0; b < u; b++)
v[b] = 0;
for (var m = new Array(o), E = new Array(o), T = new Array(o), S = 0; S < o; S++)
m[S] = 0, E[S] = 0, T[S] = 0;
for (var w = new Array(o * n.minIterations), x = 0; x < w.length; x++)
w[x] = 0;
var C;
for (C = 0; C < n.maxIterations; C++) {
for (var D = 0; D < o; D++) {
for (var A = -1 / 0, L = -1 / 0, R = -1, I = 0, M = 0; M < o; M++)
m[M] = c[D * o + M], I = v[D * o + M] + l[D * o + M], I >= A ? (L = A, A = I, R = M) : I > L && (L = I);
for (var N = 0; N < o; N++)
c[D * o + N] = (1 - n.damping) * (l[D * o + N] - A) + n.damping * m[N];
c[D * o + R] = (1 - n.damping) * (l[D * o + R] - L) + n.damping * m[R];
}
for (var O = 0; O < o; O++) {
for (var k = 0, B = 0; B < o; B++)
m[B] = v[B * o + O], E[B] = Math.max(0, c[B * o + O]), k += E[B];
k -= E[O], E[O] = c[O * o + O], k += E[O];
for (var _ = 0; _ < o; _++)
v[_ * o + O] = (1 - n.damping) * Math.min(0, k - E[_]) + n.damping * m[_];
v[O * o + O] = (1 - n.damping) * (k - E[O]) + n.damping * m[O];
}
for (var F = 0, G = 0; G < o; G++) {
var H = v[G * o + G] + c[G * o + G] > 0 ? 1 : 0;
w[C % n.minIterations * o + G] = H, F += H;
}
if (F > 0 && (C >= n.minIterations - 1 || C == n.maxIterations - 1)) {
for (var Y = 0, X = 0; X < o; X++) {
T[X] = 0;
for (var W = 0; W < n.minIterations; W++)
T[X] += w[W * o + X];
(T[X] === 0 || T[X] === n.minIterations) && Y++;
}
if (Y === o)
break;
}
}
for (var ee = Zd(o, c, v), ae = Qd(o, l, ee), J = {}, z = 0; z < ee.length; z++)
J[ee[z]] = [];
for (var V = 0; V < a.length; V++) {
var q = i[a[V].id()], Z = ae[q];
Z != null && J[Z].push(a[V]);
}
for (var re = new Array(ee.length), ve = 0; ve < ee.length; ve++)
re[ve] = r.collection(J[ee[ve]]);
return re;
}, Jd = {
affinityPropagation: pu,
ap: pu
}, jd = ht({
root: void 0,
directed: !1
}), eg = {
hierholzer: function(e) {
if (!Oe(e)) {
var r = arguments;
e = {
root: r[0],
directed: r[1]
};
}
var a = jd(e), n = a.root, i = a.directed, s = this, o = !1, u, l, f;
n && (f = ge(n) ? this.filter(n)[0].id() : n[0].id());
var c = {}, v = {};
i ? s.forEach(function(b) {
var m = b.id();
if (b.isNode()) {
var E = b.indegree(!0), T = b.outdegree(!0), S = E - T, w = T - E;
S == 1 ? u ? o = !0 : u = m : w == 1 ? l ? o = !0 : l = m : (w > 1 || S > 1) && (o = !0), c[m] = [], b.outgoers().forEach(function(x) {
x.isEdge() && c[m].push(x.id());
});
} else
v[m] = [void 0, b.target().id()];
}) : s.forEach(function(b) {
var m = b.id();
if (b.isNode()) {
var E = b.degree(!0);
E % 2 && (u ? l ? o = !0 : l = m : u = m), c[m] = [], b.connectedEdges().forEach(function(T) {
return c[m].push(T.id());
});
} else
v[m] = [b.source().id(), b.target().id()];
});
var h = {
found: !1,
trail: void 0
};
if (o)
return h;
if (l && u)
if (i) {
if (f && l != f)
return h;
f = l;
} else {
if (f && l != f && u != f)
return h;
f || (f = l);
}
else
f || (f = s[0].id());
var d = function(m) {
for (var E = m, T = [m], S, w, x; c[E].length; )
S = c[E].shift(), w = v[S][0], x = v[S][1], E != x ? (c[x] = c[x].filter(function(C) {
return C != S;
}), E = x) : !i && E != w && (c[w] = c[w].filter(function(C) {
return C != S;
}), E = w), T.unshift(S), T.unshift(E);
return T;
}, p = [], g = [];
for (g = d(f); g.length != 1; )
c[g[0]].length == 0 ? (p.unshift(s.getElementById(g.shift())), p.unshift(s.getElementById(g.shift()))) : g = d(g.shift()).concat(g);
p.unshift(s.getElementById(g.shift()));
for (var y in c)
if (c[y].length)
return h;
return h.found = !0, h.trail = this.spawn(p, !0), h;
}
}, en = function() {
var e = this, r = {}, a = 0, n = 0, i = [], s = [], o = {}, u = function(v, h) {
for (var d = s.length - 1, p = [], g = e.spawn(); s[d].x != v || s[d].y != h; )
p.push(s.pop().edge), d--;
p.push(s.pop().edge), p.forEach(function(y) {
var b = y.connectedNodes().intersection(e);
g.merge(y), b.forEach(function(m) {
var E = m.id(), T = m.connectedEdges().intersection(e);
g.merge(m), r[E].cutVertex ? g.merge(T.filter(function(S) {
return S.isLoop();
})) : g.merge(T);
});
}), i.push(g);
}, l = function(v, h, d) {
v === d && (n += 1), r[h] = {
id: a,
low: a++,
cutVertex: !1
};
var p = e.getElementById(h).connectedEdges().intersection(e);
if (p.size() === 0)
i.push(e.spawn(e.getElementById(h)));
else {
var g, y, b, m;
p.forEach(function(E) {
g = E.source().id(), y = E.target().id(), b = g === h ? y : g, b !== d && (m = E.id(), o[m] || (o[m] = !0, s.push({
x: h,
y: b,
edge: E
})), b in r ? r[h].low = Math.min(r[h].low, r[b].id) : (l(v, b, h), r[h].low = Math.min(r[h].low, r[b].low), r[h].id <= r[b].low && (r[h].cutVertex = !0, u(h, b))));
});
}
};
e.forEach(function(c) {
if (c.isNode()) {
var v = c.id();
v in r || (n = 0, l(v, v), r[v].cutVertex = n > 1);
}
});
var f = Object.keys(r).filter(function(c) {
return r[c].cutVertex;
}).map(function(c) {
return e.getElementById(c);
});
return {
cut: e.spawn(f),
components: i
};
}, tg = {
hopcroftTarjanBiconnected: en,
htbc: en,
htb: en,
hopcroftTarjanBiconnectedComponents: en
}, tn = function() {
var e = this, r = {}, a = 0, n = [], i = [], s = e.spawn(e), o = function(l) {
i.push(l), r[l] = {
index: a,
low: a++,
explored: !1
};
var f = e.getElementById(l).connectedEdges().intersection(e);
if (f.forEach(function(p) {
var g = p.target().id();
g !== l && (g in r || o(g), r[g].explored || (r[l].low = Math.min(r[l].low, r[g].low)));
}), r[l].index === r[l].low) {
for (var c = e.spawn(); ; ) {
var v = i.pop();
if (c.merge(e.getElementById(v)), r[v].low = r[l].index, r[v].explored = !0, v === l)
break;
}
var h = c.edgesWith(c), d = c.merge(h);
n.push(d), s = s.difference(d);
}
};
return e.forEach(function(u) {
if (u.isNode()) {
var l = u.id();
l in r || o(l);
}
}), {
cut: s,
components: n
};
}, rg = {
tarjanStronglyConnected: tn,
tsc: tn,
tscc: tn,
tarjanStronglyConnectedComponents: tn
}, Vf = {};
[La, Mh, Oh, Nh, Fh, Gh, Uh, gd, Jr, jr, _s, Ld, Vd, Hd, Jd, eg, tg, rg].forEach(function(t) {
be(Vf, t);
});
/*!
Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable
Copyright (c) 2013-2014 Ralf S. Engelschall (http://engelschall.com)
Licensed under The MIT License (http://opensource.org/licenses/MIT)
*/
var Uf = 0, qf = 1, Yf = 2, _t = function(e) {
if (!(this instanceof _t))
return new _t(e);
this.id = "Thenable/1.0.7", this.state = Uf, this.fulfillValue = void 0, this.rejectReason = void 0, this.onFulfilled = [], this.onRejected = [], this.proxy = {
then: this.then.bind(this)
}, typeof e == "function" && e.call(this, this.fulfill.bind(this), this.reject.bind(this));
};
_t.prototype = {
/* promise resolving methods */
fulfill: function(e) {
return yu(this, qf, "fulfillValue", e);
},
reject: function(e) {
return yu(this, Yf, "rejectReason", e);
},
/* "The then Method" [Promises/A+ 1.1, 1.2, 2.2] */
then: function(e, r) {
var a = this, n = new _t();
return a.onFulfilled.push(bu(e, n, "fulfill")), a.onRejected.push(bu(r, n, "reject")), Hf(a), n.proxy;
}
};
var yu = function(e, r, a, n) {
return e.state === Uf && (e.state = r, e[a] = n, Hf(e)), e;
}, Hf = function(e) {
e.state === qf ? mu(e, "onFulfilled", e.fulfillValue) : e.state === Yf && mu(e, "onRejected", e.rejectReason);
}, mu = function(e, r, a) {
if (e[r].length !== 0) {
var n = e[r];
e[r] = [];
var i = function() {
for (var o = 0; o < n.length; o++)
n[o](a);
};
typeof setImmediate == "function" ? setImmediate(i) : setTimeout(i, 0);
}
}, bu = function(e, r, a) {
return function(n) {
if (typeof e != "function")
r[a].call(r, n);
else {
var i;
try {
i = e(n);
} catch (s) {
r.reject(s);
return;
}
Xf(r, i);
}
};
}, Xf = function(e, r) {
if (e === r || e.proxy === r) {
e.reject(new TypeError("cannot resolve promise with itself"));
return;
}
var a;
if (nt(r) === "object" && r !== null || typeof r == "function")
try {
a = r.then;
} catch (i) {
e.reject(i);
return;
}
if (typeof a == "function") {
var n = !1;
try {
a.call(
r,
/* resolvePromise */
/* [Promises/A+ 2.3.3.3.1] */
function(i) {
n || (n = !0, i === r ? e.reject(new TypeError("circular thenable chain")) : Xf(e, i));
},
/* rejectPromise */
/* [Promises/A+ 2.3.3.3.2] */
function(i) {
n || (n = !0, e.reject(i));
}
);
} catch (i) {
n || e.reject(i);
}
return;
}
e.fulfill(r);
};
_t.all = function(t) {
return new _t(function(e, r) {
for (var a = new Array(t.length), n = 0, i = function(u, l) {
a[u] = l, n++, n === t.length && e(a);
}, s = 0; s < t.length; s++)
(function(o) {
var u = t[o], l = u != null && u.then != null;
if (l)
u.then(function(c) {
i(o, c);
}, function(c) {
r(c);
});
else {
var f = u;
i(o, f);
}
})(s);
});
};
_t.resolve = function(t) {
return new _t(function(e, r) {
e(t);
});
};
_t.reject = function(t) {
return new _t(function(e, r) {
r(t);
});
};
var ia = typeof Promise < "u" ? Promise : _t, Vs = function(e, r, a) {
var n = io(e), i = !n, s = this._private = be({
duration: 1e3
}, r, a);
if (s.target = e, s.style = s.style || s.css, s.started = !1, s.playing = !1, s.hooked = !1, s.applying = !1, s.progress = 0, s.completes = [], s.frames = [], s.complete && Xe(s.complete) && s.completes.push(s.complete), i) {
var o = e.position();
s.startPosition = s.startPosition || {
x: o.x,
y: o.y
}, s.startStyle = s.startStyle || e.cy().style().getAnimationStartStyle(e, s.style);
}
if (n) {
var u = e.pan();
s.startPan = {
x: u.x,
y: u.y
}, s.startZoom = e.zoom();
}
this.length = 1, this[0] = this;
}, Mr = Vs.prototype;
be(Mr, {
instanceString: function() {
return "animation";
},
hook: function() {
var e = this._private;
if (!e.hooked) {
var r, a = e.target._private.animation;
e.queue ? r = a.queue : r = a.current, r.push(this), Lt(e.target) && e.target.cy().addToAnimationPool(e.target), e.hooked = !0;
}
return this;
},
play: function() {
var e = this._private;
return e.progress === 1 && (e.progress = 0), e.playing = !0, e.started = !1, e.stopped = !1, this.hook(), this;
},
playing: function() {
return this._private.playing;
},
apply: function() {
var e = this._private;
return e.applying = !0, e.started = !1, e.stopped = !1, this.hook(), this;
},
applying: function() {
return this._private.applying;
},
pause: function() {
var e = this._private;
return e.playing = !1, e.started = !1, this;
},
stop: function() {
var e = this._private;
return e.playing = !1, e.started = !1, e.stopped = !0, this;
},
rewind: function() {
return this.progress(0);
},
fastforward: function() {
return this.progress(1);
},
time: function(e) {
var r = this._private;
return e === void 0 ? r.progress * r.duration : this.progress(e / r.duration);
},
progress: function(e) {
var r = this._private, a = r.playing;
return e === void 0 ? r.progress : (a && this.pause(), r.progress = e, r.started = !1, a && this.play(), this);
},
completed: function() {
return this._private.progress === 1;
},
reverse: function() {
var e = this._private, r = e.playing;
r && this.pause(), e.progress = 1 - e.progress, e.started = !1;
var a = function(l, f) {
var c = e[l];
c != null && (e[l] = e[f], e[f] = c);
};
if (a("zoom", "startZoom"), a("pan", "startPan"), a("position", "startPosition"), e.style)
for (var n = 0; n < e.style.length; n++) {
var i = e.style[n], s = i.name, o = e.startStyle[s];
e.startStyle[s] = i, e.style[n] = o;
}
return r && this.play(), this;
},
promise: function(e) {
var r = this._private, a;
switch (e) {
case "frame":
a = r.frames;
break;
default:
case "complete":
case "completed":
a = r.completes;
}
return new ia(function(n, i) {
a.push(function() {
n();
});
});
}
});
Mr.complete = Mr.completed;
Mr.run = Mr.play;
Mr.running = Mr.playing;
var ag = {
animated: function() {
return function() {
var r = this, a = r.length !== void 0, n = a ? r : [r], i = this._private.cy || this;
if (!i.styleEnabled())
return !1;
var s = n[0];
if (s)
return s._private.animation.current.length > 0;
};
},
// animated
clearQueue: function() {
return function() {
var r = this, a = r.length !== void 0, n = a ? r : [r], i = this._private.cy || this;
if (!i.styleEnabled())
return this;
for (var s = 0; s < n.length; s++) {
var o = n[s];
o._private.animation.queue = [];
}
return this;
};
},
// clearQueue
delay: function() {
return function(r, a) {
var n = this._private.cy || this;
return n.styleEnabled() ? this.animate({
delay: r,
duration: r,
complete: a
}) : this;
};
},
// delay
delayAnimation: function() {
return function(r, a) {
var n = this._private.cy || this;
return n.styleEnabled() ? this.animation({
delay: r,
duration: r,
complete: a
}) : this;
};
},
// delay
animation: function() {
return function(r, a) {
var n = this, i = n.length !== void 0, s = i ? n : [n], o = this._private.cy || this, u = !i, l = !u;
if (!o.styleEnabled())
return this;
var f = o.style();
r = be({}, r, a);
var c = Object.keys(r).length === 0;
if (c)
return new Vs(s[0], r);
switch (r.duration === void 0 && (r.duration = 400), r.duration) {
case "slow":
r.duration = 600;
break;
case "fast":
r.duration = 200;
break;
}
if (l && (r.style = f.getPropsList(r.style || r.css), r.css = void 0), l && r.renderedPosition != null) {
var v = r.renderedPosition, h = o.pan(), d = o.zoom();
r.position = Pf(v, d, h);
}
if (u && r.panBy != null) {
var p = r.panBy, g = o.pan();
r.pan = {
x: g.x + p.x,
y: g.y + p.y
};
}
var y = r.center || r.centre;
if (u && y != null) {
var b = o.getCenterPan(y.eles, r.zoom);
b != null && (r.pan = b);
}
if (u && r.fit != null) {
var m = r.fit, E = o.getFitViewport(m.eles || m.boundingBox, m.padding);
E != null && (r.pan = E.pan, r.zoom = E.zoom);
}
if (u && Oe(r.zoom)) {
var T = o.getZoomedViewport(r.zoom);
T != null ? (T.zoomed && (r.zoom = T.zoom), T.panned && (r.pan = T.pan)) : r.zoom = null;
}
return new Vs(s[0], r);
};
},
// animate
animate: function() {
return function(r, a) {
var n = this, i = n.length !== void 0, s = i ? n : [n], o = this._private.cy || this;
if (!o.styleEnabled())
return this;
a && (r = be({}, r, a));
for (var u = 0; u < s.length; u++) {
var l = s[u], f = l.animated() && (r.queue === void 0 || r.queue), c = l.animation(r, f ? {
queue: !0
} : void 0);
c.play();
}
return this;
};
},
// animate
stop: function() {
return function(r, a) {
var n = this, i = n.length !== void 0, s = i ? n : [n], o = this._private.cy || this;
if (!o.styleEnabled())
return this;
for (var u = 0; u < s.length; u++) {
for (var l = s[u], f = l._private, c = f.animation.current, v = 0; v < c.length; v++) {
var h = c[v], d = h._private;
a && (d.duration = 0);
}
r && (f.animation.queue = []), a || (f.animation.current = []);
}
return o.notify("draw"), this;
};
}
// stop
}, Ci, wu;
function Un() {
if (wu)
return Ci;
wu = 1;
var t = Array.isArray;
return Ci = t, Ci;
}
var Di, Eu;
function ng() {
if (Eu)
return Di;
Eu = 1;
var t = Un(), e = za(), r = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, a = /^\w*$/;
function n(i, s) {
if (t(i))
return !1;
var o = typeof i;
return o == "number" || o == "symbol" || o == "boolean" || i == null || e(i) ? !0 : a.test(i) || !r.test(i) || s != null && i in Object(s);
}
return Di = n, Di;
}
var Si, xu;
function ig() {
if (xu)
return Si;
xu = 1;
var t = xf(), e = Ga(), r = "[object AsyncFunction]", a = "[object Function]", n = "[object GeneratorFunction]", i = "[object Proxy]";
function s(o) {
if (!e(o))
return !1;
var u = t(o);
return u == a || u == n || u == r || u == i;
}
return Si = s, Si;
}
var Ai, Tu;
function sg() {
if (Tu)
return Ai;
Tu = 1;
var t = _n(), e = t["__core-js_shared__"];
return Ai = e, Ai;
}
var Li, Cu;
function og() {
if (Cu)
return Li;
Cu = 1;
var t = sg(), e = function() {
var a = /[^.]+$/.exec(t && t.keys && t.keys.IE_PROTO || "");
return a ? "Symbol(src)_1." + a : "";
}();
function r(a) {
return !!e && e in a;
}
return Li = r, Li;
}
var Ri, Du;
function ug() {
if (Du)
return Ri;
Du = 1;
var t = Function.prototype, e = t.toString;
function r(a) {
if (a != null) {
try {
return e.call(a);
} catch {
}
try {
return a + "";
} catch {
}
}
return "";
}
return Ri = r, Ri;
}
var Ii, Su;
function lg() {
if (Su)
return Ii;
Su = 1;
var t = ig(), e = og(), r = Ga(), a = ug(), n = /[\\^$.*+?()[\]{}|]/g, i = /^\[object .+?Constructor\]$/, s = Function.prototype, o = Object.prototype, u = s.toString, l = o.hasOwnProperty, f = RegExp(
"^" + u.call(l).replace(n, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
);
function c(v) {
if (!r(v) || e(v))
return !1;
var h = t(v) ? f : i;
return h.test(a(v));
}
return Ii = c, Ii;
}
var Pi, Au;
function fg() {
if (Au)
return Pi;
Au = 1;
function t(e, r) {
return e == null ? void 0 : e[r];
}
return Pi = t, Pi;
}
var Mi, Lu;
function yo() {
if (Lu)
return Mi;
Lu = 1;
var t = lg(), e = fg();
function r(a, n) {
var i = e(a, n);
return t(i) ? i : void 0;
}
return Mi = r, Mi;
}
var Oi, Ru;
function qn() {
if (Ru)
return Oi;
Ru = 1;
var t = yo(), e = t(Object, "create");
return Oi = e, Oi;
}
var ki, Iu;
function cg() {
if (Iu)
return ki;
Iu = 1;
var t = qn();
function e() {
this.__data__ = t ? t(null) : {}, this.size = 0;
}
return ki = e, ki;
}
var Ni, Pu;
function vg() {
if (Pu)
return Ni;
Pu = 1;
function t(e) {
var r = this.has(e) && delete this.__data__[e];
return this.size -= r ? 1 : 0, r;
}
return Ni = t, Ni;
}
var Bi, Mu;
function hg() {
if (Mu)
return Bi;
Mu = 1;
var t = qn(), e = "__lodash_hash_undefined__", r = Object.prototype, a = r.hasOwnProperty;
function n(i) {
var s = this.__data__;
if (t) {
var o = s[i];
return o === e ? void 0 : o;
}
return a.call(s, i) ? s[i] : void 0;
}
return Bi = n, Bi;
}
var Fi, Ou;
function dg() {
if (Ou)
return Fi;
Ou = 1;
var t = qn(), e = Object.prototype, r = e.hasOwnProperty;
function a(n) {
var i = this.__data__;
return t ? i[n] !== void 0 : r.call(i, n);
}
return Fi = a, Fi;
}
var _i, ku;
function gg() {
if (ku)
return _i;
ku = 1;
var t = qn(), e = "__lodash_hash_undefined__";
function r(a, n) {
var i = this.__data__;
return this.size += this.has(a) ? 0 : 1, i[a] = t && n === void 0 ? e : n, this;
}
return _i = r, _i;
}
var Gi, Nu;
function pg() {
if (Nu)
return Gi;
Nu = 1;
var t = cg(), e = vg(), r = hg(), a = dg(), n = gg();
function i(s) {
var o = -1, u = s == null ? 0 : s.length;
for (this.clear(); ++o < u; ) {
var l = s[o];
this.set(l[0], l[1]);
}
}
return i.prototype.clear = t, i.prototype.delete = e, i.prototype.get = r, i.prototype.has = a, i.prototype.set = n, Gi = i, Gi;
}
var zi, Bu;
function yg() {
if (Bu)
return zi;
Bu = 1;
function t() {
this.__data__ = [], this.size = 0;
}
return zi = t, zi;
}
var Vi, Fu;
function $f() {
if (Fu)
return Vi;
Fu = 1;
function t(e, r) {
return e === r || e !== e && r !== r;
}
return Vi = t, Vi;
}
var Ui, _u;
function Yn() {
if (_u)
return Ui;
_u = 1;
var t = $f();
function e(r, a) {
for (var n = r.length; n--; )
if (t(r[n][0], a))
return n;
return -1;
}
return Ui = e, Ui;
}
var qi, Gu;
function mg() {
if (Gu)
return qi;
Gu = 1;
var t = Yn(), e = Array.prototype, r = e.splice;
function a(n) {
var i = this.__data__, s = t(i, n);
if (s < 0)
return !1;
var o = i.length - 1;
return s == o ? i.pop() : r.call(i, s, 1), --this.size, !0;
}
return qi = a, qi;
}
var Yi, zu;
function bg() {
if (zu)
return Yi;
zu = 1;
var t = Yn();
function e(r) {
var a = this.__data__, n = t(a, r);
return n < 0 ? void 0 : a[n][1];
}
return Yi = e, Yi;
}
var Hi, Vu;
function wg() {
if (Vu)
return Hi;
Vu = 1;
var t = Yn();
function e(r) {
return t(this.__data__, r) > -1;
}
return Hi = e, Hi;
}
var Xi, Uu;
function Eg() {
if (Uu)
return Xi;
Uu = 1;
var t = Yn();
function e(r, a) {
var n = this.__data__, i = t(n, r);
return i < 0 ? (++this.size, n.push([r, a])) : n[i][1] = a, this;
}
return Xi = e, Xi;
}
var $i, qu;
function xg() {
if (qu)
return $i;
qu = 1;
var t = yg(), e = mg(), r = bg(), a = wg(), n = Eg();
function i(s) {
var o = -1, u = s == null ? 0 : s.length;
for (this.clear(); ++o < u; ) {
var l = s[o];
this.set(l[0], l[1]);
}
}
return i.prototype.clear = t, i.prototype.delete = e, i.prototype.get = r, i.prototype.has = a, i.prototype.set = n, $i = i, $i;
}
var Wi, Yu;
function Tg() {
if (Yu)
return Wi;
Yu = 1;
var t = yo(), e = _n(), r = t(e, "Map");
return Wi = r, Wi;
}
var Ki, Hu;
function Cg() {
if (Hu)
return Ki;
Hu = 1;
var t = pg(), e = xg(), r = Tg();
function a() {
this.size = 0, this.__data__ = {
hash: new t(),
map: new (r || e)(),
string: new t()
};
}
return Ki = a, Ki;
}
var Zi, Xu;
function Dg() {
if (Xu)
return Zi;
Xu = 1;
function t(e) {
var r = typeof e;
return r == "string" || r == "number" || r == "symbol" || r == "boolean" ? e !== "__proto__" : e === null;
}
return Zi = t, Zi;
}
var Qi, $u;
function Hn() {
if ($u)
return Qi;
$u = 1;
var t = Dg();
function e(r, a) {
var n = r.__data__;
return t(a) ? n[typeof a == "string" ? "string" : "hash"] : n.map;
}
return Qi = e, Qi;
}
var Ji, Wu;
function Sg() {
if (Wu)
return Ji;
Wu = 1;
var t = Hn();
function e(r) {
var a = t(this, r).delete(r);
return this.size -= a ? 1 : 0, a;
}
return Ji = e, Ji;
}
var ji, Ku;
function Ag() {
if (Ku)
return ji;
Ku = 1;
var t = Hn();
function e(r) {
return t(this, r).get(r);
}
return ji = e, ji;
}
var es, Zu;
function Lg() {
if (Zu)
return es;
Zu = 1;
var t = Hn();
function e(r) {
return t(this, r).has(r);
}
return es = e, es;
}
var ts, Qu;
function Rg() {
if (Qu)
return ts;
Qu = 1;
var t = Hn();
function e(r, a) {
var n = t(this, r), i = n.size;
return n.set(r, a), this.size += n.size == i ? 0 : 1, this;
}
return ts = e, ts;
}
var rs, Ju;
function Ig() {
if (Ju)
return rs;
Ju = 1;
var t = Cg(), e = Sg(), r = Ag(), a = Lg(), n = Rg();
function i(s) {
var o = -1, u = s == null ? 0 : s.length;
for (this.clear(); ++o < u; ) {
var l = s[o];
this.set(l[0], l[1]);
}
}
return i.prototype.clear = t, i.prototype.delete = e, i.prototype.get = r, i.prototype.has = a, i.prototype.set = n, rs = i, rs;
}
var as, ju;
function Pg() {
if (ju)
return as;
ju = 1;
var t = Ig(), e = "Expected a function";
function r(a, n) {
if (typeof a != "function" || n != null && typeof n != "function")
throw new TypeError(e);
var i = function() {
var s = arguments, o = n ? n.apply(this, s) : s[0], u = i.cache;
if (u.has(o))
return u.get(o);
var l = a.apply(this, s);
return i.cache = u.set(o, l) || u, l;
};
return i.cache = new (r.Cache || t)(), i;
}
return r.Cache = t, as = r, as;
}
var ns, el;
function Mg() {
if (el)
return ns;
el = 1;
var t = Pg(), e = 500;
function r(a) {
var n = t(a, function(s) {
return i.size === e && i.clear(), s;
}), i = n.cache;
return n;
}
return ns = r, ns;
}
var is, tl;
function Wf() {
if (tl)
return is;
tl = 1;
var t = Mg(), e = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, r = /\\(\\)?/g, a = t(function(n) {
var i = [];
return n.charCodeAt(0) === 46 && i.push(""), n.replace(e, function(s, o, u, l) {
i.push(u ? l.replace(r, "$1") : o || s);
}), i;
});
return is = a, is;
}
var ss, rl;
function Kf() {
if (rl)
return ss;
rl = 1;
function t(e, r) {
for (var a = -1, n = e == null ? 0 : e.length, i = Array(n); ++a < n; )
i[a] = r(e[a], a, e);
return i;
}
return ss = t, ss;
}
var os, al;
function Og() {
if (al)
return os;
al = 1;
var t = oo(), e = Kf(), r = Un(), a = za(), n = t ? t.prototype : void 0, i = n ? n.toString : void 0;
function s(o) {
if (typeof o == "string")
return o;
if (r(o))
return e(o, s) + "";
if (a(o))
return i ? i.call(o) : "";
var u = o + "";
return u == "0" && 1 / o == -1 / 0 ? "-0" : u;
}
return os = s, os;
}
var us, nl;
function Zf() {
if (nl)
return us;
nl = 1;
var t = Og();
function e(r) {
return r == null ? "" : t(r);
}
return us = e, us;
}
var ls, il;
function Qf() {
if (il)
return ls;
il = 1;
var t = Un(), e = ng(), r = Wf(), a = Zf();
function n(i, s) {
return t(i) ? i : e(i, s) ? [i] : r(a(i));
}
return ls = n, ls;
}
var fs, sl;
function mo() {
if (sl)
return fs;
sl = 1;
var t = za();
function e(r) {
if (typeof r == "string" || t(r))
return r;
var a = r + "";
return a == "0" && 1 / r == -1 / 0 ? "-0" : a;
}
return fs = e, fs;
}
var cs, ol;
function kg() {
if (ol)
return cs;
ol = 1;
var t = Qf(), e = mo();
function r(a, n) {
n = t(n, a);
for (var i = 0, s = n.length; a != null && i < s; )
a = a[e(n[i++])];
return i && i == s ? a : void 0;
}
return cs = r, cs;
}
var vs, ul;
function Ng() {
if (ul)
return vs;
ul = 1;
var t = kg();
function e(r, a, n) {
var i = r == null ? void 0 : t(r, a);
return i === void 0 ? n : i;
}
return vs = e, vs;
}
var Bg = Ng(), Fg = /* @__PURE__ */ _a(Bg), hs, ll;
function _g() {
if (ll)
return hs;
ll = 1;
var t = yo(), e = function() {
try {
var r = t(Object, "defineProperty");
return r({}, "", {}), r;
} catch {
}
}();
return hs = e, hs;
}
var ds, fl;
function Gg() {
if (fl)
return ds;
fl = 1;
var t = _g();
function e(r, a, n) {
a == "__proto__" && t ? t(r, a, {
configurable: !0,
enumerable: !0,
value: n,
writable: !0
}) : r[a] = n;
}
return ds = e, ds;
}
var gs, cl;
function zg() {
if (cl)
return gs;
cl = 1;
var t = Gg(), e = $f(), r = Object.prototype, a = r.hasOwnProperty;
function n(i, s, o) {
var u = i[s];
(!(a.call(i, s) && e(u, o)) || o === void 0 && !(s in i)) && t(i, s, o);
}
return gs = n, gs;
}
var ps, vl;
function Vg() {
if (vl)
return ps;
vl = 1;
var t = 9007199254740991, e = /^(?:0|[1-9]\d*)$/;
function r(a, n) {
var i = typeof a;
return n = n ?? t, !!n && (i == "number" || i != "symbol" && e.test(a)) && a > -1 && a % 1 == 0 && a < n;
}
return ps = r, ps;
}
var ys, hl;
function Ug() {
if (hl)
return ys;
hl = 1;
var t = zg(), e = Qf(), r = Vg(), a = Ga(), n = mo();
function i(s, o, u, l) {
if (!a(s))
return s;
o = e(o, s);
for (var f = -1, c = o.length, v = c - 1, h = s; h != null && ++f < c; ) {
var d = n(o[f]), p = u;
if (d === "__proto__" || d === "constructor" || d === "prototype")
return s;
if (f != v) {
var g = h[d];
p = l ? l(g, d, h) : void 0, p === void 0 && (p = a(g) ? g : r(o[f + 1]) ? [] : {});
}
t(h, d, p), h = h[d];
}
return s;
}
return ys = i, ys;
}
var ms, dl;
function qg() {
if (dl)
return ms;
dl = 1;
var t = Ug();
function e(r, a, n) {
return r == null ? r : t(r, a, n);
}
return ms = e, ms;
}
var Yg = qg(), Hg = /* @__PURE__ */ _a(Yg), bs, gl;
function Xg() {
if (gl)
return bs;
gl = 1;
function t(e, r) {
var a = -1, n = e.length;
for (r || (r = Array(n)); ++a < n; )
r[a] = e[a];
return r;
}
return bs = t, bs;
}
var ws, pl;
function $g() {
if (pl)
return ws;
pl = 1;
var t = Kf(), e = Xg(), r = Un(), a = za(), n = Wf(), i = mo(), s = Zf();
function o(u) {
return r(u) ? t(u, i) : a(u) ? [u] : e(n(s(u)));
}
return ws = o, ws;
}
var Wg = $g(), Kg = /* @__PURE__ */ _a(Wg), Zg = {
// access data field
data: function(e) {
var r = {
field: "data",
bindingEvent: "data",
allowBinding: !1,
allowSetting: !1,
allowGetting: !1,
settingEvent: "data",
settingTriggersEvent: !1,
triggerFnName: "trigger",
immutableKeys: {},
// key => true if immutable
updateStyle: !1,
beforeGet: function(n) {
},
beforeSet: function(n, i) {
},
onSet: function(n) {
},
canSet: function(n) {
return !0;
}
};
return e = be({}, r, e), function(n, i) {
var s = e, o = this, u = o.length !== void 0, l = u ? o : [o], f = u ? o[0] : o;
if (ge(n)) {
var c = n.indexOf(".") !== -1, v = c && Kg(n);
if (s.allowGetting && i === void 0) {
var h;
return f && (s.beforeGet(f), v && f._private[s.field][n] === void 0 ? h = Fg(f._private[s.field], v) : h = f._private[s.field][n]), h;
} else if (s.allowSetting && i !== void 0) {
var d = !s.immutableKeys[n];
if (d) {
var p = vf({}, n, i);
s.beforeSet(o, p);
for (var g = 0, y = l.length; g < y; g++) {
var b = l[g];
s.canSet(b) && (v && f._private[s.field][n] === void 0 ? Hg(b._private[s.field], v, i) : b._private[s.field][n] = i);
}
s.updateStyle && o.updateStyle(), s.onSet(o), s.settingTriggersEvent && o[s.triggerFnName](s.settingEvent);
}
}
} else if (s.allowSetting && Oe(n)) {
var m = n, E, T, S = Object.keys(m);
s.beforeSet(o, m);
for (var w = 0; w < S.length; w++) {
E = S[w], T = m[E];
var x = !s.immutableKeys[E];
if (x)
for (var C = 0; C < l.length; C++) {
var D = l[C];
s.canSet(D) && (D._private[s.field][E] = T);
}
}
s.updateStyle && o.updateStyle(), s.onSet(o), s.settingTriggersEvent && o[s.triggerFnName](s.settingEvent);
} else if (s.allowBinding && Xe(n)) {
var A = n;
o.on(s.bindingEvent, A);
} else if (s.allowGetting && n === void 0) {
var L;
return f && (s.beforeGet(f), L = f._private[s.field]), L;
}
return o;
};
},
// data
// remove data field
removeData: function(e) {
var r = {
field: "data",
event: "data",
triggerFnName: "trigger",
triggerEvent: !1,
immutableKeys: {}
// key => true if immutable
};
return e = be({}, r, e), function(n) {
var i = e, s = this, o = s.length !== void 0, u = o ? s : [s];
if (ge(n)) {
for (var l = n.split(/\s+/), f = l.length, c = 0; c < f; c++) {
var v = l[c];
if (!fr(v)) {
var h = !i.immutableKeys[v];
if (h)
for (var d = 0, p = u.length; d < p; d++)
u[d]._private[i.field][v] = void 0;
}
}
i.triggerEvent && s[i.triggerFnName](i.event);
} else if (n === void 0) {
for (var g = 0, y = u.length; g < y; g++)
for (var b = u[g]._private[i.field], m = Object.keys(b), E = 0; E < m.length; E++) {
var T = m[E], S = !i.immutableKeys[T];
S && (b[T] = void 0);
}
i.triggerEvent && s[i.triggerFnName](i.event);
}
return s;
};
}
// removeData
}, Qg = {
eventAliasesOn: function(e) {
var r = e;
r.addListener = r.listen = r.bind = r.on, r.unlisten = r.unbind = r.off = r.removeListener, r.trigger = r.emit, r.pon = r.promiseOn = function(a, n) {
var i = this, s = Array.prototype.slice.call(arguments, 0);
return new ia(function(o, u) {
var l = function(h) {
i.off.apply(i, c), o(h);
}, f = s.concat([l]), c = f.concat([]);
i.on.apply(i, f);
});
};
}
}, _e = {};
[ag, Zg, Qg].forEach(function(t) {
be(_e, t);
});
var Jg = {
animate: _e.animate(),
animation: _e.animation(),
animated: _e.animated(),
clearQueue: _e.clearQueue(),
delay: _e.delay(),
delayAnimation: _e.delayAnimation(),
stop: _e.stop()
}, hn = {
classes: function(e) {
var r = this;
if (e === void 0) {
var a = [];
return r[0]._private.classes.forEach(function(d) {
return a.push(d);
}), a;
} else
Ve(e) || (e = (e || "").match(/\S+/g) || []);
for (var n = [], i = new na(e), s = 0; s < r.length; s++) {
for (var o = r[s], u = o._private, l = u.classes, f = !1, c = 0; c < e.length; c++) {
var v = e[c], h = l.has(v);
if (!h) {
f = !0;
break;
}
}
f || (f = l.size !== e.length), f && (u.classes = i, n.push(o));
}
return n.length > 0 && this.spawn(n).updateStyle().emit("class"), r;
},
addClass: function(e) {
return this.toggleClass(e, !0);
},
hasClass: function(e) {
var r = this[0];
return r != null && r._private.classes.has(e);
},
toggleClass: function(e, r) {
Ve(e) || (e = e.match(/\S+/g) || []);
for (var a = this, n = r === void 0, i = [], s = 0, o = a.length; s < o; s++)
for (var u = a[s], l = u._private.classes, f = !1, c = 0; c < e.length; c++) {
var v = e[c], h = l.has(v), d = !1;
r || n && !h ? (l.add(v), d = !0) : (!r || n && h) && (l.delete(v), d = !0), !f && d && (i.push(u), f = !0);
}
return i.length > 0 && this.spawn(i).updateStyle().emit("class"), a;
},
removeClass: function(e) {
return this.toggleClass(e, !1);
},
flashClass: function(e, r) {
var a = this;
if (r == null)
r = 250;
else if (r === 0)
return a;
return a.addClass(e), setTimeout(function() {
a.removeClass(e);
}, r), a;
}
};
hn.className = hn.classNames = hn.classes;
var Me = {
metaChar: "[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",
// chars we need to escape in let names, etc
comparatorOp: "=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",
// binary comparison op (used in data selectors)
boolOp: "\\?|\\!|\\^",
// boolean (unary) operators (used in data selectors)
string: `"(?:\\\\"|[^"])*"|'(?:\\\\'|[^'])*'`,
// string literals (used in data selectors) -- doublequotes | singlequotes
number: at,
// number literal (used in data selectors) --- e.g. 0.1234, 1234, 12e123
meta: "degree|indegree|outdegree",
// allowed metadata fields (i.e. allowed functions to use from Collection)
separator: "\\s*,\\s*",
// queries are separated by commas, e.g. edge[foo = 'bar'], node.someClass
descendant: "\\s+",
child: "\\s+>\\s+",
subject: "\\$",
group: "node|edge|\\*",
directedEdge: "\\s+->\\s+",
undirectedEdge: "\\s+<->\\s+"
};
Me.variable = "(?:[\\w-.]|(?:\\\\" + Me.metaChar + "))+";
Me.className = "(?:[\\w-]|(?:\\\\" + Me.metaChar + "))+";
Me.value = Me.string + "|" + Me.number;
Me.id = Me.variable;
(function() {
var t, e, r;
for (t = Me.comparatorOp.split("|"), r = 0; r < t.length; r++)
e = t[r], Me.comparatorOp += "|@" + e;
for (t = Me.comparatorOp.split("|"), r = 0; r < t.length; r++)
e = t[r], !(e.indexOf("!") >= 0) && e !== "=" && (Me.comparatorOp += "|\\!" + e);
})();
var ze = function() {
return {
checks: []
};
}, se = {
/** E.g. node */
GROUP: 0,
/** A collection of elements */
COLLECTION: 1,
/** A filter(ele) function */
FILTER: 2,
/** E.g. [foo > 1] */
DATA_COMPARE: 3,
/** E.g. [foo] */
DATA_EXIST: 4,
/** E.g. [?foo] */
DATA_BOOL: 5,
/** E.g. [[degree > 2]] */
META_COMPARE: 6,
/** E.g. :selected */
STATE: 7,
/** E.g. #foo */
ID: 8,
/** E.g. .foo */
CLASS: 9,
/** E.g. #foo <-> #bar */
UNDIRECTED_EDGE: 10,
/** E.g. #foo -> #bar */
DIRECTED_EDGE: 11,
/** E.g. $#foo -> #bar */
NODE_SOURCE: 12,
/** E.g. #foo -> $#bar */
NODE_TARGET: 13,
/** E.g. $#foo <-> #bar */
NODE_NEIGHBOR: 14,
/** E.g. #foo > #bar */
CHILD: 15,
/** E.g. #foo #bar */
DESCENDANT: 16,
/** E.g. $#foo > #bar */
PARENT: 17,
/** E.g. $#foo #bar */
ANCESTOR: 18,
/** E.g. #foo > $bar > #baz */
COMPOUND_SPLIT: 19,
/** Always matches, useful placeholder for subject in `COMPOUND_SPLIT` */
TRUE: 20
}, Us = [{
selector: ":selected",
matches: function(e) {
return e.selected();
}
}, {
selector: ":unselected",
matches: function(e) {
return !e.selected();
}
}, {
selector: ":selectable",
matches: function(e) {
return e.selectable();
}
}, {
selector: ":unselectable",
matches: function(e) {
return !e.selectable();
}
}, {
selector: ":locked",
matches: function(e) {
return e.locked();
}
}, {
selector: ":unlocked",
matches: function(e) {
return !e.locked();
}
}, {
selector: ":visible",
matches: function(e) {
return e.visible();
}
}, {
selector: ":hidden",
matches: function(e) {
return !e.visible();
}
}, {
selector: ":transparent",
matches: function(e) {
return e.transparent();
}
}, {
selector: ":grabbed",
matches: function(e) {
return e.grabbed();
}
}, {
selector: ":free",
matches: function(e) {
return !e.grabbed();
}
}, {
selector: ":removed",
matches: function(e) {
return e.removed();
}
}, {
selector: ":inside",
matches: function(e) {
return !e.removed();
}
}, {
selector: ":grabbable",
matches: function(e) {
return e.grabbable();
}
}, {
selector: ":ungrabbable",
matches: function(e) {
return !e.grabbable();
}
}, {
selector: ":animated",
matches: function(e) {
return e.animated();
}
}, {
selector: ":unanimated",
matches: function(e) {
return !e.animated();
}
}, {
selector: ":parent",
matches: function(e) {
return e.isParent();
}
}, {
selector: ":childless",
matches: function(e) {
return e.isChildless();
}
}, {
selector: ":child",
matches: function(e) {
return e.isChild();
}
}, {
selector: ":orphan",
matches: function(e) {
return e.isOrphan();
}
}, {
selector: ":nonorphan",
matches: function(e) {
return e.isChild();
}
}, {
selector: ":compound",
matches: function(e) {
return e.isNode() ? e.isParent() : e.source().isParent() || e.target().isParent();
}
}, {
selector: ":loop",
matches: function(e) {
return e.isLoop();
}
}, {
selector: ":simple",
matches: function(e) {
return e.isSimple();
}
}, {
selector: ":active",
matches: function(e) {
return e.active();
}
}, {
selector: ":inactive",
matches: function(e) {
return !e.active();
}
}, {
selector: ":backgrounding",
matches: function(e) {
return e.backgrounding();
}
}, {
selector: ":nonbackgrounding",
matches: function(e) {
return !e.backgrounding();
}
}].sort(function(t, e) {
return Zv(t.selector, e.selector);
}), jg = function() {
for (var t = {}, e, r = 0; r < Us.length; r++)
e = Us[r], t[e.selector] = e.matches;
return t;
}(), ep = function(e, r) {
return jg[e](r);
}, tp = "(" + Us.map(function(t) {
return t.selector;
}).join("|") + ")", Gr = function(e) {
return e.replace(new RegExp("\\\\(" + Me.metaChar + ")", "g"), function(r, a) {
return a;
});
}, ar = function(e, r, a) {
e[e.length - 1] = a;
}, qs = [{
name: "group",
// just used for identifying when debugging
query: !0,
regex: "(" + Me.group + ")",
populate: function(e, r, a) {
var n = Je(a, 1), i = n[0];
r.checks.push({
type: se.GROUP,
value: i === "*" ? i : i + "s"
});
}
}, {
name: "state",
query: !0,
regex: tp,
populate: function(e, r, a) {
var n = Je(a, 1), i = n[0];
r.checks.push({
type: se.STATE,
value: i
});
}
}, {
name: "id",
query: !0,
regex: "\\#(" + Me.id + ")",
populate: function(e, r, a) {
var n = Je(a, 1), i = n[0];
r.checks.push({
type: se.ID,
value: Gr(i)
});
}
}, {
name: "className",
query: !0,
regex: "\\.(" + Me.className + ")",
populate: function(e, r, a) {
var n = Je(a, 1), i = n[0];
r.checks.push({
type: se.CLASS,
value: Gr(i)
});
}
}, {
name: "dataExists",
query: !0,
regex: "\\[\\s*(" + Me.variable + ")\\s*\\]",
populate: function(e, r, a) {
var n = Je(a, 1), i = n[0];
r.checks.push({
type: se.DATA_EXIST,
field: Gr(i)
});
}
}, {
name: "dataCompare",
query: !0,
regex: "\\[\\s*(" + Me.variable + ")\\s*(" + Me.comparatorOp + ")\\s*(" + Me.value + ")\\s*\\]",
populate: function(e, r, a) {
var n = Je(a, 3), i = n[0], s = n[1], o = n[2], u = new RegExp("^" + Me.string + "$").exec(o) != null;
u ? o = o.substring(1, o.length - 1) : o = parseFloat(o), r.checks.push({
type: se.DATA_COMPARE,
field: Gr(i),
operator: s,
value: o
});
}
}, {
name: "dataBool",
query: !0,
regex: "\\[\\s*(" + Me.boolOp + ")\\s*(" + Me.variable + ")\\s*\\]",
populate: function(e, r, a) {
var n = Je(a, 2), i = n[0], s = n[1];
r.checks.push({
type: se.DATA_BOOL,
field: Gr(s),
operator: i
});
}
}, {
name: "metaCompare",
query: !0,
regex: "\\[\\[\\s*(" + Me.meta + ")\\s*(" + Me.comparatorOp + ")\\s*(" + Me.number + ")\\s*\\]\\]",
populate: function(e, r, a) {
var n = Je(a, 3), i = n[0], s = n[1], o = n[2];
r.checks.push({
type: se.META_COMPARE,
field: Gr(i),
operator: s,
value: parseFloat(o)
});
}
}, {
name: "nextQuery",
separator: !0,
regex: Me.separator,
populate: function(e, r) {
var a = e.currentSubject, n = e.edgeCount, i = e.compoundCount, s = e[e.length - 1];
a != null && (s.subject = a, e.currentSubject = null), s.edgeCount = n, s.compoundCount = i, e.edgeCount = 0, e.compoundCount = 0;
var o = e[e.length++] = ze();
return o;
}
}, {
name: "directedEdge",
separator: !0,
regex: Me.directedEdge,
populate: function(e, r) {
if (e.currentSubject == null) {
var a = ze(), n = r, i = ze();
return a.checks.push({
type: se.DIRECTED_EDGE,
source: n,
target: i
}), ar(e, r, a), e.edgeCount++, i;
} else {
var s = ze(), o = r, u = ze();
return s.checks.push({
type: se.NODE_SOURCE,
source: o,
target: u
}), ar(e, r, s), e.edgeCount++, u;
}
}
}, {
name: "undirectedEdge",
separator: !0,
regex: Me.undirectedEdge,
populate: function(e, r) {
if (e.currentSubject == null) {
var a = ze(), n = r, i = ze();
return a.checks.push({
type: se.UNDIRECTED_EDGE,
nodes: [n, i]
}), ar(e, r, a), e.edgeCount++, i;
} else {
var s = ze(), o = r, u = ze();
return s.checks.push({
type: se.NODE_NEIGHBOR,
node: o,
neighbor: u
}), ar(e, r, s), u;
}
}
}, {
name: "child",
separator: !0,
regex: Me.child,
populate: function(e, r) {
if (e.currentSubject == null) {
var a = ze(), n = ze(), i = e[e.length - 1];
return a.checks.push({
type: se.CHILD,
parent: i,
child: n
}), ar(e, r, a), e.compoundCount++, n;
} else if (e.currentSubject === r) {
var s = ze(), o = e[e.length - 1], u = ze(), l = ze(), f = ze(), c = ze();
return s.checks.push({
type: se.COMPOUND_SPLIT,
left: o,
right: u,
subject: l
}), l.checks = r.checks, r.checks = [{
type: se.TRUE
}], c.checks.push({
type: se.TRUE
}), u.checks.push({
type: se.PARENT,
// type is swapped on right side queries
parent: c,
child: f
// empty for now
}), ar(e, o, s), e.currentSubject = l, e.compoundCount++, f;
} else {
var v = ze(), h = ze(), d = [{
type: se.PARENT,
parent: v,
child: h
}];
return v.checks = r.checks, r.checks = d, e.compoundCount++, h;
}
}
}, {
name: "descendant",
separator: !0,
regex: Me.descendant,
populate: function(e, r) {
if (e.currentSubject == null) {
var a = ze(), n = ze(), i = e[e.length - 1];
return a.checks.push({
type: se.DESCENDANT,
ancestor: i,
descendant: n
}), ar(e, r, a), e.compoundCount++, n;
} else if (e.currentSubject === r) {
var s = ze(), o = e[e.length - 1], u = ze(), l = ze(), f = ze(), c = ze();
return s.checks.push({
type: se.COMPOUND_SPLIT,
left: o,
right: u,
subject: l
}), l.checks = r.checks, r.checks = [{
type: se.TRUE
}], c.checks.push({
type: se.TRUE
}), u.checks.push({
type: se.ANCESTOR,
// type is swapped on right side queries
ancestor: c,
descendant: f
// empty for now
}), ar(e, o, s), e.currentSubject = l, e.compoundCount++, f;
} else {
var v = ze(), h = ze(), d = [{
type: se.ANCESTOR,
ancestor: v,
descendant: h
}];
return v.checks = r.checks, r.checks = d, e.compoundCount++, h;
}
}
}, {
name: "subject",
modifier: !0,
regex: Me.subject,
populate: function(e, r) {
if (e.currentSubject != null && e.currentSubject !== r)
return Ge("Redefinition of subject in selector `" + e.toString() + "`"), !1;
e.currentSubject = r;
var a = e[e.length - 1], n = a.checks[0], i = n == null ? null : n.type;
i === se.DIRECTED_EDGE ? n.type = se.NODE_TARGET : i === se.UNDIRECTED_EDGE && (n.type = se.NODE_NEIGHBOR, n.node = n.nodes[1], n.neighbor = n.nodes[0], n.nodes = null);
}
}];
qs.forEach(function(t) {
return t.regexObj = new RegExp("^" + t.regex);
});
var rp = function(e) {
for (var r, a, n, i = 0; i < qs.length; i++) {
var s = qs[i], o = s.name, u = e.match(s.regexObj);
if (u != null) {
a = u, r = s, n = o;
var l = u[0];
e = e.substring(l.length);
break;
}
}
return {
expr: r,
match: a,
name: n,
remaining: e
};
}, ap = function(e) {
var r = e.match(/^\s+/);
if (r) {
var a = r[0];
e = e.substring(a.length);
}
return e;
}, np = function(e) {
var r = this, a = r.inputText = e, n = r[0] = ze();
for (r.length = 1, a = ap(a); ; ) {
var i = rp(a);
if (i.expr == null)
return Ge("The selector `" + e + "`is invalid"), !1;
var s = i.match.slice(1), o = i.expr.populate(r, n, s);
if (o === !1)
return !1;
if (o != null && (n = o), a = i.remaining, a.match(/^\s*$/))
break;
}
var u = r[r.length - 1];
r.currentSubject != null && (u.subject = r.currentSubject), u.edgeCount = r.edgeCount, u.compoundCount = r.compoundCount;
for (var l = 0; l < r.length; l++) {
var f = r[l];
if (f.compoundCount > 0 && f.edgeCount > 0)
return Ge("The selector `" + e + "` is invalid because it uses both a compound selector and an edge selector"), !1;
if (f.edgeCount > 1)
return Ge("The selector `" + e + "` is invalid because it uses multiple edge selectors"), !1;
f.edgeCount === 1 && Ge("The selector `" + e + "` is deprecated. Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons. Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.");
}
return !0;
}, ip = function() {
if (this.toStringCache != null)
return this.toStringCache;
for (var e = function(f) {
return f ?? "";
}, r = function(f) {
return ge(f) ? '"' + f + '"' : e(f);
}, a = function(f) {
return " " + f + " ";
}, n = function(f, c) {
var v = f.type, h = f.value;
switch (v) {
case se.GROUP: {
var d = e(h);
return d.substring(0, d.length - 1);
}
case se.DATA_COMPARE: {
var p = f.field, g = f.operator;
return "[" + p + a(e(g)) + r(h) + "]";
}
case se.DATA_BOOL: {
var y = f.operator, b = f.field;
return "[" + e(y) + b + "]";
}
case se.DATA_EXIST: {
var m = f.field;
return "[" + m + "]";
}
case se.META_COMPARE: {
var E = f.operator, T = f.field;
return "[[" + T + a(e(E)) + r(h) + "]]";
}
case se.STATE:
return h;
case se.ID:
return "#" + h;
case se.CLASS:
return "." + h;
case se.PARENT:
case se.CHILD:
return i(f.parent, c) + a(">") + i(f.child, c);
case se.ANCESTOR:
case se.DESCENDANT:
return i(f.ancestor, c) + " " + i(f.descendant, c);
case se.COMPOUND_SPLIT: {
var S = i(f.left, c), w = i(f.subject, c), x = i(f.right, c);
return S + (S.length > 0 ? " " : "") + w + x;
}
case se.TRUE:
return "";
}
}, i = function(f, c) {
return f.checks.reduce(function(v, h, d) {
return v + (c === f && d === 0 ? "$" : "") + n(h, c);
}, "");
}, s = "", o = 0; o < this.length; o++) {
var u = this[o];
s += i(u, u.subject), this.length > 1 && o < this.length - 1 && (s += ", ");
}
return this.toStringCache = s, s;
}, sp = {
parse: np,
toString: ip
}, Jf = function(e, r, a) {
var n, i = ge(e), s = ne(e), o = ge(a), u, l, f = !1, c = !1, v = !1;
switch (r.indexOf("!") >= 0 && (r = r.replace("!", ""), c = !0), r.indexOf("@") >= 0 && (r = r.replace("@", ""), f = !0), (i || o || f) && (u = !i && !s ? "" : "" + e, l = "" + a), f && (e = u = u.toLowerCase(), a = l = l.toLowerCase()), r) {
case "*=":
n = u.indexOf(l) >= 0;
break;
case "$=":
n = u.indexOf(l, u.length - l.length) >= 0;
break;
case "^=":
n = u.indexOf(l) === 0;
break;
case "=":
n = e === a;
break;
case ">":
v = !0, n = e > a;
break;
case ">=":
v = !0, n = e >= a;
break;
case "<":
v = !0, n = e < a;
break;
case "<=":
v = !0, n = e <= a;
break;
default:
n = !1;
break;
}
return c && (e != null || !v) && (n = !n), n;
}, op = function(e, r) {
switch (r) {
case "?":
return !!e;
case "!":
return !e;
case "^":
return e === void 0;
}
}, up = function(e) {
return e !== void 0;
}, bo = function(e, r) {
return e.data(r);
}, lp = function(e, r) {
return e[r]();
}, We = [], Ye = function(e, r) {
return e.checks.every(function(a) {
return We[a.type](a, r);
});
};
We[se.GROUP] = function(t, e) {
var r = t.value;
return r === "*" || r === e.group();
};
We[se.STATE] = function(t, e) {
var r = t.value;
return ep(r, e);
};
We[se.ID] = function(t, e) {
var r = t.value;
return e.id() === r;
};
We[se.CLASS] = function(t, e) {
var r = t.value;
return e.hasClass(r);
};
We[se.META_COMPARE] = function(t, e) {
var r = t.field, a = t.operator, n = t.value;
return Jf(lp(e, r), a, n);
};
We[se.DATA_COMPARE] = function(t, e) {
var r = t.field, a = t.operator, n = t.value;
return Jf(bo(e, r), a, n);
};
We[se.DATA_BOOL] = function(t, e) {
var r = t.field, a = t.operator;
return op(bo(e, r), a);
};
We[se.DATA_EXIST] = function(t, e) {
var r = t.field;
return t.operator, up(bo(e, r));
};
We[se.UNDIRECTED_EDGE] = function(t, e) {
var r = t.nodes[0], a = t.nodes[1], n = e.source(), i = e.target();
return Ye(r, n) && Ye(a, i) || Ye(a, n) && Ye(r, i);
};
We[se.NODE_NEIGHBOR] = function(t, e) {
return Ye(t.node, e) && e.neighborhood().some(function(r) {
return r.isNode() && Ye(t.neighbor, r);
});
};
We[se.DIRECTED_EDGE] = function(t, e) {
return Ye(t.source, e.source()) && Ye(t.target, e.target());
};
We[se.NODE_SOURCE] = function(t, e) {
return Ye(t.source, e) && e.outgoers().some(function(r) {
return r.isNode() && Ye(t.target, r);
});
};
We[se.NODE_TARGET] = function(t, e) {
return Ye(t.target, e) && e.incomers().some(function(r) {
return r.isNode() && Ye(t.source, r);
});
};
We[se.CHILD] = function(t, e) {
return Ye(t.child, e) && Ye(t.parent, e.parent());
};
We[se.PARENT] = function(t, e) {
return Ye(t.parent, e) && e.children().some(function(r) {
return Ye(t.child, r);
});
};
We[se.DESCENDANT] = function(t, e) {
return Ye(t.descendant, e) && e.ancestors().some(function(r) {
return Ye(t.ancestor, r);
});
};
We[se.ANCESTOR] = function(t, e) {
return Ye(t.ancestor, e) && e.descendants().some(function(r) {
return Ye(t.descendant, r);
});
};
We[se.COMPOUND_SPLIT] = function(t, e) {
return Ye(t.subject, e) && Ye(t.left, e) && Ye(t.right, e);
};
We[se.TRUE] = function() {
return !0;
};
We[se.COLLECTION] = function(t, e) {
var r = t.value;
return r.has(e);
};
We[se.FILTER] = function(t, e) {
var r = t.value;
return r(e);
};
var fp = function(e) {
var r = this;
if (r.length === 1 && r[0].checks.length === 1 && r[0].checks[0].type === se.ID)
return e.getElementById(r[0].checks[0].value).collection();
var a = function(i) {
for (var s = 0; s < r.length; s++) {
var o = r[s];
if (Ye(o, i))
return !0;
}
return !1;
};
return r.text() == null && (a = function() {
return !0;
}), e.filter(a);
}, cp = function(e) {
for (var r = this, a = 0; a < r.length; a++) {
var n = r[a];
if (Ye(n, e))
return !0;
}
return !1;
}, vp = {
matches: cp,
filter: fp
}, hr = function(e) {
this.inputText = e, this.currentSubject = null, this.compoundCount = 0, this.edgeCount = 0, this.length = 0, e == null || ge(e) && e.match(/^\s*$/) || (Lt(e) ? this.addQuery({
checks: [{
type: se.COLLECTION,
value: e.collection()
}]
}) : Xe(e) ? this.addQuery({
checks: [{
type: se.FILTER,
value: e
}]
}) : ge(e) ? this.parse(e) || (this.invalid = !0) : He("A selector must be created from a string; found "));
}, dr = hr.prototype;
[sp, vp].forEach(function(t) {
return be(dr, t);
});
dr.text = function() {
return this.inputText;
};
dr.size = function() {
return this.length;
};
dr.eq = function(t) {
return this[t];
};
dr.sameText = function(t) {
return !this.invalid && !t.invalid && this.text() === t.text();
};
dr.addQuery = function(t) {
this[this.length++] = t;
};
dr.selector = dr.toString;
var ur = {
allAre: function(e) {
var r = new hr(e);
return this.every(function(a) {
return r.matches(a);
});
},
is: function(e) {
var r = new hr(e);
return this.some(function(a) {
return r.matches(a);
});
},
some: function(e, r) {
for (var a = 0; a < this.length; a++) {
var n = r ? e.apply(r, [this[a], a, this]) : e(this[a], a, this);
if (n)
return !0;
}
return !1;
},
every: function(e, r) {
for (var a = 0; a < this.length; a++) {
var n = r ? e.apply(r, [this[a], a, this]) : e(this[a], a, this);
if (!n)
return !1;
}
return !0;
},
same: function(e) {
if (this === e)
return !0;
e = this.cy().collection(e);
var r = this.length, a = e.length;
return r !== a ? !1 : r === 1 ? this[0] === e[0] : this.every(function(n) {
return e.hasElementWithId(n.id());
});
},
anySame: function(e) {
return e = this.cy().collection(e), this.some(function(r) {
return e.hasElementWithId(r.id());
});
},
allAreNeighbors: function(e) {
e = this.cy().collection(e);
var r = this.neighborhood();
return e.every(function(a) {
return r.hasElementWithId(a.id());
});
},
contains: function(e) {
e = this.cy().collection(e);
var r = this;
return e.every(function(a) {
return r.hasElementWithId(a.id());
});
}
};
ur.allAreNeighbours = ur.allAreNeighbors;
ur.has = ur.contains;
ur.equal = ur.equals = ur.same;
var Mt = function(e, r) {
return function(n, i, s, o) {
var u = n, l = this, f;
if (u == null ? f = "" : Lt(u) && u.length === 1 && (f = u.id()), l.length === 1 && f) {
var c = l[0]._private, v = c.traversalCache = c.traversalCache || {}, h = v[r] = v[r] || [], d = Ir(f), p = h[d];
return p || (h[d] = e.call(l, n, i, s, o));
} else
return e.call(l, n, i, s, o);
};
}, aa = {
parent: function(e) {
var r = [];
if (this.length === 1) {
var a = this[0]._private.parent;
if (a)
return a;
}
for (var n = 0; n < this.length; n++) {
var i = this[n], s = i._private.parent;
s && r.push(s);
}
return this.spawn(r, !0).filter(e);
},
parents: function(e) {
for (var r = [], a = this.parent(); a.nonempty(); ) {
for (var n = 0; n < a.length; n++) {
var i = a[n];
r.push(i);
}
a = a.parent();
}
return this.spawn(r, !0).filter(e);
},
commonAncestors: function(e) {
for (var r, a = 0; a < this.length; a++) {
var n = this[a], i = n.parents();
r = r || i, r = r.intersect(i);
}
return r.filter(e);
},
orphans: function(e) {
return this.stdFilter(function(r) {
return r.isOrphan();
}).filter(e);
},
nonorphans: function(e) {
return this.stdFilter(function(r) {
return r.isChild();
}).filter(e);
},
children: Mt(function(t) {
for (var e = [], r = 0; r < this.length; r++)
for (var a = this[r], n = a._private.children, i = 0; i < n.length; i++)
e.push(n[i]);
return this.spawn(e, !0).filter(t);
}, "children"),
siblings: function(e) {
return this.parent().children().not(this).filter(e);
},
isParent: function() {
var e = this[0];
if (e)
return e.isNode() && e._private.children.length !== 0;
},
isChildless: function() {
var e = this[0];
if (e)
return e.isNode() && e._private.children.length === 0;
},
isChild: function() {
var e = this[0];
if (e)
return e.isNode() && e._private.parent != null;
},
isOrphan: function() {
var e = this[0];
if (e)
return e.isNode() && e._private.parent == null;
},
descendants: function(e) {
var r = [];
function a(n) {
for (var i = 0; i < n.length; i++) {
var s = n[i];
r.push(s), s.children().nonempty() && a(s.children());
}
}
return a(this.children()), this.spawn(r, !0).filter(e);
}
};
function wo(t, e, r, a) {
for (var n = [], i = new na(), s = t.cy(), o = s.hasCompoundNodes(), u = 0; u < t.length; u++) {
var l = t[u];
r ? n.push(l) : o && a(n, i, l);
}
for (; n.length > 0; ) {
var f = n.shift();
e(f), i.add(f.id()), o && a(n, i, f);
}
return t;
}
function jf(t, e, r) {
if (r.isParent())
for (var a = r._private.children, n = 0; n < a.length; n++) {
var i = a[n];
e.has(i.id()) || t.push(i);
}
}
aa.forEachDown = function(t) {
var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0;
return wo(this, t, e, jf);
};
function ec(t, e, r) {
if (r.isChild()) {
var a = r._private.parent;
e.has(a.id()) || t.push(a);
}
}
aa.forEachUp = function(t) {
var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0;
return wo(this, t, e, ec);
};
function hp(t, e, r) {
ec(t, e, r), jf(t, e, r);
}
aa.forEachUpAndDown = function(t) {
var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0;
return wo(this, t, e, hp);
};
aa.ancestors = aa.parents;
var Pa, tc;
Pa = tc = {
data: _e.data({
field: "data",
bindingEvent: "data",
allowBinding: !0,
allowSetting: !0,
settingEvent: "data",
settingTriggersEvent: !0,
triggerFnName: "trigger",
allowGetting: !0,
immutableKeys: {
id: !0,
source: !0,
target: !0,
parent: !0
},
updateStyle: !0
}),
removeData: _e.removeData({
field: "data",
event: "data",
triggerFnName: "trigger",
triggerEvent: !0,
immutableKeys: {
id: !0,
source: !0,
target: !0,
parent: !0
},
updateStyle: !0
}),
scratch: _e.data({
field: "scratch",
bindingEvent: "scratch",
allowBinding: !0,
allowSetting: !0,
settingEvent: "scratch",
settingTriggersEvent: !0,
triggerFnName: "trigger",
allowGetting: !0,
updateStyle: !0
}),
removeScratch: _e.removeData({
field: "scratch",
event: "scratch",
triggerFnName: "trigger",
triggerEvent: !0,
updateStyle: !0
}),
rscratch: _e.data({
field: "rscratch",
allowBinding: !1,
allowSetting: !0,
settingTriggersEvent: !1,
allowGetting: !0
}),
removeRscratch: _e.removeData({
field: "rscratch",
triggerEvent: !1
}),
id: function() {
var e = this[0];
if (e)
return e._private.data.id;
}
};
Pa.attr = Pa.data;
Pa.removeAttr = Pa.removeData;
var dp = tc, Xn = {};
function Es(t) {
return function(e) {
var r = this;
if (e === void 0 && (e = !0), r.length !== 0)
if (r.isNode() && !r.removed()) {
for (var a = 0, n = r[0], i = n._private.edges, s = 0; s < i.length; s++) {
var o = i[s];
!e && o.isLoop() || (a += t(n, o));
}
return a;
} else
return;
};
}
be(Xn, {
degree: Es(function(t, e) {
return e.source().same(e.target()) ? 2 : 1;
}),
indegree: Es(function(t, e) {
return e.target().same(t) ? 1 : 0;
}),
outdegree: Es(function(t, e) {
return e.source().same(t) ? 1 : 0;
})
});
function zr(t, e) {
return function(r) {
for (var a, n = this.nodes(), i = 0; i < n.length; i++) {
var s = n[i], o = s[t](r);
o !== void 0 && (a === void 0 || e(o, a)) && (a = o);
}
return a;
};
}
be(Xn, {
minDegree: zr("degree", function(t, e) {
return t < e;
}),
maxDegree: zr("degree", function(t, e) {
return t > e;
}),
minIndegree: zr("indegree", function(t, e) {
return t < e;
}),
maxIndegree: zr("indegree", function(t, e) {
return t > e;
}),
minOutdegree: zr("outdegree", function(t, e) {
return t < e;
}),
maxOutdegree: zr("outdegree", function(t, e) {
return t > e;
})
});
be(Xn, {
totalDegree: function(e) {
for (var r = 0, a = this.nodes(), n = 0; n < a.length; n++)
r += a[n].degree(e);
return r;
}
});
var Bt, rc, ac = function(e, r, a) {
for (var n = 0; n < e.length; n++) {
var i = e[n];
if (!i.locked()) {
var s = i._private.position, o = {
x: r.x != null ? r.x - s.x : 0,
y: r.y != null ? r.y - s.y : 0
};
i.isParent() && !(o.x === 0 && o.y === 0) && i.children().shift(o, a), i.dirtyBoundingBoxCache();
}
}
}, yl = {
field: "position",
bindingEvent: "position",
allowBinding: !0,
allowSetting: !0,
settingEvent: "position",
settingTriggersEvent: !0,
triggerFnName: "emitAndNotify",
allowGetting: !0,
validKeys: ["x", "y"],
beforeGet: function(e) {
e.updateCompoundBounds();
},
beforeSet: function(e, r) {
ac(e, r, !1);
},
onSet: function(e) {
e.dirtyCompoundBoundsCache();
},
canSet: function(e) {
return !e.locked();
}
};
Bt = rc = {
position: _e.data(yl),
// position but no notification to renderer
silentPosition: _e.data(be({}, yl, {
allowBinding: !1,
allowSetting: !0,
settingTriggersEvent: !1,
allowGetting: !1,
beforeSet: function(e, r) {
ac(e, r, !0);
},
onSet: function(e) {
e.dirtyCompoundBoundsCache();
}
})),
positions: function(e, r) {
if (Oe(e))
r ? this.silentPosition(e) : this.position(e);
else if (Xe(e)) {
var a = e, n = this.cy();
n.startBatch();
for (var i = 0; i < this.length; i++) {
var s = this[i], o = void 0;
(o = a(s, i)) && (r ? s.silentPosition(o) : s.position(o));
}
n.endBatch();
}
return this;
},
silentPositions: function(e) {
return this.positions(e, !0);
},
shift: function(e, r, a) {
var n;
if (Oe(e) ? (n = {
x: ne(e.x) ? e.x : 0,
y: ne(e.y) ? e.y : 0
}, a = r) : ge(e) && ne(r) && (n = {
x: 0,
y: 0
}, n[e] = r), n != null) {
var i = this.cy();
i.startBatch();
for (var s = 0; s < this.length; s++) {
var o = this[s];
if (!(i.hasCompoundNodes() && o.isChild() && o.ancestors().anySame(this))) {
var u = o.position(), l = {
x: u.x + n.x,
y: u.y + n.y
};
a ? o.silentPosition(l) : o.position(l);
}
}
i.endBatch();
}
return this;
},
silentShift: function(e, r) {
return Oe(e) ? this.shift(e, !0) : ge(e) && ne(r) && this.shift(e, r, !0), this;
},
// get/set the rendered (i.e. on screen) positon of the element
renderedPosition: function(e, r) {
var a = this[0], n = this.cy(), i = n.zoom(), s = n.pan(), o = Oe(e) ? e : void 0, u = o !== void 0 || r !== void 0 && ge(e);
if (a && a.isNode())
if (u)
for (var l = 0; l < this.length; l++) {
var f = this[l];
r !== void 0 ? f.position(e, (r - s[e]) / i) : o !== void 0 && f.position(Pf(o, i, s));
}
else {
var c = a.position();
return o = zn(c, i, s), e === void 0 ? o : o[e];
}
else if (!u)
return;
return this;
},
// get/set the position relative to the parent
relativePosition: function(e, r) {
var a = this[0], n = this.cy(), i = Oe(e) ? e : void 0, s = i !== void 0 || r !== void 0 && ge(e), o = n.hasCompoundNodes();
if (a && a.isNode())
if (s)
for (var u = 0; u < this.length; u++) {
var l = this[u], f = o ? l.parent() : null, c = f && f.length > 0, v = c;
c && (f = f[0]);
var h = v ? f.position() : {
x: 0,
y: 0
};
r !== void 0 ? l.position(e, r + h[e]) : i !== void 0 && l.position({
x: i.x + h.x,
y: i.y + h.y
});
}
else {
var d = a.position(), p = o ? a.parent() : null, g = p && p.length > 0, y = g;
g && (p = p[0]);
var b = y ? p.position() : {
x: 0,
y: 0
};
return i = {
x: d.x - b.x,
y: d.y - b.y
}, e === void 0 ? i : i[e];
}
else if (!s)
return;
return this;
}
};
Bt.modelPosition = Bt.point = Bt.position;
Bt.modelPositions = Bt.points = Bt.positions;
Bt.renderedPoint = Bt.renderedPosition;
Bt.relativePoint = Bt.relativePosition;
var gp = rc, ea, br;
ea = br = {};
br.renderedBoundingBox = function(t) {
var e = this.boundingBox(t), r = this.cy(), a = r.zoom(), n = r.pan(), i = e.x1 * a + n.x, s = e.x2 * a + n.x, o = e.y1 * a + n.y, u = e.y2 * a + n.y;
return {
x1: i,
x2: s,
y1: o,
y2: u,
w: s - i,
h: u - o
};
};
br.dirtyCompoundBoundsCache = function() {
var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1, e = this.cy();
return !e.styleEnabled() || !e.hasCompoundNodes() ? this : (this.forEachUp(function(r) {
if (r.isParent()) {
var a = r._private;
a.compoundBoundsClean = !1, a.bbCache = null, t || r.emitAndNotify("bounds");
}
}), this);
};
br.updateCompoundBounds = function() {
var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1, e = this.cy();
if (!e.styleEnabled() || !e.hasCompoundNodes())
return this;
if (!t && e.batching())
return this;
function r(s) {
if (!s.isParent())
return;
var o = s._private, u = s.children(), l = s.pstyle("compound-sizing-wrt-labels").value === "include", f = {
width: {
val: s.pstyle("min-width").pfValue,
left: s.pstyle("min-width-bias-left"),
right: s.pstyle("min-width-bias-right")
},
height: {
val: s.pstyle("min-height").pfValue,
top: s.pstyle("min-height-bias-top"),
bottom: s.pstyle("min-height-bias-bottom")
}
}, c = u.boundingBox({
includeLabels: l,
includeOverlays: !1,
// updating the compound bounds happens outside of the regular
// cache cycle (i.e. before fired events)
useCache: !1
}), v = o.position;
(c.w === 0 || c.h === 0) && (c = {
w: s.pstyle("width").pfValue,
h: s.pstyle("height").pfValue
}, c.x1 = v.x - c.w / 2, c.x2 = v.x + c.w / 2, c.y1 = v.y - c.h / 2, c.y2 = v.y + c.h / 2);
function h(C, D, A) {
var L = 0, R = 0, I = D + A;
return C > 0 && I > 0 && (L = D / I * C, R = A / I * C), {
biasDiff: L,
biasComplementDiff: R
};
}
function d(C, D, A, L) {
if (A.units === "%")
switch (L) {
case "width":
return C > 0 ? A.pfValue * C : 0;
case "height":
return D > 0 ? A.pfValue * D : 0;
case "average":
return C > 0 && D > 0 ? A.pfValue * (C + D) / 2 : 0;
case "min":
return C > 0 && D > 0 ? C > D ? A.pfValue * D : A.pfValue * C : 0;
case "max":
return C > 0 && D > 0 ? C > D ? A.pfValue * C : A.pfValue * D : 0;
default:
return 0;
}
else
return A.units === "px" ? A.pfValue : 0;
}
var p = f.width.left.value;
f.width.left.units === "px" && f.width.val > 0 && (p = p * 100 / f.width.val);
var g = f.width.right.value;
f.width.right.units === "px" && f.width.val > 0 && (g = g * 100 / f.width.val);
var y = f.height.top.value;
f.height.top.units === "px" && f.height.val > 0 && (y = y * 100 / f.height.val);
var b = f.height.bottom.value;
f.height.bottom.units === "px" && f.height.val > 0 && (b = b * 100 / f.height.val);
var m = h(f.width.val - c.w, p, g), E = m.biasDiff, T = m.biasComplementDiff, S = h(f.height.val - c.h, y, b), w = S.biasDiff, x = S.biasComplementDiff;
o.autoPadding = d(c.w, c.h, s.pstyle("padding"), s.pstyle("padding-relative-to").value), o.autoWidth = Math.max(c.w, f.width.val), v.x = (-E + c.x1 + c.x2 + T) / 2, o.autoHeight = Math.max(c.h, f.height.val), v.y = (-w + c.y1 + c.y2 + x) / 2;
}
for (var a = 0; a < this.length; a++) {
var n = this[a], i = n._private;
(!i.compoundBoundsClean || t) && (r(n), e.batching() || (i.compoundBoundsClean = !0));
}
return this;
};
var Pt = function(e) {
return e === 1 / 0 || e === -1 / 0 ? 0 : e;
}, Nt = function(e, r, a, n, i) {
n - r === 0 || i - a === 0 || r == null || a == null || n == null || i == null || (e.x1 = r < e.x1 ? r : e.x1, e.x2 = n > e.x2 ? n : e.x2, e.y1 = a < e.y1 ? a : e.y1, e.y2 = i > e.y2 ? i : e.y2, e.w = e.x2 - e.x1, e.h = e.y2 - e.y1);
}, nr = function(e, r) {
return r == null ? e : Nt(e, r.x1, r.y1, r.x2, r.y2);
}, da = function(e, r, a) {
return Dt(e, r, a);
}, rn = function(e, r, a) {
if (!r.cy().headless()) {
var n = r._private, i = n.rstyle, s = i.arrowWidth / 2, o = r.pstyle(a + "-arrow-shape").value, u, l;
if (o !== "none") {
a === "source" ? (u = i.srcX, l = i.srcY) : a === "target" ? (u = i.tgtX, l = i.tgtY) : (u = i.midX, l = i.midY);
var f = n.arrowBounds = n.arrowBounds || {}, c = f[a] = f[a] || {};
c.x1 = u - s, c.y1 = l - s, c.x2 = u + s, c.y2 = l + s, c.w = c.x2 - c.x1, c.h = c.y2 - c.y1, cn(c, 1), Nt(e, c.x1, c.y1, c.x2, c.y2);
}
}
}, xs = function(e, r, a) {
if (!r.cy().headless()) {
var n;
a ? n = a + "-" : n = "";
var i = r._private, s = i.rstyle, o = r.pstyle(n + "label").strValue;
if (o) {
var u = r.pstyle("text-halign"), l = r.pstyle("text-valign"), f = da(s, "labelWidth", a), c = da(s, "labelHeight", a), v = da(s, "labelX", a), h = da(s, "labelY", a), d = r.pstyle(n + "text-margin-x").pfValue, p = r.pstyle(n + "text-margin-y").pfValue, g = r.isEdge(), y = r.pstyle(n + "text-rotation"), b = r.pstyle("text-outline-width").pfValue, m = r.pstyle("text-border-width").pfValue, E = m / 2, T = r.pstyle("text-background-padding").pfValue, S = 2, w = c, x = f, C = x / 2, D = w / 2, A, L, R, I;
if (g)
A = v - C, L = v + C, R = h - D, I = h + D;
else {
switch (u.value) {
case "left":
A = v - x, L = v;
break;
case "center":
A = v - C, L = v + C;
break;
case "right":
A = v, L = v + x;
break;
}
switch (l.value) {
case "top":
R = h - w, I = h;
break;
case "center":
R = h - D, I = h + D;
break;
case "bottom":
R = h, I = h + w;
break;
}
}
var M = d - Math.max(b, E) - T - S, N = d + Math.max(b, E) + T + S, O = p - Math.max(b, E) - T - S, k = p + Math.max(b, E) + T + S;
A += M, L += N, R += O, I += k;
var B = a || "main", _ = i.labelBounds, F = _[B] = _[B] || {};
F.x1 = A, F.y1 = R, F.x2 = L, F.y2 = I, F.w = L - A, F.h = I - R, F.leftPad = M, F.rightPad = N, F.topPad = O, F.botPad = k;
var G = g && y.strValue === "autorotate", H = y.pfValue != null && y.pfValue !== 0;
if (G || H) {
var Y = G ? da(i.rstyle, "labelAngle", a) : y.pfValue, X = Math.cos(Y), W = Math.sin(Y), ee = (A + L) / 2, ae = (R + I) / 2;
if (!g) {
switch (u.value) {
case "left":
ee = L;
break;
case "right":
ee = A;
break;
}
switch (l.value) {
case "top":
ae = I;
break;
case "bottom":
ae = R;
break;
}
}
var J = function(Te, we) {
return Te = Te - ee, we = we - ae, {
x: Te * X - we * W + ee,
y: Te * W + we * X + ae
};
}, z = J(A, R), V = J(A, I), q = J(L, R), Z = J(L, I);
A = Math.min(z.x, V.x, q.x, Z.x), L = Math.max(z.x, V.x, q.x, Z.x), R = Math.min(z.y, V.y, q.y, Z.y), I = Math.max(z.y, V.y, q.y, Z.y);
}
var re = B + "Rot", ve = _[re] = _[re] || {};
ve.x1 = A, ve.y1 = R, ve.x2 = L, ve.y2 = I, ve.w = L - A, ve.h = I - R, Nt(e, A, R, L, I), Nt(i.labelBounds.all, A, R, L, I);
}
return e;
}
}, ml = function(e, r) {
if (!r.cy().headless()) {
var a = r.pstyle("outline-opacity").value, n = r.pstyle("outline-width").value, i = r.pstyle("outline-offset").value, s = n + i;
nc(e, r, a, s, "outside", s / 2);
}
}, nc = function(e, r, a, n, i, s) {
if (!(a === 0 || n <= 0 || i === "inside")) {
var o = r.cy(), u = r.pstyle("shape").value, l = o.renderer().nodeShapes[u], f = r.position(), c = f.x, v = f.y, h = r.width(), d = r.height();
if (l.hasMiterBounds) {
i === "center" && (n /= 2);
var p = l.miterBounds(c, v, h, d, n);
nr(e, p);
} else
s != null && s > 0 && vn(e, [s, s, s, s]);
}
}, pp = function(e, r) {
if (!r.cy().headless()) {
var a = r.pstyle("border-opacity").value, n = r.pstyle("border-width").pfValue, i = r.pstyle("border-position").value;
nc(e, r, a, n, i);
}
}, yp = function(e, r) {
var a = e._private.cy, n = a.styleEnabled(), i = a.headless(), s = Et(), o = e._private, u = e.isNode(), l = e.isEdge(), f, c, v, h, d, p, g = o.rstyle, y = u && n ? e.pstyle("bounds-expansion").pfValue : [0], b = function(Ie) {
return Ie.pstyle("display").value !== "none";
}, m = !n || b(e) && (!l || b(e.source()) && b(e.target()));
if (m) {
var E = 0, T = 0;
n && r.includeOverlays && (E = e.pstyle("overlay-opacity").value, E !== 0 && (T = e.pstyle("overlay-padding").value));
var S = 0, w = 0;
n && r.includeUnderlays && (S = e.pstyle("underlay-opacity").value, S !== 0 && (w = e.pstyle("underlay-padding").value));
var x = Math.max(T, w), C = 0, D = 0;
if (n && (C = e.pstyle("width").pfValue, D = C / 2), u && r.includeNodes) {
var A = e.position();
d = A.x, p = A.y;
var L = e.outerWidth(), R = L / 2, I = e.outerHeight(), M = I / 2;
f = d - R, c = d + R, v = p - M, h = p + M, Nt(s, f, v, c, h), n && ml(s, e), n && r.includeOutlines && !i && ml(s, e), n && pp(s, e);
} else if (l && r.includeEdges)
if (n && !i) {
var N = e.pstyle("curve-style").strValue;
if (f = Math.min(g.srcX, g.midX, g.tgtX), c = Math.max(g.srcX, g.midX, g.tgtX), v = Math.min(g.srcY, g.midY, g.tgtY), h = Math.max(g.srcY, g.midY, g.tgtY), f -= D, c += D, v -= D, h += D, Nt(s, f, v, c, h), N === "haystack") {
var O = g.haystackPts;
if (O && O.length === 2) {
if (f = O[0].x, v = O[0].y, c = O[1].x, h = O[1].y, f > c) {
var k = f;
f = c, c = k;
}
if (v > h) {
var B = v;
v = h, h = B;
}
Nt(s, f - D, v - D, c + D, h + D);
}
} else if (N === "bezier" || N === "unbundled-bezier" || ir(N, "segments") || ir(N, "taxi")) {
var _;
switch (N) {
case "bezier":
case "unbundled-bezier":
_ = g.bezierPts;
break;
case "segments":
case "taxi":
case "round-segments":
case "round-taxi":
_ = g.linePts;
break;
}
if (_ != null)
for (var F = 0; F < _.length; F++) {
var G = _[F];
f = G.x - D, c = G.x + D, v = G.y - D, h = G.y + D, Nt(s, f, v, c, h);
}
}
} else {
var H = e.source(), Y = H.position(), X = e.target(), W = X.position();
if (f = Y.x, c = W.x, v = Y.y, h = W.y, f > c) {
var ee = f;
f = c, c = ee;
}
if (v > h) {
var ae = v;
v = h, h = ae;
}
f -= D, c += D, v -= D, h += D, Nt(s, f, v, c, h);
}
if (n && r.includeEdges && l && (rn(s, e, "mid-source"), rn(s, e, "mid-target"), rn(s, e, "source"), rn(s, e, "target")), n) {
var J = e.pstyle("ghost").value === "yes";
if (J) {
var z = e.pstyle("ghost-offset-x").pfValue, V = e.pstyle("ghost-offset-y").pfValue;
Nt(s, s.x1 + z, s.y1 + V, s.x2 + z, s.y2 + V);
}
}
var q = o.bodyBounds = o.bodyBounds || {};
au(q, s), vn(q, y), cn(q, 1), n && (f = s.x1, c = s.x2, v = s.y1, h = s.y2, Nt(s, f - x, v - x, c + x, h + x));
var Z = o.overlayBounds = o.overlayBounds || {};
au(Z, s), vn(Z, y), cn(Z, 1);
var re = o.labelBounds = o.labelBounds || {};
re.all != null ? Jh(re.all) : re.all = Et(), n && r.includeLabels && (r.includeMainLabels && xs(s, e, null), l && (r.includeSourceLabels && xs(s, e, "source"), r.includeTargetLabels && xs(s, e, "target")));
}
return s.x1 = Pt(s.x1), s.y1 = Pt(s.y1), s.x2 = Pt(s.x2), s.y2 = Pt(s.y2), s.w = Pt(s.x2 - s.x1), s.h = Pt(s.y2 - s.y1), s.w > 0 && s.h > 0 && m && (vn(s, y), cn(s, 1)), s;
}, ic = function(e) {
var r = 0, a = function(s) {
return (s ? 1 : 0) << r++;
}, n = 0;
return n += a(e.incudeNodes), n += a(e.includeEdges), n += a(e.includeLabels), n += a(e.includeMainLabels), n += a(e.includeSourceLabels), n += a(e.includeTargetLabels), n += a(e.includeOverlays), n += a(e.includeOutlines), n;
}, sc = function(e) {
var r = function(o) {
return Math.round(o);
};
if (e.isEdge()) {
var a = e.source().position(), n = e.target().position();
return Qo([r(a.x), r(a.y), r(n.x), r(n.y)]);
} else {
var i = e.position();
return Qo([r(i.x), r(i.y)]);
}
}, bl = function(e, r) {
var a = e._private, n, i = e.isEdge(), s = r == null ? wl : ic(r), o = s === wl;
if (a.bbCache == null ? (n = yp(e, Ma), a.bbCache = n, a.bbCachePosKey = sc(e)) : n = a.bbCache, !o) {
var u = e.isNode();
n = Et(), (r.includeNodes && u || r.includeEdges && !u) && (r.includeOverlays ? nr(n, a.overlayBounds) : nr(n, a.bodyBounds)), r.includeLabels && (r.includeMainLabels && (!i || r.includeSourceLabels && r.includeTargetLabels) ? nr(n, a.labelBounds.all) : (r.includeMainLabels && nr(n, a.labelBounds.mainRot), r.includeSourceLabels && nr(n, a.labelBounds.sourceRot), r.includeTargetLabels && nr(n, a.labelBounds.targetRot))), n.w = n.x2 - n.x1, n.h = n.y2 - n.y1;
}
return n;
}, Ma = {
includeNodes: !0,
includeEdges: !0,
includeLabels: !0,
includeMainLabels: !0,
includeSourceLabels: !0,
includeTargetLabels: !0,
includeOverlays: !0,
includeUnderlays: !0,
includeOutlines: !0,
useCache: !0
}, wl = ic(Ma), El = ht(Ma);
br.boundingBox = function(t) {
var e, r = t === void 0 || t.useCache === void 0 || t.useCache === !0, a = ta(function(f) {
var c = f._private;
return c.bbCache == null || c.styleDirty || c.bbCachePosKey !== sc(f);
}, function(f) {
return f.id();
});
if (r && this.length === 1 && !a(this[0]))
t === void 0 ? t = Ma : t = El(t), e = bl(this[0], t);
else {
e = Et(), t = t || Ma;
var n = El(t), i = this, s = i.cy(), o = s.styleEnabled();
this.edges().forEach(a), this.nodes().forEach(a), o && this.recalculateRenderedStyle(r), this.updateCompoundBounds(!r);
for (var u = 0; u < i.length; u++) {
var l = i[u];
a(l) && l.dirtyBoundingBoxCache(), nr(e, bl(l, n));
}
}
return e.x1 = Pt(e.x1), e.y1 = Pt(e.y1), e.x2 = Pt(e.x2), e.y2 = Pt(e.y2), e.w = Pt(e.x2 - e.x1), e.h = Pt(e.y2 - e.y1), e;
};
br.dirtyBoundingBoxCache = function() {
for (var t = 0; t < this.length; t++) {
var e = this[t]._private;
e.bbCache = null, e.bbCachePosKey = null, e.bodyBounds = null, e.overlayBounds = null, e.labelBounds.all = null, e.labelBounds.source = null, e.labelBounds.target = null, e.labelBounds.main = null, e.labelBounds.sourceRot = null, e.labelBounds.targetRot = null, e.labelBounds.mainRot = null, e.arrowBounds.source = null, e.arrowBounds.target = null, e.arrowBounds["mid-source"] = null, e.arrowBounds["mid-target"] = null;
}
return this.emitAndNotify("bounds"), this;
};
br.boundingBoxAt = function(t) {
var e = this.nodes(), r = this.cy(), a = r.hasCompoundNodes(), n = r.collection();
if (a && (n = e.filter(function(l) {
return l.isParent();
}), e = e.not(n)), Oe(t)) {
var i = t;
t = function() {
return i;
};
}
var s = function(f, c) {
return f._private.bbAtOldPos = t(f, c);
}, o = function(f) {
return f._private.bbAtOldPos;
};
r.startBatch(), e.forEach(s).silentPositions(t), a && (n.dirtyCompoundBoundsCache(), n.dirtyBoundingBoxCache(), n.updateCompoundBounds(!0));
var u = Qh(this.boundingBox({
useCache: !1
}));
return e.silentPositions(o), a && (n.dirtyCompoundBoundsCache(), n.dirtyBoundingBoxCache(), n.updateCompoundBounds(!0)), r.endBatch(), u;
};
ea.boundingbox = ea.bb = ea.boundingBox;
ea.renderedBoundingbox = ea.renderedBoundingBox;
var mp = br, Ea, qa;
Ea = qa = {};
var oc = function(e) {
e.uppercaseName = Bo(e.name), e.autoName = "auto" + e.uppercaseName, e.labelName = "label" + e.uppercaseName, e.outerName = "outer" + e.uppercaseName, e.uppercaseOuterName = Bo(e.outerName), Ea[e.name] = function() {
var a = this[0], n = a._private, i = n.cy, s = i._private.styleEnabled;
if (a)
if (s) {
if (a.isParent())
return a.updateCompoundBounds(), n[e.autoName] || 0;
var o = a.pstyle(e.name);
switch (o.strValue) {
case "label":
return a.recalculateRenderedStyle(), n.rstyle[e.labelName] || 0;
default:
return o.pfValue;
}
} else
return 1;
}, Ea["outer" + e.uppercaseName] = function() {
var a = this[0], n = a._private, i = n.cy, s = i._private.styleEnabled;
if (a)
if (s) {
var o = a[e.name](), u = a.pstyle("border-position").value, l;
u === "center" ? l = a.pstyle("border-width").pfValue : u === "outside" ? l = 2 * a.pstyle("border-width").pfValue : l = 0;
var f = 2 * a.padding();
return o + l + f;
} else
return 1;
}, Ea["rendered" + e.uppercaseName] = function() {
var a = this[0];
if (a) {
var n = a[e.name]();
return n * this.cy().zoom();
}
}, Ea["rendered" + e.uppercaseOuterName] = function() {
var a = this[0];
if (a) {
var n = a[e.outerName]();
return n * this.cy().zoom();
}
};
};
oc({
name: "width"
});
oc({
name: "height"
});
qa.padding = function() {
var t = this[0], e = t._private;
return t.isParent() ? (t.updateCompoundBounds(), e.autoPadding !== void 0 ? e.autoPadding : t.pstyle("padding").pfValue) : t.pstyle("padding").pfValue;
};
qa.paddedHeight = function() {
var t = this[0];
return t.height() + 2 * t.padding();
};
qa.paddedWidth = function() {
var t = this[0];
return t.width() + 2 * t.padding();
};
var bp = qa, wp = function(e, r) {
if (e.isEdge() && e.takesUpSpace())
return r(e);
}, Ep = function(e, r) {
if (e.isEdge() && e.takesUpSpace()) {
var a = e.cy();
return zn(r(e), a.zoom(), a.pan());
}
}, xp = function(e, r) {
if (e.isEdge() && e.takesUpSpace()) {
var a = e.cy(), n = a.pan(), i = a.zoom();
return r(e).map(function(s) {
return zn(s, i, n);
});
}
}, Tp = function(e) {
return e.renderer().getControlPoints(e);
}, Cp = function(e) {
return e.renderer().getSegmentPoints(e);
}, Dp = function(e) {
return e.renderer().getSourceEndpoint(e);
}, Sp = function(e) {
return e.renderer().getTargetEndpoint(e);
}, Ap = function(e) {
return e.renderer().getEdgeMidpoint(e);
}, xl = {
controlPoints: {
get: Tp,
mult: !0
},
segmentPoints: {
get: Cp,
mult: !0
},
sourceEndpoint: {
get: Dp
},
targetEndpoint: {
get: Sp
},
midpoint: {
get: Ap
}
}, Lp = function(e) {
return "rendered" + e[0].toUpperCase() + e.substr(1);
}, Rp = Object.keys(xl).reduce(function(t, e) {
var r = xl[e], a = Lp(e);
return t[e] = function() {
return wp(this, r.get);
}, r.mult ? t[a] = function() {
return xp(this, r.get);
} : t[a] = function() {
return Ep(this, r.get);
}, t;
}, {}), Ip = be({}, gp, mp, bp, Rp);
/*!
Event object based on jQuery events, MIT license
https://jquery.org/license/
https://tldrlegal.com/license/mit-license
https://github.com/jquery/jquery/blob/master/src/event.js
*/
var uc = function(e, r) {
this.recycle(e, r);
};
function ga() {
return !1;
}
function an() {
return !0;
}
uc.prototype = {
instanceString: function() {
return "event";
},
recycle: function(e, r) {
if (this.isImmediatePropagationStopped = this.isPropagationStopped = this.isDefaultPrevented = ga, e != null && e.preventDefault ? (this.type = e.type, this.isDefaultPrevented = e.defaultPrevented ? an : ga) : e != null && e.type ? r = e : this.type = e, r != null && (this.originalEvent = r.originalEvent, this.type = r.type != null ? r.type : this.type, this.cy = r.cy, this.target = r.target, this.position = r.position, this.renderedPosition = r.renderedPosition, this.namespace = r.namespace, this.layout = r.layout), this.cy != null && this.position != null && this.renderedPosition == null) {
var a = this.position, n = this.cy.zoom(), i = this.cy.pan();
this.renderedPosition = {
x: a.x * n + i.x,
y: a.y * n + i.y
};
}
this.timeStamp = e && e.timeStamp || Date.now();
},
preventDefault: function() {
this.isDefaultPrevented = an;
var e = this.originalEvent;
e && e.preventDefault && e.preventDefault();
},
stopPropagation: function() {
this.isPropagationStopped = an;
var e = this.originalEvent;
e && e.stopPropagation && e.stopPropagation();
},
stopImmediatePropagation: function() {
this.isImmediatePropagationStopped = an, this.stopPropagation();
},
isDefaultPrevented: ga,
isPropagationStopped: ga,
isImmediatePropagationStopped: ga
};
var lc = /^([^.]+)(\.(?:[^.]+))?$/, Pp = ".*", fc = {
qualifierCompare: function(e, r) {
return e === r;
},
eventMatches: function() {
return !0;
},
addEventFields: function() {
},
callbackContext: function(e) {
return e;
},
beforeEmit: function() {
},
afterEmit: function() {
},
bubble: function() {
return !1;
},
parent: function() {
return null;
},
context: null
}, Tl = Object.keys(fc), Mp = {};
function $n() {
for (var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Mp, e = arguments.length > 1 ? arguments[1] : void 0, r = 0; r < Tl.length; r++) {
var a = Tl[r];
this[a] = t[a] || fc[a];
}
this.context = e || this.context, this.listeners = [], this.emitting = 0;
}
var gr = $n.prototype, cc = function(e, r, a, n, i, s, o) {
Xe(n) && (i = n, n = null), o && (s == null ? s = o : s = be({}, s, o));
for (var u = Ve(a) ? a : a.split(/\s+/), l = 0; l < u.length; l++) {
var f = u[l];
if (!fr(f)) {
var c = f.match(lc);
if (c) {
var v = c[1], h = c[2] ? c[2] : null, d = r(e, f, v, h, n, i, s);
if (d === !1)
break;
}
}
}
}, Cl = function(e, r) {
return e.addEventFields(e.context, r), new uc(r.type, r);
}, Op = function(e, r, a) {
if (Gv(a)) {
r(e, a);
return;
} else if (Oe(a)) {
r(e, Cl(e, a));
return;
}
for (var n = Ve(a) ? a : a.split(/\s+/), i = 0; i < n.length; i++) {
var s = n[i];
if (!fr(s)) {
var o = s.match(lc);
if (o) {
var u = o[1], l = o[2] ? o[2] : null, f = Cl(e, {
type: u,
namespace: l,
target: e.context
});
r(e, f);
}
}
}
};
gr.on = gr.addListener = function(t, e, r, a, n) {
return cc(this, function(i, s, o, u, l, f, c) {
Xe(f) && i.listeners.push({
event: s,
// full event string
callback: f,
// callback to run
type: o,
// the event type (e.g. 'click')
namespace: u,
// the event namespace (e.g. ".foo")
qualifier: l,
// a restriction on whether to match this emitter
conf: c
// additional configuration
});
}, t, e, r, a, n), this;
};
gr.one = function(t, e, r, a) {
return this.on(t, e, r, a, {
one: !0
});
};
gr.removeListener = gr.off = function(t, e, r, a) {
var n = this;
this.emitting !== 0 && (this.listeners = Eh(this.listeners));
for (var i = this.listeners, s = function(l) {
var f = i[l];
cc(n, function(c, v, h, d, p, g) {
if ((f.type === h || t === "*") && (!d && f.namespace !== ".*" || f.namespace === d) && (!p || c.qualifierCompare(f.qualifier, p)) && (!g || f.callback === g))
return i.splice(l, 1), !1;
}, t, e, r, a);
}, o = i.length - 1; o >= 0; o--)
s(o);
return this;
};
gr.removeAllListeners = function() {
return this.removeListener("*");
};
gr.emit = gr.trigger = function(t, e, r) {
var a = this.listeners, n = a.length;
return this.emitting++, Ve(e) || (e = [e]), Op(this, function(i, s) {
r != null && (a = [{
event: s.event,
type: s.type,
namespace: s.namespace,
callback: r
}], n = a.length);
for (var o = function() {
var f = a[u];
if (f.type === s.type && (!f.namespace || f.namespace === s.namespace || f.namespace === Pp) && i.eventMatches(i.context, f, s)) {
var c = [s];
e != null && Th(c, e), i.beforeEmit(i.context, f, s), f.conf && f.conf.one && (i.listeners = i.listeners.filter(function(d) {
return d !== f;
}));
var v = i.callbackContext(i.context, f, s), h = f.callback.apply(v, c);
i.afterEmit(i.context, f, s), h === !1 && (s.stopPropagation(), s.preventDefault());
}
}, u = 0; u < n; u++)
o();
i.bubble(i.context) && !s.isPropagationStopped() && i.parent(i.context).emit(s, e);
}, t), this.emitting--, this;
};
var kp = {
qualifierCompare: function(e, r) {
return e == null || r == null ? e == null && r == null : e.sameText(r);
},
eventMatches: function(e, r, a) {
var n = r.qualifier;
return n != null ? e !== a.target && Fa(a.target) && n.matches(a.target) : !0;
},
addEventFields: function(e, r) {
r.cy = e.cy(), r.target = e;
},
callbackContext: function(e, r, a) {
return r.qualifier != null ? a.target : e;
},
beforeEmit: function(e, r) {
r.conf && r.conf.once && r.conf.onceCollection.removeListener(r.event, r.qualifier, r.callback);
},
bubble: function() {
return !0;
},
parent: function(e) {
return e.isChild() ? e.parent() : e.cy();
}
}, nn = function(e) {
return ge(e) ? new hr(e) : e;
}, vc = {
createEmitter: function() {
for (var e = 0; e < this.length; e++) {
var r = this[e], a = r._private;
a.emitter || (a.emitter = new $n(kp, r));
}
return this;
},
emitter: function() {
return this._private.emitter;
},
on: function(e, r, a) {
for (var n = nn(r), i = 0; i < this.length; i++) {
var s = this[i];
s.emitter().on(e, n, a);
}
return this;
},
removeListener: function(e, r, a) {
for (var n = nn(r), i = 0; i < this.length; i++) {
var s = this[i];
s.emitter().removeListener(e, n, a);
}
return this;
},
removeAllListeners: function() {
for (var e = 0; e < this.length; e++) {
var r = this[e];
r.emitter().removeAllListeners();
}
return this;
},
one: function(e, r, a) {
for (var n = nn(r), i = 0; i < this.length; i++) {
var s = this[i];
s.emitter().one(e, n, a);
}
return this;
},
once: function(e, r, a) {
for (var n = nn(r), i = 0; i < this.length; i++) {
var s = this[i];
s.emitter().on(e, n, a, {
once: !0,
onceCollection: this
});
}
},
emit: function(e, r) {
for (var a = 0; a < this.length; a++) {
var n = this[a];
n.emitter().emit(e, r);
}
return this;
},
emitAndNotify: function(e, r) {
if (this.length !== 0)
return this.cy().notify(e, this), this.emit(e, r), this;
}
};
_e.eventAliasesOn(vc);
var hc = {
nodes: function(e) {
return this.filter(function(r) {
return r.isNode();
}).filter(e);
},
edges: function(e) {
return this.filter(function(r) {
return r.isEdge();
}).filter(e);
},
// internal helper to get nodes and edges as separate collections with single iteration over elements
byGroup: function() {
for (var e = this.spawn(), r = this.spawn(), a = 0; a < this.length; a++) {
var n = this[a];
n.isNode() ? e.push(n) : r.push(n);
}
return {
nodes: e,
edges: r
};
},
filter: function(e, r) {
if (e === void 0)
return this;
if (ge(e) || Lt(e))
return new hr(e).filter(this);
if (Xe(e)) {
for (var a = this.spawn(), n = this, i = 0; i < n.length; i++) {
var s = n[i], o = r ? e.apply(r, [s, i, n]) : e(s, i, n);
o && a.push(s);
}
return a;
}
return this.spawn();
},
not: function(e) {
if (e) {
ge(e) && (e = this.filter(e));
for (var r = this.spawn(), a = 0; a < this.length; a++) {
var n = this[a], i = e.has(n);
i || r.push(n);
}
return r;
} else
return this;
},
absoluteComplement: function() {
var e = this.cy();
return e.mutableElements().not(this);
},
intersect: function(e) {
if (ge(e)) {
var r = e;
return this.filter(r);
}
for (var a = this.spawn(), n = this, i = e, s = this.length < e.length, o = s ? n : i, u = s ? i : n, l = 0; l < o.length; l++) {
var f = o[l];
u.has(f) && a.push(f);
}
return a;
},
xor: function(e) {
var r = this._private.cy;
ge(e) && (e = r.$(e));
var a = this.spawn(), n = this, i = e, s = function(u, l) {
for (var f = 0; f < u.length; f++) {
var c = u[f], v = c._private.data.id, h = l.hasElementWithId(v);
h || a.push(c);
}
};
return s(n, i), s(i, n), a;
},
diff: function(e) {
var r = this._private.cy;
ge(e) && (e = r.$(e));
var a = this.spawn(), n = this.spawn(), i = this.spawn(), s = this, o = e, u = function(f, c, v) {
for (var h = 0; h < f.length; h++) {
var d = f[h], p = d._private.data.id, g = c.hasElementWithId(p);
g ? i.merge(d) : v.push(d);
}
};
return u(s, o, a), u(o, s, n), {
left: a,
right: n,
both: i
};
},
add: function(e) {
var r = this._private.cy;
if (!e)
return this;
if (ge(e)) {
var a = e;
e = r.mutableElements().filter(a);
}
for (var n = this.spawnSelf(), i = 0; i < e.length; i++) {
var s = e[i], o = !this.has(s);
o && n.push(s);
}
return n;
},
// in place merge on calling collection
merge: function(e) {
var r = this._private, a = r.cy;
if (!e)
return this;
if (e && ge(e)) {
var n = e;
e = a.mutableElements().filter(n);
}
for (var i = r.map, s = 0; s < e.length; s++) {
var o = e[s], u = o._private.data.id, l = !i.has(u);
if (l) {
var f = this.length++;
this[f] = o, i.set(u, {
ele: o,
index: f
});
}
}
return this;
},
unmergeAt: function(e) {
var r = this[e], a = r.id(), n = this._private, i = n.map;
this[e] = void 0, i.delete(a);
var s = e === this.length - 1;
if (this.length > 1 && !s) {
var o = this.length - 1, u = this[o], l = u._private.data.id;
this[o] = void 0, this[e] = u, i.set(l, {
ele: u,
index: e
});
}
return this.length--, this;
},
// remove single ele in place in calling collection
unmergeOne: function(e) {
e = e[0];
var r = this._private, a = e._private.data.id, n = r.map, i = n.get(a);
if (!i)
return this;
var s = i.index;
return this.unmergeAt(s), this;
},
// remove eles in place on calling collection
unmerge: function(e) {
var r = this._private.cy;
if (!e)
return this;
if (e && ge(e)) {
var a = e;
e = r.mutableElements().filter(a);
}
for (var n = 0; n < e.length; n++)
this.unmergeOne(e[n]);
return this;
},
unmergeBy: function(e) {
for (var r = this.length - 1; r >= 0; r--) {
var a = this[r];
e(a) && this.unmergeAt(r);
}
return this;
},
map: function(e, r) {
for (var a = [], n = this, i = 0; i < n.length; i++) {
var s = n[i], o = r ? e.apply(r, [s, i, n]) : e(s, i, n);
a.push(o);
}
return a;
},
reduce: function(e, r) {
for (var a = r, n = this, i = 0; i < n.length; i++)
a = e(a, n[i], i, n);
return a;
},
max: function(e, r) {
for (var a = -1 / 0, n, i = this, s = 0; s < i.length; s++) {
var o = i[s], u = r ? e.apply(r, [o, s, i]) : e(o, s, i);
u > a && (a = u, n = o);
}
return {
value: a,
ele: n
};
},
min: function(e, r) {
for (var a = 1 / 0, n, i = this, s = 0; s < i.length; s++) {
var o = i[s], u = r ? e.apply(r, [o, s, i]) : e(o, s, i);
u < a && (a = u, n = o);
}
return {
value: a,
ele: n
};
}
}, ke = hc;
ke.u = ke["|"] = ke["+"] = ke.union = ke.or = ke.add;
ke["\\"] = ke["!"] = ke["-"] = ke.difference = ke.relativeComplement = ke.subtract = ke.not;
ke.n = ke["&"] = ke["."] = ke.and = ke.intersection = ke.intersect;
ke["^"] = ke["(+)"] = ke["(-)"] = ke.symmetricDifference = ke.symdiff = ke.xor;
ke.fnFilter = ke.filterFn = ke.stdFilter = ke.filter;
ke.complement = ke.abscomp = ke.absoluteComplement;
var Np = {
isNode: function() {
return this.group() === "nodes";
},
isEdge: function() {
return this.group() === "edges";
},
isLoop: function() {
return this.isEdge() && this.source()[0] === this.target()[0];
},
isSimple: function() {
return this.isEdge() && this.source()[0] !== this.target()[0];
},
group: function() {
var e = this[0];
if (e)
return e._private.group;
}
}, dc = function(e, r) {
var a = e.cy(), n = a.hasCompoundNodes();
function i(f) {
var c = f.pstyle("z-compound-depth");
return c.value === "auto" ? n ? f.zDepth() : 0 : c.value === "bottom" ? -1 : c.value === "top" ? uo : 0;
}
var s = i(e) - i(r);
if (s !== 0)
return s;
function o(f) {
var c = f.pstyle("z-index-compare");
return c.value === "auto" && f.isNode() ? 1 : 0;
}
var u = o(e) - o(r);
if (u !== 0)
return u;
var l = e.pstyle("z-index").value - r.pstyle("z-index").value;
return l !== 0 ? l : e.poolIndex() - r.poolIndex();
}, In = {
forEach: function(e, r) {
if (Xe(e))
for (var a = this.length, n = 0; n < a; n++) {
var i = this[n], s = r ? e.apply(r, [i, n, this]) : e(i, n, this);
if (s === !1)
break;
}
return this;
},
toArray: function() {
for (var e = [], r = 0; r < this.length; r++)
e.push(this[r]);
return e;
},
slice: function(e, r) {
var a = [], n = this.length;
r == null && (r = n), e == null && (e = 0), e < 0 && (e = n + e), r < 0 && (r = n + r);
for (var i = e; i >= 0 && i < r && i < n; i++)
a.push(this[i]);
return this.spawn(a);
},
size: function() {
return this.length;
},
eq: function(e) {
return this[e] || this.spawn();
},
first: function() {
return this[0] || this.spawn();
},
last: function() {
return this[this.length - 1] || this.spawn();
},
empty: function() {
return this.length === 0;
},
nonempty: function() {
return !this.empty();
},
sort: function(e) {
if (!Xe(e))
return this;
var r = this.toArray().sort(e);
return this.spawn(r);
},
sortByZIndex: function() {
return this.sort(dc);
},
zDepth: function() {
var e = this[0];
if (e) {
var r = e._private, a = r.group;
if (a === "nodes") {
var n = r.data.parent ? e.parents().size() : 0;
return e.isParent() ? n : uo - 1;
} else {
var i = r.source, s = r.target, o = i.zDepth(), u = s.zDepth();
return Math.max(o, u, 0);
}
}
}
};
In.each = In.forEach;
var Bp = function() {
var e = "undefined", r = (typeof Symbol > "u" ? "undefined" : nt(Symbol)) != e && nt(Symbol.iterator) != e;
r && (In[Symbol.iterator] = function() {
var a = this, n = {
value: void 0,
done: !1
}, i = 0, s = this.length;
return vf({
next: function() {
return i < s ? n.value = a[i++] : (n.value = void 0, n.done = !0), n;
}
}, Symbol.iterator, function() {
return this;
});
});
};
Bp();
var Fp = ht({
nodeDimensionsIncludeLabels: !1
}), dn = {
// Calculates and returns node dimensions { x, y } based on options given
layoutDimensions: function(e) {
e = Fp(e);
var r;
if (!this.takesUpSpace())
r = {
w: 0,
h: 0
};
else if (e.nodeDimensionsIncludeLabels) {
var a = this.boundingBox();
r = {
w: a.w,
h: a.h
};
} else
r = {
w: this.outerWidth(),
h: this.outerHeight()
};
return (r.w === 0 || r.h === 0) && (r.w = r.h = 1), r;
},
// using standard layout options, apply position function (w/ or w/o animation)
layoutPositions: function(e, r, a) {
var n = this.nodes().filter(function(T) {
return !T.isParent();
}), i = this.cy(), s = r.eles, o = function(S) {
return S.id();
}, u = ta(a, o);
e.emit({
type: "layoutstart",
layout: e
}), e.animations = [];
var l = function(S, w, x) {
var C = {
x: w.x1 + w.w / 2,
y: w.y1 + w.h / 2
}, D = {
// scale from center of bounding box (not necessarily 0,0)
x: (x.x - C.x) * S,
y: (x.y - C.y) * S
};
return {
x: C.x + D.x,
y: C.y + D.y
};
}, f = r.spacingFactor && r.spacingFactor !== 1, c = function() {
if (!f)
return null;
for (var S = Et(), w = 0; w < n.length; w++) {
var x = n[w], C = u(x, w);
Mf(S, C.x, C.y);
}
return S;
}, v = c(), h = ta(function(T, S) {
var w = u(T, S);
if (f) {
var x = Math.abs(r.spacingFactor);
w = l(x, v, w);
}
return r.transform != null && (w = r.transform(T, w)), w;
}, o);
if (r.animate) {
for (var d = 0; d < n.length; d++) {
var p = n[d], g = h(p, d), y = r.animateFilter == null || r.animateFilter(p, d);
if (y) {
var b = p.animation({
position: g,
duration: r.animationDuration,
easing: r.animationEasing
});
e.animations.push(b);
} else
p.position(g);
}
if (r.fit) {
var m = i.animation({
fit: {
boundingBox: s.boundingBoxAt(h),
padding: r.padding
},
duration: r.animationDuration,
easing: r.animationEasing
});
e.animations.push(m);
} else if (r.zoom !== void 0 && r.pan !== void 0) {
var E = i.animation({
zoom: r.zoom,
pan: r.pan,
duration: r.animationDuration,
easing: r.animationEasing
});
e.animations.push(E);
}
e.animations.forEach(function(T) {
return T.play();
}), e.one("layoutready", r.ready), e.emit({
type: "layoutready",
layout: e
}), ia.all(e.animations.map(function(T) {
return T.promise();
})).then(function() {
e.one("layoutstop", r.stop), e.emit({
type: "layoutstop",
layout: e
});
});
} else
n.positions(h), r.fit && i.fit(r.eles, r.padding), r.zoom != null && i.zoom(r.zoom), r.pan && i.pan(r.pan), e.one("layoutready", r.ready), e.emit({
type: "layoutready",
layout: e
}), e.one("layoutstop", r.stop), e.emit({
type: "layoutstop",
layout: e
});
return this;
},
layout: function(e) {
var r = this.cy();
return r.makeLayout(be({}, e, {
eles: this
}));
}
};
dn.createLayout = dn.makeLayout = dn.layout;
function gc(t, e, r) {
var a = r._private, n = a.styleCache = a.styleCache || [], i;
return (i = n[t]) != null || (i = n[t] = e(r)), i;
}
function Wn(t, e) {
return t = Ir(t), function(a) {
return gc(t, e, a);
};
}
function Kn(t, e) {
t = Ir(t);
var r = function(n) {
return e.call(n);
};
return function() {
var n = this[0];
if (n)
return gc(t, r, n);
};
}
var ct = {
recalculateRenderedStyle: function(e) {
var r = this.cy(), a = r.renderer(), n = r.styleEnabled();
return a && n && a.recalculateRenderedStyle(this, e), this;
},
dirtyStyleCache: function() {
var e = this.cy(), r = function(i) {
return i._private.styleCache = null;
};
if (e.hasCompoundNodes()) {
var a;
a = this.spawnSelf().merge(this.descendants()).merge(this.parents()), a.merge(a.connectedEdges()), a.forEach(r);
} else
this.forEach(function(n) {
r(n), n.connectedEdges().forEach(r);
});
return this;
},
// fully updates (recalculates) the style for the elements
updateStyle: function(e) {
var r = this._private.cy;
if (!r.styleEnabled())
return this;
if (r.batching()) {
var a = r._private.batchStyleEles;
return a.merge(this), this;
}
var n = r.hasCompoundNodes(), i = this;
e = !!(e || e === void 0), n && (i = this.spawnSelf().merge(this.descendants()).merge(this.parents()));
var s = i;
return e ? s.emitAndNotify("style") : s.emit("style"), i.forEach(function(o) {
return o._private.styleDirty = !0;
}), this;
},
// private: clears dirty flag and recalculates style
cleanStyle: function() {
var e = this.cy();
if (e.styleEnabled())
for (var r = 0; r < this.length; r++) {
var a = this[r];
a._private.styleDirty && (a._private.styleDirty = !1, e.style().apply(a));
}
},
// get the internal parsed style object for the specified property
parsedStyle: function(e) {
var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, a = this[0], n = a.cy();
if (n.styleEnabled() && a) {
a._private.styleDirty && (a._private.styleDirty = !1, n.style().apply(a));
var i = a._private.style[e];
return i ?? (r ? n.style().getDefaultProperty(e) : null);
}
},
numericStyle: function(e) {
var r = this[0];
if (r.cy().styleEnabled() && r) {
var a = r.pstyle(e);
return a.pfValue !== void 0 ? a.pfValue : a.value;
}
},
numericStyleUnits: function(e) {
var r = this[0];
if (r.cy().styleEnabled() && r)
return r.pstyle(e).units;
},
// get the specified css property as a rendered value (i.e. on-screen value)
// or get the whole rendered style if no property specified (NB doesn't allow setting)
renderedStyle: function(e) {
var r = this.cy();
if (!r.styleEnabled())
return this;
var a = this[0];
if (a)
return r.style().getRenderedStyle(a, e);
},
// read the calculated css style of the element or override the style (via a bypass)
style: function(e, r) {
var a = this.cy();
if (!a.styleEnabled())
return this;
var n = !1, i = a.style();
if (Oe(e)) {
var s = e;
i.applyBypass(this, s, n), this.emitAndNotify("style");
} else if (ge(e))
if (r === void 0) {
var o = this[0];
return o ? i.getStylePropertyValue(o, e) : void 0;
} else
i.applyBypass(this, e, r, n), this.emitAndNotify("style");
else if (e === void 0) {
var u = this[0];
return u ? i.getRawStyle(u) : void 0;
}
return this;
},
removeStyle: function(e) {
var r = this.cy();
if (!r.styleEnabled())
return this;
var a = !1, n = r.style(), i = this;
if (e === void 0)
for (var s = 0; s < i.length; s++) {
var o = i[s];
n.removeAllBypasses(o, a);
}
else {
e = e.split(/\s+/);
for (var u = 0; u < i.length; u++) {
var l = i[u];
n.removeBypasses(l, e, a);
}
}
return this.emitAndNotify("style"), this;
},
show: function() {
return this.css("display", "element"), this;
},
hide: function() {
return this.css("display", "none"), this;
},
effectiveOpacity: function() {
var e = this.cy();
if (!e.styleEnabled())
return 1;
var r = e.hasCompoundNodes(), a = this[0];
if (a) {
var n = a._private, i = a.pstyle("opacity").value;
if (!r)
return i;
var s = n.data.parent ? a.parents() : null;
if (s)
for (var o = 0; o < s.length; o++) {
var u = s[o], l = u.pstyle("opacity").value;
i = l * i;
}
return i;
}
},
transparent: function() {
var e = this.cy();
if (!e.styleEnabled())
return !1;
var r = this[0], a = r.cy().hasCompoundNodes();
if (r)
return a ? r.effectiveOpacity() === 0 : r.pstyle("opacity").value === 0;
},
backgrounding: function() {
var e = this.cy();
if (!e.styleEnabled())
return !1;
var r = this[0];
return !!r._private.backgrounding;
}
};
function Ts(t, e) {
var r = t._private, a = r.data.parent ? t.parents() : null;
if (a)
for (var n = 0; n < a.length; n++) {
var i = a[n];
if (!e(i))
return !1;
}
return !0;
}
function Eo(t) {
var e = t.ok, r = t.edgeOkViaNode || t.ok, a = t.parentOk || t.ok;
return function() {
var n = this.cy();
if (!n.styleEnabled())
return !0;
var i = this[0], s = n.hasCompoundNodes();
if (i) {
var o = i._private;
if (!e(i))
return !1;
if (i.isNode())
return !s || Ts(i, a);
var u = o.source, l = o.target;
return r(u) && (!s || Ts(u, r)) && (u === l || r(l) && (!s || Ts(l, r)));
}
};
}
var sa = Wn("eleTakesUpSpace", function(t) {
return t.pstyle("display").value === "element" && t.width() !== 0 && (t.isNode() ? t.height() !== 0 : !0);
});
ct.takesUpSpace = Kn("takesUpSpace", Eo({
ok: sa
}));
var _p = Wn("eleInteractive", function(t) {
return t.pstyle("events").value === "yes" && t.pstyle("visibility").value === "visible" && sa(t);
}), Gp = Wn("parentInteractive", function(t) {
return t.pstyle("visibility").value === "visible" && sa(t);
});
ct.interactive = Kn("interactive", Eo({
ok: _p,
parentOk: Gp,
edgeOkViaNode: sa
}));
ct.noninteractive = function() {
var t = this[0];
if (t)
return !t.interactive();
};
var zp = Wn("eleVisible", function(t) {
return t.pstyle("visibility").value === "visible" && t.pstyle("opacity").pfValue !== 0 && sa(t);
}), Vp = sa;
ct.visible = Kn("visible", Eo({
ok: zp,
edgeOkViaNode: Vp
}));
ct.hidden = function() {
var t = this[0];
if (t)
return !t.visible();
};
ct.isBundledBezier = Kn("isBundledBezier", function() {
return this.cy().styleEnabled() ? !this.removed() && this.pstyle("curve-style").value === "bezier" && this.takesUpSpace() : !1;
});
ct.bypass = ct.css = ct.style;
ct.renderedCss = ct.renderedStyle;
ct.removeBypass = ct.removeCss = ct.removeStyle;
ct.pstyle = ct.parsedStyle;
var lr = {};
function Dl(t) {
return function() {
var e = arguments, r = [];
if (e.length === 2) {
var a = e[0], n = e[1];
this.on(t.event, a, n);
} else if (e.length === 1 && Xe(e[0])) {
var i = e[0];
this.on(t.event, i);
} else if (e.length === 0 || e.length === 1 && Ve(e[0])) {
for (var s = e.length === 1 ? e[0] : null, o = 0; o < this.length; o++) {
var u = this[o], l = !t.ableField || u._private[t.ableField], f = u._private[t.field] != t.value;
if (t.overrideAble) {
var c = t.overrideAble(u);
if (c !== void 0 && (l = c, !c))
return this;
}
l && (u._private[t.field] = t.value, f && r.push(u));
}
var v = this.spawn(r);
v.updateStyle(), v.emit(t.event), s && v.emit(s);
}
return this;
};
}
function oa(t) {
lr[t.field] = function() {
var e = this[0];
if (e) {
if (t.overrideField) {
var r = t.overrideField(e);
if (r !== void 0)
return r;
}
return e._private[t.field];
}
}, lr[t.on] = Dl({
event: t.on,
field: t.field,
ableField: t.ableField,
overrideAble: t.overrideAble,
value: !0
}), lr[t.off] = Dl({
event: t.off,
field: t.field,
ableField: t.ableField,
overrideAble: t.overrideAble,
value: !1
});
}
oa({
field: "locked",
overrideField: function(e) {
return e.cy().autolock() ? !0 : void 0;
},
on: "lock",
off: "unlock"
});
oa({
field: "grabbable",
overrideField: function(e) {
return e.cy().autoungrabify() || e.pannable() ? !1 : void 0;
},
on: "grabify",
off: "ungrabify"
});
oa({
field: "selected",
ableField: "selectable",
overrideAble: function(e) {
return e.cy().autounselectify() ? !1 : void 0;
},
on: "select",
off: "unselect"
});
oa({
field: "selectable",
overrideField: function(e) {
return e.cy().autounselectify() ? !1 : void 0;
},
on: "selectify",
off: "unselectify"
});
lr.deselect = lr.unselect;
lr.grabbed = function() {
var t = this[0];
if (t)
return t._private.grabbed;
};
oa({
field: "active",
on: "activate",
off: "unactivate"
});
oa({
field: "pannable",
on: "panify",
off: "unpanify"
});
lr.inactive = function() {
var t = this[0];
if (t)
return !t._private.active;
};
var pt = {}, Sl = function(e) {
return function(a) {
for (var n = this, i = [], s = 0; s < n.length; s++) {
var o = n[s];
if (o.isNode()) {
for (var u = !1, l = o.connectedEdges(), f = 0; f < l.length; f++) {
var c = l[f], v = c.source(), h = c.target();
if (e.noIncomingEdges && h === o && v !== o || e.noOutgoingEdges && v === o && h !== o) {
u = !0;
break;
}
}
u || i.push(o);
}
}
return this.spawn(i, !0).filter(a);
};
}, Al = function(e) {
return function(r) {
for (var a = this, n = [], i = 0; i < a.length; i++) {
var s = a[i];
if (s.isNode())
for (var o = s.connectedEdges(), u = 0; u < o.length; u++) {
var l = o[u], f = l.source(), c = l.target();
e.outgoing && f === s ? (n.push(l), n.push(c)) : e.incoming && c === s && (n.push(l), n.push(f));
}
}
return this.spawn(n, !0).filter(r);
};
}, Ll = function(e) {
return function(r) {
for (var a = this, n = [], i = {}; ; ) {
var s = e.outgoing ? a.outgoers() : a.incomers();
if (s.length === 0)
break;
for (var o = !1, u = 0; u < s.length; u++) {
var l = s[u], f = l.id();
i[f] || (i[f] = !0, n.push(l), o = !0);
}
if (!o)
break;
a = s;
}
return this.spawn(n, !0).filter(r);
};
};
pt.clearTraversalCache = function() {
for (var t = 0; t < this.length; t++)
this[t]._private.traversalCache = null;
};
be(pt, {
// get the root nodes in the DAG
roots: Sl({
noIncomingEdges: !0
}),
// get the leaf nodes in the DAG
leaves: Sl({
noOutgoingEdges: !0
}),
// normally called children in graph theory
// these nodes =edges=> outgoing nodes
outgoers: Mt(Al({
outgoing: !0
}), "outgoers"),
// aka DAG descendants
successors: Ll({
outgoing: !0
}),
// normally called parents in graph theory
// these nodes <=edges= incoming nodes
incomers: Mt(Al({
incoming: !0
}), "incomers"),
// aka DAG ancestors
predecessors: Ll({})
});
be(pt, {
neighborhood: Mt(function(t) {
for (var e = [], r = this.nodes(), a = 0; a < r.length; a++)
for (var n = r[a], i = n.connectedEdges(), s = 0; s < i.length; s++) {
var o = i[s], u = o.source(), l = o.target(), f = n === u ? l : u;
f.length > 0 && e.push(f[0]), e.push(o[0]);
}
return this.spawn(e, !0).filter(t);
}, "neighborhood"),
closedNeighborhood: function(e) {
return this.neighborhood().add(this).filter(e);
},
openNeighborhood: function(e) {
return this.neighborhood(e);
}
});
pt.neighbourhood = pt.neighborhood;
pt.closedNeighbourhood = pt.closedNeighborhood;
pt.openNeighbourhood = pt.openNeighborhood;
be(pt, {
source: Mt(function(e) {
var r = this[0], a;
return r && (a = r._private.source || r.cy().collection()), a && e ? a.filter(e) : a;
}, "source"),
target: Mt(function(e) {
var r = this[0], a;
return r && (a = r._private.target || r.cy().collection()), a && e ? a.filter(e) : a;
}, "target"),
sources: Rl({
attr: "source"
}),
targets: Rl({
attr: "target"
})
});
function Rl(t) {
return function(r) {
for (var a = [], n = 0; n < this.length; n++) {
var i = this[n], s = i._private[t.attr];
s && a.push(s);
}
return this.spawn(a, !0).filter(r);
};
}
be(pt, {
edgesWith: Mt(Il(), "edgesWith"),
edgesTo: Mt(Il({
thisIsSrc: !0
}), "edgesTo")
});
function Il(t) {
return function(r) {
var a = [], n = this._private.cy, i = t || {};
ge(r) && (r = n.$(r));
for (var s = 0; s < r.length; s++)
for (var o = r[s]._private.edges, u = 0; u < o.length; u++) {
var l = o[u], f = l._private.data, c = this.hasElementWithId(f.source) && r.hasElementWithId(f.target), v = r.hasElementWithId(f.source) && this.hasElementWithId(f.target), h = c || v;
h && ((i.thisIsSrc || i.thisIsTgt) && (i.thisIsSrc && !c || i.thisIsTgt && !v) || a.push(l));
}
return this.spawn(a, !0);
};
}
be(pt, {
connectedEdges: Mt(function(t) {
for (var e = [], r = this, a = 0; a < r.length; a++) {
var n = r[a];
if (n.isNode())
for (var i = n._private.edges, s = 0; s < i.length; s++) {
var o = i[s];
e.push(o);
}
}
return this.spawn(e, !0).filter(t);
}, "connectedEdges"),
connectedNodes: Mt(function(t) {
for (var e = [], r = this, a = 0; a < r.length; a++) {
var n = r[a];
n.isEdge() && (e.push(n.source()[0]), e.push(n.target()[0]));
}
return this.spawn(e, !0).filter(t);
}, "connectedNodes"),
parallelEdges: Mt(Pl(), "parallelEdges"),
codirectedEdges: Mt(Pl({
codirected: !0
}), "codirectedEdges")
});
function Pl(t) {
var e = {
codirected: !1
};
return t = be({}, e, t), function(a) {
for (var n = [], i = this.edges(), s = t, o = 0; o < i.length; o++)
for (var u = i[o], l = u._private, f = l.source, c = f._private.data.id, v = l.data.target, h = f._private.edges, d = 0; d < h.length; d++) {
var p = h[d], g = p._private.data, y = g.target, b = g.source, m = y === v && b === c, E = c === y && v === b;
(s.codirected && m || !s.codirected && (m || E)) && n.push(p);
}
return this.spawn(n, !0).filter(a);
};
}
be(pt, {
components: function(e) {
var r = this, a = r.cy(), n = a.collection(), i = e == null ? r.nodes() : e.nodes(), s = [];
e != null && i.empty() && (i = e.sources());
var o = function(f, c) {
n.merge(f), i.unmerge(f), c.merge(f);
};
if (i.empty())
return r.spawn();
var u = function() {
var f = a.collection();
s.push(f);
var c = i[0];
o(c, f), r.bfs({
directed: !1,
roots: c,
visit: function(h) {
return o(h, f);
}
}), f.forEach(function(v) {
v.connectedEdges().forEach(function(h) {
r.has(h) && f.has(h.source()) && f.has(h.target()) && f.merge(h);
});
});
};
do
u();
while (i.length > 0);
return s;
},
component: function() {
var e = this[0];
return e.cy().mutableElements().components(e)[0];
}
});
pt.componentsOf = pt.components;
var vt = function(e, r) {
var a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1, n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1;
if (e === void 0) {
He("A collection must have a reference to the core");
return;
}
var i = new Zt(), s = !1;
if (!r)
r = [];
else if (r.length > 0 && Oe(r[0]) && !Fa(r[0])) {
s = !0;
for (var o = [], u = new na(), l = 0, f = r.length; l < f; l++) {
var c = r[l];
c.data == null && (c.data = {});
var v = c.data;
if (v.id == null)
v.id = Rf();
else if (e.hasElementWithId(v.id) || u.has(v.id))
continue;
var h = new Gn(e, c, !1);
o.push(h), u.add(v.id);
}
r = o;
}
this.length = 0;
for (var d = 0, p = r.length; d < p; d++) {
var g = r[d][0];
if (g != null) {
var y = g._private.data.id;
(!a || !i.has(y)) && (a && i.set(y, {
index: this.length,
ele: g
}), this[this.length] = g, this.length++);
}
}
this._private = {
eles: this,
cy: e,
get map() {
return this.lazyMap == null && this.rebuildMap(), this.lazyMap;
},
set map(b) {
this.lazyMap = b;
},
rebuildMap: function() {
for (var m = this.lazyMap = new Zt(), E = this.eles, T = 0; T < E.length; T++) {
var S = E[T];
m.set(S.id(), {
index: T,
ele: S
});
}
}
}, a && (this._private.map = i), s && !n && this.restore();
}, qe = Gn.prototype = vt.prototype = Object.create(Array.prototype);
qe.instanceString = function() {
return "collection";
};
qe.spawn = function(t, e) {
return new vt(this.cy(), t, e);
};
qe.spawnSelf = function() {
return this.spawn(this);
};
qe.cy = function() {
return this._private.cy;
};
qe.renderer = function() {
return this._private.cy.renderer();
};
qe.element = function() {
return this[0];
};
qe.collection = function() {
return gf(this) ? this : new vt(this._private.cy, [this]);
};
qe.unique = function() {
return new vt(this._private.cy, this, !0);
};
qe.hasElementWithId = function(t) {
return t = "" + t, this._private.map.has(t);
};
qe.getElementById = function(t) {
t = "" + t;
var e = this._private.cy, r = this._private.map.get(t);
return r ? r.ele : new vt(e);
};
qe.$id = qe.getElementById;
qe.poolIndex = function() {
var t = this._private.cy, e = t._private.elements, r = this[0]._private.data.id;
return e._private.map.get(r).index;
};
qe.indexOf = function(t) {
var e = t[0]._private.data.id;
return this._private.map.get(e).index;
};
qe.indexOfId = function(t) {
return t = "" + t, this._private.map.get(t).index;
};
qe.json = function(t) {
var e = this.element(), r = this.cy();
if (e == null && t)
return this;
if (e != null) {
var a = e._private;
if (Oe(t)) {
if (r.startBatch(), t.data) {
e.data(t.data);
var n = a.data;
if (e.isEdge()) {
var i = !1, s = {}, o = t.data.source, u = t.data.target;
o != null && o != n.source && (s.source = "" + o, i = !0), u != null && u != n.target && (s.target = "" + u, i = !0), i && (e = e.move(s));
} else {
var l = "parent" in t.data, f = t.data.parent;
l && (f != null || n.parent != null) && f != n.parent && (f === void 0 && (f = null), f != null && (f = "" + f), e = e.move({
parent: f
}));
}
}
t.position && e.position(t.position);
var c = function(p, g, y) {
var b = t[p];
b != null && b !== a[p] && (b ? e[g]() : e[y]());
};
return c("removed", "remove", "restore"), c("selected", "select", "unselect"), c("selectable", "selectify", "unselectify"), c("locked", "lock", "unlock"), c("grabbable", "grabify", "ungrabify"), c("pannable", "panify", "unpanify"), t.classes != null && e.classes(t.classes), r.endBatch(), this;
} else if (t === void 0) {
var v = {
data: Ut(a.data),
position: Ut(a.position),
group: a.group,
removed: a.removed,
selected: a.selected,
selectable: a.selectable,
locked: a.locked,
grabbable: a.grabbable,
pannable: a.pannable,
classes: null
};
v.classes = "";
var h = 0;
return a.classes.forEach(function(d) {
return v.classes += h++ === 0 ? d : " " + d;
}), v;
}
}
};
qe.jsons = function() {
for (var t = [], e = 0; e < this.length; e++) {
var r = this[e], a = r.json();
t.push(a);
}
return t;
};
qe.clone = function() {
for (var t = this.cy(), e = [], r = 0; r < this.length; r++) {
var a = this[r], n = a.json(), i = new Gn(t, n, !1);
e.push(i);
}
return new vt(t, e);
};
qe.copy = qe.clone;
qe.restore = function() {
for (var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !0, e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, r = this, a = r.cy(), n = a._private, i = [], s = [], o, u = 0, l = r.length; u < l; u++) {
var f = r[u];
e && !f.removed() || (f.isNode() ? i.push(f) : s.push(f));
}
o = i.concat(s);
var c, v = function() {
o.splice(c, 1), c--;
};
for (c = 0; c < o.length; c++) {
var h = o[c], d = h._private, p = d.data;
if (h.clearTraversalCache(), !(!e && !d.removed)) {
if (p.id === void 0)
p.id = Rf();
else if (ne(p.id))
p.id = "" + p.id;
else if (fr(p.id) || !ge(p.id)) {
He("Can not create element with invalid string ID `" + p.id + "`"), v();
continue;
} else if (a.hasElementWithId(p.id)) {
He("Can not create second element with ID `" + p.id + "`"), v();
continue;
}
}
var g = p.id;
if (h.isNode()) {
var y = d.position;
y.x == null && (y.x = 0), y.y == null && (y.y = 0);
}
if (h.isEdge()) {
for (var b = h, m = ["source", "target"], E = m.length, T = !1, S = 0; S < E; S++) {
var w = m[S], x = p[w];
ne(x) && (x = p[w] = "" + p[w]), x == null || x === "" ? (He("Can not create edge `" + g + "` with unspecified " + w), T = !0) : a.hasElementWithId(x) || (He("Can not create edge `" + g + "` with nonexistant " + w + " `" + x + "`"), T = !0);
}
if (T) {
v();
continue;
}
var C = a.getElementById(p.source), D = a.getElementById(p.target);
C.same(D) ? C._private.edges.push(b) : (C._private.edges.push(b), D._private.edges.push(b)), b._private.source = C, b._private.target = D;
}
d.map = new Zt(), d.map.set(g, {
ele: h,
index: 0
}), d.removed = !1, e && a.addToPool(h);
}
for (var A = 0; A < i.length; A++) {
var L = i[A], R = L._private.data;
ne(R.parent) && (R.parent = "" + R.parent);
var I = R.parent, M = I != null;
if (M || L._private.parent) {
var N = L._private.parent ? a.collection().merge(L._private.parent) : a.getElementById(I);
if (N.empty())
R.parent = void 0;
else if (N[0].removed())
Ge("Node added with missing parent, reference to parent removed"), R.parent = void 0, L._private.parent = null;
else {
for (var O = !1, k = N; !k.empty(); ) {
if (L.same(k)) {
O = !0, R.parent = void 0;
break;
}
k = k.parent();
}
O || (N[0]._private.children.push(L), L._private.parent = N[0], n.hasCompoundNodes = !0);
}
}
}
if (o.length > 0) {
for (var B = o.length === r.length ? r : new vt(a, o), _ = 0; _ < B.length; _++) {
var F = B[_];
F.isNode() || (F.parallelEdges().clearTraversalCache(), F.source().clearTraversalCache(), F.target().clearTraversalCache());
}
var G;
n.hasCompoundNodes ? G = a.collection().merge(B).merge(B.connectedNodes()).merge(B.parent()) : G = B, G.dirtyCompoundBoundsCache().dirtyBoundingBoxCache().updateStyle(t), t ? B.emitAndNotify("add") : e && B.emit("add");
}
return r;
};
qe.removed = function() {
var t = this[0];
return t && t._private.removed;
};
qe.inside = function() {
var t = this[0];
return t && !t._private.removed;
};
qe.remove = function() {
var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !0, e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, r = this, a = [], n = {}, i = r._private.cy;
function s(I) {
for (var M = I._private.edges, N = 0; N < M.length; N++)
u(M[N]);
}
function o(I) {
for (var M = I._private.children, N = 0; N < M.length; N++)
u(M[N]);
}
function u(I) {
var M = n[I.id()];
e && I.removed() || M || (n[I.id()] = !0, I.isNode() ? (a.push(I), s(I), o(I)) : a.unshift(I));
}
for (var l = 0, f = r.length; l < f; l++) {
var c = r[l];
u(c);
}
function v(I, M) {
var N = I._private.edges;
cr(N, M), I.clearTraversalCache();
}
function h(I) {
I.clearTraversalCache();
}
var d = [];
d.ids = {};
function p(I, M) {
M = M[0], I = I[0];
var N = I._private.children, O = I.id();
cr(N, M), M._private.parent = null, d.ids[O] || (d.ids[O] = !0, d.push(I));
}
r.dirtyCompoundBoundsCache(), e && i.removeFromPool(a);
for (var g = 0; g < a.length; g++) {
var y = a[g];
if (y.isEdge()) {
var b = y.source()[0], m = y.target()[0];
v(b, y), v(m, y);
for (var E = y.parallelEdges(), T = 0; T < E.length; T++) {
var S = E[T];
h(S), S.isBundledBezier() && S.dirtyBoundingBoxCache();
}
} else {
var w = y.parent();
w.length !== 0 && p(w, y);
}
e && (y._private.removed = !0);
}
var x = i._private.elements;
i._private.hasCompoundNodes = !1;
for (var C = 0; C < x.length; C++) {
var D = x[C];
if (D.isParent()) {
i._private.hasCompoundNodes = !0;
break;
}
}
var A = new vt(this.cy(), a);
A.size() > 0 && (t ? A.emitAndNotify("remove") : e && A.emit("remove"));
for (var L = 0; L < d.length; L++) {
var R = d[L];
(!e || !R.removed()) && R.updateStyle();
}
return A;
};
qe.move = function(t) {
var e = this._private.cy, r = this, a = !1, n = !1, i = function(d) {
return d == null ? d : "" + d;
};
if (t.source !== void 0 || t.target !== void 0) {
var s = i(t.source), o = i(t.target), u = s != null && e.hasElementWithId(s), l = o != null && e.hasElementWithId(o);
(u || l) && (e.batch(function() {
r.remove(a, n), r.emitAndNotify("moveout");
for (var h = 0; h < r.length; h++) {
var d = r[h], p = d._private.data;
d.isEdge() && (u && (p.source = s), l && (p.target = o));
}
r.restore(a, n);
}), r.emitAndNotify("move"));
} else if (t.parent !== void 0) {
var f = i(t.parent), c = f === null || e.hasElementWithId(f);
if (c) {
var v = f === null ? void 0 : f;
e.batch(function() {
var h = r.remove(a, n);
h.emitAndNotify("moveout");
for (var d = 0; d < r.length; d++) {
var p = r[d], g = p._private.data;
p.isNode() && (g.parent = v);
}
h.restore(a, n);
}), r.emitAndNotify("move");
}
}
return this;
};
[Vf, Jg, hn, ur, aa, dp, Xn, Ip, vc, hc, Np, In, dn, ct, lr, pt].forEach(function(t) {
be(qe, t);
});
var Up = {
add: function(e) {
var r, a = this;
if (Lt(e)) {
var n = e;
if (n._private.cy === a)
r = n.restore();
else {
for (var i = [], s = 0; s < n.length; s++) {
var o = n[s];
i.push(o.json());
}
r = new vt(a, i);
}
} else if (Ve(e)) {
var u = e;
r = new vt(a, u);
} else if (Oe(e) && (Ve(e.nodes) || Ve(e.edges))) {
for (var l = e, f = [], c = ["nodes", "edges"], v = 0, h = c.length; v < h; v++) {
var d = c[v], p = l[d];
if (Ve(p))
for (var g = 0, y = p.length; g < y; g++) {
var b = be({
group: d
}, p[g]);
f.push(b);
}
}
r = new vt(a, f);
} else {
var m = e;
r = new Gn(a, m).collection();
}
return r;
},
remove: function(e) {
if (!Lt(e)) {
if (ge(e)) {
var r = e;
e = this.$(r);
}
}
return e.remove();
}
};
/*! Bezier curve function generator. Copyright Gaetan Renaudeau. MIT License: http://en.wikipedia.org/wiki/MIT_License */
function qp(t, e, r, a) {
var n = 4, i = 1e-3, s = 1e-7, o = 10, u = 11, l = 1 / (u - 1), f = typeof Float32Array < "u";
if (arguments.length !== 4)
return !1;
for (var c = 0; c < 4; ++c)
if (typeof arguments[c] != "number" || isNaN(arguments[c]) || !isFinite(arguments[c]))
return !1;
t = Math.min(t, 1), r = Math.min(r, 1), t = Math.max(t, 0), r = Math.max(r, 0);
var v = f ? new Float32Array(u) : new Array(u);
function h(D, A) {
return 1 - 3 * A + 3 * D;
}
function d(D, A) {
return 3 * A - 6 * D;
}
function p(D) {
return 3 * D;
}
function g(D, A, L) {
return ((h(A, L) * D + d(A, L)) * D + p(A)) * D;
}
function y(D, A, L) {
return 3 * h(A, L) * D * D + 2 * d(A, L) * D + p(A);
}
function b(D, A) {
for (var L = 0; L < n; ++L) {
var R = y(A, t, r);
if (R === 0)
return A;
var I = g(A, t, r) - D;
A -= I / R;
}
return A;
}
function m() {
for (var D = 0; D < u; ++D)
v[D] = g(D * l, t, r);
}
function E(D, A, L) {
var R, I, M = 0;
do
I = A + (L - A) / 2, R = g(I, t, r) - D, R > 0 ? L = I : A = I;
while (Math.abs(R) > s && ++M < o);
return I;
}
function T(D) {
for (var A = 0, L = 1, R = u - 1; L !== R && v[L] <= D; ++L)
A += l;
--L;
var I = (D - v[L]) / (v[L + 1] - v[L]), M = A + I * l, N = y(M, t, r);
return N >= i ? b(D, M) : N === 0 ? M : E(D, A, A + l);
}
var S = !1;
function w() {
S = !0, (t !== e || r !== a) && m();
}
var x = function(A) {
return S || w(), t === e && r === a ? A : A === 0 ? 0 : A === 1 ? 1 : g(T(A), e, a);
};
x.getControlPoints = function() {
return [{
x: t,
y: e
}, {
x: r,
y: a
}];
};
var C = "generateBezier(" + [t, e, r, a] + ")";
return x.toString = function() {
return C;
}, x;
}
/*! Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */
var Yp = function() {
function t(a) {
return -a.tension * a.x - a.friction * a.v;
}
function e(a, n, i) {
var s = {
x: a.x + i.dx * n,
v: a.v + i.dv * n,
tension: a.tension,
friction: a.friction
};
return {
dx: s.v,
dv: t(s)
};
}
function r(a, n) {
var i = {
dx: a.v,
dv: t(a)
}, s = e(a, n * 0.5, i), o = e(a, n * 0.5, s), u = e(a, n, o), l = 1 / 6 * (i.dx + 2 * (s.dx + o.dx) + u.dx), f = 1 / 6 * (i.dv + 2 * (s.dv + o.dv) + u.dv);
return a.x = a.x + l * n, a.v = a.v + f * n, a;
}
return function a(n, i, s) {
var o = {
x: -1,
v: 0,
tension: null,
friction: null
}, u = [0], l = 0, f = 1 / 1e4, c = 16 / 1e3, v, h, d;
for (n = parseFloat(n) || 500, i = parseFloat(i) || 20, s = s || null, o.tension = n, o.friction = i, v = s !== null, v ? (l = a(n, i), h = l / s * c) : h = c; d = r(d || o, h), u.push(1 + d.x), l += 16, Math.abs(d.x) > f && Math.abs(d.v) > f; )
;
return v ? function(p) {
return u[p * (u.length - 1) | 0];
} : l;
};
}(), Ue = function(e, r, a, n) {
var i = qp(e, r, a, n);
return function(s, o, u) {
return s + (o - s) * i(u);
};
}, gn = {
linear: function(e, r, a) {
return e + (r - e) * a;
},
// default easings
ease: Ue(0.25, 0.1, 0.25, 1),
"ease-in": Ue(0.42, 0, 1, 1),
"ease-out": Ue(0, 0, 0.58, 1),
"ease-in-out": Ue(0.42, 0, 0.58, 1),
// sine
"ease-in-sine": Ue(0.47, 0, 0.745, 0.715),
"ease-out-sine": Ue(0.39, 0.575, 0.565, 1),
"ease-in-out-sine": Ue(0.445, 0.05, 0.55, 0.95),
// quad
"ease-in-quad": Ue(0.55, 0.085, 0.68, 0.53),
"ease-out-quad": Ue(0.25, 0.46, 0.45, 0.94),
"ease-in-out-quad": Ue(0.455, 0.03, 0.515, 0.955),
// cubic
"ease-in-cubic": Ue(0.55, 0.055, 0.675, 0.19),
"ease-out-cubic": Ue(0.215, 0.61, 0.355, 1),
"ease-in-out-cubic": Ue(0.645, 0.045, 0.355, 1),
// quart
"ease-in-quart": Ue(0.895, 0.03, 0.685, 0.22),
"ease-out-quart": Ue(0.165, 0.84, 0.44, 1),
"ease-in-out-quart": Ue(0.77, 0, 0.175, 1),
// quint
"ease-in-quint": Ue(0.755, 0.05, 0.855, 0.06),
"ease-out-quint": Ue(0.23, 1, 0.32, 1),
"ease-in-out-quint": Ue(0.86, 0, 0.07, 1),
// expo
"ease-in-expo": Ue(0.95, 0.05, 0.795, 0.035),
"ease-out-expo": Ue(0.19, 1, 0.22, 1),
"ease-in-out-expo": Ue(1, 0, 0, 1),
// circ
"ease-in-circ": Ue(0.6, 0.04, 0.98, 0.335),
"ease-out-circ": Ue(0.075, 0.82, 0.165, 1),
"ease-in-out-circ": Ue(0.785, 0.135, 0.15, 0.86),
// user param easings...
spring: function(e, r, a) {
if (a === 0)
return gn.linear;
var n = Yp(e, r, a);
return function(i, s, o) {
return i + (s - i) * n(o);
};
},
"cubic-bezier": Ue
};
function Ml(t, e, r, a, n) {
if (a === 1 || e === r)
return r;
var i = n(e, r, a);
return t == null || ((t.roundValue || t.color) && (i = Math.round(i)), t.min !== void 0 && (i = Math.max(i, t.min)), t.max !== void 0 && (i = Math.min(i, t.max))), i;
}
function Ol(t, e) {
return t.pfValue != null || t.value != null ? t.pfValue != null && (e == null || e.type.units !== "%") ? t.pfValue : t.value : t;
}
function Vr(t, e, r, a, n) {
var i = n != null ? n.type : null;
r < 0 ? r = 0 : r > 1 && (r = 1);
var s = Ol(t, n), o = Ol(e, n);
if (ne(s) && ne(o))
return Ml(i, s, o, r, a);
if (Ve(s) && Ve(o)) {
for (var u = [], l = 0; l < o.length; l++) {
var f = s[l], c = o[l];
if (f != null && c != null) {
var v = Ml(i, f, c, r, a);
u.push(v);
} else
u.push(c);
}
return u;
}
}
function Hp(t, e, r, a) {
var n = !a, i = t._private, s = e._private, o = s.easing, u = s.startTime, l = a ? t : t.cy(), f = l.style();
if (!s.easingImpl)
if (o == null)
s.easingImpl = gn.linear;
else {
var c;
if (ge(o)) {
var v = f.parse("transition-timing-function", o);
c = v.value;
} else
c = o;
var h, d;
ge(c) ? (h = c, d = []) : (h = c[1], d = c.slice(2).map(function(B) {
return +B;
})), d.length > 0 ? (h === "spring" && d.push(s.duration), s.easingImpl = gn[h].apply(null, d)) : s.easingImpl = gn[h];
}
var p = s.easingImpl, g;
if (s.duration === 0 ? g = 1 : g = (r - u) / s.duration, s.applying && (g = s.progress), g < 0 ? g = 0 : g > 1 && (g = 1), s.delay == null) {
var y = s.startPosition, b = s.position;
if (b && n && !t.locked()) {
var m = {};
pa(y.x, b.x) && (m.x = Vr(y.x, b.x, g, p)), pa(y.y, b.y) && (m.y = Vr(y.y, b.y, g, p)), t.position(m);
}
var E = s.startPan, T = s.pan, S = i.pan, w = T != null && a;
w && (pa(E.x, T.x) && (S.x = Vr(E.x, T.x, g, p)), pa(E.y, T.y) && (S.y = Vr(E.y, T.y, g, p)), t.emit("pan"));
var x = s.startZoom, C = s.zoom, D = C != null && a;
D && (pa(x, C) && (i.zoom = Ra(i.minZoom, Vr(x, C, g, p), i.maxZoom)), t.emit("zoom")), (w || D) && t.emit("viewport");
var A = s.style;
if (A && A.length > 0 && n) {
for (var L = 0; L < A.length; L++) {
var R = A[L], I = R.name, M = R, N = s.startStyle[I], O = f.properties[N.name], k = Vr(N, M, g, p, O);
f.overrideBypass(t, I, k);
}
t.emit("style");
}
}
return s.progress = g, g;
}
function pa(t, e) {
return t == null || e == null ? !1 : ne(t) && ne(e) ? !0 : !!(t && e);
}
function Xp(t, e, r, a) {
var n = e._private;
n.started = !0, n.startTime = r - n.progress * n.duration;
}
function kl(t, e) {
var r = e._private.aniEles, a = [];
function n(f, c) {
var v = f._private, h = v.animation.current, d = v.animation.queue, p = !1;
if (h.length === 0) {
var g = d.shift();
g && h.push(g);
}
for (var y = function(S) {
for (var w = S.length - 1; w >= 0; w--) {
var x = S[w];
x();
}
S.splice(0, S.length);
}, b = h.length - 1; b >= 0; b--) {
var m = h[b], E = m._private;
if (E.stopped) {
h.splice(b, 1), E.hooked = !1, E.playing = !1, E.started = !1, y(E.frames);
continue;
}
!E.playing && !E.applying || (E.playing && E.applying && (E.applying = !1), E.started || Xp(f, m, t), Hp(f, m, t, c), E.applying && (E.applying = !1), y(E.frames), E.step != null && E.step(t), m.completed() && (h.splice(b, 1), E.hooked = !1, E.playing = !1, E.started = !1, y(E.completes)), p = !0);
}
return !c && h.length === 0 && d.length === 0 && a.push(f), p;
}
for (var i = !1, s = 0; s < r.length; s++) {
var o = r[s], u = n(o);
i = i || u;
}
var l = n(e, !0);
(i || l) && (r.length > 0 ? e.notify("draw", r) : e.notify("draw")), r.unmerge(a), e.emit("step");
}
var $p = {
// pull in animation functions
animate: _e.animate(),
animation: _e.animation(),
animated: _e.animated(),
clearQueue: _e.clearQueue(),
delay: _e.delay(),
delayAnimation: _e.delayAnimation(),
stop: _e.stop(),
addToAnimationPool: function(e) {
var r = this;
r.styleEnabled() && r._private.aniEles.merge(e);
},
stopAnimationLoop: function() {
this._private.animationsRunning = !1;
},
startAnimationLoop: function() {
var e = this;
if (e._private.animationsRunning = !0, !e.styleEnabled())
return;
function r() {
e._private.animationsRunning && Dn(function(i) {
kl(i, e), r();
});
}
var a = e.renderer();
a && a.beforeRender ? a.beforeRender(function(i, s) {
kl(s, e);
}, a.beforeRenderPriorities.animations) : r();
}
}, Wp = {
qualifierCompare: function(e, r) {
return e == null || r == null ? e == null && r == null : e.sameText(r);
},
eventMatches: function(e, r, a) {
var n = r.qualifier;
return n != null ? e !== a.target && Fa(a.target) && n.matches(a.target) : !0;
},
addEventFields: function(e, r) {
r.cy = e, r.target = e;
},
callbackContext: function(e, r, a) {
return r.qualifier != null ? a.target : e;
}
}, sn = function(e) {
return ge(e) ? new hr(e) : e;
}, pc = {
createEmitter: function() {
var e = this._private;
return e.emitter || (e.emitter = new $n(Wp, this)), this;
},
emitter: function() {
return this._private.emitter;
},
on: function(e, r, a) {
return this.emitter().on(e, sn(r), a), this;
},
removeListener: function(e, r, a) {
return this.emitter().removeListener(e, sn(r), a), this;
},
removeAllListeners: function() {
return this.emitter().removeAllListeners(), this;
},
one: function(e, r, a) {
return this.emitter().one(e, sn(r), a), this;
},
once: function(e, r, a) {
return this.emitter().one(e, sn(r), a), this;
},
emit: function(e, r) {
return this.emitter().emit(e, r), this;
},
emitAndNotify: function(e, r) {
return this.emit(e), this.notify(e, r), this;
}
};
_e.eventAliasesOn(pc);
var Ys = {
png: function(e) {
var r = this._private.renderer;
return e = e || {}, r.png(e);
},
jpg: function(e) {
var r = this._private.renderer;
return e = e || {}, e.bg = e.bg || "#fff", r.jpg(e);
}
};
Ys.jpeg = Ys.jpg;
var pn = {
layout: function(e) {
var r = this;
if (e == null) {
He("Layout options must be specified to make a layout");
return;
}
if (e.name == null) {
He("A `name` must be specified to make a layout");
return;
}
var a = e.name, n = r.extension("layout", a);
if (n == null) {
He("No such layout `" + a + "` found. Did you forget to import it and `cytoscape.use()` it?");
return;
}
var i;
ge(e.eles) ? i = r.$(e.eles) : i = e.eles != null ? e.eles : r.$();
var s = new n(be({}, e, {
cy: r,
eles: i
}));
return s;
}
};
pn.createLayout = pn.makeLayout = pn.layout;
var Kp = {
notify: function(e, r) {
var a = this._private;
if (this.batching()) {
a.batchNotifications = a.batchNotifications || {};
var n = a.batchNotifications[e] = a.batchNotifications[e] || this.collection();
r != null && n.merge(r);
return;
}
if (a.notificationsEnabled) {
var i = this.renderer();
this.destroyed() || !i || i.notify(e, r);
}
},
notifications: function(e) {
var r = this._private;
return e === void 0 ? r.notificationsEnabled : (r.notificationsEnabled = !!e, this);
},
noNotifications: function(e) {
this.notifications(!1), e(), this.notifications(!0);
},
batching: function() {
return this._private.batchCount > 0;
},
startBatch: function() {
var e = this._private;
return e.batchCount == null && (e.batchCount = 0), e.batchCount === 0 && (e.batchStyleEles = this.collection(), e.batchNotifications = {}), e.batchCount++, this;
},
endBatch: function() {
var e = this._private;
if (e.batchCount === 0)
return this;
if (e.batchCount--, e.batchCount === 0) {
e.batchStyleEles.updateStyle();
var r = this.renderer();
Object.keys(e.batchNotifications).forEach(function(a) {
var n = e.batchNotifications[a];
n.empty() ? r.notify(a) : r.notify(a, n);
});
}
return this;
},
batch: function(e) {
return this.startBatch(), e(), this.endBatch(), this;
},
// for backwards compatibility
batchData: function(e) {
var r = this;
return this.batch(function() {
for (var a = Object.keys(e), n = 0; n < a.length; n++) {
var i = a[n], s = e[i], o = r.getElementById(i);
o.data(s);
}
});
}
}, Zp = ht({
hideEdgesOnViewport: !1,
textureOnViewport: !1,
motionBlur: !1,
motionBlurOpacity: 0.05,
pixelRatio: void 0,
desktopTapThreshold: 4,
touchTapThreshold: 8,
wheelSensitivity: 1,
debug: !1,
showFps: !1,
// webgl options
webgl: !1,
webglDebug: !1,
webglDebugShowAtlases: !1,
// defaults good for mobile
webglTexSize: 2048,
webglTexRows: 36,
webglTexRowsNodes: 18,
webglBatchSize: 2048,
webglTexPerBatch: 14,
webglBgColor: [255, 255, 255]
}), Hs = {
renderTo: function(e, r, a, n) {
var i = this._private.renderer;
return i.renderTo(e, r, a, n), this;
},
renderer: function() {
return this._private.renderer;
},
forceRender: function() {
return this.notify("draw"), this;
},
resize: function() {
return this.invalidateSize(), this.emitAndNotify("resize"), this;
},
initRenderer: function(e) {
var r = this, a = r.extension("renderer", e.name);
if (a == null) {
He("Can not initialise: No such renderer `".concat(e.name, "` found. Did you forget to import it and `cytoscape.use()` it?"));
return;
}
e.wheelSensitivity !== void 0 && Ge("You have set a custom wheel sensitivity. This will make your app zoom unnaturally when using mainstream mice. You should change this value from the default only if you can guarantee that all your users will use the same hardware and OS configuration as your current machine.");
var n = Zp(e);
n.cy = r, r._private.renderer = new a(n), this.notify("init");
},
destroyRenderer: function() {
var e = this;
e.notify("destroy");
var r = e.container();
if (r)
for (r._cyreg = null; r.childNodes.length > 0; )
r.removeChild(r.childNodes[0]);
e._private.renderer = null, e.mutableElements().forEach(function(a) {
var n = a._private;
n.rscratch = {}, n.rstyle = {}, n.animation.current = [], n.animation.queue = [];
});
},
onRender: function(e) {
return this.on("render", e);
},
offRender: function(e) {
return this.off("render", e);
}
};
Hs.invalidateDimensions = Hs.resize;
var yn = {
// get a collection
// - empty collection on no args
// - collection of elements in the graph on selector arg
// - guarantee a returned collection when elements or collection specified
collection: function(e, r) {
return ge(e) ? this.$(e) : Lt(e) ? e.collection() : Ve(e) ? (r || (r = {}), new vt(this, e, r.unique, r.removed)) : new vt(this);
},
nodes: function(e) {
var r = this.$(function(a) {
return a.isNode();
});
return e ? r.filter(e) : r;
},
edges: function(e) {
var r = this.$(function(a) {
return a.isEdge();
});
return e ? r.filter(e) : r;
},
// search the graph like jQuery
$: function(e) {
var r = this._private.elements;
return e ? r.filter(e) : r.spawnSelf();
},
mutableElements: function() {
return this._private.elements;
}
};
yn.elements = yn.filter = yn.$;
var lt = {}, Ta = "t", Qp = "f";
lt.apply = function(t) {
for (var e = this, r = e._private, a = r.cy, n = a.collection(), i = 0; i < t.length; i++) {
var s = t[i], o = e.getContextMeta(s);
if (!o.empty) {
var u = e.getContextStyle(o), l = e.applyContextStyle(o, u, s);
s._private.appliedInitStyle ? e.updateTransitions(s, l.diffProps) : s._private.appliedInitStyle = !0;
var f = e.updateStyleHints(s);
f && n.push(s);
}
}
return n;
};
lt.getPropertiesDiff = function(t, e) {
var r = this, a = r._private.propDiffs = r._private.propDiffs || {}, n = t + "-" + e, i = a[n];
if (i)
return i;
for (var s = [], o = {}, u = 0; u < r.length; u++) {
var l = r[u], f = t[u] === Ta, c = e[u] === Ta, v = f !== c, h = l.mappedProperties.length > 0;
if (v || c && h) {
var d = void 0;
v && h || v ? d = l.properties : h && (d = l.mappedProperties);
for (var p = 0; p < d.length; p++) {
for (var g = d[p], y = g.name, b = !1, m = u + 1; m < r.length; m++) {
var E = r[m], T = e[m] === Ta;
if (T && (b = E.properties[g.name] != null, b))
break;
}
!o[y] && !b && (o[y] = !0, s.push(y));
}
}
}
return a[n] = s, s;
};
lt.getContextMeta = function(t) {
for (var e = this, r = "", a, n = t._private.styleCxtKey || "", i = 0; i < e.length; i++) {
var s = e[i], o = s.selector && s.selector.matches(t);
o ? r += Ta : r += Qp;
}
return a = e.getPropertiesDiff(n, r), t._private.styleCxtKey = r, {
key: r,
diffPropNames: a,
empty: a.length === 0
};
};
lt.getContextStyle = function(t) {
var e = t.key, r = this, a = this._private.contextStyles = this._private.contextStyles || {};
if (a[e])
return a[e];
for (var n = {
_private: {
key: e
}
}, i = 0; i < r.length; i++) {
var s = r[i], o = e[i] === Ta;
if (o)
for (var u = 0; u < s.properties.length; u++) {
var l = s.properties[u];
n[l.name] = l;
}
}
return a[e] = n, n;
};
lt.applyContextStyle = function(t, e, r) {
for (var a = this, n = t.diffPropNames, i = {}, s = a.types, o = 0; o < n.length; o++) {
var u = n[o], l = e[u], f = r.pstyle(u);
if (!l)
if (f)
f.bypass ? l = {
name: u,
deleteBypassed: !0
} : l = {
name: u,
delete: !0
};
else
continue;
if (f !== l) {
if (l.mapped === s.fn && f != null && f.mapping != null && f.mapping.value === l.value) {
var c = f.mapping, v = c.fnValue = l.value(r);
if (v === c.prevFnValue)
continue;
}
var h = i[u] = {
prev: f
};
a.applyParsedProperty(r, l), h.next = r.pstyle(u), h.next && h.next.bypass && (h.next = h.next.bypassed);
}
}
return {
diffProps: i
};
};
lt.updateStyleHints = function(t) {
var e = t._private, r = this, a = r.propertyGroupNames, n = r.propertyGroupKeys, i = function(q, Z, re) {
return r.getPropertiesHash(q, Z, re);
}, s = e.styleKey;
if (t.removed())
return !1;
var o = e.group === "nodes", u = t._private.style;
a = Object.keys(u);
for (var l = 0; l < n.length; l++) {
var f = n[l];
e.styleKeys[f] = [Ar, $r];
}
for (var c = function(q, Z) {
return e.styleKeys[Z][0] = Sa(q, e.styleKeys[Z][0]);
}, v = function(q, Z) {
return e.styleKeys[Z][1] = Aa(q, e.styleKeys[Z][1]);
}, h = function(q, Z) {
c(q, Z), v(q, Z);
}, d = function(q, Z) {
for (var re = 0; re < q.length; re++) {
var ve = q.charCodeAt(re);
c(ve, Z), v(ve, Z);
}
}, p = 2e9, g = function(q) {
return -128 < q && q < 128 && Math.floor(q) !== q ? p - (q * 1024 | 0) : q;
}, y = 0; y < a.length; y++) {
var b = a[y], m = u[b];
if (m != null) {
var E = this.properties[b], T = E.type, S = E.groupKey, w = void 0;
E.hashOverride != null ? w = E.hashOverride(t, m) : m.pfValue != null && (w = m.pfValue);
var x = E.enums == null ? m.value : null, C = w != null, D = x != null, A = C || D, L = m.units;
if (T.number && A && !T.multiple) {
var R = C ? w : x;
h(g(R), S), !C && L != null && d(L, S);
} else
d(m.strValue, S);
}
}
for (var I = [Ar, $r], M = 0; M < n.length; M++) {
var N = n[M], O = e.styleKeys[N];
I[0] = Sa(O[0], I[0]), I[1] = Aa(O[1], I[1]);
}
e.styleKey = hh(I[0], I[1]);
var k = e.styleKeys;
e.labelDimsKey = rr(k.labelDimensions);
var B = i(t, ["label"], k.labelDimensions);
if (e.labelKey = rr(B), e.labelStyleKey = rr(Qa(k.commonLabel, B)), !o) {
var _ = i(t, ["source-label"], k.labelDimensions);
e.sourceLabelKey = rr(_), e.sourceLabelStyleKey = rr(Qa(k.commonLabel, _));
var F = i(t, ["target-label"], k.labelDimensions);
e.targetLabelKey = rr(F), e.targetLabelStyleKey = rr(Qa(k.commonLabel, F));
}
if (o) {
var G = e.styleKeys, H = G.nodeBody, Y = G.nodeBorder, X = G.nodeOutline, W = G.backgroundImage, ee = G.compound, ae = G.pie, J = G.stripe, z = [H, Y, X, W, ee, ae, J].filter(function(V) {
return V != null;
}).reduce(Qa, [Ar, $r]);
e.nodeKey = rr(z), e.hasPie = ae != null && ae[0] !== Ar && ae[1] !== $r, e.hasStripe = J != null && J[0] !== Ar && J[1] !== $r;
}
return s !== e.styleKey;
};
lt.clearStyleHints = function(t) {
var e = t._private;
e.styleCxtKey = "", e.styleKeys = {}, e.styleKey = null, e.labelKey = null, e.labelStyleKey = null, e.sourceLabelKey = null, e.sourceLabelStyleKey = null, e.targetLabelKey = null, e.targetLabelStyleKey = null, e.nodeKey = null, e.hasPie = null, e.hasStripe = null;
};
lt.applyParsedProperty = function(t, e) {
var r = this, a = e, n = t._private.style, i, s = r.types, o = r.properties[a.name].type, u = a.bypass, l = n[a.name], f = l && l.bypass, c = t._private, v = "mapping", h = function(H) {
return H == null ? null : H.pfValue != null ? H.pfValue : H.value;
}, d = function() {
var H = h(l), Y = h(a);
r.checkTriggers(t, a.name, H, Y);
};
if (e.name === "curve-style" && t.isEdge() && // loops must be bundled beziers
(e.value !== "bezier" && t.isLoop() || // edges connected to compound nodes can not be haystacks
e.value === "haystack" && (t.source().isParent() || t.target().isParent())) && (a = e = this.parse(e.name, "bezier", u)), a.delete)
return n[a.name] = void 0, d(), !0;
if (a.deleteBypassed)
return l ? l.bypass ? (l.bypassed = void 0, d(), !0) : !1 : (d(), !0);
if (a.deleteBypass)
return l ? l.bypass ? (n[a.name] = l.bypassed, d(), !0) : !1 : (d(), !0);
var p = function() {
Ge("Do not assign mappings to elements without corresponding data (i.e. ele `" + t.id() + "` has no mapping for property `" + a.name + "` with data field `" + a.field + "`); try a `[" + a.field + "]` selector to limit scope to elements with `" + a.field + "` defined");
};
switch (a.mapped) {
case s.mapData: {
for (var g = a.field.split("."), y = c.data, b = 0; b < g.length && y; b++) {
var m = g[b];
y = y[m];
}
if (y == null)
return p(), !1;
var E;
if (ne(y)) {
var T = a.fieldMax - a.fieldMin;
T === 0 ? E = 0 : E = (y - a.fieldMin) / T;
} else
return Ge("Do not use continuous mappers without specifying numeric data (i.e. `" + a.field + ": " + y + "` for `" + t.id() + "` is non-numeric)"), !1;
if (E < 0 ? E = 0 : E > 1 && (E = 1), o.color) {
var S = a.valueMin[0], w = a.valueMax[0], x = a.valueMin[1], C = a.valueMax[1], D = a.valueMin[2], A = a.valueMax[2], L = a.valueMin[3] == null ? 1 : a.valueMin[3], R = a.valueMax[3] == null ? 1 : a.valueMax[3], I = [Math.round(S + (w - S) * E), Math.round(x + (C - x) * E), Math.round(D + (A - D) * E), Math.round(L + (R - L) * E)];
i = {
// colours are simple, so just create the flat property instead of expensive string parsing
bypass: a.bypass,
// we're a bypass if the mapping property is a bypass
name: a.name,
value: I,
strValue: "rgb(" + I[0] + ", " + I[1] + ", " + I[2] + ")"
};
} else if (o.number) {
var M = a.valueMin + (a.valueMax - a.valueMin) * E;
i = this.parse(a.name, M, a.bypass, v);
} else
return !1;
if (!i)
return p(), !1;
i.mapping = a, a = i;
break;
}
case s.data: {
for (var N = a.field.split("."), O = c.data, k = 0; k < N.length && O; k++) {
var B = N[k];
O = O[B];
}
if (O != null && (i = this.parse(a.name, O, a.bypass, v)), !i)
return p(), !1;
i.mapping = a, a = i;
break;
}
case s.fn: {
var _ = a.value, F = a.fnValue != null ? a.fnValue : _(t);
if (a.prevFnValue = F, F == null)
return Ge("Custom function mappers may not return null (i.e. `" + a.name + "` for ele `" + t.id() + "` is null)"), !1;
if (i = this.parse(a.name, F, a.bypass, v), !i)
return Ge("Custom function mappers may not return invalid values for the property type (i.e. `" + a.name + "` for ele `" + t.id() + "` is invalid)"), !1;
i.mapping = Ut(a), a = i;
break;
}
case void 0:
break;
default:
return !1;
}
return u ? (f ? a.bypassed = l.bypassed : a.bypassed = l, n[a.name] = a) : f ? l.bypassed = a : n[a.name] = a, d(), !0;
};
lt.cleanElements = function(t, e) {
for (var r = 0; r < t.length; r++) {
var a = t[r];
if (this.clearStyleHints(a), a.dirtyCompoundBoundsCache(), a.dirtyBoundingBoxCache(), !e)
a._private.style = {};
else
for (var n = a._private.style, i = Object.keys(n), s = 0; s < i.length; s++) {
var o = i[s], u = n[o];
u != null && (u.bypass ? u.bypassed = null : n[o] = null);
}
}
};
lt.update = function() {
var t = this._private.cy, e = t.mutableElements();
e.updateStyle();
};
lt.updateTransitions = function(t, e) {
var r = this, a = t._private, n = t.pstyle("transition-property").value, i = t.pstyle("transition-duration").pfValue, s = t.pstyle("transition-delay").pfValue;
if (n.length > 0 && i > 0) {
for (var o = {}, u = !1, l = 0; l < n.length; l++) {
var f = n[l], c = t.pstyle(f), v = e[f];
if (v) {
var h = v.prev, d = h, p = v.next != null ? v.next : c, g = !1, y = void 0, b = 1e-6;
d && (ne(d.pfValue) && ne(p.pfValue) ? (g = p.pfValue - d.pfValue, y = d.pfValue + b * g) : ne(d.value) && ne(p.value) ? (g = p.value - d.value, y = d.value + b * g) : Ve(d.value) && Ve(p.value) && (g = d.value[0] !== p.value[0] || d.value[1] !== p.value[1] || d.value[2] !== p.value[2], y = d.strValue), g && (o[f] = p.strValue, this.applyBypass(t, f, y), u = !0));
}
}
if (!u)
return;
a.transitioning = !0, new ia(function(m) {
s > 0 ? t.delayAnimation(s).play().promise().then(m) : m();
}).then(function() {
return t.animation({
style: o,
duration: i,
easing: t.pstyle("transition-timing-function").value,
queue: !1
}).play().promise();
}).then(function() {
r.removeBypasses(t, n), t.emitAndNotify("style"), a.transitioning = !1;
});
} else
a.transitioning && (this.removeBypasses(t, n), t.emitAndNotify("style"), a.transitioning = !1);
};
lt.checkTrigger = function(t, e, r, a, n, i) {
var s = this.properties[e], o = n(s);
t.removed() || o != null && o(r, a, t) && i(s);
};
lt.checkZOrderTrigger = function(t, e, r, a) {
var n = this;
this.checkTrigger(t, e, r, a, function(i) {
return i.triggersZOrder;
}, function() {
n._private.cy.notify("zorder", t);
});
};
lt.checkBoundsTrigger = function(t, e, r, a) {
this.checkTrigger(t, e, r, a, function(n) {
return n.triggersBounds;
}, function(n) {
t.dirtyCompoundBoundsCache(), t.dirtyBoundingBoxCache();
});
};
lt.checkConnectedEdgesBoundsTrigger = function(t, e, r, a) {
this.checkTrigger(t, e, r, a, function(n) {
return n.triggersBoundsOfConnectedEdges;
}, function(n) {
t.connectedEdges().forEach(function(i) {
i.dirtyBoundingBoxCache();
});
});
};
lt.checkParallelEdgesBoundsTrigger = function(t, e, r, a) {
this.checkTrigger(t, e, r, a, function(n) {
return n.triggersBoundsOfParallelEdges;
}, function(n) {
t.parallelEdges().forEach(function(i) {
i.dirtyBoundingBoxCache();
});
});
};
lt.checkTriggers = function(t, e, r, a) {
t.dirtyStyleCache(), this.checkZOrderTrigger(t, e, r, a), this.checkBoundsTrigger(t, e, r, a), this.checkConnectedEdgesBoundsTrigger(t, e, r, a), this.checkParallelEdgesBoundsTrigger(t, e, r, a);
};
var Ya = {};
Ya.applyBypass = function(t, e, r, a) {
var n = this, i = [], s = !0;
if (e === "*" || e === "**") {
if (r !== void 0)
for (var o = 0; o < n.properties.length; o++) {
var u = n.properties[o], l = u.name, f = this.parse(l, r, !0);
f && i.push(f);
}
} else if (ge(e)) {
var c = this.parse(e, r, !0);
c && i.push(c);
} else if (Oe(e)) {
var v = e;
a = r;
for (var h = Object.keys(v), d = 0; d < h.length; d++) {
var p = h[d], g = v[p];
if (g === void 0 && (g = v[Fn(p)]), g !== void 0) {
var y = this.parse(p, g, !0);
y && i.push(y);
}
}
} else
return !1;
if (i.length === 0)
return !1;
for (var b = !1, m = 0; m < t.length; m++) {
for (var E = t[m], T = {}, S = void 0, w = 0; w < i.length; w++) {
var x = i[w];
if (a) {
var C = E.pstyle(x.name);
S = T[x.name] = {
prev: C
};
}
b = this.applyParsedProperty(E, Ut(x)) || b, a && (S.next = E.pstyle(x.name));
}
b && this.updateStyleHints(E), a && this.updateTransitions(E, T, s);
}
return b;
};
Ya.overrideBypass = function(t, e, r) {
e = so(e);
for (var a = 0; a < t.length; a++) {
var n = t[a], i = n._private.style[e], s = this.properties[e].type, o = s.color, u = s.mutiple, l = i ? i.pfValue != null ? i.pfValue : i.value : null;
!i || !i.bypass ? this.applyBypass(n, e, r) : (i.value = r, i.pfValue != null && (i.pfValue = r), o ? i.strValue = "rgb(" + r.join(",") + ")" : u ? i.strValue = r.join(" ") : i.strValue = "" + r, this.updateStyleHints(n)), this.checkTriggers(n, e, l, r);
}
};
Ya.removeAllBypasses = function(t, e) {
return this.removeBypasses(t, this.propertyNames, e);
};
Ya.removeBypasses = function(t, e, r) {
for (var a = !0, n = 0; n < t.length; n++) {
for (var i = t[n], s = {}, o = 0; o < e.length; o++) {
var u = e[o], l = this.properties[u], f = i.pstyle(l.name);
if (!(!f || !f.bypass)) {
var c = "", v = this.parse(u, c, !0), h = s[l.name] = {
prev: f
};
this.applyParsedProperty(i, v), h.next = i.pstyle(l.name);
}
}
this.updateStyleHints(i), r && this.updateTransitions(i, s, a);
}
};
var xo = {};
xo.getEmSizeInPixels = function() {
var t = this.containerCss("font-size");
return t != null ? parseFloat(t) : 1;
};
xo.containerCss = function(t) {
var e = this._private.cy, r = e.container(), a = e.window();
if (a && r && a.getComputedStyle)
return a.getComputedStyle(r).getPropertyValue(t);
};
var qt = {};
qt.getRenderedStyle = function(t, e) {
return e ? this.getStylePropertyValue(t, e, !0) : this.getRawStyle(t, !0);
};
qt.getRawStyle = function(t, e) {
var r = this;
if (t = t[0], t) {
for (var a = {}, n = 0; n < r.properties.length; n++) {
var i = r.properties[n], s = r.getStylePropertyValue(t, i.name, e);
s != null && (a[i.name] = s, a[Fn(i.name)] = s);
}
return a;
}
};
qt.getIndexedStyle = function(t, e, r, a) {
var n = t.pstyle(e)[r][a];
return n ?? t.cy().style().getDefaultProperty(e)[r][0];
};
qt.getStylePropertyValue = function(t, e, r) {
var a = this;
if (t = t[0], t) {
var n = a.properties[e];
n.alias && (n = n.pointsTo);
var i = n.type, s = t.pstyle(n.name);
if (s) {
var o = s.value, u = s.units, l = s.strValue;
if (r && i.number && o != null && ne(o)) {
var f = t.cy().zoom(), c = function(g) {
return g * f;
}, v = function(g, y) {
return c(g) + y;
}, h = Ve(o), d = h ? u.every(function(p) {
return p != null;
}) : u != null;
return d ? h ? o.map(function(p, g) {
return v(p, u[g]);
}).join(" ") : v(o, u) : h ? o.map(function(p) {
return ge(p) ? p : "" + c(p);
}).join(" ") : "" + c(o);
} else if (l != null)
return l;
}
return null;
}
};
qt.getAnimationStartStyle = function(t, e) {
for (var r = {}, a = 0; a < e.length; a++) {
var n = e[a], i = n.name, s = t.pstyle(i);
s !== void 0 && (Oe(s) ? s = this.parse(i, s.strValue) : s = this.parse(i, s)), s && (r[i] = s);
}
return r;
};
qt.getPropsList = function(t) {
var e = this, r = [], a = t, n = e.properties;
if (a)
for (var i = Object.keys(a), s = 0; s < i.length; s++) {
var o = i[s], u = a[o], l = n[o] || n[so(o)], f = this.parse(l.name, u);
f && r.push(f);
}
return r;
};
qt.getNonDefaultPropertiesHash = function(t, e, r) {
var a = r.slice(), n, i, s, o, u, l;
for (u = 0; u < e.length; u++)
if (n = e[u], i = t.pstyle(n, !1), i != null)
if (i.pfValue != null)
a[0] = Sa(o, a[0]), a[1] = Aa(o, a[1]);
else
for (s = i.strValue, l = 0; l < s.length; l++)
o = s.charCodeAt(l), a[0] = Sa(o, a[0]), a[1] = Aa(o, a[1]);
return a;
};
qt.getPropertiesHash = qt.getNonDefaultPropertiesHash;
var Zn = {};
Zn.appendFromJson = function(t) {
for (var e = this, r = 0; r < t.length; r++) {
var a = t[r], n = a.selector, i = a.style || a.css, s = Object.keys(i);
e.selector(n);
for (var o = 0; o < s.length; o++) {
var u = s[o], l = i[u];
e.css(u, l);
}
}
return e;
};
Zn.fromJson = function(t) {
var e = this;
return e.resetToDefault(), e.appendFromJson(t), e;
};
Zn.json = function() {
for (var t = [], e = this.defaultLength; e < this.length; e++) {
for (var r = this[e], a = r.selector, n = r.properties, i = {}, s = 0; s < n.length; s++) {
var o = n[s];
i[o.name] = o.strValue;
}
t.push({
selector: a ? a.toString() : "core",
style: i
});
}
return t;
};
var To = {};
To.appendFromString = function(t) {
var e = this, r = this, a = "" + t, n, i, s;
a = a.replace(/[/][*](\s|.)+?[*][/]/g, "");
function o() {
a.length > n.length ? a = a.substr(n.length) : a = "";
}
function u() {
i.length > s.length ? i = i.substr(s.length) : i = "";
}
for (; ; ) {
var l = a.match(/^\s*$/);
if (l)
break;
var f = a.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);
if (!f) {
Ge("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: " + a);
break;
}
n = f[0];
var c = f[1];
if (c !== "core") {
var v = new hr(c);
if (v.invalid) {
Ge("Skipping parsing of block: Invalid selector found in string stylesheet: " + c), o();
continue;
}
}
var h = f[2], d = !1;
i = h;
for (var p = []; ; ) {
var g = i.match(/^\s*$/);
if (g)
break;
var y = i.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/);
if (!y) {
Ge("Skipping parsing of block: Invalid formatting of style property and value definitions found in:" + h), d = !0;
break;
}
s = y[0];
var b = y[1], m = y[2], E = e.properties[b];
if (!E) {
Ge("Skipping property: Invalid property name in: " + s), u();
continue;
}
var T = r.parse(b, m);
if (!T) {
Ge("Skipping property: Invalid property definition in: " + s), u();
continue;
}
p.push({
name: b,
val: m
}), u();
}
if (d) {
o();
break;
}
r.selector(c);
for (var S = 0; S < p.length; S++) {
var w = p[S];
r.css(w.name, w.val);
}
o();
}
return r;
};
To.fromString = function(t) {
var e = this;
return e.resetToDefault(), e.appendFromString(t), e;
};
var Qe = {};
(function() {
var t = at, e = Hv, r = $v, a = Wv, n = Kv, i = function(V) {
return "^" + V + "\\s*\\(\\s*([\\w\\.]+)\\s*\\)$";
}, s = function(V) {
var q = t + "|\\w+|" + e + "|" + r + "|" + a + "|" + n;
return "^" + V + "\\s*\\(([\\w\\.]+)\\s*\\,\\s*(" + t + ")\\s*\\,\\s*(" + t + ")\\s*,\\s*(" + q + ")\\s*\\,\\s*(" + q + ")\\)$";
}, o = [`^url\\s*\\(\\s*['"]?(.+?)['"]?\\s*\\)$`, "^(none)$", "^(.+)$"];
Qe.types = {
time: {
number: !0,
min: 0,
units: "s|ms",
implicitUnits: "ms"
},
percent: {
number: !0,
min: 0,
max: 100,
units: "%",
implicitUnits: "%"
},
percentages: {
number: !0,
min: 0,
max: 100,
units: "%",
implicitUnits: "%",
multiple: !0
},
zeroOneNumber: {
number: !0,
min: 0,
max: 1,
unitless: !0
},
zeroOneNumbers: {
number: !0,
min: 0,
max: 1,
unitless: !0,
multiple: !0
},
nOneOneNumber: {
number: !0,
min: -1,
max: 1,
unitless: !0
},
nonNegativeInt: {
number: !0,
min: 0,
integer: !0,
unitless: !0
},
nonNegativeNumber: {
number: !0,
min: 0,
unitless: !0
},
position: {
enums: ["parent", "origin"]
},
nodeSize: {
number: !0,
min: 0,
enums: ["label"]
},
number: {
number: !0,
unitless: !0
},
numbers: {
number: !0,
unitless: !0,
multiple: !0
},
positiveNumber: {
number: !0,
unitless: !0,
min: 0,
strictMin: !0
},
size: {
number: !0,
min: 0
},
bidirectionalSize: {
number: !0
},
// allows negative
bidirectionalSizeMaybePercent: {
number: !0,
allowPercent: !0
},
// allows negative
bidirectionalSizes: {
number: !0,
multiple: !0
},
// allows negative
sizeMaybePercent: {
number: !0,
min: 0,
allowPercent: !0
},
axisDirection: {
enums: ["horizontal", "leftward", "rightward", "vertical", "upward", "downward", "auto"]
},
axisDirectionExplicit: {
enums: ["leftward", "rightward", "upward", "downward"]
},
axisDirectionPrimary: {
enums: ["horizontal", "vertical"]
},
paddingRelativeTo: {
enums: ["width", "height", "average", "min", "max"]
},
bgWH: {
number: !0,
min: 0,
allowPercent: !0,
enums: ["auto"],
multiple: !0
},
bgPos: {
number: !0,
allowPercent: !0,
multiple: !0
},
bgRelativeTo: {
enums: ["inner", "include-padding"],
multiple: !0
},
bgRepeat: {
enums: ["repeat", "repeat-x", "repeat-y", "no-repeat"],
multiple: !0
},
bgFit: {
enums: ["none", "contain", "cover"],
multiple: !0
},
bgCrossOrigin: {
enums: ["anonymous", "use-credentials", "null"],
multiple: !0
},
bgClip: {
enums: ["none", "node"],
multiple: !0
},
bgContainment: {
enums: ["inside", "over"],
multiple: !0
},
boxSelection: {
enums: ["contain", "overlap", "none"]
},
color: {
color: !0
},
colors: {
color: !0,
multiple: !0
},
fill: {
enums: ["solid", "linear-gradient", "radial-gradient"]
},
bool: {
enums: ["yes", "no"]
},
bools: {
enums: ["yes", "no"],
multiple: !0
},
lineStyle: {
enums: ["solid", "dotted", "dashed"]
},
lineCap: {
enums: ["butt", "round", "square"]
},
linePosition: {
enums: ["center", "inside", "outside"]
},
lineJoin: {
enums: ["round", "bevel", "miter"]
},
borderStyle: {
enums: ["solid", "dotted", "dashed", "double"]
},
curveStyle: {
enums: ["bezier", "unbundled-bezier", "haystack", "segments", "straight", "straight-triangle", "taxi", "round-segments", "round-taxi"]
},
radiusType: {
enums: ["arc-radius", "influence-radius"],
multiple: !0
},
fontFamily: {
regex: '^([\\w- \\"]+(?:\\s*,\\s*[\\w- \\"]+)*)$'
},
fontStyle: {
enums: ["italic", "normal", "oblique"]
},
fontWeight: {
enums: ["normal", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "800", "900", 100, 200, 300, 400, 500, 600, 700, 800, 900]
},
textDecoration: {
enums: ["none", "underline", "overline", "line-through"]
},
textTransform: {
enums: ["none", "uppercase", "lowercase"]
},
textWrap: {
enums: ["none", "wrap", "ellipsis"]
},
textOverflowWrap: {
enums: ["whitespace", "anywhere"]
},
textBackgroundShape: {
enums: ["rectangle", "roundrectangle", "round-rectangle", "circle"]
},
nodeShape: {
enums: ["rectangle", "roundrectangle", "round-rectangle", "cutrectangle", "cut-rectangle", "bottomroundrectangle", "bottom-round-rectangle", "barrel", "ellipse", "triangle", "round-triangle", "square", "pentagon", "round-pentagon", "hexagon", "round-hexagon", "concavehexagon", "concave-hexagon", "heptagon", "round-heptagon", "octagon", "round-octagon", "tag", "round-tag", "star", "diamond", "round-diamond", "vee", "rhomboid", "right-rhomboid", "polygon"]
},
overlayShape: {
enums: ["roundrectangle", "round-rectangle", "ellipse"]
},
cornerRadius: {
number: !0,
min: 0,
units: "px|em",
implicitUnits: "px",
enums: ["auto"]
},
compoundIncludeLabels: {
enums: ["include", "exclude"]
},
arrowShape: {
enums: ["tee", "triangle", "triangle-tee", "circle-triangle", "triangle-cross", "triangle-backcurve", "vee", "square", "circle", "diamond", "chevron", "none"]
},
arrowFill: {
enums: ["filled", "hollow"]
},
arrowWidth: {
number: !0,
units: "%|px|em",
implicitUnits: "px",
enums: ["match-line"]
},
display: {
enums: ["element", "none"]
},
visibility: {
enums: ["hidden", "visible"]
},
zCompoundDepth: {
enums: ["bottom", "orphan", "auto", "top"]
},
zIndexCompare: {
enums: ["auto", "manual"]
},
valign: {
enums: ["top", "center", "bottom"]
},
halign: {
enums: ["left", "center", "right"]
},
justification: {
enums: ["left", "center", "right", "auto"]
},
text: {
string: !0
},
data: {
mapping: !0,
regex: i("data")
},
layoutData: {
mapping: !0,
regex: i("layoutData")
},
scratch: {
mapping: !0,
regex: i("scratch")
},
mapData: {
mapping: !0,
regex: s("mapData")
},
mapLayoutData: {
mapping: !0,
regex: s("mapLayoutData")
},
mapScratch: {
mapping: !0,
regex: s("mapScratch")
},
fn: {
mapping: !0,
fn: !0
},
url: {
regexes: o,
singleRegexMatchValue: !0
},
urls: {
regexes: o,
singleRegexMatchValue: !0,
multiple: !0
},
propList: {
propList: !0
},
angle: {
number: !0,
units: "deg|rad",
implicitUnits: "rad"
},
textRotation: {
number: !0,
units: "deg|rad",
implicitUnits: "rad",
enums: ["none", "autorotate"]
},
polygonPointList: {
number: !0,
multiple: !0,
evenMultiple: !0,
min: -1,
max: 1,
unitless: !0
},
edgeDistances: {
enums: ["intersection", "node-position", "endpoints"]
},
edgeEndpoint: {
number: !0,
multiple: !0,
units: "%|px|em|deg|rad",
implicitUnits: "px",
enums: ["inside-to-node", "outside-to-node", "outside-to-node-or-label", "outside-to-line", "outside-to-line-or-label"],
singleEnum: !0,
validate: function(V, q) {
switch (V.length) {
case 2:
return q[0] !== "deg" && q[0] !== "rad" && q[1] !== "deg" && q[1] !== "rad";
case 1:
return ge(V[0]) || q[0] === "deg" || q[0] === "rad";
default:
return !1;
}
}
},
easing: {
regexes: ["^(spring)\\s*\\(\\s*(" + t + ")\\s*,\\s*(" + t + ")\\s*\\)$", "^(cubic-bezier)\\s*\\(\\s*(" + t + ")\\s*,\\s*(" + t + ")\\s*,\\s*(" + t + ")\\s*,\\s*(" + t + ")\\s*\\)$"],
enums: ["linear", "ease", "ease-in", "ease-out", "ease-in-out", "ease-in-sine", "ease-out-sine", "ease-in-out-sine", "ease-in-quad", "ease-out-quad", "ease-in-out-quad", "ease-in-cubic", "ease-out-cubic", "ease-in-out-cubic", "ease-in-quart", "ease-out-quart", "ease-in-out-quart", "ease-in-quint", "ease-out-quint", "ease-in-out-quint", "ease-in-expo", "ease-out-expo", "ease-in-out-expo", "ease-in-circ", "ease-out-circ", "ease-in-out-circ"]
},
gradientDirection: {
enums: [
"to-bottom",
"to-top",
"to-left",
"to-right",
"to-bottom-right",
"to-bottom-left",
"to-top-right",
"to-top-left",
"to-right-bottom",
"to-left-bottom",
"to-right-top",
"to-left-top"
// different order
]
},
boundsExpansion: {
number: !0,
multiple: !0,
min: 0,
validate: function(V) {
var q = V.length;
return q === 1 || q === 2 || q === 4;
}
}
};
var u = {
zeroNonZero: function(V, q) {
return (V == null || q == null) && V !== q || V == 0 && q != 0 ? !0 : V != 0 && q == 0;
},
any: function(V, q) {
return V != q;
},
emptyNonEmpty: function(V, q) {
var Z = fr(V), re = fr(q);
return Z && !re || !Z && re;
}
}, l = Qe.types, f = [{
name: "label",
type: l.text,
triggersBounds: u.any,
triggersZOrder: u.emptyNonEmpty
}, {
name: "text-rotation",
type: l.textRotation,
triggersBounds: u.any
}, {
name: "text-margin-x",
type: l.bidirectionalSize,
triggersBounds: u.any
}, {
name: "text-margin-y",
type: l.bidirectionalSize,
triggersBounds: u.any
}], c = [{
name: "source-label",
type: l.text,
triggersBounds: u.any
}, {
name: "source-text-rotation",
type: l.textRotation,
triggersBounds: u.any
}, {
name: "source-text-margin-x",
type: l.bidirectionalSize,
triggersBounds: u.any
}, {
name: "source-text-margin-y",
type: l.bidirectionalSize,
triggersBounds: u.any
}, {
name: "source-text-offset",
type: l.size,
triggersBounds: u.any
}], v = [{
name: "target-label",
type: l.text,
triggersBounds: u.any
}, {
name: "target-text-rotation",
type: l.textRotation,
triggersBounds: u.any
}, {
name: "target-text-margin-x",
type: l.bidirectionalSize,
triggersBounds: u.any
}, {
name: "target-text-margin-y",
type: l.bidirectionalSize,
triggersBounds: u.any
}, {
name: "target-text-offset",
type: l.size,
triggersBounds: u.any
}], h = [{
name: "font-family",
type: l.fontFamily,
triggersBounds: u.any
}, {
name: "font-style",
type: l.fontStyle,
triggersBounds: u.any
}, {
name: "font-weight",
type: l.fontWeight,
triggersBounds: u.any
}, {
name: "font-size",
type: l.size,
triggersBounds: u.any
}, {
name: "text-transform",
type: l.textTransform,
triggersBounds: u.any
}, {
name: "text-wrap",
type: l.textWrap,
triggersBounds: u.any
}, {
name: "text-overflow-wrap",
type: l.textOverflowWrap,
triggersBounds: u.any
}, {
name: "text-max-width",
type: l.size,
triggersBounds: u.any
}, {
name: "text-outline-width",
type: l.size,
triggersBounds: u.any
}, {
name: "line-height",
type: l.positiveNumber,
triggersBounds: u.any
}], d = [{
name: "text-valign",
type: l.valign,
triggersBounds: u.any
}, {
name: "text-halign",
type: l.halign,
triggersBounds: u.any
}, {
name: "color",
type: l.color
}, {
name: "text-outline-color",
type: l.color
}, {
name: "text-outline-opacity",
type: l.zeroOneNumber
}, {
name: "text-background-color",
type: l.color
}, {
name: "text-background-opacity",
type: l.zeroOneNumber
}, {
name: "text-background-padding",
type: l.size,
triggersBounds: u.any
}, {
name: "text-border-opacity",
type: l.zeroOneNumber
}, {
name: "text-border-color",
type: l.color
}, {
name: "text-border-width",
type: l.size,
triggersBounds: u.any
}, {
name: "text-border-style",
type: l.borderStyle,
triggersBounds: u.any
}, {
name: "text-background-shape",
type: l.textBackgroundShape,
triggersBounds: u.any
}, {
name: "text-justification",
type: l.justification
}, {
name: "box-select-labels",
type: l.bool,
triggersBounds: u.any
}], p = [{
name: "events",
type: l.bool,
triggersZOrder: u.any
}, {
name: "text-events",
type: l.bool,
triggersZOrder: u.any
}, {
name: "box-selection",
type: l.boxSelection,
triggersZOrder: u.any
}], g = [{
name: "display",
type: l.display,
triggersZOrder: u.any,
triggersBounds: u.any,
triggersBoundsOfConnectedEdges: u.any,
triggersBoundsOfParallelEdges: function(V, q, Z) {
return V === q ? !1 : Z.pstyle("curve-style").value === "bezier";
}
}, {
name: "visibility",
type: l.visibility,
triggersZOrder: u.any
}, {
name: "opacity",
type: l.zeroOneNumber,
triggersZOrder: u.zeroNonZero
}, {
name: "text-opacity",
type: l.zeroOneNumber
}, {
name: "min-zoomed-font-size",
type: l.size
}, {
name: "z-compound-depth",
type: l.zCompoundDepth,
triggersZOrder: u.any
}, {
name: "z-index-compare",
type: l.zIndexCompare,
triggersZOrder: u.any
}, {
name: "z-index",
type: l.number,
triggersZOrder: u.any
}], y = [{
name: "overlay-padding",
type: l.size,
triggersBounds: u.any
}, {
name: "overlay-color",
type: l.color
}, {
name: "overlay-opacity",
type: l.zeroOneNumber,
triggersBounds: u.zeroNonZero
}, {
name: "overlay-shape",
type: l.overlayShape,
triggersBounds: u.any
}, {
name: "overlay-corner-radius",
type: l.cornerRadius
}], b = [{
name: "underlay-padding",
type: l.size,
triggersBounds: u.any
}, {
name: "underlay-color",
type: l.color
}, {
name: "underlay-opacity",
type: l.zeroOneNumber,
triggersBounds: u.zeroNonZero
}, {
name: "underlay-shape",
type: l.overlayShape,
triggersBounds: u.any
}, {
name: "underlay-corner-radius",
type: l.cornerRadius
}], m = [{
name: "transition-property",
type: l.propList
}, {
name: "transition-duration",
type: l.time
}, {
name: "transition-delay",
type: l.time
}, {
name: "transition-timing-function",
type: l.easing
}], E = function(V, q) {
return q.value === "label" ? -V.poolIndex() : q.pfValue;
}, T = [{
name: "height",
type: l.nodeSize,
triggersBounds: u.any,
hashOverride: E
}, {
name: "width",
type: l.nodeSize,
triggersBounds: u.any,
hashOverride: E
}, {
name: "shape",
type: l.nodeShape,
triggersBounds: u.any
}, {
name: "shape-polygon-points",
type: l.polygonPointList,
triggersBounds: u.any
}, {
name: "corner-radius",
type: l.cornerRadius
}, {
name: "background-color",
type: l.color
}, {
name: "background-fill",
type: l.fill
}, {
name: "background-opacity",
type: l.zeroOneNumber
}, {
name: "background-blacken",
type: l.nOneOneNumber
}, {
name: "background-gradient-stop-colors",
type: l.colors
}, {
name: "background-gradient-stop-positions",
type: l.percentages
}, {
name: "background-gradient-direction",
type: l.gradientDirection
}, {
name: "padding",
type: l.sizeMaybePercent,
triggersBounds: u.any
}, {
name: "padding-relative-to",
type: l.paddingRelativeTo,
triggersBounds: u.any
}, {
name: "bounds-expansion",
type: l.boundsExpansion,
triggersBounds: u.any
}], S = [{
name: "border-color",
type: l.color
}, {
name: "border-opacity",
type: l.zeroOneNumber
}, {
name: "border-width",
type: l.size,
triggersBounds: u.any
}, {
name: "border-style",
type: l.borderStyle
}, {
name: "border-cap",
type: l.lineCap
}, {
name: "border-join",
type: l.lineJoin
}, {
name: "border-dash-pattern",
type: l.numbers
}, {
name: "border-dash-offset",
type: l.number
}, {
name: "border-position",
type: l.linePosition
}], w = [{
name: "outline-color",
type: l.color
}, {
name: "outline-opacity",
type: l.zeroOneNumber
}, {
name: "outline-width",
type: l.size,
triggersBounds: u.any
}, {
name: "outline-style",
type: l.borderStyle
}, {
name: "outline-offset",
type: l.size,
triggersBounds: u.any
}], x = [{
name: "background-image",
type: l.urls
}, {
name: "background-image-crossorigin",
type: l.bgCrossOrigin
}, {
name: "background-image-opacity",
type: l.zeroOneNumbers
}, {
name: "background-image-containment",
type: l.bgContainment
}, {
name: "background-image-smoothing",
type: l.bools
}, {
name: "background-position-x",
type: l.bgPos
}, {
name: "background-position-y",
type: l.bgPos
}, {
name: "background-width-relative-to",
type: l.bgRelativeTo
}, {
name: "background-height-relative-to",
type: l.bgRelativeTo
}, {
name: "background-repeat",
type: l.bgRepeat
}, {
name: "background-fit",
type: l.bgFit
}, {
name: "background-clip",
type: l.bgClip
}, {
name: "background-width",
type: l.bgWH
}, {
name: "background-height",
type: l.bgWH
}, {
name: "background-offset-x",
type: l.bgPos
}, {
name: "background-offset-y",
type: l.bgPos
}], C = [{
name: "position",
type: l.position,
triggersBounds: u.any
}, {
name: "compound-sizing-wrt-labels",
type: l.compoundIncludeLabels,
triggersBounds: u.any
}, {
name: "min-width",
type: l.size,
triggersBounds: u.any
}, {
name: "min-width-bias-left",
type: l.sizeMaybePercent,
triggersBounds: u.any
}, {
name: "min-width-bias-right",
type: l.sizeMaybePercent,
triggersBounds: u.any
}, {
name: "min-height",
type: l.size,
triggersBounds: u.any
}, {
name: "min-height-bias-top",
type: l.sizeMaybePercent,
triggersBounds: u.any
}, {
name: "min-height-bias-bottom",
type: l.sizeMaybePercent,
triggersBounds: u.any
}], D = [{
name: "line-style",
type: l.lineStyle
}, {
name: "line-color",
type: l.color
}, {
name: "line-fill",
type: l.fill
}, {
name: "line-cap",
type: l.lineCap
}, {
name: "line-opacity",
type: l.zeroOneNumber
}, {
name: "line-dash-pattern",
type: l.numbers
}, {
name: "line-dash-offset",
type: l.number
}, {
name: "line-outline-width",
type: l.size
}, {
name: "line-outline-color",
type: l.color
}, {
name: "line-gradient-stop-colors",
type: l.colors
}, {
name: "line-gradient-stop-positions",
type: l.percentages
}, {
name: "curve-style",
type: l.curveStyle,
triggersBounds: u.any,
triggersBoundsOfParallelEdges: function(V, q) {
return V === q ? !1 : V === "bezier" || // remove from bundle
q === "bezier";
}
}, {
name: "haystack-radius",
type: l.zeroOneNumber,
triggersBounds: u.any
}, {
name: "source-endpoint",
type: l.edgeEndpoint,
triggersBounds: u.any
}, {
name: "target-endpoint",
type: l.edgeEndpoint,
triggersBounds: u.any
}, {
name: "control-point-step-size",
type: l.size,
triggersBounds: u.any
}, {
name: "control-point-distances",
type: l.bidirectionalSizes,
triggersBounds: u.any
}, {
name: "control-point-weights",
type: l.numbers,
triggersBounds: u.any
}, {
name: "segment-distances",
type: l.bidirectionalSizes,
triggersBounds: u.any
}, {
name: "segment-weights",
type: l.numbers,
triggersBounds: u.any
}, {
name: "segment-radii",
type: l.numbers,
triggersBounds: u.any
}, {
name: "radius-type",
type: l.radiusType,
triggersBounds: u.any
}, {
name: "taxi-turn",
type: l.bidirectionalSizeMaybePercent,
triggersBounds: u.any
}, {
name: "taxi-turn-min-distance",
type: l.size,
triggersBounds: u.any
}, {
name: "taxi-direction",
type: l.axisDirection,
triggersBounds: u.any
}, {
name: "taxi-radius",
type: l.number,
triggersBounds: u.any
}, {
name: "edge-distances",
type: l.edgeDistances,
triggersBounds: u.any
}, {
name: "arrow-scale",
type: l.positiveNumber,
triggersBounds: u.any
}, {
name: "loop-direction",
type: l.angle,
triggersBounds: u.any
}, {
name: "loop-sweep",
type: l.angle,
triggersBounds: u.any
}, {
name: "source-distance-from-node",
type: l.size,
triggersBounds: u.any
}, {
name: "target-distance-from-node",
type: l.size,
triggersBounds: u.any
}], A = [{
name: "ghost",
type: l.bool,
triggersBounds: u.any
}, {
name: "ghost-offset-x",
type: l.bidirectionalSize,
triggersBounds: u.any
}, {
name: "ghost-offset-y",
type: l.bidirectionalSize,
triggersBounds: u.any
}, {
name: "ghost-opacity",
type: l.zeroOneNumber
}], L = [{
name: "selection-box-color",
type: l.color
}, {
name: "selection-box-opacity",
type: l.zeroOneNumber
}, {
name: "selection-box-border-color",
type: l.color
}, {
name: "selection-box-border-width",
type: l.size
}, {
name: "active-bg-color",
type: l.color
}, {
name: "active-bg-opacity",
type: l.zeroOneNumber
}, {
name: "active-bg-size",
type: l.size
}, {
name: "outside-texture-bg-color",
type: l.color
}, {
name: "outside-texture-bg-opacity",
type: l.zeroOneNumber
}], R = [];
Qe.pieBackgroundN = 16, R.push({
name: "pie-size",
type: l.sizeMaybePercent
}), R.push({
name: "pie-hole",
type: l.sizeMaybePercent
}), R.push({
name: "pie-start-angle",
type: l.angle
});
for (var I = 1; I <= Qe.pieBackgroundN; I++)
R.push({
name: "pie-" + I + "-background-color",
type: l.color
}), R.push({
name: "pie-" + I + "-background-size",
type: l.percent
}), R.push({
name: "pie-" + I + "-background-opacity",
type: l.zeroOneNumber
});
var M = [];
Qe.stripeBackgroundN = 16, M.push({
name: "stripe-size",
type: l.sizeMaybePercent
}), M.push({
name: "stripe-direction",
type: l.axisDirectionPrimary
});
for (var N = 1; N <= Qe.stripeBackgroundN; N++)
M.push({
name: "stripe-" + N + "-background-color",
type: l.color
}), M.push({
name: "stripe-" + N + "-background-size",
type: l.percent
}), M.push({
name: "stripe-" + N + "-background-opacity",
type: l.zeroOneNumber
});
var O = [], k = Qe.arrowPrefixes = ["source", "mid-source", "target", "mid-target"];
[{
name: "arrow-shape",
type: l.arrowShape,
triggersBounds: u.any
}, {
name: "arrow-color",
type: l.color
}, {
name: "arrow-fill",
type: l.arrowFill
}, {
name: "arrow-width",
type: l.arrowWidth
}].forEach(function(z) {
k.forEach(function(V) {
var q = V + "-" + z.name, Z = z.type, re = z.triggersBounds;
O.push({
name: q,
type: Z,
triggersBounds: re
});
});
}, {});
var B = Qe.properties = [].concat(p, m, g, y, b, A, d, h, f, c, v, T, S, w, x, R, M, C, D, O, L), _ = Qe.propertyGroups = {
// common to all eles
behavior: p,
transition: m,
visibility: g,
overlay: y,
underlay: b,
ghost: A,
// labels
commonLabel: d,
labelDimensions: h,
mainLabel: f,
sourceLabel: c,
targetLabel: v,
// node props
nodeBody: T,
nodeBorder: S,
nodeOutline: w,
backgroundImage: x,
pie: R,
stripe: M,
compound: C,
// edge props
edgeLine: D,
edgeArrow: O,
core: L
}, F = Qe.propertyGroupNames = {}, G = Qe.propertyGroupKeys = Object.keys(_);
G.forEach(function(z) {
F[z] = _[z].map(function(V) {
return V.name;
}), _[z].forEach(function(V) {
return V.groupKey = z;
});
});
var H = Qe.aliases = [{
name: "content",
pointsTo: "label"
}, {
name: "control-point-distance",
pointsTo: "control-point-distances"
}, {
name: "control-point-weight",
pointsTo: "control-point-weights"
}, {
name: "segment-distance",
pointsTo: "segment-distances"
}, {
name: "segment-weight",
pointsTo: "segment-weights"
}, {
name: "segment-radius",
pointsTo: "segment-radii"
}, {
name: "edge-text-rotation",
pointsTo: "text-rotation"
}, {
name: "padding-left",
pointsTo: "padding"
}, {
name: "padding-right",
pointsTo: "padding"
}, {
name: "padding-top",
pointsTo: "padding"
}, {
name: "padding-bottom",
pointsTo: "padding"
}];
Qe.propertyNames = B.map(function(z) {
return z.name;
});
for (var Y = 0; Y < B.length; Y++) {
var X = B[Y];
B[X.name] = X;
}
for (var W = 0; W < H.length; W++) {
var ee = H[W], ae = B[ee.pointsTo], J = {
name: ee.name,
alias: !0,
pointsTo: ae
};
B.push(J), B[ee.name] = J;
}
})();
Qe.getDefaultProperty = function(t) {
return this.getDefaultProperties()[t];
};
Qe.getDefaultProperties = function() {
var t = this._private;
if (t.defaultProperties != null)
return t.defaultProperties;
for (var e = be({
// core props
"selection-box-color": "#ddd",
"selection-box-opacity": 0.65,
"selection-box-border-color": "#aaa",
"selection-box-border-width": 1,
"active-bg-color": "black",
"active-bg-opacity": 0.15,
"active-bg-size": 30,
"outside-texture-bg-color": "#000",
"outside-texture-bg-opacity": 0.125,
// common node/edge props
events: "yes",
"text-events": "no",
"text-valign": "top",
"text-halign": "center",
"text-justification": "auto",
"line-height": 1,
color: "#000",
"box-selection": "contain",
"text-outline-color": "#000",
"text-outline-width": 0,
"text-outline-opacity": 1,
"text-opacity": 1,
"text-decoration": "none",
"text-transform": "none",
"text-wrap": "none",
"text-overflow-wrap": "whitespace",
"text-max-width": 9999,
"text-background-color": "#000",
"text-background-opacity": 0,
"text-background-shape": "rectangle",
"text-background-padding": 0,
"text-border-opacity": 0,
"text-border-width": 0,
"text-border-style": "solid",
"text-border-color": "#000",
"font-family": "Helvetica Neue, Helvetica, sans-serif",
"font-style": "normal",
"font-weight": "normal",
"font-size": 16,
"min-zoomed-font-size": 0,
"text-rotation": "none",
"source-text-rotation": "none",
"target-text-rotation": "none",
visibility: "visible",
display: "element",
opacity: 1,
"z-compound-depth": "auto",
"z-index-compare": "auto",
"z-index": 0,
label: "",
"text-margin-x": 0,
"text-margin-y": 0,
"source-label": "",
"source-text-offset": 0,
"source-text-margin-x": 0,
"source-text-margin-y": 0,
"target-label": "",
"target-text-offset": 0,
"target-text-margin-x": 0,
"target-text-margin-y": 0,
"overlay-opacity": 0,
"overlay-color": "#000",
"overlay-padding": 10,
"overlay-shape": "round-rectangle",
"overlay-corner-radius": "auto",
"underlay-opacity": 0,
"underlay-color": "#000",
"underlay-padding": 10,
"underlay-shape": "round-rectangle",
"underlay-corner-radius": "auto",
"transition-property": "none",
"transition-duration": 0,
"transition-delay": 0,
"transition-timing-function": "linear",
"box-select-labels": "no",
// node props
"background-blacken": 0,
"background-color": "#999",
"background-fill": "solid",
"background-opacity": 1,
"background-image": "none",
"background-image-crossorigin": "anonymous",
"background-image-opacity": 1,
"background-image-containment": "inside",
"background-image-smoothing": "yes",
"background-position-x": "50%",
"background-position-y": "50%",
"background-offset-x": 0,
"background-offset-y": 0,
"background-width-relative-to": "include-padding",
"background-height-relative-to": "include-padding",
"background-repeat": "no-repeat",
"background-fit": "none",
"background-clip": "node",
"background-width": "auto",
"background-height": "auto",
"border-color": "#000",
"border-opacity": 1,
"border-width": 0,
"border-style": "solid",
"border-dash-pattern": [4, 2],
"border-dash-offset": 0,
"border-cap": "butt",
"border-join": "miter",
"border-position": "center",
"outline-color": "#999",
"outline-opacity": 1,
"outline-width": 0,
"outline-offset": 0,
"outline-style": "solid",
height: 30,
width: 30,
shape: "ellipse",
"shape-polygon-points": "-1, -1, 1, -1, 1, 1, -1, 1",
"corner-radius": "auto",
"bounds-expansion": 0,
// node gradient
"background-gradient-direction": "to-bottom",
"background-gradient-stop-colors": "#999",
"background-gradient-stop-positions": "0%",
// ghost props
ghost: "no",
"ghost-offset-y": 0,
"ghost-offset-x": 0,
"ghost-opacity": 0,
// compound props
padding: 0,
"padding-relative-to": "width",
position: "origin",
"compound-sizing-wrt-labels": "include",
"min-width": 0,
"min-width-bias-left": 0,
"min-width-bias-right": 0,
"min-height": 0,
"min-height-bias-top": 0,
"min-height-bias-bottom": 0
}, {
// node pie bg
"pie-size": "100%",
"pie-hole": 0,
"pie-start-angle": "0deg"
}, [{
name: "pie-{{i}}-background-color",
value: "black"
}, {
name: "pie-{{i}}-background-size",
value: "0%"
}, {
name: "pie-{{i}}-background-opacity",
value: 1
}].reduce(function(u, l) {
for (var f = 1; f <= Qe.pieBackgroundN; f++) {
var c = l.name.replace("{{i}}", f), v = l.value;
u[c] = v;
}
return u;
}, {}), {
// node stripes bg
"stripe-size": "100%",
"stripe-direction": "horizontal"
}, [{
name: "stripe-{{i}}-background-color",
value: "black"
}, {
name: "stripe-{{i}}-background-size",
value: "0%"
}, {
name: "stripe-{{i}}-background-opacity",
value: 1
}].reduce(function(u, l) {
for (var f = 1; f <= Qe.stripeBackgroundN; f++) {
var c = l.name.replace("{{i}}", f), v = l.value;
u[c] = v;
}
return u;
}, {}), {
// edge props
"line-style": "solid",
"line-color": "#999",
"line-fill": "solid",
"line-cap": "butt",
"line-opacity": 1,
"line-outline-width": 0,
"line-outline-color": "#000",
"line-gradient-stop-colors": "#999",
"line-gradient-stop-positions": "0%",
"control-point-step-size": 40,
"control-point-weights": 0.5,
"segment-weights": 0.5,
"segment-distances": 20,
"segment-radii": 15,
"radius-type": "arc-radius",
"taxi-turn": "50%",
"taxi-radius": 15,
"taxi-turn-min-distance": 10,
"taxi-direction": "auto",
"edge-distances": "intersection",
"curve-style": "haystack",
"haystack-radius": 0,
"arrow-scale": 1,
"loop-direction": "-45deg",
"loop-sweep": "-90deg",
"source-distance-from-node": 0,
"target-distance-from-node": 0,
"source-endpoint": "outside-to-node",
"target-endpoint": "outside-to-node",
"line-dash-pattern": [6, 3],
"line-dash-offset": 0
}, [{
name: "arrow-shape",
value: "none"
}, {
name: "arrow-color",
value: "#999"
}, {
name: "arrow-fill",
value: "filled"
}, {
name: "arrow-width",
value: 1
}].reduce(function(u, l) {
return Qe.arrowPrefixes.forEach(function(f) {
var c = f + "-" + l.name, v = l.value;
u[c] = v;
}), u;
}, {})), r = {}, a = 0; a < this.properties.length; a++) {
var n = this.properties[a];
if (!n.pointsTo) {
var i = n.name, s = e[i], o = this.parse(i, s);
r[i] = o;
}
}
return t.defaultProperties = r, t.defaultProperties;
};
Qe.addDefaultStylesheet = function() {
this.selector(":parent").css({
shape: "rectangle",
padding: 10,
"background-color": "#eee",
"border-color": "#ccc",
"border-width": 1
}).selector("edge").css({
width: 3
}).selector(":loop").css({
"curve-style": "bezier"
}).selector("edge:compound").css({
"curve-style": "bezier",
"source-endpoint": "outside-to-line",
"target-endpoint": "outside-to-line"
}).selector(":selected").css({
"background-color": "#0169D9",
"line-color": "#0169D9",
"source-arrow-color": "#0169D9",
"target-arrow-color": "#0169D9",
"mid-source-arrow-color": "#0169D9",
"mid-target-arrow-color": "#0169D9"
}).selector(":parent:selected").css({
"background-color": "#CCE1F9",
"border-color": "#aec8e5"
}).selector(":active").css({
"overlay-color": "black",
"overlay-padding": 10,
"overlay-opacity": 0.25
}), this.defaultLength = this.length;
};
var Qn = {};
Qn.parse = function(t, e, r, a) {
var n = this;
if (Xe(e))
return n.parseImplWarn(t, e, r, a);
var i = a === "mapping" || a === !0 || a === !1 || a == null ? "dontcare" : a, s = r ? "t" : "f", o = "" + e, u = Sf(t, o, s, i), l = n.propCache = n.propCache || [], f;
return (f = l[u]) || (f = l[u] = n.parseImplWarn(t, e, r, a)), (r || a === "mapping") && (f = Ut(f), f && (f.value = Ut(f.value))), f;
};
Qn.parseImplWarn = function(t, e, r, a) {
var n = this.parseImpl(t, e, r, a);
return !n && e != null && Ge("The style property `".concat(t, ": ").concat(e, "` is invalid")), n && (n.name === "width" || n.name === "height") && e === "label" && Ge("The style value of `label` is deprecated for `" + n.name + "`"), n;
};
Qn.parseImpl = function(t, e, r, a) {
var n = this;
t = so(t);
var i = n.properties[t], s = e, o = n.types;
if (!i || e === void 0)
return null;
i.alias && (i = i.pointsTo, t = i.name);
var u = ge(e);
u && (e = e.trim());
var l = i.type;
if (!l)
return null;
if (r && (e === "" || e === null))
return {
name: t,
value: e,
bypass: !0,
deleteBypass: !0
};
if (Xe(e))
return {
name: t,
value: e,
strValue: "fn",
mapped: o.fn,
bypass: r
};
var f, c;
if (!(!u || a || e.length < 7 || e[1] !== "a")) {
if (e.length >= 7 && e[0] === "d" && (f = new RegExp(o.data.regex).exec(e))) {
if (r)
return !1;
var v = o.data;
return {
name: t,
value: f,
strValue: "" + e,
mapped: v,
field: f[1],
bypass: r
};
} else if (e.length >= 10 && e[0] === "m" && (c = new RegExp(o.mapData.regex).exec(e))) {
if (r || l.multiple)
return !1;
var h = o.mapData;
if (!(l.color || l.number))
return !1;
var d = this.parse(t, c[4]);
if (!d || d.mapped)
return !1;
var p = this.parse(t, c[5]);
if (!p || p.mapped)
return !1;
if (d.pfValue === p.pfValue || d.strValue === p.strValue)
return Ge("`" + t + ": " + e + "` is not a valid mapper because the output range is zero; converting to `" + t + ": " + d.strValue + "`"), this.parse(t, d.strValue);
if (l.color) {
var g = d.value, y = p.value, b = g[0] === y[0] && g[1] === y[1] && g[2] === y[2] && // optional alpha
(g[3] === y[3] || (g[3] == null || g[3] === 1) && (y[3] == null || y[3] === 1));
if (b)
return !1;
}
return {
name: t,
value: c,
strValue: "" + e,
mapped: h,
field: c[1],
fieldMin: parseFloat(c[2]),
// min & max are numeric
fieldMax: parseFloat(c[3]),
valueMin: d.value,
valueMax: p.value,
bypass: r
};
}
}
if (l.multiple && a !== "multiple") {
var m;
if (u ? m = e.split(/\s+/) : Ve(e) ? m = e : m = [e], l.evenMultiple && m.length % 2 !== 0)
return null;
for (var E = [], T = [], S = [], w = "", x = !1, C = 0; C < m.length; C++) {
var D = n.parse(t, m[C], r, "multiple");
x = x || ge(D.value), E.push(D.value), S.push(D.pfValue != null ? D.pfValue : D.value), T.push(D.units), w += (C > 0 ? " " : "") + D.strValue;
}
return l.validate && !l.validate(E, T) ? null : l.singleEnum && x ? E.length === 1 && ge(E[0]) ? {
name: t,
value: E[0],
strValue: E[0],
bypass: r
} : null : {
name: t,
value: E,
pfValue: S,
strValue: w,
bypass: r,
units: T
};
}
var A = function() {
for (var J = 0; J < l.enums.length; J++) {
var z = l.enums[J];
if (z === e)
return {
name: t,
value: e,
strValue: "" + e,
bypass: r
};
}
return null;
};
if (l.number) {
var L, R = "px";
if (l.units && (L = l.units), l.implicitUnits && (R = l.implicitUnits), !l.unitless)
if (u) {
var I = "px|em" + (l.allowPercent ? "|\\%" : "");
L && (I = L);
var M = e.match("^(" + at + ")(" + I + ")?$");
M && (e = M[1], L = M[2] || R);
} else
(!L || l.implicitUnits) && (L = R);
if (e = parseFloat(e), isNaN(e) && l.enums === void 0)
return null;
if (isNaN(e) && l.enums !== void 0)
return e = s, A();
if (l.integer && !_v(e) || l.min !== void 0 && (e < l.min || l.strictMin && e === l.min) || l.max !== void 0 && (e > l.max || l.strictMax && e === l.max))
return null;
var N = {
name: t,
value: e,
strValue: "" + e + (L || ""),
units: L,
bypass: r
};
return l.unitless || L !== "px" && L !== "em" ? N.pfValue = e : N.pfValue = L === "px" || !L ? e : this.getEmSizeInPixels() * e, (L === "ms" || L === "s") && (N.pfValue = L === "ms" ? e : 1e3 * e), (L === "deg" || L === "rad") && (N.pfValue = L === "rad" ? e : Wh(e)), L === "%" && (N.pfValue = e / 100), N;
} else if (l.propList) {
var O = [], k = "" + e;
if (k !== "none") {
for (var B = k.split(/\s*,\s*|\s+/), _ = 0; _ < B.length; _++) {
var F = B[_].trim();
n.properties[F] ? O.push(F) : Ge("`" + F + "` is not a valid property name");
}
if (O.length === 0)
return null;
}
return {
name: t,
value: O,
strValue: O.length === 0 ? "none" : O.join(" "),
bypass: r
};
} else if (l.color) {
var G = bf(e);
return G ? {
name: t,
value: G,
pfValue: G,
strValue: "rgb(" + G[0] + "," + G[1] + "," + G[2] + ")",
// n.b. no spaces b/c of multiple support
bypass: r
} : null;
} else if (l.regex || l.regexes) {
if (l.enums) {
var H = A();
if (H)
return H;
}
for (var Y = l.regexes ? l.regexes : [l.regex], X = 0; X < Y.length; X++) {
var W = new RegExp(Y[X]), ee = W.exec(e);
if (ee)
return {
name: t,
value: l.singleRegexMatchValue ? ee[1] : ee,
strValue: "" + e,
bypass: r
};
}
return null;
} else
return l.string ? {
name: t,
value: "" + e,
strValue: "" + e,
bypass: r
} : l.enums ? A() : null;
};
var ut = function(e) {
if (!(this instanceof ut))
return new ut(e);
if (!io(e)) {
He("A style must have a core reference");
return;
}
this._private = {
cy: e,
coreStyle: {}
}, this.length = 0, this.resetToDefault();
}, yt = ut.prototype;
yt.instanceString = function() {
return "style";
};
yt.clear = function() {
for (var t = this._private, e = t.cy, r = e.elements(), a = 0; a < this.length; a++)
this[a] = void 0;
return this.length = 0, t.contextStyles = {}, t.propDiffs = {}, this.cleanElements(r, !0), r.forEach(function(n) {
var i = n[0]._private;
i.styleDirty = !0, i.appliedInitStyle = !1;
}), this;
};
yt.resetToDefault = function() {
return this.clear(), this.addDefaultStylesheet(), this;
};
yt.core = function(t) {
return this._private.coreStyle[t] || this.getDefaultProperty(t);
};
yt.selector = function(t) {
var e = t === "core" ? null : new hr(t), r = this.length++;
return this[r] = {
selector: e,
properties: [],
mappedProperties: [],
index: r
}, this;
};
yt.css = function() {
var t = this, e = arguments;
if (e.length === 1)
for (var r = e[0], a = 0; a < t.properties.length; a++) {
var n = t.properties[a], i = r[n.name];
i === void 0 && (i = r[Fn(n.name)]), i !== void 0 && this.cssRule(n.name, i);
}
else
e.length === 2 && this.cssRule(e[0], e[1]);
return this;
};
yt.style = yt.css;
yt.cssRule = function(t, e) {
var r = this.parse(t, e);
if (r) {
var a = this.length - 1;
this[a].properties.push(r), this[a].properties[r.name] = r, r.name.match(/pie-(\d+)-background-size/) && r.value && (this._private.hasPie = !0), r.name.match(/stripe-(\d+)-background-size/) && r.value && (this._private.hasStripe = !0), r.mapped && this[a].mappedProperties.push(r);
var n = !this[a].selector;
n && (this._private.coreStyle[r.name] = r);
}
return this;
};
yt.append = function(t) {
return pf(t) ? t.appendToStyle(this) : Ve(t) ? this.appendFromJson(t) : ge(t) && this.appendFromString(t), this;
};
ut.fromJson = function(t, e) {
var r = new ut(t);
return r.fromJson(e), r;
};
ut.fromString = function(t, e) {
return new ut(t).fromString(e);
};
[lt, Ya, xo, qt, Zn, To, Qe, Qn].forEach(function(t) {
be(yt, t);
});
ut.types = yt.types;
ut.properties = yt.properties;
ut.propertyGroups = yt.propertyGroups;
ut.propertyGroupNames = yt.propertyGroupNames;
ut.propertyGroupKeys = yt.propertyGroupKeys;
var Jp = {
style: function(e) {
if (e) {
var r = this.setStyle(e);
r.update();
}
return this._private.style;
},
setStyle: function(e) {
var r = this._private;
return pf(e) ? r.style = e.generateStyle(this) : Ve(e) ? r.style = ut.fromJson(this, e) : ge(e) ? r.style = ut.fromString(this, e) : r.style = ut(this), r.style;
},
// e.g. cy.data() changed => recalc ele mappers
updateStyle: function() {
this.mutableElements().updateStyle();
}
}, jp = "single", Or = {
autolock: function(e) {
if (e !== void 0)
this._private.autolock = !!e;
else
return this._private.autolock;
return this;
},
autoungrabify: function(e) {
if (e !== void 0)
this._private.autoungrabify = !!e;
else
return this._private.autoungrabify;
return this;
},
autounselectify: function(e) {
if (e !== void 0)
this._private.autounselectify = !!e;
else
return this._private.autounselectify;
return this;
},
selectionType: function(e) {
var r = this._private;
if (r.selectionType == null && (r.selectionType = jp), e !== void 0)
(e === "additive" || e === "single") && (r.selectionType = e);
else
return r.selectionType;
return this;
},
panningEnabled: function(e) {
if (e !== void 0)
this._private.panningEnabled = !!e;
else
return this._private.panningEnabled;
return this;
},
userPanningEnabled: function(e) {
if (e !== void 0)
this._private.userPanningEnabled = !!e;
else
return this._private.userPanningEnabled;
return this;
},
zoomingEnabled: function(e) {
if (e !== void 0)
this._private.zoomingEnabled = !!e;
else
return this._private.zoomingEnabled;
return this;
},
userZoomingEnabled: function(e) {
if (e !== void 0)
this._private.userZoomingEnabled = !!e;
else
return this._private.userZoomingEnabled;
return this;
},
boxSelectionEnabled: function(e) {
if (e !== void 0)
this._private.boxSelectionEnabled = !!e;
else
return this._private.boxSelectionEnabled;
return this;
},
pan: function() {
var e = arguments, r = this._private.pan, a, n, i, s, o;
switch (e.length) {
case 0:
return r;
case 1:
if (ge(e[0]))
return a = e[0], r[a];
if (Oe(e[0])) {
if (!this._private.panningEnabled)
return this;
i = e[0], s = i.x, o = i.y, ne(s) && (r.x = s), ne(o) && (r.y = o), this.emit("pan viewport");
}
break;
case 2:
if (!this._private.panningEnabled)
return this;
a = e[0], n = e[1], (a === "x" || a === "y") && ne(n) && (r[a] = n), this.emit("pan viewport");
break;
}
return this.notify("viewport"), this;
},
panBy: function(e, r) {
var a = arguments, n = this._private.pan, i, s, o, u, l;
if (!this._private.panningEnabled)
return this;
switch (a.length) {
case 1:
Oe(e) && (o = a[0], u = o.x, l = o.y, ne(u) && (n.x += u), ne(l) && (n.y += l), this.emit("pan viewport"));
break;
case 2:
i = e, s = r, (i === "x" || i === "y") && ne(s) && (n[i] += s), this.emit("pan viewport");
break;
}
return this.notify("viewport"), this;
},
gc: function() {
this.notify("gc");
},
fit: function(e, r) {
var a = this.getFitViewport(e, r);
if (a) {
var n = this._private;
n.zoom = a.zoom, n.pan = a.pan, this.emit("pan zoom viewport"), this.notify("viewport");
}
return this;
},
getFitViewport: function(e, r) {
if (ne(e) && r === void 0 && (r = e, e = void 0), !(!this._private.panningEnabled || !this._private.zoomingEnabled)) {
var a;
if (ge(e)) {
var n = e;
e = this.$(n);
} else if (Vv(e)) {
var i = e;
a = {
x1: i.x1,
y1: i.y1,
x2: i.x2,
y2: i.y2
}, a.w = a.x2 - a.x1, a.h = a.y2 - a.y1;
} else
Lt(e) || (e = this.mutableElements());
if (!(Lt(e) && e.empty())) {
a = a || e.boundingBox();
var s = this.width(), o = this.height(), u;
if (r = ne(r) ? r : 0, !isNaN(s) && !isNaN(o) && s > 0 && o > 0 && !isNaN(a.w) && !isNaN(a.h) && a.w > 0 && a.h > 0) {
u = Math.min((s - 2 * r) / a.w, (o - 2 * r) / a.h), u = u > this._private.maxZoom ? this._private.maxZoom : u, u = u < this._private.minZoom ? this._private.minZoom : u;
var l = {
// now pan to middle
x: (s - u * (a.x1 + a.x2)) / 2,
y: (o - u * (a.y1 + a.y2)) / 2
};
return {
zoom: u,
pan: l
};
}
}
}
},
zoomRange: function(e, r) {
var a = this._private;
if (r == null) {
var n = e;
e = n.min, r = n.max;
}
return ne(e) && ne(r) && e <= r ? (a.minZoom = e, a.maxZoom = r) : ne(e) && r === void 0 && e <= a.maxZoom ? a.minZoom = e : ne(r) && e === void 0 && r >= a.minZoom && (a.maxZoom = r), this;
},
minZoom: function(e) {
return e === void 0 ? this._private.minZoom : this.zoomRange({
min: e
});
},
maxZoom: function(e) {
return e === void 0 ? this._private.maxZoom : this.zoomRange({
max: e
});
},
getZoomedViewport: function(e) {
var r = this._private, a = r.pan, n = r.zoom, i, s, o = !1;
if (r.zoomingEnabled || (o = !0), ne(e) ? s = e : Oe(e) && (s = e.level, e.position != null ? i = zn(e.position, n, a) : e.renderedPosition != null && (i = e.renderedPosition), i != null && !r.panningEnabled && (o = !0)), s = s > r.maxZoom ? r.maxZoom : s, s = s < r.minZoom ? r.minZoom : s, o || !ne(s) || s === n || i != null && (!ne(i.x) || !ne(i.y)))
return null;
if (i != null) {
var u = a, l = n, f = s, c = {
x: -f / l * (i.x - u.x) + i.x,
y: -f / l * (i.y - u.y) + i.y
};
return {
zoomed: !0,
panned: !0,
zoom: f,
pan: c
};
} else
return {
zoomed: !0,
panned: !1,
zoom: s,
pan: a
};
},
zoom: function(e) {
if (e === void 0)
return this._private.zoom;
var r = this.getZoomedViewport(e), a = this._private;
return r == null || !r.zoomed ? this : (a.zoom = r.zoom, r.panned && (a.pan.x = r.pan.x, a.pan.y = r.pan.y), this.emit("zoom" + (r.panned ? " pan" : "") + " viewport"), this.notify("viewport"), this);
},
viewport: function(e) {
var r = this._private, a = !0, n = !0, i = [], s = !1, o = !1;
if (!e)
return this;
if (ne(e.zoom) || (a = !1), Oe(e.pan) || (n = !1), !a && !n)
return this;
if (a) {
var u = e.zoom;
u < r.minZoom || u > r.maxZoom || !r.zoomingEnabled ? s = !0 : (r.zoom = u, i.push("zoom"));
}
if (n && (!s || !e.cancelOnFailedZoom) && r.panningEnabled) {
var l = e.pan;
ne(l.x) && (r.pan.x = l.x, o = !1), ne(l.y) && (r.pan.y = l.y, o = !1), o || i.push("pan");
}
return i.length > 0 && (i.push("viewport"), this.emit(i.join(" ")), this.notify("viewport")), this;
},
center: function(e) {
var r = this.getCenterPan(e);
return r && (this._private.pan = r, this.emit("pan viewport"), this.notify("viewport")), this;
},
getCenterPan: function(e, r) {
if (this._private.panningEnabled) {
if (ge(e)) {
var a = e;
e = this.mutableElements().filter(a);
} else
Lt(e) || (e = this.mutableElements());
if (e.length !== 0) {
var n = e.boundingBox(), i = this.width(), s = this.height();
r = r === void 0 ? this._private.zoom : r;
var o = {
// middle
x: (i - r * (n.x1 + n.x2)) / 2,
y: (s - r * (n.y1 + n.y2)) / 2
};
return o;
}
}
},
reset: function() {
return !this._private.panningEnabled || !this._private.zoomingEnabled ? this : (this.viewport({
pan: {
x: 0,
y: 0
},
zoom: 1
}), this);
},
invalidateSize: function() {
this._private.sizeCache = null;
},
size: function() {
var e = this._private, r = e.container, a = this;
return e.sizeCache = e.sizeCache || (r ? function() {
var n = a.window().getComputedStyle(r), i = function(o) {
return parseFloat(n.getPropertyValue(o));
};
return {
width: r.clientWidth - i("padding-left") - i("padding-right"),
height: r.clientHeight - i("padding-top") - i("padding-bottom")
};
}() : {
// fallback if no container (not 0 b/c can be used for dividing etc)
width: 1,
height: 1
});
},
width: function() {
return this.size().width;
},
height: function() {
return this.size().height;
},
extent: function() {
var e = this._private.pan, r = this._private.zoom, a = this.renderedExtent(), n = {
x1: (a.x1 - e.x) / r,
x2: (a.x2 - e.x) / r,
y1: (a.y1 - e.y) / r,
y2: (a.y2 - e.y) / r
};
return n.w = n.x2 - n.x1, n.h = n.y2 - n.y1, n;
},
renderedExtent: function() {
var e = this.width(), r = this.height();
return {
x1: 0,
y1: 0,
x2: e,
y2: r,
w: e,
h: r
};
},
multiClickDebounceTime: function(e) {
if (e)
this._private.multiClickDebounceTime = e;
else
return this._private.multiClickDebounceTime;
return this;
}
};
Or.centre = Or.center;
Or.autolockNodes = Or.autolock;
Or.autoungrabifyNodes = Or.autoungrabify;
var Oa = {
data: _e.data({
field: "data",
bindingEvent: "data",
allowBinding: !0,
allowSetting: !0,
settingEvent: "data",
settingTriggersEvent: !0,
triggerFnName: "trigger",
allowGetting: !0,
updateStyle: !0
}),
removeData: _e.removeData({
field: "data",
event: "data",
triggerFnName: "trigger",
triggerEvent: !0,
updateStyle: !0
}),
scratch: _e.data({
field: "scratch",
bindingEvent: "scratch",
allowBinding: !0,
allowSetting: !0,
settingEvent: "scratch",
settingTriggersEvent: !0,
triggerFnName: "trigger",
allowGetting: !0,
updateStyle: !0
}),
removeScratch: _e.removeData({
field: "scratch",
event: "scratch",
triggerFnName: "trigger",
triggerEvent: !0,
updateStyle: !0
})
};
Oa.attr = Oa.data;
Oa.removeAttr = Oa.removeData;
var ka = function(e) {
var r = this;
e = be({}, e);
var a = e.container;
a && !Cn(a) && Cn(a[0]) && (a = a[0]);
var n = a ? a._cyreg : null;
n = n || {}, n && n.cy && (n.cy.destroy(), n = {});
var i = n.readies = n.readies || [];
a && (a._cyreg = n), n.cy = r;
var s = tt !== void 0 && a !== void 0 && !e.headless, o = e;
o.layout = be({
name: s ? "grid" : "null"
}, o.layout), o.renderer = be({
name: s ? "canvas" : "null"
}, o.renderer);
var u = function(d, p, g) {
return p !== void 0 ? p : g !== void 0 ? g : d;
}, l = this._private = {
container: a,
// html dom ele container
ready: !1,
// whether ready has been triggered
options: o,
// cached options
elements: new vt(this),
// elements in the graph
listeners: [],
// list of listeners
aniEles: new vt(this),
// elements being animated
data: o.data || {},
// data for the core
scratch: {},
// scratch object for core
layout: null,
renderer: null,
destroyed: !1,
// whether destroy was called
notificationsEnabled: !0,
// whether notifications are sent to the renderer
minZoom: 1e-50,
maxZoom: 1e50,
zoomingEnabled: u(!0, o.zoomingEnabled),
userZoomingEnabled: u(!0, o.userZoomingEnabled),
panningEnabled: u(!0, o.panningEnabled),
userPanningEnabled: u(!0, o.userPanningEnabled),
boxSelectionEnabled: u(!0, o.boxSelectionEnabled),
autolock: u(!1, o.autolock, o.autolockNodes),
autoungrabify: u(!1, o.autoungrabify, o.autoungrabifyNodes),
autounselectify: u(!1, o.autounselectify),
styleEnabled: o.styleEnabled === void 0 ? s : o.styleEnabled,
zoom: ne(o.zoom) ? o.zoom : 1,
pan: {
x: Oe(o.pan) && ne(o.pan.x) ? o.pan.x : 0,
y: Oe(o.pan) && ne(o.pan.y) ? o.pan.y : 0
},
animation: {
// object for currently-running animations
current: [],
queue: []
},
hasCompoundNodes: !1,
multiClickDebounceTime: u(250, o.multiClickDebounceTime)
};
this.createEmitter(), this.selectionType(o.selectionType), this.zoomRange({
min: o.minZoom,
max: o.maxZoom
});
var f = function(d, p) {
var g = d.some(Uv);
if (g)
return ia.all(d).then(p);
p(d);
};
l.styleEnabled && r.setStyle([]);
var c = be({}, o, o.renderer);
r.initRenderer(c);
var v = function(d, p, g) {
r.notifications(!1);
var y = r.mutableElements();
y.length > 0 && y.remove(), d != null && (Oe(d) || Ve(d)) && r.add(d), r.one("layoutready", function(m) {
r.notifications(!0), r.emit(m), r.one("load", p), r.emitAndNotify("load");
}).one("layoutstop", function() {
r.one("done", g), r.emit("done");
});
var b = be({}, r._private.options.layout);
b.eles = r.elements(), r.layout(b).run();
};
f([o.style, o.elements], function(h) {
var d = h[0], p = h[1];
l.styleEnabled && r.style().append(d), v(p, function() {
r.startAnimationLoop(), l.ready = !0, Xe(o.ready) && r.on("ready", o.ready);
for (var g = 0; g < i.length; g++) {
var y = i[g];
r.on("ready", y);
}
n && (n.readies = []), r.emit("ready");
}, o.done);
});
}, Pn = ka.prototype;
be(Pn, {
instanceString: function() {
return "core";
},
isReady: function() {
return this._private.ready;
},
destroyed: function() {
return this._private.destroyed;
},
ready: function(e) {
return this.isReady() ? this.emitter().emit("ready", [], e) : this.on("ready", e), this;
},
destroy: function() {
var e = this;
if (!e.destroyed())
return e.stopAnimationLoop(), e.destroyRenderer(), this.emit("destroy"), e._private.destroyed = !0, e;
},
hasElementWithId: function(e) {
return this._private.elements.hasElementWithId(e);
},
getElementById: function(e) {
return this._private.elements.getElementById(e);
},
hasCompoundNodes: function() {
return this._private.hasCompoundNodes;
},
headless: function() {
return this._private.renderer.isHeadless();
},
styleEnabled: function() {
return this._private.styleEnabled;
},
addToPool: function(e) {
return this._private.elements.merge(e), this;
},
removeFromPool: function(e) {
return this._private.elements.unmerge(e), this;
},
container: function() {
return this._private.container || null;
},
window: function() {
var e = this._private.container;
if (e == null)
return tt;
var r = this._private.container.ownerDocument;
return r === void 0 || r == null ? tt : r.defaultView || tt;
},
mount: function(e) {
if (e != null) {
var r = this, a = r._private, n = a.options;
return !Cn(e) && Cn(e[0]) && (e = e[0]), r.stopAnimationLoop(), r.destroyRenderer(), a.container = e, a.styleEnabled = !0, r.invalidateSize(), r.initRenderer(be({}, n, n.renderer, {
// allow custom renderer name to be re-used, otherwise use canvas
name: n.renderer.name === "null" ? "canvas" : n.renderer.name
})), r.startAnimationLoop(), r.style(n.style), r.emit("mount"), r;
}
},
unmount: function() {
var e = this;
return e.stopAnimationLoop(), e.destroyRenderer(), e.initRenderer({
name: "null"
}), e.emit("unmount"), e;
},
options: function() {
return Ut(this._private.options);
},
json: function(e) {
var r = this, a = r._private, n = r.mutableElements(), i = function(E) {
return r.getElementById(E.id());
};
if (Oe(e)) {
if (r.startBatch(), e.elements) {
var s = {}, o = function(E, T) {
for (var S = [], w = [], x = 0; x < E.length; x++) {
var C = E[x];
if (!C.data.id) {
Ge("cy.json() cannot handle elements without an ID attribute");
continue;
}
var D = "" + C.data.id, A = r.getElementById(D);
s[D] = !0, A.length !== 0 ? w.push({
ele: A,
json: C
}) : (T && (C.group = T), S.push(C));
}
r.add(S);
for (var L = 0; L < w.length; L++) {
var R = w[L], I = R.ele, M = R.json;
I.json(M);
}
};
if (Ve(e.elements))
o(e.elements);
else
for (var u = ["nodes", "edges"], l = 0; l < u.length; l++) {
var f = u[l], c = e.elements[f];
Ve(c) && o(c, f);
}
var v = r.collection();
n.filter(function(m) {
return !s[m.id()];
}).forEach(function(m) {
m.isParent() ? v.merge(m) : m.remove();
}), v.forEach(function(m) {
return m.children().move({
parent: null
});
}), v.forEach(function(m) {
return i(m).remove();
});
}
e.style && r.style(e.style), e.zoom != null && e.zoom !== a.zoom && r.zoom(e.zoom), e.pan && (e.pan.x !== a.pan.x || e.pan.y !== a.pan.y) && r.pan(e.pan), e.data && r.data(e.data);
for (var h = ["minZoom", "maxZoom", "zoomingEnabled", "userZoomingEnabled", "panningEnabled", "userPanningEnabled", "boxSelectionEnabled", "autolock", "autoungrabify", "autounselectify", "multiClickDebounceTime"], d = 0; d < h.length; d++) {
var p = h[d];
e[p] != null && r[p](e[p]);
}
return r.endBatch(), this;
} else {
var g = !!e, y = {};
g ? y.elements = this.elements().map(function(m) {
return m.json();
}) : (y.elements = {}, n.forEach(function(m) {
var E = m.group();
y.elements[E] || (y.elements[E] = []), y.elements[E].push(m.json());
})), this._private.styleEnabled && (y.style = r.style().json()), y.data = Ut(r.data());
var b = a.options;
return y.zoomingEnabled = a.zoomingEnabled, y.userZoomingEnabled = a.userZoomingEnabled, y.zoom = a.zoom, y.minZoom = a.minZoom, y.maxZoom = a.maxZoom, y.panningEnabled = a.panningEnabled, y.userPanningEnabled = a.userPanningEnabled, y.pan = Ut(a.pan), y.boxSelectionEnabled = a.boxSelectionEnabled, y.renderer = Ut(b.renderer), y.hideEdgesOnViewport = b.hideEdgesOnViewport, y.textureOnViewport = b.textureOnViewport, y.wheelSensitivity = b.wheelSensitivity, y.motionBlur = b.motionBlur, y.multiClickDebounceTime = b.multiClickDebounceTime, y;
}
}
});
Pn.$id = Pn.getElementById;
[Up, $p, pc, Ys, pn, Kp, Hs, yn, Jp, Or, Oa].forEach(function(t) {
be(Pn, t);
});
var ey = {
fit: !0,
// whether to fit the viewport to the graph
directed: !1,
// whether the tree is directed downwards (or edges can point in any direction if false)
direction: "downward",
// determines the direction in which the tree structure is drawn. The possible values are 'downward', 'upward', 'rightward', or 'leftward'.
padding: 30,
// padding on fit
circle: !1,
// put depths in concentric circles if true, put depths top down if false
grid: !1,
// whether to create an even grid into which the DAG is placed (circle:false only)
spacingFactor: 1.75,
// positive spacing factor, larger => more space between nodes (N.B. n/a if causes overlap)
boundingBox: void 0,
// constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h }
avoidOverlap: !0,
// prevents node overlap, may overflow boundingBox if not enough space
nodeDimensionsIncludeLabels: !1,
// Excludes the label when calculating node bounding boxes for the layout algorithm
roots: void 0,
// the roots of the trees
depthSort: void 0,
// a sorting function to order nodes at equal depth. e.g. function(a, b){ return a.data('weight') - b.data('weight') }
animate: !1,
// whether to transition the node positions
animationDuration: 500,
// duration of animation in ms if enabled
animationEasing: void 0,
// easing of animation if enabled,
animateFilter: function(e, r) {
return !0;
},
// a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts
ready: void 0,
// callback on layoutready
stop: void 0,
// callback on layoutstop
transform: function(e, r) {
return r;
}
// transform a given node position. Useful for changing flow direction in discrete layouts
}, ty = {
maximal: !1,
// whether to shift nodes down their natural BFS depths in order to avoid upwards edges (DAGS only); setting acyclic to true sets maximal to true also
acyclic: !1
// whether the tree is acyclic and thus a node could be shifted (due to the maximal option) multiple times without causing an infinite loop; setting to true sets maximal to true also; if you are uncertain whether a tree is acyclic, set to false to avoid potential infinite loops
}, Ur = function(e) {
return e.scratch("breadthfirst");
}, Nl = function(e, r) {
return e.scratch("breadthfirst", r);
};
function yc(t) {
this.options = be({}, ey, ty, t);
}
yc.prototype.run = function() {
var t = this.options, e = t.cy, r = t.eles, a = r.nodes().filter(function(ye) {
return ye.isChildless();
}), n = r, i = t.directed, s = t.acyclic || t.maximal || t.maximalAdjustments > 0, o = !!t.boundingBox, u = Et(o ? t.boundingBox : structuredClone(e.extent())), l;
if (Lt(t.roots))
l = t.roots;
else if (Ve(t.roots)) {
for (var f = [], c = 0; c < t.roots.length; c++) {
var v = t.roots[c], h = e.getElementById(v);
f.push(h);
}
l = e.collection(f);
} else if (ge(t.roots))
l = e.$(t.roots);
else if (i)
l = a.roots();
else {
var d = r.components();
l = e.collection();
for (var p = function() {
var ie = d[g], he = ie.maxDegree(!1), de = ie.filter(function(xe) {
return xe.degree(!1) === he;
});
l = l.add(de);
}, g = 0; g < d.length; g++)
p();
}
var y = [], b = {}, m = function(ie, he) {
y[he] == null && (y[he] = []);
var de = y[he].length;
y[he].push(ie), Nl(ie, {
index: de,
depth: he
});
}, E = function(ie, he) {
var de = Ur(ie), xe = de.depth, pe = de.index;
y[xe][pe] = null, ie.isChildless() && m(ie, he);
};
n.bfs({
roots: l,
directed: t.directed,
visit: function(ie, he, de, xe, pe) {
var De = ie[0], Pe = De.id();
De.isChildless() && m(De, pe), b[Pe] = !0;
}
});
for (var T = [], S = 0; S < a.length; S++) {
var w = a[S];
b[w.id()] || T.push(w);
}
var x = function(ie) {
for (var he = y[ie], de = 0; de < he.length; de++) {
var xe = he[de];
if (xe == null) {
he.splice(de, 1), de--;
continue;
}
Nl(xe, {
depth: ie,
index: de
});
}
}, C = function(ie, he) {
for (var de = Ur(ie), xe = ie.incomers().filter(function(Ee) {
return Ee.isNode() && r.has(Ee);
}), pe = -1, De = ie.id(), Pe = 0; Pe < xe.length; Pe++) {
var Ne = xe[Pe], Be = Ur(Ne);
pe = Math.max(pe, Be.depth);
}
if (de.depth <= pe) {
if (!t.acyclic && he[De])
return null;
var Fe = pe + 1;
return E(ie, Fe), he[De] = Fe, !0;
}
return !1;
};
if (i && s) {
var D = [], A = {}, L = function(ie) {
return D.push(ie);
}, R = function() {
return D.shift();
};
for (a.forEach(function(ye) {
return D.push(ye);
}); D.length > 0; ) {
var I = R(), M = C(I, A);
if (M)
I.outgoers().filter(function(ye) {
return ye.isNode() && r.has(ye);
}).forEach(L);
else if (M === null) {
Ge("Detected double maximal shift for node `" + I.id() + "`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.");
break;
}
}
}
var N = 0;
if (t.avoidOverlap)
for (var O = 0; O < a.length; O++) {
var k = a[O], B = k.layoutDimensions(t), _ = B.w, F = B.h;
N = Math.max(N, _, F);
}
var G = {}, H = function(ie) {
if (G[ie.id()])
return G[ie.id()];
for (var he = Ur(ie).depth, de = ie.neighborhood(), xe = 0, pe = 0, De = 0; De < de.length; De++) {
var Pe = de[De];
if (!(Pe.isEdge() || Pe.isParent() || !a.has(Pe))) {
var Ne = Ur(Pe);
if (Ne != null) {
var Be = Ne.index, Fe = Ne.depth;
if (!(Be == null || Fe == null)) {
var Ee = y[Fe].length;
Fe < he && (xe += Be / Ee, pe++);
}
}
}
}
return pe = Math.max(1, pe), xe = xe / pe, pe === 0 && (xe = 0), G[ie.id()] = xe, xe;
}, Y = function(ie, he) {
var de = H(ie), xe = H(he), pe = de - xe;
return pe === 0 ? mf(ie.id(), he.id()) : pe;
};
t.depthSort !== void 0 && (Y = t.depthSort);
for (var X = y.length, W = 0; W < X; W++)
y[W].sort(Y), x(W);
for (var ee = [], ae = 0; ae < T.length; ae++)
ee.push(T[ae]);
var J = function() {
for (var ie = 0; ie < X; ie++)
x(ie);
};
ee.length && (y.unshift(ee), X = y.length, J());
for (var z = 0, V = 0; V < X; V++)
z = Math.max(y[V].length, z);
var q = {
x: u.x1 + u.w / 2,
y: u.y1 + u.h / 2
}, Z = a.reduce(function(ye, ie) {
return function(he) {
return {
w: ye.w === -1 ? he.w : (ye.w + he.w) / 2,
h: ye.h === -1 ? he.h : (ye.h + he.h) / 2
};
}(ie.boundingBox({
includeLabels: t.nodeDimensionsIncludeLabels
}));
}, {
w: -1,
h: -1
}), re = Math.max(
// only one depth
X === 1 ? 0 : (
// inside a bounding box, no need for top & bottom padding
o ? (u.h - t.padding * 2 - Z.h) / (X - 1) : (u.h - t.padding * 2 - Z.h) / (X + 1)
),
N
), ve = y.reduce(function(ye, ie) {
return Math.max(ye, ie.length);
}, 0), Ie = function(ie) {
var he = Ur(ie), de = he.depth, xe = he.index;
if (t.circle) {
var pe = Math.min(u.w / 2 / X, u.h / 2 / X);
pe = Math.max(pe, N);
var De = pe * de + pe - (X > 0 && y[0].length <= 3 ? pe / 2 : 0), Pe = 2 * Math.PI / y[de].length * xe;
return de === 0 && y[0].length === 1 && (De = 1), {
x: q.x + De * Math.cos(Pe),
y: q.y + De * Math.sin(Pe)
};
} else {
var Ne = y[de].length, Be = Math.max(
// only one depth
Ne === 1 ? 0 : (
// inside a bounding box, no need for left & right padding
o ? (u.w - t.padding * 2 - Z.w) / ((t.grid ? ve : Ne) - 1) : (u.w - t.padding * 2 - Z.w) / ((t.grid ? ve : Ne) + 1)
),
N
), Fe = {
x: q.x + (xe + 1 - (Ne + 1) / 2) * Be,
y: q.y + (de + 1 - (X + 1) / 2) * re
};
return Fe;
}
}, Te = {
downward: 0,
leftward: 90,
upward: 180,
rightward: -90
};
Object.keys(Te).indexOf(t.direction) === -1 && He("Invalid direction '".concat(t.direction, "' specified for breadthfirst layout. Valid values are: ").concat(Object.keys(Te).join(", ")));
var we = function(ie) {
return yh(Ie(ie), u, Te[t.direction]);
};
return r.nodes().layoutPositions(this, t, we), this;
};
var ry = {
fit: !0,
// whether to fit the viewport to the graph
padding: 30,
// the padding on fit
boundingBox: void 0,
// constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h }
avoidOverlap: !0,
// prevents node overlap, may overflow boundingBox and radius if not enough space
nodeDimensionsIncludeLabels: !1,
// Excludes the label when calculating node bounding boxes for the layout algorithm
spacingFactor: void 0,
// Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up
radius: void 0,
// the radius of the circle
startAngle: 3 / 2 * Math.PI,
// where nodes start in radians
sweep: void 0,
// how many radians should be between the first and last node (defaults to full circle)
clockwise: !0,
// whether the layout should go clockwise (true) or counterclockwise/anticlockwise (false)
sort: void 0,
// a sorting function to order the nodes; e.g. function(a, b){ return a.data('weight') - b.data('weight') }
animate: !1,
// whether to transition the node positions
animationDuration: 500,
// duration of animation in ms if enabled
animationEasing: void 0,
// easing of animation if enabled
animateFilter: function(e, r) {
return !0;
},
// a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts
ready: void 0,
// callback on layoutready
stop: void 0,
// callback on layoutstop
transform: function(e, r) {
return r;
}
// transform a given node position. Useful for changing flow direction in discrete layouts
};
function mc(t) {
this.options = be({}, ry, t);
}
mc.prototype.run = function() {
var t = this.options, e = t, r = t.cy, a = e.eles, n = e.counterclockwise !== void 0 ? !e.counterclockwise : e.clockwise, i = a.nodes().not(":parent");
e.sort && (i = i.sort(e.sort));
for (var s = Et(e.boundingBox ? e.boundingBox : {
x1: 0,
y1: 0,
w: r.width(),
h: r.height()
}), o = {
x: s.x1 + s.w / 2,
y: s.y1 + s.h / 2
}, u = e.sweep === void 0 ? 2 * Math.PI - 2 * Math.PI / i.length : e.sweep, l = u / Math.max(1, i.length - 1), f, c = 0, v = 0; v < i.length; v++) {
var h = i[v], d = h.layoutDimensions(e), p = d.w, g = d.h;
c = Math.max(c, p, g);
}
if (ne(e.radius) ? f = e.radius : i.length <= 1 ? f = 0 : f = Math.min(s.h, s.w) / 2 - c, i.length > 1 && e.avoidOverlap) {
c *= 1.75;
var y = Math.cos(l) - Math.cos(0), b = Math.sin(l) - Math.sin(0), m = Math.sqrt(c * c / (y * y + b * b));
f = Math.max(m, f);
}
var E = function(S, w) {
var x = e.startAngle + w * l * (n ? 1 : -1), C = f * Math.cos(x), D = f * Math.sin(x), A = {
x: o.x + C,
y: o.y + D
};
return A;
};
return a.nodes().layoutPositions(this, e, E), this;
};
var ay = {
fit: !0,
// whether to fit the viewport to the graph
padding: 30,
// the padding on fit
startAngle: 3 / 2 * Math.PI,
// where nodes start in radians
sweep: void 0,
// how many radians should be between the first and last node (defaults to full circle)
clockwise: !0,
// whether the layout should go clockwise (true) or counterclockwise/anticlockwise (false)
equidistant: !1,
// whether levels have an equal radial distance betwen them, may cause bounding box overflow
minNodeSpacing: 10,
// min spacing between outside of nodes (used for radius adjustment)
boundingBox: void 0,
// constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h }
avoidOverlap: !0,
// prevents node overlap, may overflow boundingBox if not enough space
nodeDimensionsIncludeLabels: !1,
// Excludes the label when calculating node bounding boxes for the layout algorithm
height: void 0,
// height of layout area (overrides container height)
width: void 0,
// width of layout area (overrides container width)
spacingFactor: void 0,
// Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up
concentric: function(e) {
return e.degree();
},
levelWidth: function(e) {
return e.maxDegree() / 4;
},
animate: !1,
// whether to transition the node positions
animationDuration: 500,
// duration of animation in ms if enabled
animationEasing: void 0,
// easing of animation if enabled
animateFilter: function(e, r) {
return !0;
},
// a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts
ready: void 0,
// callback on layoutready
stop: void 0,
// callback on layoutstop
transform: function(e, r) {
return r;
}
// transform a given node position. Useful for changing flow direction in discrete layouts
};
function bc(t) {
this.options = be({}, ay, t);
}
bc.prototype.run = function() {
for (var t = this.options, e = t, r = e.counterclockwise !== void 0 ? !e.counterclockwise : e.clockwise, a = t.cy, n = e.eles, i = n.nodes().not(":parent"), s = Et(e.boundingBox ? e.boundingBox : {
x1: 0,
y1: 0,
w: a.width(),
h: a.height()
}), o = {
x: s.x1 + s.w / 2,
y: s.y1 + s.h / 2
}, u = [], l = 0, f = 0; f < i.length; f++) {
var c = i[f], v = void 0;
v = e.concentric(c), u.push({
value: v,
node: c
}), c._private.scratch.concentric = v;
}
i.updateStyle();
for (var h = 0; h < i.length; h++) {
var d = i[h], p = d.layoutDimensions(e);
l = Math.max(l, p.w, p.h);
}
u.sort(function(re, ve) {
return ve.value - re.value;
});
for (var g = e.levelWidth(i), y = [[]], b = y[0], m = 0; m < u.length; m++) {
var E = u[m];
if (b.length > 0) {
var T = Math.abs(b[0].value - E.value);
T >= g && (b = [], y.push(b));
}
b.push(E);
}
var S = l + e.minNodeSpacing;
if (!e.avoidOverlap) {
var w = y.length > 0 && y[0].length > 1, x = Math.min(s.w, s.h) / 2 - S, C = x / (y.length + w ? 1 : 0);
S = Math.min(S, C);
}
for (var D = 0, A = 0; A < y.length; A++) {
var L = y[A], R = e.sweep === void 0 ? 2 * Math.PI - 2 * Math.PI / L.length : e.sweep, I = L.dTheta = R / Math.max(1, L.length - 1);
if (L.length > 1 && e.avoidOverlap) {
var M = Math.cos(I) - Math.cos(0), N = Math.sin(I) - Math.sin(0), O = Math.sqrt(S * S / (M * M + N * N));
D = Math.max(O, D);
}
L.r = D, D += S;
}
if (e.equidistant) {
for (var k = 0, B = 0, _ = 0; _ < y.length; _++) {
var F = y[_], G = F.r - B;
k = Math.max(k, G);
}
B = 0;
for (var H = 0; H < y.length; H++) {
var Y = y[H];
H === 0 && (B = Y.r), Y.r = B, B += k;
}
}
for (var X = {}, W = 0; W < y.length; W++)
for (var ee = y[W], ae = ee.dTheta, J = ee.r, z = 0; z < ee.length; z++) {
var V = ee[z], q = e.startAngle + (r ? 1 : -1) * ae * z, Z = {
x: o.x + J * Math.cos(q),
y: o.y + J * Math.sin(q)
};
X[V.node.id()] = Z;
}
return n.nodes().layoutPositions(this, e, function(re) {
var ve = re.id();
return X[ve];
}), this;
};
var Cs, ny = {
// Called on `layoutready`
ready: function() {
},
// Called on `layoutstop`
stop: function() {
},
// Whether to animate while running the layout
// true : Animate continuously as the layout is running
// false : Just show the end result
// 'end' : Animate with the end result, from the initial positions to the end positions
animate: !0,
// Easing of the animation for animate:'end'
animationEasing: void 0,
// The duration of the animation for animate:'end'
animationDuration: void 0,
// A function that determines whether the node should be animated
// All nodes animated by default on animate enabled
// Non-animated nodes are positioned immediately when the layout starts
animateFilter: function(e, r) {
return !0;
},
// The layout animates only after this many milliseconds for animate:true
// (prevents flashing on fast runs)
animationThreshold: 250,
// Number of iterations between consecutive screen positions update
refresh: 20,
// Whether to fit the network view after when done
fit: !0,
// Padding on fit
padding: 30,
// Constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h }
boundingBox: void 0,
// Excludes the label when calculating node bounding boxes for the layout algorithm
nodeDimensionsIncludeLabels: !1,
// Randomize the initial positions of the nodes (true) or use existing positions (false)
randomize: !1,
// Extra spacing between components in non-compound graphs
componentSpacing: 40,
// Node repulsion (non overlapping) multiplier
nodeRepulsion: function(e) {
return 2048;
},
// Node repulsion (overlapping) multiplier
nodeOverlap: 4,
// Ideal edge (non nested) length
idealEdgeLength: function(e) {
return 32;
},
// Divisor to compute edge forces
edgeElasticity: function(e) {
return 32;
},
// Nesting factor (multiplier) to compute ideal edge length for nested edges
nestingFactor: 1.2,
// Gravity force (constant)
gravity: 1,
// Maximum number of iterations to perform
numIter: 1e3,
// Initial temperature (maximum node displacement)
initialTemp: 1e3,
// Cooling factor (how the temperature is reduced between consecutive iterations
coolingFactor: 0.99,
// Lower temperature threshold (below this point the layout will end)
minTemp: 1
};
function Jn(t) {
this.options = be({}, ny, t), this.options.layout = this;
var e = this.options.eles.nodes(), r = this.options.eles.edges(), a = r.filter(function(n) {
var i = n.source().data("id"), s = n.target().data("id"), o = e.some(function(l) {
return l.data("id") === i;
}), u = e.some(function(l) {
return l.data("id") === s;
});
return !o || !u;
});
this.options.eles = this.options.eles.not(a);
}
Jn.prototype.run = function() {
var t = this.options, e = t.cy, r = this;
r.stopped = !1, (t.animate === !0 || t.animate === !1) && r.emit({
type: "layoutstart",
layout: r
}), t.debug === !0 ? Cs = !0 : Cs = !1;
var a = iy(e, r, t);
Cs && oy(a), t.randomize && uy(a);
var n = Qt(), i = function() {
ly(a, e, t), t.fit === !0 && e.fit(t.padding);
}, s = function(v) {
return !(r.stopped || v >= t.numIter || (fy(a, t), a.temperature = a.temperature * t.coolingFactor, a.temperature < t.minTemp));
}, o = function() {
if (t.animate === !0 || t.animate === !1)
i(), r.one("layoutstop", t.stop), r.emit({
type: "layoutstop",
layout: r
});
else {
var v = t.eles.nodes(), h = Ec(a, t, v);
v.layoutPositions(r, t, h);
}
}, u = 0, l = !0;
if (t.animate === !0) {
var f = function() {
for (var v = 0; l && v < t.refresh; )
l = s(u), u++, v++;
if (!l)
Fl(a, t), o();
else {
var h = Qt();
h - n >= t.animationThreshold && i(), Dn(f);
}
};
f();
} else {
for (; l; )
l = s(u), u++;
Fl(a, t), o();
}
return this;
};
Jn.prototype.stop = function() {
return this.stopped = !0, this.thread && this.thread.stop(), this.emit("layoutstop"), this;
};
Jn.prototype.destroy = function() {
return this.thread && this.thread.stop(), this;
};
var iy = function(e, r, a) {
for (var n = a.eles.edges(), i = a.eles.nodes(), s = Et(a.boundingBox ? a.boundingBox : {
x1: 0,
y1: 0,
w: e.width(),
h: e.height()
}), o = {
isCompound: e.hasCompoundNodes(),
layoutNodes: [],
idToIndex: {},
nodeSize: i.size(),
graphSet: [],
indexToGraph: [],
layoutEdges: [],
edgeSize: n.size(),
temperature: a.initialTemp,
clientWidth: s.w,
clientHeight: s.h,
boundingBox: s
}, u = a.eles.components(), l = {}, f = 0; f < u.length; f++)
for (var c = u[f], v = 0; v < c.length; v++) {
var h = c[v];
l[h.id()] = f;
}
for (var f = 0; f < o.nodeSize; f++) {
var d = i[f], p = d.layoutDimensions(a), g = {};
g.isLocked = d.locked(), g.id = d.data("id"), g.parentId = d.data("parent"), g.cmptId = l[d.id()], g.children = [], g.positionX = d.position("x"), g.positionY = d.position("y"), g.offsetX = 0, g.offsetY = 0, g.height = p.w, g.width = p.h, g.maxX = g.positionX + g.width / 2, g.minX = g.positionX - g.width / 2, g.maxY = g.positionY + g.height / 2, g.minY = g.positionY - g.height / 2, g.padLeft = parseFloat(d.style("padding")), g.padRight = parseFloat(d.style("padding")), g.padTop = parseFloat(d.style("padding")), g.padBottom = parseFloat(d.style("padding")), g.nodeRepulsion = Xe(a.nodeRepulsion) ? a.nodeRepulsion(d) : a.nodeRepulsion, o.layoutNodes.push(g), o.idToIndex[g.id] = f;
}
for (var y = [], b = 0, m = -1, E = [], f = 0; f < o.nodeSize; f++) {
var d = o.layoutNodes[f], T = d.parentId;
T != null ? o.layoutNodes[o.idToIndex[T]].children.push(d.id) : (y[++m] = d.id, E.push(d.id));
}
for (o.graphSet.push(E); b <= m; ) {
var S = y[b++], w = o.idToIndex[S], h = o.layoutNodes[w], x = h.children;
if (x.length > 0) {
o.graphSet.push(x);
for (var f = 0; f < x.length; f++)
y[++m] = x[f];
}
}
for (var f = 0; f < o.graphSet.length; f++)
for (var C = o.graphSet[f], v = 0; v < C.length; v++) {
var D = o.idToIndex[C[v]];
o.indexToGraph[D] = f;
}
for (var f = 0; f < o.edgeSize; f++) {
var A = n[f], L = {};
L.id = A.data("id"), L.sourceId = A.data("source"), L.targetId = A.data("target");
var R = Xe(a.idealEdgeLength) ? a.idealEdgeLength(A) : a.idealEdgeLength, I = Xe(a.edgeElasticity) ? a.edgeElasticity(A) : a.edgeElasticity, M = o.idToIndex[L.sourceId], N = o.idToIndex[L.targetId], O = o.indexToGraph[M], k = o.indexToGraph[N];
if (O != k) {
for (var B = sy(L.sourceId, L.targetId, o), _ = o.graphSet[B], F = 0, g = o.layoutNodes[M]; _.indexOf(g.id) === -1; )
g = o.layoutNodes[o.idToIndex[g.parentId]], F++;
for (g = o.layoutNodes[N]; _.indexOf(g.id) === -1; )
g = o.layoutNodes[o.idToIndex[g.parentId]], F++;
R *= F * a.nestingFactor;
}
L.idealLength = R, L.elasticity = I, o.layoutEdges.push(L);
}
return o;
}, sy = function(e, r, a) {
var n = wc(e, r, 0, a);
return 2 > n.count ? 0 : n.graph;
}, wc = function(e, r, a, n) {
var i = n.graphSet[a];
if (-1 < i.indexOf(e) && -1 < i.indexOf(r))
return {
count: 2,
graph: a
};
for (var s = 0, o = 0; o < i.length; o++) {
var u = i[o], l = n.idToIndex[u], f = n.layoutNodes[l].children;
if (f.length !== 0) {
var c = n.indexToGraph[n.idToIndex[f[0]]], v = wc(e, r, c, n);
if (v.count !== 0)
if (v.count === 1) {
if (s++, s === 2)
break;
} else
return v;
}
}
return {
count: s,
graph: a
};
}, oy, uy = function(e, r) {
for (var a = e.clientWidth, n = e.clientHeight, i = 0; i < e.nodeSize; i++) {
var s = e.layoutNodes[i];
s.children.length === 0 && !s.isLocked && (s.positionX = Math.random() * a, s.positionY = Math.random() * n);
}
}, Ec = function(e, r, a) {
var n = e.boundingBox, i = {
x1: 1 / 0,
x2: -1 / 0,
y1: 1 / 0,
y2: -1 / 0
};
return r.boundingBox && (a.forEach(function(s) {
var o = e.layoutNodes[e.idToIndex[s.data("id")]];
i.x1 = Math.min(i.x1, o.positionX), i.x2 = Math.max(i.x2, o.positionX), i.y1 = Math.min(i.y1, o.positionY), i.y2 = Math.max(i.y2, o.positionY);
}), i.w = i.x2 - i.x1, i.h = i.y2 - i.y1), function(s, o) {
var u = e.layoutNodes[e.idToIndex[s.data("id")]];
if (r.boundingBox) {
var l = i.w === 0 ? 0.5 : (u.positionX - i.x1) / i.w, f = i.h === 0 ? 0.5 : (u.positionY - i.y1) / i.h;
return {
x: n.x1 + l * n.w,
y: n.y1 + f * n.h
};
} else
return {
x: u.positionX,
y: u.positionY
};
};
}, ly = function(e, r, a) {
var n = a.layout, i = a.eles.nodes(), s = Ec(e, a, i);
i.positions(s), e.ready !== !0 && (e.ready = !0, n.one("layoutready", a.ready), n.emit({
type: "layoutready",
layout: this
}));
}, fy = function(e, r, a) {
cy(e, r), dy(e), gy(e, r), py(e), yy(e);
}, cy = function(e, r) {
for (var a = 0; a < e.graphSet.length; a++)
for (var n = e.graphSet[a], i = n.length, s = 0; s < i; s++)
for (var o = e.layoutNodes[e.idToIndex[n[s]]], u = s + 1; u < i; u++) {
var l = e.layoutNodes[e.idToIndex[n[u]]];
vy(o, l, e, r);
}
}, Bl = function(e) {
return -1 + 2 * e * Math.random();
}, vy = function(e, r, a, n) {
var i = e.cmptId, s = r.cmptId;
if (!(i !== s && !a.isCompound)) {
var o = r.positionX - e.positionX, u = r.positionY - e.positionY, l = 1;
o === 0 && u === 0 && (o = Bl(l), u = Bl(l));
var f = hy(e, r, o, u);
if (f > 0)
var c = n.nodeOverlap * f, v = Math.sqrt(o * o + u * u), h = c * o / v, d = c * u / v;
else
var p = Mn(e, o, u), g = Mn(r, -1 * o, -1 * u), y = g.x - p.x, b = g.y - p.y, m = y * y + b * b, v = Math.sqrt(m), c = (e.nodeRepulsion + r.nodeRepulsion) / m, h = c * y / v, d = c * b / v;
e.isLocked || (e.offsetX -= h, e.offsetY -= d), r.isLocked || (r.offsetX += h, r.offsetY += d);
}
}, hy = function(e, r, a, n) {
if (a > 0)
var i = e.maxX - r.minX;
else
var i = r.maxX - e.minX;
if (n > 0)
var s = e.maxY - r.minY;
else
var s = r.maxY - e.minY;
return i >= 0 && s >= 0 ? Math.sqrt(i * i + s * s) : 0;
}, Mn = function(e, r, a) {
var n = e.positionX, i = e.positionY, s = e.height || 1, o = e.width || 1, u = a / r, l = s / o, f = {};
return r === 0 && 0 < a || r === 0 && 0 > a ? (f.x = n, f.y = i + s / 2, f) : 0 < r && -1 * l <= u && u <= l ? (f.x = n + o / 2, f.y = i + o * a / 2 / r, f) : 0 > r && -1 * l <= u && u <= l ? (f.x = n - o / 2, f.y = i - o * a / 2 / r, f) : 0 < a && (u <= -1 * l || u >= l) ? (f.x = n + s * r / 2 / a, f.y = i + s / 2, f) : (0 > a && (u <= -1 * l || u >= l) && (f.x = n - s * r / 2 / a, f.y = i - s / 2), f);
}, dy = function(e, r) {
for (var a = 0; a < e.edgeSize; a++) {
var n = e.layoutEdges[a], i = e.idToIndex[n.sourceId], s = e.layoutNodes[i], o = e.idToIndex[n.targetId], u = e.layoutNodes[o], l = u.positionX - s.positionX, f = u.positionY - s.positionY;
if (!(l === 0 && f === 0)) {
var c = Mn(s, l, f), v = Mn(u, -1 * l, -1 * f), h = v.x - c.x, d = v.y - c.y, p = Math.sqrt(h * h + d * d), g = Math.pow(n.idealLength - p, 2) / n.elasticity;
if (p !== 0)
var y = g * h / p, b = g * d / p;
else
var y = 0, b = 0;
s.isLocked || (s.offsetX += y, s.offsetY += b), u.isLocked || (u.offsetX -= y, u.offsetY -= b);
}
}
}, gy = function(e, r) {
if (r.gravity !== 0)
for (var a = 1, n = 0; n < e.graphSet.length; n++) {
var i = e.graphSet[n], s = i.length;
if (n === 0)
var o = e.clientHeight / 2, u = e.clientWidth / 2;
else
var l = e.layoutNodes[e.idToIndex[i[0]]], f = e.layoutNodes[e.idToIndex[l.parentId]], o = f.positionX, u = f.positionY;
for (var c = 0; c < s; c++) {
var v = e.layoutNodes[e.idToIndex[i[c]]];
if (!v.isLocked) {
var h = o - v.positionX, d = u - v.positionY, p = Math.sqrt(h * h + d * d);
if (p > a) {
var g = r.gravity * h / p, y = r.gravity * d / p;
v.offsetX += g, v.offsetY += y;
}
}
}
}
}, py = function(e, r) {
var a = [], n = 0, i = -1;
for (a.push.apply(a, e.graphSet[0]), i += e.graphSet[0].length; n <= i; ) {
var s = a[n++], o = e.idToIndex[s], u = e.layoutNodes[o], l = u.children;
if (0 < l.length && !u.isLocked) {
for (var f = u.offsetX, c = u.offsetY, v = 0; v < l.length; v++) {
var h = e.layoutNodes[e.idToIndex[l[v]]];
h.offsetX += f, h.offsetY += c, a[++i] = l[v];
}
u.offsetX = 0, u.offsetY = 0;
}
}
}, yy = function(e, r) {
for (var a = 0; a < e.nodeSize; a++) {
var n = e.layoutNodes[a];
0 < n.children.length && (n.maxX = void 0, n.minX = void 0, n.maxY = void 0, n.minY = void 0);
}
for (var a = 0; a < e.nodeSize; a++) {
var n = e.layoutNodes[a];
if (!(0 < n.children.length || n.isLocked)) {
var i = my(n.offsetX, n.offsetY, e.temperature);
n.positionX += i.x, n.positionY += i.y, n.offsetX = 0, n.offsetY = 0, n.minX = n.positionX - n.width, n.maxX = n.positionX + n.width, n.minY = n.positionY - n.height, n.maxY = n.positionY + n.height, xc(n, e);
}
}
for (var a = 0; a < e.nodeSize; a++) {
var n = e.layoutNodes[a];
0 < n.children.length && !n.isLocked && (n.positionX = (n.maxX + n.minX) / 2, n.positionY = (n.maxY + n.minY) / 2, n.width = n.maxX - n.minX, n.height = n.maxY - n.minY);
}
}, my = function(e, r, a) {
var n = Math.sqrt(e * e + r * r);
if (n > a)
var i = {
x: a * e / n,
y: a * r / n
};
else
var i = {
x: e,
y: r
};
return i;
}, xc = function(e, r) {
var a = e.parentId;
if (a != null) {
var n = r.layoutNodes[r.idToIndex[a]], i = !1;
if ((n.maxX == null || e.maxX + n.padRight > n.maxX) && (n.maxX = e.maxX + n.padRight, i = !0), (n.minX == null || e.minX - n.padLeft < n.minX) && (n.minX = e.minX - n.padLeft, i = !0), (n.maxY == null || e.maxY + n.padBottom > n.maxY) && (n.maxY = e.maxY + n.padBottom, i = !0), (n.minY == null || e.minY - n.padTop < n.minY) && (n.minY = e.minY - n.padTop, i = !0), i)
return xc(n, r);
}
}, Fl = function(e, r) {
for (var a = e.layoutNodes, n = [], i = 0; i < a.length; i++) {
var s = a[i], o = s.cmptId, u = n[o] = n[o] || [];
u.push(s);
}
for (var l = 0, i = 0; i < n.length; i++) {
var f = n[i];
if (f) {
f.x1 = 1 / 0, f.x2 = -1 / 0, f.y1 = 1 / 0, f.y2 = -1 / 0;
for (var c = 0; c < f.length; c++) {
var v = f[c];
f.x1 = Math.min(f.x1, v.positionX - v.width / 2), f.x2 = Math.max(f.x2, v.positionX + v.width / 2), f.y1 = Math.min(f.y1, v.positionY - v.height / 2), f.y2 = Math.max(f.y2, v.positionY + v.height / 2);
}
f.w = f.x2 - f.x1, f.h = f.y2 - f.y1, l += f.w * f.h;
}
}
n.sort(function(b, m) {
return m.w * m.h - b.w * b.h;
});
for (var h = 0, d = 0, p = 0, g = 0, y = Math.sqrt(l) * e.clientWidth / e.clientHeight, i = 0; i < n.length; i++) {
var f = n[i];
if (f) {
for (var c = 0; c < f.length; c++) {
var v = f[c];
v.isLocked || (v.positionX += h - f.x1, v.positionY += d - f.y1);
}
h += f.w + r.componentSpacing, p += f.w + r.componentSpacing, g = Math.max(g, f.h), p > y && (d += g + r.componentSpacing, h = 0, p = 0, g = 0);
}
}
}, by = {
fit: !0,
// whether to fit the viewport to the graph
padding: 30,
// padding used on fit
boundingBox: void 0,
// constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h }
avoidOverlap: !0,
// prevents node overlap, may overflow boundingBox if not enough space
avoidOverlapPadding: 10,
// extra spacing around nodes when avoidOverlap: true
nodeDimensionsIncludeLabels: !1,
// Excludes the label when calculating node bounding boxes for the layout algorithm
spacingFactor: void 0,
// Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up
condense: !1,
// uses all available space on false, uses minimal space on true
rows: void 0,
// force num of rows in the grid
cols: void 0,
// force num of columns in the grid
position: function(e) {
},
// returns { row, col } for element
sort: void 0,
// a sorting function to order the nodes; e.g. function(a, b){ return a.data('weight') - b.data('weight') }
animate: !1,
// whether to transition the node positions
animationDuration: 500,
// duration of animation in ms if enabled
animationEasing: void 0,
// easing of animation if enabled
animateFilter: function(e, r) {
return !0;
},
// a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts
ready: void 0,
// callback on layoutready
stop: void 0,
// callback on layoutstop
transform: function(e, r) {
return r;
}
// transform a given node position. Useful for changing flow direction in discrete layouts
};
function Tc(t) {
this.options = be({}, by, t);
}
Tc.prototype.run = function() {
var t = this.options, e = t, r = t.cy, a = e.eles, n = a.nodes().not(":parent");
e.sort && (n = n.sort(e.sort));
var i = Et(e.boundingBox ? e.boundingBox : {
x1: 0,
y1: 0,
w: r.width(),
h: r.height()
});
if (i.h === 0 || i.w === 0)
a.nodes().layoutPositions(this, e, function(H) {
return {
x: i.x1,
y: i.y1
};
});
else {
var s = n.size(), o = Math.sqrt(s * i.h / i.w), u = Math.round(o), l = Math.round(i.w / i.h * o), f = function(Y) {
if (Y == null)
return Math.min(u, l);
var X = Math.min(u, l);
X == u ? u = Y : l = Y;
}, c = function(Y) {
if (Y == null)
return Math.max(u, l);
var X = Math.max(u, l);
X == u ? u = Y : l = Y;
}, v = e.rows, h = e.cols != null ? e.cols : e.columns;
if (v != null && h != null)
u = v, l = h;
else if (v != null && h == null)
u = v, l = Math.ceil(s / u);
else if (v == null && h != null)
l = h, u = Math.ceil(s / l);
else if (l * u > s) {
var d = f(), p = c();
(d - 1) * p >= s ? f(d - 1) : (p - 1) * d >= s && c(p - 1);
} else
for (; l * u < s; ) {
var g = f(), y = c();
(y + 1) * g >= s ? c(y + 1) : f(g + 1);
}
var b = i.w / l, m = i.h / u;
if (e.condense && (b = 0, m = 0), e.avoidOverlap)
for (var E = 0; E < n.length; E++) {
var T = n[E], S = T._private.position;
(S.x == null || S.y == null) && (S.x = 0, S.y = 0);
var w = T.layoutDimensions(e), x = e.avoidOverlapPadding, C = w.w + x, D = w.h + x;
b = Math.max(b, C), m = Math.max(m, D);
}
for (var A = {}, L = function(Y, X) {
return !!A["c-" + Y + "-" + X];
}, R = function(Y, X) {
A["c-" + Y + "-" + X] = !0;
}, I = 0, M = 0, N = function() {
M++, M >= l && (M = 0, I++);
}, O = {}, k = 0; k < n.length; k++) {
var B = n[k], _ = e.position(B);
if (_ && (_.row !== void 0 || _.col !== void 0)) {
var F = {
row: _.row,
col: _.col
};
if (F.col === void 0)
for (F.col = 0; L(F.row, F.col); )
F.col++;
else if (F.row === void 0)
for (F.row = 0; L(F.row, F.col); )
F.row++;
O[B.id()] = F, R(F.row, F.col);
}
}
var G = function(Y, X) {
var W, ee;
if (Y.locked() || Y.isParent())
return !1;
var ae = O[Y.id()];
if (ae)
W = ae.col * b + b / 2 + i.x1, ee = ae.row * m + m / 2 + i.y1;
else {
for (; L(I, M); )
N();
W = M * b + b / 2 + i.x1, ee = I * m + m / 2 + i.y1, R(I, M), N();
}
return {
x: W,
y: ee
};
};
n.layoutPositions(this, e, G);
}
return this;
};
var wy = {
ready: function() {
},
// on layoutready
stop: function() {
}
// on layoutstop
};
function Co(t) {
this.options = be({}, wy, t);
}
Co.prototype.run = function() {
var t = this.options, e = t.eles, r = this;
return t.cy, r.emit("layoutstart"), e.nodes().positions(function() {
return {
x: 0,
y: 0
};
}), r.one("layoutready", t.ready), r.emit("layoutready"), r.one("layoutstop", t.stop), r.emit("layoutstop"), this;
};
Co.prototype.stop = function() {
return this;
};
var Ey = {
positions: void 0,
// map of (node id) => (position obj); or function(node){ return somPos; }
zoom: void 0,
// the zoom level to set (prob want fit = false if set)
pan: void 0,
// the pan level to set (prob want fit = false if set)
fit: !0,
// whether to fit to viewport
padding: 30,
// padding on fit
spacingFactor: void 0,
// Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up
animate: !1,
// whether to transition the node positions
animationDuration: 500,
// duration of animation in ms if enabled
animationEasing: void 0,
// easing of animation if enabled
animateFilter: function(e, r) {
return !0;
},
// a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts
ready: void 0,
// callback on layoutready
stop: void 0,
// callback on layoutstop
transform: function(e, r) {
return r;
}
// transform a given node position. Useful for changing flow direction in discrete layouts
};
function Cc(t) {
this.options = be({}, Ey, t);
}
Cc.prototype.run = function() {
var t = this.options, e = t.eles, r = e.nodes(), a = Xe(t.positions);
function n(i) {
if (t.positions == null)
return qh(i.position());
if (a)
return t.positions(i);
var s = t.positions[i._private.data.id];
return s ?? null;
}
return r.layoutPositions(this, t, function(i, s) {
var o = n(i);
return i.locked() || o == null ? !1 : o;
}), this;
};
var xy = {
fit: !0,
// whether to fit to viewport
padding: 30,
// fit padding
boundingBox: void 0,
// constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h }
animate: !1,
// whether to transition the node positions
animationDuration: 500,
// duration of animation in ms if enabled
animationEasing: void 0,
// easing of animation if enabled
animateFilter: function(e, r) {
return !0;
},
// a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts
ready: void 0,
// callback on layoutready
stop: void 0,
// callback on layoutstop
transform: function(e, r) {
return r;
}
// transform a given node position. Useful for changing flow direction in discrete layouts
};
function Dc(t) {
this.options = be({}, xy, t);
}
Dc.prototype.run = function() {
var t = this.options, e = t.cy, r = t.eles, a = Et(t.boundingBox ? t.boundingBox : {
x1: 0,
y1: 0,
w: e.width(),
h: e.height()
}), n = function(s, o) {
return {
x: a.x1 + Math.round(Math.random() * a.w),
y: a.y1 + Math.round(Math.random() * a.h)
};
};
return r.nodes().layoutPositions(this, t, n), this;
};
var Ty = [{
name: "breadthfirst",
impl: yc
}, {
name: "circle",
impl: mc
}, {
name: "concentric",
impl: bc
}, {
name: "cose",
impl: Jn
}, {
name: "grid",
impl: Tc
}, {
name: "null",
impl: Co
}, {
name: "preset",
impl: Cc
}, {
name: "random",
impl: Dc
}];
function Sc(t) {
this.options = t, this.notifications = 0;
}
var _l = function() {
}, Gl = function() {
throw new Error("A headless instance can not render images");
};
Sc.prototype = {
recalculateRenderedStyle: _l,
notify: function() {
this.notifications++;
},
init: _l,
isHeadless: function() {
return !0;
},
png: Gl,
jpg: Gl
};
var Do = {};
Do.arrowShapeWidth = 0.3;
Do.registerArrowShapes = function() {
var t = this.arrowShapes = {}, e = this, r = function(l, f, c, v, h, d, p) {
var g = h.x - c / 2 - p, y = h.x + c / 2 + p, b = h.y - c / 2 - p, m = h.y + c / 2 + p, E = g <= l && l <= y && b <= f && f <= m;
return E;
}, a = function(l, f, c, v, h) {
var d = l * Math.cos(v) - f * Math.sin(v), p = l * Math.sin(v) + f * Math.cos(v), g = d * c, y = p * c, b = g + h.x, m = y + h.y;
return {
x: b,
y: m
};
}, n = function(l, f, c, v) {
for (var h = [], d = 0; d < l.length; d += 2) {
var p = l[d], g = l[d + 1];
h.push(a(p, g, f, c, v));
}
return h;
}, i = function(l) {
for (var f = [], c = 0; c < l.length; c++) {
var v = l[c];
f.push(v.x, v.y);
}
return f;
}, s = function(l) {
return l.pstyle("width").pfValue * l.pstyle("arrow-scale").pfValue * 2;
}, o = function(l, f) {
ge(f) && (f = t[f]), t[l] = be({
name: l,
points: [-0.15, -0.3, 0.15, -0.3, 0.15, 0.3, -0.15, 0.3],
collide: function(v, h, d, p, g, y) {
var b = i(n(this.points, d + 2 * y, p, g)), m = St(v, h, b);
return m;
},
roughCollide: r,
draw: function(v, h, d, p) {
var g = n(this.points, h, d, p);
e.arrowShapeImpl("polygon")(v, g);
},
spacing: function(v) {
return 0;
},
gap: s
}, f);
};
o("none", {
collide: Sn,
roughCollide: Sn,
draw: lo,
spacing: jo,
gap: jo
}), o("triangle", {
points: [-0.15, -0.3, 0, 0, 0.15, -0.3]
}), o("arrow", "triangle"), o("triangle-backcurve", {
points: t.triangle.points,
controlPoint: [0, -0.15],
roughCollide: r,
draw: function(l, f, c, v, h) {
var d = n(this.points, f, c, v), p = this.controlPoint, g = a(p[0], p[1], f, c, v);
e.arrowShapeImpl(this.name)(l, d, g);
},
gap: function(l) {
return s(l) * 0.8;
}
}), o("triangle-tee", {
points: [0, 0, 0.15, -0.3, -0.15, -0.3, 0, 0],
pointsTee: [-0.15, -0.4, -0.15, -0.5, 0.15, -0.5, 0.15, -0.4],
collide: function(l, f, c, v, h, d, p) {
var g = i(n(this.points, c + 2 * p, v, h)), y = i(n(this.pointsTee, c + 2 * p, v, h)), b = St(l, f, g) || St(l, f, y);
return b;
},
draw: function(l, f, c, v, h) {
var d = n(this.points, f, c, v), p = n(this.pointsTee, f, c, v);
e.arrowShapeImpl(this.name)(l, d, p);
}
}), o("circle-triangle", {
radius: 0.15,
pointsTr: [0, -0.15, 0.15, -0.45, -0.15, -0.45, 0, -0.15],
collide: function(l, f, c, v, h, d, p) {
var g = h, y = Math.pow(g.x - l, 2) + Math.pow(g.y - f, 2) <= Math.pow((c + 2 * p) * this.radius, 2), b = i(n(this.points, c + 2 * p, v, h));
return St(l, f, b) || y;
},
draw: function(l, f, c, v, h) {
var d = n(this.pointsTr, f, c, v);
e.arrowShapeImpl(this.name)(l, d, v.x, v.y, this.radius * f);
},
spacing: function(l) {
return e.getArrowWidth(l.pstyle("width").pfValue, l.pstyle("arrow-scale").value) * this.radius;
}
}), o("triangle-cross", {
points: [0, 0, 0.15, -0.3, -0.15, -0.3, 0, 0],
baseCrossLinePts: [
-0.15,
-0.4,
// first half of the rectangle
-0.15,
-0.4,
0.15,
-0.4,
// second half of the rectangle
0.15,
-0.4
],
crossLinePts: function(l, f) {
var c = this.baseCrossLinePts.slice(), v = f / l, h = 3, d = 5;
return c[h] = c[h] - v, c[d] = c[d] - v, c;
},
collide: function(l, f, c, v, h, d, p) {
var g = i(n(this.points, c + 2 * p, v, h)), y = i(n(this.crossLinePts(c, d), c + 2 * p, v, h)), b = St(l, f, g) || St(l, f, y);
return b;
},
draw: function(l, f, c, v, h) {
var d = n(this.points, f, c, v), p = n(this.crossLinePts(f, h), f, c, v);
e.arrowShapeImpl(this.name)(l, d, p);
}
}), o("vee", {
points: [-0.15, -0.3, 0, 0, 0.15, -0.3, 0, -0.15],
gap: function(l) {
return s(l) * 0.525;
}
}), o("circle", {
radius: 0.15,
collide: function(l, f, c, v, h, d, p) {
var g = h, y = Math.pow(g.x - l, 2) + Math.pow(g.y - f, 2) <= Math.pow((c + 2 * p) * this.radius, 2);
return y;
},
draw: function(l, f, c, v, h) {
e.arrowShapeImpl(this.name)(l, v.x, v.y, this.radius * f);
},
spacing: function(l) {
return e.getArrowWidth(l.pstyle("width").pfValue, l.pstyle("arrow-scale").value) * this.radius;
}
}), o("tee", {
points: [-0.15, 0, -0.15, -0.1, 0.15, -0.1, 0.15, 0],
spacing: function(l) {
return 1;
},
gap: function(l) {
return 1;
}
}), o("square", {
points: [-0.15, 0, 0.15, 0, 0.15, -0.3, -0.15, -0.3]
}), o("diamond", {
points: [-0.15, -0.15, 0, -0.3, 0.15, -0.15, 0, 0],
gap: function(l) {
return l.pstyle("width").pfValue * l.pstyle("arrow-scale").value;
}
}), o("chevron", {
points: [0, 0, -0.15, -0.15, -0.1, -0.2, 0, -0.1, 0.1, -0.2, 0.15, -0.15],
gap: function(l) {
return 0.95 * l.pstyle("width").pfValue * l.pstyle("arrow-scale").value;
}
});
};
var Br = {};
Br.projectIntoViewport = function(t, e) {
var r = this.cy, a = this.findContainerClientCoords(), n = a[0], i = a[1], s = a[4], o = r.pan(), u = r.zoom(), l = ((t - n) / s - o.x) / u, f = ((e - i) / s - o.y) / u;
return [l, f];
};
Br.findContainerClientCoords = function() {
if (this.containerBB)
return this.containerBB;
var t = this.container, e = t.getBoundingClientRect(), r = this.cy.window().getComputedStyle(t), a = function(y) {
return parseFloat(r.getPropertyValue(y));
}, n = {
left: a("padding-left"),
right: a("padding-right"),
top: a("padding-top"),
bottom: a("padding-bottom")
}, i = {
left: a("border-left-width"),
right: a("border-right-width"),
top: a("border-top-width"),
bottom: a("border-bottom-width")
}, s = t.clientWidth, o = t.clientHeight, u = n.left + n.right, l = n.top + n.bottom, f = i.left + i.right, c = e.width / (s + f), v = s - u, h = o - l, d = e.left + n.left + i.left, p = e.top + n.top + i.top;
return this.containerBB = [d, p, v, h, c];
};
Br.invalidateContainerClientCoordsCache = function() {
this.containerBB = null;
};
Br.findNearestElement = function(t, e, r, a) {
return this.findNearestElements(t, e, r, a)[0];
};
Br.findNearestElements = function(t, e, r, a) {
var n = this, i = this, s = i.getCachedZSortedEles(), o = [], u = i.cy.zoom(), l = i.cy.hasCompoundNodes(), f = (a ? 24 : 8) / u, c = (a ? 8 : 2) / u, v = (a ? 8 : 2) / u, h = 1 / 0, d, p;
r && (s = s.interactive);
function g(w, x) {
if (w.isNode()) {
if (p)
return;
p = w, o.push(w);
}
if (w.isEdge() && (x == null || x < h))
if (d) {
if (d.pstyle("z-compound-depth").value === w.pstyle("z-compound-depth").value && d.pstyle("z-compound-depth").value === w.pstyle("z-compound-depth").value) {
for (var C = 0; C < o.length; C++)
if (o[C].isEdge()) {
o[C] = w, d = w, h = x ?? h;
break;
}
}
} else
o.push(w), d = w, h = x ?? h;
}
function y(w) {
var x = w.outerWidth() + 2 * c, C = w.outerHeight() + 2 * c, D = x / 2, A = C / 2, L = w.position(), R = w.pstyle("corner-radius").value === "auto" ? "auto" : w.pstyle("corner-radius").pfValue, I = w._private.rscratch;
if (L.x - D <= t && t <= L.x + D && L.y - A <= e && e <= L.y + A) {
var M = i.nodeShapes[n.getNodeShape(w)];
if (M.checkPoint(t, e, 0, x, C, L.x, L.y, R, I))
return g(w, 0), !0;
}
}
function b(w) {
var x = w._private, C = x.rscratch, D = w.pstyle("width").pfValue, A = w.pstyle("arrow-scale").value, L = D / 2 + f, R = L * L, I = L * 2, k = x.source, B = x.target, M;
if (C.edgeType === "segments" || C.edgeType === "straight" || C.edgeType === "haystack") {
for (var N = C.allpts, O = 0; O + 3 < N.length; O += 2)
if (ad(t, e, N[O], N[O + 1], N[O + 2], N[O + 3], I) && R > (M = ud(t, e, N[O], N[O + 1], N[O + 2], N[O + 3])))
return g(w, M), !0;
} else if (C.edgeType === "bezier" || C.edgeType === "multibezier" || C.edgeType === "self" || C.edgeType === "compound") {
for (var N = C.allpts, O = 0; O + 5 < C.allpts.length; O += 4)
if (nd(t, e, N[O], N[O + 1], N[O + 2], N[O + 3], N[O + 4], N[O + 5], I) && R > (M = od(t, e, N[O], N[O + 1], N[O + 2], N[O + 3], N[O + 4], N[O + 5])))
return g(w, M), !0;
}
for (var k = k || x.source, B = B || x.target, _ = n.getArrowWidth(D, A), F = [{
name: "source",
x: C.arrowStartX,
y: C.arrowStartY,
angle: C.srcArrowAngle
}, {
name: "target",
x: C.arrowEndX,
y: C.arrowEndY,
angle: C.tgtArrowAngle
}, {
name: "mid-source",
x: C.midX,
y: C.midY,
angle: C.midsrcArrowAngle
}, {
name: "mid-target",
x: C.midX,
y: C.midY,
angle: C.midtgtArrowAngle
}], O = 0; O < F.length; O++) {
var G = F[O], H = i.arrowShapes[w.pstyle(G.name + "-arrow-shape").value], Y = w.pstyle("width").pfValue;
if (H.roughCollide(t, e, _, G.angle, {
x: G.x,
y: G.y
}, Y, f) && H.collide(t, e, _, G.angle, {
x: G.x,
y: G.y
}, Y, f))
return g(w), !0;
}
l && o.length > 0 && (y(k), y(B));
}
function m(w, x, C) {
return Dt(w, x, C);
}
function E(w, x) {
var C = w._private, D = v, A;
x ? A = x + "-" : A = "", w.boundingBox();
var L = C.labelBounds[x || "main"], R = w.pstyle(A + "label").value, I = w.pstyle("text-events").strValue === "yes";
if (!(!I || !R)) {
var M = m(C.rscratch, "labelX", x), N = m(C.rscratch, "labelY", x), O = m(C.rscratch, "labelAngle", x), k = w.pstyle(A + "text-margin-x").pfValue, B = w.pstyle(A + "text-margin-y").pfValue, _ = L.x1 - D - k, F = L.x2 + D - k, G = L.y1 - D - B, H = L.y2 + D - B;
if (O) {
var Y = Math.cos(O), X = Math.sin(O), W = function(Z, re) {
return Z = Z - M, re = re - N, {
x: Z * Y - re * X + M,
y: Z * X + re * Y + N
};
}, ee = W(_, G), ae = W(_, H), J = W(F, G), z = W(F, H), V = [
// with the margin added after the rotation is applied
ee.x + k,
ee.y + B,
J.x + k,
J.y + B,
z.x + k,
z.y + B,
ae.x + k,
ae.y + B
];
if (St(t, e, V))
return g(w), !0;
} else if (sr(L, t, e))
return g(w), !0;
}
}
for (var T = s.length - 1; T >= 0; T--) {
var S = s[T];
S.isNode() ? y(S) || E(S) : b(S) || E(S) || E(S, "source") || E(S, "target");
}
return o;
};
Br.getAllInBox = function(t, e, r, a) {
var n = this.getCachedZSortedEles().interactive, i = this.cy.zoom(), s = 2 / i, o = [], u = Math.min(t, r), l = Math.max(t, r), f = Math.min(e, a), c = Math.max(e, a);
t = u, r = l, e = f, a = c;
var v = Et({
x1: t,
y1: e,
x2: r,
y2: a
}), h = [{
x: v.x1,
y: v.y1
}, {
x: v.x2,
y: v.y1
}, {
x: v.x2,
y: v.y2
}, {
x: v.x1,
y: v.y2
}], d = [[h[0], h[1]], [h[1], h[2]], [h[2], h[3]], [h[3], h[0]]];
function p(Z, re, ve) {
return Dt(Z, re, ve);
}
function g(Z, re) {
var ve = Z._private, Ie = s, Te = "";
Z.boundingBox();
var we = ve.labelBounds.main;
if (!we)
return null;
var ye = p(ve.rscratch, "labelX", re), ie = p(ve.rscratch, "labelY", re), he = p(ve.rscratch, "labelAngle", re), de = Z.pstyle(Te + "text-margin-x").pfValue, xe = Z.pstyle(Te + "text-margin-y").pfValue, pe = we.x1 - Ie - de, De = we.x2 + Ie - de, Pe = we.y1 - Ie - xe, Ne = we.y2 + Ie - xe;
if (he) {
var Be = Math.cos(he), Fe = Math.sin(he), Ee = function(Q, P) {
return Q = Q - ye, P = P - ie, {
x: Q * Be - P * Fe + ye,
y: Q * Fe + P * Be + ie
};
};
return [Ee(pe, Pe), Ee(De, Pe), Ee(De, Ne), Ee(pe, Ne)];
} else
return [{
x: pe,
y: Pe
}, {
x: De,
y: Pe
}, {
x: De,
y: Ne
}, {
x: pe,
y: Ne
}];
}
function y(Z, re, ve, Ie) {
function Te(we, ye, ie) {
return (ie.y - we.y) * (ye.x - we.x) > (ye.y - we.y) * (ie.x - we.x);
}
return Te(Z, ve, Ie) !== Te(re, ve, Ie) && Te(Z, re, ve) !== Te(Z, re, Ie);
}
for (var b = 0; b < n.length; b++) {
var m = n[b];
if (m.isNode()) {
var E = m, T = E.pstyle("text-events").strValue === "yes", S = E.pstyle("box-selection").strValue, w = E.pstyle("box-select-labels").strValue === "yes";
if (S === "none")
continue;
var x = (S === "overlap" || w) && T, C = E.boundingBox({
includeNodes: !0,
includeEdges: !1,
includeLabels: x
});
if (S === "contain") {
var D = !1;
if (w && T) {
var A = g(E);
A && xi(A, h) && (o.push(E), D = !0);
}
!D && Of(v, C) && o.push(E);
} else if (S === "overlap" && ho(v, C)) {
var L = E.boundingBox({
includeNodes: !0,
includeEdges: !0,
includeLabels: !1,
includeMainLabels: !1,
includeSourceLabels: !1,
includeTargetLabels: !1
}), R = [{
x: L.x1,
y: L.y1
}, {
x: L.x2,
y: L.y1
}, {
x: L.x2,
y: L.y2
}, {
x: L.x1,
y: L.y2
}];
if (xi(R, h))
o.push(E);
else {
var I = g(E);
I && xi(I, h) && o.push(E);
}
}
} else {
var M = m, N = M._private, O = N.rscratch, k = M.pstyle("box-selection").strValue;
if (k === "none")
continue;
if (k === "contain") {
if (O.startX != null && O.startY != null && !sr(v, O.startX, O.startY) || O.endX != null && O.endY != null && !sr(v, O.endX, O.endY))
continue;
if (O.edgeType === "bezier" || O.edgeType === "multibezier" || O.edgeType === "self" || O.edgeType === "compound" || O.edgeType === "segments" || O.edgeType === "haystack") {
for (var B = N.rstyle.bezierPts || N.rstyle.linePts || N.rstyle.haystackPts, _ = !0, F = 0; F < B.length; F++)
if (!nu(v, B[F])) {
_ = !1;
break;
}
_ && o.push(M);
} else
O.edgeType === "straight" && o.push(M);
} else if (k === "overlap") {
var G = !1;
if (O.startX != null && O.startY != null && O.endX != null && O.endY != null && (sr(v, O.startX, O.startY) || sr(v, O.endX, O.endY)))
o.push(M), G = !0;
else if (!G && O.edgeType === "haystack") {
for (var H = N.rstyle.haystackPts, Y = 0; Y < H.length; Y++)
if (nu(v, H[Y])) {
o.push(M), G = !0;
break;
}
}
if (!G) {
var X = N.rstyle.bezierPts || N.rstyle.linePts || N.rstyle.haystackPts;
if ((!X || X.length < 2) && O.edgeType === "straight" && O.startX != null && O.startY != null && O.endX != null && O.endY != null && (X = [{
x: O.startX,
y: O.startY
}, {
x: O.endX,
y: O.endY
}]), !X || X.length < 2)
continue;
for (var W = 0; W < X.length - 1; W++) {
for (var ee = X[W], ae = X[W + 1], J = 0; J < d.length; J++) {
var z = Je(d[J], 2), V = z[0], q = z[1];
if (y(ee, ae, V, q)) {
o.push(M), G = !0;
break;
}
}
if (G)
break;
}
}
}
}
}
return o;
};
var On = {};
On.calculateArrowAngles = function(t) {
var e = t._private.rscratch, r = e.edgeType === "haystack", a = e.edgeType === "bezier", n = e.edgeType === "multibezier", i = e.edgeType === "segments", s = e.edgeType === "compound", o = e.edgeType === "self", u, l, f, c, v, h, y, b;
if (r ? (f = e.haystackPts[0], c = e.haystackPts[1], v = e.haystackPts[2], h = e.haystackPts[3]) : (f = e.arrowStartX, c = e.arrowStartY, v = e.arrowEndX, h = e.arrowEndY), y = e.midX, b = e.midY, i)
u = f - e.segpts[0], l = c - e.segpts[1];
else if (n || s || o || a) {
var d = e.allpts, p = ot(d[0], d[2], d[4], 0.1), g = ot(d[1], d[3], d[5], 0.1);
u = f - p, l = c - g;
} else
u = f - y, l = c - b;
e.srcArrowAngle = Ja(u, l);
var y = e.midX, b = e.midY;
if (r && (y = (f + v) / 2, b = (c + h) / 2), u = v - f, l = h - c, i) {
var d = e.allpts;
if (d.length / 2 % 2 === 0) {
var m = d.length / 2, E = m - 2;
u = d[m] - d[E], l = d[m + 1] - d[E + 1];
} else if (e.isRound)
u = e.midVector[1], l = -e.midVector[0];
else {
var m = d.length / 2 - 1, E = m - 2;
u = d[m] - d[E], l = d[m + 1] - d[E + 1];
}
} else if (n || s || o) {
var d = e.allpts, T = e.ctrlpts, S, w, x, C;
if (T.length / 2 % 2 === 0) {
var D = d.length / 2 - 1, A = D + 2, L = A + 2;
S = ot(d[D], d[A], d[L], 0), w = ot(d[D + 1], d[A + 1], d[L + 1], 0), x = ot(d[D], d[A], d[L], 1e-4), C = ot(d[D + 1], d[A + 1], d[L + 1], 1e-4);
} else {
var A = d.length / 2 - 1, D = A - 2, L = A + 2;
S = ot(d[D], d[A], d[L], 0.4999), w = ot(d[D + 1], d[A + 1], d[L + 1], 0.4999), x = ot(d[D], d[A], d[L], 0.5), C = ot(d[D + 1], d[A + 1], d[L + 1], 0.5);
}
u = x - S, l = C - w;
}
if (e.midtgtArrowAngle = Ja(u, l), e.midDispX = u, e.midDispY = l, u *= -1, l *= -1, i) {
var d = e.allpts;
if (d.length / 2 % 2 !== 0) {
if (!e.isRound) {
var m = d.length / 2 - 1, R = m + 2;
u = -(d[R] - d[m]), l = -(d[R + 1] - d[m + 1]);
}
}
}
if (e.midsrcArrowAngle = Ja(u, l), i)
u = v - e.segpts[e.segpts.length - 2], l = h - e.segpts[e.segpts.length - 1];
else if (n || s || o || a) {
var d = e.allpts, I = d.length, p = ot(d[I - 6], d[I - 4], d[I - 2], 0.9), g = ot(d[I - 5], d[I - 3], d[I - 1], 0.9);
u = v - p, l = h - g;
} else
u = v - y, l = h - b;
e.tgtArrowAngle = Ja(u, l);
};
On.getArrowWidth = On.getArrowHeight = function(t, e) {
var r = this.arrowWidthCache = this.arrowWidthCache || {}, a = r[t + ", " + e];
return a || (a = Math.max(Math.pow(t * 13.37, 0.9), 29) * e, r[t + ", " + e] = a, a);
};
var Xs, $s, Vt = {}, It = {}, zl, Vl, Lr, mn, Wt, Tr, Sr, Gt, qr, on, Ac, Lc, Ws, Ks, Ul, ql = function(e, r, a) {
a.x = r.x - e.x, a.y = r.y - e.y, a.len = Math.sqrt(a.x * a.x + a.y * a.y), a.nx = a.x / a.len, a.ny = a.y / a.len, a.ang = Math.atan2(a.ny, a.nx);
}, Cy = function(e, r) {
r.x = e.x * -1, r.y = e.y * -1, r.nx = e.nx * -1, r.ny = e.ny * -1, r.ang = e.ang > 0 ? -(Math.PI - e.ang) : Math.PI + e.ang;
}, Dy = function(e, r, a, n, i) {
if (e !== Ul ? ql(r, e, Vt) : Cy(It, Vt), ql(r, a, It), zl = Vt.nx * It.ny - Vt.ny * It.nx, Vl = Vt.nx * It.nx - Vt.ny * -It.ny, Wt = Math.asin(Math.max(-1, Math.min(1, zl))), Math.abs(Wt) < 1e-6) {
Xs = r.x, $s = r.y, Sr = qr = 0;
return;
}
Lr = 1, mn = !1, Vl < 0 ? Wt < 0 ? Wt = Math.PI + Wt : (Wt = Math.PI - Wt, Lr = -1, mn = !0) : Wt > 0 && (Lr = -1, mn = !0), r.radius !== void 0 ? qr = r.radius : qr = n, Tr = Wt / 2, on = Math.min(Vt.len / 2, It.len / 2), i ? (Gt = Math.abs(Math.cos(Tr) * qr / Math.sin(Tr)), Gt > on ? (Gt = on, Sr = Math.abs(Gt * Math.sin(Tr) / Math.cos(Tr))) : Sr = qr) : (Gt = Math.min(on, qr), Sr = Math.abs(Gt * Math.sin(Tr) / Math.cos(Tr))), Ws = r.x + It.nx * Gt, Ks = r.y + It.ny * Gt, Xs = Ws - It.ny * Sr * Lr, $s = Ks + It.nx * Sr * Lr, Ac = r.x + Vt.nx * Gt, Lc = r.y + Vt.ny * Gt, Ul = r;
};
function Rc(t, e) {
e.radius === 0 ? t.lineTo(e.cx, e.cy) : t.arc(e.cx, e.cy, e.radius, e.startAngle, e.endAngle, e.counterClockwise);
}
function So(t, e, r, a) {
var n = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0;
return a === 0 || e.radius === 0 ? {
cx: e.x,
cy: e.y,
radius: 0,
startX: e.x,
startY: e.y,
stopX: e.x,
stopY: e.y,
startAngle: void 0,
endAngle: void 0,
counterClockwise: void 0
} : (Dy(t, e, r, a, n), {
cx: Xs,
cy: $s,
radius: Sr,
startX: Ac,
startY: Lc,
stopX: Ws,
stopY: Ks,
startAngle: Vt.ang + Math.PI / 2 * Lr,
endAngle: It.ang - Math.PI / 2 * Lr,
counterClockwise: mn
});
}
var Na = 0.01, Sy = Math.sqrt(2 * Na), mt = {};
mt.findMidptPtsEtc = function(t, e) {
var r = e.posPts, a = e.intersectionPts, n = e.vectorNormInverse, i, s = t.pstyle("source-endpoint"), o = t.pstyle("target-endpoint"), u = s.units != null && o.units != null, l = function(T, S, w, x) {
var C = x - S, D = w - T, A = Math.sqrt(D * D + C * C);
return {
x: -C / A,
y: D / A
};
}, f = t.pstyle("edge-distances").value;
switch (f) {
case "node-position":
i = r;
break;
case "intersection":
i = a;
break;
case "endpoints": {
if (u) {
var c = this.manualEndptToPx(t.source()[0], s), v = Je(c, 2), h = v[0], d = v[1], p = this.manualEndptToPx(t.target()[0], o), g = Je(p, 2), y = g[0], b = g[1], m = {
x1: h,
y1: d,
x2: y,
y2: b
};
n = l(h, d, y, b), i = m;
} else
Ge("Edge ".concat(t.id(), " has edge-distances:endpoints specified without manual endpoints specified via source-endpoint and target-endpoint. Falling back on edge-distances:intersection (default).")), i = a;
break;
}
}
return {
midptPts: i,
vectorNormInverse: n
};
};
mt.findHaystackPoints = function(t) {
for (var e = 0; e < t.length; e++) {
var r = t[e], a = r._private, n = a.rscratch;
if (!n.haystack) {
var i = Math.random() * 2 * Math.PI;
n.source = {
x: Math.cos(i),
y: Math.sin(i)
}, i = Math.random() * 2 * Math.PI, n.target = {
x: Math.cos(i),
y: Math.sin(i)
};
}
var s = a.source, o = a.target, u = s.position(), l = o.position(), f = s.width(), c = o.width(), v = s.height(), h = o.height(), d = r.pstyle("haystack-radius").value, p = d / 2;
n.haystackPts = n.allpts = [n.source.x * f * p + u.x, n.source.y * v * p + u.y, n.target.x * c * p + l.x, n.target.y * h * p + l.y], n.midX = (n.allpts[0] + n.allpts[2]) / 2, n.midY = (n.allpts[1] + n.allpts[3]) / 2, n.edgeType = "haystack", n.haystack = !0, this.storeEdgeProjections(r), this.calculateArrowAngles(r), this.recalculateEdgeLabelProjections(r), this.calculateLabelAngles(r);
}
};
mt.findSegmentsPoints = function(t, e) {
var r = t._private.rscratch, a = t.pstyle("segment-weights"), n = t.pstyle("segment-distances"), i = t.pstyle("segment-radii"), s = t.pstyle("radius-type"), o = Math.min(a.pfValue.length, n.pfValue.length), u = i.pfValue[i.pfValue.length - 1], l = s.pfValue[s.pfValue.length - 1];
r.edgeType = "segments", r.segpts = [], r.radii = [], r.isArcRadius = [];
for (var f = 0; f < o; f++) {
var c = a.pfValue[f], v = n.pfValue[f], h = 1 - c, d = c, p = this.findMidptPtsEtc(t, e), g = p.midptPts, y = p.vectorNormInverse, b = {
x: g.x1 * h + g.x2 * d,
y: g.y1 * h + g.y2 * d
};
r.segpts.push(b.x + y.x * v, b.y + y.y * v), r.radii.push(i.pfValue[f] !== void 0 ? i.pfValue[f] : u), r.isArcRadius.push((s.pfValue[f] !== void 0 ? s.pfValue[f] : l) === "arc-radius");
}
};
mt.findLoopPoints = function(t, e, r, a) {
var n = t._private.rscratch, i = e.dirCounts, s = e.srcPos, o = t.pstyle("control-point-distances"), u = o ? o.pfValue[0] : void 0, l = t.pstyle("loop-direction").pfValue, f = t.pstyle("loop-sweep").pfValue, c = t.pstyle("control-point-step-size").pfValue;
n.edgeType = "self";
var v = r, h = c;
a && (v = 0, h = u);
var d = l - Math.PI / 2, p = d - f / 2, g = d + f / 2, y = l + "_" + f;
v = i[y] === void 0 ? i[y] = 0 : ++i[y], n.ctrlpts = [s.x + Math.cos(p) * 1.4 * h * (v / 3 + 1), s.y + Math.sin(p) * 1.4 * h * (v / 3 + 1), s.x + Math.cos(g) * 1.4 * h * (v / 3 + 1), s.y + Math.sin(g) * 1.4 * h * (v / 3 + 1)];
};
mt.findCompoundLoopPoints = function(t, e, r, a) {
var n = t._private.rscratch;
n.edgeType = "compound";
var i = e.srcPos, s = e.tgtPos, o = e.srcW, u = e.srcH, l = e.tgtW, f = e.tgtH, c = t.pstyle("control-point-step-size").pfValue, v = t.pstyle("control-point-distances"), h = v ? v.pfValue[0] : void 0, d = r, p = c;
a && (d = 0, p = h);
var g = 50, y = {
x: i.x - o / 2,
y: i.y - u / 2
}, b = {
x: s.x - l / 2,
y: s.y - f / 2
}, m = {
x: Math.min(y.x, b.x),
y: Math.min(y.y, b.y)
}, E = 0.5, T = Math.max(E, Math.log(o * Na)), S = Math.max(E, Math.log(l * Na));
n.ctrlpts = [m.x, m.y - (1 + Math.pow(g, 1.12) / 100) * p * (d / 3 + 1) * T, m.x - (1 + Math.pow(g, 1.12) / 100) * p * (d / 3 + 1) * S, m.y];
};
mt.findStraightEdgePoints = function(t) {
t._private.rscratch.edgeType = "straight";
};
mt.findBezierPoints = function(t, e, r, a, n) {
var i = t._private.rscratch, s = t.pstyle("control-point-step-size").pfValue, o = t.pstyle("control-point-distances"), u = t.pstyle("control-point-weights"), l = o && u ? Math.min(o.value.length, u.value.length) : 1, f = o ? o.pfValue[0] : void 0, c = u.value[0], v = a;
i.edgeType = v ? "multibezier" : "bezier", i.ctrlpts = [];
for (var h = 0; h < l; h++) {
var d = (0.5 - e.eles.length / 2 + r) * s * (n ? -1 : 1), p = void 0, g = vo(d);
v && (f = o ? o.pfValue[h] : s, c = u.value[h]), a ? p = f : p = f !== void 0 ? g * f : void 0;
var y = p !== void 0 ? p : d, b = 1 - c, m = c, E = this.findMidptPtsEtc(t, e), T = E.midptPts, S = E.vectorNormInverse, w = {
x: T.x1 * b + T.x2 * m,
y: T.y1 * b + T.y2 * m
};
i.ctrlpts.push(w.x + S.x * y, w.y + S.y * y);
}
};
mt.findTaxiPoints = function(t, e) {
var r = t._private.rscratch;
r.edgeType = "segments";
var a = "vertical", n = "horizontal", i = "leftward", s = "rightward", o = "downward", u = "upward", l = "auto", f = e.posPts, c = e.srcW, v = e.srcH, h = e.tgtW, d = e.tgtH, p = t.pstyle("edge-distances").value, g = p !== "node-position", y = t.pstyle("taxi-direction").value, b = y, m = t.pstyle("taxi-turn"), E = m.units === "%", T = m.pfValue, S = T < 0, w = t.pstyle("taxi-turn-min-distance").pfValue, x = g ? (c + h) / 2 : 0, C = g ? (v + d) / 2 : 0, D = f.x2 - f.x1, A = f.y2 - f.y1, L = function(P, U) {
return P > 0 ? Math.max(P - U, 0) : Math.min(P + U, 0);
}, R = L(D, x), I = L(A, C), M = !1;
b === l ? y = Math.abs(R) > Math.abs(I) ? n : a : b === u || b === o ? (y = a, M = !0) : (b === i || b === s) && (y = n, M = !0);
var N = y === a, O = N ? I : R, k = N ? A : D, B = vo(k), _ = !1;
!(M && (E || S)) && (b === o && k < 0 || b === u && k > 0 || b === i && k > 0 || b === s && k < 0) && (B *= -1, O = B * Math.abs(O), _ = !0);
var F;
if (E) {
var G = T < 0 ? 1 + T : T;
F = G * O;
} else {
var H = T < 0 ? O : 0;
F = H + T * B;
}
var Y = function(P) {
return Math.abs(P) < w || Math.abs(P) >= Math.abs(O);
}, X = Y(F), W = Y(Math.abs(O) - Math.abs(F)), ee = X || W;
if (ee && !_)
if (N) {
var ae = Math.abs(k) <= v / 2, J = Math.abs(D) <= h / 2;
if (ae) {
var z = (f.x1 + f.x2) / 2, V = f.y1, q = f.y2;
r.segpts = [z, V, z, q];
} else if (J) {
var Z = (f.y1 + f.y2) / 2, re = f.x1, ve = f.x2;
r.segpts = [re, Z, ve, Z];
} else
r.segpts = [f.x1, f.y2];
} else {
var Ie = Math.abs(k) <= c / 2, Te = Math.abs(A) <= d / 2;
if (Ie) {
var we = (f.y1 + f.y2) / 2, ye = f.x1, ie = f.x2;
r.segpts = [ye, we, ie, we];
} else if (Te) {
var he = (f.x1 + f.x2) / 2, de = f.y1, xe = f.y2;
r.segpts = [he, de, he, xe];
} else
r.segpts = [f.x2, f.y1];
}
else if (N) {
var pe = f.y1 + F + (g ? v / 2 * B : 0), De = f.x1, Pe = f.x2;
r.segpts = [De, pe, Pe, pe];
} else {
var Ne = f.x1 + F + (g ? c / 2 * B : 0), Be = f.y1, Fe = f.y2;
r.segpts = [Ne, Be, Ne, Fe];
}
if (r.isRound) {
var Ee = t.pstyle("taxi-radius").value, ue = t.pstyle("radius-type").value[0] === "arc-radius";
r.radii = new Array(r.segpts.length / 2).fill(Ee), r.isArcRadius = new Array(r.segpts.length / 2).fill(ue);
}
};
mt.tryToCorrectInvalidPoints = function(t, e) {
var r = t._private.rscratch;
if (r.edgeType === "bezier") {
var a = e.srcPos, n = e.tgtPos, i = e.srcW, s = e.srcH, o = e.tgtW, u = e.tgtH, l = e.srcShape, f = e.tgtShape, c = e.srcCornerRadius, v = e.tgtCornerRadius, h = e.srcRs, d = e.tgtRs, p = !ne(r.startX) || !ne(r.startY), g = !ne(r.arrowStartX) || !ne(r.arrowStartY), y = !ne(r.endX) || !ne(r.endY), b = !ne(r.arrowEndX) || !ne(r.arrowEndY), m = 3, E = this.getArrowWidth(t.pstyle("width").pfValue, t.pstyle("arrow-scale").value) * this.arrowShapeWidth, T = m * E, S = Pr({
x: r.ctrlpts[0],
y: r.ctrlpts[1]
}, {
x: r.startX,
y: r.startY
}), w = S < T, x = Pr({
x: r.ctrlpts[0],
y: r.ctrlpts[1]
}, {
x: r.endX,
y: r.endY
}), C = x < T, D = !1;
if (p || g || w) {
D = !0;
var A = {
// delta
x: r.ctrlpts[0] - a.x,
y: r.ctrlpts[1] - a.y
}, L = Math.sqrt(A.x * A.x + A.y * A.y), R = {
// normalised delta
x: A.x / L,
y: A.y / L
}, I = Math.max(i, s), M = {
// *2 radius guarantees outside shape
x: r.ctrlpts[0] + R.x * 2 * I,
y: r.ctrlpts[1] + R.y * 2 * I
}, N = l.intersectLine(a.x, a.y, i, s, M.x, M.y, 0, c, h);
w ? (r.ctrlpts[0] = r.ctrlpts[0] + R.x * (T - S), r.ctrlpts[1] = r.ctrlpts[1] + R.y * (T - S)) : (r.ctrlpts[0] = N[0] + R.x * T, r.ctrlpts[1] = N[1] + R.y * T);
}
if (y || b || C) {
D = !0;
var O = {
// delta
x: r.ctrlpts[0] - n.x,
y: r.ctrlpts[1] - n.y
}, k = Math.sqrt(O.x * O.x + O.y * O.y), B = {
// normalised delta
x: O.x / k,
y: O.y / k
}, _ = Math.max(i, s), F = {
// *2 radius guarantees outside shape
x: r.ctrlpts[0] + B.x * 2 * _,
y: r.ctrlpts[1] + B.y * 2 * _
}, G = f.intersectLine(n.x, n.y, o, u, F.x, F.y, 0, v, d);
C ? (r.ctrlpts[0] = r.ctrlpts[0] + B.x * (T - x), r.ctrlpts[1] = r.ctrlpts[1] + B.y * (T - x)) : (r.ctrlpts[0] = G[0] + B.x * T, r.ctrlpts[1] = G[1] + B.y * T);
}
D && this.findEndpoints(t);
}
};
mt.storeAllpts = function(t) {
var e = t._private.rscratch;
if (e.edgeType === "multibezier" || e.edgeType === "bezier" || e.edgeType === "self" || e.edgeType === "compound") {
e.allpts = [], e.allpts.push(e.startX, e.startY);
for (var r = 0; r + 1 < e.ctrlpts.length; r += 2)
e.allpts.push(e.ctrlpts[r], e.ctrlpts[r + 1]), r + 3 < e.ctrlpts.length && e.allpts.push((e.ctrlpts[r] + e.ctrlpts[r + 2]) / 2, (e.ctrlpts[r + 1] + e.ctrlpts[r + 3]) / 2);
e.allpts.push(e.endX, e.endY);
var a, n;
e.ctrlpts.length / 2 % 2 === 0 ? (a = e.allpts.length / 2 - 1, e.midX = e.allpts[a], e.midY = e.allpts[a + 1]) : (a = e.allpts.length / 2 - 3, n = 0.5, e.midX = ot(e.allpts[a], e.allpts[a + 2], e.allpts[a + 4], n), e.midY = ot(e.allpts[a + 1], e.allpts[a + 3], e.allpts[a + 5], n));
} else if (e.edgeType === "straight")
e.allpts = [e.startX, e.startY, e.endX, e.endY], e.midX = (e.startX + e.endX + e.arrowStartX + e.arrowEndX) / 4, e.midY = (e.startY + e.endY + e.arrowStartY + e.arrowEndY) / 4;
else if (e.edgeType === "segments") {
if (e.allpts = [], e.allpts.push(e.startX, e.startY), e.allpts.push.apply(e.allpts, e.segpts), e.allpts.push(e.endX, e.endY), e.isRound) {
e.roundCorners = [];
for (var i = 2; i + 3 < e.allpts.length; i += 2) {
var s = e.radii[i / 2 - 1], o = e.isArcRadius[i / 2 - 1];
e.roundCorners.push(So({
x: e.allpts[i - 2],
y: e.allpts[i - 1]
}, {
x: e.allpts[i],
y: e.allpts[i + 1],
radius: s
}, {
x: e.allpts[i + 2],
y: e.allpts[i + 3]
}, s, o));
}
}
if (e.segpts.length % 4 === 0) {
var u = e.segpts.length / 2, l = u - 2;
e.midX = (e.segpts[l] + e.segpts[u]) / 2, e.midY = (e.segpts[l + 1] + e.segpts[u + 1]) / 2;
} else {
var f = e.segpts.length / 2 - 1;
if (!e.isRound)
e.midX = e.segpts[f], e.midY = e.segpts[f + 1];
else {
var c = {
x: e.segpts[f],
y: e.segpts[f + 1]
}, v = e.roundCorners[f / 2];
if (v.radius === 0) {
var h = {
x: e.segpts[f + 2],
y: e.segpts[f + 3]
};
e.midX = c.x, e.midY = c.y, e.midVector = [c.y - h.y, h.x - c.x];
} else {
var d = [c.x - v.cx, c.y - v.cy], p = v.radius / Math.sqrt(Math.pow(d[0], 2) + Math.pow(d[1], 2));
d = d.map(function(g) {
return g * p;
}), e.midX = v.cx + d[0], e.midY = v.cy + d[1], e.midVector = d;
}
}
}
}
};
mt.checkForInvalidEdgeWarning = function(t) {
var e = t[0]._private.rscratch;
e.nodesOverlap || ne(e.startX) && ne(e.startY) && ne(e.endX) && ne(e.endY) ? e.loggedErr = !1 : e.loggedErr || (e.loggedErr = !0, Ge("Edge `" + t.id() + "` has invalid endpoints and so it is impossible to draw. Adjust your edge style (e.g. control points) accordingly or use an alternative edge type. This is expected behaviour when the source node and the target node overlap."));
};
mt.findEdgeControlPoints = function(t) {
var e = this;
if (!(!t || t.length === 0)) {
for (var r = this, a = r.cy, n = a.hasCompoundNodes(), i = new Zt(), s = function(C, D) {
return [].concat(Tn(C), [D ? 1 : 0]).join("-");
}, o = [], u = [], l = 0; l < t.length; l++) {
var f = t[l], c = f._private, v = f.pstyle("curve-style").value;
if (!(f.removed() || !f.takesUpSpace())) {
if (v === "haystack") {
u.push(f);
continue;
}
var h = v === "unbundled-bezier" || ir(v, "segments") || v === "straight" || v === "straight-triangle" || ir(v, "taxi"), d = v === "unbundled-bezier" || v === "bezier", p = c.source, g = c.target, y = p.poolIndex(), b = g.poolIndex(), m = [y, b].sort(), E = s(m, h), T = i.get(E);
T == null && (T = {
eles: []
}, o.push({
pairId: m,
edgeIsUnbundled: h
}), i.set(E, T)), T.eles.push(f), h && (T.hasUnbundled = !0), d && (T.hasBezier = !0);
}
}
for (var S = function() {
var C = o[w], D = C.pairId, A = C.edgeIsUnbundled, L = s(D, A), R = i.get(L), I;
if (!R.hasUnbundled) {
var M = R.eles[0].parallelEdges().filter(function(ue) {
return ue.isBundledBezier();
});
fo(R.eles), M.forEach(function(ue) {
return R.eles.push(ue);
}), R.eles.sort(function(ue, Q) {
return ue.poolIndex() - Q.poolIndex();
});
}
var N = R.eles[0], O = N.source(), k = N.target();
if (O.poolIndex() > k.poolIndex()) {
var B = O;
O = k, k = B;
}
var _ = R.srcPos = O.position(), F = R.tgtPos = k.position(), G = R.srcW = O.outerWidth(), H = R.srcH = O.outerHeight(), Y = R.tgtW = k.outerWidth(), X = R.tgtH = k.outerHeight(), W = R.srcShape = r.nodeShapes[e.getNodeShape(O)], ee = R.tgtShape = r.nodeShapes[e.getNodeShape(k)], ae = R.srcCornerRadius = O.pstyle("corner-radius").value === "auto" ? "auto" : O.pstyle("corner-radius").pfValue, J = R.tgtCornerRadius = k.pstyle("corner-radius").value === "auto" ? "auto" : k.pstyle("corner-radius").pfValue, z = R.tgtRs = k._private.rscratch, V = R.srcRs = O._private.rscratch;
R.dirCounts = {
north: 0,
west: 0,
south: 0,
east: 0,
northwest: 0,
southwest: 0,
northeast: 0,
southeast: 0
};
for (var q = 0; q < R.eles.length; q++) {
var Z = R.eles[q], re = Z[0]._private.rscratch, ve = Z.pstyle("curve-style").value, Ie = ve === "unbundled-bezier" || ir(ve, "segments") || ir(ve, "taxi"), Te = !O.same(Z.source());
if (!R.calculatedIntersection && O !== k && (R.hasBezier || R.hasUnbundled)) {
R.calculatedIntersection = !0;
var we = W.intersectLine(_.x, _.y, G, H, F.x, F.y, 0, ae, V), ye = R.srcIntn = we, ie = ee.intersectLine(F.x, F.y, Y, X, _.x, _.y, 0, J, z), he = R.tgtIntn = ie, de = R.intersectionPts = {
x1: we[0],
x2: ie[0],
y1: we[1],
y2: ie[1]
}, xe = R.posPts = {
x1: _.x,
x2: F.x,
y1: _.y,
y2: F.y
}, pe = ie[1] - we[1], De = ie[0] - we[0], Pe = Math.sqrt(De * De + pe * pe);
ne(Pe) && Pe >= Sy || (Pe = Math.sqrt(Math.max(De * De, Na) + Math.max(pe * pe, Na)));
var Ne = R.vector = {
x: De,
y: pe
}, Be = R.vectorNorm = {
x: Ne.x / Pe,
y: Ne.y / Pe
}, Fe = {
x: -Be.y,
y: Be.x
};
R.nodesOverlap = !ne(Pe) || ee.checkPoint(we[0], we[1], 0, Y, X, F.x, F.y, J, z) || W.checkPoint(ie[0], ie[1], 0, G, H, _.x, _.y, ae, V), R.vectorNormInverse = Fe, I = {
nodesOverlap: R.nodesOverlap,
dirCounts: R.dirCounts,
calculatedIntersection: !0,
hasBezier: R.hasBezier,
hasUnbundled: R.hasUnbundled,
eles: R.eles,
srcPos: F,
srcRs: z,
tgtPos: _,
tgtRs: V,
srcW: Y,
srcH: X,
tgtW: G,
tgtH: H,
srcIntn: he,
tgtIntn: ye,
srcShape: ee,
tgtShape: W,
posPts: {
x1: xe.x2,
y1: xe.y2,
x2: xe.x1,
y2: xe.y1
},
intersectionPts: {
x1: de.x2,
y1: de.y2,
x2: de.x1,
y2: de.y1
},
vector: {
x: -Ne.x,
y: -Ne.y
},
vectorNorm: {
x: -Be.x,
y: -Be.y
},
vectorNormInverse: {
x: -Fe.x,
y: -Fe.y
}
};
}
var Ee = Te ? I : R;
re.nodesOverlap = Ee.nodesOverlap, re.srcIntn = Ee.srcIntn, re.tgtIntn = Ee.tgtIntn, re.isRound = ve.startsWith("round"), n && (O.isParent() || O.isChild() || k.isParent() || k.isChild()) && (O.parents().anySame(k) || k.parents().anySame(O) || O.same(k) && O.isParent()) ? e.findCompoundLoopPoints(Z, Ee, q, Ie) : O === k ? e.findLoopPoints(Z, Ee, q, Ie) : ve.endsWith("segments") ? e.findSegmentsPoints(Z, Ee) : ve.endsWith("taxi") ? e.findTaxiPoints(Z, Ee) : ve === "straight" || !Ie && R.eles.length % 2 === 1 && q === Math.floor(R.eles.length / 2) ? e.findStraightEdgePoints(Z) : e.findBezierPoints(Z, Ee, q, Ie, Te), e.findEndpoints(Z), e.tryToCorrectInvalidPoints(Z, Ee), e.checkForInvalidEdgeWarning(Z), e.storeAllpts(Z), e.storeEdgeProjections(Z), e.calculateArrowAngles(Z), e.recalculateEdgeLabelProjections(Z), e.calculateLabelAngles(Z);
}
}, w = 0; w < o.length; w++)
S();
this.findHaystackPoints(u);
}
};
function Ic(t) {
var e = [];
if (t != null) {
for (var r = 0; r < t.length; r += 2) {
var a = t[r], n = t[r + 1];
e.push({
x: a,
y: n
});
}
return e;
}
}
mt.getSegmentPoints = function(t) {
var e = t[0]._private.rscratch;
this.recalculateRenderedStyle(t);
var r = e.edgeType;
if (r === "segments")
return Ic(e.segpts);
};
mt.getControlPoints = function(t) {
var e = t[0]._private.rscratch;
this.recalculateRenderedStyle(t);
var r = e.edgeType;
if (r === "bezier" || r === "multibezier" || r === "self" || r === "compound")
return Ic(e.ctrlpts);
};
mt.getEdgeMidpoint = function(t) {
var e = t[0]._private.rscratch;
return this.recalculateRenderedStyle(t), {
x: e.midX,
y: e.midY
};
};
var Ha = {};
Ha.manualEndptToPx = function(t, e) {
var r = this, a = t.position(), n = t.outerWidth(), i = t.outerHeight(), s = t._private.rscratch;
if (e.value.length === 2) {
var o = [e.pfValue[0], e.pfValue[1]];
return e.units[0] === "%" && (o[0] = o[0] * n), e.units[1] === "%" && (o[1] = o[1] * i), o[0] += a.x, o[1] += a.y, o;
} else {
var u = e.pfValue[0];
u = -Math.PI / 2 + u;
var l = 2 * Math.max(n, i), f = [a.x + Math.cos(u) * l, a.y + Math.sin(u) * l];
return r.nodeShapes[this.getNodeShape(t)].intersectLine(a.x, a.y, n, i, f[0], f[1], 0, t.pstyle("corner-radius").value === "auto" ? "auto" : t.pstyle("corner-radius").pfValue, s);
}
};
Ha.findEndpoints = function(t) {
var e, r, a, n, i = this, s, o = t.source()[0], u = t.target()[0], l = o.position(), f = u.position(), c = t.pstyle("target-arrow-shape").value, v = t.pstyle("source-arrow-shape").value, h = t.pstyle("target-distance-from-node").pfValue, d = t.pstyle("source-distance-from-node").pfValue, p = o._private.rscratch, g = u._private.rscratch, y = t.pstyle("curve-style").value, b = t._private.rscratch, m = b.edgeType, E = ir(y, "taxi"), T = m === "self" || m === "compound", S = m === "bezier" || m === "multibezier" || T, w = m !== "bezier", x = m === "straight" || m === "segments", C = m === "segments", D = S || w || x, A = T || E, L = t.pstyle("source-endpoint"), R = A ? "outside-to-node" : L.value, I = o.pstyle("corner-radius").value === "auto" ? "auto" : o.pstyle("corner-radius").pfValue, M = t.pstyle("target-endpoint"), N = A ? "outside-to-node" : M.value, O = u.pstyle("corner-radius").value === "auto" ? "auto" : u.pstyle("corner-radius").pfValue;
b.srcManEndpt = L, b.tgtManEndpt = M;
var k, B, _, F, G = (e = (M == null || (r = M.pfValue) === null || r === void 0 ? void 0 : r.length) === 2 ? M.pfValue : null) !== null && e !== void 0 ? e : [0, 0], H = (a = (L == null || (n = L.pfValue) === null || n === void 0 ? void 0 : n.length) === 2 ? L.pfValue : null) !== null && a !== void 0 ? a : [0, 0];
if (S) {
var Y = [b.ctrlpts[0], b.ctrlpts[1]], X = w ? [b.ctrlpts[b.ctrlpts.length - 2], b.ctrlpts[b.ctrlpts.length - 1]] : Y;
k = X, B = Y;
} else if (x) {
var W = C ? b.segpts.slice(0, 2) : [f.x + G[0], f.y + G[1]], ee = C ? b.segpts.slice(b.segpts.length - 2) : [l.x + H[0], l.y + H[1]];
k = ee, B = W;
}
if (N === "inside-to-node")
s = [f.x, f.y];
else if (M.units)
s = this.manualEndptToPx(u, M);
else if (N === "outside-to-line")
s = b.tgtIntn;
else if (N === "outside-to-node" || N === "outside-to-node-or-label" ? _ = k : (N === "outside-to-line" || N === "outside-to-line-or-label") && (_ = [l.x, l.y]), s = i.nodeShapes[this.getNodeShape(u)].intersectLine(f.x, f.y, u.outerWidth(), u.outerHeight(), _[0], _[1], 0, O, g), N === "outside-to-node-or-label" || N === "outside-to-line-or-label") {
var ae = u._private.rscratch, J = ae.labelWidth, z = ae.labelHeight, V = ae.labelX, q = ae.labelY, Z = J / 2, re = z / 2, ve = u.pstyle("text-valign").value;
ve === "top" ? q -= re : ve === "bottom" && (q += re);
var Ie = u.pstyle("text-halign").value;
Ie === "left" ? V -= Z : Ie === "right" && (V += Z);
var Te = Ia(_[0], _[1], [V - Z, q - re, V + Z, q - re, V + Z, q + re, V - Z, q + re], f.x, f.y);
if (Te.length > 0) {
var we = l, ye = Dr(we, Wr(s)), ie = Dr(we, Wr(Te)), he = ye;
if (ie < ye && (s = Te, he = ie), Te.length > 2) {
var de = Dr(we, {
x: Te[2],
y: Te[3]
});
de < he && (s = [Te[2], Te[3]]);
}
}
}
var xe = ja(s, k, i.arrowShapes[c].spacing(t) + h), pe = ja(s, k, i.arrowShapes[c].gap(t) + h);
if (b.endX = pe[0], b.endY = pe[1], b.arrowEndX = xe[0], b.arrowEndY = xe[1], R === "inside-to-node")
s = [l.x, l.y];
else if (L.units)
s = this.manualEndptToPx(o, L);
else if (R === "outside-to-line")
s = b.srcIntn;
else if (R === "outside-to-node" || R === "outside-to-node-or-label" ? F = B : (R === "outside-to-line" || R === "outside-to-line-or-label") && (F = [f.x, f.y]), s = i.nodeShapes[this.getNodeShape(o)].intersectLine(l.x, l.y, o.outerWidth(), o.outerHeight(), F[0], F[1], 0, I, p), R === "outside-to-node-or-label" || R === "outside-to-line-or-label") {
var De = o._private.rscratch, Pe = De.labelWidth, Ne = De.labelHeight, Be = De.labelX, Fe = De.labelY, Ee = Pe / 2, ue = Ne / 2, Q = o.pstyle("text-valign").value;
Q === "top" ? Fe -= ue : Q === "bottom" && (Fe += ue);
var P = o.pstyle("text-halign").value;
P === "left" ? Be -= Ee : P === "right" && (Be += Ee);
var U = Ia(F[0], F[1], [Be - Ee, Fe - ue, Be + Ee, Fe - ue, Be + Ee, Fe + ue, Be - Ee, Fe + ue], l.x, l.y);
if (U.length > 0) {
var $ = f, K = Dr($, Wr(s)), j = Dr($, Wr(U)), oe = K;
if (j < K && (s = [U[0], U[1]], oe = j), U.length > 2) {
var te = Dr($, {
x: U[2],
y: U[3]
});
te < oe && (s = [U[2], U[3]]);
}
}
}
var fe = ja(s, B, i.arrowShapes[v].spacing(t) + d), le = ja(s, B, i.arrowShapes[v].gap(t) + d);
b.startX = le[0], b.startY = le[1], b.arrowStartX = fe[0], b.arrowStartY = fe[1], D && (!ne(b.startX) || !ne(b.startY) || !ne(b.endX) || !ne(b.endY) ? b.badLine = !0 : b.badLine = !1);
};
Ha.getSourceEndpoint = function(t) {
var e = t[0]._private.rscratch;
switch (this.recalculateRenderedStyle(t), e.edgeType) {
case "haystack":
return {
x: e.haystackPts[0],
y: e.haystackPts[1]
};
default:
return {
x: e.arrowStartX,
y: e.arrowStartY
};
}
};
Ha.getTargetEndpoint = function(t) {
var e = t[0]._private.rscratch;
switch (this.recalculateRenderedStyle(t), e.edgeType) {
case "haystack":
return {
x: e.haystackPts[2],
y: e.haystackPts[3]
};
default:
return {
x: e.arrowEndX,
y: e.arrowEndY
};
}
};
var Ao = {};
function Ay(t, e, r) {
for (var a = function(l, f, c, v) {
return ot(l, f, c, v);
}, n = e._private, i = n.rstyle.bezierPts, s = 0; s < t.bezierProjPcts.length; s++) {
var o = t.bezierProjPcts[s];
i.push({
x: a(r[0], r[2], r[4], o),
y: a(r[1], r[3], r[5], o)
});
}
}
Ao.storeEdgeProjections = function(t) {
var e = t._private, r = e.rscratch, a = r.edgeType;
if (e.rstyle.bezierPts = null, e.rstyle.linePts = null, e.rstyle.haystackPts = null, a === "multibezier" || a === "bezier" || a === "self" || a === "compound") {
e.rstyle.bezierPts = [];
for (var n = 0; n + 5 < r.allpts.length; n += 4)
Ay(this, t, r.allpts.slice(n, n + 6));
} else if (a === "segments")
for (var i = e.rstyle.linePts = [], n = 0; n + 1 < r.allpts.length; n += 2)
i.push({
x: r.allpts[n],
y: r.allpts[n + 1]
});
else if (a === "haystack") {
var s = r.haystackPts;
e.rstyle.haystackPts = [{
x: s[0],
y: s[1]
}, {
x: s[2],
y: s[3]
}];
}
e.rstyle.arrowWidth = this.getArrowWidth(t.pstyle("width").pfValue, t.pstyle("arrow-scale").value) * this.arrowShapeWidth;
};
Ao.recalculateEdgeProjections = function(t) {
this.findEdgeControlPoints(t);
};
var Yt = {};
Yt.recalculateNodeLabelProjection = function(t) {
var e = t.pstyle("label").strValue;
if (!fr(e)) {
var r, a, n = t._private, i = t.width(), s = t.height(), o = t.padding(), u = t.position(), l = t.pstyle("text-halign").strValue, f = t.pstyle("text-valign").strValue, c = n.rscratch, v = n.rstyle;
switch (l) {
case "left":
r = u.x - i / 2 - o;
break;
case "right":
r = u.x + i / 2 + o;
break;
default:
r = u.x;
}
switch (f) {
case "top":
a = u.y - s / 2 - o;
break;
case "bottom":
a = u.y + s / 2 + o;
break;
default:
a = u.y;
}
c.labelX = r, c.labelY = a, v.labelX = r, v.labelY = a, this.calculateLabelAngles(t), this.applyLabelDimensions(t);
}
};
var Pc = function(e, r) {
var a = Math.atan(r / e);
return e === 0 && a < 0 && (a = a * -1), a;
}, Mc = function(e, r) {
var a = r.x - e.x, n = r.y - e.y;
return Pc(a, n);
}, Ly = function(e, r, a, n) {
var i = Ra(0, n - 1e-3, 1), s = Ra(0, n + 1e-3, 1), o = Qr(e, r, a, i), u = Qr(e, r, a, s);
return Mc(o, u);
};
Yt.recalculateEdgeLabelProjections = function(t) {
var e, r = t._private, a = r.rscratch, n = this, i = {
mid: t.pstyle("label").strValue,
source: t.pstyle("source-label").strValue,
target: t.pstyle("target-label").strValue
};
if (i.mid || i.source || i.target) {
e = {
x: a.midX,
y: a.midY
};
var s = function(c, v, h) {
Kt(r.rscratch, c, v, h), Kt(r.rstyle, c, v, h);
};
s("labelX", null, e.x), s("labelY", null, e.y);
var o = Pc(a.midDispX, a.midDispY);
s("labelAutoAngle", null, o);
var u = function() {
if (u.cache)
return u.cache;
for (var c = [], v = 0; v + 5 < a.allpts.length; v += 4) {
var h = {
x: a.allpts[v],
y: a.allpts[v + 1]
}, d = {
x: a.allpts[v + 2],
y: a.allpts[v + 3]
}, p = {
x: a.allpts[v + 4],
y: a.allpts[v + 5]
};
c.push({
p0: h,
p1: d,
p2: p,
startDist: 0,
length: 0,
segments: []
});
}
var g = r.rstyle.bezierPts, y = n.bezierProjPcts.length;
function b(w, x, C, D, A) {
var L = Pr(x, C), R = w.segments[w.segments.length - 1], I = {
p0: x,
p1: C,
t0: D,
t1: A,
startDist: R ? R.startDist + R.length : 0,
length: L
};
w.segments.push(I), w.length += L;
}
for (var m = 0; m < c.length; m++) {
var E = c[m], T = c[m - 1];
T && (E.startDist = T.startDist + T.length), b(E, E.p0, g[m * y], 0, n.bezierProjPcts[0]);
for (var S = 0; S < y - 1; S++)
b(E, g[m * y + S], g[m * y + S + 1], n.bezierProjPcts[S], n.bezierProjPcts[S + 1]);
b(E, g[m * y + y - 1], E.p2, n.bezierProjPcts[y - 1], 1);
}
return u.cache = c;
}, l = function(c) {
var v, h = c === "source";
if (i[c]) {
var d = t.pstyle(c + "-text-offset").pfValue;
switch (a.edgeType) {
case "self":
case "compound":
case "bezier":
case "multibezier": {
for (var p = u(), g, y = 0, b = 0, m = 0; m < p.length; m++) {
for (var E = p[h ? m : p.length - 1 - m], T = 0; T < E.segments.length; T++) {
var S = E.segments[h ? T : E.segments.length - 1 - T], w = m === p.length - 1 && T === E.segments.length - 1;
if (y = b, b += S.length, b >= d || w) {
g = {
cp: E,
segment: S
};
break;
}
}
if (g)
break;
}
var x = g.cp, C = g.segment, D = (d - y) / C.length, A = C.t1 - C.t0, L = h ? C.t0 + A * D : C.t1 - A * D;
L = Ra(0, L, 1), e = Qr(x.p0, x.p1, x.p2, L), v = Ly(x.p0, x.p1, x.p2, L);
break;
}
case "straight":
case "segments":
case "haystack": {
for (var R = 0, I, M, N, O, k = a.allpts.length, B = 0; B + 3 < k && (h ? (N = {
x: a.allpts[B],
y: a.allpts[B + 1]
}, O = {
x: a.allpts[B + 2],
y: a.allpts[B + 3]
}) : (N = {
x: a.allpts[k - 2 - B],
y: a.allpts[k - 1 - B]
}, O = {
x: a.allpts[k - 4 - B],
y: a.allpts[k - 3 - B]
}), I = Pr(N, O), M = R, R += I, !(R >= d)); B += 2)
;
var _ = d - M, F = _ / I;
F = Ra(0, F, 1), e = Zh(N, O, F), v = Mc(N, O);
break;
}
}
s("labelX", c, e.x), s("labelY", c, e.y), s("labelAutoAngle", c, v);
}
};
l("source"), l("target"), this.applyLabelDimensions(t);
}
};
Yt.applyLabelDimensions = function(t) {
this.applyPrefixedLabelDimensions(t), t.isEdge() && (this.applyPrefixedLabelDimensions(t, "source"), this.applyPrefixedLabelDimensions(t, "target"));
};
Yt.applyPrefixedLabelDimensions = function(t, e) {
var r = t._private, a = this.getLabelText(t, e), n = Ir(a, t._private.labelDimsKey);
if (Dt(r.rscratch, "prefixedLabelDimsKey", e) !== n) {
Kt(r.rscratch, "prefixedLabelDimsKey", e, n);
var i = this.calculateLabelDimensions(t, a), s = t.pstyle("line-height").pfValue, o = t.pstyle("text-wrap").strValue, u = Dt(r.rscratch, "labelWrapCachedLines", e) || [], l = o !== "wrap" ? 1 : Math.max(u.length, 1), f = i.height / l, c = f * s, v = i.width, h = i.height + (l - 1) * (s - 1) * f;
Kt(r.rstyle, "labelWidth", e, v), Kt(r.rscratch, "labelWidth", e, v), Kt(r.rstyle, "labelHeight", e, h), Kt(r.rscratch, "labelHeight", e, h), Kt(r.rscratch, "labelLineHeight", e, c);
}
};
Yt.getLabelText = function(t, e) {
var r = t._private, a = e ? e + "-" : "", n = t.pstyle(a + "label").strValue, i = t.pstyle("text-transform").value, s = function(H, Y) {
return Y ? (Kt(r.rscratch, H, e, Y), Y) : Dt(r.rscratch, H, e);
};
if (!n)
return "";
i == "none" || (i == "uppercase" ? n = n.toUpperCase() : i == "lowercase" && (n = n.toLowerCase()));
var o = t.pstyle("text-wrap").value;
if (o === "wrap") {
var u = s("labelKey");
if (u != null && s("labelWrapKey") === u)
return s("labelWrapCachedText");
for (var l = "", f = n.split(`
`), c = t.pstyle("text-max-width").pfValue, v = t.pstyle("text-overflow-wrap").value, h = v === "anywhere", d = [], p = /[\s\u200b]+|$/g, g = 0; g < f.length; g++) {
var y = f[g], b = this.calculateLabelDimensions(t, y), m = b.width;
if (h) {
var E = y.split("").join(l);
y = E;
}
if (m > c) {
var T = y.matchAll(p), S = "", w = 0, x = At(T), C;
try {
for (x.s(); !(C = x.n()).done; ) {
var D = C.value, A = D[0], L = y.substring(w, D.index);
w = D.index + A.length;
var R = S.length === 0 ? L : S + L + A, I = this.calculateLabelDimensions(t, R), M = I.width;
M <= c ? S += L + A : (S && d.push(S), S = L + A);
}
} catch (G) {
x.e(G);
} finally {
x.f();
}
S.match(/^[\s\u200b]+$/) || d.push(S);
} else
d.push(y);
}
s("labelWrapCachedLines", d), n = s("labelWrapCachedText", d.join(`
`)), s("labelWrapKey", u);
} else if (o === "ellipsis") {
var N = t.pstyle("text-max-width").pfValue, O = "", k = "…", B = !1;
if (this.calculateLabelDimensions(t, n).width < N)
return n;
for (var _ = 0; _ < n.length; _++) {
var F = this.calculateLabelDimensions(t, O + n[_] + k).width;
if (F > N)
break;
O += n[_], _ === n.length - 1 && (B = !0);
}
return B || (O += k), O;
}
return n;
};
Yt.getLabelJustification = function(t) {
var e = t.pstyle("text-justification").strValue, r = t.pstyle("text-halign").strValue;
if (e === "auto")
if (t.isNode())
switch (r) {
case "left":
return "right";
case "right":
return "left";
default:
return "center";
}
else
return "center";
else
return e;
};
Yt.calculateLabelDimensions = function(t, e) {
var r = this, a = r.cy.window(), n = a.document, i = 0, s = t.pstyle("font-style").strValue, o = t.pstyle("font-size").pfValue, u = t.pstyle("font-family").strValue, l = t.pstyle("font-weight").strValue, f = this.labelCalcCanvas, c = this.labelCalcCanvasContext;
if (!f) {
f = this.labelCalcCanvas = n.createElement("canvas"), c = this.labelCalcCanvasContext = f.getContext("2d");
var v = f.style;
v.position = "absolute", v.left = "-9999px", v.top = "-9999px", v.zIndex = "-1", v.visibility = "hidden", v.pointerEvents = "none";
}
c.font = "".concat(s, " ").concat(l, " ").concat(o, "px ").concat(u);
for (var h = 0, d = 0, p = e.split(`
`), g = 0; g < p.length; g++) {
var y = p[g], b = c.measureText(y), m = Math.ceil(b.width), E = o;
h = Math.max(m, h), d += E;
}
return h += i, d += i, {
width: h,
height: d
};
};
Yt.calculateLabelAngle = function(t, e) {
var r = t._private, a = r.rscratch, n = t.isEdge(), i = e ? e + "-" : "", s = t.pstyle(i + "text-rotation"), o = s.strValue;
return o === "none" ? 0 : n && o === "autorotate" ? a.labelAutoAngle : o === "autorotate" ? 0 : s.pfValue;
};
Yt.calculateLabelAngles = function(t) {
var e = this, r = t.isEdge(), a = t._private, n = a.rscratch;
n.labelAngle = e.calculateLabelAngle(t), r && (n.sourceLabelAngle = e.calculateLabelAngle(t, "source"), n.targetLabelAngle = e.calculateLabelAngle(t, "target"));
};
var Oc = {}, Yl = 28, Hl = !1;
Oc.getNodeShape = function(t) {
var e = this, r = t.pstyle("shape").value;
if (r === "cutrectangle" && (t.width() < Yl || t.height() < Yl))
return Hl || (Ge("The `cutrectangle` node shape can not be used at small sizes so `rectangle` is used instead"), Hl = !0), "rectangle";
if (t.isParent())
return r === "rectangle" || r === "roundrectangle" || r === "round-rectangle" || r === "cutrectangle" || r === "cut-rectangle" || r === "barrel" ? r : "rectangle";
if (r === "polygon") {
var a = t.pstyle("shape-polygon-points").value;
return e.nodeShapes.makePolygon(a).name;
}
return r;
};
var jn = {};
jn.registerCalculationListeners = function() {
var t = this.cy, e = t.collection(), r = this, a = function(s) {
var o = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0;
if (e.merge(s), o)
for (var u = 0; u < s.length; u++) {
var l = s[u], f = l._private, c = f.rstyle;
c.clean = !1, c.cleanConnected = !1;
}
};
r.binder(t).on("bounds.* dirty.*", function(s) {
var o = s.target;
a(o);
}).on("style.* background.*", function(s) {
var o = s.target;
a(o, !1);
});
var n = function(s) {
if (s) {
var o = r.onUpdateEleCalcsFns;
e.cleanStyle();
for (var u = 0; u < e.length; u++) {
var l = e[u], f = l._private.rstyle;
l.isNode() && !f.cleanConnected && (a(l.connectedEdges()), f.cleanConnected = !0);
}
if (o)
for (var c = 0; c < o.length; c++) {
var v = o[c];
v(s, e);
}
r.recalculateRenderedStyle(e), e = t.collection();
}
};
r.flushRenderedStyleQueue = function() {
n(!0);
}, r.beforeRender(n, r.beforeRenderPriorities.eleCalcs);
};
jn.onUpdateEleCalcs = function(t) {
var e = this.onUpdateEleCalcsFns = this.onUpdateEleCalcsFns || [];
e.push(t);
};
jn.recalculateRenderedStyle = function(t, e) {
var r = function(E) {
return E._private.rstyle.cleanConnected;
};
if (t.length !== 0) {
var a = [], n = [];
if (!this.destroyed) {
e === void 0 && (e = !0);
for (var i = 0; i < t.length; i++) {
var s = t[i], o = s._private, u = o.rstyle;
s.isEdge() && (!r(s.source()) || !r(s.target())) && (u.clean = !1), s.isEdge() && s.isBundledBezier() && s.parallelEdges().some(function(m) {
return !m._private.rstyle.clean && m.isBundledBezier();
}) && (u.clean = !1), !(e && u.clean || s.removed()) && s.pstyle("display").value !== "none" && (o.group === "nodes" ? n.push(s) : a.push(s), u.clean = !0);
}
for (var l = 0; l < n.length; l++) {
var f = n[l], c = f._private, v = c.rstyle, h = f.position();
this.recalculateNodeLabelProjection(f), v.nodeX = h.x, v.nodeY = h.y, v.nodeW = f.pstyle("width").pfValue, v.nodeH = f.pstyle("height").pfValue;
}
this.recalculateEdgeProjections(a);
for (var d = 0; d < a.length; d++) {
var p = a[d], g = p._private, y = g.rstyle, b = g.rscratch;
y.srcX = b.arrowStartX, y.srcY = b.arrowStartY, y.tgtX = b.arrowEndX, y.tgtY = b.arrowEndY, y.midX = b.midX, y.midY = b.midY, y.labelAngle = b.labelAngle, y.sourceLabelAngle = b.sourceLabelAngle, y.targetLabelAngle = b.targetLabelAngle;
}
}
}
};
var ei = {};
ei.updateCachedGrabbedEles = function() {
var t = this.cachedZSortedEles;
if (t) {
t.drag = [], t.nondrag = [];
for (var e = [], r = 0; r < t.length; r++) {
var a = t[r], n = a._private.rscratch;
a.grabbed() && !a.isParent() ? e.push(a) : n.inDragLayer ? t.drag.push(a) : t.nondrag.push(a);
}
for (var r = 0; r < e.length; r++) {
var a = e[r];
t.drag.push(a);
}
}
};
ei.invalidateCachedZSortedEles = function() {
this.cachedZSortedEles = null;
};
ei.getCachedZSortedEles = function(t) {
if (t || !this.cachedZSortedEles) {
var e = this.cy.mutableElements().toArray();
e.sort(dc), e.interactive = e.filter(function(r) {
return r.interactive();
}), this.cachedZSortedEles = e, this.updateCachedGrabbedEles();
} else
e = this.cachedZSortedEles;
return e;
};
var kc = {};
[Br, On, mt, Ha, Ao, Yt, Oc, jn, ei].forEach(function(t) {
be(kc, t);
});
var Nc = {};
Nc.getCachedImage = function(t, e, r) {
var a = this, n = a.imageCache = a.imageCache || {}, i = n[t];
if (i)
return i.image.complete || i.image.addEventListener("load", r), i.image;
i = n[t] = n[t] || {};
var s = i.image = new Image();
s.addEventListener("load", r), s.addEventListener("error", function() {
s.error = !0;
});
var o = "data:", u = t.substring(0, o.length).toLowerCase() === o;
return u || (e = e === "null" ? null : e, s.crossOrigin = e), s.src = t, s;
};
var ua = {};
ua.registerBinding = function(t, e, r, a) {
var n = Array.prototype.slice.apply(arguments, [1]);
if (Array.isArray(t)) {
for (var i = [], s = 0; s < t.length; s++) {
var o = t[s];
if (o !== void 0) {
var u = this.binder(o);
i.push(u.on.apply(u, n));
}
}
return i;
}
var u = this.binder(t);
return u.on.apply(u, n);
};
ua.binder = function(t) {
var e = this, r = e.cy.window(), a = t === r || t === r.document || t === r.document.body || zv(t);
if (e.supportsPassiveEvents == null) {
var n = !1;
try {
var i = Object.defineProperty({}, "passive", {
get: function() {
return n = !0, !0;
}
});
r.addEventListener("test", null, i);
} catch {
}
e.supportsPassiveEvents = n;
}
var s = function(u, l, f) {
var c = Array.prototype.slice.call(arguments);
return a && e.supportsPassiveEvents && (c[2] = {
capture: f ?? !1,
passive: !1,
once: !1
}), e.bindings.push({
target: t,
args: c
}), (t.addEventListener || t.on).apply(t, c), this;
};
return {
on: s,
addEventListener: s,
addListener: s,
bind: s
};
};
ua.nodeIsDraggable = function(t) {
return t && t.isNode() && !t.locked() && t.grabbable();
};
ua.nodeIsGrabbable = function(t) {
return this.nodeIsDraggable(t) && t.interactive();
};
ua.load = function() {
var t = this, e = t.cy.window(), r = function(P) {
return P.selected();
}, a = function(P) {
var U = P.getRootNode();
if (U && U.nodeType === 11 && U.host !== void 0)
return U;
}, n = function(P, U, $, K) {
P == null && (P = t.cy);
for (var j = 0; j < U.length; j++) {
var oe = U[j];
P.emit({
originalEvent: $,
type: oe,
position: K
});
}
}, i = function(P) {
return P.shiftKey || P.metaKey || P.ctrlKey;
}, s = function(P, U) {
var $ = !0;
if (t.cy.hasCompoundNodes() && P && P.pannable())
for (var K = 0; U && K < U.length; K++) {
var P = U[K];
if (P.isNode() && P.isParent() && !P.pannable()) {
$ = !1;
break;
}
}
else
$ = !0;
return $;
}, o = function(P) {
P[0]._private.grabbed = !0;
}, u = function(P) {
P[0]._private.grabbed = !1;
}, l = function(P) {
P[0]._private.rscratch.inDragLayer = !0;
}, f = function(P) {
P[0]._private.rscratch.inDragLayer = !1;
}, c = function(P) {
P[0]._private.rscratch.isGrabTarget = !0;
}, v = function(P) {
P[0]._private.rscratch.isGrabTarget = !1;
}, h = function(P, U) {
var $ = U.addToList, K = $.has(P);
!K && P.grabbable() && !P.locked() && ($.merge(P), o(P));
}, d = function(P, U) {
if (P.cy().hasCompoundNodes() && !(U.inDragLayer == null && U.addToList == null)) {
var $ = P.descendants();
U.inDragLayer && ($.forEach(l), $.connectedEdges().forEach(l)), U.addToList && h($, U);
}
}, p = function(P, U) {
U = U || {};
var $ = P.cy().hasCompoundNodes();
U.inDragLayer && (P.forEach(l), P.neighborhood().stdFilter(function(K) {
return !$ || K.isEdge();
}).forEach(l)), U.addToList && P.forEach(function(K) {
h(K, U);
}), d(P, U), b(P, {
inDragLayer: U.inDragLayer
}), t.updateCachedGrabbedEles();
}, g = p, y = function(P) {
P && (t.getCachedZSortedEles().forEach(function(U) {
u(U), f(U), v(U);
}), t.updateCachedGrabbedEles());
}, b = function(P, U) {
if (!(U.inDragLayer == null && U.addToList == null) && P.cy().hasCompoundNodes()) {
var $ = P.ancestors().orphans();
if (!$.same(P)) {
var K = $.descendants().spawnSelf().merge($).unmerge(P).unmerge(P.descendants()), j = K.connectedEdges();
U.inDragLayer && (j.forEach(l), K.forEach(l)), U.addToList && K.forEach(function(oe) {
h(oe, U);
});
}
}
}, m = function() {
document.activeElement != null && document.activeElement.blur != null && document.activeElement.blur();
}, E = typeof MutationObserver < "u", T = typeof ResizeObserver < "u";
E ? (t.removeObserver = new MutationObserver(function(Q) {
for (var P = 0; P < Q.length; P++) {
var U = Q[P], $ = U.removedNodes;
if ($)
for (var K = 0; K < $.length; K++) {
var j = $[K];
if (j === t.container) {
t.destroy();
break;
}
}
}
}), t.container.parentNode && t.removeObserver.observe(t.container.parentNode, {
childList: !0
})) : t.registerBinding(t.container, "DOMNodeRemoved", function(Q) {
t.destroy();
});
var S = Va(function() {
t.cy.resize();
}, 100);
E && (t.styleObserver = new MutationObserver(S), t.styleObserver.observe(t.container, {
attributes: !0
})), t.registerBinding(e, "resize", S), T && (t.resizeObserver = new ResizeObserver(S), t.resizeObserver.observe(t.container));
var w = function(P, U) {
for (; P != null; )
U(P), P = P.parentNode;
}, x = function() {
t.invalidateContainerClientCoordsCache();
};
w(t.container, function(Q) {
t.registerBinding(Q, "transitionend", x), t.registerBinding(Q, "animationend", x), t.registerBinding(Q, "scroll", x);
}), t.registerBinding(t.container, "contextmenu", function(Q) {
Q.preventDefault();
});
var C = function() {
return t.selection[4] !== 0;
}, D = function(P) {
for (var U = t.findContainerClientCoords(), $ = U[0], K = U[1], j = U[2], oe = U[3], te = P.touches ? P.touches : [P], fe = !1, le = 0; le < te.length; le++) {
var me = te[le];
if ($ <= me.clientX && me.clientX <= $ + j && K <= me.clientY && me.clientY <= K + oe) {
fe = !0;
break;
}
}
if (!fe)
return !1;
for (var Ae = t.container, Ce = P.target, ce = Ce.parentNode, Re = !1; ce; ) {
if (ce === Ae) {
Re = !0;
break;
}
ce = ce.parentNode;
}
return !!Re;
};
t.registerBinding(t.container, "mousedown", function(P) {
if (D(P) && !(t.hoverData.which === 1 && P.which !== 1)) {
P.preventDefault(), m(), t.hoverData.capture = !0, t.hoverData.which = P.which;
var U = t.cy, $ = [P.clientX, P.clientY], K = t.projectIntoViewport($[0], $[1]), j = t.selection, oe = t.findNearestElements(K[0], K[1], !0, !1), te = oe[0], fe = t.dragData.possibleDragElements;
t.hoverData.mdownPos = K, t.hoverData.mdownGPos = $;
var le = function(Le) {
return {
originalEvent: P,
type: Le,
position: {
x: K[0],
y: K[1]
}
};
}, me = function() {
t.hoverData.tapholdCancelled = !1, clearTimeout(t.hoverData.tapholdTimeout), t.hoverData.tapholdTimeout = setTimeout(function() {
if (!t.hoverData.tapholdCancelled) {
var Le = t.hoverData.down;
Le ? Le.emit(le("taphold")) : U.emit(le("taphold"));
}
}, t.tapholdDuration);
};
if (P.which == 3) {
t.hoverData.cxtStarted = !0;
var Ae = {
originalEvent: P,
type: "cxttapstart",
position: {
x: K[0],
y: K[1]
}
};
te ? (te.activate(), te.emit(Ae), t.hoverData.down = te) : U.emit(Ae), t.hoverData.downTime = (/* @__PURE__ */ new Date()).getTime(), t.hoverData.cxtDragged = !1;
} else if (P.which == 1) {
te && te.activate();
{
if (te != null && t.nodeIsGrabbable(te)) {
var Ce = function(Le) {
Le.emit(le("grab"));
};
if (c(te), !te.selected())
fe = t.dragData.possibleDragElements = U.collection(), g(te, {
addToList: fe
}), te.emit(le("grabon")).emit(le("grab"));
else {
fe = t.dragData.possibleDragElements = U.collection();
var ce = U.$(function(Re) {
return Re.isNode() && Re.selected() && t.nodeIsGrabbable(Re);
});
p(ce, {
addToList: fe
}), te.emit(le("grabon")), ce.forEach(Ce);
}
t.redrawHint("eles", !0), t.redrawHint("drag", !0);
}
t.hoverData.down = te, t.hoverData.downs = oe, t.hoverData.downTime = (/* @__PURE__ */ new Date()).getTime();
}
n(te, ["mousedown", "tapstart", "vmousedown"], P, {
x: K[0],
y: K[1]
}), te == null ? (j[4] = 1, t.data.bgActivePosistion = {
x: K[0],
y: K[1]
}, t.redrawHint("select", !0), t.redraw()) : te.pannable() && (j[4] = 1), me();
}
j[0] = j[2] = K[0], j[1] = j[3] = K[1];
}
}, !1);
var A = a(t.container);
t.registerBinding([e, A], "mousemove", function(P) {
var U = t.hoverData.capture;
if (!(!U && !D(P))) {
var $ = !1, K = t.cy, j = K.zoom(), oe = [P.clientX, P.clientY], te = t.projectIntoViewport(oe[0], oe[1]), fe = t.hoverData.mdownPos, le = t.hoverData.mdownGPos, me = t.selection, Ae = null;
!t.hoverData.draggingEles && !t.hoverData.dragging && !t.hoverData.selecting && (Ae = t.findNearestElement(te[0], te[1], !0, !1));
var Ce = t.hoverData.last, ce = t.hoverData.down, Re = [te[0] - me[2], te[1] - me[3]], Le = t.dragData.possibleDragElements, je;
if (le) {
var $e = oe[0] - le[0], bt = $e * $e, Ke = oe[1] - le[1], st = Ke * Ke, et = bt + st;
t.hoverData.isOverThresholdDrag = je = et >= t.desktopTapThreshold2;
}
var ft = i(P);
je && (t.hoverData.tapholdCancelled = !0);
var tr = function() {
var Rt = t.hoverData.dragDelta = t.hoverData.dragDelta || [];
Rt.length === 0 ? (Rt.push(Re[0]), Rt.push(Re[1])) : (Rt[0] += Re[0], Rt[1] += Re[1]);
};
$ = !0, n(Ae, ["mousemove", "vmousemove", "tapdrag"], P, {
x: te[0],
y: te[1]
});
var Ze = function(Rt) {
return {
originalEvent: P,
type: Rt,
position: {
x: te[0],
y: te[1]
}
};
}, Xt = function() {
t.data.bgActivePosistion = void 0, t.hoverData.selecting || K.emit(Ze("boxstart")), me[4] = 1, t.hoverData.selecting = !0, t.redrawHint("select", !0), t.redraw();
};
if (t.hoverData.which === 3) {
if (je) {
var $t = Ze("cxtdrag");
ce ? ce.emit($t) : K.emit($t), t.hoverData.cxtDragged = !0, (!t.hoverData.cxtOver || Ae !== t.hoverData.cxtOver) && (t.hoverData.cxtOver && t.hoverData.cxtOver.emit(Ze("cxtdragout")), t.hoverData.cxtOver = Ae, Ae && Ae.emit(Ze("cxtdragover")));
}
} else if (t.hoverData.dragging) {
if ($ = !0, K.panningEnabled() && K.userPanningEnabled()) {
var _r;
if (t.hoverData.justStartedPan) {
var Wa = t.hoverData.mdownPos;
_r = {
x: (te[0] - Wa[0]) * j,
y: (te[1] - Wa[1]) * j
}, t.hoverData.justStartedPan = !1;
} else
_r = {
x: Re[0] * j,
y: Re[1] * j
};
K.panBy(_r), K.emit(Ze("dragpan")), t.hoverData.dragged = !0;
}
te = t.projectIntoViewport(P.clientX, P.clientY);
} else if (me[4] == 1 && (ce == null || ce.pannable())) {
if (je) {
if (!t.hoverData.dragging && K.boxSelectionEnabled() && (ft || !K.panningEnabled() || !K.userPanningEnabled()))
Xt();
else if (!t.hoverData.selecting && K.panningEnabled() && K.userPanningEnabled()) {
var xr = s(ce, t.hoverData.downs);
xr && (t.hoverData.dragging = !0, t.hoverData.justStartedPan = !0, me[4] = 0, t.data.bgActivePosistion = Wr(fe), t.redrawHint("select", !0), t.redraw());
}
ce && ce.pannable() && ce.active() && ce.unactivate();
}
} else {
if (ce && ce.pannable() && ce.active() && ce.unactivate(), (!ce || !ce.grabbed()) && Ae != Ce && (Ce && n(Ce, ["mouseout", "tapdragout"], P, {
x: te[0],
y: te[1]
}), Ae && n(Ae, ["mouseover", "tapdragover"], P, {
x: te[0],
y: te[1]
}), t.hoverData.last = Ae), ce)
if (je) {
if (K.boxSelectionEnabled() && ft)
ce && ce.grabbed() && (y(Le), ce.emit(Ze("freeon")), Le.emit(Ze("free")), t.dragData.didDrag && (ce.emit(Ze("dragfreeon")), Le.emit(Ze("dragfree")))), Xt();
else if (ce && ce.grabbed() && t.nodeIsDraggable(ce)) {
var Tt = !t.dragData.didDrag;
Tt && t.redrawHint("eles", !0), t.dragData.didDrag = !0, t.hoverData.draggingEles || p(Le, {
inDragLayer: !0
});
var gt = {
x: 0,
y: 0
};
if (ne(Re[0]) && ne(Re[1]) && (gt.x += Re[0], gt.y += Re[1], Tt)) {
var Ct = t.hoverData.dragDelta;
Ct && ne(Ct[0]) && ne(Ct[1]) && (gt.x += Ct[0], gt.y += Ct[1]);
}
t.hoverData.draggingEles = !0, Le.silentShift(gt).emit(Ze("position")).emit(Ze("drag")), t.redrawHint("drag", !0), t.redraw();
}
} else
tr();
$ = !0;
}
if (me[2] = te[0], me[3] = te[1], $)
return P.stopPropagation && P.stopPropagation(), P.preventDefault && P.preventDefault(), !1;
}
}, !1);
var L, R, I;
t.registerBinding(e, "mouseup", function(P) {
if (!(t.hoverData.which === 1 && P.which !== 1 && t.hoverData.capture)) {
var U = t.hoverData.capture;
if (U) {
t.hoverData.capture = !1;
var $ = t.cy, K = t.projectIntoViewport(P.clientX, P.clientY), j = t.selection, oe = t.findNearestElement(K[0], K[1], !0, !1), te = t.dragData.possibleDragElements, fe = t.hoverData.down, le = i(P);
t.data.bgActivePosistion && (t.redrawHint("select", !0), t.redraw()), t.hoverData.tapholdCancelled = !0, t.data.bgActivePosistion = void 0, fe && fe.unactivate();
var me = function($e) {
return {
originalEvent: P,
type: $e,
position: {
x: K[0],
y: K[1]
}
};
};
if (t.hoverData.which === 3) {
var Ae = me("cxttapend");
if (fe ? fe.emit(Ae) : $.emit(Ae), !t.hoverData.cxtDragged) {
var Ce = me("cxttap");
fe ? fe.emit(Ce) : $.emit(Ce);
}
t.hoverData.cxtDragged = !1, t.hoverData.which = null;
} else if (t.hoverData.which === 1) {
if (n(oe, ["mouseup", "tapend", "vmouseup"], P, {
x: K[0],
y: K[1]
}), !t.dragData.didDrag && // didn't move a node around
!t.hoverData.dragged && // didn't pan
!t.hoverData.selecting && // not box selection
!t.hoverData.isOverThresholdDrag && (n(fe, ["click", "tap", "vclick"], P, {
x: K[0],
y: K[1]
}), R = !1, P.timeStamp - I <= $.multiClickDebounceTime() ? (L && clearTimeout(L), R = !0, I = null, n(fe, ["dblclick", "dbltap", "vdblclick"], P, {
x: K[0],
y: K[1]
})) : (L = setTimeout(function() {
R || n(fe, ["oneclick", "onetap", "voneclick"], P, {
x: K[0],
y: K[1]
});
}, $.multiClickDebounceTime()), I = P.timeStamp)), fe == null && !t.dragData.didDrag && !t.hoverData.selecting && !t.hoverData.dragged && !i(P) && ($.$(r).unselect(["tapunselect"]), te.length > 0 && t.redrawHint("eles", !0), t.dragData.possibleDragElements = te = $.collection()), oe == fe && !t.dragData.didDrag && !t.hoverData.selecting && oe != null && oe._private.selectable && (t.hoverData.dragging || ($.selectionType() === "additive" || le ? oe.selected() ? oe.unselect(["tapunselect"]) : oe.select(["tapselect"]) : le || ($.$(r).unmerge(oe).unselect(["tapunselect"]), oe.select(["tapselect"]))), t.redrawHint("eles", !0)), t.hoverData.selecting) {
var ce = $.collection(t.getAllInBox(j[0], j[1], j[2], j[3]));
t.redrawHint("select", !0), ce.length > 0 && t.redrawHint("eles", !0), $.emit(me("boxend"));
var Re = function($e) {
return $e.selectable() && !$e.selected();
};
$.selectionType() === "additive" || le || $.$(r).unmerge(ce).unselect(), ce.emit(me("box")).stdFilter(Re).select().emit(me("boxselect")), t.redraw();
}
if (t.hoverData.dragging && (t.hoverData.dragging = !1, t.redrawHint("select", !0), t.redrawHint("eles", !0), t.redraw()), !j[4]) {
t.redrawHint("drag", !0), t.redrawHint("eles", !0);
var Le = fe && fe.grabbed();
y(te), Le && (fe.emit(me("freeon")), te.emit(me("free")), t.dragData.didDrag && (fe.emit(me("dragfreeon")), te.emit(me("dragfree"))));
}
}
j[4] = 0, t.hoverData.down = null, t.hoverData.cxtStarted = !1, t.hoverData.draggingEles = !1, t.hoverData.selecting = !1, t.hoverData.isOverThresholdDrag = !1, t.dragData.didDrag = !1, t.hoverData.dragged = !1, t.hoverData.dragDelta = [], t.hoverData.mdownPos = null, t.hoverData.mdownGPos = null, t.hoverData.which = null;
}
}
}, !1);
var M = [], N = 4, O, k = 1e5, B = function(P, U) {
for (var $ = 0; $ < P.length; $++)
if (P[$] % U !== 0)
return !1;
return !0;
}, _ = function(P) {
for (var U = Math.abs(P[0]), $ = 1; $ < P.length; $++)
if (Math.abs(P[$]) !== U)
return !1;
return !0;
}, F = function(P) {
var U = !1, $ = P.deltaY;
if ($ == null && (P.wheelDeltaY != null ? $ = P.wheelDeltaY / 4 : P.wheelDelta != null && ($ = P.wheelDelta / 4)), $ !== 0) {
if (O == null)
if (M.length >= N) {
var K = M;
if (O = B(K, 5), !O) {
var j = Math.abs(K[0]);
O = _(K) && j > 5;
}
if (O)
for (var oe = 0; oe < K.length; oe++)
k = Math.min(Math.abs(K[oe]), k);
} else
M.push($), U = !0;
else
O && (k = Math.min(Math.abs($), k));
if (!t.scrollingPage) {
var te = t.cy, fe = te.zoom(), le = te.pan(), me = t.projectIntoViewport(P.clientX, P.clientY), Ae = [me[0] * fe + le.x, me[1] * fe + le.y];
if (t.hoverData.draggingEles || t.hoverData.dragging || t.hoverData.cxtStarted || C()) {
P.preventDefault();
return;
}
if (te.panningEnabled() && te.userPanningEnabled() && te.zoomingEnabled() && te.userZoomingEnabled()) {
P.preventDefault(), t.data.wheelZooming = !0, clearTimeout(t.data.wheelTimeout), t.data.wheelTimeout = setTimeout(function() {
t.data.wheelZooming = !1, t.redrawHint("eles", !0), t.redraw();
}, 150);
var Ce;
U && Math.abs($) > 5 && ($ = vo($) * 5), Ce = $ / -250, O && (Ce /= k, Ce *= 3), Ce = Ce * t.wheelSensitivity;
var ce = P.deltaMode === 1;
ce && (Ce *= 33);
var Re = te.zoom() * Math.pow(10, Ce);
P.type === "gesturechange" && (Re = t.gestureStartZoom * P.scale), te.zoom({
level: Re,
renderedPosition: {
x: Ae[0],
y: Ae[1]
}
}), te.emit({
type: P.type === "gesturechange" ? "pinchzoom" : "scrollzoom",
originalEvent: P,
position: {
x: me[0],
y: me[1]
}
});
}
}
}
};
t.registerBinding(t.container, "wheel", F, !0), t.registerBinding(e, "scroll", function(P) {
t.scrollingPage = !0, clearTimeout(t.scrollingPageTimeout), t.scrollingPageTimeout = setTimeout(function() {
t.scrollingPage = !1;
}, 250);
}, !0), t.registerBinding(t.container, "gesturestart", function(P) {
t.gestureStartZoom = t.cy.zoom(), t.hasTouchStarted || P.preventDefault();
}, !0), t.registerBinding(t.container, "gesturechange", function(Q) {
t.hasTouchStarted || F(Q);
}, !0), t.registerBinding(t.container, "mouseout", function(P) {
var U = t.projectIntoViewport(P.clientX, P.clientY);
t.cy.emit({
originalEvent: P,
type: "mouseout",
position: {
x: U[0],
y: U[1]
}
});
}, !1), t.registerBinding(t.container, "mouseover", function(P) {
var U = t.projectIntoViewport(P.clientX, P.clientY);
t.cy.emit({
originalEvent: P,
type: "mouseover",
position: {
x: U[0],
y: U[1]
}
});
}, !1);
var G, H, Y, X, W, ee, ae, J, z, V, q, Z, re, ve = function(P, U, $, K) {
return Math.sqrt(($ - P) * ($ - P) + (K - U) * (K - U));
}, Ie = function(P, U, $, K) {
return ($ - P) * ($ - P) + (K - U) * (K - U);
}, Te;
t.registerBinding(t.container, "touchstart", Te = function(P) {
if (t.hasTouchStarted = !0, !!D(P)) {
m(), t.touchData.capture = !0, t.data.bgActivePosistion = void 0;
var U = t.cy, $ = t.touchData.now, K = t.touchData.earlier;
if (P.touches[0]) {
var j = t.projectIntoViewport(P.touches[0].clientX, P.touches[0].clientY);
$[0] = j[0], $[1] = j[1];
}
if (P.touches[1]) {
var j = t.projectIntoViewport(P.touches[1].clientX, P.touches[1].clientY);
$[2] = j[0], $[3] = j[1];
}
if (P.touches[2]) {
var j = t.projectIntoViewport(P.touches[2].clientX, P.touches[2].clientY);
$[4] = j[0], $[5] = j[1];
}
var oe = function(ft) {
return {
originalEvent: P,
type: ft,
position: {
x: $[0],
y: $[1]
}
};
};
if (P.touches[1]) {
t.touchData.singleTouchMoved = !0, y(t.dragData.touchDragEles);
var te = t.findContainerClientCoords();
z = te[0], V = te[1], q = te[2], Z = te[3], G = P.touches[0].clientX - z, H = P.touches[0].clientY - V, Y = P.touches[1].clientX - z, X = P.touches[1].clientY - V, re = 0 <= G && G <= q && 0 <= Y && Y <= q && 0 <= H && H <= Z && 0 <= X && X <= Z;
var fe = U.pan(), le = U.zoom();
W = ve(G, H, Y, X), ee = Ie(G, H, Y, X), ae = [(G + Y) / 2, (H + X) / 2], J = [(ae[0] - fe.x) / le, (ae[1] - fe.y) / le];
var me = 200, Ae = me * me;
if (ee < Ae && !P.touches[2]) {
var Ce = t.findNearestElement($[0], $[1], !0, !0), ce = t.findNearestElement($[2], $[3], !0, !0);
Ce && Ce.isNode() ? (Ce.activate().emit(oe("cxttapstart")), t.touchData.start = Ce) : ce && ce.isNode() ? (ce.activate().emit(oe("cxttapstart")), t.touchData.start = ce) : U.emit(oe("cxttapstart")), t.touchData.start && (t.touchData.start._private.grabbed = !1), t.touchData.cxt = !0, t.touchData.cxtDragged = !1, t.data.bgActivePosistion = void 0, t.redraw();
return;
}
}
if (P.touches[2])
U.boxSelectionEnabled() && P.preventDefault();
else if (!P.touches[1]) {
if (P.touches[0]) {
var Re = t.findNearestElements($[0], $[1], !0, !0), Le = Re[0];
if (Le != null && (Le.activate(), t.touchData.start = Le, t.touchData.starts = Re, t.nodeIsGrabbable(Le))) {
var je = t.dragData.touchDragEles = U.collection(), $e = null;
t.redrawHint("eles", !0), t.redrawHint("drag", !0), Le.selected() ? ($e = U.$(function(et) {
return et.selected() && t.nodeIsGrabbable(et);
}), p($e, {
addToList: je
})) : g(Le, {
addToList: je
}), c(Le), Le.emit(oe("grabon")), $e ? $e.forEach(function(et) {
et.emit(oe("grab"));
}) : Le.emit(oe("grab"));
}
n(Le, ["touchstart", "tapstart", "vmousedown"], P, {
x: $[0],
y: $[1]
}), Le == null && (t.data.bgActivePosistion = {
x: j[0],
y: j[1]
}, t.redrawHint("select", !0), t.redraw()), t.touchData.singleTouchMoved = !1, t.touchData.singleTouchStartTime = +/* @__PURE__ */ new Date(), clearTimeout(t.touchData.tapholdTimeout), t.touchData.tapholdTimeout = setTimeout(function() {
t.touchData.singleTouchMoved === !1 && !t.pinching && !t.touchData.selecting && n(t.touchData.start, ["taphold"], P, {
x: $[0],
y: $[1]
});
}, t.tapholdDuration);
}
}
if (P.touches.length >= 1) {
for (var bt = t.touchData.startPosition = [null, null, null, null, null, null], Ke = 0; Ke < $.length; Ke++)
bt[Ke] = K[Ke] = $[Ke];
var st = P.touches[0];
t.touchData.startGPosition = [st.clientX, st.clientY];
}
}
}, !1);
var we;
t.registerBinding(e, "touchmove", we = function(P) {
var U = t.touchData.capture;
if (!(!U && !D(P))) {
var $ = t.selection, K = t.cy, j = t.touchData.now, oe = t.touchData.earlier, te = K.zoom();
if (P.touches[0]) {
var fe = t.projectIntoViewport(P.touches[0].clientX, P.touches[0].clientY);
j[0] = fe[0], j[1] = fe[1];
}
if (P.touches[1]) {
var fe = t.projectIntoViewport(P.touches[1].clientX, P.touches[1].clientY);
j[2] = fe[0], j[3] = fe[1];
}
if (P.touches[2]) {
var fe = t.projectIntoViewport(P.touches[2].clientX, P.touches[2].clientY);
j[4] = fe[0], j[5] = fe[1];
}
var le = function(pv) {
return {
originalEvent: P,
type: pv,
position: {
x: j[0],
y: j[1]
}
};
}, me = t.touchData.startGPosition, Ae;
if (U && P.touches[0] && me) {
for (var Ce = [], ce = 0; ce < j.length; ce++)
Ce[ce] = j[ce] - oe[ce];
var Re = P.touches[0].clientX - me[0], Le = Re * Re, je = P.touches[0].clientY - me[1], $e = je * je, bt = Le + $e;
Ae = bt >= t.touchTapThreshold2;
}
if (U && t.touchData.cxt) {
P.preventDefault();
var Ke = P.touches[0].clientX - z, st = P.touches[0].clientY - V, et = P.touches[1].clientX - z, ft = P.touches[1].clientY - V, tr = Ie(Ke, st, et, ft), Ze = tr / ee, Xt = 150, $t = Xt * Xt, _r = 1.5, Wa = _r * _r;
if (Ze >= Wa || tr >= $t) {
t.touchData.cxt = !1, t.data.bgActivePosistion = void 0, t.redrawHint("select", !0);
var xr = le("cxttapend");
t.touchData.start ? (t.touchData.start.unactivate().emit(xr), t.touchData.start = null) : K.emit(xr);
}
}
if (U && t.touchData.cxt) {
var xr = le("cxtdrag");
t.data.bgActivePosistion = void 0, t.redrawHint("select", !0), t.touchData.start ? t.touchData.start.emit(xr) : K.emit(xr), t.touchData.start && (t.touchData.start._private.grabbed = !1), t.touchData.cxtDragged = !0;
var Tt = t.findNearestElement(j[0], j[1], !0, !0);
(!t.touchData.cxtOver || Tt !== t.touchData.cxtOver) && (t.touchData.cxtOver && t.touchData.cxtOver.emit(le("cxtdragout")), t.touchData.cxtOver = Tt, Tt && Tt.emit(le("cxtdragover")));
} else if (U && P.touches[2] && K.boxSelectionEnabled())
P.preventDefault(), t.data.bgActivePosistion = void 0, this.lastThreeTouch = +/* @__PURE__ */ new Date(), t.touchData.selecting || K.emit(le("boxstart")), t.touchData.selecting = !0, t.touchData.didSelect = !0, $[4] = 1, !$ || $.length === 0 || $[0] === void 0 ? ($[0] = (j[0] + j[2] + j[4]) / 3, $[1] = (j[1] + j[3] + j[5]) / 3, $[2] = (j[0] + j[2] + j[4]) / 3 + 1, $[3] = (j[1] + j[3] + j[5]) / 3 + 1) : ($[2] = (j[0] + j[2] + j[4]) / 3, $[3] = (j[1] + j[3] + j[5]) / 3), t.redrawHint("select", !0), t.redraw();
else if (U && P.touches[1] && !t.touchData.didSelect && K.zoomingEnabled() && K.panningEnabled() && K.userZoomingEnabled() && K.userPanningEnabled()) {
P.preventDefault(), t.data.bgActivePosistion = void 0, t.redrawHint("select", !0);
var gt = t.dragData.touchDragEles;
if (gt) {
t.redrawHint("drag", !0);
for (var Ct = 0; Ct < gt.length; Ct++) {
var fa = gt[Ct]._private;
fa.grabbed = !1, fa.rscratch.inDragLayer = !1;
}
}
var Rt = t.touchData.start, Ke = P.touches[0].clientX - z, st = P.touches[0].clientY - V, et = P.touches[1].clientX - z, ft = P.touches[1].clientY - V, Po = ve(Ke, st, et, ft), ov = Po / W;
if (re) {
var uv = Ke - G, lv = st - H, fv = et - Y, cv = ft - X, vv = (uv + fv) / 2, hv = (lv + cv) / 2, ca = K.zoom(), ti = ca * ov, Ka = K.pan(), Mo = J[0] * ca + Ka.x, Oo = J[1] * ca + Ka.y, dv = {
x: -ti / ca * (Mo - Ka.x - vv) + Mo,
y: -ti / ca * (Oo - Ka.y - hv) + Oo
};
if (Rt && Rt.active()) {
var gt = t.dragData.touchDragEles;
y(gt), t.redrawHint("drag", !0), t.redrawHint("eles", !0), Rt.unactivate().emit(le("freeon")), gt.emit(le("free")), t.dragData.didDrag && (Rt.emit(le("dragfreeon")), gt.emit(le("dragfree")));
}
K.viewport({
zoom: ti,
pan: dv,
cancelOnFailedZoom: !0
}), K.emit(le("pinchzoom")), W = Po, G = Ke, H = st, Y = et, X = ft, t.pinching = !0;
}
if (P.touches[0]) {
var fe = t.projectIntoViewport(P.touches[0].clientX, P.touches[0].clientY);
j[0] = fe[0], j[1] = fe[1];
}
if (P.touches[1]) {
var fe = t.projectIntoViewport(P.touches[1].clientX, P.touches[1].clientY);
j[2] = fe[0], j[3] = fe[1];
}
if (P.touches[2]) {
var fe = t.projectIntoViewport(P.touches[2].clientX, P.touches[2].clientY);
j[4] = fe[0], j[5] = fe[1];
}
} else if (P.touches[0] && !t.touchData.didSelect) {
var Ot = t.touchData.start, ri = t.touchData.last, Tt;
if (!t.hoverData.draggingEles && !t.swipePanning && (Tt = t.findNearestElement(j[0], j[1], !0, !0)), U && Ot != null && P.preventDefault(), U && Ot != null && t.nodeIsDraggable(Ot))
if (Ae) {
var gt = t.dragData.touchDragEles, ko = !t.dragData.didDrag;
ko && p(gt, {
inDragLayer: !0
}), t.dragData.didDrag = !0;
var va = {
x: 0,
y: 0
};
if (ne(Ce[0]) && ne(Ce[1]) && (va.x += Ce[0], va.y += Ce[1], ko)) {
t.redrawHint("eles", !0);
var kt = t.touchData.dragDelta;
kt && ne(kt[0]) && ne(kt[1]) && (va.x += kt[0], va.y += kt[1]);
}
t.hoverData.draggingEles = !0, gt.silentShift(va).emit(le("position")).emit(le("drag")), t.redrawHint("drag", !0), t.touchData.startPosition[0] == oe[0] && t.touchData.startPosition[1] == oe[1] && t.redrawHint("eles", !0), t.redraw();
} else {
var kt = t.touchData.dragDelta = t.touchData.dragDelta || [];
kt.length === 0 ? (kt.push(Ce[0]), kt.push(Ce[1])) : (kt[0] += Ce[0], kt[1] += Ce[1]);
}
if (n(Ot || Tt, ["touchmove", "tapdrag", "vmousemove"], P, {
x: j[0],
y: j[1]
}), (!Ot || !Ot.grabbed()) && Tt != ri && (ri && ri.emit(le("tapdragout")), Tt && Tt.emit(le("tapdragover"))), t.touchData.last = Tt, U)
for (var Ct = 0; Ct < j.length; Ct++)
j[Ct] && t.touchData.startPosition[Ct] && Ae && (t.touchData.singleTouchMoved = !0);
if (U && (Ot == null || Ot.pannable()) && K.panningEnabled() && K.userPanningEnabled()) {
var gv = s(Ot, t.touchData.starts);
gv && (P.preventDefault(), t.data.bgActivePosistion || (t.data.bgActivePosistion = Wr(t.touchData.startPosition)), t.swipePanning ? (K.panBy({
x: Ce[0] * te,
y: Ce[1] * te
}), K.emit(le("dragpan"))) : Ae && (t.swipePanning = !0, K.panBy({
x: Re * te,
y: je * te
}), K.emit(le("dragpan")), Ot && (Ot.unactivate(), t.redrawHint("select", !0), t.touchData.start = null)));
var fe = t.projectIntoViewport(P.touches[0].clientX, P.touches[0].clientY);
j[0] = fe[0], j[1] = fe[1];
}
}
for (var ce = 0; ce < j.length; ce++)
oe[ce] = j[ce];
U && P.touches.length > 0 && !t.hoverData.draggingEles && !t.swipePanning && t.data.bgActivePosistion != null && (t.data.bgActivePosistion = void 0, t.redrawHint("select", !0), t.redraw());
}
}, !1);
var ye;
t.registerBinding(e, "touchcancel", ye = function(P) {
var U = t.touchData.start;
t.touchData.capture = !1, U && U.unactivate();
});
var ie, he, de, xe;
if (t.registerBinding(e, "touchend", ie = function(P) {
var U = t.touchData.start, $ = t.touchData.capture;
if ($)
P.touches.length === 0 && (t.touchData.capture = !1), P.preventDefault();
else
return;
var K = t.selection;
t.swipePanning = !1, t.hoverData.draggingEles = !1;
var j = t.cy, oe = j.zoom(), te = t.touchData.now, fe = t.touchData.earlier;
if (P.touches[0]) {
var le = t.projectIntoViewport(P.touches[0].clientX, P.touches[0].clientY);
te[0] = le[0], te[1] = le[1];
}
if (P.touches[1]) {
var le = t.projectIntoViewport(P.touches[1].clientX, P.touches[1].clientY);
te[2] = le[0], te[3] = le[1];
}
if (P.touches[2]) {
var le = t.projectIntoViewport(P.touches[2].clientX, P.touches[2].clientY);
te[4] = le[0], te[5] = le[1];
}
var me = function($t) {
return {
originalEvent: P,
type: $t,
position: {
x: te[0],
y: te[1]
}
};
};
U && U.unactivate();
var Ae;
if (t.touchData.cxt) {
if (Ae = me("cxttapend"), U ? U.emit(Ae) : j.emit(Ae), !t.touchData.cxtDragged) {
var Ce = me("cxttap");
U ? U.emit(Ce) : j.emit(Ce);
}
t.touchData.start && (t.touchData.start._private.grabbed = !1), t.touchData.cxt = !1, t.touchData.start = null, t.redraw();
return;
}
if (!P.touches[2] && j.boxSelectionEnabled() && t.touchData.selecting) {
t.touchData.selecting = !1;
var ce = j.collection(t.getAllInBox(K[0], K[1], K[2], K[3]));
K[0] = void 0, K[1] = void 0, K[2] = void 0, K[3] = void 0, K[4] = 0, t.redrawHint("select", !0), j.emit(me("boxend"));
var Re = function($t) {
return $t.selectable() && !$t.selected();
};
ce.emit(me("box")).stdFilter(Re).select().emit(me("boxselect")), ce.nonempty() && t.redrawHint("eles", !0), t.redraw();
}
if (U != null && U.unactivate(), P.touches[2])
t.data.bgActivePosistion = void 0, t.redrawHint("select", !0);
else if (!P.touches[1]) {
if (!P.touches[0]) {
if (!P.touches[0]) {
t.data.bgActivePosistion = void 0, t.redrawHint("select", !0);
var Le = t.dragData.touchDragEles;
if (U != null) {
var je = U._private.grabbed;
y(Le), t.redrawHint("drag", !0), t.redrawHint("eles", !0), je && (U.emit(me("freeon")), Le.emit(me("free")), t.dragData.didDrag && (U.emit(me("dragfreeon")), Le.emit(me("dragfree")))), n(U, ["touchend", "tapend", "vmouseup", "tapdragout"], P, {
x: te[0],
y: te[1]
}), U.unactivate(), t.touchData.start = null;
} else {
var $e = t.findNearestElement(te[0], te[1], !0, !0);
n($e, ["touchend", "tapend", "vmouseup", "tapdragout"], P, {
x: te[0],
y: te[1]
});
}
var bt = t.touchData.startPosition[0] - te[0], Ke = bt * bt, st = t.touchData.startPosition[1] - te[1], et = st * st, ft = Ke + et, tr = ft * oe * oe;
t.touchData.singleTouchMoved || (U || j.$(":selected").unselect(["tapunselect"]), n(U, ["tap", "vclick"], P, {
x: te[0],
y: te[1]
}), he = !1, P.timeStamp - xe <= j.multiClickDebounceTime() ? (de && clearTimeout(de), he = !0, xe = null, n(U, ["dbltap", "vdblclick"], P, {
x: te[0],
y: te[1]
})) : (de = setTimeout(function() {
he || n(U, ["onetap", "voneclick"], P, {
x: te[0],
y: te[1]
});
}, j.multiClickDebounceTime()), xe = P.timeStamp)), U != null && !t.dragData.didDrag && U._private.selectable && tr < t.touchTapThreshold2 && !t.pinching && (j.selectionType() === "single" ? (j.$(r).unmerge(U).unselect(["tapunselect"]), U.select(["tapselect"])) : U.selected() ? U.unselect(["tapunselect"]) : U.select(["tapselect"]), t.redrawHint("eles", !0)), t.touchData.singleTouchMoved = !0;
}
}
}
for (var Ze = 0; Ze < te.length; Ze++)
fe[Ze] = te[Ze];
t.dragData.didDrag = !1, P.touches.length === 0 && (t.touchData.dragDelta = [], t.touchData.startPosition = [null, null, null, null, null, null], t.touchData.startGPosition = null, t.touchData.didSelect = !1), P.touches.length < 2 && (P.touches.length === 1 && (t.touchData.startGPosition = [P.touches[0].clientX, P.touches[0].clientY]), t.pinching = !1, t.redrawHint("eles", !0), t.redraw());
}, !1), typeof TouchEvent > "u") {
var pe = [], De = function(P) {
return {
clientX: P.clientX,
clientY: P.clientY,
force: 1,
identifier: P.pointerId,
pageX: P.pageX,
pageY: P.pageY,
radiusX: P.width / 2,
radiusY: P.height / 2,
screenX: P.screenX,
screenY: P.screenY,
target: P.target
};
}, Pe = function(P) {
return {
event: P,
touch: De(P)
};
}, Ne = function(P) {
pe.push(Pe(P));
}, Be = function(P) {
for (var U = 0; U < pe.length; U++) {
var $ = pe[U];
if ($.event.pointerId === P.pointerId) {
pe.splice(U, 1);
return;
}
}
}, Fe = function(P) {
var U = pe.filter(function($) {
return $.event.pointerId === P.pointerId;
})[0];
U.event = P, U.touch = De(P);
}, Ee = function(P) {
P.touches = pe.map(function(U) {
return U.touch;
});
}, ue = function(P) {
return P.pointerType === "mouse" || P.pointerType === 4;
};
t.registerBinding(t.container, "pointerdown", function(Q) {
ue(Q) || (Q.preventDefault(), Ne(Q), Ee(Q), Te(Q));
}), t.registerBinding(t.container, "pointerup", function(Q) {
ue(Q) || (Be(Q), Ee(Q), ie(Q));
}), t.registerBinding(t.container, "pointercancel", function(Q) {
ue(Q) || (Be(Q), Ee(Q), ye(Q));
}), t.registerBinding(t.container, "pointermove", function(Q) {
ue(Q) || (Q.preventDefault(), Fe(Q), Ee(Q), we(Q));
});
}
};
var jt = {};
jt.generatePolygon = function(t, e) {
return this.nodeShapes[t] = {
renderer: this,
name: t,
points: e,
draw: function(a, n, i, s, o, u) {
this.renderer.nodeShapeImpl("polygon", a, n, i, s, o, this.points);
},
intersectLine: function(a, n, i, s, o, u, l, f) {
return Ia(o, u, this.points, a, n, i / 2, s / 2, l);
},
checkPoint: function(a, n, i, s, o, u, l, f) {
return Jt(a, n, this.points, u, l, s, o, [0, -1], i);
},
hasMiterBounds: t !== "rectangle",
miterBounds: function(a, n, i, s, o, u) {
return rd(this.points, a, n, i, s, o);
}
};
};
jt.generateEllipse = function() {
return this.nodeShapes.ellipse = {
renderer: this,
name: "ellipse",
draw: function(e, r, a, n, i, s) {
this.renderer.nodeShapeImpl(this.name, e, r, a, n, i);
},
intersectLine: function(e, r, a, n, i, s, o, u) {
return fd(i, s, e, r, a / 2 + o, n / 2 + o);
},
checkPoint: function(e, r, a, n, i, s, o, u) {
return Rr(e, r, n, i, s, o, a);
}
};
};
jt.generateRoundPolygon = function(t, e) {
return this.nodeShapes[t] = {
renderer: this,
name: t,
points: e,
getOrCreateCorners: function(a, n, i, s, o, u, l) {
if (u[l] !== void 0 && u[l + "-cx"] === a && u[l + "-cy"] === n)
return u[l];
u[l] = new Array(e.length / 2), u[l + "-cx"] = a, u[l + "-cy"] = n;
var f = i / 2, c = s / 2;
o = o === "auto" ? Bf(i, s) : o;
for (var v = new Array(e.length / 2), h = 0; h < e.length / 2; h++)
v[h] = {
x: a + f * e[h * 2],
y: n + c * e[h * 2 + 1]
};
var d, p, g, y, b = v.length;
for (p = v[b - 1], d = 0; d < b; d++)
g = v[d % b], y = v[(d + 1) % b], u[l][d] = So(p, g, y, o), p = g, g = y;
return u[l];
},
draw: function(a, n, i, s, o, u, l) {
this.renderer.nodeShapeImpl("round-polygon", a, n, i, s, o, this.points, this.getOrCreateCorners(n, i, s, o, u, l, "drawCorners"));
},
intersectLine: function(a, n, i, s, o, u, l, f, c) {
return vd(o, u, this.points, a, n, i, s, l, this.getOrCreateCorners(a, n, i, s, f, c, "corners"));
},
checkPoint: function(a, n, i, s, o, u, l, f, c) {
return ld(a, n, this.points, u, l, s, o, this.getOrCreateCorners(u, l, s, o, f, c, "corners"));
}
};
};
jt.generateRoundRectangle = function() {
return this.nodeShapes["round-rectangle"] = this.nodeShapes.roundrectangle = {
renderer: this,
name: "round-rectangle",
points: wt(4, 0),
draw: function(e, r, a, n, i, s) {
this.renderer.nodeShapeImpl(this.name, e, r, a, n, i, this.points, s);
},
intersectLine: function(e, r, a, n, i, s, o, u) {
return kf(i, s, e, r, a, n, o, u);
},
checkPoint: function(e, r, a, n, i, s, o, u) {
var l = n / 2, f = i / 2;
u = u === "auto" ? vr(n, i) : u, u = Math.min(l, f, u);
var c = u * 2;
return !!(Jt(e, r, this.points, s, o, n, i - c, [0, -1], a) || Jt(e, r, this.points, s, o, n - c, i, [0, -1], a) || Rr(e, r, c, c, s - l + u, o - f + u, a) || Rr(e, r, c, c, s + l - u, o - f + u, a) || Rr(e, r, c, c, s + l - u, o + f - u, a) || Rr(e, r, c, c, s - l + u, o + f - u, a));
}
};
};
jt.generateCutRectangle = function() {
return this.nodeShapes["cut-rectangle"] = this.nodeShapes.cutrectangle = {
renderer: this,
name: "cut-rectangle",
cornerLength: go(),
points: wt(4, 0),
draw: function(e, r, a, n, i, s) {
this.renderer.nodeShapeImpl(this.name, e, r, a, n, i, null, s);
},
generateCutTrianglePts: function(e, r, a, n, i) {
var s = i === "auto" ? this.cornerLength : i, o = r / 2, u = e / 2, l = a - u, f = a + u, c = n - o, v = n + o;
return {
topLeft: [l, c + s, l + s, c, l + s, c + s],
topRight: [f - s, c, f, c + s, f - s, c + s],
bottomRight: [f, v - s, f - s, v, f - s, v - s],
bottomLeft: [l + s, v, l, v - s, l + s, v - s]
};
},
intersectLine: function(e, r, a, n, i, s, o, u) {
var l = this.generateCutTrianglePts(a + 2 * o, n + 2 * o, e, r, u), f = [].concat.apply([], [l.topLeft.splice(0, 4), l.topRight.splice(0, 4), l.bottomRight.splice(0, 4), l.bottomLeft.splice(0, 4)]);
return Ia(i, s, f, e, r);
},
checkPoint: function(e, r, a, n, i, s, o, u) {
var l = u === "auto" ? this.cornerLength : u;
if (Jt(e, r, this.points, s, o, n, i - 2 * l, [0, -1], a) || Jt(e, r, this.points, s, o, n - 2 * l, i, [0, -1], a))
return !0;
var f = this.generateCutTrianglePts(n, i, s, o);
return St(e, r, f.topLeft) || St(e, r, f.topRight) || St(e, r, f.bottomRight) || St(e, r, f.bottomLeft);
}
};
};
jt.generateBarrel = function() {
return this.nodeShapes.barrel = {
renderer: this,
name: "barrel",
points: wt(4, 0),
draw: function(e, r, a, n, i, s) {
this.renderer.nodeShapeImpl(this.name, e, r, a, n, i);
},
intersectLine: function(e, r, a, n, i, s, o, u) {
var l = 0.15, f = 0.5, c = 0.85, v = this.generateBarrelBezierPts(a + 2 * o, n + 2 * o, e, r), h = function(g) {
var y = Qr({
x: g[0],
y: g[1]
}, {
x: g[2],
y: g[3]
}, {
x: g[4],
y: g[5]
}, l), b = Qr({
x: g[0],
y: g[1]
}, {
x: g[2],
y: g[3]
}, {
x: g[4],
y: g[5]
}, f), m = Qr({
x: g[0],
y: g[1]
}, {
x: g[2],
y: g[3]
}, {
x: g[4],
y: g[5]
}, c);
return [g[0], g[1], y.x, y.y, b.x, b.y, m.x, m.y, g[4], g[5]];
}, d = [].concat(h(v.topLeft), h(v.topRight), h(v.bottomRight), h(v.bottomLeft));
return Ia(i, s, d, e, r);
},
generateBarrelBezierPts: function(e, r, a, n) {
var i = r / 2, s = e / 2, o = a - s, u = a + s, l = n - i, f = n + i, c = Fs(e, r), v = c.heightOffset, h = c.widthOffset, d = c.ctrlPtOffsetPct * e, p = {
topLeft: [o, l + v, o + d, l, o + h, l],
topRight: [u - h, l, u - d, l, u, l + v],
bottomRight: [u, f - v, u - d, f, u - h, f],
bottomLeft: [o + h, f, o + d, f, o, f - v]
};
return p.topLeft.isTop = !0, p.topRight.isTop = !0, p.bottomLeft.isBottom = !0, p.bottomRight.isBottom = !0, p;
},
checkPoint: function(e, r, a, n, i, s, o, u) {
var l = Fs(n, i), f = l.heightOffset, c = l.widthOffset;
if (Jt(e, r, this.points, s, o, n, i - 2 * f, [0, -1], a) || Jt(e, r, this.points, s, o, n - 2 * c, i, [0, -1], a))
return !0;
for (var v = this.generateBarrelBezierPts(n, i, s, o), h = function(x, C, D) {
var A = D[4], L = D[2], R = D[0], I = D[5], M = D[1], N = Math.min(A, R), O = Math.max(A, R), k = Math.min(I, M), B = Math.max(I, M);
if (N <= x && x <= O && k <= C && C <= B) {
var _ = hd(A, L, R), F = id(_[0], _[1], _[2], x), G = F.filter(function(H) {
return 0 <= H && H <= 1;
});
if (G.length > 0)
return G[0];
}
return null;
}, d = Object.keys(v), p = 0; p < d.length; p++) {
var g = d[p], y = v[g], b = h(e, r, y);
if (b != null) {
var m = y[5], E = y[3], T = y[1], S = ot(m, E, T, b);
if (y.isTop && S <= r || y.isBottom && r <= S)
return !0;
}
}
return !1;
}
};
};
jt.generateBottomRoundrectangle = function() {
return this.nodeShapes["bottom-round-rectangle"] = this.nodeShapes.bottomroundrectangle = {
renderer: this,
name: "bottom-round-rectangle",
points: wt(4, 0),
draw: function(e, r, a, n, i, s) {
this.renderer.nodeShapeImpl(this.name, e, r, a, n, i, this.points, s);
},
intersectLine: function(e, r, a, n, i, s, o, u) {
var l = e - (a / 2 + o), f = r - (n / 2 + o), c = f, v = e + (a / 2 + o), h = or(i, s, e, r, l, f, v, c, !1);
return h.length > 0 ? h : kf(i, s, e, r, a, n, o, u);
},
checkPoint: function(e, r, a, n, i, s, o, u) {
u = u === "auto" ? vr(n, i) : u;
var l = 2 * u;
if (Jt(e, r, this.points, s, o, n, i - l, [0, -1], a) || Jt(e, r, this.points, s, o, n - l, i, [0, -1], a))
return !0;
var f = n / 2 + 2 * a, c = i / 2 + 2 * a, v = [s - f, o - c, s - f, o, s + f, o, s + f, o - c];
return !!(St(e, r, v) || Rr(e, r, l, l, s + n / 2 - u, o + i / 2 - u, a) || Rr(e, r, l, l, s - n / 2 + u, o + i / 2 - u, a));
}
};
};
jt.registerNodeShapes = function() {
var t = this.nodeShapes = {}, e = this;
this.generateEllipse(), this.generatePolygon("triangle", wt(3, 0)), this.generateRoundPolygon("round-triangle", wt(3, 0)), this.generatePolygon("rectangle", wt(4, 0)), t.square = t.rectangle, this.generateRoundRectangle(), this.generateCutRectangle(), this.generateBarrel(), this.generateBottomRoundrectangle();
{
var r = [0, 1, 1, 0, 0, -1, -1, 0];
this.generatePolygon("diamond", r), this.generateRoundPolygon("round-diamond", r);
}
this.generatePolygon("pentagon", wt(5, 0)), this.generateRoundPolygon("round-pentagon", wt(5, 0)), this.generatePolygon("hexagon", wt(6, 0)), this.generateRoundPolygon("round-hexagon", wt(6, 0)), this.generatePolygon("heptagon", wt(7, 0)), this.generateRoundPolygon("round-heptagon", wt(7, 0)), this.generatePolygon("octagon", wt(8, 0)), this.generateRoundPolygon("round-octagon", wt(8, 0));
var a = new Array(20);
{
var n = Bs(5, 0), i = Bs(5, Math.PI / 5), s = 0.5 * (3 - Math.sqrt(5));
s *= 1.57;
for (var o = 0; o < i.length / 2; o++)
i[o * 2] *= s, i[o * 2 + 1] *= s;
for (var o = 0; o < 20 / 4; o++)
a[o * 4] = n[o * 2], a[o * 4 + 1] = n[o * 2 + 1], a[o * 4 + 2] = i[o * 2], a[o * 4 + 3] = i[o * 2 + 1];
}
a = Nf(a), this.generatePolygon("star", a), this.generatePolygon("vee", [-1, -1, 0, -0.333, 1, -1, 0, 1]), this.generatePolygon("rhomboid", [-1, -1, 0.333, -1, 1, 1, -0.333, 1]), this.generatePolygon("right-rhomboid", [-0.333, -1, 1, -1, 0.333, 1, -1, 1]), this.nodeShapes.concavehexagon = this.generatePolygon("concave-hexagon", [-1, -0.95, -0.75, 0, -1, 0.95, 1, 0.95, 0.75, 0, 1, -0.95]);
{
var u = [-1, -1, 0.25, -1, 1, 0, 0.25, 1, -1, 1];
this.generatePolygon("tag", u), this.generateRoundPolygon("round-tag", u);
}
t.makePolygon = function(l) {
var f = l.join("$"), c = "polygon-" + f, v;
return (v = this[c]) ? v : e.generatePolygon(c, l);
};
};
var Xa = {};
Xa.timeToRender = function() {
return this.redrawTotalTime / this.redrawCount;
};
Xa.redraw = function(t) {
t = t || If();
var e = this;
e.averageRedrawTime === void 0 && (e.averageRedrawTime = 0), e.lastRedrawTime === void 0 && (e.lastRedrawTime = 0), e.lastDrawTime === void 0 && (e.lastDrawTime = 0), e.requestedFrame = !0, e.renderOptions = t;
};
Xa.beforeRender = function(t, e) {
if (!this.destroyed) {
e == null && He("Priority is not optional for beforeRender");
var r = this.beforeRenderCallbacks;
r.push({
fn: t,
priority: e
}), r.sort(function(a, n) {
return n.priority - a.priority;
});
}
};
var Xl = function(e, r, a) {
for (var n = e.beforeRenderCallbacks, i = 0; i < n.length; i++)
n[i].fn(r, a);
};
Xa.startRenderLoop = function() {
var t = this, e = t.cy;
if (!t.renderLoopStarted) {
t.renderLoopStarted = !0;
var r = function(n) {
if (!t.destroyed) {
if (!e.batching())
if (t.requestedFrame && !t.skipFrame) {
Xl(t, !0, n);
var i = Qt();
t.render(t.renderOptions);
var s = t.lastDrawTime = Qt();
t.averageRedrawTime === void 0 && (t.averageRedrawTime = s - i), t.redrawCount === void 0 && (t.redrawCount = 0), t.redrawCount++, t.redrawTotalTime === void 0 && (t.redrawTotalTime = 0);
var o = s - i;
t.redrawTotalTime += o, t.lastRedrawTime = o, t.averageRedrawTime = t.averageRedrawTime / 2 + o / 2, t.requestedFrame = !1;
} else
Xl(t, !1, n);
t.skipFrame = !1, Dn(r);
}
};
Dn(r);
}
};
var Ry = function(e) {
this.init(e);
}, Bc = Ry, la = Bc.prototype;
la.clientFunctions = ["redrawHint", "render", "renderTo", "matchCanvasSize", "nodeShapeImpl", "arrowShapeImpl"];
la.init = function(t) {
var e = this;
e.options = t, e.cy = t.cy;
var r = e.container = t.cy.container(), a = e.cy.window();
if (a) {
var n = a.document, i = n.head, s = "__________cytoscape_stylesheet", o = "__________cytoscape_container", u = n.getElementById(s) != null;
if (r.className.indexOf(o) < 0 && (r.className = (r.className || "") + " " + o), !u) {
var l = n.createElement("style");
l.id = s, l.textContent = "." + o + " { position: relative; }", i.insertBefore(l, i.children[0]);
}
var f = a.getComputedStyle(r), c = f.getPropertyValue("position");
c === "static" && Ge("A Cytoscape container has style position:static and so can not use UI extensions properly");
}
e.selection = [void 0, void 0, void 0, void 0, 0], e.bezierProjPcts = [0.05, 0.225, 0.4, 0.5, 0.6, 0.775, 0.95], e.hoverData = {
down: null,
last: null,
downTime: null,
triggerMode: null,
dragging: !1,
initialPan: [null, null],
capture: !1
}, e.dragData = {
possibleDragElements: []
}, e.touchData = {
start: null,
capture: !1,
// These 3 fields related to tap, taphold events
startPosition: [null, null, null, null, null, null],
singleTouchStartTime: null,
singleTouchMoved: !0,
now: [null, null, null, null, null, null],
earlier: [null, null, null, null, null, null]
}, e.redraws = 0, e.showFps = t.showFps, e.debug = t.debug, e.webgl = t.webgl, e.hideEdgesOnViewport = t.hideEdgesOnViewport, e.textureOnViewport = t.textureOnViewport, e.wheelSensitivity = t.wheelSensitivity, e.motionBlurEnabled = t.motionBlur, e.forcedPixelRatio = ne(t.pixelRatio) ? t.pixelRatio : null, e.motionBlur = t.motionBlur, e.motionBlurOpacity = t.motionBlurOpacity, e.motionBlurTransparency = 1 - e.motionBlurOpacity, e.motionBlurPxRatio = 1, e.mbPxRBlurry = 1, e.minMbLowQualFrames = 4, e.fullQualityMb = !1, e.clearedForMotionBlur = [], e.desktopTapThreshold = t.desktopTapThreshold, e.desktopTapThreshold2 = t.desktopTapThreshold * t.desktopTapThreshold, e.touchTapThreshold = t.touchTapThreshold, e.touchTapThreshold2 = t.touchTapThreshold * t.touchTapThreshold, e.tapholdDuration = 500, e.bindings = [], e.beforeRenderCallbacks = [], e.beforeRenderPriorities = {
// higher priority execs before lower one
animations: 400,
eleCalcs: 300,
eleTxrDeq: 200,
lyrTxrDeq: 150,
lyrTxrSkip: 100
}, e.registerNodeShapes(), e.registerArrowShapes(), e.registerCalculationListeners();
};
la.notify = function(t, e) {
var r = this, a = r.cy;
if (!this.destroyed) {
if (t === "init") {
r.load();
return;
}
if (t === "destroy") {
r.destroy();
return;
}
(t === "add" || t === "remove" || t === "move" && a.hasCompoundNodes() || t === "load" || t === "zorder" || t === "mount") && r.invalidateCachedZSortedEles(), t === "viewport" && r.redrawHint("select", !0), t === "gc" && r.redrawHint("gc", !0), (t === "load" || t === "resize" || t === "mount") && (r.invalidateContainerClientCoordsCache(), r.matchCanvasSize(r.container)), r.redrawHint("eles", !0), r.redrawHint("drag", !0), this.startRenderLoop(), this.redraw();
}
};
la.destroy = function() {
var t = this;
t.destroyed = !0, t.cy.stopAnimationLoop();
for (var e = 0; e < t.bindings.length; e++) {
var r = t.bindings[e], a = r, n = a.target;
(n.off || n.removeEventListener).apply(n, a.args);
}
if (t.bindings = [], t.beforeRenderCallbacks = [], t.onUpdateEleCalcsFns = [], t.removeObserver && t.removeObserver.disconnect(), t.styleObserver && t.styleObserver.disconnect(), t.resizeObserver && t.resizeObserver.disconnect(), t.labelCalcDiv)
try {
document.body.removeChild(t.labelCalcDiv);
} catch {
}
};
la.isHeadless = function() {
return !1;
};
[Do, kc, Nc, ua, jt, Xa].forEach(function(t) {
be(la, t);
});
var Ds = 1e3 / 60, Fc = {
setupDequeueing: function(e) {
return function() {
var a = this, n = this.renderer;
if (!a.dequeueingSetup) {
a.dequeueingSetup = !0;
var i = Va(function() {
n.redrawHint("eles", !0), n.redrawHint("drag", !0), n.redraw();
}, e.deqRedrawThreshold), s = function(l, f) {
var c = Qt(), v = n.averageRedrawTime, h = n.lastRedrawTime, d = [], p = n.cy.extent(), g = n.getPixelRatio();
for (l || n.flushRenderedStyleQueue(); ; ) {
var y = Qt(), b = y - c, m = y - f;
if (h < Ds) {
var E = Ds - (l ? v : 0);
if (m >= e.deqFastCost * E)
break;
} else if (l) {
if (b >= e.deqCost * h || b >= e.deqAvgCost * v)
break;
} else if (m >= e.deqNoDrawCost * Ds)
break;
var T = e.deq(a, g, p);
if (T.length > 0)
for (var S = 0; S < T.length; S++)
d.push(T[S]);
else
break;
}
d.length > 0 && (e.onDeqd(a, d), !l && e.shouldRedraw(a, d, g, p) && i());
}, o = e.priority || lo;
n.beforeRender(s, o(a));
}
};
}
}, Iy = /* @__PURE__ */ function() {
function t(e) {
var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Sn;
yr(this, t), this.idsByKey = new Zt(), this.keyForId = new Zt(), this.cachesByLvl = new Zt(), this.lvls = [], this.getKey = e, this.doesEleInvalidateKey = r;
}
return mr(t, [{
key: "getIdsFor",
value: function(r) {
r == null && He("Can not get id list for null key");
var a = this.idsByKey, n = this.idsByKey.get(r);
return n || (n = new na(), a.set(r, n)), n;
}
}, {
key: "addIdForKey",
value: function(r, a) {
r != null && this.getIdsFor(r).add(a);
}
}, {
key: "deleteIdForKey",
value: function(r, a) {
r != null && this.getIdsFor(r).delete(a);
}
}, {
key: "getNumberOfIdsForKey",
value: function(r) {
return r == null ? 0 : this.getIdsFor(r).size;
}
}, {
key: "updateKeyMappingFor",
value: function(r) {
var a = r.id(), n = this.keyForId.get(a), i = this.getKey(r);
this.deleteIdForKey(n, a), this.addIdForKey(i, a), this.keyForId.set(a, i);
}
}, {
key: "deleteKeyMappingFor",
value: function(r) {
var a = r.id(), n = this.keyForId.get(a);
this.deleteIdForKey(n, a), this.keyForId.delete(a);
}
}, {
key: "keyHasChangedFor",
value: function(r) {
var a = r.id(), n = this.keyForId.get(a), i = this.getKey(r);
return n !== i;
}
}, {
key: "isInvalid",
value: function(r) {
return this.keyHasChangedFor(r) || this.doesEleInvalidateKey(r);
}
}, {
key: "getCachesAt",
value: function(r) {
var a = this.cachesByLvl, n = this.lvls, i = a.get(r);
return i || (i = new Zt(), a.set(r, i), n.push(r)), i;
}
}, {
key: "getCache",
value: function(r, a) {
return this.getCachesAt(a).get(r);
}
}, {
key: "get",
value: function(r, a) {
var n = this.getKey(r), i = this.getCache(n, a);
return i != null && this.updateKeyMappingFor(r), i;
}
}, {
key: "getForCachedKey",
value: function(r, a) {
var n = this.keyForId.get(r.id()), i = this.getCache(n, a);
return i;
}
}, {
key: "hasCache",
value: function(r, a) {
return this.getCachesAt(a).has(r);
}
}, {
key: "has",
value: function(r, a) {
var n = this.getKey(r);
return this.hasCache(n, a);
}
}, {
key: "setCache",
value: function(r, a, n) {
n.key = r, this.getCachesAt(a).set(r, n);
}
}, {
key: "set",
value: function(r, a, n) {
var i = this.getKey(r);
this.setCache(i, a, n), this.updateKeyMappingFor(r);
}
}, {
key: "deleteCache",
value: function(r, a) {
this.getCachesAt(a).delete(r);
}
}, {
key: "delete",
value: function(r, a) {
var n = this.getKey(r);
this.deleteCache(n, a);
}
}, {
key: "invalidateKey",
value: function(r) {
var a = this;
this.lvls.forEach(function(n) {
return a.deleteCache(r, n);
});
}
// returns true if no other eles reference the invalidated cache (n.b. other eles may need the cache with the same key)
}, {
key: "invalidate",
value: function(r) {
var a = r.id(), n = this.keyForId.get(a);
this.deleteKeyMappingFor(r);
var i = this.doesEleInvalidateKey(r);
return i && this.invalidateKey(n), i || this.getNumberOfIdsForKey(n) === 0;
}
}]);
}(), $l = 25, un = 50, bn = -4, Zs = 3, _c = 7.99, Py = 8, My = 1024, Oy = 1024, ky = 1024, Ny = 0.2, By = 0.8, Fy = 10, _y = 0.15, Gy = 0.1, zy = 0.9, Vy = 0.9, Uy = 100, qy = 1, Zr = {
dequeue: "dequeue",
downscale: "downscale",
highQuality: "highQuality"
}, Yy = ht({
getKey: null,
doesEleInvalidateKey: Sn,
drawElement: null,
getBoundingBox: null,
getRotationPoint: null,
getRotationOffset: null,
isVisible: Af,
allowEdgeTxrCaching: !0,
allowParentTxrCaching: !0
}), xa = function(e, r) {
var a = this;
a.renderer = e, a.onDequeues = [];
var n = Yy(r);
be(a, n), a.lookup = new Iy(n.getKey, n.doesEleInvalidateKey), a.setupDequeueing();
}, it = xa.prototype;
it.reasons = Zr;
it.getTextureQueue = function(t) {
var e = this;
return e.eleImgCaches = e.eleImgCaches || {}, e.eleImgCaches[t] = e.eleImgCaches[t] || [];
};
it.getRetiredTextureQueue = function(t) {
var e = this, r = e.eleImgCaches.retired = e.eleImgCaches.retired || {}, a = r[t] = r[t] || [];
return a;
};
it.getElementQueue = function() {
var t = this, e = t.eleCacheQueue = t.eleCacheQueue || new Ua(function(r, a) {
return a.reqs - r.reqs;
});
return e;
};
it.getElementKeyToQueue = function() {
var t = this, e = t.eleKeyToCacheQueue = t.eleKeyToCacheQueue || {};
return e;
};
it.getElement = function(t, e, r, a, n) {
var i = this, s = this.renderer, o = s.cy.zoom(), u = this.lookup;
if (!e || e.w === 0 || e.h === 0 || isNaN(e.w) || isNaN(e.h) || !t.visible() || t.removed() || !i.allowEdgeTxrCaching && t.isEdge() || !i.allowParentTxrCaching && t.isParent())
return null;
if (a == null && (a = Math.ceil(co(o * r))), a < bn)
a = bn;
else if (o >= _c || a > Zs)
return null;
var l = Math.pow(2, a), f = e.h * l, c = e.w * l, v = s.eleTextBiggerThanMin(t, l);
if (!this.isVisible(t, v))
return null;
var h = u.get(t, a);
if (h && h.invalidated && (h.invalidated = !1, h.texture.invalidatedWidth -= h.width), h)
return h;
var d;
if (f <= $l ? d = $l : f <= un ? d = un : d = Math.ceil(f / un) * un, f > ky || c > Oy)
return null;
var p = i.getTextureQueue(d), g = p[p.length - 2], y = function() {
return i.recycleTexture(d, c) || i.addTexture(d, c);
};
g || (g = p[p.length - 1]), g || (g = y()), g.width - g.usedWidth < c && (g = y());
for (var b = function(N) {
return N && N.scaledLabelShown === v;
}, m = n && n === Zr.dequeue, E = n && n === Zr.highQuality, T = n && n === Zr.downscale, S, w = a + 1; w <= Zs; w++) {
var x = u.get(t, w);
if (x) {
S = x;
break;
}
}
var C = S && S.level === a + 1 ? S : null, D = function() {
g.context.drawImage(C.texture.canvas, C.x, 0, C.width, C.height, g.usedWidth, 0, c, f);
};
if (g.context.setTransform(1, 0, 0, 1, 0, 0), g.context.clearRect(g.usedWidth, 0, c, d), b(C))
D();
else if (b(S))
if (E) {
for (var A = S.level; A > a; A--)
C = i.getElement(t, e, r, A, Zr.downscale);
D();
} else
return i.queueElement(t, S.level - 1), S;
else {
var L;
if (!m && !E && !T)
for (var R = a - 1; R >= bn; R--) {
var I = u.get(t, R);
if (I) {
L = I;
break;
}
}
if (b(L))
return i.queueElement(t, a), L;
g.context.translate(g.usedWidth, 0), g.context.scale(l, l), this.drawElement(g.context, t, e, v, !1), g.context.scale(1 / l, 1 / l), g.context.translate(-g.usedWidth, 0);
}
return h = {
x: g.usedWidth,
texture: g,
level: a,
scale: l,
width: c,
height: f,
scaledLabelShown: v
}, g.usedWidth += Math.ceil(c + Py), g.eleCaches.push(h), u.set(t, a, h), i.checkTextureFullness(g), h;
};
it.invalidateElements = function(t) {
for (var e = 0; e < t.length; e++)
this.invalidateElement(t[e]);
};
it.invalidateElement = function(t) {
var e = this, r = e.lookup, a = [], n = r.isInvalid(t);
if (n) {
for (var i = bn; i <= Zs; i++) {
var s = r.getForCachedKey(t, i);
s && a.push(s);
}
var o = r.invalidate(t);
if (o)
for (var u = 0; u < a.length; u++) {
var l = a[u], f = l.texture;
f.invalidatedWidth += l.width, l.invalidated = !0, e.checkTextureUtility(f);
}
e.removeFromQueue(t);
}
};
it.checkTextureUtility = function(t) {
t.invalidatedWidth >= Ny * t.width && this.retireTexture(t);
};
it.checkTextureFullness = function(t) {
var e = this, r = e.getTextureQueue(t.height);
t.usedWidth / t.width > By && t.fullnessChecks >= Fy ? cr(r, t) : t.fullnessChecks++;
};
it.retireTexture = function(t) {
var e = this, r = t.height, a = e.getTextureQueue(r), n = this.lookup;
cr(a, t), t.retired = !0;
for (var i = t.eleCaches, s = 0; s < i.length; s++) {
var o = i[s];
n.deleteCache(o.key, o.level);
}
fo(i);
var u = e.getRetiredTextureQueue(r);
u.push(t);
};
it.addTexture = function(t, e) {
var r = this, a = r.getTextureQueue(t), n = {};
return a.push(n), n.eleCaches = [], n.height = t, n.width = Math.max(My, e), n.usedWidth = 0, n.invalidatedWidth = 0, n.fullnessChecks = 0, n.canvas = r.renderer.makeOffscreenCanvas(n.width, n.height), n.context = n.canvas.getContext("2d"), n;
};
it.recycleTexture = function(t, e) {
for (var r = this, a = r.getTextureQueue(t), n = r.getRetiredTextureQueue(t), i = 0; i < n.length; i++) {
var s = n[i];
if (s.width >= e)
return s.retired = !1, s.usedWidth = 0, s.invalidatedWidth = 0, s.fullnessChecks = 0, fo(s.eleCaches), s.context.setTransform(1, 0, 0, 1, 0, 0), s.context.clearRect(0, 0, s.width, s.height), cr(n, s), a.push(s), s;
}
};
it.queueElement = function(t, e) {
var r = this, a = r.getElementQueue(), n = r.getElementKeyToQueue(), i = this.getKey(t), s = n[i];
if (s)
s.level = Math.max(s.level, e), s.eles.merge(t), s.reqs++, a.updateItem(s);
else {
var o = {
eles: t.spawn().merge(t),
level: e,
reqs: 1,
key: i
};
a.push(o), n[i] = o;
}
};
it.dequeue = function(t) {
for (var e = this, r = e.getElementQueue(), a = e.getElementKeyToQueue(), n = [], i = e.lookup, s = 0; s < qy && r.size() > 0; s++) {
var o = r.pop(), u = o.key, l = o.eles[0], f = i.hasCache(l, o.level);
if (a[u] = null, f)
continue;
n.push(o);
var c = e.getBoundingBox(l);
e.getElement(l, c, t, o.level, Zr.dequeue);
}
return n;
};
it.removeFromQueue = function(t) {
var e = this, r = e.getElementQueue(), a = e.getElementKeyToQueue(), n = this.getKey(t), i = a[n];
i != null && (i.eles.length === 1 ? (i.reqs = uo, r.updateItem(i), r.pop(), a[n] = null) : i.eles.unmerge(t));
};
it.onDequeue = function(t) {
this.onDequeues.push(t);
};
it.offDequeue = function(t) {
cr(this.onDequeues, t);
};
it.setupDequeueing = Fc.setupDequeueing({
deqRedrawThreshold: Uy,
deqCost: _y,
deqAvgCost: Gy,
deqNoDrawCost: zy,
deqFastCost: Vy,
deq: function(e, r, a) {
return e.dequeue(r, a);
},
onDeqd: function(e, r) {
for (var a = 0; a < e.onDequeues.length; a++) {
var n = e.onDequeues[a];
n(r);
}
},
shouldRedraw: function(e, r, a, n) {
for (var i = 0; i < r.length; i++)
for (var s = r[i].eles, o = 0; o < s.length; o++) {
var u = s[o].boundingBox();
if (ho(u, n))
return !0;
}
return !1;
},
priority: function(e) {
return e.renderer.beforeRenderPriorities.eleTxrDeq;
}
});
var Hy = 1, Ca = -4, kn = 2, Xy = 3.99, $y = 50, Wy = 50, Ky = 0.15, Zy = 0.1, Qy = 0.9, Jy = 0.9, jy = 1, Wl = 250, em = 4e3 * 4e3, Kl = 32767, tm = !0, Gc = function(e) {
var r = this, a = r.renderer = e, n = a.cy;
r.layersByLevel = {}, r.firstGet = !0, r.lastInvalidationTime = Qt() - 2 * Wl, r.skipping = !1, r.eleTxrDeqs = n.collection(), r.scheduleElementRefinement = Va(function() {
r.refineElementTextures(r.eleTxrDeqs), r.eleTxrDeqs.unmerge(r.eleTxrDeqs);
}, Wy), a.beforeRender(function(s, o) {
o - r.lastInvalidationTime <= Wl ? r.skipping = !0 : r.skipping = !1;
}, a.beforeRenderPriorities.lyrTxrSkip);
var i = function(o, u) {
return u.reqs - o.reqs;
};
r.layersQueue = new Ua(i), r.setupDequeueing();
}, dt = Gc.prototype, Zl = 0, rm = Math.pow(2, 53) - 1;
dt.makeLayer = function(t, e) {
var r = Math.pow(2, e), a = Math.ceil(t.w * r), n = Math.ceil(t.h * r), i = this.renderer.makeOffscreenCanvas(a, n), s = {
id: Zl = ++Zl % rm,
bb: t,
level: e,
width: a,
height: n,
canvas: i,
context: i.getContext("2d"),
eles: [],
elesQueue: [],
reqs: 0
}, o = s.context, u = -s.bb.x1, l = -s.bb.y1;
return o.scale(r, r), o.translate(u, l), s;
};
dt.getLayers = function(t, e, r) {
var a = this, n = a.renderer, i = n.cy, s = i.zoom(), o = a.firstGet;
if (a.firstGet = !1, r == null) {
if (r = Math.ceil(co(s * e)), r < Ca)
r = Ca;
else if (s >= Xy || r > kn)
return null;
}
a.validateLayersElesOrdering(r, t);
var u = a.layersByLevel, l = Math.pow(2, r), f = u[r] = u[r] || [], c, v = a.levelIsComplete(r, t), h, d = function() {
var D = function(M) {
if (a.validateLayersElesOrdering(M, t), a.levelIsComplete(M, t))
return h = u[M], !0;
}, A = function(M) {
if (!h)
for (var N = r + M; Ca <= N && N <= kn && !D(N); N += M)
;
};
A(1), A(-1);
for (var L = f.length - 1; L >= 0; L--) {
var R = f[L];
R.invalid && cr(f, R);
}
};
if (!v)
d();
else
return f;
var p = function() {
if (!c) {
c = Et();
for (var D = 0; D < t.length; D++)
jh(c, t[D].boundingBox());
}
return c;
}, g = function(D) {
D = D || {};
var A = D.after;
p();
var L = Math.ceil(c.w * l), R = Math.ceil(c.h * l);
if (L > Kl || R > Kl)
return null;
var I = L * R;
if (I > em)
return null;
var M = a.makeLayer(c, r);
if (A != null) {
var N = f.indexOf(A) + 1;
f.splice(N, 0, M);
} else
(D.insert === void 0 || D.insert) && f.unshift(M);
return M;
};
if (a.skipping && !o)
return null;
for (var y = null, b = t.length / Hy, m = !o, E = 0; E < t.length; E++) {
var T = t[E], S = T._private.rscratch, w = S.imgLayerCaches = S.imgLayerCaches || {}, x = w[r];
if (x) {
y = x;
continue;
}
if ((!y || y.eles.length >= b || !Of(y.bb, T.boundingBox())) && (y = g({
insert: !0,
after: y
}), !y))
return null;
h || m ? a.queueLayer(y, T) : a.drawEleInLayer(y, T, r, e), y.eles.push(T), w[r] = y;
}
return h || (m ? null : f);
};
dt.getEleLevelForLayerLevel = function(t, e) {
return t;
};
dt.drawEleInLayer = function(t, e, r, a) {
var n = this, i = this.renderer, s = t.context, o = e.boundingBox();
o.w === 0 || o.h === 0 || !e.visible() || (r = n.getEleLevelForLayerLevel(r, a), i.setImgSmoothing(s, !1), i.drawCachedElement(s, e, null, null, r, tm), i.setImgSmoothing(s, !0));
};
dt.levelIsComplete = function(t, e) {
var r = this, a = r.layersByLevel[t];
if (!a || a.length === 0)
return !1;
for (var n = 0, i = 0; i < a.length; i++) {
var s = a[i];
if (s.reqs > 0 || s.invalid)
return !1;
n += s.eles.length;
}
return n === e.length;
};
dt.validateLayersElesOrdering = function(t, e) {
var r = this.layersByLevel[t];
if (r)
for (var a = 0; a < r.length; a++) {
for (var n = r[a], i = -1, s = 0; s < e.length; s++)
if (n.eles[0] === e[s]) {
i = s;
break;
}
if (i < 0) {
this.invalidateLayer(n);
continue;
}
for (var o = i, s = 0; s < n.eles.length; s++)
if (n.eles[s] !== e[o + s]) {
this.invalidateLayer(n);
break;
}
}
};
dt.updateElementsInLayers = function(t, e) {
for (var r = this, a = Fa(t[0]), n = 0; n < t.length; n++)
for (var i = a ? null : t[n], s = a ? t[n] : t[n].ele, o = s._private.rscratch, u = o.imgLayerCaches = o.imgLayerCaches || {}, l = Ca; l <= kn; l++) {
var f = u[l];
f && (i && r.getEleLevelForLayerLevel(f.level) !== i.level || e(f, s, i));
}
};
dt.haveLayers = function() {
for (var t = this, e = !1, r = Ca; r <= kn; r++) {
var a = t.layersByLevel[r];
if (a && a.length > 0) {
e = !0;
break;
}
}
return e;
};
dt.invalidateElements = function(t) {
var e = this;
t.length !== 0 && (e.lastInvalidationTime = Qt(), !(t.length === 0 || !e.haveLayers()) && e.updateElementsInLayers(t, function(a, n, i) {
e.invalidateLayer(a);
}));
};
dt.invalidateLayer = function(t) {
if (this.lastInvalidationTime = Qt(), !t.invalid) {
var e = t.level, r = t.eles, a = this.layersByLevel[e];
cr(a, t), t.elesQueue = [], t.invalid = !0, t.replacement && (t.replacement.invalid = !0);
for (var n = 0; n < r.length; n++) {
var i = r[n]._private.rscratch.imgLayerCaches;
i && (i[e] = null);
}
}
};
dt.refineElementTextures = function(t) {
var e = this;
e.updateElementsInLayers(t, function(a, n, i) {
var s = a.replacement;
if (s || (s = a.replacement = e.makeLayer(a.bb, a.level), s.replaces = a, s.eles = a.eles), !s.reqs)
for (var o = 0; o < s.eles.length; o++)
e.queueLayer(s, s.eles[o]);
});
};
dt.enqueueElementRefinement = function(t) {
this.eleTxrDeqs.merge(t), this.scheduleElementRefinement();
};
dt.queueLayer = function(t, e) {
var r = this, a = r.layersQueue, n = t.elesQueue, i = n.hasId = n.hasId || {};
if (!t.replacement) {
if (e) {
if (i[e.id()])
return;
n.push(e), i[e.id()] = !0;
}
t.reqs ? (t.reqs++, a.updateItem(t)) : (t.reqs = 1, a.push(t));
}
};
dt.dequeue = function(t) {
for (var e = this, r = e.layersQueue, a = [], n = 0; n < jy && r.size() !== 0; ) {
var i = r.peek();
if (i.replacement) {
r.pop();
continue;
}
if (i.replaces && i !== i.replaces.replacement) {
r.pop();
continue;
}
if (i.invalid) {
r.pop();
continue;
}
var s = i.elesQueue.shift();
s && (e.drawEleInLayer(i, s, i.level, t), n++), a.length === 0 && a.push(!0), i.elesQueue.length === 0 && (r.pop(), i.reqs = 0, i.replaces && e.applyLayerReplacement(i), e.requestRedraw());
}
return a;
};
dt.applyLayerReplacement = function(t) {
var e = this, r = e.layersByLevel[t.level], a = t.replaces, n = r.indexOf(a);
if (!(n < 0 || a.invalid)) {
r[n] = t;
for (var i = 0; i < t.eles.length; i++) {
var s = t.eles[i]._private, o = s.imgLayerCaches = s.imgLayerCaches || {};
o && (o[t.level] = t);
}
e.requestRedraw();
}
};
dt.requestRedraw = Va(function() {
var t = this.renderer;
t.redrawHint("eles", !0), t.redrawHint("drag", !0), t.redraw();
}, 100);
dt.setupDequeueing = Fc.setupDequeueing({
deqRedrawThreshold: $y,
deqCost: Ky,
deqAvgCost: Zy,
deqNoDrawCost: Qy,
deqFastCost: Jy,
deq: function(e, r) {
return e.dequeue(r);
},
onDeqd: lo,
shouldRedraw: Af,
priority: function(e) {
return e.renderer.beforeRenderPriorities.lyrTxrDeq;
}
});
var zc = {}, Ql;
function am(t, e) {
for (var r = 0; r < e.length; r++) {
var a = e[r];
t.lineTo(a.x, a.y);
}
}
function nm(t, e, r) {
for (var a, n = 0; n < e.length; n++) {
var i = e[n];
n === 0 && (a = i), t.lineTo(i.x, i.y);
}
t.quadraticCurveTo(r.x, r.y, a.x, a.y);
}
function Jl(t, e, r) {
t.beginPath && t.beginPath();
for (var a = e, n = 0; n < a.length; n++) {
var i = a[n];
t.lineTo(i.x, i.y);
}
var s = r, o = r[0];
t.moveTo(o.x, o.y);
for (var n = 1; n < s.length; n++) {
var i = s[n];
t.lineTo(i.x, i.y);
}
t.closePath && t.closePath();
}
function im(t, e, r, a, n) {
t.beginPath && t.beginPath(), t.arc(r, a, n, 0, Math.PI * 2, !1);
var i = e, s = i[0];
t.moveTo(s.x, s.y);
for (var o = 0; o < i.length; o++) {
var u = i[o];
t.lineTo(u.x, u.y);
}
t.closePath && t.closePath();
}
function sm(t, e, r, a) {
t.arc(e, r, a, 0, Math.PI * 2, !1);
}
zc.arrowShapeImpl = function(t) {
return (Ql || (Ql = {
polygon: am,
"triangle-backcurve": nm,
"triangle-tee": Jl,
"circle-triangle": im,
"triangle-cross": Jl,
circle: sm
}))[t];
};
var Ht = {};
Ht.drawElement = function(t, e, r, a, n, i) {
var s = this;
e.isNode() ? s.drawNode(t, e, r, a, n, i) : s.drawEdge(t, e, r, a, n, i);
};
Ht.drawElementOverlay = function(t, e) {
var r = this;
e.isNode() ? r.drawNodeOverlay(t, e) : r.drawEdgeOverlay(t, e);
};
Ht.drawElementUnderlay = function(t, e) {
var r = this;
e.isNode() ? r.drawNodeUnderlay(t, e) : r.drawEdgeUnderlay(t, e);
};
Ht.drawCachedElementPortion = function(t, e, r, a, n, i, s, o) {
var u = this, l = r.getBoundingBox(e);
if (!(l.w === 0 || l.h === 0)) {
var f = r.getElement(e, l, a, n, i);
if (f != null) {
var c = o(u, e);
if (c === 0)
return;
var v = s(u, e), h = l.x1, d = l.y1, p = l.w, g = l.h, y, b, m, E, T;
if (v !== 0) {
var S = r.getRotationPoint(e);
m = S.x, E = S.y, t.translate(m, E), t.rotate(v), T = u.getImgSmoothing(t), T || u.setImgSmoothing(t, !0);
var w = r.getRotationOffset(e);
y = w.x, b = w.y;
} else
y = h, b = d;
var x;
c !== 1 && (x = t.globalAlpha, t.globalAlpha = x * c), t.drawImage(f.texture.canvas, f.x, 0, f.width, f.height, y, b, p, g), c !== 1 && (t.globalAlpha = x), v !== 0 && (t.rotate(-v), t.translate(-m, -E), T || u.setImgSmoothing(t, !1));
} else
r.drawElement(t, e);
}
};
var om = function() {
return 0;
}, um = function(e, r) {
return e.getTextAngle(r, null);
}, lm = function(e, r) {
return e.getTextAngle(r, "source");
}, fm = function(e, r) {
return e.getTextAngle(r, "target");
}, cm = function(e, r) {
return r.effectiveOpacity();
}, Ss = function(e, r) {
return r.pstyle("text-opacity").pfValue * r.effectiveOpacity();
};
Ht.drawCachedElement = function(t, e, r, a, n, i) {
var s = this, o = s.data, u = o.eleTxrCache, l = o.lblTxrCache, f = o.slbTxrCache, c = o.tlbTxrCache, v = e.boundingBox(), h = i === !0 ? u.reasons.highQuality : null;
if (!(v.w === 0 || v.h === 0 || !e.visible()) && (!a || ho(v, a))) {
var d = e.isEdge(), p = e.element()._private.rscratch.badLine;
s.drawElementUnderlay(t, e), s.drawCachedElementPortion(t, e, u, r, n, h, om, cm), (!d || !p) && s.drawCachedElementPortion(t, e, l, r, n, h, um, Ss), d && !p && (s.drawCachedElementPortion(t, e, f, r, n, h, lm, Ss), s.drawCachedElementPortion(t, e, c, r, n, h, fm, Ss)), s.drawElementOverlay(t, e);
}
};
Ht.drawElements = function(t, e) {
for (var r = this, a = 0; a < e.length; a++) {
var n = e[a];
r.drawElement(t, n);
}
};
Ht.drawCachedElements = function(t, e, r, a) {
for (var n = this, i = 0; i < e.length; i++) {
var s = e[i];
n.drawCachedElement(t, s, r, a);
}
};
Ht.drawCachedNodes = function(t, e, r, a) {
for (var n = this, i = 0; i < e.length; i++) {
var s = e[i];
s.isNode() && n.drawCachedElement(t, s, r, a);
}
};
Ht.drawLayeredElements = function(t, e, r, a) {
var n = this, i = n.data.lyrTxrCache.getLayers(e, r);
if (i)
for (var s = 0; s < i.length; s++) {
var o = i[s], u = o.bb;
u.w === 0 || u.h === 0 || t.drawImage(o.canvas, u.x1, u.y1, u.w, u.h);
}
else
n.drawCachedElements(t, e, r, a);
};
var er = {};
er.drawEdge = function(t, e, r) {
var a = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !0, n = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, i = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : !0, s = this, o = e._private.rscratch;
if (!(i && !e.visible()) && !(o.badLine || o.allpts == null || isNaN(o.allpts[0]))) {
var u;
r && (u = r, t.translate(-u.x1, -u.y1));
var l = i ? e.pstyle("opacity").value : 1, f = i ? e.pstyle("line-opacity").value : 1, c = e.pstyle("curve-style").value, v = e.pstyle("line-style").value, h = e.pstyle("width").pfValue, d = e.pstyle("line-cap").value, p = e.pstyle("line-outline-width").value, g = e.pstyle("line-outline-color").value, y = l * f, b = l * f, m = function() {
var M = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : y;
c === "straight-triangle" ? (s.eleStrokeStyle(t, e, M), s.drawEdgeTrianglePath(e, t, o.allpts)) : (t.lineWidth = h, t.lineCap = d, s.eleStrokeStyle(t, e, M), s.drawEdgePath(e, t, o.allpts, v), t.lineCap = "butt");
}, E = function() {
var M = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : y;
if (t.lineWidth = h + p, t.lineCap = d, p > 0)
s.colorStrokeStyle(t, g[0], g[1], g[2], M);
else {
t.lineCap = "butt";
return;
}
c === "straight-triangle" ? s.drawEdgeTrianglePath(e, t, o.allpts) : (s.drawEdgePath(e, t, o.allpts, v), t.lineCap = "butt");
}, T = function() {
n && s.drawEdgeOverlay(t, e);
}, S = function() {
n && s.drawEdgeUnderlay(t, e);
}, w = function() {
var M = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : b;
s.drawArrowheads(t, e, M);
}, x = function() {
s.drawElementText(t, e, null, a);
};
t.lineJoin = "round";
var C = e.pstyle("ghost").value === "yes";
if (C) {
var D = e.pstyle("ghost-offset-x").pfValue, A = e.pstyle("ghost-offset-y").pfValue, L = e.pstyle("ghost-opacity").value, R = y * L;
t.translate(D, A), m(R), w(R), t.translate(-D, -A);
} else
E();
S(), m(), w(), T(), x(), r && t.translate(u.x1, u.y1);
}
};
var Vc = function(e) {
if (!["overlay", "underlay"].includes(e))
throw new Error("Invalid state");
return function(r, a) {
if (a.visible()) {
var n = a.pstyle("".concat(e, "-opacity")).value;
if (n !== 0) {
var i = this, s = i.usePaths(), o = a._private.rscratch, u = a.pstyle("".concat(e, "-padding")).pfValue, l = 2 * u, f = a.pstyle("".concat(e, "-color")).value;
r.lineWidth = l, o.edgeType === "self" && !s ? r.lineCap = "butt" : r.lineCap = "round", i.colorStrokeStyle(r, f[0], f[1], f[2], n), i.drawEdgePath(a, r, o.allpts, "solid");
}
}
};
};
er.drawEdgeOverlay = Vc("overlay");
er.drawEdgeUnderlay = Vc("underlay");
er.drawEdgePath = function(t, e, r, a) {
var n = t._private.rscratch, i = e, s, o = !1, u = this.usePaths(), l = t.pstyle("line-dash-pattern").pfValue, f = t.pstyle("line-dash-offset").pfValue;
if (u) {
var c = r.join("$"), v = n.pathCacheKey && n.pathCacheKey === c;
v ? (s = e = n.pathCache, o = !0) : (s = e = new Path2D(), n.pathCacheKey = c, n.pathCache = s);
}
if (i.setLineDash)
switch (a) {
case "dotted":
i.setLineDash([1, 1]);
break;
case "dashed":
i.setLineDash(l), i.lineDashOffset = f;
break;
case "solid":
i.setLineDash([]);
break;
}
if (!o && !n.badLine)
switch (e.beginPath && e.beginPath(), e.moveTo(r[0], r[1]), n.edgeType) {
case "bezier":
case "self":
case "compound":
case "multibezier":
for (var h = 2; h + 3 < r.length; h += 4)
e.quadraticCurveTo(r[h], r[h + 1], r[h + 2], r[h + 3]);
break;
case "straight":
case "haystack":
for (var d = 2; d + 1 < r.length; d += 2)
e.lineTo(r[d], r[d + 1]);
break;
case "segments":
if (n.isRound) {
var p = At(n.roundCorners), g;
try {
for (p.s(); !(g = p.n()).done; ) {
var y = g.value;
Rc(e, y);
}
} catch (m) {
p.e(m);
} finally {
p.f();
}
e.lineTo(r[r.length - 2], r[r.length - 1]);
} else
for (var b = 2; b + 1 < r.length; b += 2)
e.lineTo(r[b], r[b + 1]);
break;
}
e = i, u ? e.stroke(s) : e.stroke(), e.setLineDash && e.setLineDash([]);
};
er.drawEdgeTrianglePath = function(t, e, r) {
e.fillStyle = e.strokeStyle;
for (var a = t.pstyle("width").pfValue, n = 0; n + 1 < r.length; n += 2) {
var i = [r[n + 2] - r[n], r[n + 3] - r[n + 1]], s = Math.sqrt(i[0] * i[0] + i[1] * i[1]), o = [i[1] / s, -i[0] / s], u = [o[0] * a / 2, o[1] * a / 2];
e.beginPath(), e.moveTo(r[n] - u[0], r[n + 1] - u[1]), e.lineTo(r[n] + u[0], r[n + 1] + u[1]), e.lineTo(r[n + 2], r[n + 3]), e.closePath(), e.fill();
}
};
er.drawArrowheads = function(t, e, r) {
var a = e._private.rscratch, n = a.edgeType === "haystack";
n || this.drawArrowhead(t, e, "source", a.arrowStartX, a.arrowStartY, a.srcArrowAngle, r), this.drawArrowhead(t, e, "mid-target", a.midX, a.midY, a.midtgtArrowAngle, r), this.drawArrowhead(t, e, "mid-source", a.midX, a.midY, a.midsrcArrowAngle, r), n || this.drawArrowhead(t, e, "target", a.arrowEndX, a.arrowEndY, a.tgtArrowAngle, r);
};
er.drawArrowhead = function(t, e, r, a, n, i, s) {
if (!(isNaN(a) || a == null || isNaN(n) || n == null || isNaN(i) || i == null)) {
var o = this, u = e.pstyle(r + "-arrow-shape").value;
if (u !== "none") {
var l = e.pstyle(r + "-arrow-fill").value === "hollow" ? "both" : "filled", f = e.pstyle(r + "-arrow-fill").value, c = e.pstyle("width").pfValue, v = e.pstyle(r + "-arrow-width"), h = v.value === "match-line" ? c : v.pfValue;
v.units === "%" && (h *= c);
var d = e.pstyle("opacity").value;
s === void 0 && (s = d);
var p = t.globalCompositeOperation;
(s !== 1 || f === "hollow") && (t.globalCompositeOperation = "destination-out", o.colorFillStyle(t, 255, 255, 255, 1), o.colorStrokeStyle(t, 255, 255, 255, 1), o.drawArrowShape(e, t, l, c, u, h, a, n, i), t.globalCompositeOperation = p);
var g = e.pstyle(r + "-arrow-color").value;
o.colorFillStyle(t, g[0], g[1], g[2], s), o.colorStrokeStyle(t, g[0], g[1], g[2], s), o.drawArrowShape(e, t, f, c, u, h, a, n, i);
}
}
};
er.drawArrowShape = function(t, e, r, a, n, i, s, o, u) {
var l = this, f = this.usePaths() && n !== "triangle-cross", c = !1, v, h = e, d = {
x: s,
y: o
}, p = t.pstyle("arrow-scale").value, g = this.getArrowWidth(a, p), y = l.arrowShapes[n];
if (f) {
var b = l.arrowPathCache = l.arrowPathCache || [], m = Ir(n), E = b[m];
E != null ? (v = e = E, c = !0) : (v = e = new Path2D(), b[m] = v);
}
c || (e.beginPath && e.beginPath(), f ? y.draw(e, 1, 0, {
x: 0,
y: 0
}, 1) : y.draw(e, g, u, d, a), e.closePath && e.closePath()), e = h, f && (e.translate(s, o), e.rotate(u), e.scale(g, g)), (r === "filled" || r === "both") && (f ? e.fill(v) : e.fill()), (r === "hollow" || r === "both") && (e.lineWidth = i / (f ? g : 1), e.lineJoin = "miter", f ? e.stroke(v) : e.stroke()), f && (e.scale(1 / g, 1 / g), e.rotate(-u), e.translate(-s, -o));
};
var Lo = {};
Lo.safeDrawImage = function(t, e, r, a, n, i, s, o, u, l) {
if (!(n <= 0 || i <= 0 || u <= 0 || l <= 0))
try {
t.drawImage(e, r, a, n, i, s, o, u, l);
} catch (f) {
Ge(f);
}
};
Lo.drawInscribedImage = function(t, e, r, a, n) {
var i = this, s = r.position(), o = s.x, u = s.y, l = r.cy().style(), f = l.getIndexedStyle.bind(l), c = f(r, "background-fit", "value", a), v = f(r, "background-repeat", "value", a), h = r.width(), d = r.height(), p = r.padding() * 2, g = h + (f(r, "background-width-relative-to", "value", a) === "inner" ? 0 : p), y = d + (f(r, "background-height-relative-to", "value", a) === "inner" ? 0 : p), b = r._private.rscratch, m = f(r, "background-clip", "value", a), E = m === "node", T = f(r, "background-image-opacity", "value", a) * n, S = f(r, "background-image-smoothing", "value", a), w = r.pstyle("corner-radius").value;
w !== "auto" && (w = r.pstyle("corner-radius").pfValue);
var x = e.width || e.cachedW, C = e.height || e.cachedH;
(x == null || C == null) && (document.body.appendChild(e), x = e.cachedW = e.width || e.offsetWidth, C = e.cachedH = e.height || e.offsetHeight, document.body.removeChild(e));
var D = x, A = C;
if (f(r, "background-width", "value", a) !== "auto" && (f(r, "background-width", "units", a) === "%" ? D = f(r, "background-width", "pfValue", a) * g : D = f(r, "background-width", "pfValue", a)), f(r, "background-height", "value", a) !== "auto" && (f(r, "background-height", "units", a) === "%" ? A = f(r, "background-height", "pfValue", a) * y : A = f(r, "background-height", "pfValue", a)), !(D === 0 || A === 0)) {
if (c === "contain") {
var L = Math.min(g / D, y / A);
D *= L, A *= L;
} else if (c === "cover") {
var L = Math.max(g / D, y / A);
D *= L, A *= L;
}
var R = o - g / 2, I = f(r, "background-position-x", "units", a), M = f(r, "background-position-x", "pfValue", a);
I === "%" ? R += (g - D) * M : R += M;
var N = f(r, "background-offset-x", "units", a), O = f(r, "background-offset-x", "pfValue", a);
N === "%" ? R += (g - D) * O : R += O;
var k = u - y / 2, B = f(r, "background-position-y", "units", a), _ = f(r, "background-position-y", "pfValue", a);
B === "%" ? k += (y - A) * _ : k += _;
var F = f(r, "background-offset-y", "units", a), G = f(r, "background-offset-y", "pfValue", a);
F === "%" ? k += (y - A) * G : k += G, b.pathCache && (R -= o, k -= u, o = 0, u = 0);
var H = t.globalAlpha;
t.globalAlpha = T;
var Y = i.getImgSmoothing(t), X = !1;
if (S === "no" && Y ? (i.setImgSmoothing(t, !1), X = !0) : S === "yes" && !Y && (i.setImgSmoothing(t, !0), X = !0), v === "no-repeat")
E && (t.save(), b.pathCache ? t.clip(b.pathCache) : (i.nodeShapes[i.getNodeShape(r)].draw(t, o, u, g, y, w, b), t.clip())), i.safeDrawImage(t, e, 0, 0, x, C, R, k, D, A), E && t.restore();
else {
var W = t.createPattern(e, v);
t.fillStyle = W, i.nodeShapes[i.getNodeShape(r)].draw(t, o, u, g, y, w, b), t.translate(R, k), t.fill(), t.translate(-R, -k);
}
t.globalAlpha = H, X && i.setImgSmoothing(t, Y);
}
};
var Fr = {};
Fr.eleTextBiggerThanMin = function(t, e) {
if (!e) {
var r = t.cy().zoom(), a = this.getPixelRatio(), n = Math.ceil(co(r * a));
e = Math.pow(2, n);
}
var i = t.pstyle("font-size").pfValue * e, s = t.pstyle("min-zoomed-font-size").pfValue;
return !(i < s);
};
Fr.drawElementText = function(t, e, r, a, n) {
var i = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : !0, s = this;
if (a == null) {
if (i && !s.eleTextBiggerThanMin(e))
return;
} else if (a === !1)
return;
if (e.isNode()) {
var o = e.pstyle("label");
if (!o || !o.value)
return;
var u = s.getLabelJustification(e);
t.textAlign = u, t.textBaseline = "bottom";
} else {
var l = e.element()._private.rscratch.badLine, f = e.pstyle("label"), c = e.pstyle("source-label"), v = e.pstyle("target-label");
if (l || (!f || !f.value) && (!c || !c.value) && (!v || !v.value))
return;
t.textAlign = "center", t.textBaseline = "bottom";
}
var h = !r, d;
r && (d = r, t.translate(-d.x1, -d.y1)), n == null ? (s.drawText(t, e, null, h, i), e.isEdge() && (s.drawText(t, e, "source", h, i), s.drawText(t, e, "target", h, i))) : s.drawText(t, e, n, h, i), r && t.translate(d.x1, d.y1);
};
Fr.getFontCache = function(t) {
var e;
this.fontCaches = this.fontCaches || [];
for (var r = 0; r < this.fontCaches.length; r++)
if (e = this.fontCaches[r], e.context === t)
return e;
return e = {
context: t
}, this.fontCaches.push(e), e;
};
Fr.setupTextStyle = function(t, e) {
var r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !0, a = e.pstyle("font-style").strValue, n = e.pstyle("font-size").pfValue + "px", i = e.pstyle("font-family").strValue, s = e.pstyle("font-weight").strValue, o = r ? e.effectiveOpacity() * e.pstyle("text-opacity").value : 1, u = e.pstyle("text-outline-opacity").value * o, l = e.pstyle("color").value, f = e.pstyle("text-outline-color").value;
t.font = a + " " + s + " " + n + " " + i, t.lineJoin = "round", this.colorFillStyle(t, l[0], l[1], l[2], o), this.colorStrokeStyle(t, f[0], f[1], f[2], u);
};
function vm(t, e, r, a, n) {
var i = Math.min(a, n), s = i / 2, o = e + a / 2, u = r + n / 2;
t.beginPath(), t.arc(o, u, s, 0, Math.PI * 2), t.closePath();
}
function jl(t, e, r, a, n) {
var i = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : 5, s = Math.min(i, a / 2, n / 2);
t.beginPath(), t.moveTo(e + s, r), t.lineTo(e + a - s, r), t.quadraticCurveTo(e + a, r, e + a, r + s), t.lineTo(e + a, r + n - s), t.quadraticCurveTo(e + a, r + n, e + a - s, r + n), t.lineTo(e + s, r + n), t.quadraticCurveTo(e, r + n, e, r + n - s), t.lineTo(e, r + s), t.quadraticCurveTo(e, r, e + s, r), t.closePath();
}
Fr.getTextAngle = function(t, e) {
var r, a = t._private, n = a.rscratch, i = e ? e + "-" : "", s = t.pstyle(i + "text-rotation");
if (s.strValue === "autorotate") {
var o = Dt(n, "labelAngle", e);
r = t.isEdge() ? o : 0;
} else
s.strValue === "none" ? r = 0 : r = s.pfValue;
return r;
};
Fr.drawText = function(t, e, r) {
var a = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !0, n = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, i = e._private, s = i.rscratch, o = n ? e.effectiveOpacity() : 1;
if (!(n && (o === 0 || e.pstyle("text-opacity").value === 0))) {
r === "main" && (r = null);
var u = Dt(s, "labelX", r), l = Dt(s, "labelY", r), f, c, v = this.getLabelText(e, r);
if (v != null && v !== "" && !isNaN(u) && !isNaN(l)) {
this.setupTextStyle(t, e, n);
var h = r ? r + "-" : "", d = Dt(s, "labelWidth", r), p = Dt(s, "labelHeight", r), g = e.pstyle(h + "text-margin-x").pfValue, y = e.pstyle(h + "text-margin-y").pfValue, b = e.isEdge(), m = e.pstyle("text-halign").value, E = e.pstyle("text-valign").value;
b && (m = "center", E = "center"), u += g, l += y;
var T;
switch (a ? T = this.getTextAngle(e, r) : T = 0, T !== 0 && (f = u, c = l, t.translate(f, c), t.rotate(T), u = 0, l = 0), E) {
case "top":
break;
case "center":
l += p / 2;
break;
case "bottom":
l += p;
break;
}
var S = e.pstyle("text-background-opacity").value, w = e.pstyle("text-border-opacity").value, x = e.pstyle("text-border-width").pfValue, C = e.pstyle("text-background-padding").pfValue, D = e.pstyle("text-background-shape").strValue, A = D === "round-rectangle" || D === "roundrectangle", L = D === "circle", R = 2;
if (S > 0 || x > 0 && w > 0) {
var I = t.fillStyle, M = t.strokeStyle, N = t.lineWidth, O = e.pstyle("text-background-color").value, k = e.pstyle("text-border-color").value, B = e.pstyle("text-border-style").value, _ = S > 0, F = x > 0 && w > 0, G = u - C;
switch (m) {
case "left":
G -= d;
break;
case "center":
G -= d / 2;
break;
}
var H = l - p - C, Y = d + 2 * C, X = p + 2 * C;
if (_ && (t.fillStyle = "rgba(".concat(O[0], ",").concat(O[1], ",").concat(O[2], ",").concat(S * o, ")")), F && (t.strokeStyle = "rgba(".concat(k[0], ",").concat(k[1], ",").concat(k[2], ",").concat(w * o, ")"), t.lineWidth = x, t.setLineDash))
switch (B) {
case "dotted":
t.setLineDash([1, 1]);
break;
case "dashed":
t.setLineDash([4, 2]);
break;
case "double":
t.lineWidth = x / 4, t.setLineDash([]);
break;
case "solid":
default:
t.setLineDash([]);
break;
}
if (A ? (t.beginPath(), jl(t, G, H, Y, X, R)) : L ? (t.beginPath(), vm(t, G, H, Y, X)) : (t.beginPath(), t.rect(G, H, Y, X)), _ && t.fill(), F && t.stroke(), F && B === "double") {
var W = x / 2;
t.beginPath(), A ? jl(t, G + W, H + W, Y - 2 * W, X - 2 * W, R) : t.rect(G + W, H + W, Y - 2 * W, X - 2 * W), t.stroke();
}
t.fillStyle = I, t.strokeStyle = M, t.lineWidth = N, t.setLineDash && t.setLineDash([]);
}
var ee = 2 * e.pstyle("text-outline-width").pfValue;
if (ee > 0 && (t.lineWidth = ee), e.pstyle("text-wrap").value === "wrap") {
var ae = Dt(s, "labelWrapCachedLines", r), J = Dt(s, "labelLineHeight", r), z = d / 2, V = this.getLabelJustification(e);
switch (V === "auto" || (m === "left" ? V === "left" ? u += -d : V === "center" && (u += -z) : m === "center" ? V === "left" ? u += -z : V === "right" && (u += z) : m === "right" && (V === "center" ? u += z : V === "right" && (u += d))), E) {
case "top":
l -= (ae.length - 1) * J;
break;
case "center":
case "bottom":
l -= (ae.length - 1) * J;
break;
}
for (var q = 0; q < ae.length; q++)
ee > 0 && t.strokeText(ae[q], u, l), t.fillText(ae[q], u, l), l += J;
} else
ee > 0 && t.strokeText(v, u, l), t.fillText(v, u, l);
T !== 0 && (t.rotate(-T), t.translate(-f, -c));
}
}
};
var wr = {};
wr.drawNode = function(t, e, r) {
var a = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !0, n = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, i = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : !0, s = this, o, u, l = e._private, f = l.rscratch, c = e.position();
if (!(!ne(c.x) || !ne(c.y)) && !(i && !e.visible())) {
var v = i ? e.effectiveOpacity() : 1, h = s.usePaths(), d, p = !1, g = e.padding();
o = e.width() + 2 * g, u = e.height() + 2 * g;
var y;
r && (y = r, t.translate(-y.x1, -y.y1));
for (var b = e.pstyle("background-image"), m = b.value, E = new Array(m.length), T = new Array(m.length), S = 0, w = 0; w < m.length; w++) {
var x = m[w], C = E[w] = x != null && x !== "none";
if (C) {
var D = e.cy().style().getIndexedStyle(e, "background-image-crossorigin", "value", w);
S++, T[w] = s.getCachedImage(x, D, function() {
l.backgroundTimestamp = Date.now(), e.emitAndNotify("background");
});
}
}
var A = e.pstyle("background-blacken").value, L = e.pstyle("border-width").pfValue, R = e.pstyle("background-opacity").value * v, I = e.pstyle("border-color").value, M = e.pstyle("border-style").value, N = e.pstyle("border-join").value, O = e.pstyle("border-cap").value, k = e.pstyle("border-position").value, B = e.pstyle("border-dash-pattern").pfValue, _ = e.pstyle("border-dash-offset").pfValue, F = e.pstyle("border-opacity").value * v, G = e.pstyle("outline-width").pfValue, H = e.pstyle("outline-color").value, Y = e.pstyle("outline-style").value, X = e.pstyle("outline-opacity").value * v, W = e.pstyle("outline-offset").value, ee = e.pstyle("corner-radius").value;
ee !== "auto" && (ee = e.pstyle("corner-radius").pfValue);
var ae = function() {
var ue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : R;
s.eleFillStyle(t, e, ue);
}, J = function() {
var ue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : F;
s.colorStrokeStyle(t, I[0], I[1], I[2], ue);
}, z = function() {
var ue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : X;
s.colorStrokeStyle(t, H[0], H[1], H[2], ue);
}, V = function(ue, Q, P, U) {
var $ = s.nodePathCache = s.nodePathCache || [], K = Sf(P === "polygon" ? P + "," + U.join(",") : P, "" + Q, "" + ue, "" + ee), j = $[K], oe, te = !1;
return j != null ? (oe = j, te = !0, f.pathCache = oe) : (oe = new Path2D(), $[K] = f.pathCache = oe), {
path: oe,
cacheHit: te
};
}, q = e.pstyle("shape").strValue, Z = e.pstyle("shape-polygon-points").pfValue;
if (h) {
t.translate(c.x, c.y);
var re = V(o, u, q, Z);
d = re.path, p = re.cacheHit;
}
var ve = function() {
if (!p) {
var ue = c;
h && (ue = {
x: 0,
y: 0
}), s.nodeShapes[s.getNodeShape(e)].draw(d || t, ue.x, ue.y, o, u, ee, f);
}
h ? t.fill(d) : t.fill();
}, Ie = function() {
for (var ue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : v, Q = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, P = l.backgrounding, U = 0, $ = 0; $ < T.length; $++) {
var K = e.cy().style().getIndexedStyle(e, "background-image-containment", "value", $);
if (Q && K === "over" || !Q && K === "inside") {
U++;
continue;
}
E[$] && T[$].complete && !T[$].error && (U++, s.drawInscribedImage(t, T[$], e, $, ue));
}
l.backgrounding = U !== S, P !== l.backgrounding && e.updateStyle(!1);
}, Te = function() {
var ue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1, Q = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : v;
s.hasPie(e) && (s.drawPie(t, e, Q), ue && (h || s.nodeShapes[s.getNodeShape(e)].draw(t, c.x, c.y, o, u, ee, f)));
}, we = function() {
var ue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1, Q = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : v;
s.hasStripe(e) && (t.save(), h ? t.clip(f.pathCache) : (s.nodeShapes[s.getNodeShape(e)].draw(t, c.x, c.y, o, u, ee, f), t.clip()), s.drawStripe(t, e, Q), t.restore(), ue && (h || s.nodeShapes[s.getNodeShape(e)].draw(t, c.x, c.y, o, u, ee, f)));
}, ye = function() {
var ue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : v, Q = (A > 0 ? A : -A) * ue, P = A > 0 ? 0 : 255;
A !== 0 && (s.colorFillStyle(t, P, P, P, Q), h ? t.fill(d) : t.fill());
}, ie = function() {
if (L > 0) {
if (t.lineWidth = L, t.lineCap = O, t.lineJoin = N, t.setLineDash)
switch (M) {
case "dotted":
t.setLineDash([1, 1]);
break;
case "dashed":
t.setLineDash(B), t.lineDashOffset = _;
break;
case "solid":
case "double":
t.setLineDash([]);
break;
}
if (k !== "center") {
if (t.save(), t.lineWidth *= 2, k === "inside")
h ? t.clip(d) : t.clip();
else {
var ue = new Path2D();
ue.rect(-o / 2 - L, -u / 2 - L, o + 2 * L, u + 2 * L), ue.addPath(d), t.clip(ue, "evenodd");
}
h ? t.stroke(d) : t.stroke(), t.restore();
} else
h ? t.stroke(d) : t.stroke();
if (M === "double") {
t.lineWidth = L / 3;
var Q = t.globalCompositeOperation;
t.globalCompositeOperation = "destination-out", h ? t.stroke(d) : t.stroke(), t.globalCompositeOperation = Q;
}
t.setLineDash && t.setLineDash([]);
}
}, he = function() {
if (G > 0) {
if (t.lineWidth = G, t.lineCap = "butt", t.setLineDash)
switch (Y) {
case "dotted":
t.setLineDash([1, 1]);
break;
case "dashed":
t.setLineDash([4, 2]);
break;
case "solid":
case "double":
t.setLineDash([]);
break;
}
var ue = c;
h && (ue = {
x: 0,
y: 0
});
var Q = s.getNodeShape(e), P = L;
k === "inside" && (P = 0), k === "outside" && (P *= 2);
var U = (o + P + (G + W)) / o, $ = (u + P + (G + W)) / u, K = o * U, j = u * $, oe = s.nodeShapes[Q].points, te;
if (h) {
var fe = V(K, j, Q, oe);
te = fe.path;
}
if (Q === "ellipse")
s.drawEllipsePath(te || t, ue.x, ue.y, K, j);
else if (["round-diamond", "round-heptagon", "round-hexagon", "round-octagon", "round-pentagon", "round-polygon", "round-triangle", "round-tag"].includes(Q)) {
var le = 0, me = 0, Ae = 0;
Q === "round-diamond" ? le = (P + W + G) * 1.4 : Q === "round-heptagon" ? (le = (P + W + G) * 1.075, Ae = -(P / 2 + W + G) / 35) : Q === "round-hexagon" ? le = (P + W + G) * 1.12 : Q === "round-pentagon" ? (le = (P + W + G) * 1.13, Ae = -(P / 2 + W + G) / 15) : Q === "round-tag" ? (le = (P + W + G) * 1.12, me = (P / 2 + G + W) * 0.07) : Q === "round-triangle" && (le = (P + W + G) * (Math.PI / 2), Ae = -(P + W / 2 + G) / Math.PI), le !== 0 && (U = (o + le) / o, K = o * U, ["round-hexagon", "round-tag"].includes(Q) || ($ = (u + le) / u, j = u * $)), ee = ee === "auto" ? Bf(K, j) : ee;
for (var Ce = K / 2, ce = j / 2, Re = ee + (P + G + W) / 2, Le = new Array(oe.length / 2), je = new Array(oe.length / 2), $e = 0; $e < oe.length / 2; $e++)
Le[$e] = {
x: ue.x + me + Ce * oe[$e * 2],
y: ue.y + Ae + ce * oe[$e * 2 + 1]
};
var bt, Ke, st, et, ft = Le.length;
for (Ke = Le[ft - 1], bt = 0; bt < ft; bt++)
st = Le[bt % ft], et = Le[(bt + 1) % ft], je[bt] = So(Ke, st, et, Re), Ke = st, st = et;
s.drawRoundPolygonPath(te || t, ue.x + me, ue.y + Ae, o * U, u * $, oe, je);
} else if (["roundrectangle", "round-rectangle"].includes(Q))
ee = ee === "auto" ? vr(K, j) : ee, s.drawRoundRectanglePath(te || t, ue.x, ue.y, K, j, ee + (P + G + W) / 2);
else if (["cutrectangle", "cut-rectangle"].includes(Q))
ee = ee === "auto" ? go() : ee, s.drawCutRectanglePath(te || t, ue.x, ue.y, K, j, null, ee + (P + G + W) / 4);
else if (["bottomroundrectangle", "bottom-round-rectangle"].includes(Q))
ee = ee === "auto" ? vr(K, j) : ee, s.drawBottomRoundRectanglePath(te || t, ue.x, ue.y, K, j, ee + (P + G + W) / 2);
else if (Q === "barrel")
s.drawBarrelPath(te || t, ue.x, ue.y, K, j);
else if (Q.startsWith("polygon") || ["rhomboid", "right-rhomboid", "round-tag", "tag", "vee"].includes(Q)) {
var tr = (P + G + W) / o;
oe = An(Ln(oe, tr)), s.drawPolygonPath(te || t, ue.x, ue.y, o, u, oe);
} else {
var Ze = (P + G + W) / o;
oe = An(Ln(oe, -Ze)), s.drawPolygonPath(te || t, ue.x, ue.y, o, u, oe);
}
if (h ? t.stroke(te) : t.stroke(), Y === "double") {
t.lineWidth = P / 3;
var Xt = t.globalCompositeOperation;
t.globalCompositeOperation = "destination-out", h ? t.stroke(te) : t.stroke(), t.globalCompositeOperation = Xt;
}
t.setLineDash && t.setLineDash([]);
}
}, de = function() {
n && s.drawNodeOverlay(t, e, c, o, u);
}, xe = function() {
n && s.drawNodeUnderlay(t, e, c, o, u);
}, pe = function() {
s.drawElementText(t, e, null, a);
}, De = e.pstyle("ghost").value === "yes";
if (De) {
var Pe = e.pstyle("ghost-offset-x").pfValue, Ne = e.pstyle("ghost-offset-y").pfValue, Be = e.pstyle("ghost-opacity").value, Fe = Be * v;
t.translate(Pe, Ne), z(), he(), ae(Be * R), ve(), Ie(Fe, !0), J(Be * F), ie(), Te(A !== 0 || L !== 0), we(A !== 0 || L !== 0), Ie(Fe, !1), ye(Fe), t.translate(-Pe, -Ne);
}
h && t.translate(-c.x, -c.y), xe(), h && t.translate(c.x, c.y), z(), he(), ae(), ve(), Ie(v, !0), J(), ie(), Te(A !== 0 || L !== 0), we(A !== 0 || L !== 0), Ie(v, !1), ye(), h && t.translate(-c.x, -c.y), pe(), de(), r && t.translate(y.x1, y.y1);
}
};
var Uc = function(e) {
if (!["overlay", "underlay"].includes(e))
throw new Error("Invalid state");
return function(r, a, n, i, s) {
var o = this;
if (a.visible()) {
var u = a.pstyle("".concat(e, "-padding")).pfValue, l = a.pstyle("".concat(e, "-opacity")).value, f = a.pstyle("".concat(e, "-color")).value, c = a.pstyle("".concat(e, "-shape")).value, v = a.pstyle("".concat(e, "-corner-radius")).value;
if (l > 0) {
if (n = n || a.position(), i == null || s == null) {
var h = a.padding();
i = a.width() + 2 * h, s = a.height() + 2 * h;
}
o.colorFillStyle(r, f[0], f[1], f[2], l), o.nodeShapes[c].draw(r, n.x, n.y, i + u * 2, s + u * 2, v), r.fill();
}
}
};
};
wr.drawNodeOverlay = Uc("overlay");
wr.drawNodeUnderlay = Uc("underlay");
wr.hasPie = function(t) {
return t = t[0], t._private.hasPie;
};
wr.hasStripe = function(t) {
return t = t[0], t._private.hasStripe;
};
wr.drawPie = function(t, e, r, a) {
e = e[0], a = a || e.position();
var n = e.cy().style(), i = e.pstyle("pie-size"), s = e.pstyle("pie-hole"), o = e.pstyle("pie-start-angle").pfValue, u = a.x, l = a.y, f = e.width(), c = e.height(), v = Math.min(f, c) / 2, h, d = 0, p = this.usePaths();
if (p && (u = 0, l = 0), i.units === "%" ? v = v * i.pfValue : i.pfValue !== void 0 && (v = i.pfValue / 2), s.units === "%" ? h = v * s.pfValue : s.pfValue !== void 0 && (h = s.pfValue / 2), !(h >= v))
for (var g = 1; g <= n.pieBackgroundN; g++) {
var y = e.pstyle("pie-" + g + "-background-size").value, b = e.pstyle("pie-" + g + "-background-color").value, m = e.pstyle("pie-" + g + "-background-opacity").value * r, E = y / 100;
E + d > 1 && (E = 1 - d);
var T = 1.5 * Math.PI + 2 * Math.PI * d;
T += o;
var S = 2 * Math.PI * E, w = T + S;
y === 0 || d >= 1 || d + E > 1 || (h === 0 ? (t.beginPath(), t.moveTo(u, l), t.arc(u, l, v, T, w), t.closePath()) : (t.beginPath(), t.arc(u, l, v, T, w), t.arc(u, l, h, w, T, !0), t.closePath()), this.colorFillStyle(t, b[0], b[1], b[2], m), t.fill(), d += E);
}
};
wr.drawStripe = function(t, e, r, a) {
e = e[0], a = a || e.position();
var n = e.cy().style(), i = a.x, s = a.y, o = e.width(), u = e.height(), l = 0, f = this.usePaths();
t.save();
var c = e.pstyle("stripe-direction").value, v = e.pstyle("stripe-size");
switch (c) {
case "vertical":
break;
case "righward":
t.rotate(-Math.PI / 2);
break;
}
var h = o, d = u;
v.units === "%" ? (h = h * v.pfValue, d = d * v.pfValue) : v.pfValue !== void 0 && (h = v.pfValue, d = v.pfValue), f && (i = 0, s = 0), s -= h / 2, i -= d / 2;
for (var p = 1; p <= n.stripeBackgroundN; p++) {
var g = e.pstyle("stripe-" + p + "-background-size").value, y = e.pstyle("stripe-" + p + "-background-color").value, b = e.pstyle("stripe-" + p + "-background-opacity").value * r, m = g / 100;
m + l > 1 && (m = 1 - l), !(g === 0 || l >= 1 || l + m > 1) && (t.beginPath(), t.rect(i, s + d * l, h, d * m), t.closePath(), this.colorFillStyle(t, y[0], y[1], y[2], b), t.fill(), l += m);
}
t.restore();
};
var xt = {}, hm = 100;
xt.getPixelRatio = function() {
var t = this.data.contexts[0];
if (this.forcedPixelRatio != null)
return this.forcedPixelRatio;
var e = this.cy.window(), r = t.backingStorePixelRatio || t.webkitBackingStorePixelRatio || t.mozBackingStorePixelRatio || t.msBackingStorePixelRatio || t.oBackingStorePixelRatio || t.backingStorePixelRatio || 1;
return (e.devicePixelRatio || 1) / r;
};
xt.paintCache = function(t) {
for (var e = this.paintCaches = this.paintCaches || [], r = !0, a, n = 0; n < e.length; n++)
if (a = e[n], a.context === t) {
r = !1;
break;
}
return r && (a = {
context: t
}, e.push(a)), a;
};
xt.createGradientStyleFor = function(t, e, r, a, n) {
var i, s = this.usePaths(), o = r.pstyle(e + "-gradient-stop-colors").value, u = r.pstyle(e + "-gradient-stop-positions").pfValue;
if (a === "radial-gradient")
if (r.isEdge()) {
var l = r.sourceEndpoint(), f = r.targetEndpoint(), c = r.midpoint(), v = Pr(l, c), h = Pr(f, c);
i = t.createRadialGradient(c.x, c.y, 0, c.x, c.y, Math.max(v, h));
} else {
var d = s ? {
x: 0,
y: 0
} : r.position(), p = r.paddedWidth(), g = r.paddedHeight();
i = t.createRadialGradient(d.x, d.y, 0, d.x, d.y, Math.max(p, g));
}
else if (r.isEdge()) {
var y = r.sourceEndpoint(), b = r.targetEndpoint();
i = t.createLinearGradient(y.x, y.y, b.x, b.y);
} else {
var m = s ? {
x: 0,
y: 0
} : r.position(), E = r.paddedWidth(), T = r.paddedHeight(), S = E / 2, w = T / 2, x = r.pstyle("background-gradient-direction").value;
switch (x) {
case "to-bottom":
i = t.createLinearGradient(m.x, m.y - w, m.x, m.y + w);
break;
case "to-top":
i = t.createLinearGradient(m.x, m.y + w, m.x, m.y - w);
break;
case "to-left":
i = t.createLinearGradient(m.x + S, m.y, m.x - S, m.y);
break;
case "to-right":
i = t.createLinearGradient(m.x - S, m.y, m.x + S, m.y);
break;
case "to-bottom-right":
case "to-right-bottom":
i = t.createLinearGradient(m.x - S, m.y - w, m.x + S, m.y + w);
break;
case "to-top-right":
case "to-right-top":
i = t.createLinearGradient(m.x - S, m.y + w, m.x + S, m.y - w);
break;
case "to-bottom-left":
case "to-left-bottom":
i = t.createLinearGradient(m.x + S, m.y - w, m.x - S, m.y + w);
break;
case "to-top-left":
case "to-left-top":
i = t.createLinearGradient(m.x + S, m.y + w, m.x - S, m.y - w);
break;
}
}
if (!i)
return null;
for (var C = u.length === o.length, D = o.length, A = 0; A < D; A++)
i.addColorStop(C ? u[A] : A / (D - 1), "rgba(" + o[A][0] + "," + o[A][1] + "," + o[A][2] + "," + n + ")");
return i;
};
xt.gradientFillStyle = function(t, e, r, a) {
var n = this.createGradientStyleFor(t, "background", e, r, a);
if (!n)
return null;
t.fillStyle = n;
};
xt.colorFillStyle = function(t, e, r, a, n) {
t.fillStyle = "rgba(" + e + "," + r + "," + a + "," + n + ")";
};
xt.eleFillStyle = function(t, e, r) {
var a = e.pstyle("background-fill").value;
if (a === "linear-gradient" || a === "radial-gradient")
this.gradientFillStyle(t, e, a, r);
else {
var n = e.pstyle("background-color").value;
this.colorFillStyle(t, n[0], n[1], n[2], r);
}
};
xt.gradientStrokeStyle = function(t, e, r, a) {
var n = this.createGradientStyleFor(t, "line", e, r, a);
if (!n)
return null;
t.strokeStyle = n;
};
xt.colorStrokeStyle = function(t, e, r, a, n) {
t.strokeStyle = "rgba(" + e + "," + r + "," + a + "," + n + ")";
};
xt.eleStrokeStyle = function(t, e, r) {
var a = e.pstyle("line-fill").value;
if (a === "linear-gradient" || a === "radial-gradient")
this.gradientStrokeStyle(t, e, a, r);
else {
var n = e.pstyle("line-color").value;
this.colorStrokeStyle(t, n[0], n[1], n[2], r);
}
};
xt.matchCanvasSize = function(t) {
var e = this, r = e.data, a = e.findContainerClientCoords(), n = a[2], i = a[3], s = e.getPixelRatio(), o = e.motionBlurPxRatio;
(t === e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_NODE] || t === e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_DRAG]) && (s = o);
var u = n * s, l = i * s, f;
if (!(u === e.canvasWidth && l === e.canvasHeight)) {
e.fontCaches = null;
var c = r.canvasContainer;
c.style.width = n + "px", c.style.height = i + "px";
for (var v = 0; v < e.CANVAS_LAYERS; v++)
f = r.canvases[v], f.width = u, f.height = l, f.style.width = n + "px", f.style.height = i + "px";
for (var v = 0; v < e.BUFFER_COUNT; v++)
f = r.bufferCanvases[v], f.width = u, f.height = l, f.style.width = n + "px", f.style.height = i + "px";
e.textureMult = 1, s <= 1 && (f = r.bufferCanvases[e.TEXTURE_BUFFER], e.textureMult = 2, f.width = u * e.textureMult, f.height = l * e.textureMult), e.canvasWidth = u, e.canvasHeight = l, e.pixelRatio = s;
}
};
xt.renderTo = function(t, e, r, a) {
this.render({
forcedContext: t,
forcedZoom: e,
forcedPan: r,
drawAllLayers: !0,
forcedPxRatio: a
});
};
xt.clearCanvas = function() {
var t = this, e = t.data;
function r(a) {
a.clearRect(0, 0, t.canvasWidth, t.canvasHeight);
}
r(e.contexts[t.NODE]), r(e.contexts[t.DRAG]);
};
xt.render = function(t) {
var e = this;
t = t || If();
var r = e.cy, a = t.forcedContext, n = t.drawAllLayers, i = t.drawOnlyNodeLayer, s = t.forcedZoom, o = t.forcedPan, u = t.forcedPxRatio === void 0 ? this.getPixelRatio() : t.forcedPxRatio, l = e.data, f = l.canvasNeedsRedraw, c = e.textureOnViewport && !a && (e.pinching || e.hoverData.dragging || e.swipePanning || e.data.wheelZooming), v = t.motionBlur !== void 0 ? t.motionBlur : e.motionBlur, h = e.motionBlurPxRatio, d = r.hasCompoundNodes(), p = e.hoverData.draggingEles, g = !!(e.hoverData.selecting || e.touchData.selecting);
v = v && !a && e.motionBlurEnabled && !g;
var y = v;
a || (e.prevPxRatio !== u && (e.invalidateContainerClientCoordsCache(), e.matchCanvasSize(e.container), e.redrawHint("eles", !0), e.redrawHint("drag", !0)), e.prevPxRatio = u), !a && e.motionBlurTimeout && clearTimeout(e.motionBlurTimeout), v && (e.mbFrames == null && (e.mbFrames = 0), e.mbFrames++, e.mbFrames < 3 && (y = !1), e.mbFrames > e.minMbLowQualFrames && (e.motionBlurPxRatio = e.mbPxRBlurry)), e.clearingMotionBlur && (e.motionBlurPxRatio = 1), e.textureDrawLastFrame && !c && (f[e.NODE] = !0, f[e.SELECT_BOX] = !0);
var b = r.style(), m = r.zoom(), E = s !== void 0 ? s : m, T = r.pan(), S = {
x: T.x,
y: T.y
}, w = {
zoom: m,
pan: {
x: T.x,
y: T.y
}
}, x = e.prevViewport, C = x === void 0 || w.zoom !== x.zoom || w.pan.x !== x.pan.x || w.pan.y !== x.pan.y;
!C && !(p && !d) && (e.motionBlurPxRatio = 1), o && (S = o), E *= u, S.x *= u, S.y *= u;
var D = e.getCachedZSortedEles();
function A(J, z, V, q, Z) {
var re = J.globalCompositeOperation;
J.globalCompositeOperation = "destination-out", e.colorFillStyle(J, 255, 255, 255, e.motionBlurTransparency), J.fillRect(z, V, q, Z), J.globalCompositeOperation = re;
}
function L(J, z) {
var V, q, Z, re;
!e.clearingMotionBlur && (J === l.bufferContexts[e.MOTIONBLUR_BUFFER_NODE] || J === l.bufferContexts[e.MOTIONBLUR_BUFFER_DRAG]) ? (V = {
x: T.x * h,
y: T.y * h
}, q = m * h, Z = e.canvasWidth * h, re = e.canvasHeight * h) : (V = S, q = E, Z = e.canvasWidth, re = e.canvasHeight), J.setTransform(1, 0, 0, 1, 0, 0), z === "motionBlur" ? A(J, 0, 0, Z, re) : !a && (z === void 0 || z) && J.clearRect(0, 0, Z, re), n || (J.translate(V.x, V.y), J.scale(q, q)), o && J.translate(o.x, o.y), s && J.scale(s, s);
}
if (c || (e.textureDrawLastFrame = !1), c) {
if (e.textureDrawLastFrame = !0, !e.textureCache) {
e.textureCache = {}, e.textureCache.bb = r.mutableElements().boundingBox(), e.textureCache.texture = e.data.bufferCanvases[e.TEXTURE_BUFFER];
var R = e.data.bufferContexts[e.TEXTURE_BUFFER];
R.setTransform(1, 0, 0, 1, 0, 0), R.clearRect(0, 0, e.canvasWidth * e.textureMult, e.canvasHeight * e.textureMult), e.render({
forcedContext: R,
drawOnlyNodeLayer: !0,
forcedPxRatio: u * e.textureMult
});
var w = e.textureCache.viewport = {
zoom: r.zoom(),
pan: r.pan(),
width: e.canvasWidth,
height: e.canvasHeight
};
w.mpan = {
x: (0 - w.pan.x) / w.zoom,
y: (0 - w.pan.y) / w.zoom
};
}
f[e.DRAG] = !1, f[e.NODE] = !1;
var I = l.contexts[e.NODE], M = e.textureCache.texture, w = e.textureCache.viewport;
I.setTransform(1, 0, 0, 1, 0, 0), v ? A(I, 0, 0, w.width, w.height) : I.clearRect(0, 0, w.width, w.height);
var N = b.core("outside-texture-bg-color").value, O = b.core("outside-texture-bg-opacity").value;
e.colorFillStyle(I, N[0], N[1], N[2], O), I.fillRect(0, 0, w.width, w.height);
var m = r.zoom();
L(I, !1), I.clearRect(w.mpan.x, w.mpan.y, w.width / w.zoom / u, w.height / w.zoom / u), I.drawImage(M, w.mpan.x, w.mpan.y, w.width / w.zoom / u, w.height / w.zoom / u);
} else
e.textureOnViewport && !a && (e.textureCache = null);
var k = r.extent(), B = e.pinching || e.hoverData.dragging || e.swipePanning || e.data.wheelZooming || e.hoverData.draggingEles || e.cy.animated(), _ = e.hideEdgesOnViewport && B, F = [];
if (F[e.NODE] = !f[e.NODE] && v && !e.clearedForMotionBlur[e.NODE] || e.clearingMotionBlur, F[e.NODE] && (e.clearedForMotionBlur[e.NODE] = !0), F[e.DRAG] = !f[e.DRAG] && v && !e.clearedForMotionBlur[e.DRAG] || e.clearingMotionBlur, F[e.DRAG] && (e.clearedForMotionBlur[e.DRAG] = !0), f[e.NODE] || n || i || F[e.NODE]) {
var G = v && !F[e.NODE] && h !== 1, I = a || (G ? e.data.bufferContexts[e.MOTIONBLUR_BUFFER_NODE] : l.contexts[e.NODE]), H = v && !G ? "motionBlur" : void 0;
L(I, H), _ ? e.drawCachedNodes(I, D.nondrag, u, k) : e.drawLayeredElements(I, D.nondrag, u, k), e.debug && e.drawDebugPoints(I, D.nondrag), !n && !v && (f[e.NODE] = !1);
}
if (!i && (f[e.DRAG] || n || F[e.DRAG])) {
var G = v && !F[e.DRAG] && h !== 1, I = a || (G ? e.data.bufferContexts[e.MOTIONBLUR_BUFFER_DRAG] : l.contexts[e.DRAG]);
L(I, v && !G ? "motionBlur" : void 0), _ ? e.drawCachedNodes(I, D.drag, u, k) : e.drawCachedElements(I, D.drag, u, k), e.debug && e.drawDebugPoints(I, D.drag), !n && !v && (f[e.DRAG] = !1);
}
if (this.drawSelectionRectangle(t, L), v && h !== 1) {
var Y = l.contexts[e.NODE], X = e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_NODE], W = l.contexts[e.DRAG], ee = e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_DRAG], ae = function(z, V, q) {
z.setTransform(1, 0, 0, 1, 0, 0), q || !y ? z.clearRect(0, 0, e.canvasWidth, e.canvasHeight) : A(z, 0, 0, e.canvasWidth, e.canvasHeight);
var Z = h;
z.drawImage(
V,
// img
0,
0,
// sx, sy
e.canvasWidth * Z,
e.canvasHeight * Z,
// sw, sh
0,
0,
// x, y
e.canvasWidth,
e.canvasHeight
// w, h
);
};
(f[e.NODE] || F[e.NODE]) && (ae(Y, X, F[e.NODE]), f[e.NODE] = !1), (f[e.DRAG] || F[e.DRAG]) && (ae(W, ee, F[e.DRAG]), f[e.DRAG] = !1);
}
e.prevViewport = w, e.clearingMotionBlur && (e.clearingMotionBlur = !1, e.motionBlurCleared = !0, e.motionBlur = !0), v && (e.motionBlurTimeout = setTimeout(function() {
e.motionBlurTimeout = null, e.clearedForMotionBlur[e.NODE] = !1, e.clearedForMotionBlur[e.DRAG] = !1, e.motionBlur = !1, e.clearingMotionBlur = !c, e.mbFrames = 0, f[e.NODE] = !0, f[e.DRAG] = !0, e.redraw();
}, hm)), a || r.emit("render");
};
var ya;
xt.drawSelectionRectangle = function(t, e) {
var r = this, a = r.cy, n = r.data, i = a.style(), s = t.drawOnlyNodeLayer, o = t.drawAllLayers, u = n.canvasNeedsRedraw, l = t.forcedContext;
if (r.showFps || !s && u[r.SELECT_BOX] && !o) {
var f = l || n.contexts[r.SELECT_BOX];
if (e(f), r.selection[4] == 1 && (r.hoverData.selecting || r.touchData.selecting)) {
var c = r.cy.zoom(), v = i.core("selection-box-border-width").value / c;
f.lineWidth = v, f.fillStyle = "rgba(" + i.core("selection-box-color").value[0] + "," + i.core("selection-box-color").value[1] + "," + i.core("selection-box-color").value[2] + "," + i.core("selection-box-opacity").value + ")", f.fillRect(r.selection[0], r.selection[1], r.selection[2] - r.selection[0], r.selection[3] - r.selection[1]), v > 0 && (f.strokeStyle = "rgba(" + i.core("selection-box-border-color").value[0] + "," + i.core("selection-box-border-color").value[1] + "," + i.core("selection-box-border-color").value[2] + "," + i.core("selection-box-opacity").value + ")", f.strokeRect(r.selection[0], r.selection[1], r.selection[2] - r.selection[0], r.selection[3] - r.selection[1]));
}
if (n.bgActivePosistion && !r.hoverData.selecting) {
var c = r.cy.zoom(), h = n.bgActivePosistion;
f.fillStyle = "rgba(" + i.core("active-bg-color").value[0] + "," + i.core("active-bg-color").value[1] + "," + i.core("active-bg-color").value[2] + "," + i.core("active-bg-opacity").value + ")", f.beginPath(), f.arc(h.x, h.y, i.core("active-bg-size").pfValue / c, 0, 2 * Math.PI), f.fill();
}
var d = r.lastRedrawTime;
if (r.showFps && d) {
d = Math.round(d);
var p = Math.round(1e3 / d), g = "1 frame = " + d + " ms = " + p + " fps";
if (f.setTransform(1, 0, 0, 1, 0, 0), f.fillStyle = "rgba(255, 0, 0, 0.75)", f.strokeStyle = "rgba(255, 0, 0, 0.75)", f.font = "30px Arial", !ya) {
var y = f.measureText(g);
ya = y.actualBoundingBoxAscent;
}
f.fillText(g, 0, ya);
var b = 60;
f.strokeRect(0, ya + 10, 250, 20), f.fillRect(0, ya + 10, 250 * Math.min(p / b, 1), 20);
}
o || (u[r.SELECT_BOX] = !1);
}
};
function ef(t, e, r) {
var a = t.createShader(e);
if (t.shaderSource(a, r), t.compileShader(a), !t.getShaderParameter(a, t.COMPILE_STATUS))
throw new Error(t.getShaderInfoLog(a));
return a;
}
function dm(t, e, r) {
var a = ef(t, t.VERTEX_SHADER, e), n = ef(t, t.FRAGMENT_SHADER, r), i = t.createProgram();
if (t.attachShader(i, a), t.attachShader(i, n), t.linkProgram(i), !t.getProgramParameter(i, t.LINK_STATUS))
throw new Error("Could not initialize shaders");
return i;
}
function gm(t, e, r) {
r === void 0 && (r = e);
var a = t.makeOffscreenCanvas(e, r), n = a.context = a.getContext("2d");
return a.clear = function() {
return n.clearRect(0, 0, a.width, a.height);
}, a.clear(), a;
}
function Ro(t) {
var e = t.pixelRatio, r = t.cy.zoom(), a = t.cy.pan();
return {
zoom: r * e,
pan: {
x: a.x * e,
y: a.y * e
}
};
}
function pm(t) {
var e = t.pixelRatio, r = t.cy.zoom();
return r * e;
}
function ym(t, e, r, a, n) {
var i = a * r + e.x, s = n * r + e.y;
return s = Math.round(t.canvasHeight - s), [i, s];
}
function mm(t) {
return t.pstyle("background-fill").value !== "solid" || t.pstyle("background-image").strValue !== "none" ? !1 : t.pstyle("border-width").value === 0 || t.pstyle("border-opacity").value === 0 ? !0 : t.pstyle("border-style").value === "solid";
}
function bm(t, e) {
if (t.length !== e.length)
return !1;
for (var r = 0; r < t.length; r++)
if (t[r] !== e[r])
return !1;
return !0;
}
function Cr(t, e, r) {
var a = t[0] / 255, n = t[1] / 255, i = t[2] / 255, s = e, o = r || new Array(4);
return o[0] = a * s, o[1] = n * s, o[2] = i * s, o[3] = s, o;
}
function Yr(t, e) {
var r = e || new Array(4);
return r[0] = (t >> 0 & 255) / 255, r[1] = (t >> 8 & 255) / 255, r[2] = (t >> 16 & 255) / 255, r[3] = (t >> 24 & 255) / 255, r;
}
function wm(t) {
return t[0] + (t[1] << 8) + (t[2] << 16) + (t[3] << 24);
}
function Em(t, e) {
var r = t.createTexture();
return r.buffer = function(a) {
t.bindTexture(t.TEXTURE_2D, r), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR_MIPMAP_NEAREST), t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !0), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, a), t.generateMipmap(t.TEXTURE_2D), t.bindTexture(t.TEXTURE_2D, null);
}, r.deleteTexture = function() {
t.deleteTexture(r);
}, r;
}
function qc(t, e) {
switch (e) {
case "float":
return [1, t.FLOAT, 4];
case "vec2":
return [2, t.FLOAT, 4];
case "vec3":
return [3, t.FLOAT, 4];
case "vec4":
return [4, t.FLOAT, 4];
case "int":
return [1, t.INT, 4];
case "ivec2":
return [2, t.INT, 4];
}
}
function Yc(t, e, r) {
switch (e) {
case t.FLOAT:
return new Float32Array(r);
case t.INT:
return new Int32Array(r);
}
}
function xm(t, e, r, a, n, i) {
switch (e) {
case t.FLOAT:
return new Float32Array(r.buffer, i * a, n);
case t.INT:
return new Int32Array(r.buffer, i * a, n);
}
}
function Tm(t, e, r, a) {
var n = qc(t, e), i = Je(n, 2), s = i[0], o = i[1], u = Yc(t, o, a), l = t.createBuffer();
return t.bindBuffer(t.ARRAY_BUFFER, l), t.bufferData(t.ARRAY_BUFFER, u, t.STATIC_DRAW), o === t.FLOAT ? t.vertexAttribPointer(r, s, o, !1, 0, 0) : o === t.INT && t.vertexAttribIPointer(r, s, o, 0, 0), t.enableVertexAttribArray(r), t.bindBuffer(t.ARRAY_BUFFER, null), l;
}
function zt(t, e, r, a) {
var n = qc(t, r), i = Je(n, 3), s = i[0], o = i[1], u = i[2], l = Yc(t, o, e * s), f = s * u, c = t.createBuffer();
t.bindBuffer(t.ARRAY_BUFFER, c), t.bufferData(t.ARRAY_BUFFER, e * f, t.DYNAMIC_DRAW), t.enableVertexAttribArray(a), o === t.FLOAT ? t.vertexAttribPointer(a, s, o, !1, f, 0) : o === t.INT && t.vertexAttribIPointer(a, s, o, f, 0), t.vertexAttribDivisor(a, 1), t.bindBuffer(t.ARRAY_BUFFER, null);
for (var v = new Array(e), h = 0; h < e; h++)
v[h] = xm(t, o, l, f, s, h);
return c.dataArray = l, c.stride = f, c.size = s, c.getView = function(d) {
return v[d];
}, c.setPoint = function(d, p, g) {
var y = v[d];
y[0] = p, y[1] = g;
}, c.bufferSubData = function(d) {
t.bindBuffer(t.ARRAY_BUFFER, c), d ? t.bufferSubData(t.ARRAY_BUFFER, 0, l, 0, d * s) : t.bufferSubData(t.ARRAY_BUFFER, 0, l);
}, c;
}
function Cm(t, e, r) {
for (var a = 9, n = new Float32Array(e * a), i = new Array(e), s = 0; s < e; s++) {
var o = s * a * 4;
i[s] = new Float32Array(n.buffer, o, a);
}
var u = t.createBuffer();
t.bindBuffer(t.ARRAY_BUFFER, u), t.bufferData(t.ARRAY_BUFFER, n.byteLength, t.DYNAMIC_DRAW);
for (var l = 0; l < 3; l++) {
var f = r + l;
t.enableVertexAttribArray(f), t.vertexAttribPointer(f, 3, t.FLOAT, !1, 3 * 12, l * 12), t.vertexAttribDivisor(f, 1);
}
return t.bindBuffer(t.ARRAY_BUFFER, null), u.getMatrixView = function(c) {
return i[c];
}, u.setData = function(c, v) {
i[v].set(c, 0);
}, u.bufferSubData = function() {
t.bindBuffer(t.ARRAY_BUFFER, u), t.bufferSubData(t.ARRAY_BUFFER, 0, n);
}, u;
}
function Dm(t) {
var e = t.createFramebuffer();
t.bindFramebuffer(t.FRAMEBUFFER, e);
var r = t.createTexture();
return t.bindTexture(t.TEXTURE_2D, r), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, r, 0), t.bindFramebuffer(t.FRAMEBUFFER, null), e.setFramebufferAttachmentSizes = function(a, n) {
t.bindTexture(t.TEXTURE_2D, r), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, a, n, 0, t.RGBA, t.UNSIGNED_BYTE, null);
}, e;
}
var tf = typeof Float32Array < "u" ? Float32Array : Array;
Math.hypot || (Math.hypot = function() {
for (var t = 0, e = arguments.length; e--; )
t += arguments[e] * arguments[e];
return Math.sqrt(t);
});
function As() {
var t = new tf(9);
return tf != Float32Array && (t[1] = 0, t[2] = 0, t[3] = 0, t[5] = 0, t[6] = 0, t[7] = 0), t[0] = 1, t[4] = 1, t[8] = 1, t;
}
function rf(t) {
return t[0] = 1, t[1] = 0, t[2] = 0, t[3] = 0, t[4] = 1, t[5] = 0, t[6] = 0, t[7] = 0, t[8] = 1, t;
}
function Sm(t, e, r) {
var a = e[0], n = e[1], i = e[2], s = e[3], o = e[4], u = e[5], l = e[6], f = e[7], c = e[8], v = r[0], h = r[1], d = r[2], p = r[3], g = r[4], y = r[5], b = r[6], m = r[7], E = r[8];
return t[0] = v * a + h * s + d * l, t[1] = v * n + h * o + d * f, t[2] = v * i + h * u + d * c, t[3] = p * a + g * s + y * l, t[4] = p * n + g * o + y * f, t[5] = p * i + g * u + y * c, t[6] = b * a + m * s + E * l, t[7] = b * n + m * o + E * f, t[8] = b * i + m * u + E * c, t;
}
function wn(t, e, r) {
var a = e[0], n = e[1], i = e[2], s = e[3], o = e[4], u = e[5], l = e[6], f = e[7], c = e[8], v = r[0], h = r[1];
return t[0] = a, t[1] = n, t[2] = i, t[3] = s, t[4] = o, t[5] = u, t[6] = v * a + h * s + l, t[7] = v * n + h * o + f, t[8] = v * i + h * u + c, t;
}
function af(t, e, r) {
var a = e[0], n = e[1], i = e[2], s = e[3], o = e[4], u = e[5], l = e[6], f = e[7], c = e[8], v = Math.sin(r), h = Math.cos(r);
return t[0] = h * a + v * s, t[1] = h * n + v * o, t[2] = h * i + v * u, t[3] = h * s - v * a, t[4] = h * o - v * n, t[5] = h * u - v * i, t[6] = l, t[7] = f, t[8] = c, t;
}
function Qs(t, e, r) {
var a = r[0], n = r[1];
return t[0] = a * e[0], t[1] = a * e[1], t[2] = a * e[2], t[3] = n * e[3], t[4] = n * e[4], t[5] = n * e[5], t[6] = e[6], t[7] = e[7], t[8] = e[8], t;
}
function Am(t, e, r) {
return t[0] = 2 / e, t[1] = 0, t[2] = 0, t[3] = 0, t[4] = -2 / r, t[5] = 0, t[6] = -1, t[7] = 1, t[8] = 1, t;
}
var Lm = /* @__PURE__ */ function() {
function t(e, r, a, n) {
yr(this, t), this.debugID = Math.floor(Math.random() * 1e4), this.r = e, this.texSize = r, this.texRows = a, this.texHeight = Math.floor(r / a), this.enableWrapping = !0, this.locked = !1, this.texture = null, this.needsBuffer = !0, this.freePointer = {
x: 0,
row: 0
}, this.keyToLocation = /* @__PURE__ */ new Map(), this.canvas = n(e, r, r), this.scratch = n(e, r, this.texHeight, "scratch");
}
return mr(t, [{
key: "lock",
value: function() {
this.locked = !0;
}
}, {
key: "getKeys",
value: function() {
return new Set(this.keyToLocation.keys());
}
}, {
key: "getScale",
value: function(r) {
var a = r.w, n = r.h, i = this.texHeight, s = this.texSize, o = i / n, u = a * o, l = n * o;
return u > s && (o = s / a, u = a * o, l = n * o), {
scale: o,
texW: u,
texH: l
};
}
}, {
key: "draw",
value: function(r, a, n) {
var i = this;
if (this.locked)
throw new Error("can't draw, atlas is locked");
var s = this.texSize, o = this.texRows, u = this.texHeight, l = this.getScale(a), f = l.scale, c = l.texW, v = l.texH, h = function(m, E) {
if (n && E) {
var T = E.context, S = m.x, w = m.row, x = S, C = u * w;
T.save(), T.translate(x, C), T.scale(f, f), n(T, a), T.restore();
}
}, d = [null, null], p = function() {
h(i.freePointer, i.canvas), d[0] = {
x: i.freePointer.x,
y: i.freePointer.row * u,
w: c,
h: v
}, d[1] = {
// create a second location with a width of 0, for convenience
x: i.freePointer.x + c,
y: i.freePointer.row * u,
w: 0,
h: v
}, i.freePointer.x += c, i.freePointer.x == s && (i.freePointer.x = 0, i.freePointer.row++);
}, g = function() {
var m = i.scratch, E = i.canvas;
m.clear(), h({
x: 0,
row: 0
}, m);
var T = s - i.freePointer.x, S = c - T, w = u;
{
var x = i.freePointer.x, C = i.freePointer.row * u, D = T;
E.context.drawImage(m, 0, 0, D, w, x, C, D, w), d[0] = {
x,
y: C,
w: D,
h: v
};
}
{
var A = T, L = (i.freePointer.row + 1) * u, R = S;
E && E.context.drawImage(m, A, 0, R, w, 0, L, R, w), d[1] = {
x: 0,
y: L,
w: R,
h: v
};
}
i.freePointer.x = S, i.freePointer.row++;
}, y = function() {
i.freePointer.x = 0, i.freePointer.row++;
};
if (this.freePointer.x + c <= s)
p();
else {
if (this.freePointer.row >= o - 1)
return !1;
this.freePointer.x === s ? (y(), p()) : this.enableWrapping ? g() : (y(), p());
}
return this.keyToLocation.set(r, d), this.needsBuffer = !0, d;
}
}, {
key: "getOffsets",
value: function(r) {
return this.keyToLocation.get(r);
}
}, {
key: "isEmpty",
value: function() {
return this.freePointer.x === 0 && this.freePointer.row === 0;
}
}, {
key: "canFit",
value: function(r) {
if (this.locked)
return !1;
var a = this.texSize, n = this.texRows, i = this.getScale(r), s = i.texW;
return this.freePointer.x + s > a ? this.freePointer.row < n - 1 : !0;
}
// called on every frame
}, {
key: "bufferIfNeeded",
value: function(r) {
this.texture || (this.texture = Em(r, this.debugID)), this.needsBuffer && (this.texture.buffer(this.canvas), this.needsBuffer = !1, this.locked && (this.canvas = null, this.scratch = null));
}
}, {
key: "dispose",
value: function() {
this.texture && (this.texture.deleteTexture(), this.texture = null), this.canvas = null, this.scratch = null, this.locked = !0;
}
}]);
}(), Rm = /* @__PURE__ */ function() {
function t(e, r, a, n) {
yr(this, t), this.r = e, this.texSize = r, this.texRows = a, this.createTextureCanvas = n, this.atlases = [], this.styleKeyToAtlas = /* @__PURE__ */ new Map(), this.markedKeys = /* @__PURE__ */ new Set();
}
return mr(t, [{
key: "getKeys",
value: function() {
return new Set(this.styleKeyToAtlas.keys());
}
}, {
key: "_createAtlas",
value: function() {
var r = this.r, a = this.texSize, n = this.texRows, i = this.createTextureCanvas;
return new Lm(r, a, n, i);
}
}, {
key: "_getScratchCanvas",
value: function() {
if (!this.scratch) {
var r = this.r, a = this.texSize, n = this.texRows, i = this.createTextureCanvas, s = Math.floor(a / n);
this.scratch = i(r, a, s, "scratch");
}
return this.scratch;
}
}, {
key: "draw",
value: function(r, a, n) {
var i = this.styleKeyToAtlas.get(r);
return i || (i = this.atlases[this.atlases.length - 1], (!i || !i.canFit(a)) && (i && i.lock(), i = this._createAtlas(), this.atlases.push(i)), i.draw(r, a, n), this.styleKeyToAtlas.set(r, i)), i;
}
}, {
key: "getAtlas",
value: function(r) {
return this.styleKeyToAtlas.get(r);
}
}, {
key: "hasAtlas",
value: function(r) {
return this.styleKeyToAtlas.has(r);
}
}, {
key: "markKeyForGC",
value: function(r) {
this.markedKeys.add(r);
}
}, {
key: "gc",
value: function() {
var r = this, a = this.markedKeys;
if (a.size === 0) {
console.log("nothing to garbage collect");
return;
}
var n = [], i = /* @__PURE__ */ new Map(), s = null, o = At(this.atlases), u;
try {
var l = function() {
var c = u.value, v = c.getKeys(), h = Im(a, v);
if (h.size === 0)
return n.push(c), v.forEach(function(T) {
return i.set(T, c);
}), 1;
s || (s = r._createAtlas(), n.push(s));
var d = At(v), p;
try {
for (d.s(); !(p = d.n()).done; ) {
var g = p.value;
if (!h.has(g)) {
var y = c.getOffsets(g), b = Je(y, 2), m = b[0], E = b[1];
s.canFit({
w: m.w + E.w,
h: m.h
}) || (s.lock(), s = r._createAtlas(), n.push(s)), c.canvas && (r._copyTextureToNewAtlas(g, c, s), i.set(g, s));
}
}
} catch (T) {
d.e(T);
} finally {
d.f();
}
c.dispose();
};
for (o.s(); !(u = o.n()).done; )
l();
} catch (f) {
o.e(f);
} finally {
o.f();
}
this.atlases = n, this.styleKeyToAtlas = i, this.markedKeys = /* @__PURE__ */ new Set();
}
}, {
key: "_copyTextureToNewAtlas",
value: function(r, a, n) {
var i = a.getOffsets(r), s = Je(i, 2), o = s[0], u = s[1];
if (u.w === 0)
n.draw(r, o, function(v) {
v.drawImage(a.canvas, o.x, o.y, o.w, o.h, 0, 0, o.w, o.h);
});
else {
var l = this._getScratchCanvas();
l.clear(), l.context.drawImage(a.canvas, o.x, o.y, o.w, o.h, 0, 0, o.w, o.h), l.context.drawImage(a.canvas, u.x, u.y, u.w, u.h, o.w, 0, u.w, u.h);
var f = o.w + u.w, c = o.h;
n.draw(r, {
w: f,
h: c
}, function(v) {
v.drawImage(
l,
0,
0,
f,
c,
0,
0,
f,
c
// the destination context has already been translated to the correct position
);
});
}
}
}, {
key: "getCounts",
value: function() {
return {
keyCount: this.styleKeyToAtlas.size,
atlasCount: new Set(this.styleKeyToAtlas.values()).size
};
}
}]);
}();
function Im(t, e) {
return t.intersection ? t.intersection(e) : new Set(Tn(t).filter(function(r) {
return e.has(r);
}));
}
var Pm = /* @__PURE__ */ function() {
function t(e, r) {
yr(this, t), this.r = e, this.globalOptions = r, this.atlasSize = r.webglTexSize, this.maxAtlasesPerBatch = r.webglTexPerBatch, this.renderTypes = /* @__PURE__ */ new Map(), this.collections = /* @__PURE__ */ new Map(), this.typeAndIdToKey = /* @__PURE__ */ new Map();
}
return mr(t, [{
key: "getAtlasSize",
value: function() {
return this.atlasSize;
}
}, {
key: "addAtlasCollection",
value: function(r, a) {
var n = this.globalOptions, i = n.webglTexSize, s = n.createTextureCanvas, o = a.texRows, u = this._cacheScratchCanvas(s), l = new Rm(this.r, i, o, u);
this.collections.set(r, l);
}
}, {
key: "addRenderType",
value: function(r, a) {
var n = a.collection;
if (!this.collections.has(n))
throw new Error("invalid atlas collection name '".concat(n, "'"));
var i = this.collections.get(n), s = be({
type: r,
atlasCollection: i
}, a);
this.renderTypes.set(r, s);
}
}, {
key: "getRenderTypeOpts",
value: function(r) {
return this.renderTypes.get(r);
}
}, {
key: "getAtlasCollection",
value: function(r) {
return this.collections.get(r);
}
}, {
key: "_cacheScratchCanvas",
value: function(r) {
var a = -1, n = -1, i = null;
return function(s, o, u, l) {
return l ? ((!i || o != a || u != n) && (a = o, n = u, i = r(s, o, u)), i) : r(s, o, u);
};
}
}, {
key: "_key",
value: function(r, a) {
return "".concat(r, "-").concat(a);
}
/** Marks textues associated with the element for garbage collection. */
}, {
key: "invalidate",
value: function(r) {
var a = this, n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, i = n.forceRedraw, s = i === void 0 ? !1 : i, o = n.filterEle, u = o === void 0 ? function() {
return !0;
} : o, l = n.filterType, f = l === void 0 ? function() {
return !0;
} : l, c = !1, v = !1, h = At(r), d;
try {
for (h.s(); !(d = h.n()).done; ) {
var p = d.value;
if (u(p)) {
var g = At(this.renderTypes.values()), y;
try {
var b = function() {
var E = y.value, T = E.type;
if (f(T)) {
var S = a.collections.get(E.collection), w = E.getKey(p), x = Array.isArray(w) ? w : [w];
if (s)
x.forEach(function(L) {
return S.markKeyForGC(L);
}), v = !0;
else {
var C = E.getID ? E.getID(p) : p.id(), D = a._key(T, C), A = a.typeAndIdToKey.get(D);
A !== void 0 && !bm(x, A) && (c = !0, a.typeAndIdToKey.delete(D), A.forEach(function(L) {
return S.markKeyForGC(L);
}));
}
}
};
for (g.s(); !(y = g.n()).done; )
b();
} catch (m) {
g.e(m);
} finally {
g.f();
}
}
}
} catch (m) {
h.e(m);
} finally {
h.f();
}
return v && (this.gc(), c = !1), c;
}
/** Garbage collect */
}, {
key: "gc",
value: function() {
var r = At(this.collections.values()), a;
try {
for (r.s(); !(a = r.n()).done; ) {
var n = a.value;
n.gc();
}
} catch (i) {
r.e(i);
} finally {
r.f();
}
}
}, {
key: "getOrCreateAtlas",
value: function(r, a, n, i) {
var s = this.renderTypes.get(a), o = this.collections.get(s.collection), u = !1, l = o.draw(i, n, function(v) {
s.drawClipped ? (v.save(), v.beginPath(), v.rect(0, 0, n.w, n.h), v.clip(), s.drawElement(v, r, n, !0, !0), v.restore()) : s.drawElement(v, r, n, !0, !0), u = !0;
});
if (u) {
var f = s.getID ? s.getID(r) : r.id(), c = this._key(a, f);
this.typeAndIdToKey.has(c) ? this.typeAndIdToKey.get(c).push(i) : this.typeAndIdToKey.set(c, [i]);
}
return l;
}
}, {
key: "getAtlasInfo",
value: function(r, a) {
var n = this, i = this.renderTypes.get(a), s = i.getKey(r), o = Array.isArray(s) ? s : [s];
return o.map(function(u) {
var l = i.getBoundingBox(r, u), f = n.getOrCreateAtlas(r, a, l, u), c = f.getOffsets(u), v = Je(c, 2), h = v[0], d = v[1];
return {
atlas: f,
tex: h,
tex1: h,
tex2: d,
bb: l
};
});
}
}, {
key: "getDebugInfo",
value: function() {
var r = [], a = At(this.collections), n;
try {
for (a.s(); !(n = a.n()).done; ) {
var i = Je(n.value, 2), s = i[0], o = i[1], u = o.getCounts(), l = u.keyCount, f = u.atlasCount;
r.push({
type: s,
keyCount: l,
atlasCount: f
});
}
} catch (c) {
a.e(c);
} finally {
a.f();
}
return r;
}
}]);
}(), Mm = /* @__PURE__ */ function() {
function t(e) {
yr(this, t), this.globalOptions = e, this.atlasSize = e.webglTexSize, this.maxAtlasesPerBatch = e.webglTexPerBatch, this.batchAtlases = [];
}
return mr(t, [{
key: "getMaxAtlasesPerBatch",
value: function() {
return this.maxAtlasesPerBatch;
}
}, {
key: "getAtlasSize",
value: function() {
return this.atlasSize;
}
}, {
key: "getIndexArray",
value: function() {
return Array.from({
length: this.maxAtlasesPerBatch
}, function(r, a) {
return a;
});
}
}, {
key: "startBatch",
value: function() {
this.batchAtlases = [];
}
}, {
key: "getAtlasCount",
value: function() {
return this.batchAtlases.length;
}
}, {
key: "getAtlases",
value: function() {
return this.batchAtlases;
}
}, {
key: "canAddToCurrentBatch",
value: function(r) {
return this.batchAtlases.length === this.maxAtlasesPerBatch ? this.batchAtlases.includes(r) : !0;
}
}, {
key: "getAtlasIndexForBatch",
value: function(r) {
var a = this.batchAtlases.indexOf(r);
if (a < 0) {
if (this.batchAtlases.length === this.maxAtlasesPerBatch)
throw new Error("cannot add more atlases to batch");
this.batchAtlases.push(r), a = this.batchAtlases.length - 1;
}
return a;
}
}]);
}(), Om = `
float circleSD(vec2 p, float r) {
return distance(vec2(0), p) - r; // signed distance
}
`, km = `
float rectangleSD(vec2 p, vec2 b) {
vec2 d = abs(p)-b;
return distance(vec2(0),max(d,0.0)) + min(max(d.x,d.y),0.0);
}
`, Nm = `
float roundRectangleSD(vec2 p, vec2 b, vec4 cr) {
cr.xy = (p.x > 0.0) ? cr.xy : cr.zw;
cr.x = (p.y > 0.0) ? cr.x : cr.y;
vec2 q = abs(p) - b + cr.x;
return min(max(q.x, q.y), 0.0) + distance(vec2(0), max(q, 0.0)) - cr.x;
}
`, Bm = `
float ellipseSD(vec2 p, vec2 ab) {
p = abs( p ); // symmetry
// find root with Newton solver
vec2 q = ab*(p-ab);
float w = (q.x<q.y)? 1.570796327 : 0.0;
for( int i=0; i<5; i++ ) {
vec2 cs = vec2(cos(w),sin(w));
vec2 u = ab*vec2( cs.x,cs.y);
vec2 v = ab*vec2(-cs.y,cs.x);
w = w + dot(p-u,v)/(dot(p-u,u)+dot(v,v));
}
// compute final point and distance
float d = length(p-ab*vec2(cos(w),sin(w)));
// return signed distance
return (dot(p/ab,p/ab)>1.0) ? d : -d;
}
`, Da = {
SCREEN: {
name: "screen",
screen: !0
},
PICKING: {
name: "picking",
picking: !0
}
}, Nn = {
// render the texture just like in RENDER_TARGET.SCREEN mode
IGNORE: 1,
// don't render the texture at all
USE_BB: 2
// render the bounding box as an opaque rectangle
}, Ls = 0, nf = 1, sf = 2, Rs = 3, Hr = 4, ln = 5, ma = 6, ba = 7, Fm = /* @__PURE__ */ function() {
function t(e, r, a) {
yr(this, t), this.r = e, this.gl = r, this.maxInstances = a.webglBatchSize, this.atlasSize = a.webglTexSize, this.bgColor = a.bgColor, this.debug = a.webglDebug, this.batchDebugInfo = [], a.enableWrapping = !0, a.createTextureCanvas = gm, this.atlasManager = new Pm(e, a), this.batchManager = new Mm(a), this.simpleShapeOptions = /* @__PURE__ */ new Map(), this.program = this._createShaderProgram(Da.SCREEN), this.pickingProgram = this._createShaderProgram(Da.PICKING), this.vao = this._createVAO();
}
return mr(t, [{
key: "addAtlasCollection",
value: function(r, a) {
this.atlasManager.addAtlasCollection(r, a);
}
/**
* @typedef { Object } TextureRenderTypeOpts
* @property { string } collection - name of atlas collection to render textures to
* @property { function } getKey - returns the "style key" for an element, may be a single value or an array for multi-line lables
* @property { function } drawElement - uses a canvas renderer to draw the element to the texture atlas
* @property { boolean } drawClipped - if true the context will be clipped to the bounding box before drawElement() is called, may affect performance
* @property { function } getBoundingBox - returns the bounding box for an element
* @property { function } getRotation
* @property { function } getRotationPoint
* @property { function } getRotationOffset
* @property { function } isVisible - an extra check for visibility in addition to ele.visible()
* @property { function } getTexPickingMode - returns a value from the TEX_PICKING_MODE enum
*/
/**
* @param { string } typeName
* @param { TextureRenderTypeOpts } opts
*/
}, {
key: "addTextureAtlasRenderType",
value: function(r, a) {
this.atlasManager.addRenderType(r, a);
}
/**
* @typedef { Object } SimpleShapeRenderTypeOpts
* @property { function } getBoundingBox - returns the bounding box for an element
* @property { function } isVisible - this is an extra check for visibility in addition to ele.visible()
* @property { function } isSimple - check if element is a simple shape, or if it needs to fall back to texture rendering
* @property { ShapeVisualProperties } shapeProps
*/
/**
* @typedef { Object } ShapeVisualProperties
* @property { string } shape
* @property { string } color
* @property { string } opacity
* @property { string } padding
* @property { string } radius
* @property { boolean } border
*/
/**
* @param { string } typeName
* @param { SimpleShapeRenderTypeOpts } opts
*/
}, {
key: "addSimpleShapeRenderType",
value: function(r, a) {
this.simpleShapeOptions.set(r, a);
}
/**
* Inform the atlasManager when element style keys may have changed.
* The atlasManager can then mark unused textures for "garbage collection".
*/
}, {
key: "invalidate",
value: function(r) {
var a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = a.type, i = this.atlasManager;
return n ? i.invalidate(r, {
filterType: function(o) {
return o === n;
},
forceRedraw: !0
}) : i.invalidate(r);
}
/**
* Run texture garbage collection.
*/
}, {
key: "gc",
value: function() {
this.atlasManager.gc();
}
}, {
key: "_createShaderProgram",
value: function(r) {
var a = this.gl, n = `#version 300 es
precision highp float;
uniform mat3 uPanZoomMatrix;
uniform int uAtlasSize;
// instanced
in vec2 aPosition; // a vertex from the unit square
in mat3 aTransform; // used to transform verticies, eg into a bounding box
in int aVertType; // the type of thing we are rendering
// the z-index that is output when using picking mode
in vec4 aIndex;
// For textures
in int aAtlasId; // which shader unit/atlas to use
in vec4 aTex; // x/y/w/h of texture in atlas
// for edges
in vec4 aPointAPointB;
in vec4 aPointCPointD;
in vec2 aLineWidth; // also used for node border width
// simple shapes
in vec4 aCornerRadius; // for round-rectangle [top-right, bottom-right, top-left, bottom-left]
in vec4 aColor; // also used for edges
in vec4 aBorderColor; // aLineWidth is used for border width
// output values passed to the fragment shader
out vec2 vTexCoord;
out vec4 vColor;
out vec2 vPosition;
// flat values are not interpolated
flat out int vAtlasId;
flat out int vVertType;
flat out vec2 vTopRight;
flat out vec2 vBotLeft;
flat out vec4 vCornerRadius;
flat out vec4 vBorderColor;
flat out vec2 vBorderWidth;
flat out vec4 vIndex;
void main(void) {
int vid = gl_VertexID;
vec2 position = aPosition; // TODO make this a vec3, simplifies some code below
if(aVertType == `.concat(Ls, `) {
float texX = aTex.x; // texture coordinates
float texY = aTex.y;
float texW = aTex.z;
float texH = aTex.w;
if(vid == 1 || vid == 2 || vid == 4) {
texX += texW;
}
if(vid == 2 || vid == 4 || vid == 5) {
texY += texH;
}
float d = float(uAtlasSize);
vTexCoord = vec2(texX / d, texY / d); // tex coords must be between 0 and 1
gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);
}
else if(aVertType == `).concat(Hr, " || aVertType == ").concat(ba, `
|| aVertType == `).concat(ln, " || aVertType == ").concat(ma, `) { // simple shapes
// the bounding box is needed by the fragment shader
vBotLeft = (aTransform * vec3(0, 0, 1)).xy; // flat
vTopRight = (aTransform * vec3(1, 1, 1)).xy; // flat
vPosition = (aTransform * vec3(position, 1)).xy; // will be interpolated
// calculations are done in the fragment shader, just pass these along
vColor = aColor;
vCornerRadius = aCornerRadius;
vBorderColor = aBorderColor;
vBorderWidth = aLineWidth;
gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);
}
else if(aVertType == `).concat(nf, `) {
vec2 source = aPointAPointB.xy;
vec2 target = aPointAPointB.zw;
// adjust the geometry so that the line is centered on the edge
position.y = position.y - 0.5;
// stretch the unit square into a long skinny rectangle
vec2 xBasis = target - source;
vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));
vec2 point = source + xBasis * position.x + yBasis * aLineWidth[0] * position.y;
gl_Position = vec4(uPanZoomMatrix * vec3(point, 1.0), 1.0);
vColor = aColor;
}
else if(aVertType == `).concat(sf, `) {
vec2 pointA = aPointAPointB.xy;
vec2 pointB = aPointAPointB.zw;
vec2 pointC = aPointCPointD.xy;
vec2 pointD = aPointCPointD.zw;
// adjust the geometry so that the line is centered on the edge
position.y = position.y - 0.5;
vec2 p0, p1, p2, pos;
if(position.x == 0.0) { // The left side of the unit square
p0 = pointA;
p1 = pointB;
p2 = pointC;
pos = position;
} else { // The right side of the unit square, use same approach but flip the geometry upside down
p0 = pointD;
p1 = pointC;
p2 = pointB;
pos = vec2(0.0, -position.y);
}
vec2 p01 = p1 - p0;
vec2 p12 = p2 - p1;
vec2 p21 = p1 - p2;
// Find the normal vector.
vec2 tangent = normalize(normalize(p12) + normalize(p01));
vec2 normal = vec2(-tangent.y, tangent.x);
// Find the vector perpendicular to p0 -> p1.
vec2 p01Norm = normalize(vec2(-p01.y, p01.x));
// Determine the bend direction.
float sigma = sign(dot(p01 + p21, normal));
float width = aLineWidth[0];
if(sign(pos.y) == -sigma) {
// This is an intersecting vertex. Adjust the position so that there's no overlap.
vec2 point = 0.5 * width * normal * -sigma / dot(normal, p01Norm);
gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);
} else {
// This is a non-intersecting vertex. Treat it like a mitre join.
vec2 point = 0.5 * width * normal * sigma * dot(normal, p01Norm);
gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);
}
vColor = aColor;
}
else if(aVertType == `).concat(Rs, ` && vid < 3) {
// massage the first triangle into an edge arrow
if(vid == 0)
position = vec2(-0.15, -0.3);
if(vid == 1)
position = vec2( 0.0, 0.0);
if(vid == 2)
position = vec2( 0.15, -0.3);
gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);
vColor = aColor;
}
else {
gl_Position = vec4(2.0, 0.0, 0.0, 1.0); // discard vertex by putting it outside webgl clip space
}
vAtlasId = aAtlasId;
vVertType = aVertType;
vIndex = aIndex;
}
`), i = this.batchManager.getIndexArray(), s = `#version 300 es
precision highp float;
// declare texture unit for each texture atlas in the batch
`.concat(i.map(function(l) {
return "uniform sampler2D uTexture".concat(l, ";");
}).join(`
`), `
uniform vec4 uBGColor;
uniform float uZoom;
in vec2 vTexCoord;
in vec4 vColor;
in vec2 vPosition; // model coordinates
flat in int vAtlasId;
flat in vec4 vIndex;
flat in int vVertType;
flat in vec2 vTopRight;
flat in vec2 vBotLeft;
flat in vec4 vCornerRadius;
flat in vec4 vBorderColor;
flat in vec2 vBorderWidth;
out vec4 outColor;
`).concat(Om, `
`).concat(km, `
`).concat(Nm, `
`).concat(Bm, `
vec4 blend(vec4 top, vec4 bot) { // blend colors with premultiplied alpha
return vec4(
top.rgb + (bot.rgb * (1.0 - top.a)),
top.a + (bot.a * (1.0 - top.a))
);
}
vec4 distInterp(vec4 cA, vec4 cB, float d) { // interpolate color using Signed Distance
// scale to the zoom level so that borders don't look blurry when zoomed in
// note 1.5 is an aribitrary value chosen because it looks good
return mix(cA, cB, 1.0 - smoothstep(0.0, 1.5 / uZoom, abs(d)));
}
void main(void) {
if(vVertType == `).concat(Ls, `) {
// look up the texel from the texture unit
`).concat(i.map(function(l) {
return "if(vAtlasId == ".concat(l, ") outColor = texture(uTexture").concat(l, ", vTexCoord);");
}).join(`
else `), `
}
else if(vVertType == `).concat(Rs, `) {
// mimics how canvas renderer uses context.globalCompositeOperation = 'destination-out';
outColor = blend(vColor, uBGColor);
outColor.a = 1.0; // make opaque, masks out line under arrow
}
else if(vVertType == `).concat(Hr, ` && vBorderWidth == vec2(0.0)) { // simple rectangle with no border
outColor = vColor; // unit square is already transformed to the rectangle, nothing else needs to be done
}
else if(vVertType == `).concat(Hr, " || vVertType == ").concat(ba, `
|| vVertType == `).concat(ln, " || vVertType == ").concat(ma, `) { // use SDF
float outerBorder = vBorderWidth[0];
float innerBorder = vBorderWidth[1];
float borderPadding = outerBorder * 2.0;
float w = vTopRight.x - vBotLeft.x - borderPadding;
float h = vTopRight.y - vBotLeft.y - borderPadding;
vec2 b = vec2(w/2.0, h/2.0); // half width, half height
vec2 p = vPosition - vec2(vTopRight.x - b[0] - outerBorder, vTopRight.y - b[1] - outerBorder); // translate to center
float d; // signed distance
if(vVertType == `).concat(Hr, `) {
d = rectangleSD(p, b);
} else if(vVertType == `).concat(ba, ` && w == h) {
d = circleSD(p, b.x); // faster than ellipse
} else if(vVertType == `).concat(ba, `) {
d = ellipseSD(p, b);
} else {
d = roundRectangleSD(p, b, vCornerRadius.wzyx);
}
// use the distance to interpolate a color to smooth the edges of the shape, doesn't need multisampling
// we must smooth colors inwards, because we can't change pixels outside the shape's bounding box
if(d > 0.0) {
if(d > outerBorder) {
discard;
} else {
outColor = distInterp(vBorderColor, vec4(0), d - outerBorder);
}
} else {
if(d > innerBorder) {
vec4 outerColor = outerBorder == 0.0 ? vec4(0) : vBorderColor;
vec4 innerBorderColor = blend(vBorderColor, vColor);
outColor = distInterp(innerBorderColor, outerColor, d);
}
else {
vec4 outerColor;
if(innerBorder == 0.0 && outerBorder == 0.0) {
outerColor = vec4(0);
} else if(innerBorder == 0.0) {
outerColor = vBorderColor;
} else {
outerColor = blend(vBorderColor, vColor);
}
outColor = distInterp(vColor, outerColor, d - innerBorder);
}
}
}
else {
outColor = vColor;
}
`).concat(r.picking ? `if(outColor.a == 0.0) discard;
else outColor = vIndex;` : "", `
}
`), o = dm(a, n, s);
o.aPosition = a.getAttribLocation(o, "aPosition"), o.aIndex = a.getAttribLocation(o, "aIndex"), o.aVertType = a.getAttribLocation(o, "aVertType"), o.aTransform = a.getAttribLocation(o, "aTransform"), o.aAtlasId = a.getAttribLocation(o, "aAtlasId"), o.aTex = a.getAttribLocation(o, "aTex"), o.aPointAPointB = a.getAttribLocation(o, "aPointAPointB"), o.aPointCPointD = a.getAttribLocation(o, "aPointCPointD"), o.aLineWidth = a.getAttribLocation(o, "aLineWidth"), o.aColor = a.getAttribLocation(o, "aColor"), o.aCornerRadius = a.getAttribLocation(o, "aCornerRadius"), o.aBorderColor = a.getAttribLocation(o, "aBorderColor"), o.uPanZoomMatrix = a.getUniformLocation(o, "uPanZoomMatrix"), o.uAtlasSize = a.getUniformLocation(o, "uAtlasSize"), o.uBGColor = a.getUniformLocation(o, "uBGColor"), o.uZoom = a.getUniformLocation(o, "uZoom"), o.uTextures = [];
for (var u = 0; u < this.batchManager.getMaxAtlasesPerBatch(); u++)
o.uTextures.push(a.getUniformLocation(o, "uTexture".concat(u)));
return o;
}
}, {
key: "_createVAO",
value: function() {
var r = [0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1];
this.vertexCount = r.length / 2;
var a = this.maxInstances, n = this.gl, i = this.program, s = n.createVertexArray();
return n.bindVertexArray(s), Tm(n, "vec2", i.aPosition, r), this.transformBuffer = Cm(n, a, i.aTransform), this.indexBuffer = zt(n, a, "vec4", i.aIndex), this.vertTypeBuffer = zt(n, a, "int", i.aVertType), this.atlasIdBuffer = zt(n, a, "int", i.aAtlasId), this.texBuffer = zt(n, a, "vec4", i.aTex), this.pointAPointBBuffer = zt(n, a, "vec4", i.aPointAPointB), this.pointCPointDBuffer = zt(n, a, "vec4", i.aPointCPointD), this.lineWidthBuffer = zt(n, a, "vec2", i.aLineWidth), this.colorBuffer = zt(n, a, "vec4", i.aColor), this.cornerRadiusBuffer = zt(n, a, "vec4", i.aCornerRadius), this.borderColorBuffer = zt(n, a, "vec4", i.aBorderColor), n.bindVertexArray(null), s;
}
}, {
key: "buffers",
get: function() {
var r = this;
return this._buffers || (this._buffers = Object.keys(this).filter(function(a) {
return ir(a, "Buffer");
}).map(function(a) {
return r[a];
})), this._buffers;
}
}, {
key: "startFrame",
value: function(r) {
var a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Da.SCREEN;
this.panZoomMatrix = r, this.renderTarget = a, this.batchDebugInfo = [], this.wrappedCount = 0, this.simpleCount = 0, this.startBatch();
}
}, {
key: "startBatch",
value: function() {
this.instanceCount = 0, this.batchManager.startBatch();
}
}, {
key: "endFrame",
value: function() {
this.endBatch();
}
}, {
key: "_isVisible",
value: function(r, a) {
return r.visible() ? a && a.isVisible ? a.isVisible(r) : !0 : !1;
}
/**
* Draws a texture using the texture atlas.
*/
}, {
key: "drawTexture",
value: function(r, a, n) {
var i = this.atlasManager, s = this.batchManager, o = i.getRenderTypeOpts(n);
if (this._isVisible(r, o) && !(r.isEdge() && !this._isValidEdge(r))) {
if (this.renderTarget.picking && o.getTexPickingMode) {
var u = o.getTexPickingMode(r);
if (u === Nn.IGNORE)
return;
if (u == Nn.USE_BB) {
this.drawPickingRectangle(r, a, n);
return;
}
}
var l = i.getAtlasInfo(r, n), f = At(l), c;
try {
for (f.s(); !(c = f.n()).done; ) {
var v = c.value, h = v.atlas, d = v.tex1, p = v.tex2;
s.canAddToCurrentBatch(h) || this.endBatch();
for (var g = s.getAtlasIndexForBatch(h), y = 0, b = [[d, !0], [p, !1]]; y < b.length; y++) {
var m = Je(b[y], 2), E = m[0], T = m[1];
if (E.w != 0) {
var S = this.instanceCount;
this.vertTypeBuffer.getView(S)[0] = Ls;
var w = this.indexBuffer.getView(S);
Yr(a, w);
var x = this.atlasIdBuffer.getView(S);
x[0] = g;
var C = this.texBuffer.getView(S);
C[0] = E.x, C[1] = E.y, C[2] = E.w, C[3] = E.h;
var D = this.transformBuffer.getMatrixView(S);
this.setTransformMatrix(r, D, o, v, T), this.instanceCount++, T || this.wrappedCount++, this.instanceCount >= this.maxInstances && this.endBatch();
}
}
}
} catch (A) {
f.e(A);
} finally {
f.f();
}
}
}
/**
* matrix is expected to be a 9 element array
* this function follows same pattern as CRp.drawCachedElementPortion(...)
*/
}, {
key: "setTransformMatrix",
value: function(r, a, n, i) {
var s = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, o = 0;
if (n.shapeProps && n.shapeProps.padding && (o = r.pstyle(n.shapeProps.padding).pfValue), i) {
var u = i.bb, l = i.tex1, f = i.tex2, c = l.w / (l.w + f.w);
s || (c = 1 - c);
var v = this._getAdjustedBB(u, o, s, c);
this._applyTransformMatrix(a, v, n, r);
} else {
var h = n.getBoundingBox(r), d = this._getAdjustedBB(h, o, !0, 1);
this._applyTransformMatrix(a, d, n, r);
}
}
}, {
key: "_applyTransformMatrix",
value: function(r, a, n, i) {
var s, o;
rf(r);
var u = n.getRotation ? n.getRotation(i) : 0;
if (u !== 0) {
var l = n.getRotationPoint(i), f = l.x, c = l.y;
wn(r, r, [f, c]), af(r, r, u);
var v = n.getRotationOffset(i);
s = v.x + (a.xOffset || 0), o = v.y + (a.yOffset || 0);
} else
s = a.x1, o = a.y1;
wn(r, r, [s, o]), Qs(r, r, [a.w, a.h]);
}
/**
* Adjusts a node or label BB to accomodate padding and split for wrapped textures.
* @param bb - the original bounding box
* @param padding - the padding to add to the bounding box
* @param first - whether this is the first part of a wrapped texture
* @param ratio - the ratio of the texture width of part of the text to the entire texture
*/
}, {
key: "_getAdjustedBB",
value: function(r, a, n, i) {
var s = r.x1, o = r.y1, u = r.w, l = r.h, f = r.yOffset;
a && (s -= a, o -= a, u += 2 * a, l += 2 * a);
var c = 0, v = u * i;
return n && i < 1 ? u = v : !n && i < 1 && (c = u - v, s += c, u = v), {
x1: s,
y1: o,
w: u,
h: l,
xOffset: c,
yOffset: f
};
}
/**
* Draw a solid opaque rectangle matching the element's Bounding Box.
* Used by the PICKING mode to make the entire BB of a label clickable.
*/
}, {
key: "drawPickingRectangle",
value: function(r, a, n) {
var i = this.atlasManager.getRenderTypeOpts(n), s = this.instanceCount;
this.vertTypeBuffer.getView(s)[0] = Hr;
var o = this.indexBuffer.getView(s);
Yr(a, o);
var u = this.colorBuffer.getView(s);
Cr([0, 0, 0], 1, u);
var l = this.transformBuffer.getMatrixView(s);
this.setTransformMatrix(r, l, i), this.simpleCount++, this.instanceCount++, this.instanceCount >= this.maxInstances && this.endBatch();
}
/**
* Draw a node using either a texture or a "simple shape".
*/
}, {
key: "drawNode",
value: function(r, a, n) {
var i = this.simpleShapeOptions.get(n);
if (this._isVisible(r, i)) {
var s = i.shapeProps, o = this._getVertTypeForShape(r, s.shape);
if (o === void 0 || i.isSimple && !i.isSimple(r)) {
this.drawTexture(r, a, n);
return;
}
var u = this.instanceCount;
if (this.vertTypeBuffer.getView(u)[0] = o, o === ln || o === ma) {
var l = i.getBoundingBox(r), f = this._getCornerRadius(r, s.radius, l), c = this.cornerRadiusBuffer.getView(u);
c[0] = f, c[1] = f, c[2] = f, c[3] = f, o === ma && (c[0] = 0, c[2] = 0);
}
var v = this.indexBuffer.getView(u);
Yr(a, v);
var h = r.pstyle(s.color).value, d = r.pstyle(s.opacity).value, p = this.colorBuffer.getView(u);
Cr(h, d, p);
var g = this.lineWidthBuffer.getView(u);
if (g[0] = 0, g[1] = 0, s.border) {
var y = r.pstyle("border-width").value;
if (y > 0) {
var b = r.pstyle("border-color").value, m = r.pstyle("border-opacity").value, E = this.borderColorBuffer.getView(u);
Cr(b, m, E);
var T = r.pstyle("border-position").value;
if (T === "inside")
g[0] = 0, g[1] = -y;
else if (T === "outside")
g[0] = y, g[1] = 0;
else {
var S = y / 2;
g[0] = S, g[1] = -S;
}
}
}
var w = this.transformBuffer.getMatrixView(u);
this.setTransformMatrix(r, w, i), this.simpleCount++, this.instanceCount++, this.instanceCount >= this.maxInstances && this.endBatch();
}
}
}, {
key: "_getVertTypeForShape",
value: function(r, a) {
var n = r.pstyle(a).value;
switch (n) {
case "rectangle":
return Hr;
case "ellipse":
return ba;
case "roundrectangle":
case "round-rectangle":
return ln;
case "bottom-round-rectangle":
return ma;
default:
return;
}
}
}, {
key: "_getCornerRadius",
value: function(r, a, n) {
var i = n.w, s = n.h;
if (r.pstyle(a).value === "auto")
return vr(i, s);
var o = r.pstyle(a).pfValue, u = i / 2, l = s / 2;
return Math.min(o, l, u);
}
/**
* Only supports drawing triangles at the moment.
*/
}, {
key: "drawEdgeArrow",
value: function(r, a, n) {
if (r.visible()) {
var i = r._private.rscratch, s, o, u;
if (n === "source" ? (s = i.arrowStartX, o = i.arrowStartY, u = i.srcArrowAngle) : (s = i.arrowEndX, o = i.arrowEndY, u = i.tgtArrowAngle), !(isNaN(s) || s == null || isNaN(o) || o == null || isNaN(u) || u == null)) {
var l = r.pstyle(n + "-arrow-shape").value;
if (l !== "none") {
var f = r.pstyle(n + "-arrow-color").value, c = r.pstyle("opacity").value, v = r.pstyle("line-opacity").value, h = c * v, d = r.pstyle("width").pfValue, p = r.pstyle("arrow-scale").value, g = this.r.getArrowWidth(d, p), y = this.instanceCount, b = this.transformBuffer.getMatrixView(y);
rf(b), wn(b, b, [s, o]), Qs(b, b, [g, g]), af(b, b, u), this.vertTypeBuffer.getView(y)[0] = Rs;
var m = this.indexBuffer.getView(y);
Yr(a, m);
var E = this.colorBuffer.getView(y);
Cr(f, h, E), this.instanceCount++, this.instanceCount >= this.maxInstances && this.endBatch();
}
}
}
}
/**
* Draw straight-line or bezier curve edges.
*/
}, {
key: "drawEdgeLine",
value: function(r, a) {
if (r.visible()) {
var n = this._getEdgePoints(r);
if (n) {
var i = r.pstyle("opacity").value, s = r.pstyle("line-opacity").value, o = r.pstyle("width").pfValue, u = r.pstyle("line-color").value, l = i * s;
if (n.length / 2 + this.instanceCount > this.maxInstances && this.endBatch(), n.length == 4) {
var f = this.instanceCount;
this.vertTypeBuffer.getView(f)[0] = nf;
var c = this.indexBuffer.getView(f);
Yr(a, c);
var v = this.colorBuffer.getView(f);
Cr(u, l, v);
var h = this.lineWidthBuffer.getView(f);
h[0] = o;
var d = this.pointAPointBBuffer.getView(f);
d[0] = n[0], d[1] = n[1], d[2] = n[2], d[3] = n[3], this.instanceCount++, this.instanceCount >= this.maxInstances && this.endBatch();
} else
for (var p = 0; p < n.length - 2; p += 2) {
var g = this.instanceCount;
this.vertTypeBuffer.getView(g)[0] = sf;
var y = this.indexBuffer.getView(g);
Yr(a, y);
var b = this.colorBuffer.getView(g);
Cr(u, l, b);
var m = this.lineWidthBuffer.getView(g);
m[0] = o;
var E = n[p - 2], T = n[p - 1], S = n[p], w = n[p + 1], x = n[p + 2], C = n[p + 3], D = n[p + 4], A = n[p + 5];
p == 0 && (E = 2 * S - x + 1e-3, T = 2 * w - C + 1e-3), p == n.length - 4 && (D = 2 * x - S + 1e-3, A = 2 * C - w + 1e-3);
var L = this.pointAPointBBuffer.getView(g);
L[0] = E, L[1] = T, L[2] = S, L[3] = w;
var R = this.pointCPointDBuffer.getView(g);
R[0] = x, R[1] = C, R[2] = D, R[3] = A, this.instanceCount++, this.instanceCount >= this.maxInstances && this.endBatch();
}
}
}
}
}, {
key: "_isValidEdge",
value: function(r) {
var a = r._private.rscratch;
return !(a.badLine || a.allpts == null || isNaN(a.allpts[0]));
}
}, {
key: "_getEdgePoints",
value: function(r) {
var a = r._private.rscratch;
if (this._isValidEdge(r)) {
var n = a.allpts;
if (n.length == 4)
return n;
var i = this._getNumSegments(r);
return this._getCurveSegmentPoints(n, i);
}
}
}, {
key: "_getNumSegments",
value: function(r) {
var a = 15;
return Math.min(Math.max(a, 5), this.maxInstances);
}
}, {
key: "_getCurveSegmentPoints",
value: function(r, a) {
if (r.length == 4)
return r;
for (var n = Array((a + 1) * 2), i = 0; i <= a; i++)
if (i == 0)
n[0] = r[0], n[1] = r[1];
else if (i == a)
n[i * 2] = r[r.length - 2], n[i * 2 + 1] = r[r.length - 1];
else {
var s = i / a;
this._setCurvePoint(r, s, n, i * 2);
}
return n;
}
}, {
key: "_setCurvePoint",
value: function(r, a, n, i) {
if (r.length <= 2)
n[i] = r[0], n[i + 1] = r[1];
else {
for (var s = Array(r.length - 2), o = 0; o < s.length; o += 2) {
var u = (1 - a) * r[o] + a * r[o + 2], l = (1 - a) * r[o + 1] + a * r[o + 3];
s[o] = u, s[o + 1] = l;
}
return this._setCurvePoint(s, a, n, i);
}
}
}, {
key: "endBatch",
value: function() {
var r = this.gl, a = this.vao, n = this.vertexCount, i = this.instanceCount;
if (i !== 0) {
var s = this.renderTarget.picking ? this.pickingProgram : this.program;
r.useProgram(s), r.bindVertexArray(a);
var o = At(this.buffers), u;
try {
for (o.s(); !(u = o.n()).done; ) {
var l = u.value;
l.bufferSubData(i);
}
} catch (d) {
o.e(d);
} finally {
o.f();
}
for (var f = this.batchManager.getAtlases(), c = 0; c < f.length; c++)
f[c].bufferIfNeeded(r);
for (var v = 0; v < f.length; v++)
r.activeTexture(r.TEXTURE0 + v), r.bindTexture(r.TEXTURE_2D, f[v].texture), r.uniform1i(s.uTextures[v], v);
r.uniform1f(s.uZoom, pm(this.r)), r.uniformMatrix3fv(s.uPanZoomMatrix, !1, this.panZoomMatrix), r.uniform1i(s.uAtlasSize, this.batchManager.getAtlasSize());
var h = Cr(this.bgColor, 1);
r.uniform4fv(s.uBGColor, h), r.drawArraysInstanced(r.TRIANGLES, 0, n, i), r.bindVertexArray(null), r.bindTexture(r.TEXTURE_2D, null), this.debug && this.batchDebugInfo.push({
count: i,
// instance count
atlasCount: f.length
}), this.startBatch();
}
}
}, {
key: "getDebugInfo",
value: function() {
var r = this.atlasManager.getDebugInfo(), a = r.reduce(function(s, o) {
return s + o.atlasCount;
}, 0), n = this.batchDebugInfo, i = n.reduce(function(s, o) {
return s + o.count;
}, 0);
return {
atlasInfo: r,
totalAtlases: a,
wrappedCount: this.wrappedCount,
simpleCount: this.simpleCount,
batchCount: n.length,
batchInfo: n,
totalInstances: i
};
}
}]);
}(), Hc = {};
Hc.initWebgl = function(t, e) {
var r = this, a = r.data.contexts[r.WEBGL];
t.bgColor = _m(r), t.webglTexSize = Math.min(t.webglTexSize, a.getParameter(a.MAX_TEXTURE_SIZE)), t.webglTexRows = Math.min(t.webglTexRows, 54), t.webglTexRowsNodes = Math.min(t.webglTexRowsNodes, 54), t.webglBatchSize = Math.min(t.webglBatchSize, 16384), t.webglTexPerBatch = Math.min(t.webglTexPerBatch, a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS)), r.webglDebug = t.webglDebug, r.webglDebugShowAtlases = t.webglDebugShowAtlases, r.pickingFrameBuffer = Dm(a), r.pickingFrameBuffer.needsDraw = !0, r.drawing = new Fm(r, a, t);
var n = function(c) {
return function(v) {
return r.getTextAngle(v, c);
};
}, i = function(c) {
return function(v) {
var h = v.pstyle(c);
return h && h.value;
};
}, s = function(c) {
return function(v) {
return v.pstyle("".concat(c, "-opacity")).value > 0;
};
}, o = function(c) {
var v = c.pstyle("text-events").strValue === "yes";
return v ? Nn.USE_BB : Nn.IGNORE;
}, u = function(c) {
var v = c.position(), h = v.x, d = v.y, p = c.outerWidth(), g = c.outerHeight();
return {
w: p,
h: g,
x1: h - p / 2,
y1: d - g / 2
};
};
r.drawing.addAtlasCollection("node", {
texRows: t.webglTexRowsNodes
}), r.drawing.addAtlasCollection("label", {
texRows: t.webglTexRows
}), r.drawing.addTextureAtlasRenderType("node-body", {
collection: "node",
getKey: e.getStyleKey,
getBoundingBox: e.getElementBox,
drawElement: e.drawElement
}), r.drawing.addSimpleShapeRenderType("node-body", {
getBoundingBox: u,
isSimple: mm,
shapeProps: {
shape: "shape",
color: "background-color",
opacity: "background-opacity",
radius: "corner-radius",
border: !0
}
}), r.drawing.addSimpleShapeRenderType("node-overlay", {
getBoundingBox: u,
isVisible: s("overlay"),
shapeProps: {
shape: "overlay-shape",
color: "overlay-color",
opacity: "overlay-opacity",
padding: "overlay-padding",
radius: "overlay-corner-radius"
}
}), r.drawing.addSimpleShapeRenderType("node-underlay", {
getBoundingBox: u,
isVisible: s("underlay"),
shapeProps: {
shape: "underlay-shape",
color: "underlay-color",
opacity: "underlay-opacity",
padding: "underlay-padding",
radius: "underlay-corner-radius"
}
}), r.drawing.addTextureAtlasRenderType("label", {
// node label or edge mid label
collection: "label",
getTexPickingMode: o,
getKey: Is(e.getLabelKey, null),
getBoundingBox: Ps(e.getLabelBox, null),
drawClipped: !0,
drawElement: e.drawLabel,
getRotation: n(null),
getRotationPoint: e.getLabelRotationPoint,
getRotationOffset: e.getLabelRotationOffset,
isVisible: i("label")
}), r.drawing.addTextureAtlasRenderType("edge-source-label", {
collection: "label",
getTexPickingMode: o,
getKey: Is(e.getSourceLabelKey, "source"),
getBoundingBox: Ps(e.getSourceLabelBox, "source"),
drawClipped: !0,
drawElement: e.drawSourceLabel,
getRotation: n("source"),
getRotationPoint: e.getSourceLabelRotationPoint,
getRotationOffset: e.getSourceLabelRotationOffset,
isVisible: i("source-label")
}), r.drawing.addTextureAtlasRenderType("edge-target-label", {
collection: "label",
getTexPickingMode: o,
getKey: Is(e.getTargetLabelKey, "target"),
getBoundingBox: Ps(e.getTargetLabelBox, "target"),
drawClipped: !0,
drawElement: e.drawTargetLabel,
getRotation: n("target"),
getRotationPoint: e.getTargetLabelRotationPoint,
getRotationOffset: e.getTargetLabelRotationOffset,
isVisible: i("target-label")
});
var l = Va(function() {
console.log("garbage collect flag set"), r.data.gc = !0;
}, 1e4);
r.onUpdateEleCalcs(function(f, c) {
var v = !1;
c && c.length > 0 && (v |= r.drawing.invalidate(c)), v && l();
}), Gm(r);
};
function _m(t) {
var e = t.cy.container(), r = e && e.style && e.style.backgroundColor || "white";
return bf(r);
}
function Xc(t, e) {
var r = t._private.rscratch;
return Dt(r, "labelWrapCachedLines", e) || [];
}
var Is = function(e, r) {
return function(a) {
var n = e(a), i = Xc(a, r);
return i.length > 1 ? i.map(function(s, o) {
return "".concat(n, "_").concat(o);
}) : n;
};
}, Ps = function(e, r) {
return function(a, n) {
var i = e(a);
if (typeof n == "string") {
var s = n.indexOf("_");
if (s > 0) {
var o = Number(n.substring(s + 1)), u = Xc(a, r), l = i.h / u.length, f = l * o, c = i.y1 + f;
return {
x1: i.x1,
w: i.w,
y1: c,
h: l,
yOffset: f
};
}
}
return i;
};
};
function Gm(t) {
{
var e = t.render;
t.render = function(i) {
i = i || {};
var s = t.cy;
t.webgl && (s.zoom() > _c ? (zm(t), e.call(t, i)) : (Vm(t), Wc(t, i, Da.SCREEN)));
};
}
{
var r = t.matchCanvasSize;
t.matchCanvasSize = function(i) {
r.call(t, i), t.pickingFrameBuffer.setFramebufferAttachmentSizes(t.canvasWidth, t.canvasHeight), t.pickingFrameBuffer.needsDraw = !0;
};
}
t.findNearestElements = function(i, s, o, u) {
return $m(t, i, s);
};
{
var a = t.invalidateCachedZSortedEles;
t.invalidateCachedZSortedEles = function() {
a.call(t), t.pickingFrameBuffer.needsDraw = !0;
};
}
{
var n = t.notify;
t.notify = function(i, s) {
n.call(t, i, s), i === "viewport" || i === "bounds" ? t.pickingFrameBuffer.needsDraw = !0 : i === "background" && t.drawing.invalidate(s, {
type: "node-body"
});
};
}
}
function zm(t) {
var e = t.data.contexts[t.WEBGL];
e.clear(e.COLOR_BUFFER_BIT | e.DEPTH_BUFFER_BIT);
}
function Vm(t) {
var e = function(a) {
a.save(), a.setTransform(1, 0, 0, 1, 0, 0), a.clearRect(0, 0, t.canvasWidth, t.canvasHeight), a.restore();
};
e(t.data.contexts[t.NODE]), e(t.data.contexts[t.DRAG]);
}
function Um(t) {
var e = t.canvasWidth, r = t.canvasHeight, a = Ro(t), n = a.pan, i = a.zoom, s = As();
wn(s, s, [n.x, n.y]), Qs(s, s, [i, i]);
var o = As();
Am(o, e, r);
var u = As();
return Sm(u, o, s), u;
}
function $c(t, e) {
var r = t.canvasWidth, a = t.canvasHeight, n = Ro(t), i = n.pan, s = n.zoom;
e.setTransform(1, 0, 0, 1, 0, 0), e.clearRect(0, 0, r, a), e.translate(i.x, i.y), e.scale(s, s);
}
function qm(t, e) {
t.drawSelectionRectangle(e, function(r) {
return $c(t, r);
});
}
function Ym(t) {
var e = t.data.contexts[t.NODE];
e.save(), $c(t, e), e.strokeStyle = "rgba(0, 0, 0, 0.3)", e.beginPath(), e.moveTo(-1e3, 0), e.lineTo(1e3, 0), e.stroke(), e.beginPath(), e.moveTo(0, -1e3), e.lineTo(0, 1e3), e.stroke(), e.restore();
}
function Hm(t) {
var e = function(n, i, s) {
for (var o = n.atlasManager.getAtlasCollection(i), u = t.data.contexts[t.NODE], l = o.atlases, f = 0; f < l.length; f++) {
var c = l[f], v = c.canvas;
if (v) {
var h = v.width, d = v.height, p = h * f, g = v.height * s, y = 0.4;
u.save(), u.scale(y, y), u.drawImage(v, p, g), u.strokeStyle = "black", u.rect(p, g, h, d), u.stroke(), u.restore();
}
}
}, r = 0;
e(t.drawing, "node", r++), e(t.drawing, "label", r++);
}
function Xm(t, e, r, a, n) {
var i, s, o, u, l = Ro(t), f = l.pan, c = l.zoom;
{
var v = ym(t, f, c, e, r), h = Je(v, 2), d = h[0], p = h[1], g = 6;
i = d - g / 2, s = p - g / 2, o = g, u = g;
}
if (o === 0 || u === 0)
return [];
var y = t.data.contexts[t.WEBGL];
y.bindFramebuffer(y.FRAMEBUFFER, t.pickingFrameBuffer), t.pickingFrameBuffer.needsDraw && (y.viewport(0, 0, y.canvas.width, y.canvas.height), Wc(t, null, Da.PICKING), t.pickingFrameBuffer.needsDraw = !1);
var b = o * u, m = new Uint8Array(b * 4);
y.readPixels(i, s, o, u, y.RGBA, y.UNSIGNED_BYTE, m), y.bindFramebuffer(y.FRAMEBUFFER, null);
for (var E = /* @__PURE__ */ new Set(), T = 0; T < b; T++) {
var S = m.slice(T * 4, T * 4 + 4), w = wm(S) - 1;
w >= 0 && E.add(w);
}
return E;
}
function $m(t, e, r) {
var a = Xm(t, e, r), n = t.getCachedZSortedEles(), i, s, o = At(a), u;
try {
for (o.s(); !(u = o.n()).done; ) {
var l = u.value, f = n[l];
if (!i && f.isNode() && (i = f), !s && f.isEdge() && (s = f), i && s)
break;
}
} catch (c) {
o.e(c);
} finally {
o.f();
}
return [i, s].filter(Boolean);
}
function Ms(t, e, r) {
var a = t.drawing;
e += 1, r.isNode() ? (a.drawNode(r, e, "node-underlay"), a.drawNode(r, e, "node-body"), a.drawTexture(r, e, "label"), a.drawNode(r, e, "node-overlay")) : (a.drawEdgeLine(r, e), a.drawEdgeArrow(r, e, "source"), a.drawEdgeArrow(r, e, "target"), a.drawTexture(r, e, "label"), a.drawTexture(r, e, "edge-source-label"), a.drawTexture(r, e, "edge-target-label"));
}
function Wc(t, e, r) {
var a;
t.webglDebug && (a = performance.now());
var n = t.drawing, i = 0;
if (r.screen && t.data.canvasNeedsRedraw[t.SELECT_BOX] && qm(t, e), t.data.canvasNeedsRedraw[t.NODE] || r.picking) {
var s = t.data.contexts[t.WEBGL];
r.screen ? (s.clearColor(0, 0, 0, 0), s.enable(s.BLEND), s.blendFunc(s.ONE, s.ONE_MINUS_SRC_ALPHA)) : s.disable(s.BLEND), s.clear(s.COLOR_BUFFER_BIT | s.DEPTH_BUFFER_BIT), s.viewport(0, 0, s.canvas.width, s.canvas.height);
var o = Um(t), u = t.getCachedZSortedEles();
if (i = u.length, n.startFrame(o, r), r.screen) {
for (var l = 0; l < u.nondrag.length; l++)
Ms(t, l, u.nondrag[l]);
for (var f = 0; f < u.drag.length; f++)
Ms(t, f, u.drag[f]);
} else if (r.picking)
for (var c = 0; c < u.length; c++)
Ms(t, c, u[c]);
n.endFrame(), r.screen && t.webglDebugShowAtlases && (Ym(t), Hm(t)), t.data.canvasNeedsRedraw[t.NODE] = !1, t.data.canvasNeedsRedraw[t.DRAG] = !1;
}
if (t.webglDebug) {
var v = performance.now(), h = !1, d = Math.ceil(v - a), p = n.getDebugInfo(), g = ["".concat(i, " elements"), "".concat(p.totalInstances, " instances"), "".concat(p.batchCount, " batches"), "".concat(p.totalAtlases, " atlases"), "".concat(p.wrappedCount, " wrapped textures"), "".concat(p.simpleCount, " simple shapes")].join(", ");
if (h)
console.log("WebGL (".concat(r.name, ") - time ").concat(d, "ms, ").concat(g));
else {
console.log("WebGL (".concat(r.name, ") - frame time ").concat(d, "ms")), console.log("Totals:"), console.log(" ".concat(g)), console.log("Texture Atlases Used:");
var y = p.atlasInfo, b = At(y), m;
try {
for (b.s(); !(m = b.n()).done; ) {
var E = m.value;
console.log(" ".concat(E.type, ": ").concat(E.keyCount, " keys, ").concat(E.atlasCount, " atlases"));
}
} catch (T) {
b.e(T);
} finally {
b.f();
}
console.log("");
}
}
t.data.gc && (console.log("Garbage Collect!"), t.data.gc = !1, n.gc());
}
var Er = {};
Er.drawPolygonPath = function(t, e, r, a, n, i) {
var s = a / 2, o = n / 2;
t.beginPath && t.beginPath(), t.moveTo(e + s * i[0], r + o * i[1]);
for (var u = 1; u < i.length / 2; u++)
t.lineTo(e + s * i[u * 2], r + o * i[u * 2 + 1]);
t.closePath();
};
Er.drawRoundPolygonPath = function(t, e, r, a, n, i, s) {
s.forEach(function(o) {
return Rc(t, o);
}), t.closePath();
};
Er.drawRoundRectanglePath = function(t, e, r, a, n, i) {
var s = a / 2, o = n / 2, u = i === "auto" ? vr(a, n) : Math.min(i, o, s);
t.beginPath && t.beginPath(), t.moveTo(e, r - o), t.arcTo(e + s, r - o, e + s, r, u), t.arcTo(e + s, r + o, e, r + o, u), t.arcTo(e - s, r + o, e - s, r, u), t.arcTo(e - s, r - o, e, r - o, u), t.lineTo(e, r - o), t.closePath();
};
Er.drawBottomRoundRectanglePath = function(t, e, r, a, n, i) {
var s = a / 2, o = n / 2, u = i === "auto" ? vr(a, n) : i;
t.beginPath && t.beginPath(), t.moveTo(e, r - o), t.lineTo(e + s, r - o), t.lineTo(e + s, r), t.arcTo(e + s, r + o, e, r + o, u), t.arcTo(e - s, r + o, e - s, r, u), t.lineTo(e - s, r - o), t.lineTo(e, r - o), t.closePath();
};
Er.drawCutRectanglePath = function(t, e, r, a, n, i, s) {
var o = a / 2, u = n / 2, l = s === "auto" ? go() : s;
t.beginPath && t.beginPath(), t.moveTo(e - o + l, r - u), t.lineTo(e + o - l, r - u), t.lineTo(e + o, r - u + l), t.lineTo(e + o, r + u - l), t.lineTo(e + o - l, r + u), t.lineTo(e - o + l, r + u), t.lineTo(e - o, r + u - l), t.lineTo(e - o, r - u + l), t.closePath();
};
Er.drawBarrelPath = function(t, e, r, a, n) {
var i = a / 2, s = n / 2, o = e - i, u = e + i, l = r - s, f = r + s, c = Fs(a, n), v = c.widthOffset, h = c.heightOffset, d = c.ctrlPtOffsetPct * v;
t.beginPath && t.beginPath(), t.moveTo(o, l + h), t.lineTo(o, f - h), t.quadraticCurveTo(o + d, f, o + v, f), t.lineTo(u - v, f), t.quadraticCurveTo(u - d, f, u, f - h), t.lineTo(u, l + h), t.quadraticCurveTo(u - d, l, u - v, l), t.lineTo(o + v, l), t.quadraticCurveTo(o + d, l, o, l + h), t.closePath();
};
var of = Math.sin(0), uf = Math.cos(0), Js = {}, js = {}, Kc = Math.PI / 40;
for (var Xr = 0 * Math.PI; Xr < 2 * Math.PI; Xr += Kc)
Js[Xr] = Math.sin(Xr), js[Xr] = Math.cos(Xr);
Er.drawEllipsePath = function(t, e, r, a, n) {
if (t.beginPath && t.beginPath(), t.ellipse)
t.ellipse(e, r, a / 2, n / 2, 0, 0, 2 * Math.PI);
else
for (var i, s, o = a / 2, u = n / 2, l = 0 * Math.PI; l < 2 * Math.PI; l += Kc)
i = e - o * Js[l] * of + o * js[l] * uf, s = r + u * js[l] * of + u * Js[l] * uf, l === 0 ? t.moveTo(i, s) : t.lineTo(i, s);
t.closePath();
};
var $a = {};
$a.createBuffer = function(t, e) {
var r = document.createElement("canvas");
return r.width = t, r.height = e, [r, r.getContext("2d")];
};
$a.bufferCanvasImage = function(t) {
var e = this.cy, r = e.mutableElements(), a = r.boundingBox(), n = this.findContainerClientCoords(), i = t.full ? Math.ceil(a.w) : n[2], s = t.full ? Math.ceil(a.h) : n[3], o = ne(t.maxWidth) || ne(t.maxHeight), u = this.getPixelRatio(), l = 1;
if (t.scale !== void 0)
i *= t.scale, s *= t.scale, l = t.scale;
else if (o) {
var f = 1 / 0, c = 1 / 0;
ne(t.maxWidth) && (f = l * t.maxWidth / i), ne(t.maxHeight) && (c = l * t.maxHeight / s), l = Math.min(f, c), i *= l, s *= l;
}
o || (i *= u, s *= u, l *= u);
var v = document.createElement("canvas");
v.width = i, v.height = s, v.style.width = i + "px", v.style.height = s + "px";
var h = v.getContext("2d");
if (i > 0 && s > 0) {
h.clearRect(0, 0, i, s), h.globalCompositeOperation = "source-over";
var d = this.getCachedZSortedEles();
if (t.full)
h.translate(-a.x1 * l, -a.y1 * l), h.scale(l, l), this.drawElements(h, d), h.scale(1 / l, 1 / l), h.translate(a.x1 * l, a.y1 * l);
else {
var p = e.pan(), g = {
x: p.x * l,
y: p.y * l
};
l *= e.zoom(), h.translate(g.x, g.y), h.scale(l, l), this.drawElements(h, d), h.scale(1 / l, 1 / l), h.translate(-g.x, -g.y);
}
t.bg && (h.globalCompositeOperation = "destination-over", h.fillStyle = t.bg, h.rect(0, 0, i, s), h.fill());
}
return v;
};
function Wm(t, e) {
for (var r = atob(t), a = new ArrayBuffer(r.length), n = new Uint8Array(a), i = 0; i < r.length; i++)
n[i] = r.charCodeAt(i);
return new Blob([a], {
type: e
});
}
function lf(t) {
var e = t.indexOf(",");
return t.substr(e + 1);
}
function Zc(t, e, r) {
var a = function() {
return e.toDataURL(r, t.quality);
};
switch (t.output) {
case "blob-promise":
return new ia(function(n, i) {
try {
e.toBlob(function(s) {
s != null ? n(s) : i(new Error("`canvas.toBlob()` sent a null value in its callback"));
}, r, t.quality);
} catch (s) {
i(s);
}
});
case "blob":
return Wm(lf(a()), r);
case "base64":
return lf(a());
case "base64uri":
default:
return a();
}
}
$a.png = function(t) {
return Zc(t, this.bufferCanvasImage(t), "image/png");
};
$a.jpg = function(t) {
return Zc(t, this.bufferCanvasImage(t), "image/jpeg");
};
var Qc = {};
Qc.nodeShapeImpl = function(t, e, r, a, n, i, s, o) {
switch (t) {
case "ellipse":
return this.drawEllipsePath(e, r, a, n, i);
case "polygon":
return this.drawPolygonPath(e, r, a, n, i, s);
case "round-polygon":
return this.drawRoundPolygonPath(e, r, a, n, i, s, o);
case "roundrectangle":
case "round-rectangle":
return this.drawRoundRectanglePath(e, r, a, n, i, o);
case "cutrectangle":
case "cut-rectangle":
return this.drawCutRectanglePath(e, r, a, n, i, s, o);
case "bottomroundrectangle":
case "bottom-round-rectangle":
return this.drawBottomRoundRectanglePath(e, r, a, n, i, o);
case "barrel":
return this.drawBarrelPath(e, r, a, n, i);
}
};
var Km = Jc, Se = Jc.prototype;
Se.CANVAS_LAYERS = 3;
Se.SELECT_BOX = 0;
Se.DRAG = 1;
Se.NODE = 2;
Se.WEBGL = 3;
Se.CANVAS_TYPES = ["2d", "2d", "2d", "webgl2"];
Se.BUFFER_COUNT = 3;
Se.TEXTURE_BUFFER = 0;
Se.MOTIONBLUR_BUFFER_NODE = 1;
Se.MOTIONBLUR_BUFFER_DRAG = 2;
function Jc(t) {
var e = this, r = e.cy.window(), a = r.document;
t.webgl && (Se.CANVAS_LAYERS = e.CANVAS_LAYERS = 4, console.log("webgl rendering enabled")), e.data = {
canvases: new Array(Se.CANVAS_LAYERS),
contexts: new Array(Se.CANVAS_LAYERS),
canvasNeedsRedraw: new Array(Se.CANVAS_LAYERS),
bufferCanvases: new Array(Se.BUFFER_COUNT),
bufferContexts: new Array(Se.CANVAS_LAYERS)
};
var n = "-webkit-tap-highlight-color", i = "rgba(0,0,0,0)";
e.data.canvasContainer = a.createElement("div");
var s = e.data.canvasContainer.style;
e.data.canvasContainer.style[n] = i, s.position = "relative", s.zIndex = "0", s.overflow = "hidden";
var o = t.cy.container();
o.appendChild(e.data.canvasContainer), o.style[n] = i;
var u = {
"-webkit-user-select": "none",
"-moz-user-select": "-moz-none",
"user-select": "none",
"-webkit-tap-highlight-color": "rgba(0,0,0,0)",
"outline-style": "none"
};
qv() && (u["-ms-touch-action"] = "none", u["touch-action"] = "none");
for (var l = 0; l < Se.CANVAS_LAYERS; l++) {
var f = e.data.canvases[l] = a.createElement("canvas"), c = Se.CANVAS_TYPES[l];
e.data.contexts[l] = f.getContext(c), e.data.contexts[l] || He("Could not create canvas of type " + c), Object.keys(u).forEach(function(J) {
f.style[J] = u[J];
}), f.style.position = "absolute", f.setAttribute("data-id", "layer" + l), f.style.zIndex = String(Se.CANVAS_LAYERS - l), e.data.canvasContainer.appendChild(f), e.data.canvasNeedsRedraw[l] = !1;
}
e.data.topCanvas = e.data.canvases[0], e.data.canvases[Se.NODE].setAttribute("data-id", "layer" + Se.NODE + "-node"), e.data.canvases[Se.SELECT_BOX].setAttribute("data-id", "layer" + Se.SELECT_BOX + "-selectbox"), e.data.canvases[Se.DRAG].setAttribute("data-id", "layer" + Se.DRAG + "-drag"), e.data.canvases[Se.WEBGL] && e.data.canvases[Se.WEBGL].setAttribute("data-id", "layer" + Se.WEBGL + "-webgl");
for (var l = 0; l < Se.BUFFER_COUNT; l++)
e.data.bufferCanvases[l] = a.createElement("canvas"), e.data.bufferContexts[l] = e.data.bufferCanvases[l].getContext("2d"), e.data.bufferCanvases[l].style.position = "absolute", e.data.bufferCanvases[l].setAttribute("data-id", "buffer" + l), e.data.bufferCanvases[l].style.zIndex = String(-l - 1), e.data.bufferCanvases[l].style.visibility = "hidden";
e.pathsEnabled = !0;
var v = Et(), h = function(z) {
return {
x: (z.x1 + z.x2) / 2,
y: (z.y1 + z.y2) / 2
};
}, d = function(z) {
return {
x: -z.w / 2,
y: -z.h / 2
};
}, p = function(z) {
var V = z[0]._private, q = V.oldBackgroundTimestamp === V.backgroundTimestamp;
return !q;
}, g = function(z) {
return z[0]._private.nodeKey;
}, y = function(z) {
return z[0]._private.labelStyleKey;
}, b = function(z) {
return z[0]._private.sourceLabelStyleKey;
}, m = function(z) {
return z[0]._private.targetLabelStyleKey;
}, E = function(z, V, q, Z, re) {
return e.drawElement(z, V, q, !1, !1, re);
}, T = function(z, V, q, Z, re) {
return e.drawElementText(z, V, q, Z, "main", re);
}, S = function(z, V, q, Z, re) {
return e.drawElementText(z, V, q, Z, "source", re);
}, w = function(z, V, q, Z, re) {
return e.drawElementText(z, V, q, Z, "target", re);
}, x = function(z) {
return z.boundingBox(), z[0]._private.bodyBounds;
}, C = function(z) {
return z.boundingBox(), z[0]._private.labelBounds.main || v;
}, D = function(z) {
return z.boundingBox(), z[0]._private.labelBounds.source || v;
}, A = function(z) {
return z.boundingBox(), z[0]._private.labelBounds.target || v;
}, L = function(z, V) {
return V;
}, R = function(z) {
return h(x(z));
}, I = function(z, V, q) {
var Z = z ? z + "-" : "";
return {
x: V.x + q.pstyle(Z + "text-margin-x").pfValue,
y: V.y + q.pstyle(Z + "text-margin-y").pfValue
};
}, M = function(z, V, q) {
var Z = z[0]._private.rscratch;
return {
x: Z[V],
y: Z[q]
};
}, N = function(z) {
return I("", M(z, "labelX", "labelY"), z);
}, O = function(z) {
return I("source", M(z, "sourceLabelX", "sourceLabelY"), z);
}, k = function(z) {
return I("target", M(z, "targetLabelX", "targetLabelY"), z);
}, B = function(z) {
return d(x(z));
}, _ = function(z) {
return d(D(z));
}, F = function(z) {
return d(A(z));
}, G = function(z) {
var V = C(z), q = d(C(z));
if (z.isNode()) {
switch (z.pstyle("text-halign").value) {
case "left":
q.x = -V.w - (V.leftPad || 0);
break;
case "right":
q.x = -(V.rightPad || 0);
break;
}
switch (z.pstyle("text-valign").value) {
case "top":
q.y = -V.h - (V.topPad || 0);
break;
case "bottom":
q.y = -(V.botPad || 0);
break;
}
}
return q;
}, H = e.data.eleTxrCache = new xa(e, {
getKey: g,
doesEleInvalidateKey: p,
drawElement: E,
getBoundingBox: x,
getRotationPoint: R,
getRotationOffset: B,
allowEdgeTxrCaching: !1,
allowParentTxrCaching: !1
}), Y = e.data.lblTxrCache = new xa(e, {
getKey: y,
drawElement: T,
getBoundingBox: C,
getRotationPoint: N,
getRotationOffset: G,
isVisible: L
}), X = e.data.slbTxrCache = new xa(e, {
getKey: b,
drawElement: S,
getBoundingBox: D,
getRotationPoint: O,
getRotationOffset: _,
isVisible: L
}), W = e.data.tlbTxrCache = new xa(e, {
getKey: m,
drawElement: w,
getBoundingBox: A,
getRotationPoint: k,
getRotationOffset: F,
isVisible: L
}), ee = e.data.lyrTxrCache = new Gc(e);
e.onUpdateEleCalcs(function(z, V) {
H.invalidateElements(V), Y.invalidateElements(V), X.invalidateElements(V), W.invalidateElements(V), ee.invalidateElements(V);
for (var q = 0; q < V.length; q++) {
var Z = V[q]._private;
Z.oldBackgroundTimestamp = Z.backgroundTimestamp;
}
});
var ae = function(z) {
for (var V = 0; V < z.length; V++)
ee.enqueueElementRefinement(z[V].ele);
};
H.onDequeue(ae), Y.onDequeue(ae), X.onDequeue(ae), W.onDequeue(ae), t.webgl && e.initWebgl(t, {
getStyleKey: g,
getLabelKey: y,
getSourceLabelKey: b,
getTargetLabelKey: m,
drawElement: E,
drawLabel: T,
drawSourceLabel: S,
drawTargetLabel: w,
getElementBox: x,
getLabelBox: C,
getSourceLabelBox: D,
getTargetLabelBox: A,
getElementRotationPoint: R,
getElementRotationOffset: B,
getLabelRotationPoint: N,
getSourceLabelRotationPoint: O,
getTargetLabelRotationPoint: k,
getLabelRotationOffset: G,
getSourceLabelRotationOffset: _,
getTargetLabelRotationOffset: F
});
}
Se.redrawHint = function(t, e) {
var r = this;
switch (t) {
case "eles":
r.data.canvasNeedsRedraw[Se.NODE] = e;
break;
case "drag":
r.data.canvasNeedsRedraw[Se.DRAG] = e;
break;
case "select":
r.data.canvasNeedsRedraw[Se.SELECT_BOX] = e;
break;
case "gc":
r.data.gc = !0;
break;
}
};
var Zm = typeof Path2D < "u";
Se.path2dEnabled = function(t) {
if (t === void 0)
return this.pathsEnabled;
this.pathsEnabled = !!t;
};
Se.usePaths = function() {
return Zm && this.pathsEnabled;
};
Se.setImgSmoothing = function(t, e) {
t.imageSmoothingEnabled != null ? t.imageSmoothingEnabled = e : (t.webkitImageSmoothingEnabled = e, t.mozImageSmoothingEnabled = e, t.msImageSmoothingEnabled = e);
};
Se.getImgSmoothing = function(t) {
return t.imageSmoothingEnabled != null ? t.imageSmoothingEnabled : t.webkitImageSmoothingEnabled || t.mozImageSmoothingEnabled || t.msImageSmoothingEnabled;
};
Se.makeOffscreenCanvas = function(t, e) {
var r;
if ((typeof OffscreenCanvas > "u" ? "undefined" : nt(OffscreenCanvas)) !== "undefined")
r = new OffscreenCanvas(t, e);
else {
var a = this.cy.window(), n = a.document;
r = n.createElement("canvas"), r.width = t, r.height = e;
}
return r;
};
[zc, Ht, er, Lo, Fr, wr, xt, Hc, Er, $a, Qc].forEach(function(t) {
be(Se, t);
});
var Qm = [{
name: "null",
impl: Sc
}, {
name: "base",
impl: Bc
}, {
name: "canvas",
impl: Km
}], Jm = [{
type: "layout",
extensions: Ty
}, {
type: "renderer",
extensions: Qm
}], jc = {}, ev = {};
function tv(t, e, r) {
var a = r, n = function(x) {
Ge("Can not register `" + e + "` for `" + t + "` since `" + x + "` already exists in the prototype and can not be overridden");
};
if (t === "core") {
if (ka.prototype[e])
return n(e);
ka.prototype[e] = r;
} else if (t === "collection") {
if (vt.prototype[e])
return n(e);
vt.prototype[e] = r;
} else if (t === "layout") {
for (var i = function(x) {
this.options = x, r.call(this, x), Oe(this._private) || (this._private = {}), this._private.cy = x.cy, this._private.listeners = [], this.createEmitter();
}, s = i.prototype = Object.create(r.prototype), o = [], u = 0; u < o.length; u++) {
var l = o[u];
s[l] = s[l] || function() {
return this;
};
}
s.start && !s.run ? s.run = function() {
return this.start(), this;
} : !s.start && s.run && (s.start = function() {
return this.run(), this;
});
var f = r.prototype.stop;
s.stop = function() {
var w = this.options;
if (w && w.animate) {
var x = this.animations;
if (x)
for (var C = 0; C < x.length; C++)
x[C].stop();
}
return f ? f.call(this) : this.emit("layoutstop"), this;
}, s.destroy || (s.destroy = function() {
return this;
}), s.cy = function() {
return this._private.cy;
};
var c = function(x) {
return x._private.cy;
}, v = {
addEventFields: function(x, C) {
C.layout = x, C.cy = c(x), C.target = x;
},
bubble: function() {
return !0;
},
parent: function(x) {
return c(x);
}
};
be(s, {
createEmitter: function() {
return this._private.emitter = new $n(v, this), this;
},
emitter: function() {
return this._private.emitter;
},
on: function(x, C) {
return this.emitter().on(x, C), this;
},
one: function(x, C) {
return this.emitter().one(x, C), this;
},
once: function(x, C) {
return this.emitter().one(x, C), this;
},
removeListener: function(x, C) {
return this.emitter().removeListener(x, C), this;
},
removeAllListeners: function() {
return this.emitter().removeAllListeners(), this;
},
emit: function(x, C) {
return this.emitter().emit(x, C), this;
}
}), _e.eventAliasesOn(s), a = i;
} else if (t === "renderer" && e !== "null" && e !== "base") {
var h = rv("renderer", "base"), d = h.prototype, p = r, g = r.prototype, y = function() {
h.apply(this, arguments), p.apply(this, arguments);
}, b = y.prototype;
for (var m in d) {
var E = d[m], T = g[m] != null;
if (T)
return n(m);
b[m] = E;
}
for (var S in g)
b[S] = g[S];
d.clientFunctions.forEach(function(w) {
b[w] = b[w] || function() {
He("Renderer does not implement `renderer." + w + "()` on its prototype");
};
}), a = y;
} else if (t === "__proto__" || t === "constructor" || t === "prototype")
return He(t + " is an illegal type to be registered, possibly lead to prototype pollutions");
return wf({
map: jc,
keys: [t, e],
value: a
});
}
function rv(t, e) {
return Ef({
map: jc,
keys: [t, e]
});
}
function jm(t, e, r, a, n) {
return wf({
map: ev,
keys: [t, e, r, a],
value: n
});
}
function e0(t, e, r, a) {
return Ef({
map: ev,
keys: [t, e, r, a]
});
}
var eo = function() {
if (arguments.length === 2)
return rv.apply(null, arguments);
if (arguments.length === 3)
return tv.apply(null, arguments);
if (arguments.length === 4)
return e0.apply(null, arguments);
if (arguments.length === 5)
return jm.apply(null, arguments);
He("Invalid extension access syntax");
};
ka.prototype.extension = eo;
Jm.forEach(function(t) {
t.extensions.forEach(function(e) {
tv(t.type, e.name, e.impl);
});
});
var Bn = function() {
if (!(this instanceof Bn))
return new Bn();
this.length = 0;
}, kr = Bn.prototype;
kr.instanceString = function() {
return "stylesheet";
};
kr.selector = function(t) {
var e = this.length++;
return this[e] = {
selector: t,
properties: []
}, this;
};
kr.css = function(t, e) {
var r = this.length - 1;
if (ge(t))
this[r].properties.push({
name: t,
value: e
});
else if (Oe(t))
for (var a = t, n = Object.keys(a), i = 0; i < n.length; i++) {
var s = n[i], o = a[s];
if (o != null) {
var u = ut.properties[s] || ut.properties[Fn(s)];
if (u != null) {
var l = u.name, f = o;
this[r].properties.push({
name: l,
value: f
});
}
}
}
return this;
};
kr.style = kr.css;
kr.generateStyle = function(t) {
var e = new ut(t);
return this.appendToStyle(e);
};
kr.appendToStyle = function(t) {
for (var e = 0; e < this.length; e++) {
var r = this[e], a = r.selector, n = r.properties;
t.selector(a);
for (var i = 0; i < n.length; i++) {
var s = n[i];
t.css(s.name, s.value);
}
}
return t;
};
var t0 = "3.33.1", pr = function(e) {
if (e === void 0 && (e = {}), Oe(e))
return new ka(e);
if (ge(e))
return eo.apply(eo, arguments);
};
pr.use = function(t) {
var e = Array.prototype.slice.call(arguments, 1);
return e.unshift(pr), t.apply(null, e), this;
};
pr.warnings = function(t) {
return Lf(t);
};
pr.version = t0;
pr.stylesheet = pr.Stylesheet = Bn;
var av = { exports: {} }, Os = { exports: {} }, ks = { exports: {} }, ff;
function r0() {
return ff || (ff = 1, function(t, e) {
(function(a, n) {
t.exports = n();
})(ro, function() {
return (
/******/
function(r) {
var a = {};
function n(i) {
if (a[i])
return a[i].exports;
var s = a[i] = {
/******/
i,
/******/
l: !1,
/******/
exports: {}
/******/
};
return r[i].call(s.exports, s, s.exports, n), s.l = !0, s.exports;
}
return n.m = r, n.c = a, n.i = function(i) {
return i;
}, n.d = function(i, s, o) {
n.o(i, s) || Object.defineProperty(i, s, {
/******/
configurable: !1,
/******/
enumerable: !0,
/******/
get: o
/******/
});
}, n.n = function(i) {
var s = i && i.__esModule ? (
/******/
function() {
return i.default;
}
) : (
/******/
function() {
return i;
}
);
return n.d(s, "a", s), s;
}, n.o = function(i, s) {
return Object.prototype.hasOwnProperty.call(i, s);
}, n.p = "", n(n.s = 26);
}([
/* 0 */
/***/
function(r, a, n) {
function i() {
}
i.QUALITY = 1, i.DEFAULT_CREATE_BENDS_AS_NEEDED = !1, i.DEFAULT_INCREMENTAL = !1, i.DEFAULT_ANIMATION_ON_LAYOUT = !0, i.DEFAULT_ANIMATION_DURING_LAYOUT = !1, i.DEFAULT_ANIMATION_PERIOD = 50, i.DEFAULT_UNIFORM_LEAF_NODE_SIZES = !1, i.DEFAULT_GRAPH_MARGIN = 15, i.NODE_DIMENSIONS_INCLUDE_LABELS = !1, i.SIMPLE_NODE_SIZE = 40, i.SIMPLE_NODE_HALF_SIZE = i.SIMPLE_NODE_SIZE / 2, i.EMPTY_COMPOUND_NODE_SIZE = 40, i.MIN_EDGE_LENGTH = 1, i.WORLD_BOUNDARY = 1e6, i.INITIAL_WORLD_BOUNDARY = i.WORLD_BOUNDARY / 1e3, i.WORLD_CENTER_X = 1200, i.WORLD_CENTER_Y = 900, r.exports = i;
},
/* 1 */
/***/
function(r, a, n) {
var i = n(2), s = n(8), o = n(9);
function u(f, c, v) {
i.call(this, v), this.isOverlapingSourceAndTarget = !1, this.vGraphObject = v, this.bendpoints = [], this.source = f, this.target = c;
}
u.prototype = Object.create(i.prototype);
for (var l in i)
u[l] = i[l];
u.prototype.getSource = function() {
return this.source;
}, u.prototype.getTarget = function() {
return this.target;
}, u.prototype.isInterGraph = function() {
return this.isInterGraph;
}, u.prototype.getLength = function() {
return this.length;
}, u.prototype.isOverlapingSourceAndTarget = function() {
return this.isOverlapingSourceAndTarget;
}, u.prototype.getBendpoints = function() {
return this.bendpoints;
}, u.prototype.getLca = function() {
return this.lca;
}, u.prototype.getSourceInLca = function() {
return this.sourceInLca;
}, u.prototype.getTargetInLca = function() {
return this.targetInLca;
}, u.prototype.getOtherEnd = function(f) {
if (this.source === f)
return this.target;
if (this.target === f)
return this.source;
throw "Node is not incident with this edge";
}, u.prototype.getOtherEndInGraph = function(f, c) {
for (var v = this.getOtherEnd(f), h = c.getGraphManager().getRoot(); ; ) {
if (v.getOwner() == c)
return v;
if (v.getOwner() == h)
break;
v = v.getOwner().getParent();
}
return null;
}, u.prototype.updateLength = function() {
var f = new Array(4);
this.isOverlapingSourceAndTarget = s.getIntersection(this.target.getRect(), this.source.getRect(), f), this.isOverlapingSourceAndTarget || (this.lengthX = f[0] - f[2], this.lengthY = f[1] - f[3], Math.abs(this.lengthX) < 1 && (this.lengthX = o.sign(this.lengthX)), Math.abs(this.lengthY) < 1 && (this.lengthY = o.sign(this.lengthY)), this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY));
}, u.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 = o.sign(this.lengthX)), Math.abs(this.lengthY) < 1 && (this.lengthY = o.sign(this.lengthY)), this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY);
}, r.exports = u;
},
/* 2 */
/***/
function(r, a, n) {
function i(s) {
this.vGraphObject = s;
}
r.exports = i;
},
/* 3 */
/***/
function(r, a, n) {
var i = n(2), s = n(10), o = n(13), u = n(0), l = n(16), f = n(4);
function c(h, d, p, g) {
p == null && g == null && (g = d), i.call(this, g), h.graphManager != null && (h = h.graphManager), this.estimatedSize = s.MIN_VALUE, this.inclusionTreeDepth = s.MAX_VALUE, this.vGraphObject = g, this.edges = [], this.graphManager = h, p != null && d != null ? this.rect = new o(d.x, d.y, p.width, p.height) : this.rect = new o();
}
c.prototype = Object.create(i.prototype);
for (var v in i)
c[v] = i[v];
c.prototype.getEdges = function() {
return this.edges;
}, c.prototype.getChild = function() {
return this.child;
}, c.prototype.getOwner = function() {
return this.owner;
}, c.prototype.getWidth = function() {
return this.rect.width;
}, c.prototype.setWidth = function(h) {
this.rect.width = h;
}, c.prototype.getHeight = function() {
return this.rect.height;
}, c.prototype.setHeight = function(h) {
this.rect.height = h;
}, c.prototype.getCenterX = function() {
return this.rect.x + this.rect.width / 2;
}, c.prototype.getCenterY = function() {
return this.rect.y + this.rect.height / 2;
}, c.prototype.getCenter = function() {
return new f(this.rect.x + this.rect.width / 2, this.rect.y + this.rect.height / 2);
}, c.prototype.getLocation = function() {
return new f(this.rect.x, this.rect.y);
}, c.prototype.getRect = function() {
return this.rect;
}, c.prototype.getDiagonal = function() {
return Math.sqrt(this.rect.width * this.rect.width + this.rect.height * this.rect.height);
}, c.prototype.getHalfTheDiagonal = function() {
return Math.sqrt(this.rect.height * this.rect.height + this.rect.width * this.rect.width) / 2;
}, c.prototype.setRect = function(h, d) {
this.rect.x = h.x, this.rect.y = h.y, this.rect.width = d.width, this.rect.height = d.height;
}, c.prototype.setCenter = function(h, d) {
this.rect.x = h - this.rect.width / 2, this.rect.y = d - this.rect.height / 2;
}, c.prototype.setLocation = function(h, d) {
this.rect.x = h, this.rect.y = d;
}, c.prototype.moveBy = function(h, d) {
this.rect.x += h, this.rect.y += d;
}, c.prototype.getEdgeListToNode = function(h) {
var d = [], p = this;
return p.edges.forEach(function(g) {
if (g.target == h) {
if (g.source != p)
throw "Incorrect edge source!";
d.push(g);
}
}), d;
}, c.prototype.getEdgesBetween = function(h) {
var d = [], p = this;
return p.edges.forEach(function(g) {
if (!(g.source == p || g.target == p))
throw "Incorrect edge source and/or target";
(g.target == h || g.source == h) && d.push(g);
}), d;
}, c.prototype.getNeighborsList = function() {
var h = /* @__PURE__ */ new Set(), d = this;
return d.edges.forEach(function(p) {
if (p.source == d)
h.add(p.target);
else {
if (p.target != d)
throw "Incorrect incidency!";
h.add(p.source);
}
}), h;
}, c.prototype.withChildren = function() {
var h = /* @__PURE__ */ new Set(), d, p;
if (h.add(this), this.child != null)
for (var g = this.child.getNodes(), y = 0; y < g.length; y++)
d = g[y], p = d.withChildren(), p.forEach(function(b) {
h.add(b);
});
return h;
}, c.prototype.getNoOfChildren = function() {
var h = 0, d;
if (this.child == null)
h = 1;
else
for (var p = this.child.getNodes(), g = 0; g < p.length; g++)
d = p[g], h += d.getNoOfChildren();
return h == 0 && (h = 1), h;
}, c.prototype.getEstimatedSize = function() {
if (this.estimatedSize == s.MIN_VALUE)
throw "assert failed";
return this.estimatedSize;
}, c.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);
}, c.prototype.scatter = function() {
var h, d, p = -u.INITIAL_WORLD_BOUNDARY, g = u.INITIAL_WORLD_BOUNDARY;
h = u.WORLD_CENTER_X + l.nextDouble() * (g - p) + p;
var y = -u.INITIAL_WORLD_BOUNDARY, b = u.INITIAL_WORLD_BOUNDARY;
d = u.WORLD_CENTER_Y + l.nextDouble() * (b - y) + y, this.rect.x = h, this.rect.y = d;
}, c.prototype.updateBounds = function() {
if (this.getChild() == null)
throw "assert failed";
if (this.getChild().getNodes().length != 0) {
var h = this.getChild();
if (h.updateBounds(!0), this.rect.x = h.getLeft(), this.rect.y = h.getTop(), this.setWidth(h.getRight() - h.getLeft()), this.setHeight(h.getBottom() - h.getTop()), u.NODE_DIMENSIONS_INCLUDE_LABELS) {
var d = h.getRight() - h.getLeft(), p = h.getBottom() - h.getTop();
this.labelWidth > d && (this.rect.x -= (this.labelWidth - d) / 2, this.setWidth(this.labelWidth)), this.labelHeight > p && (this.labelPos == "center" ? this.rect.y -= (this.labelHeight - p) / 2 : this.labelPos == "top" && (this.rect.y -= this.labelHeight - p), this.setHeight(this.labelHeight));
}
}
}, c.prototype.getInclusionTreeDepth = function() {
if (this.inclusionTreeDepth == s.MAX_VALUE)
throw "assert failed";
return this.inclusionTreeDepth;
}, c.prototype.transform = function(h) {
var d = this.rect.x;
d > u.WORLD_BOUNDARY ? d = u.WORLD_BOUNDARY : d < -u.WORLD_BOUNDARY && (d = -u.WORLD_BOUNDARY);
var p = this.rect.y;
p > u.WORLD_BOUNDARY ? p = u.WORLD_BOUNDARY : p < -u.WORLD_BOUNDARY && (p = -u.WORLD_BOUNDARY);
var g = new f(d, p), y = h.inverseTransformPoint(g);
this.setLocation(y.x, y.y);
}, c.prototype.getLeft = function() {
return this.rect.x;
}, c.prototype.getRight = function() {
return this.rect.x + this.rect.width;
}, c.prototype.getTop = function() {
return this.rect.y;
}, c.prototype.getBottom = function() {
return this.rect.y + this.rect.height;
}, c.prototype.getParent = function() {
return this.owner == null ? null : this.owner.getParent();
}, r.exports = c;
},
/* 4 */
/***/
function(r, a, n) {
function i(s, o) {
s == null && o == null ? (this.x = 0, this.y = 0) : (this.x = s, this.y = o);
}
i.prototype.getX = function() {
return this.x;
}, i.prototype.getY = function() {
return this.y;
}, i.prototype.setX = function(s) {
this.x = s;
}, i.prototype.setY = function(s) {
this.y = s;
}, i.prototype.getDifference = function(s) {
return new DimensionD(this.x - s.x, this.y - s.y);
}, i.prototype.getCopy = function() {
return new i(this.x, this.y);
}, i.prototype.translate = function(s) {
return this.x += s.width, this.y += s.height, this;
}, r.exports = i;
},
/* 5 */
/***/
function(r, a, n) {
var i = n(2), s = n(10), o = n(0), u = n(6), l = n(3), f = n(1), c = n(13), v = n(12), h = n(11);
function d(g, y, b) {
i.call(this, b), this.estimatedSize = s.MIN_VALUE, this.margin = o.DEFAULT_GRAPH_MARGIN, this.edges = [], this.nodes = [], this.isConnected = !1, this.parent = g, y != null && y instanceof u ? this.graphManager = y : y != null && y instanceof Layout && (this.graphManager = y.graphManager);
}
d.prototype = Object.create(i.prototype);
for (var p in i)
d[p] = i[p];
d.prototype.getNodes = function() {
return this.nodes;
}, d.prototype.getEdges = function() {
return this.edges;
}, d.prototype.getGraphManager = function() {
return this.graphManager;
}, d.prototype.getParent = function() {
return this.parent;
}, d.prototype.getLeft = function() {
return this.left;
}, d.prototype.getRight = function() {
return this.right;
}, d.prototype.getTop = function() {
return this.top;
}, d.prototype.getBottom = function() {
return this.bottom;
}, d.prototype.isConnected = function() {
return this.isConnected;
}, d.prototype.add = function(g, y, b) {
if (y == null && b == null) {
var m = g;
if (this.graphManager == null)
throw "Graph has no graph mgr!";
if (this.getNodes().indexOf(m) > -1)
throw "Node already in graph!";
return m.owner = this, this.getNodes().push(m), m;
} else {
var E = g;
if (!(this.getNodes().indexOf(y) > -1 && this.getNodes().indexOf(b) > -1))
throw "Source or target not in graph!";
if (!(y.owner == b.owner && y.owner == this))
throw "Both owners must be this graph!";
return y.owner != b.owner ? null : (E.source = y, E.target = b, E.isInterGraph = !1, this.getEdges().push(E), y.edges.push(E), b != y && b.edges.push(E), E);
}
}, d.prototype.remove = function(g) {
var y = g;
if (g instanceof l) {
if (y == null)
throw "Node is null!";
if (!(y.owner != null && y.owner == this))
throw "Owner graph is invalid!";
if (this.graphManager == null)
throw "Owner graph manager is invalid!";
for (var b = y.edges.slice(), m, E = b.length, T = 0; T < E; T++)
m = b[T], m.isInterGraph ? this.graphManager.remove(m) : m.source.owner.remove(m);
var S = this.nodes.indexOf(y);
if (S == -1)
throw "Node not in owner node list!";
this.nodes.splice(S, 1);
} else if (g instanceof f) {
var m = g;
if (m == null)
throw "Edge is null!";
if (!(m.source != null && m.target != null))
throw "Source and/or target is null!";
if (!(m.source.owner != null && m.target.owner != null && m.source.owner == this && m.target.owner == this))
throw "Source and/or target owner is invalid!";
var w = m.source.edges.indexOf(m), x = m.target.edges.indexOf(m);
if (!(w > -1 && x > -1))
throw "Source and/or target doesn't know this edge!";
m.source.edges.splice(w, 1), m.target != m.source && m.target.edges.splice(x, 1);
var S = m.source.owner.getEdges().indexOf(m);
if (S == -1)
throw "Not in owner's edge list!";
m.source.owner.getEdges().splice(S, 1);
}
}, d.prototype.updateLeftTop = function() {
for (var g = s.MAX_VALUE, y = s.MAX_VALUE, b, m, E, T = this.getNodes(), S = T.length, w = 0; w < S; w++) {
var x = T[w];
b = x.getTop(), m = x.getLeft(), g > b && (g = b), y > m && (y = m);
}
return g == s.MAX_VALUE ? null : (T[0].getParent().paddingLeft != null ? E = T[0].getParent().paddingLeft : E = this.margin, this.left = y - E, this.top = g - E, new v(this.left, this.top));
}, d.prototype.updateBounds = function(g) {
for (var y = s.MAX_VALUE, b = -s.MAX_VALUE, m = s.MAX_VALUE, E = -s.MAX_VALUE, T, S, w, x, C, D = this.nodes, A = D.length, L = 0; L < A; L++) {
var R = D[L];
g && R.child != null && R.updateBounds(), T = R.getLeft(), S = R.getRight(), w = R.getTop(), x = R.getBottom(), y > T && (y = T), b < S && (b = S), m > w && (m = w), E < x && (E = x);
}
var I = new c(y, m, b - y, E - m);
y == s.MAX_VALUE && (this.left = this.parent.getLeft(), this.right = this.parent.getRight(), this.top = this.parent.getTop(), this.bottom = this.parent.getBottom()), D[0].getParent().paddingLeft != null ? C = D[0].getParent().paddingLeft : C = this.margin, this.left = I.x - C, this.right = I.x + I.width + C, this.top = I.y - C, this.bottom = I.y + I.height + C;
}, d.calculateBounds = function(g) {
for (var y = s.MAX_VALUE, b = -s.MAX_VALUE, m = s.MAX_VALUE, E = -s.MAX_VALUE, T, S, w, x, C = g.length, D = 0; D < C; D++) {
var A = g[D];
T = A.getLeft(), S = A.getRight(), w = A.getTop(), x = A.getBottom(), y > T && (y = T), b < S && (b = S), m > w && (m = w), E < x && (E = x);
}
var L = new c(y, m, b - y, E - m);
return L;
}, d.prototype.getInclusionTreeDepth = function() {
return this == this.graphManager.getRoot() ? 1 : this.parent.getInclusionTreeDepth();
}, d.prototype.getEstimatedSize = function() {
if (this.estimatedSize == s.MIN_VALUE)
throw "assert failed";
return this.estimatedSize;
}, d.prototype.calcEstimatedSize = function() {
for (var g = 0, y = this.nodes, b = y.length, m = 0; m < b; m++) {
var E = y[m];
g += E.calcEstimatedSize();
}
return g == 0 ? this.estimatedSize = o.EMPTY_COMPOUND_NODE_SIZE : this.estimatedSize = g / Math.sqrt(this.nodes.length), this.estimatedSize;
}, d.prototype.updateConnected = function() {
var g = this;
if (this.nodes.length == 0) {
this.isConnected = !0;
return;
}
var y = new h(), b = /* @__PURE__ */ new Set(), m = this.nodes[0], E, T, S = m.withChildren();
for (S.forEach(function(L) {
y.push(L), b.add(L);
}); y.length !== 0; ) {
m = y.shift(), E = m.getEdges();
for (var w = E.length, x = 0; x < w; x++) {
var C = E[x];
if (T = C.getOtherEndInGraph(m, this), T != null && !b.has(T)) {
var D = T.withChildren();
D.forEach(function(L) {
y.push(L), b.add(L);
});
}
}
}
if (this.isConnected = !1, b.size >= this.nodes.length) {
var A = 0;
b.forEach(function(L) {
L.owner == g && A++;
}), A == this.nodes.length && (this.isConnected = !0);
}
}, r.exports = d;
},
/* 6 */
/***/
function(r, a, n) {
var i, s = n(1);
function o(u) {
i = n(5), this.layout = u, this.graphs = [], this.edges = [];
}
o.prototype.addRoot = function() {
var u = this.layout.newGraph(), l = this.layout.newNode(null), f = this.add(u, l);
return this.setRootGraph(f), this.rootGraph;
}, o.prototype.add = function(u, l, f, c, v) {
if (f == null && c == null && v == null) {
if (u == null)
throw "Graph is null!";
if (l == null)
throw "Parent node is null!";
if (this.graphs.indexOf(u) > -1)
throw "Graph already in this graph mgr!";
if (this.graphs.push(u), u.parent != null)
throw "Already has a parent!";
if (l.child != null)
throw "Already has a child!";
return u.parent = l, l.child = u, u;
} else {
v = f, c = l, f = u;
var h = c.getOwner(), d = v.getOwner();
if (!(h != null && h.getGraphManager() == this))
throw "Source not in this graph mgr!";
if (!(d != null && d.getGraphManager() == this))
throw "Target not in this graph mgr!";
if (h == d)
return f.isInterGraph = !1, h.add(f, c, v);
if (f.isInterGraph = !0, f.source = c, f.target = v, this.edges.indexOf(f) > -1)
throw "Edge already in inter-graph edge list!";
if (this.edges.push(f), !(f.source != null && f.target != null))
throw "Edge source and/or target is null!";
if (!(f.source.edges.indexOf(f) == -1 && f.target.edges.indexOf(f) == -1))
throw "Edge already in source and/or target incidency list!";
return f.source.edges.push(f), f.target.edges.push(f), f;
}
}, o.prototype.remove = function(u) {
if (u instanceof i) {
var l = u;
if (l.getGraphManager() != this)
throw "Graph not in this graph mgr";
if (!(l == this.rootGraph || l.parent != null && l.parent.graphManager == this))
throw "Invalid parent node!";
var f = [];
f = f.concat(l.getEdges());
for (var c, v = f.length, h = 0; h < v; h++)
c = f[h], l.remove(c);
var d = [];
d = d.concat(l.getNodes());
var p;
v = d.length;
for (var h = 0; h < v; h++)
p = d[h], l.remove(p);
l == this.rootGraph && this.setRootGraph(null);
var g = this.graphs.indexOf(l);
this.graphs.splice(g, 1), l.parent = null;
} else if (u instanceof s) {
if (c = u, c == null)
throw "Edge is null!";
if (!c.isInterGraph)
throw "Not an inter-graph edge!";
if (!(c.source != null && c.target != null))
throw "Source and/or target is null!";
if (!(c.source.edges.indexOf(c) != -1 && c.target.edges.indexOf(c) != -1))
throw "Source and/or target doesn't know this edge!";
var g = c.source.edges.indexOf(c);
if (c.source.edges.splice(g, 1), g = c.target.edges.indexOf(c), c.target.edges.splice(g, 1), !(c.source.owner != null && c.source.owner.getGraphManager() != null))
throw "Edge owner graph or owner graph manager is null!";
if (c.source.owner.getGraphManager().edges.indexOf(c) == -1)
throw "Not in owner graph manager's edge list!";
var g = c.source.owner.getGraphManager().edges.indexOf(c);
c.source.owner.getGraphManager().edges.splice(g, 1);
}
}, o.prototype.updateBounds = function() {
this.rootGraph.updateBounds(!0);
}, o.prototype.getGraphs = function() {
return this.graphs;
}, o.prototype.getAllNodes = function() {
if (this.allNodes == null) {
for (var u = [], l = this.getGraphs(), f = l.length, c = 0; c < f; c++)
u = u.concat(l[c].getNodes());
this.allNodes = u;
}
return this.allNodes;
}, o.prototype.resetAllNodes = function() {
this.allNodes = null;
}, o.prototype.resetAllEdges = function() {
this.allEdges = null;
}, o.prototype.resetAllNodesToApplyGravitation = function() {
this.allNodesToApplyGravitation = null;
}, o.prototype.getAllEdges = function() {
if (this.allEdges == null) {
var u = [], l = this.getGraphs();
l.length;
for (var f = 0; f < l.length; f++)
u = u.concat(l[f].getEdges());
u = u.concat(this.edges), this.allEdges = u;
}
return this.allEdges;
}, o.prototype.getAllNodesToApplyGravitation = function() {
return this.allNodesToApplyGravitation;
}, o.prototype.setAllNodesToApplyGravitation = function(u) {
if (this.allNodesToApplyGravitation != null)
throw "assert failed";
this.allNodesToApplyGravitation = u;
}, o.prototype.getRoot = function() {
return this.rootGraph;
}, o.prototype.setRootGraph = function(u) {
if (u.getGraphManager() != this)
throw "Root not in this graph mgr!";
this.rootGraph = u, u.parent == null && (u.parent = this.layout.newNode("Root node"));
}, o.prototype.getLayout = function() {
return this.layout;
}, o.prototype.isOneAncestorOfOther = function(u, l) {
if (!(u != null && l != null))
throw "assert failed";
if (u == l)
return !0;
var f = u.getOwner(), c;
do {
if (c = f.getParent(), c == null)
break;
if (c == l)
return !0;
if (f = c.getOwner(), f == null)
break;
} while (!0);
f = l.getOwner();
do {
if (c = f.getParent(), c == null)
break;
if (c == u)
return !0;
if (f = c.getOwner(), f == null)
break;
} while (!0);
return !1;
}, o.prototype.calcLowestCommonAncestors = function() {
for (var u, l, f, c, v, h = this.getAllEdges(), d = h.length, p = 0; p < d; p++) {
if (u = h[p], l = u.source, f = u.target, u.lca = null, u.sourceInLca = l, u.targetInLca = f, l == f) {
u.lca = l.getOwner();
continue;
}
for (c = l.getOwner(); u.lca == null; ) {
for (u.targetInLca = f, v = f.getOwner(); u.lca == null; ) {
if (v == c) {
u.lca = v;
break;
}
if (v == this.rootGraph)
break;
if (u.lca != null)
throw "assert failed";
u.targetInLca = v.getParent(), v = u.targetInLca.getOwner();
}
if (c == this.rootGraph)
break;
u.lca == null && (u.sourceInLca = c.getParent(), c = u.sourceInLca.getOwner());
}
if (u.lca == null)
throw "assert failed";
}
}, o.prototype.calcLowestCommonAncestor = function(u, l) {
if (u == l)
return u.getOwner();
var f = u.getOwner();
do {
if (f == null)
break;
var c = l.getOwner();
do {
if (c == null)
break;
if (c == f)
return c;
c = c.getParent().getOwner();
} while (!0);
f = f.getParent().getOwner();
} while (!0);
return f;
}, o.prototype.calcInclusionTreeDepths = function(u, l) {
u == null && l == null && (u = this.rootGraph, l = 1);
for (var f, c = u.getNodes(), v = c.length, h = 0; h < v; h++)
f = c[h], f.inclusionTreeDepth = l, f.child != null && this.calcInclusionTreeDepths(f.child, l + 1);
}, o.prototype.includesInvalidEdge = function() {
for (var u, l = this.edges.length, f = 0; f < l; f++)
if (u = this.edges[f], this.isOneAncestorOfOther(u.source, u.target))
return !0;
return !1;
}, r.exports = o;
},
/* 7 */
/***/
function(r, a, n) {
var i = n(0);
function s() {
}
for (var o in i)
s[o] = i[o];
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, r.exports = s;
},
/* 8 */
/***/
function(r, a, n) {
var i = n(12);
function s() {
}
s.calcSeparationAmount = function(o, u, l, f) {
if (!o.intersects(u))
throw "assert failed";
var c = new Array(2);
this.decideDirectionsForOverlappingNodes(o, u, c), l[0] = Math.min(o.getRight(), u.getRight()) - Math.max(o.x, u.x), l[1] = Math.min(o.getBottom(), u.getBottom()) - Math.max(o.y, u.y), o.getX() <= u.getX() && o.getRight() >= u.getRight() ? l[0] += Math.min(u.getX() - o.getX(), o.getRight() - u.getRight()) : u.getX() <= o.getX() && u.getRight() >= o.getRight() && (l[0] += Math.min(o.getX() - u.getX(), u.getRight() - o.getRight())), o.getY() <= u.getY() && o.getBottom() >= u.getBottom() ? l[1] += Math.min(u.getY() - o.getY(), o.getBottom() - u.getBottom()) : u.getY() <= o.getY() && u.getBottom() >= o.getBottom() && (l[1] += Math.min(o.getY() - u.getY(), u.getBottom() - o.getBottom()));
var v = Math.abs((u.getCenterY() - o.getCenterY()) / (u.getCenterX() - o.getCenterX()));
u.getCenterY() === o.getCenterY() && u.getCenterX() === o.getCenterX() && (v = 1);
var h = v * l[0], d = l[1] / v;
l[0] < d ? d = l[0] : h = l[1], l[0] = -1 * c[0] * (d / 2 + f), l[1] = -1 * c[1] * (h / 2 + f);
}, s.decideDirectionsForOverlappingNodes = function(o, u, l) {
o.getCenterX() < u.getCenterX() ? l[0] = -1 : l[0] = 1, o.getCenterY() < u.getCenterY() ? l[1] = -1 : l[1] = 1;
}, s.getIntersection2 = function(o, u, l) {
var f = o.getCenterX(), c = o.getCenterY(), v = u.getCenterX(), h = u.getCenterY();
if (o.intersects(u))
return l[0] = f, l[1] = c, l[2] = v, l[3] = h, !0;
var d = o.getX(), p = o.getY(), g = o.getRight(), y = o.getX(), b = o.getBottom(), m = o.getRight(), E = o.getWidthHalf(), T = o.getHeightHalf(), S = u.getX(), w = u.getY(), x = u.getRight(), C = u.getX(), D = u.getBottom(), A = u.getRight(), L = u.getWidthHalf(), R = u.getHeightHalf(), I = !1, M = !1;
if (f === v) {
if (c > h)
return l[0] = f, l[1] = p, l[2] = v, l[3] = D, !1;
if (c < h)
return l[0] = f, l[1] = b, l[2] = v, l[3] = w, !1;
} else if (c === h) {
if (f > v)
return l[0] = d, l[1] = c, l[2] = x, l[3] = h, !1;
if (f < v)
return l[0] = g, l[1] = c, l[2] = S, l[3] = h, !1;
} else {
var N = o.height / o.width, O = u.height / u.width, k = (h - c) / (v - f), B = void 0, _ = void 0, F = void 0, G = void 0, H = void 0, Y = void 0;
if (-N === k ? f > v ? (l[0] = y, l[1] = b, I = !0) : (l[0] = g, l[1] = p, I = !0) : N === k && (f > v ? (l[0] = d, l[1] = p, I = !0) : (l[0] = m, l[1] = b, I = !0)), -O === k ? v > f ? (l[2] = C, l[3] = D, M = !0) : (l[2] = x, l[3] = w, M = !0) : O === k && (v > f ? (l[2] = S, l[3] = w, M = !0) : (l[2] = A, l[3] = D, M = !0)), I && M)
return !1;
if (f > v ? c > h ? (B = this.getCardinalDirection(N, k, 4), _ = this.getCardinalDirection(O, k, 2)) : (B = this.getCardinalDirection(-N, k, 3), _ = this.getCardinalDirection(-O, k, 1)) : c > h ? (B = this.getCardinalDirection(-N, k, 1), _ = this.getCardinalDirection(-O, k, 3)) : (B = this.getCardinalDirection(N, k, 2), _ = this.getCardinalDirection(O, k, 4)), !I)
switch (B) {
case 1:
G = p, F = f + -T / k, l[0] = F, l[1] = G;
break;
case 2:
F = m, G = c + E * k, l[0] = F, l[1] = G;
break;
case 3:
G = b, F = f + T / k, l[0] = F, l[1] = G;
break;
case 4:
F = y, G = c + -E * k, l[0] = F, l[1] = G;
break;
}
if (!M)
switch (_) {
case 1:
Y = w, H = v + -R / k, l[2] = H, l[3] = Y;
break;
case 2:
H = A, Y = h + L * k, l[2] = H, l[3] = Y;
break;
case 3:
Y = D, H = v + R / k, l[2] = H, l[3] = Y;
break;
case 4:
H = C, Y = h + -L * k, l[2] = H, l[3] = Y;
break;
}
}
return !1;
}, s.getCardinalDirection = function(o, u, l) {
return o > u ? l : 1 + l % 4;
}, s.getIntersection = function(o, u, l, f) {
if (f == null)
return this.getIntersection2(o, u, l);
var c = o.x, v = o.y, h = u.x, d = u.y, p = l.x, g = l.y, y = f.x, b = f.y, m = void 0, E = void 0, T = void 0, S = void 0, w = void 0, x = void 0, C = void 0, D = void 0, A = void 0;
return T = d - v, w = c - h, C = h * v - c * d, S = b - g, x = p - y, D = y * g - p * b, A = T * x - S * w, A === 0 ? null : (m = (w * D - x * C) / A, E = (S * C - T * D) / A, new i(m, E));
}, s.angleOfVector = function(o, u, l, f) {
var c = void 0;
return o !== l ? (c = Math.atan((f - u) / (l - o)), l < o ? c += Math.PI : f < u && (c += this.TWO_PI)) : f < u ? c = this.ONE_AND_HALF_PI : c = this.HALF_PI, c;
}, s.doIntersect = function(o, u, l, f) {
var c = o.x, v = o.y, h = u.x, d = u.y, p = l.x, g = l.y, y = f.x, b = f.y, m = (h - c) * (b - g) - (y - p) * (d - v);
if (m === 0)
return !1;
var E = ((b - g) * (y - c) + (p - y) * (b - v)) / m, T = ((v - d) * (y - c) + (h - c) * (b - v)) / m;
return 0 < E && E < 1 && 0 < T && T < 1;
}, 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, r.exports = s;
},
/* 9 */
/***/
function(r, a, n) {
function i() {
}
i.sign = function(s) {
return s > 0 ? 1 : s < 0 ? -1 : 0;
}, i.floor = function(s) {
return s < 0 ? Math.ceil(s) : Math.floor(s);
}, i.ceil = function(s) {
return s < 0 ? Math.floor(s) : Math.ceil(s);
}, r.exports = i;
},
/* 10 */
/***/
function(r, a, n) {
function i() {
}
i.MAX_VALUE = 2147483647, i.MIN_VALUE = -2147483648, r.exports = i;
},
/* 11 */
/***/
function(r, a, n) {
var i = function() {
function c(v, h) {
for (var d = 0; d < h.length; d++) {
var p = h[d];
p.enumerable = p.enumerable || !1, p.configurable = !0, "value" in p && (p.writable = !0), Object.defineProperty(v, p.key, p);
}
}
return function(v, h, d) {
return h && c(v.prototype, h), d && c(v, d), v;
};
}();
function s(c, v) {
if (!(c instanceof v))
throw new TypeError("Cannot call a class as a function");
}
var o = function(v) {
return { value: v, next: null, prev: null };
}, u = function(v, h, d, p) {
return v !== null ? v.next = h : p.head = h, d !== null ? d.prev = h : p.tail = h, h.prev = v, h.next = d, p.length++, h;
}, l = function(v, h) {
var d = v.prev, p = v.next;
return d !== null ? d.next = p : h.head = p, p !== null ? p.prev = d : h.tail = d, v.prev = v.next = null, h.length--, v;
}, f = function() {
function c(v) {
var h = this;
s(this, c), this.length = 0, this.head = null, this.tail = null, v != null && v.forEach(function(d) {
return h.push(d);
});
}
return i(c, [{
key: "size",
value: function() {
return this.length;
}
}, {
key: "insertBefore",
value: function(h, d) {
return u(d.prev, o(h), d, this);
}
}, {
key: "insertAfter",
value: function(h, d) {
return u(d, o(h), d.next, this);
}
}, {
key: "insertNodeBefore",
value: function(h, d) {
return u(d.prev, h, d, this);
}
}, {
key: "insertNodeAfter",
value: function(h, d) {
return u(d, h, d.next, this);
}
}, {
key: "push",
value: function(h) {
return u(this.tail, o(h), null, this);
}
}, {
key: "unshift",
value: function(h) {
return u(null, o(h), this.head, this);
}
}, {
key: "remove",
value: function(h) {
return l(h, this);
}
}, {
key: "pop",
value: function() {
return l(this.tail, this).value;
}
}, {
key: "popNode",
value: function() {
return l(this.tail, this);
}
}, {
key: "shift",
value: function() {
return l(this.head, this).value;
}
}, {
key: "shiftNode",
value: function() {
return l(this.head, this);
}
}, {
key: "get_object_at",
value: function(h) {
if (h <= this.length()) {
for (var d = 1, p = this.head; d < h; )
p = p.next, d++;
return p.value;
}
}
}, {
key: "set_object_at",
value: function(h, d) {
if (h <= this.length()) {
for (var p = 1, g = this.head; p < h; )
g = g.next, p++;
g.value = d;
}
}
}]), c;
}();
r.exports = f;
},
/* 12 */
/***/
function(r, a, n) {
function i(s, o, u) {
this.x = null, this.y = null, s == null && o == null && u == null ? (this.x = 0, this.y = 0) : typeof s == "number" && typeof o == "number" && u == null ? (this.x = s, this.y = o) : s.constructor.name == "Point" && o == null && u == null && (u = s, this.x = u.x, this.y = u.y);
}
i.prototype.getX = function() {
return this.x;
}, i.prototype.getY = function() {
return this.y;
}, i.prototype.getLocation = function() {
return new i(this.x, this.y);
}, i.prototype.setLocation = function(s, o, u) {
s.constructor.name == "Point" && o == null && u == null ? (u = s, this.setLocation(u.x, u.y)) : typeof s == "number" && typeof o == "number" && u == null && (parseInt(s) == s && parseInt(o) == o ? this.move(s, o) : (this.x = Math.floor(s + 0.5), this.y = Math.floor(o + 0.5)));
}, i.prototype.move = function(s, o) {
this.x = s, this.y = o;
}, i.prototype.translate = function(s, o) {
this.x += s, this.y += o;
}, i.prototype.equals = function(s) {
if (s.constructor.name == "Point") {
var o = s;
return this.x == o.x && this.y == o.y;
}
return this == s;
}, i.prototype.toString = function() {
return new i().constructor.name + "[x=" + this.x + ",y=" + this.y + "]";
}, r.exports = i;
},
/* 13 */
/***/
function(r, a, n) {
function i(s, o, u, l) {
this.x = 0, this.y = 0, this.width = 0, this.height = 0, s != null && o != null && u != null && l != null && (this.x = s, this.y = o, this.width = u, this.height = l);
}
i.prototype.getX = function() {
return this.x;
}, i.prototype.setX = function(s) {
this.x = s;
}, i.prototype.getY = function() {
return this.y;
}, i.prototype.setY = function(s) {
this.y = s;
}, i.prototype.getWidth = function() {
return this.width;
}, i.prototype.setWidth = function(s) {
this.width = s;
}, i.prototype.getHeight = function() {
return this.height;
}, i.prototype.setHeight = function(s) {
this.height = s;
}, i.prototype.getRight = function() {
return this.x + this.width;
}, i.prototype.getBottom = function() {
return this.y + this.height;
}, i.prototype.intersects = function(s) {
return !(this.getRight() < s.x || this.getBottom() < s.y || s.getRight() < this.x || s.getBottom() < this.y);
}, i.prototype.getCenterX = function() {
return this.x + this.width / 2;
}, i.prototype.getMinX = function() {
return this.getX();
}, i.prototype.getMaxX = function() {
return this.getX() + this.width;
}, i.prototype.getCenterY = function() {
return this.y + this.height / 2;
}, i.prototype.getMinY = function() {
return this.getY();
}, i.prototype.getMaxY = function() {
return this.getY() + this.height;
}, i.prototype.getWidthHalf = function() {
return this.width / 2;
}, i.prototype.getHeightHalf = function() {
return this.height / 2;
}, r.exports = i;
},
/* 14 */
/***/
function(r, a, n) {
var i = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(o) {
return typeof o;
} : function(o) {
return o && typeof Symbol == "function" && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
};
function s() {
}
s.lastID = 0, s.createID = function(o) {
return s.isPrimitive(o) ? o : (o.uniqueID != null || (o.uniqueID = s.getString(), s.lastID++), o.uniqueID);
}, s.getString = function(o) {
return o == null && (o = s.lastID), "Object#" + o;
}, s.isPrimitive = function(o) {
var u = typeof o > "u" ? "undefined" : i(o);
return o == null || u != "object" && u != "function";
}, r.exports = s;
},
/* 15 */
/***/
function(r, a, n) {
function i(p) {
if (Array.isArray(p)) {
for (var g = 0, y = Array(p.length); g < p.length; g++)
y[g] = p[g];
return y;
} else
return Array.from(p);
}
var s = n(0), o = n(6), u = n(3), l = n(1), f = n(5), c = n(4), v = n(17), h = n(27);
function d(p) {
h.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 o(this), this.isLayoutFinished = !1, this.isSubLayout = !1, this.isRemoteUse = !1, p != null && (this.isRemoteUse = p);
}
d.RANDOM_SEED = 1, d.prototype = Object.create(h.prototype), d.prototype.getGraphManager = function() {
return this.graphManager;
}, d.prototype.getAllNodes = function() {
return this.graphManager.getAllNodes();
}, d.prototype.getAllEdges = function() {
return this.graphManager.getAllEdges();
}, d.prototype.getAllNodesToApplyGravitation = function() {
return this.graphManager.getAllNodesToApplyGravitation();
}, d.prototype.newGraphManager = function() {
var p = new o(this);
return this.graphManager = p, p;
}, d.prototype.newGraph = function(p) {
return new f(null, this.graphManager, p);
}, d.prototype.newNode = function(p) {
return new u(this.graphManager, p);
}, d.prototype.newEdge = function(p) {
return new l(null, null, p);
}, d.prototype.checkLayoutSuccess = function() {
return this.graphManager.getRoot() == null || this.graphManager.getRoot().getNodes().length == 0 || this.graphManager.includesInvalidEdge();
}, d.prototype.runLayout = function() {
this.isLayoutFinished = !1, this.tilingPreLayout && this.tilingPreLayout(), this.initParameters();
var p;
return this.checkLayoutSuccess() ? p = !1 : p = this.layout(), s.ANIMATE === "during" ? !1 : (p && (this.isSubLayout || this.doPostLayout()), this.tilingPostLayout && this.tilingPostLayout(), this.isLayoutFinished = !0, p);
}, d.prototype.doPostLayout = function() {
this.incremental || this.transform(), this.update();
}, d.prototype.update2 = function() {
if (this.createBendsAsNeeded && (this.createBendpointsFromDummyNodes(), this.graphManager.resetAllEdges()), !this.isRemoteUse) {
for (var p = this.graphManager.getAllEdges(), g = 0; g < p.length; g++)
p[g];
for (var y = this.graphManager.getRoot().getNodes(), g = 0; g < y.length; g++)
y[g];
this.update(this.graphManager.getRoot());
}
}, d.prototype.update = function(p) {
if (p == null)
this.update2();
else if (p instanceof u) {
var g = p;
if (g.getChild() != null)
for (var y = g.getChild().getNodes(), b = 0; b < y.length; b++)
update(y[b]);
if (g.vGraphObject != null) {
var m = g.vGraphObject;
m.update(g);
}
} else if (p instanceof l) {
var E = p;
if (E.vGraphObject != null) {
var T = E.vGraphObject;
T.update(E);
}
} else if (p instanceof f) {
var S = p;
if (S.vGraphObject != null) {
var w = S.vGraphObject;
w.update(S);
}
}
}, d.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);
}, d.prototype.transform = function(p) {
if (p == null)
this.transform(new c(0, 0));
else {
var g = new v(), y = this.graphManager.getRoot().updateLeftTop();
if (y != null) {
g.setWorldOrgX(p.x), g.setWorldOrgY(p.y), g.setDeviceOrgX(y.x), g.setDeviceOrgY(y.y);
for (var b = this.getAllNodes(), m, E = 0; E < b.length; E++)
m = b[E], m.transform(g);
}
}
}, d.prototype.positionNodesRandomly = function(p) {
if (p == null)
this.positionNodesRandomly(this.getGraphManager().getRoot()), this.getGraphManager().getRoot().updateBounds(!0);
else
for (var g, y, b = p.getNodes(), m = 0; m < b.length; m++)
g = b[m], y = g.getChild(), y == null || y.getNodes().length == 0 ? g.scatter() : (this.positionNodesRandomly(y), g.updateBounds());
}, d.prototype.getFlatForest = function() {
for (var p = [], g = !0, y = this.graphManager.getRoot().getNodes(), b = !0, m = 0; m < y.length; m++)
y[m].getChild() != null && (b = !1);
if (!b)
return p;
var E = /* @__PURE__ */ new Set(), T = [], S = /* @__PURE__ */ new Map(), w = [];
for (w = w.concat(y); w.length > 0 && g; ) {
for (T.push(w[0]); T.length > 0 && g; ) {
var x = T[0];
T.splice(0, 1), E.add(x);
for (var C = x.getEdges(), m = 0; m < C.length; m++) {
var D = C[m].getOtherEnd(x);
if (S.get(x) != D)
if (!E.has(D))
T.push(D), S.set(D, x);
else {
g = !1;
break;
}
}
}
if (!g)
p = [];
else {
var A = [].concat(i(E));
p.push(A);
for (var m = 0; m < A.length; m++) {
var L = A[m], R = w.indexOf(L);
R > -1 && w.splice(R, 1);
}
E = /* @__PURE__ */ new Set(), S = /* @__PURE__ */ new Map();
}
}
return p;
}, d.prototype.createDummyNodesForBendpoints = function(p) {
for (var g = [], y = p.source, b = this.graphManager.calcLowestCommonAncestor(p.source, p.target), m = 0; m < p.bendpoints.length; m++) {
var E = this.newNode(null);
E.setRect(new Point(0, 0), new Dimension(1, 1)), b.add(E);
var T = this.newEdge(null);
this.graphManager.add(T, y, E), g.add(E), y = E;
}
var T = this.newEdge(null);
return this.graphManager.add(T, y, p.target), this.edgeToDummyNodes.set(p, g), p.isInterGraph() ? this.graphManager.remove(p) : b.remove(p), g;
}, d.prototype.createBendpointsFromDummyNodes = function() {
var p = [];
p = p.concat(this.graphManager.getAllEdges()), p = [].concat(i(this.edgeToDummyNodes.keys())).concat(p);
for (var g = 0; g < p.length; g++) {
var y = p[g];
if (y.bendpoints.length > 0) {
for (var b = this.edgeToDummyNodes.get(y), m = 0; m < b.length; m++) {
var E = b[m], T = new c(E.getCenterX(), E.getCenterY()), S = y.bendpoints.get(m);
S.x = T.x, S.y = T.y, E.getOwner().remove(E);
}
this.graphManager.add(y, y.source, y.target);
}
}
}, d.transform = function(p, g, y, b) {
if (y != null && b != null) {
var m = g;
if (p <= 50) {
var E = g / y;
m -= (g - E) / 50 * (50 - p);
} else {
var T = g * b;
m += (T - g) / 50 * (p - 50);
}
return m;
} else {
var S, w;
return p <= 50 ? (S = 9 * g / 500, w = g / 10) : (S = 9 * g / 50, w = -8 * g), S * p + w;
}
}, d.findCenterOfTree = function(p) {
var g = [];
g = g.concat(p);
var y = [], b = /* @__PURE__ */ new Map(), m = !1, E = null;
(g.length == 1 || g.length == 2) && (m = !0, E = g[0]);
for (var T = 0; T < g.length; T++) {
var S = g[T], w = S.getNeighborsList().size;
b.set(S, S.getNeighborsList().size), w == 1 && y.push(S);
}
var x = [];
for (x = x.concat(y); !m; ) {
var C = [];
C = C.concat(x), x = [];
for (var T = 0; T < g.length; T++) {
var S = g[T], D = g.indexOf(S);
D >= 0 && g.splice(D, 1);
var A = S.getNeighborsList();
A.forEach(function(I) {
if (y.indexOf(I) < 0) {
var M = b.get(I), N = M - 1;
N == 1 && x.push(I), b.set(I, N);
}
});
}
y = y.concat(x), (g.length == 1 || g.length == 2) && (m = !0, E = g[0]);
}
return E;
}, d.prototype.setGraphManager = function(p) {
this.graphManager = p;
}, r.exports = d;
},
/* 16 */
/***/
function(r, a, n) {
function i() {
}
i.seed = 1, i.x = 0, i.nextDouble = function() {
return i.x = Math.sin(i.seed++) * 1e4, i.x - Math.floor(i.x);
}, r.exports = i;
},
/* 17 */
/***/
function(r, a, n) {
var i = n(4);
function s(o, u) {
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(o) {
this.lworldOrgX = o;
}, s.prototype.getWorldOrgY = function() {
return this.lworldOrgY;
}, s.prototype.setWorldOrgY = function(o) {
this.lworldOrgY = o;
}, s.prototype.getWorldExtX = function() {
return this.lworldExtX;
}, s.prototype.setWorldExtX = function(o) {
this.lworldExtX = o;
}, s.prototype.getWorldExtY = function() {
return this.lworldExtY;
}, s.prototype.setWorldExtY = function(o) {
this.lworldExtY = o;
}, s.prototype.getDeviceOrgX = function() {
return this.ldeviceOrgX;
}, s.prototype.setDeviceOrgX = function(o) {
this.ldeviceOrgX = o;
}, s.prototype.getDeviceOrgY = function() {
return this.ldeviceOrgY;
}, s.prototype.setDeviceOrgY = function(o) {
this.ldeviceOrgY = o;
}, s.prototype.getDeviceExtX = function() {
return this.ldeviceExtX;
}, s.prototype.setDeviceExtX = function(o) {
this.ldeviceExtX = o;
}, s.prototype.getDeviceExtY = function() {
return this.ldeviceExtY;
}, s.prototype.setDeviceExtY = function(o) {
this.ldeviceExtY = o;
}, s.prototype.transformX = function(o) {
var u = 0, l = this.lworldExtX;
return l != 0 && (u = this.ldeviceOrgX + (o - this.lworldOrgX) * this.ldeviceExtX / l), u;
}, s.prototype.transformY = function(o) {
var u = 0, l = this.lworldExtY;
return l != 0 && (u = this.ldeviceOrgY + (o - this.lworldOrgY) * this.ldeviceExtY / l), u;
}, s.prototype.inverseTransformX = function(o) {
var u = 0, l = this.ldeviceExtX;
return l != 0 && (u = this.lworldOrgX + (o - this.ldeviceOrgX) * this.lworldExtX / l), u;
}, s.prototype.inverseTransformY = function(o) {
var u = 0, l = this.ldeviceExtY;
return l != 0 && (u = this.lworldOrgY + (o - this.ldeviceOrgY) * this.lworldExtY / l), u;
}, s.prototype.inverseTransformPoint = function(o) {
var u = new i(this.inverseTransformX(o.x), this.inverseTransformY(o.y));
return u;
}, r.exports = s;
},
/* 18 */
/***/
function(r, a, n) {
function i(h) {
if (Array.isArray(h)) {
for (var d = 0, p = Array(h.length); d < h.length; d++)
p[d] = h[d];
return p;
} else
return Array.from(h);
}
var s = n(15), o = n(7), u = n(0), l = n(8), f = n(9);
function c() {
s.call(this), this.useSmartIdealEdgeLengthCalculation = o.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION, this.idealEdgeLength = o.DEFAULT_EDGE_LENGTH, this.springConstant = o.DEFAULT_SPRING_STRENGTH, this.repulsionConstant = o.DEFAULT_REPULSION_STRENGTH, this.gravityConstant = o.DEFAULT_GRAVITY_STRENGTH, this.compoundGravityConstant = o.DEFAULT_COMPOUND_GRAVITY_STRENGTH, this.gravityRangeFactor = o.DEFAULT_GRAVITY_RANGE_FACTOR, this.compoundGravityRangeFactor = o.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR, this.displacementThresholdPerNode = 3 * o.DEFAULT_EDGE_LENGTH / 100, this.coolingFactor = o.DEFAULT_COOLING_FACTOR_INCREMENTAL, this.initialCoolingFactor = o.DEFAULT_COOLING_FACTOR_INCREMENTAL, this.totalDisplacement = 0, this.oldTotalDisplacement = 0, this.maxIterations = o.MAX_ITERATIONS;
}
c.prototype = Object.create(s.prototype);
for (var v in s)
c[v] = s[v];
c.prototype.initParameters = function() {
s.prototype.initParameters.call(this, arguments), this.totalIterations = 0, this.notAnimatedIterations = 0, this.useFRGridVariant = o.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION, this.grid = [];
}, c.prototype.calcIdealEdgeLengths = function() {
for (var h, d, p, g, y, b, m = this.getGraphManager().getAllEdges(), E = 0; E < m.length; E++)
h = m[E], h.idealLength = this.idealEdgeLength, h.isInterGraph && (p = h.getSource(), g = h.getTarget(), y = h.getSourceInLca().getEstimatedSize(), b = h.getTargetInLca().getEstimatedSize(), this.useSmartIdealEdgeLengthCalculation && (h.idealLength += y + b - 2 * u.SIMPLE_NODE_SIZE), d = h.getLca().getInclusionTreeDepth(), h.idealLength += o.DEFAULT_EDGE_LENGTH * o.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR * (p.getInclusionTreeDepth() + g.getInclusionTreeDepth() - 2 * d));
}, c.prototype.initSpringEmbedder = function() {
var h = this.getAllNodes().length;
this.incremental ? (h > o.ADAPTATION_LOWER_NODE_LIMIT && (this.coolingFactor = Math.max(this.coolingFactor * o.COOLING_ADAPTATION_FACTOR, this.coolingFactor - (h - o.ADAPTATION_LOWER_NODE_LIMIT) / (o.ADAPTATION_UPPER_NODE_LIMIT - o.ADAPTATION_LOWER_NODE_LIMIT) * this.coolingFactor * (1 - o.COOLING_ADAPTATION_FACTOR))), this.maxNodeDisplacement = o.MAX_NODE_DISPLACEMENT_INCREMENTAL) : (h > o.ADAPTATION_LOWER_NODE_LIMIT ? this.coolingFactor = Math.max(o.COOLING_ADAPTATION_FACTOR, 1 - (h - o.ADAPTATION_LOWER_NODE_LIMIT) / (o.ADAPTATION_UPPER_NODE_LIMIT - o.ADAPTATION_LOWER_NODE_LIMIT) * (1 - o.COOLING_ADAPTATION_FACTOR)) : this.coolingFactor = 1, this.initialCoolingFactor = this.coolingFactor, this.maxNodeDisplacement = o.MAX_NODE_DISPLACEMENT), this.maxIterations = Math.max(this.getAllNodes().length * 5, this.maxIterations), this.totalDisplacementThreshold = this.displacementThresholdPerNode * this.getAllNodes().length, this.repulsionRange = this.calcRepulsionRange();
}, c.prototype.calcSpringForces = function() {
for (var h = this.getAllEdges(), d, p = 0; p < h.length; p++)
d = h[p], this.calcSpringForce(d, d.idealLength);
}, c.prototype.calcRepulsionForces = function() {
var h = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !0, d = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1, p, g, y, b, m = this.getAllNodes(), E;
if (this.useFRGridVariant)
for (this.totalIterations % o.GRID_CALCULATION_CHECK_PERIOD == 1 && h && this.updateGrid(), E = /* @__PURE__ */ new Set(), p = 0; p < m.length; p++)
y = m[p], this.calculateRepulsionForceOfANode(y, E, h, d), E.add(y);
else
for (p = 0; p < m.length; p++)
for (y = m[p], g = p + 1; g < m.length; g++)
b = m[g], y.getOwner() == b.getOwner() && this.calcRepulsionForce(y, b);
}, c.prototype.calcGravitationalForces = function() {
for (var h, d = this.getAllNodesToApplyGravitation(), p = 0; p < d.length; p++)
h = d[p], this.calcGravitationalForce(h);
}, c.prototype.moveNodes = function() {
for (var h = this.getAllNodes(), d, p = 0; p < h.length; p++)
d = h[p], d.move();
}, c.prototype.calcSpringForce = function(h, d) {
var p = h.getSource(), g = h.getTarget(), y, b, m, E;
if (this.uniformLeafNodeSizes && p.getChild() == null && g.getChild() == null)
h.updateLengthSimple();
else if (h.updateLength(), h.isOverlapingSourceAndTarget)
return;
y = h.getLength(), y != 0 && (b = this.springConstant * (y - d), m = b * (h.lengthX / y), E = b * (h.lengthY / y), p.springForceX += m, p.springForceY += E, g.springForceX -= m, g.springForceY -= E);
}, c.prototype.calcRepulsionForce = function(h, d) {
var p = h.getRect(), g = d.getRect(), y = new Array(2), b = new Array(4), m, E, T, S, w, x, C;
if (p.intersects(g)) {
l.calcSeparationAmount(p, g, y, o.DEFAULT_EDGE_LENGTH / 2), x = 2 * y[0], C = 2 * y[1];
var D = h.noOfChildren * d.noOfChildren / (h.noOfChildren + d.noOfChildren);
h.repulsionForceX -= D * x, h.repulsionForceY -= D * C, d.repulsionForceX += D * x, d.repulsionForceY += D * C;
} else
this.uniformLeafNodeSizes && h.getChild() == null && d.getChild() == null ? (m = g.getCenterX() - p.getCenterX(), E = g.getCenterY() - p.getCenterY()) : (l.getIntersection(p, g, b), m = b[2] - b[0], E = b[3] - b[1]), Math.abs(m) < o.MIN_REPULSION_DIST && (m = f.sign(m) * o.MIN_REPULSION_DIST), Math.abs(E) < o.MIN_REPULSION_DIST && (E = f.sign(E) * o.MIN_REPULSION_DIST), T = m * m + E * E, S = Math.sqrt(T), w = this.repulsionConstant * h.noOfChildren * d.noOfChildren / T, x = w * m / S, C = w * E / S, h.repulsionForceX -= x, h.repulsionForceY -= C, d.repulsionForceX += x, d.repulsionForceY += C;
}, c.prototype.calcGravitationalForce = function(h) {
var d, p, g, y, b, m, E, T;
d = h.getOwner(), p = (d.getRight() + d.getLeft()) / 2, g = (d.getTop() + d.getBottom()) / 2, y = h.getCenterX() - p, b = h.getCenterY() - g, m = Math.abs(y) + h.getWidth() / 2, E = Math.abs(b) + h.getHeight() / 2, h.getOwner() == this.graphManager.getRoot() ? (T = d.getEstimatedSize() * this.gravityRangeFactor, (m > T || E > T) && (h.gravitationForceX = -this.gravityConstant * y, h.gravitationForceY = -this.gravityConstant * b)) : (T = d.getEstimatedSize() * this.compoundGravityRangeFactor, (m > T || E > T) && (h.gravitationForceX = -this.gravityConstant * y * this.compoundGravityConstant, h.gravitationForceY = -this.gravityConstant * b * this.compoundGravityConstant));
}, c.prototype.isConverged = function() {
var h, d = !1;
return this.totalIterations > this.maxIterations / 3 && (d = Math.abs(this.totalDisplacement - this.oldTotalDisplacement) < 2), h = this.totalDisplacement < this.totalDisplacementThreshold, this.oldTotalDisplacement = this.totalDisplacement, h || d;
}, c.prototype.animate = function() {
this.animationDuringLayout && !this.isSubLayout && (this.notAnimatedIterations == this.animationPeriod ? (this.update(), this.notAnimatedIterations = 0) : this.notAnimatedIterations++);
}, c.prototype.calcNoOfChildrenForAllNodes = function() {
for (var h, d = this.graphManager.getAllNodes(), p = 0; p < d.length; p++)
h = d[p], h.noOfChildren = h.getNoOfChildren();
}, c.prototype.calcGrid = function(h) {
var d = 0, p = 0;
d = parseInt(Math.ceil((h.getRight() - h.getLeft()) / this.repulsionRange)), p = parseInt(Math.ceil((h.getBottom() - h.getTop()) / this.repulsionRange));
for (var g = new Array(d), y = 0; y < d; y++)
g[y] = new Array(p);
for (var y = 0; y < d; y++)
for (var b = 0; b < p; b++)
g[y][b] = new Array();
return g;
}, c.prototype.addNodeToGrid = function(h, d, p) {
var g = 0, y = 0, b = 0, m = 0;
g = parseInt(Math.floor((h.getRect().x - d) / this.repulsionRange)), y = parseInt(Math.floor((h.getRect().width + h.getRect().x - d) / this.repulsionRange)), b = parseInt(Math.floor((h.getRect().y - p) / this.repulsionRange)), m = parseInt(Math.floor((h.getRect().height + h.getRect().y - p) / this.repulsionRange));
for (var E = g; E <= y; E++)
for (var T = b; T <= m; T++)
this.grid[E][T].push(h), h.setGridCoordinates(g, y, b, m);
}, c.prototype.updateGrid = function() {
var h, d, p = this.getAllNodes();
for (this.grid = this.calcGrid(this.graphManager.getRoot()), h = 0; h < p.length; h++)
d = p[h], this.addNodeToGrid(d, this.graphManager.getRoot().getLeft(), this.graphManager.getRoot().getTop());
}, c.prototype.calculateRepulsionForceOfANode = function(h, d, p, g) {
if (this.totalIterations % o.GRID_CALCULATION_CHECK_PERIOD == 1 && p || g) {
var y = /* @__PURE__ */ new Set();
h.surrounding = new Array();
for (var b, m = this.grid, E = h.startX - 1; E < h.finishX + 2; E++)
for (var T = h.startY - 1; T < h.finishY + 2; T++)
if (!(E < 0 || T < 0 || E >= m.length || T >= m[0].length)) {
for (var S = 0; S < m[E][T].length; S++)
if (b = m[E][T][S], !(h.getOwner() != b.getOwner() || h == b) && !d.has(b) && !y.has(b)) {
var w = Math.abs(h.getCenterX() - b.getCenterX()) - (h.getWidth() / 2 + b.getWidth() / 2), x = Math.abs(h.getCenterY() - b.getCenterY()) - (h.getHeight() / 2 + b.getHeight() / 2);
w <= this.repulsionRange && x <= this.repulsionRange && y.add(b);
}
}
h.surrounding = [].concat(i(y));
}
for (E = 0; E < h.surrounding.length; E++)
this.calcRepulsionForce(h, h.surrounding[E]);
}, c.prototype.calcRepulsionRange = function() {
return 0;
}, r.exports = c;
},
/* 19 */
/***/
function(r, a, n) {
var i = n(1), s = n(7);
function o(l, f, c) {
i.call(this, l, f, c), this.idealLength = s.DEFAULT_EDGE_LENGTH;
}
o.prototype = Object.create(i.prototype);
for (var u in i)
o[u] = i[u];
r.exports = o;
},
/* 20 */
/***/
function(r, a, n) {
var i = n(3);
function s(u, l, f, c) {
i.call(this, u, l, f, c), 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 = [];
}
s.prototype = Object.create(i.prototype);
for (var o in i)
s[o] = i[o];
s.prototype.setGridCoordinates = function(u, l, f, c) {
this.startX = u, this.finishX = l, this.startY = f, this.finishY = c;
}, r.exports = s;
},
/* 21 */
/***/
function(r, a, n) {
function i(s, o) {
this.width = 0, this.height = 0, s !== null && o !== null && (this.height = o, this.width = s);
}
i.prototype.getWidth = function() {
return this.width;
}, i.prototype.setWidth = function(s) {
this.width = s;
}, i.prototype.getHeight = function() {
return this.height;
}, i.prototype.setHeight = function(s) {
this.height = s;
}, r.exports = i;
},
/* 22 */
/***/
function(r, a, n) {
var i = n(14);
function s() {
this.map = {}, this.keys = [];
}
s.prototype.put = function(o, u) {
var l = i.createID(o);
this.contains(l) || (this.map[l] = u, this.keys.push(o));
}, s.prototype.contains = function(o) {
return i.createID(o), this.map[o] != null;
}, s.prototype.get = function(o) {
var u = i.createID(o);
return this.map[u];
}, s.prototype.keySet = function() {
return this.keys;
}, r.exports = s;
},
/* 23 */
/***/
function(r, a, n) {
var i = n(14);
function s() {
this.set = {};
}
s.prototype.add = function(o) {
var u = i.createID(o);
this.contains(u) || (this.set[u] = o);
}, s.prototype.remove = function(o) {
delete this.set[i.createID(o)];
}, s.prototype.clear = function() {
this.set = {};
}, s.prototype.contains = function(o) {
return this.set[i.createID(o)] == o;
}, s.prototype.isEmpty = function() {
return this.size() === 0;
}, s.prototype.size = function() {
return Object.keys(this.set).length;
}, s.prototype.addAllTo = function(o) {
for (var u = Object.keys(this.set), l = u.length, f = 0; f < l; f++)
o.push(this.set[u[f]]);
}, s.prototype.size = function() {
return Object.keys(this.set).length;
}, s.prototype.addAll = function(o) {
for (var u = o.length, l = 0; l < u; l++) {
var f = o[l];
this.add(f);
}
}, r.exports = s;
},
/* 24 */
/***/
function(r, a, n) {
var i = function() {
function l(f, c) {
for (var v = 0; v < c.length; v++) {
var h = c[v];
h.enumerable = h.enumerable || !1, h.configurable = !0, "value" in h && (h.writable = !0), Object.defineProperty(f, h.key, h);
}
}
return function(f, c, v) {
return c && l(f.prototype, c), v && l(f, v), f;
};
}();
function s(l, f) {
if (!(l instanceof f))
throw new TypeError("Cannot call a class as a function");
}
var o = n(11), u = function() {
function l(f, c) {
s(this, l), (c !== null || c !== void 0) && (this.compareFunction = this._defaultCompareFunction);
var v = void 0;
f instanceof o ? v = f.size() : v = f.length, this._quicksort(f, 0, v - 1);
}
return i(l, [{
key: "_quicksort",
value: function(c, v, h) {
if (v < h) {
var d = this._partition(c, v, h);
this._quicksort(c, v, d), this._quicksort(c, d + 1, h);
}
}
}, {
key: "_partition",
value: function(c, v, h) {
for (var d = this._get(c, v), p = v, g = h; ; ) {
for (; this.compareFunction(d, this._get(c, g)); )
g--;
for (; this.compareFunction(this._get(c, p), d); )
p++;
if (p < g)
this._swap(c, p, g), p++, g--;
else
return g;
}
}
}, {
key: "_get",
value: function(c, v) {
return c instanceof o ? c.get_object_at(v) : c[v];
}
}, {
key: "_set",
value: function(c, v, h) {
c instanceof o ? c.set_object_at(v, h) : c[v] = h;
}
}, {
key: "_swap",
value: function(c, v, h) {
var d = this._get(c, v);
this._set(c, v, this._get(c, h)), this._set(c, h, d);
}
}, {
key: "_defaultCompareFunction",
value: function(c, v) {
return v > c;
}
}]), l;
}();
r.exports = u;
},
/* 25 */
/***/
function(r, a, n) {
var i = function() {
function u(l, f) {
for (var c = 0; c < f.length; c++) {
var v = f[c];
v.enumerable = v.enumerable || !1, v.configurable = !0, "value" in v && (v.writable = !0), Object.defineProperty(l, v.key, v);
}
}
return function(l, f, c) {
return f && u(l.prototype, f), c && u(l, c), l;
};
}();
function s(u, l) {
if (!(u instanceof l))
throw new TypeError("Cannot call a class as a function");
}
var o = function() {
function u(l, f) {
var c = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1, v = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : -1, h = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : -1;
s(this, u), this.sequence1 = l, this.sequence2 = f, this.match_score = c, this.mismatch_penalty = v, this.gap_penalty = h, this.iMax = l.length + 1, this.jMax = f.length + 1, this.grid = new Array(this.iMax);
for (var d = 0; d < this.iMax; d++) {
this.grid[d] = new Array(this.jMax);
for (var p = 0; p < this.jMax; p++)
this.grid[d][p] = 0;
}
this.tracebackGrid = new Array(this.iMax);
for (var g = 0; g < this.iMax; g++) {
this.tracebackGrid[g] = new Array(this.jMax);
for (var y = 0; y < this.jMax; y++)
this.tracebackGrid[g][y] = [null, null, null];
}
this.alignments = [], this.score = -1, this.computeGrids();
}
return i(u, [{
key: "getScore",
value: function() {
return this.score;
}
}, {
key: "getAlignments",
value: function() {
return this.alignments;
}
// Main dynamic programming procedure
}, {
key: "computeGrids",
value: function() {
for (var f = 1; f < this.jMax; f++)
this.grid[0][f] = this.grid[0][f - 1] + this.gap_penalty, this.tracebackGrid[0][f] = [!1, !1, !0];
for (var c = 1; c < this.iMax; c++)
this.grid[c][0] = this.grid[c - 1][0] + this.gap_penalty, this.tracebackGrid[c][0] = [!1, !0, !1];
for (var v = 1; v < this.iMax; v++)
for (var h = 1; h < this.jMax; h++) {
var d = void 0;
this.sequence1[v - 1] === this.sequence2[h - 1] ? d = this.grid[v - 1][h - 1] + this.match_score : d = this.grid[v - 1][h - 1] + this.mismatch_penalty;
var p = this.grid[v - 1][h] + this.gap_penalty, g = this.grid[v][h - 1] + this.gap_penalty, y = [d, p, g], b = this.arrayAllMaxIndexes(y);
this.grid[v][h] = y[b[0]], this.tracebackGrid[v][h] = [b.includes(0), b.includes(1), b.includes(2)];
}
this.score = this.grid[this.iMax - 1][this.jMax - 1];
}
// Gets all possible valid sequence combinations
}, {
key: "alignmentTraceback",
value: function() {
var f = [];
for (f.push({
pos: [this.sequence1.length, this.sequence2.length],
seq1: "",
seq2: ""
}); f[0]; ) {
var c = f[0], v = this.tracebackGrid[c.pos[0]][c.pos[1]];
v[0] && f.push({
pos: [c.pos[0] - 1, c.pos[1] - 1],
seq1: this.sequence1[c.pos[0] - 1] + c.seq1,
seq2: this.sequence2[c.pos[1] - 1] + c.seq2
}), v[1] && f.push({
pos: [c.pos[0] - 1, c.pos[1]],
seq1: this.sequence1[c.pos[0] - 1] + c.seq1,
seq2: "-" + c.seq2
}), v[2] && f.push({
pos: [c.pos[0], c.pos[1] - 1],
seq1: "-" + c.seq1,
seq2: this.sequence2[c.pos[1] - 1] + c.seq2
}), c.pos[0] === 0 && c.pos[1] === 0 && this.alignments.push({
sequence1: c.seq1,
sequence2: c.seq2
}), f.shift();
}
return this.alignments;
}
// Helper Functions
}, {
key: "getAllIndexes",
value: function(f, c) {
for (var v = [], h = -1; (h = f.indexOf(c, h + 1)) !== -1; )
v.push(h);
return v;
}
}, {
key: "arrayAllMaxIndexes",
value: function(f) {
return this.getAllIndexes(f, Math.max.apply(null, f));
}
}]), u;
}();
r.exports = o;
},
/* 26 */
/***/
function(r, a, n) {
var i = function() {
};
i.FDLayout = n(18), i.FDLayoutConstants = n(7), i.FDLayoutEdge = n(19), i.FDLayoutNode = n(20), i.DimensionD = n(21), i.HashMap = n(22), i.HashSet = n(23), i.IGeometry = n(8), i.IMath = n(9), i.Integer = n(10), i.Point = n(12), i.PointD = n(4), i.RandomSeed = n(16), i.RectangleD = n(13), i.Transform = n(17), i.UniqueIDGeneretor = n(14), i.Quicksort = n(24), i.LinkedList = n(11), i.LGraphObject = n(2), i.LGraph = n(5), i.LEdge = n(1), i.LGraphManager = n(6), i.LNode = n(3), i.Layout = n(15), i.LayoutConstants = n(0), i.NeedlemanWunsch = n(25), r.exports = i;
},
/* 27 */
/***/
function(r, a, n) {
function i() {
this.listeners = [];
}
var s = i.prototype;
s.addListener = function(o, u) {
this.listeners.push({
event: o,
callback: u
});
}, s.removeListener = function(o, u) {
for (var l = this.listeners.length; l >= 0; l--) {
var f = this.listeners[l];
f.event === o && f.callback === u && this.listeners.splice(l, 1);
}
}, s.emit = function(o, u) {
for (var l = 0; l < this.listeners.length; l++) {
var f = this.listeners[l];
o === f.event && f.callback(u);
}
}, r.exports = i;
}
/******/
])
);
});
}(ks)), ks.exports;
}
var cf;
function a0() {
return cf || (cf = 1, function(t, e) {
(function(a, n) {
t.exports = n(r0());
})(ro, function(r) {
return (
/******/
function(a) {
var n = {};
function i(s) {
if (n[s])
return n[s].exports;
var o = n[s] = {
/******/
i: s,
/******/
l: !1,
/******/
exports: {}
/******/
};
return a[s].call(o.exports, o, o.exports, i), o.l = !0, o.exports;
}
return i.m = a, i.c = n, i.i = function(s) {
return s;
}, i.d = function(s, o, u) {
i.o(s, o) || Object.defineProperty(s, o, {
/******/
configurable: !1,
/******/
enumerable: !0,
/******/
get: u
/******/
});
}, i.n = function(s) {
var o = s && s.__esModule ? (
/******/
function() {
return s.default;
}
) : (
/******/
function() {
return s;
}
);
return i.d(o, "a", o), o;
}, i.o = function(s, o) {
return Object.prototype.hasOwnProperty.call(s, o);
}, i.p = "", i(i.s = 7);
}([
/* 0 */
/***/
function(a, n) {
a.exports = r;
},
/* 1 */
/***/
function(a, n, i) {
var s = i(0).FDLayoutConstants;
function o() {
}
for (var u in s)
o[u] = s[u];
o.DEFAULT_USE_MULTI_LEVEL_SCALING = !1, o.DEFAULT_RADIAL_SEPARATION = s.DEFAULT_EDGE_LENGTH, o.DEFAULT_COMPONENT_SEPERATION = 60, o.TILE = !0, o.TILING_PADDING_VERTICAL = 10, o.TILING_PADDING_HORIZONTAL = 10, o.TREE_REDUCTION_ON_INCREMENTAL = !1, a.exports = o;
},
/* 2 */
/***/
function(a, n, i) {
var s = i(0).FDLayoutEdge;
function o(l, f, c) {
s.call(this, l, f, c);
}
o.prototype = Object.create(s.prototype);
for (var u in s)
o[u] = s[u];
a.exports = o;
},
/* 3 */
/***/
function(a, n, i) {
var s = i(0).LGraph;
function o(l, f, c) {
s.call(this, l, f, c);
}
o.prototype = Object.create(s.prototype);
for (var u in s)
o[u] = s[u];
a.exports = o;
},
/* 4 */
/***/
function(a, n, i) {
var s = i(0).LGraphManager;
function o(l) {
s.call(this, l);
}
o.prototype = Object.create(s.prototype);
for (var u in s)
o[u] = s[u];
a.exports = o;
},
/* 5 */
/***/
function(a, n, i) {
var s = i(0).FDLayoutNode, o = i(0).IMath;
function u(f, c, v, h) {
s.call(this, f, c, v, h);
}
u.prototype = Object.create(s.prototype);
for (var l in s)
u[l] = s[l];
u.prototype.move = function() {
var f = this.graphManager.getLayout();
this.displacementX = f.coolingFactor * (this.springForceX + this.repulsionForceX + this.gravitationForceX) / this.noOfChildren, this.displacementY = f.coolingFactor * (this.springForceY + this.repulsionForceY + this.gravitationForceY) / this.noOfChildren, Math.abs(this.displacementX) > f.coolingFactor * f.maxNodeDisplacement && (this.displacementX = f.coolingFactor * f.maxNodeDisplacement * o.sign(this.displacementX)), Math.abs(this.displacementY) > f.coolingFactor * f.maxNodeDisplacement && (this.displacementY = f.coolingFactor * f.maxNodeDisplacement * o.sign(this.displacementY)), this.child == null ? this.moveBy(this.displacementX, this.displacementY) : this.child.getNodes().length == 0 ? this.moveBy(this.displacementX, this.displacementY) : this.propogateDisplacementToChildren(this.displacementX, this.displacementY), f.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;
}, u.prototype.propogateDisplacementToChildren = function(f, c) {
for (var v = this.getChild().getNodes(), h, d = 0; d < v.length; d++)
h = v[d], h.getChild() == null ? (h.moveBy(f, c), h.displacementX += f, h.displacementY += c) : h.propogateDisplacementToChildren(f, c);
}, u.prototype.setPred1 = function(f) {
this.pred1 = f;
}, u.prototype.getPred1 = function() {
return pred1;
}, u.prototype.getPred2 = function() {
return pred2;
}, u.prototype.setNext = function(f) {
this.next = f;
}, u.prototype.getNext = function() {
return next;
}, u.prototype.setProcessed = function(f) {
this.processed = f;
}, u.prototype.isProcessed = function() {
return processed;
}, a.exports = u;
},
/* 6 */
/***/
function(a, n, i) {
var s = i(0).FDLayout, o = i(4), u = i(3), l = i(5), f = i(2), c = i(1), v = i(0).FDLayoutConstants, h = i(0).LayoutConstants, d = i(0).Point, p = i(0).PointD, g = i(0).Layout, y = i(0).Integer, b = i(0).IGeometry, m = i(0).LGraph, E = i(0).Transform;
function T() {
s.call(this), this.toBeTiled = {};
}
T.prototype = Object.create(s.prototype);
for (var S in s)
T[S] = s[S];
T.prototype.newGraphManager = function() {
var w = new o(this);
return this.graphManager = w, w;
}, T.prototype.newGraph = function(w) {
return new u(null, this.graphManager, w);
}, T.prototype.newNode = function(w) {
return new l(this.graphManager, w);
}, T.prototype.newEdge = function(w) {
return new f(null, null, w);
}, T.prototype.initParameters = function() {
s.prototype.initParameters.call(this, arguments), this.isSubLayout || (c.DEFAULT_EDGE_LENGTH < 10 ? this.idealEdgeLength = 10 : this.idealEdgeLength = c.DEFAULT_EDGE_LENGTH, this.useSmartIdealEdgeLengthCalculation = c.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION, this.springConstant = v.DEFAULT_SPRING_STRENGTH, this.repulsionConstant = v.DEFAULT_REPULSION_STRENGTH, this.gravityConstant = v.DEFAULT_GRAVITY_STRENGTH, this.compoundGravityConstant = v.DEFAULT_COMPOUND_GRAVITY_STRENGTH, this.gravityRangeFactor = v.DEFAULT_GRAVITY_RANGE_FACTOR, this.compoundGravityRangeFactor = v.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR, this.prunedNodesAll = [], this.growTreeIterations = 0, this.afterGrowthIterations = 0, this.isTreeGrowing = !1, this.isGrowthFinished = !1, this.coolingCycle = 0, this.maxCoolingCycle = this.maxIterations / v.CONVERGENCE_CHECK_PERIOD, this.finalTemperature = v.CONVERGENCE_CHECK_PERIOD / this.maxIterations, this.coolingAdjuster = 1);
}, T.prototype.layout = function() {
var w = h.DEFAULT_CREATE_BENDS_AS_NEEDED;
return w && (this.createBendpoints(), this.graphManager.resetAllEdges()), this.level = 0, this.classicLayout();
}, T.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 (c.TREE_REDUCTION_ON_INCREMENTAL) {
this.reduceTrees(), this.graphManager.resetAllNodesToApplyGravitation();
var x = new Set(this.getAllNodes()), C = this.nodesWithGravity.filter(function(L) {
return x.has(L);
});
this.graphManager.setAllNodesToApplyGravitation(C);
}
} else {
var w = this.getFlatForest();
if (w.length > 0)
this.positionNodesRadially(w);
else {
this.reduceTrees(), this.graphManager.resetAllNodesToApplyGravitation();
var x = new Set(this.getAllNodes()), C = this.nodesWithGravity.filter(function(D) {
return x.has(D);
});
this.graphManager.setAllNodesToApplyGravitation(C), this.positionNodesRandomly();
}
}
return this.initSpringEmbedder(), this.runSpringEmbedder(), !0;
}, T.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 % v.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 w = new Set(this.getAllNodes()), x = this.nodesWithGravity.filter(function(A) {
return w.has(A);
});
this.graphManager.setAllNodesToApplyGravitation(x), this.graphManager.updateBounds(), this.updateGrid(), this.coolingFactor = v.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()), this.coolingFactor = v.DEFAULT_COOLING_FACTOR_INCREMENTAL * ((100 - this.afterGrowthIterations) / 100), this.afterGrowthIterations++;
}
var C = !this.isTreeGrowing && !this.isGrowthFinished, D = this.growTreeIterations % 10 == 1 && this.isTreeGrowing || this.afterGrowthIterations % 10 == 1 && this.isGrowthFinished;
return this.totalDisplacement = 0, this.graphManager.updateBounds(), this.calcSpringForces(), this.calcRepulsionForces(C, D), this.calcGravitationalForces(), this.moveNodes(), this.animate(), !1;
}, T.prototype.getPositionsData = function() {
for (var w = this.graphManager.getAllNodes(), x = {}, C = 0; C < w.length; C++) {
var D = w[C].rect, A = w[C].id;
x[A] = {
id: A,
x: D.getCenterX(),
y: D.getCenterY(),
w: D.width,
h: D.height
};
}
return x;
}, T.prototype.runSpringEmbedder = function() {
this.initialAnimationPeriod = 25, this.animationPeriod = this.initialAnimationPeriod;
var w = !1;
if (v.ANIMATE === "during")
this.emit("layoutstarted");
else {
for (; !w; )
w = this.tick();
this.graphManager.updateBounds();
}
}, T.prototype.calculateNodesToApplyGravitationTo = function() {
var w = [], x, C = this.graphManager.getGraphs(), D = C.length, A;
for (A = 0; A < D; A++)
x = C[A], x.updateConnected(), x.isConnected || (w = w.concat(x.getNodes()));
return w;
}, T.prototype.createBendpoints = function() {
var w = [];
w = w.concat(this.graphManager.getAllEdges());
var x = /* @__PURE__ */ new Set(), C;
for (C = 0; C < w.length; C++) {
var D = w[C];
if (!x.has(D)) {
var A = D.getSource(), L = D.getTarget();
if (A == L)
D.getBendpoints().push(new p()), D.getBendpoints().push(new p()), this.createDummyNodesForBendpoints(D), x.add(D);
else {
var R = [];
if (R = R.concat(A.getEdgeListToNode(L)), R = R.concat(L.getEdgeListToNode(A)), !x.has(R[0])) {
if (R.length > 1) {
var I;
for (I = 0; I < R.length; I++) {
var M = R[I];
M.getBendpoints().push(new p()), this.createDummyNodesForBendpoints(M);
}
}
R.forEach(function(N) {
x.add(N);
});
}
}
}
if (x.size == w.length)
break;
}
}, T.prototype.positionNodesRadially = function(w) {
for (var x = new d(0, 0), C = Math.ceil(Math.sqrt(w.length)), D = 0, A = 0, L = 0, R = new p(0, 0), I = 0; I < w.length; I++) {
I % C == 0 && (L = 0, A = D, I != 0 && (A += c.DEFAULT_COMPONENT_SEPERATION), D = 0);
var M = w[I], N = g.findCenterOfTree(M);
x.x = L, x.y = A, R = T.radialLayout(M, N, x), R.y > D && (D = Math.floor(R.y)), L = Math.floor(R.x + c.DEFAULT_COMPONENT_SEPERATION);
}
this.transform(new p(h.WORLD_CENTER_X - R.x / 2, h.WORLD_CENTER_Y - R.y / 2));
}, T.radialLayout = function(w, x, C) {
var D = Math.max(this.maxDiagonalInTree(w), c.DEFAULT_RADIAL_SEPARATION);
T.branchRadialLayout(x, null, 0, 359, 0, D);
var A = m.calculateBounds(w), L = new E();
L.setDeviceOrgX(A.getMinX()), L.setDeviceOrgY(A.getMinY()), L.setWorldOrgX(C.x), L.setWorldOrgY(C.y);
for (var R = 0; R < w.length; R++) {
var I = w[R];
I.transform(L);
}
var M = new p(A.getMaxX(), A.getMaxY());
return L.inverseTransformPoint(M);
}, T.branchRadialLayout = function(w, x, C, D, A, L) {
var R = (D - C + 1) / 2;
R < 0 && (R += 180);
var I = (R + C) % 360, M = I * b.TWO_PI / 360, N = A * Math.cos(M), O = A * Math.sin(M);
w.setCenter(N, O);
var k = [];
k = k.concat(w.getEdges());
var B = k.length;
x != null && B--;
for (var _ = 0, F = k.length, G, H = w.getEdgesBetween(x); H.length > 1; ) {
var Y = H[0];
H.splice(0, 1);
var X = k.indexOf(Y);
X >= 0 && k.splice(X, 1), F--, B--;
}
x != null ? G = (k.indexOf(H[0]) + 1) % F : G = 0;
for (var W = Math.abs(D - C) / B, ee = G; _ != B; ee = ++ee % F) {
var ae = k[ee].getOtherEnd(w);
if (ae != x) {
var J = (C + _ * W) % 360, z = (J + W) % 360;
T.branchRadialLayout(ae, w, J, z, A + L, L), _++;
}
}
}, T.maxDiagonalInTree = function(w) {
for (var x = y.MIN_VALUE, C = 0; C < w.length; C++) {
var D = w[C], A = D.getDiagonal();
A > x && (x = A);
}
return x;
}, T.prototype.calcRepulsionRange = function() {
return 2 * (this.level + 1) * this.idealEdgeLength;
}, T.prototype.groupZeroDegreeMembers = function() {
var w = this, x = {};
this.memberGroups = {}, this.idToDummyNode = {};
for (var C = [], D = this.graphManager.getAllNodes(), A = 0; A < D.length; A++) {
var L = D[A], R = L.getParent();
this.getNodeDegreeWithChildren(L) === 0 && (R.id == null || !this.getToBeTiled(R)) && C.push(L);
}
for (var A = 0; A < C.length; A++) {
var L = C[A], I = L.getParent().id;
typeof x[I] > "u" && (x[I] = []), x[I] = x[I].concat(L);
}
Object.keys(x).forEach(function(M) {
if (x[M].length > 1) {
var N = "DummyCompound_" + M;
w.memberGroups[N] = x[M];
var O = x[M][0].getParent(), k = new l(w.graphManager);
k.id = N, k.paddingLeft = O.paddingLeft || 0, k.paddingRight = O.paddingRight || 0, k.paddingBottom = O.paddingBottom || 0, k.paddingTop = O.paddingTop || 0, w.idToDummyNode[N] = k;
var B = w.getGraphManager().add(w.newGraph(), k), _ = O.getChild();
_.add(k);
for (var F = 0; F < x[M].length; F++) {
var G = x[M][F];
_.remove(G), B.add(G);
}
}
});
}, T.prototype.clearCompounds = function() {
var w = {}, x = {};
this.performDFSOnCompounds();
for (var C = 0; C < this.compoundOrder.length; C++)
x[this.compoundOrder[C].id] = this.compoundOrder[C], w[this.compoundOrder[C].id] = [].concat(this.compoundOrder[C].getChild().getNodes()), this.graphManager.remove(this.compoundOrder[C].getChild()), this.compoundOrder[C].child = null;
this.graphManager.resetAllNodes(), this.tileCompoundMembers(w, x);
}, T.prototype.clearZeroDegreeMembers = function() {
var w = this, x = this.tiledZeroDegreePack = [];
Object.keys(this.memberGroups).forEach(function(C) {
var D = w.idToDummyNode[C];
x[C] = w.tileNodes(w.memberGroups[C], D.paddingLeft + D.paddingRight), D.rect.width = x[C].width, D.rect.height = x[C].height;
});
}, T.prototype.repopulateCompounds = function() {
for (var w = this.compoundOrder.length - 1; w >= 0; w--) {
var x = this.compoundOrder[w], C = x.id, D = x.paddingLeft, A = x.paddingTop;
this.adjustLocations(this.tiledMemberPack[C], x.rect.x, x.rect.y, D, A);
}
}, T.prototype.repopulateZeroDegreeMembers = function() {
var w = this, x = this.tiledZeroDegreePack;
Object.keys(x).forEach(function(C) {
var D = w.idToDummyNode[C], A = D.paddingLeft, L = D.paddingTop;
w.adjustLocations(x[C], D.rect.x, D.rect.y, A, L);
});
}, T.prototype.getToBeTiled = function(w) {
var x = w.id;
if (this.toBeTiled[x] != null)
return this.toBeTiled[x];
var C = w.getChild();
if (C == null)
return this.toBeTiled[x] = !1, !1;
for (var D = C.getNodes(), A = 0; A < D.length; A++) {
var L = D[A];
if (this.getNodeDegree(L) > 0)
return this.toBeTiled[x] = !1, !1;
if (L.getChild() == null) {
this.toBeTiled[L.id] = !1;
continue;
}
if (!this.getToBeTiled(L))
return this.toBeTiled[x] = !1, !1;
}
return this.toBeTiled[x] = !0, !0;
}, T.prototype.getNodeDegree = function(w) {
w.id;
for (var x = w.getEdges(), C = 0, D = 0; D < x.length; D++) {
var A = x[D];
A.getSource().id !== A.getTarget().id && (C = C + 1);
}
return C;
}, T.prototype.getNodeDegreeWithChildren = function(w) {
var x = this.getNodeDegree(w);
if (w.getChild() == null)
return x;
for (var C = w.getChild().getNodes(), D = 0; D < C.length; D++) {
var A = C[D];
x += this.getNodeDegreeWithChildren(A);
}
return x;
}, T.prototype.performDFSOnCompounds = function() {
this.compoundOrder = [], this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes());
}, T.prototype.fillCompexOrderByDFS = function(w) {
for (var x = 0; x < w.length; x++) {
var C = w[x];
C.getChild() != null && this.fillCompexOrderByDFS(C.getChild().getNodes()), this.getToBeTiled(C) && this.compoundOrder.push(C);
}
}, T.prototype.adjustLocations = function(w, x, C, D, A) {
x += D, C += A;
for (var L = x, R = 0; R < w.rows.length; R++) {
var I = w.rows[R];
x = L;
for (var M = 0, N = 0; N < I.length; N++) {
var O = I[N];
O.rect.x = x, O.rect.y = C, x += O.rect.width + w.horizontalPadding, O.rect.height > M && (M = O.rect.height);
}
C += M + w.verticalPadding;
}
}, T.prototype.tileCompoundMembers = function(w, x) {
var C = this;
this.tiledMemberPack = [], Object.keys(w).forEach(function(D) {
var A = x[D];
C.tiledMemberPack[D] = C.tileNodes(w[D], A.paddingLeft + A.paddingRight), A.rect.width = C.tiledMemberPack[D].width, A.rect.height = C.tiledMemberPack[D].height;
});
}, T.prototype.tileNodes = function(w, x) {
var C = c.TILING_PADDING_VERTICAL, D = c.TILING_PADDING_HORIZONTAL, A = {
rows: [],
rowWidth: [],
rowHeight: [],
width: 0,
height: x,
// assume minHeight equals to minWidth
verticalPadding: C,
horizontalPadding: D
};
w.sort(function(I, M) {
return I.rect.width * I.rect.height > M.rect.width * M.rect.height ? -1 : I.rect.width * I.rect.height < M.rect.width * M.rect.height ? 1 : 0;
});
for (var L = 0; L < w.length; L++) {
var R = w[L];
A.rows.length == 0 ? this.insertNodeToRow(A, R, 0, x) : this.canAddHorizontal(A, R.rect.width, R.rect.height) ? this.insertNodeToRow(A, R, this.getShortestRowIndex(A), x) : this.insertNodeToRow(A, R, A.rows.length, x), this.shiftToLastRow(A);
}
return A;
}, T.prototype.insertNodeToRow = function(w, x, C, D) {
var A = D;
if (C == w.rows.length) {
var L = [];
w.rows.push(L), w.rowWidth.push(A), w.rowHeight.push(0);
}
var R = w.rowWidth[C] + x.rect.width;
w.rows[C].length > 0 && (R += w.horizontalPadding), w.rowWidth[C] = R, w.width < R && (w.width = R);
var I = x.rect.height;
C > 0 && (I += w.verticalPadding);
var M = 0;
I > w.rowHeight[C] && (M = w.rowHeight[C], w.rowHeight[C] = I, M = w.rowHeight[C] - M), w.height += M, w.rows[C].push(x);
}, T.prototype.getShortestRowIndex = function(w) {
for (var x = -1, C = Number.MAX_VALUE, D = 0; D < w.rows.length; D++)
w.rowWidth[D] < C && (x = D, C = w.rowWidth[D]);
return x;
}, T.prototype.getLongestRowIndex = function(w) {
for (var x = -1, C = Number.MIN_VALUE, D = 0; D < w.rows.length; D++)
w.rowWidth[D] > C && (x = D, C = w.rowWidth[D]);
return x;
}, T.prototype.canAddHorizontal = function(w, x, C) {
var D = this.getShortestRowIndex(w);
if (D < 0)
return !0;
var A = w.rowWidth[D];
if (A + w.horizontalPadding + x <= w.width)
return !0;
var L = 0;
w.rowHeight[D] < C && D > 0 && (L = C + w.verticalPadding - w.rowHeight[D]);
var R;
w.width - A >= x + w.horizontalPadding ? R = (w.height + L) / (A + x + w.horizontalPadding) : R = (w.height + L) / w.width, L = C + w.verticalPadding;
var I;
return w.width < x ? I = (w.height + L) / x : I = (w.height + L) / w.width, I < 1 && (I = 1 / I), R < 1 && (R = 1 / R), R < I;
}, T.prototype.shiftToLastRow = function(w) {
var x = this.getLongestRowIndex(w), C = w.rowWidth.length - 1, D = w.rows[x], A = D[D.length - 1], L = A.width + w.horizontalPadding;
if (w.width - w.rowWidth[C] > L && x != C) {
D.splice(-1, 1), w.rows[C].push(A), w.rowWidth[x] = w.rowWidth[x] - L, w.rowWidth[C] = w.rowWidth[C] + L, w.width = w.rowWidth[instance.getLongestRowIndex(w)];
for (var R = Number.MIN_VALUE, I = 0; I < D.length; I++)
D[I].height > R && (R = D[I].height);
x > 0 && (R += w.verticalPadding);
var M = w.rowHeight[x] + w.rowHeight[C];
w.rowHeight[x] = R, w.rowHeight[C] < A.height + w.verticalPadding && (w.rowHeight[C] = A.height + w.verticalPadding);
var N = w.rowHeight[x] + w.rowHeight[C];
w.height += N - M, this.shiftToLastRow(w);
}
}, T.prototype.tilingPreLayout = function() {
c.TILE && (this.groupZeroDegreeMembers(), this.clearCompounds(), this.clearZeroDegreeMembers());
}, T.prototype.tilingPostLayout = function() {
c.TILE && (this.repopulateZeroDegreeMembers(), this.repopulateCompounds());
}, T.prototype.reduceTrees = function() {
for (var w = [], x = !0, C; x; ) {
var D = this.graphManager.getAllNodes(), A = [];
x = !1;
for (var L = 0; L < D.length; L++)
C = D[L], C.getEdges().length == 1 && !C.getEdges()[0].isInterGraph && C.getChild() == null && (A.push([C, C.getEdges()[0], C.getOwner()]), x = !0);
if (x == !0) {
for (var R = [], I = 0; I < A.length; I++)
A[I][0].getEdges().length == 1 && (R.push(A[I]), A[I][0].getOwner().remove(A[I][0]));
w.push(R), this.graphManager.resetAllNodes(), this.graphManager.resetAllEdges();
}
}
this.prunedNodesAll = w;
}, T.prototype.growTree = function(w) {
for (var x = w.length, C = w[x - 1], D, A = 0; A < C.length; A++)
D = C[A], this.findPlaceforPrunedNode(D), D[2].add(D[0]), D[2].add(D[1], D[1].source, D[1].target);
w.splice(w.length - 1, 1), this.graphManager.resetAllNodes(), this.graphManager.resetAllEdges();
}, T.prototype.findPlaceforPrunedNode = function(w) {
var x, C, D = w[0];
D == w[1].source ? C = w[1].target : C = w[1].source;
var A = C.startX, L = C.finishX, R = C.startY, I = C.finishY, M = 0, N = 0, O = 0, k = 0, B = [M, O, N, k];
if (R > 0)
for (var _ = A; _ <= L; _++)
B[0] += this.grid[_][R - 1].length + this.grid[_][R].length - 1;
if (L < this.grid.length - 1)
for (var _ = R; _ <= I; _++)
B[1] += this.grid[L + 1][_].length + this.grid[L][_].length - 1;
if (I < this.grid[0].length - 1)
for (var _ = A; _ <= L; _++)
B[2] += this.grid[_][I + 1].length + this.grid[_][I].length - 1;
if (A > 0)
for (var _ = R; _ <= I; _++)
B[3] += this.grid[A - 1][_].length + this.grid[A][_].length - 1;
for (var F = y.MAX_VALUE, G, H, Y = 0; Y < B.length; Y++)
B[Y] < F ? (F = B[Y], G = 1, H = Y) : B[Y] == F && G++;
if (G == 3 && F == 0)
B[0] == 0 && B[1] == 0 && B[2] == 0 ? x = 1 : B[0] == 0 && B[1] == 0 && B[3] == 0 ? x = 0 : B[0] == 0 && B[2] == 0 && B[3] == 0 ? x = 3 : B[1] == 0 && B[2] == 0 && B[3] == 0 && (x = 2);
else if (G == 2 && F == 0) {
var X = Math.floor(Math.random() * 2);
B[0] == 0 && B[1] == 0 ? X == 0 ? x = 0 : x = 1 : B[0] == 0 && B[2] == 0 ? X == 0 ? x = 0 : x = 2 : B[0] == 0 && B[3] == 0 ? X == 0 ? x = 0 : x = 3 : B[1] == 0 && B[2] == 0 ? X == 0 ? x = 1 : x = 2 : B[1] == 0 && B[3] == 0 ? X == 0 ? x = 1 : x = 3 : X == 0 ? x = 2 : x = 3;
} else if (G == 4 && F == 0) {
var X = Math.floor(Math.random() * 4);
x = X;
} else
x = H;
x == 0 ? D.setCenter(C.getCenterX(), C.getCenterY() - C.getHeight() / 2 - v.DEFAULT_EDGE_LENGTH - D.getHeight() / 2) : x == 1 ? D.setCenter(C.getCenterX() + C.getWidth() / 2 + v.DEFAULT_EDGE_LENGTH + D.getWidth() / 2, C.getCenterY()) : x == 2 ? D.setCenter(C.getCenterX(), C.getCenterY() + C.getHeight() / 2 + v.DEFAULT_EDGE_LENGTH + D.getHeight() / 2) : D.setCenter(C.getCenterX() - C.getWidth() / 2 - v.DEFAULT_EDGE_LENGTH - D.getWidth() / 2, C.getCenterY());
}, a.exports = T;
},
/* 7 */
/***/
function(a, n, i) {
var s = {};
s.layoutBase = i(0), s.CoSEConstants = i(1), s.CoSEEdge = i(2), s.CoSEGraph = i(3), s.CoSEGraphManager = i(4), s.CoSELayout = i(6), s.CoSENode = i(5), a.exports = s;
}
/******/
])
);
});
}(Os)), Os.exports;
}
(function(t, e) {
(function(a, n) {
t.exports = n(a0());
})(ro, function(r) {
return (
/******/
function(a) {
var n = {};
function i(s) {
if (n[s])
return n[s].exports;
var o = n[s] = {
/******/
i: s,
/******/
l: !1,
/******/
exports: {}
/******/
};
return a[s].call(o.exports, o, o.exports, i), o.l = !0, o.exports;
}
return i.m = a, i.c = n, i.i = function(s) {
return s;
}, i.d = function(s, o, u) {
i.o(s, o) || Object.defineProperty(s, o, {
/******/
configurable: !1,
/******/
enumerable: !0,
/******/
get: u
/******/
});
}, i.n = function(s) {
var o = s && s.__esModule ? (
/******/
function() {
return s.default;
}
) : (
/******/
function() {
return s;
}
);
return i.d(o, "a", o), o;
}, i.o = function(s, o) {
return Object.prototype.hasOwnProperty.call(s, o);
}, i.p = "", i(i.s = 1);
}([
/* 0 */
/***/
function(a, n) {
a.exports = r;
},
/* 1 */
/***/
function(a, n, i) {
var s = i(0).layoutBase.LayoutConstants, o = i(0).layoutBase.FDLayoutConstants, u = i(0).CoSEConstants, l = i(0).CoSELayout, f = i(0).CoSENode, c = i(0).layoutBase.PointD, v = i(0).layoutBase.DimensionD, h = {
// Called on `layoutready`
ready: function() {
},
// Called on `layoutstop`
stop: function() {
},
// 'draft', 'default' or 'proof"
// - 'draft' fast cooling rate
// - 'default' moderate cooling rate
// - "proof" slow cooling rate
quality: "default",
// include labels in node dimensions
nodeDimensionsIncludeLabels: !1,
// number of ticks per frame; higher is faster but more jerky
refresh: 30,
// Whether to fit the network view after when done
fit: !0,
// Padding on fit
padding: 10,
// Whether to enable incremental mode
randomize: !0,
// Node repulsion (non overlapping) multiplier
nodeRepulsion: 4500,
// Ideal edge (non nested) length
idealEdgeLength: 50,
// Divisor to compute edge forces
edgeElasticity: 0.45,
// Nesting factor (multiplier) to compute ideal edge length for nested edges
nestingFactor: 0.1,
// Gravity force (constant)
gravity: 0.25,
// Maximum number of iterations to perform
numIter: 2500,
// For enabling tiling
tile: !0,
// Type of layout animation. The option set is {'during', 'end', false}
animate: "end",
// Duration for animate:end
animationDuration: 500,
// Represents the amount of the vertical space to put between the zero degree members during the tiling operation(can also be a function)
tilingPaddingVertical: 10,
// Represents the amount of the horizontal space to put between the zero degree members during the tiling operation(can also be a function)
tilingPaddingHorizontal: 10,
// Gravity range (constant) for compounds
gravityRangeCompound: 1.5,
// Gravity force (constant) for compounds
gravityCompound: 1,
// Gravity range (constant)
gravityRange: 3.8,
// Initial cooling factor for incremental layout
initialEnergyOnIncremental: 0.5
};
function d(b, m) {
var E = {};
for (var T in b)
E[T] = b[T];
for (var T in m)
E[T] = m[T];
return E;
}
function p(b) {
this.options = d(h, b), g(this.options);
}
var g = function(m) {
m.nodeRepulsion != null && (u.DEFAULT_REPULSION_STRENGTH = o.DEFAULT_REPULSION_STRENGTH = m.nodeRepulsion), m.idealEdgeLength != null && (u.DEFAULT_EDGE_LENGTH = o.DEFAULT_EDGE_LENGTH = m.idealEdgeLength), m.edgeElasticity != null && (u.DEFAULT_SPRING_STRENGTH = o.DEFAULT_SPRING_STRENGTH = m.edgeElasticity), m.nestingFactor != null && (u.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = o.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = m.nestingFactor), m.gravity != null && (u.DEFAULT_GRAVITY_STRENGTH = o.DEFAULT_GRAVITY_STRENGTH = m.gravity), m.numIter != null && (u.MAX_ITERATIONS = o.MAX_ITERATIONS = m.numIter), m.gravityRange != null && (u.DEFAULT_GRAVITY_RANGE_FACTOR = o.DEFAULT_GRAVITY_RANGE_FACTOR = m.gravityRange), m.gravityCompound != null && (u.DEFAULT_COMPOUND_GRAVITY_STRENGTH = o.DEFAULT_COMPOUND_GRAVITY_STRENGTH = m.gravityCompound), m.gravityRangeCompound != null && (u.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = o.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = m.gravityRangeCompound), m.initialEnergyOnIncremental != null && (u.DEFAULT_COOLING_FACTOR_INCREMENTAL = o.DEFAULT_COOLING_FACTOR_INCREMENTAL = m.initialEnergyOnIncremental), m.quality == "draft" ? s.QUALITY = 0 : m.quality == "proof" ? s.QUALITY = 2 : s.QUALITY = 1, u.NODE_DIMENSIONS_INCLUDE_LABELS = o.NODE_DIMENSIONS_INCLUDE_LABELS = s.NODE_DIMENSIONS_INCLUDE_LABELS = m.nodeDimensionsIncludeLabels, u.DEFAULT_INCREMENTAL = o.DEFAULT_INCREMENTAL = s.DEFAULT_INCREMENTAL = !m.randomize, u.ANIMATE = o.ANIMATE = s.ANIMATE = m.animate, u.TILE = m.tile, u.TILING_PADDING_VERTICAL = typeof m.tilingPaddingVertical == "function" ? m.tilingPaddingVertical.call() : m.tilingPaddingVertical, u.TILING_PADDING_HORIZONTAL = typeof m.tilingPaddingHorizontal == "function" ? m.tilingPaddingHorizontal.call() : m.tilingPaddingHorizontal;
};
p.prototype.run = function() {
var b, m, E = this.options;
this.idToLNode = {};
var T = this.layout = new l(), S = this;
S.stopped = !1, this.cy = this.options.cy, this.cy.trigger({ type: "layoutstart", layout: this });
var w = T.newGraphManager();
this.gm = w;
var x = this.options.eles.nodes(), C = this.options.eles.edges();
this.root = w.addRoot(), this.processChildrenList(this.root, this.getTopMostNodes(x), T);
for (var D = 0; D < C.length; D++) {
var A = C[D], L = this.idToLNode[A.data("source")], R = this.idToLNode[A.data("target")];
if (L !== R && L.getEdgesBetween(R).length == 0) {
var I = w.add(T.newEdge(), L, R);
I.id = A.id();
}
}
var M = function(k, B) {
typeof k == "number" && (k = B);
var _ = k.data("id"), F = S.idToLNode[_];
return {
x: F.getRect().getCenterX(),
y: F.getRect().getCenterY()
};
}, N = function O() {
for (var k = function() {
E.fit && E.cy.fit(E.eles, E.padding), b || (b = !0, S.cy.one("layoutready", E.ready), S.cy.trigger({ type: "layoutready", layout: S }));
}, B = S.options.refresh, _, F = 0; F < B && !_; F++)
_ = S.stopped || S.layout.tick();
if (_) {
T.checkLayoutSuccess() && !T.isSubLayout && T.doPostLayout(), T.tilingPostLayout && T.tilingPostLayout(), T.isLayoutFinished = !0, S.options.eles.nodes().positions(M), k(), S.cy.one("layoutstop", S.options.stop), S.cy.trigger({ type: "layoutstop", layout: S }), m && cancelAnimationFrame(m), b = !1;
return;
}
var G = S.layout.getPositionsData();
E.eles.nodes().positions(function(H, Y) {
if (typeof H == "number" && (H = Y), !H.isParent()) {
for (var X = H.id(), W = G[X], ee = H; W == null && (W = G[ee.data("parent")] || G["DummyCompound_" + ee.data("parent")], G[X] = W, ee = ee.parent()[0], ee != null); )
;
return W != null ? {
x: W.x,
y: W.y
} : {
x: H.position("x"),
y: H.position("y")
};
}
}), k(), m = requestAnimationFrame(O);
};
return T.addListener("layoutstarted", function() {
S.options.animate === "during" && (m = requestAnimationFrame(N));
}), T.runLayout(), this.options.animate !== "during" && (S.options.eles.nodes().not(":parent").layoutPositions(S, S.options, M), b = !1), this;
}, p.prototype.getTopMostNodes = function(b) {
for (var m = {}, E = 0; E < b.length; E++)
m[b[E].id()] = !0;
var T = b.filter(function(S, w) {
typeof S == "number" && (S = w);
for (var x = S.parent()[0]; x != null; ) {
if (m[x.id()])
return !1;
x = x.parent()[0];
}
return !0;
});
return T;
}, p.prototype.processChildrenList = function(b, m, E) {
for (var T = m.length, S = 0; S < T; S++) {
var w = m[S], x = w.children(), C, D = w.layoutDimensions({
nodeDimensionsIncludeLabels: this.options.nodeDimensionsIncludeLabels
});
if (w.outerWidth() != null && w.outerHeight() != null ? C = b.add(new f(E.graphManager, new c(w.position("x") - D.w / 2, w.position("y") - D.h / 2), new v(parseFloat(D.w), parseFloat(D.h)))) : C = b.add(new f(this.graphManager)), C.id = w.data("id"), C.paddingLeft = parseInt(w.css("padding")), C.paddingTop = parseInt(w.css("padding")), C.paddingRight = parseInt(w.css("padding")), C.paddingBottom = parseInt(w.css("padding")), this.options.nodeDimensionsIncludeLabels && w.isParent()) {
var A = w.boundingBox({ includeLabels: !0, includeNodes: !1 }).w, L = w.boundingBox({ includeLabels: !0, includeNodes: !1 }).h, R = w.css("text-halign");
C.labelWidth = A, C.labelHeight = L, C.labelPos = R;
}
if (this.idToLNode[w.data("id")] = C, isNaN(C.rect.x) && (C.rect.x = 0), isNaN(C.rect.y) && (C.rect.y = 0), x != null && x.length > 0) {
var I;
I = E.getGraphManager().add(E.newGraph(), C), this.processChildrenList(I, x, E);
}
}
}, p.prototype.stop = function() {
return this.stopped = !0, this;
};
var y = function(m) {
m("layout", "cose-bilkent", p);
};
typeof cytoscape < "u" && y(cytoscape), a.exports = y;
}
/******/
])
);
});
})(av);
var n0 = av.exports;
const i0 = /* @__PURE__ */ yv(n0);
var to = function() {
var t = function(E, T, S, w) {
for (S = S || {}, w = E.length; w--; S[E[w]] = T)
;
return S;
}, e = [1, 4], r = [1, 13], a = [1, 12], n = [1, 15], i = [1, 16], s = [1, 20], o = [1, 19], u = [6, 7, 8], l = [1, 26], f = [1, 24], c = [1, 25], v = [6, 7, 11], h = [1, 6, 13, 15, 16, 19, 22], d = [1, 33], p = [1, 34], g = [1, 6, 7, 11, 13, 15, 16, 19, 22], y = {
trace: function() {
},
yy: {},
symbols_: { error: 2, start: 3, mindMap: 4, spaceLines: 5, SPACELINE: 6, NL: 7, MINDMAP: 8, document: 9, stop: 10, EOF: 11, statement: 12, SPACELIST: 13, node: 14, ICON: 15, CLASS: 16, nodeWithId: 17, nodeWithoutId: 18, NODE_DSTART: 19, NODE_DESCR: 20, NODE_DEND: 21, NODE_ID: 22, $accept: 0, $end: 1 },
terminals_: { 2: "error", 6: "SPACELINE", 7: "NL", 8: "MINDMAP", 11: "EOF", 13: "SPACELIST", 15: "ICON", 16: "CLASS", 19: "NODE_DSTART", 20: "NODE_DESCR", 21: "NODE_DEND", 22: "NODE_ID" },
productions_: [0, [3, 1], [3, 2], [5, 1], [5, 2], [5, 2], [4, 2], [4, 3], [10, 1], [10, 1], [10, 1], [10, 2], [10, 2], [9, 3], [9, 2], [12, 2], [12, 2], [12, 2], [12, 1], [12, 1], [12, 1], [12, 1], [12, 1], [14, 1], [14, 1], [18, 3], [17, 1], [17, 4]],
performAction: function(T, S, w, x, C, D, A) {
var L = D.length - 1;
switch (C) {
case 6:
case 7:
return x;
case 8:
x.getLogger().trace("Stop NL ");
break;
case 9:
x.getLogger().trace("Stop EOF ");
break;
case 11:
x.getLogger().trace("Stop NL2 ");
break;
case 12:
x.getLogger().trace("Stop EOF2 ");
break;
case 15:
x.getLogger().info("Node: ", D[L].id), x.addNode(D[L - 1].length, D[L].id, D[L].descr, D[L].type);
break;
case 16:
x.getLogger().trace("Icon: ", D[L]), x.decorateNode({ icon: D[L] });
break;
case 17:
case 21:
x.decorateNode({ class: D[L] });
break;
case 18:
x.getLogger().trace("SPACELIST");
break;
case 19:
x.getLogger().trace("Node: ", D[L].id), x.addNode(0, D[L].id, D[L].descr, D[L].type);
break;
case 20:
x.decorateNode({ icon: D[L] });
break;
case 25:
x.getLogger().trace("node found ..", D[L - 2]), this.$ = { id: D[L - 1], descr: D[L - 1], type: x.getType(D[L - 2], D[L]) };
break;
case 26:
this.$ = { id: D[L], descr: D[L], type: x.nodeType.DEFAULT };
break;
case 27:
x.getLogger().trace("node found ..", D[L - 3]), this.$ = { id: D[L - 3], descr: D[L - 1], type: x.getType(D[L - 2], D[L]) };
break;
}
},
table: [{ 3: 1, 4: 2, 5: 3, 6: [1, 5], 8: e }, { 1: [3] }, { 1: [2, 1] }, { 4: 6, 6: [1, 7], 7: [1, 8], 8: e }, { 6: r, 7: [1, 10], 9: 9, 12: 11, 13: a, 14: 14, 15: n, 16: i, 17: 17, 18: 18, 19: s, 22: o }, t(u, [2, 3]), { 1: [2, 2] }, t(u, [2, 4]), t(u, [2, 5]), { 1: [2, 6], 6: r, 12: 21, 13: a, 14: 14, 15: n, 16: i, 17: 17, 18: 18, 19: s, 22: o }, { 6: r, 9: 22, 12: 11, 13: a, 14: 14, 15: n, 16: i, 17: 17, 18: 18, 19: s, 22: o }, { 6: l, 7: f, 10: 23, 11: c }, t(v, [2, 22], { 17: 17, 18: 18, 14: 27, 15: [1, 28], 16: [1, 29], 19: s, 22: o }), t(v, [2, 18]), t(v, [2, 19]), t(v, [2, 20]), t(v, [2, 21]), t(v, [2, 23]), t(v, [2, 24]), t(v, [2, 26], { 19: [1, 30] }), { 20: [1, 31] }, { 6: l, 7: f, 10: 32, 11: c }, { 1: [2, 7], 6: r, 12: 21, 13: a, 14: 14, 15: n, 16: i, 17: 17, 18: 18, 19: s, 22: o }, t(h, [2, 14], { 7: d, 11: p }), t(g, [2, 8]), t(g, [2, 9]), t(g, [2, 10]), t(v, [2, 15]), t(v, [2, 16]), t(v, [2, 17]), { 20: [1, 35] }, { 21: [1, 36] }, t(h, [2, 13], { 7: d, 11: p }), t(g, [2, 11]), t(g, [2, 12]), { 21: [1, 37] }, t(v, [2, 25]), t(v, [2, 27])],
defaultActions: { 2: [2, 1], 6: [2, 2] },
parseError: function(T, S) {
if (S.recoverable)
this.trace(T);
else {
var w = new Error(T);
throw w.hash = S, w;
}
},
parse: function(T) {
var S = this, w = [0], x = [], C = [null], D = [], A = this.table, L = "", R = 0, I = 0, M = 2, N = 1, O = D.slice.call(arguments, 1), k = Object.create(this.lexer), B = { yy: {} };
for (var _ in this.yy)
Object.prototype.hasOwnProperty.call(this.yy, _) && (B.yy[_] = this.yy[_]);
k.setInput(T, B.yy), B.yy.lexer = k, B.yy.parser = this, typeof k.yylloc > "u" && (k.yylloc = {});
var F = k.yylloc;
D.push(F);
var G = k.options && k.options.ranges;
typeof B.yy.parseError == "function" ? this.parseError = B.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
function H() {
var re;
return re = x.pop() || k.lex() || N, typeof re != "number" && (re instanceof Array && (x = re, re = x.pop()), re = S.symbols_[re] || re), re;
}
for (var Y, X, W, ee, ae = {}, J, z, V, q; ; ) {
if (X = w[w.length - 1], this.defaultActions[X] ? W = this.defaultActions[X] : ((Y === null || typeof Y > "u") && (Y = H()), W = A[X] && A[X][Y]), typeof W > "u" || !W.length || !W[0]) {
var Z = "";
q = [];
for (J in A[X])
this.terminals_[J] && J > M && q.push("'" + this.terminals_[J] + "'");
k.showPosition ? Z = "Parse error on line " + (R + 1) + `:
` + k.showPosition() + `
Expecting ` + q.join(", ") + ", got '" + (this.terminals_[Y] || Y) + "'" : Z = "Parse error on line " + (R + 1) + ": Unexpected " + (Y == N ? "end of input" : "'" + (this.terminals_[Y] || Y) + "'"), this.parseError(Z, {
text: k.match,
token: this.terminals_[Y] || Y,
line: k.yylineno,
loc: F,
expected: q
});
}
if (W[0] instanceof Array && W.length > 1)
throw new Error("Parse Error: multiple actions possible at state: " + X + ", token: " + Y);
switch (W[0]) {
case 1:
w.push(Y), C.push(k.yytext), D.push(k.yylloc), w.push(W[1]), Y = null, I = k.yyleng, L = k.yytext, R = k.yylineno, F = k.yylloc;
break;
case 2:
if (z = this.productions_[W[1]][1], ae.$ = C[C.length - z], ae._$ = {
first_line: D[D.length - (z || 1)].first_line,
last_line: D[D.length - 1].last_line,
first_column: D[D.length - (z || 1)].first_column,
last_column: D[D.length - 1].last_column
}, G && (ae._$.range = [
D[D.length - (z || 1)].range[0],
D[D.length - 1].range[1]
]), ee = this.performAction.apply(ae, [
L,
I,
R,
B.yy,
W[1],
C,
D
].concat(O)), typeof ee < "u")
return ee;
z && (w = w.slice(0, -1 * z * 2), C = C.slice(0, -1 * z), D = D.slice(0, -1 * z)), w.push(this.productions_[W[1]][0]), C.push(ae.$), D.push(ae._$), V = A[w[w.length - 2]][w[w.length - 1]], w.push(V);
break;
case 3:
return !0;
}
}
return !0;
}
}, b = function() {
var E = {
EOF: 1,
parseError: function(S, w) {
if (this.yy.parser)
this.yy.parser.parseError(S, w);
else
throw new Error(S);
},
// resets the lexer, sets new input
setInput: function(T, S) {
return this.yy = S || this.yy || {}, this._input = T, this._more = this._backtrack = this.done = !1, this.yylineno = this.yyleng = 0, this.yytext = this.matched = this.match = "", this.conditionStack = ["INITIAL"], this.yylloc = {
first_line: 1,
first_column: 0,
last_line: 1,
last_column: 0
}, this.options.ranges && (this.yylloc.range = [0, 0]), this.offset = 0, this;
},
// consumes and returns one char from the input
input: function() {
var T = this._input[0];
this.yytext += T, this.yyleng++, this.offset++, this.match += T, this.matched += T;
var S = T.match(/(?:\r\n?|\n).*/g);
return S ? (this.yylineno++, this.yylloc.last_line++) : this.yylloc.last_column++, this.options.ranges && this.yylloc.range[1]++, this._input = this._input.slice(1), T;
},
// unshifts one char (or a string) into the input
unput: function(T) {
var S = T.length, w = T.split(/(?:\r\n?|\n)/g);
this._input = T + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - S), this.offset -= S;
var x = this.match.split(/(?:\r\n?|\n)/g);
this.match = this.match.substr(0, this.match.length - 1), this.matched = this.matched.substr(0, this.matched.length - 1), w.length - 1 && (this.yylineno -= w.length - 1);
var C = this.yylloc.range;
return this.yylloc = {
first_line: this.yylloc.first_line,
last_line: this.yylineno + 1,
first_column: this.yylloc.first_column,
last_column: w ? (w.length === x.length ? this.yylloc.first_column : 0) + x[x.length - w.length].length - w[0].length : this.yylloc.first_column - S
}, this.options.ranges && (this.yylloc.range = [C[0], C[0] + this.yyleng - S]), this.yyleng = this.yytext.length, this;
},
// When called from action, caches matched text and appends it on next action
more: function() {
return this._more = !0, this;
},
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
reject: function() {
if (this.options.backtrack_lexer)
this._backtrack = !0;
else
return this.parseError("Lexical error on line " + (this.yylineno + 1) + `. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
` + this.showPosition(), {
text: "",
token: null,
line: this.yylineno
});
return this;
},
// retain first n characters of the match
less: function(T) {
this.unput(this.match.slice(T));
},
// displays already matched input, i.e. for error messages
pastInput: function() {
var T = this.matched.substr(0, this.matched.length - this.match.length);
return (T.length > 20 ? "..." : "") + T.substr(-20).replace(/\n/g, "");
},
// displays upcoming input, i.e. for error messages
upcomingInput: function() {
var T = this.match;
return T.length < 20 && (T += this._input.substr(0, 20 - T.length)), (T.substr(0, 20) + (T.length > 20 ? "..." : "")).replace(/\n/g, "");
},
// displays the character position where the lexing error occurred, i.e. for error messages
showPosition: function() {
var T = this.pastInput(), S = new Array(T.length + 1).join("-");
return T + this.upcomingInput() + `
` + S + "^";
},
// test the lexed token: return FALSE when not a match, otherwise return token
test_match: function(T, S) {
var w, x, C;
if (this.options.backtrack_lexer && (C = {
yylineno: this.yylineno,
yylloc: {
first_line: this.yylloc.first_line,
last_line: this.last_line,
first_column: this.yylloc.first_column,
last_column: this.yylloc.last_column
},
yytext: this.yytext,
match: this.match,
matches: this.matches,
matched: this.matched,
yyleng: this.yyleng,
offset: this.offset,
_more: this._more,
_input: this._input,
yy: this.yy,
conditionStack: this.conditionStack.slice(0),
done: this.done
}, this.options.ranges && (C.yylloc.range = this.yylloc.range.slice(0))), x = T[0].match(/(?:\r\n?|\n).*/g), x && (this.yylineno += x.length), this.yylloc = {
first_line: this.yylloc.last_line,
last_line: this.yylineno + 1,
first_column: this.yylloc.last_column,
last_column: x ? x[x.length - 1].length - x[x.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + T[0].length
}, this.yytext += T[0], this.match += T[0], this.matches = T, this.yyleng = this.yytext.length, this.options.ranges && (this.yylloc.range = [this.offset, this.offset += this.yyleng]), this._more = !1, this._backtrack = !1, this._input = this._input.slice(T[0].length), this.matched += T[0], w = this.performAction.call(this, this.yy, this, S, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), w)
return w;
if (this._backtrack) {
for (var D in C)
this[D] = C[D];
return !1;
}
return !1;
},
// return next match in input
next: function() {
if (this.done)
return this.EOF;
this._input || (this.done = !0);
var T, S, w, x;
this._more || (this.yytext = "", this.match = "");
for (var C = this._currentRules(), D = 0; D < C.length; D++)
if (w = this._input.match(this.rules[C[D]]), w && (!S || w[0].length > S[0].length)) {
if (S = w, x = D, this.options.backtrack_lexer) {
if (T = this.test_match(w, C[D]), T !== !1)
return T;
if (this._backtrack) {
S = !1;
continue;
} else
return !1;
} else if (!this.options.flex)
break;
}
return S ? (T = this.test_match(S, C[x]), T !== !1 ? T : !1) : this._input === "" ? this.EOF : this.parseError("Lexical error on line " + (this.yylineno + 1) + `. Unrecognized text.
` + this.showPosition(), {
text: "",
token: null,
line: this.yylineno
});
},
// return next match that has a token
lex: function() {
var S = this.next();
return S || this.lex();
},
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
begin: function(S) {
this.conditionStack.push(S);
},
// pop the previously active lexer condition state off the condition stack
popState: function() {
var S = this.conditionStack.length - 1;
return S > 0 ? this.conditionStack.pop() : this.conditionStack[0];
},
// produce the lexer rule set which is active for the currently active lexer condition state
_currentRules: function() {
return this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1] ? this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules : this.conditions.INITIAL.rules;
},
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
topState: function(S) {
return S = this.conditionStack.length - 1 - Math.abs(S || 0), S >= 0 ? this.conditionStack[S] : "INITIAL";
},
// alias for begin(condition)
pushState: function(S) {
this.begin(S);
},
// return the number of states currently on the stack
stateStackSize: function() {
return this.conditionStack.length;
},
options: { "case-insensitive": !0 },
performAction: function(S, w, x, C) {
switch (x) {
case 0:
return S.getLogger().trace("Found comment", w.yytext), 6;
case 1:
return 8;
case 2:
this.begin("CLASS");
break;
case 3:
return this.popState(), 16;
case 4:
this.popState();
break;
case 5:
S.getLogger().trace("Begin icon"), this.begin("ICON");
break;
case 6:
return S.getLogger().trace("SPACELINE"), 6;
case 7:
return 7;
case 8:
return 15;
case 9:
S.getLogger().trace("end icon"), this.popState();
break;
case 10:
return S.getLogger().trace("Exploding node"), this.begin("NODE"), 19;
case 11:
return S.getLogger().trace("Cloud"), this.begin("NODE"), 19;
case 12:
return S.getLogger().trace("Explosion Bang"), this.begin("NODE"), 19;
case 13:
return S.getLogger().trace("Cloud Bang"), this.begin("NODE"), 19;
case 14:
return this.begin("NODE"), 19;
case 15:
return this.begin("NODE"), 19;
case 16:
return this.begin("NODE"), 19;
case 17:
return this.begin("NODE"), 19;
case 18:
return 13;
case 19:
return 22;
case 20:
return 11;
case 21:
this.begin("NSTR2");
break;
case 22:
return "NODE_DESCR";
case 23:
this.popState();
break;
case 24:
S.getLogger().trace("Starting NSTR"), this.begin("NSTR");
break;
case 25:
return S.getLogger().trace("description:", w.yytext), "NODE_DESCR";
case 26:
this.popState();
break;
case 27:
return this.popState(), S.getLogger().trace("node end ))"), "NODE_DEND";
case 28:
return this.popState(), S.getLogger().trace("node end )"), "NODE_DEND";
case 29:
return this.popState(), S.getLogger().trace("node end ...", w.yytext), "NODE_DEND";
case 30:
return this.popState(), S.getLogger().trace("node end (("), "NODE_DEND";
case 31:
return this.popState(), S.getLogger().trace("node end (-"), "NODE_DEND";
case 32:
return this.popState(), S.getLogger().trace("node end (-"), "NODE_DEND";
case 33:
return this.popState(), S.getLogger().trace("node end (("), "NODE_DEND";
case 34:
return this.popState(), S.getLogger().trace("node end (("), "NODE_DEND";
case 35:
return S.getLogger().trace("Long description:", w.yytext), 20;
case 36:
return S.getLogger().trace("Long description:", w.yytext), 20;
}
},
rules: [/^(?:\s*%%.*)/i, /^(?:mindmap\b)/i, /^(?::::)/i, /^(?:.+)/i, /^(?:\n)/i, /^(?:::icon\()/i, /^(?:[\s]+[\n])/i, /^(?:[\n]+)/i, /^(?:[^\)]+)/i, /^(?:\))/i, /^(?:-\))/i, /^(?:\(-)/i, /^(?:\)\))/i, /^(?:\))/i, /^(?:\(\()/i, /^(?:\{\{)/i, /^(?:\()/i, /^(?:\[)/i, /^(?:[\s]+)/i, /^(?:[^\(\[\n\)\{\}]+)/i, /^(?:$)/i, /^(?:["][`])/i, /^(?:[^`"]+)/i, /^(?:[`]["])/i, /^(?:["])/i, /^(?:[^"]+)/i, /^(?:["])/i, /^(?:[\)]\))/i, /^(?:[\)])/i, /^(?:[\]])/i, /^(?:\}\})/i, /^(?:\(-)/i, /^(?:-\))/i, /^(?:\(\()/i, /^(?:\()/i, /^(?:[^\)\]\(\}]+)/i, /^(?:.+(?!\(\())/i],
conditions: { CLASS: { rules: [3, 4], inclusive: !1 }, ICON: { rules: [8, 9], inclusive: !1 }, NSTR2: { rules: [22, 23], inclusive: !1 }, NSTR: { rules: [25, 26], inclusive: !1 }, NODE: { rules: [21, 24, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36], inclusive: !1 }, INITIAL: { rules: [0, 1, 2, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], inclusive: !0 } }
};
return E;
}();
y.lexer = b;
function m() {
this.yy = {};
}
return m.prototype = y, y.Parser = m, new m();
}();
to.parser = to;
const s0 = to;
let Ft = [], nv = 0, Io = {};
const o0 = () => {
Ft = [], nv = 0, Io = {};
}, u0 = function(t) {
for (let e = Ft.length - 1; e >= 0; e--)
if (Ft[e].level < t)
return Ft[e];
return null;
}, l0 = () => Ft.length > 0 ? Ft[0] : null, f0 = (t, e, r, a) => {
var n, i;
Nr.info("addNode", t, e, r, a);
const s = ao();
let o = ((n = s.mindmap) == null ? void 0 : n.padding) ?? En.mindmap.padding;
switch (a) {
case rt.ROUNDED_RECT:
case rt.RECT:
case rt.HEXAGON:
o *= 2;
}
const u = {
id: nv++,
nodeId: xn(e, s),
level: t,
descr: xn(r, s),
type: a,
children: [],
width: ((i = s.mindmap) == null ? void 0 : i.maxNodeWidth) ?? En.mindmap.maxNodeWidth,
padding: o
}, l = u0(t);
if (l)
l.children.push(u), Ft.push(u);
else if (Ft.length === 0)
Ft.push(u);
else
throw new Error(
'There can be only one root. No parent could be found for ("' + u.descr + '")'
);
}, rt = {
DEFAULT: 0,
NO_BORDER: 0,
ROUNDED_RECT: 1,
RECT: 2,
CIRCLE: 3,
CLOUD: 4,
BANG: 5,
HEXAGON: 6
}, c0 = (t, e) => {
switch (Nr.debug("In get type", t, e), t) {
case "[":
return rt.RECT;
case "(":
return e === ")" ? rt.ROUNDED_RECT : rt.CLOUD;
case "((":
return rt.CIRCLE;
case ")":
return rt.CLOUD;
case "))":
return rt.BANG;
case "{{":
return rt.HEXAGON;
default:
return rt.DEFAULT;
}
}, v0 = (t, e) => {
Io[t] = e;
}, h0 = (t) => {
if (!t)
return;
const e = ao(), r = Ft[Ft.length - 1];
t.icon && (r.icon = xn(t.icon, e)), t.class && (r.class = xn(t.class, e));
}, d0 = (t) => {
switch (t) {
case rt.DEFAULT:
return "no-border";
case rt.RECT:
return "rect";
case rt.ROUNDED_RECT:
return "rounded-rect";
case rt.CIRCLE:
return "circle";
case rt.CLOUD:
return "cloud";
case rt.BANG:
return "bang";
case rt.HEXAGON:
return "hexgon";
default:
return "no-border";
}
}, g0 = () => Nr, p0 = (t) => Io[t], y0 = {
clear: o0,
addNode: f0,
getMindmap: l0,
nodeType: rt,
getType: c0,
setElementForId: v0,
decorateNode: h0,
type2Str: d0,
getLogger: g0,
getElementById: p0
}, m0 = y0, b0 = 12, w0 = function(t, e, r, a) {
e.append("path").attr("id", "node-" + r.id).attr("class", "node-bkg node-" + t.type2Str(r.type)).attr(
"d",
`M0 ${r.height - 5} v${-r.height + 2 * 5} q0,-5 5,-5 h${r.width - 2 * 5} q5,0 5,5 v${r.height - 5} H0 Z`
), e.append("line").attr("class", "node-line-" + a).attr("x1", 0).attr("y1", r.height).attr("x2", r.width).attr("y2", r.height);
}, E0 = function(t, e, r) {
e.append("rect").attr("id", "node-" + r.id).attr("class", "node-bkg node-" + t.type2Str(r.type)).attr("height", r.height).attr("width", r.width);
}, x0 = function(t, e, r) {
const a = r.width, n = r.height, i = 0.15 * a, s = 0.25 * a, o = 0.35 * a, u = 0.2 * a;
e.append("path").attr("id", "node-" + r.id).attr("class", "node-bkg node-" + t.type2Str(r.type)).attr(
"d",
`M0 0 a${i},${i} 0 0,1 ${a * 0.25},${-1 * a * 0.1}
a${o},${o} 1 0,1 ${a * 0.4},${-1 * a * 0.1}
a${s},${s} 1 0,1 ${a * 0.35},${1 * a * 0.2}
a${i},${i} 1 0,1 ${a * 0.15},${1 * n * 0.35}
a${u},${u} 1 0,1 ${-1 * a * 0.15},${1 * n * 0.65}
a${s},${i} 1 0,1 ${-1 * a * 0.25},${a * 0.15}
a${o},${o} 1 0,1 ${-1 * a * 0.5},0
a${i},${i} 1 0,1 ${-1 * a * 0.25},${-1 * a * 0.15}
a${i},${i} 1 0,1 ${-1 * a * 0.1},${-1 * n * 0.35}
a${u},${u} 1 0,1 ${a * 0.1},${-1 * n * 0.65}
H0 V0 Z`
);
}, T0 = function(t, e, r) {
const a = r.width, n = r.height, i = 0.15 * a;
e.append("path").attr("id", "node-" + r.id).attr("class", "node-bkg node-" + t.type2Str(r.type)).attr(
"d",
`M0 0 a${i},${i} 1 0,0 ${a * 0.25},${-1 * n * 0.1}
a${i},${i} 1 0,0 ${a * 0.25},0
a${i},${i} 1 0,0 ${a * 0.25},0
a${i},${i} 1 0,0 ${a * 0.25},${1 * n * 0.1}
a${i},${i} 1 0,0 ${a * 0.15},${1 * n * 0.33}
a${i * 0.8},${i * 0.8} 1 0,0 0,${1 * n * 0.34}
a${i},${i} 1 0,0 ${-1 * a * 0.15},${1 * n * 0.33}
a${i},${i} 1 0,0 ${-1 * a * 0.25},${n * 0.15}
a${i},${i} 1 0,0 ${-1 * a * 0.25},0
a${i},${i} 1 0,0 ${-1 * a * 0.25},0
a${i},${i} 1 0,0 ${-1 * a * 0.25},${-1 * n * 0.15}
a${i},${i} 1 0,0 ${-1 * a * 0.1},${-1 * n * 0.33}
a${i * 0.8},${i * 0.8} 1 0,0 0,${-1 * n * 0.34}
a${i},${i} 1 0,0 ${a * 0.1},${-1 * n * 0.33}
H0 V0 Z`
);
}, C0 = function(t, e, r) {
e.append("circle").attr("id", "node-" + r.id).attr("class", "node-bkg node-" + t.type2Str(r.type)).attr("r", r.width / 2);
};
function D0(t, e, r, a, n) {
return t.insert("polygon", ":first-child").attr(
"points",
a.map(function(i) {
return i.x + "," + i.y;
}).join(" ")
).attr("transform", "translate(" + (n.width - e) / 2 + ", " + r + ")");
}
const S0 = function(t, e, r) {
const a = r.height, i = a / 4, s = r.width - r.padding + 2 * i, o = [
{ x: i, y: 0 },
{ x: s - i, y: 0 },
{ x: s, y: -a / 2 },
{ x: s - i, y: -a },
{ x: i, y: -a },
{ x: 0, y: -a / 2 }
];
D0(e, s, a, o, r);
}, A0 = function(t, e, r) {
e.append("rect").attr("id", "node-" + r.id).attr("class", "node-bkg node-" + t.type2Str(r.type)).attr("height", r.height).attr("rx", r.padding).attr("ry", r.padding).attr("width", r.width);
}, L0 = function(t, e, r, a, n) {
const i = n.htmlLabels, s = a % (b0 - 1), o = e.append("g");
r.section = s;
let u = "section-" + s;
s < 0 && (u += " section-root"), o.attr("class", (r.class ? r.class + " " : "") + "mindmap-node " + u);
const l = o.append("g"), f = o.append("g"), c = r.descr.replace(/(<br\/*>)/g, `
`);
Dv(f, c, {
useHtmlLabels: i,
width: r.width,
classes: "mindmap-node-label"
}), i || f.attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle");
const v = f.node().getBBox(), [h] = Cv(n.fontSize);
if (r.height = v.height + h * 1.1 * 0.5 + r.padding, r.width = v.width + 2 * r.padding, r.icon)
if (r.type === t.nodeType.CIRCLE)
r.height += 50, r.width += 50, o.append("foreignObject").attr("height", "50px").attr("width", r.width).attr("style", "text-align: center;").append("div").attr("class", "icon-container").append("i").attr("class", "node-icon-" + s + " " + r.icon), f.attr(
"transform",
"translate(" + r.width / 2 + ", " + (r.height / 2 - 1.5 * r.padding) + ")"
);
else {
r.width += 50;
const d = r.height;
r.height = Math.max(d, 60);
const p = Math.abs(r.height - d);
o.append("foreignObject").attr("width", "60px").attr("height", r.height).attr("style", "text-align: center;margin-top:" + p / 2 + "px;").append("div").attr("class", "icon-container").append("i").attr("class", "node-icon-" + s + " " + r.icon), f.attr(
"transform",
"translate(" + (25 + r.width / 2) + ", " + (p / 2 + r.padding / 2) + ")"
);
}
else if (i) {
const d = (r.width - v.width) / 2, p = (r.height - v.height) / 2;
f.attr("transform", "translate(" + d + ", " + p + ")");
} else {
const d = r.width / 2, p = r.padding / 2;
f.attr("transform", "translate(" + d + ", " + p + ")");
}
switch (r.type) {
case t.nodeType.DEFAULT:
w0(t, l, r, s);
break;
case t.nodeType.ROUNDED_RECT:
A0(t, l, r);
break;
case t.nodeType.RECT:
E0(t, l, r);
break;
case t.nodeType.CIRCLE:
l.attr("transform", "translate(" + r.width / 2 + ", " + +r.height / 2 + ")"), C0(t, l, r);
break;
case t.nodeType.CLOUD:
x0(t, l, r);
break;
case t.nodeType.BANG:
T0(t, l, r);
break;
case t.nodeType.HEXAGON:
S0(t, l, r);
break;
}
return t.setElementForId(r.id, o), r.height;
}, R0 = function(t, e) {
const r = t.getElementById(e.id), a = e.x || 0, n = e.y || 0;
r.attr("transform", "translate(" + a + "," + n + ")");
};
pr.use(i0);
function iv(t, e, r, a, n) {
L0(t, e, r, a, n), r.children && r.children.forEach((i, s) => {
iv(t, e, i, a < 0 ? s : a, n);
});
}
function I0(t, e) {
e.edges().map((r, a) => {
const n = r.data();
if (r[0]._private.bodyBounds) {
const i = r[0]._private.rscratch;
Nr.trace("Edge: ", a, n), t.insert("path").attr(
"d",
`M ${i.startX},${i.startY} L ${i.midX},${i.midY} L${i.endX},${i.endY} `
).attr("class", "edge section-edge-" + n.section + " edge-depth-" + n.depth);
}
});
}
function sv(t, e, r, a) {
e.add({
group: "nodes",
data: {
id: t.id.toString(),
labelText: t.descr,
height: t.height,
width: t.width,
level: a,
nodeId: t.id,
padding: t.padding,
type: t.type
},
position: {
x: t.x,
y: t.y
}
}), t.children && t.children.forEach((n) => {
sv(n, e, r, a + 1), e.add({
group: "edges",
data: {
id: `${t.id}_${n.id}`,
source: t.id,
target: n.id,
depth: a,
section: n.section
}
});
});
}
function P0(t, e) {
return new Promise((r) => {
const a = wv("body").append("div").attr("id", "cy").attr("style", "display:none"), n = pr({
container: document.getElementById("cy"),
// container to render in
style: [
{
selector: "edge",
style: {
"curve-style": "bezier"
}
}
]
});
a.remove(), sv(t, n, e, 0), n.nodes().forEach(function(i) {
i.layoutDimensions = () => {
const s = i.data();
return { w: s.width, h: s.height };
};
}), n.layout({
name: "cose-bilkent",
// @ts-ignore Types for cose-bilkent are not correct?
quality: "proof",
styleEnabled: !1,
animate: !1
}).run(), n.ready((i) => {
Nr.info("Ready", i), r(n);
});
});
}
function M0(t, e) {
e.nodes().map((r, a) => {
const n = r.data();
n.x = r.position().x, n.y = r.position().y, R0(t, n);
const i = t.getElementById(n.nodeId);
Nr.info("Id:", a, "Position: (", r.position().x, ", ", r.position().y, ")", n), i.attr(
"transform",
`translate(${r.position().x - n.width / 2}, ${r.position().y - n.height / 2})`
), i.attr("attr", `apa-${a})`);
});
}
const O0 = async (t, e, r, a) => {
var n, i;
Nr.debug(`Rendering mindmap diagram
` + t);
const s = a.db, o = s.getMindmap();
if (!o)
return;
const u = ao();
u.htmlLabels = !1;
const l = mv(e), f = l.append("g");
f.attr("class", "mindmap-edges");
const c = l.append("g");
c.attr("class", "mindmap-nodes"), iv(s, c, o, -1, u);
const v = await P0(o, u);
I0(f, v), M0(s, v), bv(
void 0,
l,
((n = u.mindmap) == null ? void 0 : n.padding) ?? En.mindmap.padding,
((i = u.mindmap) == null ? void 0 : i.useMaxWidth) ?? En.mindmap.useMaxWidth
);
}, k0 = {
draw: O0
}, N0 = (t) => {
let e = "";
for (let r = 0; r < t.THEME_COLOR_LIMIT; r++)
t["lineColor" + r] = t["lineColor" + r] || t["cScaleInv" + r], Ev(t["lineColor" + r]) ? t["lineColor" + r] = xv(t["lineColor" + r], 20) : t["lineColor" + r] = Tv(t["lineColor" + r], 20);
for (let r = 0; r < t.THEME_COLOR_LIMIT; r++) {
const a = "" + (17 - 3 * r);
e += `
.section-${r - 1} rect, .section-${r - 1} path, .section-${r - 1} circle, .section-${r - 1} polygon, .section-${r - 1} path {
fill: ${t["cScale" + r]};
}
.section-${r - 1} text {
fill: ${t["cScaleLabel" + r]};
}
.node-icon-${r - 1} {
font-size: 40px;
color: ${t["cScaleLabel" + r]};
}
.section-edge-${r - 1}{
stroke: ${t["cScale" + r]};
}
.edge-depth-${r - 1}{
stroke-width: ${a};
}
.section-${r - 1} line {
stroke: ${t["cScaleInv" + r]} ;
stroke-width: 3;
}
.disabled, .disabled circle, .disabled text {
fill: lightgray;
}
.disabled text {
fill: #efefef;
}
`;
}
return e;
}, B0 = (t) => `
.edge {
stroke-width: 3;
}
${N0(t)}
.section-root rect, .section-root path, .section-root circle, .section-root polygon {
fill: ${t.git0};
}
.section-root text {
fill: ${t.gitBranchLabel0};
}
.icon-container {
height:100%;
display: flex;
justify-content: center;
align-items: center;
}
.edge {
fill: none;
}
.mindmap-node-label {
dy: 1em;
alignment-baseline: middle;
text-anchor: middle;
dominant-baseline: middle;
text-align: center;
}
`, F0 = B0, U0 = {
db: m0,
renderer: k0,
parser: s0,
styles: F0
};
export {
U0 as diagram
};