UNPKG

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