@aidapt/caity-chat 3.0.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 (62) hide show
  1. package/README.md +73 -0
  2. package/dist/lib/_baseUniq-BVCT-t6P.js +477 -0
  3. package/dist/lib/arc-Kj6ZmwPS.js +83 -0
  4. package/dist/lib/architectureDiagram-Q4EWVU46-DA4kYaz_.js +4690 -0
  5. package/dist/lib/blockDiagram-DXYQGD6D-BWT5yya1.js +2295 -0
  6. package/dist/lib/c4Diagram-AHTNJAMY-BjY6DW3U.js +1577 -0
  7. package/dist/lib/caity-chat.tgz +0 -0
  8. package/dist/lib/channel-BjraetTo.js +5 -0
  9. package/dist/lib/chunk-4BX2VUAB-iSPZGgxQ.js +8 -0
  10. package/dist/lib/chunk-4TB4RGXK-DvnUcLoe.js +1465 -0
  11. package/dist/lib/chunk-55IACEB6-Mw25YX9j.js +8 -0
  12. package/dist/lib/chunk-EDXVE4YY-Dtbxz7df.js +19 -0
  13. package/dist/lib/chunk-FMBD7UC4-OCIy3top.js +19 -0
  14. package/dist/lib/chunk-OYMX7WX6-DFW9El2C.js +1383 -0
  15. package/dist/lib/chunk-QZHKN3VN-BYFTfk7k.js +15 -0
  16. package/dist/lib/chunk-YZCP3GAM-Cs-HTcyJ.js +68 -0
  17. package/dist/lib/classDiagram-6PBFFD2Q-CrDUlIYr.js +16 -0
  18. package/dist/lib/classDiagram-v2-HSJHXN6E-CrDUlIYr.js +16 -0
  19. package/dist/lib/clone-C0qEGPCz.js +8 -0
  20. package/dist/lib/cose-bilkent-S5V4N54A-H1-YbKvI.js +2609 -0
  21. package/dist/lib/cytoscape.esm-D_3MZVO6.js +18707 -0
  22. package/dist/lib/dagre-KV5264BT-DhEnTJ4D.js +443 -0
  23. package/dist/lib/defaultLocale-BgPVtth8.js +171 -0
  24. package/dist/lib/diagram-5BDNPKRD-CK6wgKxI.js +123 -0
  25. package/dist/lib/diagram-G4DWMVQ6-IhA_MJ0t.js +528 -0
  26. package/dist/lib/diagram-MMDJMWI5-DDuA1rYY.js +217 -0
  27. package/dist/lib/diagram-TYMM5635-_VI1en0S.js +142 -0
  28. package/dist/lib/erDiagram-SMLLAGMA-B1REwW7y.js +899 -0
  29. package/dist/lib/flowDiagram-DWJPFMVM-rWzOGDlg.js +1628 -0
  30. package/dist/lib/ganttDiagram-T4ZO3ILL-UhSvbAmM.js +2701 -0
  31. package/dist/lib/gitGraphDiagram-UUTBAWPF-DrsSMMoJ.js +815 -0
  32. package/dist/lib/graph-DMr8NrNW.js +738 -0
  33. package/dist/lib/index.d.ts +665 -0
  34. package/dist/lib/index.js +52 -0
  35. package/dist/lib/infoDiagram-42DDH7IO-CPF3XCNj.js +24 -0
  36. package/dist/lib/init-DjUOC4st.js +16 -0
  37. package/dist/lib/ishikawaDiagram-UXIWVN3A-B4Nt1TdW.js +621 -0
  38. package/dist/lib/journeyDiagram-VCZTEJTY-DW5yRsOM.js +834 -0
  39. package/dist/lib/kanban-definition-6JOO6SKY-5DmJRubo.js +724 -0
  40. package/dist/lib/layout-B00IQLgh.js +1441 -0
  41. package/dist/lib/linear-LLab47WO.js +259 -0
  42. package/dist/lib/main-C9dvh9CT.js +88771 -0
  43. package/dist/lib/mermaid.core-BrBkhL9h.js +15967 -0
  44. package/dist/lib/min-CJFyJhXg.js +38 -0
  45. package/dist/lib/mindmap-definition-QFDTVHPH-doqZCFNi.js +833 -0
  46. package/dist/lib/ordinal-B6-f3MAq.js +61 -0
  47. package/dist/lib/pieDiagram-DEJITSTG-DKi5GKup.js +163 -0
  48. package/dist/lib/quadrantDiagram-34T5L4WZ-COYWmEhy.js +1022 -0
  49. package/dist/lib/requirementDiagram-MS252O5E-D3odK6YH.js +882 -0
  50. package/dist/lib/sankeyDiagram-XADWPNL6-D36eaMCx.js +810 -0
  51. package/dist/lib/sequenceDiagram-FGHM5R23-NpESTwMk.js +2883 -0
  52. package/dist/lib/standalone.js +4 -0
  53. package/dist/lib/stateDiagram-FHFEXIEX-kXZ_Bn-a.js +263 -0
  54. package/dist/lib/stateDiagram-v2-QKLJ7IA2-B5xMdEuE.js +16 -0
  55. package/dist/lib/timeline-definition-GMOUNBTQ-DZDdcJwy.js +1055 -0
  56. package/dist/lib/vennDiagram-DHZGUBPP-Clhb6EGF.js +1557 -0
  57. package/dist/lib/wardley-RL74JXVD-CwSnyVu7.js +18396 -0
  58. package/dist/lib/wardleyDiagram-NUSXRM2D-DnXL4F04.js +594 -0
  59. package/dist/lib/xychartDiagram-5P7HB3ND-CweIkrg3.js +1342 -0
  60. package/package.json +95 -0
  61. package/src/types/caity-chat.d.ts +213 -0
  62. package/src/types/template-slots.d.ts +167 -0
@@ -0,0 +1,123 @@
1
+ import { p as x, b as f, s as C, q as B, g as T, a as y, _ as s, F as u, l as k, I as V, e as _, D, G as N, z as S } from "./mermaid.core-BrBkhL9h.js";
2
+ import { p as I } from "./chunk-4BX2VUAB-iSPZGgxQ.js";
3
+ import { I as $ } from "./chunk-QZHKN3VN-BYFTfk7k.js";
4
+ import { p as z } from "./wardley-RL74JXVD-CwSnyVu7.js";
5
+ var d = new $(() => ({
6
+ cnt: 1,
7
+ stack: [
8
+ {
9
+ id: 0,
10
+ level: -1,
11
+ name: "/",
12
+ children: []
13
+ }
14
+ ]
15
+ })), A = /* @__PURE__ */ s(() => {
16
+ d.reset(), S();
17
+ }, "clear"), X = /* @__PURE__ */ s(() => d.records.stack[0], "getRoot"), H = /* @__PURE__ */ s(() => d.records.cnt, "getCount"), L = N.treeView, R = /* @__PURE__ */ s(() => u(L, D().treeView), "getConfig"), W = /* @__PURE__ */ s((e, t) => {
18
+ for (; e <= d.records.stack[d.records.stack.length - 1].level; )
19
+ d.records.stack.pop();
20
+ const a = {
21
+ id: d.records.cnt++,
22
+ level: e,
23
+ name: t,
24
+ children: []
25
+ };
26
+ d.records.stack[d.records.stack.length - 1].children.push(a), d.records.stack.push(a);
27
+ }, "addNode"), E = {
28
+ clear: A,
29
+ addNode: W,
30
+ getRoot: X,
31
+ getCount: H,
32
+ getConfig: R,
33
+ getAccTitle: y,
34
+ getAccDescription: T,
35
+ getDiagramTitle: B,
36
+ setAccDescription: C,
37
+ setAccTitle: f,
38
+ setDiagramTitle: x
39
+ }, m = E, F = /* @__PURE__ */ s((e) => {
40
+ I(e, m), e.nodes.map((t) => m.addNode(t.indent ? parseInt(t.indent) : 0, t.name));
41
+ }, "populate"), M = {
42
+ parse: /* @__PURE__ */ s(async (e) => {
43
+ const t = await z("treeView", e);
44
+ k.debug(t), F(t);
45
+ }, "parse")
46
+ }, Y = /* @__PURE__ */ s((e, t, a, n, o) => {
47
+ const c = n.append("text").text(a.name).attr("dominant-baseline", "middle").attr("class", "treeView-node-label"), { height: g, width: r } = c.node().getBBox(), l = g + o.paddingY * 2, i = r + o.paddingX * 2;
48
+ c.attr("x", e + o.paddingX), c.attr("y", t + l / 2), a.BBox = {
49
+ x: e,
50
+ y: t,
51
+ width: i,
52
+ height: l
53
+ };
54
+ }, "positionLabel"), b = /* @__PURE__ */ s((e, t, a, n, o, c) => e.append("line").attr("x1", t).attr("y1", a).attr("x2", n).attr("y2", o).attr("stroke-width", c).attr("class", "treeView-node-line"), "positionLine"), q = /* @__PURE__ */ s((e, t, a) => {
55
+ let n = 0, o = 0;
56
+ const c = /* @__PURE__ */ s((r, l, i, h) => {
57
+ const v = h * (i.rowIndent + i.paddingX);
58
+ Y(v, n, l, r, i);
59
+ const { height: p, width: w } = l.BBox;
60
+ b(
61
+ r,
62
+ v - i.rowIndent,
63
+ n + p / 2,
64
+ v,
65
+ n + p / 2,
66
+ i.lineThickness
67
+ ), o = Math.max(o, v + w), n += p;
68
+ }, "drawNode"), g = /* @__PURE__ */ s((r, l = 0) => {
69
+ c(e, r, a, l), r.children.forEach((p) => {
70
+ g(p, l + 1);
71
+ });
72
+ const { x: i, y: h, height: v } = r.BBox;
73
+ if (r.children.length) {
74
+ const { y: p, height: w } = r.children[r.children.length - 1].BBox;
75
+ b(
76
+ e,
77
+ i + a.paddingX,
78
+ h + v,
79
+ i + a.paddingX,
80
+ p + w / 2 + a.lineThickness / 2,
81
+ a.lineThickness
82
+ );
83
+ }
84
+ }, "processNode");
85
+ return g(t), { totalHeight: n, totalWidth: o };
86
+ }, "drawTree"), G = /* @__PURE__ */ s((e, t, a, n) => {
87
+ k.debug(`Rendering treeView diagram
88
+ ` + e);
89
+ const o = n.db, c = o.getRoot(), g = o.getConfig(), r = V(t), l = r.append("g");
90
+ l.attr("class", "tree-view");
91
+ const { totalHeight: i, totalWidth: h } = q(l, c, g);
92
+ r.attr("viewBox", `-${g.lineThickness / 2} 0 ${h} ${i}`), _(r, i, h, g.useMaxWidth);
93
+ }, "draw"), j = {
94
+ draw: G
95
+ }, J = j, K = {
96
+ labelFontSize: "16px",
97
+ labelColor: "black",
98
+ lineColor: "black"
99
+ }, O = /* @__PURE__ */ s(({
100
+ treeView: e
101
+ }) => {
102
+ const { labelFontSize: t, labelColor: a, lineColor: n } = u(
103
+ K,
104
+ e
105
+ );
106
+ return `
107
+ .treeView-node-label {
108
+ font-size: ${t};
109
+ fill: ${a};
110
+ }
111
+ .treeView-node-line {
112
+ stroke: ${n};
113
+ }
114
+ `;
115
+ }, "styles"), P = O, te = {
116
+ db: m,
117
+ renderer: J,
118
+ parser: M,
119
+ styles: P
120
+ };
121
+ export {
122
+ te as diagram
123
+ };
@@ -0,0 +1,528 @@
1
+ import { _ as w, K as he, D as ee, F as J, I as ue, e as pe, l as Q, bb as P, d as j, b as fe, a as me, p as ge, q as ye, g as Se, s as ve, G as xe, bc as be, z as we } from "./mermaid.core-BrBkhL9h.js";
2
+ import { s as Ce } from "./chunk-EDXVE4YY-Dtbxz7df.js";
3
+ import { p as Te } from "./chunk-4BX2VUAB-iSPZGgxQ.js";
4
+ import { p as Le } from "./wardley-RL74JXVD-CwSnyVu7.js";
5
+ import { b as O } from "./defaultLocale-BgPVtth8.js";
6
+ import { o as Z } from "./ordinal-B6-f3MAq.js";
7
+ function $e(t) {
8
+ var a = 0, l = t.children, n = l && l.length;
9
+ if (!n) a = 1;
10
+ else for (; --n >= 0; ) a += l[n].value;
11
+ t.value = a;
12
+ }
13
+ function Ae() {
14
+ return this.eachAfter($e);
15
+ }
16
+ function Fe(t, a) {
17
+ let l = -1;
18
+ for (const n of this)
19
+ t.call(a, n, ++l, this);
20
+ return this;
21
+ }
22
+ function Ne(t, a) {
23
+ for (var l = this, n = [l], r, i, d = -1; l = n.pop(); )
24
+ if (t.call(a, l, ++d, this), r = l.children)
25
+ for (i = r.length - 1; i >= 0; --i)
26
+ n.push(r[i]);
27
+ return this;
28
+ }
29
+ function Me(t, a) {
30
+ for (var l = this, n = [l], r = [], i, d, h, m = -1; l = n.pop(); )
31
+ if (r.push(l), i = l.children)
32
+ for (d = 0, h = i.length; d < h; ++d)
33
+ n.push(i[d]);
34
+ for (; l = r.pop(); )
35
+ t.call(a, l, ++m, this);
36
+ return this;
37
+ }
38
+ function Ve(t, a) {
39
+ let l = -1;
40
+ for (const n of this)
41
+ if (t.call(a, n, ++l, this))
42
+ return n;
43
+ }
44
+ function _e(t) {
45
+ return this.eachAfter(function(a) {
46
+ for (var l = +t(a.data) || 0, n = a.children, r = n && n.length; --r >= 0; ) l += n[r].value;
47
+ a.value = l;
48
+ });
49
+ }
50
+ function ke(t) {
51
+ return this.eachBefore(function(a) {
52
+ a.children && a.children.sort(t);
53
+ });
54
+ }
55
+ function ze(t) {
56
+ for (var a = this, l = De(a, t), n = [a]; a !== l; )
57
+ a = a.parent, n.push(a);
58
+ for (var r = n.length; t !== l; )
59
+ n.splice(r, 0, t), t = t.parent;
60
+ return n;
61
+ }
62
+ function De(t, a) {
63
+ if (t === a) return t;
64
+ var l = t.ancestors(), n = a.ancestors(), r = null;
65
+ for (t = l.pop(), a = n.pop(); t === a; )
66
+ r = t, t = l.pop(), a = n.pop();
67
+ return r;
68
+ }
69
+ function Pe() {
70
+ for (var t = this, a = [t]; t = t.parent; )
71
+ a.push(t);
72
+ return a;
73
+ }
74
+ function Be() {
75
+ return Array.from(this);
76
+ }
77
+ function Re() {
78
+ var t = [];
79
+ return this.eachBefore(function(a) {
80
+ a.children || t.push(a);
81
+ }), t;
82
+ }
83
+ function Ee() {
84
+ var t = this, a = [];
85
+ return t.each(function(l) {
86
+ l !== t && a.push({ source: l.parent, target: l });
87
+ }), a;
88
+ }
89
+ function* We() {
90
+ var t = this, a, l = [t], n, r, i;
91
+ do
92
+ for (a = l.reverse(), l = []; t = a.pop(); )
93
+ if (yield t, n = t.children)
94
+ for (r = 0, i = n.length; r < i; ++r)
95
+ l.push(n[r]);
96
+ while (l.length);
97
+ }
98
+ function te(t, a) {
99
+ t instanceof Map ? (t = [void 0, t], a === void 0 && (a = Oe)) : a === void 0 && (a = He);
100
+ for (var l = new K(t), n, r = [l], i, d, h, m; n = r.pop(); )
101
+ if ((d = a(n.data)) && (m = (d = Array.from(d)).length))
102
+ for (n.children = d, h = m - 1; h >= 0; --h)
103
+ r.push(i = d[h] = new K(d[h])), i.parent = n, i.depth = n.depth + 1;
104
+ return l.eachBefore(qe);
105
+ }
106
+ function Ie() {
107
+ return te(this).eachBefore(Ge);
108
+ }
109
+ function He(t) {
110
+ return t.children;
111
+ }
112
+ function Oe(t) {
113
+ return Array.isArray(t) ? t[1] : null;
114
+ }
115
+ function Ge(t) {
116
+ t.data.value !== void 0 && (t.value = t.data.value), t.data = t.data.data;
117
+ }
118
+ function qe(t) {
119
+ var a = 0;
120
+ do
121
+ t.height = a;
122
+ while ((t = t.parent) && t.height < ++a);
123
+ }
124
+ function K(t) {
125
+ this.data = t, this.depth = this.height = 0, this.parent = null;
126
+ }
127
+ K.prototype = te.prototype = {
128
+ constructor: K,
129
+ count: Ae,
130
+ each: Fe,
131
+ eachAfter: Me,
132
+ eachBefore: Ne,
133
+ find: Ve,
134
+ sum: _e,
135
+ sort: ke,
136
+ path: ze,
137
+ ancestors: Pe,
138
+ descendants: Be,
139
+ leaves: Re,
140
+ links: Ee,
141
+ copy: Ie,
142
+ [Symbol.iterator]: We
143
+ };
144
+ function Xe(t) {
145
+ if (typeof t != "function") throw new Error();
146
+ return t;
147
+ }
148
+ function G() {
149
+ return 0;
150
+ }
151
+ function q(t) {
152
+ return function() {
153
+ return t;
154
+ };
155
+ }
156
+ function Ye(t) {
157
+ t.x0 = Math.round(t.x0), t.y0 = Math.round(t.y0), t.x1 = Math.round(t.x1), t.y1 = Math.round(t.y1);
158
+ }
159
+ function je(t, a, l, n, r) {
160
+ for (var i = t.children, d, h = -1, m = i.length, c = t.value && (n - a) / t.value; ++h < m; )
161
+ d = i[h], d.y0 = l, d.y1 = r, d.x0 = a, d.x1 = a += d.value * c;
162
+ }
163
+ function Ke(t, a, l, n, r) {
164
+ for (var i = t.children, d, h = -1, m = i.length, c = t.value && (r - l) / t.value; ++h < m; )
165
+ d = i[h], d.x0 = a, d.x1 = n, d.y0 = l, d.y1 = l += d.value * c;
166
+ }
167
+ var Ue = (1 + Math.sqrt(5)) / 2;
168
+ function Ze(t, a, l, n, r, i) {
169
+ for (var d = [], h = a.children, m, c, u = 0, b = 0, s = h.length, x, S, v = a.value, p, g, M, N, z, E, V; u < s; ) {
170
+ x = r - l, S = i - n;
171
+ do
172
+ p = h[b++].value;
173
+ while (!p && b < s);
174
+ for (g = M = p, E = Math.max(S / x, x / S) / (v * t), V = p * p * E, z = Math.max(M / V, V / g); b < s; ++b) {
175
+ if (p += c = h[b].value, c < g && (g = c), c > M && (M = c), V = p * p * E, N = Math.max(M / V, V / g), N > z) {
176
+ p -= c;
177
+ break;
178
+ }
179
+ z = N;
180
+ }
181
+ d.push(m = { value: p, dice: x < S, children: h.slice(u, b) }), m.dice ? je(m, l, n, r, v ? n += S * p / v : i) : Ke(m, l, n, v ? l += x * p / v : r, i), v -= p, u = b;
182
+ }
183
+ return d;
184
+ }
185
+ const Je = (function t(a) {
186
+ function l(n, r, i, d, h) {
187
+ Ze(a, n, r, i, d, h);
188
+ }
189
+ return l.ratio = function(n) {
190
+ return t((n = +n) > 1 ? n : 1);
191
+ }, l;
192
+ })(Ue);
193
+ function Qe() {
194
+ var t = Je, a = !1, l = 1, n = 1, r = [0], i = G, d = G, h = G, m = G, c = G;
195
+ function u(s) {
196
+ return s.x0 = s.y0 = 0, s.x1 = l, s.y1 = n, s.eachBefore(b), r = [0], a && s.eachBefore(Ye), s;
197
+ }
198
+ function b(s) {
199
+ var x = r[s.depth], S = s.x0 + x, v = s.y0 + x, p = s.x1 - x, g = s.y1 - x;
200
+ p < S && (S = p = (S + p) / 2), g < v && (v = g = (v + g) / 2), s.x0 = S, s.y0 = v, s.x1 = p, s.y1 = g, s.children && (x = r[s.depth + 1] = i(s) / 2, S += c(s) - x, v += d(s) - x, p -= h(s) - x, g -= m(s) - x, p < S && (S = p = (S + p) / 2), g < v && (v = g = (v + g) / 2), t(s, S, v, p, g));
201
+ }
202
+ return u.round = function(s) {
203
+ return arguments.length ? (a = !!s, u) : a;
204
+ }, u.size = function(s) {
205
+ return arguments.length ? (l = +s[0], n = +s[1], u) : [l, n];
206
+ }, u.tile = function(s) {
207
+ return arguments.length ? (t = Xe(s), u) : t;
208
+ }, u.padding = function(s) {
209
+ return arguments.length ? u.paddingInner(s).paddingOuter(s) : u.paddingInner();
210
+ }, u.paddingInner = function(s) {
211
+ return arguments.length ? (i = typeof s == "function" ? s : q(+s), u) : i;
212
+ }, u.paddingOuter = function(s) {
213
+ return arguments.length ? u.paddingTop(s).paddingRight(s).paddingBottom(s).paddingLeft(s) : u.paddingTop();
214
+ }, u.paddingTop = function(s) {
215
+ return arguments.length ? (d = typeof s == "function" ? s : q(+s), u) : d;
216
+ }, u.paddingRight = function(s) {
217
+ return arguments.length ? (h = typeof s == "function" ? s : q(+s), u) : h;
218
+ }, u.paddingBottom = function(s) {
219
+ return arguments.length ? (m = typeof s == "function" ? s : q(+s), u) : m;
220
+ }, u.paddingLeft = function(s) {
221
+ return arguments.length ? (c = typeof s == "function" ? s : q(+s), u) : c;
222
+ }, u;
223
+ }
224
+ var R, ne = (R = class {
225
+ constructor() {
226
+ this.nodes = [], this.levels = /* @__PURE__ */ new Map(), this.outerNodes = [], this.classes = /* @__PURE__ */ new Map(), this.setAccTitle = fe, this.getAccTitle = me, this.setDiagramTitle = ge, this.getDiagramTitle = ye, this.getAccDescription = Se, this.setAccDescription = ve;
227
+ }
228
+ getNodes() {
229
+ return this.nodes;
230
+ }
231
+ getConfig() {
232
+ const a = xe, l = ee();
233
+ return J({
234
+ ...a.treemap,
235
+ ...l.treemap ?? {}
236
+ });
237
+ }
238
+ addNode(a, l) {
239
+ this.nodes.push(a), this.levels.set(a, l), l === 0 && (this.outerNodes.push(a), this.root ??= a);
240
+ }
241
+ getRoot() {
242
+ return { name: "", children: this.outerNodes };
243
+ }
244
+ addClass(a, l) {
245
+ const n = this.classes.get(a) ?? { id: a, styles: [], textStyles: [] }, r = l.replace(/\\,/g, "§§§").replace(/,/g, ";").replace(/§§§/g, ",").split(";");
246
+ r && r.forEach((i) => {
247
+ be(i) && (n?.textStyles ? n.textStyles.push(i) : n.textStyles = [i]), n?.styles ? n.styles.push(i) : n.styles = [i];
248
+ }), this.classes.set(a, n);
249
+ }
250
+ getClasses() {
251
+ return this.classes;
252
+ }
253
+ getStylesForClass(a) {
254
+ return this.classes.get(a)?.styles ?? [];
255
+ }
256
+ clear() {
257
+ we(), this.nodes = [], this.levels = /* @__PURE__ */ new Map(), this.outerNodes = [], this.classes = /* @__PURE__ */ new Map(), this.root = void 0;
258
+ }
259
+ }, w(R, "TreeMapDB"), R);
260
+ function le(t) {
261
+ if (!t.length)
262
+ return [];
263
+ const a = [], l = [];
264
+ return t.forEach((n) => {
265
+ const r = {
266
+ name: n.name,
267
+ children: n.type === "Leaf" ? void 0 : []
268
+ };
269
+ for (r.classSelector = n?.classSelector, n?.cssCompiledStyles && (r.cssCompiledStyles = n.cssCompiledStyles), n.type === "Leaf" && n.value !== void 0 && (r.value = n.value); l.length > 0 && l[l.length - 1].level >= n.level; )
270
+ l.pop();
271
+ if (l.length === 0)
272
+ a.push(r);
273
+ else {
274
+ const i = l[l.length - 1].node;
275
+ i.children ? i.children.push(r) : i.children = [r];
276
+ }
277
+ n.type !== "Leaf" && l.push({ node: r, level: n.level });
278
+ }), a;
279
+ }
280
+ w(le, "buildHierarchy");
281
+ var et = /* @__PURE__ */ w((t, a) => {
282
+ Te(t, a);
283
+ const l = [];
284
+ for (const i of t.TreemapRows ?? [])
285
+ i.$type === "ClassDefStatement" && a.addClass(i.className ?? "", i.styleText ?? "");
286
+ for (const i of t.TreemapRows ?? []) {
287
+ const d = i.item;
288
+ if (!d)
289
+ continue;
290
+ const h = i.indent ? parseInt(i.indent) : 0, m = tt(d), c = d.classSelector ? a.getStylesForClass(d.classSelector) : [], u = c.length > 0 ? c : void 0, b = {
291
+ level: h,
292
+ name: m,
293
+ type: d.$type,
294
+ value: d.value,
295
+ classSelector: d.classSelector,
296
+ cssCompiledStyles: u
297
+ };
298
+ l.push(b);
299
+ }
300
+ const n = le(l), r = /* @__PURE__ */ w((i, d) => {
301
+ for (const h of i)
302
+ a.addNode(h, d), h.children && h.children.length > 0 && r(h.children, d + 1);
303
+ }, "addNodesRecursively");
304
+ r(n, 0);
305
+ }, "populate"), tt = /* @__PURE__ */ w((t) => t.name ? String(t.name) : "", "getItemName"), re = {
306
+ // @ts-expect-error - TreeMapDB is not assignable to DiagramDB
307
+ parser: { yy: void 0 },
308
+ parse: /* @__PURE__ */ w(async (t) => {
309
+ try {
310
+ const l = await Le("treemap", t);
311
+ Q.debug("Treemap AST:", l);
312
+ const n = re.parser?.yy;
313
+ if (!(n instanceof ne))
314
+ throw new Error(
315
+ "parser.parser?.yy was not a TreemapDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues."
316
+ );
317
+ et(l, n);
318
+ } catch (a) {
319
+ throw Q.error("Error parsing treemap:", a), a;
320
+ }
321
+ }, "parse")
322
+ }, at = 10, B = 10, X = 25, nt = /* @__PURE__ */ w((t, a, l, n) => {
323
+ const r = n.db, i = r.getConfig(), d = i.padding ?? at, h = r.getDiagramTitle(), m = r.getRoot(), { themeVariables: c } = ee();
324
+ if (!m)
325
+ return;
326
+ const u = h ? 30 : 0, b = ue(a), s = i.nodeWidth ? i.nodeWidth * B : 960, x = i.nodeHeight ? i.nodeHeight * B : 500, S = s, v = x + u;
327
+ b.attr("viewBox", `0 0 ${S} ${v}`), pe(b, v, S, i.useMaxWidth);
328
+ let p;
329
+ try {
330
+ const e = i.valueFormat || ",";
331
+ if (e === "$0,0")
332
+ p = /* @__PURE__ */ w((o) => "$" + O(",")(o), "valueFormat");
333
+ else if (e.startsWith("$") && e.includes(",")) {
334
+ const o = /\.\d+/.exec(e), f = o ? o[0] : "";
335
+ p = /* @__PURE__ */ w((C) => "$" + O("," + f)(C), "valueFormat");
336
+ } else if (e.startsWith("$")) {
337
+ const o = e.substring(1);
338
+ p = /* @__PURE__ */ w((f) => "$" + O(o || "")(f), "valueFormat");
339
+ } else
340
+ p = O(e);
341
+ } catch (e) {
342
+ Q.error("Error creating format function:", e), p = O(",");
343
+ }
344
+ const g = Z().range([
345
+ "transparent",
346
+ c.cScale0,
347
+ c.cScale1,
348
+ c.cScale2,
349
+ c.cScale3,
350
+ c.cScale4,
351
+ c.cScale5,
352
+ c.cScale6,
353
+ c.cScale7,
354
+ c.cScale8,
355
+ c.cScale9,
356
+ c.cScale10,
357
+ c.cScale11
358
+ ]), M = Z().range([
359
+ "transparent",
360
+ c.cScalePeer0,
361
+ c.cScalePeer1,
362
+ c.cScalePeer2,
363
+ c.cScalePeer3,
364
+ c.cScalePeer4,
365
+ c.cScalePeer5,
366
+ c.cScalePeer6,
367
+ c.cScalePeer7,
368
+ c.cScalePeer8,
369
+ c.cScalePeer9,
370
+ c.cScalePeer10,
371
+ c.cScalePeer11
372
+ ]), N = Z().range([
373
+ c.cScaleLabel0,
374
+ c.cScaleLabel1,
375
+ c.cScaleLabel2,
376
+ c.cScaleLabel3,
377
+ c.cScaleLabel4,
378
+ c.cScaleLabel5,
379
+ c.cScaleLabel6,
380
+ c.cScaleLabel7,
381
+ c.cScaleLabel8,
382
+ c.cScaleLabel9,
383
+ c.cScaleLabel10,
384
+ c.cScaleLabel11
385
+ ]);
386
+ h && b.append("text").attr("x", S / 2).attr("y", u / 2).attr("class", "treemapTitle").attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(h);
387
+ const z = b.append("g").attr("transform", `translate(0, ${u})`).attr("class", "treemapContainer"), E = te(m).sum((e) => e.value ?? 0).sort((e, o) => (o.value ?? 0) - (e.value ?? 0)), ae = Qe().size([s, x]).paddingTop(
388
+ (e) => e.children && e.children.length > 0 ? X + B : 0
389
+ ).paddingInner(d).paddingLeft((e) => e.children && e.children.length > 0 ? B : 0).paddingRight((e) => e.children && e.children.length > 0 ? B : 0).paddingBottom((e) => e.children && e.children.length > 0 ? B : 0).round(!0)(E), se = ae.descendants().filter((e) => e.children && e.children.length > 0), W = z.selectAll(".treemapSection").data(se).enter().append("g").attr("class", "treemapSection").attr("transform", (e) => `translate(${e.x0},${e.y0})`);
390
+ W.append("rect").attr("width", (e) => e.x1 - e.x0).attr("height", X).attr("class", "treemapSectionHeader").attr("fill", "none").attr("fill-opacity", 0.6).attr("stroke-width", 0.6).attr("style", (e) => e.depth === 0 ? "display: none;" : ""), W.append("clipPath").attr("id", (e, o) => `clip-section-${a}-${o}`).append("rect").attr("width", (e) => Math.max(0, e.x1 - e.x0 - 12)).attr("height", X), W.append("rect").attr("width", (e) => e.x1 - e.x0).attr("height", (e) => e.y1 - e.y0).attr("class", (e, o) => `treemapSection section${o}`).attr("fill", (e) => g(e.data.name)).attr("fill-opacity", 0.6).attr("stroke", (e) => M(e.data.name)).attr("stroke-width", 2).attr("stroke-opacity", 0.4).attr("style", (e) => {
391
+ if (e.depth === 0)
392
+ return "display: none;";
393
+ const o = P({ cssCompiledStyles: e.data.cssCompiledStyles });
394
+ return o.nodeStyles + ";" + o.borderStyles.join(";");
395
+ }), W.append("text").attr("class", "treemapSectionLabel").attr("x", 6).attr("y", X / 2).attr("dominant-baseline", "middle").text((e) => e.depth === 0 ? "" : e.data.name).attr("font-weight", "bold").attr("style", (e) => {
396
+ if (e.depth === 0)
397
+ return "display: none;";
398
+ const o = "dominant-baseline: middle; font-size: 12px; fill:" + N(e.data.name) + "; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;", f = P({ cssCompiledStyles: e.data.cssCompiledStyles });
399
+ return o + f.labelStyles.replace("color:", "fill:");
400
+ }).each(function(e) {
401
+ if (e.depth === 0)
402
+ return;
403
+ const o = j(this), f = e.data.name;
404
+ o.text(f);
405
+ const C = e.x1 - e.x0, L = 6;
406
+ let $;
407
+ i.showValues !== !1 && e.value ? $ = C - 10 - 30 - 10 - L : $ = C - L - 6;
408
+ const A = Math.max(15, $), y = o.node();
409
+ if (y.getComputedTextLength() > A) {
410
+ let T = f;
411
+ for (; T.length > 0; ) {
412
+ if (T = f.substring(0, T.length - 1), T.length === 0) {
413
+ o.text("..."), y.getComputedTextLength() > A && o.text("");
414
+ break;
415
+ }
416
+ if (o.text(T + "..."), y.getComputedTextLength() <= A)
417
+ break;
418
+ }
419
+ }
420
+ }), i.showValues !== !1 && W.append("text").attr("class", "treemapSectionValue").attr("x", (e) => e.x1 - e.x0 - 10).attr("y", X / 2).attr("text-anchor", "end").attr("dominant-baseline", "middle").text((e) => e.value ? p(e.value) : "").attr("font-style", "italic").attr("style", (e) => {
421
+ if (e.depth === 0)
422
+ return "display: none;";
423
+ const o = "text-anchor: end; dominant-baseline: middle; font-size: 10px; fill:" + N(e.data.name) + "; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;", f = P({ cssCompiledStyles: e.data.cssCompiledStyles });
424
+ return o + f.labelStyles.replace("color:", "fill:");
425
+ });
426
+ const ie = ae.leaves(), Y = z.selectAll(".treemapLeafGroup").data(ie).enter().append("g").attr("class", (e, o) => `treemapNode treemapLeafGroup leaf${o}${e.data.classSelector ? ` ${e.data.classSelector}` : ""}x`).attr("transform", (e) => `translate(${e.x0},${e.y0})`);
427
+ Y.append("rect").attr("width", (e) => e.x1 - e.x0).attr("height", (e) => e.y1 - e.y0).attr("class", "treemapLeaf").attr("fill", (e) => e.parent ? g(e.parent.data.name) : g(e.data.name)).attr("style", (e) => P({ cssCompiledStyles: e.data.cssCompiledStyles }).nodeStyles).attr("fill-opacity", 0.3).attr("stroke", (e) => e.parent ? g(e.parent.data.name) : g(e.data.name)).attr("stroke-width", 3), Y.append("clipPath").attr("id", (e, o) => `clip-${a}-${o}`).append("rect").attr("width", (e) => Math.max(0, e.x1 - e.x0 - 4)).attr("height", (e) => Math.max(0, e.y1 - e.y0 - 4)), Y.append("text").attr("class", "treemapLabel").attr("x", (e) => (e.x1 - e.x0) / 2).attr("y", (e) => (e.y1 - e.y0) / 2).attr("style", (e) => {
428
+ const o = "text-anchor: middle; dominant-baseline: middle; font-size: 38px;fill:" + N(e.data.name) + ";", f = P({ cssCompiledStyles: e.data.cssCompiledStyles });
429
+ return o + f.labelStyles.replace("color:", "fill:");
430
+ }).attr("clip-path", (e, o) => `url(#clip-${a}-${o})`).text((e) => e.data.name).each(function(e) {
431
+ const o = j(this), f = e.x1 - e.x0, C = e.y1 - e.y0, L = o.node(), $ = 4, D = f - 2 * $, A = C - 2 * $;
432
+ if (D < 10 || A < 10) {
433
+ o.style("display", "none");
434
+ return;
435
+ }
436
+ let y = parseInt(o.style("font-size"), 10);
437
+ const _ = 8, F = 28, T = 0.6, k = 6, I = 2;
438
+ for (; L.getComputedTextLength() > D && y > _; )
439
+ y--, o.style("font-size", `${y}px`);
440
+ let H = Math.max(
441
+ k,
442
+ Math.min(F, Math.round(y * T))
443
+ ), U = y + I + H;
444
+ for (; U > A && y > _ && (y--, H = Math.max(
445
+ k,
446
+ Math.min(F, Math.round(y * T))
447
+ ), !(H < k && y === _)); )
448
+ o.style("font-size", `${y}px`), U = y + I + H;
449
+ o.style("font-size", `${y}px`), (L.getComputedTextLength() > D || y < _ || A < y) && o.style("display", "none");
450
+ }), i.showValues !== !1 && Y.append("text").attr("class", "treemapValue").attr("x", (o) => (o.x1 - o.x0) / 2).attr("y", function(o) {
451
+ return (o.y1 - o.y0) / 2;
452
+ }).attr("style", (o) => {
453
+ const f = "text-anchor: middle; dominant-baseline: hanging; font-size: 28px;fill:" + N(o.data.name) + ";", C = P({ cssCompiledStyles: o.data.cssCompiledStyles });
454
+ return f + C.labelStyles.replace("color:", "fill:");
455
+ }).attr("clip-path", (o, f) => `url(#clip-${a}-${f})`).text((o) => o.value ? p(o.value) : "").each(function(o) {
456
+ const f = j(this), C = this.parentNode;
457
+ if (!C) {
458
+ f.style("display", "none");
459
+ return;
460
+ }
461
+ const L = j(C).select(".treemapLabel");
462
+ if (L.empty() || L.style("display") === "none") {
463
+ f.style("display", "none");
464
+ return;
465
+ }
466
+ const $ = parseFloat(L.style("font-size")), D = 28, A = 0.6, y = 6, _ = 2, F = Math.max(
467
+ y,
468
+ Math.min(D, Math.round($ * A))
469
+ );
470
+ f.style("font-size", `${F}px`);
471
+ const k = (o.y1 - o.y0) / 2 + $ / 2 + _;
472
+ f.attr("y", k);
473
+ const I = o.x1 - o.x0, ce = o.y1 - o.y0 - 4, de = I - 8;
474
+ f.node().getComputedTextLength() > de || k + F > ce || F < y ? f.style("display", "none") : f.style("display", null);
475
+ });
476
+ const oe = i.diagramPadding ?? 8;
477
+ Ce(b, oe, "flowchart", i?.useMaxWidth || !1);
478
+ }, "draw"), lt = /* @__PURE__ */ w(function(t, a) {
479
+ return a.db.getClasses();
480
+ }, "getClasses"), rt = { draw: nt, getClasses: lt }, st = {
481
+ sectionStrokeColor: "black",
482
+ sectionStrokeWidth: "1",
483
+ sectionFillColor: "#efefef",
484
+ leafStrokeColor: "black",
485
+ leafStrokeWidth: "1",
486
+ leafFillColor: "#efefef",
487
+ labelFontSize: "12px",
488
+ valueFontSize: "10px",
489
+ titleFontSize: "14px"
490
+ }, it = /* @__PURE__ */ w(({
491
+ treemap: t
492
+ } = {}) => {
493
+ const a = he(), l = ee(), n = J(a, l.themeVariables), r = J(st, t), i = r.titleColor ?? n.titleColor, d = r.labelColor ?? n.textColor, h = r.valueColor ?? n.textColor;
494
+ return `
495
+ .treemapNode.section {
496
+ stroke: ${r.sectionStrokeColor};
497
+ stroke-width: ${r.sectionStrokeWidth};
498
+ fill: ${r.sectionFillColor};
499
+ }
500
+ .treemapNode.leaf {
501
+ stroke: ${r.leafStrokeColor};
502
+ stroke-width: ${r.leafStrokeWidth};
503
+ fill: ${r.leafFillColor};
504
+ }
505
+ .treemapLabel {
506
+ fill: ${d};
507
+ font-size: ${r.labelFontSize};
508
+ }
509
+ .treemapValue {
510
+ fill: ${h};
511
+ font-size: ${r.valueFontSize};
512
+ }
513
+ .treemapTitle {
514
+ fill: ${i};
515
+ font-size: ${r.titleFontSize};
516
+ }
517
+ `;
518
+ }, "getStyles"), ot = it, gt = {
519
+ parser: re,
520
+ get db() {
521
+ return new ne();
522
+ },
523
+ renderer: rt,
524
+ styles: ot
525
+ };
526
+ export {
527
+ gt as diagram
528
+ };