1 | import { c as rt, g as mt, s as kt, a as _t, b as xt, D as vt, C as bt, E as wt, f as St, ar as Lt, j as G, t as Et } from "./mermaid-9f2aa176.js";
|
2 | import { o as At } from "./ordinal-5695958c.js";
|
3 | import { d as Tt } from "./Tableau10-558cc280.js";
|
4 | import "./init-f9637058.js";
|
5 | var tt = function() {
|
6 | var t = function(m, i, o, c) {
|
7 | for (o = o || {}, c = m.length; c--; o[m[c]] = i)
|
8 | ;
|
9 | return o;
|
10 | }, n = [1, 9], s = [1, 10], a = [1, 5, 10, 12], u = {
|
11 | trace: function() {
|
12 | },
|
13 | yy: {},
|
14 | symbols_: { error: 2, start: 3, SANKEY: 4, NEWLINE: 5, csv: 6, opt_eof: 7, record: 8, csv_tail: 9, EOF: 10, "field[source]": 11, COMMA: 12, "field[target]": 13, "field[value]": 14, field: 15, escaped: 16, non_escaped: 17, DQUOTE: 18, ESCAPED_TEXT: 19, NON_ESCAPED_TEXT: 20, $accept: 0, $end: 1 },
|
15 | terminals_: { 2: "error", 4: "SANKEY", 5: "NEWLINE", 10: "EOF", 11: "field[source]", 12: "COMMA", 13: "field[target]", 14: "field[value]", 18: "DQUOTE", 19: "ESCAPED_TEXT", 20: "NON_ESCAPED_TEXT" },
|
16 | productions_: [0, [3, 4], [6, 2], [9, 2], [9, 0], [7, 1], [7, 0], [8, 5], [15, 1], [15, 1], [16, 3], [17, 1]],
|
17 | performAction: function(i, o, c, k, b, d, x) {
|
18 | var E = d.length - 1;
|
19 | switch (b) {
|
20 | case 7:
|
21 | const L = k.findOrCreateNode(d[E - 4].trim().replaceAll('""', '"')), A = k.findOrCreateNode(d[E - 2].trim().replaceAll('""', '"')), N = parseFloat(d[E].trim());
|
22 | k.addLink(L, A, N);
|
23 | break;
|
24 | case 8:
|
25 | case 9:
|
26 | case 11:
|
27 | this.$ = d[E];
|
28 | break;
|
29 | case 10:
|
30 | this.$ = d[E - 1];
|
31 | break;
|
32 | }
|
33 | },
|
34 | table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, { 5: [1, 3] }, { 6: 4, 8: 5, 15: 6, 16: 7, 17: 8, 18: n, 20: s }, { 1: [2, 6], 7: 11, 10: [1, 12] }, t(s, [2, 4], { 9: 13, 5: [1, 14] }), { 12: [1, 15] }, t(a, [2, 8]), t(a, [2, 9]), { 19: [1, 16] }, t(a, [2, 11]), { 1: [2, 1] }, { 1: [2, 5] }, t(s, [2, 2]), { 6: 17, 8: 5, 15: 6, 16: 7, 17: 8, 18: n, 20: s }, { 15: 18, 16: 7, 17: 8, 18: n, 20: s }, { 18: [1, 19] }, t(s, [2, 3]), { 12: [1, 20] }, t(a, [2, 10]), { 15: 21, 16: 7, 17: 8, 18: n, 20: s }, t([1, 5, 10], [2, 7])],
|
35 | defaultActions: { 11: [2, 1], 12: [2, 5] },
|
36 | parseError: function(i, o) {
|
37 | if (o.recoverable)
|
38 | this.trace(i);
|
39 | else {
|
40 | var c = new Error(i);
|
41 | throw c.hash = o, c;
|
42 | }
|
43 | },
|
44 | parse: function(i) {
|
45 | var o = this, c = [0], k = [], b = [null], d = [], x = this.table, E = "", L = 0, A = 0, N = 2, C = 1, j = d.slice.call(arguments, 1), S = Object.create(this.lexer), M = { yy: {} };
|
46 | for (var $ in this.yy)
|
47 | Object.prototype.hasOwnProperty.call(this.yy, $) && (M.yy[$] = this.yy[$]);
|
48 | S.setInput(i, M.yy), M.yy.lexer = S, M.yy.parser = this, typeof S.yylloc > "u" && (S.yylloc = {});
|
49 | var P = S.yylloc;
|
50 | d.push(P);
|
51 | var I = S.options && S.options.ranges;
|
52 | typeof M.yy.parseError == "function" ? this.parseError = M.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
|
53 | function g() {
|
54 | var v;
|
55 | return v = k.pop() || S.lex() || C, typeof v != "number" && (v instanceof Array && (k = v, v = k.pop()), v = o.symbols_[v] || v), v;
|
56 | }
|
57 | for (var w, O, T, V, e = {}, f, l, h, r; ; ) {
|
58 | if (O = c[c.length - 1], this.defaultActions[O] ? T = this.defaultActions[O] : ((w === null || typeof w > "u") && (w = g()), T = x[O] && x[O][w]), typeof T > "u" || !T.length || !T[0]) {
|
59 | var _ = "";
|
60 | r = [];
|
61 | for (f in x[O])
|
62 | this.terminals_[f] && f > N && r.push("'" + this.terminals_[f] + "'");
|
63 | S.showPosition ? _ = "Parse error on line " + (L + 1) + `:
|
64 | ` + S.showPosition() + `
|
65 | Expecting ` + r.join(", ") + ", got '" + (this.terminals_[w] || w) + "'" : _ = "Parse error on line " + (L + 1) + ": Unexpected " + (w == C ? "end of input" : "'" + (this.terminals_[w] || w) + "'"), this.parseError(_, {
|
66 | text: S.match,
|
67 | token: this.terminals_[w] || w,
|
68 | line: S.yylineno,
|
69 | loc: P,
|
70 | expected: r
|
71 | });
|
72 | }
|
73 | if (T[0] instanceof Array && T.length > 1)
|
74 | throw new Error("Parse Error: multiple actions possible at state: " + O + ", token: " + w);
|
75 | switch (T[0]) {
|
76 | case 1:
|
77 | c.push(w), b.push(S.yytext), d.push(S.yylloc), c.push(T[1]), w = null, A = S.yyleng, E = S.yytext, L = S.yylineno, P = S.yylloc;
|
78 | break;
|
79 | case 2:
|
80 | if (l = this.productions_[T[1]][1], e.$ = b[b.length - l], e._$ = {
|
81 | first_line: d[d.length - (l || 1)].first_line,
|
82 | last_line: d[d.length - 1].last_line,
|
83 | first_column: d[d.length - (l || 1)].first_column,
|
84 | last_column: d[d.length - 1].last_column
|
85 | }, I && (e._$.range = [
|
86 | d[d.length - (l || 1)].range[0],
|
87 | d[d.length - 1].range[1]
|
88 | ]), V = this.performAction.apply(e, [
|
89 | E,
|
90 | A,
|
91 | L,
|
92 | M.yy,
|
93 | T[1],
|
94 | b,
|
95 | d
|
96 | ].concat(j)), typeof V < "u")
|
97 | return V;
|
98 | l && (c = c.slice(0, -1 * l * 2), b = b.slice(0, -1 * l), d = d.slice(0, -1 * l)), c.push(this.productions_[T[1]][0]), b.push(e.$), d.push(e._$), h = x[c[c.length - 2]][c[c.length - 1]], c.push(h);
|
99 | break;
|
100 | case 3:
|
101 | return !0;
|
102 | }
|
103 | }
|
104 | return !0;
|
105 | }
|
106 | }, y = function() {
|
107 | var m = {
|
108 | EOF: 1,
|
109 | parseError: function(o, c) {
|
110 | if (this.yy.parser)
|
111 | this.yy.parser.parseError(o, c);
|
112 | else
|
113 | throw new Error(o);
|
114 | },
|
115 |
|
116 | setInput: function(i, o) {
|
117 | return this.yy = o || this.yy || {}, this._input = i, this._more = this._backtrack = this.done = !1, this.yylineno = this.yyleng = 0, this.yytext = this.matched = this.match = "", this.conditionStack = ["INITIAL"], this.yylloc = {
|
118 | first_line: 1,
|
119 | first_column: 0,
|
120 | last_line: 1,
|
121 | last_column: 0
|
122 | }, this.options.ranges && (this.yylloc.range = [0, 0]), this.offset = 0, this;
|
123 | },
|
124 |
|
125 | input: function() {
|
126 | var i = this._input[0];
|
127 | this.yytext += i, this.yyleng++, this.offset++, this.match += i, this.matched += i;
|
128 | var o = i.match(/(?:\r\n?|\n).*/g);
|
129 | return o ? (this.yylineno++, this.yylloc.last_line++) : this.yylloc.last_column++, this.options.ranges && this.yylloc.range[1]++, this._input = this._input.slice(1), i;
|
130 | },
|
131 |
|
132 | unput: function(i) {
|
133 | var o = i.length, c = i.split(/(?:\r\n?|\n)/g);
|
134 | this._input = i + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - o), this.offset -= o;
|
135 | var k = this.match.split(/(?:\r\n?|\n)/g);
|
136 | this.match = this.match.substr(0, this.match.length - 1), this.matched = this.matched.substr(0, this.matched.length - 1), c.length - 1 && (this.yylineno -= c.length - 1);
|
137 | var b = this.yylloc.range;
|
138 | return this.yylloc = {
|
139 | first_line: this.yylloc.first_line,
|
140 | last_line: this.yylineno + 1,
|
141 | first_column: this.yylloc.first_column,
|
142 | last_column: c ? (c.length === k.length ? this.yylloc.first_column : 0) + k[k.length - c.length].length - c[0].length : this.yylloc.first_column - o
|
143 | }, this.options.ranges && (this.yylloc.range = [b[0], b[0] + this.yyleng - o]), this.yyleng = this.yytext.length, this;
|
144 | },
|
145 |
|
146 | more: function() {
|
147 | return this._more = !0, this;
|
148 | },
|
149 |
|
150 | reject: function() {
|
151 | if (this.options.backtrack_lexer)
|
152 | this._backtrack = !0;
|
153 | else
|
154 | 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).
|
155 | ` + this.showPosition(), {
|
156 | text: "",
|
157 | token: null,
|
158 | line: this.yylineno
|
159 | });
|
160 | return this;
|
161 | },
|
162 |
|
163 | less: function(i) {
|
164 | this.unput(this.match.slice(i));
|
165 | },
|
166 |
|
167 | pastInput: function() {
|
168 | var i = this.matched.substr(0, this.matched.length - this.match.length);
|
169 | return (i.length > 20 ? "..." : "") + i.substr(-20).replace(/\n/g, "");
|
170 | },
|
171 |
|
172 | upcomingInput: function() {
|
173 | var i = this.match;
|
174 | return i.length < 20 && (i += this._input.substr(0, 20 - i.length)), (i.substr(0, 20) + (i.length > 20 ? "..." : "")).replace(/\n/g, "");
|
175 | },
|
176 |
|
177 | showPosition: function() {
|
178 | var i = this.pastInput(), o = new Array(i.length + 1).join("-");
|
179 | return i + this.upcomingInput() + `
|
180 | ` + o + "^";
|
181 | },
|
182 |
|
183 | test_match: function(i, o) {
|
184 | var c, k, b;
|
185 | if (this.options.backtrack_lexer && (b = {
|
186 | yylineno: this.yylineno,
|
187 | yylloc: {
|
188 | first_line: this.yylloc.first_line,
|
189 | last_line: this.last_line,
|
190 | first_column: this.yylloc.first_column,
|
191 | last_column: this.yylloc.last_column
|
192 | },
|
193 | yytext: this.yytext,
|
194 | match: this.match,
|
195 | matches: this.matches,
|
196 | matched: this.matched,
|
197 | yyleng: this.yyleng,
|
198 | offset: this.offset,
|
199 | _more: this._more,
|
200 | _input: this._input,
|
201 | yy: this.yy,
|
202 | conditionStack: this.conditionStack.slice(0),
|
203 | done: this.done
|
204 | }, this.options.ranges && (b.yylloc.range = this.yylloc.range.slice(0))), k = i[0].match(/(?:\r\n?|\n).*/g), k && (this.yylineno += k.length), this.yylloc = {
|
205 | first_line: this.yylloc.last_line,
|
206 | last_line: this.yylineno + 1,
|
207 | first_column: this.yylloc.last_column,
|
208 | last_column: k ? k[k.length - 1].length - k[k.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + i[0].length
|
209 | }, this.yytext += i[0], this.match += i[0], this.matches = i, 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(i[0].length), this.matched += i[0], c = this.performAction.call(this, this.yy, this, o, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), c)
|
210 | return c;
|
211 | if (this._backtrack) {
|
212 | for (var d in b)
|
213 | this[d] = b[d];
|
214 | return !1;
|
215 | }
|
216 | return !1;
|
217 | },
|
218 |
|
219 | next: function() {
|
220 | if (this.done)
|
221 | return this.EOF;
|
222 | this._input || (this.done = !0);
|
223 | var i, o, c, k;
|
224 | this._more || (this.yytext = "", this.match = "");
|
225 | for (var b = this._currentRules(), d = 0; d < b.length; d++)
|
226 | if (c = this._input.match(this.rules[b[d]]), c && (!o || c[0].length > o[0].length)) {
|
227 | if (o = c, k = d, this.options.backtrack_lexer) {
|
228 | if (i = this.test_match(c, b[d]), i !== !1)
|
229 | return i;
|
230 | if (this._backtrack) {
|
231 | o = !1;
|
232 | continue;
|
233 | } else
|
234 | return !1;
|
235 | } else if (!this.options.flex)
|
236 | break;
|
237 | }
|
238 | return o ? (i = this.test_match(o, b[k]), i !== !1 ? i : !1) : this._input === "" ? this.EOF : this.parseError("Lexical error on line " + (this.yylineno + 1) + `. Unrecognized text.
|
239 | ` + this.showPosition(), {
|
240 | text: "",
|
241 | token: null,
|
242 | line: this.yylineno
|
243 | });
|
244 | },
|
245 |
|
246 | lex: function() {
|
247 | var o = this.next();
|
248 | return o || this.lex();
|
249 | },
|
250 |
|
251 | begin: function(o) {
|
252 | this.conditionStack.push(o);
|
253 | },
|
254 |
|
255 | popState: function() {
|
256 | var o = this.conditionStack.length - 1;
|
257 | return o > 0 ? this.conditionStack.pop() : this.conditionStack[0];
|
258 | },
|
259 |
|
260 | _currentRules: function() {
|
261 | return this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1] ? this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules : this.conditions.INITIAL.rules;
|
262 | },
|
263 |
|
264 | topState: function(o) {
|
265 | return o = this.conditionStack.length - 1 - Math.abs(o || 0), o >= 0 ? this.conditionStack[o] : "INITIAL";
|
266 | },
|
267 |
|
268 | pushState: function(o) {
|
269 | this.begin(o);
|
270 | },
|
271 |
|
272 | stateStackSize: function() {
|
273 | return this.conditionStack.length;
|
274 | },
|
275 | options: { "case-insensitive": !0 },
|
276 | performAction: function(o, c, k, b) {
|
277 | switch (k) {
|
278 | case 0:
|
279 | return this.pushState("csv"), 4;
|
280 | case 1:
|
281 | return 10;
|
282 | case 2:
|
283 | return 5;
|
284 | case 3:
|
285 | return 12;
|
286 | case 4:
|
287 | return this.pushState("escaped_text"), 18;
|
288 | case 5:
|
289 | return 20;
|
290 | case 6:
|
291 | return this.popState("escaped_text"), 18;
|
292 | case 7:
|
293 | return 19;
|
294 | }
|
295 | },
|
296 | rules: [/^(?:sankey-beta\b)/i, /^(?:$)/i, /^(?:((\u000D\u000A)|(\u000A)))/i, /^(?:(\u002C))/i, /^(?:(\u0022))/i, /^(?:([\u0020-\u0021\u0023-\u002B\u002D-\u007E])*)/i, /^(?:(\u0022)(?!(\u0022)))/i, /^(?:(([\u0020-\u0021\u0023-\u002B\u002D-\u007E])|(\u002C)|(\u000D)|(\u000A)|(\u0022)(\u0022))*)/i],
|
297 | conditions: { csv: { rules: [1, 2, 3, 4, 5, 6, 7], inclusive: !1 }, escaped_text: { rules: [6, 7], inclusive: !1 }, INITIAL: { rules: [0, 1, 2, 3, 4, 5, 6, 7], inclusive: !0 } }
|
298 | };
|
299 | return m;
|
300 | }();
|
301 | u.lexer = y;
|
302 | function p() {
|
303 | this.yy = {};
|
304 | }
|
305 | return p.prototype = u, u.Parser = p, new p();
|
306 | }();
|
307 | tt.parser = tt;
|
308 | const H = tt;
|
309 | let q = [], Q = [], B = {};
|
310 | const Mt = () => {
|
311 | q = [], Q = [], B = {}, wt();
|
312 | };
|
313 | class Nt {
|
314 | constructor(n, s, a = 0) {
|
315 | this.source = n, this.target = s, this.value = a;
|
316 | }
|
317 | }
|
318 | const Ct = (t, n, s) => {
|
319 | q.push(new Nt(t, n, s));
|
320 | };
|
321 | class Pt {
|
322 | constructor(n) {
|
323 | this.ID = n;
|
324 | }
|
325 | }
|
326 | const It = (t) => (t = St.sanitizeText(t, rt()), B[t] || (B[t] = new Pt(t), Q.push(B[t])), B[t]), Ot = () => Q, $t = () => q, jt = () => ({
|
327 | nodes: Q.map((t) => ({ id: t.ID })),
|
328 | links: q.map((t) => ({
|
329 | source: t.source.ID,
|
330 | target: t.target.ID,
|
331 | value: t.value
|
332 | }))
|
333 | }), zt = {
|
334 | nodesMap: B,
|
335 | getConfig: () => rt().sankey,
|
336 | getNodes: Ot,
|
337 | getLinks: $t,
|
338 | getGraph: jt,
|
339 | addLink: Ct,
|
340 | findOrCreateNode: It,
|
341 | getAccTitle: mt,
|
342 | setAccTitle: kt,
|
343 | getAccDescription: _t,
|
344 | setAccDescription: xt,
|
345 | getDiagramTitle: vt,
|
346 | setDiagramTitle: bt,
|
347 | clear: Mt
|
348 | };
|
349 | function ot(t, n) {
|
350 | let s;
|
351 | if (n === void 0)
|
352 | for (const a of t)
|
353 | a != null && (s < a || s === void 0 && a >= a) && (s = a);
|
354 | else {
|
355 | let a = -1;
|
356 | for (let u of t)
|
357 | (u = n(u, ++a, t)) != null && (s < u || s === void 0 && u >= u) && (s = u);
|
358 | }
|
359 | return s;
|
360 | }
|
361 | function yt(t, n) {
|
362 | let s;
|
363 | if (n === void 0)
|
364 | for (const a of t)
|
365 | a != null && (s > a || s === void 0 && a >= a) && (s = a);
|
366 | else {
|
367 | let a = -1;
|
368 | for (let u of t)
|
369 | (u = n(u, ++a, t)) != null && (s > u || s === void 0 && u >= u) && (s = u);
|
370 | }
|
371 | return s;
|
372 | }
|
373 | function Z(t, n) {
|
374 | let s = 0;
|
375 | if (n === void 0)
|
376 | for (let a of t)
|
377 | (a = +a) && (s += a);
|
378 | else {
|
379 | let a = -1;
|
380 | for (let u of t)
|
381 | (u = +n(u, ++a, t)) && (s += u);
|
382 | }
|
383 | return s;
|
384 | }
|
385 | function Dt(t) {
|
386 | return t.target.depth;
|
387 | }
|
388 | function Bt(t) {
|
389 | return t.depth;
|
390 | }
|
391 | function Vt(t, n) {
|
392 | return n - 1 - t.height;
|
393 | }
|
394 | function dt(t, n) {
|
395 | return t.sourceLinks.length ? t.depth : n - 1;
|
396 | }
|
397 | function Rt(t) {
|
398 | return t.targetLinks.length ? t.depth : t.sourceLinks.length ? yt(t.sourceLinks, Dt) - 1 : 0;
|
399 | }
|
400 | function Y(t) {
|
401 | return function() {
|
402 | return t;
|
403 | };
|
404 | }
|
405 | function lt(t, n) {
|
406 | return X(t.source, n.source) || t.index - n.index;
|
407 | }
|
408 | function at(t, n) {
|
409 | return X(t.target, n.target) || t.index - n.index;
|
410 | }
|
411 | function X(t, n) {
|
412 | return t.y0 - n.y0;
|
413 | }
|
414 | function J(t) {
|
415 | return t.value;
|
416 | }
|
417 | function Ut(t) {
|
418 | return t.index;
|
419 | }
|
420 | function Ft(t) {
|
421 | return t.nodes;
|
422 | }
|
423 | function Wt(t) {
|
424 | return t.links;
|
425 | }
|
426 | function ct(t, n) {
|
427 | const s = t.get(n);
|
428 | if (!s)
|
429 | throw new Error("missing: " + n);
|
430 | return s;
|
431 | }
|
432 | function ut({ nodes: t }) {
|
433 | for (const n of t) {
|
434 | let s = n.y0, a = s;
|
435 | for (const u of n.sourceLinks)
|
436 | u.y0 = s + u.width / 2, s += u.width;
|
437 | for (const u of n.targetLinks)
|
438 | u.y1 = a + u.width / 2, a += u.width;
|
439 | }
|
440 | }
|
441 | function Gt() {
|
442 | let t = 0, n = 0, s = 1, a = 1, u = 24, y = 8, p, m = Ut, i = dt, o, c, k = Ft, b = Wt, d = 6;
|
443 | function x() {
|
444 | const e = { nodes: k.apply(null, arguments), links: b.apply(null, arguments) };
|
445 | return E(e), L(e), A(e), N(e), S(e), ut(e), e;
|
446 | }
|
447 | x.update = function(e) {
|
448 | return ut(e), e;
|
449 | }, x.nodeId = function(e) {
|
450 | return arguments.length ? (m = typeof e == "function" ? e : Y(e), x) : m;
|
451 | }, x.nodeAlign = function(e) {
|
452 | return arguments.length ? (i = typeof e == "function" ? e : Y(e), x) : i;
|
453 | }, x.nodeSort = function(e) {
|
454 | return arguments.length ? (o = e, x) : o;
|
455 | }, x.nodeWidth = function(e) {
|
456 | return arguments.length ? (u = +e, x) : u;
|
457 | }, x.nodePadding = function(e) {
|
458 | return arguments.length ? (y = p = +e, x) : y;
|
459 | }, x.nodes = function(e) {
|
460 | return arguments.length ? (k = typeof e == "function" ? e : Y(e), x) : k;
|
461 | }, x.links = function(e) {
|
462 | return arguments.length ? (b = typeof e == "function" ? e : Y(e), x) : b;
|
463 | }, x.linkSort = function(e) {
|
464 | return arguments.length ? (c = e, x) : c;
|
465 | }, x.size = function(e) {
|
466 | return arguments.length ? (t = n = 0, s = +e[0], a = +e[1], x) : [s - t, a - n];
|
467 | }, x.extent = function(e) {
|
468 | return arguments.length ? (t = +e[0][0], s = +e[1][0], n = +e[0][1], a = +e[1][1], x) : [[t, n], [s, a]];
|
469 | }, x.iterations = function(e) {
|
470 | return arguments.length ? (d = +e, x) : d;
|
471 | };
|
472 | function E({ nodes: e, links: f }) {
|
473 | for (const [h, r] of e.entries())
|
474 | r.index = h, r.sourceLinks = [], r.targetLinks = [];
|
475 | const l = new Map(e.map((h, r) => [m(h, r, e), h]));
|
476 | for (const [h, r] of f.entries()) {
|
477 | r.index = h;
|
478 | let { source: _, target: v } = r;
|
479 | typeof _ != "object" && (_ = r.source = ct(l, _)), typeof v != "object" && (v = r.target = ct(l, v)), _.sourceLinks.push(r), v.targetLinks.push(r);
|
480 | }
|
481 | if (c != null)
|
482 | for (const { sourceLinks: h, targetLinks: r } of e)
|
483 | h.sort(c), r.sort(c);
|
484 | }
|
485 | function L({ nodes: e }) {
|
486 | for (const f of e)
|
487 | f.value = f.fixedValue === void 0 ? Math.max(Z(f.sourceLinks, J), Z(f.targetLinks, J)) : f.fixedValue;
|
488 | }
|
489 | function A({ nodes: e }) {
|
490 | const f = e.length;
|
491 | let l = new Set(e), h = new Set(), r = 0;
|
492 | for (; l.size; ) {
|
493 | for (const _ of l) {
|
494 | _.depth = r;
|
495 | for (const { target: v } of _.sourceLinks)
|
496 | h.add(v);
|
497 | }
|
498 | if (++r > f)
|
499 | throw new Error("circular link");
|
500 | l = h, h = new Set();
|
501 | }
|
502 | }
|
503 | function N({ nodes: e }) {
|
504 | const f = e.length;
|
505 | let l = new Set(e), h = new Set(), r = 0;
|
506 | for (; l.size; ) {
|
507 | for (const _ of l) {
|
508 | _.height = r;
|
509 | for (const { source: v } of _.targetLinks)
|
510 | h.add(v);
|
511 | }
|
512 | if (++r > f)
|
513 | throw new Error("circular link");
|
514 | l = h, h = new Set();
|
515 | }
|
516 | }
|
517 | function C({ nodes: e }) {
|
518 | const f = ot(e, (r) => r.depth) + 1, l = (s - t - u) / (f - 1), h = new Array(f);
|
519 | for (const r of e) {
|
520 | const _ = Math.max(0, Math.min(f - 1, Math.floor(i.call(null, r, f))));
|
521 | r.layer = _, r.x0 = t + _ * l, r.x1 = r.x0 + u, h[_] ? h[_].push(r) : h[_] = [r];
|
522 | }
|
523 | if (o)
|
524 | for (const r of h)
|
525 | r.sort(o);
|
526 | return h;
|
527 | }
|
528 | function j(e) {
|
529 | const f = yt(e, (l) => (a - n - (l.length - 1) * p) / Z(l, J));
|
530 | for (const l of e) {
|
531 | let h = n;
|
532 | for (const r of l) {
|
533 | r.y0 = h, r.y1 = h + r.value * f, h = r.y1 + p;
|
534 | for (const _ of r.sourceLinks)
|
535 | _.width = _.value * f;
|
536 | }
|
537 | h = (a - h + p) / (l.length + 1);
|
538 | for (let r = 0; r < l.length; ++r) {
|
539 | const _ = l[r];
|
540 | _.y0 += h * (r + 1), _.y1 += h * (r + 1);
|
541 | }
|
542 | O(l);
|
543 | }
|
544 | }
|
545 | function S(e) {
|
546 | const f = C(e);
|
547 | p = Math.min(y, (a - n) / (ot(f, (l) => l.length) - 1)), j(f);
|
548 | for (let l = 0; l < d; ++l) {
|
549 | const h = Math.pow(0.99, l), r = Math.max(1 - h, (l + 1) / d);
|
550 | $(f, h, r), M(f, h, r);
|
551 | }
|
552 | }
|
553 | function M(e, f, l) {
|
554 | for (let h = 1, r = e.length; h < r; ++h) {
|
555 | const _ = e[h];
|
556 | for (const v of _) {
|
557 | let R = 0, z = 0;
|
558 | for (const { source: F, value: K } of v.targetLinks) {
|
559 | let W = K * (v.layer - F.layer);
|
560 | R += T(F, v) * W, z += W;
|
561 | }
|
562 | if (!(z > 0))
|
563 | continue;
|
564 | let U = (R / z - v.y0) * f;
|
565 | v.y0 += U, v.y1 += U, w(v);
|
566 | }
|
567 | o === void 0 && _.sort(X), P(_, l);
|
568 | }
|
569 | }
|
570 | function $(e, f, l) {
|
571 | for (let h = e.length, r = h - 2; r >= 0; --r) {
|
572 | const _ = e[r];
|
573 | for (const v of _) {
|
574 | let R = 0, z = 0;
|
575 | for (const { target: F, value: K } of v.sourceLinks) {
|
576 | let W = K * (F.layer - v.layer);
|
577 | R += V(v, F) * W, z += W;
|
578 | }
|
579 | if (!(z > 0))
|
580 | continue;
|
581 | let U = (R / z - v.y0) * f;
|
582 | v.y0 += U, v.y1 += U, w(v);
|
583 | }
|
584 | o === void 0 && _.sort(X), P(_, l);
|
585 | }
|
586 | }
|
587 | function P(e, f) {
|
588 | const l = e.length >> 1, h = e[l];
|
589 | g(e, h.y0 - p, l - 1, f), I(e, h.y1 + p, l + 1, f), g(e, a, e.length - 1, f), I(e, n, 0, f);
|
590 | }
|
591 | function I(e, f, l, h) {
|
592 | for (; l < e.length; ++l) {
|
593 | const r = e[l], _ = (f - r.y0) * h;
|
594 | _ > 1e-6 && (r.y0 += _, r.y1 += _), f = r.y1 + p;
|
595 | }
|
596 | }
|
597 | function g(e, f, l, h) {
|
598 | for (; l >= 0; --l) {
|
599 | const r = e[l], _ = (r.y1 - f) * h;
|
600 | _ > 1e-6 && (r.y0 -= _, r.y1 -= _), f = r.y0 - p;
|
601 | }
|
602 | }
|
603 | function w({ sourceLinks: e, targetLinks: f }) {
|
604 | if (c === void 0) {
|
605 | for (const { source: { sourceLinks: l } } of f)
|
606 | l.sort(at);
|
607 | for (const { target: { targetLinks: l } } of e)
|
608 | l.sort(lt);
|
609 | }
|
610 | }
|
611 | function O(e) {
|
612 | if (c === void 0)
|
613 | for (const { sourceLinks: f, targetLinks: l } of e)
|
614 | f.sort(at), l.sort(lt);
|
615 | }
|
616 | function T(e, f) {
|
617 | let l = e.y0 - (e.sourceLinks.length - 1) * p / 2;
|
618 | for (const { target: h, width: r } of e.sourceLinks) {
|
619 | if (h === f)
|
620 | break;
|
621 | l += r + p;
|
622 | }
|
623 | for (const { source: h, width: r } of f.targetLinks) {
|
624 | if (h === e)
|
625 | break;
|
626 | l -= r;
|
627 | }
|
628 | return l;
|
629 | }
|
630 | function V(e, f) {
|
631 | let l = f.y0 - (f.targetLinks.length - 1) * p / 2;
|
632 | for (const { source: h, width: r } of f.targetLinks) {
|
633 | if (h === e)
|
634 | break;
|
635 | l += r + p;
|
636 | }
|
637 | for (const { target: h, width: r } of e.sourceLinks) {
|
638 | if (h === f)
|
639 | break;
|
640 | l -= r;
|
641 | }
|
642 | return l;
|
643 | }
|
644 | return x;
|
645 | }
|
646 | var et = Math.PI, nt = 2 * et, D = 1e-6, Yt = nt - D;
|
647 | function it() {
|
648 | this._x0 = this._y0 =
|
649 | this._x1 = this._y1 = null, this._ = "";
|
650 | }
|
651 | function gt() {
|
652 | return new it();
|
653 | }
|
654 | it.prototype = gt.prototype = {
|
655 | constructor: it,
|
656 | moveTo: function(t, n) {
|
657 | this._ += "M" + (this._x0 = this._x1 = +t) + "," + (this._y0 = this._y1 = +n);
|
658 | },
|
659 | closePath: function() {
|
660 | this._x1 !== null && (this._x1 = this._x0, this._y1 = this._y0, this._ += "Z");
|
661 | },
|
662 | lineTo: function(t, n) {
|
663 | this._ += "L" + (this._x1 = +t) + "," + (this._y1 = +n);
|
664 | },
|
665 | quadraticCurveTo: function(t, n, s, a) {
|
666 | this._ += "Q" + +t + "," + +n + "," + (this._x1 = +s) + "," + (this._y1 = +a);
|
667 | },
|
668 | bezierCurveTo: function(t, n, s, a, u, y) {
|
669 | this._ += "C" + +t + "," + +n + "," + +s + "," + +a + "," + (this._x1 = +u) + "," + (this._y1 = +y);
|
670 | },
|
671 | arcTo: function(t, n, s, a, u) {
|
672 | t = +t, n = +n, s = +s, a = +a, u = +u;
|
673 | var y = this._x1, p = this._y1, m = s - t, i = a - n, o = y - t, c = p - n, k = o * o + c * c;
|
674 | if (u < 0)
|
675 | throw new Error("negative radius: " + u);
|
676 | if (this._x1 === null)
|
677 | this._ += "M" + (this._x1 = t) + "," + (this._y1 = n);
|
678 | else if (k > D)
|
679 | if (!(Math.abs(c * m - i * o) > D) || !u)
|
680 | this._ += "L" + (this._x1 = t) + "," + (this._y1 = n);
|
681 | else {
|
682 | var b = s - y, d = a - p, x = m * m + i * i, E = b * b + d * d, L = Math.sqrt(x), A = Math.sqrt(k), N = u * Math.tan((et - Math.acos((x + k - E) / (2 * L * A))) / 2), C = N / A, j = N / L;
|
683 | Math.abs(C - 1) > D && (this._ += "L" + (t + C * o) + "," + (n + C * c)), this._ += "A" + u + "," + u + ",0,0," + +(c * b > o * d) + "," + (this._x1 = t + j * m) + "," + (this._y1 = n + j * i);
|
684 | }
|
685 | },
|
686 | arc: function(t, n, s, a, u, y) {
|
687 | t = +t, n = +n, s = +s, y = !!y;
|
688 | var p = s * Math.cos(a), m = s * Math.sin(a), i = t + p, o = n + m, c = 1 ^ y, k = y ? a - u : u - a;
|
689 | if (s < 0)
|
690 | throw new Error("negative radius: " + s);
|
691 | this._x1 === null ? this._ += "M" + i + "," + o : (Math.abs(this._x1 - i) > D || Math.abs(this._y1 - o) > D) && (this._ += "L" + i + "," + o), s && (k < 0 && (k = k % nt + nt), k > Yt ? this._ += "A" + s + "," + s + ",0,1," + c + "," + (t - p) + "," + (n - m) + "A" + s + "," + s + ",0,1," + c + "," + (this._x1 = i) + "," + (this._y1 = o) : k > D && (this._ += "A" + s + "," + s + ",0," + +(k >= et) + "," + c + "," + (this._x1 = t + s * Math.cos(u)) + "," + (this._y1 = n + s * Math.sin(u))));
|
692 | },
|
693 | rect: function(t, n, s, a) {
|
694 | this._ += "M" + (this._x0 = this._x1 = +t) + "," + (this._y0 = this._y1 = +n) + "h" + +s + "v" + +a + "h" + -s + "Z";
|
695 | },
|
696 | toString: function() {
|
697 | return this._;
|
698 | }
|
699 | };
|
700 | function ht(t) {
|
701 | return function() {
|
702 | return t;
|
703 | };
|
704 | }
|
705 | function Ht(t) {
|
706 | return t[0];
|
707 | }
|
708 | function Xt(t) {
|
709 | return t[1];
|
710 | }
|
711 | var qt = Array.prototype.slice;
|
712 | function Qt(t) {
|
713 | return t.source;
|
714 | }
|
715 | function Kt(t) {
|
716 | return t.target;
|
717 | }
|
718 | function Zt(t) {
|
719 | var n = Qt, s = Kt, a = Ht, u = Xt, y = null;
|
720 | function p() {
|
721 | var m, i = qt.call(arguments), o = n.apply(this, i), c = s.apply(this, i);
|
722 | if (y || (y = m = gt()), t(y, +a.apply(this, (i[0] = o, i)), +u.apply(this, i), +a.apply(this, (i[0] = c, i)), +u.apply(this, i)), m)
|
723 | return y = null, m + "" || null;
|
724 | }
|
725 | return p.source = function(m) {
|
726 | return arguments.length ? (n = m, p) : n;
|
727 | }, p.target = function(m) {
|
728 | return arguments.length ? (s = m, p) : s;
|
729 | }, p.x = function(m) {
|
730 | return arguments.length ? (a = typeof m == "function" ? m : ht(+m), p) : a;
|
731 | }, p.y = function(m) {
|
732 | return arguments.length ? (u = typeof m == "function" ? m : ht(+m), p) : u;
|
733 | }, p.context = function(m) {
|
734 | return arguments.length ? (y = m ?? null, p) : y;
|
735 | }, p;
|
736 | }
|
737 | function Jt(t, n, s, a, u) {
|
738 | t.moveTo(n, s), t.bezierCurveTo(n = (n + a) / 2, s, n, u, a, u);
|
739 | }
|
740 | function te() {
|
741 | return Zt(Jt);
|
742 | }
|
743 | function ee(t) {
|
744 | return [t.source.x1, t.y0];
|
745 | }
|
746 | function ne(t) {
|
747 | return [t.target.x0, t.y1];
|
748 | }
|
749 | function ie() {
|
750 | return te().source(ee).target(ne);
|
751 | }
|
752 | const pt = class st {
|
753 | static next(n) {
|
754 | return new st(n + ++st.count);
|
755 | }
|
756 | constructor(n) {
|
757 | this.id = n, this.href = `#${n}`;
|
758 | }
|
759 | toString() {
|
760 | return "url(" + this.href + ")";
|
761 | }
|
762 | };
|
763 | pt.count = 0;
|
764 | let ft = pt;
|
765 | const se = {
|
766 | left: Bt,
|
767 | right: Vt,
|
768 | center: Rt,
|
769 | justify: dt
|
770 | }, re = function(t, n, s, a) {
|
771 | const { securityLevel: u, sankey: y } = rt(), p = Lt.sankey;
|
772 | let m;
|
773 | u === "sandbox" && (m = G("#i" + n));
|
774 | const i = u === "sandbox" ? G(m.nodes()[0].contentDocument.body) : G("body"), o = u === "sandbox" ? i.select(`[id="${n}"]`) : G(`[id="${n}"]`), c = (y == null ? void 0 : y.width) ?? p.width, k = (y == null ? void 0 : y.height) ?? p.width, b = (y == null ? void 0 : y.useMaxWidth) ?? p.useMaxWidth, d = (y == null ? void 0 : y.nodeAlignment) ?? p.nodeAlignment, x = (y == null ? void 0 : y.prefix) ?? p.prefix, E = (y == null ? void 0 : y.suffix) ?? p.suffix, L = (y == null ? void 0 : y.showValues) ?? p.showValues, A = a.db.getGraph(), N = se[d], C = 10;
|
775 | Gt().nodeId((g) => g.id).nodeWidth(C).nodePadding(10 + (L ? 15 : 0)).nodeAlign(N).extent([
|
776 | [0, 0],
|
777 | [c, k]
|
778 | ])(A);
|
779 | const S = At(Tt);
|
780 | o.append("g").attr("class", "nodes").selectAll(".node").data(A.nodes).join("g").attr("class", "node").attr("id", (g) => (g.uid = ft.next("node-")).id).attr("transform", function(g) {
|
781 | return "translate(" + g.x0 + "," + g.y0 + ")";
|
782 | }).attr("x", (g) => g.x0).attr("y", (g) => g.y0).append("rect").attr("height", (g) => g.y1 - g.y0).attr("width", (g) => g.x1 - g.x0).attr("fill", (g) => S(g.id));
|
783 | const M = ({ id: g, value: w }) => L ? `${g}
|
784 | ${x}${Math.round(w * 100) / 100}${E}` : g;
|
785 | o.append("g").attr("class", "node-labels").attr("font-family", "sans-serif").attr("font-size", 14).selectAll("text").data(A.nodes).join("text").attr("x", (g) => g.x0 < c / 2 ? g.x1 + 6 : g.x0 - 6).attr("y", (g) => (g.y1 + g.y0) / 2).attr("dy", `${L ? "0" : "0.35"}em`).attr("text-anchor", (g) => g.x0 < c / 2 ? "start" : "end").text(M);
|
786 | const $ = o.append("g").attr("class", "links").attr("fill", "none").attr("stroke-opacity", 0.5).selectAll(".link").data(A.links).join("g").attr("class", "link").style("mix-blend-mode", "multiply"), P = (y == null ? void 0 : y.linkColor) || "gradient";
|
787 | if (P === "gradient") {
|
788 | const g = $.append("linearGradient").attr("id", (w) => (w.uid = ft.next("linearGradient-")).id).attr("gradientUnits", "userSpaceOnUse").attr("x1", (w) => w.source.x1).attr("x2", (w) => w.target.x0);
|
789 | g.append("stop").attr("offset", "0%").attr("stop-color", (w) => S(w.source.id)), g.append("stop").attr("offset", "100%").attr("stop-color", (w) => S(w.target.id));
|
790 | }
|
791 | let I;
|
792 | switch (P) {
|
793 | case "gradient":
|
794 | I = (g) => g.uid;
|
795 | break;
|
796 | case "source":
|
797 | I = (g) => S(g.source.id);
|
798 | break;
|
799 | case "target":
|
800 | I = (g) => S(g.target.id);
|
801 | break;
|
802 | default:
|
803 | I = P;
|
804 | }
|
805 | $.append("path").attr("d", ie()).attr("stroke", I).attr("stroke-width", (g) => Math.max(1, g.width)), Et(void 0, o, 0, b);
|
806 | }, oe = {
|
807 | draw: re
|
808 | }, le = (t) => t.replaceAll(/^[^\S\n\r]+|[^\S\n\r]+$/g, "").replaceAll(/([\n\r])+/g, `
|
809 | `).trim(), ae = H.parse.bind(H);
|
810 | H.parse = (t) => ae(le(t));
|
811 | const ye = {
|
812 | parser: H,
|
813 | db: zt,
|
814 | renderer: oe
|
815 | };
|
816 | export {
|
817 | ye as diagram
|
818 | };
|