@draftably/editor 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +4 -5
  2. package/dist/assets/engine.worker-BY9GKt7x.js +7505 -0
  3. package/dist/element.js +1 -1
  4. package/dist/index.js +20202 -2
  5. package/dist/types/src/cli/raster-fonts.d.ts +3 -0
  6. package/dist/types/src/components/controls.d.ts +8 -5
  7. package/dist/types/src/dsl/compile.d.ts +13 -0
  8. package/dist/types/src/dsl/corridors.d.ts +38 -0
  9. package/dist/types/src/model/types.d.ts +9 -0
  10. package/dist/types/src/state/canvas-commands.d.ts +169 -0
  11. package/dist/types/src/state/canvas-keyboard.d.ts +15 -0
  12. package/dist/types/src/state/links.d.ts +4 -1
  13. package/dist/types/src/state/workspace.d.ts +3 -0
  14. package/package.json +1 -1
  15. package/dist/assets/engine.worker-DmHew5f6.js +0 -6813
  16. package/dist/assets/import-d2.worker-CnXfFXoa.js +0 -5395
  17. package/dist/chunks/abnfDiagram-WEYOIA3C-llcpthp5.js +0 -87
  18. package/dist/chunks/arc-rJj0TtXf.js +0 -83
  19. package/dist/chunks/architectureDiagram-ZHVYKT53-CfiXg0Lk.js +0 -4781
  20. package/dist/chunks/blockDiagram-RJAE7QA3-CO-14jWz.js +0 -1440
  21. package/dist/chunks/browser-iNhbPsGc.js +0 -40
  22. package/dist/chunks/c4Diagram-XDPPPE54-DYKuxA4n.js +0 -1524
  23. package/dist/chunks/channel-qMvPU6eH.js +0 -5
  24. package/dist/chunks/chunk-2E7WHVMD-BEZwsFS3.js +0 -670
  25. package/dist/chunks/chunk-2Q5K7J3B-gqtzQ8ux.js +0 -18
  26. package/dist/chunks/chunk-4EMNKR2T-MC54CXVe.js +0 -262
  27. package/dist/chunks/chunk-55XCU76K-DkZUAaqC.js +0 -68
  28. package/dist/chunks/chunk-5VM5RSS4-CaKe4sjM.js +0 -19
  29. package/dist/chunks/chunk-JWPE2WC7-CnAFS2xF.js +0 -8
  30. package/dist/chunks/chunk-VQ5W62QI-CXRv7FiX.js +0 -19
  31. package/dist/chunks/chunk-XXDRQBXY-B-AMQgD2.js +0 -8
  32. package/dist/chunks/chunk-ZCHMQSOR-BALpdc3g.js +0 -451
  33. package/dist/chunks/classDiagram-v2-4MYWR3UA-wPjgJTg4.js +0 -1570
  34. package/dist/chunks/cose-bilkent-JH36ORCC-Bbh5ggBc.js +0 -2608
  35. package/dist/chunks/cynefin-EF2NZ3EQ-Bt6b88hY.js +0 -22361
  36. package/dist/chunks/cynefinDiagram-WF24UDRP-BHWZvxoF.js +0 -299
  37. package/dist/chunks/cytoscape.esm-CRsF_JA3.js +0 -18791
  38. package/dist/chunks/dagre-NK4GIZVX-Cz37yPrT.js +0 -2157
  39. package/dist/chunks/defaultLocale-BgPVtth8.js +0 -171
  40. package/dist/chunks/diagram-CBK3MWTC-Q2R6FJ0B.js +0 -531
  41. package/dist/chunks/diagram-I5XIIV2D-a2Kdu_wA.js +0 -153
  42. package/dist/chunks/diagram-ODIL2UCW-DTWXxcOn.js +0 -346
  43. package/dist/chunks/diagram-PFBEJUXE-DIAQQ5KX.js +0 -480
  44. package/dist/chunks/diagram-RJA3I4VV-BPD0GghS.js +0 -219
  45. package/dist/chunks/diagram-TYUNFSNR-BmdkONfG.js +0 -2586
  46. package/dist/chunks/dot-importer-B23jwEkx.js +0 -1547
  47. package/dist/chunks/ebnfDiagram-V4P3TTPT-C5IKvYlb.js +0 -109
  48. package/dist/chunks/elk-QONTBCTQ-CtdQFvh2.js +0 -49229
  49. package/dist/chunks/erDiagram-KYQIGQAA-5wguK9Dx.js +0 -1064
  50. package/dist/chunks/flowDiagram-IUGLLWBU-BijvFPku.js +0 -1771
  51. package/dist/chunks/ganttDiagram-R7GPNTJY-BaqGPz-O.js +0 -2729
  52. package/dist/chunks/gitGraphDiagram-PDYL7XHY-DZfMGyHE.js +0 -815
  53. package/dist/chunks/graph-CKJmgLki.js +0 -1541
  54. package/dist/chunks/import-core-C-I1wGfw.js +0 -145
  55. package/dist/chunks/infoDiagram-MVDRKAX5-C2vH_59e.js +0 -24
  56. package/dist/chunks/init-DjUOC4st.js +0 -16
  57. package/dist/chunks/ishikawaDiagram-HPEHV2GE-q149MFlV.js +0 -624
  58. package/dist/chunks/journeyDiagram-BOSHW7O7-D-2Z3VtR.js +0 -834
  59. package/dist/chunks/kanban-definition-FNSA4HC5-wvAjV5ub.js +0 -724
  60. package/dist/chunks/katex-BsrBVQKd.js +0 -11314
  61. package/dist/chunks/linear-4t7D_ros.js +0 -259
  62. package/dist/chunks/mermaid-facade-BoLWBerE.js +0 -289
  63. package/dist/chunks/mermaid-importer-Cgx1IhmR.js +0 -478
  64. package/dist/chunks/mermaid.core-DXv6D2Sm.js +0 -19244
  65. package/dist/chunks/mindmap-definition-6OY57UG3-r9wTKul_.js +0 -837
  66. package/dist/chunks/mount-C1Xk_GQz.js +0 -22131
  67. package/dist/chunks/ordinal-DfAQgscy.js +0 -61
  68. package/dist/chunks/pegDiagram-ECIUJNBX-CmKlFWiP.js +0 -95
  69. package/dist/chunks/pieDiagram-GNMPY74T-DNTw_qan.js +0 -208
  70. package/dist/chunks/quadrantDiagram-D57K4MC3-CT_tvVub.js +0 -1029
  71. package/dist/chunks/railroadDiagram-Y72NRBL7-C5TUvZBe.js +0 -77
  72. package/dist/chunks/requirementDiagram-EQYSW5RA-C_c65aCa.js +0 -889
  73. package/dist/chunks/sankeyDiagram-SY24JHO5-CKcbizM1.js +0 -859
  74. package/dist/chunks/sequenceDiagram-BLEHNHQU-GpVnHOjf.js +0 -2972
  75. package/dist/chunks/sizeCapture-INFHLROL-CToN3JSu.js +0 -46
  76. package/dist/chunks/stateDiagram-v2-A6IESKWZ-rJYd2FfM.js +0 -1520
  77. package/dist/chunks/swimlanes-B3ENRKFQ-C7w5pfxG.js +0 -4991
  78. package/dist/chunks/swimlanesDiagram-AYQRV4AK-BpGY_bvE.js +0 -13
  79. package/dist/chunks/timeline-definition-JXYKGLGB-ChKFPBKc.js +0 -1058
  80. package/dist/chunks/usecaseDiagram-WPOLBNNX-skXH8Dcu.js +0 -7945
  81. package/dist/chunks/vennDiagram-Q3Y3IDCW-C5KknmJf.js +0 -1578
  82. package/dist/chunks/wardleyDiagram-IVAIDKWA-DY4Lkfpu.js +0 -678
  83. package/dist/chunks/xychartDiagram-4URNHDU4-BHScsL7h.js +0 -1536
  84. package/dist/types/src/cli/png.d.ts +0 -23
  85. package/dist/types/src/import/browser.d.ts +0 -3
  86. package/dist/types/src/import/detect.d.ts +0 -31
  87. package/dist/types/src/import/dot-importer.d.ts +0 -3
  88. package/dist/types/src/import/import-core.d.ts +0 -105
  89. package/dist/types/src/import/mermaid-facade.d.ts +0 -120
  90. package/dist/types/src/import/mermaid-importer.d.ts +0 -4
  91. package/dist/types/src/import/mermaid-sequence.d.ts +0 -8
  92. package/dist/types/src/import/scratch.d.ts +0 -3
  93. package/dist/types/src/lib/source-hash.d.ts +0 -7
  94. package/dist/types/src/model/candidates.d.ts +0 -53
  95. package/dist/types/src/model/embed.d.ts +0 -17
  96. package/dist/types/src/model/examples.d.ts +0 -15
  97. package/dist/types/src/model/label-hits.d.ts +0 -27
  98. package/dist/types/src/model/static-scene.d.ts +0 -15
  99. package/dist/types/src/state/commands.d.ts +0 -529
  100. package/dist/types/src/state/comparison.d.ts +0 -151
  101. package/dist/types/src/state/files.d.ts +0 -61
  102. package/dist/types/src/state/keyboard.d.ts +0 -6
  103. package/dist/types/src/state/launch.d.ts +0 -61
  104. package/dist/types/src/state/ui.d.ts +0 -39
@@ -1,2157 +0,0 @@
1
- import { s as ce, a as Wn, c as qn, b as Hn, f as Te, e as T, i as zn } from "./chunk-ZCHMQSOR-BALpdc3g.js";
2
- import { _ as x, c as Jn, l as m, bB as Kn, bC as Zn, aD as Qn, aC as Se, an as Ce, al as er, az as nr, b8 as rr } from "./mermaid.core-DXv6D2Sm.js";
3
- import { i as U, a as O, d as Ie, e as H, b as z, c as tn, f as le, g as an, h as tr, j as on, s as ar, o as ir, k as or, l as he, m as sr, r as dr, U as Re, S as ke, n as pe, p as ge, q as V, t as sn, u as dn, v as ur, w as I, x as fr, y as cr, z as lr, A as _e, B as hr, C as un, D as _, E as pr, F as gr, H as vr, I as X, J as fn, K as cn, L as br, M as ve, N as ln, O as wr, P as hn, Q as mr, R as yr, G as N, T as l, V as xr, W as L, X as $, Y as R, Z as J } from "./graph-CKJmgLki.js";
4
- var Er = /\s/;
5
- function Lr(e) {
6
- for (var n = e.length; n-- && Er.test(e.charAt(n)); )
7
- ;
8
- return n;
9
- }
10
- var Or = /^\s+/;
11
- function Nr(e) {
12
- return e && e.slice(0, Lr(e) + 1).replace(Or, "");
13
- }
14
- var Me = NaN, Pr = /^[-+]0x[0-9a-f]+$/i, Tr = /^0b[01]+$/i, Sr = /^0o[0-7]+$/i, Cr = parseInt;
15
- function Ir(e) {
16
- if (typeof e == "number")
17
- return e;
18
- if (U(e))
19
- return Me;
20
- if (O(e)) {
21
- var n = typeof e.valueOf == "function" ? e.valueOf() : e;
22
- e = O(n) ? n + "" : n;
23
- }
24
- if (typeof e != "string")
25
- return e === 0 ? e : +e;
26
- e = Nr(e);
27
- var r = Tr.test(e);
28
- return r || Sr.test(e) ? Cr(e.slice(2), r ? 2 : 8) : Pr.test(e) ? Me : +e;
29
- }
30
- var Ae = 1 / 0, Rr = 17976931348623157e292;
31
- function G(e) {
32
- if (!e)
33
- return e === 0 ? e : 0;
34
- if (e = Ir(e), e === Ae || e === -Ae) {
35
- var n = e < 0 ? -1 : 1;
36
- return n * Rr;
37
- }
38
- return e === e ? e : 0;
39
- }
40
- function kr(e) {
41
- var n = G(e), r = n % 1;
42
- return n === n ? r ? n - r : n : 0;
43
- }
44
- var je = Object.create, _r = /* @__PURE__ */ (function() {
45
- function e() {
46
- }
47
- return function(n) {
48
- if (!O(n))
49
- return {};
50
- if (je)
51
- return je(n);
52
- e.prototype = n;
53
- var r = new e();
54
- return e.prototype = void 0, r;
55
- };
56
- })();
57
- function Mr(e, n) {
58
- var r = -1, t = e.length;
59
- for (n || (n = Array(t)); ++r < t; )
60
- n[r] = e[r];
61
- return n;
62
- }
63
- function K(e, n, r) {
64
- n == "__proto__" && Ie ? Ie(e, n, {
65
- configurable: !0,
66
- enumerable: !0,
67
- value: r,
68
- writable: !0
69
- }) : e[n] = r;
70
- }
71
- var Ar = Object.prototype, jr = Ar.hasOwnProperty;
72
- function Z(e, n, r) {
73
- var t = e[n];
74
- (!(jr.call(e, n) && H(t, r)) || r === void 0 && !(n in e)) && K(e, n, r);
75
- }
76
- function Dr(e, n, r, t) {
77
- var a = !r;
78
- r || (r = {});
79
- for (var o = -1, i = n.length; ++o < i; ) {
80
- var s = n[o], d = void 0;
81
- d === void 0 && (d = e[s]), a ? K(r, s, d) : Z(r, s, d);
82
- }
83
- return r;
84
- }
85
- function j(e, n, r) {
86
- if (!O(r))
87
- return !1;
88
- var t = typeof n;
89
- return (t == "number" ? z(r) && tn(n, r.length) : t == "string" && n in r) ? H(r[n], e) : !1;
90
- }
91
- function Br(e) {
92
- return le(function(n, r) {
93
- var t = -1, a = r.length, o = a > 1 ? r[a - 1] : void 0, i = a > 2 ? r[2] : void 0;
94
- for (o = e.length > 3 && typeof o == "function" ? (a--, o) : void 0, i && j(r[0], r[1], i) && (o = a < 3 ? void 0 : o, a = 1), n = Object(n); ++t < a; ) {
95
- var s = r[t];
96
- s && e(n, s, t, o);
97
- }
98
- return n;
99
- });
100
- }
101
- function $r(e) {
102
- var n = [];
103
- if (e != null)
104
- for (var r in Object(e))
105
- n.push(r);
106
- return n;
107
- }
108
- var Fr = Object.prototype, Xr = Fr.hasOwnProperty;
109
- function Gr(e) {
110
- if (!O(e))
111
- return $r(e);
112
- var n = an(e), r = [];
113
- for (var t in e)
114
- t == "constructor" && (n || !Xr.call(e, t)) || r.push(t);
115
- return r;
116
- }
117
- function Q(e) {
118
- return z(e) ? tr(e, !0) : Gr(e);
119
- }
120
- function M(e) {
121
- var n = e == null ? 0 : e.length;
122
- return n ? on(e) : [];
123
- }
124
- function Yr(e) {
125
- return ar(ir(e, void 0, M), e + "");
126
- }
127
- var pn = or(Object.getPrototypeOf, Object), Ur = "[object Object]", Vr = Function.prototype, Wr = Object.prototype, gn = Vr.toString, qr = Wr.hasOwnProperty, Hr = gn.call(Object);
128
- function zr(e) {
129
- if (!he(e) || sr(e) != Ur)
130
- return !1;
131
- var n = pn(e);
132
- if (n === null)
133
- return !0;
134
- var r = qr.call(n, "constructor") && n.constructor;
135
- return typeof r == "function" && r instanceof r && gn.call(r) == Hr;
136
- }
137
- var vn = typeof exports == "object" && exports && !exports.nodeType && exports, De = vn && typeof module == "object" && module && !module.nodeType && module, Jr = De && De.exports === vn, Be = Jr ? dr.Buffer : void 0, $e = Be ? Be.allocUnsafe : void 0;
138
- function bn(e, n) {
139
- if (n)
140
- return e.slice();
141
- var r = e.length, t = $e ? $e(r) : new e.constructor(r);
142
- return e.copy(t), t;
143
- }
144
- var Kr = Object.prototype, Zr = Kr.hasOwnProperty;
145
- function Qr(e) {
146
- var n = e.length, r = new e.constructor(n);
147
- return n && typeof e[0] == "string" && Zr.call(e, "index") && (r.index = e.index, r.input = e.input), r;
148
- }
149
- function be(e) {
150
- var n = new e.constructor(e.byteLength);
151
- return new Re(n).set(new Re(e)), n;
152
- }
153
- function et(e, n) {
154
- var r = be(e.buffer);
155
- return new e.constructor(r, e.byteOffset, e.byteLength);
156
- }
157
- var nt = /\w*$/;
158
- function rt(e) {
159
- var n = new e.constructor(e.source, nt.exec(e));
160
- return n.lastIndex = e.lastIndex, n;
161
- }
162
- var Fe = ke ? ke.prototype : void 0, Xe = Fe ? Fe.valueOf : void 0;
163
- function tt(e) {
164
- return Xe ? Object(Xe.call(e)) : {};
165
- }
166
- function wn(e, n) {
167
- var r = n ? be(e.buffer) : e.buffer;
168
- return new e.constructor(r, e.byteOffset, e.length);
169
- }
170
- var at = "[object Boolean]", it = "[object Date]", ot = "[object Map]", st = "[object Number]", dt = "[object RegExp]", ut = "[object Set]", ft = "[object String]", ct = "[object Symbol]", lt = "[object ArrayBuffer]", ht = "[object DataView]", pt = "[object Float32Array]", gt = "[object Float64Array]", vt = "[object Int8Array]", bt = "[object Int16Array]", wt = "[object Int32Array]", mt = "[object Uint8Array]", yt = "[object Uint8ClampedArray]", xt = "[object Uint16Array]", Et = "[object Uint32Array]";
171
- function Lt(e, n, r) {
172
- var t = e.constructor;
173
- switch (n) {
174
- case lt:
175
- return be(e);
176
- case at:
177
- case it:
178
- return new t(+e);
179
- case ht:
180
- return et(e);
181
- case pt:
182
- case gt:
183
- case vt:
184
- case bt:
185
- case wt:
186
- case mt:
187
- case yt:
188
- case xt:
189
- case Et:
190
- return wn(e, r);
191
- case ot:
192
- return new t();
193
- case st:
194
- case ft:
195
- return new t(e);
196
- case dt:
197
- return rt(e);
198
- case ut:
199
- return new t();
200
- case ct:
201
- return tt(e);
202
- }
203
- }
204
- function mn(e) {
205
- return typeof e.constructor == "function" && !an(e) ? _r(pn(e)) : {};
206
- }
207
- var Ot = "[object Map]";
208
- function Nt(e) {
209
- return he(e) && pe(e) == Ot;
210
- }
211
- var Ge = V && V.isMap, Pt = Ge ? ge(Ge) : Nt, Tt = "[object Set]";
212
- function St(e) {
213
- return he(e) && pe(e) == Tt;
214
- }
215
- var Ye = V && V.isSet, Ct = Ye ? ge(Ye) : St, It = 1, yn = "[object Arguments]", Rt = "[object Array]", kt = "[object Boolean]", _t = "[object Date]", Mt = "[object Error]", xn = "[object Function]", At = "[object GeneratorFunction]", jt = "[object Map]", Dt = "[object Number]", En = "[object Object]", Bt = "[object RegExp]", $t = "[object Set]", Ft = "[object String]", Xt = "[object Symbol]", Gt = "[object WeakMap]", Yt = "[object ArrayBuffer]", Ut = "[object DataView]", Vt = "[object Float32Array]", Wt = "[object Float64Array]", qt = "[object Int8Array]", Ht = "[object Int16Array]", zt = "[object Int32Array]", Jt = "[object Uint8Array]", Kt = "[object Uint8ClampedArray]", Zt = "[object Uint16Array]", Qt = "[object Uint32Array]", y = {};
216
- y[yn] = y[Rt] = y[Yt] = y[Ut] = y[kt] = y[_t] = y[Vt] = y[Wt] = y[qt] = y[Ht] = y[zt] = y[jt] = y[Dt] = y[En] = y[Bt] = y[$t] = y[Ft] = y[Xt] = y[Jt] = y[Kt] = y[Zt] = y[Qt] = !0;
217
- y[Mt] = y[xn] = y[Gt] = !1;
218
- function Y(e, n, r, t, a, o) {
219
- var i, s = n & It;
220
- if (i !== void 0)
221
- return i;
222
- if (!O(e))
223
- return e;
224
- var d = I(e);
225
- if (d)
226
- i = Qr(e);
227
- else {
228
- var u = pe(e), f = u == xn || u == At;
229
- if (sn(e))
230
- return bn(e, s);
231
- if (u == En || u == yn || f && !a)
232
- i = f ? {} : mn(e);
233
- else {
234
- if (!y[u])
235
- return a ? e : {};
236
- i = Lt(e, u, s);
237
- }
238
- }
239
- o || (o = new dn());
240
- var c = o.get(e);
241
- if (c)
242
- return c;
243
- o.set(e, i), Ct(e) ? e.forEach(function(p) {
244
- i.add(Y(p, n, r, p, e, o));
245
- }) : Pt(e) && e.forEach(function(p, g) {
246
- i.set(g, Y(p, n, r, g, e, o));
247
- });
248
- var h = fr, v = d ? void 0 : h(e);
249
- return ur(v || e, function(p, g) {
250
- v && (g = p, p = e[g]), Z(i, g, Y(p, n, r, g, e, o));
251
- }), i;
252
- }
253
- var ea = 1, na = 4;
254
- function ra(e) {
255
- return Y(e, ea | na);
256
- }
257
- var Ln = Object.prototype, ta = Ln.hasOwnProperty, aa = le(function(e, n) {
258
- e = Object(e);
259
- var r = -1, t = n.length, a = t > 2 ? n[2] : void 0;
260
- for (a && j(n[0], n[1], a) && (t = 1); ++r < t; )
261
- for (var o = n[r], i = Q(o), s = -1, d = i.length; ++s < d; ) {
262
- var u = i[s], f = e[u];
263
- (f === void 0 || H(f, Ln[u]) && !ta.call(e, u)) && (e[u] = o[u]);
264
- }
265
- return e;
266
- });
267
- function se(e, n, r) {
268
- (r !== void 0 && !H(e[n], r) || r === void 0 && !(n in e)) && K(e, n, r);
269
- }
270
- function de(e, n) {
271
- if (!(n === "constructor" && typeof e[n] == "function") && n != "__proto__")
272
- return e[n];
273
- }
274
- function ia(e) {
275
- return Dr(e, Q(e));
276
- }
277
- function oa(e, n, r, t, a, o, i) {
278
- var s = de(e, r), d = de(n, r), u = i.get(d);
279
- if (u) {
280
- se(e, r, u);
281
- return;
282
- }
283
- var f = o ? o(s, d, r + "", e, n, i) : void 0, c = f === void 0;
284
- if (c) {
285
- var h = I(d), v = !h && sn(d), p = !h && !v && cr(d);
286
- f = d, h || v || p ? I(s) ? f = s : lr(s) ? f = Mr(s) : v ? (c = !1, f = bn(d, !0)) : p ? (c = !1, f = wn(d, !0)) : f = [] : zr(d) || _e(d) ? (f = s, _e(s) ? f = ia(s) : (!O(s) || hr(s)) && (f = mn(d))) : c = !1;
287
- }
288
- c && (i.set(d, f), a(f, d, t, o, i), i.delete(d)), se(e, r, f);
289
- }
290
- function On(e, n, r, t, a) {
291
- e !== n && un(n, function(o, i) {
292
- if (a || (a = new dn()), O(o))
293
- oa(e, n, i, r, On, t, a);
294
- else {
295
- var s = t ? t(de(e, i), o, i + "", e, n, a) : void 0;
296
- s === void 0 && (s = o), se(e, i, s);
297
- }
298
- }, Q);
299
- }
300
- function W(e) {
301
- var n = e == null ? 0 : e.length;
302
- return n ? e[n - 1] : void 0;
303
- }
304
- function sa(e) {
305
- return function(n, r, t) {
306
- var a = Object(n);
307
- if (!z(n)) {
308
- var o = _(r);
309
- n = pr(n), r = function(s) {
310
- return o(a[s], s, a);
311
- };
312
- }
313
- var i = e(n, r, t);
314
- return i > -1 ? a[o ? n[i] : i] : void 0;
315
- };
316
- }
317
- var da = Math.max;
318
- function ua(e, n, r) {
319
- var t = e == null ? 0 : e.length;
320
- if (!t)
321
- return -1;
322
- var a = r == null ? 0 : kr(r);
323
- return a < 0 && (a = da(t + a, 0)), gr(e, _(n), a);
324
- }
325
- var we = sa(ua);
326
- function Nn(e, n) {
327
- var r = -1, t = z(e) ? Array(e.length) : [];
328
- return vr(e, function(a, o, i) {
329
- t[++r] = n(a, o, i);
330
- }), t;
331
- }
332
- function E(e, n) {
333
- var r = I(e) ? X : Nn;
334
- return r(e, _(n));
335
- }
336
- function fa(e, n) {
337
- return e == null ? e : un(e, fn(n), Q);
338
- }
339
- function ca(e, n) {
340
- return e && cn(e, fn(n));
341
- }
342
- function la(e, n) {
343
- return e > n;
344
- }
345
- var ha = Object.prototype, pa = ha.hasOwnProperty;
346
- function ga(e, n) {
347
- return e != null && pa.call(e, n);
348
- }
349
- function Pn(e, n) {
350
- return e != null && br(e, n, ga);
351
- }
352
- function Tn(e, n) {
353
- return e < n;
354
- }
355
- function ee(e, n) {
356
- var r = {};
357
- return n = _(n), cn(e, function(t, a, o) {
358
- K(r, a, n(t, a, o));
359
- }), r;
360
- }
361
- function me(e, n, r) {
362
- for (var t = -1, a = e.length; ++t < a; ) {
363
- var o = e[t], i = n(o);
364
- if (i != null && (s === void 0 ? i === i && !U(i) : r(i, s)))
365
- var s = i, d = o;
366
- }
367
- return d;
368
- }
369
- function S(e) {
370
- return e && e.length ? me(e, ve, la) : void 0;
371
- }
372
- var ue = Br(function(e, n, r) {
373
- On(e, n, r);
374
- });
375
- function D(e) {
376
- return e && e.length ? me(e, ve, Tn) : void 0;
377
- }
378
- function ye(e, n) {
379
- return e && e.length ? me(e, _(n), Tn) : void 0;
380
- }
381
- function va(e, n, r, t) {
382
- if (!O(e))
383
- return e;
384
- n = ln(n, e);
385
- for (var a = -1, o = n.length, i = o - 1, s = e; s != null && ++a < o; ) {
386
- var d = wr(n[a]), u = r;
387
- if (d === "__proto__" || d === "constructor" || d === "prototype")
388
- return e;
389
- if (a != i) {
390
- var f = s[d];
391
- u = void 0, u === void 0 && (u = O(f) ? f : tn(n[a + 1]) ? [] : {});
392
- }
393
- Z(s, d, u), s = s[d];
394
- }
395
- return e;
396
- }
397
- function ba(e, n, r) {
398
- for (var t = -1, a = n.length, o = {}; ++t < a; ) {
399
- var i = n[t], s = hn(e, i);
400
- r(s, i) && va(o, ln(i, e), s);
401
- }
402
- return o;
403
- }
404
- function wa(e, n) {
405
- var r = e.length;
406
- for (e.sort(n); r--; )
407
- e[r] = e[r].value;
408
- return e;
409
- }
410
- function ma(e, n) {
411
- if (e !== n) {
412
- var r = e !== void 0, t = e === null, a = e === e, o = U(e), i = n !== void 0, s = n === null, d = n === n, u = U(n);
413
- if (!s && !u && !o && e > n || o && i && d && !s && !u || t && i && d || !r && d || !a)
414
- return 1;
415
- if (!t && !o && !u && e < n || u && r && a && !t && !o || s && r && a || !i && a || !d)
416
- return -1;
417
- }
418
- return 0;
419
- }
420
- function ya(e, n, r) {
421
- for (var t = -1, a = e.criteria, o = n.criteria, i = a.length, s = r.length; ++t < i; ) {
422
- var d = ma(a[t], o[t]);
423
- if (d) {
424
- if (t >= s)
425
- return d;
426
- var u = r[t];
427
- return d * (u == "desc" ? -1 : 1);
428
- }
429
- }
430
- return e.index - n.index;
431
- }
432
- function xa(e, n, r) {
433
- n.length ? n = X(n, function(o) {
434
- return I(o) ? function(i) {
435
- return hn(i, o.length === 1 ? o[0] : o);
436
- } : o;
437
- }) : n = [ve];
438
- var t = -1;
439
- n = X(n, ge(_));
440
- var a = Nn(e, function(o, i, s) {
441
- var d = X(n, function(u) {
442
- return u(o);
443
- });
444
- return { criteria: d, index: ++t, value: o };
445
- });
446
- return wa(a, function(o, i) {
447
- return ya(o, i, r);
448
- });
449
- }
450
- function Ea(e, n) {
451
- return ba(e, n, function(r, t) {
452
- return mr(e, t);
453
- });
454
- }
455
- var q = Yr(function(e, n) {
456
- return e == null ? {} : Ea(e, n);
457
- }), La = Math.ceil, Oa = Math.max;
458
- function Na(e, n, r, t) {
459
- for (var a = -1, o = Oa(La((n - e) / (r || 1)), 0), i = Array(o); o--; )
460
- i[++a] = e, e += r;
461
- return i;
462
- }
463
- function Pa(e) {
464
- return function(n, r, t) {
465
- return t && typeof t != "number" && j(n, r, t) && (r = t = void 0), n = G(n), r === void 0 ? (r = n, n = 0) : r = G(r), t = t === void 0 ? n < r ? 1 : -1 : G(t), Na(n, r, t);
466
- };
467
- }
468
- var k = Pa(), F = le(function(e, n) {
469
- if (e == null)
470
- return [];
471
- var r = n.length;
472
- return r > 1 && j(e, n[0], n[1]) ? n = [] : r > 2 && j(n[0], n[1], n[2]) && (n = [n[0]]), xa(e, on(n), []);
473
- }), Ta = 0;
474
- function xe(e) {
475
- var n = ++Ta;
476
- return yr(e) + n;
477
- }
478
- function Sa(e, n, r) {
479
- for (var t = -1, a = e.length, o = n.length, i = {}; ++t < a; ) {
480
- var s = t < o ? n[t] : void 0;
481
- r(i, e[t], s);
482
- }
483
- return i;
484
- }
485
- function Ca(e, n) {
486
- return Sa(e || [], n || [], Z);
487
- }
488
- class Ia {
489
- constructor() {
490
- var n = {};
491
- n._next = n._prev = n, this._sentinel = n;
492
- }
493
- dequeue() {
494
- var n = this._sentinel, r = n._prev;
495
- if (r !== n)
496
- return Ue(r), r;
497
- }
498
- enqueue(n) {
499
- var r = this._sentinel;
500
- n._prev && n._next && Ue(n), n._next = r._next, r._next._prev = n, r._next = n, n._prev = r;
501
- }
502
- toString() {
503
- for (var n = [], r = this._sentinel, t = r._prev; t !== r; )
504
- n.push(JSON.stringify(t, Ra)), t = t._prev;
505
- return "[" + n.join(", ") + "]";
506
- }
507
- }
508
- function Ue(e) {
509
- e._prev._next = e._next, e._next._prev = e._prev, delete e._next, delete e._prev;
510
- }
511
- function Ra(e, n) {
512
- if (e !== "_next" && e !== "_prev")
513
- return n;
514
- }
515
- var ka = xr(1);
516
- function _a(e, n) {
517
- if (e.nodeCount() <= 1)
518
- return [];
519
- var r = Aa(e, n || ka), t = Ma(r.graph, r.buckets, r.zeroIdx);
520
- return M(
521
- E(t, function(a) {
522
- return e.outEdges(a.v, a.w);
523
- })
524
- );
525
- }
526
- function Ma(e, n, r) {
527
- for (var t = [], a = n[n.length - 1], o = n[0], i; e.nodeCount(); ) {
528
- for (; i = o.dequeue(); )
529
- re(e, n, r, i);
530
- for (; i = a.dequeue(); )
531
- re(e, n, r, i);
532
- if (e.nodeCount()) {
533
- for (var s = n.length - 2; s > 0; --s)
534
- if (i = n[s].dequeue(), i) {
535
- t = t.concat(re(e, n, r, i, !0));
536
- break;
537
- }
538
- }
539
- }
540
- return t;
541
- }
542
- function re(e, n, r, t, a) {
543
- var o = a ? [] : void 0;
544
- return l(e.inEdges(t.v), function(i) {
545
- var s = e.edge(i), d = e.node(i.v);
546
- a && o.push({ v: i.v, w: i.w }), d.out -= s, fe(n, r, d);
547
- }), l(e.outEdges(t.v), function(i) {
548
- var s = e.edge(i), d = i.w, u = e.node(d);
549
- u.in -= s, fe(n, r, u);
550
- }), e.removeNode(t.v), o;
551
- }
552
- function Aa(e, n) {
553
- var r = new N(), t = 0, a = 0;
554
- l(e.nodes(), function(s) {
555
- r.setNode(s, { v: s, in: 0, out: 0 });
556
- }), l(e.edges(), function(s) {
557
- var d = r.edge(s.v, s.w) || 0, u = n(s), f = d + u;
558
- r.setEdge(s.v, s.w, f), a = Math.max(a, r.node(s.v).out += u), t = Math.max(t, r.node(s.w).in += u);
559
- });
560
- var o = k(a + t + 3).map(function() {
561
- return new Ia();
562
- }), i = t + 1;
563
- return l(r.nodes(), function(s) {
564
- fe(o, i, r.node(s));
565
- }), { graph: r, buckets: o, zeroIdx: i };
566
- }
567
- function fe(e, n, r) {
568
- r.out ? r.in ? e[r.out - r.in + n].enqueue(r) : e[e.length - 1].enqueue(r) : e[0].enqueue(r);
569
- }
570
- function ja(e) {
571
- var n = e.graph().acyclicer === "greedy" ? _a(e, r(e)) : Da(e);
572
- l(n, function(t) {
573
- var a = e.edge(t);
574
- e.removeEdge(t), a.forwardName = t.name, a.reversed = !0, e.setEdge(t.w, t.v, a, xe("rev"));
575
- });
576
- function r(t) {
577
- return function(a) {
578
- return t.edge(a).weight;
579
- };
580
- }
581
- }
582
- function Da(e) {
583
- var n = [], r = {}, t = {};
584
- function a(o) {
585
- Object.prototype.hasOwnProperty.call(t, o) || (t[o] = !0, r[o] = !0, l(e.outEdges(o), function(i) {
586
- Object.prototype.hasOwnProperty.call(r, i.w) ? n.push(i) : a(i.w);
587
- }), delete r[o]);
588
- }
589
- return l(e.nodes(), a), n;
590
- }
591
- function Ba(e) {
592
- l(e.edges(), function(n) {
593
- var r = e.edge(n);
594
- if (r.reversed) {
595
- e.removeEdge(n);
596
- var t = r.forwardName;
597
- delete r.reversed, delete r.forwardName, e.setEdge(n.w, n.v, r, t);
598
- }
599
- });
600
- }
601
- function A(e, n, r, t) {
602
- var a;
603
- do
604
- a = xe(t);
605
- while (e.hasNode(a));
606
- return r.dummy = n, e.setNode(a, r), a;
607
- }
608
- function $a(e) {
609
- var n = new N().setGraph(e.graph());
610
- return l(e.nodes(), function(r) {
611
- n.setNode(r, e.node(r));
612
- }), l(e.edges(), function(r) {
613
- var t = n.edge(r.v, r.w) || { weight: 0, minlen: 1 }, a = e.edge(r);
614
- n.setEdge(r.v, r.w, {
615
- weight: t.weight + a.weight,
616
- minlen: Math.max(t.minlen, a.minlen)
617
- });
618
- }), n;
619
- }
620
- function Sn(e) {
621
- var n = new N({ multigraph: e.isMultigraph() }).setGraph(e.graph());
622
- return l(e.nodes(), function(r) {
623
- e.children(r).length || n.setNode(r, e.node(r));
624
- }), l(e.edges(), function(r) {
625
- n.setEdge(r, e.edge(r));
626
- }), n;
627
- }
628
- function Ve(e, n) {
629
- var r = e.x, t = e.y, a = n.x - r, o = n.y - t, i = e.width / 2, s = e.height / 2;
630
- if (!a && !o)
631
- throw new Error("Not possible to find intersection inside of the rectangle");
632
- var d, u;
633
- return Math.abs(o) * i > Math.abs(a) * s ? (o < 0 && (s = -s), d = s * a / o, u = s) : (a < 0 && (i = -i), d = i, u = i * o / a), { x: r + d, y: t + u };
634
- }
635
- function ne(e) {
636
- var n = E(k(Cn(e) + 1), function() {
637
- return [];
638
- });
639
- return l(e.nodes(), function(r) {
640
- var t = e.node(r), a = t.rank;
641
- L(a) || (n[a][t.order] = r);
642
- }), n;
643
- }
644
- function Fa(e) {
645
- var n = D(
646
- E(e.nodes(), function(r) {
647
- return e.node(r).rank;
648
- })
649
- );
650
- l(e.nodes(), function(r) {
651
- var t = e.node(r);
652
- Pn(t, "rank") && (t.rank -= n);
653
- });
654
- }
655
- function Xa(e) {
656
- var n = D(
657
- E(e.nodes(), function(o) {
658
- return e.node(o).rank;
659
- })
660
- ), r = [];
661
- l(e.nodes(), function(o) {
662
- var i = e.node(o).rank - n;
663
- r[i] || (r[i] = []), r[i].push(o);
664
- });
665
- var t = 0, a = e.graph().nodeRankFactor;
666
- l(r, function(o, i) {
667
- L(o) && i % a !== 0 ? --t : t && l(o, function(s) {
668
- e.node(s).rank += t;
669
- });
670
- });
671
- }
672
- function We(e, n, r, t) {
673
- var a = {
674
- width: 0,
675
- height: 0
676
- };
677
- return arguments.length >= 4 && (a.rank = r, a.order = t), A(e, "border", a, n);
678
- }
679
- function Cn(e) {
680
- return S(
681
- E(e.nodes(), function(n) {
682
- var r = e.node(n).rank;
683
- if (!L(r))
684
- return r;
685
- })
686
- );
687
- }
688
- function Ga(e, n) {
689
- var r = { lhs: [], rhs: [] };
690
- return l(e, function(t) {
691
- n(t) ? r.lhs.push(t) : r.rhs.push(t);
692
- }), r;
693
- }
694
- function Ya(e, n) {
695
- return n();
696
- }
697
- function Ua(e) {
698
- function n(r) {
699
- var t = e.children(r), a = e.node(r);
700
- if (t.length && l(t, n), Object.prototype.hasOwnProperty.call(a, "minRank")) {
701
- a.borderLeft = [], a.borderRight = [];
702
- for (var o = a.minRank, i = a.maxRank + 1; o < i; ++o)
703
- qe(e, "borderLeft", "_bl", r, a, o), qe(e, "borderRight", "_br", r, a, o);
704
- }
705
- }
706
- l(e.children(), n);
707
- }
708
- function qe(e, n, r, t, a, o) {
709
- var i = { width: 0, height: 0, rank: o, borderType: n }, s = a[n][o - 1], d = A(e, "border", i, r);
710
- a[n][o] = d, e.setParent(d, t), s && e.setEdge(s, d, { weight: 1 });
711
- }
712
- function Va(e) {
713
- var n = e.graph().rankdir.toLowerCase();
714
- (n === "lr" || n === "rl") && In(e);
715
- }
716
- function Wa(e) {
717
- var n = e.graph().rankdir.toLowerCase();
718
- (n === "bt" || n === "rl") && qa(e), (n === "lr" || n === "rl") && (Ha(e), In(e));
719
- }
720
- function In(e) {
721
- l(e.nodes(), function(n) {
722
- He(e.node(n));
723
- }), l(e.edges(), function(n) {
724
- He(e.edge(n));
725
- });
726
- }
727
- function He(e) {
728
- var n = e.width;
729
- e.width = e.height, e.height = n;
730
- }
731
- function qa(e) {
732
- l(e.nodes(), function(n) {
733
- te(e.node(n));
734
- }), l(e.edges(), function(n) {
735
- var r = e.edge(n);
736
- l(r.points, te), Object.prototype.hasOwnProperty.call(r, "y") && te(r);
737
- });
738
- }
739
- function te(e) {
740
- e.y = -e.y;
741
- }
742
- function Ha(e) {
743
- l(e.nodes(), function(n) {
744
- ae(e.node(n));
745
- }), l(e.edges(), function(n) {
746
- var r = e.edge(n);
747
- l(r.points, ae), Object.prototype.hasOwnProperty.call(r, "x") && ae(r);
748
- });
749
- }
750
- function ae(e) {
751
- var n = e.x;
752
- e.x = e.y, e.y = n;
753
- }
754
- function za(e) {
755
- e.graph().dummyChains = [], l(e.edges(), function(n) {
756
- Ja(e, n);
757
- });
758
- }
759
- function Ja(e, n) {
760
- var r = n.v, t = e.node(r).rank, a = n.w, o = e.node(a).rank, i = n.name, s = e.edge(n), d = s.labelRank;
761
- if (o !== t + 1) {
762
- e.removeEdge(n);
763
- var u = void 0, f, c;
764
- for (c = 0, ++t; t < o; ++c, ++t)
765
- s.points = [], u = {
766
- width: 0,
767
- height: 0,
768
- edgeLabel: s,
769
- edgeObj: n,
770
- rank: t
771
- }, f = A(e, "edge", u, "_d"), t === d && (u.width = s.width, u.height = s.height, u.dummy = "edge-label", u.labelpos = s.labelpos), e.setEdge(r, f, { weight: s.weight }, i), c === 0 && e.graph().dummyChains.push(f), r = f;
772
- e.setEdge(r, a, { weight: s.weight }, i);
773
- }
774
- }
775
- function Ka(e) {
776
- l(e.graph().dummyChains, function(n) {
777
- var r = e.node(n), t = r.edgeLabel, a;
778
- for (e.setEdge(r.edgeObj, t); r.dummy; )
779
- a = e.successors(n)[0], e.removeNode(n), t.points.push({ x: r.x, y: r.y }), r.dummy === "edge-label" && (t.x = r.x, t.y = r.y, t.width = r.width, t.height = r.height), n = a, r = e.node(n);
780
- });
781
- }
782
- function Ee(e) {
783
- var n = {};
784
- function r(t) {
785
- var a = e.node(t);
786
- if (Object.prototype.hasOwnProperty.call(n, t))
787
- return a.rank;
788
- n[t] = !0;
789
- var o = D(
790
- E(e.outEdges(t), function(i) {
791
- return r(i.w) - e.edge(i).minlen;
792
- })
793
- );
794
- return (o === Number.POSITIVE_INFINITY || // return value of _.map([]) for Lodash 3
795
- o === void 0 || // return value of _.map([]) for Lodash 4
796
- o === null) && (o = 0), a.rank = o;
797
- }
798
- l(e.sources(), r);
799
- }
800
- function B(e, n) {
801
- return e.node(n.w).rank - e.node(n.v).rank - e.edge(n).minlen;
802
- }
803
- function Rn(e) {
804
- var n = new N({ directed: !1 }), r = e.nodes()[0], t = e.nodeCount();
805
- n.setNode(r, {});
806
- for (var a, o; Za(n, e) < t; )
807
- a = Qa(n, e), o = n.hasNode(a.v) ? B(e, a) : -B(e, a), ei(n, e, o);
808
- return n;
809
- }
810
- function Za(e, n) {
811
- function r(t) {
812
- l(n.nodeEdges(t), function(a) {
813
- var o = a.v, i = t === o ? a.w : o;
814
- !e.hasNode(i) && !B(n, a) && (e.setNode(i, {}), e.setEdge(t, i, {}), r(i));
815
- });
816
- }
817
- return l(e.nodes(), r), e.nodeCount();
818
- }
819
- function Qa(e, n) {
820
- return ye(n.edges(), function(r) {
821
- if (e.hasNode(r.v) !== e.hasNode(r.w))
822
- return B(n, r);
823
- });
824
- }
825
- function ei(e, n, r) {
826
- l(e.nodes(), function(t) {
827
- n.node(t).rank += r;
828
- });
829
- }
830
- function ni() {
831
- }
832
- ni.prototype = new Error();
833
- function kn(e, n, r) {
834
- I(n) || (n = [n]);
835
- var t = (e.isDirected() ? e.successors : e.neighbors).bind(e), a = [], o = {};
836
- return l(n, function(i) {
837
- if (!e.hasNode(i))
838
- throw new Error("Graph does not have node: " + i);
839
- _n(e, i, r === "post", o, t, a);
840
- }), a;
841
- }
842
- function _n(e, n, r, t, a, o) {
843
- Object.prototype.hasOwnProperty.call(t, n) || (t[n] = !0, r || o.push(n), l(a(n), function(i) {
844
- _n(e, i, r, t, a, o);
845
- }), r && o.push(n));
846
- }
847
- function ri(e, n) {
848
- return kn(e, n, "post");
849
- }
850
- function ti(e, n) {
851
- return kn(e, n, "pre");
852
- }
853
- C.initLowLimValues = Oe;
854
- C.initCutValues = Le;
855
- C.calcCutValue = Mn;
856
- C.leaveEdge = jn;
857
- C.enterEdge = Dn;
858
- C.exchangeEdges = Bn;
859
- function C(e) {
860
- e = $a(e), Ee(e);
861
- var n = Rn(e);
862
- Oe(n), Le(n, e);
863
- for (var r, t; r = jn(n); )
864
- t = Dn(n, e, r), Bn(n, e, r, t);
865
- }
866
- function Le(e, n) {
867
- var r = ri(e, e.nodes());
868
- r = r.slice(0, r.length - 1), l(r, function(t) {
869
- ai(e, n, t);
870
- });
871
- }
872
- function ai(e, n, r) {
873
- var t = e.node(r), a = t.parent;
874
- e.edge(r, a).cutvalue = Mn(e, n, r);
875
- }
876
- function Mn(e, n, r) {
877
- var t = e.node(r), a = t.parent, o = !0, i = n.edge(r, a), s = 0;
878
- return i || (o = !1, i = n.edge(a, r)), s = i.weight, l(n.nodeEdges(r), function(d) {
879
- var u = d.v === r, f = u ? d.w : d.v;
880
- if (f !== a) {
881
- var c = u === o, h = n.edge(d).weight;
882
- if (s += c ? h : -h, oi(e, r, f)) {
883
- var v = e.edge(r, f).cutvalue;
884
- s += c ? -v : v;
885
- }
886
- }
887
- }), s;
888
- }
889
- function Oe(e, n) {
890
- arguments.length < 2 && (n = e.nodes()[0]), An(e, {}, 1, n);
891
- }
892
- function An(e, n, r, t, a) {
893
- var o = r, i = e.node(t);
894
- return n[t] = !0, l(e.neighbors(t), function(s) {
895
- Object.prototype.hasOwnProperty.call(n, s) || (r = An(e, n, r, s, t));
896
- }), i.low = o, i.lim = r++, a ? i.parent = a : delete i.parent, r;
897
- }
898
- function jn(e) {
899
- return we(e.edges(), function(n) {
900
- return e.edge(n).cutvalue < 0;
901
- });
902
- }
903
- function Dn(e, n, r) {
904
- var t = r.v, a = r.w;
905
- n.hasEdge(t, a) || (t = r.w, a = r.v);
906
- var o = e.node(t), i = e.node(a), s = o, d = !1;
907
- o.lim > i.lim && (s = i, d = !0);
908
- var u = $(n.edges(), function(f) {
909
- return d === ze(e, e.node(f.v), s) && d !== ze(e, e.node(f.w), s);
910
- });
911
- return ye(u, function(f) {
912
- return B(n, f);
913
- });
914
- }
915
- function Bn(e, n, r, t) {
916
- var a = r.v, o = r.w;
917
- e.removeEdge(a, o), e.setEdge(t.v, t.w, {}), Oe(e), Le(e, n), ii(e, n);
918
- }
919
- function ii(e, n) {
920
- var r = we(e.nodes(), function(a) {
921
- return !n.node(a).parent;
922
- }), t = ti(e, r);
923
- t = t.slice(1), l(t, function(a) {
924
- var o = e.node(a).parent, i = n.edge(a, o), s = !1;
925
- i || (i = n.edge(o, a), s = !0), n.node(a).rank = n.node(o).rank + (s ? i.minlen : -i.minlen);
926
- });
927
- }
928
- function oi(e, n, r) {
929
- return e.hasEdge(n, r);
930
- }
931
- function ze(e, n, r) {
932
- return r.low <= n.lim && n.lim <= r.lim;
933
- }
934
- function si(e) {
935
- switch (e.graph().ranker) {
936
- case "network-simplex":
937
- Je(e);
938
- break;
939
- case "tight-tree":
940
- ui(e);
941
- break;
942
- case "longest-path":
943
- di(e);
944
- break;
945
- default:
946
- Je(e);
947
- }
948
- }
949
- var di = Ee;
950
- function ui(e) {
951
- Ee(e), Rn(e);
952
- }
953
- function Je(e) {
954
- C(e);
955
- }
956
- function fi(e) {
957
- var n = A(e, "root", {}, "_root"), r = ci(e), t = S(R(r)) - 1, a = 2 * t + 1;
958
- e.graph().nestingRoot = n, l(e.edges(), function(i) {
959
- e.edge(i).minlen *= a;
960
- });
961
- var o = li(e) + 1;
962
- l(e.children(), function(i) {
963
- $n(e, n, a, o, t, r, i);
964
- }), e.graph().nodeRankFactor = a;
965
- }
966
- function $n(e, n, r, t, a, o, i) {
967
- var s = e.children(i);
968
- if (!s.length) {
969
- i !== n && e.setEdge(n, i, { weight: 0, minlen: r });
970
- return;
971
- }
972
- var d = We(e, "_bt"), u = We(e, "_bb"), f = e.node(i);
973
- e.setParent(d, i), f.borderTop = d, e.setParent(u, i), f.borderBottom = u, l(s, function(c) {
974
- $n(e, n, r, t, a, o, c);
975
- var h = e.node(c), v = h.borderTop ? h.borderTop : c, p = h.borderBottom ? h.borderBottom : c, g = h.borderTop ? t : 2 * t, b = v !== p ? 1 : a - o[i] + 1;
976
- e.setEdge(d, v, {
977
- weight: g,
978
- minlen: b,
979
- nestingEdge: !0
980
- }), e.setEdge(p, u, {
981
- weight: g,
982
- minlen: b,
983
- nestingEdge: !0
984
- });
985
- }), e.parent(i) || e.setEdge(n, d, { weight: 0, minlen: a + o[i] });
986
- }
987
- function ci(e) {
988
- var n = {};
989
- function r(t, a) {
990
- var o = e.children(t);
991
- o && o.length && l(o, function(i) {
992
- r(i, a + 1);
993
- }), n[t] = a;
994
- }
995
- return l(e.children(), function(t) {
996
- r(t, 1);
997
- }), n;
998
- }
999
- function li(e) {
1000
- return J(
1001
- e.edges(),
1002
- function(n, r) {
1003
- return n + e.edge(r).weight;
1004
- },
1005
- 0
1006
- );
1007
- }
1008
- function hi(e) {
1009
- var n = e.graph();
1010
- e.removeNode(n.nestingRoot), delete n.nestingRoot, l(e.edges(), function(r) {
1011
- var t = e.edge(r);
1012
- t.nestingEdge && e.removeEdge(r);
1013
- });
1014
- }
1015
- function pi(e, n, r) {
1016
- var t = {}, a;
1017
- l(r, function(o) {
1018
- for (var i = e.parent(o), s, d; i; ) {
1019
- if (s = e.parent(i), s ? (d = t[s], t[s] = i) : (d = a, a = i), d && d !== i) {
1020
- n.setEdge(d, i);
1021
- return;
1022
- }
1023
- i = s;
1024
- }
1025
- });
1026
- }
1027
- function gi(e, n, r) {
1028
- var t = vi(e), a = new N({ compound: !0 }).setGraph({ root: t }).setDefaultNodeLabel(function(o) {
1029
- return e.node(o);
1030
- });
1031
- return l(e.nodes(), function(o) {
1032
- var i = e.node(o), s = e.parent(o);
1033
- (i.rank === n || i.minRank <= n && n <= i.maxRank) && (a.setNode(o), a.setParent(o, s || t), l(e[r](o), function(d) {
1034
- var u = d.v === o ? d.w : d.v, f = a.edge(u, o), c = L(f) ? 0 : f.weight;
1035
- a.setEdge(u, o, { weight: e.edge(d).weight + c });
1036
- }), Object.prototype.hasOwnProperty.call(i, "minRank") && a.setNode(o, {
1037
- borderLeft: i.borderLeft[n],
1038
- borderRight: i.borderRight[n]
1039
- }));
1040
- }), a;
1041
- }
1042
- function vi(e) {
1043
- for (var n; e.hasNode(n = xe("_root")); ) ;
1044
- return n;
1045
- }
1046
- function bi(e, n) {
1047
- for (var r = 0, t = 1; t < n.length; ++t)
1048
- r += wi(e, n[t - 1], n[t]);
1049
- return r;
1050
- }
1051
- function wi(e, n, r) {
1052
- for (var t = Ca(
1053
- r,
1054
- E(r, function(u, f) {
1055
- return f;
1056
- })
1057
- ), a = M(
1058
- E(n, function(u) {
1059
- return F(
1060
- E(e.outEdges(u), function(f) {
1061
- return { pos: t[f.w], weight: e.edge(f).weight };
1062
- }),
1063
- "pos"
1064
- );
1065
- })
1066
- ), o = 1; o < r.length; ) o <<= 1;
1067
- var i = 2 * o - 1;
1068
- o -= 1;
1069
- var s = E(new Array(i), function() {
1070
- return 0;
1071
- }), d = 0;
1072
- return l(
1073
- // @ts-expect-error
1074
- a.forEach(function(u) {
1075
- var f = u.pos + o;
1076
- s[f] += u.weight;
1077
- for (var c = 0; f > 0; )
1078
- f % 2 && (c += s[f + 1]), f = f - 1 >> 1, s[f] += u.weight;
1079
- d += u.weight * c;
1080
- })
1081
- ), d;
1082
- }
1083
- function mi(e) {
1084
- var n = {}, r = $(e.nodes(), function(s) {
1085
- return !e.children(s).length;
1086
- }), t = S(
1087
- E(r, function(s) {
1088
- return e.node(s).rank;
1089
- })
1090
- ), a = E(k(t + 1), function() {
1091
- return [];
1092
- });
1093
- function o(s) {
1094
- if (!Pn(n, s)) {
1095
- n[s] = !0;
1096
- var d = e.node(s);
1097
- a[d.rank].push(s), l(e.successors(s), o);
1098
- }
1099
- }
1100
- var i = F(r, function(s) {
1101
- return e.node(s).rank;
1102
- });
1103
- return l(i, o), a;
1104
- }
1105
- function yi(e, n) {
1106
- return E(n, function(r) {
1107
- var t = e.inEdges(r);
1108
- if (t.length) {
1109
- var a = J(
1110
- t,
1111
- function(o, i) {
1112
- var s = e.edge(i), d = e.node(i.v);
1113
- return {
1114
- sum: o.sum + s.weight * d.order,
1115
- weight: o.weight + s.weight
1116
- };
1117
- },
1118
- { sum: 0, weight: 0 }
1119
- );
1120
- return {
1121
- v: r,
1122
- barycenter: a.sum / a.weight,
1123
- weight: a.weight
1124
- };
1125
- } else
1126
- return { v: r };
1127
- });
1128
- }
1129
- function xi(e, n) {
1130
- var r = {};
1131
- l(e, function(a, o) {
1132
- var i = r[a.v] = {
1133
- indegree: 0,
1134
- in: [],
1135
- out: [],
1136
- vs: [a.v],
1137
- i: o
1138
- };
1139
- L(a.barycenter) || (i.barycenter = a.barycenter, i.weight = a.weight);
1140
- }), l(n.edges(), function(a) {
1141
- var o = r[a.v], i = r[a.w];
1142
- !L(o) && !L(i) && (i.indegree++, o.out.push(r[a.w]));
1143
- });
1144
- var t = $(r, function(a) {
1145
- return !a.indegree;
1146
- });
1147
- return Ei(t);
1148
- }
1149
- function Ei(e) {
1150
- var n = [];
1151
- function r(o) {
1152
- return function(i) {
1153
- i.merged || (L(i.barycenter) || L(o.barycenter) || i.barycenter >= o.barycenter) && Li(o, i);
1154
- };
1155
- }
1156
- function t(o) {
1157
- return function(i) {
1158
- i.in.push(o), --i.indegree === 0 && e.push(i);
1159
- };
1160
- }
1161
- for (; e.length; ) {
1162
- var a = e.pop();
1163
- n.push(a), l(a.in.reverse(), r(a)), l(a.out, t(a));
1164
- }
1165
- return E(
1166
- $(n, function(o) {
1167
- return !o.merged;
1168
- }),
1169
- function(o) {
1170
- return q(o, ["vs", "i", "barycenter", "weight"]);
1171
- }
1172
- );
1173
- }
1174
- function Li(e, n) {
1175
- var r = 0, t = 0;
1176
- e.weight && (r += e.barycenter * e.weight, t += e.weight), n.weight && (r += n.barycenter * n.weight, t += n.weight), e.vs = n.vs.concat(e.vs), e.barycenter = r / t, e.weight = t, e.i = Math.min(n.i, e.i), n.merged = !0;
1177
- }
1178
- function Oi(e, n) {
1179
- var r = Ga(e, function(f) {
1180
- return Object.prototype.hasOwnProperty.call(f, "barycenter");
1181
- }), t = r.lhs, a = F(r.rhs, function(f) {
1182
- return -f.i;
1183
- }), o = [], i = 0, s = 0, d = 0;
1184
- t.sort(Ni(!!n)), d = Ke(o, a, d), l(t, function(f) {
1185
- d += f.vs.length, o.push(f.vs), i += f.barycenter * f.weight, s += f.weight, d = Ke(o, a, d);
1186
- });
1187
- var u = { vs: M(o) };
1188
- return s && (u.barycenter = i / s, u.weight = s), u;
1189
- }
1190
- function Ke(e, n, r) {
1191
- for (var t; n.length && (t = W(n)).i <= r; )
1192
- n.pop(), e.push(t.vs), r++;
1193
- return r;
1194
- }
1195
- function Ni(e) {
1196
- return function(n, r) {
1197
- return n.barycenter < r.barycenter ? -1 : n.barycenter > r.barycenter ? 1 : e ? r.i - n.i : n.i - r.i;
1198
- };
1199
- }
1200
- function Fn(e, n, r, t) {
1201
- var a = e.children(n), o = e.node(n), i = o ? o.borderLeft : void 0, s = o ? o.borderRight : void 0, d = {};
1202
- i && (a = $(a, function(p) {
1203
- return p !== i && p !== s;
1204
- }));
1205
- var u = yi(e, a);
1206
- l(u, function(p) {
1207
- if (e.children(p.v).length) {
1208
- var g = Fn(e, p.v, r, t);
1209
- d[p.v] = g, Object.prototype.hasOwnProperty.call(g, "barycenter") && Ti(p, g);
1210
- }
1211
- });
1212
- var f = xi(u, r);
1213
- Pi(f, d);
1214
- var c = Oi(f, t);
1215
- if (i && (c.vs = M([i, c.vs, s]), e.predecessors(i).length)) {
1216
- var h = e.node(e.predecessors(i)[0]), v = e.node(e.predecessors(s)[0]);
1217
- Object.prototype.hasOwnProperty.call(c, "barycenter") || (c.barycenter = 0, c.weight = 0), c.barycenter = (c.barycenter * c.weight + h.order + v.order) / (c.weight + 2), c.weight += 2;
1218
- }
1219
- return c;
1220
- }
1221
- function Pi(e, n) {
1222
- l(e, function(r) {
1223
- r.vs = M(
1224
- r.vs.map(function(t) {
1225
- return n[t] ? n[t].vs : t;
1226
- })
1227
- );
1228
- });
1229
- }
1230
- function Ti(e, n) {
1231
- L(e.barycenter) ? (e.barycenter = n.barycenter, e.weight = n.weight) : (e.barycenter = (e.barycenter * e.weight + n.barycenter * n.weight) / (e.weight + n.weight), e.weight += n.weight);
1232
- }
1233
- function Si(e) {
1234
- var n = Cn(e), r = Ze(e, k(1, n + 1), "inEdges"), t = Ze(e, k(n - 1, -1, -1), "outEdges"), a = mi(e);
1235
- Qe(e, a);
1236
- for (var o = Number.POSITIVE_INFINITY, i, s = 0, d = 0; d < 4; ++s, ++d) {
1237
- Ci(s % 2 ? r : t, s % 4 >= 2), a = ne(e);
1238
- var u = bi(e, a);
1239
- u < o && (d = 0, i = ra(a), o = u);
1240
- }
1241
- Qe(e, i);
1242
- }
1243
- function Ze(e, n, r) {
1244
- return E(n, function(t) {
1245
- return gi(e, t, r);
1246
- });
1247
- }
1248
- function Ci(e, n) {
1249
- var r = new N();
1250
- l(e, function(t) {
1251
- var a = t.graph().root, o = Fn(t, a, r, n);
1252
- l(o.vs, function(i, s) {
1253
- t.node(i).order = s;
1254
- }), pi(t, r, o.vs);
1255
- });
1256
- }
1257
- function Qe(e, n) {
1258
- l(n, function(r) {
1259
- l(r, function(t, a) {
1260
- e.node(t).order = a;
1261
- });
1262
- });
1263
- }
1264
- function Ii(e) {
1265
- var n = ki(e);
1266
- l(e.graph().dummyChains, function(r) {
1267
- for (var t = e.node(r), a = t.edgeObj, o = Ri(e, n, a.v, a.w), i = o.path, s = o.lca, d = 0, u = i[d], f = !0; r !== a.w; ) {
1268
- if (t = e.node(r), f) {
1269
- for (; (u = i[d]) !== s && e.node(u).maxRank < t.rank; )
1270
- d++;
1271
- u === s && (f = !1);
1272
- }
1273
- if (!f) {
1274
- for (; d < i.length - 1 && e.node(u = i[d + 1]).minRank <= t.rank; )
1275
- d++;
1276
- u = i[d];
1277
- }
1278
- e.setParent(r, u), r = e.successors(r)[0];
1279
- }
1280
- });
1281
- }
1282
- function Ri(e, n, r, t) {
1283
- var a = [], o = [], i = Math.min(n[r].low, n[t].low), s = Math.max(n[r].lim, n[t].lim), d, u;
1284
- d = r;
1285
- do
1286
- d = e.parent(d), a.push(d);
1287
- while (d && (n[d].low > i || s > n[d].lim));
1288
- for (u = d, d = t; (d = e.parent(d)) !== u; )
1289
- o.push(d);
1290
- return { path: a.concat(o.reverse()), lca: u };
1291
- }
1292
- function ki(e) {
1293
- var n = {}, r = 0;
1294
- function t(a) {
1295
- var o = r;
1296
- l(e.children(a), t), n[a] = { low: o, lim: r++ };
1297
- }
1298
- return l(e.children(), t), n;
1299
- }
1300
- function _i(e, n) {
1301
- var r = {};
1302
- function t(a, o) {
1303
- var i = 0, s = 0, d = a.length, u = W(o);
1304
- return l(o, function(f, c) {
1305
- var h = Ai(e, f), v = h ? e.node(h).order : d;
1306
- (h || f === u) && (l(o.slice(s, c + 1), function(p) {
1307
- l(e.predecessors(p), function(g) {
1308
- var b = e.node(g), w = b.order;
1309
- (w < i || v < w) && !(b.dummy && e.node(p).dummy) && Xn(r, g, p);
1310
- });
1311
- }), s = c + 1, i = v);
1312
- }), o;
1313
- }
1314
- return J(n, t), r;
1315
- }
1316
- function Mi(e, n) {
1317
- var r = {};
1318
- function t(o, i, s, d, u) {
1319
- var f;
1320
- l(k(i, s), function(c) {
1321
- f = o[c], e.node(f).dummy && l(e.predecessors(f), function(h) {
1322
- var v = e.node(h);
1323
- v.dummy && (v.order < d || v.order > u) && Xn(r, h, f);
1324
- });
1325
- });
1326
- }
1327
- function a(o, i) {
1328
- var s = -1, d, u = 0;
1329
- return l(i, function(f, c) {
1330
- if (e.node(f).dummy === "border") {
1331
- var h = e.predecessors(f);
1332
- h.length && (d = e.node(h[0]).order, t(i, u, c, s, d), u = c, s = d);
1333
- }
1334
- t(i, u, i.length, d, o.length);
1335
- }), i;
1336
- }
1337
- return J(n, a), r;
1338
- }
1339
- function Ai(e, n) {
1340
- if (e.node(n).dummy)
1341
- return we(e.predecessors(n), function(r) {
1342
- return e.node(r).dummy;
1343
- });
1344
- }
1345
- function Xn(e, n, r) {
1346
- if (n > r) {
1347
- var t = n;
1348
- n = r, r = t;
1349
- }
1350
- Object.prototype.hasOwnProperty.call(e, n) || Object.defineProperty(e, n, {
1351
- enumerable: !0,
1352
- configurable: !0,
1353
- value: {},
1354
- writable: !0
1355
- });
1356
- var a = e[n];
1357
- Object.defineProperty(a, r, {
1358
- enumerable: !0,
1359
- configurable: !0,
1360
- value: !0,
1361
- writable: !0
1362
- });
1363
- }
1364
- function ji(e, n, r) {
1365
- if (n > r) {
1366
- var t = n;
1367
- n = r, r = t;
1368
- }
1369
- return !!e[n] && Object.prototype.hasOwnProperty.call(e[n], r);
1370
- }
1371
- function Di(e, n, r, t) {
1372
- var a = {}, o = {}, i = {};
1373
- return l(n, function(s) {
1374
- l(s, function(d, u) {
1375
- a[d] = d, o[d] = d, i[d] = u;
1376
- });
1377
- }), l(n, function(s) {
1378
- var d = -1;
1379
- l(s, function(u) {
1380
- var f = t(u);
1381
- if (f.length) {
1382
- f = F(f, function(g) {
1383
- return i[g];
1384
- });
1385
- for (var c = (f.length - 1) / 2, h = Math.floor(c), v = Math.ceil(c); h <= v; ++h) {
1386
- var p = f[h];
1387
- o[u] === u && d < i[p] && !ji(r, u, p) && (o[p] = u, o[u] = a[u] = a[p], d = i[p]);
1388
- }
1389
- }
1390
- });
1391
- }), { root: a, align: o };
1392
- }
1393
- function Bi(e, n, r, t, a) {
1394
- var o = {}, i = $i(e, n, r, a), s = a ? "borderLeft" : "borderRight";
1395
- function d(c, h) {
1396
- for (var v = i.nodes(), p = v.pop(), g = {}; p; )
1397
- g[p] ? c(p) : (g[p] = !0, v.push(p), v = v.concat(h(p))), p = v.pop();
1398
- }
1399
- function u(c) {
1400
- o[c] = i.inEdges(c).reduce(function(h, v) {
1401
- return Math.max(h, o[v.v] + i.edge(v));
1402
- }, 0);
1403
- }
1404
- function f(c) {
1405
- var h = i.outEdges(c).reduce(function(p, g) {
1406
- return Math.min(p, o[g.w] - i.edge(g));
1407
- }, Number.POSITIVE_INFINITY), v = e.node(c);
1408
- h !== Number.POSITIVE_INFINITY && v.borderType !== s && (o[c] = Math.max(o[c], h));
1409
- }
1410
- return d(u, i.predecessors.bind(i)), d(f, i.successors.bind(i)), l(t, function(c) {
1411
- o[c] = o[r[c]];
1412
- }), o;
1413
- }
1414
- function $i(e, n, r, t) {
1415
- var a = new N(), o = e.graph(), i = Ui(o.nodesep, o.edgesep, t);
1416
- return l(n, function(s) {
1417
- var d;
1418
- l(s, function(u) {
1419
- var f = r[u];
1420
- if (a.setNode(f), d) {
1421
- var c = r[d], h = a.edge(c, f);
1422
- a.setEdge(c, f, Math.max(i(e, u, d), h || 0));
1423
- }
1424
- d = u;
1425
- });
1426
- }), a;
1427
- }
1428
- function Fi(e, n) {
1429
- return ye(R(n), function(r) {
1430
- var t = Number.NEGATIVE_INFINITY, a = Number.POSITIVE_INFINITY;
1431
- return fa(r, function(o, i) {
1432
- var s = Vi(e, i) / 2;
1433
- t = Math.max(o + s, t), a = Math.min(o - s, a);
1434
- }), t - a;
1435
- });
1436
- }
1437
- function Xi(e, n) {
1438
- var r = R(n), t = D(r), a = S(r);
1439
- l(["u", "d"], function(o) {
1440
- l(["l", "r"], function(i) {
1441
- var s = o + i, d = e[s], u;
1442
- if (d !== n) {
1443
- var f = R(d);
1444
- u = i === "l" ? t - D(f) : a - S(f), u && (e[s] = ee(d, function(c) {
1445
- return c + u;
1446
- }));
1447
- }
1448
- });
1449
- });
1450
- }
1451
- function Gi(e, n) {
1452
- return ee(e.ul, function(r, t) {
1453
- if (n)
1454
- return e[n.toLowerCase()][t];
1455
- var a = F(E(e, t));
1456
- return (a[1] + a[2]) / 2;
1457
- });
1458
- }
1459
- function Yi(e) {
1460
- var n = ne(e), r = ue(_i(e, n), Mi(e, n)), t = {}, a;
1461
- l(["u", "d"], function(i) {
1462
- a = i === "u" ? n : R(n).reverse(), l(["l", "r"], function(s) {
1463
- s === "r" && (a = E(a, function(c) {
1464
- return R(c).reverse();
1465
- }));
1466
- var d = (i === "u" ? e.predecessors : e.successors).bind(e), u = Di(e, a, r, d), f = Bi(e, a, u.root, u.align, s === "r");
1467
- s === "r" && (f = ee(f, function(c) {
1468
- return -c;
1469
- })), t[i + s] = f;
1470
- });
1471
- });
1472
- var o = Fi(e, t);
1473
- return Xi(t, o), Gi(t, e.graph().align);
1474
- }
1475
- function Ui(e, n, r) {
1476
- return function(t, a, o) {
1477
- var i = t.node(a), s = t.node(o), d = 0, u;
1478
- if (d += i.width / 2, Object.prototype.hasOwnProperty.call(i, "labelpos"))
1479
- switch (i.labelpos.toLowerCase()) {
1480
- case "l":
1481
- u = -i.width / 2;
1482
- break;
1483
- case "r":
1484
- u = i.width / 2;
1485
- break;
1486
- }
1487
- if (u && (d += r ? u : -u), u = 0, d += (i.dummy ? n : e) / 2, d += (s.dummy ? n : e) / 2, d += s.width / 2, Object.prototype.hasOwnProperty.call(s, "labelpos"))
1488
- switch (s.labelpos.toLowerCase()) {
1489
- case "l":
1490
- u = s.width / 2;
1491
- break;
1492
- case "r":
1493
- u = -s.width / 2;
1494
- break;
1495
- }
1496
- return u && (d += r ? u : -u), u = 0, d;
1497
- };
1498
- }
1499
- function Vi(e, n) {
1500
- return e.node(n).width;
1501
- }
1502
- function Wi(e) {
1503
- e = Sn(e), qi(e), ca(Yi(e), function(n, r) {
1504
- e.node(r).x = n;
1505
- });
1506
- }
1507
- function qi(e) {
1508
- var n = ne(e), r = e.graph().ranksep, t = 0;
1509
- l(n, function(a) {
1510
- var o = S(
1511
- E(a, function(i) {
1512
- return e.node(i).height;
1513
- })
1514
- );
1515
- l(a, function(i) {
1516
- e.node(i).y = t + o / 2;
1517
- }), t += o + r;
1518
- });
1519
- }
1520
- function Hi(e, n) {
1521
- var r = Ya;
1522
- r("layout", () => {
1523
- var t = r(" buildLayoutGraph", () => io(e));
1524
- r(" runLayout", () => zi(t, r)), r(" updateInputGraph", () => Ji(e, t));
1525
- });
1526
- }
1527
- function zi(e, n) {
1528
- n(" makeSpaceForEdgeLabels", () => oo(e)), n(" removeSelfEdges", () => vo(e)), n(" acyclic", () => ja(e)), n(" nestingGraph.run", () => fi(e)), n(" rank", () => si(Sn(e))), n(" injectEdgeLabelProxies", () => so(e)), n(" removeEmptyRanks", () => Xa(e)), n(" nestingGraph.cleanup", () => hi(e)), n(" normalizeRanks", () => Fa(e)), n(" assignRankMinMax", () => uo(e)), n(" removeEdgeLabelProxies", () => fo(e)), n(" normalize.run", () => za(e)), n(" parentDummyChains", () => Ii(e)), n(" addBorderSegments", () => Ua(e)), n(" order", () => Si(e)), n(" insertSelfEdges", () => bo(e)), n(" adjustCoordinateSystem", () => Va(e)), n(" position", () => Wi(e)), n(" positionSelfEdges", () => wo(e)), n(" removeBorderNodes", () => go(e)), n(" normalize.undo", () => Ka(e)), n(" fixupEdgeLabelCoords", () => ho(e)), n(" undoCoordinateSystem", () => Wa(e)), n(" translateGraph", () => co(e)), n(" assignNodeIntersects", () => lo(e)), n(" reversePoints", () => po(e)), n(" acyclic.undo", () => Ba(e));
1529
- }
1530
- function Ji(e, n) {
1531
- l(e.nodes(), function(r) {
1532
- var t = e.node(r), a = n.node(r);
1533
- t && (t.x = a.x, t.y = a.y, n.children(r).length && (t.width = a.width, t.height = a.height));
1534
- }), l(e.edges(), function(r) {
1535
- var t = e.edge(r), a = n.edge(r);
1536
- t.points = a.points, Object.prototype.hasOwnProperty.call(a, "x") && (t.x = a.x, t.y = a.y);
1537
- }), e.graph().width = n.graph().width, e.graph().height = n.graph().height;
1538
- }
1539
- var Ki = ["nodesep", "edgesep", "ranksep", "marginx", "marginy"], Zi = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "tb" }, Qi = ["acyclicer", "ranker", "rankdir", "align"], eo = ["width", "height"], no = { width: 0, height: 0 }, ro = ["minlen", "weight", "width", "height", "labeloffset"], to = {
1540
- minlen: 1,
1541
- weight: 1,
1542
- width: 0,
1543
- height: 0,
1544
- labeloffset: 10,
1545
- labelpos: "r"
1546
- }, ao = ["labelpos"];
1547
- function io(e) {
1548
- var n = new N({ multigraph: !0, compound: !0 }), r = oe(e.graph());
1549
- return n.setGraph(
1550
- ue({}, Zi, ie(r, Ki), q(r, Qi))
1551
- ), l(e.nodes(), function(t) {
1552
- var a = oe(e.node(t));
1553
- n.setNode(t, aa(ie(a, eo), no)), n.setParent(t, e.parent(t));
1554
- }), l(e.edges(), function(t) {
1555
- var a = oe(e.edge(t));
1556
- n.setEdge(
1557
- t,
1558
- ue({}, to, ie(a, ro), q(a, ao))
1559
- );
1560
- }), n;
1561
- }
1562
- function oo(e) {
1563
- var n = e.graph();
1564
- n.ranksep /= 2, l(e.edges(), function(r) {
1565
- var t = e.edge(r);
1566
- t.minlen *= 2, t.labelpos.toLowerCase() !== "c" && (n.rankdir === "TB" || n.rankdir === "BT" ? t.width += t.labeloffset : t.height += t.labeloffset);
1567
- });
1568
- }
1569
- function so(e) {
1570
- l(e.edges(), function(n) {
1571
- var r = e.edge(n);
1572
- if (r.width && r.height) {
1573
- var t = e.node(n.v), a = e.node(n.w), o = { rank: (a.rank - t.rank) / 2 + t.rank, e: n };
1574
- A(e, "edge-proxy", o, "_ep");
1575
- }
1576
- });
1577
- }
1578
- function uo(e) {
1579
- var n = 0;
1580
- l(e.nodes(), function(r) {
1581
- var t = e.node(r);
1582
- t.borderTop && (t.minRank = e.node(t.borderTop).rank, t.maxRank = e.node(t.borderBottom).rank, n = S(n, t.maxRank));
1583
- }), e.graph().maxRank = n;
1584
- }
1585
- function fo(e) {
1586
- l(e.nodes(), function(n) {
1587
- var r = e.node(n);
1588
- r.dummy === "edge-proxy" && (e.edge(r.e).labelRank = r.rank, e.removeNode(n));
1589
- });
1590
- }
1591
- function co(e) {
1592
- var n = Number.POSITIVE_INFINITY, r = 0, t = Number.POSITIVE_INFINITY, a = 0, o = e.graph(), i = o.marginx || 0, s = o.marginy || 0;
1593
- function d(u) {
1594
- var f = u.x, c = u.y, h = u.width, v = u.height;
1595
- n = Math.min(n, f - h / 2), r = Math.max(r, f + h / 2), t = Math.min(t, c - v / 2), a = Math.max(a, c + v / 2);
1596
- }
1597
- l(e.nodes(), function(u) {
1598
- d(e.node(u));
1599
- }), l(e.edges(), function(u) {
1600
- var f = e.edge(u);
1601
- Object.prototype.hasOwnProperty.call(f, "x") && d(f);
1602
- }), n -= i, t -= s, l(e.nodes(), function(u) {
1603
- var f = e.node(u);
1604
- f.x -= n, f.y -= t;
1605
- }), l(e.edges(), function(u) {
1606
- var f = e.edge(u);
1607
- l(f.points, function(c) {
1608
- c.x -= n, c.y -= t;
1609
- }), Object.prototype.hasOwnProperty.call(f, "x") && (f.x -= n), Object.prototype.hasOwnProperty.call(f, "y") && (f.y -= t);
1610
- }), o.width = r - n + i, o.height = a - t + s;
1611
- }
1612
- function lo(e) {
1613
- l(e.edges(), function(n) {
1614
- var r = e.edge(n), t = e.node(n.v), a = e.node(n.w), o, i;
1615
- r.points ? (o = r.points[0], i = r.points[r.points.length - 1]) : (r.points = [], o = a, i = t), r.points.unshift(Ve(t, o)), r.points.push(Ve(a, i));
1616
- });
1617
- }
1618
- function ho(e) {
1619
- l(e.edges(), function(n) {
1620
- var r = e.edge(n);
1621
- if (Object.prototype.hasOwnProperty.call(r, "x"))
1622
- switch ((r.labelpos === "l" || r.labelpos === "r") && (r.width -= r.labeloffset), r.labelpos) {
1623
- case "l":
1624
- r.x -= r.width / 2 + r.labeloffset;
1625
- break;
1626
- case "r":
1627
- r.x += r.width / 2 + r.labeloffset;
1628
- break;
1629
- }
1630
- });
1631
- }
1632
- function po(e) {
1633
- l(e.edges(), function(n) {
1634
- var r = e.edge(n);
1635
- r.reversed && r.points.reverse();
1636
- });
1637
- }
1638
- function go(e) {
1639
- l(e.nodes(), function(n) {
1640
- if (e.children(n).length) {
1641
- var r = e.node(n), t = e.node(r.borderTop), a = e.node(r.borderBottom), o = e.node(W(r.borderLeft)), i = e.node(W(r.borderRight));
1642
- r.width = Math.abs(i.x - o.x), r.height = Math.abs(a.y - t.y), r.x = o.x + r.width / 2, r.y = t.y + r.height / 2;
1643
- }
1644
- }), l(e.nodes(), function(n) {
1645
- e.node(n).dummy === "border" && e.removeNode(n);
1646
- });
1647
- }
1648
- function vo(e) {
1649
- l(e.edges(), function(n) {
1650
- if (n.v === n.w) {
1651
- var r = e.node(n.v);
1652
- r.selfEdges || (r.selfEdges = []), r.selfEdges.push({ e: n, label: e.edge(n) }), e.removeEdge(n);
1653
- }
1654
- });
1655
- }
1656
- function bo(e) {
1657
- var n = ne(e);
1658
- l(n, function(r) {
1659
- var t = 0;
1660
- l(r, function(a, o) {
1661
- var i = e.node(a);
1662
- i.order = o + t, l(i.selfEdges, function(s) {
1663
- A(
1664
- e,
1665
- "selfedge",
1666
- {
1667
- width: s.label.width,
1668
- height: s.label.height,
1669
- rank: i.rank,
1670
- order: o + ++t,
1671
- e: s.e,
1672
- label: s.label
1673
- },
1674
- "_se"
1675
- );
1676
- }), delete i.selfEdges;
1677
- });
1678
- });
1679
- }
1680
- function wo(e) {
1681
- l(e.nodes(), function(n) {
1682
- var r = e.node(n);
1683
- if (r.dummy === "selfedge") {
1684
- var t = e.node(r.e.v), a = t.x + t.width / 2, o = t.y, i = r.x - a, s = t.height / 2;
1685
- e.setEdge(r.e, r.label), e.removeNode(n), r.label.points = [
1686
- { x: a + 2 * i / 3, y: o - s },
1687
- { x: a + 5 * i / 6, y: o - s },
1688
- { x: a + i, y: o },
1689
- { x: a + 5 * i / 6, y: o + s },
1690
- { x: a + 2 * i / 3, y: o + s }
1691
- ], r.label.x = r.x, r.label.y = r.y;
1692
- }
1693
- });
1694
- }
1695
- function ie(e, n) {
1696
- return ee(q(e, n), Number);
1697
- }
1698
- function oe(e) {
1699
- var n = {};
1700
- return l(e, function(r, t) {
1701
- n[t.toLowerCase()] = r;
1702
- }), n;
1703
- }
1704
- var en = /* @__PURE__ */ x((e, n, r) => Math.max(n, Math.min(r, e)), "clamp"), nn = /* @__PURE__ */ x((e = "TB") => {
1705
- switch (e) {
1706
- case "BT":
1707
- return "bottom";
1708
- case "LR":
1709
- return "right";
1710
- case "RL":
1711
- return "left";
1712
- case "TB":
1713
- default:
1714
- return "top";
1715
- }
1716
- }, "getDefaultSelfLoopSide"), mo = /* @__PURE__ */ x((e) => e === "flowchart" || e === "flowchart-v2" || e === "stateDiagram" || e === "er" || e === "classDiagram", "shouldMergeSelfLoopSegments"), yo = [
1717
- "x",
1718
- "y",
1719
- "width",
1720
- "height",
1721
- "labelBBox",
1722
- "intersect",
1723
- "calcIntersect",
1724
- "diff",
1725
- "clusterNode"
1726
- ], xo = /* @__PURE__ */ x((e, n, r, t, a) => {
1727
- const o = [], i = /* @__PURE__ */ new Set();
1728
- if (r.forEach(({ start: f, end: c }) => {
1729
- f !== t && i.add(f), c !== t && i.add(c);
1730
- }), i.forEach((f) => {
1731
- const c = e.node(f);
1732
- typeof c?.x == "number" && typeof c?.y == "number" && o.push(c);
1733
- }), o.length === 0 && r.forEach(({ edge: f }) => {
1734
- (f.points ?? []).forEach((c) => {
1735
- typeof c?.x == "number" && typeof c?.y == "number" && o.push(c);
1736
- });
1737
- }), o.length === 0)
1738
- return nn(a);
1739
- const s = o.reduce(
1740
- (f, c) => ({
1741
- x: f.x + c.x / o.length,
1742
- y: f.y + c.y / o.length
1743
- }),
1744
- { x: 0, y: 0 }
1745
- ), d = s.x - n.x, u = s.y - n.y;
1746
- return Math.abs(d) > Math.abs(u) ? d > 0 ? "right" : "left" : Math.abs(u) > 0 ? u > 0 ? "bottom" : "top" : nn(a);
1747
- }, "getSelfLoopSide"), Eo = /* @__PURE__ */ x((e, n = "top", r = 0, t = 0) => {
1748
- const a = e.x, o = e.y - r, i = e.width / 2, s = e.height / 2, d = Math.max(36, Math.min(100, e.width * 0.8)), u = en(Math.max(t, e.width * 0.35), 36, d), f = en(Math.min(e.width, e.height) * 0.45, 24, 48);
1749
- switch (n) {
1750
- case "bottom": {
1751
- const c = o + s;
1752
- return [
1753
- { x: a - u / 2, y: c },
1754
- { x: a - u / 2, y: c + f },
1755
- { x: a + u / 2, y: c + f },
1756
- { x: a + u / 2, y: c }
1757
- ];
1758
- }
1759
- case "right": {
1760
- const c = a + i;
1761
- return [
1762
- { x: c, y: o - u / 2 },
1763
- { x: c + f, y: o - u / 2 },
1764
- { x: c + f, y: o + u / 2 },
1765
- { x: c, y: o + u / 2 }
1766
- ];
1767
- }
1768
- case "left": {
1769
- const c = a - i;
1770
- return [
1771
- { x: c, y: o - u / 2 },
1772
- { x: c - f, y: o - u / 2 },
1773
- { x: c - f, y: o + u / 2 },
1774
- { x: c, y: o + u / 2 }
1775
- ];
1776
- }
1777
- case "top":
1778
- default: {
1779
- const c = o - s;
1780
- return [
1781
- { x: a - u / 2, y: c },
1782
- { x: a - u / 2, y: c - f },
1783
- { x: a + u / 2, y: c - f },
1784
- { x: a + u / 2, y: c }
1785
- ];
1786
- }
1787
- }
1788
- }, "getSelfLoopPoints"), Lo = /* @__PURE__ */ x((e, n, r = "top", t = 0, a = {}) => {
1789
- const i = e.x, s = e.y - t, d = a.width ?? 0, u = a.height ?? 0;
1790
- switch (r) {
1791
- case "bottom":
1792
- return { x: i, y: Math.max(...n.map((f) => f.y)) + u / 2 + 4 };
1793
- case "right":
1794
- return { x: Math.max(...n.map((f) => f.x)) + d / 2 + 4, y: s };
1795
- case "left":
1796
- return { x: Math.min(...n.map((f) => f.x)) - d / 2 - 4, y: s };
1797
- case "top":
1798
- default:
1799
- return { x: i, y: Math.min(...n.map((f) => f.y)) - u / 2 - 4 };
1800
- }
1801
- }, "getSelfLoopLabelPosition"), Gn = /* @__PURE__ */ x((e, n = 0, { mergeSelfLoops: r = !0 } = {}) => {
1802
- const t = /* @__PURE__ */ new Map(), a = [], o = e.graph()?.rankdir;
1803
- return e.edges().forEach((i) => {
1804
- const s = e.edge(i);
1805
- if (r && s.selfLoop) {
1806
- const d = s.selfLoop.id;
1807
- t.has(d) || t.set(d, []), t.get(d).push({ edge: s, start: i.v, end: i.w });
1808
- } else
1809
- a.push({ edge: s, start: i.v, end: i.w });
1810
- }), t.forEach((i) => {
1811
- if (i.length !== 3) {
1812
- i.forEach((w) => a.push(w));
1813
- return;
1814
- }
1815
- i.sort((w, P) => w.edge.selfLoop.order - P.edge.selfLoop.order);
1816
- const [s, d, u] = i, f = s.edge.originalEdge ?? d.edge.originalEdge ?? u.edge.originalEdge ?? d.edge, c = e.node(f.start);
1817
- if (!c) {
1818
- i.forEach((w) => a.push(w));
1819
- return;
1820
- }
1821
- const h = {
1822
- width: d.edge.width,
1823
- height: d.edge.height
1824
- }, v = xo(e, c, i, f.start, o), p = Eo(c, v, n, h.width ?? 0), g = Lo(c, p, v, n, h), b = {
1825
- ...d.edge,
1826
- ...f,
1827
- id: f.id,
1828
- points: p,
1829
- start: f.start,
1830
- end: f.end,
1831
- x: g.x,
1832
- y: g.y,
1833
- width: h.width,
1834
- height: h.height,
1835
- labelStyle: d.edge.labelStyle,
1836
- fromCluster: s.edge.fromCluster ?? d.edge.fromCluster ?? u.edge.fromCluster,
1837
- toCluster: s.edge.toCluster ?? d.edge.toCluster ?? u.edge.toCluster
1838
- };
1839
- delete b.selfLoop, delete b.originalEdge, a.push({ edge: b, start: b.start, end: b.end });
1840
- }), a;
1841
- }, "getEdgesToRender"), Yn = /* @__PURE__ */ x(async ({
1842
- element: e,
1843
- graph: n,
1844
- diagramType: r,
1845
- id: t,
1846
- parentCluster: a,
1847
- siteConfig: o
1848
- }) => {
1849
- const i = n.graph().rankdir;
1850
- m.trace("Dir in recursive render - dir:", i);
1851
- const {
1852
- clusters: s,
1853
- edgePaths: d,
1854
- edgeLabels: u,
1855
- nodes: f,
1856
- rootGroups: c
1857
- } = Hn(e, {
1858
- edgePathsClass: "edgePaths"
1859
- });
1860
- n.nodes() ? m.info("Recursive render XXX", n.nodes()) : m.info("No nodes found for", n), n.edges().length > 0 && m.info("Recursive edges", n.edge(n.edges()[0]));
1861
- const h = mo(r);
1862
- await Promise.all(
1863
- n.nodes().map(async function(g) {
1864
- const b = n.node(g);
1865
- if (a !== void 0) {
1866
- const w = JSON.parse(JSON.stringify(a.clusterData));
1867
- m.trace(
1868
- `Setting data for parent cluster XXX
1869
- Node.id = `,
1870
- g,
1871
- `
1872
- data=`,
1873
- w.height,
1874
- `
1875
- Parent cluster`,
1876
- a.height
1877
- ), n.setNode(a.id, w), n.parent(g) || (m.trace("Setting parent", g, a.id), n.setParent(g, a.id, w));
1878
- }
1879
- if (m.info("(Insert) Node XXX" + g + ": " + JSON.stringify(n.node(g))), b?.clusterNode) {
1880
- m.info("Cluster identified XBX", g, b.width, n.node(g));
1881
- const { ranksep: w, nodesep: P } = n.graph();
1882
- b.graph.setGraph({
1883
- ...b.graph.graph(),
1884
- ranksep: w + 25,
1885
- nodesep: P
1886
- });
1887
- const Ne = await So({
1888
- element: f,
1889
- graph: b.graph,
1890
- diagramType: r,
1891
- id: t,
1892
- parentCluster: n.node(g),
1893
- siteConfig: o
1894
- }), Pe = Ne.elem;
1895
- Kn(b, Pe), b.diff = Ne.diff || 0, m.info(
1896
- "New compound node after recursive render XAX",
1897
- g,
1898
- "width",
1899
- // node,
1900
- b.width,
1901
- "height",
1902
- b.height
1903
- // node.x,
1904
- // node.y
1905
- ), Zn(Pe, b);
1906
- } else
1907
- n.children(g).length > 0 ? (m.trace(
1908
- "Cluster - the non recursive path XBX",
1909
- g,
1910
- b.id,
1911
- b,
1912
- b.width,
1913
- "Graph:",
1914
- n
1915
- ), m.trace(Te(b.id, n)), T.set(b.id, { id: Te(b.id, n), node: b })) : (m.trace("Node - the non recursive path XAX", g, f, n.node(g), i), await zn(f, n.node(g), { config: o, dir: i }));
1916
- })
1917
- ), await (/* @__PURE__ */ x(async () => {
1918
- const g = n.edges().map(async function(b) {
1919
- const w = n.edge(b.v, b.w, b.name);
1920
- if (m.info("Edge " + b.v + " -> " + b.w + ": " + JSON.stringify(b)), m.info("Edge " + b.v + " -> " + b.w + ": ", b, " ", JSON.stringify(n.edge(b))), m.info(
1921
- "Fix",
1922
- T,
1923
- "ids:",
1924
- b.v,
1925
- b.w,
1926
- "Translating: ",
1927
- T.get(b.v),
1928
- T.get(b.w)
1929
- ), h && w.selfLoop) {
1930
- if (w.selfLoop.order !== 1)
1931
- return;
1932
- const P = {
1933
- ...w.originalEdge,
1934
- ...w,
1935
- id: w.selfLoop.id,
1936
- startLabelLeft: w.originalEdge?.startLabelLeft ?? w.startLabelLeft,
1937
- startLabelRight: w.originalEdge?.startLabelRight ?? w.startLabelRight,
1938
- endLabelLeft: w.originalEdge?.endLabelLeft ?? w.endLabelLeft,
1939
- endLabelRight: w.originalEdge?.endLabelRight ?? w.endLabelRight
1940
- };
1941
- await Se(u, P), w.width = P.width, w.height = P.height, w.labelStyle = P.labelStyle;
1942
- return;
1943
- }
1944
- await Se(u, w);
1945
- });
1946
- await Promise.all(g);
1947
- }, "processEdges"))();
1948
- const { subGraphTitleTotalMargin: p } = Qn(o);
1949
- return {
1950
- elem: c,
1951
- graph: n,
1952
- groups: { clusters: s, edgePaths: d, edgeLabels: u, nodes: f, rootGroups: c },
1953
- diagramType: r,
1954
- id: t,
1955
- mergeSelfLoops: h,
1956
- subGraphTitleTotalMargin: p
1957
- };
1958
- }, "measureDagreGraph"), Un = /* @__PURE__ */ x((e) => {
1959
- m.info("############################################# XXX"), m.info("### Layout ### XXX"), m.info("############################################# XXX"), Hi(e);
1960
- }, "runDagreGraphLayout"), Oo = /* @__PURE__ */ x((e, n, r) => {
1961
- const t = e.node(n);
1962
- if (!t)
1963
- return;
1964
- const a = { ...t };
1965
- return t?.clusterNode ? a.y = (t.y ?? 0) + r : e.children(n).length > 0 ? a.height = (t.height ?? 0) + r : a.y = (t.y ?? 0) + r / 2, a;
1966
- }, "normalizeDagreNode"), rn = /* @__PURE__ */ x((e, n) => {
1967
- yo.forEach((r) => {
1968
- n[r] !== void 0 && (e[r] = n[r]);
1969
- });
1970
- }, "applyDagreNodeLayout"), No = /* @__PURE__ */ x((e, n, r, t) => ({
1971
- ...e,
1972
- start: e.start ?? n,
1973
- end: e.end ?? r,
1974
- points: (e.points ?? []).map((a) => ({
1975
- ...a,
1976
- y: typeof a.y == "number" ? a.y + t : a.y
1977
- }))
1978
- }), "normalizeDagreEdge"), Po = /* @__PURE__ */ x((e, n) => {
1979
- const { graph: r, mergeSelfLoops: t, subGraphTitleTotalMargin: a = 0 } = n, o = new Map(e.nodes.map((s) => [s.id, s]));
1980
- ce(r).forEach((s) => {
1981
- const d = Oo(r, s, a);
1982
- if (!d)
1983
- return;
1984
- rn(r.node(s), d);
1985
- const u = o.get(s);
1986
- u && rn(u, d);
1987
- });
1988
- const i = a / 2;
1989
- return e.edges = Gn(r, i, { mergeSelfLoops: t }).map(
1990
- ({ edge: s, start: d, end: u }) => No(s, d, u, i)
1991
- ), e;
1992
- }, "applyDagreLayoutResult"), To = /* @__PURE__ */ x(async ({
1993
- elem: e,
1994
- graph: n,
1995
- groups: { clusters: r, edgePaths: t },
1996
- diagramType: a,
1997
- id: o,
1998
- mergeSelfLoops: i,
1999
- subGraphTitleTotalMargin: s
2000
- }) => {
2001
- let d = 0;
2002
- await Promise.all(
2003
- ce(n).map(async function(c) {
2004
- const h = n.node(c);
2005
- if (m.info(
2006
- "Position XBX => " + c + ": (" + h.x,
2007
- "," + h.y,
2008
- ") width: ",
2009
- h.width,
2010
- " height: ",
2011
- h.height
2012
- ), h?.clusterNode)
2013
- h.y += s, m.info(
2014
- "A tainted cluster node XBX1",
2015
- c,
2016
- h.id,
2017
- h.width,
2018
- h.height,
2019
- h.x,
2020
- h.y,
2021
- n.parent(c)
2022
- ), T.get(h.id).node = h, Ce(h);
2023
- else if (n.children(c).length > 0) {
2024
- m.info(
2025
- "A pure cluster node XBX1",
2026
- c,
2027
- h.id,
2028
- h.x,
2029
- h.y,
2030
- h.width,
2031
- h.height,
2032
- n.parent(c)
2033
- ), h.height += s, n.node(h.parentId);
2034
- const v = h?.padding / 2 || 0, p = h?.labelBBox?.height || 0, g = p - v || 0;
2035
- m.debug("OffsetY", g, "labelHeight", p, "halfPadding", v), await er(r, h), T.get(h.id).node = h;
2036
- } else {
2037
- const v = n.node(h.parentId);
2038
- h.y += s / 2, m.info(
2039
- "A regular node XBX1 - using the padding",
2040
- h.id,
2041
- "parent",
2042
- h.parentId,
2043
- h.width,
2044
- h.height,
2045
- h.x,
2046
- h.y,
2047
- "offsetY",
2048
- h.offsetY,
2049
- "parent",
2050
- v,
2051
- v?.offsetY,
2052
- h
2053
- ), Ce(h);
2054
- }
2055
- })
2056
- );
2057
- const u = s / 2;
2058
- return Gn(n, u, { mergeSelfLoops: i }).forEach(function({ edge: c, start: h, end: v }) {
2059
- m.info("Edge " + h + " -> " + v + ": " + JSON.stringify(c), c), c.points.forEach((w) => w.y += u);
2060
- const p = n.node(h), g = n.node(v), b = nr(t, c, T, a, p, g, o);
2061
- rr(c, b);
2062
- }), n.nodes().forEach(function(c) {
2063
- const h = n.node(c);
2064
- m.info(c, h.type, h.diff), h.isGroup && (d = h.diff);
2065
- }), m.warn("Returning from recursive render XAX", e, d), { elem: e, diff: d };
2066
- }, "paintDagreLayoutCore"), So = /* @__PURE__ */ x(async (e) => {
2067
- const n = await Yn(e);
2068
- return Un(n.graph), await To(n);
2069
- }, "renderDagreSubgraph"), Vn = /* @__PURE__ */ x((e) => {
2070
- const n = new N({
2071
- multigraph: !0,
2072
- compound: !0
2073
- }).setGraph({
2074
- rankdir: e.direction,
2075
- // Precedence: an explicit top-level config override (only present when a
2076
- // user sets it - it has no schema default) > the value the diagram's own
2077
- // renderer put on data4Layout (usually derived from that diagram's config)
2078
- // > the flowchart config as a generic fallback. The flowchart keys have
2079
- // schema defaults and therefore always exist, so they must come last or
2080
- // they silently shadow every diagram's own spacing (see #7932).
2081
- nodesep: e.config?.nodeSpacing || e.nodeSpacing || e.config?.flowchart?.nodeSpacing,
2082
- ranksep: e.config?.rankSpacing || e.rankSpacing || e.config?.flowchart?.rankSpacing,
2083
- marginx: 8,
2084
- marginy: 8
2085
- }).setDefaultEdgeLabel(function() {
2086
- return {};
2087
- });
2088
- return e.nodes.forEach((r) => {
2089
- n.setNode(r.id, { ...r }), r.parentId && n.setParent(r.id, r.parentId);
2090
- }), m.debug("Edges:", e.edges), e.edges.forEach((r) => {
2091
- if (r.start === r.end) {
2092
- const t = r.start, a = t + "---" + t + "---1", o = t + "---" + t + "---2", i = n.node(t);
2093
- n.setNode(a, {
2094
- domId: a,
2095
- id: a,
2096
- parentId: i.parentId,
2097
- labelStyle: "",
2098
- label: "",
2099
- padding: 0,
2100
- shape: "labelRect",
2101
- // shape: 'rect',
2102
- style: "",
2103
- width: 10,
2104
- height: 10
2105
- }), n.setParent(a, i.parentId), n.setNode(o, {
2106
- domId: o,
2107
- id: o,
2108
- parentId: i.parentId,
2109
- labelStyle: "",
2110
- padding: 0,
2111
- // shape: 'rect',
2112
- shape: "labelRect",
2113
- label: "",
2114
- style: "",
2115
- width: 10,
2116
- height: 10
2117
- }), n.setParent(o, i.parentId);
2118
- const s = structuredClone(r), d = structuredClone(r), u = structuredClone(r), f = structuredClone(r);
2119
- d.originalEdge = s, d.selfLoop = { id: s.id, order: 0 }, u.originalEdge = s, u.selfLoop = { id: s.id, order: 1 }, f.originalEdge = s, f.selfLoop = { id: s.id, order: 2 }, d.label = "", d.arrowTypeEnd = "none", d.endLabelLeft = "", d.endLabelRight = "", d.startLabelLeft = "", d.id = t + "-cyclic-special-1", u.startLabelRight = "", u.startLabelLeft = "", u.endLabelLeft = "", u.endLabelRight = "", u.arrowTypeStart = "none", u.arrowTypeEnd = "none", u.id = t + "-cyclic-special-mid", f.label = "", f.startLabelRight = "", f.startLabelLeft = "", f.arrowTypeStart = "none", i.isGroup && (d.fromCluster = t, f.toCluster = t), f.id = t + "-cyclic-special-2", f.arrowTypeStart = "none", n.setEdge(t, a, d, t + "-cyclic-special-0"), n.setEdge(a, o, u, t + "-cyclic-special-1"), n.setEdge(o, t, f, t + "-cyclic-special-2");
2120
- } else
2121
- n.setEdge(r.start, r.end, { ...r }, r.id);
2122
- }), Wn(n), { graph: n };
2123
- }, "prepareLayoutForDagre"), Co = /* @__PURE__ */ x(async (e, { element: n, preparedLayout: r }) => {
2124
- const t = r ?? Vn(e), a = Jn(), o = await Yn({
2125
- element: n,
2126
- graph: t.graph,
2127
- diagramType: e.type,
2128
- id: e.diagramId,
2129
- parentCluster: void 0,
2130
- siteConfig: a
2131
- });
2132
- return t.measuredLayout = o, o;
2133
- }, "measureDagreLayout"), Io = /* @__PURE__ */ x((e, n) => {
2134
- const r = n.preparedLayout?.measuredLayout;
2135
- if (!r)
2136
- throw new Error("runDagreLayoutCore requires measureDagreLayout to run first");
2137
- return Un(r.graph), Po(e, r), r;
2138
- }, "runDagreLayoutCore"), Ro = /* @__PURE__ */ x((e, { measure: n }) => ce(n.graph).map((r) => n.graph.node(r)).filter(Boolean), "getDagrePaintNodes"), ko = /* @__PURE__ */ x((e, n, { measure: r }) => e ? r.graph.node(e) : void 0, "getDagreEdgeNode"), jo = qn({
2139
- prepareLayout: Vn,
2140
- measureLayout: Co,
2141
- runLayoutCore: Io,
2142
- paintOptions: {
2143
- clusterDb: T,
2144
- getNodes: Ro,
2145
- getEdgeNode: ko,
2146
- skipNode: /* @__PURE__ */ x((e, { measure: n }) => !n.graph.hasNode(e.id), "skipNode"),
2147
- isCluster: /* @__PURE__ */ x((e, { measure: n }) => n.graph.hasNode(e.id) && (n.graph.children(e.id) ?? []).length > 0, "isCluster")
2148
- }
2149
- });
2150
- export {
2151
- Po as applyDagreLayoutResult,
2152
- Gn as getEdgesToRender,
2153
- Co as measureDagreLayout,
2154
- Vn as prepareLayoutForDagre,
2155
- jo as render,
2156
- Io as runDagreLayoutCore
2157
- };