@estjs/template 0.0.15-beta.6 → 0.0.15-beta.7

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,4 +1,4 @@
1
- import { Signal } from '@estjs/signals';
1
+ import { Signal, Computed } from '@estjs/signals';
2
2
  export { escapeHTML } from '@estjs/shared';
3
3
 
4
4
  /**
@@ -60,13 +60,13 @@ declare enum COMPONENT_TYPE {
60
60
  FOR = "for"
61
61
  }
62
62
 
63
- type AnyNode = Node | Component | Element | string | number | boolean | null | undefined | AnyNode[] | (() => AnyNode);
63
+ type AnyNode = Node | Component<any> | Element | string | number | boolean | null | undefined | AnyNode[] | (() => AnyNode) | Signal<AnyNode> | Computed<AnyNode>;
64
64
  type ComponentProps = Record<string, unknown>;
65
- type ComponentFn = (props?: ComponentProps) => AnyNode;
65
+ type ComponentFn<P = ComponentProps> = (props: P) => AnyNode;
66
66
 
67
- declare class Component {
68
- component: ComponentFn;
69
- props: ComponentProps | undefined;
67
+ declare class Component<P extends ComponentProps = ComponentProps> {
68
+ component: ComponentFn<P>;
69
+ props: P;
70
70
  protected renderedNodes: AnyNode[];
71
71
  protected scope: Scope | null;
72
72
  protected parentNode: Node | undefined;
@@ -78,15 +78,15 @@ declare class Component {
78
78
  private [COMPONENT_TYPE.NORMAL];
79
79
  get isConnected(): boolean;
80
80
  get firstChild(): Node | undefined;
81
- constructor(component: ComponentFn, props: ComponentProps | undefined);
81
+ constructor(component: ComponentFn<P>, props?: P);
82
82
  mount(parentNode: Node, beforeNode?: Node): AnyNode[];
83
- update(prevNode: Component): Component;
83
+ update(prevNode: Component<any>): Component<P>;
84
84
  forceUpdate(): Promise<void>;
85
85
  /**
86
86
  * Destroy component
87
87
  */
88
88
  destroy(): void;
89
- applyProps(props: ComponentProps): void;
89
+ applyProps(props: P): void;
90
90
  }
91
91
  /**
92
92
  * check if a node is a component
@@ -100,7 +100,7 @@ declare function isComponent(node: unknown): node is Component;
100
100
  * @param {ComponentProps} props - the component props
101
101
  * @returns {Component} the component
102
102
  */
103
- declare function createComponent(componentFn: ComponentFn, props?: ComponentProps): Component;
103
+ declare function createComponent<P extends ComponentProps>(componentFn: ComponentFn<P>, props?: P): Component<P>;
104
104
 
105
105
  /**
106
106
  * Create a template factory function from HTML string
@@ -140,7 +140,7 @@ declare function template(html: string): () => Node;
140
140
  * const app = createApp(App, container);
141
141
  * ```
142
142
  */
143
- declare function createApp(component: ComponentFn, target: string | Element): Component | undefined;
143
+ declare function createApp<P extends ComponentProps = {}>(component: ComponentFn<P>, target: string | Element): Component<P> | undefined;
144
144
 
145
145
  type LifecycleHook = () => void | Promise<void>;
146
146
  /**
@@ -191,7 +191,7 @@ declare function bindElement(node: Element, key: any, defaultValue: any, setter:
191
191
  * insert(container, "Hello World", null); // Direct string support
192
192
  * ```
193
193
  */
194
- declare function insert(parent: Node, nodeFactory: (() => Node | AnyNode[]) | Node | string | AnyNode[], before?: Node): AnyNode[] | undefined;
194
+ declare function insert(parent: Node, nodeFactory: AnyNode, before?: Node): AnyNode[] | undefined;
195
195
  /**
196
196
  * Map nodes from template by indexes
197
197
  */
@@ -283,7 +283,7 @@ type EventCleanup = () => void;
283
283
  declare function addEvent(el: Element, event: string, handler: EventListener, options?: EventOptions): EventCleanup;
284
284
 
285
285
  interface FragmentProps extends ComponentProps {
286
- children: AnyNode | AnyNode[];
286
+ children?: AnyNode | AnyNode[];
287
287
  }
288
288
  /**
289
289
  * Fragment component - renders multiple children without wrapper elements
@@ -1,4 +1,4 @@
1
- import { Signal } from '@estjs/signals';
1
+ import { Signal, Computed } from '@estjs/signals';
2
2
  export { escapeHTML } from '@estjs/shared';
3
3
 
4
4
  /**
@@ -60,13 +60,13 @@ declare enum COMPONENT_TYPE {
60
60
  FOR = "for"
61
61
  }
62
62
 
63
- type AnyNode = Node | Component | Element | string | number | boolean | null | undefined | AnyNode[] | (() => AnyNode);
63
+ type AnyNode = Node | Component<any> | Element | string | number | boolean | null | undefined | AnyNode[] | (() => AnyNode) | Signal<AnyNode> | Computed<AnyNode>;
64
64
  type ComponentProps = Record<string, unknown>;
65
- type ComponentFn = (props?: ComponentProps) => AnyNode;
65
+ type ComponentFn<P = ComponentProps> = (props: P) => AnyNode;
66
66
 
67
- declare class Component {
68
- component: ComponentFn;
69
- props: ComponentProps | undefined;
67
+ declare class Component<P extends ComponentProps = ComponentProps> {
68
+ component: ComponentFn<P>;
69
+ props: P;
70
70
  protected renderedNodes: AnyNode[];
71
71
  protected scope: Scope | null;
72
72
  protected parentNode: Node | undefined;
@@ -78,15 +78,15 @@ declare class Component {
78
78
  private [COMPONENT_TYPE.NORMAL];
79
79
  get isConnected(): boolean;
80
80
  get firstChild(): Node | undefined;
81
- constructor(component: ComponentFn, props: ComponentProps | undefined);
81
+ constructor(component: ComponentFn<P>, props?: P);
82
82
  mount(parentNode: Node, beforeNode?: Node): AnyNode[];
83
- update(prevNode: Component): Component;
83
+ update(prevNode: Component<any>): Component<P>;
84
84
  forceUpdate(): Promise<void>;
85
85
  /**
86
86
  * Destroy component
87
87
  */
88
88
  destroy(): void;
89
- applyProps(props: ComponentProps): void;
89
+ applyProps(props: P): void;
90
90
  }
91
91
  /**
92
92
  * check if a node is a component
@@ -100,7 +100,7 @@ declare function isComponent(node: unknown): node is Component;
100
100
  * @param {ComponentProps} props - the component props
101
101
  * @returns {Component} the component
102
102
  */
103
- declare function createComponent(componentFn: ComponentFn, props?: ComponentProps): Component;
103
+ declare function createComponent<P extends ComponentProps>(componentFn: ComponentFn<P>, props?: P): Component<P>;
104
104
 
105
105
  /**
106
106
  * Create a template factory function from HTML string
@@ -140,7 +140,7 @@ declare function template(html: string): () => Node;
140
140
  * const app = createApp(App, container);
141
141
  * ```
142
142
  */
143
- declare function createApp(component: ComponentFn, target: string | Element): Component | undefined;
143
+ declare function createApp<P extends ComponentProps = {}>(component: ComponentFn<P>, target: string | Element): Component<P> | undefined;
144
144
 
145
145
  type LifecycleHook = () => void | Promise<void>;
146
146
  /**
@@ -191,7 +191,7 @@ declare function bindElement(node: Element, key: any, defaultValue: any, setter:
191
191
  * insert(container, "Hello World", null); // Direct string support
192
192
  * ```
193
193
  */
194
- declare function insert(parent: Node, nodeFactory: (() => Node | AnyNode[]) | Node | string | AnyNode[], before?: Node): AnyNode[] | undefined;
194
+ declare function insert(parent: Node, nodeFactory: AnyNode, before?: Node): AnyNode[] | undefined;
195
195
  /**
196
196
  * Map nodes from template by indexes
197
197
  */
@@ -283,7 +283,7 @@ type EventCleanup = () => void;
283
283
  declare function addEvent(el: Element, event: string, handler: EventListener, options?: EventOptions): EventCleanup;
284
284
 
285
285
  interface FragmentProps extends ComponentProps {
286
- children: AnyNode | AnyNode[];
286
+ children?: AnyNode | AnyNode[];
287
287
  }
288
288
  /**
289
289
  * Fragment component - renders multiple children without wrapper elements
@@ -4,7 +4,7 @@ var shared = require('@estjs/shared');
4
4
  var signals = require('@estjs/signals');
5
5
 
6
6
  /**
7
- * @estjs/template v0.0.15-beta.6
7
+ * @estjs/template v0.0.15-beta.7
8
8
  * (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
9
9
  * @license MIT
10
10
  **/
@@ -893,7 +893,7 @@ function onUpdate(hook) {
893
893
  var _a;
894
894
  _a = "normal" /* NORMAL */;
895
895
  var Component = class {
896
- constructor(component, props) {
896
+ constructor(component, props = {}) {
897
897
  this.component = component;
898
898
  this.props = props;
899
899
  // component rendered nodes (supports arrays and fragments)
@@ -904,7 +904,7 @@ var Component = class {
904
904
  this.parentNode = void 0;
905
905
  // component before node
906
906
  this.beforeNode = void 0;
907
- // component props
907
+ // component reactive props
908
908
  this.reactiveProps = {};
909
909
  // component state
910
910
  this.state = 0 /* INITIAL */;
@@ -913,8 +913,8 @@ var Component = class {
913
913
  // component type
914
914
  // @ts-ignore
915
915
  this[_a] = true;
916
- this.key = (props == null ? void 0 : props.key) ? normalizeKey(props.key) : getComponentKey(component);
917
- this.reactiveProps = signals.shallowReactive(__spreadValues({}, this.props || {}));
916
+ this.key = props.key ? normalizeKey(props.key) : getComponentKey(component);
917
+ this.reactiveProps = signals.shallowReactive(__spreadValues({}, props || {}));
918
918
  this.parentScope = getActiveScope();
919
919
  }
920
920
  get isConnected() {
@@ -1069,7 +1069,7 @@ var Component = class {
1069
1069
  this.beforeNode = void 0;
1070
1070
  this.parentScope = null;
1071
1071
  this.reactiveProps = {};
1072
- this.props = void 0;
1072
+ this.props = {};
1073
1073
  this.state = 5 /* DESTROYED */;
1074
1074
  }
1075
1075
  applyProps(props) {
@@ -1652,10 +1652,11 @@ function createResource(fetcher, options) {
1652
1652
  loading.value = true;
1653
1653
  state.value = "pending";
1654
1654
  error10.value = null;
1655
- const promise = fetcher();
1656
- currentPromise = promise.then(() => {
1657
- });
1658
1655
  try {
1656
+ const promise = fetcher();
1657
+ currentPromise = promise.then(() => {
1658
+ }).catch(() => {
1659
+ });
1659
1660
  const result = yield promise;
1660
1661
  if (currentFetchId === fetchId) {
1661
1662
  value.value = result;
@@ -1729,7 +1730,7 @@ function addAttributes(htmlContent, hydrationId) {
1729
1730
  }
1730
1731
 
1731
1732
  // src/server/render.ts
1732
- function renderToString(component, props) {
1733
+ function renderToString(component, props = {}) {
1733
1734
  if (!shared.isFunction(component)) {
1734
1735
  shared.error("Component must be a function");
1735
1736
  return "";
@@ -3,7 +3,7 @@ export { escapeHTML } from '@estjs/shared';
3
3
  import { effect, shallowReactive, isSignal, signal, isComputed } from '@estjs/signals';
4
4
 
5
5
  /**
6
- * @estjs/template v0.0.15-beta.6
6
+ * @estjs/template v0.0.15-beta.7
7
7
  * (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
8
8
  * @license MIT
9
9
  **/
@@ -892,7 +892,7 @@ function onUpdate(hook) {
892
892
  var _a;
893
893
  _a = "normal" /* NORMAL */;
894
894
  var Component = class {
895
- constructor(component, props) {
895
+ constructor(component, props = {}) {
896
896
  this.component = component;
897
897
  this.props = props;
898
898
  // component rendered nodes (supports arrays and fragments)
@@ -903,7 +903,7 @@ var Component = class {
903
903
  this.parentNode = void 0;
904
904
  // component before node
905
905
  this.beforeNode = void 0;
906
- // component props
906
+ // component reactive props
907
907
  this.reactiveProps = {};
908
908
  // component state
909
909
  this.state = 0 /* INITIAL */;
@@ -912,8 +912,8 @@ var Component = class {
912
912
  // component type
913
913
  // @ts-ignore
914
914
  this[_a] = true;
915
- this.key = (props == null ? void 0 : props.key) ? normalizeKey(props.key) : getComponentKey(component);
916
- this.reactiveProps = shallowReactive(__spreadValues({}, this.props || {}));
915
+ this.key = props.key ? normalizeKey(props.key) : getComponentKey(component);
916
+ this.reactiveProps = shallowReactive(__spreadValues({}, props || {}));
917
917
  this.parentScope = getActiveScope();
918
918
  }
919
919
  get isConnected() {
@@ -1068,7 +1068,7 @@ var Component = class {
1068
1068
  this.beforeNode = void 0;
1069
1069
  this.parentScope = null;
1070
1070
  this.reactiveProps = {};
1071
- this.props = void 0;
1071
+ this.props = {};
1072
1072
  this.state = 5 /* DESTROYED */;
1073
1073
  }
1074
1074
  applyProps(props) {
@@ -1651,10 +1651,11 @@ function createResource(fetcher, options) {
1651
1651
  loading.value = true;
1652
1652
  state.value = "pending";
1653
1653
  error10.value = null;
1654
- const promise = fetcher();
1655
- currentPromise = promise.then(() => {
1656
- });
1657
1654
  try {
1655
+ const promise = fetcher();
1656
+ currentPromise = promise.then(() => {
1657
+ }).catch(() => {
1658
+ });
1658
1659
  const result = yield promise;
1659
1660
  if (currentFetchId === fetchId) {
1660
1661
  value.value = result;
@@ -1728,7 +1729,7 @@ function addAttributes(htmlContent, hydrationId) {
1728
1729
  }
1729
1730
 
1730
1731
  // src/server/render.ts
1731
- function renderToString(component, props) {
1732
+ function renderToString(component, props = {}) {
1732
1733
  if (!isFunction(component)) {
1733
1734
  error("Component must be a function");
1734
1735
  return "";
@@ -1,8 +1,8 @@
1
1
  import {isObject,startsWith,isHTMLElement,isString,error,isArray,camelCase,capitalize,isSpecialBooleanAttr,isBooleanAttr,includeBooleanAttr,isSymbol,isUndefined,isPromise,isFunction,coerceArray,isFalsy,isNumber,isPrimitive,isNil,kebabCase}from'@estjs/shared';export{escapeHTML}from'@estjs/shared';import {effect,shallowReactive,isSignal,signal,isComputed}from'@estjs/signals';/**
2
- * @estjs/template v0.0.15-beta.6
2
+ * @estjs/template v0.0.15-beta.7
3
3
  * (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
4
4
  * @license MIT
5
5
  **/
6
- var ft=Object.defineProperty;var xe=Object.getOwnPropertySymbols;var at=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable;var Ee=(e,t,n)=>t in e?ft(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n,z=(e,t)=>{for(var n in t||(t={}))at.call(t,n)&&Ee(e,n,t[n]);if(xe)for(var n of xe(t))ut.call(t,n)&&Ee(e,n,t[n]);return e};var $=(e,t,n)=>new Promise((r,o)=>{var s=c=>{try{f(n.next(c));}catch(a){o(a);}},i=c=>{try{f(n.throw(c));}catch(a){o(a);}},f=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,i);f((n=n.apply(e,t)).next());});var R=null,lt=0,B=[];function x(){return R}function dt(e){R=e;}function Ae(e=R){let t={id:++lt,parent:e,children:null,provides:null,cleanup:null,onMount:null,onUpdate:null,onDestroy:null,isMounted:false,isDestroyed:false};return e&&(e.children||(e.children=new Set),e.children.add(t)),t}function k(e,t){let n=R;n&&B.push(n),R=e;try{return t()}finally{R=B.length>0?B.pop():n;}}function J(e){var t,n,r,o,s;if(!(!e||e.isDestroyed)){if(e.children){let i=Array.from(e.children);for(let f of i)J(f);}if(e.onDestroy){for(let i of e.onDestroy)try{i();}catch(f){}e.onDestroy.clear();}if(e.cleanup){for(let i of e.cleanup)try{i();}catch(f){}e.cleanup.clear();}(t=e.parent)!=null&&t.children&&e.parent.children.delete(e),(n=e.children)==null||n.clear(),(r=e.provides)==null||r.clear(),(o=e.onMount)==null||o.clear(),(s=e.onUpdate)==null||s.clear(),dt(e.parent),e.parent=null,e.isDestroyed=true;}}function K(e){let t=R;t&&(t.cleanup||(t.cleanup=new Set),t.cleanup.add(e));}var ve="_$spread$";var be="http://www.w3.org/2000/svg",Q="http://www.w3.org/2000/xlink",Z="http://www.w3.org/2000/xmlns/",ee=/^\d+-\d+$/;var _e=1e3,ke=new WeakMap;function Ce(e){let t=ke.get(e);if(!t){let n=e.name||"anonymous",r=De(e.toString()).toString(36);t=`${n}_${r}`,ke.set(e,t);}return t}function De(e){let t=0,n=e.length<100?e.length:100;for(let r=0;r<n;r++)t=Math.trunc((t<<5)-t+e.charCodeAt(r));return t<0?-t:t}var ht=0;function ne(e){if(!isFalsy(e)){if(isString(e))return e.length<=_e?e:`${e.slice(0,_e-10)}_${De(e).toString(36)}`;if(isNumber(e))return String(e);if(isSymbol(e)){let t=Symbol.keyFor(e);if(t)return `_s.${t}`;let n=e.description;return n?`_s.${n}`:`${ht++}`}return String(e)}}var te=Symbol("essor.key");function F(e,t){if(m(e)||!e||e.nodeType===Node.DOCUMENT_NODE)return;let n=ne(t);isFalsy(n)?delete e[te]:e[te]=n;}function T(e){if(e)return m(e)?e.key:e[te]}function Nt(e,t){let n=new Set(t);return new Proxy(e,{get(r,o){if(!n.has(o))return Reflect.get(r,o)},ownKeys(r){return Reflect.ownKeys(r).filter(o=>!n.has(o))},getOwnPropertyDescriptor(r,o){if(!n.has(o))return Reflect.getOwnPropertyDescriptor(r,o)},has(r,o){return n.has(o)?false:Reflect.has(r,o)}})}function A(e){if(e)try{if(m(e))e.destroy();else {let t=e;t.parentElement&&t.remove();}}catch(t){error("Failed to remove node:",t);}}function S(e,t,n){if(!(!e||!t))try{let r=m(n)?n.firstChild:n;if(m(t)){t.mount(e,r);return}r?e.insertBefore(t,r):e.appendChild(t);}catch(r){error("Failed to insert node:",r);}}function oe(e,t,n){if(!(!e||!t||!n||t===n))try{let r=m(n)?n.beforeNode:n.nextSibling;A(n),S(e,t,r);}catch(r){error("Failed to replace node:",r);}}function C(e){if(e){if(m(e))return e.firstChild;if(!isPrimitive(e))return e}}function D(e,t){let n=T(e),r=T(t);if(n!==r)return false;let o=m(e),s=m(t);if(o&&s)return e.component===t.component;if(o!==s)return false;if(isPrimitive(e)||isPrimitive(t))return e===t;let i=e,f=t;return i.nodeType!==f.nodeType?false:i.nodeType===Node.ELEMENT_NODE?i.tagName===f.tagName:true}function L(e){if(isHTMLElement(e))return e;if(isPrimitive(e)){let t=isFalsy(e)?"":String(e);return document.createTextNode(t)}return e}function Le(e){return e instanceof HTMLInputElement}function Pe(e){return e instanceof HTMLSelectElement}function we(e){return e instanceof HTMLTextAreaElement}function ie(e){return e instanceof Text}function Re(e,t){if(e===t)return true;if(!e||!t||Array.isArray(e)!==Array.isArray(t))return false;for(let n in e)if(e[n]!==t[n])return false;for(let n in t)if(!(n in e))return false;return true}function He(e,t){if(m(e)||m(t))return;let n=T(e);n&&!T(t)&&F(t,n);}function P(e,t,n){if(n===t)return t;let r=isHTMLElement(t);if(isHTMLElement(n)&&r){if(n.isEqualNode(t))return t;if(t.tagName===n.tagName){let f=t.attributes,c=n.attributes;for(let a=f.length-1;a>=0;a--){let l=f[a].name;n.hasAttribute(l)||t.removeAttribute(l);}for(let a=0,l=c.length;a<l;a++){let u=c[a];t.getAttribute(u.name)!==u.value&&t.setAttribute(u.name,u.value);}return He(t,n),t}}if(ie(t)&&ie(n))return t.textContent!==n.textContent&&(t.textContent=n.textContent),He(t,n),t;let s=m(t),i=m(n);return s&&i&&t.component===n.component?n.update(t):(oe(e,n,t),n)}function Ie(e,t,n,r){let o=t.length,s=n.length;if(o===0&&s===0)return [];if(o===0){for(let i=0;i<s;i++)S(e,n[i],r);return n}if(s===0){for(let i=0;i<o;i++)A(t[i]);return []}if(o===1&&s===1){let i=t[0],f=n[0];return D(i,f)?(P(e,i,f),n[0]=i):oe(e,f,i),n}if(o===2&&s===2){let i=t[0],f=t[1],c=n[0],a=n[1];if(D(i,c)&&D(f,a))return P(e,i,c),P(e,f,a),n[0]=i,n[1]=f,n;if(D(i,a)&&D(f,c)){P(e,i,a),P(e,f,c);let l=C(f),u=C(i);return l&&u&&l.parentNode===e&&e.insertBefore(l,u),n[0]=f,n[1]=i,n}}return xt(e,t,n,r)}function xt(e,t,n,r){let o=0,s=0,i=t.length-1,f=n.length-1,c=t[0],a=t[i],l=n[0],u=n[f];for(;o<=i&&s<=f;)if(!c)c=t[++o];else if(!a)a=t[--i];else if(D(c,l))P(e,c,l),n[s]=c,c=t[++o],l=n[++s];else break;for(;o<=i&&s<=f;)if(!c)c=t[++o];else if(!a)a=t[--i];else if(D(a,u))P(e,a,u),n[f]=a,a=t[--i],u=n[--f];else break;if(o>i){if(s<=f){let h=f+1<n.length?C(n[f+1]):r;for(let y=s;y<=f;y++)S(e,n[y],h);}}else if(s>f)for(let h=o;h<=i;h++){let y=t[h];y&&A(y);}else Et(e,t,n,o,i,s,f,r);return n}function Et(e,t,n,r,o,s,i,f){let c=i-s+1,a=n.length,l;for(let g=s;g<=i;g++){let N=T(n[g]);N!==void 0&&(l||(l=Object.create(null)),l[N]=g);}let u=new Int32Array(c),h=false,y=0,b=0;for(let g=r;g<=o;g++){let N=t[g];if(!N)continue;if(b>=c){A(N);continue}let E,w=T(N);if(w!==void 0&&l&&w in l)E=l[w];else for(let _=s;_<=i;_++)if(u[_-s]===0&&w===void 0&&T(n[_])===void 0&&D(N,n[_])){E=_;break}E===void 0?A(N):(u[E-s]=g+1,E>=y?y=E:h=true,P(e,N,n[E]),n[E]=N,b++);}let I=h?At(u):[],q=I.length-1;for(let g=c-1;g>=0;g--){let N=s+g,E=n[N],w=N+1<a?C(n[N+1]):f;if(u[g]===0)S(e,E,w);else if(h)if(q<0||g!==I[q]){let _=C(E);_&&_.parentNode===e&&S(e,_,w);}else q--;}}function At(e){let t=e.length;if(t===0)return [];if(t===1)return e[0]!==0?[0]:[];let n=[],r=new Int32Array(t),o,s,i,f,c;for(o=0;o<t;o++){let a=e[o];if(a!==0){if(s=n[n.length-1],n.length===0||e[s]<a){r[o]=s,n.push(o);continue}for(i=0,f=n.length-1;i<f;)c=i+f>>1,e[n[c]]<a?i=c+1:f=c;a<e[n[i]]&&(i>0&&(r[o]=n[i-1]),n[i]=o);}}for(i=n.length,f=n[i-1];i-- >0;)n[i]=f,f=r[f];return n}function v(e,t,n,r){e.addEventListener(t,n,r),K(()=>{e.removeEventListener(t,n,r);});}function _t(e,t,n,r){if(Le(e))switch(e.type){case "checkbox":v(e,"change",()=>{r(!!e.checked);});break;case "radio":v(e,"change",()=>{r(e.checked?e.value:"");});break;case "file":v(e,"change",()=>{r(e.files);});break;case "number":case "range":v(e,"input",()=>{r(e.value||"");});break;case "date":case "datetime-local":case "month":case "time":case "week":v(e,"change",()=>{r(e.value||"");});break;default:v(e,"input",()=>{r(e.value);});break}else Pe(e)?v(e,"change",()=>{if(e.multiple){let o=Array.from(e.options).filter(s=>s.selected).map(s=>s.value);r(o);}else r(e.value);}):we(e)&&v(e,"input",()=>{r(e.value);});}function se(e,t,n){if(!e)return;let r=x(),o=[],s=effect(()=>{let i=()=>{let f=isFunction(t)?t():t,c=coerceArray(f).map(a=>isFunction(a)?a():a).flatMap(a=>a).map(L);o=Ie(e,o,c,n);};r&&!r.isDestroyed?k(r,i):i();});return K(()=>{s(),o.forEach(i=>A(i)),o.length=0;}),o}function ce(e,t){let n=t.length,r=new Array(n),o=new Set(t),s=1,i=0,f=c=>{if(c.nodeType!==Node.DOCUMENT_FRAGMENT_NODE){if(o.has(s)&&(r[i++]=c,i===n))return true;s++;}let a=c.firstChild;for(;a;){if(f(a))return true;a=a.nextSibling;}return false};return f(e),r}function kt(e){let t=x();if(t){if(t.isMounted){try{e();}catch(n){}return}t.onMount||(t.onMount=new Set),t.onMount.add(e);}}function Tt(e){let t=x();t&&(t.onUpdate||(t.onUpdate=new Set),t.onUpdate.add(e));}function Ct(e){let t=x();t&&(t.onDestroy||(t.onDestroy=new Set),t.onDestroy.add(e));}function Ke(e){!e||e.isDestroyed||e.isMounted||(e.isMounted=true,e.onMount&&k(e,()=>{for(let t of e.onMount)try{t();}catch(n){}}));}function fe(e){if(!(!e||e.isDestroyed)&&e.onUpdate)for(let t of e.onUpdate)try{t();}catch(n){}}function ae(e){kt(e);}function ue(e){Ct(e);}function Dt(e){Tt(e);}var Ue;Ue="normal";var G=class{constructor(t,n){this.component=t;this.props=n;this.renderedNodes=[];this.scope=null;this.parentNode=void 0;this.beforeNode=void 0;this.reactiveProps={};this.state=0;this.parentScope=null;this[Ue]=true;this.key=n!=null&&n.key?ne(n.key):Ce(t),this.reactiveProps=shallowReactive(z({},this.props||{})),this.parentScope=x();}get isConnected(){return this.state===2}get firstChild(){for(let t of this.renderedNodes){let n=C(t);if(n)return n}}mount(t,n){var s;if(this.parentNode=t,this.beforeNode=n,this.state=1,this.renderedNodes.length>0){for(let i of this.renderedNodes)S(t,i,n);return this.state=2,this.renderedNodes}let r=(s=this.parentScope)!=null?s:x();this.scope=Ae(r);let o=k(this.scope,()=>{var c;let i=this.component(this.reactiveProps);return isFunction(i)&&(i=i(this.reactiveProps)),(isSignal(i)||isComputed(i))&&(i=i.value),(c=se(t,i,n))!=null?c:[]});return this.renderedNodes=o,k(this.scope,()=>{this.applyProps(this.props||{});}),this.state=2,this.scope&&Ke(this.scope),this.renderedNodes}update(t){if(this.key!==t.key)return this.mount(t.parentNode,t.beforeNode),this;if(this.parentNode=t.parentNode,this.beforeNode=t.beforeNode,this.scope=t.scope,this.parentScope=t.parentScope,this.renderedNodes=t.renderedNodes,this.state=t.state,this.reactiveProps=t.reactiveProps,this.props)for(let n in this.props){if(n==="key")continue;let r=this.props[n],o=this.reactiveProps[n];Object.is(o,r)||isObject(o)&&isObject(r)&&Re(o,r)||(this.reactiveProps[n]=r);}return !this.isConnected&&this.parentNode&&this.mount(this.parentNode,this.beforeNode),this.scope&&(k(this.scope,()=>{this.applyProps(this.props||{});}),fe(this.scope)),this}forceUpdate(){return $(this,null,function*(){if(yield Promise.resolve(),this.state===5||!this.parentNode||!this.scope)return;let t=[...this.renderedNodes];try{k(this.scope,()=>{let n=this.component(this.reactiveProps);isFunction(n)&&(n=n(this.reactiveProps)),(isSignal(n)||isComputed(n))&&(n=n.value);let r=coerceArray(n);if(this.parentNode){let o=this.beforeNode;if(!o&&this.renderedNodes.length>0){let s=this.renderedNodes[this.renderedNodes.length-1],i=C(s);i&&(o=i.nextSibling);}for(let s of this.renderedNodes)A(s);for(let s of r)S(this.parentNode,s,o);this.renderedNodes=r;}}),this.scope&&fe(this.scope);}catch(n){throw this.renderedNodes=t,n}})}destroy(){if(this.state===4||this.state===5)return;this.state=4;let t=this.scope;t&&(J(t),this.scope=null);for(let n of this.renderedNodes)A(n);this.renderedNodes=[],this.parentNode=void 0,this.beforeNode=void 0,this.parentScope=null,this.reactiveProps={},this.props=void 0,this.state=5;}applyProps(t){if(!t)return;let n=this.firstChild;for(let[r,o]of Object.entries(t))if(startsWith(r,"on")&&n){let s=r.slice(2).toLowerCase();isHTMLElement(n)&&v(n,s,o);}else r==="ref"&&isSignal(o)&&(o.value=n);this.props=t;}};function m(e){return !!e&&!!e.normal}function O(e,t){return m(e)?e:new G(e,t)}function de(e){let t,n=()=>{let r=document.createElement("template");r.innerHTML=e;let o=r.content.firstChild;if(!o)throw new Error("Invalid template: empty content");return o};return ()=>(t||(t=n())).cloneNode(true)}function Ht(e,t){let n=isString(t)?document.querySelector(t):t;if(!n){error(`Target element not found: ${t}`);return}n.innerHTML&&(error(`Target element is not empty, it will be delete: ${t}`),n.innerHTML="");let o=O(e);return o.mount(n),o}function pe(e,t){let n=x();n&&(n.provides||(n.provides=new Map),n.provides.set(e,t));}function me(e,t){let n=x();if(!n)return t;let r=n;for(;r;){if(r.provides){let o=r.provides.get(e);if(o)return o}r=r.parent;}return t}function $t(e){let t=e.target,n=`${e.type}`,r=e.target,o=e.currentTarget,s=c=>Object.defineProperty(e,"target",{configurable:true,value:c}),i=()=>{let c=t[`_$${n}`];if(c&&isFunction(c)&&!t.disabled){let a=t[`${n}Data`];if(a?c.call(t,a,e):c.call(t,e),e.cancelBubble)return false}return t.host&&!isString(t.host)&&!t.host._$host&&isFunction(t.contains)&&t.contains(e.target)&&s(t.host),true},f=()=>{for(;i()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:true,get(){return t||document}}),e.composedPath){let c=e.composedPath();s(c[0]);for(let a=0;a<c.length-2&&(t=c[a],!!i());a++){if(t._$host){t=t._$host,f();break}if(t.parentNode===o)break}}else f();s(r);}var Ge=Symbol("_$EVENTS");function Kt(e,t=window.document){let n=t,r=n[Ge]||(n[Ge]=new Set);for(let o of e)r.has(o)||(r.add(o),t.addEventListener(o,$t));}function jt(e,t,n,r=false){if(t===n)return;let o=X(n),s=X(t);o&&s===o||(o?r?e.setAttribute("class",o):e.className=o:e.removeAttribute("class"));}function X(e){if(e==null)return "";if(typeof e=="string")return e.trim();if(isArray(e))return e.map(X).filter(Boolean).join(" ");if(isObject(e)){let t=[];for(let n in e)e[n]&&t.push(n);return t.join(" ")}return String(e).trim()}var Xe=/\s*!important$/,Gt=["Webkit","Moz","ms"],ye={};function Xt(e,t,n){let r=e.style,o=isString(n);if(n&&o){t!==n&&(r.cssText=n);return}if(!n){t&&e.removeAttribute("style");return}if(t&&!isString(t))for(let s in t)(!n||n[s]==null)&&U(r,s,"");else if(t&&isString(t)){let s=t.split(";");for(let i of s){let f=i.indexOf(":");if(f>0){let c=i.slice(0,f).trim();n&&isObject(n)&&n[c]==null&&U(r,c,"");}}}if(n&&!isString(n))for(let s in n){let i=n[s];(!t||isString(t)||t[s]!==i)&&i!=null&&U(r,s,i);}}function U(e,t,n){if(isArray(n)){for(let o of n)U(e,t,o);return}if((n==null||n==="")&&(n=""),t.startsWith("--")){e.setProperty(t,n);return}let r=Yt(e,t);typeof n=="string"&&Xe.test(n)?e.setProperty(camelCase(r),n.replace(Xe,""),"important"):e[r]=n;}function Yt(e,t){let n=ye[t];if(n)return n;let r=camelCase(t);if(r!=="filter"&&r in e)return ye[t]=r;r=capitalize(r);for(let o of Gt){let s=o+r;if(s in e)return ye[t]=s}return t}function We(e,t,n,r){if(t==="key"){r==null?F(e,void 0):F(e,String(r));return}if(t===ve){Object.keys(r).forEach(u=>{We(e,u,n==null?void 0:n[u],r==null?void 0:r[u]);});return}let o=(e==null?void 0:e.namespaceURI)===be,s=o&&t.startsWith("xlink:"),i=o&&t.startsWith("xmlns:"),f=isSpecialBooleanAttr(t)||isBooleanAttr(t);if(n===r)return;let c=t.toLowerCase();if(/^on[a-z]+/.test(c)||c==="innerhtml")return;if(r==null){if(s)e.removeAttributeNS(Q,t.slice(6));else if(i){let u=t.slice(6);e.removeAttributeNS(Z,u);}else e.removeAttribute(t);return}if(s){e.setAttributeNS(Q,t,String(r));return}if(i){e.setAttributeNS(Z,t,String(r));return}if(f){includeBooleanAttr(r)?e.setAttribute(t,""):e.removeAttribute(t);return}let a=isSymbol(r)?String(r):r;if((c==="href"||c==="src"||c==="xlink:href")&&typeof a=="string"){let u=a.trim().toLowerCase();if(u.startsWith("javascript:")||u.startsWith("data:"))return}if(o)e.setAttribute(t,String(a));else if(t in e)try{e[t]=a;}catch(u){e.setAttribute(t,String(a));}else e.setAttribute(t,String(a));}function Zt(e,t,n,r){if(!(r!=null&&r.delegate))return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r);let o=r.delegate,s=f=>{let c=f.target;(c.matches(o)||c.closest(o))&&n.call(e,f);},i=z({},r);return i.delegate=void 0,e.addEventListener(t,s,i),()=>{e.removeEventListener(t,s,i);}}function en(e){return e==null?void 0:e.children}en.fragment=true;function io(e){return !!e&&!!e.fragment}function nn(e){if(typeof document=="undefined"){let r=e.children;return r?(isArray(r)?r:[r]).map(s=>String(s||"")).join(""):""}let t=document.createComment("portal");t.portal=true;let n=e.children;if(n){let r=isArray(n)?n:[n],o=[];ae(()=>{let s=isString(e.target)?document.querySelector(e.target):e.target;s&&(r.forEach(i=>{if(i!=null){let f=L(i);f&&(S(s,f),o.push(f));}}),K(()=>{o.forEach(i=>{typeof i!="string"&&i.parentNode===s&&s.removeChild(i);});}));});}return t}nn.portal=true;function mo(e){return !!e&&!!e.portal}var ge=Symbol("SuspenseContext");function sn(e){if(isUndefined(document)){let u=e.fallback;return u?String(u||""):""}let t=document.createElement("div");t.style.display="contents";let n=true,r=0,o=false,s=null,i=()=>{if(!o){for(o=true;t.firstChild;)t.removeChild(t.firstChild);if(e.fallback!=null){let u=L(e.fallback);u&&S(t,u);}}},f=()=>{if(!(!o||!(s||e.children!=null&&!isPromise(e.children)))){for(o=false;t.firstChild;)t.removeChild(t.firstChild);s?c(s):e.children!=null&&!isPromise(e.children)&&c(e.children);}},c=u=>{for(;t.firstChild;)t.removeChild(t.firstChild);if(u==null)return;let h=x();if((isArray(u)?u:[u]).forEach(b=>{if(b!=null){m(b)&&(b.parentContext=h);let I=L(b);I&&S(t,I);}}),o){for(;t.firstChild;)t.removeChild(t.firstChild);if(e.fallback!=null){let b=L(e.fallback);b&&S(t,b);}}},a={register:u=>{r++,i(),u.then(()=>{n&&(r--,r===0&&f());}).catch(h=>{n&&(r--,r===0&&f());});},increment:()=>{r++,i();},decrement:()=>{r--,r===0&&f();}};pe(ge,a);let l=e.children;return isPromise(l)?(l.then(u=>{s=u;}).catch(()=>{}),a.register(l)):l!=null?c(l):i(),ue(()=>{for(n=false;t.firstChild;)t.removeChild(t.firstChild);}),t}sn.suspense=true;function bo(e){return !!e&&!!e.suspense}function Lo(e,t){let n=signal(t==null?void 0:t.initialValue),r=signal(true),o=signal(null),s=signal("pending"),i=0,f=null,c=()=>$(null,null,function*(){let u=++i;r.value=true,s.value="pending",o.value=null;let h=e();f=h.then(()=>{});try{let y=yield h;u===i&&(n.value=y,s.value="ready",r.value=!1);}catch(y){u===i&&(o.value=y instanceof Error?y:new Error(String(y)),s.value="errored",r.value=false);}});c();let a=(()=>{if(r.value&&f){let u=me(ge,null);u&&u.register(f);}return n.value});return a.loading=r,a.error=o,a.state=s,[a,{mutate:u=>{n.value=u,s.value="ready",r.value=false,o.value=null;},refetch:()=>$(null,null,function*(){yield c();})}]}var Be=0;function Se(){return `${Be++}`}function W(){Be=0;}function Ne(){}function M(e,t=false){return isNil(e)?"":isString(e)?e:isArray(e)?e.map(n=>M(n,t)).join(""):isFunction(e)?M(e(),t):String(e)}function Ze(e,t){let n=/^<([a-z]+)(\s*)([^>]*)>/i,r=/data-idx="(\d+)"/g,o=/<!--(.*?)-->/g;return e.replace(n,`<$1$2$3 data-hk="${t}">`).replaceAll(r,`data-idx="${t}-$1"`).replaceAll(o,`<!--${t}-$1-->`)}function ln(e,t){if(!isFunction(e))return error("Component must be a function"),"";W();let n=e(t);return M(n)}function dn(e,t,...n){let r="",o=0;for(let i of e)if(r+=i,o<n.length){let f=n[o++];f&&(r+=M(f));}return Ze(r,t)}function pn(e,t={}){if(!isFunction(e))return error("create ssg component: Component is not a function"),"";let n=e(t);return M(n)}function ot(e){if(isArray(e)){let t={};for(let n of e){let r=isString(n)?En(n):ot(n);if(r)for(let o in r)t[o]=r[o];}return t}if(isString(e)||isObject(e))return e}var Sn=/;(?![^(]*\))/g,Nn=/:([\s\S]+)/,xn=/\/\*[\s\S]*?\*\//g;function En(e){let t={};return e.replaceAll(xn,"").split(Sn).forEach(n=>{if(n){let r=n.split(Nn);r.length>1&&(t[r[0].trim()]=r[1].trim());}}),t}function An(e){if(!e)return "";if(isString(e))return e;let t="";for(let n in e){let r=e[n];if(isString(r)||isNumber(r)){let o=n.startsWith("--")?n:kebabCase(n);t+=`${o}:${r};`;}}return t}function it(e){let t="";if(isString(e))t=e;else if(isArray(e))for(let n of e){let r=it(n);r&&(t+=`${r} `);}else if(isObject(e))for(let n in e)e[n]&&(t+=`${n} `);return t.trim()}function st(e,t,n){if(isSignal(t)||isComputed(t))return st(e,t.value);if(!t&&t!==0)return "";if(e==="style"){let r=ot(t);return r?isString(r)?` style="${r}"`:` style="${An(r)}"`:""}if(e==="class"){let r=it(t);return r?` class="${r}"`:""}return e.startsWith("on")?"":t===true?` ${e}`:` ${e}="${t}"`}function bn(e){return ()=>{let t=Se();return document.querySelector(`[data-hk="${t}"]`)||de(e)()}}function _n(e,t){let n=e.dataset.hk;if(!n)return ce(e,t);let r=[],o=e.querySelectorAll(`[data-idx^="${n}"]`);o.length>0&&r.push(...Array.from(o).filter(c=>{let a=c.dataset.idx;return a!==null&&ee.test(a)}).map(c=>{let a=c.dataset.idx||"",[l,u]=a.split("-");return {hk:l,idx:u,node:c}}));let s=[],i=c=>{if(c.nodeType===Node.COMMENT_NODE&&c.textContent&&ee.test(c.textContent)){let[l,u]=c.textContent.split("-");s.push({hk:l,idx:u,node:c});}let a=c.firstChild;for(;a;)i(a),a=a.nextSibling;};i(e),r.push(...s);let f=[e];return t.forEach(c=>{let a=r.find(l=>l.idx===String(c));a&&f.push(a.node);}),f}function kn(e,t,n={}){W();try{let r=isString(t)?document.querySelector(t):t;if(!r){error("Hydration error: Root element not found");return}let o=O(e,n);return o.mount(r),Ne(),o}catch(r){error("Hydration error:",r);return}}
7
- export{G as Component,en as Fragment,nn as Portal,sn as Suspense,ge as SuspenseContext,Zt as addEvent,v as addEventListener,_t as bindElement,Ht as createApp,O as createComponent,Lo as createResource,pn as createSSGComponent,Kt as delegateEvents,Se as getHydrationKey,bn as getRenderedElement,kn as hydrate,me as inject,se as insert,m as isComponent,io as isFragment,mo as isPortal,bo as isSuspense,ce as mapNodes,_n as mapSSRNodes,X as normalizeClass,Nt as omitProps,ue as onDestroy,ae as onMount,Dt as onUpdate,We as patchAttr,jt as patchClass,Xt as patchStyle,pe as provide,dn as render,ln as renderToString,st as setSSGAttr,U as setStyle,de as template};//# sourceMappingURL=template.esm.js.map
6
+ var at=Object.defineProperty;var xe=Object.getOwnPropertySymbols;var ft=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable;var Ee=(e,t,n)=>t in e?at(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n,z=(e,t)=>{for(var n in t||(t={}))ft.call(t,n)&&Ee(e,n,t[n]);if(xe)for(var n of xe(t))ut.call(t,n)&&Ee(e,n,t[n]);return e};var $=(e,t,n)=>new Promise((r,o)=>{var s=c=>{try{a(n.next(c));}catch(f){o(f);}},i=c=>{try{a(n.throw(c));}catch(f){o(f);}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,i);a((n=n.apply(e,t)).next());});var R=null,lt=0,B=[];function N(){return R}function dt(e){R=e;}function Ae(e=R){let t={id:++lt,parent:e,children:null,provides:null,cleanup:null,onMount:null,onUpdate:null,onDestroy:null,isMounted:false,isDestroyed:false};return e&&(e.children||(e.children=new Set),e.children.add(t)),t}function k(e,t){let n=R;n&&B.push(n),R=e;try{return t()}finally{R=B.length>0?B.pop():n;}}function J(e){var t,n,r,o,s;if(!(!e||e.isDestroyed)){if(e.children){let i=Array.from(e.children);for(let a of i)J(a);}if(e.onDestroy){for(let i of e.onDestroy)try{i();}catch(a){}e.onDestroy.clear();}if(e.cleanup){for(let i of e.cleanup)try{i();}catch(a){}e.cleanup.clear();}(t=e.parent)!=null&&t.children&&e.parent.children.delete(e),(n=e.children)==null||n.clear(),(r=e.provides)==null||r.clear(),(o=e.onMount)==null||o.clear(),(s=e.onUpdate)==null||s.clear(),dt(e.parent),e.parent=null,e.isDestroyed=true;}}function K(e){let t=R;t&&(t.cleanup||(t.cleanup=new Set),t.cleanup.add(e));}var ve="_$spread$";var be="http://www.w3.org/2000/svg",Q="http://www.w3.org/2000/xlink",Z="http://www.w3.org/2000/xmlns/",ee=/^\d+-\d+$/;var _e=1e3,ke=new WeakMap;function Te(e){let t=ke.get(e);if(!t){let n=e.name||"anonymous",r=Ce(e.toString()).toString(36);t=`${n}_${r}`,ke.set(e,t);}return t}function Ce(e){let t=0,n=e.length<100?e.length:100;for(let r=0;r<n;r++)t=Math.trunc((t<<5)-t+e.charCodeAt(r));return t<0?-t:t}var ht=0;function ne(e){if(!isFalsy(e)){if(isString(e))return e.length<=_e?e:`${e.slice(0,_e-10)}_${Ce(e).toString(36)}`;if(isNumber(e))return String(e);if(isSymbol(e)){let t=Symbol.keyFor(e);if(t)return `_s.${t}`;let n=e.description;return n?`_s.${n}`:`${ht++}`}return String(e)}}var te=Symbol("essor.key");function F(e,t){if(m(e)||!e||e.nodeType===Node.DOCUMENT_NODE)return;let n=ne(t);isFalsy(n)?delete e[te]:e[te]=n;}function P(e){if(e)return m(e)?e.key:e[te]}function Nt(e,t){let n=new Set(t);return new Proxy(e,{get(r,o){if(!n.has(o))return Reflect.get(r,o)},ownKeys(r){return Reflect.ownKeys(r).filter(o=>!n.has(o))},getOwnPropertyDescriptor(r,o){if(!n.has(o))return Reflect.getOwnPropertyDescriptor(r,o)},has(r,o){return n.has(o)?false:Reflect.has(r,o)}})}function A(e){if(e)try{if(m(e))e.destroy();else {let t=e;t.parentElement&&t.remove();}}catch(t){error("Failed to remove node:",t);}}function g(e,t,n){if(!(!e||!t))try{let r=m(n)?n.firstChild:n;if(m(t)){t.mount(e,r);return}r?e.insertBefore(t,r):e.appendChild(t);}catch(r){error("Failed to insert node:",r);}}function oe(e,t,n){if(!(!e||!t||!n||t===n))try{let r=m(n)?n.beforeNode:n.nextSibling;A(n),g(e,t,r);}catch(r){error("Failed to replace node:",r);}}function T(e){if(e){if(m(e))return e.firstChild;if(!isPrimitive(e))return e}}function C(e,t){let n=P(e),r=P(t);if(n!==r)return false;let o=m(e),s=m(t);if(o&&s)return e.component===t.component;if(o!==s)return false;if(isPrimitive(e)||isPrimitive(t))return e===t;let i=e,a=t;return i.nodeType!==a.nodeType?false:i.nodeType===Node.ELEMENT_NODE?i.tagName===a.tagName:true}function D(e){if(isHTMLElement(e))return e;if(isPrimitive(e)){let t=isFalsy(e)?"":String(e);return document.createTextNode(t)}return e}function De(e){return e instanceof HTMLInputElement}function Le(e){return e instanceof HTMLSelectElement}function we(e){return e instanceof HTMLTextAreaElement}function ie(e){return e instanceof Text}function Re(e,t){if(e===t)return true;if(!e||!t||Array.isArray(e)!==Array.isArray(t))return false;for(let n in e)if(e[n]!==t[n])return false;for(let n in t)if(!(n in e))return false;return true}function He(e,t){if(m(e)||m(t))return;let n=P(e);n&&!P(t)&&F(t,n);}function L(e,t,n){if(n===t)return t;let r=isHTMLElement(t);if(isHTMLElement(n)&&r){if(n.isEqualNode(t))return t;if(t.tagName===n.tagName){let a=t.attributes,c=n.attributes;for(let f=a.length-1;f>=0;f--){let l=a[f].name;n.hasAttribute(l)||t.removeAttribute(l);}for(let f=0,l=c.length;f<l;f++){let u=c[f];t.getAttribute(u.name)!==u.value&&t.setAttribute(u.name,u.value);}return He(t,n),t}}if(ie(t)&&ie(n))return t.textContent!==n.textContent&&(t.textContent=n.textContent),He(t,n),t;let s=m(t),i=m(n);return s&&i&&t.component===n.component?n.update(t):(oe(e,n,t),n)}function Ie(e,t,n,r){let o=t.length,s=n.length;if(o===0&&s===0)return [];if(o===0){for(let i=0;i<s;i++)g(e,n[i],r);return n}if(s===0){for(let i=0;i<o;i++)A(t[i]);return []}if(o===1&&s===1){let i=t[0],a=n[0];return C(i,a)?(L(e,i,a),n[0]=i):oe(e,a,i),n}if(o===2&&s===2){let i=t[0],a=t[1],c=n[0],f=n[1];if(C(i,c)&&C(a,f))return L(e,i,c),L(e,a,f),n[0]=i,n[1]=a,n;if(C(i,f)&&C(a,c)){L(e,i,f),L(e,a,c);let l=T(a),u=T(i);return l&&u&&l.parentNode===e&&e.insertBefore(l,u),n[0]=a,n[1]=i,n}}return xt(e,t,n,r)}function xt(e,t,n,r){let o=0,s=0,i=t.length-1,a=n.length-1,c=t[0],f=t[i],l=n[0],u=n[a];for(;o<=i&&s<=a;)if(!c)c=t[++o];else if(!f)f=t[--i];else if(C(c,l))L(e,c,l),n[s]=c,c=t[++o],l=n[++s];else break;for(;o<=i&&s<=a;)if(!c)c=t[++o];else if(!f)f=t[--i];else if(C(f,u))L(e,f,u),n[a]=f,f=t[--i],u=n[--a];else break;if(o>i){if(s<=a){let y=a+1<n.length?T(n[a+1]):r;for(let x=s;x<=a;x++)g(e,n[x],y);}}else if(s>a)for(let y=o;y<=i;y++){let x=t[y];x&&A(x);}else Et(e,t,n,o,i,s,a,r);return n}function Et(e,t,n,r,o,s,i,a){let c=i-s+1,f=n.length,l;for(let h=s;h<=i;h++){let S=P(n[h]);S!==void 0&&(l||(l=Object.create(null)),l[S]=h);}let u=new Int32Array(c),y=false,x=0,b=0;for(let h=r;h<=o;h++){let S=t[h];if(!S)continue;if(b>=c){A(S);continue}let E,w=P(S);if(w!==void 0&&l&&w in l)E=l[w];else for(let _=s;_<=i;_++)if(u[_-s]===0&&w===void 0&&P(n[_])===void 0&&C(S,n[_])){E=_;break}E===void 0?A(S):(u[E-s]=h+1,E>=x?x=E:y=true,L(e,S,n[E]),n[E]=S,b++);}let I=y?At(u):[],q=I.length-1;for(let h=c-1;h>=0;h--){let S=s+h,E=n[S],w=S+1<f?T(n[S+1]):a;if(u[h]===0)g(e,E,w);else if(y)if(q<0||h!==I[q]){let _=T(E);_&&_.parentNode===e&&g(e,_,w);}else q--;}}function At(e){let t=e.length;if(t===0)return [];if(t===1)return e[0]!==0?[0]:[];let n=[],r=new Int32Array(t),o,s,i,a,c;for(o=0;o<t;o++){let f=e[o];if(f!==0){if(s=n[n.length-1],n.length===0||e[s]<f){r[o]=s,n.push(o);continue}for(i=0,a=n.length-1;i<a;)c=i+a>>1,e[n[c]]<f?i=c+1:a=c;f<e[n[i]]&&(i>0&&(r[o]=n[i-1]),n[i]=o);}}for(i=n.length,a=n[i-1];i-- >0;)n[i]=a,a=r[a];return n}function v(e,t,n,r){e.addEventListener(t,n,r),K(()=>{e.removeEventListener(t,n,r);});}function _t(e,t,n,r){if(De(e))switch(e.type){case "checkbox":v(e,"change",()=>{r(!!e.checked);});break;case "radio":v(e,"change",()=>{r(e.checked?e.value:"");});break;case "file":v(e,"change",()=>{r(e.files);});break;case "number":case "range":v(e,"input",()=>{r(e.value||"");});break;case "date":case "datetime-local":case "month":case "time":case "week":v(e,"change",()=>{r(e.value||"");});break;default:v(e,"input",()=>{r(e.value);});break}else Le(e)?v(e,"change",()=>{if(e.multiple){let o=Array.from(e.options).filter(s=>s.selected).map(s=>s.value);r(o);}else r(e.value);}):we(e)&&v(e,"input",()=>{r(e.value);});}function se(e,t,n){if(!e)return;let r=N(),o=[],s=effect(()=>{let i=()=>{let a=isFunction(t)?t():t,c=coerceArray(a).map(f=>isFunction(f)?f():f).flatMap(f=>f).map(D);o=Ie(e,o,c,n);};r&&!r.isDestroyed?k(r,i):i();});return K(()=>{s(),o.forEach(i=>A(i)),o.length=0;}),o}function ce(e,t){let n=t.length,r=new Array(n),o=new Set(t),s=1,i=0,a=c=>{if(c.nodeType!==Node.DOCUMENT_FRAGMENT_NODE){if(o.has(s)&&(r[i++]=c,i===n))return true;s++;}let f=c.firstChild;for(;f;){if(a(f))return true;f=f.nextSibling;}return false};return a(e),r}function kt(e){let t=N();if(t){if(t.isMounted){try{e();}catch(n){}return}t.onMount||(t.onMount=new Set),t.onMount.add(e);}}function Pt(e){let t=N();t&&(t.onUpdate||(t.onUpdate=new Set),t.onUpdate.add(e));}function Tt(e){let t=N();t&&(t.onDestroy||(t.onDestroy=new Set),t.onDestroy.add(e));}function Ke(e){!e||e.isDestroyed||e.isMounted||(e.isMounted=true,e.onMount&&k(e,()=>{for(let t of e.onMount)try{t();}catch(n){}}));}function ae(e){if(!(!e||e.isDestroyed)&&e.onUpdate)for(let t of e.onUpdate)try{t();}catch(n){}}function fe(e){kt(e);}function ue(e){Tt(e);}function Ct(e){Pt(e);}var Ue;Ue="normal";var G=class{constructor(t,n={}){this.component=t;this.props=n;this.renderedNodes=[];this.scope=null;this.parentNode=void 0;this.beforeNode=void 0;this.reactiveProps={};this.state=0;this.parentScope=null;this[Ue]=true;this.key=n.key?ne(n.key):Te(t),this.reactiveProps=shallowReactive(z({},n||{})),this.parentScope=N();}get isConnected(){return this.state===2}get firstChild(){for(let t of this.renderedNodes){let n=T(t);if(n)return n}}mount(t,n){var s;if(this.parentNode=t,this.beforeNode=n,this.state=1,this.renderedNodes.length>0){for(let i of this.renderedNodes)g(t,i,n);return this.state=2,this.renderedNodes}let r=(s=this.parentScope)!=null?s:N();this.scope=Ae(r);let o=k(this.scope,()=>{var c;let i=this.component(this.reactiveProps);return isFunction(i)&&(i=i(this.reactiveProps)),(isSignal(i)||isComputed(i))&&(i=i.value),(c=se(t,i,n))!=null?c:[]});return this.renderedNodes=o,k(this.scope,()=>{this.applyProps(this.props||{});}),this.state=2,this.scope&&Ke(this.scope),this.renderedNodes}update(t){if(this.key!==t.key)return this.mount(t.parentNode,t.beforeNode),this;if(this.parentNode=t.parentNode,this.beforeNode=t.beforeNode,this.scope=t.scope,this.parentScope=t.parentScope,this.renderedNodes=t.renderedNodes,this.state=t.state,this.reactiveProps=t.reactiveProps,this.props)for(let n in this.props){if(n==="key")continue;let r=this.props[n],o=this.reactiveProps[n];Object.is(o,r)||isObject(o)&&isObject(r)&&Re(o,r)||(this.reactiveProps[n]=r);}return !this.isConnected&&this.parentNode&&this.mount(this.parentNode,this.beforeNode),this.scope&&(k(this.scope,()=>{this.applyProps(this.props||{});}),ae(this.scope)),this}forceUpdate(){return $(this,null,function*(){if(yield Promise.resolve(),this.state===5||!this.parentNode||!this.scope)return;let t=[...this.renderedNodes];try{k(this.scope,()=>{let n=this.component(this.reactiveProps);isFunction(n)&&(n=n(this.reactiveProps)),(isSignal(n)||isComputed(n))&&(n=n.value);let r=coerceArray(n);if(this.parentNode){let o=this.beforeNode;if(!o&&this.renderedNodes.length>0){let s=this.renderedNodes[this.renderedNodes.length-1],i=T(s);i&&(o=i.nextSibling);}for(let s of this.renderedNodes)A(s);for(let s of r)g(this.parentNode,s,o);this.renderedNodes=r;}}),this.scope&&ae(this.scope);}catch(n){throw this.renderedNodes=t,n}})}destroy(){if(this.state===4||this.state===5)return;this.state=4;let t=this.scope;t&&(J(t),this.scope=null);for(let n of this.renderedNodes)A(n);this.renderedNodes=[],this.parentNode=void 0,this.beforeNode=void 0,this.parentScope=null,this.reactiveProps={},this.props={},this.state=5;}applyProps(t){if(!t)return;let n=this.firstChild;for(let[r,o]of Object.entries(t))if(startsWith(r,"on")&&n){let s=r.slice(2).toLowerCase();isHTMLElement(n)&&v(n,s,o);}else r==="ref"&&isSignal(o)&&(o.value=n);this.props=t;}};function m(e){return !!e&&!!e.normal}function O(e,t){return m(e)?e:new G(e,t)}function de(e){let t,n=()=>{let r=document.createElement("template");r.innerHTML=e;let o=r.content.firstChild;if(!o)throw new Error("Invalid template: empty content");return o};return ()=>(t||(t=n())).cloneNode(true)}function Ht(e,t){let n=isString(t)?document.querySelector(t):t;if(!n){error(`Target element not found: ${t}`);return}n.innerHTML&&(error(`Target element is not empty, it will be delete: ${t}`),n.innerHTML="");let o=O(e);return o.mount(n),o}function pe(e,t){let n=N();n&&(n.provides||(n.provides=new Map),n.provides.set(e,t));}function me(e,t){let n=N();if(!n)return t;let r=n;for(;r;){if(r.provides){let o=r.provides.get(e);if(o)return o}r=r.parent;}return t}function $t(e){let t=e.target,n=`${e.type}`,r=e.target,o=e.currentTarget,s=c=>Object.defineProperty(e,"target",{configurable:true,value:c}),i=()=>{let c=t[`_$${n}`];if(c&&isFunction(c)&&!t.disabled){let f=t[`${n}Data`];if(f?c.call(t,f,e):c.call(t,e),e.cancelBubble)return false}return t.host&&!isString(t.host)&&!t.host._$host&&isFunction(t.contains)&&t.contains(e.target)&&s(t.host),true},a=()=>{for(;i()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:true,get(){return t||document}}),e.composedPath){let c=e.composedPath();s(c[0]);for(let f=0;f<c.length-2&&(t=c[f],!!i());f++){if(t._$host){t=t._$host,a();break}if(t.parentNode===o)break}}else a();s(r);}var Ge=Symbol("_$EVENTS");function Kt(e,t=window.document){let n=t,r=n[Ge]||(n[Ge]=new Set);for(let o of e)r.has(o)||(r.add(o),t.addEventListener(o,$t));}function jt(e,t,n,r=false){if(t===n)return;let o=X(n),s=X(t);o&&s===o||(o?r?e.setAttribute("class",o):e.className=o:e.removeAttribute("class"));}function X(e){if(e==null)return "";if(typeof e=="string")return e.trim();if(isArray(e))return e.map(X).filter(Boolean).join(" ");if(isObject(e)){let t=[];for(let n in e)e[n]&&t.push(n);return t.join(" ")}return String(e).trim()}var Xe=/\s*!important$/,Gt=["Webkit","Moz","ms"],ye={};function Xt(e,t,n){let r=e.style,o=isString(n);if(n&&o){t!==n&&(r.cssText=n);return}if(!n){t&&e.removeAttribute("style");return}if(t&&!isString(t))for(let s in t)(!n||n[s]==null)&&U(r,s,"");else if(t&&isString(t)){let s=t.split(";");for(let i of s){let a=i.indexOf(":");if(a>0){let c=i.slice(0,a).trim();n&&isObject(n)&&n[c]==null&&U(r,c,"");}}}if(n&&!isString(n))for(let s in n){let i=n[s];(!t||isString(t)||t[s]!==i)&&i!=null&&U(r,s,i);}}function U(e,t,n){if(isArray(n)){for(let o of n)U(e,t,o);return}if((n==null||n==="")&&(n=""),t.startsWith("--")){e.setProperty(t,n);return}let r=Yt(e,t);typeof n=="string"&&Xe.test(n)?e.setProperty(camelCase(r),n.replace(Xe,""),"important"):e[r]=n;}function Yt(e,t){let n=ye[t];if(n)return n;let r=camelCase(t);if(r!=="filter"&&r in e)return ye[t]=r;r=capitalize(r);for(let o of Gt){let s=o+r;if(s in e)return ye[t]=s}return t}function We(e,t,n,r){if(t==="key"){r==null?F(e,void 0):F(e,String(r));return}if(t===ve){Object.keys(r).forEach(u=>{We(e,u,n==null?void 0:n[u],r==null?void 0:r[u]);});return}let o=(e==null?void 0:e.namespaceURI)===be,s=o&&t.startsWith("xlink:"),i=o&&t.startsWith("xmlns:"),a=isSpecialBooleanAttr(t)||isBooleanAttr(t);if(n===r)return;let c=t.toLowerCase();if(/^on[a-z]+/.test(c)||c==="innerhtml")return;if(r==null){if(s)e.removeAttributeNS(Q,t.slice(6));else if(i){let u=t.slice(6);e.removeAttributeNS(Z,u);}else e.removeAttribute(t);return}if(s){e.setAttributeNS(Q,t,String(r));return}if(i){e.setAttributeNS(Z,t,String(r));return}if(a){includeBooleanAttr(r)?e.setAttribute(t,""):e.removeAttribute(t);return}let f=isSymbol(r)?String(r):r;if((c==="href"||c==="src"||c==="xlink:href")&&typeof f=="string"){let u=f.trim().toLowerCase();if(u.startsWith("javascript:")||u.startsWith("data:"))return}if(o)e.setAttribute(t,String(f));else if(t in e)try{e[t]=f;}catch(u){e.setAttribute(t,String(f));}else e.setAttribute(t,String(f));}function Zt(e,t,n,r){if(!(r!=null&&r.delegate))return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r);let o=r.delegate,s=a=>{let c=a.target;(c.matches(o)||c.closest(o))&&n.call(e,a);},i=z({},r);return i.delegate=void 0,e.addEventListener(t,s,i),()=>{e.removeEventListener(t,s,i);}}function en(e){return e==null?void 0:e.children}en.fragment=true;function io(e){return !!e&&!!e.fragment}function nn(e){if(typeof document=="undefined"){let r=e.children;return r?(isArray(r)?r:[r]).map(s=>String(s||"")).join(""):""}let t=document.createComment("portal");t.portal=true;let n=e.children;if(n){let r=isArray(n)?n:[n],o=[];fe(()=>{let s=isString(e.target)?document.querySelector(e.target):e.target;s&&(r.forEach(i=>{if(i!=null){let a=D(i);a&&(g(s,a),o.push(a));}}),K(()=>{o.forEach(i=>{typeof i!="string"&&i.parentNode===s&&s.removeChild(i);});}));});}return t}nn.portal=true;function mo(e){return !!e&&!!e.portal}var ge=Symbol("SuspenseContext");function sn(e){if(isUndefined(document)){let u=e.fallback;return u?String(u||""):""}let t=document.createElement("div");t.style.display="contents";let n=true,r=0,o=false,s=null,i=()=>{if(!o){for(o=true;t.firstChild;)t.removeChild(t.firstChild);if(e.fallback!=null){let u=D(e.fallback);u&&g(t,u);}}},a=()=>{if(!(!o||!(s||e.children!=null&&!isPromise(e.children)))){for(o=false;t.firstChild;)t.removeChild(t.firstChild);s?c(s):e.children!=null&&!isPromise(e.children)&&c(e.children);}},c=u=>{for(;t.firstChild;)t.removeChild(t.firstChild);if(u==null)return;let y=N();if((isArray(u)?u:[u]).forEach(b=>{if(b!=null){m(b)&&(b.parentContext=y);let I=D(b);I&&g(t,I);}}),o){for(;t.firstChild;)t.removeChild(t.firstChild);if(e.fallback!=null){let b=D(e.fallback);b&&g(t,b);}}},f={register:u=>{r++,i(),u.then(()=>{n&&(r--,r===0&&a());}).catch(y=>{n&&(r--,r===0&&a());});},increment:()=>{r++,i();},decrement:()=>{r--,r===0&&a();}};pe(ge,f);let l=e.children;return isPromise(l)?(l.then(u=>{s=u;}).catch(()=>{}),f.register(l)):l!=null?c(l):i(),ue(()=>{for(n=false;t.firstChild;)t.removeChild(t.firstChild);}),t}sn.suspense=true;function bo(e){return !!e&&!!e.suspense}function Do(e,t){let n=signal(t==null?void 0:t.initialValue),r=signal(true),o=signal(null),s=signal("pending"),i=0,a=null,c=()=>$(null,null,function*(){let u=++i;r.value=true,s.value="pending",o.value=null;try{let y=e();a=y.then(()=>{}).catch(()=>{});let x=yield y;u===i&&(n.value=x,s.value="ready",r.value=!1);}catch(y){u===i&&(o.value=y instanceof Error?y:new Error(String(y)),s.value="errored",r.value=false);}});c();let f=(()=>{if(r.value&&a){let u=me(ge,null);u&&u.register(a);}return n.value});return f.loading=r,f.error=o,f.state=s,[f,{mutate:u=>{n.value=u,s.value="ready",r.value=false,o.value=null;},refetch:()=>$(null,null,function*(){yield c();})}]}var Be=0;function Se(){return `${Be++}`}function W(){Be=0;}function Ne(){}function M(e,t=false){return isNil(e)?"":isString(e)?e:isArray(e)?e.map(n=>M(n,t)).join(""):isFunction(e)?M(e(),t):String(e)}function Ze(e,t){let n=/^<([a-z]+)(\s*)([^>]*)>/i,r=/data-idx="(\d+)"/g,o=/<!--(.*?)-->/g;return e.replace(n,`<$1$2$3 data-hk="${t}">`).replaceAll(r,`data-idx="${t}-$1"`).replaceAll(o,`<!--${t}-$1-->`)}function ln(e,t={}){if(!isFunction(e))return error("Component must be a function"),"";W();let n=e(t);return M(n)}function dn(e,t,...n){let r="",o=0;for(let i of e)if(r+=i,o<n.length){let a=n[o++];a&&(r+=M(a));}return Ze(r,t)}function pn(e,t={}){if(!isFunction(e))return error("create ssg component: Component is not a function"),"";let n=e(t);return M(n)}function ot(e){if(isArray(e)){let t={};for(let n of e){let r=isString(n)?En(n):ot(n);if(r)for(let o in r)t[o]=r[o];}return t}if(isString(e)||isObject(e))return e}var Sn=/;(?![^(]*\))/g,Nn=/:([\s\S]+)/,xn=/\/\*[\s\S]*?\*\//g;function En(e){let t={};return e.replaceAll(xn,"").split(Sn).forEach(n=>{if(n){let r=n.split(Nn);r.length>1&&(t[r[0].trim()]=r[1].trim());}}),t}function An(e){if(!e)return "";if(isString(e))return e;let t="";for(let n in e){let r=e[n];if(isString(r)||isNumber(r)){let o=n.startsWith("--")?n:kebabCase(n);t+=`${o}:${r};`;}}return t}function it(e){let t="";if(isString(e))t=e;else if(isArray(e))for(let n of e){let r=it(n);r&&(t+=`${r} `);}else if(isObject(e))for(let n in e)e[n]&&(t+=`${n} `);return t.trim()}function st(e,t,n){if(isSignal(t)||isComputed(t))return st(e,t.value);if(!t&&t!==0)return "";if(e==="style"){let r=ot(t);return r?isString(r)?` style="${r}"`:` style="${An(r)}"`:""}if(e==="class"){let r=it(t);return r?` class="${r}"`:""}return e.startsWith("on")?"":t===true?` ${e}`:` ${e}="${t}"`}function bn(e){return ()=>{let t=Se();return document.querySelector(`[data-hk="${t}"]`)||de(e)()}}function _n(e,t){let n=e.dataset.hk;if(!n)return ce(e,t);let r=[],o=e.querySelectorAll(`[data-idx^="${n}"]`);o.length>0&&r.push(...Array.from(o).filter(c=>{let f=c.dataset.idx;return f!==null&&ee.test(f)}).map(c=>{let f=c.dataset.idx||"",[l,u]=f.split("-");return {hk:l,idx:u,node:c}}));let s=[],i=c=>{if(c.nodeType===Node.COMMENT_NODE&&c.textContent&&ee.test(c.textContent)){let[l,u]=c.textContent.split("-");s.push({hk:l,idx:u,node:c});}let f=c.firstChild;for(;f;)i(f),f=f.nextSibling;};i(e),r.push(...s);let a=[e];return t.forEach(c=>{let f=r.find(l=>l.idx===String(c));f&&a.push(f.node);}),a}function kn(e,t,n={}){W();try{let r=isString(t)?document.querySelector(t):t;if(!r){error("Hydration error: Root element not found");return}let o=O(e,n);return o.mount(r),Ne(),o}catch(r){error("Hydration error:",r);return}}
7
+ export{G as Component,en as Fragment,nn as Portal,sn as Suspense,ge as SuspenseContext,Zt as addEvent,v as addEventListener,_t as bindElement,Ht as createApp,O as createComponent,Do as createResource,pn as createSSGComponent,Kt as delegateEvents,Se as getHydrationKey,bn as getRenderedElement,kn as hydrate,me as inject,se as insert,m as isComponent,io as isFragment,mo as isPortal,bo as isSuspense,ce as mapNodes,_n as mapSSRNodes,X as normalizeClass,Nt as omitProps,ue as onDestroy,fe as onMount,Ct as onUpdate,We as patchAttr,jt as patchClass,Xt as patchStyle,pe as provide,dn as render,ln as renderToString,st as setSSGAttr,U as setStyle,de as template};//# sourceMappingURL=template.esm.js.map
8
8
  //# sourceMappingURL=template.esm.js.map