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