@estjs/template 0.0.14-beta.3 → 0.0.14-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,14 @@
1
- import { isString, isFunction, isArray, isSymbol, escape, startsWith, isPrimitive, capitalizeFirstLetter, isNil, isHTMLElement, coerceArray, isFalsy, kebabCase } from '@estjs/shared';
2
- import { shallowSignal, isSignal, shallowReactive, useEffect, useSignal } from '@estjs/signal';
1
+ import { isString, isFunction, isArray, isSymbol, escape, startsWith, isPrimitive, capitalize, isNil, isHTMLElement, coerceArray, isFalsy, kebabCase } from '@estjs/shared';
2
+ import { shallowSignal, isSignal, signalObject, useReactive, useSignal, useEffect } from '@estjs/signal';
3
3
 
4
4
  /**
5
- * @estjs/template v0.0.14-beta.3
5
+ * @estjs/template v0.0.14-beta.5
6
6
  * (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
7
7
  * @license MIT
8
8
  **/
9
9
 
10
10
 
11
- // src/shared-config.ts
11
+ // src/sharedConfig.ts
12
12
  var EVENT_PREFIX = "on";
13
13
  var UPDATE_PREFIX = "update";
14
14
  var CHILDREN_PROP = "children";
@@ -20,27 +20,21 @@ var RenderContext = class {
20
20
  constructor() {
21
21
  this.renderMode = 0 /* CLIENT */;
22
22
  }
23
- // Getter to check if the current mode is SSG
24
23
  get isSSG() {
25
24
  return this.renderMode === 1 /* SSG */;
26
25
  }
27
- // Getter to check if the current mode is SSR
28
26
  get isSSR() {
29
27
  return this.renderMode === 2 /* SSR */;
30
28
  }
31
- // Getter to check if the current mode is Client
32
29
  get isClient() {
33
30
  return this.renderMode === 0 /* CLIENT */;
34
31
  }
35
- // Set render mode to SSR
36
32
  setSSR() {
37
33
  this.renderMode = 2 /* SSR */;
38
34
  }
39
- // Set render mode to SSG
40
35
  setSSG() {
41
36
  this.renderMode = 1 /* SSG */;
42
37
  }
43
- // Set render mode to Client
44
38
  setClient() {
45
39
  this.renderMode = 0 /* CLIENT */;
46
40
  }
@@ -57,7 +51,7 @@ function getComponentIndex(temp) {
57
51
  return (_a = componentMap.get(temp)) == null ? void 0 : _a.index;
58
52
  }
59
53
 
60
- // src/lifecycle-context.ts
54
+ // src/lifecycleContext.ts
61
55
  var _LifecycleContext = class _LifecycleContext {
62
56
  constructor() {
63
57
  // Hooks for different lifecycle stages
@@ -83,11 +77,9 @@ var _LifecycleContext = class _LifecycleContext {
83
77
  setContext(context, value) {
84
78
  _LifecycleContext.context[context] = value;
85
79
  }
86
- // Initialize the static reference
87
80
  initRef() {
88
81
  _LifecycleContext.ref = this;
89
82
  }
90
- // Remove the static reference
91
83
  removeRef() {
92
84
  _LifecycleContext.ref = null;
93
85
  }
@@ -96,13 +88,11 @@ var _LifecycleContext = class _LifecycleContext {
96
88
  Object.values(this.hooks).forEach((set) => set.clear());
97
89
  }
98
90
  };
99
- // Static reference to the current context
100
91
  _LifecycleContext.ref = null;
101
- // Static context to store shared values
102
92
  _LifecycleContext.context = {};
103
93
  var LifecycleContext = _LifecycleContext;
104
94
 
105
- // src/ssg-node.ts
95
+ // src/ssgNode.ts
106
96
  function isSSGNode(node) {
107
97
  return node instanceof SSGNode;
108
98
  }
@@ -116,7 +106,6 @@ var SSGNode = class extends LifecycleContext {
116
106
  enterComponent(template, componentIndex);
117
107
  this.templates = this.processTemplate();
118
108
  }
119
- // Process the template and return an array of processed strings
120
109
  processTemplate() {
121
110
  if (isArray(this.template)) {
122
111
  const htmlString = this.template.join(PLACEHOLDER);
@@ -125,7 +114,6 @@ var SSGNode = class extends LifecycleContext {
125
114
  }
126
115
  return [];
127
116
  }
128
- // Process HTML string by adding component index and handling text nodes
129
117
  processHtmlString(htmlString) {
130
118
  return htmlString.replaceAll(/(<[^>]+>)|([^<]+)/g, (match, p1, p2) => {
131
119
  if (p1) {
@@ -139,14 +127,12 @@ var SSGNode = class extends LifecycleContext {
139
127
  return match;
140
128
  });
141
129
  }
142
- // Mount the SSGNode and return the rendered string
143
130
  mount() {
144
131
  this.initRef();
145
132
  const output = this.render();
146
133
  this.removeRef();
147
134
  return output;
148
135
  }
149
- // Render the SSGNode
150
136
  render() {
151
137
  if (isFunction(this.template)) {
152
138
  const root = this.template(this.props);
@@ -158,7 +144,6 @@ var SSGNode = class extends LifecycleContext {
158
144
  }
159
145
  return this.renderTemplate();
160
146
  }
161
- // Render the template by processing props and children
162
147
  renderTemplate() {
163
148
  Object.entries(this.props).forEach(([key, cur]) => {
164
149
  const children = cur.children;
@@ -174,7 +159,6 @@ var SSGNode = class extends LifecycleContext {
174
159
  });
175
160
  return this.templates.join("");
176
161
  }
177
- // Normalize props by removing children and handling signals
178
162
  normalizeProps(props) {
179
163
  Object.entries(props).forEach(([key, value]) => {
180
164
  if (key === "children") {
@@ -186,11 +170,9 @@ var SSGNode = class extends LifecycleContext {
186
170
  }
187
171
  });
188
172
  }
189
- // Generate HTML attributes string from props
190
173
  generateAttributes(props) {
191
174
  return Object.entries(props).filter(([key, value]) => key !== "children" && !isFunction(value)).map(([key, value]) => `${key}="${escape(String(value))}"`).join(" ");
192
175
  }
193
- // Render children and append them to the template
194
176
  renderChildren(children, findIndex) {
195
177
  children.forEach(([child]) => {
196
178
  componentIndex++;
@@ -198,7 +180,6 @@ var SSGNode = class extends LifecycleContext {
198
180
  this.templates[findIndex] += renderedChild;
199
181
  });
200
182
  }
201
- // Render a single child node
202
183
  renderChild(child) {
203
184
  if (isFunction(child)) {
204
185
  return this.renderChild(child(this.props));
@@ -400,25 +381,21 @@ var ComponentNode = class extends LifecycleContext {
400
381
  this.key || (this.key = props == null ? void 0 : props.key);
401
382
  this.proxyProps = this.createProxyProps(props);
402
383
  }
403
- // Create reactive props
404
384
  createProxyProps(props) {
405
385
  if (!props) return {};
406
- return shallowReactive(
386
+ return signalObject(
407
387
  props,
408
388
  (key) => startsWith(key, EVENT_PREFIX) || startsWith(key, UPDATE_PREFIX) || key === CHILDREN_PROP
409
389
  );
410
390
  }
411
- // Getter for the first child node
412
391
  get firstChild() {
413
392
  var _a, _b;
414
393
  return (_b = (_a = this.rootNode) == null ? void 0 : _a.firstChild) != null ? _b : null;
415
394
  }
416
- // Getter to check if the node is connected to the DOM
417
395
  get isConnected() {
418
396
  var _a, _b;
419
397
  return (_b = (_a = this.rootNode) == null ? void 0 : _a.isConnected) != null ? _b : false;
420
398
  }
421
- // Method to mount the component to the DOM
422
399
  mount(parent, before) {
423
400
  var _a, _b, _c, _d;
424
401
  if (!isFunction(this.template)) {
@@ -428,14 +405,13 @@ var ComponentNode = class extends LifecycleContext {
428
405
  return (_b = (_a = this.rootNode) == null ? void 0 : _a.mount(parent, before)) != null ? _b : [];
429
406
  }
430
407
  this.initRef();
431
- this.rootNode = this.template(this.proxyProps);
408
+ this.rootNode = this.template(useReactive(this.proxyProps, ["children"]));
432
409
  const mountedNode = (_d = (_c = this.rootNode) == null ? void 0 : _c.mount(parent, before)) != null ? _d : [];
433
410
  this.callMountHooks();
434
411
  this.patchProps(this.props);
435
412
  this.removeRef();
436
413
  return mountedNode;
437
414
  }
438
- // Method to unmount the component from the DOM
439
415
  unmount() {
440
416
  var _a;
441
417
  this.callDestroyHooks();
@@ -445,22 +421,18 @@ var ComponentNode = class extends LifecycleContext {
445
421
  this.proxyProps = {};
446
422
  this.clearEmitter();
447
423
  }
448
- // Private method to call mount hooks
449
424
  callMountHooks() {
450
425
  this.hooks.mounted.forEach((handler) => handler());
451
426
  }
452
- // Private method to call destroy hooks
453
427
  callDestroyHooks() {
454
428
  this.hooks.destroy.forEach((handler) => handler());
455
429
  }
456
- // Private method to clear the event emitter
457
430
  clearEmitter() {
458
431
  for (const cleanup of this.emitter) {
459
432
  cleanup();
460
433
  }
461
434
  this.emitter.clear();
462
435
  }
463
- // Method to inherit properties from another ComponentNode
464
436
  inheritNode(node) {
465
437
  Object.assign(this.proxyProps, node.proxyProps);
466
438
  this.rootNode = node.rootNode;
@@ -470,7 +442,6 @@ var ComponentNode = class extends LifecycleContext {
470
442
  this.props = node.props;
471
443
  this.patchProps(props);
472
444
  }
473
- // Private method to get or create a NodeTrack
474
445
  getNodeTrack(trackKey) {
475
446
  let track = this.trackMap.get(trackKey);
476
447
  if (!track) {
@@ -481,7 +452,6 @@ var ComponentNode = class extends LifecycleContext {
481
452
  track.cleanup();
482
453
  return track;
483
454
  }
484
- // Method to patch props onto the component
485
455
  patchProps(props) {
486
456
  var _a;
487
457
  if (!props) {
@@ -500,30 +470,32 @@ var ComponentNode = class extends LifecycleContext {
500
470
  }
501
471
  this.props = props;
502
472
  }
503
- // Private method to patch event listeners
504
473
  patchEventListener(key, prop) {
505
474
  const event = key.slice(2).toLowerCase();
506
475
  const cleanup = addEventListener(this.rootNode.nodes[0], event, prop);
507
476
  this.emitter.add(cleanup);
508
477
  }
509
- // Private method to patch ref
510
478
  patchRef(prop) {
511
479
  var _a, _b;
512
480
  prop.value = (_b = (_a = this.rootNode) == null ? void 0 : _a.firstChild) != null ? _b : null;
513
481
  }
514
- // Private method to patch update handlers
515
482
  patchUpdateHandler(key, prop) {
516
483
  this.props[key] = extractSignal(prop);
517
484
  }
518
- // Private method to patch normal props
519
485
  patchNormalProp(key, prop) {
486
+ var _a, _b;
487
+ const newValue = (_b = (_a = this.proxyProps)[key]) != null ? _b : _a[key] = useSignal(prop);
520
488
  const track = this.getNodeTrack(key);
521
489
  track.cleanup = useEffect(() => {
522
- this.proxyProps[key] = isFunction(prop) ? prop() : prop;
490
+ newValue.value = isFunction(prop) ? prop() : prop;
523
491
  });
524
492
  }
525
493
  };
526
494
 
495
+ // ../shared/src/comm.ts
496
+ var _toString = Object.prototype.toString;
497
+ var isPlainObject = (val) => _toString.call(val) === "[object Object]";
498
+
527
499
  // src/patch.ts
528
500
  function patchChildren(parent, childrenMap, nextChildren, before) {
529
501
  const result = /* @__PURE__ */ new Map();
@@ -631,7 +603,7 @@ function getKey(node, index) {
631
603
  return `_$${index}$`;
632
604
  }
633
605
 
634
- // src/template-node.ts
606
+ // src/templateNode.ts
635
607
  var TemplateNode = class {
636
608
  constructor(template, props, key) {
637
609
  this.template = template;
@@ -649,21 +621,17 @@ var TemplateNode = class {
649
621
  this.componentIndex = getComponentIndex(this.template);
650
622
  }
651
623
  }
652
- // Getter for the first child node
653
624
  get firstChild() {
654
625
  var _a;
655
626
  return (_a = this.nodes[0]) != null ? _a : null;
656
627
  }
657
- // Getter to check if the node is connected to the DOM
658
628
  get isConnected() {
659
629
  return this.mounted;
660
630
  }
661
- // Placeholder methods for event handling
662
631
  addEventListener() {
663
632
  }
664
633
  removeEventListener() {
665
634
  }
666
- // Method to mount the node to the DOM
667
635
  mount(parent, before) {
668
636
  var _a;
669
637
  this.parent = parent;
@@ -693,7 +661,6 @@ var TemplateNode = class {
693
661
  this.mounted = true;
694
662
  return this.nodes;
695
663
  }
696
- // Method to unmount the node from the DOM
697
664
  unmount() {
698
665
  var _a, _b;
699
666
  this.trackMap.forEach((track) => {
@@ -731,7 +698,6 @@ var TemplateNode = class {
731
698
  removeChild(child);
732
699
  }
733
700
  }
734
- // Method to inherit properties from another TemplateNode
735
701
  inheritNode(node) {
736
702
  this.mounted = node.mounted;
737
703
  this.nodes = node.nodes;
@@ -741,7 +707,6 @@ var TemplateNode = class {
741
707
  this.props = node.props;
742
708
  this.patchProps(props);
743
709
  }
744
- // Private method to map SSG node tree
745
710
  mapSSGNodeTree(parent) {
746
711
  this.treeMap.set(0, parent);
747
712
  this.walkNodeTree(parent, this.handleSSGNode.bind(this));
@@ -757,7 +722,6 @@ var TemplateNode = class {
757
722
  };
758
723
  this.walkNodeTree(tree, handleNode);
759
724
  }
760
- // Private method to walk through the node tree
761
725
  walkNodeTree(node, handler) {
762
726
  if (node.nodeType !== Node.DOCUMENT_FRAGMENT_NODE) {
763
727
  handler(node);
@@ -768,7 +732,6 @@ var TemplateNode = class {
768
732
  child = child.nextSibling;
769
733
  }
770
734
  }
771
- // Private method to handle SSG nodes
772
735
  handleSSGNode(node) {
773
736
  var _a;
774
737
  if (node.nodeType === Node.COMMENT_NODE) {
@@ -784,7 +747,6 @@ var TemplateNode = class {
784
747
  }
785
748
  }
786
749
  }
787
- // Method to patch props onto the node
788
750
  patchProps(props) {
789
751
  if (!props) return;
790
752
  Object.entries(props).forEach(([key, value]) => {
@@ -796,7 +758,6 @@ var TemplateNode = class {
796
758
  });
797
759
  this.props = props;
798
760
  }
799
- // Private method to patch a single prop
800
761
  patchProp(key, node, props, isRoot) {
801
762
  if (!props) return;
802
763
  Object.entries(props).forEach(([attr, value]) => {
@@ -815,13 +776,12 @@ var TemplateNode = class {
815
776
  }
816
777
  getBindUpdateValue(props, key, attr) {
817
778
  const UPDATE_PREFIX2 = "update";
818
- const updateKey = `${UPDATE_PREFIX2}${capitalizeFirstLetter(attr)}`;
779
+ const updateKey = `${UPDATE_PREFIX2}${capitalize(attr)}`;
819
780
  if (updateKey && props[updateKey] && isFunction(props[updateKey])) {
820
781
  this.bindValueKeys.push(updateKey);
821
782
  return props[updateKey];
822
783
  }
823
784
  }
824
- // Private method to patch children
825
785
  patchChildren(key, node, children, isRoot) {
826
786
  if (!isArray(children)) {
827
787
  const trackKey = `${key}:${CHILDREN_PROP}:0`;
@@ -838,20 +798,20 @@ var TemplateNode = class {
838
798
  });
839
799
  }
840
800
  }
841
- // Private method to patch event listeners
842
801
  patchEventListener(key, node, attr, listener) {
843
802
  const eventName = attr.slice(2).toLowerCase();
844
803
  const track = this.getNodeTrack(`${key}:${attr}`);
845
804
  track.cleanup = addEventListener(node, eventName, listener);
846
805
  }
847
- // Private method to patch attributes
848
806
  patchAttribute(key, element, attr, value, updateFn) {
849
807
  const track = this.getNodeTrack(`${key}:${attr}`);
850
808
  const val = isFunction(value) ? value() : value;
851
- const triggerValue = isSignal(val) ? val : useSignal(val);
809
+ const triggerValue = isSignal(val) ? val : shallowSignal(val);
852
810
  setAttribute(element, attr, triggerValue.value);
853
811
  const cleanup = useEffect(() => {
854
812
  const val2 = isFunction(value) ? value() : value;
813
+ if (isPlainObject(val2) && isPlainObject(triggerValue.peek()) && JSON.stringify(triggerValue.value) === JSON.stringify(val2))
814
+ return;
855
815
  triggerValue.value = isSignal(val2) ? val2.value : val2;
856
816
  setAttribute(element, attr, triggerValue.value);
857
817
  });
@@ -866,7 +826,6 @@ var TemplateNode = class {
866
826
  cleanupBind && cleanupBind();
867
827
  };
868
828
  }
869
- // Private method to get or create a NodeTrack
870
829
  getNodeTrack(trackKey, trackLastNodes, isRoot) {
871
830
  var _a;
872
831
  let track = this.trackMap.get(trackKey);
@@ -884,7 +843,6 @@ var TemplateNode = class {
884
843
  (_a = track.cleanup) == null ? void 0 : _a.call(track);
885
844
  return track;
886
845
  }
887
- // Private method to patch a child node
888
846
  patchChild(track, parent, child, before) {
889
847
  if (isFunction(child)) {
890
848
  track.cleanup = useEffect(() => {
@@ -908,7 +866,6 @@ var TemplateNode = class {
908
866
  });
909
867
  }
910
868
  }
911
- // Private method to reconcile children nodes
912
869
  reconcileChildren(parent, nextNodes, before) {
913
870
  const result = /* @__PURE__ */ new Map();
914
871
  const textNodes = Array.from(parent.childNodes).filter(
@@ -934,7 +891,7 @@ var TemplateNode = class {
934
891
  }
935
892
  };
936
893
 
937
- // src/jsx-renderer.ts
894
+ // src/jsxRenderer.ts
938
895
  function h(template, props, key) {
939
896
  if (isString(template)) {
940
897
  if (isHtmlTagName(template)) {
@@ -1,13 +1,13 @@
1
- import { isString, isFunction, isArray, escape, startsWith, isPrimitive, capitalizeFirstLetter, isNil, isHTMLElement, coerceArray, isFalsy, kebabCase } from '@estjs/shared';
2
- import { shallowSignal, isSignal, shallowReactive, useEffect, useSignal } from '@estjs/signal';
1
+ import { isString, isFunction, isArray, escape, startsWith, isPrimitive, capitalize, isNil, isHTMLElement, coerceArray, isFalsy, kebabCase } from '@estjs/shared';
2
+ import { shallowSignal, isSignal, signalObject, useReactive, useSignal, useEffect } from '@estjs/signal';
3
3
 
4
4
  /**
5
- * @estjs/template v0.0.14-beta.3
5
+ * @estjs/template v0.0.14-beta.5
6
6
  * (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
7
7
  * @license MIT
8
8
  **/
9
- var G="on",F="update",v="children",R="",H="0",z="1";var A=" __PLACEHOLDER__ ";var D=class{constructor(){this.renderMode=0;}get isSSG(){return this.renderMode===1}get isSSR(){return this.renderMode===2}get isClient(){return this.renderMode===0}setSSR(){this.renderMode=2;}setSSG(){this.renderMode=1;}setClient(){this.renderMode=0;}},m=new D,q=new Map;function W(o,t){q.set(o,{index:t});}function Q(o){var t;return (t=q.get(o))==null?void 0:t.index}var T=class T{constructor(){this.hooks={mounted:new Set,destroy:new Set};}addEventListener(){}removeEventListener(){}addHook(t,e){var n;(n=this.hooks[t])==null||n.add(e);}getContext(t){return T.context[t]}setContext(t,e){T.context[t]=e;}initRef(){T.ref=this;}removeRef(){T.ref=null;}clearHooks(){Object.values(this.hooks).forEach(t=>t.clear());}};T.ref=null,T.context={};var u=T;function _(o){return o instanceof M}var C=1,M=class extends u{constructor(e,n={},r){super();this.template=e;this.props=n;this.key=r;W(e,C),this.templates=this.processTemplate();}processTemplate(){if(isArray(this.template)){let e=this.template.join(A);return this.processHtmlString(e).split(A)}return []}processHtmlString(e){return e.replaceAll(/(<[^>]+>)|([^<]+)/g,(n,r,i)=>r?r.includes("data-ci")?n:r.replace(/<\s*([\da-z]+)(\s[^>]*)?>/i,(s,a,l)=>`<${a} data-ci="${C}"${l||""}>`):i&&i.replace(A,"").trim()?`<!--0-${C}-->${i}<!$>`:n)}mount(){this.initRef();let e=this.render();return this.removeRef(),e}render(){if(isFunction(this.template)){let e=this.template(this.props);return _(e)?e.mount():String(e)}return this.renderTemplate()}renderTemplate(){return Object.entries(this.props).forEach(([e,n])=>{let r=n.children;this.normalizeProps(n);let i=this.templates.findIndex(s=>s.includes(`data-hk="${e}"`));r&&this.renderChildren(r,i),this.templates[i]=this.templates[i].replace(`data-hk="${e}"`,`data-hk="${e}" ${this.generateAttributes(n)}`);}),this.templates.join("")}normalizeProps(e){Object.entries(e).forEach(([n,r])=>{n==="children"||isFunction(r)?delete e[n]:isSignal(r)&&(e[n]=r.value);});}generateAttributes(e){return Object.entries(e).filter(([n,r])=>n!=="children"&&!isFunction(r)).map(([n,r])=>`${n}="${escape(String(r))}"`).join(" ")}renderChildren(e,n){e.forEach(([r])=>{C++;let i=this.renderChild(r);this.templates[n]+=i;});}renderChild(e){if(isFunction(e))return this.renderChild(e(this.props));if(isSignal(e))return `<!--1-${C}-->${e.value}<!$>`;if(_(e)){let n=e.mount();return isFunction(n)?n(this.props):O(n)}else return `<!--1-${C}-->${e}<!$>`}};var te="area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr".split(","),ge="a,abbr,acronym,address,applet,area,article,aside,audio,b,base,basefont,bdi,bdo,bgsound,big,blink,blockquote,body,br,button,canvas,caption,center,cite,code,col,colgroup,command,content,data,datalist,dd,del,details,dfn,dialog,dir,div,dl,dt,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,image,img,input,ins,kbd,keygen,label,legend,li,link,listing,main,map,mark,marquee,menu,menuitem,meta,meter,nav,nobr,noframes,noscript,object,ol,optgroup,option,output,p,param,picture,plaintext,pre,progress,q,rb,rp,rt,rtc,ruby,s,samp,script,section,select,shadow,small,source,spacer,span,strike,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,tt,u,ul,var,video,wbr,xmp".split(",");function J(o){if(f(o)||o instanceof Node||_(o))return o;let t=isFalsy(o)?"":String(o);return document.createTextNode(t)}function E(o,t,e=null){let n=f(e)?e.firstChild:e,r=m.isSSR;f(t)?t.mount(o,n):n&&!r?n.before(t):r||o.append(t);}function S(o){f(o)?o.unmount():o.parentNode&&o.remove();}function V(o,t,e){E(o,t,e),S(e);}function U(o,t,e){t==="class"?Ee(o,e):t==="style"?Te(o,e):ve(o,t,e);}function Ee(o,t){typeof t=="string"?o.className=t:isArray(t)?o.className=t.join(" "):t&&typeof t=="object"&&(o.className=Object.entries(t).reduce((e,[n,r])=>e+(r?` ${n}`:""),"").trim());}function Te(o,t){typeof t=="string"?o.style.cssText=t:t&&typeof t=="object"&&Object.entries(t).forEach(([n,r])=>{o.style.setProperty(kebabCase(n),String(r));});}function ve(o,t,e){isFalsy(e)?o.removeAttribute(t):e===!0?o.setAttribute(t,""):o instanceof HTMLInputElement&&t==="value"?o.value=String(e):o.setAttribute(t,String(e));}function ne(o,t){if(o instanceof HTMLInputElement)switch(o.type){case"checkbox":return h(o,"change",()=>{t(!!o.checked);});case"date":return h(o,"change",()=>{t(o.value?o.value:"");});case"file":return h(o,"change",()=>{o.files&&t(o.files);});case"number":return h(o,"input",()=>{let e=Number.parseFloat(o.value);t(Number.isNaN(e)?"":String(e));});case"radio":return h(o,"change",()=>{t(o.checked?o.value:"");});case"text":return h(o,"input",()=>{t(o.value);})}if(o instanceof HTMLSelectElement)return h(o,"change",()=>{t(o.value);});if(o instanceof HTMLTextAreaElement)return h(o,"input",()=>{t(o.value);})}Promise.resolve();function h(o,t,e){return o.addEventListener(t,e),()=>o.removeEventListener(t,e)}function oe(o){let t=[],e=[],n=/<\/?([\da-z-]+)([^>]*)>/gi,r=0;for(;;){let i=n.exec(o);if(!i)break;let[s,a]=i,l=s[1]==="/";if(e.push(o.slice(r,i.index)),r=i.index+s.length,l){for(;t.length>0&&t[t.length-1]!==a;){let c=t.pop();c&&e.push(`</${c}>`);}t.length>0&&t.pop();}else te.includes(a)||t.push(a);e.push(s);}for(e.push(o.slice(r));t.length>0;){let i=t.pop();i&&e.push(`</${i}>`);}return e.join("")}function re(o){return ge.includes(o)}function ie(o){return te.includes(o)?`<${o}/>`:`<${o}></${o}>`}function O(o){return isSignal(o)?o.value:o}var k=class extends u{constructor(e,n,r){super();this.template=e;this.props=n;this.key=r;this.emitter=new Set;this.rootNode=null;this.trackMap=new Map;this.key||(this.key=n==null?void 0:n.key),this.proxyProps=this.createProxyProps(n);}createProxyProps(e){return e?shallowReactive(e,n=>startsWith(n,G)||startsWith(n,F)||n===v):{}}get firstChild(){var e,n;return (n=(e=this.rootNode)==null?void 0:e.firstChild)!=null?n:null}get isConnected(){var e,n;return (n=(e=this.rootNode)==null?void 0:e.isConnected)!=null?n:!1}mount(e,n){var i,s,a,l;if(!isFunction(this.template))throw new Error("Template must be a function");if(this.isConnected)return (s=(i=this.rootNode)==null?void 0:i.mount(e,n))!=null?s:[];this.initRef(),this.rootNode=this.template(this.proxyProps);let r=(l=(a=this.rootNode)==null?void 0:a.mount(e,n))!=null?l:[];return this.callMountHooks(),this.patchProps(this.props),this.removeRef(),r}unmount(){var e;this.callDestroyHooks(),this.clearHooks(),(e=this.rootNode)==null||e.unmount(),this.rootNode=null,this.proxyProps={},this.clearEmitter();}callMountHooks(){this.hooks.mounted.forEach(e=>e());}callDestroyHooks(){this.hooks.destroy.forEach(e=>e());}clearEmitter(){for(let e of this.emitter)e();this.emitter.clear();}inheritNode(e){Object.assign(this.proxyProps,e.proxyProps),this.rootNode=e.rootNode,this.trackMap=e.trackMap,this.hooks=e.hooks;let n=this.props;this.props=e.props,this.patchProps(n);}getNodeTrack(e){let n=this.trackMap.get(e);return n||(n={cleanup:()=>{}},this.trackMap.set(e,n)),n.cleanup(),n}patchProps(e){var n;if(e){for(let[r,i]of Object.entries(e))startsWith(r,G)&&((n=this.rootNode)!=null&&n.firstChild)?this.patchEventListener(r,i):r==="ref"?this.patchRef(i):startsWith(r,F)?this.patchUpdateHandler(r,i):r!==v&&this.patchNormalProp(r,i);this.props=e;}}patchEventListener(e,n){let r=e.slice(2).toLowerCase(),i=h(this.rootNode.nodes[0],r,n);this.emitter.add(i);}patchRef(e){var n,r;e.value=(r=(n=this.rootNode)==null?void 0:n.firstChild)!=null?r:null;}patchUpdateHandler(e,n){this.props[e]=O(n);}patchNormalProp(e,n){let r=this.getNodeTrack(e);r.cleanup=useEffect(()=>{this.proxyProps[e]=isFunction(n)?n():n;});}};function ae(o,t,e,n){let r=new Map,i=Array.from(t.values());if(i.length&&e.length===0)return xe(o,i,n),r;let s=[],a=Ce(e),l=0;for(let[c,d]of e.entries()){let p=i[l],b=y(p,c);for(;p&&!a.has(b);)S(p),t.delete(b),p=i[++l],b=y(p,c);let Y=y(d,c),X=t.get(Y);if(X&&(d=be(o,X,d)),p)if(p===X)l++;else {let B=document.createComment("");E(o,B,p),s.push([B,d]);}else E(o,d,n);r.set(Y,d);}return s.forEach(([c,d])=>{V(o,d,c);}),t.forEach((c,d)=>{c.isConnected&&!r.has(d)&&S(c);}),r}function xe(o,t,e){if(o.childNodes.length===t.length+(e?1:0))o.innerHTML="",e&&E(o,e);else {let n=document.createRange(),r=t[0],i=f(r)?r.firstChild:r;n.setStartBefore(i),e?n.setEndBefore(e):n.setEndAfter(o),n.deleteContents();}t.forEach(n=>{f(n)&&n.unmount();});}function be(o,t,e){return t===e?t:f(t)&&f(e)&&t.template===e.template?(e.inheritNode(t),e):t instanceof Text&&e instanceof Text?(t.textContent!==e.textContent&&(t.textContent=e.textContent),t):(V(o,e,t),e)}function Ce(o){let t=new Map;for(let[e,n]of o.entries()){let r=y(n,e);t.set(r,n);}return t}function y(o,t){if(f(o)){let e=o.key;if(e!=null)return String(e)}return `_$${t}$`}var x=class{constructor(t,e,n){this.template=t;this.props=e;this.key=n;this.treeMap=new Map;this.mounted=!1;this.nodes=[];this.trackMap=new Map;this.bindValueKeys=[];this.parent=null;this.key||(this.key=e==null?void 0:e.key),m.isSSR&&(this.componentIndex=Q(this.template));}get firstChild(){var t;return (t=this.nodes[0])!=null?t:null}get isConnected(){return this.mounted}addEventListener(){}removeEventListener(){}mount(t,e){var i;if(this.parent=t,this.isConnected)return this.nodes.forEach(s=>E(t,s,e)),this.nodes;isArray(this.template)&&(this.template=L(this.template.join("")));let n=this.template.content.cloneNode(!0),r=n.firstChild;return (i=r==null?void 0:r.hasAttribute)!=null&&i.call(r,"_svg_")&&(r.remove(),r==null||r.childNodes.forEach(s=>{n.append(s);})),this.nodes=Array.from(n.childNodes),m.isSSR?this.mapSSGNodeTree(t):this.mapNodeTree(t,n),E(t,n,e),this.patchProps(this.props),this.mounted=!0,this.nodes}unmount(){var t,e;if(this.trackMap.forEach(n=>{var r;(r=n.cleanup)==null||r.call(n);}),this.trackMap.clear(),this.treeMap.clear(),this.nodes.forEach(n=>S(n)),!this.template.innerHTML&&!this.nodes.length){let n=(e=(t=this.props)==null?void 0:t[H])==null?void 0:e.children;n&&(isArray(n)?n.forEach(r=>{this.deleteFragmentTextNode(r);}):this.deleteFragmentTextNode(n));}this.nodes=[],this.mounted=!1;}deleteFragmentTextNode(t){var e;isPrimitive(t)?(e=this.parent)==null||e.childNodes.forEach(n=>{var r;n.nodeType===Node.TEXT_NODE&&n.textContent===`${t}`&&((r=this.parent)==null||r.removeChild(n));}):S(t);}inheritNode(t){this.mounted=t.mounted,this.nodes=t.nodes,this.trackMap=t.trackMap,this.treeMap=t.treeMap;let e=this.props;this.props=t.props,this.patchProps(e);}mapSSGNodeTree(t){this.treeMap.set(0,t),this.walkNodeTree(t,this.handleSSGNode.bind(this));}mapNodeTree(t,e){let n=1;this.treeMap.set(0,t);let r=[t],i=s=>{s.nodeType!==Node.DOCUMENT_FRAGMENT_NODE&&(this.treeMap.set(n++,s),r.push(s));};this.walkNodeTree(e,i);}walkNodeTree(t,e){t.nodeType!==Node.DOCUMENT_FRAGMENT_NODE&&e(t);let n=t.firstChild;for(;n;)this.walkNodeTree(n,e),n=n.nextSibling;}handleSSGNode(t){var e;if(t.nodeType===Node.COMMENT_NODE){let[n,r]=((e=t.textContent)==null?void 0:e.split("-"))||[];if(0===+n&&+r===this.componentIndex){let i=t.nextSibling;this.treeMap.set(+r,i);}}else if(t.nodeType!==Node.TEXT_NODE){let{ci:n="-1",hk:r}=(t==null?void 0:t.dataset)||{};r&&+n===this.componentIndex&&this.treeMap.set(+r,t);}}patchProps(t){t&&(Object.entries(t).forEach(([e,n])=>{let r=Number(e),i=this.treeMap.get(r);i&&this.patchProp(e,i,n,r===0);}),this.props=t);}patchProp(t,e,n,r){n&&Object.entries(n).forEach(([i,s])=>{if(i===v&&s)this.patchChildren(t,e,s,r);else if(i==="ref")n[i].value=e;else if(startsWith(i,"on"))this.patchEventListener(t,e,i,s);else {if(this.bindValueKeys.includes(i))return;let a=this.getBindUpdateValue(n,t,i);this.patchAttribute(t,e,i,s,a);}});}getBindUpdateValue(t,e,n){let i=`update${capitalizeFirstLetter(n)}`;if(i&&t[i]&&isFunction(t[i]))return this.bindValueKeys.push(i),t[i]}patchChildren(t,e,n,r){if(isArray(n))n.filter(Boolean).forEach((i,s)=>{var b;let[a,l]=isArray(i)?i:[i,null],c=isNil(l)?null:(b=this.treeMap.get(l))!=null?b:null,d=`${t}:${v}:${s}`,p=this.getNodeTrack(d,!0,r);this.patchChild(p,e,a,c);});else {let i=`${t}:${v}:0`,s=this.getNodeTrack(i,!0,r);this.patchChild(s,e,n,null);}}patchEventListener(t,e,n,r){let i=n.slice(2).toLowerCase(),s=this.getNodeTrack(`${t}:${n}`);s.cleanup=h(e,i,r);}patchAttribute(t,e,n,r,i){let s=this.getNodeTrack(`${t}:${n}`),a=isFunction(r)?r():r,l=isSignal(a)?a:useSignal(a);U(e,n,l.value);let c=useEffect(()=>{let p=isFunction(r)?r():r;l.value=isSignal(p)?p.value:p,U(e,n,l.value);}),d;i&&isHTMLElement(e)&&(d=ne(e,p=>{i(p);})),s.cleanup=()=>{c&&c(),d&&d();};}getNodeTrack(t,e,n){var i;let r=this.trackMap.get(t);return r||(r={cleanup:()=>{}},e&&(r.lastNodes=new Map),n&&(r.isRoot=!0),this.trackMap.set(t,r)),(i=r.cleanup)==null||i.call(r),r}patchChild(t,e,n,r){isFunction(n)?t.cleanup=useEffect(()=>{let i=coerceArray(n()).map(J);m.isSSR?t.lastNodes=this.reconcileChildren(e,i,r):t.lastNodes=ae(e,t.lastNodes,i,r);}):coerceArray(n).forEach((i,s)=>{let a=J(i),l=y(a,s);m.isSSR?t.lastNodes=this.reconcileChildren(e,[a],r):(t.lastNodes.set(l,a),E(e,a,r));});}reconcileChildren(t,e,n){let r=new Map,i=Array.from(t.childNodes).filter(s=>{var a,l;return s.nodeType===Node.TEXT_NODE&&((a=s.previousSibling)==null?void 0:a.nodeType)===Node.COMMENT_NODE&&((l=s.nextSibling)==null?void 0:l.nodeType)===Node.COMMENT_NODE});return e.forEach((s,a)=>{let l=y(s,a);s.nodeType===Node.TEXT_NODE?i.forEach(c=>{s.textContent===c.textContent&&t.replaceChild(s,c);}):E(t,s,n),r.set(l,s);}),r}};function w(o,t,e){if(isString(o)){if(re(o)){let n=ie(o);return t={[z]:t},new x(L(n),t,e)}else if(o===R)return t={[H]:t},new x(L(R),t,e)}return isFunction(o)?new k(o,t,e):new x(o,t,e)}function Oe(o){return o instanceof k}function f(o){return o instanceof k||o instanceof x}function L(o){let t=document.createElement("template");return t.innerHTML=oe(o),t}function $e(o){return w(R,{children:isArray(o.children)?o.children.filter(Boolean):[o.children]})}function je(o){u.ref&&u.ref.addHook("mounted",o);}function Ke(o){u.ref&&u.ref.addHook("destroy",o);}function Xe(o,t){u.ref&&u.ref.setContext(o,t);}function De(o,t){var e;return (e=u.ref&&u.ref.getContext(o))!=null?e:t}function Ge(){return shallowSignal(null)}function Fe(o,t){m.setSSG();let n=new M(o,t||{}).mount();return m.setClient(),n}function Je(o,t){let e=typeof t=="string"?document.querySelector(t):t;if(!e)throw new Error(`Could not find container: ${t}`);m.setSSR(),w(o).mount(e),m.setClient();}function Ve(o,t){return m.isSSG?new M(o,t):w(o,t)}
9
+ var D="on",G="update",y="children",R="",A="0",q="1";var O=" __PLACEHOLDER__ ";var X=class{constructor(){this.renderMode=0;}get isSSG(){return this.renderMode===1}get isSSR(){return this.renderMode===2}get isClient(){return this.renderMode===0}setSSR(){this.renderMode=2;}setSSG(){this.renderMode=1;}setClient(){this.renderMode=0;}},m=new X,z=new Map;function Q(o,t){z.set(o,{index:t});}function Z(o){var t;return (t=z.get(o))==null?void 0:t.index}var T=class T{constructor(){this.hooks={mounted:new Set,destroy:new Set};}addEventListener(){}removeEventListener(){}addHook(t,e){var n;(n=this.hooks[t])==null||n.add(e);}getContext(t){return T.context[t]}setContext(t,e){T.context[t]=e;}initRef(){T.ref=this;}removeRef(){T.ref=null;}clearHooks(){Object.values(this.hooks).forEach(t=>t.clear());}};T.ref=null,T.context={};var d=T;function H(o){return o instanceof k}var M=1,k=class extends d{constructor(e,n={},r){super();this.template=e;this.props=n;this.key=r;Q(e,M),this.templates=this.processTemplate();}processTemplate(){if(isArray(this.template)){let e=this.template.join(O);return this.processHtmlString(e).split(O)}return []}processHtmlString(e){return e.replaceAll(/(<[^>]+>)|([^<]+)/g,(n,r,i)=>r?r.includes("data-ci")?n:r.replace(/<\s*([\da-z]+)(\s[^>]*)?>/i,(s,a,l)=>`<${a} data-ci="${M}"${l||""}>`):i&&i.replace(O,"").trim()?`<!--0-${M}-->${i}<!$>`:n)}mount(){this.initRef();let e=this.render();return this.removeRef(),e}render(){if(isFunction(this.template)){let e=this.template(this.props);return H(e)?e.mount():String(e)}return this.renderTemplate()}renderTemplate(){return Object.entries(this.props).forEach(([e,n])=>{let r=n.children;this.normalizeProps(n);let i=this.templates.findIndex(s=>s.includes(`data-hk="${e}"`));r&&this.renderChildren(r,i),this.templates[i]=this.templates[i].replace(`data-hk="${e}"`,`data-hk="${e}" ${this.generateAttributes(n)}`);}),this.templates.join("")}normalizeProps(e){Object.entries(e).forEach(([n,r])=>{n==="children"||isFunction(r)?delete e[n]:isSignal(r)&&(e[n]=r.value);});}generateAttributes(e){return Object.entries(e).filter(([n,r])=>n!=="children"&&!isFunction(r)).map(([n,r])=>`${n}="${escape(String(r))}"`).join(" ")}renderChildren(e,n){e.forEach(([r])=>{M++;let i=this.renderChild(r);this.templates[n]+=i;});}renderChild(e){if(isFunction(e))return this.renderChild(e(this.props));if(isSignal(e))return `<!--1-${M}-->${e.value}<!$>`;if(H(e)){let n=e.mount();return isFunction(n)?n(this.props):j(n)}else return `<!--1-${M}-->${e}<!$>`}};var ne="area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr".split(","),Te="a,abbr,acronym,address,applet,area,article,aside,audio,b,base,basefont,bdi,bdo,bgsound,big,blink,blockquote,body,br,button,canvas,caption,center,cite,code,col,colgroup,command,content,data,datalist,dd,del,details,dfn,dialog,dir,div,dl,dt,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,image,img,input,ins,kbd,keygen,label,legend,li,link,listing,main,map,mark,marquee,menu,menuitem,meta,meter,nav,nobr,noframes,noscript,object,ol,optgroup,option,output,p,param,picture,plaintext,pre,progress,q,rb,rp,rt,rtc,ruby,s,samp,script,section,select,shadow,small,source,spacer,span,strike,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,tt,u,ul,var,video,wbr,xmp".split(",");function J(o){if(N(o)||o instanceof Node||H(o))return o;let t=isFalsy(o)?"":String(o);return document.createTextNode(t)}function E(o,t,e=null){let n=N(e)?e.firstChild:e,r=m.isSSR;N(t)?t.mount(o,n):n&&!r?n.before(t):r||o.append(t);}function x(o){N(o)?o.unmount():o.parentNode&&o.remove();}function V(o,t,e){E(o,t,e),x(e);}function U(o,t,e){t==="class"?ye(o,e):t==="style"?xe(o,e):ve(o,t,e);}function ye(o,t){typeof t=="string"?o.className=t:isArray(t)?o.className=t.join(" "):t&&typeof t=="object"&&(o.className=Object.entries(t).reduce((e,[n,r])=>e+(r?` ${n}`:""),"").trim());}function xe(o,t){typeof t=="string"?o.style.cssText=t:t&&typeof t=="object"&&Object.entries(t).forEach(([n,r])=>{o.style.setProperty(kebabCase(n),String(r));});}function ve(o,t,e){isFalsy(e)?o.removeAttribute(t):e===!0?o.setAttribute(t,""):o instanceof HTMLInputElement&&t==="value"?o.value=String(e):o.setAttribute(t,String(e));}function oe(o,t){if(o instanceof HTMLInputElement)switch(o.type){case"checkbox":return g(o,"change",()=>{t(!!o.checked);});case"date":return g(o,"change",()=>{t(o.value?o.value:"");});case"file":return g(o,"change",()=>{o.files&&t(o.files);});case"number":return g(o,"input",()=>{let e=Number.parseFloat(o.value);t(Number.isNaN(e)?"":String(e));});case"radio":return g(o,"change",()=>{t(o.checked?o.value:"");});case"text":return g(o,"input",()=>{t(o.value);})}if(o instanceof HTMLSelectElement)return g(o,"change",()=>{t(o.value);});if(o instanceof HTMLTextAreaElement)return g(o,"input",()=>{t(o.value);})}Promise.resolve();function g(o,t,e){return o.addEventListener(t,e),()=>o.removeEventListener(t,e)}function re(o){let t=[],e=[],n=/<\/?([\da-z-]+)([^>]*)>/gi,r=0;for(;;){let i=n.exec(o);if(!i)break;let[s,a]=i,l=s[1]==="/";if(e.push(o.slice(r,i.index)),r=i.index+s.length,l){for(;t.length>0&&t[t.length-1]!==a;){let c=t.pop();c&&e.push(`</${c}>`);}t.length>0&&t.pop();}else ne.includes(a)||t.push(a);e.push(s);}for(e.push(o.slice(r));t.length>0;){let i=t.pop();i&&e.push(`</${i}>`);}return e.join("")}function ie(o){return Te.includes(o)}function se(o){return ne.includes(o)?`<${o}/>`:`<${o}></${o}>`}function j(o){return isSignal(o)?o.value:o}var C=class extends d{constructor(e,n,r){super();this.template=e;this.props=n;this.key=r;this.emitter=new Set;this.rootNode=null;this.trackMap=new Map;this.key||(this.key=n==null?void 0:n.key),this.proxyProps=this.createProxyProps(n);}createProxyProps(e){return e?signalObject(e,n=>startsWith(n,D)||startsWith(n,G)||n===y):{}}get firstChild(){var e,n;return (n=(e=this.rootNode)==null?void 0:e.firstChild)!=null?n:null}get isConnected(){var e,n;return (n=(e=this.rootNode)==null?void 0:e.isConnected)!=null?n:!1}mount(e,n){var i,s,a,l;if(!isFunction(this.template))throw new Error("Template must be a function");if(this.isConnected)return (s=(i=this.rootNode)==null?void 0:i.mount(e,n))!=null?s:[];this.initRef(),this.rootNode=this.template(useReactive(this.proxyProps,["children"]));let r=(l=(a=this.rootNode)==null?void 0:a.mount(e,n))!=null?l:[];return this.callMountHooks(),this.patchProps(this.props),this.removeRef(),r}unmount(){var e;this.callDestroyHooks(),this.clearHooks(),(e=this.rootNode)==null||e.unmount(),this.rootNode=null,this.proxyProps={},this.clearEmitter();}callMountHooks(){this.hooks.mounted.forEach(e=>e());}callDestroyHooks(){this.hooks.destroy.forEach(e=>e());}clearEmitter(){for(let e of this.emitter)e();this.emitter.clear();}inheritNode(e){Object.assign(this.proxyProps,e.proxyProps),this.rootNode=e.rootNode,this.trackMap=e.trackMap,this.hooks=e.hooks;let n=this.props;this.props=e.props,this.patchProps(n);}getNodeTrack(e){let n=this.trackMap.get(e);return n||(n={cleanup:()=>{}},this.trackMap.set(e,n)),n.cleanup(),n}patchProps(e){var n;if(e){for(let[r,i]of Object.entries(e))startsWith(r,D)&&((n=this.rootNode)!=null&&n.firstChild)?this.patchEventListener(r,i):r==="ref"?this.patchRef(i):startsWith(r,G)?this.patchUpdateHandler(r,i):r!==y&&this.patchNormalProp(r,i);this.props=e;}}patchEventListener(e,n){let r=e.slice(2).toLowerCase(),i=g(this.rootNode.nodes[0],r,n);this.emitter.add(i);}patchRef(e){var n,r;e.value=(r=(n=this.rootNode)==null?void 0:n.firstChild)!=null?r:null;}patchUpdateHandler(e,n){this.props[e]=j(n);}patchNormalProp(e,n){var s,a;let r=(a=(s=this.proxyProps)[e])!=null?a:s[e]=useSignal(n),i=this.getNodeTrack(e);i.cleanup=useEffect(()=>{r.value=isFunction(n)?n():n;});}};var le=Object.prototype.toString;var B=o=>le.call(o)==="[object Object]";function ce(o,t,e,n){let r=new Map,i=Array.from(t.values());if(i.length&&e.length===0)return Ce(o,i,n),r;let s=[],a=we(e),l=0;for(let[c,u]of e.entries()){let p=i[l],b=v(p,c);for(;p&&!a.has(b);)x(p),t.delete(b),p=i[++l],b=v(p,c);let W=v(u,c),K=t.get(W);if(K&&(u=Pe(o,K,u)),p)if(p===K)l++;else {let Y=document.createComment("");E(o,Y,p),s.push([Y,u]);}else E(o,u,n);r.set(W,u);}return s.forEach(([c,u])=>{V(o,u,c);}),t.forEach((c,u)=>{c.isConnected&&!r.has(u)&&x(c);}),r}function Ce(o,t,e){if(o.childNodes.length===t.length+(e?1:0))o.innerHTML="",e&&E(o,e);else {let n=document.createRange(),r=t[0],i=N(r)?r.firstChild:r;n.setStartBefore(i),e?n.setEndBefore(e):n.setEndAfter(o),n.deleteContents();}t.forEach(n=>{N(n)&&n.unmount();});}function Pe(o,t,e){return t===e?t:N(t)&&N(e)&&t.template===e.template?(e.inheritNode(t),e):t instanceof Text&&e instanceof Text?(t.textContent!==e.textContent&&(t.textContent=e.textContent),t):(V(o,e,t),e)}function we(o){let t=new Map;for(let[e,n]of o.entries()){let r=v(n,e);t.set(r,n);}return t}function v(o,t){if(N(o)){let e=o.key;if(e!=null)return String(e)}return `_$${t}$`}var S=class{constructor(t,e,n){this.template=t;this.props=e;this.key=n;this.treeMap=new Map;this.mounted=!1;this.nodes=[];this.trackMap=new Map;this.bindValueKeys=[];this.parent=null;this.key||(this.key=e==null?void 0:e.key),m.isSSR&&(this.componentIndex=Z(this.template));}get firstChild(){var t;return (t=this.nodes[0])!=null?t:null}get isConnected(){return this.mounted}addEventListener(){}removeEventListener(){}mount(t,e){var i;if(this.parent=t,this.isConnected)return this.nodes.forEach(s=>E(t,s,e)),this.nodes;isArray(this.template)&&(this.template=w(this.template.join("")));let n=this.template.content.cloneNode(!0),r=n.firstChild;return (i=r==null?void 0:r.hasAttribute)!=null&&i.call(r,"_svg_")&&(r.remove(),r==null||r.childNodes.forEach(s=>{n.append(s);})),this.nodes=Array.from(n.childNodes),m.isSSR?this.mapSSGNodeTree(t):this.mapNodeTree(t,n),E(t,n,e),this.patchProps(this.props),this.mounted=!0,this.nodes}unmount(){var t,e;if(this.trackMap.forEach(n=>{var r;(r=n.cleanup)==null||r.call(n);}),this.trackMap.clear(),this.treeMap.clear(),this.nodes.forEach(n=>x(n)),!this.template.innerHTML&&!this.nodes.length){let n=(e=(t=this.props)==null?void 0:t[A])==null?void 0:e.children;n&&(isArray(n)?n.forEach(r=>{this.deleteFragmentTextNode(r);}):this.deleteFragmentTextNode(n));}this.nodes=[],this.mounted=!1;}deleteFragmentTextNode(t){var e;isPrimitive(t)?(e=this.parent)==null||e.childNodes.forEach(n=>{var r;n.nodeType===Node.TEXT_NODE&&n.textContent===`${t}`&&((r=this.parent)==null||r.removeChild(n));}):x(t);}inheritNode(t){this.mounted=t.mounted,this.nodes=t.nodes,this.trackMap=t.trackMap,this.treeMap=t.treeMap;let e=this.props;this.props=t.props,this.patchProps(e);}mapSSGNodeTree(t){this.treeMap.set(0,t),this.walkNodeTree(t,this.handleSSGNode.bind(this));}mapNodeTree(t,e){let n=1;this.treeMap.set(0,t);let r=[t],i=s=>{s.nodeType!==Node.DOCUMENT_FRAGMENT_NODE&&(this.treeMap.set(n++,s),r.push(s));};this.walkNodeTree(e,i);}walkNodeTree(t,e){t.nodeType!==Node.DOCUMENT_FRAGMENT_NODE&&e(t);let n=t.firstChild;for(;n;)this.walkNodeTree(n,e),n=n.nextSibling;}handleSSGNode(t){var e;if(t.nodeType===Node.COMMENT_NODE){let[n,r]=((e=t.textContent)==null?void 0:e.split("-"))||[];if(0===+n&&+r===this.componentIndex){let i=t.nextSibling;this.treeMap.set(+r,i);}}else if(t.nodeType!==Node.TEXT_NODE){let{ci:n="-1",hk:r}=(t==null?void 0:t.dataset)||{};r&&+n===this.componentIndex&&this.treeMap.set(+r,t);}}patchProps(t){t&&(Object.entries(t).forEach(([e,n])=>{let r=Number(e),i=this.treeMap.get(r);i&&this.patchProp(e,i,n,r===0);}),this.props=t);}patchProp(t,e,n,r){n&&Object.entries(n).forEach(([i,s])=>{if(i===y&&s)this.patchChildren(t,e,s,r);else if(i==="ref")n[i].value=e;else if(startsWith(i,"on"))this.patchEventListener(t,e,i,s);else {if(this.bindValueKeys.includes(i))return;let a=this.getBindUpdateValue(n,t,i);this.patchAttribute(t,e,i,s,a);}});}getBindUpdateValue(t,e,n){let i=`update${capitalize(n)}`;if(i&&t[i]&&isFunction(t[i]))return this.bindValueKeys.push(i),t[i]}patchChildren(t,e,n,r){if(isArray(n))n.filter(Boolean).forEach((i,s)=>{var b;let[a,l]=isArray(i)?i:[i,null],c=isNil(l)?null:(b=this.treeMap.get(l))!=null?b:null,u=`${t}:${y}:${s}`,p=this.getNodeTrack(u,!0,r);this.patchChild(p,e,a,c);});else {let i=`${t}:${y}:0`,s=this.getNodeTrack(i,!0,r);this.patchChild(s,e,n,null);}}patchEventListener(t,e,n,r){let i=n.slice(2).toLowerCase(),s=this.getNodeTrack(`${t}:${n}`);s.cleanup=g(e,i,r);}patchAttribute(t,e,n,r,i){let s=this.getNodeTrack(`${t}:${n}`),a=isFunction(r)?r():r,l=isSignal(a)?a:shallowSignal(a);U(e,n,l.value);let c=useEffect(()=>{let p=isFunction(r)?r():r;B(p)&&B(l.peek())&&JSON.stringify(l.value)===JSON.stringify(p)||(l.value=isSignal(p)?p.value:p,U(e,n,l.value));}),u;i&&isHTMLElement(e)&&(u=oe(e,p=>{i(p);})),s.cleanup=()=>{c&&c(),u&&u();};}getNodeTrack(t,e,n){var i;let r=this.trackMap.get(t);return r||(r={cleanup:()=>{}},e&&(r.lastNodes=new Map),n&&(r.isRoot=!0),this.trackMap.set(t,r)),(i=r.cleanup)==null||i.call(r),r}patchChild(t,e,n,r){isFunction(n)?t.cleanup=useEffect(()=>{let i=coerceArray(n()).map(J);m.isSSR?t.lastNodes=this.reconcileChildren(e,i,r):t.lastNodes=ce(e,t.lastNodes,i,r);}):coerceArray(n).forEach((i,s)=>{let a=J(i),l=v(a,s);m.isSSR?t.lastNodes=this.reconcileChildren(e,[a],r):(t.lastNodes.set(l,a),E(e,a,r));});}reconcileChildren(t,e,n){let r=new Map,i=Array.from(t.childNodes).filter(s=>{var a,l;return s.nodeType===Node.TEXT_NODE&&((a=s.previousSibling)==null?void 0:a.nodeType)===Node.COMMENT_NODE&&((l=s.nextSibling)==null?void 0:l.nodeType)===Node.COMMENT_NODE});return e.forEach((s,a)=>{let l=v(s,a);s.nodeType===Node.TEXT_NODE?i.forEach(c=>{s.textContent===c.textContent&&t.replaceChild(s,c);}):E(t,s,n),r.set(l,s);}),r}};function L(o,t,e){if(isString(o)){if(ie(o)){let n=se(o);return t={[q]:t},new S(w(n),t,e)}else if(o===R)return t={[A]:t},new S(w(R),t,e)}return isFunction(o)?new C(o,t,e):new S(o,t,e)}function Fe(o){return o instanceof C}function N(o){return o instanceof C||o instanceof S}function w(o){let t=document.createElement("template");return t.innerHTML=re(o),t}function Ke(o){return L(R,{children:isArray(o.children)?o.children.filter(Boolean):[o.children]})}function De(o){d.ref&&d.ref.addHook("mounted",o);}function Ge(o){d.ref&&d.ref.addHook("destroy",o);}function Je(o,t){d.ref&&d.ref.setContext(o,t);}function Ve(o,t){var e;return (e=d.ref&&d.ref.getContext(o))!=null?e:t}function Ue(){return shallowSignal(null)}function Be(o,t){m.setSSG();let n=new k(o,t||{}).mount();return m.setClient(),n}function We(o,t){let e=typeof t=="string"?document.querySelector(t):t;if(!e)throw new Error(`Could not find container: ${t}`);m.setSSR(),L(o).mount(e),m.setClient();}function Ye(o,t){return m.isSSG?new k(o,t):L(o,t)}
10
10
 
11
- export { $e as Fragment, w as h, Je as hydrate, Oe as isComponent, f as isJsxElement, Ke as onDestroy, je as onMount, Fe as renderToString, Ve as ssg, L as template, De as useInject, Xe as useProvide, Ge as useRef };
11
+ export { Ke as Fragment, L as h, We as hydrate, Fe as isComponent, N as isJsxElement, Ge as onDestroy, De as onMount, Be as renderToString, Ye as ssg, w as template, Ve as useInject, Je as useProvide, Ue as useRef };
12
12
  //# sourceMappingURL=template.esm.js.map
13
13
  //# sourceMappingURL=template.esm.js.map