@miragon/wardley-renderer 0.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 (96) hide show
  1. package/dist/Modeler.d.ts +14 -0
  2. package/dist/Modeler.d.ts.map +1 -0
  3. package/dist/NavigatedViewer.d.ts +10 -0
  4. package/dist/NavigatedViewer.d.ts.map +1 -0
  5. package/dist/Viewer.d.ts +6 -0
  6. package/dist/Viewer.d.ts.map +1 -0
  7. package/dist/WardleyBaseViewer.d.ts +66 -0
  8. package/dist/WardleyBaseViewer.d.ts.map +1 -0
  9. package/dist/append/WardleyAppendBehavior.d.ts +15 -0
  10. package/dist/append/WardleyAppendBehavior.d.ts.map +1 -0
  11. package/dist/append/index.d.ts +9 -0
  12. package/dist/append/index.d.ts.map +1 -0
  13. package/dist/color-picker/WardleyColorPicker.d.ts +23 -0
  14. package/dist/color-picker/WardleyColorPicker.d.ts.map +1 -0
  15. package/dist/color-picker/index.d.ts +5 -0
  16. package/dist/color-picker/index.d.ts.map +1 -0
  17. package/dist/context-pad/WardleyContextPadProvider.d.ts +28 -0
  18. package/dist/context-pad/WardleyContextPadProvider.d.ts.map +1 -0
  19. package/dist/context-pad/index.d.ts +5 -0
  20. package/dist/context-pad/index.d.ts.map +1 -0
  21. package/dist/draw/WardleyRenderer.d.ts +23 -0
  22. package/dist/draw/WardleyRenderer.d.ts.map +1 -0
  23. package/dist/draw/icons.d.ts +70 -0
  24. package/dist/draw/icons.d.ts.map +1 -0
  25. package/dist/draw/index.d.ts +5 -0
  26. package/dist/draw/index.d.ts.map +1 -0
  27. package/dist/draw/palette-icons.d.ts +3 -0
  28. package/dist/draw/palette-icons.d.ts.map +1 -0
  29. package/dist/draw/styles.d.ts +108 -0
  30. package/dist/draw/styles.d.ts.map +1 -0
  31. package/dist/evolution-grid/EvolutionConstraintBehavior.d.ts +16 -0
  32. package/dist/evolution-grid/EvolutionConstraintBehavior.d.ts.map +1 -0
  33. package/dist/evolution-grid/EvolutionGrid.d.ts +39 -0
  34. package/dist/evolution-grid/EvolutionGrid.d.ts.map +1 -0
  35. package/dist/evolution-grid/index.d.ts +8 -0
  36. package/dist/evolution-grid/index.d.ts.map +1 -0
  37. package/dist/evolve/WardleyEvolveDragging.d.ts +21 -0
  38. package/dist/evolve/WardleyEvolveDragging.d.ts.map +1 -0
  39. package/dist/evolve/index.d.ts +4 -0
  40. package/dist/evolve/index.d.ts.map +1 -0
  41. package/dist/index.d.ts +28 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +1985 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/io/WardleyExporter.d.ts +19 -0
  46. package/dist/io/WardleyExporter.d.ts.map +1 -0
  47. package/dist/io/WardleyImporter.d.ts +27 -0
  48. package/dist/io/WardleyImporter.d.ts.map +1 -0
  49. package/dist/io/index.d.ts +8 -0
  50. package/dist/io/index.d.ts.map +1 -0
  51. package/dist/io/saveSvg.d.ts +10 -0
  52. package/dist/io/saveSvg.d.ts.map +1 -0
  53. package/dist/io/types.d.ts +13 -0
  54. package/dist/io/types.d.ts.map +1 -0
  55. package/dist/keyboard/WardleyKeyboard.d.ts +13 -0
  56. package/dist/keyboard/WardleyKeyboard.d.ts.map +1 -0
  57. package/dist/keyboard/index.d.ts +5 -0
  58. package/dist/keyboard/index.d.ts.map +1 -0
  59. package/dist/label-editing/WardleyLabelEditing.d.ts +22 -0
  60. package/dist/label-editing/WardleyLabelEditing.d.ts.map +1 -0
  61. package/dist/label-editing/index.d.ts +5 -0
  62. package/dist/label-editing/index.d.ts.map +1 -0
  63. package/dist/model/WardleyElementFactory.d.ts +46 -0
  64. package/dist/model/WardleyElementFactory.d.ts.map +1 -0
  65. package/dist/model/di-types.d.ts +47 -0
  66. package/dist/model/di-types.d.ts.map +1 -0
  67. package/dist/model/index.d.ts +6 -0
  68. package/dist/model/index.d.ts.map +1 -0
  69. package/dist/modeling/WardleyModeling.d.ts +27 -0
  70. package/dist/modeling/WardleyModeling.d.ts.map +1 -0
  71. package/dist/modeling/cmd/UpdatePropertiesHandler.d.ts +18 -0
  72. package/dist/modeling/cmd/UpdatePropertiesHandler.d.ts.map +1 -0
  73. package/dist/modeling/index.d.ts +6 -0
  74. package/dist/modeling/index.d.ts.map +1 -0
  75. package/dist/palette/WardleyPaletteProvider.d.ts +12 -0
  76. package/dist/palette/WardleyPaletteProvider.d.ts.map +1 -0
  77. package/dist/palette/index.d.ts +5 -0
  78. package/dist/palette/index.d.ts.map +1 -0
  79. package/dist/pan-constraint/PanConstraint.d.ts +18 -0
  80. package/dist/pan-constraint/PanConstraint.d.ts.map +1 -0
  81. package/dist/pan-constraint/index.d.ts +4 -0
  82. package/dist/pan-constraint/index.d.ts.map +1 -0
  83. package/dist/popup/WardleyElementSettingsProvider.d.ts +17 -0
  84. package/dist/popup/WardleyElementSettingsProvider.d.ts.map +1 -0
  85. package/dist/popup/index.d.ts +5 -0
  86. package/dist/popup/index.d.ts.map +1 -0
  87. package/dist/rules/WardleyRules.d.ts +13 -0
  88. package/dist/rules/WardleyRules.d.ts.map +1 -0
  89. package/dist/rules/index.d.ts +5 -0
  90. package/dist/rules/index.d.ts.map +1 -0
  91. package/dist/snapping/StageSnapping.d.ts +12 -0
  92. package/dist/snapping/StageSnapping.d.ts.map +1 -0
  93. package/dist/snapping/index.d.ts +5 -0
  94. package/dist/snapping/index.d.ts.map +1 -0
  95. package/dist/wardley.css +2 -0
  96. package/package.json +43 -0
package/dist/index.js ADDED
@@ -0,0 +1,1985 @@
1
+ import e from "diagram-js/lib/Diagram";
2
+ import { parseDSL as t, serializeDSL as n } from "@miragon/wardley-dsl";
3
+ import { append as r, attr as i, clear as a, create as o } from "tiny-svg";
4
+ import { CURRENT_SCHEMA_VERSION as s, DEFAULT_EVOLUTION_LABELS as c, DEFAULT_STAGE_BOUNDARIES as l, evolutionStage as u, validateMap as d } from "@miragon/wardley-schema-model";
5
+ import f from "diagram-js/lib/command/CommandInterceptor";
6
+ import ee from "diagram-js/lib/draw/BaseRenderer";
7
+ import te from "diagram-js/lib/features/selection";
8
+ import ne from "diagram-js/lib/navigation/zoomscroll";
9
+ import re from "diagram-js/lib/navigation/movecanvas";
10
+ import ie from "diagram-js/lib/features/keyboard";
11
+ import ae from "diagram-js/lib/features/modeling";
12
+ import oe from "diagram-js/lib/features/move";
13
+ import se from "diagram-js/lib/features/create";
14
+ import ce from "diagram-js/lib/features/connect";
15
+ import le from "diagram-js/lib/features/context-pad";
16
+ import ue from "diagram-js/lib/features/palette";
17
+ import de from "diagram-js/lib/features/rules";
18
+ import fe from "diagram-js/lib/features/outline";
19
+ import pe from "diagram-js/lib/features/resize";
20
+ import me from "diagram-js/lib/features/popup-menu";
21
+ import he from "diagram-js/lib/features/rules/RuleProvider";
22
+ import ge from "diagram-js/lib/features/connection-preview";
23
+ //#region src/draw/styles.ts
24
+ var p = {
25
+ width: 1080,
26
+ height: 680,
27
+ marginLeft: 66,
28
+ marginTop: 38,
29
+ marginRight: 44,
30
+ marginBottom: 58
31
+ }, _e = {
32
+ width: 480,
33
+ height: 320
34
+ }, ve = 8, ye = 6, be = 7.5;
35
+ function m(e) {
36
+ let t = (e && e.length ? e : "note").split("\n"), n = Math.max(1, ...t.map((e) => e.length));
37
+ return {
38
+ lines: t,
39
+ width: Math.max(34, Math.round(n * be) + ve * 2),
40
+ height: Math.max(34, t.length * 17 + ye * 2)
41
+ };
42
+ }
43
+ var h = {
44
+ paper: "#fbfaf7",
45
+ ink: "#1b1b1a",
46
+ inkSoft: "#3a3a37",
47
+ axis: "#cdc7bb",
48
+ axisText: "#8c8475",
49
+ grid: "#ebe7de",
50
+ band: "rgba(27,27,26,0.022)",
51
+ stroke: "#1b1b1a",
52
+ componentFill: "#ffffff",
53
+ anchorFill: "#1b1b1a",
54
+ dependency: "#a9a296",
55
+ accent: "#0e7c74",
56
+ accentSoft: "rgba(14,124,116,0.12)",
57
+ flow: "#0e7c74",
58
+ movement: "#bf2f2a",
59
+ inertia: "#1b1b1a",
60
+ noteText: "#4a4640",
61
+ pipeline: "#1b1b1a"
62
+ }, xe = [
63
+ {
64
+ id: "green",
65
+ name: "Green · good",
66
+ value: "#15803d"
67
+ },
68
+ {
69
+ id: "amber",
70
+ name: "Amber · watch",
71
+ value: "#b45309"
72
+ },
73
+ {
74
+ id: "red",
75
+ name: "Red · problem",
76
+ value: "#b91c1c"
77
+ },
78
+ {
79
+ id: "blue",
80
+ name: "Blue · info",
81
+ value: "#1d4ed8"
82
+ },
83
+ {
84
+ id: "teal",
85
+ name: "Teal",
86
+ value: "#0e7c74"
87
+ },
88
+ {
89
+ id: "purple",
90
+ name: "Purple · idea",
91
+ value: "#7e22ce"
92
+ },
93
+ {
94
+ id: "pink",
95
+ name: "Pink",
96
+ value: "#be185d"
97
+ },
98
+ {
99
+ id: "slate",
100
+ name: "Slate · neutral",
101
+ value: "#475569"
102
+ }
103
+ ], Se = {
104
+ pioneers: {
105
+ fill: "rgba(14,124,116,0.07)",
106
+ stroke: "#0e7c74"
107
+ },
108
+ settlers: {
109
+ fill: "rgba(180,131,30,0.08)",
110
+ stroke: "#b4831e"
111
+ },
112
+ townplanners: {
113
+ fill: "rgba(120,53,170,0.07)",
114
+ stroke: "#7835aa"
115
+ }
116
+ }, g = {
117
+ family: "'Spline Sans Variable', 'Spline Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif",
118
+ label: 13,
119
+ axis: 12,
120
+ stage: 12
121
+ };
122
+ //#endregion
123
+ //#region src/io/saveSvg.ts
124
+ function Ce(e) {
125
+ let t = e.getContainer().querySelector("svg");
126
+ if (!t) throw Error("No SVG found in the canvas container.");
127
+ let n = t.cloneNode(!0), r = p.marginLeft + p.width + p.marginRight, i = p.marginTop + p.height + p.marginBottom;
128
+ n.setAttribute("xmlns", "http://www.w3.org/2000/svg"), n.setAttribute("viewBox", `0 0 ${r} ${i}`), n.setAttribute("width", String(r)), n.setAttribute("height", String(i));
129
+ let a = n.querySelector(".viewport");
130
+ return a && a.removeAttribute("transform"), { svg: "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + new XMLSerializer().serializeToString(n) };
131
+ }
132
+ //#endregion
133
+ //#region src/io/types.ts
134
+ var we = "wardley-root";
135
+ //#endregion
136
+ //#region src/WardleyBaseViewer.ts
137
+ function Te(e) {
138
+ return typeof e == "number" ? `${e}px` : e;
139
+ }
140
+ var Ee = class {
141
+ _diagram;
142
+ _container;
143
+ _options;
144
+ constructor(e = {}) {
145
+ this._options = e, this._container = this._createContainer(e);
146
+ }
147
+ _createContainer(e) {
148
+ let t = e.container ?? document.createElement("div");
149
+ return t.classList.add("wardley-container"), t.style.width = Te(e.width ?? "100%"), t.style.height = Te(e.height ?? (e.container ? "100%" : "600px")), t;
150
+ }
151
+ _ensureDiagram() {
152
+ if (!this._diagram) {
153
+ let t = [...this._getModules(), ...this._options.additionalModules ?? []];
154
+ this._diagram = new e({
155
+ canvas: { container: this._container },
156
+ modules: t
157
+ });
158
+ }
159
+ return this._diagram;
160
+ }
161
+ get(e) {
162
+ return this._ensureDiagram().get(e);
163
+ }
164
+ on(e, t, n = 1e3) {
165
+ this.get("eventBus").on(e, n, t);
166
+ }
167
+ off(e, t) {
168
+ this.get("eventBus").off(e, t);
169
+ }
170
+ async importMap(e) {
171
+ let t = this._ensureDiagram(), n = t.get("eventBus"), r = t.get("wardleyImporter");
172
+ r.clear();
173
+ let i = r.import(e);
174
+ return n.fire("import.done", { warnings: i }), { warnings: i };
175
+ }
176
+ async importDSL(e) {
177
+ let n = this._ensureDiagram().get("eventBus");
178
+ n.fire("import.parse.start", { text: e });
179
+ let r = t(e);
180
+ return n.fire("import.parse.done", { map: r }), this.importMap(r);
181
+ }
182
+ exportMap() {
183
+ return this.get("wardleyExporter").export();
184
+ }
185
+ async setMapSize(e, t) {
186
+ let n = this.exportMap();
187
+ return this.importMap({
188
+ ...n,
189
+ config: {
190
+ ...n.config,
191
+ size: {
192
+ width: e,
193
+ height: t
194
+ }
195
+ }
196
+ });
197
+ }
198
+ setEvolutionLabels(e) {
199
+ let t = this.get("canvas"), n;
200
+ try {
201
+ n = t.getRootElement();
202
+ } catch {
203
+ return;
204
+ }
205
+ if (!n || n.id !== "wardley-root") return;
206
+ let { evolutionLabels: r, ...i } = n.businessObject?.config ?? { title: "Untitled Map" }, a = e ? {
207
+ ...i,
208
+ evolutionLabels: e
209
+ } : i;
210
+ n.businessObject = {
211
+ ...n.businessObject,
212
+ config: a
213
+ };
214
+ let o = this.get("evolutionGrid");
215
+ o.configure(a), o.render(), this.get("eventBus").fire("wardley.config.changed", { config: a });
216
+ }
217
+ exportDSL() {
218
+ return n(this.exportMap());
219
+ }
220
+ async saveSVG() {
221
+ return Ce(this.get("canvas"));
222
+ }
223
+ attachTo(e) {
224
+ e.appendChild(this._container), this.get("canvas").resized();
225
+ }
226
+ detach() {
227
+ this._container.remove();
228
+ }
229
+ clear() {
230
+ this._ensureDiagram().clear();
231
+ }
232
+ destroy() {
233
+ this._diagram &&= (this._diagram.destroy(), void 0), this._container.remove();
234
+ }
235
+ get container() {
236
+ return this._container;
237
+ }
238
+ }, _ = class {
239
+ elementFactory;
240
+ grid;
241
+ elementRegistry;
242
+ static $inject = [
243
+ "elementFactory",
244
+ "evolutionGrid",
245
+ "elementRegistry"
246
+ ];
247
+ constructor(e, t, n) {
248
+ this.elementFactory = e, this.grid = t, this.elementRegistry = n;
249
+ }
250
+ uniqueLabel(e, t) {
251
+ let n = /* @__PURE__ */ new Set();
252
+ for (let e of this.elementRegistry.getAll()) {
253
+ if (t && e.id === t) continue;
254
+ let r = e.wardleyLabel;
255
+ typeof r == "string" && n.add(r);
256
+ }
257
+ if (!n.has(e)) return e;
258
+ let r = 2;
259
+ for (; n.has(`${e} ${r}`);) r++;
260
+ return `${e} ${r}`;
261
+ }
262
+ createComponent(e) {
263
+ return this.node("component", e.id, e.label, e.position.visibility, e.position.evolution, e, {
264
+ ...e.decorators ? { decorators: e.decorators } : {},
265
+ ...e.movement ? { movement: e.movement } : {}
266
+ });
267
+ }
268
+ createAnchor(e) {
269
+ return this.node("anchor", e.id, e.label, e.position.visibility, e.position.evolution, e);
270
+ }
271
+ createNote(e) {
272
+ let { width: t, height: n } = m(e.label), r = this.grid.toCanvas(e.position);
273
+ return this.elementFactory.createShape({
274
+ id: e.id,
275
+ x: r.x - t / 2,
276
+ y: r.y - n / 2,
277
+ width: t,
278
+ height: n,
279
+ wardleyType: "note",
280
+ wardleyLabel: e.label,
281
+ evolution: e.position.evolution,
282
+ visibility: e.position.visibility,
283
+ businessObject: e,
284
+ ...e.color ? { color: e.color } : {}
285
+ });
286
+ }
287
+ createPipeline(e) {
288
+ let t = this.grid.toCanvas({
289
+ visibility: e.position.visibility,
290
+ evolution: e.evolutionStart
291
+ }), n = this.grid.toCanvas({
292
+ visibility: e.position.visibility,
293
+ evolution: e.evolutionEnd
294
+ }), r = Math.max(n.x - t.x, 2);
295
+ return this.elementFactory.createShape({
296
+ id: e.id,
297
+ x: t.x,
298
+ y: t.y - 30 / 2,
299
+ width: r,
300
+ height: 30,
301
+ wardleyType: "pipeline",
302
+ wardleyLabel: e.label,
303
+ evolution: e.position.evolution,
304
+ visibility: e.position.visibility,
305
+ evolutionStart: e.evolutionStart,
306
+ evolutionEnd: e.evolutionEnd,
307
+ isFrame: !0,
308
+ businessObject: e
309
+ });
310
+ }
311
+ createAnnotation(e) {
312
+ let t = e.positions[0] ?? e.position;
313
+ return this.node("annotation", e.id, e.text, t.visibility, t.evolution, e, { annotationNumber: e.number });
314
+ }
315
+ createAccelerator(e) {
316
+ return this.node("accelerator", e.id, e.label, e.position.visibility, e.position.evolution, e, { acceleratorDirection: e.direction });
317
+ }
318
+ createAttitude(e) {
319
+ let t = this.grid.toCanvas(e.position);
320
+ return this.elementFactory.createShape({
321
+ id: e.id,
322
+ x: t.x,
323
+ y: t.y,
324
+ width: Math.max(e.width, 4),
325
+ height: Math.max(e.height, 4),
326
+ wardleyType: "attitude",
327
+ wardleyLabel: e.label || e.kind,
328
+ attitudeKind: e.kind,
329
+ evolution: e.position.evolution,
330
+ visibility: e.position.visibility,
331
+ isFrame: !0,
332
+ businessObject: e
333
+ });
334
+ }
335
+ createSubmap(e) {
336
+ return this.node("submap", e.id, e.label, e.position.visibility, e.position.evolution, e);
337
+ }
338
+ createNew(e, t, n = {}) {
339
+ let r = this.uniqueLabel(t);
340
+ if (e === "pipeline") return this.elementFactory.createShape({
341
+ width: 200,
342
+ height: 30,
343
+ wardleyType: "pipeline",
344
+ wardleyLabel: r,
345
+ evolution: .5,
346
+ visibility: .5,
347
+ evolutionStart: .4,
348
+ evolutionEnd: .6,
349
+ isFrame: !0
350
+ });
351
+ if (e === "attitude") return this.elementFactory.createShape({
352
+ width: 180,
353
+ height: 48,
354
+ wardleyType: "attitude",
355
+ wardleyLabel: r,
356
+ attitudeKind: n.attitudeKind ?? "pioneers",
357
+ evolution: .5,
358
+ visibility: .5,
359
+ isFrame: !0
360
+ });
361
+ if (e === "note") {
362
+ let { width: e, height: t } = m(r);
363
+ return this.elementFactory.createShape({
364
+ width: e,
365
+ height: t,
366
+ wardleyType: "note",
367
+ wardleyLabel: r,
368
+ evolution: .5,
369
+ visibility: .5
370
+ });
371
+ }
372
+ let i = n.market ? { market: !0 } : n.ecosystem ? { ecosystem: !0 } : void 0;
373
+ return this.elementFactory.createShape({
374
+ width: 34,
375
+ height: 34,
376
+ wardleyType: e,
377
+ wardleyLabel: r,
378
+ evolution: .5,
379
+ visibility: .5,
380
+ ...n.acceleratorDirection ? { acceleratorDirection: n.acceleratorDirection } : {},
381
+ ...n.annotationNumber === void 0 ? {} : { annotationNumber: n.annotationNumber },
382
+ ...i ? { decorators: i } : {}
383
+ });
384
+ }
385
+ createDependency(e, t, n) {
386
+ return this.connection("dependency", e, t, n);
387
+ }
388
+ createFlow(e, t, n) {
389
+ let r = e.edgeType === "flow" && e.bidirectional === !0;
390
+ return this.connection("flow", e, t, n, r);
391
+ }
392
+ node(e, t, n, r, i, a, o = {}) {
393
+ let s = this.grid.toCanvas({
394
+ visibility: r,
395
+ evolution: i
396
+ });
397
+ return this.elementFactory.createShape({
398
+ id: t,
399
+ x: s.x - 34 / 2,
400
+ y: s.y - 34 / 2,
401
+ width: 34,
402
+ height: 34,
403
+ wardleyType: e,
404
+ wardleyLabel: n,
405
+ evolution: i,
406
+ visibility: r,
407
+ businessObject: a,
408
+ ...o
409
+ });
410
+ }
411
+ connection(e, t, n, r, i = !1) {
412
+ let a = t.edgeType === "flow" ? t.flowValue : void 0;
413
+ return this.elementFactory.createConnection({
414
+ id: t.id,
415
+ source: n,
416
+ target: r,
417
+ waypoints: [v(n), v(r)],
418
+ wardleyType: e,
419
+ bidirectional: i,
420
+ ...a ? { flowValue: a } : {},
421
+ ...t.label ? { linkLabel: t.label } : {},
422
+ businessObject: t
423
+ });
424
+ }
425
+ };
426
+ function v(e) {
427
+ return {
428
+ x: e.x + e.width / 2,
429
+ y: e.y + e.height / 2
430
+ };
431
+ }
432
+ //#endregion
433
+ //#region src/model/di-types.ts
434
+ function y(e) {
435
+ return typeof e == "object" && !!e;
436
+ }
437
+ function b(e) {
438
+ return y(e) && typeof e.wardleyType == "string" && "evolution" in e;
439
+ }
440
+ function x(e) {
441
+ return y(e) && typeof e.wardleyType == "string" && "waypoints" in e;
442
+ }
443
+ function S(e) {
444
+ return b(e) && e.wardleyType === "component";
445
+ }
446
+ function C(e) {
447
+ return b(e) && e.wardleyType === "pipeline";
448
+ }
449
+ //#endregion
450
+ //#region src/model/index.ts
451
+ var w = { wardleyElementFactory: ["type", _] }, De = "wardley-axes";
452
+ function T(e) {
453
+ return e < 0 ? 0 : e > 1 ? 1 : e;
454
+ }
455
+ var E = class {
456
+ canvas;
457
+ static $inject = ["canvas"];
458
+ boundaries = l;
459
+ labels = c;
460
+ yAxisLabel = "Value Chain";
461
+ plotWidth = p.width;
462
+ plotHeight = p.height;
463
+ constructor(e) {
464
+ this.canvas = e;
465
+ }
466
+ configure(e) {
467
+ this.boundaries = e.stageBoundaries ?? l, this.labels = e.evolutionLabels ?? c, this.yAxisLabel = e.yAxisLabel ?? "Value Chain", this.plotWidth = Math.max(e.size?.width ?? p.width, _e.width), this.plotHeight = Math.max(e.size?.height ?? p.height, _e.height);
468
+ }
469
+ toCanvas(e) {
470
+ return {
471
+ x: p.marginLeft + e.evolution * this.plotWidth,
472
+ y: p.marginTop + (1 - e.visibility) * this.plotHeight
473
+ };
474
+ }
475
+ fromCanvas(e) {
476
+ return {
477
+ evolution: T((e.x - p.marginLeft) / this.plotWidth),
478
+ visibility: T(1 - (e.y - p.marginTop) / this.plotHeight)
479
+ };
480
+ }
481
+ stageOf(e) {
482
+ return u(e, this.boundaries);
483
+ }
484
+ getBoundaries() {
485
+ return this.boundaries;
486
+ }
487
+ getPlotSize() {
488
+ return {
489
+ width: this.plotWidth,
490
+ height: this.plotHeight
491
+ };
492
+ }
493
+ outerBounds() {
494
+ return {
495
+ x: 0,
496
+ y: 0,
497
+ width: p.marginLeft + this.plotWidth + p.marginRight,
498
+ height: p.marginTop + this.plotHeight + p.marginBottom
499
+ };
500
+ }
501
+ render() {
502
+ let e = this.canvas.getLayer(De, -1);
503
+ a(e);
504
+ let t = p.marginLeft, n = p.marginTop, o = t + this.plotWidth, s = n + this.plotHeight;
505
+ r(e, D(t, n, this.plotWidth, this.plotHeight, {
506
+ fill: "#ffffff",
507
+ stroke: h.grid
508
+ }));
509
+ let c = [
510
+ 0,
511
+ ...this.boundaries,
512
+ 1
513
+ ];
514
+ for (let i = 0; i < 4; i++) {
515
+ let a = t + c[i] * this.plotWidth, o = t + c[i + 1] * this.plotWidth;
516
+ i % 2 == 1 && r(e, D(a, n, o - a, this.plotHeight, {
517
+ fill: h.band,
518
+ stroke: "none"
519
+ })), i > 0 && r(e, O(a, n, a, s, {
520
+ stroke: h.grid,
521
+ "stroke-dasharray": "3 5"
522
+ }));
523
+ let l = (a + o) / 2;
524
+ r(e, k(this.labels[i].toUpperCase(), l, s + 18, {
525
+ "text-anchor": "middle",
526
+ "font-size": g.stage,
527
+ "letter-spacing": "0.08em",
528
+ fill: h.axisText
529
+ }));
530
+ }
531
+ r(e, O(t, s, o + 10, s, { stroke: h.axis })), r(e, A(o + 10, s, "right")), r(e, k("Evolution", o + 6, s + 38, {
532
+ "text-anchor": "end",
533
+ "font-size": g.axis,
534
+ fill: h.axisText,
535
+ "font-style": "italic"
536
+ })), r(e, O(t, s, t, n - 10, { stroke: h.axis })), r(e, A(t, n - 10, "up"));
537
+ let l = k(this.yAxisLabel, 0, 0, {
538
+ "text-anchor": "middle",
539
+ "font-size": g.axis,
540
+ fill: h.axisText,
541
+ "font-style": "italic"
542
+ });
543
+ i(l, { transform: `translate(${t - 46}, ${(n + s) / 2}) rotate(-90)` }), r(e, l), r(e, k("visible", t - 10, n + 11, {
544
+ "text-anchor": "end",
545
+ "font-size": g.stage,
546
+ fill: h.axisText
547
+ })), r(e, k("invisible", t - 10, s - 2, {
548
+ "text-anchor": "end",
549
+ "font-size": g.stage,
550
+ fill: h.axisText
551
+ }));
552
+ }
553
+ };
554
+ function D(e, t, n, r, a) {
555
+ return i(o("rect"), {
556
+ x: e,
557
+ y: t,
558
+ width: n,
559
+ height: r,
560
+ "stroke-width": 1,
561
+ ...a
562
+ });
563
+ }
564
+ function O(e, t, n, r, a) {
565
+ return i(o("line"), {
566
+ x1: e,
567
+ y1: t,
568
+ x2: n,
569
+ y2: r,
570
+ "stroke-width": 1,
571
+ ...a
572
+ });
573
+ }
574
+ function k(e, t, n, r) {
575
+ let a = i(o("text"), {
576
+ x: t,
577
+ y: n,
578
+ "font-family": g.family,
579
+ ...r
580
+ });
581
+ return a.textContent = e, a;
582
+ }
583
+ function A(e, t, n) {
584
+ let r = n === "right" ? `${e - 5},${t - 5} ${e + 2},${t} ${e - 5},${t + 5}` : `${e - 5},${t + 5} ${e},${t - 2} ${e + 5},${t + 5}`;
585
+ return i(o("polygon"), {
586
+ points: r,
587
+ fill: h.axis
588
+ });
589
+ }
590
+ //#endregion
591
+ //#region src/evolution-grid/EvolutionConstraintBehavior.ts
592
+ var j = [
593
+ "shape.move",
594
+ "shape.create",
595
+ "shape.resize",
596
+ "elements.move",
597
+ "elements.create"
598
+ ], Oe = class extends f {
599
+ grid;
600
+ static $inject = ["eventBus", "evolutionGrid"];
601
+ constructor(e, t) {
602
+ super(e), this.grid = t;
603
+ let n = (e) => this.syncAll(e.context);
604
+ this.postExecuted(j, n), this.reverted(j, n);
605
+ }
606
+ syncAll(e) {
607
+ if (!e) return;
608
+ let t = [
609
+ ...e.shape ? [e.shape] : [],
610
+ ...e.shapes ?? [],
611
+ ...e.elements ?? []
612
+ ];
613
+ for (let e of t) b(e) && this.syncFromGeometry(e);
614
+ }
615
+ syncFromGeometry(e) {
616
+ let t = e.y + e.height / 2;
617
+ if (e.wardleyType === "pipeline") {
618
+ let n = this.grid.fromCanvas({
619
+ x: e.x,
620
+ y: t
621
+ }), r = this.grid.fromCanvas({
622
+ x: e.x + e.width,
623
+ y: t
624
+ });
625
+ e.evolutionStart = n.evolution, e.evolutionEnd = Math.max(r.evolution, n.evolution + .001), e.evolution = (e.evolutionStart + e.evolutionEnd) / 2, e.visibility = n.visibility;
626
+ return;
627
+ }
628
+ if (e.wardleyType === "attitude") {
629
+ let t = this.grid.fromCanvas({
630
+ x: e.x,
631
+ y: e.y
632
+ });
633
+ e.evolution = t.evolution, e.visibility = t.visibility;
634
+ return;
635
+ }
636
+ let n = this.grid.fromCanvas({
637
+ x: e.x + e.width / 2,
638
+ y: t
639
+ });
640
+ e.evolution = n.evolution, e.visibility = n.visibility;
641
+ }
642
+ }, M = { evolutionGrid: ["type", E] }, ke = {
643
+ __init__: ["evolutionConstraintBehavior"],
644
+ __depends__: [M],
645
+ evolutionConstraintBehavior: ["type", Oe]
646
+ }, N = "M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z", Ae = "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z", je = "M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z", Me = "M15.5 5H11l5 7-5 7h4.5l5-7zM8.5 5H4l5 7-5 7h4.5l5-7z", Ne = "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.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z", P = "M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z", Pe = "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z", Fe = "M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z", Ie = "M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z", Le = "M4 7v2c0 .55-.45 1-1 1H2v2h1c.55 0 1 .45 1 1v2c0 1.65 1.35 3 3 3h1v-2H7c-.55 0-1-.45-1-1v-2c0-.84-.35-1.61-.92-2.18L4.85 12l.23-.82C5.65 10.61 6 9.84 6 9V7c0-.55.45-1 1-1h1V4H7C5.35 4 4 5.35 4 7zm16 3c-.55 0-1-.45-1-1V7c0-1.65-1.35-3-3-3h-1v2h1c.55 0 1 .45 1 1v2c0 .84.35 1.61.92 2.18l.23.82-.23.82c-.57.57-.92 1.34-.92 2.18v2c0 .55-.45 1-1 1h-1v2h1c1.65 0 3-1.35 3-3v-2c0-.55.45-1 1-1h1v-2h-1z", Re = "M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z", ze = "M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z", Be = "M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81 1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05.21-.08.43-.08.65 0 1.61 1.31 2.92 2.92 2.92s2.92-1.31 2.92-2.92-1.31-2.92-2.92-2.92z", Ve = "M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z", He = "M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z", Ue = "M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 14h-3v3h-2v-3H8v-2h3v-3h2v3h3v2zm-3-7V3.5L18.5 9H13z", We = "M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z", Ge = "M12 2C6.49 2 2 6.49 2 12s4.49 10 10 10c1.38 0 2.5-1.12 2.5-2.5 0-.61-.23-1.2-.64-1.67-.08-.1-.13-.21-.13-.33 0-.28.22-.5.5-.5H16c3.31 0 6-2.69 6-6 0-4.96-4.49-9-10-9zm-5.5 9c-.83 0-1.5-.67-1.5-1.5S5.67 8 6.5 8 8 8.67 8 9.5 7.33 11 6.5 11zm3-4C8.67 7 8 6.33 8 5.5S8.67 4 9.5 4s1.5.67 1.5 1.5S10.33 7 9.5 7zm5 0c-.83 0-1.5-.67-1.5-1.5S13.67 4 14.5 4s1.5.67 1.5 1.5S15.33 7 14.5 7zm3 4c-.83 0-1.5-.67-1.5-1.5S16.67 8 17.5 8s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z", Ke = "M19 12h-2v3h-3v2h5v-5zM7 9h3V7H5v5h2V9zm14-6H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16.01H3V4.99h18v14.02z", qe = "M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z", Je = "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z", Ye = "M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z";
647
+ function Xe(e, t, n, a, s) {
648
+ let c = o("g"), l = a / 24;
649
+ return i(c, {
650
+ transform: `translate(${t - a / 2}, ${n - a / 2}) scale(${l})`,
651
+ fill: s,
652
+ stroke: "none"
653
+ }), r(c, i(o("path"), { d: e })), c;
654
+ }
655
+ function Ze(e, t = 18) {
656
+ return `<svg viewBox="0 0 24 24" width="${t}" height="${t}" fill="currentColor" aria-hidden="true"><path d="${e}"/></svg>`;
657
+ }
658
+ //#endregion
659
+ //#region src/draw/WardleyRenderer.ts
660
+ var Qe = 1500, $e = class extends ee {
661
+ grid;
662
+ static $inject = ["eventBus", "evolutionGrid"];
663
+ constructor(e, t) {
664
+ super(e, Qe), this.grid = t;
665
+ }
666
+ canRender(e) {
667
+ return b(e) || x(e);
668
+ }
669
+ drawShape(e, t) {
670
+ let n = t;
671
+ switch (n.wardleyType) {
672
+ case "pipeline": return this.drawPipeline(e, n);
673
+ case "anchor": return this.drawAnchor(e, n);
674
+ case "note": return this.drawNote(e, n);
675
+ case "attitude": return this.drawAttitude(e, n);
676
+ case "annotation": return this.drawAnnotation(e, n);
677
+ case "accelerator": return this.drawAccelerator(e, n);
678
+ case "submap": return this.drawSubmap(e, n);
679
+ default: return this.drawComponent(e, n);
680
+ }
681
+ }
682
+ drawConnection(e, t) {
683
+ let n = t, a = n.wardleyType === "flow", s = a ? h.flow : h.dependency, [c, l] = nt(n), u = i(o("polyline"), {
684
+ points: `${c.x},${c.y} ${l.x},${l.y}`,
685
+ fill: "none",
686
+ stroke: s,
687
+ "stroke-width": a ? 2.5 : 1.5,
688
+ "stroke-linecap": "round"
689
+ });
690
+ r(e, u), r(e, L(c, l, s, a ? 11 : 9, a ? 5 : 4)), a && n.bidirectional && r(e, L(l, c, s, 11, 5));
691
+ let d = (c.x + l.x) / 2, f = (c.y + l.y) / 2;
692
+ return a && n.flowValue && r(e, I(n.flowValue, d, f - 5, {
693
+ "text-anchor": "middle",
694
+ "font-size": 11,
695
+ fill: h.flow
696
+ })), n.linkLabel && r(e, I(n.linkLabel, d, f + (n.flowValue ? 12 : -4), {
697
+ "text-anchor": "middle",
698
+ "font-size": 11,
699
+ "font-style": "italic",
700
+ fill: h.axisText
701
+ })), u;
702
+ }
703
+ getShapePath(e) {
704
+ let { x: t, y: n, width: r, height: i } = e;
705
+ return `M${t},${n}l${r},0l0,${i}l${-r},0z`;
706
+ }
707
+ getConnectionPath(e) {
708
+ let [t, ...n] = e.waypoints;
709
+ return t ? `M${t.x},${t.y}` + n.map((e) => `L${e.x},${e.y}`).join("") : "";
710
+ }
711
+ drawComponent(e, t) {
712
+ let n = t.width / 2, i = t.height / 2, a = !!t.movement, o = t.decorators;
713
+ if (t.movement) {
714
+ let a = this.grid.toCanvas({
715
+ visibility: t.visibility,
716
+ evolution: t.evolution
717
+ }), o = this.grid.toCanvas({
718
+ visibility: t.visibility,
719
+ evolution: t.movement.targetEvolution
720
+ }).x - a.x;
721
+ r(e, et(n, i, n + o, i, {
722
+ stroke: h.movement,
723
+ "stroke-width": 1.5
724
+ })), r(e, L({
725
+ x: n,
726
+ y: i
727
+ }, {
728
+ x: n + o,
729
+ y: i
730
+ }, h.movement)), r(e, F(n + o, i, 15, {
731
+ fill: h.paper,
732
+ stroke: h.movement,
733
+ "stroke-width": 2,
734
+ class: "wardley-evolve-handle"
735
+ }));
736
+ }
737
+ if (o?.inertia) {
738
+ let t = n + 15 + 3;
739
+ r(e, et(t, i - 13, t, i + 13, {
740
+ stroke: h.inertia,
741
+ "stroke-width": 3,
742
+ "stroke-linecap": "round"
743
+ }));
744
+ }
745
+ let s = F(n, i, 15, {
746
+ fill: h.componentFill,
747
+ stroke: h.stroke,
748
+ "stroke-width": 2
749
+ });
750
+ return r(e, s), a && r(e, F(n, i, 12, {
751
+ fill: "none",
752
+ stroke: h.stroke,
753
+ "stroke-width": 1.5
754
+ })), o?.ecosystem ? r(e, F(n, i, 4.5, {
755
+ fill: "none",
756
+ stroke: h.stroke,
757
+ "stroke-width": 1.5
758
+ })) : o?.market && r(e, F(n, i, 3, { fill: h.stroke })), r(e, I(t.wardleyLabel, n + 15 + 7, i - 4, { "font-weight": "500" })), o?.method && r(e, I(o.method, n + 15 + 7, i + 11, {
759
+ "font-size": 10.5,
760
+ fill: h.axisText
761
+ })), s;
762
+ }
763
+ drawAnchor(e, t) {
764
+ let n = t.width / 2, i = t.height / 2, a = Xe(N, n, i, 26, h.ink);
765
+ return r(e, a), r(e, I(t.wardleyLabel, n, i - 26 / 2 - 4, {
766
+ "text-anchor": "middle",
767
+ "font-weight": "700"
768
+ })), a;
769
+ }
770
+ drawPipeline(e, t) {
771
+ let n = i(o("rect"), {
772
+ x: 0,
773
+ y: 0,
774
+ width: Math.max(t.width, 1),
775
+ height: Math.max(t.height, 1),
776
+ rx: 4,
777
+ fill: h.accentSoft,
778
+ stroke: h.pipeline,
779
+ "stroke-width": 1.25,
780
+ "stroke-dasharray": "6 3"
781
+ });
782
+ return r(e, n), r(e, I(t.wardleyLabel, 4, -6, { "font-weight": "500" })), n;
783
+ }
784
+ drawNote(e, t) {
785
+ let n = t.color, i = (t.wardleyLabel ?? "").split("\n"), a = t.width / 2, s = t.height / 2 - (i.length - 1) * 17 / 2 + 4, c = {
786
+ "text-anchor": "middle",
787
+ fill: n ?? h.noteText,
788
+ "font-style": "italic",
789
+ ...n ? { "font-weight": "600" } : {}
790
+ }, l;
791
+ return i.forEach((t, n) => {
792
+ let i = I(t, a, s + n * 17, c);
793
+ r(e, i), l ||= i;
794
+ }), l ?? o("text");
795
+ }
796
+ drawAttitude(e, t) {
797
+ let n = Se[t.attitudeKind ?? "pioneers"] ?? {
798
+ fill: "rgba(0,0,0,0.05)",
799
+ stroke: "#666666"
800
+ }, a = i(o("rect"), {
801
+ x: 0,
802
+ y: 0,
803
+ width: Math.max(t.width, 1),
804
+ height: Math.max(t.height, 1),
805
+ rx: 10,
806
+ fill: n.fill,
807
+ stroke: n.stroke,
808
+ "stroke-width": 1.25,
809
+ "stroke-dasharray": "5 4"
810
+ });
811
+ return r(e, a), r(e, I(rt(t.attitudeKind ?? t.wardleyLabel), 10, 18, {
812
+ fill: n.stroke,
813
+ "font-weight": "700",
814
+ "letter-spacing": "0.04em"
815
+ })), a;
816
+ }
817
+ drawAnnotation(e, t) {
818
+ let n = t.width / 2, i = t.height / 2, a = F(n, i, 10, {
819
+ fill: "#fff8e6",
820
+ stroke: h.stroke,
821
+ "stroke-width": 1.25
822
+ });
823
+ return r(e, a), r(e, I(String(t.annotationNumber ?? ""), n, i + 4, {
824
+ "text-anchor": "middle",
825
+ "font-size": 11,
826
+ "font-weight": "700"
827
+ }, !1)), t.wardleyLabel && r(e, I(t.wardleyLabel, n + 15, i + 4, {
828
+ "font-size": 12,
829
+ fill: h.noteText
830
+ })), a;
831
+ }
832
+ drawAccelerator(e, t) {
833
+ let n = t.width / 2, i = t.height / 2, a = t.acceleratorDirection !== "deaccelerate", o = I(a ? "»" : "«", n, i + 6, {
834
+ "text-anchor": "middle",
835
+ "font-size": 19,
836
+ "font-weight": "700",
837
+ fill: a ? h.flow : h.movement
838
+ });
839
+ return r(e, o), t.wardleyLabel && r(e, I(t.wardleyLabel, n + 11, i + 6, { "font-size": 12 })), o;
840
+ }
841
+ drawSubmap(e, t) {
842
+ let n = t.width / 2, a = t.height / 2, s = i(o("rect"), {
843
+ x: n - 16,
844
+ y: a - 16,
845
+ width: 32,
846
+ height: 32,
847
+ rx: 3,
848
+ fill: h.componentFill,
849
+ stroke: h.stroke,
850
+ "stroke-width": 2
851
+ });
852
+ return r(e, s), r(e, i(o("rect"), {
853
+ x: n - 16 + 3,
854
+ y: a - 16 + 3,
855
+ width: 26,
856
+ height: 26,
857
+ rx: 1.5,
858
+ fill: "none",
859
+ stroke: h.stroke,
860
+ "stroke-width": 1
861
+ })), r(e, I(t.wardleyLabel, n + 16 + 6, a - 6, { "font-weight": "500" })), s;
862
+ }
863
+ };
864
+ function F(e, t, n, r) {
865
+ return i(o("circle"), {
866
+ cx: e,
867
+ cy: t,
868
+ r: n,
869
+ "stroke-width": 1,
870
+ ...r
871
+ });
872
+ }
873
+ function et(e, t, n, r, a) {
874
+ return i(o("line"), {
875
+ x1: e,
876
+ y1: t,
877
+ x2: n,
878
+ y2: r,
879
+ ...a
880
+ });
881
+ }
882
+ function I(e, t, n, r = {}, a = !0) {
883
+ let s = a ? {
884
+ stroke: h.paper,
885
+ "stroke-width": 3.5,
886
+ "paint-order": "stroke",
887
+ "stroke-linejoin": "round"
888
+ } : {}, c = i(o("text"), {
889
+ x: t,
890
+ y: n,
891
+ "font-family": g.family,
892
+ "font-size": g.label,
893
+ fill: h.ink,
894
+ ...s,
895
+ ...r
896
+ });
897
+ return c.textContent = e, c;
898
+ }
899
+ function L(e, t, n, r = 10, a = 5) {
900
+ let s = Math.atan2(t.y - e.y, t.x - e.x), c = t.x - r * Math.cos(s), l = t.y - r * Math.sin(s), u = `${t.x},${t.y} ${c - a * Math.sin(s)},${l + a * Math.cos(s)} ${c + a * Math.sin(s)},${l - a * Math.cos(s)}`;
901
+ return i(o("polygon"), {
902
+ points: u,
903
+ fill: n
904
+ });
905
+ }
906
+ function tt(e) {
907
+ return e.wardleyType === "component" ? 17 : e.wardleyType === "anchor" ? 14 : Math.min(e.width, e.height) / 2;
908
+ }
909
+ function nt(e) {
910
+ let t = e.source, n = e.target, r = e.waypoints;
911
+ if (!t || !n) {
912
+ let e = r[0] ?? {
913
+ x: 0,
914
+ y: 0
915
+ };
916
+ return [e, r[r.length - 1] ?? e];
917
+ }
918
+ let i = {
919
+ x: t.x + t.width / 2,
920
+ y: t.y + t.height / 2
921
+ }, a = {
922
+ x: n.x + n.width / 2,
923
+ y: n.y + n.height / 2
924
+ }, o = a.x - i.x, s = a.y - i.y, c = Math.hypot(o, s) || 1, l = o / c, u = s / c, d = tt(t), f = tt(n);
925
+ return c <= d + f + 2 ? [i, a] : [{
926
+ x: i.x + l * d,
927
+ y: i.y + u * d
928
+ }, {
929
+ x: a.x - l * f,
930
+ y: a.y - u * f
931
+ }];
932
+ }
933
+ function rt(e) {
934
+ return e && e.charAt(0).toUpperCase() + e.slice(1);
935
+ }
936
+ //#endregion
937
+ //#region src/draw/index.ts
938
+ var it = {
939
+ __init__: ["wardleyRenderer"],
940
+ wardleyRenderer: ["type", $e]
941
+ }, at = new Set(["attitude", "pipeline"]), ot = {
942
+ attitude: 0,
943
+ pipeline: 1,
944
+ note: 2,
945
+ component: 3,
946
+ anchor: 4,
947
+ annotation: 5,
948
+ submap: 3,
949
+ accelerator: 3
950
+ }, st = class {
951
+ canvas;
952
+ elementFactory;
953
+ factory;
954
+ grid;
955
+ eventBus;
956
+ elementRegistry;
957
+ static $inject = [
958
+ "canvas",
959
+ "elementFactory",
960
+ "wardleyElementFactory",
961
+ "evolutionGrid",
962
+ "eventBus",
963
+ "elementRegistry"
964
+ ];
965
+ constructor(e, t, n, r, i, a) {
966
+ this.canvas = e, this.elementFactory = t, this.factory = n, this.grid = r, this.eventBus = i, this.elementRegistry = a;
967
+ }
968
+ import(e) {
969
+ let t = [];
970
+ this.eventBus.fire("import.render.start", { map: e }), this.grid.configure(e.config);
971
+ let n = {
972
+ config: e.config,
973
+ ...e.rawPassthrough ? { rawPassthrough: e.rawPassthrough } : {}
974
+ }, r;
975
+ try {
976
+ r = this.canvas.getRootElement();
977
+ } catch {
978
+ r = void 0;
979
+ }
980
+ let i;
981
+ r && r.id === "wardley-root" ? i = r : (i = this.elementFactory.createRoot({ id: we }), this.canvas.setRootElement(i)), i.businessObject = n, this.grid.render();
982
+ let a = /* @__PURE__ */ new Map(), o = [...e.elements].sort((e, t) => (ot[e.elementType] ?? 9) - (ot[t.elementType] ?? 9)), s = o.filter((e) => at.has(e.elementType)), c = o.filter((e) => !at.has(e.elementType)), l = 0;
983
+ for (let e of s) {
984
+ let t = this.createShape(e);
985
+ t && (this.canvas.addShape(t, i), a.set(e.id, t), l++);
986
+ }
987
+ for (let e of c) {
988
+ let t = this.createShape(e);
989
+ t && (this.canvas.addShape(t, i), a.set(e.id, t));
990
+ }
991
+ for (let n of e.edges) {
992
+ let e = a.get(n.from), r = a.get(n.to);
993
+ if (!e || !r) {
994
+ t.push({
995
+ message: `Edge ${n.id}: endpoint missing.`,
996
+ elementId: n.id
997
+ });
998
+ continue;
999
+ }
1000
+ let o = n.edgeType === "flow" ? this.factory.createFlow(n, e, r) : this.factory.createDependency(n, e, r);
1001
+ this.canvas.addConnection(o, i, l);
1002
+ }
1003
+ return this.canvas.viewbox(this.grid.outerBounds()), this.eventBus.fire("import.render.done", { warnings: t }), t;
1004
+ }
1005
+ createShape(e) {
1006
+ switch (e.elementType) {
1007
+ case "component": return this.factory.createComponent(e);
1008
+ case "anchor": return this.factory.createAnchor(e);
1009
+ case "note": return this.factory.createNote(e);
1010
+ case "pipeline": return this.factory.createPipeline(e);
1011
+ case "annotation": return this.factory.createAnnotation(e);
1012
+ case "attitude": return this.factory.createAttitude(e);
1013
+ case "accelerator": return this.factory.createAccelerator(e);
1014
+ case "submap": return this.factory.createSubmap(e);
1015
+ default: return;
1016
+ }
1017
+ }
1018
+ clear() {
1019
+ for (let e of [...this.elementRegistry.getAll()]) {
1020
+ let t = e;
1021
+ if (t.id !== "wardley-root") try {
1022
+ t.waypoints ? this.canvas.removeConnection(t.id) : this.canvas.removeShape(t.id);
1023
+ } catch {}
1024
+ }
1025
+ }
1026
+ };
1027
+ //#endregion
1028
+ //#region src/io/WardleyExporter.ts
1029
+ function R(e) {
1030
+ let t = {};
1031
+ for (let [n, r] of Object.entries(e)) r !== void 0 && (t[n] = r);
1032
+ return t;
1033
+ }
1034
+ var ct = class {
1035
+ elementRegistry;
1036
+ canvas;
1037
+ static $inject = ["elementRegistry", "canvas"];
1038
+ constructor(e, t) {
1039
+ this.elementRegistry = e, this.canvas = t;
1040
+ }
1041
+ export() {
1042
+ let e = this.canvas.getRootElement().businessObject, t = e?.config ?? { title: "Untitled Map" }, n = [], r = [];
1043
+ for (let e of this.elementRegistry.getAll()) if (e.id !== "wardley-root") {
1044
+ if (x(e)) if (e.businessObject) r.push(e.businessObject);
1045
+ else {
1046
+ let t = {
1047
+ id: e.id,
1048
+ from: e.source?.id ?? "",
1049
+ to: e.target?.id ?? ""
1050
+ };
1051
+ r.push(e.wardleyType === "flow" ? {
1052
+ ...t,
1053
+ edgeType: "flow",
1054
+ ...e.bidirectional ? { bidirectional: !0 } : {}
1055
+ } : {
1056
+ ...t,
1057
+ edgeType: "dependency"
1058
+ });
1059
+ }
1060
+ else if (b(e)) {
1061
+ let t = this.buildElement(e);
1062
+ t && n.push(t);
1063
+ }
1064
+ }
1065
+ return d({
1066
+ schemaVersion: s,
1067
+ config: t,
1068
+ elements: n,
1069
+ edges: r,
1070
+ ...e?.rawPassthrough ? { rawPassthrough: e.rawPassthrough } : {}
1071
+ });
1072
+ }
1073
+ buildElement(e) {
1074
+ let t = {
1075
+ visibility: e.visibility,
1076
+ evolution: e.evolution
1077
+ }, n = e.businessObject;
1078
+ switch (e.wardleyType) {
1079
+ case "component": return R({
1080
+ id: e.id,
1081
+ elementType: "component",
1082
+ label: e.wardleyLabel,
1083
+ position: t,
1084
+ decorators: e.decorators,
1085
+ movement: e.movement,
1086
+ pipelineId: n?.pipelineId
1087
+ });
1088
+ case "anchor": return {
1089
+ id: e.id,
1090
+ elementType: "anchor",
1091
+ label: e.wardleyLabel,
1092
+ position: t
1093
+ };
1094
+ case "note": return R({
1095
+ id: e.id,
1096
+ elementType: "note",
1097
+ label: e.wardleyLabel,
1098
+ position: t,
1099
+ patternType: n?.patternType,
1100
+ color: e.color
1101
+ });
1102
+ case "pipeline": return {
1103
+ id: e.id,
1104
+ elementType: "pipeline",
1105
+ label: e.wardleyLabel,
1106
+ position: t,
1107
+ evolutionStart: e.evolutionStart ?? 0,
1108
+ evolutionEnd: e.evolutionEnd ?? 1,
1109
+ childIds: n?.childIds ?? []
1110
+ };
1111
+ case "attitude": return {
1112
+ id: e.id,
1113
+ elementType: "attitude",
1114
+ kind: e.attitudeKind ?? "pioneers",
1115
+ label: e.wardleyLabel,
1116
+ position: t,
1117
+ width: e.width,
1118
+ height: e.height
1119
+ };
1120
+ case "accelerator": return {
1121
+ id: e.id,
1122
+ elementType: "accelerator",
1123
+ direction: e.acceleratorDirection ?? "accelerate",
1124
+ label: e.wardleyLabel,
1125
+ position: t
1126
+ };
1127
+ case "annotation": return {
1128
+ id: e.id,
1129
+ elementType: "annotation",
1130
+ label: e.wardleyLabel,
1131
+ position: t,
1132
+ number: e.annotationNumber ?? 0,
1133
+ positions: [t],
1134
+ text: e.wardleyLabel
1135
+ };
1136
+ case "submap": return R({
1137
+ id: e.id,
1138
+ elementType: "submap",
1139
+ label: e.wardleyLabel,
1140
+ position: t,
1141
+ urlRef: n?.urlRef
1142
+ });
1143
+ default: return e.wardleyType, n ? {
1144
+ ...n,
1145
+ position: t
1146
+ } : void 0;
1147
+ }
1148
+ }
1149
+ }, lt = {
1150
+ wardleyImporter: ["type", st],
1151
+ wardleyExporter: ["type", ct]
1152
+ }, ut = class extends Ee {
1153
+ _getModules() {
1154
+ return [
1155
+ w,
1156
+ M,
1157
+ it,
1158
+ lt
1159
+ ];
1160
+ }
1161
+ }, dt = 180, ft = 80, pt = 120, mt = .5, ht = (e, t, n) => e < t ? t : e > n ? n : e;
1162
+ function gt(e, t, n, r) {
1163
+ return t <= r ? ht(e, n, n + r - t) : n + r / 2 - t / 2;
1164
+ }
1165
+ var _t = class {
1166
+ canvas;
1167
+ grid;
1168
+ static $inject = [
1169
+ "eventBus",
1170
+ "canvas",
1171
+ "evolutionGrid"
1172
+ ];
1173
+ applying = !1;
1174
+ constructor(e, t, n) {
1175
+ this.canvas = t, this.grid = n, e.on("canvas.viewbox.changed", (e) => {
1176
+ this.applying || this.constrain(e?.viewbox);
1177
+ });
1178
+ }
1179
+ constrain(e) {
1180
+ let t = e ?? this.canvas.viewbox(), n = this.grid.outerBounds();
1181
+ if (!(n.width > 0) || !(n.height > 0) || !(t.width > 0) || !(t.height > 0)) return;
1182
+ let r = gt(t.x, t.width, n.x - pt, n.width + 2 * pt), i = gt(t.y, t.height, n.y - dt, n.height + dt + ft);
1183
+ if (!(Math.abs(r - t.x) < mt && Math.abs(i - t.y) < mt)) {
1184
+ this.applying = !0;
1185
+ try {
1186
+ this.canvas.viewbox({
1187
+ x: r,
1188
+ y: i,
1189
+ width: t.width,
1190
+ height: t.height
1191
+ });
1192
+ } finally {
1193
+ this.applying = !1;
1194
+ }
1195
+ }
1196
+ }
1197
+ }, vt = {
1198
+ __init__: ["panConstraint"],
1199
+ panConstraint: ["type", _t]
1200
+ }, yt = class extends ut {
1201
+ _getModules() {
1202
+ return [
1203
+ ...super._getModules(),
1204
+ te,
1205
+ ne,
1206
+ re,
1207
+ ie,
1208
+ vt
1209
+ ];
1210
+ }
1211
+ };
1212
+ //#endregion
1213
+ //#region src/modeling/cmd/UpdatePropertiesHandler.ts
1214
+ function bt(e, t, n) {
1215
+ n === void 0 ? delete e[t] : e[t] = n;
1216
+ }
1217
+ var xt = class {
1218
+ execute(e) {
1219
+ let { element: t, properties: n } = e, r = t, i = {};
1220
+ for (let e of Object.keys(n)) i[e] = r[e], bt(r, e, n[e]);
1221
+ return e.oldProperties = i, [t];
1222
+ }
1223
+ revert(e) {
1224
+ let { element: t, oldProperties: n } = e, r = t;
1225
+ if (n) for (let e of Object.keys(n)) bt(r, e, n[e]);
1226
+ return [t];
1227
+ }
1228
+ }, St = "element.updateProperties";
1229
+ function Ct(e) {
1230
+ let t = {};
1231
+ for (let [n, r] of Object.entries(e)) r !== void 0 && (t[n] = r);
1232
+ return t;
1233
+ }
1234
+ var wt = class {
1235
+ commandStack;
1236
+ static $inject = ["commandStack"];
1237
+ constructor(e) {
1238
+ this.commandStack = e, e.registerHandler(St, xt);
1239
+ }
1240
+ updateProperties(e, t) {
1241
+ this.commandStack.execute(St, {
1242
+ element: e,
1243
+ properties: t
1244
+ });
1245
+ }
1246
+ updateLabel(e, t) {
1247
+ if (e.wardleyType === "note") {
1248
+ let { width: n, height: r } = m(t), i = e.x + e.width / 2, a = e.y + e.height / 2;
1249
+ this.updateProperties(e, {
1250
+ wardleyLabel: t,
1251
+ width: n,
1252
+ height: r,
1253
+ x: i - n / 2,
1254
+ y: a - r / 2
1255
+ });
1256
+ return;
1257
+ }
1258
+ this.updateProperties(e, { wardleyLabel: t });
1259
+ }
1260
+ evolveComponent(e, t, n = {}) {
1261
+ this.updateProperties(e, { movement: Ct({
1262
+ targetEvolution: Tt(t),
1263
+ newLabel: n.newLabel,
1264
+ method: n.method
1265
+ }) });
1266
+ }
1267
+ clearMovement(e) {
1268
+ this.updateProperties(e, { movement: void 0 });
1269
+ }
1270
+ toggleInertia(e) {
1271
+ let t = { ...e.decorators ?? {} };
1272
+ t.inertia ? delete t.inertia : t.inertia = !0, this.updateProperties(e, { decorators: Object.keys(t).length ? t : void 0 });
1273
+ }
1274
+ setMethod(e, t) {
1275
+ let n = { ...e.decorators ?? {} };
1276
+ t ? n.method = t : delete n.method, this.updateProperties(e, { decorators: Object.keys(n).length ? n : void 0 });
1277
+ }
1278
+ setMarketEcosystem(e, t) {
1279
+ let n = { ...e.decorators ?? {} };
1280
+ delete n.market, delete n.ecosystem, t && (n[t] = !0), this.updateProperties(e, { decorators: Object.keys(n).length ? n : void 0 });
1281
+ }
1282
+ setColor(e, t) {
1283
+ this.updateProperties(e, { color: t });
1284
+ }
1285
+ };
1286
+ function Tt(e) {
1287
+ return e < 0 ? 0 : e > 1 ? 1 : e;
1288
+ }
1289
+ //#endregion
1290
+ //#region src/modeling/index.ts
1291
+ var Et = {
1292
+ __init__: ["wardleyModeling"],
1293
+ wardleyModeling: ["type", wt]
1294
+ }, Dt = new Set(["component", "anchor"]);
1295
+ function z(e) {
1296
+ return b(e) && Dt.has(e.wardleyType);
1297
+ }
1298
+ var Ot = class extends he {
1299
+ static $inject = ["eventBus"];
1300
+ constructor(e) {
1301
+ super(e);
1302
+ }
1303
+ init() {
1304
+ this.addRule("connection.start", (e) => z(e.source)), this.addRule("connection.create", (e) => {
1305
+ let { source: t, target: n } = e;
1306
+ return !z(t) || !z(n) || t === n ? !1 : { wardleyType: "dependency" };
1307
+ }), this.addRule(["shape.move", "elements.move"], () => !0), this.addRule("shape.create", () => !0), this.addRule("shape.resize", (e) => C(e.shape));
1308
+ }
1309
+ }, kt = {
1310
+ __init__: ["wardleyRules"],
1311
+ wardleyRules: ["type", Ot]
1312
+ }, At = 8, jt = {
1313
+ __init__: ["stageSnapping"],
1314
+ stageSnapping: ["type", class {
1315
+ static $inject = ["eventBus", "evolutionGrid"];
1316
+ constructor(e, t) {
1317
+ e.on([
1318
+ "shape.move.move",
1319
+ "shape.move.end",
1320
+ "create.move",
1321
+ "create.end",
1322
+ "shape.resize.move",
1323
+ "shape.resize.end"
1324
+ ], 1500, (e) => {
1325
+ if (e.originalEvent?.shiftKey || typeof e.x != "number") return;
1326
+ let n = t.getBoundaries().map((e) => t.toCanvas({
1327
+ visibility: .5,
1328
+ evolution: e
1329
+ }).x);
1330
+ for (let t of n) if (Math.abs(e.x - t) <= At) {
1331
+ e.x = t;
1332
+ break;
1333
+ }
1334
+ });
1335
+ }
1336
+ }]
1337
+ }, B = (e) => `<svg width="24" height="24" viewBox="0 0 24 24" class="wardley-palette-svg">${e}</svg>`, V = (e = "") => `<circle cx="12" cy="12" r="7" fill="${h.componentFill}" stroke="${h.stroke}" stroke-width="2"/>${e}`, H = (e, t) => `<text x="12" text-anchor="middle" font-family="${g.family}" ${t}>${e}</text>`, U = {
1338
+ component: B(V()),
1339
+ market: B(V(`<circle cx="12" cy="12" r="2.6" fill="${h.stroke}"/>`)),
1340
+ ecosystem: B(V(`<circle cx="12" cy="12" r="4" fill="none" stroke="${h.stroke}" stroke-width="1.5"/>`)),
1341
+ anchor: B(`<path d="${N}" fill="${h.ink}"/>`),
1342
+ pipeline: B(`<rect x="2" y="8" width="20" height="8" rx="3" fill="${h.accentSoft}" stroke="${h.pipeline}" stroke-width="1.5" stroke-dasharray="3 2"/>`),
1343
+ note: B(`<g stroke="${h.noteText}" stroke-width="1.5" stroke-linecap="round"><line x1="5" y1="8" x2="19" y2="8"/><line x1="5" y1="12" x2="19" y2="12"/><line x1="5" y1="16" x2="13" y2="16"/></g>`),
1344
+ annotation: B(`<circle cx="12" cy="12" r="8" fill="#fff8e6" stroke="${h.stroke}" stroke-width="1.25"/>` + H("1", `y="16" font-size="11" font-weight="700" fill="${h.stroke}"`)),
1345
+ accelerator: B(H("»", `y="17.5" font-size="19" font-weight="700" fill="${h.flow}"`)),
1346
+ deaccelerator: B(H("«", `y="17.5" font-size="19" font-weight="700" fill="${h.movement}"`)),
1347
+ submap: B(`<rect x="4" y="4" width="16" height="16" rx="3" fill="${h.componentFill}" stroke="${h.stroke}" stroke-width="2"/><rect x="7.5" y="7.5" width="9" height="9" rx="1.5" fill="none" stroke="${h.stroke}" stroke-width="1"/>`)
1348
+ };
1349
+ function W(e) {
1350
+ let t = Se[e] ?? {
1351
+ fill: "rgba(0,0,0,0.05)",
1352
+ stroke: "#666666"
1353
+ };
1354
+ return B(`<rect x="2" y="6" width="20" height="12" rx="3" fill="${t.fill}" stroke="${t.stroke}" stroke-width="1.5" stroke-dasharray="3 2"/>`);
1355
+ }
1356
+ //#endregion
1357
+ //#region src/palette/WardleyPaletteProvider.ts
1358
+ var G = "wardley-1-blocks", K = "wardley-2-strategy", Mt = "wardley-3-notes", Nt = [
1359
+ {
1360
+ key: "component",
1361
+ type: "component",
1362
+ label: "Component",
1363
+ title: "Component",
1364
+ icon: U.component,
1365
+ group: G
1366
+ },
1367
+ {
1368
+ key: "market",
1369
+ type: "component",
1370
+ label: "Market",
1371
+ title: "Market component",
1372
+ icon: U.market,
1373
+ group: G,
1374
+ extra: { market: !0 }
1375
+ },
1376
+ {
1377
+ key: "ecosystem",
1378
+ type: "component",
1379
+ label: "Ecosystem",
1380
+ title: "Ecosystem component",
1381
+ icon: U.ecosystem,
1382
+ group: G,
1383
+ extra: { ecosystem: !0 }
1384
+ },
1385
+ {
1386
+ key: "anchor",
1387
+ type: "anchor",
1388
+ label: "User",
1389
+ title: "Anchor / User",
1390
+ icon: U.anchor,
1391
+ group: G
1392
+ },
1393
+ {
1394
+ key: "pipeline",
1395
+ type: "pipeline",
1396
+ label: "Pipeline",
1397
+ title: "Pipeline",
1398
+ icon: U.pipeline,
1399
+ group: G
1400
+ },
1401
+ {
1402
+ key: "submap",
1403
+ type: "submap",
1404
+ label: "Submap",
1405
+ title: "Submap",
1406
+ icon: U.submap,
1407
+ group: G
1408
+ },
1409
+ {
1410
+ key: "pioneers",
1411
+ type: "attitude",
1412
+ label: "Pioneers",
1413
+ title: "Pioneers region",
1414
+ icon: W("pioneers"),
1415
+ group: K,
1416
+ extra: { attitudeKind: "pioneers" }
1417
+ },
1418
+ {
1419
+ key: "settlers",
1420
+ type: "attitude",
1421
+ label: "Settlers",
1422
+ title: "Settlers region",
1423
+ icon: W("settlers"),
1424
+ group: K,
1425
+ extra: { attitudeKind: "settlers" }
1426
+ },
1427
+ {
1428
+ key: "townplanners",
1429
+ type: "attitude",
1430
+ label: "Town Planners",
1431
+ title: "Town Planners region",
1432
+ icon: W("townplanners"),
1433
+ group: K,
1434
+ extra: { attitudeKind: "townplanners" }
1435
+ },
1436
+ {
1437
+ key: "accelerator",
1438
+ type: "accelerator",
1439
+ label: "Accelerate",
1440
+ title: "Accelerator",
1441
+ icon: U.accelerator,
1442
+ group: K,
1443
+ extra: { acceleratorDirection: "accelerate" }
1444
+ },
1445
+ {
1446
+ key: "deaccelerator",
1447
+ type: "accelerator",
1448
+ label: "Deaccelerate",
1449
+ title: "Deaccelerator",
1450
+ icon: U.deaccelerator,
1451
+ group: K,
1452
+ extra: { acceleratorDirection: "deaccelerate" }
1453
+ },
1454
+ {
1455
+ key: "note",
1456
+ type: "note",
1457
+ label: "Note",
1458
+ title: "Note",
1459
+ icon: U.note,
1460
+ group: Mt
1461
+ },
1462
+ {
1463
+ key: "annotation",
1464
+ type: "annotation",
1465
+ label: "Annotation",
1466
+ title: "Annotation (numbered marker)",
1467
+ icon: U.annotation,
1468
+ group: Mt,
1469
+ extra: { annotationNumber: 1 }
1470
+ }
1471
+ ], Pt = {
1472
+ __init__: ["wardleyPaletteProvider"],
1473
+ wardleyPaletteProvider: ["type", class {
1474
+ create;
1475
+ factory;
1476
+ static $inject = [
1477
+ "palette",
1478
+ "create",
1479
+ "wardleyElementFactory"
1480
+ ];
1481
+ constructor(e, t, n) {
1482
+ this.create = t, this.factory = n, e.registerProvider(this);
1483
+ }
1484
+ getPaletteEntries() {
1485
+ let e = {};
1486
+ for (let t of Nt) {
1487
+ let n = (e) => {
1488
+ let n = this.factory.createNew(t.type, t.label, t.extra ?? {});
1489
+ this.create.start(e, n);
1490
+ };
1491
+ e[`create.${t.key}`] = {
1492
+ group: t.group,
1493
+ title: t.title,
1494
+ html: `<div class="entry wardley-palette-entry" draggable="true" title="${t.title}">${t.icon}</div>`,
1495
+ action: {
1496
+ dragstart: n,
1497
+ click: n
1498
+ }
1499
+ };
1500
+ }
1501
+ return e;
1502
+ }
1503
+ }]
1504
+ }, q = "wardley-element-settings", J = {
1505
+ id: "type",
1506
+ name: "Type"
1507
+ }, Y = {
1508
+ id: "method",
1509
+ name: "Sourcing"
1510
+ }, Ft = {
1511
+ id: "props",
1512
+ name: "Properties"
1513
+ };
1514
+ function X(e, t) {
1515
+ return e ? `✓ ${t}` : t;
1516
+ }
1517
+ var It = class {
1518
+ modeling;
1519
+ static $inject = ["popupMenu", "wardleyModeling"];
1520
+ constructor(e, t) {
1521
+ this.modeling = t, e.registerProvider(q, this);
1522
+ }
1523
+ getPopupMenuEntries(e) {
1524
+ let t = Array.isArray(e) ? e[0] : e;
1525
+ return S(t) ? this.componentEntries(t) : {};
1526
+ }
1527
+ componentEntries(e) {
1528
+ let t = e.decorators ?? {}, n = t.ecosystem ? "ecosystem" : t.market ? "market" : "normal", r = t.method;
1529
+ return {
1530
+ "type-normal": {
1531
+ label: X(n === "normal", "Normal"),
1532
+ group: J,
1533
+ action: () => this.modeling.setMarketEcosystem(e, void 0)
1534
+ },
1535
+ "type-market": {
1536
+ label: X(n === "market", "Market"),
1537
+ group: J,
1538
+ action: () => this.modeling.setMarketEcosystem(e, "market")
1539
+ },
1540
+ "type-ecosystem": {
1541
+ label: X(n === "ecosystem", "Ecosystem"),
1542
+ group: J,
1543
+ action: () => this.modeling.setMarketEcosystem(e, "ecosystem")
1544
+ },
1545
+ "method-none": {
1546
+ label: X(!r, "None"),
1547
+ group: Y,
1548
+ action: () => this.modeling.setMethod(e, void 0)
1549
+ },
1550
+ "method-build": {
1551
+ label: X(r === "build", "Build"),
1552
+ group: Y,
1553
+ action: () => this.modeling.setMethod(e, "build")
1554
+ },
1555
+ "method-buy": {
1556
+ label: X(r === "buy", "Buy"),
1557
+ group: Y,
1558
+ action: () => this.modeling.setMethod(e, "buy")
1559
+ },
1560
+ "method-outsource": {
1561
+ label: X(r === "outsource", "Outsource"),
1562
+ group: Y,
1563
+ action: () => this.modeling.setMethod(e, "outsource")
1564
+ },
1565
+ "prop-inertia": {
1566
+ label: X(!!t.inertia, "Inertia"),
1567
+ group: Ft,
1568
+ action: () => this.modeling.toggleInertia(e)
1569
+ }
1570
+ };
1571
+ }
1572
+ }, Lt = {
1573
+ __init__: ["wardleyElementSettings"],
1574
+ wardleyElementSettings: ["type", It]
1575
+ };
1576
+ //#endregion
1577
+ //#region src/context-pad/WardleyContextPadProvider.ts
1578
+ function Z(e, t, n = !1) {
1579
+ return `<div class="entry wardley-cp-entry"${n ? " draggable=\"true\"" : ""} title="${t}">${Ze(e)}</div>`;
1580
+ }
1581
+ //#endregion
1582
+ //#region src/context-pad/index.ts
1583
+ var Rt = {
1584
+ __init__: ["wardleyContextPadProvider"],
1585
+ wardleyContextPadProvider: ["type", class {
1586
+ modeling;
1587
+ connect;
1588
+ create;
1589
+ popupMenu;
1590
+ wardleyModeling;
1591
+ labelEditing;
1592
+ evolveDragging;
1593
+ factory;
1594
+ colorPicker;
1595
+ static $inject = [
1596
+ "contextPad",
1597
+ "modeling",
1598
+ "connect",
1599
+ "create",
1600
+ "popupMenu",
1601
+ "wardleyModeling",
1602
+ "wardleyLabelEditing",
1603
+ "wardleyEvolveDragging",
1604
+ "wardleyElementFactory",
1605
+ "wardleyColorPicker"
1606
+ ];
1607
+ constructor(e, t, n, r, i, a, o, s, c, l) {
1608
+ this.modeling = t, this.connect = n, this.create = r, this.popupMenu = i, this.wardleyModeling = a, this.labelEditing = o, this.evolveDragging = s, this.factory = c, this.colorPicker = l, e.registerProvider(this);
1609
+ }
1610
+ getContextPadEntries(e) {
1611
+ if (x(e)) return { delete: {
1612
+ group: "edit",
1613
+ title: "Delete connection",
1614
+ html: Z(P, "Delete connection"),
1615
+ action: { click: () => this.modeling.removeElements([e]) }
1616
+ } };
1617
+ if (!b(e)) return {};
1618
+ let t = e, n = {};
1619
+ if (t.wardleyType === "component" || t.wardleyType === "anchor") {
1620
+ let e = (e) => {
1621
+ let n = this.factory.createNew("component", "Component");
1622
+ this.create.start(e, n, { source: t });
1623
+ };
1624
+ n.append = {
1625
+ group: "edit",
1626
+ title: "Append component (auto-connect)",
1627
+ html: Z(Ae, "Append component", !0),
1628
+ action: {
1629
+ click: e,
1630
+ dragstart: e
1631
+ }
1632
+ };
1633
+ let r = (e) => {
1634
+ this.connect.start(e, t);
1635
+ };
1636
+ n.connect = {
1637
+ group: "edit",
1638
+ title: "Connect to existing element",
1639
+ html: Z(je, "Connect to existing element", !0),
1640
+ action: {
1641
+ click: r,
1642
+ dragstart: r
1643
+ }
1644
+ };
1645
+ }
1646
+ if (t.wardleyType === "component") {
1647
+ if (t.movement) n["evolve-clear"] = {
1648
+ group: "wardley",
1649
+ title: "Remove evolve",
1650
+ html: Z(Pe, "Remove evolve"),
1651
+ action: { click: () => this.wardleyModeling.clearMovement(t) }
1652
+ };
1653
+ else {
1654
+ let e = (e) => this.evolveDragging.start(e, t);
1655
+ n.evolve = {
1656
+ group: "wardley",
1657
+ title: "Evolve: drag to set the target maturity",
1658
+ html: Z(Me, "Evolve: drag to set the target maturity", !0),
1659
+ action: {
1660
+ click: e,
1661
+ dragstart: e
1662
+ }
1663
+ };
1664
+ }
1665
+ n.settings = {
1666
+ group: "wardley",
1667
+ title: "Settings (type, sourcing, inertia)",
1668
+ html: Z(We, "Settings"),
1669
+ action: { click: (e) => {
1670
+ let n = e;
1671
+ this.popupMenu.open(t, q, {
1672
+ x: n.clientX,
1673
+ y: n.clientY
1674
+ });
1675
+ } }
1676
+ };
1677
+ }
1678
+ return t.wardleyType === "note" && (n.color = {
1679
+ group: "wardley",
1680
+ title: "Note color",
1681
+ html: Z(Ge, "Note color"),
1682
+ action: { click: (e) => {
1683
+ let n = e;
1684
+ this.colorPicker.open(t, n.clientX, n.clientY);
1685
+ } }
1686
+ }), n["edit-label"] = {
1687
+ group: "edit",
1688
+ title: "Edit label",
1689
+ html: Z(Ne, "Edit label"),
1690
+ action: { click: () => this.labelEditing.activate(t) }
1691
+ }, n.delete = {
1692
+ group: "edit",
1693
+ title: "Delete",
1694
+ html: Z(P, "Delete"),
1695
+ action: { click: () => this.modeling.removeElements([t]) }
1696
+ }, n;
1697
+ }
1698
+ }]
1699
+ }, zt = class {
1700
+ canvas;
1701
+ modeling;
1702
+ factory;
1703
+ static $inject = [
1704
+ "eventBus",
1705
+ "canvas",
1706
+ "wardleyModeling",
1707
+ "wardleyElementFactory"
1708
+ ];
1709
+ active = null;
1710
+ constructor(e, t, n, r) {
1711
+ this.canvas = t, this.modeling = n, this.factory = r, e.on("element.dblclick", (e) => {
1712
+ b(e.element) && this.activate(e.element);
1713
+ }), e.on([
1714
+ "element.mousedown",
1715
+ "drag.init",
1716
+ "canvas.viewbox.changing"
1717
+ ], () => this.active?.commit());
1718
+ }
1719
+ activate(e) {
1720
+ this.active?.commit();
1721
+ let t = this.canvas.getContainer(), n = this.canvas.zoom(), r = this.canvas.viewbox(), i = e.wardleyType === "note", a = (e.x + e.width + 6 - r.x) * n, o = (e.y + e.height / 2 - 11 - r.y) * n, s = document.createElement(i ? "textarea" : "input");
1722
+ if (s.className = i ? "wardley-label-input wardley-label-textarea" : "wardley-label-input", s.value = e.wardleyLabel ?? "", i) {
1723
+ let e = s;
1724
+ e.rows = Math.max(2, s.value.split("\n").length), e.wrap = "off";
1725
+ } else s.type = "text";
1726
+ s.style.position = "absolute", s.style.left = `${a}px`, s.style.top = `${o}px`, t.appendChild(s), s.focus(), s.select();
1727
+ let c = !1, l = () => {
1728
+ c || (c = !0, s.removeEventListener("keydown", d), s.removeEventListener("blur", f), s.remove(), this.active = null);
1729
+ }, u = () => {
1730
+ if (c) return;
1731
+ let t = s.value.trim(), n = t && t !== e.wardleyLabel;
1732
+ if (l(), !n) return;
1733
+ let r = i ? t : this.factory.uniqueLabel(t, e.id);
1734
+ this.modeling.updateLabel(e, r);
1735
+ }, d = (e) => {
1736
+ if (e.key === "Escape") {
1737
+ e.preventDefault(), l();
1738
+ return;
1739
+ }
1740
+ if (e.key === "Enter") {
1741
+ if (i && !(e.metaKey || e.ctrlKey)) return;
1742
+ e.preventDefault(), u();
1743
+ }
1744
+ }, f = () => u();
1745
+ s.addEventListener("keydown", d), s.addEventListener("blur", f), this.active = {
1746
+ field: s,
1747
+ commit: u,
1748
+ cleanup: l
1749
+ };
1750
+ }
1751
+ cancel() {
1752
+ this.active?.cleanup();
1753
+ }
1754
+ }, Bt = {
1755
+ __init__: ["wardleyLabelEditing"],
1756
+ wardleyLabelEditing: ["type", zt]
1757
+ }, Vt = class {
1758
+ static $inject = [
1759
+ "canvas",
1760
+ "commandStack",
1761
+ "selection",
1762
+ "modeling"
1763
+ ];
1764
+ constructor(e, t, n, r) {
1765
+ let i = e.getContainer();
1766
+ i.hasAttribute("tabindex") || i.setAttribute("tabindex", "0"), i.addEventListener("keydown", (e) => {
1767
+ if (Ht(e.target)) return;
1768
+ let i = e.ctrlKey || e.metaKey, a = e.key.toLowerCase();
1769
+ if (i && a === "z" && !e.shiftKey) e.preventDefault(), t.undo();
1770
+ else if (i && a === "z" && e.shiftKey || i && a === "y") e.preventDefault(), t.redo();
1771
+ else if (a === "delete" || a === "backspace") {
1772
+ let t = n.get();
1773
+ t.length && (e.preventDefault(), r.removeElements(t));
1774
+ }
1775
+ });
1776
+ }
1777
+ };
1778
+ function Ht(e) {
1779
+ if (!(e instanceof HTMLElement)) return !1;
1780
+ let t = e.tagName;
1781
+ return t === "INPUT" || t === "TEXTAREA" || e.isContentEditable;
1782
+ }
1783
+ //#endregion
1784
+ //#region src/keyboard/index.ts
1785
+ var Ut = {
1786
+ __init__: ["wardleyKeyboard"],
1787
+ wardleyKeyboard: ["type", Vt]
1788
+ }, Q = "wardley.evolve", Wt = .005, Gt = "wardley-evolve-handle";
1789
+ function Kt(e) {
1790
+ return e < 0 ? 0 : e > 1 ? 1 : e;
1791
+ }
1792
+ var $ = class {
1793
+ dragging;
1794
+ static $inject = [
1795
+ "eventBus",
1796
+ "dragging",
1797
+ "evolutionGrid",
1798
+ "wardleyModeling",
1799
+ "canvas",
1800
+ "elementRegistry"
1801
+ ];
1802
+ constructor(e, t, n, r, i, a) {
1803
+ this.dragging = t;
1804
+ let o = (t, n) => {
1805
+ n === void 0 ? delete t.movement : t.movement = n, e.fire("element.changed", { element: t });
1806
+ }, s = (e, t) => {
1807
+ let r = i.getContainer().getBoundingClientRect(), a = i.viewbox(), o = a.x + (e - r.left) * (a.width / r.width);
1808
+ return Kt(n.fromCanvas({
1809
+ x: o,
1810
+ y: t
1811
+ }).evolution);
1812
+ };
1813
+ i.getContainer().addEventListener("mousedown", (e) => {
1814
+ let t = e.target;
1815
+ if (!t?.closest(`.${Gt}`)) return;
1816
+ let n = t.closest("[data-element-id]")?.getAttribute("data-element-id"), i = n ? a.get(n) : void 0;
1817
+ if (!i || i.wardleyType !== "component") return;
1818
+ e.stopPropagation(), e.preventDefault();
1819
+ let c = i.movement, l = i.y + i.height / 2, u, d = (e) => {
1820
+ u = s(e.clientX, l), o(i, { targetEvolution: u });
1821
+ }, f = () => {
1822
+ document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", f), o(i, c), u !== void 0 && Math.abs(u - i.evolution) > Wt && r.evolveComponent(i, u);
1823
+ };
1824
+ document.addEventListener("mousemove", d), document.addEventListener("mouseup", f);
1825
+ }, !0), e.on(`${Q}.move`, (e) => {
1826
+ let { shape: t } = e.context, r = t.y + t.height / 2, i = Kt(n.fromCanvas({
1827
+ x: e.x,
1828
+ y: r
1829
+ }).evolution);
1830
+ e.context.target = i, o(t, { targetEvolution: i });
1831
+ }), e.on(`${Q}.end`, (e) => {
1832
+ let t = e.context, { shape: n, target: i } = t;
1833
+ o(n, t.originalMovement), i !== void 0 && Math.abs(i - n.evolution) > Wt && r.evolveComponent(n, i), t.committed = !0;
1834
+ }), e.on(`${Q}.cleanup`, (e) => {
1835
+ let t = e.context;
1836
+ t && !t.committed && o(t.shape, t.originalMovement);
1837
+ });
1838
+ }
1839
+ start(e, t) {
1840
+ let n = {
1841
+ shape: t,
1842
+ ...t.movement ? { originalMovement: t.movement } : {}
1843
+ };
1844
+ this.dragging.init(e, Q, {
1845
+ cursor: "ew-resize",
1846
+ data: { context: n }
1847
+ });
1848
+ }
1849
+ }, qt = {
1850
+ __init__: ["wardleyEvolveDragging"],
1851
+ wardleyEvolveDragging: ["type", $]
1852
+ }, Jt = 500, Yt = class {
1853
+ static $inject = ["injector", "eventBus"];
1854
+ constructor(e, t) {
1855
+ let n = e.get("connectionPreview", !1), r = e.get("wardleyLabelEditing", !1);
1856
+ n && (t.on("create.move", (e) => {
1857
+ let { context: t } = e, r = t.source;
1858
+ if (!r) return;
1859
+ let i = t.canExecute && t.canExecute.connect;
1860
+ n.drawPreview(t, i ?? !1, {
1861
+ source: r,
1862
+ connectionStart: {
1863
+ x: r.x + r.width / 2,
1864
+ y: r.y + r.height / 2
1865
+ },
1866
+ connectionEnd: {
1867
+ x: e.x,
1868
+ y: e.y
1869
+ }
1870
+ });
1871
+ }), t.on([
1872
+ "create.end",
1873
+ "create.cancel",
1874
+ "create.cleanup"
1875
+ ], (e) => {
1876
+ n.cleanUp(e.context);
1877
+ })), r && t.on("create.end", Jt, (e) => {
1878
+ let { context: t } = e;
1879
+ if (!t.source || !t.canExecute || !t.shape) return;
1880
+ let n = t.shape;
1881
+ setTimeout(() => r.activate(n), 0);
1882
+ });
1883
+ }
1884
+ }, Xt = {
1885
+ __depends__: [ge],
1886
+ __init__: ["wardleyAppendBehavior"],
1887
+ wardleyAppendBehavior: ["type", Yt]
1888
+ }, Zt = class {
1889
+ canvas;
1890
+ modeling;
1891
+ static $inject = [
1892
+ "canvas",
1893
+ "eventBus",
1894
+ "wardleyModeling"
1895
+ ];
1896
+ popover;
1897
+ onDocPointer = (e) => {
1898
+ this.popover && !this.popover.contains(e.target) && this.close();
1899
+ };
1900
+ onKey = (e) => {
1901
+ e.key === "Escape" && this.close();
1902
+ };
1903
+ constructor(e, t, n) {
1904
+ this.canvas = e, this.modeling = n, t.on([
1905
+ "canvas.viewbox.changing",
1906
+ "drag.init",
1907
+ "diagram.clear"
1908
+ ], () => this.close());
1909
+ }
1910
+ open(e, t, n) {
1911
+ this.close();
1912
+ let r = this.canvas.getContainer(), i = r.getBoundingClientRect(), a = document.createElement("div");
1913
+ a.className = "wardley-color-picker";
1914
+ let o = [{
1915
+ value: void 0,
1916
+ title: "No color",
1917
+ cls: "wardley-cp-none"
1918
+ }, ...xe.map((e) => ({
1919
+ value: e.value,
1920
+ title: e.name,
1921
+ cls: ""
1922
+ }))];
1923
+ for (let t of o) {
1924
+ let n = document.createElement("button");
1925
+ n.type = "button", n.className = `wardley-cp-swatch ${t.cls}`.trim(), n.title = t.title, t.value && (n.style.background = t.value), (e.color ?? void 0) === t.value && n.classList.add("wardley-cp-active"), n.addEventListener("click", (n) => {
1926
+ n.stopPropagation(), this.modeling.setColor(e, t.value), this.close();
1927
+ }), a.append(n);
1928
+ }
1929
+ r.appendChild(a);
1930
+ let s = r.clientWidth, c = r.clientHeight, l = a.offsetWidth, u = a.offsetHeight, d = Math.max(4, Math.min(t - i.left, s - l - 4)), f = Math.max(4, Math.min(n - i.top, c - u - 4));
1931
+ a.style.left = `${d}px`, a.style.top = `${f}px`, this.popover = a, setTimeout(() => {
1932
+ document.addEventListener("click", this.onDocPointer, !0), document.addEventListener("keydown", this.onKey, !0);
1933
+ }, 0);
1934
+ }
1935
+ close() {
1936
+ this.popover && (this.popover.remove(), this.popover = void 0, document.removeEventListener("click", this.onDocPointer, !0), document.removeEventListener("keydown", this.onKey, !0));
1937
+ }
1938
+ }, Qt = {
1939
+ __init__: ["wardleyColorPicker"],
1940
+ wardleyColorPicker: ["type", Zt]
1941
+ }, $t = class extends yt {
1942
+ _getModules() {
1943
+ return [
1944
+ ...super._getModules(),
1945
+ ae,
1946
+ de,
1947
+ oe,
1948
+ se,
1949
+ ce,
1950
+ le,
1951
+ ue,
1952
+ fe,
1953
+ pe,
1954
+ me,
1955
+ Et,
1956
+ kt,
1957
+ ke,
1958
+ jt,
1959
+ Pt,
1960
+ Rt,
1961
+ Bt,
1962
+ Ut,
1963
+ qt,
1964
+ Lt,
1965
+ Xt,
1966
+ Qt
1967
+ ];
1968
+ }
1969
+ undo() {
1970
+ this.get("commandStack").undo();
1971
+ }
1972
+ redo() {
1973
+ this.get("commandStack").redo();
1974
+ }
1975
+ canUndo() {
1976
+ return this.get("commandStack").canUndo();
1977
+ }
1978
+ canRedo() {
1979
+ return this.get("commandStack").canRedo();
1980
+ }
1981
+ };
1982
+ //#endregion
1983
+ export { E as EvolutionGrid, Je as ICON_ADD, Ke as ICON_ASPECT_RATIO, Re as ICON_CODE, Le as ICON_DATA_OBJECT, P as ICON_DELETE, ze as ICON_DOWNLOAD, Ne as ICON_EDIT, Ve as ICON_FOLDER_OPEN, He as ICON_IMAGE, qe as ICON_MENU, Ue as ICON_NEW, N as ICON_PERSON, Ie as ICON_REDO, Be as ICON_SHARE, Fe as ICON_UNDO, Ye as ICON_VISIBILITY, $t as Modeler, xe as NOTE_COLORS, yt as NavigatedViewer, q as POPUP_PROVIDER_ID, _t as PanConstraint, vt as PanConstraintModule, we as ROOT_ID, ut as Viewer, Yt as WardleyAppendBehavior, Ee as WardleyBaseViewer, Zt as WardleyColorPicker, _ as WardleyElementFactory, It as WardleyElementSettingsProvider, $ as WardleyEvolveDragging, ct as WardleyExporter, st as WardleyImporter, zt as WardleyLabelEditing, wt as WardleyModeling, $e as WardleyRenderer, Ot as WardleyRules, ke as evolutionConstraintModule, M as evolutionGridModule, Ze as iconMarkup, lt as ioModule, S as isComponent, C as isPipeline, x as isWardleyConnection, b as isWardleyShape, Bt as labelEditingModule, Ce as saveSVG, jt as stageSnappingModule, Xt as wardleyAppendModule, Qt as wardleyColorPickerModule, Rt as wardleyContextPadModule, it as wardleyDrawModule, qt as wardleyEvolveModule, Ut as wardleyKeyboardModule, w as wardleyModelModule, Et as wardleyModelingModule, Pt as wardleyPaletteModule, Lt as wardleyPopupModule, kt as wardleyRulesModule };
1984
+
1985
+ //# sourceMappingURL=index.js.map