elit 1.0.0-test → 1.1.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.
package/dist/index.mjs CHANGED
@@ -1,2039 +1,35 @@
1
- // src/DomNode.ts
2
- var DomNode = class {
3
- constructor() {
4
- this.elementCache = /* @__PURE__ */ new WeakMap();
5
- this.reactiveNodes = /* @__PURE__ */ new Map();
6
- }
7
- createElement(tagName, props = {}, children = []) {
8
- return { tagName, props, children };
9
- }
10
- renderToDOM(vNode, parent) {
11
- if (vNode == null || vNode === false) {
12
- return;
13
- }
14
- if (typeof vNode !== "object") {
15
- parent.appendChild(document.createTextNode(String(vNode)));
16
- return;
17
- }
18
- const tagName = vNode.tagName;
19
- const isSVG = tagName === "svg" || tagName[0] === "s" && tagName[1] === "v" && tagName[2] === "g" || parent.namespaceURI === "http://www.w3.org/2000/svg";
20
- const el = isSVG ? document.createElementNS("http://www.w3.org/2000/svg", tagName.replace("svg", "").toLowerCase() || tagName) : document.createElement(tagName);
21
- const props = vNode.props;
22
- for (const key in props) {
23
- const value = props[key];
24
- if (value == null || value === false) continue;
25
- const c = key.charCodeAt(0);
26
- if (c === 99) {
27
- if (key.length < 6 || key[5] === "N") {
28
- const classValue = Array.isArray(value) ? value.join(" ") : value;
29
- if (isSVG) {
30
- el.setAttribute("class", classValue);
31
- } else {
32
- el.className = classValue;
33
- }
34
- continue;
35
- }
36
- } else if (c === 115 && key.length === 5) {
37
- if (typeof value === "string") {
38
- el.style.cssText = value;
39
- } else {
40
- const s2 = el.style;
41
- for (const k in value) s2[k] = value[k];
42
- }
43
- continue;
44
- } else if (c === 111 && key.charCodeAt(1) === 110) {
45
- el[key.toLowerCase()] = value;
46
- continue;
47
- } else if (c === 100 && key.length > 20) {
48
- el.innerHTML = value.__html;
49
- continue;
50
- } else if (c === 114 && key.length === 3) {
51
- setTimeout(() => {
52
- if (typeof value === "function") {
53
- value(el);
54
- } else if (value && "current" in value) {
55
- value.current = el;
56
- }
57
- }, 0);
58
- continue;
59
- }
60
- isSVG ? el.setAttributeNS(null, key, value === true ? "" : String(value)) : el.setAttribute(key, value === true ? "" : String(value));
61
- }
62
- const children = vNode.children;
63
- const len = children.length;
64
- if (len === 0) {
65
- parent.appendChild(el);
66
- return;
67
- }
68
- if (len > 30) {
69
- const fragment = document.createDocumentFragment();
70
- for (let i2 = 0; i2 < len; i2++) {
71
- const child = children[i2];
72
- if (child == null || child === false) continue;
73
- if (Array.isArray(child)) {
74
- const childLen = child.length;
75
- for (let j = 0; j < childLen; j++) {
76
- const c = child[j];
77
- if (c != null && c !== false) {
78
- this.renderToDOM(c, fragment);
79
- }
80
- }
81
- } else {
82
- this.renderToDOM(child, fragment);
83
- }
84
- }
85
- el.appendChild(fragment);
86
- } else {
87
- for (let i2 = 0; i2 < len; i2++) {
88
- const child = children[i2];
89
- if (child == null || child === false) continue;
90
- if (Array.isArray(child)) {
91
- const childLen = child.length;
92
- for (let j = 0; j < childLen; j++) {
93
- const c = child[j];
94
- if (c != null && c !== false) {
95
- this.renderToDOM(c, el);
96
- }
97
- }
98
- } else {
99
- this.renderToDOM(child, el);
100
- }
101
- }
102
- }
103
- parent.appendChild(el);
104
- }
105
- render(rootElement, vNode) {
106
- const el = typeof rootElement === "string" ? document.getElementById(rootElement.replace("#", "")) : rootElement;
107
- if (!el) {
108
- throw new Error(`Element not found: ${rootElement}`);
109
- }
110
- if (vNode.children && vNode.children.length > 500) {
111
- const fragment = document.createDocumentFragment();
112
- this.renderToDOM(vNode, fragment);
113
- el.appendChild(fragment);
114
- } else {
115
- this.renderToDOM(vNode, el);
116
- }
117
- return el;
118
- }
119
- batchRender(rootElement, vNodes) {
120
- const el = typeof rootElement === "string" ? document.getElementById(rootElement.replace("#", "")) : rootElement;
121
- if (!el) {
122
- throw new Error(`Element not found: ${rootElement}`);
123
- }
124
- const len = vNodes.length;
125
- if (len > 3e3) {
126
- const fragment = document.createDocumentFragment();
127
- let processed = 0;
128
- const chunkSize = 1500;
129
- const processChunk = () => {
130
- const end = Math.min(processed + chunkSize, len);
131
- for (let i2 = processed; i2 < end; i2++) {
132
- this.renderToDOM(vNodes[i2], fragment);
133
- }
134
- processed = end;
135
- if (processed >= len) {
136
- el.appendChild(fragment);
137
- } else {
138
- requestAnimationFrame(processChunk);
139
- }
140
- };
141
- processChunk();
142
- } else {
143
- const fragment = document.createDocumentFragment();
144
- for (let i2 = 0; i2 < len; i2++) {
145
- this.renderToDOM(vNodes[i2], fragment);
146
- }
147
- el.appendChild(fragment);
148
- }
149
- return el;
150
- }
151
- renderChunked(rootElement, vNodes, chunkSize = 5e3, onProgress) {
152
- const el = typeof rootElement === "string" ? document.getElementById(rootElement.replace("#", "")) : rootElement;
153
- if (!el) {
154
- throw new Error(`Element not found: ${rootElement}`);
155
- }
156
- const len = vNodes.length;
157
- let index = 0;
158
- const renderChunk = () => {
159
- const end = Math.min(index + chunkSize, len);
160
- const fragment = document.createDocumentFragment();
161
- for (let i2 = index; i2 < end; i2++) {
162
- this.renderToDOM(vNodes[i2], fragment);
163
- }
164
- el.appendChild(fragment);
165
- index = end;
166
- if (onProgress) onProgress(index, len);
167
- if (index < len) {
168
- requestAnimationFrame(renderChunk);
169
- }
170
- };
171
- requestAnimationFrame(renderChunk);
172
- return el;
173
- }
174
- renderToHead(...vNodes) {
175
- const head2 = document.head;
176
- if (head2) {
177
- for (const vNode of vNodes.flat()) {
178
- vNode && this.renderToDOM(vNode, head2);
179
- }
180
- }
181
- return head2;
182
- }
183
- addStyle(cssText) {
184
- const el = document.createElement("style");
185
- el.textContent = cssText;
186
- return document.head.appendChild(el);
187
- }
188
- addMeta(attrs) {
189
- const el = document.createElement("meta");
190
- for (const k in attrs) el.setAttribute(k, attrs[k]);
191
- return document.head.appendChild(el);
192
- }
193
- addLink(attrs) {
194
- const el = document.createElement("link");
195
- for (const k in attrs) el.setAttribute(k, attrs[k]);
196
- return document.head.appendChild(el);
197
- }
198
- setTitle(text2) {
199
- return document.title = text2;
200
- }
201
- // Reactive State Management
202
- createState(initialValue, options = {}) {
203
- let value = initialValue;
204
- const listeners = /* @__PURE__ */ new Set();
205
- let updateTimer = null;
206
- const { throttle: throttle2 = 0, deep = false } = options;
207
- const notify = () => {
208
- listeners.forEach((fn) => fn(value));
209
- };
210
- const scheduleUpdate = () => {
211
- if (throttle2 > 0) {
212
- if (!updateTimer) {
213
- updateTimer = setTimeout(() => {
214
- updateTimer = null;
215
- notify();
216
- }, throttle2);
217
- }
218
- } else {
219
- notify();
220
- }
221
- };
222
- return {
223
- get value() {
224
- return value;
225
- },
226
- set value(newValue) {
227
- const changed = deep ? JSON.stringify(value) !== JSON.stringify(newValue) : value !== newValue;
228
- if (changed) {
229
- value = newValue;
230
- scheduleUpdate();
231
- }
232
- },
233
- subscribe(fn) {
234
- listeners.add(fn);
235
- return () => {
236
- listeners.delete(fn);
237
- };
238
- },
239
- destroy() {
240
- listeners.clear();
241
- if (updateTimer) clearTimeout(updateTimer);
242
- }
243
- };
244
- }
245
- computed(states, computeFn) {
246
- const values = states.map((s2) => s2.value);
247
- const result = this.createState(computeFn(...values));
248
- states.forEach((state, index) => {
249
- state.subscribe((newValue) => {
250
- values[index] = newValue;
251
- result.value = computeFn(...values);
252
- });
253
- });
254
- return result;
255
- }
256
- effect(stateFn) {
257
- stateFn();
258
- }
259
- // Virtual scrolling helper for large lists
260
- createVirtualList(container, items, renderItem, itemHeight = 50, bufferSize = 5) {
261
- const viewportHeight = container.clientHeight;
262
- const totalHeight = items.length * itemHeight;
263
- let scrollTop = 0;
264
- const getVisibleRange = () => {
265
- const start = Math.max(0, Math.floor(scrollTop / itemHeight) - bufferSize);
266
- const end = Math.min(items.length, Math.ceil((scrollTop + viewportHeight) / itemHeight) + bufferSize);
267
- return { start, end };
268
- };
269
- const render = () => {
270
- const { start, end } = getVisibleRange();
271
- const wrapper = document.createElement("div");
272
- wrapper.style.cssText = `height:${totalHeight}px;position:relative`;
273
- for (let i2 = start; i2 < end; i2++) {
274
- const itemEl = document.createElement("div");
275
- itemEl.style.cssText = `position:absolute;top:${i2 * itemHeight}px;height:${itemHeight}px;width:100%`;
276
- this.renderToDOM(renderItem(items[i2], i2), itemEl);
277
- wrapper.appendChild(itemEl);
278
- }
279
- container.innerHTML = "";
280
- container.appendChild(wrapper);
281
- };
282
- const scrollHandler = () => {
283
- scrollTop = container.scrollTop;
284
- requestAnimationFrame(render);
285
- };
286
- container.addEventListener("scroll", scrollHandler);
287
- render();
288
- return {
289
- render,
290
- destroy: () => {
291
- container.removeEventListener("scroll", scrollHandler);
292
- container.innerHTML = "";
293
- }
294
- };
295
- }
296
- // Lazy load components
297
- lazy(loadFn) {
298
- let component = null;
299
- let loading = false;
300
- return async (...args) => {
301
- if (!component && !loading) {
302
- loading = true;
303
- component = await loadFn();
304
- loading = false;
305
- }
306
- return component ? component(...args) : { tagName: "div", props: { class: "loading" }, children: ["Loading..."] };
307
- };
308
- }
309
- // Memory management - cleanup unused elements
310
- cleanupUnusedElements(root) {
311
- const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT);
312
- const toRemove = [];
313
- while (walker.nextNode()) {
314
- const node = walker.currentNode;
315
- if (node.id && node.id.startsWith("r") && !this.elementCache.has(node)) {
316
- toRemove.push(node);
317
- }
318
- }
319
- toRemove.forEach((el) => el.remove());
320
- return toRemove.length;
321
- }
322
- // Server-Side Rendering - convert VNode to HTML string
323
- renderToString(vNode, options = {}) {
324
- const { pretty = false, indent = 0 } = options;
325
- const indentStr = pretty ? " ".repeat(indent) : "";
326
- const newLine = pretty ? "\n" : "";
327
- let resolvedVNode = this.resolveStateValue(vNode);
328
- resolvedVNode = this.unwrapReactive(resolvedVNode);
329
- if (Array.isArray(resolvedVNode)) {
330
- return resolvedVNode.map((child) => this.renderToString(child, options)).join("");
331
- }
332
- if (typeof resolvedVNode !== "object" || resolvedVNode === null) {
333
- if (resolvedVNode === null || resolvedVNode === void 0 || resolvedVNode === false) {
334
- return "";
335
- }
336
- return this.escapeHtml(String(resolvedVNode));
337
- }
338
- const { tagName, props, children } = resolvedVNode;
339
- const isSelfClosing = this.isSelfClosingTag(tagName);
340
- let html2 = `${indentStr}<${tagName}`;
341
- const attrs = this.propsToAttributes(props);
342
- if (attrs) {
343
- html2 += ` ${attrs}`;
344
- }
345
- if (isSelfClosing) {
346
- html2 += ` />${newLine}`;
347
- return html2;
348
- }
349
- html2 += ">";
350
- if (props.dangerouslySetInnerHTML) {
351
- html2 += props.dangerouslySetInnerHTML.__html;
352
- html2 += `</${tagName}>${newLine}`;
353
- return html2;
354
- }
355
- if (children && children.length > 0) {
356
- const resolvedChildren = children.map((c) => {
357
- const resolved = this.resolveStateValue(c);
358
- return this.unwrapReactive(resolved);
359
- });
360
- const hasComplexChildren = resolvedChildren.some(
361
- (c) => typeof c === "object" && c !== null && !Array.isArray(c) && "tagName" in c
362
- );
363
- if (pretty && hasComplexChildren) {
364
- html2 += newLine;
365
- for (const child of resolvedChildren) {
366
- if (child == null || child === false) continue;
367
- if (Array.isArray(child)) {
368
- for (const c of child) {
369
- if (c != null && c !== false) {
370
- html2 += this.renderToString(c, { pretty, indent: indent + 1 });
371
- }
372
- }
373
- } else {
374
- html2 += this.renderToString(child, { pretty, indent: indent + 1 });
375
- }
376
- }
377
- html2 += indentStr;
378
- } else {
379
- for (const child of resolvedChildren) {
380
- if (child == null || child === false) continue;
381
- if (Array.isArray(child)) {
382
- for (const c of child) {
383
- if (c != null && c !== false) {
384
- html2 += this.renderToString(c, { pretty: false, indent: 0 });
385
- }
386
- }
387
- } else {
388
- html2 += this.renderToString(child, { pretty: false, indent: 0 });
389
- }
390
- }
391
- }
392
- }
393
- html2 += `</${tagName}>${newLine}`;
394
- return html2;
395
- }
396
- resolveStateValue(value) {
397
- if (value && typeof value === "object" && "value" in value && "subscribe" in value) {
398
- return value.value;
399
- }
400
- return value;
401
- }
402
- isReactiveWrapper(vNode) {
403
- if (!vNode || typeof vNode !== "object" || !vNode.tagName) {
404
- return false;
405
- }
406
- return vNode.tagName === "span" && vNode.props?.id && typeof vNode.props.id === "string" && vNode.props.id.match(/^r[a-z0-9]{9}$/);
407
- }
408
- unwrapReactive(vNode) {
409
- if (!this.isReactiveWrapper(vNode)) {
410
- return vNode;
411
- }
412
- const children = vNode.children;
413
- if (!children || children.length === 0) {
414
- return "";
415
- }
416
- if (children.length === 1) {
417
- const child = children[0];
418
- if (child && typeof child === "object" && child.tagName === "span") {
419
- const props = child.props;
420
- const hasNoProps = !props || Object.keys(props).length === 0;
421
- const hasSingleStringChild = child.children && child.children.length === 1 && typeof child.children[0] === "string";
422
- if (hasNoProps && hasSingleStringChild) {
423
- return child.children[0];
424
- }
425
- }
426
- return this.unwrapReactive(child);
427
- }
428
- return children.map((c) => this.unwrapReactive(c));
429
- }
430
- escapeHtml(text2) {
431
- const htmlEscapes = {
432
- "&": "&amp;",
433
- "<": "&lt;",
434
- ">": "&gt;",
435
- '"': "&quot;",
436
- "'": "&#x27;"
437
- };
438
- return text2.replace(/[&<>"']/g, (char) => htmlEscapes[char]);
439
- }
440
- isSelfClosingTag(tagName) {
441
- const selfClosingTags = /* @__PURE__ */ new Set([
442
- "area",
443
- "base",
444
- "br",
445
- "col",
446
- "embed",
447
- "hr",
448
- "img",
449
- "input",
450
- "link",
451
- "meta",
452
- "param",
453
- "source",
454
- "track",
455
- "wbr"
456
- ]);
457
- return selfClosingTags.has(tagName.toLowerCase());
458
- }
459
- propsToAttributes(props) {
460
- const attrs = [];
461
- for (const key in props) {
462
- if (key === "children" || key === "dangerouslySetInnerHTML" || key === "ref") {
463
- continue;
464
- }
465
- let value = props[key];
466
- value = this.resolveStateValue(value);
467
- if (value == null || value === false) continue;
468
- if (key.startsWith("on") && typeof value === "function") {
469
- continue;
470
- }
471
- if (key === "className" || key === "class") {
472
- const className = Array.isArray(value) ? value.join(" ") : value;
473
- if (className) {
474
- attrs.push(`class="${this.escapeHtml(String(className))}"`);
475
- }
476
- continue;
477
- }
478
- if (key === "style") {
479
- const styleStr = this.styleToString(value);
480
- if (styleStr) {
481
- attrs.push(`style="${this.escapeHtml(styleStr)}"`);
482
- }
483
- continue;
484
- }
485
- if (value === true) {
486
- attrs.push(key);
487
- continue;
488
- }
489
- attrs.push(`${key}="${this.escapeHtml(String(value))}"`);
490
- }
491
- return attrs.join(" ");
492
- }
493
- styleToString(style2) {
494
- if (typeof style2 === "string") {
495
- return style2;
496
- }
497
- if (typeof style2 === "object" && style2 !== null) {
498
- const styles = [];
499
- for (const key in style2) {
500
- const cssKey = key.replace(/([A-Z])/g, "-$1").toLowerCase();
501
- styles.push(`${cssKey}:${style2[key]}`);
502
- }
503
- return styles.join(";");
504
- }
505
- return "";
506
- }
507
- isState(value) {
508
- return value && typeof value === "object" && "value" in value && "subscribe" in value && typeof value.subscribe === "function";
509
- }
510
- createReactiveChild(state, renderFn) {
511
- const currentValue = renderFn(state.value);
512
- if (typeof window !== "undefined" && typeof document !== "undefined") {
513
- const entry = { node: null, renderFn };
514
- this.reactiveNodes.set(state, entry);
515
- state.subscribe(() => {
516
- if (entry.node && entry.node.parentNode) {
517
- const newValue = renderFn(state.value);
518
- entry.node.textContent = String(newValue ?? "");
519
- }
520
- });
521
- }
522
- return currentValue;
523
- }
524
- jsonToVNode(json) {
525
- if (this.isState(json)) {
526
- return this.createReactiveChild(json, (v) => v);
527
- }
528
- if (json == null || typeof json === "boolean") {
529
- return json;
530
- }
531
- if (typeof json === "string" || typeof json === "number") {
532
- return json;
533
- }
534
- const { tag, attributes = {}, children } = json;
535
- const props = {};
536
- for (const key in attributes) {
537
- const value = attributes[key];
538
- if (key === "class") {
539
- props.className = this.isState(value) ? value.value : value;
540
- } else {
541
- props[key] = this.isState(value) ? value.value : value;
542
- }
543
- }
544
- const childrenArray = [];
545
- if (children != null) {
546
- if (Array.isArray(children)) {
547
- for (const child of children) {
548
- if (this.isState(child)) {
549
- childrenArray.push(this.createReactiveChild(child, (v) => v));
550
- } else {
551
- const converted = this.jsonToVNode(child);
552
- if (converted != null && converted !== false) {
553
- childrenArray.push(converted);
554
- }
555
- }
556
- }
557
- } else if (this.isState(children)) {
558
- childrenArray.push(this.createReactiveChild(children, (v) => v));
559
- } else if (typeof children === "object" && "tag" in children) {
560
- const converted = this.jsonToVNode(children);
561
- if (converted != null && converted !== false) {
562
- childrenArray.push(converted);
563
- }
564
- } else {
565
- childrenArray.push(children);
566
- }
567
- }
568
- return { tagName: tag, props, children: childrenArray };
569
- }
570
- vNodeJsonToVNode(json) {
571
- if (this.isState(json)) {
572
- return this.createReactiveChild(json, (v) => v);
573
- }
574
- if (json == null || typeof json === "boolean") {
575
- return json;
576
- }
577
- if (typeof json === "string" || typeof json === "number") {
578
- return json;
579
- }
580
- const { tagName, props = {}, children = [] } = json;
581
- const resolvedProps = {};
582
- for (const key in props) {
583
- const value = props[key];
584
- resolvedProps[key] = this.isState(value) ? value.value : value;
585
- }
586
- const childrenArray = [];
587
- for (const child of children) {
588
- if (this.isState(child)) {
589
- childrenArray.push(this.createReactiveChild(child, (v) => v));
590
- } else {
591
- const converted = this.vNodeJsonToVNode(child);
592
- if (converted != null && converted !== false) {
593
- childrenArray.push(converted);
594
- }
595
- }
596
- }
597
- return { tagName, props: resolvedProps, children: childrenArray };
598
- }
599
- renderJson(rootElement, json) {
600
- const vNode = this.jsonToVNode(json);
601
- if (!vNode || typeof vNode !== "object" || !("tagName" in vNode)) {
602
- throw new Error("Invalid JSON structure");
603
- }
604
- return this.render(rootElement, vNode);
605
- }
606
- renderVNode(rootElement, json) {
607
- const vNode = this.vNodeJsonToVNode(json);
608
- if (!vNode || typeof vNode !== "object" || !("tagName" in vNode)) {
609
- throw new Error("Invalid VNode JSON structure");
610
- }
611
- return this.render(rootElement, vNode);
612
- }
613
- renderJsonToString(json, options = {}) {
614
- const vNode = this.jsonToVNode(json);
615
- return this.renderToString(vNode, options);
616
- }
617
- renderVNodeToString(json, options = {}) {
618
- const vNode = this.vNodeJsonToVNode(json);
619
- return this.renderToString(vNode, options);
620
- }
621
- // Expose elementCache for reactive updates
622
- getElementCache() {
623
- return this.elementCache;
624
- }
625
- };
626
- var domNode = new DomNode();
627
-
628
- // src/state.ts
629
- var createState = (initial, options) => domNode.createState(initial, options);
630
- var computed = (states, fn) => domNode.computed(states, fn);
631
- var effect = (fn) => domNode.effect(fn);
632
- var batchRender = (container, vNodes) => domNode.batchRender(container, vNodes);
633
- var renderChunked = (container, vNodes, chunkSize, onProgress) => domNode.renderChunked(container, vNodes, chunkSize, onProgress);
634
- var createVirtualList = (container, items, renderItem, itemHeight, bufferSize) => domNode.createVirtualList(container, items, renderItem, itemHeight, bufferSize);
635
- var lazy = (loadFn) => domNode.lazy(loadFn);
636
- var cleanupUnused = (root) => domNode.cleanupUnusedElements(root);
637
- var throttle = (fn, delay) => {
638
- let timer = null;
639
- return (...args) => {
640
- if (!timer) {
641
- timer = setTimeout(() => {
642
- timer = null;
643
- fn(...args);
644
- }, delay);
645
- }
646
- };
647
- };
648
- var debounce = (fn, delay) => {
649
- let timer = null;
650
- return (...args) => {
651
- if (timer) clearTimeout(timer);
652
- timer = setTimeout(() => fn(...args), delay);
653
- };
654
- };
655
-
656
- // src/reactive.ts
657
- var reactive = (state, renderFn) => {
658
- let rafId = null;
659
- let elementRef = null;
660
- let placeholder = null;
661
- let isInDOM = true;
662
- const initialResult = renderFn(state.value);
663
- const isVNodeResult = initialResult && typeof initialResult === "object" && "tagName" in initialResult;
664
- const initialIsNull = initialResult == null || initialResult === false;
665
- state.subscribe(() => {
666
- if (rafId) cancelAnimationFrame(rafId);
667
- rafId = requestAnimationFrame(() => {
668
- if (!elementRef && !placeholder) return;
669
- const newResult = renderFn(state.value);
670
- const resultIsNull = newResult == null || newResult === false;
671
- if (resultIsNull) {
672
- if (isInDOM && elementRef) {
673
- placeholder = document.createComment("reactive");
674
- elementRef.parentNode?.replaceChild(placeholder, elementRef);
675
- isInDOM = false;
676
- }
677
- } else {
678
- if (!isInDOM && placeholder && elementRef) {
679
- placeholder.parentNode?.replaceChild(elementRef, placeholder);
680
- placeholder = null;
681
- isInDOM = true;
682
- }
683
- if (elementRef) {
684
- const fragment = document.createDocumentFragment();
685
- if (isVNodeResult && newResult && typeof newResult === "object" && "tagName" in newResult) {
686
- const vnode = newResult;
687
- const props = vnode.props;
688
- for (const key in props) {
689
- const value = props[key];
690
- if (key === "ref") continue;
691
- if (key === "class" || key === "className") {
692
- elementRef.className = Array.isArray(value) ? value.join(" ") : value || "";
693
- } else if (key === "style" && typeof value === "object") {
694
- const s2 = elementRef.style;
695
- for (const k in value) s2[k] = value[k];
696
- } else if (key.startsWith("on")) {
697
- elementRef[key.toLowerCase()] = value;
698
- } else if (value != null && value !== false) {
699
- elementRef.setAttribute(key, String(value === true ? "" : value));
700
- } else {
701
- elementRef.removeAttribute(key);
702
- }
703
- }
704
- for (const child of vnode.children) {
705
- domNode.renderToDOM(child, fragment);
706
- }
707
- } else {
708
- domNode.renderToDOM(newResult, fragment);
709
- }
710
- elementRef.textContent = "";
711
- elementRef.appendChild(fragment);
712
- domNode.getElementCache().set(elementRef, true);
713
- }
714
- }
715
- rafId = null;
716
- });
717
- });
718
- const refCallback = (el) => {
719
- elementRef = el;
720
- if (initialIsNull && el.parentNode) {
721
- placeholder = document.createComment("reactive");
722
- el.parentNode.replaceChild(placeholder, el);
723
- isInDOM = false;
724
- }
725
- };
726
- if (isVNodeResult) {
727
- const vnode = initialResult;
728
- return {
729
- tagName: vnode.tagName,
730
- props: { ...vnode.props, ref: refCallback },
731
- children: vnode.children
732
- };
733
- }
734
- return { tagName: "span", props: { ref: refCallback }, children: [initialResult] };
735
- };
736
- var reactiveAs = (tagName, state, renderFn, props = {}) => {
737
- let rafId = null;
738
- let elementRef = null;
739
- state.subscribe(() => {
740
- if (rafId) cancelAnimationFrame(rafId);
741
- rafId = requestAnimationFrame(() => {
742
- if (elementRef) {
743
- const fragment = document.createDocumentFragment();
744
- const newResult = renderFn(state.value);
745
- if (newResult == null || newResult === false) {
746
- elementRef.style.display = "none";
747
- elementRef.textContent = "";
748
- } else {
749
- elementRef.style.display = "";
750
- domNode.renderToDOM(newResult, fragment);
751
- elementRef.textContent = "";
752
- elementRef.appendChild(fragment);
753
- }
754
- domNode.getElementCache().set(elementRef, true);
755
- }
756
- rafId = null;
757
- });
758
- });
759
- const refCallback = (el) => {
760
- elementRef = el;
761
- };
762
- return { tagName, props: { ...props, ref: refCallback }, children: [renderFn(state.value)] };
763
- };
764
- var text = (state) => state && state.value !== void 0 ? reactive(state, (v) => ({ tagName: "span", props: {}, children: [String(v)] })) : String(state);
765
- var bindValue = (state) => ({
766
- value: state.value,
767
- oninput: (e) => {
768
- state.value = e.target.value;
769
- }
770
- });
771
- var bindChecked = (state) => ({
772
- checked: state.value,
773
- onchange: (e) => {
774
- state.value = e.target.checked;
775
- }
776
- });
777
-
778
- // src/CreateStyle.ts
779
- var CreateStyle = class {
780
- constructor() {
781
- this.variables = [];
782
- this.rules = [];
783
- this.mediaRules = [];
784
- this.keyframes = [];
785
- this.fontFaces = [];
786
- this.imports = [];
787
- this.containerRules = [];
788
- this.supportsRules = [];
789
- this.layerRules = [];
790
- this._layerOrder = [];
791
- }
792
- // CSS Variables
793
- addVar(name, value) {
794
- const cssVar = {
795
- name: name.startsWith("--") ? name : `--${name}`,
796
- value,
797
- toString() {
798
- return `var(${this.name})`;
799
- }
800
- };
801
- this.variables.push(cssVar);
802
- return cssVar;
803
- }
804
- var(variable, fallback) {
805
- const varName = typeof variable === "string" ? variable.startsWith("--") ? variable : `--${variable}` : variable.name;
806
- return fallback ? `var(${varName}, ${fallback})` : `var(${varName})`;
807
- }
808
- // Basic Selectors
809
- addTag(tag, styles) {
810
- const rule = { selector: tag, styles, type: "tag" };
811
- this.rules.push(rule);
812
- return rule;
813
- }
814
- addClass(name, styles) {
815
- const selector = name.startsWith(".") ? name : `.${name}`;
816
- const rule = { selector, styles, type: "class" };
817
- this.rules.push(rule);
818
- return rule;
819
- }
820
- addId(name, styles) {
821
- const selector = name.startsWith("#") ? name : `#${name}`;
822
- const rule = { selector, styles, type: "id" };
823
- this.rules.push(rule);
824
- return rule;
825
- }
826
- // Pseudo Selectors
827
- addPseudoClass(pseudo, styles, baseSelector) {
828
- const pseudoClass = pseudo.startsWith(":") ? pseudo : `:${pseudo}`;
829
- const selector = baseSelector ? `${baseSelector}${pseudoClass}` : pseudoClass;
830
- const rule = { selector, styles, type: "pseudo-class" };
831
- this.rules.push(rule);
832
- return rule;
833
- }
834
- addPseudoElement(pseudo, styles, baseSelector) {
835
- const pseudoElement = pseudo.startsWith("::") ? pseudo : `::${pseudo}`;
836
- const selector = baseSelector ? `${baseSelector}${pseudoElement}` : pseudoElement;
837
- const rule = { selector, styles, type: "pseudo-element" };
838
- this.rules.push(rule);
839
- return rule;
840
- }
841
- // Attribute Selectors
842
- addAttribute(attr, styles, baseSelector) {
843
- const attrSelector = attr.startsWith("[") ? attr : `[${attr}]`;
844
- const selector = baseSelector ? `${baseSelector}${attrSelector}` : attrSelector;
845
- const rule = { selector, styles, type: "attribute" };
846
- this.rules.push(rule);
847
- return rule;
848
- }
849
- attrEquals(attr, value, styles, baseSelector) {
850
- return this.addAttribute(`${attr}="${value}"`, styles, baseSelector);
851
- }
852
- attrContainsWord(attr, value, styles, baseSelector) {
853
- return this.addAttribute(`${attr}~="${value}"`, styles, baseSelector);
854
- }
855
- attrStartsWith(attr, value, styles, baseSelector) {
856
- return this.addAttribute(`${attr}^="${value}"`, styles, baseSelector);
857
- }
858
- attrEndsWith(attr, value, styles, baseSelector) {
859
- return this.addAttribute(`${attr}$="${value}"`, styles, baseSelector);
860
- }
861
- attrContains(attr, value, styles, baseSelector) {
862
- return this.addAttribute(`${attr}*="${value}"`, styles, baseSelector);
863
- }
864
- // Combinator Selectors
865
- descendant(ancestor, descendant, styles) {
866
- const selector = `${ancestor} ${descendant}`;
867
- const rule = { selector, styles, type: "custom" };
868
- this.rules.push(rule);
869
- return rule;
870
- }
871
- child(parent, childSel, styles) {
872
- const selector = `${parent} > ${childSel}`;
873
- const rule = { selector, styles, type: "custom" };
874
- this.rules.push(rule);
875
- return rule;
876
- }
877
- adjacentSibling(element, sibling, styles) {
878
- const selector = `${element} + ${sibling}`;
879
- const rule = { selector, styles, type: "custom" };
880
- this.rules.push(rule);
881
- return rule;
882
- }
883
- generalSibling(element, sibling, styles) {
884
- const selector = `${element} ~ ${sibling}`;
885
- const rule = { selector, styles, type: "custom" };
886
- this.rules.push(rule);
887
- return rule;
888
- }
889
- multiple(selectors, styles) {
890
- const selector = selectors.join(", ");
891
- const rule = { selector, styles, type: "custom" };
892
- this.rules.push(rule);
893
- return rule;
894
- }
895
- // Nesting (BEM-style)
896
- addName(name, styles) {
897
- const selector = name.startsWith("--") ? `&${name}` : `&--${name}`;
898
- const rule = { selector, styles, type: "name" };
899
- return rule;
900
- }
901
- nesting(parentRule, ...childRules) {
902
- parentRule.nested = childRules;
903
- return parentRule;
904
- }
905
- // @keyframes - Animations
906
- keyframe(name, steps) {
907
- const keyframeSteps = Object.entries(steps).map(([step, styles]) => ({
908
- step: step === "from" ? "from" : step === "to" ? "to" : `${step}%`,
909
- styles
910
- }));
911
- const kf = { name, steps: keyframeSteps };
912
- this.keyframes.push(kf);
913
- return kf;
914
- }
915
- keyframeFromTo(name, from, to) {
916
- return this.keyframe(name, { from, to });
917
- }
918
- // @font-face - Custom Fonts
919
- fontFace(options) {
920
- this.fontFaces.push(options);
921
- return options;
922
- }
923
- // @import - Import Stylesheets
924
- import(url, mediaQuery) {
925
- const importRule = mediaQuery ? `@import url("${url}") ${mediaQuery};` : `@import url("${url}");`;
926
- this.imports.push(importRule);
927
- return importRule;
928
- }
929
- // @media - Media Queries
930
- media(type, condition, rules) {
931
- const cssRules = Object.entries(rules).map(([selector, styles]) => ({
932
- selector,
933
- styles,
934
- type: "custom"
935
- }));
936
- const mediaRule = { type, condition, rules: cssRules };
937
- this.mediaRules.push(mediaRule);
938
- return mediaRule;
939
- }
940
- mediaScreen(condition, rules) {
941
- return this.media("screen", condition, rules);
942
- }
943
- mediaPrint(rules) {
944
- return this.media("print", "", rules);
945
- }
946
- mediaMinWidth(minWidth, rules) {
947
- return this.media("screen", `min-width: ${minWidth}`, rules);
948
- }
949
- mediaMaxWidth(maxWidth, rules) {
950
- return this.media("screen", `max-width: ${maxWidth}`, rules);
951
- }
952
- mediaDark(rules) {
953
- const cssRules = Object.entries(rules).map(([selector, styles]) => ({
954
- selector,
955
- styles,
956
- type: "custom"
957
- }));
958
- const mediaRule = { type: "", condition: "prefers-color-scheme: dark", rules: cssRules };
959
- this.mediaRules.push(mediaRule);
960
- return mediaRule;
961
- }
962
- mediaLight(rules) {
963
- const cssRules = Object.entries(rules).map(([selector, styles]) => ({
964
- selector,
965
- styles,
966
- type: "custom"
967
- }));
968
- const mediaRule = { type: "", condition: "prefers-color-scheme: light", rules: cssRules };
969
- this.mediaRules.push(mediaRule);
970
- return mediaRule;
971
- }
972
- mediaReducedMotion(rules) {
973
- const cssRules = Object.entries(rules).map(([selector, styles]) => ({
974
- selector,
975
- styles,
976
- type: "custom"
977
- }));
978
- const mediaRule = { type: "", condition: "prefers-reduced-motion: reduce", rules: cssRules };
979
- this.mediaRules.push(mediaRule);
980
- return mediaRule;
981
- }
982
- // @container - Container Queries
983
- container(condition, rules, name) {
984
- const cssRules = Object.entries(rules).map(([selector, styles]) => ({
985
- selector,
986
- styles,
987
- type: "custom"
988
- }));
989
- const containerRule = { name, condition, rules: cssRules };
990
- this.containerRules.push(containerRule);
991
- return containerRule;
992
- }
993
- addContainer(name, styles) {
994
- const containerStyles = { ...styles, containerName: name };
995
- return this.addClass(name, containerStyles);
996
- }
997
- // @supports - Feature Queries
998
- supports(condition, rules) {
999
- const cssRules = Object.entries(rules).map(([selector, styles]) => ({
1000
- selector,
1001
- styles,
1002
- type: "custom"
1003
- }));
1004
- const supportsRule = { condition, rules: cssRules };
1005
- this.supportsRules.push(supportsRule);
1006
- return supportsRule;
1007
- }
1008
- // @layer - Cascade Layers
1009
- layerOrder(...layers) {
1010
- this._layerOrder = layers;
1011
- }
1012
- layer(name, rules) {
1013
- const cssRules = Object.entries(rules).map(([selector, styles]) => ({
1014
- selector,
1015
- styles,
1016
- type: "custom"
1017
- }));
1018
- const layerRule = { name, rules: cssRules };
1019
- this.layerRules.push(layerRule);
1020
- return layerRule;
1021
- }
1022
- // Custom Rules
1023
- add(rules) {
1024
- const cssRules = Object.entries(rules).map(([selector, styles]) => {
1025
- const rule = { selector, styles, type: "custom" };
1026
- this.rules.push(rule);
1027
- return rule;
1028
- });
1029
- return cssRules;
1030
- }
1031
- important(value) {
1032
- return `${value} !important`;
1033
- }
1034
- // Utility Methods
1035
- toKebabCase(str) {
1036
- return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
1037
- }
1038
- stylesToString(styles, indent = " ") {
1039
- return Object.entries(styles).map(([prop, value]) => {
1040
- const cssValue = typeof value === "object" && value !== null && "name" in value ? `var(${value.name})` : value;
1041
- return `${indent}${this.toKebabCase(prop)}: ${cssValue};`;
1042
- }).join("\n");
1043
- }
1044
- renderRule(rule, indent = "") {
1045
- let css = `${indent}${rule.selector} {
1046
- ${this.stylesToString(rule.styles, indent + " ")}
1047
- `;
1048
- if (rule.nested && rule.nested.length > 0) {
1049
- for (const nestedRule of rule.nested) {
1050
- const nestedSelector = nestedRule.selector.startsWith("&") ? nestedRule.selector.replace(/&/g, rule.selector) : `${rule.selector} ${nestedRule.selector}`;
1051
- css += `
1052
- ${indent}${nestedSelector} {
1053
- ${this.stylesToString(nestedRule.styles, indent + " ")}
1054
- ${indent}}
1055
- `;
1056
- }
1057
- }
1058
- css += `${indent}}`;
1059
- return css;
1060
- }
1061
- renderMediaRule(media) {
1062
- const condition = media.type && media.condition ? `${media.type} and (${media.condition})` : media.type ? media.type : `(${media.condition})`;
1063
- let css = `@media ${condition} {
1064
- `;
1065
- for (const rule of media.rules) {
1066
- css += this.renderRule(rule, " ") + "\n";
1067
- }
1068
- css += "}";
1069
- return css;
1070
- }
1071
- renderKeyframes(kf) {
1072
- let css = `@keyframes ${kf.name} {
1073
- `;
1074
- for (const step of kf.steps) {
1075
- css += ` ${step.step} {
1076
- ${this.stylesToString(step.styles, " ")}
1077
- }
1078
- `;
1079
- }
1080
- css += "}";
1081
- return css;
1082
- }
1083
- renderFontFace(ff) {
1084
- let css = "@font-face {\n";
1085
- css += ` font-family: "${ff.fontFamily}";
1086
- `;
1087
- css += ` src: ${ff.src};
1088
- `;
1089
- if (ff.fontWeight) css += ` font-weight: ${ff.fontWeight};
1090
- `;
1091
- if (ff.fontStyle) css += ` font-style: ${ff.fontStyle};
1092
- `;
1093
- if (ff.fontDisplay) css += ` font-display: ${ff.fontDisplay};
1094
- `;
1095
- if (ff.unicodeRange) css += ` unicode-range: ${ff.unicodeRange};
1096
- `;
1097
- css += "}";
1098
- return css;
1099
- }
1100
- renderContainerRule(container) {
1101
- const nameStr = container.name ? `${container.name} ` : "";
1102
- let css = `@container ${nameStr}(${container.condition}) {
1103
- `;
1104
- for (const rule of container.rules) {
1105
- css += this.renderRule(rule, " ") + "\n";
1106
- }
1107
- css += "}";
1108
- return css;
1109
- }
1110
- renderSupportsRule(supports) {
1111
- let css = `@supports (${supports.condition}) {
1112
- `;
1113
- for (const rule of supports.rules) {
1114
- css += this.renderRule(rule, " ") + "\n";
1115
- }
1116
- css += "}";
1117
- return css;
1118
- }
1119
- renderLayerRule(layer) {
1120
- let css = `@layer ${layer.name} {
1121
- `;
1122
- for (const rule of layer.rules) {
1123
- css += this.renderRule(rule, " ") + "\n";
1124
- }
1125
- css += "}";
1126
- return css;
1127
- }
1128
- // Render Output
1129
- render(...additionalRules) {
1130
- const parts = [];
1131
- if (this.imports.length > 0) {
1132
- parts.push(this.imports.join("\n"));
1133
- }
1134
- if (this._layerOrder.length > 0) {
1135
- parts.push(`@layer ${this._layerOrder.join(", ")};`);
1136
- }
1137
- if (this.variables.length > 0) {
1138
- const varDeclarations = this.variables.map((v) => ` ${v.name}: ${v.value};`).join("\n");
1139
- parts.push(`:root {
1140
- ${varDeclarations}
1141
- }`);
1142
- }
1143
- for (const ff of this.fontFaces) {
1144
- parts.push(this.renderFontFace(ff));
1145
- }
1146
- for (const kf of this.keyframes) {
1147
- parts.push(this.renderKeyframes(kf));
1148
- }
1149
- const allRules = [...this.rules];
1150
- const allMediaRules = [...this.mediaRules];
1151
- const allKeyframes = [];
1152
- const allContainerRules = [...this.containerRules];
1153
- const allSupportsRules = [...this.supportsRules];
1154
- const allLayerRules = [...this.layerRules];
1155
- for (const item of additionalRules) {
1156
- if (!item) continue;
1157
- if (Array.isArray(item)) {
1158
- allRules.push(...item);
1159
- } else if ("condition" in item && "rules" in item && !("name" in item && "steps" in item)) {
1160
- if ("type" in item) {
1161
- allMediaRules.push(item);
1162
- } else if ("name" in item && typeof item.name === "string") {
1163
- allContainerRules.push(item);
1164
- } else {
1165
- allSupportsRules.push(item);
1166
- }
1167
- } else if ("name" in item && "steps" in item) {
1168
- allKeyframes.push(item);
1169
- } else if ("name" in item && "rules" in item) {
1170
- allLayerRules.push(item);
1171
- } else {
1172
- allRules.push(item);
1173
- }
1174
- }
1175
- for (const kf of allKeyframes) {
1176
- parts.push(this.renderKeyframes(kf));
1177
- }
1178
- for (const layer of allLayerRules) {
1179
- parts.push(this.renderLayerRule(layer));
1180
- }
1181
- for (const rule of allRules) {
1182
- parts.push(this.renderRule(rule));
1183
- }
1184
- for (const supports of allSupportsRules) {
1185
- parts.push(this.renderSupportsRule(supports));
1186
- }
1187
- for (const container of allContainerRules) {
1188
- parts.push(this.renderContainerRule(container));
1189
- }
1190
- for (const media of allMediaRules) {
1191
- parts.push(this.renderMediaRule(media));
1192
- }
1193
- return parts.join("\n\n");
1194
- }
1195
- inject(styleId) {
1196
- const css = this.render();
1197
- const style2 = document.createElement("style");
1198
- if (styleId) style2.id = styleId;
1199
- style2.textContent = css;
1200
- document.head.appendChild(style2);
1201
- return style2;
1202
- }
1203
- clear() {
1204
- this.variables = [];
1205
- this.rules = [];
1206
- this.mediaRules = [];
1207
- this.keyframes = [];
1208
- this.fontFaces = [];
1209
- this.imports = [];
1210
- this.containerRules = [];
1211
- this.supportsRules = [];
1212
- this.layerRules = [];
1213
- this._layerOrder = [];
1214
- }
1215
- };
1216
-
1217
- // src/router.ts
1218
- function matchRoute(pattern, path) {
1219
- const patternParts = pattern.split("/").filter(Boolean);
1220
- const pathParts = path.split("/").filter(Boolean);
1221
- if (pattern.endsWith("*")) {
1222
- const basePattern = pattern.slice(0, -1);
1223
- if (path.startsWith(basePattern) || basePattern === "/" || pattern === "*") {
1224
- return { "*": path.slice(basePattern.length) };
1225
- }
1226
- }
1227
- if (patternParts.length !== pathParts.length) return null;
1228
- const params = {};
1229
- for (let i2 = 0; i2 < patternParts.length; i2++) {
1230
- const patternPart = patternParts[i2];
1231
- const pathPart = pathParts[i2];
1232
- if (patternPart.startsWith(":")) {
1233
- params[patternPart.slice(1)] = decodeURIComponent(pathPart);
1234
- } else if (patternPart !== pathPart) {
1235
- return null;
1236
- }
1237
- }
1238
- return params;
1239
- }
1240
- function createRouter(options) {
1241
- const { mode = "history", base: base2 = "", routes } = options;
1242
- const globalGuards = [];
1243
- const parseQuery = (search) => {
1244
- const query = {};
1245
- const params = new URLSearchParams(search);
1246
- params.forEach((value, key) => {
1247
- query[key] = value;
1248
- });
1249
- return query;
1250
- };
1251
- const getCurrentPath = () => {
1252
- if (mode === "hash") {
1253
- return window.location.hash.slice(1) || "/";
1254
- }
1255
- return window.location.pathname.replace(base2, "") || "/";
1256
- };
1257
- const parseLocation = (path) => {
1258
- const [pathPart, queryPart = ""] = path.split("?");
1259
- const [cleanPath, hash = ""] = pathPart.split("#");
1260
- return {
1261
- path: cleanPath || "/",
1262
- params: {},
1263
- query: parseQuery(queryPart),
1264
- hash: hash ? "#" + hash : ""
1265
- };
1266
- };
1267
- const findRoute = (path) => {
1268
- for (const route of routes) {
1269
- const params = matchRoute(route.path, path);
1270
- if (params !== null) {
1271
- return { route, params };
1272
- }
1273
- }
1274
- return null;
1275
- };
1276
- const currentRoute = domNode.createState(parseLocation(getCurrentPath()));
1277
- const navigate = (path, replace = false) => {
1278
- const location = parseLocation(path);
1279
- const match = findRoute(location.path);
1280
- if (match) {
1281
- location.params = match.params;
1282
- }
1283
- for (const guard of globalGuards) {
1284
- const result = guard(location, currentRoute.value);
1285
- if (result === false) return;
1286
- if (typeof result === "string") {
1287
- navigate(result, replace);
1288
- return;
1289
- }
1290
- }
1291
- if (match?.route.beforeEnter) {
1292
- const result = match.route.beforeEnter(location, currentRoute.value);
1293
- if (result === false) return;
1294
- if (typeof result === "string") {
1295
- navigate(result, replace);
1296
- return;
1297
- }
1298
- }
1299
- const url = mode === "hash" ? "#" + path : base2 + path;
1300
- if (replace) {
1301
- window.history.replaceState({ path }, "", url);
1302
- } else {
1303
- window.history.pushState({ path }, "", url);
1304
- }
1305
- currentRoute.value = location;
1306
- };
1307
- const handlePopState = () => {
1308
- const path = getCurrentPath();
1309
- const location = parseLocation(path);
1310
- const match = findRoute(location.path);
1311
- if (match) {
1312
- location.params = match.params;
1313
- }
1314
- currentRoute.value = location;
1315
- };
1316
- if (typeof window !== "undefined") {
1317
- window.addEventListener("popstate", handlePopState);
1318
- }
1319
- return {
1320
- currentRoute,
1321
- push: (path) => navigate(path, false),
1322
- replace: (path) => navigate(path, true),
1323
- back: () => window.history.back(),
1324
- forward: () => window.history.forward(),
1325
- go: (delta) => window.history.go(delta),
1326
- beforeEach: (guard) => {
1327
- globalGuards.push(guard);
1328
- },
1329
- destroy: () => {
1330
- if (typeof window !== "undefined") {
1331
- window.removeEventListener("popstate", handlePopState);
1332
- }
1333
- currentRoute.destroy();
1334
- }
1335
- };
1336
- }
1337
- function createRouterView(router, options) {
1338
- const { routes, notFound } = options;
1339
- return () => {
1340
- const location = router.currentRoute.value;
1341
- const match = routes.find((r) => matchRoute(r.path, location.path) !== null);
1342
- if (match) {
1343
- const params = matchRoute(match.path, location.path) || {};
1344
- const component = match.component({ ...params, ...location.query });
1345
- if (typeof component === "object" && component !== null && "tagName" in component) {
1346
- return component;
1347
- }
1348
- return { tagName: "span", props: {}, children: [component] };
1349
- }
1350
- if (notFound) {
1351
- const component = notFound(location.params);
1352
- if (typeof component === "object" && component !== null && "tagName" in component) {
1353
- return component;
1354
- }
1355
- return { tagName: "span", props: {}, children: [component] };
1356
- }
1357
- return { tagName: "div", props: {}, children: ["404 - Not Found"] };
1358
- };
1359
- }
1360
- var routerLink = (router, props, ...children) => {
1361
- return {
1362
- tagName: "a",
1363
- props: {
1364
- ...props,
1365
- href: props.to,
1366
- onclick: (e) => {
1367
- e.preventDefault();
1368
- router.push(props.to);
1369
- }
1370
- },
1371
- children
1372
- };
1373
- };
1374
-
1375
- // src/elements.ts
1376
- var createElementFactory = (tag) => {
1377
- return function(props, ...rest) {
1378
- if (arguments.length === 0) {
1379
- return { tagName: tag, props: {}, children: [] };
1380
- }
1381
- let actualProps = {};
1382
- let startIndex = 1;
1383
- const isState = props && typeof props === "object" && "value" in props && "subscribe" in props;
1384
- const isVNode = props && typeof props === "object" && "tagName" in props;
1385
- const isChild = typeof props !== "object" || Array.isArray(props) || props === null || isState || isVNode;
1386
- if (isChild) {
1387
- actualProps = {};
1388
- startIndex = 0;
1389
- } else {
1390
- actualProps = props;
1391
- }
1392
- const args = startIndex === 0 ? [props, ...rest] : rest;
1393
- if (args.length === 0) {
1394
- return { tagName: tag, props: actualProps, children: [] };
1395
- }
1396
- if (args.length === 1) {
1397
- const child = args[0];
1398
- if (child == null || child === false) {
1399
- return { tagName: tag, props: actualProps, children: [] };
1400
- }
1401
- if (Array.isArray(child)) {
1402
- const flatChildren2 = [];
1403
- const len = child.length;
1404
- for (let j = 0; j < len; j++) {
1405
- const c = child[j];
1406
- if (c != null && c !== false) {
1407
- flatChildren2.push(c);
1408
- }
1409
- }
1410
- return { tagName: tag, props: actualProps, children: flatChildren2 };
1411
- }
1412
- return { tagName: tag, props: actualProps, children: [child] };
1413
- }
1414
- const flatChildren = [];
1415
- for (let i2 = 0; i2 < args.length; i2++) {
1416
- const child = args[i2];
1417
- if (child == null || child === false) continue;
1418
- if (Array.isArray(child)) {
1419
- const len = child.length;
1420
- for (let j = 0; j < len; j++) {
1421
- const c = child[j];
1422
- if (c != null && c !== false) {
1423
- flatChildren.push(c);
1424
- }
1425
- }
1426
- } else {
1427
- flatChildren.push(child);
1428
- }
1429
- }
1430
- return { tagName: tag, props: actualProps, children: flatChildren };
1431
- };
1432
- };
1433
- var tags = [
1434
- "html",
1435
- "head",
1436
- "body",
1437
- "title",
1438
- "base",
1439
- "link",
1440
- "meta",
1441
- "style",
1442
- "address",
1443
- "article",
1444
- "aside",
1445
- "footer",
1446
- "header",
1447
- "h1",
1448
- "h2",
1449
- "h3",
1450
- "h4",
1451
- "h5",
1452
- "h6",
1453
- "main",
1454
- "nav",
1455
- "section",
1456
- "blockquote",
1457
- "dd",
1458
- "div",
1459
- "dl",
1460
- "dt",
1461
- "figcaption",
1462
- "figure",
1463
- "hr",
1464
- "li",
1465
- "ol",
1466
- "p",
1467
- "pre",
1468
- "ul",
1469
- "a",
1470
- "abbr",
1471
- "b",
1472
- "bdi",
1473
- "bdo",
1474
- "br",
1475
- "cite",
1476
- "code",
1477
- "data",
1478
- "dfn",
1479
- "em",
1480
- "i",
1481
- "kbd",
1482
- "mark",
1483
- "q",
1484
- "rp",
1485
- "rt",
1486
- "ruby",
1487
- "s",
1488
- "samp",
1489
- "small",
1490
- "span",
1491
- "strong",
1492
- "sub",
1493
- "sup",
1494
- "time",
1495
- "u",
1496
- "wbr",
1497
- "area",
1498
- "audio",
1499
- "img",
1500
- "map",
1501
- "track",
1502
- "video",
1503
- "embed",
1504
- "iframe",
1505
- "object",
1506
- "param",
1507
- "picture",
1508
- "portal",
1509
- "source",
1510
- "canvas",
1511
- "noscript",
1512
- "script",
1513
- "del",
1514
- "ins",
1515
- "caption",
1516
- "col",
1517
- "colgroup",
1518
- "table",
1519
- "tbody",
1520
- "td",
1521
- "tfoot",
1522
- "th",
1523
- "thead",
1524
- "tr",
1525
- "button",
1526
- "datalist",
1527
- "fieldset",
1528
- "form",
1529
- "input",
1530
- "label",
1531
- "legend",
1532
- "meter",
1533
- "optgroup",
1534
- "option",
1535
- "output",
1536
- "progress",
1537
- "select",
1538
- "textarea",
1539
- "details",
1540
- "dialog",
1541
- "menu",
1542
- "summary",
1543
- "slot",
1544
- "template"
1545
- ];
1546
- var svgTags = [
1547
- "svg",
1548
- "circle",
1549
- "rect",
1550
- "path",
1551
- "line",
1552
- "polyline",
1553
- "polygon",
1554
- "ellipse",
1555
- "g",
1556
- "text",
1557
- "tspan",
1558
- "defs",
1559
- "linearGradient",
1560
- "radialGradient",
1561
- "stop",
1562
- "pattern",
1563
- "mask",
1564
- "clipPath",
1565
- "use",
1566
- "symbol",
1567
- "marker",
1568
- "image",
1569
- "foreignObject",
1570
- "animate",
1571
- "animateTransform",
1572
- "animateMotion",
1573
- "set",
1574
- "filter",
1575
- "feBlend",
1576
- "feColorMatrix",
1577
- "feComponentTransfer",
1578
- "feComposite",
1579
- "feConvolveMatrix",
1580
- "feDiffuseLighting",
1581
- "feDisplacementMap",
1582
- "feFlood",
1583
- "feGaussianBlur",
1584
- "feMorphology",
1585
- "feOffset",
1586
- "feSpecularLighting",
1587
- "feTile",
1588
- "feTurbulence"
1589
- ];
1590
- var mathTags = [
1591
- "math",
1592
- "mi",
1593
- "mn",
1594
- "mo",
1595
- "ms",
1596
- "mtext",
1597
- "mrow",
1598
- "mfrac",
1599
- "msqrt",
1600
- "mroot",
1601
- "msub",
1602
- "msup"
1603
- ];
1604
- var elements = {};
1605
- tags.forEach((tag) => {
1606
- elements[tag] = createElementFactory(tag);
1607
- });
1608
- svgTags.forEach((tag) => {
1609
- const name = "svg" + tag.charAt(0).toUpperCase() + tag.slice(1);
1610
- elements[name] = createElementFactory(tag);
1611
- });
1612
- mathTags.forEach((tag) => {
1613
- const name = "math" + tag.charAt(0).toUpperCase() + tag.slice(1);
1614
- elements[name] = createElementFactory(tag);
1615
- });
1616
- elements.varElement = createElementFactory("var");
1617
- var {
1618
- html,
1619
- head,
1620
- body,
1621
- title,
1622
- base,
1623
- link,
1624
- meta,
1625
- style,
1626
- address,
1627
- article,
1628
- aside,
1629
- footer,
1630
- header,
1631
- h1,
1632
- h2,
1633
- h3,
1634
- h4,
1635
- h5,
1636
- h6,
1637
- main,
1638
- nav,
1639
- section,
1640
- blockquote,
1641
- dd,
1642
- div,
1643
- dl,
1644
- dt,
1645
- figcaption,
1646
- figure,
1647
- hr,
1648
- li,
1649
- ol,
1650
- p,
1651
- pre,
1652
- ul,
1653
- a,
1654
- abbr,
1655
- b,
1656
- bdi,
1657
- bdo,
1658
- br,
1659
- cite,
1660
- code,
1661
- data,
1662
- dfn,
1663
- em,
1664
- i,
1665
- kbd,
1666
- mark,
1667
- q,
1668
- rp,
1669
- rt,
1670
- ruby,
1671
- s,
1672
- samp,
1673
- small,
1674
- span,
1675
- strong,
1676
- sub,
1677
- sup,
1678
- time,
1679
- u,
1680
- wbr,
1681
- area,
1682
- audio,
1683
- img,
1684
- map,
1685
- track,
1686
- video,
1687
- embed,
1688
- iframe,
1689
- object,
1690
- param,
1691
- picture,
1692
- portal,
1693
- source,
1694
- canvas,
1695
- noscript,
1696
- script,
1697
- del,
1698
- ins,
1699
- caption,
1700
- col,
1701
- colgroup,
1702
- table,
1703
- tbody,
1704
- td,
1705
- tfoot,
1706
- th,
1707
- thead,
1708
- tr,
1709
- button,
1710
- datalist,
1711
- fieldset,
1712
- form,
1713
- input,
1714
- label,
1715
- legend,
1716
- meter,
1717
- optgroup,
1718
- option,
1719
- output,
1720
- progress,
1721
- select,
1722
- textarea,
1723
- details,
1724
- dialog,
1725
- menu,
1726
- summary,
1727
- slot,
1728
- template,
1729
- svgSvg,
1730
- svgCircle,
1731
- svgRect,
1732
- svgPath,
1733
- svgLine,
1734
- svgPolyline,
1735
- svgPolygon,
1736
- svgEllipse,
1737
- svgG,
1738
- svgText,
1739
- svgTspan,
1740
- svgDefs,
1741
- svgLinearGradient,
1742
- svgRadialGradient,
1743
- svgStop,
1744
- svgPattern,
1745
- svgMask,
1746
- svgClipPath,
1747
- svgUse,
1748
- svgSymbol,
1749
- svgMarker,
1750
- svgImage,
1751
- svgForeignObject,
1752
- svgAnimate,
1753
- svgAnimateTransform,
1754
- svgAnimateMotion,
1755
- svgSet,
1756
- svgFilter,
1757
- svgFeBlend,
1758
- svgFeColorMatrix,
1759
- svgFeComponentTransfer,
1760
- svgFeComposite,
1761
- svgFeConvolveMatrix,
1762
- svgFeDiffuseLighting,
1763
- svgFeDisplacementMap,
1764
- svgFeFlood,
1765
- svgFeGaussianBlur,
1766
- svgFeMorphology,
1767
- svgFeOffset,
1768
- svgFeSpecularLighting,
1769
- svgFeTile,
1770
- svgFeTurbulence,
1771
- mathMath,
1772
- mathMi,
1773
- mathMn,
1774
- mathMo,
1775
- mathMs,
1776
- mathMtext,
1777
- mathMrow,
1778
- mathMfrac,
1779
- mathMsqrt,
1780
- mathMroot,
1781
- mathMsub,
1782
- mathMsup,
1783
- varElement
1784
- } = elements;
1
+ var Z=Object.defineProperty;var Q=(i,e)=>{for(var t in e)Z(i,t,{get:e[t],enumerable:true});};var E=class{constructor(){this.elementCache=new WeakMap;this.reactiveNodes=new Map;}createElement(e,t={},r=[]){return {tagName:e,props:t,children:r}}renderToDOM(e,t){if(e==null||e===false)return;if(typeof e!="object"){t.appendChild(document.createTextNode(String(e)));return}let{tagName:r,props:n,children:s}=e,a=r==="svg"||r[0]==="s"&&r[1]==="v"&&r[2]==="g"||t.namespaceURI==="http://www.w3.org/2000/svg",o=a?document.createElementNS("http://www.w3.org/2000/svg",r.replace("svg","").toLowerCase()||r):document.createElement(r);for(let p in n){let d=n[p];if(d==null||d===false)continue;let c=p.charCodeAt(0);if(c===99&&(p.length<6||p[5]==="N")){let h=Array.isArray(d)?d.join(" "):d;a?o.setAttribute("class",h):o.className=h;}else if(c===115&&p.length===5)if(typeof d=="string")o.style.cssText=d;else {let h=o.style;for(let g in d)h[g]=d[g];}else c===111&&p.charCodeAt(1)===110?o[p.toLowerCase()]=d:c===100&&p.length>20?o.innerHTML=d.__html:c===114&&p.length===3?setTimeout(()=>{typeof d=="function"?d(o):d.current=o;},0):o.setAttribute(p,d===true?"":String(d));}let u=s.length;if(!u){t.appendChild(o);return}let l=p=>{for(let d=0;d<u;d++){let c=s[d];if(!(c==null||c===false))if(Array.isArray(c))for(let h=0,g=c.length;h<g;h++){let v=c[h];v!=null&&v!==false&&this.renderToDOM(v,p);}else this.renderToDOM(c,p);}};if(u>30){let p=document.createDocumentFragment();l(p),o.appendChild(p);}else l(o);t.appendChild(o);}render(e,t){let r=typeof e=="string"?document.getElementById(e.replace("#","")):e;if(!r)throw new Error(`Element not found: ${e}`);if(t.children&&t.children.length>500){let n=document.createDocumentFragment();this.renderToDOM(t,n),r.appendChild(n);}else this.renderToDOM(t,r);return r}batchRender(e,t){let r=typeof e=="string"?document.getElementById(e.replace("#","")):e;if(!r)throw new Error(`Element not found: ${e}`);let n=t.length;if(n>3e3){let s=document.createDocumentFragment(),a=0,o=1500,u=()=>{let l=Math.min(a+o,n);for(let p=a;p<l;p++)this.renderToDOM(t[p],s);a=l,a>=n?r.appendChild(s):requestAnimationFrame(u);};u();}else {let s=document.createDocumentFragment();for(let a=0;a<n;a++)this.renderToDOM(t[a],s);r.appendChild(s);}return r}renderChunked(e,t,r=5e3,n){let s=typeof e=="string"?document.getElementById(e.replace("#","")):e;if(!s)throw new Error(`Element not found: ${e}`);let a=t.length,o=0,u=()=>{let l=Math.min(o+r,a),p=document.createDocumentFragment();for(let d=o;d<l;d++)this.renderToDOM(t[d],p);s.appendChild(p),o=l,n&&n(o,a),o<a&&requestAnimationFrame(u);};return requestAnimationFrame(u),s}renderToHead(...e){let t=document.head;if(t)for(let r of e.flat())r&&this.renderToDOM(r,t);return t}addStyle(e){let t=document.createElement("style");return t.textContent=e,document.head.appendChild(t)}addMeta(e){let t=document.createElement("meta");for(let r in e)t.setAttribute(r,e[r]);return document.head.appendChild(t)}addLink(e){let t=document.createElement("link");for(let r in e)t.setAttribute(r,e[r]);return document.head.appendChild(t)}setTitle(e){return document.title=e}createState(e,t={}){let r=e,n=new Set,s=null,{throttle:a=0,deep:o=false}=t,u=()=>n.forEach(p=>p(r)),l=()=>{a>0?s||(s=setTimeout(()=>{s=null,u();},a)):u();};return {get value(){return r},set value(p){(o?JSON.stringify(r)!==JSON.stringify(p):r!==p)&&(r=p,l());},subscribe(p){return n.add(p),()=>n.delete(p)},destroy(){n.clear(),s&&clearTimeout(s);}}}computed(e,t){let r=e.map(s=>s.value),n=this.createState(t(...r));return e.forEach((s,a)=>{s.subscribe(o=>{r[a]=o,n.value=t(...r);});}),n}effect(e){e();}createVirtualList(e,t,r,n=50,s=5){let a=e.clientHeight,o=t.length*n,u=0,l=()=>{let c=Math.max(0,Math.floor(u/n)-s),h=Math.min(t.length,Math.ceil((u+a)/n)+s);return {start:c,end:h}},p=()=>{let{start:c,end:h}=l(),g=document.createElement("div");g.style.cssText=`height:${o}px;position:relative`;for(let v=c;v<h;v++){let m=document.createElement("div");m.style.cssText=`position:absolute;top:${v*n}px;height:${n}px;width:100%`,this.renderToDOM(r(t[v],v),m),g.appendChild(m);}e.innerHTML="",e.appendChild(g);},d=()=>{u=e.scrollTop,requestAnimationFrame(p);};return e.addEventListener("scroll",d),p(),{render:p,destroy:()=>{e.removeEventListener("scroll",d),e.innerHTML="";}}}lazy(e){let t=null,r=false;return async(...n)=>(!t&&!r&&(r=true,t=await e(),r=false),t?t(...n):{tagName:"div",props:{class:"loading"},children:["Loading..."]})}cleanupUnusedElements(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT),r=[];for(;t.nextNode();){let n=t.currentNode;n.id&&n.id.startsWith("r")&&!this.elementCache.has(n)&&r.push(n);}return r.forEach(n=>n.remove()),r.length}renderToString(e,t={}){let{pretty:r=false,indent:n=0}=t,s=r?" ".repeat(n):"",a=r?`
2
+ `:"",o=this.resolveStateValue(e);if(o=this.unwrapReactive(o),Array.isArray(o))return o.map(g=>this.renderToString(g,t)).join("");if(typeof o!="object"||o===null)return o==null||o===false?"":this.escapeHtml(String(o));let{tagName:u,props:l,children:p}=o,d=this.isSelfClosingTag(u),c=`${s}<${u}`,h=this.propsToAttributes(l);if(h&&(c+=` ${h}`),d)return c+=` />${a}`,c;if(c+=">",l.dangerouslySetInnerHTML)return c+=l.dangerouslySetInnerHTML.__html,c+=`</${u}>${a}`,c;if(p&&p.length>0){let g=p.map(m=>{let y=this.resolveStateValue(m);return this.unwrapReactive(y)}),v=g.some(m=>typeof m=="object"&&m!==null&&!Array.isArray(m)&&"tagName"in m);if(r&&v){c+=a;for(let m of g)if(!(m==null||m===false))if(Array.isArray(m))for(let y of m)y!=null&&y!==false&&(c+=this.renderToString(y,{pretty:r,indent:n+1}));else c+=this.renderToString(m,{pretty:r,indent:n+1});c+=s;}else for(let m of g)if(!(m==null||m===false))if(Array.isArray(m))for(let y of m)y!=null&&y!==false&&(c+=this.renderToString(y,{pretty:false,indent:0}));else c+=this.renderToString(m,{pretty:false,indent:0});}return c+=`</${u}>${a}`,c}resolveStateValue(e){return e&&typeof e=="object"&&"value"in e&&"subscribe"in e?e.value:e}isReactiveWrapper(e){return !e||typeof e!="object"||!e.tagName?false:e.tagName==="span"&&e.props?.id&&typeof e.props.id=="string"&&e.props.id.match(/^r[a-z0-9]{9}$/)}unwrapReactive(e){if(!this.isReactiveWrapper(e))return e;let t=e.children;if(!t||t.length===0)return "";if(t.length===1){let r=t[0];if(r&&typeof r=="object"&&r.tagName==="span"){let n=r.props,s=!n||Object.keys(n).length===0,a=r.children&&r.children.length===1&&typeof r.children[0]=="string";if(s&&a)return r.children[0]}return this.unwrapReactive(r)}return t.map(r=>this.unwrapReactive(r))}escapeHtml(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"};return e.replace(/[&<>"']/g,r=>t[r])}isSelfClosingTag(e){return new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]).has(e.toLowerCase())}propsToAttributes(e){let t=[];for(let r in e){if(r==="children"||r==="dangerouslySetInnerHTML"||r==="ref")continue;let n=e[r];if(n=this.resolveStateValue(n),!(n==null||n===false)&&!(r.startsWith("on")&&typeof n=="function")){if(r==="className"||r==="class"){let s=Array.isArray(n)?n.join(" "):n;s&&t.push(`class="${this.escapeHtml(String(s))}"`);continue}if(r==="style"){let s=this.styleToString(n);s&&t.push(`style="${this.escapeHtml(s)}"`);continue}if(n===true){t.push(r);continue}t.push(`${r}="${this.escapeHtml(String(n))}"`);}}return t.join(" ")}styleToString(e){if(typeof e=="string")return e;if(typeof e=="object"&&e!==null){let t=[];for(let r in e){let n=r.replace(/([A-Z])/g,"-$1").toLowerCase();t.push(`${n}:${e[r]}`);}return t.join(";")}return ""}isState(e){return e&&typeof e=="object"&&"value"in e&&"subscribe"in e&&typeof e.subscribe=="function"}createReactiveChild(e,t){let r=t(e.value);if(typeof window<"u"&&typeof document<"u"){let n={node:null,renderFn:t};this.reactiveNodes.set(e,n),e.subscribe(()=>{if(n.node&&n.node.parentNode){let s=t(e.value);n.node.textContent=String(s??"");}});}return r}jsonToVNode(e){if(this.isState(e))return this.createReactiveChild(e,o=>o);if(e==null||typeof e=="boolean"||typeof e=="string"||typeof e=="number")return e;let{tag:t,attributes:r={},children:n}=e,s={};for(let o in r){let u=r[o];o==="class"?s.className=this.isState(u)?u.value:u:s[o]=this.isState(u)?u.value:u;}let a=[];if(n!=null)if(Array.isArray(n))for(let o of n)if(this.isState(o))a.push(this.createReactiveChild(o,u=>u));else {let u=this.jsonToVNode(o);u!=null&&u!==false&&a.push(u);}else if(this.isState(n))a.push(this.createReactiveChild(n,o=>o));else if(typeof n=="object"&&"tag"in n){let o=this.jsonToVNode(n);o!=null&&o!==false&&a.push(o);}else a.push(n);return {tagName:t,props:s,children:a}}vNodeJsonToVNode(e){if(this.isState(e))return this.createReactiveChild(e,o=>o);if(e==null||typeof e=="boolean"||typeof e=="string"||typeof e=="number")return e;let{tagName:t,props:r={},children:n=[]}=e,s={};for(let o in r){let u=r[o];s[o]=this.isState(u)?u.value:u;}let a=[];for(let o of n)if(this.isState(o))a.push(this.createReactiveChild(o,u=>u));else {let u=this.vNodeJsonToVNode(o);u!=null&&u!==false&&a.push(u);}return {tagName:t,props:s,children:a}}renderJson(e,t){let r=this.jsonToVNode(t);if(!r||typeof r!="object"||!("tagName"in r))throw new Error("Invalid JSON structure");return this.render(e,r)}renderVNode(e,t){let r=this.vNodeJsonToVNode(t);if(!r||typeof r!="object"||!("tagName"in r))throw new Error("Invalid VNode JSON structure");return this.render(e,r)}renderJsonToString(e,t={}){let r=this.jsonToVNode(e);return this.renderToString(r,t)}renderVNodeToString(e,t={}){let r=this.vNodeJsonToVNode(e);return this.renderToString(r,t)}getElementCache(){return this.elementCache}},f=new E;var C=(i,e)=>f.createState(i,e),x=(i,e)=>f.computed(i,e),w=i=>f.effect(i),V=(i,e)=>f.batchRender(i,e),$=(i,e,t,r)=>f.renderChunked(i,e,t,r),k=(i,e,t,r,n)=>f.createVirtualList(i,e,t,r,n),F=i=>f.lazy(i),A=i=>f.cleanupUnusedElements(i),H=(i,e)=>{let t=null;return (...r)=>{t||(t=setTimeout(()=>{t=null,i(...r);},e));}},O=(i,e)=>{let t=null;return (...r)=>{t&&clearTimeout(t),t=setTimeout(()=>i(...r),e);}};var M=class{constructor(e,t,r){this.key=e;this.wsUrl=r;this.ws=null;this.pendingUpdates=[];this.localState=C(t),this.previousValue=t,this.connect();}get value(){return this.localState.value}set value(e){this.previousValue=this.localState.value,this.localState.value=e,this.sendToServer(e);}get state(){return this.localState}onChange(e){return this.localState.subscribe(t=>{let r=this.previousValue;this.previousValue=t,e(t,r);})}update(e){this.value=e(this.value);}connect(){if(typeof window>"u")return;let e=this.wsUrl||`ws://${location.host}`;this.ws=new WebSocket(e),this.ws.addEventListener("open",()=>{for(this.subscribe();this.pendingUpdates.length>0;){let t=this.pendingUpdates.shift();this.sendToServer(t);}}),this.ws.addEventListener("message",t=>{this.handleMessage(t.data);}),this.ws.addEventListener("close",()=>{setTimeout(()=>this.connect(),1e3);}),this.ws.addEventListener("error",t=>{console.error("[SharedState] WebSocket error:",t);});}subscribe(){!this.ws||this.ws.readyState!==WebSocket.OPEN||this.ws.send(JSON.stringify({type:"state:subscribe",key:this.key}));}handleMessage(e){try{let t=JSON.parse(e);if(t.key!==this.key)return;(t.type==="state:init"||t.type==="state:update")&&(this.localState.value=t.value);}catch{}}sendToServer(e){if(this.ws){if(this.ws.readyState!==WebSocket.OPEN){this.pendingUpdates.push(e);return}this.ws.send(JSON.stringify({type:"state:change",key:this.key,value:e}));}}disconnect(){this.ws&&(this.ws.close(),this.ws=null);}destroy(){this.disconnect(),this.localState.destroy();}};function j(i,e,t){return new M(i,e,t)}var P=class{constructor(){this.states=new Map;}create(e,t,r){if(this.states.has(e))return this.states.get(e);let n=new M(e,t,r);return this.states.set(e,n),n}get(e){return this.states.get(e)}delete(e){let t=this.states.get(e);return t?(t.destroy(),this.states.delete(e)):false}clear(){this.states.forEach(e=>e.destroy()),this.states.clear();}},J=new P;var L=(i,e)=>{let t=null,r=null,n=null,s=true,a=e(i.value),o=a&&typeof a=="object"&&"tagName"in a,u=a==null||a===false,l=()=>{if(!r&&!n)return;let d=e(i.value);if(d==null||d===false)s&&r&&(n=document.createComment("reactive"),r.parentNode?.replaceChild(n,r),s=false);else if(!s&&n&&r&&(n.parentNode?.replaceChild(r,n),n=null,s=true),r){let h=document.createDocumentFragment();if(o&&d&&typeof d=="object"&&"tagName"in d){let{props:g,children:v}=d;for(let m in g){let y=g[m];if(m!=="ref")if(m==="class"||m==="className")r.className=Array.isArray(y)?y.join(" "):y||"";else if(m==="style"&&typeof y=="object"){let T=r.style;for(let z in y)T[z]=y[z];}else m.startsWith("on")?r[m.toLowerCase()]=y:y!=null&&y!==false?r.setAttribute(m,String(y===true?"":y)):r.removeAttribute(m);}for(let m of v)f.renderToDOM(m,h);}else f.renderToDOM(d,h);r.textContent="",r.appendChild(h),f.getElementCache().set(r,true);}};i.subscribe(()=>{t&&cancelAnimationFrame(t),t=requestAnimationFrame(()=>{l(),t=null;});});let p=d=>{r=d,u&&d.parentNode&&(n=document.createComment("reactive"),d.parentNode.replaceChild(n,d),s=false);};if(o){let d=a;return {tagName:d.tagName,props:{...d.props,ref:p},children:d.children}}return {tagName:"span",props:{ref:p},children:[a]}},D=(i,e,t,r={})=>{let n=null,s=null;return e.subscribe(()=>{n&&cancelAnimationFrame(n),n=requestAnimationFrame(()=>{if(s){let o=document.createDocumentFragment(),u=t(e.value);u==null||u===false?(s.style.display="none",s.textContent=""):(s.style.display="",f.renderToDOM(u,o),s.textContent="",s.appendChild(o)),f.getElementCache().set(s,true);}n=null;});}),{tagName:i,props:{...r,ref:o=>{s=o;}},children:[t(e.value)]}},W=i=>i&&i.value!==void 0?L(i,e=>({tagName:"span",props:{},children:[String(e)]})):String(i),K=i=>({value:i.value,oninput:e=>{i.value=e.target.value;}}),q=i=>({checked:i.value,onchange:e=>{i.value=e.target.checked;}});var N=class{constructor(){this.variables=[];this.rules=[];this.mediaRules=[];this.keyframes=[];this.fontFaces=[];this.imports=[];this.containerRules=[];this.supportsRules=[];this.layerRules=[];this._layerOrder=[];}addVar(e,t){let r={name:e.startsWith("--")?e:`--${e}`,value:t,toString(){return `var(${this.name})`}};return this.variables.push(r),r}var(e,t){let r=typeof e=="string"?e.startsWith("--")?e:`--${e}`:e.name;return t?`var(${r}, ${t})`:`var(${r})`}addTag(e,t){let r={selector:e,styles:t,type:"tag"};return this.rules.push(r),r}addClass(e,t){let n={selector:e.startsWith(".")?e:`.${e}`,styles:t,type:"class"};return this.rules.push(n),n}addId(e,t){let n={selector:e.startsWith("#")?e:`#${e}`,styles:t,type:"id"};return this.rules.push(n),n}addPseudoClass(e,t,r){let n=e.startsWith(":")?e:`:${e}`,a={selector:r?`${r}${n}`:n,styles:t,type:"pseudo-class"};return this.rules.push(a),a}addPseudoElement(e,t,r){let n=e.startsWith("::")?e:`::${e}`,a={selector:r?`${r}${n}`:n,styles:t,type:"pseudo-element"};return this.rules.push(a),a}addAttribute(e,t,r){let n=e.startsWith("[")?e:`[${e}]`,a={selector:r?`${r}${n}`:n,styles:t,type:"attribute"};return this.rules.push(a),a}attrEquals(e,t,r,n){return this.addAttribute(`${e}="${t}"`,r,n)}attrContainsWord(e,t,r,n){return this.addAttribute(`${e}~="${t}"`,r,n)}attrStartsWith(e,t,r,n){return this.addAttribute(`${e}^="${t}"`,r,n)}attrEndsWith(e,t,r,n){return this.addAttribute(`${e}$="${t}"`,r,n)}attrContains(e,t,r,n){return this.addAttribute(`${e}*="${t}"`,r,n)}descendant(e,t,r){let s={selector:`${e} ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}child(e,t,r){let s={selector:`${e} > ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}adjacentSibling(e,t,r){let s={selector:`${e} + ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}generalSibling(e,t,r){let s={selector:`${e} ~ ${t}`,styles:r,type:"custom"};return this.rules.push(s),s}multiple(e,t){let n={selector:e.join(", "),styles:t,type:"custom"};return this.rules.push(n),n}addName(e,t){return {selector:e.startsWith("--")?`&${e}`:`&--${e}`,styles:t,type:"name"}}nesting(e,...t){return e.nested=t,e}keyframe(e,t){let r=Object.entries(t).map(([s,a])=>({step:s==="from"?"from":s==="to"?"to":`${s}%`,styles:a})),n={name:e,steps:r};return this.keyframes.push(n),n}keyframeFromTo(e,t,r){return this.keyframe(e,{from:t,to:r})}fontFace(e){return this.fontFaces.push(e),e}import(e,t){let r=t?`@import url("${e}") ${t};`:`@import url("${e}");`;return this.imports.push(r),r}media(e,t,r){let n=Object.entries(r).map(([a,o])=>({selector:a,styles:o,type:"custom"})),s={type:e,condition:t,rules:n};return this.mediaRules.push(s),s}mediaScreen(e,t){return this.media("screen",e,t)}mediaPrint(e){return this.media("print","",e)}mediaMinWidth(e,t){return this.media("screen",`min-width: ${e}`,t)}mediaMaxWidth(e,t){return this.media("screen",`max-width: ${e}`,t)}mediaDark(e){let r={type:"",condition:"prefers-color-scheme: dark",rules:Object.entries(e).map(([n,s])=>({selector:n,styles:s,type:"custom"}))};return this.mediaRules.push(r),r}mediaLight(e){let r={type:"",condition:"prefers-color-scheme: light",rules:Object.entries(e).map(([n,s])=>({selector:n,styles:s,type:"custom"}))};return this.mediaRules.push(r),r}mediaReducedMotion(e){let r={type:"",condition:"prefers-reduced-motion: reduce",rules:Object.entries(e).map(([n,s])=>({selector:n,styles:s,type:"custom"}))};return this.mediaRules.push(r),r}container(e,t,r){let n=Object.entries(t).map(([a,o])=>({selector:a,styles:o,type:"custom"})),s={name:r,condition:e,rules:n};return this.containerRules.push(s),s}addContainer(e,t){let r={...t,containerName:e};return this.addClass(e,r)}supports(e,t){let r=Object.entries(t).map(([s,a])=>({selector:s,styles:a,type:"custom"})),n={condition:e,rules:r};return this.supportsRules.push(n),n}layerOrder(...e){this._layerOrder=e;}layer(e,t){let r=Object.entries(t).map(([s,a])=>({selector:s,styles:a,type:"custom"})),n={name:e,rules:r};return this.layerRules.push(n),n}add(e){return Object.entries(e).map(([r,n])=>{let s={selector:r,styles:n,type:"custom"};return this.rules.push(s),s})}important(e){return `${e} !important`}toKebabCase(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}stylesToString(e,t=" "){return Object.entries(e).map(([r,n])=>{let s=typeof n=="object"&&n!==null&&"name"in n?`var(${n.name})`:n;return `${t}${this.toKebabCase(r)}: ${s};`}).join(`
3
+ `)}renderRule(e,t=""){let r=`${t}${e.selector} {
4
+ ${this.stylesToString(e.styles,t+" ")}
5
+ `;if(e.nested&&e.nested.length>0)for(let n of e.nested){let s=n.selector.startsWith("&")?n.selector.replace(/&/g,e.selector):`${e.selector} ${n.selector}`;r+=`
6
+ ${t}${s} {
7
+ ${this.stylesToString(n.styles,t+" ")}
8
+ ${t}}
9
+ `;}return r+=`${t}}`,r}renderMediaRule(e){let r=`@media ${e.type&&e.condition?`${e.type} and (${e.condition})`:e.type?e.type:`(${e.condition})`} {
10
+ `;for(let n of e.rules)r+=this.renderRule(n," ")+`
11
+ `;return r+="}",r}renderKeyframes(e){let t=`@keyframes ${e.name} {
12
+ `;for(let r of e.steps)t+=` ${r.step} {
13
+ ${this.stylesToString(r.styles," ")}
14
+ }
15
+ `;return t+="}",t}renderFontFace(e){let t=`@font-face {
16
+ `;return t+=` font-family: "${e.fontFamily}";
17
+ `,t+=` src: ${e.src};
18
+ `,e.fontWeight&&(t+=` font-weight: ${e.fontWeight};
19
+ `),e.fontStyle&&(t+=` font-style: ${e.fontStyle};
20
+ `),e.fontDisplay&&(t+=` font-display: ${e.fontDisplay};
21
+ `),e.unicodeRange&&(t+=` unicode-range: ${e.unicodeRange};
22
+ `),t+="}",t}renderContainerRule(e){let r=`@container ${e.name?`${e.name} `:""}(${e.condition}) {
23
+ `;for(let n of e.rules)r+=this.renderRule(n," ")+`
24
+ `;return r+="}",r}renderSupportsRule(e){let t=`@supports (${e.condition}) {
25
+ `;for(let r of e.rules)t+=this.renderRule(r," ")+`
26
+ `;return t+="}",t}renderLayerRule(e){let t=`@layer ${e.name} {
27
+ `;for(let r of e.rules)t+=this.renderRule(r," ")+`
28
+ `;return t+="}",t}render(...e){let t=[];if(this.imports.length>0&&t.push(this.imports.join(`
29
+ `)),this._layerOrder.length>0&&t.push(`@layer ${this._layerOrder.join(", ")};`),this.variables.length>0){let l=this.variables.map(p=>` ${p.name}: ${p.value};`).join(`
30
+ `);t.push(`:root {
31
+ ${l}
32
+ }`);}for(let l of this.fontFaces)t.push(this.renderFontFace(l));for(let l of this.keyframes)t.push(this.renderKeyframes(l));let r=[...this.rules],n=[...this.mediaRules],s=[],a=[...this.containerRules],o=[...this.supportsRules],u=[...this.layerRules];for(let l of e)l&&(Array.isArray(l)?r.push(...l):"condition"in l&&"rules"in l&&!("name"in l&&"steps"in l)?"type"in l?n.push(l):"name"in l&&typeof l.name=="string"?a.push(l):o.push(l):"name"in l&&"steps"in l?s.push(l):"name"in l&&"rules"in l?u.push(l):r.push(l));for(let l of s)t.push(this.renderKeyframes(l));for(let l of u)t.push(this.renderLayerRule(l));for(let l of r)t.push(this.renderRule(l));for(let l of o)t.push(this.renderSupportsRule(l));for(let l of a)t.push(this.renderContainerRule(l));for(let l of n)t.push(this.renderMediaRule(l));return t.join(`
1785
33
 
1786
- // src/index.ts
1787
- var renderToHead = (...vNodes) => domNode.renderToHead(...vNodes);
1788
- var addStyle = (css) => domNode.addStyle(css);
1789
- var addMeta = (attrs) => domNode.addMeta(attrs);
1790
- var addLink = (attrs) => domNode.addLink(attrs);
1791
- var setTitle = (text2) => domNode.setTitle(text2);
1792
- var renderToString = (vNode, options) => domNode.renderToString(vNode, options);
1793
- var jsonToVNode = (json) => domNode.jsonToVNode(json);
1794
- var renderJson = (container, json) => domNode.renderJson(container, json);
1795
- var renderJsonToString = (json, options) => domNode.renderJsonToString(json, options);
1796
- var vNodeJsonToVNode = (json) => domNode.vNodeJsonToVNode(json);
1797
- var renderVNode = (container, json) => domNode.renderVNode(container, json);
1798
- var renderVNodeToString = (json, options) => domNode.renderVNodeToString(json, options);
1799
- if (typeof window !== "undefined") {
1800
- Object.assign(window, {
1801
- domNode,
1802
- createElementFactory,
1803
- renderToHead,
1804
- addStyle,
1805
- addMeta,
1806
- addLink,
1807
- setTitle,
1808
- createState,
1809
- computed,
1810
- effect,
1811
- reactive,
1812
- reactiveAs,
1813
- text,
1814
- bindValue,
1815
- bindChecked,
1816
- batchRender,
1817
- renderChunked,
1818
- createVirtualList,
1819
- lazy,
1820
- cleanupUnused,
1821
- renderToString,
1822
- jsonToVNode,
1823
- renderJson,
1824
- renderJsonToString,
1825
- vNodeJsonToVNode,
1826
- renderVNode,
1827
- renderVNodeToString,
1828
- throttle,
1829
- debounce,
1830
- CreateStyle,
1831
- createRouter,
1832
- createRouterView,
1833
- routerLink,
1834
- ...elements
1835
- });
1836
- }
1837
- export {
1838
- CreateStyle,
1839
- DomNode,
1840
- a,
1841
- abbr,
1842
- addLink,
1843
- addMeta,
1844
- addStyle,
1845
- address,
1846
- area,
1847
- article,
1848
- aside,
1849
- audio,
1850
- b,
1851
- base,
1852
- batchRender,
1853
- bdi,
1854
- bdo,
1855
- bindChecked,
1856
- bindValue,
1857
- blockquote,
1858
- body,
1859
- br,
1860
- button,
1861
- canvas,
1862
- caption,
1863
- cite,
1864
- cleanupUnused,
1865
- code,
1866
- col,
1867
- colgroup,
1868
- computed,
1869
- createElementFactory,
1870
- createRouter,
1871
- createRouterView,
1872
- createState,
1873
- createVirtualList,
1874
- data,
1875
- datalist,
1876
- dd,
1877
- debounce,
1878
- del,
1879
- details,
1880
- dfn,
1881
- dialog,
1882
- div,
1883
- dl,
1884
- domNode,
1885
- dt,
1886
- effect,
1887
- elements,
1888
- em,
1889
- embed,
1890
- fieldset,
1891
- figcaption,
1892
- figure,
1893
- footer,
1894
- form,
1895
- h1,
1896
- h2,
1897
- h3,
1898
- h4,
1899
- h5,
1900
- h6,
1901
- head,
1902
- header,
1903
- hr,
1904
- html,
1905
- i,
1906
- iframe,
1907
- img,
1908
- input,
1909
- ins,
1910
- jsonToVNode,
1911
- kbd,
1912
- label,
1913
- lazy,
1914
- legend,
1915
- li,
1916
- link,
1917
- main,
1918
- map,
1919
- mark,
1920
- mathMath,
1921
- mathMfrac,
1922
- mathMi,
1923
- mathMn,
1924
- mathMo,
1925
- mathMroot,
1926
- mathMrow,
1927
- mathMs,
1928
- mathMsqrt,
1929
- mathMsub,
1930
- mathMsup,
1931
- mathMtext,
1932
- menu,
1933
- meta,
1934
- meter,
1935
- nav,
1936
- noscript,
1937
- object,
1938
- ol,
1939
- optgroup,
1940
- option,
1941
- output,
1942
- p,
1943
- param,
1944
- picture,
1945
- portal,
1946
- pre,
1947
- progress,
1948
- q,
1949
- reactive,
1950
- reactiveAs,
1951
- renderChunked,
1952
- renderJson,
1953
- renderJsonToString,
1954
- renderToHead,
1955
- renderToString,
1956
- renderVNode,
1957
- renderVNodeToString,
1958
- routerLink,
1959
- rp,
1960
- rt,
1961
- ruby,
1962
- s,
1963
- samp,
1964
- script,
1965
- section,
1966
- select,
1967
- setTitle,
1968
- slot,
1969
- small,
1970
- source,
1971
- span,
1972
- strong,
1973
- style,
1974
- sub,
1975
- summary,
1976
- sup,
1977
- svgAnimate,
1978
- svgAnimateMotion,
1979
- svgAnimateTransform,
1980
- svgCircle,
1981
- svgClipPath,
1982
- svgDefs,
1983
- svgEllipse,
1984
- svgFeBlend,
1985
- svgFeColorMatrix,
1986
- svgFeComponentTransfer,
1987
- svgFeComposite,
1988
- svgFeConvolveMatrix,
1989
- svgFeDiffuseLighting,
1990
- svgFeDisplacementMap,
1991
- svgFeFlood,
1992
- svgFeGaussianBlur,
1993
- svgFeMorphology,
1994
- svgFeOffset,
1995
- svgFeSpecularLighting,
1996
- svgFeTile,
1997
- svgFeTurbulence,
1998
- svgFilter,
1999
- svgForeignObject,
2000
- svgG,
2001
- svgImage,
2002
- svgLine,
2003
- svgLinearGradient,
2004
- svgMarker,
2005
- svgMask,
2006
- svgPath,
2007
- svgPattern,
2008
- svgPolygon,
2009
- svgPolyline,
2010
- svgRadialGradient,
2011
- svgRect,
2012
- svgSet,
2013
- svgStop,
2014
- svgSvg,
2015
- svgSymbol,
2016
- svgText,
2017
- svgTspan,
2018
- svgUse,
2019
- table,
2020
- tbody,
2021
- td,
2022
- template,
2023
- text,
2024
- textarea,
2025
- tfoot,
2026
- th,
2027
- thead,
2028
- throttle,
2029
- time,
2030
- title,
2031
- tr,
2032
- track,
2033
- u,
2034
- ul,
2035
- vNodeJsonToVNode,
2036
- varElement,
2037
- video,
2038
- wbr
2039
- };
34
+ `)}inject(e){let t=this.render(),r=document.createElement("style");return e&&(r.id=e),r.textContent=t,document.head.appendChild(r),r}clear(){this.variables=[],this.rules=[],this.mediaRules=[],this.keyframes=[],this.fontFaces=[],this.imports=[],this.containerRules=[],this.supportsRules=[],this.layerRules=[],this._layerOrder=[];}};function I(i,e){let t=i.split("/").filter(Boolean),r=e.split("/").filter(Boolean);if(i.endsWith("*")){let s=i.slice(0,-1);if(e.startsWith(s)||s==="/"||i==="*")return {"*":e.slice(s.length)}}if(t.length!==r.length)return null;let n={};for(let s=0;s<t.length;s++){let a=t[s],o=r[s];if(a.startsWith(":"))n[a.slice(1)]=decodeURIComponent(o);else if(a!==o)return null}return n}function G(i){let{mode:e="history",base:t="",routes:r}=i,n=[],s=c=>{let h={};return new URLSearchParams(c).forEach((v,m)=>{h[m]=v;}),h},a=()=>e==="hash"?window.location.hash.slice(1)||"/":window.location.pathname.replace(t,"")||"/",o=c=>{let[h,g=""]=c.split("?"),[v,m=""]=h.split("#");return {path:v||"/",params:{},query:s(g),hash:m?"#"+m:""}},u=c=>{for(let h of r){let g=I(h.path,c);if(g!==null)return {route:h,params:g}}return null},l=f.createState(o(a())),p=(c,h=false)=>{let g=o(c),v=u(g.path);v&&(g.params=v.params);for(let y of n){let T=y(g,l.value);if(T===false)return;if(typeof T=="string"){p(T,h);return}}if(v?.route.beforeEnter){let y=v.route.beforeEnter(g,l.value);if(y===false)return;if(typeof y=="string"){p(y,h);return}}let m=e==="hash"?"#"+c:t+c;h?window.history.replaceState({path:c},"",m):window.history.pushState({path:c},"",m),l.value=g;},d=()=>{let c=a(),h=o(c),g=u(h.path);g&&(h.params=g.params),l.value=h;};return typeof window<"u"&&window.addEventListener("popstate",d),{currentRoute:l,push:c=>p(c,false),replace:c=>p(c,true),back:()=>window.history.back(),forward:()=>window.history.forward(),go:c=>window.history.go(c),beforeEach:c=>{n.push(c);},destroy:()=>{typeof window<"u"&&window.removeEventListener("popstate",d),l.destroy();}}}function U(i,e){let{routes:t,notFound:r}=e;return ()=>{let n=i.currentRoute.value,s=t.find(a=>I(a.path,n.path)!==null);if(s){let a=I(s.path,n.path)||{},o=s.component({...a,...n.query});return typeof o=="object"&&o!==null&&"tagName"in o?o:{tagName:"span",props:{},children:[o]}}if(r){let a=r(n.params);return typeof a=="object"&&a!==null&&"tagName"in a?a:{tagName:"span",props:{},children:[a]}}return {tagName:"div",props:{},children:["404 - Not Found"]}}}var B=(i,e,...t)=>({tagName:"a",props:{...e,href:e.to,onclick:r=>{r.preventDefault(),i.push(e.to);}},children:t});var b=i=>function(e,...t){if(!arguments.length)return {tagName:i,props:{},children:[]};let r=e&&typeof e=="object"&&"value"in e&&"subscribe"in e,n=e&&typeof e=="object"&&"tagName"in e,s=typeof e!="object"||Array.isArray(e)||e===null||r||n,a=s?{}:e,o=s?[e,...t]:t;if(!o.length)return {tagName:i,props:a,children:[]};let u=[];for(let l=0,p=o.length;l<p;l++){let d=o[l];if(!(d==null||d===false))if(Array.isArray(d))for(let c=0,h=d.length;c<h;c++){let g=d[c];g!=null&&g!==false&&u.push(g);}else u.push(d);}return {tagName:i,props:a,children:u}},X=["html","head","body","title","base","link","meta","style","address","article","aside","footer","header","h1","h2","h3","h4","h5","h6","main","nav","section","blockquote","dd","div","dl","dt","figcaption","figure","hr","li","ol","p","pre","ul","a","abbr","b","bdi","bdo","br","cite","code","data","dfn","em","i","kbd","mark","q","rp","rt","ruby","s","samp","small","span","strong","sub","sup","time","u","wbr","area","audio","img","map","track","video","embed","iframe","object","param","picture","portal","source","canvas","noscript","script","del","ins","caption","col","colgroup","table","tbody","td","tfoot","th","thead","tr","button","datalist","fieldset","form","input","label","legend","meter","optgroup","option","output","progress","select","textarea","details","dialog","menu","summary","slot","template"],Y=["svg","circle","rect","path","line","polyline","polygon","ellipse","g","text","tspan","defs","linearGradient","radialGradient","stop","pattern","mask","clipPath","use","symbol","marker","image","foreignObject","animate","animateTransform","animateMotion","set","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence"],ee=["math","mi","mn","mo","ms","mtext","mrow","mfrac","msqrt","mroot","msub","msup"],R={};X.forEach(i=>{R[i]=b(i);});Y.forEach(i=>{let e="svg"+i.charAt(0).toUpperCase()+i.slice(1);R[e]=b(i);});ee.forEach(i=>{let e="math"+i.charAt(0).toUpperCase()+i.slice(1);R[e]=b(i);});R.varElement=b("var");var {html:te,head:re,body:ne,title:se,base:oe,link:ie,meta:ae,style:le,address:ue,article:ce,aside:de,footer:pe,header:me,h1:he,h2:ge,h3:fe,h4:ye,h5:Se,h6:ve,main:Re,nav:be,section:Te,blockquote:Ce,dd:Me,div:Ne,dl:Ee,dt:Le,figcaption:xe,figure:we,hr:Ve,li:$e,ol:ke,p:Fe,pre:Ae,ul:He,a:Oe,abbr:Pe,b:je,bdi:Je,bdo:De,br:We,cite:Ke,code:qe,data:Ie,dfn:Ge,em:Ue,i:Be,kbd:_e,mark:ze,q:Ze,rp:Qe,rt:Xe,ruby:Ye,s:et,samp:tt,small:rt,span:nt,strong:st,sub:ot,sup:it,time:at,u:lt,wbr:ut,area:ct,audio:dt,img:pt,map:mt,track:ht,video:gt,embed:ft,iframe:yt,object:St,param:vt,picture:Rt,portal:bt,source:Tt,canvas:Ct,noscript:Mt,script:Nt,del:Et,ins:Lt,caption:xt,col:wt,colgroup:Vt,table:$t,tbody:kt,td:Ft,tfoot:At,th:Ht,thead:Ot,tr:Pt,button:jt,datalist:Jt,fieldset:Dt,form:Wt,input:Kt,label:qt,legend:It,meter:Gt,optgroup:Ut,option:Bt,output:_t,progress:zt,select:Zt,textarea:Qt,details:Xt,dialog:Yt,menu:er,summary:tr,slot:rr,template:nr,svgSvg:sr,svgCircle:or,svgRect:ir,svgPath:ar,svgLine:lr,svgPolyline:ur,svgPolygon:cr,svgEllipse:dr,svgG:pr,svgText:mr,svgTspan:hr,svgDefs:gr,svgLinearGradient:fr,svgRadialGradient:yr,svgStop:Sr,svgPattern:vr,svgMask:Rr,svgClipPath:br,svgUse:Tr,svgSymbol:Cr,svgMarker:Mr,svgImage:Nr,svgForeignObject:Er,svgAnimate:Lr,svgAnimateTransform:xr,svgAnimateMotion:wr,svgSet:Vr,svgFilter:$r,svgFeBlend:kr,svgFeColorMatrix:Fr,svgFeComponentTransfer:Ar,svgFeComposite:Hr,svgFeConvolveMatrix:Or,svgFeDiffuseLighting:Pr,svgFeDisplacementMap:jr,svgFeFlood:Jr,svgFeGaussianBlur:Dr,svgFeMorphology:Wr,svgFeOffset:Kr,svgFeSpecularLighting:qr,svgFeTile:Ir,svgFeTurbulence:Gr,mathMath:Ur,mathMi:Br,mathMn:_r,mathMo:zr,mathMs:Zr,mathMtext:Qr,mathMrow:Xr,mathMfrac:Yr,mathMsqrt:en,mathMroot:tn,mathMsub:rn,mathMsup:nn,varElement:sn}=R;var _={};Q(_,{commentNode:()=>mn,createEl:()=>ln,createMathEl:()=>cn,createSvgEl:()=>un,doc:()=>S,el:()=>on,elClass:()=>gn,elId:()=>hn,elName:()=>yn,elTag:()=>fn,els:()=>an,fragment:()=>dn,textNode:()=>pn});var S=document,on=S.querySelector.bind(S),an=S.querySelectorAll.bind(S),ln=S.createElement.bind(S),un=S.createElementNS.bind(S,"http://www.w3.org/2000/svg"),cn=S.createElementNS.bind(S,"http://www.w3.org/1998/Math/MathML"),dn=S.createDocumentFragment.bind(S),pn=S.createTextNode.bind(S),mn=S.createComment.bind(S),hn=S.getElementById.bind(S),gn=S.getElementsByClassName.bind(S),fn=S.getElementsByTagName.bind(S),yn=S.getElementsByName.bind(S);var Sn=(...i)=>f.renderToHead(...i),vn=i=>f.addStyle(i),Rn=i=>f.addMeta(i),bn=i=>f.addLink(i),Tn=i=>f.setTitle(i),Cn=(i,e)=>f.renderToString(i,e),Mn=i=>f.jsonToVNode(i),Nn=(i,e)=>f.renderJson(i,e),En=(i,e)=>f.renderJsonToString(i,e),Ln=i=>f.vNodeJsonToVNode(i),xn=(i,e)=>f.renderVNode(i,e),wn=(i,e)=>f.renderVNodeToString(i,e);typeof window<"u"&&Object.assign(window,{domNode:f,createElementFactory:b,renderToHead:Sn,addStyle:vn,addMeta:Rn,addLink:bn,setTitle:Tn,createState:C,computed:x,effect:w,createSharedState:j,sharedStateManager:J,reactive:L,reactiveAs:D,text:W,bindValue:K,bindChecked:q,batchRender:V,renderChunked:$,createVirtualList:k,lazy:F,cleanupUnused:A,renderToString:Cn,jsonToVNode:Mn,renderJson:Nn,renderJsonToString:En,vNodeJsonToVNode:Ln,renderVNode:xn,renderVNodeToString:wn,throttle:H,debounce:O,CreateStyle:N,createRouter:G,createRouterView:U,routerLink:B,...R,..._});
35
+ export{N as CreateStyle,E as DomNode,M as SharedState,Oe as a,Pe as abbr,bn as addLink,Rn as addMeta,vn as addStyle,ue as address,ct as area,ce as article,de as aside,dt as audio,je as b,oe as base,V as batchRender,Je as bdi,De as bdo,q as bindChecked,K as bindValue,Ce as blockquote,ne as body,We as br,jt as button,Ct as canvas,xt as caption,Ke as cite,A as cleanupUnused,qe as code,wt as col,Vt as colgroup,mn as commentNode,x as computed,ln as createEl,b as createElementFactory,cn as createMathEl,G as createRouter,U as createRouterView,j as createSharedState,C as createState,un as createSvgEl,k as createVirtualList,Ie as data,Jt as datalist,Me as dd,O as debounce,Et as del,Xt as details,Ge as dfn,Yt as dialog,Ne as div,Ee as dl,S as doc,f as domNode,Le as dt,w as effect,on as el,gn as elClass,hn as elId,yn as elName,fn as elTag,R as elements,an as els,Ue as em,ft as embed,Dt as fieldset,xe as figcaption,we as figure,pe as footer,Wt as form,dn as fragment,he as h1,ge as h2,fe as h3,ye as h4,Se as h5,ve as h6,re as head,me as header,Ve as hr,te as html,Be as i,yt as iframe,pt as img,Kt as input,Lt as ins,Mn as jsonToVNode,_e as kbd,qt as label,F as lazy,It as legend,$e as li,ie as link,Re as main,mt as map,ze as mark,Ur as mathMath,Yr as mathMfrac,Br as mathMi,_r as mathMn,zr as mathMo,tn as mathMroot,Xr as mathMrow,Zr as mathMs,en as mathMsqrt,rn as mathMsub,nn as mathMsup,Qr as mathMtext,er as menu,ae as meta,Gt as meter,be as nav,Mt as noscript,St as object,ke as ol,Ut as optgroup,Bt as option,_t as output,Fe as p,vt as param,Rt as picture,bt as portal,Ae as pre,zt as progress,Ze as q,L as reactive,D as reactiveAs,$ as renderChunked,Nn as renderJson,En as renderJsonToString,Sn as renderToHead,Cn as renderToString,xn as renderVNode,wn as renderVNodeToString,B as routerLink,Qe as rp,Xe as rt,Ye as ruby,et as s,tt as samp,Nt as script,Te as section,Zt as select,Tn as setTitle,J as sharedStateManager,rr as slot,rt as small,Tt as source,nt as span,st as strong,le as style,ot as sub,tr as summary,it as sup,Lr as svgAnimate,wr as svgAnimateMotion,xr as svgAnimateTransform,or as svgCircle,br as svgClipPath,gr as svgDefs,dr as svgEllipse,kr as svgFeBlend,Fr as svgFeColorMatrix,Ar as svgFeComponentTransfer,Hr as svgFeComposite,Or as svgFeConvolveMatrix,Pr as svgFeDiffuseLighting,jr as svgFeDisplacementMap,Jr as svgFeFlood,Dr as svgFeGaussianBlur,Wr as svgFeMorphology,Kr as svgFeOffset,qr as svgFeSpecularLighting,Ir as svgFeTile,Gr as svgFeTurbulence,$r as svgFilter,Er as svgForeignObject,pr as svgG,Nr as svgImage,lr as svgLine,fr as svgLinearGradient,Mr as svgMarker,Rr as svgMask,ar as svgPath,vr as svgPattern,cr as svgPolygon,ur as svgPolyline,yr as svgRadialGradient,ir as svgRect,Vr as svgSet,Sr as svgStop,sr as svgSvg,Cr as svgSymbol,mr as svgText,hr as svgTspan,Tr as svgUse,$t as table,kt as tbody,Ft as td,nr as template,W as text,pn as textNode,Qt as textarea,At as tfoot,Ht as th,Ot as thead,H as throttle,at as time,se as title,Pt as tr,ht as track,lt as u,He as ul,Ln as vNodeJsonToVNode,sn as varElement,gt as video,ut as wbr};