@neeloong/form 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @neeloong/form v0.8.0
2
+ * @neeloong/form v0.8.1
3
3
  * (c) 2024-2025 Fierflame
4
4
  * @license Apache-2.0
5
5
  */
@@ -108,7 +108,7 @@ declare namespace Component {
108
108
  events: [string, ($event: any) => void, AddEventListenerOptions][];
109
109
  tagAttrs: Record<string, any>;
110
110
  watchAttr: (name: any, fn: (value: any, old: any, name: string) => void) => () => void;
111
- relate: (el: Element) => () => void;
111
+ relate: (el: Element | Relatedness) => () => void;
112
112
  destroyed: boolean;
113
113
  init: boolean;
114
114
  listen: <K extends keyof Component.Context.Events>(event: K, listener: (...p: Component.Context.Events[K]) => void) => () => void;
@@ -226,6 +226,12 @@ declare namespace Schema {
226
226
  }
227
227
  type Validator = (store: Store) => string | string[] | void | null;
228
228
  type AsyncValidator = (store: Store, signal: AbortSignal) => PromiseLike<string | string[] | void | null> | string | string[] | void | null;
229
+ type Relatedness = {
230
+ focus?: (() => void) | undefined;
231
+ scrollIntoView?: (() => void) | undefined;
232
+ input?: Element | undefined;
233
+ root?: Element | undefined;
234
+ };
229
235
 
230
236
  declare const ref: unique symbol;
231
237
  type Ref = {
@@ -466,7 +472,7 @@ declare class Store<T = any> {
466
472
  * @param {object} [options]
467
473
  * @param {Record<string, Store | {get?(): any; set?(v: any): void; exec?(...p: any[]): any; calc?(...p: any[]): any }>} [options.global]
468
474
  * @param {(path: string[]) => Component?} [options.component]
469
- * @param {(store: Store, el: Element) => () => void} [options.relate]
475
+ * @param {(store: Store, el: Element | Relatedness) => () => void} [options.relate]
470
476
  * @returns {() => void}
471
477
  */
472
478
  declare function _default(store: Store, layouts: (Node | string)[], parent: Element, { component, global, relate }?: {
@@ -477,7 +483,7 @@ declare function _default(store: Store, layouts: (Node | string)[], parent: Elem
477
483
  calc?(...p: any[]): any;
478
484
  }> | undefined;
479
485
  component?: ((path: string[]) => Component | null) | undefined;
480
- relate?: ((store: Store, el: Element) => () => void) | undefined;
486
+ relate?: ((store: Store, el: Element | Relatedness) => () => void) | undefined;
481
487
  }): () => void;
482
488
 
483
489
  /**
@@ -497,4 +503,4 @@ declare function watch<T>(getter: () => T, callback: (value: T) => void, immedia
497
503
  */
498
504
  declare function effect(fn: () => void): () => void;
499
505
 
500
- export { type AsyncValidator, Component, index_d as Layout, type Ref, Schema, Store, type Validator, type VerifyError, effect, _default as render, watch };
506
+ export { type AsyncValidator, Component, index_d as Layout, type Ref, type Relatedness, Schema, Store, type Validator, type VerifyError, effect, _default as render, watch };
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @neeloong/form v0.8.0
2
+ * @neeloong/form v0.8.1
3
3
  * (c) 2024-2025 Fierflame
4
4
  * @license Apache-2.0
5
5
  */
@@ -2921,6 +2921,14 @@
2921
2921
  return store instanceof Store ? store : item.get;
2922
2922
 
2923
2923
  }
2924
+ /**
2925
+ * @param {string | boolean | null} [name]
2926
+ */
2927
+ getStore(name) {
2928
+ if (!name) { return null; }
2929
+ const item = this.#items[name === true ? '' : name];
2930
+ return item?.get && item.store || null
2931
+ }
2924
2932
 
2925
2933
  /**
2926
2934
  * @param {string | true} name
@@ -3610,7 +3618,7 @@
3610
3618
  }
3611
3619
  }
3612
3620
 
3613
- /** @import { Component } from '../types.mjs' */
3621
+ /** @import { Component, Relatedness } from '../types.mjs' */
3614
3622
  /** @import Store from '../Store/index.mjs' */
3615
3623
  /** @import Environment from './Environment/index.mjs' */
3616
3624
 
@@ -3736,10 +3744,11 @@
3736
3744
  *
3737
3745
  * @param {Component | string} component
3738
3746
  * @param {Environment} env
3739
- * @param {((store: Store, el: Element) => () => void)?} [relate]
3747
+ * @param {Store?} store
3748
+ * @param {((store: Store, el: Element | Relatedness) => () => void)?} [relate]
3740
3749
  * @returns
3741
3750
  */
3742
- function createContext(component, env, relate) {
3751
+ function createContext(component, env, store, relate) {
3743
3752
  const tag = typeof component === 'string' ? component : component.tag;
3744
3753
  const { attrs, events } = typeof component !== 'string' && component || { attrs: null, events: null };
3745
3754
 
@@ -3780,9 +3789,9 @@
3780
3789
  };
3781
3790
  },
3782
3791
  relate(el) {
3783
- if (!relate || destroyed) { return () => { }; }
3792
+ if (!store || !relate || destroyed) { return () => { }; }
3784
3793
  try {
3785
- const w = relate(env.store, el);
3794
+ const w = relate(store, el);
3786
3795
  if (typeof w !== 'function') { return () => { }; }
3787
3796
  cancelFns.add(w);
3788
3797
  return () => {
@@ -4046,6 +4055,9 @@
4046
4055
  function createTagComponent (context, name, is) {
4047
4056
  const node = document.createElement(name, {is: is || undefined});
4048
4057
  const { watchAttr, props } = context;
4058
+ if(['input', 'textarea', 'select'].includes(name.toLowerCase())) {
4059
+ context.relate(node);
4060
+ }
4049
4061
 
4050
4062
  context.listen('init', ({events})=> {
4051
4063
  const e = tagBindMap[name.toLowerCase()];
@@ -4512,7 +4524,7 @@
4512
4524
  * @param {Environment} env
4513
4525
  * @param {Record<string, [Layout.Node, Environment]>} templates
4514
4526
  * @param {string[]} componentPath
4515
- * @param {((store: Store, el: Element) => () => void)?} [relate]
4527
+ * @param {((store: Store, el: Element | Relatedness) => () => void)?} [relate]
4516
4528
  * @param {Component.Getter?} [getComponent]
4517
4529
  */
4518
4530
  function renderItem(layout, parent, next, env, templates, componentPath, relate, getComponent) {
@@ -4535,8 +4547,12 @@
4535
4547
  const path = [...componentPath, layout.name];
4536
4548
  const component = getComponent?.(path);
4537
4549
  if (getComponent && !component) { return () => { }; }
4538
- const { context, handler } = createContext(component ? component : layout.name, env, relate);
4539
-
4550
+ const { context, handler } = createContext(
4551
+ component ? component : layout.name,
4552
+ env,
4553
+ env.getStore(bind),
4554
+ relate
4555
+ );
4540
4556
 
4541
4557
  const componentAttrs = component?.attrs;
4542
4558
  const attrs = componentAttrs
@@ -4587,7 +4603,7 @@
4587
4603
  * @param {Environment} env
4588
4604
  * @param {Record<string, [Layout.Node, Environment]>} templates
4589
4605
  * @param {string[]} componentPath
4590
- * @param {((store: Store, el: Element) => () => void)?} [relate]
4606
+ * @param {((store: Store, el: Element | Relatedness) => () => void)?} [relate]
4591
4607
  * @param {Component.Getter?} [getComponent]
4592
4608
  * @returns {() => void}
4593
4609
  */
@@ -4620,7 +4636,7 @@
4620
4636
  * @param {object} [options]
4621
4637
  * @param {Record<string, Store | {get?(): any; set?(v: any): void; exec?(...p: any[]): any; calc?(...p: any[]): any }>} [options.global]
4622
4638
  * @param {(path: string[]) => Component?} [options.component]
4623
- * @param {(store: Store, el: Element) => () => void} [options.relate]
4639
+ * @param {(store: Store, el: Element | Relatedness) => () => void} [options.relate]
4624
4640
  * @returns {() => void}
4625
4641
  */
4626
4642
  function index (store, layouts, parent, {component, global, relate} = {}) {
package/index.min.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @neeloong/form v0.8.0
2
+ * @neeloong/form v0.8.1
3
3
  * (c) 2024-2025 Fierflame
4
4
  * @license Apache-2.0
5
5
  */
@@ -57,4 +57,4 @@ function(){throw new Error};function j(){return h(this),this.value}function L(e,
57
57
  * Use of this source code is governed by an MIT-style license that can be
58
58
  * found in the LICENSE file at https://angular.io/license
59
59
  */
60
- function(e){const t=Object.create(T);t.value=e;const n=()=>(h(t),t.value);return n[u]=t,n}(r),a=l[u];if(this[M]=a,a.wrapper=this,i){const t=i.equals;t&&(a.equal=t),a.watched=i[e.subtle.watched],a.unwatched=i[e.subtle.unwatched]}}get(){if(!(0,e.isState)(this))throw new TypeError("Wrong receiver type for Signal.State.prototype.get");return j.call(this[M])}set(t){if(!(0,e.isState)(this))throw new TypeError("Wrong receiver type for Signal.State.prototype.set");if(a)throw new Error("Writes to signals not permitted during Watcher callback");L(this[M],t)}};c=M,p=new WeakSet,e.isComputed=e=>r(p,e),e.Computed=class{constructor(t,r){s(this,p),n(this,c);const i=function(e){const t=Object.create(A);t.computation=e;const n=()=>S(t);return n[u]=t,n}(t),o=i[u];if(o.consumerAllowSignalWrites=!0,this[M]=o,o.wrapper=this,r){const t=r.equals;t&&(o.equal=t),o.watched=r[e.subtle.watched],o.unwatched=r[e.subtle.unwatched]}}get(){if(!(0,e.isComputed)(this))throw new TypeError("Wrong receiver type for Signal.Computed.prototype.get");return S(this[M])}},(t=>{var o,a,c,u;t.untrack=function(e){let t,n=null;try{n=f(null),t=e()}finally{f(n)}return t},t.introspectSources=function(t){var n;if(!(0,e.isComputed)(t)&&!(0,e.isWatcher)(t))throw new TypeError("Called introspectSources without a Computed or Watcher argument");return(null==(n=t[M].producerNode)?void 0:n.map((e=>e.wrapper)))??[]},t.introspectSinks=function(t){var n;if(!(0,e.isComputed)(t)&&!(0,e.isState)(t))throw new TypeError("Called introspectSinks without a Signal argument");return(null==(n=t[M].liveConsumerNode)?void 0:n.map((e=>e.wrapper)))??[]},t.hasSinks=function(t){if(!(0,e.isComputed)(t)&&!(0,e.isState)(t))throw new TypeError("Called hasSinks without a Signal argument");const n=t[M].liveConsumerNode;return!!n&&n.length>0},t.hasSources=function(t){if(!(0,e.isComputed)(t)&&!(0,e.isWatcher)(t))throw new TypeError("Called hasSources without a Computed or Watcher argument");const n=t[M].producerNode;return!!n&&n.length>0};o=M,a=new WeakSet,c=new WeakSet,u=function(t){for(const n of t)if(!(0,e.isComputed)(n)&&!(0,e.isState)(n))throw new TypeError("Called watch/unwatch without a Computed or State argument")},e.isWatcher=e=>r(a,e),t.Watcher=class{constructor(e){s(this,a),s(this,c),n(this,o);let t=Object.create(d);t.wrapper=this,t.consumerMarkedDirty=e,t.consumerIsAlwaysLive=!0,t.consumerAllowSignalWrites=!1,t.producerNode=[],this[M]=t}watch(...t){if(!(0,e.isWatcher)(this))throw new TypeError("Called unwatch without Watcher receiver");i(this,c,u).call(this,t);const n=this[M];n.dirty=!1;const r=f(n);for(const e of t)h(e[M]);f(r)}unwatch(...t){if(!(0,e.isWatcher)(this))throw new TypeError("Called unwatch without Watcher receiver");i(this,c,u).call(this,t);const n=this[M];w(n);for(let e=n.producerNode.length-1;e>=0;e--)if(t.includes(n.producerNode[e].wrapper)){y(n.producerNode[e],n.producerIndexOfThis[e]);const t=n.producerNode.length-1;if(n.producerNode[e]=n.producerNode[t],n.producerIndexOfThis[e]=n.producerIndexOfThis[t],n.producerNode.length--,n.producerIndexOfThis.length--,n.nextProducerIndex--,e<n.producerNode.length){const t=n.producerIndexOfThis[e],r=n.producerNode[e];x(r),r.liveConsumerIndexOfThis[t]=e}}}getPending(){if(!(0,e.isWatcher)(this))throw new TypeError("Called getPending without Watcher receiver");return this[M].producerNode.filter((e=>e.dirty)).map((e=>e.wrapper))}},t.currentComputed=function(){var e;return null==(e=l)?void 0:e.wrapper},t.watched=Symbol("watched"),t.unwatched=Symbol("unwatched")})(e.subtle||(e.subtle={}))})(e.Signal||(e.Signal={}));const N=(t,n,r,s)=>{const i=new e.Signal.State("boolean"==typeof n?n:null);let o;if("function"==typeof r)o=new e.Signal.Computed((()=>Boolean(r(t))));else{const t=Boolean(r);o=new e.Signal.Computed((()=>t))}const l=()=>{const e=i.get();return null===e?o.get():e},a=s?new e.Signal.Computed((()=>s.get()||l())):new e.Signal.Computed(l);return[i,a]},k=e=>"string"==typeof e&&e||null,I=e=>"number"==typeof e&&e||null,P=e=>e instanceof RegExp?e:null,U=Boolean;function q(e){if("number"==typeof e||"string"==typeof e)return{label:e,value:e};if(!e||"object"!=typeof e)return null;const{children:t,label:n,value:r}=e,s=Array.isArray(t)?t.map(q).filter(U):[];return s.length?{children:s,label:n,value:r}:"number"==typeof r||"string"==typeof r?{label:n,value:r}:null}const B=e=>{if(!e||!Array.isArray(e))return null;const t=e.map(q).filter(U);return t.length?t:null};function R(t,n,r,s){const i=new e.Signal.State(n(r));let o;if("function"==typeof s){const r=s;o=new e.Signal.Computed((()=>n(r(t))))}else{const t=n(s);o=new e.Signal.Computed((()=>t))}const l=new e.Signal.Computed((()=>{const e=i.get();return null===e?o.get():e}));return[i,l]}const V=Symbol();function D(e){const t={[V]:e};for(const[n,r]of e)Object.defineProperty(t,n,{get:()=>r.ref,configurable:!1,enumerable:!0});return Object.defineProperty(t,V,{get:()=>e,configurable:!1,enumerable:!0}),t}let W=null,_=null,K=Object.create(null);function H(e,t){const n=e.type;let r=F;if(!e.array||_&&t?.parent instanceof _)if("string"==typeof n){const e=K[n];e&&(r=e)}else n&&"object"==typeof n&&W&&(r=W);else _&&(r=_);return new r(e,t)}function Y(e){return e?e instanceof Error?e.message:"string"!=typeof e?"":e:""}function z(t,...n){const r=n.flat().filter((e=>"function"==typeof e));if(!r.length)return[()=>Promise.resolve([]),new e.Signal.Computed((()=>[])),()=>{}];const s=new e.Signal.State([]);let i=null;return[function(){i?.abort(),i=new AbortController;const e=i.signal;return s.set([]),Promise.all(r.map((n=>async function(e,n){let r=[];try{r.push(await e(t,n))}catch(e){r.push(e)}const i=r.flat().map(Y).filter(Boolean);return!n.aborted&&i.length&&s.set([...s.get(),...i]),i}(n,e)))).then((e=>e.flat()))},new e.Signal.Computed((()=>s.get())),()=>{i?.abort(),s.set([])}]}class F{#e=new Map;emit(e,t){const n="number"==typeof e?String(e):e,r=this.#e;let s=!1;for(const e of[...r.get(n)||[]])s=!1===e(t,this)||s;return!s}listen(e,t){const n=t.bind(this),r=this.#e,s="number"==typeof e?String(e):e;let i=r.get(s);return i||(i=new Set,r.set(s,i)),i.add(n),()=>{i?.delete(n)}}static create(e,t={}){return H({type:e},{...t,parent:null})}static setStore(e,t){return function(e,t){K[e]=t}(e,t)}#t=!1;get null(){return this.#t}get kind(){return""}#n=null;get ref(){return this.#n||D(this)}constructor(t,{null:n,state:r,ref:s,setValue:i,setState:o,convert:l,onUpdate:a,onUpdateState:c,validator:u,validators:f,index:d,length:h,new:p,parent:g,hidden:m,clearable:b,required:y,disabled:v,readonly:w,label:x,description:S,placeholder:O,min:E,max:C,step:A,minLength:$,maxLength:j,pattern:L,values:T}={}){this.schema=t,this.#r.set("object"==typeof r&&r||{});const M=g instanceof F?g:null;M&&(this.#s=M,this.#i=M.#i),this.#o=t.type,this.#l=t.meta,this.#a=t.component;const U=new e.Signal.State(Boolean(p));this.#c=U;const q=M?new e.Signal.Computed((()=>M.#u.get()||U.get())):new e.Signal.Computed((()=>U.get()));this.#u=q;const V=Boolean(t.immutable),W=!1!==t.creatable;this.#f=V,this.#d=W;const _=t.readonly,K=new e.Signal.State("boolean"==typeof w?w:null);let H;if("function"==typeof _)H=new e.Signal.Computed((()=>Boolean(_(this))));else{const t=Boolean(_);H=new e.Signal.Computed((()=>t))}const G=()=>{if(q.get()?!W:V)return!0;const e=K.get();return null===e?H.get():e},Q=M?M.#h:null;this.#p=K,this.#h=Q?new e.Signal.Computed((()=>Q.get()||G())):new e.Signal.Computed(G),[this.#g,this.#m]=N(this,m,t.hidden,M?M.#m:null),[this.#b,this.#y]=N(this,b,t.clearable,M?M.#y:null),[this.#v,this.#w]=N(this,y,t.required,M?M.#w:null),[this.#x,this.#S]=N(this,v,t.disabled,M?M.#S:null),[this.#O,this.#E]=R(this,k,x,t.label),[this.#C,this.#A]=R(this,k,S,t.description),[this.#$,this.#j]=R(this,k,O,t.placeholder),[this.#L,this.#T]=R(this,I,E,t.min),[this.#M,this.#N]=R(this,I,C,t.max),[this.#k,this.#I]=R(this,I,A,t.step),[this.#P,this.#U]=R(this,I,$,t.minLength),[this.#q,this.#B]=R(this,I,j,t.maxLength),[this.#R,this.#V]=R(this,P,L,t.pattern),[this.#D,this.#W]=R(this,B,T,t.values);const Z=function(t,...n){const r=n.flat().filter((e=>"function"==typeof e));return r.length?new e.Signal.Computed((()=>{const e=[];for(const n of r)try{e.push(n(t))}catch(t){e.push(t)}return e.flat().map(Y).filter(Boolean)})):new e.Signal.Computed((()=>[]))}(this,t.validator,u),[X,J,ee]=z(this,t.validators?.change,f?.change),[te,ne,re]=z(this,t.validators?.blur,f?.blur);if(this.listen("change",(()=>{X()})),this.listen("blur",(()=>{te()})),this.#_=function(...t){const n=t.filter(Boolean);return new e.Signal.Computed((()=>n.flatMap((e=>e.get()))))}(Z,J,ne),this.#K=Z,this.#H=X,this.#Y=te,this.#z=ee,this.#F=re,h instanceof e.Signal.State||h instanceof e.Signal.Computed?this.#G=h:this.#G=new e.Signal.State(h||0),n)return this.#t=!0,void(this.#n=D(this));this.#n=s||null,this.#Q=a||null,this.#Z=c||null,this.#X="function"==typeof i?i:null,this.#J="function"==typeof o?o:null,this.#ee="function"==typeof l?l:null,this.#te.set(d??"");for(const[e,n]of Object.entries(t.events||{}))"function"==typeof n&&this.listen(e,n)}#X=null;#J=null;#ee=null;#Q=null;#Z=null;#s=null;#i=this;#o;#l;#a;get store(){return this}get parent(){return this.#s}get root(){return this.#i}get type(){return this.#o}get meta(){return this.#l}get component(){return this.#a}#G;get length(){return this.#G.get()}#te=new e.Signal.State("");get index(){return this.#te.get()}set index(e){this.#te.set(e)}get no(){if(this.#t)return"";const e=this.index;return"number"==typeof e?e+1:e}#d=!0;get creatable(){return this.#d}#f=!1;get immutable(){return this.#f}#u;#c;get selfNew(){return this.#c.get()}set selfNew(e){this.#c.set(Boolean(e))}get new(){return this.#u.get()}set new(e){this.#c.set(Boolean(e))}#g;#m;get selfHidden(){return this.#g.get()}set selfHidden(e){this.#g.set("boolean"==typeof e?e:null)}get hidden(){return this.#m.get()}set hidden(e){this.#g.set("boolean"==typeof e?e:null)}#b;#y;get selfClearable(){return this.#b.get()}set selfClearable(e){this.#b.set("boolean"==typeof e?e:null)}get clearable(){return this.#y.get()}set clearable(e){this.#b.set("boolean"==typeof e?e:null)}#v;#w;get selfRequired(){return this.#v.get()}set selfRequired(e){this.#v.set("boolean"==typeof e?e:null)}get required(){return this.#w.get()}set required(e){this.#v.set("boolean"==typeof e?e:null)}#x;#S;get selfDisabled(){return this.#x.get()}set selfDisabled(e){this.#x.set("boolean"==typeof e?e:null)}get disabled(){return this.#S.get()}set disabled(e){this.#x.set("boolean"==typeof e?e:null)}#p;#h;get selfReadonly(){return this.#p.get()}set selfReadonly(e){this.#p.set("boolean"==typeof e?e:null)}get readonly(){return this.#h.get()}set readonly(e){this.#p.set("boolean"==typeof e?e:null)}#O;#E;get selfLabel(){return this.#O.get()}set selfLabel(e){this.#O.set(k(e))}get label(){return this.#E.get()}set label(e){this.#O.set(k(e))}#C;#A;get selfDescription(){return this.#C.get()}set selfDescription(e){this.#C.set(k(e))}get description(){return this.#A.get()}set description(e){this.#C.set(k(e))}#$;#j;get selfPlaceholder(){return this.#$.get()}set selfPlaceholder(e){this.#$.set(k(e))}get placeholder(){return this.#j.get()}set placeholder(e){this.#$.set(k(e))}#L;#T;get selfMin(){return this.#L.get()}set selfMin(e){this.#L.set(I(e))}get min(){return this.#T.get()}set min(e){this.#L.set(I(e))}#M;#N;get selfMax(){return this.#M.get()}set selfMax(e){this.#M.set(I(e))}get max(){return this.#N.get()}set max(e){this.#M.set(I(e))}#k;#I;get selfStep(){return this.#k.get()}set selfStep(e){this.#k.set(I(e))}get step(){return this.#I.get()}set step(e){this.#k.set(I(e))}#P;#U;get selfMinLength(){return this.#P.get()}set selfMinLength(e){this.#P.set(I(e))}get minLength(){return this.#U.get()}set minLength(e){this.#P.set(I(e))}#q;#B;get selfMaxLength(){return this.#q.get()}set selfMaxLength(e){this.#q.set(I(e))}get maxLength(){return this.#B.get()}set maxLength(e){this.#q.set(I(e))}#R;#V;get selfPattern(){return this.#R.get()}set selfPattern(e){this.#R.set(P(e))}get pattern(){return this.#V.get()}set pattern(e){this.#R.set(P(e))}#D;#W;get selfValues(){return this.#D.get()}set selfValues(e){this.#D.set(B(e))}get values(){return this.#W.get()}set values(e){this.#D.set(B(e))}#_;#K;#H;#Y;#z;#F;get errors(){return this.#_.get()}get error(){return this.#_.get()[0]}*[Symbol.iterator](){}child(e){return null}#ne=!1;#re=new e.Signal.State(null);#se=new e.Signal.State(this.#re.get());#r=new e.Signal.State(null);get changed(){return this.#se.get()===this.#re.get()}get value(){return this.#se.get()}set value(e){const t=this.#X?.(e),n=void 0===t?e:t;this.#se.set(n),this.#ne||this.#re.set(n),this.#Q?.(n,this.#te.get(),this),this.#ie()}get state(){return this.#r.get()}set state(e){const t=this.#J?.(e),n=void 0===t?e:t;this.#r.set(n),this.#Z?.(n,this.#te.get(),this),this.#ie()}#ie(){this.#oe||(this.#oe=!0,queueMicrotask((()=>{const e=this.#se.get(),t=this.#r.get();this.#le(e,t)})))}reset(e=this.#re.get()){this.#ae(e)}#ae(e){const t=this.#X?.(e),n=void 0===t?e:t;if(this.#z(),this.#F(),this.#ne=!0,!n||"object"!=typeof n){for(const[,e]of this)e.#ae(null);return this.#se.set(n),this.#re.set(n),n}const r=Array.isArray(n)?[...n]:{...n};for(const[e,t]of this)r[e]=t.#ae(r[e]);return this.#se.set(r),this.#re.set(r),r}#oe=!1;#ce(e,t){const[n,r]=this.#ee?.(e,t)||[e,t];return this.#se.get()===n&&this.#r.get()===r?[n,r]:(this.#se.set(n),this.#r.set(r),this.#le(n,r))}#le(e,t){this.#oe=!1;let n=e;if(e&&"object"==typeof e){let r=Array.isArray(e)?[...e]:{...e},s=Array.isArray(e)?Array.isArray(t)?[...t]:[]:{...t},i=!1;for(const[n,o]of this){const l=e[n],a=t?.[n],[c,u]=o.#ce(l,a);l!==c&&(r[n]=c,i=!0),a!==u&&(s[n]=u,i=!0)}i&&(t=s,n=e=r,this.#se.set(e),this.#r.set(s))}return this.#ne||(this.#ne=!0,this.#re.set(n)),[e,t]}validate(e){if(!Array.isArray(e))return Promise.all([this.#K.get(),this.#H(),this.#Y()]).then((e=>{const t=e.flat();return t.length?t:null}));const t=[this.validate().then((t=>t?.length?[{path:[...e],store:this,errors:t}]:[]))];for(const[n,r]of this)t.push(r.validate([...e,n]));return Promise.all(t).then((e=>e.flat()))}}class G extends F{get kind(){return"object"}#ue;*[Symbol.iterator](){yield*Object.entries(this.#ue)}child(e){return this.#ue[e]||null}constructor(e,{parent:t,index:n,new:r,onUpdate:s,onUpdateState:i}={}){const o=Object.entries(e.type);super(e,{parent:t,index:n,new:r,onUpdate:s,onUpdateState:i,length:o.length,setValue:e=>"object"==typeof e?e:null,setState:e=>"object"==typeof e?e:null,convert:(e,t)=>["object"==typeof e?e:{},"object"==typeof t?t:{}]});const l=Object.create(null),a={parent:this,onUpdate:(e,t,n)=>{n===this.#ue[t]&&(this.value={...this.value,[t]:e})},onUpdateState:(e,t,n)=>{n===this.#ue[t]&&(this.state={...this.state,[t]:e})}};for(const[e,t]of o)l[e]=H(t,{...a,index:e});this.#ue=l}}W=G;class Q extends F{#fe=()=>{throw new Error};#ue;get children(){return[...this.#ue.get()]}*[Symbol.iterator](){return yield*[...this.#ue.get().entries()]}child(e){const t=this.#ue.get();return"number"==typeof e&&e<0?t[t.length+e]||null:t[Number(e)]||null}get kind(){return"array"}constructor(t,{parent:n,onUpdate:r,onUpdateState:s,index:i,new:o}={}){const l=new e.Signal.State([]),a=e=>{const t=Array.isArray(e)&&e.length||0,n=[...l.get()],r=n.length;for(let e=n.length;e<t;e++)n.push(this.#fe(e));r!==t&&l.set(n)};super(t,{index:i,new:o,parent:n,length:new e.Signal.Computed((()=>l.get().length)),state:[],setValue:e=>Array.isArray(e)?e:null==e?null:[e],setState:e=>Array.isArray(e)?e:null==e?null:[e],convert(e,t){const n=Array.isArray(e)?e:null==e?null:[e];return a(n),[n,Array.isArray(t)?t:null==e?[]:[t]]},onUpdate:(e,t,n)=>{a(e),r?.(e,t,n)},onUpdateState:s}),this.#ue=l;const c={parent:this,onUpdate:(e,t,n)=>{if(l.get()[t]!==n)return;const r=[...this.value||[]];r.length<t&&(r.length=t),r[t]=e,this.value=r},onUpdateState:(e,t,n)=>{if(l.get()[t]!==n)return;const r=[...this.state||[]];r.length<t&&(r.length=t),r[t]=e,this.state=r}};this.#fe=(e,n)=>{const r=H(t,{...c,index:e,new:n});return r.index=e,r}}insert(e,t=null,n){const r=this.value||[];if(!Array.isArray(r))return!1;const s=[...this.#ue.get()],i=Math.max(0,Math.min(Math.floor(e),s.length)),o=this.#fe(i,n);o.new=!0,s.splice(i,0,o);for(let t=e+1;t<s.length;t++)s[t].index=t;const l=[...r];l.splice(i,0,t);const a=this.state;if(Array.isArray(a)){const e=[...a];e.splice(i,0,{}),this.state=e}return this.#ue.set(s),this.value=l,!0}add(e=null){return this.insert(this.#ue.get().length,e)}remove(e){const t=this.value;if(!Array.isArray(t))return;const n=[...this.#ue.get()],r=Math.max(0,Math.min(Math.floor(e),n.length)),[s]=n.splice(r,1);if(!s)return;for(let t=e;t<n.length;t++)n[t].index=t;const i=[...t],[o]=i.splice(r,1),l=this.state;if(Array.isArray(l)){const e=[...this.state];e.splice(r,1),this.state=e}return this.#ue.set(n),this.value=i,o}move(e,t){const n=this.value;if(!Array.isArray(n))return!1;const r=[...this.#ue.get()],[s]=r.splice(e,1);if(!s)return!1;r.splice(t,0,s);let i=Math.min(e,t),o=Math.max(e,t);for(let e=i;e<=o;e++)r[e].index=e;const l=[...n],[a]=l.splice(e,1);l.splice(t,0,a);const c=this.state;if(Array.isArray(c)){const n=[...c],[r={}]=n.splice(e,1);t<=n.length?n.splice(t,0,r):n[t]=r,this.state=n}return this.#ue.set(r),this.value=l,!0}exchange(e,t){const n=this.value;if(!Array.isArray(n))return!1;const r=[...this.#ue.get()],s=r[e],i=r[t];if(!s||!i)return!1;r[t]=s,r[e]=i,s.index=t,i.index=e;const o=[...n],l=o[e],a=o[t];o[t]=l,o[e]=a;const c=this.state;if(Array.isArray(c)){const n=[...c],r=n[e],s=n[t];n[t]=r,n[e]=s,this.state=n}return this.#ue.set(r),this.value=o,!0}}!function(e){_=e}(Q);const Z={CALC:"no `createCalc` option, no expression parsing support",EVENT:"no `createEvent`, options, no event parsing support",CLOSE:(e,t)=>`end tag name: ${e} is not match the current start tagName: ${t}`,UNCLOSE:e=>`end tag name: ${e} maybe not complete`,QUOTE:e=>`attribute value no end '${e}' match`,CLOSE_SYMBOL:"elements closed character '/' and '>' must be connected to",UNCOMPLETED:(e,t)=>t?`end tag name: ${e} is not complete: ${t}`:`end tag name: ${e} maybe not complete`,ENTITY:e=>`entity not found: ${e}`,SYMBOL:e=>`unexpected symbol: ${e}`,TAG:e=>`invalid tagName: ${e}`,ATTR:e=>`invalid attribute: ${e}`,EQUAL:"attribute equal must after attrName",ATTR_VALUE:'attribute value must after "="',EOF:"unexpected end of file"};class X extends Error{constructor(e,...t){const n=Z[e];super("function"==typeof n?n(...t):n),this.code=e}}const J=/^(?<decorator>[:@!+*\.?]|style:|样式:)?(?<name>-?[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_:\d\.]*)$/u,ee=/^(?<name>[a-zA-Z$\p{Unified_Ideograph}_][\da-zA-Z$\p{Unified_Ideograph}_]*)?$/u;function te(e,t,n){const{attrs:r,directives:s,events:i,classes:o,styles:l,vars:a,aliases:c,params:u}=e;return function(e,f){const d=J.exec(e.replace(/./g,".").replace(/:/g,":").replace(/@/g,"@").replace(/+/g,"+").replace(/-/g,"-").replace(/[*×]/g,"*").replace(/!/g,"!"))?.groups;if(!d)throw new X("ATTR",e);const{name:h}=d,p=d.decorator?.toLowerCase();if(p){if(":"===p)r[h]=ee.test(f)?{name:f}:t(f);else if("."===p)o[h]=!f||(ee.test(f)?f:t(f));else if("style:"===p)l[h]=ee.test(f)?f:t(f);else if("@"===p)i[h]=ee.test(f)?f:n(f);else if("+"===p)a[h]=f?ee.test(f)?f:t(f):"";else if("*"===p)c[h]=ee.test(f)?f:t(f);else if("?"===p)u[h]=ee.test(f)?f:t(f);else if("!"===p){const e=h.toString();switch(e){case"fragment":s.fragment=f||!0;break;case"else":s.else=!0;break;case"enum":s.enum=!f||(ee.test(f)?f:t(f));break;case"if":case"text":case"html":s[e]=ee.test(f)?f:t(f);break;case"template":s.template=f;break;case"bind":s.bind=f||!0;break;case"value":s.value=f;break;case"comment":s.comment=f}}}else r[h]=f}}function ne(e,t){return{name:e,is:t,children:[],attrs:Object.create(null),events:Object.create(null),directives:Object.create(null),classes:Object.create(null),styles:Object.create(null),vars:Object.create(null),aliases:Object.create(null),params:Object.create(null)}}var re={lt:"<",gt:">",amp:"&",quot:'"',apos:"'",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",times:"×",divide:"÷",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",euro:"€",trade:"™",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"};const se=/^(?<name>[\w\p{Unified_Ideograph}_][-\.\|:|d\w\p{Unified_Ideograph}_:]*)(?:|(?<is>[\w\p{Unified_Ideograph}_][-\.\|:|d\w\p{Unified_Ideograph}_]*))?$/u;function ie(e){return"="!==e&&"/"!==e&&">"!==e&&e&&"'"!==e&&'"'!==e&&!function(e){return"0x80"===e||e<=" "}(e)}function oe(e,t,n,r){let s=r[n];return null==s&&(s=e.lastIndexOf("</"+n+">"),s<t&&(s=e.lastIndexOf("</"+n)),r[n]=s),s<t}function le(...e){console.error(new X(...e))}function ae(e){const t=e.slice(1,-1);return"#"===t.charAt(0)?String.fromCodePoint(parseInt(t.substring(1).replace("x","0x"))):t in re?re[t]:(le("ENTITY",e),e)}function ce(e){return("<"==e?"&lt;":">"==e&&"&gt;")||"&"==e&&"&amp;"||'"'==e&&"&quot;"||"&#"+e.charCodeAt()+";"}function*ue(e,t=0){const{attrs:n,events:r,directives:s,children:i,is:o,name:l,params:a,classes:c,styles:u,aliases:f,vars:d}=e,h=t>0?"".padEnd(t,"\t"):"";yield h,yield*["<",l||"-"],o&&(yield*["|",o]);for(const[e,t]of Object.entries(a)){if(null==t)continue;const n="function"==typeof t?String(t):t;yield*[" ?",e],n&&"string"==typeof n&&(yield*['="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(s)){if(!1===t||null==t)continue;const n="function"==typeof t?String(t):t;yield*[" !",e],n&&"string"==typeof n&&(yield*['="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(f)){if(null==t)continue;const n="function"==typeof t?String(t):t;yield*[" *",e],n&&"string"==typeof n&&(yield*['="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(d)){if(null==t)continue;const n="function"==typeof t?String(t):t;yield*[" +",e],n&&"string"==typeof n&&(yield*['="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(n)){if(null==t)continue;if("string"==typeof t){yield*[" ",e],t&&(yield*['="',t.replace(/[<&"]/g,ce),'"']);continue}const n="function"==typeof t?String(t):"object"==typeof t?t.name:t;n&&"string"==typeof n&&(yield*[" :",e,'="',n.replace(/[<&"]/g,ce)||"",'"'])}for(const[e,t]of Object.entries(r)){if(null==t)continue;const n="function"==typeof t?String(t):t;n&&"string"==typeof n&&(yield*[" @",e,'="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(c)){if(null==t||0==t)continue;const n="function"==typeof t?String(t):t;yield*[" .",e],n&&"string"==typeof n&&(yield*[" .",e,'="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(u)){if(null==t)continue;const n="function"==typeof t?String(t):t;n&&"string"==typeof n&&(yield*[" style:",e,'="',n.replace(/[<&"]/g,ce),'"'])}if(!i.length)return yield"/>",void(t>=0&&(yield"\n"));if(1===i.length){const[e]=i;if("string"==typeof e&&e.length<80&&!e.includes("\n"))return yield">",yield*[e.replace(/[<&\t]/g,ce).replace(/]]>/g,"]]&gt;")],yield*["</",l,">"],void(t>=0&&(yield"\n"))}yield">",t>=0&&(yield"\n"),yield*fe(i,t>=0?t+1:-1),yield*[h,"</",l,">"],t>=0&&(yield"\n")}function*fe(e,t=0){if(!e.length)return"";const n=t>0?"".padEnd(t,"\t"):"";for(const r of e)if("string"==typeof r){let e=r.replace(/[<&\t]/g,ce).replace(/]]>/g,"]]&gt;");n&&(e=e.replace(/(?<=^|\n)/g,n)),yield e,t>=0&&(yield"\n")}else yield*ue(r,t)}var de=Object.freeze({__proto__:null,parse:function(e,{createCalc:t=()=>{throw new X("CALC")},createEvent:n=()=>{throw new X("EVENT")},simpleTag:r=new Set}={}){const s=[],i={children:s},o=[];let l=null,a=i;function c(){l=o.pop()||null,a=l||i}function u(e){(e=e.replace(/^\n|(?<=\n)\t+|\n\t*$/g,""))&&a.children.push(e)}let f={},d=0;function h(t){if(t<=d)return;u(e.substring(d,t).replace(/&#?\w+;/g,ae)),d=t}for(;;){const p=e.indexOf("<",d);if(p<0){const E=e.substring(d);E.match(/^\s*$/)||u(E);break}if(p>d&&h(p),"/"===e.charAt(p+1)){d=e.indexOf(">",p+3);let C=e.substring(p+2,d);if(d<0?(C=e.substring(p+2).replace(/[\s<].*/,""),le("UNCOMPLETED",C,l?.name),d=p+1+C.length):C.match(/\s</)&&(C=C.replace(/[\s<].*/,""),le("UNCOMPLETED",C),d=p+1+C.length),l){const A=l.name;if(A===C)c();else{if(A.toLowerCase()!=C.toLowerCase())throw new X("CLOSE",C,l.name);c()}}d++;continue}function g(t){let n=d+1;if(d=e.indexOf(t,n),d<0)throw new X("QUOTE",t);const r=e.slice(n,d).replace(/&#?\w+;/g,ae);return d++,r}function m(){let t=e.charAt(d);for(;t<=" "||"€"===t;t=e.charAt(++d));return t}function b(){let t=d,n=e.charAt(d);for(;ie(n);)d++,n=e.charAt(d);return e.slice(t,d)}d=p+1;let y=e.charAt(d);switch(y){case"=":throw new X("EQUAL");case'"':case"'":throw new X("ATTR_VALUE");case">":case"/":throw new X("SYMBOL",y);case"":throw new X("EOF")}const v=b(),w=se.exec(v)?.groups;if(!w)throw new X("TAG",v);o.push(l),l=ne(w.name,w.is),a.children.push(l),a=l;const x=te(l,t,n);let S=!0,O=!1;e:for(;S;){let $=m();switch($){case"":le("EOF"),d++;break e;case">":d++;break e;case"/":O=!0;break e;case'"':case"'":throw new X("ATTR_VALUE");case"=":throw new X("SYMBOL",$)}const j=b();if(!j){le("EOF"),d++;break e}switch($=m(),$){case"":le("EOF"),d++;break e;case">":x(j,""),d++;break e;case"/":x(j,""),O=!0;break e;case"=":d++;break;case"'":case'"':x(j,g($));continue;default:x(j,"");continue}switch($=m(),$){case"":x(j,""),le("EOF"),d++;break e;case">":x(j,""),d++;break e;case"/":x(j,""),O=!0;break e;case"'":case'"':x(j,g($));continue}x(j,b())}if(O){for(;;){d++;const L=e.charAt(d);if("/"!==L&&!(L<=" "||"€"===L))break}switch(e.charAt(d)){case"=":throw new X("EQUAL");case'"':case"'":throw new X("ATTR_VALUE");case"":le("EOF");break;case">":d++;break;default:throw new X("CLOSE_SYMBOL")}c()}else(r.has(v)||oe(e,d,v,f))&&c()}return s},stringify:function(e,t){const n=t?0:-1;return Array.isArray(e)?[...fe(e,n)].join(""):[ue(e,n)].join()}});function he(t){let n=!0;const r=new e.Signal.subtle.Watcher((()=>{n&&(n=!1,queueMicrotask((()=>{n=!0;for(const e of r.getPending())e.get();r.watch()})))})),s=new e.Signal.Computed(t);return r.watch(s),s.get(),()=>{r.unwatch(s)}}function pe(e,t,n){let r,s=!1;return he((()=>{const i=e();if(!s)return s=!0,r=i,void(n&&t(i));Object.is(i,r)||(r=i,t(i))}))}const ge=new Set(Object.keys({type:!0,meta:!0,component:!0,kind:!0,value:!0,state:!0,store:!0,parent:!0,root:!0,ref:!0,schema:!0,new:!0,readonly:!0,creatable:!0,immutable:!0,changed:!0,required:!0,clearable:!0,hidden:!0,disabled:!0,label:!0,description:!0,placeholder:!0,min:!0,max:!0,step:!0,minLength:!0,maxLength:!0,pattern:!0,values:!0,null:!0,index:!0,no:!0,length:!0,error:!0,errors:!0}));function*me(e,t="",n="$"){yield[`${t}`,{get:()=>e.value,set:t=>e.value=t,store:e}];for(const r of ge)yield[`${t}${n}${r}`,{get:()=>e[r]}];yield[`${t}${n}value`,{get:()=>e.value,set:t=>e.value=t}],yield[`${t}${n}state`,{get:()=>e.state,set:t=>e.state=t}],yield[`${t}${n}reset`,{exec:()=>e.reset()}],yield[`${t}${n}validate`,{exec:t=>e.validate(t?[]:null)}],e instanceof Q&&(yield[`${t}${n}insert`,{exec:(t,n)=>e.insert(t,n)}],yield[`${t}${n}add`,{exec:t=>e.add(t)}],yield[`${t}${n}remove`,{exec:t=>e.remove(t)}],yield[`${t}${n}move`,{exec:(t,n)=>e.move(t,n)}],yield[`${t}${n}exchange`,{exec:(t,n)=>e.exchange(t,n)}])}function be(e,t,n){for(const[n,r]of t){for(const[t,s]of me(r,n))e[t]=s;for(const[t,s]of me(r,n,"$$"))e[t]=s}}const ye={value$:{calc:e=>e?.[V].value},state$:{calc:e=>e?.[V].state}};var ve=Object.getOwnPropertyDescriptors(ye);function we(e){if(!e)return!1;const t=e.indexOf("$");return t<0||(e.indexOf("$",t+2)>0||"$"===e[0]&&"_$".includes(e[1]))}function xe(e,t){Object.defineProperty(t,"$store",{value:e,writable:!1,configurable:!0,enumerable:!1}),Object.defineProperty(t,"$root",{value:e.root,writable:!1,configurable:!0,enumerable:!1})}class Se{exec(e){if("string"==typeof e){const t=this.#de[e];if("function"!=typeof t?.get)return;return t.get()}if("function"==typeof e)return e(this.getters)}watch(e,t){return pe((()=>this.exec(e)),t,!0)}enum(e){if(!e)return!0;if(!0===e)return this.store;if("function"==typeof e)return()=>e(this.getters);if("string"!=typeof e)return null;const t=this.#de[e];if("function"!=typeof t?.get)return null;const n=t.store;return n instanceof F?n:t.get}bind(e,t,n){const r=this.#de[!0===e?"":e];if(!r?.get)return;const{store:s}=r;return s?ge.has(t)?pe((()=>s[t]),n,!0):void 0:"value"===t?pe((()=>r.get()),n,!0):void 0}bindAll(e){const t=this.#de[!0===e?"":e];if(!t?.get)return;const{store:n}=t;if(!n){const e=t.get;if("function"!=typeof e)return;return{$value:t=>pe(e,t,!0)}}return Object.fromEntries([...ge].map((e=>[`$${e}`,t=>pe((()=>n[e]),t,!0)])))}bindSet(e,t){const n=this.#de[!0===e?"":e];if(!n?.get)return;const{store:r}=n;if(r)switch(t){case"value":return e=>{r.value=e};case"state":return e=>{r.state=e}}}bindEvents(e){const t=this.#de[!0===e?"":e];if(!t?.get)return;const{store:n}=t;if(!n){const e=t.set;if("function"!=typeof e)return;return{$value:e}}return{$value:e=>{n.value=e},$state:e=>{n.state=e},$input:e=>{n.emit("input",e)},$change:e=>{n.emit("change",e)},$click:e=>{n.emit("click",e)},$focus:e=>{n.emit("focus",e)},$blur:e=>{n.emit("blur",e)},$reset:e=>{n.reset()},$validate:e=>{n.validate(e?[]:null)}}}getEvent(e){if("function"==typeof e)return e;const t=this.#de[e];if(!t)return null;const{exec:n,calc:r}=t;return"function"==typeof n?n:"function"==typeof r?r:null}constructor(e,t){if(this.store=e,t instanceof Se){this.#he=t.#he;const e=this.#pe;for(const[n,r]of Object.entries(t.#pe))e[n]=r;const n=this.#ge;for(const[e,r]of Object.entries(t.#ge))n[e]=r}else be(this.#pe,e),this.#he=function(e){const t=Object.create(null,ve);if(!e||"object"!=typeof e)return t;for(const[n,r]of Object.entries(e)){if(!we(n))continue;if(!r||"object"!=typeof r)continue;if(r instanceof F){for(const[e,s]of me(r,n))t[e]=s;continue}const{get:e,set:s,exec:i,calc:o}=r;"function"!=typeof e?"function"!=typeof o?"function"!=typeof i||(t[n]={exec:i}):t[n]={calc:o}:t[n]="function"==typeof s?{get:e,set:s}:{get:e}}return t}(t)}#he;#pe=Object.create(null);#ge=Object.create(null);store;#me=null;#s=null;#be=null;get#de(){const e=this.#be;if(e)return e;const t=Object.create(null,Object.getOwnPropertyDescriptors({...this.#pe,...this.#he,...this.#ge})),n=this.store,r=this.#s,s=this.#me;if(s)for(const e of Object.keys(s))t[`$${e}`]={get:()=>s[e]};else{for(const[e,r]of me(n))t[e]=r;for(const[e,s]of function*(e,t,n="",r="$"){if(!(e instanceof Q))return yield[`${n}${r}upMovable`,{get:()=>!1}],void(yield[`${n}${r}downMovable`,{get:()=>!1}]);yield[`${n}${r}upMovable`,{get:()=>{const e=t.index;return"number"==typeof e&&!(e<=0)}}],yield[`${n}${r}downMovable`,{get:()=>{const n=t.index;return"number"==typeof n&&!(n>=e.length-1)}}],yield[`${n}${r}remove`,{exec:()=>e.remove(Number(t.index))}],yield[`${n}${r}upMove`,{exec:()=>{const n=t.index;"number"==typeof n&&(n<=0||e.move(n,n-1))}}],yield[`${n}${r}downMove`,{exec:()=>{const n=t.index;"number"==typeof n&&(n>=e.length-1||e.move(n,n+1))}}]}(r,n))t[e]=s}return this.#be=t,t}setStore(e,t){const n=new Se(e,this);return t&&(n.#s=t),be(n.#pe,e),n}child(e){if(!e)return this;const t=this.store.child(e);if(!t)return null;const n=new Se(t,this);return be(n.#pe,t),n}params({params:t},{attrs:n},r,s){let i=this.store;if(!0===s)i=r.store;else if(s){const e=r.#de[s],t=e?.get&&e.store;t&&(i=t)}if(0===Object.keys(t).length)return this;const o=new Se(i,this);o.#s=this.#s,o.#me=this.#me;const l=o.#ge,a=o.#de;for(const[s,i]of Object.entries(t)){const t=s in n?n[s]:null;if("string"!=typeof t){if(t&&"object"==typeof t){const e=r.#de[t.name];if(!e?.get)continue;if(!e.store){l[s]=a[s]=e;continue}for(const[t,n]of me(e.store,s))l[t]=a[t]=n;continue}if("function"==typeof t){const n=new e.Signal.Computed((()=>t(r.getters)));l[s]=a[s]={get:()=>n.get()};continue}if("function"==typeof i){const t=o.getters;o.#ye=null;const n=new e.Signal.Computed((()=>i(t)));l[s]=a[s]={get:()=>n.get()};continue}{const e=a[i];if(!e?.get)continue;if(!e.store){l[s]=a[s]=e;continue}for(const[t,n]of me(e.store,s))l[t]=a[t]=n;continue}}l[s]=a[s]={get:()=>t}}return o}setObject(e){const t=new Se(this.store,this);return t.#me=e,t}set(t,n){if(Object.keys(t).length+Object.keys(n).length===0)return this;const r=new Se(this.store,this);r.#s=this.#s,r.#me=this.#me;const s=r.#ge,i=r.#de;for(const[n,o]of Object.entries(t)){if("function"==typeof o){const t=r.getters;r.#ye=null;const l=new e.Signal.Computed((()=>o(t)));s[n]=i[n]={get:()=>l.get()};continue}const t=i[o];if(t)if(t.get&&t.store)for(const[e,r]of me(t.store,n))s[e]=i[e]=r;else s[n]=i[n]=t}for(const[t,o]of Object.entries(n)){const n=new e.Signal.State(null);if("function"==typeof o){const e=r.settable;r.#ve=null,n.set(o(e))}else if(o&&"string"==typeof o){const e=i[o];if(!e?.get)continue;n.set(e.get())}s[t]=i[t]={get:()=>n.get(),set:e=>{n.set(e)}}}return r}#we=null;get all(){const e=this.#we;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#de))n.get?Object.defineProperty(t,e,{get:n.get,set:n.set,configurable:!0,enumerable:!0}):n.calc?Object.defineProperty(t,e,{value:n.calc,writable:!1,configurable:!0,enumerable:!1}):Object.defineProperty(t,e,{value:n.exec,writable:!1,configurable:!0,enumerable:!1});return xe(this.store,t),this.#we=t,t}#ve=null;get settable(){const e=this.#ve;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#de))n.get?Object.defineProperty(t,e,{get:n.get,set:n.set,configurable:!0,enumerable:!0}):n.calc&&Object.defineProperty(t,e,{value:n.calc,writable:!1,configurable:!0,enumerable:!1});return xe(this.store,t),this.#ve=t,t}#ye=null;get getters(){const e=this.#ye;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#de))n.get?Object.defineProperty(t,e,{get:n.get,configurable:!0,enumerable:!0}):n.calc&&Object.defineProperty(t,e,{value:n.calc,writable:!1,configurable:!0,enumerable:!1});return xe(this.store,t),this.#ye=t,t}}const Oe={width:"px",height:"px",top:"px",right:"px",bottom:"px",left:"px",border:"px","border-top":"px","border-right":"px","border-left":"px","border-bottom":"px","border-width":"px","border-top-width":"px","border-right-width":"px","border-left-width":"px","border-bottom-width":"px","border-radius":"px","border-top-left-radius":"px","border-top-right-radius":"px","border-bottom-left-radius":"px","border-bottom-right-radius":"px",padding:"px","padding-top":"px","padding-right":"px","padding-left":"px","padding-bottom":"px",margin:"px","margin-top":"px","margin-right":"px","margin-left":"px","margin-bottom":"px"};function Ee(e,t){let n=!!Array.isArray(t)&&Boolean(t[1]),r="";if("string"==typeof t)return r=t.replace(/!important\s*$/,""),r?(n=r!==t,[r,n?"important":void 0]):null;const s=Array.isArray(t)?t[0]:t;return"number"==typeof s||"bigint"==typeof s?r=s&&e in Oe?`${s}${Oe[e]}`:`${s}`:"string"==typeof s&&(r=s),r?[r,n?"important":void 0]:null}class Ce{#e=new Map;emit(e,...t){const n="number"==typeof e?String(e):e,r=this.#e;for(const e of[...r.get(n)||[]])e(...t)}listen(e,t){const n=t.bind(this),r=this.#e,s="number"==typeof e?String(e):e;let i=r.get(s);return i||(i=new Set,r.set(s,i)),i.add(n),()=>{i?.delete(n)}}}const Ae={stop(e){e instanceof Event&&e.stopPropagation()},prevent(e){e instanceof Event&&e.preventDefault()},self(e){if(e instanceof Event)return e.target===e.currentTarget},enter(e){if(e instanceof KeyboardEvent)return"Enter"===e.key},tab(e){if(e instanceof KeyboardEvent)return"Tab"===e.key},esc(e){if(e instanceof KeyboardEvent)return"Escape"===e.key},space(e){if(e instanceof KeyboardEvent)return" "===e.key},backspace(e){if(e instanceof KeyboardEvent)return"Backspace"===e.key},delete(e){if(e instanceof KeyboardEvent)return"Delete"===e.key},delBack(e){if(e instanceof KeyboardEvent)return"Delete"===e.key||"Backspace"===e.key},"del-back"(e){if(e instanceof KeyboardEvent)return"Delete"===e.key||"Backspace"===e.key},insert(e){if(e instanceof KeyboardEvent)return"Insert"===e.key},repeat(e){if(e instanceof KeyboardEvent)return e.repeat},key(e,t){if(e instanceof KeyboardEvent){const n=e.code.toLowerCase().replace(/-/g,"");for(const e of t)if(n===e.toLowerCase().replace(/-/g,""))return!0;return!1}},main(e){if(e instanceof MouseEvent)return 0===e.button},auxiliary(e){if(e instanceof MouseEvent)return 1===e.button},secondary(e){if(e instanceof MouseEvent)return 2===e.button},left(e){if(e instanceof MouseEvent)return 0===e.button},middle(e){if(e instanceof MouseEvent)return 1===e.button},right(e){if(e instanceof MouseEvent)return 2===e.button},primary(e){if(e instanceof PointerEvent)return e.isPrimary},mouse(e){if(e instanceof PointerEvent)return"mouse"===e.pointerType},pen(e){if(e instanceof PointerEvent)return"pen"===e.pointerType},touch(e){if(e instanceof PointerEvent)return"touch"===e.pointerType},pointer(e,t){if(e instanceof PointerEvent){const n=e.pointerType.toLowerCase().replace(/-/g,"");for(const e of t)if(n===e.toLowerCase().replace(/-/g,""))return!0;return!1}},ctrl(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.ctrlKey},alt(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.altKey},shift(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.shiftKey},meta(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.metaKey},cmd(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.ctrlKey||e.metaKey}};function $e(e){return"number"==typeof e||"bigint"==typeof e?String(e):"boolean"==typeof e?e?"":null:"string"==typeof e?e:null===(e??null)?null:String(e)}function je(e){return null===(e??null)?"":String(e)}function Le(e,t){if(e instanceof HTMLInputElement&&"checked"===t)switch(e.type.toLowerCase()){case"checkbox":case"radio":return Boolean}if((e instanceof HTMLSelectElement||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&"value"===t)return je;if(e instanceof HTMLDetailsElement&&"open"===t)return Boolean;if(e instanceof HTMLMediaElement){if("muted"===t)return Boolean;if("paused"===t)return Boolean;if("currentTime"===t)return!0;if("playbackRate"===t)return!0;if("volume"===t)return!0}return!1}const Te={input:{attrs:{$min:(e,t)=>{t.min=e},$max:(e,t)=>{t.max=e},$step:(e,t)=>{t.step=e},$placeholder:(e,t)=>{t.placeholder=e},$disabled:(e,t)=>{t.disabled=e},$readonly:(e,t)=>{t.readOnly=e},$required:(e,t)=>{t.required=e},$value:(e,t)=>{switch(t.type){case"checkbox":case"radio":t.checked=Boolean(e)}t.value=je(e)}},events:{$value:["input",(e,t)=>{switch(t.type){case"checkbox":case"radio":return t.checked;case"number":return Number(t.value)}return t.value}]}},textarea:{attrs:{$placeholder:(e,t)=>{t.placeholder=e},$disabled:(e,t)=>{t.disabled=e},$readonly:(e,t)=>{t.readOnly=e},$required:(e,t)=>{t.required=e},$value:(e,t)=>{t.value=je(e)}},events:{$value:["input",(e,t)=>t.value]}},select:{attrs:{$disabled:(e,t)=>{t.disabled=e},$required:(e,t)=>{t.required=e},$value:(e,t)=>{t.value=je(e)}},events:{$value:["change",(e,t)=>t.value]}}};function Me(e,t,n){const r=document.createElement(t,{is:n||void 0}),{watchAttr:s,props:i}=e;return e.listen("init",(({events:n})=>{const o=Te[t.toLowerCase()],l=o?.attrs||{},a=o?.events||{};for(const[e,t,s]of n)if("$"!==e[0])r.addEventListener(e,t,s);else{const n=a[e];if(n){const[e,i]=n;r.addEventListener(e,(e=>t(i(e,r))),s)}}if(i)for(const[t,n]of Object.entries(e.tagAttrs))if(s(t,(e=>{if(i.has(t))r[t]=e;else{const n=$e(e);null==n?r.removeAttribute(t):r.setAttribute(t,n)}})),i.has(t))r[t]=n;else{const e=$e(n);null!==e&&r.setAttribute(t,e)}else for(const[t,n]of Object.entries(e.tagAttrs)){if(r instanceof HTMLInputElement&&"type"===t.toLocaleLowerCase()){const e=$e(n);null!==e&&r.setAttribute(t,e);continue}if("$hidden"===t){n&&(r.hidden=n),s(t,(e=>{r.hidden=e}));continue}if("$"===t[0]){const e=l[t];e&&(e(n,r),s(t,(t=>e(t,r))));continue}const e=Le(r,t);if("function"==typeof e){r[t]=e(n),s(t,(n=>{r[t]=e(n)}));continue}if(e){r[t]=n,s(t,(e=>{r[t]=e}));continue}let i=$e(n);null!==i&&r.setAttribute(t,i),s(t,(e=>{const n=$e(e);null===n?r.removeAttribute(t):r.setAttribute(t,n)}))}})),r}function Ne(e){return null===(e??null)?"":String(e)}function ke(e,t,n,{text:r,html:s}){if(null!=r){const s=e.insertBefore(document.createTextNode(""),t),i=n.watch(r,(e=>s.textContent=Ne(e)));return()=>{s.remove(),i()}}if(null==s)return;const i=e.insertBefore(document.createComment(""),t),o=e.insertBefore(document.createComment(""),t),l=document.createElement("div");function a(){for(let e=i.nextSibling;e&&e!==o;e=i.nextSibling)e.remove()}const c=n.watch(s,(t=>{a(),function(t){l.innerHTML=t;for(let t=l.firstChild;t;t=i.firstChild)e.insertBefore(t,o)}(Ne(t))}));return()=>{c(),a(),i.remove(),o.remove()}}function Ie(e,t,n,r,s,i){let o=new Set,l=[],a=Object.create(s);for(const t of e){if("string"==typeof t)continue;const e=t.directives.template;e&&(a[e]=[t,r])}function c(e){if(!e.length||!o)return;const s=t.insertBefore(document.createComment(""),n);let l=-1,c=()=>{};o.add((()=>{c(),c=()=>{},s.remove()})),o.add(pe((()=>e.findIndex((([e])=>null===e||r.exec(e)))),(t=>{t!==l&&(l=t,c(),c=()=>{},function(t){const n=e[t]?.[1];n&&(c=i(n,a))}(l))}),!0))}for(const r of e){if("string"==typeof r){c(l),l=[];const e=document.createTextNode(r);t.insertBefore(e,n),o.add((()=>e.remove()));continue}if(r.directives.template){c(l),l=[];continue}if(l.length&&r.directives.else){const e=r.directives.if||null;l.push([e,r]),e||(c(l),l=[]);continue}c(l),l=[];const e=r.directives.if;e?l.push([e,r]):o.add(i(r,a))}return()=>{if(!o)return;const e=o;o=null;for(const t of e)t()}}function Pe(t,n,r,s,i,o,l,a){s=s.set(t.aliases,t.vars);const c=t.directives.bind,u=t.directives.fragment;if(u&&"string"==typeof u){const e=i[u];if(!e)return()=>{};const[f,d]=e,h=d.params(f,t,s,c);return Ue(f,n,r,h,i,o,l,a)}if(!t.name||t.directives.fragment)return ke(n,r,s,t.directives)||Ie(t.children||[],n,r,s,i,((e,t)=>Ue(e,n,r,s,t,o,l,a)));const f=[...o,t.name],d=a?.(f);if(a&&!d)return()=>{};const{context:h,handler:p}=function(t,n,r){const s="string"==typeof t?t:t.tag,{attrs:i,events:o}="string"!=typeof t&&t||{attrs:null,events:null};let l=!1;const a=new e.Signal.State(!1);let c=!1;const u=new e.Signal.State(!1),f=Object.create(null),d=Object.create(null),h=new Set,p=[],g=new Ce;return{context:{events:p,props:i?new Set(Object.entries(i).filter((([,e])=>e.isProp)).map((([e])=>e))):null,tagAttrs:d,watchAttr(e,t){if(l)return()=>{};const n=f[e];if(!n)return()=>{};let r=n.get();const s=pe((()=>n.get()),(n=>{const s=r;r=n,t(n,s,e)}),!0);return h.add(s),()=>{h.delete(s),s()}},relate(e){if(!r||l)return()=>{};try{const t=r(n.store,e);return"function"!=typeof t?()=>{}:(h.add(t),()=>{h.delete(t),t()})}catch{return()=>{}}},get destroyed(){return a.get()},get init(){return u.get()},listen:(e,t)=>g.listen(e,t)},handler:{tag:s,set(t,n){if(i&&!(t in i))return;let r=f[t];if(r)return void r.set(n);const s=new e.Signal.State(n);f[t]=s,Object.defineProperty(d,t,{configurable:!0,enumerable:!0,get:s.get.bind(s)})},addEvent(e,t){if("function"!=typeof t)return;const[r,...s]=e.split(".").filter(Boolean),i=o?o[r].filters:{};if(!i)return;const l={},a=[];if(i)for(let e=s.shift();e;e=s.shift()){const t=e.indexOf(":"),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1).split(":"):[],s=n.replace(/^-+/,""),o=(n.length-s.length)%2==1;let c=i[s]||s;switch(c){case"once":l.once=!o;break;case"passive":l.passive=!o;break;case"capture":l.capture=!o;break;default:"string"==typeof c&&(c=Ae[c])}"function"==typeof c&&a.push([c,r,o])}p.push([r,e=>{const r=n.all;for(const[t,n,s]of a)if(t(e,n,r)===s)return;t(e,r)},l])},destroy(){if(!l){l=!0,a.set(!0);for(const e of h)e();g.emit("destroy")}},mount(){c||(c=!0,u.set(!0),g.emit("init",{events:p}))}}}}(d||t.name,s,l),g=d?.attrs,m=g?function(e,t,n,r,s){let i=new Set;for(const[o,l]of Object.entries(r)){const r=n[o];if(o in n){if("function"!=typeof r&&"object"!=typeof r){e.set(o,r);continue}const n="function"==typeof r?r:r.name;if(l.immutable){e.set(o,t.exec(n));continue}i.add(t.watch(n,(t=>e.set(o,t))));continue}const a=l.bind;if(!s||!a){e.set(o,l.default);continue}if("string"==typeof a){const n=t.bind(s,a,(t=>e.set(o,t)));n?i.add(n):e.set(o,l.default);continue}if(!Array.isArray(a)){e.set(o,l.default);continue}const[c,u,f]=a;if(!c||"function"!=typeof u)continue;if(!f){const n=!0===s?"":s;i.add(t.watch(n,(t=>e.set(o,t)))),e.addEvent(c,((...e)=>{t.all[n]=u(...e)}));continue}const d=t.bind(s,"state",(t=>e.set(o,t)));if(!d)continue;i.add(d);const h=t.bindSet(s,"state");h&&e.addEvent(c,((...e)=>{h(u(...e))}))}return()=>{const e=i;i=new Set;for(const t of e)t()}}(p,s,t.attrs,g,c):function(e,t,n){const r=e.tag;let s=new Set;for(const[i,o]of Object.entries(n)){if("function"!=typeof o&&"object"!=typeof o){e.set(i,o);continue}const n="function"==typeof o?o:o.name;if("string"!=typeof r||"input"!==r.toLocaleLowerCase()||"type"!==i.toLocaleLowerCase())s.add(t.watch(n,(t=>e.set(i,t))));else{const r=t.exec(n);e.set(i,r)}}return()=>{const e=s;s=new Set;for(const t of e)t()}}(p,s,t.attrs);for(const[e,n]of Object.entries(t.events)){const t=s.getEvent(n);t&&p.addEvent(e,t)}const b=function(e,t,n){if(!n)return()=>{};let r=new Set;for(const[s,i]of Object.entries(t.bindAll(n)||{}))"function"==typeof i&&r.add(i((t=>e.set(s,t))));for(const[r,s]of Object.entries(t.bindEvents(n)||{}))e.addEvent(r,(e=>s(e)));return()=>{const e=r;r=new Set;for(const t of e)t()}}(p,s,c),y=d?"function"==typeof d.tag?d.tag(h):Me(h,d.tag,d.is):Me(h,t.name,t.is),v=Array.isArray(y)?y[0]:y,w=Array.isArray(y)?y[1]:v;n.insertBefore(v,r);const x=w?ke(w,null,s,t.directives)||Ie(t.children||[],w,null,s,i,((e,t)=>Ue(e,w,null,s,t,o,l,a))):()=>{};return function(e,t,n){if(!(e instanceof Element))return()=>{};let r=new Set;for(const[s,i]of Object.entries(t))i&&(!0!==i?r.add(pe((()=>Boolean(n.exec(i))),(t=>{t?e.classList.add(s):e.classList.remove(s)}),!0)):e.classList.add(s))}(v,t.classes,s),function(e,t,n){if(!(e instanceof HTMLElement||e instanceof SVGElement))return()=>{};let r=new Set;for(const[s,i]of Object.entries(t))r.add(pe((()=>Ee(s,n.exec(i))),(t=>{t?e.style.setProperty(s,...t):e.style.removeProperty(s)}),!0))}(v,t.styles,s),p.mount(),()=>{v.remove(),p.destroy(),m(),x(),b()}}function Ue(t,n,r,s,i,o,l,a){const{directives:c}=t,u=s.child(c.value);if(!u)return()=>{};const f=u.enum(c.enum),d=(e,r)=>Pe(t,n,e,r,i,o,l,a);return!0===f?d(r,u):f instanceof Q?function(e,t,n,r,s){const i=e.insertBefore(document.createComment(""),t);let o=new Map;function l(e){for(const[t,n,r]of e.values())r(),t.remove(),n.remove()}const a=pe((()=>n.children),(function(t){if(!i.parentNode)return;let a=i.nextSibling;const c=o;o=new Map;for(let i of t){const t=c.get(i);if(!t){const t=e.insertBefore(document.createComment(""),a),l=e.insertBefore(document.createComment(""),a),c=s(l,r.setStore(i,n));o.set(i,[t,l,c]);continue}if(c.delete(i),o.set(i,t),a===t[0]){a=t[1].nextSibling;continue}let l=t[0];for(;l&&l!==t[1];){const t=l;l=l.nextSibling,e.insertBefore(t,a)}e.insertBefore(t[1],a)}l(c)}),!0);return()=>{i.remove(),l(o),a()}}(n,r,f,u,d):f instanceof G?function(e,t,n,r,s){const i=[];for(const[e,o]of[...n])i.push(s(t,r.setStore(o,n)));return()=>{for(const e of i)e()}}(0,r,f,u,d):"function"==typeof f?function(t,n,r,s,i){const o=new e.Signal.Computed((()=>{const e=r();if("number"==typeof e){const t=Math.floor(e);return t?Array(t).fill(0).map(((e,t)=>[t+1,t,t])):[]}return e&&"object"==typeof e?Array.isArray(e)?e.map(((e,t)=>[e,t,t])):Object.entries(e).map((([e,t],n)=>[t,n,e])):[]})),l=t.insertBefore(document.createComment(""),n);let a=[];function c(e){for(const[t,n,r]of e)r(),t.remove(),n.remove()}const u=pe((()=>o.get()),(function(n){if(!l.parentNode)return;let r=l.nextSibling;const o=a;a=[];for(const[l,c,u]of n){const n=o.findIndex((e=>e[3]===u)),[f]=n>=0?o.splice(n,1):[];if(!f){const n=t.insertBefore(document.createComment(""),r),o=t.insertBefore(document.createComment(""),r),f=new e.Signal.State(l),d=new e.Signal.State(c),h=i(o,s.setObject({get key(){return u},get value(){return f.get()},get index(){return d.get()}}));a.push([n,o,h,u,f,d]);continue}if(a.push(f),f[4].set(l),f[5].set(c),r===f[0]){r=f[1].nextSibling;continue}let d=f[0];for(;d&&d!==f[1];){const e=d;d=d.nextSibling,t.insertBefore(e,r)}t.insertBefore(f[1],r)}c(o)}),!0);return()=>{l.remove(),c(a),u()}}(n,r,f,u,d):()=>{}}e.Layout=de,e.Store=F,e.effect=he,e.render=function(e,t,n,{component:r,global:s,relate:i}={}){const o=new Se(e,s),l=Object.create(null),a="function"==typeof i?i:null;return Ie(t,n,null,o,l,((e,t)=>Ue(e,n,null,o,t,[],a,r)))},e.watch=pe}));
60
+ function(e){const t=Object.create(T);t.value=e;const n=()=>(h(t),t.value);return n[u]=t,n}(r),a=l[u];if(this[M]=a,a.wrapper=this,i){const t=i.equals;t&&(a.equal=t),a.watched=i[e.subtle.watched],a.unwatched=i[e.subtle.unwatched]}}get(){if(!(0,e.isState)(this))throw new TypeError("Wrong receiver type for Signal.State.prototype.get");return j.call(this[M])}set(t){if(!(0,e.isState)(this))throw new TypeError("Wrong receiver type for Signal.State.prototype.set");if(a)throw new Error("Writes to signals not permitted during Watcher callback");L(this[M],t)}};c=M,p=new WeakSet,e.isComputed=e=>r(p,e),e.Computed=class{constructor(t,r){s(this,p),n(this,c);const i=function(e){const t=Object.create(A);t.computation=e;const n=()=>S(t);return n[u]=t,n}(t),o=i[u];if(o.consumerAllowSignalWrites=!0,this[M]=o,o.wrapper=this,r){const t=r.equals;t&&(o.equal=t),o.watched=r[e.subtle.watched],o.unwatched=r[e.subtle.unwatched]}}get(){if(!(0,e.isComputed)(this))throw new TypeError("Wrong receiver type for Signal.Computed.prototype.get");return S(this[M])}},(t=>{var o,a,c,u;t.untrack=function(e){let t,n=null;try{n=f(null),t=e()}finally{f(n)}return t},t.introspectSources=function(t){var n;if(!(0,e.isComputed)(t)&&!(0,e.isWatcher)(t))throw new TypeError("Called introspectSources without a Computed or Watcher argument");return(null==(n=t[M].producerNode)?void 0:n.map((e=>e.wrapper)))??[]},t.introspectSinks=function(t){var n;if(!(0,e.isComputed)(t)&&!(0,e.isState)(t))throw new TypeError("Called introspectSinks without a Signal argument");return(null==(n=t[M].liveConsumerNode)?void 0:n.map((e=>e.wrapper)))??[]},t.hasSinks=function(t){if(!(0,e.isComputed)(t)&&!(0,e.isState)(t))throw new TypeError("Called hasSinks without a Signal argument");const n=t[M].liveConsumerNode;return!!n&&n.length>0},t.hasSources=function(t){if(!(0,e.isComputed)(t)&&!(0,e.isWatcher)(t))throw new TypeError("Called hasSources without a Computed or Watcher argument");const n=t[M].producerNode;return!!n&&n.length>0};o=M,a=new WeakSet,c=new WeakSet,u=function(t){for(const n of t)if(!(0,e.isComputed)(n)&&!(0,e.isState)(n))throw new TypeError("Called watch/unwatch without a Computed or State argument")},e.isWatcher=e=>r(a,e),t.Watcher=class{constructor(e){s(this,a),s(this,c),n(this,o);let t=Object.create(d);t.wrapper=this,t.consumerMarkedDirty=e,t.consumerIsAlwaysLive=!0,t.consumerAllowSignalWrites=!1,t.producerNode=[],this[M]=t}watch(...t){if(!(0,e.isWatcher)(this))throw new TypeError("Called unwatch without Watcher receiver");i(this,c,u).call(this,t);const n=this[M];n.dirty=!1;const r=f(n);for(const e of t)h(e[M]);f(r)}unwatch(...t){if(!(0,e.isWatcher)(this))throw new TypeError("Called unwatch without Watcher receiver");i(this,c,u).call(this,t);const n=this[M];w(n);for(let e=n.producerNode.length-1;e>=0;e--)if(t.includes(n.producerNode[e].wrapper)){y(n.producerNode[e],n.producerIndexOfThis[e]);const t=n.producerNode.length-1;if(n.producerNode[e]=n.producerNode[t],n.producerIndexOfThis[e]=n.producerIndexOfThis[t],n.producerNode.length--,n.producerIndexOfThis.length--,n.nextProducerIndex--,e<n.producerNode.length){const t=n.producerIndexOfThis[e],r=n.producerNode[e];x(r),r.liveConsumerIndexOfThis[t]=e}}}getPending(){if(!(0,e.isWatcher)(this))throw new TypeError("Called getPending without Watcher receiver");return this[M].producerNode.filter((e=>e.dirty)).map((e=>e.wrapper))}},t.currentComputed=function(){var e;return null==(e=l)?void 0:e.wrapper},t.watched=Symbol("watched"),t.unwatched=Symbol("unwatched")})(e.subtle||(e.subtle={}))})(e.Signal||(e.Signal={}));const N=(t,n,r,s)=>{const i=new e.Signal.State("boolean"==typeof n?n:null);let o;if("function"==typeof r)o=new e.Signal.Computed((()=>Boolean(r(t))));else{const t=Boolean(r);o=new e.Signal.Computed((()=>t))}const l=()=>{const e=i.get();return null===e?o.get():e},a=s?new e.Signal.Computed((()=>s.get()||l())):new e.Signal.Computed(l);return[i,a]},k=e=>"string"==typeof e&&e||null,I=e=>"number"==typeof e&&e||null,P=e=>e instanceof RegExp?e:null,U=Boolean;function q(e){if("number"==typeof e||"string"==typeof e)return{label:e,value:e};if(!e||"object"!=typeof e)return null;const{children:t,label:n,value:r}=e,s=Array.isArray(t)?t.map(q).filter(U):[];return s.length?{children:s,label:n,value:r}:"number"==typeof r||"string"==typeof r?{label:n,value:r}:null}const B=e=>{if(!e||!Array.isArray(e))return null;const t=e.map(q).filter(U);return t.length?t:null};function R(t,n,r,s){const i=new e.Signal.State(n(r));let o;if("function"==typeof s){const r=s;o=new e.Signal.Computed((()=>n(r(t))))}else{const t=n(s);o=new e.Signal.Computed((()=>t))}const l=new e.Signal.Computed((()=>{const e=i.get();return null===e?o.get():e}));return[i,l]}const V=Symbol();function D(e){const t={[V]:e};for(const[n,r]of e)Object.defineProperty(t,n,{get:()=>r.ref,configurable:!1,enumerable:!0});return Object.defineProperty(t,V,{get:()=>e,configurable:!1,enumerable:!0}),t}let W=null,_=null,K=Object.create(null);function H(e,t){const n=e.type;let r=F;if(!e.array||_&&t?.parent instanceof _)if("string"==typeof n){const e=K[n];e&&(r=e)}else n&&"object"==typeof n&&W&&(r=W);else _&&(r=_);return new r(e,t)}function Y(e){return e?e instanceof Error?e.message:"string"!=typeof e?"":e:""}function z(t,...n){const r=n.flat().filter((e=>"function"==typeof e));if(!r.length)return[()=>Promise.resolve([]),new e.Signal.Computed((()=>[])),()=>{}];const s=new e.Signal.State([]);let i=null;return[function(){i?.abort(),i=new AbortController;const e=i.signal;return s.set([]),Promise.all(r.map((n=>async function(e,n){let r=[];try{r.push(await e(t,n))}catch(e){r.push(e)}const i=r.flat().map(Y).filter(Boolean);return!n.aborted&&i.length&&s.set([...s.get(),...i]),i}(n,e)))).then((e=>e.flat()))},new e.Signal.Computed((()=>s.get())),()=>{i?.abort(),s.set([])}]}class F{#e=new Map;emit(e,t){const n="number"==typeof e?String(e):e,r=this.#e;let s=!1;for(const e of[...r.get(n)||[]])s=!1===e(t,this)||s;return!s}listen(e,t){const n=t.bind(this),r=this.#e,s="number"==typeof e?String(e):e;let i=r.get(s);return i||(i=new Set,r.set(s,i)),i.add(n),()=>{i?.delete(n)}}static create(e,t={}){return H({type:e},{...t,parent:null})}static setStore(e,t){return function(e,t){K[e]=t}(e,t)}#t=!1;get null(){return this.#t}get kind(){return""}#n=null;get ref(){return this.#n||D(this)}constructor(t,{null:n,state:r,ref:s,setValue:i,setState:o,convert:l,onUpdate:a,onUpdateState:c,validator:u,validators:f,index:d,length:h,new:p,parent:g,hidden:m,clearable:b,required:y,disabled:v,readonly:w,label:x,description:S,placeholder:O,min:E,max:C,step:A,minLength:$,maxLength:j,pattern:L,values:T}={}){this.schema=t,this.#r.set("object"==typeof r&&r||{});const M=g instanceof F?g:null;M&&(this.#s=M,this.#i=M.#i),this.#o=t.type,this.#l=t.meta,this.#a=t.component;const U=new e.Signal.State(Boolean(p));this.#c=U;const q=M?new e.Signal.Computed((()=>M.#u.get()||U.get())):new e.Signal.Computed((()=>U.get()));this.#u=q;const V=Boolean(t.immutable),W=!1!==t.creatable;this.#f=V,this.#d=W;const _=t.readonly,K=new e.Signal.State("boolean"==typeof w?w:null);let H;if("function"==typeof _)H=new e.Signal.Computed((()=>Boolean(_(this))));else{const t=Boolean(_);H=new e.Signal.Computed((()=>t))}const G=()=>{if(q.get()?!W:V)return!0;const e=K.get();return null===e?H.get():e},Q=M?M.#h:null;this.#p=K,this.#h=Q?new e.Signal.Computed((()=>Q.get()||G())):new e.Signal.Computed(G),[this.#g,this.#m]=N(this,m,t.hidden,M?M.#m:null),[this.#b,this.#y]=N(this,b,t.clearable,M?M.#y:null),[this.#v,this.#w]=N(this,y,t.required,M?M.#w:null),[this.#x,this.#S]=N(this,v,t.disabled,M?M.#S:null),[this.#O,this.#E]=R(this,k,x,t.label),[this.#C,this.#A]=R(this,k,S,t.description),[this.#$,this.#j]=R(this,k,O,t.placeholder),[this.#L,this.#T]=R(this,I,E,t.min),[this.#M,this.#N]=R(this,I,C,t.max),[this.#k,this.#I]=R(this,I,A,t.step),[this.#P,this.#U]=R(this,I,$,t.minLength),[this.#q,this.#B]=R(this,I,j,t.maxLength),[this.#R,this.#V]=R(this,P,L,t.pattern),[this.#D,this.#W]=R(this,B,T,t.values);const Z=function(t,...n){const r=n.flat().filter((e=>"function"==typeof e));return r.length?new e.Signal.Computed((()=>{const e=[];for(const n of r)try{e.push(n(t))}catch(t){e.push(t)}return e.flat().map(Y).filter(Boolean)})):new e.Signal.Computed((()=>[]))}(this,t.validator,u),[X,J,ee]=z(this,t.validators?.change,f?.change),[te,ne,re]=z(this,t.validators?.blur,f?.blur);if(this.listen("change",(()=>{X()})),this.listen("blur",(()=>{te()})),this.#_=function(...t){const n=t.filter(Boolean);return new e.Signal.Computed((()=>n.flatMap((e=>e.get()))))}(Z,J,ne),this.#K=Z,this.#H=X,this.#Y=te,this.#z=ee,this.#F=re,h instanceof e.Signal.State||h instanceof e.Signal.Computed?this.#G=h:this.#G=new e.Signal.State(h||0),n)return this.#t=!0,void(this.#n=D(this));this.#n=s||null,this.#Q=a||null,this.#Z=c||null,this.#X="function"==typeof i?i:null,this.#J="function"==typeof o?o:null,this.#ee="function"==typeof l?l:null,this.#te.set(d??"");for(const[e,n]of Object.entries(t.events||{}))"function"==typeof n&&this.listen(e,n)}#X=null;#J=null;#ee=null;#Q=null;#Z=null;#s=null;#i=this;#o;#l;#a;get store(){return this}get parent(){return this.#s}get root(){return this.#i}get type(){return this.#o}get meta(){return this.#l}get component(){return this.#a}#G;get length(){return this.#G.get()}#te=new e.Signal.State("");get index(){return this.#te.get()}set index(e){this.#te.set(e)}get no(){if(this.#t)return"";const e=this.index;return"number"==typeof e?e+1:e}#d=!0;get creatable(){return this.#d}#f=!1;get immutable(){return this.#f}#u;#c;get selfNew(){return this.#c.get()}set selfNew(e){this.#c.set(Boolean(e))}get new(){return this.#u.get()}set new(e){this.#c.set(Boolean(e))}#g;#m;get selfHidden(){return this.#g.get()}set selfHidden(e){this.#g.set("boolean"==typeof e?e:null)}get hidden(){return this.#m.get()}set hidden(e){this.#g.set("boolean"==typeof e?e:null)}#b;#y;get selfClearable(){return this.#b.get()}set selfClearable(e){this.#b.set("boolean"==typeof e?e:null)}get clearable(){return this.#y.get()}set clearable(e){this.#b.set("boolean"==typeof e?e:null)}#v;#w;get selfRequired(){return this.#v.get()}set selfRequired(e){this.#v.set("boolean"==typeof e?e:null)}get required(){return this.#w.get()}set required(e){this.#v.set("boolean"==typeof e?e:null)}#x;#S;get selfDisabled(){return this.#x.get()}set selfDisabled(e){this.#x.set("boolean"==typeof e?e:null)}get disabled(){return this.#S.get()}set disabled(e){this.#x.set("boolean"==typeof e?e:null)}#p;#h;get selfReadonly(){return this.#p.get()}set selfReadonly(e){this.#p.set("boolean"==typeof e?e:null)}get readonly(){return this.#h.get()}set readonly(e){this.#p.set("boolean"==typeof e?e:null)}#O;#E;get selfLabel(){return this.#O.get()}set selfLabel(e){this.#O.set(k(e))}get label(){return this.#E.get()}set label(e){this.#O.set(k(e))}#C;#A;get selfDescription(){return this.#C.get()}set selfDescription(e){this.#C.set(k(e))}get description(){return this.#A.get()}set description(e){this.#C.set(k(e))}#$;#j;get selfPlaceholder(){return this.#$.get()}set selfPlaceholder(e){this.#$.set(k(e))}get placeholder(){return this.#j.get()}set placeholder(e){this.#$.set(k(e))}#L;#T;get selfMin(){return this.#L.get()}set selfMin(e){this.#L.set(I(e))}get min(){return this.#T.get()}set min(e){this.#L.set(I(e))}#M;#N;get selfMax(){return this.#M.get()}set selfMax(e){this.#M.set(I(e))}get max(){return this.#N.get()}set max(e){this.#M.set(I(e))}#k;#I;get selfStep(){return this.#k.get()}set selfStep(e){this.#k.set(I(e))}get step(){return this.#I.get()}set step(e){this.#k.set(I(e))}#P;#U;get selfMinLength(){return this.#P.get()}set selfMinLength(e){this.#P.set(I(e))}get minLength(){return this.#U.get()}set minLength(e){this.#P.set(I(e))}#q;#B;get selfMaxLength(){return this.#q.get()}set selfMaxLength(e){this.#q.set(I(e))}get maxLength(){return this.#B.get()}set maxLength(e){this.#q.set(I(e))}#R;#V;get selfPattern(){return this.#R.get()}set selfPattern(e){this.#R.set(P(e))}get pattern(){return this.#V.get()}set pattern(e){this.#R.set(P(e))}#D;#W;get selfValues(){return this.#D.get()}set selfValues(e){this.#D.set(B(e))}get values(){return this.#W.get()}set values(e){this.#D.set(B(e))}#_;#K;#H;#Y;#z;#F;get errors(){return this.#_.get()}get error(){return this.#_.get()[0]}*[Symbol.iterator](){}child(e){return null}#ne=!1;#re=new e.Signal.State(null);#se=new e.Signal.State(this.#re.get());#r=new e.Signal.State(null);get changed(){return this.#se.get()===this.#re.get()}get value(){return this.#se.get()}set value(e){const t=this.#X?.(e),n=void 0===t?e:t;this.#se.set(n),this.#ne||this.#re.set(n),this.#Q?.(n,this.#te.get(),this),this.#ie()}get state(){return this.#r.get()}set state(e){const t=this.#J?.(e),n=void 0===t?e:t;this.#r.set(n),this.#Z?.(n,this.#te.get(),this),this.#ie()}#ie(){this.#oe||(this.#oe=!0,queueMicrotask((()=>{const e=this.#se.get(),t=this.#r.get();this.#le(e,t)})))}reset(e=this.#re.get()){this.#ae(e)}#ae(e){const t=this.#X?.(e),n=void 0===t?e:t;if(this.#z(),this.#F(),this.#ne=!0,!n||"object"!=typeof n){for(const[,e]of this)e.#ae(null);return this.#se.set(n),this.#re.set(n),n}const r=Array.isArray(n)?[...n]:{...n};for(const[e,t]of this)r[e]=t.#ae(r[e]);return this.#se.set(r),this.#re.set(r),r}#oe=!1;#ce(e,t){const[n,r]=this.#ee?.(e,t)||[e,t];return this.#se.get()===n&&this.#r.get()===r?[n,r]:(this.#se.set(n),this.#r.set(r),this.#le(n,r))}#le(e,t){this.#oe=!1;let n=e;if(e&&"object"==typeof e){let r=Array.isArray(e)?[...e]:{...e},s=Array.isArray(e)?Array.isArray(t)?[...t]:[]:{...t},i=!1;for(const[n,o]of this){const l=e[n],a=t?.[n],[c,u]=o.#ce(l,a);l!==c&&(r[n]=c,i=!0),a!==u&&(s[n]=u,i=!0)}i&&(t=s,n=e=r,this.#se.set(e),this.#r.set(s))}return this.#ne||(this.#ne=!0,this.#re.set(n)),[e,t]}validate(e){if(!Array.isArray(e))return Promise.all([this.#K.get(),this.#H(),this.#Y()]).then((e=>{const t=e.flat();return t.length?t:null}));const t=[this.validate().then((t=>t?.length?[{path:[...e],store:this,errors:t}]:[]))];for(const[n,r]of this)t.push(r.validate([...e,n]));return Promise.all(t).then((e=>e.flat()))}}class G extends F{get kind(){return"object"}#ue;*[Symbol.iterator](){yield*Object.entries(this.#ue)}child(e){return this.#ue[e]||null}constructor(e,{parent:t,index:n,new:r,onUpdate:s,onUpdateState:i}={}){const o=Object.entries(e.type);super(e,{parent:t,index:n,new:r,onUpdate:s,onUpdateState:i,length:o.length,setValue:e=>"object"==typeof e?e:null,setState:e=>"object"==typeof e?e:null,convert:(e,t)=>["object"==typeof e?e:{},"object"==typeof t?t:{}]});const l=Object.create(null),a={parent:this,onUpdate:(e,t,n)=>{n===this.#ue[t]&&(this.value={...this.value,[t]:e})},onUpdateState:(e,t,n)=>{n===this.#ue[t]&&(this.state={...this.state,[t]:e})}};for(const[e,t]of o)l[e]=H(t,{...a,index:e});this.#ue=l}}W=G;class Q extends F{#fe=()=>{throw new Error};#ue;get children(){return[...this.#ue.get()]}*[Symbol.iterator](){return yield*[...this.#ue.get().entries()]}child(e){const t=this.#ue.get();return"number"==typeof e&&e<0?t[t.length+e]||null:t[Number(e)]||null}get kind(){return"array"}constructor(t,{parent:n,onUpdate:r,onUpdateState:s,index:i,new:o}={}){const l=new e.Signal.State([]),a=e=>{const t=Array.isArray(e)&&e.length||0,n=[...l.get()],r=n.length;for(let e=n.length;e<t;e++)n.push(this.#fe(e));r!==t&&l.set(n)};super(t,{index:i,new:o,parent:n,length:new e.Signal.Computed((()=>l.get().length)),state:[],setValue:e=>Array.isArray(e)?e:null==e?null:[e],setState:e=>Array.isArray(e)?e:null==e?null:[e],convert(e,t){const n=Array.isArray(e)?e:null==e?null:[e];return a(n),[n,Array.isArray(t)?t:null==e?[]:[t]]},onUpdate:(e,t,n)=>{a(e),r?.(e,t,n)},onUpdateState:s}),this.#ue=l;const c={parent:this,onUpdate:(e,t,n)=>{if(l.get()[t]!==n)return;const r=[...this.value||[]];r.length<t&&(r.length=t),r[t]=e,this.value=r},onUpdateState:(e,t,n)=>{if(l.get()[t]!==n)return;const r=[...this.state||[]];r.length<t&&(r.length=t),r[t]=e,this.state=r}};this.#fe=(e,n)=>{const r=H(t,{...c,index:e,new:n});return r.index=e,r}}insert(e,t=null,n){const r=this.value||[];if(!Array.isArray(r))return!1;const s=[...this.#ue.get()],i=Math.max(0,Math.min(Math.floor(e),s.length)),o=this.#fe(i,n);o.new=!0,s.splice(i,0,o);for(let t=e+1;t<s.length;t++)s[t].index=t;const l=[...r];l.splice(i,0,t);const a=this.state;if(Array.isArray(a)){const e=[...a];e.splice(i,0,{}),this.state=e}return this.#ue.set(s),this.value=l,!0}add(e=null){return this.insert(this.#ue.get().length,e)}remove(e){const t=this.value;if(!Array.isArray(t))return;const n=[...this.#ue.get()],r=Math.max(0,Math.min(Math.floor(e),n.length)),[s]=n.splice(r,1);if(!s)return;for(let t=e;t<n.length;t++)n[t].index=t;const i=[...t],[o]=i.splice(r,1),l=this.state;if(Array.isArray(l)){const e=[...this.state];e.splice(r,1),this.state=e}return this.#ue.set(n),this.value=i,o}move(e,t){const n=this.value;if(!Array.isArray(n))return!1;const r=[...this.#ue.get()],[s]=r.splice(e,1);if(!s)return!1;r.splice(t,0,s);let i=Math.min(e,t),o=Math.max(e,t);for(let e=i;e<=o;e++)r[e].index=e;const l=[...n],[a]=l.splice(e,1);l.splice(t,0,a);const c=this.state;if(Array.isArray(c)){const n=[...c],[r={}]=n.splice(e,1);t<=n.length?n.splice(t,0,r):n[t]=r,this.state=n}return this.#ue.set(r),this.value=l,!0}exchange(e,t){const n=this.value;if(!Array.isArray(n))return!1;const r=[...this.#ue.get()],s=r[e],i=r[t];if(!s||!i)return!1;r[t]=s,r[e]=i,s.index=t,i.index=e;const o=[...n],l=o[e],a=o[t];o[t]=l,o[e]=a;const c=this.state;if(Array.isArray(c)){const n=[...c],r=n[e],s=n[t];n[t]=r,n[e]=s,this.state=n}return this.#ue.set(r),this.value=o,!0}}!function(e){_=e}(Q);const Z={CALC:"no `createCalc` option, no expression parsing support",EVENT:"no `createEvent`, options, no event parsing support",CLOSE:(e,t)=>`end tag name: ${e} is not match the current start tagName: ${t}`,UNCLOSE:e=>`end tag name: ${e} maybe not complete`,QUOTE:e=>`attribute value no end '${e}' match`,CLOSE_SYMBOL:"elements closed character '/' and '>' must be connected to",UNCOMPLETED:(e,t)=>t?`end tag name: ${e} is not complete: ${t}`:`end tag name: ${e} maybe not complete`,ENTITY:e=>`entity not found: ${e}`,SYMBOL:e=>`unexpected symbol: ${e}`,TAG:e=>`invalid tagName: ${e}`,ATTR:e=>`invalid attribute: ${e}`,EQUAL:"attribute equal must after attrName",ATTR_VALUE:'attribute value must after "="',EOF:"unexpected end of file"};class X extends Error{constructor(e,...t){const n=Z[e];super("function"==typeof n?n(...t):n),this.code=e}}const J=/^(?<decorator>[:@!+*\.?]|style:|样式:)?(?<name>-?[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_:\d\.]*)$/u,ee=/^(?<name>[a-zA-Z$\p{Unified_Ideograph}_][\da-zA-Z$\p{Unified_Ideograph}_]*)?$/u;function te(e,t,n){const{attrs:r,directives:s,events:i,classes:o,styles:l,vars:a,aliases:c,params:u}=e;return function(e,f){const d=J.exec(e.replace(/./g,".").replace(/:/g,":").replace(/@/g,"@").replace(/+/g,"+").replace(/-/g,"-").replace(/[*×]/g,"*").replace(/!/g,"!"))?.groups;if(!d)throw new X("ATTR",e);const{name:h}=d,p=d.decorator?.toLowerCase();if(p){if(":"===p)r[h]=ee.test(f)?{name:f}:t(f);else if("."===p)o[h]=!f||(ee.test(f)?f:t(f));else if("style:"===p)l[h]=ee.test(f)?f:t(f);else if("@"===p)i[h]=ee.test(f)?f:n(f);else if("+"===p)a[h]=f?ee.test(f)?f:t(f):"";else if("*"===p)c[h]=ee.test(f)?f:t(f);else if("?"===p)u[h]=ee.test(f)?f:t(f);else if("!"===p){const e=h.toString();switch(e){case"fragment":s.fragment=f||!0;break;case"else":s.else=!0;break;case"enum":s.enum=!f||(ee.test(f)?f:t(f));break;case"if":case"text":case"html":s[e]=ee.test(f)?f:t(f);break;case"template":s.template=f;break;case"bind":s.bind=f||!0;break;case"value":s.value=f;break;case"comment":s.comment=f}}}else r[h]=f}}function ne(e,t){return{name:e,is:t,children:[],attrs:Object.create(null),events:Object.create(null),directives:Object.create(null),classes:Object.create(null),styles:Object.create(null),vars:Object.create(null),aliases:Object.create(null),params:Object.create(null)}}var re={lt:"<",gt:">",amp:"&",quot:'"',apos:"'",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",times:"×",divide:"÷",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",euro:"€",trade:"™",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"};const se=/^(?<name>[\w\p{Unified_Ideograph}_][-\.\|:|d\w\p{Unified_Ideograph}_:]*)(?:|(?<is>[\w\p{Unified_Ideograph}_][-\.\|:|d\w\p{Unified_Ideograph}_]*))?$/u;function ie(e){return"="!==e&&"/"!==e&&">"!==e&&e&&"'"!==e&&'"'!==e&&!function(e){return"0x80"===e||e<=" "}(e)}function oe(e,t,n,r){let s=r[n];return null==s&&(s=e.lastIndexOf("</"+n+">"),s<t&&(s=e.lastIndexOf("</"+n)),r[n]=s),s<t}function le(...e){console.error(new X(...e))}function ae(e){const t=e.slice(1,-1);return"#"===t.charAt(0)?String.fromCodePoint(parseInt(t.substring(1).replace("x","0x"))):t in re?re[t]:(le("ENTITY",e),e)}function ce(e){return("<"==e?"&lt;":">"==e&&"&gt;")||"&"==e&&"&amp;"||'"'==e&&"&quot;"||"&#"+e.charCodeAt()+";"}function*ue(e,t=0){const{attrs:n,events:r,directives:s,children:i,is:o,name:l,params:a,classes:c,styles:u,aliases:f,vars:d}=e,h=t>0?"".padEnd(t,"\t"):"";yield h,yield*["<",l||"-"],o&&(yield*["|",o]);for(const[e,t]of Object.entries(a)){if(null==t)continue;const n="function"==typeof t?String(t):t;yield*[" ?",e],n&&"string"==typeof n&&(yield*['="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(s)){if(!1===t||null==t)continue;const n="function"==typeof t?String(t):t;yield*[" !",e],n&&"string"==typeof n&&(yield*['="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(f)){if(null==t)continue;const n="function"==typeof t?String(t):t;yield*[" *",e],n&&"string"==typeof n&&(yield*['="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(d)){if(null==t)continue;const n="function"==typeof t?String(t):t;yield*[" +",e],n&&"string"==typeof n&&(yield*['="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(n)){if(null==t)continue;if("string"==typeof t){yield*[" ",e],t&&(yield*['="',t.replace(/[<&"]/g,ce),'"']);continue}const n="function"==typeof t?String(t):"object"==typeof t?t.name:t;n&&"string"==typeof n&&(yield*[" :",e,'="',n.replace(/[<&"]/g,ce)||"",'"'])}for(const[e,t]of Object.entries(r)){if(null==t)continue;const n="function"==typeof t?String(t):t;n&&"string"==typeof n&&(yield*[" @",e,'="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(c)){if(null==t||0==t)continue;const n="function"==typeof t?String(t):t;yield*[" .",e],n&&"string"==typeof n&&(yield*[" .",e,'="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(u)){if(null==t)continue;const n="function"==typeof t?String(t):t;n&&"string"==typeof n&&(yield*[" style:",e,'="',n.replace(/[<&"]/g,ce),'"'])}if(!i.length)return yield"/>",void(t>=0&&(yield"\n"));if(1===i.length){const[e]=i;if("string"==typeof e&&e.length<80&&!e.includes("\n"))return yield">",yield*[e.replace(/[<&\t]/g,ce).replace(/]]>/g,"]]&gt;")],yield*["</",l,">"],void(t>=0&&(yield"\n"))}yield">",t>=0&&(yield"\n"),yield*fe(i,t>=0?t+1:-1),yield*[h,"</",l,">"],t>=0&&(yield"\n")}function*fe(e,t=0){if(!e.length)return"";const n=t>0?"".padEnd(t,"\t"):"";for(const r of e)if("string"==typeof r){let e=r.replace(/[<&\t]/g,ce).replace(/]]>/g,"]]&gt;");n&&(e=e.replace(/(?<=^|\n)/g,n)),yield e,t>=0&&(yield"\n")}else yield*ue(r,t)}var de=Object.freeze({__proto__:null,parse:function(e,{createCalc:t=()=>{throw new X("CALC")},createEvent:n=()=>{throw new X("EVENT")},simpleTag:r=new Set}={}){const s=[],i={children:s},o=[];let l=null,a=i;function c(){l=o.pop()||null,a=l||i}function u(e){(e=e.replace(/^\n|(?<=\n)\t+|\n\t*$/g,""))&&a.children.push(e)}let f={},d=0;function h(t){if(t<=d)return;u(e.substring(d,t).replace(/&#?\w+;/g,ae)),d=t}for(;;){const p=e.indexOf("<",d);if(p<0){const E=e.substring(d);E.match(/^\s*$/)||u(E);break}if(p>d&&h(p),"/"===e.charAt(p+1)){d=e.indexOf(">",p+3);let C=e.substring(p+2,d);if(d<0?(C=e.substring(p+2).replace(/[\s<].*/,""),le("UNCOMPLETED",C,l?.name),d=p+1+C.length):C.match(/\s</)&&(C=C.replace(/[\s<].*/,""),le("UNCOMPLETED",C),d=p+1+C.length),l){const A=l.name;if(A===C)c();else{if(A.toLowerCase()!=C.toLowerCase())throw new X("CLOSE",C,l.name);c()}}d++;continue}function g(t){let n=d+1;if(d=e.indexOf(t,n),d<0)throw new X("QUOTE",t);const r=e.slice(n,d).replace(/&#?\w+;/g,ae);return d++,r}function m(){let t=e.charAt(d);for(;t<=" "||"€"===t;t=e.charAt(++d));return t}function b(){let t=d,n=e.charAt(d);for(;ie(n);)d++,n=e.charAt(d);return e.slice(t,d)}d=p+1;let y=e.charAt(d);switch(y){case"=":throw new X("EQUAL");case'"':case"'":throw new X("ATTR_VALUE");case">":case"/":throw new X("SYMBOL",y);case"":throw new X("EOF")}const v=b(),w=se.exec(v)?.groups;if(!w)throw new X("TAG",v);o.push(l),l=ne(w.name,w.is),a.children.push(l),a=l;const x=te(l,t,n);let S=!0,O=!1;e:for(;S;){let $=m();switch($){case"":le("EOF"),d++;break e;case">":d++;break e;case"/":O=!0;break e;case'"':case"'":throw new X("ATTR_VALUE");case"=":throw new X("SYMBOL",$)}const j=b();if(!j){le("EOF"),d++;break e}switch($=m(),$){case"":le("EOF"),d++;break e;case">":x(j,""),d++;break e;case"/":x(j,""),O=!0;break e;case"=":d++;break;case"'":case'"':x(j,g($));continue;default:x(j,"");continue}switch($=m(),$){case"":x(j,""),le("EOF"),d++;break e;case">":x(j,""),d++;break e;case"/":x(j,""),O=!0;break e;case"'":case'"':x(j,g($));continue}x(j,b())}if(O){for(;;){d++;const L=e.charAt(d);if("/"!==L&&!(L<=" "||"€"===L))break}switch(e.charAt(d)){case"=":throw new X("EQUAL");case'"':case"'":throw new X("ATTR_VALUE");case"":le("EOF");break;case">":d++;break;default:throw new X("CLOSE_SYMBOL")}c()}else(r.has(v)||oe(e,d,v,f))&&c()}return s},stringify:function(e,t){const n=t?0:-1;return Array.isArray(e)?[...fe(e,n)].join(""):[ue(e,n)].join()}});function he(t){let n=!0;const r=new e.Signal.subtle.Watcher((()=>{n&&(n=!1,queueMicrotask((()=>{n=!0;for(const e of r.getPending())e.get();r.watch()})))})),s=new e.Signal.Computed(t);return r.watch(s),s.get(),()=>{r.unwatch(s)}}function pe(e,t,n){let r,s=!1;return he((()=>{const i=e();if(!s)return s=!0,r=i,void(n&&t(i));Object.is(i,r)||(r=i,t(i))}))}const ge=new Set(Object.keys({type:!0,meta:!0,component:!0,kind:!0,value:!0,state:!0,store:!0,parent:!0,root:!0,ref:!0,schema:!0,new:!0,readonly:!0,creatable:!0,immutable:!0,changed:!0,required:!0,clearable:!0,hidden:!0,disabled:!0,label:!0,description:!0,placeholder:!0,min:!0,max:!0,step:!0,minLength:!0,maxLength:!0,pattern:!0,values:!0,null:!0,index:!0,no:!0,length:!0,error:!0,errors:!0}));function*me(e,t="",n="$"){yield[`${t}`,{get:()=>e.value,set:t=>e.value=t,store:e}];for(const r of ge)yield[`${t}${n}${r}`,{get:()=>e[r]}];yield[`${t}${n}value`,{get:()=>e.value,set:t=>e.value=t}],yield[`${t}${n}state`,{get:()=>e.state,set:t=>e.state=t}],yield[`${t}${n}reset`,{exec:()=>e.reset()}],yield[`${t}${n}validate`,{exec:t=>e.validate(t?[]:null)}],e instanceof Q&&(yield[`${t}${n}insert`,{exec:(t,n)=>e.insert(t,n)}],yield[`${t}${n}add`,{exec:t=>e.add(t)}],yield[`${t}${n}remove`,{exec:t=>e.remove(t)}],yield[`${t}${n}move`,{exec:(t,n)=>e.move(t,n)}],yield[`${t}${n}exchange`,{exec:(t,n)=>e.exchange(t,n)}])}function be(e,t,n){for(const[n,r]of t){for(const[t,s]of me(r,n))e[t]=s;for(const[t,s]of me(r,n,"$$"))e[t]=s}}const ye={value$:{calc:e=>e?.[V].value},state$:{calc:e=>e?.[V].state}};var ve=Object.getOwnPropertyDescriptors(ye);function we(e){if(!e)return!1;const t=e.indexOf("$");return t<0||(e.indexOf("$",t+2)>0||"$"===e[0]&&"_$".includes(e[1]))}function xe(e,t){Object.defineProperty(t,"$store",{value:e,writable:!1,configurable:!0,enumerable:!1}),Object.defineProperty(t,"$root",{value:e.root,writable:!1,configurable:!0,enumerable:!1})}class Se{exec(e){if("string"==typeof e){const t=this.#de[e];if("function"!=typeof t?.get)return;return t.get()}if("function"==typeof e)return e(this.getters)}watch(e,t){return pe((()=>this.exec(e)),t,!0)}enum(e){if(!e)return!0;if(!0===e)return this.store;if("function"==typeof e)return()=>e(this.getters);if("string"!=typeof e)return null;const t=this.#de[e];if("function"!=typeof t?.get)return null;const n=t.store;return n instanceof F?n:t.get}getStore(e){if(!e)return null;const t=this.#de[!0===e?"":e];return t?.get&&t.store||null}bind(e,t,n){const r=this.#de[!0===e?"":e];if(!r?.get)return;const{store:s}=r;return s?ge.has(t)?pe((()=>s[t]),n,!0):void 0:"value"===t?pe((()=>r.get()),n,!0):void 0}bindAll(e){const t=this.#de[!0===e?"":e];if(!t?.get)return;const{store:n}=t;if(!n){const e=t.get;if("function"!=typeof e)return;return{$value:t=>pe(e,t,!0)}}return Object.fromEntries([...ge].map((e=>[`$${e}`,t=>pe((()=>n[e]),t,!0)])))}bindSet(e,t){const n=this.#de[!0===e?"":e];if(!n?.get)return;const{store:r}=n;if(r)switch(t){case"value":return e=>{r.value=e};case"state":return e=>{r.state=e}}}bindEvents(e){const t=this.#de[!0===e?"":e];if(!t?.get)return;const{store:n}=t;if(!n){const e=t.set;if("function"!=typeof e)return;return{$value:e}}return{$value:e=>{n.value=e},$state:e=>{n.state=e},$input:e=>{n.emit("input",e)},$change:e=>{n.emit("change",e)},$click:e=>{n.emit("click",e)},$focus:e=>{n.emit("focus",e)},$blur:e=>{n.emit("blur",e)},$reset:e=>{n.reset()},$validate:e=>{n.validate(e?[]:null)}}}getEvent(e){if("function"==typeof e)return e;const t=this.#de[e];if(!t)return null;const{exec:n,calc:r}=t;return"function"==typeof n?n:"function"==typeof r?r:null}constructor(e,t){if(this.store=e,t instanceof Se){this.#he=t.#he;const e=this.#pe;for(const[n,r]of Object.entries(t.#pe))e[n]=r;const n=this.#ge;for(const[e,r]of Object.entries(t.#ge))n[e]=r}else be(this.#pe,e),this.#he=function(e){const t=Object.create(null,ve);if(!e||"object"!=typeof e)return t;for(const[n,r]of Object.entries(e)){if(!we(n))continue;if(!r||"object"!=typeof r)continue;if(r instanceof F){for(const[e,s]of me(r,n))t[e]=s;continue}const{get:e,set:s,exec:i,calc:o}=r;"function"!=typeof e?"function"!=typeof o?"function"!=typeof i||(t[n]={exec:i}):t[n]={calc:o}:t[n]="function"==typeof s?{get:e,set:s}:{get:e}}return t}(t)}#he;#pe=Object.create(null);#ge=Object.create(null);store;#me=null;#s=null;#be=null;get#de(){const e=this.#be;if(e)return e;const t=Object.create(null,Object.getOwnPropertyDescriptors({...this.#pe,...this.#he,...this.#ge})),n=this.store,r=this.#s,s=this.#me;if(s)for(const e of Object.keys(s))t[`$${e}`]={get:()=>s[e]};else{for(const[e,r]of me(n))t[e]=r;for(const[e,s]of function*(e,t,n="",r="$"){if(!(e instanceof Q))return yield[`${n}${r}upMovable`,{get:()=>!1}],void(yield[`${n}${r}downMovable`,{get:()=>!1}]);yield[`${n}${r}upMovable`,{get:()=>{const e=t.index;return"number"==typeof e&&!(e<=0)}}],yield[`${n}${r}downMovable`,{get:()=>{const n=t.index;return"number"==typeof n&&!(n>=e.length-1)}}],yield[`${n}${r}remove`,{exec:()=>e.remove(Number(t.index))}],yield[`${n}${r}upMove`,{exec:()=>{const n=t.index;"number"==typeof n&&(n<=0||e.move(n,n-1))}}],yield[`${n}${r}downMove`,{exec:()=>{const n=t.index;"number"==typeof n&&(n>=e.length-1||e.move(n,n+1))}}]}(r,n))t[e]=s}return this.#be=t,t}setStore(e,t){const n=new Se(e,this);return t&&(n.#s=t),be(n.#pe,e),n}child(e){if(!e)return this;const t=this.store.child(e);if(!t)return null;const n=new Se(t,this);return be(n.#pe,t),n}params({params:t},{attrs:n},r,s){let i=this.store;if(!0===s)i=r.store;else if(s){const e=r.#de[s],t=e?.get&&e.store;t&&(i=t)}if(0===Object.keys(t).length)return this;const o=new Se(i,this);o.#s=this.#s,o.#me=this.#me;const l=o.#ge,a=o.#de;for(const[s,i]of Object.entries(t)){const t=s in n?n[s]:null;if("string"!=typeof t){if(t&&"object"==typeof t){const e=r.#de[t.name];if(!e?.get)continue;if(!e.store){l[s]=a[s]=e;continue}for(const[t,n]of me(e.store,s))l[t]=a[t]=n;continue}if("function"==typeof t){const n=new e.Signal.Computed((()=>t(r.getters)));l[s]=a[s]={get:()=>n.get()};continue}if("function"==typeof i){const t=o.getters;o.#ye=null;const n=new e.Signal.Computed((()=>i(t)));l[s]=a[s]={get:()=>n.get()};continue}{const e=a[i];if(!e?.get)continue;if(!e.store){l[s]=a[s]=e;continue}for(const[t,n]of me(e.store,s))l[t]=a[t]=n;continue}}l[s]=a[s]={get:()=>t}}return o}setObject(e){const t=new Se(this.store,this);return t.#me=e,t}set(t,n){if(Object.keys(t).length+Object.keys(n).length===0)return this;const r=new Se(this.store,this);r.#s=this.#s,r.#me=this.#me;const s=r.#ge,i=r.#de;for(const[n,o]of Object.entries(t)){if("function"==typeof o){const t=r.getters;r.#ye=null;const l=new e.Signal.Computed((()=>o(t)));s[n]=i[n]={get:()=>l.get()};continue}const t=i[o];if(t)if(t.get&&t.store)for(const[e,r]of me(t.store,n))s[e]=i[e]=r;else s[n]=i[n]=t}for(const[t,o]of Object.entries(n)){const n=new e.Signal.State(null);if("function"==typeof o){const e=r.settable;r.#ve=null,n.set(o(e))}else if(o&&"string"==typeof o){const e=i[o];if(!e?.get)continue;n.set(e.get())}s[t]=i[t]={get:()=>n.get(),set:e=>{n.set(e)}}}return r}#we=null;get all(){const e=this.#we;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#de))n.get?Object.defineProperty(t,e,{get:n.get,set:n.set,configurable:!0,enumerable:!0}):n.calc?Object.defineProperty(t,e,{value:n.calc,writable:!1,configurable:!0,enumerable:!1}):Object.defineProperty(t,e,{value:n.exec,writable:!1,configurable:!0,enumerable:!1});return xe(this.store,t),this.#we=t,t}#ve=null;get settable(){const e=this.#ve;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#de))n.get?Object.defineProperty(t,e,{get:n.get,set:n.set,configurable:!0,enumerable:!0}):n.calc&&Object.defineProperty(t,e,{value:n.calc,writable:!1,configurable:!0,enumerable:!1});return xe(this.store,t),this.#ve=t,t}#ye=null;get getters(){const e=this.#ye;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#de))n.get?Object.defineProperty(t,e,{get:n.get,configurable:!0,enumerable:!0}):n.calc&&Object.defineProperty(t,e,{value:n.calc,writable:!1,configurable:!0,enumerable:!1});return xe(this.store,t),this.#ye=t,t}}const Oe={width:"px",height:"px",top:"px",right:"px",bottom:"px",left:"px",border:"px","border-top":"px","border-right":"px","border-left":"px","border-bottom":"px","border-width":"px","border-top-width":"px","border-right-width":"px","border-left-width":"px","border-bottom-width":"px","border-radius":"px","border-top-left-radius":"px","border-top-right-radius":"px","border-bottom-left-radius":"px","border-bottom-right-radius":"px",padding:"px","padding-top":"px","padding-right":"px","padding-left":"px","padding-bottom":"px",margin:"px","margin-top":"px","margin-right":"px","margin-left":"px","margin-bottom":"px"};function Ee(e,t){let n=!!Array.isArray(t)&&Boolean(t[1]),r="";if("string"==typeof t)return r=t.replace(/!important\s*$/,""),r?(n=r!==t,[r,n?"important":void 0]):null;const s=Array.isArray(t)?t[0]:t;return"number"==typeof s||"bigint"==typeof s?r=s&&e in Oe?`${s}${Oe[e]}`:`${s}`:"string"==typeof s&&(r=s),r?[r,n?"important":void 0]:null}class Ce{#e=new Map;emit(e,...t){const n="number"==typeof e?String(e):e,r=this.#e;for(const e of[...r.get(n)||[]])e(...t)}listen(e,t){const n=t.bind(this),r=this.#e,s="number"==typeof e?String(e):e;let i=r.get(s);return i||(i=new Set,r.set(s,i)),i.add(n),()=>{i?.delete(n)}}}const Ae={stop(e){e instanceof Event&&e.stopPropagation()},prevent(e){e instanceof Event&&e.preventDefault()},self(e){if(e instanceof Event)return e.target===e.currentTarget},enter(e){if(e instanceof KeyboardEvent)return"Enter"===e.key},tab(e){if(e instanceof KeyboardEvent)return"Tab"===e.key},esc(e){if(e instanceof KeyboardEvent)return"Escape"===e.key},space(e){if(e instanceof KeyboardEvent)return" "===e.key},backspace(e){if(e instanceof KeyboardEvent)return"Backspace"===e.key},delete(e){if(e instanceof KeyboardEvent)return"Delete"===e.key},delBack(e){if(e instanceof KeyboardEvent)return"Delete"===e.key||"Backspace"===e.key},"del-back"(e){if(e instanceof KeyboardEvent)return"Delete"===e.key||"Backspace"===e.key},insert(e){if(e instanceof KeyboardEvent)return"Insert"===e.key},repeat(e){if(e instanceof KeyboardEvent)return e.repeat},key(e,t){if(e instanceof KeyboardEvent){const n=e.code.toLowerCase().replace(/-/g,"");for(const e of t)if(n===e.toLowerCase().replace(/-/g,""))return!0;return!1}},main(e){if(e instanceof MouseEvent)return 0===e.button},auxiliary(e){if(e instanceof MouseEvent)return 1===e.button},secondary(e){if(e instanceof MouseEvent)return 2===e.button},left(e){if(e instanceof MouseEvent)return 0===e.button},middle(e){if(e instanceof MouseEvent)return 1===e.button},right(e){if(e instanceof MouseEvent)return 2===e.button},primary(e){if(e instanceof PointerEvent)return e.isPrimary},mouse(e){if(e instanceof PointerEvent)return"mouse"===e.pointerType},pen(e){if(e instanceof PointerEvent)return"pen"===e.pointerType},touch(e){if(e instanceof PointerEvent)return"touch"===e.pointerType},pointer(e,t){if(e instanceof PointerEvent){const n=e.pointerType.toLowerCase().replace(/-/g,"");for(const e of t)if(n===e.toLowerCase().replace(/-/g,""))return!0;return!1}},ctrl(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.ctrlKey},alt(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.altKey},shift(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.shiftKey},meta(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.metaKey},cmd(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.ctrlKey||e.metaKey}};function $e(e){return"number"==typeof e||"bigint"==typeof e?String(e):"boolean"==typeof e?e?"":null:"string"==typeof e?e:null===(e??null)?null:String(e)}function je(e){return null===(e??null)?"":String(e)}function Le(e,t){if(e instanceof HTMLInputElement&&"checked"===t)switch(e.type.toLowerCase()){case"checkbox":case"radio":return Boolean}if((e instanceof HTMLSelectElement||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&"value"===t)return je;if(e instanceof HTMLDetailsElement&&"open"===t)return Boolean;if(e instanceof HTMLMediaElement){if("muted"===t)return Boolean;if("paused"===t)return Boolean;if("currentTime"===t)return!0;if("playbackRate"===t)return!0;if("volume"===t)return!0}return!1}const Te={input:{attrs:{$min:(e,t)=>{t.min=e},$max:(e,t)=>{t.max=e},$step:(e,t)=>{t.step=e},$placeholder:(e,t)=>{t.placeholder=e},$disabled:(e,t)=>{t.disabled=e},$readonly:(e,t)=>{t.readOnly=e},$required:(e,t)=>{t.required=e},$value:(e,t)=>{switch(t.type){case"checkbox":case"radio":t.checked=Boolean(e)}t.value=je(e)}},events:{$value:["input",(e,t)=>{switch(t.type){case"checkbox":case"radio":return t.checked;case"number":return Number(t.value)}return t.value}]}},textarea:{attrs:{$placeholder:(e,t)=>{t.placeholder=e},$disabled:(e,t)=>{t.disabled=e},$readonly:(e,t)=>{t.readOnly=e},$required:(e,t)=>{t.required=e},$value:(e,t)=>{t.value=je(e)}},events:{$value:["input",(e,t)=>t.value]}},select:{attrs:{$disabled:(e,t)=>{t.disabled=e},$required:(e,t)=>{t.required=e},$value:(e,t)=>{t.value=je(e)}},events:{$value:["change",(e,t)=>t.value]}}};function Me(e,t,n){const r=document.createElement(t,{is:n||void 0}),{watchAttr:s,props:i}=e;return["input","textarea","select"].includes(t.toLowerCase())&&e.relate(r),e.listen("init",(({events:n})=>{const o=Te[t.toLowerCase()],l=o?.attrs||{},a=o?.events||{};for(const[e,t,s]of n)if("$"!==e[0])r.addEventListener(e,t,s);else{const n=a[e];if(n){const[e,i]=n;r.addEventListener(e,(e=>t(i(e,r))),s)}}if(i)for(const[t,n]of Object.entries(e.tagAttrs))if(s(t,(e=>{if(i.has(t))r[t]=e;else{const n=$e(e);null==n?r.removeAttribute(t):r.setAttribute(t,n)}})),i.has(t))r[t]=n;else{const e=$e(n);null!==e&&r.setAttribute(t,e)}else for(const[t,n]of Object.entries(e.tagAttrs)){if(r instanceof HTMLInputElement&&"type"===t.toLocaleLowerCase()){const e=$e(n);null!==e&&r.setAttribute(t,e);continue}if("$hidden"===t){n&&(r.hidden=n),s(t,(e=>{r.hidden=e}));continue}if("$"===t[0]){const e=l[t];e&&(e(n,r),s(t,(t=>e(t,r))));continue}const e=Le(r,t);if("function"==typeof e){r[t]=e(n),s(t,(n=>{r[t]=e(n)}));continue}if(e){r[t]=n,s(t,(e=>{r[t]=e}));continue}let i=$e(n);null!==i&&r.setAttribute(t,i),s(t,(e=>{const n=$e(e);null===n?r.removeAttribute(t):r.setAttribute(t,n)}))}})),r}function Ne(e){return null===(e??null)?"":String(e)}function ke(e,t,n,{text:r,html:s}){if(null!=r){const s=e.insertBefore(document.createTextNode(""),t),i=n.watch(r,(e=>s.textContent=Ne(e)));return()=>{s.remove(),i()}}if(null==s)return;const i=e.insertBefore(document.createComment(""),t),o=e.insertBefore(document.createComment(""),t),l=document.createElement("div");function a(){for(let e=i.nextSibling;e&&e!==o;e=i.nextSibling)e.remove()}const c=n.watch(s,(t=>{a(),function(t){l.innerHTML=t;for(let t=l.firstChild;t;t=i.firstChild)e.insertBefore(t,o)}(Ne(t))}));return()=>{c(),a(),i.remove(),o.remove()}}function Ie(e,t,n,r,s,i){let o=new Set,l=[],a=Object.create(s);for(const t of e){if("string"==typeof t)continue;const e=t.directives.template;e&&(a[e]=[t,r])}function c(e){if(!e.length||!o)return;const s=t.insertBefore(document.createComment(""),n);let l=-1,c=()=>{};o.add((()=>{c(),c=()=>{},s.remove()})),o.add(pe((()=>e.findIndex((([e])=>null===e||r.exec(e)))),(t=>{t!==l&&(l=t,c(),c=()=>{},function(t){const n=e[t]?.[1];n&&(c=i(n,a))}(l))}),!0))}for(const r of e){if("string"==typeof r){c(l),l=[];const e=document.createTextNode(r);t.insertBefore(e,n),o.add((()=>e.remove()));continue}if(r.directives.template){c(l),l=[];continue}if(l.length&&r.directives.else){const e=r.directives.if||null;l.push([e,r]),e||(c(l),l=[]);continue}c(l),l=[];const e=r.directives.if;e?l.push([e,r]):o.add(i(r,a))}return()=>{if(!o)return;const e=o;o=null;for(const t of e)t()}}function Pe(t,n,r,s,i,o,l,a){s=s.set(t.aliases,t.vars);const c=t.directives.bind,u=t.directives.fragment;if(u&&"string"==typeof u){const e=i[u];if(!e)return()=>{};const[f,d]=e,h=d.params(f,t,s,c);return Ue(f,n,r,h,i,o,l,a)}if(!t.name||t.directives.fragment)return ke(n,r,s,t.directives)||Ie(t.children||[],n,r,s,i,((e,t)=>Ue(e,n,r,s,t,o,l,a)));const f=[...o,t.name],d=a?.(f);if(a&&!d)return()=>{};const{context:h,handler:p}=function(t,n,r,s){const i="string"==typeof t?t:t.tag,{attrs:o,events:l}="string"!=typeof t&&t||{attrs:null,events:null};let a=!1;const c=new e.Signal.State(!1);let u=!1;const f=new e.Signal.State(!1),d=Object.create(null),h=Object.create(null),p=new Set,g=[],m=new Ce;return{context:{events:g,props:o?new Set(Object.entries(o).filter((([,e])=>e.isProp)).map((([e])=>e))):null,tagAttrs:h,watchAttr(e,t){if(a)return()=>{};const n=d[e];if(!n)return()=>{};let r=n.get();const s=pe((()=>n.get()),(n=>{const s=r;r=n,t(n,s,e)}),!0);return p.add(s),()=>{p.delete(s),s()}},relate(e){if(!r||!s||a)return()=>{};try{const t=s(r,e);return"function"!=typeof t?()=>{}:(p.add(t),()=>{p.delete(t),t()})}catch{return()=>{}}},get destroyed(){return c.get()},get init(){return f.get()},listen:(e,t)=>m.listen(e,t)},handler:{tag:i,set(t,n){if(o&&!(t in o))return;let r=d[t];if(r)return void r.set(n);const s=new e.Signal.State(n);d[t]=s,Object.defineProperty(h,t,{configurable:!0,enumerable:!0,get:s.get.bind(s)})},addEvent(e,t){if("function"!=typeof t)return;const[r,...s]=e.split(".").filter(Boolean),i=l?l[r].filters:{};if(!i)return;const o={},a=[];if(i)for(let e=s.shift();e;e=s.shift()){const t=e.indexOf(":"),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1).split(":"):[],s=n.replace(/^-+/,""),l=(n.length-s.length)%2==1;let c=i[s]||s;switch(c){case"once":o.once=!l;break;case"passive":o.passive=!l;break;case"capture":o.capture=!l;break;default:"string"==typeof c&&(c=Ae[c])}"function"==typeof c&&a.push([c,r,l])}g.push([r,e=>{const r=n.all;for(const[t,n,s]of a)if(t(e,n,r)===s)return;t(e,r)},o])},destroy(){if(!a){a=!0,c.set(!0);for(const e of p)e();m.emit("destroy")}},mount(){u||(u=!0,f.set(!0),m.emit("init",{events:g}))}}}}(d||t.name,s,s.getStore(c),l),g=d?.attrs,m=g?function(e,t,n,r,s){let i=new Set;for(const[o,l]of Object.entries(r)){const r=n[o];if(o in n){if("function"!=typeof r&&"object"!=typeof r){e.set(o,r);continue}const n="function"==typeof r?r:r.name;if(l.immutable){e.set(o,t.exec(n));continue}i.add(t.watch(n,(t=>e.set(o,t))));continue}const a=l.bind;if(!s||!a){e.set(o,l.default);continue}if("string"==typeof a){const n=t.bind(s,a,(t=>e.set(o,t)));n?i.add(n):e.set(o,l.default);continue}if(!Array.isArray(a)){e.set(o,l.default);continue}const[c,u,f]=a;if(!c||"function"!=typeof u)continue;if(!f){const n=!0===s?"":s;i.add(t.watch(n,(t=>e.set(o,t)))),e.addEvent(c,((...e)=>{t.all[n]=u(...e)}));continue}const d=t.bind(s,"state",(t=>e.set(o,t)));if(!d)continue;i.add(d);const h=t.bindSet(s,"state");h&&e.addEvent(c,((...e)=>{h(u(...e))}))}return()=>{const e=i;i=new Set;for(const t of e)t()}}(p,s,t.attrs,g,c):function(e,t,n){const r=e.tag;let s=new Set;for(const[i,o]of Object.entries(n)){if("function"!=typeof o&&"object"!=typeof o){e.set(i,o);continue}const n="function"==typeof o?o:o.name;if("string"!=typeof r||"input"!==r.toLocaleLowerCase()||"type"!==i.toLocaleLowerCase())s.add(t.watch(n,(t=>e.set(i,t))));else{const r=t.exec(n);e.set(i,r)}}return()=>{const e=s;s=new Set;for(const t of e)t()}}(p,s,t.attrs);for(const[e,n]of Object.entries(t.events)){const t=s.getEvent(n);t&&p.addEvent(e,t)}const b=function(e,t,n){if(!n)return()=>{};let r=new Set;for(const[s,i]of Object.entries(t.bindAll(n)||{}))"function"==typeof i&&r.add(i((t=>e.set(s,t))));for(const[r,s]of Object.entries(t.bindEvents(n)||{}))e.addEvent(r,(e=>s(e)));return()=>{const e=r;r=new Set;for(const t of e)t()}}(p,s,c),y=d?"function"==typeof d.tag?d.tag(h):Me(h,d.tag,d.is):Me(h,t.name,t.is),v=Array.isArray(y)?y[0]:y,w=Array.isArray(y)?y[1]:v;n.insertBefore(v,r);const x=w?ke(w,null,s,t.directives)||Ie(t.children||[],w,null,s,i,((e,t)=>Ue(e,w,null,s,t,o,l,a))):()=>{};return function(e,t,n){if(!(e instanceof Element))return()=>{};let r=new Set;for(const[s,i]of Object.entries(t))i&&(!0!==i?r.add(pe((()=>Boolean(n.exec(i))),(t=>{t?e.classList.add(s):e.classList.remove(s)}),!0)):e.classList.add(s))}(v,t.classes,s),function(e,t,n){if(!(e instanceof HTMLElement||e instanceof SVGElement))return()=>{};let r=new Set;for(const[s,i]of Object.entries(t))r.add(pe((()=>Ee(s,n.exec(i))),(t=>{t?e.style.setProperty(s,...t):e.style.removeProperty(s)}),!0))}(v,t.styles,s),p.mount(),()=>{v.remove(),p.destroy(),m(),x(),b()}}function Ue(t,n,r,s,i,o,l,a){const{directives:c}=t,u=s.child(c.value);if(!u)return()=>{};const f=u.enum(c.enum),d=(e,r)=>Pe(t,n,e,r,i,o,l,a);return!0===f?d(r,u):f instanceof Q?function(e,t,n,r,s){const i=e.insertBefore(document.createComment(""),t);let o=new Map;function l(e){for(const[t,n,r]of e.values())r(),t.remove(),n.remove()}const a=pe((()=>n.children),(function(t){if(!i.parentNode)return;let a=i.nextSibling;const c=o;o=new Map;for(let i of t){const t=c.get(i);if(!t){const t=e.insertBefore(document.createComment(""),a),l=e.insertBefore(document.createComment(""),a),c=s(l,r.setStore(i,n));o.set(i,[t,l,c]);continue}if(c.delete(i),o.set(i,t),a===t[0]){a=t[1].nextSibling;continue}let l=t[0];for(;l&&l!==t[1];){const t=l;l=l.nextSibling,e.insertBefore(t,a)}e.insertBefore(t[1],a)}l(c)}),!0);return()=>{i.remove(),l(o),a()}}(n,r,f,u,d):f instanceof G?function(e,t,n,r,s){const i=[];for(const[e,o]of[...n])i.push(s(t,r.setStore(o,n)));return()=>{for(const e of i)e()}}(0,r,f,u,d):"function"==typeof f?function(t,n,r,s,i){const o=new e.Signal.Computed((()=>{const e=r();if("number"==typeof e){const t=Math.floor(e);return t?Array(t).fill(0).map(((e,t)=>[t+1,t,t])):[]}return e&&"object"==typeof e?Array.isArray(e)?e.map(((e,t)=>[e,t,t])):Object.entries(e).map((([e,t],n)=>[t,n,e])):[]})),l=t.insertBefore(document.createComment(""),n);let a=[];function c(e){for(const[t,n,r]of e)r(),t.remove(),n.remove()}const u=pe((()=>o.get()),(function(n){if(!l.parentNode)return;let r=l.nextSibling;const o=a;a=[];for(const[l,c,u]of n){const n=o.findIndex((e=>e[3]===u)),[f]=n>=0?o.splice(n,1):[];if(!f){const n=t.insertBefore(document.createComment(""),r),o=t.insertBefore(document.createComment(""),r),f=new e.Signal.State(l),d=new e.Signal.State(c),h=i(o,s.setObject({get key(){return u},get value(){return f.get()},get index(){return d.get()}}));a.push([n,o,h,u,f,d]);continue}if(a.push(f),f[4].set(l),f[5].set(c),r===f[0]){r=f[1].nextSibling;continue}let d=f[0];for(;d&&d!==f[1];){const e=d;d=d.nextSibling,t.insertBefore(e,r)}t.insertBefore(f[1],r)}c(o)}),!0);return()=>{l.remove(),c(a),u()}}(n,r,f,u,d):()=>{}}e.Layout=de,e.Store=F,e.effect=he,e.render=function(e,t,n,{component:r,global:s,relate:i}={}){const o=new Se(e,s),l=Object.create(null),a="function"==typeof i?i:null;return Ie(t,n,null,o,l,((e,t)=>Ue(e,n,null,o,t,[],a,r)))},e.watch=pe}));
package/index.min.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @neeloong/form v0.8.0
2
+ * @neeloong/form v0.8.1
3
3
  * (c) 2024-2025 Fierflame
4
4
  * @license Apache-2.0
5
5
  */
@@ -57,4 +57,4 @@ function(){throw new Error};function $(){return d(this),this.value}function j(e,
57
57
  * Use of this source code is governed by an MIT-style license that can be
58
58
  * found in the LICENSE file at https://angular.io/license
59
59
  */
60
- function(e){const t=Object.create(L);t.value=e;const n=()=>(d(t),t.value);return n[c]=t,n}(n),l=i[c];if(this[T]=l,l.wrapper=this,s){const t=s.equals;t&&(l.equal=t),l.watched=s[e.subtle.watched],l.unwatched=s[e.subtle.unwatched]}}get(){if(!(0,e.isState)(this))throw new TypeError("Wrong receiver type for Signal.State.prototype.get");return $.call(this[T])}set(t){if(!(0,e.isState)(this))throw new TypeError("Wrong receiver type for Signal.State.prototype.set");if(l)throw new Error("Writes to signals not permitted during Watcher callback");j(this[T],t)}};h=T,p=new WeakSet,e.isComputed=e=>n(p,e),e.Computed=class{constructor(n,s){r(this,p),t(this,h);const o=function(e){const t=Object.create(C);t.computation=e;const n=()=>x(t);return n[c]=t,n}(n),i=o[c];if(i.consumerAllowSignalWrites=!0,this[T]=i,i.wrapper=this,s){const t=s.equals;t&&(i.equal=t),i.watched=s[e.subtle.watched],i.unwatched=s[e.subtle.unwatched]}}get(){if(!(0,e.isComputed)(this))throw new TypeError("Wrong receiver type for Signal.Computed.prototype.get");return x(this[T])}},(o=>{var l,a,c,h;o.untrack=function(e){let t,n=null;try{n=u(null),t=e()}finally{u(n)}return t},o.introspectSources=function(t){var n;if(!(0,e.isComputed)(t)&&!(0,e.isWatcher)(t))throw new TypeError("Called introspectSources without a Computed or Watcher argument");return(null==(n=t[T].producerNode)?void 0:n.map((e=>e.wrapper)))??[]},o.introspectSinks=function(t){var n;if(!(0,e.isComputed)(t)&&!(0,e.isState)(t))throw new TypeError("Called introspectSinks without a Signal argument");return(null==(n=t[T].liveConsumerNode)?void 0:n.map((e=>e.wrapper)))??[]},o.hasSinks=function(t){if(!(0,e.isComputed)(t)&&!(0,e.isState)(t))throw new TypeError("Called hasSinks without a Signal argument");const n=t[T].liveConsumerNode;return!!n&&n.length>0},o.hasSources=function(t){if(!(0,e.isComputed)(t)&&!(0,e.isWatcher)(t))throw new TypeError("Called hasSources without a Computed or Watcher argument");const n=t[T].producerNode;return!!n&&n.length>0};l=T,a=new WeakSet,c=new WeakSet,h=function(t){for(const n of t)if(!(0,e.isComputed)(n)&&!(0,e.isState)(n))throw new TypeError("Called watch/unwatch without a Computed or State argument")},e.isWatcher=e=>n(a,e),o.Watcher=class{constructor(e){r(this,a),r(this,c),t(this,l);let n=Object.create(f);n.wrapper=this,n.consumerMarkedDirty=e,n.consumerIsAlwaysLive=!0,n.consumerAllowSignalWrites=!1,n.producerNode=[],this[T]=n}watch(...t){if(!(0,e.isWatcher)(this))throw new TypeError("Called unwatch without Watcher receiver");s(this,c,h).call(this,t);const n=this[T];n.dirty=!1;const r=u(n);for(const e of t)d(e[T]);u(r)}unwatch(...t){if(!(0,e.isWatcher)(this))throw new TypeError("Called unwatch without Watcher receiver");s(this,c,h).call(this,t);const n=this[T];v(n);for(let e=n.producerNode.length-1;e>=0;e--)if(t.includes(n.producerNode[e].wrapper)){b(n.producerNode[e],n.producerIndexOfThis[e]);const t=n.producerNode.length-1;if(n.producerNode[e]=n.producerNode[t],n.producerIndexOfThis[e]=n.producerIndexOfThis[t],n.producerNode.length--,n.producerIndexOfThis.length--,n.nextProducerIndex--,e<n.producerNode.length){const t=n.producerIndexOfThis[e],r=n.producerNode[e];w(r),r.liveConsumerIndexOfThis[t]=e}}}getPending(){if(!(0,e.isWatcher)(this))throw new TypeError("Called getPending without Watcher receiver");return this[T].producerNode.filter((e=>e.dirty)).map((e=>e.wrapper))}},o.currentComputed=function(){var e;return null==(e=i)?void 0:e.wrapper},o.watched=Symbol("watched"),o.unwatched=Symbol("unwatched")})(e.subtle||(e.subtle={}))})(M||(M={}));const N=(e,t,n,r)=>{const s=new M.State("boolean"==typeof t?t:null);let o;if("function"==typeof n)o=new M.Computed((()=>Boolean(n(e))));else{const e=Boolean(n);o=new M.Computed((()=>e))}const i=()=>{const e=s.get();return null===e?o.get():e},l=r?new M.Computed((()=>r.get()||i())):new M.Computed(i);return[s,l]},k=e=>"string"==typeof e&&e||null,I=e=>"number"==typeof e&&e||null,P=e=>e instanceof RegExp?e:null,U=Boolean;function q(e){if("number"==typeof e||"string"==typeof e)return{label:e,value:e};if(!e||"object"!=typeof e)return null;const{children:t,label:n,value:r}=e,s=Array.isArray(t)?t.map(q).filter(U):[];return s.length?{children:s,label:n,value:r}:"number"==typeof r||"string"==typeof r?{label:n,value:r}:null}const B=e=>{if(!e||!Array.isArray(e))return null;const t=e.map(q).filter(U);return t.length?t:null};function R(e,t,n,r){const s=new M.State(t(n));let o;if("function"==typeof r){const n=r;o=new M.Computed((()=>t(n(e))))}else{const e=t(r);o=new M.Computed((()=>e))}const i=new M.Computed((()=>{const e=s.get();return null===e?o.get():e}));return[s,i]}const V=Symbol();function D(e){const t={[V]:e};for(const[n,r]of e)Object.defineProperty(t,n,{get:()=>r.ref,configurable:!1,enumerable:!0});return Object.defineProperty(t,V,{get:()=>e,configurable:!1,enumerable:!0}),t}let W=null,_=null,K=Object.create(null);function H(e,t){const n=e.type;let r=F;if(!e.array||_&&t?.parent instanceof _)if("string"==typeof n){const e=K[n];e&&(r=e)}else n&&"object"==typeof n&&W&&(r=W);else _&&(r=_);return new r(e,t)}function Y(e){return e?e instanceof Error?e.message:"string"!=typeof e?"":e:""}function z(e,...t){const n=t.flat().filter((e=>"function"==typeof e));if(!n.length)return[()=>Promise.resolve([]),new M.Computed((()=>[])),()=>{}];const r=new M.State([]);let s=null;return[function(){s?.abort(),s=new AbortController;const t=s.signal;return r.set([]),Promise.all(n.map((n=>async function(t,n){let s=[];try{s.push(await t(e,n))}catch(e){s.push(e)}const o=s.flat().map(Y).filter(Boolean);return!n.aborted&&o.length&&r.set([...r.get(),...o]),o}(n,t)))).then((e=>e.flat()))},new M.Computed((()=>r.get())),()=>{s?.abort(),r.set([])}]}class F{#e=new Map;emit(e,t){const n="number"==typeof e?String(e):e,r=this.#e;let s=!1;for(const e of[...r.get(n)||[]])s=!1===e(t,this)||s;return!s}listen(e,t){const n=t.bind(this),r=this.#e,s="number"==typeof e?String(e):e;let o=r.get(s);return o||(o=new Set,r.set(s,o)),o.add(n),()=>{o?.delete(n)}}static create(e,t={}){return H({type:e},{...t,parent:null})}static setStore(e,t){return function(e,t){K[e]=t}(e,t)}#t=!1;get null(){return this.#t}get kind(){return""}#n=null;get ref(){return this.#n||D(this)}constructor(e,{null:t,state:n,ref:r,setValue:s,setState:o,convert:i,onUpdate:l,onUpdateState:a,validator:c,validators:u,index:f,length:d,new:h,parent:p,hidden:g,clearable:m,required:b,disabled:y,readonly:v,label:w,description:x,placeholder:O,min:S,max:E,step:C,minLength:A,maxLength:$,pattern:j,values:L}={}){this.schema=e,this.#r.set("object"==typeof n&&n||{});const T=p instanceof F?p:null;T&&(this.#s=T,this.#o=T.#o),this.#i=e.type,this.#l=e.meta,this.#a=e.component;const U=new M.State(Boolean(h));this.#c=U;const q=T?new M.Computed((()=>T.#u.get()||U.get())):new M.Computed((()=>U.get()));this.#u=q;const V=Boolean(e.immutable),W=!1!==e.creatable;this.#f=V,this.#d=W;const _=e.readonly,K=new M.State("boolean"==typeof v?v:null);let H;if("function"==typeof _)H=new M.Computed((()=>Boolean(_(this))));else{const e=Boolean(_);H=new M.Computed((()=>e))}const G=()=>{if(q.get()?!W:V)return!0;const e=K.get();return null===e?H.get():e},Q=T?T.#h:null;this.#p=K,this.#h=Q?new M.Computed((()=>Q.get()||G())):new M.Computed(G),[this.#g,this.#m]=N(this,g,e.hidden,T?T.#m:null),[this.#b,this.#y]=N(this,m,e.clearable,T?T.#y:null),[this.#v,this.#w]=N(this,b,e.required,T?T.#w:null),[this.#x,this.#O]=N(this,y,e.disabled,T?T.#O:null),[this.#S,this.#E]=R(this,k,w,e.label),[this.#C,this.#A]=R(this,k,x,e.description),[this.#$,this.#j]=R(this,k,O,e.placeholder),[this.#L,this.#T]=R(this,I,S,e.min),[this.#M,this.#N]=R(this,I,E,e.max),[this.#k,this.#I]=R(this,I,C,e.step),[this.#P,this.#U]=R(this,I,A,e.minLength),[this.#q,this.#B]=R(this,I,$,e.maxLength),[this.#R,this.#V]=R(this,P,j,e.pattern),[this.#D,this.#W]=R(this,B,L,e.values);const Z=function(e,...t){const n=t.flat().filter((e=>"function"==typeof e));return n.length?new M.Computed((()=>{const t=[];for(const r of n)try{t.push(r(e))}catch(e){t.push(e)}return t.flat().map(Y).filter(Boolean)})):new M.Computed((()=>[]))}(this,e.validator,c),[X,J,ee]=z(this,e.validators?.change,u?.change),[te,ne,re]=z(this,e.validators?.blur,u?.blur);if(this.listen("change",(()=>{X()})),this.listen("blur",(()=>{te()})),this.#_=function(...e){const t=e.filter(Boolean);return new M.Computed((()=>t.flatMap((e=>e.get()))))}(Z,J,ne),this.#K=Z,this.#H=X,this.#Y=te,this.#z=ee,this.#F=re,d instanceof M.State||d instanceof M.Computed?this.#G=d:this.#G=new M.State(d||0),t)return this.#t=!0,void(this.#n=D(this));this.#n=r||null,this.#Q=l||null,this.#Z=a||null,this.#X="function"==typeof s?s:null,this.#J="function"==typeof o?o:null,this.#ee="function"==typeof i?i:null,this.#te.set(f??"");for(const[t,n]of Object.entries(e.events||{}))"function"==typeof n&&this.listen(t,n)}#X=null;#J=null;#ee=null;#Q=null;#Z=null;#s=null;#o=this;#i;#l;#a;get store(){return this}get parent(){return this.#s}get root(){return this.#o}get type(){return this.#i}get meta(){return this.#l}get component(){return this.#a}#G;get length(){return this.#G.get()}#te=new M.State("");get index(){return this.#te.get()}set index(e){this.#te.set(e)}get no(){if(this.#t)return"";const e=this.index;return"number"==typeof e?e+1:e}#d=!0;get creatable(){return this.#d}#f=!1;get immutable(){return this.#f}#u;#c;get selfNew(){return this.#c.get()}set selfNew(e){this.#c.set(Boolean(e))}get new(){return this.#u.get()}set new(e){this.#c.set(Boolean(e))}#g;#m;get selfHidden(){return this.#g.get()}set selfHidden(e){this.#g.set("boolean"==typeof e?e:null)}get hidden(){return this.#m.get()}set hidden(e){this.#g.set("boolean"==typeof e?e:null)}#b;#y;get selfClearable(){return this.#b.get()}set selfClearable(e){this.#b.set("boolean"==typeof e?e:null)}get clearable(){return this.#y.get()}set clearable(e){this.#b.set("boolean"==typeof e?e:null)}#v;#w;get selfRequired(){return this.#v.get()}set selfRequired(e){this.#v.set("boolean"==typeof e?e:null)}get required(){return this.#w.get()}set required(e){this.#v.set("boolean"==typeof e?e:null)}#x;#O;get selfDisabled(){return this.#x.get()}set selfDisabled(e){this.#x.set("boolean"==typeof e?e:null)}get disabled(){return this.#O.get()}set disabled(e){this.#x.set("boolean"==typeof e?e:null)}#p;#h;get selfReadonly(){return this.#p.get()}set selfReadonly(e){this.#p.set("boolean"==typeof e?e:null)}get readonly(){return this.#h.get()}set readonly(e){this.#p.set("boolean"==typeof e?e:null)}#S;#E;get selfLabel(){return this.#S.get()}set selfLabel(e){this.#S.set(k(e))}get label(){return this.#E.get()}set label(e){this.#S.set(k(e))}#C;#A;get selfDescription(){return this.#C.get()}set selfDescription(e){this.#C.set(k(e))}get description(){return this.#A.get()}set description(e){this.#C.set(k(e))}#$;#j;get selfPlaceholder(){return this.#$.get()}set selfPlaceholder(e){this.#$.set(k(e))}get placeholder(){return this.#j.get()}set placeholder(e){this.#$.set(k(e))}#L;#T;get selfMin(){return this.#L.get()}set selfMin(e){this.#L.set(I(e))}get min(){return this.#T.get()}set min(e){this.#L.set(I(e))}#M;#N;get selfMax(){return this.#M.get()}set selfMax(e){this.#M.set(I(e))}get max(){return this.#N.get()}set max(e){this.#M.set(I(e))}#k;#I;get selfStep(){return this.#k.get()}set selfStep(e){this.#k.set(I(e))}get step(){return this.#I.get()}set step(e){this.#k.set(I(e))}#P;#U;get selfMinLength(){return this.#P.get()}set selfMinLength(e){this.#P.set(I(e))}get minLength(){return this.#U.get()}set minLength(e){this.#P.set(I(e))}#q;#B;get selfMaxLength(){return this.#q.get()}set selfMaxLength(e){this.#q.set(I(e))}get maxLength(){return this.#B.get()}set maxLength(e){this.#q.set(I(e))}#R;#V;get selfPattern(){return this.#R.get()}set selfPattern(e){this.#R.set(P(e))}get pattern(){return this.#V.get()}set pattern(e){this.#R.set(P(e))}#D;#W;get selfValues(){return this.#D.get()}set selfValues(e){this.#D.set(B(e))}get values(){return this.#W.get()}set values(e){this.#D.set(B(e))}#_;#K;#H;#Y;#z;#F;get errors(){return this.#_.get()}get error(){return this.#_.get()[0]}*[Symbol.iterator](){}child(e){return null}#ne=!1;#re=new M.State(null);#se=new M.State(this.#re.get());#r=new M.State(null);get changed(){return this.#se.get()===this.#re.get()}get value(){return this.#se.get()}set value(e){const t=this.#X?.(e),n=void 0===t?e:t;this.#se.set(n),this.#ne||this.#re.set(n),this.#Q?.(n,this.#te.get(),this),this.#oe()}get state(){return this.#r.get()}set state(e){const t=this.#J?.(e),n=void 0===t?e:t;this.#r.set(n),this.#Z?.(n,this.#te.get(),this),this.#oe()}#oe(){this.#ie||(this.#ie=!0,queueMicrotask((()=>{const e=this.#se.get(),t=this.#r.get();this.#le(e,t)})))}reset(e=this.#re.get()){this.#ae(e)}#ae(e){const t=this.#X?.(e),n=void 0===t?e:t;if(this.#z(),this.#F(),this.#ne=!0,!n||"object"!=typeof n){for(const[,e]of this)e.#ae(null);return this.#se.set(n),this.#re.set(n),n}const r=Array.isArray(n)?[...n]:{...n};for(const[e,t]of this)r[e]=t.#ae(r[e]);return this.#se.set(r),this.#re.set(r),r}#ie=!1;#ce(e,t){const[n,r]=this.#ee?.(e,t)||[e,t];return this.#se.get()===n&&this.#r.get()===r?[n,r]:(this.#se.set(n),this.#r.set(r),this.#le(n,r))}#le(e,t){this.#ie=!1;let n=e;if(e&&"object"==typeof e){let r=Array.isArray(e)?[...e]:{...e},s=Array.isArray(e)?Array.isArray(t)?[...t]:[]:{...t},o=!1;for(const[n,i]of this){const l=e[n],a=t?.[n],[c,u]=i.#ce(l,a);l!==c&&(r[n]=c,o=!0),a!==u&&(s[n]=u,o=!0)}o&&(t=s,n=e=r,this.#se.set(e),this.#r.set(s))}return this.#ne||(this.#ne=!0,this.#re.set(n)),[e,t]}validate(e){if(!Array.isArray(e))return Promise.all([this.#K.get(),this.#H(),this.#Y()]).then((e=>{const t=e.flat();return t.length?t:null}));const t=[this.validate().then((t=>t?.length?[{path:[...e],store:this,errors:t}]:[]))];for(const[n,r]of this)t.push(r.validate([...e,n]));return Promise.all(t).then((e=>e.flat()))}}class G extends F{get kind(){return"object"}#ue;*[Symbol.iterator](){yield*Object.entries(this.#ue)}child(e){return this.#ue[e]||null}constructor(e,{parent:t,index:n,new:r,onUpdate:s,onUpdateState:o}={}){const i=Object.entries(e.type);super(e,{parent:t,index:n,new:r,onUpdate:s,onUpdateState:o,length:i.length,setValue:e=>"object"==typeof e?e:null,setState:e=>"object"==typeof e?e:null,convert:(e,t)=>["object"==typeof e?e:{},"object"==typeof t?t:{}]});const l=Object.create(null),a={parent:this,onUpdate:(e,t,n)=>{n===this.#ue[t]&&(this.value={...this.value,[t]:e})},onUpdateState:(e,t,n)=>{n===this.#ue[t]&&(this.state={...this.state,[t]:e})}};for(const[e,t]of i)l[e]=H(t,{...a,index:e});this.#ue=l}}W=G;class Q extends F{#fe=()=>{throw new Error};#ue;get children(){return[...this.#ue.get()]}*[Symbol.iterator](){return yield*[...this.#ue.get().entries()]}child(e){const t=this.#ue.get();return"number"==typeof e&&e<0?t[t.length+e]||null:t[Number(e)]||null}get kind(){return"array"}constructor(e,{parent:t,onUpdate:n,onUpdateState:r,index:s,new:o}={}){const i=new M.State([]),l=e=>{const t=Array.isArray(e)&&e.length||0,n=[...i.get()],r=n.length;for(let e=n.length;e<t;e++)n.push(this.#fe(e));r!==t&&i.set(n)};super(e,{index:s,new:o,parent:t,length:new M.Computed((()=>i.get().length)),state:[],setValue:e=>Array.isArray(e)?e:null==e?null:[e],setState:e=>Array.isArray(e)?e:null==e?null:[e],convert(e,t){const n=Array.isArray(e)?e:null==e?null:[e];return l(n),[n,Array.isArray(t)?t:null==e?[]:[t]]},onUpdate:(e,t,r)=>{l(e),n?.(e,t,r)},onUpdateState:r}),this.#ue=i;const a={parent:this,onUpdate:(e,t,n)=>{if(i.get()[t]!==n)return;const r=[...this.value||[]];r.length<t&&(r.length=t),r[t]=e,this.value=r},onUpdateState:(e,t,n)=>{if(i.get()[t]!==n)return;const r=[...this.state||[]];r.length<t&&(r.length=t),r[t]=e,this.state=r}};this.#fe=(t,n)=>{const r=H(e,{...a,index:t,new:n});return r.index=t,r}}insert(e,t=null,n){const r=this.value||[];if(!Array.isArray(r))return!1;const s=[...this.#ue.get()],o=Math.max(0,Math.min(Math.floor(e),s.length)),i=this.#fe(o,n);i.new=!0,s.splice(o,0,i);for(let t=e+1;t<s.length;t++)s[t].index=t;const l=[...r];l.splice(o,0,t);const a=this.state;if(Array.isArray(a)){const e=[...a];e.splice(o,0,{}),this.state=e}return this.#ue.set(s),this.value=l,!0}add(e=null){return this.insert(this.#ue.get().length,e)}remove(e){const t=this.value;if(!Array.isArray(t))return;const n=[...this.#ue.get()],r=Math.max(0,Math.min(Math.floor(e),n.length)),[s]=n.splice(r,1);if(!s)return;for(let t=e;t<n.length;t++)n[t].index=t;const o=[...t],[i]=o.splice(r,1),l=this.state;if(Array.isArray(l)){const e=[...this.state];e.splice(r,1),this.state=e}return this.#ue.set(n),this.value=o,i}move(e,t){const n=this.value;if(!Array.isArray(n))return!1;const r=[...this.#ue.get()],[s]=r.splice(e,1);if(!s)return!1;r.splice(t,0,s);let o=Math.min(e,t),i=Math.max(e,t);for(let e=o;e<=i;e++)r[e].index=e;const l=[...n],[a]=l.splice(e,1);l.splice(t,0,a);const c=this.state;if(Array.isArray(c)){const n=[...c],[r={}]=n.splice(e,1);t<=n.length?n.splice(t,0,r):n[t]=r,this.state=n}return this.#ue.set(r),this.value=l,!0}exchange(e,t){const n=this.value;if(!Array.isArray(n))return!1;const r=[...this.#ue.get()],s=r[e],o=r[t];if(!s||!o)return!1;r[t]=s,r[e]=o,s.index=t,o.index=e;const i=[...n],l=i[e],a=i[t];i[t]=l,i[e]=a;const c=this.state;if(Array.isArray(c)){const n=[...c],r=n[e],s=n[t];n[t]=r,n[e]=s,this.state=n}return this.#ue.set(r),this.value=i,!0}}!function(e){_=e}(Q);const Z={CALC:"no `createCalc` option, no expression parsing support",EVENT:"no `createEvent`, options, no event parsing support",CLOSE:(e,t)=>`end tag name: ${e} is not match the current start tagName: ${t}`,UNCLOSE:e=>`end tag name: ${e} maybe not complete`,QUOTE:e=>`attribute value no end '${e}' match`,CLOSE_SYMBOL:"elements closed character '/' and '>' must be connected to",UNCOMPLETED:(e,t)=>t?`end tag name: ${e} is not complete: ${t}`:`end tag name: ${e} maybe not complete`,ENTITY:e=>`entity not found: ${e}`,SYMBOL:e=>`unexpected symbol: ${e}`,TAG:e=>`invalid tagName: ${e}`,ATTR:e=>`invalid attribute: ${e}`,EQUAL:"attribute equal must after attrName",ATTR_VALUE:'attribute value must after "="',EOF:"unexpected end of file"};class X extends Error{constructor(e,...t){const n=Z[e];super("function"==typeof n?n(...t):n),this.code=e}}const J=/^(?<decorator>[:@!+*\.?]|style:|样式:)?(?<name>-?[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_:\d\.]*)$/u,ee=/^(?<name>[a-zA-Z$\p{Unified_Ideograph}_][\da-zA-Z$\p{Unified_Ideograph}_]*)?$/u;function te(e,t,n){const{attrs:r,directives:s,events:o,classes:i,styles:l,vars:a,aliases:c,params:u}=e;return function(e,f){const d=J.exec(e.replace(/./g,".").replace(/:/g,":").replace(/@/g,"@").replace(/+/g,"+").replace(/-/g,"-").replace(/[*×]/g,"*").replace(/!/g,"!"))?.groups;if(!d)throw new X("ATTR",e);const{name:h}=d,p=d.decorator?.toLowerCase();if(p){if(":"===p)r[h]=ee.test(f)?{name:f}:t(f);else if("."===p)i[h]=!f||(ee.test(f)?f:t(f));else if("style:"===p)l[h]=ee.test(f)?f:t(f);else if("@"===p)o[h]=ee.test(f)?f:n(f);else if("+"===p)a[h]=f?ee.test(f)?f:t(f):"";else if("*"===p)c[h]=ee.test(f)?f:t(f);else if("?"===p)u[h]=ee.test(f)?f:t(f);else if("!"===p){const e=h.toString();switch(e){case"fragment":s.fragment=f||!0;break;case"else":s.else=!0;break;case"enum":s.enum=!f||(ee.test(f)?f:t(f));break;case"if":case"text":case"html":s[e]=ee.test(f)?f:t(f);break;case"template":s.template=f;break;case"bind":s.bind=f||!0;break;case"value":s.value=f;break;case"comment":s.comment=f}}}else r[h]=f}}function ne(e,t){return{name:e,is:t,children:[],attrs:Object.create(null),events:Object.create(null),directives:Object.create(null),classes:Object.create(null),styles:Object.create(null),vars:Object.create(null),aliases:Object.create(null),params:Object.create(null)}}var re={lt:"<",gt:">",amp:"&",quot:'"',apos:"'",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",times:"×",divide:"÷",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",euro:"€",trade:"™",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"};const se=/^(?<name>[\w\p{Unified_Ideograph}_][-\.\|:|d\w\p{Unified_Ideograph}_:]*)(?:|(?<is>[\w\p{Unified_Ideograph}_][-\.\|:|d\w\p{Unified_Ideograph}_]*))?$/u;function oe(e){return"="!==e&&"/"!==e&&">"!==e&&e&&"'"!==e&&'"'!==e&&!function(e){return"0x80"===e||e<=" "}(e)}function ie(e,t,n,r){let s=r[n];return null==s&&(s=e.lastIndexOf("</"+n+">"),s<t&&(s=e.lastIndexOf("</"+n)),r[n]=s),s<t}function le(...e){console.error(new X(...e))}function ae(e){const t=e.slice(1,-1);return"#"===t.charAt(0)?String.fromCodePoint(parseInt(t.substring(1).replace("x","0x"))):t in re?re[t]:(le("ENTITY",e),e)}function ce(e){return("<"==e?"&lt;":">"==e&&"&gt;")||"&"==e&&"&amp;"||'"'==e&&"&quot;"||"&#"+e.charCodeAt()+";"}function*ue(e,t=0){const{attrs:n,events:r,directives:s,children:o,is:i,name:l,params:a,classes:c,styles:u,aliases:f,vars:d}=e,h=t>0?"".padEnd(t,"\t"):"";yield h,yield*["<",l||"-"],i&&(yield*["|",i]);for(const[e,t]of Object.entries(a)){if(null==t)continue;const n="function"==typeof t?String(t):t;yield*[" ?",e],n&&"string"==typeof n&&(yield*['="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(s)){if(!1===t||null==t)continue;const n="function"==typeof t?String(t):t;yield*[" !",e],n&&"string"==typeof n&&(yield*['="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(f)){if(null==t)continue;const n="function"==typeof t?String(t):t;yield*[" *",e],n&&"string"==typeof n&&(yield*['="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(d)){if(null==t)continue;const n="function"==typeof t?String(t):t;yield*[" +",e],n&&"string"==typeof n&&(yield*['="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(n)){if(null==t)continue;if("string"==typeof t){yield*[" ",e],t&&(yield*['="',t.replace(/[<&"]/g,ce),'"']);continue}const n="function"==typeof t?String(t):"object"==typeof t?t.name:t;n&&"string"==typeof n&&(yield*[" :",e,'="',n.replace(/[<&"]/g,ce)||"",'"'])}for(const[e,t]of Object.entries(r)){if(null==t)continue;const n="function"==typeof t?String(t):t;n&&"string"==typeof n&&(yield*[" @",e,'="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(c)){if(null==t||0==t)continue;const n="function"==typeof t?String(t):t;yield*[" .",e],n&&"string"==typeof n&&(yield*[" .",e,'="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(u)){if(null==t)continue;const n="function"==typeof t?String(t):t;n&&"string"==typeof n&&(yield*[" style:",e,'="',n.replace(/[<&"]/g,ce),'"'])}if(!o.length)return yield"/>",void(t>=0&&(yield"\n"));if(1===o.length){const[e]=o;if("string"==typeof e&&e.length<80&&!e.includes("\n"))return yield">",yield*[e.replace(/[<&\t]/g,ce).replace(/]]>/g,"]]&gt;")],yield*["</",l,">"],void(t>=0&&(yield"\n"))}yield">",t>=0&&(yield"\n"),yield*fe(o,t>=0?t+1:-1),yield*[h,"</",l,">"],t>=0&&(yield"\n")}function*fe(e,t=0){if(!e.length)return"";const n=t>0?"".padEnd(t,"\t"):"";for(const r of e)if("string"==typeof r){let e=r.replace(/[<&\t]/g,ce).replace(/]]>/g,"]]&gt;");n&&(e=e.replace(/(?<=^|\n)/g,n)),yield e,t>=0&&(yield"\n")}else yield*ue(r,t)}var de=Object.freeze({__proto__:null,parse:function(e,{createCalc:t=()=>{throw new X("CALC")},createEvent:n=()=>{throw new X("EVENT")},simpleTag:r=new Set}={}){const s=[],o={children:s},i=[];let l=null,a=o;function c(){l=i.pop()||null,a=l||o}function u(e){(e=e.replace(/^\n|(?<=\n)\t+|\n\t*$/g,""))&&a.children.push(e)}let f={},d=0;function h(t){if(t<=d)return;u(e.substring(d,t).replace(/&#?\w+;/g,ae)),d=t}for(;;){const p=e.indexOf("<",d);if(p<0){const E=e.substring(d);E.match(/^\s*$/)||u(E);break}if(p>d&&h(p),"/"===e.charAt(p+1)){d=e.indexOf(">",p+3);let C=e.substring(p+2,d);if(d<0?(C=e.substring(p+2).replace(/[\s<].*/,""),le("UNCOMPLETED",C,l?.name),d=p+1+C.length):C.match(/\s</)&&(C=C.replace(/[\s<].*/,""),le("UNCOMPLETED",C),d=p+1+C.length),l){const A=l.name;if(A===C)c();else{if(A.toLowerCase()!=C.toLowerCase())throw new X("CLOSE",C,l.name);c()}}d++;continue}function g(t){let n=d+1;if(d=e.indexOf(t,n),d<0)throw new X("QUOTE",t);const r=e.slice(n,d).replace(/&#?\w+;/g,ae);return d++,r}function m(){let t=e.charAt(d);for(;t<=" "||"€"===t;t=e.charAt(++d));return t}function b(){let t=d,n=e.charAt(d);for(;oe(n);)d++,n=e.charAt(d);return e.slice(t,d)}d=p+1;let y=e.charAt(d);switch(y){case"=":throw new X("EQUAL");case'"':case"'":throw new X("ATTR_VALUE");case">":case"/":throw new X("SYMBOL",y);case"":throw new X("EOF")}const v=b(),w=se.exec(v)?.groups;if(!w)throw new X("TAG",v);i.push(l),l=ne(w.name,w.is),a.children.push(l),a=l;const x=te(l,t,n);let O=!0,S=!1;e:for(;O;){let $=m();switch($){case"":le("EOF"),d++;break e;case">":d++;break e;case"/":S=!0;break e;case'"':case"'":throw new X("ATTR_VALUE");case"=":throw new X("SYMBOL",$)}const j=b();if(!j){le("EOF"),d++;break e}switch($=m(),$){case"":le("EOF"),d++;break e;case">":x(j,""),d++;break e;case"/":x(j,""),S=!0;break e;case"=":d++;break;case"'":case'"':x(j,g($));continue;default:x(j,"");continue}switch($=m(),$){case"":x(j,""),le("EOF"),d++;break e;case">":x(j,""),d++;break e;case"/":x(j,""),S=!0;break e;case"'":case'"':x(j,g($));continue}x(j,b())}if(S){for(;;){d++;const L=e.charAt(d);if("/"!==L&&!(L<=" "||"€"===L))break}switch(e.charAt(d)){case"=":throw new X("EQUAL");case'"':case"'":throw new X("ATTR_VALUE");case"":le("EOF");break;case">":d++;break;default:throw new X("CLOSE_SYMBOL")}c()}else(r.has(v)||ie(e,d,v,f))&&c()}return s},stringify:function(e,t){const n=t?0:-1;return Array.isArray(e)?[...fe(e,n)].join(""):[ue(e,n)].join()}});function he(e){let t=!0;const n=new M.subtle.Watcher((()=>{t&&(t=!1,queueMicrotask((()=>{t=!0;for(const e of n.getPending())e.get();n.watch()})))})),r=new M.Computed(e);return n.watch(r),r.get(),()=>{n.unwatch(r)}}function pe(e,t,n){let r,s=!1;return he((()=>{const o=e();if(!s)return s=!0,r=o,void(n&&t(o));Object.is(o,r)||(r=o,t(o))}))}const ge=new Set(Object.keys({type:!0,meta:!0,component:!0,kind:!0,value:!0,state:!0,store:!0,parent:!0,root:!0,ref:!0,schema:!0,new:!0,readonly:!0,creatable:!0,immutable:!0,changed:!0,required:!0,clearable:!0,hidden:!0,disabled:!0,label:!0,description:!0,placeholder:!0,min:!0,max:!0,step:!0,minLength:!0,maxLength:!0,pattern:!0,values:!0,null:!0,index:!0,no:!0,length:!0,error:!0,errors:!0}));function*me(e,t="",n="$"){yield[`${t}`,{get:()=>e.value,set:t=>e.value=t,store:e}];for(const r of ge)yield[`${t}${n}${r}`,{get:()=>e[r]}];yield[`${t}${n}value`,{get:()=>e.value,set:t=>e.value=t}],yield[`${t}${n}state`,{get:()=>e.state,set:t=>e.state=t}],yield[`${t}${n}reset`,{exec:()=>e.reset()}],yield[`${t}${n}validate`,{exec:t=>e.validate(t?[]:null)}],e instanceof Q&&(yield[`${t}${n}insert`,{exec:(t,n)=>e.insert(t,n)}],yield[`${t}${n}add`,{exec:t=>e.add(t)}],yield[`${t}${n}remove`,{exec:t=>e.remove(t)}],yield[`${t}${n}move`,{exec:(t,n)=>e.move(t,n)}],yield[`${t}${n}exchange`,{exec:(t,n)=>e.exchange(t,n)}])}function be(e,t,n){for(const[n,r]of t){for(const[t,s]of me(r,n))e[t]=s;for(const[t,s]of me(r,n,"$$"))e[t]=s}}const ye={value$:{calc:e=>e?.[V].value},state$:{calc:e=>e?.[V].state}};var ve=Object.getOwnPropertyDescriptors(ye);function we(e){if(!e)return!1;const t=e.indexOf("$");return t<0||(e.indexOf("$",t+2)>0||"$"===e[0]&&"_$".includes(e[1]))}function xe(e,t){Object.defineProperty(t,"$store",{value:e,writable:!1,configurable:!0,enumerable:!1}),Object.defineProperty(t,"$root",{value:e.root,writable:!1,configurable:!0,enumerable:!1})}class Oe{exec(e){if("string"==typeof e){const t=this.#de[e];if("function"!=typeof t?.get)return;return t.get()}if("function"==typeof e)return e(this.getters)}watch(e,t){return pe((()=>this.exec(e)),t,!0)}enum(e){if(!e)return!0;if(!0===e)return this.store;if("function"==typeof e)return()=>e(this.getters);if("string"!=typeof e)return null;const t=this.#de[e];if("function"!=typeof t?.get)return null;const n=t.store;return n instanceof F?n:t.get}bind(e,t,n){const r=this.#de[!0===e?"":e];if(!r?.get)return;const{store:s}=r;return s?ge.has(t)?pe((()=>s[t]),n,!0):void 0:"value"===t?pe((()=>r.get()),n,!0):void 0}bindAll(e){const t=this.#de[!0===e?"":e];if(!t?.get)return;const{store:n}=t;if(!n){const e=t.get;if("function"!=typeof e)return;return{$value:t=>pe(e,t,!0)}}return Object.fromEntries([...ge].map((e=>[`$${e}`,t=>pe((()=>n[e]),t,!0)])))}bindSet(e,t){const n=this.#de[!0===e?"":e];if(!n?.get)return;const{store:r}=n;if(r)switch(t){case"value":return e=>{r.value=e};case"state":return e=>{r.state=e}}}bindEvents(e){const t=this.#de[!0===e?"":e];if(!t?.get)return;const{store:n}=t;if(!n){const e=t.set;if("function"!=typeof e)return;return{$value:e}}return{$value:e=>{n.value=e},$state:e=>{n.state=e},$input:e=>{n.emit("input",e)},$change:e=>{n.emit("change",e)},$click:e=>{n.emit("click",e)},$focus:e=>{n.emit("focus",e)},$blur:e=>{n.emit("blur",e)},$reset:e=>{n.reset()},$validate:e=>{n.validate(e?[]:null)}}}getEvent(e){if("function"==typeof e)return e;const t=this.#de[e];if(!t)return null;const{exec:n,calc:r}=t;return"function"==typeof n?n:"function"==typeof r?r:null}constructor(e,t){if(this.store=e,t instanceof Oe){this.#he=t.#he;const e=this.#pe;for(const[n,r]of Object.entries(t.#pe))e[n]=r;const n=this.#ge;for(const[e,r]of Object.entries(t.#ge))n[e]=r}else be(this.#pe,e),this.#he=function(e){const t=Object.create(null,ve);if(!e||"object"!=typeof e)return t;for(const[n,r]of Object.entries(e)){if(!we(n))continue;if(!r||"object"!=typeof r)continue;if(r instanceof F){for(const[e,s]of me(r,n))t[e]=s;continue}const{get:e,set:s,exec:o,calc:i}=r;"function"!=typeof e?"function"!=typeof i?"function"!=typeof o||(t[n]={exec:o}):t[n]={calc:i}:t[n]="function"==typeof s?{get:e,set:s}:{get:e}}return t}(t)}#he;#pe=Object.create(null);#ge=Object.create(null);store;#me=null;#s=null;#be=null;get#de(){const e=this.#be;if(e)return e;const t=Object.create(null,Object.getOwnPropertyDescriptors({...this.#pe,...this.#he,...this.#ge})),n=this.store,r=this.#s,s=this.#me;if(s)for(const e of Object.keys(s))t[`$${e}`]={get:()=>s[e]};else{for(const[e,r]of me(n))t[e]=r;for(const[e,s]of function*(e,t,n="",r="$"){if(!(e instanceof Q))return yield[`${n}${r}upMovable`,{get:()=>!1}],void(yield[`${n}${r}downMovable`,{get:()=>!1}]);yield[`${n}${r}upMovable`,{get:()=>{const e=t.index;return"number"==typeof e&&!(e<=0)}}],yield[`${n}${r}downMovable`,{get:()=>{const n=t.index;return"number"==typeof n&&!(n>=e.length-1)}}],yield[`${n}${r}remove`,{exec:()=>e.remove(Number(t.index))}],yield[`${n}${r}upMove`,{exec:()=>{const n=t.index;"number"==typeof n&&(n<=0||e.move(n,n-1))}}],yield[`${n}${r}downMove`,{exec:()=>{const n=t.index;"number"==typeof n&&(n>=e.length-1||e.move(n,n+1))}}]}(r,n))t[e]=s}return this.#be=t,t}setStore(e,t){const n=new Oe(e,this);return t&&(n.#s=t),be(n.#pe,e),n}child(e){if(!e)return this;const t=this.store.child(e);if(!t)return null;const n=new Oe(t,this);return be(n.#pe,t),n}params({params:e},{attrs:t},n,r){let s=this.store;if(!0===r)s=n.store;else if(r){const e=n.#de[r],t=e?.get&&e.store;t&&(s=t)}if(0===Object.keys(e).length)return this;const o=new Oe(s,this);o.#s=this.#s,o.#me=this.#me;const i=o.#ge,l=o.#de;for(const[r,s]of Object.entries(e)){const e=r in t?t[r]:null;if("string"!=typeof e){if(e&&"object"==typeof e){const t=n.#de[e.name];if(!t?.get)continue;if(!t.store){i[r]=l[r]=t;continue}for(const[e,n]of me(t.store,r))i[e]=l[e]=n;continue}if("function"==typeof e){const t=new M.Computed((()=>e(n.getters)));i[r]=l[r]={get:()=>t.get()};continue}if("function"==typeof s){const e=o.getters;o.#ye=null;const t=new M.Computed((()=>s(e)));i[r]=l[r]={get:()=>t.get()};continue}{const e=l[s];if(!e?.get)continue;if(!e.store){i[r]=l[r]=e;continue}for(const[t,n]of me(e.store,r))i[t]=l[t]=n;continue}}i[r]=l[r]={get:()=>e}}return o}setObject(e){const t=new Oe(this.store,this);return t.#me=e,t}set(e,t){if(Object.keys(e).length+Object.keys(t).length===0)return this;const n=new Oe(this.store,this);n.#s=this.#s,n.#me=this.#me;const r=n.#ge,s=n.#de;for(const[t,o]of Object.entries(e)){if("function"==typeof o){const e=n.getters;n.#ye=null;const i=new M.Computed((()=>o(e)));r[t]=s[t]={get:()=>i.get()};continue}const e=s[o];if(e)if(e.get&&e.store)for(const[n,o]of me(e.store,t))r[n]=s[n]=o;else r[t]=s[t]=e}for(const[e,o]of Object.entries(t)){const t=new M.State(null);if("function"==typeof o){const e=n.settable;n.#ve=null,t.set(o(e))}else if(o&&"string"==typeof o){const e=s[o];if(!e?.get)continue;t.set(e.get())}r[e]=s[e]={get:()=>t.get(),set:e=>{t.set(e)}}}return n}#we=null;get all(){const e=this.#we;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#de))n.get?Object.defineProperty(t,e,{get:n.get,set:n.set,configurable:!0,enumerable:!0}):n.calc?Object.defineProperty(t,e,{value:n.calc,writable:!1,configurable:!0,enumerable:!1}):Object.defineProperty(t,e,{value:n.exec,writable:!1,configurable:!0,enumerable:!1});return xe(this.store,t),this.#we=t,t}#ve=null;get settable(){const e=this.#ve;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#de))n.get?Object.defineProperty(t,e,{get:n.get,set:n.set,configurable:!0,enumerable:!0}):n.calc&&Object.defineProperty(t,e,{value:n.calc,writable:!1,configurable:!0,enumerable:!1});return xe(this.store,t),this.#ve=t,t}#ye=null;get getters(){const e=this.#ye;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#de))n.get?Object.defineProperty(t,e,{get:n.get,configurable:!0,enumerable:!0}):n.calc&&Object.defineProperty(t,e,{value:n.calc,writable:!1,configurable:!0,enumerable:!1});return xe(this.store,t),this.#ye=t,t}}const Se={width:"px",height:"px",top:"px",right:"px",bottom:"px",left:"px",border:"px","border-top":"px","border-right":"px","border-left":"px","border-bottom":"px","border-width":"px","border-top-width":"px","border-right-width":"px","border-left-width":"px","border-bottom-width":"px","border-radius":"px","border-top-left-radius":"px","border-top-right-radius":"px","border-bottom-left-radius":"px","border-bottom-right-radius":"px",padding:"px","padding-top":"px","padding-right":"px","padding-left":"px","padding-bottom":"px",margin:"px","margin-top":"px","margin-right":"px","margin-left":"px","margin-bottom":"px"};function Ee(e,t){let n=!!Array.isArray(t)&&Boolean(t[1]),r="";if("string"==typeof t)return r=t.replace(/!important\s*$/,""),r?(n=r!==t,[r,n?"important":void 0]):null;const s=Array.isArray(t)?t[0]:t;return"number"==typeof s||"bigint"==typeof s?r=s&&e in Se?`${s}${Se[e]}`:`${s}`:"string"==typeof s&&(r=s),r?[r,n?"important":void 0]:null}class Ce{#e=new Map;emit(e,...t){const n="number"==typeof e?String(e):e,r=this.#e;for(const e of[...r.get(n)||[]])e(...t)}listen(e,t){const n=t.bind(this),r=this.#e,s="number"==typeof e?String(e):e;let o=r.get(s);return o||(o=new Set,r.set(s,o)),o.add(n),()=>{o?.delete(n)}}}const Ae={stop(e){e instanceof Event&&e.stopPropagation()},prevent(e){e instanceof Event&&e.preventDefault()},self(e){if(e instanceof Event)return e.target===e.currentTarget},enter(e){if(e instanceof KeyboardEvent)return"Enter"===e.key},tab(e){if(e instanceof KeyboardEvent)return"Tab"===e.key},esc(e){if(e instanceof KeyboardEvent)return"Escape"===e.key},space(e){if(e instanceof KeyboardEvent)return" "===e.key},backspace(e){if(e instanceof KeyboardEvent)return"Backspace"===e.key},delete(e){if(e instanceof KeyboardEvent)return"Delete"===e.key},delBack(e){if(e instanceof KeyboardEvent)return"Delete"===e.key||"Backspace"===e.key},"del-back"(e){if(e instanceof KeyboardEvent)return"Delete"===e.key||"Backspace"===e.key},insert(e){if(e instanceof KeyboardEvent)return"Insert"===e.key},repeat(e){if(e instanceof KeyboardEvent)return e.repeat},key(e,t){if(e instanceof KeyboardEvent){const n=e.code.toLowerCase().replace(/-/g,"");for(const e of t)if(n===e.toLowerCase().replace(/-/g,""))return!0;return!1}},main(e){if(e instanceof MouseEvent)return 0===e.button},auxiliary(e){if(e instanceof MouseEvent)return 1===e.button},secondary(e){if(e instanceof MouseEvent)return 2===e.button},left(e){if(e instanceof MouseEvent)return 0===e.button},middle(e){if(e instanceof MouseEvent)return 1===e.button},right(e){if(e instanceof MouseEvent)return 2===e.button},primary(e){if(e instanceof PointerEvent)return e.isPrimary},mouse(e){if(e instanceof PointerEvent)return"mouse"===e.pointerType},pen(e){if(e instanceof PointerEvent)return"pen"===e.pointerType},touch(e){if(e instanceof PointerEvent)return"touch"===e.pointerType},pointer(e,t){if(e instanceof PointerEvent){const n=e.pointerType.toLowerCase().replace(/-/g,"");for(const e of t)if(n===e.toLowerCase().replace(/-/g,""))return!0;return!1}},ctrl(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.ctrlKey},alt(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.altKey},shift(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.shiftKey},meta(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.metaKey},cmd(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.ctrlKey||e.metaKey}};function $e(e){return"number"==typeof e||"bigint"==typeof e?String(e):"boolean"==typeof e?e?"":null:"string"==typeof e?e:null===(e??null)?null:String(e)}function je(e){return null===(e??null)?"":String(e)}function Le(e,t){if(e instanceof HTMLInputElement&&"checked"===t)switch(e.type.toLowerCase()){case"checkbox":case"radio":return Boolean}if((e instanceof HTMLSelectElement||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&"value"===t)return je;if(e instanceof HTMLDetailsElement&&"open"===t)return Boolean;if(e instanceof HTMLMediaElement){if("muted"===t)return Boolean;if("paused"===t)return Boolean;if("currentTime"===t)return!0;if("playbackRate"===t)return!0;if("volume"===t)return!0}return!1}const Te={input:{attrs:{$min:(e,t)=>{t.min=e},$max:(e,t)=>{t.max=e},$step:(e,t)=>{t.step=e},$placeholder:(e,t)=>{t.placeholder=e},$disabled:(e,t)=>{t.disabled=e},$readonly:(e,t)=>{t.readOnly=e},$required:(e,t)=>{t.required=e},$value:(e,t)=>{switch(t.type){case"checkbox":case"radio":t.checked=Boolean(e)}t.value=je(e)}},events:{$value:["input",(e,t)=>{switch(t.type){case"checkbox":case"radio":return t.checked;case"number":return Number(t.value)}return t.value}]}},textarea:{attrs:{$placeholder:(e,t)=>{t.placeholder=e},$disabled:(e,t)=>{t.disabled=e},$readonly:(e,t)=>{t.readOnly=e},$required:(e,t)=>{t.required=e},$value:(e,t)=>{t.value=je(e)}},events:{$value:["input",(e,t)=>t.value]}},select:{attrs:{$disabled:(e,t)=>{t.disabled=e},$required:(e,t)=>{t.required=e},$value:(e,t)=>{t.value=je(e)}},events:{$value:["change",(e,t)=>t.value]}}};function Me(e,t,n){const r=document.createElement(t,{is:n||void 0}),{watchAttr:s,props:o}=e;return e.listen("init",(({events:n})=>{const i=Te[t.toLowerCase()],l=i?.attrs||{},a=i?.events||{};for(const[e,t,s]of n)if("$"!==e[0])r.addEventListener(e,t,s);else{const n=a[e];if(n){const[e,o]=n;r.addEventListener(e,(e=>t(o(e,r))),s)}}if(o)for(const[t,n]of Object.entries(e.tagAttrs))if(s(t,(e=>{if(o.has(t))r[t]=e;else{const n=$e(e);null==n?r.removeAttribute(t):r.setAttribute(t,n)}})),o.has(t))r[t]=n;else{const e=$e(n);null!==e&&r.setAttribute(t,e)}else for(const[t,n]of Object.entries(e.tagAttrs)){if(r instanceof HTMLInputElement&&"type"===t.toLocaleLowerCase()){const e=$e(n);null!==e&&r.setAttribute(t,e);continue}if("$hidden"===t){n&&(r.hidden=n),s(t,(e=>{r.hidden=e}));continue}if("$"===t[0]){const e=l[t];e&&(e(n,r),s(t,(t=>e(t,r))));continue}const e=Le(r,t);if("function"==typeof e){r[t]=e(n),s(t,(n=>{r[t]=e(n)}));continue}if(e){r[t]=n,s(t,(e=>{r[t]=e}));continue}let o=$e(n);null!==o&&r.setAttribute(t,o),s(t,(e=>{const n=$e(e);null===n?r.removeAttribute(t):r.setAttribute(t,n)}))}})),r}function Ne(e){return null===(e??null)?"":String(e)}function ke(e,t,n,{text:r,html:s}){if(null!=r){const s=e.insertBefore(document.createTextNode(""),t),o=n.watch(r,(e=>s.textContent=Ne(e)));return()=>{s.remove(),o()}}if(null==s)return;const o=e.insertBefore(document.createComment(""),t),i=e.insertBefore(document.createComment(""),t),l=document.createElement("div");function a(){for(let e=o.nextSibling;e&&e!==i;e=o.nextSibling)e.remove()}const c=n.watch(s,(t=>{a(),function(t){l.innerHTML=t;for(let t=l.firstChild;t;t=o.firstChild)e.insertBefore(t,i)}(Ne(t))}));return()=>{c(),a(),o.remove(),i.remove()}}function Ie(e,t,n,r,s,o){let i=new Set,l=[],a=Object.create(s);for(const t of e){if("string"==typeof t)continue;const e=t.directives.template;e&&(a[e]=[t,r])}function c(e){if(!e.length||!i)return;const s=t.insertBefore(document.createComment(""),n);let l=-1,c=()=>{};i.add((()=>{c(),c=()=>{},s.remove()})),i.add(pe((()=>e.findIndex((([e])=>null===e||r.exec(e)))),(t=>{t!==l&&(l=t,c(),c=()=>{},function(t){const n=e[t]?.[1];n&&(c=o(n,a))}(l))}),!0))}for(const r of e){if("string"==typeof r){c(l),l=[];const e=document.createTextNode(r);t.insertBefore(e,n),i.add((()=>e.remove()));continue}if(r.directives.template){c(l),l=[];continue}if(l.length&&r.directives.else){const e=r.directives.if||null;l.push([e,r]),e||(c(l),l=[]);continue}c(l),l=[];const e=r.directives.if;e?l.push([e,r]):i.add(o(r,a))}return()=>{if(!i)return;const e=i;i=null;for(const t of e)t()}}function Pe(e,t,n,r,s,o,i,l){r=r.set(e.aliases,e.vars);const a=e.directives.bind,c=e.directives.fragment;if(c&&"string"==typeof c){const u=s[c];if(!u)return()=>{};const[f,d]=u,h=d.params(f,e,r,a);return Ue(f,t,n,h,s,o,i,l)}if(!e.name||e.directives.fragment)return ke(t,n,r,e.directives)||Ie(e.children||[],t,n,r,s,((e,s)=>Ue(e,t,n,r,s,o,i,l)));const u=[...o,e.name],f=l?.(u);if(l&&!f)return()=>{};const{context:d,handler:h}=function(e,t,n){const r="string"==typeof e?e:e.tag,{attrs:s,events:o}="string"!=typeof e&&e||{attrs:null,events:null};let i=!1;const l=new M.State(!1);let a=!1;const c=new M.State(!1),u=Object.create(null),f=Object.create(null),d=new Set,h=[],p=new Ce;return{context:{events:h,props:s?new Set(Object.entries(s).filter((([,e])=>e.isProp)).map((([e])=>e))):null,tagAttrs:f,watchAttr(e,t){if(i)return()=>{};const n=u[e];if(!n)return()=>{};let r=n.get();const s=pe((()=>n.get()),(n=>{const s=r;r=n,t(n,s,e)}),!0);return d.add(s),()=>{d.delete(s),s()}},relate(e){if(!n||i)return()=>{};try{const r=n(t.store,e);return"function"!=typeof r?()=>{}:(d.add(r),()=>{d.delete(r),r()})}catch{return()=>{}}},get destroyed(){return l.get()},get init(){return c.get()},listen:(e,t)=>p.listen(e,t)},handler:{tag:r,set(e,t){if(s&&!(e in s))return;let n=u[e];if(n)return void n.set(t);const r=new M.State(t);u[e]=r,Object.defineProperty(f,e,{configurable:!0,enumerable:!0,get:r.get.bind(r)})},addEvent(e,n){if("function"!=typeof n)return;const[r,...s]=e.split(".").filter(Boolean),i=o?o[r].filters:{};if(!i)return;const l={},a=[];if(i)for(let e=s.shift();e;e=s.shift()){const t=e.indexOf(":"),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1).split(":"):[],s=n.replace(/^-+/,""),o=(n.length-s.length)%2==1;let c=i[s]||s;switch(c){case"once":l.once=!o;break;case"passive":l.passive=!o;break;case"capture":l.capture=!o;break;default:"string"==typeof c&&(c=Ae[c])}"function"==typeof c&&a.push([c,r,o])}h.push([r,e=>{const r=t.all;for(const[t,n,s]of a)if(t(e,n,r)===s)return;n(e,r)},l])},destroy(){if(!i){i=!0,l.set(!0);for(const e of d)e();p.emit("destroy")}},mount(){a||(a=!0,c.set(!0),p.emit("init",{events:h}))}}}}(f||e.name,r,i),p=f?.attrs,g=p?function(e,t,n,r,s){let o=new Set;for(const[i,l]of Object.entries(r)){const r=n[i];if(i in n){if("function"!=typeof r&&"object"!=typeof r){e.set(i,r);continue}const n="function"==typeof r?r:r.name;if(l.immutable){e.set(i,t.exec(n));continue}o.add(t.watch(n,(t=>e.set(i,t))));continue}const a=l.bind;if(!s||!a){e.set(i,l.default);continue}if("string"==typeof a){const n=t.bind(s,a,(t=>e.set(i,t)));n?o.add(n):e.set(i,l.default);continue}if(!Array.isArray(a)){e.set(i,l.default);continue}const[c,u,f]=a;if(!c||"function"!=typeof u)continue;if(!f){const n=!0===s?"":s;o.add(t.watch(n,(t=>e.set(i,t)))),e.addEvent(c,((...e)=>{t.all[n]=u(...e)}));continue}const d=t.bind(s,"state",(t=>e.set(i,t)));if(!d)continue;o.add(d);const h=t.bindSet(s,"state");h&&e.addEvent(c,((...e)=>{h(u(...e))}))}return()=>{const e=o;o=new Set;for(const t of e)t()}}(h,r,e.attrs,p,a):function(e,t,n){const r=e.tag;let s=new Set;for(const[o,i]of Object.entries(n)){if("function"!=typeof i&&"object"!=typeof i){e.set(o,i);continue}const n="function"==typeof i?i:i.name;if("string"!=typeof r||"input"!==r.toLocaleLowerCase()||"type"!==o.toLocaleLowerCase())s.add(t.watch(n,(t=>e.set(o,t))));else{const r=t.exec(n);e.set(o,r)}}return()=>{const e=s;s=new Set;for(const t of e)t()}}(h,r,e.attrs);for(const[t,n]of Object.entries(e.events)){const e=r.getEvent(n);e&&h.addEvent(t,e)}const m=function(e,t,n){if(!n)return()=>{};let r=new Set;for(const[s,o]of Object.entries(t.bindAll(n)||{}))"function"==typeof o&&r.add(o((t=>e.set(s,t))));for(const[r,s]of Object.entries(t.bindEvents(n)||{}))e.addEvent(r,(e=>s(e)));return()=>{const e=r;r=new Set;for(const t of e)t()}}(h,r,a),b=f?"function"==typeof f.tag?f.tag(d):Me(d,f.tag,f.is):Me(d,e.name,e.is),y=Array.isArray(b)?b[0]:b,v=Array.isArray(b)?b[1]:y;t.insertBefore(y,n);const w=v?ke(v,null,r,e.directives)||Ie(e.children||[],v,null,r,s,((e,t)=>Ue(e,v,null,r,t,o,i,l))):()=>{};return function(e,t,n){if(!(e instanceof Element))return()=>{};let r=new Set;for(const[s,o]of Object.entries(t))o&&(!0!==o?r.add(pe((()=>Boolean(n.exec(o))),(t=>{t?e.classList.add(s):e.classList.remove(s)}),!0)):e.classList.add(s))}(y,e.classes,r),function(e,t,n){if(!(e instanceof HTMLElement||e instanceof SVGElement))return()=>{};let r=new Set;for(const[s,o]of Object.entries(t))r.add(pe((()=>Ee(s,n.exec(o))),(t=>{t?e.style.setProperty(s,...t):e.style.removeProperty(s)}),!0))}(y,e.styles,r),h.mount(),()=>{y.remove(),h.destroy(),g(),w(),m()}}function Ue(e,t,n,r,s,o,i,l){const{directives:a}=e,c=r.child(a.value);if(!c)return()=>{};const u=c.enum(a.enum),f=(n,r)=>Pe(e,t,n,r,s,o,i,l);return!0===u?f(n,c):u instanceof Q?function(e,t,n,r,s){const o=e.insertBefore(document.createComment(""),t);let i=new Map;function l(e){for(const[t,n,r]of e.values())r(),t.remove(),n.remove()}const a=pe((()=>n.children),(function(t){if(!o.parentNode)return;let a=o.nextSibling;const c=i;i=new Map;for(let o of t){const t=c.get(o);if(!t){const t=e.insertBefore(document.createComment(""),a),l=e.insertBefore(document.createComment(""),a),c=s(l,r.setStore(o,n));i.set(o,[t,l,c]);continue}if(c.delete(o),i.set(o,t),a===t[0]){a=t[1].nextSibling;continue}let l=t[0];for(;l&&l!==t[1];){const t=l;l=l.nextSibling,e.insertBefore(t,a)}e.insertBefore(t[1],a)}l(c)}),!0);return()=>{o.remove(),l(i),a()}}(t,n,u,c,f):u instanceof G?function(e,t,n,r,s){const o=[];for(const[e,i]of[...n])o.push(s(t,r.setStore(i,n)));return()=>{for(const e of o)e()}}(0,n,u,c,f):"function"==typeof u?function(e,t,n,r,s){const o=new M.Computed((()=>{const e=n();if("number"==typeof e){const t=Math.floor(e);return t?Array(t).fill(0).map(((e,t)=>[t+1,t,t])):[]}return e&&"object"==typeof e?Array.isArray(e)?e.map(((e,t)=>[e,t,t])):Object.entries(e).map((([e,t],n)=>[t,n,e])):[]})),i=e.insertBefore(document.createComment(""),t);let l=[];function a(e){for(const[t,n,r]of e)r(),t.remove(),n.remove()}const c=pe((()=>o.get()),(function(t){if(!i.parentNode)return;let n=i.nextSibling;const o=l;l=[];for(const[i,a,c]of t){const t=o.findIndex((e=>e[3]===c)),[u]=t>=0?o.splice(t,1):[];if(!u){const t=e.insertBefore(document.createComment(""),n),o=e.insertBefore(document.createComment(""),n),u=new M.State(i),f=new M.State(a),d=s(o,r.setObject({get key(){return c},get value(){return u.get()},get index(){return f.get()}}));l.push([t,o,d,c,u,f]);continue}if(l.push(u),u[4].set(i),u[5].set(a),n===u[0]){n=u[1].nextSibling;continue}let f=u[0];for(;f&&f!==u[1];){const t=f;f=f.nextSibling,e.insertBefore(t,n)}e.insertBefore(u[1],n)}a(o)}),!0);return()=>{i.remove(),a(l),c()}}(t,n,u,c,f):()=>{}}function qe(e,t,n,{component:r,global:s,relate:o}={}){const i=new Oe(e,s),l=Object.create(null),a="function"==typeof o?o:null;return Ie(t,n,null,i,l,((e,t)=>Ue(e,n,null,i,t,[],a,r)))}export{de as Layout,M as Signal,F as Store,he as effect,qe as render,pe as watch};
60
+ function(e){const t=Object.create(L);t.value=e;const n=()=>(d(t),t.value);return n[c]=t,n}(n),l=i[c];if(this[T]=l,l.wrapper=this,s){const t=s.equals;t&&(l.equal=t),l.watched=s[e.subtle.watched],l.unwatched=s[e.subtle.unwatched]}}get(){if(!(0,e.isState)(this))throw new TypeError("Wrong receiver type for Signal.State.prototype.get");return $.call(this[T])}set(t){if(!(0,e.isState)(this))throw new TypeError("Wrong receiver type for Signal.State.prototype.set");if(l)throw new Error("Writes to signals not permitted during Watcher callback");j(this[T],t)}};h=T,p=new WeakSet,e.isComputed=e=>n(p,e),e.Computed=class{constructor(n,s){r(this,p),t(this,h);const o=function(e){const t=Object.create(C);t.computation=e;const n=()=>x(t);return n[c]=t,n}(n),i=o[c];if(i.consumerAllowSignalWrites=!0,this[T]=i,i.wrapper=this,s){const t=s.equals;t&&(i.equal=t),i.watched=s[e.subtle.watched],i.unwatched=s[e.subtle.unwatched]}}get(){if(!(0,e.isComputed)(this))throw new TypeError("Wrong receiver type for Signal.Computed.prototype.get");return x(this[T])}},(o=>{var l,a,c,h;o.untrack=function(e){let t,n=null;try{n=u(null),t=e()}finally{u(n)}return t},o.introspectSources=function(t){var n;if(!(0,e.isComputed)(t)&&!(0,e.isWatcher)(t))throw new TypeError("Called introspectSources without a Computed or Watcher argument");return(null==(n=t[T].producerNode)?void 0:n.map((e=>e.wrapper)))??[]},o.introspectSinks=function(t){var n;if(!(0,e.isComputed)(t)&&!(0,e.isState)(t))throw new TypeError("Called introspectSinks without a Signal argument");return(null==(n=t[T].liveConsumerNode)?void 0:n.map((e=>e.wrapper)))??[]},o.hasSinks=function(t){if(!(0,e.isComputed)(t)&&!(0,e.isState)(t))throw new TypeError("Called hasSinks without a Signal argument");const n=t[T].liveConsumerNode;return!!n&&n.length>0},o.hasSources=function(t){if(!(0,e.isComputed)(t)&&!(0,e.isWatcher)(t))throw new TypeError("Called hasSources without a Computed or Watcher argument");const n=t[T].producerNode;return!!n&&n.length>0};l=T,a=new WeakSet,c=new WeakSet,h=function(t){for(const n of t)if(!(0,e.isComputed)(n)&&!(0,e.isState)(n))throw new TypeError("Called watch/unwatch without a Computed or State argument")},e.isWatcher=e=>n(a,e),o.Watcher=class{constructor(e){r(this,a),r(this,c),t(this,l);let n=Object.create(f);n.wrapper=this,n.consumerMarkedDirty=e,n.consumerIsAlwaysLive=!0,n.consumerAllowSignalWrites=!1,n.producerNode=[],this[T]=n}watch(...t){if(!(0,e.isWatcher)(this))throw new TypeError("Called unwatch without Watcher receiver");s(this,c,h).call(this,t);const n=this[T];n.dirty=!1;const r=u(n);for(const e of t)d(e[T]);u(r)}unwatch(...t){if(!(0,e.isWatcher)(this))throw new TypeError("Called unwatch without Watcher receiver");s(this,c,h).call(this,t);const n=this[T];v(n);for(let e=n.producerNode.length-1;e>=0;e--)if(t.includes(n.producerNode[e].wrapper)){b(n.producerNode[e],n.producerIndexOfThis[e]);const t=n.producerNode.length-1;if(n.producerNode[e]=n.producerNode[t],n.producerIndexOfThis[e]=n.producerIndexOfThis[t],n.producerNode.length--,n.producerIndexOfThis.length--,n.nextProducerIndex--,e<n.producerNode.length){const t=n.producerIndexOfThis[e],r=n.producerNode[e];w(r),r.liveConsumerIndexOfThis[t]=e}}}getPending(){if(!(0,e.isWatcher)(this))throw new TypeError("Called getPending without Watcher receiver");return this[T].producerNode.filter((e=>e.dirty)).map((e=>e.wrapper))}},o.currentComputed=function(){var e;return null==(e=i)?void 0:e.wrapper},o.watched=Symbol("watched"),o.unwatched=Symbol("unwatched")})(e.subtle||(e.subtle={}))})(M||(M={}));const N=(e,t,n,r)=>{const s=new M.State("boolean"==typeof t?t:null);let o;if("function"==typeof n)o=new M.Computed((()=>Boolean(n(e))));else{const e=Boolean(n);o=new M.Computed((()=>e))}const i=()=>{const e=s.get();return null===e?o.get():e},l=r?new M.Computed((()=>r.get()||i())):new M.Computed(i);return[s,l]},k=e=>"string"==typeof e&&e||null,I=e=>"number"==typeof e&&e||null,P=e=>e instanceof RegExp?e:null,U=Boolean;function q(e){if("number"==typeof e||"string"==typeof e)return{label:e,value:e};if(!e||"object"!=typeof e)return null;const{children:t,label:n,value:r}=e,s=Array.isArray(t)?t.map(q).filter(U):[];return s.length?{children:s,label:n,value:r}:"number"==typeof r||"string"==typeof r?{label:n,value:r}:null}const B=e=>{if(!e||!Array.isArray(e))return null;const t=e.map(q).filter(U);return t.length?t:null};function R(e,t,n,r){const s=new M.State(t(n));let o;if("function"==typeof r){const n=r;o=new M.Computed((()=>t(n(e))))}else{const e=t(r);o=new M.Computed((()=>e))}const i=new M.Computed((()=>{const e=s.get();return null===e?o.get():e}));return[s,i]}const V=Symbol();function D(e){const t={[V]:e};for(const[n,r]of e)Object.defineProperty(t,n,{get:()=>r.ref,configurable:!1,enumerable:!0});return Object.defineProperty(t,V,{get:()=>e,configurable:!1,enumerable:!0}),t}let W=null,_=null,K=Object.create(null);function H(e,t){const n=e.type;let r=F;if(!e.array||_&&t?.parent instanceof _)if("string"==typeof n){const e=K[n];e&&(r=e)}else n&&"object"==typeof n&&W&&(r=W);else _&&(r=_);return new r(e,t)}function Y(e){return e?e instanceof Error?e.message:"string"!=typeof e?"":e:""}function z(e,...t){const n=t.flat().filter((e=>"function"==typeof e));if(!n.length)return[()=>Promise.resolve([]),new M.Computed((()=>[])),()=>{}];const r=new M.State([]);let s=null;return[function(){s?.abort(),s=new AbortController;const t=s.signal;return r.set([]),Promise.all(n.map((n=>async function(t,n){let s=[];try{s.push(await t(e,n))}catch(e){s.push(e)}const o=s.flat().map(Y).filter(Boolean);return!n.aborted&&o.length&&r.set([...r.get(),...o]),o}(n,t)))).then((e=>e.flat()))},new M.Computed((()=>r.get())),()=>{s?.abort(),r.set([])}]}class F{#e=new Map;emit(e,t){const n="number"==typeof e?String(e):e,r=this.#e;let s=!1;for(const e of[...r.get(n)||[]])s=!1===e(t,this)||s;return!s}listen(e,t){const n=t.bind(this),r=this.#e,s="number"==typeof e?String(e):e;let o=r.get(s);return o||(o=new Set,r.set(s,o)),o.add(n),()=>{o?.delete(n)}}static create(e,t={}){return H({type:e},{...t,parent:null})}static setStore(e,t){return function(e,t){K[e]=t}(e,t)}#t=!1;get null(){return this.#t}get kind(){return""}#n=null;get ref(){return this.#n||D(this)}constructor(e,{null:t,state:n,ref:r,setValue:s,setState:o,convert:i,onUpdate:l,onUpdateState:a,validator:c,validators:u,index:f,length:d,new:h,parent:p,hidden:g,clearable:m,required:b,disabled:y,readonly:v,label:w,description:x,placeholder:O,min:S,max:E,step:C,minLength:A,maxLength:$,pattern:j,values:L}={}){this.schema=e,this.#r.set("object"==typeof n&&n||{});const T=p instanceof F?p:null;T&&(this.#s=T,this.#o=T.#o),this.#i=e.type,this.#l=e.meta,this.#a=e.component;const U=new M.State(Boolean(h));this.#c=U;const q=T?new M.Computed((()=>T.#u.get()||U.get())):new M.Computed((()=>U.get()));this.#u=q;const V=Boolean(e.immutable),W=!1!==e.creatable;this.#f=V,this.#d=W;const _=e.readonly,K=new M.State("boolean"==typeof v?v:null);let H;if("function"==typeof _)H=new M.Computed((()=>Boolean(_(this))));else{const e=Boolean(_);H=new M.Computed((()=>e))}const G=()=>{if(q.get()?!W:V)return!0;const e=K.get();return null===e?H.get():e},Q=T?T.#h:null;this.#p=K,this.#h=Q?new M.Computed((()=>Q.get()||G())):new M.Computed(G),[this.#g,this.#m]=N(this,g,e.hidden,T?T.#m:null),[this.#b,this.#y]=N(this,m,e.clearable,T?T.#y:null),[this.#v,this.#w]=N(this,b,e.required,T?T.#w:null),[this.#x,this.#O]=N(this,y,e.disabled,T?T.#O:null),[this.#S,this.#E]=R(this,k,w,e.label),[this.#C,this.#A]=R(this,k,x,e.description),[this.#$,this.#j]=R(this,k,O,e.placeholder),[this.#L,this.#T]=R(this,I,S,e.min),[this.#M,this.#N]=R(this,I,E,e.max),[this.#k,this.#I]=R(this,I,C,e.step),[this.#P,this.#U]=R(this,I,A,e.minLength),[this.#q,this.#B]=R(this,I,$,e.maxLength),[this.#R,this.#V]=R(this,P,j,e.pattern),[this.#D,this.#W]=R(this,B,L,e.values);const Z=function(e,...t){const n=t.flat().filter((e=>"function"==typeof e));return n.length?new M.Computed((()=>{const t=[];for(const r of n)try{t.push(r(e))}catch(e){t.push(e)}return t.flat().map(Y).filter(Boolean)})):new M.Computed((()=>[]))}(this,e.validator,c),[X,J,ee]=z(this,e.validators?.change,u?.change),[te,ne,re]=z(this,e.validators?.blur,u?.blur);if(this.listen("change",(()=>{X()})),this.listen("blur",(()=>{te()})),this.#_=function(...e){const t=e.filter(Boolean);return new M.Computed((()=>t.flatMap((e=>e.get()))))}(Z,J,ne),this.#K=Z,this.#H=X,this.#Y=te,this.#z=ee,this.#F=re,d instanceof M.State||d instanceof M.Computed?this.#G=d:this.#G=new M.State(d||0),t)return this.#t=!0,void(this.#n=D(this));this.#n=r||null,this.#Q=l||null,this.#Z=a||null,this.#X="function"==typeof s?s:null,this.#J="function"==typeof o?o:null,this.#ee="function"==typeof i?i:null,this.#te.set(f??"");for(const[t,n]of Object.entries(e.events||{}))"function"==typeof n&&this.listen(t,n)}#X=null;#J=null;#ee=null;#Q=null;#Z=null;#s=null;#o=this;#i;#l;#a;get store(){return this}get parent(){return this.#s}get root(){return this.#o}get type(){return this.#i}get meta(){return this.#l}get component(){return this.#a}#G;get length(){return this.#G.get()}#te=new M.State("");get index(){return this.#te.get()}set index(e){this.#te.set(e)}get no(){if(this.#t)return"";const e=this.index;return"number"==typeof e?e+1:e}#d=!0;get creatable(){return this.#d}#f=!1;get immutable(){return this.#f}#u;#c;get selfNew(){return this.#c.get()}set selfNew(e){this.#c.set(Boolean(e))}get new(){return this.#u.get()}set new(e){this.#c.set(Boolean(e))}#g;#m;get selfHidden(){return this.#g.get()}set selfHidden(e){this.#g.set("boolean"==typeof e?e:null)}get hidden(){return this.#m.get()}set hidden(e){this.#g.set("boolean"==typeof e?e:null)}#b;#y;get selfClearable(){return this.#b.get()}set selfClearable(e){this.#b.set("boolean"==typeof e?e:null)}get clearable(){return this.#y.get()}set clearable(e){this.#b.set("boolean"==typeof e?e:null)}#v;#w;get selfRequired(){return this.#v.get()}set selfRequired(e){this.#v.set("boolean"==typeof e?e:null)}get required(){return this.#w.get()}set required(e){this.#v.set("boolean"==typeof e?e:null)}#x;#O;get selfDisabled(){return this.#x.get()}set selfDisabled(e){this.#x.set("boolean"==typeof e?e:null)}get disabled(){return this.#O.get()}set disabled(e){this.#x.set("boolean"==typeof e?e:null)}#p;#h;get selfReadonly(){return this.#p.get()}set selfReadonly(e){this.#p.set("boolean"==typeof e?e:null)}get readonly(){return this.#h.get()}set readonly(e){this.#p.set("boolean"==typeof e?e:null)}#S;#E;get selfLabel(){return this.#S.get()}set selfLabel(e){this.#S.set(k(e))}get label(){return this.#E.get()}set label(e){this.#S.set(k(e))}#C;#A;get selfDescription(){return this.#C.get()}set selfDescription(e){this.#C.set(k(e))}get description(){return this.#A.get()}set description(e){this.#C.set(k(e))}#$;#j;get selfPlaceholder(){return this.#$.get()}set selfPlaceholder(e){this.#$.set(k(e))}get placeholder(){return this.#j.get()}set placeholder(e){this.#$.set(k(e))}#L;#T;get selfMin(){return this.#L.get()}set selfMin(e){this.#L.set(I(e))}get min(){return this.#T.get()}set min(e){this.#L.set(I(e))}#M;#N;get selfMax(){return this.#M.get()}set selfMax(e){this.#M.set(I(e))}get max(){return this.#N.get()}set max(e){this.#M.set(I(e))}#k;#I;get selfStep(){return this.#k.get()}set selfStep(e){this.#k.set(I(e))}get step(){return this.#I.get()}set step(e){this.#k.set(I(e))}#P;#U;get selfMinLength(){return this.#P.get()}set selfMinLength(e){this.#P.set(I(e))}get minLength(){return this.#U.get()}set minLength(e){this.#P.set(I(e))}#q;#B;get selfMaxLength(){return this.#q.get()}set selfMaxLength(e){this.#q.set(I(e))}get maxLength(){return this.#B.get()}set maxLength(e){this.#q.set(I(e))}#R;#V;get selfPattern(){return this.#R.get()}set selfPattern(e){this.#R.set(P(e))}get pattern(){return this.#V.get()}set pattern(e){this.#R.set(P(e))}#D;#W;get selfValues(){return this.#D.get()}set selfValues(e){this.#D.set(B(e))}get values(){return this.#W.get()}set values(e){this.#D.set(B(e))}#_;#K;#H;#Y;#z;#F;get errors(){return this.#_.get()}get error(){return this.#_.get()[0]}*[Symbol.iterator](){}child(e){return null}#ne=!1;#re=new M.State(null);#se=new M.State(this.#re.get());#r=new M.State(null);get changed(){return this.#se.get()===this.#re.get()}get value(){return this.#se.get()}set value(e){const t=this.#X?.(e),n=void 0===t?e:t;this.#se.set(n),this.#ne||this.#re.set(n),this.#Q?.(n,this.#te.get(),this),this.#oe()}get state(){return this.#r.get()}set state(e){const t=this.#J?.(e),n=void 0===t?e:t;this.#r.set(n),this.#Z?.(n,this.#te.get(),this),this.#oe()}#oe(){this.#ie||(this.#ie=!0,queueMicrotask((()=>{const e=this.#se.get(),t=this.#r.get();this.#le(e,t)})))}reset(e=this.#re.get()){this.#ae(e)}#ae(e){const t=this.#X?.(e),n=void 0===t?e:t;if(this.#z(),this.#F(),this.#ne=!0,!n||"object"!=typeof n){for(const[,e]of this)e.#ae(null);return this.#se.set(n),this.#re.set(n),n}const r=Array.isArray(n)?[...n]:{...n};for(const[e,t]of this)r[e]=t.#ae(r[e]);return this.#se.set(r),this.#re.set(r),r}#ie=!1;#ce(e,t){const[n,r]=this.#ee?.(e,t)||[e,t];return this.#se.get()===n&&this.#r.get()===r?[n,r]:(this.#se.set(n),this.#r.set(r),this.#le(n,r))}#le(e,t){this.#ie=!1;let n=e;if(e&&"object"==typeof e){let r=Array.isArray(e)?[...e]:{...e},s=Array.isArray(e)?Array.isArray(t)?[...t]:[]:{...t},o=!1;for(const[n,i]of this){const l=e[n],a=t?.[n],[c,u]=i.#ce(l,a);l!==c&&(r[n]=c,o=!0),a!==u&&(s[n]=u,o=!0)}o&&(t=s,n=e=r,this.#se.set(e),this.#r.set(s))}return this.#ne||(this.#ne=!0,this.#re.set(n)),[e,t]}validate(e){if(!Array.isArray(e))return Promise.all([this.#K.get(),this.#H(),this.#Y()]).then((e=>{const t=e.flat();return t.length?t:null}));const t=[this.validate().then((t=>t?.length?[{path:[...e],store:this,errors:t}]:[]))];for(const[n,r]of this)t.push(r.validate([...e,n]));return Promise.all(t).then((e=>e.flat()))}}class G extends F{get kind(){return"object"}#ue;*[Symbol.iterator](){yield*Object.entries(this.#ue)}child(e){return this.#ue[e]||null}constructor(e,{parent:t,index:n,new:r,onUpdate:s,onUpdateState:o}={}){const i=Object.entries(e.type);super(e,{parent:t,index:n,new:r,onUpdate:s,onUpdateState:o,length:i.length,setValue:e=>"object"==typeof e?e:null,setState:e=>"object"==typeof e?e:null,convert:(e,t)=>["object"==typeof e?e:{},"object"==typeof t?t:{}]});const l=Object.create(null),a={parent:this,onUpdate:(e,t,n)=>{n===this.#ue[t]&&(this.value={...this.value,[t]:e})},onUpdateState:(e,t,n)=>{n===this.#ue[t]&&(this.state={...this.state,[t]:e})}};for(const[e,t]of i)l[e]=H(t,{...a,index:e});this.#ue=l}}W=G;class Q extends F{#fe=()=>{throw new Error};#ue;get children(){return[...this.#ue.get()]}*[Symbol.iterator](){return yield*[...this.#ue.get().entries()]}child(e){const t=this.#ue.get();return"number"==typeof e&&e<0?t[t.length+e]||null:t[Number(e)]||null}get kind(){return"array"}constructor(e,{parent:t,onUpdate:n,onUpdateState:r,index:s,new:o}={}){const i=new M.State([]),l=e=>{const t=Array.isArray(e)&&e.length||0,n=[...i.get()],r=n.length;for(let e=n.length;e<t;e++)n.push(this.#fe(e));r!==t&&i.set(n)};super(e,{index:s,new:o,parent:t,length:new M.Computed((()=>i.get().length)),state:[],setValue:e=>Array.isArray(e)?e:null==e?null:[e],setState:e=>Array.isArray(e)?e:null==e?null:[e],convert(e,t){const n=Array.isArray(e)?e:null==e?null:[e];return l(n),[n,Array.isArray(t)?t:null==e?[]:[t]]},onUpdate:(e,t,r)=>{l(e),n?.(e,t,r)},onUpdateState:r}),this.#ue=i;const a={parent:this,onUpdate:(e,t,n)=>{if(i.get()[t]!==n)return;const r=[...this.value||[]];r.length<t&&(r.length=t),r[t]=e,this.value=r},onUpdateState:(e,t,n)=>{if(i.get()[t]!==n)return;const r=[...this.state||[]];r.length<t&&(r.length=t),r[t]=e,this.state=r}};this.#fe=(t,n)=>{const r=H(e,{...a,index:t,new:n});return r.index=t,r}}insert(e,t=null,n){const r=this.value||[];if(!Array.isArray(r))return!1;const s=[...this.#ue.get()],o=Math.max(0,Math.min(Math.floor(e),s.length)),i=this.#fe(o,n);i.new=!0,s.splice(o,0,i);for(let t=e+1;t<s.length;t++)s[t].index=t;const l=[...r];l.splice(o,0,t);const a=this.state;if(Array.isArray(a)){const e=[...a];e.splice(o,0,{}),this.state=e}return this.#ue.set(s),this.value=l,!0}add(e=null){return this.insert(this.#ue.get().length,e)}remove(e){const t=this.value;if(!Array.isArray(t))return;const n=[...this.#ue.get()],r=Math.max(0,Math.min(Math.floor(e),n.length)),[s]=n.splice(r,1);if(!s)return;for(let t=e;t<n.length;t++)n[t].index=t;const o=[...t],[i]=o.splice(r,1),l=this.state;if(Array.isArray(l)){const e=[...this.state];e.splice(r,1),this.state=e}return this.#ue.set(n),this.value=o,i}move(e,t){const n=this.value;if(!Array.isArray(n))return!1;const r=[...this.#ue.get()],[s]=r.splice(e,1);if(!s)return!1;r.splice(t,0,s);let o=Math.min(e,t),i=Math.max(e,t);for(let e=o;e<=i;e++)r[e].index=e;const l=[...n],[a]=l.splice(e,1);l.splice(t,0,a);const c=this.state;if(Array.isArray(c)){const n=[...c],[r={}]=n.splice(e,1);t<=n.length?n.splice(t,0,r):n[t]=r,this.state=n}return this.#ue.set(r),this.value=l,!0}exchange(e,t){const n=this.value;if(!Array.isArray(n))return!1;const r=[...this.#ue.get()],s=r[e],o=r[t];if(!s||!o)return!1;r[t]=s,r[e]=o,s.index=t,o.index=e;const i=[...n],l=i[e],a=i[t];i[t]=l,i[e]=a;const c=this.state;if(Array.isArray(c)){const n=[...c],r=n[e],s=n[t];n[t]=r,n[e]=s,this.state=n}return this.#ue.set(r),this.value=i,!0}}!function(e){_=e}(Q);const Z={CALC:"no `createCalc` option, no expression parsing support",EVENT:"no `createEvent`, options, no event parsing support",CLOSE:(e,t)=>`end tag name: ${e} is not match the current start tagName: ${t}`,UNCLOSE:e=>`end tag name: ${e} maybe not complete`,QUOTE:e=>`attribute value no end '${e}' match`,CLOSE_SYMBOL:"elements closed character '/' and '>' must be connected to",UNCOMPLETED:(e,t)=>t?`end tag name: ${e} is not complete: ${t}`:`end tag name: ${e} maybe not complete`,ENTITY:e=>`entity not found: ${e}`,SYMBOL:e=>`unexpected symbol: ${e}`,TAG:e=>`invalid tagName: ${e}`,ATTR:e=>`invalid attribute: ${e}`,EQUAL:"attribute equal must after attrName",ATTR_VALUE:'attribute value must after "="',EOF:"unexpected end of file"};class X extends Error{constructor(e,...t){const n=Z[e];super("function"==typeof n?n(...t):n),this.code=e}}const J=/^(?<decorator>[:@!+*\.?]|style:|样式:)?(?<name>-?[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_:\d\.]*)$/u,ee=/^(?<name>[a-zA-Z$\p{Unified_Ideograph}_][\da-zA-Z$\p{Unified_Ideograph}_]*)?$/u;function te(e,t,n){const{attrs:r,directives:s,events:o,classes:i,styles:l,vars:a,aliases:c,params:u}=e;return function(e,f){const d=J.exec(e.replace(/./g,".").replace(/:/g,":").replace(/@/g,"@").replace(/+/g,"+").replace(/-/g,"-").replace(/[*×]/g,"*").replace(/!/g,"!"))?.groups;if(!d)throw new X("ATTR",e);const{name:h}=d,p=d.decorator?.toLowerCase();if(p){if(":"===p)r[h]=ee.test(f)?{name:f}:t(f);else if("."===p)i[h]=!f||(ee.test(f)?f:t(f));else if("style:"===p)l[h]=ee.test(f)?f:t(f);else if("@"===p)o[h]=ee.test(f)?f:n(f);else if("+"===p)a[h]=f?ee.test(f)?f:t(f):"";else if("*"===p)c[h]=ee.test(f)?f:t(f);else if("?"===p)u[h]=ee.test(f)?f:t(f);else if("!"===p){const e=h.toString();switch(e){case"fragment":s.fragment=f||!0;break;case"else":s.else=!0;break;case"enum":s.enum=!f||(ee.test(f)?f:t(f));break;case"if":case"text":case"html":s[e]=ee.test(f)?f:t(f);break;case"template":s.template=f;break;case"bind":s.bind=f||!0;break;case"value":s.value=f;break;case"comment":s.comment=f}}}else r[h]=f}}function ne(e,t){return{name:e,is:t,children:[],attrs:Object.create(null),events:Object.create(null),directives:Object.create(null),classes:Object.create(null),styles:Object.create(null),vars:Object.create(null),aliases:Object.create(null),params:Object.create(null)}}var re={lt:"<",gt:">",amp:"&",quot:'"',apos:"'",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",times:"×",divide:"÷",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",euro:"€",trade:"™",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"};const se=/^(?<name>[\w\p{Unified_Ideograph}_][-\.\|:|d\w\p{Unified_Ideograph}_:]*)(?:|(?<is>[\w\p{Unified_Ideograph}_][-\.\|:|d\w\p{Unified_Ideograph}_]*))?$/u;function oe(e){return"="!==e&&"/"!==e&&">"!==e&&e&&"'"!==e&&'"'!==e&&!function(e){return"0x80"===e||e<=" "}(e)}function ie(e,t,n,r){let s=r[n];return null==s&&(s=e.lastIndexOf("</"+n+">"),s<t&&(s=e.lastIndexOf("</"+n)),r[n]=s),s<t}function le(...e){console.error(new X(...e))}function ae(e){const t=e.slice(1,-1);return"#"===t.charAt(0)?String.fromCodePoint(parseInt(t.substring(1).replace("x","0x"))):t in re?re[t]:(le("ENTITY",e),e)}function ce(e){return("<"==e?"&lt;":">"==e&&"&gt;")||"&"==e&&"&amp;"||'"'==e&&"&quot;"||"&#"+e.charCodeAt()+";"}function*ue(e,t=0){const{attrs:n,events:r,directives:s,children:o,is:i,name:l,params:a,classes:c,styles:u,aliases:f,vars:d}=e,h=t>0?"".padEnd(t,"\t"):"";yield h,yield*["<",l||"-"],i&&(yield*["|",i]);for(const[e,t]of Object.entries(a)){if(null==t)continue;const n="function"==typeof t?String(t):t;yield*[" ?",e],n&&"string"==typeof n&&(yield*['="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(s)){if(!1===t||null==t)continue;const n="function"==typeof t?String(t):t;yield*[" !",e],n&&"string"==typeof n&&(yield*['="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(f)){if(null==t)continue;const n="function"==typeof t?String(t):t;yield*[" *",e],n&&"string"==typeof n&&(yield*['="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(d)){if(null==t)continue;const n="function"==typeof t?String(t):t;yield*[" +",e],n&&"string"==typeof n&&(yield*['="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(n)){if(null==t)continue;if("string"==typeof t){yield*[" ",e],t&&(yield*['="',t.replace(/[<&"]/g,ce),'"']);continue}const n="function"==typeof t?String(t):"object"==typeof t?t.name:t;n&&"string"==typeof n&&(yield*[" :",e,'="',n.replace(/[<&"]/g,ce)||"",'"'])}for(const[e,t]of Object.entries(r)){if(null==t)continue;const n="function"==typeof t?String(t):t;n&&"string"==typeof n&&(yield*[" @",e,'="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(c)){if(null==t||0==t)continue;const n="function"==typeof t?String(t):t;yield*[" .",e],n&&"string"==typeof n&&(yield*[" .",e,'="',n.replace(/[<&"]/g,ce),'"'])}for(const[e,t]of Object.entries(u)){if(null==t)continue;const n="function"==typeof t?String(t):t;n&&"string"==typeof n&&(yield*[" style:",e,'="',n.replace(/[<&"]/g,ce),'"'])}if(!o.length)return yield"/>",void(t>=0&&(yield"\n"));if(1===o.length){const[e]=o;if("string"==typeof e&&e.length<80&&!e.includes("\n"))return yield">",yield*[e.replace(/[<&\t]/g,ce).replace(/]]>/g,"]]&gt;")],yield*["</",l,">"],void(t>=0&&(yield"\n"))}yield">",t>=0&&(yield"\n"),yield*fe(o,t>=0?t+1:-1),yield*[h,"</",l,">"],t>=0&&(yield"\n")}function*fe(e,t=0){if(!e.length)return"";const n=t>0?"".padEnd(t,"\t"):"";for(const r of e)if("string"==typeof r){let e=r.replace(/[<&\t]/g,ce).replace(/]]>/g,"]]&gt;");n&&(e=e.replace(/(?<=^|\n)/g,n)),yield e,t>=0&&(yield"\n")}else yield*ue(r,t)}var de=Object.freeze({__proto__:null,parse:function(e,{createCalc:t=()=>{throw new X("CALC")},createEvent:n=()=>{throw new X("EVENT")},simpleTag:r=new Set}={}){const s=[],o={children:s},i=[];let l=null,a=o;function c(){l=i.pop()||null,a=l||o}function u(e){(e=e.replace(/^\n|(?<=\n)\t+|\n\t*$/g,""))&&a.children.push(e)}let f={},d=0;function h(t){if(t<=d)return;u(e.substring(d,t).replace(/&#?\w+;/g,ae)),d=t}for(;;){const p=e.indexOf("<",d);if(p<0){const E=e.substring(d);E.match(/^\s*$/)||u(E);break}if(p>d&&h(p),"/"===e.charAt(p+1)){d=e.indexOf(">",p+3);let C=e.substring(p+2,d);if(d<0?(C=e.substring(p+2).replace(/[\s<].*/,""),le("UNCOMPLETED",C,l?.name),d=p+1+C.length):C.match(/\s</)&&(C=C.replace(/[\s<].*/,""),le("UNCOMPLETED",C),d=p+1+C.length),l){const A=l.name;if(A===C)c();else{if(A.toLowerCase()!=C.toLowerCase())throw new X("CLOSE",C,l.name);c()}}d++;continue}function g(t){let n=d+1;if(d=e.indexOf(t,n),d<0)throw new X("QUOTE",t);const r=e.slice(n,d).replace(/&#?\w+;/g,ae);return d++,r}function m(){let t=e.charAt(d);for(;t<=" "||"€"===t;t=e.charAt(++d));return t}function b(){let t=d,n=e.charAt(d);for(;oe(n);)d++,n=e.charAt(d);return e.slice(t,d)}d=p+1;let y=e.charAt(d);switch(y){case"=":throw new X("EQUAL");case'"':case"'":throw new X("ATTR_VALUE");case">":case"/":throw new X("SYMBOL",y);case"":throw new X("EOF")}const v=b(),w=se.exec(v)?.groups;if(!w)throw new X("TAG",v);i.push(l),l=ne(w.name,w.is),a.children.push(l),a=l;const x=te(l,t,n);let O=!0,S=!1;e:for(;O;){let $=m();switch($){case"":le("EOF"),d++;break e;case">":d++;break e;case"/":S=!0;break e;case'"':case"'":throw new X("ATTR_VALUE");case"=":throw new X("SYMBOL",$)}const j=b();if(!j){le("EOF"),d++;break e}switch($=m(),$){case"":le("EOF"),d++;break e;case">":x(j,""),d++;break e;case"/":x(j,""),S=!0;break e;case"=":d++;break;case"'":case'"':x(j,g($));continue;default:x(j,"");continue}switch($=m(),$){case"":x(j,""),le("EOF"),d++;break e;case">":x(j,""),d++;break e;case"/":x(j,""),S=!0;break e;case"'":case'"':x(j,g($));continue}x(j,b())}if(S){for(;;){d++;const L=e.charAt(d);if("/"!==L&&!(L<=" "||"€"===L))break}switch(e.charAt(d)){case"=":throw new X("EQUAL");case'"':case"'":throw new X("ATTR_VALUE");case"":le("EOF");break;case">":d++;break;default:throw new X("CLOSE_SYMBOL")}c()}else(r.has(v)||ie(e,d,v,f))&&c()}return s},stringify:function(e,t){const n=t?0:-1;return Array.isArray(e)?[...fe(e,n)].join(""):[ue(e,n)].join()}});function he(e){let t=!0;const n=new M.subtle.Watcher((()=>{t&&(t=!1,queueMicrotask((()=>{t=!0;for(const e of n.getPending())e.get();n.watch()})))})),r=new M.Computed(e);return n.watch(r),r.get(),()=>{n.unwatch(r)}}function pe(e,t,n){let r,s=!1;return he((()=>{const o=e();if(!s)return s=!0,r=o,void(n&&t(o));Object.is(o,r)||(r=o,t(o))}))}const ge=new Set(Object.keys({type:!0,meta:!0,component:!0,kind:!0,value:!0,state:!0,store:!0,parent:!0,root:!0,ref:!0,schema:!0,new:!0,readonly:!0,creatable:!0,immutable:!0,changed:!0,required:!0,clearable:!0,hidden:!0,disabled:!0,label:!0,description:!0,placeholder:!0,min:!0,max:!0,step:!0,minLength:!0,maxLength:!0,pattern:!0,values:!0,null:!0,index:!0,no:!0,length:!0,error:!0,errors:!0}));function*me(e,t="",n="$"){yield[`${t}`,{get:()=>e.value,set:t=>e.value=t,store:e}];for(const r of ge)yield[`${t}${n}${r}`,{get:()=>e[r]}];yield[`${t}${n}value`,{get:()=>e.value,set:t=>e.value=t}],yield[`${t}${n}state`,{get:()=>e.state,set:t=>e.state=t}],yield[`${t}${n}reset`,{exec:()=>e.reset()}],yield[`${t}${n}validate`,{exec:t=>e.validate(t?[]:null)}],e instanceof Q&&(yield[`${t}${n}insert`,{exec:(t,n)=>e.insert(t,n)}],yield[`${t}${n}add`,{exec:t=>e.add(t)}],yield[`${t}${n}remove`,{exec:t=>e.remove(t)}],yield[`${t}${n}move`,{exec:(t,n)=>e.move(t,n)}],yield[`${t}${n}exchange`,{exec:(t,n)=>e.exchange(t,n)}])}function be(e,t,n){for(const[n,r]of t){for(const[t,s]of me(r,n))e[t]=s;for(const[t,s]of me(r,n,"$$"))e[t]=s}}const ye={value$:{calc:e=>e?.[V].value},state$:{calc:e=>e?.[V].state}};var ve=Object.getOwnPropertyDescriptors(ye);function we(e){if(!e)return!1;const t=e.indexOf("$");return t<0||(e.indexOf("$",t+2)>0||"$"===e[0]&&"_$".includes(e[1]))}function xe(e,t){Object.defineProperty(t,"$store",{value:e,writable:!1,configurable:!0,enumerable:!1}),Object.defineProperty(t,"$root",{value:e.root,writable:!1,configurable:!0,enumerable:!1})}class Oe{exec(e){if("string"==typeof e){const t=this.#de[e];if("function"!=typeof t?.get)return;return t.get()}if("function"==typeof e)return e(this.getters)}watch(e,t){return pe((()=>this.exec(e)),t,!0)}enum(e){if(!e)return!0;if(!0===e)return this.store;if("function"==typeof e)return()=>e(this.getters);if("string"!=typeof e)return null;const t=this.#de[e];if("function"!=typeof t?.get)return null;const n=t.store;return n instanceof F?n:t.get}getStore(e){if(!e)return null;const t=this.#de[!0===e?"":e];return t?.get&&t.store||null}bind(e,t,n){const r=this.#de[!0===e?"":e];if(!r?.get)return;const{store:s}=r;return s?ge.has(t)?pe((()=>s[t]),n,!0):void 0:"value"===t?pe((()=>r.get()),n,!0):void 0}bindAll(e){const t=this.#de[!0===e?"":e];if(!t?.get)return;const{store:n}=t;if(!n){const e=t.get;if("function"!=typeof e)return;return{$value:t=>pe(e,t,!0)}}return Object.fromEntries([...ge].map((e=>[`$${e}`,t=>pe((()=>n[e]),t,!0)])))}bindSet(e,t){const n=this.#de[!0===e?"":e];if(!n?.get)return;const{store:r}=n;if(r)switch(t){case"value":return e=>{r.value=e};case"state":return e=>{r.state=e}}}bindEvents(e){const t=this.#de[!0===e?"":e];if(!t?.get)return;const{store:n}=t;if(!n){const e=t.set;if("function"!=typeof e)return;return{$value:e}}return{$value:e=>{n.value=e},$state:e=>{n.state=e},$input:e=>{n.emit("input",e)},$change:e=>{n.emit("change",e)},$click:e=>{n.emit("click",e)},$focus:e=>{n.emit("focus",e)},$blur:e=>{n.emit("blur",e)},$reset:e=>{n.reset()},$validate:e=>{n.validate(e?[]:null)}}}getEvent(e){if("function"==typeof e)return e;const t=this.#de[e];if(!t)return null;const{exec:n,calc:r}=t;return"function"==typeof n?n:"function"==typeof r?r:null}constructor(e,t){if(this.store=e,t instanceof Oe){this.#he=t.#he;const e=this.#pe;for(const[n,r]of Object.entries(t.#pe))e[n]=r;const n=this.#ge;for(const[e,r]of Object.entries(t.#ge))n[e]=r}else be(this.#pe,e),this.#he=function(e){const t=Object.create(null,ve);if(!e||"object"!=typeof e)return t;for(const[n,r]of Object.entries(e)){if(!we(n))continue;if(!r||"object"!=typeof r)continue;if(r instanceof F){for(const[e,s]of me(r,n))t[e]=s;continue}const{get:e,set:s,exec:o,calc:i}=r;"function"!=typeof e?"function"!=typeof i?"function"!=typeof o||(t[n]={exec:o}):t[n]={calc:i}:t[n]="function"==typeof s?{get:e,set:s}:{get:e}}return t}(t)}#he;#pe=Object.create(null);#ge=Object.create(null);store;#me=null;#s=null;#be=null;get#de(){const e=this.#be;if(e)return e;const t=Object.create(null,Object.getOwnPropertyDescriptors({...this.#pe,...this.#he,...this.#ge})),n=this.store,r=this.#s,s=this.#me;if(s)for(const e of Object.keys(s))t[`$${e}`]={get:()=>s[e]};else{for(const[e,r]of me(n))t[e]=r;for(const[e,s]of function*(e,t,n="",r="$"){if(!(e instanceof Q))return yield[`${n}${r}upMovable`,{get:()=>!1}],void(yield[`${n}${r}downMovable`,{get:()=>!1}]);yield[`${n}${r}upMovable`,{get:()=>{const e=t.index;return"number"==typeof e&&!(e<=0)}}],yield[`${n}${r}downMovable`,{get:()=>{const n=t.index;return"number"==typeof n&&!(n>=e.length-1)}}],yield[`${n}${r}remove`,{exec:()=>e.remove(Number(t.index))}],yield[`${n}${r}upMove`,{exec:()=>{const n=t.index;"number"==typeof n&&(n<=0||e.move(n,n-1))}}],yield[`${n}${r}downMove`,{exec:()=>{const n=t.index;"number"==typeof n&&(n>=e.length-1||e.move(n,n+1))}}]}(r,n))t[e]=s}return this.#be=t,t}setStore(e,t){const n=new Oe(e,this);return t&&(n.#s=t),be(n.#pe,e),n}child(e){if(!e)return this;const t=this.store.child(e);if(!t)return null;const n=new Oe(t,this);return be(n.#pe,t),n}params({params:e},{attrs:t},n,r){let s=this.store;if(!0===r)s=n.store;else if(r){const e=n.#de[r],t=e?.get&&e.store;t&&(s=t)}if(0===Object.keys(e).length)return this;const o=new Oe(s,this);o.#s=this.#s,o.#me=this.#me;const i=o.#ge,l=o.#de;for(const[r,s]of Object.entries(e)){const e=r in t?t[r]:null;if("string"!=typeof e){if(e&&"object"==typeof e){const t=n.#de[e.name];if(!t?.get)continue;if(!t.store){i[r]=l[r]=t;continue}for(const[e,n]of me(t.store,r))i[e]=l[e]=n;continue}if("function"==typeof e){const t=new M.Computed((()=>e(n.getters)));i[r]=l[r]={get:()=>t.get()};continue}if("function"==typeof s){const e=o.getters;o.#ye=null;const t=new M.Computed((()=>s(e)));i[r]=l[r]={get:()=>t.get()};continue}{const e=l[s];if(!e?.get)continue;if(!e.store){i[r]=l[r]=e;continue}for(const[t,n]of me(e.store,r))i[t]=l[t]=n;continue}}i[r]=l[r]={get:()=>e}}return o}setObject(e){const t=new Oe(this.store,this);return t.#me=e,t}set(e,t){if(Object.keys(e).length+Object.keys(t).length===0)return this;const n=new Oe(this.store,this);n.#s=this.#s,n.#me=this.#me;const r=n.#ge,s=n.#de;for(const[t,o]of Object.entries(e)){if("function"==typeof o){const e=n.getters;n.#ye=null;const i=new M.Computed((()=>o(e)));r[t]=s[t]={get:()=>i.get()};continue}const e=s[o];if(e)if(e.get&&e.store)for(const[n,o]of me(e.store,t))r[n]=s[n]=o;else r[t]=s[t]=e}for(const[e,o]of Object.entries(t)){const t=new M.State(null);if("function"==typeof o){const e=n.settable;n.#ve=null,t.set(o(e))}else if(o&&"string"==typeof o){const e=s[o];if(!e?.get)continue;t.set(e.get())}r[e]=s[e]={get:()=>t.get(),set:e=>{t.set(e)}}}return n}#we=null;get all(){const e=this.#we;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#de))n.get?Object.defineProperty(t,e,{get:n.get,set:n.set,configurable:!0,enumerable:!0}):n.calc?Object.defineProperty(t,e,{value:n.calc,writable:!1,configurable:!0,enumerable:!1}):Object.defineProperty(t,e,{value:n.exec,writable:!1,configurable:!0,enumerable:!1});return xe(this.store,t),this.#we=t,t}#ve=null;get settable(){const e=this.#ve;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#de))n.get?Object.defineProperty(t,e,{get:n.get,set:n.set,configurable:!0,enumerable:!0}):n.calc&&Object.defineProperty(t,e,{value:n.calc,writable:!1,configurable:!0,enumerable:!1});return xe(this.store,t),this.#ve=t,t}#ye=null;get getters(){const e=this.#ye;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#de))n.get?Object.defineProperty(t,e,{get:n.get,configurable:!0,enumerable:!0}):n.calc&&Object.defineProperty(t,e,{value:n.calc,writable:!1,configurable:!0,enumerable:!1});return xe(this.store,t),this.#ye=t,t}}const Se={width:"px",height:"px",top:"px",right:"px",bottom:"px",left:"px",border:"px","border-top":"px","border-right":"px","border-left":"px","border-bottom":"px","border-width":"px","border-top-width":"px","border-right-width":"px","border-left-width":"px","border-bottom-width":"px","border-radius":"px","border-top-left-radius":"px","border-top-right-radius":"px","border-bottom-left-radius":"px","border-bottom-right-radius":"px",padding:"px","padding-top":"px","padding-right":"px","padding-left":"px","padding-bottom":"px",margin:"px","margin-top":"px","margin-right":"px","margin-left":"px","margin-bottom":"px"};function Ee(e,t){let n=!!Array.isArray(t)&&Boolean(t[1]),r="";if("string"==typeof t)return r=t.replace(/!important\s*$/,""),r?(n=r!==t,[r,n?"important":void 0]):null;const s=Array.isArray(t)?t[0]:t;return"number"==typeof s||"bigint"==typeof s?r=s&&e in Se?`${s}${Se[e]}`:`${s}`:"string"==typeof s&&(r=s),r?[r,n?"important":void 0]:null}class Ce{#e=new Map;emit(e,...t){const n="number"==typeof e?String(e):e,r=this.#e;for(const e of[...r.get(n)||[]])e(...t)}listen(e,t){const n=t.bind(this),r=this.#e,s="number"==typeof e?String(e):e;let o=r.get(s);return o||(o=new Set,r.set(s,o)),o.add(n),()=>{o?.delete(n)}}}const Ae={stop(e){e instanceof Event&&e.stopPropagation()},prevent(e){e instanceof Event&&e.preventDefault()},self(e){if(e instanceof Event)return e.target===e.currentTarget},enter(e){if(e instanceof KeyboardEvent)return"Enter"===e.key},tab(e){if(e instanceof KeyboardEvent)return"Tab"===e.key},esc(e){if(e instanceof KeyboardEvent)return"Escape"===e.key},space(e){if(e instanceof KeyboardEvent)return" "===e.key},backspace(e){if(e instanceof KeyboardEvent)return"Backspace"===e.key},delete(e){if(e instanceof KeyboardEvent)return"Delete"===e.key},delBack(e){if(e instanceof KeyboardEvent)return"Delete"===e.key||"Backspace"===e.key},"del-back"(e){if(e instanceof KeyboardEvent)return"Delete"===e.key||"Backspace"===e.key},insert(e){if(e instanceof KeyboardEvent)return"Insert"===e.key},repeat(e){if(e instanceof KeyboardEvent)return e.repeat},key(e,t){if(e instanceof KeyboardEvent){const n=e.code.toLowerCase().replace(/-/g,"");for(const e of t)if(n===e.toLowerCase().replace(/-/g,""))return!0;return!1}},main(e){if(e instanceof MouseEvent)return 0===e.button},auxiliary(e){if(e instanceof MouseEvent)return 1===e.button},secondary(e){if(e instanceof MouseEvent)return 2===e.button},left(e){if(e instanceof MouseEvent)return 0===e.button},middle(e){if(e instanceof MouseEvent)return 1===e.button},right(e){if(e instanceof MouseEvent)return 2===e.button},primary(e){if(e instanceof PointerEvent)return e.isPrimary},mouse(e){if(e instanceof PointerEvent)return"mouse"===e.pointerType},pen(e){if(e instanceof PointerEvent)return"pen"===e.pointerType},touch(e){if(e instanceof PointerEvent)return"touch"===e.pointerType},pointer(e,t){if(e instanceof PointerEvent){const n=e.pointerType.toLowerCase().replace(/-/g,"");for(const e of t)if(n===e.toLowerCase().replace(/-/g,""))return!0;return!1}},ctrl(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.ctrlKey},alt(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.altKey},shift(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.shiftKey},meta(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.metaKey},cmd(e){if(e instanceof MouseEvent||e instanceof KeyboardEvent||e instanceof TouchEvent)return e.ctrlKey||e.metaKey}};function $e(e){return"number"==typeof e||"bigint"==typeof e?String(e):"boolean"==typeof e?e?"":null:"string"==typeof e?e:null===(e??null)?null:String(e)}function je(e){return null===(e??null)?"":String(e)}function Le(e,t){if(e instanceof HTMLInputElement&&"checked"===t)switch(e.type.toLowerCase()){case"checkbox":case"radio":return Boolean}if((e instanceof HTMLSelectElement||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&"value"===t)return je;if(e instanceof HTMLDetailsElement&&"open"===t)return Boolean;if(e instanceof HTMLMediaElement){if("muted"===t)return Boolean;if("paused"===t)return Boolean;if("currentTime"===t)return!0;if("playbackRate"===t)return!0;if("volume"===t)return!0}return!1}const Te={input:{attrs:{$min:(e,t)=>{t.min=e},$max:(e,t)=>{t.max=e},$step:(e,t)=>{t.step=e},$placeholder:(e,t)=>{t.placeholder=e},$disabled:(e,t)=>{t.disabled=e},$readonly:(e,t)=>{t.readOnly=e},$required:(e,t)=>{t.required=e},$value:(e,t)=>{switch(t.type){case"checkbox":case"radio":t.checked=Boolean(e)}t.value=je(e)}},events:{$value:["input",(e,t)=>{switch(t.type){case"checkbox":case"radio":return t.checked;case"number":return Number(t.value)}return t.value}]}},textarea:{attrs:{$placeholder:(e,t)=>{t.placeholder=e},$disabled:(e,t)=>{t.disabled=e},$readonly:(e,t)=>{t.readOnly=e},$required:(e,t)=>{t.required=e},$value:(e,t)=>{t.value=je(e)}},events:{$value:["input",(e,t)=>t.value]}},select:{attrs:{$disabled:(e,t)=>{t.disabled=e},$required:(e,t)=>{t.required=e},$value:(e,t)=>{t.value=je(e)}},events:{$value:["change",(e,t)=>t.value]}}};function Me(e,t,n){const r=document.createElement(t,{is:n||void 0}),{watchAttr:s,props:o}=e;return["input","textarea","select"].includes(t.toLowerCase())&&e.relate(r),e.listen("init",(({events:n})=>{const i=Te[t.toLowerCase()],l=i?.attrs||{},a=i?.events||{};for(const[e,t,s]of n)if("$"!==e[0])r.addEventListener(e,t,s);else{const n=a[e];if(n){const[e,o]=n;r.addEventListener(e,(e=>t(o(e,r))),s)}}if(o)for(const[t,n]of Object.entries(e.tagAttrs))if(s(t,(e=>{if(o.has(t))r[t]=e;else{const n=$e(e);null==n?r.removeAttribute(t):r.setAttribute(t,n)}})),o.has(t))r[t]=n;else{const e=$e(n);null!==e&&r.setAttribute(t,e)}else for(const[t,n]of Object.entries(e.tagAttrs)){if(r instanceof HTMLInputElement&&"type"===t.toLocaleLowerCase()){const e=$e(n);null!==e&&r.setAttribute(t,e);continue}if("$hidden"===t){n&&(r.hidden=n),s(t,(e=>{r.hidden=e}));continue}if("$"===t[0]){const e=l[t];e&&(e(n,r),s(t,(t=>e(t,r))));continue}const e=Le(r,t);if("function"==typeof e){r[t]=e(n),s(t,(n=>{r[t]=e(n)}));continue}if(e){r[t]=n,s(t,(e=>{r[t]=e}));continue}let o=$e(n);null!==o&&r.setAttribute(t,o),s(t,(e=>{const n=$e(e);null===n?r.removeAttribute(t):r.setAttribute(t,n)}))}})),r}function Ne(e){return null===(e??null)?"":String(e)}function ke(e,t,n,{text:r,html:s}){if(null!=r){const s=e.insertBefore(document.createTextNode(""),t),o=n.watch(r,(e=>s.textContent=Ne(e)));return()=>{s.remove(),o()}}if(null==s)return;const o=e.insertBefore(document.createComment(""),t),i=e.insertBefore(document.createComment(""),t),l=document.createElement("div");function a(){for(let e=o.nextSibling;e&&e!==i;e=o.nextSibling)e.remove()}const c=n.watch(s,(t=>{a(),function(t){l.innerHTML=t;for(let t=l.firstChild;t;t=o.firstChild)e.insertBefore(t,i)}(Ne(t))}));return()=>{c(),a(),o.remove(),i.remove()}}function Ie(e,t,n,r,s,o){let i=new Set,l=[],a=Object.create(s);for(const t of e){if("string"==typeof t)continue;const e=t.directives.template;e&&(a[e]=[t,r])}function c(e){if(!e.length||!i)return;const s=t.insertBefore(document.createComment(""),n);let l=-1,c=()=>{};i.add((()=>{c(),c=()=>{},s.remove()})),i.add(pe((()=>e.findIndex((([e])=>null===e||r.exec(e)))),(t=>{t!==l&&(l=t,c(),c=()=>{},function(t){const n=e[t]?.[1];n&&(c=o(n,a))}(l))}),!0))}for(const r of e){if("string"==typeof r){c(l),l=[];const e=document.createTextNode(r);t.insertBefore(e,n),i.add((()=>e.remove()));continue}if(r.directives.template){c(l),l=[];continue}if(l.length&&r.directives.else){const e=r.directives.if||null;l.push([e,r]),e||(c(l),l=[]);continue}c(l),l=[];const e=r.directives.if;e?l.push([e,r]):i.add(o(r,a))}return()=>{if(!i)return;const e=i;i=null;for(const t of e)t()}}function Pe(e,t,n,r,s,o,i,l){r=r.set(e.aliases,e.vars);const a=e.directives.bind,c=e.directives.fragment;if(c&&"string"==typeof c){const u=s[c];if(!u)return()=>{};const[f,d]=u,h=d.params(f,e,r,a);return Ue(f,t,n,h,s,o,i,l)}if(!e.name||e.directives.fragment)return ke(t,n,r,e.directives)||Ie(e.children||[],t,n,r,s,((e,s)=>Ue(e,t,n,r,s,o,i,l)));const u=[...o,e.name],f=l?.(u);if(l&&!f)return()=>{};const{context:d,handler:h}=function(e,t,n,r){const s="string"==typeof e?e:e.tag,{attrs:o,events:i}="string"!=typeof e&&e||{attrs:null,events:null};let l=!1;const a=new M.State(!1);let c=!1;const u=new M.State(!1),f=Object.create(null),d=Object.create(null),h=new Set,p=[],g=new Ce;return{context:{events:p,props:o?new Set(Object.entries(o).filter((([,e])=>e.isProp)).map((([e])=>e))):null,tagAttrs:d,watchAttr(e,t){if(l)return()=>{};const n=f[e];if(!n)return()=>{};let r=n.get();const s=pe((()=>n.get()),(n=>{const s=r;r=n,t(n,s,e)}),!0);return h.add(s),()=>{h.delete(s),s()}},relate(e){if(!n||!r||l)return()=>{};try{const t=r(n,e);return"function"!=typeof t?()=>{}:(h.add(t),()=>{h.delete(t),t()})}catch{return()=>{}}},get destroyed(){return a.get()},get init(){return u.get()},listen:(e,t)=>g.listen(e,t)},handler:{tag:s,set(e,t){if(o&&!(e in o))return;let n=f[e];if(n)return void n.set(t);const r=new M.State(t);f[e]=r,Object.defineProperty(d,e,{configurable:!0,enumerable:!0,get:r.get.bind(r)})},addEvent(e,n){if("function"!=typeof n)return;const[r,...s]=e.split(".").filter(Boolean),o=i?i[r].filters:{};if(!o)return;const l={},a=[];if(o)for(let e=s.shift();e;e=s.shift()){const t=e.indexOf(":"),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1).split(":"):[],s=n.replace(/^-+/,""),i=(n.length-s.length)%2==1;let c=o[s]||s;switch(c){case"once":l.once=!i;break;case"passive":l.passive=!i;break;case"capture":l.capture=!i;break;default:"string"==typeof c&&(c=Ae[c])}"function"==typeof c&&a.push([c,r,i])}p.push([r,e=>{const r=t.all;for(const[t,n,s]of a)if(t(e,n,r)===s)return;n(e,r)},l])},destroy(){if(!l){l=!0,a.set(!0);for(const e of h)e();g.emit("destroy")}},mount(){c||(c=!0,u.set(!0),g.emit("init",{events:p}))}}}}(f||e.name,r,r.getStore(a),i),p=f?.attrs,g=p?function(e,t,n,r,s){let o=new Set;for(const[i,l]of Object.entries(r)){const r=n[i];if(i in n){if("function"!=typeof r&&"object"!=typeof r){e.set(i,r);continue}const n="function"==typeof r?r:r.name;if(l.immutable){e.set(i,t.exec(n));continue}o.add(t.watch(n,(t=>e.set(i,t))));continue}const a=l.bind;if(!s||!a){e.set(i,l.default);continue}if("string"==typeof a){const n=t.bind(s,a,(t=>e.set(i,t)));n?o.add(n):e.set(i,l.default);continue}if(!Array.isArray(a)){e.set(i,l.default);continue}const[c,u,f]=a;if(!c||"function"!=typeof u)continue;if(!f){const n=!0===s?"":s;o.add(t.watch(n,(t=>e.set(i,t)))),e.addEvent(c,((...e)=>{t.all[n]=u(...e)}));continue}const d=t.bind(s,"state",(t=>e.set(i,t)));if(!d)continue;o.add(d);const h=t.bindSet(s,"state");h&&e.addEvent(c,((...e)=>{h(u(...e))}))}return()=>{const e=o;o=new Set;for(const t of e)t()}}(h,r,e.attrs,p,a):function(e,t,n){const r=e.tag;let s=new Set;for(const[o,i]of Object.entries(n)){if("function"!=typeof i&&"object"!=typeof i){e.set(o,i);continue}const n="function"==typeof i?i:i.name;if("string"!=typeof r||"input"!==r.toLocaleLowerCase()||"type"!==o.toLocaleLowerCase())s.add(t.watch(n,(t=>e.set(o,t))));else{const r=t.exec(n);e.set(o,r)}}return()=>{const e=s;s=new Set;for(const t of e)t()}}(h,r,e.attrs);for(const[t,n]of Object.entries(e.events)){const e=r.getEvent(n);e&&h.addEvent(t,e)}const m=function(e,t,n){if(!n)return()=>{};let r=new Set;for(const[s,o]of Object.entries(t.bindAll(n)||{}))"function"==typeof o&&r.add(o((t=>e.set(s,t))));for(const[r,s]of Object.entries(t.bindEvents(n)||{}))e.addEvent(r,(e=>s(e)));return()=>{const e=r;r=new Set;for(const t of e)t()}}(h,r,a),b=f?"function"==typeof f.tag?f.tag(d):Me(d,f.tag,f.is):Me(d,e.name,e.is),y=Array.isArray(b)?b[0]:b,v=Array.isArray(b)?b[1]:y;t.insertBefore(y,n);const w=v?ke(v,null,r,e.directives)||Ie(e.children||[],v,null,r,s,((e,t)=>Ue(e,v,null,r,t,o,i,l))):()=>{};return function(e,t,n){if(!(e instanceof Element))return()=>{};let r=new Set;for(const[s,o]of Object.entries(t))o&&(!0!==o?r.add(pe((()=>Boolean(n.exec(o))),(t=>{t?e.classList.add(s):e.classList.remove(s)}),!0)):e.classList.add(s))}(y,e.classes,r),function(e,t,n){if(!(e instanceof HTMLElement||e instanceof SVGElement))return()=>{};let r=new Set;for(const[s,o]of Object.entries(t))r.add(pe((()=>Ee(s,n.exec(o))),(t=>{t?e.style.setProperty(s,...t):e.style.removeProperty(s)}),!0))}(y,e.styles,r),h.mount(),()=>{y.remove(),h.destroy(),g(),w(),m()}}function Ue(e,t,n,r,s,o,i,l){const{directives:a}=e,c=r.child(a.value);if(!c)return()=>{};const u=c.enum(a.enum),f=(n,r)=>Pe(e,t,n,r,s,o,i,l);return!0===u?f(n,c):u instanceof Q?function(e,t,n,r,s){const o=e.insertBefore(document.createComment(""),t);let i=new Map;function l(e){for(const[t,n,r]of e.values())r(),t.remove(),n.remove()}const a=pe((()=>n.children),(function(t){if(!o.parentNode)return;let a=o.nextSibling;const c=i;i=new Map;for(let o of t){const t=c.get(o);if(!t){const t=e.insertBefore(document.createComment(""),a),l=e.insertBefore(document.createComment(""),a),c=s(l,r.setStore(o,n));i.set(o,[t,l,c]);continue}if(c.delete(o),i.set(o,t),a===t[0]){a=t[1].nextSibling;continue}let l=t[0];for(;l&&l!==t[1];){const t=l;l=l.nextSibling,e.insertBefore(t,a)}e.insertBefore(t[1],a)}l(c)}),!0);return()=>{o.remove(),l(i),a()}}(t,n,u,c,f):u instanceof G?function(e,t,n,r,s){const o=[];for(const[e,i]of[...n])o.push(s(t,r.setStore(i,n)));return()=>{for(const e of o)e()}}(0,n,u,c,f):"function"==typeof u?function(e,t,n,r,s){const o=new M.Computed((()=>{const e=n();if("number"==typeof e){const t=Math.floor(e);return t?Array(t).fill(0).map(((e,t)=>[t+1,t,t])):[]}return e&&"object"==typeof e?Array.isArray(e)?e.map(((e,t)=>[e,t,t])):Object.entries(e).map((([e,t],n)=>[t,n,e])):[]})),i=e.insertBefore(document.createComment(""),t);let l=[];function a(e){for(const[t,n,r]of e)r(),t.remove(),n.remove()}const c=pe((()=>o.get()),(function(t){if(!i.parentNode)return;let n=i.nextSibling;const o=l;l=[];for(const[i,a,c]of t){const t=o.findIndex((e=>e[3]===c)),[u]=t>=0?o.splice(t,1):[];if(!u){const t=e.insertBefore(document.createComment(""),n),o=e.insertBefore(document.createComment(""),n),u=new M.State(i),f=new M.State(a),d=s(o,r.setObject({get key(){return c},get value(){return u.get()},get index(){return f.get()}}));l.push([t,o,d,c,u,f]);continue}if(l.push(u),u[4].set(i),u[5].set(a),n===u[0]){n=u[1].nextSibling;continue}let f=u[0];for(;f&&f!==u[1];){const t=f;f=f.nextSibling,e.insertBefore(t,n)}e.insertBefore(u[1],n)}a(o)}),!0);return()=>{i.remove(),a(l),c()}}(t,n,u,c,f):()=>{}}function qe(e,t,n,{component:r,global:s,relate:o}={}){const i=new Oe(e,s),l=Object.create(null),a="function"==typeof o?o:null;return Ie(t,n,null,i,l,((e,t)=>Ue(e,n,null,i,t,[],a,r)))}export{de as Layout,M as Signal,F as Store,he as effect,qe as render,pe as watch};
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @neeloong/form v0.8.0
2
+ * @neeloong/form v0.8.1
3
3
  * (c) 2024-2025 Fierflame
4
4
  * @license Apache-2.0
5
5
  */
@@ -2343,6 +2343,14 @@ class Environment {
2343
2343
  return store instanceof Store ? store : item.get;
2344
2344
 
2345
2345
  }
2346
+ /**
2347
+ * @param {string | boolean | null} [name]
2348
+ */
2349
+ getStore(name) {
2350
+ if (!name) { return null; }
2351
+ const item = this.#items[name === true ? '' : name];
2352
+ return item?.get && item.store || null
2353
+ }
2346
2354
 
2347
2355
  /**
2348
2356
  * @param {string | true} name
@@ -3032,7 +3040,7 @@ class EventEmitter {
3032
3040
  }
3033
3041
  }
3034
3042
 
3035
- /** @import { Component } from '../types.mjs' */
3043
+ /** @import { Component, Relatedness } from '../types.mjs' */
3036
3044
  /** @import Store from '../Store/index.mjs' */
3037
3045
  /** @import Environment from './Environment/index.mjs' */
3038
3046
 
@@ -3158,10 +3166,11 @@ const eventFilters = {
3158
3166
  *
3159
3167
  * @param {Component | string} component
3160
3168
  * @param {Environment} env
3161
- * @param {((store: Store, el: Element) => () => void)?} [relate]
3169
+ * @param {Store?} store
3170
+ * @param {((store: Store, el: Element | Relatedness) => () => void)?} [relate]
3162
3171
  * @returns
3163
3172
  */
3164
- function createContext(component, env, relate) {
3173
+ function createContext(component, env, store, relate) {
3165
3174
  const tag = typeof component === 'string' ? component : component.tag;
3166
3175
  const { attrs, events } = typeof component !== 'string' && component || { attrs: null, events: null };
3167
3176
 
@@ -3202,9 +3211,9 @@ function createContext(component, env, relate) {
3202
3211
  };
3203
3212
  },
3204
3213
  relate(el) {
3205
- if (!relate || destroyed) { return () => { }; }
3214
+ if (!store || !relate || destroyed) { return () => { }; }
3206
3215
  try {
3207
- const w = relate(env.store, el);
3216
+ const w = relate(store, el);
3208
3217
  if (typeof w !== 'function') { return () => { }; }
3209
3218
  cancelFns.add(w);
3210
3219
  return () => {
@@ -3468,6 +3477,9 @@ const tagBindMap = {
3468
3477
  function createTagComponent (context, name, is) {
3469
3478
  const node = document.createElement(name, {is: is || undefined});
3470
3479
  const { watchAttr, props } = context;
3480
+ if(['input', 'textarea', 'select'].includes(name.toLowerCase())) {
3481
+ context.relate(node);
3482
+ }
3471
3483
 
3472
3484
  context.listen('init', ({events})=> {
3473
3485
  const e = tagBindMap[name.toLowerCase()];
@@ -3934,7 +3946,7 @@ function bindBase(handler, env, bind) {
3934
3946
  * @param {Environment} env
3935
3947
  * @param {Record<string, [Layout.Node, Environment]>} templates
3936
3948
  * @param {string[]} componentPath
3937
- * @param {((store: Store, el: Element) => () => void)?} [relate]
3949
+ * @param {((store: Store, el: Element | Relatedness) => () => void)?} [relate]
3938
3950
  * @param {Component.Getter?} [getComponent]
3939
3951
  */
3940
3952
  function renderItem(layout, parent, next, env, templates, componentPath, relate, getComponent) {
@@ -3957,8 +3969,12 @@ function renderItem(layout, parent, next, env, templates, componentPath, relate,
3957
3969
  const path = [...componentPath, layout.name];
3958
3970
  const component = getComponent?.(path);
3959
3971
  if (getComponent && !component) { return () => { }; }
3960
- const { context, handler } = createContext(component ? component : layout.name, env, relate);
3961
-
3972
+ const { context, handler } = createContext(
3973
+ component ? component : layout.name,
3974
+ env,
3975
+ env.getStore(bind),
3976
+ relate
3977
+ );
3962
3978
 
3963
3979
  const componentAttrs = component?.attrs;
3964
3980
  const attrs = componentAttrs
@@ -4009,7 +4025,7 @@ function renderItem(layout, parent, next, env, templates, componentPath, relate,
4009
4025
  * @param {Environment} env
4010
4026
  * @param {Record<string, [Layout.Node, Environment]>} templates
4011
4027
  * @param {string[]} componentPath
4012
- * @param {((store: Store, el: Element) => () => void)?} [relate]
4028
+ * @param {((store: Store, el: Element | Relatedness) => () => void)?} [relate]
4013
4029
  * @param {Component.Getter?} [getComponent]
4014
4030
  * @returns {() => void}
4015
4031
  */
@@ -4042,7 +4058,7 @@ function render(layout, parent, next, env, templates, componentPath, relate, get
4042
4058
  * @param {object} [options]
4043
4059
  * @param {Record<string, Store | {get?(): any; set?(v: any): void; exec?(...p: any[]): any; calc?(...p: any[]): any }>} [options.global]
4044
4060
  * @param {(path: string[]) => Component?} [options.component]
4045
- * @param {(store: Store, el: Element) => () => void} [options.relate]
4061
+ * @param {(store: Store, el: Element | Relatedness) => () => void} [options.relate]
4046
4062
  * @returns {() => void}
4047
4063
  */
4048
4064
  function index (store, layouts, parent, {component, global, relate} = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neeloong/form",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "from",