UNPKG

52.7 kBJavaScriptView Raw
1import { c as ge, _ as se, l as L, E as ye, f as _e, B as we, o as De, j as H, k as Ne } from "./mermaid-9f2aa176.js";
2import { c as Ie } from "./clone-afc2f047.js";
3import { c as Oe } from "./channel-ebbc4130.js";
4import { h as Te, f as ze, j as Ce, e as de, p as Ae, a as Re } from "./edges-16357fde.js";
5import { G as ve } from "./graph-0ee63739.js";
6import { o as Be } from "./ordinal-5695958c.js";
7import { d as ke } from "./Tableau10-558cc280.js";
8import "./createText-03b82060.js";
9import "./line-24d93f1b.js";
10import "./array-2ff2c7a6.js";
11import "./path-428ebac9.js";
12import "./init-f9637058.js";
13var ee = function() {
14 var e = function(D, l, s, r) {
15 for (s = s || {}, r = D.length; r--; s[D[r]] = l)
16 ;
17 return s;
18 }, c = [1, 7], u = [1, 13], a = [1, 14], i = [1, 15], g = [1, 19], o = [1, 16], p = [1, 17], f = [1, 18], m = [8, 30], S = [8, 21, 28, 29, 30, 31, 32, 40, 44, 47], y = [1, 23], z = [1, 24], I = [8, 15, 16, 21, 28, 29, 30, 31, 32, 40, 44, 47], w = [8, 15, 16, 21, 27, 28, 29, 30, 31, 32, 40, 44, 47], C = [1, 49], E = {
19 trace: function() {
20 },
21 yy: {},
22 symbols_: { error: 2, spaceLines: 3, SPACELINE: 4, NL: 5, separator: 6, SPACE: 7, EOF: 8, start: 9, BLOCK_DIAGRAM_KEY: 10, document: 11, stop: 12, statement: 13, link: 14, LINK: 15, START_LINK: 16, LINK_LABEL: 17, STR: 18, nodeStatement: 19, columnsStatement: 20, SPACE_BLOCK: 21, blockStatement: 22, classDefStatement: 23, cssClassStatement: 24, styleStatement: 25, node: 26, SIZE: 27, COLUMNS: 28, "id-block": 29, end: 30, block: 31, NODE_ID: 32, nodeShapeNLabel: 33, dirList: 34, DIR: 35, NODE_DSTART: 36, NODE_DEND: 37, BLOCK_ARROW_START: 38, BLOCK_ARROW_END: 39, classDef: 40, CLASSDEF_ID: 41, CLASSDEF_STYLEOPTS: 42, DEFAULT: 43, class: 44, CLASSENTITY_IDS: 45, STYLECLASS: 46, style: 47, STYLE_ENTITY_IDS: 48, STYLE_DEFINITION_DATA: 49, $accept: 0, $end: 1 },
23 terminals_: { 2: "error", 4: "SPACELINE", 5: "NL", 7: "SPACE", 8: "EOF", 10: "BLOCK_DIAGRAM_KEY", 15: "LINK", 16: "START_LINK", 17: "LINK_LABEL", 18: "STR", 21: "SPACE_BLOCK", 27: "SIZE", 28: "COLUMNS", 29: "id-block", 30: "end", 31: "block", 32: "NODE_ID", 35: "DIR", 36: "NODE_DSTART", 37: "NODE_DEND", 38: "BLOCK_ARROW_START", 39: "BLOCK_ARROW_END", 40: "classDef", 41: "CLASSDEF_ID", 42: "CLASSDEF_STYLEOPTS", 43: "DEFAULT", 44: "class", 45: "CLASSENTITY_IDS", 46: "STYLECLASS", 47: "style", 48: "STYLE_ENTITY_IDS", 49: "STYLE_DEFINITION_DATA" },
24 productions_: [0, [3, 1], [3, 2], [3, 2], [6, 1], [6, 1], [6, 1], [9, 3], [12, 1], [12, 1], [12, 2], [12, 2], [11, 1], [11, 2], [14, 1], [14, 4], [13, 1], [13, 1], [13, 1], [13, 1], [13, 1], [13, 1], [13, 1], [19, 3], [19, 2], [19, 1], [20, 1], [22, 4], [22, 3], [26, 1], [26, 2], [34, 1], [34, 2], [33, 3], [33, 4], [23, 3], [23, 3], [24, 3], [25, 3]],
25 performAction: function(l, s, r, h, d, t, x) {
26 var n = t.length - 1;
27 switch (d) {
28 case 4:
29 h.getLogger().debug("Rule: separator (NL) ");
30 break;
31 case 5:
32 h.getLogger().debug("Rule: separator (Space) ");
33 break;
34 case 6:
35 h.getLogger().debug("Rule: separator (EOF) ");
36 break;
37 case 7:
38 h.getLogger().debug("Rule: hierarchy: ", t[n - 1]), h.setHierarchy(t[n - 1]);
39 break;
40 case 8:
41 h.getLogger().debug("Stop NL ");
42 break;
43 case 9:
44 h.getLogger().debug("Stop EOF ");
45 break;
46 case 10:
47 h.getLogger().debug("Stop NL2 ");
48 break;
49 case 11:
50 h.getLogger().debug("Stop EOF2 ");
51 break;
52 case 12:
53 h.getLogger().debug("Rule: statement: ", t[n]), typeof t[n].length == "number" ? this.$ = t[n] : this.$ = [t[n]];
54 break;
55 case 13:
56 h.getLogger().debug("Rule: statement #2: ", t[n - 1]), this.$ = [t[n - 1]].concat(t[n]);
57 break;
58 case 14:
59 h.getLogger().debug("Rule: link: ", t[n], l), this.$ = { edgeTypeStr: t[n], label: "" };
60 break;
61 case 15:
62 h.getLogger().debug("Rule: LABEL link: ", t[n - 3], t[n - 1], t[n]), this.$ = { edgeTypeStr: t[n], label: t[n - 1] };
63 break;
64 case 18:
65 const B = parseInt(t[n]), Y = h.generateId();
66 this.$ = { id: Y, type: "space", label: "", width: B, children: [] };
67 break;
68 case 23:
69 h.getLogger().debug("Rule: (nodeStatement link node) ", t[n - 2], t[n - 1], t[n], " typestr: ", t[n - 1].edgeTypeStr);
70 const F = h.edgeStrToEdgeData(t[n - 1].edgeTypeStr);
71 this.$ = [
72 { id: t[n - 2].id, label: t[n - 2].label, type: t[n - 2].type, directions: t[n - 2].directions },
73 { id: t[n - 2].id + "-" + t[n].id, start: t[n - 2].id, end: t[n].id, label: t[n - 1].label, type: "edge", directions: t[n].directions, arrowTypeEnd: F, arrowTypeStart: "arrow_open" },
74 { id: t[n].id, label: t[n].label, type: h.typeStr2Type(t[n].typeStr), directions: t[n].directions }
75 ];
76 break;
77 case 24:
78 h.getLogger().debug("Rule: nodeStatement (abc88 node size) ", t[n - 1], t[n]), this.$ = { id: t[n - 1].id, label: t[n - 1].label, type: h.typeStr2Type(t[n - 1].typeStr), directions: t[n - 1].directions, widthInColumns: parseInt(t[n], 10) };
79 break;
80 case 25:
81 h.getLogger().debug("Rule: nodeStatement (node) ", t[n]), this.$ = { id: t[n].id, label: t[n].label, type: h.typeStr2Type(t[n].typeStr), directions: t[n].directions, widthInColumns: 1 };
82 break;
83 case 26:
84 h.getLogger().debug("APA123", this ? this : "na"), h.getLogger().debug("COLUMNS: ", t[n]), this.$ = { type: "column-setting", columns: t[n] === "auto" ? -1 : parseInt(t[n]) };
85 break;
86 case 27:
87 h.getLogger().debug("Rule: id-block statement : ", t[n - 2], t[n - 1]), h.generateId(), this.$ = { ...t[n - 2], type: "composite", children: t[n - 1] };
88 break;
89 case 28:
90 h.getLogger().debug("Rule: blockStatement : ", t[n - 2], t[n - 1], t[n]);
91 const R = h.generateId();
92 this.$ = { id: R, type: "composite", label: "", children: t[n - 1] };
93 break;
94 case 29:
95 h.getLogger().debug("Rule: node (NODE_ID separator): ", t[n]), this.$ = { id: t[n] };
96 break;
97 case 30:
98 h.getLogger().debug("Rule: node (NODE_ID nodeShapeNLabel separator): ", t[n - 1], t[n]), this.$ = { id: t[n - 1], label: t[n].label, typeStr: t[n].typeStr, directions: t[n].directions };
99 break;
100 case 31:
101 h.getLogger().debug("Rule: dirList: ", t[n]), this.$ = [t[n]];
102 break;
103 case 32:
104 h.getLogger().debug("Rule: dirList: ", t[n - 1], t[n]), this.$ = [t[n - 1]].concat(t[n]);
105 break;
106 case 33:
107 h.getLogger().debug("Rule: nodeShapeNLabel: ", t[n - 2], t[n - 1], t[n]), this.$ = { typeStr: t[n - 2] + t[n], label: t[n - 1] };
108 break;
109 case 34:
110 h.getLogger().debug("Rule: BLOCK_ARROW nodeShapeNLabel: ", t[n - 3], t[n - 2], " #3:", t[n - 1], t[n]), this.$ = { typeStr: t[n - 3] + t[n], label: t[n - 2], directions: t[n - 1] };
111 break;
112 case 35:
113 case 36:
114 this.$ = { type: "classDef", id: t[n - 1].trim(), css: t[n].trim() };
115 break;
116 case 37:
117 this.$ = { type: "applyClass", id: t[n - 1].trim(), styleClass: t[n].trim() };
118 break;
119 case 38:
120 this.$ = { type: "applyStyles", id: t[n - 1].trim(), stylesStr: t[n].trim() };
121 break;
122 }
123 },
124 table: [{ 9: 1, 10: [1, 2] }, { 1: [3] }, { 11: 3, 13: 4, 19: 5, 20: 6, 21: c, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 28: u, 29: a, 31: i, 32: g, 40: o, 44: p, 47: f }, { 8: [1, 20] }, e(m, [2, 12], { 13: 4, 19: 5, 20: 6, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 11: 21, 21: c, 28: u, 29: a, 31: i, 32: g, 40: o, 44: p, 47: f }), e(S, [2, 16], { 14: 22, 15: y, 16: z }), e(S, [2, 17]), e(S, [2, 18]), e(S, [2, 19]), e(S, [2, 20]), e(S, [2, 21]), e(S, [2, 22]), e(I, [2, 25], { 27: [1, 25] }), e(S, [2, 26]), { 19: 26, 26: 12, 32: g }, { 11: 27, 13: 4, 19: 5, 20: 6, 21: c, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 28: u, 29: a, 31: i, 32: g, 40: o, 44: p, 47: f }, { 41: [1, 28], 43: [1, 29] }, { 45: [1, 30] }, { 48: [1, 31] }, e(w, [2, 29], { 33: 32, 36: [1, 33], 38: [1, 34] }), { 1: [2, 7] }, e(m, [2, 13]), { 26: 35, 32: g }, { 32: [2, 14] }, { 17: [1, 36] }, e(I, [2, 24]), { 11: 37, 13: 4, 14: 22, 15: y, 16: z, 19: 5, 20: 6, 21: c, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 28: u, 29: a, 31: i, 32: g, 40: o, 44: p, 47: f }, { 30: [1, 38] }, { 42: [1, 39] }, { 42: [1, 40] }, { 46: [1, 41] }, { 49: [1, 42] }, e(w, [2, 30]), { 18: [1, 43] }, { 18: [1, 44] }, e(I, [2, 23]), { 18: [1, 45] }, { 30: [1, 46] }, e(S, [2, 28]), e(S, [2, 35]), e(S, [2, 36]), e(S, [2, 37]), e(S, [2, 38]), { 37: [1, 47] }, { 34: 48, 35: C }, { 15: [1, 50] }, e(S, [2, 27]), e(w, [2, 33]), { 39: [1, 51] }, { 34: 52, 35: C, 39: [2, 31] }, { 32: [2, 15] }, e(w, [2, 34]), { 39: [2, 32] }],
125 defaultActions: { 20: [2, 7], 23: [2, 14], 50: [2, 15], 52: [2, 32] },
126 parseError: function(l, s) {
127 if (s.recoverable)
128 this.trace(l);
129 else {
130 var r = new Error(l);
131 throw r.hash = s, r;
132 }
133 },
134 parse: function(l) {
135 var s = this, r = [0], h = [], d = [null], t = [], x = this.table, n = "", B = 0, Y = 0, F = 2, R = 1, me = t.slice.call(arguments, 1), _ = Object.create(this.lexer), K = { yy: {} };
136 for (var Z in this.yy)
137 Object.prototype.hasOwnProperty.call(this.yy, Z) && (K.yy[Z] = this.yy[Z]);
138 _.setInput(l, K.yy), K.yy.lexer = _, K.yy.parser = this, typeof _.yylloc > "u" && (_.yylloc = {});
139 var J = _.yylloc;
140 t.push(J);
141 var be = _.options && _.options.ranges;
142 typeof K.yy.parseError == "function" ? this.parseError = K.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
143 function Ee() {
144 var P;
145 return P = h.pop() || _.lex() || R, typeof P != "number" && (P instanceof Array && (h = P, P = h.pop()), P = s.symbols_[P] || P), P;
146 }
147 for (var O, M, A, Q, W = {}, X, k, ae, G; ; ) {
148 if (M = r[r.length - 1], this.defaultActions[M] ? A = this.defaultActions[M] : ((O === null || typeof O > "u") && (O = Ee()), A = x[M] && x[M][O]), typeof A > "u" || !A.length || !A[0]) {
149 var $ = "";
150 G = [];
151 for (X in x[M])
152 this.terminals_[X] && X > F && G.push("'" + this.terminals_[X] + "'");
153 _.showPosition ? $ = "Parse error on line " + (B + 1) + `:
154` + _.showPosition() + `
155Expecting ` + G.join(", ") + ", got '" + (this.terminals_[O] || O) + "'" : $ = "Parse error on line " + (B + 1) + ": Unexpected " + (O == R ? "end of input" : "'" + (this.terminals_[O] || O) + "'"), this.parseError($, {
156 text: _.match,
157 token: this.terminals_[O] || O,
158 line: _.yylineno,
159 loc: J,
160 expected: G
161 });
162 }
163 if (A[0] instanceof Array && A.length > 1)
164 throw new Error("Parse Error: multiple actions possible at state: " + M + ", token: " + O);
165 switch (A[0]) {
166 case 1:
167 r.push(O), d.push(_.yytext), t.push(_.yylloc), r.push(A[1]), O = null, Y = _.yyleng, n = _.yytext, B = _.yylineno, J = _.yylloc;
168 break;
169 case 2:
170 if (k = this.productions_[A[1]][1], W.$ = d[d.length - k], W._$ = {
171 first_line: t[t.length - (k || 1)].first_line,
172 last_line: t[t.length - 1].last_line,
173 first_column: t[t.length - (k || 1)].first_column,
174 last_column: t[t.length - 1].last_column
175 }, be && (W._$.range = [
176 t[t.length - (k || 1)].range[0],
177 t[t.length - 1].range[1]
178 ]), Q = this.performAction.apply(W, [
179 n,
180 Y,
181 B,
182 K.yy,
183 A[1],
184 d,
185 t
186 ].concat(me)), typeof Q < "u")
187 return Q;
188 k && (r = r.slice(0, -1 * k * 2), d = d.slice(0, -1 * k), t = t.slice(0, -1 * k)), r.push(this.productions_[A[1]][0]), d.push(W.$), t.push(W._$), ae = x[r[r.length - 2]][r[r.length - 1]], r.push(ae);
189 break;
190 case 3:
191 return !0;
192 }
193 }
194 return !0;
195 }
196 }, v = function() {
197 var D = {
198 EOF: 1,
199 parseError: function(s, r) {
200 if (this.yy.parser)
201 this.yy.parser.parseError(s, r);
202 else
203 throw new Error(s);
204 },
205 // resets the lexer, sets new input
206 setInput: function(l, s) {
207 return this.yy = s || this.yy || {}, this._input = l, this._more = this._backtrack = this.done = !1, this.yylineno = this.yyleng = 0, this.yytext = this.matched = this.match = "", this.conditionStack = ["INITIAL"], this.yylloc = {
208 first_line: 1,
209 first_column: 0,
210 last_line: 1,
211 last_column: 0
212 }, this.options.ranges && (this.yylloc.range = [0, 0]), this.offset = 0, this;
213 },
214 // consumes and returns one char from the input
215 input: function() {
216 var l = this._input[0];
217 this.yytext += l, this.yyleng++, this.offset++, this.match += l, this.matched += l;
218 var s = l.match(/(?:\r\n?|\n).*/g);
219 return s ? (this.yylineno++, this.yylloc.last_line++) : this.yylloc.last_column++, this.options.ranges && this.yylloc.range[1]++, this._input = this._input.slice(1), l;
220 },
221 // unshifts one char (or a string) into the input
222 unput: function(l) {
223 var s = l.length, r = l.split(/(?:\r\n?|\n)/g);
224 this._input = l + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - s), this.offset -= s;
225 var h = this.match.split(/(?:\r\n?|\n)/g);
226 this.match = this.match.substr(0, this.match.length - 1), this.matched = this.matched.substr(0, this.matched.length - 1), r.length - 1 && (this.yylineno -= r.length - 1);
227 var d = this.yylloc.range;
228 return this.yylloc = {
229 first_line: this.yylloc.first_line,
230 last_line: this.yylineno + 1,
231 first_column: this.yylloc.first_column,
232 last_column: r ? (r.length === h.length ? this.yylloc.first_column : 0) + h[h.length - r.length].length - r[0].length : this.yylloc.first_column - s
233 }, this.options.ranges && (this.yylloc.range = [d[0], d[0] + this.yyleng - s]), this.yyleng = this.yytext.length, this;
234 },
235 // When called from action, caches matched text and appends it on next action
236 more: function() {
237 return this._more = !0, this;
238 },
239 // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
240 reject: function() {
241 if (this.options.backtrack_lexer)
242 this._backtrack = !0;
243 else
244 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).
245` + this.showPosition(), {
246 text: "",
247 token: null,
248 line: this.yylineno
249 });
250 return this;
251 },
252 // retain first n characters of the match
253 less: function(l) {
254 this.unput(this.match.slice(l));
255 },
256 // displays already matched input, i.e. for error messages
257 pastInput: function() {
258 var l = this.matched.substr(0, this.matched.length - this.match.length);
259 return (l.length > 20 ? "..." : "") + l.substr(-20).replace(/\n/g, "");
260 },
261 // displays upcoming input, i.e. for error messages
262 upcomingInput: function() {
263 var l = this.match;
264 return l.length < 20 && (l += this._input.substr(0, 20 - l.length)), (l.substr(0, 20) + (l.length > 20 ? "..." : "")).replace(/\n/g, "");
265 },
266 // displays the character position where the lexing error occurred, i.e. for error messages
267 showPosition: function() {
268 var l = this.pastInput(), s = new Array(l.length + 1).join("-");
269 return l + this.upcomingInput() + `
270` + s + "^";
271 },
272 // test the lexed token: return FALSE when not a match, otherwise return token
273 test_match: function(l, s) {
274 var r, h, d;
275 if (this.options.backtrack_lexer && (d = {
276 yylineno: this.yylineno,
277 yylloc: {
278 first_line: this.yylloc.first_line,
279 last_line: this.last_line,
280 first_column: this.yylloc.first_column,
281 last_column: this.yylloc.last_column
282 },
283 yytext: this.yytext,
284 match: this.match,
285 matches: this.matches,
286 matched: this.matched,
287 yyleng: this.yyleng,
288 offset: this.offset,
289 _more: this._more,
290 _input: this._input,
291 yy: this.yy,
292 conditionStack: this.conditionStack.slice(0),
293 done: this.done
294 }, this.options.ranges && (d.yylloc.range = this.yylloc.range.slice(0))), h = l[0].match(/(?:\r\n?|\n).*/g), h && (this.yylineno += h.length), this.yylloc = {
295 first_line: this.yylloc.last_line,
296 last_line: this.yylineno + 1,
297 first_column: this.yylloc.last_column,
298 last_column: h ? h[h.length - 1].length - h[h.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + l[0].length
299 }, this.yytext += l[0], this.match += l[0], this.matches = l, 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(l[0].length), this.matched += l[0], r = this.performAction.call(this, this.yy, this, s, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), r)
300 return r;
301 if (this._backtrack) {
302 for (var t in d)
303 this[t] = d[t];
304 return !1;
305 }
306 return !1;
307 },
308 // return next match in input
309 next: function() {
310 if (this.done)
311 return this.EOF;
312 this._input || (this.done = !0);
313 var l, s, r, h;
314 this._more || (this.yytext = "", this.match = "");
315 for (var d = this._currentRules(), t = 0; t < d.length; t++)
316 if (r = this._input.match(this.rules[d[t]]), r && (!s || r[0].length > s[0].length)) {
317 if (s = r, h = t, this.options.backtrack_lexer) {
318 if (l = this.test_match(r, d[t]), l !== !1)
319 return l;
320 if (this._backtrack) {
321 s = !1;
322 continue;
323 } else
324 return !1;
325 } else if (!this.options.flex)
326 break;
327 }
328 return s ? (l = this.test_match(s, d[h]), l !== !1 ? l : !1) : this._input === "" ? this.EOF : this.parseError("Lexical error on line " + (this.yylineno + 1) + `. Unrecognized text.
329` + this.showPosition(), {
330 text: "",
331 token: null,
332 line: this.yylineno
333 });
334 },
335 // return next match that has a token
336 lex: function() {
337 var s = this.next();
338 return s || this.lex();
339 },
340 // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
341 begin: function(s) {
342 this.conditionStack.push(s);
343 },
344 // pop the previously active lexer condition state off the condition stack
345 popState: function() {
346 var s = this.conditionStack.length - 1;
347 return s > 0 ? this.conditionStack.pop() : this.conditionStack[0];
348 },
349 // produce the lexer rule set which is active for the currently active lexer condition state
350 _currentRules: function() {
351 return this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1] ? this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules : this.conditions.INITIAL.rules;
352 },
353 // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
354 topState: function(s) {
355 return s = this.conditionStack.length - 1 - Math.abs(s || 0), s >= 0 ? this.conditionStack[s] : "INITIAL";
356 },
357 // alias for begin(condition)
358 pushState: function(s) {
359 this.begin(s);
360 },
361 // return the number of states currently on the stack
362 stateStackSize: function() {
363 return this.conditionStack.length;
364 },
365 options: {},
366 performAction: function(s, r, h, d) {
367 switch (h) {
368 case 0:
369 return 10;
370 case 1:
371 return s.getLogger().debug("Found space-block"), 31;
372 case 2:
373 return s.getLogger().debug("Found nl-block"), 31;
374 case 3:
375 return s.getLogger().debug("Found space-block"), 29;
376 case 4:
377 s.getLogger().debug(".", r.yytext);
378 break;
379 case 5:
380 s.getLogger().debug("_", r.yytext);
381 break;
382 case 6:
383 return 5;
384 case 7:
385 return r.yytext = -1, 28;
386 case 8:
387 return r.yytext = r.yytext.replace(/columns\s+/, ""), s.getLogger().debug("COLUMNS (LEX)", r.yytext), 28;
388 case 9:
389 this.pushState("md_string");
390 break;
391 case 10:
392 return "MD_STR";
393 case 11:
394 this.popState();
395 break;
396 case 12:
397 this.pushState("string");
398 break;
399 case 13:
400 s.getLogger().debug("LEX: POPPING STR:", r.yytext), this.popState();
401 break;
402 case 14:
403 return s.getLogger().debug("LEX: STR end:", r.yytext), "STR";
404 case 15:
405 return r.yytext = r.yytext.replace(/space\:/, ""), s.getLogger().debug("SPACE NUM (LEX)", r.yytext), 21;
406 case 16:
407 return r.yytext = "1", s.getLogger().debug("COLUMNS (LEX)", r.yytext), 21;
408 case 17:
409 return 43;
410 case 18:
411 return "LINKSTYLE";
412 case 19:
413 return "INTERPOLATE";
414 case 20:
415 return this.pushState("CLASSDEF"), 40;
416 case 21:
417 return this.popState(), this.pushState("CLASSDEFID"), "DEFAULT_CLASSDEF_ID";
418 case 22:
419 return this.popState(), this.pushState("CLASSDEFID"), 41;
420 case 23:
421 return this.popState(), 42;
422 case 24:
423 return this.pushState("CLASS"), 44;
424 case 25:
425 return this.popState(), this.pushState("CLASS_STYLE"), 45;
426 case 26:
427 return this.popState(), 46;
428 case 27:
429 return this.pushState("STYLE_STMNT"), 47;
430 case 28:
431 return this.popState(), this.pushState("STYLE_DEFINITION"), 48;
432 case 29:
433 return this.popState(), 49;
434 case 30:
435 return this.pushState("acc_title"), "acc_title";
436 case 31:
437 return this.popState(), "acc_title_value";
438 case 32:
439 return this.pushState("acc_descr"), "acc_descr";
440 case 33:
441 return this.popState(), "acc_descr_value";
442 case 34:
443 this.pushState("acc_descr_multiline");
444 break;
445 case 35:
446 this.popState();
447 break;
448 case 36:
449 return "acc_descr_multiline_value";
450 case 37:
451 return 30;
452 case 38:
453 return this.popState(), s.getLogger().debug("Lex: (("), "NODE_DEND";
454 case 39:
455 return this.popState(), s.getLogger().debug("Lex: (("), "NODE_DEND";
456 case 40:
457 return this.popState(), s.getLogger().debug("Lex: ))"), "NODE_DEND";
458 case 41:
459 return this.popState(), s.getLogger().debug("Lex: (("), "NODE_DEND";
460 case 42:
461 return this.popState(), s.getLogger().debug("Lex: (("), "NODE_DEND";
462 case 43:
463 return this.popState(), s.getLogger().debug("Lex: (-"), "NODE_DEND";
464 case 44:
465 return this.popState(), s.getLogger().debug("Lex: -)"), "NODE_DEND";
466 case 45:
467 return this.popState(), s.getLogger().debug("Lex: (("), "NODE_DEND";
468 case 46:
469 return this.popState(), s.getLogger().debug("Lex: ]]"), "NODE_DEND";
470 case 47:
471 return this.popState(), s.getLogger().debug("Lex: ("), "NODE_DEND";
472 case 48:
473 return this.popState(), s.getLogger().debug("Lex: ])"), "NODE_DEND";
474 case 49:
475 return this.popState(), s.getLogger().debug("Lex: /]"), "NODE_DEND";
476 case 50:
477 return this.popState(), s.getLogger().debug("Lex: /]"), "NODE_DEND";
478 case 51:
479 return this.popState(), s.getLogger().debug("Lex: )]"), "NODE_DEND";
480 case 52:
481 return this.popState(), s.getLogger().debug("Lex: )"), "NODE_DEND";
482 case 53:
483 return this.popState(), s.getLogger().debug("Lex: ]>"), "NODE_DEND";
484 case 54:
485 return this.popState(), s.getLogger().debug("Lex: ]"), "NODE_DEND";
486 case 55:
487 return s.getLogger().debug("Lexa: -)"), this.pushState("NODE"), 36;
488 case 56:
489 return s.getLogger().debug("Lexa: (-"), this.pushState("NODE"), 36;
490 case 57:
491 return s.getLogger().debug("Lexa: ))"), this.pushState("NODE"), 36;
492 case 58:
493 return s.getLogger().debug("Lexa: )"), this.pushState("NODE"), 36;
494 case 59:
495 return s.getLogger().debug("Lex: ((("), this.pushState("NODE"), 36;
496 case 60:
497 return s.getLogger().debug("Lexa: )"), this.pushState("NODE"), 36;
498 case 61:
499 return s.getLogger().debug("Lexa: )"), this.pushState("NODE"), 36;
500 case 62:
501 return s.getLogger().debug("Lexa: )"), this.pushState("NODE"), 36;
502 case 63:
503 return s.getLogger().debug("Lexc: >"), this.pushState("NODE"), 36;
504 case 64:
505 return s.getLogger().debug("Lexa: (["), this.pushState("NODE"), 36;
506 case 65:
507 return s.getLogger().debug("Lexa: )"), this.pushState("NODE"), 36;
508 case 66:
509 return this.pushState("NODE"), 36;
510 case 67:
511 return this.pushState("NODE"), 36;
512 case 68:
513 return this.pushState("NODE"), 36;
514 case 69:
515 return this.pushState("NODE"), 36;
516 case 70:
517 return this.pushState("NODE"), 36;
518 case 71:
519 return this.pushState("NODE"), 36;
520 case 72:
521 return this.pushState("NODE"), 36;
522 case 73:
523 return s.getLogger().debug("Lexa: ["), this.pushState("NODE"), 36;
524 case 74:
525 return this.pushState("BLOCK_ARROW"), s.getLogger().debug("LEX ARR START"), 38;
526 case 75:
527 return s.getLogger().debug("Lex: NODE_ID", r.yytext), 32;
528 case 76:
529 return s.getLogger().debug("Lex: EOF", r.yytext), 8;
530 case 77:
531 this.pushState("md_string");
532 break;
533 case 78:
534 this.pushState("md_string");
535 break;
536 case 79:
537 return "NODE_DESCR";
538 case 80:
539 this.popState();
540 break;
541 case 81:
542 s.getLogger().debug("Lex: Starting string"), this.pushState("string");
543 break;
544 case 82:
545 s.getLogger().debug("LEX ARR: Starting string"), this.pushState("string");
546 break;
547 case 83:
548 return s.getLogger().debug("LEX: NODE_DESCR:", r.yytext), "NODE_DESCR";
549 case 84:
550 s.getLogger().debug("LEX POPPING"), this.popState();
551 break;
552 case 85:
553 s.getLogger().debug("Lex: =>BAE"), this.pushState("ARROW_DIR");
554 break;
555 case 86:
556 return r.yytext = r.yytext.replace(/^,\s*/, ""), s.getLogger().debug("Lex (right): dir:", r.yytext), "DIR";
557 case 87:
558 return r.yytext = r.yytext.replace(/^,\s*/, ""), s.getLogger().debug("Lex (left):", r.yytext), "DIR";
559 case 88:
560 return r.yytext = r.yytext.replace(/^,\s*/, ""), s.getLogger().debug("Lex (x):", r.yytext), "DIR";
561 case 89:
562 return r.yytext = r.yytext.replace(/^,\s*/, ""), s.getLogger().debug("Lex (y):", r.yytext), "DIR";
563 case 90:
564 return r.yytext = r.yytext.replace(/^,\s*/, ""), s.getLogger().debug("Lex (up):", r.yytext), "DIR";
565 case 91:
566 return r.yytext = r.yytext.replace(/^,\s*/, ""), s.getLogger().debug("Lex (down):", r.yytext), "DIR";
567 case 92:
568 return r.yytext = "]>", s.getLogger().debug("Lex (ARROW_DIR end):", r.yytext), this.popState(), this.popState(), "BLOCK_ARROW_END";
569 case 93:
570 return s.getLogger().debug("Lex: LINK", "#" + r.yytext + "#"), 15;
571 case 94:
572 return s.getLogger().debug("Lex: LINK", r.yytext), 15;
573 case 95:
574 return s.getLogger().debug("Lex: LINK", r.yytext), 15;
575 case 96:
576 return s.getLogger().debug("Lex: LINK", r.yytext), 15;
577 case 97:
578 return s.getLogger().debug("Lex: START_LINK", r.yytext), this.pushState("LLABEL"), 16;
579 case 98:
580 return s.getLogger().debug("Lex: START_LINK", r.yytext), this.pushState("LLABEL"), 16;
581 case 99:
582 return s.getLogger().debug("Lex: START_LINK", r.yytext), this.pushState("LLABEL"), 16;
583 case 100:
584 this.pushState("md_string");
585 break;
586 case 101:
587 return s.getLogger().debug("Lex: Starting string"), this.pushState("string"), "LINK_LABEL";
588 case 102:
589 return this.popState(), s.getLogger().debug("Lex: LINK", "#" + r.yytext + "#"), 15;
590 case 103:
591 return this.popState(), s.getLogger().debug("Lex: LINK", r.yytext), 15;
592 case 104:
593 return this.popState(), s.getLogger().debug("Lex: LINK", r.yytext), 15;
594 case 105:
595 return s.getLogger().debug("Lex: COLON", r.yytext), r.yytext = r.yytext.slice(1), 27;
596 }
597 },
598 rules: [/^(?:block-beta\b)/, /^(?:block\s+)/, /^(?:block\n+)/, /^(?:block:)/, /^(?:[\s]+)/, /^(?:[\n]+)/, /^(?:((\u000D\u000A)|(\u000A)))/, /^(?:columns\s+auto\b)/, /^(?:columns\s+[\d]+)/, /^(?:["][`])/, /^(?:[^`"]+)/, /^(?:[`]["])/, /^(?:["])/, /^(?:["])/, /^(?:[^"]*)/, /^(?:space[:]\d+)/, /^(?:space\b)/, /^(?:default\b)/, /^(?:linkStyle\b)/, /^(?:interpolate\b)/, /^(?:classDef\s+)/, /^(?:DEFAULT\s+)/, /^(?:\w+\s+)/, /^(?:[^\n]*)/, /^(?:class\s+)/, /^(?:(\w+)+((,\s*\w+)*))/, /^(?:[^\n]*)/, /^(?:style\s+)/, /^(?:(\w+)+((,\s*\w+)*))/, /^(?:[^\n]*)/, /^(?:accTitle\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*\{\s*)/, /^(?:[\}])/, /^(?:[^\}]*)/, /^(?:end\b\s*)/, /^(?:\(\(\()/, /^(?:\)\)\))/, /^(?:[\)]\))/, /^(?:\}\})/, /^(?:\})/, /^(?:\(-)/, /^(?:-\))/, /^(?:\(\()/, /^(?:\]\])/, /^(?:\()/, /^(?:\]\))/, /^(?:\\\])/, /^(?:\/\])/, /^(?:\)\])/, /^(?:[\)])/, /^(?:\]>)/, /^(?:[\]])/, /^(?:-\))/, /^(?:\(-)/, /^(?:\)\))/, /^(?:\))/, /^(?:\(\(\()/, /^(?:\(\()/, /^(?:\{\{)/, /^(?:\{)/, /^(?:>)/, /^(?:\(\[)/, /^(?:\()/, /^(?:\[\[)/, /^(?:\[\|)/, /^(?:\[\()/, /^(?:\)\)\))/, /^(?:\[\\)/, /^(?:\[\/)/, /^(?:\[\\)/, /^(?:\[)/, /^(?:<\[)/, /^(?:[^\(\[\n\-\)\{\}\s\<\>:]+)/, /^(?:$)/, /^(?:["][`])/, /^(?:["][`])/, /^(?:[^`"]+)/, /^(?:[`]["])/, /^(?:["])/, /^(?:["])/, /^(?:[^"]+)/, /^(?:["])/, /^(?:\]>\s*\()/, /^(?:,?\s*right\s*)/, /^(?:,?\s*left\s*)/, /^(?:,?\s*x\s*)/, /^(?:,?\s*y\s*)/, /^(?:,?\s*up\s*)/, /^(?:,?\s*down\s*)/, /^(?:\)\s*)/, /^(?:\s*[xo<]?--+[-xo>]\s*)/, /^(?:\s*[xo<]?==+[=xo>]\s*)/, /^(?:\s*[xo<]?-?\.+-[xo>]?\s*)/, /^(?:\s*~~[\~]+\s*)/, /^(?:\s*[xo<]?--\s*)/, /^(?:\s*[xo<]?==\s*)/, /^(?:\s*[xo<]?-\.\s*)/, /^(?:["][`])/, /^(?:["])/, /^(?:\s*[xo<]?--+[-xo>]\s*)/, /^(?:\s*[xo<]?==+[=xo>]\s*)/, /^(?:\s*[xo<]?-?\.+-[xo>]?\s*)/, /^(?::\d+)/],
599 conditions: { STYLE_DEFINITION: { rules: [29], inclusive: !1 }, STYLE_STMNT: { rules: [28], inclusive: !1 }, CLASSDEFID: { rules: [23], inclusive: !1 }, CLASSDEF: { rules: [21, 22], inclusive: !1 }, CLASS_STYLE: { rules: [26], inclusive: !1 }, CLASS: { rules: [25], inclusive: !1 }, LLABEL: { rules: [100, 101, 102, 103, 104], inclusive: !1 }, ARROW_DIR: { rules: [86, 87, 88, 89, 90, 91, 92], inclusive: !1 }, BLOCK_ARROW: { rules: [77, 82, 85], inclusive: !1 }, NODE: { rules: [38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 78, 81], inclusive: !1 }, md_string: { rules: [10, 11, 79, 80], inclusive: !1 }, space: { rules: [], inclusive: !1 }, string: { rules: [13, 14, 83, 84], inclusive: !1 }, acc_descr_multiline: { rules: [35, 36], inclusive: !1 }, acc_descr: { rules: [33], inclusive: !1 }, acc_title: { rules: [31], inclusive: !1 }, INITIAL: { rules: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 15, 16, 17, 18, 19, 20, 24, 27, 30, 32, 34, 37, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 93, 94, 95, 96, 97, 98, 99, 105], inclusive: !0 } }
600 };
601 return D;
602 }();
603 E.lexer = v;
604 function N() {
605 this.yy = {};
606 }
607 return N.prototype = E, E.Parser = N, new N();
608}();
609ee.parser = ee;
610const Pe = ee;
611let T = {}, ie = [], V = {};
612const oe = "color", ce = "fill", Fe = "bgFill", pe = ",", Ke = ge();
613let j = {};
614const Me = (e) => _e.sanitizeText(e, Ke), Ye = function(e, c = "") {
615 j[e] === void 0 && (j[e] = { id: e, styles: [], textStyles: [] });
616 const u = j[e];
617 c != null && c.split(pe).forEach((a) => {
618 const i = a.replace(/([^;]*);/, "$1").trim();
619 if (a.match(oe)) {
620 const o = i.replace(ce, Fe).replace(oe, ce);
621 u.textStyles.push(o);
622 }
623 u.styles.push(i);
624 });
625}, We = function(e, c = "") {
626 const u = T[e];
627 c != null && (u.styles = c.split(pe));
628}, Ve = function(e, c) {
629 e.split(",").forEach(function(u) {
630 let a = T[u];
631 if (a === void 0) {
632 const i = u.trim();
633 T[i] = { id: i, type: "na", children: [] }, a = T[i];
634 }
635 a.classes || (a.classes = []), a.classes.push(c);
636 });
637}, fe = (e, c) => {
638 const u = e.flat(), a = [];
639 for (const i of u) {
640 if (i.label && (i.label = Me(i.label)), i.type === "classDef") {
641 Ye(i.id, i.css);
642 continue;
643 }
644 if (i.type === "applyClass") {
645 Ve(i.id, (i == null ? void 0 : i.styleClass) || "");
646 continue;
647 }
648 if (i.type === "applyStyles") {
649 i != null && i.stylesStr && We(i.id, i == null ? void 0 : i.stylesStr);
650 continue;
651 }
652 if (i.type === "column-setting")
653 c.columns = i.columns || -1;
654 else if (i.type === "edge")
655 V[i.id] ? V[i.id]++ : V[i.id] = 1, i.id = V[i.id] + "-" + i.id, ie.push(i);
656 else {
657 i.label || (i.type === "composite" ? i.label = "" : i.label = i.id);
658 const g = !T[i.id];
659 if (g ? T[i.id] = i : (i.type !== "na" && (T[i.id].type = i.type), i.label !== i.id && (T[i.id].label = i.label)), i.children && fe(i.children, i), i.type === "space") {
660 const o = i.width || 1;
661 for (let p = 0; p < o; p++) {
662 const f = Ie(i);
663 f.id = f.id + "-" + p, T[f.id] = f, a.push(f);
664 }
665 } else
666 g && a.push(i);
667 }
668 }
669 c.children = a;
670};
671let re = [], U = { id: "root", type: "composite", children: [], columns: -1 };
672const je = () => {
673 L.debug("Clear called"), ye(), U = { id: "root", type: "composite", children: [], columns: -1 }, T = { root: U }, re = [], j = {}, ie = [], V = {};
674};
675function Ue(e) {
676 switch (L.debug("typeStr2Type", e), e) {
677 case "[]":
678 return "square";
679 case "()":
680 return L.debug("we have a round"), "round";
681 case "(())":
682 return "circle";
683 case ">]":
684 return "rect_left_inv_arrow";
685 case "{}":
686 return "diamond";
687 case "{{}}":
688 return "hexagon";
689 case "([])":
690 return "stadium";
691 case "[[]]":
692 return "subroutine";
693 case "[()]":
694 return "cylinder";
695 case "((()))":
696 return "doublecircle";
697 case "[//]":
698 return "lean_right";
699 case "[\\\\]":
700 return "lean_left";
701 case "[/\\]":
702 return "trapezoid";
703 case "[\\/]":
704 return "inv_trapezoid";
705 case "<[]>":
706 return "block_arrow";
707 default:
708 return "na";
709 }
710}
711function Xe(e) {
712 switch (L.debug("typeStr2Type", e), e) {
713 case "==":
714 return "thick";
715 default:
716 return "normal";
717 }
718}
719function Ge(e) {
720 switch (e.trim()) {
721 case "--x":
722 return "arrow_cross";
723 case "--o":
724 return "arrow_circle";
725 default:
726 return "arrow_point";
727 }
728}
729let le = 0;
730const He = () => (le++, "id-" + Math.random().toString(36).substr(2, 12) + "-" + le), qe = (e) => {
731 U.children = e, fe(e, U), re = U.children;
732}, Ze = (e) => {
733 const c = T[e];
734 return c ? c.columns ? c.columns : c.children ? c.children.length : -1 : -1;
735}, Je = () => [...Object.values(T)], Qe = () => re || [], $e = () => ie, et = (e) => T[e], tt = (e) => {
736 T[e.id] = e;
737}, st = () => console, it = function() {
738 return j;
739}, rt = {
740 getConfig: () => se().block,
741 typeStr2Type: Ue,
742 edgeTypeStr2Type: Xe,
743 edgeStrToEdgeData: Ge,
744 getLogger: st,
745 getBlocksFlat: Je,
746 getBlocks: Qe,
747 getEdges: $e,
748 setHierarchy: qe,
749 getBlock: et,
750 setBlock: tt,
751 getColumns: Ze,
752 getClasses: it,
753 clear: je,
754 generateId: He
755}, nt = rt, q = (e, c) => {
756 const u = Oe, a = u(e, "r"), i = u(e, "g"), g = u(e, "b");
757 return we(a, i, g, c);
758}, at = (e) => `.label {
759 font-family: ${e.fontFamily};
760 color: ${e.nodeTextColor || e.textColor};
761 }
762 .cluster-label text {
763 fill: ${e.titleColor};
764 }
765 .cluster-label span,p {
766 color: ${e.titleColor};
767 }
768
769
770
771 .label text,span,p {
772 fill: ${e.nodeTextColor || e.textColor};
773 color: ${e.nodeTextColor || e.textColor};
774 }
775
776 .node rect,
777 .node circle,
778 .node ellipse,
779 .node polygon,
780 .node path {
781 fill: ${e.mainBkg};
782 stroke: ${e.nodeBorder};
783 stroke-width: 1px;
784 }
785 .flowchart-label text {
786 text-anchor: middle;
787 }
788 // .flowchart-label .text-outer-tspan {
789 // text-anchor: middle;
790 // }
791 // .flowchart-label .text-inner-tspan {
792 // text-anchor: start;
793 // }
794
795 .node .label {
796 text-align: center;
797 }
798 .node.clickable {
799 cursor: pointer;
800 }
801
802 .arrowheadPath {
803 fill: ${e.arrowheadColor};
804 }
805
806 .edgePath .path {
807 stroke: ${e.lineColor};
808 stroke-width: 2.0px;
809 }
810
811 .flowchart-link {
812 stroke: ${e.lineColor};
813 fill: none;
814 }
815
816 .edgeLabel {
817 background-color: ${e.edgeLabelBackground};
818 rect {
819 opacity: 0.5;
820 background-color: ${e.edgeLabelBackground};
821 fill: ${e.edgeLabelBackground};
822 }
823 text-align: center;
824 }
825
826 /* For html labels only */
827 .labelBkg {
828 background-color: ${q(e.edgeLabelBackground, 0.5)};
829 // background-color:
830 }
831
832 .node .cluster {
833 // fill: ${q(e.mainBkg, 0.5)};
834 fill: ${q(e.clusterBkg, 0.5)};
835 stroke: ${q(e.clusterBorder, 0.2)};
836 box-shadow: rgba(50, 50, 93, 0.25) 0px 13px 27px -5px, rgba(0, 0, 0, 0.3) 0px 8px 16px -8px;
837 stroke-width: 1px;
838 }
839
840 .cluster text {
841 fill: ${e.titleColor};
842 }
843
844 .cluster span,p {
845 color: ${e.titleColor};
846 }
847 /* .cluster div {
848 color: ${e.titleColor};
849 } */
850
851 div.mermaidTooltip {
852 position: absolute;
853 text-align: center;
854 max-width: 200px;
855 padding: 2px;
856 font-family: ${e.fontFamily};
857 font-size: 12px;
858 background: ${e.tertiaryColor};
859 border: 1px solid ${e.border2};
860 border-radius: 2px;
861 pointer-events: none;
862 z-index: 100;
863 }
864
865 .flowchartTitleText {
866 text-anchor: middle;
867 font-size: 18px;
868 fill: ${e.textColor};
869 }
870`, ot = at;
871function Se(e, c, u = !1) {
872 var z, I, w;
873 const a = e;
874 let i = "default";
875 (((z = a == null ? void 0 : a.classes) == null ? void 0 : z.length) || 0) > 0 && (i = ((a == null ? void 0 : a.classes) || []).join(" ")), i = i + " flowchart-label";
876 let g = 0, o = "", p;
877 switch (a.type) {
878 case "round":
879 g = 5, o = "rect";
880 break;
881 case "composite":
882 g = 0, o = "composite", p = 0;
883 break;
884 case "square":
885 o = "rect";
886 break;
887 case "diamond":
888 o = "question";
889 break;
890 case "hexagon":
891 o = "hexagon";
892 break;
893 case "block_arrow":
894 o = "block_arrow";
895 break;
896 case "odd":
897 o = "rect_left_inv_arrow";
898 break;
899 case "lean_right":
900 o = "lean_right";
901 break;
902 case "lean_left":
903 o = "lean_left";
904 break;
905 case "trapezoid":
906 o = "trapezoid";
907 break;
908 case "inv_trapezoid":
909 o = "inv_trapezoid";
910 break;
911 case "rect_left_inv_arrow":
912 o = "rect_left_inv_arrow";
913 break;
914 case "circle":
915 o = "circle";
916 break;
917 case "ellipse":
918 o = "ellipse";
919 break;
920 case "stadium":
921 o = "stadium";
922 break;
923 case "subroutine":
924 o = "subroutine";
925 break;
926 case "cylinder":
927 o = "cylinder";
928 break;
929 case "group":
930 o = "rect";
931 break;
932 case "doublecircle":
933 o = "doublecircle";
934 break;
935 default:
936 o = "rect";
937 }
938 const f = De((a == null ? void 0 : a.styles) || []), m = a.label, S = a.size || { width: 0, height: 0, x: 0, y: 0 };
939 return {
940 labelStyle: f.labelStyle,
941 shape: o,
942 labelText: m,
943 rx: g,
944 ry: g,
945 class: i,
946 style: f.style,
947 id: a.id,
948 directions: a.directions,
949 width: S.width,
950 height: S.height,
951 x: S.x,
952 y: S.y,
953 positioned: u,
954 intersect: void 0,
955 type: a.type,
956 padding: p ?? (((w = (I = se()) == null ? void 0 : I.block) == null ? void 0 : w.padding) || 0)
957 };
958}
959async function ct(e, c, u) {
960 const a = Se(c, u, !1);
961 if (a.type === "group")
962 return;
963 const i = await de(e, a), g = i.node().getBBox(), o = u.getBlock(a.id);
964 o.size = { width: g.width, height: g.height, x: 0, y: 0, node: i }, u.setBlock(o), i.remove();
965}
966async function lt(e, c, u) {
967 const a = Se(c, u, !0);
968 u.getBlock(a.id).type !== "space" && (await de(e, a), c.intersect = a == null ? void 0 : a.intersect, Ae(a));
969}
970async function ne(e, c, u, a) {
971 for (const i of c)
972 await a(e, i, u), i.children && await ne(e, i.children, u, a);
973}
974async function ht(e, c, u) {
975 await ne(e, c, u, ct);
976}
977async function ut(e, c, u) {
978 await ne(e, c, u, lt);
979}
980async function gt(e, c, u, a, i) {
981 const g = new ve({
982 multigraph: !0,
983 compound: !0
984 });
985 g.setGraph({
986 rankdir: "TB",
987 nodesep: 10,
988 ranksep: 10,
989 marginx: 8,
990 marginy: 8
991 });
992 for (const o of u)
993 o.size && g.setNode(o.id, {
994 width: o.size.width,
995 height: o.size.height,
996 intersect: o.intersect
997 });
998 for (const o of c)
999 if (o.start && o.end) {
1000 const p = a.getBlock(o.start), f = a.getBlock(o.end);
1001 if (p != null && p.size && (f != null && f.size)) {
1002 const m = p.size, S = f.size, y = [
1003 { x: m.x, y: m.y },
1004 { x: m.x + (S.x - m.x) / 2, y: m.y + (S.y - m.y) / 2 },
1005 { x: S.x, y: S.y }
1006 ];
1007 await Te(
1008 e,
1009 { v: o.start, w: o.end, name: o.id },
1010 {
1011 ...o,
1012 arrowTypeEnd: o.arrowTypeEnd,
1013 arrowTypeStart: o.arrowTypeStart,
1014 points: y,
1015 classes: "edge-thickness-normal edge-pattern-solid flowchart-link LS-a1 LE-b1"
1016 },
1017 void 0,
1018 "block",
1019 g,
1020 i
1021 ), o.label && (await ze(e, {
1022 ...o,
1023 label: o.label,
1024 labelStyle: "stroke: #333; stroke-width: 1.5px;fill:none;",
1025 arrowTypeEnd: o.arrowTypeEnd,
1026 arrowTypeStart: o.arrowTypeStart,
1027 points: y,
1028 classes: "edge-thickness-normal edge-pattern-solid flowchart-link LS-a1 LE-b1"
1029 }), await Ce(
1030 { ...o, x: y[1].x, y: y[1].y },
1031 {
1032 originalPath: y
1033 }
1034 ));
1035 }
1036 }
1037}
1038var he, ue;
1039const b = ((ue = (he = ge()) == null ? void 0 : he.block) == null ? void 0 : ue.padding) || 8;
1040function dt(e, c) {
1041 if (e === 0 || !Number.isInteger(e))
1042 throw new Error("Columns must be an integer !== 0.");
1043 if (c < 0 || !Number.isInteger(c))
1044 throw new Error("Position must be a non-negative integer." + c);
1045 if (e < 0)
1046 return { px: c, py: 0 };
1047 if (e === 1)
1048 return { px: 0, py: c };
1049 const u = c % e, a = Math.floor(c / e);
1050 return { px: u, py: a };
1051}
1052const pt = (e) => {
1053 let c = 0, u = 0;
1054 for (const a of e.children) {
1055 const { width: i, height: g, x: o, y: p } = a.size || { width: 0, height: 0, x: 0, y: 0 };
1056 L.debug(
1057 "getMaxChildSize abc95 child:",
1058 a.id,
1059 "width:",
1060 i,
1061 "height:",
1062 g,
1063 "x:",
1064 o,
1065 "y:",
1066 p,
1067 a.type
1068 ), a.type !== "space" && (i > c && (c = i / (e.widthInColumns || 1)), g > u && (u = g));
1069 }
1070 return { width: c, height: u };
1071};
1072function te(e, c, u = 0, a = 0) {
1073 var o, p, f, m, S, y, z, I, w, C, E;
1074 L.debug(
1075 "setBlockSizes abc95 (start)",
1076 e.id,
1077 (o = e == null ? void 0 : e.size) == null ? void 0 : o.x,
1078 "block width =",
1079 e == null ? void 0 : e.size,
1080 "sieblingWidth",
1081 u
1082 ), (p = e == null ? void 0 : e.size) != null && p.width || (e.size = {
1083 width: u,
1084 height: a,
1085 x: 0,
1086 y: 0
1087 });
1088 let i = 0, g = 0;
1089 if (((f = e.children) == null ? void 0 : f.length) > 0) {
1090 for (const d of e.children)
1091 te(d, c);
1092 const v = pt(e);
1093 i = v.width, g = v.height, L.debug("setBlockSizes abc95 maxWidth of", e.id, ":s children is ", i, g);
1094 for (const d of e.children)
1095 d.size && (L.debug(
1096 `abc95 Setting size of children of ${e.id} id=${d.id} ${i} ${g} ${d.size}`
1097 ), d.size.width = i * (d.widthInColumns || 1) + b * ((d.widthInColumns || 1) - 1), d.size.height = g, d.size.x = 0, d.size.y = 0, L.debug(
1098 `abc95 updating size of ${e.id} children child:${d.id} maxWidth:${i} maxHeight:${g}`
1099 ));
1100 for (const d of e.children)
1101 te(d, c, i, g);
1102 const N = e.columns || -1;
1103 let D = 0;
1104 for (const d of e.children)
1105 D += d.widthInColumns || 1;
1106 let l = e.children.length;
1107 N > 0 && N < D && (l = N), e.widthInColumns;
1108 const s = Math.ceil(D / l);
1109 let r = l * (i + b) + b, h = s * (g + b) + b;
1110 if (r < u) {
1111 L.debug(
1112 `Detected to small siebling: abc95 ${e.id} sieblingWidth ${u} sieblingHeight ${a} width ${r}`
1113 ), r = u, h = a;
1114 const d = (u - l * b - b) / l, t = (a - s * b - b) / s;
1115 L.debug("Size indata abc88", e.id, "childWidth", d, "maxWidth", i), L.debug("Size indata abc88", e.id, "childHeight", t, "maxHeight", g), L.debug("Size indata abc88 xSize", l, "padding", b);
1116 for (const x of e.children)
1117 x.size && (x.size.width = d, x.size.height = t, x.size.x = 0, x.size.y = 0);
1118 }
1119 if (L.debug(
1120 `abc95 (finale calc) ${e.id} xSize ${l} ySize ${s} columns ${N}${e.children.length} width=${Math.max(r, ((m = e.size) == null ? void 0 : m.width) || 0)}`
1121 ), r < (((S = e == null ? void 0 : e.size) == null ? void 0 : S.width) || 0)) {
1122 r = ((y = e == null ? void 0 : e.size) == null ? void 0 : y.width) || 0;
1123 const d = N > 0 ? Math.min(e.children.length, N) : e.children.length;
1124 if (d > 0) {
1125 const t = (r - d * b - b) / d;
1126 L.debug("abc95 (growing to fit) width", e.id, r, (z = e.size) == null ? void 0 : z.width, t);
1127 for (const x of e.children)
1128 x.size && (x.size.width = t);
1129 }
1130 }
1131 e.size = {
1132 width: r,
1133 height: h,
1134 x: 0,
1135 y: 0
1136 };
1137 }
1138 L.debug(
1139 "setBlockSizes abc94 (done)",
1140 e.id,
1141 (I = e == null ? void 0 : e.size) == null ? void 0 : I.x,
1142 (w = e == null ? void 0 : e.size) == null ? void 0 : w.width,
1143 (C = e == null ? void 0 : e.size) == null ? void 0 : C.y,
1144 (E = e == null ? void 0 : e.size) == null ? void 0 : E.height
1145 );
1146}
1147function Le(e, c) {
1148 var a, i, g, o, p, f, m, S, y, z, I, w, C, E, v, N, D;
1149 L.debug(
1150 `abc85 layout blocks (=>layoutBlocks) ${e.id} x: ${(a = e == null ? void 0 : e.size) == null ? void 0 : a.x} y: ${(i = e == null ? void 0 : e.size) == null ? void 0 : i.y} width: ${(g = e == null ? void 0 : e.size) == null ? void 0 : g.width}`
1151 );
1152 const u = e.columns || -1;
1153 if (L.debug("layoutBlocks columns abc95", e.id, "=>", u, e), e.children && // find max width of children
1154 e.children.length > 0) {
1155 const l = ((p = (o = e == null ? void 0 : e.children[0]) == null ? void 0 : o.size) == null ? void 0 : p.width) || 0, s = e.children.length * l + (e.children.length - 1) * b;
1156 L.debug("widthOfChildren 88", s, "posX");
1157 let r = 0;
1158 L.debug("abc91 block?.size?.x", e.id, (f = e == null ? void 0 : e.size) == null ? void 0 : f.x);
1159 let h = (m = e == null ? void 0 : e.size) != null && m.x ? ((S = e == null ? void 0 : e.size) == null ? void 0 : S.x) + (-((y = e == null ? void 0 : e.size) == null ? void 0 : y.width) / 2 || 0) : -b, d = 0;
1160 for (const t of e.children) {
1161 const x = e;
1162 if (!t.size)
1163 continue;
1164 const { width: n, height: B } = t.size, { px: Y, py: F } = dt(u, r);
1165 if (F != d && (d = F, h = (z = e == null ? void 0 : e.size) != null && z.x ? ((I = e == null ? void 0 : e.size) == null ? void 0 : I.x) + (-((w = e == null ? void 0 : e.size) == null ? void 0 : w.width) / 2 || 0) : -b, L.debug("New row in layout for block", e.id, " and child ", t.id, d)), L.debug(
1166 `abc89 layout blocks (child) id: ${t.id} Pos: ${r} (px, py) ${Y},${F} (${(C = x == null ? void 0 : x.size) == null ? void 0 : C.x},${(E = x == null ? void 0 : x.size) == null ? void 0 : E.y}) parent: ${x.id} width: ${n}${b}`
1167 ), x.size) {
1168 const R = n / 2;
1169 t.size.x = h + b + R, L.debug(
1170 `abc91 layout blocks (calc) px, pyid:${t.id} startingPos=X${h} new startingPosX${t.size.x} ${R} padding=${b} width=${n} halfWidth=${R} => x:${t.size.x} y:${t.size.y} ${t.widthInColumns} (width * (child?.w || 1)) / 2 ${n * ((t == null ? void 0 : t.widthInColumns) || 1) / 2}`
1171 ), h = t.size.x + R, t.size.y = x.size.y - x.size.height / 2 + F * (B + b) + B / 2 + b, L.debug(
1172 `abc88 layout blocks (calc) px, pyid:${t.id}startingPosX${h}${b}${R}=>x:${t.size.x}y:${t.size.y}${t.widthInColumns}(width * (child?.w || 1)) / 2${n * ((t == null ? void 0 : t.widthInColumns) || 1) / 2}`
1173 );
1174 }
1175 t.children && Le(t), r += (t == null ? void 0 : t.widthInColumns) || 1, L.debug("abc88 columnsPos", t, r);
1176 }
1177 }
1178 L.debug(
1179 `layout blocks (<==layoutBlocks) ${e.id} x: ${(v = e == null ? void 0 : e.size) == null ? void 0 : v.x} y: ${(N = e == null ? void 0 : e.size) == null ? void 0 : N.y} width: ${(D = e == null ? void 0 : e.size) == null ? void 0 : D.width}`
1180 );
1181}
1182function xe(e, { minX: c, minY: u, maxX: a, maxY: i } = { minX: 0, minY: 0, maxX: 0, maxY: 0 }) {
1183 if (e.size && e.id !== "root") {
1184 const { x: g, y: o, width: p, height: f } = e.size;
1185 g - p / 2 < c && (c = g - p / 2), o - f / 2 < u && (u = o - f / 2), g + p / 2 > a && (a = g + p / 2), o + f / 2 > i && (i = o + f / 2);
1186 }
1187 if (e.children)
1188 for (const g of e.children)
1189 ({ minX: c, minY: u, maxX: a, maxY: i } = xe(g, { minX: c, minY: u, maxX: a, maxY: i }));
1190 return { minX: c, minY: u, maxX: a, maxY: i };
1191}
1192function ft(e) {
1193 const c = e.getBlock("root");
1194 if (!c)
1195 return;
1196 te(c, e, 0, 0), Le(c), L.debug("getBlocks", JSON.stringify(c, null, 2));
1197 const { minX: u, minY: a, maxX: i, maxY: g } = xe(c), o = g - a, p = i - u;
1198 return { x: u, y: a, width: p, height: o };
1199}
1200const St = function(e, c) {
1201 return c.db.getClasses();
1202}, Lt = async function(e, c, u, a) {
1203 const { securityLevel: i, block: g } = se(), o = a.db;
1204 let p;
1205 i === "sandbox" && (p = H("#i" + c));
1206 const f = i === "sandbox" ? H(p.nodes()[0].contentDocument.body) : H("body"), m = i === "sandbox" ? f.select(`[id="${c}"]`) : H(`[id="${c}"]`);
1207 Re(m, ["point", "circle", "cross"], a.type, c);
1208 const y = o.getBlocks(), z = o.getBlocksFlat(), I = o.getEdges(), w = m.insert("g").attr("class", "block");
1209 await ht(w, y, o);
1210 const C = ft(o);
1211 if (await ut(w, y, o), await gt(w, I, z, o, c), C) {
1212 const E = C, v = Math.max(1, Math.round(0.125 * (E.width / E.height))), N = E.height + v + 10, D = E.width + 10, { useMaxWidth: l } = g;
1213 Ne(m, N, D, !!l), L.debug("Here Bounds", C, E), m.attr(
1214 "viewBox",
1215 `${E.x - 5} ${E.y - 5} ${E.width + 10} ${E.height + 10}`
1216 );
1217 }
1218 Be(ke);
1219}, xt = {
1220 draw: Lt,
1221 getClasses: St
1222}, Ct = {
1223 parser: Pe,
1224 db: nt,
1225 renderer: xt,
1226 styles: ot
1227};
1228export {
1229 Ct as diagram
1230};