tutuca 0.9.6 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -1
- package/dist/tutuca-dev.js +77 -83
- package/dist/tutuca-dev.min.js +3 -3
- package/dist/tutuca-extra.js +77 -83
- package/dist/tutuca-extra.min.js +3 -3
- package/dist/tutuca.js +57 -71
- package/dist/tutuca.min.js +3 -3
- package/package.json +22 -1
package/dist/tutuca-dev.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
class Yt{lookup(t,e=null){return e}setValue(t,e){return t}updateBindings(t,e){}isFrame=!0}class bt extends Yt{constructor(t){super();this.binds=t}lookup(t,e){return t}setValue(t,e){return e}withIndex(t){return new bt({...this.binds,key:t})}withKey(t){return new bt({...this.binds,key:t})}updateBindings(t,e){Object.assign(e,this.binds)}isFrame=!1}class ze extends Yt{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 fr(this.field,t)}withKey(t){return new or(this.field,t)}}class ur extends Yt{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 or extends ur{}class fr extends ur{}var J=Symbol("NONE");class cr extends Yt{constructor(t,e){super();this.seqField=t,this.keyField=e}lookup(t,e=null){let r=t?.get(this.seqField,J),s=t?.get(this.keyField,J);return s!==J&&r?.get?r.get(s,e):e}setValue(t,e){let r=t?.get(this.seqField,J),s=t?.get(this.keyField,J);return r===J||s===J?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,J),r===J)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,J),s===J)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,J),r===J)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}=ri(t.previousSibling),{eid:z,cid:d,vid:E}=t.dataset;if(z!==void 0)o.push(z);if(d!==void 0){let Ot=i.getComponentForId(+d,E);if(_){if(f=Uh(Ot,o,E,e),f===null&&n)return Ih;_=!1}let Mt=Ah(Ot,c,E);if(Mt)h.push(Mt);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 ei={};function ri(t){if(t?.nodeType===8&&t.textContent[0]==="§"){let e=ri(t.previousSibling);if(e!==ei)return e;try{return JSON.parse(t.textContent.slice(1,-1))}catch(r){console.warn(r,t)}}return ei}function Uh(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 Ah(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 Ih=[null,null];class _r{constructor(){this.pathChanges=[]}add(t){return this.pathChanges.push(t),this}field(t){return this.add(new ze(t))}index(t,e){return this.add(new fr(t,e))}key(t,e){return this.add(new or(t,e))}}var Kh=/^[a-zA-Z][a-zA-Z0-9_]*$/,ut=(t)=>Kh.test(t),Lh=/^-?[0-9]+(\.[0-9]+)?$/,si=(t,e)=>ar.parse(t,e),Bt=(t,e)=>new L(t),Wh=(t,e)=>ut(t)?new F(t):null,Jh=(t,e)=>ut(t)?new Oe(t):null,Dh=(t,e)=>ut(t)?new gr(t):null,Rh=(t,e)=>ut(t)?new ui(t):null,Zh=(t,e)=>ut(t)?new be(t):null,Hh=(t,e)=>ut(t)?new qe(t):null,Xh=(t,e)=>ut(t)?new Me(t):null;class ii{constructor(){this.allowFieldOnly(),this.bindValIt=new gr("it"),this.nullConstVal=new L(null)}const(t){return new L(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 Ee(s,i):null}parse(t,e){switch(Th(t)){case oi:return this.parseIfOk(t,e,this.okStrTpl,si);case ci:return this.parseIfOk(t,e,this.okStrTpl,Bt);case fi:return this._parseSeqAccess(t,e);case pe:return this.parseIfOk(t,e,this.okStrTpl,si)}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,Bt);case 39:return this.parseIfOk(t.slice(1,-1),e,this.okStrTpl,Bt);case 64:return this.parseIfOk(t.slice(1),e,this.okBind,Dh);case 42:return this.parseIfOk(t.slice(1),e,this.okDyn,Rh);case 46:return this.parseIfOk(t.slice(1),e,this.okField,Zh);case 36:return this.parseIfOk(t.slice(1),e,this.okComputed,Hh);case 33:return this.parseIfOk(t.slice(1),e,this.okRequest,Xh)}let s=Lh.test(t)?parseFloat(t):null;if(Number.isFinite(s))return this.parseIfOk(s,e,this.okConst,Bt);else if(t==="true"||t==="false")return this.parseIfOk(t==="true",e,this.okConst,Bt);else if(r>=97&&r<=122)return this.parseIfOk(t,e,this.okName,Wh);else if(r>=65&&r<=90)return this.parseIfOk(t,e,this.okType,Jh);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,de)}parseAlter(t,e){return this._parseHandler(t,e,ni)}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 Se{render(t,e){}eval(t){}toPathItem(){return null}}class L extends Se{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 lr extends Se{}class ar extends lr{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 L(h);s[n]=o,i&&=o instanceof L}return i?new L(s.map((n)=>n.value).join("")):new ar(s)}}class F extends lr{constructor(t){super();this.name=t}eval(t){return t.lookupName(this.name)}toString(){return this.name}}class de extends F{eval(t){return t.getInputHandler(this.name)??hi("input",this.name)}}class ni extends F{eval(t){return t.getAlterHandler(this.name)??hi("alter",this.name)}}var hi=(t,e)=>function(...r){return console.warn("handler not found",{type:t,name:e,args:r},this),this};class Oe extends F{eval(t){return t.lookupType(this.name)}}class Me extends F{eval(t){return t.lookupRequest(this.name)}toString(){return`!${this.name}`}}class Pt extends F{eval(t){return t.lookupFieldRaw(this.name)}toString(){return`.${this.name}`}}class yr extends Se{render(t,e){return this.eval(t)}}class Ct extends yr{constructor(t){super();this.name=t}}class gr extends Ct{eval(t){return t.lookupBind(this.name)}toString(){return`@${this.name}`}}class ui extends Ct{eval(t){return t.lookupDynamic(this.name)}toPathItem(){return null}toString(){return`*${this.name}`}}class be extends Ct{eval(t){return t.lookupField(this.name)}toPathItem(){return new ze(this.name)}toRawFieldVal(){return new Pt(this.name)}toString(){return`.${this.name}`}}class qe extends Ct{eval(t){return t.lookupComputed(this.name)}toString(){return`$${this.name}`}}class Ee extends yr{constructor(t,e){super();this.seqVal=t,this.keyVal=e}toPathItem(){return new cr(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 oi=0,fi=1,pe=2,ci=3;function Th(t){let e=0,r=0;for(let s=0;s<t.length;s++)switch(t.charCodeAt(s)){case 91:if(e>0)return pe;e+=1;break;case 93:if(r>0||e===0)return pe;r+=1;break;case 123:return oi;case 125:return ci}if(e>0||r>0)return e===1&&r===1?fi:pe;return-1}var w=new ii;class qt{constructor(t){this.items=t}eval(t){return{}}static parse(t,e,r=!1){return Sr(e).parse(t,r)}isConstant(){return!1}}var Qh="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",Gh=new Set(Qh.split(","));class _i{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 Et(t,s)),this.hasDynamic||=!(s instanceof L)}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 ai(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)??xt}parseElse(t){if(this.ifAttr)this.ifAttr.elseVal=w.parseAttr(t,this.px)??xt}parseEvent(t,e){let[r,...s]=t.slice(3).split("+"),i=dr.parse(e,this.px);if(i){if(this.events===null)this.events=this.px.registerEvents(),this.attrs??=[],this.attrs.push(new je("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 li(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===""&&Gh.has(n)?!0:h;this.attrs.push(new je(n,w.const(o)))}}let{attrs:r,hasDynamic:s}=this;return[s?new $e(r):zr.fromAttrs(r??[]),this.wrapperAttrs,this.textChild]}}class zr extends qt{eval(t){return this.items}static fromAttrs(t){let e={};for(let r of t)e[r.name]=r.value.eval(null);return new zr(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 $e extends qt{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 je(t,new L(e)))}toMacroVars(){let t={};for(let e of this.items)t[e.name]=e.value.toString();return t}}class pr{constructor(t){this.name=t}}class Et extends pr{constructor(t,e){super(t);this.value=e}eval(t){return this.value.eval(t)}}class je extends Et{}class li extends Et{constructor(t){super("dangerouslySetInnerHTML",t??w.nullConstVal)}eval(t){return{__html:`${this.value.eval(t)}`}}}var xt=w.nullConstVal;class ai extends pr{constructor(t,e){super(t);this.condVal=e,this.thenVal=this.elseVal=xt}get anyBranchIsSet(){return this.thenVal!==xt||this.elseVal!==xt}eval(t){return this.condVal.eval(t)?this.thenVal.eval(t):this.elseVal.eval(t)}}var wr=null;function Sr(t){return wr??=new _i(t),wr.clear(t),wr}class dr{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 dr(i,n)}}class Or{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 jt{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 jt{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 Yh(t){for(let e=0;e<t.length;e++){let r=t[e];if(r.isConstant())t[e]=new Ur(r);else r.optimize()}}function Er(t){if(t.isConstant())return new Ur(t);return t.optimize(),t}class jr extends jt{constructor(t){super();this.childs=t}isConstant(){return this.childs.every((t)=>t.isConstant())}optimize(){Yh(this.childs)}}class Ue 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 Ae 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 Mr=(t)=>t.length===1?t[0]:new Ae(t),Bh=/^[a-zA-Z][a-zA-Z0-9-]*$/,yi=null;class et extends jt{constructor(t,e){super();this.nodeId=t,this.val=e}toPathItem(){return this.val.toPathItem()}static parse(t,e){yi??=e.newDOMParser();let r=yi.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 Mr(n);let{name:h,value:u}=s[0],o=s.getNamedItem("as")?.value??null;switch(h){case"slot":return new Le(null,w.const(u),Mr(n));case"text":{let f=w.parseText(u,e);return f!==null?new qr(null,f):null}case"render":return e.addNodeIf(Oi,w.parseRender(u,e),o);case"render-it":return e.addNodeIf(Ke,w.bindValIt,o);case"render-each":return Vt.parse(e,w,u,o,s)}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]??Mr(n)}let[u,o]=qt.parse(s,e,!0);return e.onAttributes(u,o,null),gi(e.newMacroNode(h,u.toMacroVars(),n),e,o)}else if(Bh.test(i)){let[h,u,o]=qt.parse(s,e);if(e.onAttributes(h,u,o),o)n.unshift(new qr(null,o));let f=i!=="PRE"?kh(n):n;return gi(new Ue(i.toLowerCase(),h,f),e,u)}return new Ft(`Error: InvalidTagName ${i}`)}}function gi(t,e,r){if(r)for(let s=r.length-1;s>=0;s--){let i=Ph(r[s],e);if(i)i.wrapNode(t),t=i}return t}function Ph(t,e){let r=Fh[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 di extends jt{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=Er(this.node)}}class $r{constructor(t,e){this.defaults=t,this.rawView=e}expand(t){return et.parse(this.rawView,t)}}class Ie extends et{constructor(t,e,r){super(t,e);this.viewId=r}}class Oi extends Ie{render(t,e){let r=t.enter(this.val.eval(t),{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}}class Ke extends Ie{render(t,e){return e.renderIt(t,this.nodeId,"",this.viewId)}pathInNext=!0}class Vt extends Ie{constructor(t,e,r){super(t,e,r);this.iterInfo=new Ar(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=Sr(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 qr extends et{render(t,e){return e.renderText(this.val.eval(t))}}class Ur extends jt{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 ot 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=Er(this.node)}static register=!1}class Mi extends ot{render(t,e){return this.val.eval(t)?this.node.render(t,e):e.renderEmpty()}}class bi extends ot{render(t,e){return this.val.eval(t)?e.renderEmpty():this.node.render(t,e)}}class qi extends ot{render(t,e){return this.node.render(t.pushViewName(this.val.eval(t)),e)}}class Le extends ot{optimize(){this.node.optimize()}}class Ei extends ot{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 bt({})}wrapNode(t){this.node=t,this.node.setDataAttr("data-nid",this.nodeId)}static register=!0}class We extends ot{constructor(t,e){super(t,e);this.iterInfo=new Ar(e,null,null,null)}render(t,e){return e.renderEachWhen(t,this.iterInfo,this.node,this.nodeId)}toPathItem(){return new bt({})}static register=!0}class Ar{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)??Ch,s=this.loopWithVal?.eval(t)??xh,i=this.enrichWithVal?.eval(t)??null;return{seq:e,filter:r,loopWith:s,enricher:i}}}var Ch=(t,e,r)=>!0,xh=(t)=>({seq:t}),Fh={slot:Le,show:Mi,hide:bi,each:We,scope:Ei,"push-view":qi};class k{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 k(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 ji(t);return this.events.push(e),e}newMacroNode(t,e,r){let s=[],i={_:new Ae(s)};for(let h of r)if(h instanceof Le)i[h.val.value]=h.node;else if(!(h instanceof kt)||!h.isWhiteSpace())s.push(h);let n=new di(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 br=(t)=>t instanceof kt&&t.isWhiteSpace(),wi=(t)=>t instanceof Ue||t instanceof Ae&&t.childs[0]instanceof Ue;function kh(t){let e=t.length;if(e===0)return t;let r=0,s=!1;if(br(t[0]))r=1,s=!0;if(e>1&&br(t[e-1]))e-=1,s=!0;for(let i=1;i<e-1;i++){let n=t[i];if(br(n)&&wi(t[i-1])&&wi(t[i+1])&&n.hasNewLine())n.condenseWhiteSpace()}return s?t.slice(r,e):t}class Je{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=Er(this.anode)}render(t,e){return this.anode.render(t,e)}}class ji{constructor(t){this.id=t,this.handlers=[]}add(t,e,r){this.handlers.push(new $i(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 $i{constructor(t,e,r){this.name=t,this.handlerCall=e,this.modifierWrapper=tu(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 Vh=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),De=(t)=>(e)=>(r,s,i,n)=>t(n)?e(r,s,i,n):r,zi=(t)=>De((e)=>e.e.key===t),pi=De(({e:t})=>Vh&&t.metaKey||t.ctrlKey),Nh=De(({e:t})=>t.metaKey),mh=De(({e:t})=>t.altKey),Si={ctrl:pi,cmd:pi,meta:Nh,alt:mh},Ir={keydown:{send:zi("Enter"),cancel:zi("Escape"),...Si},click:{...Si}},vh=(t,e)=>t;function tu(t,e){if(e.length===0)return vh;let r=Ir[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 Kr{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 Lr{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 Wr{getKey(t,e,r){return r.call(t)}}class Jr{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 Re{constructor(){this.getComponentSymbol=Symbol("getComponent"),this.byId=new Map,this.computedCache=new Jr}setNullComputedCache(){this.computedCache=new Wr}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:Ai}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
|
|
3
|
-
`)}}function Ai(t){return t}var Ii=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===Ii?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 Zr{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?Ii:Xr:e}}class Hr{constructor(t){this.bindings=t}lookup(t){let e=this.bindings[t];return e===void 0?Xr:e}}class H{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 H(t,e.tail.head.it,e.tail,r,s,i)}static root(t,e,r){let s=new Nt(new Zr(e,{it:e},!0),null),i=new Nt(new Hr({}),null),n=new Nt("main",null);return new H(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 Zr(t,e,r));return new H(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 H(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 Hr(e));return new H(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 Li{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 Qr{constructor(t,e){this.comps=t,this.transactions=[],this.state=new Li(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 Br(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 Di(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)??ru(e),o=s?.onResName??e,f=(c,_,l,a,y)=>{let d=new Ji(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 Wi(t,e,r,this,s))}}function ru(t){return()=>{throw Error(`Request not found: ${t}`)}}function su(){return this}class Gr{constructor(t,e){this.path=t,this.transactor=e,this.parentTransaction=null,this._task=null}get task(){return this._task??=new Ri,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 H.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 iu=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Ki=(t)=>Number.isNaN(t)?null:t;function Tr(t){return t.target.type==="checkbox"?t.target.checked:(t instanceof CustomEvent?t.detail:t.target.value)??null}class Wi extends Gr{constructor(t,e,r,s,i){super(t,s);this.e=e,this.handler=r,this.dragInfo=i}buildRootStack(t,e){return H.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 Pr(this.path,this.transactor,this),n[u]=n[u].toHandlerArg(h);return[i,n]}lookupName(t){let{e}=this;switch(t){case"value":return Tr(e);case"valueAsInt":return Ki(parseInt(Tr(e),10));case"valueAsFloat":return Ki(parseFloat(Tr(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 iu&&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 Cr(this.path,this.transactor,this);case"dragInfo":return this.dragInfo}return null}}class Yr extends Gr{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]??su}getHandlerAndArgs(t,e,r){return[this.getHandlerForName(r.getCompFor(e)),[...this.args,new Cr(this.path,this.transactor,this)]]}}class Ji extends Yr{handlerProp="response"}class Br extends Yr{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 Di extends Br{handlerProp="bubble";stopPropagation(){this.opts.bubbles=!1}}class Ri{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 Pr{constructor(t,e,r=null){this.path=t,this.transactor=e,this.parent=r}get at(){return new Zi(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 Cr extends Pr{stopPropagation(){return this.parent.stopPropagation()}}class Zi extends _r{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 xr{constructor(t,e,r,s,i){this.rootNode=t,this.comps=r,this.compStack=new Ze(r),this.transactor=new Qr(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=nu(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 Hi(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 H.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()}),He("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 He(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 nu(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 Hi{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 Xe extends k{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 Xe(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){if(this._addClasses(n.value),typeof h?.value==="string")this._addClasses(h.value)}else if(typeof i?.value==="string")this._addClasses(i.value);else if(i?.vals!==void 0){for(let u of i.vals)if(u instanceof L&&u.value!=="")this._addClasses(u.value)}}else{let s=t.items.class;if(s)this._addClasses(s)}}}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 Xi(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 hu=(t,e)=>e,uu=(t,e)=>[e,t],Fr=(t)=>function(...e){return!t.apply(this,e)},Ti=(t)=>function(...e){return-t.apply(this,e)};function fn(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 Qi=(t,e)=>t<e?1:t>e?-1:0,A={done:!0,value:void 0};class cn{constructor(t){this.next=t}[Symbol.iterator](){return this}}function W(t){return new cn(t)}function M(t){let e=[void 0,void 0],r={done:!1,value:void 0};return W(()=>{if(t(e))return r.value=[e[0],e[1]],r;return A})}var ou=W(()=>A),ft=()=>ou;function ke(t){let e=0,r={done:!1,value:void 0};return W(()=>{if(e===t)return A;return r.value=e++,r})}function ie(t,e){return M((r)=>{let s=t.next();if(s.done)return!1;return e(s.value[0],s.value[1],r),!0})}function _n(t){if(Array.isArray(t))return!0;return!!Ve(t)}var fu=(t)=>!!(t&&typeof t.next==="function");function ln(t){return Ve(t)?.call(t)}function Ve(t){let e=t&&t[Symbol.iterator];if(typeof e==="function")return e}function cu(t){let e=Ve(t);return e&&e===t.entries}function _u(t){let e=Ve(t);return e&&e===t.keys}var ne="delete",S=5,q=1<<S,I=q-1,g={},rs=()=>({value:!1});function Z(t){if(t)t.value=!0}class Ne{}function At(t){if(t.size===void 0)t.size=t.__iterate(an);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?At(t)+e:e}var an=()=>!0,yn=(t)=>t<0||Object.is(t,-0),he=(t,e,r)=>(t===0&&!yn(t)||r!==void 0&&(t??0)<=-r)&&(e===void 0||r!==void 0&&e>=r),gn=(t,e,r)=>t===void 0?r:yn(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)=>gn(t,e,0),ue=(t,e)=>gn(t,e,e),wn="@@__IMMUTABLE_ITERABLE__@@",Ye="@@__IMMUTABLE_KEYED__@@",Be="@@__IMMUTABLE_INDEXED__@@",it="@@__IMMUTABLE_ORDERED__@@",oe="@@__IMMUTABLE_SEQ__@@",zn="@@__IMMUTABLE_LIST__@@",pn="@@__IMMUTABLE_MAP__@@",Sn="@@__IMMUTABLE_SET__@@",dn="@@__IMMUTABLE_STACK__@@",On="@@__IMMUTABLE_RECORD__@@";function C(t,e){return typeof t==="object"&&t!==null&&e in t}var D=(t)=>C(t,wn),p=(t)=>C(t,Ye),j=(t)=>C(t,Be),os=(t)=>p(t)||j(t),V=(t)=>C(t,it),fs=(t)=>C(t,oe),cs=(t)=>C(t,zn),fe=(t)=>C(t,pn),_s=(t)=>C(t,Sn),ls=(t)=>C(t,dn),at=(t)=>C(t,On),x=(t)=>D(t)||at(t),me=(t)=>fe(t)&&V(t),Mn=(t)=>_s(t)&&V(t),Gi=(t)=>typeof t==="object"&&t!==null&&typeof t.equals==="function"&&typeof t.hashCode==="function";function bn(t){let e=B(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=Zt,e.__iterate=function(r,s){return t.__iterate((i,n)=>r(n,i,this),s)},e.__iteratorUncached=function(r){return ie(t.__iterator(r),(s,i,n)=>{n[0]=i,n[1]=s})},e}function qn(t,e,r){let s=B(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 ie(t.__iterator(i),(n,h,u)=>{u[0]=n,u[1]=e.call(r,h,n,t)})},s}function En(t,e){let r=B(t);if(r._iter=t,r.size=t.size,r.reverse=()=>t,t.flip)r.flip=function(){let s=bn(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=Zt,r.__iterate=function(s,i){let n=0;if(i)At(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)At(t);let n=this.size;return ie(t.__iterator(!s),(h,u,o)=>{o[0]=e?h:s?n-++i:i++,o[1]=u})},r}function jn(t,e,r,s){let i=t.size;if(he(e,r,i))return t;if(i===void 0&&(e<0||r<0))return jn(t.toSeq().cacheResult(),e,r,s);let n=Dt(e,i),u=ue(r,i)-n,o;if(!Number.isNaN(u))o=Math.max(0,u);let f=B(t);if(f.size=o===0?o:t.size&&o||void 0,!s&&fs(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,z)=>{if(l<n){l++;return}if(o!==void 0&&a>=o)return!1;if(a++,c(y,s?z:a-1,this)===!1)return!1},_),a},f.__iteratorUncached=function(c){if(o!==0&&c)return this.cacheResult().__iterator(c);if(o===0)return ft();let _=t.__iterator(c),l=0,a=0;if(s)return W(()=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return A;let y=_.next();if(y.done)return y;return a++,y});return M((y)=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return!1;let z=_.next();if(z.done)return!1;return a++,y[0]=a-1,y[1]=z.value[1],!0})},f}function Yi(t,e,r){if(!e)e=fn;let s=p(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?zs(n):j(t)?lt(n):te(n)}function Te(t,e,r){if(!e)e=fn;if(r){let s=t.toSeq().map((i,n)=>[i,r(i,n,t)]).reduce((i,n)=>Bi(e,i[1],n[1])?n:i);return s&&s[0]}return t.reduce((s,i)=>Bi(e,s,i)?i:s)}function Bi(t,e,r){let s=t(r,e);return s===0&&r!==e&&(r===void 0||r===null||Number.isNaN(r))||s>0}function kr(t,e,r,s){let i=B(t),n=new ce(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=N(_);return ln(h?l.reverse():l)}),o=0,f=Array(u.length),c=Array(u.length);return M((_)=>{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 $n(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 lu(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"&&(x(t)||Array.isArray(t)||lu(t));function Un(t){if($n(t)&&typeof t!=="string")return t;if(V(t))return t.toArray();throw TypeError(`Invalid keyPath: expected Ordered Collection or Array: ${t}`)}var au=(t,e)=>x(t)?t.has(e):nt(t)&&Object.hasOwn(t,e);function An(t,e,r){return x(t)?t.get(e,r):!au(t,e)?r:typeof t.get==="function"?t.get(e):t[e]}function as(t,e,r){let s=Un(e),i=0;while(i!==s.length)if(t=An(t,s[i++],g),t===g)return r;return t}var In=(t,e)=>as(t,e,g)!==g;function $(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!!(Gi(t)&&Gi(e)&&t.equals(e))}function Pe(t){if(!t||typeof t!=="object")return t;if(!D(t)){if(!nt(t))return t;t=ht(t)}if(p(t)){let r={};return t.__iterate((s,i)=>{r[String(i)]=Pe(s)}),r}let e=[];return t.__iterate((r)=>{e.push(Pe(r))}),e}function ys(t,e){if(t===e)return!0;if(!D(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||p(t)!==p(e)||j(t)!==j(e)||V(t)!==V(e))return!1;if(t.size===0&&e.size===0)return!0;let r=!os(t);if(V(t)){let h=t.entries();return!!(e.every((u,o)=>{let f=h.next().value;return f&&$(f[1],u)&&(r||$(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?!$(h,t.get(u,g)):!$(t.get(u,g),h))return i=!1,!1;return!0});return i&&t.size===n}var ve=(t)=>t>>>1&1073741824|t&3221225471;function X(t){if(t===null||t===void 0)return Pi(t);if(typeof t.hashCode==="function")return ve(t.hashCode(t));let e=pu(t);if(e===null||e===void 0)return Pi(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return yu(e);case"string":return e.length>Su?gu(e):ss(e);case"object":case"function":return zu(e);case"symbol":return wu(e);default:if(typeof e.toString==="function")return ss(e.toString());throw Error(`Value type ${typeof e} cannot be hashed.`)}}var Pi=(t)=>t===null?1108378658:1108378659;function yu(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 ve(e)}function gu(t){let e=mr[t];if(e===void 0){if(e=ss(t),Nr===du)Nr=0,mr={};Nr++,mr[t]=e}return e}function ss(t){let e=0;for(let r=0;r<t.length;r++)e=31*e+t.charCodeAt(r)|0;return ve(e)}function wu(t){let e=xi[t];if(e!==void 0)return e;return e=Kn(),xi[t]=e,e}function zu(t){let e=Ci.get(t);if(e!==void 0)return e;return e=Kn(),Ci.set(t,e),e}var pu=(t)=>t.valueOf!==Object.prototype.valueOf?t.valueOf():t;function Kn(){let t=++Vr;if(Vr&1073741824)Vr=0;return t}var Ci=new WeakMap,xi=Object.create(null),Vr=0,Su=16,du=255,Nr=0,mr={};function Ou(t){if(t.size===1/0)return 0;let e=V(t),r=p(t),s=e?1:0;return t.__iterate(r?e?(i,n)=>{s=31*s+Fi(X(i),X(n))|0}:(i,n)=>{s=s+Fi(X(i),X(n))|0}:e?(i)=>{s=31*s+X(i)|0}:(i)=>{s=s+X(i)|0}),Mu(t.size,s)}var Fi=(t,e)=>t^e+2654435769+(t<<6)+(t>>2)|0;function Mu(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=ve(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:fs(t)?e:t.create?t.create(e):t.constructor(e),bu=(t,e)=>O(t,(p(t)?Q:j(t)?yt:gt)(e)),ki=(...t)=>t,N=(t)=>D(t)?t:ht(t);class T{size=0;static{this.prototype[wn]=!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 ys(this,t)}hashCode(){return this.__hash??(this.__hash=Ou(this))}toArray(){U(this.size);let t=Array(this.size||0),e=p(this),r=0;return this.__iterate((s,i)=>{t[r++]=e?[i,s]:s}),t}toIndexedSeq(){return new Rn(this)}toJS(){return Pe(this)}toKeyedSeq(){return new Ms(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 Zn(this)}toSeq(){return j(this)?this.toIndexedSeq():p(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=p(this),r=[this,...t].map((s)=>{if(!D(s))s=e?Wn(s):Jn(Array.isArray(s)?s:[s]);else if(e)s=Q(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&&p(s)||j(this)&&j(s))return s}return O(this,new Dn(r))}includes(t){return this.some((e)=>$(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=p(this),i=B(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 M((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=p(this),s=[[],[]];return this.__iterate((i,n)=>{s[t.call(e,i,n,this)?1:0].push(r?[n,i]:i)}),s.map((i)=>bu(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 W(()=>{let r=t.next();if(r.done)return A;return e.value=r.value[0],e})}map(t,e){return O(this,qn(this,t,e))}reduce(t,e=g,r){return Xi(this,t,e,r,e===g,!1)}reduceRight(t,e=g,r){return Xi(this,t,e,r,e===g,!0)}reverse(){return O(this,En(this,p(this)))}slice(t,e){return O(this,jn(this,t,e,p(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,Yi(this,t))}values(){let t=this.__iterator(),e={done:!1,value:void 0};return W(()=>{let r=t.next();if(r.done)return A;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 At(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 ce(t._cache);let e=t.toSeq().map(uu).toIndexedSeq();return e.fromEntrySeq=()=>t.toSeq(),e}filterNot(t,e){return this.filter(Fr(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(an,null,t)}flatMap(t,e){return O(this,this.toSeq().map((r,s)=>(p(this)?Q:j(this)?yt:gt)(t.call(e,r,s,this))).flatten(!0))}flatten(t){let e=this,r=p(this),s=B(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)&&D(_))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 M((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)&&D(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 Hn(this)}get(t,e){return this.find((r,s)=>$(s,t),void 0,e)}getIn(t,e){return as(this,t,e)}groupBy(t,e){throw Error("groupBy: not patched — import CollectionConversions")}has(t){return this.get(t,g)!==g}hasIn(t){return In(this,t)}isSubset(t){let e=typeof t.includes==="function"?t:N(t);return this.every((r)=>e.includes(r))}isSuperset(t){return(typeof t.isSubset==="function"?t:N(t)).isSubset(this)}keyOf(t){return this.findKey((e)=>$(e,t))}keySeq(){return this.toSeq().map(hu).toIndexedSeq()}last(t){return this.toSeq().reverse().first(t)}lastKeyOf(t){return this.toKeyedSeq().reverse().keyOf(t)}max(t){return Te(this,t)}maxBy(t,e){return Te(this,e,t)}min(t){return Te(this,t?Ti(t):Qi)}minBy(t,e){return Te(this,e?Ti(e):Qi,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=p(this),i=B(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 M((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(Fr(t),e)}sortBy(t,e){return O(this,Yi(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=B(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 W(()=>{if(u)return A;let o=n.next();if(o.done)return o;if(!t.call(e,o.value[1],o.value[0],h))return u=!0,A;return o})},O(this,s)}takeUntil(t,e){return this.takeWhile(Fr(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 Q=(t)=>p(t)?t:zs(t);class gs extends T{static{this.prototype[Ye]=!0,this.prototype.__toStringMapper=(t,e)=>`${vt(e)}: ${vt(t)}`,this.prototype[Symbol.iterator]=T.prototype.entries,this.prototype.toJSON=function(){U(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}}flip(){return O(this,bn(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 yt=(t)=>j(t)?t:lt(t);class It extends T{static{this.prototype[Be]=!0,this.prototype[it]=!0}toKeyedSeq(){return new Ms(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=B(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 M((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=kr(this.toSeq(),lt.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(ki,...t)}zipAll(...t){let e=[this,...t];return O(this,kr(this,ki,e,!0))}zipWith(t,...e){let r=[this,...e];return O(this,kr(this,t,r))}}var gt=(t)=>D(t)&&!os(t)?t:te(t);class tr extends T{static{this.prototype.has=T.prototype.includes,this.prototype.contains=T.prototype.includes,this.prototype.keys=tr.prototype.values}get(t,e){return this.has(t)?t:e}includes(t){return this.has(t)}keySeq(){return this.valueSeq()}}N.Keyed=Q;N.Indexed=yt;N.Set=gt;var vr=It.prototype,ht=(t)=>t===void 0||t===null?ds():x(t)?t.toSeq():qu(t),B=(t)=>Object.create((p(t)?Rt:j(t)?wt:ps).prototype);class ct extends T{static{this.prototype[oe]=!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 W(()=>{if(s===r)return A;return i.value=e[t?r-++s:s++],i})}return this.__iteratorUncached(t)}}var ws={cacheResult:ct.prototype.cacheResult,__iterateUncached:ct.prototype.__iterateUncached,__iterate:ct.prototype.__iterate,__iterator:ct.prototype.__iterator},zs=(t)=>t===void 0||t===null?ds().toKeyedSeq():D(t)?p(t)?t.toSeq():t.fromEntrySeq():at(t)?t.toSeq():Wn(t);class Rt extends gs{static{this.prototype[oe]=!0,Object.assign(this.prototype,ws)}toSeq(){return this}toKeyedSeq(){return this}}var lt=(t)=>t===void 0||t===null?ds():D(t)?p(t)?t.entrySeq():t.toIndexedSeq():at(t)?t.toSeq().entrySeq():Jn(t);lt.of=(...t)=>lt(t);class wt extends It{static{this.prototype[oe]=!0,Object.assign(this.prototype,ws)}toSeq(){return this}toIndexedSeq(){return this}toString(){return this.__toString("Seq [","]")}}var te=(t)=>(D(t)&&!os(t)?t:lt(t)).toSetSeq();te.of=(...t)=>te(t);class ps extends tr{static{this.prototype[oe]=!0,Object.assign(this.prototype,ws)}toSeq(){return this}toSetSeq(){return this}}ht.isSeq=fs;ht.Keyed=zs;ht.Set=te;ht.Indexed=lt;class ce extends wt{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 M((i)=>{if(s===r)return!1;let n=t?r-++s:s++;return i[0]=n,i[1]=e[n],!0})}}class Ss extends Rt{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 M((n)=>{if(i===s)return!1;let h=r[t?s-++i:i++];return n[0]=h,n[1]=e[h],!0})}}class Ln extends wt{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=ln(e);if(!fu(r))return ft();let s=0;return M((i)=>{let n=r.next();if(n.done)return!1;return i[0]=s++,i[1]=n.value,!0})}}var ds=()=>new ce([]),Os=(t)=>$n(t)?new ce(t):_n(t)?new Ln(t):void 0;function Wn(t){let e=Os(t);if(e)return e.fromEntrySeq();if(typeof t==="object")return new Ss(t);throw TypeError(`Expected Array or collection object of [k, v] entries, or keyed object: ${t}`)}function Jn(t){let e=Os(t);if(e)return e;throw TypeError(`Expected Array or collection object of values: ${t}`)}function qu(t){let e=Os(t);if(e)return cu(t)?e.fromEntrySeq():_u(t)?e.toSetSeq():e;if(typeof t==="object")return new Ss(t);throw TypeError(`Expected Array or collection object of values, or keyed object: ${t}`)}class Dn extends ct{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[Ye])this[Ye]=!0;if(i[Be])this[Be]=!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=!p(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 ft();if(t)return this.cacheResult().__iterator(t);let e=this._wrappedIterables,r=!p(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 M((u)=>{let o=n();if(!o)return!1;return u[0]=h++,u[1]=o.value[1],!0})}return W(()=>n()||A)}}class Ms extends Rt{static{this.prototype[it]=!0}constructor(t,e){super();this._iter=t,this._useKeys=e,this.size=t.size}cacheResult(){return Zt.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=En(this,!0);if(!this._useKeys)t.valueSeq=()=>this._iter.toSeq().reverse();return t}map(t,e){let r=qn(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 Rn extends wt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Zt.call(this)}includes(t){return this._iter.includes(t)}__iterateUncached(t,e){let r=0;if(e)At(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)At(this);let r=this.size;return ie(this._iter.__iterator(t),(s,i,n)=>{n[0]=t?r-++e:e++,n[1]=i})}}class Zn extends ps{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Zt.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 ie(this._iter.__iterator(t),(e,r,s)=>{s[0]=r,s[1]=r})}}class Hn extends Rt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Zt.call(this)}entrySeq(){return this._iter.toSeq()}__iterateUncached(t,e){let r=0;return this._iter.__iterate((s)=>{if(s){Vi(s),r++;let i=D(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 M((r)=>{while(!0){let s=e.next();if(s.done)return!1;let i=s.value[1];if(i){Vi(i);let n=D(i);return r[0]=n?i.get(0):i[0],r[1]=n?i.get(1):i[1],!0}}})}}function Zt(){if(this._iter.cacheResult)return this._iter.cacheResult(),this.size=this._iter.size,this;return ct.prototype.cacheResult.call(this)}function Vi(t){if(t!==Object(t))throw TypeError(`Expected [K, V] tuple: ${t}`)}var Y=(t)=>t===void 0||t===null?G():fe(t)&&!V(t)?t:G().withMutations((e)=>{let r=Q(t);U(r.size),r.forEach((s,i)=>e.set(i,s))});class bs extends gs{static{pt(this,{asImmutable:_e,asMutable:le,deleteIn:Kt,merge:is,mergeWith:Pn,mergeDeep:xn,mergeDeepWith:Fn,mergeDeepIn:Rs,mergeIn:Ds,setIn:Ls,update:Ws,updateIn:Js,wasAltered:Ks,withMutations:ae,removeIn:Kt,concat:is,[pn]:!0,[ne]: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 Y(t)}toString(){return this.__toString("Map {","}")}get(t,e){return this._root?this._root.get(0,X(t),t,e):e}set(t,e){return mi(this,t,e)}remove(t){return mi(this,t,g)}deleteAll(t){let e=N(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 G()}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 ft();return Qe(this._root,!1,0)}values(){if(!this._root)return ft();return Qe(this._root,!1,1)}entries(){if(!this._root)return ft();return Qe(this._root,!1)}__iterator(t){if(!this._root)return ft();return Qe(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 G();return this.__ownerID=t,this.__altered=!1,this}return js(this.size,this._root,t,this.__hash)}}Y.isMap=fe;class qs{constructor(t,e){this.ownerID=t,this.entries=e}get(t,e,r,s){return Xn(this.entries,r,s)}iterate(t,e){return Tn(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($(s,o[f][0]))break;let _=f<c;if(_?o[f][1]===i:u)return this;if(Z(h),u||!_)Z(n);if(u&&c===1)return;if(!_&&!u&&c>=Iu)return Eu(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 qs(t,a)}}class er{constructor(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}iterate(t,e){return Qn(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[tn(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 _=tn(f&o-1),l=this.nodes,a=c?l[_]:void 0,y=$s(a,t,e+S,r,s,i,n,h);if(y===a)return this;if(!c&&y&&l.length>=Ku)return $u(t,l,f,u,y);if(c&&!y&&l.length===2&&vi(l[_^1]))return l[_^1];if(c&&y&&l.length===1&&vi(y))return y;let z=t&&t===this.ownerID,d=c?y?f:f^o:f|o,E=c?y?Gn(l,_,y,z):Au(l,_,z):Uu(l,_,y,z);if(z)return this.bitmap=d,this.nodes=E,this;return new er(t,d,E)}}class Es{constructor(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}iterate(t,e){return Qn(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 _=$s(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<Lu)return ju(t,f,l,u)}let a=t&&t===this.ownerID,y=Gn(f,u,_,a);if(a)return this.count=l,this.nodes=y,this;return new Es(t,l,y)}}class rr{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}get(t,e,r,s){return Xn(this.entries,r,s)}iterate(t,e){return Tn(this.entries,t,e)}update(t,e,r,s,i,n,h){if(r!==this.keyHash){if(i===g)return this;return Z(h),Z(n),Us(this,t,e,r,[s,i])}let u=i===g,o=this.entries,f=0,c=o.length;for(;f<c;f++)if($(s,o[f][0]))break;let _=f<c;if(_?o[f][1]===i:u)return this;if(Z(h),u||!_)Z(n);if(u&&c===2)return new zt(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 rr(t,this.keyHash,a)}}class zt{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 $(r,this.entry[0])?this.entry[1]:s}update(t,e,r,s,i,n,h){let u=i===g,o=$(s,this.entry[0]);if(o?i===this.entry[1]:u)return this;if(Z(h),u){Z(n);return}if(o){if(t&&t===this.ownerID)return this.entry[1]=i,this;return new zt(t,this.keyHash,[s,i])}return Z(n),Us(this,t,e,X(s),[s,i])}}function Xn(t,e,r){for(let s=0,i=t.length;s<i;s++)if($(e,t[s][0]))return t[s][1];return r}function Tn(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 Qn(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 Qe(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 W(()=>{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 A})}var js=(t,e,r,s)=>new bs(t,e,r,s),Ni,G=()=>Ni||(Ni=js(0));function mi(t,e,r){let s,i;if(!t._root){if(r===g)return t;i=1,s=new qs(t.__ownerID,[[e,r]])}else{let n=rs(),h=rs();if(s=$s(t._root,t.__ownerID,0,X(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):G()}function $s(t,e,r,s,i,n,h,u){if(!t){if(n===g)return t;return Z(u),Z(h),new zt(e,s,[i,n])}return t.update(e,r,s,i,n,h,u)}var vi=(t)=>t.constructor===zt||t.constructor===rr;function Us(t,e,r,s,i){if(t.keyHash===s)return new rr(e,s,[t.entry,i]);let n=(r===0?t.keyHash:t.keyHash>>>r)&I,h=(r===0?s:s>>>r)&I,u=new zt(e,s,i),o=n===h?[Us(t,e,r+S,s,i)]:n<h?[t,u]:[u,t];return new er(e,1<<n|1<<h,o)}function Eu(t,e,r,s){if(!t)t=new Ne;let i=new zt(t,X(r),[r,s]);for(let[n,h]of e)i=i.update(t,0,X(n),n,h);return i}function ju(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 er(t,i,h)}function $u(t,e,r,s,i){let n=0,h=Array(q);for(let u=0;r!==0;u++,r>>>=1)h[u]=r&1?e[n++]:void 0;return h[s]=i,new Es(t,n+1,h)}function tn(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 Gn(t,e,r,s){let i=s?t:t.slice();return i[e]=r,i}function Uu(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 Au(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 Iu=q/4,Ku=q/2,Lu=q/4;function Ce(t){if(Array.isArray(t))return t.slice();return{...t}}var As=(t,e,r)=>Is(t,e,Wu(r));function Is(t,e,r){if(!nt(t))throw TypeError(`Cannot merge into non-data-structure value: ${t}`);if(x(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?yt:Q,h=s?(u)=>{if(i===t)i=Ce(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=Ce(i);i[o]=c}};for(let u of e)n(u).forEach(h);return i}function Wu(t){function e(r,s,i){return nt(r)&&nt(s)&&Ju(r,s)?Is(r,[s],e):t?t(r,s,i):s}return e}function Ju(t,e){let r=ht(t),s=ht(e);return j(r)===j(s)&&p(r)===p(s)}function Du(t,e){if(!nt(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(x(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=Ce(t);if(Array.isArray(r))r.splice(e,1);else delete r[e];return r}function Ru(t,e,r){if(!nt(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(x(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=Ce(t);return s[e]=r,s}function Ht(t,e,r,s){if(!s)s=r,r=void 0;let i=Yn(x(t),t,Un(e),0,r,s);return i===g?r:i}function Yn(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:An(e,u,g),f=Yn(o===g?t:x(o),o,r,s+1,i,n);if(f===o)return e;if(f===g)return Du(e,u);let c=h?t?G():{}:e;return Ru(c,u,f)}var Zu=(t,e)=>Ht(t,e,()=>g),Hu=(t,e,r)=>Ht(t,e,g,()=>r);function Bn(t,e,r,s){return Ht(t,[e],r,s)}function _e(){return this.__ensureOwner()}function le(){return this.__ownerID?this:this.__ensureOwner(new Ne)}function Ks(){return this.__altered}function ae(t){let e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Xu(t,e){return as(this,t,e)}function Tu(t){return In(this,t)}function Kt(t){return Zu(this,t)}function Ls(t,e){return Hu(this,t,e)}function Ws(t,e,r){return typeof t==="function"?t(this):Bn(this,t,e,r)}function Js(t,e,r){return Ht(this,t,e,r)}function en(){U(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}function is(...t){return Cn(this,t)}function Pn(t,...e){if(typeof t!=="function")throw TypeError(`Invalid merger function: ${t}`);return Cn(this,e,t)}function Cn(t,e,r){let s=[];for(let i of e){let n=Q(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 at(t)?t:t.create(s[0]);return t.withMutations((i)=>{let n=r?(h,u)=>{Bn(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 xn(...t){return As(this,t)}function Fn(t,...e){return As(this,e,t)}function Ds(t,...e){return Ht(this,t,G(),(r)=>Is(r,e))}function Rs(t,...e){return Ht(this,t,G(),(r)=>As(r,e))}function pt(t,e){Object.assign(t.prototype,e)}var K=(t)=>{let e=ee();if(t===void 0||t===null)return e;if(cs(t))return t;let r=yt(t),s=r.size;if(s===0)return e;if(U(s),s>0&&s<q)return ye(0,s,S,null,new _t(r.toArray()));return e.withMutations((i)=>{i.setSize(s),r.forEach((n,h)=>i.set(h,n))})};K.of=(...t)=>K(t);class kn extends It{static{pt(this,{asImmutable:_e,asMutable:le,deleteIn:Kt,mergeDeepIn:Rs,mergeIn:Ds,setIn:Ls,update:Ws,updateIn:Js,wasAltered:Ks,withMutations:ae,removeIn:Kt,[zn]:!0,[ne]: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 K(t)}toString(){return this.__toString("List [","]")}get(t,e){if(t=st(this,t),t>=0&&t<this.size){t+=this._origin;let r=mn(this,t);return r&&r.array[t&I]}return e}set(t,e){return Gu(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 ee()}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=yt(typeof r!=="string"&&_n(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 K(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(he(t,e,r))return this;return rt(this,Dt(t,r),ue(e,r))}__iterate(t,e){let r=e?this.size:0;return Qu(this,(s)=>t(s,e?--r:r++,this),e),e?this.size-r:r}__iterator(t){let e=t?this.size:0,r=rn(this,t);return M((s)=>{let i=r.next();if(i.done)return!1;return s[0]=t?--e:e++,s[1]=i.value,!0})}values(){return rn(this,!1)}keys(){return ke(this.size)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return ee();return this.__ownerID=t,this.__altered=!1,this}return ye(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash)}}K.isList=cs;class _t{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 _t([],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=Lt(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:q)||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=Lt(this,t);if(n.array.splice(s+1),i)n.array[s]=i;return n}}function rn(t,e){let{_origin:r,_capacity:s}=t,i=Wt(s),n=t._tail,h=[];o(t._root,t._level,0);let u={done:!1,value:void 0};return W(()=>{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 A});function o(f,c,_){if(c===0){let l=_===i?n?.array:f?.array,a=_>r?0:r-_,y=s-_;if(y>q)y=q;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>q)y=q;if(a!==y)h.push({array:l,from:a,to:y,level:c,offset:_,isLeaf:!1})}}}function Qu(t,e,r){let{_origin:s,_capacity:i}=t,n=Wt(i),h=t._tail,u=t._level,o=t._root;return u===0?Vn(o,0,s,i,n,h,e,r):Nn(o,u,0,s,i,n,h,e,r)}function Vn(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>q)c=q;while(f!==c){let _=u?--c:f++;if(h(o?.[_])===!1)return!1}}function Nn(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(_>q)_=q;let l=e-S;while(c!==_){let a=o?--_:c++,y=r+(a<<e);if((l===0?Vn(f?.[a],y,s,i,n,h,u,o):Nn(f?.[a],l,y,s,i,n,h,u,o))===!1)return!1}}var ye=(t,e,r,s,i,n,h)=>new kn(t,e,r,s,i,n,h),ee=()=>ye(0,0,S);function Gu(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=rs();if(e>=Wt(t._capacity))s=ns(s,t.__ownerID,0,e,r,n);else i=ns(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 ye(t._origin,t._capacity,t._level,i,s)}function ns(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=ns(f,e,r-S,s,i,n);if(c===f)return t;return o=Lt(t,e),o.array[h]=c,o}if(u&&t.array[h]===i)return t;if(n)Z(n);if(o=Lt(t,e),i===void 0&&h===o.array.length-1)o.array.pop();else o.array[h]=i;return o}function Lt(t,e){if(e&&e===t?.ownerID)return t;return new _t(t?.array.slice()??[],e)}function mn(t,e){if(e>=Wt(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 rt(t,e,r){if(e!==void 0)e|=0;if(r!==void 0)r|=0;let s=t.__ownerID||new Ne,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 _t(f?.array.length?[void 0,f]:[],s),o+=S,c+=1<<o;if(c)h+=c,i+=c,u+=c,n+=c;let _=Wt(n),l=Wt(u);while(l>=1<<o+S)f=new _t(f?.array.length?[f]:[],s),o+=S;let a=t._tail,y=l<_?mn(t,u-1):l>_?new _t([],s):a;if(a&&l>_&&h<n&&a.array.length){f=Lt(f,s);let z=f;for(let d=o;d>S;d-=S){let E=_>>>d&I;z=z.array[E]=Lt(z.array[E],s)}z.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 z=h>>>o&I;if(z!==l>>>o&I)break;if(z)c+=(1<<o)*z;o-=S,f=f.array[z]}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 ye(h,u,o,f,y)}var Wt=(t)=>t<q?0:t-1>>>S<<S,P=(t)=>t===void 0||t===null?re():me(t)?t:re().withMutations((e)=>{let r=Q(t);U(r.size),r.forEach((s,i)=>e.set(i,s))});P.of=(...t)=>P(t);class vn extends bs{static{pt(this,{[it]:!0,[ne]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.OrderedMap",keys:T.prototype.keys,values:T.prototype.values,__iterate:T.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 P(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 re()}set(t,e){return sn(this,t,e)}remove(t){return sn(this,t,g)}entries(){return this.__iterator(!1)}__iterator(t){let e=this._list.__iterator(t);return M((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 re();return this.__ownerID=t,this.__altered=!1,this._map=e,this._list=r,this}return Zs(e,r,t,this.__hash)}}P.isOrderedMap=me;var Zs=(t,e,r,s)=>new vn(t,e,r,s),re=()=>Zs(G(),ee());function sn(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>=q&&i.size>=s.size*2){let f=[];if(i.forEach((c,_)=>{if(c!==void 0&&n!==_)f.push(c)}),o=ee().withMutations((c)=>{for(let _=0;_<f.length;_++)c.set(_,f[_])}),u=G().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 Zs(u,o)}var xe=(t)=>t===void 0||t===null?Fe():ls(t)?t:Fe().pushAll(t);xe.of=(...t)=>xe(t);class th extends It{static{pt(this,{asImmutable:_e,asMutable:le,wasAltered:Ks,withMutations:ae,[dn]:!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 xe(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 ts(this,e,r)}pushAll(t){if(t=yt(t),t.size===0)return this;if(this.size===0&&ls(t))return t;U(t.size);let e=this.size,r=this._head;return t.__iterate((s)=>{e++,r={value:s,next:r}},!0),ts(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 Fe()}slice(t,e){if(he(t,e,this.size))return this;let r=Dt(t,this.size);if(ue(e,this.size)!==this.size)return It.prototype.slice.call(this,t,e);let i=this.size-r,n=this._head;while(r--)n=n.next;return ts(this,i,n)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return Fe();return this.__ownerID=t,this.__altered=!1,this}return Hs(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 M((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 M((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 W(()=>{if(!t)return A;return e.value=t.value,t=t.next,e})}keys(){return ke(this.size)}}xe.isStack=ls;function ts(t,e,r){if(t.__ownerID)return t.size=e,t._head=r,t.__hash=void 0,t.__altered=!0,t;return Hs(e,r)}var Hs=(t,e,r,s)=>new th(t,e,r,s),nn,Fe=()=>nn||(nn=Hs(0)),b=(t)=>t===void 0||t===null?se():_s(t)&&!V(t)?t:se().withMutations((e)=>{let r=gt(t);U(r.size),r.forEach((s)=>e.add(s))});b.of=(...t)=>b(t);b.fromKeys=(t)=>b(Q(t).keySeq());b.intersect=(t)=>{return t=N(t).toArray(),t.length?b(t.pop()).intersect(...t):se()};b.union=(t)=>{let e=N(t).toArray();return e.length?b(e.pop()).union(...e):se()};class Xs extends tr{static{pt(this,{withMutations:ae,asImmutable:_e,asMutable:le,[Sn]:!0,[ne]: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 b(t)}toString(){return this.__toString("Set {","}")}has(t){return this._map.has(t)}add(t){return Ge(this,this._map.set(t,t))}remove(t){return Ge(this,this._map.remove(t))}clear(){return Ge(this,this._map.clear())}map(t,e){let r=!1,s=Ge(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 b(t[0]);return this.withMutations((e)=>{for(let r of t)if(typeof r==="string")e.add(r);else gt(r).forEach((s)=>e.add(s))})}intersect(...t){return un(this,t,(e,r)=>!r.every((s)=>s.includes(e)))}subtract(...t){return un(this,t,(e,r)=>r.some((s)=>s.includes(e)))}wasAltered(){return this._map.wasAltered()}__iterator(t){return this._map.__iterator(t)}__empty(){return se()}__make(t,e){return eh(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)}}b.isSet=_s;var eh=(t,e)=>new Xs(t,e),hn,se=()=>hn||(hn=eh(G()));function un(t,e,r){if(e.length===0)return t;return e=e.map((s)=>gt(s)),t.withMutations((s)=>{t.forEach((i)=>{if(r(i,e))s.remove(i)})})}function Ge(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 Jt=(t)=>t===void 0||t===null?hs():Mn(t)?t:hs().withMutations((e)=>{let r=gt(t);U(r.size),r.forEach((s)=>e.add(s))});Jt.of=(...t)=>Jt(t);Jt.fromKeys=(t)=>Jt(Q(t).keySeq());class rh extends Xs{static{pt(this,{[it]:!0,[Symbol.toStringTag]:"Immutable.OrderedSet",zip:vr.zip,zipWith:vr.zipWith,zipAll:vr.zipAll})}create(t){return Jt(t)}toString(){return this.__toString("OrderedSet {","}")}__empty(){return hs()}__make(t,e){return sh(t,e)}}Jt.isOrderedSet=Mn;var sh=(t,e)=>new rh(t,e),hs=()=>sh(re());function Yu(t){if(at(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(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 ge=(t,e)=>{let r;Yu(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._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 ${Ts(this)} with property "${c}" since that property name is part of the Record API.`);else Pu(i,c)}}return this.__ownerID=void 0,this._values=K().withMutations((u)=>{u.setSize(this._keys.length),Q(h).forEach((o,f)=>{u.set(this._indices[f],o===this._defaultValues[f]?void 0:o)})}),this},i=s.prototype=Object.create(Bu);if(i.constructor=s,i.create=s,e)s.displayName=e;return s};class ih{static{pt(this,{asImmutable:_e,asMutable:le,deleteIn:Kt,getIn:Xu,hasIn:Tu,merge:is,mergeWith:Pn,mergeDeep:xn,mergeDeepWith:Fn,mergeDeepIn:Rs,mergeIn:Ds,setIn:Ls,toObject:en,update:Ws,updateIn:Js,withMutations:ae,removeIn:Kt,toJSON:en,[On]:!0,[ne]: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`${Ts(this)} { ${t} }`}equals(t){return this===t||at(t)&&Ut(this).equals(Ut(t))}hashCode(){return Ut(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 es(this,r)}return this}remove(t){return this.set(t)}clear(){let t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:es(this,t)}wasAltered(){return this._values.wasAltered()}toSeq(){return Ut(this)}toJS(){return Pe(this)}entries(){return this.__iterator()}__iterate(t,e){return Ut(this).__iterate(t,e)}__iterator(t){return Ut(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 es(this,e,t)}}ge.isRecord=at;var Ts=(t)=>t.constructor.displayName||t.constructor.name||"Record";class nh extends Rt{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 M((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 Ut=(t)=>new nh(t);ge.getDescriptiveName=Ts;var Bu=ih.prototype;function es(t,e,r){let s=Object.create(Object.getPrototypeOf(t));return s._values=e,s.__ownerID=r,s}function Pu(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 on=(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 Qs(t,e,r,s)};class Qs extends wt{_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(he(t,e,this.size))return this;if(t=Dt(t,this.size),e=ue(e,this.size),e<=t)return on(0,0);return on(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 M((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 W(()=>{if(s===t)return A;return i.value=r,r+=e,s++,i})}keys(){return ke(this.size)}equals(t){return t instanceof Qs?this._start===t._start&&this._end===t._end&&this._step===t._step:ys(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}class us extends wt{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 $(this._value,t)}slice(t,e){let r=this.size;return he(t,e,r)?this:new us(this._value,ue(e,r)-Dt(t,r))}reverse(){return this}indexOf(t){if($(this._value,t))return 0;return-1}lastIndexOf(t){if($(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 M((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 W(()=>{if(r===t)return A;return r++,s.value=e,s})}keys(){return ke(this.size)}equals(t){return t instanceof us?this.size===t.size&&$(this._value,t._value):ys(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var hh=Symbol("BadValue"),ch=(t)=>t;class R{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,hh);if(h===hh)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 Ys{isValid(t){return!0}getMessage(t){return"Invalid"}}class _h extends Ys{}var Cu=new _h;class m extends Ys{constructor(t,e){super();this._isValid=t,this._getMessage=e}isValid(t){return this._isValid(t)}getMessage(t){return this._getMessage(t)}}var xu=new m((t)=>Number.isInteger(t),()=>"Integer expected"),Fu=new m((t)=>Number.isFinite(t),()=>"Float expected"),ku=new m((t)=>typeof t==="boolean",()=>"Boolean expected"),Vu=new m((t)=>typeof t==="string",()=>"String expected"),Nu=new m((t)=>K.isList(t),()=>"List expected"),mu=new m((t)=>Y.isMap(t),()=>"Map expected"),vu=new m((t)=>P.isOrderedMap(t),()=>"OrderedMap expected"),to=new m((t)=>b.isSet(t),()=>"Set expected"),eo=(t)=>!!t;class Bs extends R{constructor(t,e=!1){super("bool",t,ku,eo,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 sr extends R{constructor(t,e=null){super("any",t,Cu,ch,e)}toDataDef(){let{defaultValue:t}=this;return{type:Gs(t)??"any",defaultValue:t?.toJS?t.toJS():t}}}var ro=(t)=>t?.toString?.()??"";class Ps extends R{constructor(t,e=""){super("text",t,Vu,ro,e)}extendProtoForType(t,e){let{name:r}=this;t[`${r}IsEmpty`]=function(){return this.get(r,"").length===0},t[`${r}Len`]=function(){return this.get(r,"").length}}}var so=(t)=>Number.isFinite(t)?Math.trunc(t):null;class lh extends R{constructor(t,e=0){super("int",t,xu,so,e)}}var io=(t)=>null;class Cs extends R{constructor(t,e=0){super("float",t,Fu,io,e)}}var Gs=(t)=>t?.constructor?.getMetaClass?.()?.name;class ah{constructor(t){this.typeName=t}isValid(t){return Gs(t)===this.typeName}getMessage(t){let e=Gs(t);return`Expected "${this.typeName}", got "${e}"`}}class yh extends R{constructor(t,e,r){super(t,e,new ah(t),ch,null);this.args=r}toDataDef(){return{component:this.typeName,args:this.args}}}var uh=Symbol("NONE");function Xt(t,e,r){wh(t,e,gh),t[`setIn${r}At`]=function(i,n){return this.set(e,this.get(e).set(i,n))},t[`getIn${r}At`]=function(i,n){return this.get(e).get(i,n)},t[`updateIn${r}At`]=function(i,n){let h=this.get(e),u=h.get(i,uh);if(u!==uh)return this.set(e,h.set(i,n(u)));return console.warn("key",i,"not found in",e,h),this};function s(i){return this.set(e,this.get(e).delete(i))}t[`deleteIn${r}At`]=s,t[`removeIn${r}At`]=s}var gh=K(),no=(t)=>Array.isArray(t)?K(t):null;class xs extends R{constructor(t,e=gh){super("list",t,Nu,no,e)}extendProtoForType(t,e){let{name:r}=this;Xt(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 ho=(t)=>Y(t);class Fs extends R{constructor(t,e=Y()){super("map",t,mu,ho,e)}extendProtoForType(t,e){Xt(t,this.name,e)}}var uo=(t)=>P(t);class ks extends R{constructor(t,e=P()){super("omap",t,vu,uo,e)}extendProtoForType(t,e){Xt(t,this.name,e)}}function wh(t,e,r){t[`${e}IsEmpty`]=function(){return this.get(e,r).size===0},t[`${e}Len`]=function(){return this.get(e,r).size}}var oh=b(),oo=(t)=>Array.isArray(t)?b(t):t instanceof Set?b(t):null;class Vs extends R{constructor(t,e=oh){super("set",t,to,oo,e)}extendProtoForType(t,e){let{name:r}=this;wh(t,r,oh),t[`addIn${e}`]=function(s){return this.set(r,this.get(r).add(s))},t[`deleteIn${e}`]=function(s){return this.set(r,this.get(r).delete(s))},t[`removeIn${e}`]=t[`deleteIn${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 fh(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 zh{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]=fh(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]=fh(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]:ge(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 yh(e,t,r);return this.compFields.add(t),this.fields[t]=s,s}}var ir=new Map,fo={text:Ps,int:lh,float:Cs,bool:Bs,list:xs,map:Fs,omap:ks,set:Vs,any:sr};function co(t,{fields:e={},methods:r,statics:s}){let i=new zh(t);for(let n in e){let h=e[n],u=typeof h;if(u==="string")i.addField(n,h,Ps);else if(u==="number")i.addField(n,h,Cs);else if(u==="boolean")i.addField(n,h,Bs);else if(K.isList(h)||Array.isArray(h))i.addField(n,K(h),xs);else if(b.isSet(h)||h instanceof Set)i.addField(n,b(h),Vs);else if(P.isOrderedMap(h))i.addField(n,h,ks);else if(h?.type&&h?.defaultValue!==void 0){let o=fo[h.type]??sr;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(Y.isMap(h)||h?.constructor===Object)i.addField(n,Y(h),Fs);else{let o=ir.get(h?.constructor)??sr;i.addField(n,h,o)}}if(r)i.methods(r);if(s)i.statics(s);return i.build()}var _o=(t)=>new Rr(t.name??"Comp",co(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 lo=["nid","cid","eid","vid","si","sk"];class Ns{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??po,this.cache=h??new Lr}setNullCache(){this.cache=new Kr}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 lo)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 z={key:a,value:y},d=`${s}-${a}`,E;if(c)u.call(t.it,z,a,y,l),E=this.cache.get2(t.it,y,d);else E=this.cache.get(y,d);if(E){_.push(this.renderMetadata("Each",{nid:s,[o]:a})),_.push(E);continue}let Ot=t.enter(y,z,!1),Mt=r.render(Ot,this);if(_.push(this.renderMetadata("Each",{nid:s,[o]:a})),c)this.cache.set2(t.it,y,d,Mt);else this.cache.set(y,d,Mt);_.push(Mt)}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*ao(t){let e=0;for(let r of t)yield[e++,r]}function*yo(t){for(let[e,r]of t.toSeq().entries())yield[e,r]}var nr=new Map,go=["si",ao],wo=["sk",yo],zo=["si",function*(e){}];function po(t){return j(t)?go:p(t)?wo:nr.get(t?.constructor)??zo}class St{constructor(t=Y(),e=K()){this.items=t,this.order=e,this.$=0}_clonish(t,e){return new St(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 So=(t)=>null;class ph{isValid(t){return t instanceof St}getMessage(t){return"KList expected"}}var Oo=new ph;class Sh extends R{constructor(t,e=new St){super("KList",t,Oo,So,e)}extendProtoForType(t,e){Xt(t,this.name,e);let{name:r}=this;Xt(t,r,e),t[`pushIn${e}`]=function(s){return this.set(r,this.get(r).push(s))}}}ir.set(St,Sh);function*Mo(t){for(let e of t.order)yield[e,t.items.get(e)]}nr.set(St,["data-sk",Mo]);function vs(t){return t[4]==="-"&&(t[0]==="d"||t[0]==="a")}function Oh(t,e,r){for(let s in e){let i=e[s];if(i===void 0)bo(t,s,r);else if(vs(s))t.setAttribute(s,i);else if(s==="dangerouslySetInnerHTML")t.innerHTML=i.__html??"";else if(typeof i==="object"&&i!==null)qo(t,r,s,i);else if(s==="className")t.setAttribute("class",i);else t[s]=i}}function bo(t,e,r){let s=r[e];if(e==="dangerouslySetInnerHTML")t.innerHTML="";else if(vs(e))t.removeAttribute(e);else if(typeof s==="string"){if(e!=="className")t[e]="";let i=e==="className"?"class":e==="htmlFor"?"for":e;t.removeAttribute(i)}else t[e]=null}function qo(t,e,r,s){let i=e?.[r];if(i&&typeof i==="object"&&Object.getPrototypeOf(i)!==Object.getPrototypeOf(s)){t[r]=s;return}let n=t[r];if(typeof n!=="object"||n===null)t[r]={},n=t[r];let h=n;for(let u in s)h[u]=s[u]}class Gt{isEqualTo(t){return this===t}toDom(t){return null}}function ms(t){return t instanceof Qt?t.key:void 0}function Eo(t){return t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function"}function ti(t,e){if(e==null)return;if(Eo(e))for(let r of e)ti(t,r);else if(e instanceof Gt)if(e instanceof v)t.push(...e.childs);else t.push(e);else t.push(new we(e))}class we extends Gt{constructor(t){super();this.text=String(t)}get nodeType(){return 3}isEqualTo(t){return t instanceof we&&this.text===t.text}toDom(t){return t.document.createTextNode(this.text)}}class Tt extends Gt{constructor(t){super();this.text=t}get nodeType(){return 8}isEqualTo(t){return t instanceof Tt&&this.text===t.text}toDom(t){return t.document.createComment(this.text)}}class v extends Gt{constructor(t){super();let e=[];ti(e,t),this.childs=e}get nodeType(){return 11}isEqualTo(t){if(!(t instanceof v)||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 Qt extends Gt{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 Qt)||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);Oh(r,this.attrs,{});for(let s of this.childs){let i=s.toDom(t);if(i)r.appendChild(i)}return r}}function Mh(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(typeof i==="object"&&i!==null&&typeof n==="object"&&n!==null)if(Object.getPrototypeOf(n)!==Object.getPrototypeOf(i))r??={},r[s]=n;else{let h=Mh(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 jo(t,e,r){let s=t.parentNode,i=e.toDom(r);if(s&&i&&i!==t)s.replaceChild(i,t);return i||t}function bh(t,e,r,s){if(e===r||e.isEqualTo(r))return t;if(e instanceof we&&r instanceof we||e instanceof Tt&&r instanceof Tt)return t.data=r.text,t;if(e instanceof Qt&&r instanceof Qt&&e.tag===r.tag&&e.namespace===r.namespace&&e.key===r.key){let i=Mh(e.attrs,r.attrs);if(i)Oh(t,i,e.attrs);if(!r.attrs.dangerouslySetInnerHTML)dh(t,e.childs,r.childs,e.tag,s);return t}if(e instanceof v&&r instanceof v)return dh(t,e.childs,r.childs,null,s),t;return jo(t,r,s)}function dh(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=ms(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],_=ms(c),l=-1;if(_!=null){if(_ in h&&!u[h[_]])l=h[_]}else while(o<e.length){if(!u[o]&&ms(e[o])==null){l=o++;break}o++}if(l>=0){u[l]=1;let a=n[l],y=bh(a,e[l],c,i),z=t.childNodes[f]??null;if(y!==z)t.insertBefore(y,z)}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 hr=new WeakMap;function qh(t,e,r){let s=hr.get(e),i=t instanceof v;if(s){let h=s.vnode instanceof v;if(h===i){let u=h?e:s.dom,o=bh(u,s.vnode,t,r);return hr.set(e,{vnode:t,dom:i?e:o}),o}hr.delete(e)}let n=t.toDom(r);if(n)e.innerHTML="",e.appendChild(n),hr.set(e,{vnode:t,dom:i?e:n});return n}function Eh(t,e,r){let s=t.toUpperCase(),i={},n,h;if(e)for(let o in e)if(o==="key")n=e[o];else if(o==="namespace")h=e[o];else if(o==="class")i.className=e[o];else if(o==="for")i.htmlFor=e[o];else if(vs(o))i[o]=String(e[o]);else i[o]=e[o];let u=[];return ti(u,r),new Qt(s,i,u,n,h)}var{raw:Gf,raw:Yf}=String;function Bf(t,e){return new $r(t,e)}var $o=(t)=>typeof t==="string"?document.querySelector(t):t;function Pf(t){let e=$o(t),r=new Re,s=(o)=>new v(o),i=(o)=>new Tt(o),n={document},h=(o,f)=>qh(o,f,n),u=new Ns(r,Eh,s,i,h);return new xr(e,h,r,u,k)}async function tc(t,e,r="margaui-css"){let s=performance.now(),i=await Uo(t,e),n=performance.now();return He(r,i),n-s}async function Uo(t,e,r){t.ParseContext=Xe,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 Ao="RENDER_IT_OUTSIDE_OF_LOOP",Io="UNKNOWN_EVENT_MODIFIER",Ko="UNKNOWN_HANDLER_ARG_NAME",Lo="INPUT_HANDLER_NOT_IMPLEMENTED",Wo="INPUT_HANDLER_METHOD_NOT_IMPLEMENTED",Jo="INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD",Do="INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER",Ro="FIELD_VAL_NOT_DEFINED",Zo="COMPUTED_VAL_NOT_DEFINED",Ho="UNKNOWN_REQUEST_NAME",Xo="UNKNOWN_COMPONENT_NAME",To="warn",jh="error",Qo="hint";function uc(t,e=new $h){Fo(e,t),ko(e,t);for(let r in t.views)Go(e,t.views[r],t);return e}function Go(t,e,r){Yo(t,e),Po(t,e),xo(t,e,r)}function Yo(t,e){let{nodes:r}=e.ctx;for(let s=0;s<r.length;s++){let i=r[s];if(i instanceof Ke){let n=r[s+1];if(!(n instanceof We||n instanceof Vt))t.error(Ao,{node:i})}}}var Bo={};function Po(t,e){for(let r of e.ctx.events)for(let s of r.handlers){let{name:i,modifiers:n}=s,h=Ir[i]??Bo;for(let u of n)if(h[u]===void 0)t.warn(Io,{name:i,modifier:u,handler:s,event:r})}}function Co(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 xo(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[_];dt(t,l,u,h,s,i)}}}function Fo(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 de){if(r[c.name]===void 0){if(t.warn(Lo,{name:c.name,handler:f,event:o}),n[c.name]!==void 0)t.hint(Do,{name:c.name,handler:f,event:o})}}else if(c instanceof Pt){if(n[c.name]===void 0){if(t.warn(Wo,{name:c.name,handler:f,event:o}),r[c.name]!==void 0)t.hint(Jo,{name:c.name,handler:f,event:o})}}}}}function dt(t,e,r,s,i,n){if(e instanceof be||e instanceof Pt){let{name:h}=e;if(r[h]===void 0&&s[h]===void 0)t.error(Ro,{val:e,name:h})}else if(e instanceof qe){let{name:h}=e;if(i[h]===void 0)t.error(Zo,{val:e,name:h})}else if(e instanceof Ee)dt(t,e.seqVal,r,s,i,n),dt(t,e.keyVal,r,s,i,n);else if(e instanceof Me){if(n.lookupRequest(e.name)===null)t.warn(Ho,{name:e.name})}else if(e instanceof Oe){if(n.lookupComponent(e.name)===null)t.warn(Xo,{name:e.name})}else if(e instanceof F&&!Co(e.name))t.warn(Ko,{name:e.name});else if(!(e instanceof L))console.log(e)}function ko(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 $e){for(let y of _.items)if(y instanceof Et)dt(t,y.value,u,h,r,s)}if(l!==null)for(let{val:y}of l)dt(t,y,u,h,r,s);if(a)dt(t,a,u,h,r,s)}for(let c of f.ctx.nodes)if(c.val)dt(t,c.val,u,h,r,s)}}class $h{constructor(){this.reports=[]}error(t,e){this.report(t,e,jh)}warn(t,e){this.report(t,e,To)}hint(t,e){this.report(t,e,Qo)}report(t,e={},r=jh){this.reports.push({id:t,info:e,level:r})}}class Vo extends k{constructor(t,e,r){super(t,e,r);this.attrs=[]}onAttributes(t,e,r){this.attrs.push({attrs:t,wrapperAttrs:e,textChild:r})}}export{Pf as tutuca,nr as seqInfoByClass,Bf as macro,me as isOrderedMap,me as isOMap,fe as isMap,cs as isList,p as isKeyed,j as isIndexed,fe as isIMap,He as injectCss,Yf as html,ir as fieldsByClass,Gf as css,_o as component,Uo as compileClassesToStyleText,tc as compileClassesToStyle,Go as checkView,uc as checkComponent,Ho as UNKNOWN_REQUEST_NAME,Ko as UNKNOWN_HANDLER_ARG_NAME,Io as UNKNOWN_EVENT_MODIFIER,Xo as UNKNOWN_COMPONENT_NAME,ge as Record,Ao as RENDER_IT_OUTSIDE_OF_LOOP,k as ParseContext,P as OMap,K as List,Vo as LintParseContext,$h as LintContext,To as LEVEL_WARN,Qo as LEVEL_HINT,jh as LEVEL_ERROR,St as KList,b as ISet,Lo as INPUT_HANDLER_NOT_IMPLEMENTED,Wo as INPUT_HANDLER_METHOD_NOT_IMPLEMENTED,Do as INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER,Jo as INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD,Y as IMap,Ro as FIELD_VAL_NOT_DEFINED,Zo as COMPUTED_VAL_NOT_DEFINED};
|
|
1
|
+
class Qt{lookup(t,e=null){return e}setValue(t,e){return t}updateBindings(t,e){}isFrame=!0}class bt extends Qt{constructor(t){super();this.binds=t}lookup(t,e){return t}setValue(t,e){return e}withIndex(t){return new bt({...this.binds,key:t})}withKey(t){return new bt({...this.binds,key:t})}updateBindings(t,e){Object.assign(e,this.binds)}isFrame=!1}class pe extends Qt{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 lr(this.field,t)}withKey(t){return new _r(this.field,t)}}class cr extends Qt{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 _r extends cr{}class lr extends cr{}var J=Symbol("NONE");class ar extends Qt{constructor(t,e){super();this.seqField=t,this.keyField=e}lookup(t,e=null){let r=t?.get(this.seqField,J),s=t?.get(this.keyField,J);return s!==J&&r?.get?r.get(s,e):e}setValue(t,e){let r=t?.get(this.seqField,J),s=t?.get(this.keyField,J);return r===J||s===J?t:t.set(this.seqField,r.set(s,e))}updateBindings(t,e){e.key=t?.get(this.keyField,null)}}class v{constructor(t=[]){this.steps=t}concat(t){return new v(this.steps.concat(t))}popStep(){return new v(this.steps.slice(0,-1))}lookup(t,e=null){let r=t;for(let s of this.steps)if(r=s.lookup(r,J),r===J)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,J),s===J)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,J),r===J)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}=ui(t.previousSibling),{eid:z,cid:d,vid:E}=t.dataset;if(z!==void 0)o.push(z);if(d!==void 0){let Ot=i.getComponentForId(+d,E);if(_){if(f=Kh(Ot,o,E,e),f===null&&n)return Wh;_=!1}let Mt=Lh(Ot,c,E);if(Mt)h.push(Mt);o=[],c=[]}if(l!==void 0)c.push({nid:l,si:a,sk:y})}u+=1,t=t.parentNode}return[new v(h.reverse()),f]}static fromEvent(t,e,r,s,i=!0){let{type:n,target:h}=t;return v.fromNodeAndEventName(h,n,e,r,s,i)}}var hi={};function ui(t){if(t?.nodeType===8&&t.textContent[0]==="§"){let e=ui(t.previousSibling);if(e!==hi)return e;try{return JSON.parse(t.textContent.slice(1,-1))}catch(r){console.warn(r,t)}}return hi}function Kh(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 Lh(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 Wh=[null,null];class yr{constructor(){this.pathChanges=[]}add(t){return this.pathChanges.push(t),this}field(t){return this.add(new pe(t))}index(t,e){return this.add(new lr(t,e))}key(t,e){return this.add(new _r(t,e))}}var Jh=/^[a-zA-Z][a-zA-Z0-9_]*$/,ut=(t)=>Jh.test(t),Rh=/^-?[0-9]+(\.[0-9]+)?$/,oi=(t,e)=>wr.parse(t,e),Gt=(t,e)=>new L(t),Dh=(t,e)=>ut(t)?new F(t):null,Zh=(t,e)=>ut(t)?new Me(t):null,Th=(t,e)=>ut(t)?new pr(t):null,Xh=(t,e)=>ut(t)?new li(t):null,Hh=(t,e)=>ut(t)?new qe(t):null,Qh=(t,e)=>ut(t)?new Ee(t):null,Gh=(t,e)=>ut(t)?new be(t):null;class fi{constructor(){this.allowFieldOnly(),this.bindValIt=new pr("it"),this.nullConstVal=new L(null)}const(t){return new L(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 je(s,i):null}parse(t,e){switch(Yh(t)){case ai:return this.parseIfOk(t,e,this.okStrTpl,oi);case gi:return this.parseIfOk(t,e,this.okStrTpl,Gt);case yi:return this._parseSeqAccess(t,e);case Se:return this.parseIfOk(t,e,this.okStrTpl,oi)}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,Gt);case 39:return this.parseIfOk(t.slice(1,-1),e,this.okStrTpl,Gt);case 64:return this.parseIfOk(t.slice(1),e,this.okBind,Th);case 42:return this.parseIfOk(t.slice(1),e,this.okDyn,Xh);case 46:return this.parseIfOk(t.slice(1),e,this.okField,Hh);case 36:return this.parseIfOk(t.slice(1),e,this.okComputed,Qh);case 33:return this.parseIfOk(t.slice(1),e,this.okRequest,Gh)}let s=Rh.test(t)?parseFloat(t):null;if(Number.isFinite(s))return this.parseIfOk(s,e,this.okConst,Gt);else if(t==="true"||t==="false")return this.parseIfOk(t==="true",e,this.okConst,Gt);else if(r>=97&&r<=122)return this.parseIfOk(t,e,this.okName,Dh);else if(r>=65&&r<=90)return this.parseIfOk(t,e,this.okType,Zh);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,Oe)}parseAlter(t,e){return this._parseHandler(t,e,ci)}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 de{render(t,e){}eval(t){}toPathItem(){return null}}class L extends de{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 gr extends de{}class wr extends gr{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 L(h);s[n]=o,i&&=o instanceof L}return i?new L(s.map((n)=>n.value).join("")):new wr(s)}}class F extends gr{constructor(t){super();this.name=t}eval(t){return t.lookupName(this.name)}toString(){return this.name}}class Oe extends F{eval(t){return t.getInputHandler(this.name)??_i("input",this.name)}}class ci extends F{eval(t){return t.getAlterHandler(this.name)??_i("alter",this.name)}}var _i=(t,e)=>function(...r){return console.warn("handler not found",{type:t,name:e,args:r},this),this};class Me extends F{eval(t){return t.lookupType(this.name)}}class be extends F{eval(t){return t.lookupRequest(this.name)}toString(){return`!${this.name}`}}class Yt extends F{eval(t){return t.lookupFieldRaw(this.name)}toString(){return`.${this.name}`}}class zr extends de{render(t,e){return this.eval(t)}}class Bt extends zr{constructor(t){super();this.name=t}}class pr extends Bt{eval(t){return t.lookupBind(this.name)}toString(){return`@${this.name}`}}class li extends Bt{eval(t){return t.lookupDynamic(this.name)}toPathItem(){return null}toString(){return`*${this.name}`}}class qe extends Bt{eval(t){return t.lookupField(this.name)}toPathItem(){return new pe(this.name)}toRawFieldVal(){return new Yt(this.name)}toString(){return`.${this.name}`}}class Ee extends Bt{eval(t){return t.lookupComputed(this.name)}toString(){return`$${this.name}`}}class je extends zr{constructor(t,e){super();this.seqVal=t,this.keyVal=e}toPathItem(){return new ar(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 ai=0,yi=1,Se=2,gi=3;function Yh(t){let e=0,r=0;for(let s=0;s<t.length;s++)switch(t.charCodeAt(s)){case 91:if(e>0)return Se;e+=1;break;case 93:if(r>0||e===0)return Se;r+=1;break;case 123:return ai;case 125:return gi}if(e>0||r>0)return e===1&&r===1?yi:Se;return-1}var w=new fi;class qt{constructor(t){this.items=t}eval(t){return{}}static parse(t,e,r=!1){return Mr(e).parse(t,r)}isConstant(){return!1}}var Bh="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",Ph=new Set(Bh.split(","));class wi{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 Et(t,s)),this.hasDynamic||=!(s instanceof L)}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 pi(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)??Pt}parseElse(t){if(this.ifAttr)this.ifAttr.elseVal=w.parseAttr(t,this.px)??Pt}parseEvent(t,e){let[r,...s]=t.slice(3).split("+"),i=br.parse(e,this.px);if(i){if(this.events===null)this.events=this.px.registerEvents(),this.attrs??=[],this.attrs.push(new $e("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 zi(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===""&&Ph.has(n)?!0:h;this.attrs.push(new $e(n,w.const(o)))}}let{attrs:r,hasDynamic:s}=this;return[s?new Ae(r):dr.fromAttrs(r??[]),this.wrapperAttrs,this.textChild]}}class dr extends qt{eval(t){return this.items}static fromAttrs(t){let e={};for(let r of t)e[r.name]=r.value.eval(null);return new dr(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 Ae extends qt{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 $e(t,new L(e)))}toMacroVars(){let t={};for(let e of this.items)t[e.name]=e.value.toString();return t}}class Or{constructor(t){this.name=t}}class Et extends Or{constructor(t,e){super(t);this.value=e}eval(t){return this.value.eval(t)}}class $e extends Et{}class zi extends Et{constructor(t){super("dangerouslySetInnerHTML",t??w.nullConstVal)}eval(t){return{__html:`${this.value.eval(t)}`}}}var Pt=w.nullConstVal;class pi extends Or{constructor(t,e){super(t);this.condVal=e,this.thenVal=this.elseVal=Pt}get anyBranchIsSet(){return this.thenVal!==Pt||this.elseVal!==Pt}eval(t){return this.condVal.eval(t)?this.thenVal.eval(t):this.elseVal.eval(t)}}var Sr=null;function Mr(t){return Sr??=new wi(t),Sr.clear(t),Sr}class br{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 br(i,n)}}class qr{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 jt{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 Ft extends jt{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 xt extends Ft{render(t,e){return e.renderComment(this.v)}}function Ch(t){for(let e=0;e<t.length;e++){let r=t[e];if(r.isConstant())t[e]=new Ir(r);else r.optimize()}}function $r(t){if(t.isConstant())return new Ir(t);return t.optimize(),t}class Ar extends jt{constructor(t){super();this.childs=t}isConstant(){return this.childs.every((t)=>t.isConstant())}optimize(){Ch(this.childs)}}class Ue extends Ar{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 Ie extends Ar{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 Ct=(t)=>t.length===1?t[0]:new Ie(t),xh=/^[a-zA-Z][a-zA-Z0-9-]*$/,Si=null;class tt extends jt{constructor(t,e){super();this.nodeId=t,this.val=e}toPathItem(){return this.val.toPathItem()}static parse(t,e){Si??=e.newDOMParser();let r=Si.parseFromString(t,"text/html").body.childNodes;return tt.fromDOM(r[0]??new e.Text(""),e)}static fromDOM(t,e){if(e.isTextNode(t))return new Ft(t.textContent);else if(e.isCommentNode(t))return new xt(t.textContent);let{childNodes:r,attributes:s,tagName:i}=t,n=Array(r.length);for(let h=0;h<r.length;h++)n[h]=tt.fromDOM(r[h],e);if(i==="X"){if(s.length===0)return Ct(n);let{name:h,value:u}=s[0],o=s.getNamedItem("as")?.value??null;switch(h){case"slot":return new We(null,w.const(u),Ct(n));case"text":{let f=w.parseText(u,e);return f!==null?new jr(null,f):null}case"render":return e.addNodeIf(ji,w.parseRender(u,e),o);case"render-it":return e.addNodeIf(Le,w.bindValIt,o);case"render-each":return Vt.parse(e,w,u,o,s);case"show":return e.addNodeIf(Kr,w.parseCondValue(u,e),Ct(n));case"hide":return e.addNodeIf(Lr,w.parseCondValue(u,e),Ct(n))}return new xt(`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]??Ct(n)}let[u,o]=qt.parse(s,e,!0);return e.onAttributes(u,o,null),di(e.newMacroNode(h,u.toMacroVars(),n),e,o)}else if(xh.test(i)){let[h,u,o]=qt.parse(s,e);if(e.onAttributes(h,u,o),o)n.unshift(new jr(null,o));let f=i!=="PRE"?mh(n):n;return di(new Ue(i.toLowerCase(),h,f),e,u)}return new xt(`Error: InvalidTagName ${i}`)}}function di(t,e,r){if(r)for(let s=r.length-1;s>=0;s--){let i=Fh(r[s],e);if(i)i.wrapNode(t),t=i}return t}function Fh(t,e){let r=Nh[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 Ei extends jt{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 xt(`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=$r(this.node)}}class Ur{constructor(t,e){this.defaults=t,this.rawView=e}expand(t){return tt.parse(this.rawView,t)}}class Ke extends tt{constructor(t,e,r){super(t,e);this.viewId=r}}class ji extends Ke{render(t,e){let r=t.enter(this.val.eval(t),{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}}class Le extends Ke{render(t,e){return e.renderIt(t,this.nodeId,"",this.viewId)}pathInNext=!0}class Vt extends Ke{constructor(t,e,r){super(t,e,r);this.iterInfo=new Wr(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=Mr(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 jr extends tt{render(t,e){return e.renderText(this.val.eval(t))}}class Ir extends jt{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 ot extends tt{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=$r(this.node)}static register=!1}class Kr extends ot{render(t,e){return this.val.eval(t)?this.node.render(t,e):e.renderEmpty()}}class Lr extends ot{render(t,e){return this.val.eval(t)?e.renderEmpty():this.node.render(t,e)}}class $i extends ot{render(t,e){return this.node.render(t.pushViewName(this.val.eval(t)),e)}}class We extends ot{optimize(){this.node.optimize()}}class Ai extends ot{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 bt({})}wrapNode(t){this.node=t,this.node.setDataAttr("data-nid",this.nodeId)}static register=!0}class Je extends ot{constructor(t,e){super(t,e);this.iterInfo=new Wr(e,null,null,null)}render(t,e){return e.renderEachWhen(t,this.iterInfo,this.node,this.nodeId)}toPathItem(){return new bt({})}static register=!0}class Wr{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)??kh,i=this.enrichWithVal?.eval(t)??null;return{seq:e,filter:r,loopWith:s,enricher:i}}}var Vh=(t,e,r)=>!0,kh=(t)=>({seq:t}),Nh={slot:We,show:Kr,hide:Lr,each:Je,scope:Ai,"push-view":$i};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 Ui(t);return this.events.push(e),e}newMacroNode(t,e,r){let s=[],i={_:new Ie(s)};for(let h of r)if(h instanceof We)i[h.val.value]=h.node;else if(!(h instanceof Ft)||!h.isWhiteSpace())s.push(h);let n=new Ei(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 Er=(t)=>t instanceof Ft&&t.isWhiteSpace(),Oi=(t)=>t instanceof Ue||t instanceof Ie&&t.childs[0]instanceof Ue;function mh(t){let e=t.length;if(e===0)return t;let r=0,s=!1;if(Er(t[0]))r=1,s=!0;if(e>1&&Er(t[e-1]))e-=1,s=!0;for(let i=1;i<e-1;i++){let n=t[i];if(Er(n)&&Oi(t[i-1])&&Oi(t[i+1])&&n.hasNewLine())n.condenseWhiteSpace()}return s?t.slice(r,e):t}class Re{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=tt.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=$r(this.anode)}render(t,e){return this.anode.render(t,e)}}class Ui{constructor(t){this.id=t,this.handlers=[]}add(t,e,r){this.handlers.push(new Ii(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 Ii{constructor(t,e,r){this.name=t,this.handlerCall=e,this.modifierWrapper=su(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 vh=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),De=(t)=>(e)=>(r,s,i,n)=>t(n)?e(r,s,i,n):r,Mi=(t)=>De((e)=>e.e.key===t),bi=De(({e:t})=>vh&&t.metaKey||t.ctrlKey),tu=De(({e:t})=>t.metaKey),eu=De(({e:t})=>t.altKey),qi={ctrl:bi,cmd:bi,meta:tu,alt:eu},Jr={keydown:{send:Mi("Enter"),cancel:Mi("Escape"),...qi},click:{...qi}},ru=(t,e)=>t;function su(t,e){if(e.length===0)return ru;let r=Jr[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 Rr{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 Dr{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 Zr{getKey(t,e,r){return r.call(t)}}class Tr{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 Ze{constructor(){this.getComponentSymbol=Symbol("getComponent"),this.byId=new Map,this.computedCache=new Tr}setNullComputedCache(){this.computedCache=new Zr}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:Li}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 Te{constructor(t=new Ze,e=null){this.comps=t,this.parent=e,this.byName={},this.reqsByName={},this.macros={}}enter(){return new Te(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 qr(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 Xr{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 Ki extends Xr{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 $t=(t)=>typeof t==="string",iu=0;class Hr{constructor(t,e,r,s={},i="",n="",h="",u={},o={},f={},c={},_={},l={},a={},y={}){this.id=iu++,this.name=t,this.Class=e,this.views={main:new Re("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??Li};for(let z in s){let d=s[z],{view:E,style:Ot}=$t(d)?{view:d}:d;this.views[z]=new Re(z,E,Ot)}this._rawDynamic=a,this.dynamic={},this.scope=null}compile(t){for(let e in this._rawDynamic){let r=this._rawDynamic[e];if($t(r)){let s=w.parseDynamic(r,this.views.main.ctx);this.dynamic[e]=new Xr(e,s,Symbol(e))}else if($t(r?.default)&&$t(r?.for)){let s=w.parseDynamic(r.default,this.views.main.ctx),[i,n]=r.for.split(".");if($t(i)&&$t(n))this.dynamic[e]=new Ki(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 Li(t){return t}var Wi=Symbol("STOP"),Yr=Symbol("NEXT");class kt{constructor(t,e){this.head=t,this.tail=e}push(t){return new kt(t,this)}lookup(t,e=null){let{tail:r}=this,s=this.head.lookup(t);return s===Wi?e:s===Yr?r!==null?r.lookup(t,e):e:s}*[Symbol.iterator](){let t=this;while(t!==null)yield t.head,t=t.tail}}class Qr{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?Wi:Yr:e}}class Gr{constructor(t){this.bindings=t}lookup(t){let e=this.bindings[t];return e===void 0?Yr:e}}class T{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 T(t,e.tail.head.it,e.tail,r,s,i)}static root(t,e,r){let s=new kt(new Qr(e,{it:e},!0),null),i=new kt(new Gr({}),null),n=new kt("main",null);return new T(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 Qr(t,e,r));return new T(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 T(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 Gr(e));return new T(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 Ri{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 Pr{constructor(t,e){this.comps=t,this.transactions=[],this.state=new Ri(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 Fr(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 Ti(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)??nu(e),o=s?.onResName??e,f=(c,_,l,a,y)=>{let d=new Zi(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 Di(t,e,r,this,s))}}function nu(t){return()=>{throw Error(`Request not found: ${t}`)}}function hu(){return this}class Cr{constructor(t,e){this.path=t,this.transactor=e,this.parentTransaction=null,this._task=null}get task(){return this._task??=new Xi,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 T.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 uu=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Ji=(t)=>Number.isNaN(t)?null:t;function Br(t){return t.target.type==="checkbox"?t.target.checked:(t instanceof CustomEvent?t.detail:t.target.value)??null}class Di extends Cr{constructor(t,e,r,s,i){super(t,s);this.e=e,this.handler=r,this.dragInfo=i}buildRootStack(t,e){return T.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 Br(e);case"valueAsInt":return Ji(parseInt(Br(e),10));case"valueAsFloat":return Ji(parseFloat(Br(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 uu&&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 kr(this.path,this.transactor,this);case"dragInfo":return this.dragInfo}return null}}class xr extends Cr{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]??hu}getHandlerAndArgs(t,e,r){return[this.getHandlerForName(r.getCompFor(e)),[...this.args,new kr(this.path,this.transactor,this)]]}}class Zi extends xr{handlerProp="response"}class Fr extends xr{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 Ti extends Fr{handlerProp="bubble";stopPropagation(){this.opts.bubbles=!1}}class Xi{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 Hi(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 kr extends Vr{stopPropagation(){return this.parent.stopPropagation()}}class Hi extends yr{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 Nr{constructor(t,e,r,s,i){this.rootNode=t,this.comps=r,this.compStack=new Te(r),this.transactor=new Pr(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]=v.fromEvent(t,i,n,h,u);if(r){let c=ou(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 Qi(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 T.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()}),Xe("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 v([]),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 Xe(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 ou(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 Qi{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 He 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 He(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 L&&e.value!=="")this._addClasses(e.value);return!0}return!1}}function Nt(t,e){if(!t)throw Error(e)}function A(t){Nt(t!==1/0,"Cannot perform this action with an infinite size.")}function Gi(t,e,r,s,i,n){return A(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 fu=(t,e)=>e,cu=(t,e)=>[e,t],mr=(t)=>function(...e){return!t.apply(this,e)},Yi=(t)=>function(...e){return-t.apply(this,e)};function ln(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 Bi=(t,e)=>t<e?1:t>e?-1:0,U={done:!0,value:void 0};class an{constructor(t){this.next=t}[Symbol.iterator](){return this}}function W(t){return new an(t)}function M(t){let e=[void 0,void 0],r={done:!1,value:void 0};return W(()=>{if(t(e))return r.value=[e[0],e[1]],r;return U})}var _u=W(()=>U),ft=()=>_u;function ke(t){let e=0,r={done:!1,value:void 0};return W(()=>{if(e===t)return U;return r.value=e++,r})}function se(t,e){return M((r)=>{let s=t.next();if(s.done)return!1;return e(s.value[0],s.value[1],r),!0})}function yn(t){if(Array.isArray(t))return!0;return!!Ne(t)}var lu=(t)=>!!(t&&typeof t.next==="function");function gn(t){return Ne(t)?.call(t)}function Ne(t){let e=t&&t[Symbol.iterator];if(typeof e==="function")return e}function au(t){let e=Ne(t);return e&&e===t.entries}function yu(t){let e=Ne(t);return e&&e===t.keys}var ie="delete",S=5,q=1<<S,I=q-1,g={},hs=()=>({value:!1});function Z(t){if(t)t.value=!0}class me{}function Ut(t){if(t.size===void 0)t.size=t.__iterate(wn);return t.size}function rt(t,e){if(typeof e!=="number"){let r=e>>>0;if(String(r)!==e||r===4294967295)return NaN;e=r}return e<0?Ut(t)+e:e}var wn=()=>!0,zn=(t)=>t<0||Object.is(t,-0),ne=(t,e,r)=>(t===0&&!zn(t)||r!==void 0&&(t??0)<=-r)&&(e===void 0||r!==void 0&&e>=r),pn=(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)=>pn(t,e,0),he=(t,e)=>pn(t,e,e),Sn="@@__IMMUTABLE_ITERABLE__@@",Be="@@__IMMUTABLE_KEYED__@@",Pe="@@__IMMUTABLE_INDEXED__@@",st="@@__IMMUTABLE_ORDERED__@@",ue="@@__IMMUTABLE_SEQ__@@",dn="@@__IMMUTABLE_LIST__@@",On="@@__IMMUTABLE_MAP__@@",Mn="@@__IMMUTABLE_SET__@@",bn="@@__IMMUTABLE_STACK__@@",qn="@@__IMMUTABLE_RECORD__@@";function C(t,e){return typeof t==="object"&&t!==null&&e in t}var R=(t)=>C(t,Sn),p=(t)=>C(t,Be),j=(t)=>C(t,Pe),ls=(t)=>p(t)||j(t),k=(t)=>C(t,st),as=(t)=>C(t,ue),ys=(t)=>C(t,dn),oe=(t)=>C(t,On),gs=(t)=>C(t,Mn),ws=(t)=>C(t,bn),at=(t)=>C(t,qn),x=(t)=>R(t)||at(t),ve=(t)=>oe(t)&&k(t),En=(t)=>gs(t)&&k(t),Pi=(t)=>typeof t==="object"&&t!==null&&typeof t.equals==="function"&&typeof t.hashCode==="function";function jn(t){let e=B(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=Zt,e.__iterate=function(r,s){return t.__iterate((i,n)=>r(n,i,this),s)},e.__iteratorUncached=function(r){return se(t.__iterator(r),(s,i,n)=>{n[0]=i,n[1]=s})},e}function $n(t,e,r){let s=B(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 se(t.__iterator(i),(n,h,u)=>{u[0]=n,u[1]=e.call(r,h,n,t)})},s}function An(t,e){let r=B(t);if(r._iter=t,r.size=t.size,r.reverse=()=>t,t.flip)r.flip=function(){let s=jn(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=Zt,r.__iterate=function(s,i){let n=0;if(i)Ut(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)Ut(t);let n=this.size;return se(t.__iterator(!s),(h,u,o)=>{o[0]=e?h:s?n-++i:i++,o[1]=u})},r}function Un(t,e,r,s){let i=t.size;if(ne(e,r,i))return t;if(i===void 0&&(e<0||r<0))return Un(t.toSeq().cacheResult(),e,r,s);let n=Rt(e,i),u=he(r,i)-n,o;if(!Number.isNaN(u))o=Math.max(0,u);let f=B(t);if(f.size=o===0?o:t.size&&o||void 0,!s&&as(t)&&o>=0)f.get=function(c,_){return c=rt(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,z)=>{if(l<n){l++;return}if(o!==void 0&&a>=o)return!1;if(a++,c(y,s?z:a-1,this)===!1)return!1},_),a},f.__iteratorUncached=function(c){if(o!==0&&c)return this.cacheResult().__iterator(c);if(o===0)return ft();let _=t.__iterator(c),l=0,a=0;if(s)return W(()=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return U;let y=_.next();if(y.done)return y;return a++,y});return M((y)=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return!1;let z=_.next();if(z.done)return!1;return a++,y[0]=a-1,y[1]=z.value[1],!0})},f}function Ci(t,e,r){if(!e)e=ln;let s=p(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?Os(n):j(t)?lt(n):vt(n)}function Qe(t,e,r){if(!e)e=ln;if(r){let s=t.toSeq().map((i,n)=>[i,r(i,n,t)]).reduce((i,n)=>xi(e,i[1],n[1])?n:i);return s&&s[0]}return t.reduce((s,i)=>xi(e,s,i)?i:s)}function xi(t,e,r){let s=t(r,e);return s===0&&r!==e&&(r===void 0||r===null||Number.isNaN(r))||s>0}function vr(t,e,r,s){let i=B(t),n=new fe(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=N(_);return gn(h?l.reverse():l)}),o=0,f=Array(u.length),c=Array(u.length);return M((_)=>{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 gu(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 it=(t)=>typeof t==="object"&&(x(t)||Array.isArray(t)||gu(t));function Kn(t){if(In(t)&&typeof t!=="string")return t;if(k(t))return t.toArray();throw TypeError(`Invalid keyPath: expected Ordered Collection or Array: ${t}`)}var wu=(t,e)=>x(t)?t.has(e):it(t)&&Object.hasOwn(t,e);function Ln(t,e,r){return x(t)?t.get(e,r):!wu(t,e)?r:typeof t.get==="function"?t.get(e):t[e]}function zs(t,e,r){let s=Kn(e),i=0;while(i!==s.length)if(t=Ln(t,s[i++],g),t===g)return r;return t}var Wn=(t,e)=>zs(t,e,g)!==g;function $(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!!(Pi(t)&&Pi(e)&&t.equals(e))}function Ce(t){if(!t||typeof t!=="object")return t;if(!R(t)){if(!it(t))return t;t=nt(t)}if(p(t)){let r={};return t.__iterate((s,i)=>{r[String(i)]=Ce(s)}),r}let e=[];return t.__iterate((r)=>{e.push(Ce(r))}),e}function ps(t,e){if(t===e)return!0;if(!R(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||p(t)!==p(e)||j(t)!==j(e)||k(t)!==k(e))return!1;if(t.size===0&&e.size===0)return!0;let r=!ls(t);if(k(t)){let h=t.entries();return!!(e.every((u,o)=>{let f=h.next().value;return f&&$(f[1],u)&&(r||$(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?!$(h,t.get(u,g)):!$(t.get(u,g),h))return i=!1,!1;return!0});return i&&t.size===n}var tr=(t)=>t>>>1&1073741824|t&3221225471;function X(t){if(t===null||t===void 0)return Fi(t);if(typeof t.hashCode==="function")return tr(t.hashCode(t));let e=Ou(t);if(e===null||e===void 0)return Fi(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return zu(e);case"string":return e.length>Mu?pu(e):us(e);case"object":case"function":return du(e);case"symbol":return Su(e);default:if(typeof e.toString==="function")return us(e.toString());throw Error(`Value type ${typeof e} cannot be hashed.`)}}var Fi=(t)=>t===null?1108378658:1108378659;function zu(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 tr(e)}function pu(t){let e=rs[t];if(e===void 0){if(e=us(t),es===bu)es=0,rs={};es++,rs[t]=e}return e}function us(t){let e=0;for(let r=0;r<t.length;r++)e=31*e+t.charCodeAt(r)|0;return tr(e)}function Su(t){let e=ki[t];if(e!==void 0)return e;return e=Jn(),ki[t]=e,e}function du(t){let e=Vi.get(t);if(e!==void 0)return e;return e=Jn(),Vi.set(t,e),e}var Ou=(t)=>t.valueOf!==Object.prototype.valueOf?t.valueOf():t;function Jn(){let t=++ts;if(ts&1073741824)ts=0;return t}var Vi=new WeakMap,ki=Object.create(null),ts=0,Mu=16,bu=255,es=0,rs={};function qu(t){if(t.size===1/0)return 0;let e=k(t),r=p(t),s=e?1:0;return t.__iterate(r?e?(i,n)=>{s=31*s+Ni(X(i),X(n))|0}:(i,n)=>{s=s+Ni(X(i),X(n))|0}:e?(i)=>{s=31*s+X(i)|0}:(i)=>{s=s+X(i)|0}),Eu(t.size,s)}var Ni=(t,e)=>t^e+2654435769+(t<<6)+(t>>2)|0;function Eu(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=tr(e^e>>>16),e}function mt(t){try{return typeof t==="string"?JSON.stringify(t):String(t)}catch{return JSON.stringify(t)}}var O=(t,e)=>t===e?t:as(t)?e:t.create?t.create(e):t.constructor(e),ju=(t,e)=>O(t,(p(t)?Q:j(t)?yt:gt)(e)),mi=(...t)=>t,N=(t)=>R(t)?t:nt(t);class H{size=0;static{this.prototype[Sn]=!0,this.prototype.__toStringMapper=mt,this.prototype[Symbol.iterator]=this.prototype.values,this.prototype.toJSON=this.prototype.toArray,this.prototype.contains=this.prototype.includes}equals(t){return ps(this,t)}hashCode(){return this.__hash??(this.__hash=qu(this))}toArray(){A(this.size);let t=Array(this.size||0),e=p(this),r=0;return this.__iterate((s,i)=>{t[r++]=e?[i,s]:s}),t}toIndexedSeq(){return new Xn(this)}toJS(){return Ce(this)}toKeyedSeq(){return new js(this,!0)}toMap(){throw Error("toMap: not patched — import CollectionConversions")}toObject(){A(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 Hn(this)}toSeq(){return j(this)?this.toIndexedSeq():p(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=p(this),r=[this,...t].map((s)=>{if(!R(s))s=e?Dn(s):Zn(Array.isArray(s)?s:[s]);else if(e)s=Q(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&&p(s)||j(this)&&j(s))return s}return O(this,new Tn(r))}includes(t){return this.some((e)=>$(e,t))}every(t,e){A(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=p(this),i=B(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 M((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=p(this),s=[[],[]];return this.__iterate((i,n)=>{s[t.call(e,i,n,this)?1:0].push(r?[n,i]:i)}),s.map((i)=>ju(this,i))}find(t,e,r){let s=this.findEntry(t,e);return s?s[1]:r}forEach(t,e){return A(this.size),this.__iterate(e?t.bind(e):t)}join(t){A(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 W(()=>{let r=t.next();if(r.done)return U;return e.value=r.value[0],e})}map(t,e){return O(this,$n(this,t,e))}reduce(t,e=g,r){return Gi(this,t,e,r,e===g,!1)}reduceRight(t,e=g,r){return Gi(this,t,e,r,e===g,!0)}reverse(){return O(this,An(this,p(this)))}slice(t,e){return O(this,Un(this,t,e,p(this)))}some(t,e){A(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,Ci(this,t))}values(){let t=this.__iterator(),e={done:!1,value:void 0};return W(()=>{let r=t.next();if(r.done)return U;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 Ut(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 fe(t._cache);let e=t.toSeq().map(cu).toIndexedSeq();return e.fromEntrySeq=()=>t.toSeq(),e}filterNot(t,e){return this.filter(mr(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(wn,null,t)}flatMap(t,e){return O(this,this.toSeq().map((r,s)=>(p(this)?Q:j(this)?yt:gt)(t.call(e,r,s,this))).flatten(!0))}flatten(t){let e=this,r=p(this),s=B(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)&&R(_))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 M((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)&&R(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 Qn(this)}get(t,e){return this.find((r,s)=>$(s,t),void 0,e)}getIn(t,e){return zs(this,t,e)}groupBy(t,e){throw Error("groupBy: not patched — import CollectionConversions")}has(t){return this.get(t,g)!==g}hasIn(t){return Wn(this,t)}isSubset(t){let e=typeof t.includes==="function"?t:N(t);return this.every((r)=>e.includes(r))}isSuperset(t){return(typeof t.isSubset==="function"?t:N(t)).isSubset(this)}keyOf(t){return this.findKey((e)=>$(e,t))}keySeq(){return this.toSeq().map(fu).toIndexedSeq()}last(t){return this.toSeq().reverse().first(t)}lastKeyOf(t){return this.toKeyedSeq().reverse().keyOf(t)}max(t){return Qe(this,t)}maxBy(t,e){return Qe(this,e,t)}min(t){return Qe(this,t?Yi(t):Bi)}minBy(t,e){return Qe(this,e?Yi(e):Bi,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=p(this),i=B(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 M((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(mr(t),e)}sortBy(t,e){return O(this,Ci(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=B(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 W(()=>{if(u)return U;let o=n.next();if(o.done)return o;if(!t.call(e,o.value[1],o.value[0],h))return u=!0,U;return o})},O(this,s)}takeUntil(t,e){return this.takeWhile(mr(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 Q=(t)=>p(t)?t:Os(t);class Ss extends H{static{this.prototype[Be]=!0,this.prototype.__toStringMapper=(t,e)=>`${mt(e)}: ${mt(t)}`,this.prototype[Symbol.iterator]=H.prototype.entries,this.prototype.toJSON=function(){A(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}}flip(){return O(this,jn(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 yt=(t)=>j(t)?t:lt(t);class It extends H{static{this.prototype[Pe]=!0,this.prototype[st]=!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=rt(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=rt(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=B(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 M((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=vr(this.toSeq(),lt.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(mi,...t)}zipAll(...t){let e=[this,...t];return O(this,vr(this,mi,e,!0))}zipWith(t,...e){let r=[this,...e];return O(this,vr(this,t,r))}}var gt=(t)=>R(t)&&!ls(t)?t:vt(t);class er extends H{static{this.prototype.has=H.prototype.includes,this.prototype.contains=H.prototype.includes,this.prototype.keys=er.prototype.values}get(t,e){return this.has(t)?t:e}includes(t){return this.has(t)}keySeq(){return this.valueSeq()}}N.Keyed=Q;N.Indexed=yt;N.Set=gt;var ss=It.prototype,nt=(t)=>t===void 0||t===null?qs():x(t)?t.toSeq():$u(t),B=(t)=>Object.create((p(t)?Dt:j(t)?wt:Ms).prototype);class ct extends H{static{this.prototype[ue]=!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 W(()=>{if(s===r)return U;return i.value=e[t?r-++s:s++],i})}return this.__iteratorUncached(t)}}var ds={cacheResult:ct.prototype.cacheResult,__iterateUncached:ct.prototype.__iterateUncached,__iterate:ct.prototype.__iterate,__iterator:ct.prototype.__iterator},Os=(t)=>t===void 0||t===null?qs().toKeyedSeq():R(t)?p(t)?t.toSeq():t.fromEntrySeq():at(t)?t.toSeq():Dn(t);class Dt extends Ss{static{this.prototype[ue]=!0,Object.assign(this.prototype,ds)}toSeq(){return this}toKeyedSeq(){return this}}var lt=(t)=>t===void 0||t===null?qs():R(t)?p(t)?t.entrySeq():t.toIndexedSeq():at(t)?t.toSeq().entrySeq():Zn(t);lt.of=(...t)=>lt(t);class wt extends It{static{this.prototype[ue]=!0,Object.assign(this.prototype,ds)}toSeq(){return this}toIndexedSeq(){return this}toString(){return this.__toString("Seq [","]")}}var vt=(t)=>(R(t)&&!ls(t)?t:lt(t)).toSetSeq();vt.of=(...t)=>vt(t);class Ms extends er{static{this.prototype[ue]=!0,Object.assign(this.prototype,ds)}toSeq(){return this}toSetSeq(){return this}}nt.isSeq=as;nt.Keyed=Os;nt.Set=vt;nt.Indexed=lt;class fe extends wt{constructor(t){super();this._array=t,this.size=t.length}get(t,e){return this.has(t)?this._array[rt(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 M((i)=>{if(s===r)return!1;let n=t?r-++s:s++;return i[0]=n,i[1]=e[n],!0})}}class bs extends Dt{static{this.prototype[st]=!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 M((n)=>{if(i===s)return!1;let h=r[t?s-++i:i++];return n[0]=h,n[1]=e[h],!0})}}class Rn extends wt{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=gn(e);if(!lu(r))return ft();let s=0;return M((i)=>{let n=r.next();if(n.done)return!1;return i[0]=s++,i[1]=n.value,!0})}}var qs=()=>new fe([]),Es=(t)=>In(t)?new fe(t):yn(t)?new Rn(t):void 0;function Dn(t){let e=Es(t);if(e)return e.fromEntrySeq();if(typeof t==="object")return new bs(t);throw TypeError(`Expected Array or collection object of [k, v] entries, or keyed object: ${t}`)}function Zn(t){let e=Es(t);if(e)return e;throw TypeError(`Expected Array or collection object of values: ${t}`)}function $u(t){let e=Es(t);if(e)return au(t)?e.fromEntrySeq():yu(t)?e.toSetSeq():e;if(typeof t==="object")return new bs(t);throw TypeError(`Expected Array or collection object of values, or keyed object: ${t}`)}class Tn extends ct{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[Be])this[Be]=!0;if(i[Pe])this[Pe]=!0;if(i[st])this[st]=!0}__iterateUncached(t,e){if(this._wrappedIterables.length===0)return 0;if(e)return this.cacheResult().__iterate(t,e);let r=this._wrappedIterables,s=!p(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 ft();if(t)return this.cacheResult().__iterator(t);let e=this._wrappedIterables,r=!p(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 M((u)=>{let o=n();if(!o)return!1;return u[0]=h++,u[1]=o.value[1],!0})}return W(()=>n()||U)}}class js extends Dt{static{this.prototype[st]=!0}constructor(t,e){super();this._iter=t,this._useKeys=e,this.size=t.size}cacheResult(){return Zt.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=An(this,!0);if(!this._useKeys)t.valueSeq=()=>this._iter.toSeq().reverse();return t}map(t,e){let r=$n(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 Xn extends wt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Zt.call(this)}includes(t){return this._iter.includes(t)}__iterateUncached(t,e){let r=0;if(e)Ut(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)Ut(this);let r=this.size;return se(this._iter.__iterator(t),(s,i,n)=>{n[0]=t?r-++e:e++,n[1]=i})}}class Hn extends Ms{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Zt.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 se(this._iter.__iterator(t),(e,r,s)=>{s[0]=r,s[1]=r})}}class Qn extends Dt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Zt.call(this)}entrySeq(){return this._iter.toSeq()}__iterateUncached(t,e){let r=0;return this._iter.__iterate((s)=>{if(s){vi(s),r++;let i=R(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 M((r)=>{while(!0){let s=e.next();if(s.done)return!1;let i=s.value[1];if(i){vi(i);let n=R(i);return r[0]=n?i.get(0):i[0],r[1]=n?i.get(1):i[1],!0}}})}}function Zt(){if(this._iter.cacheResult)return this._iter.cacheResult(),this.size=this._iter.size,this;return ct.prototype.cacheResult.call(this)}function vi(t){if(t!==Object(t))throw TypeError(`Expected [K, V] tuple: ${t}`)}var Y=(t)=>t===void 0||t===null?G():oe(t)&&!k(t)?t:G().withMutations((e)=>{let r=Q(t);A(r.size),r.forEach((s,i)=>e.set(i,s))});class $s extends Ss{static{pt(this,{asImmutable:ce,asMutable:_e,deleteIn:Kt,merge:os,mergeWith:Fn,mergeDeep:kn,mergeDeepWith:Nn,mergeDeepIn:Hs,mergeIn:Xs,setIn:Ds,update:Zs,updateIn:Ts,wasAltered:Rs,withMutations:le,removeIn:Kt,concat:os,[On]:!0,[ie]: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 Y(t)}toString(){return this.__toString("Map {","}")}get(t,e){return this._root?this._root.get(0,X(t),t,e):e}set(t,e){return en(this,t,e)}remove(t){return en(this,t,g)}deleteAll(t){let e=N(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 G()}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 ft();return Ge(this._root,!1,0)}values(){if(!this._root)return ft();return Ge(this._root,!1,1)}entries(){if(!this._root)return ft();return Ge(this._root,!1)}__iterator(t){if(!this._root)return ft();return Ge(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 G();return this.__ownerID=t,this.__altered=!1,this}return Is(this.size,this._root,t,this.__hash)}}Y.isMap=oe;class As{constructor(t,e){this.ownerID=t,this.entries=e}get(t,e,r,s){return Gn(this.entries,r,s)}iterate(t,e){return Yn(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($(s,o[f][0]))break;let _=f<c;if(_?o[f][1]===i:u)return this;if(Z(h),u||!_)Z(n);if(u&&c===1)return;if(!_&&!u&&c>=Wu)return Au(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 As(t,a)}}class rr{constructor(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}iterate(t,e){return Bn(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[sn(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 _=sn(f&o-1),l=this.nodes,a=c?l[_]:void 0,y=Ks(a,t,e+S,r,s,i,n,h);if(y===a)return this;if(!c&&y&&l.length>=Ju)return Iu(t,l,f,u,y);if(c&&!y&&l.length===2&&rn(l[_^1]))return l[_^1];if(c&&y&&l.length===1&&rn(y))return y;let z=t&&t===this.ownerID,d=c?y?f:f^o:f|o,E=c?y?Pn(l,_,y,z):Lu(l,_,z):Ku(l,_,y,z);if(z)return this.bitmap=d,this.nodes=E,this;return new rr(t,d,E)}}class Us{constructor(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}iterate(t,e){return Bn(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 _=Ks(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<Ru)return Uu(t,f,l,u)}let a=t&&t===this.ownerID,y=Pn(f,u,_,a);if(a)return this.count=l,this.nodes=y,this;return new Us(t,l,y)}}class sr{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}get(t,e,r,s){return Gn(this.entries,r,s)}iterate(t,e){return Yn(this.entries,t,e)}update(t,e,r,s,i,n,h){if(r!==this.keyHash){if(i===g)return this;return Z(h),Z(n),Ls(this,t,e,r,[s,i])}let u=i===g,o=this.entries,f=0,c=o.length;for(;f<c;f++)if($(s,o[f][0]))break;let _=f<c;if(_?o[f][1]===i:u)return this;if(Z(h),u||!_)Z(n);if(u&&c===2)return new zt(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 sr(t,this.keyHash,a)}}class zt{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 $(r,this.entry[0])?this.entry[1]:s}update(t,e,r,s,i,n,h){let u=i===g,o=$(s,this.entry[0]);if(o?i===this.entry[1]:u)return this;if(Z(h),u){Z(n);return}if(o){if(t&&t===this.ownerID)return this.entry[1]=i,this;return new zt(t,this.keyHash,[s,i])}return Z(n),Ls(this,t,e,X(s),[s,i])}}function Gn(t,e,r){for(let s=0,i=t.length;s<i;s++)if($(e,t[s][0]))return t[s][1];return r}function Yn(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 Bn(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 Ge(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 W(()=>{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 U})}var Is=(t,e,r,s)=>new $s(t,e,r,s),tn,G=()=>tn||(tn=Is(0));function en(t,e,r){let s,i;if(!t._root){if(r===g)return t;i=1,s=new As(t.__ownerID,[[e,r]])}else{let n=hs(),h=hs();if(s=Ks(t._root,t.__ownerID,0,X(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?Is(i,s):G()}function Ks(t,e,r,s,i,n,h,u){if(!t){if(n===g)return t;return Z(u),Z(h),new zt(e,s,[i,n])}return t.update(e,r,s,i,n,h,u)}var rn=(t)=>t.constructor===zt||t.constructor===sr;function Ls(t,e,r,s,i){if(t.keyHash===s)return new sr(e,s,[t.entry,i]);let n=(r===0?t.keyHash:t.keyHash>>>r)&I,h=(r===0?s:s>>>r)&I,u=new zt(e,s,i),o=n===h?[Ls(t,e,r+S,s,i)]:n<h?[t,u]:[u,t];return new rr(e,1<<n|1<<h,o)}function Au(t,e,r,s){if(!t)t=new me;let i=new zt(t,X(r),[r,s]);for(let[n,h]of e)i=i.update(t,0,X(n),n,h);return i}function Uu(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 rr(t,i,h)}function Iu(t,e,r,s,i){let n=0,h=Array(q);for(let u=0;r!==0;u++,r>>>=1)h[u]=r&1?e[n++]:void 0;return h[s]=i,new Us(t,n+1,h)}function sn(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 Pn(t,e,r,s){let i=s?t:t.slice();return i[e]=r,i}function Ku(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 Lu(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 Wu=q/4,Ju=q/2,Ru=q/4;function xe(t){if(Array.isArray(t))return t.slice();return{...t}}var Ws=(t,e,r)=>Js(t,e,Du(r));function Js(t,e,r){if(!it(t))throw TypeError(`Cannot merge into non-data-structure value: ${t}`);if(x(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?yt:Q,h=s?(u)=>{if(i===t)i=xe(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=xe(i);i[o]=c}};for(let u of e)n(u).forEach(h);return i}function Du(t){function e(r,s,i){return it(r)&&it(s)&&Zu(r,s)?Js(r,[s],e):t?t(r,s,i):s}return e}function Zu(t,e){let r=nt(t),s=nt(e);return j(r)===j(s)&&p(r)===p(s)}function Tu(t,e){if(!it(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(x(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=xe(t);if(Array.isArray(r))r.splice(e,1);else delete r[e];return r}function Xu(t,e,r){if(!it(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(x(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=xe(t);return s[e]=r,s}function Tt(t,e,r,s){if(!s)s=r,r=void 0;let i=Cn(x(t),t,Kn(e),0,r,s);return i===g?r:i}function Cn(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&&!it(e))throw TypeError(`Cannot update within non-data-structure value in path [${Array.from(r).slice(0,s).map(mt)}]: ${e}`);let u=r[s],o=h?g:Ln(e,u,g),f=Cn(o===g?t:x(o),o,r,s+1,i,n);if(f===o)return e;if(f===g)return Tu(e,u);let c=h?t?G():{}:e;return Xu(c,u,f)}var Hu=(t,e)=>Tt(t,e,()=>g),Qu=(t,e,r)=>Tt(t,e,g,()=>r);function xn(t,e,r,s){return Tt(t,[e],r,s)}function ce(){return this.__ensureOwner()}function _e(){return this.__ownerID?this:this.__ensureOwner(new me)}function Rs(){return this.__altered}function le(t){let e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Gu(t,e){return zs(this,t,e)}function Yu(t){return Wn(this,t)}function Kt(t){return Hu(this,t)}function Ds(t,e){return Qu(this,t,e)}function Zs(t,e,r){return typeof t==="function"?t(this):xn(this,t,e,r)}function Ts(t,e,r){return Tt(this,t,e,r)}function nn(){A(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}function os(...t){return Vn(this,t)}function Fn(t,...e){if(typeof t!=="function")throw TypeError(`Invalid merger function: ${t}`);return Vn(this,e,t)}function Vn(t,e,r){let s=[];for(let i of e){let n=Q(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 at(t)?t:t.create(s[0]);return t.withMutations((i)=>{let n=r?(h,u)=>{xn(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 kn(...t){return Ws(this,t)}function Nn(t,...e){return Ws(this,e,t)}function Xs(t,...e){return Tt(this,t,G(),(r)=>Js(r,e))}function Hs(t,...e){return Tt(this,t,G(),(r)=>Ws(r,e))}function pt(t,e){Object.assign(t.prototype,e)}var K=(t)=>{let e=te();if(t===void 0||t===null)return e;if(ys(t))return t;let r=yt(t),s=r.size;if(s===0)return e;if(A(s),s>0&&s<q)return ae(0,s,S,null,new _t(r.toArray()));return e.withMutations((i)=>{i.setSize(s),r.forEach((n,h)=>i.set(h,n))})};K.of=(...t)=>K(t);class mn extends It{static{pt(this,{asImmutable:ce,asMutable:_e,deleteIn:Kt,mergeDeepIn:Hs,mergeIn:Xs,setIn:Ds,update:Zs,updateIn:Ts,wasAltered:Rs,withMutations:le,removeIn:Kt,[dn]:!0,[ie]: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 K(t)}toString(){return this.__toString("List [","]")}get(t,e){if(t=rt(this,t),t>=0&&t<this.size){t+=this._origin;let r=eh(this,t);return r&&r.array[t&I]}return e}set(t,e){return Pu(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 te()}push(...t){let e=this.size;return this.withMutations((r)=>{et(r,0,e+t.length);for(let s=0;s<t.length;s++)r.set(e+s,t[s])})}pop(){return et(this,0,-1)}unshift(...t){return this.withMutations((e)=>{et(e,-t.length);for(let r=0;r<t.length;r++)e.set(r,t[r])})}shift(){return et(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=yt(typeof r!=="string"&&yn(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 K(e[0]);return this.withMutations((r)=>{e.forEach((s)=>s.forEach((i)=>r.push(i)))})}setSize(t){return et(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(ne(t,e,r))return this;return et(this,Rt(t,r),he(e,r))}__iterate(t,e){let r=e?this.size:0;return Bu(this,(s)=>t(s,e?--r:r++,this),e),e?this.size-r:r}__iterator(t){let e=t?this.size:0,r=hn(this,t);return M((s)=>{let i=r.next();if(i.done)return!1;return s[0]=t?--e:e++,s[1]=i.value,!0})}values(){return hn(this,!1)}keys(){return ke(this.size)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return te();return this.__ownerID=t,this.__altered=!1,this}return ae(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash)}}K.isList=ys;class _t{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 _t([],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=Lt(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:q)||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=Lt(this,t);if(n.array.splice(s+1),i)n.array[s]=i;return n}}function hn(t,e){let{_origin:r,_capacity:s}=t,i=Wt(s),n=t._tail,h=[];o(t._root,t._level,0);let u={done:!1,value:void 0};return W(()=>{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 U});function o(f,c,_){if(c===0){let l=_===i?n?.array:f?.array,a=_>r?0:r-_,y=s-_;if(y>q)y=q;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>q)y=q;if(a!==y)h.push({array:l,from:a,to:y,level:c,offset:_,isLeaf:!1})}}}function Bu(t,e,r){let{_origin:s,_capacity:i}=t,n=Wt(i),h=t._tail,u=t._level,o=t._root;return u===0?vn(o,0,s,i,n,h,e,r):th(o,u,0,s,i,n,h,e,r)}function vn(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>q)c=q;while(f!==c){let _=u?--c:f++;if(h(o?.[_])===!1)return!1}}function th(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(_>q)_=q;let l=e-S;while(c!==_){let a=o?--_:c++,y=r+(a<<e);if((l===0?vn(f?.[a],y,s,i,n,h,u,o):th(f?.[a],l,y,s,i,n,h,u,o))===!1)return!1}}var ae=(t,e,r,s,i,n,h)=>new mn(t,e,r,s,i,n,h),te=()=>ae(0,0,S);function Pu(t,e,r){if(e=rt(t,e),Number.isNaN(e))return t;if(e>=t.size||e<0)return t.withMutations((h)=>{if(e<0)et(h,e).set(0,r);else et(h,0,e+1).set(e,r)});e+=t._origin;let{_tail:s,_root:i}=t,n=hs();if(e>=Wt(t._capacity))s=fs(s,t.__ownerID,0,e,r,n);else i=fs(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 ae(t._origin,t._capacity,t._level,i,s)}function fs(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=fs(f,e,r-S,s,i,n);if(c===f)return t;return o=Lt(t,e),o.array[h]=c,o}if(u&&t.array[h]===i)return t;if(n)Z(n);if(o=Lt(t,e),i===void 0&&h===o.array.length-1)o.array.pop();else o.array[h]=i;return o}function Lt(t,e){if(e&&e===t?.ownerID)return t;return new _t(t?.array.slice()??[],e)}function eh(t,e){if(e>=Wt(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 et(t,e,r){if(e!==void 0)e|=0;if(r!==void 0)r|=0;let s=t.__ownerID||new me,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 _t(f?.array.length?[void 0,f]:[],s),o+=S,c+=1<<o;if(c)h+=c,i+=c,u+=c,n+=c;let _=Wt(n),l=Wt(u);while(l>=1<<o+S)f=new _t(f?.array.length?[f]:[],s),o+=S;let a=t._tail,y=l<_?eh(t,u-1):l>_?new _t([],s):a;if(a&&l>_&&h<n&&a.array.length){f=Lt(f,s);let z=f;for(let d=o;d>S;d-=S){let E=_>>>d&I;z=z.array[E]=Lt(z.array[E],s)}z.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 z=h>>>o&I;if(z!==l>>>o&I)break;if(z)c+=(1<<o)*z;o-=S,f=f.array[z]}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 ae(h,u,o,f,y)}var Wt=(t)=>t<q?0:t-1>>>S<<S,P=(t)=>t===void 0||t===null?ee():ve(t)?t:ee().withMutations((e)=>{let r=Q(t);A(r.size),r.forEach((s,i)=>e.set(i,s))});P.of=(...t)=>P(t);class rh extends $s{static{pt(this,{[st]:!0,[ie]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.OrderedMap",keys:H.prototype.keys,values:H.prototype.values,__iterate:H.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 P(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 ee()}set(t,e){return un(this,t,e)}remove(t){return un(this,t,g)}entries(){return this.__iterator(!1)}__iterator(t){let e=this._list.__iterator(t);return M((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 ee();return this.__ownerID=t,this.__altered=!1,this._map=e,this._list=r,this}return Qs(e,r,t,this.__hash)}}P.isOrderedMap=ve;var Qs=(t,e,r,s)=>new rh(t,e,r,s),ee=()=>Qs(G(),te());function un(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>=q&&i.size>=s.size*2){let f=[];if(i.forEach((c,_)=>{if(c!==void 0&&n!==_)f.push(c)}),o=te().withMutations((c)=>{for(let _=0;_<f.length;_++)c.set(_,f[_])}),u=G().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 Qs(u,o)}var Fe=(t)=>t===void 0||t===null?Ve():ws(t)?t:Ve().pushAll(t);Fe.of=(...t)=>Fe(t);class sh extends It{static{pt(this,{asImmutable:ce,asMutable:_e,wasAltered:Rs,withMutations:le,[bn]:!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 Fe(t)}toString(){return this.__toString("Stack [","]")}get(t,e){let r=this._head;t=rt(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 is(this,e,r)}pushAll(t){if(t=yt(t),t.size===0)return this;if(this.size===0&&ws(t))return t;A(t.size);let e=this.size,r=this._head;return t.__iterate((s)=>{e++,r={value:s,next:r}},!0),is(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(ne(t,e,this.size))return this;let r=Rt(t,this.size);if(he(e,this.size)!==this.size)return It.prototype.slice.call(this,t,e);let i=this.size-r,n=this._head;while(r--)n=n.next;return is(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 Gs(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 M((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 M((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 W(()=>{if(!t)return U;return e.value=t.value,t=t.next,e})}keys(){return ke(this.size)}}Fe.isStack=ws;function is(t,e,r){if(t.__ownerID)return t.size=e,t._head=r,t.__hash=void 0,t.__altered=!0,t;return Gs(e,r)}var Gs=(t,e,r,s)=>new sh(t,e,r,s),on,Ve=()=>on||(on=Gs(0)),b=(t)=>t===void 0||t===null?re():gs(t)&&!k(t)?t:re().withMutations((e)=>{let r=gt(t);A(r.size),r.forEach((s)=>e.add(s))});b.of=(...t)=>b(t);b.fromKeys=(t)=>b(Q(t).keySeq());b.intersect=(t)=>{return t=N(t).toArray(),t.length?b(t.pop()).intersect(...t):re()};b.union=(t)=>{let e=N(t).toArray();return e.length?b(e.pop()).union(...e):re()};class Ys extends er{static{pt(this,{withMutations:le,asImmutable:ce,asMutable:_e,[Mn]:!0,[ie]: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 b(t)}toString(){return this.__toString("Set {","}")}has(t){return this._map.has(t)}add(t){return Ye(this,this._map.set(t,t))}remove(t){return Ye(this,this._map.remove(t))}clear(){return Ye(this,this._map.clear())}map(t,e){let r=!1,s=Ye(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 b(t[0]);return this.withMutations((e)=>{for(let r of t)if(typeof r==="string")e.add(r);else gt(r).forEach((s)=>e.add(s))})}intersect(...t){return cn(this,t,(e,r)=>!r.every((s)=>s.includes(e)))}subtract(...t){return cn(this,t,(e,r)=>r.some((s)=>s.includes(e)))}wasAltered(){return this._map.wasAltered()}__iterator(t){return this._map.__iterator(t)}__empty(){return re()}__make(t,e){return ih(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)}}b.isSet=gs;var ih=(t,e)=>new Ys(t,e),fn,re=()=>fn||(fn=ih(G()));function cn(t,e,r){if(e.length===0)return t;return e=e.map((s)=>gt(s)),t.withMutations((s)=>{t.forEach((i)=>{if(r(i,e))s.remove(i)})})}function Ye(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 Jt=(t)=>t===void 0||t===null?cs():En(t)?t:cs().withMutations((e)=>{let r=gt(t);A(r.size),r.forEach((s)=>e.add(s))});Jt.of=(...t)=>Jt(t);Jt.fromKeys=(t)=>Jt(Q(t).keySeq());class nh extends Ys{static{pt(this,{[st]:!0,[Symbol.toStringTag]:"Immutable.OrderedSet",zip:ss.zip,zipWith:ss.zipWith,zipAll:ss.zipAll})}create(t){return Jt(t)}toString(){return this.__toString("OrderedSet {","}")}__empty(){return cs()}__make(t,e){return hh(t,e)}}Jt.isOrderedSet=En;var hh=(t,e)=>new nh(t,e),cs=()=>hh(ee());function Cu(t){if(at(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(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 ye=(t,e)=>{let r;Cu(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._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 ${Bs(this)} with property "${c}" since that property name is part of the Record API.`);else Fu(i,c)}}return this.__ownerID=void 0,this._values=K().withMutations((u)=>{u.setSize(this._keys.length),Q(h).forEach((o,f)=>{u.set(this._indices[f],o===this._defaultValues[f]?void 0:o)})}),this},i=s.prototype=Object.create(xu);if(i.constructor=s,i.create=s,e)s.displayName=e;return s};class uh{static{pt(this,{asImmutable:ce,asMutable:_e,deleteIn:Kt,getIn:Gu,hasIn:Yu,merge:os,mergeWith:Fn,mergeDeep:kn,mergeDeepWith:Nn,mergeDeepIn:Hs,mergeIn:Xs,setIn:Ds,toObject:nn,update:Zs,updateIn:Ts,withMutations:le,removeIn:Kt,toJSON:nn,[qn]:!0,[ie]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Record"})}toString(){let t=this._keys.map((e)=>`${e}: ${mt(this.get(e))}`).join(", ");return`${Bs(this)} { ${t} }`}equals(t){return this===t||at(t)&&At(this).equals(At(t))}hashCode(){return At(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 ns(this,r)}return this}remove(t){return this.set(t)}clear(){let t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:ns(this,t)}wasAltered(){return this._values.wasAltered()}toSeq(){return At(this)}toJS(){return Ce(this)}entries(){return this.__iterator()}__iterate(t,e){return At(this).__iterate(t,e)}__iterator(t){return At(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 ns(this,e,t)}}ye.isRecord=at;var Bs=(t)=>t.constructor.displayName||t.constructor.name||"Record";class oh extends Dt{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 M((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 At=(t)=>new oh(t);ye.getDescriptiveName=Bs;var xu=uh.prototype;function ns(t,e,r){let s=Object.create(Object.getPrototypeOf(t));return s._values=e,s.__ownerID=r,s}function Fu(t,e){Object.defineProperty(t,e,{get(){return this.get(e)},set(r){Nt(this.__ownerID,"Cannot set on an immutable record."),this.set(e,r)}})}var _n=(t,e,r=1)=>{if(Nt(r!==0,"Cannot step a Range by 0"),Nt(t!==void 0,"You must define a start value when using Range"),Nt(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 Ps(t,e,r,s)};class Ps extends wt{_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+rt(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(ne(t,e,this.size))return this;if(t=Rt(t,this.size),e=he(e,this.size),e<=t)return _n(0,0);return _n(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 M((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 W(()=>{if(s===t)return U;return i.value=r,r+=e,s++,i})}keys(){return ke(this.size)}equals(t){return t instanceof Ps?this._start===t._start&&this._end===t._end&&this._step===t._step:ps(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}class _s extends wt{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 $(this._value,t)}slice(t,e){let r=this.size;return ne(t,e,r)?this:new _s(this._value,he(e,r)-Rt(t,r))}reverse(){return this}indexOf(t){if($(this._value,t))return 0;return-1}lastIndexOf(t){if($(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 M((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 W(()=>{if(r===t)return U;return r++,s.value=e,s})}keys(){return ke(this.size)}equals(t){return t instanceof _s?this.size===t.size&&$(this._value,t._value):ps(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var fh=Symbol("BadValue"),ah=(t)=>t;class D{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,fh);if(h===fh)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 xs{isValid(t){return!0}getMessage(t){return"Invalid"}}class yh extends xs{}var Vu=new yh;class m extends xs{constructor(t,e){super();this._isValid=t,this._getMessage=e}isValid(t){return this._isValid(t)}getMessage(t){return this._getMessage(t)}}var ku=new m((t)=>Number.isInteger(t),()=>"Integer expected"),Nu=new m((t)=>Number.isFinite(t),()=>"Float expected"),mu=new m((t)=>typeof t==="boolean",()=>"Boolean expected"),vu=new m((t)=>typeof t==="string",()=>"String expected"),to=new m((t)=>K.isList(t),()=>"List expected"),eo=new m((t)=>Y.isMap(t),()=>"Map expected"),ro=new m((t)=>P.isOrderedMap(t),()=>"OrderedMap expected"),so=new m((t)=>b.isSet(t),()=>"Set expected"),io=(t)=>!!t;class Fs extends D{constructor(t,e=!1){super("bool",t,mu,io,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 ir extends D{constructor(t,e=null){super("any",t,Vu,ah,e)}toDataDef(){let{defaultValue:t}=this;return{type:Cs(t)??"any",defaultValue:t?.toJS?t.toJS():t}}}var no=(t)=>t?.toString?.()??"";class Vs extends D{constructor(t,e=""){super("text",t,vu,no,e)}extendProtoForType(t,e){ti(t,this.name,e,"","length")}}var ho=(t)=>Number.isFinite(t)?Math.trunc(t):null;class gh extends D{constructor(t,e=0){super("int",t,ku,ho,e)}}var uo=(t)=>null;class ks extends D{constructor(t,e=0){super("float",t,Nu,uo,e)}}var Cs=(t)=>t?.constructor?.getMetaClass?.()?.name;class wh{constructor(t){this.typeName=t}isValid(t){return Cs(t)===this.typeName}getMessage(t){let e=Cs(t);return`Expected "${this.typeName}", got "${e}"`}}class zh extends D{constructor(t,e,r){super(t,e,new wh(t),ah,null);this.args=r}toDataDef(){return{component:this.typeName,args:this.args}}}var ch=Symbol("NONE");function Xt(t,e,r){ti(t,e,r,Sh),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,ch);if(h!==ch)return this.set(e,n.set(s,i(h)));return console.warn("key",s,"not found in",e,n),this},ph(t,e,`${r}At`)}function ph(t,e,r){t[`deleteIn${r}`]=function(s){return this.set(e,this.get(e).delete(s))},t[`removeIn${r}`]=t[`deleteIn${r}`]}var Sh=K(),oo=(t)=>Array.isArray(t)?K(t):null;class Ns extends D{constructor(t,e=Sh){super("list",t,to,oo,e)}extendProtoForType(t,e){let{name:r}=this;Xt(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 fo=(t)=>Y(t);class ms extends D{constructor(t,e=Y()){super("map",t,eo,fo,e)}extendProtoForType(t,e){Xt(t,this.name,e)}}var co=(t)=>P(t);class vs extends D{constructor(t,e=P()){super("omap",t,ro,co,e)}extendProtoForType(t,e){Xt(t,this.name,e)}}function ti(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 _h=b(),_o=(t)=>Array.isArray(t)?b(t):t instanceof Set?b(t):null;class ei extends D{constructor(t,e=_h){super("set",t,so,_o,e)}extendProtoForType(t,e){let{name:r}=this;ti(t,r,e,_h),t[`addIn${e}`]=function(s){return this.set(r,this.get(r).add(s))},ph(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 lh(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 dh{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]=lh(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]=lh(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]:ye(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 zh(e,t,r);return this.compFields.add(t),this.fields[t]=s,s}}var nr=new Map,lo={text:Vs,int:gh,float:ks,bool:Fs,list:Ns,map:ms,omap:vs,set:ei,any:ir};function ao(t,{fields:e={},methods:r,statics:s}){let i=new dh(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,ks);else if(u==="boolean")i.addField(n,h,Fs);else if(K.isList(h)||Array.isArray(h))i.addField(n,K(h),Ns);else if(b.isSet(h)||h instanceof Set)i.addField(n,b(h),ei);else if(P.isOrderedMap(h))i.addField(n,h,vs);else if(h?.type&&h?.defaultValue!==void 0){let o=lo[h.type]??ir;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(Y.isMap(h)||h?.constructor===Object)i.addField(n,Y(h),ms);else{let o=nr.get(h?.constructor)??ir;i.addField(n,h,o)}}if(r)i.methods(r);if(s)i.statics(s);return i.build()}var yo=(t)=>new Hr(t.name??"Comp",ao(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 go=["nid","cid","eid","vid","si","sk"];class ri{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??Mo,this.cache=h??new Dr}setNullCache(){this.cache=new Rr}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 go)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 z={key:a,value:y},d=`${s}-${a}`,E;if(c)u.call(t.it,z,a,y,l),E=this.cache.get2(t.it,y,d);else E=this.cache.get(y,d);if(E){_.push(this.renderMetadata("Each",{nid:s,[o]:a})),_.push(E);continue}let Ot=t.enter(y,z,!1),Mt=r.render(Ot,this);if(_.push(this.renderMetadata("Each",{nid:s,[o]:a})),c)this.cache.set2(t.it,y,d,Mt);else this.cache.set(y,d,Mt);_.push(Mt)}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*wo(t){let e=0;for(let r of t)yield[e++,r]}function*zo(t){for(let[e,r]of t.toSeq().entries())yield[e,r]}var hr=new Map,po=["si",wo],So=["sk",zo],Oo=["si",function*(e){}];function Mo(t){return j(t)?po:p(t)?So:hr.get(t?.constructor)??Oo}class St{constructor(t=Y(),e=K()){this.items=t,this.order=e,this.$=0}_clonish(t,e){return new St(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 bo=(t)=>null;class Oh{isValid(t){return t instanceof St}getMessage(t){return"KList expected"}}var qo=new Oh;class Mh extends D{constructor(t,e=new St){super("KList",t,qo,bo,e)}extendProtoForType(t,e){Xt(t,this.name,e);let{name:r}=this;Xt(t,r,e),t[`pushIn${e}`]=function(s){return this.set(r,this.get(r).push(s))}}}nr.set(St,Mh);function*Eo(t){for(let e of t.order)yield[e,t.items.get(e)]}hr.set(St,["data-sk",Eo]);var ii=(t)=>t[4]==="-"&&(t[0]==="d"||t[0]==="a"),ge=(t)=>t!==null&&typeof t==="object";function qh(t,e,r){for(let s in e){let i=e[s];if(i===void 0)jo(t,s,r);else if(ii(s))t.setAttribute(s,i);else if(s==="dangerouslySetInnerHTML")t.innerHTML=i.__html??"";else if(ge(i))$o(t,r,s,i);else if(s==="className")t.setAttribute("class",i);else t[s]=i}}function jo(t,e,r){let s=r[e];if(e==="dangerouslySetInnerHTML")t.innerHTML="";else if(typeof s==="string"||ii(e)){let i=e==="className"?"class":e==="htmlFor"?"for":e;t.removeAttribute(i)}else t[e]=null}function $o(t,e,r,s){let i=e?.[r];if(ge(i)&&Object.getPrototypeOf(i)!==Object.getPrototypeOf(s)){t[r]=s;return}let n=t[r];if(!ge(n))t[r]={},n=t[r];let h=n;for(let u in s)h[u]=s[u]}class Ht{isEqualTo(t){return this===t}toDom(t){return null}}var si=(t)=>t instanceof ze?t.key:void 0,Ao=(t)=>t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function";function ni(t,e){if(e==null)return;if(Ao(e))for(let r of e)ni(t,r);else if(e instanceof Ht)if(e instanceof ht)t.push(...e.childs);else t.push(e);else t.push(new fr(e))}class fr extends Ht{constructor(t){super();this.text=String(t)}get nodeType(){return 3}isEqualTo(t){return t instanceof fr&&this.text===t.text}toDom(t){return t.document.createTextNode(this.text)}}class we extends Ht{constructor(t){super();this.text=t}get nodeType(){return 8}isEqualTo(t){return t instanceof we&&this.text===t.text}toDom(t){return t.document.createComment(this.text)}}class ht extends Ht{constructor(t){super();this.childs=[],ni(this.childs,t)}get nodeType(){return 11}isEqualTo(t){if(!(t instanceof ht)||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 ze extends Ht{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 ze)||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);qh(r,this.attrs,{});for(let s of this.childs){let i=s.toDom(t);if(i)r.appendChild(i)}return r}}function Eh(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(ge(i)&&ge(n))if(Object.getPrototypeOf(n)!==Object.getPrototypeOf(i))r??={},r[s]=n;else{let h=Eh(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 Uo(t,e,r){let s=t.parentNode,i=e.toDom(r);if(s&&i&&i!==t)s.replaceChild(i,t);return i||t}var ur=(t,e,r)=>t instanceof r&&e instanceof r;function jh(t,e,r,s){if(e===r||e.isEqualTo(r))return t;if(ur(e,r,fr)||ur(e,r,we))return t.data=r.text,t;if(ur(e,r,ze)&&e.tag===r.tag&&e.namespace===r.namespace&&e.key===r.key){let i=Eh(e.attrs,r.attrs);if(i)qh(t,i,e.attrs);if(!r.attrs.dangerouslySetInnerHTML)bh(t,e.childs,r.childs,e.tag,s);return t}if(ur(e,r,ht))return bh(t,e.childs,r.childs,null,s),t;return Uo(t,r,s)}function bh(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=si(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],_=si(c),l=-1;if(_!=null){if(_ in h&&!u[h[_]])l=h[_]}else while(o<e.length){if(!u[o]&&si(e[o])==null){l=o++;break}o++}if(l>=0){u[l]=1;let a=n[l],y=jh(a,e[l],c,i),z=t.childNodes[f]??null;if(y!==z)t.insertBefore(y,z)}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 or=new WeakMap;function $h(t,e,r){let s=or.get(e),i=t instanceof ht;if(s){let h=s.vnode instanceof ht;if(h===i){let u=h?e:s.dom,o=jh(u,s.vnode,t,r),f=i?e:o;return or.set(e,{vnode:t,dom:f}),o}or.delete(e)}let n=t.toDom(r);if(n){e.innerHTML="",e.appendChild(n);let h=i?e:n;or.set(e,{vnode:t,dom:h})}return n}function Ah(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]=ii(o)?String(f):f}}let u=[];return ni(u,r),new ze(s,i,u,n,h)}var{raw:Pf,raw:Cf}=String;function xf(t,e){return new Ur(t,e)}var Io=(t)=>typeof t==="string"?document.querySelector(t):t;function Ff(t){let e=Io(t),r=new Ze,s=(o)=>new ht(o),i=(o)=>new we(o),n={document},h=(o,f)=>$h(o,f,n),u=new ri(r,Ah,s,i,h);return new Nr(e,h,r,u,V)}async function sc(t,e,r="margaui-css"){let s=performance.now(),i=await Ko(t,e),n=performance.now();return Xe(r,i),n-s}async function Ko(t,e,r){t.ParseContext=He,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 Lo="RENDER_IT_OUTSIDE_OF_LOOP",Wo="UNKNOWN_EVENT_MODIFIER",Jo="UNKNOWN_HANDLER_ARG_NAME",Ro="INPUT_HANDLER_NOT_IMPLEMENTED",Do="INPUT_HANDLER_METHOD_NOT_IMPLEMENTED",Zo="INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD",To="INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER",Xo="FIELD_VAL_NOT_DEFINED",Ho="COMPUTED_VAL_NOT_DEFINED",Qo="UNKNOWN_REQUEST_NAME",Go="UNKNOWN_COMPONENT_NAME",Yo="warn",Uh="error",Bo="hint";function cc(t,e=new Ih){No(e,t),mo(e,t);for(let r in t.views)Po(e,t.views[r],t);return e}function Po(t,e,r){Co(t,e),Fo(t,e),ko(t,e,r)}function Co(t,e){let{nodes:r}=e.ctx;for(let s=0;s<r.length;s++){let i=r[s];if(i instanceof Le){let n=r[s+1];if(!(n instanceof Je||n instanceof Vt))t.error(Lo,{node:i})}}}var xo={};function Fo(t,e){for(let r of e.ctx.events)for(let s of r.handlers){let{name:i,modifiers:n}=s,h=Jr[i]??xo;for(let u of n)if(h[u]===void 0)t.warn(Wo,{name:i,modifier:u,handler:s,event:r})}}function Vo(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 ko(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[_];dt(t,l,u,h,s,i)}}}function No(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 Oe){if(r[c.name]===void 0){if(t.warn(Ro,{name:c.name,handler:f,event:o}),n[c.name]!==void 0)t.hint(To,{name:c.name,handler:f,event:o})}}else if(c instanceof Yt){if(n[c.name]===void 0){if(t.warn(Do,{name:c.name,handler:f,event:o}),r[c.name]!==void 0)t.hint(Zo,{name:c.name,handler:f,event:o})}}}}}function dt(t,e,r,s,i,n){if(e instanceof qe||e instanceof Yt){let{name:h}=e;if(r[h]===void 0&&s[h]===void 0)t.error(Xo,{val:e,name:h})}else if(e instanceof Ee){let{name:h}=e;if(i[h]===void 0)t.error(Ho,{val:e,name:h})}else if(e instanceof je)dt(t,e.seqVal,r,s,i,n),dt(t,e.keyVal,r,s,i,n);else if(e instanceof be){if(n.lookupRequest(e.name)===null)t.warn(Qo,{name:e.name})}else if(e instanceof Me){if(n.lookupComponent(e.name)===null)t.warn(Go,{name:e.name})}else if(e instanceof F&&!Vo(e.name))t.warn(Jo,{name:e.name});else if(!(e instanceof L))console.log(e)}function mo(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 Ae){for(let y of _.items)if(y instanceof Et)dt(t,y.value,u,h,r,s)}if(l!==null)for(let{val:y}of l)dt(t,y,u,h,r,s);if(a)dt(t,a,u,h,r,s)}for(let c of f.ctx.nodes)if(c.val)dt(t,c.val,u,h,r,s)}}class Ih{constructor(){this.reports=[]}error(t,e){this.report(t,e,Uh)}warn(t,e){this.report(t,e,Yo)}hint(t,e){this.report(t,e,Bo)}report(t,e={},r=Uh){this.reports.push({id:t,info:e,level:r})}}class vo 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{Ff as tutuca,hr as seqInfoByClass,xf as macro,ve as isOrderedMap,ve as isOMap,oe as isMap,ys as isList,p as isKeyed,j as isIndexed,oe as isIMap,Xe as injectCss,Cf as html,nr as fieldsByClass,Pf as css,yo as component,Ko as compileClassesToStyleText,sc as compileClassesToStyle,Po as checkView,cc as checkComponent,Qo as UNKNOWN_REQUEST_NAME,Jo as UNKNOWN_HANDLER_ARG_NAME,Wo as UNKNOWN_EVENT_MODIFIER,Go as UNKNOWN_COMPONENT_NAME,ye as Record,Lo as RENDER_IT_OUTSIDE_OF_LOOP,V as ParseContext,P as OMap,K as List,vo as LintParseContext,Ih as LintContext,Yo as LEVEL_WARN,Bo as LEVEL_HINT,Uh as LEVEL_ERROR,St as KList,b as ISet,Ro as INPUT_HANDLER_NOT_IMPLEMENTED,Do as INPUT_HANDLER_METHOD_NOT_IMPLEMENTED,To as INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER,Zo as INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD,Y as IMap,Xo as FIELD_VAL_NOT_DEFINED,Ho as COMPUTED_VAL_NOT_DEFINED};
|