@likec4/core 1.48.0 → 1.50.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 (130) hide show
  1. package/dist/THIRD-PARTY-LICENSES.md +1034 -0
  2. package/dist/_chunks/Builder.view-element.mjs +2 -3284
  3. package/dist/_chunks/LikeC4Model.d.mts +21 -25
  4. package/dist/_chunks/_types.d.mts +1 -5
  5. package/dist/_chunks/_types2.d.mts +2 -4
  6. package/dist/_chunks/assignTagColors.mjs +1 -24
  7. package/dist/_chunks/geometry.mjs +1 -335
  8. package/dist/_chunks/index.d.mts +1995 -131
  9. package/dist/_chunks/index2.d.mts +153 -892
  10. package/dist/_chunks/index3.d.mts +15 -13
  11. package/dist/_chunks/index4.d.mts +229 -3
  12. package/dist/_chunks/index5.d.mts +392 -30
  13. package/dist/_chunks/libs/@mantine/colors-generator.mjs +2 -3403
  14. package/dist/_chunks/libs/@radix-ui/colors.mjs +1 -0
  15. package/dist/_chunks/libs/@ungap/structured-clone.mjs +1 -213
  16. package/dist/_chunks/libs/bail.mjs +1 -14
  17. package/dist/_chunks/libs/ccount.mjs +1 -25
  18. package/dist/_chunks/libs/character-entities-html4.mjs +1 -263
  19. package/dist/_chunks/libs/character-entities-legacy.mjs +1 -117
  20. package/dist/_chunks/libs/character-entities.mjs +2 -2136
  21. package/dist/_chunks/libs/comma-separated-tokens.mjs +1 -18
  22. package/dist/_chunks/libs/decode-named-character-reference.mjs +1 -21
  23. package/dist/_chunks/libs/defu.mjs +1 -42
  24. package/dist/_chunks/libs/devlop.mjs +1 -5
  25. package/dist/_chunks/libs/escape-string-regexp.mjs +1 -8
  26. package/dist/_chunks/libs/extend.mjs +1 -77
  27. package/dist/_chunks/libs/graphology-dag.mjs +1 -703
  28. package/dist/_chunks/libs/graphology.mjs +1 -4565
  29. package/dist/_chunks/libs/hast-util-sanitize.mjs +1 -863
  30. package/dist/_chunks/libs/hast-util-to-html.mjs +9 -2696
  31. package/dist/_chunks/libs/is-plain-obj.mjs +1 -9
  32. package/dist/_chunks/libs/longest-streak.mjs +1 -30
  33. package/dist/_chunks/libs/markdown-table.mjs +2 -290
  34. package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +1 -653
  35. package/dist/_chunks/libs/mdast-util-from-markdown.mjs +3 -8522
  36. package/dist/_chunks/libs/mdast-util-gfm.mjs +15 -2393
  37. package/dist/_chunks/libs/mdast-util-to-hast.mjs +11 -1803
  38. package/dist/_chunks/libs/micromark-extension-gfm.mjs +1 -2243
  39. package/dist/_chunks/libs/mnemonist.d.mts +1 -91
  40. package/dist/_chunks/libs/mnemonist.mjs +1 -1978
  41. package/dist/_chunks/libs/natural-compare-lite.mjs +9 -42
  42. package/dist/_chunks/libs/ohash.mjs +1 -0
  43. package/dist/_chunks/libs/rehype-sanitize.mjs +1 -29
  44. package/dist/_chunks/libs/rehype-stringify.mjs +1 -34
  45. package/dist/_chunks/libs/remark-gfm.mjs +1 -36
  46. package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +3 -100
  47. package/dist/_chunks/libs/remark-parse.mjs +1 -39
  48. package/dist/_chunks/libs/remark-rehype.mjs +1 -171
  49. package/dist/_chunks/libs/remeda.mjs +2 -702
  50. package/dist/_chunks/libs/trough.mjs +1 -158
  51. package/dist/_chunks/libs/unified.mjs +1 -2212
  52. package/dist/_chunks/manual-layout.mjs +1 -0
  53. package/dist/_chunks/model.mjs +4 -1898
  54. package/dist/_chunks/rolldown-runtime.mjs +1 -42
  55. package/dist/_chunks/types.mjs +1 -0
  56. package/dist/_chunks/utils.mjs +1 -483
  57. package/dist/builder/index.d.mts +3 -6
  58. package/dist/builder/index.mjs +1 -662
  59. package/dist/compute-view/index.d.mts +85 -13
  60. package/dist/compute-view/index.mjs +2 -262
  61. package/dist/geometry/index.d.mts +2 -2
  62. package/dist/geometry/index.mjs +1 -3
  63. package/dist/index.d.mts +7 -13
  64. package/dist/index.mjs +1 -27
  65. package/dist/model/index.d.mts +4 -11
  66. package/dist/model/index.mjs +1 -11
  67. package/dist/styles/index.d.mts +2 -7
  68. package/dist/styles/index.mjs +1 -30
  69. package/dist/types/index.d.mts +3 -9
  70. package/dist/types/index.mjs +1 -15
  71. package/dist/utils/graphology/index.d.mts +1 -1
  72. package/dist/utils/graphology/index.mjs +1 -3
  73. package/dist/utils/index.d.mts +5 -10
  74. package/dist/utils/index.mjs +1 -17
  75. package/package.json +14 -13
  76. package/dist/_chunks/LikeC4Styles.mjs +0 -691
  77. package/dist/_chunks/RichText.d.mts +0 -84
  78. package/dist/_chunks/RichText.mjs +0 -148
  79. package/dist/_chunks/_aux.d.mts +0 -289
  80. package/dist/_chunks/_aux.mjs +0 -18
  81. package/dist/_chunks/calcDriftsFromSnapshot.mjs +0 -379
  82. package/dist/_chunks/connection.mjs +0 -0
  83. package/dist/_chunks/const.d.mts +0 -43
  84. package/dist/_chunks/const.mjs +0 -33
  85. package/dist/_chunks/expression-model.d.mts +0 -192
  86. package/dist/_chunks/expression-model.mjs +0 -103
  87. package/dist/_chunks/expression.d.mts +0 -347
  88. package/dist/_chunks/expression.mjs +0 -107
  89. package/dist/_chunks/find.d.mts +0 -82
  90. package/dist/_chunks/find.mjs +0 -646
  91. package/dist/_chunks/find2.d.mts +0 -78
  92. package/dist/_chunks/find2.mjs +0 -287
  93. package/dist/_chunks/fqnRef.d.mts +0 -58
  94. package/dist/_chunks/fqnRef.mjs +0 -41
  95. package/dist/_chunks/index6.d.mts +0 -43
  96. package/dist/_chunks/index7.d.mts +0 -268
  97. package/dist/_chunks/index8.d.mts +0 -144
  98. package/dist/_chunks/invariant.mjs +0 -18
  99. package/dist/_chunks/iterable.mjs +0 -146
  100. package/dist/_chunks/libs/graphology-types.d.mts +0 -601
  101. package/dist/_chunks/libs/graphology.d.mts +0 -6
  102. package/dist/_chunks/mnemonist.mjs +0 -0
  103. package/dist/_chunks/model2.mjs +0 -0
  104. package/dist/_chunks/relationships-view.mjs +0 -132
  105. package/dist/_chunks/scalar.d.mts +0 -109
  106. package/dist/_chunks/scalar.mjs +0 -84
  107. package/dist/compute-view/relationships-view/index.d.mts +0 -16
  108. package/dist/compute-view/relationships-view/index.mjs +0 -7
  109. package/dist/model/connection/deployment/index.d.mts +0 -12
  110. package/dist/model/connection/deployment/index.mjs +0 -9
  111. package/dist/model/connection/index.d.mts +0 -14
  112. package/dist/model/connection/index.mjs +0 -10
  113. package/dist/model/connection/model/index.d.mts +0 -12
  114. package/dist/model/connection/model/index.mjs +0 -8
  115. package/dist/types/RichText.d.mts +0 -3
  116. package/dist/types/RichText.mjs +0 -7
  117. package/dist/types/_aux.d.mts +0 -3
  118. package/dist/types/_aux.mjs +0 -3
  119. package/dist/types/expression-model.d.mts +0 -6
  120. package/dist/types/expression-model.mjs +0 -7
  121. package/dist/types/expression.d.mts +0 -5
  122. package/dist/types/expression.mjs +0 -7
  123. package/dist/types/fqnRef.d.mts +0 -4
  124. package/dist/types/fqnRef.mjs +0 -7
  125. package/dist/types/scalar.d.mts +0 -2
  126. package/dist/types/scalar.mjs +0 -7
  127. package/dist/utils/iterable/index.d.mts +0 -9
  128. package/dist/utils/iterable/index.mjs +0 -3
  129. package/dist/utils/mnemonist.d.mts +0 -2
  130. package/dist/utils/mnemonist.mjs +0 -12
@@ -1,1898 +1,4 @@
1
- import { D as e, F as e$2, I as e$1, Q as t$5, T as t$3, Y as t$4, Z as t$1, c as t$8, i as n, k as t, l as t$7, m as e$4, r as t$2, s as e$3, w as t$6 } from "./libs/remeda.mjs";
2
- import { D as whereOperatorAsPredicate, F as isOnStage, I as exact, N as _stage, P as _type, j as isDeploymentNode, t as LikeC4Styles } from "./LikeC4Styles.mjs";
3
- import { A as sortParentsFirst, C as isAncestor, D as parentFqn, E as nameFromFqn, I as compareNatural, L as compareNaturalHierarchically, S as hierarchyLevel, _ as ancestorsFqn, g as getOrCreate, h as memoizeProp, k as sortNaturalByFqn, v as commonAncestor } from "./utils.mjs";
4
- import { n as nonNullable, t as invariant } from "./invariant.mjs";
5
- import { n as import_default_map } from "./libs/mnemonist.mjs";
6
- import { d as ifind, f as ifilter, s as ihead } from "./iterable.mjs";
7
- import { n as preferSummary, t as preferDescription } from "./_aux.mjs";
8
- import { f as extractStep, g as isStepEdgeId, h as isGroupElementKind, i as GlobalFqn, m as isGlobalFqn, v as splitGlobalFqn } from "./scalar.mjs";
9
- import { t as FqnRef } from "./fqnRef.mjs";
10
- import { t as RichText } from "./RichText.mjs";
11
- import { n as applyManualLayout, t as calcDriftsFromSnapshot } from "./calcDriftsFromSnapshot.mjs";
12
- import { c as DeploymentRelationModel, l as NestedElementOfDeployedInstanceModel, o as DeployedInstanceModel, s as DeploymentNodeModel } from "./find.mjs";
13
-
14
- //#region src/model/ElementModel.ts
15
- var ElementModel = class {
16
- /**
17
- * Don't use in runtime, only for type inference
18
- */
19
- Aux;
20
- id;
21
- _literalId;
22
- hierarchyLevel;
23
- imported;
24
- constructor($model, $element) {
25
- this.$model = $model;
26
- this.$element = $element;
27
- this.id = this.$element.id;
28
- this._literalId = this.$element.id;
29
- const [projectId, fqn] = splitGlobalFqn(this.id);
30
- if (projectId) {
31
- this.imported = {
32
- from: projectId,
33
- fqn
34
- };
35
- this.hierarchyLevel = hierarchyLevel(fqn);
36
- } else {
37
- this.imported = null;
38
- this.hierarchyLevel = hierarchyLevel(this.id);
39
- }
40
- }
41
- get name() {
42
- return nameFromFqn(this.id);
43
- }
44
- get parent() {
45
- return this.$model.parent(this);
46
- }
47
- get kind() {
48
- return this.$element.kind;
49
- }
50
- get shape() {
51
- return this.style.shape;
52
- }
53
- get color() {
54
- return this.style.color;
55
- }
56
- get icon() {
57
- return this.style.icon ?? null;
58
- }
59
- /**
60
- * Returns all tags of the element.
61
- * It includes tags from the element and its kind.
62
- */
63
- get tags() {
64
- return memoizeProp(this, Symbol.for("tags"), () => {
65
- return n([...this.$element.tags ?? [], ...this.$model.specification.elements[this.$element.kind]?.tags ?? []]);
66
- });
67
- }
68
- get title() {
69
- return this.$element.title;
70
- }
71
- /**
72
- * Returns true if the element has a summary and a description
73
- * (if one is missing - it falls back to another)
74
- */
75
- get hasSummary() {
76
- return !!this.$element.summary && !!this.$element.description && !t(this.$element.summary, this.$element.description);
77
- }
78
- /**
79
- * Short description of the element.
80
- * Falls back to description if summary is not provided.
81
- */
82
- get summary() {
83
- return RichText.memoize(this, "summary", /* @__PURE__ */ preferSummary(this.$element));
84
- }
85
- /**
86
- * Long description of the element.
87
- * Falls back to summary if description is not provided.
88
- */
89
- get description() {
90
- return RichText.memoize(this, "description", /* @__PURE__ */ preferDescription(this.$element));
91
- }
92
- get technology() {
93
- return this.$element.technology ?? null;
94
- }
95
- get links() {
96
- return this.$element.links ?? [];
97
- }
98
- get defaultView() {
99
- return memoizeProp(this, Symbol.for("defaultView"), () => ihead(this.scopedViews()) ?? null);
100
- }
101
- get isRoot() {
102
- return this.parent === null;
103
- }
104
- get style() {
105
- return memoizeProp(this, "style", () => exact({
106
- shape: this.$model.$styles.defaults.shape,
107
- color: this.$model.$styles.defaults.color,
108
- border: this.$model.$styles.defaults.border,
109
- opacity: this.$model.$styles.defaults.opacity,
110
- size: this.$model.$styles.defaults.size,
111
- padding: this.$model.$styles.defaults.padding,
112
- textSize: this.$model.$styles.defaults.text,
113
- ...this.$element.style
114
- }));
115
- }
116
- get projectId() {
117
- return this.imported?.from ?? this.$model.projectId;
118
- }
119
- isAncestorOf(another) {
120
- return isAncestor(this, another);
121
- }
122
- isDescendantOf(another) {
123
- return isAncestor(another, this);
124
- }
125
- /**
126
- * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
127
- * (from closest to root)
128
- */
129
- ancestors() {
130
- return this.$model.ancestors(this);
131
- }
132
- /**
133
- * Returns the common ancestor of this element and another element.
134
- */
135
- commonAncestor(another) {
136
- const common = commonAncestor(this.id, another.id);
137
- return common ? this.$model.element(common) : null;
138
- }
139
- children() {
140
- return this.$model.children(this);
141
- }
142
- /**
143
- * Get all descendant elements (i.e. children, children’s children, etc.)
144
- */
145
- descendants(sort) {
146
- if (sort) return sortNaturalByFqn([...this.$model.descendants(this)], sort)[Symbol.iterator]();
147
- return this.$model.descendants(this);
148
- }
149
- /**
150
- * Get all sibling (i.e. same parent)
151
- */
152
- siblings() {
153
- return this.$model.siblings(this);
154
- }
155
- /**
156
- * Resolve siblings of the element and its ancestors
157
- * (from closest parent to root)
158
- */
159
- *ascendingSiblings() {
160
- yield* this.siblings();
161
- for (const ancestor of this.ancestors()) yield* ancestor.siblings();
162
- }
163
- /**
164
- * Resolve siblings of the element and its ancestors
165
- * (from root to closest)
166
- */
167
- *descendingSiblings() {
168
- for (const ancestor of [...this.ancestors()].reverse()) yield* ancestor.siblings();
169
- yield* this.siblings();
170
- }
171
- incoming(filter = "all") {
172
- return this.$model.incoming(this, filter);
173
- }
174
- *incomers(filter = "all") {
175
- const unique = /* @__PURE__ */ new Set();
176
- for (const r of this.incoming(filter)) {
177
- if (unique.has(r.source.id)) continue;
178
- unique.add(r.source.id);
179
- yield r.source;
180
- }
181
- }
182
- outgoing(filter = "all") {
183
- return this.$model.outgoing(this, filter);
184
- }
185
- *outgoers(filter = "all") {
186
- const unique = /* @__PURE__ */ new Set();
187
- for (const r of this.outgoing(filter)) {
188
- if (unique.has(r.target.id)) continue;
189
- unique.add(r.target.id);
190
- yield r.target;
191
- }
192
- }
193
- get allOutgoing() {
194
- return memoizeProp(this, Symbol.for("allOutgoing"), () => new Set(this.outgoing()));
195
- }
196
- get allIncoming() {
197
- return memoizeProp(this, Symbol.for("allIncoming"), () => new Set(this.incoming()));
198
- }
199
- /**
200
- * Iterate over all views that include this element.
201
- */
202
- views() {
203
- return memoizeProp(this, Symbol.for("views"), () => {
204
- const views = /* @__PURE__ */ new Set();
205
- for (const view of this.$model.views()) if (view.includesElement(this.id)) views.add(view);
206
- return views;
207
- });
208
- }
209
- /**
210
- * Iterate over all views that scope this element.
211
- * It is possible that element is not included in the view.
212
- */
213
- scopedViews() {
214
- return memoizeProp(this, Symbol.for("scopedViews"), () => {
215
- const views = /* @__PURE__ */ new Set();
216
- for (const vm of this.$model.views()) if (vm.isScopedElementView() && vm.viewOf.id === this.id) views.add(vm);
217
- return views;
218
- });
219
- }
220
- /**
221
- * @returns true if the element is deployed
222
- */
223
- isDeployed() {
224
- return e(ihead(this.deployments()));
225
- }
226
- deployments() {
227
- return this.$model.deployment.instancesOf(this);
228
- }
229
- hasMetadata() {
230
- return !!this.$element.metadata && !e$1(this.$element.metadata);
231
- }
232
- getMetadata(field) {
233
- if (field) return this.$element.metadata?.[field];
234
- return this.$element.metadata ?? {};
235
- }
236
- /**
237
- * Checks if the element has the given tag.
238
- */
239
- isTagged(tag) {
240
- return this.tags.includes(tag);
241
- }
242
- };
243
-
244
- //#endregion
245
- //#region src/model/utils/get-id.ts
246
- /**
247
- * Utility function to extract `id` from the given element.
248
- */
249
- const getId = (element) => {
250
- return typeof element === "string" ? element : element.id;
251
- };
252
-
253
- //#endregion
254
- //#region src/model/utils/view-title-path.ts
255
- const VIEW_FOLDERS_SEPARATOR = "/";
256
- const splitViewTitle = (title) => {
257
- invariant(!title.includes("\n"), "View title cannot contain newlines");
258
- if (title.includes(VIEW_FOLDERS_SEPARATOR)) {
259
- const segments = title.split(VIEW_FOLDERS_SEPARATOR).map((s) => s.trim()).filter((s) => s.length > 0);
260
- if (t$1(segments, 1)) return segments;
261
- return [""];
262
- }
263
- return [title.trim()];
264
- };
265
- /**
266
- * Normalizes view path by removing spaces from segments, removing empty segments,
267
- * and removing leading/trailing slashes
268
- * @example
269
- * normalizeViewPath('One / Tw o / Thre e') === 'One/Tw o/Thre e'
270
- */
271
- const normalizeViewPath = (title) => {
272
- return splitViewTitle(title).join(VIEW_FOLDERS_SEPARATOR);
273
- };
274
- /**
275
- * Returns view group path if it is used as a path
276
- * Returns empty string if it is not a path
277
- * @example
278
- * getViewFolderPath('One / Tw o / Thre e') === 'One/Tw o'
279
- * getViewFolderPath('One') === ''
280
- */
281
- const getViewFolderPath = (title) => {
282
- const segments = splitViewTitle(title);
283
- if (!t$1(segments, 2)) return null;
284
- return segments.slice(0, -1).join(VIEW_FOLDERS_SEPARATOR);
285
- };
286
- /**
287
- * Returns view title if it is used as a path
288
- * @example
289
- * getViewTitleFromPath('One / Tw o / Thre e') === 'Thre e'
290
- * getViewTitleFromPath('One') === 'One'
291
- */
292
- const extractViewTitleFromPath = (title) => {
293
- if (!title.includes(VIEW_FOLDERS_SEPARATOR)) return title.trim();
294
- return splitViewTitle(title).pop() ?? title;
295
- };
296
-
297
- //#endregion
298
- //#region src/model/DeploymentModel.ts
299
- var LikeC4DeploymentModel = class {
300
- #elements = /* @__PURE__ */ new Map();
301
- #parents = /* @__PURE__ */ new Map();
302
- #children = new import_default_map.default(() => /* @__PURE__ */ new Set());
303
- #instancesOf = new import_default_map.default(() => /* @__PURE__ */ new Set());
304
- #rootElements = /* @__PURE__ */ new Set();
305
- #relations = /* @__PURE__ */ new Map();
306
- #incoming = new import_default_map.default(() => /* @__PURE__ */ new Set());
307
- #outgoing = new import_default_map.default(() => /* @__PURE__ */ new Set());
308
- #internal = new import_default_map.default(() => /* @__PURE__ */ new Set());
309
- #allTags = new import_default_map.default(() => /* @__PURE__ */ new Set());
310
- #nestedElementsOfDeployment = /* @__PURE__ */ new Map();
311
- $deployments;
312
- constructor($model) {
313
- this.$model = $model;
314
- const $deployments = this.$deployments = $model.$data.deployments;
315
- const elements = t$2($deployments.elements);
316
- for (const element of sortParentsFirst(elements)) {
317
- const el = this.addElement(element);
318
- for (const tag of el.tags) this.#allTags.get(tag).add(el);
319
- if (el.isInstance()) this.#instancesOf.get(el.element.id).add(el);
320
- }
321
- for (const relation of t$2($deployments.relations)) {
322
- const el = this.addRelation(relation);
323
- for (const tag of el.tags) this.#allTags.get(tag).add(el);
324
- }
325
- }
326
- /**
327
- * Returns the styles configuration for the project.
328
- */
329
- get $styles() {
330
- return this.$model.$styles;
331
- }
332
- /**
333
- * Returns the Project ID associated with the model.
334
- * If the project ID is not defined in the model, it returns "default".
335
- */
336
- get projectId() {
337
- return this.$model.projectId;
338
- }
339
- /**
340
- * Returns the project associated with the model.
341
- * If the project is not defined in the model, it returns a default project with the ID "default".
342
- */
343
- get project() {
344
- return this.$model.project;
345
- }
346
- get specification() {
347
- return this.$model.specification;
348
- }
349
- element(el) {
350
- if (el instanceof DeploymentNodeModel || el instanceof DeployedInstanceModel) return el;
351
- const id = getId(el);
352
- return nonNullable(this.#elements.get(id), `Element ${id} not found`);
353
- }
354
- findElement(el) {
355
- return this.#elements.get(el) ?? null;
356
- }
357
- node(el) {
358
- const element = this.element(el);
359
- invariant(element.isDeploymentNode(), `Element ${element.id} is not a deployment node`);
360
- return element;
361
- }
362
- findNode(el) {
363
- const element = this.findElement(el);
364
- if (!element) return null;
365
- invariant(element.isDeploymentNode(), `Element ${element?.id} is not a deployment node`);
366
- return element;
367
- }
368
- instance(el) {
369
- const element = this.element(el);
370
- invariant(element.isInstance(), `Element ${element.id} is not a deployed instance`);
371
- return element;
372
- }
373
- findInstance(el) {
374
- const element = this.findElement(el);
375
- if (!element) return null;
376
- invariant(element.isInstance(), `Element ${element?.id} is not a deployed instance`);
377
- return element;
378
- }
379
- /**
380
- * Returns the root elements of the model.
381
- */
382
- roots() {
383
- return this.#rootElements.values();
384
- }
385
- /**
386
- * Returns all elements in the model.
387
- */
388
- elements() {
389
- return this.#elements.values();
390
- }
391
- /**
392
- * Returns all elements in the model.
393
- */
394
- *nodes() {
395
- for (const element of this.#elements.values()) if (element.isDeploymentNode()) yield element;
396
- }
397
- *nodesOfKind(kind) {
398
- for (const node of this.#elements.values()) if (node.isDeploymentNode() && node.kind === kind) yield node;
399
- }
400
- *instances() {
401
- for (const element of this.#elements.values()) if (element.isInstance()) yield element;
402
- }
403
- /**
404
- * Iterate over all instances of the given logical element.
405
- */
406
- *instancesOf(element) {
407
- const id = getId(element);
408
- const instances = this.#instancesOf.get(id);
409
- if (instances) yield* instances;
410
- }
411
- deploymentRef(ref) {
412
- if (FqnRef.isInsideInstanceRef(ref)) {
413
- const { deployment, element } = ref;
414
- return getOrCreate(this.#nestedElementsOfDeployment, `${deployment}@${element}`, () => {
415
- return new NestedElementOfDeployedInstanceModel(this.instance(deployment), this.$model.element(element));
416
- });
417
- }
418
- return this.element(ref.deployment);
419
- }
420
- /**
421
- * Returns all relationships in the model.
422
- */
423
- relationships() {
424
- return this.#relations.values();
425
- }
426
- /**
427
- * Returns a specific relationship by its ID.
428
- */
429
- relationship(id) {
430
- const relationId = getId(id);
431
- return nonNullable(this.#relations.get(relationId), `DeploymentRelationModel ${relationId} not found`);
432
- }
433
- findRelationship(id) {
434
- return this.#relations.get(id) ?? null;
435
- }
436
- /**
437
- * Returns all deployment views in the model.
438
- */
439
- *views() {
440
- for (const view of this.$model.views()) if (view.isDeploymentView()) yield view;
441
- }
442
- /**
443
- * Returns the parent element of given element.
444
- * @see ancestors
445
- */
446
- parent(element) {
447
- const id = getId(element);
448
- return this.#parents.get(id) || null;
449
- }
450
- /**
451
- * Get all children of the element (only direct children),
452
- * @see descendants
453
- */
454
- children(element) {
455
- const id = getId(element);
456
- return this.#children.get(id);
457
- }
458
- /**
459
- * Get all sibling (i.e. same parent)
460
- */
461
- *siblings(element) {
462
- const id = getId(element);
463
- const siblings = this.parent(element)?.children() ?? this.roots();
464
- for (const sibling of siblings) if (sibling.id !== id) yield sibling;
465
- }
466
- /**
467
- * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
468
- * (from closest to root)
469
- */
470
- *ancestors(element) {
471
- let id = getId(element);
472
- let parent;
473
- while (parent = this.#parents.get(id)) {
474
- yield parent;
475
- id = parent.id;
476
- }
477
- }
478
- /**
479
- * Get all descendant elements (i.e. children, children’s children, etc.)
480
- */
481
- *descendants(element, sort = "desc") {
482
- for (const child of this.children(element)) if (sort === "asc") {
483
- yield child;
484
- yield* this.descendants(child.id);
485
- } else {
486
- yield* this.descendants(child.id);
487
- yield child;
488
- }
489
- }
490
- /**
491
- * Incoming relationships to the element and its descendants
492
- * @see incomers
493
- */
494
- *incoming(element, filter = "all") {
495
- const id = getId(element);
496
- for (const rel of this.#incoming.get(id)) switch (true) {
497
- case filter === "all":
498
- case filter === "direct" && rel.target.id === id:
499
- case filter === "to-descendants" && rel.target.id !== id:
500
- yield rel;
501
- break;
502
- }
503
- }
504
- /**
505
- * Outgoing relationships from the element and its descendants
506
- * @see outgoers
507
- */
508
- *outgoing(element, filter = "all") {
509
- const id = getId(element);
510
- for (const rel of this.#outgoing.get(id)) switch (true) {
511
- case filter === "all":
512
- case filter === "direct" && rel.source.id === id:
513
- case filter === "from-descendants" && rel.source.id !== id:
514
- yield rel;
515
- break;
516
- }
517
- }
518
- addElement(element) {
519
- if (this.#elements.has(element.id)) throw new Error(`Element ${element.id} already exists`);
520
- const el = isDeploymentNode(element) ? new DeploymentNodeModel(this, Object.freeze(element)) : new DeployedInstanceModel(this, Object.freeze(element), this.$model.element(element.element));
521
- this.#elements.set(el.id, el);
522
- const parentId = parentFqn(el.id);
523
- if (parentId) {
524
- invariant(this.#elements.has(parentId), `Parent ${parentId} of ${el.id} not found`);
525
- this.#parents.set(el.id, this.node(parentId));
526
- this.#children.get(parentId).add(el);
527
- } else {
528
- invariant(el.isDeploymentNode(), `Root element ${el.id} is not a deployment node`);
529
- this.#rootElements.add(el);
530
- }
531
- return el;
532
- }
533
- addRelation(relation) {
534
- if (this.#relations.has(relation.id)) throw new Error(`Relation ${relation.id} already exists`);
535
- const rel = new DeploymentRelationModel(this, Object.freeze(relation));
536
- this.#relations.set(rel.id, rel);
537
- this.#incoming.get(rel.target.id).add(rel);
538
- this.#outgoing.get(rel.source.id).add(rel);
539
- const relParent = rel.boundary?.id ?? null;
540
- if (relParent) for (const ancestor of [relParent, ...ancestorsFqn(relParent)]) this.#internal.get(ancestor).add(rel);
541
- for (const sourceAncestor of ancestorsFqn(rel.source.id)) {
542
- if (sourceAncestor === relParent) break;
543
- this.#outgoing.get(sourceAncestor).add(rel);
544
- }
545
- for (const targetAncestor of ancestorsFqn(rel.target.id)) {
546
- if (targetAncestor === relParent) break;
547
- this.#incoming.get(targetAncestor).add(rel);
548
- }
549
- return rel;
550
- }
551
- };
552
-
553
- //#endregion
554
- //#region src/model/RelationModel.ts
555
- var RelationshipModel = class {
556
- source;
557
- target;
558
- /**
559
- * Common ancestor of the source and target elements.
560
- * Represents the boundary of the Relation.
561
- */
562
- boundary;
563
- constructor(model, $relationship) {
564
- this.model = model;
565
- this.$relationship = $relationship;
566
- this.source = model.element(FqnRef.flatten($relationship.source));
567
- this.target = model.element(FqnRef.flatten($relationship.target));
568
- const parent = commonAncestor(this.source.id, this.target.id);
569
- this.boundary = parent ? this.model.element(parent) : null;
570
- }
571
- get id() {
572
- return this.$relationship.id;
573
- }
574
- get expression() {
575
- return `${this.source.id} -> ${this.target.id}`;
576
- }
577
- get title() {
578
- if (e$2(this.$relationship.title)) return null;
579
- return this.$relationship.title;
580
- }
581
- get technology() {
582
- if (e$2(this.$relationship.technology)) return (this.kind && this.model.specification.relationships[this.kind])?.technology ?? null;
583
- return this.$relationship.technology;
584
- }
585
- /**
586
- * Returns true if the relationship has a summary and a description
587
- * (if one is missing - it falls back to another)
588
- */
589
- get hasSummary() {
590
- return !!this.$relationship.summary && !!this.$relationship.description && !t(this.$relationship.summary, this.$relationship.description);
591
- }
592
- /**
593
- * Short description of the relationship.
594
- * Falls back to description if summary is not provided.
595
- */
596
- get summary() {
597
- return RichText.memoize(this, "summary", /* @__PURE__ */ preferSummary(this.$relationship));
598
- }
599
- /**
600
- * Long description of the relationship.
601
- * Falls back to summary if description is not provided.
602
- */
603
- get description() {
604
- return RichText.memoize(this, "description", /* @__PURE__ */ preferDescription(this.$relationship));
605
- }
606
- get navigateTo() {
607
- return this.$relationship.navigateTo ? this.model.view(this.$relationship.navigateTo) : null;
608
- }
609
- get tags() {
610
- return this.$relationship.tags ?? [];
611
- }
612
- get kind() {
613
- return this.$relationship.kind ?? null;
614
- }
615
- get links() {
616
- return this.$relationship.links ?? [];
617
- }
618
- get color() {
619
- return this.$relationship.color ?? this.model.$styles.defaults.relationship.color;
620
- }
621
- get line() {
622
- return this.$relationship.line ?? this.model.$styles.defaults.relationship.line;
623
- }
624
- get head() {
625
- return this.$relationship.head ?? this.model.$styles.defaults.relationship.arrow;
626
- }
627
- get tail() {
628
- return this.$relationship.tail;
629
- }
630
- /**
631
- * Iterate over all views that include this relationship.
632
- */
633
- *views() {
634
- for (const view of this.model.views()) if (view.includesRelation(this.id)) yield view;
635
- }
636
- isDeploymentRelation() {
637
- return false;
638
- }
639
- isModelRelation() {
640
- return true;
641
- }
642
- hasMetadata() {
643
- return !!this.$relationship.metadata && !e$1(this.$relationship.metadata);
644
- }
645
- getMetadata(field) {
646
- if (field) return this.$relationship.metadata?.[field];
647
- return this.$relationship.metadata ?? {};
648
- }
649
- /**
650
- * Checks if the relationship has the given tag.
651
- */
652
- isTagged(tag) {
653
- return this.tags.includes(tag);
654
- }
655
- };
656
-
657
- //#endregion
658
- //#region src/model/view/EdgeModel.ts
659
- var EdgeModel = class {
660
- Aux;
661
- $viewModel;
662
- $view;
663
- $edge;
664
- constructor($viewModel, $edge, source, target) {
665
- this.source = source;
666
- this.target = target;
667
- this.$viewModel = $viewModel;
668
- this.$view = $viewModel.$view;
669
- this.$edge = $edge;
670
- }
671
- get id() {
672
- return this.$edge.id;
673
- }
674
- get parent() {
675
- return this.$edge.parent ? this.$viewModel.node(this.$edge.parent) : null;
676
- }
677
- get label() {
678
- return this.$edge.label ?? null;
679
- }
680
- get description() {
681
- return RichText.memoize(this, "description", this.$edge.description);
682
- }
683
- get technology() {
684
- return this.$edge.technology ?? null;
685
- }
686
- hasParent() {
687
- return this.$edge.parent !== null;
688
- }
689
- get tags() {
690
- return this.$edge.tags ?? [];
691
- }
692
- get stepNumber() {
693
- return this.isStep() ? extractStep(this.id) : null;
694
- }
695
- get navigateTo() {
696
- return this.$edge.navigateTo ? this.$viewModel.$model.view(this.$edge.navigateTo) : null;
697
- }
698
- get color() {
699
- return this.$edge.color;
700
- }
701
- get line() {
702
- return this.$edge.line ?? this.$viewModel.$styles.defaults.relationship.line;
703
- }
704
- get head() {
705
- return this.$edge.head ?? this.$viewModel.$styles.defaults.relationship.arrow;
706
- }
707
- get tail() {
708
- return this.$edge.tail;
709
- }
710
- isStep() {
711
- return isStepEdgeId(this.id);
712
- }
713
- *relationships(type) {
714
- for (const id of this.$edge.relations) if (type) {
715
- const rel = this.$viewModel.$model.findRelationship(id, type);
716
- if (rel) yield rel;
717
- } else yield this.$viewModel.$model.relationship(id);
718
- }
719
- includesRelation(rel) {
720
- const id = typeof rel === "string" ? rel : rel.id;
721
- return this.$edge.relations.includes(id);
722
- }
723
- isTagged(tag) {
724
- return this.tags.includes(tag);
725
- }
726
- };
727
-
728
- //#endregion
729
- //#region src/model/view/NodeModel.ts
730
- var NodeModel = class {
731
- Aux;
732
- $viewModel;
733
- $view;
734
- $node;
735
- constructor($viewModel, $node) {
736
- this.$viewModel = $viewModel;
737
- this.$view = $viewModel.$view;
738
- this.$node = $node;
739
- }
740
- get id() {
741
- return this.$node.id;
742
- }
743
- get title() {
744
- return this.$node.title;
745
- }
746
- get kind() {
747
- return this.$node.kind;
748
- }
749
- get description() {
750
- return RichText.memoize(this, "description", this.$node.description);
751
- }
752
- get technology() {
753
- return this.$node.technology ?? null;
754
- }
755
- get parent() {
756
- return this.$node.parent ? this.$viewModel.node(this.$node.parent) : null;
757
- }
758
- get element() {
759
- const modelRef = this.$node.modelRef;
760
- return modelRef ? this.$viewModel.$model.element(modelRef) : null;
761
- }
762
- get deployment() {
763
- const modelRef = this.$node.deploymentRef;
764
- return modelRef ? this.$viewModel.$model.deployment.element(modelRef) : null;
765
- }
766
- get shape() {
767
- return this.$node.shape;
768
- }
769
- get color() {
770
- return this.$node.color;
771
- }
772
- get icon() {
773
- return this.$node.icon ?? null;
774
- }
775
- get tags() {
776
- return this.$node.tags;
777
- }
778
- get links() {
779
- return this.$node.links ?? [];
780
- }
781
- get navigateTo() {
782
- return this.$node.navigateTo ? this.$viewModel.$model.view(this.$node.navigateTo) : null;
783
- }
784
- get style() {
785
- return this.$node.style;
786
- }
787
- get x() {
788
- return "x" in this.$node ? this.$node.x : void 0;
789
- }
790
- get y() {
791
- return "y" in this.$node ? this.$node.y : void 0;
792
- }
793
- get width() {
794
- return "width" in this.$node ? this.$node.width : void 0;
795
- }
796
- get height() {
797
- return "height" in this.$node ? this.$node.height : void 0;
798
- }
799
- children() {
800
- return memoizeProp(this, "children", () => new Set(this.$node.children.map((child) => this.$viewModel.node(child))));
801
- }
802
- /**
803
- * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
804
- * (from closest to root)
805
- */
806
- *ancestors() {
807
- let parent = this.parent;
808
- while (parent) {
809
- yield parent;
810
- parent = parent.parent;
811
- }
812
- }
813
- *siblings() {
814
- const siblings = this.parent?.children() ?? this.$viewModel.roots();
815
- for (const sibling of siblings) if (sibling.id !== this.id) yield sibling;
816
- }
817
- *incoming(filter = "all") {
818
- for (const edgeId of this.$node.inEdges) {
819
- const edge = this.$viewModel.edge(edgeId);
820
- switch (true) {
821
- case filter === "all":
822
- case filter === "direct" && edge.target.id === this.id:
823
- case filter === "to-descendants" && edge.target.id !== this.id:
824
- yield edge;
825
- break;
826
- }
827
- }
828
- }
829
- *incomers(filter = "all") {
830
- const unique = /* @__PURE__ */ new Set();
831
- for (const r of this.incoming(filter)) {
832
- if (unique.has(r.source.id)) continue;
833
- unique.add(r.source.id);
834
- yield r.source;
835
- }
836
- }
837
- *outgoing(filter = "all") {
838
- for (const edgeId of this.$node.outEdges) {
839
- const edge = this.$viewModel.edge(edgeId);
840
- switch (true) {
841
- case filter === "all":
842
- case filter === "direct" && edge.source.id === this.id:
843
- case filter === "from-descendants" && edge.source.id !== this.id:
844
- yield edge;
845
- break;
846
- }
847
- }
848
- }
849
- *outgoers(filter = "all") {
850
- const unique = /* @__PURE__ */ new Set();
851
- for (const r of this.outgoing(filter)) {
852
- if (unique.has(r.target.id)) continue;
853
- unique.add(r.target.id);
854
- yield r.target;
855
- }
856
- }
857
- isLayouted() {
858
- return "width" in this.$node && "height" in this.$node;
859
- }
860
- hasChildren() {
861
- return this.$node.children.length > 0;
862
- }
863
- hasParent() {
864
- return this.$node.parent !== null;
865
- }
866
- /**
867
- * Check if this node references to logical model element.
868
- */
869
- hasElement() {
870
- return e(this.$node.modelRef);
871
- }
872
- /**
873
- * Check if this node references to deployment element (Node or Instance).
874
- */
875
- hasDeployment() {
876
- return e(this.$node.deploymentRef);
877
- }
878
- /**
879
- * Check if this node references to deployed instance
880
- * Deployed instance always references to element and deployment element.
881
- */
882
- hasDeployedInstance() {
883
- return this.hasElement() && this.hasDeployment();
884
- }
885
- isGroup() {
886
- return isGroupElementKind(this.$node);
887
- }
888
- /**
889
- * Checks if the node has the given tag.
890
- */
891
- isTagged(tag) {
892
- return this.tags.includes(tag);
893
- }
894
- };
895
-
896
- //#endregion
897
- //#region src/model/view/LikeC4ViewModel.ts
898
- var LikeC4ViewModel = class {
899
- /**
900
- * Don't use in runtime, only for type inference
901
- */
902
- Aux;
903
- #view;
904
- #rootnodes = /* @__PURE__ */ new Set();
905
- #nodes = /* @__PURE__ */ new Map();
906
- #edges = /* @__PURE__ */ new Map();
907
- #includeElements = /* @__PURE__ */ new Set();
908
- #includeDeployments = /* @__PURE__ */ new Set();
909
- #includeRelations = /* @__PURE__ */ new Set();
910
- #allTags = new import_default_map.default((_key) => /* @__PURE__ */ new Set());
911
- #manualLayoutSnapshot;
912
- id;
913
- /**
914
- * The model this view belongs to
915
- */
916
- $model;
917
- /**
918
- * The title of the view
919
- */
920
- title;
921
- /**
922
- * View folder this view belongs to.
923
- * If view is top-level, this is the root folder.
924
- */
925
- folder;
926
- /**
927
- * Path to this view, processed by {@link normalizeViewPath}
928
- *
929
- * @example
930
- * "Group 1/Group 2/View"
931
- */
932
- viewPath;
933
- constructor(model, folder, view, manualLayoutSnapshot) {
934
- this.$model = model;
935
- this.#view = view;
936
- this.id = view.id;
937
- this.folder = folder;
938
- this.#manualLayoutSnapshot = manualLayoutSnapshot;
939
- for (const node of this.#view.nodes) {
940
- const el = new NodeModel(this, Object.freeze(node));
941
- this.#nodes.set(node.id, el);
942
- if (!node.parent) this.#rootnodes.add(el);
943
- if (node.deploymentRef) this.#includeDeployments.add(node.deploymentRef);
944
- if (node.modelRef) this.#includeElements.add(node.modelRef);
945
- for (const tag of el.tags) this.#allTags.get(tag).add(el);
946
- }
947
- for (const edge of this.#view.edges) {
948
- const edgeModel = new EdgeModel(this, Object.freeze(edge), this.node(edge.source), this.node(edge.target));
949
- for (const tag of edgeModel.tags) this.#allTags.get(tag).add(edgeModel);
950
- for (const rel of edge.relations) this.#includeRelations.add(rel);
951
- this.#edges.set(edge.id, edgeModel);
952
- }
953
- this.title = view.title ? extractViewTitleFromPath(view.title) : null;
954
- this.viewPath = view.title ? normalizeViewPath(view.title) : view.id;
955
- }
956
- /**
957
- * Returns the styles configuration for the project.
958
- */
959
- get $styles() {
960
- return this.$model.$styles;
961
- }
962
- get _type() {
963
- return this.#view[_type];
964
- }
965
- get stage() {
966
- return this.#view[_stage];
967
- }
968
- get bounds() {
969
- if ("bounds" in this.#view) return this.#view.bounds;
970
- if (this.#manualLayoutSnapshot) return this.#manualLayoutSnapshot.bounds;
971
- throw new Error("View is not layouted");
972
- }
973
- /**
974
- * Returns title if defined, otherwise returns title of the element it is based on, otherwise returns its {@link id}
975
- */
976
- get titleOrId() {
977
- return this.title ?? this.viewOf?.title ?? this.id;
978
- }
979
- /**
980
- * Returns title if defined, otherwise returns `Untitled`.
981
- */
982
- get titleOrUntitled() {
983
- return this.title ?? "Untitled";
984
- }
985
- /**
986
- * Returns path to this view as an array of groups and this view as the last element
987
- * If view is top-level, returns only this view.
988
- *
989
- * @example
990
- * viewPath = "Group 1/Group 2/View"
991
- *
992
- * breadcrumbs = [
993
- * "Group 1", // folder
994
- * "Group 1/Group 2", // folder
995
- * "Group 1/Group 2/View" // view
996
- * ]
997
- */
998
- get breadcrumbs() {
999
- return memoizeProp(this, "breadcrumbs", () => {
1000
- if (!this.folder.isRoot) return [...this.folder.breadcrumbs, this];
1001
- return [this];
1002
- });
1003
- }
1004
- get description() {
1005
- return RichText.memoize(this, "description", this.#view.description);
1006
- }
1007
- get tags() {
1008
- return this.#view.tags ?? [];
1009
- }
1010
- get links() {
1011
- return this.#view.links ?? [];
1012
- }
1013
- get viewOf() {
1014
- if (this.isElementView()) {
1015
- const viewOf = this.#view.viewOf;
1016
- return viewOf ? this.$model.element(viewOf) : null;
1017
- }
1018
- return null;
1019
- }
1020
- /**
1021
- * Available for dynamic views only
1022
- * throws error if view is not dynamic
1023
- */
1024
- get mode() {
1025
- if (this.isDynamicView()) return this.#view.variant ?? "diagram";
1026
- return null;
1027
- }
1028
- /**
1029
- * All tags from nodes and edges.
1030
- */
1031
- get includedTags() {
1032
- return [...this.#allTags.keys()];
1033
- }
1034
- /**
1035
- * The original view from the model.
1036
- * In case of layouted model, this is the latest auto-layouted view without manual changes applied
1037
- * @see {@link $layouted} should be used for rendering in the UI
1038
- */
1039
- get $view() {
1040
- if (!this.isLayouted() || "drifts" in this.#view) return this.#view;
1041
- const snapshot = this.#manualLayoutSnapshot;
1042
- if (snapshot) return memoizeProp(this, "withDriftReasons", () => {
1043
- return calcDriftsFromSnapshot(this.#view, snapshot);
1044
- });
1045
- return this.#view;
1046
- }
1047
- /**
1048
- * Returns the view with manual layout applied if it exists, otherwise returns the original view
1049
- * This should be used for rendering in the UI
1050
- */
1051
- get $layouted() {
1052
- if (!this.isLayouted()) throw new Error("View is not layouted");
1053
- return this.$manual ?? this.#view;
1054
- }
1055
- get hasManualLayout() {
1056
- return this.#manualLayoutSnapshot !== void 0;
1057
- }
1058
- get hasLayoutDrifts() {
1059
- if (!this.isLayouted()) return false;
1060
- const manualLayout = this.$manual;
1061
- return !!manualLayout?.drifts && manualLayout.drifts.length > 0;
1062
- }
1063
- /**
1064
- * If view has manual layout, returns it with manual layout applied
1065
- */
1066
- get $manual() {
1067
- if (!this.isLayouted()) return null;
1068
- const snapshot = this.#manualLayoutSnapshot;
1069
- if (snapshot) return memoizeProp(this, "snapshotWithManualLayout", () => {
1070
- return applyManualLayout(this.#view, snapshot);
1071
- });
1072
- return null;
1073
- }
1074
- get projectId() {
1075
- return this.$model.projectId;
1076
- }
1077
- roots() {
1078
- return this.#rootnodes.values();
1079
- }
1080
- /**
1081
- * Iterate over all nodes that have children.
1082
- */
1083
- *compounds() {
1084
- for (const node of this.#nodes.values()) if (node.hasChildren()) yield node;
1085
- }
1086
- /**
1087
- * Get node by id.
1088
- * @throws Error if node is not found.
1089
- */
1090
- node(node) {
1091
- const nodeId = getId(node);
1092
- return nonNullable(this.#nodes.get(nodeId), `Node ${nodeId} not found in view ${this.#view.id}`);
1093
- }
1094
- /**
1095
- * Find node by id.
1096
- */
1097
- findNode(node) {
1098
- return this.#nodes.get(getId(node)) ?? null;
1099
- }
1100
- findNodeWithElement(element) {
1101
- const id = getId(element);
1102
- if (!this.#includeElements.has(id)) return null;
1103
- return ifind(this.#nodes.values(), (node) => node.hasElement() && node.element.id === id) ?? null;
1104
- }
1105
- /**
1106
- * Iterate over all nodes.
1107
- */
1108
- nodes() {
1109
- return this.#nodes.values();
1110
- }
1111
- /**
1112
- * Get edge by id, throws error if edge is not found.
1113
- * Use {@link findEdge} if you are not sure if the edge exists.
1114
- *
1115
- * @param edge Edge or id
1116
- * @returns {@link EdgeModel}
1117
- */
1118
- edge(edge) {
1119
- const edgeId = getId(edge);
1120
- return nonNullable(this.#edges.get(edgeId), `Edge ${edgeId} not found in view ${this.#view.id}`);
1121
- }
1122
- /**
1123
- * Find edge by id.
1124
- * @param edge Edge or id
1125
- * @returns {@link EdgeModel} or null if edge is not found
1126
- */
1127
- findEdge(edge) {
1128
- return this.#edges.get(getId(edge)) ?? null;
1129
- }
1130
- /**
1131
- * Iterate over all edges.
1132
- */
1133
- edges() {
1134
- return this.#edges.values();
1135
- }
1136
- /**
1137
- * Iterate over all edges.
1138
- */
1139
- *edgesWithRelation(relation) {
1140
- for (const edge of this.#edges.values()) if (edge.includesRelation(relation)) yield edge;
1141
- }
1142
- /**
1143
- * Nodes that have references to elements from logical model.
1144
- */
1145
- *elements() {
1146
- for (const node of this.#nodes.values()) if (node.hasElement()) yield node;
1147
- }
1148
- /**
1149
- * Checks if the view has the given tag.
1150
- */
1151
- isTagged(tag) {
1152
- return this.tags.includes(tag);
1153
- }
1154
- includesElement(element) {
1155
- return this.#includeElements.has(getId(element));
1156
- }
1157
- includesDeployment(deployment) {
1158
- return this.#includeDeployments.has(getId(deployment));
1159
- }
1160
- includesRelation(relation) {
1161
- return this.#includeRelations.has(getId(relation));
1162
- }
1163
- /**
1164
- * Below are type guards.
1165
- */
1166
- isComputed() {
1167
- return this.#view[_stage] === "computed";
1168
- }
1169
- isLayouted() {
1170
- return this.#view[_stage] === "layouted";
1171
- }
1172
- /**
1173
- * @deprecated Use {@link isLayouted} instead
1174
- */
1175
- isDiagram() {
1176
- return this.#view[_stage] === "layouted";
1177
- }
1178
- isElementView() {
1179
- return this.#view[_type] === "element";
1180
- }
1181
- isScopedElementView() {
1182
- return this.#view[_type] === "element" && e(this.#view.viewOf);
1183
- }
1184
- isDeploymentView() {
1185
- return this.#view[_type] === "deployment";
1186
- }
1187
- isDynamicView() {
1188
- return this.#view[_type] === "dynamic";
1189
- }
1190
- };
1191
-
1192
- //#endregion
1193
- //#region src/model/view/LikeC4ViewsFolder.ts
1194
- var LikeC4ViewsFolder = class LikeC4ViewsFolder {
1195
- $model;
1196
- /**
1197
- * Path to this view folder, processed by {@link normalizeViewPath}
1198
- *
1199
- * @example
1200
- * "Folder 1/Folder 2/Folder 3"
1201
- */
1202
- path;
1203
- /**
1204
- * Title of this view folder.
1205
- *
1206
- * @example
1207
- * // title is the last segment of the path
1208
- * path = "Folder 1/Folder 2/Folder 3"
1209
- * title = "Folder 3"
1210
- */
1211
- title;
1212
- /**
1213
- * Whether this is the root view folder.
1214
- *
1215
- * !NOTE
1216
- * Root folder is special folder with an empty path and used only for internal purposes. \
1217
- * It is not visible to the user and should not be used in the code.
1218
- */
1219
- isRoot;
1220
- parentPath;
1221
- defaultViewId;
1222
- constructor($model, path, defaultViewId) {
1223
- this.$model = $model;
1224
- this.path = path.join("/");
1225
- this.isRoot = this.path === "";
1226
- this.title = t$3(path);
1227
- if (this.isRoot) this.parentPath = void 0;
1228
- else this.parentPath = path.slice(0, -1).join("/");
1229
- this.defaultViewId = defaultViewId;
1230
- }
1231
- /**
1232
- * Default view of this view folder.\
1233
- * It is for the case when there is a view at the same path as this folder.\
1234
- * (if there are multiple views at the same path, the first one is chosen)
1235
- *
1236
- * @example
1237
- * ```
1238
- * // Assume the following views exist:
1239
- * const views = [
1240
- * "Folder 1/ Folder 2 / View",
1241
- * "Folder 1/ Folder 2 / View / Subview",
1242
- * ]
1243
- * ```
1244
- * Group with path `Folder 1/ Folder 2 / View`\
1245
- * will have default view `Folder 1/ Folder 2 / View`
1246
- */
1247
- get defaultView() {
1248
- if (!this.defaultViewId) return null;
1249
- return this.$model.view(this.defaultViewId);
1250
- }
1251
- /**
1252
- * Returns path to this view folder as an array of ancestors (excluding root) and this view folder as the last element
1253
- *
1254
- * @throws Error if this is the root folder.
1255
- */
1256
- get breadcrumbs() {
1257
- invariant(!this.isRoot, "Root view folder has no breadcrumbs");
1258
- return memoizeProp(this, "breadcrumbs", () => {
1259
- const parent = this.parent;
1260
- if (parent) {
1261
- if (parent.isRoot) return [parent, this];
1262
- return [...parent.breadcrumbs, this];
1263
- }
1264
- return [this];
1265
- });
1266
- }
1267
- /**
1268
- * Returns parent folder
1269
- *
1270
- * @throws Error if this is the root folder.
1271
- */
1272
- get parent() {
1273
- invariant(!this.isRoot, "Root view folder has no parent");
1274
- if (e$2(this.parentPath)) return null;
1275
- return this.$model.viewFolder(this.parentPath);
1276
- }
1277
- /**
1278
- * Returns sorted set of children
1279
- * - First folders
1280
- * - Then views
1281
- */
1282
- get children() {
1283
- return this.$model.viewFolderItems(this.path);
1284
- }
1285
- /**
1286
- * Returns sorted array of children folders
1287
- */
1288
- get folders() {
1289
- return memoizeProp(this, "folders", () => {
1290
- const folders = [];
1291
- for (const child of this.children) if (child instanceof LikeC4ViewsFolder) folders.push(child);
1292
- return folders;
1293
- });
1294
- }
1295
- /**
1296
- * Returns all views in this view folder.
1297
- */
1298
- get views() {
1299
- return memoizeProp(this, "views", () => {
1300
- const views = [];
1301
- for (const child of this.children) if (child instanceof LikeC4ViewModel) views.push(child);
1302
- return views;
1303
- });
1304
- }
1305
- };
1306
-
1307
- //#endregion
1308
- //#region src/model/LikeC4Model.ts
1309
- var LikeC4Model = class LikeC4Model {
1310
- /**
1311
- * Don't use in runtime, only for type inference
1312
- */
1313
- Aux;
1314
- _elements = /* @__PURE__ */ new Map();
1315
- _parents = /* @__PURE__ */ new Map();
1316
- _children = new import_default_map.default(() => /* @__PURE__ */ new Set());
1317
- _rootElements = /* @__PURE__ */ new Set();
1318
- _relations = /* @__PURE__ */ new Map();
1319
- _incoming = new import_default_map.default(() => /* @__PURE__ */ new Set());
1320
- _outgoing = new import_default_map.default(() => /* @__PURE__ */ new Set());
1321
- _internal = new import_default_map.default(() => /* @__PURE__ */ new Set());
1322
- _views = /* @__PURE__ */ new Map();
1323
- _rootViewFolder;
1324
- _viewFolders = /* @__PURE__ */ new Map();
1325
- _viewFolderItems = new import_default_map.default(() => /* @__PURE__ */ new Set());
1326
- _allTags = new import_default_map.default(() => /* @__PURE__ */ new Set());
1327
- static fromParsed(model) {
1328
- return new LikeC4Model(model);
1329
- }
1330
- static create(model) {
1331
- return new LikeC4Model(model);
1332
- }
1333
- /**
1334
- * Creates a new LikeC4Model instance and infers types from a model dump.\
1335
- * Model dump expected to be computed or layouted.
1336
- *
1337
- * @typeParam D - A constant type parameter extending LikeC4ModelDump
1338
- * @param dump - The model dump to create the instance from
1339
- * @returns A new LikeC4Model instance with types inferred from the dump
1340
- */
1341
- static fromDump(dump) {
1342
- const { _stage: stage = "layouted", projectId = "unknown", project, globals, imports, deployments, views, relations, elements, specification } = dump;
1343
- return new LikeC4Model({
1344
- [_stage]: stage,
1345
- projectId,
1346
- project,
1347
- globals: {
1348
- predicates: globals?.predicates ?? {},
1349
- dynamicPredicates: globals?.dynamicPredicates ?? {},
1350
- styles: globals?.styles ?? {}
1351
- },
1352
- imports: imports ?? {},
1353
- deployments: {
1354
- elements: deployments?.elements ?? {},
1355
- relations: deployments?.relations ?? {}
1356
- },
1357
- views: views ?? {},
1358
- relations: relations ?? {},
1359
- elements: elements ?? {},
1360
- specification
1361
- });
1362
- }
1363
- deployment;
1364
- $data;
1365
- constructor($data) {
1366
- this.$data = $data;
1367
- for (const [, element] of t$4($data.elements)) {
1368
- const el = this.addElement(element);
1369
- for (const tag of el.tags) this._allTags.get(tag).add(el);
1370
- }
1371
- for (const [projectId, elements] of t$4($data.imports ?? {})) for (const element of sortParentsFirst(elements)) {
1372
- const el = this.addImportedElement(projectId, element);
1373
- for (const tag of el.tags) this._allTags.get(tag).add(el);
1374
- }
1375
- for (const relation of t$2($data.relations)) {
1376
- const el = this.addRelation(relation);
1377
- for (const tag of el.tags) this._allTags.get(tag).add(el);
1378
- }
1379
- this.deployment = new LikeC4DeploymentModel(this);
1380
- if (isOnStage($data, "computed") || isOnStage($data, "layouted")) {
1381
- const compare = compareNaturalHierarchically(VIEW_FOLDERS_SEPARATOR);
1382
- const views = t$5(t$2($data.views), t$6((view) => ({
1383
- view,
1384
- path: normalizeViewPath(view.title ?? view.id),
1385
- folderPath: view.title && getViewFolderPath(view.title) || ""
1386
- })), t$7((a, b) => compare(a.folderPath, b.folderPath)));
1387
- const getOrCreateFolder = (path) => {
1388
- let folder = this._viewFolders.get(path);
1389
- if (!folder) {
1390
- const segments = e$3(path, VIEW_FOLDERS_SEPARATOR);
1391
- invariant(t$1(segments, 1), `View group path "${path}" must have at least one element`);
1392
- let defaultView;
1393
- if (path === "") defaultView = views.find((view) => view.view.id === "index");
1394
- else defaultView = views.find((view) => view.path === path);
1395
- folder = new LikeC4ViewsFolder(this, segments, defaultView?.view.id);
1396
- this._viewFolders.set(path, folder);
1397
- }
1398
- return folder;
1399
- };
1400
- this._rootViewFolder = getOrCreateFolder("");
1401
- for (const { folderPath } of views) {
1402
- if (this._viewFolders.has(folderPath)) continue;
1403
- e$3(folderPath, VIEW_FOLDERS_SEPARATOR).reduce((segments, segment) => {
1404
- const parent = segments.join(VIEW_FOLDERS_SEPARATOR);
1405
- const folder = getOrCreateFolder(e$1(parent) ? segment : parent + VIEW_FOLDERS_SEPARATOR + segment);
1406
- this._viewFolderItems.get(parent).add(folder);
1407
- segments.push(segment);
1408
- return segments;
1409
- }, []);
1410
- }
1411
- for (const { view, folderPath } of views) {
1412
- const vm = new LikeC4ViewModel(this, getOrCreateFolder(folderPath), view, $data.manualLayouts?.[view.id]);
1413
- this._viewFolderItems.get(folderPath).add(vm);
1414
- this._views.set(view.id, vm);
1415
- for (const tag of vm.tags) this._allTags.get(tag).add(vm);
1416
- }
1417
- } else {
1418
- this._rootViewFolder = new LikeC4ViewsFolder(this, [""], void 0);
1419
- this._viewFolders.set(this._rootViewFolder.path, this._rootViewFolder);
1420
- }
1421
- }
1422
- /**
1423
- * Type narrows the model to the parsed stage.
1424
- * This is useful for tests
1425
- */
1426
- get asParsed() {
1427
- return this;
1428
- }
1429
- /**
1430
- * Type narrows the model to the layouted stage.
1431
- * This is useful for tests
1432
- */
1433
- get asComputed() {
1434
- return this;
1435
- }
1436
- /**
1437
- * Type narrows the model to the layouted stage.
1438
- * This is useful for tests
1439
- */
1440
- get asLayouted() {
1441
- return this;
1442
- }
1443
- /**
1444
- * Returns the styles configuration for the project.
1445
- */
1446
- get $styles() {
1447
- return memoizeProp(this, "styles", () => LikeC4Styles.from(this.$data.project.styles, this.$data.specification.customColors ? { theme: { colors: this.$data.specification.customColors } } : void 0));
1448
- }
1449
- /**
1450
- * Type guard the model to the parsed stage.
1451
- */
1452
- isParsed() {
1453
- return this.stage === "parsed";
1454
- }
1455
- /**
1456
- * Type guard the model to the layouted stage.
1457
- */
1458
- isLayouted() {
1459
- return this.stage === "layouted";
1460
- }
1461
- /**
1462
- * Type guard the model to the computed stage.
1463
- */
1464
- isComputed() {
1465
- return this.stage === "computed";
1466
- }
1467
- /**
1468
- * Keeping here for backward compatibility
1469
- * @deprecated use {@link $data}
1470
- */
1471
- get $model() {
1472
- return this.$data;
1473
- }
1474
- get stage() {
1475
- return this.$data[_stage];
1476
- }
1477
- /**
1478
- * Returns the Project ID associated with the model.
1479
- * If the project ID is not defined in the model, it returns "default".
1480
- */
1481
- get projectId() {
1482
- return this.$data.projectId ?? "default";
1483
- }
1484
- /**
1485
- * Returns the project associated with the model.
1486
- * If the project is not defined in the model, it returns a default project with the ID "default".
1487
- */
1488
- get project() {
1489
- return this.$data.project ?? memoizeProp(this, Symbol.for("project"), () => ({ id: this.projectId }));
1490
- }
1491
- get specification() {
1492
- return this.$data.specification;
1493
- }
1494
- get globals() {
1495
- return memoizeProp(this, Symbol.for("globals"), () => ({
1496
- predicates: { ...this.$data.globals?.predicates },
1497
- dynamicPredicates: { ...this.$data.globals?.dynamicPredicates },
1498
- styles: { ...this.$data.globals?.styles }
1499
- }));
1500
- }
1501
- /**
1502
- * Returns the element with the given FQN.
1503
- *
1504
- * @throws Error if element is not found\
1505
- * Use {@link findElement} if you don't want to throw an error
1506
- *
1507
- * @note Method is type-safe for typed model
1508
-
1509
- * @example
1510
- * model.element('cloud.frontend')
1511
- * // or object with id property of scalar.Fqn
1512
- * model.element({
1513
- * id: 'dashboard',
1514
- * })
1515
- */
1516
- element(el) {
1517
- if (el instanceof ElementModel) return el;
1518
- const id = getId(el);
1519
- return nonNullable(this._elements.get(id), `Element ${id} not found`);
1520
- }
1521
- /**
1522
- * Returns the element with the given FQN.
1523
- *
1524
- * @returns Element if found, null otherwise
1525
- * @note Method is not type-safe as {@link element}
1526
- *
1527
- * @example
1528
- * model.findElement('cloud.frontend')
1529
- */
1530
- findElement(el) {
1531
- return this._elements.get(getId(el)) ?? null;
1532
- }
1533
- /**
1534
- * Returns the root elements of the model.
1535
- */
1536
- roots() {
1537
- return this._rootElements.values();
1538
- }
1539
- /**
1540
- * Returns all elements in the model.
1541
- */
1542
- elements() {
1543
- return this._elements.values();
1544
- }
1545
- /**
1546
- * Returns all relationships in the model.
1547
- */
1548
- relationships() {
1549
- return this._relations.values();
1550
- }
1551
- relationship(rel, type) {
1552
- if (type === "deployment") return this.deployment.relationship(rel);
1553
- const id = getId(rel);
1554
- let model = this._relations.get(id) ?? null;
1555
- if (model || type === "model") return nonNullable(model, `Model relation ${id} not found`);
1556
- return nonNullable(this.deployment.findRelationship(id), `No model/deployment relation ${id} not found`);
1557
- }
1558
- findRelationship(id, type) {
1559
- if (type === "deployment") return this.deployment.findRelationship(id);
1560
- let model = this._relations.get(getId(id)) ?? null;
1561
- if (model || type === "model") return model;
1562
- return this.deployment.findRelationship(id);
1563
- }
1564
- /**
1565
- * Returns all views in the model.
1566
- */
1567
- views() {
1568
- return this._views.values();
1569
- }
1570
- /**
1571
- * Returns a specific view by its ID.
1572
- * @note Method is type-safe for typed model
1573
- * @throws Error if view is not found\
1574
- * Use {@link findView} if you don't want to throw an error
1575
- *
1576
- * @example
1577
- * model.view('index')
1578
- * // or object with id property of scalar.ViewId
1579
- * model.view({
1580
- * id: 'index',
1581
- * })
1582
- */
1583
- view(viewId) {
1584
- const id = getId(viewId);
1585
- return nonNullable(this._views.get(id), `View ${id} not found`);
1586
- }
1587
- /**
1588
- * Returns a specific view by its ID.
1589
- * @note Method is not type-safe as {@link view}
1590
- *
1591
- * @example
1592
- * model.findView('index')
1593
- */
1594
- findView(viewId) {
1595
- return this._views.get(viewId) ?? null;
1596
- }
1597
- /**
1598
- * Returns manual layout snapshot for given view ID, if any.
1599
- */
1600
- findManualLayout(viewId) {
1601
- if ("manualLayouts" in this.$data) return this.$data.manualLayouts?.[viewId] ?? null;
1602
- return null;
1603
- }
1604
- /**
1605
- * Returns a view folder by its path.
1606
- * Path is extracted from the view title, e.g. "Group 1/Group 2/View" -> "Group 1/Group 2"
1607
- * @throws Error if view folder is not found.
1608
- */
1609
- viewFolder(path) {
1610
- return nonNullable(this._viewFolders.get(path), `View folder ${path} not found`);
1611
- }
1612
- /**
1613
- * Root folder is a special one with an empty path and used only for internal purposes.
1614
- * It is not visible to the user and should be used only to get top-level folders and views.
1615
- */
1616
- get rootViewFolder() {
1617
- return this._rootViewFolder;
1618
- }
1619
- /**
1620
- * Whether the model has any view folders.
1621
- */
1622
- get hasViewFolders() {
1623
- return this._viewFolders.size > 1;
1624
- }
1625
- /**
1626
- * Returns all children of a view folder.
1627
- * Path is extracted from the view title, e.g. "Group 1/Group 2/View" -> "Group 1/Group 2"
1628
- *
1629
- * @throws Error if view folder is not found.
1630
- */
1631
- viewFolderItems(path) {
1632
- invariant(this._viewFolders.has(path), `View folder ${path} not found`);
1633
- return this._viewFolderItems.get(path);
1634
- }
1635
- /**
1636
- * Returns the parent element of given element.
1637
- * @see ancestors
1638
- */
1639
- parent(element) {
1640
- const id = getId(element);
1641
- return this._parents.get(id) || null;
1642
- }
1643
- /**
1644
- * Get all children of the element (only direct children),
1645
- * @see descendants
1646
- */
1647
- children(element) {
1648
- const id = getId(element);
1649
- return this._children.get(id);
1650
- }
1651
- /**
1652
- * Get all sibling (i.e. same parent)
1653
- */
1654
- *siblings(element) {
1655
- const id = getId(element);
1656
- const parent = this._parents.get(id);
1657
- const siblings = parent ? this._children.get(parent.id).values() : this.roots();
1658
- for (const sibling of siblings) if (sibling.id !== id) yield sibling;
1659
- }
1660
- /**
1661
- * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
1662
- * (from closest to root)
1663
- */
1664
- *ancestors(element) {
1665
- let id = getId(element);
1666
- let parent;
1667
- while (parent = this._parents.get(id)) {
1668
- yield parent;
1669
- id = parent.id;
1670
- }
1671
- }
1672
- /**
1673
- * Get all descendant elements (i.e. children, children’s children, etc.)
1674
- */
1675
- *descendants(element) {
1676
- for (const child of this.children(element)) {
1677
- yield child;
1678
- yield* this.descendants(child.id);
1679
- }
1680
- }
1681
- /**
1682
- * Incoming relationships to the element and its descendants
1683
- * @see incomers
1684
- */
1685
- *incoming(element, filter = "all") {
1686
- const id = getId(element);
1687
- for (const rel of this._incoming.get(id)) switch (true) {
1688
- case filter === "all":
1689
- case filter === "direct" && rel.target.id === id:
1690
- case filter === "to-descendants" && rel.target.id !== id:
1691
- yield rel;
1692
- break;
1693
- }
1694
- }
1695
- /**
1696
- * Outgoing relationships from the element and its descendants
1697
- * @see outgoers
1698
- */
1699
- *outgoing(element, filter = "all") {
1700
- const id = getId(element);
1701
- for (const rel of this._outgoing.get(id)) switch (true) {
1702
- case filter === "all":
1703
- case filter === "direct" && rel.source.id === id:
1704
- case filter === "from-descendants" && rel.source.id !== id:
1705
- yield rel;
1706
- break;
1707
- }
1708
- }
1709
- /**
1710
- * Returns array of all tags used in the model, sorted naturally.\
1711
- * Use {@link specification.tags} to get all defined tags
1712
- */
1713
- get tags() {
1714
- return memoizeProp(this, "tags", () => t$7([...this._allTags.keys()], compareNatural));
1715
- }
1716
- /**
1717
- * Returns all tags used in the model, sorted by usage count (descending).
1718
- */
1719
- get tagsSortedByUsage() {
1720
- return memoizeProp(this, "tagsSortedByUsage", () => t$5([...this._allTags.entries()], t$6(([tag, tagged]) => ({
1721
- tag,
1722
- count: tagged.size,
1723
- tagged
1724
- })), t$7((a, b) => compareNatural(a.tag, b.tag)), t$8([e$4("count"), "desc"])));
1725
- }
1726
- findByTag(tag, type) {
1727
- return ifilter(this._allTags.get(tag), (el) => {
1728
- if (type === "elements") return el instanceof ElementModel;
1729
- if (type === "views") return el instanceof LikeC4ViewModel;
1730
- if (type === "relationships") return el instanceof RelationshipModel;
1731
- return true;
1732
- });
1733
- }
1734
- /**
1735
- * Returns all elements of the given kind.
1736
- */
1737
- *elementsOfKind(kind) {
1738
- for (const el of this._elements.values()) if (el.kind === kind) yield el;
1739
- }
1740
- /**
1741
- * Returns all elements that match the given where operator.
1742
- *
1743
- * @example
1744
- * ```ts
1745
- * model.where({
1746
- * and: [
1747
- * { kind: 'component' },
1748
- * {
1749
- * or: [
1750
- * { tag: 'old' },
1751
- * { tag: { neq: 'new' } },
1752
- * ],
1753
- * },
1754
- * ],
1755
- * })
1756
- * ```
1757
- */
1758
- *elementsWhere(where) {
1759
- const predicate = whereOperatorAsPredicate(where);
1760
- for (const el of this._elements.values()) if (predicate(el)) yield el;
1761
- }
1762
- /**
1763
- * Returns all **model** relationships that match the given where operator.
1764
- *
1765
- * @example
1766
- * ```ts
1767
- * model.relationshipsWhere({
1768
- * and: [
1769
- * { kind: 'uses' },
1770
- * {
1771
- * or: [
1772
- * { tag: 'old' },
1773
- * { tag: { neq: 'new' } },
1774
- * ],
1775
- * },
1776
- * ],
1777
- * })
1778
- * ```
1779
- */
1780
- *relationshipsWhere(where) {
1781
- const predicate = whereOperatorAsPredicate(where);
1782
- for (const rel of this._relations.values()) if (predicate(rel)) yield rel;
1783
- }
1784
- addElement(element) {
1785
- if (this._elements.has(element.id)) throw new Error(`Element ${element.id} already exists`);
1786
- const el = new ElementModel(this, Object.freeze(element));
1787
- this._elements.set(el.id, el);
1788
- const parentId = parentFqn(el.id);
1789
- if (parentId) {
1790
- invariant(this._elements.has(parentId), `Parent ${parentId} of ${el.id} not found`);
1791
- this._parents.set(el.id, this.element(parentId));
1792
- this._children.get(parentId).add(el);
1793
- } else this._rootElements.add(el);
1794
- return el;
1795
- }
1796
- addImportedElement(projectId, element) {
1797
- invariant(!isGlobalFqn(element.id), `Imported element already has global FQN`);
1798
- const id = GlobalFqn(projectId, element.id);
1799
- if (this._elements.has(id)) throw new Error(`Element ${id} already exists`);
1800
- const el = new ElementModel(this, Object.freeze({
1801
- ...element,
1802
- id
1803
- }));
1804
- this._elements.set(el.id, el);
1805
- let parentId = parentFqn(el.id);
1806
- while (parentId) {
1807
- if (parentId.includes(".") && this._elements.has(parentId)) {
1808
- this._parents.set(el.id, this.element(parentId));
1809
- this._children.get(parentId).add(el);
1810
- return el;
1811
- }
1812
- parentId = parentFqn(parentId);
1813
- }
1814
- this._rootElements.add(el);
1815
- return el;
1816
- }
1817
- addRelation(relation) {
1818
- if (this._relations.has(relation.id)) throw new Error(`Relation ${relation.id} already exists`);
1819
- const rel = new RelationshipModel(this, Object.freeze(relation));
1820
- const { source, target } = rel;
1821
- this._relations.set(rel.id, rel);
1822
- this._incoming.get(target.id).add(rel);
1823
- this._outgoing.get(source.id).add(rel);
1824
- const relParent = commonAncestor(source.id, target.id);
1825
- if (relParent) for (const ancestor of [relParent, ...ancestorsFqn(relParent)]) this._internal.get(ancestor).add(rel);
1826
- for (const sourceAncestor of ancestorsFqn(source.id)) {
1827
- if (sourceAncestor === relParent) break;
1828
- this._outgoing.get(sourceAncestor).add(rel);
1829
- }
1830
- for (const targetAncestor of ancestorsFqn(target.id)) {
1831
- if (targetAncestor === relParent) break;
1832
- this._incoming.get(targetAncestor).add(rel);
1833
- }
1834
- return rel;
1835
- }
1836
- };
1837
- (function(_LikeC4Model) {
1838
- _LikeC4Model.EMPTY = LikeC4Model.create({
1839
- _stage: "computed",
1840
- projectId: "default",
1841
- project: { id: "default" },
1842
- specification: {
1843
- elements: {},
1844
- relationships: {},
1845
- deployments: {},
1846
- tags: {}
1847
- },
1848
- globals: {
1849
- predicates: {},
1850
- dynamicPredicates: {},
1851
- styles: {}
1852
- },
1853
- deployments: {
1854
- elements: {},
1855
- relations: {}
1856
- },
1857
- elements: {},
1858
- relations: {},
1859
- views: {},
1860
- imports: {}
1861
- });
1862
- })(LikeC4Model || (LikeC4Model = {}));
1863
-
1864
- //#endregion
1865
- //#region src/model/guards.ts
1866
- function isDeploymentNodeModel(model) {
1867
- return model instanceof DeploymentNodeModel;
1868
- }
1869
- function isDeployedInstanceModel(model) {
1870
- return model instanceof DeployedInstanceModel;
1871
- }
1872
- function isDeploymentElementModel(model) {
1873
- return isDeploymentNodeModel(model) || isDeployedInstanceModel(model);
1874
- }
1875
- function isNestedElementOfDeployedInstanceModel(model) {
1876
- return model instanceof NestedElementOfDeployedInstanceModel;
1877
- }
1878
- function isDeploymentRelationModel(x) {
1879
- return x instanceof DeploymentRelationModel;
1880
- }
1881
- function isRelationModel(x) {
1882
- return x instanceof RelationshipModel;
1883
- }
1884
- function isElementModel(element) {
1885
- return element instanceof ElementModel;
1886
- }
1887
- function isLikeC4ViewModel(view) {
1888
- return view instanceof LikeC4ViewModel;
1889
- }
1890
- function isNodeModel(node) {
1891
- return node instanceof NodeModel;
1892
- }
1893
- function isEdgeModel(edge) {
1894
- return edge instanceof EdgeModel;
1895
- }
1896
-
1897
- //#endregion
1898
- export { ElementModel as S, LikeC4DeploymentModel as _, isEdgeModel as a, getViewFolderPath as b, isNestedElementOfDeployedInstanceModel as c, LikeC4Model as d, LikeC4ViewsFolder as f, RelationshipModel as g, EdgeModel as h, isDeploymentRelationModel as i, isNodeModel as l, NodeModel as m, isDeploymentElementModel as n, isElementModel as o, LikeC4ViewModel as p, isDeploymentNodeModel as r, isLikeC4ViewModel as s, isDeployedInstanceModel as t, isRelationModel as u, VIEW_FOLDERS_SEPARATOR as v, normalizeViewPath as x, extractViewTitleFromPath as y };
1
+ import{n as e}from"./rolldown-runtime.mjs";import{A as t,E as n,I as r,L as i,N as a,O as o,Q as s,T as c,X as ee,c as te,et as l,i as u,l as d,m as ne,r as f,s as re}from"./libs/remeda.mjs";import{A as ie,D as ae,J as p,Q as oe,V as se,_t as m,bt as h,dt as ce,gt as g,lt as le,pt as ue,st as de,t as _,ut as fe,vt as pe,xt as v,yt as y}from"./types.mjs";import{$ as b,A as x,B as S,D as me,E as he,F as C,H as ge,I as w,J as _e,L as T,Q as E,R as ve,S as D,U as ye,Y as be,a as O,c as k,h as A,j,k as xe,o as M,q as Se,r as Ce,u as N,y as we,z as Te}from"./utils.mjs";import{t as P}from"./libs/mnemonist.mjs";import{n as Ee,t as De}from"./manual-layout.mjs";var F=class{Aux;id;_literalId;hierarchyLevel;imported;constructor(e,t){this.$model=e,this.$element=t,this.id=this.$element.id,this._literalId=this.$element.id;let[n,r]=ue(this.id);n?(this.imported={from:n,fqn:r},this.hierarchyLevel=C(r)):(this.imported=null,this.hierarchyLevel=C(this.id))}get name(){return Te(this.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$element.kind}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get tags(){return A(this,Symbol.for(`tags`),()=>u([...this.$element.tags??[],...this.$model.specification.elements[this.$element.kind]?.tags??[]]))}get title(){return this.$element.title}get hasSummary(){return!!this.$element.summary&&!!this.$element.description&&!t(this.$element.summary,this.$element.description)}get summary(){return _.memoize(this,`summary`,h(this.$element))}get description(){return _.memoize(this,`description`,y(this.$element))}get technology(){return this.$element.technology??null}get links(){return this.$element.links??[]}get defaultView(){return A(this,Symbol.for(`defaultView`),()=>D(this.scopedViews())??null)}get isRoot(){return this.parent===null}get style(){return A(this,`style`,()=>v({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.$element.style}))}get projectId(){return this.imported?.from??this.$model.projectId}isAncestorOf(e){return w(this,e)}isDescendantOf(e){return w(e,this)}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){let t=j(this.id,e.id);return t?this.$model.element(t):null}children(){return this.$model.children(this)}descendants(e){return e?ge([...this.$model.descendants(this)],e)[Symbol.iterator]():this.$model.descendants(this)}siblings(){return this.$model.siblings(this)}*ascendingSiblings(){yield*this.siblings();for(let e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(let e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e=`all`){return this.$model.incoming(this,e)}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}outgoing(e=`all`){return this.$model.outgoing(this,e)}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}get allOutgoing(){return A(this,Symbol.for(`allOutgoing`),()=>new Set(this.outgoing()))}get allIncoming(){return A(this,Symbol.for(`allIncoming`),()=>new Set(this.incoming()))}views(){return A(this,Symbol.for(`views`),()=>{let e=new Set;for(let t of this.$model.views())t.includesElement(this.id)&&e.add(t);return e})}scopedViews(){return A(this,Symbol.for(`scopedViews`),()=>{let e=new Set;for(let t of this.$model.views())t.isScopedElementView()&&t.viewOf.id===this.id&&e.add(t);return e})}isDeployed(){return o(D(this.deployments()))}deployments(){return this.$model.deployment.instancesOf(this)}hasMetadata(){return!!this.$element.metadata&&!i(this.$element.metadata)}getMetadata(e){return e?this.$element.metadata?.[e]:this.$element.metadata??{}}isTagged(e){return this.tags.includes(e)}},Oe=class{Aux;get style(){return A(this,`style`,()=>v({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.$node.style}))}get name(){return Te(this.id)}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get summary(){return _.memoize(this,`summary`,h(this.$node))}get description(){return _.memoize(this,`description`,y(this.$node))}get technology(){return this.$node.technology??null}get links(){return this.$node.links??[]}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){let t=j(this.id,e.id);return t?this.$model.node(t):null}siblings(){return this.$model.siblings(this)}isSibling(e){return this.parent===e.parent}*ascendingSiblings(){yield*this.siblings();for(let e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(let e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e=`all`){return this.$model.incoming(this,e)}outgoing(e=`all`){return this.$model.outgoing(this,e)}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}*views(){for(let e of this.$model.views())e._type===`deployment`&&e.includesDeployment(this.id)&&(yield e)}isDeploymentNode(){return!1}isInstance(){return!1}get allOutgoing(){return A(this,Symbol.for(`allOutgoing`),()=>z.from(new Set(this.outgoingModelRelationships()),new Set(this.outgoing())))}get allIncoming(){return A(this,Symbol.for(`allIncoming`),()=>z.from(new Set(this.incomingModelRelationships()),new Set(this.incoming())))}hasMetadata(){return!!this.$node.metadata&&!i(this.$node.metadata)}getMetadata(e){return e?this.$node.metadata?.[e]:this.$node.metadata??{}}isTagged(e){return this.tags.includes(e)}},I=class extends Oe{id;_literalId;title;hierarchyLevel;constructor(e,t){super(),this.$model=e,this.$node=t,this.id=t.id,this._literalId=t.id,this.title=t.title,this.hierarchyLevel=C(t.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$node.kind}get tags(){return A(this,Symbol.for(`tags`),()=>u([...this.$node.tags??[],...this.$model.$model.specification.deployments[this.kind]?.tags??[]]))}children(){return this.$model.children(this)}descendants(e=`desc`){return this.$model.descendants(this,e)}isDeploymentNode(){return!0}*instances(){for(let e of this.descendants(`desc`))e.isInstance()&&(yield e)}onlyOneInstance(){let e=this.children();if(e.size!==1)return null;let t=D(e);return t?t.isInstance()?t:t.onlyOneInstance():null}_relationshipsFromInstances=null;relationshipsFromInstances(){if(this._relationshipsFromInstances)return this._relationshipsFromInstances;let{outgoing:e,incoming:t}=this._relationshipsFromInstances={outgoing:new Set,incoming:new Set};for(let n of this.instances()){for(let t of n.element.outgoing())e.add(t);for(let e of n.element.incoming())t.add(e)}return this._relationshipsFromInstances}outgoingModelRelationships(){return this.relationshipsFromInstances().outgoing.values()}incomingModelRelationships(){return this.relationshipsFromInstances().incoming.values()}internalModelRelationships(){let{outgoing:e,incoming:t}=this.relationshipsFromInstances();return k(t,e)}},L=class extends Oe{id;_literalId;title;hierarchyLevel;constructor(e,t,n){super(),this.$model=e,this.$instance=t,this.element=n,this.id=t.id,this._literalId=t.id,this.title=t.title??n.title,this.hierarchyLevel=C(t.id)}get $node(){return this.$instance}get parent(){return b(this.$model.parent(this),`Parent of ${this.id} not found`)}get style(){return A(this,`style`,()=>v({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.element.$element.style,...this.$instance.style}))}get tags(){return A(this,Symbol.for(`tags`),()=>u([...this.$instance.tags??[],...this.element.tags]))}get kind(){return this.element.kind}get summary(){return _.memoize(this,`summary`,h(this.$instance)??h(this.element.$element))}get description(){return _.memoize(this,`description`,y(this.$instance)??y(this.element.$element))}get technology(){return this.$instance.technology??this.element.technology??null}get links(){return this.$instance.links??this.element.links}isInstance(){return!0}outgoingModelRelationships(){return this.element.outgoing()}incomingModelRelationships(){return this.element.incoming()}*views(){for(let e of this.$model.views())if(e._type===`deployment`){if(e.includesDeployment(this.id)){yield e;continue}e.includesDeployment(this.parent.id)&&this.parent.onlyOneInstance()&&(yield e)}}},ke=class{constructor(e,t){this.instance=e,this.element=t}get id(){return this.instance.id}get _literalId(){return this.instance.id}get style(){return A(this,`style `,()=>({shape:this.element.shape,color:this.element.color,...this.element.$element.style}))}get shape(){return this.element.shape}get color(){return this.element.color}get title(){return this.element.title}get summary(){return this.element.summary}get description(){return this.element.description}get technology(){return this.element.technology}isDeploymentNode(){return!1}isInstance(){return!1}},R=class{boundary;source;target;constructor(e,t){this.$model=e,this.$relationship=t,this.source=e.deploymentRef(t.source),this.target=e.deploymentRef(t.target);let n=j(this.source.id,this.target.id);this.boundary=n?this.$model.node(n):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return o(this.$relationship.title)?this.$relationship.title:null}get technology(){return r(this.$relationship.technology)?(this.kind&&this.$model.specification.relationships[this.kind])?.technology??null:this.$relationship.technology}get hasSummary(){return!!this.$relationship.summary&&!!this.$relationship.description&&!t(this.$relationship.summary,this.$relationship.description)}get summary(){return _.memoize(this,`summary`,h(this.$relationship))}get description(){return _.memoize(this,`description`,y(this.$relationship))}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get navigateTo(){return this.$relationship.navigateTo?this.$model.$model.view(this.$relationship.navigateTo):null}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.$model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.$model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.$model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let e of this.$model.views())e.includesRelation(this.id)&&(yield e)}isDeploymentRelation(){return!0}isModelRelation(){return!1}hasMetadata(){return!!this.$relationship.metadata&&!i(this.$relationship.metadata)}getMetadata(e){return e?this.$relationship.metadata?.[e]:this.$relationship.metadata??{}}isTagged(e){return this.tags.includes(e)}},z=class e{static empty(){return new e}static from(t,n){return new e(new Set(t),new Set(n))}constructor(e=new Set,t=new Set){this.model=e,this.deployment=t}get isEmpty(){return this.model.size===0&&this.deployment.size===0}get nonEmpty(){return this.model.size>0||this.deployment.size>0}get size(){return this.model.size+this.deployment.size}intersect(t){return e.from(k(this.model,t.model),k(this.deployment,t.deployment))}difference(t){return e.from(O(this.model,t.model),O(this.deployment,t.deployment))}union(t){return e.from(N(this.model,t.model),N(this.deployment,t.deployment))}};const B=e=>typeof e==`string`?e:e.id,Ae=`/`,V=e=>{if(E(!e.includes(`
2
+ `),`View title cannot contain newlines`),e.includes(`/`)){let t=e.split(`/`).map(e=>e.trim()).filter(e=>e.length>0);return s(t,1)?t:[``]}return[e.trim()]},H=e=>V(e).join(`/`),je=e=>{let t=V(e);return s(t,2)?t.slice(0,-1).join(`/`):null},Me=e=>e.includes(`/`)?V(e).pop()??e:e.trim();var Ne=class{#e=new Map;#t=new Map;#n=new P.default(()=>new Set);#r=new P.default(()=>new Set);#i=new Set;#a=new Map;#o=new P.default(()=>new Set);#s=new P.default(()=>new Set);#c=new P.default(()=>new Set);#l=new P.default(()=>new Set);#u=new Map;$deployments;constructor(e){this.$model=e;let t=this.$deployments=e.$data.deployments,n=f(t.elements);for(let e of ye(n)){let t=this.addElement(e);for(let e of t.tags)this.#l.get(e).add(t);t.isInstance()&&this.#r.get(t.element.id).add(t)}for(let e of f(t.relations)){let t=this.addRelation(e);for(let e of t.tags)this.#l.get(e).add(t)}}get $styles(){return this.$model.$styles}get projectId(){return this.$model.projectId}get project(){return this.$model.project}get specification(){return this.$model.specification}element(e){if(e instanceof I||e instanceof L)return e;let t=B(e);return b(this.#e.get(t),`Element ${t} not found`)}findElement(e){return this.#e.get(e)??null}node(e){let t=this.element(e);return E(t.isDeploymentNode(),`Element ${t.id} is not a deployment node`),t}findNode(e){let t=this.findElement(e);return t?(E(t.isDeploymentNode(),`Element ${t?.id} is not a deployment node`),t):null}instance(e){let t=this.element(e);return E(t.isInstance(),`Element ${t.id} is not a deployed instance`),t}findInstance(e){let t=this.findElement(e);return t?(E(t.isInstance(),`Element ${t?.id} is not a deployed instance`),t):null}roots(){return this.#i.values()}elements(){return this.#e.values()}*nodes(){for(let e of this.#e.values())e.isDeploymentNode()&&(yield e)}*nodesOfKind(e){for(let t of this.#e.values())t.isDeploymentNode()&&t.kind===e&&(yield t)}*instances(){for(let e of this.#e.values())e.isInstance()&&(yield e)}*instancesOf(e){let t=B(e),n=this.#r.get(t);n&&(yield*n)}deploymentRef(e){if(p.isInsideInstanceRef(e)){let{deployment:t,element:n}=e;return xe(this.#u,`${t}@${n}`,()=>new ke(this.instance(t),this.$model.element(n)))}return this.element(e.deployment)}relationships(){return this.#a.values()}relationship(e){let t=B(e);return b(this.#a.get(t),`DeploymentRelationModel ${t} not found`)}findRelationship(e){return this.#a.get(e)??null}*views(){for(let e of this.$model.views())e.isDeploymentView()&&(yield e)}parent(e){let t=B(e);return this.#t.get(t)||null}children(e){let t=B(e);return this.#n.get(t)}*siblings(e){let t=B(e),n=this.parent(e)?.children()??this.roots();for(let e of n)e.id!==t&&(yield e)}*ancestors(e){let t=B(e),n;for(;n=this.#t.get(t);)yield n,t=n.id}*descendants(e,t=`desc`){for(let n of this.children(e))t===`asc`?(yield n,yield*this.descendants(n.id)):(yield*this.descendants(n.id),yield n)}*incoming(e,t=`all`){let n=B(e);for(let e of this.#o.get(n))switch(!0){case t===`all`:case t===`direct`&&e.target.id===n:case t===`to-descendants`&&e.target.id!==n:yield e;break}}*outgoing(e,t=`all`){let n=B(e);for(let e of this.#s.get(n))switch(!0){case t===`all`:case t===`direct`&&e.source.id===n:case t===`from-descendants`&&e.source.id!==n:yield e;break}}addElement(e){if(this.#e.has(e.id))throw Error(`Element ${e.id} already exists`);let t=se(e)?new I(this,Object.freeze(e)):new L(this,Object.freeze(e),this.$model.element(e.element));this.#e.set(t.id,t);let n=S(t.id);return n?(E(this.#e.has(n),`Parent ${n} of ${t.id} not found`),this.#t.set(t.id,this.node(n)),this.#n.get(n).add(t)):(E(t.isDeploymentNode(),`Root element ${t.id} is not a deployment node`),this.#i.add(t)),t}addRelation(e){if(this.#a.has(e.id))throw Error(`Relation ${e.id} already exists`);let t=new R(this,Object.freeze(e));this.#a.set(t.id,t),this.#o.get(t.target.id).add(t),this.#s.get(t.source.id).add(t);let n=t.boundary?.id??null;if(n)for(let e of[n,...x(n)])this.#c.get(e).add(t);for(let e of x(t.source.id)){if(e===n)break;this.#s.get(e).add(t)}for(let e of x(t.target.id)){if(e===n)break;this.#o.get(e).add(t)}return t}},U=class{source;target;boundary;constructor(e,t){this.model=e,this.$relationship=t,this.source=e.element(p.flatten(t.source)),this.target=e.element(p.flatten(t.target));let n=j(this.source.id,this.target.id);this.boundary=n?this.model.element(n):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return r(this.$relationship.title)?null:this.$relationship.title}get technology(){return r(this.$relationship.technology)?(this.kind&&this.model.specification.relationships[this.kind])?.technology??null:this.$relationship.technology}get hasSummary(){return!!this.$relationship.summary&&!!this.$relationship.description&&!t(this.$relationship.summary,this.$relationship.description)}get summary(){return _.memoize(this,`summary`,h(this.$relationship))}get description(){return _.memoize(this,`description`,y(this.$relationship))}get navigateTo(){return this.$relationship.navigateTo?this.model.view(this.$relationship.navigateTo):null}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let e of this.model.views())e.includesRelation(this.id)&&(yield e)}isDeploymentRelation(){return!1}isModelRelation(){return!0}hasMetadata(){return!!this.$relationship.metadata&&!i(this.$relationship.metadata)}getMetadata(e){return e?this.$relationship.metadata?.[e]:this.$relationship.metadata??{}}isTagged(e){return this.tags.includes(e)}},W=class{Aux;$viewModel;$view;$edge;constructor(e,t,n,r){this.source=n,this.target=r,this.$viewModel=e,this.$view=e.$view,this.$edge=t}get id(){return this.$edge.id}get parent(){return this.$edge.parent?this.$viewModel.node(this.$edge.parent):null}get label(){return this.$edge.label??null}get description(){return _.memoize(this,`description`,this.$edge.description)}get technology(){return this.$edge.technology??null}hasParent(){return this.$edge.parent!==null}get tags(){return this.$edge.tags??[]}get stepNumber(){return this.isStep()?de(this.id):null}get navigateTo(){return this.$edge.navigateTo?this.$viewModel.$model.view(this.$edge.navigateTo):null}get color(){return this.$edge.color}get line(){return this.$edge.line??this.$viewModel.$styles.defaults.relationship.line}get head(){return this.$edge.head??this.$viewModel.$styles.defaults.relationship.arrow}get tail(){return this.$edge.tail}isStep(){return ce(this.id)}*relationships(e){for(let t of this.$edge.relations)if(e){let n=this.$viewModel.$model.findRelationship(t,e);n&&(yield n)}else yield this.$viewModel.$model.relationship(t)}includesRelation(e){let t=typeof e==`string`?e:e.id;return this.$edge.relations.includes(t)}isTagged(e){return this.tags.includes(e)}},G=class{Aux;$viewModel;$view;$node;constructor(e,t){this.$viewModel=e,this.$view=e.$view,this.$node=t}get id(){return this.$node.id}get title(){return this.$node.title}get kind(){return this.$node.kind}get description(){return _.memoize(this,`description`,this.$node.description)}get technology(){return this.$node.technology??null}get notes(){return _.memoize(this,`notes`,this.$node.notes)}get parent(){return this.$node.parent?this.$viewModel.node(this.$node.parent):null}get element(){let e=this.$node.modelRef;return e?this.$viewModel.$model.element(e):null}get deployment(){let e=this.$node.deploymentRef;return e?this.$viewModel.$model.deployment.element(e):null}get shape(){return this.$node.shape}get color(){return this.$node.color}get icon(){return this.$node.icon??null}get tags(){return this.$node.tags}get links(){return this.$node.links??[]}get navigateTo(){return this.$node.navigateTo?this.$viewModel.$model.view(this.$node.navigateTo):null}get style(){return this.$node.style}get x(){return`x`in this.$node?this.$node.x:void 0}get y(){return`y`in this.$node?this.$node.y:void 0}get width(){return`width`in this.$node?this.$node.width:void 0}get height(){return`height`in this.$node?this.$node.height:void 0}children(){return A(this,`children`,()=>new Set(this.$node.children.map(e=>this.$viewModel.node(e))))}*ancestors(){let e=this.parent;for(;e;)yield e,e=e.parent}*siblings(){let e=this.parent?.children()??this.$viewModel.roots();for(let t of e)t.id!==this.id&&(yield t)}*incoming(e=`all`){for(let t of this.$node.inEdges){let n=this.$viewModel.edge(t);switch(!0){case e===`all`:case e===`direct`&&n.target.id===this.id:case e===`to-descendants`&&n.target.id!==this.id:yield n;break}}}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}*outgoing(e=`all`){for(let t of this.$node.outEdges){let n=this.$viewModel.edge(t);switch(!0){case e===`all`:case e===`direct`&&n.source.id===this.id:case e===`from-descendants`&&n.source.id!==this.id:yield n;break}}}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}isLayouted(){return`width`in this.$node&&`height`in this.$node}hasChildren(){return this.$node.children.length>0}hasParent(){return this.$node.parent!==null}hasElement(){return o(this.$node.modelRef)}hasDeployment(){return o(this.$node.deploymentRef)}hasDeployedInstance(){return this.hasElement()&&this.hasDeployment()}isGroup(){return fe(this.$node)}isTagged(e){return this.tags.includes(e)}},K=class{Aux;#e;#t=new Set;#n=new Map;#r=new Map;#i=new Set;#a=new Set;#o=new Set;#s=new P.default(e=>new Set);#c;id;$model;title;folder;viewPath;constructor(e,t,n,r){this.$model=e,this.#e=n,this.id=n.id,this.folder=t,this.#c=r;for(let e of this.#e.nodes){let t=new G(this,Object.freeze(e));this.#n.set(e.id,t),e.parent||this.#t.add(t),e.deploymentRef&&this.#a.add(e.deploymentRef),e.modelRef&&this.#i.add(e.modelRef);for(let e of t.tags)this.#s.get(e).add(t)}for(let e of this.#e.edges){let t=new W(this,Object.freeze(e),this.node(e.source),this.node(e.target));for(let e of t.tags)this.#s.get(e).add(t);for(let t of e.relations)this.#o.add(t);this.#r.set(e.id,t)}this.title=n.title?Me(n.title):null,this.viewPath=n.title?H(n.title):n.id}get $styles(){return this.$model.$styles}get _type(){return this.#e[m]}get stage(){return this.#e[g]}get bounds(){if(`bounds`in this.#e)return this.#e.bounds;if(this.#c)return this.#c.bounds;throw Error(`View is not layouted`)}get titleOrId(){return this.title??this.viewOf?.title??this.id}get titleOrUntitled(){return this.title??`Untitled`}get breadcrumbs(){return A(this,`breadcrumbs`,()=>this.folder.isRoot?[this]:[...this.folder.breadcrumbs,this])}get description(){return _.memoize(this,`description`,this.#e.description)}get tags(){return this.#e.tags??[]}get links(){return this.#e.links??[]}get viewOf(){if(this.isElementView()){let e=this.#e.viewOf;return e?this.$model.element(e):null}return null}get mode(){return this.isDynamicView()?this.#e.variant??`diagram`:null}get includedTags(){return[...this.#s.keys()]}get $view(){if(!this.isLayouted()||`drifts`in this.#e)return this.#e;let e=this.#c;return e?A(this,`withDriftReasons`,()=>De(this.#e,e)):this.#e}get $layouted(){if(!this.isLayouted())throw Error(`View is not layouted`);return this.$manual??this.#e}get hasManualLayout(){return this.#c!==void 0}get hasLayoutDrifts(){if(!this.isLayouted())return!1;let e=this.$manual;return!!e?.drifts&&e.drifts.length>0}get $manual(){if(!this.isLayouted())return null;let e=this.#c;return e?A(this,`snapshotWithManualLayout`,()=>Ee(this.#e,e)):null}get projectId(){return this.$model.projectId}roots(){return this.#t.values()}*compounds(){for(let e of this.#n.values())e.hasChildren()&&(yield e)}node(e){let t=B(e);return b(this.#n.get(t),`Node ${t} not found in view ${this.#e.id}`)}findNode(e){return this.#n.get(B(e))??null}findNodeWithElement(e){let t=B(e);return this.#i.has(t)?he(this.#n.values(),e=>e.hasElement()&&e.element.id===t)??null:null}nodes(){return this.#n.values()}edge(e){let t=B(e);return b(this.#r.get(t),`Edge ${t} not found in view ${this.#e.id}`)}findEdge(e){return this.#r.get(B(e))??null}edges(){return this.#r.values()}*edgesWithRelation(e){for(let t of this.#r.values())t.includesRelation(e)&&(yield t)}*elements(){for(let e of this.#n.values())e.hasElement()&&(yield e)}isTagged(e){return this.tags.includes(e)}includesElement(e){return this.#i.has(B(e))}includesDeployment(e){return this.#a.has(B(e))}includesRelation(e){return this.#o.has(B(e))}isComputed(){return this.#e[g]===`computed`}isLayouted(){return this.#e[g]===`layouted`}isDiagram(){return this.#e[g]===`layouted`}isElementView(){return this.#e[m]===`element`}isScopedElementView(){return this.#e[m]===`element`&&o(this.#e.viewOf)}isDeploymentView(){return this.#e[m]===`deployment`}isDynamicView(){return this.#e[m]===`dynamic`}},q=class e{$model;path;title;isRoot;parentPath;defaultViewId;constructor(e,t,r){this.$model=e,this.path=t.join(`/`),this.isRoot=this.path===``,this.title=n(t),this.isRoot?this.parentPath=void 0:this.parentPath=t.slice(0,-1).join(`/`),this.defaultViewId=r}get defaultView(){return this.defaultViewId?this.$model.view(this.defaultViewId):null}get breadcrumbs(){return E(!this.isRoot,`Root view folder has no breadcrumbs`),A(this,`breadcrumbs`,()=>{let e=this.parent;return e?e.isRoot?[e,this]:[...e.breadcrumbs,this]:[this]})}get parent(){return E(!this.isRoot,`Root view folder has no parent`),r(this.parentPath)?null:this.$model.viewFolder(this.parentPath)}get children(){return this.$model.viewFolderItems(this.path)}get folders(){return A(this,`folders`,()=>{let t=[];for(let n of this.children)n instanceof e&&t.push(n);return t})}get views(){return A(this,`views`,()=>{let e=[];for(let t of this.children)t instanceof K&&e.push(t);return e})}},J=class e{Aux;_elements=new Map;_parents=new Map;_children=new P.default(()=>new Set);_rootElements=new Set;_relations=new Map;_incoming=new P.default(()=>new Set);_outgoing=new P.default(()=>new Set);_internal=new P.default(()=>new Set);_views=new Map;_rootViewFolder;_viewFolders=new Map;_viewFolderItems=new P.default(()=>new Set);_allTags=new P.default(()=>new Set);static fromParsed(t){return new e(t)}static create(t){return new e(t)}static fromDump(t){let{_stage:n=`layouted`,projectId:r=`unknown`,project:i,globals:a,imports:o,deployments:s,views:c,relations:ee,elements:te,specification:l}=t;return new e({[g]:n,projectId:r,project:i,globals:{predicates:a?.predicates??{},dynamicPredicates:a?.dynamicPredicates??{},styles:a?.styles??{}},imports:o??{},deployments:{elements:s?.elements??{},relations:s?.relations??{}},views:c??{},relations:ee??{},elements:te??{},specification:l})}deployment;$data;constructor(e){this.$data=e;for(let[,t]of ee(e.elements)){let e=this.addElement(t);for(let t of e.tags)this._allTags.get(t).add(e)}for(let[t,n]of ee(e.imports??{}))for(let e of ye(n)){let n=this.addImportedElement(t,e);for(let e of n.tags)this._allTags.get(e).add(n)}for(let t of f(e.relations)){let e=this.addRelation(t);for(let t of e.tags)this._allTags.get(t).add(e)}if(this.deployment=new Ne(this),pe(e,`computed`)||pe(e,`layouted`)){let t=be(`/`),n=l(f(e.views),c(e=>({view:e,path:H(e.title??e.id),folderPath:e.title&&je(e.title)||``})),d((e,n)=>t(e.folderPath,n.folderPath))),r=e=>{let t=this._viewFolders.get(e);if(!t){let r=re(e,`/`);E(s(r,1),`View group path "${e}" must have at least one element`);let i;i=e===``?n.find(e=>e.view.id===`index`):n.find(t=>t.path===e),t=new q(this,r,i?.view.id),this._viewFolders.set(e,t)}return t};this._rootViewFolder=r(``);for(let{folderPath:e}of n)this._viewFolders.has(e)||re(e,`/`).reduce((e,t)=>{let n=e.join(`/`),a=r(i(n)?t:n+`/`+t);return this._viewFolderItems.get(n).add(a),e.push(t),e},[]);for(let{view:t,folderPath:i}of n){let n=new K(this,r(i),t,e.manualLayouts?.[t.id]);this._viewFolderItems.get(i).add(n),this._views.set(t.id,n);for(let e of n.tags)this._allTags.get(e).add(n)}}else this._rootViewFolder=new q(this,[``],void 0),this._viewFolders.set(this._rootViewFolder.path,this._rootViewFolder)}get asParsed(){return this}get asComputed(){return this}get asLayouted(){return this}get $styles(){return A(this,`styles`,()=>ie.from(this.project.styles,this.specification.customColors))}isParsed(){return this.stage===`parsed`}isLayouted(){return this.stage===`layouted`}isComputed(){return this.stage===`computed`}get $model(){return this.$data}get stage(){return this.$data[g]}get projectId(){return this.$data.projectId??`default`}get project(){return this.$data.project??A(this,Symbol.for(`project`),()=>({id:this.projectId,styles:{},manualLayouts:{}}))}get specification(){return this.$data.specification}get globals(){return A(this,Symbol.for(`globals`),()=>({predicates:{...this.$data.globals?.predicates},dynamicPredicates:{...this.$data.globals?.dynamicPredicates},styles:{...this.$data.globals?.styles}}))}element(e){if(e instanceof F)return e;let t=B(e);return b(this._elements.get(t),`Element ${t} not found`)}findElement(e){return this._elements.get(B(e))??null}roots(){return this._rootElements.values()}elements(){return this._elements.values()}relationships(){return this._relations.values()}relationship(e,t){if(t===`deployment`)return this.deployment.relationship(e);let n=B(e),r=this._relations.get(n)??null;return r||t===`model`?b(r,`Model relation ${n} not found`):b(this.deployment.findRelationship(n),`No model/deployment relation ${n} not found`)}findRelationship(e,t){if(t===`deployment`)return this.deployment.findRelationship(e);let n=this._relations.get(B(e))??null;return n||t===`model`?n:this.deployment.findRelationship(e)}views(){return this._views.values()}view(e){let t=B(e);return b(this._views.get(t),`View ${t} not found`)}findView(e){return this._views.get(e)??null}findManualLayout(e){return`manualLayouts`in this.$data?this.$data.manualLayouts?.[e]??null:null}viewFolder(e){return b(this._viewFolders.get(e),`View folder ${e} not found`)}get rootViewFolder(){return this._rootViewFolder}get hasViewFolders(){return this._viewFolders.size>1}viewFolderItems(e){return E(this._viewFolders.has(e),`View folder ${e} not found`),this._viewFolderItems.get(e)}parent(e){let t=B(e);return this._parents.get(t)||null}children(e){let t=B(e);return this._children.get(t)}*siblings(e){let t=B(e),n=this._parents.get(t),r=n?this._children.get(n.id).values():this.roots();for(let e of r)e.id!==t&&(yield e)}*ancestors(e){let t=B(e),n;for(;n=this._parents.get(t);)yield n,t=n.id}*descendants(e){for(let t of this.children(e))yield t,yield*this.descendants(t.id)}*incoming(e,t=`all`){let n=B(e);for(let e of this._incoming.get(n))switch(!0){case t===`all`:case t===`direct`&&e.target.id===n:case t===`to-descendants`&&e.target.id!==n:yield e;break}}*outgoing(e,t=`all`){let n=B(e);for(let e of this._outgoing.get(n))switch(!0){case t===`all`:case t===`direct`&&e.source.id===n:case t===`from-descendants`&&e.source.id!==n:yield e;break}}get tags(){return A(this,`tags`,()=>d([...this._allTags.keys()],_e))}get tagsSortedByUsage(){return A(this,`tagsSortedByUsage`,()=>l([...this._allTags.entries()],c(([e,t])=>({tag:e,count:t.size,tagged:t})),d((e,t)=>_e(e.tag,t.tag)),te([ne(`count`),`desc`])))}findByTag(e,t){return me(this._allTags.get(e),e=>t===`elements`?e instanceof F:t===`views`?e instanceof K:t===`relationships`?e instanceof U:!0)}*elementsOfKind(e){for(let t of this._elements.values())t.kind===e&&(yield t)}*elementsWhere(e){let t=ae(e);for(let e of this._elements.values())t(e)&&(yield e)}*relationshipsWhere(e){let t=ae(e);for(let e of this._relations.values())t(e)&&(yield e)}addElement(e){if(this._elements.has(e.id))throw Error(`Element ${e.id} already exists`);let t=new F(this,Object.freeze(e));this._elements.set(t.id,t);let n=S(t.id);return n?(E(this._elements.has(n),`Parent ${n} of ${t.id} not found`),this._parents.set(t.id,this.element(n)),this._children.get(n).add(t)):this._rootElements.add(t),t}addImportedElement(e,t){E(!le(t.id),`Imported element already has global FQN`);let n=oe(e,t.id);if(this._elements.has(n))throw Error(`Element ${n} already exists`);let r=new F(this,Object.freeze({...t,id:n}));this._elements.set(r.id,r);let i=S(r.id);for(;i;){if(i.includes(`.`)&&this._elements.has(i))return this._parents.set(r.id,this.element(i)),this._children.get(i).add(r),r;i=S(i)}return this._rootElements.add(r),r}addRelation(e){if(this._relations.has(e.id))throw Error(`Relation ${e.id} already exists`);let t=new U(this,Object.freeze(e)),{source:n,target:r}=t;this._relations.set(t.id,t),this._incoming.get(r.id).add(t),this._outgoing.get(n.id).add(t);let i=j(n.id,r.id);if(i)for(let e of[i,...x(i)])this._internal.get(e).add(t);for(let e of x(n.id)){if(e===i)break;this._outgoing.get(e).add(t)}for(let e of x(r.id)){if(e===i)break;this._incoming.get(e).add(t)}return t}};(function(e){e.EMPTY=J.create({_stage:`computed`,projectId:`default`,project:{id:`default`},specification:{elements:{},relationships:{},deployments:{},tags:{}},globals:{predicates:{},dynamicPredicates:{},styles:{}},deployments:{elements:{},relations:{}},elements:{},relations:{},views:{},imports:{}})})(J||={});let Pe;(function(e){e.isInside=e=>t=>w(e,t.source.id)&&w(e,t.target.id);let t=e.isDirectedBetween=(e,t)=>n=>(n.source.id===e||w(e,n.source.id))&&(n.target.id===t||w(t,n.target.id));e.isAnyBetween=(e,n)=>{let r=t(e,n),i=t(n,e);return e=>r(e)||i(e)};let n=e.isIncoming=e=>t=>(t.target.id===e||w(e,t.target.id))&&!w(e,t.source.id),r=e.isOutgoing=e=>t=>(t.source.id===e||w(e,t.source.id))&&!w(e,t.target.id);e.isAnyInOut=e=>{let t=n(e),i=r(e);return e=>t(e)||i(e)}})(Pe||={});const Y=Symbol.for(`nodejs.util.inspect.custom`);var Fe=class e{id;constructor(e,t,n){this.source=e,this.target=t,this.relations=n,this.id=Ce(`deployment:${e.id}:${t.id}`)}get expression(){return`${this.source.id} -> ${this.target.id}`}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target),this._boundary}nonEmpty(){return this.relations.nonEmpty}[Y](t,n,r){let i=this.toString();return Object.defineProperty(i,`constructor`,{value:e,enumerable:!1}),i}toString(){let e=[...this.relations.model].map(e=>` `+e.expression);e.length?e.unshift(` model:`):e.unshift(` model: []`);let t=[...this.relations.deployment].map(e=>` `+e.expression);return t.length?t.unshift(` deployment:`):t.unshift(` deployment: []`),[this.expression,...e,...t].join(`
3
+ `)}hasDirectDeploymentRelation(){for(let e of this.relations.deployment)if(e.source.id===this.source.id||e.target.id===this.target.id)return!0;return!1}*values(){yield*this.relations.model,yield*this.relations.deployment}mergeWith(t){return Array.isArray(t)?t.reduce((e,t)=>e.mergeWith(t),this):(E(this.source.id===t.source.id,`Cannot merge connections with different sources`),E(this.target.id===t.target.id,`Cannot merge connections with different targets`),new e(this.source,this.target,this.relations.union(t.relations)))}difference(t){return new e(this.source,this.target,this.relations.difference(t.relations))}intersect(t){return new e(this.source,this.target,this.relations.intersect(t.relations))}equals(t){return E(t instanceof e,`Other should ne DeploymentConnectionModel`),this.id===t.id&&this.source.id===t.source.id&&this.target.id===t.target.id&&M(this.relations.model,t.relations.model)&&M(this.relations.deployment,t.relations.deployment)}update(t){return t&&={model:this.relations.model,deployment:this.relations.deployment,...t},new e(this.source,this.target,t?new z(t.model??new Set,t.deployment??new Set):this.relations)}};function X(e,t){if(!t){let t=e;return e=>X(e,t)}let n=e.source===t.source,r=e.target===t.target;if(n&&r)return!1;let i=w(t.source.id,e.source.id),a=w(t.target.id,e.target.id);return i&&a||n&&a||r&&i}function Ie(e,t){let n=t;for(let t of e)X(t,n)&&(n=t);return n===t?null:n}function Le(e){let t=[],n=e.slice(),r;for(;r=n.shift();){let e;for(;e=Ie(n,r);){let r=n.indexOf(e);t.push(n.splice(r,1)[0])}t.push(r)}return t}function Re(e){return e.boundary?.id?`.${e.boundary.id}`:``}function ze(e,t){if(!e||Se(e)){let t=e??`asc`;return e=>Be(e,t)}return Be(e,t??`asc`)}function Be(e,t){return l(e,c(e=>({id:Re(e),conn:e})),ge(t),c(e=>e.conn))}function Ve(e,t){return e.filter(e=>X(t,e))}function He(e,t){return e.filter(X(t))}function Ue(e){let t=new Map;for(let n of e){let e=t.get(n.id);e?t.set(n.id,n.mergeWith(e)):t.set(n.id,n)}return[...t.values()]}function We(e,t){let n=new Map([...t].map(e=>[e.id,e]));return[...e].reduce((e,t)=>{let r=n.get(t.id);if(!r)return e.push(t),e;let i=t.difference(r);return i.nonEmpty()&&e.push(i),e},[])}function Z(e,t){return t?e.source===t.source&&e.target===t.target:t=>e.source===t.source&&e.target===t.target}function Ge(e,t){return t?e.source===t.source:t=>e.source===t.source}function Ke(e,t){return t?e.target===t.target:t=>e.target===t.target}function qe(e,t){if(!t){let t=e;return e=>qe(e,t)}let n=e;return T(n.source,t)&&!T(n.target,t)}function Je(e,t){if(!t){let t=e;return e=>Je(e,t)}let n=e;return T(n.target,t)&&!T(n.source,t)}function Ye(e,t){if(!t){let t=e;return e=>Ye(e,t)}let n=e;return T(n.source,t)!==T(n.target,t)}var Q=class e{id;constructor(e,t,n=new Set){this.source=e,this.target=t,this.relations=n,this.id=Ce(`model:${e.id}:${t.id}`)}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target)}get expression(){return`${this.source.id} -> ${this.target.id}`}get isDirect(){return this.nonEmpty()&&!this.isImplicit}get isImplicit(){return this.nonEmpty()&&we(this.relations,a(Z(this)))}get directRelations(){return new Set(me(this.relations,Z(this)))}nonEmpty(){return this.relations.size>0}mergeWith(t){return E(this.source.id===t.source.id,`Cannot merge connections with different sources`),E(this.target.id===t.target.id,`Cannot merge connections with different targets`),new e(this.source,this.target,N(this.relations,t.relations))}difference(t){return new e(this.source,this.target,O(this.relations,t.relations))}intersect(t){return E(t instanceof e,`Cannot intersect connection with different type`),new e(this.source,this.target,k(this.relations,t.relations))}equals(t){E(t instanceof e,`Cannot merge connection with different type`);let n=t;return this.id===n.id&&this.source.id===n.source.id&&this.target.id===n.target.id&&M(this.relations,n.relations)}update(t){return new e(this.source,this.target,t)}[Y](t,n,r){let i=this.toString();return Object.defineProperty(i,`constructor`,{value:e,enumerable:!1}),i}toString(){return[this.expression,this.relations.size?` relations:`:` relations: [ ]`,...[...this.relations].map(e=>` `+e.expression)].join(`
4
+ `)}reversed(){return new e(this.target,this.source)}},Xe=e({findConnection:()=>$,findConnectionsBetween:()=>Ze,findConnectionsWithin:()=>Qe});function $(e,t,n=`directed`){if(e===t||ve(e,t))return[];let r=e.allOutgoing.intersect(t.allIncoming),i=r.nonEmpty?[new Fe(e,t,r)]:[];return n===`directed`?i:[...i,...$(t,e,`directed`)]}function Ze(e,t,n=`both`){if(e.allIncoming.isEmpty&&e.allOutgoing.isEmpty)return[];let r=[],i=[];for(let a of t)if(e!==a)for(let t of $(e,a,n))t.source===e?r.push(t):i.push(t);return[...r,...i]}function Qe(e){return[...e].reduce((e,t,n,r)=>(n===r.length-1||e.push(...Ze(t,r.slice(n+1),`both`)),e),[])}var $e=e({findConnection:()=>et,findConnectionsBetween:()=>tt,findConnectionsWithin:()=>nt});function et(e,t,n=`directed`){if(e===t||ve(e,t))return[];let r=k(e.allOutgoing,t.allIncoming),i=r.size>0?new Q(e,t,r):null;if(n===`directed`)return i?[i]:[];let a=k(e.allIncoming,t.allOutgoing),o=a.size>0?new Q(t,e,a):null;return i&&o?[i,o]:i?[i]:o?[o]:[]}function tt(e,t,n=`both`){if(e.allIncoming.size===0&&e.allOutgoing.size===0)return[];let r=[],i=[];for(let a of t)if(e!==a)for(let t of et(e,a,n))t.source===e?r.push(t):i.push(t);return[...r,...i]}function nt(e){return[...e].reduce((e,t,n,r)=>(n===r.length-1||e.push(...tt(t,r.slice(n+1),`both`)),e),[])}function rt(e){return e instanceof I}function it(e){return e instanceof L}function at(e){return rt(e)||it(e)}function ot(e){return e instanceof ke}function st(e){return e instanceof R}function ct(e){return e instanceof U}function lt(e){return e instanceof F}function ut(e){return e instanceof K}function dt(e){return e instanceof G}function ft(e){return e instanceof W}export{Fe as A,Ae as B,Ye as C,Ue as D,qe as E,K as F,I as G,je as H,G as I,F as J,R as K,W as L,Pe as M,J as N,ze as O,q as P,U as R,Ke as S,X as T,H as U,Me as V,L as W,Ve as _,ft as a,Ge as b,ot as c,et as d,tt as f,We as g,Q as h,st as i,Y as j,Le as k,dt as l,Xe as m,at as n,lt as o,$e as p,z as q,rt as r,ut as s,it as t,ct as u,Ie as v,Je as w,Z as x,He as y,Ne as z};