1 | var _a, _b;
|
2 | import { c as getConfig, F as getConfig$1, l as log, v as clear$1, e as common, k as getStylesFromArray, i as configureSvgSize } from "./mermaid-6dc72991.js";
|
3 | import clone from "lodash-es/clone.js";
|
4 | import * as khroma from "khroma";
|
5 | import { h as insertEdge, f as insertEdgeLabel, j as positionEdgeLabel, e as insertNode, p as positionNode, a as insertMarkers } from "./edges-066a5561.js";
|
6 | import * as graphlib from "dagre-d3-es/src/graphlib/index.js";
|
7 | import { select, scaleOrdinal, schemeTableau10 } from "d3";
|
8 | import "ts-dedent";
|
9 | import "dayjs";
|
10 | import "@braintree/sanitize-url";
|
11 | import "dompurify";
|
12 | import "lodash-es/memoize.js";
|
13 | import "lodash-es/merge.js";
|
14 | import "stylis";
|
15 | import "lodash-es/isEmpty.js";
|
16 | import "./createText-ca0c5216.js";
|
17 | import "mdast-util-from-markdown";
|
18 | var parser = function() {
|
19 | var o = function(k, v, o2, l) {
|
20 | for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v)
|
21 | ;
|
22 | return o2;
|
23 | }, $V0 = [1, 7], $V1 = [1, 13], $V2 = [1, 14], $V3 = [1, 15], $V4 = [1, 19], $V5 = [1, 16], $V6 = [1, 17], $V7 = [1, 18], $V8 = [8, 30], $V9 = [8, 21, 28, 29, 30, 31, 32, 40, 44, 47], $Va = [1, 23], $Vb = [1, 24], $Vc = [8, 15, 16, 21, 28, 29, 30, 31, 32, 40, 44, 47], $Vd = [8, 15, 16, 21, 27, 28, 29, 30, 31, 32, 40, 44, 47], $Ve = [1, 49];
|
24 | var parser2 = {
|
25 | trace: function trace() {
|
26 | },
|
27 | yy: {},
|
28 | 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 },
|
29 | 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" },
|
30 | 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]],
|
31 | performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
|
32 | var $0 = $$.length - 1;
|
33 | switch (yystate) {
|
34 | case 4:
|
35 | yy.getLogger().debug("Rule: separator (NL) ");
|
36 | break;
|
37 | case 5:
|
38 | yy.getLogger().debug("Rule: separator (Space) ");
|
39 | break;
|
40 | case 6:
|
41 | yy.getLogger().debug("Rule: separator (EOF) ");
|
42 | break;
|
43 | case 7:
|
44 | yy.getLogger().debug("Rule: hierarchy: ", $$[$0 - 1]);
|
45 | yy.setHierarchy($$[$0 - 1]);
|
46 | break;
|
47 | case 8:
|
48 | yy.getLogger().debug("Stop NL ");
|
49 | break;
|
50 | case 9:
|
51 | yy.getLogger().debug("Stop EOF ");
|
52 | break;
|
53 | case 10:
|
54 | yy.getLogger().debug("Stop NL2 ");
|
55 | break;
|
56 | case 11:
|
57 | yy.getLogger().debug("Stop EOF2 ");
|
58 | break;
|
59 | case 12:
|
60 | yy.getLogger().debug("Rule: statement: ", $$[$0]);
|
61 | typeof $$[$0].length === "number" ? this.$ = $$[$0] : this.$ = [$$[$0]];
|
62 | break;
|
63 | case 13:
|
64 | yy.getLogger().debug("Rule: statement #2: ", $$[$0 - 1]);
|
65 | this.$ = [$$[$0 - 1]].concat($$[$0]);
|
66 | break;
|
67 | case 14:
|
68 | yy.getLogger().debug("Rule: link: ", $$[$0], yytext);
|
69 | this.$ = { edgeTypeStr: $$[$0], label: "" };
|
70 | break;
|
71 | case 15:
|
72 | yy.getLogger().debug("Rule: LABEL link: ", $$[$0 - 3], $$[$0 - 1], $$[$0]);
|
73 | this.$ = { edgeTypeStr: $$[$0], label: $$[$0 - 1] };
|
74 | break;
|
75 | case 18:
|
76 | const num = parseInt($$[$0]);
|
77 | const spaceId = yy.generateId();
|
78 | this.$ = { id: spaceId, type: "space", label: "", width: num, children: [] };
|
79 | break;
|
80 | case 23:
|
81 | yy.getLogger().debug("Rule: (nodeStatement link node) ", $$[$0 - 2], $$[$0 - 1], $$[$0], " typestr: ", $$[$0 - 1].edgeTypeStr);
|
82 | const edgeData = yy.edgeStrToEdgeData($$[$0 - 1].edgeTypeStr);
|
83 | this.$ = [
|
84 | { id: $$[$0 - 2].id, label: $$[$0 - 2].label, type: $$[$0 - 2].type, directions: $$[$0 - 2].directions },
|
85 | { id: $$[$0 - 2].id + "-" + $$[$0].id, start: $$[$0 - 2].id, end: $$[$0].id, label: $$[$0 - 1].label, type: "edge", directions: $$[$0].directions, arrowTypeEnd: edgeData, arrowTypeStart: "arrow_open" },
|
86 | { id: $$[$0].id, label: $$[$0].label, type: yy.typeStr2Type($$[$0].typeStr), directions: $$[$0].directions }
|
87 | ];
|
88 | break;
|
89 | case 24:
|
90 | yy.getLogger().debug("Rule: nodeStatement (abc88 node size) ", $$[$0 - 1], $$[$0]);
|
91 | this.$ = { id: $$[$0 - 1].id, label: $$[$0 - 1].label, type: yy.typeStr2Type($$[$0 - 1].typeStr), directions: $$[$0 - 1].directions, widthInColumns: parseInt($$[$0], 10) };
|
92 | break;
|
93 | case 25:
|
94 | yy.getLogger().debug("Rule: nodeStatement (node) ", $$[$0]);
|
95 | this.$ = { id: $$[$0].id, label: $$[$0].label, type: yy.typeStr2Type($$[$0].typeStr), directions: $$[$0].directions, widthInColumns: 1 };
|
96 | break;
|
97 | case 26:
|
98 | yy.getLogger().debug("APA123", this ? this : "na");
|
99 | yy.getLogger().debug("COLUMNS: ", $$[$0]);
|
100 | this.$ = { type: "column-setting", columns: $$[$0] === "auto" ? -1 : parseInt($$[$0]) };
|
101 | break;
|
102 | case 27:
|
103 | yy.getLogger().debug("Rule: id-block statement : ", $$[$0 - 2], $$[$0 - 1]);
|
104 | yy.generateId();
|
105 | this.$ = { ...$$[$0 - 2], type: "composite", children: $$[$0 - 1] };
|
106 | break;
|
107 | case 28:
|
108 | yy.getLogger().debug("Rule: blockStatement : ", $$[$0 - 2], $$[$0 - 1], $$[$0]);
|
109 | const id = yy.generateId();
|
110 | this.$ = { id, type: "composite", label: "", children: $$[$0 - 1] };
|
111 | break;
|
112 | case 29:
|
113 | yy.getLogger().debug("Rule: node (NODE_ID separator): ", $$[$0]);
|
114 | this.$ = { id: $$[$0] };
|
115 | break;
|
116 | case 30:
|
117 | yy.getLogger().debug("Rule: node (NODE_ID nodeShapeNLabel separator): ", $$[$0 - 1], $$[$0]);
|
118 | this.$ = { id: $$[$0 - 1], label: $$[$0].label, typeStr: $$[$0].typeStr, directions: $$[$0].directions };
|
119 | break;
|
120 | case 31:
|
121 | yy.getLogger().debug("Rule: dirList: ", $$[$0]);
|
122 | this.$ = [$$[$0]];
|
123 | break;
|
124 | case 32:
|
125 | yy.getLogger().debug("Rule: dirList: ", $$[$0 - 1], $$[$0]);
|
126 | this.$ = [$$[$0 - 1]].concat($$[$0]);
|
127 | break;
|
128 | case 33:
|
129 | yy.getLogger().debug("Rule: nodeShapeNLabel: ", $$[$0 - 2], $$[$0 - 1], $$[$0]);
|
130 | this.$ = { typeStr: $$[$0 - 2] + $$[$0], label: $$[$0 - 1] };
|
131 | break;
|
132 | case 34:
|
133 | yy.getLogger().debug("Rule: BLOCK_ARROW nodeShapeNLabel: ", $$[$0 - 3], $$[$0 - 2], " #3:", $$[$0 - 1], $$[$0]);
|
134 | this.$ = { typeStr: $$[$0 - 3] + $$[$0], label: $$[$0 - 2], directions: $$[$0 - 1] };
|
135 | break;
|
136 | case 35:
|
137 | case 36:
|
138 | this.$ = { type: "classDef", id: $$[$0 - 1].trim(), css: $$[$0].trim() };
|
139 | break;
|
140 | case 37:
|
141 | this.$ = { type: "applyClass", id: $$[$0 - 1].trim(), styleClass: $$[$0].trim() };
|
142 | break;
|
143 | case 38:
|
144 | this.$ = { type: "applyStyles", id: $$[$0 - 1].trim(), stylesStr: $$[$0].trim() };
|
145 | break;
|
146 | }
|
147 | },
|
148 | table: [{ 9: 1, 10: [1, 2] }, { 1: [3] }, { 11: 3, 13: 4, 19: 5, 20: 6, 21: $V0, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 28: $V1, 29: $V2, 31: $V3, 32: $V4, 40: $V5, 44: $V6, 47: $V7 }, { 8: [1, 20] }, o($V8, [2, 12], { 13: 4, 19: 5, 20: 6, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 11: 21, 21: $V0, 28: $V1, 29: $V2, 31: $V3, 32: $V4, 40: $V5, 44: $V6, 47: $V7 }), o($V9, [2, 16], { 14: 22, 15: $Va, 16: $Vb }), o($V9, [2, 17]), o($V9, [2, 18]), o($V9, [2, 19]), o($V9, [2, 20]), o($V9, [2, 21]), o($V9, [2, 22]), o($Vc, [2, 25], { 27: [1, 25] }), o($V9, [2, 26]), { 19: 26, 26: 12, 32: $V4 }, { 11: 27, 13: 4, 19: 5, 20: 6, 21: $V0, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 28: $V1, 29: $V2, 31: $V3, 32: $V4, 40: $V5, 44: $V6, 47: $V7 }, { 41: [1, 28], 43: [1, 29] }, { 45: [1, 30] }, { 48: [1, 31] }, o($Vd, [2, 29], { 33: 32, 36: [1, 33], 38: [1, 34] }), { 1: [2, 7] }, o($V8, [2, 13]), { 26: 35, 32: $V4 }, { 32: [2, 14] }, { 17: [1, 36] }, o($Vc, [2, 24]), { 11: 37, 13: 4, 14: 22, 15: $Va, 16: $Vb, 19: 5, 20: 6, 21: $V0, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 28: $V1, 29: $V2, 31: $V3, 32: $V4, 40: $V5, 44: $V6, 47: $V7 }, { 30: [1, 38] }, { 42: [1, 39] }, { 42: [1, 40] }, { 46: [1, 41] }, { 49: [1, 42] }, o($Vd, [2, 30]), { 18: [1, 43] }, { 18: [1, 44] }, o($Vc, [2, 23]), { 18: [1, 45] }, { 30: [1, 46] }, o($V9, [2, 28]), o($V9, [2, 35]), o($V9, [2, 36]), o($V9, [2, 37]), o($V9, [2, 38]), { 37: [1, 47] }, { 34: 48, 35: $Ve }, { 15: [1, 50] }, o($V9, [2, 27]), o($Vd, [2, 33]), { 39: [1, 51] }, { 34: 52, 35: $Ve, 39: [2, 31] }, { 32: [2, 15] }, o($Vd, [2, 34]), { 39: [2, 32] }],
|
149 | defaultActions: { 20: [2, 7], 23: [2, 14], 50: [2, 15], 52: [2, 32] },
|
150 | parseError: function parseError(str, hash) {
|
151 | if (hash.recoverable) {
|
152 | this.trace(str);
|
153 | } else {
|
154 | var error = new Error(str);
|
155 | error.hash = hash;
|
156 | throw error;
|
157 | }
|
158 | },
|
159 | parse: function parse(input) {
|
160 | var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
|
161 | var args = lstack.slice.call(arguments, 1);
|
162 | var lexer2 = Object.create(this.lexer);
|
163 | var sharedState = { yy: {} };
|
164 | for (var k in this.yy) {
|
165 | if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
|
166 | sharedState.yy[k] = this.yy[k];
|
167 | }
|
168 | }
|
169 | lexer2.setInput(input, sharedState.yy);
|
170 | sharedState.yy.lexer = lexer2;
|
171 | sharedState.yy.parser = this;
|
172 | if (typeof lexer2.yylloc == "undefined") {
|
173 | lexer2.yylloc = {};
|
174 | }
|
175 | var yyloc = lexer2.yylloc;
|
176 | lstack.push(yyloc);
|
177 | var ranges = lexer2.options && lexer2.options.ranges;
|
178 | if (typeof sharedState.yy.parseError === "function") {
|
179 | this.parseError = sharedState.yy.parseError;
|
180 | } else {
|
181 | this.parseError = Object.getPrototypeOf(this).parseError;
|
182 | }
|
183 | function lex() {
|
184 | var token;
|
185 | token = tstack.pop() || lexer2.lex() || EOF;
|
186 | if (typeof token !== "number") {
|
187 | if (token instanceof Array) {
|
188 | tstack = token;
|
189 | token = tstack.pop();
|
190 | }
|
191 | token = self.symbols_[token] || token;
|
192 | }
|
193 | return token;
|
194 | }
|
195 | var symbol, state, action, r, yyval = {}, p, len, newState, expected;
|
196 | while (true) {
|
197 | state = stack[stack.length - 1];
|
198 | if (this.defaultActions[state]) {
|
199 | action = this.defaultActions[state];
|
200 | } else {
|
201 | if (symbol === null || typeof symbol == "undefined") {
|
202 | symbol = lex();
|
203 | }
|
204 | action = table[state] && table[state][symbol];
|
205 | }
|
206 | if (typeof action === "undefined" || !action.length || !action[0]) {
|
207 | var errStr = "";
|
208 | expected = [];
|
209 | for (p in table[state]) {
|
210 | if (this.terminals_[p] && p > TERROR) {
|
211 | expected.push("'" + this.terminals_[p] + "'");
|
212 | }
|
213 | }
|
214 | if (lexer2.showPosition) {
|
215 | errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
|
216 | } else {
|
217 | errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
|
218 | }
|
219 | this.parseError(errStr, {
|
220 | text: lexer2.match,
|
221 | token: this.terminals_[symbol] || symbol,
|
222 | line: lexer2.yylineno,
|
223 | loc: yyloc,
|
224 | expected
|
225 | });
|
226 | }
|
227 | if (action[0] instanceof Array && action.length > 1) {
|
228 | throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
|
229 | }
|
230 | switch (action[0]) {
|
231 | case 1:
|
232 | stack.push(symbol);
|
233 | vstack.push(lexer2.yytext);
|
234 | lstack.push(lexer2.yylloc);
|
235 | stack.push(action[1]);
|
236 | symbol = null;
|
237 | {
|
238 | yyleng = lexer2.yyleng;
|
239 | yytext = lexer2.yytext;
|
240 | yylineno = lexer2.yylineno;
|
241 | yyloc = lexer2.yylloc;
|
242 | }
|
243 | break;
|
244 | case 2:
|
245 | len = this.productions_[action[1]][1];
|
246 | yyval.$ = vstack[vstack.length - len];
|
247 | yyval._$ = {
|
248 | first_line: lstack[lstack.length - (len || 1)].first_line,
|
249 | last_line: lstack[lstack.length - 1].last_line,
|
250 | first_column: lstack[lstack.length - (len || 1)].first_column,
|
251 | last_column: lstack[lstack.length - 1].last_column
|
252 | };
|
253 | if (ranges) {
|
254 | yyval._$.range = [
|
255 | lstack[lstack.length - (len || 1)].range[0],
|
256 | lstack[lstack.length - 1].range[1]
|
257 | ];
|
258 | }
|
259 | r = this.performAction.apply(yyval, [
|
260 | yytext,
|
261 | yyleng,
|
262 | yylineno,
|
263 | sharedState.yy,
|
264 | action[1],
|
265 | vstack,
|
266 | lstack
|
267 | ].concat(args));
|
268 | if (typeof r !== "undefined") {
|
269 | return r;
|
270 | }
|
271 | if (len) {
|
272 | stack = stack.slice(0, -1 * len * 2);
|
273 | vstack = vstack.slice(0, -1 * len);
|
274 | lstack = lstack.slice(0, -1 * len);
|
275 | }
|
276 | stack.push(this.productions_[action[1]][0]);
|
277 | vstack.push(yyval.$);
|
278 | lstack.push(yyval._$);
|
279 | newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
280 | stack.push(newState);
|
281 | break;
|
282 | case 3:
|
283 | return true;
|
284 | }
|
285 | }
|
286 | return true;
|
287 | }
|
288 | };
|
289 | var lexer = function() {
|
290 | var lexer2 = {
|
291 | EOF: 1,
|
292 | parseError: function parseError(str, hash) {
|
293 | if (this.yy.parser) {
|
294 | this.yy.parser.parseError(str, hash);
|
295 | } else {
|
296 | throw new Error(str);
|
297 | }
|
298 | },
|
299 |
|
300 | setInput: function(input, yy) {
|
301 | this.yy = yy || this.yy || {};
|
302 | this._input = input;
|
303 | this._more = this._backtrack = this.done = false;
|
304 | this.yylineno = this.yyleng = 0;
|
305 | this.yytext = this.matched = this.match = "";
|
306 | this.conditionStack = ["INITIAL"];
|
307 | this.yylloc = {
|
308 | first_line: 1,
|
309 | first_column: 0,
|
310 | last_line: 1,
|
311 | last_column: 0
|
312 | };
|
313 | if (this.options.ranges) {
|
314 | this.yylloc.range = [0, 0];
|
315 | }
|
316 | this.offset = 0;
|
317 | return this;
|
318 | },
|
319 |
|
320 | input: function() {
|
321 | var ch = this._input[0];
|
322 | this.yytext += ch;
|
323 | this.yyleng++;
|
324 | this.offset++;
|
325 | this.match += ch;
|
326 | this.matched += ch;
|
327 | var lines = ch.match(/(?:\r\n?|\n).*/g);
|
328 | if (lines) {
|
329 | this.yylineno++;
|
330 | this.yylloc.last_line++;
|
331 | } else {
|
332 | this.yylloc.last_column++;
|
333 | }
|
334 | if (this.options.ranges) {
|
335 | this.yylloc.range[1]++;
|
336 | }
|
337 | this._input = this._input.slice(1);
|
338 | return ch;
|
339 | },
|
340 |
|
341 | unput: function(ch) {
|
342 | var len = ch.length;
|
343 | var lines = ch.split(/(?:\r\n?|\n)/g);
|
344 | this._input = ch + this._input;
|
345 | this.yytext = this.yytext.substr(0, this.yytext.length - len);
|
346 | this.offset -= len;
|
347 | var oldLines = this.match.split(/(?:\r\n?|\n)/g);
|
348 | this.match = this.match.substr(0, this.match.length - 1);
|
349 | this.matched = this.matched.substr(0, this.matched.length - 1);
|
350 | if (lines.length - 1) {
|
351 | this.yylineno -= lines.length - 1;
|
352 | }
|
353 | var r = this.yylloc.range;
|
354 | this.yylloc = {
|
355 | first_line: this.yylloc.first_line,
|
356 | last_line: this.yylineno + 1,
|
357 | first_column: this.yylloc.first_column,
|
358 | last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len
|
359 | };
|
360 | if (this.options.ranges) {
|
361 | this.yylloc.range = [r[0], r[0] + this.yyleng - len];
|
362 | }
|
363 | this.yyleng = this.yytext.length;
|
364 | return this;
|
365 | },
|
366 |
|
367 | more: function() {
|
368 | this._more = true;
|
369 | return this;
|
370 | },
|
371 |
|
372 | reject: function() {
|
373 | if (this.options.backtrack_lexer) {
|
374 | this._backtrack = true;
|
375 | } else {
|
376 | 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).\n" + this.showPosition(), {
|
377 | text: "",
|
378 | token: null,
|
379 | line: this.yylineno
|
380 | });
|
381 | }
|
382 | return this;
|
383 | },
|
384 |
|
385 | less: function(n) {
|
386 | this.unput(this.match.slice(n));
|
387 | },
|
388 |
|
389 | pastInput: function() {
|
390 | var past = this.matched.substr(0, this.matched.length - this.match.length);
|
391 | return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
|
392 | },
|
393 |
|
394 | upcomingInput: function() {
|
395 | var next = this.match;
|
396 | if (next.length < 20) {
|
397 | next += this._input.substr(0, 20 - next.length);
|
398 | }
|
399 | return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
|
400 | },
|
401 |
|
402 | showPosition: function() {
|
403 | var pre = this.pastInput();
|
404 | var c = new Array(pre.length + 1).join("-");
|
405 | return pre + this.upcomingInput() + "\n" + c + "^";
|
406 | },
|
407 |
|
408 | test_match: function(match, indexed_rule) {
|
409 | var token, lines, backup;
|
410 | if (this.options.backtrack_lexer) {
|
411 | backup = {
|
412 | yylineno: this.yylineno,
|
413 | yylloc: {
|
414 | first_line: this.yylloc.first_line,
|
415 | last_line: this.last_line,
|
416 | first_column: this.yylloc.first_column,
|
417 | last_column: this.yylloc.last_column
|
418 | },
|
419 | yytext: this.yytext,
|
420 | match: this.match,
|
421 | matches: this.matches,
|
422 | matched: this.matched,
|
423 | yyleng: this.yyleng,
|
424 | offset: this.offset,
|
425 | _more: this._more,
|
426 | _input: this._input,
|
427 | yy: this.yy,
|
428 | conditionStack: this.conditionStack.slice(0),
|
429 | done: this.done
|
430 | };
|
431 | if (this.options.ranges) {
|
432 | backup.yylloc.range = this.yylloc.range.slice(0);
|
433 | }
|
434 | }
|
435 | lines = match[0].match(/(?:\r\n?|\n).*/g);
|
436 | if (lines) {
|
437 | this.yylineno += lines.length;
|
438 | }
|
439 | this.yylloc = {
|
440 | first_line: this.yylloc.last_line,
|
441 | last_line: this.yylineno + 1,
|
442 | first_column: this.yylloc.last_column,
|
443 | last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
|
444 | };
|
445 | this.yytext += match[0];
|
446 | this.match += match[0];
|
447 | this.matches = match;
|
448 | this.yyleng = this.yytext.length;
|
449 | if (this.options.ranges) {
|
450 | this.yylloc.range = [this.offset, this.offset += this.yyleng];
|
451 | }
|
452 | this._more = false;
|
453 | this._backtrack = false;
|
454 | this._input = this._input.slice(match[0].length);
|
455 | this.matched += match[0];
|
456 | token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
|
457 | if (this.done && this._input) {
|
458 | this.done = false;
|
459 | }
|
460 | if (token) {
|
461 | return token;
|
462 | } else if (this._backtrack) {
|
463 | for (var k in backup) {
|
464 | this[k] = backup[k];
|
465 | }
|
466 | return false;
|
467 | }
|
468 | return false;
|
469 | },
|
470 |
|
471 | next: function() {
|
472 | if (this.done) {
|
473 | return this.EOF;
|
474 | }
|
475 | if (!this._input) {
|
476 | this.done = true;
|
477 | }
|
478 | var token, match, tempMatch, index;
|
479 | if (!this._more) {
|
480 | this.yytext = "";
|
481 | this.match = "";
|
482 | }
|
483 | var rules = this._currentRules();
|
484 | for (var i = 0; i < rules.length; i++) {
|
485 | tempMatch = this._input.match(this.rules[rules[i]]);
|
486 | if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
487 | match = tempMatch;
|
488 | index = i;
|
489 | if (this.options.backtrack_lexer) {
|
490 | token = this.test_match(tempMatch, rules[i]);
|
491 | if (token !== false) {
|
492 | return token;
|
493 | } else if (this._backtrack) {
|
494 | match = false;
|
495 | continue;
|
496 | } else {
|
497 | return false;
|
498 | }
|
499 | } else if (!this.options.flex) {
|
500 | break;
|
501 | }
|
502 | }
|
503 | }
|
504 | if (match) {
|
505 | token = this.test_match(match, rules[index]);
|
506 | if (token !== false) {
|
507 | return token;
|
508 | }
|
509 | return false;
|
510 | }
|
511 | if (this._input === "") {
|
512 | return this.EOF;
|
513 | } else {
|
514 | return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
|
515 | text: "",
|
516 | token: null,
|
517 | line: this.yylineno
|
518 | });
|
519 | }
|
520 | },
|
521 |
|
522 | lex: function lex() {
|
523 | var r = this.next();
|
524 | if (r) {
|
525 | return r;
|
526 | } else {
|
527 | return this.lex();
|
528 | }
|
529 | },
|
530 |
|
531 | begin: function begin(condition) {
|
532 | this.conditionStack.push(condition);
|
533 | },
|
534 |
|
535 | popState: function popState() {
|
536 | var n = this.conditionStack.length - 1;
|
537 | if (n > 0) {
|
538 | return this.conditionStack.pop();
|
539 | } else {
|
540 | return this.conditionStack[0];
|
541 | }
|
542 | },
|
543 |
|
544 | _currentRules: function _currentRules() {
|
545 | if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
|
546 | return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
|
547 | } else {
|
548 | return this.conditions["INITIAL"].rules;
|
549 | }
|
550 | },
|
551 |
|
552 | topState: function topState(n) {
|
553 | n = this.conditionStack.length - 1 - Math.abs(n || 0);
|
554 | if (n >= 0) {
|
555 | return this.conditionStack[n];
|
556 | } else {
|
557 | return "INITIAL";
|
558 | }
|
559 | },
|
560 |
|
561 | pushState: function pushState(condition) {
|
562 | this.begin(condition);
|
563 | },
|
564 |
|
565 | stateStackSize: function stateStackSize() {
|
566 | return this.conditionStack.length;
|
567 | },
|
568 | options: {},
|
569 | performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
|
570 | switch ($avoiding_name_collisions) {
|
571 | case 0:
|
572 | return 10;
|
573 | case 1:
|
574 | yy.getLogger().debug("Found space-block");
|
575 | return 31;
|
576 | case 2:
|
577 | yy.getLogger().debug("Found nl-block");
|
578 | return 31;
|
579 | case 3:
|
580 | yy.getLogger().debug("Found space-block");
|
581 | return 29;
|
582 | case 4:
|
583 | yy.getLogger().debug(".", yy_.yytext);
|
584 | break;
|
585 | case 5:
|
586 | yy.getLogger().debug("_", yy_.yytext);
|
587 | break;
|
588 | case 6:
|
589 | return 5;
|
590 | case 7:
|
591 | yy_.yytext = -1;
|
592 | return 28;
|
593 | case 8:
|
594 | yy_.yytext = yy_.yytext.replace(/columns\s+/, "");
|
595 | yy.getLogger().debug("COLUMNS (LEX)", yy_.yytext);
|
596 | return 28;
|
597 | case 9:
|
598 | this.pushState("md_string");
|
599 | break;
|
600 | case 10:
|
601 | return "MD_STR";
|
602 | case 11:
|
603 | this.popState();
|
604 | break;
|
605 | case 12:
|
606 | this.pushState("string");
|
607 | break;
|
608 | case 13:
|
609 | yy.getLogger().debug("LEX: POPPING STR:", yy_.yytext);
|
610 | this.popState();
|
611 | break;
|
612 | case 14:
|
613 | yy.getLogger().debug("LEX: STR end:", yy_.yytext);
|
614 | return "STR";
|
615 | case 15:
|
616 | yy_.yytext = yy_.yytext.replace(/space\:/, "");
|
617 | yy.getLogger().debug("SPACE NUM (LEX)", yy_.yytext);
|
618 | return 21;
|
619 | case 16:
|
620 | yy_.yytext = "1";
|
621 | yy.getLogger().debug("COLUMNS (LEX)", yy_.yytext);
|
622 | return 21;
|
623 | case 17:
|
624 | return 43;
|
625 | case 18:
|
626 | return "LINKSTYLE";
|
627 | case 19:
|
628 | return "INTERPOLATE";
|
629 | case 20:
|
630 | this.pushState("CLASSDEF");
|
631 | return 40;
|
632 | case 21:
|
633 | this.popState();
|
634 | this.pushState("CLASSDEFID");
|
635 | return "DEFAULT_CLASSDEF_ID";
|
636 | case 22:
|
637 | this.popState();
|
638 | this.pushState("CLASSDEFID");
|
639 | return 41;
|
640 | case 23:
|
641 | this.popState();
|
642 | return 42;
|
643 | case 24:
|
644 | this.pushState("CLASS");
|
645 | return 44;
|
646 | case 25:
|
647 | this.popState();
|
648 | this.pushState("CLASS_STYLE");
|
649 | return 45;
|
650 | case 26:
|
651 | this.popState();
|
652 | return 46;
|
653 | case 27:
|
654 | this.pushState("STYLE_STMNT");
|
655 | return 47;
|
656 | case 28:
|
657 | this.popState();
|
658 | this.pushState("STYLE_DEFINITION");
|
659 | return 48;
|
660 | case 29:
|
661 | this.popState();
|
662 | return 49;
|
663 | case 30:
|
664 | this.pushState("acc_title");
|
665 | return "acc_title";
|
666 | case 31:
|
667 | this.popState();
|
668 | return "acc_title_value";
|
669 | case 32:
|
670 | this.pushState("acc_descr");
|
671 | return "acc_descr";
|
672 | case 33:
|
673 | this.popState();
|
674 | return "acc_descr_value";
|
675 | case 34:
|
676 | this.pushState("acc_descr_multiline");
|
677 | break;
|
678 | case 35:
|
679 | this.popState();
|
680 | break;
|
681 | case 36:
|
682 | return "acc_descr_multiline_value";
|
683 | case 37:
|
684 | return 30;
|
685 | case 38:
|
686 | this.popState();
|
687 | yy.getLogger().debug("Lex: ((");
|
688 | return "NODE_DEND";
|
689 | case 39:
|
690 | this.popState();
|
691 | yy.getLogger().debug("Lex: ((");
|
692 | return "NODE_DEND";
|
693 | case 40:
|
694 | this.popState();
|
695 | yy.getLogger().debug("Lex: ))");
|
696 | return "NODE_DEND";
|
697 | case 41:
|
698 | this.popState();
|
699 | yy.getLogger().debug("Lex: ((");
|
700 | return "NODE_DEND";
|
701 | case 42:
|
702 | this.popState();
|
703 | yy.getLogger().debug("Lex: ((");
|
704 | return "NODE_DEND";
|
705 | case 43:
|
706 | this.popState();
|
707 | yy.getLogger().debug("Lex: (-");
|
708 | return "NODE_DEND";
|
709 | case 44:
|
710 | this.popState();
|
711 | yy.getLogger().debug("Lex: -)");
|
712 | return "NODE_DEND";
|
713 | case 45:
|
714 | this.popState();
|
715 | yy.getLogger().debug("Lex: ((");
|
716 | return "NODE_DEND";
|
717 | case 46:
|
718 | this.popState();
|
719 | yy.getLogger().debug("Lex: ]]");
|
720 | return "NODE_DEND";
|
721 | case 47:
|
722 | this.popState();
|
723 | yy.getLogger().debug("Lex: (");
|
724 | return "NODE_DEND";
|
725 | case 48:
|
726 | this.popState();
|
727 | yy.getLogger().debug("Lex: ])");
|
728 | return "NODE_DEND";
|
729 | case 49:
|
730 | this.popState();
|
731 | yy.getLogger().debug("Lex: /]");
|
732 | return "NODE_DEND";
|
733 | case 50:
|
734 | this.popState();
|
735 | yy.getLogger().debug("Lex: /]");
|
736 | return "NODE_DEND";
|
737 | case 51:
|
738 | this.popState();
|
739 | yy.getLogger().debug("Lex: )]");
|
740 | return "NODE_DEND";
|
741 | case 52:
|
742 | this.popState();
|
743 | yy.getLogger().debug("Lex: )");
|
744 | return "NODE_DEND";
|
745 | case 53:
|
746 | this.popState();
|
747 | yy.getLogger().debug("Lex: ]>");
|
748 | return "NODE_DEND";
|
749 | case 54:
|
750 | this.popState();
|
751 | yy.getLogger().debug("Lex: ]");
|
752 | return "NODE_DEND";
|
753 | case 55:
|
754 | yy.getLogger().debug("Lexa: -)");
|
755 | this.pushState("NODE");
|
756 | return 36;
|
757 | case 56:
|
758 | yy.getLogger().debug("Lexa: (-");
|
759 | this.pushState("NODE");
|
760 | return 36;
|
761 | case 57:
|
762 | yy.getLogger().debug("Lexa: ))");
|
763 | this.pushState("NODE");
|
764 | return 36;
|
765 | case 58:
|
766 | yy.getLogger().debug("Lexa: )");
|
767 | this.pushState("NODE");
|
768 | return 36;
|
769 | case 59:
|
770 | yy.getLogger().debug("Lex: (((");
|
771 | this.pushState("NODE");
|
772 | return 36;
|
773 | case 60:
|
774 | yy.getLogger().debug("Lexa: )");
|
775 | this.pushState("NODE");
|
776 | return 36;
|
777 | case 61:
|
778 | yy.getLogger().debug("Lexa: )");
|
779 | this.pushState("NODE");
|
780 | return 36;
|
781 | case 62:
|
782 | yy.getLogger().debug("Lexa: )");
|
783 | this.pushState("NODE");
|
784 | return 36;
|
785 | case 63:
|
786 | yy.getLogger().debug("Lexc: >");
|
787 | this.pushState("NODE");
|
788 | return 36;
|
789 | case 64:
|
790 | yy.getLogger().debug("Lexa: ([");
|
791 | this.pushState("NODE");
|
792 | return 36;
|
793 | case 65:
|
794 | yy.getLogger().debug("Lexa: )");
|
795 | this.pushState("NODE");
|
796 | return 36;
|
797 | case 66:
|
798 | this.pushState("NODE");
|
799 | return 36;
|
800 | case 67:
|
801 | this.pushState("NODE");
|
802 | return 36;
|
803 | case 68:
|
804 | this.pushState("NODE");
|
805 | return 36;
|
806 | case 69:
|
807 | this.pushState("NODE");
|
808 | return 36;
|
809 | case 70:
|
810 | this.pushState("NODE");
|
811 | return 36;
|
812 | case 71:
|
813 | this.pushState("NODE");
|
814 | return 36;
|
815 | case 72:
|
816 | this.pushState("NODE");
|
817 | return 36;
|
818 | case 73:
|
819 | yy.getLogger().debug("Lexa: [");
|
820 | this.pushState("NODE");
|
821 | return 36;
|
822 | case 74:
|
823 | this.pushState("BLOCK_ARROW");
|
824 | yy.getLogger().debug("LEX ARR START");
|
825 | return 38;
|
826 | case 75:
|
827 | yy.getLogger().debug("Lex: NODE_ID", yy_.yytext);
|
828 | return 32;
|
829 | case 76:
|
830 | yy.getLogger().debug("Lex: EOF", yy_.yytext);
|
831 | return 8;
|
832 | case 77:
|
833 | this.pushState("md_string");
|
834 | break;
|
835 | case 78:
|
836 | this.pushState("md_string");
|
837 | break;
|
838 | case 79:
|
839 | return "NODE_DESCR";
|
840 | case 80:
|
841 | this.popState();
|
842 | break;
|
843 | case 81:
|
844 | yy.getLogger().debug("Lex: Starting string");
|
845 | this.pushState("string");
|
846 | break;
|
847 | case 82:
|
848 | yy.getLogger().debug("LEX ARR: Starting string");
|
849 | this.pushState("string");
|
850 | break;
|
851 | case 83:
|
852 | yy.getLogger().debug("LEX: NODE_DESCR:", yy_.yytext);
|
853 | return "NODE_DESCR";
|
854 | case 84:
|
855 | yy.getLogger().debug("LEX POPPING");
|
856 | this.popState();
|
857 | break;
|
858 | case 85:
|
859 | yy.getLogger().debug("Lex: =>BAE");
|
860 | this.pushState("ARROW_DIR");
|
861 | break;
|
862 | case 86:
|
863 | yy_.yytext = yy_.yytext.replace(/^,\s*/, "");
|
864 | yy.getLogger().debug("Lex (right): dir:", yy_.yytext);
|
865 | return "DIR";
|
866 | case 87:
|
867 | yy_.yytext = yy_.yytext.replace(/^,\s*/, "");
|
868 | yy.getLogger().debug("Lex (left):", yy_.yytext);
|
869 | return "DIR";
|
870 | case 88:
|
871 | yy_.yytext = yy_.yytext.replace(/^,\s*/, "");
|
872 | yy.getLogger().debug("Lex (x):", yy_.yytext);
|
873 | return "DIR";
|
874 | case 89:
|
875 | yy_.yytext = yy_.yytext.replace(/^,\s*/, "");
|
876 | yy.getLogger().debug("Lex (y):", yy_.yytext);
|
877 | return "DIR";
|
878 | case 90:
|
879 | yy_.yytext = yy_.yytext.replace(/^,\s*/, "");
|
880 | yy.getLogger().debug("Lex (up):", yy_.yytext);
|
881 | return "DIR";
|
882 | case 91:
|
883 | yy_.yytext = yy_.yytext.replace(/^,\s*/, "");
|
884 | yy.getLogger().debug("Lex (down):", yy_.yytext);
|
885 | return "DIR";
|
886 | case 92:
|
887 | yy_.yytext = "]>";
|
888 | yy.getLogger().debug("Lex (ARROW_DIR end):", yy_.yytext);
|
889 | this.popState();
|
890 | this.popState();
|
891 | return "BLOCK_ARROW_END";
|
892 | case 93:
|
893 | yy.getLogger().debug("Lex: LINK", "#" + yy_.yytext + "#");
|
894 | return 15;
|
895 | case 94:
|
896 | yy.getLogger().debug("Lex: LINK", yy_.yytext);
|
897 | return 15;
|
898 | case 95:
|
899 | yy.getLogger().debug("Lex: LINK", yy_.yytext);
|
900 | return 15;
|
901 | case 96:
|
902 | yy.getLogger().debug("Lex: LINK", yy_.yytext);
|
903 | return 15;
|
904 | case 97:
|
905 | yy.getLogger().debug("Lex: START_LINK", yy_.yytext);
|
906 | this.pushState("LLABEL");
|
907 | return 16;
|
908 | case 98:
|
909 | yy.getLogger().debug("Lex: START_LINK", yy_.yytext);
|
910 | this.pushState("LLABEL");
|
911 | return 16;
|
912 | case 99:
|
913 | yy.getLogger().debug("Lex: START_LINK", yy_.yytext);
|
914 | this.pushState("LLABEL");
|
915 | return 16;
|
916 | case 100:
|
917 | this.pushState("md_string");
|
918 | break;
|
919 | case 101:
|
920 | yy.getLogger().debug("Lex: Starting string");
|
921 | this.pushState("string");
|
922 | return "LINK_LABEL";
|
923 | case 102:
|
924 | this.popState();
|
925 | yy.getLogger().debug("Lex: LINK", "#" + yy_.yytext + "#");
|
926 | return 15;
|
927 | case 103:
|
928 | this.popState();
|
929 | yy.getLogger().debug("Lex: LINK", yy_.yytext);
|
930 | return 15;
|
931 | case 104:
|
932 | this.popState();
|
933 | yy.getLogger().debug("Lex: LINK", yy_.yytext);
|
934 | return 15;
|
935 | case 105:
|
936 | yy.getLogger().debug("Lex: COLON", yy_.yytext);
|
937 | yy_.yytext = yy_.yytext.slice(1);
|
938 | return 27;
|
939 | }
|
940 | },
|
941 | 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+)/],
|
942 | conditions: { "STYLE_DEFINITION": { "rules": [29], "inclusive": false }, "STYLE_STMNT": { "rules": [28], "inclusive": false }, "CLASSDEFID": { "rules": [23], "inclusive": false }, "CLASSDEF": { "rules": [21, 22], "inclusive": false }, "CLASS_STYLE": { "rules": [26], "inclusive": false }, "CLASS": { "rules": [25], "inclusive": false }, "LLABEL": { "rules": [100, 101, 102, 103, 104], "inclusive": false }, "ARROW_DIR": { "rules": [86, 87, 88, 89, 90, 91, 92], "inclusive": false }, "BLOCK_ARROW": { "rules": [77, 82, 85], "inclusive": false }, "NODE": { "rules": [38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 78, 81], "inclusive": false }, "md_string": { "rules": [10, 11, 79, 80], "inclusive": false }, "space": { "rules": [], "inclusive": false }, "string": { "rules": [13, 14, 83, 84], "inclusive": false }, "acc_descr_multiline": { "rules": [35, 36], "inclusive": false }, "acc_descr": { "rules": [33], "inclusive": false }, "acc_title": { "rules": [31], "inclusive": false }, "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": true } }
|
943 | };
|
944 | return lexer2;
|
945 | }();
|
946 | parser2.lexer = lexer;
|
947 | function Parser() {
|
948 | this.yy = {};
|
949 | }
|
950 | Parser.prototype = parser2;
|
951 | parser2.Parser = Parser;
|
952 | return new Parser();
|
953 | }();
|
954 | parser.parser = parser;
|
955 | const parser$1 = parser;
|
956 | let blockDatabase = {};
|
957 | let edgeList = [];
|
958 | let edgeCount = {};
|
959 | const COLOR_KEYWORD = "color";
|
960 | const FILL_KEYWORD = "fill";
|
961 | const BG_FILL = "bgFill";
|
962 | const STYLECLASS_SEP = ",";
|
963 | const config = getConfig();
|
964 | let classes = {};
|
965 | const sanitizeText = (txt) => common.sanitizeText(txt, config);
|
966 | const addStyleClass = function(id, styleAttributes = "") {
|
967 | if (classes[id] === void 0) {
|
968 | classes[id] = { id, styles: [], textStyles: [] };
|
969 | }
|
970 | const foundClass = classes[id];
|
971 | if (styleAttributes !== void 0 && styleAttributes !== null) {
|
972 | styleAttributes.split(STYLECLASS_SEP).forEach((attrib) => {
|
973 | const fixedAttrib = attrib.replace(/([^;]*);/, "$1").trim();
|
974 | if (attrib.match(COLOR_KEYWORD)) {
|
975 | const newStyle1 = fixedAttrib.replace(FILL_KEYWORD, BG_FILL);
|
976 | const newStyle2 = newStyle1.replace(COLOR_KEYWORD, FILL_KEYWORD);
|
977 | foundClass.textStyles.push(newStyle2);
|
978 | }
|
979 | foundClass.styles.push(fixedAttrib);
|
980 | });
|
981 | }
|
982 | };
|
983 | const addStyle2Node = function(id, styles = "") {
|
984 | const foundBlock = blockDatabase[id];
|
985 | if (styles !== void 0 && styles !== null) {
|
986 | foundBlock.styles = styles.split(STYLECLASS_SEP);
|
987 | }
|
988 | };
|
989 | const setCssClass = function(itemIds, cssClassName) {
|
990 | itemIds.split(",").forEach(function(id) {
|
991 | let foundBlock = blockDatabase[id];
|
992 | if (foundBlock === void 0) {
|
993 | const trimmedId = id.trim();
|
994 | blockDatabase[trimmedId] = { id: trimmedId, type: "na", children: [] };
|
995 | foundBlock = blockDatabase[trimmedId];
|
996 | }
|
997 | if (!foundBlock.classes) {
|
998 | foundBlock.classes = [];
|
999 | }
|
1000 | foundBlock.classes.push(cssClassName);
|
1001 | });
|
1002 | };
|
1003 | const populateBlockDatabase = (_blockList, parent) => {
|
1004 | const blockList = _blockList.flat();
|
1005 | const children = [];
|
1006 | for (const block of blockList) {
|
1007 | if (block.label) {
|
1008 | block.label = sanitizeText(block.label);
|
1009 | }
|
1010 | if (block.type === "classDef") {
|
1011 | addStyleClass(block.id, block.css);
|
1012 | continue;
|
1013 | }
|
1014 | if (block.type === "applyClass") {
|
1015 | setCssClass(block.id, (block == null ? void 0 : block.styleClass) || "");
|
1016 | continue;
|
1017 | }
|
1018 | if (block.type === "applyStyles") {
|
1019 | if (block == null ? void 0 : block.stylesStr) {
|
1020 | addStyle2Node(block.id, block == null ? void 0 : block.stylesStr);
|
1021 | }
|
1022 | continue;
|
1023 | }
|
1024 | if (block.type === "column-setting") {
|
1025 | parent.columns = block.columns || -1;
|
1026 | } else if (block.type === "edge") {
|
1027 | if (edgeCount[block.id]) {
|
1028 | edgeCount[block.id]++;
|
1029 | } else {
|
1030 | edgeCount[block.id] = 1;
|
1031 | }
|
1032 | block.id = edgeCount[block.id] + "-" + block.id;
|
1033 | edgeList.push(block);
|
1034 | } else {
|
1035 | if (!block.label) {
|
1036 | if (block.type === "composite") {
|
1037 | block.label = "";
|
1038 | } else {
|
1039 | block.label = block.id;
|
1040 | }
|
1041 | }
|
1042 | const newBlock = !blockDatabase[block.id];
|
1043 | if (newBlock) {
|
1044 | blockDatabase[block.id] = block;
|
1045 | } else {
|
1046 | if (block.type !== "na") {
|
1047 | blockDatabase[block.id].type = block.type;
|
1048 | }
|
1049 | if (block.label !== block.id) {
|
1050 | blockDatabase[block.id].label = block.label;
|
1051 | }
|
1052 | }
|
1053 | if (block.children) {
|
1054 | populateBlockDatabase(block.children, block);
|
1055 | }
|
1056 | if (block.type === "space") {
|
1057 | const w = block.width || 1;
|
1058 | for (let j = 0; j < w; j++) {
|
1059 | const newBlock2 = clone(block);
|
1060 | newBlock2.id = newBlock2.id + "-" + j;
|
1061 | blockDatabase[newBlock2.id] = newBlock2;
|
1062 | children.push(newBlock2);
|
1063 | }
|
1064 | } else if (newBlock) {
|
1065 | children.push(block);
|
1066 | }
|
1067 | }
|
1068 | }
|
1069 | parent.children = children;
|
1070 | };
|
1071 | let blocks = [];
|
1072 | let rootBlock = { id: "root", type: "composite", children: [], columns: -1 };
|
1073 | const clear = () => {
|
1074 | log.debug("Clear called");
|
1075 | clear$1();
|
1076 | rootBlock = { id: "root", type: "composite", children: [], columns: -1 };
|
1077 | blockDatabase = { root: rootBlock };
|
1078 | blocks = [];
|
1079 | classes = {};
|
1080 | edgeList = [];
|
1081 | edgeCount = {};
|
1082 | };
|
1083 | function typeStr2Type(typeStr) {
|
1084 | log.debug("typeStr2Type", typeStr);
|
1085 | switch (typeStr) {
|
1086 | case "[]":
|
1087 | return "square";
|
1088 | case "()":
|
1089 | log.debug("we have a round");
|
1090 | return "round";
|
1091 | case "(())":
|
1092 | return "circle";
|
1093 | case ">]":
|
1094 | return "rect_left_inv_arrow";
|
1095 | case "{}":
|
1096 | return "diamond";
|
1097 | case "{{}}":
|
1098 | return "hexagon";
|
1099 | case "([])":
|
1100 | return "stadium";
|
1101 | case "[[]]":
|
1102 | return "subroutine";
|
1103 | case "[()]":
|
1104 | return "cylinder";
|
1105 | case "((()))":
|
1106 | return "doublecircle";
|
1107 | case "[//]":
|
1108 | return "lean_right";
|
1109 | case "[\\\\]":
|
1110 | return "lean_left";
|
1111 | case "[/\\]":
|
1112 | return "trapezoid";
|
1113 | case "[\\/]":
|
1114 | return "inv_trapezoid";
|
1115 | case "<[]>":
|
1116 | return "block_arrow";
|
1117 | default:
|
1118 | return "na";
|
1119 | }
|
1120 | }
|
1121 | function edgeTypeStr2Type(typeStr) {
|
1122 | log.debug("typeStr2Type", typeStr);
|
1123 | switch (typeStr) {
|
1124 | case "==":
|
1125 | return "thick";
|
1126 | default:
|
1127 | return "normal";
|
1128 | }
|
1129 | }
|
1130 | function edgeStrToEdgeData(typeStr) {
|
1131 | switch (typeStr.trim()) {
|
1132 | case "--x":
|
1133 | return "arrow_cross";
|
1134 | case "--o":
|
1135 | return "arrow_circle";
|
1136 | default:
|
1137 | return "arrow_point";
|
1138 | }
|
1139 | }
|
1140 | let cnt = 0;
|
1141 | const generateId = () => {
|
1142 | cnt++;
|
1143 | return "id-" + Math.random().toString(36).substr(2, 12) + "-" + cnt;
|
1144 | };
|
1145 | const setHierarchy = (block) => {
|
1146 | rootBlock.children = block;
|
1147 | populateBlockDatabase(block, rootBlock);
|
1148 | blocks = rootBlock.children;
|
1149 | };
|
1150 | const getColumns = (blockId) => {
|
1151 | const block = blockDatabase[blockId];
|
1152 | if (!block) {
|
1153 | return -1;
|
1154 | }
|
1155 | if (block.columns) {
|
1156 | return block.columns;
|
1157 | }
|
1158 | if (!block.children) {
|
1159 | return -1;
|
1160 | }
|
1161 | return block.children.length;
|
1162 | };
|
1163 | const getBlocksFlat = () => {
|
1164 | return [...Object.values(blockDatabase)];
|
1165 | };
|
1166 | const getBlocks = () => {
|
1167 | return blocks || [];
|
1168 | };
|
1169 | const getEdges = () => {
|
1170 | return edgeList;
|
1171 | };
|
1172 | const getBlock = (id) => {
|
1173 | return blockDatabase[id];
|
1174 | };
|
1175 | const setBlock = (block) => {
|
1176 | blockDatabase[block.id] = block;
|
1177 | };
|
1178 | const getLogger = () => console;
|
1179 | const getClasses$1 = function() {
|
1180 | return classes;
|
1181 | };
|
1182 | const db = {
|
1183 | getConfig: () => getConfig$1().block,
|
1184 | typeStr2Type,
|
1185 | edgeTypeStr2Type,
|
1186 | edgeStrToEdgeData,
|
1187 | getLogger,
|
1188 | getBlocksFlat,
|
1189 | getBlocks,
|
1190 | getEdges,
|
1191 | setHierarchy,
|
1192 | getBlock,
|
1193 | setBlock,
|
1194 | getColumns,
|
1195 | getClasses: getClasses$1,
|
1196 | clear,
|
1197 | generateId
|
1198 | };
|
1199 | const db$1 = db;
|
1200 | const fade = (color, opacity) => {
|
1201 | const channel = khroma.channel;
|
1202 | const r = channel(color, "r");
|
1203 | const g = channel(color, "g");
|
1204 | const b = channel(color, "b");
|
1205 | return khroma.rgba(r, g, b, opacity);
|
1206 | };
|
1207 | const getStyles = (options) => `.label {
|
1208 | font-family: ${options.fontFamily};
|
1209 | color: ${options.nodeTextColor || options.textColor};
|
1210 | }
|
1211 | .cluster-label text {
|
1212 | fill: ${options.titleColor};
|
1213 | }
|
1214 | .cluster-label span,p {
|
1215 | color: ${options.titleColor};
|
1216 | }
|
1217 |
|
1218 |
|
1219 |
|
1220 | .label text,span,p {
|
1221 | fill: ${options.nodeTextColor || options.textColor};
|
1222 | color: ${options.nodeTextColor || options.textColor};
|
1223 | }
|
1224 |
|
1225 | .node rect,
|
1226 | .node circle,
|
1227 | .node ellipse,
|
1228 | .node polygon,
|
1229 | .node path {
|
1230 | fill: ${options.mainBkg};
|
1231 | stroke: ${options.nodeBorder};
|
1232 | stroke-width: 1px;
|
1233 | }
|
1234 | .flowchart-label text {
|
1235 | text-anchor: middle;
|
1236 | }
|
1237 | // .flowchart-label .text-outer-tspan {
|
1238 | // text-anchor: middle;
|
1239 | // }
|
1240 | // .flowchart-label .text-inner-tspan {
|
1241 | // text-anchor: start;
|
1242 | // }
|
1243 |
|
1244 | .node .label {
|
1245 | text-align: center;
|
1246 | }
|
1247 | .node.clickable {
|
1248 | cursor: pointer;
|
1249 | }
|
1250 |
|
1251 | .arrowheadPath {
|
1252 | fill: ${options.arrowheadColor};
|
1253 | }
|
1254 |
|
1255 | .edgePath .path {
|
1256 | stroke: ${options.lineColor};
|
1257 | stroke-width: 2.0px;
|
1258 | }
|
1259 |
|
1260 | .flowchart-link {
|
1261 | stroke: ${options.lineColor};
|
1262 | fill: none;
|
1263 | }
|
1264 |
|
1265 | .edgeLabel {
|
1266 | background-color: ${options.edgeLabelBackground};
|
1267 | rect {
|
1268 | opacity: 0.5;
|
1269 | background-color: ${options.edgeLabelBackground};
|
1270 | fill: ${options.edgeLabelBackground};
|
1271 | }
|
1272 | text-align: center;
|
1273 | }
|
1274 |
|
1275 | /* For html labels only */
|
1276 | .labelBkg {
|
1277 | background-color: ${fade(options.edgeLabelBackground, 0.5)};
|
1278 | // background-color:
|
1279 | }
|
1280 |
|
1281 | .node .cluster {
|
1282 | // fill: ${fade(options.mainBkg, 0.5)};
|
1283 | fill: ${fade(options.clusterBkg, 0.5)};
|
1284 | stroke: ${fade(options.clusterBorder, 0.2)};
|
1285 | box-shadow: rgba(50, 50, 93, 0.25) 0px 13px 27px -5px, rgba(0, 0, 0, 0.3) 0px 8px 16px -8px;
|
1286 | stroke-width: 1px;
|
1287 | }
|
1288 |
|
1289 | .cluster text {
|
1290 | fill: ${options.titleColor};
|
1291 | }
|
1292 |
|
1293 | .cluster span,p {
|
1294 | color: ${options.titleColor};
|
1295 | }
|
1296 | /* .cluster div {
|
1297 | color: ${options.titleColor};
|
1298 | } */
|
1299 |
|
1300 | div.mermaidTooltip {
|
1301 | position: absolute;
|
1302 | text-align: center;
|
1303 | max-width: 200px;
|
1304 | padding: 2px;
|
1305 | font-family: ${options.fontFamily};
|
1306 | font-size: 12px;
|
1307 | background: ${options.tertiaryColor};
|
1308 | border: 1px solid ${options.border2};
|
1309 | border-radius: 2px;
|
1310 | pointer-events: none;
|
1311 | z-index: 100;
|
1312 | }
|
1313 |
|
1314 | .flowchartTitleText {
|
1315 | text-anchor: middle;
|
1316 | font-size: 18px;
|
1317 | fill: ${options.textColor};
|
1318 | }
|
1319 | `;
|
1320 | const flowStyles = getStyles;
|
1321 | function getNodeFromBlock(block, db2, positioned = false) {
|
1322 | var _a2, _b2, _c;
|
1323 | const vertex = block;
|
1324 | let classStr = "default";
|
1325 | if ((((_a2 = vertex == null ? void 0 : vertex.classes) == null ? void 0 : _a2.length) || 0) > 0) {
|
1326 | classStr = ((vertex == null ? void 0 : vertex.classes) || []).join(" ");
|
1327 | }
|
1328 | classStr = classStr + " flowchart-label";
|
1329 | let radius = 0;
|
1330 | let shape = "";
|
1331 | let padding2;
|
1332 | switch (vertex.type) {
|
1333 | case "round":
|
1334 | radius = 5;
|
1335 | shape = "rect";
|
1336 | break;
|
1337 | case "composite":
|
1338 | radius = 0;
|
1339 | shape = "composite";
|
1340 | padding2 = 0;
|
1341 | break;
|
1342 | case "square":
|
1343 | shape = "rect";
|
1344 | break;
|
1345 | case "diamond":
|
1346 | shape = "question";
|
1347 | break;
|
1348 | case "hexagon":
|
1349 | shape = "hexagon";
|
1350 | break;
|
1351 | case "block_arrow":
|
1352 | shape = "block_arrow";
|
1353 | break;
|
1354 | case "odd":
|
1355 | shape = "rect_left_inv_arrow";
|
1356 | break;
|
1357 | case "lean_right":
|
1358 | shape = "lean_right";
|
1359 | break;
|
1360 | case "lean_left":
|
1361 | shape = "lean_left";
|
1362 | break;
|
1363 | case "trapezoid":
|
1364 | shape = "trapezoid";
|
1365 | break;
|
1366 | case "inv_trapezoid":
|
1367 | shape = "inv_trapezoid";
|
1368 | break;
|
1369 | case "rect_left_inv_arrow":
|
1370 | shape = "rect_left_inv_arrow";
|
1371 | break;
|
1372 | case "circle":
|
1373 | shape = "circle";
|
1374 | break;
|
1375 | case "ellipse":
|
1376 | shape = "ellipse";
|
1377 | break;
|
1378 | case "stadium":
|
1379 | shape = "stadium";
|
1380 | break;
|
1381 | case "subroutine":
|
1382 | shape = "subroutine";
|
1383 | break;
|
1384 | case "cylinder":
|
1385 | shape = "cylinder";
|
1386 | break;
|
1387 | case "group":
|
1388 | shape = "rect";
|
1389 | break;
|
1390 | case "doublecircle":
|
1391 | shape = "doublecircle";
|
1392 | break;
|
1393 | default:
|
1394 | shape = "rect";
|
1395 | }
|
1396 | const styles = getStylesFromArray((vertex == null ? void 0 : vertex.styles) || []);
|
1397 | const vertexText = vertex.label;
|
1398 | const bounds = vertex.size || { width: 0, height: 0, x: 0, y: 0 };
|
1399 | const node = {
|
1400 | labelStyle: styles.labelStyle,
|
1401 | shape,
|
1402 | labelText: vertexText,
|
1403 | rx: radius,
|
1404 | ry: radius,
|
1405 | class: classStr,
|
1406 | style: styles.style,
|
1407 | id: vertex.id,
|
1408 | directions: vertex.directions,
|
1409 | width: bounds.width,
|
1410 | height: bounds.height,
|
1411 | x: bounds.x,
|
1412 | y: bounds.y,
|
1413 | positioned,
|
1414 | intersect: void 0,
|
1415 | type: vertex.type,
|
1416 | padding: padding2 ?? (((_c = (_b2 = getConfig$1()) == null ? void 0 : _b2.block) == null ? void 0 : _c.padding) || 0)
|
1417 | };
|
1418 | return node;
|
1419 | }
|
1420 | async function calculateBlockSize(elem, block, db2) {
|
1421 | const node = getNodeFromBlock(block, db2, false);
|
1422 | if (node.type === "group") {
|
1423 | return;
|
1424 | }
|
1425 | const nodeEl = await insertNode(elem, node);
|
1426 | const boundingBox = nodeEl.node().getBBox();
|
1427 | const obj = db2.getBlock(node.id);
|
1428 | obj.size = { width: boundingBox.width, height: boundingBox.height, x: 0, y: 0, node: nodeEl };
|
1429 | db2.setBlock(obj);
|
1430 | nodeEl.remove();
|
1431 | }
|
1432 | async function insertBlockPositioned(elem, block, db2) {
|
1433 | const node = getNodeFromBlock(block, db2, true);
|
1434 | const obj = db2.getBlock(node.id);
|
1435 | if (obj.type !== "space") {
|
1436 | await insertNode(elem, node);
|
1437 | block.intersect = node == null ? void 0 : node.intersect;
|
1438 | positionNode(node);
|
1439 | }
|
1440 | }
|
1441 | async function performOperations(elem, blocks2, db2, operation) {
|
1442 | for (const block of blocks2) {
|
1443 | await operation(elem, block, db2);
|
1444 | if (block.children) {
|
1445 | await performOperations(elem, block.children, db2, operation);
|
1446 | }
|
1447 | }
|
1448 | }
|
1449 | async function calculateBlockSizes(elem, blocks2, db2) {
|
1450 | await performOperations(elem, blocks2, db2, calculateBlockSize);
|
1451 | }
|
1452 | async function insertBlocks(elem, blocks2, db2) {
|
1453 | await performOperations(elem, blocks2, db2, insertBlockPositioned);
|
1454 | }
|
1455 | async function insertEdges(elem, edges, blocks2, db2, id) {
|
1456 | const g = new graphlib.Graph({
|
1457 | multigraph: true,
|
1458 | compound: true
|
1459 | });
|
1460 | g.setGraph({
|
1461 | rankdir: "TB",
|
1462 | nodesep: 10,
|
1463 | ranksep: 10,
|
1464 | marginx: 8,
|
1465 | marginy: 8
|
1466 | });
|
1467 | for (const block of blocks2) {
|
1468 | if (block.size) {
|
1469 | g.setNode(block.id, {
|
1470 | width: block.size.width,
|
1471 | height: block.size.height,
|
1472 | intersect: block.intersect
|
1473 | });
|
1474 | }
|
1475 | }
|
1476 | for (const edge of edges) {
|
1477 | if (edge.start && edge.end) {
|
1478 | const startBlock = db2.getBlock(edge.start);
|
1479 | const endBlock = db2.getBlock(edge.end);
|
1480 | if ((startBlock == null ? void 0 : startBlock.size) && (endBlock == null ? void 0 : endBlock.size)) {
|
1481 | const start = startBlock.size;
|
1482 | const end = endBlock.size;
|
1483 | const points = [
|
1484 | { x: start.x, y: start.y },
|
1485 | { x: start.x + (end.x - start.x) / 2, y: start.y + (end.y - start.y) / 2 },
|
1486 | { x: end.x, y: end.y }
|
1487 | ];
|
1488 | await insertEdge(
|
1489 | elem,
|
1490 | { v: edge.start, w: edge.end, name: edge.id },
|
1491 | {
|
1492 | ...edge,
|
1493 | arrowTypeEnd: edge.arrowTypeEnd,
|
1494 | arrowTypeStart: edge.arrowTypeStart,
|
1495 | points,
|
1496 | classes: "edge-thickness-normal edge-pattern-solid flowchart-link LS-a1 LE-b1"
|
1497 | },
|
1498 | void 0,
|
1499 | "block",
|
1500 | g,
|
1501 | id
|
1502 | );
|
1503 | if (edge.label) {
|
1504 | await insertEdgeLabel(elem, {
|
1505 | ...edge,
|
1506 | label: edge.label,
|
1507 | labelStyle: "stroke: #333; stroke-width: 1.5px;fill:none;",
|
1508 | arrowTypeEnd: edge.arrowTypeEnd,
|
1509 | arrowTypeStart: edge.arrowTypeStart,
|
1510 | points,
|
1511 | classes: "edge-thickness-normal edge-pattern-solid flowchart-link LS-a1 LE-b1"
|
1512 | });
|
1513 | await positionEdgeLabel(
|
1514 | { ...edge, x: points[1].x, y: points[1].y },
|
1515 | {
|
1516 | originalPath: points
|
1517 | }
|
1518 | );
|
1519 | }
|
1520 | }
|
1521 | }
|
1522 | }
|
1523 | }
|
1524 | const padding = ((_b = (_a = getConfig()) == null ? void 0 : _a.block) == null ? void 0 : _b.padding) || 8;
|
1525 | function calculateBlockPosition(columns, position) {
|
1526 | if (columns === 0 || !Number.isInteger(columns)) {
|
1527 | throw new Error("Columns must be an integer !== 0.");
|
1528 | }
|
1529 | if (position < 0 || !Number.isInteger(position)) {
|
1530 | throw new Error("Position must be a non-negative integer." + position);
|
1531 | }
|
1532 | if (columns < 0) {
|
1533 | return { px: position, py: 0 };
|
1534 | }
|
1535 | if (columns === 1) {
|
1536 | return { px: 0, py: position };
|
1537 | }
|
1538 | const px = position % columns;
|
1539 | const py = Math.floor(position / columns);
|
1540 | return { px, py };
|
1541 | }
|
1542 | const getMaxChildSize = (block) => {
|
1543 | let maxWidth = 0;
|
1544 | let maxHeight = 0;
|
1545 | for (const child of block.children) {
|
1546 | const { width, height, x, y } = child.size || { width: 0, height: 0, x: 0, y: 0 };
|
1547 | log.debug(
|
1548 | "getMaxChildSize abc95 child:",
|
1549 | child.id,
|
1550 | "width:",
|
1551 | width,
|
1552 | "height:",
|
1553 | height,
|
1554 | "x:",
|
1555 | x,
|
1556 | "y:",
|
1557 | y,
|
1558 | child.type
|
1559 | );
|
1560 | if (child.type === "space") {
|
1561 | continue;
|
1562 | }
|
1563 | if (width > maxWidth) {
|
1564 | maxWidth = width / (block.widthInColumns || 1);
|
1565 | }
|
1566 | if (height > maxHeight) {
|
1567 | maxHeight = height;
|
1568 | }
|
1569 | }
|
1570 | return { width: maxWidth, height: maxHeight };
|
1571 | };
|
1572 | function setBlockSizes(block, db2, siblingWidth = 0, siblingHeight = 0) {
|
1573 | var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
1574 | log.debug(
|
1575 | "setBlockSizes abc95 (start)",
|
1576 | block.id,
|
1577 | (_a2 = block == null ? void 0 : block.size) == null ? void 0 : _a2.x,
|
1578 | "block width =",
|
1579 | block == null ? void 0 : block.size,
|
1580 | "sieblingWidth",
|
1581 | siblingWidth
|
1582 | );
|
1583 | if (!((_b2 = block == null ? void 0 : block.size) == null ? void 0 : _b2.width)) {
|
1584 | block.size = {
|
1585 | width: siblingWidth,
|
1586 | height: siblingHeight,
|
1587 | x: 0,
|
1588 | y: 0
|
1589 | };
|
1590 | }
|
1591 | let maxWidth = 0;
|
1592 | let maxHeight = 0;
|
1593 | if (((_c = block.children) == null ? void 0 : _c.length) > 0) {
|
1594 | for (const child of block.children) {
|
1595 | setBlockSizes(child, db2);
|
1596 | }
|
1597 | const childSize = getMaxChildSize(block);
|
1598 | maxWidth = childSize.width;
|
1599 | maxHeight = childSize.height;
|
1600 | log.debug("setBlockSizes abc95 maxWidth of", block.id, ":s children is ", maxWidth, maxHeight);
|
1601 | for (const child of block.children) {
|
1602 | if (child.size) {
|
1603 | log.debug(
|
1604 | `abc95 Setting size of children of ${block.id} id=${child.id} ${maxWidth} ${maxHeight} ${child.size}`
|
1605 | );
|
1606 | child.size.width = maxWidth * (child.widthInColumns || 1) + padding * ((child.widthInColumns || 1) - 1);
|
1607 | child.size.height = maxHeight;
|
1608 | child.size.x = 0;
|
1609 | child.size.y = 0;
|
1610 | log.debug(
|
1611 | `abc95 updating size of ${block.id} children child:${child.id} maxWidth:${maxWidth} maxHeight:${maxHeight}`
|
1612 | );
|
1613 | }
|
1614 | }
|
1615 | for (const child of block.children) {
|
1616 | setBlockSizes(child, db2, maxWidth, maxHeight);
|
1617 | }
|
1618 | const columns = block.columns || -1;
|
1619 | let numItems = 0;
|
1620 | for (const child of block.children) {
|
1621 | numItems += child.widthInColumns || 1;
|
1622 | }
|
1623 | let xSize = block.children.length;
|
1624 | if (columns > 0 && columns < numItems) {
|
1625 | xSize = columns;
|
1626 | }
|
1627 | block.widthInColumns || 1;
|
1628 | const ySize = Math.ceil(numItems / xSize);
|
1629 | let width = xSize * (maxWidth + padding) + padding;
|
1630 | let height = ySize * (maxHeight + padding) + padding;
|
1631 | if (width < siblingWidth) {
|
1632 | log.debug(
|
1633 | `Detected to small siebling: abc95 ${block.id} sieblingWidth ${siblingWidth} sieblingHeight ${siblingHeight} width ${width}`
|
1634 | );
|
1635 | width = siblingWidth;
|
1636 | height = siblingHeight;
|
1637 | const childWidth = (siblingWidth - xSize * padding - padding) / xSize;
|
1638 | const childHeight = (siblingHeight - ySize * padding - padding) / ySize;
|
1639 | log.debug("Size indata abc88", block.id, "childWidth", childWidth, "maxWidth", maxWidth);
|
1640 | log.debug("Size indata abc88", block.id, "childHeight", childHeight, "maxHeight", maxHeight);
|
1641 | log.debug("Size indata abc88 xSize", xSize, "padding", padding);
|
1642 | for (const child of block.children) {
|
1643 | if (child.size) {
|
1644 | child.size.width = childWidth;
|
1645 | child.size.height = childHeight;
|
1646 | child.size.x = 0;
|
1647 | child.size.y = 0;
|
1648 | }
|
1649 | }
|
1650 | }
|
1651 | log.debug(
|
1652 | `abc95 (finale calc) ${block.id} xSize ${xSize} ySize ${ySize} columns ${columns}${block.children.length} width=${Math.max(width, ((_d = block.size) == null ? void 0 : _d.width) || 0)}`
|
1653 | );
|
1654 | if (width < (((_e = block == null ? void 0 : block.size) == null ? void 0 : _e.width) || 0)) {
|
1655 | width = ((_f = block == null ? void 0 : block.size) == null ? void 0 : _f.width) || 0;
|
1656 | const num = columns > 0 ? Math.min(block.children.length, columns) : block.children.length;
|
1657 | if (num > 0) {
|
1658 | const childWidth = (width - num * padding - padding) / num;
|
1659 | log.debug("abc95 (growing to fit) width", block.id, width, (_g = block.size) == null ? void 0 : _g.width, childWidth);
|
1660 | for (const child of block.children) {
|
1661 | if (child.size) {
|
1662 | child.size.width = childWidth;
|
1663 | }
|
1664 | }
|
1665 | }
|
1666 | }
|
1667 | block.size = {
|
1668 | width,
|
1669 | height,
|
1670 | x: 0,
|
1671 | y: 0
|
1672 | };
|
1673 | }
|
1674 | log.debug(
|
1675 | "setBlockSizes abc94 (done)",
|
1676 | block.id,
|
1677 | (_h = block == null ? void 0 : block.size) == null ? void 0 : _h.x,
|
1678 | (_i = block == null ? void 0 : block.size) == null ? void 0 : _i.width,
|
1679 | (_j = block == null ? void 0 : block.size) == null ? void 0 : _j.y,
|
1680 | (_k = block == null ? void 0 : block.size) == null ? void 0 : _k.height
|
1681 | );
|
1682 | }
|
1683 | function layoutBlocks(block, db2) {
|
1684 | var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
1685 | log.debug(
|
1686 | `abc85 layout blocks (=>layoutBlocks) ${block.id} x: ${(_a2 = block == null ? void 0 : block.size) == null ? void 0 : _a2.x} y: ${(_b2 = block == null ? void 0 : block.size) == null ? void 0 : _b2.y} width: ${(_c = block == null ? void 0 : block.size) == null ? void 0 : _c.width}`
|
1687 | );
|
1688 | const columns = block.columns || -1;
|
1689 | log.debug("layoutBlocks columns abc95", block.id, "=>", columns, block);
|
1690 | if (block.children &&
|
1691 | block.children.length > 0) {
|
1692 | const width = ((_e = (_d = block == null ? void 0 : block.children[0]) == null ? void 0 : _d.size) == null ? void 0 : _e.width) || 0;
|
1693 | const widthOfChildren = block.children.length * width + (block.children.length - 1) * padding;
|
1694 | log.debug("widthOfChildren 88", widthOfChildren, "posX");
|
1695 | let columnPos = 0;
|
1696 | log.debug("abc91 block?.size?.x", block.id, (_f = block == null ? void 0 : block.size) == null ? void 0 : _f.x);
|
1697 | let startingPosX = ((_g = block == null ? void 0 : block.size) == null ? void 0 : _g.x) ? ((_h = block == null ? void 0 : block.size) == null ? void 0 : _h.x) + (-((_i = block == null ? void 0 : block.size) == null ? void 0 : _i.width) / 2 || 0) : -padding;
|
1698 | let rowPos = 0;
|
1699 | for (const child of block.children) {
|
1700 | const parent = block;
|
1701 | if (!child.size) {
|
1702 | continue;
|
1703 | }
|
1704 | const { width: width2, height } = child.size;
|
1705 | const { px, py } = calculateBlockPosition(columns, columnPos);
|
1706 | if (py != rowPos) {
|
1707 | rowPos = py;
|
1708 | startingPosX = ((_j = block == null ? void 0 : block.size) == null ? void 0 : _j.x) ? ((_k = block == null ? void 0 : block.size) == null ? void 0 : _k.x) + (-((_l = block == null ? void 0 : block.size) == null ? void 0 : _l.width) / 2 || 0) : -padding;
|
1709 | log.debug("New row in layout for block", block.id, " and child ", child.id, rowPos);
|
1710 | }
|
1711 | log.debug(
|
1712 | `abc89 layout blocks (child) id: ${child.id} Pos: ${columnPos} (px, py) ${px},${py} (${(_m = parent == null ? void 0 : parent.size) == null ? void 0 : _m.x},${(_n = parent == null ? void 0 : parent.size) == null ? void 0 : _n.y}) parent: ${parent.id} width: ${width2}${padding}`
|
1713 | );
|
1714 | if (parent.size) {
|
1715 | const halfWidth = width2 / 2;
|
1716 | child.size.x = startingPosX + padding + halfWidth;
|
1717 | log.debug(
|
1718 | `abc91 layout blocks (calc) px, pyid:${child.id} startingPos=X${startingPosX} new startingPosX${child.size.x} ${halfWidth} padding=${padding} width=${width2} halfWidth=${halfWidth} => x:${child.size.x} y:${child.size.y} ${child.widthInColumns} (width * (child?.w || 1)) / 2 ${width2 * ((child == null ? void 0 : child.widthInColumns) || 1) / 2}`
|
1719 | );
|
1720 | startingPosX = child.size.x + halfWidth;
|
1721 | child.size.y = parent.size.y - parent.size.height / 2 + py * (height + padding) + height / 2 + padding;
|
1722 | log.debug(
|
1723 | `abc88 layout blocks (calc) px, pyid:${child.id}startingPosX${startingPosX}${padding}${halfWidth}=>x:${child.size.x}y:${child.size.y}${child.widthInColumns}(width * (child?.w || 1)) / 2${width2 * ((child == null ? void 0 : child.widthInColumns) || 1) / 2}`
|
1724 | );
|
1725 | }
|
1726 | if (child.children) {
|
1727 | layoutBlocks(child);
|
1728 | }
|
1729 | columnPos += (child == null ? void 0 : child.widthInColumns) || 1;
|
1730 | log.debug("abc88 columnsPos", child, columnPos);
|
1731 | }
|
1732 | }
|
1733 | log.debug(
|
1734 | `layout blocks (<==layoutBlocks) ${block.id} x: ${(_o = block == null ? void 0 : block.size) == null ? void 0 : _o.x} y: ${(_p = block == null ? void 0 : block.size) == null ? void 0 : _p.y} width: ${(_q = block == null ? void 0 : block.size) == null ? void 0 : _q.width}`
|
1735 | );
|
1736 | }
|
1737 | function findBounds(block, { minX, minY, maxX, maxY } = { minX: 0, minY: 0, maxX: 0, maxY: 0 }) {
|
1738 | if (block.size && block.id !== "root") {
|
1739 | const { x, y, width, height } = block.size;
|
1740 | if (x - width / 2 < minX) {
|
1741 | minX = x - width / 2;
|
1742 | }
|
1743 | if (y - height / 2 < minY) {
|
1744 | minY = y - height / 2;
|
1745 | }
|
1746 | if (x + width / 2 > maxX) {
|
1747 | maxX = x + width / 2;
|
1748 | }
|
1749 | if (y + height / 2 > maxY) {
|
1750 | maxY = y + height / 2;
|
1751 | }
|
1752 | }
|
1753 | if (block.children) {
|
1754 | for (const child of block.children) {
|
1755 | ({ minX, minY, maxX, maxY } = findBounds(child, { minX, minY, maxX, maxY }));
|
1756 | }
|
1757 | }
|
1758 | return { minX, minY, maxX, maxY };
|
1759 | }
|
1760 | function layout(db2) {
|
1761 | const root = db2.getBlock("root");
|
1762 | if (!root) {
|
1763 | return;
|
1764 | }
|
1765 | setBlockSizes(root, db2, 0, 0);
|
1766 | layoutBlocks(root);
|
1767 | log.debug("getBlocks", JSON.stringify(root, null, 2));
|
1768 | const { minX, minY, maxX, maxY } = findBounds(root);
|
1769 | const height = maxY - minY;
|
1770 | const width = maxX - minX;
|
1771 | return { x: minX, y: minY, width, height };
|
1772 | }
|
1773 | const getClasses = function(text, diagObj) {
|
1774 | return diagObj.db.getClasses();
|
1775 | };
|
1776 | const draw = async function(text, id, _version, diagObj) {
|
1777 | const { securityLevel, block: conf } = getConfig$1();
|
1778 | const db2 = diagObj.db;
|
1779 | let sandboxElement;
|
1780 | if (securityLevel === "sandbox") {
|
1781 | sandboxElement = select("#i" + id);
|
1782 | }
|
1783 | const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
|
1784 | const svg = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : select(`[id="${id}"]`);
|
1785 | const markers = ["point", "circle", "cross"];
|
1786 | insertMarkers(svg, markers, diagObj.type, id);
|
1787 | const bl = db2.getBlocks();
|
1788 | const blArr = db2.getBlocksFlat();
|
1789 | const edges = db2.getEdges();
|
1790 | const nodes = svg.insert("g").attr("class", "block");
|
1791 | await calculateBlockSizes(nodes, bl, db2);
|
1792 | const bounds = layout(db2);
|
1793 | await insertBlocks(nodes, bl, db2);
|
1794 | await insertEdges(nodes, edges, blArr, db2, id);
|
1795 | if (bounds) {
|
1796 | const bounds2 = bounds;
|
1797 | const magicFactor = Math.max(1, Math.round(0.125 * (bounds2.width / bounds2.height)));
|
1798 | const height = bounds2.height + magicFactor + 10;
|
1799 | const width = bounds2.width + 10;
|
1800 | const { useMaxWidth } = conf;
|
1801 | configureSvgSize(svg, height, width, !!useMaxWidth);
|
1802 | log.debug("Here Bounds", bounds, bounds2);
|
1803 | svg.attr(
|
1804 | "viewBox",
|
1805 | `${bounds2.x - 5} ${bounds2.y - 5} ${bounds2.width + 10} ${bounds2.height + 10}`
|
1806 | );
|
1807 | }
|
1808 | scaleOrdinal(schemeTableau10);
|
1809 | };
|
1810 | const renderer = {
|
1811 | draw,
|
1812 | getClasses
|
1813 | };
|
1814 | const diagram = {
|
1815 | parser: parser$1,
|
1816 | db: db$1,
|
1817 | renderer,
|
1818 | styles: flowStyles
|
1819 | };
|
1820 | export {
|
1821 | diagram
|
1822 | };
|