UNPKG

42.4 kBJavaScriptView Raw
1import { c as getConfig, z as setDiagramTitle, A as getDiagramTitle, s as setAccTitle, g as getAccTitle, b as setAccDescription, a as getAccDescription, m as mermaidAPI, B as clear$1, j as select, k as configureSvgSize } from "./mermaid-4b4b971d.js";
2import { d as drawRect$1, f as drawText$1, a as drawBackgroundRect$1, g as getNoteRect } from "./svgDrawCommon-ca4e6afc.js";
3import { d as d3arc } from "./arc-ec6eac64.js";
4import "./constant-b644328d.js";
5var parser = function() {
6 var o = function(k, v, o2, l) {
7 for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v)
8 ;
9 return o2;
10 }, $V0 = [1, 2], $V1 = [1, 5], $V2 = [6, 9, 11, 17, 18, 20, 22, 23, 24, 26], $V3 = [1, 15], $V4 = [1, 16], $V5 = [1, 17], $V6 = [1, 18], $V7 = [1, 19], $V8 = [1, 20], $V9 = [1, 24], $Va = [4, 6, 9, 11, 17, 18, 20, 22, 23, 24, 26];
11 var parser2 = {
12 trace: function trace() {
13 },
14 yy: {},
15 symbols_: { "error": 2, "start": 3, "journey": 4, "document": 5, "EOF": 6, "directive": 7, "line": 8, "SPACE": 9, "statement": 10, "NEWLINE": 11, "openDirective": 12, "typeDirective": 13, "closeDirective": 14, ":": 15, "argDirective": 16, "title": 17, "acc_title": 18, "acc_title_value": 19, "acc_descr": 20, "acc_descr_value": 21, "acc_descr_multiline_value": 22, "section": 23, "taskName": 24, "taskData": 25, "open_directive": 26, "type_directive": 27, "arg_directive": 28, "close_directive": 29, "$accept": 0, "$end": 1 },
16 terminals_: { 2: "error", 4: "journey", 6: "EOF", 9: "SPACE", 11: "NEWLINE", 15: ":", 17: "title", 18: "acc_title", 19: "acc_title_value", 20: "acc_descr", 21: "acc_descr_value", 22: "acc_descr_multiline_value", 23: "section", 24: "taskName", 25: "taskData", 26: "open_directive", 27: "type_directive", 28: "arg_directive", 29: "close_directive" },
17 productions_: [0, [3, 3], [3, 2], [5, 0], [5, 2], [8, 2], [8, 1], [8, 1], [8, 1], [7, 4], [7, 6], [10, 1], [10, 2], [10, 2], [10, 1], [10, 1], [10, 2], [10, 1], [12, 1], [13, 1], [16, 1], [14, 1]],
18 performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
19 var $0 = $$.length - 1;
20 switch (yystate) {
21 case 1:
22 return $$[$0 - 1];
23 case 3:
24 this.$ = [];
25 break;
26 case 4:
27 $$[$0 - 1].push($$[$0]);
28 this.$ = $$[$0 - 1];
29 break;
30 case 5:
31 case 6:
32 this.$ = $$[$0];
33 break;
34 case 7:
35 case 8:
36 this.$ = [];
37 break;
38 case 11:
39 yy.setDiagramTitle($$[$0].substr(6));
40 this.$ = $$[$0].substr(6);
41 break;
42 case 12:
43 this.$ = $$[$0].trim();
44 yy.setAccTitle(this.$);
45 break;
46 case 13:
47 case 14:
48 this.$ = $$[$0].trim();
49 yy.setAccDescription(this.$);
50 break;
51 case 15:
52 yy.addSection($$[$0].substr(8));
53 this.$ = $$[$0].substr(8);
54 break;
55 case 16:
56 yy.addTask($$[$0 - 1], $$[$0]);
57 this.$ = "task";
58 break;
59 case 18:
60 yy.parseDirective("%%{", "open_directive");
61 break;
62 case 19:
63 yy.parseDirective($$[$0], "type_directive");
64 break;
65 case 20:
66 $$[$0] = $$[$0].trim().replace(/'/g, '"');
67 yy.parseDirective($$[$0], "arg_directive");
68 break;
69 case 21:
70 yy.parseDirective("}%%", "close_directive", "journey");
71 break;
72 }
73 },
74 table: [{ 3: 1, 4: $V0, 7: 3, 12: 4, 26: $V1 }, { 1: [3] }, o($V2, [2, 3], { 5: 6 }), { 3: 7, 4: $V0, 7: 3, 12: 4, 26: $V1 }, { 13: 8, 27: [1, 9] }, { 27: [2, 18] }, { 6: [1, 10], 7: 21, 8: 11, 9: [1, 12], 10: 13, 11: [1, 14], 12: 4, 17: $V3, 18: $V4, 20: $V5, 22: $V6, 23: $V7, 24: $V8, 26: $V1 }, { 1: [2, 2] }, { 14: 22, 15: [1, 23], 29: $V9 }, o([15, 29], [2, 19]), o($V2, [2, 8], { 1: [2, 1] }), o($V2, [2, 4]), { 7: 21, 10: 25, 12: 4, 17: $V3, 18: $V4, 20: $V5, 22: $V6, 23: $V7, 24: $V8, 26: $V1 }, o($V2, [2, 6]), o($V2, [2, 7]), o($V2, [2, 11]), { 19: [1, 26] }, { 21: [1, 27] }, o($V2, [2, 14]), o($V2, [2, 15]), { 25: [1, 28] }, o($V2, [2, 17]), { 11: [1, 29] }, { 16: 30, 28: [1, 31] }, { 11: [2, 21] }, o($V2, [2, 5]), o($V2, [2, 12]), o($V2, [2, 13]), o($V2, [2, 16]), o($Va, [2, 9]), { 14: 32, 29: $V9 }, { 29: [2, 20] }, { 11: [1, 33] }, o($Va, [2, 10])],
75 defaultActions: { 5: [2, 18], 7: [2, 2], 24: [2, 21], 31: [2, 20] },
76 parseError: function parseError(str, hash) {
77 if (hash.recoverable) {
78 this.trace(str);
79 } else {
80 var error = new Error(str);
81 error.hash = hash;
82 throw error;
83 }
84 },
85 parse: function parse(input) {
86 var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
87 var args = lstack.slice.call(arguments, 1);
88 var lexer2 = Object.create(this.lexer);
89 var sharedState = { yy: {} };
90 for (var k in this.yy) {
91 if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
92 sharedState.yy[k] = this.yy[k];
93 }
94 }
95 lexer2.setInput(input, sharedState.yy);
96 sharedState.yy.lexer = lexer2;
97 sharedState.yy.parser = this;
98 if (typeof lexer2.yylloc == "undefined") {
99 lexer2.yylloc = {};
100 }
101 var yyloc = lexer2.yylloc;
102 lstack.push(yyloc);
103 var ranges = lexer2.options && lexer2.options.ranges;
104 if (typeof sharedState.yy.parseError === "function") {
105 this.parseError = sharedState.yy.parseError;
106 } else {
107 this.parseError = Object.getPrototypeOf(this).parseError;
108 }
109 function lex() {
110 var token;
111 token = tstack.pop() || lexer2.lex() || EOF;
112 if (typeof token !== "number") {
113 if (token instanceof Array) {
114 tstack = token;
115 token = tstack.pop();
116 }
117 token = self.symbols_[token] || token;
118 }
119 return token;
120 }
121 var symbol, state, action, r, yyval = {}, p, len, newState, expected;
122 while (true) {
123 state = stack[stack.length - 1];
124 if (this.defaultActions[state]) {
125 action = this.defaultActions[state];
126 } else {
127 if (symbol === null || typeof symbol == "undefined") {
128 symbol = lex();
129 }
130 action = table[state] && table[state][symbol];
131 }
132 if (typeof action === "undefined" || !action.length || !action[0]) {
133 var errStr = "";
134 expected = [];
135 for (p in table[state]) {
136 if (this.terminals_[p] && p > TERROR) {
137 expected.push("'" + this.terminals_[p] + "'");
138 }
139 }
140 if (lexer2.showPosition) {
141 errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
142 } else {
143 errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
144 }
145 this.parseError(errStr, {
146 text: lexer2.match,
147 token: this.terminals_[symbol] || symbol,
148 line: lexer2.yylineno,
149 loc: yyloc,
150 expected
151 });
152 }
153 if (action[0] instanceof Array && action.length > 1) {
154 throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
155 }
156 switch (action[0]) {
157 case 1:
158 stack.push(symbol);
159 vstack.push(lexer2.yytext);
160 lstack.push(lexer2.yylloc);
161 stack.push(action[1]);
162 symbol = null;
163 {
164 yyleng = lexer2.yyleng;
165 yytext = lexer2.yytext;
166 yylineno = lexer2.yylineno;
167 yyloc = lexer2.yylloc;
168 }
169 break;
170 case 2:
171 len = this.productions_[action[1]][1];
172 yyval.$ = vstack[vstack.length - len];
173 yyval._$ = {
174 first_line: lstack[lstack.length - (len || 1)].first_line,
175 last_line: lstack[lstack.length - 1].last_line,
176 first_column: lstack[lstack.length - (len || 1)].first_column,
177 last_column: lstack[lstack.length - 1].last_column
178 };
179 if (ranges) {
180 yyval._$.range = [
181 lstack[lstack.length - (len || 1)].range[0],
182 lstack[lstack.length - 1].range[1]
183 ];
184 }
185 r = this.performAction.apply(yyval, [
186 yytext,
187 yyleng,
188 yylineno,
189 sharedState.yy,
190 action[1],
191 vstack,
192 lstack
193 ].concat(args));
194 if (typeof r !== "undefined") {
195 return r;
196 }
197 if (len) {
198 stack = stack.slice(0, -1 * len * 2);
199 vstack = vstack.slice(0, -1 * len);
200 lstack = lstack.slice(0, -1 * len);
201 }
202 stack.push(this.productions_[action[1]][0]);
203 vstack.push(yyval.$);
204 lstack.push(yyval._$);
205 newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
206 stack.push(newState);
207 break;
208 case 3:
209 return true;
210 }
211 }
212 return true;
213 }
214 };
215 var lexer = function() {
216 var lexer2 = {
217 EOF: 1,
218 parseError: function parseError(str, hash) {
219 if (this.yy.parser) {
220 this.yy.parser.parseError(str, hash);
221 } else {
222 throw new Error(str);
223 }
224 },
225 // resets the lexer, sets new input
226 setInput: function(input, yy) {
227 this.yy = yy || this.yy || {};
228 this._input = input;
229 this._more = this._backtrack = this.done = false;
230 this.yylineno = this.yyleng = 0;
231 this.yytext = this.matched = this.match = "";
232 this.conditionStack = ["INITIAL"];
233 this.yylloc = {
234 first_line: 1,
235 first_column: 0,
236 last_line: 1,
237 last_column: 0
238 };
239 if (this.options.ranges) {
240 this.yylloc.range = [0, 0];
241 }
242 this.offset = 0;
243 return this;
244 },
245 // consumes and returns one char from the input
246 input: function() {
247 var ch = this._input[0];
248 this.yytext += ch;
249 this.yyleng++;
250 this.offset++;
251 this.match += ch;
252 this.matched += ch;
253 var lines = ch.match(/(?:\r\n?|\n).*/g);
254 if (lines) {
255 this.yylineno++;
256 this.yylloc.last_line++;
257 } else {
258 this.yylloc.last_column++;
259 }
260 if (this.options.ranges) {
261 this.yylloc.range[1]++;
262 }
263 this._input = this._input.slice(1);
264 return ch;
265 },
266 // unshifts one char (or a string) into the input
267 unput: function(ch) {
268 var len = ch.length;
269 var lines = ch.split(/(?:\r\n?|\n)/g);
270 this._input = ch + this._input;
271 this.yytext = this.yytext.substr(0, this.yytext.length - len);
272 this.offset -= len;
273 var oldLines = this.match.split(/(?:\r\n?|\n)/g);
274 this.match = this.match.substr(0, this.match.length - 1);
275 this.matched = this.matched.substr(0, this.matched.length - 1);
276 if (lines.length - 1) {
277 this.yylineno -= lines.length - 1;
278 }
279 var r = this.yylloc.range;
280 this.yylloc = {
281 first_line: this.yylloc.first_line,
282 last_line: this.yylineno + 1,
283 first_column: this.yylloc.first_column,
284 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
285 };
286 if (this.options.ranges) {
287 this.yylloc.range = [r[0], r[0] + this.yyleng - len];
288 }
289 this.yyleng = this.yytext.length;
290 return this;
291 },
292 // When called from action, caches matched text and appends it on next action
293 more: function() {
294 this._more = true;
295 return this;
296 },
297 // 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.
298 reject: function() {
299 if (this.options.backtrack_lexer) {
300 this._backtrack = true;
301 } else {
302 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(), {
303 text: "",
304 token: null,
305 line: this.yylineno
306 });
307 }
308 return this;
309 },
310 // retain first n characters of the match
311 less: function(n) {
312 this.unput(this.match.slice(n));
313 },
314 // displays already matched input, i.e. for error messages
315 pastInput: function() {
316 var past = this.matched.substr(0, this.matched.length - this.match.length);
317 return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
318 },
319 // displays upcoming input, i.e. for error messages
320 upcomingInput: function() {
321 var next = this.match;
322 if (next.length < 20) {
323 next += this._input.substr(0, 20 - next.length);
324 }
325 return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
326 },
327 // displays the character position where the lexing error occurred, i.e. for error messages
328 showPosition: function() {
329 var pre = this.pastInput();
330 var c = new Array(pre.length + 1).join("-");
331 return pre + this.upcomingInput() + "\n" + c + "^";
332 },
333 // test the lexed token: return FALSE when not a match, otherwise return token
334 test_match: function(match, indexed_rule) {
335 var token, lines, backup;
336 if (this.options.backtrack_lexer) {
337 backup = {
338 yylineno: this.yylineno,
339 yylloc: {
340 first_line: this.yylloc.first_line,
341 last_line: this.last_line,
342 first_column: this.yylloc.first_column,
343 last_column: this.yylloc.last_column
344 },
345 yytext: this.yytext,
346 match: this.match,
347 matches: this.matches,
348 matched: this.matched,
349 yyleng: this.yyleng,
350 offset: this.offset,
351 _more: this._more,
352 _input: this._input,
353 yy: this.yy,
354 conditionStack: this.conditionStack.slice(0),
355 done: this.done
356 };
357 if (this.options.ranges) {
358 backup.yylloc.range = this.yylloc.range.slice(0);
359 }
360 }
361 lines = match[0].match(/(?:\r\n?|\n).*/g);
362 if (lines) {
363 this.yylineno += lines.length;
364 }
365 this.yylloc = {
366 first_line: this.yylloc.last_line,
367 last_line: this.yylineno + 1,
368 first_column: this.yylloc.last_column,
369 last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
370 };
371 this.yytext += match[0];
372 this.match += match[0];
373 this.matches = match;
374 this.yyleng = this.yytext.length;
375 if (this.options.ranges) {
376 this.yylloc.range = [this.offset, this.offset += this.yyleng];
377 }
378 this._more = false;
379 this._backtrack = false;
380 this._input = this._input.slice(match[0].length);
381 this.matched += match[0];
382 token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
383 if (this.done && this._input) {
384 this.done = false;
385 }
386 if (token) {
387 return token;
388 } else if (this._backtrack) {
389 for (var k in backup) {
390 this[k] = backup[k];
391 }
392 return false;
393 }
394 return false;
395 },
396 // return next match in input
397 next: function() {
398 if (this.done) {
399 return this.EOF;
400 }
401 if (!this._input) {
402 this.done = true;
403 }
404 var token, match, tempMatch, index;
405 if (!this._more) {
406 this.yytext = "";
407 this.match = "";
408 }
409 var rules = this._currentRules();
410 for (var i = 0; i < rules.length; i++) {
411 tempMatch = this._input.match(this.rules[rules[i]]);
412 if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
413 match = tempMatch;
414 index = i;
415 if (this.options.backtrack_lexer) {
416 token = this.test_match(tempMatch, rules[i]);
417 if (token !== false) {
418 return token;
419 } else if (this._backtrack) {
420 match = false;
421 continue;
422 } else {
423 return false;
424 }
425 } else if (!this.options.flex) {
426 break;
427 }
428 }
429 }
430 if (match) {
431 token = this.test_match(match, rules[index]);
432 if (token !== false) {
433 return token;
434 }
435 return false;
436 }
437 if (this._input === "") {
438 return this.EOF;
439 } else {
440 return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
441 text: "",
442 token: null,
443 line: this.yylineno
444 });
445 }
446 },
447 // return next match that has a token
448 lex: function lex() {
449 var r = this.next();
450 if (r) {
451 return r;
452 } else {
453 return this.lex();
454 }
455 },
456 // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
457 begin: function begin(condition) {
458 this.conditionStack.push(condition);
459 },
460 // pop the previously active lexer condition state off the condition stack
461 popState: function popState() {
462 var n = this.conditionStack.length - 1;
463 if (n > 0) {
464 return this.conditionStack.pop();
465 } else {
466 return this.conditionStack[0];
467 }
468 },
469 // produce the lexer rule set which is active for the currently active lexer condition state
470 _currentRules: function _currentRules() {
471 if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
472 return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
473 } else {
474 return this.conditions["INITIAL"].rules;
475 }
476 },
477 // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
478 topState: function topState(n) {
479 n = this.conditionStack.length - 1 - Math.abs(n || 0);
480 if (n >= 0) {
481 return this.conditionStack[n];
482 } else {
483 return "INITIAL";
484 }
485 },
486 // alias for begin(condition)
487 pushState: function pushState(condition) {
488 this.begin(condition);
489 },
490 // return the number of states currently on the stack
491 stateStackSize: function stateStackSize() {
492 return this.conditionStack.length;
493 },
494 options: { "case-insensitive": true },
495 performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
496 switch ($avoiding_name_collisions) {
497 case 0:
498 this.begin("open_directive");
499 return 26;
500 case 1:
501 this.begin("type_directive");
502 return 27;
503 case 2:
504 this.popState();
505 this.begin("arg_directive");
506 return 15;
507 case 3:
508 this.popState();
509 this.popState();
510 return 29;
511 case 4:
512 return 28;
513 case 5:
514 break;
515 case 6:
516 break;
517 case 7:
518 return 11;
519 case 8:
520 break;
521 case 9:
522 break;
523 case 10:
524 return 4;
525 case 11:
526 return 17;
527 case 12:
528 this.begin("acc_title");
529 return 18;
530 case 13:
531 this.popState();
532 return "acc_title_value";
533 case 14:
534 this.begin("acc_descr");
535 return 20;
536 case 15:
537 this.popState();
538 return "acc_descr_value";
539 case 16:
540 this.begin("acc_descr_multiline");
541 break;
542 case 17:
543 this.popState();
544 break;
545 case 18:
546 return "acc_descr_multiline_value";
547 case 19:
548 return 23;
549 case 20:
550 return 24;
551 case 21:
552 return 25;
553 case 22:
554 return 15;
555 case 23:
556 return 6;
557 case 24:
558 return "INVALID";
559 }
560 },
561 rules: [/^(?:%%\{)/i, /^(?:((?:(?!\}%%)[^:.])*))/i, /^(?::)/i, /^(?:\}%%)/i, /^(?:((?:(?!\}%%).|\n)*))/i, /^(?:%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:journey\b)/i, /^(?:title\s[^#\n;]+)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:section\s[^#:\n;]+)/i, /^(?:[^#:\n;]+)/i, /^(?::[^#\n;]+)/i, /^(?::)/i, /^(?:$)/i, /^(?:.)/i],
562 conditions: { "open_directive": { "rules": [1], "inclusive": false }, "type_directive": { "rules": [2, 3], "inclusive": false }, "arg_directive": { "rules": [3, 4], "inclusive": false }, "acc_descr_multiline": { "rules": [17, 18], "inclusive": false }, "acc_descr": { "rules": [15], "inclusive": false }, "acc_title": { "rules": [13], "inclusive": false }, "INITIAL": { "rules": [0, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 19, 20, 21, 22, 23, 24], "inclusive": true } }
563 };
564 return lexer2;
565 }();
566 parser2.lexer = lexer;
567 function Parser() {
568 this.yy = {};
569 }
570 Parser.prototype = parser2;
571 parser2.Parser = Parser;
572 return new Parser();
573}();
574parser.parser = parser;
575const parser$1 = parser;
576let currentSection = "";
577const sections = [];
578const tasks = [];
579const rawTasks = [];
580const parseDirective = function(statement, context, type) {
581 mermaidAPI.parseDirective(this, statement, context, type);
582};
583const clear = function() {
584 sections.length = 0;
585 tasks.length = 0;
586 currentSection = "";
587 rawTasks.length = 0;
588 clear$1();
589};
590const addSection = function(txt) {
591 currentSection = txt;
592 sections.push(txt);
593};
594const getSections = function() {
595 return sections;
596};
597const getTasks = function() {
598 let allItemsProcessed = compileTasks();
599 const maxDepth = 100;
600 let iterationCount = 0;
601 while (!allItemsProcessed && iterationCount < maxDepth) {
602 allItemsProcessed = compileTasks();
603 iterationCount++;
604 }
605 tasks.push(...rawTasks);
606 return tasks;
607};
608const updateActors = function() {
609 const tempActors = [];
610 tasks.forEach((task) => {
611 if (task.people) {
612 tempActors.push(...task.people);
613 }
614 });
615 const unique = new Set(tempActors);
616 return [...unique].sort();
617};
618const addTask = function(descr, taskData) {
619 const pieces = taskData.substr(1).split(":");
620 let score = 0;
621 let peeps = [];
622 if (pieces.length === 1) {
623 score = Number(pieces[0]);
624 peeps = [];
625 } else {
626 score = Number(pieces[0]);
627 peeps = pieces[1].split(",");
628 }
629 const peopleList = peeps.map((s) => s.trim());
630 const rawTask = {
631 section: currentSection,
632 type: currentSection,
633 people: peopleList,
634 task: descr,
635 score
636 };
637 rawTasks.push(rawTask);
638};
639const addTaskOrg = function(descr) {
640 const newTask = {
641 section: currentSection,
642 type: currentSection,
643 description: descr,
644 task: descr,
645 classes: []
646 };
647 tasks.push(newTask);
648};
649const compileTasks = function() {
650 const compileTask = function(pos) {
651 return rawTasks[pos].processed;
652 };
653 let allProcessed = true;
654 for (const [i, rawTask] of rawTasks.entries()) {
655 compileTask(i);
656 allProcessed = allProcessed && rawTask.processed;
657 }
658 return allProcessed;
659};
660const getActors = function() {
661 return updateActors();
662};
663const db = {
664 parseDirective,
665 getConfig: () => getConfig().journey,
666 clear,
667 setDiagramTitle,
668 getDiagramTitle,
669 setAccTitle,
670 getAccTitle,
671 setAccDescription,
672 getAccDescription,
673 addSection,
674 getSections,
675 getTasks,
676 addTask,
677 addTaskOrg,
678 getActors
679};
680const getStyles = (options) => `.label {
681 font-family: 'trebuchet ms', verdana, arial, sans-serif;
682 font-family: var(--mermaid-font-family);
683 color: ${options.textColor};
684 }
685 .mouth {
686 stroke: #666;
687 }
688
689 line {
690 stroke: ${options.textColor}
691 }
692
693 .legend {
694 fill: ${options.textColor};
695 }
696
697 .label text {
698 fill: #333;
699 }
700 .label {
701 color: ${options.textColor}
702 }
703
704 .face {
705 ${options.faceColor ? `fill: ${options.faceColor}` : "fill: #FFF8DC"};
706 stroke: #999;
707 }
708
709 .node rect,
710 .node circle,
711 .node ellipse,
712 .node polygon,
713 .node path {
714 fill: ${options.mainBkg};
715 stroke: ${options.nodeBorder};
716 stroke-width: 1px;
717 }
718
719 .node .label {
720 text-align: center;
721 }
722 .node.clickable {
723 cursor: pointer;
724 }
725
726 .arrowheadPath {
727 fill: ${options.arrowheadColor};
728 }
729
730 .edgePath .path {
731 stroke: ${options.lineColor};
732 stroke-width: 1.5px;
733 }
734
735 .flowchart-link {
736 stroke: ${options.lineColor};
737 fill: none;
738 }
739
740 .edgeLabel {
741 background-color: ${options.edgeLabelBackground};
742 rect {
743 opacity: 0.5;
744 }
745 text-align: center;
746 }
747
748 .cluster rect {
749 }
750
751 .cluster text {
752 fill: ${options.titleColor};
753 }
754
755 div.mermaidTooltip {
756 position: absolute;
757 text-align: center;
758 max-width: 200px;
759 padding: 2px;
760 font-family: 'trebuchet ms', verdana, arial, sans-serif;
761 font-family: var(--mermaid-font-family);
762 font-size: 12px;
763 background: ${options.tertiaryColor};
764 border: 1px solid ${options.border2};
765 border-radius: 2px;
766 pointer-events: none;
767 z-index: 100;
768 }
769
770 .task-type-0, .section-type-0 {
771 ${options.fillType0 ? `fill: ${options.fillType0}` : ""};
772 }
773 .task-type-1, .section-type-1 {
774 ${options.fillType0 ? `fill: ${options.fillType1}` : ""};
775 }
776 .task-type-2, .section-type-2 {
777 ${options.fillType0 ? `fill: ${options.fillType2}` : ""};
778 }
779 .task-type-3, .section-type-3 {
780 ${options.fillType0 ? `fill: ${options.fillType3}` : ""};
781 }
782 .task-type-4, .section-type-4 {
783 ${options.fillType0 ? `fill: ${options.fillType4}` : ""};
784 }
785 .task-type-5, .section-type-5 {
786 ${options.fillType0 ? `fill: ${options.fillType5}` : ""};
787 }
788 .task-type-6, .section-type-6 {
789 ${options.fillType0 ? `fill: ${options.fillType6}` : ""};
790 }
791 .task-type-7, .section-type-7 {
792 ${options.fillType0 ? `fill: ${options.fillType7}` : ""};
793 }
794
795 .actor-0 {
796 ${options.actor0 ? `fill: ${options.actor0}` : ""};
797 }
798 .actor-1 {
799 ${options.actor1 ? `fill: ${options.actor1}` : ""};
800 }
801 .actor-2 {
802 ${options.actor2 ? `fill: ${options.actor2}` : ""};
803 }
804 .actor-3 {
805 ${options.actor3 ? `fill: ${options.actor3}` : ""};
806 }
807 .actor-4 {
808 ${options.actor4 ? `fill: ${options.actor4}` : ""};
809 }
810 .actor-5 {
811 ${options.actor5 ? `fill: ${options.actor5}` : ""};
812 }
813`;
814const styles = getStyles;
815const drawRect = function(elem, rectData) {
816 return drawRect$1(elem, rectData);
817};
818const drawFace = function(element, faceData) {
819 const radius = 15;
820 const circleElement = element.append("circle").attr("cx", faceData.cx).attr("cy", faceData.cy).attr("class", "face").attr("r", radius).attr("stroke-width", 2).attr("overflow", "visible");
821 const face = element.append("g");
822 face.append("circle").attr("cx", faceData.cx - radius / 3).attr("cy", faceData.cy - radius / 3).attr("r", 1.5).attr("stroke-width", 2).attr("fill", "#666").attr("stroke", "#666");
823 face.append("circle").attr("cx", faceData.cx + radius / 3).attr("cy", faceData.cy - radius / 3).attr("r", 1.5).attr("stroke-width", 2).attr("fill", "#666").attr("stroke", "#666");
824 function smile(face2) {
825 const arc = d3arc().startAngle(Math.PI / 2).endAngle(3 * (Math.PI / 2)).innerRadius(radius / 2).outerRadius(radius / 2.2);
826 face2.append("path").attr("class", "mouth").attr("d", arc).attr("transform", "translate(" + faceData.cx + "," + (faceData.cy + 2) + ")");
827 }
828 function sad(face2) {
829 const arc = d3arc().startAngle(3 * Math.PI / 2).endAngle(5 * (Math.PI / 2)).innerRadius(radius / 2).outerRadius(radius / 2.2);
830 face2.append("path").attr("class", "mouth").attr("d", arc).attr("transform", "translate(" + faceData.cx + "," + (faceData.cy + 7) + ")");
831 }
832 function ambivalent(face2) {
833 face2.append("line").attr("class", "mouth").attr("stroke", 2).attr("x1", faceData.cx - 5).attr("y1", faceData.cy + 7).attr("x2", faceData.cx + 5).attr("y2", faceData.cy + 7).attr("class", "mouth").attr("stroke-width", "1px").attr("stroke", "#666");
834 }
835 if (faceData.score > 3) {
836 smile(face);
837 } else if (faceData.score < 3) {
838 sad(face);
839 } else {
840 ambivalent(face);
841 }
842 return circleElement;
843};
844const drawCircle = function(element, circleData) {
845 const circleElement = element.append("circle");
846 circleElement.attr("cx", circleData.cx);
847 circleElement.attr("cy", circleData.cy);
848 circleElement.attr("class", "actor-" + circleData.pos);
849 circleElement.attr("fill", circleData.fill);
850 circleElement.attr("stroke", circleData.stroke);
851 circleElement.attr("r", circleData.r);
852 if (circleElement.class !== void 0) {
853 circleElement.attr("class", circleElement.class);
854 }
855 if (circleData.title !== void 0) {
856 circleElement.append("title").text(circleData.title);
857 }
858 return circleElement;
859};
860const drawText = function(elem, textData) {
861 return drawText$1(elem, textData);
862};
863const drawLabel = function(elem, txtObject) {
864 function genPoints(x, y, width, height, cut) {
865 return x + "," + y + " " + (x + width) + "," + y + " " + (x + width) + "," + (y + height - cut) + " " + (x + width - cut * 1.2) + "," + (y + height) + " " + x + "," + (y + height);
866 }
867 const polygon = elem.append("polygon");
868 polygon.attr("points", genPoints(txtObject.x, txtObject.y, 50, 20, 7));
869 polygon.attr("class", "labelBox");
870 txtObject.y = txtObject.y + txtObject.labelMargin;
871 txtObject.x = txtObject.x + 0.5 * txtObject.labelMargin;
872 drawText(elem, txtObject);
873};
874const drawSection = function(elem, section, conf2) {
875 const g = elem.append("g");
876 const rect = getNoteRect();
877 rect.x = section.x;
878 rect.y = section.y;
879 rect.fill = section.fill;
880 rect.width = conf2.width * section.taskCount + // width of the tasks
881 conf2.diagramMarginX * (section.taskCount - 1);
882 rect.height = conf2.height;
883 rect.class = "journey-section section-type-" + section.num;
884 rect.rx = 3;
885 rect.ry = 3;
886 drawRect(g, rect);
887 _drawTextCandidateFunc(conf2)(
888 section.text,
889 g,
890 rect.x,
891 rect.y,
892 rect.width,
893 rect.height,
894 { class: "journey-section section-type-" + section.num },
895 conf2,
896 section.colour
897 );
898};
899let taskCount = -1;
900const drawTask = function(elem, task, conf2) {
901 const center = task.x + conf2.width / 2;
902 const g = elem.append("g");
903 taskCount++;
904 const maxHeight = 300 + 5 * 30;
905 g.append("line").attr("id", "task" + taskCount).attr("x1", center).attr("y1", task.y).attr("x2", center).attr("y2", maxHeight).attr("class", "task-line").attr("stroke-width", "1px").attr("stroke-dasharray", "4 2").attr("stroke", "#666");
906 drawFace(g, {
907 cx: center,
908 cy: 300 + (5 - task.score) * 30,
909 score: task.score
910 });
911 const rect = getNoteRect();
912 rect.x = task.x;
913 rect.y = task.y;
914 rect.fill = task.fill;
915 rect.width = conf2.width;
916 rect.height = conf2.height;
917 rect.class = "task task-type-" + task.num;
918 rect.rx = 3;
919 rect.ry = 3;
920 drawRect(g, rect);
921 let xPos = task.x + 14;
922 task.people.forEach((person) => {
923 const colour = task.actors[person].color;
924 const circle = {
925 cx: xPos,
926 cy: task.y,
927 r: 7,
928 fill: colour,
929 stroke: "#000",
930 title: person,
931 pos: task.actors[person].position
932 };
933 drawCircle(g, circle);
934 xPos += 10;
935 });
936 _drawTextCandidateFunc(conf2)(
937 task.task,
938 g,
939 rect.x,
940 rect.y,
941 rect.width,
942 rect.height,
943 { class: "task" },
944 conf2,
945 task.colour
946 );
947};
948const drawBackgroundRect = function(elem, bounds2) {
949 drawBackgroundRect$1(elem, bounds2);
950};
951const _drawTextCandidateFunc = function() {
952 function byText(content, g, x, y, width, height, textAttrs, colour) {
953 const text = g.append("text").attr("x", x + width / 2).attr("y", y + height / 2 + 5).style("font-color", colour).style("text-anchor", "middle").text(content);
954 _setTextAttrs(text, textAttrs);
955 }
956 function byTspan(content, g, x, y, width, height, textAttrs, conf2, colour) {
957 const { taskFontSize, taskFontFamily } = conf2;
958 const lines = content.split(/<br\s*\/?>/gi);
959 for (let i = 0; i < lines.length; i++) {
960 const dy = i * taskFontSize - taskFontSize * (lines.length - 1) / 2;
961 const text = g.append("text").attr("x", x + width / 2).attr("y", y).attr("fill", colour).style("text-anchor", "middle").style("font-size", taskFontSize).style("font-family", taskFontFamily);
962 text.append("tspan").attr("x", x + width / 2).attr("dy", dy).text(lines[i]);
963 text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central");
964 _setTextAttrs(text, textAttrs);
965 }
966 }
967 function byFo(content, g, x, y, width, height, textAttrs, conf2) {
968 const body = g.append("switch");
969 const f = body.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height).attr("position", "fixed");
970 const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%");
971 text.append("div").attr("class", "label").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content);
972 byTspan(content, body, x, y, width, height, textAttrs, conf2);
973 _setTextAttrs(text, textAttrs);
974 }
975 function _setTextAttrs(toText, fromTextAttrsDict) {
976 for (const key in fromTextAttrsDict) {
977 if (key in fromTextAttrsDict) {
978 toText.attr(key, fromTextAttrsDict[key]);
979 }
980 }
981 }
982 return function(conf2) {
983 return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan;
984 };
985}();
986const initGraphics = function(graphics) {
987 graphics.append("defs").append("marker").attr("id", "arrowhead").attr("refX", 5).attr("refY", 2).attr("markerWidth", 6).attr("markerHeight", 4).attr("orient", "auto").append("path").attr("d", "M 0,0 V 4 L6,2 Z");
988};
989const svgDraw = {
990 drawRect,
991 drawCircle,
992 drawSection,
993 drawText,
994 drawLabel,
995 drawTask,
996 drawBackgroundRect,
997 initGraphics
998};
999const setConf = function(cnf) {
1000 const keys = Object.keys(cnf);
1001 keys.forEach(function(key) {
1002 conf[key] = cnf[key];
1003 });
1004};
1005const actors = {};
1006function drawActorLegend(diagram2) {
1007 const conf2 = getConfig().journey;
1008 let yPos = 60;
1009 Object.keys(actors).forEach((person) => {
1010 const colour = actors[person].color;
1011 const circleData = {
1012 cx: 20,
1013 cy: yPos,
1014 r: 7,
1015 fill: colour,
1016 stroke: "#000",
1017 pos: actors[person].position
1018 };
1019 svgDraw.drawCircle(diagram2, circleData);
1020 const labelData = {
1021 x: 40,
1022 y: yPos + 7,
1023 fill: "#666",
1024 text: person,
1025 textMargin: conf2.boxTextMargin | 5
1026 };
1027 svgDraw.drawText(diagram2, labelData);
1028 yPos += 20;
1029 });
1030}
1031const conf = getConfig().journey;
1032const LEFT_MARGIN = conf.leftMargin;
1033const draw = function(text, id, version, diagObj) {
1034 const conf2 = getConfig().journey;
1035 diagObj.db.clear();
1036 diagObj.parser.parse(text + "\n");
1037 const securityLevel = getConfig().securityLevel;
1038 let sandboxElement;
1039 if (securityLevel === "sandbox") {
1040 sandboxElement = select("#i" + id);
1041 }
1042 const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
1043 bounds.init();
1044 const diagram2 = root.select("#" + id);
1045 svgDraw.initGraphics(diagram2);
1046 const tasks2 = diagObj.db.getTasks();
1047 const title = diagObj.db.getDiagramTitle();
1048 const actorNames = diagObj.db.getActors();
1049 for (const member in actors) {
1050 delete actors[member];
1051 }
1052 let actorPos = 0;
1053 actorNames.forEach((actorName) => {
1054 actors[actorName] = {
1055 color: conf2.actorColours[actorPos % conf2.actorColours.length],
1056 position: actorPos
1057 };
1058 actorPos++;
1059 });
1060 drawActorLegend(diagram2);
1061 bounds.insert(0, 0, LEFT_MARGIN, Object.keys(actors).length * 50);
1062 drawTasks(diagram2, tasks2, 0);
1063 const box = bounds.getBounds();
1064 if (title) {
1065 diagram2.append("text").text(title).attr("x", LEFT_MARGIN).attr("font-size", "4ex").attr("font-weight", "bold").attr("y", 25);
1066 }
1067 const height = box.stopy - box.starty + 2 * conf2.diagramMarginY;
1068 const width = LEFT_MARGIN + box.stopx + 2 * conf2.diagramMarginX;
1069 configureSvgSize(diagram2, height, width, conf2.useMaxWidth);
1070 diagram2.append("line").attr("x1", LEFT_MARGIN).attr("y1", conf2.height * 4).attr("x2", width - LEFT_MARGIN - 4).attr("y2", conf2.height * 4).attr("stroke-width", 4).attr("stroke", "black").attr("marker-end", "url(#arrowhead)");
1071 const extraVertForTitle = title ? 70 : 0;
1072 diagram2.attr("viewBox", `${box.startx} -25 ${width} ${height + extraVertForTitle}`);
1073 diagram2.attr("preserveAspectRatio", "xMinYMin meet");
1074 diagram2.attr("height", height + extraVertForTitle + 25);
1075};
1076const bounds = {
1077 data: {
1078 startx: void 0,
1079 stopx: void 0,
1080 starty: void 0,
1081 stopy: void 0
1082 },
1083 verticalPos: 0,
1084 sequenceItems: [],
1085 init: function() {
1086 this.sequenceItems = [];
1087 this.data = {
1088 startx: void 0,
1089 stopx: void 0,
1090 starty: void 0,
1091 stopy: void 0
1092 };
1093 this.verticalPos = 0;
1094 },
1095 updateVal: function(obj, key, val, fun) {
1096 if (obj[key] === void 0) {
1097 obj[key] = val;
1098 } else {
1099 obj[key] = fun(val, obj[key]);
1100 }
1101 },
1102 updateBounds: function(startx, starty, stopx, stopy) {
1103 const conf2 = getConfig().journey;
1104 const _self = this;
1105 let cnt = 0;
1106 function updateFn(type) {
1107 return function updateItemBounds(item) {
1108 cnt++;
1109 const n = _self.sequenceItems.length - cnt + 1;
1110 _self.updateVal(item, "starty", starty - n * conf2.boxMargin, Math.min);
1111 _self.updateVal(item, "stopy", stopy + n * conf2.boxMargin, Math.max);
1112 _self.updateVal(bounds.data, "startx", startx - n * conf2.boxMargin, Math.min);
1113 _self.updateVal(bounds.data, "stopx", stopx + n * conf2.boxMargin, Math.max);
1114 if (!(type === "activation")) {
1115 _self.updateVal(item, "startx", startx - n * conf2.boxMargin, Math.min);
1116 _self.updateVal(item, "stopx", stopx + n * conf2.boxMargin, Math.max);
1117 _self.updateVal(bounds.data, "starty", starty - n * conf2.boxMargin, Math.min);
1118 _self.updateVal(bounds.data, "stopy", stopy + n * conf2.boxMargin, Math.max);
1119 }
1120 };
1121 }
1122 this.sequenceItems.forEach(updateFn());
1123 },
1124 insert: function(startx, starty, stopx, stopy) {
1125 const _startx = Math.min(startx, stopx);
1126 const _stopx = Math.max(startx, stopx);
1127 const _starty = Math.min(starty, stopy);
1128 const _stopy = Math.max(starty, stopy);
1129 this.updateVal(bounds.data, "startx", _startx, Math.min);
1130 this.updateVal(bounds.data, "starty", _starty, Math.min);
1131 this.updateVal(bounds.data, "stopx", _stopx, Math.max);
1132 this.updateVal(bounds.data, "stopy", _stopy, Math.max);
1133 this.updateBounds(_startx, _starty, _stopx, _stopy);
1134 },
1135 bumpVerticalPos: function(bump) {
1136 this.verticalPos = this.verticalPos + bump;
1137 this.data.stopy = this.verticalPos;
1138 },
1139 getVerticalPos: function() {
1140 return this.verticalPos;
1141 },
1142 getBounds: function() {
1143 return this.data;
1144 }
1145};
1146const fills = conf.sectionFills;
1147const textColours = conf.sectionColours;
1148const drawTasks = function(diagram2, tasks2, verticalPos) {
1149 const conf2 = getConfig().journey;
1150 let lastSection = "";
1151 const sectionVHeight = conf2.height * 2 + conf2.diagramMarginY;
1152 const taskPos = verticalPos + sectionVHeight;
1153 let sectionNumber = 0;
1154 let fill = "#CCC";
1155 let colour = "black";
1156 let num = 0;
1157 for (const [i, task] of tasks2.entries()) {
1158 if (lastSection !== task.section) {
1159 fill = fills[sectionNumber % fills.length];
1160 num = sectionNumber % fills.length;
1161 colour = textColours[sectionNumber % textColours.length];
1162 let taskInSectionCount = 0;
1163 const currentSection2 = task.section;
1164 for (let taskIndex = i; taskIndex < tasks2.length; taskIndex++) {
1165 if (tasks2[taskIndex].section == currentSection2) {
1166 taskInSectionCount = taskInSectionCount + 1;
1167 } else {
1168 break;
1169 }
1170 }
1171 const section = {
1172 x: i * conf2.taskMargin + i * conf2.width + LEFT_MARGIN,
1173 y: 50,
1174 text: task.section,
1175 fill,
1176 num,
1177 colour,
1178 taskCount: taskInSectionCount
1179 };
1180 svgDraw.drawSection(diagram2, section, conf2);
1181 lastSection = task.section;
1182 sectionNumber++;
1183 }
1184 const taskActors = task.people.reduce((acc, actorName) => {
1185 if (actors[actorName]) {
1186 acc[actorName] = actors[actorName];
1187 }
1188 return acc;
1189 }, {});
1190 task.x = i * conf2.taskMargin + i * conf2.width + LEFT_MARGIN;
1191 task.y = taskPos;
1192 task.width = conf2.diagramMarginX;
1193 task.height = conf2.diagramMarginY;
1194 task.colour = colour;
1195 task.fill = fill;
1196 task.num = num;
1197 task.actors = taskActors;
1198 svgDraw.drawTask(diagram2, task, conf2);
1199 bounds.insert(task.x, task.y, task.x + task.width + conf2.taskMargin, 300 + 5 * 30);
1200 }
1201};
1202const renderer = {
1203 setConf,
1204 draw
1205};
1206const diagram = {
1207 parser: parser$1,
1208 db,
1209 renderer,
1210 styles,
1211 init: (cnf) => {
1212 renderer.setConf(cnf.journey);
1213 db.clear();
1214 }
1215};
1216export {
1217 diagram
1218};