@clusterenvision/ui-framework 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +295 -0
  3. package/dist/ai-assistant-Db002XYC.d.ts +92 -0
  4. package/dist/ai-assistant-EobSUV70.d.cts +92 -0
  5. package/dist/browser-DnHpnWwE.d.cts +354 -0
  6. package/dist/browser-Dx4oKf5e.d.ts +354 -0
  7. package/dist/browser-signals-07qodpYT.d.cts +66 -0
  8. package/dist/browser-signals-07qodpYT.d.ts +66 -0
  9. package/dist/browser-signals.cjs +32 -0
  10. package/dist/browser-signals.cjs.map +1 -0
  11. package/dist/browser-signals.d.cts +1 -0
  12. package/dist/browser-signals.d.ts +1 -0
  13. package/dist/browser-signals.js +3 -0
  14. package/dist/browser-signals.js.map +1 -0
  15. package/dist/browser.cjs +197 -0
  16. package/dist/browser.cjs.map +1 -0
  17. package/dist/browser.d.cts +13 -0
  18. package/dist/browser.d.ts +13 -0
  19. package/dist/browser.js +12 -0
  20. package/dist/browser.js.map +1 -0
  21. package/dist/chunk-22HQL2Y4.js +568 -0
  22. package/dist/chunk-22HQL2Y4.js.map +1 -0
  23. package/dist/chunk-3ZBRNFEE.js +1525 -0
  24. package/dist/chunk-3ZBRNFEE.js.map +1 -0
  25. package/dist/chunk-4HRORR2Q.js +1953 -0
  26. package/dist/chunk-4HRORR2Q.js.map +1 -0
  27. package/dist/chunk-4L3UXVL5.cjs +68 -0
  28. package/dist/chunk-4L3UXVL5.cjs.map +1 -0
  29. package/dist/chunk-6BYWFGQY.cjs +226 -0
  30. package/dist/chunk-6BYWFGQY.cjs.map +1 -0
  31. package/dist/chunk-7SCIB5HP.js +57 -0
  32. package/dist/chunk-7SCIB5HP.js.map +1 -0
  33. package/dist/chunk-BBAUALNU.js +888 -0
  34. package/dist/chunk-BBAUALNU.js.map +1 -0
  35. package/dist/chunk-CHLDE4JQ.js +715 -0
  36. package/dist/chunk-CHLDE4JQ.js.map +1 -0
  37. package/dist/chunk-CXTAUXLG.cjs +71 -0
  38. package/dist/chunk-CXTAUXLG.cjs.map +1 -0
  39. package/dist/chunk-D2USIT6V.js +121 -0
  40. package/dist/chunk-D2USIT6V.js.map +1 -0
  41. package/dist/chunk-D3H5CGVD.js +36 -0
  42. package/dist/chunk-D3H5CGVD.js.map +1 -0
  43. package/dist/chunk-DQBX75NJ.js +92 -0
  44. package/dist/chunk-DQBX75NJ.js.map +1 -0
  45. package/dist/chunk-DRPG2DFX.js +208 -0
  46. package/dist/chunk-DRPG2DFX.js.map +1 -0
  47. package/dist/chunk-EFOOXCY7.cjs +41 -0
  48. package/dist/chunk-EFOOXCY7.cjs.map +1 -0
  49. package/dist/chunk-FFCZSYC7.cjs +906 -0
  50. package/dist/chunk-FFCZSYC7.cjs.map +1 -0
  51. package/dist/chunk-FNXIYAET.cjs +1593 -0
  52. package/dist/chunk-FNXIYAET.cjs.map +1 -0
  53. package/dist/chunk-I6GNUM3P.cjs +63 -0
  54. package/dist/chunk-I6GNUM3P.cjs.map +1 -0
  55. package/dist/chunk-IHAMVLRY.js +129 -0
  56. package/dist/chunk-IHAMVLRY.js.map +1 -0
  57. package/dist/chunk-IRBUKIRF.cjs +133 -0
  58. package/dist/chunk-IRBUKIRF.cjs.map +1 -0
  59. package/dist/chunk-KPG5HAHK.cjs +97 -0
  60. package/dist/chunk-KPG5HAHK.cjs.map +1 -0
  61. package/dist/chunk-N7Q2ESLG.cjs +130 -0
  62. package/dist/chunk-N7Q2ESLG.cjs.map +1 -0
  63. package/dist/chunk-PFBEIFVS.js +180 -0
  64. package/dist/chunk-PFBEIFVS.js.map +1 -0
  65. package/dist/chunk-PVZVFICK.cjs +318 -0
  66. package/dist/chunk-PVZVFICK.cjs.map +1 -0
  67. package/dist/chunk-Q3KH6HMU.js +305 -0
  68. package/dist/chunk-Q3KH6HMU.js.map +1 -0
  69. package/dist/chunk-QPAAV32J.cjs +1985 -0
  70. package/dist/chunk-QPAAV32J.cjs.map +1 -0
  71. package/dist/chunk-R6XQUMWT.cjs +61 -0
  72. package/dist/chunk-R6XQUMWT.cjs.map +1 -0
  73. package/dist/chunk-SA5UD5B6.js +92 -0
  74. package/dist/chunk-SA5UD5B6.js.map +1 -0
  75. package/dist/chunk-SM35JOYD.cjs +211 -0
  76. package/dist/chunk-SM35JOYD.cjs.map +1 -0
  77. package/dist/chunk-SZQNIMYI.cjs +592 -0
  78. package/dist/chunk-SZQNIMYI.cjs.map +1 -0
  79. package/dist/chunk-T6T7QE4J.js +224 -0
  80. package/dist/chunk-T6T7QE4J.js.map +1 -0
  81. package/dist/chunk-TIF372DZ.js +65 -0
  82. package/dist/chunk-TIF372DZ.js.map +1 -0
  83. package/dist/chunk-V6JCOBGY.js +69 -0
  84. package/dist/chunk-V6JCOBGY.js.map +1 -0
  85. package/dist/chunk-VHUXNDW2.cjs +189 -0
  86. package/dist/chunk-VHUXNDW2.cjs.map +1 -0
  87. package/dist/chunk-W3LNNY3U.cjs +729 -0
  88. package/dist/chunk-W3LNNY3U.cjs.map +1 -0
  89. package/dist/chunk-ZUWSU4OA.js +61 -0
  90. package/dist/chunk-ZUWSU4OA.js.map +1 -0
  91. package/dist/chunk-ZWUA2LPB.cjs +103 -0
  92. package/dist/chunk-ZWUA2LPB.cjs.map +1 -0
  93. package/dist/cli/index.cjs +566 -0
  94. package/dist/cli/index.cjs.map +1 -0
  95. package/dist/cli/index.d.cts +1 -0
  96. package/dist/cli/index.d.ts +1 -0
  97. package/dist/cli/index.js +558 -0
  98. package/dist/cli/index.js.map +1 -0
  99. package/dist/compiler/index.cjs +80 -0
  100. package/dist/compiler/index.cjs.map +1 -0
  101. package/dist/compiler/index.d.cts +130 -0
  102. package/dist/compiler/index.d.ts +130 -0
  103. package/dist/compiler/index.js +3 -0
  104. package/dist/compiler/index.js.map +1 -0
  105. package/dist/component-BVzvepw9.d.cts +90 -0
  106. package/dist/component-wTxZ2BPD.d.ts +90 -0
  107. package/dist/index-CpxDa60m.d.cts +644 -0
  108. package/dist/index-CpxDa60m.d.ts +644 -0
  109. package/dist/index.cjs +1356 -0
  110. package/dist/index.cjs.map +1 -0
  111. package/dist/index.d.cts +165 -0
  112. package/dist/index.d.ts +165 -0
  113. package/dist/index.js +772 -0
  114. package/dist/index.js.map +1 -0
  115. package/dist/lib/dom.cjs +102 -0
  116. package/dist/lib/dom.cjs.map +1 -0
  117. package/dist/lib/dom.d.cts +373 -0
  118. package/dist/lib/dom.d.ts +373 -0
  119. package/dist/lib/dom.js +3 -0
  120. package/dist/lib/dom.js.map +1 -0
  121. package/dist/lib/icons.cjs +20 -0
  122. package/dist/lib/icons.cjs.map +1 -0
  123. package/dist/lib/icons.d.cts +64 -0
  124. package/dist/lib/icons.d.ts +64 -0
  125. package/dist/lib/icons.js +3 -0
  126. package/dist/lib/icons.js.map +1 -0
  127. package/dist/lib/index.cjs +247 -0
  128. package/dist/lib/index.cjs.map +1 -0
  129. package/dist/lib/index.d.cts +30 -0
  130. package/dist/lib/index.d.ts +30 -0
  131. package/dist/lib/index.js +92 -0
  132. package/dist/lib/index.js.map +1 -0
  133. package/dist/lib/theme.cjs +56 -0
  134. package/dist/lib/theme.cjs.map +1 -0
  135. package/dist/lib/theme.d.cts +27 -0
  136. package/dist/lib/theme.d.ts +27 -0
  137. package/dist/lib/theme.js +3 -0
  138. package/dist/lib/theme.js.map +1 -0
  139. package/dist/router-B9kms5XQ.d.ts +124 -0
  140. package/dist/router-YnpW_sIK.d.cts +124 -0
  141. package/dist/runtime/adapters/angular.cjs +48 -0
  142. package/dist/runtime/adapters/angular.cjs.map +1 -0
  143. package/dist/runtime/adapters/angular.d.cts +38 -0
  144. package/dist/runtime/adapters/angular.d.ts +38 -0
  145. package/dist/runtime/adapters/angular.js +46 -0
  146. package/dist/runtime/adapters/angular.js.map +1 -0
  147. package/dist/runtime/adapters/react.cjs +41 -0
  148. package/dist/runtime/adapters/react.cjs.map +1 -0
  149. package/dist/runtime/adapters/react.d.cts +26 -0
  150. package/dist/runtime/adapters/react.d.ts +26 -0
  151. package/dist/runtime/adapters/react.js +39 -0
  152. package/dist/runtime/adapters/react.js.map +1 -0
  153. package/dist/runtime/adapters/vue.cjs +44 -0
  154. package/dist/runtime/adapters/vue.cjs.map +1 -0
  155. package/dist/runtime/adapters/vue.d.cts +37 -0
  156. package/dist/runtime/adapters/vue.d.ts +37 -0
  157. package/dist/runtime/adapters/vue.js +42 -0
  158. package/dist/runtime/adapters/vue.js.map +1 -0
  159. package/dist/runtime/components/ai-assistant.cjs +18 -0
  160. package/dist/runtime/components/ai-assistant.cjs.map +1 -0
  161. package/dist/runtime/components/ai-assistant.d.cts +8 -0
  162. package/dist/runtime/components/ai-assistant.d.ts +8 -0
  163. package/dist/runtime/components/ai-assistant.js +9 -0
  164. package/dist/runtime/components/ai-assistant.js.map +1 -0
  165. package/dist/runtime/components/ai-summary-card.cjs +18 -0
  166. package/dist/runtime/components/ai-summary-card.cjs.map +1 -0
  167. package/dist/runtime/components/ai-summary-card.d.cts +19 -0
  168. package/dist/runtime/components/ai-summary-card.d.ts +19 -0
  169. package/dist/runtime/components/ai-summary-card.js +9 -0
  170. package/dist/runtime/components/ai-summary-card.js.map +1 -0
  171. package/dist/runtime/router.cjs +429 -0
  172. package/dist/runtime/router.cjs.map +1 -0
  173. package/dist/runtime/router.d.cts +2 -0
  174. package/dist/runtime/router.d.ts +2 -0
  175. package/dist/runtime/router.js +421 -0
  176. package/dist/runtime/router.js.map +1 -0
  177. package/dist/runtime/server.cjs +125 -0
  178. package/dist/runtime/server.cjs.map +1 -0
  179. package/dist/runtime/server.d.cts +27 -0
  180. package/dist/runtime/server.d.ts +27 -0
  181. package/dist/runtime/server.js +117 -0
  182. package/dist/runtime/server.js.map +1 -0
  183. package/dist/runtime/workflow/index.cjs +282 -0
  184. package/dist/runtime/workflow/index.cjs.map +1 -0
  185. package/dist/runtime/workflow/index.d.cts +1 -0
  186. package/dist/runtime/workflow/index.d.ts +1 -0
  187. package/dist/runtime/workflow/index.js +5 -0
  188. package/dist/runtime/workflow/index.js.map +1 -0
  189. package/dist/tracing-DGdvMCEl.d.cts +109 -0
  190. package/dist/tracing-DGdvMCEl.d.ts +109 -0
  191. package/dist/types-C4RXXKfk.d.cts +76 -0
  192. package/dist/types-C4RXXKfk.d.ts +76 -0
  193. package/package.json +166 -0
@@ -0,0 +1,888 @@
1
+ // src/compiler/html-parser.js
2
+ var NodeType;
3
+ (function(NodeType2) {
4
+ NodeType2[NodeType2["ELEMENT_NODE"] = 1] = "ELEMENT_NODE";
5
+ NodeType2[NodeType2["TEXT_NODE"] = 3] = "TEXT_NODE";
6
+ NodeType2[NodeType2["COMMENT_NODE"] = 8] = "COMMENT_NODE";
7
+ NodeType2[NodeType2["DOCUMENT_FRAGMENT_NODE"] = 11] = "DOCUMENT_FRAGMENT_NODE";
8
+ })(NodeType || (NodeType = {}));
9
+ var defaultVoidElementNames = [
10
+ "area",
11
+ "base",
12
+ "br",
13
+ "col",
14
+ "embed",
15
+ "hr",
16
+ "img",
17
+ "input",
18
+ "link",
19
+ "meta",
20
+ "param",
21
+ "source",
22
+ "track",
23
+ "wbr"
24
+ ];
25
+ var defaultRawTextElementNames = ["script", "style", "textarea"];
26
+ var namedEntities = {
27
+ amp: "&",
28
+ lt: "<",
29
+ gt: ">",
30
+ quot: '"',
31
+ apos: "'",
32
+ nbsp: "\xA0"
33
+ };
34
+ var TreeNode = class {
35
+ parentNode = null;
36
+ previousSibling = null;
37
+ nextSibling = null;
38
+ };
39
+ var ParentNodeImpl = class extends TreeNode {
40
+ childNodes = [];
41
+ get firstChild() {
42
+ return this.childNodes[0];
43
+ }
44
+ get lastChild() {
45
+ return this.childNodes[this.childNodes.length - 1];
46
+ }
47
+ appendChild(child) {
48
+ if (child === this) {
49
+ return child;
50
+ }
51
+ detach(child);
52
+ const last = this.lastChild ?? null;
53
+ if (last) {
54
+ last.nextSibling = child;
55
+ }
56
+ child.previousSibling = last;
57
+ child.nextSibling = null;
58
+ child.parentNode = this;
59
+ this.childNodes.push(child);
60
+ return child;
61
+ }
62
+ insertBefore(child, reference) {
63
+ if (child === this) {
64
+ return child;
65
+ }
66
+ if (reference === null) {
67
+ return this.appendChild(child);
68
+ }
69
+ const index = this.childNodes.indexOf(reference);
70
+ if (index === -1) {
71
+ throw new Error("Reference node not found in parent.");
72
+ }
73
+ detach(child);
74
+ const prev = reference.previousSibling;
75
+ if (prev) {
76
+ prev.nextSibling = child;
77
+ }
78
+ child.previousSibling = prev;
79
+ child.nextSibling = reference;
80
+ reference.previousSibling = child;
81
+ child.parentNode = this;
82
+ this.childNodes.splice(index, 0, child);
83
+ return child;
84
+ }
85
+ removeChild(child) {
86
+ const index = this.childNodes.indexOf(child);
87
+ if (index === -1) {
88
+ return child;
89
+ }
90
+ const prev = child.previousSibling;
91
+ const next = child.nextSibling;
92
+ if (prev) {
93
+ prev.nextSibling = next;
94
+ }
95
+ if (next) {
96
+ next.previousSibling = prev;
97
+ }
98
+ child.parentNode = null;
99
+ child.previousSibling = null;
100
+ child.nextSibling = null;
101
+ this.childNodes.splice(index, 1);
102
+ return child;
103
+ }
104
+ replaceChild(newChild, oldChild) {
105
+ this.insertBefore(newChild, oldChild);
106
+ this.removeChild(oldChild);
107
+ return newChild;
108
+ }
109
+ clearChildren() {
110
+ for (const child of this.childNodes) {
111
+ child.parentNode = null;
112
+ child.previousSibling = null;
113
+ child.nextSibling = null;
114
+ }
115
+ this.childNodes.length = 0;
116
+ }
117
+ get textContent() {
118
+ return this.childNodes.map((child) => child.textContent).join("");
119
+ }
120
+ set textContent(value) {
121
+ this.clearChildren();
122
+ if (value) {
123
+ this.appendChild(new TextNode(value));
124
+ }
125
+ }
126
+ };
127
+ var TextNode = class _TextNode extends TreeNode {
128
+ text;
129
+ nodeType = NodeType.TEXT_NODE;
130
+ constructor(text) {
131
+ super();
132
+ this.text = text;
133
+ }
134
+ get textContent() {
135
+ return this.text;
136
+ }
137
+ set textContent(value) {
138
+ this.text = value;
139
+ }
140
+ clone() {
141
+ return new _TextNode(this.text);
142
+ }
143
+ toString() {
144
+ return escapeText(this.text);
145
+ }
146
+ };
147
+ var CommentNode = class _CommentNode extends TreeNode {
148
+ data;
149
+ nodeType = NodeType.COMMENT_NODE;
150
+ constructor(data) {
151
+ super();
152
+ this.data = data;
153
+ }
154
+ get textContent() {
155
+ return this.data;
156
+ }
157
+ set textContent(value) {
158
+ this.data = value;
159
+ }
160
+ clone() {
161
+ return new _CommentNode(this.data);
162
+ }
163
+ toString() {
164
+ return `<!--${this.data}-->`;
165
+ }
166
+ };
167
+ var HTMLElement = class _HTMLElement extends ParentNodeImpl {
168
+ tagName;
169
+ nodeType = NodeType.ELEMENT_NODE;
170
+ attrs = {};
171
+ normalizedTagName;
172
+ isVoidElement;
173
+ lowerCaseAttributeName;
174
+ constructor(tagName, attrs = {}, options = {}) {
175
+ super();
176
+ this.tagName = tagName;
177
+ const shouldLowercase = options.lowerCaseTagName ?? true;
178
+ this.tagName = shouldLowercase ? tagName.toLowerCase() : tagName;
179
+ this.normalizedTagName = (options.normalizedTagName ?? this.tagName).toLowerCase();
180
+ this.lowerCaseAttributeName = options.lowerCaseAttributeName ?? true;
181
+ this.isVoidElement = options.isVoidElement ?? false;
182
+ for (const [key, value] of Object.entries(attrs)) {
183
+ const normalized = this.normalizeAttrName(key);
184
+ this.attrs[normalized] = options.decodeEntities ? decodeHtmlEntities(value) : value;
185
+ }
186
+ }
187
+ getAttribute(name) {
188
+ return this.attrs[this.normalizeAttrName(name)];
189
+ }
190
+ getAttributeNames() {
191
+ return Object.keys(this.attrs);
192
+ }
193
+ hasAttribute(name) {
194
+ return Object.prototype.hasOwnProperty.call(this.attrs, this.normalizeAttrName(name));
195
+ }
196
+ setAttribute(name, value) {
197
+ this.attrs[this.normalizeAttrName(name)] = value;
198
+ }
199
+ removeAttribute(name) {
200
+ Reflect.deleteProperty(this.attrs, this.normalizeAttrName(name));
201
+ }
202
+ toggleAttribute(name, force) {
203
+ const attr = this.normalizeAttrName(name);
204
+ const exists = Object.prototype.hasOwnProperty.call(this.attrs, attr);
205
+ if (force === true || !exists && force === void 0) {
206
+ this.attrs[attr] = "";
207
+ return true;
208
+ }
209
+ if (force === false || exists) {
210
+ Reflect.deleteProperty(this.attrs, attr);
211
+ return false;
212
+ }
213
+ return false;
214
+ }
215
+ clone(deep = true) {
216
+ const clone = new _HTMLElement(this.tagName, { ...this.attrs }, {
217
+ lowerCaseTagName: false,
218
+ lowerCaseAttributeName: false,
219
+ isVoidElement: this.isVoidElement,
220
+ normalizedTagName: this.normalizedTagName
221
+ });
222
+ if (deep) {
223
+ for (const child of this.childNodes) {
224
+ clone.appendChild(child.clone(true));
225
+ }
226
+ }
227
+ return clone;
228
+ }
229
+ toString() {
230
+ const attrString = Object.entries(this.attrs).map(([key, value]) => value === "" ? key : `${key}="${escapeAttribute(value)}"`).join(" ");
231
+ const openTag = attrString ? `<${this.tagName} ${attrString}>` : `<${this.tagName}>`;
232
+ if (this.isVoidElement) {
233
+ return openTag;
234
+ }
235
+ if (!this.childNodes.length) {
236
+ return `${openTag}</${this.tagName}>`;
237
+ }
238
+ const children = this.childNodes.map((child) => child.toString()).join("");
239
+ return `${openTag}${children}</${this.tagName}>`;
240
+ }
241
+ normalizeAttrName(name) {
242
+ return this.lowerCaseAttributeName ? name.toLowerCase() : name;
243
+ }
244
+ };
245
+ var DocumentFragment = class _DocumentFragment extends ParentNodeImpl {
246
+ nodeType = NodeType.DOCUMENT_FRAGMENT_NODE;
247
+ clone(deep = true) {
248
+ const fragment = new _DocumentFragment();
249
+ if (deep) {
250
+ for (const child of this.childNodes) {
251
+ fragment.appendChild(child.clone(true));
252
+ }
253
+ }
254
+ return fragment;
255
+ }
256
+ toString() {
257
+ return this.childNodes.map((child) => child.toString()).join("");
258
+ }
259
+ };
260
+ function parse(html, options = {}) {
261
+ const runtime = normalizeParseOptions(options);
262
+ const root = new DocumentFragment();
263
+ const stack = [root];
264
+ let index = 0;
265
+ while (index < html.length) {
266
+ const nextLt = html.indexOf("<", index);
267
+ if (nextLt === -1) {
268
+ appendText(html.slice(index));
269
+ break;
270
+ }
271
+ if (nextLt > index) {
272
+ appendText(html.slice(index, nextLt));
273
+ }
274
+ if (html.startsWith("<!--", nextLt)) {
275
+ const endComment = html.indexOf("-->", nextLt + 4);
276
+ if (endComment === -1) {
277
+ if (runtime.preserveComments) {
278
+ appendComment(html.slice(nextLt + 4));
279
+ }
280
+ break;
281
+ }
282
+ if (runtime.preserveComments) {
283
+ appendComment(html.slice(nextLt + 4, endComment));
284
+ }
285
+ index = endComment + 3;
286
+ continue;
287
+ }
288
+ if (html.startsWith("<![CDATA[", nextLt)) {
289
+ const endCdata = html.indexOf("]]>", nextLt + 9);
290
+ const content2 = endCdata === -1 ? html.slice(nextLt + 9) : html.slice(nextLt + 9, endCdata);
291
+ appendText(content2, false);
292
+ if (endCdata === -1) {
293
+ break;
294
+ }
295
+ index = endCdata + 3;
296
+ continue;
297
+ }
298
+ const { content, endIndex } = readTag(html, nextLt + 1);
299
+ if (!content) {
300
+ index = endIndex + 1;
301
+ continue;
302
+ }
303
+ if (content.startsWith("/")) {
304
+ const closingName = extractClosingName(content);
305
+ if (closingName) {
306
+ const normalizedClosing = closingName.toLowerCase();
307
+ while (stack.length > 1) {
308
+ const node = stack.pop();
309
+ if (node instanceof HTMLElement && node.normalizedTagName === normalizedClosing) {
310
+ break;
311
+ }
312
+ }
313
+ }
314
+ index = endIndex + 1;
315
+ continue;
316
+ }
317
+ if (content.startsWith("!") || content.startsWith("?")) {
318
+ index = endIndex + 1;
319
+ continue;
320
+ }
321
+ const tag = parseTag(content, runtime);
322
+ const element = new HTMLElement(tag.tagName, tag.attrs, {
323
+ lowerCaseTagName: false,
324
+ lowerCaseAttributeName: runtime.lowerCaseAttributeName,
325
+ decodeEntities: false,
326
+ isVoidElement: runtime.voidElements.has(tag.normalizedTagName),
327
+ normalizedTagName: tag.normalizedTagName
328
+ });
329
+ stack[stack.length - 1].appendChild(element);
330
+ if (runtime.rawTextElements.has(tag.normalizedTagName)) {
331
+ const rawStart = endIndex + 1;
332
+ const closing = findRawTextClosure(html, rawStart, tag.normalizedTagName);
333
+ const inner = closing ? html.slice(rawStart, closing.start) : html.slice(rawStart);
334
+ appendText(inner, false, element);
335
+ index = closing ? closing.end + 1 : html.length;
336
+ continue;
337
+ }
338
+ if (!tag.selfClosing && !runtime.voidElements.has(tag.normalizedTagName)) {
339
+ stack.push(element);
340
+ }
341
+ index = endIndex + 1;
342
+ }
343
+ return root;
344
+ function appendText(text, decode = true, target) {
345
+ if (!text) {
346
+ return;
347
+ }
348
+ const nodeText = decode && runtime.decodeEntities ? decodeHtmlEntities(text) : text;
349
+ (target ?? stack[stack.length - 1]).appendChild(new TextNode(nodeText));
350
+ }
351
+ function appendComment(value) {
352
+ stack[stack.length - 1].appendChild(new CommentNode(value));
353
+ }
354
+ }
355
+ function createElement(tagName, attrs = {}, options = {}) {
356
+ const normalizedTag = options.lowerCaseTagName ?? true ? tagName.toLowerCase() : tagName;
357
+ const isVoid = options.isVoidElement ?? defaultVoidSet.has(normalizedTag.toLowerCase());
358
+ return new HTMLElement(tagName, attrs, { ...options, isVoidElement: isVoid, normalizedTagName: normalizedTag.toLowerCase() });
359
+ }
360
+ function createTextNode(text) {
361
+ return new TextNode(text);
362
+ }
363
+ function createCommentNode(content) {
364
+ return new CommentNode(content);
365
+ }
366
+ function createFragment(children = [], options = {}) {
367
+ const fragment = new DocumentFragment();
368
+ for (const child of children) {
369
+ fragment.appendChild(options.clone ? child.clone(true) : child);
370
+ }
371
+ return fragment;
372
+ }
373
+ function cloneNode(node, deep = true) {
374
+ return node.clone(deep);
375
+ }
376
+ function serialize(target, options = {}) {
377
+ const nodes = Array.isArray(target) ? target : [target];
378
+ if (!options.pretty) {
379
+ return nodes.map((node) => node.toString()).join("");
380
+ }
381
+ const indent = options.indent ?? " ";
382
+ const newline = options.newline ?? "\n";
383
+ return nodes.map((node) => serializePretty(node, indent, newline, 0)).filter(Boolean).join(newline);
384
+ }
385
+ function walk(target, visitor) {
386
+ const nodes = Array.isArray(target) ? target : [target];
387
+ traverse(nodes, visitor, null, 0);
388
+ }
389
+ function isElementNode(node) {
390
+ return node instanceof HTMLElement;
391
+ }
392
+ function isTextNode(node) {
393
+ return node instanceof TextNode;
394
+ }
395
+ function isCommentNode(node) {
396
+ return node instanceof CommentNode;
397
+ }
398
+ function isParentNode(node) {
399
+ return node instanceof HTMLElement || node instanceof DocumentFragment;
400
+ }
401
+ var defaultVoidSet = new Set(defaultVoidElementNames);
402
+ function normalizeParseOptions(options) {
403
+ const lowerCaseTagName = options.lowerCaseTagName ?? true;
404
+ const lowerCaseAttributeName = options.lowerCaseAttributeName ?? true;
405
+ const decodeEntities = options.decodeEntities ?? false;
406
+ const preserveComments = options.preserveComments ?? options.comment ?? false;
407
+ const voidElements = createNameSet(options.voidElements ?? defaultVoidElementNames);
408
+ const rawTextElements = createNameSet(options.rawTextElements ?? defaultRawTextElementNames);
409
+ return {
410
+ lowerCaseTagName,
411
+ lowerCaseAttributeName,
412
+ decodeEntities,
413
+ preserveComments,
414
+ voidElements,
415
+ rawTextElements
416
+ };
417
+ }
418
+ function parseTag(content, options) {
419
+ let body = content;
420
+ let selfClosing = false;
421
+ if (body.endsWith("/")) {
422
+ body = body.slice(0, -1);
423
+ selfClosing = true;
424
+ }
425
+ const firstSpace = body.search(/\s/);
426
+ const rawName = firstSpace === -1 ? body : body.slice(0, firstSpace);
427
+ const attrsSource = firstSpace === -1 ? "" : body.slice(firstSpace).trim();
428
+ const normalizedTagName = rawName.toLowerCase();
429
+ const tagName = options.lowerCaseTagName ? normalizedTagName : rawName;
430
+ const attrs = parseAttributes(attrsSource, options);
431
+ return { tagName, normalizedTagName, attrs, selfClosing };
432
+ }
433
+ function parseAttributes(source, options) {
434
+ const attrs = {};
435
+ let i = 0;
436
+ while (i < source.length) {
437
+ while (i < source.length && isWhitespace(source[i])) {
438
+ i += 1;
439
+ }
440
+ if (i >= source.length) {
441
+ break;
442
+ }
443
+ const nameStart = i;
444
+ while (i < source.length && !isWhitespace(source[i]) && source[i] !== "=") {
445
+ i += 1;
446
+ }
447
+ let name = source.slice(nameStart, i);
448
+ while (i < source.length && isWhitespace(source[i])) {
449
+ i += 1;
450
+ }
451
+ let value = "";
452
+ if (source[i] === "=") {
453
+ i += 1;
454
+ while (i < source.length && isWhitespace(source[i])) {
455
+ i += 1;
456
+ }
457
+ if (source[i] === '"' || source[i] === "'") {
458
+ const quote = source[i];
459
+ i += 1;
460
+ const valueStart = i;
461
+ while (i < source.length && source[i] !== quote) {
462
+ i += 1;
463
+ }
464
+ value = source.slice(valueStart, i);
465
+ i += 1;
466
+ } else {
467
+ const valueStart = i;
468
+ while (i < source.length && !isWhitespace(source[i])) {
469
+ i += 1;
470
+ }
471
+ value = source.slice(valueStart, i);
472
+ }
473
+ }
474
+ if (name) {
475
+ if (options.lowerCaseAttributeName) {
476
+ name = name.toLowerCase();
477
+ }
478
+ attrs[name] = options.decodeEntities ? decodeHtmlEntities(value) : value;
479
+ }
480
+ }
481
+ return attrs;
482
+ }
483
+ function readTag(html, start) {
484
+ let i = start;
485
+ let inQuote = null;
486
+ while (i < html.length) {
487
+ const char = html[i];
488
+ if (char === '"' || char === "'") {
489
+ if (inQuote === char) {
490
+ inQuote = null;
491
+ } else if (!inQuote) {
492
+ inQuote = char;
493
+ }
494
+ } else if (char === ">" && !inQuote) {
495
+ break;
496
+ }
497
+ i += 1;
498
+ }
499
+ return {
500
+ content: html.slice(start, i).trim(),
501
+ endIndex: i
502
+ };
503
+ }
504
+ function extractClosingName(content) {
505
+ const body = content.slice(1).trim();
506
+ if (!body) {
507
+ return null;
508
+ }
509
+ const firstSpace = body.search(/\s/);
510
+ return firstSpace === -1 ? body : body.slice(0, firstSpace);
511
+ }
512
+ function findRawTextClosure(html, start, normalizedTagName) {
513
+ let index = start;
514
+ while (index < html.length) {
515
+ const lt = html.indexOf("</", index);
516
+ if (lt === -1) {
517
+ return null;
518
+ }
519
+ const { content, endIndex } = readTag(html, lt + 1);
520
+ if (content.startsWith("/")) {
521
+ const closingName = extractClosingName(content);
522
+ if (closingName && closingName.toLowerCase() === normalizedTagName) {
523
+ return { start: lt, end: endIndex };
524
+ }
525
+ }
526
+ index = endIndex + 1;
527
+ }
528
+ return null;
529
+ }
530
+ function createNameSet(input) {
531
+ const set = /* @__PURE__ */ new Set();
532
+ for (const value of input) {
533
+ set.add(value.toLowerCase());
534
+ }
535
+ return set;
536
+ }
537
+ function isWhitespace(char) {
538
+ return char === " " || char === "\n" || char === " " || char === "\r" || char === "\f";
539
+ }
540
+ function decodeHtmlEntities(value) {
541
+ return value.replace(/&(#x?[0-9a-fA-F]+|[\w]+);/g, (_, entity) => {
542
+ if (entity.startsWith("#")) {
543
+ const isHex = entity.length > 1 && entity[1].toLowerCase() === "x";
544
+ const code = isHex ? parseInt(entity.slice(2), 16) : parseInt(entity.slice(1), 10);
545
+ return Number.isFinite(code) ? String.fromCodePoint(code) : "";
546
+ }
547
+ return namedEntities[entity] ?? _;
548
+ });
549
+ }
550
+ function escapeAttribute(value) {
551
+ return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
552
+ }
553
+ function escapeText(value) {
554
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;");
555
+ }
556
+ function detach(node) {
557
+ if (node.parentNode) {
558
+ node.parentNode.removeChild(node);
559
+ }
560
+ }
561
+ function serializePretty(node, indent, newline, depth) {
562
+ const pad = indent.repeat(depth);
563
+ if (node instanceof TextNode || node instanceof CommentNode) {
564
+ const value = node.toString();
565
+ return value ? `${pad}${value}` : "";
566
+ }
567
+ if (node instanceof DocumentFragment) {
568
+ return node.childNodes.map((child) => serializePretty(child, indent, newline, depth)).filter(Boolean).join(newline);
569
+ }
570
+ if (!(node instanceof HTMLElement)) {
571
+ return "";
572
+ }
573
+ const element = node;
574
+ const attrString = Object.entries(element.attrs).map(([key, value]) => value === "" ? key : `${key}="${escapeAttribute(value)}"`).join(" ");
575
+ const openTag = attrString ? `<${element.tagName} ${attrString}>` : `<${element.tagName}>`;
576
+ if (element.isVoidElement || !element.childNodes.length) {
577
+ if (element.isVoidElement) {
578
+ return `${pad}${openTag}`;
579
+ }
580
+ return `${pad}${openTag}</${element.tagName}>`;
581
+ }
582
+ const children = element.childNodes.map((child) => serializePretty(child, indent, newline, depth + 1)).filter(Boolean).join(newline);
583
+ const closing = `</${element.tagName}>`;
584
+ if (!children) {
585
+ return `${pad}${openTag}${closing}`;
586
+ }
587
+ return `${pad}${openTag}${newline}${children}${newline}${pad}${closing}`;
588
+ }
589
+ function traverse(nodes, visitor, parent, depth) {
590
+ for (let i = 0; i < nodes.length; i += 1) {
591
+ const node = nodes[i];
592
+ const signal = visitor(node, { parent, depth, index: i });
593
+ if (signal === "stop") {
594
+ return true;
595
+ }
596
+ if (signal !== "skip" && isParentNode(node) && node.childNodes.length) {
597
+ if (traverse(node.childNodes, visitor, node, depth + 1)) {
598
+ return true;
599
+ }
600
+ }
601
+ }
602
+ return false;
603
+ }
604
+
605
+ // src/compiler/compileTemplate.js
606
+ var structuralAttrs = /* @__PURE__ */ new Set(["ce:if", "ce:else", "ce:for", "track", "ce:slot", "ce:await", "ce:then", "ce:catch"]);
607
+ var TemplateCompiler = class {
608
+ constructor(options = {}) {
609
+ this.options = options;
610
+ this.instructions = [];
611
+ this.styles = [];
612
+ }
613
+ compile(source) {
614
+ const html = parse(`<fragment>${source}</fragment>`, {
615
+ comment: false,
616
+ lowerCaseTagName: false
617
+ });
618
+ const fragment = html.firstChild ?? html;
619
+ const nodes = fragment.childNodes;
620
+ this.walkNodes(nodes);
621
+ return {
622
+ name: this.options.name,
623
+ instructions: this.instructions,
624
+ styles: this.styles.length ? this.styles : void 0,
625
+ scopeId: this.options.scopeId
626
+ };
627
+ }
628
+ walkNodes(nodes) {
629
+ for (let i = 0; i < nodes.length; i += 1) {
630
+ const node = nodes[i];
631
+ if (isStyleNode(node)) {
632
+ const styleText = node.textContent.trim();
633
+ if (styleText) {
634
+ this.styles.push(styleText);
635
+ }
636
+ continue;
637
+ }
638
+ if (node.nodeType === NodeType.ELEMENT_NODE) {
639
+ const element = node;
640
+ if (element.hasAttribute("ce:else")) {
641
+ continue;
642
+ }
643
+ if (element.hasAttribute("ce:await")) {
644
+ this.instructions.push(this.compileAwait(element));
645
+ continue;
646
+ }
647
+ if (element.hasAttribute("ce:if")) {
648
+ const { instruction, consumedElse } = this.compileConditional(element, nodes, i);
649
+ this.instructions.push(instruction);
650
+ if (consumedElse) {
651
+ i += 1;
652
+ }
653
+ continue;
654
+ }
655
+ if (element.hasAttribute("ce:for")) {
656
+ this.instructions.push(this.compileLoop(element));
657
+ continue;
658
+ }
659
+ this.instructions.push(this.compileElement(element));
660
+ continue;
661
+ }
662
+ if (node.nodeType === NodeType.TEXT_NODE) {
663
+ this.instructions.push(...this.compileText(node));
664
+ }
665
+ }
666
+ }
667
+ compileConditional(element, nodes, index) {
668
+ const condition = element.getAttribute("ce:if") ?? "";
669
+ const truthy = [this.compileElement(element, true)];
670
+ let falsy;
671
+ let consumedElse = false;
672
+ const next = nodes[index + 1];
673
+ if (next && next.nodeType === NodeType.ELEMENT_NODE) {
674
+ const nextElement = next;
675
+ if (nextElement.hasAttribute("ce:else")) {
676
+ falsy = [this.compileElement(nextElement, true)];
677
+ consumedElse = true;
678
+ }
679
+ }
680
+ return {
681
+ instruction: {
682
+ type: "if",
683
+ condition,
684
+ truthy,
685
+ falsy
686
+ },
687
+ consumedElse
688
+ };
689
+ }
690
+ compileLoop(element) {
691
+ const loopExpr = element.getAttribute("ce:for") ?? "";
692
+ const loop = parseLoop(loopExpr);
693
+ return {
694
+ type: "for",
695
+ ...loop,
696
+ children: [this.compileElement(element, true)]
697
+ };
698
+ }
699
+ compileElement(element, stripStructural = false) {
700
+ if (element.tagName.toLowerCase() === "slot") {
701
+ const fallback = [];
702
+ for (const child of element.childNodes) {
703
+ if (child.nodeType === NodeType.TEXT_NODE) {
704
+ fallback.push(...this.compileText(child));
705
+ } else if (child.nodeType === NodeType.ELEMENT_NODE) {
706
+ fallback.push(this.compileElement(child));
707
+ }
708
+ }
709
+ return {
710
+ type: "slot",
711
+ name: element.getAttribute("name") ?? void 0,
712
+ children: fallback
713
+ };
714
+ }
715
+ const attributes = [];
716
+ const attrSource = element.attrs;
717
+ for (const [key, rawValue] of Object.entries(attrSource)) {
718
+ const value = String(rawValue);
719
+ if (stripStructural && structuralAttrs.has(key)) {
720
+ continue;
721
+ }
722
+ if (key.startsWith("on:")) {
723
+ const eventName = key.slice(3);
724
+ attributes.push({ kind: "event", name: eventName, handler: value });
725
+ continue;
726
+ }
727
+ if (key.startsWith("[") && key.endsWith("]")) {
728
+ const prop = key.slice(1, -1);
729
+ attributes.push({ kind: "property", name: prop, expression: value });
730
+ continue;
731
+ }
732
+ if (key.startsWith("bind:")) {
733
+ const prop = key.slice(5);
734
+ attributes.push({ kind: "property", name: prop, expression: value });
735
+ continue;
736
+ }
737
+ if (key === "class:list") {
738
+ attributes.push({ kind: "class-list", expression: value });
739
+ continue;
740
+ }
741
+ if (key === "ce:slot") {
742
+ attributes.push({ kind: "static", name: "slot", value });
743
+ continue;
744
+ }
745
+ attributes.push({ kind: "static", name: key, value });
746
+ }
747
+ const children = [];
748
+ for (const child of element.childNodes) {
749
+ if (isStyleNode(child)) {
750
+ continue;
751
+ }
752
+ if (child.nodeType === NodeType.ELEMENT_NODE) {
753
+ const childEl = child;
754
+ if (childEl.hasAttribute("ce:await")) {
755
+ children.push(this.compileAwait(childEl));
756
+ continue;
757
+ }
758
+ if (childEl.hasAttribute("ce:if") || childEl.hasAttribute("ce:for")) {
759
+ const compiledFragment = compileTemplate(childEl.toString(), this.options);
760
+ children.push(...compiledFragment.instructions);
761
+ continue;
762
+ }
763
+ children.push(this.compileElement(childEl));
764
+ continue;
765
+ }
766
+ if (child.nodeType === NodeType.TEXT_NODE) {
767
+ children.push(...this.compileText(child));
768
+ }
769
+ }
770
+ return {
771
+ type: "element",
772
+ tag: element.tagName.toLowerCase(),
773
+ attributes,
774
+ children
775
+ };
776
+ }
777
+ compileAwait(element) {
778
+ if (element.tagName.toLowerCase() !== "template") {
779
+ throw new Error("ce:await must be used on a <template> element.");
780
+ }
781
+ const expression = element.getAttribute("ce:await") ?? "";
782
+ const pending = [];
783
+ let resolved = [];
784
+ let rejected = [];
785
+ let valueName;
786
+ let errorName;
787
+ for (const child of element.childNodes) {
788
+ if (isStyleNode(child)) {
789
+ continue;
790
+ }
791
+ if (child.nodeType === NodeType.ELEMENT_NODE) {
792
+ const childEl = child;
793
+ if (childEl.tagName.toLowerCase() === "template" && childEl.hasAttribute("ce:then")) {
794
+ valueName = childEl.getAttribute("ce:then") ?? void 0;
795
+ resolved = this.compileTemplateChildren(childEl);
796
+ continue;
797
+ }
798
+ if (childEl.tagName.toLowerCase() === "template" && childEl.hasAttribute("ce:catch")) {
799
+ errorName = childEl.getAttribute("ce:catch") ?? void 0;
800
+ rejected = this.compileTemplateChildren(childEl);
801
+ continue;
802
+ }
803
+ pending.push(this.compileElement(childEl));
804
+ continue;
805
+ }
806
+ if (child.nodeType === NodeType.TEXT_NODE) {
807
+ pending.push(...this.compileText(child));
808
+ }
809
+ }
810
+ return {
811
+ type: "await",
812
+ expression,
813
+ pending,
814
+ resolved,
815
+ rejected,
816
+ valueName,
817
+ errorName
818
+ };
819
+ }
820
+ compileTemplateChildren(element) {
821
+ const children = [];
822
+ for (const child of element.childNodes) {
823
+ if (isStyleNode(child)) {
824
+ continue;
825
+ }
826
+ if (child.nodeType === NodeType.TEXT_NODE) {
827
+ children.push(...this.compileText(child));
828
+ continue;
829
+ }
830
+ if (child.nodeType === NodeType.ELEMENT_NODE) {
831
+ const childEl = child;
832
+ if (childEl.hasAttribute("ce:await")) {
833
+ children.push(this.compileAwait(childEl));
834
+ continue;
835
+ }
836
+ if (childEl.hasAttribute("ce:if") || childEl.hasAttribute("ce:for")) {
837
+ const compiledFragment = compileTemplate(childEl.toString(), this.options);
838
+ children.push(...compiledFragment.instructions);
839
+ continue;
840
+ }
841
+ children.push(this.compileElement(childEl));
842
+ }
843
+ }
844
+ return children;
845
+ }
846
+ compileText(node) {
847
+ const content = node.text;
848
+ if (!this.options.preserveWhitespace && !content.trim()) {
849
+ return [];
850
+ }
851
+ const parts = content.split(/({{[^}]+}})/g).filter(Boolean);
852
+ return parts.map((part) => {
853
+ if (part.startsWith("{{") && part.endsWith("}}")) {
854
+ return {
855
+ type: "expression",
856
+ expression: part.slice(2, -2).trim()
857
+ };
858
+ }
859
+ return {
860
+ type: "text",
861
+ value: this.options.preserveWhitespace ? part : part.trim()
862
+ };
863
+ });
864
+ }
865
+ };
866
+ function compileTemplate(source, options = {}) {
867
+ return new TemplateCompiler(options).compile(source);
868
+ }
869
+ function parseLoop(expression) {
870
+ const loopRegex = /^(?<item>[\w$]+)(?:\s*,\s*(?<index>[\w$]+))?\s+in\s+(?<iterator>.+)$/;
871
+ const match = loopRegex.exec(expression.trim());
872
+ const groups = match?.groups;
873
+ if (!groups) {
874
+ throw new Error(`Invalid ce:for expression: ${expression}`);
875
+ }
876
+ return {
877
+ item: groups.item,
878
+ index: groups.index,
879
+ iterator: groups.iterator
880
+ };
881
+ }
882
+ function isStyleNode(node) {
883
+ return node.nodeType === NodeType.ELEMENT_NODE && node.tagName === "STYLE";
884
+ }
885
+
886
+ export { CommentNode, DocumentFragment, HTMLElement, NodeType, TextNode, cloneNode, compileTemplate, createCommentNode, createElement, createFragment, createTextNode, isCommentNode, isElementNode, isParentNode, isTextNode, parse, serialize, walk };
887
+ //# sourceMappingURL=chunk-BBAUALNU.js.map
888
+ //# sourceMappingURL=chunk-BBAUALNU.js.map