tutuca 0.9.9 → 0.9.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- class Gt{lookup(t,e=null){return e}setValue(t,e){return t}updateBindings(t,e){}isFrame=!0}class Et extends Gt{constructor(t){super();this.binds=t}lookup(t,e){return t}setValue(t,e){return e}withIndex(t){return new Et({...this.binds,key:t})}withKey(t){return new Et({...this.binds,key:t})}updateBindings(t,e){Object.assign(e,this.binds)}isFrame=!1}class Me extends Gt{constructor(t){super();this.field=t}lookup(t,e=null){return t?.get?t.get(this.field,e):e}setValue(t,e){return t.set(this.field,e)}withIndex(t){return new wr(this.field,t)}withKey(t){return new gr(this.field,t)}}class yr extends Gt{constructor(t,e){super();this.field=t,this.key=e}lookup(t,e=null){let r=t?.get(this.field,null);return r?.get?r.get(this.key,e):e}setValue(t,e){return t.set(this.field,t.get(this.field).set(this.key,e))}updateBindings(t,e){e.key=this.key}}class gr extends yr{}class wr extends yr{}var Z=Symbol("NONE");class pr extends Gt{constructor(t,e){super();this.seqField=t,this.keyField=e}lookup(t,e=null){let r=t?.get(this.seqField,Z),s=t?.get(this.keyField,Z);return s!==Z&&r?.get?r.get(s,e):e}setValue(t,e){let r=t?.get(this.seqField,Z),s=t?.get(this.keyField,Z);return r===Z||s===Z?t:t.set(this.seqField,r.set(s,e))}updateBindings(t,e){e.key=t?.get(this.keyField,null)}}class tt{constructor(t=[]){this.steps=t}concat(t){return new tt(this.steps.concat(t))}popStep(){return new tt(this.steps.slice(0,-1))}lookup(t,e=null){let r=t;for(let s of this.steps)if(r=s.lookup(r,Z),r===Z)return e;return r}setValue(t,e){let r=Array(this.steps.length),s=t;for(let n=0;n<this.steps.length;n++)if(r[n]=s,s=this.steps[n].lookup(s,Z),s===Z)return t;let i=e;for(let n=this.steps.length-1;n>=0;n--)i=this.steps[n].setValue(r[n],i),r[n]=i;return i}buildStack(t){let e=t.it,r=e;for(let s of this.steps){if(r=s.lookup(r,Z),r===Z)return console.warn("bad PathItem",{root:e,curVal:r,step:s,path:this}),null;s.updateBindings(r,t.binds.head.bindings),t=t.enter(r,{},s.isFrame)}return t}static fromNodeAndEventName(t,e,r,s,i,n=!0){let h=[],u=0,o=[],f=null,c=[],_=!0;while(t&&t!==r&&u<s){if(t?.dataset){let{nid:l,si:a,sk:y}=ci(t.previousSibling),{eid:p,cid:d,vid:j}=t.dataset;if(p!==void 0)o.push(p);if(d!==void 0){let bt=i.getComponentForId(+d,j);if(_){if(f=Wh(bt,o,j,e),f===null&&n)return Rh;_=!1}let qt=Jh(bt,c,j);if(qt)h.push(qt);o=[],c=[]}if(l!==void 0)c.push({nid:l,si:a,sk:y})}u+=1,t=t.parentNode}return[new tt(h.reverse()),f]}static fromEvent(t,e,r,s,i=!0){let{type:n,target:h}=t;return tt.fromNodeAndEventName(h,n,e,r,s,i)}}var fi={};function ci(t){if(t?.nodeType===8&&t.textContent[0]==="§"){let e=ci(t.previousSibling);if(e!==fi)return e;try{return JSON.parse(t.textContent.slice(1,-1))}catch(r){console.warn(r,t)}}return fi}function Wh(t,e,r,s){for(let i of e){let n=t.getEventForId(+i,r).getHandlersFor(s);if(n!==null)return n}return null}function Jh(t,e,r){for(let s=0;s<e.length;s++){let i=t.getNodeForId(+e[s].nid,r),n=i.pathInNext?s+1:s,{si:h,sk:u,nid:o}=e[n],f=i.pathInNext?t.getNodeForId(+o,r).val.toPathItem():i.toPathItem();if(f!==null)return h!==void 0?f.withIndex(+h):u?f.withKey(u):f}return null}var Rh=[null,null];class zr{constructor(){this.pathChanges=[]}add(t){return this.pathChanges.push(t),this}field(t){return this.add(new Me(t))}index(t,e){return this.add(new wr(t,e))}key(t,e){return this.add(new gr(t,e))}}var Dh=/^[a-zA-Z][a-zA-Z0-9_]*$/,ot=(t)=>Dh.test(t),Zh=/^-?[0-9]+(\.[0-9]+)?$/,_i=(t,e)=>dr.parse(t,e),Yt=(t,e)=>new W(t),Th=(t,e)=>ot(t)?new k(t):null,Xh=(t,e)=>ot(t)?new je(t):null,Hh=(t,e)=>ot(t)?new Mr(t):null,Qh=(t,e)=>ot(t)?new gi(t):null,Gh=(t,e)=>ot(t)?new Ae(t):null,Yh=(t,e)=>ot(t)?new Ue(t):null,Bh=(t,e)=>ot(t)?new $e(t):null;class li{constructor(){this.allowFieldOnly(),this.bindValIt=new Mr("it"),this.nullConstVal=new W(null)}const(t){return new W(t)}allowFieldOnly(){this.okField=!0,this.okBind=!1,this.okComputed=!1,this.okDyn=!1,this.okType=!1,this.okRequest=!1,this.okName=!1,this.okConst=!1,this.okStrTpl=!1,this.okSeqAccess=!1}parseIfOk(t,e,r,s){return r?s(t,e):null}_parseSeqAccess(t,e){if(!this.okSeqAccess)return null;let r=t.indexOf("[");this.allowFieldOnly();let s=this.parse(t.slice(0,r),e),i=this.parse(t.slice(r+1,-1),e);return s&&i?new Ke(s,i):null}parse(t,e){switch(Ph(t)){case wi:return this.parseIfOk(t,e,this.okStrTpl,_i);case zi:return this.parseIfOk(t,e,this.okStrTpl,Yt);case pi:return this._parseSeqAccess(t,e);case be:return this.parseIfOk(t,e,this.okStrTpl,_i)}let r=t.charCodeAt(0);switch(r){case 94:{let i=e.frame.macroVars?.[t.slice(1)];if(i!==void 0)return this.parse(i,e);return null}case 126:return this.parseIfOk(t.slice(1),e,this.okStrTpl,Yt);case 39:return this.parseIfOk(t.slice(1,-1),e,this.okStrTpl,Yt);case 64:return this.parseIfOk(t.slice(1),e,this.okBind,Hh);case 42:return this.parseIfOk(t.slice(1),e,this.okDyn,Qh);case 46:return this.parseIfOk(t.slice(1),e,this.okField,Gh);case 36:return this.parseIfOk(t.slice(1),e,this.okComputed,Yh);case 33:return this.parseIfOk(t.slice(1),e,this.okRequest,Bh)}let s=Zh.test(t)?parseFloat(t):null;if(Number.isFinite(s))return this.parseIfOk(s,e,this.okConst,Yt);else if(t==="true"||t==="false")return this.parseIfOk(t==="true",e,this.okConst,Yt);else if(r>=97&&r<=122)return this.parseIfOk(t,e,this.okName,Th);else if(r>=65&&r<=90)return this.parseIfOk(t,e,this.okType,Xh);return null}parseDynamic(t,e){return this.allowFieldOnly(),this.okComputed=!0,this.parse(t,e)}parseEach(t,e){return this.allowFieldOnly(),this.okComputed=!0,this.okDyn=!0,this.parse(t,e)}allowHandlerArg(){this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okType=!0,this.okRequest=!0,this.okName=!0,this.okConst=!0}parseHandlerArg(t,e){return this.allowHandlerArg(),this.parse(t,e)}_parseHandler(t,e,r){this.allowFieldOnly(),this.okName=!0;let s=this.parse(t,e);return s&&(s.toRawFieldVal?s.toRawFieldVal():new r(s.name))}parseHandlerName(t,e){return this._parseHandler(t,e,Ee)}parseAlter(t,e){return this._parseHandler(t,e,ai)}parseAttr(t,e){return this.parseText(t,e)}parseAll(t,e){return this.allowHandlerArg(),this.okStrTpl=!0,this.okSeqAccess=!0,this.parse(t,e)}parseCondValue(t,e){return this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okConst=!0,this.parse(t,e)}parseText(t,e){return this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okConst=!0,this.okStrTpl=!0,this.parse(t,e)}parseRender(t,e){return this.allowFieldOnly(),this.okSeqAccess=!0,this.parse(t,e)}}class qe{render(t,e){}eval(t){}toPathItem(){return null}}class W extends qe{constructor(t){super();this.value=t}render(t,e){return this.value}eval(t){return this.value}toString(){let t=this.value;return typeof t==="string"?`'${t}'`:`${t}`}}class Sr extends qe{}class dr extends Sr{constructor(t){super();this.vals=t}render(t,e){return this.eval(t)}eval(t){let e=Array(this.vals.length);for(let r=0;r<this.vals.length;r++)e[r]=this.vals[r]?.eval(t,"");return e.join("")}static parse(t,e){let r=t.split(/(\{[^}]+\})/g),s=Array(r.length),i=!0;for(let n=0;n<r.length;n++){let h=r[n],o=h[0]==="{"&&h.at(-1)==="}"?w.parseText(h.slice(1,-1),e):new W(h);s[n]=o,i&&=o instanceof W}return i?new W(s.map((n)=>n.value).join("")):new dr(s)}}class k extends Sr{constructor(t){super();this.name=t}eval(t){return t.lookupName(this.name)}toString(){return this.name}}class Ee extends k{eval(t){return t.getInputHandler(this.name)??yi("input",this.name)}}class ai extends k{eval(t){return t.getAlterHandler(this.name)??yi("alter",this.name)}}var yi=(t,e)=>function(...r){return console.warn("handler not found",{type:t,name:e,args:r},this),this};class je extends k{eval(t){return t.lookupType(this.name)}}class $e extends k{eval(t){return t.lookupRequest(this.name)}toString(){return`!${this.name}`}}class Bt extends k{eval(t){return t.lookupFieldRaw(this.name)}toString(){return`.${this.name}`}}class Or extends qe{render(t,e){return this.eval(t)}}class Pt extends Or{constructor(t){super();this.name=t}}class Mr extends Pt{eval(t){return t.lookupBind(this.name)}toString(){return`@${this.name}`}}class gi extends Pt{eval(t){return t.lookupDynamic(this.name)}toPathItem(){return null}toString(){return`*${this.name}`}}class Ae extends Pt{eval(t){return t.lookupField(this.name)}toPathItem(){return new Me(this.name)}toRawFieldVal(){return new Bt(this.name)}toString(){return`.${this.name}`}}class Ue extends Pt{eval(t){return t.lookupComputed(this.name)}toString(){return`$${this.name}`}}class Ke extends Or{constructor(t,e){super();this.seqVal=t,this.keyVal=e}toPathItem(){return new pr(this.seqVal.name,this.keyVal.name)}eval(t){let e=this.keyVal.eval(t);return this.seqVal.eval(t).get(e,null)}toString(){return`${this.seqVal}[${this.keyVal}]`}}var wi=0,pi=1,be=2,zi=3;function Ph(t){let e=0,r=0;for(let s=0;s<t.length;s++)switch(t.charCodeAt(s)){case 91:if(e>0)return be;e+=1;break;case 93:if(r>0||e===0)return be;r+=1;break;case 123:return wi;case 125:return zi}if(e>0||r>0)return e===1&&r===1?pi:be;return-1}var w=new li;class jt{constructor(t){this.items=t}eval(t){return{}}static parse(t,e,r=!1){return jr(e).parse(t,r)}isConstant(){return!1}}var Ch="itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected",xh=new Set(Ch.split(","));class Si{constructor(t){this.clear(t)}clear(t){this.px=t,this.attrs=null,this.hasDynamic=!1,this.wrapperAttrs=null,this.textChild=null,this.eachAttr=null,this.ifAttr=null,this.events=null}parseAttr(t,e,r=!1){let s=r?w.parseAll(e,this.px):w.parseAttr(e,this.px);if(s!==null)this.attrs??=[],this.attrs.push(new $t(t,s)),this.hasDynamic||=!(s instanceof W)}pushWrapper(t,e,r){let s={name:t,val:r,raw:e};return this.wrapperAttrs??=[],this.wrapperAttrs.push(s),s}parseIf(t,e){let r=w.parseCondValue(e,this.px);if(r)this.ifAttr=new Oi(t.slice(3),r),this.attrs??=[],this.attrs.push(this.ifAttr),this.hasDynamic=!0}parseThen(t){if(this.ifAttr)this.ifAttr.thenVal=w.parseAttr(t,this.px)??Ct}parseElse(t){if(this.ifAttr)this.ifAttr.elseVal=w.parseAttr(t,this.px)??Ct}parseEvent(t,e){let[r,...s]=t.slice(3).split("+"),i=$r.parse(e,this.px);if(i){if(this.events===null)this.events=this.px.registerEvents(),this.attrs??=[],this.attrs.push(new Ie("data-eid",w.const(this.events.id)));this.events.add(r,i,s)}}parseDirective(t,e){switch(e){case"dangerouslysetinnerhtml":this.attrs??=[],this.attrs.push(new di(w.parseText(t,this.px))),this.hasDynamic=!0;return;case"slot":this.pushWrapper("slot",t,w.const(t));return;case"push-view":this.pushWrapper("push-view",t,w.parseText(t,this.px));return;case"text":this.textChild=w.parseText(t,this.px);return;case"show":this.pushWrapper("show",t,w.parseCondValue(t,this.px));return;case"hide":this.pushWrapper("hide",t,w.parseCondValue(t,this.px));return;case"each":this.eachAttr=this.pushWrapper("each",t,w.parseEach(t,this.px));return;case"enrich-with":if(this.eachAttr!==null)this.eachAttr.enrichWithVal=w.parseAlter(t,this.px);else this.pushWrapper("scope",t,w.parseAlter(t,this.px));return;case"when":this._parseWhen(t);return;case"loop-with":this._parseLoopWith(t);return;case"then":this.parseThen(t);return;case"else":this.parseElse(t);return}if(e.startsWith("on."))this.parseEvent(e,t);else if(e.startsWith("if."))this.parseIf(e,t);else if(e.startsWith("then."))this.parseThen(t);else if(e.startsWith("else."))this.parseElse(t)}_parseWhen(t){if(this.eachAttr!==null)this.eachAttr.whenVal=w.parseAlter(t,this.px)}_parseLoopWith(t){if(this.eachAttr!==null)this.eachAttr.loopWithVal=w.parseAlter(t,this.px)}parse(t,e=!1){for(let{name:n,value:h}of t){let u=n.charCodeAt(0);if(u===58)this.parseAttr(n===":viewbox"?"viewBox":n.slice(1),h,e);else if(u===64)this.parseDirective(h,n.slice(1));else{this.attrs??=[];let o=h===""&&xh.has(n)?!0:h;this.attrs.push(new Ie(n,w.const(o)))}}let{attrs:r,hasDynamic:s}=this;return[s?new Le(r):qr.fromAttrs(r??[]),this.wrapperAttrs,this.textChild]}}class qr extends jt{eval(t){return this.items}static fromAttrs(t){let e={};for(let r of t)e[r.name]=r.value.eval(null);return new qr(e)}setDataAttr(t,e){this.items[t]=e}toMacroVars(){let t={};for(let e in this.items)t[e]=`'${this.items[e]}'`;return t}isConstant(){return!0}}class Le extends jt{eval(t){let e={};for(let r of this.items)e[r.name]=r.eval(t);return e}setDataAttr(t,e){this.items.push(new Ie(t,new W(e)))}toMacroVars(){let t={};for(let e of this.items)t[e.name]=e.value.toString();return t}}class Er{constructor(t){this.name=t}}class $t extends Er{constructor(t,e){super(t);this.value=e}eval(t){return this.value.eval(t)}}class Ie extends $t{}class di extends $t{constructor(t){super("dangerouslySetInnerHTML",t??w.nullConstVal)}eval(t){return{__html:`${this.value.eval(t)}`}}}var Ct=w.nullConstVal;class Oi extends Er{constructor(t,e){super(t);this.condVal=e,this.thenVal=this.elseVal=Ct}get anyBranchIsSet(){return this.thenVal!==Ct||this.elseVal!==Ct}eval(t){return this.condVal.eval(t)?this.thenVal.eval(t):this.elseVal.eval(t)}}var br=null;function jr(t){return br??=new Si(t),br.clear(t),br}class $r{constructor(t,e=[]){this.handlerVal=t,this.args=e}getHandlerAndArgs(t,e){let r=Array(this.args.length);for(let s=0;s<r.length;s++)r[s]=this.args[s].eval(t);return[this.handlerVal.eval(t),r]}static parse(t,e){let[r,...s]=t.trim().split(/\s+/),i=w.parseHandlerName(r,e);if(i===null)return null;let n=Array(s.length);w.allowHandlerArg();for(let h=0;h<s.length;h++){let u=w.parse(s[h],e);n[h]=u!==null?u:w.nullConstVal}return new $r(i,n)}}class Ar{constructor(t,e){this.name=t,this.fn=e}toHandlerArg(t){let e=(...r)=>t.request(this.name,r);return e.withOpts=(...r)=>t.request(this.name,r.slice(0,-1),r.at(-1)),e}}class At{render(t,e){return e.renderEmpty()}setDataAttr(t,e){console.warn("setDataAttr not implemented for",this,{key:t,val:e})}isConstant(){return!1}optimize(){}}class kt extends At{constructor(t){super();this.v=t}render(t,e){return e.renderText(this.v)}isWhiteSpace(){for(let t=0;t<this.v.length;t++){let e=this.v.charCodeAt(t);if(!(e===32||e===10||e===9||e===13))return!1}return!0}hasNewLine(){for(let t=0;t<this.v.length;t++){let e=this.v.charCodeAt(t);if(e===10||e===13)return!0}return!1}condenseWhiteSpace(){this.v=""}isConstant(){return!0}setDataAttr(t,e){}}class Ft extends kt{render(t,e){return e.renderComment(this.v)}}function Fh(t){for(let e=0;e<t.length;e++){let r=t[e];if(r.isConstant())t[e]=new Jr(r);else r.optimize()}}function Ir(t){if(t.isConstant())return new Jr(t);return t.optimize(),t}class Lr extends At{constructor(t){super();this.childs=t}isConstant(){return this.childs.every((t)=>t.isConstant())}optimize(){Fh(this.childs)}}class We extends Lr{constructor(t,e,r){super(r);this.tagName=t,this.attrs=e}render(t,e){let r=Array(this.childs.length);for(let s=0;s<r.length;s++)r[s]=this.childs[s]?.render?.(t,e)??null;return e.renderTag(this.tagName,this.attrs.eval(t),r)}setDataAttr(t,e){this.attrs.setDataAttr(t,e)}isConstant(){return this.attrs.isConstant()&&super.isConstant()}}class Je extends Lr{render(t,e){return e.renderFragment(this.childs.map((r)=>r?.render(t,e)))}setDataAttr(t,e){for(let r of this.childs)r.setDataAttr(t,e)}}var xt=(t)=>t.length===1?t[0]:new Je(t),kh=/^[a-zA-Z][a-zA-Z0-9-]*$/,Mi=null;class et extends At{constructor(t,e){super();this.nodeId=t,this.val=e}toPathItem(){return this.val.toPathItem()}static parse(t,e){Mi??=e.newDOMParser();let r=Mi.parseFromString(t,"text/html").body.childNodes;return et.fromDOM(r[0]??new e.Text(""),e)}static fromDOM(t,e){if(e.isTextNode(t))return new kt(t.textContent);else if(e.isCommentNode(t))return new Ft(t.textContent);let{childNodes:r,attributes:s,tagName:i}=t,n=Array(r.length);for(let h=0;h<r.length;h++)n[h]=et.fromDOM(r[h],e);if(i==="X"){if(s.length===0)return xt(n);let{name:h,value:u}=s[0],o=s.getNamedItem("as")?.value??null;switch(h){case"slot":return new Ze(null,w.const(u),xt(n));case"text":{let f=w.parseText(u,e);return f!==null?new Kr(null,f):null}case"render":return e.addNodeIf(Ui,w.parseRender(u,e),o);case"render-it":return e.addNodeIf(De,w.bindValIt,o);case"render-each":return Vt.parse(e,w,u,o,s);case"show":return e.addNodeIf(Rr,w.parseCondValue(u,e),xt(n));case"hide":return e.addNodeIf(Dr,w.parseCondValue(u,e),xt(n))}return new Ft(`Error: InvalidSpecialTagOp ${h}=${u}`)}else if(i.charCodeAt(1)===58&&i.charCodeAt(0)===88){let h=i.slice(2).toLowerCase();if(h==="slot"){let f=s.getNamedItem("name")?.value??"_";return e.frame.macroSlots[f]??xt(n)}let[u,o]=jt.parse(s,e,!0);return e.onAttributes(u,o,null),bi(e.newMacroNode(h,u.toMacroVars(),n),e,o)}else if(kh.test(i)){let[h,u,o]=jt.parse(s,e);if(e.onAttributes(h,u,o),o)n.unshift(new Kr(null,o));let f=i!=="PRE"?tu(n):n;return bi(new We(i.toLowerCase(),h,f),e,u)}return new Ft(`Error: InvalidTagName ${i}`)}}function bi(t,e,r){if(r)for(let s=r.length-1;s>=0;s--){let i=Vh(r[s],e);if(i)i.wrapNode(t),t=i}return t}function Vh(t,e){let r=vh[t.name],s=r.register?e.addNodeIf(r,t.val):t.val&&new r(null,t.val);if(s!==null&&t.name==="each")s.iterInfo.enrichWithVal=t.enrichWithVal??null,s.iterInfo.whenVal=t.whenVal??null,s.iterInfo.loopWithVal=t.loopWithVal??null;return s}class Ai extends At{constructor(t,e,r,s){super();this.name=t,this.attrs=e,this.slots=r,this.px=s,this.node=null,this.dataAttrs={}}compile(t){let{name:e,attrs:r,slots:s}=this;if(this.px.isInsideMacro(e))throw Error(`Recursive macro expansion: ${e}`);let i=t.lookupMacro(e);if(i===null)this.node=new Ft(`bad macro: ${e}`);else{let n={...i.defaults,...r};this.node=i.expand(this.px.enterMacro(e,n,s));for(let h in this.dataAttrs)this.node.setDataAttr(h,this.dataAttrs[h])}}render(t,e){return this.node.render(t,e)}setDataAttr(t,e){this.dataAttrs[t]=e}isConstant(){return this.node.isConstant()}optimize(){this.node=Ir(this.node)}}class Wr{constructor(t,e){this.defaults=t,this.rawView=e}expand(t){return et.parse(this.rawView,t)}}class Re extends et{constructor(t,e,r){super(t,e);this.viewId=r}}class Ui extends Re{render(t,e){let r=t.enter(this.val.eval(t),{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}}class De extends Re{render(t,e){return e.renderIt(t,this.nodeId,"",this.viewId)}pathInNext=!0}class Vt extends Re{constructor(t,e,r){super(t,e,r);this.iterInfo=new Zr(e,null,null,null)}render(t,e){return e.renderEach(t,this.iterInfo,this.nodeId,this.viewId)}static parse(t,e,r,s,i){let n=t.addNodeIf(Vt,e.parseEach(r,t),s);if(n!==null){let h=jr(t);h.eachAttr=h.pushWrapper("each",r,n.val);let u=i.getNamedItem("when");u&&h._parseWhen(u.value);let o=i.getNamedItem("loop-with");o&&h._parseLoopWith(o.value),n.iterInfo.whenVal=h.eachAttr.whenVal??null,n.iterInfo.loopWithVal=h.eachAttr.loopWithVal??null}return n}}class Kr extends et{render(t,e){return e.renderText(this.val.eval(t))}}class Jr extends At{constructor(t){super();this.node=t,this._render=(e,r)=>{let s=t.render(e,r);return this._render=(i,n)=>s,s}}render(t,e){return this._render(t,e)}}class ft extends et{constructor(t,e,r=null){super(t,e);this.node=r}wrapNode(t){this.node=t}setDataAttr(t,e){this.node.setDataAttr(t,e)}optimize(){this.node=Ir(this.node)}static register=!1}class Rr extends ft{render(t,e){return this.val.eval(t)?this.node.render(t,e):e.renderEmpty()}}class Dr extends ft{render(t,e){return this.val.eval(t)?e.renderEmpty():this.node.render(t,e)}}class Ki extends ft{render(t,e){return this.node.render(t.pushViewName(this.val.eval(t)),e)}}class Ze extends ft{optimize(){this.node.optimize()}}class Ii extends ft{render(t,e){let r=this.val.eval(t)?.call(t.it)??{};return this.node.render(t.enter(t.it,r,!1),e)}toPathItem(){return new Et({})}wrapNode(t){this.node=t,this.node.setDataAttr("data-nid",this.nodeId)}static register=!0}class Te extends ft{constructor(t,e){super(t,e);this.iterInfo=new Zr(e,null,null,null)}render(t,e){return e.renderEachWhen(t,this.iterInfo,this.node,this.nodeId)}toPathItem(){return new Et({})}static register=!0}class Zr{constructor(t,e,r,s){this.val=t,this.whenVal=e,this.loopWithVal=r,this.enrichWithVal=s}eval(t){let e=this.val.eval(t)??[],r=this.whenVal?.eval(t)??Nh,s=this.loopWithVal?.eval(t)??mh,i=this.enrichWithVal?.eval(t)??null;return{seq:e,filter:r,loopWith:s,enricher:i}}}var Nh=(t,e,r)=>!0,mh=(t)=>({seq:t}),vh={slot:Ze,show:Rr,hide:Dr,each:Te,scope:Ii,"push-view":Ki};class V{constructor(t,e,r,s,i,n,h,u){this.nodes=s??[],this.events=i??[],this.macroNodes=n??[],this.parent=u??null,this.frame=h??{},this.DOMParser=t??globalThis.DOMParser,this.Text=e??globalThis.Text,this.Comment=r??globalThis.Comment,this.cacheConstNodes=!0}isInsideMacro(t){return this.frame.macroName===t||this.parent?.isInsideMacro(t)}enterMacro(t,e,r){let{DOMParser:s,Text:i,Comment:n,nodes:h,events:u,macroNodes:o}=this;return new V(s,i,n,h,u,o,{macroName:t,macroVars:e,macroSlots:r},this)}newDOMParser(){return new this.DOMParser}isTextNode(t){return t instanceof this.Text}isCommentNode(t){return t instanceof this.Comment}addNodeIf(t,e,r){if(e!==null){let s=this.nodes.length,i=new t(s,e,r);return this.nodes.push(i),i}return null}registerEvents(){let t=this.events.length,e=new Li(t);return this.events.push(e),e}newMacroNode(t,e,r){let s=[],i={_:new Je(s)};for(let h of r)if(h instanceof Ze)i[h.val.value]=h.node;else if(!(h instanceof kt)||!h.isWhiteSpace())s.push(h);let n=new Ai(t,e,i,this);return this.macroNodes.push(n),n}compile(t){for(let e=0;e<this.macroNodes.length;e++)this.macroNodes[e].compile(t)}*genEventNames(){for(let t of this.events)yield*t.genEventNames()}getEventForId(t){return this.events[t]??null}getNodeForId(t){return this.nodes[t]??null}onAttributes(t,e,r){}}var Ur=(t)=>t instanceof kt&&t.isWhiteSpace(),qi=(t)=>t instanceof We||t instanceof Je&&t.childs[0]instanceof We;function tu(t){let e=t.length;if(e===0)return t;let r=0,s=!1;if(Ur(t[0]))r=1,s=!0;if(e>1&&Ur(t[e-1]))e-=1,s=!0;for(let i=1;i<e-1;i++){let n=t[i];if(Ur(n)&&qi(t[i-1])&&qi(t[i+1])&&n.hasNewLine())n.condenseWhiteSpace()}return s?t.slice(r,e):t}class Xe{constructor(t,e,r="",s=null,i=null){this.name=t,this.anode=s,this.style=r,this.ctx=i,this.rawView=e}compile(t,e,r){if(this.ctx=t,this.anode=et.parse(this.rawView,t),this.anode.setDataAttr("data-cid",r),this.anode.setDataAttr("data-vid",this.name),this.ctx.compile(e),t.cacheConstNodes)this.anode=Ir(this.anode)}render(t,e){return this.anode.render(t,e)}}class Li{constructor(t){this.id=t,this.handlers=[]}add(t,e,r){this.handlers.push(new Wi(t,e,r))}*genEventNames(){for(let t of this.handlers)yield t.name}getHandlersFor(t){let e=null;for(let r of this.handlers)if(r.handlesEventName(t))e??=[],e.push(r);return e}}class Wi{constructor(t,e,r){this.name=t,this.handlerCall=e,this.modifierWrapper=nu(t,r),this.modifiers=r}handlesEventName(t){return this.name===t}getHandlerAndArgs(t,e){let r=this.handlerCall.getHandlerAndArgs(t,e);return r[0]=this.modifierWrapper(r[0],e),r}}var eu=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),He=(t)=>(e)=>(r,s,i,n)=>t(n)?e(r,s,i,n):r,Ei=(t)=>He((e)=>e.e.key===t),ji=He(({e:t})=>eu&&t.metaKey||t.ctrlKey),ru=He(({e:t})=>t.metaKey),su=He(({e:t})=>t.altKey),$i={ctrl:ji,cmd:ji,meta:ru,alt:su},Tr={keydown:{send:Ei("Enter"),cancel:Ei("Escape"),...$i},click:{...$i}},iu=(t,e)=>t;function nu(t,e){if(e.length===0)return iu;let r=Tr[t]??{},s=(i,n,h,u)=>n.apply(i,h);for(let i of e){let n=r[i];if(n!==void 0)s=n(s)}return(i,n)=>function(...h){return s(this,i,h,n)}}class Xr{get(t,e){}set(t,e,r){}get2(t,e,r){}set2(t,e,r,s){}evict(){return{hit:0,miss:0,badKey:0}}}class Hr{constructor(){this.hit=this.miss=this.badKey=0,this.map=new WeakMap}_returnValue(t){if(t===void 0)this.miss+=1;else this.hit+=1;return t}get(t,e){return this._returnValue(this.map.get(t)?.[e])}set(t,e,r){let s=this.map.get(t);if(s)s[e]=r;else if(typeof t==="object")this.map.set(t,{[e]:r});else this.badKey+=1}get2(t,e,r){return this._returnValue(this.map.get(t)?.get?.(e)?.[r])}set2(t,e,r,s){let i=this.map.get(t);if(i){let n=i.get(e);if(n)n[r]=s;else i.set(e,{[r]:s})}else if(typeof t==="object"&&typeof e==="object"){let n=new WeakMap;n.set(e,{[r]:s}),this.map.set(t,n)}else this.badKey+=1}evict(){let{hit:t,miss:e,badKey:r}=this;return this.hit=this.miss=this.badKey=0,this.map=new WeakMap,{hit:t,miss:e,badKey:r}}}class Qr{getKey(t,e,r){return r.call(t)}}class Gr{constructor(){this.map=new WeakMap}getKey(t,e,r){let s=this.map.get(t);if(s){let n=s[e];if(n!==void 0)return n;let h=r.call(t)??null;return s[e]=h,h}let i=r.call(t)??null;return this.map.set(t,{[e]:i}),i}}class Qe{constructor(){this.getComponentSymbol=Symbol("getComponent"),this.byId=new Map,this.computedCache=new Gr}setNullComputedCache(){this.computedCache=new Qr}registerComponent(t){t.Class.prototype[this.getComponentSymbol]=()=>t,this.byId.set(t.id,t)}getComponentForId(t){return this.byId.get(t)??null}getCompFor(t){return t?.[this.getComponentSymbol]?.()??null}getOnEnterFor(t){let e=this.getCompFor(t);return e?e.on.stackEnter:Ri}getInputHandlerFor(t,e){return this.getCompFor(t)?.input[e]??null}getAlterHandlerFor(t,e){return this.getCompFor(t)?.alter[e]??null}getRequestFor(t,e){let r=this.getCompFor(t);return r?r.scope.lookupRequest(e):null}lookupComputed(t,e){let r=this.getCompFor(t)?.computed[e];return r?this.computedCache.getKey(t,e,r):null}compileStyles(){let t=[];for(let e of this.byId.values())t.push(e.compileStyle());return t.join(`
2
- `)}}class Ge{constructor(t=new Qe,e=null){this.comps=t,this.parent=e,this.byName={},this.reqsByName={},this.macros={}}enter(){return new Ge(this.comps,this)}registerComponents(t,e={}){for(let r=0;r<t.length;r++){let s=t[r];s.scope=this.enter(),this.comps.registerComponent(s),this.byName[s.name]=s;let i=e[s.name];if(i)this.byName[i]=s}}registerMacros(t){Object.assign(this.macros,t)}getCompFor(t){return this.comps.getCompFor(t)}registerRequestHandlers(t){for(let e in t)this.reqsByName[e]=new Ar(e,t[e])}lookupRequest(t){return this.reqsByName[t]??this.parent?.lookupRequest(t)??null}lookupComponent(t){return this.byName[t]??this.parent?.lookupComponent(t)??null}lookupMacro(t){return this.macros[t]??this.parent?.lookupMacro(t)??null}}class Yr{constructor(t,e,r){this.name=t,this.val=e,this.symbol=r}getSymbol(t){return this.symbol}evalAndBind(t,e){e[this.getSymbol(t)]=this.val.eval(t)}}class Ji extends Yr{constructor(t,e,r,s){super(t,e,null);this.compName=r,this.dynName=s}_resolveSymbol(t){return t.lookupType(this.compName)?.dynamic[this.dynName]?.symbol??null}getSymbol(t){return this.symbol??=this._resolveSymbol(t),this.symbol}}var Ut=(t)=>typeof t==="string",hu=0;class Br{constructor(t,e,r,s={},i="",n="",h="",u={},o={},f={},c={},_={},l={},a={},y={}){this.id=hu++,this.name=t,this.Class=e,this.views={main:new Xe("main",r,i)},this.commonStyle=n,this.globalStyle=h,this.computed=u,this.input=o,this.logic=f,this.bubble=c,this.response=_,this.alter=l,this.on={stackEnter:y?.stackEnter??Ri};for(let p in s){let d=s[p],{view:j,style:bt}=Ut(d)?{view:d}:d;this.views[p]=new Xe(p,j,bt)}this._rawDynamic=a,this.dynamic={},this.scope=null}compile(t){for(let e in this._rawDynamic){let r=this._rawDynamic[e];if(Ut(r)){let s=w.parseDynamic(r,this.views.main.ctx);this.dynamic[e]=new Yr(e,s,Symbol(e))}else if(Ut(r?.default)&&Ut(r?.for)){let s=w.parseDynamic(r.default,this.views.main.ctx),[i,n]=r.for.split(".");if(Ut(i)&&Ut(n))this.dynamic[e]=new Ji(e,s,i,n)}}for(let e in this.views)this.views[e].compile(new t,this.scope,this.id)}make(t,e){return this.Class.make(t,e)}getView(t){return this.views[t]??this.views.main}getEventForId(t,e="main"){return this.getView(e).ctx.getEventForId(t)}getNodeForId(t,e="main"){return this.getView(e).ctx.getNodeForId(t)}compileStyle(){let{id:t,commonStyle:e,globalStyle:r,views:s}=this,i=e?[`[data-cid="${t}"]{${e}}`]:[];if(r!=="")i.push(r);for(let n in s){let{style:h}=s[n];if(h!=="")i.push(`[data-cid="${t}"][data-vid="${n}"]{${h}}`)}return i.join(`
3
- `)}}function Ri(t){return t}var Di=Symbol("STOP"),xr=Symbol("NEXT");class Nt{constructor(t,e){this.head=t,this.tail=e}push(t){return new Nt(t,this)}lookup(t,e=null){let{tail:r}=this,s=this.head.lookup(t);return s===Di?e:s===xr?r!==null?r.lookup(t,e):e:s}*[Symbol.iterator](){let t=this;while(t!==null)yield t.head,t=t.tail}}class Pr{constructor(t,e,r){this.it=t,this.bindings=e,this.isFrame=r}lookup(t){let e=this.bindings[t];return e===void 0?this.isFrame?Di:xr:e}}class Cr{constructor(t){this.bindings=t}lookup(t){let e=this.bindings[t];return e===void 0?xr:e}}class Q{constructor(t,e,r,s,i,n=null){this.comps=t,this.it=e,this.binds=r,this.dynBinds=s,this.views=i,this.ctx=n;let h=[...i].join("");this.viewsId=h==="main"?"":h}_enrichOnEnter(){return this.comps.getOnEnterFor(this.it).call(this.it,this)??this}upToFrameBinds(){let{comps:t,binds:e,dynBinds:r,views:s,ctx:i}=this;return e.head.isFrame?this:new Q(t,e.tail.head.it,e.tail,r,s,i)}static root(t,e,r){let s=new Nt(new Pr(e,{it:e},!0),null),i=new Nt(new Cr({}),null),n=new Nt("main",null);return new Q(t,e,s,i,n,r)._enrichOnEnter()}enter(t,e={},r=!0){let{comps:s,binds:i,dynBinds:n,views:h,ctx:u}=this,o=i.push(new Pr(t,e,r));return new Q(s,t,o,n,h,u)._enrichOnEnter()}pushViewName(t){let{comps:e,it:r,binds:s,dynBinds:i,views:n,ctx:h}=this;return new Q(e,r,s,i,n.push(t),h)}withDynamicBindings(t){let e={},r=this.comps.getCompFor(this.it);for(let f of t)r.dynamic[f].evalAndBind(this,e);let{comps:s,it:i,binds:n,views:h,ctx:u}=this,o=this.dynBinds.push(new Cr(e));return new Q(s,i,n,o,h,u)}lookupDynamic(t){let e=this.comps.getCompFor(this.it)?.dynamic[t];return e?this.dynBinds.lookup(e.getSymbol(this))??e.val.eval(this):null}lookupBind(t){return this.binds.lookup(t)}lookupType(t){return this.comps.getCompFor(this.it).scope.lookupComponent(t)}lookupFieldRaw(t){return this.it[t]??null}lookupField(t){let e=this.lookupFieldRaw(t);return e instanceof Function?e.call(this.it):e}lookupName(t){return this.ctx.lookupName(t)}lookupComputed(t){let e=this.binds.head.isFrame?this.binds.head:this.binds.tail.head;return this.comps.lookupComputed(e.it,t)}getInputHandler(t){return this.comps.getInputHandlerFor(this.it,t)}getAlterHandler(t){return this.comps.getAlterHandlerFor(this.it,t)}lookupRequest(t){return this.comps.getRequestFor(this.it,t)}lookupBestView(t,e){for(let r of this.views){let s=t[r];if(s!==void 0)return s}return t[e]}}class Ti{constructor(t){this.value=t,this.changeSubs=[]}onChange(t){this.changeSubs.push(t)}set(t,e){let r=this.value;this.value=t;for(let s of this.changeSubs)s({value:t,old:r,info:e,timestamp:Date.now()})}update(t,e){return this.set(t(this.value),e)}}class kr{constructor(t,e){this.comps=t,this.transactions=[],this.state=new Ti(e),this.onTransactionPushed=()=>{}}pushTransaction(t){return this.transactions.push(t),this.onTransactionPushed(t),t}pushLogic(t,e,r=[],s={},i=null){return this.pushTransaction(new mr(t,this,e,r,i,s))}pushBubble(t,e,r=[],s={},i=null){let n=s.skipSelf?{...s,skipSelf:!1}:s;return this.pushTransaction(new Qi(t,this,e,r,i,n))}async pushRequest(t,e,r=[],s={},i=null){let n=this.state.value,h=t.lookup(n),u=this.comps.getRequestFor(h,e)??uu(e),o=s?.onResName??e,f=(c,_,l,a,y)=>{let d=new Hi(t,this,c??_,c?[l]:[a,y],i);return this.pushTransaction(d)};try{let c=await u.fn.apply(null,r);return f(s?.onOkName,o,c,c,null)}catch(c){return f(s?.onErrorName,o,c,null,c)}}get hasPendingTransactions(){return this.transactions.length>0}transactNext(){if(this.hasPendingTransactions)this.transact(this.transactions.shift())}transactAll(){while(this.hasPendingTransactions)this.transact(this.transactions.shift())}transact(t){let e=this.state.value,r=t.run(e,this.comps);if(r!==void 0)this.state.set(r,{transaction:t}),t.afterTransaction();else console.warn("undefined new state",{curState:e,transaction:t})}transactInputNow(t,e,r,s){this.transact(new Xi(t,e,r,this,s))}}function uu(t){return()=>{throw Error(`Request not found: ${t}`)}}function ou(){return this}class Vr{constructor(t,e){this.path=t,this.transactor=e,this.parentTransaction=null,this._task=null}get task(){return this._task??=new Gi,this._task}getCompletionPromise(){return this.task.promise}setParent(t){this.parentTransaction=t,t.task.addDep(this.task)}run(t,e){return this.updateRootValue(t,e)}afterTransaction(){}buildRootStack(t,e){return Q.root(e,t)}buildStack(t,e){let r=this.path.buildStack(this.buildRootStack(t,e));return r?r.upToFrameBinds():null}callHandler(t,e,r){let[s,i]=this.getHandlerAndArgs(t,e,r);return s.apply(e,i)}getHandlerAndArgs(t,e,r){return null}updateRootValue(t,e){let r=this.path.lookup(t),s=this.callHandler(t,r,e);return this._task?.complete?.({value:s,old:r}),r!==s?this.path.setValue(t,s):t}lookupName(t){return null}}var fu=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Zi=(t)=>Number.isNaN(t)?null:t;function Fr(t){return t.target.type==="checkbox"?t.target.checked:(t instanceof CustomEvent?t.detail:t.target.value)??null}class Xi extends Vr{constructor(t,e,r,s,i){super(t,s);this.e=e,this.handler=r,this.dragInfo=i}buildRootStack(t,e){return Q.root(e,t,this)}getHandlerAndArgs(t,e,r){let s=this.buildStack(t,r),[i,n]=this.handler.getHandlerAndArgs(s,this),h;for(let u=0;u<n.length;u++)if(n[u]?.toHandlerArg)h??=new vr(this.path,this.transactor,this),n[u]=n[u].toHandlerArg(h);return[i,n]}lookupName(t){let{e}=this;switch(t){case"value":return Fr(e);case"valueAsInt":return Zi(parseInt(Fr(e),10));case"valueAsFloat":return Zi(parseFloat(Fr(e)));case"target":return e.target;case"event":return e;case"isAlt":return e.altKey;case"isShift":return e.shiftKey;case"isCtrl":case"isCmd":return fu&&e.metaKey||e.ctrlKey;case"key":return e.key;case"keyCode":return e.keyCode;case"isUpKey":return e.key==="ArrowUp";case"isDownKey":return e.key==="ArrowDown";case"isSend":return e.key==="Enter";case"isCancel":return e.key==="Escape";case"isTabKey":return e.key==="Tab";case"ctx":return new ts(this.path,this.transactor,this);case"dragInfo":return this.dragInfo}return null}}class Nr extends Vr{constructor(t,e,r,s,i,n={}){super(t,e,i);this.name=r,this.args=s,this.opts=n}handlerProp=null;getHandlerForName(t){return t?.[this.handlerProp]?.[this.name]??ou}getHandlerAndArgs(t,e,r){return[this.getHandlerForName(r.getCompFor(e)),[...this.args,new ts(this.path,this.transactor,this)]]}}class Hi extends Nr{handlerProp="response"}class mr extends Nr{handlerProp="logic";run(t,e){return this.opts.skipSelf?t:this.updateRootValue(t,e)}afterTransaction(){let{path:t,name:e,args:r,opts:s}=this;if(s.bubbles&&t.steps.length>0)this.transactor.pushBubble(t.popStep(),e,r,s,this)}}class Qi extends mr{handlerProp="bubble";stopPropagation(){this.opts.bubbles=!1}}class Gi{constructor(t){this.info=t,this.deps=[],this.value=this.resolve=this.reject=null,this.promise=new Promise((e,r)=>{this.resolve=e,this.reject=r}),this.isCompleted=!1}addDep(t){console.assert(!this.isCompleted,"addDep for completed task",this,t),this.deps.push(t),t.promise.then((e)=>this._check())}complete(t){this.value=t,this._check()}_check(){if(this.deps.every((t)=>t.isCompleted))this.isCompleted=!0,this.resolve(this)}}class vr{constructor(t,e,r=null){this.path=t,this.transactor=e,this.parent=r}get at(){return new Yi(this)}logic(t,e,r){return this.logicAtPath(this.path,t,e,r)}bubble(t,e,r){return this.logic(t,e,{skipSelf:!0,bubbles:!0,...r})}logicAtPath(t,e,r,s){return this.transactor.pushLogic(t,e,r,s,this.parent)}request(t,e,r){return this.requestAtPath(this.path,t,e,r)}requestAtPath(t,e,r,s){return this.transactor.pushRequest(t,e,r,s,this.parent)}lookupTypeFor(t,e){return this.transactor.comps.getCompFor(e).scope.lookupComponent(t)}}class ts extends vr{stopPropagation(){return this.parent.stopPropagation()}}class Yi extends zr{constructor(t){super();this.dispatcher=t}logic(t,e,r){return this.dispatcher.logicAtPath(this.buildPath(),t,e,r)}bubble(t,e,r){return this.logic(t,e,{skipSelf:!0,bubbles:!0,...r})}buildPath(){return this.dispatcher.path.concat(this.pathChanges)}}class es{constructor(t,e,r,s,i){this.rootNode=t,this.comps=r,this.compStack=new Ge(r),this.transactor=new kr(r,null),this.ParseContext=i,this.renderer=s,this.renderFn=e,this.maxEventNodeDepth=1/0,this._transactNextBatchId=this._evictCacheId=null,this._eventNames=new Set(["dragstart","dragover","dragend"]),this.dragInfo=this.curDragOver=null,this.transactor.onTransactionPushed=(n)=>{if(this._transactNextBatchId===null)this._scheduleNextTransactionBatchExecution()},this._compiled=!1}get state(){return this.transactor.state}handleEvent(t){let e=t.type==="dragstart",r=t.type==="dragover",s=t.type==="dragend",{rootNode:i,maxEventNodeDepth:n,comps:h}=this,u=!(r||e||s),[o,f]=tt.fromEvent(t,i,n,h,u);if(r){let c=cu(t.target,this.rootNode,50);if(c!==null)t.preventDefault(),this._cleanDragOverAttrs(),this.curDragOver=c,c.dataset.draggingover=this.dragInfo.type}else if(e){t.target.dataset.dragging=1;let c=this.state.value,_=o.lookup(c),l=t.target.dataset.dragtype??"?",a=o.buildStack(this.makeStack(c));this.dragInfo=new Bi(o,a,t,_,l,t.target)}else if(s)delete this.dragInfo.node.dataset.dragging,this.dragInfo=null,this._cleanDragOverAttrs();if(o!==null&&f!==null)for(let c of f)this.transactor.transactInputNow(o,t,c,this.dragInfo)}makeStack(t){return Q.root(this.comps,t)}_cleanDragOverAttrs(){if(this.curDragOver!==null)delete this.curDragOver.dataset.draggingover,this.curDragOver=null}render(){let t=this.state.value,e=this.makeStack(t);return this.renderFn(this.renderer.renderRoot(e,t),this.rootNode)}onChange(t){this.transactor.state.onChange(t)}compile(){for(let t of this.comps.byId.values()){t.compile(this.ParseContext);for(let e in t.views)for(let r of t.views[e].ctx.genEventNames())this._eventNames.add(r)}this._compiled=!0}start(t){if(!this._compiled)this.compile();for(let e of this._eventNames)this.rootNode.addEventListener(e,this);if(this.onChange((e)=>{if(e.value!==e.old)this.render()}),Ye("tutuca-app",this.comps.compileStyles(),t?.head??document.head),t?.noCache)this.renderer.setNullCache(),this.comps.setNullComputedCache();else this.startCacheEvictionInterval();this.render()}stop(){this.stopCacheEvictionInterval();for(let t of this._eventNames)this.rootNode.removeEventListener(t,this)}dispatchLogicAtRoot(t,e,r){return this.transactor.pushLogic(new tt([]),t,e,r)}registerComponents(t,e){let r=this.compStack.enter();return r.registerComponents(t,e),r}_transactNextBatch(t=10){this._transactNextBatchId=null;let e=Date.now(),r=this.transactor;while(r.hasPendingTransactions&&Date.now()-e<t)r.transactNext();if(r.hasPendingTransactions)this._scheduleNextTransactionBatchExecution()}_scheduleNextTransactionBatchExecution(){this._transactNextBatchId=setTimeout(()=>this._transactNextBatch(),0)}startCacheEvictionInterval(t=30000){this._evictCacheId=setInterval(()=>this.renderer.cache.evict(),t)}stopCacheEvictionInterval(){clearInterval(this._evictCacheId),this._evictCacheId=null}}function Ye(t,e,r=document.head){let s=document.createElement("style"),i=r.querySelector(`#${t}`);if(i)r.removeChild(i);s.id=t,s.innerHTML=e,r.appendChild(s)}function cu(t,e,r){let s=t;while(r-- >0&&s!==e){if(s.dataset?.droptarget!==void 0)return s;s=s.parentNode}return null}class Bi{constructor(t,e,r,s,i,n){this.path=t,this.stack=e,this.e=r,this.value=s,this.type=i,this.node=n}lookupBind(t){return this.stack.lookupBind(t)}}class Be extends V{constructor(...t){super(...t);this.classes=new Set}_addClasses(t){for(let e of t.split(/\s+/))this.classes.add(e)}enterMacro(t,e,r){let{DOMParser:s,Text:i,Comment:n,nodes:h,events:u,macroNodes:o}=this,c=new Be(s,i,n,h,u,o,{macroName:t,macroVars:e,macroSlots:r},this);return c.classes=this.classes,c}onAttributes(t,e,r){if(Array.isArray(t.items))for(let s of t.items){if(s.name!=="class")continue;let{value:i,thenVal:n,elseVal:h}=s;if(n!==void 0)this._maybeAddVal(n),this._maybeAddVal(h);else this._maybeAddVal(i)}else{let s=t.items.class;if(s)this._addClasses(s)}}_maybeAddVal(t){if(!this._maybeAddStrTpl(t)&&typeof t?.value==="string")this._addClasses(t.value)}_maybeAddStrTpl(t){if(t?.vals!==void 0){for(let e of t.vals)if(e instanceof W&&e.value!=="")this._addClasses(e.value);return!0}return!1}}function mt(t,e){if(!t)throw Error(e)}function K(t){mt(t!==1/0,"Cannot perform this action with an infinite size.")}function Pi(t,e,r,s,i,n){return K(t.size),t.__iterate((h,u,o)=>{if(i)i=!1,r=h;else r=e.call(s,r,h,u,o)},n),r}var _u=(t,e)=>e,lu=(t,e)=>[e,t],rs=(t)=>function(...e){return!t.apply(this,e)},Ci=(t)=>function(...e){return-t.apply(this,e)};function an(t,e){if(t===void 0&&e===void 0)return 0;if(t===void 0)return 1;if(e===void 0)return-1;return t>e?1:t<e?-1:0}var xi=(t,e)=>t<e?1:t>e?-1:0,I={done:!0,value:void 0};class yn{constructor(t){this.next=t}[Symbol.iterator](){return this}}function R(t){return new yn(t)}function q(t){let e=[void 0,void 0],r={done:!1,value:void 0};return R(()=>{if(t(e))return r.value=[e[0],e[1]],r;return I})}var au=R(()=>I),ct=()=>au;function tr(t){let e=0,r={done:!1,value:void 0};return R(()=>{if(e===t)return I;return r.value=e++,r})}function ue(t,e){return q((r)=>{let s=t.next();if(s.done)return!1;return e(s.value[0],s.value[1],r),!0})}function gn(t){if(Array.isArray(t))return!0;return!!er(t)}var yu=(t)=>!!(t&&typeof t.next==="function");function wn(t){return er(t)?.call(t)}function er(t){let e=t&&t[Symbol.iterator];if(typeof e==="function")return e}function gu(t){let e=er(t);return e&&e===t.entries}function wu(t){let e=er(t);return e&&e===t.keys}var oe="delete",S=5,E=1<<S,L=E-1,g={},cs=()=>({value:!1});function H(t){if(t)t.value=!0}class rr{}function Lt(t){if(t.size===void 0)t.size=t.__iterate(pn);return t.size}function st(t,e){if(typeof e!=="number"){let r=e>>>0;if(String(r)!==e||r===4294967295)return NaN;e=r}return e<0?Lt(t)+e:e}var pn=()=>!0,zn=(t)=>t<0||Object.is(t,-0),fe=(t,e,r)=>(t===0&&!zn(t)||r!==void 0&&(t??0)<=-r)&&(e===void 0||r!==void 0&&e>=r),Sn=(t,e,r)=>t===void 0?r:zn(t)?e===1/0?e:Math.max(0,e+t)|0:e===void 0||e===t?t:Math.min(e,t)|0,Dt=(t,e)=>Sn(t,e,0),ce=(t,e)=>Sn(t,e,e),dn="@@__IMMUTABLE_ITERABLE__@@",ke="@@__IMMUTABLE_KEYED__@@",Ve="@@__IMMUTABLE_INDEXED__@@",it="@@__IMMUTABLE_ORDERED__@@",_e="@@__IMMUTABLE_SEQ__@@",On="@@__IMMUTABLE_LIST__@@",Mn="@@__IMMUTABLE_MAP__@@",bn="@@__IMMUTABLE_SET__@@",qn="@@__IMMUTABLE_STACK__@@",En="@@__IMMUTABLE_RECORD__@@";function x(t,e){return typeof t==="object"&&t!==null&&e in t}var T=(t)=>x(t,dn),z=(t)=>x(t,ke),$=(t)=>x(t,Ve),ps=(t)=>z(t)||$(t),C=(t)=>x(t,it),zs=(t)=>x(t,_e),Ss=(t)=>x(t,On),le=(t)=>x(t,Mn),ds=(t)=>x(t,bn),Os=(t)=>x(t,qn),gt=(t)=>x(t,En),F=(t)=>T(t)||gt(t),sr=(t)=>le(t)&&C(t),jn=(t)=>ds(t)&&C(t),Fi=(t)=>typeof t==="object"&&t!==null&&typeof t.equals==="function"&&typeof t.hashCode==="function";function $n(t){let e=P(t);return e._iter=t,e.size=t.size,e.flip=()=>t,e.reverse=function(){let r=t.reverse.call(this);return r.flip=()=>t.reverse(),r},e.has=(r)=>t.includes(r),e.includes=(r)=>t.has(r),e.cacheResult=Tt,e.__iterate=function(r,s){return t.__iterate((i,n)=>r(n,i,this),s)},e.__iteratorUncached=function(r){return ue(t.__iterator(r),(s,i,n)=>{n[0]=i,n[1]=s})},e}function An(t,e,r){let s=P(t);return s.size=t.size,s.has=(i)=>t.has(i),s.get=(i,n)=>{let h=t.get(i,g);return h===g?n:e.call(r,h,i,t)},s.__iterate=function(i,n){return t.__iterate((h,u)=>i(e.call(r,h,u,t),u,this),n)},s.__iteratorUncached=function(i){return ue(t.__iterator(i),(n,h,u)=>{u[0]=n,u[1]=e.call(r,h,n,t)})},s}function Un(t,e){let r=P(t);if(r._iter=t,r.size=t.size,r.reverse=()=>t,t.flip)r.flip=function(){let s=$n(t);return s.reverse=()=>t.flip(),s};return r.get=(s,i)=>t.get(e?s:-1-s,i),r.has=(s)=>t.has(e?s:-1-s),r.includes=(s)=>t.includes(s),r.cacheResult=Tt,r.__iterate=function(s,i){let n=0;if(i)Lt(t);return t.__iterate((h,u)=>s(h,e?u:i?this.size-++n:n++,this),!i)},r.__iteratorUncached=function(s){let i=0;if(s)Lt(t);let n=this.size;return ue(t.__iterator(!s),(h,u,o)=>{o[0]=e?h:s?n-++i:i++,o[1]=u})},r}function Kn(t,e,r,s){let i=t.size;if(fe(e,r,i))return t;if(i===void 0&&(e<0||r<0))return Kn(t.toSeq().cacheResult(),e,r,s);let n=Dt(e,i),u=ce(r,i)-n,o;if(!Number.isNaN(u))o=Math.max(0,u);let f=P(t);if(f.size=o===0?o:t.size&&o||void 0,!s&&zs(t)&&o>=0)f.get=function(c,_){return c=st(this,c),c>=0&&c<o?t.get(c+n,_):_};return f.__iterateUncached=function(c,_){if(o!==0&&_)return this.cacheResult().__iterate(c,_);if(o===0)return 0;let l=0,a=0;return t.__iterate((y,p)=>{if(l<n){l++;return}if(o!==void 0&&a>=o)return!1;if(a++,c(y,s?p:a-1,this)===!1)return!1},_),a},f.__iteratorUncached=function(c){if(o!==0&&c)return this.cacheResult().__iterator(c);if(o===0)return ct();let _=t.__iterator(c),l=0,a=0;if(s)return R(()=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return I;let y=_.next();if(y.done)return y;return a++,y});return q((y)=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return!1;let p=_.next();if(p.done)return!1;return a++,y[0]=a-1,y[1]=p.value[1],!0})},f}function It(t,e,r){if(!e)e=an;let s=z(t),i=0,n=t.toSeq().map((h,u)=>[u,h,i++,r?r(h,u,t):h]).valueSeq().toArray();return n.sort((h,u)=>e(h[3],u[3])||h[2]-u[2]).forEach(s?(h,u)=>{n[u].length=2}:(h,u)=>{n[u]=h[1]}),s?js(n):$(t)?yt(n):te(n)}function Pe(t,e,r){if(!e)e=an;if(r){let s=t.toSeq().map((i,n)=>[i,r(i,n,t)]).reduce((i,n)=>ki(e,i[1],n[1])?n:i);return s&&s[0]}return t.reduce((s,i)=>ki(e,s,i)?i:s)}function ki(t,e,r){let s=t(r,e);return s===0&&r!==e&&(r===void 0||r===null||Number.isNaN(r))||s>0}function ss(t,e,r,s){let i=P(t),n=new ae(r).map((h)=>h.size);return i.size=s?n.max():n.min(),i.__iterate=function(h,u){let o=this.__iterator(u),f=0,c;while(!(c=o.next()).done)if(h(c.value[1],f++,this)===!1)break;return f},i.__iteratorUncached=function(h){let u=r.map((_)=>{let l=m(_);return wn(h?l.reverse():l)}),o=0,f=Array(u.length),c=Array(u.length);return q((_)=>{let l=s;for(let a=0;a<u.length;a++)f[a]=u[a].next(),l=s?l&&f[a].done:l||f[a].done;if(l)return!1;for(let a=0;a<f.length;a++)c[a]=f[a].value;return _[0]=o++,_[1]=e(...c),!0})},i}function In(t){if(Array.isArray(t)||typeof t==="string")return!0;return t&&typeof t==="object"&&Number.isInteger(t.length)&&t.length>=0&&(t.length===0?Object.keys(t).length===1:Object.hasOwn(t,t.length-1))}function pu(t){if(!t||typeof t!=="object"||Object.prototype.toString.call(t)!=="[object Object]")return!1;let e=Object.getPrototypeOf(t);if(e===null)return!0;let r=e,s=Object.getPrototypeOf(e);while(s!==null)r=s,s=Object.getPrototypeOf(r);return r===e}var nt=(t)=>typeof t==="object"&&(F(t)||Array.isArray(t)||pu(t));function Ln(t){if(In(t)&&typeof t!=="string")return t;if(C(t))return t.toArray();throw TypeError(`Invalid keyPath: expected Ordered Collection or Array: ${t}`)}var zu=(t,e)=>F(t)?t.has(e):nt(t)&&Object.hasOwn(t,e);function Wn(t,e,r){return F(t)?t.get(e,r):!zu(t,e)?r:typeof t.get==="function"?t.get(e):t[e]}function Ms(t,e,r){let s=Ln(e),i=0;while(i!==s.length)if(t=Wn(t,s[i++],g),t===g)return r;return t}var Jn=(t,e)=>Ms(t,e,g)!==g;function A(t,e){if(t===e||Number.isNaN(t)&&Number.isNaN(e))return!0;if(!t||!e)return!1;if(typeof t.valueOf==="function"&&typeof e.valueOf==="function"){if(t=t.valueOf(),e=e.valueOf(),t===e||Number.isNaN(t)&&Number.isNaN(e))return!0;if(!t||!e)return!1}return!!(Fi(t)&&Fi(e)&&t.equals(e))}function Ne(t){if(!t||typeof t!=="object")return t;if(!T(t)){if(!nt(t))return t;t=ht(t)}if(z(t)){let r={};return t.__iterate((s,i)=>{r[String(i)]=Ne(s)}),r}let e=[];return t.__iterate((r)=>{e.push(Ne(r))}),e}function bs(t,e){if(t===e)return!0;if(!T(e)||t.size!==void 0&&e.size!==void 0&&t.size!==e.size||t.__hash!==void 0&&e.__hash!==void 0&&t.__hash!==e.__hash||z(t)!==z(e)||$(t)!==$(e)||C(t)!==C(e))return!1;if(t.size===0&&e.size===0)return!0;let r=!ps(t);if(C(t)){let h=t.entries();return!!(e.every((u,o)=>{let f=h.next().value;return f&&A(f[1],u)&&(r||A(f[0],o))})&&h.next().done)}let s=!1;if(t.size===void 0)if(e.size===void 0){if(typeof t.cacheResult==="function")t.cacheResult()}else{s=!0;let h=t;t=e,e=h}let i=!0,n=e.__iterate((h,u)=>{if(r?!t.has(h):s?!A(h,t.get(u,g)):!A(t.get(u,g),h))return i=!1,!1;return!0});return i&&t.size===n}var ir=(t)=>t>>>1&1073741824|t&3221225471;function G(t){if(t===null||t===void 0)return Vi(t);if(typeof t.hashCode==="function")return ir(t.hashCode(t));let e=bu(t);if(e===null||e===void 0)return Vi(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return Su(e);case"string":return e.length>qu?du(e):_s(e);case"object":case"function":return Mu(e);case"symbol":return Ou(e);default:if(typeof e.toString==="function")return _s(e.toString());throw Error(`Value type ${typeof e} cannot be hashed.`)}}var Vi=(t)=>t===null?1108378658:1108378659;function Su(t){if(Number.isNaN(t)||t===1/0)return 0;let e=t|0;if(e!==t)e^=t*4294967295;while(t>4294967295)t/=4294967295,e^=t;return ir(e)}function du(t){let e=hs[t];if(e===void 0){if(e=_s(t),ns===Eu)ns=0,hs={};ns++,hs[t]=e}return e}function _s(t){let e=0;for(let r=0;r<t.length;r++)e=31*e+t.charCodeAt(r)|0;return ir(e)}function Ou(t){let e=mi[t];if(e!==void 0)return e;return e=Rn(),mi[t]=e,e}function Mu(t){let e=Ni.get(t);if(e!==void 0)return e;return e=Rn(),Ni.set(t,e),e}var bu=(t)=>t.valueOf!==Object.prototype.valueOf?t.valueOf():t;function Rn(){let t=++is;if(is&1073741824)is=0;return t}var Ni=new WeakMap,mi=Object.create(null),is=0,qu=16,Eu=255,ns=0,hs={};function ju(t){if(t.size===1/0)return 0;let e=C(t),r=z(t),s=e?1:0;return t.__iterate(r?e?(i,n)=>{s=31*s+vi(G(i),G(n))|0}:(i,n)=>{s=s+vi(G(i),G(n))|0}:e?(i)=>{s=31*s+G(i)|0}:(i)=>{s=s+G(i)|0}),$u(t.size,s)}var vi=(t,e)=>t^e+2654435769+(t<<6)+(t>>2)|0;function $u(t,e){return e=Math.imul(e,3432918353),e=Math.imul(e<<15|e>>>-15,461845907),e=Math.imul(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=Math.imul(e^e>>>16,2246822507),e=Math.imul(e^e>>>13,3266489909),e=ir(e^e>>>16),e}function vt(t){try{return typeof t==="string"?JSON.stringify(t):String(t)}catch{return JSON.stringify(t)}}var O=(t,e)=>t===e?t:zs(t)?e:t.create?t.create(e):t.constructor(e),Dn=(t,e)=>O(t,(z(t)?Y:$(t)?wt:pt)(e)),tn=(...t)=>t,m=(t)=>T(t)?t:ht(t);class b{size=0;static{this.prototype[dn]=!0,this.prototype.__toStringMapper=vt,this.prototype[Symbol.iterator]=this.prototype.values,this.prototype.toJSON=this.prototype.toArray,this.prototype.contains=this.prototype.includes}equals(t){return bs(this,t)}hashCode(){return this.__hash??(this.__hash=ju(this))}toArray(){K(this.size);let t=Array(this.size||0),e=z(this),r=0;return this.__iterate((s,i)=>{t[r++]=e?[i,s]:s}),t}toIndexedSeq(){return new Qn(this)}toJS(){return Ne(this)}toKeyedSeq(){return new Is(this,!0)}toMap(){throw Error("toMap: not patched — import CollectionConversions")}toObject(){K(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}toOrderedMap(){throw Error("toOrderedMap: not patched — import CollectionConversions")}toOrderedSet(){throw Error("toOrderedSet: not patched — import CollectionConversions")}toSet(){throw Error("toSet: not patched — import CollectionConversions")}toSetSeq(){return new Gn(this)}toSeq(){return $(this)?this.toIndexedSeq():z(this)?this.toKeyedSeq():this.toSetSeq()}toStack(){throw Error("toStack: not patched — import CollectionConversions")}toList(){throw Error("toList: not patched — import CollectionConversions")}toString(){return"[Collection]"}__toString(t,e){if(this.size===0)return`${t}${e}`;return`${t} ${this.toSeq().map(this.__toStringMapper).join(", ")} ${e}`}concat(...t){let e=z(this),r=[this,...t].map((s)=>{if(!T(s))s=e?Tn(s):Xn(Array.isArray(s)?s:[s]);else if(e)s=Y(s);return s}).filter((s)=>s.size!==0);if(r.length===0)return this;if(r.length===1){let s=r[0];if(s===this||e&&z(s)||$(this)&&$(s))return s}return O(this,new Hn(r))}includes(t){return this.some((e)=>A(e,t))}every(t,e){K(this.size);let r=!0;return this.__iterate((s,i,n)=>{if(!t.call(e,s,i,n))return r=!1,!1}),r}entries(){return this.__iterator()}filter(t,e){let r=this,s=z(this),i=P(r);if(s)i.has=(n)=>{let h=r.get(n,g);return h!==g&&!!t.call(e,h,n,r)},i.get=(n,h)=>{let u=r.get(n,g);return u!==g&&t.call(e,u,n,r)?u:h};return i.__iterateUncached=function(n,h){let u=0;return r.__iterate((o,f)=>{if(t.call(e,o,f,r))return u++,n(o,s?f:u-1,this)},h),u},i.__iteratorUncached=function(n){let h=r.__iterator(n),u=0;return q((o)=>{while(!0){let f=h.next();if(f.done)return!1;let c=f.value[0],_=f.value[1];if(t.call(e,_,c,r))return o[0]=s?c:u++,o[1]=_,!0}})},O(this,i)}partition(t,e){let r=z(this),s=[[],[]];return this.__iterate((i,n)=>{s[t.call(e,i,n,this)?1:0].push(r?[n,i]:i)}),s.map((i)=>Dn(this,i))}find(t,e,r){let s=this.findEntry(t,e);return s?s[1]:r}forEach(t,e){return K(this.size),this.__iterate(e?t.bind(e):t)}join(t){K(this.size),t=t!==void 0?String(t):",";let e="",r=!0;return this.__iterate((s)=>{if(r)r=!1;else e+=t;e+=s!==null&&s!==void 0?String(s):""}),e}keys(){let t=this.__iterator(),e={done:!1,value:void 0};return R(()=>{let r=t.next();if(r.done)return I;return e.value=r.value[0],e})}map(t,e){return O(this,An(this,t,e))}reduce(t,e=g,r){return Pi(this,t,e,r,e===g,!1)}reduceRight(t,e=g,r){return Pi(this,t,e,r,e===g,!0)}reverse(){return O(this,Un(this,z(this)))}slice(t,e){return O(this,Kn(this,t,e,z(this)))}some(t,e){K(this.size);let r=!1;return this.__iterate((s,i,n)=>{if(t.call(e,s,i,n))return r=!0,!1}),r}sort(t){return O(this,It(this,t))}values(){let t=this.__iterator(),e={done:!1,value:void 0};return R(()=>{let r=t.next();if(r.done)return I;return e.value=r.value[1],e})}butLast(){return this.slice(0,-1)}isEmpty(){return this.size!==void 0?this.size===0:!this.some(()=>!0)}count(t,e){return Lt(t?this.toSeq().filter(t,e):this)}countBy(t,e){throw Error("countBy: not patched — import CollectionConversions")}entrySeq(){let t=this;if(t._cache)return new ae(t._cache);let e=t.toSeq().map(lu).toIndexedSeq();return e.fromEntrySeq=()=>t.toSeq(),e}filterNot(t,e){return this.filter(rs(t),e)}findEntry(t,e,r){let s=r;return this.__iterate((i,n,h)=>{if(t.call(e,i,n,h))return s=[n,i],!1}),s}findKey(t,e){let r=this.findEntry(t,e);return r&&r[0]}findLast(t,e,r){return this.toKeyedSeq().reverse().find(t,e,r)}findLastEntry(t,e,r){return this.toKeyedSeq().reverse().findEntry(t,e,r)}findLastKey(t,e){return this.toKeyedSeq().reverse().findKey(t,e)}first(t){return this.find(pn,null,t)}flatMap(t,e){return O(this,this.toSeq().map((r,s)=>(z(this)?Y:$(this)?wt:pt)(t.call(e,r,s,this))).flatten(!0))}flatten(t){let e=this,r=z(this),s=P(e);return s.__iterateUncached=function(i,n){if(n)return this.cacheResult().__iterate(i,n);let h=0,u=!1;function o(f,c){f.__iterate((_,l)=>{if((!t||c<t)&&T(_))o(_,c+1);else if(h++,i(_,r?l:h-1,s)===!1)u=!0;if(u)return!1},n)}return o(e,0),h},s.__iteratorUncached=function(i){if(i)return this.cacheResult().__iterator(i);let n=0,h=[{iterator:e.__iterator(i),depth:0}];return q((u)=>{while(h.length>0){let o=h[h.length-1],f=o.iterator.next();if(f.done){h.pop();continue}let c=f.value[1];if((!t||o.depth<t)&&T(c)){h.push({iterator:c.__iterator(i),depth:o.depth+1});continue}return u[0]=r?f.value[0]:n++,u[1]=c,!0}return!1})},O(this,s)}fromEntrySeq(){return new Yn(this)}get(t,e){return this.find((r,s)=>A(s,t),void 0,e)}getIn(t,e){return Ms(this,t,e)}groupBy(t,e){throw Error("groupBy: not patched — import CollectionConversions")}has(t){return this.get(t,g)!==g}hasIn(t){return Jn(this,t)}isSubset(t){let e=typeof t.includes==="function"?t:m(t);return this.every((r)=>e.includes(r))}isSuperset(t){return(typeof t.isSubset==="function"?t:m(t)).isSubset(this)}keyOf(t){return this.findKey((e)=>A(e,t))}keySeq(){return this.toSeq().map(_u).toIndexedSeq()}last(t){return this.toSeq().reverse().first(t)}lastKeyOf(t){return this.toKeyedSeq().reverse().keyOf(t)}max(t){return Pe(this,t)}maxBy(t,e){return Pe(this,e,t)}min(t){return Pe(this,t?Ci(t):xi)}minBy(t,e){return Pe(this,e?Ci(e):xi,t)}rest(){return this.slice(1)}skip(t){return t===0?this:this.slice(Math.max(0,t))}skipLast(t){return t===0?this:this.slice(0,-Math.max(0,t))}skipWhile(t,e){let r=this,s=z(this),i=P(r);return i.__iterateUncached=function(n,h){if(h)return this.cacheResult().__iterate(n,h);let u=!0,o=0;return r.__iterate((f,c)=>{if(u&&t.call(e,f,c,this))return;return u=!1,o++,n(f,s?c:o-1,this)},h),o},i.__iteratorUncached=function(n){if(n)return this.cacheResult().__iterator(n);let h=r.__iterator(n),u=0,o=this,f=!0;return q((c)=>{while(!0){let _=h.next();if(_.done)return!1;let l=_.value[0],a=_.value[1];if(f&&t.call(e,a,l,o))continue;return f=!1,c[0]=s?l:u++,c[1]=a,!0}})},O(this,i)}skipUntil(t,e){return this.skipWhile(rs(t),e)}sortBy(t,e){return O(this,It(this,e,t))}take(t){return this.slice(0,Math.max(0,t))}takeLast(t){return this.slice(-Math.max(0,t))}takeWhile(t,e){let r=this,s=P(r);return s.__iterateUncached=function(i,n){if(n)return this.cacheResult().__iterate(i,n);let h=0;return r.__iterate((u,o)=>{if(!t.call(e,u,o,this))return!1;return h++,i(u,o,this)},n),h},s.__iteratorUncached=function(i){if(i)return this.cacheResult().__iterator(i);let n=r.__iterator(i),h=this,u=!1;return R(()=>{if(u)return I;let o=n.next();if(o.done)return o;if(!t.call(e,o.value[1],o.value[0],h))return u=!0,I;return o})},O(this,s)}takeUntil(t,e){return this.takeWhile(rs(t),e)}update(t){return t(this)}valueSeq(){return this.toIndexedSeq()}__iterate(t,e=!1){let r=this.__iterator(e),s=0,i;while(!(i=r.next()).done)if(s++,t(i.value[1],i.value[0],this)===!1)break;return s}__iterator(t=!1){throw Error("CollectionImpl does not implement __iterator. Use a subclass instead.")}}var Y=(t)=>z(t)?t:js(t);class qs extends b{static{this.prototype[ke]=!0,this.prototype.__toStringMapper=(t,e)=>`${vt(e)}: ${vt(t)}`,this.prototype[Symbol.iterator]=b.prototype.entries,this.prototype.toJSON=function(){K(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}}flip(){return O(this,$n(this))}mapEntries(t,e){let r=0;return O(this,this.toSeq().map((s,i)=>t.call(e,[i,s],r++,this)).fromEntrySeq())}mapKeys(t,e){return O(this,this.toSeq().flip().map((r,s)=>t.call(e,r,s,this)).flip())}}var wt=(t)=>$(t)?t:yt(t);class at extends b{static{this.prototype[Ve]=!0,this.prototype[it]=!0}toKeyedSeq(){return new Is(this,!1)}findIndex(t,e){let r=this.findEntry(t,e);return r?r[0]:-1}indexOf(t){let e=this.keyOf(t);return e===void 0?-1:e}lastIndexOf(t){let e=this.lastKeyOf(t);return e===void 0?-1:e}splice(t,e=g,...r){if(t===void 0)return this;let s=e!==g;if(e=s?Math.max(e||0,0):0,s&&!e&&r.length===0)return this;t=Dt(t,t<0?this.count():this.size);let i=this.slice(0,t);return O(this,!s?i:i.concat(r,this.slice(t+e)))}findLastIndex(t,e){let r=this.findLastEntry(t,e);return r?r[0]:-1}first(t){return this.get(0,t)}get(t,e){return t=st(this,t),t<0||this.size===1/0||this.size!==void 0&&t>this.size?e:this.find((r,s)=>s===t,void 0,e)}has(t){return t=st(this,t),t>=0&&(this.size!==void 0?this.size===1/0||t<this.size:this.indexOf(t)!==-1)}interpose(t){let e=this,r=P(e);return r.size=e.size&&e.size*2-1,r.__iterateUncached=function(s,i){let n=0,h=!0;return e.__iterate((u)=>{if(!h){if(s(t,n++,this)===!1)return!1}return h=!1,s(u,n++,this)},i),n},r.__iteratorUncached=function(s){let i=e.__iterator(s),n=0,h=!0,u,o=!1;return q((f)=>{if(o)return o=!1,f[0]=n++,f[1]=u,!0;let c=i.next();if(c.done)return!1;let _=c.value[1];if(!h)return u=_,o=!0,f[0]=n++,f[1]=t,!0;return h=!1,f[0]=n++,f[1]=_,!0})},O(this,r)}interleave(...t){let e=[this,...t],r=ss(this.toSeq(),yt.of,e),s=r.flatten(!0);if(r.size)s.size=r.size*e.length;return O(this,s)}keySeq(){throw Error("keySeq: not patched — import CollectionConversions")}last(t){return this.get(-1,t)}zip(...t){return this.zipWith(tn,...t)}zipAll(...t){let e=[this,...t];return O(this,ss(this,tn,e,!0))}zipWith(t,...e){let r=[this,...e];return O(this,ss(this,t,r))}}var pt=(t)=>T(t)&&!ps(t)?t:te(t);class nr extends b{static{this.prototype.has=b.prototype.includes,this.prototype.contains=b.prototype.includes,this.prototype.keys=nr.prototype.values}get(t,e){return this.has(t)?t:e}includes(t){return this.has(t)}keySeq(){return this.valueSeq()}}m.Keyed=Y;m.Indexed=wt;m.Set=pt;var us=at.prototype,ht=(t)=>t===void 0||t===null?Us():F(t)?t.toSeq():Au(t),P=(t)=>Object.create((z(t)?Zt:$(t)?zt:$s).prototype);class _t extends b{static{this.prototype[_e]=!0}toSeq(){return this}toString(){return this.__toString("Seq {","}")}cacheResult(){if(!this._cache&&this.__iterateUncached)this._cache=this.entrySeq().toArray(),this.size=this._cache.length;return this}__iterateUncached(t,e){let r=this.__iteratorUncached(e),s=0,i;while(!(i=r.next()).done)if(s++,t(i.value[1],i.value[0],this)===!1)break;return s}__iterate(t,e){let r=this._cache;if(r){let s=r.length,i=0;while(i!==s){let n=r[e?s-++i:i++];if(t(n[1],n[0],this)===!1)break}return i}return this.__iterateUncached(t,e)}__iterator(t){let e=this._cache;if(e){let r=e.length,s=0,i={done:!1,value:void 0};return R(()=>{if(s===r)return I;return i.value=e[t?r-++s:s++],i})}return this.__iteratorUncached(t)}}var Es={cacheResult:_t.prototype.cacheResult,__iterateUncached:_t.prototype.__iterateUncached,__iterate:_t.prototype.__iterate,__iterator:_t.prototype.__iterator},js=(t)=>t===void 0||t===null?Us().toKeyedSeq():T(t)?z(t)?t.toSeq():t.fromEntrySeq():gt(t)?t.toSeq():Tn(t);class Zt extends qs{static{this.prototype[_e]=!0,Object.assign(this.prototype,Es)}toSeq(){return this}toKeyedSeq(){return this}}var yt=(t)=>t===void 0||t===null?Us():T(t)?z(t)?t.entrySeq():t.toIndexedSeq():gt(t)?t.toSeq().entrySeq():Xn(t);yt.of=(...t)=>yt(t);class zt extends at{static{this.prototype[_e]=!0,Object.assign(this.prototype,Es)}toSeq(){return this}toIndexedSeq(){return this}toString(){return this.__toString("Seq [","]")}}var te=(t)=>(T(t)&&!ps(t)?t:yt(t)).toSetSeq();te.of=(...t)=>te(t);class $s extends nr{static{this.prototype[_e]=!0,Object.assign(this.prototype,Es)}toSeq(){return this}toSetSeq(){return this}}ht.isSeq=zs;ht.Keyed=js;ht.Set=te;ht.Indexed=yt;class ae extends zt{constructor(t){super();this._array=t,this.size=t.length}get(t,e){return this.has(t)?this._array[st(this,t)]:e}__iterateUncached(t,e){let r=this._array,s=r.length,i=0;while(i!==s){let n=e?s-++i:i++;if(t(r[n],n,this)===!1)break}return i}__iteratorUncached(t){let e=this._array,r=e.length,s=0;return q((i)=>{if(s===r)return!1;let n=t?r-++s:s++;return i[0]=n,i[1]=e[n],!0})}}class As extends Zt{static{this.prototype[it]=!0}constructor(t){super();let e=[...Object.keys(t),...Object.getOwnPropertySymbols(t)];this._object=t,this._keys=e,this.size=e.length}get(t,e){if(e!==void 0&&!this.has(t))return e;return this._object[t]}has(t){return Object.hasOwn(this._object,t)}__iterateUncached(t,e){let r=this._object,s=this._keys,i=s.length,n=0;while(n!==i){let h=s[e?i-++n:n++];if(t(r[h],h,this)===!1)break}return n}__iteratorUncached(t){let e=this._object,r=this._keys,s=r.length,i=0;return q((n)=>{if(i===s)return!1;let h=r[t?s-++i:i++];return n[0]=h,n[1]=e[h],!0})}}class Zn extends zt{constructor(t){super();this._collection=t,this.size=t.length||t.size}__iterateUncached(t,e){if(e)return this.cacheResult().__iterate(t,e);let r=0;for(let s of this._collection){if(t(s,r,this)===!1)break;r++}return r}__iteratorUncached(t){if(t)return this.cacheResult().__iterator(t);let e=this._collection,r=wn(e);if(!yu(r))return ct();let s=0;return q((i)=>{let n=r.next();if(n.done)return!1;return i[0]=s++,i[1]=n.value,!0})}}var Us=()=>new ae([]),Ks=(t)=>In(t)?new ae(t):gn(t)?new Zn(t):void 0;function Tn(t){let e=Ks(t);if(e)return e.fromEntrySeq();if(typeof t==="object")return new As(t);throw TypeError(`Expected Array or collection object of [k, v] entries, or keyed object: ${t}`)}function Xn(t){let e=Ks(t);if(e)return e;throw TypeError(`Expected Array or collection object of values: ${t}`)}function Au(t){let e=Ks(t);if(e)return gu(t)?e.fromEntrySeq():wu(t)?e.toSetSeq():e;if(typeof t==="object")return new As(t);throw TypeError(`Expected Array or collection object of values, or keyed object: ${t}`)}class Hn extends _t{constructor(t){super();let e=[],r=0,s=!0;for(let n of t)if(n._wrappedIterables){for(let h of n._wrappedIterables)if(e.push(h),s){let u=h.size;if(u!==void 0)r+=u;else s=!1}}else if(e.push(n),s){let h=n.size;if(h!==void 0)r+=h;else s=!1}this._wrappedIterables=e,this.size=s?r:void 0;let i=this._wrappedIterables[0];if(i[ke])this[ke]=!0;if(i[Ve])this[Ve]=!0;if(i[it])this[it]=!0}__iterateUncached(t,e){if(this._wrappedIterables.length===0)return 0;if(e)return this.cacheResult().__iterate(t,e);let r=this._wrappedIterables,s=!z(this),i=0,n=!1;for(let h of r)if(h.__iterate((u,o)=>{if(t(u,s?i++:o,this)===!1)return n=!0,!1},e),n)break;return i}__iteratorUncached(t){if(this._wrappedIterables.length===0)return ct();if(t)return this.cacheResult().__iterator(t);let e=this._wrappedIterables,r=!z(this),s=0,i=e[0].__iterator(t);function n(){while(s<e.length){let h=i.next();if(!h.done)return h;if(s++,s<e.length)i=e[s].__iterator(t)}return}if(r){let h=0;return q((u)=>{let o=n();if(!o)return!1;return u[0]=h++,u[1]=o.value[1],!0})}return R(()=>n()||I)}}class Is extends Zt{static{this.prototype[it]=!0}constructor(t,e){super();this._iter=t,this._useKeys=e,this.size=t.size}cacheResult(){return Tt.call(this)}get(t,e){return this._iter.get(t,e)}has(t){return this._iter.has(t)}valueSeq(){return this._iter.valueSeq()}reverse(){let t=Un(this,!0);if(!this._useKeys)t.valueSeq=()=>this._iter.toSeq().reverse();return t}map(t,e){let r=An(this,t,e);if(!this._useKeys)r.valueSeq=()=>this._iter.toSeq().map(t,e);return r}__iterateUncached(t,e){return this._iter.__iterate(t,e)}__iteratorUncached(t){return this._iter.__iterator(t)}}class Qn extends zt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Tt.call(this)}includes(t){return this._iter.includes(t)}__iterateUncached(t,e){let r=0;if(e)Lt(this);let s=this.size;return this._iter.__iterate((i)=>{let n=e?s-++r:r++;return t(i,n,this)},e),r}__iteratorUncached(t){let e=0;if(t)Lt(this);let r=this.size;return ue(this._iter.__iterator(t),(s,i,n)=>{n[0]=t?r-++e:e++,n[1]=i})}}class Gn extends $s{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Tt.call(this)}has(t){return this._iter.includes(t)}__iterateUncached(t,e){return this._iter.__iterate((r)=>t(r,r,this),e)}__iteratorUncached(t){return ue(this._iter.__iterator(t),(e,r,s)=>{s[0]=r,s[1]=r})}}class Yn extends Zt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Tt.call(this)}entrySeq(){return this._iter.toSeq()}__iterateUncached(t,e){let r=0;return this._iter.__iterate((s)=>{if(s){en(s),r++;let i=T(s);return t(i?s.get(1):s[1],i?s.get(0):s[0],this)}},e),r}__iteratorUncached(t){let e=this._iter.__iterator(t);return q((r)=>{while(!0){let s=e.next();if(s.done)return!1;let i=s.value[1];if(i){en(i);let n=T(i);return r[0]=n?i.get(0):i[0],r[1]=n?i.get(1):i[1],!0}}})}}function Tt(){if(this._iter.cacheResult)return this._iter.cacheResult(),this.size=this._iter.size,this;return _t.prototype.cacheResult.call(this)}function en(t){if(t!==Object(t))throw TypeError(`Expected [K, V] tuple: ${t}`)}var D=(t)=>t===void 0||t===null?B():le(t)&&!C(t)?t:B().withMutations((e)=>{let r=Y(t);K(r.size),r.forEach((s,i)=>e.set(i,s))});class ee extends qs{static{dt(this,{asImmutable:ye,asMutable:ge,deleteIn:Wt,merge:ls,mergeWith:Vn,mergeDeep:mn,mergeDeepWith:vn,mergeDeepIn:Bs,mergeIn:Ys,setIn:Hs,update:Qs,updateIn:Gs,wasAltered:Xs,withMutations:we,removeIn:Wt,concat:ls,[Mn]:!0,[oe]:this.prototype.remove,removeAll:this.prototype.deleteAll,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Map"})}constructor(t,e,r,s){super();this.size=t,this._root=e,this.__ownerID=r,this.__hash=s,this.__altered=!1}create(t){return D(t)}toString(){return this.__toString("Map {","}")}get(t,e){return this._root?this._root.get(0,G(t),t,e):e}set(t,e){return sn(this,t,e)}remove(t){return sn(this,t,g)}deleteAll(t){let e=m(t);if(e.size===0)return this;return this.withMutations((r)=>{e.forEach((s)=>r.remove(s))})}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this;return B()}map(t,e){return this.withMutations((r)=>{r.forEach((s,i)=>{r.set(i,t.call(e,s,i,this))})})}keys(){if(!this._root)return ct();return Ce(this._root,!1,0)}values(){if(!this._root)return ct();return Ce(this._root,!1,1)}entries(){if(!this._root)return ct();return Ce(this._root,!1)}__iterator(t){if(!this._root)return ct();return Ce(this._root,t)}__iterate(t,e){let r=0;if(this._root)this._root.iterate(([s,i])=>{return r++,t(i,s,this)},e);return r}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return B();return this.__ownerID=t,this.__altered=!1,this}return Js(this.size,this._root,t,this.__hash)}}D.isMap=le;class Ls{constructor(t,e){this.ownerID=t,this.entries=e}get(t,e,r,s){return Bn(this.entries,r,s)}iterate(t,e){return Pn(this.entries,t,e)}update(t,e,r,s,i,n,h){let u=i===g,o=this.entries,f=0,c=o.length;for(;f<c;f++)if(A(s,o[f][0]))break;let _=f<c;if(_?o[f][1]===i:u)return this;if(H(h),u||!_)H(n);if(u&&c===1)return;if(!_&&!u&&c>=Ju)return Uu(t,o,s,i);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(f===c-1)a.pop();else a[f]=a.pop();else a[f]=[s,i];else a.push([s,i]);if(l)return this.entries=a,this;return new Ls(t,a)}}class hr{constructor(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}iterate(t,e){return Cn(this.nodes,t,e)}get(t,e,r,s){let i=1<<((t===0?e:e>>>t)&L),n=this.bitmap;return(n&i)===0?s:this.nodes[hn(n&i-1)].get(t+S,e,r,s)}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&L,o=1<<u,f=this.bitmap,c=(f&o)!==0;if(!c&&i===g)return this;let _=hn(f&o-1),l=this.nodes,a=c?l[_]:void 0,y=Rs(a,t,e+S,r,s,i,n,h);if(y===a)return this;if(!c&&y&&l.length>=Ru)return Iu(t,l,f,u,y);if(c&&!y&&l.length===2&&nn(l[_^1]))return l[_^1];if(c&&y&&l.length===1&&nn(y))return y;let p=t&&t===this.ownerID,d=c?y?f:f^o:f|o,j=c?y?xn(l,_,y,p):Wu(l,_,p):Lu(l,_,y,p);if(p)return this.bitmap=d,this.nodes=j,this;return new hr(t,d,j)}}class Ws{constructor(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}iterate(t,e){return Cn(this.nodes,t,e)}get(t,e,r,s){let i=(t===0?e:e>>>t)&L,n=this.nodes[i];return n?n.get(t+S,e,r,s):s}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&L,o=i===g,f=this.nodes,c=f[u];if(o&&!c)return this;let _=Rs(c,t,e+S,r,s,i,n,h);if(_===c)return this;let l=this.count;if(!c)l++;else if(!_){if(l--,l<Du)return Ku(t,f,l,u)}let a=t&&t===this.ownerID,y=xn(f,u,_,a);if(a)return this.count=l,this.nodes=y,this;return new Ws(t,l,y)}}class ur{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}get(t,e,r,s){return Bn(this.entries,r,s)}iterate(t,e){return Pn(this.entries,t,e)}update(t,e,r,s,i,n,h){if(r!==this.keyHash){if(i===g)return this;return H(h),H(n),Ds(this,t,e,r,[s,i])}let u=i===g,o=this.entries,f=0,c=o.length;for(;f<c;f++)if(A(s,o[f][0]))break;let _=f<c;if(_?o[f][1]===i:u)return this;if(H(h),u||!_)H(n);if(u&&c===2)return new St(t,this.keyHash,o[f^1]);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(f===c-1)a.pop();else a[f]=a.pop();else a[f]=[s,i];else a.push([s,i]);if(l)return this.entries=a,this;return new ur(t,this.keyHash,a)}}class St{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entry=r}iterate(t,e){return t(this.entry)}get(t,e,r,s){return A(r,this.entry[0])?this.entry[1]:s}update(t,e,r,s,i,n,h){let u=i===g,o=A(s,this.entry[0]);if(o?i===this.entry[1]:u)return this;if(H(h),u){H(n);return}if(o){if(t&&t===this.ownerID)return this.entry[1]=i,this;return new St(t,this.keyHash,[s,i])}return H(n),Ds(this,t,e,G(s),[s,i])}}function Bn(t,e,r){for(let s=0,i=t.length;s<i;s++)if(A(e,t[s][0]))return t[s][1];return r}function Pn(t,e,r){for(let s=0,i=t.length-1;s<=i;s++)if(e(t[r?i-s:s])===!1)return!1}function Cn(t,e,r){for(let s=0,i=t.length-1;s<=i;s++)if(t[r?i-s:s]?.iterate(e,r)===!1)return!1}function Ce(t,e,r){let s={node:t,index:0,__prev:null},i=r!==void 0?(h)=>h[r]:(h)=>h,n={done:!1,value:void 0};return R(()=>{while(s){let h=s.node,u=s.index++,o;if(h.entry){if(u===0)return n.value=i(h.entry),n}else if(h.entries){if(o=h.entries.length-1,u<=o)return n.value=i(h.entries[e?o-u:u]),n}else if(o=h.nodes.length-1,u<=o){let f=h.nodes[e?o-u:u];if(f){if(f.entry)return n.value=i(f.entry),n;s={node:f,index:0,__prev:s}}continue}s=s.__prev}return I})}var Js=(t,e,r,s)=>new ee(t,e,r,s),rn,B=()=>rn||(rn=Js(0));function sn(t,e,r){let s,i;if(!t._root){if(r===g)return t;i=1,s=new Ls(t.__ownerID,[[e,r]])}else{let n=cs(),h=cs();if(s=Rs(t._root,t.__ownerID,0,G(e),e,r,n,h),!h.value)return t;i=t.size+(n.value?r===g?-1:1:0)}if(t.__ownerID)return t.size=i,t._root=s,t.__hash=void 0,t.__altered=!0,t;return s?Js(i,s):B()}function Rs(t,e,r,s,i,n,h,u){if(!t){if(n===g)return t;return H(u),H(h),new St(e,s,[i,n])}return t.update(e,r,s,i,n,h,u)}var nn=(t)=>t.constructor===St||t.constructor===ur;function Ds(t,e,r,s,i){if(t.keyHash===s)return new ur(e,s,[t.entry,i]);let n=(r===0?t.keyHash:t.keyHash>>>r)&L,h=(r===0?s:s>>>r)&L,u=new St(e,s,i),o=n===h?[Ds(t,e,r+S,s,i)]:n<h?[t,u]:[u,t];return new hr(e,1<<n|1<<h,o)}function Uu(t,e,r,s){if(!t)t=new rr;let i=new St(t,G(r),[r,s]);for(let[n,h]of e)i=i.update(t,0,G(n),n,h);return i}function Ku(t,e,r,s){let i=0,n=0,h=Array(r);for(let u=0,o=1,f=e.length;u<f;u++,o<<=1){let c=e[u];if(c!==void 0&&u!==s)i|=o,h[n++]=c}return new hr(t,i,h)}function Iu(t,e,r,s,i){let n=0,h=Array(E);for(let u=0;r!==0;u++,r>>>=1)h[u]=r&1?e[n++]:void 0;return h[s]=i,new Ws(t,n+1,h)}function hn(t){return t-=t>>1&1431655765,t=(t&858993459)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,t+=t>>16,t&127}function xn(t,e,r,s){let i=s?t:t.slice();return i[e]=r,i}function Lu(t,e,r,s){let i=t.length+1;if(s&&e+1===i)return t[e]=r,t;let n=Array(i),h=0;for(let u=0;u<i;u++)if(u===e)n[u]=r,h=-1;else n[u]=t[u+h];return n}function Wu(t,e,r){let s=t.length-1;if(r&&e===s)return t.pop(),t;let i=Array(s),n=0;for(let h=0;h<s;h++){if(h===e)n=1;i[h]=t[h+n]}return i}var Ju=E/4,Ru=E/2,Du=E/4;function me(t){if(Array.isArray(t))return t.slice();return{...t}}var Zs=(t,e,r)=>Ts(t,e,Zu(r));function Ts(t,e,r){if(!nt(t))throw TypeError(`Cannot merge into non-data-structure value: ${t}`);if(F(t))return typeof r==="function"&&t.mergeWith?t.mergeWith(r,...e):t.merge?t.merge(...e):t.concat(...e);let s=Array.isArray(t),i=t,n=s?wt:Y,h=s?(u)=>{if(i===t)i=me(i);i.push(u)}:(u,o)=>{let f=Object.hasOwn(i,o),c=f&&r?r(i[o],u,o):u;if(!f||c!==i[o]){if(i===t)i=me(i);i[o]=c}};for(let u of e)n(u).forEach(h);return i}function Zu(t){function e(r,s,i){return nt(r)&&nt(s)&&Tu(r,s)?Ts(r,[s],e):t?t(r,s,i):s}return e}function Tu(t,e){let r=ht(t),s=ht(e);return $(r)===$(s)&&z(r)===z(s)}function Xu(t,e){if(!nt(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(F(t)){if(!t.remove)throw TypeError(`Cannot update immutable value without .remove() method: ${t}`);return t.remove(e)}if(!Object.hasOwn(t,e))return t;let r=me(t);if(Array.isArray(r))r.splice(e,1);else delete r[e];return r}function Hu(t,e,r){if(!nt(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(F(t)){if(!t.set)throw TypeError(`Cannot update immutable value without .set() method: ${t}`);return t.set(e,r)}if(Object.hasOwn(t,e)&&r===t[e])return t;let s=me(t);return s[e]=r,s}function Xt(t,e,r,s){if(!s)s=r,r=void 0;let i=Fn(F(t),t,Ln(e),0,r,s);return i===g?r:i}function Fn(t,e,r,s,i,n){let h=e===g;if(s===r.length){let _=h?i:e,l=n(_);return l===_?e:l}if(!h&&!nt(e))throw TypeError(`Cannot update within non-data-structure value in path [${Array.from(r).slice(0,s).map(vt)}]: ${e}`);let u=r[s],o=h?g:Wn(e,u,g),f=Fn(o===g?t:F(o),o,r,s+1,i,n);if(f===o)return e;if(f===g)return Xu(e,u);let c=h?t?B():{}:e;return Hu(c,u,f)}var Qu=(t,e)=>Xt(t,e,()=>g),Gu=(t,e,r)=>Xt(t,e,g,()=>r);function kn(t,e,r,s){return Xt(t,[e],r,s)}function ye(){return this.__ensureOwner()}function ge(){return this.__ownerID?this:this.__ensureOwner(new rr)}function Xs(){return this.__altered}function we(t){let e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Yu(t,e){return Ms(this,t,e)}function Bu(t){return Jn(this,t)}function Wt(t){return Qu(this,t)}function Hs(t,e){return Gu(this,t,e)}function Qs(t,e,r){return typeof t==="function"?t(this):kn(this,t,e,r)}function Gs(t,e,r){return Xt(this,t,e,r)}function un(){K(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}function ls(...t){return Nn(this,t)}function Vn(t,...e){if(typeof t!=="function")throw TypeError(`Invalid merger function: ${t}`);return Nn(this,e,t)}function Nn(t,e,r){let s=[];for(let i of e){let n=Y(i);if(n.size!==0)s.push(n)}if(s.length===0)return t;if(t.toSeq().size===0&&!t.__ownerID&&s.length===1)return gt(t)?t:t.create(s[0]);return t.withMutations((i)=>{let n=r?(h,u)=>{kn(i,u,g,(o)=>o===g?h:r(o,h,u))}:(h,u)=>{i.set(u,h)};for(let h of s)h.forEach(n)})}function mn(...t){return Zs(this,t)}function vn(t,...e){return Zs(this,e,t)}function Ys(t,...e){return Xt(this,t,B(),(r)=>Ts(r,e))}function Bs(t,...e){return Xt(this,t,B(),(r)=>Zs(r,e))}function dt(t,e){Object.assign(t.prototype,e)}var U=(t)=>{let e=re();if(t===void 0||t===null)return e;if(Ss(t))return t;let r=wt(t),s=r.size;if(s===0)return e;if(K(s),s>0&&s<E)return pe(0,s,S,null,new lt(r.toArray()));return e.withMutations((i)=>{i.setSize(s),r.forEach((n,h)=>i.set(h,n))})};U.of=(...t)=>U(t);class th extends at{static{dt(this,{asImmutable:ye,asMutable:ge,deleteIn:Wt,mergeDeepIn:Bs,mergeIn:Ys,setIn:Hs,update:Qs,updateIn:Gs,wasAltered:Xs,withMutations:we,removeIn:Wt,[On]:!0,[oe]:this.prototype.remove,merge:this.prototype.concat,[Symbol.toStringTag]:"Immutable.List",[Symbol.iterator]:this.prototype.values})}constructor(t,e,r,s,i,n,h){super();this.size=e-t,this._origin=t,this._capacity=e,this._level=r,this._root=s,this._tail=i,this.__ownerID=n,this.__hash=h,this.__altered=!1}create(t){return U(t)}toString(){return this.__toString("List [","]")}get(t,e){if(t=st(this,t),t>=0&&t<this.size){t+=this._origin;let r=sh(this,t);return r&&r.array[t&L]}return e}set(t,e){return Cu(this,t,e)}remove(t){return!this.has(t)?this:t===0?this.shift():t===this.size-1?this.pop():this.splice(t,1)}insert(t,e){return this.splice(t,0,e)}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=this._origin=this._capacity=0,this._level=S,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this;return re()}push(...t){let e=this.size;return this.withMutations((r)=>{rt(r,0,e+t.length);for(let s=0;s<t.length;s++)r.set(e+s,t[s])})}pop(){return rt(this,0,-1)}unshift(...t){return this.withMutations((e)=>{rt(e,-t.length);for(let r=0;r<t.length;r++)e.set(r,t[r])})}shift(){return rt(this,1)}shuffle(t=Math.random){return this.withMutations((e)=>{let r=e.size,s,i;while(r)s=Math.floor(t()*r--),i=e.get(s),e.set(s,e.get(r)),e.set(r,i)})}concat(...t){let e=[];for(let r of t){let s=wt(typeof r!=="string"&&gn(r)?r:[r]);if(s.size!==0)e.push(s)}if(e.length===0)return this;if(this.size===0&&!this.__ownerID&&e.length===1)return U(e[0]);return this.withMutations((r)=>{e.forEach((s)=>s.forEach((i)=>r.push(i)))})}setSize(t){return rt(this,0,t)}map(t,e){return this.withMutations((r)=>{for(let s=0;s<this.size;s++)r.set(s,t.call(e,r.get(s),s,this))})}slice(t,e){let r=this.size;if(fe(t,e,r))return this;return rt(this,Dt(t,r),ce(e,r))}__iterate(t,e){let r=e?this.size:0;return Pu(this,(s)=>t(s,e?--r:r++,this),e),e?this.size-r:r}__iterator(t){let e=t?this.size:0,r=on(this,t);return q((s)=>{let i=r.next();if(i.done)return!1;return s[0]=t?--e:e++,s[1]=i.value,!0})}values(){return on(this,!1)}keys(){return tr(this.size)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return re();return this.__ownerID=t,this.__altered=!1,this}return pe(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash)}}U.isList=Ss;class lt{constructor(t,e){this.array=t,this.ownerID=e}removeBefore(t,e,r){if((r&(1<<e+S)-1)===0||this.array.length===0)return this;let s=r>>>e&L;if(s>=this.array.length)return new lt([],t);let i=s===0,n;if(e>0){let u=this.array[s];if(n=u?.removeBefore(t,e-S,r),n===u&&i)return this}if(i&&!n)return this;let h=Jt(this,t);if(!i)for(let u=0;u<s;u++)h.array[u]=void 0;if(n)h.array[s]=n;return h}removeAfter(t,e,r){if(r===(e?1<<e+S:E)||this.array.length===0)return this;let s=r-1>>>e&L;if(s>=this.array.length)return this;let i;if(e>0){let h=this.array[s];if(i=h?.removeAfter(t,e-S,r),i===h&&s===this.array.length-1)return this}let n=Jt(this,t);if(n.array.splice(s+1),i)n.array[s]=i;return n}}function on(t,e){let{_origin:r,_capacity:s}=t,i=Rt(s),n=t._tail,h=[];o(t._root,t._level,0);let u={done:!1,value:void 0};return R(()=>{while(h.length>0){let f=h[h.length-1];if(f.from===f.to){h.pop();continue}let c=e?--f.to:f.from++;if(f.isLeaf)return u.value=f.array?.[c],u;let _=f.array?.[c],l=f.level-S,a=f.offset+(c<<f.level);o(_,l,a)}return I});function o(f,c,_){if(c===0){let l=_===i?n?.array:f?.array,a=_>r?0:r-_,y=s-_;if(y>E)y=E;if(a!==y)h.push({array:l,from:a,to:y,isLeaf:!0})}else{let l=f?.array,a=_>r?0:r-_>>c,y=(s-_>>c)+1;if(y>E)y=E;if(a!==y)h.push({array:l,from:a,to:y,level:c,offset:_,isLeaf:!1})}}}function Pu(t,e,r){let{_origin:s,_capacity:i}=t,n=Rt(i),h=t._tail,u=t._level,o=t._root;return u===0?eh(o,0,s,i,n,h,e,r):rh(o,u,0,s,i,n,h,e,r)}function eh(t,e,r,s,i,n,h,u){let o=e===i?n?.array:t?.array,f=e>r?0:r-e,c=s-e;if(c>E)c=E;while(f!==c){let _=u?--c:f++;if(h(o?.[_])===!1)return!1}}function rh(t,e,r,s,i,n,h,u,o){let f=t?.array,c=r>s?0:s-r>>e,_=(i-r>>e)+1;if(_>E)_=E;let l=e-S;while(c!==_){let a=o?--_:c++,y=r+(a<<e);if((l===0?eh(f?.[a],y,s,i,n,h,u,o):rh(f?.[a],l,y,s,i,n,h,u,o))===!1)return!1}}var pe=(t,e,r,s,i,n,h)=>new th(t,e,r,s,i,n,h),re=()=>pe(0,0,S);function Cu(t,e,r){if(e=st(t,e),Number.isNaN(e))return t;if(e>=t.size||e<0)return t.withMutations((h)=>{if(e<0)rt(h,e).set(0,r);else rt(h,0,e+1).set(e,r)});e+=t._origin;let{_tail:s,_root:i}=t,n=cs();if(e>=Rt(t._capacity))s=as(s,t.__ownerID,0,e,r,n);else i=as(i,t.__ownerID,t._level,e,r,n);if(!n.value)return t;if(t.__ownerID)return t._root=i,t._tail=s,t.__hash=void 0,t.__altered=!0,t;return pe(t._origin,t._capacity,t._level,i,s)}function as(t,e,r,s,i,n){let h=s>>>r&L,u=t&&h<t.array.length;if(!u&&i===void 0)return t;let o;if(r>0){let f=t&&t.array[h],c=as(f,e,r-S,s,i,n);if(c===f)return t;return o=Jt(t,e),o.array[h]=c,o}if(u&&t.array[h]===i)return t;if(n)H(n);if(o=Jt(t,e),i===void 0&&h===o.array.length-1)o.array.pop();else o.array[h]=i;return o}function Jt(t,e){if(e&&e===t?.ownerID)return t;return new lt(t?.array.slice()??[],e)}function sh(t,e){if(e>=Rt(t._capacity))return t._tail;if(e<1<<t._level+S){let{_root:r,_level:s}=t;while(r&&s>0)r=r.array[e>>>s&L],s-=S;return r}}function rt(t,e,r){if(e!==void 0)e|=0;if(r!==void 0)r|=0;let s=t.__ownerID||new rr,i=t._origin,n=t._capacity,h=i+e,u=r===void 0?n:r<0?n+r:i+r;if(h===i&&u===n)return t;if(h>=u)return t.clear();let{_level:o,_root:f}=t,c=0;while(h+c<0)f=new lt(f?.array.length?[void 0,f]:[],s),o+=S,c+=1<<o;if(c)h+=c,i+=c,u+=c,n+=c;let _=Rt(n),l=Rt(u);while(l>=1<<o+S)f=new lt(f?.array.length?[f]:[],s),o+=S;let a=t._tail,y=l<_?sh(t,u-1):l>_?new lt([],s):a;if(a&&l>_&&h<n&&a.array.length){f=Jt(f,s);let p=f;for(let d=o;d>S;d-=S){let j=_>>>d&L;p=p.array[j]=Jt(p.array[j],s)}p.array[_>>>S&L]=a}if(u<n)y=y&&y.removeAfter(s,0,u);if(h>=l)h-=l,u-=l,o=S,f=null,y=y&&y.removeBefore(s,0,h);else if(h>i||l<_){c=0;while(f){let p=h>>>o&L;if(p!==l>>>o&L)break;if(p)c+=(1<<o)*p;o-=S,f=f.array[p]}if(f&&h>i)f=f.removeBefore(s,o,h-c);if(f&&l<_)f=f.removeAfter(s,o,l-c);if(c)h-=c,u-=c}if(t.__ownerID)return t.size=u-h,t._origin=h,t._capacity=u,t._level=o,t._root=f,t._tail=y,t.__hash=void 0,t.__altered=!0,t;return pe(h,u,o,f,y)}var Rt=(t)=>t<E?0:t-1>>>S<<S,J=(t)=>t===void 0||t===null?se():sr(t)?t:se().withMutations((e)=>{let r=Y(t);K(r.size),r.forEach((s,i)=>e.set(i,s))});J.of=(...t)=>J(t);class ih extends ee{static{dt(this,{[it]:!0,[oe]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.OrderedMap",keys:b.prototype.keys,values:b.prototype.values,__iterate:b.prototype.__iterate})}constructor(t,e,r,s){super(t?t.size:0,void 0,r,s);this._map=t,this._list=e}create(t){return J(t)}toString(){return this.__toString("OrderedMap {","}")}get(t,e){let r=this._map.get(t);return r!==void 0?this._list.get(r)[1]:e}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=0,this._map.clear(),this._list.clear(),this.__altered=!0,this;return se()}set(t,e){return fn(this,t,e)}remove(t){return fn(this,t,g)}entries(){return this.__iterator(!1)}__iterator(t){let e=this._list.__iterator(t);return q((r)=>{while(!0){let s=e.next();if(s.done)return!1;let i=s.value[1];if(i)return r[0]=i[0],r[1]=i[1],!0}})}__ensureOwner(t){if(t===this.__ownerID)return this;let e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);if(!t){if(this.size===0)return se();return this.__ownerID=t,this.__altered=!1,this._map=e,this._list=r,this}return Ps(e,r,t,this.__hash)}}J.isOrderedMap=sr;var Ps=(t,e,r,s)=>new ih(t,e,r,s),se=()=>Ps(B(),re());function fn(t,e,r){let{_map:s,_list:i}=t,n=s.get(e),h=n!==void 0,u,o;if(r===g){if(!h)return t;if(i.size>=E&&i.size>=s.size*2){let f=[];if(i.forEach((c,_)=>{if(c!==void 0&&n!==_)f.push(c)}),o=re().withMutations((c)=>{for(let _=0;_<f.length;_++)c.set(_,f[_])}),u=B().withMutations((c)=>{for(let _=0;_<f.length;_++)c.set(f[_][0],_)}),t.__ownerID)u.__ownerID=o.__ownerID=t.__ownerID}else u=s.remove(e),o=n===i.size-1?i.pop():i.set(n,void 0)}else if(h){if(r===i.get(n)[1])return t;u=s,o=i.set(n,[e,r])}else{let f=i.size;u=s.set(e,f),o=i.set(f,[e,r])}if(t.__ownerID)return t.size=u.size,t._map=u,t._list=o,t.__hash=void 0,t.__altered=!0,t;return Ps(u,o)}var ie=(t)=>t===void 0||t===null?ve():Os(t)?t:ve().pushAll(t);ie.of=(...t)=>ie(t);class nh extends at{static{dt(this,{asImmutable:ye,asMutable:ge,wasAltered:Xs,withMutations:we,[qn]:!0,shift:this.prototype.pop,unshift:this.prototype.push,unshiftAll:this.prototype.pushAll,[Symbol.toStringTag]:"Immutable.Stack",[Symbol.iterator]:this.prototype.values})}constructor(t,e,r,s){super();this.size=t,this._head=e,this.__ownerID=r,this.__hash=s,this.__altered=!1}create(t){return ie(t)}toString(){return this.__toString("Stack [","]")}get(t,e){let r=this._head;t=st(this,t);while(r&&t--)r=r.next;return r?r.value:e}peek(){return this._head?.value}push(...t){if(t.length===0)return this;let e=this.size+t.length,r=this._head;for(let s=t.length-1;s>=0;s--)r={value:t[s],next:r};return os(this,e,r)}pushAll(t){if(t=wt(t),t.size===0)return this;if(this.size===0&&Os(t))return t;K(t.size);let e=this.size,r=this._head;return t.__iterate((s)=>{e++,r={value:s,next:r}},!0),os(this,e,r)}pop(){return this.slice(1)}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this;return ve()}slice(t,e){if(fe(t,e,this.size))return this;let r=Dt(t,this.size);if(ce(e,this.size)!==this.size)return at.prototype.slice.call(this,t,e);let i=this.size-r,n=this._head;while(r--)n=n.next;return os(this,i,n)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return ve();return this.__ownerID=t,this.__altered=!1,this}return Cs(this.size,this._head,t,this.__hash)}__iterate(t,e){if(e){let i=this.toArray(),n=i.length,h=0;while(h!==n)if(t(i[n-++h],n-h,this)===!1)break;return h}let r=0,s=this._head;while(s){if(t(s.value,r++,this)===!1)break;s=s.next}return r}__iterator(t){if(t){let s=this.toArray(),i=s.length,n=0;return q((h)=>{if(n===i)return!1;let u=i-++n;return h[0]=u,h[1]=s[u],!0})}let e=0,r=this._head;return q((s)=>{if(!r)return!1;return s[0]=e++,s[1]=r.value,r=r.next,!0})}values(){let t=this._head,e={done:!1,value:void 0};return R(()=>{if(!t)return I;return e.value=t.value,t=t.next,e})}keys(){return tr(this.size)}}ie.isStack=Os;function os(t,e,r){if(t.__ownerID)return t.size=e,t._head=r,t.__hash=void 0,t.__altered=!0,t;return Cs(e,r)}var Cs=(t,e,r,s)=>new nh(t,e,r,s),cn,ve=()=>cn||(cn=Cs(0)),M=(t)=>t===void 0||t===null?he():ds(t)&&!C(t)?t:he().withMutations((e)=>{let r=pt(t);K(r.size),r.forEach((s)=>e.add(s))});M.of=(...t)=>M(t);M.fromKeys=(t)=>M(Y(t).keySeq());M.intersect=(t)=>{return t=m(t).toArray(),t.length?M(t.pop()).intersect(...t):he()};M.union=(t)=>{let e=m(t).toArray();return e.length?M(e.pop()).union(...e):he()};class ne extends nr{static{dt(this,{withMutations:we,asImmutable:ye,asMutable:ge,[bn]:!0,[oe]:this.prototype.remove,merge:this.prototype.union,concat:this.prototype.union,[Symbol.toStringTag]:"Immutable.Set"})}constructor(t,e){super();this.size=t?t.size:0,this._map=t,this.__ownerID=e}create(t){return M(t)}toString(){return this.__toString("Set {","}")}has(t){return this._map.has(t)}add(t){return xe(this,this._map.set(t,t))}remove(t){return xe(this,this._map.remove(t))}clear(){return xe(this,this._map.clear())}map(t,e){let r=!1,s=xe(this,this._map.mapEntries(([,i])=>{let n=t.call(e,i,i,this);if(n!==i)r=!0;return[n,n]},e));return r?s:this}union(...t){if(t=t.filter((e)=>e.size!==0),t.length===0)return this;if(this.size===0&&!this.__ownerID&&t.length===1)return M(t[0]);return this.withMutations((e)=>{for(let r of t)if(typeof r==="string")e.add(r);else pt(r).forEach((s)=>e.add(s))})}intersect(...t){return ln(this,t,(e,r)=>!r.every((s)=>s.includes(e)))}subtract(...t){return ln(this,t,(e,r)=>r.some((s)=>s.includes(e)))}wasAltered(){return this._map.wasAltered()}__iterator(t){return this._map.__iterator(t)}__empty(){return he()}__make(t,e){return hh(t,e)}__ensureOwner(t){if(t===this.__ownerID)return this;let e=this._map.__ensureOwner(t);if(!t){if(this.size===0)return this.__empty();return this.__ownerID=t,this._map=e,this}return this.__make(e,t)}}M.isSet=ds;var hh=(t,e)=>new ne(t,e),_n,he=()=>_n||(_n=hh(B()));function ln(t,e,r){if(e.length===0)return t;return e=e.map((s)=>pt(s)),t.withMutations((s)=>{t.forEach((i)=>{if(r(i,e))s.remove(i)})})}function xe(t,e){if(t.__ownerID)return t.size=e.size,t._map=e,t;return e===t._map?t:e.size===0?t.__empty():t.__make(e)}var N=(t)=>t===void 0||t===null?ys():jn(t)?t:ys().withMutations((e)=>{let r=pt(t);K(r.size),r.forEach((s)=>e.add(s))});N.of=(...t)=>N(t);N.fromKeys=(t)=>N(Y(t).keySeq());class uh extends ne{static{dt(this,{[it]:!0,[Symbol.toStringTag]:"Immutable.OrderedSet",zip:us.zip,zipWith:us.zipWith,zipAll:us.zipAll})}create(t){return N(t)}toString(){return this.__toString("OrderedSet {","}")}__empty(){return ys()}__make(t,e){return oh(t,e)}}N.isOrderedSet=jn;var oh=(t,e)=>new uh(t,e),ys=()=>oh(se());function xu(t){if(gt(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(F(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(t===null||typeof t!=="object")throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}var ze=(t,e)=>{let r;xu(t);let s=function(h){if(h instanceof s)return h;if(!(this instanceof s))return new s(h);if(!r){r=!0;let u=Object.keys(t),o=i._indices={};i._name=e,i._keys=u,i._defaultValues=t;for(let f=0;f<u.length;f++){let c=u[f];if(o[c]=f,i[c])console.warn(`Cannot define ${xs(this)} with property "${c}" since that property name is part of the Record API.`);else ku(i,c)}}return this.__ownerID=void 0,this._values=U().withMutations((u)=>{u.setSize(this._keys.length),Y(h).forEach((o,f)=>{u.set(this._indices[f],o===this._defaultValues[f]?void 0:o)})}),this},i=s.prototype=Object.create(Fu);if(i.constructor=s,i.create=s,e)s.displayName=e;return s};class fh{static{dt(this,{asImmutable:ye,asMutable:ge,deleteIn:Wt,getIn:Yu,hasIn:Bu,merge:ls,mergeWith:Vn,mergeDeep:mn,mergeDeepWith:vn,mergeDeepIn:Bs,mergeIn:Ys,setIn:Hs,toObject:un,update:Qs,updateIn:Gs,withMutations:we,removeIn:Wt,toJSON:un,[En]:!0,[oe]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Record"})}toString(){let t=this._keys.map((e)=>`${e}: ${vt(this.get(e))}`).join(", ");return`${xs(this)} { ${t} }`}equals(t){return this===t||gt(t)&&Kt(this).equals(Kt(t))}hashCode(){return Kt(this).hashCode()}has(t){return Object.hasOwn(this._indices,t)}get(t,e){if(!this.has(t))return e;let r=this._indices[t],s=this._values.get(r);return s===void 0?this._defaultValues[t]:s}set(t,e){if(this.has(t)){let r=this._values.set(this._indices[t],e===this._defaultValues[t]?void 0:e);if(r!==this._values&&!this.__ownerID)return fs(this,r)}return this}remove(t){return this.set(t)}clear(){let t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:fs(this,t)}wasAltered(){return this._values.wasAltered()}toSeq(){return Kt(this)}toJS(){return Ne(this)}entries(){return this.__iterator()}__iterate(t,e){return Kt(this).__iterate(t,e)}__iterator(t){return Kt(this).__iterator(t)}__ensureOwner(t){if(t===this.__ownerID)return this;let e=this._values.__ensureOwner(t);if(!t)return this.__ownerID=t,this._values=e,this;return fs(this,e,t)}}ze.isRecord=gt;var xs=(t)=>t.constructor.displayName||t.constructor.name||"Record";class ch extends Zt{constructor(t){super();this._record=t,this.size=t._keys.length}get(t,e){return this._record.get(t,e)}has(t){return this._record.has(t)}__iterateUncached(t,e){let r=this._record,s=r._keys,i=s.length,n=0;while(n!==i){let h=e?i-++n:n++,u=s[h];if(t(r.get(u),u,this)===!1)break}return n}__iteratorUncached(t){let e=this._record,r=e._keys,s=r.length,i=0;return q((n)=>{if(i===s)return!1;let h=t?s-++i:i++,u=r[h];return n[0]=u,n[1]=e.get(u),!0})}}var Kt=(t)=>new ch(t);ze.getDescriptiveName=xs;var Fu=fh.prototype;function fs(t,e,r){let s=Object.create(Object.getPrototypeOf(t));return s._values=e,s.__ownerID=r,s}function ku(t,e){Object.defineProperty(t,e,{get(){return this.get(e)},set(r){mt(this.__ownerID,"Cannot set on an immutable record."),this.set(e,r)}})}var gs=(t,e,r=1)=>{if(mt(r!==0,"Cannot step a Range by 0"),mt(t!==void 0,"You must define a start value when using Range"),mt(e!==void 0,"You must define an end value when using Range"),r=Math.abs(r),e<t)r=-r;let s=Math.max(0,Math.ceil((e-t)/r-1)+1);return new Fs(t,e,r,s)};class Fs extends zt{_start;_end;_step;constructor(t,e,r,s){super();this._start=t,this._end=e,this._step=r,this.size=s}toString(){return this.size===0?"Range []":`Range [ ${this._start}...${this._end}${this._step!==1?` by ${this._step}`:""} ]`}get(t,e){return this.has(t)?this._start+st(this,t)*this._step:e}includes(t){let e=(t-this._start)/this._step;return e>=0&&e<this.size&&e===Math.floor(e)}slice(t,e){if(fe(t,e,this.size))return this;if(t=Dt(t,this.size),e=ce(e,this.size),e<=t)return gs(0,0);return gs(this.get(t,this._end),this.get(e,this._end),this._step)}indexOf(t){let e=t-this._start;if(e%this._step===0){let r=e/this._step;if(r>=0&&r<this.size)return r}return-1}lastIndexOf(t){return this.indexOf(t)}__iterateUncached(t,e=!1){let r=this.size,s=this._step,i=e?this._start+(r-1)*s:this._start,n=0;while(n!==r){let h=i;i+=e?-s:s;let u=e?r-++n:n++;if(t(h,u,this)===!1)break}return n}__iteratorUncached(t=!1){let e=this.size,r=this._step,s=t?this._start+(e-1)*r:this._start,i=0;return q((n)=>{if(i===e)return!1;let h=s;return s+=t?-r:r,n[0]=t?e-++i:i++,n[1]=h,!0})}values(){let t=this.size,e=this._step,r=this._start,s=0,i={done:!1,value:void 0};return R(()=>{if(s===t)return I;return i.value=r,r+=e,s++,i})}keys(){return tr(this.size)}equals(t){return t instanceof Fs?this._start===t._start&&this._end===t._end&&this._step===t._step:bs(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}class ws extends zt{constructor(t,e){super();this._value=t,this.size=e}toString(){if(this.size===0)return"Repeat []";return`Repeat [ ${this._value} ${this.size} times ]`}get(t,e){return this.has(t)?this._value:e}includes(t){return A(this._value,t)}slice(t,e){let r=this.size;return fe(t,e,r)?this:new ws(this._value,ce(e,r)-Dt(t,r))}reverse(){return this}indexOf(t){if(A(this._value,t))return 0;return-1}lastIndexOf(t){if(A(this._value,t))return this.size;return-1}__iterateUncached(t,e){let r=this.size,s=0;while(s!==r)if(t(this._value,e?r-++s:s++,this)===!1)break;return s}__iteratorUncached(t){let e=this.size,r=this._value,s=0;return q((i)=>{if(s===e)return!1;return i[0]=t?e-++s:s++,i[1]=r,!0})}values(){let t=this.size,e=this._value,r=0,s={done:!1,value:void 0};return R(()=>{if(r===t)return I;return r++,s.value=e,s})}keys(){return tr(this.size)}equals(t){return t instanceof ws?this.size===t.size&&A(this._value,t._value):bs(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var Fe=(t)=>z(t)?t.valueSeq():t;function Vu(){b.prototype.toMap=function(){return D(this.toKeyedSeq())},b.prototype.toOrderedMap=function(){return J(this.toKeyedSeq())},b.prototype.toOrderedSet=function(){return N(Fe(this))},b.prototype.toSet=function(){return M(Fe(this))},b.prototype.toStack=function(){return ie(Fe(this))},b.prototype.toList=function(){return U(Fe(this))},b.prototype.countBy=function(e,r){let s=D().asMutable();return this.__iterate((i,n)=>{s.update(e.call(r,i,n,this),0,(h)=>h+1)}),s.asImmutable()},b.prototype.groupBy=function(e,r){let s=z(this),i=(C(this)?J():D()).asMutable();return this.__iterate((n,h)=>{i.update(e.call(r,n,h,this),(u)=>{return u??=[],u.push(s?[h,n]:n),u})}),i.map((n)=>Dn(this,n)).asImmutable()},at.prototype.keySeq=function(){return gs(0,this.size)},ee.prototype.sort=function(e){return J(It(this,e))},ee.prototype.sortBy=function(e,r){return J(It(this,r,e))},ne.prototype.sort=function(e){return N(It(this,e))},ne.prototype.sortBy=function(e,r){return N(It(this,r,e))}}Vu();var _h=Symbol("BadValue"),gh=(t)=>t;class X{constructor(t,e,r,s,i=null){this.type=t,this.name=e,this.typeCheck=r,this.coercer=s,this.checks=[],this.defaultValue=i}toDataDef(){let{type:t,defaultValue:e}=this;return{type:t,defaultValue:e?.toJS?e.toJS():e}}getFirstFailingCheck(t){if(!this.typeCheck.isValid(t))return this.typeCheck;for(let e of this.checks)if(!e.isValid(t))return e;return null}isValid(t){return this.getFirstFailingCheck(t)===null}addCheck(t){return this.checks.push(t),this}coerceOr(t,e=null){if(this.isValid(t))return t;let r=this.coercer(t);return this.isValid(r)?r:e}coerceOrDefault(t){return this.coerceOr(t,this.defaultValue)}extendProtoForType(t,e){}extendProto(t){let{name:e}=this,r=e[0].toUpperCase()+e.slice(1),s=`set${r}`,i=this;t[s]=function(n){let h=i.coerceOr(n,_h);if(h===_h)return console.warn("invalid value",n),this;return this.set(e,h)},t[`update${r}`]=function(n){return this[s](n(this.get(e)))},t[`reset${r}`]=function(){return this.set(e,i.defaultValue)},t[`is${r}NotSet`]=function(){return this.get(e)==null},t[`is${r}Set`]=function(){return this.get(e)!=null},this.extendProtoForType(t,r)}}class Vs{isValid(t){return!0}getMessage(t){return"Invalid"}}class wh extends Vs{}var Nu=new wh;class v extends Vs{constructor(t,e){super();this._isValid=t,this._getMessage=e}isValid(t){return this._isValid(t)}getMessage(t){return this._getMessage(t)}}var mu=new v((t)=>Number.isInteger(t),()=>"Integer expected"),vu=new v((t)=>Number.isFinite(t),()=>"Float expected"),to=new v((t)=>typeof t==="boolean",()=>"Boolean expected"),eo=new v((t)=>typeof t==="string",()=>"String expected"),ro=new v((t)=>U.isList(t),()=>"List expected"),so=new v((t)=>D.isMap(t),()=>"Map expected"),io=new v((t)=>J.isOrderedMap(t),()=>"OrderedMap expected"),no=new v((t)=>M.isSet(t),()=>"Set expected"),ho=(t)=>!!t;class Ns extends X{constructor(t,e=!1){super("bool",t,to,ho,e)}extendProtoForType(t,e){let{name:r}=this;t[`toggle${e}`]=function(){return this.set(r,!this.get(r,!1))},t[`set${e}`]=function(s){return this.set(r,!!s)}}}class or extends X{constructor(t,e=null){super("any",t,Nu,gh,e)}toDataDef(){let{defaultValue:t}=this;return{type:ks(t)??"any",defaultValue:t?.toJS?t.toJS():t}}}var uo=(t)=>t?.toString?.()??"";class ms extends X{constructor(t,e=""){super("text",t,eo,uo,e)}extendProtoForType(t,e){si(t,this.name,e,"","length")}}var oo=(t)=>Number.isFinite(t)?Math.trunc(t):null;class ph extends X{constructor(t,e=0){super("int",t,mu,oo,e)}}var fo=(t)=>null;class vs extends X{constructor(t,e=0){super("float",t,vu,fo,e)}}var ks=(t)=>t?.constructor?.getMetaClass?.()?.name;class zh{constructor(t){this.typeName=t}isValid(t){return ks(t)===this.typeName}getMessage(t){let e=ks(t);return`Expected "${this.typeName}", got "${e}"`}}class Sh extends X{constructor(t,e,r){super(t,e,new zh(t),gh,null);this.args=r}toDataDef(){return{component:this.typeName,args:this.args}}}var lh=Symbol("NONE");function Ht(t,e,r){si(t,e,r,Oh),t[`setIn${r}At`]=function(s,i){return this.set(e,this.get(e).set(s,i))},t[`getIn${r}At`]=function(s,i){return this.get(e).get(s,i)},t[`updateIn${r}At`]=function(s,i){let n=this.get(e),h=n.get(s,lh);if(h!==lh)return this.set(e,n.set(s,i(h)));return console.warn("key",s,"not found in",e,n),this},dh(t,e,`${r}At`)}function dh(t,e,r){t[`deleteIn${r}`]=function(s){return this.set(e,this.get(e).delete(s))},t[`removeIn${r}`]=t[`deleteIn${r}`]}var Oh=U(),co=(t)=>Array.isArray(t)?U(t):null;class ti extends X{constructor(t,e=Oh){super("list",t,ro,co,e)}extendProtoForType(t,e){let{name:r}=this;Ht(t,r,e),t[`pushIn${e}`]=function(s){return this.set(r,this.get(r).push(s))},t[`insertIn${e}At`]=function(s,i){return this.set(r,this.get(r).insert(s,i))}}}var _o=(t)=>D(t);class ei extends X{constructor(t,e=D()){super("map",t,so,_o,e)}extendProtoForType(t,e){Ht(t,this.name,e)}}var lo=(t)=>J(t);class ri extends X{constructor(t,e=J()){super("omap",t,io,lo,e)}extendProtoForType(t,e){Ht(t,this.name,e)}}function si(t,e,r,s,i="size"){t[`is${r}Empty`]=function(){return this.get(e,s)[i]===0},t[`${e}Len`]=function(){return this.get(e,s)[i]}}var ah=M(),ao=(t)=>Array.isArray(t)?M(t):t instanceof Set?M(t):null;class ii extends X{constructor(t,e=ah){super("set",t,no,ao,e)}extendProtoForType(t,e){let{name:r}=this;si(t,r,e,ah),t[`addIn${e}`]=function(s){return this.set(r,this.get(r).add(s))},dh(t,r,e),t[`hasIn${e}`]=function(s){return this.get(r).has(s)},t[`toggleIn${e}`]=function(s){let i=this.get(r);return this.set(r,i.has(s)?i.delete(s):i.add(s))}}}function yh(t,e,r){let s=e.lookupComponent(t.type);return console.assert(s!==null,"component not found",{field:t}),s?.make({...t.args,...r},{scope:e})??null}class Mh{constructor(t){let e={},r=new Set;this.name=t,this.fields=e,this.compFields=r,this._methods={},this._statics={make:function(s={},i={}){let n={};for(let h in s){let u=e[h];if(r.has(h))n[h]=yh(u,i.scope,s[h]);else if(u===void 0){console.warn("extra argument to constructor:",t,h,s);continue}n[h]=u.coerceOrDefault(s[h])}for(let h of r)if(n[h]===void 0)n[h]=yh(e[h],i.scope,s[h]);return this(n)}}}build(){let t={},e={},{name:r,_methods:s,fields:i}=this;for(let u in i){let o=i[u];t[u]=o.defaultValue,o.extendProto(e)}let n={[r]:ze(t,r)}[r];Object.assign(n.prototype,e,s);let h={fields:i,name:r,methods:s};return Object.assign(n,this._statics,{getMetaClass:()=>h}),n}methods(t){return this._mergeProto(this._methods,t,"method")}statics(t){return this._mergeProto(this._statics,t,"static")}_mergeProto(t,e,r){for(let s in e)t[s]=e[s];return this}addField(t,e,r){let s=new r(t,e);return this.fields[t]=s,s}addCompField(t,e,r){let s=new Sh(e,t,r);return this.compFields.add(t),this.fields[t]=s,s}}var fr=new Map,yo={text:ms,int:ph,float:vs,bool:Ns,list:ti,map:ei,omap:ri,set:ii,any:or};function go(t,{fields:e={},methods:r,statics:s}){let i=new Mh(t);for(let n in e){let h=e[n],u=typeof h;if(u==="string")i.addField(n,h,ms);else if(u==="number")i.addField(n,h,vs);else if(u==="boolean")i.addField(n,h,Ns);else if(U.isList(h)||Array.isArray(h))i.addField(n,U(h),ti);else if(M.isSet(h)||h instanceof Set)i.addField(n,M(h),ii);else if(J.isOrderedMap(h))i.addField(n,h,ri);else if(h?.type&&h?.defaultValue!==void 0){let o=yo[h.type]??or;i.addField(n,new o().coerceOr(h.defaultValue),o)}else if(h?.component&&h?.args!==void 0)i.addCompField(n,h.component,h.args);else if(D.isMap(h)||h?.constructor===Object)i.addField(n,D(h),ei);else{let o=fr.get(h?.constructor)??or;i.addField(n,h,o)}}if(r)i.methods(r);if(s)i.statics(s);return i.build()}var wo=(t)=>new Br(t.name??"Comp",go(t.name,t),t.view??"Not Defined",t.views,t.style,t.commonStyle??"",t.globalStyle??"",t.computed,t.input,t.logic,t.bubble,t.response,t.alter,t.dynamic,t.on);var po=["nid","cid","eid","vid","si","sk"];class ni{constructor(t,e,r,s,i,n,h){this.comps=t,this.h=e,this.fragment=r,this.comment=s,this.renderFn=i,this.getSeqInfo=n??qo,this.cache=h??new Hr}setNullCache(){this.cache=new Xr}renderToDOM(t,e){let r=document.createElement("div");return this.renderFn(this.h("div",null,[this.renderRoot(t,e)]),r),r.childNodes[0]}renderToString(t,e,r=!0){let s=this.renderToDOM(t,e,this.renderFn);if(r){let i=s.querySelectorAll("[data-nid],[data-cid],[data-eid]");for(let{dataset:n}of i)for(let h of po)delete n[h]}return s.innerHTML}renderRoot(t,e,r=null){let s=this.comps.getCompFor(e),i=s.getView(r).anode.nodeId??null;return s?this._rValComp(t,e,s,i,"ROOT",r):null}renderIt(t,e,r,s){let i=this.comps.getCompFor(t.it);return i?this._rValComp(t,t.it,i,e,r,s):null}_rValComp(t,e,r,s,i,n){let h=`${n??t.viewsId??""}${s}-${i}`,u=this.cache.get(e,h);if(u)return u;let o=n?r.getView(n):t.lookupBestView(r.views,"main"),f=this.renderMetadata("Comp",{nid:s}),c=this.renderFragment([f,o.render(t,this)]);return this.cache.set(e,h,c),c}renderEach(t,e,r,s){let{seq:i,filter:n,loopWith:h}=e.eval(t),[u,o]=this.getSeqInfo(i),f=[],c=h.call(t.it,i);for(let[_,l]of o(i))if(n.call(t.it,_,l,c)){let a=t.enter(l,{key:_},!0),y=this.renderIt(a,r,_,s);f.push(this.renderMetadata("Each",{nid:r,[u]:_})),f.push(y)}return f}renderEachWhen(t,e,r,s){let{seq:i,filter:n,loopWith:h,enricher:u}=e.eval(t),[o,f]=this.getSeqInfo(i),c=!!u,_=[],l=h.call(t.it,i);for(let[a,y]of f(i))if(n.call(t.it,a,y,l)){let p={key:a,value:y},d=`${s}-${a}`,j;if(c)u.call(t.it,p,a,y,l),j=this.cache.get2(t.it,y,d);else j=this.cache.get(y,d);if(j){_.push(this.renderMetadata("Each",{nid:s,[o]:a})),_.push(j);continue}let bt=t.enter(y,p,!1),qt=r.render(bt,this);if(_.push(this.renderMetadata("Each",{nid:s,[o]:a})),c)this.cache.set2(t.it,y,d,qt);else this.cache.set(y,d,qt);_.push(qt)}return _}renderText(t){return t}renderMetadata(t,e){return e.$=t,this.renderComment(`§${JSON.stringify(e)}§`)}renderComment(t){return this.comment(t)}renderEmpty(t){return null}renderTag(t,e,r){return this.h(t,e,r)}renderFragment(t){return this.fragment(t)}}function*zo(t){let e=0;for(let r of t)yield[e++,r]}function*So(t){for(let[e,r]of t.toSeq().entries())yield[e,r]}var cr=new Map,Oo=["si",zo],Mo=["sk",So],bo=["si",function*(e){}];function qo(t){return $(t)?Oo:z(t)?Mo:cr.get(t?.constructor)??bo}class Ot{constructor(t=D(),e=U()){this.items=t,this.order=e,this.$=0}_clonish(t,e){return new Ot(t,e,this.$)}toJS(){return this.order.toArray().map((t)=>this.items.get(t))}set(t,e){let r=this.items.has(t)?this.order:this.order.push(t);return this._clonish(this.items.set(t,e),r,this.$)}get(t,e=null){return this.items.get(t,e)}_nextFreeKey(){let t=this.$;while(!0){let e=`§${t}§`;if(!this.items.has(e))return[e,t];t+=1}}push(t){let[e,r]=this._nextFreeKey(),s=this.set(e,t);return s.$=r,s}get size(){return this.items.size}delete(t){if(this.items.has(t)){let e=this.order.delete(this.order.indexOf(t));return this._clonish(this.items.delete(t),e)}return this}moveKeyBeforeKey(t,e){let{order:r}=this;return this.moveKeyIndexToIndex(r.indexOf(t),r.indexOf(e),0)}moveKeyAfterKey(t,e){let{order:r}=this;return this.moveKeyIndexToIndex(r.indexOf(t),r.indexOf(e),1)}moveKeyIndexToIndex(t,e,r){if(t===-1||e===-1||t===e)return this;let{order:s}=this,i=e+r,n=i<t?t+1:t,h=s.insert(i,s.get(t)).delete(n);return this._clonish(this.items,h)}}var Eo=(t)=>null;class bh{isValid(t){return t instanceof Ot}getMessage(t){return"KList expected"}}var jo=new bh;class qh extends X{constructor(t,e=new Ot){super("KList",t,jo,Eo,e)}extendProtoForType(t,e){Ht(t,this.name,e);let{name:r}=this;Ht(t,r,e),t[`pushIn${e}`]=function(s){return this.set(r,this.get(r).push(s))}}}fr.set(Ot,qh);function*$o(t){for(let e of t.order)yield[e,t.items.get(e)]}cr.set(Ot,["data-sk",$o]);var ui=(t)=>t[4]==="-"&&(t[0]==="d"||t[0]==="a"),Se=(t)=>t!==null&&typeof t==="object";function jh(t,e,r){for(let s in e){let i=e[s];if(i===void 0)Ao(t,s,r);else if(ui(s))t.setAttribute(s,i);else if(s==="dangerouslySetInnerHTML")t.innerHTML=i.__html??"";else if(Se(i))Uo(t,r,s,i);else if(s==="className")t.setAttribute("class",i);else t[s]=i}}function Ao(t,e,r){let s=r[e];if(e==="dangerouslySetInnerHTML")t.innerHTML="";else if(typeof s==="string"||ui(e)){let i=e==="className"?"class":e==="htmlFor"?"for":e;t.removeAttribute(i)}else t[e]=null}function Uo(t,e,r,s){let i=e?.[r];if(Se(i)&&Object.getPrototypeOf(i)!==Object.getPrototypeOf(s)){t[r]=s;return}let n=t[r];if(!Se(n))t[r]={},n=t[r];let h=n;for(let u in s)h[u]=s[u]}class Qt{isEqualTo(t){return this===t}toDom(t){return null}}var hi=(t)=>t instanceof Oe?t.key:void 0,Ko=(t)=>t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function";function oi(t,e){if(e==null)return;if(Ko(e))for(let r of e)oi(t,r);else if(e instanceof Qt)if(e instanceof ut)t.push(...e.childs);else t.push(e);else t.push(new ar(e))}class ar extends Qt{constructor(t){super();this.text=String(t)}get nodeType(){return 3}isEqualTo(t){return t instanceof ar&&this.text===t.text}toDom(t){return t.document.createTextNode(this.text)}}class de extends Qt{constructor(t){super();this.text=t}get nodeType(){return 8}isEqualTo(t){return t instanceof de&&this.text===t.text}toDom(t){return t.document.createComment(this.text)}}class ut extends Qt{constructor(t){super();this.childs=[],oi(this.childs,t)}get nodeType(){return 11}isEqualTo(t){if(!(t instanceof ut)||this.childs.length!==t.childs.length)return!1;for(let e=0;e<this.childs.length;e++)if(!this.childs[e].isEqualTo(t.childs[e]))return!1;return!0}toDom(t){let e=t.document.createDocumentFragment();for(let r of this.childs){let s=r.toDom(t);if(s)e.appendChild(s)}return e}}class Oe extends Qt{constructor(t,e,r,s,i){super();this.tag=t,this.attrs=e??{},this.childs=r??[],this.key=s!=null?String(s):void 0,this.namespace=typeof i==="string"?i:null}get nodeType(){return 1}isEqualTo(t){if(!(t instanceof Oe)||this.tag!==t.tag||this.key!==t.key||this.namespace!==t.namespace||this.childs.length!==t.childs.length)return!1;for(let e in this.attrs)if(this.attrs[e]!==t.attrs[e])return!1;for(let e in t.attrs)if(!Object.hasOwn(this.attrs,e))return!1;for(let e=0;e<this.childs.length;e++)if(!this.childs[e].isEqualTo(t.childs[e]))return!1;return!0}toDom(t){let e=t.document,r=this.namespace===null?e.createElement(this.tag):e.createElementNS(this.namespace,this.tag);jh(r,this.attrs,{});for(let s of this.childs){let i=s.toDom(t);if(i)r.appendChild(i)}return r}}function $h(t,e){let r=null;for(let s in t){if(!Object.hasOwn(e,s)){r??={},r[s]=void 0;continue}let i=t[s],n=e[s];if(i===n);else if(Se(i)&&Se(n))if(Object.getPrototypeOf(n)!==Object.getPrototypeOf(i))r??={},r[s]=n;else{let h=$h(i,n);if(h)r??={},r[s]=h}else r??={},r[s]=n}for(let s in e)if(!Object.hasOwn(t,s))r??={},r[s]=e[s];return r}function Io(t,e,r){let s=t.parentNode,i=e.toDom(r);if(s&&i&&i!==t)s.replaceChild(i,t);return i||t}var _r=(t,e,r)=>t instanceof r&&e instanceof r;function Ah(t,e,r,s){if(e===r||e.isEqualTo(r))return t;if(_r(e,r,ar)||_r(e,r,de))return t.data=r.text,t;if(_r(e,r,Oe)&&e.tag===r.tag&&e.namespace===r.namespace&&e.key===r.key){let i=$h(e.attrs,r.attrs);if(i)jh(t,i,e.attrs);if(!r.attrs.dangerouslySetInnerHTML)Eh(t,e.childs,r.childs,e.tag,s);return t}if(_r(e,r,ut))return Eh(t,e.childs,r.childs,null,s),t;return Io(t,r,s)}function Eh(t,e,r,s,i){if(e.length===0){for(let f of r){let c=f.toDom(i);if(c)t.appendChild(c)}return}if(r.length===0){while(t.firstChild)t.removeChild(t.firstChild);return}let n=Array.from(t.childNodes),h={};for(let f=0;f<e.length;f++){let c=hi(e[f]);if(c!=null)h[c]=f}let u=new Uint8Array(e.length),o=0;for(let f=0;f<r.length;f++){let c=r[f],_=hi(c),l=-1;if(_!=null){if(_ in h&&!u[h[_]])l=h[_]}else while(o<e.length){if(!u[o]&&hi(e[o])==null){l=o++;break}o++}if(l>=0){u[l]=1;let a=n[l],y=Ah(a,e[l],c,i),p=t.childNodes[f]??null;if(y!==p)t.insertBefore(y,p)}else{let a=c.toDom(i);if(a){let y=t.childNodes[f]??null;t.insertBefore(a,y)}}}for(let f=e.length-1;f>=0;f--)if(!u[f]&&n[f].parentNode===t)t.removeChild(n[f])}var lr=new WeakMap;function Uh(t,e,r){let s=lr.get(e),i=t instanceof ut;if(s){let h=s.vnode instanceof ut;if(h===i){let u=h?e:s.dom,o=Ah(u,s.vnode,t,r),f=i?e:o;return lr.set(e,{vnode:t,dom:f}),o}lr.delete(e)}let n=t.toDom(r);if(n){e.innerHTML="",e.appendChild(n);let h=i?e:n;lr.set(e,{vnode:t,dom:h})}return n}function Kh(t,e,r){let s=t.toUpperCase(),i={},n,h;if(e)for(let o in e){let f=e[o];switch(o){case"key":n=f;break;case"namespace":h=f;break;case"class":i.className=f;break;case"for":i.htmlFor=f;break;default:i[o]=ui(o)?String(f):f}}let u=[];return oi(u,r),new Oe(s,i,u,n,h)}var{raw:xf,raw:Ff}=String;function kf(t,e){return new Wr(t,e)}var Lo=(t)=>typeof t==="string"?document.querySelector(t):t;function Vf(t){let e=Lo(t),r=new Qe,s=(o)=>new ut(o),i=(o)=>new de(o),n={document},h=(o,f)=>Uh(o,f,n),u=new ni(r,Kh,s,i,h);return new es(e,h,r,u,V)}async function nc(t,e,r="margaui-css"){let s=performance.now(),i=await Wo(t,e),n=performance.now();return Ye(r,i),n-s}async function Wo(t,e,r){t.ParseContext=Be,t.compile();let s=new Set(r??[]);for(let i of t.comps.byId.values())for(let n in i.views){let h=i.views[n];for(let u of h.ctx.classes)s.add(u)}return await e(Array.from(s))}var Jo="RENDER_IT_OUTSIDE_OF_LOOP",Ro="UNKNOWN_EVENT_MODIFIER",Do="UNKNOWN_HANDLER_ARG_NAME",Zo="INPUT_HANDLER_NOT_IMPLEMENTED",To="INPUT_HANDLER_METHOD_NOT_IMPLEMENTED",Xo="INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD",Ho="INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER",Qo="FIELD_VAL_NOT_DEFINED",Go="COMPUTED_VAL_NOT_DEFINED",Yo="UNKNOWN_REQUEST_NAME",Bo="UNKNOWN_COMPONENT_NAME",Po="warn",Ih="error",Co="hint";function lc(t,e=new Lh){vo(e,t),tf(e,t);for(let r in t.views)xo(e,t.views[r],t);return e}function xo(t,e,r){Fo(t,e),Vo(t,e),mo(t,e,r)}function Fo(t,e){let{nodes:r}=e.ctx;for(let s=0;s<r.length;s++){let i=r[s];if(i instanceof De){let n=r[s+1];if(!(n instanceof Te||n instanceof Vt))t.error(Jo,{node:i})}}}var ko={};function Vo(t,e){for(let r of e.ctx.events)for(let s of r.handlers){let{name:i,modifiers:n}=s,h=Tr[i]??ko;for(let u of n)if(h[u]===void 0)t.warn(Ro,{name:i,modifier:u,handler:s,event:r})}}function No(t){switch(t){case"value":case"valueAsInt":case"valueAsFloat":case"target":case"event":case"isAlt":case"isShift":case"isCtrl":case"isCmd":case"key":case"keyCode":case"isUpKey":case"isDownKey":case"isSend":case"isCancel":case"isTabKey":case"ctx":case"dragInfo":return!0;default:return!1}}function mo(t,e,r){let{computed:s,scope:i,Class:n}=r,{prototype:h}=n,{fields:u}=n.getMetaClass();for(let o of e.ctx.events)for(let f of o.handlers){let{args:c}=f.handlerCall;for(let _=0;_<c.length;_++){let l=c[_];Mt(t,l,u,h,s,i)}}}function vo(t,e){let{input:r,views:s,Class:i}=e,{prototype:n}=i;for(let h in s){let u=s[h];for(let o of u.ctx.events)for(let f of o.handlers){let{handlerVal:c}=f.handlerCall;if(c instanceof Ee){if(r[c.name]===void 0){if(t.warn(Zo,{name:c.name,handler:f,event:o}),n[c.name]!==void 0)t.hint(Ho,{name:c.name,handler:f,event:o})}}else if(c instanceof Bt){if(n[c.name]===void 0){if(t.warn(To,{name:c.name,handler:f,event:o}),r[c.name]!==void 0)t.hint(Xo,{name:c.name,handler:f,event:o})}}}}}function Mt(t,e,r,s,i,n){if(e instanceof Ae||e instanceof Bt){let{name:h}=e;if(r[h]===void 0&&s[h]===void 0)t.error(Qo,{val:e,name:h})}else if(e instanceof Ue){let{name:h}=e;if(i[h]===void 0)t.error(Go,{val:e,name:h})}else if(e instanceof Ke)Mt(t,e.seqVal,r,s,i,n),Mt(t,e.keyVal,r,s,i,n);else if(e instanceof $e){if(n.lookupRequest(e.name)===null)t.warn(Yo,{name:e.name})}else if(e instanceof je){if(n.lookupComponent(e.name)===null)t.warn(Bo,{name:e.name})}else if(e instanceof k&&!No(e.name))t.warn(Do,{name:e.name});else if(!(e instanceof W))console.log(e)}function tf(t,e){let{computed:r,scope:s,views:i,Class:n}=e,{prototype:h}=n,{fields:u}=n.getMetaClass();for(let o in i){let f=i[o];for(let c of f.ctx.attrs){let{attrs:_,wrapperAttrs:l,textChild:a}=c;if(_ instanceof Le){for(let y of _.items)if(y instanceof $t)Mt(t,y.value,u,h,r,s)}if(l!==null)for(let{val:y}of l)Mt(t,y,u,h,r,s);if(a)Mt(t,a,u,h,r,s)}for(let c of f.ctx.nodes)if(c.val)Mt(t,c.val,u,h,r,s)}}class Lh{constructor(){this.reports=[]}error(t,e){this.report(t,e,Ih)}warn(t,e){this.report(t,e,Po)}hint(t,e){this.report(t,e,Co)}report(t,e={},r=Ih){this.reports.push({id:t,info:e,level:r})}}class ef extends V{constructor(t,e,r){super(t,e,r);this.attrs=[]}onAttributes(t,e,r){this.attrs.push({attrs:t,wrapperAttrs:e,textChild:r})}}export{Vf as tutuca,cr as seqInfoByClass,kf as macro,sr as isOrderedMap,sr as isOMap,le as isMap,Ss as isList,z as isKeyed,$ as isIndexed,le as isIMap,Ye as injectCss,Ff as html,fr as fieldsByClass,xf as css,wo as component,Wo as compileClassesToStyleText,nc as compileClassesToStyle,xo as checkView,lc as checkComponent,Yo as UNKNOWN_REQUEST_NAME,Do as UNKNOWN_HANDLER_ARG_NAME,Ro as UNKNOWN_EVENT_MODIFIER,Bo as UNKNOWN_COMPONENT_NAME,ze as Record,Jo as RENDER_IT_OUTSIDE_OF_LOOP,V as ParseContext,J as OMap,U as List,ef as LintParseContext,Lh as LintContext,Po as LEVEL_WARN,Co as LEVEL_HINT,Ih as LEVEL_ERROR,Ot as KList,M as ISet,Zo as INPUT_HANDLER_NOT_IMPLEMENTED,To as INPUT_HANDLER_METHOD_NOT_IMPLEMENTED,Ho as INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER,Xo as INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD,D as IMap,Qo as FIELD_VAL_NOT_DEFINED,Go as COMPUTED_VAL_NOT_DEFINED};
1
+ class Gt{lookup(t,e=null){return e}setValue(t,e){return t}updateBindings(t,e){}isFrame=!0}class Et extends Gt{constructor(t){super();this.binds=t}lookup(t,e){return t}setValue(t,e){return e}withIndex(t){return new Et({...this.binds,key:t})}withKey(t){return new Et({...this.binds,key:t})}updateBindings(t,e){Object.assign(e,this.binds)}isFrame=!1}class Me extends Gt{constructor(t){super();this.field=t}lookup(t,e=null){return t?.get?t.get(this.field,e):e}setValue(t,e){return t.set(this.field,e)}withIndex(t){return new zr(this.field,t)}withKey(t){return new pr(this.field,t)}}class wr extends Gt{constructor(t,e){super();this.field=t,this.key=e}lookup(t,e=null){let r=t?.get(this.field,null);return r?.get?r.get(this.key,e):e}setValue(t,e){return t.set(this.field,t.get(this.field).set(this.key,e))}updateBindings(t,e){e.key=this.key}}class pr extends wr{}class zr extends wr{}var Z=Symbol("NONE");class Sr extends Gt{constructor(t,e){super();this.seqField=t,this.keyField=e}lookup(t,e=null){let r=t?.get(this.seqField,Z),s=t?.get(this.keyField,Z);return s!==Z&&r?.get?r.get(s,e):e}setValue(t,e){let r=t?.get(this.seqField,Z),s=t?.get(this.keyField,Z);return r===Z||s===Z?t:t.set(this.seqField,r.set(s,e))}updateBindings(t,e){e.key=t?.get(this.keyField,null)}}class et{constructor(t=[]){this.steps=t}concat(t){return new et(this.steps.concat(t))}popStep(){return new et(this.steps.slice(0,-1))}lookup(t,e=null){let r=t;for(let s of this.steps)if(r=s.lookup(r,Z),r===Z)return e;return r}setValue(t,e){let r=Array(this.steps.length),s=t;for(let n=0;n<this.steps.length;n++)if(r[n]=s,s=this.steps[n].lookup(s,Z),s===Z)return t;let i=e;for(let n=this.steps.length-1;n>=0;n--)i=this.steps[n].setValue(r[n],i),r[n]=i;return i}buildStack(t){let e=t.it,r=e;for(let s of this.steps){if(r=s.lookup(r,Z),r===Z)return console.warn("bad PathItem",{root:e,curVal:r,step:s,path:this}),null;s.updateBindings(r,t.binds.head.bindings),t=t.enter(r,{},s.isFrame)}return t}static fromNodeAndEventName(t,e,r,s,i,n=!0){let h=[],u=0,o=[],f=null,c=[],_=!0;while(t&&t!==r&&u<s){if(t?.dataset){let{nid:l,si:a,sk:y}=_i(t.previousSibling),{eid:p,cid:d,vid:j}=t.dataset;if(p!==void 0)o.push(p);if(d!==void 0){let bt=i.getComponentForId(+d,j);if(_){if(f=Dh(bt,o,j,e),f===null&&n)return Zh;_=!1}let qt=Rh(bt,c,j);if(qt)h.push(qt);o=[],c=[]}if(l!==void 0)c.push({nid:l,si:a,sk:y})}u+=1,t=t.parentNode}return[new et(h.reverse()),f]}static fromEvent(t,e,r,s,i=!0){let{type:n,target:h}=t;return et.fromNodeAndEventName(h,n,e,r,s,i)}}var ci={};function _i(t){if(t?.nodeType===8&&t.textContent[0]==="§"){let e=_i(t.previousSibling);if(e!==ci)return e;try{return JSON.parse(t.textContent.slice(1,-1))}catch(r){console.warn(r,t)}}return ci}function Dh(t,e,r,s){for(let i of e){let n=t.getEventForId(+i,r).getHandlersFor(s);if(n!==null)return n}return null}function Rh(t,e,r){for(let s=0;s<e.length;s++){let i=t.getNodeForId(+e[s].nid,r),n=i.pathInNext?s+1:s,{si:h,sk:u,nid:o}=e[n],f=i.pathInNext?t.getNodeForId(+o,r).val.toPathItem():i.toPathItem();if(f!==null)return h!==void 0?f.withIndex(+h):u?f.withKey(u):f}return null}var Zh=[null,null];class dr{constructor(){this.pathChanges=[]}add(t){return this.pathChanges.push(t),this}field(t){return this.add(new Me(t))}index(t,e){return this.add(new zr(t,e))}key(t,e){return this.add(new pr(t,e))}}var Th=/^[a-zA-Z][a-zA-Z0-9_]*$/,ot=(t)=>Th.test(t),Xh=/^-?[0-9]+(\.[0-9]+)?$/,li=(t,e)=>Mr.parse(t,e),Yt=(t,e)=>new W(t),Hh=(t,e)=>ot(t)?new k(t):null,Qh=(t,e)=>ot(t)?new je(t):null,Gh=(t,e)=>ot(t)?new qr(t):null,Yh=(t,e)=>ot(t)?new wi(t):null,Bh=(t,e)=>ot(t)?new Ae(t):null,Ph=(t,e)=>ot(t)?new Ue(t):null,Ch=(t,e)=>ot(t)?new $e(t):null;class ai{constructor(){this.allowFieldOnly(),this.bindValIt=new qr("it"),this.nullConstVal=new W(null)}const(t){return new W(t)}allowFieldOnly(){this.okField=!0,this.okBind=!1,this.okComputed=!1,this.okDyn=!1,this.okType=!1,this.okRequest=!1,this.okName=!1,this.okConst=!1,this.okStrTpl=!1,this.okSeqAccess=!1}parseIfOk(t,e,r,s){return r?s(t,e):null}_parseSeqAccess(t,e){if(!this.okSeqAccess)return null;let r=t.indexOf("[");this.allowFieldOnly();let s=this.parse(t.slice(0,r),e),i=this.parse(t.slice(r+1,-1),e);return s&&i?new Ke(s,i):null}parse(t,e){switch(xh(t)){case pi:return this.parseIfOk(t,e,this.okStrTpl,li);case Si:return this.parseIfOk(t,e,this.okStrTpl,Yt);case zi:return this._parseSeqAccess(t,e);case be:return this.parseIfOk(t,e,this.okStrTpl,li)}let r=t.charCodeAt(0);switch(r){case 94:{let i=e.frame.macroVars?.[t.slice(1)];if(i!==void 0)return this.parse(i,e);return null}case 126:return this.parseIfOk(t.slice(1),e,this.okStrTpl,Yt);case 39:return this.parseIfOk(t.slice(1,-1),e,this.okStrTpl,Yt);case 64:return this.parseIfOk(t.slice(1),e,this.okBind,Gh);case 42:return this.parseIfOk(t.slice(1),e,this.okDyn,Yh);case 46:return this.parseIfOk(t.slice(1),e,this.okField,Bh);case 36:return this.parseIfOk(t.slice(1),e,this.okComputed,Ph);case 33:return this.parseIfOk(t.slice(1),e,this.okRequest,Ch)}let s=Xh.test(t)?parseFloat(t):null;if(Number.isFinite(s))return this.parseIfOk(s,e,this.okConst,Yt);else if(t==="true"||t==="false")return this.parseIfOk(t==="true",e,this.okConst,Yt);else if(r>=97&&r<=122)return this.parseIfOk(t,e,this.okName,Hh);else if(r>=65&&r<=90)return this.parseIfOk(t,e,this.okType,Qh);return null}parseDynamic(t,e){return this.allowFieldOnly(),this.okComputed=!0,this.parse(t,e)}parseEach(t,e){return this.allowFieldOnly(),this.okComputed=!0,this.okDyn=!0,this.parse(t,e)}allowHandlerArg(){this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okType=!0,this.okRequest=!0,this.okName=!0,this.okConst=!0}parseHandlerArg(t,e){return this.allowHandlerArg(),this.parse(t,e)}_parseHandler(t,e,r){this.allowFieldOnly(),this.okName=!0;let s=this.parse(t,e);return s&&(s.toRawFieldVal?s.toRawFieldVal():new r(s.name))}parseHandlerName(t,e){return this._parseHandler(t,e,Ee)}parseAlter(t,e){return this._parseHandler(t,e,yi)}parseAttr(t,e){return this.parseText(t,e)}parseAll(t,e){return this.allowHandlerArg(),this.okStrTpl=!0,this.okSeqAccess=!0,this.parse(t,e)}parseCondValue(t,e){return this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okConst=!0,this.parse(t,e)}parseText(t,e){return this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okConst=!0,this.okStrTpl=!0,this.parse(t,e)}parseRender(t,e){return this.allowFieldOnly(),this.okSeqAccess=!0,this.parse(t,e)}}class qe{render(t,e){}eval(t){}toPathItem(){return null}}class W extends qe{constructor(t){super();this.value=t}render(t,e){return this.value}eval(t){return this.value}toString(){let t=this.value;return typeof t==="string"?`'${t}'`:`${t}`}}class Or extends qe{}class Mr extends Or{constructor(t){super();this.vals=t}render(t,e){return this.eval(t)}eval(t){let e=Array(this.vals.length);for(let r=0;r<this.vals.length;r++)e[r]=this.vals[r]?.eval(t,"");return e.join("")}static parse(t,e){let r=t.split(/(\{[^}]+\})/g),s=Array(r.length),i=!0;for(let n=0;n<r.length;n++){let h=r[n],o=h[0]==="{"&&h.at(-1)==="}"?w.parseText(h.slice(1,-1),e):new W(h);s[n]=o,i&&=o instanceof W}return i?new W(s.map((n)=>n.value).join("")):new Mr(s)}}class k extends Or{constructor(t){super();this.name=t}eval(t){return t.lookupName(this.name)}toString(){return this.name}}class Ee extends k{eval(t){return t.getInputHandler(this.name)??gi("input",this.name)}}class yi extends k{eval(t){return t.getAlterHandler(this.name)??gi("alter",this.name)}}var gi=(t,e)=>function(...r){return console.warn("handler not found",{type:t,name:e,args:r},this),this};class je extends k{eval(t){return t.lookupType(this.name)}}class $e extends k{eval(t){return t.lookupRequest(this.name)}toString(){return`!${this.name}`}}class Bt extends k{eval(t){return t.lookupFieldRaw(this.name)}toString(){return`.${this.name}`}}class br extends qe{render(t,e){return this.eval(t)}}class Pt extends br{constructor(t){super();this.name=t}}class qr extends Pt{eval(t){return t.lookupBind(this.name)}toString(){return`@${this.name}`}}class wi extends Pt{eval(t){return t.lookupDynamic(this.name)}toPathItem(){return null}toString(){return`*${this.name}`}}class Ae extends Pt{eval(t){return t.lookupField(this.name)}toPathItem(){return new Me(this.name)}toRawFieldVal(){return new Bt(this.name)}toString(){return`.${this.name}`}}class Ue extends Pt{eval(t){return t.lookupComputed(this.name)}toString(){return`$${this.name}`}}class Ke extends br{constructor(t,e){super();this.seqVal=t,this.keyVal=e}toPathItem(){return new Sr(this.seqVal.name,this.keyVal.name)}eval(t){let e=this.keyVal.eval(t);return this.seqVal.eval(t).get(e,null)}toString(){return`${this.seqVal}[${this.keyVal}]`}}var pi=0,zi=1,be=2,Si=3;function xh(t){let e=0,r=0;for(let s=0;s<t.length;s++)switch(t.charCodeAt(s)){case 91:if(e>0)return be;e+=1;break;case 93:if(r>0||e===0)return be;r+=1;break;case 123:return pi;case 125:return Si}if(e>0||r>0)return e===1&&r===1?zi:be;return-1}var w=new ai;class jt{constructor(t){this.items=t}eval(t){return{}}static parse(t,e,r=!1){return Ar(e).parse(t,r)}isConstant(){return!1}}var Fh="itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected",kh=new Set(Fh.split(","));class di{constructor(t){this.clear(t)}clear(t){this.px=t,this.attrs=null,this.hasDynamic=!1,this.wrapperAttrs=null,this.textChild=null,this.eachAttr=null,this.ifAttr=null,this.events=null}parseAttr(t,e,r=!1){let s=r?w.parseAll(e,this.px):w.parseAttr(e,this.px);if(s!==null)this.attrs??=[],this.attrs.push(new $t(t,s)),this.hasDynamic||=!(s instanceof W)}pushWrapper(t,e,r){let s={name:t,val:r,raw:e};return this.wrapperAttrs??=[],this.wrapperAttrs.push(s),s}parseIf(t,e){let r=w.parseCondValue(e,this.px);if(r)this.ifAttr=new Mi(t.slice(3),r),this.attrs??=[],this.attrs.push(this.ifAttr),this.hasDynamic=!0}parseThen(t){if(this.ifAttr)this.ifAttr.thenVal=w.parseAttr(t,this.px)??Ct}parseElse(t){if(this.ifAttr)this.ifAttr.elseVal=w.parseAttr(t,this.px)??Ct}parseEvent(t,e){let[r,...s]=t.slice(3).split("+"),i=Ur.parse(e,this.px);if(i){if(this.events===null)this.events=this.px.registerEvents(),this.attrs??=[],this.attrs.push(new Ie("data-eid",w.const(this.events.id)));this.events.add(r,i,s)}}parseDirective(t,e){switch(e){case"dangerouslysetinnerhtml":this.attrs??=[],this.attrs.push(new Oi(w.parseText(t,this.px))),this.hasDynamic=!0;return;case"slot":this.pushWrapper("slot",t,w.const(t));return;case"push-view":this.pushWrapper("push-view",t,w.parseText(t,this.px));return;case"text":this.textChild=w.parseText(t,this.px);return;case"show":this.pushWrapper("show",t,w.parseCondValue(t,this.px));return;case"hide":this.pushWrapper("hide",t,w.parseCondValue(t,this.px));return;case"each":this.eachAttr=this.pushWrapper("each",t,w.parseEach(t,this.px));return;case"enrich-with":if(this.eachAttr!==null)this.eachAttr.enrichWithVal=w.parseAlter(t,this.px);else this.pushWrapper("scope",t,w.parseAlter(t,this.px));return;case"when":this._parseWhen(t);return;case"loop-with":this._parseLoopWith(t);return;case"then":this.parseThen(t);return;case"else":this.parseElse(t);return}if(e.startsWith("on."))this.parseEvent(e,t);else if(e.startsWith("if."))this.parseIf(e,t);else if(e.startsWith("then."))this.parseThen(t);else if(e.startsWith("else."))this.parseElse(t)}_parseWhen(t){if(this.eachAttr!==null)this.eachAttr.whenVal=w.parseAlter(t,this.px)}_parseLoopWith(t){if(this.eachAttr!==null)this.eachAttr.loopWithVal=w.parseAlter(t,this.px)}parse(t,e=!1){for(let{name:n,value:h}of t){let u=n.charCodeAt(0);if(u===58)this.parseAttr(n===":viewbox"?"viewBox":n.slice(1),h,e);else if(u===64)this.parseDirective(h,n.slice(1));else{this.attrs??=[];let o=h===""&&kh.has(n)?!0:h;this.attrs.push(new Ie(n,w.const(o)))}}let{attrs:r,hasDynamic:s}=this;return[s?new Le(r):jr.fromAttrs(r??[]),this.wrapperAttrs,this.textChild]}}class jr extends jt{eval(t){return this.items}static fromAttrs(t){let e={};for(let r of t)e[r.name]=r.value.eval(null);return new jr(e)}setDataAttr(t,e){this.items[t]=e}toMacroVars(){let t={};for(let e in this.items)t[e]=`'${this.items[e]}'`;return t}isConstant(){return!0}}class Le extends jt{eval(t){let e={};for(let r of this.items)e[r.name]=r.eval(t);return e}setDataAttr(t,e){this.items.push(new Ie(t,new W(e)))}toMacroVars(){let t={};for(let e of this.items)t[e.name]=e.value.toString();return t}}class $r{constructor(t){this.name=t}}class $t extends $r{constructor(t,e){super(t);this.value=e}eval(t){return this.value.eval(t)}}class Ie extends $t{}class Oi extends $t{constructor(t){super("dangerouslySetInnerHTML",t??w.nullConstVal)}eval(t){return{__html:`${this.value.eval(t)}`}}}var Ct=w.nullConstVal;class Mi extends $r{constructor(t,e){super(t);this.condVal=e,this.thenVal=this.elseVal=Ct}get anyBranchIsSet(){return this.thenVal!==Ct||this.elseVal!==Ct}eval(t){return this.condVal.eval(t)?this.thenVal.eval(t):this.elseVal.eval(t)}}var Er=null;function Ar(t){return Er??=new di(t),Er.clear(t),Er}class Ur{constructor(t,e=[]){this.handlerVal=t,this.args=e}getHandlerAndArgs(t,e){let r=Array(this.args.length);for(let s=0;s<r.length;s++)r[s]=this.args[s].eval(t);return[this.handlerVal.eval(t),r]}static parse(t,e){let[r,...s]=t.trim().split(/\s+/),i=w.parseHandlerName(r,e);if(i===null)return null;let n=Array(s.length);w.allowHandlerArg();for(let h=0;h<s.length;h++){let u=w.parse(s[h],e);n[h]=u!==null?u:w.nullConstVal}return new Ur(i,n)}}class Kr{constructor(t,e){this.name=t,this.fn=e}toHandlerArg(t){let e=(...r)=>t.request(this.name,r);return e.withOpts=(...r)=>t.request(this.name,r.slice(0,-1),r.at(-1)),e}}class At{render(t,e){return e.renderEmpty()}setDataAttr(t,e){console.warn("setDataAttr not implemented for",this,{key:t,val:e})}isConstant(){return!1}optimize(){}}class kt extends At{constructor(t){super();this.v=t}render(t,e){return e.renderText(this.v)}isWhiteSpace(){for(let t=0;t<this.v.length;t++){let e=this.v.charCodeAt(t);if(!(e===32||e===10||e===9||e===13))return!1}return!0}hasNewLine(){for(let t=0;t<this.v.length;t++){let e=this.v.charCodeAt(t);if(e===10||e===13)return!0}return!1}condenseWhiteSpace(){this.v=""}isConstant(){return!0}setDataAttr(t,e){}}class Ft extends kt{render(t,e){return e.renderComment(this.v)}}function Vh(t){for(let e=0;e<t.length;e++){let r=t[e];if(r.isConstant())t[e]=new Rr(r);else r.optimize()}}function Wr(t){if(t.isConstant())return new Rr(t);return t.optimize(),t}class Jr extends At{constructor(t){super();this.childs=t}isConstant(){return this.childs.every((t)=>t.isConstant())}optimize(){Vh(this.childs)}}class We extends Jr{constructor(t,e,r){super(r);this.tagName=t,this.attrs=e}render(t,e){let r=Array(this.childs.length);for(let s=0;s<r.length;s++)r[s]=this.childs[s]?.render?.(t,e)??null;return e.renderTag(this.tagName,this.attrs.eval(t),r)}setDataAttr(t,e){this.attrs.setDataAttr(t,e)}isConstant(){return this.attrs.isConstant()&&super.isConstant()}}class Je extends Jr{render(t,e){return e.renderFragment(this.childs.map((r)=>r?.render(t,e)))}setDataAttr(t,e){for(let r of this.childs)r.setDataAttr(t,e)}}var xt=(t)=>t.length===1?t[0]:new Je(t),Nh=/^[a-zA-Z][a-zA-Z0-9-]*$/,bi=null;class rt extends At{constructor(t,e){super();this.nodeId=t,this.val=e}toPathItem(){return this.val.toPathItem()}static parse(t,e){bi??=e.newDOMParser();let r=bi.parseFromString(t,"text/html").body.childNodes;return rt.fromDOM(r[0]??new e.Text(""),e)}static fromDOM(t,e){if(e.isTextNode(t))return new kt(t.textContent);else if(e.isCommentNode(t))return new Ft(t.textContent);let{childNodes:r,attributes:s,tagName:i}=t,n=Array(r.length);for(let h=0;h<r.length;h++)n[h]=rt.fromDOM(r[h],e);if(i==="X"){if(s.length===0)return xt(n);let{name:h,value:u}=s[0],o=s.getNamedItem("as")?.value??null;switch(h){case"slot":return new Ze(null,w.const(u),xt(n));case"text":{let f=w.parseText(u,e);return f!==null?new Lr(null,f):null}case"render":return e.addNodeIf(Ki,w.parseRender(u,e),o);case"render-it":return e.addNodeIf(Re,w.bindValIt,o);case"render-each":return Vt.parse(e,w,u,o,s);case"show":return e.addNodeIf(Zr,w.parseCondValue(u,e),xt(n));case"hide":return e.addNodeIf(Tr,w.parseCondValue(u,e),xt(n))}return new Ft(`Error: InvalidSpecialTagOp ${h}=${u}`)}else if(i.charCodeAt(1)===58&&i.charCodeAt(0)===88){let h=i.slice(2).toLowerCase();if(h==="slot"){let f=s.getNamedItem("name")?.value??"_";return e.frame.macroSlots[f]??xt(n)}let[u,o]=jt.parse(s,e,!0);return e.onAttributes(u,o,null),qi(e.newMacroNode(h,u.toMacroVars(),n),e,o)}else if(Nh.test(i)){let[h,u,o]=jt.parse(s,e);if(e.onAttributes(h,u,o),o)n.unshift(new Lr(null,o));let f=i!=="PRE"?ru(n):n;return qi(new We(i.toLowerCase(),h,f),e,u)}return new Ft(`Error: InvalidTagName ${i}`)}}function qi(t,e,r){if(r)for(let s=r.length-1;s>=0;s--){let i=mh(r[s],e);if(i)i.wrapNode(t),t=i}return t}function mh(t,e){let r=eu[t.name],s=r.register?e.addNodeIf(r,t.val):t.val&&new r(null,t.val);if(s!==null&&t.name==="each")s.iterInfo.enrichWithVal=t.enrichWithVal??null,s.iterInfo.whenVal=t.whenVal??null,s.iterInfo.loopWithVal=t.loopWithVal??null;return s}class Ui extends At{constructor(t,e,r,s){super();this.name=t,this.attrs=e,this.slots=r,this.px=s,this.node=null,this.dataAttrs={}}compile(t){let{name:e,attrs:r,slots:s}=this;if(this.px.isInsideMacro(e))throw Error(`Recursive macro expansion: ${e}`);let i=t.lookupMacro(e);if(i===null)this.node=new Ft(`bad macro: ${e}`);else{let n={...i.defaults,...r};this.node=i.expand(this.px.enterMacro(e,n,s));for(let h in this.dataAttrs)this.node.setDataAttr(h,this.dataAttrs[h])}}render(t,e){return this.node.render(t,e)}setDataAttr(t,e){this.dataAttrs[t]=e}isConstant(){return this.node.isConstant()}optimize(){this.node=Wr(this.node)}}class Dr{constructor(t,e){this.defaults=t,this.rawView=e}expand(t){return rt.parse(this.rawView,t)}}class De extends rt{constructor(t,e,r){super(t,e);this.viewId=r}}class Ki extends De{render(t,e){let r=t.enter(this.val.eval(t),{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}}class Re extends De{render(t,e){return e.renderIt(t,this.nodeId,"",this.viewId)}pathInNext=!0}class Vt extends De{constructor(t,e,r){super(t,e,r);this.iterInfo=new Xr(e,null,null,null)}render(t,e){return e.renderEach(t,this.iterInfo,this.nodeId,this.viewId)}static parse(t,e,r,s,i){let n=t.addNodeIf(Vt,e.parseEach(r,t),s);if(n!==null){let h=Ar(t);h.eachAttr=h.pushWrapper("each",r,n.val);let u=i.getNamedItem("when");u&&h._parseWhen(u.value);let o=i.getNamedItem("loop-with");o&&h._parseLoopWith(o.value),n.iterInfo.whenVal=h.eachAttr.whenVal??null,n.iterInfo.loopWithVal=h.eachAttr.loopWithVal??null}return n}}class Lr extends rt{render(t,e){return e.renderText(this.val.eval(t))}}class Rr extends At{constructor(t){super();this.node=t,this._render=(e,r)=>{let s=t.render(e,r);return this._render=(i,n)=>s,s}}render(t,e){return this._render(t,e)}}class ft extends rt{constructor(t,e,r=null){super(t,e);this.node=r}wrapNode(t){this.node=t}setDataAttr(t,e){this.node.setDataAttr(t,e)}optimize(){this.node=Wr(this.node)}static register=!1}class Zr extends ft{render(t,e){return this.val.eval(t)?this.node.render(t,e):e.renderEmpty()}}class Tr extends ft{render(t,e){return this.val.eval(t)?e.renderEmpty():this.node.render(t,e)}}class Ii extends ft{render(t,e){return this.node.render(t.pushViewName(this.val.eval(t)),e)}}class Ze extends ft{optimize(){this.node.optimize()}}class Li extends ft{render(t,e){let r=this.val.eval(t)?.call(t.it)??{};return this.node.render(t.enter(t.it,r,!1),e)}toPathItem(){return new Et({})}wrapNode(t){this.node=t,this.node.setDataAttr("data-nid",this.nodeId)}static register=!0}class Te extends ft{constructor(t,e){super(t,e);this.iterInfo=new Xr(e,null,null,null)}render(t,e){return e.renderEachWhen(t,this.iterInfo,this.node,this.nodeId)}toPathItem(){return new Et({})}static register=!0}class Xr{constructor(t,e,r,s){this.val=t,this.whenVal=e,this.loopWithVal=r,this.enrichWithVal=s}eval(t){let e=this.val.eval(t)??[],r=this.whenVal?.eval(t)??vh,s=this.loopWithVal?.eval(t)??tu,i=this.enrichWithVal?.eval(t)??null;return{seq:e,filter:r,loopWith:s,enricher:i}}}var vh=(t,e,r)=>!0,tu=(t)=>({seq:t}),eu={slot:Ze,show:Zr,hide:Tr,each:Te,scope:Li,"push-view":Ii};class V{constructor(t,e,r,s,i,n,h,u){this.nodes=s??[],this.events=i??[],this.macroNodes=n??[],this.parent=u??null,this.frame=h??{},this.DOMParser=t??globalThis.DOMParser,this.Text=e??globalThis.Text,this.Comment=r??globalThis.Comment,this.cacheConstNodes=!0}isInsideMacro(t){return this.frame.macroName===t||this.parent?.isInsideMacro(t)}enterMacro(t,e,r){let{DOMParser:s,Text:i,Comment:n,nodes:h,events:u,macroNodes:o}=this;return new V(s,i,n,h,u,o,{macroName:t,macroVars:e,macroSlots:r},this)}newDOMParser(){return new this.DOMParser}isTextNode(t){return t instanceof this.Text}isCommentNode(t){return t instanceof this.Comment}addNodeIf(t,e,r){if(e!==null){let s=this.nodes.length,i=new t(s,e,r);return this.nodes.push(i),i}return null}registerEvents(){let t=this.events.length,e=new Wi(t);return this.events.push(e),e}newMacroNode(t,e,r){let s=[],i={_:new Je(s)};for(let h of r)if(h instanceof Ze)i[h.val.value]=h.node;else if(!(h instanceof kt)||!h.isWhiteSpace())s.push(h);let n=new Ui(t,e,i,this);return this.macroNodes.push(n),n}compile(t){for(let e=0;e<this.macroNodes.length;e++)this.macroNodes[e].compile(t)}*genEventNames(){for(let t of this.events)yield*t.genEventNames()}getEventForId(t){return this.events[t]??null}getNodeForId(t){return this.nodes[t]??null}onAttributes(t,e,r){}}var Ir=(t)=>t instanceof kt&&t.isWhiteSpace(),Ei=(t)=>t instanceof We||t instanceof Je&&t.childs[0]instanceof We;function ru(t){let e=t.length;if(e===0)return t;let r=0,s=!1;if(Ir(t[0]))r=1,s=!0;if(e>1&&Ir(t[e-1]))e-=1,s=!0;for(let i=1;i<e-1;i++){let n=t[i];if(Ir(n)&&Ei(t[i-1])&&Ei(t[i+1])&&n.hasNewLine())n.condenseWhiteSpace()}return s?t.slice(r,e):t}class Xe{constructor(t,e,r="",s=null,i=null){this.name=t,this.anode=s,this.style=r,this.ctx=i,this.rawView=e}compile(t,e,r){if(this.ctx=t,this.anode=rt.parse(this.rawView,t),this.anode.setDataAttr("data-cid",r),this.anode.setDataAttr("data-vid",this.name),this.ctx.compile(e),t.cacheConstNodes)this.anode=Wr(this.anode)}render(t,e){return this.anode.render(t,e)}}class Wi{constructor(t){this.id=t,this.handlers=[]}add(t,e,r){this.handlers.push(new Ji(t,e,r))}*genEventNames(){for(let t of this.handlers)yield t.name}getHandlersFor(t){let e=null;for(let r of this.handlers)if(r.handlesEventName(t))e??=[],e.push(r);return e}}class Ji{constructor(t,e,r){this.name=t,this.handlerCall=e,this.modifierWrapper=uu(t,r),this.modifiers=r}handlesEventName(t){return this.name===t}getHandlerAndArgs(t,e){let r=this.handlerCall.getHandlerAndArgs(t,e);return r[0]=this.modifierWrapper(r[0],e),r}}var su=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),He=(t)=>(e)=>(r,s,i,n)=>t(n)?e(r,s,i,n):r,ji=(t)=>He((e)=>e.e.key===t),$i=He(({e:t})=>su&&t.metaKey||t.ctrlKey),iu=He(({e:t})=>t.metaKey),nu=He(({e:t})=>t.altKey),Ai={ctrl:$i,cmd:$i,meta:iu,alt:nu},Hr={keydown:{send:ji("Enter"),cancel:ji("Escape"),...Ai},click:{...Ai}},hu=(t,e)=>t;function uu(t,e){if(e.length===0)return hu;let r=Hr[t]??{},s=(i,n,h,u)=>n.apply(i,h);for(let i of e){let n=r[i];if(n!==void 0)s=n(s)}return(i,n)=>function(...h){return s(this,i,h,n)}}class Qr{get(t,e){}set(t,e,r){}get2(t,e,r){}set2(t,e,r,s){}evict(){return{hit:0,miss:0,badKey:0}}}class Gr{constructor(){this.hit=this.miss=this.badKey=0,this.map=new WeakMap}_returnValue(t){if(t===void 0)this.miss+=1;else this.hit+=1;return t}get(t,e){return this._returnValue(this.map.get(t)?.[e])}set(t,e,r){let s=this.map.get(t);if(s)s[e]=r;else if(typeof t==="object")this.map.set(t,{[e]:r});else this.badKey+=1}get2(t,e,r){return this._returnValue(this.map.get(t)?.get?.(e)?.[r])}set2(t,e,r,s){let i=this.map.get(t);if(i){let n=i.get(e);if(n)n[r]=s;else i.set(e,{[r]:s})}else if(typeof t==="object"&&typeof e==="object"){let n=new WeakMap;n.set(e,{[r]:s}),this.map.set(t,n)}else this.badKey+=1}evict(){let{hit:t,miss:e,badKey:r}=this;return this.hit=this.miss=this.badKey=0,this.map=new WeakMap,{hit:t,miss:e,badKey:r}}}class Yr{getKey(t,e,r){return r.call(t)}}class Br{constructor(){this.map=new WeakMap}getKey(t,e,r){let s=this.map.get(t);if(s){let n=s[e];if(n!==void 0)return n;let h=r.call(t)??null;return s[e]=h,h}let i=r.call(t)??null;return this.map.set(t,{[e]:i}),i}}class Qe{constructor(){this.getComponentSymbol=Symbol("getComponent"),this.byId=new Map,this.computedCache=new Br}setNullComputedCache(){this.computedCache=new Yr}registerComponent(t){t.Class.prototype[this.getComponentSymbol]=()=>t,this.byId.set(t.id,t)}getComponentForId(t){return this.byId.get(t)??null}getCompFor(t){return t?.[this.getComponentSymbol]?.()??null}getOnEnterFor(t){let e=this.getCompFor(t);return e?e.on.stackEnter:Ri}getInputHandlerFor(t,e){return this.getCompFor(t)?.input[e]??null}getAlterHandlerFor(t,e){return this.getCompFor(t)?.alter[e]??null}getRequestFor(t,e){let r=this.getCompFor(t);return r?r.scope.lookupRequest(e):null}lookupComputed(t,e){let r=this.getCompFor(t)?.computed[e];return r?this.computedCache.getKey(t,e,r):null}compileStyles(){let t=[];for(let e of this.byId.values())t.push(e.compileStyle());return t.join(`
2
+ `)}}class Ge{constructor(t=new Qe,e=null){this.comps=t,this.parent=e,this.byName={},this.reqsByName={},this.macros={}}enter(){return new Ge(this.comps,this)}registerComponents(t,e={}){for(let r=0;r<t.length;r++){let s=t[r];s.scope=this.enter(),this.comps.registerComponent(s),this.byName[s.name]=s;let i=e[s.name];if(i)this.byName[i]=s}}registerMacros(t){Object.assign(this.macros,t)}getCompFor(t){return this.comps.getCompFor(t)}registerRequestHandlers(t){for(let e in t)this.reqsByName[e]=new Kr(e,t[e])}lookupRequest(t){return this.reqsByName[t]??this.parent?.lookupRequest(t)??null}lookupComponent(t){return this.byName[t]??this.parent?.lookupComponent(t)??null}lookupMacro(t){return this.macros[t]??this.parent?.lookupMacro(t)??null}}class Pr{constructor(t,e,r){this.name=t,this.val=e,this.symbol=r}getSymbol(t){return this.symbol}evalAndBind(t,e){e[this.getSymbol(t)]=this.val.eval(t)}}class Di extends Pr{constructor(t,e,r,s){super(t,e,null);this.compName=r,this.dynName=s}_resolveSymbol(t){return t.lookupType(this.compName)?.dynamic[this.dynName]?.symbol??null}getSymbol(t){return this.symbol??=this._resolveSymbol(t),this.symbol}}var Ut=(t)=>typeof t==="string",ou=0;class Cr{constructor(t,e,r,s={},i="",n="",h="",u={},o={},f={},c={},_={},l={},a={},y={}){this.id=ou++,this.name=t,this.Class=e,this.views={main:new Xe("main",r,i)},this.commonStyle=n,this.globalStyle=h,this.computed=u,this.input=o,this.logic=f,this.bubble=c,this.response=_,this.alter=l,this.on={stackEnter:y?.stackEnter??Ri};for(let p in s){let d=s[p],{view:j,style:bt}=Ut(d)?{view:d}:d;this.views[p]=new Xe(p,j,bt)}this._rawDynamic=a,this.dynamic={},this.scope=null}compile(t){for(let e in this._rawDynamic){let r=this._rawDynamic[e];if(Ut(r)){let s=w.parseDynamic(r,this.views.main.ctx);this.dynamic[e]=new Pr(e,s,Symbol(e))}else if(Ut(r?.default)&&Ut(r?.for)){let s=w.parseDynamic(r.default,this.views.main.ctx),[i,n]=r.for.split(".");if(Ut(i)&&Ut(n))this.dynamic[e]=new Di(e,s,i,n)}}for(let e in this.views)this.views[e].compile(new t,this.scope,this.id)}make(t,e){return this.Class.make(t,e)}getView(t){return this.views[t]??this.views.main}getEventForId(t,e="main"){return this.getView(e).ctx.getEventForId(t)}getNodeForId(t,e="main"){return this.getView(e).ctx.getNodeForId(t)}compileStyle(){let{id:t,commonStyle:e,globalStyle:r,views:s}=this,i=e?[`[data-cid="${t}"]{${e}}`]:[];if(r!=="")i.push(r);for(let n in s){let{style:h}=s[n];if(h!=="")i.push(`[data-cid="${t}"][data-vid="${n}"]{${h}}`)}return i.join(`
3
+ `)}}function Ri(t){return t}var Zi=Symbol("STOP"),kr=Symbol("NEXT");class Nt{constructor(t,e){this.head=t,this.tail=e}push(t){return new Nt(t,this)}lookup(t,e=null){let{tail:r}=this,s=this.head.lookup(t);return s===Zi?e:s===kr?r!==null?r.lookup(t,e):e:s}*[Symbol.iterator](){let t=this;while(t!==null)yield t.head,t=t.tail}}class xr{constructor(t,e,r){this.it=t,this.bindings=e,this.isFrame=r}lookup(t){let e=this.bindings[t];return e===void 0?this.isFrame?Zi:kr:e}}class Fr{constructor(t){this.bindings=t}lookup(t){let e=this.bindings[t];return e===void 0?kr:e}}class Q{constructor(t,e,r,s,i,n=null){this.comps=t,this.it=e,this.binds=r,this.dynBinds=s,this.views=i,this.ctx=n;let h=[...i].join("");this.viewsId=h==="main"?"":h}_enrichOnEnter(){return this.comps.getOnEnterFor(this.it).call(this.it,this)??this}upToFrameBinds(){let{comps:t,binds:e,dynBinds:r,views:s,ctx:i}=this;return e.head.isFrame?this:new Q(t,e.tail.head.it,e.tail,r,s,i)}static root(t,e,r){let s=new Nt(new xr(e,{it:e},!0),null),i=new Nt(new Fr({}),null),n=new Nt("main",null);return new Q(t,e,s,i,n,r)._enrichOnEnter()}enter(t,e={},r=!0){let{comps:s,binds:i,dynBinds:n,views:h,ctx:u}=this,o=i.push(new xr(t,e,r));return new Q(s,t,o,n,h,u)._enrichOnEnter()}pushViewName(t){let{comps:e,it:r,binds:s,dynBinds:i,views:n,ctx:h}=this;return new Q(e,r,s,i,n.push(t),h)}withDynamicBindings(t){let e={},r=this.comps.getCompFor(this.it);for(let f of t)r.dynamic[f].evalAndBind(this,e);let{comps:s,it:i,binds:n,views:h,ctx:u}=this,o=this.dynBinds.push(new Fr(e));return new Q(s,i,n,o,h,u)}lookupDynamic(t){let e=this.comps.getCompFor(this.it)?.dynamic[t];return e?this.dynBinds.lookup(e.getSymbol(this))??e.val.eval(this):null}lookupBind(t){return this.binds.lookup(t)}lookupType(t){return this.comps.getCompFor(this.it).scope.lookupComponent(t)}lookupFieldRaw(t){return this.it[t]??null}lookupField(t){let e=this.lookupFieldRaw(t);return e instanceof Function?e.call(this.it):e}lookupName(t){return this.ctx.lookupName(t)}lookupComputed(t){let e=this.binds.head.isFrame?this.binds.head:this.binds.tail.head;return this.comps.lookupComputed(e.it,t)}getInputHandler(t){return this.comps.getInputHandlerFor(this.it,t)}getAlterHandler(t){return this.comps.getAlterHandlerFor(this.it,t)}lookupRequest(t){return this.comps.getRequestFor(this.it,t)}lookupBestView(t,e){for(let r of this.views){let s=t[r];if(s!==void 0)return s}return t[e]}}class Xi{constructor(t){this.value=t,this.changeSubs=[]}onChange(t){this.changeSubs.push(t)}set(t,e){let r=this.value;this.value=t;for(let s of this.changeSubs)s({value:t,old:r,info:e,timestamp:Date.now()})}update(t,e){return this.set(t(this.value),e)}}class Nr{constructor(t,e){this.comps=t,this.transactions=[],this.state=new Xi(e),this.onTransactionPushed=()=>{}}pushTransaction(t){return this.transactions.push(t),this.onTransactionPushed(t),t}pushLogic(t,e,r=[],s={},i=null){return this.pushTransaction(new ts(t,this,e,r,i,s))}pushBubble(t,e,r=[],s={},i=null){let n=s.skipSelf?{...s,skipSelf:!1}:s;return this.pushTransaction(new Gi(t,this,e,r,i,n))}async pushRequest(t,e,r=[],s={},i=null){let n=this.state.value,h=t.lookup(n),u=this.comps.getRequestFor(h,e)??fu(e),o=s?.onResName??e,f=(c,_,l,a,y)=>{let d=new Qi(t,this,c??_,c?[l]:[a,y],i);return this.pushTransaction(d)};try{let c=await u.fn.apply(null,r);return f(s?.onOkName,o,c,c,null)}catch(c){return f(s?.onErrorName,o,c,null,c)}}get hasPendingTransactions(){return this.transactions.length>0}transactNext(){if(this.hasPendingTransactions)this.transact(this.transactions.shift())}transactAll(){while(this.hasPendingTransactions)this.transact(this.transactions.shift())}transact(t){let e=this.state.value,r=t.run(e,this.comps);if(r!==void 0)this.state.set(r,{transaction:t}),t.afterTransaction();else console.warn("undefined new state",{curState:e,transaction:t})}transactInputNow(t,e,r,s){this.transact(new Hi(t,e,r,this,s))}}function fu(t){return()=>{throw Error(`Request not found: ${t}`)}}function cu(){return this}class mr{constructor(t,e){this.path=t,this.transactor=e,this.parentTransaction=null,this._task=null}get task(){return this._task??=new Yi,this._task}getCompletionPromise(){return this.task.promise}setParent(t){this.parentTransaction=t,t.task.addDep(this.task)}run(t,e){return this.updateRootValue(t,e)}afterTransaction(){}buildRootStack(t,e){return Q.root(e,t)}buildStack(t,e){let r=this.path.buildStack(this.buildRootStack(t,e));return r?r.upToFrameBinds():null}callHandler(t,e,r){let[s,i]=this.getHandlerAndArgs(t,e,r);return s.apply(e,i)}getHandlerAndArgs(t,e,r){return null}updateRootValue(t,e){let r=this.path.lookup(t),s=this.callHandler(t,r,e);return this._task?.complete?.({value:s,old:r}),r!==s?this.path.setValue(t,s):t}lookupName(t){return null}}var _u=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Ti=(t)=>Number.isNaN(t)?null:t;function Vr(t){return t.target.type==="checkbox"?t.target.checked:(t instanceof CustomEvent?t.detail:t.target.value)??null}class Hi extends mr{constructor(t,e,r,s,i){super(t,s);this.e=e,this.handler=r,this.dragInfo=i}buildRootStack(t,e){return Q.root(e,t,this)}getHandlerAndArgs(t,e,r){let s=this.buildStack(t,r),[i,n]=this.handler.getHandlerAndArgs(s,this),h;for(let u=0;u<n.length;u++)if(n[u]?.toHandlerArg)h??=new es(this.path,this.transactor,this),n[u]=n[u].toHandlerArg(h);return[i,n]}lookupName(t){let{e}=this;switch(t){case"value":return Vr(e);case"valueAsInt":return Ti(parseInt(Vr(e),10));case"valueAsFloat":return Ti(parseFloat(Vr(e)));case"target":return e.target;case"event":return e;case"isAlt":return e.altKey;case"isShift":return e.shiftKey;case"isCtrl":case"isCmd":return _u&&e.metaKey||e.ctrlKey;case"key":return e.key;case"keyCode":return e.keyCode;case"isUpKey":return e.key==="ArrowUp";case"isDownKey":return e.key==="ArrowDown";case"isSend":return e.key==="Enter";case"isCancel":return e.key==="Escape";case"isTabKey":return e.key==="Tab";case"ctx":return new rs(this.path,this.transactor,this);case"dragInfo":return this.dragInfo}return null}}class vr extends mr{constructor(t,e,r,s,i,n={}){super(t,e,i);this.name=r,this.args=s,this.opts=n}handlerProp=null;getHandlerForName(t){return t?.[this.handlerProp]?.[this.name]??cu}getHandlerAndArgs(t,e,r){return[this.getHandlerForName(r.getCompFor(e)),[...this.args,new rs(this.path,this.transactor,this)]]}}class Qi extends vr{handlerProp="response"}class ts extends vr{handlerProp="logic";run(t,e){return this.opts.skipSelf?t:this.updateRootValue(t,e)}afterTransaction(){let{path:t,name:e,args:r,opts:s}=this;if(s.bubbles&&t.steps.length>0)this.transactor.pushBubble(t.popStep(),e,r,s,this)}}class Gi extends ts{handlerProp="bubble";stopPropagation(){this.opts.bubbles=!1}}class Yi{constructor(t){this.info=t,this.deps=[],this.value=this.resolve=this.reject=null,this.promise=new Promise((e,r)=>{this.resolve=e,this.reject=r}),this.isCompleted=!1}addDep(t){console.assert(!this.isCompleted,"addDep for completed task",this,t),this.deps.push(t),t.promise.then((e)=>this._check())}complete(t){this.value=t,this._check()}_check(){if(this.deps.every((t)=>t.isCompleted))this.isCompleted=!0,this.resolve(this)}}class es{constructor(t,e,r=null){this.path=t,this.transactor=e,this.parent=r}get at(){return new Bi(this)}logic(t,e,r){return this.logicAtPath(this.path,t,e,r)}bubble(t,e,r){return this.logic(t,e,{skipSelf:!0,bubbles:!0,...r})}logicAtPath(t,e,r,s){return this.transactor.pushLogic(t,e,r,s,this.parent)}request(t,e,r){return this.requestAtPath(this.path,t,e,r)}requestAtPath(t,e,r,s){return this.transactor.pushRequest(t,e,r,s,this.parent)}lookupTypeFor(t,e){return this.transactor.comps.getCompFor(e).scope.lookupComponent(t)}}class rs extends es{stopPropagation(){return this.parent.stopPropagation()}}class Bi extends dr{constructor(t){super();this.dispatcher=t}logic(t,e,r){return this.dispatcher.logicAtPath(this.buildPath(),t,e,r)}bubble(t,e,r){return this.logic(t,e,{skipSelf:!0,bubbles:!0,...r})}buildPath(){return this.dispatcher.path.concat(this.pathChanges)}}class ss{constructor(t,e,r,s,i){this.rootNode=t,this.comps=r,this.compStack=new Ge(r),this.transactor=new Nr(r,null),this.ParseContext=i,this.renderer=s,this.renderFn=e,this.maxEventNodeDepth=1/0,this._transactNextBatchId=this._evictCacheId=null,this._eventNames=new Set(["dragstart","dragover","dragend"]),this.dragInfo=this.curDragOver=null,this.transactor.onTransactionPushed=(n)=>{if(this._transactNextBatchId===null)this._scheduleNextTransactionBatchExecution()},this._compiled=!1}get state(){return this.transactor.state}handleEvent(t){let e=t.type==="dragstart",r=t.type==="dragover",s=t.type==="dragend",{rootNode:i,maxEventNodeDepth:n,comps:h}=this,u=!(r||e||s),[o,f]=et.fromEvent(t,i,n,h,u);if(r){let c=lu(t.target,this.rootNode,50);if(c!==null)t.preventDefault(),this._cleanDragOverAttrs(),this.curDragOver=c,c.dataset.draggingover=this.dragInfo.type}else if(e){t.target.dataset.dragging=1;let c=this.state.value,_=o.lookup(c),l=t.target.dataset.dragtype??"?",a=o.buildStack(this.makeStack(c));this.dragInfo=new Pi(o,a,t,_,l,t.target)}else if(s)delete this.dragInfo.node.dataset.dragging,this.dragInfo=null,this._cleanDragOverAttrs();if(o!==null&&f!==null)for(let c of f)this.transactor.transactInputNow(o,t,c,this.dragInfo)}makeStack(t){return Q.root(this.comps,t)}_cleanDragOverAttrs(){if(this.curDragOver!==null)delete this.curDragOver.dataset.draggingover,this.curDragOver=null}render(){let t=this.state.value,e=this.makeStack(t);return this.renderFn(this.renderer.renderRoot(e,t),this.rootNode)}onChange(t){this.transactor.state.onChange(t)}compile(){for(let t of this.comps.byId.values()){t.compile(this.ParseContext);for(let e in t.views)for(let r of t.views[e].ctx.genEventNames())this._eventNames.add(r)}this._compiled=!0}start(t){if(!this._compiled)this.compile();for(let e of this._eventNames)this.rootNode.addEventListener(e,this);if(this.onChange((e)=>{if(e.value!==e.old)this.render()}),Ye("tutuca-app",this.comps.compileStyles(),t?.head??document.head),t?.noCache)this.renderer.setNullCache(),this.comps.setNullComputedCache();else this.startCacheEvictionInterval();this.render()}stop(){this.stopCacheEvictionInterval();for(let t of this._eventNames)this.rootNode.removeEventListener(t,this)}dispatchLogicAtRoot(t,e,r){return this.transactor.pushLogic(new et([]),t,e,r)}registerComponents(t,e){let r=this.compStack.enter();return r.registerComponents(t,e),r}_transactNextBatch(t=10){this._transactNextBatchId=null;let e=Date.now(),r=this.transactor;while(r.hasPendingTransactions&&Date.now()-e<t)r.transactNext();if(r.hasPendingTransactions)this._scheduleNextTransactionBatchExecution()}_scheduleNextTransactionBatchExecution(){this._transactNextBatchId=setTimeout(()=>this._transactNextBatch(),0)}startCacheEvictionInterval(t=30000){this._evictCacheId=setInterval(()=>this.renderer.cache.evict(),t)}stopCacheEvictionInterval(){clearInterval(this._evictCacheId),this._evictCacheId=null}}function Ye(t,e,r=document.head){let s=document.createElement("style"),i=r.querySelector(`#${t}`);if(i)r.removeChild(i);s.id=t,s.innerHTML=e,r.appendChild(s)}function lu(t,e,r){let s=t;while(r-- >0&&s!==e){if(s.dataset?.droptarget!==void 0)return s;s=s.parentNode}return null}class Pi{constructor(t,e,r,s,i,n){this.path=t,this.stack=e,this.e=r,this.value=s,this.type=i,this.node=n}lookupBind(t){return this.stack.lookupBind(t)}}class Be extends V{constructor(...t){super(...t);this.classes=new Set}_addClasses(t){for(let e of t.split(/\s+/))this.classes.add(e)}enterMacro(t,e,r){let{DOMParser:s,Text:i,Comment:n,nodes:h,events:u,macroNodes:o}=this,c=new Be(s,i,n,h,u,o,{macroName:t,macroVars:e,macroSlots:r},this);return c.classes=this.classes,c}onAttributes(t,e,r){if(Array.isArray(t.items))for(let s of t.items){if(s.name!=="class")continue;let{value:i,thenVal:n,elseVal:h}=s;if(n!==void 0)this._maybeAddVal(n),this._maybeAddVal(h);else this._maybeAddVal(i)}else{let s=t.items.class;if(s)this._addClasses(s)}}_maybeAddVal(t){if(!this._maybeAddStrTpl(t)&&typeof t?.value==="string")this._addClasses(t.value)}_maybeAddStrTpl(t){if(t?.vals!==void 0){for(let e of t.vals)if(e instanceof W&&e.value!=="")this._addClasses(e.value);return!0}return!1}}function mt(t,e){if(!t)throw Error(e)}function U(t){mt(t!==1/0,"Cannot perform this action with an infinite size.")}function Ci(t,e,r,s,i,n){return U(t.size),t.__iterate((h,u,o)=>{if(i)i=!1,r=h;else r=e.call(s,r,h,u,o)},n),r}var au=(t,e)=>e,yu=(t,e)=>[e,t],is=(t)=>function(...e){return!t.apply(this,e)},xi=(t)=>function(...e){return-t.apply(this,e)};function yn(t,e){if(t===void 0&&e===void 0)return 0;if(t===void 0)return 1;if(e===void 0)return-1;return t>e?1:t<e?-1:0}var Fi=(t,e)=>t<e?1:t>e?-1:0,K={done:!0,value:void 0};class gn{constructor(t){this.next=t}[Symbol.iterator](){return this}}function D(t){return new gn(t)}function q(t){let e=[void 0,void 0],r={done:!1,value:void 0};return D(()=>{if(t(e))return r.value=[e[0],e[1]],r;return K})}var gu=D(()=>K),ct=()=>gu;function er(t){let e=0,r={done:!1,value:void 0};return D(()=>{if(e===t)return K;return r.value=e++,r})}function ue(t,e){return q((r)=>{let s=t.next();if(s.done)return!1;return e(s.value[0],s.value[1],r),!0})}function zs(t){if(Array.isArray(t))return!0;return!!rr(t)}var wu=(t)=>!!(t&&typeof t.next==="function");function wn(t){return rr(t)?.call(t)}function rr(t){let e=t&&t[Symbol.iterator];if(typeof e==="function")return e}function pu(t){let e=rr(t);return e&&e===t.entries}function zu(t){let e=rr(t);return e&&e===t.keys}var oe="delete",S=5,E=1<<S,I=E-1,g={},ls=()=>({value:!1});function H(t){if(t)t.value=!0}class sr{}function Lt(t){if(t.size===void 0)t.size=t.__iterate(pn);return t.size}function it(t,e){if(typeof e!=="number"){let r=e>>>0;if(String(r)!==e||r===4294967295)return NaN;e=r}return e<0?Lt(t)+e:e}var pn=()=>!0,zn=(t)=>t<0||Object.is(t,-0),fe=(t,e,r)=>(t===0&&!zn(t)||r!==void 0&&(t??0)<=-r)&&(e===void 0||r!==void 0&&e>=r),Sn=(t,e,r)=>t===void 0?r:zn(t)?e===1/0?e:Math.max(0,e+t)|0:e===void 0||e===t?t:Math.min(e,t)|0,Rt=(t,e)=>Sn(t,e,0),ce=(t,e)=>Sn(t,e,e),dn="@@__IMMUTABLE_ITERABLE__@@",ke="@@__IMMUTABLE_KEYED__@@",Ve="@@__IMMUTABLE_INDEXED__@@",nt="@@__IMMUTABLE_ORDERED__@@",_e="@@__IMMUTABLE_SEQ__@@",On="@@__IMMUTABLE_LIST__@@",Mn="@@__IMMUTABLE_MAP__@@",bn="@@__IMMUTABLE_SET__@@",qn="@@__IMMUTABLE_STACK__@@",En="@@__IMMUTABLE_RECORD__@@";function F(t,e){return typeof t==="object"&&t!==null&&e in t}var T=(t)=>F(t,dn),z=(t)=>F(t,ke),$=(t)=>F(t,Ve),Ss=(t)=>z(t)||$(t),x=(t)=>F(t,nt),ds=(t)=>F(t,_e),jn=(t)=>F(t,On),ir=(t)=>F(t,Mn),Os=(t)=>F(t,bn),Ms=(t)=>F(t,qn),gt=(t)=>F(t,En),P=(t)=>T(t)||gt(t),bs=(t)=>ir(t)&&x(t),$n=(t)=>Os(t)&&x(t),ki=(t)=>typeof t==="object"&&t!==null&&typeof t.equals==="function"&&typeof t.hashCode==="function";function An(t){let e=C(t);return e._iter=t,e.size=t.size,e.flip=()=>t,e.reverse=function(){let r=t.reverse.call(this);return r.flip=()=>t.reverse(),r},e.has=(r)=>t.includes(r),e.includes=(r)=>t.has(r),e.cacheResult=Tt,e.__iterate=function(r,s){return t.__iterate((i,n)=>r(n,i,this),s)},e.__iteratorUncached=function(r){return ue(t.__iterator(r),(s,i,n)=>{n[0]=i,n[1]=s})},e}function Un(t,e,r){let s=C(t);return s.size=t.size,s.has=(i)=>t.has(i),s.get=(i,n)=>{let h=t.get(i,g);return h===g?n:e.call(r,h,i,t)},s.__iterate=function(i,n){return t.__iterate((h,u)=>i(e.call(r,h,u,t),u,this),n)},s.__iteratorUncached=function(i){return ue(t.__iterator(i),(n,h,u)=>{u[0]=n,u[1]=e.call(r,h,n,t)})},s}function Kn(t,e){let r=C(t);if(r._iter=t,r.size=t.size,r.reverse=()=>t,t.flip)r.flip=function(){let s=An(t);return s.reverse=()=>t.flip(),s};return r.get=(s,i)=>t.get(e?s:-1-s,i),r.has=(s)=>t.has(e?s:-1-s),r.includes=(s)=>t.includes(s),r.cacheResult=Tt,r.__iterate=function(s,i){let n=0;if(i)Lt(t);return t.__iterate((h,u)=>s(h,e?u:i?this.size-++n:n++,this),!i)},r.__iteratorUncached=function(s){let i=0;if(s)Lt(t);let n=this.size;return ue(t.__iterator(!s),(h,u,o)=>{o[0]=e?h:s?n-++i:i++,o[1]=u})},r}function In(t,e,r,s){let i=t.size;if(fe(e,r,i))return t;if(i===void 0&&(e<0||r<0))return In(t.toSeq().cacheResult(),e,r,s);let n=Rt(e,i),u=ce(r,i)-n,o;if(!Number.isNaN(u))o=Math.max(0,u);let f=C(t);if(f.size=o===0?o:t.size&&o||void 0,!s&&ds(t)&&o>=0)f.get=function(c,_){return c=it(this,c),c>=0&&c<o?t.get(c+n,_):_};return f.__iterateUncached=function(c,_){if(o!==0&&_)return this.cacheResult().__iterate(c,_);if(o===0)return 0;let l=0,a=0;return t.__iterate((y,p)=>{if(l<n){l++;return}if(o!==void 0&&a>=o)return!1;if(a++,c(y,s?p:a-1,this)===!1)return!1},_),a},f.__iteratorUncached=function(c){if(o!==0&&c)return this.cacheResult().__iterator(c);if(o===0)return ct();let _=t.__iterator(c),l=0,a=0;if(s)return D(()=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return K;let y=_.next();if(y.done)return y;return a++,y});return q((y)=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return!1;let p=_.next();if(p.done)return!1;return a++,y[0]=a-1,y[1]=p.value[1],!0})},f}function It(t,e,r){if(!e)e=yn;let s=z(t),i=0,n=t.toSeq().map((h,u)=>[u,h,i++,r?r(h,u,t):h]).valueSeq().toArray();return n.sort((h,u)=>e(h[3],u[3])||h[2]-u[2]).forEach(s?(h,u)=>{n[u].length=2}:(h,u)=>{n[u]=h[1]}),s?Us(n):$(t)?yt(n):te(n)}function Pe(t,e,r){if(!e)e=yn;if(r){let s=t.toSeq().map((i,n)=>[i,r(i,n,t)]).reduce((i,n)=>Vi(e,i[1],n[1])?n:i);return s&&s[0]}return t.reduce((s,i)=>Vi(e,s,i)?i:s)}function Vi(t,e,r){let s=t(r,e);return s===0&&r!==e&&(r===void 0||r===null||Number.isNaN(r))||s>0}function ns(t,e,r,s){let i=C(t),n=new le(r).map((h)=>h.size);return i.size=s?n.max():n.min(),i.__iterate=function(h,u){let o=this.__iterator(u),f=0,c;while(!(c=o.next()).done)if(h(c.value[1],f++,this)===!1)break;return f},i.__iteratorUncached=function(h){let u=r.map((_)=>{let l=m(_);return wn(h?l.reverse():l)}),o=0,f=Array(u.length),c=Array(u.length);return q((_)=>{let l=s;for(let a=0;a<u.length;a++)f[a]=u[a].next(),l=s?l&&f[a].done:l||f[a].done;if(l)return!1;for(let a=0;a<f.length;a++)c[a]=f[a].value;return _[0]=o++,_[1]=e(...c),!0})},i}function qs(t){if(Array.isArray(t)||typeof t==="string")return!0;return t&&typeof t==="object"&&Number.isInteger(t.length)&&t.length>=0&&(t.length===0?Object.keys(t).length===1:Object.hasOwn(t,t.length-1))}function Ln(t){if(!t||typeof t!=="object"||Object.prototype.toString.call(t)!=="[object Object]")return!1;let e=Object.getPrototypeOf(t);if(e===null)return!0;let r=e,s=Object.getPrototypeOf(e);while(s!==null)r=s,s=Object.getPrototypeOf(r);return r===e}var ht=(t)=>typeof t==="object"&&(P(t)||Array.isArray(t)||Ln(t));function Wn(t){if(qs(t)&&typeof t!=="string")return t;if(x(t))return t.toArray();throw TypeError(`Invalid keyPath: expected Ordered Collection or Array: ${t}`)}var Su=(t,e)=>P(t)?t.has(e):ht(t)&&Object.hasOwn(t,e);function Jn(t,e,r){return P(t)?t.get(e,r):!Su(t,e)?r:typeof t.get==="function"?t.get(e):t[e]}function Es(t,e,r){let s=Wn(e),i=0;while(i!==s.length)if(t=Jn(t,s[i++],g),t===g)return r;return t}var Dn=(t,e)=>Es(t,e,g)!==g;function A(t,e){if(t===e||Number.isNaN(t)&&Number.isNaN(e))return!0;if(!t||!e)return!1;if(typeof t.valueOf==="function"&&typeof e.valueOf==="function"){if(t=t.valueOf(),e=e.valueOf(),t===e||Number.isNaN(t)&&Number.isNaN(e))return!0;if(!t||!e)return!1}return!!(ki(t)&&ki(e)&&t.equals(e))}function Ne(t){if(!t||typeof t!=="object")return t;if(!T(t)){if(!ht(t))return t;t=v(t)}if(z(t)){let r={};return t.__iterate((s,i)=>{r[String(i)]=Ne(s)}),r}let e=[];return t.__iterate((r)=>{e.push(Ne(r))}),e}function js(t,e){if(t===e)return!0;if(!T(e)||t.size!==void 0&&e.size!==void 0&&t.size!==e.size||t.__hash!==void 0&&e.__hash!==void 0&&t.__hash!==e.__hash||z(t)!==z(e)||$(t)!==$(e)||x(t)!==x(e))return!1;if(t.size===0&&e.size===0)return!0;let r=!Ss(t);if(x(t)){let h=t.entries();return!!(e.every((u,o)=>{let f=h.next().value;return f&&A(f[1],u)&&(r||A(f[0],o))})&&h.next().done)}let s=!1;if(t.size===void 0)if(e.size===void 0){if(typeof t.cacheResult==="function")t.cacheResult()}else{s=!0;let h=t;t=e,e=h}let i=!0,n=e.__iterate((h,u)=>{if(r?!t.has(h):s?!A(h,t.get(u,g)):!A(t.get(u,g),h))return i=!1,!1;return!0});return i&&t.size===n}var nr=(t)=>t>>>1&1073741824|t&3221225471;function G(t){if(t===null||t===void 0)return Ni(t);if(typeof t.hashCode==="function")return nr(t.hashCode(t));let e=qu(t);if(e===null||e===void 0)return Ni(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return du(e);case"string":return e.length>Eu?Ou(e):as(e);case"object":case"function":return bu(e);case"symbol":return Mu(e);default:if(typeof e.toString==="function")return as(e.toString());throw Error(`Value type ${typeof e} cannot be hashed.`)}}var Ni=(t)=>t===null?1108378658:1108378659;function du(t){if(Number.isNaN(t)||t===1/0)return 0;let e=t|0;if(e!==t)e^=t*4294967295;while(t>4294967295)t/=4294967295,e^=t;return nr(e)}function Ou(t){let e=os[t];if(e===void 0){if(e=as(t),us===ju)us=0,os={};us++,os[t]=e}return e}function as(t){let e=0;for(let r=0;r<t.length;r++)e=31*e+t.charCodeAt(r)|0;return nr(e)}function Mu(t){let e=vi[t];if(e!==void 0)return e;return e=Rn(),vi[t]=e,e}function bu(t){let e=mi.get(t);if(e!==void 0)return e;return e=Rn(),mi.set(t,e),e}var qu=(t)=>t.valueOf!==Object.prototype.valueOf?t.valueOf():t;function Rn(){let t=++hs;if(hs&1073741824)hs=0;return t}var mi=new WeakMap,vi=Object.create(null),hs=0,Eu=16,ju=255,us=0,os={};function $u(t){if(t.size===1/0)return 0;let e=x(t),r=z(t),s=e?1:0;return t.__iterate(r?e?(i,n)=>{s=31*s+tn(G(i),G(n))|0}:(i,n)=>{s=s+tn(G(i),G(n))|0}:e?(i)=>{s=31*s+G(i)|0}:(i)=>{s=s+G(i)|0}),Au(t.size,s)}var tn=(t,e)=>t^e+2654435769+(t<<6)+(t>>2)|0;function Au(t,e){return e=Math.imul(e,3432918353),e=Math.imul(e<<15|e>>>-15,461845907),e=Math.imul(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=Math.imul(e^e>>>16,2246822507),e=Math.imul(e^e>>>13,3266489909),e=nr(e^e>>>16),e}function vt(t){try{return typeof t==="string"?JSON.stringify(t):String(t)}catch{return JSON.stringify(t)}}var O=(t,e)=>t===e?t:ds(t)?e:t.create?t.create(e):t.constructor(e),Zn=(t,e)=>O(t,(z(t)?Y:$(t)?wt:pt)(e)),en=(...t)=>t,m=(t)=>T(t)?t:v(t);class b{size=0;static{this.prototype[dn]=!0,this.prototype.__toStringMapper=vt,this.prototype[Symbol.iterator]=this.prototype.values,this.prototype.toJSON=this.prototype.toArray,this.prototype.contains=this.prototype.includes}equals(t){return js(this,t)}hashCode(){return this.__hash??(this.__hash=$u(this))}toArray(){U(this.size);let t=Array(this.size||0),e=z(this),r=0;return this.__iterate((s,i)=>{t[r++]=e?[i,s]:s}),t}toIndexedSeq(){return new Gn(this)}toJS(){return Ne(this)}toKeyedSeq(){return new Js(this,!0)}toMap(){throw Error("toMap: not patched — import CollectionConversions")}toObject(){U(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}toOrderedMap(){throw Error("toOrderedMap: not patched — import CollectionConversions")}toOrderedSet(){throw Error("toOrderedSet: not patched — import CollectionConversions")}toSet(){throw Error("toSet: not patched — import CollectionConversions")}toSetSeq(){return new Yn(this)}toSeq(){return $(this)?this.toIndexedSeq():z(this)?this.toKeyedSeq():this.toSetSeq()}toStack(){throw Error("toStack: not patched — import CollectionConversions")}toList(){throw Error("toList: not patched — import CollectionConversions")}toString(){return"[Collection]"}__toString(t,e){if(this.size===0)return`${t}${e}`;return`${t} ${this.toSeq().map(this.__toStringMapper).join(", ")} ${e}`}concat(...t){let e=z(this),r=[this,...t].map((s)=>{if(!T(s))s=e?Xn(s):Hn(Array.isArray(s)?s:[s]);else if(e)s=Y(s);return s}).filter((s)=>s.size!==0);if(r.length===0)return this;if(r.length===1){let s=r[0];if(s===this||e&&z(s)||$(this)&&$(s))return s}return O(this,new Qn(r))}includes(t){return this.some((e)=>A(e,t))}every(t,e){U(this.size);let r=!0;return this.__iterate((s,i,n)=>{if(!t.call(e,s,i,n))return r=!1,!1}),r}entries(){return this.__iterator()}filter(t,e){let r=this,s=z(this),i=C(r);if(s)i.has=(n)=>{let h=r.get(n,g);return h!==g&&!!t.call(e,h,n,r)},i.get=(n,h)=>{let u=r.get(n,g);return u!==g&&t.call(e,u,n,r)?u:h};return i.__iterateUncached=function(n,h){let u=0;return r.__iterate((o,f)=>{if(t.call(e,o,f,r))return u++,n(o,s?f:u-1,this)},h),u},i.__iteratorUncached=function(n){let h=r.__iterator(n),u=0;return q((o)=>{while(!0){let f=h.next();if(f.done)return!1;let c=f.value[0],_=f.value[1];if(t.call(e,_,c,r))return o[0]=s?c:u++,o[1]=_,!0}})},O(this,i)}partition(t,e){let r=z(this),s=[[],[]];return this.__iterate((i,n)=>{s[t.call(e,i,n,this)?1:0].push(r?[n,i]:i)}),s.map((i)=>Zn(this,i))}find(t,e,r){let s=this.findEntry(t,e);return s?s[1]:r}forEach(t,e){return U(this.size),this.__iterate(e?t.bind(e):t)}join(t){U(this.size),t=t!==void 0?String(t):",";let e="",r=!0;return this.__iterate((s)=>{if(r)r=!1;else e+=t;e+=s!==null&&s!==void 0?String(s):""}),e}keys(){let t=this.__iterator(),e={done:!1,value:void 0};return D(()=>{let r=t.next();if(r.done)return K;return e.value=r.value[0],e})}map(t,e){return O(this,Un(this,t,e))}reduce(t,e=g,r){return Ci(this,t,e,r,e===g,!1)}reduceRight(t,e=g,r){return Ci(this,t,e,r,e===g,!0)}reverse(){return O(this,Kn(this,z(this)))}slice(t,e){return O(this,In(this,t,e,z(this)))}some(t,e){U(this.size);let r=!1;return this.__iterate((s,i,n)=>{if(t.call(e,s,i,n))return r=!0,!1}),r}sort(t){return O(this,It(this,t))}values(){let t=this.__iterator(),e={done:!1,value:void 0};return D(()=>{let r=t.next();if(r.done)return K;return e.value=r.value[1],e})}butLast(){return this.slice(0,-1)}isEmpty(){return this.size!==void 0?this.size===0:!this.some(()=>!0)}count(t,e){return Lt(t?this.toSeq().filter(t,e):this)}countBy(t,e){throw Error("countBy: not patched — import CollectionConversions")}entrySeq(){let t=this;if(t._cache)return new le(t._cache);let e=t.toSeq().map(yu).toIndexedSeq();return e.fromEntrySeq=()=>t.toSeq(),e}filterNot(t,e){return this.filter(is(t),e)}findEntry(t,e,r){let s=r;return this.__iterate((i,n,h)=>{if(t.call(e,i,n,h))return s=[n,i],!1}),s}findKey(t,e){let r=this.findEntry(t,e);return r&&r[0]}findLast(t,e,r){return this.toKeyedSeq().reverse().find(t,e,r)}findLastEntry(t,e,r){return this.toKeyedSeq().reverse().findEntry(t,e,r)}findLastKey(t,e){return this.toKeyedSeq().reverse().findKey(t,e)}first(t){return this.find(pn,null,t)}flatMap(t,e){return O(this,this.toSeq().map((r,s)=>(z(this)?Y:$(this)?wt:pt)(t.call(e,r,s,this))).flatten(!0))}flatten(t){let e=this,r=z(this),s=C(e);return s.__iterateUncached=function(i,n){if(n)return this.cacheResult().__iterate(i,n);let h=0,u=!1;function o(f,c){f.__iterate((_,l)=>{if((!t||c<t)&&T(_))o(_,c+1);else if(h++,i(_,r?l:h-1,s)===!1)u=!0;if(u)return!1},n)}return o(e,0),h},s.__iteratorUncached=function(i){if(i)return this.cacheResult().__iterator(i);let n=0,h=[{iterator:e.__iterator(i),depth:0}];return q((u)=>{while(h.length>0){let o=h[h.length-1],f=o.iterator.next();if(f.done){h.pop();continue}let c=f.value[1];if((!t||o.depth<t)&&T(c)){h.push({iterator:c.__iterator(i),depth:o.depth+1});continue}return u[0]=r?f.value[0]:n++,u[1]=c,!0}return!1})},O(this,s)}fromEntrySeq(){return new Bn(this)}get(t,e){return this.find((r,s)=>A(s,t),void 0,e)}getIn(t,e){return Es(this,t,e)}groupBy(t,e){throw Error("groupBy: not patched — import CollectionConversions")}has(t){return this.get(t,g)!==g}hasIn(t){return Dn(this,t)}isSubset(t){let e=typeof t.includes==="function"?t:m(t);return this.every((r)=>e.includes(r))}isSuperset(t){return(typeof t.isSubset==="function"?t:m(t)).isSubset(this)}keyOf(t){return this.findKey((e)=>A(e,t))}keySeq(){return this.toSeq().map(au).toIndexedSeq()}last(t){return this.toSeq().reverse().first(t)}lastKeyOf(t){return this.toKeyedSeq().reverse().keyOf(t)}max(t){return Pe(this,t)}maxBy(t,e){return Pe(this,e,t)}min(t){return Pe(this,t?xi(t):Fi)}minBy(t,e){return Pe(this,e?xi(e):Fi,t)}rest(){return this.slice(1)}skip(t){return t===0?this:this.slice(Math.max(0,t))}skipLast(t){return t===0?this:this.slice(0,-Math.max(0,t))}skipWhile(t,e){let r=this,s=z(this),i=C(r);return i.__iterateUncached=function(n,h){if(h)return this.cacheResult().__iterate(n,h);let u=!0,o=0;return r.__iterate((f,c)=>{if(u&&t.call(e,f,c,this))return;return u=!1,o++,n(f,s?c:o-1,this)},h),o},i.__iteratorUncached=function(n){if(n)return this.cacheResult().__iterator(n);let h=r.__iterator(n),u=0,o=this,f=!0;return q((c)=>{while(!0){let _=h.next();if(_.done)return!1;let l=_.value[0],a=_.value[1];if(f&&t.call(e,a,l,o))continue;return f=!1,c[0]=s?l:u++,c[1]=a,!0}})},O(this,i)}skipUntil(t,e){return this.skipWhile(is(t),e)}sortBy(t,e){return O(this,It(this,e,t))}take(t){return this.slice(0,Math.max(0,t))}takeLast(t){return this.slice(-Math.max(0,t))}takeWhile(t,e){let r=this,s=C(r);return s.__iterateUncached=function(i,n){if(n)return this.cacheResult().__iterate(i,n);let h=0;return r.__iterate((u,o)=>{if(!t.call(e,u,o,this))return!1;return h++,i(u,o,this)},n),h},s.__iteratorUncached=function(i){if(i)return this.cacheResult().__iterator(i);let n=r.__iterator(i),h=this,u=!1;return D(()=>{if(u)return K;let o=n.next();if(o.done)return o;if(!t.call(e,o.value[1],o.value[0],h))return u=!0,K;return o})},O(this,s)}takeUntil(t,e){return this.takeWhile(is(t),e)}update(t){return t(this)}valueSeq(){return this.toIndexedSeq()}__iterate(t,e=!1){let r=this.__iterator(e),s=0,i;while(!(i=r.next()).done)if(s++,t(i.value[1],i.value[0],this)===!1)break;return s}__iterator(t=!1){throw Error("CollectionImpl does not implement __iterator. Use a subclass instead.")}}var Y=(t)=>z(t)?t:Us(t);class $s extends b{static{this.prototype[ke]=!0,this.prototype.__toStringMapper=(t,e)=>`${vt(e)}: ${vt(t)}`,this.prototype[Symbol.iterator]=b.prototype.entries,this.prototype.toJSON=function(){U(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}}flip(){return O(this,An(this))}mapEntries(t,e){let r=0;return O(this,this.toSeq().map((s,i)=>t.call(e,[i,s],r++,this)).fromEntrySeq())}mapKeys(t,e){return O(this,this.toSeq().flip().map((r,s)=>t.call(e,r,s,this)).flip())}}var wt=(t)=>$(t)?t:yt(t);class at extends b{static{this.prototype[Ve]=!0,this.prototype[nt]=!0}toKeyedSeq(){return new Js(this,!1)}findIndex(t,e){let r=this.findEntry(t,e);return r?r[0]:-1}indexOf(t){let e=this.keyOf(t);return e===void 0?-1:e}lastIndexOf(t){let e=this.lastKeyOf(t);return e===void 0?-1:e}splice(t,e=g,...r){if(t===void 0)return this;let s=e!==g;if(e=s?Math.max(e||0,0):0,s&&!e&&r.length===0)return this;t=Rt(t,t<0?this.count():this.size);let i=this.slice(0,t);return O(this,!s?i:i.concat(r,this.slice(t+e)))}findLastIndex(t,e){let r=this.findLastEntry(t,e);return r?r[0]:-1}first(t){return this.get(0,t)}get(t,e){return t=it(this,t),t<0||this.size===1/0||this.size!==void 0&&t>this.size?e:this.find((r,s)=>s===t,void 0,e)}has(t){return t=it(this,t),t>=0&&(this.size!==void 0?this.size===1/0||t<this.size:this.indexOf(t)!==-1)}interpose(t){let e=this,r=C(e);return r.size=e.size&&e.size*2-1,r.__iterateUncached=function(s,i){let n=0,h=!0;return e.__iterate((u)=>{if(!h){if(s(t,n++,this)===!1)return!1}return h=!1,s(u,n++,this)},i),n},r.__iteratorUncached=function(s){let i=e.__iterator(s),n=0,h=!0,u,o=!1;return q((f)=>{if(o)return o=!1,f[0]=n++,f[1]=u,!0;let c=i.next();if(c.done)return!1;let _=c.value[1];if(!h)return u=_,o=!0,f[0]=n++,f[1]=t,!0;return h=!1,f[0]=n++,f[1]=_,!0})},O(this,r)}interleave(...t){let e=[this,...t],r=ns(this.toSeq(),yt.of,e),s=r.flatten(!0);if(r.size)s.size=r.size*e.length;return O(this,s)}keySeq(){throw Error("keySeq: not patched — import CollectionConversions")}last(t){return this.get(-1,t)}zip(...t){return this.zipWith(en,...t)}zipAll(...t){let e=[this,...t];return O(this,ns(this,en,e,!0))}zipWith(t,...e){let r=[this,...e];return O(this,ns(this,t,r))}}var pt=(t)=>T(t)&&!Ss(t)?t:te(t);class hr extends b{static{this.prototype.has=b.prototype.includes,this.prototype.contains=b.prototype.includes,this.prototype.keys=hr.prototype.values}get(t,e){return this.has(t)?t:e}includes(t){return this.has(t)}keySeq(){return this.valueSeq()}}m.Keyed=Y;m.Indexed=wt;m.Set=pt;var fs=at.prototype,v=(t)=>t===void 0||t===null?Ls():P(t)?t.toSeq():Uu(t),C=(t)=>Object.create((z(t)?Zt:$(t)?zt:Ks).prototype);class _t extends b{static{this.prototype[_e]=!0}toSeq(){return this}toString(){return this.__toString("Seq {","}")}cacheResult(){if(!this._cache&&this.__iterateUncached)this._cache=this.entrySeq().toArray(),this.size=this._cache.length;return this}__iterateUncached(t,e){let r=this.__iteratorUncached(e),s=0,i;while(!(i=r.next()).done)if(s++,t(i.value[1],i.value[0],this)===!1)break;return s}__iterate(t,e){let r=this._cache;if(r){let s=r.length,i=0;while(i!==s){let n=r[e?s-++i:i++];if(t(n[1],n[0],this)===!1)break}return i}return this.__iterateUncached(t,e)}__iterator(t){let e=this._cache;if(e){let r=e.length,s=0,i={done:!1,value:void 0};return D(()=>{if(s===r)return K;return i.value=e[t?r-++s:s++],i})}return this.__iteratorUncached(t)}}var As={cacheResult:_t.prototype.cacheResult,__iterateUncached:_t.prototype.__iterateUncached,__iterate:_t.prototype.__iterate,__iterator:_t.prototype.__iterator},Us=(t)=>t===void 0||t===null?Ls().toKeyedSeq():T(t)?z(t)?t.toSeq():t.fromEntrySeq():gt(t)?t.toSeq():Xn(t);class Zt extends $s{static{this.prototype[_e]=!0,Object.assign(this.prototype,As)}toSeq(){return this}toKeyedSeq(){return this}}var yt=(t)=>t===void 0||t===null?Ls():T(t)?z(t)?t.entrySeq():t.toIndexedSeq():gt(t)?t.toSeq().entrySeq():Hn(t);yt.of=(...t)=>yt(t);class zt extends at{static{this.prototype[_e]=!0,Object.assign(this.prototype,As)}toSeq(){return this}toIndexedSeq(){return this}toString(){return this.__toString("Seq [","]")}}var te=(t)=>(T(t)&&!Ss(t)?t:yt(t)).toSetSeq();te.of=(...t)=>te(t);class Ks extends hr{static{this.prototype[_e]=!0,Object.assign(this.prototype,As)}toSeq(){return this}toSetSeq(){return this}}v.isSeq=ds;v.Keyed=Us;v.Set=te;v.Indexed=yt;class le extends zt{constructor(t){super();this._array=t,this.size=t.length}get(t,e){return this.has(t)?this._array[it(this,t)]:e}__iterateUncached(t,e){let r=this._array,s=r.length,i=0;while(i!==s){let n=e?s-++i:i++;if(t(r[n],n,this)===!1)break}return i}__iteratorUncached(t){let e=this._array,r=e.length,s=0;return q((i)=>{if(s===r)return!1;let n=t?r-++s:s++;return i[0]=n,i[1]=e[n],!0})}}class Is extends Zt{static{this.prototype[nt]=!0}constructor(t){super();let e=[...Object.keys(t),...Object.getOwnPropertySymbols(t)];this._object=t,this._keys=e,this.size=e.length}get(t,e){if(e!==void 0&&!this.has(t))return e;return this._object[t]}has(t){return Object.hasOwn(this._object,t)}__iterateUncached(t,e){let r=this._object,s=this._keys,i=s.length,n=0;while(n!==i){let h=s[e?i-++n:n++];if(t(r[h],h,this)===!1)break}return n}__iteratorUncached(t){let e=this._object,r=this._keys,s=r.length,i=0;return q((n)=>{if(i===s)return!1;let h=r[t?s-++i:i++];return n[0]=h,n[1]=e[h],!0})}}class Tn extends zt{constructor(t){super();this._collection=t,this.size=t.length||t.size}__iterateUncached(t,e){if(e)return this.cacheResult().__iterate(t,e);let r=0;for(let s of this._collection){if(t(s,r,this)===!1)break;r++}return r}__iteratorUncached(t){if(t)return this.cacheResult().__iterator(t);let e=this._collection,r=wn(e);if(!wu(r))return ct();let s=0;return q((i)=>{let n=r.next();if(n.done)return!1;return i[0]=s++,i[1]=n.value,!0})}}var Ls=()=>new le([]),Ws=(t)=>qs(t)?new le(t):zs(t)?new Tn(t):void 0;function Xn(t){let e=Ws(t);if(e)return e.fromEntrySeq();if(typeof t==="object")return new Is(t);throw TypeError(`Expected Array or collection object of [k, v] entries, or keyed object: ${t}`)}function Hn(t){let e=Ws(t);if(e)return e;throw TypeError(`Expected Array or collection object of values: ${t}`)}function Uu(t){let e=Ws(t);if(e)return pu(t)?e.fromEntrySeq():zu(t)?e.toSetSeq():e;if(typeof t==="object")return new Is(t);throw TypeError(`Expected Array or collection object of values, or keyed object: ${t}`)}class Qn extends _t{constructor(t){super();let e=[],r=0,s=!0;for(let n of t)if(n._wrappedIterables){for(let h of n._wrappedIterables)if(e.push(h),s){let u=h.size;if(u!==void 0)r+=u;else s=!1}}else if(e.push(n),s){let h=n.size;if(h!==void 0)r+=h;else s=!1}this._wrappedIterables=e,this.size=s?r:void 0;let i=this._wrappedIterables[0];if(i[ke])this[ke]=!0;if(i[Ve])this[Ve]=!0;if(i[nt])this[nt]=!0}__iterateUncached(t,e){if(this._wrappedIterables.length===0)return 0;if(e)return this.cacheResult().__iterate(t,e);let r=this._wrappedIterables,s=!z(this),i=0,n=!1;for(let h of r)if(h.__iterate((u,o)=>{if(t(u,s?i++:o,this)===!1)return n=!0,!1},e),n)break;return i}__iteratorUncached(t){if(this._wrappedIterables.length===0)return ct();if(t)return this.cacheResult().__iterator(t);let e=this._wrappedIterables,r=!z(this),s=0,i=e[0].__iterator(t);function n(){while(s<e.length){let h=i.next();if(!h.done)return h;if(s++,s<e.length)i=e[s].__iterator(t)}return}if(r){let h=0;return q((u)=>{let o=n();if(!o)return!1;return u[0]=h++,u[1]=o.value[1],!0})}return D(()=>n()||K)}}class Js extends Zt{static{this.prototype[nt]=!0}constructor(t,e){super();this._iter=t,this._useKeys=e,this.size=t.size}cacheResult(){return Tt.call(this)}get(t,e){return this._iter.get(t,e)}has(t){return this._iter.has(t)}valueSeq(){return this._iter.valueSeq()}reverse(){let t=Kn(this,!0);if(!this._useKeys)t.valueSeq=()=>this._iter.toSeq().reverse();return t}map(t,e){let r=Un(this,t,e);if(!this._useKeys)r.valueSeq=()=>this._iter.toSeq().map(t,e);return r}__iterateUncached(t,e){return this._iter.__iterate(t,e)}__iteratorUncached(t){return this._iter.__iterator(t)}}class Gn extends zt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Tt.call(this)}includes(t){return this._iter.includes(t)}__iterateUncached(t,e){let r=0;if(e)Lt(this);let s=this.size;return this._iter.__iterate((i)=>{let n=e?s-++r:r++;return t(i,n,this)},e),r}__iteratorUncached(t){let e=0;if(t)Lt(this);let r=this.size;return ue(this._iter.__iterator(t),(s,i,n)=>{n[0]=t?r-++e:e++,n[1]=i})}}class Yn extends Ks{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Tt.call(this)}has(t){return this._iter.includes(t)}__iterateUncached(t,e){return this._iter.__iterate((r)=>t(r,r,this),e)}__iteratorUncached(t){return ue(this._iter.__iterator(t),(e,r,s)=>{s[0]=r,s[1]=r})}}class Bn extends Zt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Tt.call(this)}entrySeq(){return this._iter.toSeq()}__iterateUncached(t,e){let r=0;return this._iter.__iterate((s)=>{if(s){rn(s),r++;let i=T(s);return t(i?s.get(1):s[1],i?s.get(0):s[0],this)}},e),r}__iteratorUncached(t){let e=this._iter.__iterator(t);return q((r)=>{while(!0){let s=e.next();if(s.done)return!1;let i=s.value[1];if(i){rn(i);let n=T(i);return r[0]=n?i.get(0):i[0],r[1]=n?i.get(1):i[1],!0}}})}}function Tt(){if(this._iter.cacheResult)return this._iter.cacheResult(),this.size=this._iter.size,this;return _t.prototype.cacheResult.call(this)}function rn(t){if(t!==Object(t))throw TypeError(`Expected [K, V] tuple: ${t}`)}var R=(t)=>t===void 0||t===null?B():ir(t)&&!x(t)?t:B().withMutations((e)=>{let r=Y(t);U(r.size),r.forEach((s,i)=>e.set(i,s))});class ee extends $s{static{dt(this,{asImmutable:ge,asMutable:we,deleteIn:Wt,merge:ys,mergeWith:Nn,mergeDeep:vn,mergeDeepWith:th,mergeDeepIn:Ps,mergeIn:Bs,setIn:Qs,update:Gs,updateIn:Ys,wasAltered:Hs,withMutations:pe,removeIn:Wt,concat:ys,[Mn]:!0,[oe]:this.prototype.remove,removeAll:this.prototype.deleteAll,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Map"})}constructor(t,e,r,s){super();this.size=t,this._root=e,this.__ownerID=r,this.__hash=s,this.__altered=!1}create(t){return R(t)}toString(){return this.__toString("Map {","}")}get(t,e){return this._root?this._root.get(0,G(t),t,e):e}set(t,e){return nn(this,t,e)}remove(t){return nn(this,t,g)}deleteAll(t){let e=m(t);if(e.size===0)return this;return this.withMutations((r)=>{e.forEach((s)=>r.remove(s))})}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this;return B()}map(t,e){return this.withMutations((r)=>{r.forEach((s,i)=>{r.set(i,t.call(e,s,i,this))})})}keys(){if(!this._root)return ct();return Ce(this._root,!1,0)}values(){if(!this._root)return ct();return Ce(this._root,!1,1)}entries(){if(!this._root)return ct();return Ce(this._root,!1)}__iterator(t){if(!this._root)return ct();return Ce(this._root,t)}__iterate(t,e){let r=0;if(this._root)this._root.iterate(([s,i])=>{return r++,t(i,s,this)},e);return r}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return B();return this.__ownerID=t,this.__altered=!1,this}return Zs(this.size,this._root,t,this.__hash)}}R.isMap=ir;class Ds{constructor(t,e){this.ownerID=t,this.entries=e}get(t,e,r,s){return Pn(this.entries,r,s)}iterate(t,e){return Cn(this.entries,t,e)}update(t,e,r,s,i,n,h){let u=i===g,o=this.entries,f=0,c=o.length;for(;f<c;f++)if(A(s,o[f][0]))break;let _=f<c;if(_?o[f][1]===i:u)return this;if(H(h),u||!_)H(n);if(u&&c===1)return;if(!_&&!u&&c>=Du)return Ku(t,o,s,i);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(f===c-1)a.pop();else a[f]=a.pop();else a[f]=[s,i];else a.push([s,i]);if(l)return this.entries=a,this;return new Ds(t,a)}}class ur{constructor(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}iterate(t,e){return xn(this.nodes,t,e)}get(t,e,r,s){let i=1<<((t===0?e:e>>>t)&I),n=this.bitmap;return(n&i)===0?s:this.nodes[un(n&i-1)].get(t+S,e,r,s)}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&I,o=1<<u,f=this.bitmap,c=(f&o)!==0;if(!c&&i===g)return this;let _=un(f&o-1),l=this.nodes,a=c?l[_]:void 0,y=Ts(a,t,e+S,r,s,i,n,h);if(y===a)return this;if(!c&&y&&l.length>=Ru)return Lu(t,l,f,u,y);if(c&&!y&&l.length===2&&hn(l[_^1]))return l[_^1];if(c&&y&&l.length===1&&hn(y))return y;let p=t&&t===this.ownerID,d=c?y?f:f^o:f|o,j=c?y?Fn(l,_,y,p):Ju(l,_,p):Wu(l,_,y,p);if(p)return this.bitmap=d,this.nodes=j,this;return new ur(t,d,j)}}class Rs{constructor(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}iterate(t,e){return xn(this.nodes,t,e)}get(t,e,r,s){let i=(t===0?e:e>>>t)&I,n=this.nodes[i];return n?n.get(t+S,e,r,s):s}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&I,o=i===g,f=this.nodes,c=f[u];if(o&&!c)return this;let _=Ts(c,t,e+S,r,s,i,n,h);if(_===c)return this;let l=this.count;if(!c)l++;else if(!_){if(l--,l<Zu)return Iu(t,f,l,u)}let a=t&&t===this.ownerID,y=Fn(f,u,_,a);if(a)return this.count=l,this.nodes=y,this;return new Rs(t,l,y)}}class or{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}get(t,e,r,s){return Pn(this.entries,r,s)}iterate(t,e){return Cn(this.entries,t,e)}update(t,e,r,s,i,n,h){if(r!==this.keyHash){if(i===g)return this;return H(h),H(n),Xs(this,t,e,r,[s,i])}let u=i===g,o=this.entries,f=0,c=o.length;for(;f<c;f++)if(A(s,o[f][0]))break;let _=f<c;if(_?o[f][1]===i:u)return this;if(H(h),u||!_)H(n);if(u&&c===2)return new St(t,this.keyHash,o[f^1]);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(f===c-1)a.pop();else a[f]=a.pop();else a[f]=[s,i];else a.push([s,i]);if(l)return this.entries=a,this;return new or(t,this.keyHash,a)}}class St{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entry=r}iterate(t,e){return t(this.entry)}get(t,e,r,s){return A(r,this.entry[0])?this.entry[1]:s}update(t,e,r,s,i,n,h){let u=i===g,o=A(s,this.entry[0]);if(o?i===this.entry[1]:u)return this;if(H(h),u){H(n);return}if(o){if(t&&t===this.ownerID)return this.entry[1]=i,this;return new St(t,this.keyHash,[s,i])}return H(n),Xs(this,t,e,G(s),[s,i])}}function Pn(t,e,r){for(let s=0,i=t.length;s<i;s++)if(A(e,t[s][0]))return t[s][1];return r}function Cn(t,e,r){for(let s=0,i=t.length-1;s<=i;s++)if(e(t[r?i-s:s])===!1)return!1}function xn(t,e,r){for(let s=0,i=t.length-1;s<=i;s++)if(t[r?i-s:s]?.iterate(e,r)===!1)return!1}function Ce(t,e,r){let s={node:t,index:0,__prev:null},i=r!==void 0?(h)=>h[r]:(h)=>h,n={done:!1,value:void 0};return D(()=>{while(s){let h=s.node,u=s.index++,o;if(h.entry){if(u===0)return n.value=i(h.entry),n}else if(h.entries){if(o=h.entries.length-1,u<=o)return n.value=i(h.entries[e?o-u:u]),n}else if(o=h.nodes.length-1,u<=o){let f=h.nodes[e?o-u:u];if(f){if(f.entry)return n.value=i(f.entry),n;s={node:f,index:0,__prev:s}}continue}s=s.__prev}return K})}var Zs=(t,e,r,s)=>new ee(t,e,r,s),sn,B=()=>sn||(sn=Zs(0));function nn(t,e,r){let s,i;if(!t._root){if(r===g)return t;i=1,s=new Ds(t.__ownerID,[[e,r]])}else{let n=ls(),h=ls();if(s=Ts(t._root,t.__ownerID,0,G(e),e,r,n,h),!h.value)return t;i=t.size+(n.value?r===g?-1:1:0)}if(t.__ownerID)return t.size=i,t._root=s,t.__hash=void 0,t.__altered=!0,t;return s?Zs(i,s):B()}function Ts(t,e,r,s,i,n,h,u){if(!t){if(n===g)return t;return H(u),H(h),new St(e,s,[i,n])}return t.update(e,r,s,i,n,h,u)}var hn=(t)=>t.constructor===St||t.constructor===or;function Xs(t,e,r,s,i){if(t.keyHash===s)return new or(e,s,[t.entry,i]);let n=(r===0?t.keyHash:t.keyHash>>>r)&I,h=(r===0?s:s>>>r)&I,u=new St(e,s,i),o=n===h?[Xs(t,e,r+S,s,i)]:n<h?[t,u]:[u,t];return new ur(e,1<<n|1<<h,o)}function Ku(t,e,r,s){if(!t)t=new sr;let i=new St(t,G(r),[r,s]);for(let[n,h]of e)i=i.update(t,0,G(n),n,h);return i}function Iu(t,e,r,s){let i=0,n=0,h=Array(r);for(let u=0,o=1,f=e.length;u<f;u++,o<<=1){let c=e[u];if(c!==void 0&&u!==s)i|=o,h[n++]=c}return new ur(t,i,h)}function Lu(t,e,r,s,i){let n=0,h=Array(E);for(let u=0;r!==0;u++,r>>>=1)h[u]=r&1?e[n++]:void 0;return h[s]=i,new Rs(t,n+1,h)}function un(t){return t-=t>>1&1431655765,t=(t&858993459)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,t+=t>>16,t&127}function Fn(t,e,r,s){let i=s?t:t.slice();return i[e]=r,i}function Wu(t,e,r,s){let i=t.length+1;if(s&&e+1===i)return t[e]=r,t;let n=Array(i),h=0;for(let u=0;u<i;u++)if(u===e)n[u]=r,h=-1;else n[u]=t[u+h];return n}function Ju(t,e,r){let s=t.length-1;if(r&&e===s)return t.pop(),t;let i=Array(s),n=0;for(let h=0;h<s;h++){if(h===e)n=1;i[h]=t[h+n]}return i}var Du=E/4,Ru=E/2,Zu=E/4;function me(t){if(Array.isArray(t))return t.slice();return{...t}}var Jf=(t,...e)=>ye(t,e),Df=(t,e,...r)=>ye(e,r,t),ae=(t,e,r)=>ye(t,e,Tu(r)),Rf=(t,...e)=>ae(t,e),Zf=(t,e,...r)=>ae(e,r,t);function ye(t,e,r){if(!ht(t))throw TypeError(`Cannot merge into non-data-structure value: ${t}`);if(P(t))return typeof r==="function"&&t.mergeWith?t.mergeWith(r,...e):t.merge?t.merge(...e):t.concat(...e);let s=Array.isArray(t),i=t,n=s?wt:Y,h=s?(u)=>{if(i===t)i=me(i);i.push(u)}:(u,o)=>{let f=Object.hasOwn(i,o),c=f&&r?r(i[o],u,o):u;if(!f||c!==i[o]){if(i===t)i=me(i);i[o]=c}};for(let u of e)n(u).forEach(h);return i}function Tu(t){function e(r,s,i){return ht(r)&&ht(s)&&Xu(r,s)?ye(r,[s],e):t?t(r,s,i):s}return e}function Xu(t,e){let r=v(t),s=v(e);return $(r)===$(s)&&z(r)===z(s)}function Hu(t,e){if(!ht(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(P(t)){if(!t.remove)throw TypeError(`Cannot update immutable value without .remove() method: ${t}`);return t.remove(e)}if(!Object.hasOwn(t,e))return t;let r=me(t);if(Array.isArray(r))r.splice(e,1);else delete r[e];return r}function Qu(t,e,r){if(!ht(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(P(t)){if(!t.set)throw TypeError(`Cannot update immutable value without .set() method: ${t}`);return t.set(e,r)}if(Object.hasOwn(t,e)&&r===t[e])return t;let s=me(t);return s[e]=r,s}function Xt(t,e,r,s){if(!s)s=r,r=void 0;let i=kn(P(t),t,Wn(e),0,r,s);return i===g?r:i}function kn(t,e,r,s,i,n){let h=e===g;if(s===r.length){let _=h?i:e,l=n(_);return l===_?e:l}if(!h&&!ht(e))throw TypeError(`Cannot update within non-data-structure value in path [${Array.from(r).slice(0,s).map(vt)}]: ${e}`);let u=r[s],o=h?g:Jn(e,u,g),f=kn(o===g?t:P(o),o,r,s+1,i,n);if(f===o)return e;if(f===g)return Hu(e,u);let c=h?t?B():{}:e;return Qu(c,u,f)}var Gu=(t,e)=>Xt(t,e,()=>g),Yu=(t,e,r)=>Xt(t,e,g,()=>r);function Vn(t,e,r,s){return Xt(t,[e],r,s)}function ge(){return this.__ensureOwner()}function we(){return this.__ownerID?this:this.__ensureOwner(new sr)}function Hs(){return this.__altered}function pe(t){let e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Bu(t,e){return Es(this,t,e)}function Pu(t){return Dn(this,t)}function Wt(t){return Gu(this,t)}function Qs(t,e){return Yu(this,t,e)}function Gs(t,e,r){return typeof t==="function"?t(this):Vn(this,t,e,r)}function Ys(t,e,r){return Xt(this,t,e,r)}function on(){U(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}function ys(...t){return mn(this,t)}function Nn(t,...e){if(typeof t!=="function")throw TypeError(`Invalid merger function: ${t}`);return mn(this,e,t)}function mn(t,e,r){let s=[];for(let i of e){let n=Y(i);if(n.size!==0)s.push(n)}if(s.length===0)return t;if(t.toSeq().size===0&&!t.__ownerID&&s.length===1)return gt(t)?t:t.create(s[0]);return t.withMutations((i)=>{let n=r?(h,u)=>{Vn(i,u,g,(o)=>o===g?h:r(o,h,u))}:(h,u)=>{i.set(u,h)};for(let h of s)h.forEach(n)})}function vn(...t){return ae(this,t)}function th(t,...e){return ae(this,e,t)}function Bs(t,...e){return Xt(this,t,B(),(r)=>ye(r,e))}function Ps(t,...e){return Xt(this,t,B(),(r)=>ae(r,e))}function dt(t,e){Object.assign(t.prototype,e)}var L=(t)=>{let e=re();if(t===void 0||t===null)return e;if(jn(t))return t;let r=wt(t),s=r.size;if(s===0)return e;if(U(s),s>0&&s<E)return ze(0,s,S,null,new lt(r.toArray()));return e.withMutations((i)=>{i.setSize(s),r.forEach((n,h)=>i.set(h,n))})};L.of=(...t)=>L(t);class eh extends at{static{dt(this,{asImmutable:ge,asMutable:we,deleteIn:Wt,mergeDeepIn:Ps,mergeIn:Bs,setIn:Qs,update:Gs,updateIn:Ys,wasAltered:Hs,withMutations:pe,removeIn:Wt,[On]:!0,[oe]:this.prototype.remove,merge:this.prototype.concat,[Symbol.toStringTag]:"Immutable.List",[Symbol.iterator]:this.prototype.values})}constructor(t,e,r,s,i,n,h){super();this.size=e-t,this._origin=t,this._capacity=e,this._level=r,this._root=s,this._tail=i,this.__ownerID=n,this.__hash=h,this.__altered=!1}create(t){return L(t)}toString(){return this.__toString("List [","]")}get(t,e){if(t=it(this,t),t>=0&&t<this.size){t+=this._origin;let r=ih(this,t);return r&&r.array[t&I]}return e}set(t,e){return xu(this,t,e)}remove(t){return!this.has(t)?this:t===0?this.shift():t===this.size-1?this.pop():this.splice(t,1)}insert(t,e){return this.splice(t,0,e)}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=this._origin=this._capacity=0,this._level=S,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this;return re()}push(...t){let e=this.size;return this.withMutations((r)=>{st(r,0,e+t.length);for(let s=0;s<t.length;s++)r.set(e+s,t[s])})}pop(){return st(this,0,-1)}unshift(...t){return this.withMutations((e)=>{st(e,-t.length);for(let r=0;r<t.length;r++)e.set(r,t[r])})}shift(){return st(this,1)}shuffle(t=Math.random){return this.withMutations((e)=>{let r=e.size,s,i;while(r)s=Math.floor(t()*r--),i=e.get(s),e.set(s,e.get(r)),e.set(r,i)})}concat(...t){let e=[];for(let r of t){let s=wt(typeof r!=="string"&&zs(r)?r:[r]);if(s.size!==0)e.push(s)}if(e.length===0)return this;if(this.size===0&&!this.__ownerID&&e.length===1)return L(e[0]);return this.withMutations((r)=>{e.forEach((s)=>s.forEach((i)=>r.push(i)))})}setSize(t){return st(this,0,t)}map(t,e){return this.withMutations((r)=>{for(let s=0;s<this.size;s++)r.set(s,t.call(e,r.get(s),s,this))})}slice(t,e){let r=this.size;if(fe(t,e,r))return this;return st(this,Rt(t,r),ce(e,r))}__iterate(t,e){let r=e?this.size:0;return Cu(this,(s)=>t(s,e?--r:r++,this),e),e?this.size-r:r}__iterator(t){let e=t?this.size:0,r=fn(this,t);return q((s)=>{let i=r.next();if(i.done)return!1;return s[0]=t?--e:e++,s[1]=i.value,!0})}values(){return fn(this,!1)}keys(){return er(this.size)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return re();return this.__ownerID=t,this.__altered=!1,this}return ze(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash)}}L.isList=jn;class lt{constructor(t,e){this.array=t,this.ownerID=e}removeBefore(t,e,r){if((r&(1<<e+S)-1)===0||this.array.length===0)return this;let s=r>>>e&I;if(s>=this.array.length)return new lt([],t);let i=s===0,n;if(e>0){let u=this.array[s];if(n=u?.removeBefore(t,e-S,r),n===u&&i)return this}if(i&&!n)return this;let h=Jt(this,t);if(!i)for(let u=0;u<s;u++)h.array[u]=void 0;if(n)h.array[s]=n;return h}removeAfter(t,e,r){if(r===(e?1<<e+S:E)||this.array.length===0)return this;let s=r-1>>>e&I;if(s>=this.array.length)return this;let i;if(e>0){let h=this.array[s];if(i=h?.removeAfter(t,e-S,r),i===h&&s===this.array.length-1)return this}let n=Jt(this,t);if(n.array.splice(s+1),i)n.array[s]=i;return n}}function fn(t,e){let{_origin:r,_capacity:s}=t,i=Dt(s),n=t._tail,h=[];o(t._root,t._level,0);let u={done:!1,value:void 0};return D(()=>{while(h.length>0){let f=h[h.length-1];if(f.from===f.to){h.pop();continue}let c=e?--f.to:f.from++;if(f.isLeaf)return u.value=f.array?.[c],u;let _=f.array?.[c],l=f.level-S,a=f.offset+(c<<f.level);o(_,l,a)}return K});function o(f,c,_){if(c===0){let l=_===i?n?.array:f?.array,a=_>r?0:r-_,y=s-_;if(y>E)y=E;if(a!==y)h.push({array:l,from:a,to:y,isLeaf:!0})}else{let l=f?.array,a=_>r?0:r-_>>c,y=(s-_>>c)+1;if(y>E)y=E;if(a!==y)h.push({array:l,from:a,to:y,level:c,offset:_,isLeaf:!1})}}}function Cu(t,e,r){let{_origin:s,_capacity:i}=t,n=Dt(i),h=t._tail,u=t._level,o=t._root;return u===0?rh(o,0,s,i,n,h,e,r):sh(o,u,0,s,i,n,h,e,r)}function rh(t,e,r,s,i,n,h,u){let o=e===i?n?.array:t?.array,f=e>r?0:r-e,c=s-e;if(c>E)c=E;while(f!==c){let _=u?--c:f++;if(h(o?.[_])===!1)return!1}}function sh(t,e,r,s,i,n,h,u,o){let f=t?.array,c=r>s?0:s-r>>e,_=(i-r>>e)+1;if(_>E)_=E;let l=e-S;while(c!==_){let a=o?--_:c++,y=r+(a<<e);if((l===0?rh(f?.[a],y,s,i,n,h,u,o):sh(f?.[a],l,y,s,i,n,h,u,o))===!1)return!1}}var ze=(t,e,r,s,i,n,h)=>new eh(t,e,r,s,i,n,h),re=()=>ze(0,0,S);function xu(t,e,r){if(e=it(t,e),Number.isNaN(e))return t;if(e>=t.size||e<0)return t.withMutations((h)=>{if(e<0)st(h,e).set(0,r);else st(h,0,e+1).set(e,r)});e+=t._origin;let{_tail:s,_root:i}=t,n=ls();if(e>=Dt(t._capacity))s=gs(s,t.__ownerID,0,e,r,n);else i=gs(i,t.__ownerID,t._level,e,r,n);if(!n.value)return t;if(t.__ownerID)return t._root=i,t._tail=s,t.__hash=void 0,t.__altered=!0,t;return ze(t._origin,t._capacity,t._level,i,s)}function gs(t,e,r,s,i,n){let h=s>>>r&I,u=t&&h<t.array.length;if(!u&&i===void 0)return t;let o;if(r>0){let f=t&&t.array[h],c=gs(f,e,r-S,s,i,n);if(c===f)return t;return o=Jt(t,e),o.array[h]=c,o}if(u&&t.array[h]===i)return t;if(n)H(n);if(o=Jt(t,e),i===void 0&&h===o.array.length-1)o.array.pop();else o.array[h]=i;return o}function Jt(t,e){if(e&&e===t?.ownerID)return t;return new lt(t?.array.slice()??[],e)}function ih(t,e){if(e>=Dt(t._capacity))return t._tail;if(e<1<<t._level+S){let{_root:r,_level:s}=t;while(r&&s>0)r=r.array[e>>>s&I],s-=S;return r}}function st(t,e,r){if(e!==void 0)e|=0;if(r!==void 0)r|=0;let s=t.__ownerID||new sr,i=t._origin,n=t._capacity,h=i+e,u=r===void 0?n:r<0?n+r:i+r;if(h===i&&u===n)return t;if(h>=u)return t.clear();let{_level:o,_root:f}=t,c=0;while(h+c<0)f=new lt(f?.array.length?[void 0,f]:[],s),o+=S,c+=1<<o;if(c)h+=c,i+=c,u+=c,n+=c;let _=Dt(n),l=Dt(u);while(l>=1<<o+S)f=new lt(f?.array.length?[f]:[],s),o+=S;let a=t._tail,y=l<_?ih(t,u-1):l>_?new lt([],s):a;if(a&&l>_&&h<n&&a.array.length){f=Jt(f,s);let p=f;for(let d=o;d>S;d-=S){let j=_>>>d&I;p=p.array[j]=Jt(p.array[j],s)}p.array[_>>>S&I]=a}if(u<n)y=y&&y.removeAfter(s,0,u);if(h>=l)h-=l,u-=l,o=S,f=null,y=y&&y.removeBefore(s,0,h);else if(h>i||l<_){c=0;while(f){let p=h>>>o&I;if(p!==l>>>o&I)break;if(p)c+=(1<<o)*p;o-=S,f=f.array[p]}if(f&&h>i)f=f.removeBefore(s,o,h-c);if(f&&l<_)f=f.removeAfter(s,o,l-c);if(c)h-=c,u-=c}if(t.__ownerID)return t.size=u-h,t._origin=h,t._capacity=u,t._level=o,t._root=f,t._tail=y,t.__hash=void 0,t.__altered=!0,t;return ze(h,u,o,f,y)}var Dt=(t)=>t<E?0:t-1>>>S<<S,J=(t)=>t===void 0||t===null?se():bs(t)?t:se().withMutations((e)=>{let r=Y(t);U(r.size),r.forEach((s,i)=>e.set(i,s))});J.of=(...t)=>J(t);class nh extends ee{static{dt(this,{[nt]:!0,[oe]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.OrderedMap",keys:b.prototype.keys,values:b.prototype.values,__iterate:b.prototype.__iterate})}constructor(t,e,r,s){super(t?t.size:0,void 0,r,s);this._map=t,this._list=e}create(t){return J(t)}toString(){return this.__toString("OrderedMap {","}")}get(t,e){let r=this._map.get(t);return r!==void 0?this._list.get(r)[1]:e}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=0,this._map.clear(),this._list.clear(),this.__altered=!0,this;return se()}set(t,e){return cn(this,t,e)}remove(t){return cn(this,t,g)}entries(){return this.__iterator(!1)}__iterator(t){let e=this._list.__iterator(t);return q((r)=>{while(!0){let s=e.next();if(s.done)return!1;let i=s.value[1];if(i)return r[0]=i[0],r[1]=i[1],!0}})}__ensureOwner(t){if(t===this.__ownerID)return this;let e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);if(!t){if(this.size===0)return se();return this.__ownerID=t,this.__altered=!1,this._map=e,this._list=r,this}return Cs(e,r,t,this.__hash)}}J.isOrderedMap=bs;var Cs=(t,e,r,s)=>new nh(t,e,r,s),se=()=>Cs(B(),re());function cn(t,e,r){let{_map:s,_list:i}=t,n=s.get(e),h=n!==void 0,u,o;if(r===g){if(!h)return t;if(i.size>=E&&i.size>=s.size*2){let f=[];if(i.forEach((c,_)=>{if(c!==void 0&&n!==_)f.push(c)}),o=re().withMutations((c)=>{for(let _=0;_<f.length;_++)c.set(_,f[_])}),u=B().withMutations((c)=>{for(let _=0;_<f.length;_++)c.set(f[_][0],_)}),t.__ownerID)u.__ownerID=o.__ownerID=t.__ownerID}else u=s.remove(e),o=n===i.size-1?i.pop():i.set(n,void 0)}else if(h){if(r===i.get(n)[1])return t;u=s,o=i.set(n,[e,r])}else{let f=i.size;u=s.set(e,f),o=i.set(f,[e,r])}if(t.__ownerID)return t.size=u.size,t._map=u,t._list=o,t.__hash=void 0,t.__altered=!0,t;return Cs(u,o)}var ie=(t)=>t===void 0||t===null?ve():Ms(t)?t:ve().pushAll(t);ie.of=(...t)=>ie(t);class hh extends at{static{dt(this,{asImmutable:ge,asMutable:we,wasAltered:Hs,withMutations:pe,[qn]:!0,shift:this.prototype.pop,unshift:this.prototype.push,unshiftAll:this.prototype.pushAll,[Symbol.toStringTag]:"Immutable.Stack",[Symbol.iterator]:this.prototype.values})}constructor(t,e,r,s){super();this.size=t,this._head=e,this.__ownerID=r,this.__hash=s,this.__altered=!1}create(t){return ie(t)}toString(){return this.__toString("Stack [","]")}get(t,e){let r=this._head;t=it(this,t);while(r&&t--)r=r.next;return r?r.value:e}peek(){return this._head?.value}push(...t){if(t.length===0)return this;let e=this.size+t.length,r=this._head;for(let s=t.length-1;s>=0;s--)r={value:t[s],next:r};return cs(this,e,r)}pushAll(t){if(t=wt(t),t.size===0)return this;if(this.size===0&&Ms(t))return t;U(t.size);let e=this.size,r=this._head;return t.__iterate((s)=>{e++,r={value:s,next:r}},!0),cs(this,e,r)}pop(){return this.slice(1)}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this;return ve()}slice(t,e){if(fe(t,e,this.size))return this;let r=Rt(t,this.size);if(ce(e,this.size)!==this.size)return at.prototype.slice.call(this,t,e);let i=this.size-r,n=this._head;while(r--)n=n.next;return cs(this,i,n)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return ve();return this.__ownerID=t,this.__altered=!1,this}return xs(this.size,this._head,t,this.__hash)}__iterate(t,e){if(e){let i=this.toArray(),n=i.length,h=0;while(h!==n)if(t(i[n-++h],n-h,this)===!1)break;return h}let r=0,s=this._head;while(s){if(t(s.value,r++,this)===!1)break;s=s.next}return r}__iterator(t){if(t){let s=this.toArray(),i=s.length,n=0;return q((h)=>{if(n===i)return!1;let u=i-++n;return h[0]=u,h[1]=s[u],!0})}let e=0,r=this._head;return q((s)=>{if(!r)return!1;return s[0]=e++,s[1]=r.value,r=r.next,!0})}values(){let t=this._head,e={done:!1,value:void 0};return D(()=>{if(!t)return K;return e.value=t.value,t=t.next,e})}keys(){return er(this.size)}}ie.isStack=Ms;function cs(t,e,r){if(t.__ownerID)return t.size=e,t._head=r,t.__hash=void 0,t.__altered=!0,t;return xs(e,r)}var xs=(t,e,r,s)=>new hh(t,e,r,s),_n,ve=()=>_n||(_n=xs(0)),M=(t)=>t===void 0||t===null?he():Os(t)&&!x(t)?t:he().withMutations((e)=>{let r=pt(t);U(r.size),r.forEach((s)=>e.add(s))});M.of=(...t)=>M(t);M.fromKeys=(t)=>M(Y(t).keySeq());M.intersect=(t)=>{return t=m(t).toArray(),t.length?M(t.pop()).intersect(...t):he()};M.union=(t)=>{let e=m(t).toArray();return e.length?M(e.pop()).union(...e):he()};class ne extends hr{static{dt(this,{withMutations:pe,asImmutable:ge,asMutable:we,[bn]:!0,[oe]:this.prototype.remove,merge:this.prototype.union,concat:this.prototype.union,[Symbol.toStringTag]:"Immutable.Set"})}constructor(t,e){super();this.size=t?t.size:0,this._map=t,this.__ownerID=e}create(t){return M(t)}toString(){return this.__toString("Set {","}")}has(t){return this._map.has(t)}add(t){return xe(this,this._map.set(t,t))}remove(t){return xe(this,this._map.remove(t))}clear(){return xe(this,this._map.clear())}map(t,e){let r=!1,s=xe(this,this._map.mapEntries(([,i])=>{let n=t.call(e,i,i,this);if(n!==i)r=!0;return[n,n]},e));return r?s:this}union(...t){if(t=t.filter((e)=>e.size!==0),t.length===0)return this;if(this.size===0&&!this.__ownerID&&t.length===1)return M(t[0]);return this.withMutations((e)=>{for(let r of t)if(typeof r==="string")e.add(r);else pt(r).forEach((s)=>e.add(s))})}intersect(...t){return an(this,t,(e,r)=>!r.every((s)=>s.includes(e)))}subtract(...t){return an(this,t,(e,r)=>r.some((s)=>s.includes(e)))}wasAltered(){return this._map.wasAltered()}__iterator(t){return this._map.__iterator(t)}__empty(){return he()}__make(t,e){return uh(t,e)}__ensureOwner(t){if(t===this.__ownerID)return this;let e=this._map.__ensureOwner(t);if(!t){if(this.size===0)return this.__empty();return this.__ownerID=t,this._map=e,this}return this.__make(e,t)}}M.isSet=Os;var uh=(t,e)=>new ne(t,e),ln,he=()=>ln||(ln=uh(B()));function an(t,e,r){if(e.length===0)return t;return e=e.map((s)=>pt(s)),t.withMutations((s)=>{t.forEach((i)=>{if(r(i,e))s.remove(i)})})}function xe(t,e){if(t.__ownerID)return t.size=e.size,t._map=e,t;return e===t._map?t:e.size===0?t.__empty():t.__make(e)}var N=(t)=>t===void 0||t===null?ws():$n(t)?t:ws().withMutations((e)=>{let r=pt(t);U(r.size),r.forEach((s)=>e.add(s))});N.of=(...t)=>N(t);N.fromKeys=(t)=>N(Y(t).keySeq());class oh extends ne{static{dt(this,{[nt]:!0,[Symbol.toStringTag]:"Immutable.OrderedSet",zip:fs.zip,zipWith:fs.zipWith,zipAll:fs.zipAll})}create(t){return N(t)}toString(){return this.__toString("OrderedSet {","}")}__empty(){return ws()}__make(t,e){return fh(t,e)}}N.isOrderedSet=$n;var fh=(t,e)=>new oh(t,e),ws=()=>fh(se()),Tf={LeftThenRight:-1,RightThenLeft:1};function Fu(t){if(gt(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(P(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(t===null||typeof t!=="object")throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}var fr=(t,e)=>{let r;Fu(t);let s=function(h){if(h instanceof s)return h;if(!(this instanceof s))return new s(h);if(!r){r=!0;let u=Object.keys(t),o=i._indices={};i._name=e,i._keys=u,i._defaultValues=t;for(let f=0;f<u.length;f++){let c=u[f];if(o[c]=f,i[c])console.warn(`Cannot define ${Fs(this)} with property "${c}" since that property name is part of the Record API.`);else Vu(i,c)}}return this.__ownerID=void 0,this._values=L().withMutations((u)=>{u.setSize(this._keys.length),Y(h).forEach((o,f)=>{u.set(this._indices[f],o===this._defaultValues[f]?void 0:o)})}),this},i=s.prototype=Object.create(ku);if(i.constructor=s,i.create=s,e)s.displayName=e;return s};class ch{static{dt(this,{asImmutable:ge,asMutable:we,deleteIn:Wt,getIn:Bu,hasIn:Pu,merge:ys,mergeWith:Nn,mergeDeep:vn,mergeDeepWith:th,mergeDeepIn:Ps,mergeIn:Bs,setIn:Qs,toObject:on,update:Gs,updateIn:Ys,withMutations:pe,removeIn:Wt,toJSON:on,[En]:!0,[oe]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Record"})}toString(){let t=this._keys.map((e)=>`${e}: ${vt(this.get(e))}`).join(", ");return`${Fs(this)} { ${t} }`}equals(t){return this===t||gt(t)&&Kt(this).equals(Kt(t))}hashCode(){return Kt(this).hashCode()}has(t){return Object.hasOwn(this._indices,t)}get(t,e){if(!this.has(t))return e;let r=this._indices[t],s=this._values.get(r);return s===void 0?this._defaultValues[t]:s}set(t,e){if(this.has(t)){let r=this._values.set(this._indices[t],e===this._defaultValues[t]?void 0:e);if(r!==this._values&&!this.__ownerID)return _s(this,r)}return this}remove(t){return this.set(t)}clear(){let t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:_s(this,t)}wasAltered(){return this._values.wasAltered()}toSeq(){return Kt(this)}toJS(){return Ne(this)}entries(){return this.__iterator()}__iterate(t,e){return Kt(this).__iterate(t,e)}__iterator(t){return Kt(this).__iterator(t)}__ensureOwner(t){if(t===this.__ownerID)return this;let e=this._values.__ensureOwner(t);if(!t)return this.__ownerID=t,this._values=e,this;return _s(this,e,t)}}fr.isRecord=gt;var Fs=(t)=>t.constructor.displayName||t.constructor.name||"Record";class _h extends Zt{constructor(t){super();this._record=t,this.size=t._keys.length}get(t,e){return this._record.get(t,e)}has(t){return this._record.has(t)}__iterateUncached(t,e){let r=this._record,s=r._keys,i=s.length,n=0;while(n!==i){let h=e?i-++n:n++,u=s[h];if(t(r.get(u),u,this)===!1)break}return n}__iteratorUncached(t){let e=this._record,r=e._keys,s=r.length,i=0;return q((n)=>{if(i===s)return!1;let h=t?s-++i:i++,u=r[h];return n[0]=u,n[1]=e.get(u),!0})}}var Kt=(t)=>new _h(t);fr.getDescriptiveName=Fs;var ku=ch.prototype;function _s(t,e,r){let s=Object.create(Object.getPrototypeOf(t));return s._values=e,s.__ownerID=r,s}function Vu(t,e){Object.defineProperty(t,e,{get(){return this.get(e)},set(r){mt(this.__ownerID,"Cannot set on an immutable record."),this.set(e,r)}})}var ps=(t,e,r=1)=>{if(mt(r!==0,"Cannot step a Range by 0"),mt(t!==void 0,"You must define a start value when using Range"),mt(e!==void 0,"You must define an end value when using Range"),r=Math.abs(r),e<t)r=-r;let s=Math.max(0,Math.ceil((e-t)/r-1)+1);return new ks(t,e,r,s)};class ks extends zt{_start;_end;_step;constructor(t,e,r,s){super();this._start=t,this._end=e,this._step=r,this.size=s}toString(){return this.size===0?"Range []":`Range [ ${this._start}...${this._end}${this._step!==1?` by ${this._step}`:""} ]`}get(t,e){return this.has(t)?this._start+it(this,t)*this._step:e}includes(t){let e=(t-this._start)/this._step;return e>=0&&e<this.size&&e===Math.floor(e)}slice(t,e){if(fe(t,e,this.size))return this;if(t=Rt(t,this.size),e=ce(e,this.size),e<=t)return ps(0,0);return ps(this.get(t,this._end),this.get(e,this._end),this._step)}indexOf(t){let e=t-this._start;if(e%this._step===0){let r=e/this._step;if(r>=0&&r<this.size)return r}return-1}lastIndexOf(t){return this.indexOf(t)}__iterateUncached(t,e=!1){let r=this.size,s=this._step,i=e?this._start+(r-1)*s:this._start,n=0;while(n!==r){let h=i;i+=e?-s:s;let u=e?r-++n:n++;if(t(h,u,this)===!1)break}return n}__iteratorUncached(t=!1){let e=this.size,r=this._step,s=t?this._start+(e-1)*r:this._start,i=0;return q((n)=>{if(i===e)return!1;let h=s;return s+=t?-r:r,n[0]=t?e-++i:i++,n[1]=h,!0})}values(){let t=this.size,e=this._step,r=this._start,s=0,i={done:!1,value:void 0};return D(()=>{if(s===t)return K;return i.value=r,r+=e,s++,i})}keys(){return er(this.size)}equals(t){return t instanceof ks?this._start===t._start&&this._end===t._end&&this._step===t._step:js(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var Xf=(t,e)=>{let r=e===void 0?1/0:Math.max(0,e);return new tr(t,r)};class tr extends zt{constructor(t,e){super();this._value=t,this.size=e}toString(){if(this.size===0)return"Repeat []";return`Repeat [ ${this._value} ${this.size} times ]`}get(t,e){return this.has(t)?this._value:e}includes(t){return A(this._value,t)}slice(t,e){let r=this.size;return fe(t,e,r)?this:new tr(this._value,ce(e,r)-Rt(t,r))}reverse(){return this}indexOf(t){if(A(this._value,t))return 0;return-1}lastIndexOf(t){if(A(this._value,t))return this.size;return-1}__iterateUncached(t,e){let r=this.size,s=0;while(s!==r)if(t(this._value,e?r-++s:s++,this)===!1)break;return s}__iteratorUncached(t){let e=this.size,r=this._value,s=0;return q((i)=>{if(s===e)return!1;return i[0]=t?e-++s:s++,i[1]=r,!0})}values(){let t=this.size,e=this._value,r=0,s={done:!1,value:void 0};return D(()=>{if(r===t)return K;return r++,s.value=e,s})}keys(){return er(this.size)}equals(t){return t instanceof tr?this.size===t.size&&A(this._value,t._value):js(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var Hf=(t,e)=>lh([],e??Nu,t,"",e?.length>2?[]:void 0,{"":t});function lh(t,e,r,s,i,n){if(typeof r!=="string"&&!P(r)&&(qs(r)||zs(r)||Ln(r))){if(t.includes(r))throw TypeError("Cannot convert circular structure to Immutable");if(t.push(r),i&&s!=="")i.push(s);let h=e.call(n,s,v(r).map((u,o)=>lh(t,e,u,o,i,r)),i&&i.slice());if(t.pop(),i)i.pop();return h}return r}var Nu=(t,e)=>$(e)?e.toList():z(e)?e.toMap():e.toSet(),Fe=(t)=>z(t)?t.valueSeq():t;function mu(){b.prototype.toMap=function(){return R(this.toKeyedSeq())},b.prototype.toOrderedMap=function(){return J(this.toKeyedSeq())},b.prototype.toOrderedSet=function(){return N(Fe(this))},b.prototype.toSet=function(){return M(Fe(this))},b.prototype.toStack=function(){return ie(Fe(this))},b.prototype.toList=function(){return L(Fe(this))},b.prototype.countBy=function(e,r){let s=R().asMutable();return this.__iterate((i,n)=>{s.update(e.call(r,i,n,this),0,(h)=>h+1)}),s.asImmutable()},b.prototype.groupBy=function(e,r){let s=z(this),i=(x(this)?J():R()).asMutable();return this.__iterate((n,h)=>{i.update(e.call(r,n,h,this),(u)=>{return u??=[],u.push(s?[h,n]:n),u})}),i.map((n)=>Zn(this,n)).asImmutable()},at.prototype.keySeq=function(){return ps(0,this.size)},ee.prototype.sort=function(e){return J(It(this,e))},ee.prototype.sortBy=function(e,r){return J(It(this,r,e))},ne.prototype.sort=function(e){return N(It(this,e))},ne.prototype.sortBy=function(e,r){return N(It(this,r,e))}}var vu="7.0.0",to={version:vu};mu();var{version:Qf}=to;var ah=Symbol("BadValue"),ph=(t)=>t;class X{constructor(t,e,r,s,i=null){this.type=t,this.name=e,this.typeCheck=r,this.coercer=s,this.checks=[],this.defaultValue=i}toDataDef(){let{type:t,defaultValue:e}=this;return{type:t,defaultValue:e?.toJS?e.toJS():e}}getFirstFailingCheck(t){if(!this.typeCheck.isValid(t))return this.typeCheck;for(let e of this.checks)if(!e.isValid(t))return e;return null}isValid(t){return this.getFirstFailingCheck(t)===null}addCheck(t){return this.checks.push(t),this}coerceOr(t,e=null){if(this.isValid(t))return t;let r=this.coercer(t);return this.isValid(r)?r:e}coerceOrDefault(t){return this.coerceOr(t,this.defaultValue)}extendProtoForType(t,e){}extendProto(t){let{name:e}=this,r=e[0].toUpperCase()+e.slice(1),s=`set${r}`,i=this;t[s]=function(n){let h=i.coerceOr(n,ah);if(h===ah)return console.warn("invalid value",n),this;return this.set(e,h)},t[`update${r}`]=function(n){return this[s](n(this.get(e)))},t[`reset${r}`]=function(){return this.set(e,i.defaultValue)},t[`is${r}NotSet`]=function(){return this.get(e)==null},t[`is${r}Set`]=function(){return this.get(e)!=null},this.extendProtoForType(t,r)}}class Ns{isValid(t){return!0}getMessage(t){return"Invalid"}}class zh extends Ns{}var eo=new zh;class tt extends Ns{constructor(t,e){super();this._isValid=t,this._getMessage=e}isValid(t){return this._isValid(t)}getMessage(t){return this._getMessage(t)}}var ro=new tt((t)=>Number.isInteger(t),()=>"Integer expected"),so=new tt((t)=>Number.isFinite(t),()=>"Float expected"),io=new tt((t)=>typeof t==="boolean",()=>"Boolean expected"),no=new tt((t)=>typeof t==="string",()=>"String expected"),ho=new tt((t)=>L.isList(t),()=>"List expected"),uo=new tt((t)=>R.isMap(t),()=>"Map expected"),oo=new tt((t)=>J.isOrderedMap(t),()=>"OrderedMap expected"),fo=new tt((t)=>M.isSet(t),()=>"Set expected"),co=(t)=>!!t;class ms extends X{constructor(t,e=!1){super("bool",t,io,co,e)}extendProtoForType(t,e){let{name:r}=this;t[`toggle${e}`]=function(){return this.set(r,!this.get(r,!1))},t[`set${e}`]=function(s){return this.set(r,!!s)}}}class cr extends X{constructor(t,e=null){super("any",t,eo,ph,e)}toDataDef(){let{defaultValue:t}=this;return{type:Vs(t)??"any",defaultValue:t?.toJS?t.toJS():t}}}var _o=(t)=>t?.toString?.()??"";class vs extends X{constructor(t,e=""){super("text",t,no,_o,e)}extendProtoForType(t,e){ii(t,this.name,e,"","length")}}var lo=(t)=>Number.isFinite(t)?Math.trunc(t):null;class Sh extends X{constructor(t,e=0){super("int",t,ro,lo,e)}}var ao=(t)=>null;class ti extends X{constructor(t,e=0){super("float",t,so,ao,e)}}var Vs=(t)=>t?.constructor?.getMetaClass?.()?.name;class dh{constructor(t){this.typeName=t}isValid(t){return Vs(t)===this.typeName}getMessage(t){let e=Vs(t);return`Expected "${this.typeName}", got "${e}"`}}class Oh extends X{constructor(t,e,r){super(t,e,new dh(t),ph,null);this.args=r}toDataDef(){return{component:this.typeName,args:this.args}}}var yh=Symbol("NONE");function Ht(t,e,r){ii(t,e,r,bh),t[`setIn${r}At`]=function(s,i){return this.set(e,this.get(e).set(s,i))},t[`getIn${r}At`]=function(s,i){return this.get(e).get(s,i)},t[`updateIn${r}At`]=function(s,i){let n=this.get(e),h=n.get(s,yh);if(h!==yh)return this.set(e,n.set(s,i(h)));return console.warn("key",s,"not found in",e,n),this},Mh(t,e,`${r}At`)}function Mh(t,e,r){t[`deleteIn${r}`]=function(s){return this.set(e,this.get(e).delete(s))},t[`removeIn${r}`]=t[`deleteIn${r}`]}var bh=L(),yo=(t)=>Array.isArray(t)?L(t):null;class ei extends X{constructor(t,e=bh){super("list",t,ho,yo,e)}extendProtoForType(t,e){let{name:r}=this;Ht(t,r,e),t[`pushIn${e}`]=function(s){return this.set(r,this.get(r).push(s))},t[`insertIn${e}At`]=function(s,i){return this.set(r,this.get(r).insert(s,i))}}}var go=(t)=>R(t);class ri extends X{constructor(t,e=R()){super("map",t,uo,go,e)}extendProtoForType(t,e){Ht(t,this.name,e)}}var wo=(t)=>J(t);class si extends X{constructor(t,e=J()){super("omap",t,oo,wo,e)}extendProtoForType(t,e){Ht(t,this.name,e)}}function ii(t,e,r,s,i="size"){t[`is${r}Empty`]=function(){return this.get(e,s)[i]===0},t[`${e}Len`]=function(){return this.get(e,s)[i]}}var gh=M(),po=(t)=>Array.isArray(t)?M(t):t instanceof Set?M(t):null;class ni extends X{constructor(t,e=gh){super("set",t,fo,po,e)}extendProtoForType(t,e){let{name:r}=this;ii(t,r,e,gh),t[`addIn${e}`]=function(s){return this.set(r,this.get(r).add(s))},Mh(t,r,e),t[`hasIn${e}`]=function(s){return this.get(r).has(s)},t[`toggleIn${e}`]=function(s){let i=this.get(r);return this.set(r,i.has(s)?i.delete(s):i.add(s))}}}function wh(t,e,r){let s=e.lookupComponent(t.type);return console.assert(s!==null,"component not found",{field:t}),s?.make({...t.args,...r},{scope:e})??null}class qh{constructor(t){let e={},r=new Set;this.name=t,this.fields=e,this.compFields=r,this._methods={},this._statics={make:function(s={},i={}){let n={};for(let h in s){let u=e[h];if(r.has(h))n[h]=wh(u,i.scope,s[h]);else if(u===void 0){console.warn("extra argument to constructor:",t,h,s);continue}n[h]=u.coerceOrDefault(s[h])}for(let h of r)if(n[h]===void 0)n[h]=wh(e[h],i.scope,s[h]);return this(n)}}}build(){let t={},e={},{name:r,_methods:s,fields:i}=this;for(let u in i){let o=i[u];t[u]=o.defaultValue,o.extendProto(e)}let n={[r]:fr(t,r)}[r];Object.assign(n.prototype,e,s);let h={fields:i,name:r,methods:s};return Object.assign(n,this._statics,{getMetaClass:()=>h}),n}methods(t){return this._mergeProto(this._methods,t,"method")}statics(t){return this._mergeProto(this._statics,t,"static")}_mergeProto(t,e,r){for(let s in e)t[s]=e[s];return this}addField(t,e,r){let s=new r(t,e);return this.fields[t]=s,s}addCompField(t,e,r){let s=new Oh(e,t,r);return this.compFields.add(t),this.fields[t]=s,s}}var _r=new Map,zo={text:vs,int:Sh,float:ti,bool:ms,list:ei,map:ri,omap:si,set:ni,any:cr};function So(t,{fields:e={},methods:r,statics:s}){let i=new qh(t);for(let n in e){let h=e[n],u=typeof h;if(u==="string")i.addField(n,h,vs);else if(u==="number")i.addField(n,h,ti);else if(u==="boolean")i.addField(n,h,ms);else if(L.isList(h)||Array.isArray(h))i.addField(n,L(h),ei);else if(M.isSet(h)||h instanceof Set)i.addField(n,M(h),ni);else if(J.isOrderedMap(h))i.addField(n,h,si);else if(h?.type&&h?.defaultValue!==void 0){let o=zo[h.type]??cr;i.addField(n,new o().coerceOr(h.defaultValue),o)}else if(h?.component&&h?.args!==void 0)i.addCompField(n,h.component,h.args);else if(R.isMap(h)||h?.constructor===Object)i.addField(n,R(h),ri);else{let o=_r.get(h?.constructor)??cr;i.addField(n,h,o)}}if(r)i.methods(r);if(s)i.statics(s);return i.build()}var Oo=(t)=>new Cr(t.name??"Comp",So(t.name,t),t.view??"Not Defined",t.views,t.style,t.commonStyle??"",t.globalStyle??"",t.computed,t.input,t.logic,t.bubble,t.response,t.alter,t.dynamic,t.on);var Mo=["nid","cid","eid","vid","si","sk"];class hi{constructor(t,e,r,s,i,n,h){this.comps=t,this.h=e,this.fragment=r,this.comment=s,this.renderFn=i,this.getSeqInfo=n??Ao,this.cache=h??new Gr}setNullCache(){this.cache=new Qr}renderToDOM(t,e){let r=document.createElement("div");return this.renderFn(this.h("div",null,[this.renderRoot(t,e)]),r),r.childNodes[0]}renderToString(t,e,r=!0){let s=this.renderToDOM(t,e,this.renderFn);if(r){let i=s.querySelectorAll("[data-nid],[data-cid],[data-eid]");for(let{dataset:n}of i)for(let h of Mo)delete n[h]}return s.innerHTML}renderRoot(t,e,r=null){let s=this.comps.getCompFor(e),i=s.getView(r).anode.nodeId??null;return s?this._rValComp(t,e,s,i,"ROOT",r):null}renderIt(t,e,r,s){let i=this.comps.getCompFor(t.it);return i?this._rValComp(t,t.it,i,e,r,s):null}_rValComp(t,e,r,s,i,n){let h=`${n??t.viewsId??""}${s}-${i}`,u=this.cache.get(e,h);if(u)return u;let o=n?r.getView(n):t.lookupBestView(r.views,"main"),f=this.renderMetadata("Comp",{nid:s}),c=this.renderFragment([f,o.render(t,this)]);return this.cache.set(e,h,c),c}renderEach(t,e,r,s){let{seq:i,filter:n,loopWith:h}=e.eval(t),[u,o]=this.getSeqInfo(i),f=[],c=h.call(t.it,i);for(let[_,l]of o(i))if(n.call(t.it,_,l,c)){let a=t.enter(l,{key:_},!0),y=this.renderIt(a,r,_,s);f.push(this.renderMetadata("Each",{nid:r,[u]:_})),f.push(y)}return f}renderEachWhen(t,e,r,s){let{seq:i,filter:n,loopWith:h,enricher:u}=e.eval(t),[o,f]=this.getSeqInfo(i),c=!!u,_=[],l=h.call(t.it,i);for(let[a,y]of f(i))if(n.call(t.it,a,y,l)){let p={key:a,value:y},d=`${s}-${a}`,j;if(c)u.call(t.it,p,a,y,l),j=this.cache.get2(t.it,y,d);else j=this.cache.get(y,d);if(j){_.push(this.renderMetadata("Each",{nid:s,[o]:a})),_.push(j);continue}let bt=t.enter(y,p,!1),qt=r.render(bt,this);if(_.push(this.renderMetadata("Each",{nid:s,[o]:a})),c)this.cache.set2(t.it,y,d,qt);else this.cache.set(y,d,qt);_.push(qt)}return _}renderText(t){return t}renderMetadata(t,e){return e.$=t,this.renderComment(`§${JSON.stringify(e)}§`)}renderComment(t){return this.comment(t)}renderEmpty(t){return null}renderTag(t,e,r){return this.h(t,e,r)}renderFragment(t){return this.fragment(t)}}function*bo(t){let e=0;for(let r of t)yield[e++,r]}function*qo(t){for(let[e,r]of t.toSeq().entries())yield[e,r]}var lr=new Map,Eo=["si",bo],jo=["sk",qo],$o=["si",function*(e){}];function Ao(t){return $(t)?Eo:z(t)?jo:lr.get(t?.constructor)??$o}class Ot{constructor(t=R(),e=L()){this.items=t,this.order=e,this.$=0}_clonish(t,e){return new Ot(t,e,this.$)}toJS(){return this.order.toArray().map((t)=>this.items.get(t))}set(t,e){let r=this.items.has(t)?this.order:this.order.push(t);return this._clonish(this.items.set(t,e),r,this.$)}get(t,e=null){return this.items.get(t,e)}_nextFreeKey(){let t=this.$;while(!0){let e=`§${t}§`;if(!this.items.has(e))return[e,t];t+=1}}push(t){let[e,r]=this._nextFreeKey(),s=this.set(e,t);return s.$=r,s}get size(){return this.items.size}delete(t){if(this.items.has(t)){let e=this.order.delete(this.order.indexOf(t));return this._clonish(this.items.delete(t),e)}return this}moveKeyBeforeKey(t,e){let{order:r}=this;return this.moveKeyIndexToIndex(r.indexOf(t),r.indexOf(e),0)}moveKeyAfterKey(t,e){let{order:r}=this;return this.moveKeyIndexToIndex(r.indexOf(t),r.indexOf(e),1)}moveKeyIndexToIndex(t,e,r){if(t===-1||e===-1||t===e)return this;let{order:s}=this,i=e+r,n=i<t?t+1:t,h=s.insert(i,s.get(t)).delete(n);return this._clonish(this.items,h)}}var Uo=(t)=>null;class Eh{isValid(t){return t instanceof Ot}getMessage(t){return"KList expected"}}var Ko=new Eh;class jh extends X{constructor(t,e=new Ot){super("KList",t,Ko,Uo,e)}extendProtoForType(t,e){Ht(t,this.name,e);let{name:r}=this;Ht(t,r,e),t[`pushIn${e}`]=function(s){return this.set(r,this.get(r).push(s))}}}_r.set(Ot,jh);function*Io(t){for(let e of t.order)yield[e,t.items.get(e)]}lr.set(Ot,["data-sk",Io]);var oi=(t)=>t[4]==="-"&&(t[0]==="d"||t[0]==="a"),Se=(t)=>t!==null&&typeof t==="object";function Ah(t,e,r){for(let s in e){let i=e[s];if(i===void 0)Lo(t,s,r);else if(oi(s))t.setAttribute(s,i);else if(s==="dangerouslySetInnerHTML")t.innerHTML=i.__html??"";else if(Se(i))Wo(t,r,s,i);else if(s==="className")t.setAttribute("class",i);else t[s]=i}}function Lo(t,e,r){let s=r[e];if(e==="dangerouslySetInnerHTML")t.innerHTML="";else if(typeof s==="string"||oi(e)){let i=e==="className"?"class":e==="htmlFor"?"for":e;t.removeAttribute(i)}else t[e]=null}function Wo(t,e,r,s){let i=e?.[r];if(Se(i)&&Object.getPrototypeOf(i)!==Object.getPrototypeOf(s)){t[r]=s;return}let n=t[r];if(!Se(n))t[r]={},n=t[r];let h=n;for(let u in s)h[u]=s[u]}class Qt{isEqualTo(t){return this===t}toDom(t){return null}}var ui=(t)=>t instanceof Oe?t.key:void 0,Jo=(t)=>t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function";function fi(t,e){if(e==null)return;if(Jo(e))for(let r of e)fi(t,r);else if(e instanceof Qt)if(e instanceof ut)t.push(...e.childs);else t.push(e);else t.push(new gr(e))}class gr extends Qt{constructor(t){super();this.text=String(t)}get nodeType(){return 3}isEqualTo(t){return t instanceof gr&&this.text===t.text}toDom(t){return t.document.createTextNode(this.text)}}class de extends Qt{constructor(t){super();this.text=t}get nodeType(){return 8}isEqualTo(t){return t instanceof de&&this.text===t.text}toDom(t){return t.document.createComment(this.text)}}class ut extends Qt{constructor(t){super();this.childs=[],fi(this.childs,t)}get nodeType(){return 11}isEqualTo(t){if(!(t instanceof ut)||this.childs.length!==t.childs.length)return!1;for(let e=0;e<this.childs.length;e++)if(!this.childs[e].isEqualTo(t.childs[e]))return!1;return!0}toDom(t){let e=t.document.createDocumentFragment();for(let r of this.childs){let s=r.toDom(t);if(s)e.appendChild(s)}return e}}class Oe extends Qt{constructor(t,e,r,s,i){super();this.tag=t,this.attrs=e??{},this.childs=r??[],this.key=s!=null?String(s):void 0,this.namespace=typeof i==="string"?i:null}get nodeType(){return 1}isEqualTo(t){if(!(t instanceof Oe)||this.tag!==t.tag||this.key!==t.key||this.namespace!==t.namespace||this.childs.length!==t.childs.length)return!1;for(let e in this.attrs)if(this.attrs[e]!==t.attrs[e])return!1;for(let e in t.attrs)if(!Object.hasOwn(this.attrs,e))return!1;for(let e=0;e<this.childs.length;e++)if(!this.childs[e].isEqualTo(t.childs[e]))return!1;return!0}toDom(t){let e=t.document,r=this.namespace===null?e.createElement(this.tag):e.createElementNS(this.namespace,this.tag);Ah(r,this.attrs,{});for(let s of this.childs){let i=s.toDom(t);if(i)r.appendChild(i)}return r}}function Uh(t,e){let r=null;for(let s in t){if(!Object.hasOwn(e,s)){r??={},r[s]=void 0;continue}let i=t[s],n=e[s];if(i===n);else if(Se(i)&&Se(n))if(Object.getPrototypeOf(n)!==Object.getPrototypeOf(i))r??={},r[s]=n;else{let h=Uh(i,n);if(h)r??={},r[s]=h}else r??={},r[s]=n}for(let s in e)if(!Object.hasOwn(t,s))r??={},r[s]=e[s];return r}function Do(t,e,r){let s=t.parentNode,i=e.toDom(r);if(s&&i&&i!==t)s.replaceChild(i,t);return i||t}var ar=(t,e,r)=>t instanceof r&&e instanceof r;function Kh(t,e,r,s){if(e===r||e.isEqualTo(r))return t;if(ar(e,r,gr)||ar(e,r,de))return t.data=r.text,t;if(ar(e,r,Oe)&&e.tag===r.tag&&e.namespace===r.namespace&&e.key===r.key){let i=Uh(e.attrs,r.attrs);if(i)Ah(t,i,e.attrs);if(!r.attrs.dangerouslySetInnerHTML)$h(t,e.childs,r.childs,e.tag,s);return t}if(ar(e,r,ut))return $h(t,e.childs,r.childs,null,s),t;return Do(t,r,s)}function $h(t,e,r,s,i){if(e.length===0){for(let f of r){let c=f.toDom(i);if(c)t.appendChild(c)}return}if(r.length===0){while(t.firstChild)t.removeChild(t.firstChild);return}let n=Array.from(t.childNodes),h={};for(let f=0;f<e.length;f++){let c=ui(e[f]);if(c!=null)h[c]=f}let u=new Uint8Array(e.length),o=0;for(let f=0;f<r.length;f++){let c=r[f],_=ui(c),l=-1;if(_!=null){if(_ in h&&!u[h[_]])l=h[_]}else while(o<e.length){if(!u[o]&&ui(e[o])==null){l=o++;break}o++}if(l>=0){u[l]=1;let a=n[l],y=Kh(a,e[l],c,i),p=t.childNodes[f]??null;if(y!==p)t.insertBefore(y,p)}else{let a=c.toDom(i);if(a){let y=t.childNodes[f]??null;t.insertBefore(a,y)}}}for(let f=e.length-1;f>=0;f--)if(!u[f]&&n[f].parentNode===t)t.removeChild(n[f])}var yr=new WeakMap;function Ih(t,e,r){let s=yr.get(e),i=t instanceof ut;if(s){let h=s.vnode instanceof ut;if(h===i){let u=h?e:s.dom,o=Kh(u,s.vnode,t,r),f=i?e:o;return yr.set(e,{vnode:t,dom:f}),o}yr.delete(e)}let n=t.toDom(r);if(n){e.innerHTML="",e.appendChild(n);let h=i?e:n;yr.set(e,{vnode:t,dom:h})}return n}function Lh(t,e,r){let s=t.toUpperCase(),i={},n,h;if(e)for(let o in e){let f=e[o];switch(o){case"key":n=f;break;case"namespace":h=f;break;case"class":i.className=f;break;case"for":i.htmlFor=f;break;default:i[o]=oi(o)?String(f):f}}let u=[];return fi(u,r),new Oe(s,i,u,n,h)}var{raw:nc,raw:hc}=String;function uc(t,e){return new Dr(t,e)}var Ro=(t)=>typeof t==="string"?document.querySelector(t):t;function oc(t){let e=Ro(t),r=new Qe,s=(o)=>new ut(o),i=(o)=>new de(o),n={document},h=(o,f)=>Ih(o,f,n),u=new hi(r,Lh,s,i,h);return new ss(e,h,r,u,V)}async function zc(t,e,r="margaui-css"){let s=performance.now(),i=await Zo(t,e),n=performance.now();return Ye(r,i),n-s}async function Zo(t,e,r){t.ParseContext=Be,t.compile();let s=new Set(r??[]);for(let i of t.comps.byId.values())for(let n in i.views){let h=i.views[n];for(let u of h.ctx.classes)s.add(u)}return await e(Array.from(s))}var To="RENDER_IT_OUTSIDE_OF_LOOP",Xo="UNKNOWN_EVENT_MODIFIER",Ho="UNKNOWN_HANDLER_ARG_NAME",Qo="INPUT_HANDLER_NOT_IMPLEMENTED",Go="INPUT_HANDLER_METHOD_NOT_IMPLEMENTED",Yo="INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD",Bo="INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER",Po="FIELD_VAL_NOT_DEFINED",Co="COMPUTED_VAL_NOT_DEFINED",xo="UNKNOWN_REQUEST_NAME",Fo="UNKNOWN_COMPONENT_NAME",ko="warn",Wh="error",Vo="hint";function Ec(t,e=new Jh){sf(e,t),nf(e,t);for(let r in t.views)No(e,t.views[r],t);return e}function No(t,e,r){mo(t,e),tf(t,e),rf(t,e,r)}function mo(t,e){let{nodes:r}=e.ctx;for(let s=0;s<r.length;s++){let i=r[s];if(i instanceof Re){let n=r[s+1];if(!(n instanceof Te||n instanceof Vt))t.error(To,{node:i})}}}var vo={};function tf(t,e){for(let r of e.ctx.events)for(let s of r.handlers){let{name:i,modifiers:n}=s,h=Hr[i]??vo;for(let u of n)if(h[u]===void 0)t.warn(Xo,{name:i,modifier:u,handler:s,event:r})}}function ef(t){switch(t){case"value":case"valueAsInt":case"valueAsFloat":case"target":case"event":case"isAlt":case"isShift":case"isCtrl":case"isCmd":case"key":case"keyCode":case"isUpKey":case"isDownKey":case"isSend":case"isCancel":case"isTabKey":case"ctx":case"dragInfo":return!0;default:return!1}}function rf(t,e,r){let{computed:s,scope:i,Class:n}=r,{prototype:h}=n,{fields:u}=n.getMetaClass();for(let o of e.ctx.events)for(let f of o.handlers){let{args:c}=f.handlerCall;for(let _=0;_<c.length;_++){let l=c[_];Mt(t,l,u,h,s,i)}}}function sf(t,e){let{input:r,views:s,Class:i}=e,{prototype:n}=i;for(let h in s){let u=s[h];for(let o of u.ctx.events)for(let f of o.handlers){let{handlerVal:c}=f.handlerCall;if(c instanceof Ee){if(r[c.name]===void 0){if(t.warn(Qo,{name:c.name,handler:f,event:o}),n[c.name]!==void 0)t.hint(Bo,{name:c.name,handler:f,event:o})}}else if(c instanceof Bt){if(n[c.name]===void 0){if(t.warn(Go,{name:c.name,handler:f,event:o}),r[c.name]!==void 0)t.hint(Yo,{name:c.name,handler:f,event:o})}}}}}function Mt(t,e,r,s,i,n){if(e instanceof Ae||e instanceof Bt){let{name:h}=e;if(r[h]===void 0&&s[h]===void 0)t.error(Po,{val:e,name:h})}else if(e instanceof Ue){let{name:h}=e;if(i[h]===void 0)t.error(Co,{val:e,name:h})}else if(e instanceof Ke)Mt(t,e.seqVal,r,s,i,n),Mt(t,e.keyVal,r,s,i,n);else if(e instanceof $e){if(n.lookupRequest(e.name)===null)t.warn(xo,{name:e.name})}else if(e instanceof je){if(n.lookupComponent(e.name)===null)t.warn(Fo,{name:e.name})}else if(e instanceof k&&!ef(e.name))t.warn(Ho,{name:e.name});else if(!(e instanceof W))console.log(e)}function nf(t,e){let{computed:r,scope:s,views:i,Class:n}=e,{prototype:h}=n,{fields:u}=n.getMetaClass();for(let o in i){let f=i[o];for(let c of f.ctx.attrs){let{attrs:_,wrapperAttrs:l,textChild:a}=c;if(_ instanceof Le){for(let y of _.items)if(y instanceof $t)Mt(t,y.value,u,h,r,s)}if(l!==null)for(let{val:y}of l)Mt(t,y,u,h,r,s);if(a)Mt(t,a,u,h,r,s)}for(let c of f.ctx.nodes)if(c.val)Mt(t,c.val,u,h,r,s)}}class Jh{constructor(){this.reports=[]}error(t,e){this.report(t,e,Wh)}warn(t,e){this.report(t,e,ko)}hint(t,e){this.report(t,e,Vo)}report(t,e={},r=Wh){this.reports.push({id:t,info:e,level:r})}}class hf extends V{constructor(t,e,r){super(t,e,r);this.attrs=[]}onAttributes(t,e,r){this.attrs.push({attrs:t,wrapperAttrs:e,textChild:r})}}export{Qf as version,Xt as updateIn,Vn as update,oc as tutuca,Yu as setIn,Qu as set,lr as seqInfoByClass,Gu as removeIn,Hu as remove,Df as mergeWith,Zf as mergeDeepWith,Rf as mergeDeep,Jf as merge,uc as macro,ki as isValueObject,Ms as isStack,Os as isSet,ds as isSeq,gt as isRecord,Ln as isPlainObject,$n as isOrderedSet,bs as isOrderedMap,x as isOrdered,bs as isOMap,ir as isMap,jn as isList,z as isKeyed,$ as isIndexed,P as isImmutable,ir as isIMap,T as isCollection,Ss as isAssociative,A as is,Ye as injectCss,hc as html,G as hash,Dn as hasIn,Su as has,Es as getIn,Jn as get,Hf as fromJS,_r as fieldsByClass,nc as css,Oo as component,Zo as compileClassesToStyleText,zc as compileClassesToStyle,No as checkView,Ec as checkComponent,xo as UNKNOWN_REQUEST_NAME,Ho as UNKNOWN_HANDLER_ARG_NAME,Xo as UNKNOWN_EVENT_MODIFIER,Fo as UNKNOWN_COMPONENT_NAME,ie as Stack,M as Set,v as Seq,Xf as Repeat,fr as Record,ps as Range,To as RENDER_IT_OUTSIDE_OF_LOOP,V as ParseContext,Tf as PairSorting,N as OrderedSet,J as OrderedMap,J as OMap,R as Map,L as List,hf as LintParseContext,Jh as LintContext,ko as LEVEL_WARN,Vo as LEVEL_HINT,Wh as LEVEL_ERROR,Ot as KList,M as ISet,Qo as INPUT_HANDLER_NOT_IMPLEMENTED,Go as INPUT_HANDLER_METHOD_NOT_IMPLEMENTED,Bo as INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER,Yo as INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD,R as IMap,Po as FIELD_VAL_NOT_DEFINED,m as Collection,Co as COMPUTED_VAL_NOT_DEFINED};