@jasonshimmy/custom-elements-runtime 2.5.2 → 2.5.5

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 (94) hide show
  1. package/README.md +115 -40
  2. package/dist/css/colors.d.ts +14 -0
  3. package/dist/custom-elements-runtime.cjs.js +6 -1
  4. package/dist/custom-elements-runtime.cjs.js.map +1 -1
  5. package/dist/custom-elements-runtime.colors.cjs.js +2 -0
  6. package/dist/custom-elements-runtime.colors.cjs.js.map +1 -0
  7. package/dist/custom-elements-runtime.colors.es.js +279 -0
  8. package/dist/custom-elements-runtime.colors.es.js.map +1 -0
  9. package/dist/custom-elements-runtime.directive-enhancements.es.js +1 -1
  10. package/dist/custom-elements-runtime.es.js +258 -166
  11. package/dist/custom-elements-runtime.es.js.map +1 -1
  12. package/dist/custom-elements-runtime.event-bus.cjs.js +1 -1
  13. package/dist/custom-elements-runtime.event-bus.cjs.js.map +1 -1
  14. package/dist/custom-elements-runtime.event-bus.es.js +28 -25
  15. package/dist/custom-elements-runtime.event-bus.es.js.map +1 -1
  16. package/dist/custom-elements-runtime.router.cjs.js +20 -20
  17. package/dist/custom-elements-runtime.router.cjs.js.map +1 -1
  18. package/dist/custom-elements-runtime.router.es.js +549 -531
  19. package/dist/custom-elements-runtime.router.es.js.map +1 -1
  20. package/dist/custom-elements-runtime.ssr.cjs.js +1 -1
  21. package/dist/custom-elements-runtime.ssr.es.js +12 -8
  22. package/dist/custom-elements-runtime.ssr.es.js.map +1 -1
  23. package/dist/custom-elements-runtime.store.cjs.js +1 -1
  24. package/dist/custom-elements-runtime.store.cjs.js.map +1 -1
  25. package/dist/custom-elements-runtime.store.es.js +5 -5
  26. package/dist/custom-elements-runtime.store.es.js.map +1 -1
  27. package/dist/custom-elements-runtime.transitions.cjs.js +1 -1
  28. package/dist/custom-elements-runtime.transitions.es.js +1 -1
  29. package/dist/event-bus.d.ts +17 -4
  30. package/dist/index.d.ts +13 -5
  31. package/dist/keep-alive.d.ts +50 -0
  32. package/dist/{logger-BuUYv7C_.js → logger-BvkEbVM4.js} +15 -11
  33. package/dist/logger-BvkEbVM4.js.map +1 -0
  34. package/dist/logger-CSALKaYm.cjs +2 -0
  35. package/dist/logger-CSALKaYm.cjs.map +1 -0
  36. package/dist/namespace-helpers-4qeKVqQw.cjs +5 -0
  37. package/dist/namespace-helpers-4qeKVqQw.cjs.map +1 -0
  38. package/dist/namespace-helpers-DcD_6_K1.js +989 -0
  39. package/dist/namespace-helpers-DcD_6_K1.js.map +1 -0
  40. package/dist/router/active-proxy.d.ts +5 -0
  41. package/dist/router/component-loader.d.ts +11 -0
  42. package/dist/router/instance.d.ts +11 -0
  43. package/dist/router/matcher.d.ts +14 -0
  44. package/dist/router/path-utils.d.ts +48 -0
  45. package/dist/router/types.d.ts +134 -0
  46. package/dist/router.d.ts +6 -208
  47. package/dist/runtime/builtin-components.d.ts +78 -0
  48. package/dist/runtime/component/element-class.d.ts +4 -0
  49. package/dist/runtime/component/factory.d.ts +39 -0
  50. package/dist/runtime/component/registry.d.ts +16 -0
  51. package/dist/runtime/component.d.ts +3 -50
  52. package/dist/runtime/discovery-state.d.ts +30 -0
  53. package/dist/runtime/hooks.d.ts +115 -0
  54. package/dist/runtime/logger.d.ts +19 -1
  55. package/dist/runtime/monitoring/health-monitor.d.ts +22 -65
  56. package/dist/runtime/reactive.d.ts +39 -7
  57. package/dist/runtime/render.d.ts +20 -4
  58. package/dist/runtime/scheduler.d.ts +69 -2
  59. package/dist/runtime/template-compiler/impl.d.ts +14 -0
  60. package/dist/runtime/template-compiler/lru-cache.d.ts +20 -0
  61. package/dist/runtime/template-compiler/props-parser.d.ts +15 -0
  62. package/dist/runtime/template-compiler/vnode-utils.d.ts +5 -0
  63. package/dist/runtime/template-compiler.d.ts +5 -28
  64. package/dist/runtime/types.d.ts +10 -0
  65. package/dist/runtime/vdom-directives.d.ts +71 -0
  66. package/dist/runtime/vdom-helpers.d.ts +126 -0
  67. package/dist/runtime/vdom-patch.d.ts +67 -0
  68. package/dist/runtime/vdom.d.ts +16 -140
  69. package/dist/ssr.d.ts +2 -1
  70. package/dist/teleport.d.ts +68 -0
  71. package/dist/template-compiler-CA4YRaBu.cjs +23 -0
  72. package/dist/template-compiler-CA4YRaBu.cjs.map +1 -0
  73. package/dist/template-compiler-CJFwjLCP.js +3981 -0
  74. package/dist/template-compiler-CJFwjLCP.js.map +1 -0
  75. package/dist/transitions-DPZiuXb9.cjs +330 -0
  76. package/dist/transitions-DPZiuXb9.cjs.map +1 -0
  77. package/dist/{transitions-Bx0Nc9zR.js → transitions-Di5wW9yc.js} +1072 -632
  78. package/dist/transitions-Di5wW9yc.js.map +1 -0
  79. package/dist/transitions.d.ts +1 -1
  80. package/package.json +18 -11
  81. package/dist/logger-BuUYv7C_.js.map +0 -1
  82. package/dist/logger-DiXdWaF-.cjs +0 -2
  83. package/dist/logger-DiXdWaF-.cjs.map +0 -1
  84. package/dist/namespace-helpers-BCVTzhAO.cjs +0 -5
  85. package/dist/namespace-helpers-BCVTzhAO.cjs.map +0 -1
  86. package/dist/namespace-helpers-CF28TyaG.js +0 -786
  87. package/dist/namespace-helpers-CF28TyaG.js.map +0 -1
  88. package/dist/template-compiler-CXHEnaBh.cjs +0 -17
  89. package/dist/template-compiler-CXHEnaBh.cjs.map +0 -1
  90. package/dist/template-compiler-DD_VZrte.js +0 -3729
  91. package/dist/template-compiler-DD_VZrte.js.map +0 -1
  92. package/dist/transitions-Bx0Nc9zR.js.map +0 -1
  93. package/dist/transitions-DfcqL-X4.cjs +0 -302
  94. package/dist/transitions-DfcqL-X4.cjs.map +0 -1
@@ -0,0 +1,989 @@
1
+ import { d as E, a as y } from "./logger-BvkEbVM4.js";
2
+ function x() {
3
+ const s = (() => {
4
+ try {
5
+ return globalThis.process?.env?.NODE_ENV;
6
+ } catch {
7
+ return;
8
+ }
9
+ })(), e = (() => {
10
+ try {
11
+ if (typeof window > "u")
12
+ return { vitest: !1, cypress: !1 };
13
+ const n = window;
14
+ return {
15
+ vitest: !!n.__vitest__,
16
+ cypress: !!n.Cypress
17
+ };
18
+ } catch {
19
+ return { vitest: !1, cypress: !1 };
20
+ }
21
+ })();
22
+ return {
23
+ isTest: s === "test" || e.vitest || e.cypress,
24
+ isVitest: e.vitest,
25
+ isCypress: e.cypress
26
+ };
27
+ }
28
+ class H {
29
+ pendingUpdates = /* @__PURE__ */ new Map();
30
+ isFlushScheduled = !1;
31
+ isFlushing = !1;
32
+ testEnv;
33
+ lastCleanup = 0;
34
+ CLEANUP_INTERVAL = 300 * 1e3;
35
+ // 5 minutes
36
+ MAX_PENDING_SIZE = 1e4;
37
+ // Prevent memory bloat
38
+ // Idle / time-sliced priority support
39
+ pendingIdleUpdates = /* @__PURE__ */ new Map();
40
+ idleCallbackHandle = null;
41
+ constructor() {
42
+ this.testEnv = x(), this.schedulePeriodicCleanup();
43
+ }
44
+ /**
45
+ * Schedule an update to be executed in the next microtask
46
+ * Uses component identity to deduplicate multiple render requests for the same component
47
+ */
48
+ schedule(e, t) {
49
+ const n = t || e;
50
+ this.pendingUpdates.size >= this.MAX_PENDING_SIZE && this.performEmergencyCleanup(), this.pendingUpdates.set(n, e), this.isFlushScheduled || this.scheduleFlush();
51
+ }
52
+ /**
53
+ * Schedule the flush operation based on environment
54
+ */
55
+ scheduleFlush() {
56
+ this.isFlushScheduled = !0, this.testEnv.isTest && !this.isFlushing ? this.flush() : queueMicrotask(() => this.flush());
57
+ }
58
+ /**
59
+ * Execute all pending updates with priority ordering
60
+ * Execute all pending updates with priority ordering
61
+ */
62
+ flush() {
63
+ if (this.isFlushing)
64
+ return;
65
+ this.isFlushing = !0;
66
+ const e = this.pendingUpdates;
67
+ this.pendingUpdates = /* @__PURE__ */ new Map(), this.isFlushScheduled = !1;
68
+ try {
69
+ for (const t of e.values())
70
+ try {
71
+ t();
72
+ } catch (n) {
73
+ E("Error in batched update:", n);
74
+ }
75
+ } finally {
76
+ this.isFlushing = !1;
77
+ }
78
+ }
79
+ /**
80
+ * Force flush any pending DOM updates immediately. This is useful in
81
+ * test environments or callers that require synchronous guarantees after
82
+ * state changes. Prefer relying on the scheduler's automatic flush when
83
+ * possible; use this only when a caller needs to synchronously observe
84
+ * rendered DOM changes.
85
+ */
86
+ flushImmediately() {
87
+ this.pendingUpdates.size !== 0 && (this.isFlushScheduled = !1, this.flush());
88
+ }
89
+ /**
90
+ * Get the number of pending updates
91
+ */
92
+ get pendingCount() {
93
+ return this.pendingUpdates.size;
94
+ }
95
+ /**
96
+ * Check if there are pending updates
97
+ */
98
+ get hasPendingUpdates() {
99
+ return this.pendingUpdates.size > 0;
100
+ }
101
+ /**
102
+ * Check if currently flushing updates
103
+ */
104
+ get isFlushingUpdates() {
105
+ return this.isFlushing;
106
+ }
107
+ /**
108
+ * Schedule periodic cleanup to prevent memory leaks
109
+ */
110
+ schedulePeriodicCleanup() {
111
+ if (this.testEnv.isTest) return;
112
+ const e = () => {
113
+ this.performPeriodicCleanup(), this.testEnv.isTest || setTimeout(e, this.CLEANUP_INTERVAL);
114
+ };
115
+ setTimeout(e, this.CLEANUP_INTERVAL);
116
+ }
117
+ /**
118
+ * Perform periodic cleanup of stale entries
119
+ */
120
+ performPeriodicCleanup() {
121
+ const e = Date.now();
122
+ e - this.lastCleanup < this.CLEANUP_INTERVAL || (this.pendingUpdates.size > 100 && y(
123
+ `Scheduler has ${this.pendingUpdates.size} pending updates. Consider investigating.`
124
+ ), this.lastCleanup = e);
125
+ }
126
+ /**
127
+ * Emergency cleanup when pending updates exceed safe limits
128
+ */
129
+ performEmergencyCleanup() {
130
+ y(
131
+ "Scheduler emergency cleanup: too many pending updates, clearing oldest entries"
132
+ );
133
+ const e = Array.from(this.pendingUpdates.entries()), t = Math.floor(e.length / 2);
134
+ for (let n = 0; n < t; n++)
135
+ this.pendingUpdates.delete(e[n][0]);
136
+ }
137
+ /**
138
+ * Schedule an update with an explicit priority level.
139
+ *
140
+ * - `'immediate'` — Runs synchronously before returning.
141
+ * - `'normal'` — Default microtask batching (same as `schedule()`).
142
+ * - `'idle'` — Deferred to browser idle time via `requestIdleCallback`
143
+ * with time-slicing to avoid blocking the main thread.
144
+ * Falls back to a 5 ms `setTimeout` when
145
+ * `requestIdleCallback` is unavailable (e.g. Safari < 16).
146
+ *
147
+ * @example Defer a low-priority analytics flush
148
+ * ```ts
149
+ * scheduleWithPriority(() => flushAnalytics(), 'idle');
150
+ * ```
151
+ */
152
+ scheduleWithPriority(e, t = "normal", n) {
153
+ if (t === "immediate") {
154
+ try {
155
+ e();
156
+ } catch (i) {
157
+ E("Error in immediate update:", i);
158
+ }
159
+ return;
160
+ }
161
+ if (t === "idle") {
162
+ const i = n ?? e;
163
+ this.pendingIdleUpdates.size >= this.MAX_PENDING_SIZE && this.performEmergencyCleanup(), this.pendingIdleUpdates.set(i, e), this.scheduleIdleFlush();
164
+ return;
165
+ }
166
+ const r = n ?? e;
167
+ this.pendingUpdates.size >= this.MAX_PENDING_SIZE && this.performEmergencyCleanup(), this.pendingUpdates.set(r, e), this.isFlushScheduled || (this.isFlushScheduled = !0, queueMicrotask(() => this.flush()));
168
+ }
169
+ /**
170
+ * Schedule a flush of idle-priority updates.
171
+ * Uses `requestIdleCallback` when available; falls back to a short `setTimeout`.
172
+ */
173
+ scheduleIdleFlush() {
174
+ if (this.idleCallbackHandle === null) {
175
+ if (this.testEnv.isTest) {
176
+ this.idleCallbackHandle = setTimeout(() => {
177
+ this.idleCallbackHandle = null, this.flushIdleUpdates(null);
178
+ }, 0);
179
+ return;
180
+ }
181
+ if (typeof requestIdleCallback < "u") {
182
+ const e = requestIdleCallback(
183
+ (t) => {
184
+ this.idleCallbackHandle = null, this.flushIdleUpdates(t);
185
+ },
186
+ { timeout: 2e3 }
187
+ );
188
+ this.idleCallbackHandle = e;
189
+ } else
190
+ this.idleCallbackHandle = setTimeout(() => {
191
+ this.idleCallbackHandle = null;
192
+ const e = Date.now();
193
+ this.flushIdleUpdates({
194
+ timeRemaining: () => Math.max(0, 50 - (Date.now() - e)),
195
+ didTimeout: !1
196
+ });
197
+ }, 5);
198
+ }
199
+ }
200
+ /**
201
+ * Process pending idle-priority updates in a time-sliced manner.
202
+ * Yields back to the browser when the deadline's `timeRemaining()` reaches
203
+ * zero and reschedules any unprocessed work.
204
+ */
205
+ flushIdleUpdates(e) {
206
+ const t = Array.from(this.pendingIdleUpdates.entries());
207
+ this.pendingIdleUpdates = /* @__PURE__ */ new Map();
208
+ for (let n = 0; n < t.length; n++) {
209
+ if (e && !e.didTimeout && e.timeRemaining() <= 0) {
210
+ for (let r = n; r < t.length; r++)
211
+ this.pendingIdleUpdates.set(t[r][0], t[r][1]);
212
+ this.scheduleIdleFlush();
213
+ return;
214
+ }
215
+ try {
216
+ t[n][1]();
217
+ } catch (r) {
218
+ E("Error in idle update:", r);
219
+ }
220
+ }
221
+ }
222
+ }
223
+ const h = new H();
224
+ function R(s, e) {
225
+ h.schedule(s, e);
226
+ }
227
+ function V(s, e = "normal", t) {
228
+ h.scheduleWithPriority(s, e, t);
229
+ }
230
+ function q() {
231
+ h.flushImmediately();
232
+ }
233
+ function $() {
234
+ return new Promise((s) => {
235
+ h.hasPendingUpdates && h.flushImmediately(), queueMicrotask(s);
236
+ });
237
+ }
238
+ const _ = /* @__PURE__ */ new WeakSet();
239
+ class L {
240
+ static cache = /* @__PURE__ */ new WeakMap();
241
+ static arrayHandlerCache = /* @__PURE__ */ new WeakMap();
242
+ static objectHandlerCache = /* @__PURE__ */ new WeakMap();
243
+ /**
244
+ * Get or create a reactive proxy for an object
245
+ */
246
+ static getOrCreateProxy(e, t, n = !1) {
247
+ const r = this.cache.get(e);
248
+ if (r)
249
+ return r;
250
+ const i = n ? this.getOrCreateArrayHandler(t) : this.getOrCreateObjectHandler(t), a = new Proxy(e, i);
251
+ try {
252
+ v.markAsProxy(a);
253
+ } catch {
254
+ }
255
+ return this.cache.set(e, a), a;
256
+ }
257
+ /**
258
+ * Get or create a cached array handler
259
+ */
260
+ static getOrCreateArrayHandler(e) {
261
+ if (!this.arrayHandlerCache.has(e)) {
262
+ const t = {
263
+ get: (n, r, i) => {
264
+ const a = Reflect.get(n, r, i);
265
+ return typeof a == "function" && typeof r == "string" && [
266
+ "push",
267
+ "pop",
268
+ "shift",
269
+ "unshift",
270
+ "splice",
271
+ "sort",
272
+ "reverse",
273
+ "fill",
274
+ "copyWithin"
275
+ ].includes(r) ? function(...u) {
276
+ const d = a.apply(n, u);
277
+ return e.triggerUpdate(), d;
278
+ } : a !== null && typeof a == "object" && typeof r == "string" ? e.makeReactiveValue(a) : a;
279
+ },
280
+ set: (n, r, i) => (n[r] = e.makeReactiveValue(i), e.triggerUpdate(), !0),
281
+ deleteProperty: (n, r) => (delete n[r], e.triggerUpdate(), !0)
282
+ };
283
+ this.arrayHandlerCache.set(e, t);
284
+ }
285
+ return this.arrayHandlerCache.get(e);
286
+ }
287
+ /**
288
+ * Get or create a cached object handler
289
+ */
290
+ static getOrCreateObjectHandler(e) {
291
+ if (!this.objectHandlerCache.has(e)) {
292
+ const t = {
293
+ get: (n, r, i) => {
294
+ const a = Reflect.get(n, r, i);
295
+ return a !== null && typeof a == "object" && typeof r == "string" ? e.makeReactiveValue(a) : a;
296
+ },
297
+ set: (n, r, i) => (n[r] = e.makeReactiveValue(i), e.triggerUpdate(), !0),
298
+ deleteProperty: (n, r) => (delete n[r], e.triggerUpdate(), !0)
299
+ };
300
+ this.objectHandlerCache.set(e, t);
301
+ }
302
+ return this.objectHandlerCache.get(e);
303
+ }
304
+ /**
305
+ * Check if an object already has a cached proxy
306
+ */
307
+ static hasProxy(e) {
308
+ return this.cache.has(e);
309
+ }
310
+ /**
311
+ * Clear all cached proxies (useful for testing)
312
+ */
313
+ static clear() {
314
+ this.cache = /* @__PURE__ */ new WeakMap(), this.arrayHandlerCache = /* @__PURE__ */ new WeakMap(), this.objectHandlerCache = /* @__PURE__ */ new WeakMap();
315
+ }
316
+ /**
317
+ * Get cache statistics (for debugging)
318
+ * Note: WeakMap doesn't provide size, so this is limited
319
+ */
320
+ static getStats() {
321
+ return {
322
+ hasCachedProxies: this.cache instanceof WeakMap
323
+ };
324
+ }
325
+ }
326
+ class v {
327
+ // Cache a stable reactiveContext object keyed by onUpdate -> makeReactive
328
+ // This allows handler caches in ReactiveProxyCache to reuse handlers
329
+ // for identical reactive contexts instead of creating a new context object
330
+ // on each createReactiveProxy call.
331
+ static contextCache = /* @__PURE__ */ new WeakMap();
332
+ /**
333
+ * Create an optimized reactive proxy with minimal overhead
334
+ */
335
+ static createReactiveProxy(e, t, n) {
336
+ try {
337
+ if (_.has(e)) return e;
338
+ } catch {
339
+ }
340
+ const r = Array.isArray(e);
341
+ let i = this.contextCache.get(t);
342
+ i || (i = /* @__PURE__ */ new WeakMap(), this.contextCache.set(t, i));
343
+ let a = i.get(n);
344
+ return a || (a = {
345
+ triggerUpdate: t,
346
+ makeReactiveValue: n
347
+ }, i.set(n, a)), L.getOrCreateProxy(e, a, r);
348
+ }
349
+ /**
350
+ * Mark an object as a proxy (for optimization)
351
+ */
352
+ static markAsProxy(e) {
353
+ if (e)
354
+ try {
355
+ _.add(e);
356
+ } catch {
357
+ }
358
+ }
359
+ }
360
+ let b = !1;
361
+ function U() {
362
+ return b;
363
+ }
364
+ function G() {
365
+ b = !0;
366
+ }
367
+ function Z() {
368
+ b = !1;
369
+ }
370
+ class P {
371
+ // Use a stack to support nested callers (component render -> watcher)
372
+ // so that watchers can temporarily become the "current component" while
373
+ // establishing dependencies without clobbering the outer component id.
374
+ currentComponentStack = [];
375
+ // Consolidated component data: stores dependencies, render function, state index, and last warning time
376
+ componentData = /* @__PURE__ */ new Map();
377
+ // Flat storage: compound key `${componentId}:${stateIndex}` -> ReactiveState
378
+ stateStorage = /* @__PURE__ */ new Map();
379
+ trackingDisabled = !1;
380
+ /**
381
+ * Set the current component being rendered for dependency tracking
382
+ */
383
+ setCurrentComponent(e, t) {
384
+ if (this.currentComponentStack.push(e), !this.componentData.has(e))
385
+ this.componentData.set(e, {
386
+ dependencies: /* @__PURE__ */ new Set(),
387
+ renderFn: t,
388
+ stateIndex: 0,
389
+ lastWarnTime: 0,
390
+ watchers: /* @__PURE__ */ new Map()
391
+ });
392
+ else {
393
+ const n = this.componentData.get(e);
394
+ if (n.watchers && n.watchers.size) {
395
+ for (const r of n.watchers.values())
396
+ try {
397
+ this.cleanup(r);
398
+ } catch {
399
+ }
400
+ n.watchers.clear();
401
+ }
402
+ n.renderFn = t, n.stateIndex = 0;
403
+ }
404
+ }
405
+ /**
406
+ * Clear the current component after rendering
407
+ */
408
+ clearCurrentComponent() {
409
+ this.currentComponentStack.pop();
410
+ }
411
+ /**
412
+ * Get the current component id (top of stack) or null
413
+ */
414
+ getCurrentComponentId() {
415
+ return this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
416
+ }
417
+ /**
418
+ * Register a watcher id under a component so it can be cleaned up on re-render
419
+ */
420
+ registerWatcher(e, t) {
421
+ const n = this.componentData.get(e);
422
+ n && n.watchers.set(t, t);
423
+ }
424
+ /**
425
+ * Temporarily disable dependency tracking
426
+ */
427
+ disableTracking() {
428
+ this.trackingDisabled = !0;
429
+ }
430
+ /**
431
+ * Re-enable dependency tracking
432
+ */
433
+ enableTracking() {
434
+ this.trackingDisabled = !1;
435
+ }
436
+ /**
437
+ * Check if a component is currently rendering
438
+ */
439
+ isRenderingComponent() {
440
+ return this.currentComponentStack.length > 0;
441
+ }
442
+ /**
443
+ * Return whether we should emit a render-time warning for the current component.
444
+ * This throttles warnings to avoid spamming the console for legitimate rapid updates.
445
+ */
446
+ shouldEmitRenderWarning() {
447
+ const e = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
448
+ if (!e) return !0;
449
+ const t = this.componentData.get(e);
450
+ if (!t) return !0;
451
+ const n = Date.now();
452
+ return n - t.lastWarnTime < 1e3 ? !1 : (t.lastWarnTime = n, !0);
453
+ }
454
+ /**
455
+ * Execute a function with tracking disabled
456
+ */
457
+ withoutTracking(e) {
458
+ const t = this.trackingDisabled;
459
+ this.trackingDisabled = !0;
460
+ try {
461
+ return e();
462
+ } finally {
463
+ this.trackingDisabled = t;
464
+ }
465
+ }
466
+ /**
467
+ * Get or create a state instance for the current component
468
+ */
469
+ getOrCreateState(e) {
470
+ const t = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
471
+ if (!t)
472
+ return new k(e);
473
+ const n = this.componentData.get(t);
474
+ if (!n)
475
+ return new k(e);
476
+ const r = `${t}:${n.stateIndex++}`;
477
+ let i = this.stateStorage.get(r);
478
+ return i || (i = new k(e), this.stateStorage.set(r, i)), i;
479
+ }
480
+ /**
481
+ * Track a dependency for the current component
482
+ */
483
+ trackDependency(e) {
484
+ if (this.trackingDisabled) return;
485
+ const t = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
486
+ if (!t) return;
487
+ const n = this.componentData.get(t);
488
+ n && (n.dependencies.add(e), e.addDependent(t));
489
+ }
490
+ /**
491
+ * Trigger updates for all components that depend on a state
492
+ */
493
+ triggerUpdate(e) {
494
+ const t = e.getDependents();
495
+ for (const n of t) {
496
+ const r = this.componentData.get(n);
497
+ r && R(r.renderFn, n);
498
+ }
499
+ }
500
+ /**
501
+ * Clean up component dependencies when component is destroyed
502
+ */
503
+ cleanup(e) {
504
+ const t = this.componentData.get(e);
505
+ if (t) {
506
+ for (const r of t.dependencies)
507
+ r.removeDependent(e);
508
+ this.componentData.delete(e);
509
+ }
510
+ const n = e + ":";
511
+ for (const r of this.stateStorage.keys())
512
+ r.startsWith(n) && this.stateStorage.delete(r);
513
+ }
514
+ }
515
+ const c = new P();
516
+ class k {
517
+ _value;
518
+ dependents = /* @__PURE__ */ new Set();
519
+ constructor(e) {
520
+ this._value = this.makeReactive(e);
521
+ try {
522
+ Object.defineProperty(this, /* @__PURE__ */ Symbol.for("@cer/ReactiveState"), {
523
+ value: !0,
524
+ enumerable: !1,
525
+ configurable: !1
526
+ });
527
+ } catch {
528
+ }
529
+ }
530
+ get value() {
531
+ return c.trackDependency(this), this._value;
532
+ }
533
+ set value(e) {
534
+ c.isRenderingComponent() && c.shouldEmitRenderWarning() && y(
535
+ `🚨 State modification detected during render! This can cause infinite loops.
536
+ • Move state updates to event handlers
537
+ • Use watchEffect/watch for side effects
538
+ • Ensure computed properties don't modify state`
539
+ ), this._value = this.makeReactive(e), c.triggerUpdate(this);
540
+ }
541
+ /**
542
+ * Read the current value without registering a reactive dependency.
543
+ * Useful for internal infrastructure (e.g. stable hook slots) that must
544
+ * inspect the stored value without re-triggering the containing component.
545
+ * @internal
546
+ */
547
+ peek() {
548
+ return this._value;
549
+ }
550
+ /**
551
+ * Set the initial value without triggering any reactive updates or warnings.
552
+ * Only intended for internal/infrastructure use (e.g. storing a stable hook
553
+ * handle in a reactive slot without causing a spurious re-render).
554
+ * The value is stored as-is without reactive proxy wrapping so that opaque
555
+ * objects (e.g. TeleportHandle) are not accidentally instrumented.
556
+ * @internal
557
+ */
558
+ initSilent(e) {
559
+ this._value = e;
560
+ }
561
+ addDependent(e) {
562
+ this.dependents.add(e);
563
+ }
564
+ removeDependent(e) {
565
+ this.dependents.delete(e);
566
+ }
567
+ getDependents() {
568
+ return this.dependents;
569
+ }
570
+ makeReactive(e) {
571
+ return e === null || typeof e != "object" || e instanceof Node || e instanceof Element || e instanceof HTMLElement ? e : v.createReactiveProxy(
572
+ e,
573
+ () => c.triggerUpdate(this),
574
+ (t) => this.makeReactive(t)
575
+ );
576
+ }
577
+ }
578
+ function X(s) {
579
+ return c.getOrCreateState(
580
+ s === void 0 ? null : s
581
+ );
582
+ }
583
+ function w(s) {
584
+ if (!s || typeof s != "object") return !1;
585
+ try {
586
+ const e = /* @__PURE__ */ Symbol.for("@cer/ReactiveState");
587
+ return Object.prototype.hasOwnProperty.call(s, e);
588
+ } catch {
589
+ return !1;
590
+ }
591
+ }
592
+ function B(s) {
593
+ let e, t = !0;
594
+ const n = `computed-${crypto.randomUUID()}`, r = () => {
595
+ t = !0;
596
+ };
597
+ try {
598
+ const i = c.getCurrentComponentId();
599
+ i && c.registerWatcher(i, n);
600
+ } catch {
601
+ }
602
+ return c.setCurrentComponent(n, r), e = s(), c.clearCurrentComponent(), t = !1, {
603
+ get value() {
604
+ return t && (c.setCurrentComponent(n, r), e = s(), c.clearCurrentComponent(), t = !1), s(), e;
605
+ }
606
+ };
607
+ }
608
+ function K(s) {
609
+ if (U()) return () => {
610
+ };
611
+ const e = `effect-${crypto.randomUUID()}`;
612
+ try {
613
+ const n = c.getCurrentComponentId();
614
+ n && c.registerWatcher(n, e);
615
+ } catch {
616
+ }
617
+ const t = () => {
618
+ c.setCurrentComponent(e, t);
619
+ try {
620
+ s();
621
+ } finally {
622
+ c.clearCurrentComponent();
623
+ }
624
+ };
625
+ return t(), () => {
626
+ c.cleanup(e);
627
+ };
628
+ }
629
+ function C(s, e = /* @__PURE__ */ new WeakMap()) {
630
+ if (s === null || typeof s != "object") return s;
631
+ const t = s;
632
+ if (e.has(t)) return e.get(t);
633
+ if (typeof Node < "u" && t instanceof Node) return s;
634
+ if (t instanceof Date) return new Date(t.getTime());
635
+ if (Array.isArray(t)) {
636
+ const r = [];
637
+ e.set(t, r);
638
+ for (let i = 0; i < t.length; i++)
639
+ r.push(C(t[i], e));
640
+ return r;
641
+ }
642
+ const n = {};
643
+ e.set(t, n);
644
+ for (const r of Object.keys(t))
645
+ try {
646
+ n[r] = C(t[r], e);
647
+ } catch {
648
+ }
649
+ return n;
650
+ }
651
+ function J(s, e, t) {
652
+ if (U()) return () => {
653
+ };
654
+ let n;
655
+ const r = w(s) ? () => s.value : s, i = `watch-${crypto.randomUUID()}`;
656
+ try {
657
+ const o = c.getCurrentComponentId();
658
+ o && c.registerWatcher(o, i);
659
+ } catch {
660
+ }
661
+ const a = () => {
662
+ c.setCurrentComponent(i, a);
663
+ const o = r();
664
+ if (c.clearCurrentComponent(), t?.deep) {
665
+ const u = c.withoutTracking(
666
+ () => C(o)
667
+ );
668
+ e(u, n), n = u;
669
+ } else o !== n && (e(o, n), n = o);
670
+ };
671
+ return c.setCurrentComponent(i, a), n = r(), c.clearCurrentComponent(), t?.deep && (n = c.withoutTracking(() => C(n))), t && t.immediate && e(n, void 0), () => {
672
+ c.cleanup(i);
673
+ };
674
+ }
675
+ const Q = (s) => {
676
+ try {
677
+ s();
678
+ } catch {
679
+ }
680
+ }, p = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), M = 500;
681
+ let f, D, S = !1, A = !1, T;
682
+ const W = !!globalThis.process?.versions?.node;
683
+ function Y(s) {
684
+ if (p.has(s))
685
+ return p.get(s);
686
+ const e = s.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
687
+ return p.size < M && p.set(s, e), e;
688
+ }
689
+ function ee(s) {
690
+ if (g.has(s))
691
+ return g.get(s);
692
+ const e = s.replace(/-([a-z])/g, (t, n) => n.toUpperCase());
693
+ return g.size < M && g.set(s, e), e;
694
+ }
695
+ function te(s) {
696
+ if (typeof s == "string") {
697
+ if (m.has(s))
698
+ return m.get(s);
699
+ const e = s.replace(
700
+ /[&<>"']/g,
701
+ (t) => ({
702
+ "&": "&amp;",
703
+ "<": "&lt;",
704
+ ">": "&gt;",
705
+ '"': "&quot;",
706
+ "'": "&#39;"
707
+ })[t]
708
+ );
709
+ return e !== s && m.size < M && m.set(s, e), e;
710
+ }
711
+ return s;
712
+ }
713
+ function l(s) {
714
+ if (!s) return "";
715
+ const e = String(s);
716
+ if (typeof document < "u" && typeof document.createElement == "function") {
717
+ const o = e.replace(/</g, "").replace(/>/g, ""), u = T || (T = document.createElement("div"));
718
+ try {
719
+ l._el = u;
720
+ } catch {
721
+ }
722
+ return u.innerHTML = o, (u.textContent || "").replace(new RegExp("", "g"), "<").replace(new RegExp("", "g"), ">");
723
+ }
724
+ const t = {
725
+ lt: "<",
726
+ gt: ">",
727
+ amp: "&",
728
+ quot: '"',
729
+ apos: "'",
730
+ nbsp: " "
731
+ }, n = f ?? l._namedMap;
732
+ let r = n;
733
+ if (!r && W)
734
+ try {
735
+ const i = globalThis.require;
736
+ if (typeof i == "function") {
737
+ const a = [
738
+ "@jasonshimmy/custom-elements-runtime/entities.json",
739
+ // installed package export
740
+ "../../entities.json",
741
+ // dist/runtime -> ../../entities.json
742
+ "../../../entities.json",
743
+ // src/lib/runtime -> ../../../entities.json
744
+ "../entities.json",
745
+ "./entities.json"
746
+ ];
747
+ for (const o of a)
748
+ try {
749
+ const u = i(o);
750
+ if (u && typeof u == "object") {
751
+ r = u;
752
+ break;
753
+ }
754
+ } catch {
755
+ }
756
+ }
757
+ } catch {
758
+ }
759
+ if (!r) {
760
+ r = t, S = !0;
761
+ try {
762
+ l._usedFallback = !0;
763
+ } catch {
764
+ }
765
+ const i = l._namedMapLoader ?? D;
766
+ i && i().then((a) => {
767
+ f = a;
768
+ try {
769
+ l._namedMap = a;
770
+ } catch {
771
+ }
772
+ }).catch(() => {
773
+ });
774
+ }
775
+ if ((S || l._usedFallback) && !(A || l._warnedFallback)) {
776
+ A = !0;
777
+ try {
778
+ l._warnedFallback = !0;
779
+ } catch {
780
+ }
781
+ try {
782
+ y(
783
+ "decodeEntities: using small SSR fallback entity map. Register the full entities.json via registerEntityMap(entities) on the server to enable full HTML5 named-entity decoding."
784
+ );
785
+ } catch {
786
+ }
787
+ }
788
+ return e.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, (i, a) => {
789
+ if (a.charCodeAt(0) === 35) {
790
+ const d = (a.charAt(1) || "").toLowerCase() === "x" ? parseInt(a.slice(2), 16) : parseInt(a.slice(1), 10);
791
+ return Number.isNaN(d) ? `&${a};` : String.fromCodePoint(d);
792
+ }
793
+ const o = r[a] ?? (n && n[a]);
794
+ return o !== void 0 ? o : `&${a};`;
795
+ });
796
+ }
797
+ async function I() {
798
+ const s = [
799
+ "@jasonshimmy",
800
+ "custom-elements-runtime",
801
+ "entities.json"
802
+ ].join("/");
803
+ try {
804
+ const e = await import(
805
+ /* @vite-ignore */
806
+ s
807
+ );
808
+ return e && (e.default || e);
809
+ } catch {
810
+ try {
811
+ const e = [
812
+ s,
813
+ // try package export via dynamic import too (best for installed packages)
814
+ "./entities.json",
815
+ "../../entities.json",
816
+ "../../../entities.json"
817
+ ];
818
+ for (const t of e)
819
+ try {
820
+ const n = await import(
821
+ /* @vite-ignore */
822
+ t
823
+ );
824
+ if (n)
825
+ return n && (n.default || n);
826
+ } catch {
827
+ }
828
+ return {
829
+ lt: "<",
830
+ gt: ">",
831
+ amp: "&",
832
+ quot: '"',
833
+ apos: "'",
834
+ nbsp: " "
835
+ };
836
+ } catch {
837
+ return {
838
+ lt: "<",
839
+ gt: ">",
840
+ amp: "&",
841
+ quot: '"',
842
+ apos: "'",
843
+ nbsp: " "
844
+ };
845
+ }
846
+ }
847
+ }
848
+ D = I;
849
+ l._namedMapLoader = I;
850
+ function ne(s, e) {
851
+ !s || typeof s != "object" || f && !e?.overwrite || (f = s);
852
+ }
853
+ function se() {
854
+ f = void 0;
855
+ }
856
+ function re(s) {
857
+ const e = String(s);
858
+ return { __unsafeHTML: e, __rawHTML: e };
859
+ }
860
+ function ie(s) {
861
+ return !!s && (typeof s.__unsafeHTML == "string" || typeof s.__rawHTML == "string");
862
+ }
863
+ function ae(s, e) {
864
+ if (typeof e == "string") {
865
+ if (e === "") return;
866
+ const t = e.split(".");
867
+ let n = s;
868
+ for (const r of t) {
869
+ if (n == null || typeof n != "object") {
870
+ n = void 0;
871
+ break;
872
+ }
873
+ n = n[r];
874
+ }
875
+ return w(n) ? n.value : n;
876
+ }
877
+ return e;
878
+ }
879
+ function ce(s, e, t) {
880
+ const n = String(e).split("."), r = n.pop();
881
+ if (!r) return;
882
+ const i = n.reduce(
883
+ (a, o) => (a[o] == null && (a[o] = {}), a[o]),
884
+ s
885
+ );
886
+ w(i[r]) ? i[r].value = t : i[r] = t;
887
+ }
888
+ function F(s) {
889
+ try {
890
+ if (s && typeof s == "object") {
891
+ if (w(s)) return s.value;
892
+ if ("value" in s) {
893
+ const e = s.value;
894
+ return e == null || typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? e : s;
895
+ }
896
+ }
897
+ } catch {
898
+ }
899
+ return s;
900
+ }
901
+ function oe(s) {
902
+ const e = F(s);
903
+ if (e == null) return null;
904
+ const t = typeof e;
905
+ return t === "string" || t === "number" || t === "boolean" ? String(e) : null;
906
+ }
907
+ function ue(s) {
908
+ if (!s || typeof s != "string") return !1;
909
+ if (s === "class" || s.endsWith("Class")) return !0;
910
+ if (s.includes("-"))
911
+ try {
912
+ if (s.split("-").some((t) => t === "class")) return !0;
913
+ } catch {
914
+ }
915
+ return !1;
916
+ }
917
+ const N = {
918
+ xlink: "http://www.w3.org/1999/xlink",
919
+ xml: "http://www.w3.org/XML/1998/namespace"
920
+ };
921
+ function le(s, e, t) {
922
+ try {
923
+ if (!e || !e.includes(":")) {
924
+ s.setAttribute(e, t);
925
+ return;
926
+ }
927
+ const n = e.indexOf(":"), r = e.substring(0, n), i = e.substring(n + 1), a = N[r];
928
+ a ? s.setAttributeNS(a, i, t) : s.setAttribute(e, t);
929
+ } catch {
930
+ try {
931
+ s.setAttribute(e, t);
932
+ } catch {
933
+ }
934
+ }
935
+ }
936
+ function de(s, e) {
937
+ try {
938
+ if (!e || !e.includes(":")) {
939
+ s.removeAttribute(e);
940
+ return;
941
+ }
942
+ const t = e.indexOf(":"), n = e.substring(0, t), r = e.substring(t + 1), i = N[n];
943
+ i ? s.removeAttributeNS(i, r) : s.removeAttribute(e);
944
+ } catch {
945
+ try {
946
+ s.removeAttribute(e);
947
+ } catch {
948
+ }
949
+ }
950
+ }
951
+ const j = "http://www.w3.org/2000/svg", O = "http://www.w3.org/1998/Math/MathML", he = {
952
+ svg: j,
953
+ math: O
954
+ };
955
+ export {
956
+ G as A,
957
+ Z as B,
958
+ ie as C,
959
+ k as R,
960
+ j as S,
961
+ he as T,
962
+ c as a,
963
+ K as b,
964
+ B as c,
965
+ l as d,
966
+ te as e,
967
+ q as f,
968
+ se as g,
969
+ ne as h,
970
+ w as i,
971
+ ae as j,
972
+ ce as k,
973
+ I as l,
974
+ Q as m,
975
+ $ as n,
976
+ oe as o,
977
+ le as p,
978
+ de as q,
979
+ X as r,
980
+ V as s,
981
+ Y as t,
982
+ re as u,
983
+ ee as v,
984
+ J as w,
985
+ ue as x,
986
+ R as y,
987
+ U as z
988
+ };
989
+ //# sourceMappingURL=namespace-helpers-DcD_6_K1.js.map