@jasonshimmy/custom-elements-runtime 3.4.0 → 3.5.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 (105) hide show
  1. package/README.md +28 -7
  2. package/dist/css-utils-Bn-dO44e.js +203 -0
  3. package/dist/{css-utils-CC43BbEy.js.map → css-utils-Bn-dO44e.js.map} +1 -1
  4. package/dist/{css-utils-CC43BbEy.js → css-utils-CFeP8SK1.cjs} +5 -71
  5. package/dist/{css-utils-mgjmH8qX.cjs.map → css-utils-CFeP8SK1.cjs.map} +1 -1
  6. package/dist/custom-elements-runtime.cjs.js +3 -4
  7. package/dist/custom-elements-runtime.cjs.js.map +1 -1
  8. package/dist/custom-elements-runtime.colors.cjs.js +1 -2
  9. package/dist/custom-elements-runtime.colors.cjs.js.map +1 -1
  10. package/dist/custom-elements-runtime.colors.es.js +277 -277
  11. package/dist/custom-elements-runtime.colors.es.js.map +1 -1
  12. package/dist/custom-elements-runtime.directive-enhancements.cjs.js +1 -2
  13. package/dist/custom-elements-runtime.directive-enhancements.cjs.js.map +1 -1
  14. package/dist/custom-elements-runtime.directive-enhancements.es.js +106 -122
  15. package/dist/custom-elements-runtime.directive-enhancements.es.js.map +1 -1
  16. package/dist/custom-elements-runtime.directives.cjs.js +1 -2
  17. package/dist/custom-elements-runtime.directives.cjs.js.map +1 -1
  18. package/dist/custom-elements-runtime.directives.es.js +60 -65
  19. package/dist/custom-elements-runtime.directives.es.js.map +1 -1
  20. package/dist/custom-elements-runtime.dom-jit-css.cjs.js +1 -7
  21. package/dist/custom-elements-runtime.dom-jit-css.cjs.js.map +1 -1
  22. package/dist/custom-elements-runtime.dom-jit-css.es.js +103 -115
  23. package/dist/custom-elements-runtime.dom-jit-css.es.js.map +1 -1
  24. package/dist/custom-elements-runtime.es.js +206 -253
  25. package/dist/custom-elements-runtime.es.js.map +1 -1
  26. package/dist/custom-elements-runtime.event-bus.cjs.js +1 -2
  27. package/dist/custom-elements-runtime.event-bus.cjs.js.map +1 -1
  28. package/dist/custom-elements-runtime.event-bus.es.js +102 -108
  29. package/dist/custom-elements-runtime.event-bus.es.js.map +1 -1
  30. package/dist/custom-elements-runtime.jit-css.cjs.js +1 -2
  31. package/dist/custom-elements-runtime.jit-css.cjs.js.map +1 -1
  32. package/dist/custom-elements-runtime.jit-css.es.js +14 -32
  33. package/dist/custom-elements-runtime.jit-css.es.js.map +1 -1
  34. package/dist/custom-elements-runtime.router.cjs.js +20 -21
  35. package/dist/custom-elements-runtime.router.cjs.js.map +1 -1
  36. package/dist/custom-elements-runtime.router.es.js +866 -926
  37. package/dist/custom-elements-runtime.router.es.js.map +1 -1
  38. package/dist/custom-elements-runtime.ssr-middleware.cjs.js +3 -4
  39. package/dist/custom-elements-runtime.ssr-middleware.cjs.js.map +1 -1
  40. package/dist/custom-elements-runtime.ssr-middleware.es.js +67 -73
  41. package/dist/custom-elements-runtime.ssr-middleware.es.js.map +1 -1
  42. package/dist/custom-elements-runtime.ssr.cjs.js +1 -1
  43. package/dist/custom-elements-runtime.ssr.es.js +3 -14
  44. package/dist/custom-elements-runtime.store.cjs.js +1 -2
  45. package/dist/custom-elements-runtime.store.cjs.js.map +1 -1
  46. package/dist/custom-elements-runtime.store.es.js +32 -33
  47. package/dist/custom-elements-runtime.store.es.js.map +1 -1
  48. package/dist/custom-elements-runtime.transitions.cjs.js +1 -2
  49. package/dist/custom-elements-runtime.transitions.cjs.js.map +1 -1
  50. package/dist/custom-elements-runtime.transitions.es.js +200 -210
  51. package/dist/custom-elements-runtime.transitions.es.js.map +1 -1
  52. package/dist/custom-elements-runtime.vite-plugin.cjs.js +4 -2
  53. package/dist/custom-elements-runtime.vite-plugin.cjs.js.map +1 -1
  54. package/dist/custom-elements-runtime.vite-plugin.es.js +155 -78
  55. package/dist/custom-elements-runtime.vite-plugin.es.js.map +1 -1
  56. package/dist/helpers-DcEpRwq5.cjs +5 -0
  57. package/dist/helpers-DcEpRwq5.cjs.map +1 -0
  58. package/dist/helpers-tJgb4Qve.js +693 -0
  59. package/dist/helpers-tJgb4Qve.js.map +1 -0
  60. package/dist/hooks-CEUnvtsA.js +407 -0
  61. package/dist/hooks-CEUnvtsA.js.map +1 -0
  62. package/dist/hooks-CNfugc95.cjs +2 -0
  63. package/dist/hooks-CNfugc95.cjs.map +1 -0
  64. package/dist/logger-DIJ0UH3R.js +36 -0
  65. package/dist/{logger-L25axmB-.js.map → logger-DIJ0UH3R.js.map} +1 -1
  66. package/dist/logger-Dkht1dCX.cjs +2 -0
  67. package/dist/{logger-BYIN7ysT.cjs.map → logger-Dkht1dCX.cjs.map} +1 -1
  68. package/dist/namespace-helpers-CIUkG8Mn.js +56 -0
  69. package/dist/{namespace-helpers-BucDdgz_.js.map → namespace-helpers-CIUkG8Mn.js.map} +1 -1
  70. package/dist/namespace-helpers-yYIb7INq.cjs +2 -0
  71. package/dist/{namespace-helpers-Bf7rm9JV.cjs.map → namespace-helpers-yYIb7INq.cjs.map} +1 -1
  72. package/dist/runtime/tag-utils.d.ts +11 -0
  73. package/dist/ssr-BpYy9XlW.js +170 -0
  74. package/dist/{ssr-H9GDwbTy.js.map → ssr-BpYy9XlW.js.map} +1 -1
  75. package/dist/ssr-CFabTOyi.cjs +4 -0
  76. package/dist/{ssr-DRsGduIK.cjs.map → ssr-CFabTOyi.cjs.map} +1 -1
  77. package/dist/style-A8l3aQ52.cjs +55 -0
  78. package/dist/{style-Bjn8zDiZ.cjs.map → style-A8l3aQ52.cjs.map} +1 -1
  79. package/dist/style-DSSoCbC9.js +1877 -0
  80. package/dist/{style-DuDoj_xK.js.map → style-DSSoCbC9.js.map} +1 -1
  81. package/dist/tag-utils-CoSXTr1F.js +10 -0
  82. package/dist/tag-utils-CoSXTr1F.js.map +1 -0
  83. package/dist/tag-utils-XJ3dkcPQ.cjs +2 -0
  84. package/dist/tag-utils-XJ3dkcPQ.cjs.map +1 -0
  85. package/dist/template-compiler-B4B_jAPN.cjs +19 -0
  86. package/dist/{template-compiler-BB4JJdqk.cjs.map → template-compiler-B4B_jAPN.cjs.map} +1 -1
  87. package/dist/template-compiler-C3h8_vbE.js +3044 -0
  88. package/dist/{template-compiler-Cs5axmn4.js.map → template-compiler-C3h8_vbE.js.map} +1 -1
  89. package/dist/vite-plugin.d.ts +96 -2
  90. package/package.json +8 -8
  91. package/dist/css-utils-mgjmH8qX.cjs +0 -577
  92. package/dist/hooks-_3xP4G2N.js +0 -1189
  93. package/dist/hooks-_3xP4G2N.js.map +0 -1
  94. package/dist/hooks-fYQgZk2g.cjs +0 -7
  95. package/dist/hooks-fYQgZk2g.cjs.map +0 -1
  96. package/dist/logger-BYIN7ysT.cjs +0 -3
  97. package/dist/logger-L25axmB-.js +0 -41
  98. package/dist/namespace-helpers-Bf7rm9JV.cjs +0 -3
  99. package/dist/namespace-helpers-BucDdgz_.js +0 -61
  100. package/dist/ssr-DRsGduIK.cjs +0 -5
  101. package/dist/ssr-H9GDwbTy.js +0 -172
  102. package/dist/style-Bjn8zDiZ.cjs +0 -56
  103. package/dist/style-DuDoj_xK.js +0 -1972
  104. package/dist/template-compiler-BB4JJdqk.cjs +0 -23
  105. package/dist/template-compiler-Cs5axmn4.js +0 -3236
@@ -0,0 +1,693 @@
1
+ import { r as e, t } from "./logger-DIJ0UH3R.js";
2
+ //#region src/lib/runtime/scheduler.ts
3
+ function n() {
4
+ let e = (() => {
5
+ try {
6
+ return globalThis.process?.env?.NODE_ENV;
7
+ } catch {
8
+ return;
9
+ }
10
+ })(), t = (() => {
11
+ try {
12
+ if (typeof window > "u") return {
13
+ vitest: !1,
14
+ cypress: !1
15
+ };
16
+ let e = window;
17
+ return {
18
+ vitest: !!e.__vitest__,
19
+ cypress: !!e.Cypress
20
+ };
21
+ } catch {
22
+ return {
23
+ vitest: !1,
24
+ cypress: !1
25
+ };
26
+ }
27
+ })();
28
+ return {
29
+ isTest: e === "test" || t.vitest || t.cypress,
30
+ isVitest: t.vitest,
31
+ isCypress: t.cypress
32
+ };
33
+ }
34
+ var r = new class {
35
+ pendingUpdates = /* @__PURE__ */ new Map();
36
+ isFlushScheduled = !1;
37
+ isFlushing = !1;
38
+ testEnv;
39
+ lastCleanup = 0;
40
+ CLEANUP_INTERVAL = 300 * 1e3;
41
+ MAX_PENDING_SIZE = 1e4;
42
+ pendingIdleUpdates = /* @__PURE__ */ new Map();
43
+ idleCallbackHandle = null;
44
+ constructor() {
45
+ this.testEnv = n(), this.schedulePeriodicCleanup();
46
+ }
47
+ schedule(e, t) {
48
+ let n = t || e;
49
+ this.pendingUpdates.size >= this.MAX_PENDING_SIZE && this.performEmergencyCleanup(), this.pendingUpdates.set(n, e), this.isFlushScheduled || this.scheduleFlush();
50
+ }
51
+ scheduleFlush() {
52
+ this.isFlushScheduled = !0, this.testEnv.isTest && !this.isFlushing ? this.flush() : queueMicrotask(() => this.flush());
53
+ }
54
+ flush() {
55
+ if (this.isFlushing) return;
56
+ this.isFlushing = !0;
57
+ let e = this.pendingUpdates;
58
+ this.pendingUpdates = /* @__PURE__ */ new Map(), this.isFlushScheduled = !1;
59
+ try {
60
+ for (let n of e.values()) try {
61
+ n();
62
+ } catch (e) {
63
+ t("Error in batched update:", e);
64
+ }
65
+ } finally {
66
+ this.isFlushing = !1;
67
+ }
68
+ }
69
+ flushImmediately() {
70
+ this.pendingUpdates.size !== 0 && (this.isFlushScheduled = !1, this.flush());
71
+ }
72
+ get pendingCount() {
73
+ return this.pendingUpdates.size;
74
+ }
75
+ get hasPendingUpdates() {
76
+ return this.pendingUpdates.size > 0;
77
+ }
78
+ get isFlushingUpdates() {
79
+ return this.isFlushing;
80
+ }
81
+ schedulePeriodicCleanup() {
82
+ if (this.testEnv.isTest) return;
83
+ let e = () => {
84
+ this.performPeriodicCleanup(), this.testEnv.isTest || setTimeout(e, this.CLEANUP_INTERVAL);
85
+ };
86
+ setTimeout(e, this.CLEANUP_INTERVAL);
87
+ }
88
+ performPeriodicCleanup() {
89
+ let t = Date.now();
90
+ t - this.lastCleanup < this.CLEANUP_INTERVAL || (this.pendingUpdates.size > 100 && e(`Scheduler has ${this.pendingUpdates.size} pending updates. Consider investigating.`), this.lastCleanup = t);
91
+ }
92
+ performEmergencyCleanup(t = this.pendingUpdates) {
93
+ e("Scheduler emergency cleanup: too many pending updates, clearing oldest entries");
94
+ let n = Array.from(t.entries()), r = Math.floor(n.length / 2);
95
+ for (let e = 0; e < r; e++) t.delete(n[e][0]);
96
+ }
97
+ scheduleWithPriority(e, n = "normal", r) {
98
+ if (n === "immediate") {
99
+ try {
100
+ e();
101
+ } catch (e) {
102
+ t("Error in immediate update:", e);
103
+ }
104
+ return;
105
+ }
106
+ if (n === "idle") {
107
+ let t = r ?? e;
108
+ this.pendingIdleUpdates.size >= this.MAX_PENDING_SIZE && this.performEmergencyCleanup(this.pendingIdleUpdates), this.pendingIdleUpdates.set(t, e), this.scheduleIdleFlush();
109
+ return;
110
+ }
111
+ let i = r ?? e;
112
+ this.pendingUpdates.size >= this.MAX_PENDING_SIZE && this.performEmergencyCleanup(), this.pendingUpdates.set(i, e), this.isFlushScheduled || (this.isFlushScheduled = !0, queueMicrotask(() => this.flush()));
113
+ }
114
+ scheduleIdleFlush() {
115
+ if (this.idleCallbackHandle === null) {
116
+ if (this.testEnv.isTest) {
117
+ this.idleCallbackHandle = setTimeout(() => {
118
+ this.idleCallbackHandle = null, this.flushIdleUpdates(null);
119
+ }, 0);
120
+ return;
121
+ }
122
+ typeof requestIdleCallback < "u" ? this.idleCallbackHandle = requestIdleCallback((e) => {
123
+ this.idleCallbackHandle = null, this.flushIdleUpdates(e);
124
+ }, { timeout: 2e3 }) : this.idleCallbackHandle = setTimeout(() => {
125
+ this.idleCallbackHandle = null;
126
+ let e = Date.now();
127
+ this.flushIdleUpdates({
128
+ timeRemaining: () => Math.max(0, 50 - (Date.now() - e)),
129
+ didTimeout: !1
130
+ });
131
+ }, 5);
132
+ }
133
+ }
134
+ flushIdleUpdates(e) {
135
+ let n = Array.from(this.pendingIdleUpdates.entries());
136
+ this.pendingIdleUpdates = /* @__PURE__ */ new Map();
137
+ for (let r = 0; r < n.length; r++) {
138
+ if (e && !e.didTimeout && e.timeRemaining() <= 0) {
139
+ for (let e = r; e < n.length; e++) this.pendingIdleUpdates.set(n[e][0], n[e][1]);
140
+ this.scheduleIdleFlush();
141
+ return;
142
+ }
143
+ try {
144
+ n[r][1]();
145
+ } catch (e) {
146
+ t("Error in idle update:", e);
147
+ }
148
+ }
149
+ }
150
+ }();
151
+ function i(e, t) {
152
+ r.schedule(e, t);
153
+ }
154
+ function a(e, t = "normal", n) {
155
+ r.scheduleWithPriority(e, t, n);
156
+ }
157
+ function o() {
158
+ r.flushImmediately();
159
+ }
160
+ function s() {
161
+ return new Promise((t) => {
162
+ let n = 0;
163
+ for (; r.hasPendingUpdates && n < 100;) r.flushImmediately(), n++;
164
+ n >= 100 && e("[nextTick] Maximum flush iterations reached — possible circular update loop. Check for watchers or computed values that unconditionally mutate reactive state."), queueMicrotask(t);
165
+ });
166
+ }
167
+ //#endregion
168
+ //#region src/lib/runtime/reactive-proxy-cache.ts
169
+ var c = /* @__PURE__ */ new WeakSet(), l = class {
170
+ static cache = /* @__PURE__ */ new WeakMap();
171
+ static arrayHandlerCache = /* @__PURE__ */ new WeakMap();
172
+ static objectHandlerCache = /* @__PURE__ */ new WeakMap();
173
+ static getOrCreateProxy(e, t, n = !1) {
174
+ let r = this.cache.get(e);
175
+ if (r) return r;
176
+ let i = n ? this.getOrCreateArrayHandler(t) : this.getOrCreateObjectHandler(t), a = new Proxy(e, i);
177
+ try {
178
+ u.markAsProxy(a);
179
+ } catch {}
180
+ return this.cache.set(e, a), a;
181
+ }
182
+ static getOrCreateArrayHandler(e) {
183
+ return this.arrayHandlerCache.has(e) || this.arrayHandlerCache.set(e, {
184
+ get: (t, n, r) => {
185
+ let i = Reflect.get(t, n, r);
186
+ return typeof i == "function" && typeof n == "string" && [
187
+ "push",
188
+ "pop",
189
+ "shift",
190
+ "unshift",
191
+ "splice",
192
+ "sort",
193
+ "reverse",
194
+ "fill",
195
+ "copyWithin"
196
+ ].includes(n) ? function(...n) {
197
+ let r = i.apply(t, n);
198
+ return e.triggerUpdate(), r;
199
+ } : typeof i == "object" && i && typeof n == "string" ? e.makeReactiveValue(i) : i;
200
+ },
201
+ set: (t, n, r) => (t[n] = e.makeReactiveValue(r), e.triggerUpdate(), !0),
202
+ deleteProperty: (t, n) => (delete t[n], e.triggerUpdate(), !0)
203
+ }), this.arrayHandlerCache.get(e);
204
+ }
205
+ static getOrCreateObjectHandler(e) {
206
+ return this.objectHandlerCache.has(e) || this.objectHandlerCache.set(e, {
207
+ get: (t, n, r) => {
208
+ let i = Reflect.get(t, n, r);
209
+ return typeof i == "object" && i && typeof n == "string" ? e.makeReactiveValue(i) : i;
210
+ },
211
+ set: (t, n, r) => (t[n] = e.makeReactiveValue(r), e.triggerUpdate(), !0),
212
+ deleteProperty: (t, n) => (delete t[n], e.triggerUpdate(), !0)
213
+ }), this.objectHandlerCache.get(e);
214
+ }
215
+ static hasProxy(e) {
216
+ return this.cache.has(e);
217
+ }
218
+ static clear() {
219
+ this.cache = /* @__PURE__ */ new WeakMap(), this.arrayHandlerCache = /* @__PURE__ */ new WeakMap(), this.objectHandlerCache = /* @__PURE__ */ new WeakMap();
220
+ }
221
+ static getStats() {
222
+ return { hasCachedProxies: this.cache instanceof WeakMap };
223
+ }
224
+ }, u = class {
225
+ static contextCache = /* @__PURE__ */ new WeakMap();
226
+ static createReactiveProxy(e, t, n) {
227
+ try {
228
+ if (c.has(e)) return e;
229
+ } catch {}
230
+ let r = Array.isArray(e), i = this.contextCache.get(t);
231
+ i || (i = /* @__PURE__ */ new WeakMap(), this.contextCache.set(t, i));
232
+ let a = i.get(n);
233
+ return a || (a = {
234
+ triggerUpdate: t,
235
+ makeReactiveValue: n
236
+ }, i.set(n, a)), l.getOrCreateProxy(e, a, r);
237
+ }
238
+ static markAsProxy(e) {
239
+ if (e) try {
240
+ c.add(e);
241
+ } catch {}
242
+ }
243
+ }, d = !1;
244
+ function f() {
245
+ return d;
246
+ }
247
+ function p() {
248
+ d && e("[CER] beginDiscoveryRender() called while a discovery render is already active. This usually means a component was registered inside another component's render function. Ensure component() calls are at module top-level."), d = !0;
249
+ }
250
+ function m() {
251
+ d = !1;
252
+ }
253
+ //#endregion
254
+ //#region src/lib/runtime/reactive.ts
255
+ var h = 0;
256
+ function g(e) {
257
+ return `${e}-${++h}`;
258
+ }
259
+ var _ = new class {
260
+ currentComponentStack = [];
261
+ componentData = /* @__PURE__ */ new Map();
262
+ stateStorage = /* @__PURE__ */ new Map();
263
+ trackingDisabled = !1;
264
+ setCurrentComponent(e, t) {
265
+ if (this.currentComponentStack.push(e), !this.componentData.has(e)) this.componentData.set(e, {
266
+ dependencies: /* @__PURE__ */ new Set(),
267
+ renderFn: t,
268
+ stateIndex: 0,
269
+ lastWarnTime: 0,
270
+ watchers: /* @__PURE__ */ new Map()
271
+ });
272
+ else {
273
+ let n = this.componentData.get(e);
274
+ if (n.watchers && n.watchers.size) {
275
+ for (let e of n.watchers.values()) try {
276
+ this.cleanup(e);
277
+ } catch {}
278
+ n.watchers.clear();
279
+ }
280
+ n.renderFn = t, n.stateIndex = 0;
281
+ }
282
+ }
283
+ clearCurrentComponent() {
284
+ this.currentComponentStack.pop();
285
+ }
286
+ getCurrentComponentId() {
287
+ return this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
288
+ }
289
+ registerWatcher(e, t) {
290
+ let n = this.componentData.get(e);
291
+ n && n.watchers.set(t, t);
292
+ }
293
+ disableTracking() {
294
+ this.trackingDisabled = !0;
295
+ }
296
+ enableTracking() {
297
+ this.trackingDisabled = !1;
298
+ }
299
+ isRenderingComponent() {
300
+ return this.currentComponentStack.length > 0;
301
+ }
302
+ shouldEmitRenderWarning() {
303
+ let e = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
304
+ if (!e) return !0;
305
+ let t = this.componentData.get(e);
306
+ if (!t) return !0;
307
+ let n = Date.now();
308
+ return n - t.lastWarnTime < 1e3 ? !1 : (t.lastWarnTime = n, !0);
309
+ }
310
+ withoutTracking(e) {
311
+ let t = this.trackingDisabled;
312
+ this.trackingDisabled = !0;
313
+ try {
314
+ return e();
315
+ } finally {
316
+ this.trackingDisabled = t;
317
+ }
318
+ }
319
+ getOrCreateState(e) {
320
+ let t = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
321
+ if (!t) return new v(e);
322
+ let n = this.componentData.get(t);
323
+ if (!n) return new v(e);
324
+ let r = `${t}:${n.stateIndex++}`, i = this.stateStorage.get(r);
325
+ return i || (i = new v(e), this.stateStorage.set(r, i)), i;
326
+ }
327
+ trackDependency(e) {
328
+ if (this.trackingDisabled) return;
329
+ let t = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
330
+ if (!t) return;
331
+ let n = this.componentData.get(t);
332
+ n && (n.dependencies.add(e), e.addDependent(t));
333
+ }
334
+ propagateDependencies(e) {
335
+ if (this.trackingDisabled) return;
336
+ let t = this.currentComponentStack.length ? this.currentComponentStack[this.currentComponentStack.length - 1] : null;
337
+ if (!t || t === e) return;
338
+ let n = this.componentData.get(e);
339
+ if (!n) return;
340
+ let r = this.componentData.get(t);
341
+ if (r) for (let e of n.dependencies) r.dependencies.add(e), e.addDependent(t);
342
+ }
343
+ triggerUpdate(e) {
344
+ let t = e.getDependents();
345
+ for (let e of t) {
346
+ let t = this.componentData.get(e);
347
+ t && i(t.renderFn, e);
348
+ }
349
+ }
350
+ cleanup(e) {
351
+ let t = this.componentData.get(e);
352
+ if (t) {
353
+ for (let n of t.dependencies) n.removeDependent(e);
354
+ this.componentData.delete(e);
355
+ }
356
+ let n = e + ":";
357
+ for (let e of this.stateStorage.keys()) e.startsWith(n) && this.stateStorage.delete(e);
358
+ }
359
+ }(), v = class {
360
+ _value;
361
+ _rawValue;
362
+ dependents = /* @__PURE__ */ new Set();
363
+ constructor(e) {
364
+ this._rawValue = e, this._value = this.makeReactive(e);
365
+ try {
366
+ Object.defineProperty(this, Symbol.for("@cer/ReactiveState"), {
367
+ value: !0,
368
+ enumerable: !1,
369
+ configurable: !1
370
+ });
371
+ } catch {}
372
+ }
373
+ get value() {
374
+ return _.trackDependency(this), this._value;
375
+ }
376
+ set value(t) {
377
+ Object.is(t, this._rawValue) || (_.isRenderingComponent() && _.shouldEmitRenderWarning() && e("🚨 State modification detected during render! This can cause infinite loops.\n • Move state updates to event handlers\n • Use watchEffect/watch for side effects\n • Ensure computed properties don't modify state"), this._rawValue = t, this._value = this.makeReactive(t), _.triggerUpdate(this));
378
+ }
379
+ peek() {
380
+ return this._value;
381
+ }
382
+ initSilent(e) {
383
+ this._rawValue = e, this._value = e;
384
+ }
385
+ addDependent(e) {
386
+ this.dependents.add(e);
387
+ }
388
+ removeDependent(e) {
389
+ this.dependents.delete(e);
390
+ }
391
+ getDependents() {
392
+ return this.dependents;
393
+ }
394
+ makeReactive(e) {
395
+ return typeof e != "object" || !e || typeof Node < "u" && e instanceof Node || typeof Element < "u" && e instanceof Element || typeof HTMLElement < "u" && e instanceof HTMLElement ? e : u.createReactiveProxy(e, () => _.triggerUpdate(this), (e) => this.makeReactive(e));
396
+ }
397
+ };
398
+ function y(e) {
399
+ return _.getOrCreateState(e === void 0 ? null : e);
400
+ }
401
+ function b(e) {
402
+ if (!e || typeof e != "object") return !1;
403
+ try {
404
+ let t = Symbol.for("@cer/ReactiveState");
405
+ return Object.prototype.hasOwnProperty.call(e, t);
406
+ } catch {
407
+ return !1;
408
+ }
409
+ }
410
+ function x(e) {
411
+ let t, n = !0, r = g("computed"), i = () => {
412
+ n = !0;
413
+ };
414
+ try {
415
+ let e = _.getCurrentComponentId();
416
+ e && _.registerWatcher(e, r);
417
+ } catch {}
418
+ return _.setCurrentComponent(r, i), t = e(), _.clearCurrentComponent(), n = !1, { get value() {
419
+ return n &&= (_.setCurrentComponent(r, i), t = e(), _.clearCurrentComponent(), !1), _.propagateDependencies(r), t;
420
+ } };
421
+ }
422
+ function S(e) {
423
+ if (f()) return () => {};
424
+ let t = g("effect");
425
+ try {
426
+ let e = _.getCurrentComponentId();
427
+ e && _.registerWatcher(e, t);
428
+ } catch {}
429
+ let n = () => {
430
+ _.setCurrentComponent(t, n);
431
+ try {
432
+ e();
433
+ } finally {
434
+ _.clearCurrentComponent();
435
+ }
436
+ };
437
+ return n(), () => {
438
+ _.cleanup(t);
439
+ };
440
+ }
441
+ var C = 50;
442
+ function w(t, n = /* @__PURE__ */ new WeakMap(), r = 0) {
443
+ if (typeof t != "object" || !t) return t;
444
+ let i = t;
445
+ if (n.has(i)) return n.get(i);
446
+ if (r > C) return e(`[watch] Deep clone exceeded ${C} nesting levels. Returning a reference at this depth instead of cloning further. Consider restructuring your state or switching to a shallow watch.`), t;
447
+ if (typeof Node < "u" && i instanceof Node) return t;
448
+ if (i instanceof Date) return new Date(i.getTime());
449
+ if (Array.isArray(i)) {
450
+ let e = [];
451
+ n.set(i, e);
452
+ for (let t = 0; t < i.length; t++) e.push(w(i[t], n, r + 1));
453
+ return e;
454
+ }
455
+ let a = {};
456
+ n.set(i, a);
457
+ for (let e of Object.keys(i)) try {
458
+ a[e] = w(i[e], n, r + 1);
459
+ } catch {}
460
+ return a;
461
+ }
462
+ function T(e, t, n) {
463
+ if (f()) return () => {};
464
+ let r, i = b(e) ? () => e.value : e, a = g("watch");
465
+ try {
466
+ let e = _.getCurrentComponentId();
467
+ e && _.registerWatcher(e, a);
468
+ } catch {}
469
+ let o = () => {
470
+ _.setCurrentComponent(a, o);
471
+ let e = i();
472
+ if (_.clearCurrentComponent(), n?.deep) {
473
+ let n = _.withoutTracking(() => w(e));
474
+ t(n, r), r = n;
475
+ } else e !== r && (t(e, r), r = e);
476
+ };
477
+ return _.setCurrentComponent(a, o), r = i(), _.clearCurrentComponent(), n?.deep && (r = _.withoutTracking(() => w(r))), n && n.immediate && t(r, void 0), () => {
478
+ _.cleanup(a);
479
+ };
480
+ }
481
+ //#endregion
482
+ //#region src/lib/runtime/helpers.ts
483
+ var E = (e) => {
484
+ try {
485
+ e();
486
+ } catch {}
487
+ }, D = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Map(), A = 500, j, M, N = !1, P = !1, F, I = !!globalThis.process?.versions?.node;
488
+ function L(e) {
489
+ if (D.has(e)) return D.get(e);
490
+ let t = e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
491
+ return D.size < A && D.set(e, t), t;
492
+ }
493
+ function R(e) {
494
+ if (O.has(e)) return O.get(e);
495
+ let t = e.replace(/-([a-z])/g, (e, t) => t.toUpperCase());
496
+ return O.size < A && O.set(e, t), t;
497
+ }
498
+ function z(e) {
499
+ if (typeof e == "string") {
500
+ if (k.has(e)) return k.get(e);
501
+ let t = e.replace(/[&<>"']/g, (e) => ({
502
+ "&": "&amp;",
503
+ "<": "&lt;",
504
+ ">": "&gt;",
505
+ "\"": "&quot;",
506
+ "'": "&#39;"
507
+ })[e]);
508
+ return t !== e && k.size < A && k.set(e, t), t;
509
+ }
510
+ return e;
511
+ }
512
+ function B(t) {
513
+ if (!t) return "";
514
+ let n = String(t);
515
+ if (typeof document < "u" && typeof document.createElement == "function") {
516
+ let e = n.replace(/</g, "").replace(/>/g, ""), t = F ||= document.createElement("div");
517
+ try {
518
+ B._el = t;
519
+ } catch {}
520
+ return t.innerHTML = e, (t.textContent || "").replace(RegExp("", "g"), "<").replace(RegExp("", "g"), ">");
521
+ }
522
+ let r = {
523
+ lt: "<",
524
+ gt: ">",
525
+ amp: "&",
526
+ quot: "\"",
527
+ apos: "'",
528
+ nbsp: "\xA0"
529
+ }, i = j ?? B._namedMap, a = i;
530
+ if (!a && I) try {
531
+ let e = globalThis.require;
532
+ if (typeof e == "function") for (let t of [
533
+ "@jasonshimmy/custom-elements-runtime/entities.json",
534
+ "../../entities.json",
535
+ "../../../entities.json",
536
+ "../entities.json",
537
+ "./entities.json"
538
+ ]) try {
539
+ let n = e(t);
540
+ if (n && typeof n == "object") {
541
+ a = n;
542
+ break;
543
+ }
544
+ } catch {}
545
+ } catch {}
546
+ if (!a) {
547
+ a = r, N = !0;
548
+ try {
549
+ B._usedFallback = !0;
550
+ } catch {}
551
+ let e = B._namedMapLoader ?? M;
552
+ e && e().then((e) => {
553
+ j = e;
554
+ try {
555
+ B._namedMap = e;
556
+ } catch {}
557
+ }).catch(() => {});
558
+ }
559
+ if ((N || B._usedFallback) && !(P || B._warnedFallback)) {
560
+ P = !0;
561
+ try {
562
+ B._warnedFallback = !0;
563
+ } catch {}
564
+ try {
565
+ e("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.");
566
+ } catch {}
567
+ }
568
+ return n.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, (e, t) => {
569
+ if (t.charCodeAt(0) === 35) {
570
+ let e = (t.charAt(1) || "").toLowerCase() === "x" ? parseInt(t.slice(2), 16) : parseInt(t.slice(1), 10);
571
+ return Number.isNaN(e) ? `&${t};` : String.fromCodePoint(e);
572
+ }
573
+ let n = a[t] ?? (i && i[t]);
574
+ return n === void 0 ? `&${t};` : n;
575
+ });
576
+ }
577
+ async function V() {
578
+ let e = [
579
+ "@jasonshimmy",
580
+ "custom-elements-runtime",
581
+ "entities.json"
582
+ ].join("/");
583
+ try {
584
+ // @vite-ignore: dynamic import specifier constructed at runtime
585
+ let t = await import(
586
+ /* @vite-ignore */
587
+ e
588
+ );
589
+ return t && (t.default || t);
590
+ } catch {
591
+ try {
592
+ let t = [
593
+ e,
594
+ "./entities.json",
595
+ "../../entities.json",
596
+ "../../../entities.json"
597
+ ];
598
+ for (let e of t) try {
599
+ // @vite-ignore: intentionally dynamic path candidates for dev/local resolution
600
+ let t = await import(
601
+ /* @vite-ignore */
602
+ e
603
+ );
604
+ if (t) return t && (t.default || t);
605
+ } catch {}
606
+ return {
607
+ lt: "<",
608
+ gt: ">",
609
+ amp: "&",
610
+ quot: "\"",
611
+ apos: "'",
612
+ nbsp: "\xA0"
613
+ };
614
+ } catch {
615
+ return {
616
+ lt: "<",
617
+ gt: ">",
618
+ amp: "&",
619
+ quot: "\"",
620
+ apos: "'",
621
+ nbsp: "\xA0"
622
+ };
623
+ }
624
+ }
625
+ }
626
+ M = V, B._namedMapLoader = V;
627
+ function H(e, t) {
628
+ !e || typeof e != "object" || j && !t?.overwrite || (j = e);
629
+ }
630
+ function U() {
631
+ j = void 0;
632
+ }
633
+ function W(e) {
634
+ let t = String(e);
635
+ return {
636
+ __unsafeHTML: t,
637
+ __rawHTML: t
638
+ };
639
+ }
640
+ function G(e) {
641
+ return !!e && (typeof e.__unsafeHTML == "string" || typeof e.__rawHTML == "string");
642
+ }
643
+ function K(e, t) {
644
+ if (typeof t == "string") {
645
+ if (t === "") return;
646
+ let n = t.split("."), r = e;
647
+ for (let e of n) {
648
+ if (typeof r != "object" || !r) {
649
+ r = void 0;
650
+ break;
651
+ }
652
+ r = r[e];
653
+ }
654
+ return b(r) ? r.value : r;
655
+ }
656
+ return t;
657
+ }
658
+ function q(e, t, n) {
659
+ let r = String(t).split("."), i = r.pop();
660
+ if (!i) return;
661
+ let a = r.reduce((e, t) => (e[t] ?? (e[t] = {}), e[t]), e);
662
+ b(a[i]) ? a[i].value = n : a[i] = n;
663
+ }
664
+ function J(e) {
665
+ try {
666
+ if (e && typeof e == "object") {
667
+ if (b(e)) return e.value;
668
+ if ("value" in e) {
669
+ let t = e.value;
670
+ return t == null || typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? t : e;
671
+ }
672
+ }
673
+ } catch {}
674
+ return e;
675
+ }
676
+ function Y(e) {
677
+ let t = J(e);
678
+ if (t == null) return null;
679
+ let n = typeof t;
680
+ return n === "string" || n === "number" || n === "boolean" ? String(t) : null;
681
+ }
682
+ function X(e) {
683
+ if (!e || typeof e != "string") return !1;
684
+ if (e === "class" || e.endsWith("Class")) return !0;
685
+ if (e.includes("-")) try {
686
+ if (e.split("-").some((e) => e === "class")) return !0;
687
+ } catch {}
688
+ return !1;
689
+ }
690
+ //#endregion
691
+ export { m as C, s as D, o as E, i as O, p as S, n as T, b as _, X as a, T as b, H as c, q as d, R as f, x as g, v as h, K as i, a as k, E as l, W as m, B as n, G as o, L as p, z as r, V as s, U as t, Y as u, _ as v, f as w, S as x, y };
692
+
693
+ //# sourceMappingURL=helpers-tJgb4Qve.js.map