@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,729 @@
1
+ 'use strict';
2
+
3
+ var chunkPVZVFICK_cjs = require('./chunk-PVZVFICK.cjs');
4
+ var chunkIRBUKIRF_cjs = require('./chunk-IRBUKIRF.cjs');
5
+ var chunkFFCZSYC7_cjs = require('./chunk-FFCZSYC7.cjs');
6
+ var chunkEFOOXCY7_cjs = require('./chunk-EFOOXCY7.cjs');
7
+ var chunkVHUXNDW2_cjs = require('./chunk-VHUXNDW2.cjs');
8
+
9
+ // src/runtime/di.js
10
+ var Injector = class _Injector {
11
+ constructor(parent) {
12
+ this.parent = parent;
13
+ this.records = /* @__PURE__ */ new Map();
14
+ }
15
+ register(provider) {
16
+ this.records.set(provider.token, createRecord(provider));
17
+ }
18
+ get(token, notFound) {
19
+ const record = this.records.get(token);
20
+ if (record) {
21
+ if (!record.resolved) {
22
+ record.value = record.factory(this);
23
+ record.resolved = true;
24
+ }
25
+ return record.value;
26
+ }
27
+ if (this.parent) {
28
+ return this.parent.get(token, notFound);
29
+ }
30
+ if (typeof notFound !== "undefined") {
31
+ return notFound;
32
+ }
33
+ throw new Error(`No provider for token ${token.toString()}`);
34
+ }
35
+ createChild(providers = []) {
36
+ const child = new _Injector(this);
37
+ providers.forEach((provider) => {
38
+ child.register(provider);
39
+ });
40
+ return child;
41
+ }
42
+ };
43
+ function createInjector(providers = [], parent) {
44
+ const injector = new Injector(parent);
45
+ providers.forEach((provider) => {
46
+ injector.register(provider);
47
+ });
48
+ return injector;
49
+ }
50
+ function createRecord(provider) {
51
+ if (Object.prototype.hasOwnProperty.call(provider, "useValue")) {
52
+ return {
53
+ token: provider.token,
54
+ resolved: true,
55
+ factory: () => provider.useValue,
56
+ value: provider.useValue
57
+ };
58
+ }
59
+ if (provider.useClass) {
60
+ const Target = provider.useClass;
61
+ return {
62
+ token: provider.token,
63
+ resolved: false,
64
+ factory: (injector) => new Target(...(provider.deps ?? []).map((dep) => injector.get(dep)))
65
+ };
66
+ }
67
+ if (provider.useFactory) {
68
+ const factory = provider.useFactory;
69
+ return {
70
+ token: provider.token,
71
+ resolved: false,
72
+ factory: (injector) => factory(...(provider.deps ?? []).map((dep) => injector.get(dep)))
73
+ };
74
+ }
75
+ throw new Error("Unsupported provider configuration.");
76
+ }
77
+
78
+ // src/runtime/template.js
79
+ var expressionCache = /* @__PURE__ */ new Map();
80
+ function compileExpression(expression) {
81
+ let runner = expressionCache.get(expression);
82
+ if (!runner) {
83
+ runner = new Function("ctx", `with(ctx){ return (${expression}); }`);
84
+ expressionCache.set(expression, runner);
85
+ }
86
+ return runner;
87
+ }
88
+ function toDisplay(value) {
89
+ if (value == null) {
90
+ return "";
91
+ }
92
+ if (Array.isArray(value)) {
93
+ return value.map(toDisplay).join(",");
94
+ }
95
+ if (typeof value === "object") {
96
+ return JSON.stringify(value);
97
+ }
98
+ return String(value);
99
+ }
100
+ function renderTemplate(compiled, scope, target) {
101
+ const disposers = [];
102
+ const register = (dispose) => disposers.push(dispose);
103
+ const renderContext = { scopeAttr: compiled.scopeId };
104
+ compiled.instructions.forEach((instruction) => {
105
+ mountInstruction(instruction, target, scope, register, renderContext);
106
+ });
107
+ return {
108
+ destroy() {
109
+ disposers.slice().reverse().forEach((dispose) => {
110
+ dispose();
111
+ });
112
+ }
113
+ };
114
+ }
115
+ function mountInstruction(instruction, parent, scope, register, context, before) {
116
+ switch (instruction.type) {
117
+ case "text":
118
+ mountText(instruction.value, parent, register, before);
119
+ return;
120
+ case "expression":
121
+ mountExpression(instruction.expression, parent, scope, register, before);
122
+ return;
123
+ case "element":
124
+ mountElement(instruction, parent, scope, register, context, before);
125
+ return;
126
+ case "if":
127
+ mountConditional(instruction, parent, scope, register, context, before);
128
+ return;
129
+ case "for":
130
+ mountLoop(instruction, parent, scope, register, context, before);
131
+ return;
132
+ case "slot":
133
+ mountSlot(instruction, parent, scope, register, context, before);
134
+ return;
135
+ case "await":
136
+ mountAwait(instruction, parent, scope, register, context, before);
137
+ return;
138
+ default:
139
+ return;
140
+ }
141
+ }
142
+ function mountText(value, parent, register, before) {
143
+ const textNode = document.createTextNode(value);
144
+ insertNode(parent, textNode, before);
145
+ register(() => {
146
+ textNode.remove();
147
+ });
148
+ }
149
+ function mountExpression(expression, parent, scope, register, before) {
150
+ const textNode = document.createTextNode("");
151
+ insertNode(parent, textNode, before);
152
+ const runner = compileExpression(expression);
153
+ const dispose = chunkVHUXNDW2_cjs.effect(() => {
154
+ const value = runner(scope);
155
+ textNode.textContent = toDisplay(value);
156
+ });
157
+ register(() => {
158
+ dispose();
159
+ textNode.remove();
160
+ });
161
+ }
162
+ function mountElement(instruction, parent, scope, register, context, before) {
163
+ const el = document.createElement(instruction.tag.toLowerCase());
164
+ const indexedEl = el;
165
+ if (context.scopeAttr && !el.hasAttribute(chunkIRBUKIRF_cjs.STYLE_SCOPE_ATTR)) {
166
+ el.setAttribute(chunkIRBUKIRF_cjs.STYLE_SCOPE_ATTR, context.scopeAttr);
167
+ }
168
+ const attrRegister = createLocalRegister(register);
169
+ for (const attr of instruction.attributes) {
170
+ switch (attr.kind) {
171
+ case "static":
172
+ el.setAttribute(attr.name, attr.value);
173
+ break;
174
+ case "property": {
175
+ const runner = compileExpression(attr.expression);
176
+ const dispose = chunkVHUXNDW2_cjs.effect(() => {
177
+ const value = runner(scope);
178
+ indexedEl[attr.name] = value;
179
+ });
180
+ attrRegister.register(dispose);
181
+ break;
182
+ }
183
+ case "event": {
184
+ const runner = compileExpression(attr.handler);
185
+ const listener = (event) => {
186
+ const handler = runner(scope);
187
+ if (typeof handler === "function") {
188
+ handler(event);
189
+ }
190
+ };
191
+ el.addEventListener(attr.name, listener);
192
+ attrRegister.register(() => {
193
+ el.removeEventListener(attr.name, listener);
194
+ });
195
+ break;
196
+ }
197
+ case "class-list": {
198
+ const runner = compileExpression(attr.expression);
199
+ const dispose = chunkVHUXNDW2_cjs.effect(() => {
200
+ const result = runner(scope);
201
+ if (typeof result === "string") {
202
+ el.className = result;
203
+ return;
204
+ }
205
+ if (result && typeof result === "object") {
206
+ const segments = [];
207
+ for (const [key, value] of Object.entries(result)) {
208
+ if (value) {
209
+ segments.push(key);
210
+ }
211
+ }
212
+ el.className = segments.join(" ");
213
+ }
214
+ });
215
+ attrRegister.register(dispose);
216
+ break;
217
+ }
218
+ }
219
+ }
220
+ insertNode(parent, el, before);
221
+ instruction.children.forEach((child) => {
222
+ mountInstruction(child, el, scope, register, context);
223
+ });
224
+ register(() => {
225
+ attrRegister.flush();
226
+ el.remove();
227
+ });
228
+ }
229
+ function mountConditional(instruction, parent, scope, register, context, before) {
230
+ const anchor = document.createComment("ce:if");
231
+ insertNode(parent, anchor, before);
232
+ let current;
233
+ const runner = compileExpression(instruction.condition);
234
+ const dispose = chunkVHUXNDW2_cjs.effect(() => {
235
+ current?.();
236
+ current = void 0;
237
+ const condition = Boolean(runner(scope));
238
+ if (condition) {
239
+ current = mountInstructionList(instruction.truthy, parent, scope, register, context, anchor);
240
+ return;
241
+ }
242
+ if (instruction.falsy) {
243
+ current = mountInstructionList(instruction.falsy, parent, scope, register, context, anchor);
244
+ }
245
+ });
246
+ register(() => {
247
+ dispose();
248
+ current?.();
249
+ anchor.remove();
250
+ });
251
+ }
252
+ function mountLoop(instruction, parent, scope, register, context, before) {
253
+ const anchor = document.createComment("ce:for");
254
+ insertNode(parent, anchor, before);
255
+ let instances = [];
256
+ const runner = compileExpression(instruction.iterator);
257
+ const dispose = chunkVHUXNDW2_cjs.effect(() => {
258
+ instances.forEach((cleanup) => {
259
+ cleanup();
260
+ });
261
+ instances = [];
262
+ const iterable = runner(scope);
263
+ const values = Array.isArray(iterable) ? iterable : iterable && typeof iterable === "object" && Symbol.iterator in iterable ? Array.from(iterable) : [];
264
+ values.forEach((value, index) => {
265
+ const childScope = Object.create(scope);
266
+ childScope[instruction.item] = value;
267
+ if (instruction.index) {
268
+ childScope[instruction.index] = index;
269
+ }
270
+ instances.push(mountInstructionList(instruction.children, parent, childScope, register, context, anchor));
271
+ });
272
+ });
273
+ register(() => {
274
+ dispose();
275
+ instances.forEach((cleanup) => {
276
+ cleanup();
277
+ });
278
+ anchor.remove();
279
+ });
280
+ }
281
+ function mountSlot(instruction, parent, scope, register, _context, before) {
282
+ const slotName = instruction.name ?? "default";
283
+ const slotRenderer = scope.slots?.[slotName];
284
+ if (slotRenderer) {
285
+ const fragment = document.createDocumentFragment();
286
+ slotRenderer(fragment);
287
+ insertNode(parent, fragment, before);
288
+ const nodes = Array.from(fragment.childNodes);
289
+ register(() => {
290
+ nodes.forEach((node) => {
291
+ node.parentNode?.removeChild(node);
292
+ });
293
+ });
294
+ } else {
295
+ instruction.children.forEach((child) => {
296
+ mountInstruction(child, parent, scope, register, _context, before);
297
+ });
298
+ }
299
+ }
300
+ function mountAwait(instruction, parent, scope, register, context, before) {
301
+ const start = document.createComment("ce:await:start");
302
+ const end = document.createComment("ce:await:end");
303
+ insertNode(parent, start, before);
304
+ insertNode(parent, end, before);
305
+ let currentDispose = null;
306
+ let token = 0;
307
+ const renderBranch = (instructions, extraScope) => {
308
+ if (currentDispose) {
309
+ currentDispose();
310
+ }
311
+ if (instructions.length === 0) {
312
+ currentDispose = null;
313
+ return;
314
+ }
315
+ const branchScope = extraScope ? Object.assign(Object.create(scope), extraScope) : scope;
316
+ currentDispose = mountInstructionList(instructions, parent, branchScope, register, context, end);
317
+ };
318
+ const dispose = chunkVHUXNDW2_cjs.effect(() => {
319
+ const value = compileExpression(instruction.expression)(scope);
320
+ const currentToken = token += 1;
321
+ if (isPromiseLike(value)) {
322
+ renderBranch(instruction.pending);
323
+ value.then((resolved) => {
324
+ if (currentToken !== token) {
325
+ return;
326
+ }
327
+ const extra2 = instruction.valueName ? { [instruction.valueName]: resolved } : void 0;
328
+ renderBranch(instruction.resolved, extra2);
329
+ }).catch((error) => {
330
+ if (currentToken !== token) {
331
+ return;
332
+ }
333
+ const extra2 = instruction.errorName ? { [instruction.errorName]: error } : void 0;
334
+ renderBranch(instruction.rejected, extra2);
335
+ });
336
+ return;
337
+ }
338
+ const extra = instruction.valueName ? { [instruction.valueName]: value } : void 0;
339
+ renderBranch(instruction.resolved, extra);
340
+ });
341
+ register(() => {
342
+ dispose();
343
+ if (currentDispose) {
344
+ currentDispose();
345
+ }
346
+ start.remove();
347
+ end.remove();
348
+ });
349
+ }
350
+ function mountInstructionList(instructions, parent, scope, register, context, before) {
351
+ const local = createLocalRegister(register);
352
+ instructions.forEach((child) => {
353
+ mountInstruction(child, parent, scope, local.register, context, before);
354
+ });
355
+ return () => {
356
+ local.flush();
357
+ };
358
+ }
359
+ function insertNode(parent, node, before) {
360
+ if (before && before.parentNode === parent) {
361
+ parent.insertBefore(node, before);
362
+ return;
363
+ }
364
+ parent.appendChild(node);
365
+ }
366
+ function createLocalRegister(parent) {
367
+ const localDisposers = [];
368
+ const register = (dispose) => localDisposers.push(dispose);
369
+ const flush = () => {
370
+ localDisposers.slice().reverse().forEach((dispose) => {
371
+ dispose();
372
+ });
373
+ localDisposers.length = 0;
374
+ };
375
+ parent(flush);
376
+ return { register, flush };
377
+ }
378
+ function isPromiseLike(value) {
379
+ return Boolean(value) && typeof value === "object" && "then" in value;
380
+ }
381
+
382
+ // src/runtime/ssr.js
383
+ function renderTemplateToString(compiled, scope) {
384
+ return compiled.instructions.map((instruction) => renderInstruction(instruction, scope, compiled.scopeId)).join("");
385
+ }
386
+ async function renderTemplateToStream(compiled, scope) {
387
+ const tasks = [];
388
+ const html = compiled.instructions.map((instruction) => renderInstruction(instruction, scope, compiled.scopeId, tasks)).join("");
389
+ return createStreamIterable(html, tasks);
390
+ }
391
+ function renderInstruction(instruction, scope, scopeAttr, tasks) {
392
+ switch (instruction.type) {
393
+ case "text":
394
+ return escapeHtml(instruction.value);
395
+ case "expression":
396
+ return escapeHtml(toDisplay(compileExpression(instruction.expression)(scope)));
397
+ case "element":
398
+ return renderElement(instruction, scope, scopeAttr, tasks);
399
+ case "if":
400
+ return renderConditional(instruction, scope, scopeAttr, tasks);
401
+ case "for":
402
+ return renderLoop(instruction, scope, scopeAttr, tasks);
403
+ case "slot":
404
+ return renderSlot(instruction, scope, scopeAttr, tasks);
405
+ case "await":
406
+ return renderAwait(instruction, scope, scopeAttr, tasks);
407
+ default:
408
+ return "";
409
+ }
410
+ }
411
+ function renderElement(instruction, scope, scopeAttr, tasks) {
412
+ const attrs = instruction.attributes.map((attr) => attributeToString(attr, scope)).filter(Boolean);
413
+ if (scopeAttr && !instruction.attributes.some((attr) => attr.kind === "static" && attr.name === chunkIRBUKIRF_cjs.STYLE_SCOPE_ATTR)) {
414
+ attrs.push(`${chunkIRBUKIRF_cjs.STYLE_SCOPE_ATTR}="${scopeAttr}"`);
415
+ }
416
+ const joinedAttrs = attrs.filter(Boolean).join(" ");
417
+ const children = instruction.children.map((child) => renderInstruction(child, scope, scopeAttr, tasks)).join("");
418
+ const open = `<${instruction.tag}${joinedAttrs ? ` ${joinedAttrs}` : ""}>`;
419
+ const close = `</${instruction.tag}>`;
420
+ return `${open}${children}${close}`;
421
+ }
422
+ function attributeToString(attr, scope) {
423
+ if (attr.kind === "static") {
424
+ return `${attr.name}="${escapeAttribute(attr.value)}"`;
425
+ }
426
+ if (attr.kind === "property") {
427
+ const value = compileExpression(attr.expression)(scope);
428
+ if (value === false || value === null || typeof value === "undefined") {
429
+ return "";
430
+ }
431
+ return `${attr.name}="${escapeAttribute(toDisplay(value))}"`;
432
+ }
433
+ if (attr.kind === "class-list") {
434
+ const value = compileExpression(attr.expression)(scope);
435
+ if (typeof value === "string") {
436
+ return value ? `class="${escapeAttribute(value)}"` : "";
437
+ }
438
+ if (value && typeof value === "object") {
439
+ const segments = Object.entries(value).filter(([, enabled]) => Boolean(enabled)).map(([key]) => key).join(" ");
440
+ return segments ? `class="${escapeAttribute(segments)}"` : "";
441
+ }
442
+ return "";
443
+ }
444
+ return "";
445
+ }
446
+ function renderConditional(instruction, scope, scopeAttr, tasks) {
447
+ const condition = Boolean(compileExpression(instruction.condition)(scope));
448
+ if (condition) {
449
+ return instruction.truthy.map((child) => renderInstruction(child, scope, scopeAttr, tasks)).join("");
450
+ }
451
+ if (instruction.falsy) {
452
+ return instruction.falsy.map((child) => renderInstruction(child, scope, scopeAttr, tasks)).join("");
453
+ }
454
+ return "";
455
+ }
456
+ function renderLoop(instruction, scope, scopeAttr, tasks) {
457
+ const iterable = compileExpression(instruction.iterator)(scope);
458
+ const values = Array.isArray(iterable) ? iterable : iterable && typeof iterable === "object" && Symbol.iterator in iterable ? Array.from(iterable) : [];
459
+ return values.map((value, index) => {
460
+ const childScope = Object.create(scope);
461
+ childScope[instruction.item] = value;
462
+ if (instruction.index) {
463
+ childScope[instruction.index] = index;
464
+ }
465
+ return instruction.children.map((child) => renderInstruction(child, childScope, scopeAttr, tasks)).join("");
466
+ }).join("");
467
+ }
468
+ function renderSlot(instruction, scope, scopeAttr, tasks) {
469
+ const slotName = instruction.name ?? "default";
470
+ const renderer = scope.slots?.[slotName];
471
+ if (renderer) {
472
+ return "";
473
+ }
474
+ return instruction.children.map((child) => renderInstruction(child, scope, scopeAttr, tasks)).join("");
475
+ }
476
+ function renderAwait(instruction, scope, scopeAttr, tasks) {
477
+ const value = compileExpression(instruction.expression)(scope);
478
+ if (!isPromiseLike2(value)) {
479
+ return renderAwaitBranch(instruction.resolved, scope, scopeAttr, tasks, instruction.valueName, value);
480
+ }
481
+ const pendingHtml = instruction.pending.map((child) => renderInstruction(child, scope, scopeAttr, tasks)).join("");
482
+ const awaitId = nextAwaitId();
483
+ if (tasks) {
484
+ tasks.push({
485
+ id: awaitId,
486
+ promise: value,
487
+ resolve: (resolved) => renderAwaitBranch(instruction.resolved, scope, scopeAttr, tasks, instruction.valueName, resolved),
488
+ reject: (error) => renderAwaitBranch(instruction.rejected, scope, scopeAttr, tasks, instruction.errorName, error)
489
+ });
490
+ }
491
+ return `<span data-ce-await="${awaitId}">${pendingHtml}</span>`;
492
+ }
493
+ function renderAwaitBranch(instructions, scope, scopeAttr, tasks, bindingName, bindingValue) {
494
+ if (instructions.length === 0) {
495
+ return "";
496
+ }
497
+ const branchScope = bindingName ? Object.assign(Object.create(scope), { [bindingName]: bindingValue }) : scope;
498
+ return instructions.map((child) => renderInstruction(child, branchScope, scopeAttr, tasks)).join("");
499
+ }
500
+ function escapeHtml(value) {
501
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
502
+ }
503
+ function escapeAttribute(value) {
504
+ return escapeHtml(value).replace(/"/g, "&quot;");
505
+ }
506
+ function isPromiseLike2(value) {
507
+ return Boolean(value) && typeof value === "object" && "then" in value;
508
+ }
509
+ function createStreamIterable(initialHtml, tasks) {
510
+ return {
511
+ async *[Symbol.asyncIterator]() {
512
+ yield initialHtml;
513
+ for (const task of tasks) {
514
+ try {
515
+ const resolved = await task.promise;
516
+ const html = task.resolve(resolved);
517
+ yield buildAwaitReplacement(task.id, html);
518
+ } catch (error) {
519
+ const html = task.reject(error);
520
+ yield buildAwaitReplacement(task.id, html);
521
+ }
522
+ }
523
+ }
524
+ };
525
+ }
526
+ function buildAwaitReplacement(id, html) {
527
+ const escapedId = escapeAttribute(id);
528
+ const template = `<template data-ce-await="${escapedId}">${html}</template>`;
529
+ const script = `<script>(function(){var t=document.querySelector('template[data-ce-await="${escapedId}"]');var host=document.querySelector('[data-ce-await="${escapedId}"]');if(t&&host){host.replaceWith(t.content.cloneNode(true));t.remove();}})();</script>`;
530
+ return `${template}${script}`;
531
+ }
532
+ var awaitCounter = 0;
533
+ function nextAwaitId() {
534
+ awaitCounter += 1;
535
+ return `await-${awaitCounter}`;
536
+ }
537
+
538
+ // src/runtime/router-context.js
539
+ var routerContextStack = [];
540
+ function withRouterContext(router, run) {
541
+ routerContextStack.push({ router });
542
+ try {
543
+ return run();
544
+ } finally {
545
+ routerContextStack.pop();
546
+ }
547
+ }
548
+ function ensureRouterContext() {
549
+ const context = routerContextStack.at(-1) ?? null;
550
+ if (!context) {
551
+ throw new Error("Router hooks can only be used while a Router context is active.");
552
+ }
553
+ return context;
554
+ }
555
+ function useRouter() {
556
+ return ensureRouterContext().router;
557
+ }
558
+ function useNavigate() {
559
+ const router = useRouter();
560
+ return (path, options) => router.navigate(path, options);
561
+ }
562
+ function useLocation() {
563
+ return useRouter().currentPath;
564
+ }
565
+ function useRouteMatch() {
566
+ return useRouter().currentMatch;
567
+ }
568
+ function useRouteParams() {
569
+ const matchSignal = useRouteMatch();
570
+ return chunkVHUXNDW2_cjs.computed(() => matchSignal()?.params ?? {});
571
+ }
572
+ function useRouteData() {
573
+ const matchSignal = useRouteMatch();
574
+ return chunkVHUXNDW2_cjs.computed(() => {
575
+ const match = matchSignal();
576
+ const entry = chunkEFOOXCY7_cjs.readRouteData(match);
577
+ return entry?.data;
578
+ });
579
+ }
580
+
581
+ // src/runtime/component.js
582
+ var ComponentRuntime = class {
583
+ constructor(options) {
584
+ this.options = options;
585
+ }
586
+ mount(mountOptions) {
587
+ const compiled = this.ensureTemplate();
588
+ styleRegistry.attach(compiled);
589
+ const propsSignal = chunkVHUXNDW2_cjs.signal({ ...mountOptions.props ?? {} });
590
+ const reactiveProps = createReactiveProps(propsSignal);
591
+ const emit = (event, payload) => {
592
+ mountOptions.on?.[event]?.(payload);
593
+ };
594
+ const injector = mountOptions.injector ? mountOptions.injector.createChild(this.options.providers ?? []) : createInjector(this.options.providers ?? []);
595
+ const setupResult = this.options.setup ? this.options.setup({ props: reactiveProps, emit, injector, slots: mountOptions.slots }) : {};
596
+ const { slots: setupSlots, ...setupState } = setupResult ?? {};
597
+ const scope = {
598
+ props: reactiveProps,
599
+ ...setupState,
600
+ slots: setupSlots ?? mountOptions.slots
601
+ };
602
+ const handle = mountOptions.router ? withRouterContext(mountOptions.router, () => renderTemplate(compiled, scope, mountOptions.target)) : renderTemplate(compiled, scope, mountOptions.target);
603
+ const updateProps = (partial) => {
604
+ propsSignal.set({ ...propsSignal(), ...partial });
605
+ };
606
+ const lifecycle = this.options.lifecycle;
607
+ const lifecycleContext = {
608
+ target: mountOptions.target,
609
+ props: reactiveProps,
610
+ emit,
611
+ injector,
612
+ updateProps
613
+ };
614
+ let cleanupTheme;
615
+ let cleanupA11y;
616
+ if (lifecycle?.onThemeUpdate && typeof document !== "undefined") {
617
+ cleanupTheme = chunkPVZVFICK_cjs.registerThemeAwareComponent((state) => {
618
+ lifecycle?.onThemeUpdate?.(state, lifecycleContext);
619
+ });
620
+ }
621
+ if (lifecycle?.onStylesApplied) {
622
+ lifecycle.onStylesApplied(compiled.styles ?? [], lifecycleContext);
623
+ }
624
+ if (lifecycle?.onA11ySetup) {
625
+ const cleanup = lifecycle.onA11ySetup(lifecycleContext);
626
+ if (typeof cleanup === "function") {
627
+ cleanupA11y = cleanup;
628
+ }
629
+ }
630
+ lifecycle?.onMount?.(lifecycleContext);
631
+ return {
632
+ destroy() {
633
+ cleanupTheme?.();
634
+ cleanupA11y?.();
635
+ lifecycle?.onDestroy?.(lifecycleContext);
636
+ handle.destroy();
637
+ },
638
+ updateProps
639
+ };
640
+ }
641
+ renderToString(props) {
642
+ const compiled = this.ensureTemplate();
643
+ const propsSignal = chunkVHUXNDW2_cjs.signal({ ...props ?? {} });
644
+ const reactiveProps = createReactiveProps(propsSignal);
645
+ const injector = createInjector(this.options.providers ?? []);
646
+ const setupResult = this.options.setup ? this.options.setup({ props: reactiveProps, emit: () => void 0, injector }) : {};
647
+ const scope = {
648
+ props: reactiveProps,
649
+ ...setupResult
650
+ };
651
+ return renderTemplateToString(compiled, scope);
652
+ }
653
+ ensureTemplate() {
654
+ if (this.compiled) {
655
+ return this.compiled;
656
+ }
657
+ const compiled = this.buildTemplate();
658
+ this.compiled = compiled;
659
+ return compiled;
660
+ }
661
+ buildTemplate() {
662
+ const base = typeof this.options.template === "string" ? chunkFFCZSYC7_cjs.compileTemplate(this.options.template, {
663
+ name: this.options.name,
664
+ ...this.options.templateOptions,
665
+ scopeId: this.options.scopeId
666
+ }) : { ...this.options.template };
667
+ if (this.options.styles?.length) {
668
+ const scopeId = base.scopeId ?? this.options.scopeId ?? chunkIRBUKIRF_cjs.createStyleScopeId(this.options.name ?? "component");
669
+ base.scopeId = scopeId;
670
+ base.styles = chunkIRBUKIRF_cjs.scopeStyles(this.options.styles, scopeId);
671
+ } else if (base.styles?.length && base.scopeId) {
672
+ base.styles = chunkIRBUKIRF_cjs.scopeStyles(base.styles, base.scopeId);
673
+ }
674
+ return base;
675
+ }
676
+ };
677
+ function defineComponent(options) {
678
+ return new ComponentRuntime(options);
679
+ }
680
+ var StyleRegistry = class {
681
+ constructor() {
682
+ this.mounted = /* @__PURE__ */ new Map();
683
+ }
684
+ attach(compiled) {
685
+ if (typeof document === "undefined") {
686
+ return;
687
+ }
688
+ if (!compiled.styles?.length) {
689
+ return;
690
+ }
691
+ const scopeId = compiled.scopeId ?? "component";
692
+ if (this.mounted.has(scopeId)) {
693
+ return;
694
+ }
695
+ const styleTag = document.createElement("style");
696
+ styleTag.dataset.ceComponent = compiled.name ?? "component";
697
+ styleTag.textContent = compiled.styles.join("\n");
698
+ document.head.appendChild(styleTag);
699
+ this.mounted.set(scopeId, styleTag);
700
+ }
701
+ };
702
+ var styleRegistry = new StyleRegistry();
703
+ function renderComponent(component, options) {
704
+ return component.mount(options);
705
+ }
706
+ function createReactiveProps(propsSignal) {
707
+ return new Proxy({}, {
708
+ get: (_target, key) => {
709
+ const current = propsSignal();
710
+ return current[key];
711
+ }
712
+ });
713
+ }
714
+
715
+ exports.Injector = Injector;
716
+ exports.createInjector = createInjector;
717
+ exports.defineComponent = defineComponent;
718
+ exports.renderComponent = renderComponent;
719
+ exports.renderTemplateToStream = renderTemplateToStream;
720
+ exports.renderTemplateToString = renderTemplateToString;
721
+ exports.useLocation = useLocation;
722
+ exports.useNavigate = useNavigate;
723
+ exports.useRouteData = useRouteData;
724
+ exports.useRouteMatch = useRouteMatch;
725
+ exports.useRouteParams = useRouteParams;
726
+ exports.useRouter = useRouter;
727
+ exports.withRouterContext = withRouterContext;
728
+ //# sourceMappingURL=chunk-W3LNNY3U.cjs.map
729
+ //# sourceMappingURL=chunk-W3LNNY3U.cjs.map