@likec4/core 1.47.0 → 1.48.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 (181) hide show
  1. package/LICENSE +1 -1
  2. package/dist/_chunks/Builder.view-element.mjs +3284 -0
  3. package/dist/_chunks/LikeC4Model.d.mts +1287 -0
  4. package/dist/_chunks/LikeC4Styles.mjs +691 -0
  5. package/dist/_chunks/RichText.d.mts +84 -0
  6. package/dist/_chunks/RichText.mjs +148 -0
  7. package/dist/_chunks/_aux.d.mts +289 -0
  8. package/dist/_chunks/_aux.mjs +18 -0
  9. package/dist/_chunks/_types.d.mts +781 -0
  10. package/dist/_chunks/_types2.d.mts +38 -0
  11. package/dist/_chunks/assignTagColors.mjs +24 -0
  12. package/dist/_chunks/calcDriftsFromSnapshot.mjs +379 -0
  13. package/dist/_chunks/connection.mjs +0 -0
  14. package/dist/_chunks/const.d.mts +43 -0
  15. package/dist/_chunks/const.mjs +33 -0
  16. package/dist/_chunks/expression-model.d.mts +192 -0
  17. package/dist/_chunks/expression-model.mjs +103 -0
  18. package/dist/_chunks/expression.d.mts +347 -0
  19. package/dist/_chunks/expression.mjs +107 -0
  20. package/dist/_chunks/find.d.mts +82 -0
  21. package/dist/_chunks/find.mjs +646 -0
  22. package/dist/_chunks/find2.d.mts +78 -0
  23. package/dist/_chunks/find2.mjs +287 -0
  24. package/dist/_chunks/fqnRef.d.mts +58 -0
  25. package/dist/_chunks/fqnRef.mjs +41 -0
  26. package/dist/_chunks/geometry.mjs +335 -0
  27. package/dist/_chunks/index.d.mts +169 -0
  28. package/dist/_chunks/index2.d.mts +937 -0
  29. package/dist/_chunks/index3.d.mts +146 -0
  30. package/dist/_chunks/index4.d.mts +62 -0
  31. package/dist/_chunks/index5.d.mts +42 -0
  32. package/dist/_chunks/index6.d.mts +43 -0
  33. package/dist/{shared/core.OtRNdMxy.d.mts → _chunks/index7.d.mts} +113 -197
  34. package/dist/_chunks/index8.d.mts +144 -0
  35. package/dist/_chunks/invariant.mjs +18 -0
  36. package/dist/_chunks/iterable.mjs +146 -0
  37. package/dist/_chunks/libs/@mantine/colors-generator.mjs +3416 -0
  38. package/dist/_chunks/libs/@ungap/structured-clone.mjs +213 -0
  39. package/dist/_chunks/libs/bail.mjs +14 -0
  40. package/dist/_chunks/libs/ccount.mjs +25 -0
  41. package/dist/_chunks/libs/character-entities-html4.mjs +263 -0
  42. package/dist/_chunks/libs/character-entities-legacy.mjs +117 -0
  43. package/dist/_chunks/libs/character-entities.mjs +2136 -0
  44. package/dist/_chunks/libs/comma-separated-tokens.mjs +18 -0
  45. package/dist/_chunks/libs/decode-named-character-reference.mjs +21 -0
  46. package/dist/_chunks/libs/defu.mjs +42 -0
  47. package/dist/_chunks/libs/devlop.mjs +5 -0
  48. package/dist/_chunks/libs/escape-string-regexp.mjs +8 -0
  49. package/dist/_chunks/libs/extend.mjs +77 -0
  50. package/dist/_chunks/libs/graphology-dag.mjs +703 -0
  51. package/dist/_chunks/libs/graphology-types.d.mts +601 -0
  52. package/dist/_chunks/libs/graphology.d.mts +6 -0
  53. package/dist/_chunks/libs/graphology.mjs +4565 -0
  54. package/dist/_chunks/libs/hast-util-sanitize.mjs +863 -0
  55. package/dist/_chunks/libs/hast-util-to-html.mjs +2696 -0
  56. package/dist/_chunks/libs/is-plain-obj.mjs +9 -0
  57. package/dist/_chunks/libs/longest-streak.mjs +30 -0
  58. package/dist/_chunks/libs/markdown-table.mjs +290 -0
  59. package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +653 -0
  60. package/dist/_chunks/libs/mdast-util-from-markdown.mjs +8522 -0
  61. package/dist/_chunks/libs/mdast-util-gfm.mjs +2393 -0
  62. package/dist/_chunks/libs/mdast-util-to-hast.mjs +1803 -0
  63. package/dist/_chunks/libs/micromark-extension-gfm.mjs +2243 -0
  64. package/dist/_chunks/libs/mnemonist.d.mts +254 -0
  65. package/dist/_chunks/libs/mnemonist.mjs +1978 -0
  66. package/dist/_chunks/libs/natural-compare-lite.mjs +42 -0
  67. package/dist/_chunks/libs/rehype-sanitize.mjs +29 -0
  68. package/dist/_chunks/libs/rehype-stringify.mjs +34 -0
  69. package/dist/_chunks/libs/remark-gfm.mjs +36 -0
  70. package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +100 -0
  71. package/dist/_chunks/libs/remark-parse.mjs +39 -0
  72. package/dist/_chunks/libs/remark-rehype.mjs +171 -0
  73. package/dist/_chunks/libs/remeda.mjs +702 -0
  74. package/dist/_chunks/libs/trough.mjs +158 -0
  75. package/dist/_chunks/libs/unified.mjs +2212 -0
  76. package/dist/_chunks/mnemonist.d.mts +1 -0
  77. package/dist/_chunks/mnemonist.mjs +0 -0
  78. package/dist/_chunks/model.mjs +1898 -0
  79. package/dist/_chunks/model2.mjs +0 -0
  80. package/dist/_chunks/relationships-view.mjs +132 -0
  81. package/dist/_chunks/rolldown-runtime.mjs +42 -0
  82. package/dist/{shared/core.C_3y3eqV.d.mts → _chunks/scalar.d.mts} +13 -43
  83. package/dist/_chunks/scalar.mjs +84 -0
  84. package/dist/_chunks/utils.mjs +483 -0
  85. package/dist/builder/index.d.mts +11 -775
  86. package/dist/builder/index.mjs +631 -1022
  87. package/dist/compute-view/index.d.mts +85 -56
  88. package/dist/compute-view/index.mjs +247 -214
  89. package/dist/compute-view/relationships-view/index.d.mts +16 -51
  90. package/dist/compute-view/relationships-view/index.mjs +6 -184
  91. package/dist/geometry/index.d.mts +2 -109
  92. package/dist/geometry/index.mjs +2 -327
  93. package/dist/index.d.mts +18 -20
  94. package/dist/index.mjs +27 -18
  95. package/dist/model/connection/deployment/index.d.mts +12 -15
  96. package/dist/model/connection/deployment/index.mjs +9 -2
  97. package/dist/model/connection/index.d.mts +14 -75
  98. package/dist/model/connection/index.mjs +10 -3
  99. package/dist/model/connection/model/index.d.mts +12 -15
  100. package/dist/model/connection/model/index.mjs +8 -2
  101. package/dist/model/index.d.mts +15 -57
  102. package/dist/model/index.mjs +11 -4
  103. package/dist/styles/index.d.mts +9 -117
  104. package/dist/styles/index.mjs +26 -59
  105. package/dist/types/RichText.d.mts +3 -0
  106. package/dist/types/RichText.mjs +7 -0
  107. package/dist/types/_aux.d.mts +3 -4
  108. package/dist/types/_aux.mjs +2 -7
  109. package/dist/types/expression-model.d.mts +6 -190
  110. package/dist/types/expression-model.mjs +6 -108
  111. package/dist/types/expression.d.mts +5 -6
  112. package/dist/types/expression.mjs +6 -112
  113. package/dist/types/fqnRef.d.mts +4 -60
  114. package/dist/types/fqnRef.mjs +6 -44
  115. package/dist/types/index.d.mts +9 -47
  116. package/dist/types/index.mjs +14 -16
  117. package/dist/types/scalar.d.mts +2 -2
  118. package/dist/types/scalar.mjs +7 -4
  119. package/dist/utils/graphology/index.d.mts +2 -1864
  120. package/dist/utils/graphology/index.mjs +3 -1
  121. package/dist/utils/index.d.mts +11 -124
  122. package/dist/utils/index.mjs +16 -43
  123. package/dist/utils/iterable/index.d.mts +9 -132
  124. package/dist/utils/iterable/index.mjs +2 -61
  125. package/dist/utils/mnemonist.d.mts +2 -0
  126. package/dist/utils/mnemonist.mjs +12 -0
  127. package/package.json +17 -22
  128. package/compute-view/relationships/package.json +0 -4
  129. package/dist/shared/core.3ZhnKAlZ.mjs +0 -106
  130. package/dist/shared/core.78IWAHAE.mjs +0 -332
  131. package/dist/shared/core.B85MJLTf.mjs +0 -5
  132. package/dist/shared/core.BFd1lU9R.mjs +0 -29
  133. package/dist/shared/core.BKlholso.mjs +0 -3
  134. package/dist/shared/core.BNN-3vPH.mjs +0 -1255
  135. package/dist/shared/core.BPGOjone.d.mts +0 -46
  136. package/dist/shared/core.BP_QHEXs.mjs +0 -785
  137. package/dist/shared/core.BbE4y-yl.mjs +0 -177
  138. package/dist/shared/core.Bdy3hhTc.mjs +0 -28382
  139. package/dist/shared/core.BfCKSW-g.d.mts +0 -1266
  140. package/dist/shared/core.BhNcrwzK.mjs +0 -7
  141. package/dist/shared/core.BkVA6gjl.mjs +0 -5
  142. package/dist/shared/core.BoYfZOBm.mjs +0 -3
  143. package/dist/shared/core.BsSXS-_R.mjs +0 -7
  144. package/dist/shared/core.C3JowhaZ.mjs +0 -32
  145. package/dist/shared/core.C4x8aaWa.mjs +0 -27
  146. package/dist/shared/core.CAgYpDtM.d.mts +0 -98
  147. package/dist/shared/core.CHf8VEa3.mjs +0 -1206
  148. package/dist/shared/core.CLSZtnFh.mjs +0 -69
  149. package/dist/shared/core.CbT8JVYL.mjs +0 -5
  150. package/dist/shared/core.CdNCAwq7.mjs +0 -176
  151. package/dist/shared/core.CmGY9blO.mjs +0 -6717
  152. package/dist/shared/core.CmPXpJ8l.mjs +0 -21
  153. package/dist/shared/core.Coi_LOUZ.mjs +0 -7
  154. package/dist/shared/core.CqAJJpK_.mjs +0 -3
  155. package/dist/shared/core.CywrQs86.d.mts +0 -31
  156. package/dist/shared/core.D00YbOhQ.d.mts +0 -300
  157. package/dist/shared/core.D0WZutNd.mjs +0 -94
  158. package/dist/shared/core.D4npX2q8.mjs +0 -18
  159. package/dist/shared/core.DB0Ue5Wx.d.mts +0 -70
  160. package/dist/shared/core.DC5IAaDT.d.mts +0 -334
  161. package/dist/shared/core.DE9qzhn8.d.mts +0 -83
  162. package/dist/shared/core.DGcIbsj4.mjs +0 -3946
  163. package/dist/shared/core.DH7TXqXf.mjs +0 -136
  164. package/dist/shared/core.DKhRkHRN.d.mts +0 -41
  165. package/dist/shared/core.DRJma0Ol.mjs +0 -22
  166. package/dist/shared/core.DU5SRqNF.mjs +0 -2209
  167. package/dist/shared/core.DXhDWKFZ.d.mts +0 -3
  168. package/dist/shared/core.DbfO90vF.mjs +0 -434
  169. package/dist/shared/core.DcS-0zys.mjs +0 -10
  170. package/dist/shared/core.Dh119QSP.mjs +0 -4995
  171. package/dist/shared/core.DjcWextK.mjs +0 -1371
  172. package/dist/shared/core.Dojz4bvg.d.mts +0 -504
  173. package/dist/shared/core.FZ305VYd.mjs +0 -21
  174. package/dist/shared/core.RfnaEmgA.mjs +0 -7
  175. package/dist/shared/core.btEq3i3f.mjs +0 -300
  176. package/dist/shared/core.oSV6SRfk.mjs +0 -13
  177. package/dist/shared/core.om36dXXW.mjs +0 -41
  178. package/dist/shared/core.osFs8tU7.d.mts +0 -466
  179. package/dist/shared/core.q10OP9oJ.mjs +0 -5
  180. package/dist/shared/core.tpvDGvdC.d.mts +0 -87
  181. package/dist/shared/core.uFk_o9X6.mjs +0 -13
@@ -0,0 +1,483 @@
1
+ import { r as __toESM } from "./rolldown-runtime.mjs";
2
+ import { N as e$2, O as e, Q as t, Z as t$4, a as t$2, f as e$1, t as t$1, w as t$3 } from "./libs/remeda.mjs";
3
+ import { t as require_natural_compare_lite } from "./libs/natural-compare-lite.mjs";
4
+ import { t as invariant } from "./invariant.mjs";
5
+ import { c as import_set } from "./libs/mnemonist.mjs";
6
+ import { t as defu } from "./libs/defu.mjs";
7
+ import { n as defaultSchema } from "./libs/hast-util-sanitize.mjs";
8
+ import { t as rehypeSanitize } from "./libs/rehype-sanitize.mjs";
9
+ import { t as rehypeStringify } from "./libs/rehype-stringify.mjs";
10
+ import { c as toString, t as fromMarkdown } from "./libs/mdast-util-from-markdown.mjs";
11
+ import { t as remarkGfm } from "./libs/remark-gfm.mjs";
12
+ import { t as remarkAlert } from "./libs/remark-github-blockquote-alert.mjs";
13
+ import { t as remarkParse } from "./libs/remark-parse.mjs";
14
+ import { t as remarkRehype } from "./libs/remark-rehype.mjs";
15
+ import { t as unified } from "./libs/unified.mjs";
16
+ import { hash } from "ohash";
17
+
18
+ //#region src/utils/compare-natural.ts
19
+ var import_natural_compare_lite = /* @__PURE__ */ __toESM(require_natural_compare_lite(), 1);
20
+ function compareNatural(a, b) {
21
+ if (a === b) return 0;
22
+ if (e(a)) {
23
+ if (e(b)) return (0, import_natural_compare_lite.default)(a, b);
24
+ return 1;
25
+ }
26
+ return e(b) ? -1 : 0;
27
+ }
28
+ /**
29
+ * Compares two strings lexicographically first, then hierarchically based on their depth.\
30
+ * From parent nodes to leaves
31
+ *
32
+ * @example
33
+ * const lines = [
34
+ * 'b.c',
35
+ * 'b',
36
+ * 'a.b.c',
37
+ * ]
38
+ * lines.sort(compareNaturalHierarchically('.'))
39
+ * // [
40
+ * // 'a.b.c',
41
+ * // 'b',
42
+ * // 'b.c',
43
+ * // ]
44
+ */
45
+ function compareNaturalHierarchically(separator = ".", deepestFirst = false) {
46
+ return (a, b) => {
47
+ if (a === b) return 0;
48
+ if (!a) return -1;
49
+ if (!b) return 1;
50
+ const aParts = a.split(separator);
51
+ const bParts = b.split(separator);
52
+ const minLength = Math.min(aParts.length, bParts.length);
53
+ for (let i = 0; i < minLength; i++) {
54
+ const aPart = aParts[i];
55
+ const bPart = bParts[i];
56
+ const comparison = (0, import_natural_compare_lite.default)(aPart, bPart);
57
+ if (comparison !== 0) return comparison;
58
+ }
59
+ const diff = aParts.length - bParts.length;
60
+ return deepestFirst ? -1 * diff : diff;
61
+ };
62
+ }
63
+
64
+ //#endregion
65
+ //#region src/utils/common-head.ts
66
+ /**
67
+ * Common head of two arrays
68
+ *
69
+ * @param equals - Equality function, defaults to `Object.is`
70
+ */
71
+ function commonHead(sources, targets, equals) {
72
+ if (sources.length === 0 || targets.length === 0) return [];
73
+ equals ??= Object.is;
74
+ return t(t$1(sources, targets), t$2(([source, target]) => equals(source, target)), t$3(([source, _]) => source));
75
+ }
76
+
77
+ //#endregion
78
+ //#region src/utils/guards.ts
79
+ function isString(value) {
80
+ return value != null && typeof value === "string";
81
+ }
82
+ function isNonEmptyArray(arr) {
83
+ return !!arr && Array.isArray(arr) && arr.length > 0;
84
+ }
85
+ function hasProp(value, path) {
86
+ return value[path] != null;
87
+ }
88
+ /**
89
+ * Creates a type guard that checks if a value matches any of the provided predicates.
90
+ *
91
+ * @template Predicates - A non-empty array of guard functions
92
+ * @param predicates - The guard functions to test against
93
+ * @returns A type guard function that returns true if the value matches any of the predicates
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * const isStringOrNumber = isAnyOf(isString, isNumber);
98
+ *
99
+ * if (isStringOrNumber(value)) {
100
+ * // value is now typed as string | number
101
+ * console.log(value);
102
+ * }
103
+ * ```
104
+ */
105
+ function isAnyOf(...predicates) {
106
+ return (value) => {
107
+ return predicates.some((predicate) => predicate(value));
108
+ };
109
+ }
110
+
111
+ //#endregion
112
+ //#region src/utils/fqn.ts
113
+ function parentFqn(fqn) {
114
+ const lastDot = fqn.lastIndexOf(".");
115
+ if (lastDot > 0) return fqn.slice(0, lastDot);
116
+ return null;
117
+ }
118
+ function nameFromFqn(fqn) {
119
+ const lastDot = fqn.lastIndexOf(".");
120
+ if (lastDot > 0) return fqn.slice(lastDot + 1);
121
+ else return fqn;
122
+ }
123
+ const asString = (e) => isString(e) ? e : e.id;
124
+ function isAncestor(arg1, arg2) {
125
+ const arg1Id = asString(arg1);
126
+ if (arg2) return asString(arg2).startsWith(arg1Id + ".");
127
+ return (ancestor) => {
128
+ const ancestorId = asString(ancestor);
129
+ return arg1Id.startsWith(ancestorId + ".");
130
+ };
131
+ }
132
+ function isSameHierarchy(one, another) {
133
+ if (!another) return (b) => isSameHierarchy(one, b);
134
+ const first = asString(one);
135
+ const second = asString(another);
136
+ return first === second || second.startsWith(first + ".") || first.startsWith(second + ".");
137
+ }
138
+ function isDescendantOf(descedant, ancestor) {
139
+ if (!ancestor) return (d) => isAncestor(descedant, d);
140
+ return isAncestor(ancestor, descedant);
141
+ }
142
+ /**
143
+ * How deep in the hierarchy the element is.
144
+ * Root element has depth 1
145
+ */
146
+ function hierarchyLevel(elementOfFqn) {
147
+ return (isString(elementOfFqn) ? elementOfFqn : elementOfFqn.id).split(".").length;
148
+ }
149
+ /**
150
+ * Calculate the distance as number of steps from one element to another, i.e.
151
+ * going up to the common ancestor, then going down to the other element.
152
+ * Sibling distance is always 1
153
+ *
154
+ * Can be used for hierarchical clustering
155
+ */
156
+ function hierarchyDistance(one, another) {
157
+ const first = isString(one) ? one : one.id;
158
+ const second = isString(another) ? another : another.id;
159
+ if (first === second) return 0;
160
+ const firstDepth = hierarchyLevel(first);
161
+ const secondDepth = hierarchyLevel(second);
162
+ if (isSameHierarchy(first, second)) return Math.abs(firstDepth - secondDepth);
163
+ const ancestor = commonAncestor(first, second);
164
+ const ancestorDepth = ancestor ? hierarchyLevel(ancestor) : 0;
165
+ return firstDepth + secondDepth - (2 * ancestorDepth + 1);
166
+ }
167
+ function commonAncestor(first, second) {
168
+ const a = first.split(".");
169
+ if (a.length < 2) return null;
170
+ const b = second.split(".");
171
+ if (b.length < 2) return null;
172
+ let ancestor = [];
173
+ for (let i = 0; i < Math.min(a.length, b.length) - 1 && a[i] === b[i]; i++) ancestor.push(a[i]);
174
+ if (ancestor.length === 0) return null;
175
+ return ancestor.join(".");
176
+ }
177
+ /**
178
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
179
+ * going up from parent to the root
180
+ */
181
+ function ancestorsFqn(fqn) {
182
+ const path = fqn.split(".");
183
+ path.pop();
184
+ if (path.length === 0) return [];
185
+ return path.reduce((acc, part, idx) => {
186
+ if (idx === 0) {
187
+ acc.push(part);
188
+ return acc;
189
+ }
190
+ acc.unshift(`${acc[0]}.${part}`);
191
+ return acc;
192
+ }, []);
193
+ }
194
+ /**
195
+ * Compares two fully qualified names (fqns) hierarchically based on their depth.
196
+ * From parent nodes to leaves
197
+ *
198
+ * @param {string} a - The first fqn to compare.
199
+ * @param {string} b - The second fqn to compare.
200
+ * @returns {number} - 0 if the fqns have the same depth.
201
+ * - Positive number if a is deeper than b.
202
+ * - Negative number if b is deeper than a.
203
+ */
204
+ function compareFqnHierarchically(a, b) {
205
+ const depthA = a.split(".").length;
206
+ const depthB = b.split(".").length;
207
+ switch (true) {
208
+ case depthA > depthB: return 1;
209
+ case depthA < depthB: return -1;
210
+ default: return 0;
211
+ }
212
+ }
213
+ function compareByFqnHierarchically(a, b) {
214
+ return compareFqnHierarchically(a.id, b.id);
215
+ }
216
+ /**
217
+ * Sorts an array of objects hierarchically based on their fully qualified names (FQN).
218
+ * Objects are sorted by the number of segments in their FQN (defined by dot-separated ID).
219
+ *
220
+ * @typeParam T - Object type that contains an 'id' string property
221
+ * @typeParam A - Type extending IterableContainer of T
222
+ *
223
+ * @param array - Array of objects to be sorted
224
+ * @returns A new array with items sorted by their FQN hierarchy depth (number of segments)
225
+ *
226
+ * @example
227
+ * ```ts
228
+ * const items = [
229
+ * { id: "a.b.c" },
230
+ * { id: "a" },
231
+ * { id: "a.b" }
232
+ * ];
233
+ * sortByFqnHierarchically(items);
234
+ * // Result: [
235
+ * // { id: "a" },
236
+ * // { id: "a.b" },
237
+ * // { id: "a.b.c" }
238
+ * // ]
239
+ * ```
240
+ */
241
+ function sortByFqnHierarchically(array) {
242
+ return array.map((item) => ({
243
+ item,
244
+ fqn: item.id.split(".")
245
+ })).sort((a, b) => {
246
+ return a.fqn.length - b.fqn.length;
247
+ }).map(({ item }) => item);
248
+ }
249
+ function findTopAncestor(items, item) {
250
+ let parent = item;
251
+ for (const e of items) if (isAncestor(e, parent)) parent = e;
252
+ return parent !== item ? parent : null;
253
+ }
254
+ /**
255
+ * Keeps initial order of the elements, but ensures that parents are before children
256
+ */
257
+ function sortParentsFirst(array) {
258
+ const result = [];
259
+ const items = [...array];
260
+ let item;
261
+ while (item = items.shift()) {
262
+ let parent;
263
+ while (parent = findTopAncestor(items, item)) result.push(items.splice(items.indexOf(parent), 1)[0]);
264
+ result.push(item);
265
+ }
266
+ return result;
267
+ }
268
+ function sortNaturalByFqn(array, sort) {
269
+ if (!array || isString(array)) {
270
+ const dir = array ?? "asc";
271
+ return (arr) => sortNaturalByFqn(arr, dir);
272
+ }
273
+ const dir = sort === "desc" ? -1 : 1;
274
+ return array.map((item) => ({
275
+ item,
276
+ fqn: item.id.split(".")
277
+ })).sort((a, b) => {
278
+ if (a.fqn.length !== b.fqn.length) return (a.fqn.length - b.fqn.length) * dir;
279
+ for (let i = 0; i < a.fqn.length; i++) {
280
+ const compare = compareNatural(a.fqn[i], b.fqn[i]);
281
+ if (compare !== 0) return compare;
282
+ }
283
+ return 0;
284
+ }).map(({ item }) => item);
285
+ }
286
+
287
+ //#endregion
288
+ //#region src/utils/getOrCreate.ts
289
+ function getOrCreate(map, key, create) {
290
+ let entry = map.get(key);
291
+ if (!entry) {
292
+ entry = create(key);
293
+ map.set(key, entry);
294
+ }
295
+ return entry;
296
+ }
297
+
298
+ //#endregion
299
+ //#region src/utils/memoize-prop.ts
300
+ /**
301
+ * Saves the value returned by fn() in a hidden property tag of obj object, so next time memoizeProp() is called,
302
+ * that value will be returned, and fn won't be called.
303
+ *
304
+ * @example
305
+ * ```ts
306
+ * class Model {
307
+ * // using same Symbol
308
+ * get computed1() {
309
+ * return memoizeProp(this, Symbol.for('computed1'), () => doOnce())
310
+ * }
311
+ * // using string
312
+ * get computed2() {
313
+ * return memoizeProp(this, 'computed2', () => doOnce())
314
+ * }
315
+ *
316
+ * }
317
+ * ```
318
+ */
319
+ function memoizeProp(obj, tag, fn) {
320
+ const tagSymbol = typeof tag === "symbol" ? tag : Symbol.for(tag);
321
+ if (!obj.hasOwnProperty(tagSymbol)) Object.defineProperty(obj, tagSymbol, {
322
+ enumerable: false,
323
+ writable: false,
324
+ value: fn()
325
+ });
326
+ return obj[tagSymbol];
327
+ }
328
+
329
+ //#endregion
330
+ //#region src/utils/promises.ts
331
+ const DELAY = "LIKEC4_DELAY";
332
+ function delay(...args) {
333
+ let ms = 100;
334
+ if (args.length === 2) ms = e$1(args[0], args[1]);
335
+ else if (args.length === 1) ms = args[0];
336
+ return new Promise((resolve) => {
337
+ setTimeout(() => {
338
+ resolve(DELAY);
339
+ }, ms ?? 100);
340
+ });
341
+ }
342
+ function promiseNextTick() {
343
+ return Promise.resolve().then(() => void 0);
344
+ }
345
+ function onNextTick(fn) {
346
+ Promise.resolve().then(fn);
347
+ }
348
+
349
+ //#endregion
350
+ //#region src/utils/relations.ts
351
+ /**
352
+ * Compares two relations hierarchically.
353
+ * From the most general (implicit) to the most specific (deepest in the tree)
354
+ */
355
+ const compareRelations = (a, b) => {
356
+ const parentA = commonAncestor(a.source.id, a.target.id);
357
+ const parentB = commonAncestor(b.source.id, b.target.id);
358
+ if (parentA && !parentB) return 1;
359
+ if (!parentA && parentB) return -1;
360
+ const compareParents = parentA && parentB ? compareFqnHierarchically(parentA, parentB) : 0;
361
+ if (compareParents !== 0) return compareParents;
362
+ const compareSource = compareFqnHierarchically(a.source.id, b.source.id);
363
+ if (compareSource !== 0) return compareSource;
364
+ return compareFqnHierarchically(a.target.id, b.target.id);
365
+ };
366
+
367
+ //#endregion
368
+ //#region src/utils/set.ts
369
+ /**
370
+ * Returns new set as a union of given sets
371
+ * Keeps order of elements
372
+ */
373
+ function union(...sets) {
374
+ let result = /* @__PURE__ */ new Set();
375
+ for (const set of sets) for (const value of set) result.add(value);
376
+ return result;
377
+ }
378
+ /**
379
+ * Returns new set as an intersection of all sets
380
+ * Keeps order from the first set
381
+ */
382
+ function intersection(first, ...sets) {
383
+ let result = /* @__PURE__ */ new Set();
384
+ if (first.size === 0) return result;
385
+ let other = t$4(sets, 2) ? (0, import_set.intersection)(...sets) : sets[0];
386
+ if (other.size === 0) return result;
387
+ for (const value of first) if (other.has(value)) result.add(value);
388
+ return result;
389
+ }
390
+ /**
391
+ * Returns new set as a difference of two sets (A-B)
392
+ * Keeps order from the first set
393
+ */
394
+ function difference(a, b) {
395
+ if (a.size === 0) return /* @__PURE__ */ new Set();
396
+ if (b.size === 0) return new Set(a);
397
+ let result = /* @__PURE__ */ new Set();
398
+ for (const value of a) if (!b.has(value)) result.add(value);
399
+ return result;
400
+ }
401
+ function equals(a, b) {
402
+ return a.size === b.size && [...a].every((value) => b.has(value));
403
+ }
404
+ function symmetricDifference(a, b) {
405
+ return (0, import_set.symmetricDifference)(a, b);
406
+ }
407
+ function hasIntersection(a, b) {
408
+ if (a.size === 0 || b.size === 0) return false;
409
+ if (b.size < a.size) [a, b] = [b, a];
410
+ for (const value of a) if (b.has(value)) return true;
411
+ return false;
412
+ }
413
+
414
+ //#endregion
415
+ //#region src/utils/object-hash.ts
416
+ function objectHash(value) {
417
+ invariant(typeof value === "object" && e$2(value), "objectHash: value must be an object");
418
+ return hash(value);
419
+ }
420
+
421
+ //#endregion
422
+ //#region src/utils/string-hash.ts
423
+ /**
424
+ * @see https://gist.github.com/victor-homyakov/bcb7d7911e4a388b1c810f8c3ce17bcf
425
+ */
426
+ function stringHash(str) {
427
+ let hash = 5381;
428
+ const len = str.length;
429
+ invariant(len > 0, "stringHash: empty string");
430
+ for (let i = 0; i < len; i++) hash = hash * 33 ^ str.charCodeAt(i);
431
+ return (hash >>> 0).toString(36);
432
+ }
433
+
434
+ //#endregion
435
+ //#region src/utils/markdown/to-html.ts
436
+ function parser() {
437
+ return unified().use(remarkParse).use(remarkGfm).use(remarkAlert).use(remarkRehype, { allowDangerousHtml: true }).use(rehypeSanitize, defu({
438
+ attributes: {
439
+ "*": ["className"],
440
+ "svg": [
441
+ "width",
442
+ "height",
443
+ "viewBox",
444
+ "fill",
445
+ "ariaHidden"
446
+ ],
447
+ "path": [
448
+ "d",
449
+ "fill",
450
+ "stroke",
451
+ "strokeWidth",
452
+ "strokeLinecap",
453
+ "strokeLinejoin"
454
+ ]
455
+ },
456
+ tagNames: [
457
+ "svg",
458
+ "g",
459
+ "path",
460
+ "div"
461
+ ]
462
+ }, defaultSchema)).use(rehypeStringify, { allowDangerousHtml: true });
463
+ }
464
+ function markdownToHtml(markdown) {
465
+ return ("" + parser().processSync(markdown)).trim();
466
+ }
467
+
468
+ //#endregion
469
+ //#region src/utils/markdown/to-text.ts
470
+ /**
471
+ * Converts markdown to plain text, removing any markdown formatting.
472
+ * @param markdown - The markdown to convert.
473
+ * @returns The plain text.
474
+ */
475
+ function markdownToText(markdown) {
476
+ return toString(fromMarkdown(markdown), {
477
+ includeHtml: false,
478
+ includeImageAlt: false
479
+ });
480
+ }
481
+
482
+ //#endregion
483
+ export { sortParentsFirst as A, isAncestor as C, parentFqn as D, nameFromFqn as E, commonHead as F, compareNatural as I, compareNaturalHierarchically as L, isAnyOf as M, isNonEmptyArray as N, sortByFqnHierarchically as O, isString as P, hierarchyLevel as S, isSameHierarchy as T, ancestorsFqn as _, difference as a, compareFqnHierarchically as b, intersection as c, compareRelations as d, delay as f, getOrCreate as g, memoizeProp as h, objectHash as i, hasProp as j, sortNaturalByFqn as k, symmetricDifference as l, promiseNextTick as m, markdownToHtml as n, equals as o, onNextTick as p, stringHash as r, hasIntersection as s, markdownToText as t, union as u, commonAncestor as v, isDescendantOf as w, hierarchyDistance as x, compareByFqnHierarchically as y };