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

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, shallowReactive, useEffect } from '@estjs/signal';
3
3
 
4
4
  /**
5
- * @estjs/template v0.0.14-beta.3
5
+ * @estjs/template v0.0.14-beta.4
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,7 +381,6 @@ 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
386
  return shallowReactive(
@@ -408,17 +388,14 @@ var ComponentNode = class extends LifecycleContext {
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)) {
@@ -435,7 +412,6 @@ var ComponentNode = class extends LifecycleContext {
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,22 +470,18 @@ 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) {
520
486
  const track = this.getNodeTrack(key);
521
487
  track.cleanup = useEffect(() => {
@@ -631,7 +597,7 @@ function getKey(node, index) {
631
597
  return `_$${index}$`;
632
598
  }
633
599
 
634
- // src/template-node.ts
600
+ // src/templateNode.ts
635
601
  var TemplateNode = class {
636
602
  constructor(template, props, key) {
637
603
  this.template = template;
@@ -649,21 +615,17 @@ var TemplateNode = class {
649
615
  this.componentIndex = getComponentIndex(this.template);
650
616
  }
651
617
  }
652
- // Getter for the first child node
653
618
  get firstChild() {
654
619
  var _a;
655
620
  return (_a = this.nodes[0]) != null ? _a : null;
656
621
  }
657
- // Getter to check if the node is connected to the DOM
658
622
  get isConnected() {
659
623
  return this.mounted;
660
624
  }
661
- // Placeholder methods for event handling
662
625
  addEventListener() {
663
626
  }
664
627
  removeEventListener() {
665
628
  }
666
- // Method to mount the node to the DOM
667
629
  mount(parent, before) {
668
630
  var _a;
669
631
  this.parent = parent;
@@ -693,7 +655,6 @@ var TemplateNode = class {
693
655
  this.mounted = true;
694
656
  return this.nodes;
695
657
  }
696
- // Method to unmount the node from the DOM
697
658
  unmount() {
698
659
  var _a, _b;
699
660
  this.trackMap.forEach((track) => {
@@ -731,7 +692,6 @@ var TemplateNode = class {
731
692
  removeChild(child);
732
693
  }
733
694
  }
734
- // Method to inherit properties from another TemplateNode
735
695
  inheritNode(node) {
736
696
  this.mounted = node.mounted;
737
697
  this.nodes = node.nodes;
@@ -741,7 +701,6 @@ var TemplateNode = class {
741
701
  this.props = node.props;
742
702
  this.patchProps(props);
743
703
  }
744
- // Private method to map SSG node tree
745
704
  mapSSGNodeTree(parent) {
746
705
  this.treeMap.set(0, parent);
747
706
  this.walkNodeTree(parent, this.handleSSGNode.bind(this));
@@ -757,7 +716,6 @@ var TemplateNode = class {
757
716
  };
758
717
  this.walkNodeTree(tree, handleNode);
759
718
  }
760
- // Private method to walk through the node tree
761
719
  walkNodeTree(node, handler) {
762
720
  if (node.nodeType !== Node.DOCUMENT_FRAGMENT_NODE) {
763
721
  handler(node);
@@ -768,7 +726,6 @@ var TemplateNode = class {
768
726
  child = child.nextSibling;
769
727
  }
770
728
  }
771
- // Private method to handle SSG nodes
772
729
  handleSSGNode(node) {
773
730
  var _a;
774
731
  if (node.nodeType === Node.COMMENT_NODE) {
@@ -784,7 +741,6 @@ var TemplateNode = class {
784
741
  }
785
742
  }
786
743
  }
787
- // Method to patch props onto the node
788
744
  patchProps(props) {
789
745
  if (!props) return;
790
746
  Object.entries(props).forEach(([key, value]) => {
@@ -796,7 +752,6 @@ var TemplateNode = class {
796
752
  });
797
753
  this.props = props;
798
754
  }
799
- // Private method to patch a single prop
800
755
  patchProp(key, node, props, isRoot) {
801
756
  if (!props) return;
802
757
  Object.entries(props).forEach(([attr, value]) => {
@@ -815,13 +770,12 @@ var TemplateNode = class {
815
770
  }
816
771
  getBindUpdateValue(props, key, attr) {
817
772
  const UPDATE_PREFIX2 = "update";
818
- const updateKey = `${UPDATE_PREFIX2}${capitalizeFirstLetter(attr)}`;
773
+ const updateKey = `${UPDATE_PREFIX2}${capitalize(attr)}`;
819
774
  if (updateKey && props[updateKey] && isFunction(props[updateKey])) {
820
775
  this.bindValueKeys.push(updateKey);
821
776
  return props[updateKey];
822
777
  }
823
778
  }
824
- // Private method to patch children
825
779
  patchChildren(key, node, children, isRoot) {
826
780
  if (!isArray(children)) {
827
781
  const trackKey = `${key}:${CHILDREN_PROP}:0`;
@@ -838,20 +792,19 @@ var TemplateNode = class {
838
792
  });
839
793
  }
840
794
  }
841
- // Private method to patch event listeners
842
795
  patchEventListener(key, node, attr, listener) {
843
796
  const eventName = attr.slice(2).toLowerCase();
844
797
  const track = this.getNodeTrack(`${key}:${attr}`);
845
798
  track.cleanup = addEventListener(node, eventName, listener);
846
799
  }
847
- // Private method to patch attributes
848
800
  patchAttribute(key, element, attr, value, updateFn) {
849
801
  const track = this.getNodeTrack(`${key}:${attr}`);
850
802
  const val = isFunction(value) ? value() : value;
851
- const triggerValue = isSignal(val) ? val : useSignal(val);
803
+ const triggerValue = isSignal(val) ? val : shallowSignal(val);
852
804
  setAttribute(element, attr, triggerValue.value);
853
805
  const cleanup = useEffect(() => {
854
806
  const val2 = isFunction(value) ? value() : value;
807
+ if (JSON.stringify(triggerValue.value) === JSON.stringify(val2)) return;
855
808
  triggerValue.value = isSignal(val2) ? val2.value : val2;
856
809
  setAttribute(element, attr, triggerValue.value);
857
810
  });
@@ -866,7 +819,6 @@ var TemplateNode = class {
866
819
  cleanupBind && cleanupBind();
867
820
  };
868
821
  }
869
- // Private method to get or create a NodeTrack
870
822
  getNodeTrack(trackKey, trackLastNodes, isRoot) {
871
823
  var _a;
872
824
  let track = this.trackMap.get(trackKey);
@@ -884,7 +836,6 @@ var TemplateNode = class {
884
836
  (_a = track.cleanup) == null ? void 0 : _a.call(track);
885
837
  return track;
886
838
  }
887
- // Private method to patch a child node
888
839
  patchChild(track, parent, child, before) {
889
840
  if (isFunction(child)) {
890
841
  track.cleanup = useEffect(() => {
@@ -908,7 +859,6 @@ var TemplateNode = class {
908
859
  });
909
860
  }
910
861
  }
911
- // Private method to reconcile children nodes
912
862
  reconcileChildren(parent, nextNodes, before) {
913
863
  const result = /* @__PURE__ */ new Map();
914
864
  const textNodes = Array.from(parent.childNodes).filter(
@@ -934,7 +884,7 @@ var TemplateNode = class {
934
884
  }
935
885
  };
936
886
 
937
- // src/jsx-renderer.ts
887
+ // src/jsxRenderer.ts
938
888
  function h(template, props, key) {
939
889
  if (isString(template)) {
940
890
  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, shallowReactive, useEffect } from '@estjs/signal';
3
3
 
4
4
  /**
5
- * @estjs/template v0.0.14-beta.3
5
+ * @estjs/template v0.0.14-beta.4
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 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(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 O(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(O(e)){let n=e.mount();return isFunction(n)?n(this.props):_(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(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){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]=_(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,p]of e.entries()){let d=i[l],b=y(d,c);for(;d&&!a.has(b);)S(d),t.delete(b),d=i[++l],b=y(d,c);let Y=y(p,c),X=t.get(Y);if(X&&(p=be(o,X,p)),d)if(d===X)l++;else {let B=document.createComment("");E(o,B,d),s.push([B,p]);}else E(o,p,n);r.set(Y,p);}return s.forEach(([c,p])=>{V(o,p,c);}),t.forEach((c,p)=>{c.isConnected&&!r.has(p)&&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${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,p=`${t}:${v}:${s}`,d=this.getNodeTrack(p,!0,r);this.patchChild(d,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:shallowSignal(a);U(e,n,l.value);let c=useEffect(()=>{let d=isFunction(r)?r():r;JSON.stringify(l.value)!==JSON.stringify(d)&&(l.value=isSignal(d)?d.value:d,U(e,n,l.value));}),p;i&&isHTMLElement(e)&&(p=ne(e,d=>{i(d);})),s.cleanup=()=>{c&&c(),p&&p();};}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 _e(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)}
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 { $e as Fragment, w as h, Je as hydrate, _e 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 };
12
12
  //# sourceMappingURL=template.esm.js.map
13
13
  //# sourceMappingURL=template.esm.js.map