@bytechain.cn/colamd 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/.github/workflows/release.yml +66 -0
  2. package/.trae/documents/fix-mermaid-colors-and-sankey.md +50 -0
  3. package/CLAUDE.md +87 -0
  4. package/LICENSE +21 -0
  5. package/README.md +540 -0
  6. package/README_CN.md +543 -0
  7. package/demo.md +486 -0
  8. package/dist/main/index.js +735 -0
  9. package/dist/preload/index.js +71 -0
  10. package/dist/renderer/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  11. package/dist/renderer/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  12. package/dist/renderer/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  13. package/dist/renderer/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  14. package/dist/renderer/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  15. package/dist/renderer/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  16. package/dist/renderer/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  17. package/dist/renderer/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  18. package/dist/renderer/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  19. package/dist/renderer/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  20. package/dist/renderer/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  21. package/dist/renderer/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  22. package/dist/renderer/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  23. package/dist/renderer/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  24. package/dist/renderer/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  25. package/dist/renderer/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  26. package/dist/renderer/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  27. package/dist/renderer/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  28. package/dist/renderer/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  29. package/dist/renderer/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  30. package/dist/renderer/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  31. package/dist/renderer/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  32. package/dist/renderer/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  33. package/dist/renderer/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  34. package/dist/renderer/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  35. package/dist/renderer/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  36. package/dist/renderer/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  37. package/dist/renderer/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  38. package/dist/renderer/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  39. package/dist/renderer/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  40. package/dist/renderer/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  41. package/dist/renderer/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  42. package/dist/renderer/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  43. package/dist/renderer/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  44. package/dist/renderer/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  45. package/dist/renderer/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  46. package/dist/renderer/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  47. package/dist/renderer/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  48. package/dist/renderer/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  49. package/dist/renderer/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  50. package/dist/renderer/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  51. package/dist/renderer/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  52. package/dist/renderer/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  53. package/dist/renderer/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  54. package/dist/renderer/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  55. package/dist/renderer/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  56. package/dist/renderer/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  57. package/dist/renderer/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  58. package/dist/renderer/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  59. package/dist/renderer/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  60. package/dist/renderer/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  61. package/dist/renderer/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  62. package/dist/renderer/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  63. package/dist/renderer/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  64. package/dist/renderer/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  65. package/dist/renderer/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  66. package/dist/renderer/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  67. package/dist/renderer/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  68. package/dist/renderer/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  69. package/dist/renderer/assets/arc-tTbbM8LO.js +131 -0
  70. package/dist/renderer/assets/architectureDiagram-3BPJPVTR-CEgYow6c.js +8720 -0
  71. package/dist/renderer/assets/blockDiagram-GPEHLZMM-LHyVtPwW.js +3825 -0
  72. package/dist/renderer/assets/c4Diagram-AAUBKEIU-C1P1eJrf.js +2482 -0
  73. package/dist/renderer/assets/channel-upve91Tq.js +7 -0
  74. package/dist/renderer/assets/chunk-2J33WTMH-lag2vhq9.js +24 -0
  75. package/dist/renderer/assets/chunk-4BX2VUAB-BXJ8Ggh-.js +16 -0
  76. package/dist/renderer/assets/chunk-55IACEB6-CiBpxRa1.js +13 -0
  77. package/dist/renderer/assets/chunk-727SXJPM-ODeKQFXC.js +2016 -0
  78. package/dist/renderer/assets/chunk-AQP2D5EJ-BK7xJolB.js +1953 -0
  79. package/dist/renderer/assets/chunk-FMBD7UC4-BxpCZPtz.js +19 -0
  80. package/dist/renderer/assets/chunk-ND2GUHAM-CqqaU9Ue.js +116 -0
  81. package/dist/renderer/assets/chunk-QZHKN3VN-Biq_K124.js +19 -0
  82. package/dist/renderer/assets/classDiagram-4FO5ZUOK-Cq95X99o.js +23 -0
  83. package/dist/renderer/assets/classDiagram-v2-Q7XG4LA2-Cq95X99o.js +23 -0
  84. package/dist/renderer/assets/cose-bilkent-S5V4N54A-XasiD0bu.js +4942 -0
  85. package/dist/renderer/assets/cytoscape.esm-CpHeHM5e.js +30269 -0
  86. package/dist/renderer/assets/dagre-BM42HDAG-Nq84Gfx4.js +705 -0
  87. package/dist/renderer/assets/defaultLocale-B2RvLBDe.js +206 -0
  88. package/dist/renderer/assets/diagram-2AECGRRQ-DwuB1GWt.js +301 -0
  89. package/dist/renderer/assets/diagram-5GNKFQAL-C2tgeI1h.js +169 -0
  90. package/dist/renderer/assets/diagram-KO2AKTUF-D5KzjNBc.js +632 -0
  91. package/dist/renderer/assets/diagram-LMA3HP47-C12xHS1c.js +212 -0
  92. package/dist/renderer/assets/diagram-OG6HWLK6-CnxI9oEa.js +851 -0
  93. package/dist/renderer/assets/erDiagram-TEJ5UH35-D_uPaKwn.js +1227 -0
  94. package/dist/renderer/assets/flowDiagram-I6XJVG4X-B6q_1-tE.js +2332 -0
  95. package/dist/renderer/assets/ganttDiagram-6RSMTGT7-CFo7ifF9.js +3720 -0
  96. package/dist/renderer/assets/gitGraphDiagram-PVQCEYII-WSexHTnq.js +1373 -0
  97. package/dist/renderer/assets/graph-DyX_9f6d.js +1988 -0
  98. package/dist/renderer/assets/index-DW7LS8C1.js +72292 -0
  99. package/dist/renderer/assets/index-dyHEFYvY.css +2184 -0
  100. package/dist/renderer/assets/infoDiagram-5YYISTIA-DaeJdLRq.js +31 -0
  101. package/dist/renderer/assets/init-ZxktEp_H.js +16 -0
  102. package/dist/renderer/assets/ishikawaDiagram-YF4QCWOH-DDCZc35f.js +967 -0
  103. package/dist/renderer/assets/journeyDiagram-JHISSGLW-BEdmpAgl.js +1255 -0
  104. package/dist/renderer/assets/kanban-definition-UN3LZRKU-BEFtQcFb.js +1052 -0
  105. package/dist/renderer/assets/layout-CAJgQHdw.js +2610 -0
  106. package/dist/renderer/assets/linear-B2ggJ8Am.js +340 -0
  107. package/dist/renderer/assets/mindmap-definition-RKZ34NQL-DSxVgHB5.js +1180 -0
  108. package/dist/renderer/assets/ordinal-DSZU4PqD.js +76 -0
  109. package/dist/renderer/assets/pieDiagram-4H26LBE5-CwYoJBuL.js +246 -0
  110. package/dist/renderer/assets/quadrantDiagram-W4KKPZXB-CST9Fvg9.js +1344 -0
  111. package/dist/renderer/assets/requirementDiagram-4Y6WPE33-DtrH52jS.js +1204 -0
  112. package/dist/renderer/assets/sankeyDiagram-5OEKKPKP-ca1tPzJ_.js +1274 -0
  113. package/dist/renderer/assets/sequenceDiagram-3UESZ5HK-Dfp1EJZ7.js +4514 -0
  114. package/dist/renderer/assets/stateDiagram-AJRCARHV-Bha2QoNB.js +450 -0
  115. package/dist/renderer/assets/stateDiagram-v2-BHNVJYJU-DWgFUYu1.js +21 -0
  116. package/dist/renderer/assets/timeline-definition-PNZ67QCA-C3h_-OTj.js +1596 -0
  117. package/dist/renderer/assets/vennDiagram-CIIHVFJN-DFzjSrZi.js +2486 -0
  118. package/dist/renderer/assets/wardley-L42UT6IY-Cx-VbqoS.js +30699 -0
  119. package/dist/renderer/assets/wardleyDiagram-YWT4CUSO-S2D9XqX6.js +975 -0
  120. package/dist/renderer/assets/xychartDiagram-2RQKCTM6-Cfxigbts.js +1932 -0
  121. package/dist/renderer/index.html +19 -0
  122. package/docs/agent-diff-view.md +48 -0
  123. package/electron-builder.yml +57 -0
  124. package/electron.vite.config.ts +30 -0
  125. package/package.json +40 -0
  126. package/resources/entitlements.mac.plist +12 -0
  127. package/resources/icon.icns +0 -0
  128. package/resources/icon.png +0 -0
  129. package/resources/icon.svg +23 -0
  130. package/resources/templates/slides/icon.png +0 -0
  131. package/resources/templates/slides/slides-template.md +74 -0
  132. package/resources/templates/slides/template.html +535 -0
  133. package/scripts/afterPack.js +13 -0
  134. package/src/main/index.ts +881 -0
  135. package/src/preload/index.ts +110 -0
  136. package/src/renderer/editor/editor.ts +204 -0
  137. package/src/renderer/editor/html-view.ts +15 -0
  138. package/src/renderer/editor/plugins/index.ts +76 -0
  139. package/src/renderer/editor/plugins/math-plugin.ts +297 -0
  140. package/src/renderer/editor/plugins/mermaid-plugin-custom.css +431 -0
  141. package/src/renderer/editor/plugins/mermaid-plugin-dark.css +428 -0
  142. package/src/renderer/editor/plugins/mermaid-plugin-elegant.css +443 -0
  143. package/src/renderer/editor/plugins/mermaid-plugin-newsprint.css +208 -0
  144. package/src/renderer/editor/plugins/mermaid-plugin.css +111 -0
  145. package/src/renderer/editor/plugins/mermaid-plugin.ts +679 -0
  146. package/src/renderer/env.d.ts +7 -0
  147. package/src/renderer/index.html +18 -0
  148. package/src/renderer/main.ts +303 -0
  149. package/src/renderer/themes/base.css +509 -0
  150. package/src/renderer/themes/theme-manager.ts +40 -0
  151. package/themes/README.md +280 -0
  152. package/themes/elegant.css +664 -0
  153. package/themes/guizang.css +732 -0
  154. package/tsconfig.json +14 -0
  155. package/tsconfig.main.json +11 -0
  156. package/tsconfig.preload.json +11 -0
  157. package/tsconfig.renderer.json +12 -0
@@ -0,0 +1,1596 @@
1
+ import { _ as __name, D as getConfig, V as isDark, W as lighten, X as darken, c as getConfig2, l as log, I as selectSvgElement, N as parseFontSize, Y as setupGraphViewbox, d as select, C as __export, $ as commonDb_exports, z as clear } from "./index-DW7LS8C1.js";
2
+ import { d as d3arc } from "./arc-tTbbM8LO.js";
3
+ var parser = (function() {
4
+ var o = /* @__PURE__ */ __name(function(k, v, o2, l) {
5
+ for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) ;
6
+ return o2;
7
+ }, "o"), $V0 = [6, 11, 13, 14, 15, 17, 19, 20, 23, 24], $V1 = [1, 12], $V2 = [1, 13], $V3 = [1, 14], $V4 = [1, 15], $V5 = [1, 16], $V6 = [1, 19], $V7 = [1, 20];
8
+ var parser2 = {
9
+ trace: /* @__PURE__ */ __name(function trace() {
10
+ }, "trace"),
11
+ yy: {},
12
+ symbols_: { "error": 2, "start": 3, "timeline_header": 4, "document": 5, "EOF": 6, "timeline": 7, "timeline_lr": 8, "timeline_td": 9, "line": 10, "SPACE": 11, "statement": 12, "NEWLINE": 13, "title": 14, "acc_title": 15, "acc_title_value": 16, "acc_descr": 17, "acc_descr_value": 18, "acc_descr_multiline_value": 19, "section": 20, "period_statement": 21, "event_statement": 22, "period": 23, "event": 24, "$accept": 0, "$end": 1 },
13
+ terminals_: { 2: "error", 6: "EOF", 7: "timeline", 8: "timeline_lr", 9: "timeline_td", 11: "SPACE", 13: "NEWLINE", 14: "title", 15: "acc_title", 16: "acc_title_value", 17: "acc_descr", 18: "acc_descr_value", 19: "acc_descr_multiline_value", 20: "section", 23: "period", 24: "event" },
14
+ productions_: [0, [3, 3], [4, 1], [4, 1], [4, 1], [5, 0], [5, 2], [10, 2], [10, 1], [10, 1], [10, 1], [12, 1], [12, 2], [12, 2], [12, 1], [12, 1], [12, 1], [12, 1], [21, 1], [22, 1]],
15
+ performAction: /* @__PURE__ */ __name(function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
16
+ var $0 = $$.length - 1;
17
+ switch (yystate) {
18
+ case 1:
19
+ return $$[$0 - 1];
20
+ case 3:
21
+ yy.setDirection("LR");
22
+ break;
23
+ case 4:
24
+ yy.setDirection("TD");
25
+ break;
26
+ case 5:
27
+ this.$ = [];
28
+ break;
29
+ case 6:
30
+ $$[$0 - 1].push($$[$0]);
31
+ this.$ = $$[$0 - 1];
32
+ break;
33
+ case 7:
34
+ case 8:
35
+ this.$ = $$[$0];
36
+ break;
37
+ case 9:
38
+ case 10:
39
+ this.$ = [];
40
+ break;
41
+ case 11:
42
+ yy.getCommonDb().setDiagramTitle($$[$0].substr(6));
43
+ this.$ = $$[$0].substr(6);
44
+ break;
45
+ case 12:
46
+ this.$ = $$[$0].trim();
47
+ yy.getCommonDb().setAccTitle(this.$);
48
+ break;
49
+ case 13:
50
+ case 14:
51
+ this.$ = $$[$0].trim();
52
+ yy.getCommonDb().setAccDescription(this.$);
53
+ break;
54
+ case 15:
55
+ yy.addSection($$[$0].substr(8));
56
+ this.$ = $$[$0].substr(8);
57
+ break;
58
+ case 18:
59
+ yy.addTask($$[$0], 0, "");
60
+ this.$ = $$[$0];
61
+ break;
62
+ case 19:
63
+ yy.addEvent($$[$0].substr(2));
64
+ this.$ = $$[$0];
65
+ break;
66
+ }
67
+ }, "anonymous"),
68
+ table: [{ 3: 1, 4: 2, 7: [1, 3], 8: [1, 4], 9: [1, 5] }, { 1: [3] }, o($V0, [2, 5], { 5: 6 }), o($V0, [2, 2]), o($V0, [2, 3]), o($V0, [2, 4]), { 6: [1, 7], 10: 8, 11: [1, 9], 12: 10, 13: [1, 11], 14: $V1, 15: $V2, 17: $V3, 19: $V4, 20: $V5, 21: 17, 22: 18, 23: $V6, 24: $V7 }, o($V0, [2, 10], { 1: [2, 1] }), o($V0, [2, 6]), { 12: 21, 14: $V1, 15: $V2, 17: $V3, 19: $V4, 20: $V5, 21: 17, 22: 18, 23: $V6, 24: $V7 }, o($V0, [2, 8]), o($V0, [2, 9]), o($V0, [2, 11]), { 16: [1, 22] }, { 18: [1, 23] }, o($V0, [2, 14]), o($V0, [2, 15]), o($V0, [2, 16]), o($V0, [2, 17]), o($V0, [2, 18]), o($V0, [2, 19]), o($V0, [2, 7]), o($V0, [2, 12]), o($V0, [2, 13])],
69
+ defaultActions: {},
70
+ parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
71
+ if (hash.recoverable) {
72
+ this.trace(str);
73
+ } else {
74
+ var error = new Error(str);
75
+ error.hash = hash;
76
+ throw error;
77
+ }
78
+ }, "parseError"),
79
+ parse: /* @__PURE__ */ __name(function parse(input) {
80
+ var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
81
+ var args = lstack.slice.call(arguments, 1);
82
+ var lexer2 = Object.create(this.lexer);
83
+ var sharedState = { yy: {} };
84
+ for (var k in this.yy) {
85
+ if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
86
+ sharedState.yy[k] = this.yy[k];
87
+ }
88
+ }
89
+ lexer2.setInput(input, sharedState.yy);
90
+ sharedState.yy.lexer = lexer2;
91
+ sharedState.yy.parser = this;
92
+ if (typeof lexer2.yylloc == "undefined") {
93
+ lexer2.yylloc = {};
94
+ }
95
+ var yyloc = lexer2.yylloc;
96
+ lstack.push(yyloc);
97
+ var ranges = lexer2.options && lexer2.options.ranges;
98
+ if (typeof sharedState.yy.parseError === "function") {
99
+ this.parseError = sharedState.yy.parseError;
100
+ } else {
101
+ this.parseError = Object.getPrototypeOf(this).parseError;
102
+ }
103
+ function popStack(n) {
104
+ stack.length = stack.length - 2 * n;
105
+ vstack.length = vstack.length - n;
106
+ lstack.length = lstack.length - n;
107
+ }
108
+ __name(popStack, "popStack");
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
+ __name(lex, "lex");
122
+ var symbol, state, action, r, yyval = {}, p, len, newState, expected;
123
+ while (true) {
124
+ state = stack[stack.length - 1];
125
+ if (this.defaultActions[state]) {
126
+ action = this.defaultActions[state];
127
+ } else {
128
+ if (symbol === null || typeof symbol == "undefined") {
129
+ symbol = lex();
130
+ }
131
+ action = table[state] && table[state][symbol];
132
+ }
133
+ if (typeof action === "undefined" || !action.length || !action[0]) {
134
+ var errStr = "";
135
+ expected = [];
136
+ for (p in table[state]) {
137
+ if (this.terminals_[p] && p > TERROR) {
138
+ expected.push("'" + this.terminals_[p] + "'");
139
+ }
140
+ }
141
+ if (lexer2.showPosition) {
142
+ errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
143
+ } else {
144
+ errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
145
+ }
146
+ this.parseError(errStr, {
147
+ text: lexer2.match,
148
+ token: this.terminals_[symbol] || symbol,
149
+ line: lexer2.yylineno,
150
+ loc: yyloc,
151
+ expected
152
+ });
153
+ }
154
+ if (action[0] instanceof Array && action.length > 1) {
155
+ throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
156
+ }
157
+ switch (action[0]) {
158
+ case 1:
159
+ stack.push(symbol);
160
+ vstack.push(lexer2.yytext);
161
+ lstack.push(lexer2.yylloc);
162
+ stack.push(action[1]);
163
+ symbol = null;
164
+ {
165
+ yyleng = lexer2.yyleng;
166
+ yytext = lexer2.yytext;
167
+ yylineno = lexer2.yylineno;
168
+ yyloc = lexer2.yylloc;
169
+ }
170
+ break;
171
+ case 2:
172
+ len = this.productions_[action[1]][1];
173
+ yyval.$ = vstack[vstack.length - len];
174
+ yyval._$ = {
175
+ first_line: lstack[lstack.length - (len || 1)].first_line,
176
+ last_line: lstack[lstack.length - 1].last_line,
177
+ first_column: lstack[lstack.length - (len || 1)].first_column,
178
+ last_column: lstack[lstack.length - 1].last_column
179
+ };
180
+ if (ranges) {
181
+ yyval._$.range = [
182
+ lstack[lstack.length - (len || 1)].range[0],
183
+ lstack[lstack.length - 1].range[1]
184
+ ];
185
+ }
186
+ r = this.performAction.apply(yyval, [
187
+ yytext,
188
+ yyleng,
189
+ yylineno,
190
+ sharedState.yy,
191
+ action[1],
192
+ vstack,
193
+ lstack
194
+ ].concat(args));
195
+ if (typeof r !== "undefined") {
196
+ return r;
197
+ }
198
+ if (len) {
199
+ stack = stack.slice(0, -1 * len * 2);
200
+ vstack = vstack.slice(0, -1 * len);
201
+ lstack = lstack.slice(0, -1 * len);
202
+ }
203
+ stack.push(this.productions_[action[1]][0]);
204
+ vstack.push(yyval.$);
205
+ lstack.push(yyval._$);
206
+ newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
207
+ stack.push(newState);
208
+ break;
209
+ case 3:
210
+ return true;
211
+ }
212
+ }
213
+ return true;
214
+ }, "parse")
215
+ };
216
+ var lexer = /* @__PURE__ */ (function() {
217
+ var lexer2 = {
218
+ EOF: 1,
219
+ parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
220
+ if (this.yy.parser) {
221
+ this.yy.parser.parseError(str, hash);
222
+ } else {
223
+ throw new Error(str);
224
+ }
225
+ }, "parseError"),
226
+ // resets the lexer, sets new input
227
+ setInput: /* @__PURE__ */ __name(function(input, yy) {
228
+ this.yy = yy || this.yy || {};
229
+ this._input = input;
230
+ this._more = this._backtrack = this.done = false;
231
+ this.yylineno = this.yyleng = 0;
232
+ this.yytext = this.matched = this.match = "";
233
+ this.conditionStack = ["INITIAL"];
234
+ this.yylloc = {
235
+ first_line: 1,
236
+ first_column: 0,
237
+ last_line: 1,
238
+ last_column: 0
239
+ };
240
+ if (this.options.ranges) {
241
+ this.yylloc.range = [0, 0];
242
+ }
243
+ this.offset = 0;
244
+ return this;
245
+ }, "setInput"),
246
+ // consumes and returns one char from the input
247
+ input: /* @__PURE__ */ __name(function() {
248
+ var ch = this._input[0];
249
+ this.yytext += ch;
250
+ this.yyleng++;
251
+ this.offset++;
252
+ this.match += ch;
253
+ this.matched += ch;
254
+ var lines = ch.match(/(?:\r\n?|\n).*/g);
255
+ if (lines) {
256
+ this.yylineno++;
257
+ this.yylloc.last_line++;
258
+ } else {
259
+ this.yylloc.last_column++;
260
+ }
261
+ if (this.options.ranges) {
262
+ this.yylloc.range[1]++;
263
+ }
264
+ this._input = this._input.slice(1);
265
+ return ch;
266
+ }, "input"),
267
+ // unshifts one char (or a string) into the input
268
+ unput: /* @__PURE__ */ __name(function(ch) {
269
+ var len = ch.length;
270
+ var lines = ch.split(/(?:\r\n?|\n)/g);
271
+ this._input = ch + this._input;
272
+ this.yytext = this.yytext.substr(0, this.yytext.length - len);
273
+ this.offset -= len;
274
+ var oldLines = this.match.split(/(?:\r\n?|\n)/g);
275
+ this.match = this.match.substr(0, this.match.length - 1);
276
+ this.matched = this.matched.substr(0, this.matched.length - 1);
277
+ if (lines.length - 1) {
278
+ this.yylineno -= lines.length - 1;
279
+ }
280
+ var r = this.yylloc.range;
281
+ this.yylloc = {
282
+ first_line: this.yylloc.first_line,
283
+ last_line: this.yylineno + 1,
284
+ first_column: this.yylloc.first_column,
285
+ 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
286
+ };
287
+ if (this.options.ranges) {
288
+ this.yylloc.range = [r[0], r[0] + this.yyleng - len];
289
+ }
290
+ this.yyleng = this.yytext.length;
291
+ return this;
292
+ }, "unput"),
293
+ // When called from action, caches matched text and appends it on next action
294
+ more: /* @__PURE__ */ __name(function() {
295
+ this._more = true;
296
+ return this;
297
+ }, "more"),
298
+ // 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.
299
+ reject: /* @__PURE__ */ __name(function() {
300
+ if (this.options.backtrack_lexer) {
301
+ this._backtrack = true;
302
+ } else {
303
+ 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(), {
304
+ text: "",
305
+ token: null,
306
+ line: this.yylineno
307
+ });
308
+ }
309
+ return this;
310
+ }, "reject"),
311
+ // retain first n characters of the match
312
+ less: /* @__PURE__ */ __name(function(n) {
313
+ this.unput(this.match.slice(n));
314
+ }, "less"),
315
+ // displays already matched input, i.e. for error messages
316
+ pastInput: /* @__PURE__ */ __name(function() {
317
+ var past = this.matched.substr(0, this.matched.length - this.match.length);
318
+ return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
319
+ }, "pastInput"),
320
+ // displays upcoming input, i.e. for error messages
321
+ upcomingInput: /* @__PURE__ */ __name(function() {
322
+ var next = this.match;
323
+ if (next.length < 20) {
324
+ next += this._input.substr(0, 20 - next.length);
325
+ }
326
+ return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
327
+ }, "upcomingInput"),
328
+ // displays the character position where the lexing error occurred, i.e. for error messages
329
+ showPosition: /* @__PURE__ */ __name(function() {
330
+ var pre = this.pastInput();
331
+ var c = new Array(pre.length + 1).join("-");
332
+ return pre + this.upcomingInput() + "\n" + c + "^";
333
+ }, "showPosition"),
334
+ // test the lexed token: return FALSE when not a match, otherwise return token
335
+ test_match: /* @__PURE__ */ __name(function(match, indexed_rule) {
336
+ var token, lines, backup;
337
+ if (this.options.backtrack_lexer) {
338
+ backup = {
339
+ yylineno: this.yylineno,
340
+ yylloc: {
341
+ first_line: this.yylloc.first_line,
342
+ last_line: this.last_line,
343
+ first_column: this.yylloc.first_column,
344
+ last_column: this.yylloc.last_column
345
+ },
346
+ yytext: this.yytext,
347
+ match: this.match,
348
+ matches: this.matches,
349
+ matched: this.matched,
350
+ yyleng: this.yyleng,
351
+ offset: this.offset,
352
+ _more: this._more,
353
+ _input: this._input,
354
+ yy: this.yy,
355
+ conditionStack: this.conditionStack.slice(0),
356
+ done: this.done
357
+ };
358
+ if (this.options.ranges) {
359
+ backup.yylloc.range = this.yylloc.range.slice(0);
360
+ }
361
+ }
362
+ lines = match[0].match(/(?:\r\n?|\n).*/g);
363
+ if (lines) {
364
+ this.yylineno += lines.length;
365
+ }
366
+ this.yylloc = {
367
+ first_line: this.yylloc.last_line,
368
+ last_line: this.yylineno + 1,
369
+ first_column: this.yylloc.last_column,
370
+ last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
371
+ };
372
+ this.yytext += match[0];
373
+ this.match += match[0];
374
+ this.matches = match;
375
+ this.yyleng = this.yytext.length;
376
+ if (this.options.ranges) {
377
+ this.yylloc.range = [this.offset, this.offset += this.yyleng];
378
+ }
379
+ this._more = false;
380
+ this._backtrack = false;
381
+ this._input = this._input.slice(match[0].length);
382
+ this.matched += match[0];
383
+ token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
384
+ if (this.done && this._input) {
385
+ this.done = false;
386
+ }
387
+ if (token) {
388
+ return token;
389
+ } else if (this._backtrack) {
390
+ for (var k in backup) {
391
+ this[k] = backup[k];
392
+ }
393
+ return false;
394
+ }
395
+ return false;
396
+ }, "test_match"),
397
+ // return next match in input
398
+ next: /* @__PURE__ */ __name(function() {
399
+ if (this.done) {
400
+ return this.EOF;
401
+ }
402
+ if (!this._input) {
403
+ this.done = true;
404
+ }
405
+ var token, match, tempMatch, index;
406
+ if (!this._more) {
407
+ this.yytext = "";
408
+ this.match = "";
409
+ }
410
+ var rules = this._currentRules();
411
+ for (var i = 0; i < rules.length; i++) {
412
+ tempMatch = this._input.match(this.rules[rules[i]]);
413
+ if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
414
+ match = tempMatch;
415
+ index = i;
416
+ if (this.options.backtrack_lexer) {
417
+ token = this.test_match(tempMatch, rules[i]);
418
+ if (token !== false) {
419
+ return token;
420
+ } else if (this._backtrack) {
421
+ match = false;
422
+ continue;
423
+ } else {
424
+ return false;
425
+ }
426
+ } else if (!this.options.flex) {
427
+ break;
428
+ }
429
+ }
430
+ }
431
+ if (match) {
432
+ token = this.test_match(match, rules[index]);
433
+ if (token !== false) {
434
+ return token;
435
+ }
436
+ return false;
437
+ }
438
+ if (this._input === "") {
439
+ return this.EOF;
440
+ } else {
441
+ return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
442
+ text: "",
443
+ token: null,
444
+ line: this.yylineno
445
+ });
446
+ }
447
+ }, "next"),
448
+ // return next match that has a token
449
+ lex: /* @__PURE__ */ __name(function lex() {
450
+ var r = this.next();
451
+ if (r) {
452
+ return r;
453
+ } else {
454
+ return this.lex();
455
+ }
456
+ }, "lex"),
457
+ // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
458
+ begin: /* @__PURE__ */ __name(function begin(condition) {
459
+ this.conditionStack.push(condition);
460
+ }, "begin"),
461
+ // pop the previously active lexer condition state off the condition stack
462
+ popState: /* @__PURE__ */ __name(function popState() {
463
+ var n = this.conditionStack.length - 1;
464
+ if (n > 0) {
465
+ return this.conditionStack.pop();
466
+ } else {
467
+ return this.conditionStack[0];
468
+ }
469
+ }, "popState"),
470
+ // produce the lexer rule set which is active for the currently active lexer condition state
471
+ _currentRules: /* @__PURE__ */ __name(function _currentRules() {
472
+ if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
473
+ return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
474
+ } else {
475
+ return this.conditions["INITIAL"].rules;
476
+ }
477
+ }, "_currentRules"),
478
+ // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
479
+ topState: /* @__PURE__ */ __name(function topState(n) {
480
+ n = this.conditionStack.length - 1 - Math.abs(n || 0);
481
+ if (n >= 0) {
482
+ return this.conditionStack[n];
483
+ } else {
484
+ return "INITIAL";
485
+ }
486
+ }, "topState"),
487
+ // alias for begin(condition)
488
+ pushState: /* @__PURE__ */ __name(function pushState(condition) {
489
+ this.begin(condition);
490
+ }, "pushState"),
491
+ // return the number of states currently on the stack
492
+ stateStackSize: /* @__PURE__ */ __name(function stateStackSize() {
493
+ return this.conditionStack.length;
494
+ }, "stateStackSize"),
495
+ options: { "case-insensitive": true },
496
+ performAction: /* @__PURE__ */ __name(function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
497
+ switch ($avoiding_name_collisions) {
498
+ case 0:
499
+ break;
500
+ case 1:
501
+ break;
502
+ case 2:
503
+ return 13;
504
+ case 3:
505
+ break;
506
+ case 4:
507
+ break;
508
+ case 5:
509
+ return 8;
510
+ case 6:
511
+ return 9;
512
+ case 7:
513
+ return 7;
514
+ case 8:
515
+ return 14;
516
+ case 9:
517
+ this.begin("acc_title");
518
+ return 15;
519
+ case 10:
520
+ this.popState();
521
+ return "acc_title_value";
522
+ case 11:
523
+ this.begin("acc_descr");
524
+ return 17;
525
+ case 12:
526
+ this.popState();
527
+ return "acc_descr_value";
528
+ case 13:
529
+ this.begin("acc_descr_multiline");
530
+ break;
531
+ case 14:
532
+ this.popState();
533
+ break;
534
+ case 15:
535
+ return "acc_descr_multiline_value";
536
+ case 16:
537
+ return 20;
538
+ case 17:
539
+ return 24;
540
+ case 18:
541
+ return 23;
542
+ case 19:
543
+ return 6;
544
+ case 20:
545
+ return "INVALID";
546
+ }
547
+ }, "anonymous"),
548
+ rules: [/^(?:%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:timeline[ \t]+LR\b)/i, /^(?:timeline[ \t]+TD\b)/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]|:(?!\s))+)/i, /^(?:[^#:\n]+)/i, /^(?:$)/i, /^(?:.)/i],
549
+ conditions: { "acc_descr_multiline": { "rules": [14, 15], "inclusive": false }, "acc_descr": { "rules": [12], "inclusive": false }, "acc_title": { "rules": [10], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13, 16, 17, 18, 19, 20], "inclusive": true } }
550
+ };
551
+ return lexer2;
552
+ })();
553
+ parser2.lexer = lexer;
554
+ function Parser() {
555
+ this.yy = {};
556
+ }
557
+ __name(Parser, "Parser");
558
+ Parser.prototype = parser2;
559
+ parser2.Parser = Parser;
560
+ return new Parser();
561
+ })();
562
+ parser.parser = parser;
563
+ var timeline_default = parser;
564
+ var timelineDb_exports = {};
565
+ __export(timelineDb_exports, {
566
+ addEvent: () => addEvent,
567
+ addSection: () => addSection,
568
+ addTask: () => addTask,
569
+ addTaskOrg: () => addTaskOrg,
570
+ clear: () => clear2,
571
+ default: () => timelineDb_default,
572
+ getCommonDb: () => getCommonDb,
573
+ getDirection: () => getDirection,
574
+ getSections: () => getSections,
575
+ getTasks: () => getTasks,
576
+ setDirection: () => setDirection
577
+ });
578
+ var currentSection = "";
579
+ var currentTaskId = 0;
580
+ var direction = "LR";
581
+ var sections = [];
582
+ var tasks = [];
583
+ var rawTasks = [];
584
+ var getCommonDb = /* @__PURE__ */ __name(() => commonDb_exports, "getCommonDb");
585
+ var clear2 = /* @__PURE__ */ __name(function() {
586
+ sections.length = 0;
587
+ tasks.length = 0;
588
+ currentSection = "";
589
+ rawTasks.length = 0;
590
+ direction = "LR";
591
+ clear();
592
+ }, "clear");
593
+ var setDirection = /* @__PURE__ */ __name(function(dir) {
594
+ direction = dir;
595
+ }, "setDirection");
596
+ var getDirection = /* @__PURE__ */ __name(function() {
597
+ return direction;
598
+ }, "getDirection");
599
+ var addSection = /* @__PURE__ */ __name(function(txt) {
600
+ currentSection = txt;
601
+ sections.push(txt);
602
+ }, "addSection");
603
+ var getSections = /* @__PURE__ */ __name(function() {
604
+ return sections;
605
+ }, "getSections");
606
+ var getTasks = /* @__PURE__ */ __name(function() {
607
+ let allItemsProcessed = compileTasks();
608
+ const maxDepth = 100;
609
+ let iterationCount = 0;
610
+ while (!allItemsProcessed && iterationCount < maxDepth) {
611
+ allItemsProcessed = compileTasks();
612
+ iterationCount++;
613
+ }
614
+ tasks.push(...rawTasks);
615
+ return tasks;
616
+ }, "getTasks");
617
+ var addTask = /* @__PURE__ */ __name(function(period, length, event) {
618
+ const rawTask = {
619
+ id: currentTaskId++,
620
+ section: currentSection,
621
+ type: currentSection,
622
+ task: period,
623
+ score: length ? length : 0,
624
+ //if event is defined, then add it the events array
625
+ events: event ? [event] : []
626
+ };
627
+ rawTasks.push(rawTask);
628
+ }, "addTask");
629
+ var addEvent = /* @__PURE__ */ __name(function(event) {
630
+ const currentTask = rawTasks.find((task) => task.id === currentTaskId - 1);
631
+ currentTask.events.push(event);
632
+ }, "addEvent");
633
+ var addTaskOrg = /* @__PURE__ */ __name(function(descr) {
634
+ const newTask = {
635
+ section: currentSection,
636
+ type: currentSection,
637
+ description: descr,
638
+ task: descr,
639
+ classes: []
640
+ };
641
+ tasks.push(newTask);
642
+ }, "addTaskOrg");
643
+ var compileTasks = /* @__PURE__ */ __name(function() {
644
+ const compileTask = /* @__PURE__ */ __name(function(pos) {
645
+ return rawTasks[pos].processed;
646
+ }, "compileTask");
647
+ let allProcessed = true;
648
+ for (const [i, rawTask] of rawTasks.entries()) {
649
+ compileTask(i);
650
+ allProcessed = allProcessed && rawTask.processed;
651
+ }
652
+ return allProcessed;
653
+ }, "compileTasks");
654
+ var timelineDb_default = {
655
+ clear: clear2,
656
+ getCommonDb,
657
+ getDirection,
658
+ setDirection,
659
+ addSection,
660
+ getSections,
661
+ getTasks,
662
+ addTask,
663
+ addTaskOrg,
664
+ addEvent
665
+ };
666
+ var nodeCount = 0;
667
+ var drawRect = /* @__PURE__ */ __name(function(elem, rectData) {
668
+ const rectElem = elem.append("rect");
669
+ rectElem.attr("x", rectData.x);
670
+ rectElem.attr("y", rectData.y);
671
+ rectElem.attr("fill", rectData.fill);
672
+ rectElem.attr("stroke", rectData.stroke);
673
+ rectElem.attr("width", rectData.width);
674
+ rectElem.attr("height", rectData.height);
675
+ rectElem.attr("rx", rectData.rx);
676
+ rectElem.attr("ry", rectData.ry);
677
+ if (rectData.class !== void 0) {
678
+ rectElem.attr("class", rectData.class);
679
+ }
680
+ return rectElem;
681
+ }, "drawRect");
682
+ var drawFace = /* @__PURE__ */ __name(function(element, faceData) {
683
+ const radius = 15;
684
+ 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");
685
+ const face = element.append("g");
686
+ 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");
687
+ 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");
688
+ function smile(face2) {
689
+ const arc = d3arc().startAngle(Math.PI / 2).endAngle(3 * (Math.PI / 2)).innerRadius(radius / 2).outerRadius(radius / 2.2);
690
+ face2.append("path").attr("class", "mouth").attr("d", arc).attr("transform", "translate(" + faceData.cx + "," + (faceData.cy + 2) + ")");
691
+ }
692
+ __name(smile, "smile");
693
+ function sad(face2) {
694
+ const arc = d3arc().startAngle(3 * Math.PI / 2).endAngle(5 * (Math.PI / 2)).innerRadius(radius / 2).outerRadius(radius / 2.2);
695
+ face2.append("path").attr("class", "mouth").attr("d", arc).attr("transform", "translate(" + faceData.cx + "," + (faceData.cy + 7) + ")");
696
+ }
697
+ __name(sad, "sad");
698
+ function ambivalent(face2) {
699
+ 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");
700
+ }
701
+ __name(ambivalent, "ambivalent");
702
+ if (faceData.score > 3) {
703
+ smile(face);
704
+ } else if (faceData.score < 3) {
705
+ sad(face);
706
+ } else {
707
+ ambivalent(face);
708
+ }
709
+ return circleElement;
710
+ }, "drawFace");
711
+ var drawCircle = /* @__PURE__ */ __name(function(element, circleData) {
712
+ const circleElement = element.append("circle");
713
+ circleElement.attr("cx", circleData.cx);
714
+ circleElement.attr("cy", circleData.cy);
715
+ circleElement.attr("class", "actor-" + circleData.pos);
716
+ circleElement.attr("fill", circleData.fill);
717
+ circleElement.attr("stroke", circleData.stroke);
718
+ circleElement.attr("r", circleData.r);
719
+ if (circleElement.class !== void 0) {
720
+ circleElement.attr("class", circleElement.class);
721
+ }
722
+ if (circleData.title !== void 0) {
723
+ circleElement.append("title").text(circleData.title);
724
+ }
725
+ return circleElement;
726
+ }, "drawCircle");
727
+ var drawText = /* @__PURE__ */ __name(function(elem, textData) {
728
+ const nText = textData.text.replace(/<br\s*\/?>/gi, " ");
729
+ const textElem = elem.append("text");
730
+ textElem.attr("x", textData.x);
731
+ textElem.attr("y", textData.y);
732
+ textElem.attr("class", "legend");
733
+ textElem.style("text-anchor", textData.anchor);
734
+ if (textData.class !== void 0) {
735
+ textElem.attr("class", textData.class);
736
+ }
737
+ const span = textElem.append("tspan");
738
+ span.attr("x", textData.x + textData.textMargin * 2);
739
+ span.text(nText);
740
+ return textElem;
741
+ }, "drawText");
742
+ var drawLabel = /* @__PURE__ */ __name(function(elem, txtObject) {
743
+ function genPoints(x, y, width, height, cut) {
744
+ return x + "," + y + " " + (x + width) + "," + y + " " + (x + width) + "," + (y + height - cut) + " " + (x + width - cut * 1.2) + "," + (y + height) + " " + x + "," + (y + height);
745
+ }
746
+ __name(genPoints, "genPoints");
747
+ const polygon = elem.append("polygon");
748
+ polygon.attr("points", genPoints(txtObject.x, txtObject.y, 50, 20, 7));
749
+ polygon.attr("class", "labelBox");
750
+ txtObject.y = txtObject.y + txtObject.labelMargin;
751
+ txtObject.x = txtObject.x + 0.5 * txtObject.labelMargin;
752
+ drawText(elem, txtObject);
753
+ }, "drawLabel");
754
+ var drawSection = /* @__PURE__ */ __name(function(elem, section, conf) {
755
+ const g = elem.append("g");
756
+ const rect = getNoteRect();
757
+ rect.x = section.x;
758
+ rect.y = section.y;
759
+ rect.fill = section.fill;
760
+ rect.width = conf.width;
761
+ rect.height = conf.height;
762
+ rect.class = "journey-section section-type-" + section.num;
763
+ rect.rx = 3;
764
+ rect.ry = 3;
765
+ drawRect(g, rect);
766
+ _drawTextCandidateFunc(conf)(
767
+ section.text,
768
+ g,
769
+ rect.x,
770
+ rect.y,
771
+ rect.width,
772
+ rect.height,
773
+ { class: "journey-section section-type-" + section.num },
774
+ conf,
775
+ section.colour
776
+ );
777
+ }, "drawSection");
778
+ var taskCount = -1;
779
+ var drawTask = /* @__PURE__ */ __name(function(elem, task, conf, diagramId) {
780
+ const center = task.x + conf.width / 2;
781
+ const g = elem.append("g");
782
+ taskCount++;
783
+ const maxHeight = 300 + 5 * 30;
784
+ g.append("line").attr("id", diagramId + "-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");
785
+ drawFace(g, {
786
+ cx: center,
787
+ cy: 300 + (5 - task.score) * 30,
788
+ score: task.score
789
+ });
790
+ const rect = getNoteRect();
791
+ rect.x = task.x;
792
+ rect.y = task.y;
793
+ rect.fill = task.fill;
794
+ rect.width = conf.width;
795
+ rect.height = conf.height;
796
+ rect.class = "task task-type-" + task.num;
797
+ rect.rx = 3;
798
+ rect.ry = 3;
799
+ drawRect(g, rect);
800
+ _drawTextCandidateFunc(conf)(
801
+ task.task,
802
+ g,
803
+ rect.x,
804
+ rect.y,
805
+ rect.width,
806
+ rect.height,
807
+ { class: "task" },
808
+ conf,
809
+ task.colour
810
+ );
811
+ }, "drawTask");
812
+ var drawBackgroundRect = /* @__PURE__ */ __name(function(elem, bounds) {
813
+ const rectElem = drawRect(elem, {
814
+ x: bounds.startx,
815
+ y: bounds.starty,
816
+ width: bounds.stopx - bounds.startx,
817
+ height: bounds.stopy - bounds.starty,
818
+ fill: bounds.fill,
819
+ class: "rect"
820
+ });
821
+ rectElem.lower();
822
+ }, "drawBackgroundRect");
823
+ var getTextObj = /* @__PURE__ */ __name(function() {
824
+ return {
825
+ x: 0,
826
+ y: 0,
827
+ fill: void 0,
828
+ "text-anchor": "start",
829
+ width: 100,
830
+ height: 100,
831
+ textMargin: 0,
832
+ rx: 0,
833
+ ry: 0
834
+ };
835
+ }, "getTextObj");
836
+ var getNoteRect = /* @__PURE__ */ __name(function() {
837
+ return {
838
+ x: 0,
839
+ y: 0,
840
+ width: 100,
841
+ anchor: "start",
842
+ height: 100,
843
+ rx: 0,
844
+ ry: 0
845
+ };
846
+ }, "getNoteRect");
847
+ var _drawTextCandidateFunc = /* @__PURE__ */ (function() {
848
+ function byText(content, g, x, y, width, height, textAttrs, colour) {
849
+ 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);
850
+ _setTextAttrs(text, textAttrs);
851
+ }
852
+ __name(byText, "byText");
853
+ function byTspan(content, g, x, y, width, height, textAttrs, conf, colour) {
854
+ const { taskFontSize, taskFontFamily } = conf;
855
+ const lines = content.split(/<br\s*\/?>/gi);
856
+ for (let i = 0; i < lines.length; i++) {
857
+ const dy = i * taskFontSize - taskFontSize * (lines.length - 1) / 2;
858
+ 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);
859
+ text.append("tspan").attr("x", x + width / 2).attr("dy", dy).text(lines[i]);
860
+ text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central");
861
+ _setTextAttrs(text, textAttrs);
862
+ }
863
+ }
864
+ __name(byTspan, "byTspan");
865
+ function byFo(content, g, x, y, width, height, textAttrs, conf) {
866
+ const body = g.append("switch");
867
+ const f = body.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height).attr("position", "fixed");
868
+ const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%");
869
+ text.append("div").attr("class", "label").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content);
870
+ byTspan(content, body, x, y, width, height, textAttrs, conf);
871
+ _setTextAttrs(text, textAttrs);
872
+ }
873
+ __name(byFo, "byFo");
874
+ function _setTextAttrs(toText, fromTextAttrsDict) {
875
+ for (const key in fromTextAttrsDict) {
876
+ if (key in fromTextAttrsDict) {
877
+ toText.attr(key, fromTextAttrsDict[key]);
878
+ }
879
+ }
880
+ }
881
+ __name(_setTextAttrs, "_setTextAttrs");
882
+ return function(conf) {
883
+ return conf.textPlacement === "fo" ? byFo : conf.textPlacement === "old" ? byText : byTspan;
884
+ };
885
+ })();
886
+ var initGraphics = /* @__PURE__ */ __name(function(graphics, id) {
887
+ nodeCount = 0;
888
+ taskCount = -1;
889
+ graphics.append("defs").append("marker").attr("id", 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");
890
+ }, "initGraphics");
891
+ function wrap(text, width) {
892
+ text.each(function() {
893
+ 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");
894
+ for (let j = 0; j < words.length; j++) {
895
+ word = words[words.length - 1 - j];
896
+ line.push(word);
897
+ tspan.text(line.join(" ").trim());
898
+ if (tspan.node().getComputedTextLength() > width || word === "<br>") {
899
+ line.pop();
900
+ tspan.text(line.join(" ").trim());
901
+ if (word === "<br>") {
902
+ line = [""];
903
+ } else {
904
+ line = [word];
905
+ }
906
+ tspan = text2.append("tspan").attr("x", 0).attr("y", y).attr("dy", lineHeight + "em").text(word);
907
+ }
908
+ }
909
+ });
910
+ }
911
+ __name(wrap, "wrap");
912
+ var drawNode = /* @__PURE__ */ __name(function(elem, node, fullSection, conf, diagramId, isEvent = false) {
913
+ const { theme, look } = conf;
914
+ const isReduxTheme = theme?.includes("redux");
915
+ const maxSections = conf?.themeVariables?.THEME_COLOR_LIMIT ?? 12;
916
+ const section = fullSection % maxSections - 1;
917
+ const nodeElem = elem.append("g");
918
+ node.section = section;
919
+ nodeElem.attr(
920
+ "class",
921
+ (node.class ? node.class + " " : "") + "timeline-node " + ("section-" + section)
922
+ );
923
+ const bkgElem = nodeElem.append("g");
924
+ const textElem = nodeElem.append("g");
925
+ 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);
926
+ const bbox = txt.node().getBBox();
927
+ const fontSize = conf.fontSize?.replace ? conf.fontSize.replace("px", "") : conf.fontSize;
928
+ node.height = bbox.height + fontSize * 1.1 * 0.5 + node.padding;
929
+ node.height = Math.max(node.height, node.maxHeight);
930
+ node.width = node.width + 2 * node.padding;
931
+ textElem.attr("transform", "translate(" + node.width / 2 + ", " + node.padding / 2 + ")");
932
+ if (isReduxTheme) {
933
+ textElem.attr(
934
+ "transform",
935
+ `translate(${node.width / 2}, ${isEvent ? node.padding / 2 + 3 : node.padding})`
936
+ );
937
+ }
938
+ defaultBkg(bkgElem, node, section, diagramId, conf);
939
+ if (look === "neo") {
940
+ nodeElem.attr("data-look", `neo`);
941
+ if (isReduxTheme) {
942
+ const isDark2 = theme.includes("dark");
943
+ const rootSvgNode = elem.node()?.ownerSVGElement ?? elem.node();
944
+ const rootSvg = select(rootSvgNode);
945
+ const svgId = rootSvg.attr("id") ?? "";
946
+ const dropShadowId = svgId ? `${svgId}-drop-shadow` : "drop-shadow";
947
+ if (rootSvg.select(`#${dropShadowId}`).empty()) {
948
+ const existingDefs = rootSvg.select("defs");
949
+ const defsEl = existingDefs.empty() ? rootSvg.append("defs") : existingDefs;
950
+ defsEl.append("filter").attr("id", dropShadowId).attr("height", "130%").attr("width", "130%").append("feDropShadow").attr("dx", "4").attr("dy", "4").attr("stdDeviation", 0).attr("flood-opacity", isDark2 ? "0.2" : "0.06").attr("flood-color", isDark2 ? "#FFFFFF" : "#000000");
951
+ }
952
+ }
953
+ }
954
+ return node;
955
+ }, "drawNode");
956
+ var getVirtualNodeHeight = /* @__PURE__ */ __name(function(elem, node, conf) {
957
+ const textElem = elem.append("g");
958
+ 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);
959
+ const bbox = txt.node().getBBox();
960
+ const fontSize = conf.fontSize?.replace ? conf.fontSize.replace("px", "") : conf.fontSize;
961
+ textElem.remove();
962
+ return bbox.height + fontSize * 1.1 * 0.5 + node.padding;
963
+ }, "getVirtualNodeHeight");
964
+ var defaultBkg = /* @__PURE__ */ __name(function(elem, node, section, diagramId, config) {
965
+ const { theme } = config;
966
+ const r = theme?.includes("redux") ? 0 : 5;
967
+ const rd = 5;
968
+ const d = r > 0 ? `M0 ${node.height - rd} v${-node.height + 2 * rd} q0,-${r},${r},-${r} h${node.width - 2 * rd} q${r},0,${r},${r} v${node.height - rd} H0 Z` : `M0 ${node.height - rd} v${-(node.height - rd)} h${node.width} v${node.height} H0 Z`;
969
+ elem.append("path").attr("id", diagramId + "-node-" + nodeCount++).attr("class", "node-bkg node-" + node.type).attr("d", d);
970
+ if (!theme?.includes("redux")) {
971
+ elem.append("line").attr("class", "node-line-" + section).attr("x1", 0).attr("y1", node.height).attr("x2", node.width).attr("y2", node.height);
972
+ }
973
+ }, "defaultBkg");
974
+ var svgDraw_default = {
975
+ drawRect,
976
+ drawCircle,
977
+ drawSection,
978
+ drawText,
979
+ drawLabel,
980
+ drawTask,
981
+ drawBackgroundRect,
982
+ getTextObj,
983
+ getNoteRect,
984
+ initGraphics,
985
+ drawNode,
986
+ getVirtualNodeHeight
987
+ };
988
+ var draw = /* @__PURE__ */ __name(function(text, id, version, diagObj) {
989
+ const conf = getConfig2();
990
+ const { look, theme, themeVariables } = conf;
991
+ const { useGradient, gradientStart, gradientStop } = themeVariables;
992
+ const LEFT_MARGIN = conf.timeline?.leftMargin ?? 50;
993
+ log.debug("timeline", diagObj.db);
994
+ const securityLevel = conf.securityLevel;
995
+ let sandboxElement;
996
+ if (securityLevel === "sandbox") {
997
+ sandboxElement = select("#i" + id);
998
+ }
999
+ const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
1000
+ const svg = root.select("#" + id);
1001
+ svg.append("g");
1002
+ const tasks2 = diagObj.db.getTasks();
1003
+ const title = diagObj.db.getCommonDb().getDiagramTitle();
1004
+ log.debug("task", tasks2);
1005
+ svgDraw_default.initGraphics(svg, id);
1006
+ const sections2 = diagObj.db.getSections();
1007
+ log.debug("sections", sections2);
1008
+ let maxSectionHeight = 0;
1009
+ let maxTaskHeight = 0;
1010
+ let depthY = 0;
1011
+ let sectionBeginY = 0;
1012
+ let masterX = 50 + LEFT_MARGIN;
1013
+ let masterY = 50;
1014
+ sectionBeginY = 50;
1015
+ let sectionNumber = 0;
1016
+ let hasSections = true;
1017
+ sections2.forEach(function(section) {
1018
+ const sectionNode = {
1019
+ number: sectionNumber,
1020
+ descr: section,
1021
+ section: sectionNumber,
1022
+ width: 150,
1023
+ padding: 20,
1024
+ maxHeight: maxSectionHeight
1025
+ };
1026
+ const sectionHeight = svgDraw_default.getVirtualNodeHeight(svg, sectionNode, conf);
1027
+ log.debug("sectionHeight before draw", sectionHeight);
1028
+ maxSectionHeight = Math.max(maxSectionHeight, sectionHeight + 20);
1029
+ });
1030
+ let maxEventCount = 0;
1031
+ let maxEventLineLength = 0;
1032
+ log.debug("tasks.length", tasks2.length);
1033
+ for (const [i, task] of tasks2.entries()) {
1034
+ const taskNode = {
1035
+ number: i,
1036
+ descr: task,
1037
+ section: task.section,
1038
+ width: 150,
1039
+ padding: 20,
1040
+ maxHeight: maxTaskHeight
1041
+ };
1042
+ const taskHeight = svgDraw_default.getVirtualNodeHeight(svg, taskNode, conf);
1043
+ log.debug("taskHeight before draw", taskHeight);
1044
+ maxTaskHeight = Math.max(maxTaskHeight, taskHeight + 20);
1045
+ maxEventCount = Math.max(maxEventCount, task.events.length);
1046
+ let maxEventLineLengthTemp = 0;
1047
+ for (const event of task.events) {
1048
+ const eventNode = {
1049
+ descr: event,
1050
+ section: task.section,
1051
+ number: task.section,
1052
+ width: 150,
1053
+ padding: 20,
1054
+ maxHeight: 50
1055
+ };
1056
+ maxEventLineLengthTemp += svgDraw_default.getVirtualNodeHeight(svg, eventNode, conf);
1057
+ }
1058
+ if (task.events.length > 0) {
1059
+ maxEventLineLengthTemp += (task.events.length - 1) * 10;
1060
+ }
1061
+ maxEventLineLength = Math.max(maxEventLineLength, maxEventLineLengthTemp);
1062
+ }
1063
+ log.debug("maxSectionHeight before draw", maxSectionHeight);
1064
+ log.debug("maxTaskHeight before draw", maxTaskHeight);
1065
+ if (sections2 && sections2.length > 0) {
1066
+ sections2.forEach((section) => {
1067
+ const tasksForSection = tasks2.filter((task) => task.section === section);
1068
+ const sectionNode = {
1069
+ number: sectionNumber,
1070
+ descr: section,
1071
+ section: sectionNumber,
1072
+ width: 200 * Math.max(tasksForSection.length, 1) - 50,
1073
+ padding: 20,
1074
+ maxHeight: maxSectionHeight
1075
+ };
1076
+ log.debug("sectionNode", sectionNode);
1077
+ const sectionNodeWrapper = svg.append("g");
1078
+ const node = svgDraw_default.drawNode(sectionNodeWrapper, sectionNode, sectionNumber, conf, id);
1079
+ log.debug("sectionNode output", node);
1080
+ sectionNodeWrapper.attr("transform", `translate(${masterX}, ${sectionBeginY})`);
1081
+ masterY += maxSectionHeight + 50;
1082
+ if (tasksForSection.length > 0) {
1083
+ drawTasks(
1084
+ svg,
1085
+ tasksForSection,
1086
+ sectionNumber,
1087
+ masterX,
1088
+ masterY,
1089
+ maxTaskHeight,
1090
+ conf,
1091
+ maxEventCount,
1092
+ maxEventLineLength,
1093
+ maxSectionHeight,
1094
+ false,
1095
+ id
1096
+ );
1097
+ }
1098
+ masterX += 200 * Math.max(tasksForSection.length, 1);
1099
+ masterY = sectionBeginY;
1100
+ sectionNumber++;
1101
+ });
1102
+ } else {
1103
+ hasSections = false;
1104
+ drawTasks(
1105
+ svg,
1106
+ tasks2,
1107
+ sectionNumber,
1108
+ masterX,
1109
+ masterY,
1110
+ maxTaskHeight,
1111
+ conf,
1112
+ maxEventCount,
1113
+ maxEventLineLength,
1114
+ maxSectionHeight,
1115
+ true,
1116
+ id
1117
+ );
1118
+ }
1119
+ const box = svg.node().getBBox();
1120
+ log.debug("bounds", box);
1121
+ if (title) {
1122
+ svg.append("text").text(title).attr("x", look === "neo" ? box.x * 2 + LEFT_MARGIN : box.width / 2 - LEFT_MARGIN).attr("font-size", "4ex").attr("font-weight", "bold").attr("y", 20);
1123
+ }
1124
+ depthY = hasSections ? maxSectionHeight + maxTaskHeight + 150 : maxTaskHeight + 100;
1125
+ const lineWrapper = svg.append("g").attr("class", "lineWrapper");
1126
+ 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(#${id}-arrowhead)`);
1127
+ if (look === "neo" && useGradient && theme !== "neutral") {
1128
+ const existingDefs = svg.select("defs");
1129
+ const defsEl = existingDefs.empty() ? svg.append("defs") : existingDefs;
1130
+ const gradient = defsEl.append("linearGradient").attr("id", svg.attr("id") + "-gradient").attr("gradientUnits", "objectBoundingBox").attr("x1", "0%").attr("y1", "0%").attr("x2", "100%").attr("y2", "0%");
1131
+ gradient.append("stop").attr("offset", "0%").attr("stop-color", gradientStart).attr("stop-opacity", 1);
1132
+ gradient.append("stop").attr("offset", "100%").attr("stop-color", gradientStop).attr("stop-opacity", 1);
1133
+ }
1134
+ setupGraphViewbox(
1135
+ void 0,
1136
+ svg,
1137
+ conf.timeline?.padding ?? 50,
1138
+ conf.timeline?.useMaxWidth ?? false
1139
+ );
1140
+ }, "draw");
1141
+ var drawTasks = /* @__PURE__ */ __name(function(diagram2, tasks2, sectionColor, masterX, masterY, maxTaskHeight, conf, maxEventCount, maxEventLineLength, maxSectionHeight, isWithoutSections, diagramId) {
1142
+ for (const task of tasks2) {
1143
+ const taskNode = {
1144
+ descr: task.task,
1145
+ section: sectionColor,
1146
+ number: sectionColor,
1147
+ width: 150,
1148
+ padding: 20,
1149
+ maxHeight: maxTaskHeight
1150
+ };
1151
+ log.debug("taskNode", taskNode);
1152
+ const taskWrapper = diagram2.append("g").attr("class", "taskWrapper");
1153
+ const node = svgDraw_default.drawNode(taskWrapper, taskNode, sectionColor, conf, diagramId);
1154
+ const taskHeight = node.height;
1155
+ log.debug("taskHeight after draw", taskHeight);
1156
+ taskWrapper.attr("transform", `translate(${masterX}, ${masterY})`);
1157
+ maxTaskHeight = Math.max(maxTaskHeight, taskHeight);
1158
+ if (task.events) {
1159
+ const lineWrapper = diagram2.append("g").attr("class", "lineWrapper");
1160
+ let lineLength = maxTaskHeight;
1161
+ masterY += 100;
1162
+ lineLength = lineLength + drawEvents(diagram2, task.events, sectionColor, masterX, masterY, conf, diagramId);
1163
+ masterY -= 100;
1164
+ lineWrapper.append("line").attr("x1", masterX + 190 / 2).attr("y1", masterY + maxTaskHeight).attr("x2", masterX + 190 / 2).attr("y2", masterY + maxTaskHeight + 100 + maxEventLineLength + 100).attr("stroke-width", 2).attr("stroke", "black").attr("marker-end", `url(#${diagramId}-arrowhead)`).attr("stroke-dasharray", "5,5");
1165
+ }
1166
+ masterX = masterX + 200;
1167
+ if (isWithoutSections && !conf.timeline?.disableMulticolor) {
1168
+ sectionColor++;
1169
+ }
1170
+ }
1171
+ masterY = masterY - 10;
1172
+ }, "drawTasks");
1173
+ var drawEvents = /* @__PURE__ */ __name(function(diagram2, events, sectionColor, masterX, masterY, conf, diagramId) {
1174
+ let maxEventHeight = 0;
1175
+ const eventBeginY = masterY;
1176
+ masterY = masterY + 100;
1177
+ for (const event of events) {
1178
+ const eventNode = {
1179
+ descr: event,
1180
+ section: sectionColor,
1181
+ number: sectionColor,
1182
+ width: 150,
1183
+ padding: 20,
1184
+ maxHeight: 50
1185
+ };
1186
+ log.debug("eventNode", eventNode);
1187
+ const eventWrapper = diagram2.append("g").attr("class", "eventWrapper");
1188
+ const node = svgDraw_default.drawNode(eventWrapper, eventNode, sectionColor, conf, diagramId, true);
1189
+ const eventHeight = node.height;
1190
+ maxEventHeight = maxEventHeight + eventHeight;
1191
+ eventWrapper.attr("transform", `translate(${masterX}, ${masterY})`);
1192
+ masterY = masterY + 10 + eventHeight;
1193
+ }
1194
+ masterY = eventBeginY;
1195
+ return maxEventHeight;
1196
+ }, "drawEvents");
1197
+ var timelineRenderer_default = {
1198
+ setConf: /* @__PURE__ */ __name(() => {
1199
+ }, "setConf"),
1200
+ draw
1201
+ };
1202
+ var NODE_WIDTH = 200;
1203
+ var NODE_PADDING = 5;
1204
+ var NODE_TOTAL_WIDTH = NODE_WIDTH + NODE_PADDING * 2;
1205
+ var EVENT_WIDTH = NODE_WIDTH + 100;
1206
+ var EVENT_TOTAL_WIDTH = EVENT_WIDTH + NODE_PADDING * 2;
1207
+ var EVENT_SPACING = 10;
1208
+ var EVENT_VERTICAL_GAP = 0;
1209
+ var SECTION_TASK_GAP = 20;
1210
+ var TASK_AXIS_GAP = 20;
1211
+ var TASK_VERTICAL_GAP = 30;
1212
+ var EVENT_AXIS_GAP = 50;
1213
+ var draw2 = /* @__PURE__ */ __name(function(text, id, version, diagObj) {
1214
+ const conf = getConfig2();
1215
+ const LEFT_MARGIN = conf.timeline?.leftMargin ?? 50;
1216
+ log.debug("timeline", diagObj.db);
1217
+ const svg = selectSvgElement(id);
1218
+ svg.append("g");
1219
+ const tasks2 = diagObj.db.getTasks();
1220
+ const title = diagObj.db.getCommonDb().getDiagramTitle();
1221
+ log.debug("task", tasks2);
1222
+ svgDraw_default.initGraphics(svg);
1223
+ const sections2 = diagObj.db.getSections();
1224
+ log.debug("sections", sections2);
1225
+ let maxSectionHeight = 0;
1226
+ let maxTaskHeight = 0;
1227
+ const masterX = 50 + LEFT_MARGIN;
1228
+ let masterY = 50;
1229
+ const contentTopY = masterY;
1230
+ const sectionBeginX = masterX;
1231
+ const leftWidth = NODE_TOTAL_WIDTH + TASK_AXIS_GAP;
1232
+ const rightWidth = EVENT_TOTAL_WIDTH + EVENT_AXIS_GAP;
1233
+ const axisX = sectionBeginX + leftWidth;
1234
+ let sectionNumber = 0;
1235
+ const hasSections = sections2 && sections2.length > 0;
1236
+ const timelineX = hasSections ? axisX : masterX + leftWidth;
1237
+ const sectionWidth = Math.max(50, leftWidth + rightWidth - NODE_PADDING * 2);
1238
+ sections2.forEach(function(section) {
1239
+ const sectionNode = {
1240
+ number: sectionNumber,
1241
+ descr: section,
1242
+ section: sectionNumber,
1243
+ width: sectionWidth,
1244
+ padding: NODE_PADDING,
1245
+ maxHeight: maxSectionHeight
1246
+ };
1247
+ const sectionHeight = svgDraw_default.getVirtualNodeHeight(svg, sectionNode, conf);
1248
+ log.debug("sectionHeight before draw", sectionHeight);
1249
+ maxSectionHeight = Math.max(maxSectionHeight, sectionHeight);
1250
+ });
1251
+ let maxEventStackHeight = 0;
1252
+ log.debug("tasks.length", tasks2.length);
1253
+ for (const [i, task] of tasks2.entries()) {
1254
+ const taskNode = {
1255
+ number: i,
1256
+ descr: task,
1257
+ section: task.section,
1258
+ width: NODE_WIDTH,
1259
+ padding: NODE_PADDING,
1260
+ maxHeight: maxTaskHeight
1261
+ };
1262
+ const taskHeight = svgDraw_default.getVirtualNodeHeight(svg, taskNode, conf);
1263
+ log.debug("taskHeight before draw", taskHeight);
1264
+ maxTaskHeight = Math.max(maxTaskHeight, taskHeight);
1265
+ let maxEventStackHeightTemp = 0;
1266
+ for (const event of task.events) {
1267
+ const eventNode = {
1268
+ descr: event,
1269
+ section: task.section,
1270
+ number: task.section,
1271
+ width: EVENT_WIDTH,
1272
+ padding: NODE_PADDING,
1273
+ maxHeight: 50
1274
+ };
1275
+ maxEventStackHeightTemp += svgDraw_default.getVirtualNodeHeight(svg, eventNode, conf);
1276
+ }
1277
+ if (task.events.length > 0) {
1278
+ maxEventStackHeightTemp += (task.events.length - 1) * EVENT_SPACING;
1279
+ }
1280
+ maxEventStackHeight = Math.max(maxEventStackHeight, maxEventStackHeightTemp) + EVENT_VERTICAL_GAP;
1281
+ }
1282
+ log.debug("maxSectionHeight before draw", maxSectionHeight);
1283
+ log.debug("maxTaskHeight before draw", maxTaskHeight);
1284
+ const taskBlockHeight = Math.max(maxTaskHeight, maxEventStackHeight);
1285
+ const taskSpacing = taskBlockHeight + TASK_VERTICAL_GAP;
1286
+ if (hasSections) {
1287
+ sections2.forEach((section) => {
1288
+ const tasksForSection = tasks2.filter((task) => task.section === section);
1289
+ const sectionNode = {
1290
+ number: sectionNumber,
1291
+ descr: section,
1292
+ section: sectionNumber,
1293
+ width: sectionWidth,
1294
+ padding: NODE_PADDING,
1295
+ maxHeight: maxSectionHeight
1296
+ };
1297
+ log.debug("sectionNode", sectionNode);
1298
+ const sectionNodeWrapper = svg.append("g");
1299
+ const node = svgDraw_default.drawNode(sectionNodeWrapper, sectionNode, sectionNumber, conf);
1300
+ log.debug("sectionNode output", node);
1301
+ const sectionX = timelineX - leftWidth;
1302
+ sectionNodeWrapper.attr("transform", `translate(${sectionX}, ${masterY})`);
1303
+ const taskStartY = masterY + node.height + SECTION_TASK_GAP;
1304
+ if (tasksForSection.length > 0) {
1305
+ drawTasks2(
1306
+ svg,
1307
+ tasksForSection,
1308
+ sectionNumber,
1309
+ timelineX,
1310
+ taskStartY,
1311
+ maxTaskHeight,
1312
+ conf,
1313
+ taskSpacing,
1314
+ false
1315
+ );
1316
+ }
1317
+ const taskCount2 = tasksForSection.length;
1318
+ const sectionHeight = node.height + SECTION_TASK_GAP + taskSpacing * Math.max(taskCount2, 1) - (taskCount2 > 0 ? TASK_VERTICAL_GAP * 2 : 0);
1319
+ masterY += sectionHeight;
1320
+ sectionNumber++;
1321
+ });
1322
+ } else {
1323
+ drawTasks2(
1324
+ svg,
1325
+ tasks2,
1326
+ sectionNumber,
1327
+ timelineX,
1328
+ masterY,
1329
+ maxTaskHeight,
1330
+ conf,
1331
+ taskSpacing,
1332
+ true
1333
+ );
1334
+ }
1335
+ let box = svg.node()?.getBBox();
1336
+ if (!box) {
1337
+ throw new Error("bbox not found");
1338
+ }
1339
+ log.debug("bounds", box);
1340
+ if (title) {
1341
+ svg.append("text").text(title).attr("x", box.width / 2 - LEFT_MARGIN).attr("font-size", "4ex").attr("font-weight", "bold").attr("y", 20);
1342
+ box = svg.node()?.getBBox();
1343
+ if (!box) {
1344
+ throw new Error("bbox not found");
1345
+ }
1346
+ log.debug("bounds after title", box);
1347
+ }
1348
+ const [fontSize] = parseFontSize(conf.fontSize);
1349
+ const arrowTopOffset = (fontSize ?? 16) * 2;
1350
+ const arrowBottomPadding = (fontSize ?? 16) * 0.5 + 20;
1351
+ const lineWrapper = svg.append("g").attr("class", "lineWrapper");
1352
+ lineWrapper.append("line").attr("x1", timelineX).attr("y1", contentTopY - arrowTopOffset).attr("x2", timelineX).attr("y2", box.y + box.height + arrowBottomPadding).attr("stroke-width", 4).attr("stroke", "black").attr("marker-end", "url(#arrowhead)");
1353
+ lineWrapper.lower();
1354
+ setupGraphViewbox(
1355
+ void 0,
1356
+ svg,
1357
+ conf.timeline?.padding ?? 50,
1358
+ conf.timeline?.useMaxWidth ?? false
1359
+ );
1360
+ }, "draw");
1361
+ var drawTasks2 = /* @__PURE__ */ __name(function(diagram2, tasks2, sectionColor, timelineX, masterY, maxTaskHeight, conf, taskSpacing, isWithoutSections) {
1362
+ for (const task of tasks2) {
1363
+ const taskNode = {
1364
+ descr: task.task,
1365
+ section: sectionColor,
1366
+ number: sectionColor,
1367
+ width: NODE_WIDTH,
1368
+ padding: NODE_PADDING,
1369
+ maxHeight: maxTaskHeight
1370
+ };
1371
+ log.debug("taskNode", taskNode);
1372
+ const taskWrapper = diagram2.append("g").attr("class", "taskWrapper");
1373
+ const node = svgDraw_default.drawNode(taskWrapper, taskNode, sectionColor, conf);
1374
+ const taskHeight = node.height;
1375
+ log.debug("taskHeight after draw", taskHeight);
1376
+ const taskX = timelineX - TASK_AXIS_GAP - node.width;
1377
+ taskWrapper.attr("transform", `translate(${taskX}, ${masterY})`);
1378
+ maxTaskHeight = Math.max(maxTaskHeight, taskHeight);
1379
+ if (task.events && task.events.length > 0) {
1380
+ const eventsStartY = masterY;
1381
+ const eventsX = timelineX + EVENT_AXIS_GAP;
1382
+ drawEvents2(diagram2, task.events, sectionColor, timelineX, eventsX, eventsStartY, conf);
1383
+ }
1384
+ masterY = masterY + taskSpacing;
1385
+ if (isWithoutSections && !conf.timeline?.disableMulticolor) {
1386
+ sectionColor++;
1387
+ }
1388
+ }
1389
+ }, "drawTasks");
1390
+ var drawEvents2 = /* @__PURE__ */ __name(function(diagram2, events, sectionColor, axisX, eventsX, startY, conf) {
1391
+ let currentY = startY;
1392
+ for (const event of events) {
1393
+ const eventNode = {
1394
+ descr: event,
1395
+ section: sectionColor,
1396
+ number: sectionColor,
1397
+ width: EVENT_WIDTH,
1398
+ padding: NODE_PADDING,
1399
+ maxHeight: 0
1400
+ };
1401
+ log.debug("eventNode", eventNode);
1402
+ const eventWrapper = diagram2.append("g").attr("class", "eventWrapper");
1403
+ const node = svgDraw_default.drawNode(eventWrapper, eventNode, sectionColor, conf);
1404
+ const eventHeight = node.height;
1405
+ eventWrapper.attr("transform", `translate(${eventsX}, ${currentY})`);
1406
+ const lineWrapper = diagram2.append("g").attr("class", "lineWrapper");
1407
+ const lineY = currentY + eventHeight / 2;
1408
+ lineWrapper.append("line").attr("x1", axisX).attr("y1", lineY).attr("x2", eventsX).attr("y2", lineY).attr("stroke-width", 2).attr("stroke", "black").attr("marker-end", "url(#arrowhead)").attr("stroke-dasharray", "5,5");
1409
+ currentY = currentY + eventHeight + EVENT_SPACING;
1410
+ }
1411
+ return currentY - startY;
1412
+ }, "drawEvents");
1413
+ var timelineRendererVertical_default = {
1414
+ setConf: /* @__PURE__ */ __name(() => {
1415
+ }, "setConf"),
1416
+ draw: draw2
1417
+ };
1418
+ var genReduxSections = /* @__PURE__ */ __name((options) => {
1419
+ const { theme } = getConfig();
1420
+ const isDarkTheme = theme?.includes("dark");
1421
+ const isColorTheme = theme?.includes("color");
1422
+ const rawSvgId = options.svgId?.replace(/^#/, "") ?? "";
1423
+ const scopedDropShadow = rawSvgId ? `url(#${rawSvgId}-drop-shadow)` : options.dropShadow ?? "none";
1424
+ let sections2 = "";
1425
+ for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) {
1426
+ const sw = `${17 - 3 * i}`;
1427
+ const color = isColorTheme ? options.borderColorArray[i] : options.mainBkg;
1428
+ const stroke = isColorTheme ? options.borderColorArray[i] : options.nodeBorder;
1429
+ sections2 += `
1430
+ .section-${i - 1} rect,
1431
+ .section-${i - 1} path,
1432
+ .section-${i - 1} circle {
1433
+ fill: ${isDarkTheme && isColorTheme ? options.mainBkg : color};
1434
+ stroke: ${stroke};
1435
+ stroke-width: ${options.strokeWidth};
1436
+ filter: ${scopedDropShadow};
1437
+ }
1438
+
1439
+ .section-${i - 1} text {
1440
+ fill: ${options.nodeBorder};
1441
+ font-weight: ${options.fontWeight}
1442
+ }
1443
+
1444
+ .node-icon-${i - 1} {
1445
+ font-size: 40px;
1446
+ color: ${options["cScaleLabel" + i]};
1447
+ }
1448
+
1449
+ .section-edge-${i - 1} {
1450
+ stroke: ${options["cScale" + i]};
1451
+ }
1452
+
1453
+ .edge-depth-${i - 1} {
1454
+ stroke-width: ${sw};
1455
+ }
1456
+
1457
+ .section-${i - 1} line {
1458
+ stroke: ${options["cScaleInv" + i]};
1459
+ stroke-width: 3;
1460
+ }
1461
+
1462
+ .lineWrapper line {
1463
+ stroke: ${options.nodeBorder};
1464
+ stroke-width:${options.strokeWidth}
1465
+ }
1466
+
1467
+ .disabled,
1468
+ .disabled circle,
1469
+ .disabled text {
1470
+ fill: ${options.tertiaryColor ?? "lightgray"};
1471
+ }
1472
+
1473
+ .disabled text {
1474
+ fill: ${options.clusterBorder ?? "#efefef"};
1475
+ }
1476
+ `;
1477
+ }
1478
+ return sections2;
1479
+ }, "genReduxSections");
1480
+ var genSections = /* @__PURE__ */ __name((options) => {
1481
+ let sections2 = "";
1482
+ for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) {
1483
+ options["lineColor" + i] = options["lineColor" + i] || options["cScaleInv" + i];
1484
+ if (isDark(options["lineColor" + i])) {
1485
+ options["lineColor" + i] = lighten(options["lineColor" + i], 20);
1486
+ } else {
1487
+ options["lineColor" + i] = darken(options["lineColor" + i], 20);
1488
+ }
1489
+ }
1490
+ for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) {
1491
+ const sw = "" + (17 - 3 * i);
1492
+ sections2 += `
1493
+ .section-${i - 1} rect, .section-${i - 1} path, .section-${i - 1} circle, .section-${i - 1} path {
1494
+ fill: ${options["cScale" + i]};
1495
+ }
1496
+ .section-${i - 1} text {
1497
+ fill: ${options["cScaleLabel" + i]};
1498
+ }
1499
+ .node-icon-${i - 1} {
1500
+ font-size: 40px;
1501
+ color: ${options["cScaleLabel" + i]};
1502
+ }
1503
+ .section-edge-${i - 1}{
1504
+ stroke: ${options["cScale" + i]};
1505
+ }
1506
+ .edge-depth-${i - 1}{
1507
+ stroke-width: ${sw};
1508
+ }
1509
+ .section-${i - 1} line {
1510
+ stroke: ${options["cScaleInv" + i]} ;
1511
+ stroke-width: 3;
1512
+ }
1513
+
1514
+ .lineWrapper line{
1515
+ stroke: ${options["cScaleLabel" + i]} ;
1516
+ }
1517
+
1518
+ .disabled, .disabled circle, .disabled text {
1519
+ fill: ${options.tertiaryColor ?? "lightgray"};
1520
+ }
1521
+ .disabled text {
1522
+ fill: ${options.clusterBorder ?? "#efefef"};
1523
+ }
1524
+ `;
1525
+ }
1526
+ return sections2;
1527
+ }, "genSections");
1528
+ var getStyles = /* @__PURE__ */ __name((options) => {
1529
+ const { theme } = getConfig();
1530
+ const isReduxTheme = theme?.includes("redux");
1531
+ const isNeutralTheme = theme === "neutral";
1532
+ const rawSvgId = options.svgId?.replace(/^#/, "") ?? "";
1533
+ let gradientSections = "";
1534
+ if (options.useGradient && rawSvgId && options.THEME_COLOR_LIMIT && !isNeutralTheme) {
1535
+ for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) {
1536
+ gradientSections += `
1537
+ .section-${i - 1}[data-look="neo"] rect,
1538
+ .section-${i - 1}[data-look="neo"] path,
1539
+ .section-${i - 1}[data-look="neo"] circle {
1540
+ fill: ${options.mainBkg};
1541
+ stroke: url(#${rawSvgId}-gradient);
1542
+ stroke-width: 2;
1543
+ }
1544
+ .section-${i - 1}[data-look="neo"] line {
1545
+ stroke: url(#${rawSvgId}-gradient);
1546
+ stroke-width: 2;
1547
+ }`;
1548
+ }
1549
+ }
1550
+ return `
1551
+ .edge {
1552
+ stroke-width: 3;
1553
+ }
1554
+ ${isReduxTheme ? genReduxSections(options) : genSections(options)}
1555
+ ${gradientSections}
1556
+ .section-root rect, .section-root path, .section-root circle {
1557
+ fill: ${options.git0};
1558
+ }
1559
+ .section-root text {
1560
+ fill: ${options.gitBranchLabel0};
1561
+ }
1562
+ .icon-container {
1563
+ height:100%;
1564
+ display: flex;
1565
+ justify-content: center;
1566
+ align-items: center;
1567
+ }
1568
+ .edge {
1569
+ fill: none;
1570
+ }
1571
+ .eventWrapper {
1572
+ filter: brightness(120%);
1573
+ }
1574
+ `;
1575
+ }, "getStyles");
1576
+ var styles_default = getStyles;
1577
+ var rendererSelector = {
1578
+ setConf: /* @__PURE__ */ __name(() => {
1579
+ }, "setConf"),
1580
+ draw: /* @__PURE__ */ __name((text, id, version, diagObj) => {
1581
+ const direction2 = diagObj?.db?.getDirection?.() ?? "LR";
1582
+ if (direction2 === "TD") {
1583
+ return timelineRendererVertical_default.draw(text, id, version, diagObj);
1584
+ }
1585
+ return timelineRenderer_default.draw(text, id, version, diagObj);
1586
+ }, "draw")
1587
+ };
1588
+ var diagram = {
1589
+ db: timelineDb_exports,
1590
+ renderer: rendererSelector,
1591
+ parser: timeline_default,
1592
+ styles: styles_default
1593
+ };
1594
+ export {
1595
+ diagram
1596
+ };