@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,594 @@
1
+ import { s as Mt, g as Ct, q as Nt, p as zt, a as Lt, b as Xt, _ as y, l as Q, I as At, e as Et, z as Tt, c as H, i as Yt } from "./mermaid.core-BrBkhL9h.js";
2
+ import { p as Bt } from "./chunk-4BX2VUAB-iSPZGgxQ.js";
3
+ import { p as Rt } from "./wardley-RL74JXVD-CwSnyVu7.js";
4
+ var q = /* @__PURE__ */ y((a, r) => {
5
+ const e = a <= 1 ? a * 100 : a;
6
+ if (e < 0 || e > 100)
7
+ throw new Error(
8
+ `${r} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${a}`
9
+ );
10
+ return e;
11
+ }, "toPercent"), E = /* @__PURE__ */ y((a, r, e) => ({
12
+ x: q(r, `${e} evolution`),
13
+ y: q(a, `${e} visibility`)
14
+ }), "toCoordinates"), K = /* @__PURE__ */ y((a) => {
15
+ if (a) {
16
+ if (a === "+<>")
17
+ return "bidirectional";
18
+ if (a === "+<")
19
+ return "backward";
20
+ if (a === "+>")
21
+ return "forward";
22
+ }
23
+ }, "getFlowFromPort"), Ft = /* @__PURE__ */ y((a) => {
24
+ if (!a?.startsWith("+"))
25
+ return {};
26
+ const e = /^\+'([^']*)'/.exec(a)?.[1];
27
+ return a.includes("<>") ? { flow: "bidirectional", label: e } : a.includes("<") ? { flow: "backward", label: e } : a.includes(">") ? { flow: "forward", label: e } : { label: e };
28
+ }, "extractFlowFromArrow"), It = /* @__PURE__ */ y((a, r) => {
29
+ if (Bt(a, r), a.size && r.setSize(a.size.width, a.size.height), a.evolution) {
30
+ const e = a.evolution.stages.map((s) => s.secondName ? `${s.name.trim()} / ${s.secondName.trim()}` : s.name.trim()), x = a.evolution.stages.filter((s) => s.boundary !== void 0).map((s) => s.boundary);
31
+ r.updateAxes({ stages: e, stageBoundaries: x });
32
+ }
33
+ if (a.anchors.forEach((e) => {
34
+ const x = E(e.visibility, e.evolution, `Anchor "${e.name}"`);
35
+ r.addNode(e.name, e.name, x.x, x.y, "anchor");
36
+ }), a.components.forEach((e) => {
37
+ const x = E(
38
+ e.visibility,
39
+ e.evolution,
40
+ `Component "${e.name}"`
41
+ ), s = e.label ? (e.label.negX ? -1 : 1) * e.label.offsetX : void 0, d = e.label ? (e.label.negY ? -1 : 1) * e.label.offsetY : void 0, m = e.decorator?.strategy;
42
+ r.addNode(
43
+ e.name,
44
+ e.name,
45
+ x.x,
46
+ x.y,
47
+ "component",
48
+ s,
49
+ d,
50
+ e.inertia,
51
+ m
52
+ );
53
+ }), a.notes.forEach((e) => {
54
+ const x = E(e.visibility, e.evolution, `Note "${e.text}"`);
55
+ r.addNote(e.text, x.x, x.y);
56
+ }), a.pipelines.forEach((e) => {
57
+ const x = r.getNode(e.parent);
58
+ if (!x || typeof x.y != "number")
59
+ throw new Error(
60
+ `Pipeline "${e.parent}" must reference an existing component with coordinates.`
61
+ );
62
+ const s = x.y;
63
+ r.startPipeline(e.parent), e.components.forEach((d) => {
64
+ const m = `${e.parent}_${d.name}`, M = d.label ? (d.label.negX ? -1 : 1) * d.label.offsetX : void 0, g = d.label ? (d.label.negY ? -1 : 1) * d.label.offsetY : void 0, O = q(d.evolution, `Pipeline component "${d.name}" evolution`);
65
+ r.addNode(
66
+ m,
67
+ d.name,
68
+ O,
69
+ s,
70
+ "pipeline-component",
71
+ M,
72
+ g
73
+ ), r.addPipelineComponent(e.parent, m);
74
+ });
75
+ }), a.links.forEach((e) => {
76
+ const x = !!e.arrow && (e.arrow.includes("-.->") || e.arrow.includes(".-."));
77
+ let s = K(e.fromPort) ?? K(e.toPort);
78
+ const { flow: d, label: m } = Ft(e.arrow);
79
+ !s && d && (s = d);
80
+ const M = e.linkLabel, g = m ?? M;
81
+ r.addLink(e.from, e.to, x, g, s);
82
+ }), a.evolves.forEach((e) => {
83
+ const x = r.getNode(e.component);
84
+ if (x?.y !== void 0) {
85
+ const s = q(e.target, `Evolve target for "${e.component}"`);
86
+ r.addTrend(e.component, s, x.y);
87
+ }
88
+ }), a.annotations.length > 0) {
89
+ const e = a.annotations[0], x = E(e.x, e.y, "Annotations box");
90
+ r.setAnnotationsBox(x.x, x.y);
91
+ }
92
+ a.annotation.forEach((e) => {
93
+ const x = E(e.x, e.y, `Annotation ${e.number}`);
94
+ r.addAnnotation(e.number, [{ x: x.x, y: x.y }], e.text);
95
+ }), a.accelerators.forEach((e) => {
96
+ const x = E(e.x, e.y, `Accelerator "${e.name}"`);
97
+ r.addAccelerator(e.name, x.x, x.y);
98
+ }), a.deaccelerators.forEach((e) => {
99
+ const x = E(
100
+ e.x,
101
+ e.y,
102
+ `Deaccelerator "${e.name}"`
103
+ );
104
+ r.addDeaccelerator(e.name, x.x, x.y);
105
+ });
106
+ }, "populateDb"), tt = {
107
+ parser: {
108
+ // @ts-expect-error - WardleyDB is not assignable to DiagramDB
109
+ yy: void 0
110
+ },
111
+ parse: /* @__PURE__ */ y(async (a) => {
112
+ const r = await Rt("wardley", a);
113
+ Q.debug(r);
114
+ const e = tt.parser?.yy;
115
+ if (!e || typeof e.addNode != "function")
116
+ throw new Error(
117
+ "parser.parser?.yy was not a WardleyDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues."
118
+ );
119
+ It(r, e);
120
+ }, "parse")
121
+ }, Y, Ot = (Y = class {
122
+ constructor() {
123
+ this.nodes = /* @__PURE__ */ new Map(), this.links = [], this.trends = /* @__PURE__ */ new Map(), this.pipelines = /* @__PURE__ */ new Map(), this.annotations = [], this.notes = [], this.accelerators = [], this.deaccelerators = [], this.axes = {};
124
+ }
125
+ addNode(r) {
126
+ const e = this.nodes.get(r.id) ?? { id: r.id, label: r.label }, x = {
127
+ ...e,
128
+ ...r,
129
+ className: r.className ?? e.className,
130
+ labelOffsetX: r.labelOffsetX ?? e.labelOffsetX,
131
+ labelOffsetY: r.labelOffsetY ?? e.labelOffsetY
132
+ };
133
+ this.nodes.set(r.id, x);
134
+ }
135
+ addLink(r) {
136
+ this.links.push(r);
137
+ }
138
+ addTrend(r) {
139
+ this.trends.set(r.nodeId, r);
140
+ }
141
+ startPipeline(r) {
142
+ this.pipelines.set(r, { nodeId: r, componentIds: [] });
143
+ const e = this.nodes.get(r);
144
+ e && (e.isPipelineParent = !0);
145
+ }
146
+ addPipelineComponent(r, e) {
147
+ const x = this.pipelines.get(r);
148
+ x && x.componentIds.push(e);
149
+ const s = this.nodes.get(e);
150
+ s && (s.inPipeline = !0);
151
+ }
152
+ addAnnotation(r) {
153
+ this.annotations.push(r);
154
+ }
155
+ addNote(r) {
156
+ this.notes.push(r);
157
+ }
158
+ addAccelerator(r) {
159
+ this.accelerators.push(r);
160
+ }
161
+ addDeaccelerator(r) {
162
+ this.deaccelerators.push(r);
163
+ }
164
+ setAnnotationsBox(r, e) {
165
+ this.annotationsBox = { x: r, y: e };
166
+ }
167
+ setAxes(r) {
168
+ this.axes = {
169
+ ...this.axes,
170
+ ...r
171
+ };
172
+ }
173
+ setSize(r, e) {
174
+ this.size = { width: r, height: e };
175
+ }
176
+ getNode(r) {
177
+ return this.nodes.get(r);
178
+ }
179
+ build() {
180
+ const r = [];
181
+ for (const e of this.nodes.values()) {
182
+ if (typeof e.x != "number" || typeof e.y != "number")
183
+ throw new Error(`Node "${e.label}" is missing coordinates`);
184
+ r.push(e);
185
+ }
186
+ return {
187
+ nodes: r,
188
+ links: [...this.links],
189
+ trends: [...this.trends.values()],
190
+ pipelines: [...this.pipelines.values()],
191
+ annotations: [...this.annotations],
192
+ notes: [...this.notes],
193
+ accelerators: [...this.accelerators],
194
+ deaccelerators: [...this.deaccelerators],
195
+ annotationsBox: this.annotationsBox,
196
+ axes: { ...this.axes },
197
+ size: this.size
198
+ };
199
+ }
200
+ clear() {
201
+ this.nodes.clear(), this.links = [], this.trends.clear(), this.pipelines.clear(), this.annotations = [], this.notes = [], this.accelerators = [], this.deaccelerators = [], this.annotationsBox = void 0, this.axes = {}, this.size = void 0;
202
+ }
203
+ }, y(Y, "WardleyBuilder"), Y), P = new Ot();
204
+ function $(a) {
205
+ const r = H();
206
+ return Yt(a.trim(), r);
207
+ }
208
+ y($, "textSanitizer");
209
+ function et() {
210
+ return H()["wardley-beta"];
211
+ }
212
+ y(et, "getConfig");
213
+ function at(a, r, e, x, s, d, m, M, g) {
214
+ P.addNode({
215
+ id: a,
216
+ label: $(r),
217
+ x: e,
218
+ y: x,
219
+ className: s,
220
+ labelOffsetX: d,
221
+ labelOffsetY: m,
222
+ inertia: M,
223
+ sourceStrategy: g
224
+ });
225
+ }
226
+ y(at, "addNode");
227
+ function rt(a, r, e = !1, x, s) {
228
+ P.addLink({ source: a, target: r, dashed: e, label: x, flow: s });
229
+ }
230
+ y(rt, "addLink");
231
+ function ot(a, r, e) {
232
+ P.addTrend({ nodeId: a, targetX: r, targetY: e });
233
+ }
234
+ y(ot, "addTrend");
235
+ function st(a, r, e) {
236
+ P.addAnnotation({
237
+ number: a,
238
+ coordinates: r,
239
+ text: e ? $(e) : void 0
240
+ });
241
+ }
242
+ y(st, "addAnnotation");
243
+ function nt(a, r, e) {
244
+ P.addNote({
245
+ text: $(a),
246
+ x: r,
247
+ y: e
248
+ });
249
+ }
250
+ y(nt, "addNote");
251
+ function it(a, r, e) {
252
+ P.addAccelerator({
253
+ name: $(a),
254
+ x: r,
255
+ y: e
256
+ });
257
+ }
258
+ y(it, "addAccelerator");
259
+ function dt(a, r, e) {
260
+ P.addDeaccelerator({
261
+ name: $(a),
262
+ x: r,
263
+ y: e
264
+ });
265
+ }
266
+ y(dt, "addDeaccelerator");
267
+ function lt(a, r) {
268
+ P.setAnnotationsBox(a, r);
269
+ }
270
+ y(lt, "setAnnotationsBox");
271
+ function ct(a, r) {
272
+ P.setSize(a, r);
273
+ }
274
+ y(ct, "setSize");
275
+ function pt(a) {
276
+ P.startPipeline(a);
277
+ }
278
+ y(pt, "startPipeline");
279
+ function ht(a, r) {
280
+ P.addPipelineComponent(a, r);
281
+ }
282
+ y(ht, "addPipelineComponent");
283
+ function ft(a) {
284
+ const r = {};
285
+ a.xLabel && (r.xLabel = $(a.xLabel)), a.yLabel && (r.yLabel = $(a.yLabel)), a.stages && (r.stages = a.stages.map((e) => $(e))), a.stageBoundaries && (r.stageBoundaries = a.stageBoundaries), P.setAxes(r);
286
+ }
287
+ y(ft, "updateAxes");
288
+ function xt(a) {
289
+ return P.getNode(a);
290
+ }
291
+ y(xt, "getNode");
292
+ function gt() {
293
+ return P.build();
294
+ }
295
+ y(gt, "getWardleyData");
296
+ function ut() {
297
+ P.clear(), Tt();
298
+ }
299
+ y(ut, "clear");
300
+ var Wt = {
301
+ getConfig: et,
302
+ addNode: at,
303
+ addLink: rt,
304
+ addTrend: ot,
305
+ addAnnotation: st,
306
+ addNote: nt,
307
+ addAccelerator: it,
308
+ addDeaccelerator: dt,
309
+ setAnnotationsBox: lt,
310
+ setSize: ct,
311
+ startPipeline: pt,
312
+ addPipelineComponent: ht,
313
+ updateAxes: ft,
314
+ getNode: xt,
315
+ getWardleyData: gt,
316
+ clear: ut,
317
+ setAccTitle: Xt,
318
+ getAccTitle: Lt,
319
+ setDiagramTitle: zt,
320
+ getDiagramTitle: Nt,
321
+ getAccDescription: Ct,
322
+ setAccDescription: Mt
323
+ }, Dt = ["Genesis", "Custom Built", "Product", "Commodity"], Gt = /* @__PURE__ */ y(() => {
324
+ const { themeVariables: a } = H();
325
+ return {
326
+ backgroundColor: a.wardley?.backgroundColor ?? a.background ?? "#fff",
327
+ axisColor: a.wardley?.axisColor ?? "#000",
328
+ axisTextColor: a.wardley?.axisTextColor ?? a.primaryTextColor ?? "#222",
329
+ gridColor: a.wardley?.gridColor ?? "rgba(100, 100, 100, 0.2)",
330
+ componentFill: a.wardley?.componentFill ?? "#fff",
331
+ componentStroke: a.wardley?.componentStroke ?? "#000",
332
+ componentLabelColor: a.wardley?.componentLabelColor ?? a.primaryTextColor ?? "#222",
333
+ linkStroke: a.wardley?.linkStroke ?? "#000",
334
+ evolutionStroke: a.wardley?.evolutionStroke ?? "#dc3545",
335
+ annotationStroke: a.wardley?.annotationStroke ?? "#000",
336
+ annotationTextColor: a.wardley?.annotationTextColor ?? a.primaryTextColor ?? "#222",
337
+ annotationFill: a.wardley?.annotationFill ?? a.background ?? "#fff"
338
+ };
339
+ }, "getTheme"), qt = /* @__PURE__ */ y(() => {
340
+ const a = H()["wardley-beta"];
341
+ return {
342
+ width: a?.width ?? 900,
343
+ height: a?.height ?? 600,
344
+ padding: a?.padding ?? 48,
345
+ nodeRadius: a?.nodeRadius ?? 6,
346
+ nodeLabelOffset: a?.nodeLabelOffset ?? 8,
347
+ axisFontSize: a?.axisFontSize ?? 12,
348
+ labelFontSize: a?.labelFontSize ?? 10,
349
+ showGrid: a?.showGrid ?? !1,
350
+ useMaxWidth: a?.useMaxWidth ?? !0
351
+ };
352
+ }, "getConfigValues"), Ht = /* @__PURE__ */ y((a, r, e, x) => {
353
+ Q.debug(`Rendering Wardley map
354
+ ` + a);
355
+ const s = qt(), d = Gt(), m = s.nodeRadius * 1.6, M = x.db, g = M.getWardleyData(), O = M.getDiagramTitle(), C = g.size?.width ?? s.width, b = g.size?.height ?? s.height, B = At(r);
356
+ B.selectAll("*").remove(), Et(B, b, C, s.useMaxWidth), B.attr("viewBox", `0 0 ${C} ${b}`);
357
+ const v = B.append("g").attr("class", "wardley-map"), j = B.append("defs");
358
+ j.append("marker").attr("id", `arrow-${r}`).attr("viewBox", "0 0 10 10").attr("refX", 9).attr("refY", 5).attr("markerWidth", 6).attr("markerHeight", 6).attr("orient", "auto-start-reverse").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z").attr("fill", d.evolutionStroke).attr("stroke", "none"), j.append("marker").attr("id", `link-arrow-end-${r}`).attr("viewBox", "0 0 10 10").attr("refX", 9).attr("refY", 5).attr("markerWidth", 5).attr("markerHeight", 5).attr("orient", "auto").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z").attr("fill", d.linkStroke).attr("stroke", "none"), j.append("marker").attr("id", `link-arrow-start-${r}`).attr("viewBox", "0 0 10 10").attr("refX", 1).attr("refY", 5).attr("markerWidth", 5).attr("markerHeight", 5).attr("orient", "auto").append("path").attr("d", "M 10 0 L 0 5 L 10 10 z").attr("fill", d.linkStroke).attr("stroke", "none"), v.append("rect").attr("class", "wardley-background").attr("width", C).attr("height", b).attr("fill", d.backgroundColor);
359
+ const R = C - s.padding * 2, F = b - s.padding * 2;
360
+ O && v.append("text").attr("class", "wardley-title").attr("x", C / 2).attr("y", s.padding / 2).attr("fill", d.axisTextColor).attr("font-size", s.axisFontSize * 1.05).attr("font-weight", "bold").attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(O);
361
+ const L = /* @__PURE__ */ y((t) => s.padding + t / 100 * R, "projectX"), X = /* @__PURE__ */ y((t) => b - s.padding - t / 100 * F, "projectY"), W = v.append("g").attr("class", "wardley-axes");
362
+ W.append("line").attr("x1", s.padding).attr("x2", C - s.padding).attr("y1", b - s.padding).attr("y2", b - s.padding).attr("stroke", d.axisColor).attr("stroke-width", 1), W.append("line").attr("x1", s.padding).attr("x2", s.padding).attr("y1", s.padding).attr("y2", b - s.padding).attr("stroke", d.axisColor).attr("stroke-width", 1);
363
+ const yt = g.axes.xLabel ?? "Evolution", mt = g.axes.yLabel ?? "Visibility";
364
+ W.append("text").attr("class", "wardley-axis-label wardley-axis-label-x").attr("x", s.padding + R / 2).attr("y", b - s.padding / 4).attr("fill", d.axisTextColor).attr("font-size", s.axisFontSize).attr("font-weight", "bold").attr("text-anchor", "middle").text(yt), W.append("text").attr("class", "wardley-axis-label wardley-axis-label-y").attr("x", s.padding / 3).attr("y", s.padding + F / 2).attr("fill", d.axisTextColor).attr("font-size", s.axisFontSize).attr("font-weight", "bold").attr("text-anchor", "middle").attr(
365
+ "transform",
366
+ `rotate(-90 ${s.padding / 3} ${s.padding + F / 2})`
367
+ ).text(mt);
368
+ const I = g.axes.stages && g.axes.stages.length > 0 ? g.axes.stages : Dt;
369
+ if (I.length > 0) {
370
+ const t = v.append("g").attr("class", "wardley-stages"), n = g.axes.stageBoundaries, o = [];
371
+ if (n && n.length === I.length) {
372
+ let i = 0;
373
+ n.forEach((p) => {
374
+ o.push({ start: i, end: p }), i = p;
375
+ });
376
+ } else {
377
+ const i = 1 / I.length;
378
+ I.forEach((p, l) => {
379
+ o.push({
380
+ start: l * i,
381
+ end: (l + 1) * i
382
+ });
383
+ });
384
+ }
385
+ I.forEach((i, p) => {
386
+ const l = o[p], h = s.padding + l.start * R, f = s.padding + l.end * R, u = (h + f) / 2;
387
+ p > 0 && t.append("line").attr("x1", h).attr("x2", h).attr("y1", s.padding).attr("y2", b - s.padding).attr("stroke", "#000").attr("stroke-width", 1).attr("stroke-dasharray", "5 5").attr("opacity", 0.8), t.append("text").attr("class", "wardley-stage-label").attr("x", u).attr("y", b - s.padding / 1.5).attr("fill", d.axisTextColor).attr("font-size", s.axisFontSize - 2).attr("text-anchor", "middle").text(i);
388
+ });
389
+ }
390
+ if (s.showGrid) {
391
+ const t = v.append("g").attr("class", "wardley-grid");
392
+ for (let n = 1; n < 4; n++) {
393
+ const o = n / 4, i = s.padding + R * o;
394
+ t.append("line").attr("x1", i).attr("x2", i).attr("y1", s.padding).attr("y2", b - s.padding).attr("stroke", d.gridColor).attr("stroke-dasharray", "2 6"), t.append("line").attr("x1", s.padding).attr("x2", C - s.padding).attr("y1", b - s.padding - F * o).attr("y2", b - s.padding - F * o).attr("stroke", d.gridColor).attr("stroke-dasharray", "2 6");
395
+ }
396
+ }
397
+ const c = /* @__PURE__ */ new Map();
398
+ if (g.nodes.forEach((t) => {
399
+ c.set(t.id, {
400
+ x: L(t.x),
401
+ y: X(t.y),
402
+ node: t
403
+ });
404
+ }), g.pipelines.length > 0) {
405
+ const t = v.append("g").attr("class", "wardley-pipelines"), n = v.append("g").attr("class", "wardley-pipeline-links");
406
+ g.pipelines.forEach((o) => {
407
+ if (o.componentIds.length === 0)
408
+ return;
409
+ const i = o.componentIds.map((f) => ({ id: f, pos: c.get(f), node: g.nodes.find((u) => u.id === f) })).filter((f) => f.pos && f.node).sort((f, u) => f.node.x - u.node.x);
410
+ for (let f = 0; f < i.length - 1; f++) {
411
+ const u = i[f], w = i[f + 1];
412
+ n.append("line").attr("class", "wardley-pipeline-evolution-link").attr("x1", u.pos.x).attr("y1", u.pos.y).attr("x2", w.pos.x).attr("y2", w.pos.y).attr("stroke", d.linkStroke).attr("stroke-width", 1).attr("stroke-dasharray", "4 4");
413
+ }
414
+ let p = 1 / 0, l = -1 / 0, h = 0;
415
+ if (o.componentIds.forEach((f) => {
416
+ const u = c.get(f);
417
+ u && (p = Math.min(p, u.x), l = Math.max(l, u.x), h = u.y);
418
+ }), p !== 1 / 0 && l !== -1 / 0) {
419
+ const u = s.nodeRadius * 4, w = h - u / 2, S = c.get(o.nodeId);
420
+ if (S) {
421
+ const z = (p + l) / 2;
422
+ S.x = z, S.y = w - m / 6;
423
+ }
424
+ t.append("rect").attr("class", "wardley-pipeline-box").attr("x", p - 15).attr("y", w).attr("width", l - p + 30).attr("height", u).attr("fill", "none").attr("stroke", d.axisColor).attr("stroke-width", 1.5).attr("rx", 4).attr("ry", 4);
425
+ }
426
+ });
427
+ }
428
+ const Z = v.append("g").attr("class", "wardley-links"), U = /* @__PURE__ */ new Map();
429
+ g.pipelines.forEach((t) => {
430
+ U.set(t.nodeId, new Set(t.componentIds));
431
+ });
432
+ const J = g.links.filter((t) => !(!c.has(t.source) || !c.has(t.target) || U.get(t.target)?.has(t.source)));
433
+ Z.selectAll("line").data(J).enter().append("line").attr("class", (t) => `wardley-link${t.dashed ? " wardley-link--dashed" : ""}`).attr("x1", (t) => {
434
+ const n = c.get(t.source), o = c.get(t.target), p = g.nodes.find((u) => u.id === t.source).isPipelineParent ? m / Math.sqrt(2) : s.nodeRadius, l = o.x - n.x, h = o.y - n.y, f = Math.sqrt(l * l + h * h);
435
+ return n.x + l / f * p;
436
+ }).attr("y1", (t) => {
437
+ const n = c.get(t.source), o = c.get(t.target), p = g.nodes.find((u) => u.id === t.source).isPipelineParent ? m / Math.sqrt(2) : s.nodeRadius, l = o.x - n.x, h = o.y - n.y, f = Math.sqrt(l * l + h * h);
438
+ return n.y + h / f * p;
439
+ }).attr("x2", (t) => {
440
+ const n = c.get(t.source), o = c.get(t.target), p = g.nodes.find((u) => u.id === t.target).isPipelineParent ? m / Math.sqrt(2) : s.nodeRadius, l = n.x - o.x, h = n.y - o.y, f = Math.sqrt(l * l + h * h);
441
+ return o.x + l / f * p;
442
+ }).attr("y2", (t) => {
443
+ const n = c.get(t.source), o = c.get(t.target), p = g.nodes.find((u) => u.id === t.target).isPipelineParent ? m / Math.sqrt(2) : s.nodeRadius, l = n.x - o.x, h = n.y - o.y, f = Math.sqrt(l * l + h * h);
444
+ return o.y + h / f * p;
445
+ }).attr("stroke", d.linkStroke).attr("stroke-width", 1).attr("stroke-dasharray", (t) => t.dashed ? "6 6" : null).attr("marker-end", (t) => t.flow === "forward" || t.flow === "bidirectional" ? `url(#link-arrow-end-${r})` : null).attr("marker-start", (t) => t.flow === "backward" || t.flow === "bidirectional" ? `url(#link-arrow-start-${r})` : null), Z.selectAll("text").data(J.filter((t) => t.label)).enter().append("text").attr("class", "wardley-link-label").attr("x", (t) => {
446
+ const n = c.get(t.source), o = c.get(t.target), i = (n.x + o.x) / 2, p = o.y - n.y, l = o.x - n.x, h = Math.sqrt(l * l + p * p), f = 8, u = p / h;
447
+ return i + u * f;
448
+ }).attr("y", (t) => {
449
+ const n = c.get(t.source), o = c.get(t.target), i = (n.y + o.y) / 2, p = o.x - n.x, l = o.y - n.y, h = Math.sqrt(p * p + l * l), f = 8, u = -p / h;
450
+ return i + u * f;
451
+ }).attr("fill", d.axisTextColor).attr("font-size", s.labelFontSize).attr("text-anchor", "middle").attr("dominant-baseline", "middle").attr("transform", (t) => {
452
+ const n = c.get(t.source), o = c.get(t.target), i = (n.x + o.x) / 2, p = (n.y + o.y) / 2, l = o.x - n.x, h = o.y - n.y, f = Math.sqrt(l * l + h * h), u = 8, w = h / f, S = -l / f, z = i + w * u, D = p + S * u;
453
+ let T = Math.atan2(h, l) * 180 / Math.PI;
454
+ return (T > 90 || T < -90) && (T += 180), `rotate(${T} ${z} ${D})`;
455
+ }).text((t) => t.label);
456
+ const wt = v.append("g").attr("class", "wardley-trends"), bt = g.trends.map((t) => {
457
+ const n = c.get(t.nodeId);
458
+ if (!n)
459
+ return null;
460
+ const o = L(t.targetX), i = X(t.targetY), p = o - n.x, l = i - n.y, h = Math.sqrt(p * p + l * l), f = s.nodeRadius + 2, u = h > f ? o - p / h * f : o, w = h > f ? i - l / h * f : i;
461
+ return {
462
+ origin: n,
463
+ targetX: o,
464
+ targetY: i,
465
+ adjustedX2: u,
466
+ adjustedY2: w
467
+ };
468
+ }).filter((t) => t !== null);
469
+ wt.selectAll("line").data(bt).enter().append("line").attr("class", "wardley-trend").attr("x1", (t) => t.origin.x).attr("y1", (t) => t.origin.y).attr("x2", (t) => t.adjustedX2).attr("y2", (t) => t.adjustedY2).attr("stroke", d.evolutionStroke).attr("stroke-width", 1).attr("stroke-dasharray", "4 4").attr("marker-end", `url(#arrow-${r})`);
470
+ const N = v.append("g").attr("class", "wardley-nodes").selectAll("g").data(g.nodes).enter().append("g").attr(
471
+ "class",
472
+ (t) => ["wardley-node", t.className ? `wardley-node--${t.className}` : ""].filter(Boolean).join(" ")
473
+ );
474
+ N.filter((t) => t.sourceStrategy === "outsource").append("circle").attr("class", "wardley-outsource-overlay").attr("cx", (t) => c.get(t.id).x).attr("cy", (t) => c.get(t.id).y).attr("r", s.nodeRadius * 2).attr("fill", "#666").attr("stroke", d.componentStroke).attr("stroke-width", 1), N.filter((t) => t.sourceStrategy === "buy").append("circle").attr("class", "wardley-buy-overlay").attr("cx", (t) => c.get(t.id).x).attr("cy", (t) => c.get(t.id).y).attr("r", s.nodeRadius * 2).attr("fill", "#ccc").attr("stroke", d.componentStroke).attr("stroke-width", 1), N.filter((t) => t.sourceStrategy === "build").append("circle").attr("class", "wardley-build-overlay").attr("cx", (t) => c.get(t.id).x).attr("cy", (t) => c.get(t.id).y).attr("r", s.nodeRadius * 2).attr("fill", "#eee").attr("stroke", "#000").attr("stroke-width", 1);
475
+ const A = N.filter((t) => t.sourceStrategy === "market");
476
+ A.append("circle").attr("class", "wardley-market-overlay").attr("cx", (t) => c.get(t.id).x).attr("cy", (t) => c.get(t.id).y).attr("r", s.nodeRadius * 2).attr("fill", "white").attr("stroke", d.componentStroke).attr("stroke-width", 1), N.filter(
477
+ (t) => !t.isPipelineParent && t.sourceStrategy !== "market" && t.className !== "anchor"
478
+ ).append("circle").attr("cx", (t) => c.get(t.id).x).attr("cy", (t) => c.get(t.id).y).attr("r", s.nodeRadius).attr("fill", d.componentFill).attr("stroke", d.componentStroke).attr("stroke-width", 1);
479
+ const _ = s.nodeRadius * 0.7, k = s.nodeRadius * 1.2;
480
+ if (A.append("line").attr("class", "wardley-market-line").attr("x1", (t) => c.get(t.id).x).attr("y1", (t) => c.get(t.id).y - k).attr("x2", (t) => c.get(t.id).x - k * Math.cos(Math.PI / 6)).attr("y2", (t) => c.get(t.id).y + k * Math.sin(Math.PI / 6)).attr("stroke", d.componentStroke).attr("stroke-width", 1), A.append("line").attr("class", "wardley-market-line").attr("x1", (t) => c.get(t.id).x - k * Math.cos(Math.PI / 6)).attr("y1", (t) => c.get(t.id).y + k * Math.sin(Math.PI / 6)).attr("x2", (t) => c.get(t.id).x + k * Math.cos(Math.PI / 6)).attr("y2", (t) => c.get(t.id).y + k * Math.sin(Math.PI / 6)).attr("stroke", d.componentStroke).attr("stroke-width", 1), A.append("line").attr("class", "wardley-market-line").attr("x1", (t) => c.get(t.id).x + k * Math.cos(Math.PI / 6)).attr("y1", (t) => c.get(t.id).y + k * Math.sin(Math.PI / 6)).attr("x2", (t) => c.get(t.id).x).attr("y2", (t) => c.get(t.id).y - k).attr("stroke", d.componentStroke).attr("stroke-width", 1), A.append("circle").attr("class", "wardley-market-dot").attr("cx", (t) => c.get(t.id).x).attr("cy", (t) => c.get(t.id).y - k).attr("r", _).attr("fill", "white").attr("stroke", d.componentStroke).attr("stroke-width", 2), A.append("circle").attr("class", "wardley-market-dot").attr("cx", (t) => c.get(t.id).x - k * Math.cos(Math.PI / 6)).attr("cy", (t) => c.get(t.id).y + k * Math.sin(Math.PI / 6)).attr("r", _).attr("fill", "white").attr("stroke", d.componentStroke).attr("stroke-width", 2), A.append("circle").attr("class", "wardley-market-dot").attr("cx", (t) => c.get(t.id).x + k * Math.cos(Math.PI / 6)).attr("cy", (t) => c.get(t.id).y + k * Math.sin(Math.PI / 6)).attr("r", _).attr("fill", "white").attr("stroke", d.componentStroke).attr("stroke-width", 2), N.filter((t) => t.isPipelineParent === !0).append("rect").attr("x", (t) => c.get(t.id).x - m / 2).attr("y", (t) => c.get(t.id).y - m / 2).attr("width", m).attr("height", m).attr("fill", d.componentFill).attr("stroke", d.componentStroke).attr("stroke-width", 1), N.filter((t) => t.inertia === !0).append("line").attr("class", "wardley-inertia").attr("x1", (t) => {
481
+ const n = c.get(t.id);
482
+ let o = t.isPipelineParent ? m / 2 + 15 : s.nodeRadius + 15;
483
+ return t.sourceStrategy && (o += s.nodeRadius + 10), n.x + o;
484
+ }).attr("y1", (t) => {
485
+ const n = c.get(t.id), o = t.isPipelineParent ? m : s.nodeRadius * 2;
486
+ return n.y - o / 2;
487
+ }).attr("x2", (t) => {
488
+ const n = c.get(t.id);
489
+ let o = t.isPipelineParent ? m / 2 + 15 : s.nodeRadius + 15;
490
+ return t.sourceStrategy && (o += s.nodeRadius + 10), n.x + o;
491
+ }).attr("y2", (t) => {
492
+ const n = c.get(t.id), o = t.isPipelineParent ? m : s.nodeRadius * 2;
493
+ return n.y + o / 2;
494
+ }).attr("stroke", d.componentStroke).attr("stroke-width", 6), N.append("text").attr("x", (t) => {
495
+ const n = c.get(t.id);
496
+ if (t.className === "anchor")
497
+ return t.labelOffsetX !== void 0 ? n.x + t.labelOffsetX : n.x;
498
+ let o = s.nodeLabelOffset;
499
+ t.sourceStrategy && t.labelOffsetX === void 0 && (o += 10);
500
+ const i = t.labelOffsetX ?? o;
501
+ return n.x + i;
502
+ }).attr("y", (t) => {
503
+ const n = c.get(t.id);
504
+ if (t.className === "anchor")
505
+ return t.labelOffsetY !== void 0 ? n.y + t.labelOffsetY : n.y - 3;
506
+ let o = -s.nodeLabelOffset;
507
+ t.sourceStrategy && t.labelOffsetY === void 0 && (o -= 10);
508
+ const i = t.labelOffsetY ?? o;
509
+ return n.y + i;
510
+ }).attr("class", "wardley-node-label").attr("fill", (t) => t.className === "evolved" ? d.evolutionStroke : t.className === "anchor" ? "#000" : d.componentLabelColor).attr("font-size", s.labelFontSize).attr("font-weight", (t) => t.className === "anchor" ? "bold" : "normal").attr("text-anchor", (t) => t.className === "anchor" ? "middle" : "start").attr("dominant-baseline", (t) => t.className === "anchor" ? "middle" : "auto").text((t) => t.label), g.annotations.length > 0) {
511
+ const t = v.append("g").attr("class", "wardley-annotations");
512
+ if (g.annotations.forEach((n) => {
513
+ const o = n.coordinates.map((i) => ({
514
+ x: L(i.x),
515
+ y: X(i.y)
516
+ }));
517
+ if (o.length > 1)
518
+ for (let i = 0; i < o.length - 1; i++)
519
+ t.append("line").attr("class", "wardley-annotation-line").attr("x1", o[i].x).attr("y1", o[i].y).attr("x2", o[i + 1].x).attr("y2", o[i + 1].y).attr("stroke", d.axisColor).attr("stroke-width", 1.5).attr("stroke-dasharray", "4 4");
520
+ o.forEach((i) => {
521
+ const p = t.append("g").attr("class", "wardley-annotation");
522
+ p.append("circle").attr("cx", i.x).attr("cy", i.y).attr("r", 10).attr("fill", "white").attr("stroke", d.axisColor).attr("stroke-width", 1.5), p.append("text").attr("x", i.x).attr("y", i.y).attr("text-anchor", "middle").attr("dominant-baseline", "central").attr("font-size", 10).attr("fill", d.axisTextColor).attr("font-weight", "bold").text(n.number);
523
+ });
524
+ }), g.annotationsBox) {
525
+ let n = L(g.annotationsBox.x), o = X(g.annotationsBox.y);
526
+ const i = 10, p = 16, l = 11, h = t.append("g").attr("class", "wardley-annotations-box"), f = [...g.annotations].filter((w) => w.text).sort((w, S) => w.number - S.number), u = [];
527
+ if (f.forEach((w, S) => {
528
+ const z = h.append("text").attr("x", n + i).attr("y", o + i + (S + 1) * p).attr("font-size", l).attr("fill", d.axisTextColor).attr("text-anchor", "start").attr("dominant-baseline", "middle").text(`${w.number}. ${w.text}`);
529
+ u.push(z);
530
+ }), u.length > 0) {
531
+ let w = 0, S = 0;
532
+ u.forEach((V) => {
533
+ const G = V.node(), St = G.getComputedTextLength();
534
+ w = Math.max(w, St);
535
+ const $t = G.getBBox();
536
+ S = Math.max(S, $t.height);
537
+ });
538
+ const z = w + i * 2 + 105, D = f.length * p + i * 2 + S / 2, T = s.padding, kt = C - s.padding - z, Pt = s.padding, vt = b - s.padding - D;
539
+ n = Math.max(T, Math.min(n, kt)), o = Math.max(Pt, Math.min(o, vt)), u.forEach((V, G) => {
540
+ V.attr("x", n + i).attr("y", o + i + (G + 1) * p);
541
+ }), h.insert("rect", "text").attr("x", n).attr("y", o).attr("width", z).attr("height", D).attr("fill", "white").attr("stroke", d.axisColor).attr("stroke-width", 1.5).attr("rx", 4).attr("ry", 4);
542
+ }
543
+ }
544
+ }
545
+ if (g.notes.length > 0) {
546
+ const t = v.append("g").attr("class", "wardley-notes");
547
+ g.notes.forEach((n) => {
548
+ const o = L(n.x), i = X(n.y);
549
+ t.append("text").attr("x", o).attr("y", i).attr("text-anchor", "start").attr("font-size", 11).attr("fill", d.axisTextColor).attr("font-weight", "bold").text(n.text);
550
+ });
551
+ }
552
+ if (g.accelerators.length > 0) {
553
+ const t = v.append("g").attr("class", "wardley-accelerators");
554
+ g.accelerators.forEach((n) => {
555
+ const o = L(n.x), i = X(n.y), p = 60, l = 30, h = 20, f = `
556
+ M ${o} ${i - l / 2}
557
+ L ${o + p - h} ${i - l / 2}
558
+ L ${o + p - h} ${i - l / 2 - 8}
559
+ L ${o + p} ${i}
560
+ L ${o + p - h} ${i + l / 2 + 8}
561
+ L ${o + p - h} ${i + l / 2}
562
+ L ${o} ${i + l / 2}
563
+ Z
564
+ `;
565
+ t.append("path").attr("d", f).attr("fill", "white").attr("stroke", d.componentStroke).attr("stroke-width", 1), t.append("text").attr("x", o + p / 2).attr("y", i + l / 2 + 15).attr("text-anchor", "middle").attr("font-size", 10).attr("fill", d.axisTextColor).attr("font-weight", "bold").text(n.name);
566
+ });
567
+ }
568
+ if (g.deaccelerators.length > 0) {
569
+ const t = v.append("g").attr("class", "wardley-deaccelerators");
570
+ g.deaccelerators.forEach((n) => {
571
+ const o = L(n.x), i = X(n.y), p = 60, l = 30, h = 20, f = `
572
+ M ${o + p} ${i - l / 2}
573
+ L ${o + h} ${i - l / 2}
574
+ L ${o + h} ${i - l / 2 - 8}
575
+ L ${o} ${i}
576
+ L ${o + h} ${i + l / 2 + 8}
577
+ L ${o + h} ${i + l / 2}
578
+ L ${o + p} ${i + l / 2}
579
+ Z
580
+ `;
581
+ t.append("path").attr("d", f).attr("fill", "white").attr("stroke", d.componentStroke).attr("stroke-width", 1), t.append("text").attr("x", o + p / 2).attr("y", i + l / 2 + 15).attr("text-anchor", "middle").attr("font-size", 10).attr("fill", d.axisTextColor).attr("font-weight", "bold").text(n.name);
582
+ });
583
+ }
584
+ }, "draw"), jt = {
585
+ draw: Ht
586
+ }, Jt = {
587
+ parser: tt,
588
+ db: Wt,
589
+ renderer: jt,
590
+ styles: /* @__PURE__ */ y(() => "", "styles")
591
+ };
592
+ export {
593
+ Jt as diagram
594
+ };