@neeloong/form 0.21.2 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.mts +2 -2
- package/index.full.js +9 -15
- package/index.full.min.js +2 -2
- package/index.full.min.mjs +2 -2
- package/index.min.mjs +2 -2
- package/index.mjs +9 -15
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @neeloong/form v0.
|
|
2
|
+
* @neeloong/form v0.22.0
|
|
3
3
|
* (c) 2024-2026 Fierflame
|
|
4
4
|
* @license Apache-2.0
|
|
5
5
|
*/
|
|
@@ -878,7 +878,7 @@ declare namespace StoreLayout {
|
|
|
878
878
|
editable?: boolean | undefined;
|
|
879
879
|
call?: ((name: string, event: Event, store: Store<any, any>, options?: StoreLayout.Options | null) => void) | undefined;
|
|
880
880
|
};
|
|
881
|
-
type Renderer = (store: Store<any, any>,
|
|
881
|
+
type Renderer = (store: Store<any, any>, options?: StoreLayout.Options | null) => [HTMLElement, () => void] | null;
|
|
882
882
|
}
|
|
883
883
|
|
|
884
884
|
declare const ref: unique symbol;
|
package/index.full.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @neeloong/form v0.
|
|
2
|
+
* @neeloong/form v0.22.0
|
|
3
3
|
* (c) 2024-2026 Fierflame
|
|
4
4
|
* @license Apache-2.0
|
|
5
5
|
*/
|
|
@@ -5299,14 +5299,11 @@
|
|
|
5299
5299
|
return destroy;
|
|
5300
5300
|
}
|
|
5301
5301
|
}
|
|
5302
|
-
const
|
|
5303
|
-
if (
|
|
5304
|
-
const
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
node.replaceWith(el);
|
|
5308
|
-
return destroy;
|
|
5309
|
-
}
|
|
5302
|
+
const res = fieldRenderer(fieldStore, options);
|
|
5303
|
+
if (res) {
|
|
5304
|
+
const [el, destroy] = res;
|
|
5305
|
+
node.replaceWith(el);
|
|
5306
|
+
return destroy;
|
|
5310
5307
|
}
|
|
5311
5308
|
const value = node.getAttribute('placeholder') || '';
|
|
5312
5309
|
node.replaceWith(document.createTextNode(value));
|
|
@@ -5504,10 +5501,7 @@
|
|
|
5504
5501
|
* @returns {[ParentNode, () => void]}
|
|
5505
5502
|
*/
|
|
5506
5503
|
function FormFieldInline(store, fieldRenderer, layout, options) {
|
|
5507
|
-
|
|
5508
|
-
return component
|
|
5509
|
-
&& fieldRenderer(store, component, options)
|
|
5510
|
-
|| [document.createElement('div'), () => { }];
|
|
5504
|
+
return fieldRenderer(store, options) || [document.createElement('div'), () => { }];
|
|
5511
5505
|
}
|
|
5512
5506
|
|
|
5513
5507
|
/** @import { Store } from '../Store/index.mjs' */
|
|
@@ -6852,7 +6846,7 @@
|
|
|
6852
6846
|
* @returns {[ParentNode, () => void]}
|
|
6853
6847
|
*/
|
|
6854
6848
|
function FormField(store, fieldRenderer, layout, options) {
|
|
6855
|
-
const { type
|
|
6849
|
+
const { type } = store;
|
|
6856
6850
|
const isObject = type && typeof type === 'object';
|
|
6857
6851
|
const html = layout?.html;
|
|
6858
6852
|
/** @type {StoreLayout.Grid['cell']} */
|
|
@@ -6864,7 +6858,7 @@
|
|
|
6864
6858
|
|
|
6865
6859
|
const r =
|
|
6866
6860
|
html && Html(html, store, fieldRenderer, options, layout)
|
|
6867
|
-
||
|
|
6861
|
+
|| fieldRenderer(store, options)
|
|
6868
6862
|
|| store instanceof ArrayStore && getArrayCell(layout?.arrayStyle)(store, fieldRenderer, layout, options)
|
|
6869
6863
|
|| isObject && Form(store, fieldRenderer, layout, options);
|
|
6870
6864
|
if (r) {
|
package/index.full.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @neeloong/form v0.
|
|
2
|
+
* @neeloong/form v0.22.0
|
|
3
3
|
* (c) 2024-2026 Fierflame
|
|
4
4
|
* @license Apache-2.0
|
|
5
5
|
*/
|
|
@@ -57,4 +57,4 @@ function(){throw new Error};function $(){return p(this),this.value}function A(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(j);t.value=e;const n=()=>(p(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 $.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");A(this[M],t)}};c=M,h=new WeakSet,e.isComputed=e=>r(h,e),e.Computed=class{constructor(t,r){o(this,h),n(this,c);const i=function(e){const t=Object.create(N);t.computation=e;const n=()=>x(t);return n[u]=t,n}(t),s=i[u];if(s.consumerAllowSignalWrites=!0,this[M]=s,s.wrapper=this,r){const t=r.equals;t&&(s.equal=t),s.watched=r[e.subtle.watched],s.unwatched=r[e.subtle.unwatched]}}get(){if(!(0,e.isComputed)(this))throw new TypeError("Wrong receiver type for Signal.Computed.prototype.get");return x(this[M])}},(t=>{var s,a,c,u;t.untrack=function(e){let t,n=null;try{n=d(null),t=e()}finally{d(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};s=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){o(this,a),o(this,c),n(this,s);let t=Object.create(f);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=d(n);for(const e of t)p(e[M]);d(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)){v(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];E(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 k=e=>"string"==typeof e&&e||null,I=e=>"number"==typeof e&&e||null,F=e=>e instanceof RegExp?e:null,B=Boolean;function P(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,o=Array.isArray(t)?t.map(P).filter(B):[];return o.length?{children:o,label:n,value:r}:"number"==typeof r||"string"==typeof r?{label:n,value:r}:null}const R=e=>{if(!e||!Array.isArray(e))return null;const t=e.map(P).filter(B);return t.length?t:null};function U(t,n,r,o){const i=new e.Signal.State(n(r));let s;if("function"==typeof o){const r=o;s=new e.Signal.Computed((()=>n(r(t))))}else{const t=n(o);s=new e.Signal.Computed((()=>t))}const l=new e.Signal.Computed((()=>{const e=i.get();return null===e?s.get():e}));return[i,l]}const q=Symbol();function D(e){const t={[q]:e};for(const[n,r]of e)Object.defineProperty(t,n,{get:()=>r.ref,configurable:!1,enumerable:!0});return Object.defineProperty(t,q,{get:()=>e,configurable:!1,enumerable:!0}),t}let V=null,_=null,W=Object.create(null);function H(e,t){const n=e.type;let r=Y;if(!e.array||_&&t?.parent instanceof _)if("string"==typeof n){const e=W[n];e&&(r=e)}else n&&"object"==typeof n&&V&&(r=V);else _&&(r=_);return new r(e,t)}function K(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 o=new e.Signal.State([]);let i=null;return[function(){i?.abort(),i=new AbortController;const e=i.signal;return o.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(K).filter(Boolean);return!n.aborted&&i.length&&o.set([...o.get(),...i]),i}(n,e)))).then((e=>e.flat()))},new e.Signal.Computed((()=>o.get())),()=>{i?.abort(),o.set([])}]}class Y{#e=new Map;emit(e,t){const n="number"==typeof e?String(e):e,r=this.#e;let o=!1;for(const e of[...r.get(n)||[]])o=!1===e(t,this)||o;return!o}listen(e,t){const n=t.bind(this),r=this.#e,o="number"==typeof e?String(e):e;let i=r.get(o);return i||(i=new Set,r.set(o,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){W[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,ref:r,default:o,setValue:i,convert:s,onUpdate:l,validator:a,validators:c,index:u,size:d,new:f,parent:p,hidden:h,clearable:m,required:g,disabled:b,readonly:v,removable:y,label:w,description:E,placeholder:x,min:S,max:C,step:L,minLength:N,maxLength:O,pattern:$,values:A}={}){this.schema=t;const j=p instanceof Y?p:null;var M,B;j&&(this.#r=j,this.#o=j.#o,this.#i=j.#i),this.#s=(M=this,"function"!=typeof(B=o??t.default)?()=>structuredClone(B):e=>structuredClone(B(M,e)));const P=new e.Signal.State(!1);this.#l=P,this.#i=P,this.#a=t.type,this.#c=t.meta,this.#u=t.component;const q=new e.Signal.State(Boolean(f));this.#d=q;const V=j?new e.Signal.Computed((()=>j.#f.get()||q.get())):new e.Signal.Computed((()=>q.get()));this.#f=V;const _=Boolean(t.immutable),W=!1!==t.creatable;this.#p=_,this.#h=W;const H=t.readonly,G=new e.Signal.State("boolean"==typeof v?v:null);let Q;if("function"==typeof H)Q=new e.Signal.Computed((()=>Boolean(H(this))));else{const t=Boolean(H);Q=new e.Signal.Computed((()=>t))}const X=()=>{if(V.get()?!W:_)return!0;const e=G.get();return null===e?Q.get():e},Z=j?j.#m:null;this.#g=G,this.#m=Z?new e.Signal.Computed((()=>Z.get()||X())):new e.Signal.Computed(X),[this.#b,this.#v]=T(this,h,t.hidden,j?j.#v:null),[this.#y,this.#w]=T(this,m,t.clearable,j?j.#w:null),[this.#E,this.#x]=T(this,g,t.required,j?j.#x:null),[this.#S,this.#C]=T(this,b,t.disabled,j?j.#C:null),[this.#L,this.#N]=U(this,k,w,t.label),[this.#O,this.#$]=U(this,k,E,t.description),[this.#A,this.#j]=U(this,k,x,t.placeholder),[this.#M,this.#T]=U(this,I,S,t.min),[this.#k,this.#I]=U(this,I,C,t.max),[this.#F,this.#B]=U(this,I,L,t.step),[this.#P,this.#R]=U(this,I,N,t.minLength),[this.#U,this.#q]=U(this,I,O,t.maxLength),[this.#D,this.#V]=U(this,F,$,t.pattern),[this.#_,this.#W]=U(this,R,A,t.values),[this.#H,this.#K]=T(this,y,t.removable??!0);const J=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(K).filter(Boolean)})):new e.Signal.Computed((()=>[]))}(this,t.validator,a),[ee,te,ne]=z(this,t.validators?.change,c?.change),[re,oe,ie]=z(this,t.validators?.blur,c?.blur);if(this.listen("change",(()=>{ee()})),this.listen("blur",(()=>{re()})),this.#z=function(...t){const n=t.filter(Boolean);return new e.Signal.Computed((()=>n.flatMap((e=>e.get()))))}(J,te,oe),this.#Y=J,this.#G=ee,this.#Q=re,this.#X=ne,this.#Z=ie,d instanceof e.Signal.State||d instanceof e.Signal.Computed?this.#J=d:this.#J=new e.Signal.State(d||0),n)return this.#t=!0,void(this.#n=D(this));this.#n=r||null,this.#ee=l||null,this.#te="function"==typeof i?i:null,this.#ne="function"==typeof s?s:null,this.#re.set(u??"");for(const[e,n]of Object.entries(t.events||{}))"function"==typeof n&&this.listen(e,n)}#s;createDefault(e){return this.#s(e)}#te=null;#ne=null;#ee=null;#r=null;#o=this;#a;#c;#u;#l=null;#i;get loading(){return this.#i.get()}set loading(e){const t=this.#l;t&&t.set(Boolean(e))}get store(){return this}get parent(){return this.#r}get root(){return this.#o}get type(){return this.#a}get meta(){return this.#c}get component(){return this.#u}#J;get size(){return this.#J.get()}#re=new e.Signal.State("");get index(){return this.#re.get()}set index(e){this.#re.set(e)}get no(){if(this.#t)return"";const e=this.index;return"number"==typeof e?e+1:e}#h=!0;get creatable(){return this.#h}#p=!1;get immutable(){return this.#p}#f;#d;get selfNew(){return this.#d.get()}set selfNew(e){this.#d.set(Boolean(e))}get new(){return this.#f.get()}set new(e){this.#d.set(Boolean(e))}#b;#v;get selfHidden(){return this.#b.get()}set selfHidden(e){this.#b.set("boolean"==typeof e?e:null)}get hidden(){return this.#v.get()}set hidden(e){this.#b.set("boolean"==typeof e?e:null)}#y;#w;get selfClearable(){return this.#y.get()}set selfClearable(e){this.#y.set("boolean"==typeof e?e:null)}get clearable(){return this.#w.get()}set clearable(e){this.#y.set("boolean"==typeof e?e:null)}#E;#x;get selfRequired(){return this.#E.get()}set selfRequired(e){this.#E.set("boolean"==typeof e?e:null)}get required(){return this.#x.get()}set required(e){this.#E.set("boolean"==typeof e?e:null)}#S;#C;get selfDisabled(){return this.#S.get()}set selfDisabled(e){this.#S.set("boolean"==typeof e?e:null)}get disabled(){return this.#C.get()}set disabled(e){this.#S.set("boolean"==typeof e?e:null)}#g;#m;get selfReadonly(){return this.#g.get()}set selfReadonly(e){this.#g.set("boolean"==typeof e?e:null)}get readonly(){return this.#m.get()}set readonly(e){this.#g.set("boolean"==typeof e?e:null)}#H;#K;get selfRemovable(){return this.#H.get()}set selfRemovable(e){this.#H.set("boolean"==typeof e?e:null)}get removable(){return this.#K.get()}set removable(e){this.#H.set("boolean"==typeof e?e:null)}#L;#N;get selfLabel(){return this.#L.get()}set selfLabel(e){this.#L.set(k(e))}get label(){return this.#N.get()}set label(e){this.#L.set(k(e))}#O;#$;get selfDescription(){return this.#O.get()}set selfDescription(e){this.#O.set(k(e))}get description(){return this.#$.get()}set description(e){this.#O.set(k(e))}#A;#j;get selfPlaceholder(){return this.#A.get()}set selfPlaceholder(e){this.#A.set(k(e))}get placeholder(){return this.#j.get()}set placeholder(e){this.#A.set(k(e))}#M;#T;get selfMin(){return this.#M.get()}set selfMin(e){this.#M.set(I(e))}get min(){return this.#T.get()}set min(e){this.#M.set(I(e))}#k;#I;get selfMax(){return this.#k.get()}set selfMax(e){this.#k.set(I(e))}get max(){return this.#I.get()}set max(e){this.#k.set(I(e))}#F;#B;get selfStep(){return this.#F.get()}set selfStep(e){this.#F.set(I(e))}get step(){return this.#B.get()}set step(e){this.#F.set(I(e))}#P;#R;get selfMinLength(){return this.#P.get()}set selfMinLength(e){this.#P.set(I(e))}get minLength(){return this.#R.get()}set minLength(e){this.#P.set(I(e))}#U;#q;get selfMaxLength(){return this.#U.get()}set selfMaxLength(e){this.#U.set(I(e))}get maxLength(){return this.#q.get()}set maxLength(e){this.#U.set(I(e))}#D;#V;get selfPattern(){return this.#D.get()}set selfPattern(e){this.#D.set(F(e))}get pattern(){return this.#V.get()}set pattern(e){this.#D.set(F(e))}#_;#W;get selfValues(){return this.#_.get()}set selfValues(e){this.#_.set(R(e))}get values(){return this.#W.get()}set values(e){this.#_.set(R(e))}#z;#Y;#G;#Q;#X;#Z;get errors(){return this.#z.get()}get error(){return this.#z.get()[0]}*[Symbol.iterator](){}child(e){return null}#oe=!1;#ie=new e.Signal.State(null);#se=new e.Signal.State(this.#ie.get());get changed(){return!Object.is(this.#se.get(),this.#ie.get())}get value(){return this.#se.get()}set value(e){const t=this.#te?.(e),n=void 0===t?e:t;this.#se.set(n),this.#oe||this.#ie.set(n),this.#ee?.(n,this.#re.get(),this),this.#le()}#le(){this.#ae||(this.#ae=!0,queueMicrotask((()=>{const e=this.#se.get();this.#ce(e)})))}reset(e=(this.#oe?this.#ie.get():this.#s()),t=this.#d.get()){this.#ue(e,Boolean(t))}#ue(e,t){this.#d.set(t);const n=this.#te?.(e),r=void 0===n?e:n;if(this.#X(),this.#Z(),this.#oe=!0,!r||"object"!=typeof r){for(const[,e]of this)e.#ue(null,!1);return this.#se.set(r),this.#ie.set(r),this.#ee?.(r,this.#re.get(),this),r}const o=Array.isArray(r)?[...r]:{...r};for(const[e,t]of this)o[e]=t.#ue(Object.hasOwn(o,e)?o[e]:void 0,!1);return this.#se.set(o),this.#ie.set(o),this.#ee?.(o,this.#re.get(),this),o}#ae=!1;#de(e){let t=this.#ne?.(e)??e;return void 0===t&&(t=e),Object.is(this.#se.get(),t)?t:this.#ce(t)}#ce(e){this.#ae=!1;let t=e;if(e&&"object"==typeof e){let n=Array.isArray(e)?[...e]:{...e},r=!1;for(const[t,o]of this){const i=Object.hasOwn(e,t)?e[t]:void 0,s=o.#de(i);Object.is(i,s)||(n[t]=s,r=!0)}r&&(t=e=n,this.#se.set(e))}return this.#oe||(this.#oe=!0,this.#ie.set(t)),this.#se.set(e),e}validate(e){if(!0===e)return Promise.all([this.#Y.get(),this.#G(),this.#Q()]).then((e=>{const t=e.flat();return t.length?t:null}));const t=Array.isArray(e)?e:[],n=[this.validate(!0).then((e=>e?.length?[{path:[...t],store:this,errors:e}]:[]))];for(const[e,r]of this)n.push(r.validate([...t,e]));return Promise.all(n).then((e=>e.flat()))}}class G extends Y{get kind(){return"object"}#fe;*[Symbol.iterator](){yield*Object.entries(this.#fe)}child(e){return this.#fe[e]||null}constructor(e,{parent:t,index:n,new:r,onUpdate:o}={}){const i=Object.entries(e.type),s=Object.create(null);super(e,{parent:t,index:n,new:r,onUpdate:o,size:i.length,setValue:e=>"object"==typeof e?e:null,convert:e=>"object"==typeof e?e:{},default:e.default??((t,n)=>{const r=Object.entries(s);let o=n;return o&&"object"==typeof o||(o=e.default),o&&"object"==typeof o||(o={}),Object.fromEntries(r.map((([e,t])=>[e,t.createDefault(Object.hasOwn(o,e)?o[e]:null)])))})});const l={parent:this,onUpdate:(e,t,n)=>{n===this.#fe[t]&&(this.value={...this.value,[t]:e})}};for(const[e,t]of i)s[e]=H(t,{...l,index:e});this.#fe=s}}V=G;class Q extends Y{#pe=()=>{throw new Error};#fe;get children(){return[...this.#fe.get()]}*[Symbol.iterator](){return yield*[...this.#fe.get().entries()]}child(e){const t=this.#fe.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,index:o,new:i,addable:s}={}){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.#pe(e));n.length=t,r!==t&&l.set(n)};super(t,{index:o,new:i,parent:n,size:new e.Signal.Computed((()=>l.get().length)),setValue(e){const t=Array.isArray(e)?e:null==e?null:[e];return a(t),t},convert(e){const t=Array.isArray(e)?e:null==e?null:[e];return a(t),t},onUpdate:(e,t,n)=>{a(e),r?.(e,t,n)},default:t.default??[]}),[this.#he,this.#me]=T(this,s,t.addable??!0),this.#fe=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}};this.#pe=(e,n)=>{const r=H(t,{...c,index:e,new:n});return r.index=e,r}}#he;#me;get selfAddable(){return this.#he.get()}set selfAddable(e){this.#he.set("boolean"==typeof e?e:null)}get addable(){return this.#me.get()}set addable(e){this.#he.set("boolean"==typeof e?e:null)}insert(e,t=null,n){if(!this.addable)return!1;const r=this.value||[];if(!Array.isArray(r))return!1;const o=[...this.#fe.get()],i=Math.max(0,Math.min(Math.floor(e),o.length)),s=this.#pe(i,n);s.new=!0,o.splice(i,0,s);for(let t=e+1;t<o.length;t++)o[t].index=t;const l=[...r];return l.splice(i,0,s.createDefault(t)),this.#fe.set(o),this.value=l,!0}add(e=null){return this.insert(this.#fe.get().length,e)}remove(e){const t=this.value;if(!Array.isArray(t))return;const n=[...this.#fe.get()],r=Math.max(0,Math.min(Math.floor(e),n.length)),[o]=n.splice(r,1);if(!o)return;for(let t=e;t<n.length;t++)n[t].index=t;const i=[...t],[s]=i.splice(r,1);return this.#fe.set(n),this.value=i,s}move(e,t,n=1){const r=Math.floor(n);if(r<1)return 0;if(e<=t&&e+r>t)return 0;const o=this.value;if(!Array.isArray(o))return 0;const i=[...this.#fe.get()],s=i.splice(e,r),l=s.length;if(!l)return 0;const a=r>1&&t>e?t-r+1:t;i.splice(a,0,...s);let c=Math.min(e,a),u=Math.max(e+r-1,t);for(let e=c;e<=u;e++)i[e].index=e;const d=[...o],f=d.splice(e,l);for(let e=f.length;e<l;e++)f.push(null);for(;a>d.length;)d.push(null);return d.splice(a,0,...f),this.#fe.set(i),this.value=d,l}exchange(e,t){const n=this.value;if(!Array.isArray(n))return!1;const r=[...this.#fe.get()],o=r[e],i=r[t];if(!o||!i)return!1;r[t]=o,r[e]=i,o.index=t,i.index=e;const s=[...n],l=s[e],a=s[t];return s[t]=l,s[e]=a,this.#fe.set(r),this.value=s,!0}}function X(e){if(!e?.length)return[];const t=[];let n=[],r=Object.create(null),o=!1;for(const t of e){if("string"==typeof t)continue;const e=t.template;if(!e)continue;o=!0;const n=Z(t);r[e]={params:t.params,children:n?[n]:[]}}function i(e){e.length&&t.push({type:"divergent",children:e.map((([e,t])=>{const n=Z(t);return n?"string"!=typeof n&&"fragment"===n.type?[n,e]:[{children:[n]},e]:[{children:[]},e]}))})}for(const r of e){if("string"==typeof r){i(n),n=[],t.push(r);continue}if(r.template){i(n),n=[];continue}if(n.length&&r.else){const e=r.if||null;n.push([e,r]),e||(i(n),n=[]);continue}i(n),n=[];const e=r.if;if(e){n.push([e,r]);continue}const o=Z(r);o&&t.push(o)}return i(n),o?[{type:"fragment",templates:r,children:t}]:t}function Z(e){let t=function(e){const t=e.fragment;if(t&&"string"==typeof t)return{type:"template",template:t,attrs:e.attrs,children:[]};const n=function({text:e,html:t}){return null!=e?{type:"content",value:e}:null!=t?{type:"content",value:t,html:!0}:void 0}(e),r=n?[n]:X(e.children);return!e.name||t?n||{type:"fragment",children:r}:{name:e.name,is:e.is,attrs:e.attrs,events:e.events,classes:e.classes,styles:e.styles,enhancements:e.enhancements,bind:e.bind,comment:e.comment,children:r}}(e),n=e.vars;n.length&&t&&"string"!=typeof t&&(t.vars?t.vars=[...n,...t.vars]:t?t.vars=n:t={type:"fragment",vars:n,children:[]},n=null);const r=e.enum,o=e.value;return r&&(t={type:"enum",value:r,sort:e.sort,vars:n,children:t?[t]:[]},n=null),o&&(t={type:"value",name:o,vars:n,children:t?[t]:[]},n=null),n?.length&&(t={type:"fragment",vars:n,children:t?[t]:[]}),t}!function(e){_=e}(Q);const J=/^([+-]?(\d(_?\d)*(\.(\d(_?\d)*)?)?|\.\d(_?\d)*)(?:e[+-]?\d(_?\d)*)|0(b[01](?:_?[01])*|o[0-7](?:_?[0-7])*|x[\dA-F](?:_?[\dA-F])*))$/is;const ee={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 te extends Error{constructor(e,...t){const n=ee[e];super("function"==typeof n?n(...t):n),this.code=e}}const ne=/^(?<decorator>[:@!+*\.?]|style:|样式:)?(?<name>-?[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_:\d\.]*)$/u,re=/^~(?<enhancement>[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_\d\.]*)(?:(?<decorator>[:@!])(?<name>-?[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_:\d\.]*))?$/u,oe=/^(?<name>[a-zA-Z$\p{Unified_Ideograph}_][\da-zA-Z$\p{Unified_Ideograph}_]*)?$/u;function ie(e,t){const n=e[t];if(n)return n;const r={attrs:Object.create(null),events:Object.create(null)};return e[t]=r,r}function se(e,t){const n=e.replace(/$\s+|\s+$/gs,"");if("null"===n)return{value:null};if("true"===n)return{value:!0};if("false"===n)return{value:!1};const r=function(e){return J.test(e)?Number(e.replaceAll("_","")):NaN}(n);return Number.isNaN(r)?oe.test(n)?{name:n}:{calc:t(e)}:{value:r}}function le(e,t,n,r,o){const{attrs:i,events:s,classes:l,styles:a,vars:c,params:u,enhancements:d}=e;return function(f,p){const h=f.replace(/./g,".").replace(/:/g,":").replace(/@/g,"@").replace(/+/g,"+").replace(/-/g,"-").replace(/[*×]/g,"*").replace(/!/g,"!"),m=(ne.exec(h)||re.exec(h))?.groups;if(!m)throw new te("ATTR",f);const{name:g,enhancement:b}=m,v=m.decorator?.toLowerCase();if(b){if(":"===v)ie(d,b).attrs[g]=p?se(p,t):{name:g};else if("@"===v)ie(d,b).events[g]=p?oe.test(p)?{name:p}:{event:r(p)}:{name:g};else if("!"===v){if("bind"===g)ie(d,b).bind=p||!0}else ie(d,b).value=se(p,t);return}if(!v)return void(i[g]={value:p});if(":"===v)return void(i[g]=p?se(p,t):{name:g});if("."===v)return void(l[g]=p?se(p,t):{name:g});if("style:"===v)return void(a[g]=se(p,t));if("@"===v)return void(s[g]=p?oe.test(p)?{name:p}:{event:r(p)}:{name:g});if("+"===v)return void c.push({...p?se(p,n):{value:void 0},variable:g,init:!0});if("*"===v)return void c.push({...se(p,t),variable:g,init:!1});if("?"===v)return void(u[g]=se(p,t));if("!"!==v)return;switch(g.toString()){case"fragment":e.fragment=p||!0;break;case"else":e.else=!0;break;case"enum":e.enum=p?se(p,t):{value:!0};break;case"sort":e.sort=p?se(p,t):{value:!0};break;case"if":e.if=se(p,t);break;case"text":e.text=se(p,t);break;case"html":o&&(e.html=se(p,t));break;case"template":e.template=p;break;case"bind":e.bind=p||!0;break;case"value":e.value=p;break;case"comment":e.comment=p}}}function ae(e,t){return{name:e,is:t,children:[],attrs:Object.create(null),events:Object.create(null),classes:Object.create(null),styles:Object.create(null),vars:[],params:Object.create(null),enhancements:Object.create(null)}}var ce={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 ue=/^(?<name>[\w\p{Unified_Ideograph}_][-\.\|:|d\w\p{Unified_Ideograph}_:]*)(?:|(?<is>[\w\p{Unified_Ideograph}_][-\.\|:|d\w\p{Unified_Ideograph}_]*))?$/u;function de(e){return"="!==e&&"/"!==e&&">"!==e&&e&&"'"!==e&&'"'!==e&&!function(e){return"0x80"===e||e<=" "}(e)}function fe(e,t,n,r){let o=r[n];return null==o&&(o=e.lastIndexOf("</"+n+">"),o<t&&(o=e.lastIndexOf("</"+n)),r[n]=o),o<t}function pe(...e){console.error(new te(...e))}function he(e){const t=e.slice(1,-1);return"#"===t.charAt(0)?String.fromCodePoint(parseInt(t.substring(1).replace("x","0x"))):t in ce?ce[t]:(pe("ENTITY",e),e)}var me=Object.freeze({__proto__:null,parse:function(e,{createCalc:t=()=>{throw new te("CALC")},createInit:n=t,createEvent:r=()=>{throw new te("EVENT")},simpleTag:o=new Set,enableHTML:i=!1}={}){const s=[],l={children:s},a=[];let c=null,u=l;function d(){c=a.pop()||null,u=c||l}function f(e){(e=e.replace(/^\n|(?<=\n)\t+|\n\t*$/g,""))&&u.children.push(e)}let p={},h=0;function m(t){if(t<=h)return;f(e.substring(h,t).replace(/&#?\w+;/g,he)),h=t}for(;;){const g=e.indexOf("<",h);if(g<0){const O=e.substring(h);O.match(/^\s*$/)||f(O);break}g>h&&m(g);const b=e.charAt(g+1);if("!"===b){let $=g+2,A=">";if("--"===e.slice(g+2,g+4)&&($+=4,A="--\x3e"),h=e.indexOf(A,$),h<0)break;h++;continue}if("/"===b){h=e.indexOf(">",g+3);let j=e.substring(g+2,h);if(h<0?(j=e.substring(g+2).replace(/[\s<].*/,""),pe("UNCOMPLETED",j,c?.name),h=g+1+j.length):j.match(/\s</)&&(j=j.replace(/[\s<].*/,""),pe("UNCOMPLETED",j),h=g+1+j.length),c){const M=c.name;if(M===j)d();else{if(M.toLowerCase()!=j.toLowerCase())throw new te("CLOSE",j,c.name);d()}}h++;continue}function v(t){let n=h+1;if(h=e.indexOf(t,n),h<0)throw new te("QUOTE",t);const r=e.slice(n,h).replace(/&#?\w+;/g,he);return h++,r}function y(){let t=e.charAt(h);for(;t<=" "||""===t;t=e.charAt(++h));return t}function w(){let t=h,n=e.charAt(h);for(;de(n);)h++,n=e.charAt(h);return e.slice(t,h)}h=g+1;let E=e.charAt(h);switch(E){case"=":throw new te("EQUAL");case'"':case"'":throw new te("ATTR_VALUE");case">":case"/":throw new te("SYMBOL",E);case"":throw new te("EOF")}const x=w(),S=ue.exec(x)?.groups;if(!S)throw new te("TAG",x);a.push(c),c=ae(S.name,S.is),u.children.push(c),u=c;const C=le(c,t,n,r,i);let L=!0,N=!1;e:for(;L;){let T=y();switch(T){case"":pe("EOF"),h++;break e;case">":h++;break e;case"/":N=!0;break e;case'"':case"'":throw new te("ATTR_VALUE");case"=":throw new te("SYMBOL",T)}const k=w();if(!k){pe("EOF"),h++;break e}switch(T=y(),T){case"":pe("EOF"),h++;break e;case">":C(k,""),h++;break e;case"/":C(k,""),N=!0;break e;case"=":h++;break;case"'":case'"':C(k,v(T));continue;default:C(k,"");continue}switch(T=y(),T){case"":C(k,""),pe("EOF"),h++;break e;case">":C(k,""),h++;break e;case"/":C(k,""),N=!0;break e;case"'":case'"':C(k,v(T));continue}C(k,w())}if(N){for(;;){h++;const I=e.charAt(h);if("/"!==I&&!(I<=" "||""===I))break}switch(e.charAt(h)){case"=":throw new te("EQUAL");case'"':case"'":throw new te("ATTR_VALUE");case"":pe("EOF");break;case">":h++;break;default:throw new te("CLOSE_SYMBOL")}d()}else(o.has(x)||fe(e,h,x,p))&&d()}return X(s)}});function ge(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()})))})),o=new e.Signal.Computed(t);return r.watch(o),o.get(),()=>{r.unwatch(o)}}function be(e,t,n){let r,o=!1;return ge((()=>{const i=e();if(!o)return o=!0,r=i,void(n&&t(i));Object.is(i,r)||(r=i,t(i))}))}const ve=new Set(Object.keys({type:!0,meta:!0,component:!0,kind:!0,value:!0,store:!0,parent:!0,root:!0,ref:!0,schema:!0,new:!0,readonly:!0,creatable:!0,immutable:!0,changed:!0,loading:!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,size:!0,error:!0,errors:!0}));function*ye(e,t="",n="$"){yield[`${t}`,{get:()=>e.value,set:t=>e.value=t,store:e}];for(const r of ve)yield[`${t}${n}${r}`,{get:()=>e[r]}];yield[`${t}${n}value`,{get:()=>e.value,set:t=>e.value=t}],yield[`${t}${n}state`,{get:()=>null,set:e=>{}}],yield[`${t}${n}reset`,{exec:()=>e.reset()}],yield[`${t}${n}validate`,{exec:t=>e.validate(t?[]:null)}],e instanceof Q?(yield[`${t}${n}addable`,{get:()=>e.addable}],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)}]):yield[`${t}${n}addable`,{get:()=>!1}]}function we(e,t,n){for(const[n,r]of t){for(const[t,o]of ye(r,n))e[t]=o;for(const[t,o]of ye(r,n,"$$"))e[t]=o}}const Ee={value$:{calc:e=>e?.[q].value},state$:{calc:e=>e?.[q].state}};var xe=Object.getOwnPropertyDescriptors(Ee);function Se(e){if(!e)return!1;const t=e.indexOf("$");return t<0||(e.indexOf("$",t+2)>0||"$"===e[0]&&"_$".includes(e[1]))}function Ce(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 Le{exec({name:e,calc:t,value:n}){if("string"==typeof e){const t=this.#ge[e];if("function"!=typeof t?.get)return;return t.get()}return"function"==typeof t?t(this.getters):n}get({name:t,calc:n,value:r}){if("string"==typeof t){const e=this.#ge[t];if("function"!=typeof e?.get)return;const{get:n,set:r}=e;return{get:n,set:r}}if("function"==typeof n){const t=new e.Signal.Computed((()=>n(this.getters)));return{get:()=>t.get()}}return{get:()=>r}}watch(e,t){return be((()=>this.exec(e)),t,!0)}enum(e){const{name:t,calc:n}=e;if("function"==typeof n)return()=>n(this.getters);if("string"==typeof t){const e=this.#ge[t];if("function"!=typeof e?.get)return null;const n=e.store;return n instanceof Y?n:e.get}return this.store}getStore(e){if(!e)return null;const t=this.#ge[!0===e?"":e];return t?.get&&t.store||null}bind(e,t,n){const r=this.#ge[!0===e?"":e];if(!r?.get)return;const{store:o}=r;return o?ve.has(t)?be((()=>o[t]),n,!0):void 0:"value"===t?be((()=>r.get()),n,!0):void 0}bindAll(e){const t=this.#ge[!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=>be(e,t,!0)}}const r=Object.fromEntries([...ve].map((e=>[`$${e}`,t=>be((()=>n[e]),t,!0)])));return r.$$state=e=>be((()=>null),e,!0),r}getBindAll(e){const t=this.#ge[!0===e?"":e];if(!t?.get)return{};const{store:n}=t;if(!n){const{get:e,set:n}=t;return{$value:{get:e,set:n}}}const r=Object.fromEntries([...ve].map((e=>[`$${e}`,"value"===e?{get:()=>n[e],set:t=>{n[e]=t}}:{get:()=>n[e]}])));return r.$$state={get:()=>null,set:()=>{}},r}bindSet(e,t){const n=this.#ge[!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=>{}}}bindEvents(e){const t=this.#ge[!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=>{},$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({name:e,event:t}){if("function"==typeof t)return t;const n=this.#ge[e];if(!n)return null;const{exec:r,calc:o}=n;return"function"==typeof r?r:"function"==typeof o?o:null}constructor(e,t){if(this.store=e,t instanceof Le){this.#be=t.#be;const e=this.#ve;for(const[n,r]of Object.entries(t.#ve))e[n]=r;const n=this.#ye;for(const[e,r]of Object.entries(t.#ye))n[e]=r}else we(this.#ve,e),this.#be=function(e){const t=Object.create(null,xe);if(!e||"object"!=typeof e)return t;for(const[n,r]of Object.entries(e)){if(!Se(n))continue;if(!r||"object"!=typeof r)continue;if(r instanceof Y){for(const[e,o]of ye(r,n))t[e]=o;continue}const{get:e,set:o,exec:i,calc:s}=r;"function"!=typeof e?"function"==typeof s||s&&"object"==typeof s?t[n]={calc:s}:("function"==typeof i||s&&"object"==typeof s)&&(t[n]={exec:i}):t[n]="function"==typeof o?{get:e,set:o}:{get:e}}return t}(t)}#be;#ve=Object.create(null);#ye=Object.create(null);store;#we=null;#r=null;#Ee=null;get#ge(){const e=this.#Ee;if(e)return e;const t=Object.create(null,Object.getOwnPropertyDescriptors({...this.#ve,...this.#be,...this.#ye})),n=this.store,r=this.#r,o=this.#we;for(const[e,r]of ye(n))t[e]=r;for(const[e,o]of function*(e,t,n="",r="$"){if(!(e instanceof Q))return yield[`${n}${r}removable`,{get:()=>!1}],yield[`${n}${r}upMovable`,{get:()=>!1}],yield[`${n}${r}downMovable`,{get:()=>!1}],yield[`${n}${r}remove`,{exec:()=>{}}],yield[`${n}${r}upMove`,{exec:()=>{}}],void(yield[`${n}${r}downMove`,{exec:()=>{}}]);yield[`${n}${r}removable`,{get:()=>!e.readonly&&!e.disabled&&!!t.removable}],yield[`${n}${r}upMovable`,{get:()=>{if(e.readonly)return!1;if(e.disabled)return!1;const n=t.index;return"number"==typeof n&&!(n<=0)}}],yield[`${n}${r}downMovable`,{get:()=>{if(e.readonly)return!1;if(e.disabled)return!1;const n=t.index;return"number"==typeof n&&!(n>=e.size-1)}}],yield[`${n}${r}remove`,{exec:()=>{e.readonly||e.disabled||t.removable&&e.remove(Number(t.index))}}],yield[`${n}${r}upMove`,{exec:()=>{if(e.readonly)return;if(e.disabled)return;const n=t.index;"number"==typeof n&&(n<=0||e.move(n,n-1))}}],yield[`${n}${r}downMove`,{exec:()=>{if(e.readonly)return;if(e.disabled)return;const n=t.index;"number"==typeof n&&(n>=e.size-1||e.move(n,n+1))}}]}(r,n))t[e]=o;if(o)for(const e of Object.keys(o))t[`$${e}`]={get:()=>o[e]};return this.#Ee=t,t}setStore(e,t,n){const r=new Le(e,this);return t&&(r.#r=t),we(r.#ve,e),n&&(r.#we=n),r}child(e){if(!e)return this;const t=this.store.child(e);if(!t)return null;const n=new Le(t,this);return we(n.#ve,t),n}params(t,n,r,o){let i=this.store;if(!0===o)i=r.store;else if(o){const e=r.#ge[o],t=e?.get&&e.store;t&&(i=t)}if(0===Object.keys(t).length)return this;const s=new Le(i,this);s.#r=this.#r,s.#we=this.#we;const l=s.#ye,a=s.#ge;for(const[o,i]of Object.entries(t)){const t=o in n?n[o]:null;if(t){const{name:n,calc:i,value:s}=t;if(n){const e=r.#ge[n];if(!e?.get)continue;if(!e.store){l[o]=a[o]=e;continue}for(const[t,n]of ye(e.store,o))l[t]=a[t]=n;continue}if("function"==typeof i){const t=new e.Signal.Computed((()=>i(r.getters)));l[o]=a[o]={get:()=>t.get()};continue}l[o]=a[o]={get:()=>s}}else{const{name:t,calc:n,value:r}=i;if("function"==typeof n){const t=s.getters;s.#xe=null;const r=new e.Signal.Computed((()=>n(t)));l[o]=a[o]={get:()=>r.get()};continue}if(t){const e=a[t];if(!e?.get)continue;if(!e.store){l[o]=a[o]=e;continue}for(const[t,n]of ye(e.store,o))l[t]=a[t]=n;continue}l[o]=a[o]={get:()=>r}}}return s}setObject(e){const t=new Le(this.store,this);return t.#we=e,t}set(t){if(!t?.length)return this;const n=new Le(this.store,this);n.#r=this.#r,n.#we=this.#we;const r=n.#ye,o=n.#ge;for(const{variable:i,name:s,calc:l,value:a,init:c}of t)if(c){const t=new e.Signal.State(a);if("function"==typeof l){const e=n.settable;n.#Se=null,t.set(l(e))}else if(s){const e=o[s];if(!e?.get)continue;t.set(e.get())}r[i]=o[i]={get:()=>t.get(),set:e=>{t.set(e)}}}else if("function"!=typeof l)if(s){const e=o[s];if(!e)continue;if(!e.get||!e.store){r[i]=o[i]=e;continue}for(const[t,n]of ye(e.store,i))r[t]=o[t]=n}else r[i]=o[i]={get:()=>a};else{const t=n.getters;n.#xe=null;const s=new e.Signal.Computed((()=>l(t)));r[i]=o[i]={get:()=>s.get()}}return n}#Ce=null;get all(){const e=this.#Ce;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#ge))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 Ce(this.store,t),this.#Ce=t,t}#Se=null;get settable(){const e=this.#Se;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#ge))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 Ce(this.store,t),this.#Se=t,t}#xe=null;get getters(){const e=this.#xe;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#ge))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 Ce(this.store,t),this.#xe=t,t}}const Ne={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 Oe(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 o=Array.isArray(t)?t[0]:t;return"number"==typeof o||"bigint"==typeof o?r=o&&e in Ne?`${o}${Ne[e]}`:`${o}`:"string"==typeof o&&(r=o),r?[r,n?"important":void 0]:null}class $e{#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,o="number"==typeof e?String(e):e;let i=r.get(o);return i||(i=new Set,r.set(o,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 je(e,t,n){const r=[];if(t)for(let o=e.shift();o;o=e.shift()){const e=o.indexOf(":"),i=e>=0?o.slice(0,e):o,s=e>=0?o.slice(e+1).split(":"):[],l=i.replace(/^-+/,""),a=(i.length-l.length)%2==1;let c=t[l]||l;if(n)switch(c){case"once":case"passive":case"capture":n[c]=!a;continue}"string"==typeof c&&(c=Ae[c]),"function"==typeof c&&r.push([c,s,a])}return r}function Me(e,t,n){return r=>{const o=e.all;for(const[e,t,i]of n)if(e(r,t,o)===i)return;t(r,o)}}function Te(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 ke(e){return null===(e??null)?"":String(e)}function Ie(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 ke;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 Fe={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=ke(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=ke(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=ke(e)}},events:{$value:["change",(e,t)=>t.value]}}};function Be(e,t,n){const r=document.createElement(t,{is:n||void 0}),{watch:o,props:i}=e;return["input","textarea","select"].includes(t.toLowerCase())&&e.relate(r),e.listen("init",(({events:n})=>{const s=Fe[t.toLowerCase()],l=s?.attrs||{},a=s?.events||{};for(const[e,t,o]of n)if("$"!==e[0])r.addEventListener(e,t,o);else{const n=a[e];if(n){const[e,i]=n;r.addEventListener(e,(e=>t(i(e,r))),o)}}if(i)for(const[t,n]of Object.entries(e.attrs))if(o(t,(e=>{if(i.has(t))r[t]=e;else{const n=Te(e);null==n?r.removeAttribute(t):r.setAttribute(t,n)}})),i.has(t))r[t]=n;else{const e=Te(n);null!==e&&r.setAttribute(t,e)}else for(const[t,n]of Object.entries(e.attrs)){if(r instanceof HTMLInputElement&&"type"===t.toLocaleLowerCase()){const e=Te(n);null!==e&&r.setAttribute(t,e);continue}if("$hidden"===t){n&&(r.hidden=n),o(t,(e=>{r.hidden=e}));continue}if("$"===t[0]){const e=l[t];e&&(e(n,r),o(t,(t=>e(t,r))));continue}const e=Ie(r,t);if("function"==typeof e){r[t]=e(n),o(t,(n=>{r[t]=e(n)}));continue}if(e){r[t]=n,o(t,(e=>{r[t]=e}));continue}let i=Te(n);null!==i&&r.setAttribute(t,i),o(t,(e=>{const n=Te(e);null===n?r.removeAttribute(t):r.setAttribute(t,n)}))}})),r}function Pe(e){return null===(e??null)?"":String(e)}function Re(e,t,n,r,o){if(!o){const o=e.insertBefore(document.createTextNode(""),t),i=n.watch(r,(e=>o.textContent=Pe(e)));return()=>{o.remove(),i()}}const i=e.insertBefore(document.createComment(""),t),s=e.insertBefore(document.createComment(""),t),l=document.createElement("div");function a(){for(let e=i.nextSibling;e&&e!==s;e=i.nextSibling)e.remove()}const c=n.watch(r,(t=>{a(),function(t){l.innerHTML=t;for(let t=l.firstChild;t;t=i.firstChild)e.insertBefore(t,s)}(Pe(t))}));return()=>{c(),a(),i.remove(),s.remove()}}function Ue(e,t){if("bigint"==typeof e&&"bigint"==typeof t)return Number(e-t);if(!("number"!=typeof e&&"bigint"!=typeof e||"number"!=typeof t&&"bigint"!=typeof t))return Number(e)-Number(t);const n=String(e),r=String(t);return n>r?1:n<r?-1:0}const qe=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);function De(e,t,n,r,o){const i=e.children;if(!i.length)return()=>{};const s=t.insertBefore(document.createComment(""),n);let l=null,a=()=>{};const c=be((()=>i.find((([,e])=>!e||r.exec(e)))||null),(e=>{if(e===l)return;l=e,a(),a=()=>{};const t=e?.[0];t&&(a=o(t.children,t.vars,t.templates))}),!0);let u=!1;return()=>{u||(u=!0,c(),a(),a=()=>{},s.remove())}}function Ve(t,n,r,o,i,s,l,a,c){const u=t.bind,d=[...s,t.name],f=c?.(d);if(c&&!f)return()=>{};const{context:p,handler:h}=function(t,n,r,o){const i="string"==typeof t?t:t.tag,{attrs:s,events:l}="string"!=typeof t&&t||{attrs:null,events:null};let a=!1;const c=new e.Signal.State(!1);let u=!1;const d=new e.Signal.State(!1),f=Object.create(null),p=Object.create(null),h=new Set,m=[],g=new $e;return{context:{events:m,props:s?new Set(Object.entries(s).filter((([,e])=>e.isProp)).map((([e])=>e))):null,attrs:p,watch(e,t){if(a)return()=>{};const n=f[e];if(!n)return()=>{};let r=n.get();const o=be((()=>n.get()),(n=>{const o=r;r=n,t(n,o,e)}),!0);return h.add(o),()=>{h.delete(o),o()}},relate(e){if(!r||!o||a)return()=>{};try{const t=o(r,e);return"function"!=typeof t?()=>{}:(h.add(t),()=>{h.delete(t),t()})}catch{return()=>{}}},get destroyed(){return c.get()},get init(){return d.get()},listen:(e,t)=>g.listen(e,t)},handler:{tag:i,set(t,n){if(s&&!(t in s))return;let r=f[t];if(r)return void r.set(n);const o=new e.Signal.State(n);f[t]=o,Object.defineProperty(p,t,{configurable:!0,enumerable:!0,get:o.get.bind(o)})},addEvent(e,t){if("function"!=typeof t)return;const[r,...o]=e.split(".").filter(Boolean),i=l?l[r].filters:{};if(!i)return;const s={},a=je(o,i,s);m.push([r,Me(n,t,a),s])},destroy(){if(!a){a=!0,c.set(!0);for(const e of h)e();g.emit("destroy")}},mount(){u||(u=!0,d.set(!0),g.emit("init",{events:m}))}}}}(f||t.name,o,o.getStore(u),a),m=f?.attrs,g=m?function(e,t,n,r,o){let i=new Set;for(const[s,l]of Object.entries(r)){if("class"===s||"style"===s)continue;if(s in n){const r=n[s],{name:o,calc:a,value:c}=n[s];if(!o&&!a){e.set(s,c);continue}l.immutable&&e.set(s,t.exec(r)),i.add(t.watch(r,(t=>e.set(s,t))));continue}const r=l.bind;if(!o||!r){e.set(s,l.default);continue}if("string"==typeof r){const n=t.bind(o,r,(t=>e.set(s,t)));n?i.add(n):e.set(s,l.default);continue}if(!Array.isArray(r)){e.set(s,l.default);continue}const[a,c,u]=r;if(!a||"function"!=typeof c)continue;if(!u){const n=!0===o?"":o;i.add(t.watch({name:n},(t=>e.set(s,t)))),e.addEvent(a,((...e)=>{t.all[n]=c(...e)}));continue}const d=t.bind(o,"state",(t=>e.set(s,t)));if(!d)continue;i.add(d);const f=t.bindSet(o,"state");f&&e.addEvent(a,((...e)=>{f(c(...e))}))}return()=>{const e=i;i=new Set;for(const t of e)t()}}(h,o,t.attrs,m,u):function(e,t,n){const r=e.tag;let o=new Set;for(const[i,s]of Object.entries(n)){if("class"===i||"style"===i)continue;const{name:n,calc:l,value:a}=s;if(n||l)if("string"!=typeof r||"input"!==r.toLocaleLowerCase()||"type"!==i.toLocaleLowerCase())o.add(t.watch(s,(t=>e.set(i,t))));else{const n=t.exec(s);e.set(i,n)}else e.set(i,a)}return()=>{const e=o;o=new Set;for(const t of e)t()}}(h,o,t.attrs);for(const[e,n]of Object.entries(t.events)){const t=o.getEvent(n);t&&h.addEvent(e,t)}const b=function(e,t,n){if(!n)return()=>{};let r=new Set;for(const[o,i]of Object.entries(t.bindAll(n)||{}))"function"==typeof i&&r.add(i((t=>e.set(o,t))));for(const[r,o]of Object.entries(t.bindEvents(n)||{}))e.addEvent(r,(e=>o(e)));return()=>{const e=r;r=new Set;for(const t of e)t()}}(h,o,u),v=f?"function"==typeof f.tag?f.tag(p):Be(p,f.tag,f.is):Be(p,t.name,t.is),y=Array.isArray(v)?v[0]:v,w=Array.isArray(v)?v[1]:y;n.insertBefore(y,r);const E=w?He(t.children||[],w,null,o,i,s,l,a,c):()=>{},x=function(e,t,n,r){if(!(e instanceof Element))return()=>{};r&&(e.className+=" "+t.exec(r));let o=new Set;for(const[r,i]of Object.entries(n))i.value?e.classList.add(r):o.add(be((()=>Boolean(t.exec(i))),(t=>{t?e.classList.add(r):e.classList.remove(r)}),!0));return()=>{if(!o)return;const e=o;o=null;for(const t of e)t()}}(y,o,t.classes,t.attrs.class),S=function(e,t,n,r){if(!(e instanceof HTMLElement||e instanceof SVGElement))return()=>{};if(r){const n=[e.getAttribute("style")||"",t.exec(r)||""].filter(Boolean).join(";");n&&e.setAttribute("style",n)}let o=new Set;for(const[r,i]of Object.entries(n))o.add(be((()=>Oe(r,t.exec(i))),(t=>{t?e.style.setProperty(r,...t):e.style.removeProperty(r)}),!0));return()=>{if(!o)return;const e=o;o=null;for(const t of e)t()}}(y,o,t.styles,t.attrs.style);h.mount();const C=function(t,n,r,o,i,s){let l=new Set;for(const[a,{attrs:c,value:u,events:d,bind:f}]of Object.entries(n)){if(!qe(o,a))continue;const p=o[a];if("function"!=typeof p)continue;let h=!1;const m=new e.Signal.State(!1),g=p?.events,b=[],v=Object.create(null),y=new Set,w=new $e;function E(e,t){if("function"!=typeof t)return;const[n,...o]=e.split(".").filter(Boolean),i=g?g[n].filters:{};if(!i)return;const s={},l=je(o,i,s);b.push([n,Me(r,t,l),s])}function x(){if(!h){h=!0,m.set(!0);for(const e of y)e();w.emit("destroy")}}l.add(x);for(const[C,L]of Object.entries(c)){const N=r.get(L);N&&Object.defineProperty(v,C,{...N,configurable:!0,enumerable:!0})}for(const[O,$]of Object.entries(d)){const A=r.getEvent($);A&&E(O,A)}if(f){for(const[j,M]of Object.entries(r.getBindAll(f)||{}))Object.defineProperty(v,j,{...M,configurable:!0,enumerable:!0});for(const[T,k]of Object.entries(r.bindEvents(f)||{}))E(T,(e=>k(e)))}const S={get value(){return null},events:b,attrs:v,watch(e,t){if(h)return()=>{};let n=v[e];const r=be((()=>v[e]),(r=>{const o=n;n=r,t(r,o,e)}),!0);return y.add(r),()=>{y.delete(r),r()}},get destroyed(){return m.get()},listen:(e,t)=>w.listen(e,t),root:i,slot:s,tag:t};if(u){const I=r.get(u);I&&Object.defineProperty(S,"value",{...I,configurable:!0,enumerable:!0})}p(S)}return()=>{const e=l;l=new Set;for(const t of e)t()}}(h.tag,t.enhancements,o,l,y,w);return()=>{C(),h.destroy(),y.remove(),g(),E(),b(),x(),S()}}function _e(e,t,n){if(!n)return t;const r=Object.entries(n);if(!r.length)return t;const o=Object.create(t);for(const[t,n]of r)o[t]=[n,e];return o}function We(t,n,r,o,i,s,l,a,c){if("string"==typeof t){const e=document.createTextNode(t);return n.insertBefore(e,r),()=>e.remove()}const u=o.set(t.vars),d=_e(u,i,t.templates);if("divergent"===t.type)return De(t,n,r,u,((e,t,o)=>{const d=u.set(t),f=_e(d,i,o);return He(e,n,r,d,f,s,l,a,c)}));if("value"===t.type){const e=u.child(t.name);return e?He(t.children,n,r,e,d,s,l,a,c):()=>{}}if("enum"===t.type){const o=u.enum(t.value),i=(e,r)=>He(t.children,n,e,r,d,s,l,a,c);return o instanceof Q?function(t,n,r,o,i){const s=t.insertBefore(document.createComment(""),n);let l=new Map;function a(e){for(const[t,n,r]of e.values())r(),t.remove(),n.remove()}const c=new e.Signal.State(0),u=be((()=>r.children),(function(e){if(!s.parentNode)return;let n=s.nextSibling;const u=l;l=new Map,c.set(e.length);for(let s of e){const e=u.get(s);if(!e){const e=t.insertBefore(document.createComment(""),n),a=t.insertBefore(document.createComment(""),n),u=i(a,o.setStore(s,r,{get count(){return c.get()},get key(){return s.index},get index(){return s.index},get item(){return s.value}}));l.set(s,[e,a,u]);continue}if(u.delete(s),l.set(s,e),n===e[0]){n=e[1].nextSibling;continue}let a=e[0];for(;a&&a!==e[1];){const e=a;a=a.nextSibling,t.insertBefore(e,n)}t.insertBefore(e[1],n)}a(u)}),!0);return()=>{s.remove(),a(l),u()}}(n,r,o,u,i,t.sort):o instanceof G?function(e,t,n,r,o,i){const s=[],l=[...n],a=l.length,c=i?l.map((([e,t])=>[e,t,r.setStore(t,n).exec(i)])).sort((([,,e],[,,t])=>Ue(e,t))).map((([e,t],n)=>[e,t,n])):l.map((([e,t],n)=>[e,t,n]));for(const[e,i,l]of c)s.push(o(t,r.setStore(i,n,{get count(){return a},get key(){return e},get index(){return l},get item(){return i.value}})));return()=>{for(const e of s)e()}}(0,r,o,u,i,t.sort):"function"==typeof o?function(t,n,r,o,i,s){const l=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])):[]}return e&&"object"==typeof e?Array.isArray(e)?e.map(((e,t)=>[e,t])):Object.entries(e).map((([e,t])=>[t,e])):[]})),a=s?new e.Signal.Computed((()=>{const e=l.get();return e.map((([t,n],r)=>[n,t,o.setObject({get count(){return e.length},get key(){return t},get item(){return n},get index(){return r}}).exec(s)])).sort((([,,e],[,,t])=>Ue(e,t))).map((([e,t],n)=>[t,n,e]))})):new e.Signal.Computed((()=>l.get().map((([e,t],n)=>[t,n,e])))),c=t.insertBefore(document.createComment(""),n);let u=[];function d(e){for(const[t,n,r]of e)r(),t.remove(),n.remove()}const f=new e.Signal.State(0),p=be((()=>a.get()),(function(n){if(!c.parentNode)return;let r=c.nextSibling;const s=u;u=[],f.set(n.length);for(const[l,a,c]of n){const n=s.findIndex((e=>e[3]===c)),[d]=n>=0?s.splice(n,1):[];if(!d){const n=t.insertBefore(document.createComment(""),r),s=t.insertBefore(document.createComment(""),r),d=new e.Signal.State(l),p=new e.Signal.State(a),h=i(s,o.setObject({get count(){return f.get()},get key(){return c},get item(){return d.get()},get index(){return p.get()}}));u.push([n,s,h,c,d,p]);continue}if(u.push(d),d[4].set(l),d[5].set(a),r===d[0]){r=d[1].nextSibling;continue}let p=d[0];for(;p&&p!==d[1];){const e=p;p=p.nextSibling,t.insertBefore(e,r)}t.insertBefore(d[1],r)}d(s)}),!0);return()=>{c.remove(),d(u),p()}}(n,r,o,u,i,t.sort):()=>{}}if("content"===t.type)return Re(n,r,u,t.value,t.html);if("template"===t.type){const e=d[t.template];if(!e)return()=>{};const[o,f]=e,p=f.params(o.params,t.attrs,u,t.bind),h=_e(p,i,o.templates);return He(o.children,n,r,p,h,s,l,a,c)}return"fragment"===t.type?He(t.children,n,r,u,d,s,l,a,c):Ve(t,n,r,u,d,s,l,a,c)}function He(e,t,n,r,o,i,s,l,a){const c=e.map((e=>We(e,t,n,r,o,i,s,l,a)));let u=!1;return()=>{if(!u){u=!0;for(const e of c)e()}}}function Ke(e){return function(t){return(!t.type||"field"===t.type)&&t.field===e}}function ze(e,t,n,r,o,i,s){const l=[];if(n instanceof Element){const a=n.tagName.toLowerCase();if(!n.parentNode)return()=>{};if("nl-form-field"===a){const f=n.getAttribute("name")||"",p=n.getAttribute("mode")||"",h=f?e.child(f):e,m=f&&o?.fields?.find(Ke(f))||null;if(!h)return()=>{};if("grid"===p){const[v,y]=dt(e,t,m,r);return n.replaceWith(v),y}const g=h.component;if(g){const w=t(h,g,r);if(w){const[E,x]=w;return n.replaceWith(E),x}}const b=n.getAttribute("placeholder")||"";return n.replaceWith(document.createTextNode(b)),()=>{}}if("nl-form-button"===a){const S=document.createElement("button");S.className="NeeloongForm-item-button";const C=n.getAttribute("click")||"",L=r?.call;C&&"function"==typeof L&&S.addEventListener("click",(t=>L(C,t,e,r)));for(const N of[...n.childNodes])S.appendChild(N);return n.replaceWith(S),()=>{}}const c=n.getAttribute("nl-form-field");if(c){const O=c.endsWith("[]"),$=O?c.slice(0,c.length-2):c,A=$?e.child($):e;if(!A)return()=>{};n.removeAttribute("nl-form-field");const j=$?o?.fields?.find(Ke($)):o;if(!O)return ze(A,t,n,r,j,i);if(!(A instanceof Q))return n.remove(),()=>{};const M=n.parentElement;if(!M)return n.remove(),()=>{};const T=M.insertBefore(document.createComment(""),n)||null;n.remove();let k=new Map;function I(e){for(const[t,n]of e.values())n(),t instanceof Element&&t.remove()}let F=-1;const B=e=>{if(F<0)return;const t=e?Number(e.index):A.children.length;t<0||F<0||F===t||A.move(F,t)&&(F=t)},P=be((()=>A.children),(e=>{let o=T.nextSibling;const i=k;k=new Map;for(const s of e){const e=i.get(s);if(e)i.delete(s),k.set(s,e),o!==e[0]?M.insertBefore(e[0],o):o=o.nextSibling;else{const e=M.insertBefore(n.cloneNode(!0),o),i=ze(s,t,e,r,j,e);e.addEventListener("dragenter",(()=>{B(s)})),e.addEventListener("dragstart",(e=>{e.target===e.currentTarget&&(F=Number(s.index))})),e.addEventListener("dragend",(()=>{F=-1})),k.set(s,[e,i])}}I(i)}),!0);return()=>{T.remove(),I(k),P()}}if(null!==n.getAttribute("nl-form-remove")){const R=e.parent;R instanceof Q&&n.addEventListener("click",(()=>{R.remove(Number(e.index))}))}null!==n.getAttribute("nl-form-move")&&i instanceof HTMLElement&&n.addEventListener("pointerdown",(({pointerId:e})=>{i.draggable=!0;const t=n=>{n.pointerId===e&&(i.draggable=!1,window.removeEventListener("pointerup",t,{capture:!0}),window.removeEventListener("pointercancel",t,{capture:!0}))};window.addEventListener("pointerup",t,{capture:!0}),window.addEventListener("pointercancel",t,{capture:!0})}));const u=n.getAttribute("nl-form-add");if(u){const U=e.child(u);U instanceof Q&&n.addEventListener("click",(()=>{U.add({})}))}const d=r?.call;for(const q of[...n.getAttributeNames()]){const D=q.indexOf(":");if(D<0)continue;const V=q.slice(0,D).toLowerCase(),_=q.slice(D+1);if("nl-form-field"===V){const W=n.getAttribute(q),H=W?e.child(W):e;if(!H)continue;l.push(ge((()=>{try{n.setAttribute(_,H.value)}catch{}})))}else if("nl-form-event"===V&&"function"==typeof d){const K=n.getAttribute(q);if(!K)continue;try{n.addEventListener(_,(t=>d(K,t,e,r)))}catch{}}}}if(n instanceof Element||n instanceof DocumentFragment)for(const z of[...n.children])l.push(ze(e,t,z,r,o,i));return()=>{for(const e of l)e()}}function Ye(e){if(!e)return document.createElement("template").content;if("string"!=typeof e)return e.cloneNode(!0);const t=document.createElement("template");return t.innerHTML=e,t.content}function Ge(e,t,n,r){const{component:o}=e;return o&&t(e,o,r)||[document.createElement("div"),()=>{}]}function Qe(e,t,n,{columns:r,remove:o,dragenter:i,dragstart:s,dragend:l,deletable:a},c){const u=document.createElement("tbody");u.addEventListener("dragenter",(()=>{i()})),u.addEventListener("dragstart",(e=>{e.target===e.currentTarget&&s()})),u.addEventListener("dragend",l);const d=u.appendChild(document.createElement("tr")),f=[];let p=()=>{};const h=[];if(r.find((e=>e.actions?.includes("trigger")))){const o=u.appendChild(document.createElement("tr")),i=o.appendChild(document.createElement("td"));i.colSpan=r.length;const[s,l]=dt(e,t,n,c);i.appendChild(s),f.push(l),o.hidden=!0,p=function(){if(o.hidden){o.hidden=!1;for(const e of h)e.classList.remove("NeeloongForm-table-line-open"),e.classList.add("NeeloongForm-table-line-close")}else{o.hidden=!0;for(const e of h)e.classList.remove("NeeloongForm-table-line-close"),e.classList.add("NeeloongForm-table-line-open")}}}function m({pointerId:e}){function t(n){n.pointerId===e&&u&&(u.draggable=!1,window.removeEventListener("pointerup",t,{capture:!0}),window.removeEventListener("pointercancel",t,{capture:!0}))}u.draggable=!0,window.addEventListener("pointerup",t,{capture:!0}),window.addEventListener("pointercancel",t,{capture:!0})}for(const n of r){const{actions:r,field:i,pattern:s}=n;if(!r?.length){const n=d.appendChild(document.createElement("td")),r=i&&e.child(i);if(r){const[e,o]=Ge(r,t,0,c);f.push(o),n.appendChild(e)}continue}const l=d.appendChild(document.createElement("th"));l.classList.add("NeeloongForm-table-line-handle");for(const t of r)switch(t){case"trigger":{const e=l.appendChild(document.createElement("button"));e.classList.add("NeeloongForm-table-line-open"),h.push(e),e.addEventListener("click",p);continue}case"move":{if(!c?.editable)continue;const t=l.appendChild(document.createElement("button"));t.classList.add("NeeloongForm-table-move"),t.addEventListener("pointerdown",m),f.push(be((()=>e.readonly||e.disabled),(e=>{t.disabled=e}),!0));continue}case"remove":{if(!c?.editable)continue;const t=l.appendChild(document.createElement("button"));t.classList.add("NeeloongForm-table-remove"),t.addEventListener("click",o),f.push(be((()=>!a.get()||e.readonly||e.disabled),(e=>{t.disabled=e}),!0));continue}case"serial":l.appendChild(document.createElement("span")).classList.add("NeeloongForm-table-serial");continue}}return[u,()=>{for(const e of f)e()}]}function Xe(e,t,n,r,o){const i=e.appendChild(document.createElement("tr")),s=[];for(const{action:e,actions:l,width:a,label:c}of t){const t=i.appendChild(document.createElement("th"));if(a&&t.setAttribute("width",`${a}`),![e,l].flat().includes("add")){t.innerText=c||"";continue}if(!o)continue;const u=t.appendChild(document.createElement("button"));u.addEventListener("click",n),u.classList.add("NeeloongForm-table-add"),s.push(be((()=>!r.get()),(e=>{u.disabled=e}),!0))}return()=>{for(const e of s)e()}}function Ze(t,n,r,o){const i=r?.columns,s=Object.entries(t.type||{}).filter((([e,t])=>"object"!=typeof t?.type)).map((([e,{width:t,label:n}])=>({field:e,width:t,label:n})));let l=[];if(Array.isArray(i)){const e=new Map(s.map((e=>[e.field,e]))),t=i.map((t=>{if(!t)return null;if("number"==typeof t)return{placeholder:t};if("string"==typeof t)return e.get(t)||null;if("object"!=typeof t)return null;if(Array.isArray(t)){const e=new Set(["add","move","trigger","remove","serial","open","collapse"]),n=t.filter((t=>e.delete(t)));return n?{actions:n}:null}const{action:n,actions:r,field:o,placeholder:i,pattern:s,width:l,label:a}=t;if(o){const t=e.get(o);if(t)return{field:o,placeholder:i,width:l,label:a||t.label}}const c=new Set(["add","move","trigger","remove","serial"]),u=[n,r].flat().filter((e=>e&&c.delete(e)));return u.length?{actions:u,width:l,label:a}:null}));l=t.filter(Boolean)}l.length||(l=[{actions:["add","trigger","move","remove","serial"]},...s.slice(0,3)]);const a=document.createElement("table");a.className="NeeloongForm-table";const c=a.appendChild(document.createElement("thead")),u=new e.Signal.Computed((()=>t.addable)),d={get:()=>Boolean(o?.editable)};function f(){t.add({})}function p(e){t.remove(Number(e.index))}let h=-1;function m(e){if(h<0)return;const n=e?Number(e.index):t.children.length;n<0||h<0||h===n||t.move(h,n)&&(h=n)}function g(e){h=Number(e.index)}function b(){h=-1}const v=[];switch(v.push(Xe(c,l,f,u,Boolean(o?.editable))),r?.tableFoot){default:case"header":{const e=a.appendChild(document.createElement("tfoot"));e.addEventListener("dragenter",(()=>{m()})),v.push(Xe(e,l,f,u,Boolean(o?.editable)));break}case"add":{const e=a.appendChild(document.createElement("tfoot"));e.addEventListener("dragenter",(()=>{m()}));const t=e.appendChild(document.createElement("tr")).appendChild(document.createElement("th"));t.colSpan=l.length;const n=t.appendChild(document.createElement("button"));n.addEventListener("click",f),n.classList.add("NeeloongForm-table-foot-add"),v.push(be((()=>!u.get()),(e=>{n.disabled=e}),!0));break}case"none":}const y=c;let w=new Map;function E(e){for(const[t,n]of e.values())n(),t.remove()}const x=be((()=>t.children),(function(e){let t=c.nextSibling;const i=w;w=new Map;for(let s of e){const e=i.get(s);if(e)i.delete(s),w.set(s,e),t!==e[0]?a.insertBefore(e[0],t):t=t.nextSibling;else{const[e,i]=Qe(s,n,r,{columns:l,remove:p.bind(null,s),dragenter:m.bind(null,s),dragstart:g.bind(null,s),dragend:b,deletable:d},o);a.insertBefore(e,t),w.set(s,[e,i])}}E(i)}),!0);return[a,()=>{y.remove(),c.remove(),E(w),x();for(const e of v)e()}]}function Je(e,t){const{colStart:n,colSpan:r,colEnd:o,rowStart:i,rowSpan:s,rowEnd:l}=t||{};e.classList.add("NeeloongForm-item-grid"),n&&o?e.style.gridColumn=`${n} / ${o}`:n&&r?e.style.gridColumn=`${n} / span ${r}`:r&&(e.style.gridColumn=`span ${r}`),i&&l?e.style.gridRow=`${i} / ${l}`:i&&s?e.style.gridRow=`${i} / span ${s}`:s&&(e.style.gridRow=`span ${s}`)}function et(e,t){return ge((()=>{t?.error?e.classList.add("NeeloongForm-item-errored"):e.classList.remove("NeeloongForm-item-errored")}))}function tt(e,t){return ge((()=>{t?.required?e.classList.add("NeeloongForm-item-required"):e.classList.remove("NeeloongForm-item-required")}))}function nt(e){const t=[],n=document.createElement("div");n.className="NeeloongForm-item",t.push(tt(n,e));const r=n.appendChild(document.createElement("div"));r.className="NeeloongForm-item-label",t.push(ge((()=>r.innerText=e?.label||"")));const o=n.appendChild(document.createElement("div"));o.className="NeeloongForm-item-content";const i=n.appendChild(document.createElement("div"));i.className="NeeloongForm-item-description",t.push(ge((()=>i.innerText=e?.description||"")));const s=n.appendChild(document.createElement("div"));return s.className="NeeloongForm-item-error",t.push(ge((()=>s.innerText=e?.error||""))),t.push(et(n,e)),[n,()=>{for(const e of t)e()},o,t]}function rt(e,t,n,r){function o(n){if(!n)return null;if(!r)switch(n){case"inline":{const n=nt(t);return Je(n[0],e),n}case"base":{const n=function(e){const t=[],n=document.createElement("div");return n.className="NeeloongForm-item",t.push(tt(n,e)),t.push(et(n,e)),[n,()=>{for(const e of t)e()},n,t]}(t);return Je(n[0],e),n}}switch(n){case"block":return nt(t);case"fieldset":return function(e){const t=[],n=document.createElement("fieldset");n.className="NeeloongForm-item",t.push(tt(n,e));const r=n.appendChild(document.createElement("legend"));return t.push(ge((()=>r.innerText=e?.label||""))),t.push(et(n,e)),[n,()=>{for(const e of t)e()},n,t]}(t);case"collapse":return function(e){const t=[],n=document.createElement("details");n.className="NeeloongForm-item",t.push(tt(n,e)),n.open=!0;const r=n.appendChild(document.createElement("summary"));return t.push(ge((()=>r.innerText=e?.label||""))),t.push(et(n,e)),[n,()=>{for(const e of t)e()},n,t]}(t)}return null}return o(e?.cell)||o(n)||nt(t)}function ot(t,n,r,o,i,{columns:s,remove:l,dragenter:a,dragstart:c,dragend:u,deletable:d,addNode:f,drop:p,createDetails:h},m){const g=new e.Signal.State(i),b=document.createElement("div");b.addEventListener("dragstart",(e=>{e.target===e.currentTarget&&c()})),b.addEventListener("dragend",u);const v=[];b.classList.add("NeeloongForm-tree-item"),v.push(ge((()=>{n.get()===t?b.classList.add("NeeloongForm-tree-current"):b.classList.remove("NeeloongForm-tree-current")}))),v.push(ge((()=>{const e=g.get().level;b.style.setProperty("--NeeloongForm-tree-level",`${e}`)}))),v.push(ge((()=>{b.hidden=g.get().hidden})));const y=[];function w({pointerId:e}){function t(n){n.pointerId===e&&b&&(b.draggable=!1,window.removeEventListener("pointerup",t,{capture:!0}),window.removeEventListener("pointercancel",t,{capture:!0}))}b.draggable=!0,window.addEventListener("pointerup",t,{capture:!0}),window.addEventListener("pointercancel",t,{capture:!0})}function E(){const e=g.get();e.collapsed=!e.collapsed}let x=()=>{};function S(){x=h(t)}function C(){n.get()!==t?x=h(t):x()}const L="move"===o?.mainMethod?w:null,N=L?null:"collapse"===o?.mainMethod?E:"trigger"===o?.mainMethod?C:S,O=b.appendChild(document.createElement("div"));O.classList.add("NeeloongForm-tree-line");const $=b.appendChild(document.createElement("div"));$.classList.add("NeeloongForm-tree-drop");const A=b.appendChild(document.createElement("div"));A.classList.add("NeeloongForm-tree-drop-children"),$.addEventListener("dragover",(e=>e.preventDefault())),A.addEventListener("dragover",(e=>e.preventDefault())),$.addEventListener("drop",(()=>p())),A.addEventListener("drop",(()=>p(!0))),v.push(ge((()=>{$.hidden=A.hidden=!g.get().droppable})));let j=()=>{};$.addEventListener("dragenter",(()=>j=a($))),A.addEventListener("dragenter",(()=>j=a(A))),$.addEventListener("dragleave",(()=>j())),A.addEventListener("dragleave",(()=>j()));for(const{actions:e,pattern:n,placeholder:o,width:i,field:a}of s)if(e?.length)for(const n of e)switch(n){case"trigger":{const e=O.appendChild(document.createElement("button"));e.classList.add("NeeloongForm-tree-trigger"),e.addEventListener("click",C);continue}case"open":{const e=O.appendChild(document.createElement("button"));e.classList.add("NeeloongForm-tree-open"),e.addEventListener("click",S);continue}case"collapse":{const e=O.appendChild(document.createElement("button"));e.classList.add("NeeloongForm-tree-collapse"),e.addEventListener("click",E),y.push(e);continue}case"move":{if(!m?.editable)continue;const e=O.appendChild(document.createElement("button"));e.classList.add("NeeloongForm-tree-move"),e.addEventListener("pointerdown",w),v.push(be((()=>t.readonly||t.disabled),(t=>{e.disabled=t}),!0));continue}case"add":{if(!m?.editable)continue;const e=O.appendChild(document.createElement("button"));e.classList.add("NeeloongForm-tree-add"),e.addEventListener("click",f),v.push(be((()=>t.readonly||t.disabled),(t=>{e.disabled=t}),!0));continue}case"remove":{if(!m?.editable)continue;const e=O.appendChild(document.createElement("button"));e.classList.add("NeeloongForm-tree-remove"),e.addEventListener("click",l),v.push(be((()=>!d.get()||t.readonly||t.disabled),(t=>{e.disabled=t}),!0));continue}case"serial":O.appendChild(document.createElement("span")).classList.add("NeeloongForm-tree-serial");continue}else{const e=O.appendChild(document.createElement("div"));if(e.classList.add("NeeloongForm-tree-cell"),N&&e.addEventListener("click",N),L&&e.addEventListener("pointerdown",L),a){const n=t.child(a);if(!n)continue;const[o,i]=Ge(n,r,0,{...m,editable:!1});v.push(i),e.appendChild(o);continue}"number"==typeof o&&(e.style.flex=`${o}`),"number"==typeof i&&(e.style.width=`${i}px`)}return v.push(ge((()=>{const e=g.get();if(e.hasChildren)if(e.collapsed)for(const e of y)e.classList.remove("NeeloongForm-tree-collapse-close"),e.classList.add("NeeloongForm-tree-collapse-open"),e.disabled=!1;else for(const e of y)e.classList.remove("NeeloongForm-tree-collapse-open"),e.classList.add("NeeloongForm-tree-collapse-close"),e.disabled=!1;else for(const e of y)e.classList.remove("NeeloongForm-tree-collapse-close"),e.classList.remove("NeeloongForm-tree-collapse-open"),e.disabled=!0}))),[b,()=>{for(const e of v)e()},e=>g.set(e)]}const it=new Set(["vertical-lr","vertical-rl","sideways-lr","sideways-rl"]);function st(e){const t=getComputedStyle(e),n=t.writingMode?.toLowerCase();return[it.has(n),"rtl"===t.direction.toLowerCase()!=("sideways-lr"===n)]}function lt(t,n,r,o,i){const s=new e.Signal.Computed((()=>{const e=t.child(i);return e?Math.max(0,Math.floor(e.value?.[o])||0):0})),l=new e.Signal.Computed((()=>{if(!t.child(i))return-1;const e=s.get();if(!e)return-1;for(let t=i-1;t>=0;t--)if(e>n[t]?.levelValue)return t;return-1})),a=new e.Signal.Computed((()=>{const e=t.children,n=e[i+1];if(!n)return!1;if(!e[i])return!1;const r=s.get();return Math.floor(n.child(o)?.value)>r})),c=new e.Signal.Computed((()=>{if(r.get()===i)return!1;const e=l.get(),t=n[e];return!t||t.droppable})),u=new e.Signal.Computed((()=>{const e=l.get(),t=n[e];return t?t.level+1:0})),d=new e.Signal.State(!1),f=new e.Signal.Computed((()=>{const e=l.get(),t=n[e];return!!t&&(t.collapsed||t.hidden)})),p=new e.Signal.Computed((()=>{const e=l.get(),t=n[e];if(!t)return new Set;const r=new Set(t.parents);return r.add(e),r}));return{get level(){return u.get()},get levelValue(){return s.get()},get collapsed(){return d.get()},set collapsed(e){d.set(e)},get hidden(){return f.get()},get hasChildren(){return a.get()},get droppable(){return c.get()},get parents(){return p.get()}}}function at(t,n,r,o){const i=r?.columns,s=Object.entries(t.type||{}).filter((([e,t])=>"object"!=typeof t?.type)).map((([e,{width:t,label:n}])=>({field:e,width:t,label:n})));let l=[];if(Array.isArray(i)){const e=new Map(s.map((e=>[e.field,e]))),t=i.map((t=>{if(!t)return null;if("number"==typeof t)return{placeholder:t};if("string"==typeof t)return e.get(t)||null;if("object"!=typeof t)return null;if(Array.isArray(t)){const e=new Set(["add","move","trigger","remove","serial","open","collapse"]),n=t.filter((t=>e.delete(t)));return n?{actions:n}:null}const{action:n,actions:r,field:o,placeholder:i,pattern:s,width:l,label:a}=t;if(o){const t=e.get(o);if(t)return{field:o,placeholder:i,width:l,label:a||t.label}}const c=new Set(["add","move","trigger","remove","serial","open","collapse"]),u=[n,r].flat().filter((e=>e&&c.delete(e)));return u.length?{actions:u,width:l,label:a}:s?{pattern:s,placeholder:i,width:l,label:a}:i||l?{placeholder:i,width:l,label:a}:null}));l=t.filter(Boolean)}l.length||(l=[{actions:["collapse","move"]},s[0],{actions:["add","remove"]}]);const a=document.createElement("div");a.className="NeeloongForm-tree";const c=a.appendChild(document.createElement("div"));c.className="NeeloongForm-tree-main";const u=a.appendChild(document.createElement("div"));u.className="NeeloongForm-tree-splitter";const d=a.appendChild(document.createElement("div"));d.className="NeeloongForm-tree-details",u.hidden=!0,d.hidden=!0;let f=null,p=0;function h(){const e=f;null!==e&&(f=null,u.releasePointerCapture(e))}u.addEventListener("pointerdown",(e=>{const{pointerId:t}=e;if([null,t].includes(f))switch(f=t,u.setPointerCapture(t),st(u).map(((e,t)=>e?2**t:0)).reduce(((e,t)=>e+t))){case 0:p=-e.offsetX;break;case 1:p=-e.offsetY;break;case 2:p=e.offsetX-u.offsetWidth;break;case 3:p=e.offsetY-u.offsetHeight}}));const m=e=>{const[t,n]=st(u);let r=0;switch([t,n].map(((e,t)=>e?2**t:0)).reduce(((e,t)=>e+t))){case 0:r=e.clientX-a.getBoundingClientRect().left;break;case 1:r=e.clientY-a.getBoundingClientRect().top;break;case 2:r=a.getBoundingClientRect().right-e.clientX;break;case 3:r=a.getBoundingClientRect().bottom-e.clientY}const o=1-Math.max(0,Math.min((r+p)/(e=>e?a.clientHeight-u.offsetHeight:a.clientWidth-u.offsetWidth)(t),1));d.style.inlineSize=100*o+"%"};u.addEventListener("pointermove",(e=>{const{pointerId:t}=e;u.hasPointerCapture(t)&&m(e)})),u.addEventListener("pointerup",(e=>{const{pointerId:t}=e;t===f&&(m(e),h())})),u.addEventListener("pointercancel",(e=>{const{pointerId:t}=e;t===f&&(m(e),h())}));const g=[];let b=()=>{};const v=new e.Signal.State(null);function y(e){if(v.get()===e)return b;b(),v.set(e);const[t,i]=dt(e,n,r,o);d.appendChild(t),d.hidden=!1,u.hidden=!1;let s=!1;return b=()=>{s||(s=!0,v.set(null),t.remove(),i(),h(),u.hidden=!0,d.hidden=!0)},b}const w=r?.levelKey||"level",E=new e.Signal.Computed((()=>t.addable)),x={get:()=>Boolean(o?.editable)};function S(e){const n={};if(-2===e)return n[w]=0,void t.add(n);n[w]=(F[e]?.levelValue??-1)+1,t.insert(e+1,n)}function C(e){t.remove(Number(e.index))}let L=-1,N=new e.Signal.State(L);function O(e,n){if(L<0)return;const r=Number(function(e,t){if(!e)return 0;const n=Number(F[Number(e.index)]?.levelValue)||0;return t?n+1:n}(e,n))||0;let o=function(e){let t=e+1;const n=F[L]?.level??0;for(;(F[t]?.level??-1)>n;t++);return t-L}(L),i=-1;if(e){if(i=Number(e.index),L===i||F[i]?.parents?.has(L))return;if(n||i!==L+o){if(n){for(const e=F[i]?.level||0;F[i+1]?.level>e;i++);i<L&&(i+=1)}else i>L&&(i-=1);if(i<0)return}else i=-1}else if(i=F.length-1,i<0)return;if(i>=0&&L!==i){if(o=t.move(L,i,o),!o)return;L=o>1&&i>L?i-o+1:i,N.set(L)}const s=Array(o).fill(F[L]?.level??0).map(((e,t)=>Math.max((F[t+L]?.level??0)-e,0)));for(let e=0;e<o;e++){const n=t.children[L+e]?.child(w);n&&(n.value=r+s[e])}}function $(e){L=Number(e.index),N.set(L),c.classList.add("NeeloongForm-tree-moving")}let A=null;function j(e){return-1===L?()=>{}:(A?.classList.remove("NeeloongForm-tree-drag-over"),A=e,A?.classList.add("NeeloongForm-tree-drag-over"),()=>{A===e&&(A?.classList.remove("NeeloongForm-tree-drag-over"),A=null)})}function M(){L=-1,N.set(L),c.classList.remove("NeeloongForm-tree-moving"),A?.classList.remove("NeeloongForm-tree-drag-over"),A=null}if(o?.editable){const e=c.appendChild(document.createElement("button"));e.addEventListener("click",(()=>S(-1))),e.classList.add("NeeloongForm-tree-head-add"),g.push(be((()=>!E.get()),(t=>{e.disabled=t}),!0))}const T=c.appendChild(document.createComment(""));if(o?.editable){const e=c.appendChild(document.createElement("div"));e.classList.add("NeeloongForm-tree-foot");const t=e.appendChild(document.createElement("button"));t.addEventListener("click",(()=>S(-2))),t.classList.add("NeeloongForm-tree-foot-add");const n=e.appendChild(document.createElement("div"));n.classList.add("NeeloongForm-tree-drop");let r=()=>{};n.addEventListener("dragover",(e=>e.preventDefault())),n.addEventListener("dragenter",(()=>r=j(n))),n.addEventListener("dragleave",(()=>r())),n.addEventListener("drop",(()=>O())),g.push(be((()=>!E.get()),(e=>{t.disabled=e}),!0))}let k=new Map;function I(e){for(const[t,n]of e.values())n(),t.remove()}const F=[],B=be((()=>t.children),(function(e){let i=T.nextSibling;const s=k;k=new Map;const a=e.length;for(let e=F.length;e<a;e++)F[e]=lt(t,F,N,"level",e);let u=-1;for(let t of e){u++;const e=F[u],a=s.get(t);if(a)s.delete(t),k.set(t,a),a[2](e),i!==a[0]?c.insertBefore(a[0],i):i=i.nextSibling;else{const[s,a,u]=ot(t,v,n,r,e,{columns:l,remove:C.bind(null,t),dragenter:j,dragstart:$.bind(null,t),dragend:M,deletable:x,addNode:()=>S(Number(t.index)),createDetails:y,drop:O.bind(null,t)},o);c.insertBefore(s,i),k.set(t,[s,a,u])}}F.splice(a),I(s)}),!0);return[a,()=>{T.remove(),I(k),B(),b?.();for(const e of g)e()}]}function ct(e,t,n,r){const{type:o,component:i}=e,s=o&&"object"==typeof o,l=n?.html,a=s?e instanceof Q?"collapse":"fieldset":l?"base":"inline",[c,u,d,f]=rt(n,e,a,s);f.push(ge((()=>c.hidden=e.hidden)));const p=l&&function(e,t,n,r,o){const i=Ye(e);return[i,ze(t,n,i,r,o)]}(l,e,t,r,n)||"function"==typeof i&&t(e,i,r)||e instanceof Q&&(h=n?.arrayStyle,"tree"===h?at:Ze)(e,t,n,r)||s&&dt(e,t,n,r);var h;if(p){const[e,t]=p;d.appendChild(e),f.push(t)}return[c,u]}function ut(e,t,n,r){if("button"===n.type)return function(e,t,n){const[r,o,i,s]=rt(t,e),l=document.createElement("button");s.push((()=>{const r=t.text,o="function"==typeof r?r(e,n):r;l.innerText=o??""})),s.push((()=>{const r=t.disabled,o="function"==typeof r?r(e,n):r;l.disabled=Boolean(o)})),l.className="NeeloongForm-item-button",i.appendChild(l);const a=t.click;if("function"==typeof a)l.addEventListener("click",(t=>a(t,e,n)));else if(a&&"string"==typeof a){const t=n?.call;"function"==typeof t&&l.addEventListener("click",(r=>t(a,r,e,n)))}return[r,o]}(e,n,r);if("html"===n.type)return function(e,t,n,r){const[o,i,s,l]=rt(n,e),a=n.html;if(!a)return[o,i];const c=Ye(a);return l.push(ze(e,t,c,r,n)),s.appendChild(c),[o,i]}(e,t,n,r);const o=e.child(n.field);return o?ct(o,t,n,r):null}function dt(e,t,n,r,o){const i=o instanceof HTMLElement?o:document.createElement("div");i.className="NeeloongForm";const s=[],l=n?.fields;if(l)for(const n of l){const o=ut(e,t,n,r);if(!o)continue;const[l,a]=o;i.appendChild(l),s.push(a)}else{const n=[...e].map((([,e])=>e));for(const e of n){const[n,o]=ct(e,t,null,r);i.appendChild(n),s.push(o)}}return[i,()=>{for(const e of s)e()}]}e.ArrayStore=Q,e.Layout=me,e.ObjectStore=G,e.Store=Y,e.effect=ge,e.render=function(e,t,n,{component:r,global:o,relate:i,enhancements:s}={}){return He(t,n,null,new Le(e,o),Object.create(null),[],s||{},"function"==typeof i?i:null,r)},e.renderStore=function(e,t,n,r,o){const i=r?.html;if(i){const s=Ye(i),l=ze(e,t,s,o||null,r);return n.appendChild(s),l}return dt(e,t,r||null,o||null,n)[1]},e.watch=be}));
|
|
60
|
+
function(e){const t=Object.create(j);t.value=e;const n=()=>(p(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 $.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");A(this[M],t)}};c=M,h=new WeakSet,e.isComputed=e=>r(h,e),e.Computed=class{constructor(t,r){o(this,h),n(this,c);const i=function(e){const t=Object.create(N);t.computation=e;const n=()=>x(t);return n[u]=t,n}(t),s=i[u];if(s.consumerAllowSignalWrites=!0,this[M]=s,s.wrapper=this,r){const t=r.equals;t&&(s.equal=t),s.watched=r[e.subtle.watched],s.unwatched=r[e.subtle.unwatched]}}get(){if(!(0,e.isComputed)(this))throw new TypeError("Wrong receiver type for Signal.Computed.prototype.get");return x(this[M])}},(t=>{var s,a,c,u;t.untrack=function(e){let t,n=null;try{n=d(null),t=e()}finally{d(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};s=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){o(this,a),o(this,c),n(this,s);let t=Object.create(f);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=d(n);for(const e of t)p(e[M]);d(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)){v(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];E(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 k=e=>"string"==typeof e&&e||null,I=e=>"number"==typeof e&&e||null,F=e=>e instanceof RegExp?e:null,B=Boolean;function P(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,o=Array.isArray(t)?t.map(P).filter(B):[];return o.length?{children:o,label:n,value:r}:"number"==typeof r||"string"==typeof r?{label:n,value:r}:null}const R=e=>{if(!e||!Array.isArray(e))return null;const t=e.map(P).filter(B);return t.length?t:null};function U(t,n,r,o){const i=new e.Signal.State(n(r));let s;if("function"==typeof o){const r=o;s=new e.Signal.Computed((()=>n(r(t))))}else{const t=n(o);s=new e.Signal.Computed((()=>t))}const l=new e.Signal.Computed((()=>{const e=i.get();return null===e?s.get():e}));return[i,l]}const q=Symbol();function D(e){const t={[q]:e};for(const[n,r]of e)Object.defineProperty(t,n,{get:()=>r.ref,configurable:!1,enumerable:!0});return Object.defineProperty(t,q,{get:()=>e,configurable:!1,enumerable:!0}),t}let V=null,_=null,W=Object.create(null);function H(e,t){const n=e.type;let r=Y;if(!e.array||_&&t?.parent instanceof _)if("string"==typeof n){const e=W[n];e&&(r=e)}else n&&"object"==typeof n&&V&&(r=V);else _&&(r=_);return new r(e,t)}function K(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 o=new e.Signal.State([]);let i=null;return[function(){i?.abort(),i=new AbortController;const e=i.signal;return o.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(K).filter(Boolean);return!n.aborted&&i.length&&o.set([...o.get(),...i]),i}(n,e)))).then((e=>e.flat()))},new e.Signal.Computed((()=>o.get())),()=>{i?.abort(),o.set([])}]}class Y{#e=new Map;emit(e,t){const n="number"==typeof e?String(e):e,r=this.#e;let o=!1;for(const e of[...r.get(n)||[]])o=!1===e(t,this)||o;return!o}listen(e,t){const n=t.bind(this),r=this.#e,o="number"==typeof e?String(e):e;let i=r.get(o);return i||(i=new Set,r.set(o,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){W[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,ref:r,default:o,setValue:i,convert:s,onUpdate:l,validator:a,validators:c,index:u,size:d,new:f,parent:p,hidden:h,clearable:m,required:g,disabled:b,readonly:v,removable:y,label:w,description:E,placeholder:x,min:S,max:C,step:L,minLength:N,maxLength:O,pattern:$,values:A}={}){this.schema=t;const j=p instanceof Y?p:null;var M,B;j&&(this.#r=j,this.#o=j.#o,this.#i=j.#i),this.#s=(M=this,"function"!=typeof(B=o??t.default)?()=>structuredClone(B):e=>structuredClone(B(M,e)));const P=new e.Signal.State(!1);this.#l=P,this.#i=P,this.#a=t.type,this.#c=t.meta,this.#u=t.component;const q=new e.Signal.State(Boolean(f));this.#d=q;const V=j?new e.Signal.Computed((()=>j.#f.get()||q.get())):new e.Signal.Computed((()=>q.get()));this.#f=V;const _=Boolean(t.immutable),W=!1!==t.creatable;this.#p=_,this.#h=W;const H=t.readonly,G=new e.Signal.State("boolean"==typeof v?v:null);let Q;if("function"==typeof H)Q=new e.Signal.Computed((()=>Boolean(H(this))));else{const t=Boolean(H);Q=new e.Signal.Computed((()=>t))}const X=()=>{if(V.get()?!W:_)return!0;const e=G.get();return null===e?Q.get():e},Z=j?j.#m:null;this.#g=G,this.#m=Z?new e.Signal.Computed((()=>Z.get()||X())):new e.Signal.Computed(X),[this.#b,this.#v]=T(this,h,t.hidden,j?j.#v:null),[this.#y,this.#w]=T(this,m,t.clearable,j?j.#w:null),[this.#E,this.#x]=T(this,g,t.required,j?j.#x:null),[this.#S,this.#C]=T(this,b,t.disabled,j?j.#C:null),[this.#L,this.#N]=U(this,k,w,t.label),[this.#O,this.#$]=U(this,k,E,t.description),[this.#A,this.#j]=U(this,k,x,t.placeholder),[this.#M,this.#T]=U(this,I,S,t.min),[this.#k,this.#I]=U(this,I,C,t.max),[this.#F,this.#B]=U(this,I,L,t.step),[this.#P,this.#R]=U(this,I,N,t.minLength),[this.#U,this.#q]=U(this,I,O,t.maxLength),[this.#D,this.#V]=U(this,F,$,t.pattern),[this.#_,this.#W]=U(this,R,A,t.values),[this.#H,this.#K]=T(this,y,t.removable??!0);const J=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(K).filter(Boolean)})):new e.Signal.Computed((()=>[]))}(this,t.validator,a),[ee,te,ne]=z(this,t.validators?.change,c?.change),[re,oe,ie]=z(this,t.validators?.blur,c?.blur);if(this.listen("change",(()=>{ee()})),this.listen("blur",(()=>{re()})),this.#z=function(...t){const n=t.filter(Boolean);return new e.Signal.Computed((()=>n.flatMap((e=>e.get()))))}(J,te,oe),this.#Y=J,this.#G=ee,this.#Q=re,this.#X=ne,this.#Z=ie,d instanceof e.Signal.State||d instanceof e.Signal.Computed?this.#J=d:this.#J=new e.Signal.State(d||0),n)return this.#t=!0,void(this.#n=D(this));this.#n=r||null,this.#ee=l||null,this.#te="function"==typeof i?i:null,this.#ne="function"==typeof s?s:null,this.#re.set(u??"");for(const[e,n]of Object.entries(t.events||{}))"function"==typeof n&&this.listen(e,n)}#s;createDefault(e){return this.#s(e)}#te=null;#ne=null;#ee=null;#r=null;#o=this;#a;#c;#u;#l=null;#i;get loading(){return this.#i.get()}set loading(e){const t=this.#l;t&&t.set(Boolean(e))}get store(){return this}get parent(){return this.#r}get root(){return this.#o}get type(){return this.#a}get meta(){return this.#c}get component(){return this.#u}#J;get size(){return this.#J.get()}#re=new e.Signal.State("");get index(){return this.#re.get()}set index(e){this.#re.set(e)}get no(){if(this.#t)return"";const e=this.index;return"number"==typeof e?e+1:e}#h=!0;get creatable(){return this.#h}#p=!1;get immutable(){return this.#p}#f;#d;get selfNew(){return this.#d.get()}set selfNew(e){this.#d.set(Boolean(e))}get new(){return this.#f.get()}set new(e){this.#d.set(Boolean(e))}#b;#v;get selfHidden(){return this.#b.get()}set selfHidden(e){this.#b.set("boolean"==typeof e?e:null)}get hidden(){return this.#v.get()}set hidden(e){this.#b.set("boolean"==typeof e?e:null)}#y;#w;get selfClearable(){return this.#y.get()}set selfClearable(e){this.#y.set("boolean"==typeof e?e:null)}get clearable(){return this.#w.get()}set clearable(e){this.#y.set("boolean"==typeof e?e:null)}#E;#x;get selfRequired(){return this.#E.get()}set selfRequired(e){this.#E.set("boolean"==typeof e?e:null)}get required(){return this.#x.get()}set required(e){this.#E.set("boolean"==typeof e?e:null)}#S;#C;get selfDisabled(){return this.#S.get()}set selfDisabled(e){this.#S.set("boolean"==typeof e?e:null)}get disabled(){return this.#C.get()}set disabled(e){this.#S.set("boolean"==typeof e?e:null)}#g;#m;get selfReadonly(){return this.#g.get()}set selfReadonly(e){this.#g.set("boolean"==typeof e?e:null)}get readonly(){return this.#m.get()}set readonly(e){this.#g.set("boolean"==typeof e?e:null)}#H;#K;get selfRemovable(){return this.#H.get()}set selfRemovable(e){this.#H.set("boolean"==typeof e?e:null)}get removable(){return this.#K.get()}set removable(e){this.#H.set("boolean"==typeof e?e:null)}#L;#N;get selfLabel(){return this.#L.get()}set selfLabel(e){this.#L.set(k(e))}get label(){return this.#N.get()}set label(e){this.#L.set(k(e))}#O;#$;get selfDescription(){return this.#O.get()}set selfDescription(e){this.#O.set(k(e))}get description(){return this.#$.get()}set description(e){this.#O.set(k(e))}#A;#j;get selfPlaceholder(){return this.#A.get()}set selfPlaceholder(e){this.#A.set(k(e))}get placeholder(){return this.#j.get()}set placeholder(e){this.#A.set(k(e))}#M;#T;get selfMin(){return this.#M.get()}set selfMin(e){this.#M.set(I(e))}get min(){return this.#T.get()}set min(e){this.#M.set(I(e))}#k;#I;get selfMax(){return this.#k.get()}set selfMax(e){this.#k.set(I(e))}get max(){return this.#I.get()}set max(e){this.#k.set(I(e))}#F;#B;get selfStep(){return this.#F.get()}set selfStep(e){this.#F.set(I(e))}get step(){return this.#B.get()}set step(e){this.#F.set(I(e))}#P;#R;get selfMinLength(){return this.#P.get()}set selfMinLength(e){this.#P.set(I(e))}get minLength(){return this.#R.get()}set minLength(e){this.#P.set(I(e))}#U;#q;get selfMaxLength(){return this.#U.get()}set selfMaxLength(e){this.#U.set(I(e))}get maxLength(){return this.#q.get()}set maxLength(e){this.#U.set(I(e))}#D;#V;get selfPattern(){return this.#D.get()}set selfPattern(e){this.#D.set(F(e))}get pattern(){return this.#V.get()}set pattern(e){this.#D.set(F(e))}#_;#W;get selfValues(){return this.#_.get()}set selfValues(e){this.#_.set(R(e))}get values(){return this.#W.get()}set values(e){this.#_.set(R(e))}#z;#Y;#G;#Q;#X;#Z;get errors(){return this.#z.get()}get error(){return this.#z.get()[0]}*[Symbol.iterator](){}child(e){return null}#oe=!1;#ie=new e.Signal.State(null);#se=new e.Signal.State(this.#ie.get());get changed(){return!Object.is(this.#se.get(),this.#ie.get())}get value(){return this.#se.get()}set value(e){const t=this.#te?.(e),n=void 0===t?e:t;this.#se.set(n),this.#oe||this.#ie.set(n),this.#ee?.(n,this.#re.get(),this),this.#le()}#le(){this.#ae||(this.#ae=!0,queueMicrotask((()=>{const e=this.#se.get();this.#ce(e)})))}reset(e=(this.#oe?this.#ie.get():this.#s()),t=this.#d.get()){this.#ue(e,Boolean(t))}#ue(e,t){this.#d.set(t);const n=this.#te?.(e),r=void 0===n?e:n;if(this.#X(),this.#Z(),this.#oe=!0,!r||"object"!=typeof r){for(const[,e]of this)e.#ue(null,!1);return this.#se.set(r),this.#ie.set(r),this.#ee?.(r,this.#re.get(),this),r}const o=Array.isArray(r)?[...r]:{...r};for(const[e,t]of this)o[e]=t.#ue(Object.hasOwn(o,e)?o[e]:void 0,!1);return this.#se.set(o),this.#ie.set(o),this.#ee?.(o,this.#re.get(),this),o}#ae=!1;#de(e){let t=this.#ne?.(e)??e;return void 0===t&&(t=e),Object.is(this.#se.get(),t)?t:this.#ce(t)}#ce(e){this.#ae=!1;let t=e;if(e&&"object"==typeof e){let n=Array.isArray(e)?[...e]:{...e},r=!1;for(const[t,o]of this){const i=Object.hasOwn(e,t)?e[t]:void 0,s=o.#de(i);Object.is(i,s)||(n[t]=s,r=!0)}r&&(t=e=n,this.#se.set(e))}return this.#oe||(this.#oe=!0,this.#ie.set(t)),this.#se.set(e),e}validate(e){if(!0===e)return Promise.all([this.#Y.get(),this.#G(),this.#Q()]).then((e=>{const t=e.flat();return t.length?t:null}));const t=Array.isArray(e)?e:[],n=[this.validate(!0).then((e=>e?.length?[{path:[...t],store:this,errors:e}]:[]))];for(const[e,r]of this)n.push(r.validate([...t,e]));return Promise.all(n).then((e=>e.flat()))}}class G extends Y{get kind(){return"object"}#fe;*[Symbol.iterator](){yield*Object.entries(this.#fe)}child(e){return this.#fe[e]||null}constructor(e,{parent:t,index:n,new:r,onUpdate:o}={}){const i=Object.entries(e.type),s=Object.create(null);super(e,{parent:t,index:n,new:r,onUpdate:o,size:i.length,setValue:e=>"object"==typeof e?e:null,convert:e=>"object"==typeof e?e:{},default:e.default??((t,n)=>{const r=Object.entries(s);let o=n;return o&&"object"==typeof o||(o=e.default),o&&"object"==typeof o||(o={}),Object.fromEntries(r.map((([e,t])=>[e,t.createDefault(Object.hasOwn(o,e)?o[e]:null)])))})});const l={parent:this,onUpdate:(e,t,n)=>{n===this.#fe[t]&&(this.value={...this.value,[t]:e})}};for(const[e,t]of i)s[e]=H(t,{...l,index:e});this.#fe=s}}V=G;class Q extends Y{#pe=()=>{throw new Error};#fe;get children(){return[...this.#fe.get()]}*[Symbol.iterator](){return yield*[...this.#fe.get().entries()]}child(e){const t=this.#fe.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,index:o,new:i,addable:s}={}){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.#pe(e));n.length=t,r!==t&&l.set(n)};super(t,{index:o,new:i,parent:n,size:new e.Signal.Computed((()=>l.get().length)),setValue(e){const t=Array.isArray(e)?e:null==e?null:[e];return a(t),t},convert(e){const t=Array.isArray(e)?e:null==e?null:[e];return a(t),t},onUpdate:(e,t,n)=>{a(e),r?.(e,t,n)},default:t.default??[]}),[this.#he,this.#me]=T(this,s,t.addable??!0),this.#fe=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}};this.#pe=(e,n)=>{const r=H(t,{...c,index:e,new:n});return r.index=e,r}}#he;#me;get selfAddable(){return this.#he.get()}set selfAddable(e){this.#he.set("boolean"==typeof e?e:null)}get addable(){return this.#me.get()}set addable(e){this.#he.set("boolean"==typeof e?e:null)}insert(e,t=null,n){if(!this.addable)return!1;const r=this.value||[];if(!Array.isArray(r))return!1;const o=[...this.#fe.get()],i=Math.max(0,Math.min(Math.floor(e),o.length)),s=this.#pe(i,n);s.new=!0,o.splice(i,0,s);for(let t=e+1;t<o.length;t++)o[t].index=t;const l=[...r];return l.splice(i,0,s.createDefault(t)),this.#fe.set(o),this.value=l,!0}add(e=null){return this.insert(this.#fe.get().length,e)}remove(e){const t=this.value;if(!Array.isArray(t))return;const n=[...this.#fe.get()],r=Math.max(0,Math.min(Math.floor(e),n.length)),[o]=n.splice(r,1);if(!o)return;for(let t=e;t<n.length;t++)n[t].index=t;const i=[...t],[s]=i.splice(r,1);return this.#fe.set(n),this.value=i,s}move(e,t,n=1){const r=Math.floor(n);if(r<1)return 0;if(e<=t&&e+r>t)return 0;const o=this.value;if(!Array.isArray(o))return 0;const i=[...this.#fe.get()],s=i.splice(e,r),l=s.length;if(!l)return 0;const a=r>1&&t>e?t-r+1:t;i.splice(a,0,...s);let c=Math.min(e,a),u=Math.max(e+r-1,t);for(let e=c;e<=u;e++)i[e].index=e;const d=[...o],f=d.splice(e,l);for(let e=f.length;e<l;e++)f.push(null);for(;a>d.length;)d.push(null);return d.splice(a,0,...f),this.#fe.set(i),this.value=d,l}exchange(e,t){const n=this.value;if(!Array.isArray(n))return!1;const r=[...this.#fe.get()],o=r[e],i=r[t];if(!o||!i)return!1;r[t]=o,r[e]=i,o.index=t,i.index=e;const s=[...n],l=s[e],a=s[t];return s[t]=l,s[e]=a,this.#fe.set(r),this.value=s,!0}}function X(e){if(!e?.length)return[];const t=[];let n=[],r=Object.create(null),o=!1;for(const t of e){if("string"==typeof t)continue;const e=t.template;if(!e)continue;o=!0;const n=Z(t);r[e]={params:t.params,children:n?[n]:[]}}function i(e){e.length&&t.push({type:"divergent",children:e.map((([e,t])=>{const n=Z(t);return n?"string"!=typeof n&&"fragment"===n.type?[n,e]:[{children:[n]},e]:[{children:[]},e]}))})}for(const r of e){if("string"==typeof r){i(n),n=[],t.push(r);continue}if(r.template){i(n),n=[];continue}if(n.length&&r.else){const e=r.if||null;n.push([e,r]),e||(i(n),n=[]);continue}i(n),n=[];const e=r.if;if(e){n.push([e,r]);continue}const o=Z(r);o&&t.push(o)}return i(n),o?[{type:"fragment",templates:r,children:t}]:t}function Z(e){let t=function(e){const t=e.fragment;if(t&&"string"==typeof t)return{type:"template",template:t,attrs:e.attrs,children:[]};const n=function({text:e,html:t}){return null!=e?{type:"content",value:e}:null!=t?{type:"content",value:t,html:!0}:void 0}(e),r=n?[n]:X(e.children);return!e.name||t?n||{type:"fragment",children:r}:{name:e.name,is:e.is,attrs:e.attrs,events:e.events,classes:e.classes,styles:e.styles,enhancements:e.enhancements,bind:e.bind,comment:e.comment,children:r}}(e),n=e.vars;n.length&&t&&"string"!=typeof t&&(t.vars?t.vars=[...n,...t.vars]:t?t.vars=n:t={type:"fragment",vars:n,children:[]},n=null);const r=e.enum,o=e.value;return r&&(t={type:"enum",value:r,sort:e.sort,vars:n,children:t?[t]:[]},n=null),o&&(t={type:"value",name:o,vars:n,children:t?[t]:[]},n=null),n?.length&&(t={type:"fragment",vars:n,children:t?[t]:[]}),t}!function(e){_=e}(Q);const J=/^([+-]?(\d(_?\d)*(\.(\d(_?\d)*)?)?|\.\d(_?\d)*)(?:e[+-]?\d(_?\d)*)|0(b[01](?:_?[01])*|o[0-7](?:_?[0-7])*|x[\dA-F](?:_?[\dA-F])*))$/is;const ee={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 te extends Error{constructor(e,...t){const n=ee[e];super("function"==typeof n?n(...t):n),this.code=e}}const ne=/^(?<decorator>[:@!+*\.?]|style:|样式:)?(?<name>-?[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_:\d\.]*)$/u,re=/^~(?<enhancement>[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_\d\.]*)(?:(?<decorator>[:@!])(?<name>-?[\w\p{Unified_Ideograph}_][-\w\p{Unified_Ideograph}_:\d\.]*))?$/u,oe=/^(?<name>[a-zA-Z$\p{Unified_Ideograph}_][\da-zA-Z$\p{Unified_Ideograph}_]*)?$/u;function ie(e,t){const n=e[t];if(n)return n;const r={attrs:Object.create(null),events:Object.create(null)};return e[t]=r,r}function se(e,t){const n=e.replace(/$\s+|\s+$/gs,"");if("null"===n)return{value:null};if("true"===n)return{value:!0};if("false"===n)return{value:!1};const r=function(e){return J.test(e)?Number(e.replaceAll("_","")):NaN}(n);return Number.isNaN(r)?oe.test(n)?{name:n}:{calc:t(e)}:{value:r}}function le(e,t,n,r,o){const{attrs:i,events:s,classes:l,styles:a,vars:c,params:u,enhancements:d}=e;return function(f,p){const h=f.replace(/./g,".").replace(/:/g,":").replace(/@/g,"@").replace(/+/g,"+").replace(/-/g,"-").replace(/[*×]/g,"*").replace(/!/g,"!"),m=(ne.exec(h)||re.exec(h))?.groups;if(!m)throw new te("ATTR",f);const{name:g,enhancement:b}=m,v=m.decorator?.toLowerCase();if(b){if(":"===v)ie(d,b).attrs[g]=p?se(p,t):{name:g};else if("@"===v)ie(d,b).events[g]=p?oe.test(p)?{name:p}:{event:r(p)}:{name:g};else if("!"===v){if("bind"===g)ie(d,b).bind=p||!0}else ie(d,b).value=se(p,t);return}if(!v)return void(i[g]={value:p});if(":"===v)return void(i[g]=p?se(p,t):{name:g});if("."===v)return void(l[g]=p?se(p,t):{name:g});if("style:"===v)return void(a[g]=se(p,t));if("@"===v)return void(s[g]=p?oe.test(p)?{name:p}:{event:r(p)}:{name:g});if("+"===v)return void c.push({...p?se(p,n):{value:void 0},variable:g,init:!0});if("*"===v)return void c.push({...se(p,t),variable:g,init:!1});if("?"===v)return void(u[g]=se(p,t));if("!"!==v)return;switch(g.toString()){case"fragment":e.fragment=p||!0;break;case"else":e.else=!0;break;case"enum":e.enum=p?se(p,t):{value:!0};break;case"sort":e.sort=p?se(p,t):{value:!0};break;case"if":e.if=se(p,t);break;case"text":e.text=se(p,t);break;case"html":o&&(e.html=se(p,t));break;case"template":e.template=p;break;case"bind":e.bind=p||!0;break;case"value":e.value=p;break;case"comment":e.comment=p}}}function ae(e,t){return{name:e,is:t,children:[],attrs:Object.create(null),events:Object.create(null),classes:Object.create(null),styles:Object.create(null),vars:[],params:Object.create(null),enhancements:Object.create(null)}}var ce={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 ue=/^(?<name>[\w\p{Unified_Ideograph}_][-\.\|:|d\w\p{Unified_Ideograph}_:]*)(?:|(?<is>[\w\p{Unified_Ideograph}_][-\.\|:|d\w\p{Unified_Ideograph}_]*))?$/u;function de(e){return"="!==e&&"/"!==e&&">"!==e&&e&&"'"!==e&&'"'!==e&&!function(e){return"0x80"===e||e<=" "}(e)}function fe(e,t,n,r){let o=r[n];return null==o&&(o=e.lastIndexOf("</"+n+">"),o<t&&(o=e.lastIndexOf("</"+n)),r[n]=o),o<t}function pe(...e){console.error(new te(...e))}function he(e){const t=e.slice(1,-1);return"#"===t.charAt(0)?String.fromCodePoint(parseInt(t.substring(1).replace("x","0x"))):t in ce?ce[t]:(pe("ENTITY",e),e)}var me=Object.freeze({__proto__:null,parse:function(e,{createCalc:t=()=>{throw new te("CALC")},createInit:n=t,createEvent:r=()=>{throw new te("EVENT")},simpleTag:o=new Set,enableHTML:i=!1}={}){const s=[],l={children:s},a=[];let c=null,u=l;function d(){c=a.pop()||null,u=c||l}function f(e){(e=e.replace(/^\n|(?<=\n)\t+|\n\t*$/g,""))&&u.children.push(e)}let p={},h=0;function m(t){if(t<=h)return;f(e.substring(h,t).replace(/&#?\w+;/g,he)),h=t}for(;;){const g=e.indexOf("<",h);if(g<0){const O=e.substring(h);O.match(/^\s*$/)||f(O);break}g>h&&m(g);const b=e.charAt(g+1);if("!"===b){let $=g+2,A=">";if("--"===e.slice(g+2,g+4)&&($+=4,A="--\x3e"),h=e.indexOf(A,$),h<0)break;h++;continue}if("/"===b){h=e.indexOf(">",g+3);let j=e.substring(g+2,h);if(h<0?(j=e.substring(g+2).replace(/[\s<].*/,""),pe("UNCOMPLETED",j,c?.name),h=g+1+j.length):j.match(/\s</)&&(j=j.replace(/[\s<].*/,""),pe("UNCOMPLETED",j),h=g+1+j.length),c){const M=c.name;if(M===j)d();else{if(M.toLowerCase()!=j.toLowerCase())throw new te("CLOSE",j,c.name);d()}}h++;continue}function v(t){let n=h+1;if(h=e.indexOf(t,n),h<0)throw new te("QUOTE",t);const r=e.slice(n,h).replace(/&#?\w+;/g,he);return h++,r}function y(){let t=e.charAt(h);for(;t<=" "||""===t;t=e.charAt(++h));return t}function w(){let t=h,n=e.charAt(h);for(;de(n);)h++,n=e.charAt(h);return e.slice(t,h)}h=g+1;let E=e.charAt(h);switch(E){case"=":throw new te("EQUAL");case'"':case"'":throw new te("ATTR_VALUE");case">":case"/":throw new te("SYMBOL",E);case"":throw new te("EOF")}const x=w(),S=ue.exec(x)?.groups;if(!S)throw new te("TAG",x);a.push(c),c=ae(S.name,S.is),u.children.push(c),u=c;const C=le(c,t,n,r,i);let L=!0,N=!1;e:for(;L;){let T=y();switch(T){case"":pe("EOF"),h++;break e;case">":h++;break e;case"/":N=!0;break e;case'"':case"'":throw new te("ATTR_VALUE");case"=":throw new te("SYMBOL",T)}const k=w();if(!k){pe("EOF"),h++;break e}switch(T=y(),T){case"":pe("EOF"),h++;break e;case">":C(k,""),h++;break e;case"/":C(k,""),N=!0;break e;case"=":h++;break;case"'":case'"':C(k,v(T));continue;default:C(k,"");continue}switch(T=y(),T){case"":C(k,""),pe("EOF"),h++;break e;case">":C(k,""),h++;break e;case"/":C(k,""),N=!0;break e;case"'":case'"':C(k,v(T));continue}C(k,w())}if(N){for(;;){h++;const I=e.charAt(h);if("/"!==I&&!(I<=" "||""===I))break}switch(e.charAt(h)){case"=":throw new te("EQUAL");case'"':case"'":throw new te("ATTR_VALUE");case"":pe("EOF");break;case">":h++;break;default:throw new te("CLOSE_SYMBOL")}d()}else(o.has(x)||fe(e,h,x,p))&&d()}return X(s)}});function ge(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()})))})),o=new e.Signal.Computed(t);return r.watch(o),o.get(),()=>{r.unwatch(o)}}function be(e,t,n){let r,o=!1;return ge((()=>{const i=e();if(!o)return o=!0,r=i,void(n&&t(i));Object.is(i,r)||(r=i,t(i))}))}const ve=new Set(Object.keys({type:!0,meta:!0,component:!0,kind:!0,value:!0,store:!0,parent:!0,root:!0,ref:!0,schema:!0,new:!0,readonly:!0,creatable:!0,immutable:!0,changed:!0,loading:!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,size:!0,error:!0,errors:!0}));function*ye(e,t="",n="$"){yield[`${t}`,{get:()=>e.value,set:t=>e.value=t,store:e}];for(const r of ve)yield[`${t}${n}${r}`,{get:()=>e[r]}];yield[`${t}${n}value`,{get:()=>e.value,set:t=>e.value=t}],yield[`${t}${n}state`,{get:()=>null,set:e=>{}}],yield[`${t}${n}reset`,{exec:()=>e.reset()}],yield[`${t}${n}validate`,{exec:t=>e.validate(t?[]:null)}],e instanceof Q?(yield[`${t}${n}addable`,{get:()=>e.addable}],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)}]):yield[`${t}${n}addable`,{get:()=>!1}]}function we(e,t,n){for(const[n,r]of t){for(const[t,o]of ye(r,n))e[t]=o;for(const[t,o]of ye(r,n,"$$"))e[t]=o}}const Ee={value$:{calc:e=>e?.[q].value},state$:{calc:e=>e?.[q].state}};var xe=Object.getOwnPropertyDescriptors(Ee);function Se(e){if(!e)return!1;const t=e.indexOf("$");return t<0||(e.indexOf("$",t+2)>0||"$"===e[0]&&"_$".includes(e[1]))}function Ce(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 Le{exec({name:e,calc:t,value:n}){if("string"==typeof e){const t=this.#ge[e];if("function"!=typeof t?.get)return;return t.get()}return"function"==typeof t?t(this.getters):n}get({name:t,calc:n,value:r}){if("string"==typeof t){const e=this.#ge[t];if("function"!=typeof e?.get)return;const{get:n,set:r}=e;return{get:n,set:r}}if("function"==typeof n){const t=new e.Signal.Computed((()=>n(this.getters)));return{get:()=>t.get()}}return{get:()=>r}}watch(e,t){return be((()=>this.exec(e)),t,!0)}enum(e){const{name:t,calc:n}=e;if("function"==typeof n)return()=>n(this.getters);if("string"==typeof t){const e=this.#ge[t];if("function"!=typeof e?.get)return null;const n=e.store;return n instanceof Y?n:e.get}return this.store}getStore(e){if(!e)return null;const t=this.#ge[!0===e?"":e];return t?.get&&t.store||null}bind(e,t,n){const r=this.#ge[!0===e?"":e];if(!r?.get)return;const{store:o}=r;return o?ve.has(t)?be((()=>o[t]),n,!0):void 0:"value"===t?be((()=>r.get()),n,!0):void 0}bindAll(e){const t=this.#ge[!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=>be(e,t,!0)}}const r=Object.fromEntries([...ve].map((e=>[`$${e}`,t=>be((()=>n[e]),t,!0)])));return r.$$state=e=>be((()=>null),e,!0),r}getBindAll(e){const t=this.#ge[!0===e?"":e];if(!t?.get)return{};const{store:n}=t;if(!n){const{get:e,set:n}=t;return{$value:{get:e,set:n}}}const r=Object.fromEntries([...ve].map((e=>[`$${e}`,"value"===e?{get:()=>n[e],set:t=>{n[e]=t}}:{get:()=>n[e]}])));return r.$$state={get:()=>null,set:()=>{}},r}bindSet(e,t){const n=this.#ge[!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=>{}}}bindEvents(e){const t=this.#ge[!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=>{},$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({name:e,event:t}){if("function"==typeof t)return t;const n=this.#ge[e];if(!n)return null;const{exec:r,calc:o}=n;return"function"==typeof r?r:"function"==typeof o?o:null}constructor(e,t){if(this.store=e,t instanceof Le){this.#be=t.#be;const e=this.#ve;for(const[n,r]of Object.entries(t.#ve))e[n]=r;const n=this.#ye;for(const[e,r]of Object.entries(t.#ye))n[e]=r}else we(this.#ve,e),this.#be=function(e){const t=Object.create(null,xe);if(!e||"object"!=typeof e)return t;for(const[n,r]of Object.entries(e)){if(!Se(n))continue;if(!r||"object"!=typeof r)continue;if(r instanceof Y){for(const[e,o]of ye(r,n))t[e]=o;continue}const{get:e,set:o,exec:i,calc:s}=r;"function"!=typeof e?"function"==typeof s||s&&"object"==typeof s?t[n]={calc:s}:("function"==typeof i||s&&"object"==typeof s)&&(t[n]={exec:i}):t[n]="function"==typeof o?{get:e,set:o}:{get:e}}return t}(t)}#be;#ve=Object.create(null);#ye=Object.create(null);store;#we=null;#r=null;#Ee=null;get#ge(){const e=this.#Ee;if(e)return e;const t=Object.create(null,Object.getOwnPropertyDescriptors({...this.#ve,...this.#be,...this.#ye})),n=this.store,r=this.#r,o=this.#we;for(const[e,r]of ye(n))t[e]=r;for(const[e,o]of function*(e,t,n="",r="$"){if(!(e instanceof Q))return yield[`${n}${r}removable`,{get:()=>!1}],yield[`${n}${r}upMovable`,{get:()=>!1}],yield[`${n}${r}downMovable`,{get:()=>!1}],yield[`${n}${r}remove`,{exec:()=>{}}],yield[`${n}${r}upMove`,{exec:()=>{}}],void(yield[`${n}${r}downMove`,{exec:()=>{}}]);yield[`${n}${r}removable`,{get:()=>!e.readonly&&!e.disabled&&!!t.removable}],yield[`${n}${r}upMovable`,{get:()=>{if(e.readonly)return!1;if(e.disabled)return!1;const n=t.index;return"number"==typeof n&&!(n<=0)}}],yield[`${n}${r}downMovable`,{get:()=>{if(e.readonly)return!1;if(e.disabled)return!1;const n=t.index;return"number"==typeof n&&!(n>=e.size-1)}}],yield[`${n}${r}remove`,{exec:()=>{e.readonly||e.disabled||t.removable&&e.remove(Number(t.index))}}],yield[`${n}${r}upMove`,{exec:()=>{if(e.readonly)return;if(e.disabled)return;const n=t.index;"number"==typeof n&&(n<=0||e.move(n,n-1))}}],yield[`${n}${r}downMove`,{exec:()=>{if(e.readonly)return;if(e.disabled)return;const n=t.index;"number"==typeof n&&(n>=e.size-1||e.move(n,n+1))}}]}(r,n))t[e]=o;if(o)for(const e of Object.keys(o))t[`$${e}`]={get:()=>o[e]};return this.#Ee=t,t}setStore(e,t,n){const r=new Le(e,this);return t&&(r.#r=t),we(r.#ve,e),n&&(r.#we=n),r}child(e){if(!e)return this;const t=this.store.child(e);if(!t)return null;const n=new Le(t,this);return we(n.#ve,t),n}params(t,n,r,o){let i=this.store;if(!0===o)i=r.store;else if(o){const e=r.#ge[o],t=e?.get&&e.store;t&&(i=t)}if(0===Object.keys(t).length)return this;const s=new Le(i,this);s.#r=this.#r,s.#we=this.#we;const l=s.#ye,a=s.#ge;for(const[o,i]of Object.entries(t)){const t=o in n?n[o]:null;if(t){const{name:n,calc:i,value:s}=t;if(n){const e=r.#ge[n];if(!e?.get)continue;if(!e.store){l[o]=a[o]=e;continue}for(const[t,n]of ye(e.store,o))l[t]=a[t]=n;continue}if("function"==typeof i){const t=new e.Signal.Computed((()=>i(r.getters)));l[o]=a[o]={get:()=>t.get()};continue}l[o]=a[o]={get:()=>s}}else{const{name:t,calc:n,value:r}=i;if("function"==typeof n){const t=s.getters;s.#xe=null;const r=new e.Signal.Computed((()=>n(t)));l[o]=a[o]={get:()=>r.get()};continue}if(t){const e=a[t];if(!e?.get)continue;if(!e.store){l[o]=a[o]=e;continue}for(const[t,n]of ye(e.store,o))l[t]=a[t]=n;continue}l[o]=a[o]={get:()=>r}}}return s}setObject(e){const t=new Le(this.store,this);return t.#we=e,t}set(t){if(!t?.length)return this;const n=new Le(this.store,this);n.#r=this.#r,n.#we=this.#we;const r=n.#ye,o=n.#ge;for(const{variable:i,name:s,calc:l,value:a,init:c}of t)if(c){const t=new e.Signal.State(a);if("function"==typeof l){const e=n.settable;n.#Se=null,t.set(l(e))}else if(s){const e=o[s];if(!e?.get)continue;t.set(e.get())}r[i]=o[i]={get:()=>t.get(),set:e=>{t.set(e)}}}else if("function"!=typeof l)if(s){const e=o[s];if(!e)continue;if(!e.get||!e.store){r[i]=o[i]=e;continue}for(const[t,n]of ye(e.store,i))r[t]=o[t]=n}else r[i]=o[i]={get:()=>a};else{const t=n.getters;n.#xe=null;const s=new e.Signal.Computed((()=>l(t)));r[i]=o[i]={get:()=>s.get()}}return n}#Ce=null;get all(){const e=this.#Ce;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#ge))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 Ce(this.store,t),this.#Ce=t,t}#Se=null;get settable(){const e=this.#Se;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#ge))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 Ce(this.store,t),this.#Se=t,t}#xe=null;get getters(){const e=this.#xe;if(e)return e;const t={};for(const[e,n]of Object.entries(this.#ge))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 Ce(this.store,t),this.#xe=t,t}}const Ne={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 Oe(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 o=Array.isArray(t)?t[0]:t;return"number"==typeof o||"bigint"==typeof o?r=o&&e in Ne?`${o}${Ne[e]}`:`${o}`:"string"==typeof o&&(r=o),r?[r,n?"important":void 0]:null}class $e{#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,o="number"==typeof e?String(e):e;let i=r.get(o);return i||(i=new Set,r.set(o,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 je(e,t,n){const r=[];if(t)for(let o=e.shift();o;o=e.shift()){const e=o.indexOf(":"),i=e>=0?o.slice(0,e):o,s=e>=0?o.slice(e+1).split(":"):[],l=i.replace(/^-+/,""),a=(i.length-l.length)%2==1;let c=t[l]||l;if(n)switch(c){case"once":case"passive":case"capture":n[c]=!a;continue}"string"==typeof c&&(c=Ae[c]),"function"==typeof c&&r.push([c,s,a])}return r}function Me(e,t,n){return r=>{const o=e.all;for(const[e,t,i]of n)if(e(r,t,o)===i)return;t(r,o)}}function Te(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 ke(e){return null===(e??null)?"":String(e)}function Ie(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 ke;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 Fe={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=ke(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=ke(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=ke(e)}},events:{$value:["change",(e,t)=>t.value]}}};function Be(e,t,n){const r=document.createElement(t,{is:n||void 0}),{watch:o,props:i}=e;return["input","textarea","select"].includes(t.toLowerCase())&&e.relate(r),e.listen("init",(({events:n})=>{const s=Fe[t.toLowerCase()],l=s?.attrs||{},a=s?.events||{};for(const[e,t,o]of n)if("$"!==e[0])r.addEventListener(e,t,o);else{const n=a[e];if(n){const[e,i]=n;r.addEventListener(e,(e=>t(i(e,r))),o)}}if(i)for(const[t,n]of Object.entries(e.attrs))if(o(t,(e=>{if(i.has(t))r[t]=e;else{const n=Te(e);null==n?r.removeAttribute(t):r.setAttribute(t,n)}})),i.has(t))r[t]=n;else{const e=Te(n);null!==e&&r.setAttribute(t,e)}else for(const[t,n]of Object.entries(e.attrs)){if(r instanceof HTMLInputElement&&"type"===t.toLocaleLowerCase()){const e=Te(n);null!==e&&r.setAttribute(t,e);continue}if("$hidden"===t){n&&(r.hidden=n),o(t,(e=>{r.hidden=e}));continue}if("$"===t[0]){const e=l[t];e&&(e(n,r),o(t,(t=>e(t,r))));continue}const e=Ie(r,t);if("function"==typeof e){r[t]=e(n),o(t,(n=>{r[t]=e(n)}));continue}if(e){r[t]=n,o(t,(e=>{r[t]=e}));continue}let i=Te(n);null!==i&&r.setAttribute(t,i),o(t,(e=>{const n=Te(e);null===n?r.removeAttribute(t):r.setAttribute(t,n)}))}})),r}function Pe(e){return null===(e??null)?"":String(e)}function Re(e,t,n,r,o){if(!o){const o=e.insertBefore(document.createTextNode(""),t),i=n.watch(r,(e=>o.textContent=Pe(e)));return()=>{o.remove(),i()}}const i=e.insertBefore(document.createComment(""),t),s=e.insertBefore(document.createComment(""),t),l=document.createElement("div");function a(){for(let e=i.nextSibling;e&&e!==s;e=i.nextSibling)e.remove()}const c=n.watch(r,(t=>{a(),function(t){l.innerHTML=t;for(let t=l.firstChild;t;t=i.firstChild)e.insertBefore(t,s)}(Pe(t))}));return()=>{c(),a(),i.remove(),s.remove()}}function Ue(e,t){if("bigint"==typeof e&&"bigint"==typeof t)return Number(e-t);if(!("number"!=typeof e&&"bigint"!=typeof e||"number"!=typeof t&&"bigint"!=typeof t))return Number(e)-Number(t);const n=String(e),r=String(t);return n>r?1:n<r?-1:0}const qe=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);function De(e,t,n,r,o){const i=e.children;if(!i.length)return()=>{};const s=t.insertBefore(document.createComment(""),n);let l=null,a=()=>{};const c=be((()=>i.find((([,e])=>!e||r.exec(e)))||null),(e=>{if(e===l)return;l=e,a(),a=()=>{};const t=e?.[0];t&&(a=o(t.children,t.vars,t.templates))}),!0);let u=!1;return()=>{u||(u=!0,c(),a(),a=()=>{},s.remove())}}function Ve(t,n,r,o,i,s,l,a,c){const u=t.bind,d=[...s,t.name],f=c?.(d);if(c&&!f)return()=>{};const{context:p,handler:h}=function(t,n,r,o){const i="string"==typeof t?t:t.tag,{attrs:s,events:l}="string"!=typeof t&&t||{attrs:null,events:null};let a=!1;const c=new e.Signal.State(!1);let u=!1;const d=new e.Signal.State(!1),f=Object.create(null),p=Object.create(null),h=new Set,m=[],g=new $e;return{context:{events:m,props:s?new Set(Object.entries(s).filter((([,e])=>e.isProp)).map((([e])=>e))):null,attrs:p,watch(e,t){if(a)return()=>{};const n=f[e];if(!n)return()=>{};let r=n.get();const o=be((()=>n.get()),(n=>{const o=r;r=n,t(n,o,e)}),!0);return h.add(o),()=>{h.delete(o),o()}},relate(e){if(!r||!o||a)return()=>{};try{const t=o(r,e);return"function"!=typeof t?()=>{}:(h.add(t),()=>{h.delete(t),t()})}catch{return()=>{}}},get destroyed(){return c.get()},get init(){return d.get()},listen:(e,t)=>g.listen(e,t)},handler:{tag:i,set(t,n){if(s&&!(t in s))return;let r=f[t];if(r)return void r.set(n);const o=new e.Signal.State(n);f[t]=o,Object.defineProperty(p,t,{configurable:!0,enumerable:!0,get:o.get.bind(o)})},addEvent(e,t){if("function"!=typeof t)return;const[r,...o]=e.split(".").filter(Boolean),i=l?l[r].filters:{};if(!i)return;const s={},a=je(o,i,s);m.push([r,Me(n,t,a),s])},destroy(){if(!a){a=!0,c.set(!0);for(const e of h)e();g.emit("destroy")}},mount(){u||(u=!0,d.set(!0),g.emit("init",{events:m}))}}}}(f||t.name,o,o.getStore(u),a),m=f?.attrs,g=m?function(e,t,n,r,o){let i=new Set;for(const[s,l]of Object.entries(r)){if("class"===s||"style"===s)continue;if(s in n){const r=n[s],{name:o,calc:a,value:c}=n[s];if(!o&&!a){e.set(s,c);continue}l.immutable&&e.set(s,t.exec(r)),i.add(t.watch(r,(t=>e.set(s,t))));continue}const r=l.bind;if(!o||!r){e.set(s,l.default);continue}if("string"==typeof r){const n=t.bind(o,r,(t=>e.set(s,t)));n?i.add(n):e.set(s,l.default);continue}if(!Array.isArray(r)){e.set(s,l.default);continue}const[a,c,u]=r;if(!a||"function"!=typeof c)continue;if(!u){const n=!0===o?"":o;i.add(t.watch({name:n},(t=>e.set(s,t)))),e.addEvent(a,((...e)=>{t.all[n]=c(...e)}));continue}const d=t.bind(o,"state",(t=>e.set(s,t)));if(!d)continue;i.add(d);const f=t.bindSet(o,"state");f&&e.addEvent(a,((...e)=>{f(c(...e))}))}return()=>{const e=i;i=new Set;for(const t of e)t()}}(h,o,t.attrs,m,u):function(e,t,n){const r=e.tag;let o=new Set;for(const[i,s]of Object.entries(n)){if("class"===i||"style"===i)continue;const{name:n,calc:l,value:a}=s;if(n||l)if("string"!=typeof r||"input"!==r.toLocaleLowerCase()||"type"!==i.toLocaleLowerCase())o.add(t.watch(s,(t=>e.set(i,t))));else{const n=t.exec(s);e.set(i,n)}else e.set(i,a)}return()=>{const e=o;o=new Set;for(const t of e)t()}}(h,o,t.attrs);for(const[e,n]of Object.entries(t.events)){const t=o.getEvent(n);t&&h.addEvent(e,t)}const b=function(e,t,n){if(!n)return()=>{};let r=new Set;for(const[o,i]of Object.entries(t.bindAll(n)||{}))"function"==typeof i&&r.add(i((t=>e.set(o,t))));for(const[r,o]of Object.entries(t.bindEvents(n)||{}))e.addEvent(r,(e=>o(e)));return()=>{const e=r;r=new Set;for(const t of e)t()}}(h,o,u),v=f?"function"==typeof f.tag?f.tag(p):Be(p,f.tag,f.is):Be(p,t.name,t.is),y=Array.isArray(v)?v[0]:v,w=Array.isArray(v)?v[1]:y;n.insertBefore(y,r);const E=w?He(t.children||[],w,null,o,i,s,l,a,c):()=>{},x=function(e,t,n,r){if(!(e instanceof Element))return()=>{};r&&(e.className+=" "+t.exec(r));let o=new Set;for(const[r,i]of Object.entries(n))i.value?e.classList.add(r):o.add(be((()=>Boolean(t.exec(i))),(t=>{t?e.classList.add(r):e.classList.remove(r)}),!0));return()=>{if(!o)return;const e=o;o=null;for(const t of e)t()}}(y,o,t.classes,t.attrs.class),S=function(e,t,n,r){if(!(e instanceof HTMLElement||e instanceof SVGElement))return()=>{};if(r){const n=[e.getAttribute("style")||"",t.exec(r)||""].filter(Boolean).join(";");n&&e.setAttribute("style",n)}let o=new Set;for(const[r,i]of Object.entries(n))o.add(be((()=>Oe(r,t.exec(i))),(t=>{t?e.style.setProperty(r,...t):e.style.removeProperty(r)}),!0));return()=>{if(!o)return;const e=o;o=null;for(const t of e)t()}}(y,o,t.styles,t.attrs.style);h.mount();const C=function(t,n,r,o,i,s){let l=new Set;for(const[a,{attrs:c,value:u,events:d,bind:f}]of Object.entries(n)){if(!qe(o,a))continue;const p=o[a];if("function"!=typeof p)continue;let h=!1;const m=new e.Signal.State(!1),g=p?.events,b=[],v=Object.create(null),y=new Set,w=new $e;function E(e,t){if("function"!=typeof t)return;const[n,...o]=e.split(".").filter(Boolean),i=g?g[n].filters:{};if(!i)return;const s={},l=je(o,i,s);b.push([n,Me(r,t,l),s])}function x(){if(!h){h=!0,m.set(!0);for(const e of y)e();w.emit("destroy")}}l.add(x);for(const[C,L]of Object.entries(c)){const N=r.get(L);N&&Object.defineProperty(v,C,{...N,configurable:!0,enumerable:!0})}for(const[O,$]of Object.entries(d)){const A=r.getEvent($);A&&E(O,A)}if(f){for(const[j,M]of Object.entries(r.getBindAll(f)||{}))Object.defineProperty(v,j,{...M,configurable:!0,enumerable:!0});for(const[T,k]of Object.entries(r.bindEvents(f)||{}))E(T,(e=>k(e)))}const S={get value(){return null},events:b,attrs:v,watch(e,t){if(h)return()=>{};let n=v[e];const r=be((()=>v[e]),(r=>{const o=n;n=r,t(r,o,e)}),!0);return y.add(r),()=>{y.delete(r),r()}},get destroyed(){return m.get()},listen:(e,t)=>w.listen(e,t),root:i,slot:s,tag:t};if(u){const I=r.get(u);I&&Object.defineProperty(S,"value",{...I,configurable:!0,enumerable:!0})}p(S)}return()=>{const e=l;l=new Set;for(const t of e)t()}}(h.tag,t.enhancements,o,l,y,w);return()=>{C(),h.destroy(),y.remove(),g(),E(),b(),x(),S()}}function _e(e,t,n){if(!n)return t;const r=Object.entries(n);if(!r.length)return t;const o=Object.create(t);for(const[t,n]of r)o[t]=[n,e];return o}function We(t,n,r,o,i,s,l,a,c){if("string"==typeof t){const e=document.createTextNode(t);return n.insertBefore(e,r),()=>e.remove()}const u=o.set(t.vars),d=_e(u,i,t.templates);if("divergent"===t.type)return De(t,n,r,u,((e,t,o)=>{const d=u.set(t),f=_e(d,i,o);return He(e,n,r,d,f,s,l,a,c)}));if("value"===t.type){const e=u.child(t.name);return e?He(t.children,n,r,e,d,s,l,a,c):()=>{}}if("enum"===t.type){const o=u.enum(t.value),i=(e,r)=>He(t.children,n,e,r,d,s,l,a,c);return o instanceof Q?function(t,n,r,o,i){const s=t.insertBefore(document.createComment(""),n);let l=new Map;function a(e){for(const[t,n,r]of e.values())r(),t.remove(),n.remove()}const c=new e.Signal.State(0),u=be((()=>r.children),(function(e){if(!s.parentNode)return;let n=s.nextSibling;const u=l;l=new Map,c.set(e.length);for(let s of e){const e=u.get(s);if(!e){const e=t.insertBefore(document.createComment(""),n),a=t.insertBefore(document.createComment(""),n),u=i(a,o.setStore(s,r,{get count(){return c.get()},get key(){return s.index},get index(){return s.index},get item(){return s.value}}));l.set(s,[e,a,u]);continue}if(u.delete(s),l.set(s,e),n===e[0]){n=e[1].nextSibling;continue}let a=e[0];for(;a&&a!==e[1];){const e=a;a=a.nextSibling,t.insertBefore(e,n)}t.insertBefore(e[1],n)}a(u)}),!0);return()=>{s.remove(),a(l),u()}}(n,r,o,u,i,t.sort):o instanceof G?function(e,t,n,r,o,i){const s=[],l=[...n],a=l.length,c=i?l.map((([e,t])=>[e,t,r.setStore(t,n).exec(i)])).sort((([,,e],[,,t])=>Ue(e,t))).map((([e,t],n)=>[e,t,n])):l.map((([e,t],n)=>[e,t,n]));for(const[e,i,l]of c)s.push(o(t,r.setStore(i,n,{get count(){return a},get key(){return e},get index(){return l},get item(){return i.value}})));return()=>{for(const e of s)e()}}(0,r,o,u,i,t.sort):"function"==typeof o?function(t,n,r,o,i,s){const l=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])):[]}return e&&"object"==typeof e?Array.isArray(e)?e.map(((e,t)=>[e,t])):Object.entries(e).map((([e,t])=>[t,e])):[]})),a=s?new e.Signal.Computed((()=>{const e=l.get();return e.map((([t,n],r)=>[n,t,o.setObject({get count(){return e.length},get key(){return t},get item(){return n},get index(){return r}}).exec(s)])).sort((([,,e],[,,t])=>Ue(e,t))).map((([e,t],n)=>[t,n,e]))})):new e.Signal.Computed((()=>l.get().map((([e,t],n)=>[t,n,e])))),c=t.insertBefore(document.createComment(""),n);let u=[];function d(e){for(const[t,n,r]of e)r(),t.remove(),n.remove()}const f=new e.Signal.State(0),p=be((()=>a.get()),(function(n){if(!c.parentNode)return;let r=c.nextSibling;const s=u;u=[],f.set(n.length);for(const[l,a,c]of n){const n=s.findIndex((e=>e[3]===c)),[d]=n>=0?s.splice(n,1):[];if(!d){const n=t.insertBefore(document.createComment(""),r),s=t.insertBefore(document.createComment(""),r),d=new e.Signal.State(l),p=new e.Signal.State(a),h=i(s,o.setObject({get count(){return f.get()},get key(){return c},get item(){return d.get()},get index(){return p.get()}}));u.push([n,s,h,c,d,p]);continue}if(u.push(d),d[4].set(l),d[5].set(a),r===d[0]){r=d[1].nextSibling;continue}let p=d[0];for(;p&&p!==d[1];){const e=p;p=p.nextSibling,t.insertBefore(e,r)}t.insertBefore(d[1],r)}d(s)}),!0);return()=>{c.remove(),d(u),p()}}(n,r,o,u,i,t.sort):()=>{}}if("content"===t.type)return Re(n,r,u,t.value,t.html);if("template"===t.type){const e=d[t.template];if(!e)return()=>{};const[o,f]=e,p=f.params(o.params,t.attrs,u,t.bind),h=_e(p,i,o.templates);return He(o.children,n,r,p,h,s,l,a,c)}return"fragment"===t.type?He(t.children,n,r,u,d,s,l,a,c):Ve(t,n,r,u,d,s,l,a,c)}function He(e,t,n,r,o,i,s,l,a){const c=e.map((e=>We(e,t,n,r,o,i,s,l,a)));let u=!1;return()=>{if(!u){u=!0;for(const e of c)e()}}}function Ke(e){return function(t){return(!t.type||"field"===t.type)&&t.field===e}}function ze(e,t,n,r,o,i,s){const l=[];if(n instanceof Element){const a=n.tagName.toLowerCase();if(!n.parentNode)return()=>{};if("nl-form-field"===a){const f=n.getAttribute("name")||"",p=n.getAttribute("mode")||"",h=f?e.child(f):e,m=f&&o?.fields?.find(Ke(f))||null;if(!h)return()=>{};if("grid"===p){const[v,y]=dt(e,t,m,r);return n.replaceWith(v),y}const g=t(h,r);if(g){const[w,E]=g;return n.replaceWith(w),E}const b=n.getAttribute("placeholder")||"";return n.replaceWith(document.createTextNode(b)),()=>{}}if("nl-form-button"===a){const x=document.createElement("button");x.className="NeeloongForm-item-button";const S=n.getAttribute("click")||"",C=r?.call;S&&"function"==typeof C&&x.addEventListener("click",(t=>C(S,t,e,r)));for(const L of[...n.childNodes])x.appendChild(L);return n.replaceWith(x),()=>{}}const c=n.getAttribute("nl-form-field");if(c){const N=c.endsWith("[]"),O=N?c.slice(0,c.length-2):c,$=O?e.child(O):e;if(!$)return()=>{};n.removeAttribute("nl-form-field");const A=O?o?.fields?.find(Ke(O)):o;if(!N)return ze($,t,n,r,A,i);if(!($ instanceof Q))return n.remove(),()=>{};const j=n.parentElement;if(!j)return n.remove(),()=>{};const M=j.insertBefore(document.createComment(""),n)||null;n.remove();let T=new Map;function k(e){for(const[t,n]of e.values())n(),t instanceof Element&&t.remove()}let I=-1;const F=e=>{if(I<0)return;const t=e?Number(e.index):$.children.length;t<0||I<0||I===t||$.move(I,t)&&(I=t)},B=be((()=>$.children),(e=>{let o=M.nextSibling;const i=T;T=new Map;for(const s of e){const e=i.get(s);if(e)i.delete(s),T.set(s,e),o!==e[0]?j.insertBefore(e[0],o):o=o.nextSibling;else{const e=j.insertBefore(n.cloneNode(!0),o),i=ze(s,t,e,r,A,e);e.addEventListener("dragenter",(()=>{F(s)})),e.addEventListener("dragstart",(e=>{e.target===e.currentTarget&&(I=Number(s.index))})),e.addEventListener("dragend",(()=>{I=-1})),T.set(s,[e,i])}}k(i)}),!0);return()=>{M.remove(),k(T),B()}}if(null!==n.getAttribute("nl-form-remove")){const P=e.parent;P instanceof Q&&n.addEventListener("click",(()=>{P.remove(Number(e.index))}))}null!==n.getAttribute("nl-form-move")&&i instanceof HTMLElement&&n.addEventListener("pointerdown",(({pointerId:e})=>{i.draggable=!0;const t=n=>{n.pointerId===e&&(i.draggable=!1,window.removeEventListener("pointerup",t,{capture:!0}),window.removeEventListener("pointercancel",t,{capture:!0}))};window.addEventListener("pointerup",t,{capture:!0}),window.addEventListener("pointercancel",t,{capture:!0})}));const u=n.getAttribute("nl-form-add");if(u){const R=e.child(u);R instanceof Q&&n.addEventListener("click",(()=>{R.add({})}))}const d=r?.call;for(const U of[...n.getAttributeNames()]){const q=U.indexOf(":");if(q<0)continue;const D=U.slice(0,q).toLowerCase(),V=U.slice(q+1);if("nl-form-field"===D){const _=n.getAttribute(U),W=_?e.child(_):e;if(!W)continue;l.push(ge((()=>{try{n.setAttribute(V,W.value)}catch{}})))}else if("nl-form-event"===D&&"function"==typeof d){const H=n.getAttribute(U);if(!H)continue;try{n.addEventListener(V,(t=>d(H,t,e,r)))}catch{}}}}if(n instanceof Element||n instanceof DocumentFragment)for(const K of[...n.children])l.push(ze(e,t,K,r,o,i));return()=>{for(const e of l)e()}}function Ye(e){if(!e)return document.createElement("template").content;if("string"!=typeof e)return e.cloneNode(!0);const t=document.createElement("template");return t.innerHTML=e,t.content}function Ge(e,t,n,r){return t(e,r)||[document.createElement("div"),()=>{}]}function Qe(e,t,n,{columns:r,remove:o,dragenter:i,dragstart:s,dragend:l,deletable:a},c){const u=document.createElement("tbody");u.addEventListener("dragenter",(()=>{i()})),u.addEventListener("dragstart",(e=>{e.target===e.currentTarget&&s()})),u.addEventListener("dragend",l);const d=u.appendChild(document.createElement("tr")),f=[];let p=()=>{};const h=[];if(r.find((e=>e.actions?.includes("trigger")))){const o=u.appendChild(document.createElement("tr")),i=o.appendChild(document.createElement("td"));i.colSpan=r.length;const[s,l]=dt(e,t,n,c);i.appendChild(s),f.push(l),o.hidden=!0,p=function(){if(o.hidden){o.hidden=!1;for(const e of h)e.classList.remove("NeeloongForm-table-line-open"),e.classList.add("NeeloongForm-table-line-close")}else{o.hidden=!0;for(const e of h)e.classList.remove("NeeloongForm-table-line-close"),e.classList.add("NeeloongForm-table-line-open")}}}function m({pointerId:e}){function t(n){n.pointerId===e&&u&&(u.draggable=!1,window.removeEventListener("pointerup",t,{capture:!0}),window.removeEventListener("pointercancel",t,{capture:!0}))}u.draggable=!0,window.addEventListener("pointerup",t,{capture:!0}),window.addEventListener("pointercancel",t,{capture:!0})}for(const n of r){const{actions:r,field:i,pattern:s}=n;if(!r?.length){const n=d.appendChild(document.createElement("td")),r=i&&e.child(i);if(r){const[e,o]=Ge(r,t,0,c);f.push(o),n.appendChild(e)}continue}const l=d.appendChild(document.createElement("th"));l.classList.add("NeeloongForm-table-line-handle");for(const t of r)switch(t){case"trigger":{const e=l.appendChild(document.createElement("button"));e.classList.add("NeeloongForm-table-line-open"),h.push(e),e.addEventListener("click",p);continue}case"move":{if(!c?.editable)continue;const t=l.appendChild(document.createElement("button"));t.classList.add("NeeloongForm-table-move"),t.addEventListener("pointerdown",m),f.push(be((()=>e.readonly||e.disabled),(e=>{t.disabled=e}),!0));continue}case"remove":{if(!c?.editable)continue;const t=l.appendChild(document.createElement("button"));t.classList.add("NeeloongForm-table-remove"),t.addEventListener("click",o),f.push(be((()=>!a.get()||e.readonly||e.disabled),(e=>{t.disabled=e}),!0));continue}case"serial":l.appendChild(document.createElement("span")).classList.add("NeeloongForm-table-serial");continue}}return[u,()=>{for(const e of f)e()}]}function Xe(e,t,n,r,o){const i=e.appendChild(document.createElement("tr")),s=[];for(const{action:e,actions:l,width:a,label:c}of t){const t=i.appendChild(document.createElement("th"));if(a&&t.setAttribute("width",`${a}`),![e,l].flat().includes("add")){t.innerText=c||"";continue}if(!o)continue;const u=t.appendChild(document.createElement("button"));u.addEventListener("click",n),u.classList.add("NeeloongForm-table-add"),s.push(be((()=>!r.get()),(e=>{u.disabled=e}),!0))}return()=>{for(const e of s)e()}}function Ze(t,n,r,o){const i=r?.columns,s=Object.entries(t.type||{}).filter((([e,t])=>"object"!=typeof t?.type)).map((([e,{width:t,label:n}])=>({field:e,width:t,label:n})));let l=[];if(Array.isArray(i)){const e=new Map(s.map((e=>[e.field,e]))),t=i.map((t=>{if(!t)return null;if("number"==typeof t)return{placeholder:t};if("string"==typeof t)return e.get(t)||null;if("object"!=typeof t)return null;if(Array.isArray(t)){const e=new Set(["add","move","trigger","remove","serial","open","collapse"]),n=t.filter((t=>e.delete(t)));return n?{actions:n}:null}const{action:n,actions:r,field:o,placeholder:i,pattern:s,width:l,label:a}=t;if(o){const t=e.get(o);if(t)return{field:o,placeholder:i,width:l,label:a||t.label}}const c=new Set(["add","move","trigger","remove","serial"]),u=[n,r].flat().filter((e=>e&&c.delete(e)));return u.length?{actions:u,width:l,label:a}:null}));l=t.filter(Boolean)}l.length||(l=[{actions:["add","trigger","move","remove","serial"]},...s.slice(0,3)]);const a=document.createElement("table");a.className="NeeloongForm-table";const c=a.appendChild(document.createElement("thead")),u=new e.Signal.Computed((()=>t.addable)),d={get:()=>Boolean(o?.editable)};function f(){t.add({})}function p(e){t.remove(Number(e.index))}let h=-1;function m(e){if(h<0)return;const n=e?Number(e.index):t.children.length;n<0||h<0||h===n||t.move(h,n)&&(h=n)}function g(e){h=Number(e.index)}function b(){h=-1}const v=[];switch(v.push(Xe(c,l,f,u,Boolean(o?.editable))),r?.tableFoot){default:case"header":{const e=a.appendChild(document.createElement("tfoot"));e.addEventListener("dragenter",(()=>{m()})),v.push(Xe(e,l,f,u,Boolean(o?.editable)));break}case"add":{const e=a.appendChild(document.createElement("tfoot"));e.addEventListener("dragenter",(()=>{m()}));const t=e.appendChild(document.createElement("tr")).appendChild(document.createElement("th"));t.colSpan=l.length;const n=t.appendChild(document.createElement("button"));n.addEventListener("click",f),n.classList.add("NeeloongForm-table-foot-add"),v.push(be((()=>!u.get()),(e=>{n.disabled=e}),!0));break}case"none":}const y=c;let w=new Map;function E(e){for(const[t,n]of e.values())n(),t.remove()}const x=be((()=>t.children),(function(e){let t=c.nextSibling;const i=w;w=new Map;for(let s of e){const e=i.get(s);if(e)i.delete(s),w.set(s,e),t!==e[0]?a.insertBefore(e[0],t):t=t.nextSibling;else{const[e,i]=Qe(s,n,r,{columns:l,remove:p.bind(null,s),dragenter:m.bind(null,s),dragstart:g.bind(null,s),dragend:b,deletable:d},o);a.insertBefore(e,t),w.set(s,[e,i])}}E(i)}),!0);return[a,()=>{y.remove(),c.remove(),E(w),x();for(const e of v)e()}]}function Je(e,t){const{colStart:n,colSpan:r,colEnd:o,rowStart:i,rowSpan:s,rowEnd:l}=t||{};e.classList.add("NeeloongForm-item-grid"),n&&o?e.style.gridColumn=`${n} / ${o}`:n&&r?e.style.gridColumn=`${n} / span ${r}`:r&&(e.style.gridColumn=`span ${r}`),i&&l?e.style.gridRow=`${i} / ${l}`:i&&s?e.style.gridRow=`${i} / span ${s}`:s&&(e.style.gridRow=`span ${s}`)}function et(e,t){return ge((()=>{t?.error?e.classList.add("NeeloongForm-item-errored"):e.classList.remove("NeeloongForm-item-errored")}))}function tt(e,t){return ge((()=>{t?.required?e.classList.add("NeeloongForm-item-required"):e.classList.remove("NeeloongForm-item-required")}))}function nt(e){const t=[],n=document.createElement("div");n.className="NeeloongForm-item",t.push(tt(n,e));const r=n.appendChild(document.createElement("div"));r.className="NeeloongForm-item-label",t.push(ge((()=>r.innerText=e?.label||"")));const o=n.appendChild(document.createElement("div"));o.className="NeeloongForm-item-content";const i=n.appendChild(document.createElement("div"));i.className="NeeloongForm-item-description",t.push(ge((()=>i.innerText=e?.description||"")));const s=n.appendChild(document.createElement("div"));return s.className="NeeloongForm-item-error",t.push(ge((()=>s.innerText=e?.error||""))),t.push(et(n,e)),[n,()=>{for(const e of t)e()},o,t]}function rt(e,t,n,r){function o(n){if(!n)return null;if(!r)switch(n){case"inline":{const n=nt(t);return Je(n[0],e),n}case"base":{const n=function(e){const t=[],n=document.createElement("div");return n.className="NeeloongForm-item",t.push(tt(n,e)),t.push(et(n,e)),[n,()=>{for(const e of t)e()},n,t]}(t);return Je(n[0],e),n}}switch(n){case"block":return nt(t);case"fieldset":return function(e){const t=[],n=document.createElement("fieldset");n.className="NeeloongForm-item",t.push(tt(n,e));const r=n.appendChild(document.createElement("legend"));return t.push(ge((()=>r.innerText=e?.label||""))),t.push(et(n,e)),[n,()=>{for(const e of t)e()},n,t]}(t);case"collapse":return function(e){const t=[],n=document.createElement("details");n.className="NeeloongForm-item",t.push(tt(n,e)),n.open=!0;const r=n.appendChild(document.createElement("summary"));return t.push(ge((()=>r.innerText=e?.label||""))),t.push(et(n,e)),[n,()=>{for(const e of t)e()},n,t]}(t)}return null}return o(e?.cell)||o(n)||nt(t)}function ot(t,n,r,o,i,{columns:s,remove:l,dragenter:a,dragstart:c,dragend:u,deletable:d,addNode:f,drop:p,createDetails:h},m){const g=new e.Signal.State(i),b=document.createElement("div");b.addEventListener("dragstart",(e=>{e.target===e.currentTarget&&c()})),b.addEventListener("dragend",u);const v=[];b.classList.add("NeeloongForm-tree-item"),v.push(ge((()=>{n.get()===t?b.classList.add("NeeloongForm-tree-current"):b.classList.remove("NeeloongForm-tree-current")}))),v.push(ge((()=>{const e=g.get().level;b.style.setProperty("--NeeloongForm-tree-level",`${e}`)}))),v.push(ge((()=>{b.hidden=g.get().hidden})));const y=[];function w({pointerId:e}){function t(n){n.pointerId===e&&b&&(b.draggable=!1,window.removeEventListener("pointerup",t,{capture:!0}),window.removeEventListener("pointercancel",t,{capture:!0}))}b.draggable=!0,window.addEventListener("pointerup",t,{capture:!0}),window.addEventListener("pointercancel",t,{capture:!0})}function E(){const e=g.get();e.collapsed=!e.collapsed}let x=()=>{};function S(){x=h(t)}function C(){n.get()!==t?x=h(t):x()}const L="move"===o?.mainMethod?w:null,N=L?null:"collapse"===o?.mainMethod?E:"trigger"===o?.mainMethod?C:S,O=b.appendChild(document.createElement("div"));O.classList.add("NeeloongForm-tree-line");const $=b.appendChild(document.createElement("div"));$.classList.add("NeeloongForm-tree-drop");const A=b.appendChild(document.createElement("div"));A.classList.add("NeeloongForm-tree-drop-children"),$.addEventListener("dragover",(e=>e.preventDefault())),A.addEventListener("dragover",(e=>e.preventDefault())),$.addEventListener("drop",(()=>p())),A.addEventListener("drop",(()=>p(!0))),v.push(ge((()=>{$.hidden=A.hidden=!g.get().droppable})));let j=()=>{};$.addEventListener("dragenter",(()=>j=a($))),A.addEventListener("dragenter",(()=>j=a(A))),$.addEventListener("dragleave",(()=>j())),A.addEventListener("dragleave",(()=>j()));for(const{actions:e,pattern:n,placeholder:o,width:i,field:a}of s)if(e?.length)for(const n of e)switch(n){case"trigger":{const e=O.appendChild(document.createElement("button"));e.classList.add("NeeloongForm-tree-trigger"),e.addEventListener("click",C);continue}case"open":{const e=O.appendChild(document.createElement("button"));e.classList.add("NeeloongForm-tree-open"),e.addEventListener("click",S);continue}case"collapse":{const e=O.appendChild(document.createElement("button"));e.classList.add("NeeloongForm-tree-collapse"),e.addEventListener("click",E),y.push(e);continue}case"move":{if(!m?.editable)continue;const e=O.appendChild(document.createElement("button"));e.classList.add("NeeloongForm-tree-move"),e.addEventListener("pointerdown",w),v.push(be((()=>t.readonly||t.disabled),(t=>{e.disabled=t}),!0));continue}case"add":{if(!m?.editable)continue;const e=O.appendChild(document.createElement("button"));e.classList.add("NeeloongForm-tree-add"),e.addEventListener("click",f),v.push(be((()=>t.readonly||t.disabled),(t=>{e.disabled=t}),!0));continue}case"remove":{if(!m?.editable)continue;const e=O.appendChild(document.createElement("button"));e.classList.add("NeeloongForm-tree-remove"),e.addEventListener("click",l),v.push(be((()=>!d.get()||t.readonly||t.disabled),(t=>{e.disabled=t}),!0));continue}case"serial":O.appendChild(document.createElement("span")).classList.add("NeeloongForm-tree-serial");continue}else{const e=O.appendChild(document.createElement("div"));if(e.classList.add("NeeloongForm-tree-cell"),N&&e.addEventListener("click",N),L&&e.addEventListener("pointerdown",L),a){const n=t.child(a);if(!n)continue;const[o,i]=Ge(n,r,0,{...m,editable:!1});v.push(i),e.appendChild(o);continue}"number"==typeof o&&(e.style.flex=`${o}`),"number"==typeof i&&(e.style.width=`${i}px`)}return v.push(ge((()=>{const e=g.get();if(e.hasChildren)if(e.collapsed)for(const e of y)e.classList.remove("NeeloongForm-tree-collapse-close"),e.classList.add("NeeloongForm-tree-collapse-open"),e.disabled=!1;else for(const e of y)e.classList.remove("NeeloongForm-tree-collapse-open"),e.classList.add("NeeloongForm-tree-collapse-close"),e.disabled=!1;else for(const e of y)e.classList.remove("NeeloongForm-tree-collapse-close"),e.classList.remove("NeeloongForm-tree-collapse-open"),e.disabled=!0}))),[b,()=>{for(const e of v)e()},e=>g.set(e)]}const it=new Set(["vertical-lr","vertical-rl","sideways-lr","sideways-rl"]);function st(e){const t=getComputedStyle(e),n=t.writingMode?.toLowerCase();return[it.has(n),"rtl"===t.direction.toLowerCase()!=("sideways-lr"===n)]}function lt(t,n,r,o,i){const s=new e.Signal.Computed((()=>{const e=t.child(i);return e?Math.max(0,Math.floor(e.value?.[o])||0):0})),l=new e.Signal.Computed((()=>{if(!t.child(i))return-1;const e=s.get();if(!e)return-1;for(let t=i-1;t>=0;t--)if(e>n[t]?.levelValue)return t;return-1})),a=new e.Signal.Computed((()=>{const e=t.children,n=e[i+1];if(!n)return!1;if(!e[i])return!1;const r=s.get();return Math.floor(n.child(o)?.value)>r})),c=new e.Signal.Computed((()=>{if(r.get()===i)return!1;const e=l.get(),t=n[e];return!t||t.droppable})),u=new e.Signal.Computed((()=>{const e=l.get(),t=n[e];return t?t.level+1:0})),d=new e.Signal.State(!1),f=new e.Signal.Computed((()=>{const e=l.get(),t=n[e];return!!t&&(t.collapsed||t.hidden)})),p=new e.Signal.Computed((()=>{const e=l.get(),t=n[e];if(!t)return new Set;const r=new Set(t.parents);return r.add(e),r}));return{get level(){return u.get()},get levelValue(){return s.get()},get collapsed(){return d.get()},set collapsed(e){d.set(e)},get hidden(){return f.get()},get hasChildren(){return a.get()},get droppable(){return c.get()},get parents(){return p.get()}}}function at(t,n,r,o){const i=r?.columns,s=Object.entries(t.type||{}).filter((([e,t])=>"object"!=typeof t?.type)).map((([e,{width:t,label:n}])=>({field:e,width:t,label:n})));let l=[];if(Array.isArray(i)){const e=new Map(s.map((e=>[e.field,e]))),t=i.map((t=>{if(!t)return null;if("number"==typeof t)return{placeholder:t};if("string"==typeof t)return e.get(t)||null;if("object"!=typeof t)return null;if(Array.isArray(t)){const e=new Set(["add","move","trigger","remove","serial","open","collapse"]),n=t.filter((t=>e.delete(t)));return n?{actions:n}:null}const{action:n,actions:r,field:o,placeholder:i,pattern:s,width:l,label:a}=t;if(o){const t=e.get(o);if(t)return{field:o,placeholder:i,width:l,label:a||t.label}}const c=new Set(["add","move","trigger","remove","serial","open","collapse"]),u=[n,r].flat().filter((e=>e&&c.delete(e)));return u.length?{actions:u,width:l,label:a}:s?{pattern:s,placeholder:i,width:l,label:a}:i||l?{placeholder:i,width:l,label:a}:null}));l=t.filter(Boolean)}l.length||(l=[{actions:["collapse","move"]},s[0],{actions:["add","remove"]}]);const a=document.createElement("div");a.className="NeeloongForm-tree";const c=a.appendChild(document.createElement("div"));c.className="NeeloongForm-tree-main";const u=a.appendChild(document.createElement("div"));u.className="NeeloongForm-tree-splitter";const d=a.appendChild(document.createElement("div"));d.className="NeeloongForm-tree-details",u.hidden=!0,d.hidden=!0;let f=null,p=0;function h(){const e=f;null!==e&&(f=null,u.releasePointerCapture(e))}u.addEventListener("pointerdown",(e=>{const{pointerId:t}=e;if([null,t].includes(f))switch(f=t,u.setPointerCapture(t),st(u).map(((e,t)=>e?2**t:0)).reduce(((e,t)=>e+t))){case 0:p=-e.offsetX;break;case 1:p=-e.offsetY;break;case 2:p=e.offsetX-u.offsetWidth;break;case 3:p=e.offsetY-u.offsetHeight}}));const m=e=>{const[t,n]=st(u);let r=0;switch([t,n].map(((e,t)=>e?2**t:0)).reduce(((e,t)=>e+t))){case 0:r=e.clientX-a.getBoundingClientRect().left;break;case 1:r=e.clientY-a.getBoundingClientRect().top;break;case 2:r=a.getBoundingClientRect().right-e.clientX;break;case 3:r=a.getBoundingClientRect().bottom-e.clientY}const o=1-Math.max(0,Math.min((r+p)/(e=>e?a.clientHeight-u.offsetHeight:a.clientWidth-u.offsetWidth)(t),1));d.style.inlineSize=100*o+"%"};u.addEventListener("pointermove",(e=>{const{pointerId:t}=e;u.hasPointerCapture(t)&&m(e)})),u.addEventListener("pointerup",(e=>{const{pointerId:t}=e;t===f&&(m(e),h())})),u.addEventListener("pointercancel",(e=>{const{pointerId:t}=e;t===f&&(m(e),h())}));const g=[];let b=()=>{};const v=new e.Signal.State(null);function y(e){if(v.get()===e)return b;b(),v.set(e);const[t,i]=dt(e,n,r,o);d.appendChild(t),d.hidden=!1,u.hidden=!1;let s=!1;return b=()=>{s||(s=!0,v.set(null),t.remove(),i(),h(),u.hidden=!0,d.hidden=!0)},b}const w=r?.levelKey||"level",E=new e.Signal.Computed((()=>t.addable)),x={get:()=>Boolean(o?.editable)};function S(e){const n={};if(-2===e)return n[w]=0,void t.add(n);n[w]=(F[e]?.levelValue??-1)+1,t.insert(e+1,n)}function C(e){t.remove(Number(e.index))}let L=-1,N=new e.Signal.State(L);function O(e,n){if(L<0)return;const r=Number(function(e,t){if(!e)return 0;const n=Number(F[Number(e.index)]?.levelValue)||0;return t?n+1:n}(e,n))||0;let o=function(e){let t=e+1;const n=F[L]?.level??0;for(;(F[t]?.level??-1)>n;t++);return t-L}(L),i=-1;if(e){if(i=Number(e.index),L===i||F[i]?.parents?.has(L))return;if(n||i!==L+o){if(n){for(const e=F[i]?.level||0;F[i+1]?.level>e;i++);i<L&&(i+=1)}else i>L&&(i-=1);if(i<0)return}else i=-1}else if(i=F.length-1,i<0)return;if(i>=0&&L!==i){if(o=t.move(L,i,o),!o)return;L=o>1&&i>L?i-o+1:i,N.set(L)}const s=Array(o).fill(F[L]?.level??0).map(((e,t)=>Math.max((F[t+L]?.level??0)-e,0)));for(let e=0;e<o;e++){const n=t.children[L+e]?.child(w);n&&(n.value=r+s[e])}}function $(e){L=Number(e.index),N.set(L),c.classList.add("NeeloongForm-tree-moving")}let A=null;function j(e){return-1===L?()=>{}:(A?.classList.remove("NeeloongForm-tree-drag-over"),A=e,A?.classList.add("NeeloongForm-tree-drag-over"),()=>{A===e&&(A?.classList.remove("NeeloongForm-tree-drag-over"),A=null)})}function M(){L=-1,N.set(L),c.classList.remove("NeeloongForm-tree-moving"),A?.classList.remove("NeeloongForm-tree-drag-over"),A=null}if(o?.editable){const e=c.appendChild(document.createElement("button"));e.addEventListener("click",(()=>S(-1))),e.classList.add("NeeloongForm-tree-head-add"),g.push(be((()=>!E.get()),(t=>{e.disabled=t}),!0))}const T=c.appendChild(document.createComment(""));if(o?.editable){const e=c.appendChild(document.createElement("div"));e.classList.add("NeeloongForm-tree-foot");const t=e.appendChild(document.createElement("button"));t.addEventListener("click",(()=>S(-2))),t.classList.add("NeeloongForm-tree-foot-add");const n=e.appendChild(document.createElement("div"));n.classList.add("NeeloongForm-tree-drop");let r=()=>{};n.addEventListener("dragover",(e=>e.preventDefault())),n.addEventListener("dragenter",(()=>r=j(n))),n.addEventListener("dragleave",(()=>r())),n.addEventListener("drop",(()=>O())),g.push(be((()=>!E.get()),(e=>{t.disabled=e}),!0))}let k=new Map;function I(e){for(const[t,n]of e.values())n(),t.remove()}const F=[],B=be((()=>t.children),(function(e){let i=T.nextSibling;const s=k;k=new Map;const a=e.length;for(let e=F.length;e<a;e++)F[e]=lt(t,F,N,"level",e);let u=-1;for(let t of e){u++;const e=F[u],a=s.get(t);if(a)s.delete(t),k.set(t,a),a[2](e),i!==a[0]?c.insertBefore(a[0],i):i=i.nextSibling;else{const[s,a,u]=ot(t,v,n,r,e,{columns:l,remove:C.bind(null,t),dragenter:j,dragstart:$.bind(null,t),dragend:M,deletable:x,addNode:()=>S(Number(t.index)),createDetails:y,drop:O.bind(null,t)},o);c.insertBefore(s,i),k.set(t,[s,a,u])}}F.splice(a),I(s)}),!0);return[a,()=>{T.remove(),I(k),B(),b?.();for(const e of g)e()}]}function ct(e,t,n,r){const{type:o}=e,i=o&&"object"==typeof o,s=n?.html,l=i?e instanceof Q?"collapse":"fieldset":s?"base":"inline",[a,c,u,d]=rt(n,e,l,i);d.push(ge((()=>a.hidden=e.hidden)));const f=s&&function(e,t,n,r,o){const i=Ye(e);return[i,ze(t,n,i,r,o)]}(s,e,t,r,n)||t(e,r)||e instanceof Q&&(p=n?.arrayStyle,"tree"===p?at:Ze)(e,t,n,r)||i&&dt(e,t,n,r);var p;if(f){const[e,t]=f;u.appendChild(e),d.push(t)}return[a,c]}function ut(e,t,n,r){if("button"===n.type)return function(e,t,n){const[r,o,i,s]=rt(t,e),l=document.createElement("button");s.push((()=>{const r=t.text,o="function"==typeof r?r(e,n):r;l.innerText=o??""})),s.push((()=>{const r=t.disabled,o="function"==typeof r?r(e,n):r;l.disabled=Boolean(o)})),l.className="NeeloongForm-item-button",i.appendChild(l);const a=t.click;if("function"==typeof a)l.addEventListener("click",(t=>a(t,e,n)));else if(a&&"string"==typeof a){const t=n?.call;"function"==typeof t&&l.addEventListener("click",(r=>t(a,r,e,n)))}return[r,o]}(e,n,r);if("html"===n.type)return function(e,t,n,r){const[o,i,s,l]=rt(n,e),a=n.html;if(!a)return[o,i];const c=Ye(a);return l.push(ze(e,t,c,r,n)),s.appendChild(c),[o,i]}(e,t,n,r);const o=e.child(n.field);return o?ct(o,t,n,r):null}function dt(e,t,n,r,o){const i=o instanceof HTMLElement?o:document.createElement("div");i.className="NeeloongForm";const s=[],l=n?.fields;if(l)for(const n of l){const o=ut(e,t,n,r);if(!o)continue;const[l,a]=o;i.appendChild(l),s.push(a)}else{const n=[...e].map((([,e])=>e));for(const e of n){const[n,o]=ct(e,t,null,r);i.appendChild(n),s.push(o)}}return[i,()=>{for(const e of s)e()}]}e.ArrayStore=Q,e.Layout=me,e.ObjectStore=G,e.Store=Y,e.effect=ge,e.render=function(e,t,n,{component:r,global:o,relate:i,enhancements:s}={}){return He(t,n,null,new Le(e,o),Object.create(null),[],s||{},"function"==typeof i?i:null,r)},e.renderStore=function(e,t,n,r,o){const i=r?.html;if(i){const s=Ye(i),l=ze(e,t,s,o||null,r);return n.appendChild(s),l}return dt(e,t,r||null,o||null,n)[1]},e.watch=be}));
|