@miragon/team-topologies-renderer 0.10.1 → 0.11.1

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 (60) hide show
  1. package/README.md +98 -31
  2. package/dist/Modeler.d.ts +2 -1
  3. package/dist/Modeler.d.ts.map +1 -1
  4. package/dist/TtBaseViewer.d.ts +47 -7
  5. package/dist/TtBaseViewer.d.ts.map +1 -1
  6. package/dist/collaborative/CollaborativeTeamTopologies.d.ts +36 -0
  7. package/dist/collaborative/CollaborativeTeamTopologies.d.ts.map +1 -0
  8. package/dist/collaborative/index.d.ts +2 -0
  9. package/dist/collaborative/index.d.ts.map +1 -0
  10. package/dist/context-pad/TtContextPadProvider.d.ts +9 -1
  11. package/dist/context-pad/TtContextPadProvider.d.ts.map +1 -1
  12. package/dist/copy-paste/TtCopyPasteProps.d.ts.map +1 -1
  13. package/dist/draw/icons.d.ts +51 -11
  14. package/dist/draw/icons.d.ts.map +1 -1
  15. package/dist/draw/label-layout.d.ts +5 -0
  16. package/dist/draw/label-layout.d.ts.map +1 -1
  17. package/dist/draw/palette-icons.d.ts +1 -1
  18. package/dist/draw/palette-icons.d.ts.map +1 -1
  19. package/dist/draw/styles.d.ts +4 -5
  20. package/dist/draw/styles.d.ts.map +1 -1
  21. package/dist/index.d.ts +11 -2
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +1019 -497
  24. package/dist/index.js.map +1 -1
  25. package/dist/io/TtExporter.d.ts.map +1 -1
  26. package/dist/io/TtImporter.d.ts +4 -1
  27. package/dist/io/TtImporter.d.ts.map +1 -1
  28. package/dist/io/TtViewport.d.ts +19 -0
  29. package/dist/io/TtViewport.d.ts.map +1 -0
  30. package/dist/io/fontEmbedding.d.ts +18 -0
  31. package/dist/io/fontEmbedding.d.ts.map +1 -0
  32. package/dist/io/index.d.ts +4 -1
  33. package/dist/io/index.d.ts.map +1 -1
  34. package/dist/io/saveSvg.d.ts.map +1 -1
  35. package/dist/io/types.d.ts +3 -0
  36. package/dist/io/types.d.ts.map +1 -1
  37. package/dist/keyboard/TtKeyboard.d.ts +9 -1
  38. package/dist/keyboard/TtKeyboard.d.ts.map +1 -1
  39. package/dist/keyboard/index.d.ts +2 -1
  40. package/dist/keyboard/index.d.ts.map +1 -1
  41. package/dist/label-editing/TtLabelEditing.d.ts +33 -2
  42. package/dist/label-editing/TtLabelEditing.d.ts.map +1 -1
  43. package/dist/model/TtElementFactory.d.ts +2 -0
  44. package/dist/model/TtElementFactory.d.ts.map +1 -1
  45. package/dist/model/di-types.d.ts +11 -5
  46. package/dist/model/di-types.d.ts.map +1 -1
  47. package/dist/modeling/TtModeling.d.ts +2 -0
  48. package/dist/modeling/TtModeling.d.ts.map +1 -1
  49. package/dist/modeling/cmd/UpdateTitleHandler.d.ts +16 -0
  50. package/dist/modeling/cmd/UpdateTitleHandler.d.ts.map +1 -0
  51. package/dist/palette/TtPaletteProvider.d.ts +28 -1
  52. package/dist/palette/TtPaletteProvider.d.ts.map +1 -1
  53. package/dist/read-only/TtReadOnly.d.ts +14 -0
  54. package/dist/read-only/TtReadOnly.d.ts.map +1 -0
  55. package/dist/read-only/index.d.ts +5 -0
  56. package/dist/read-only/index.d.ts.map +1 -0
  57. package/dist/team-topologies.css +1 -1
  58. package/dist/theme/palette.d.ts +29 -9
  59. package/dist/theme/palette.d.ts.map +1 -1
  60. package/package.json +10 -9
package/dist/index.js CHANGED
@@ -1,84 +1,150 @@
1
1
  import e from "diagram-js/lib/Diagram";
2
- import { getMid as t } from "diagram-js/lib/layout/LayoutUtil";
3
- import { ALL_INTERACTION_SPECS as n, ALL_TEAM_SPECS as r, ANNOTATION_SPEC as i, DOCUMENT_VERSION as a, FLOW_SPEC as o, INTERACTION_MODE_SPECS as s, TEAM_TYPE_SPECS as c, dashArray as l, newId as u } from "@miragon/team-topologies-schema-model";
4
- import d from "diagram-js/lib/layout/CroppingConnectionDocking";
5
- import f from "diagram-js/lib/draw/BaseRenderer";
6
- import { append as p, attr as m, create as h } from "tiny-svg";
7
- import g from "diagram-js/lib/features/selection";
8
- import ee from "diagram-js/lib/navigation/zoomscroll";
9
- import te from "diagram-js/lib/navigation/movecanvas";
10
- import _ from "diagram-js/lib/features/lasso-tool";
11
- import v from "diagram-js/lib/features/modeling";
12
- import ne from "diagram-js/lib/features/move";
13
- import re from "diagram-js/lib/features/outline";
14
- import ie from "diagram-js/lib/features/resize";
15
- import ae from "diagram-js/lib/layout/BaseLayouter";
16
- import oe from "diagram-js/lib/features/rules";
17
- import se from "diagram-js/lib/features/rules/RuleProvider";
18
- import ce from "diagram-js/lib/command/CommandInterceptor";
19
- import le from "diagram-js/lib/features/palette";
20
- import ue from "diagram-js/lib/features/create";
21
- import de from "diagram-js/lib/features/connect";
22
- import fe from "diagram-js/lib/features/connection-preview";
23
- import pe from "diagram-js/lib/features/context-pad";
24
- import me from "diagram-js/lib/features/copy-paste";
25
- import he from "diagram-js/lib/features/copy-paste/CopyPaste.js";
2
+ import { ALL_INTERACTION_SPECS as t, ALL_TEAM_SPECS as n, ANNOTATION_FIELDS as r, ANNOTATION_SPEC as i, DIAGRAM_ROOT_ID as a, DOCUMENT_FIELDS as o, DOCUMENT_VERSION as s, FLOW_FIELDS as c, FLOW_SPEC as l, INTERACTION_FIELDS as u, INTERACTION_MODE_SPECS as d, TEAM_NODE_FIELDS as f, TEAM_TYPE_SPECS as p, associationId as m, dashArray as h, documentIdProblems as g, foreignFields as _, newId as v, parseDocument as ee, serializeDocument as te, withForeignFields as y } from "@miragon/team-topologies-schema-model";
3
+ import { getMid as b } from "diagram-js/lib/layout/LayoutUtil";
4
+ import ne from "diagram-js/lib/layout/CroppingConnectionDocking";
5
+ import re from "diagram-js/lib/draw/BaseRenderer";
6
+ import { append as x, attr as S, create as C } from "tiny-svg";
7
+ import ie from "diagram-js/lib/features/selection";
8
+ import ae from "diagram-js/lib/navigation/zoomscroll";
9
+ import oe from "diagram-js/lib/navigation/movecanvas";
10
+ import se from "diagram-js/lib/features/lasso-tool";
11
+ import ce from "diagram-js/lib/features/modeling";
12
+ import le from "diagram-js/lib/features/move";
13
+ import ue from "diagram-js/lib/features/outline";
14
+ import de from "diagram-js/lib/features/resize";
15
+ import fe from "diagram-js/lib/layout/BaseLayouter";
16
+ import pe from "diagram-js/lib/features/rules";
17
+ import me from "diagram-js/lib/features/rules/RuleProvider";
18
+ import he from "diagram-js/lib/command/CommandInterceptor";
19
+ import ge from "diagram-js/lib/features/palette";
20
+ import _e from "diagram-js/lib/features/create";
21
+ import ve from "diagram-js/lib/features/connect";
22
+ import ye from "diagram-js/lib/features/connection-preview";
23
+ import be from "diagram-js/lib/features/context-pad";
24
+ import xe from "diagram-js/lib/features/copy-paste";
25
+ import Se from "diagram-js/lib/features/copy-paste/CopyPaste.js";
26
+ import { MODELER_API_VERSION as Ce } from "@miragon/modeler-api";
26
27
  //#region src/model/di-types.ts
27
- var ge = /* @__PURE__ */ new Set([
28
+ var we = /* @__PURE__ */ new Set([
28
29
  "team",
29
30
  "interaction",
30
31
  "flow",
31
32
  "annotation"
32
33
  ]);
33
- function y(e) {
34
+ function w(e) {
34
35
  return typeof e == "object" && e ? e.ttKind : void 0;
35
36
  }
36
- function b(e) {
37
- let t = y(e);
38
- return t !== void 0 && ge.has(t);
37
+ function T(e) {
38
+ let t = w(e);
39
+ return t !== void 0 && we.has(t);
39
40
  }
40
- function x(e) {
41
- return y(e) === "team";
41
+ function E(e) {
42
+ return w(e) === "team";
42
43
  }
43
- function S(e) {
44
- return y(e) === "interaction";
44
+ function D(e) {
45
+ return w(e) === "interaction";
45
46
  }
46
- function C(e) {
47
- return y(e) === "flow";
47
+ function O(e) {
48
+ return w(e) === "flow";
48
49
  }
49
- function w(e) {
50
- return y(e) === "annotation";
50
+ function k(e) {
51
+ return w(e) === "annotation";
51
52
  }
52
- function T(e) {
53
- return y(e) === "association";
53
+ function A(e) {
54
+ return w(e) === "association";
54
55
  }
55
56
  //#endregion
56
- //#region src/io/saveSvg.ts
57
- var E = 40;
58
- function D(e, t) {
59
- let n = e.getContainer().querySelector("svg");
57
+ //#region src/theme/palette.ts
58
+ var j = {
59
+ blau: "#335DE5",
60
+ blauLink: "#2B50D4",
61
+ blauHell: "#6B8AFF",
62
+ gruen: "#00E676",
63
+ grau: "#F9F7F7",
64
+ schwarz: "#1D1D1D",
65
+ weiss: "#FFFFFF",
66
+ linie: "#E6E2E2",
67
+ kontur: "#8F8A8A",
68
+ textLeise: "#6B6666",
69
+ success: "#00E676",
70
+ successSoft: "#DAFBEB",
71
+ warning: "#FFB000",
72
+ warningSoft: "#FFF1D2",
73
+ danger: "#CD1839",
74
+ dangerSoft: "#FBEEF0",
75
+ info: "#335DE5",
76
+ infoSoft: "#EEF1FD",
77
+ successHell: "#00E676",
78
+ warningHell: "#FFB000",
79
+ dangerHell: "#FB6D73",
80
+ infoHell: "#6B8AFF",
81
+ gradientBrand: "linear-gradient(120deg, #335DE5 30%, #00E676)"
82
+ }, Te = {
83
+ "--cd-blau": j.blau,
84
+ "--cd-gruen": j.gruen,
85
+ "--cd-grau": j.grau,
86
+ "--cd-schwarz": j.schwarz,
87
+ "--cd-weiss": j.weiss,
88
+ "--cd-blau-link": j.blauLink,
89
+ "--cd-blau-hell": j.blauHell,
90
+ "--cd-linie": j.linie,
91
+ "--cd-kontur": j.kontur,
92
+ "--cd-text-leise": j.textLeise,
93
+ "--cd-success": j.success,
94
+ "--cd-success-soft": j.successSoft,
95
+ "--cd-warning": j.warning,
96
+ "--cd-warning-soft": j.warningSoft,
97
+ "--cd-danger": j.danger,
98
+ "--cd-danger-soft": j.dangerSoft,
99
+ "--cd-info": j.info,
100
+ "--cd-info-soft": j.infoSoft,
101
+ "--cd-success-hell": j.successHell,
102
+ "--cd-warning-hell": j.warningHell,
103
+ "--cd-danger-hell": j.dangerHell,
104
+ "--cd-info-hell": j.infoHell,
105
+ "--cd-gradient-brand": j.gradientBrand
106
+ }, M = 40, Ee = "http://www.w3.org/2000/svg", De = [
107
+ ".djs-outline",
108
+ ".djs-resizer",
109
+ ".djs-selection-outline",
110
+ ".djs-lasso-overlay",
111
+ ".djs-dragger",
112
+ ".djs-bendpoint",
113
+ ".djs-segment-dragger"
114
+ ].join(", "), Oe = ["selected", "hover"], ke = [
115
+ "class",
116
+ "tabindex",
117
+ "role",
118
+ "aria-roledescription",
119
+ "aria-label"
120
+ ];
121
+ function Ae(e, t) {
122
+ let n = e.getContainer().querySelector(":scope > svg");
60
123
  if (!n) throw Error("No SVG found in the canvas container.");
61
124
  let r = Infinity, i = Infinity, a = -Infinity, o = -Infinity;
62
125
  for (let e of t.getAll()) {
63
- if (!b(e)) continue;
126
+ if (!T(e)) continue;
64
127
  let t = e;
65
128
  r = Math.min(r, t.x), i = Math.min(i, t.y), a = Math.max(a, t.x + t.width), o = Math.max(o, t.y + t.height);
66
129
  }
67
130
  Number.isFinite(r) || (r = 0, i = 0, a = 100, o = 100);
68
- let s = r - E, c = i - E, l = a - r + 80, u = o - i + 80, d = n.cloneNode(!0);
69
- d.setAttribute("xmlns", "http://www.w3.org/2000/svg"), d.setAttribute("viewBox", `${s} ${c} ${l} ${u}`), d.setAttribute("width", String(Math.round(l))), d.setAttribute("height", String(Math.round(u)));
131
+ let s = r - M, c = i - M, l = a - r + 80, u = o - i + 80, d = n.cloneNode(!0);
132
+ for (let e of ke) d.removeAttribute(e);
133
+ for (let e of d.querySelectorAll(De)) e.remove();
134
+ for (let e of d.querySelectorAll(Oe.map((e) => `.${e}`).join())) e.classList.remove(...Oe);
135
+ d.setAttribute("xmlns", Ee), d.setAttribute("viewBox", `${s} ${c} ${l} ${u}`), d.setAttribute("width", String(Math.round(l))), d.setAttribute("height", String(Math.round(u)));
70
136
  let f = d.querySelector(".viewport");
71
- return f && f.removeAttribute("transform"), { svg: "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + new XMLSerializer().serializeToString(d) };
137
+ f && f.removeAttribute("transform");
138
+ let p = d.ownerDocument.createElementNS(Ee, "rect");
139
+ return p.setAttribute("class", "tt-export-paper"), p.setAttribute("x", String(s)), p.setAttribute("y", String(c)), p.setAttribute("width", String(l)), p.setAttribute("height", String(u)), p.setAttribute("fill", j.weiss), d.insertBefore(p, d.firstChild), { svg: "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + new XMLSerializer().serializeToString(d) };
72
140
  }
73
141
  //#endregion
74
142
  //#region src/io/types.ts
75
- var O = "tt-root";
76
- //#endregion
77
- //#region src/TtBaseViewer.ts
78
- function _e(e) {
143
+ var N = a, P = "tt-canvas-keyboard-focus";
144
+ function je(e) {
79
145
  return typeof e == "number" ? `${e}px` : e;
80
146
  }
81
- var ve = class {
147
+ var Me = class {
82
148
  _diagram;
83
149
  _container;
84
150
  _options;
@@ -87,18 +153,33 @@ var ve = class {
87
153
  }
88
154
  _createContainer(e) {
89
155
  let t = e.container ?? document.createElement("div");
90
- return t.classList.add("tt-djs-container"), t.style.width = _e(e.width ?? "100%"), t.style.height = _e(e.height ?? (e.container ? "100%" : "600px")), t;
156
+ return t.classList.add("tt-djs-container"), t.style.width = je(e.width ?? "100%"), t.style.height = je(e.height ?? (e.container ? "100%" : "600px")), t;
91
157
  }
92
158
  _ensureDiagram() {
93
159
  if (!this._diagram) {
94
160
  let t = [...this._getModules(), ...this._options.additionalModules ?? []];
95
161
  this._diagram = new e({
96
162
  canvas: { container: this._container },
97
- modules: t
98
- });
163
+ modules: t,
164
+ ttKeyboard: { undoRedoKeys: this._options.undoRedoKeys ?? !0 },
165
+ ttPalette: { freeRectCenter: this._options.freeRectCenter }
166
+ }), this._describeCanvas(this._diagram);
99
167
  }
100
168
  return this._diagram;
101
169
  }
170
+ _describeCanvas(e) {
171
+ let t = e.get("canvas").getContainer(), n = t.querySelector(":scope > svg");
172
+ if (!n) return;
173
+ n.setAttribute("aria-label", "Team Topologies diagram");
174
+ let r = t.ownerDocument, i = !1, a = (e) => {
175
+ i = e.key === "Tab";
176
+ }, o = () => {
177
+ i = !1, n.classList.remove(P);
178
+ };
179
+ r.addEventListener("keydown", a, !0), r.addEventListener("pointerdown", o, !0), n.addEventListener("focusin", () => n.classList.toggle(P, i)), n.addEventListener("focusout", () => n.classList.remove(P)), e.get("eventBus").on("diagram.destroy", () => {
180
+ r.removeEventListener("keydown", a, !0), r.removeEventListener("pointerdown", o, !0);
181
+ });
182
+ }
102
183
  get(e) {
103
184
  return this._ensureDiagram().get(e);
104
185
  }
@@ -108,11 +189,20 @@ var ve = class {
108
189
  off(e, t) {
109
190
  this.get("eventBus").off(e, t);
110
191
  }
111
- importDocument(e) {
112
- let t = this._ensureDiagram(), n = t.get("eventBus"), r = t.get("ttImporter");
113
- r.clear();
114
- let i = r.import(e);
115
- return this._fit(), n.fire("import.done", { warnings: i }), { warnings: i };
192
+ importDocument(e, t = {}) {
193
+ let n = g(e);
194
+ if (n.length > 0) throw Error(n.map(({ path: e, message: t }) => `${e.join(".")}: ${t}`).join("; "));
195
+ let r = this._ensureDiagram(), i = r.get("eventBus"), a = r.get("ttImporter"), o = r.get("ttLabelEditing", !1);
196
+ i.fire("import.parse.start", { document: e }), o?.suspend(), r.get("commandStack", !1)?.clear(!1), a.clear();
197
+ let s = a.import(e);
198
+ return t.fit !== !1 && this._fit(), i.fire("import.done", { warnings: s }), o?.resumeAfterImport(), { warnings: s };
199
+ }
200
+ fitToView() {
201
+ this._fit();
202
+ }
203
+ _fit() {
204
+ let e = this._ensureDiagram().get("ttViewport", !1);
205
+ e ? e.fit() : this.get("canvas").zoom("fit-viewport");
116
206
  }
117
207
  exportDocument() {
118
208
  return this.get("ttExporter").export();
@@ -124,7 +214,7 @@ var ve = class {
124
214
  } catch {
125
215
  return;
126
216
  }
127
- if (!n || n.id !== "tt-root") return;
217
+ if (!n || n.id !== N) return;
128
218
  let r = n.businessObject ?? { title: "Untitled team topology" };
129
219
  n.businessObject = {
130
220
  ...r,
@@ -139,27 +229,7 @@ var ve = class {
139
229
  }
140
230
  }
141
231
  saveSVG() {
142
- return D(this.get("canvas"), this.get("elementRegistry"));
143
- }
144
- _fit(e = 84, t = 56) {
145
- let n = this.get("canvas"), r = this.get("elementRegistry"), i = Infinity, a = Infinity, o = -Infinity, s = -Infinity;
146
- for (let e of r.getAll()) {
147
- let t = e;
148
- typeof t.x == "number" && typeof t.y == "number" && typeof t.width == "number" && typeof t.height == "number" && (i = Math.min(i, t.x), a = Math.min(a, t.y), o = Math.max(o, t.x + t.width), s = Math.max(s, t.y + t.height));
149
- }
150
- if (!Number.isFinite(i)) return;
151
- let c = this._container.getBoundingClientRect(), l = c.width, u = c.height, d = Math.max(o - i, 1), f = Math.max(s - a, 1);
152
- if (!l || !u) {
153
- n.zoom("fit-viewport");
154
- return;
155
- }
156
- let p = Math.min((l - 2 * t) / d, (u - e - t) / f, 1.25);
157
- n.viewbox({
158
- x: i + d / 2 - l / 2 / p,
159
- y: a - e / p,
160
- width: l / p,
161
- height: u / p
162
- });
232
+ return Ae(this.get("canvas"), this.get("elementRegistry"));
163
233
  }
164
234
  attachTo(e) {
165
235
  e.appendChild(this._container), this.get("canvas").resized();
@@ -176,12 +246,16 @@ var ve = class {
176
246
  get container() {
177
247
  return this._container;
178
248
  }
179
- }, ye = class {
249
+ }, Ne = class {
180
250
  elementFactory;
181
251
  static $inject = ["elementFactory"];
182
252
  constructor(e) {
183
253
  this.elementFactory = e;
184
254
  }
255
+ foreign(e, t) {
256
+ let n = _(e, t);
257
+ return n ? { ttForeign: n } : {};
258
+ }
185
259
  createTeam(e) {
186
260
  return this.elementFactory.createShape({
187
261
  id: e.id,
@@ -194,7 +268,8 @@ var ve = class {
194
268
  ttLabel: e.label,
195
269
  ...e.description ? { description: e.description } : {},
196
270
  ...e.fill ? { fill: e.fill } : {},
197
- ...e.stroke ? { stroke: e.stroke } : {}
271
+ ...e.stroke ? { stroke: e.stroke } : {},
272
+ ...this.foreign(e, f)
198
273
  });
199
274
  }
200
275
  createInteraction(e) {
@@ -208,7 +283,8 @@ var ve = class {
208
283
  mode: e.mode,
209
284
  ...e.label ? { ttLabel: e.label } : {},
210
285
  ...e.fill ? { fill: e.fill } : {},
211
- ...e.stroke ? { stroke: e.stroke } : {}
286
+ ...e.stroke ? { stroke: e.stroke } : {},
287
+ ...this.foreign(e, u)
212
288
  });
213
289
  }
214
290
  createFlow(e) {
@@ -219,7 +295,8 @@ var ve = class {
219
295
  width: e.size.width,
220
296
  height: e.size.height,
221
297
  ttKind: "flow",
222
- ...e.label ? { ttLabel: e.label } : {}
298
+ ...e.label ? { ttLabel: e.label } : {},
299
+ ...this.foreign(e, c)
223
300
  });
224
301
  }
225
302
  createAnnotation(e) {
@@ -230,22 +307,23 @@ var ve = class {
230
307
  width: e.size.width,
231
308
  height: e.size.height,
232
309
  ttKind: "annotation",
233
- ...e.text ? { ttLabel: e.text } : {}
310
+ ...e.text ? { ttLabel: e.text } : {},
311
+ ...this.foreign(e, r)
234
312
  });
235
313
  }
236
- createAssociation(e, n) {
314
+ createAssociation(e, t) {
237
315
  return this.elementFactory.createConnection({
238
- id: `assoc_${e.id}`,
316
+ id: m(e.id),
239
317
  ttKind: "association",
240
318
  source: e,
241
- target: n,
242
- waypoints: [t(e), t(n)]
319
+ target: t,
320
+ waypoints: [b(e), b(t)]
243
321
  });
244
322
  }
245
323
  createNewTeam(e, t) {
246
- let n = c[e];
324
+ let n = p[e];
247
325
  return this.elementFactory.createShape({
248
- id: u("team"),
326
+ id: v("team"),
249
327
  width: n.defaultSize.width,
250
328
  height: n.defaultSize.height,
251
329
  ttKind: "team",
@@ -254,9 +332,9 @@ var ve = class {
254
332
  });
255
333
  }
256
334
  createNewInteraction(e) {
257
- let t = s[e];
335
+ let t = d[e];
258
336
  return this.elementFactory.createShape({
259
- id: u("int"),
337
+ id: v("int"),
260
338
  width: t.defaultSize.width,
261
339
  height: t.defaultSize.height,
262
340
  ttKind: "interaction",
@@ -265,16 +343,16 @@ var ve = class {
265
343
  }
266
344
  createNewFlow() {
267
345
  return this.elementFactory.createShape({
268
- id: u("flow"),
269
- width: o.defaultSize.width,
270
- height: o.defaultSize.height,
346
+ id: v("flow"),
347
+ width: l.defaultSize.width,
348
+ height: l.defaultSize.height,
271
349
  ttKind: "flow",
272
- ttLabel: o.label
350
+ ttLabel: l.label
273
351
  });
274
352
  }
275
353
  createNewAnnotation(e) {
276
354
  return this.elementFactory.createShape({
277
- id: u("ann"),
355
+ id: v("ann"),
278
356
  width: i.defaultSize.width,
279
357
  height: i.defaultSize.height,
280
358
  ttKind: "annotation",
@@ -283,86 +361,107 @@ var ve = class {
283
361
  }
284
362
  createNewAssociation() {
285
363
  return this.elementFactory.createConnection({
286
- id: u("assoc"),
364
+ id: v("assoc"),
287
365
  ttKind: "association"
288
366
  });
289
367
  }
290
- }, be = { ttElementFactory: ["type", ye] }, k = {
291
- blau: "#335DE5",
292
- blauLink: "#2B50D4",
293
- blauHell: "#6B8AFF",
294
- gruen: "#00E676",
295
- grau: "#F9F7F7",
296
- schwarz: "#1D1D1D",
297
- weiss: "#FFFFFF",
298
- success: "#0B7A55",
299
- warning: "#92610A",
300
- danger: "#C92A2A",
301
- info: "#2B50D4",
302
- gradientBrand: "linear-gradient(120deg, #335DE5 30%, #00E676)"
303
- };
304
- k.blau, k.gruen, k.grau, k.schwarz, k.weiss, k.blauLink, k.blauHell, k.success, k.warning, k.danger, k.info, k.gradientBrand;
305
- //#endregion
306
- //#region src/draw/styles.ts
307
- var xe = 1500;
308
- k.blau;
309
- var Se = k.schwarz, A = "#5B5B5B", j = {
368
+ }, Pe = { ttElementFactory: ["type", Ne] }, Fe = 1500, F = j.schwarz, Ie = j.textLeise, Le = j.kontur, I = {
310
369
  family: "'Geist Variable', 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif",
311
370
  label: 13.5,
312
371
  small: 11,
313
372
  annotation: 12
314
- };
315
- k.weiss;
316
- //#endregion
317
- //#region src/draw/label-layout.ts
318
- var M = 10, N = {
373
+ }, Re = 10, L = {
319
374
  left: 10,
320
375
  right: 6,
321
376
  top: 6,
322
377
  bottom: 6
323
- }, P = 1.2;
324
- function F(e, t) {
378
+ }, R = 1.2, ze = 4.5;
379
+ function z(e) {
380
+ if (typeof e != "string") return;
381
+ let t = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());
382
+ if (!t) return;
383
+ let n = t[1].length === 3 ? [...t[1]].map((e) => e + e).join("") : t[1], r = (e) => parseInt(n.slice(e, e + 2), 16);
384
+ return [
385
+ r(0),
386
+ r(2),
387
+ r(4)
388
+ ];
389
+ }
390
+ function Be(e, t, n) {
391
+ let r = (r) => Math.round(e[r] * n + t[r] * (1 - n));
392
+ return [
393
+ r(0),
394
+ r(1),
395
+ r(2)
396
+ ];
397
+ }
398
+ function B([e, t, n]) {
399
+ let r = (e) => {
400
+ let t = e / 255;
401
+ return t <= .04045 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
402
+ };
403
+ return .2126 * r(e) + .7152 * r(t) + .0722 * r(n);
404
+ }
405
+ function V(e, t) {
406
+ let [n, r] = [B(e), B(t)].sort((e, t) => t - e);
407
+ return (n + .05) / (r + .05);
408
+ }
409
+ function Ve(e, t = 1) {
410
+ let n = z(e), r = z(F), i = z(j.weiss);
411
+ if (!n || !r || !i) return F;
412
+ let a = Be(n, i, t), o = V(r, a);
413
+ return o >= ze ? F : V(i, a) > o ? j.weiss : F;
414
+ }
415
+ function He(e) {
416
+ if (D(e)) {
417
+ let t = d[e.mode] ?? d.collaboration;
418
+ return Ve(e.fill ?? t.fill, t.opacity);
419
+ }
420
+ let t = p[e.teamType] ?? p["stream-aligned"];
421
+ return Ve(e.fill ?? t.fill);
422
+ }
423
+ function Ue(e, t) {
325
424
  return Math.min(e * .16, t * 1.1);
326
425
  }
327
- function I(e) {
426
+ function H(e) {
328
427
  let t = Math.max(e.width, 1), n = Math.max(e.height, 1);
329
- return w(e) ? {
428
+ return k(e) ? {
330
429
  box: {
331
- x: N.left,
332
- y: N.top,
333
- width: Math.max(t - N.left - N.right, 1),
334
- height: Math.max(n - N.top - N.bottom, 1)
430
+ x: L.left,
431
+ y: L.top,
432
+ width: Math.max(t - L.left - L.right, 1),
433
+ height: Math.max(n - L.top - L.bottom, 1)
335
434
  },
336
435
  align: "left-top",
337
- fontSize: j.annotation,
338
- fontWeight: "450",
339
- fill: Se
340
- } : C(e) ? {
436
+ fontSize: I.annotation,
437
+ fontWeight: "400",
438
+ fill: F
439
+ } : O(e) ? {
341
440
  box: {
342
- x: M,
441
+ x: Re,
343
442
  y: 0,
344
- width: t - F(t, n) - 20,
443
+ width: t - Ue(t, n) - 20,
345
444
  height: n
346
445
  },
347
446
  align: "center",
348
- fontSize: j.small,
349
- fontWeight: "650",
447
+ fontSize: I.small,
448
+ fontWeight: "600",
350
449
  letterSpacing: "0.06em",
351
- fill: A
450
+ fill: Ie
352
451
  } : {
353
452
  box: {
354
- x: M,
453
+ x: Re,
355
454
  y: 0,
356
455
  width: t - 20,
357
456
  height: n
358
457
  },
359
458
  align: "center",
360
- fontSize: S(e) ? j.small : j.label,
361
- fontWeight: S(e) ? "600" : "640",
362
- fill: Se
459
+ fontSize: D(e) ? I.small : I.label,
460
+ fontWeight: "600",
461
+ fill: He(e)
363
462
  };
364
463
  }
365
- function Ce(e, t, n) {
464
+ function We(e, t, n) {
366
465
  let r = Math.max(4, Math.floor(t / (n * .58))), i = e.split(/\r?\n/), a = [];
367
466
  for (let e of i) {
368
467
  let t = e.split(/\s+/).filter(Boolean), n = "";
@@ -378,65 +477,65 @@ function Ce(e, t, n) {
378
477
  }
379
478
  //#endregion
380
479
  //#region src/draw/TeamTopologiesRenderer.ts
381
- var L = class extends f {
480
+ var Ge = class extends re {
382
481
  static $inject = ["eventBus"];
383
482
  constructor(e) {
384
- super(e, xe);
483
+ super(e, Fe);
385
484
  }
386
485
  canRender(e) {
387
- return b(e) || T(e);
486
+ return T(e) || A(e);
388
487
  }
389
488
  drawShape(e, t) {
390
- if (x(t)) return this.drawTeam(e, t);
391
- if (S(t)) return this.drawInteraction(e, t);
392
- if (C(t)) return this.drawFlow(e, t);
393
- if (w(t)) return this.drawAnnotation(e, t);
394
- let n = m(h("rect"), {
489
+ if (E(t)) return this.drawTeam(e, t);
490
+ if (D(t)) return this.drawInteraction(e, t);
491
+ if (O(t)) return this.drawFlow(e, t);
492
+ if (k(t)) return this.drawAnnotation(e, t);
493
+ let n = S(C("rect"), {
395
494
  width: t.width,
396
495
  height: t.height,
397
- fill: "#eee"
496
+ fill: j.linie
398
497
  });
399
- return p(e, n), n;
498
+ return x(e, n), n;
400
499
  }
401
500
  drawConnection(e, t) {
402
- let n = m(h("path"), {
403
- d: R(t.waypoints),
501
+ let n = S(C("path"), {
502
+ d: qe(t.waypoints),
404
503
  fill: "none",
405
- stroke: A,
504
+ stroke: Le,
406
505
  "stroke-width": 1.5,
407
506
  "stroke-dasharray": "4 4",
408
507
  "stroke-linecap": "round"
409
508
  });
410
- return p(e, n), n;
509
+ return x(e, n), n;
411
510
  }
412
511
  getShapePath(e) {
413
512
  let { x: t, y: n, width: r, height: i } = e;
414
513
  return `M${t},${n}l${r},0l0,${i}l${-r},0z`;
415
514
  }
416
515
  getConnectionPath(e) {
417
- return R(e.waypoints);
516
+ return qe(e.waypoints);
418
517
  }
419
518
  drawTeam(e, t) {
420
- let n = c[t.teamType] ?? c["stream-aligned"], r = Math.max(t.width, 1), i = Math.max(t.height, 1), a = n.strokeWidth, o = l(n.strokeStyle, a), s = this.teamOutline(n.shape, r, i, a, {
519
+ let n = p[t.teamType] ?? p["stream-aligned"], r = Math.max(t.width, 1), i = Math.max(t.height, 1), a = n.strokeWidth, o = h(n.strokeStyle, a), s = this.teamOutline(n.shape, r, i, a, {
421
520
  fill: t.fill ?? n.fill,
422
521
  stroke: t.stroke ?? n.stroke,
423
522
  "stroke-width": a,
424
523
  ...o ? { "stroke-dasharray": o } : {},
425
524
  "stroke-linejoin": "round"
426
525
  });
427
- return p(e, s), this.appendLabel(e, t.ttLabel ?? "", I(t)), s;
526
+ return x(e, s), this.appendLabel(e, t.ttLabel ?? "", H(t)), s;
428
527
  }
429
528
  teamOutline(e, t, n, r, i) {
430
529
  let a = r / 2, o = t - r, s = n - r;
431
530
  if (e === "octagon") {
432
531
  let e = Math.min(o, s) * .29;
433
- return m(h("polygon"), {
434
- points: we(a, o, s, e),
532
+ return S(C("polygon"), {
533
+ points: Ke(a, o, s, e),
435
534
  ...i
436
535
  });
437
536
  }
438
537
  let c = e === "rect" ? 4 : Math.min(20, s / 2, o / 2);
439
- return m(h("rect"), {
538
+ return S(C("rect"), {
440
539
  x: a,
441
540
  y: a,
442
541
  width: o,
@@ -447,15 +546,15 @@ var L = class extends f {
447
546
  });
448
547
  }
449
548
  drawInteraction(e, t) {
450
- let n = s[t.mode] ?? s.collaboration, r = Math.max(t.width, 1), i = Math.max(t.height, 1), a = {
549
+ let n = d[t.mode] ?? d.collaboration, r = Math.max(t.width, 1), i = Math.max(t.height, 1), a = {
451
550
  fill: t.fill ?? n.fill,
452
551
  "fill-opacity": n.opacity,
453
552
  stroke: t.stroke ?? n.stroke,
454
553
  "stroke-width": 2,
455
- "stroke-dasharray": l(n.strokeStyle, 2) || "6 4",
554
+ "stroke-dasharray": h(n.strokeStyle, 2) || "6 4",
456
555
  "stroke-linejoin": "round"
457
556
  }, o;
458
- if (n.shape === "circle") o = m(h("ellipse"), {
557
+ if (n.shape === "circle") o = S(C("ellipse"), {
459
558
  cx: r / 2,
460
559
  cy: i / 2,
461
560
  rx: (r - 2) / 2,
@@ -464,56 +563,56 @@ var L = class extends f {
464
563
  });
465
564
  else if (n.shape === "triangle") {
466
565
  let e = `${r / 2},1 ${r - 1},${i - 1} 1,${i - 1}`;
467
- o = m(h("polygon"), {
566
+ o = S(C("polygon"), {
468
567
  points: e,
469
568
  ...a
470
569
  });
471
570
  } else {
472
571
  let e = Math.min(r * .26, i * .85), t = `${1 + e},1 ${r - 1},1 ${r - 1 - e},${i - 1} 1,${i - 1}`;
473
- o = m(h("polygon"), {
572
+ o = S(C("polygon"), {
474
573
  points: t,
475
574
  ...a
476
575
  });
477
576
  }
478
- return p(e, o), this.appendLabel(e, t.ttLabel ?? "", I(t)), o;
577
+ return x(e, o), this.appendLabel(e, t.ttLabel ?? "", H(t)), o;
479
578
  }
480
579
  drawFlow(e, t) {
481
- let n = Math.max(t.width, 1), r = Math.max(t.height, 1), i = o.strokeWidth, a = i / 2, s = F(n, r), c = r * .5, u = (r - c) / 2, d = u + c, f = [
482
- [a, u],
483
- [n - s, u],
484
- [n - s, a],
580
+ let n = Math.max(t.width, 1), r = Math.max(t.height, 1), i = l.strokeWidth, a = i / 2, o = Ue(n, r), s = r * .5, c = (r - s) / 2, u = c + s, d = [
581
+ [a, c],
582
+ [n - o, c],
583
+ [n - o, a],
485
584
  [n - a, r / 2],
486
- [n - s, r - a],
487
- [n - s, d],
488
- [a, d]
489
- ].map((e) => e.join(",")).join(" "), g = m(h("polygon"), {
490
- points: f,
585
+ [n - o, r - a],
586
+ [n - o, u],
587
+ [a, u]
588
+ ].map((e) => e.join(",")).join(" "), f = S(C("polygon"), {
589
+ points: d,
491
590
  fill: "none",
492
- stroke: o.stroke,
591
+ stroke: l.stroke,
493
592
  "stroke-width": i,
494
- "stroke-dasharray": l(o.strokeStyle, i) || "6 4",
593
+ "stroke-dasharray": h(l.strokeStyle, i) || "6 4",
495
594
  "stroke-linejoin": "round"
496
595
  });
497
- return p(e, g), this.appendLabel(e, t.ttLabel ?? "", I(t)), g;
596
+ return x(e, f), this.appendLabel(e, t.ttLabel ?? "", H(t)), f;
498
597
  }
499
598
  drawAnnotation(e, t) {
500
- let n = Math.max(t.width, 1), r = Math.max(t.height, 1), i = 1.5, a = i / 2, o = Math.min(14, n / 2), s = m(h("path"), {
599
+ let n = Math.max(t.width, 1), r = Math.max(t.height, 1), i = 1.5, a = i / 2, o = Math.min(14, n / 2), s = S(C("path"), {
501
600
  d: `M${o},${a} L${a},${a} L${a},${r - a} L${o},${r - a}`,
502
601
  fill: "none",
503
- stroke: A,
602
+ stroke: Le,
504
603
  "stroke-width": i,
505
604
  "stroke-linejoin": "round"
506
605
  });
507
- return p(e, s), this.appendLabel(e, t.ttLabel ?? "", I(t)), s;
606
+ return x(e, s), this.appendLabel(e, t.ttLabel ?? "", H(t)), s;
508
607
  }
509
608
  appendLabel(e, t, n) {
510
- let { box: r, fontSize: i } = n, a = Ce(t, r.width, i), o = i * P, s = n.align === "center", c = s ? r.x + r.width / 2 : r.x, l = s ? r.y + r.height / 2 - (a.length - 1) * o / 2 : r.y + o / 2;
609
+ let { box: r, fontSize: i } = n, a = We(t, r.width, i), o = i * R, s = n.align === "center", c = s ? r.x + r.width / 2 : r.x, l = s ? r.y + r.height / 2 - (a.length - 1) * o / 2 : r.y + o / 2;
511
610
  a.forEach((t, r) => {
512
611
  if (!t) return;
513
- let a = m(h("text"), {
612
+ let a = S(C("text"), {
514
613
  x: c,
515
614
  y: l + r * o,
516
- "font-family": j.family,
615
+ "font-family": I.family,
517
616
  "font-size": i,
518
617
  fill: n.fill,
519
618
  "text-anchor": s ? "middle" : "start",
@@ -521,11 +620,11 @@ var L = class extends f {
521
620
  "font-weight": n.fontWeight,
522
621
  ...n.letterSpacing ? { "letter-spacing": n.letterSpacing } : {}
523
622
  });
524
- a.textContent = t, p(e, a);
623
+ a.textContent = t, x(e, a);
525
624
  });
526
625
  }
527
626
  };
528
- function we(e, t, n, r) {
627
+ function Ke(e, t, n, r) {
529
628
  return [
530
629
  [e + r, e],
531
630
  [e + t - r, e],
@@ -537,16 +636,16 @@ function we(e, t, n, r) {
537
636
  [e, e + r]
538
637
  ].map((e) => e.join(",")).join(" ");
539
638
  }
540
- function R(e) {
639
+ function qe(e) {
541
640
  return e.map((e, t) => `${t === 0 ? "M" : "L"}${e.x},${e.y}`).join(" ");
542
641
  }
543
642
  //#endregion
544
643
  //#region src/draw/index.ts
545
- var z = {
644
+ var Je = {
546
645
  __init__: ["ttRenderer"],
547
- ttRenderer: ["type", L],
548
- connectionDocking: ["type", d]
549
- }, B = class {
646
+ ttRenderer: ["type", Ge],
647
+ connectionDocking: ["type", ne]
648
+ }, Ye = class {
550
649
  canvas;
551
650
  elementFactory;
552
651
  factory;
@@ -574,7 +673,12 @@ var z = {
574
673
  n = void 0;
575
674
  }
576
675
  let r;
577
- n && n.id === "tt-root" ? r = n : (r = this.elementFactory.createRoot({ id: O }), this.canvas.setRootElement(r)), r.businessObject = { title: e.title };
676
+ n && n.id === N ? r = n : (r = this.elementFactory.createRoot({ id: N }), this.canvas.setRootElement(r));
677
+ let i = _(e, o);
678
+ r.businessObject = {
679
+ title: e.title,
680
+ ...i ? { foreign: i } : {}
681
+ };
578
682
  for (let t of e.flows) this.canvas.addShape(this.factory.createFlow(t), r);
579
683
  for (let t of e.nodes) this.canvas.addShape(this.factory.createTeam(t), r);
580
684
  for (let t of e.interactions) this.canvas.addShape(this.factory.createInteraction(t), r);
@@ -582,7 +686,7 @@ var z = {
582
686
  for (let n of e.annotations) {
583
687
  if (!n.attachedTo) continue;
584
688
  let e = this.elementRegistry.get(n.id), i = this.elementRegistry.get(n.attachedTo);
585
- if (!b(i) || w(i)) {
689
+ if (!T(i) || k(i)) {
586
690
  t.push({
587
691
  message: `Annotation "${n.id}" is attached to unknown element "${n.attachedTo}"; its connector was dropped.`,
588
692
  elementId: n.id
@@ -595,13 +699,13 @@ var z = {
595
699
  return this.eventBus.fire("import.render.done", { warnings: t }), t;
596
700
  }
597
701
  clear() {
598
- let e = this.elementRegistry.getAll().filter((e) => e.id !== O), t = e.filter((e) => "waypoints" in e), n = e.filter((e) => !("waypoints" in e));
702
+ let e = this.elementRegistry.getAll().filter((e) => !!e.parent), t = e.filter((e) => "waypoints" in e), n = e.filter((e) => !("waypoints" in e));
599
703
  for (let e of t) this.canvas.removeConnection(e.id);
600
704
  for (let e of n) try {
601
705
  this.canvas.removeShape(e.id);
602
706
  } catch {}
603
707
  }
604
- }, V = class {
708
+ }, Xe = class {
605
709
  elementRegistry;
606
710
  canvas;
607
711
  static $inject = ["elementRegistry", "canvas"];
@@ -615,106 +719,183 @@ var z = {
615
719
  } catch {
616
720
  e = void 0;
617
721
  }
618
- let t = [], n = [], r = [], i = [];
722
+ let t = [], n = [], i = [], a = [];
619
723
  for (let e of this.elementRegistry.getAll()) {
620
- if (e.id === "tt-root") continue;
621
- let a = e, o = {
622
- x: a.x,
623
- y: a.y
624
- }, s = {
625
- width: a.width,
626
- height: a.height
724
+ if (e.id === N) continue;
725
+ let o = e, s = {
726
+ x: o.x,
727
+ y: o.y
728
+ }, l = {
729
+ width: o.width,
730
+ height: o.height
627
731
  };
628
- if (x(e)) t.push({
732
+ if (E(e)) t.push(y({
629
733
  id: e.id,
630
734
  type: e.teamType,
631
735
  label: e.ttLabel ?? "",
632
- position: o,
633
- size: s,
736
+ position: s,
737
+ size: l,
634
738
  ...e.description ? { description: e.description } : {},
635
739
  ...e.fill ? { fill: e.fill } : {},
636
740
  ...e.stroke ? { stroke: e.stroke } : {}
637
- });
638
- else if (S(e)) n.push({
741
+ }, e.ttForeign, f));
742
+ else if (D(e)) n.push(y({
639
743
  id: e.id,
640
744
  mode: e.mode,
641
- position: o,
642
- size: s,
745
+ position: s,
746
+ size: l,
643
747
  ...e.ttLabel ? { label: e.ttLabel } : {},
644
748
  ...e.fill ? { fill: e.fill } : {},
645
749
  ...e.stroke ? { stroke: e.stroke } : {}
646
- });
647
- else if (C(e)) r.push({
750
+ }, e.ttForeign, u));
751
+ else if (O(e)) i.push(y({
648
752
  id: e.id,
649
- position: o,
650
- size: s,
753
+ position: s,
754
+ size: l,
651
755
  ...e.ttLabel ? { label: e.ttLabel } : {}
652
- });
653
- else if (w(e)) {
654
- let t = Te(e);
655
- i.push({
756
+ }, e.ttForeign, c));
757
+ else if (k(e)) {
758
+ let t = Ze(e);
759
+ a.push(y({
656
760
  id: e.id,
657
761
  text: e.ttLabel ?? "",
658
- position: o,
659
- size: s,
762
+ position: s,
763
+ size: l,
660
764
  ...t ? { attachedTo: t } : {}
661
- });
765
+ }, e.ttForeign, r));
662
766
  }
663
767
  }
664
- return {
665
- version: a,
768
+ return y({
769
+ version: s,
666
770
  title: e?.title ?? "Untitled team topology",
667
771
  nodes: t,
668
772
  interactions: n,
669
- flows: r,
670
- annotations: i
671
- };
773
+ flows: i,
774
+ annotations: a
775
+ }, e?.foreign, o);
672
776
  }
673
777
  };
674
- function Te(e) {
675
- let t = [...e.outgoing, ...e.incoming].find(T);
778
+ function Ze(e) {
779
+ let t = [...e.outgoing, ...e.incoming].find(A);
676
780
  if (t) return (t.source === e ? t.target : t.source)?.id;
677
781
  }
678
782
  //#endregion
783
+ //#region src/io/TtViewport.ts
784
+ var Qe = 760, $e = 88, et = 120, U = 56, tt = 24, nt = 1, rt = class {
785
+ canvas;
786
+ elementRegistry;
787
+ static $inject = ["canvas", "elementRegistry"];
788
+ constructor(e, t) {
789
+ this.canvas = e, this.elementRegistry = t;
790
+ }
791
+ fit() {
792
+ let e = this.contentBounds();
793
+ if (!e) return;
794
+ let t = this.canvas.getContainer().getBoundingClientRect(), n = t.width, r = t.height;
795
+ if (!n || !r) {
796
+ this.canvas.zoom("fit-viewport");
797
+ return;
798
+ }
799
+ let i = n <= Qe, a = i ? et : $e, o = i ? tt : U, s = Math.max(e.maxX - e.minX, 1), c = Math.max(e.maxY - e.minY, 1), l = Math.min((n - 2 * o) / s, (r - a - U) / c, nt);
800
+ l > 0 ? this.canvas.viewbox({
801
+ x: e.minX + s / 2 - n / 2 / l,
802
+ y: this.viewboxTop(e, c, l, r, a, i),
803
+ width: n / l,
804
+ height: r / l
805
+ }) : this.canvas.zoom("fit-viewport");
806
+ }
807
+ viewboxTop(e, t, n, r, i, a) {
808
+ if (!a) return e.minY - i / n;
809
+ let o = r - i - U, s = Math.max(0, o - t * n);
810
+ return e.minY - (i + s / 2) / n;
811
+ }
812
+ contentBounds() {
813
+ let e = Infinity, t = Infinity, n = -Infinity, r = -Infinity;
814
+ for (let i of this.elementRegistry.getAll()) {
815
+ let a = i;
816
+ typeof a.x == "number" && typeof a.y == "number" && typeof a.width == "number" && typeof a.height == "number" && (e = Math.min(e, a.x), t = Math.min(t, a.y), n = Math.max(n, a.x + a.width), r = Math.max(r, a.y + a.height));
817
+ }
818
+ return Number.isFinite(e) ? {
819
+ minX: e,
820
+ minY: t,
821
+ maxX: n,
822
+ maxY: r
823
+ } : void 0;
824
+ }
825
+ }, W = "http://www.w3.org/2000/svg", G = {
826
+ latin: "U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD",
827
+ latinExt: "U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF"
828
+ };
829
+ function it(e) {
830
+ return Object.keys(G).map((t) => `@font-face{font-family:'Geist Variable';font-style:normal;font-weight:100 900;font-display:block;src:url(${e[t].replace(/^data:[^;,]*/, "data:font/woff2")}) format('woff2');unicode-range:${G[t]};}`).join("");
831
+ }
832
+ function at(e, t) {
833
+ let n = new DOMParser().parseFromString(e, "image/svg+xml"), r = n.documentElement;
834
+ if (r.namespaceURI !== W || n.querySelector("parsererror")) return e;
835
+ let i = n.createElementNS(W, "defs"), a = n.createElementNS(W, "style");
836
+ return a.textContent = t, i.appendChild(a), r.insertBefore(i, r.firstChild), new XMLSerializer().serializeToString(n);
837
+ }
838
+ //#endregion
679
839
  //#region src/io/index.ts
680
- var H = {
681
- ttImporter: ["type", B],
682
- ttExporter: ["type", V]
683
- }, U = class extends ve {
840
+ var ot = {
841
+ ttImporter: ["type", Ye],
842
+ ttExporter: ["type", Xe],
843
+ ttViewport: ["type", rt]
844
+ }, st = class extends Me {
684
845
  _getModules() {
685
846
  return [
686
- be,
687
- z,
688
- H
847
+ Pe,
848
+ Je,
849
+ ot
689
850
  ];
690
851
  }
691
- }, W = class extends U {
852
+ }, K = class extends st {
692
853
  _getModules() {
693
854
  return [
694
855
  ...super._getModules(),
695
- g,
696
- ee,
697
- te
856
+ ie,
857
+ ae,
858
+ oe
698
859
  ];
699
860
  }
700
861
  };
701
862
  //#endregion
702
863
  //#region src/modeling/cmd/UpdatePropertiesHandler.ts
703
- function G(e, t, n) {
864
+ function ct(e, t, n) {
704
865
  n === void 0 ? delete e[t] : e[t] = n;
705
866
  }
706
- var Ee = class {
867
+ var lt = class {
707
868
  execute(e) {
708
869
  let { element: t, properties: n } = e, r = t, i = {};
709
- for (let e of Object.keys(n)) i[e] = r[e], G(r, e, n[e]);
870
+ for (let e of Object.keys(n)) i[e] = r[e], ct(r, e, n[e]);
710
871
  return e.oldProperties = i, [t];
711
872
  }
712
873
  revert(e) {
713
874
  let { element: t, oldProperties: n } = e, r = t;
714
- if (n) for (let e of Object.keys(n)) G(r, e, n[e]);
875
+ if (n) for (let e of Object.keys(n)) ct(r, e, n[e]);
715
876
  return [t];
716
877
  }
717
- }, K = "element.updateProperties", q = 40, J = class {
878
+ }, q = "Untitled team topology", ut = class {
879
+ canvas;
880
+ static $inject = ["canvas"];
881
+ constructor(e) {
882
+ this.canvas = e;
883
+ }
884
+ execute(e) {
885
+ let t = this.canvas.getRootElement(), n = t.businessObject ?? { title: q };
886
+ return e.oldTitle = n.title, t.businessObject = {
887
+ ...n,
888
+ title: e.title
889
+ }, [t];
890
+ }
891
+ revert(e) {
892
+ let t = this.canvas.getRootElement();
893
+ return t.businessObject = {
894
+ ...t.businessObject ?? { title: q },
895
+ title: e.oldTitle ?? q
896
+ }, [t];
897
+ }
898
+ }, dt = "element.updateProperties", ft = "tt.title.update", pt = 40, mt = class {
718
899
  commandStack;
719
900
  modeling;
720
901
  factory;
@@ -726,10 +907,13 @@ var Ee = class {
726
907
  "canvas"
727
908
  ];
728
909
  constructor(e, t, n, r) {
729
- this.commandStack = e, this.modeling = t, this.factory = n, this.canvas = r, e.registerHandler(K, Ee);
910
+ this.commandStack = e, this.modeling = t, this.factory = n, this.canvas = r, e.registerHandler(dt, lt), e.registerHandler(ft, ut);
911
+ }
912
+ setTitle(e) {
913
+ this.commandStack.execute(ft, { title: e });
730
914
  }
731
915
  updateProperties(e, t) {
732
- this.commandStack.execute(K, {
916
+ this.commandStack.execute(dt, {
733
917
  element: e,
734
918
  properties: t
735
919
  });
@@ -754,8 +938,8 @@ var Ee = class {
754
938
  }
755
939
  appendAnnotation(e) {
756
940
  let t = this.factory.createNewAnnotation(), n = {
757
- x: e.x + e.width + q + t.width / 2,
758
- y: e.y - q / 4
941
+ x: e.x + e.width + pt + t.width / 2,
942
+ y: e.y - pt / 4
759
943
  };
760
944
  return this.modeling.appendShape(e, t, n, this.canvas.getRootElement(), {
761
945
  connection: this.factory.createNewAssociation(),
@@ -763,45 +947,45 @@ var Ee = class {
763
947
  });
764
948
  }
765
949
  detachAnnotation(e) {
766
- let t = [...e.incoming, ...e.outgoing].filter(T);
950
+ let t = [...e.incoming, ...e.outgoing].filter(A);
767
951
  t.length > 0 && this.modeling.removeElements(t);
768
952
  }
769
- }, Y = class extends ae {
770
- layoutConnection(e, n = {}) {
771
- let r = n.source ?? e.source, i = n.target ?? e.target;
772
- return !r || !i ? super.layoutConnection(e, n) : [t(r), t(i)];
953
+ }, ht = class extends fe {
954
+ layoutConnection(e, t = {}) {
955
+ let n = t.source ?? e.source, r = t.target ?? e.target;
956
+ return !n || !r ? super.layoutConnection(e, t) : [b(n), b(r)];
773
957
  }
774
- }, De = {
775
- __depends__: [v],
958
+ }, gt = {
959
+ __depends__: [ce],
776
960
  __init__: ["ttModeling"],
777
- ttModeling: ["type", J],
778
- layouter: ["type", Y]
961
+ ttModeling: ["type", mt],
962
+ layouter: ["type", ht]
779
963
  };
780
964
  //#endregion
781
965
  //#region src/rules/TtRules.ts
782
- function Oe(e) {
783
- return b(e) && !w(e);
966
+ function _t(e) {
967
+ return T(e) && !k(e);
784
968
  }
785
- var ke = class extends se {
969
+ var vt = class extends me {
786
970
  static $inject = ["eventBus"];
787
971
  constructor(e) {
788
972
  super(e);
789
973
  }
790
974
  init() {
791
- this.addRule(["shape.move", "elements.move"], (e) => e.target && e.target.parent ? null : !0), this.addRule("shape.create", () => !0), this.addRule("shape.resize", () => !0), this.addRule("element.copy", () => !0), this.addRule("connection.create", ({ source: e, target: t }) => w(e) && Oe(t) || w(t) && Oe(e) ? { ttKind: "association" } : !1);
975
+ this.addRule(["shape.move", "elements.move"], (e) => e.target && e.target.parent ? null : !0), this.addRule("shape.create", () => !0), this.addRule("shape.resize", () => !0), this.addRule("element.copy", () => !0), this.addRule("connection.create", ({ source: e, target: t }) => k(e) && _t(t) || k(t) && _t(e) ? { ttKind: "association" } : !1);
792
976
  }
793
- }, Ae = {
794
- __depends__: [oe],
977
+ }, yt = {
978
+ __depends__: [pe],
795
979
  __init__: ["ttRules"],
796
- ttRules: ["type", ke]
797
- }, je = class extends ce {
980
+ ttRules: ["type", vt]
981
+ }, bt = class extends he {
798
982
  static $inject = ["eventBus", "canvas"];
799
983
  constructor(e, t) {
800
984
  super(e), this.preExecute(["shape.create", "elements.create"], (e) => {
801
985
  e.parent = t.getRootElement();
802
986
  }, !0);
803
987
  }
804
- }, Me = class extends ce {
988
+ }, xt = class extends he {
805
989
  static $inject = [
806
990
  "eventBus",
807
991
  "connectionDocking",
@@ -809,171 +993,307 @@ var ke = class extends se {
809
993
  ];
810
994
  constructor(e, t, n) {
811
995
  super(e), this.executed(["connection.layout", "connection.create"], (e) => {
812
- !e.cropped && T(e.connection) && (e.connection.waypoints = t.getCroppedWaypoints(e.connection), e.cropped = !0);
996
+ !e.cropped && A(e.connection) && (e.connection.waypoints = t.getCroppedWaypoints(e.connection), e.cropped = !0);
813
997
  }, !0), this.reverted("connection.layout", (e) => {
814
998
  delete e.cropped;
815
999
  }, !0), this.postExecuted("connection.create", (e) => {
816
1000
  let t = e.connection;
817
- if (!T(t)) return;
818
- let r = w(t.source) ? t.source : t.target;
819
- if (!w(r)) return;
820
- let i = [...r.incoming, ...r.outgoing].filter((e) => e !== t && T(e));
1001
+ if (!A(t)) return;
1002
+ let r = k(t.source) ? t.source : t.target;
1003
+ if (!k(r)) return;
1004
+ let i = [...r.incoming, ...r.outgoing].filter((e) => e !== t && A(e));
821
1005
  i.length > 0 && n.removeElements(i);
822
1006
  }, !0);
823
1007
  }
824
- }, Ne = {
1008
+ }, St = {
825
1009
  __init__: ["ttFlatModelBehavior", "ttAssociationBehavior"],
826
- ttFlatModelBehavior: ["type", je],
827
- ttAssociationBehavior: ["type", Me]
828
- };
1010
+ ttFlatModelBehavior: ["type", bt],
1011
+ ttAssociationBehavior: ["type", xt]
1012
+ }, Ct = [["path", { d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" }], ["path", { d: "m15 5 4 4" }]], wt = [
1013
+ ["path", { d: "M10 11v6" }],
1014
+ ["path", { d: "M14 11v6" }],
1015
+ ["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" }],
1016
+ ["path", { d: "M3 6h18" }],
1017
+ ["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }]
1018
+ ], Tt = [["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }], ["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" }]], Et = [
1019
+ ["path", { d: "M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z" }],
1020
+ ["path", { d: "M12 8v6" }],
1021
+ ["path", { d: "M9 11h6" }]
1022
+ ], Dt = [
1023
+ ["path", { d: "M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z" }],
1024
+ ["path", { d: "M5 3a2 2 0 0 0-2 2" }],
1025
+ ["path", { d: "M19 3a2 2 0 0 1 2 2" }],
1026
+ ["path", { d: "M5 21a2 2 0 0 1-2-2" }],
1027
+ ["path", { d: "M9 3h1" }],
1028
+ ["path", { d: "M9 21h2" }],
1029
+ ["path", { d: "M14 3h1" }],
1030
+ ["path", { d: "M3 9v1" }],
1031
+ ["path", { d: "M21 9v2" }],
1032
+ ["path", { d: "M3 14v1" }]
1033
+ ], Ot = [
1034
+ ["path", { d: "M4 5h16" }],
1035
+ ["path", { d: "M4 12h16" }],
1036
+ ["path", { d: "M4 19h16" }]
1037
+ ], kt = [["path", { d: "M5 12h14" }]], At = [["path", { d: "M5 12h14" }], ["path", { d: "M12 5v14" }]], jt = [
1038
+ ["path", { d: "M8 3H5a2 2 0 0 0-2 2v3" }],
1039
+ ["path", { d: "M21 8V5a2 2 0 0 0-2-2h-3" }],
1040
+ ["path", { d: "M3 16v3a2 2 0 0 0 2 2h3" }],
1041
+ ["path", { d: "M16 21h3a2 2 0 0 0 2-2v-3" }]
1042
+ ], Mt = [
1043
+ ["path", { d: "M12 15V3" }],
1044
+ ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }],
1045
+ ["path", { d: "m7 10 5 5 5-5" }]
1046
+ ], Nt = [["path", { d: "M18 6 6 18" }], ["path", { d: "m6 6 12 12" }]], Pt = 2.5, Ft = 16, It = [
1047
+ "path",
1048
+ "circle",
1049
+ "ellipse",
1050
+ "line",
1051
+ "polyline",
1052
+ "polygon",
1053
+ "rect"
1054
+ ], Lt = [
1055
+ "d",
1056
+ "cx",
1057
+ "cy",
1058
+ "r",
1059
+ "rx",
1060
+ "ry",
1061
+ "x",
1062
+ "y",
1063
+ "x1",
1064
+ "y1",
1065
+ "x2",
1066
+ "y2",
1067
+ "width",
1068
+ "height",
1069
+ "points"
1070
+ ];
1071
+ function Rt(e) {
1072
+ return e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/'/g, "&#39;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1073
+ }
1074
+ function zt(e, t) {
1075
+ let n = Number(e);
1076
+ return Number.isFinite(n) && n > 0 ? n : t;
1077
+ }
1078
+ function J(e, t = {}) {
1079
+ let n = zt(t.size, Ft), r = zt(t.strokeWidth, Pt);
1080
+ return `<svg${t.className ? ` class="${Rt(t.className)}"` : ""} xmlns="http://www.w3.org/2000/svg" width="${n}" height="${n}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${r}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">${e.map(([e, t]) => {
1081
+ let n = It.find((t) => t === e);
1082
+ return n ? `<${n} ${Object.entries(t).flatMap(([e, t]) => {
1083
+ let n = Lt.find((t) => t === e);
1084
+ return n ? [`${n}="${Rt(String(t))}"`] : [];
1085
+ }).join(" ")}/>` : "";
1086
+ }).join("")}</svg>`;
1087
+ }
829
1088
  //#endregion
830
1089
  //#region src/draw/palette-icons.ts
831
- function X(e) {
1090
+ var Bt = {
1091
+ size: 20,
1092
+ strokeWidth: 2
1093
+ };
1094
+ function Y(e) {
832
1095
  return `<svg class="tt-palette-svg" width="24" height="24" viewBox="0 0 26 26" aria-hidden="true">${e}</svg>`;
833
1096
  }
834
- function Pe(e) {
835
- let t = c[e], n = l(t.strokeStyle, 1.5), r = `fill="${t.fill}" stroke="${t.stroke}" stroke-width="1.5"` + (n ? ` stroke-dasharray="${n}"` : "");
1097
+ function Vt(e) {
1098
+ let t = p[e], n = h(t.strokeStyle, 1.5), r = `fill="${t.fill}" stroke="${t.stroke}" stroke-width="1.5"` + (n ? ` stroke-dasharray="${n}"` : "");
836
1099
  switch (t.shape) {
837
- case "octagon": return X(`<polygon points="8,3 18,3 23,8 23,18 18,23 8,23 3,18 3,8" ${r}/>`);
838
- case "rounded-rect-vertical": return X(`<rect x="8" y="3" width="10" height="20" rx="4" ${r}/>`);
839
- case "rect": return X(`<rect x="3" y="7" width="20" height="12" rx="1.5" ${r}/>`);
840
- default: return X(`<rect x="3" y="8" width="20" height="10" rx="5" ${r}/>`);
1100
+ case "octagon": return Y(`<polygon points="8,3 18,3 23,8 23,18 18,23 8,23 3,18 3,8" ${r}/>`);
1101
+ case "rounded-rect-vertical": return Y(`<rect x="8" y="3" width="10" height="20" rx="4" ${r}/>`);
1102
+ case "rect": return Y(`<rect x="3" y="7" width="20" height="12" rx="1.5" ${r}/>`);
1103
+ default: return Y(`<rect x="3" y="8" width="20" height="10" rx="5" ${r}/>`);
841
1104
  }
842
1105
  }
843
- function Fe() {
844
- return X("<g fill=\"none\" stroke=\"#6b6459\" stroke-width=\"1.5\" stroke-linejoin=\"round\" stroke-dasharray=\"3 2\"><polygon points=\"3,9 16,9 16,5 23,13 16,21 16,17 3,17\"/></g>");
1106
+ function Ht() {
1107
+ let e = h(l.strokeStyle, 1.5);
1108
+ return Y(`<g fill="none" stroke="${l.stroke}" stroke-width="1.5" stroke-linejoin="round"` + (e ? ` stroke-dasharray="${e}"` : "") + "><polygon points=\"3,9 16,9 16,5 23,13 16,21 16,17 3,17\"/></g>");
845
1109
  }
846
- function Ie() {
847
- return X(`<g fill="none" stroke="${A}" stroke-width="1.5" stroke-linecap="round"><path d="M10 4H5v18h5"/><path d="M13 9h9M13 13h9M13 17h6"/></g>`);
1110
+ function Ut() {
1111
+ return Y("<g fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\"><path d=\"M10 4H5v18h5\"/><path d=\"M13 9h9M13 13h9M13 17h6\"/></g>");
848
1112
  }
849
- function Le() {
850
- return X("<rect x=\"3\" y=\"3\" width=\"16\" height=\"13\" rx=\"1.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-dasharray=\"3 2\"/><path d=\"M14 12l9 3.6-3.8 1.4-1.4 3.8z\" fill=\"currentColor\"/>");
1113
+ function Wt() {
1114
+ return J(Dt, {
1115
+ ...Bt,
1116
+ className: "tt-palette-svg"
1117
+ });
851
1118
  }
852
- function Re(e) {
853
- let t = s[e], n = l(t.strokeStyle, 1.5), r = `fill="${t.fill}" fill-opacity="${t.opacity}" stroke="${t.stroke}" stroke-width="1.5"` + (n ? ` stroke-dasharray="${n}"` : "");
1119
+ function Gt(e) {
1120
+ let t = d[e], n = h(t.strokeStyle, 1.5), r = `fill="${t.fill}" fill-opacity="${t.opacity}" stroke="${t.stroke}" stroke-width="1.5"` + (n ? ` stroke-dasharray="${n}"` : "");
854
1121
  switch (t.shape) {
855
- case "circle": return X(`<circle cx="13" cy="13" r="9" ${r}/>`);
856
- case "triangle": return X(`<polygon points="5,6 22,13 5,20" ${r}/>`);
857
- default: return X(`<polygon points="9,6 23,6 17,20 3,20" ${r}/>`);
1122
+ case "circle": return Y(`<circle cx="13" cy="13" r="9" ${r}/>`);
1123
+ case "triangle": return Y(`<polygon points="5,6 22,13 5,20" ${r}/>`);
1124
+ default: return Y(`<polygon points="9,6 23,6 17,20 3,20" ${r}/>`);
858
1125
  }
859
1126
  }
860
1127
  //#endregion
861
1128
  //#region src/palette/TtPaletteProvider.ts
862
- var ze = "tools", Be = "tt-1-teams", Ve = "tt-2-modes", He = "tt-3-guides";
863
- function Z(e, t, n = !0) {
864
- return `<div class="entry tt-palette-entry" draggable="${n}" title="${t}">${e}</div>`;
1129
+ var Kt = "tools", qt = "tt-1-teams", Jt = "tt-2-modes", Yt = "tt-3-guides", Xt = 24;
1130
+ function Zt(e, t = !0) {
1131
+ return `<div class="entry tt-palette-entry" draggable="${t}">${e}</div>`;
1132
+ }
1133
+ function Qt(e) {
1134
+ return e.type === "click" && e.detail === 0;
1135
+ }
1136
+ function $t(e) {
1137
+ return {
1138
+ x: e.x + e.width / 2,
1139
+ y: e.y + e.height / 2
1140
+ };
865
1141
  }
866
- var Ue = class {
1142
+ var en = class {
1143
+ config;
867
1144
  create;
868
1145
  factory;
869
1146
  lassoTool;
1147
+ canvas;
1148
+ modeling;
1149
+ selection;
1150
+ elementRegistry;
870
1151
  static $inject = [
1152
+ "config.ttPalette",
871
1153
  "palette",
872
1154
  "create",
873
1155
  "ttElementFactory",
874
- "lassoTool"
1156
+ "lassoTool",
1157
+ "canvas",
1158
+ "modeling",
1159
+ "selection",
1160
+ "elementRegistry",
1161
+ "injector"
875
1162
  ];
876
- constructor(e, t, n, r) {
877
- this.create = t, this.factory = n, this.lassoTool = r, e.registerProvider(this);
1163
+ readOnly;
1164
+ labelEditing;
1165
+ constructor(e, t, n, r, i, a, o, s, c, l) {
1166
+ this.config = e, this.create = n, this.factory = r, this.lassoTool = i, this.canvas = a, this.modeling = o, this.selection = s, this.elementRegistry = c, this.readOnly = l.get("ttReadOnly", !1), this.labelEditing = l.get("ttLabelEditing", !1), t.registerProvider(this);
878
1167
  }
879
1168
  getPaletteEntries() {
880
- let e = {}, t = "Select several elements (or Shift + drag on the canvas)";
1169
+ let e = {};
881
1170
  e["lasso-tool"] = {
882
- group: ze,
883
- title: t,
884
- html: Z(Le(), t, !1),
1171
+ group: Kt,
1172
+ title: "Select several elements",
1173
+ html: Zt(Wt(), !1),
885
1174
  action: { click: (e) => this.lassoTool.activateSelection(e) }
886
1175
  };
887
- for (let t of r) {
888
- let n = (e) => this.create.start(e, this.factory.createNewTeam(t.type, t.label));
889
- e[`team.${t.type}`] = {
890
- group: Be,
891
- title: `${t.label} team — ${t.description}`,
892
- html: Z(Pe(t.type), `${t.label} team — ${t.description}`),
893
- action: {
894
- dragstart: n,
895
- click: n
896
- }
897
- };
898
- }
899
- for (let t of n) {
900
- let n = (e) => this.create.start(e, this.factory.createNewInteraction(t.mode));
901
- e[`mode.${t.mode}`] = {
902
- group: Ve,
903
- title: `${t.label} — ${t.description} (place over the teams it relates to)`,
904
- html: Z(Re(t.mode), `${t.label} — ${t.description}`),
905
- action: {
906
- dragstart: n,
907
- click: n
908
- }
909
- };
910
- }
911
- let a = (e) => this.create.start(e, this.factory.createNewFlow());
912
- e.flow = {
913
- group: He,
914
- title: `${o.label} — the implied left-to-right flow`,
915
- html: Z(Fe(), o.label),
916
- action: {
917
- dragstart: a,
918
- click: a
919
- }
1176
+ for (let t of n) e[`team.${t.type}`] = this.createEntry(qt, `${t.label} team`, Vt(t.type), () => this.factory.createNewTeam(t.type, t.label));
1177
+ for (let n of t) e[`mode.${n.mode}`] = this.createEntry(Jt, `${n.label} interaction`, Gt(n.mode), () => this.factory.createNewInteraction(n.mode));
1178
+ return e.flow = this.createEntry(Yt, l.label, Ht(), () => this.factory.createNewFlow()), e.annotation = this.createEntry(Yt, i.label, Ut(), () => this.factory.createNewAnnotation()), e;
1179
+ }
1180
+ createEntry(e, t, n, r) {
1181
+ let i = (e) => {
1182
+ Qt(e) ? this.placeInFreeRect(r()) : this.create.start(e, r());
920
1183
  };
921
- let s = (e) => this.create.start(e, this.factory.createNewAnnotation()), c = `${i.label} — a free-text note beside the diagram`;
922
- return e.annotation = {
923
- group: He,
924
- title: c,
925
- html: Z(Ie(), c),
1184
+ return {
1185
+ group: e,
1186
+ title: t,
1187
+ html: Zt(n),
926
1188
  action: {
927
- dragstart: s,
928
- click: s
1189
+ dragstart: i,
1190
+ click: i
929
1191
  }
930
- }, e;
1192
+ };
931
1193
  }
932
- }, We = {
1194
+ freePlace() {
1195
+ let e = this.canvas.viewbox(), t = this.config?.freeRectCenter?.() ?? {
1196
+ x: e.x + e.width / 2,
1197
+ y: e.y + e.height / 2
1198
+ }, n = {
1199
+ x: Math.round(t.x),
1200
+ y: Math.round(t.y)
1201
+ }, r = () => this.elementRegistry.filter(T).some((e) => {
1202
+ let t = $t(e);
1203
+ return Math.abs(t.x - n.x) < 1 && Math.abs(t.y - n.y) < 1;
1204
+ });
1205
+ for (; r();) n.x += Xt, n.y += Xt;
1206
+ return n;
1207
+ }
1208
+ placeInFreeRect(e) {
1209
+ if (this.readOnly?.isReadOnly()) return;
1210
+ let t = this.modeling.createShape(e, this.freePlace(), this.canvas.getRootElement());
1211
+ this.selection.select(t), this.canvas.focus(), T(t) && this.labelEditing?.activate(t);
1212
+ }
1213
+ }, tn = {
933
1214
  __depends__: [
934
- le,
935
- ue,
936
- _
1215
+ ge,
1216
+ _e,
1217
+ se
937
1218
  ],
938
1219
  __init__: ["ttPaletteProvider"],
939
- ttPaletteProvider: ["type", Ue]
940
- }, Ge = "M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z", Ke = "M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z", qe = "M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z", Je = "M4 3h5v2H6v14h3v2H4V3zm7 4h9v2h-9V7zm0 4h9v2h-9v-2zm0 4h6v2h-6v-2z";
941
- function Ye(e, t = 18) {
942
- return `<svg width="${t}" height="${t}" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="${e}"/></svg>`;
1220
+ ttPaletteProvider: ["type", en]
1221
+ }, X = "tt.readOnly.changed", nn = 5e3, rn = [
1222
+ "elements.move",
1223
+ "shape.move",
1224
+ "shape.resize",
1225
+ "shape.create",
1226
+ "elements.create",
1227
+ "shape.append",
1228
+ "connection.start",
1229
+ "connection.create",
1230
+ "connection.reconnect",
1231
+ "connection.updateWaypoints",
1232
+ "elements.delete"
1233
+ ], an = class extends me {
1234
+ bus;
1235
+ static $inject = ["eventBus"];
1236
+ readOnly = !1;
1237
+ constructor(e) {
1238
+ super(e), this.bus = e;
1239
+ }
1240
+ init() {
1241
+ this.addRule(rn, nn, () => !this.readOnly && void 0);
1242
+ }
1243
+ isReadOnly() {
1244
+ return this.readOnly;
1245
+ }
1246
+ setReadOnly(e) {
1247
+ this.readOnly !== e && (this.readOnly = e, this.bus.fire(X, { readOnly: e }));
1248
+ }
1249
+ }, on = {
1250
+ __depends__: [pe],
1251
+ __init__: ["ttReadOnly"],
1252
+ ttReadOnly: ["type", an]
1253
+ }, sn = ".djs-context-pad .entry[data-action]";
1254
+ function Z(e, t, n = !0) {
1255
+ return `<div class="entry tt-cp-entry" role="button" tabindex="${n ? 0 : -1}" aria-label="${t}">${J(e)}</div>`;
943
1256
  }
944
- //#endregion
945
- //#region src/context-pad/TtContextPadProvider.ts
946
- function Q(e, t) {
947
- return `<div class="entry tt-cp-entry" title="${t}">${Ye(e)}</div>`;
1257
+ function cn(e) {
1258
+ return k(e) ? "Edit text" : D(e) || O(e) ? "Edit label" : "Rename";
948
1259
  }
949
- var Xe = class {
1260
+ var ln = class {
1261
+ contextPad;
950
1262
  modeling;
951
1263
  ttModeling;
952
1264
  labelEditing;
953
1265
  connect;
954
1266
  selection;
1267
+ canvas;
955
1268
  static $inject = [
956
1269
  "contextPad",
957
1270
  "modeling",
958
1271
  "ttModeling",
959
1272
  "ttLabelEditing",
960
1273
  "connect",
961
- "selection"
1274
+ "selection",
1275
+ "canvas",
1276
+ "eventBus",
1277
+ "injector"
962
1278
  ];
963
- constructor(e, t, n, r, i, a) {
964
- this.modeling = t, this.ttModeling = n, this.labelEditing = r, this.connect = i, this.selection = a, e.registerProvider(this);
1279
+ readOnly;
1280
+ constructor(e, t, n, r, i, a, o, s, c) {
1281
+ this.contextPad = e, this.modeling = t, this.ttModeling = n, this.labelEditing = r, this.connect = i, this.selection = a, this.canvas = o, this.readOnly = c.get("ttReadOnly", !1), e.registerProvider(this), s.on("contextPad.open.allowed", () => !this.readOnly?.isReadOnly() && void 0), s.on(X, (t) => {
1282
+ t.readOnly && e.close();
1283
+ }), o.getContainer().addEventListener("keydown", (e) => this.onEntryKeyDown(e));
965
1284
  }
966
1285
  getContextPadEntries(e) {
967
- if (T(e)) return { delete: this.deleteEntry([e], "Remove connector") };
968
- if (!b(e)) return {};
969
- if (w(e)) {
1286
+ if (this.readOnly?.isReadOnly()) return {};
1287
+ if (A(e)) return { delete: this.deleteEntry([e], "Delete connector") };
1288
+ if (!T(e)) return {};
1289
+ if (k(e)) {
970
1290
  let t = (t) => this.connect.start(t, e);
971
1291
  return {
972
- "edit-label": this.editEntry(e, "Edit text"),
1292
+ "edit-label": this.editEntry(e),
973
1293
  connect: {
974
1294
  group: "edit",
975
- title: "Attach to an element",
976
- html: Q(qe, "Attach to an element"),
1295
+ title: "Attach to element",
1296
+ html: Z(Tt, "Attach to element", !1),
977
1297
  action: {
978
1298
  click: t,
979
1299
  dragstart: t
@@ -982,106 +1302,165 @@ var Xe = class {
982
1302
  delete: this.deleteEntry([e], "Delete")
983
1303
  };
984
1304
  }
1305
+ let t = () => {
1306
+ let t = this.ttModeling.appendAnnotation(e);
1307
+ this.selection.select(t), this.labelEditing.activate(t);
1308
+ };
985
1309
  return {
986
- "edit-label": this.editEntry(e, "Rename"),
1310
+ "edit-label": this.editEntry(e),
987
1311
  "append-annotation": {
988
1312
  group: "edit",
989
1313
  title: "Add annotation",
990
- html: Q(Je, "Add annotation"),
991
- action: { click: () => {
992
- let t = this.ttModeling.appendAnnotation(e);
993
- this.selection.select(t), this.labelEditing.activate(t);
994
- } }
1314
+ html: Z(Et, "Add annotation"),
1315
+ action: {
1316
+ click: t,
1317
+ keyboard: t
1318
+ }
995
1319
  },
996
1320
  delete: this.deleteEntry([e], "Delete")
997
1321
  };
998
1322
  }
999
1323
  getMultiElementContextPadEntries(e) {
1000
- return { delete: this.deleteEntry(e, `Delete ${e.length} elements`) };
1324
+ return this.readOnly?.isReadOnly() ? {} : { delete: this.deleteEntry(e, `Delete ${e.length} elements`) };
1001
1325
  }
1002
- editEntry(e, t) {
1326
+ onEntryKeyDown(e) {
1327
+ if (e.key !== "Enter" && e.key !== " " || e.repeat) return;
1328
+ let t = (e.target?.closest?.(sn))?.getAttribute("data-action");
1329
+ t && (e.preventDefault(), e.stopPropagation(), this.contextPad.triggerEntry(t, "keyboard", e));
1330
+ }
1331
+ editEntry(e) {
1332
+ let t = cn(e), n = () => this.labelEditing.activate(e);
1003
1333
  return {
1004
1334
  group: "edit",
1005
1335
  title: t,
1006
- html: Q(Ge, t),
1007
- action: { click: () => this.labelEditing.activate(e) }
1336
+ html: Z(Ct, t),
1337
+ action: {
1338
+ click: n,
1339
+ keyboard: n
1340
+ }
1008
1341
  };
1009
1342
  }
1010
1343
  deleteEntry(e, t) {
1011
1344
  return {
1012
1345
  group: "edit",
1013
1346
  title: t,
1014
- html: Q(Ke, t),
1015
- action: { click: () => this.modeling.removeElements([...e]) }
1347
+ html: Z(wt, t),
1348
+ action: {
1349
+ click: () => this.modeling.removeElements([...e]),
1350
+ keyboard: () => {
1351
+ this.modeling.removeElements([...e]), this.canvas.focus();
1352
+ }
1353
+ }
1016
1354
  };
1017
1355
  }
1018
- }, Ze = {
1356
+ }, un = {
1019
1357
  __depends__: [
1020
- pe,
1021
- de,
1022
- fe
1358
+ be,
1359
+ ve,
1360
+ ye
1023
1361
  ],
1024
1362
  __init__: ["ttContextPadProvider"],
1025
- ttContextPadProvider: ["type", Xe]
1026
- }, $ = "tt-label-editing", Qe = 96, $e = class {
1363
+ ttContextPadProvider: ["type", ln]
1364
+ }, dn = "tt-label-editing", fn = 96;
1365
+ function pn(e) {
1366
+ return k(e) ? "Annotation text" : D(e) ? "Interaction label" : O(e) ? "Flow label" : "Team name";
1367
+ }
1368
+ var mn = class {
1027
1369
  canvas;
1028
1370
  modeling;
1371
+ elementRegistry;
1029
1372
  static $inject = [
1030
1373
  "eventBus",
1031
1374
  "canvas",
1032
- "ttModeling"
1375
+ "ttModeling",
1376
+ "elementRegistry",
1377
+ "injector"
1033
1378
  ];
1034
1379
  active = null;
1035
- constructor(e, t, n) {
1036
- this.canvas = t, this.modeling = n, e.on("element.dblclick", (e) => {
1037
- b(e.element) && this.activate(e.element);
1380
+ suspended = null;
1381
+ resumeTimer;
1382
+ readOnly;
1383
+ constructor(e, t, n, r, i) {
1384
+ this.canvas = t, this.modeling = n, this.elementRegistry = r, this.readOnly = i.get("ttReadOnly", !1), e.on("element.dblclick", (e) => {
1385
+ T(e.element) && this.activate(e.element);
1038
1386
  }), e.on([
1039
1387
  "element.mousedown",
1040
1388
  "drag.init",
1041
1389
  "canvas.viewbox.changing"
1042
- ], () => this.active?.commit()), e.on("import.render.start", () => this.cancel());
1043
- }
1044
- activate(e) {
1045
- this.active?.commit();
1046
- let t = I(e), n = t.align === "center", r = this.canvas.zoom(), i = this.canvas.viewbox(), a = n ? Math.max(t.box.width, Qe) : t.box.width, o = e.x + t.box.x + (t.box.width - a) / 2, s = (e.y + t.box.y - i.y) * r, c = t.box.height * r, l = document.createElement("textarea");
1047
- l.className = "tt-label-editor", l.value = e.ttLabel ?? "", l.rows = 1, l.setAttribute("aria-label", w(e) ? "Annotation text" : "Label"), Object.assign(l.style, {
1048
- left: `${(o - i.x) * r}px`,
1049
- width: `${a * r}px`,
1050
- fontFamily: j.family,
1051
- fontSize: `${t.fontSize * r}px`,
1052
- fontWeight: t.fontWeight,
1053
- letterSpacing: t.letterSpacing ?? "normal",
1054
- lineHeight: String(P),
1055
- color: t.fill,
1056
- textAlign: n ? "center" : "left"
1390
+ ], () => this.active?.commit()), e.on("import.render.start", () => this.cancel()), e.on(X, (e) => {
1391
+ e.readOnly && this.cancel();
1392
+ }), e.on("diagram.destroy", () => {
1393
+ clearTimeout(this.resumeTimer), this.suspended = null, this.cancel();
1394
+ });
1395
+ }
1396
+ suspend() {
1397
+ clearTimeout(this.resumeTimer), this.active && (this.suspended = this.active.snapshot(), this.active.cleanup());
1398
+ }
1399
+ resumeAfterImport() {
1400
+ clearTimeout(this.resumeTimer), this.suspended && (this.resumeTimer = setTimeout(() => {
1401
+ let e = this.suspended;
1402
+ if (this.suspended = null, !e || this.active) return;
1403
+ let t = this.elementRegistry.get(e.elementId);
1404
+ T(t) && this.activate(t, e);
1405
+ }, 0));
1406
+ }
1407
+ openEdit() {
1408
+ if (!this.active) return;
1409
+ let { elementId: e, value: t } = this.active.snapshot();
1410
+ return {
1411
+ elementId: e,
1412
+ value: t
1413
+ };
1414
+ }
1415
+ activate(e, t) {
1416
+ if (this.active?.commit(), this.readOnly?.isReadOnly()) return;
1417
+ let n = H(e), r = n.align === "center", i = this.canvas.zoom(), a = this.canvas.viewbox(), o = r ? Math.max(n.box.width, fn) : n.box.width, s = e.x + n.box.x + (n.box.width - o) / 2, c = (e.y + n.box.y - a.y) * i, l = n.box.height * i, u = document.createElement("textarea");
1418
+ u.className = "tt-label-editor", u.value = t ? t.value : e.ttLabel ?? "", u.rows = 1, u.setAttribute("aria-label", pn(e)), Object.assign(u.style, {
1419
+ left: `${(s - a.x) * i}px`,
1420
+ width: `${o * i}px`,
1421
+ fontFamily: I.family,
1422
+ fontSize: `${n.fontSize * i}px`,
1423
+ fontWeight: n.fontWeight,
1424
+ letterSpacing: n.letterSpacing ?? "normal",
1425
+ lineHeight: String(R),
1426
+ color: n.fill,
1427
+ textAlign: r ? "center" : "left"
1057
1428
  });
1058
- let u = () => {
1059
- l.style.height = "0px";
1060
- let e = l.scrollHeight;
1061
- l.style.height = `${n ? e : Math.max(e, c)}px`, l.style.top = `${n ? s + (c - e) / 2 : s}px`;
1429
+ let d = () => {
1430
+ u.style.height = "0px";
1431
+ let e = u.scrollHeight;
1432
+ u.style.height = `${r ? e : Math.max(e, l)}px`, u.style.top = `${r ? c + (l - e) / 2 : c}px`;
1062
1433
  };
1063
- this.canvas.getContainer().appendChild(l), this.canvas.addMarker(e, $), u(), l.focus(), l.select();
1064
- let d = !1, f = () => {
1065
- d || (d = !0, l.removeEventListener("keydown", m), l.removeEventListener("input", u), l.removeEventListener("blur", h), l.remove(), this.canvas.removeMarker(e, $), this.active = null);
1066
- }, p = () => {
1067
- if (d) return;
1068
- let t = l.value.trim(), n = t !== (e.ttLabel ?? "");
1069
- f(), n && this.modeling.updateLabel(e, t);
1070
- }, m = (e) => {
1071
- e.key === "Enter" && !e.shiftKey && !e.isComposing ? (e.preventDefault(), p()) : e.key === "Escape" && (e.preventDefault(), f());
1072
- }, h = () => p();
1073
- l.addEventListener("keydown", m), l.addEventListener("input", u), l.addEventListener("blur", h), this.active = {
1074
- commit: p,
1075
- cleanup: f
1434
+ this.canvas.getContainer().appendChild(u), this.canvas.addMarker(e, dn), d(), u.focus(), t ? u.setSelectionRange(t.selectionStart, t.selectionEnd) : u.select();
1435
+ let f = !1, p = () => {
1436
+ f || (f = !0, u.removeEventListener("keydown", h), u.removeEventListener("input", d), u.removeEventListener("blur", g), u.remove(), this.elementRegistry.get(e.id) === e && this.canvas.removeMarker(e, dn), this.active = null, this.canvas.restoreFocus());
1437
+ }, m = () => {
1438
+ if (f) return;
1439
+ let t = u.value.trim(), n = t !== (e.ttLabel ?? "");
1440
+ p(), n && this.modeling.updateLabel(e, t);
1441
+ }, h = (e) => {
1442
+ e.key === "Enter" && !e.shiftKey && !e.isComposing ? (e.preventDefault(), m(), this.canvas.focus()) : e.key === "Escape" && (e.preventDefault(), p(), this.canvas.focus());
1443
+ }, g = () => m();
1444
+ u.addEventListener("keydown", h), u.addEventListener("input", d), u.addEventListener("blur", g);
1445
+ let _ = () => ({
1446
+ elementId: e.id,
1447
+ value: u.value,
1448
+ selectionStart: u.selectionStart,
1449
+ selectionEnd: u.selectionEnd
1450
+ });
1451
+ this.active = {
1452
+ commit: m,
1453
+ cleanup: p,
1454
+ snapshot: _
1076
1455
  };
1077
1456
  }
1078
1457
  cancel() {
1079
1458
  this.active?.cleanup();
1080
1459
  }
1081
- }, et = {
1460
+ }, hn = {
1082
1461
  __init__: ["ttLabelEditing"],
1083
- ttLabelEditing: ["type", $e]
1084
- }, tt = 1, nt = 10, rt = {
1462
+ ttLabelEditing: ["type", mn]
1463
+ }, gn = 1, _n = 10, vn = {
1085
1464
  ArrowLeft: {
1086
1465
  x: -1,
1087
1466
  y: 0
@@ -1098,16 +1477,26 @@ var Xe = class {
1098
1477
  x: 0,
1099
1478
  y: 1
1100
1479
  }
1101
- };
1102
- function it(e) {
1480
+ }, yn = "[aria-modal=\"true\"], dialog[open]";
1481
+ function bn(e) {
1103
1482
  let t = e;
1104
1483
  return t ? t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.tagName === "SELECT" || t.isContentEditable : !1;
1105
1484
  }
1106
- function at(e) {
1485
+ function xn(e) {
1486
+ return typeof e?.nodeType == "number";
1487
+ }
1488
+ function Sn(e, t) {
1489
+ if (t.closest("[inert]")) return !1;
1490
+ if (!xn(e) || e.nodeType === Node.DOCUMENT_NODE) return !0;
1491
+ let n = e.ownerDocument;
1492
+ return e === n?.body || e === n?.documentElement || t.contains(e);
1493
+ }
1494
+ function Cn(e) {
1107
1495
  return !("waypoints" in e);
1108
1496
  }
1109
- var ot = class {
1497
+ var Q = class {
1110
1498
  static $inject = [
1499
+ "config.ttKeyboard",
1111
1500
  "eventBus",
1112
1501
  "canvas",
1113
1502
  "elementRegistry",
@@ -1115,42 +1504,54 @@ var ot = class {
1115
1504
  "selection",
1116
1505
  "modeling",
1117
1506
  "copyPaste",
1118
- "rules"
1507
+ "rules",
1508
+ "injector"
1119
1509
  ];
1120
- constructor(e, t, n, r, i, a, o, s) {
1121
- let c = t.getContainer().ownerDocument ?? document, l = (e) => {
1122
- if (it(e.target)) return;
1123
- let t = e.ctrlKey || e.metaKey, c = e.key.toLowerCase();
1124
- if (t && c === "z" && !e.shiftKey) e.preventDefault(), r.canUndo() && r.undo();
1125
- else if (t && c === "z" && e.shiftKey || t && c === "y") e.preventDefault(), r.canRedo() && r.redo();
1126
- else if (c === "delete" || c === "backspace") {
1127
- let t = i.get();
1128
- t.length && (e.preventDefault(), a.removeElements([...t]));
1129
- } else if (t && c === "c") {
1130
- let t = i.get();
1131
- t.length && (e.preventDefault(), o.copy(t));
1132
- } else if (t && c === "v") e.preventDefault(), o.paste();
1133
- else if (t && c === "a") e.preventDefault(), i.select(n.filter((e) => !!e.parent));
1134
- else if (!t && !e.altKey && Object.hasOwn(rt, e.key)) {
1135
- let t = i.get().filter(at);
1136
- if (!t.length || !s.allowed("elements.move", { shapes: t })) return;
1510
+ constructor(e, t, n, r, i, a, o, s, c, l) {
1511
+ let u = n.getContainer(), d = u.ownerDocument ?? document, f = e?.undoRedoKeys ?? !0, p = l.get("dragging", !1), m = l.get("ttReadOnly", !1), h = (e, t, n) => {
1512
+ if (t && n === "a" && !e.shiftKey) e.preventDefault(), a.select(r.filter((e) => !!e.parent));
1513
+ else if (t && n === "c" && !e.shiftKey) {
1514
+ let t = a.get();
1515
+ if (!t.length) return !0;
1516
+ e.preventDefault(), s.copy(t);
1517
+ } else if (!t && n === "escape") {
1518
+ if (p?.context() || !a.get().length) return !0;
1519
+ e.preventDefault(), a.select(null);
1520
+ } else return !1;
1521
+ return !0;
1522
+ }, g = (e, t, n) => {
1523
+ let r = t && n === "z" && !e.shiftKey, l = t && n === "z" && e.shiftKey || t && n === "y" && !e.shiftKey;
1524
+ if (r || l) {
1525
+ if (!f) return;
1526
+ e.preventDefault(), r && i.canUndo() && i.undo(), l && i.canRedo() && i.redo();
1527
+ } else if (n === "delete" || n === "backspace") {
1528
+ let t = a.get();
1529
+ t.length && (e.preventDefault(), o.removeElements([...t]));
1530
+ } else if (t && n === "v" && !e.shiftKey) e.preventDefault(), s.paste();
1531
+ else if (!t && Object.hasOwn(vn, e.key)) {
1532
+ let t = a.get().filter(Cn);
1533
+ if (!t.length || !c.allowed("elements.move", { shapes: t })) return;
1137
1534
  e.preventDefault();
1138
- let n = rt[e.key], r = e.shiftKey ? nt : tt;
1139
- a.moveElements(t, {
1535
+ let n = vn[e.key], r = e.shiftKey ? _n : gn;
1536
+ o.moveElements(t, {
1140
1537
  x: n.x * r,
1141
1538
  y: n.y * r
1142
1539
  });
1143
1540
  }
1541
+ }, _ = (e) => {
1542
+ if (e.defaultPrevented || e.altKey || e.isComposing || bn(e.target) || !Sn(e.target, u) || d.querySelector(yn)) return;
1543
+ let t = e.ctrlKey || e.metaKey, n = e.key.toLowerCase();
1544
+ h(e, t, n) || m?.isReadOnly() || g(e, t, n);
1144
1545
  };
1145
- c.addEventListener("keydown", l), e.on("diagram.destroy", () => c.removeEventListener("keydown", l));
1546
+ d.addEventListener("keydown", _), t.on("diagram.destroy", () => d.removeEventListener("keydown", _));
1146
1547
  }
1147
- }, st = {
1548
+ }, wn = {
1148
1549
  __init__: ["ttKeyboard"],
1149
- ttKeyboard: ["type", ot]
1550
+ ttKeyboard: ["type", Q]
1150
1551
  };
1151
1552
  //#endregion
1152
1553
  //#region src/copy-paste/TtCopyPaste.ts
1153
- function ct(e) {
1554
+ function Tn(e) {
1154
1555
  switch (e) {
1155
1556
  case "team": return "team";
1156
1557
  case "interaction": return "int";
@@ -1160,7 +1561,7 @@ function ct(e) {
1160
1561
  default: return;
1161
1562
  }
1162
1563
  }
1163
- var lt = class extends he {
1564
+ var En = class extends Se {
1164
1565
  elementFactory;
1165
1566
  static $inject = [
1166
1567
  "canvas",
@@ -1176,52 +1577,53 @@ var lt = class extends he {
1176
1577
  super(e, t, n, r, i, a, o, s), this.elementFactory = r;
1177
1578
  }
1178
1579
  createConnection(e) {
1179
- let t = ct(e.ttKind);
1580
+ let t = Tn(e.ttKind);
1180
1581
  return t ? this.elementFactory.createConnection({
1181
1582
  ...e,
1182
- id: u(t)
1583
+ id: v(t)
1183
1584
  }) : super.createConnection(e);
1184
1585
  }
1185
1586
  createShape(e) {
1186
- let t = ct(e.ttKind);
1587
+ let t = Tn(e.ttKind);
1187
1588
  return t ? this.elementFactory.createShape({
1188
1589
  ...e,
1189
- id: u(t)
1590
+ id: v(t)
1190
1591
  }) : super.createShape(e);
1191
1592
  }
1192
- }, ut = [
1593
+ }, Dn = [
1193
1594
  "ttKind",
1194
1595
  "teamType",
1195
1596
  "mode",
1196
1597
  "ttLabel",
1197
1598
  "description",
1198
1599
  "fill",
1199
- "stroke"
1200
- ], dt = {
1201
- __depends__: [me],
1600
+ "stroke",
1601
+ "ttForeign"
1602
+ ], On = {
1603
+ __depends__: [xe],
1202
1604
  __init__: ["ttCopyPasteProps"],
1203
- copyPaste: ["type", lt],
1605
+ copyPaste: ["type", En],
1204
1606
  ttCopyPasteProps: ["type", class {
1205
1607
  static $inject = ["eventBus"];
1206
1608
  constructor(e) {
1207
1609
  e.on("copyPaste.copyElement", (e) => {
1208
1610
  let { descriptor: t, element: n } = e;
1209
- if (!b(n) && !T(n)) return;
1611
+ if (!T(n) && !A(n)) return;
1210
1612
  let r = n;
1211
- for (let e of ut) r[e] !== void 0 && (t[e] = r[e]);
1613
+ for (let e of Dn) r[e] !== void 0 && (t[e] = structuredClone(r[e]));
1212
1614
  });
1213
1615
  }
1214
1616
  }]
1215
1617
  };
1216
1618
  //#endregion
1217
1619
  //#region src/zorder/TtZOrder.ts
1218
- function ft(e) {
1219
- return C(e) ? 0 : x(e) ? e.teamType === "enabling" ? 3 : e.teamType === "complicated-subsystem" ? 2 : 1 : S(e) ? 4 : w(e) ? 5 : T(e) ? 6 : 1;
1620
+ function kn(e) {
1621
+ return O(e) ? 0 : E(e) ? e.teamType === "enabling" ? 3 : e.teamType === "complicated-subsystem" ? 2 : 1 : D(e) ? 4 : k(e) ? 5 : A(e) ? 6 : 1;
1220
1622
  }
1221
- function pt(e) {
1222
- return b(e) || T(e);
1623
+ function An(e) {
1624
+ return T(e) || A(e);
1223
1625
  }
1224
- var mt = class {
1626
+ var jn = class {
1225
1627
  canvas;
1226
1628
  elementRegistry;
1227
1629
  static $inject = [
@@ -1240,33 +1642,34 @@ var mt = class {
1240
1642
  });
1241
1643
  }
1242
1644
  reorder() {
1243
- let e = this.elementRegistry.getAll().filter(pt).sort((e, t) => ft(e) - ft(t));
1645
+ let e = this.elementRegistry.getAll().filter(An).sort((e, t) => kn(e) - kn(t));
1244
1646
  for (let t of e) {
1245
1647
  let e = this.canvas.getGraphics(t)?.parentNode, n = e?.parentNode;
1246
1648
  e && n && n.appendChild(e);
1247
1649
  }
1248
1650
  }
1249
- }, ht = {
1651
+ }, Mn = {
1250
1652
  __init__: ["ttZOrder"],
1251
- ttZOrder: ["type", mt]
1252
- }, gt = class extends W {
1653
+ ttZOrder: ["type", jn]
1654
+ }, Nn = class extends K {
1253
1655
  _getModules() {
1254
1656
  return [
1255
1657
  ...super._getModules(),
1256
- v,
1257
- _,
1258
- ne,
1259
- re,
1260
- ie,
1261
- De,
1262
- Ae,
1263
- Ne,
1264
- We,
1265
- Ze,
1266
- et,
1267
- st,
1268
- dt,
1269
- ht
1658
+ ce,
1659
+ se,
1660
+ le,
1661
+ ue,
1662
+ de,
1663
+ on,
1664
+ gt,
1665
+ yt,
1666
+ St,
1667
+ tn,
1668
+ un,
1669
+ hn,
1670
+ wn,
1671
+ On,
1672
+ Mn
1270
1673
  ];
1271
1674
  }
1272
1675
  undo() {
@@ -1281,8 +1684,127 @@ var mt = class {
1281
1684
  canRedo() {
1282
1685
  return this.get("commandStack").canRedo();
1283
1686
  }
1284
- };
1687
+ }, Pn = "team-topologies";
1688
+ function Fn(e = {}) {
1689
+ return zn(new Nn({
1690
+ ...Ln(e),
1691
+ undoRedoKeys: e.undoRedoKeys ?? !0,
1692
+ freeRectCenter: e.freeRectCenter
1693
+ }), !0, e.fitOnImport ?? !0);
1694
+ }
1695
+ function In(e = {}) {
1696
+ return zn(new K(Ln(e)), !1, e.fitOnImport ?? !0);
1697
+ }
1698
+ function Ln(e) {
1699
+ return {
1700
+ width: "100%",
1701
+ height: "100%",
1702
+ additionalModules: e.additionalModules ?? []
1703
+ };
1704
+ }
1705
+ function Rn(e) {
1706
+ let t = ee(e.trim() === "" ? {} : JSON.parse(e));
1707
+ if (!t.ok) throw Error(t.error);
1708
+ return t.document;
1709
+ }
1710
+ function zn(e, t, n) {
1711
+ let r = e.get("eventBus"), i = e.get("canvas"), a = e.get("elementRegistry"), o = e.get("selection"), s = /* @__PURE__ */ new Set(), c = 0, l = !1, u = "", d = {
1712
+ notation: Pn,
1713
+ apiVersion: Ce,
1714
+ editable: t
1715
+ };
1716
+ t && r.on("commandStack.changed", () => {
1717
+ if (!(c > 0)) for (let e of [...s]) e();
1718
+ });
1719
+ let f = () => te(e.exportDocument());
1720
+ return {
1721
+ meta: d,
1722
+ elements: {
1723
+ list: () => l ? [] : a.getAll().filter(T).map(Vn),
1724
+ reveal(e) {
1725
+ if (l) return !1;
1726
+ let t = a.get(e);
1727
+ return T(t) ? (o.select(t), i.scrollToElement(t), !0) : !1;
1728
+ },
1729
+ selection: () => l ? [] : Bn(o.get()),
1730
+ onSelection(e) {
1731
+ let t = (t) => e(Bn(t.newSelection ?? []));
1732
+ return r.on("selection.changed", t), () => r.off("selection.changed", t);
1733
+ }
1734
+ },
1735
+ diagram: e,
1736
+ attachTo(t) {
1737
+ e.attachTo(t);
1738
+ },
1739
+ async importText(t) {
1740
+ if (l) throw Error("The modeler was destroyed.");
1741
+ let r = Rn(t);
1742
+ c += 1;
1743
+ try {
1744
+ let { warnings: t } = e.importDocument(r, { fit: n });
1745
+ return { warnings: t.map((e) => e.message) };
1746
+ } finally {
1747
+ --c;
1748
+ }
1749
+ },
1750
+ exportText() {
1751
+ return l ? u : f();
1752
+ },
1753
+ onContentChanged(e) {
1754
+ return t ? (s.add(e), () => s.delete(e)) : () => void 0;
1755
+ },
1756
+ getViewState() {
1757
+ if (!l) try {
1758
+ let { x: e, y: t, width: n, height: r } = i.viewbox(), a = {
1759
+ x: e,
1760
+ y: t,
1761
+ width: n,
1762
+ height: r
1763
+ };
1764
+ return Hn(a) ? a : void 0;
1765
+ } catch {
1766
+ return;
1767
+ }
1768
+ },
1769
+ setViewState(e) {
1770
+ !l && Hn(e) && i.viewbox({
1771
+ x: e.x,
1772
+ y: e.y,
1773
+ width: e.width,
1774
+ height: e.height
1775
+ });
1776
+ },
1777
+ destroy() {
1778
+ if (!l) {
1779
+ try {
1780
+ u = f();
1781
+ } catch {
1782
+ u = "";
1783
+ }
1784
+ l = !0, s.clear(), e.destroy();
1785
+ }
1786
+ }
1787
+ };
1788
+ }
1789
+ function Bn(e) {
1790
+ return e.filter(T).map((e) => e.id);
1791
+ }
1792
+ function Vn(e) {
1793
+ let t = e.ttLabel;
1794
+ return t ? {
1795
+ id: e.id,
1796
+ name: t
1797
+ } : { id: e.id };
1798
+ }
1799
+ function Hn(e) {
1800
+ if (typeof e != "object" || !e) return !1;
1801
+ let { x: t, y: n, width: r, height: i } = e;
1802
+ return $(t) && $(n) && $(r) && $(i) && r > 0 && i > 0;
1803
+ }
1804
+ function $(e) {
1805
+ return typeof e == "number" && Number.isFinite(e);
1806
+ }
1285
1807
  //#endregion
1286
- export { gt as Modeler, W as NavigatedViewer, O as ROOT_ID, L as TeamTopologiesRenderer, Me as TtAssociationBehavior, ve as TtBaseViewer, Xe as TtContextPadProvider, ye as TtElementFactory, V as TtExporter, je as TtFlatModelBehavior, B as TtImporter, ot as TtKeyboard, $e as TtLabelEditing, Y as TtLayouter, J as TtModeling, Ue as TtPaletteProvider, ke as TtRules, mt as TtZOrder, U as Viewer, Ie as annotationIconSvg, Fe as flowIconSvg, Re as interactionIconSvg, H as ioModule, w as isTtAnnotation, T as isTtAssociation, b as isTtElement, C as isTtFlow, S as isTtInteraction, x as isTtTeam, D as saveSVG, Pe as teamIconSvg, Ne as ttBehaviorsModule, Ze as ttContextPadModule, z as ttDrawModule, st as ttKeyboardModule, et as ttLabelEditingModule, be as ttModelModule, De as ttModelingModule, We as ttPaletteModule, Ae as ttRulesModule, ht as ttZOrderModule };
1808
+ export { Te as CD_TOKENS, G as GEIST_UNICODE_RANGES, Mt as ICON_DOWNLOAD, Tt as ICON_LINK, jt as ICON_MAXIMIZE, Ot as ICON_MENU, Et as ICON_MESSAGE_SQUARE_PLUS, kt as ICON_MINUS, Ct as ICON_PENCIL, At as ICON_PLUS, Dt as ICON_SQUARE_DASHED_MOUSE_POINTER, wt as ICON_TRASH, Nt as ICON_X, j as MIRAGON, Nn as Modeler, K as NavigatedViewer, X as READ_ONLY_CHANGED_EVENT, N as ROOT_ID, Pn as TEAM_TOPOLOGIES_NOTATION, Ge as TeamTopologiesRenderer, xt as TtAssociationBehavior, Me as TtBaseViewer, ln as TtContextPadProvider, Ne as TtElementFactory, Xe as TtExporter, bt as TtFlatModelBehavior, Ye as TtImporter, Q as TtKeyboard, mn as TtLabelEditing, ht as TtLayouter, mt as TtModeling, en as TtPaletteProvider, an as TtReadOnly, vt as TtRules, rt as TtViewport, jn as TtZOrder, st as Viewer, Ut as annotationIconSvg, Fn as createCollaborativeModeler, In as createCollaborativeViewer, at as embedSvgStyles, Ht as flowIconSvg, it as geistFontFaceCss, J as iconMarkup, Gt as interactionIconSvg, ot as ioModule, k as isTtAnnotation, A as isTtAssociation, T as isTtElement, O as isTtFlow, D as isTtInteraction, E as isTtTeam, Rn as parseDocumentText, Ae as saveSVG, Vt as teamIconSvg, St as ttBehaviorsModule, un as ttContextPadModule, Je as ttDrawModule, wn as ttKeyboardModule, hn as ttLabelEditingModule, Pe as ttModelModule, gt as ttModelingModule, tn as ttPaletteModule, on as ttReadOnlyModule, yt as ttRulesModule, Mn as ttZOrderModule };
1287
1809
 
1288
1810
  //# sourceMappingURL=index.js.map