@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,1985 @@
1
+ 'use strict';
2
+
3
+ var chunkZWUA2LPB_cjs = require('./chunk-ZWUA2LPB.cjs');
4
+ var chunkEFOOXCY7_cjs = require('./chunk-EFOOXCY7.cjs');
5
+ var chunkVHUXNDW2_cjs = require('./chunk-VHUXNDW2.cjs');
6
+
7
+ // src/runtime/forms.js
8
+ var PATH_SEGMENT_REGEX = /[^.[\]]+|\[(\d+)\]/g;
9
+ function createFormController() {
10
+ const fields = /* @__PURE__ */ new Map();
11
+ const pathCache = /* @__PURE__ */ new Map();
12
+ const controller = {
13
+ register(name, options) {
14
+ if (fields.has(name)) {
15
+ return fields.get(name);
16
+ }
17
+ const control = createFieldControl(name, options);
18
+ fields.set(name, control);
19
+ return control;
20
+ },
21
+ registerArray(name, options) {
22
+ if (fields.has(name)) {
23
+ return fields.get(name);
24
+ }
25
+ const base = createFieldControl(name, options);
26
+ const control = {
27
+ ...base,
28
+ append(value) {
29
+ updateArray(base, (items) => {
30
+ items.push(value);
31
+ });
32
+ },
33
+ insert(index, value) {
34
+ updateArray(base, (items) => {
35
+ const nextIndex = clampIndex(index, items.length);
36
+ items.splice(nextIndex, 0, value);
37
+ });
38
+ },
39
+ remove(index) {
40
+ updateArray(base, (items) => {
41
+ if (index < 0 || index >= items.length) {
42
+ return;
43
+ }
44
+ items.splice(index, 1);
45
+ });
46
+ },
47
+ swap(indexA, indexB) {
48
+ updateArray(base, (items) => {
49
+ if (indexA < 0 || indexA >= items.length || indexB < 0 || indexB >= items.length || indexA === indexB) {
50
+ return;
51
+ }
52
+ const temp = items[indexA];
53
+ items[indexA] = items[indexB];
54
+ items[indexB] = temp;
55
+ });
56
+ },
57
+ move(fromIndex, toIndex) {
58
+ updateArray(base, (items) => {
59
+ if (fromIndex < 0 || fromIndex >= items.length) {
60
+ return;
61
+ }
62
+ const targetIndex = clampIndex(toIndex, items.length - 1);
63
+ const [item] = items.splice(fromIndex, 1);
64
+ const insertIndex = clampIndex(targetIndex, items.length);
65
+ items.splice(insertIndex, 0, item);
66
+ });
67
+ }
68
+ };
69
+ fields.set(name, control);
70
+ return control;
71
+ },
72
+ values() {
73
+ return buildNestedState((field) => field.value());
74
+ },
75
+ errors() {
76
+ return buildNestedErrors();
77
+ },
78
+ async validate() {
79
+ const entries = orderedEntries();
80
+ const fieldStates = {};
81
+ for (const [name, field] of entries) {
82
+ fieldStates[name] = await field.validateWithState();
83
+ }
84
+ return buildValidationResult(fieldStates, entries);
85
+ },
86
+ async validateFields(names) {
87
+ if (names.length === 0) {
88
+ return {
89
+ valid: true,
90
+ errors: {},
91
+ fields: {}
92
+ };
93
+ }
94
+ const entries = orderedEntries().filter(([name]) => names.includes(name));
95
+ const fieldStates = {};
96
+ for (const [name, field] of entries) {
97
+ fieldStates[name] = await field.validateWithState();
98
+ }
99
+ return buildValidationResult(fieldStates, entries);
100
+ },
101
+ handleSubmit(handler) {
102
+ return async (event) => {
103
+ event?.preventDefault();
104
+ const result = await controller.validate();
105
+ if (!result.valid) {
106
+ return;
107
+ }
108
+ await handler(controller.values(), event);
109
+ };
110
+ }
111
+ };
112
+ function createFieldControl(name, options) {
113
+ const value = chunkVHUXNDW2_cjs.signal(options.initialValue);
114
+ const errors = chunkVHUXNDW2_cjs.signal([]);
115
+ const touched = chunkVHUXNDW2_cjs.signal(false);
116
+ const runValidators = async () => {
117
+ const context = {
118
+ name,
119
+ value: value(),
120
+ values: controller.values(),
121
+ touched: touched()
122
+ };
123
+ const results = await Promise.all((options.validators ?? []).map((validator) => Promise.resolve(validator(context.value, context))));
124
+ const filtered = results.filter((message) => Boolean(message));
125
+ errors.set(filtered);
126
+ return {
127
+ name,
128
+ valid: filtered.length === 0,
129
+ errors: filtered
130
+ };
131
+ };
132
+ return {
133
+ name,
134
+ value,
135
+ errors,
136
+ touched,
137
+ setValue(nextValue) {
138
+ value.set(nextValue);
139
+ },
140
+ markTouched() {
141
+ touched.set(true);
142
+ },
143
+ async validate() {
144
+ const state = await runValidators();
145
+ return state.valid;
146
+ },
147
+ async validateWithState() {
148
+ return runValidators();
149
+ }
150
+ };
151
+ }
152
+ function updateArray(control, update) {
153
+ const current = Array.isArray(control.value()) ? [...control.value()] : [];
154
+ update(current);
155
+ control.setValue(current);
156
+ }
157
+ function orderedEntries() {
158
+ return Array.from(fields.entries()).sort((a, b) => getPath(a[0]).length - getPath(b[0]).length);
159
+ }
160
+ function buildNestedState(readValue) {
161
+ const result = {};
162
+ orderedEntries().forEach(([name, field]) => {
163
+ const path = getPath(name);
164
+ if (path.length === 0) {
165
+ return;
166
+ }
167
+ setPathValue(result, path, readValue(field));
168
+ });
169
+ return result;
170
+ }
171
+ function buildNestedErrors() {
172
+ return buildNestedErrorsForEntries(orderedEntries());
173
+ }
174
+ function buildNestedErrorsForEntries(entries) {
175
+ const result = {};
176
+ entries.forEach(([name, field]) => {
177
+ const fieldErrors = field.errors();
178
+ if (!fieldErrors.length) {
179
+ return;
180
+ }
181
+ const path = getPath(name);
182
+ if (path.length === 0) {
183
+ return;
184
+ }
185
+ setPathValue(result, path, fieldErrors);
186
+ });
187
+ return result;
188
+ }
189
+ function buildValidationResult(fieldStates, entries) {
190
+ const errors = buildNestedErrorsForEntries(entries);
191
+ const valid = Object.values(fieldStates).every((state) => state.valid);
192
+ return {
193
+ valid,
194
+ errors,
195
+ fields: fieldStates
196
+ };
197
+ }
198
+ function getPath(name) {
199
+ const cached = pathCache.get(name);
200
+ if (cached) {
201
+ return cached;
202
+ }
203
+ const segments = [];
204
+ let match;
205
+ while ((match = PATH_SEGMENT_REGEX.exec(name)) !== null) {
206
+ if (match[1] !== void 0) {
207
+ segments.push(Number(match[1]));
208
+ } else if (match[0]) {
209
+ segments.push(match[0]);
210
+ }
211
+ }
212
+ const resolved = segments.length > 0 ? segments : [name];
213
+ pathCache.set(name, resolved);
214
+ return resolved;
215
+ }
216
+ return controller;
217
+ }
218
+ function createFormWizard(form, steps, initialStep = 0) {
219
+ if (steps.length === 0) {
220
+ throw new Error("Form wizard requires at least one step.");
221
+ }
222
+ const stepIndex = chunkVHUXNDW2_cjs.signal(resolveStepIndex(steps, initialStep));
223
+ const currentStep = chunkVHUXNDW2_cjs.computed(() => steps[stepIndex()]);
224
+ const isFirst = chunkVHUXNDW2_cjs.computed(() => stepIndex() === 0);
225
+ const isLast = chunkVHUXNDW2_cjs.computed(() => stepIndex() >= steps.length - 1);
226
+ const controller = {
227
+ steps,
228
+ currentIndex: stepIndex,
229
+ currentStep,
230
+ isFirst,
231
+ isLast,
232
+ goTo(step) {
233
+ stepIndex.set(resolveStepIndex(steps, step));
234
+ },
235
+ async next() {
236
+ if (await controller.validateCurrent()) {
237
+ if (!isLast()) {
238
+ stepIndex.set(stepIndex() + 1);
239
+ }
240
+ return true;
241
+ }
242
+ return false;
243
+ },
244
+ previous() {
245
+ if (!isFirst()) {
246
+ stepIndex.set(stepIndex() - 1);
247
+ }
248
+ },
249
+ async validateCurrent() {
250
+ const step = currentStep();
251
+ if (step.validate) {
252
+ return Boolean(await step.validate(form));
253
+ }
254
+ if (step.fields && step.fields.length > 0) {
255
+ const result = await form.validateFields(step.fields);
256
+ return result.valid;
257
+ }
258
+ return true;
259
+ },
260
+ reset(step = 0) {
261
+ stepIndex.set(resolveStepIndex(steps, step));
262
+ }
263
+ };
264
+ return controller;
265
+ }
266
+ function resolveStepIndex(steps, step) {
267
+ if (typeof step === "number") {
268
+ return clampIndex(step, steps.length - 1);
269
+ }
270
+ const index = steps.findIndex((item) => item.id === step);
271
+ return index >= 0 ? index : 0;
272
+ }
273
+ function setPathValue(target, path, value) {
274
+ let cursor = target;
275
+ for (let index = 0; index < path.length; index += 1) {
276
+ const segment = path[index];
277
+ const isLast = index === path.length - 1;
278
+ if (isLast) {
279
+ if (Array.isArray(cursor) && typeof segment === "number") {
280
+ cursor[segment] = value;
281
+ } else {
282
+ cursor[segment] = value;
283
+ }
284
+ return;
285
+ }
286
+ const nextSegment = path[index + 1];
287
+ const shouldBeArray = typeof nextSegment === "number";
288
+ if (Array.isArray(cursor) && typeof segment === "number") {
289
+ if (!cursor[segment] || typeof cursor[segment] !== "object") {
290
+ cursor[segment] = shouldBeArray ? [] : {};
291
+ }
292
+ cursor = cursor[segment];
293
+ continue;
294
+ }
295
+ const currentValue = cursor[segment];
296
+ if (!currentValue || typeof currentValue !== "object") {
297
+ cursor[segment] = shouldBeArray ? [] : {};
298
+ } else if (shouldBeArray && !Array.isArray(currentValue)) {
299
+ cursor[segment] = [];
300
+ } else if (!shouldBeArray && Array.isArray(currentValue)) {
301
+ cursor[segment] = {};
302
+ }
303
+ cursor = cursor[segment];
304
+ }
305
+ }
306
+ function clampIndex(index, length) {
307
+ if (Number.isNaN(index)) {
308
+ return length;
309
+ }
310
+ return Math.min(Math.max(index, 0), length);
311
+ }
312
+
313
+ // src/runtime/resource.js
314
+ var defaultCache = createResourceCache();
315
+ function createResourceCache() {
316
+ const store = chunkVHUXNDW2_cjs.signal(/* @__PURE__ */ new Map());
317
+ return {
318
+ read(key) {
319
+ return store().get(key);
320
+ },
321
+ write(key, state) {
322
+ store.update((current) => {
323
+ const next = new Map(current);
324
+ next.set(key, state);
325
+ return next;
326
+ });
327
+ },
328
+ delete(key) {
329
+ store.update((current) => {
330
+ const next = new Map(current);
331
+ next.delete(key);
332
+ return next;
333
+ });
334
+ },
335
+ clear() {
336
+ store.set(/* @__PURE__ */ new Map());
337
+ },
338
+ keys() {
339
+ return Array.from(store().keys());
340
+ }
341
+ };
342
+ }
343
+ function getResourceCache() {
344
+ return defaultCache;
345
+ }
346
+ function normalizeResourceKey(key) {
347
+ return encodeResourceKey(key);
348
+ }
349
+ function invalidateResource(key, cache = defaultCache) {
350
+ cache.delete(normalizeResourceKey(key));
351
+ }
352
+ function createResource(key, fetcher, options = {}) {
353
+ const cache = options.cache ?? defaultCache;
354
+ const keySignal = chunkVHUXNDW2_cjs.signal(normalizeResourceKey(key));
355
+ const cached = resolveCachedState(cache, keySignal(), options.cacheTimeMs);
356
+ const hasCached = Boolean(cached);
357
+ const initialState = cached ? cached : options.initialData !== void 0 ? {
358
+ status: "success",
359
+ data: options.initialData,
360
+ updatedAt: Date.now()
361
+ } : { status: "idle" };
362
+ const state = chunkVHUXNDW2_cjs.signal(initialState);
363
+ const setState = (next) => {
364
+ state.set(next);
365
+ cache.write(keySignal(), next);
366
+ };
367
+ const load = async (context = {}) => {
368
+ const current = state();
369
+ if (!context.force && current.status === "success" && !isResourceStale(current, options.staleTimeMs)) {
370
+ return current;
371
+ }
372
+ if (current.status === "loading") {
373
+ return current;
374
+ }
375
+ setState({
376
+ ...current,
377
+ status: "loading"
378
+ });
379
+ const maxRetries = options.maxRetries ?? (typeof options.retry === "number" ? options.retry : 3);
380
+ let lastError;
381
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
382
+ try {
383
+ if (attempt > 0) {
384
+ const delay = typeof options.retryDelayMs === "function" ? options.retryDelayMs(attempt - 1) : calculateRetryDelay(attempt - 1, options.retryDelayMs);
385
+ await new Promise((resolve) => setTimeout(resolve, delay));
386
+ }
387
+ const data = await Promise.resolve(fetcher(context));
388
+ const next2 = {
389
+ status: "success",
390
+ data,
391
+ error: void 0,
392
+ updatedAt: Date.now()
393
+ };
394
+ setState(next2);
395
+ options.onSuccess?.(data);
396
+ options.onSettled?.(data, void 0);
397
+ return next2;
398
+ } catch (error) {
399
+ lastError = classifyError(error);
400
+ const shouldRetry = attempt < maxRetries && determineRetry(options.retry, attempt, lastError);
401
+ if (!shouldRetry) {
402
+ break;
403
+ }
404
+ }
405
+ }
406
+ const finalError = lastError ?? classifyError(new Error("Unknown error"));
407
+ const next = {
408
+ status: "error",
409
+ data: state().data,
410
+ error: finalError,
411
+ updatedAt: Date.now()
412
+ };
413
+ setState(next);
414
+ options.onError?.(finalError);
415
+ options.onSettled?.(void 0, finalError);
416
+ return next;
417
+ };
418
+ const resource = {
419
+ key: keySignal,
420
+ state,
421
+ isStale() {
422
+ return isResourceStale(state(), options.staleTimeMs);
423
+ },
424
+ load,
425
+ refresh(context) {
426
+ return load({ ...context, force: true });
427
+ },
428
+ async mutate(mutator, mutateOptions) {
429
+ const current = state();
430
+ const previousData = current.data;
431
+ if (mutateOptions?.optimisticData !== void 0) {
432
+ setState({
433
+ status: "success",
434
+ data: mutateOptions.optimisticData,
435
+ error: void 0,
436
+ updatedAt: Date.now()
437
+ });
438
+ }
439
+ try {
440
+ const nextData = await Promise.resolve(mutator(previousData));
441
+ const next = {
442
+ status: "success",
443
+ data: nextData,
444
+ error: void 0,
445
+ updatedAt: Date.now()
446
+ };
447
+ setState(next);
448
+ options.onSuccess?.(nextData);
449
+ options.onSettled?.(nextData, void 0);
450
+ return next;
451
+ } catch (error) {
452
+ const normalized = error instanceof Error ? error : new Error(String(error));
453
+ const shouldRollback = mutateOptions?.rollbackOnError !== false && previousData !== void 0;
454
+ if (shouldRollback) {
455
+ setState({
456
+ status: "success",
457
+ data: previousData,
458
+ error: void 0,
459
+ updatedAt: current.updatedAt ?? Date.now()
460
+ });
461
+ mutateOptions?.onRollback?.(previousData);
462
+ options.onError?.(normalized);
463
+ options.onSettled?.(void 0, normalized);
464
+ return {
465
+ status: "success",
466
+ data: previousData,
467
+ error: void 0,
468
+ updatedAt: current.updatedAt ?? Date.now()
469
+ };
470
+ } else {
471
+ setState({
472
+ status: "error",
473
+ data: previousData,
474
+ error: normalized,
475
+ updatedAt: Date.now()
476
+ });
477
+ }
478
+ options.onError?.(normalized);
479
+ options.onSettled?.(void 0, normalized);
480
+ return {
481
+ status: "error",
482
+ data: previousData,
483
+ error: normalized,
484
+ updatedAt: Date.now()
485
+ };
486
+ }
487
+ },
488
+ setData(data) {
489
+ setState({
490
+ status: "success",
491
+ data,
492
+ error: void 0,
493
+ updatedAt: Date.now()
494
+ });
495
+ },
496
+ setError(error) {
497
+ setState({
498
+ status: "error",
499
+ data: state().data,
500
+ error,
501
+ updatedAt: Date.now()
502
+ });
503
+ },
504
+ clear() {
505
+ setState({ status: "idle" });
506
+ cache.delete(keySignal());
507
+ }
508
+ };
509
+ if (options.enabled) {
510
+ void load();
511
+ }
512
+ if (options.refetchOnStale && hasCached && resource.isStale()) {
513
+ void load();
514
+ }
515
+ return resource;
516
+ }
517
+ function encodeResourceKey(value) {
518
+ if (value === void 0) {
519
+ return "u:";
520
+ }
521
+ if (value === null) {
522
+ return "null:";
523
+ }
524
+ if (typeof value === "string") {
525
+ return `s:${value}`;
526
+ }
527
+ if (typeof value === "number") {
528
+ return `n:${String(value)}`;
529
+ }
530
+ if (typeof value === "boolean") {
531
+ return `b:${value ? "1" : "0"}`;
532
+ }
533
+ if (Array.isArray(value)) {
534
+ return `a:[${value.map(encodeResourceKey).join("|")}]`;
535
+ }
536
+ const keys = Object.keys(value).sort();
537
+ const serialized = keys.map((key) => `${key}:${encodeResourceKey(value[key])}`).join("|");
538
+ return `o:{${serialized}}`;
539
+ }
540
+ function determineRetry(retry, attempt, error) {
541
+ if (retry === false || retry === void 0) {
542
+ return false;
543
+ }
544
+ if (!error.retryable) {
545
+ return false;
546
+ }
547
+ if (retry === true) {
548
+ return true;
549
+ }
550
+ if (typeof retry === "number") {
551
+ return attempt < retry;
552
+ }
553
+ return retry(attempt, error);
554
+ }
555
+ function resolveCachedState(cache, key, cacheTimeMs) {
556
+ const cached = cache.read(key);
557
+ if (!cached) {
558
+ return void 0;
559
+ }
560
+ if (isResourceExpired(cached, cacheTimeMs)) {
561
+ cache.delete(key);
562
+ return void 0;
563
+ }
564
+ return cached;
565
+ }
566
+ function isResourceStale(state, staleTimeMs) {
567
+ if (staleTimeMs === void 0) {
568
+ return false;
569
+ }
570
+ if (!state.updatedAt) {
571
+ return true;
572
+ }
573
+ return Date.now() - state.updatedAt >= staleTimeMs;
574
+ }
575
+ function isResourceExpired(state, cacheTimeMs) {
576
+ if (cacheTimeMs === void 0) {
577
+ return false;
578
+ }
579
+ if (!state.updatedAt) {
580
+ return true;
581
+ }
582
+ return Date.now() - state.updatedAt >= cacheTimeMs;
583
+ }
584
+ function classifyError(error) {
585
+ const base = error instanceof Error ? error : new Error(String(error));
586
+ if (base.name === "AbortError" || error && error.code === "ABORT_ERR") {
587
+ return Object.assign(base, {
588
+ type: "abort",
589
+ retryable: false
590
+ });
591
+ }
592
+ if (base.name === "TimeoutError" || base.message.toLowerCase().includes("timeout")) {
593
+ return Object.assign(base, {
594
+ type: "timeout",
595
+ retryable: true
596
+ });
597
+ }
598
+ const lower = base.message.toLowerCase();
599
+ if (base.name === "TypeError" && (lower.includes("fetch") || lower.includes("network"))) {
600
+ return Object.assign(base, {
601
+ type: "network",
602
+ retryable: true
603
+ });
604
+ }
605
+ const statusCode = error && error.statusCode;
606
+ if (statusCode !== void 0) {
607
+ if (statusCode >= 500) {
608
+ return Object.assign(base, {
609
+ type: "server",
610
+ retryable: true,
611
+ statusCode
612
+ });
613
+ }
614
+ if (statusCode >= 400) {
615
+ return Object.assign(base, {
616
+ type: "client",
617
+ retryable: false,
618
+ statusCode
619
+ });
620
+ }
621
+ }
622
+ return Object.assign(base, {
623
+ type: "unknown",
624
+ retryable: false
625
+ });
626
+ }
627
+ function calculateRetryDelay(attempt, baseDelayMs = 1e3) {
628
+ const exponentialDelay = Math.min(baseDelayMs * Math.pow(2, attempt), 3e4);
629
+ const jitter = exponentialDelay * 0.25 * (Math.random() * 2 - 1);
630
+ return Math.max(0, Math.floor(exponentialDelay + jitter));
631
+ }
632
+
633
+ // src/runtime/ai.ts
634
+ function createAiSession(options) {
635
+ const historyLimit = Math.max(2, options.historyLimit ?? 20);
636
+ const initialMessages = trimHistory(options.initialMessages ?? [], historyLimit);
637
+ const messagesSignal = chunkVHUXNDW2_cjs.signal(initialMessages);
638
+ const suggestionsSignal = chunkVHUXNDW2_cjs.signal([...options.initialSuggestions ?? []]);
639
+ const statusSignal = chunkVHUXNDW2_cjs.signal("idle");
640
+ const errorSignal = chunkVHUXNDW2_cjs.signal(null);
641
+ const send = async (prompt, metadata) => {
642
+ const content = prompt.trim();
643
+ if (!content) {
644
+ return;
645
+ }
646
+ const priorMessages = messagesSignal();
647
+ const userMessage = createMessage("user", content, metadata?.context);
648
+ const nextHistory = trimHistory([...priorMessages, userMessage], historyLimit);
649
+ messagesSignal.set(nextHistory);
650
+ statusSignal.set("processing");
651
+ errorSignal.set(null);
652
+ const requestHistory = metadata?.systemPrompt ? trimHistory([...priorMessages, createMessage("system", metadata.systemPrompt), userMessage], historyLimit) : nextHistory;
653
+ try {
654
+ const response = await options.provider({
655
+ messages: requestHistory,
656
+ prompt: content,
657
+ locale: metadata?.locale ?? options.locale,
658
+ context: { ...options.context ?? {}, ...metadata?.context ?? {} }
659
+ });
660
+ const assistantMessage = normalizeAssistantMessage(response.message);
661
+ messagesSignal.set(trimHistory([...messagesSignal(), assistantMessage], historyLimit));
662
+ if (response.suggestions) {
663
+ suggestionsSignal.set(response.suggestions);
664
+ }
665
+ statusSignal.set("idle");
666
+ } catch (error) {
667
+ statusSignal.set("error");
668
+ errorSignal.set(error instanceof Error ? error.message : "Failed to fetch AI response");
669
+ }
670
+ };
671
+ const reset = () => {
672
+ messagesSignal.set([...initialMessages]);
673
+ suggestionsSignal.set([...options.initialSuggestions ?? []]);
674
+ statusSignal.set("idle");
675
+ errorSignal.set(null);
676
+ };
677
+ return {
678
+ messages: messagesSignal,
679
+ suggestions: suggestionsSignal,
680
+ status: statusSignal,
681
+ error: errorSignal,
682
+ send,
683
+ reset
684
+ };
685
+ }
686
+ function createHttpAiProvider(options) {
687
+ const fetcher = options.fetch ?? globalThis.fetch;
688
+ if (!fetcher) {
689
+ throw new Error("No fetch implementation available for AI provider.");
690
+ }
691
+ return async (request) => {
692
+ const response = await fetcher(options.endpoint, {
693
+ method: "POST",
694
+ headers: {
695
+ "content-type": "application/json",
696
+ ...options.headers ?? {}
697
+ },
698
+ body: JSON.stringify(request)
699
+ });
700
+ if (!response.ok) {
701
+ const errorText = await response.text();
702
+ throw new Error(`AI endpoint responded with ${String(response.status)}: ${errorText}`);
703
+ }
704
+ const json = await response.json();
705
+ return options.mapResponse ? options.mapResponse(json) : json;
706
+ };
707
+ }
708
+ function createMockAiProvider(options = {}) {
709
+ const suggestions = options.suggestions ?? [
710
+ "Summarize the key risks",
711
+ "Outline a rollout plan",
712
+ "Draft stakeholder notes"
713
+ ];
714
+ return async (request) => {
715
+ const delay = Math.max(0, options.delayMs ?? 120);
716
+ if (delay) {
717
+ await new Promise((resolve) => setTimeout(resolve, delay));
718
+ }
719
+ const suffix = options.signature ? `
720
+
721
+ \u2014 ${options.signature}` : "";
722
+ return {
723
+ message: {
724
+ content: `AI mock response:
725
+ ${request.prompt}${suffix}`
726
+ },
727
+ suggestions
728
+ };
729
+ };
730
+ }
731
+ function trimHistory(messages, limit) {
732
+ if (messages.length <= limit) {
733
+ return [...messages];
734
+ }
735
+ return messages.slice(messages.length - limit);
736
+ }
737
+ function createMessage(role, content, metadata) {
738
+ return {
739
+ id: createMessageId(),
740
+ role,
741
+ content,
742
+ metadata,
743
+ createdAt: Date.now()
744
+ };
745
+ }
746
+ function normalizeAssistantMessage(payload) {
747
+ return {
748
+ id: payload.id ?? createMessageId(),
749
+ role: payload.role ?? "assistant",
750
+ content: payload.content,
751
+ metadata: payload.metadata,
752
+ createdAt: payload.createdAt ?? Date.now()
753
+ };
754
+ }
755
+ function createMessageId() {
756
+ const maybeCrypto = globalThis.crypto;
757
+ if (maybeCrypto?.randomUUID) {
758
+ return maybeCrypto.randomUUID();
759
+ }
760
+ return `ai_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
761
+ }
762
+
763
+ // src/runtime/devtools/diagnostics.js
764
+ function createRuntimeDiagnosticsStore(options = {}) {
765
+ const reports = chunkVHUXNDW2_cjs.signal([]);
766
+ const reporterName = options.reporterName ?? `ceui-devtools-${Date.now()}`;
767
+ const maxReports = options.maxReports ?? 100;
768
+ let attached = false;
769
+ const reporter = {
770
+ name: reporterName,
771
+ report(report) {
772
+ reports.update((current) => {
773
+ const next = [...current, report];
774
+ if (next.length > maxReports) {
775
+ return next.slice(next.length - maxReports);
776
+ }
777
+ return next;
778
+ });
779
+ }
780
+ };
781
+ const store = {
782
+ reports,
783
+ attach() {
784
+ if (attached) {
785
+ return;
786
+ }
787
+ chunkZWUA2LPB_cjs.addRuntimeErrorReporter(reporter);
788
+ attached = true;
789
+ },
790
+ detach() {
791
+ if (!attached) {
792
+ return;
793
+ }
794
+ const next = chunkZWUA2LPB_cjs.getRuntimeErrorReporters().filter((entry) => entry.name !== reporterName);
795
+ chunkZWUA2LPB_cjs.registerRuntimeErrorReporters(next);
796
+ attached = false;
797
+ },
798
+ clearReports() {
799
+ reports.set([]);
800
+ },
801
+ getSnapshot() {
802
+ return {
803
+ reports: reports(),
804
+ routeData: store.getRouteDataSnapshot(),
805
+ resources: store.getResourceSnapshot()
806
+ };
807
+ },
808
+ getRouteDataSnapshot() {
809
+ const data = chunkEFOOXCY7_cjs.getRouteDataStore()();
810
+ return Object.fromEntries(data.entries());
811
+ },
812
+ getResourceSnapshot() {
813
+ const cache = getResourceCache();
814
+ const entries = cache.keys().map((key) => [key, cache.read(key)]).filter(([, value]) => Boolean(value));
815
+ return Object.fromEntries(entries);
816
+ }
817
+ };
818
+ return store;
819
+ }
820
+
821
+ // src/runtime/devtools/hydration-dashboard.js
822
+ function getHydrationReports(reports) {
823
+ return reports.filter((report) => report.info.phase === "hydration");
824
+ }
825
+ function buildHydrationSummary(reports) {
826
+ const hydrationReports = getHydrationReports(reports);
827
+ const summary = {
828
+ total: hydrationReports.length,
829
+ byTemplateId: {},
830
+ byComponentName: {},
831
+ byReason: {}
832
+ };
833
+ hydrationReports.forEach((report) => {
834
+ const templateId = report.info.templateId ?? "unknown";
835
+ summary.byTemplateId[templateId] = (summary.byTemplateId[templateId] ?? 0) + 1;
836
+ const componentName = report.info.componentName ?? "unknown";
837
+ summary.byComponentName[componentName] = (summary.byComponentName[componentName] ?? 0) + 1;
838
+ const reason = extractHydrationReason(report.error);
839
+ summary.byReason[reason] = (summary.byReason[reason] ?? 0) + 1;
840
+ });
841
+ return summary;
842
+ }
843
+ function extractHydrationReason(error) {
844
+ const message = error?.message ?? "unknown";
845
+ const prefix = "[hydration] ";
846
+ return message.startsWith(prefix) ? message.slice(prefix.length) : message;
847
+ }
848
+
849
+ // src/runtime/devtools/hydration-replay.js
850
+ function getHydrationDomPayload(report) {
851
+ const attributes = report.info.attributes;
852
+ if (!attributes || typeof attributes !== "object") {
853
+ return {};
854
+ }
855
+ const record = attributes;
856
+ return {
857
+ expectedDom: typeof record.expectedDom === "string" ? record.expectedDom : void 0,
858
+ receivedDom: typeof record.receivedDom === "string" ? record.receivedDom : void 0
859
+ };
860
+ }
861
+ function buildHydrationDomDiff(expectedDom, receivedDom, contextRadius = 40) {
862
+ const expected = expectedDom ?? "";
863
+ const received = receivedDom ?? "";
864
+ const minLength = Math.min(expected.length, received.length);
865
+ let mismatchIndex = -1;
866
+ for (let i = 0; i < minLength; i += 1) {
867
+ if (expected[i] !== received[i]) {
868
+ mismatchIndex = i;
869
+ break;
870
+ }
871
+ }
872
+ if (mismatchIndex === -1 && expected.length !== received.length) {
873
+ mismatchIndex = minLength;
874
+ }
875
+ const hasMismatch = mismatchIndex !== -1;
876
+ const expectedContext = hasMismatch ? expected.slice(Math.max(0, mismatchIndex - contextRadius), mismatchIndex + contextRadius) : "";
877
+ const receivedContext = hasMismatch ? received.slice(Math.max(0, mismatchIndex - contextRadius), mismatchIndex + contextRadius) : "";
878
+ return {
879
+ hasMismatch,
880
+ firstMismatchIndex: mismatchIndex,
881
+ expectedLength: expected.length,
882
+ receivedLength: received.length,
883
+ expectedContext,
884
+ receivedContext
885
+ };
886
+ }
887
+ function createHydrationReplaySession(report, options = {}) {
888
+ const payload = getHydrationDomPayload(report);
889
+ const diff = payload.expectedDom || payload.receivedDom ? buildHydrationDomDiff(payload.expectedDom, payload.receivedDom, options.contextRadius) : null;
890
+ return {
891
+ payload,
892
+ diff,
893
+ applyExpected(target) {
894
+ applyDomPayload(target, payload.expectedDom);
895
+ },
896
+ applyReceived(target) {
897
+ applyDomPayload(target, payload.receivedDom);
898
+ },
899
+ clear(target) {
900
+ clearNode(target);
901
+ }
902
+ };
903
+ }
904
+ function applyDomPayload(target, html) {
905
+ clearNode(target);
906
+ if (!html) {
907
+ return;
908
+ }
909
+ if (typeof document === "undefined") {
910
+ return;
911
+ }
912
+ if (target instanceof Element) {
913
+ target.innerHTML = html;
914
+ return;
915
+ }
916
+ if (target instanceof DocumentFragment) {
917
+ const template = document.createElement("template");
918
+ template.innerHTML = html;
919
+ target.appendChild(template.content.cloneNode(true));
920
+ return;
921
+ }
922
+ target.textContent = html;
923
+ }
924
+ function clearNode(target) {
925
+ while (target.firstChild) {
926
+ target.removeChild(target.firstChild);
927
+ }
928
+ }
929
+
930
+ // src/runtime/devtools/hydration-replay-panel.js
931
+ function createHydrationReplayPanel(report, options = {}) {
932
+ if (typeof document === "undefined") {
933
+ throw new Error("[ce-ui] Hydration replay panel requires a DOM.");
934
+ }
935
+ const contextRadius = options.contextRadius ?? 40;
936
+ const session = createHydrationReplaySession(report, { contextRadius });
937
+ const diff = session.diff ?? buildHydrationDomDiff(session.payload.expectedDom, session.payload.receivedDom, contextRadius);
938
+ const container = document.createElement("section");
939
+ container.className = ["ceui-hydration-panel", options.className].filter(Boolean).join(" ");
940
+ const style = document.createElement("style");
941
+ style.textContent = `
942
+ .ceui-hydration-panel {
943
+ font-family: "Space Grotesk", "IBM Plex Sans", "Segoe UI", sans-serif;
944
+ border: 1px solid var(--ceui-border, #d7dbe6);
945
+ border-radius: 16px;
946
+ padding: 16px;
947
+ background: var(--ceui-surface, #ffffff);
948
+ box-shadow: 0 10px 24px rgba(25, 36, 60, 0.08);
949
+ }
950
+ .ceui-hydration-panel__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
951
+ .ceui-hydration-panel__meta { font-size: 12px; color: var(--ceui-muted, #6a7280); }
952
+ .ceui-hydration-panel__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
953
+ .ceui-hydration-panel__card {
954
+ border: 1px solid rgba(36, 86, 255, 0.12);
955
+ border-radius: 14px;
956
+ padding: 12px;
957
+ background: var(--ceui-surface-alt, #f6f4ff);
958
+ }
959
+ .ceui-hydration-panel__preview { border: 1px dashed #c9ccd4; border-radius: 10px; padding: 8px; min-height: 64px; background: #ffffff; }
960
+ .ceui-hydration-panel__code { margin-top: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: #f1f3f8; padding: 8px; border-radius: 8px; overflow: auto; }
961
+ .ceui-hydration-panel__highlight { background: #ffd54f; color: #1c1e22; padding: 0 2px; border-radius: 3px; }
962
+ .ceui-hydration-panel__label { font-weight: 600; margin-bottom: 6px; color: var(--ceui-ink, #1f2430); }
963
+ `;
964
+ const header = document.createElement("div");
965
+ header.className = "ceui-hydration-panel__header";
966
+ const title = document.createElement("div");
967
+ title.textContent = `Hydration Replay \xB7 ${report.info.templateId ?? "template"}`;
968
+ const meta = document.createElement("div");
969
+ meta.className = "ceui-hydration-panel__meta";
970
+ meta.textContent = `Component: ${report.info.componentName ?? "unknown"} \xB7 Mismatch index: ${diff.firstMismatchIndex}`;
971
+ header.append(title, meta);
972
+ const grid = document.createElement("div");
973
+ grid.className = "ceui-hydration-panel__grid";
974
+ grid.appendChild(buildPane("Expected (SSR)", session.payload.expectedDom, diff.firstMismatchIndex, contextRadius));
975
+ grid.appendChild(buildPane("Received (CSR)", session.payload.receivedDom, diff.firstMismatchIndex, contextRadius));
976
+ container.append(style, header, grid);
977
+ return container;
978
+ }
979
+ function buildPane(label, html, mismatchIndex, contextRadius) {
980
+ const card = document.createElement("div");
981
+ card.className = "ceui-hydration-panel__card";
982
+ const labelNode = document.createElement("div");
983
+ labelNode.className = "ceui-hydration-panel__label";
984
+ labelNode.textContent = label;
985
+ const preview = document.createElement("div");
986
+ preview.className = "ceui-hydration-panel__preview";
987
+ if (html) {
988
+ preview.innerHTML = html;
989
+ }
990
+ const code = document.createElement("pre");
991
+ code.className = "ceui-hydration-panel__code";
992
+ code.innerHTML = highlightSnippet(html ?? "", mismatchIndex, contextRadius);
993
+ card.append(labelNode, preview, code);
994
+ return card;
995
+ }
996
+ function highlightSnippet(value, mismatchIndex, contextRadius) {
997
+ if (!value) {
998
+ return escapeHtml("(empty)");
999
+ }
1000
+ if (mismatchIndex < 0) {
1001
+ return escapeHtml(truncate(value, contextRadius * 2));
1002
+ }
1003
+ const start = Math.max(0, mismatchIndex - contextRadius);
1004
+ const end = Math.min(value.length, mismatchIndex + contextRadius);
1005
+ const before = escapeHtml(value.slice(start, mismatchIndex));
1006
+ const current = value[mismatchIndex] ?? "";
1007
+ const after = escapeHtml(value.slice(mismatchIndex + 1, end));
1008
+ const highlight = current ? escapeHtml(current) : "&nbsp;";
1009
+ return `${before}<mark class="ceui-hydration-panel__highlight">${highlight}</mark>${after}`;
1010
+ }
1011
+ function truncate(value, maxLength) {
1012
+ if (value.length <= maxLength) {
1013
+ return value;
1014
+ }
1015
+ return `${value.slice(0, maxLength)}\u2026`;
1016
+ }
1017
+ function escapeHtml(value) {
1018
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
1019
+ }
1020
+
1021
+ // src/runtime/devtools/router-inspector-panel.js
1022
+ function createRouterInspectorPanel(inspector, options = {}) {
1023
+ if (typeof document === "undefined") {
1024
+ throw new Error("[ce-ui] Router inspector panel requires a DOM.");
1025
+ }
1026
+ const snapshot = inspector.getSnapshot();
1027
+ const container = document.createElement("section");
1028
+ container.className = ["ceui-router-panel", options.className].filter(Boolean).join(" ");
1029
+ const style = document.createElement("style");
1030
+ style.textContent = `
1031
+ .ceui-router-panel {
1032
+ font-family: "Space Grotesk", "IBM Plex Sans", "Segoe UI", sans-serif;
1033
+ border: 1px solid var(--ceui-border, #d7dbe6);
1034
+ border-radius: 16px;
1035
+ padding: 16px;
1036
+ background: var(--ceui-surface, #ffffff);
1037
+ box-shadow: 0 10px 24px rgba(25, 36, 60, 0.08);
1038
+ }
1039
+ .ceui-router-panel__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
1040
+ .ceui-router-panel__meta { font-size: 12px; color: var(--ceui-muted, #6a7280); }
1041
+ .ceui-router-panel__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
1042
+ .ceui-router-panel__card {
1043
+ border: 1px solid rgba(36, 86, 255, 0.12);
1044
+ border-radius: 14px;
1045
+ padding: 12px;
1046
+ background: var(--ceui-surface-alt, #f6f4ff);
1047
+ }
1048
+ .ceui-router-panel__list { margin: 0; padding: 0; list-style: none; }
1049
+ .ceui-router-panel__item { padding: 4px 0; font-size: 13px; }
1050
+ .ceui-router-panel__item--active { font-weight: 600; color: var(--ceui-ink, #1f2430); }
1051
+ .ceui-router-panel__code {
1052
+ margin-top: 8px;
1053
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
1054
+ font-size: 12px;
1055
+ background: #f1f3f8;
1056
+ padding: 8px;
1057
+ border-radius: 8px;
1058
+ overflow: auto;
1059
+ }
1060
+ .ceui-router-panel__label { font-weight: 600; margin-bottom: 6px; color: var(--ceui-ink, #1f2430); }
1061
+ `;
1062
+ const header = document.createElement("div");
1063
+ header.className = "ceui-router-panel__header";
1064
+ const title = document.createElement("div");
1065
+ title.textContent = "Router Inspector";
1066
+ const meta = document.createElement("div");
1067
+ meta.className = "ceui-router-panel__meta";
1068
+ meta.textContent = `Path: ${snapshot.currentPath || "/"}`;
1069
+ header.append(title, meta);
1070
+ const grid = document.createElement("div");
1071
+ grid.className = "ceui-router-panel__grid";
1072
+ const treeCard = document.createElement("div");
1073
+ treeCard.className = "ceui-router-panel__card";
1074
+ const treeLabel = document.createElement("div");
1075
+ treeLabel.className = "ceui-router-panel__label";
1076
+ treeLabel.textContent = "Route Tree";
1077
+ const list = document.createElement("ul");
1078
+ list.className = "ceui-router-panel__list";
1079
+ buildRouteList(snapshot.tree, list, 0);
1080
+ treeCard.append(treeLabel, list);
1081
+ grid.appendChild(treeCard);
1082
+ if (options.showRouteData !== false) {
1083
+ const dataCard = document.createElement("div");
1084
+ dataCard.className = "ceui-router-panel__card";
1085
+ const dataLabel = document.createElement("div");
1086
+ dataLabel.className = "ceui-router-panel__label";
1087
+ dataLabel.textContent = "Route Data Cache";
1088
+ const cacheList = document.createElement("ul");
1089
+ cacheList.className = "ceui-router-panel__list";
1090
+ const dataEntries = Object.entries(snapshot.routeData);
1091
+ if (dataEntries.length === 0) {
1092
+ const empty = document.createElement("li");
1093
+ empty.className = "ceui-router-panel__item";
1094
+ empty.textContent = "No cached loader/action data.";
1095
+ cacheList.appendChild(empty);
1096
+ } else {
1097
+ dataEntries.forEach(([key, entry]) => {
1098
+ cacheList.appendChild(buildRouteDataItem(key, entry));
1099
+ });
1100
+ }
1101
+ dataCard.append(dataLabel, cacheList);
1102
+ grid.appendChild(dataCard);
1103
+ }
1104
+ container.append(style, header, grid);
1105
+ return container;
1106
+ }
1107
+ function buildRouteList(nodes, list, depth) {
1108
+ nodes.forEach((node) => {
1109
+ const item = document.createElement("li");
1110
+ item.className = `ceui-router-panel__item${node.isActive ? " ceui-router-panel__item--active" : ""}`;
1111
+ item.textContent = `${" ".repeat(depth * 2)}${node.fullPath}`;
1112
+ list.appendChild(item);
1113
+ if (node.children.length) {
1114
+ buildRouteList(node.children, list, depth + 1);
1115
+ }
1116
+ });
1117
+ }
1118
+ function buildRouteDataItem(key, entry) {
1119
+ const item = document.createElement("li");
1120
+ item.className = "ceui-router-panel__item";
1121
+ const label = document.createElement("div");
1122
+ label.textContent = key;
1123
+ const status = document.createElement("div");
1124
+ status.className = "ceui-router-panel__meta";
1125
+ const phase = entry.info?.phase ?? "unknown";
1126
+ const outcome = entry.error ? "error" : "ok";
1127
+ const handled = entry.handled ? "handled" : "unhandled";
1128
+ status.textContent = `Phase: ${phase} \xB7 Status: ${outcome} \xB7 ${handled}`;
1129
+ if (entry.error) {
1130
+ status.textContent += ` \xB7 ${entry.error.message}`;
1131
+ }
1132
+ if (typeof entry.durationMs === "number") {
1133
+ status.textContent += ` \xB7 Duration: ${entry.durationMs}ms`;
1134
+ }
1135
+ const code = document.createElement("pre");
1136
+ code.className = "ceui-router-panel__code";
1137
+ code.textContent = JSON.stringify(
1138
+ {
1139
+ handled: entry.handled,
1140
+ hasError: Boolean(entry.error),
1141
+ info: entry.info ?? null,
1142
+ data: entry.data ?? null
1143
+ },
1144
+ null,
1145
+ 2
1146
+ );
1147
+ item.append(label, status, code);
1148
+ return item;
1149
+ }
1150
+
1151
+ // src/runtime/devtools/signals-inspector.js
1152
+ function createSignalsInspector() {
1153
+ const snapshot = chunkVHUXNDW2_cjs.signal(chunkVHUXNDW2_cjs.getSignalsInspectorSnapshot());
1154
+ return {
1155
+ snapshot,
1156
+ refresh() {
1157
+ const next = chunkVHUXNDW2_cjs.getSignalsInspectorSnapshot();
1158
+ snapshot.set(next);
1159
+ return next;
1160
+ },
1161
+ clear() {
1162
+ chunkVHUXNDW2_cjs.clearSignalsInspectorRegistry();
1163
+ snapshot.set(chunkVHUXNDW2_cjs.getSignalsInspectorSnapshot());
1164
+ }
1165
+ };
1166
+ }
1167
+ function buildSignalsGraph(snapshot) {
1168
+ const nodes = [
1169
+ ...snapshot.signals.map((signal2) => ({
1170
+ id: signal2.id,
1171
+ type: "signal",
1172
+ label: signal2.id
1173
+ })),
1174
+ ...snapshot.effects.map((effect) => ({
1175
+ id: effect.id,
1176
+ type: "effect",
1177
+ label: effect.name
1178
+ }))
1179
+ ];
1180
+ const edges = [];
1181
+ snapshot.effects.forEach((effect) => {
1182
+ effect.trackedSignalIds.forEach((signalId) => {
1183
+ edges.push({ from: effect.id, to: signalId, type: "tracks" });
1184
+ });
1185
+ });
1186
+ return { nodes, edges };
1187
+ }
1188
+
1189
+ // src/runtime/devtools/signals-inspector-panel.js
1190
+ function createSignalsInspectorPanel(options = {}) {
1191
+ if (typeof document === "undefined") {
1192
+ throw new Error("[ce-ui] Signals inspector panel requires a DOM.");
1193
+ }
1194
+ const snapshot = options.snapshot ?? createSignalsInspector().refresh();
1195
+ const graph = buildSignalsGraph(snapshot);
1196
+ const container = document.createElement("section");
1197
+ container.className = ["ceui-signals-panel", options.className].filter(Boolean).join(" ");
1198
+ const style = document.createElement("style");
1199
+ style.textContent = `
1200
+ .ceui-signals-panel {
1201
+ font-family: "Space Grotesk", "IBM Plex Sans", "Segoe UI", sans-serif;
1202
+ border: 1px solid var(--ceui-border, #d7dbe6);
1203
+ border-radius: 16px;
1204
+ padding: 16px;
1205
+ background: var(--ceui-surface, #ffffff);
1206
+ box-shadow: 0 10px 24px rgba(25, 36, 60, 0.08);
1207
+ }
1208
+ .ceui-signals-panel__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
1209
+ .ceui-signals-panel__meta { font-size: 12px; color: var(--ceui-muted, #6a7280); }
1210
+ .ceui-signals-panel__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
1211
+ .ceui-signals-panel__card {
1212
+ border: 1px solid rgba(36, 86, 255, 0.12);
1213
+ border-radius: 14px;
1214
+ padding: 12px;
1215
+ background: var(--ceui-surface-alt, #f6f4ff);
1216
+ }
1217
+ .ceui-signals-panel__list { margin: 0; padding: 0; list-style: none; }
1218
+ .ceui-signals-panel__item { padding: 4px 0; font-size: 13px; }
1219
+ .ceui-signals-panel__label { font-weight: 600; margin-bottom: 6px; color: var(--ceui-ink, #1f2430); }
1220
+ `;
1221
+ const header = document.createElement("div");
1222
+ header.className = "ceui-signals-panel__header";
1223
+ const title = document.createElement("div");
1224
+ title.textContent = "Signals Inspector";
1225
+ const meta = document.createElement("div");
1226
+ meta.className = "ceui-signals-panel__meta";
1227
+ meta.textContent = `Signals: ${snapshot.signals.length} \xB7 Effects: ${snapshot.effects.length}`;
1228
+ header.append(title, meta);
1229
+ const grid = document.createElement("div");
1230
+ grid.className = "ceui-signals-panel__grid";
1231
+ grid.appendChild(buildSignalList(snapshot));
1232
+ grid.appendChild(buildEffectList(snapshot));
1233
+ grid.appendChild(buildEdgesList(graph));
1234
+ container.append(style, header, grid);
1235
+ return container;
1236
+ }
1237
+ function buildSignalList(snapshot) {
1238
+ const card = document.createElement("div");
1239
+ card.className = "ceui-signals-panel__card";
1240
+ const label = document.createElement("div");
1241
+ label.className = "ceui-signals-panel__label";
1242
+ label.textContent = "Signals";
1243
+ const list = document.createElement("ul");
1244
+ list.className = "ceui-signals-panel__list";
1245
+ if (snapshot.signals.length === 0) {
1246
+ list.appendChild(buildEmptyItem("No signals recorded."));
1247
+ } else {
1248
+ snapshot.signals.forEach((signal2) => {
1249
+ const item = document.createElement("li");
1250
+ item.className = "ceui-signals-panel__item";
1251
+ item.textContent = `${signal2.id} \xB7 Subscribers: ${signal2.subscribers}`;
1252
+ list.appendChild(item);
1253
+ });
1254
+ }
1255
+ card.append(label, list);
1256
+ return card;
1257
+ }
1258
+ function buildEffectList(snapshot) {
1259
+ const card = document.createElement("div");
1260
+ card.className = "ceui-signals-panel__card";
1261
+ const label = document.createElement("div");
1262
+ label.className = "ceui-signals-panel__label";
1263
+ label.textContent = "Effects";
1264
+ const list = document.createElement("ul");
1265
+ list.className = "ceui-signals-panel__list";
1266
+ if (snapshot.effects.length === 0) {
1267
+ list.appendChild(buildEmptyItem("No effects recorded."));
1268
+ } else {
1269
+ snapshot.effects.forEach((effect) => {
1270
+ const item = document.createElement("li");
1271
+ item.className = "ceui-signals-panel__item";
1272
+ item.textContent = `${effect.name} (${effect.id}) \xB7 Tracks: ${effect.trackedSignals}`;
1273
+ list.appendChild(item);
1274
+ });
1275
+ }
1276
+ card.append(label, list);
1277
+ return card;
1278
+ }
1279
+ function buildEdgesList(graph) {
1280
+ const card = document.createElement("div");
1281
+ card.className = "ceui-signals-panel__card";
1282
+ const label = document.createElement("div");
1283
+ label.className = "ceui-signals-panel__label";
1284
+ label.textContent = "Edges";
1285
+ const list = document.createElement("ul");
1286
+ list.className = "ceui-signals-panel__list";
1287
+ if (graph.edges.length === 0) {
1288
+ list.appendChild(buildEmptyItem("No tracked edges yet."));
1289
+ } else {
1290
+ graph.edges.forEach((edge) => {
1291
+ const item = document.createElement("li");
1292
+ item.className = "ceui-signals-panel__item";
1293
+ item.textContent = `${edge.from} \u2192 ${edge.to}`;
1294
+ list.appendChild(item);
1295
+ });
1296
+ }
1297
+ card.append(label, list);
1298
+ return card;
1299
+ }
1300
+ function buildEmptyItem(message) {
1301
+ const item = document.createElement("li");
1302
+ item.className = "ceui-signals-panel__item";
1303
+ item.textContent = message;
1304
+ return item;
1305
+ }
1306
+
1307
+ // src/runtime/devtools/devtools-dashboard.js
1308
+ function createDevtoolsDashboard(options = {}) {
1309
+ if (typeof document === "undefined") {
1310
+ throw new Error("[ce-ui] Devtools dashboard requires a DOM.");
1311
+ }
1312
+ const container = document.createElement("section");
1313
+ container.className = ["ceui-devtools-dashboard", options.className].filter(Boolean).join(" ");
1314
+ const style = document.createElement("style");
1315
+ style.textContent = `
1316
+ .ceui-devtools-dashboard {
1317
+ --ceui-surface: #ffffff;
1318
+ --ceui-surface-alt: #f6f4ff;
1319
+ --ceui-border: #d7dbe6;
1320
+ --ceui-ink: #1f2430;
1321
+ --ceui-muted: #6a7280;
1322
+ --ceui-accent: #2456ff;
1323
+ --ceui-shadow: 0 18px 40px rgba(25, 36, 60, 0.12);
1324
+ font-family: "Space Grotesk", "IBM Plex Sans", "Segoe UI", sans-serif;
1325
+ display: grid;
1326
+ gap: 18px;
1327
+ padding: 20px;
1328
+ border-radius: 20px;
1329
+ background:
1330
+ radial-gradient(120% 140% at 10% 0%, rgba(36, 86, 255, 0.12), transparent 55%),
1331
+ radial-gradient(140% 120% at 90% 10%, rgba(34, 197, 94, 0.12), transparent 60%),
1332
+ linear-gradient(135deg, #fefeff 0%, #f5f6fb 55%, #ffffff 100%);
1333
+ border: 1px solid var(--ceui-border);
1334
+ box-shadow: var(--ceui-shadow);
1335
+ color: var(--ceui-ink);
1336
+ animation: ceui-dashboard-fade 420ms ease;
1337
+ }
1338
+ .ceui-devtools-dashboard--compact {
1339
+ gap: 12px;
1340
+ padding: 14px;
1341
+ border-radius: 16px;
1342
+ }
1343
+ .ceui-devtools-dashboard--soft {
1344
+ --ceui-surface: #fafbfc;
1345
+ --ceui-surface-alt: #f8f9fc;
1346
+ --ceui-border: #e3e6ed;
1347
+ --ceui-ink: #414958;
1348
+ --ceui-muted: #7d8594;
1349
+ --ceui-accent: #5577ff;
1350
+ --ceui-shadow: 0 12px 32px rgba(25, 36, 60, 0.08);
1351
+ background:
1352
+ radial-gradient(120% 140% at 10% 0%, rgba(85, 119, 255, 0.08), transparent 55%),
1353
+ radial-gradient(140% 120% at 90% 10%, rgba(52, 211, 153, 0.08), transparent 60%),
1354
+ linear-gradient(135deg, #fafbfc 0%, #f8f9fc 55%, #fafbfc 100%);
1355
+ }
1356
+ @keyframes ceui-dashboard-fade {
1357
+ from { opacity: 0; transform: translateY(8px); }
1358
+ to { opacity: 1; transform: translateY(0); }
1359
+ }
1360
+ .ceui-devtools-dashboard__empty {
1361
+ border: 1px dashed var(--ceui-border);
1362
+ border-radius: 14px;
1363
+ padding: 16px;
1364
+ color: var(--ceui-muted);
1365
+ background: rgba(255, 255, 255, 0.7);
1366
+ }
1367
+ .ceui-devtools-dashboard__header {
1368
+ display: flex;
1369
+ justify-content: space-between;
1370
+ align-items: center;
1371
+ gap: 16px;
1372
+ }
1373
+ .ceui-devtools-dashboard__title {
1374
+ font-weight: 600;
1375
+ font-size: 20px;
1376
+ letter-spacing: -0.02em;
1377
+ }
1378
+ .ceui-devtools-dashboard__subtitle {
1379
+ font-size: 12px;
1380
+ color: var(--ceui-muted);
1381
+ }
1382
+ .ceui-devtools-dashboard__refresh,
1383
+ .ceui-devtools-dashboard__toggle,
1384
+ .ceui-devtools-dashboard__copy,
1385
+ .ceui-devtools-dashboard__clear,
1386
+ .ceui-devtools-dashboard__export {
1387
+ border: 1px solid var(--ceui-border);
1388
+ background: var(--ceui-surface);
1389
+ border-radius: 999px;
1390
+ padding: 6px 12px;
1391
+ cursor: pointer;
1392
+ font-size: 12px;
1393
+ transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
1394
+ }
1395
+ .ceui-devtools-dashboard--compact .ceui-devtools-dashboard__refresh,
1396
+ .ceui-devtools-dashboard--compact .ceui-devtools-dashboard__toggle,
1397
+ .ceui-devtools-dashboard--compact .ceui-devtools-dashboard__copy,
1398
+ .ceui-devtools-dashboard--compact .ceui-devtools-dashboard__clear,
1399
+ .ceui-devtools-dashboard--compact .ceui-devtools-dashboard__export {
1400
+ padding: 5px 10px;
1401
+ font-size: 11px;
1402
+ border-radius: 12px;
1403
+ }
1404
+ .ceui-devtools-dashboard__refresh:hover,
1405
+ .ceui-devtools-dashboard__toggle:hover,
1406
+ .ceui-devtools-dashboard__copy:hover,
1407
+ .ceui-devtools-dashboard__clear:hover,
1408
+ .ceui-devtools-dashboard__export:hover {
1409
+ border-color: var(--ceui-accent);
1410
+ box-shadow: 0 6px 14px rgba(36, 86, 255, 0.16);
1411
+ transform: translateY(-1px);
1412
+ }
1413
+ .ceui-devtools-dashboard__panels { display: grid; gap: 16px; }
1414
+ .ceui-devtools-dashboard__panels > * {
1415
+ animation: ceui-panel-rise 360ms ease;
1416
+ animation-fill-mode: both;
1417
+ }
1418
+ .ceui-devtools-dashboard__panels > *:nth-child(1) { animation-delay: 40ms; }
1419
+ .ceui-devtools-dashboard__panels > *:nth-child(2) { animation-delay: 100ms; }
1420
+ .ceui-devtools-dashboard__panels > *:nth-child(3) { animation-delay: 160ms; }
1421
+ @keyframes ceui-panel-rise {
1422
+ from { opacity: 0; transform: translateY(10px); }
1423
+ to { opacity: 1; transform: translateY(0); }
1424
+ }
1425
+ .ceui-devtools-dashboard__summary {
1426
+ display: flex;
1427
+ flex-wrap: wrap;
1428
+ gap: 10px;
1429
+ color: var(--ceui-muted);
1430
+ font-size: 12px;
1431
+ }
1432
+ .ceui-devtools-dashboard--compact .ceui-devtools-dashboard__summary {
1433
+ gap: 8px;
1434
+ font-size: 11px;
1435
+ }
1436
+ .ceui-devtools-dashboard__pill {
1437
+ background: var(--ceui-surface-alt);
1438
+ border-radius: 999px;
1439
+ padding: 4px 12px;
1440
+ max-width: 320px;
1441
+ overflow: hidden;
1442
+ text-overflow: ellipsis;
1443
+ white-space: nowrap;
1444
+ border: 1px solid rgba(36, 86, 255, 0.12);
1445
+ }
1446
+ .ceui-devtools-dashboard--compact .ceui-devtools-dashboard__pill { padding: 3px 10px; }
1447
+ .ceui-devtools-dashboard__meta {
1448
+ font-size: 12px;
1449
+ color: var(--ceui-muted);
1450
+ margin-left: auto;
1451
+ margin-right: 12px;
1452
+ }
1453
+ .ceui-devtools-dashboard--compact .ceui-devtools-dashboard__meta {
1454
+ font-size: 11px;
1455
+ margin-right: 8px;
1456
+ }
1457
+ .ceui-devtools-dashboard__controls { display: flex; flex-wrap: wrap; gap: 8px; }
1458
+ .ceui-devtools-dashboard__panels--hidden { display: none; }
1459
+ .ceui-devtools-dashboard__footer {
1460
+ font-size: 12px;
1461
+ color: var(--ceui-muted);
1462
+ padding-top: 4px;
1463
+ }
1464
+ .ceui-devtools-dashboard--compact .ceui-devtools-dashboard__footer {
1465
+ font-size: 11px;
1466
+ padding-top: 2px;
1467
+ }
1468
+ .ceui-devtools-dashboard__phase {
1469
+ font-size: 12px;
1470
+ color: var(--ceui-muted);
1471
+ background: var(--ceui-surface);
1472
+ border: 1px solid var(--ceui-border);
1473
+ border-radius: 14px;
1474
+ padding: 12px;
1475
+ box-shadow: 0 10px 24px rgba(25, 36, 60, 0.08);
1476
+ }
1477
+ .ceui-devtools-dashboard--compact .ceui-devtools-dashboard__phase {
1478
+ font-size: 11px;
1479
+ padding: 10px;
1480
+ border-radius: 12px;
1481
+ }
1482
+ .ceui-devtools-dashboard__phase-title { font-weight: 600; margin-bottom: 6px; color: var(--ceui-ink); }
1483
+ .ceui-devtools-dashboard--compact .ceui-devtools-dashboard__title { font-size: 17px; }
1484
+ .ceui-devtools-dashboard--compact .ceui-devtools-dashboard__subtitle { font-size: 11px; }
1485
+ .ceui-devtools-dashboard--compact .ceui-devtools-dashboard__panels { gap: 12px; }
1486
+ .ceui-devtools-dashboard--compact .ceui-router-panel,
1487
+ .ceui-devtools-dashboard--compact .ceui-signals-panel,
1488
+ .ceui-devtools-dashboard--compact .ceui-hydration-panel,
1489
+ .ceui-devtools-dashboard--compact .ceui-hydration-replay-panel {
1490
+ border-radius: 12px;
1491
+ padding: 12px;
1492
+ box-shadow: 0 8px 18px rgba(25, 36, 60, 0.06);
1493
+ }
1494
+ .ceui-devtools-dashboard--compact .ceui-router-panel__card,
1495
+ .ceui-devtools-dashboard--compact .ceui-signals-panel__card {
1496
+ padding: 10px;
1497
+ border-radius: 12px;
1498
+ }
1499
+ .ceui-devtools-dashboard--compact .ceui-router-panel__item,
1500
+ .ceui-devtools-dashboard--compact .ceui-signals-panel__item,
1501
+ .ceui-devtools-dashboard--compact .ceui-devtools-dashboard__pill {
1502
+ font-size: 12px;
1503
+ }
1504
+ `;
1505
+ container.appendChild(style);
1506
+ const header = document.createElement("div");
1507
+ header.className = "ceui-devtools-dashboard__header";
1508
+ const title = document.createElement("div");
1509
+ title.className = "ceui-devtools-dashboard__title";
1510
+ title.textContent = "CE UI Devtools";
1511
+ const subtitle = document.createElement("div");
1512
+ subtitle.className = "ceui-devtools-dashboard__subtitle";
1513
+ subtitle.textContent = "Runtime diagnostics and live state";
1514
+ const headerText = document.createElement("div");
1515
+ headerText.append(title, subtitle);
1516
+ header.appendChild(headerText);
1517
+ const refreshedAt = document.createElement("div");
1518
+ refreshedAt.className = "ceui-devtools-dashboard__meta";
1519
+ const controls = document.createElement("div");
1520
+ controls.className = "ceui-devtools-dashboard__controls";
1521
+ let panelsToggleButton = null;
1522
+ let compactMode = Boolean(options.compact);
1523
+ let currentTheme = options.theme ?? "default";
1524
+ container.classList.toggle("ceui-devtools-dashboard--compact", compactMode);
1525
+ container.classList.toggle("ceui-devtools-dashboard--soft", currentTheme === "soft");
1526
+ if (options.showRefresh !== false) {
1527
+ const refreshButton = document.createElement("button");
1528
+ refreshButton.type = "button";
1529
+ refreshButton.className = "ceui-devtools-dashboard__refresh";
1530
+ refreshButton.textContent = "Refresh";
1531
+ refreshButton.addEventListener("click", () => {
1532
+ renderPanels();
1533
+ });
1534
+ controls.appendChild(refreshButton);
1535
+ }
1536
+ if (options.enableSummaryToggle) {
1537
+ const toggleButton = document.createElement("button");
1538
+ toggleButton.type = "button";
1539
+ toggleButton.className = "ceui-devtools-dashboard__toggle";
1540
+ toggleButton.textContent = "Hide summary";
1541
+ toggleButton.addEventListener("click", () => {
1542
+ summaryHidden = !summaryHidden;
1543
+ toggleButton.textContent = summaryHidden ? "Show summary" : "Hide summary";
1544
+ renderPanels();
1545
+ });
1546
+ controls.appendChild(toggleButton);
1547
+ }
1548
+ if (options.enablePanelsToggle) {
1549
+ const panelsButton = document.createElement("button");
1550
+ panelsButton.type = "button";
1551
+ panelsButton.className = "ceui-devtools-dashboard__toggle";
1552
+ panelsButton.textContent = "Collapse panels";
1553
+ panelsButton.addEventListener("click", () => {
1554
+ panelsHidden = !panelsHidden;
1555
+ panelsButton.textContent = panelsHidden ? "Expand panels" : "Collapse panels";
1556
+ renderPanels();
1557
+ });
1558
+ controls.appendChild(panelsButton);
1559
+ panelsToggleButton = panelsButton;
1560
+ }
1561
+ if (options.enableCompactToggle !== false) {
1562
+ const compactButton = document.createElement("button");
1563
+ compactButton.type = "button";
1564
+ compactButton.className = "ceui-devtools-dashboard__toggle";
1565
+ compactButton.textContent = compactMode ? "Compact: on" : "Compact: off";
1566
+ compactButton.addEventListener("click", () => {
1567
+ compactMode = !compactMode;
1568
+ container.classList.toggle("ceui-devtools-dashboard--compact", compactMode);
1569
+ compactButton.textContent = compactMode ? "Compact: on" : "Compact: off";
1570
+ });
1571
+ controls.appendChild(compactButton);
1572
+ }
1573
+ if (options.enableThemeToggle !== false) {
1574
+ const themeButton = document.createElement("button");
1575
+ themeButton.type = "button";
1576
+ themeButton.className = "ceui-devtools-dashboard__toggle";
1577
+ themeButton.textContent = currentTheme === "soft" ? "Theme: soft" : "Theme: default";
1578
+ themeButton.addEventListener("click", () => {
1579
+ currentTheme = currentTheme === "soft" ? "default" : "soft";
1580
+ container.classList.toggle("ceui-devtools-dashboard--soft", currentTheme === "soft");
1581
+ themeButton.textContent = currentTheme === "soft" ? "Theme: soft" : "Theme: default";
1582
+ });
1583
+ controls.appendChild(themeButton);
1584
+ }
1585
+ if (options.enableCopyDiagnostics) {
1586
+ const copyButton = document.createElement("button");
1587
+ copyButton.type = "button";
1588
+ copyButton.className = "ceui-devtools-dashboard__copy";
1589
+ copyButton.textContent = "Copy diagnostics";
1590
+ copyButton.addEventListener("click", async () => {
1591
+ if (!options.diagnosticsStore || typeof navigator === "undefined" || !navigator.clipboard) {
1592
+ return;
1593
+ }
1594
+ try {
1595
+ await navigator.clipboard.writeText(JSON.stringify(options.diagnosticsStore.getSnapshot(), null, 2));
1596
+ copyButton.textContent = "Copied";
1597
+ setTimeout(() => {
1598
+ copyButton.textContent = "Copy diagnostics";
1599
+ }, 1500);
1600
+ } catch {
1601
+ copyButton.textContent = "Copy failed";
1602
+ setTimeout(() => {
1603
+ copyButton.textContent = "Copy diagnostics";
1604
+ }, 1500);
1605
+ }
1606
+ });
1607
+ controls.appendChild(copyButton);
1608
+ }
1609
+ if (options.enableClearDiagnostics) {
1610
+ const clearButton = document.createElement("button");
1611
+ clearButton.type = "button";
1612
+ clearButton.className = "ceui-devtools-dashboard__clear";
1613
+ clearButton.textContent = "Clear diagnostics";
1614
+ clearButton.addEventListener("click", () => {
1615
+ options.diagnosticsStore?.clearReports();
1616
+ renderPanels();
1617
+ });
1618
+ controls.appendChild(clearButton);
1619
+ }
1620
+ if (options.enableExportDiagnostics) {
1621
+ const exportButton = document.createElement("button");
1622
+ exportButton.type = "button";
1623
+ exportButton.className = "ceui-devtools-dashboard__export";
1624
+ exportButton.textContent = "Export diagnostics";
1625
+ exportButton.addEventListener("click", () => {
1626
+ if (!options.diagnosticsStore || typeof document === "undefined") {
1627
+ return;
1628
+ }
1629
+ const snapshot = options.diagnosticsStore.getSnapshot();
1630
+ const json = JSON.stringify(snapshot, null, 2);
1631
+ const blob = new Blob([json], { type: "application/json" });
1632
+ const url = URL.createObjectURL(blob);
1633
+ const anchor = document.createElement("a");
1634
+ anchor.href = url;
1635
+ anchor.download = `ce-ui-diagnostics-${Date.now()}.json`;
1636
+ anchor.click();
1637
+ URL.revokeObjectURL(url);
1638
+ });
1639
+ controls.appendChild(exportButton);
1640
+ }
1641
+ if (options.enableResetPanels) {
1642
+ const resetButton = document.createElement("button");
1643
+ resetButton.type = "button";
1644
+ resetButton.className = "ceui-devtools-dashboard__toggle";
1645
+ resetButton.textContent = "Reset panels";
1646
+ resetButton.addEventListener("click", () => {
1647
+ panelsHidden = false;
1648
+ if (panelsToggleButton) {
1649
+ panelsToggleButton.textContent = "Collapse panels";
1650
+ }
1651
+ renderPanels();
1652
+ });
1653
+ controls.appendChild(resetButton);
1654
+ }
1655
+ header.append(refreshedAt, controls);
1656
+ const summary = document.createElement("div");
1657
+ summary.className = "ceui-devtools-dashboard__summary";
1658
+ const panels = document.createElement("div");
1659
+ panels.className = "ceui-devtools-dashboard__panels";
1660
+ const footer = document.createElement("div");
1661
+ footer.className = "ceui-devtools-dashboard__footer";
1662
+ const phasePanel = document.createElement("div");
1663
+ phasePanel.className = "ceui-devtools-dashboard__phase";
1664
+ let summaryHidden = false;
1665
+ let panelsHidden = false;
1666
+ const renderPanels = () => {
1667
+ while (panels.firstChild) {
1668
+ panels.removeChild(panels.firstChild);
1669
+ }
1670
+ while (summary.firstChild) {
1671
+ summary.removeChild(summary.firstChild);
1672
+ }
1673
+ refreshedAt.textContent = `Refreshed: ${(/* @__PURE__ */ new Date()).toLocaleTimeString()}`;
1674
+ if (!summaryHidden && options.showSummary !== false) {
1675
+ buildSummary(options, summary);
1676
+ }
1677
+ panels.classList.toggle("ceui-devtools-dashboard__panels--hidden", panelsHidden);
1678
+ footer.textContent = `Runtime reports: ${options.diagnosticsStore ? options.diagnosticsStore.reports().length : 0}`;
1679
+ renderPhasePanel(options, phasePanel);
1680
+ if (panelsHidden) {
1681
+ return;
1682
+ }
1683
+ if (options.routerInspector) {
1684
+ panels.appendChild(createRouterInspectorPanel(options.routerInspector));
1685
+ }
1686
+ const signalsPanel = createSignalsInspectorPanel({ snapshot: options.signalsSnapshot });
1687
+ panels.appendChild(signalsPanel);
1688
+ const hydrationReport = resolveHydrationReport(options);
1689
+ if (hydrationReport) {
1690
+ panels.appendChild(createHydrationReplayPanel(hydrationReport));
1691
+ } else {
1692
+ const empty = document.createElement("div");
1693
+ empty.className = "ceui-devtools-dashboard__empty";
1694
+ empty.textContent = "No hydration mismatch reports available.";
1695
+ panels.appendChild(empty);
1696
+ }
1697
+ };
1698
+ renderPanels();
1699
+ container.append(header, summary, panels, phasePanel, footer);
1700
+ return container;
1701
+ }
1702
+ function resolveHydrationReport(options) {
1703
+ if (options.hydrationReport) {
1704
+ return options.hydrationReport;
1705
+ }
1706
+ if (options.diagnosticsStore) {
1707
+ const reports = getHydrationReports(options.diagnosticsStore.reports());
1708
+ return reports[0];
1709
+ }
1710
+ return void 0;
1711
+ }
1712
+ function buildSummary(options, summary) {
1713
+ const signalsSnapshot = options.signalsSnapshot ?? createSignalsInspector().refresh();
1714
+ const signalsCount = signalsSnapshot.signals.length;
1715
+ const effectsCount = signalsSnapshot.effects.length;
1716
+ const hydrationReports = options.diagnosticsStore ? getHydrationReports(options.diagnosticsStore.reports()) : [];
1717
+ const hydrationCount = hydrationReports.length;
1718
+ const lastHydration = hydrationReports.slice().sort((a, b) => resolveHydrationTimestampValue(b) - resolveHydrationTimestampValue(a))[0];
1719
+ const reportsByPhase = options.diagnosticsStore ? countReportsByPhase(options.diagnosticsStore) : /* @__PURE__ */ new Map();
1720
+ const routeSummary = options.routerInspector?.getSnapshot();
1721
+ if (routeSummary && options.showRouterSummary !== false) {
1722
+ summary.appendChild(
1723
+ buildSummaryPill(`Route: ${routeSummary.currentPath || "/"} (${routeSummary.currentMatch?.route.id ?? "unknown"})`)
1724
+ );
1725
+ }
1726
+ summary.appendChild(buildSummaryPill(`Signals: ${signalsCount}`));
1727
+ summary.appendChild(buildSummaryPill(`Effects: ${effectsCount}`));
1728
+ summary.appendChild(buildSummaryPill(`Signals refreshed: ${(/* @__PURE__ */ new Date()).toLocaleTimeString()}`));
1729
+ summary.appendChild(buildSummaryPill(`Hydration: ${hydrationCount}`));
1730
+ if (reportsByPhase.size) {
1731
+ const formatted = formatPhaseCounts(reportsByPhase);
1732
+ const pill = buildSummaryPill(`Reports: ${formatted}`);
1733
+ pill.title = formatted;
1734
+ summary.appendChild(pill);
1735
+ }
1736
+ if (lastHydration) {
1737
+ const timestampLabel = resolveHydrationTimestamp(lastHydration);
1738
+ summary.appendChild(buildSummaryPill(`Last hydration: ${timestampLabel}`));
1739
+ if (options.showHydrationTemplate !== false) {
1740
+ summary.appendChild(buildSummaryPill(`Hydration template: ${lastHydration.info.templateId ?? "unknown"}`));
1741
+ }
1742
+ }
1743
+ }
1744
+ function buildSummaryPill(text) {
1745
+ const pill = document.createElement("div");
1746
+ pill.className = "ceui-devtools-dashboard__pill";
1747
+ pill.textContent = text;
1748
+ return pill;
1749
+ }
1750
+ function resolveHydrationTimestamp(report) {
1751
+ const timestamp = resolveHydrationTimestampValue(report);
1752
+ return timestamp ? new Date(timestamp).toLocaleTimeString() : "unknown";
1753
+ }
1754
+ function resolveHydrationTimestampValue(report) {
1755
+ const timestamp = report.info.attributes?.timestamp;
1756
+ return typeof timestamp === "number" ? timestamp : 0;
1757
+ }
1758
+ function countReportsByPhase(store) {
1759
+ const counts = /* @__PURE__ */ new Map();
1760
+ store.reports().forEach((report) => {
1761
+ const phase = report.info.phase ?? "unknown";
1762
+ counts.set(phase, (counts.get(phase) ?? 0) + 1);
1763
+ });
1764
+ return counts;
1765
+ }
1766
+ function formatPhaseCounts(counts) {
1767
+ return Array.from(counts.entries()).sort((a, b) => a[0].localeCompare(b[0])).map(([phase, count]) => `${phase}:${count}`).join(" \xB7 ");
1768
+ }
1769
+ function renderPhasePanel(options, panel) {
1770
+ panel.replaceChildren();
1771
+ const title = document.createElement("div");
1772
+ title.className = "ceui-devtools-dashboard__phase-title";
1773
+ title.textContent = "Reports by phase";
1774
+ panel.appendChild(title);
1775
+ const counts = options.diagnosticsStore ? countReportsByPhase(options.diagnosticsStore) : /* @__PURE__ */ new Map();
1776
+ if (!counts.size) {
1777
+ const empty = document.createElement("div");
1778
+ empty.textContent = "No reports captured.";
1779
+ panel.appendChild(empty);
1780
+ return;
1781
+ }
1782
+ const list = document.createElement("div");
1783
+ list.textContent = formatPhaseCounts(counts);
1784
+ panel.appendChild(list);
1785
+ }
1786
+
1787
+ // src/runtime/devtools/router-inspector.js
1788
+ function buildRouteTree(routes, parentPath = "") {
1789
+ return routes.map((route) => {
1790
+ const fullPath = chunkZWUA2LPB_cjs.normalizePath(parentPath, route.path);
1791
+ return {
1792
+ id: route.id ?? route.path,
1793
+ path: route.path,
1794
+ fullPath,
1795
+ hasLoader: Boolean(route.loader),
1796
+ hasAction: Boolean(route.action),
1797
+ hasGuards: Boolean(route.guards?.length),
1798
+ children: buildRouteTree(route.children ?? [], fullPath),
1799
+ isActive: false
1800
+ };
1801
+ });
1802
+ }
1803
+ function createRouterInspector(router, routes) {
1804
+ const baseTree = buildRouteTree(routes);
1805
+ const tree = chunkVHUXNDW2_cjs.computed(() => {
1806
+ const activePath = router.currentMatch()?.fullPath ?? router.currentPath();
1807
+ return markActiveRoutes(baseTree, activePath);
1808
+ });
1809
+ const inspector = {
1810
+ tree,
1811
+ currentPath: router.currentPath,
1812
+ currentMatch: router.currentMatch,
1813
+ getSnapshot() {
1814
+ return {
1815
+ currentPath: router.currentPath(),
1816
+ currentMatch: router.currentMatch(),
1817
+ tree: tree(),
1818
+ routeData: inspector.getRouteDataSnapshot()
1819
+ };
1820
+ },
1821
+ getRouteDataSnapshot() {
1822
+ const store = chunkEFOOXCY7_cjs.getRouteDataStore()();
1823
+ return Object.fromEntries(store.entries());
1824
+ }
1825
+ };
1826
+ return inspector;
1827
+ }
1828
+ function markActiveRoutes(nodes, activePath) {
1829
+ return nodes.map((node) => ({
1830
+ ...node,
1831
+ isActive: isPathActive(node.fullPath, activePath),
1832
+ children: markActiveRoutes(node.children, activePath)
1833
+ }));
1834
+ }
1835
+ function isPathActive(routePath, activePath) {
1836
+ if (routePath === "/") {
1837
+ return true;
1838
+ }
1839
+ if (activePath === routePath) {
1840
+ return true;
1841
+ }
1842
+ return activePath.startsWith(`${routePath}/`);
1843
+ }
1844
+
1845
+ // src/runtime/adapters/angular.js
1846
+ function createAngularAdapter(factory, options = {}) {
1847
+ var _a;
1848
+ return _a = class CeAngularBridge {
1849
+ constructor(host) {
1850
+ this.host = host;
1851
+ this.props = {};
1852
+ }
1853
+ setInput(key, value) {
1854
+ this.props = { ...this.props, [key]: value };
1855
+ const patch = { [key]: value };
1856
+ this.instance?.updateProps(patch);
1857
+ }
1858
+ ngOnInit() {
1859
+ this.instance = factory.mount({
1860
+ target: this.host.nativeElement,
1861
+ props: this.props
1862
+ });
1863
+ }
1864
+ ngOnChanges(changes) {
1865
+ if (!this.instance) {
1866
+ return;
1867
+ }
1868
+ const next = {};
1869
+ Object.keys(changes).forEach((key) => {
1870
+ const change = changes[key];
1871
+ if (change) {
1872
+ next[key] = change.currentValue;
1873
+ }
1874
+ });
1875
+ if (Object.keys(next).length) {
1876
+ this.instance.updateProps(next);
1877
+ }
1878
+ }
1879
+ ngOnDestroy() {
1880
+ this.instance?.destroy();
1881
+ }
1882
+ }, _a.selector = options.selector, _a.inputs = options.inputs ?? [], _a;
1883
+ }
1884
+
1885
+ // src/runtime/adapters/react.js
1886
+ function createReactAdapter(factory, react, options = {}) {
1887
+ const hostTag = options.hostElement ?? "div";
1888
+ const Adapter = (props) => {
1889
+ const hostRef = react.useRef(null);
1890
+ const instanceRef = react.useRef(null);
1891
+ react.useEffect(() => {
1892
+ if (!hostRef.current) {
1893
+ return void 0;
1894
+ }
1895
+ instanceRef.current = factory.mount({
1896
+ target: hostRef.current,
1897
+ props
1898
+ });
1899
+ return () => {
1900
+ instanceRef.current?.destroy();
1901
+ instanceRef.current = null;
1902
+ };
1903
+ }, []);
1904
+ react.useEffect(() => {
1905
+ if (instanceRef.current) {
1906
+ instanceRef.current.updateProps(props);
1907
+ }
1908
+ return void 0;
1909
+ }, [props]);
1910
+ const refCallback = (node) => {
1911
+ hostRef.current = node;
1912
+ };
1913
+ return react.createElement(hostTag, { ref: refCallback }, props.children ?? null);
1914
+ };
1915
+ if (options.displayName) {
1916
+ Adapter.displayName = options.displayName;
1917
+ }
1918
+ return Adapter;
1919
+ }
1920
+
1921
+ // src/runtime/adapters/vue.js
1922
+ function createVueAdapter(factory, vue, options = {}) {
1923
+ const hostTag = options.hostElement ?? "div";
1924
+ const component = {
1925
+ name: options.displayName,
1926
+ setup(props, ctx) {
1927
+ const hostRef = vue.ref(null);
1928
+ let instance = null;
1929
+ vue.onMounted(() => {
1930
+ if (!hostRef.value) {
1931
+ return;
1932
+ }
1933
+ instance = factory.mount({
1934
+ target: hostRef.value,
1935
+ props
1936
+ });
1937
+ });
1938
+ vue.watch(() => props, (next) => {
1939
+ if (instance) {
1940
+ instance.updateProps(next);
1941
+ }
1942
+ }, { deep: true });
1943
+ vue.onBeforeUnmount(() => {
1944
+ instance?.destroy();
1945
+ instance = null;
1946
+ });
1947
+ return () => vue.h(hostTag, { ref: hostRef }, ctx?.slots?.default ? ctx.slots.default() : null);
1948
+ }
1949
+ };
1950
+ return component;
1951
+ }
1952
+
1953
+ exports.buildHydrationDomDiff = buildHydrationDomDiff;
1954
+ exports.buildHydrationSummary = buildHydrationSummary;
1955
+ exports.buildRouteTree = buildRouteTree;
1956
+ exports.buildSignalsGraph = buildSignalsGraph;
1957
+ exports.calculateRetryDelay = calculateRetryDelay;
1958
+ exports.classifyError = classifyError;
1959
+ exports.createAiSession = createAiSession;
1960
+ exports.createAngularAdapter = createAngularAdapter;
1961
+ exports.createDevtoolsDashboard = createDevtoolsDashboard;
1962
+ exports.createFormController = createFormController;
1963
+ exports.createFormWizard = createFormWizard;
1964
+ exports.createHttpAiProvider = createHttpAiProvider;
1965
+ exports.createHydrationReplayPanel = createHydrationReplayPanel;
1966
+ exports.createHydrationReplaySession = createHydrationReplaySession;
1967
+ exports.createMockAiProvider = createMockAiProvider;
1968
+ exports.createReactAdapter = createReactAdapter;
1969
+ exports.createResource = createResource;
1970
+ exports.createResourceCache = createResourceCache;
1971
+ exports.createRouterInspector = createRouterInspector;
1972
+ exports.createRouterInspectorPanel = createRouterInspectorPanel;
1973
+ exports.createRuntimeDiagnosticsStore = createRuntimeDiagnosticsStore;
1974
+ exports.createSignalsInspector = createSignalsInspector;
1975
+ exports.createSignalsInspectorPanel = createSignalsInspectorPanel;
1976
+ exports.createVueAdapter = createVueAdapter;
1977
+ exports.getHydrationDomPayload = getHydrationDomPayload;
1978
+ exports.getHydrationReports = getHydrationReports;
1979
+ exports.getResourceCache = getResourceCache;
1980
+ exports.invalidateResource = invalidateResource;
1981
+ exports.isResourceExpired = isResourceExpired;
1982
+ exports.isResourceStale = isResourceStale;
1983
+ exports.normalizeResourceKey = normalizeResourceKey;
1984
+ //# sourceMappingURL=chunk-QPAAV32J.cjs.map
1985
+ //# sourceMappingURL=chunk-QPAAV32J.cjs.map