tutuca 0.9.1 → 0.9.2
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/dist/tutuca-dev.js +2 -2
- package/dist/tutuca-dev.min.js +1 -1
- package/dist/tutuca-extra.js +2 -2
- package/dist/tutuca-extra.min.js +1 -1
- package/package.json +1 -1
package/dist/tutuca-dev.js
CHANGED
|
@@ -8038,10 +8038,10 @@ async function compileClassesToStyle(app, compileClasses, styleId = "margaui-css
|
|
|
8038
8038
|
injectCss(styleId, css2);
|
|
8039
8039
|
return t2 - t1;
|
|
8040
8040
|
}
|
|
8041
|
-
async function compileClassesToStyleText(app, compileClasses) {
|
|
8041
|
+
async function compileClassesToStyleText(app, compileClasses, extraCSSClasses) {
|
|
8042
8042
|
app.ParseContext = ParseCtxClassSetCollector;
|
|
8043
8043
|
app.compile();
|
|
8044
|
-
const classes = new Set;
|
|
8044
|
+
const classes = new Set(extraCSSClasses ?? []);
|
|
8045
8045
|
for (const Comp of app.comps.byId.values()) {
|
|
8046
8046
|
for (const key in Comp.views) {
|
|
8047
8047
|
const view = Comp.views[key];
|
package/dist/tutuca-dev.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
class Yt{lookup(t,e=null){return e}setValue(t,e){return t}updateBindings(t,e){}isFrame=!0}class Et extends Yt{constructor(t){super();this.binds=t}lookup(t,e){return t}setValue(t,e){return e}withIndex(t){return new Et({...this.binds,key:t})}withKey(t){return new Et({...this.binds,key:t})}updateBindings(t,e){Object.assign(e,this.binds)}isFrame=!1}class 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 _r(this.field,t)}withKey(t){return new fr(this.field,t)}}class cr 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 fr extends cr{}class _r extends cr{}var D=Symbol("NONE");class lr extends Yt{constructor(t,e){super();this.seqField=t,this.keyField=e}lookup(t,e=null){let r=t?.get(this.seqField,D),s=t?.get(this.keyField,D);return s!==D&&r?.get?r.get(s,e):e}setValue(t,e){let r=t?.get(this.seqField,D),s=t?.get(this.keyField,D);return r===D||s===D?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,D),r===D)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,D),s===D)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,D),r===D)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=[],c=null,f=[],_=!0;while(t&&t!==r&&u<s){if(t?.dataset){let{nid:l,si:a,sk:y}=si(t.previousSibling),{eid:g,cid:S,vid:O}=t.dataset;if(g!==void 0)o.push(g);if(S!==void 0){let bt=i.getComponentForId(+S,O);if(_){if(c=Lh(bt,o,O,e),c===null&&n)return Rh;_=!1}let Mt=Dh(bt,f,O);if(Mt)h.push(Mt);o=[],f=[]}if(l!==void 0)f.push({nid:l,si:a,sk:y})}u+=1,t=t.parentNode}return[new tt(h.reverse()),c]}static fromEvent(t,e,r,s,i=!0){let{type:n,target:h}=t;return tt.fromNodeAndEventName(h,n,e,r,s,i)}}var ri={};function si(t){if(t?.nodeType===8&&t.textContent[0]==="§"){let e=si(t.previousSibling);if(e!==ri)return e;try{return JSON.parse(t.textContent.slice(1,-1))}catch(r){console.warn(r,t)}}return ri}function Lh(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 Dh(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],c=i.pathInNext?t.getNodeForId(+o,r).val.toPathItem():i.toPathItem();if(c!==null)return h!==void 0?c.withIndex(+h):u?c.withKey(u):c}return null}var Rh=[null,null];class ar{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 _r(t,e))}key(t,e){return this.add(new fr(t,e))}}var Wh=/^[a-zA-Z][a-zA-Z0-9_]*$/,ut=(t)=>Wh.test(t),Jh=/^-?[0-9]+(\.[0-9]+)?$/,ii=(t,e)=>gr.parse(t,e),Pt=(t,e)=>new J(t),Th=(t,e)=>ut(t)?new F(t):null,Xh=(t,e)=>ut(t)?new Me(t):null,Zh=(t,e)=>ut(t)?new pr(t):null,Bh=(t,e)=>ut(t)?new oi(t):null,Hh=(t,e)=>ut(t)?new qe(t):null,Qh=(t,e)=>ut(t)?new je(t):null,Gh=(t,e)=>ut(t)?new Ee(t):null;class ni{constructor(){this.allowFieldOnly(),this.bindValIt=new pr("it"),this.nullConstVal=new J(null)}const(t){return new J(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 Ie(s,i):null}parse(t,e){switch(Yh(t)){case ci:return this.parseIfOk(t,e,this.okStrTpl,ii);case _i:return this.parseIfOk(t,e,this.okStrTpl,Pt);case fi:return this._parseSeqAccess(t,e);case Se:return this.parseIfOk(t,e,this.okStrTpl,ii)}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,Pt);case 39:return this.parseIfOk(t.slice(1,-1),e,this.okStrTpl,Pt);case 64:return this.parseIfOk(t.slice(1),e,this.okBind,Zh);case 42:return this.parseIfOk(t.slice(1),e,this.okDyn,Bh);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=Jh.test(t)?parseFloat(t):null;if(Number.isFinite(s))return this.parseIfOk(s,e,this.okConst,Pt);else if(t==="true"||t==="false")return this.parseIfOk(t==="true",e,this.okConst,Pt);else if(r>=97&&r<=122)return this.parseIfOk(t,e,this.okName,Th);else if(r>=65&&r<=90)return this.parseIfOk(t,e,this.okType,Xh);return null}parseDynamic(t,e){return this.allowFieldOnly(),this.okComputed=!0,this.parse(t,e)}parseEach(t,e){return this.allowFieldOnly(),this.okComputed=!0,this.okDyn=!0,this.parse(t,e)}allowHandlerArg(){this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okType=!0,this.okRequest=!0,this.okName=!0,this.okConst=!0}parseHandlerArg(t,e){return this.allowHandlerArg(),this.parse(t,e)}_parseHandler(t,e,r){this.allowFieldOnly(),this.okName=!0;let s=this.parse(t,e);return s.toRawFieldVal?s.toRawFieldVal():new r(s.name)}parseHandlerName(t,e){return this._parseHandler(t,e,be)}parseAlter(t,e){return this._parseHandler(t,e,hi)}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 Oe{render(t,e){}eval(t){}toPathItem(){return null}}class J extends Oe{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 yr extends Oe{}class gr extends yr{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)==="}"?p.parseText(h.slice(1,-1),e):new J(h);s[n]=o,i&&=o instanceof J}return i?new J(s.map((n)=>n.value).join("")):new gr(s)}}class F extends yr{constructor(t){super();this.name=t}eval(t){return t.lookupName(this.name)}toString(){return this.name}}class be extends F{eval(t){return t.getInputHandler(this.name)??ui("input",this.name)}}class hi extends F{eval(t){return t.getAlterHandler(this.name)??ui("alter",this.name)}}var ui=(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 Ee extends F{eval(t){return t.lookupRequest(this.name)}toString(){return`!${this.name}`}}class Ct extends F{eval(t){return t.lookupFieldRaw(this.name)}toString(){return`.${this.name}`}}class dr extends Oe{render(t,e){return this.eval(t)}}class xt extends dr{constructor(t){super();this.name=t}}class pr extends xt{eval(t){return t.lookupBind(this.name)}toString(){return`@${this.name}`}}class oi extends xt{eval(t){return t.lookupDynamic(this.name)}toPathItem(){return null}toString(){return`*${this.name}`}}class qe extends xt{eval(t){return t.lookupField(this.name)}toPathItem(){return new ze(this.name)}toRawFieldVal(){return new Ct(this.name)}toString(){return`.${this.name}`}}class je extends xt{eval(t){return t.lookupComputed(this.name)}toString(){return`$${this.name}`}}class Ie extends dr{constructor(t,e){super();this.seqVal=t,this.keyVal=e}toPathItem(){return new lr(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 ci=0,fi=1,Se=2,_i=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 ci;case 125:return _i}if(e>0||r>0)return e===1&&r===1?fi:Se;return-1}var p=new ni;class qt{constructor(t){this.items=t}eval(t){return{}}static parse(t,e,r=!1){return Or(e).parse(t,r)}isConstant(){return!1}}var Ph="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",Ch=new Set(Ph.split(","));class li{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?p.parseAll(e,this.px):p.parseAttr(e,this.px);if(s!==null)this.attrs??=[],this.attrs.push(new jt(t,s)),this.hasDynamic||=!(s instanceof J)}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=p.parseCondValue(e,this.px);if(r)this.ifAttr=new yi(t.slice(3),r),this.attrs??=[],this.attrs.push(this.ifAttr),this.hasDynamic=!0}parseThen(t){if(this.ifAttr)this.ifAttr.thenVal=p.parseAttr(t,this.px)??Ft}parseElse(t){if(this.ifAttr)this.ifAttr.elseVal=p.parseAttr(t,this.px)??Ft}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",p.const(this.events.id)));this.events.add(r,i,s)}}parseDirective(t,e){switch(e){case"dangerouslysetinnerhtml":this.attrs??=[],this.attrs.push(new ai(p.parseText(t,this.px))),this.hasDynamic=!0;return;case"slot":this.pushWrapper("slot",t,p.const(t));return;case"push-view":this.pushWrapper("push-view",t,p.parseText(t,this.px));return;case"text":this.textChild=p.parseText(t,this.px)??p.const("");return;case"show":this.pushWrapper("show",t,p.parseCondValue(t,this.px));return;case"hide":this.pushWrapper("hide",t,p.parseCondValue(t,this.px));return;case"each":this.eachAttr=this.pushWrapper("each",t,p.parseEach(t,this.px));return;case"enrich-with":if(this.eachAttr!==null)this.eachAttr.enrichWithVal=p.parseAlter(t,this.px);else this.pushWrapper("scope",t,p.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=p.parseAlter(t,this.px)}_parseLoopWith(t){if(this.eachAttr!==null)this.eachAttr.loopWithVal=p.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===""&&Ch.has(n)?!0:h;this.attrs.push(new $e(n,p.const(o)))}}let{attrs:r,hasDynamic:s}=this;return[s?new Ke(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 Ke 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 J(e)))}toMacroVars(){let t={};for(let e of this.items)t[e.name]=e.value.toString();return t}}class Sr{constructor(t){this.name=t}}class jt extends Sr{constructor(t,e){super(t);this.value=e}eval(t){return this.value.eval(t)}}class $e extends jt{}class ai extends jt{constructor(t){super("dangerouslySetInnerHTML",t??p.nullConstVal)}eval(t){return{__html:`${this.value.eval(t)}`}}}var Ft=p.nullConstVal;class yi extends Sr{constructor(t,e){super(t);this.condVal=e,this.thenVal=this.elseVal=Ft}get anyBranchIsSet(){return this.thenVal!==Ft||this.elseVal!==Ft}eval(t){return this.condVal.eval(t)?this.thenVal.eval(t):this.elseVal.eval(t)}}var wr=null;function Or(t){return wr??=new li(t),wr.clear(t),wr}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=p.parseHandlerName(r,e);if(i===null)return null;let n=Array(s.length);p.allowHandlerArg();for(let h=0;h<s.length;h++){let u=p.parse(s[h],e);n[h]=u!==null?u:p.nullConstVal}return new br(i,n)}}class Mr{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 It{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 mt extends It{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 kt extends mt{render(t,e){return e.renderComment(this.v)}}function xh(t){for(let e=0;e<t.length;e++){let r=t[e];if(r.isConstant())t[e]=new Ar(r);else r.optimize()}}function Ir(t){if(t.isConstant())return new Ar(t);return t.optimize(),t}class $r extends It{constructor(t){super();this.childs=t}isConstant(){return this.childs.every((t)=>t.isConstant())}optimize(){xh(this.childs)}}class Ae extends $r{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 Ue extends $r{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 Er=(t)=>t.length===1?t[0]:new Ue(t),Fh=/^[a-zA-Z][a-zA-Z0-9-]*$/,gi=null;class et extends It{constructor(t,e){super();this.nodeId=t,this.val=e}toPathItem(){return this.val.toPathItem()}static parse(t,e){gi??=e.newDOMParser();let r=gi.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 mt(t.textContent);else if(e.isCommentNode(t))return new kt(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 Er(n);let{name:h,value:u}=s[0],o=s.getNamedItem("as")?.value??null;switch(h){case"slot":return new Re(null,p.const(u),Er(n));case"text":return new jr(null,p.parseText(u,e)??p.const(""));case"render":return e.addNodeIf(bi,p.parseRender(u,e),o);case"render-it":return e.addNodeIf(De,p.bindValIt,o);case"render-each":return Nt.parse(e,p,u,o,s)}return new kt(`Error: InvalidSpecialTagOp ${h}=${u}`)}else if(i.charCodeAt(1)===58&&i.charCodeAt(0)===88){let h=i.slice(2).toLowerCase();if(h==="slot"){let c=s.getNamedItem("name")?.value??"_";return e.frame.macroSlots[c]??Er(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(Fh.test(i)){let[h,u,o]=qt.parse(s,e);if(e.onAttributes(h,u,o),o)n.unshift(new jr(null,o));let c=i!=="PRE"?vh(n):n;return di(new Ae(i.toLowerCase(),h,c),e,u)}return new kt(`Error: InvalidTagName ${i}`)}}function di(t,e,r){if(r)for(let s=r.length-1;s>=0;s--){let i=kh(r[s],e);if(i)i.wrapNode(t),t=i}return t}function kh(t,e){let r=Vh[t.name],s=r.register?e.addNodeIf(r,t.val):new r(null,t.val);if(t.name==="each")s.iterInfo.enrichWithVal=t.enrichWithVal??null,s.iterInfo.whenVal=t.whenVal??null,s.iterInfo.loopWithVal=t.loopWithVal??null;return s}class Oi extends It{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 kt(`bad macro: ${e}`);else{let n={...i.defaults,...r};this.node=i.expand(this.px.enterMacro(e,n,s));for(let h in this.dataAttrs)this.node.setDataAttr(h,this.dataAttrs[h])}}render(t,e){return this.node.render(t,e)}setDataAttr(t,e){this.dataAttrs[t]=e}isConstant(){return this.node.isConstant()}optimize(){this.node=Ir(this.node)}}class Kr{constructor(t,e){this.defaults=t,this.rawView=e}expand(t){return et.parse(this.rawView,t)}}class Le extends et{constructor(t,e,r){super(t,e);this.viewId=r}}class bi extends Le{render(t,e){let r=t.enter(this.val.eval(t),{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}}class De extends Le{render(t,e){return e.renderIt(t,this.nodeId,"",this.viewId)}pathInNext=!0}class Nt extends Le{constructor(t,e,r){super(t,e,r);this.iterInfo=new Ur(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(Nt,e.parseEach(r,t),s);if(n!==null){let h=Or(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 et{render(t,e){return e.renderText(this.val.eval(t))}}class Ar extends It{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=Ir(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 Ei 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 Re extends ot{optimize(){this.node.optimize()}}class ji 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 Et({})}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 Ur(e,null,null,null)}render(t,e){return e.renderEachWhen(t,this.iterInfo,this.node,this.nodeId)}toPathItem(){return new Et({})}static register=!0}class Ur{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)??mh,s=this.loopWithVal?.eval(t)??Nh,i=this.enrichWithVal?.eval(t)??null;return{seq:e,filter:r,loopWith:s,enricher:i}}}var mh=(t,e,r)=>!0,Nh=(t)=>({seq:t}),Vh={slot:Re,show:Mi,hide:Ei,each:We,scope:ji,"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 Ii(t);return this.events.push(e),e}newMacroNode(t,e,r){let s=[],i={_:new Ue(s)};for(let h of r)if(h instanceof Re)i[h.val.value]=h.node;else if(!(h instanceof mt)||!h.isWhiteSpace())s.push(h);let n=new Oi(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 qr=(t)=>t instanceof mt&&t.isWhiteSpace(),pi=(t)=>t instanceof Ae||t instanceof Ue&&t.childs[0]instanceof Ae;function vh(t){let e=t.length;if(e===0)return t;let r=0,s=!1;if(qr(t[0]))r=1,s=!0;if(e>1&&qr(t[e-1]))e-=1,s=!0;for(let i=1;i<e-1;i++){let n=t[i];if(qr(n)&&pi(t[i-1])&&pi(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=Ir(this.anode)}render(t,e){return this.anode.render(t,e)}}class Ii{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=iu(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 tu=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Te=(t)=>(e)=>(r,s,i,n)=>t(n)?e(r,s,i,n):r,wi=(t)=>Te((e)=>e.e.key===t),zi=Te(({e:t})=>tu&&t.metaKey||t.ctrlKey),eu=Te(({e:t})=>t.metaKey),ru=Te(({e:t})=>t.altKey),Si={ctrl:zi,cmd:zi,meta:eu,alt:ru},Lr={keydown:{send:wi("Enter"),cancel:wi("Escape"),...Si},click:{...Si}},su=(t,e)=>t;function iu(t,e){if(e.length===0)return su;let r=Lr[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 Dr{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 Rr{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 Xe{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
2
|
`)}}class Ze{constructor(t=new Xe,e=null){this.comps=t,this.parent=e,this.byName={},this.reqsByName={},this.macros={}}enter(){return new Ze(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 Mr(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 Tr{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 Tr{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",nu=0;class Xr{constructor(t,e,r,s={},i="",n="",h="",u={},o={},c={},f={},_={},l={},a={},y={}){this.id=nu++,this.name=t,this.Class=e,this.views={main:new Je("main",r,i)},this.commonStyle=n,this.globalStyle=h,this.computed=u,this.input=o,this.logic=c,this.bubble=f,this.response=_,this.alter=l,this.on={stackEnter:y?.stackEnter??Ai};for(let g in s){let S=s[g],{view:O,style:bt}=$t(S)?{view:S}:S;this.views[g]=new Je(g,O,bt)}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=p.parseDynamic(r,this.views.main.ctx);this.dynamic[e]=new Tr(e,s,Symbol(e))}else if($t(r?.default)&&$t(r?.for)){let s=p.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 Ai(t){return t}var Ui=Symbol("STOP"),Hr=Symbol("NEXT");class Vt{constructor(t,e){this.head=t,this.tail=e}push(t){return new Vt(t,this)}lookup(t,e=null){let{tail:r}=this,s=this.head.lookup(t);return s===Ui?e:s===Hr?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?Ui:Hr:e}}class Br{constructor(t){this.bindings=t}lookup(t){let e=this.bindings[t];return e===void 0?Hr:e}}class X{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 X(t,e.tail.head.it,e.tail,r,s,i)}static root(t,e,r){let s=new Vt(new Zr(e,{it:e},!0),null),i=new Vt(new Br({}),null),n=new Vt("main",null);return new X(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 X(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 X(e,r,s,i,n.push(t),h)}withDynamicBindings(t){let e={},r=this.comps.getCompFor(this.it);for(let c of t)r.dynamic[c].evalAndBind(this,e);let{comps:s,it:i,binds:n,views:h,ctx:u}=this,o=this.dynBinds.push(new Br(e));return new X(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){return this.comps.lookupComputed(this.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 Pr(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 Wi(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)??hu(e),o=s?.onResName??e,c=(f,_,l,a,y)=>{let S=new Ri(t,this,f??_,f?[l]:[a,y],i);return this.pushTransaction(S)};try{let f=await u.fn.apply(null,r);return c(s?.onOkName,o,f,f,null)}catch(f){return c(s?.onErrorName,o,f,null,f)}}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 hu(t){return()=>{throw Error(`Request not found: ${t}`)}}function uu(){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 Ji,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 X.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 ou=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac");function cu(t){return t.target.type==="checkbox"?t.target.checked:(t instanceof CustomEvent?t.detail:t.target.value)??null}class Di extends Gr{constructor(t,e,r,s,i){super(t,s);this.e=e,this.handler=r,this.dragInfo=i}buildRootStack(t,e){return X.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 Cr(this.path,this.transactor,this),n[u]=n[u].toHandlerArg(h);return[i,n]}lookupName(t){let{e}=this;switch(t){case"value":return cu(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 ou&&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 xr(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]??uu}getHandlerAndArgs(t,e,r){return[this.getHandlerForName(r.getCompFor(e)),[...this.args,new xr(this.path,this.transactor,this)]]}}class Ri extends Yr{handlerProp="response"}class Pr 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 Wi extends Pr{handlerProp="bubble";stopPropagation(){this.opts.bubbles=!1}}class Ji{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 Cr{constructor(t,e,r=null){this.path=t,this.transactor=e,this.parent=r}get at(){return new Ti(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 xr extends Cr{stopPropagation(){return this.parent.stopPropagation()}}class Ti extends ar{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 Fr{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,c]=tt.fromEvent(t,i,n,h,u);if(r){let f=fu(t.target,this.rootNode,50);if(f!==null)t.preventDefault(),this._cleanDragOverAttrs(),this.curDragOver=f,f.dataset.draggingover=this.dragInfo.type}else if(e){t.target.dataset.dragging=1;let f=this.state.value,_=o.lookup(f),l=t.target.dataset.dragtype??"?",a=o.buildStack(this.makeStack(f));this.dragInfo=new Xi(o,a,t,_,l,t.target)}else if(s)delete this.dragInfo.node.dataset.dragging,this.dragInfo=null,this._cleanDragOverAttrs();if(o!==null&&c!==null)for(let f of c)this.transactor.transactInputNow(o,t,f,this.dragInfo)}makeStack(t){return X.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()}),kr("tutuca-app",this.comps.compileStyles()),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 kr(t,e){let r=document.createElement("style"),s=document.head.querySelector(`#${t}`);if(s)document.head.removeChild(s);r.id=t,r.innerHTML=e,document.head.appendChild(r)}function fu(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 Xi{constructor(t,e,r,s,i,n){this.path=t,this.stack=e,this.e=r,this.value=s,this.type=i,this.node=n}lookupBind(t){return this.stack.lookupBind(t)}}class Be extends 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,f=new Be(s,i,n,h,u,o,{macroName:t,macroVars:e,macroSlots:r},this);return f.classes=this.classes,f}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),h)this._addClasses(h.value)}else if(typeof i?.value==="string")this._addClasses(i.value)}else{let s=t.items.class;if(s)this._addClasses(s)}}}function vt(t,e){if(!t)throw Error(e)}function $(t){vt(t!==1/0,"Cannot perform this action with an infinite size.")}function Zi(t,e,r,s,i,n){return $(t.size),t.__iterate((h,u,o)=>{if(i)i=!1,r=h;else r=e.call(s,r,h,u,o)},n),r}var _u=(t,e)=>e,lu=(t,e)=>[e,t],mr=(t)=>function(...e){return!t.apply(this,e)},Bi=(t)=>function(...e){return-t.apply(this,e)};function cn(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 Hi=(t,e)=>t<e?1:t>e?-1:0,K={done:!0,value:void 0};class fn{constructor(t){this.next=t}[Symbol.iterator](){return this}}function L(t){return new fn(t)}function M(t){let e=[void 0,void 0],r={done:!1,value:void 0};return L(()=>{if(t(e))return r.value=[e[0],e[1]],r;return K})}var au=L(()=>K),ct=()=>au;function me(t){let e=0,r={done:!1,value:void 0};return L(()=>{if(e===t)return K;return r.value=e++,r})}function ne(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!!Ne(t)}var yu=(t)=>!!(t&&typeof t.next==="function");function ln(t){return Ne(t)?.call(t)}function Ne(t){let e=t&&t[Symbol.iterator];if(typeof e==="function")return e}function gu(t){let e=Ne(t);return e&&e===t.entries}function du(t){let e=Ne(t);return e&&e===t.keys}var he="delete",z=5,q=1<<z,A=q-1,d={},is=()=>({value:!1});function T(t){if(t)t.value=!0}class Ve{}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),ue=(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,Jt=(t,e)=>gn(t,e,0),oe=(t,e)=>gn(t,e,e),dn="@@__IMMUTABLE_ITERABLE__@@",Ye="@@__IMMUTABLE_KEYED__@@",Pe="@@__IMMUTABLE_INDEXED__@@",it="@@__IMMUTABLE_ORDERED__@@",ce="@@__IMMUTABLE_SEQ__@@",pn="@@__IMMUTABLE_LIST__@@",wn="@@__IMMUTABLE_MAP__@@",zn="@@__IMMUTABLE_SET__@@",Sn="@@__IMMUTABLE_STACK__@@",On="@@__IMMUTABLE_RECORD__@@";function C(t,e){return typeof t==="object"&&t!==null&&e in t}var R=(t)=>C(t,dn),w=(t)=>C(t,Ye),j=(t)=>C(t,Pe),fs=(t)=>w(t)||j(t),m=(t)=>C(t,it),_s=(t)=>C(t,ce),ls=(t)=>C(t,pn),fe=(t)=>C(t,wn),as=(t)=>C(t,zn),ys=(t)=>C(t,Sn),at=(t)=>C(t,On),x=(t)=>R(t)||at(t),ve=(t)=>fe(t)&&m(t),bn=(t)=>as(t)&&m(t),Qi=(t)=>typeof t==="object"&&t!==null&&typeof t.equals==="function"&&typeof t.hashCode==="function";function Mn(t){let e=Y(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=Xt,e.__iterate=function(r,s){return t.__iterate((i,n)=>r(n,i,this),s)},e.__iteratorUncached=function(r){return ne(t.__iterator(r),(s,i,n)=>{n[0]=i,n[1]=s})},e}function En(t,e,r){let s=Y(t);return s.size=t.size,s.has=(i)=>t.has(i),s.get=(i,n)=>{let h=t.get(i,d);return h===d?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 ne(t.__iterator(i),(n,h,u)=>{u[0]=n,u[1]=e.call(r,h,n,t)})},s}function qn(t,e){let r=Y(t);if(r._iter=t,r.size=t.size,r.reverse=()=>t,t.flip)r.flip=function(){let s=Mn(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=Xt,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 ne(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(ue(e,r,i))return t;if(i===void 0&&(e<0||r<0))return jn(t.toSeq().cacheResult(),e,r,s);let n=Jt(e,i),u=oe(r,i)-n,o;if(!Number.isNaN(u))o=Math.max(0,u);let c=Y(t);if(c.size=o===0?o:t.size&&o||void 0,!s&&_s(t)&&o>=0)c.get=function(f,_){return f=st(this,f),f>=0&&f<o?t.get(f+n,_):_};return c.__iterateUncached=function(f,_){if(o!==0&&_)return this.cacheResult().__iterate(f,_);if(o===0)return 0;let l=0,a=0;return t.__iterate((y,g)=>{if(l<n){l++;return}if(o!==void 0&&a>=o)return!1;if(a++,f(y,s?g:a-1,this)===!1)return!1},_),a},c.__iteratorUncached=function(f){if(o!==0&&f)return this.cacheResult().__iterator(f);if(o===0)return ct();let _=t.__iterator(f),l=0,a=0;if(s)return L(()=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return K;let y=_.next();if(y.done)return y;return a++,y});return M((y)=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return!1;let g=_.next();if(g.done)return!1;return a++,y[0]=a-1,y[1]=g.value[1],!0})},c}function Gi(t,e,r){if(!e)e=cn;let s=w(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):ee(n)}function He(t,e,r){if(!e)e=cn;if(r){let s=t.toSeq().map((i,n)=>[i,r(i,n,t)]).reduce((i,n)=>Yi(e,i[1],n[1])?n:i);return s&&s[0]}return t.reduce((s,i)=>Yi(e,s,i)?i:s)}function Yi(t,e,r){let s=t(r,e);return s===0&&r!==e&&(r===void 0||r===null||Number.isNaN(r))||s>0}function Nr(t,e,r,s){let i=Y(t),n=new _e(r).map((h)=>h.size);return i.size=s?n.max():n.min(),i.__iterate=function(h,u){let o=this.__iterator(u),c=0,f;while(!(f=o.next()).done)if(h(f.value[1],c++,this)===!1)break;return c},i.__iteratorUncached=function(h){let u=r.map((_)=>{let l=N(_);return ln(h?l.reverse():l)}),o=0,c=Array(u.length),f=Array(u.length);return M((_)=>{let l=s;for(let a=0;a<u.length;a++)c[a]=u[a].next(),l=s?l&&c[a].done:l||c[a].done;if(l)return!1;for(let a=0;a<c.length;a++)f[a]=c[a].value;return _[0]=o++,_[1]=e(...f),!0})},i}function In(t){if(Array.isArray(t)||typeof t==="string")return!0;return t&&typeof t==="object"&&Number.isInteger(t.length)&&t.length>=0&&(t.length===0?Object.keys(t).length===1:Object.hasOwn(t,t.length-1))}function pu(t){if(!t||typeof t!=="object"||Object.prototype.toString.call(t)!=="[object Object]")return!1;let e=Object.getPrototypeOf(t);if(e===null)return!0;let r=e,s=Object.getPrototypeOf(e);while(s!==null)r=s,s=Object.getPrototypeOf(r);return r===e}var nt=(t)=>typeof t==="object"&&(x(t)||Array.isArray(t)||pu(t));function $n(t){if(In(t)&&typeof t!=="string")return t;if(m(t))return t.toArray();throw TypeError(`Invalid keyPath: expected Ordered Collection or Array: ${t}`)}var wu=(t,e)=>x(t)?t.has(e):nt(t)&&Object.hasOwn(t,e);function Kn(t,e,r){return x(t)?t.get(e,r):!wu(t,e)?r:typeof t.get==="function"?t.get(e):t[e]}function gs(t,e,r){let s=$n(e),i=0;while(i!==s.length)if(t=Kn(t,s[i++],d),t===d)return r;return t}var An=(t,e)=>gs(t,e,d)!==d;function I(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!!(Qi(t)&&Qi(e)&&t.equals(e))}function Ce(t){if(!t||typeof t!=="object")return t;if(!R(t)){if(!nt(t))return t;t=ht(t)}if(w(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 ds(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||w(t)!==w(e)||j(t)!==j(e)||m(t)!==m(e))return!1;if(t.size===0&&e.size===0)return!0;let r=!fs(t);if(m(t)){let h=t.entries();return!!(e.every((u,o)=>{let c=h.next().value;return c&&I(c[1],u)&&(r||I(c[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?!I(h,t.get(u,d)):!I(t.get(u,d),h))return i=!1,!1;return!0});return i&&t.size===n}var tr=(t)=>t>>>1&1073741824|t&3221225471;function Z(t){if(t===null||t===void 0)return Pi(t);if(typeof t.hashCode==="function")return tr(t.hashCode(t));let e=Mu(t);if(e===null||e===void 0)return Pi(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return zu(e);case"string":return e.length>Eu?Su(e):ns(e);case"object":case"function":return bu(e);case"symbol":return Ou(e);default:if(typeof e.toString==="function")return ns(e.toString());throw Error(`Value type ${typeof e} cannot be hashed.`)}}var Pi=(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 Su(t){let e=ts[t];if(e===void 0){if(e=ns(t),vr===qu)vr=0,ts={};vr++,ts[t]=e}return e}function ns(t){let e=0;for(let r=0;r<t.length;r++)e=31*e+t.charCodeAt(r)|0;return tr(e)}function Ou(t){let e=xi[t];if(e!==void 0)return e;return e=Un(),xi[t]=e,e}function bu(t){let e=Ci.get(t);if(e!==void 0)return e;return e=Un(),Ci.set(t,e),e}var Mu=(t)=>t.valueOf!==Object.prototype.valueOf?t.valueOf():t;function Un(){let t=++Vr;if(Vr&1073741824)Vr=0;return t}var Ci=new WeakMap,xi=Object.create(null),Vr=0,Eu=16,qu=255,vr=0,ts={};function ju(t){if(t.size===1/0)return 0;let e=m(t),r=w(t),s=e?1:0;return t.__iterate(r?e?(i,n)=>{s=31*s+Fi(Z(i),Z(n))|0}:(i,n)=>{s=s+Fi(Z(i),Z(n))|0}:e?(i)=>{s=31*s+Z(i)|0}:(i)=>{s=s+Z(i)|0}),Iu(t.size,s)}var Fi=(t,e)=>t^e+2654435769+(t<<6)+(t>>2)|0;function Iu(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 te(t){try{return typeof t==="string"?JSON.stringify(t):String(t)}catch{return JSON.stringify(t)}}var b=(t,e)=>t===e?t:_s(t)?e:t.create?t.create(e):t.constructor(e),$u=(t,e)=>b(t,(w(t)?H:j(t)?yt:gt)(e)),ki=(...t)=>t,N=(t)=>R(t)?t:ht(t);class B{size=0;static{this.prototype[dn]=!0,this.prototype.__toStringMapper=te,this.prototype[Symbol.iterator]=this.prototype.values,this.prototype.toJSON=this.prototype.toArray,this.prototype.contains=this.prototype.includes}equals(t){return ds(this,t)}hashCode(){return this.__hash??(this.__hash=ju(this))}toArray(){$(this.size);let t=Array(this.size||0),e=w(this),r=0;return this.__iterate((s,i)=>{t[r++]=e?[i,s]:s}),t}toIndexedSeq(){return new Jn(this)}toJS(){return Ce(this)}toKeyedSeq(){return new Es(this,!0)}toMap(){throw Error("toMap: not patched — import CollectionConversions")}toObject(){$(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 Tn(this)}toSeq(){return j(this)?this.toIndexedSeq():w(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=w(this),r=[this,...t].map((s)=>{if(!R(s))s=e?Dn(s):Rn(Array.isArray(s)?s:[s]);else if(e)s=H(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&&w(s)||j(this)&&j(s))return s}return b(this,new Wn(r))}includes(t){return this.some((e)=>I(e,t))}every(t,e){$(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=w(this),i=Y(r);if(s)i.has=(n)=>{let h=r.get(n,d);return h!==d&&!!t.call(e,h,n,r)},i.get=(n,h)=>{let u=r.get(n,d);return u!==d&&t.call(e,u,n,r)?u:h};return i.__iterateUncached=function(n,h){let u=0;return r.__iterate((o,c)=>{if(t.call(e,o,c,r))return u++,n(o,s?c:u-1,this)},h),u},i.__iteratorUncached=function(n){let h=r.__iterator(n),u=0;return M((o)=>{while(!0){let c=h.next();if(c.done)return!1;let f=c.value[0],_=c.value[1];if(t.call(e,_,f,r))return o[0]=s?f:u++,o[1]=_,!0}})},b(this,i)}partition(t,e){let r=w(this),s=[[],[]];return this.__iterate((i,n)=>{s[t.call(e,i,n,this)?1:0].push(r?[n,i]:i)}),s.map((i)=>$u(this,i))}find(t,e,r){let s=this.findEntry(t,e);return s?s[1]:r}forEach(t,e){return $(this.size),this.__iterate(e?t.bind(e):t)}join(t){$(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 L(()=>{let r=t.next();if(r.done)return K;return e.value=r.value[0],e})}map(t,e){return b(this,En(this,t,e))}reduce(t,e=d,r){return Zi(this,t,e,r,e===d,!1)}reduceRight(t,e=d,r){return Zi(this,t,e,r,e===d,!0)}reverse(){return b(this,qn(this,w(this)))}slice(t,e){return b(this,jn(this,t,e,w(this)))}some(t,e){$(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 b(this,Gi(this,t))}values(){let t=this.__iterator(),e={done:!1,value:void 0};return L(()=>{let r=t.next();if(r.done)return K;return e.value=r.value[1],e})}butLast(){return this.slice(0,-1)}isEmpty(){return this.size!==void 0?this.size===0:!this.some(()=>!0)}count(t,e){return 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 _e(t._cache);let e=t.toSeq().map(lu).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(an,null,t)}flatMap(t,e){return b(this,this.toSeq().map((r,s)=>(w(this)?H:j(this)?yt:gt)(t.call(e,r,s,this))).flatten(!0))}flatten(t){let e=this,r=w(this),s=Y(e);return s.__iterateUncached=function(i,n){if(n)return this.cacheResult().__iterate(i,n);let h=0,u=!1;function o(c,f){c.__iterate((_,l)=>{if((!t||f<t)&&R(_))o(_,f+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],c=o.iterator.next();if(c.done){h.pop();continue}let f=c.value[1];if((!t||o.depth<t)&&R(f)){h.push({iterator:f.__iterator(i),depth:o.depth+1});continue}return u[0]=r?c.value[0]:n++,u[1]=f,!0}return!1})},b(this,s)}fromEntrySeq(){return new Xn(this)}get(t,e){return this.find((r,s)=>I(s,t),void 0,e)}getIn(t,e){return gs(this,t,e)}groupBy(t,e){throw Error("groupBy: not patched — import CollectionConversions")}has(t){return this.get(t,d)!==d}hasIn(t){return An(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)=>I(e,t))}keySeq(){return this.toSeq().map(_u).toIndexedSeq()}last(t){return this.toSeq().reverse().first(t)}lastKeyOf(t){return this.toKeyedSeq().reverse().keyOf(t)}max(t){return He(this,t)}maxBy(t,e){return He(this,e,t)}min(t){return He(this,t?Bi(t):Hi)}minBy(t,e){return He(this,e?Bi(e):Hi,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=w(this),i=Y(r);return i.__iterateUncached=function(n,h){if(h)return this.cacheResult().__iterate(n,h);let u=!0,o=0;return r.__iterate((c,f)=>{if(u&&t.call(e,c,f,this))return;return u=!1,o++,n(c,s?f: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,c=!0;return M((f)=>{while(!0){let _=h.next();if(_.done)return!1;let l=_.value[0],a=_.value[1];if(c&&t.call(e,a,l,o))continue;return c=!1,f[0]=s?l:u++,f[1]=a,!0}})},b(this,i)}skipUntil(t,e){return this.skipWhile(mr(t),e)}sortBy(t,e){return b(this,Gi(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=Y(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 L(()=>{if(u)return K;let o=n.next();if(o.done)return o;if(!t.call(e,o.value[1],o.value[0],h))return u=!0,K;return o})},b(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 H=(t)=>w(t)?t:zs(t);class ps extends B{static{this.prototype[Ye]=!0,this.prototype.__toStringMapper=(t,e)=>`${te(e)}: ${te(t)}`,this.prototype[Symbol.iterator]=B.prototype.entries,this.prototype.toJSON=function(){$(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}}flip(){return b(this,Mn(this))}mapEntries(t,e){let r=0;return b(this,this.toSeq().map((s,i)=>t.call(e,[i,s],r++,this)).fromEntrySeq())}mapKeys(t,e){return b(this,this.toSeq().flip().map((r,s)=>t.call(e,r,s,this)).flip())}}var yt=(t)=>j(t)?t:lt(t);class Ut extends B{static{this.prototype[Pe]=!0,this.prototype[it]=!0}toKeyedSeq(){return new Es(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=d,...r){if(t===void 0)return this;let s=e!==d;if(e=s?Math.max(e||0,0):0,s&&!e&&r.length===0)return this;t=Jt(t,t<0?this.count():this.size);let i=this.slice(0,t);return b(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=Y(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((c)=>{if(o)return o=!1,c[0]=n++,c[1]=u,!0;let f=i.next();if(f.done)return!1;let _=f.value[1];if(!h)return u=_,o=!0,c[0]=n++,c[1]=t,!0;return h=!1,c[0]=n++,c[1]=_,!0})},b(this,r)}interleave(...t){let e=[this,...t],r=Nr(this.toSeq(),lt.of,e),s=r.flatten(!0);if(r.size)s.size=r.size*e.length;return b(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 b(this,Nr(this,ki,e,!0))}zipWith(t,...e){let r=[this,...e];return b(this,Nr(this,t,r))}}var gt=(t)=>R(t)&&!fs(t)?t:ee(t);class er extends B{static{this.prototype.has=B.prototype.includes,this.prototype.contains=B.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=H;N.Indexed=yt;N.Set=gt;var es=Ut.prototype,ht=(t)=>t===void 0||t===null?bs():x(t)?t.toSeq():Ku(t),Y=(t)=>Object.create((w(t)?Tt:j(t)?dt:Ss).prototype);class ft extends B{static{this.prototype[ce]=!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 L(()=>{if(s===r)return K;return i.value=e[t?r-++s:s++],i})}return this.__iteratorUncached(t)}}var ws={cacheResult:ft.prototype.cacheResult,__iterateUncached:ft.prototype.__iterateUncached,__iterate:ft.prototype.__iterate,__iterator:ft.prototype.__iterator},zs=(t)=>t===void 0||t===null?bs().toKeyedSeq():R(t)?w(t)?t.toSeq():t.fromEntrySeq():at(t)?t.toSeq():Dn(t);class Tt extends ps{static{this.prototype[ce]=!0,Object.assign(this.prototype,ws)}toSeq(){return this}toKeyedSeq(){return this}}var lt=(t)=>t===void 0||t===null?bs():R(t)?w(t)?t.entrySeq():t.toIndexedSeq():at(t)?t.toSeq().entrySeq():Rn(t);lt.of=(...t)=>lt(t);class dt extends Ut{static{this.prototype[ce]=!0,Object.assign(this.prototype,ws)}toSeq(){return this}toIndexedSeq(){return this}toString(){return this.__toString("Seq [","]")}}var ee=(t)=>(R(t)&&!fs(t)?t:lt(t)).toSetSeq();ee.of=(...t)=>ee(t);class Ss extends er{static{this.prototype[ce]=!0,Object.assign(this.prototype,ws)}toSeq(){return this}toSetSeq(){return this}}ht.isSeq=_s;ht.Keyed=zs;ht.Set=ee;ht.Indexed=lt;class _e extends dt{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 Os extends Tt{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 dt{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(!yu(r))return ct();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 bs=()=>new _e([]),Ms=(t)=>In(t)?new _e(t):_n(t)?new Ln(t):void 0;function Dn(t){let e=Ms(t);if(e)return e.fromEntrySeq();if(typeof t==="object")return new Os(t);throw TypeError(`Expected Array or collection object of [k, v] entries, or keyed object: ${t}`)}function Rn(t){let e=Ms(t);if(e)return e;throw TypeError(`Expected Array or collection object of values: ${t}`)}function Ku(t){let e=Ms(t);if(e)return gu(t)?e.fromEntrySeq():du(t)?e.toSetSeq():e;if(typeof t==="object")return new Os(t);throw TypeError(`Expected Array or collection object of values, or keyed object: ${t}`)}class Wn extends ft{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[Pe])this[Pe]=!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=!w(this),i=0,n=!1;for(let h of r)if(h.__iterate((u,o)=>{if(t(u,s?i++:o,this)===!1)return n=!0,!1},e),n)break;return i}__iteratorUncached(t){if(this._wrappedIterables.length===0)return ct();if(t)return this.cacheResult().__iterator(t);let e=this._wrappedIterables,r=!w(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 L(()=>n()||K)}}class Es extends Tt{static{this.prototype[it]=!0}constructor(t,e){super();this._iter=t,this._useKeys=e,this.size=t.size}cacheResult(){return Xt.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=qn(this,!0);if(!this._useKeys)t.valueSeq=()=>this._iter.toSeq().reverse();return t}map(t,e){let r=En(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 Jn extends dt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Xt.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 ne(this._iter.__iterator(t),(s,i,n)=>{n[0]=t?r-++e:e++,n[1]=i})}}class Tn extends Ss{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Xt.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 ne(this._iter.__iterator(t),(e,r,s)=>{s[0]=r,s[1]=r})}}class Xn extends Tt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Xt.call(this)}entrySeq(){return this._iter.toSeq()}__iterateUncached(t,e){let r=0;return this._iter.__iterate((s)=>{if(s){mi(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){mi(i);let n=R(i);return r[0]=n?i.get(0):i[0],r[1]=n?i.get(1):i[1],!0}}})}}function Xt(){if(this._iter.cacheResult)return this._iter.cacheResult(),this.size=this._iter.size,this;return ft.prototype.cacheResult.call(this)}function mi(t){if(t!==Object(t))throw TypeError(`Expected [K, V] tuple: ${t}`)}var G=(t)=>t===void 0||t===null?Q():fe(t)&&!m(t)?t:Q().withMutations((e)=>{let r=H(t);$(r.size),r.forEach((s,i)=>e.set(i,s))});class qs extends ps{static{wt(this,{asImmutable:le,asMutable:ae,deleteIn:Lt,merge:hs,mergeWith:Pn,mergeDeep:xn,mergeDeepWith:Fn,mergeDeepIn:Xs,mergeIn:Ts,setIn:Rs,update:Ws,updateIn:Js,wasAltered:Ds,withMutations:ye,removeIn:Lt,concat:hs,[wn]:!0,[he]: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 G(t)}toString(){return this.__toString("Map {","}")}get(t,e){return this._root?this._root.get(0,Z(t),t,e):e}set(t,e){return Vi(this,t,e)}remove(t){return Vi(this,t,d)}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 Q()}map(t,e){return this.withMutations((r)=>{r.forEach((s,i)=>{r.set(i,t.call(e,s,i,this))})})}keys(){if(!this._root)return ct();return Qe(this._root,!1,0)}values(){if(!this._root)return ct();return Qe(this._root,!1,1)}entries(){if(!this._root)return ct();return Qe(this._root,!1)}__iterator(t){if(!this._root)return ct();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 Q();return this.__ownerID=t,this.__altered=!1,this}return $s(this.size,this._root,t,this.__hash)}}G.isMap=fe;class js{constructor(t,e){this.ownerID=t,this.entries=e}get(t,e,r,s){return Zn(this.entries,r,s)}iterate(t,e){return Bn(this.entries,t,e)}update(t,e,r,s,i,n,h){let u=i===d,o=this.entries,c=0,f=o.length;for(;c<f;c++)if(I(s,o[c][0]))break;let _=c<f;if(_?o[c][1]===i:u)return this;if(T(h),u||!_)T(n);if(u&&f===1)return;if(!_&&!u&&f>=Wu)return Au(t,o,s,i);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(c===f-1)a.pop();else a[c]=a.pop();else a[c]=[s,i];else a.push([s,i]);if(l)return this.entries=a,this;return new js(t,a)}}class rr{constructor(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}iterate(t,e){return Hn(this.nodes,t,e)}get(t,e,r,s){let i=1<<((t===0?e:e>>>t)&A),n=this.bitmap;return(n&i)===0?s:this.nodes[tn(n&i-1)].get(t+z,e,r,s)}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&A,o=1<<u,c=this.bitmap,f=(c&o)!==0;if(!f&&i===d)return this;let _=tn(c&o-1),l=this.nodes,a=f?l[_]:void 0,y=Ks(a,t,e+z,r,s,i,n,h);if(y===a)return this;if(!f&&y&&l.length>=Ju)return Lu(t,l,c,u,y);if(f&&!y&&l.length===2&&vi(l[_^1]))return l[_^1];if(f&&y&&l.length===1&&vi(y))return y;let g=t&&t===this.ownerID,S=f?y?c:c^o:c|o,O=f?y?Qn(l,_,y,g):Ru(l,_,g):Du(l,_,y,g);if(g)return this.bitmap=S,this.nodes=O,this;return new rr(t,S,O)}}class Is{constructor(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}iterate(t,e){return Hn(this.nodes,t,e)}get(t,e,r,s){let i=(t===0?e:e>>>t)&A,n=this.nodes[i];return n?n.get(t+z,e,r,s):s}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&A,o=i===d,c=this.nodes,f=c[u];if(o&&!f)return this;let _=Ks(f,t,e+z,r,s,i,n,h);if(_===f)return this;let l=this.count;if(!f)l++;else if(!_){if(l--,l<Tu)return Uu(t,c,l,u)}let a=t&&t===this.ownerID,y=Qn(c,u,_,a);if(a)return this.count=l,this.nodes=y,this;return new Is(t,l,y)}}class sr{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}get(t,e,r,s){return Zn(this.entries,r,s)}iterate(t,e){return Bn(this.entries,t,e)}update(t,e,r,s,i,n,h){if(r!==this.keyHash){if(i===d)return this;return T(h),T(n),As(this,t,e,r,[s,i])}let u=i===d,o=this.entries,c=0,f=o.length;for(;c<f;c++)if(I(s,o[c][0]))break;let _=c<f;if(_?o[c][1]===i:u)return this;if(T(h),u||!_)T(n);if(u&&f===2)return new pt(t,this.keyHash,o[c^1]);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(c===f-1)a.pop();else a[c]=a.pop();else a[c]=[s,i];else a.push([s,i]);if(l)return this.entries=a,this;return new sr(t,this.keyHash,a)}}class pt{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 I(r,this.entry[0])?this.entry[1]:s}update(t,e,r,s,i,n,h){let u=i===d,o=I(s,this.entry[0]);if(o?i===this.entry[1]:u)return this;if(T(h),u){T(n);return}if(o){if(t&&t===this.ownerID)return this.entry[1]=i,this;return new pt(t,this.keyHash,[s,i])}return T(n),As(this,t,e,Z(s),[s,i])}}function Zn(t,e,r){for(let s=0,i=t.length;s<i;s++)if(I(e,t[s][0]))return t[s][1];return r}function Bn(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 Hn(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 L(()=>{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 c=h.nodes[e?o-u:u];if(c){if(c.entry)return n.value=i(c.entry),n;s={node:c,index:0,__prev:s}}continue}s=s.__prev}return K})}var $s=(t,e,r,s)=>new qs(t,e,r,s),Ni,Q=()=>Ni||(Ni=$s(0));function Vi(t,e,r){let s,i;if(!t._root){if(r===d)return t;i=1,s=new js(t.__ownerID,[[e,r]])}else{let n=is(),h=is();if(s=Ks(t._root,t.__ownerID,0,Z(e),e,r,n,h),!h.value)return t;i=t.size+(n.value?r===d?-1:1:0)}if(t.__ownerID)return t.size=i,t._root=s,t.__hash=void 0,t.__altered=!0,t;return s?$s(i,s):Q()}function Ks(t,e,r,s,i,n,h,u){if(!t){if(n===d)return t;return T(u),T(h),new pt(e,s,[i,n])}return t.update(e,r,s,i,n,h,u)}var vi=(t)=>t.constructor===pt||t.constructor===sr;function As(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)&A,h=(r===0?s:s>>>r)&A,u=new pt(e,s,i),o=n===h?[As(t,e,r+z,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 Ve;let i=new pt(t,Z(r),[r,s]);for(let[n,h]of e)i=i.update(t,0,Z(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,c=e.length;u<c;u++,o<<=1){let f=e[u];if(f!==void 0&&u!==s)i|=o,h[n++]=f}return new rr(t,i,h)}function Lu(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 Is(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 Qn(t,e,r,s){let i=s?t:t.slice();return i[e]=r,i}function Du(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 Ru(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,Tu=q/4;function xe(t){if(Array.isArray(t))return t.slice();return{...t}}var Us=(t,e,r)=>Ls(t,e,Xu(r));function Ls(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:H,h=s?(u)=>{if(i===t)i=xe(i);i.push(u)}:(u,o)=>{let c=Object.hasOwn(i,o),f=c&&r?r(i[o],u,o):u;if(!c||f!==i[o]){if(i===t)i=xe(i);i[o]=f}};for(let u of e)n(u).forEach(h);return i}function Xu(t){function e(r,s,i){return nt(r)&&nt(s)&&Zu(r,s)?Ls(r,[s],e):t?t(r,s,i):s}return e}function Zu(t,e){let r=ht(t),s=ht(e);return j(r)===j(s)&&w(r)===w(s)}function Bu(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=xe(t);if(Array.isArray(r))r.splice(e,1);else delete r[e];return r}function Hu(t,e,r){if(!nt(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(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 Zt(t,e,r,s){if(!s)s=r,r=void 0;let i=Gn(x(t),t,$n(e),0,r,s);return i===d?r:i}function Gn(t,e,r,s,i,n){let h=e===d;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(te)}]: ${e}`);let u=r[s],o=h?d:Kn(e,u,d),c=Gn(o===d?t:x(o),o,r,s+1,i,n);if(c===o)return e;if(c===d)return Bu(e,u);let f=h?t?Q():{}:e;return Hu(f,u,c)}var Qu=(t,e)=>Zt(t,e,()=>d),Gu=(t,e,r)=>Zt(t,e,d,()=>r);function Yn(t,e,r,s){return Zt(t,[e],r,s)}function le(){return this.__ensureOwner()}function ae(){return this.__ownerID?this:this.__ensureOwner(new Ve)}function Ds(){return this.__altered}function ye(t){let e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Yu(t,e){return gs(this,t,e)}function Pu(t){return An(this,t)}function Lt(t){return Qu(this,t)}function Rs(t,e){return Gu(this,t,e)}function Ws(t,e,r){return typeof t==="function"?t(this):Yn(this,t,e,r)}function Js(t,e,r){return Zt(this,t,e,r)}function en(){$(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}function hs(...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=H(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)=>{Yn(i,u,d,(o)=>o===d?h:r(o,h,u))}:(h,u)=>{i.set(u,h)};for(let h of s)h.forEach(n)})}function xn(...t){return Us(this,t)}function Fn(t,...e){return Us(this,e,t)}function Ts(t,...e){return Zt(this,t,Q(),(r)=>Ls(r,e))}function Xs(t,...e){return Zt(this,t,Q(),(r)=>Us(r,e))}function wt(t,e){Object.assign(t.prototype,e)}var U=(t)=>{let e=re();if(t===void 0||t===null)return e;if(ls(t))return t;let r=yt(t),s=r.size;if(s===0)return e;if($(s),s>0&&s<q)return ge(0,s,z,null,new _t(r.toArray()));return e.withMutations((i)=>{i.setSize(s),r.forEach((n,h)=>i.set(h,n))})};U.of=(...t)=>U(t);class kn extends Ut{static{wt(this,{asImmutable:le,asMutable:ae,deleteIn:Lt,mergeDeepIn:Xs,mergeIn:Ts,setIn:Rs,update:Ws,updateIn:Js,wasAltered:Ds,withMutations:ye,removeIn:Lt,[pn]:!0,[he]:this.prototype.remove,merge:this.prototype.concat,[Symbol.toStringTag]:"Immutable.List",[Symbol.iterator]:this.prototype.values})}constructor(t,e,r,s,i,n,h){super();this.size=e-t,this._origin=t,this._capacity=e,this._level=r,this._root=s,this._tail=i,this.__ownerID=n,this.__hash=h,this.__altered=!1}create(t){return U(t)}toString(){return this.__toString("List [","]")}get(t,e){if(t=st(this,t),t>=0&&t<this.size){t+=this._origin;let r=Vn(this,t);return r&&r.array[t&A]}return e}set(t,e){return xu(this,t,e)}remove(t){return!this.has(t)?this:t===0?this.shift():t===this.size-1?this.pop():this.splice(t,1)}insert(t,e){return this.splice(t,0,e)}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=this._origin=this._capacity=0,this._level=z,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this;return re()}push(...t){let e=this.size;return this.withMutations((r)=>{rt(r,0,e+t.length);for(let s=0;s<t.length;s++)r.set(e+s,t[s])})}pop(){return rt(this,0,-1)}unshift(...t){return this.withMutations((e)=>{rt(e,-t.length);for(let r=0;r<t.length;r++)e.set(r,t[r])})}shift(){return rt(this,1)}shuffle(t=Math.random){return this.withMutations((e)=>{let r=e.size,s,i;while(r)s=Math.floor(t()*r--),i=e.get(s),e.set(s,e.get(r)),e.set(r,i)})}concat(...t){let e=[];for(let r of t){let s=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 U(e[0]);return this.withMutations((r)=>{e.forEach((s)=>s.forEach((i)=>r.push(i)))})}setSize(t){return rt(this,0,t)}map(t,e){return this.withMutations((r)=>{for(let s=0;s<this.size;s++)r.set(s,t.call(e,r.get(s),s,this))})}slice(t,e){let r=this.size;if(ue(t,e,r))return this;return rt(this,Jt(t,r),oe(e,r))}__iterate(t,e){let r=e?this.size:0;return Cu(this,(s)=>t(s,e?--r:r++,this),e),e?this.size-r:r}__iterator(t){let e=t?this.size:0,r=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 me(this.size)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return re();return this.__ownerID=t,this.__altered=!1,this}return ge(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash)}}U.isList=ls;class _t{constructor(t,e){this.array=t,this.ownerID=e}removeBefore(t,e,r){if((r&(1<<e+z)-1)===0||this.array.length===0)return this;let s=r>>>e&A;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-z,r),n===u&&i)return this}if(i&&!n)return this;let h=Dt(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+z:q)||this.array.length===0)return this;let s=r-1>>>e&A;if(s>=this.array.length)return this;let i;if(e>0){let h=this.array[s];if(i=h?.removeAfter(t,e-z,r),i===h&&s===this.array.length-1)return this}let n=Dt(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=Rt(s),n=t._tail,h=[];o(t._root,t._level,0);let u={done:!1,value:void 0};return L(()=>{while(h.length>0){let c=h[h.length-1];if(c.from===c.to){h.pop();continue}let f=e?--c.to:c.from++;if(c.isLeaf)return u.value=c.array?.[f],u;let _=c.array?.[f],l=c.level-z,a=c.offset+(f<<c.level);o(_,l,a)}return K});function o(c,f,_){if(f===0){let l=_===i?n?.array:c?.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=c?.array,a=_>r?0:r-_>>f,y=(s-_>>f)+1;if(y>q)y=q;if(a!==y)h.push({array:l,from:a,to:y,level:f,offset:_,isLeaf:!1})}}}function Cu(t,e,r){let{_origin:s,_capacity:i}=t,n=Rt(i),h=t._tail,u=t._level,o=t._root;return u===0?mn(o,0,s,i,n,h,e,r):Nn(o,u,0,s,i,n,h,e,r)}function mn(t,e,r,s,i,n,h,u){let o=e===i?n?.array:t?.array,c=e>r?0:r-e,f=s-e;if(f>q)f=q;while(c!==f){let _=u?--f:c++;if(h(o?.[_])===!1)return!1}}function Nn(t,e,r,s,i,n,h,u,o){let c=t?.array,f=r>s?0:s-r>>e,_=(i-r>>e)+1;if(_>q)_=q;let l=e-z;while(f!==_){let a=o?--_:f++,y=r+(a<<e);if((l===0?mn(c?.[a],y,s,i,n,h,u,o):Nn(c?.[a],l,y,s,i,n,h,u,o))===!1)return!1}}var ge=(t,e,r,s,i,n,h)=>new kn(t,e,r,s,i,n,h),re=()=>ge(0,0,z);function xu(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=is();if(e>=Rt(t._capacity))s=us(s,t.__ownerID,0,e,r,n);else i=us(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 ge(t._origin,t._capacity,t._level,i,s)}function us(t,e,r,s,i,n){let h=s>>>r&A,u=t&&h<t.array.length;if(!u&&i===void 0)return t;let o;if(r>0){let c=t&&t.array[h],f=us(c,e,r-z,s,i,n);if(f===c)return t;return o=Dt(t,e),o.array[h]=f,o}if(u&&t.array[h]===i)return t;if(n)T(n);if(o=Dt(t,e),i===void 0&&h===o.array.length-1)o.array.pop();else o.array[h]=i;return o}function Dt(t,e){if(e&&e===t?.ownerID)return t;return new _t(t?.array.slice()??[],e)}function Vn(t,e){if(e>=Rt(t._capacity))return t._tail;if(e<1<<t._level+z){let{_root:r,_level:s}=t;while(r&&s>0)r=r.array[e>>>s&A],s-=z;return r}}function rt(t,e,r){if(e!==void 0)e|=0;if(r!==void 0)r|=0;let s=t.__ownerID||new Ve,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:c}=t,f=0;while(h+f<0)c=new _t(c?.array.length?[void 0,c]:[],s),o+=z,f+=1<<o;if(f)h+=f,i+=f,u+=f,n+=f;let _=Rt(n),l=Rt(u);while(l>=1<<o+z)c=new _t(c?.array.length?[c]:[],s),o+=z;let a=t._tail,y=l<_?Vn(t,u-1):l>_?new _t([],s):a;if(a&&l>_&&h<n&&a.array.length){c=Dt(c,s);let g=c;for(let S=o;S>z;S-=z){let O=_>>>S&A;g=g.array[O]=Dt(g.array[O],s)}g.array[_>>>z&A]=a}if(u<n)y=y&&y.removeAfter(s,0,u);if(h>=l)h-=l,u-=l,o=z,c=null,y=y&&y.removeBefore(s,0,h);else if(h>i||l<_){f=0;while(c){let g=h>>>o&A;if(g!==l>>>o&A)break;if(g)f+=(1<<o)*g;o-=z,c=c.array[g]}if(c&&h>i)c=c.removeBefore(s,o,h-f);if(c&&l<_)c=c.removeAfter(s,o,l-f);if(f)h-=f,u-=f}if(t.__ownerID)return t.size=u-h,t._origin=h,t._capacity=u,t._level=o,t._root=c,t._tail=y,t.__hash=void 0,t.__altered=!0,t;return ge(h,u,o,c,y)}var Rt=(t)=>t<q?0:t-1>>>z<<z,P=(t)=>t===void 0||t===null?se():ve(t)?t:se().withMutations((e)=>{let r=H(t);$(r.size),r.forEach((s,i)=>e.set(i,s))});P.of=(...t)=>P(t);class vn extends qs{static{wt(this,{[it]:!0,[he]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.OrderedMap",keys:B.prototype.keys,values:B.prototype.values,__iterate:B.prototype.__iterate})}constructor(t,e,r,s){super(t?t.size:0,void 0,r,s);this._map=t,this._list=e}create(t){return 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 se()}set(t,e){return sn(this,t,e)}remove(t){return sn(this,t,d)}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 se();return this.__ownerID=t,this.__altered=!1,this._map=e,this._list=r,this}return Zs(e,r,t,this.__hash)}}P.isOrderedMap=ve;var Zs=(t,e,r,s)=>new vn(t,e,r,s),se=()=>Zs(Q(),re());function sn(t,e,r){let{_map:s,_list:i}=t,n=s.get(e),h=n!==void 0,u,o;if(r===d){if(!h)return t;if(i.size>=q&&i.size>=s.size*2){let c=[];if(i.forEach((f,_)=>{if(f!==void 0&&n!==_)c.push(f)}),o=re().withMutations((f)=>{for(let _=0;_<c.length;_++)f.set(_,c[_])}),u=Q().withMutations((f)=>{for(let _=0;_<c.length;_++)f.set(c[_][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 c=i.size;u=s.set(e,c),o=i.set(c,[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 Fe=(t)=>t===void 0||t===null?ke():ys(t)?t:ke().pushAll(t);Fe.of=(...t)=>Fe(t);class th extends Ut{static{wt(this,{asImmutable:le,asMutable:ae,wasAltered:Ds,withMutations:ye,[Sn]:!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=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 rs(this,e,r)}pushAll(t){if(t=yt(t),t.size===0)return this;if(this.size===0&&ys(t))return t;$(t.size);let e=this.size,r=this._head;return t.__iterate((s)=>{e++,r={value:s,next:r}},!0),rs(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 ke()}slice(t,e){if(ue(t,e,this.size))return this;let r=Jt(t,this.size);if(oe(e,this.size)!==this.size)return Ut.prototype.slice.call(this,t,e);let i=this.size-r,n=this._head;while(r--)n=n.next;return rs(this,i,n)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return ke();return this.__ownerID=t,this.__altered=!1,this}return Bs(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 L(()=>{if(!t)return K;return e.value=t.value,t=t.next,e})}keys(){return me(this.size)}}Fe.isStack=ys;function rs(t,e,r){if(t.__ownerID)return t.size=e,t._head=r,t.__hash=void 0,t.__altered=!0,t;return Bs(e,r)}var Bs=(t,e,r,s)=>new th(t,e,r,s),nn,ke=()=>nn||(nn=Bs(0)),E=(t)=>t===void 0||t===null?ie():as(t)&&!m(t)?t:ie().withMutations((e)=>{let r=gt(t);$(r.size),r.forEach((s)=>e.add(s))});E.of=(...t)=>E(t);E.fromKeys=(t)=>E(H(t).keySeq());E.intersect=(t)=>{return t=N(t).toArray(),t.length?E(t.pop()).intersect(...t):ie()};E.union=(t)=>{let e=N(t).toArray();return e.length?E(e.pop()).union(...e):ie()};class Hs extends er{static{wt(this,{withMutations:ye,asImmutable:le,asMutable:ae,[zn]:!0,[he]: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 E(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 E(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 ie()}__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)}}E.isSet=as;var eh=(t,e)=>new Hs(t,e),hn,ie=()=>hn||(hn=eh(Q()));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 Wt=(t)=>t===void 0||t===null?os():bn(t)?t:os().withMutations((e)=>{let r=gt(t);$(r.size),r.forEach((s)=>e.add(s))});Wt.of=(...t)=>Wt(t);Wt.fromKeys=(t)=>Wt(H(t).keySeq());class rh extends Hs{static{wt(this,{[it]:!0,[Symbol.toStringTag]:"Immutable.OrderedSet",zip:es.zip,zipWith:es.zipWith,zipAll:es.zipAll})}create(t){return Wt(t)}toString(){return this.__toString("OrderedSet {","}")}__empty(){return os()}__make(t,e){return sh(t,e)}}Wt.isOrderedSet=bn;var sh=(t,e)=>new rh(t,e),os=()=>sh(se());function Fu(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 de=(t,e)=>{let r;Fu(t);let s=function(h){if(h instanceof s)return h;if(!(this instanceof s))return new s(h);if(!r){r=!0;let u=Object.keys(t),o=i._indices={};i._keys=u,i._defaultValues=t;for(let c=0;c<u.length;c++){let f=u[c];if(o[f]=c,i[f])console.warn(`Cannot define ${Qs(this)} with property "${f}" since that property name is part of the Record API.`);else mu(i,f)}}return this.__ownerID=void 0,this._values=U().withMutations((u)=>{u.setSize(this._keys.length),H(h).forEach((o,c)=>{u.set(this._indices[c],o===this._defaultValues[c]?void 0:o)})}),this},i=s.prototype=Object.create(ku);if(i.constructor=s,i.create=s,e)s.displayName=e;return s};class ih{static{wt(this,{asImmutable:le,asMutable:ae,deleteIn:Lt,getIn:Yu,hasIn:Pu,merge:hs,mergeWith:Pn,mergeDeep:xn,mergeDeepWith:Fn,mergeDeepIn:Xs,mergeIn:Ts,setIn:Rs,toObject:en,update:Ws,updateIn:Js,withMutations:ye,removeIn:Lt,toJSON:en,[On]:!0,[he]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Record"})}toString(){let t=this._keys.map((e)=>`${e}: ${te(this.get(e))}`).join(", ");return`${Qs(this)} { ${t} }`}equals(t){return this===t||at(t)&&Kt(this).equals(Kt(t))}hashCode(){return Kt(this).hashCode()}has(t){return Object.hasOwn(this._indices,t)}get(t,e){if(!this.has(t))return e;let r=this._indices[t],s=this._values.get(r);return s===void 0?this._defaultValues[t]:s}set(t,e){if(this.has(t)){let r=this._values.set(this._indices[t],e===this._defaultValues[t]?void 0:e);if(r!==this._values&&!this.__ownerID)return ss(this,r)}return this}remove(t){return this.set(t)}clear(){let t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:ss(this,t)}wasAltered(){return this._values.wasAltered()}toSeq(){return Kt(this)}toJS(){return Ce(this)}entries(){return this.__iterator()}__iterate(t,e){return Kt(this).__iterate(t,e)}__iterator(t){return Kt(this).__iterator(t)}__ensureOwner(t){if(t===this.__ownerID)return this;let e=this._values.__ensureOwner(t);if(!t)return this.__ownerID=t,this._values=e,this;return ss(this,e,t)}}de.isRecord=at;var Qs=(t)=>t.constructor.displayName||t.constructor.name||"Record";class nh extends Tt{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 Kt=(t)=>new nh(t);de.getDescriptiveName=Qs;var ku=ih.prototype;function ss(t,e,r){let s=Object.create(Object.getPrototypeOf(t));return s._values=e,s.__ownerID=r,s}function mu(t,e){Object.defineProperty(t,e,{get(){return this.get(e)},set(r){vt(this.__ownerID,"Cannot set on an immutable record."),this.set(e,r)}})}var on=(t,e,r=1)=>{if(vt(r!==0,"Cannot step a Range by 0"),vt(t!==void 0,"You must define a start value when using Range"),vt(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 Gs(t,e,r,s)};class Gs extends dt{_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(ue(t,e,this.size))return this;if(t=Jt(t,this.size),e=oe(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 L(()=>{if(s===t)return K;return i.value=r,r+=e,s++,i})}keys(){return me(this.size)}equals(t){return t instanceof Gs?this._start===t._start&&this._end===t._end&&this._step===t._step:ds(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}class cs extends dt{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 I(this._value,t)}slice(t,e){let r=this.size;return ue(t,e,r)?this:new cs(this._value,oe(e,r)-Jt(t,r))}reverse(){return this}indexOf(t){if(I(this._value,t))return 0;return-1}lastIndexOf(t){if(I(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 L(()=>{if(r===t)return K;return r++,s.value=e,s})}keys(){return me(this.size)}equals(t){return t instanceof cs?this.size===t.size&&I(this._value,t._value):ds(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var hh=Symbol("BadValue"),fh=(t)=>t;class W{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 Ps{isValid(t){return!0}getMessage(t){return"Invalid"}}class _h extends Ps{}var Nu=new _h;class V extends Ps{constructor(t,e){super();this._isValid=t,this._getMessage=e}isValid(t){return this._isValid(t)}getMessage(t){return this._getMessage(t)}}var Vu=new V((t)=>Number.isInteger(t),()=>"Integer expected"),vu=new V((t)=>Number.isFinite(t),()=>"Float expected"),to=new V((t)=>typeof t==="boolean",()=>"Boolean expected"),eo=new V((t)=>typeof t==="string",()=>"String expected"),ro=new V((t)=>U.isList(t),()=>"List expected"),so=new V((t)=>G.isMap(t),()=>"Map expected"),io=new V((t)=>P.isOrderedMap(t),()=>"OrderedMap expected"),no=new V((t)=>E.isSet(t),()=>"Set expected"),ho=(t)=>!!t;class Cs extends W{constructor(t,e=!1){super("bool",t,to,ho,e)}extendProtoForType(t,e){let{name:r}=this;t[`toggle${e}`]=function(){return this.set(r,!this.get(r,!1))},t[`set${e}`]=function(s){return this.set(r,!!s)}}}class ir extends W{constructor(t,e=null){super("any",t,Nu,fh,e)}toDataDef(){let{defaultValue:t}=this;return{type:Ys(t)??"any",defaultValue:t?.toJS?t.toJS():t}}}var uo=(t)=>t?.toString?.()??"";class xs extends W{constructor(t,e=""){super("text",t,eo,uo,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 oo=(t)=>Number.isFinite(t)?Math.trunc(t):null;class lh extends W{constructor(t,e=0){super("int",t,Vu,oo,e)}}var co=(t)=>null;class Fs extends W{constructor(t,e=0){super("float",t,vu,co,e)}}var Ys=(t)=>t?.constructor?.getMetaClass?.()?.name;class ah{constructor(t){this.typeName=t}isValid(t){return Ys(t)===this.typeName}getMessage(t){let e=Ys(t);return`Expected "${this.typeName}", got "${e}"`}}class yh extends W{constructor(t,e,r){super(t,e,new ah(t),fh,null);this.args=r}toDataDef(){return{component:this.typeName,args:this.args}}}var uh=Symbol("NONE");function Bt(t,e,r){dh(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=U(),fo=(t)=>Array.isArray(t)?U(t):null;class ks extends W{constructor(t,e=gh){super("list",t,ro,fo,e)}extendProtoForType(t,e){let{name:r}=this;Bt(t,r,e),t[`pushIn${e}`]=function(s){return this.set(r,this.get(r).push(s))},t[`insertIn${e}At`]=function(s,i){return this.set(r,this.get(r).insert(s,i))}}}var _o=(t)=>G(t);class ms extends W{constructor(t,e=G()){super("map",t,so,_o,e)}extendProtoForType(t,e){Bt(t,this.name,e)}}var lo=(t)=>P(t);class Ns extends W{constructor(t,e=P()){super("omap",t,io,lo,e)}extendProtoForType(t,e){Bt(t,this.name,e)}}function dh(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=E(),ao=(t)=>Array.isArray(t)?E(t):t instanceof Set?E(t):null;class Vs extends W{constructor(t,e=oh){super("set",t,no,ao,e)}extendProtoForType(t,e){let{name:r}=this;dh(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 ch(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 ph{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]=ch(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]=ch(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]:de(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 nr=new Map,yo={text:xs,int:lh,float:Fs,bool:Cs,list:ks,map:ms,omap:Ns,set:Vs,any:ir};function go(t,{fields:e={},methods:r,statics:s}){let i=new ph(t);for(let n in e){let h=e[n],u=typeof h;if(u==="string")i.addField(n,h,xs);else if(u==="number")i.addField(n,h,Fs);else if(u==="boolean")i.addField(n,h,Cs);else if(U.isList(h)||Array.isArray(h))i.addField(n,U(h),ks);else if(E.isSet(h)||h instanceof Set)i.addField(n,E(h),Vs);else if(P.isOrderedMap(h))i.addField(n,h,Ns);else if(h?.type&&h?.defaultValue!==void 0){let o=yo[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(G.isMap(h)||h?.constructor===Object)i.addField(n,G(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 po=(t)=>new Xr(t.name??"Comp",go(t.name,t),t.view??"Not Defined",t.views,t.style,t.commonStyle??"",t.globalStyle??"",t.computed,t.input,t.logic,t.bubble,t.response,t.alter,t.dynamic,t.on);var wo=["nid","cid","eid","vid","si","sk"];class vs{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??Eo,this.cache=h??new Rr}setNullCache(){this.cache=new Dr}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 wo)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"),c=this.renderMetadata("Comp",{nid:s}),f=this.renderFragment([c,o.render(t,this)]);return this.cache.set(e,h,f),f}renderEach(t,e,r,s){let{seq:i,filter:n,loopWith:h}=e.eval(t),[u,o]=this.getSeqInfo(i),c=[],f=h.call(t.it,i);for(let[_,l]of o(i))if(n.call(t.it,_,l,f)){let a=t.enter(l,{key:_},!0),y=this.renderIt(a,r,_,s);c.push(this.renderMetadata("Each",{nid:r,[u]:_})),c.push(y)}return c}renderEachWhen(t,e,r,s){let{seq:i,filter:n,loopWith:h,enricher:u}=e.eval(t),[o,c]=this.getSeqInfo(i),f=!!u,_=[],l=h.call(t.it,i);for(let[a,y]of c(i))if(n.call(t.it,a,y,l)){let g={key:a,value:y},S=`${s}-${a}`,O;if(f)u.call(t.it,g,a,y,l),O=this.cache.get2(t.it,y,S);else O=this.cache.get(y,S);if(O){_.push(this.renderMetadata("Each",{nid:s,[o]:a})),_.push(O);continue}let bt=t.enter(y,g,!1),Mt=r.render(bt,this);if(_.push(this.renderMetadata("Each",{nid:s,[o]:a})),f)this.cache.set2(t.it,y,S,Mt);else this.cache.set(y,S,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*zo(t){let e=0;for(let r of t)yield[e++,r]}function*So(t){for(let[e,r]of t.toSeq().entries())yield[e,r]}var hr=new Map,Oo=["si",zo],bo=["sk",So],Mo=["si",function*(e){}];function Eo(t){return j(t)?Oo:w(t)?bo:hr.get(t?.constructor)??Mo}class zt{constructor(t=G(),e=U()){this.items=t,this.order=e,this.$=0}_clonish(t,e){return new zt(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 qo=(t)=>null;class wh{isValid(t){return t instanceof zt}getMessage(t){return"KList expected"}}var jo=new wh;class zh extends W{constructor(t,e=new zt){super("KList",t,jo,qo,e)}extendProtoForType(t,e){Bt(t,this.name,e);let{name:r}=this;Bt(t,r,e),t[`pushIn${e}`]=function(s){return this.set(r,this.get(r).push(s))}}}nr.set(zt,zh);function*Io(t){for(let e of t.order)yield[e,t.items.get(e)]}hr.set(zt,["data-sk",Io]);function ti(t){return t[4]==="-"&&(t[0]==="d"||t[0]==="a")}function Sh(t,e){return t[e]}function pe(t,e,r){t[e]=r}function bh(t,e,r){for(let s in e){let i=e[s];if(i===void 0)$o(t,s,r);else if(ti(s))t.setAttribute(s,i);else if(typeof i==="object"&&i!==null)Ko(t,r,s,i);else pe(t,s,i)}}function $o(t,e,r){let s=r[e];if(ti(e))t.removeAttribute(e);else if(typeof s==="string"){pe(t,e,"");let i=e==="className"?"class":e==="htmlFor"?"for":e;t.removeAttribute(i)}else pe(t,e,null)}function Ko(t,e,r,s){let i=e?.[r];if(i&&typeof i==="object"&&Object.getPrototypeOf(i)!==Object.getPrototypeOf(s)){pe(t,r,s);return}let n=Sh(t,r);if(typeof n!=="object"||n===null)pe(t,r,{}),n=Sh(t,r);let h=n;for(let u in s)h[u]=s[u]}class Mh{type;message;constructor(t,e){this.type=t,this.message=e}}class Eh extends Mh{duplicatedKeys;parentTag;parentIndex;constructor(t,e,r){let s=[...t].join(", ");super("DuplicatedKeys",`Duplicate keys found: [${s}] in ${e||"fragment"} at index ${r}. Nodes with duplicated keys are matched positionally.`);this.duplicatedKeys=t,this.parentTag=e,this.parentIndex=r}}class Gt{isEqualTo(t){return this===t}toDom(t){return null}}function qh(t){return t instanceof Qt?t.key:void 0}function St(t,e){let r=qh(t);return r&&e?.has(r)?void 0:r}function Ao(t){return t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function"}function ei(t,e){if(e==null)return;if(Ao(e))for(let r of e)ei(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{text;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 Ht extends Gt{text;constructor(t){super();this.text=t}get nodeType(){return 8}isEqualTo(t){return t instanceof Ht&&this.text===t.text}toDom(t){return t.document.createComment(this.text)}}class v extends Gt{childs;constructor(t){super();let e=[];ei(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{tag;attrs;childs;key;namespace;attrCount;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,this.attrCount=Object.keys(this.attrs).length}get nodeType(){return 1}isEqualTo(t){if(!(t instanceof Qt)||this.tag!==t.tag||this.key!==t.key||this.namespace!==t.namespace||this.attrCount!==t.attrCount||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=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);bh(r,this.attrs,{});for(let s of this.childs){let i=s.toDom(t);if(i)r.appendChild(i)}return r}}function jh(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=jh(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){let r=ur(e);if(r.free.length===e.length)return{children:e,moves:null,duplicatedKeys:r.duplicatedKeys};let s=ur(t),i=r.duplicatedKeys||s.duplicatedKeys?new Set([...r.duplicatedKeys||[],...s.duplicatedKeys||[]]):null;if(s.free.length===t.length)return{children:e,moves:null,duplicatedKeys:i};let n,h,u;if(i){let y=ur(e,i);n=y.keys,h=y.free,u=ur(t,i).keys}else n=r.keys,h=r.free,u=s.keys;let o=[],c=0,f=h.length,_=0;for(let y=0;y<t.length;y++){let g=t[y],S=St(g,i);if(S)if(Object.hasOwn(n,S)){let O=n[S];o.push(e[O])}else _++,o.push(null);else if(c<f){let O=h[c++];o.push(e[O])}else _++,o.push(null)}let l=c>=h.length?e.length:h[c];for(let y=0;y<e.length;y++){let g=e[y],S=St(g,i);if(S){if(!Object.hasOwn(u,S))o.push(g)}else if(y>=l)o.push(g)}let a=Lo(o,e,n,i,_);return{children:o,moves:a,duplicatedKeys:i}}function Lo(t,e,r,s,i){let n=t.slice(),h=0,u=[],o=[],c=Array(e.length);for(let f=0;f<e.length;f++)c[f]=St(e[f],s);for(let f=0;f<e.length;){let _=c[f],l=n[h],a=St(l,s);while(l===null&&n.length)n.splice(h,1),u.push({from:h,key:null}),l=n[h],a=St(l,s);if(l&&a===_){h++,f++;continue}if(_){if(a&&r[a]!==f+1){if(n.splice(h,1),u.push({from:h,key:a}),l=n[h],a=St(l,s),l&&a===_){h++,f++;continue}}o.push({key:_,to:f}),f++;continue}if(a){n.splice(h,1),u.push({from:h,key:a});continue}f++}while(h<n.length){let f=n[h];n.splice(h,1),u.push({from:h,key:St(f,s)})}if(u.length===i&&!o.length)return null;return{removes:u,inserts:o}}function ur(t,e){let r={},s=[],i=null;for(let n=0;n<t.length;n++){let h=qh(t[n]);if(h&&!e?.has(h)){if(h in r)i??=new Set,i.add(h);r[h]=n}else s.push(n)}return{keys:r,free:s,duplicatedKeys:i}}function Do(t,e,r){let s=t.parentNode,i=e.toDom(r);if(s&&i&&i!==t)s.replaceChild(i,t);return i||t}function Ih(t,e,r,s){if(e===r||e.isEqualTo(r))return t;if(e instanceof we&&r instanceof we||e instanceof Ht&&r instanceof Ht)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=jh(e.attrs,r.attrs);if(i)bh(t,i,e.attrs);return Oh(t,e.childs,r.childs,e.tag,s),t}if(e instanceof v&&r instanceof v)return Oh(t,e.childs,r.childs,null,s),t;return Do(t,r,s)}function Oh(t,e,r,s,i){if(e.length===0){for(let l of r){let a=l.toDom(i);if(a)t.appendChild(a)}return}if(r.length===0){while(t.firstChild)t.removeChild(t.firstChild);return}let n=Uo(e,r),h=n.children;if(n.duplicatedKeys&&i.onWarning)i.onWarning(new Eh(n.duplicatedKeys,s,0));let u=Array.from(t.childNodes),o=e.length,c=h.length,f=Math.max(o,c),_=[];for(let l=0;l<f;l++){let a=e[l],y=h[l];if(!a&&y){let g=y.toDom(i);if(g)t.appendChild(g)}else if(a&&y){let g=u[l];if(g)Ih(g,a,y,i)}else if(a&&!y){if(!n.moves&&u[l])_.push(u[l])}}for(let l of _)if(l.parentNode===t)t.removeChild(l);if(n.moves)Ro(t,n.moves)}function Ro(t,e){let r=t.childNodes,s={};for(let n of e.removes){let h=r[n.from];if(n.key)s[n.key]=h;t.removeChild(h)}let i=r.length;for(let n=0;n<e.inserts.length;n++){let h=e.inserts[n],u=s[h.key];if(u)t.insertBefore(u,h.to>=i++?null:r[h.to])}}var or=new WeakMap;function $h(t,e,r){let s=or.get(e),i=t instanceof v;if(s){let h=s.vnode instanceof v;if(h===i){let u=h?e:s.dom,o=Ih(u,s.vnode,t,r);return or.set(e,{vnode:t,dom:i?e:o}),o}or.delete(e)}let n=t.toDom(r);if(n)e.innerHTML="",e.appendChild(n),or.set(e,{vnode:t,dom:i?e:n});return n}function Kh(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(ti(o))i[o]=String(e[o]);else i[o]=e[o];let u=[];return ei(u,r),new Qt(s,i,u,n,h)}var{raw:Fc,raw:kc}=String;function mc(t,e){return new Kr(t,e)}var Wo=(t)=>typeof t==="string"?document.querySelector(t):t;function Nc(t){let e=Wo(t),r=new Xe,s=(o)=>new v(o),i=(o)=>new Ht(o),n={document},h=(o,c)=>$h(o,c,n),u=new vs(r,Kh,s,i,h);return new Fr(e,h,r,u,k)}async function hf(t,e,r="margaui-css"){let s=performance.now(),i=await Jo(t,e),n=performance.now();return kr(r,i),n-s}async function Jo(t,e){t.ParseContext=Be,t.compile();let r=new Set;for(let s of t.comps.byId.values())for(let i in s.views){let n=s.views[i];for(let h of n.ctx.classes)r.add(h)}return await e(Array.from(r))}var To="RENDER_IT_OUTSIDE_OF_LOOP",Xo="UNKNOWN_EVENT_MODIFIER",Zo="UNKNOWN_HANDLER_ARG_NAME",Bo="INPUT_HANDLER_NOT_IMPLEMENTED",Ho="INPUT_HANDLER_METHOD_NOT_IMPLEMENTED",Qo="INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD",Go="INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER",Yo="FIELD_VAL_NOT_DEFINED",Po="COMPUTED_VAL_NOT_DEFINED",Co="UNKNOWN_REQUEST_NAME",xo="UNKNOWN_COMPONENT_NAME",Fo="warn",Ah="error",ko="hint";function af(t,e=new Uh){rc(e,t),sc(e,t);for(let r in t.views)mo(e,t.views[r],t);return e}function mo(t,e,r){No(t,e),vo(t,e),ec(t,e,r)}function No(t,e){let{nodes:r}=e.ctx;for(let s=0;s<r.length;s++){let i=r[s];if(i instanceof De){let n=r[s+1];if(!(n instanceof We||n instanceof Nt))t.error(To,{node:i})}}}var Vo={};function vo(t,e){for(let r of e.ctx.events)for(let s of r.handlers){let{name:i,modifiers:n}=s,h=Lr[i]??Vo;for(let u of n)if(h[u]===void 0)t.warn(Xo,{name:i,modifier:u,handler:s,event:r})}}function tc(t){switch(t){case"value":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 ec(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 c of o.handlers){let{args:f}=c.handlerCall;for(let _=0;_<f.length;_++){let l=f[_];Ot(t,l,u,h,s,i)}}}function rc(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 c of o.handlers){let{handlerVal:f}=c.handlerCall;if(f instanceof be){if(r[f.name]===void 0){if(t.warn(Bo,{name:f.name,handler:c,event:o}),n[f.name]!==void 0)t.hint(Go,{name:f.name,handler:c,event:o})}}else if(f instanceof Ct){if(n[f.name]===void 0){if(t.warn(Ho,{name:f.name,handler:c,event:o}),r[f.name]!==void 0)t.hint(Qo,{name:f.name,handler:c,event:o})}}}}}function Ot(t,e,r,s,i,n){if(e instanceof qe||e instanceof Ct){let{name:h}=e;if(r[h]===void 0&&s[h]===void 0)t.error(Yo,{val:e,name:h})}else if(e instanceof je){let{name:h}=e;if(i[h]===void 0)t.error(Po,{val:e,name:h})}else if(e instanceof Ie)Ot(t,e.seqVal,r,s,i,n),Ot(t,e.keyVal,r,s,i,n);else if(e instanceof Ee){if(n.lookupRequest(e.name)===null)t.warn(Co,{name:e.name})}else if(e instanceof Me){if(n.lookupComponent(e.name)===null)t.warn(xo,{name:e.name})}else if(e instanceof F&&!tc(e.name))t.warn(Zo,{name:e.name});else if(!(e instanceof J))console.log(e)}function sc(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 c=i[o];for(let f of c.ctx.attrs){let{attrs:_,wrapperAttrs:l,textChild:a}=f;if(_ instanceof Ke){for(let y of _.items)if(y instanceof jt)Ot(t,y.value,u,h,r,s)}if(l!==null)for(let{val:y}of l)Ot(t,y,u,h,r,s);if(a)Ot(t,a,u,h,r,s)}for(let f of c.ctx.nodes)if(f.val)Ot(t,f.val,u,h,r,s)}}class Uh{constructor(){this.reports=[]}error(t,e){this.report(t,e,Ah)}warn(t,e){this.report(t,e,Fo)}hint(t,e){this.report(t,e,ko)}report(t,e={},r=Ah){this.reports.push({id:t,info:e,level:r})}}class ic 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{Nc as tutuca,hr as seqInfoByClass,mc as macro,ve as isOrderedMap,ve as isOMap,fe as isMap,ls as isList,w as isKeyed,j as isIndexed,fe as isIMap,kc as html,nr as fieldsByClass,Fc as css,po as component,Jo as compileClassesToStyleText,hf as compileClassesToStyle,mo as checkView,af as checkComponent,Co as UNKNOWN_REQUEST_NAME,Zo as UNKNOWN_HANDLER_ARG_NAME,Xo as UNKNOWN_EVENT_MODIFIER,xo as UNKNOWN_COMPONENT_NAME,de as Record,To as RENDER_IT_OUTSIDE_OF_LOOP,k as ParseContext,P as OMap,U as List,ic as LintParseContext,Uh as LintContext,Fo as LEVEL_WARN,ko as LEVEL_HINT,Ah as LEVEL_ERROR,zt as KList,E as ISet,Bo as INPUT_HANDLER_NOT_IMPLEMENTED,Ho as INPUT_HANDLER_METHOD_NOT_IMPLEMENTED,Go as INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER,Qo as INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD,G as IMap,Yo as FIELD_VAL_NOT_DEFINED,Po as COMPUTED_VAL_NOT_DEFINED};
|
|
3
|
+
`)}}function Ai(t){return t}var Ui=Symbol("STOP"),Hr=Symbol("NEXT");class Vt{constructor(t,e){this.head=t,this.tail=e}push(t){return new Vt(t,this)}lookup(t,e=null){let{tail:r}=this,s=this.head.lookup(t);return s===Ui?e:s===Hr?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?Ui:Hr:e}}class Br{constructor(t){this.bindings=t}lookup(t){let e=this.bindings[t];return e===void 0?Hr:e}}class X{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 X(t,e.tail.head.it,e.tail,r,s,i)}static root(t,e,r){let s=new Vt(new Zr(e,{it:e},!0),null),i=new Vt(new Br({}),null),n=new Vt("main",null);return new X(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 X(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 X(e,r,s,i,n.push(t),h)}withDynamicBindings(t){let e={},r=this.comps.getCompFor(this.it);for(let c of t)r.dynamic[c].evalAndBind(this,e);let{comps:s,it:i,binds:n,views:h,ctx:u}=this,o=this.dynBinds.push(new Br(e));return new X(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){return this.comps.lookupComputed(this.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 Pr(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 Wi(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)??hu(e),o=s?.onResName??e,c=(f,_,l,a,y)=>{let S=new Ri(t,this,f??_,f?[l]:[a,y],i);return this.pushTransaction(S)};try{let f=await u.fn.apply(null,r);return c(s?.onOkName,o,f,f,null)}catch(f){return c(s?.onErrorName,o,f,null,f)}}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 hu(t){return()=>{throw Error(`Request not found: ${t}`)}}function uu(){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 Ji,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 X.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 ou=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac");function cu(t){return t.target.type==="checkbox"?t.target.checked:(t instanceof CustomEvent?t.detail:t.target.value)??null}class Di extends Gr{constructor(t,e,r,s,i){super(t,s);this.e=e,this.handler=r,this.dragInfo=i}buildRootStack(t,e){return X.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 Cr(this.path,this.transactor,this),n[u]=n[u].toHandlerArg(h);return[i,n]}lookupName(t){let{e}=this;switch(t){case"value":return cu(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 ou&&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 xr(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]??uu}getHandlerAndArgs(t,e,r){return[this.getHandlerForName(r.getCompFor(e)),[...this.args,new xr(this.path,this.transactor,this)]]}}class Ri extends Yr{handlerProp="response"}class Pr 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 Wi extends Pr{handlerProp="bubble";stopPropagation(){this.opts.bubbles=!1}}class Ji{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 Cr{constructor(t,e,r=null){this.path=t,this.transactor=e,this.parent=r}get at(){return new Ti(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 xr extends Cr{stopPropagation(){return this.parent.stopPropagation()}}class Ti extends ar{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 Fr{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,c]=tt.fromEvent(t,i,n,h,u);if(r){let f=fu(t.target,this.rootNode,50);if(f!==null)t.preventDefault(),this._cleanDragOverAttrs(),this.curDragOver=f,f.dataset.draggingover=this.dragInfo.type}else if(e){t.target.dataset.dragging=1;let f=this.state.value,_=o.lookup(f),l=t.target.dataset.dragtype??"?",a=o.buildStack(this.makeStack(f));this.dragInfo=new Xi(o,a,t,_,l,t.target)}else if(s)delete this.dragInfo.node.dataset.dragging,this.dragInfo=null,this._cleanDragOverAttrs();if(o!==null&&c!==null)for(let f of c)this.transactor.transactInputNow(o,t,f,this.dragInfo)}makeStack(t){return X.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()}),kr("tutuca-app",this.comps.compileStyles()),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 kr(t,e){let r=document.createElement("style"),s=document.head.querySelector(`#${t}`);if(s)document.head.removeChild(s);r.id=t,r.innerHTML=e,document.head.appendChild(r)}function fu(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 Xi{constructor(t,e,r,s,i,n){this.path=t,this.stack=e,this.e=r,this.value=s,this.type=i,this.node=n}lookupBind(t){return this.stack.lookupBind(t)}}class Be extends 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,f=new Be(s,i,n,h,u,o,{macroName:t,macroVars:e,macroSlots:r},this);return f.classes=this.classes,f}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),h)this._addClasses(h.value)}else if(typeof i?.value==="string")this._addClasses(i.value)}else{let s=t.items.class;if(s)this._addClasses(s)}}}function vt(t,e){if(!t)throw Error(e)}function $(t){vt(t!==1/0,"Cannot perform this action with an infinite size.")}function Zi(t,e,r,s,i,n){return $(t.size),t.__iterate((h,u,o)=>{if(i)i=!1,r=h;else r=e.call(s,r,h,u,o)},n),r}var _u=(t,e)=>e,lu=(t,e)=>[e,t],mr=(t)=>function(...e){return!t.apply(this,e)},Bi=(t)=>function(...e){return-t.apply(this,e)};function cn(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 Hi=(t,e)=>t<e?1:t>e?-1:0,K={done:!0,value:void 0};class fn{constructor(t){this.next=t}[Symbol.iterator](){return this}}function L(t){return new fn(t)}function M(t){let e=[void 0,void 0],r={done:!1,value:void 0};return L(()=>{if(t(e))return r.value=[e[0],e[1]],r;return K})}var au=L(()=>K),ct=()=>au;function me(t){let e=0,r={done:!1,value:void 0};return L(()=>{if(e===t)return K;return r.value=e++,r})}function ne(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!!Ne(t)}var yu=(t)=>!!(t&&typeof t.next==="function");function ln(t){return Ne(t)?.call(t)}function Ne(t){let e=t&&t[Symbol.iterator];if(typeof e==="function")return e}function gu(t){let e=Ne(t);return e&&e===t.entries}function du(t){let e=Ne(t);return e&&e===t.keys}var he="delete",z=5,q=1<<z,A=q-1,d={},is=()=>({value:!1});function T(t){if(t)t.value=!0}class Ve{}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),ue=(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,Jt=(t,e)=>gn(t,e,0),oe=(t,e)=>gn(t,e,e),dn="@@__IMMUTABLE_ITERABLE__@@",Ye="@@__IMMUTABLE_KEYED__@@",Pe="@@__IMMUTABLE_INDEXED__@@",it="@@__IMMUTABLE_ORDERED__@@",ce="@@__IMMUTABLE_SEQ__@@",pn="@@__IMMUTABLE_LIST__@@",wn="@@__IMMUTABLE_MAP__@@",zn="@@__IMMUTABLE_SET__@@",Sn="@@__IMMUTABLE_STACK__@@",On="@@__IMMUTABLE_RECORD__@@";function C(t,e){return typeof t==="object"&&t!==null&&e in t}var R=(t)=>C(t,dn),w=(t)=>C(t,Ye),j=(t)=>C(t,Pe),fs=(t)=>w(t)||j(t),m=(t)=>C(t,it),_s=(t)=>C(t,ce),ls=(t)=>C(t,pn),fe=(t)=>C(t,wn),as=(t)=>C(t,zn),ys=(t)=>C(t,Sn),at=(t)=>C(t,On),x=(t)=>R(t)||at(t),ve=(t)=>fe(t)&&m(t),bn=(t)=>as(t)&&m(t),Qi=(t)=>typeof t==="object"&&t!==null&&typeof t.equals==="function"&&typeof t.hashCode==="function";function Mn(t){let e=Y(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=Xt,e.__iterate=function(r,s){return t.__iterate((i,n)=>r(n,i,this),s)},e.__iteratorUncached=function(r){return ne(t.__iterator(r),(s,i,n)=>{n[0]=i,n[1]=s})},e}function En(t,e,r){let s=Y(t);return s.size=t.size,s.has=(i)=>t.has(i),s.get=(i,n)=>{let h=t.get(i,d);return h===d?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 ne(t.__iterator(i),(n,h,u)=>{u[0]=n,u[1]=e.call(r,h,n,t)})},s}function qn(t,e){let r=Y(t);if(r._iter=t,r.size=t.size,r.reverse=()=>t,t.flip)r.flip=function(){let s=Mn(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=Xt,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 ne(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(ue(e,r,i))return t;if(i===void 0&&(e<0||r<0))return jn(t.toSeq().cacheResult(),e,r,s);let n=Jt(e,i),u=oe(r,i)-n,o;if(!Number.isNaN(u))o=Math.max(0,u);let c=Y(t);if(c.size=o===0?o:t.size&&o||void 0,!s&&_s(t)&&o>=0)c.get=function(f,_){return f=st(this,f),f>=0&&f<o?t.get(f+n,_):_};return c.__iterateUncached=function(f,_){if(o!==0&&_)return this.cacheResult().__iterate(f,_);if(o===0)return 0;let l=0,a=0;return t.__iterate((y,g)=>{if(l<n){l++;return}if(o!==void 0&&a>=o)return!1;if(a++,f(y,s?g:a-1,this)===!1)return!1},_),a},c.__iteratorUncached=function(f){if(o!==0&&f)return this.cacheResult().__iterator(f);if(o===0)return ct();let _=t.__iterator(f),l=0,a=0;if(s)return L(()=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return K;let y=_.next();if(y.done)return y;return a++,y});return M((y)=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return!1;let g=_.next();if(g.done)return!1;return a++,y[0]=a-1,y[1]=g.value[1],!0})},c}function Gi(t,e,r){if(!e)e=cn;let s=w(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):ee(n)}function He(t,e,r){if(!e)e=cn;if(r){let s=t.toSeq().map((i,n)=>[i,r(i,n,t)]).reduce((i,n)=>Yi(e,i[1],n[1])?n:i);return s&&s[0]}return t.reduce((s,i)=>Yi(e,s,i)?i:s)}function Yi(t,e,r){let s=t(r,e);return s===0&&r!==e&&(r===void 0||r===null||Number.isNaN(r))||s>0}function Nr(t,e,r,s){let i=Y(t),n=new _e(r).map((h)=>h.size);return i.size=s?n.max():n.min(),i.__iterate=function(h,u){let o=this.__iterator(u),c=0,f;while(!(f=o.next()).done)if(h(f.value[1],c++,this)===!1)break;return c},i.__iteratorUncached=function(h){let u=r.map((_)=>{let l=N(_);return ln(h?l.reverse():l)}),o=0,c=Array(u.length),f=Array(u.length);return M((_)=>{let l=s;for(let a=0;a<u.length;a++)c[a]=u[a].next(),l=s?l&&c[a].done:l||c[a].done;if(l)return!1;for(let a=0;a<c.length;a++)f[a]=c[a].value;return _[0]=o++,_[1]=e(...f),!0})},i}function In(t){if(Array.isArray(t)||typeof t==="string")return!0;return t&&typeof t==="object"&&Number.isInteger(t.length)&&t.length>=0&&(t.length===0?Object.keys(t).length===1:Object.hasOwn(t,t.length-1))}function pu(t){if(!t||typeof t!=="object"||Object.prototype.toString.call(t)!=="[object Object]")return!1;let e=Object.getPrototypeOf(t);if(e===null)return!0;let r=e,s=Object.getPrototypeOf(e);while(s!==null)r=s,s=Object.getPrototypeOf(r);return r===e}var nt=(t)=>typeof t==="object"&&(x(t)||Array.isArray(t)||pu(t));function $n(t){if(In(t)&&typeof t!=="string")return t;if(m(t))return t.toArray();throw TypeError(`Invalid keyPath: expected Ordered Collection or Array: ${t}`)}var wu=(t,e)=>x(t)?t.has(e):nt(t)&&Object.hasOwn(t,e);function Kn(t,e,r){return x(t)?t.get(e,r):!wu(t,e)?r:typeof t.get==="function"?t.get(e):t[e]}function gs(t,e,r){let s=$n(e),i=0;while(i!==s.length)if(t=Kn(t,s[i++],d),t===d)return r;return t}var An=(t,e)=>gs(t,e,d)!==d;function I(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!!(Qi(t)&&Qi(e)&&t.equals(e))}function Ce(t){if(!t||typeof t!=="object")return t;if(!R(t)){if(!nt(t))return t;t=ht(t)}if(w(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 ds(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||w(t)!==w(e)||j(t)!==j(e)||m(t)!==m(e))return!1;if(t.size===0&&e.size===0)return!0;let r=!fs(t);if(m(t)){let h=t.entries();return!!(e.every((u,o)=>{let c=h.next().value;return c&&I(c[1],u)&&(r||I(c[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?!I(h,t.get(u,d)):!I(t.get(u,d),h))return i=!1,!1;return!0});return i&&t.size===n}var tr=(t)=>t>>>1&1073741824|t&3221225471;function Z(t){if(t===null||t===void 0)return Pi(t);if(typeof t.hashCode==="function")return tr(t.hashCode(t));let e=Mu(t);if(e===null||e===void 0)return Pi(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return zu(e);case"string":return e.length>Eu?Su(e):ns(e);case"object":case"function":return bu(e);case"symbol":return Ou(e);default:if(typeof e.toString==="function")return ns(e.toString());throw Error(`Value type ${typeof e} cannot be hashed.`)}}var Pi=(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 Su(t){let e=ts[t];if(e===void 0){if(e=ns(t),vr===qu)vr=0,ts={};vr++,ts[t]=e}return e}function ns(t){let e=0;for(let r=0;r<t.length;r++)e=31*e+t.charCodeAt(r)|0;return tr(e)}function Ou(t){let e=xi[t];if(e!==void 0)return e;return e=Un(),xi[t]=e,e}function bu(t){let e=Ci.get(t);if(e!==void 0)return e;return e=Un(),Ci.set(t,e),e}var Mu=(t)=>t.valueOf!==Object.prototype.valueOf?t.valueOf():t;function Un(){let t=++Vr;if(Vr&1073741824)Vr=0;return t}var Ci=new WeakMap,xi=Object.create(null),Vr=0,Eu=16,qu=255,vr=0,ts={};function ju(t){if(t.size===1/0)return 0;let e=m(t),r=w(t),s=e?1:0;return t.__iterate(r?e?(i,n)=>{s=31*s+Fi(Z(i),Z(n))|0}:(i,n)=>{s=s+Fi(Z(i),Z(n))|0}:e?(i)=>{s=31*s+Z(i)|0}:(i)=>{s=s+Z(i)|0}),Iu(t.size,s)}var Fi=(t,e)=>t^e+2654435769+(t<<6)+(t>>2)|0;function Iu(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 te(t){try{return typeof t==="string"?JSON.stringify(t):String(t)}catch{return JSON.stringify(t)}}var b=(t,e)=>t===e?t:_s(t)?e:t.create?t.create(e):t.constructor(e),$u=(t,e)=>b(t,(w(t)?H:j(t)?yt:gt)(e)),ki=(...t)=>t,N=(t)=>R(t)?t:ht(t);class B{size=0;static{this.prototype[dn]=!0,this.prototype.__toStringMapper=te,this.prototype[Symbol.iterator]=this.prototype.values,this.prototype.toJSON=this.prototype.toArray,this.prototype.contains=this.prototype.includes}equals(t){return ds(this,t)}hashCode(){return this.__hash??(this.__hash=ju(this))}toArray(){$(this.size);let t=Array(this.size||0),e=w(this),r=0;return this.__iterate((s,i)=>{t[r++]=e?[i,s]:s}),t}toIndexedSeq(){return new Jn(this)}toJS(){return Ce(this)}toKeyedSeq(){return new Es(this,!0)}toMap(){throw Error("toMap: not patched — import CollectionConversions")}toObject(){$(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 Tn(this)}toSeq(){return j(this)?this.toIndexedSeq():w(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=w(this),r=[this,...t].map((s)=>{if(!R(s))s=e?Dn(s):Rn(Array.isArray(s)?s:[s]);else if(e)s=H(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&&w(s)||j(this)&&j(s))return s}return b(this,new Wn(r))}includes(t){return this.some((e)=>I(e,t))}every(t,e){$(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=w(this),i=Y(r);if(s)i.has=(n)=>{let h=r.get(n,d);return h!==d&&!!t.call(e,h,n,r)},i.get=(n,h)=>{let u=r.get(n,d);return u!==d&&t.call(e,u,n,r)?u:h};return i.__iterateUncached=function(n,h){let u=0;return r.__iterate((o,c)=>{if(t.call(e,o,c,r))return u++,n(o,s?c:u-1,this)},h),u},i.__iteratorUncached=function(n){let h=r.__iterator(n),u=0;return M((o)=>{while(!0){let c=h.next();if(c.done)return!1;let f=c.value[0],_=c.value[1];if(t.call(e,_,f,r))return o[0]=s?f:u++,o[1]=_,!0}})},b(this,i)}partition(t,e){let r=w(this),s=[[],[]];return this.__iterate((i,n)=>{s[t.call(e,i,n,this)?1:0].push(r?[n,i]:i)}),s.map((i)=>$u(this,i))}find(t,e,r){let s=this.findEntry(t,e);return s?s[1]:r}forEach(t,e){return $(this.size),this.__iterate(e?t.bind(e):t)}join(t){$(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 L(()=>{let r=t.next();if(r.done)return K;return e.value=r.value[0],e})}map(t,e){return b(this,En(this,t,e))}reduce(t,e=d,r){return Zi(this,t,e,r,e===d,!1)}reduceRight(t,e=d,r){return Zi(this,t,e,r,e===d,!0)}reverse(){return b(this,qn(this,w(this)))}slice(t,e){return b(this,jn(this,t,e,w(this)))}some(t,e){$(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 b(this,Gi(this,t))}values(){let t=this.__iterator(),e={done:!1,value:void 0};return L(()=>{let r=t.next();if(r.done)return K;return e.value=r.value[1],e})}butLast(){return this.slice(0,-1)}isEmpty(){return this.size!==void 0?this.size===0:!this.some(()=>!0)}count(t,e){return 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 _e(t._cache);let e=t.toSeq().map(lu).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(an,null,t)}flatMap(t,e){return b(this,this.toSeq().map((r,s)=>(w(this)?H:j(this)?yt:gt)(t.call(e,r,s,this))).flatten(!0))}flatten(t){let e=this,r=w(this),s=Y(e);return s.__iterateUncached=function(i,n){if(n)return this.cacheResult().__iterate(i,n);let h=0,u=!1;function o(c,f){c.__iterate((_,l)=>{if((!t||f<t)&&R(_))o(_,f+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],c=o.iterator.next();if(c.done){h.pop();continue}let f=c.value[1];if((!t||o.depth<t)&&R(f)){h.push({iterator:f.__iterator(i),depth:o.depth+1});continue}return u[0]=r?c.value[0]:n++,u[1]=f,!0}return!1})},b(this,s)}fromEntrySeq(){return new Xn(this)}get(t,e){return this.find((r,s)=>I(s,t),void 0,e)}getIn(t,e){return gs(this,t,e)}groupBy(t,e){throw Error("groupBy: not patched — import CollectionConversions")}has(t){return this.get(t,d)!==d}hasIn(t){return An(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)=>I(e,t))}keySeq(){return this.toSeq().map(_u).toIndexedSeq()}last(t){return this.toSeq().reverse().first(t)}lastKeyOf(t){return this.toKeyedSeq().reverse().keyOf(t)}max(t){return He(this,t)}maxBy(t,e){return He(this,e,t)}min(t){return He(this,t?Bi(t):Hi)}minBy(t,e){return He(this,e?Bi(e):Hi,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=w(this),i=Y(r);return i.__iterateUncached=function(n,h){if(h)return this.cacheResult().__iterate(n,h);let u=!0,o=0;return r.__iterate((c,f)=>{if(u&&t.call(e,c,f,this))return;return u=!1,o++,n(c,s?f: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,c=!0;return M((f)=>{while(!0){let _=h.next();if(_.done)return!1;let l=_.value[0],a=_.value[1];if(c&&t.call(e,a,l,o))continue;return c=!1,f[0]=s?l:u++,f[1]=a,!0}})},b(this,i)}skipUntil(t,e){return this.skipWhile(mr(t),e)}sortBy(t,e){return b(this,Gi(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=Y(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 L(()=>{if(u)return K;let o=n.next();if(o.done)return o;if(!t.call(e,o.value[1],o.value[0],h))return u=!0,K;return o})},b(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 H=(t)=>w(t)?t:zs(t);class ps extends B{static{this.prototype[Ye]=!0,this.prototype.__toStringMapper=(t,e)=>`${te(e)}: ${te(t)}`,this.prototype[Symbol.iterator]=B.prototype.entries,this.prototype.toJSON=function(){$(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}}flip(){return b(this,Mn(this))}mapEntries(t,e){let r=0;return b(this,this.toSeq().map((s,i)=>t.call(e,[i,s],r++,this)).fromEntrySeq())}mapKeys(t,e){return b(this,this.toSeq().flip().map((r,s)=>t.call(e,r,s,this)).flip())}}var yt=(t)=>j(t)?t:lt(t);class Ut extends B{static{this.prototype[Pe]=!0,this.prototype[it]=!0}toKeyedSeq(){return new Es(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=d,...r){if(t===void 0)return this;let s=e!==d;if(e=s?Math.max(e||0,0):0,s&&!e&&r.length===0)return this;t=Jt(t,t<0?this.count():this.size);let i=this.slice(0,t);return b(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=Y(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((c)=>{if(o)return o=!1,c[0]=n++,c[1]=u,!0;let f=i.next();if(f.done)return!1;let _=f.value[1];if(!h)return u=_,o=!0,c[0]=n++,c[1]=t,!0;return h=!1,c[0]=n++,c[1]=_,!0})},b(this,r)}interleave(...t){let e=[this,...t],r=Nr(this.toSeq(),lt.of,e),s=r.flatten(!0);if(r.size)s.size=r.size*e.length;return b(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 b(this,Nr(this,ki,e,!0))}zipWith(t,...e){let r=[this,...e];return b(this,Nr(this,t,r))}}var gt=(t)=>R(t)&&!fs(t)?t:ee(t);class er extends B{static{this.prototype.has=B.prototype.includes,this.prototype.contains=B.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=H;N.Indexed=yt;N.Set=gt;var es=Ut.prototype,ht=(t)=>t===void 0||t===null?bs():x(t)?t.toSeq():Ku(t),Y=(t)=>Object.create((w(t)?Tt:j(t)?dt:Ss).prototype);class ft extends B{static{this.prototype[ce]=!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 L(()=>{if(s===r)return K;return i.value=e[t?r-++s:s++],i})}return this.__iteratorUncached(t)}}var ws={cacheResult:ft.prototype.cacheResult,__iterateUncached:ft.prototype.__iterateUncached,__iterate:ft.prototype.__iterate,__iterator:ft.prototype.__iterator},zs=(t)=>t===void 0||t===null?bs().toKeyedSeq():R(t)?w(t)?t.toSeq():t.fromEntrySeq():at(t)?t.toSeq():Dn(t);class Tt extends ps{static{this.prototype[ce]=!0,Object.assign(this.prototype,ws)}toSeq(){return this}toKeyedSeq(){return this}}var lt=(t)=>t===void 0||t===null?bs():R(t)?w(t)?t.entrySeq():t.toIndexedSeq():at(t)?t.toSeq().entrySeq():Rn(t);lt.of=(...t)=>lt(t);class dt extends Ut{static{this.prototype[ce]=!0,Object.assign(this.prototype,ws)}toSeq(){return this}toIndexedSeq(){return this}toString(){return this.__toString("Seq [","]")}}var ee=(t)=>(R(t)&&!fs(t)?t:lt(t)).toSetSeq();ee.of=(...t)=>ee(t);class Ss extends er{static{this.prototype[ce]=!0,Object.assign(this.prototype,ws)}toSeq(){return this}toSetSeq(){return this}}ht.isSeq=_s;ht.Keyed=zs;ht.Set=ee;ht.Indexed=lt;class _e extends dt{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 Os extends Tt{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 dt{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(!yu(r))return ct();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 bs=()=>new _e([]),Ms=(t)=>In(t)?new _e(t):_n(t)?new Ln(t):void 0;function Dn(t){let e=Ms(t);if(e)return e.fromEntrySeq();if(typeof t==="object")return new Os(t);throw TypeError(`Expected Array or collection object of [k, v] entries, or keyed object: ${t}`)}function Rn(t){let e=Ms(t);if(e)return e;throw TypeError(`Expected Array or collection object of values: ${t}`)}function Ku(t){let e=Ms(t);if(e)return gu(t)?e.fromEntrySeq():du(t)?e.toSetSeq():e;if(typeof t==="object")return new Os(t);throw TypeError(`Expected Array or collection object of values, or keyed object: ${t}`)}class Wn extends ft{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[Pe])this[Pe]=!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=!w(this),i=0,n=!1;for(let h of r)if(h.__iterate((u,o)=>{if(t(u,s?i++:o,this)===!1)return n=!0,!1},e),n)break;return i}__iteratorUncached(t){if(this._wrappedIterables.length===0)return ct();if(t)return this.cacheResult().__iterator(t);let e=this._wrappedIterables,r=!w(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 L(()=>n()||K)}}class Es extends Tt{static{this.prototype[it]=!0}constructor(t,e){super();this._iter=t,this._useKeys=e,this.size=t.size}cacheResult(){return Xt.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=qn(this,!0);if(!this._useKeys)t.valueSeq=()=>this._iter.toSeq().reverse();return t}map(t,e){let r=En(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 Jn extends dt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Xt.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 ne(this._iter.__iterator(t),(s,i,n)=>{n[0]=t?r-++e:e++,n[1]=i})}}class Tn extends Ss{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Xt.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 ne(this._iter.__iterator(t),(e,r,s)=>{s[0]=r,s[1]=r})}}class Xn extends Tt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Xt.call(this)}entrySeq(){return this._iter.toSeq()}__iterateUncached(t,e){let r=0;return this._iter.__iterate((s)=>{if(s){mi(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){mi(i);let n=R(i);return r[0]=n?i.get(0):i[0],r[1]=n?i.get(1):i[1],!0}}})}}function Xt(){if(this._iter.cacheResult)return this._iter.cacheResult(),this.size=this._iter.size,this;return ft.prototype.cacheResult.call(this)}function mi(t){if(t!==Object(t))throw TypeError(`Expected [K, V] tuple: ${t}`)}var G=(t)=>t===void 0||t===null?Q():fe(t)&&!m(t)?t:Q().withMutations((e)=>{let r=H(t);$(r.size),r.forEach((s,i)=>e.set(i,s))});class qs extends ps{static{wt(this,{asImmutable:le,asMutable:ae,deleteIn:Lt,merge:hs,mergeWith:Pn,mergeDeep:xn,mergeDeepWith:Fn,mergeDeepIn:Xs,mergeIn:Ts,setIn:Rs,update:Ws,updateIn:Js,wasAltered:Ds,withMutations:ye,removeIn:Lt,concat:hs,[wn]:!0,[he]: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 G(t)}toString(){return this.__toString("Map {","}")}get(t,e){return this._root?this._root.get(0,Z(t),t,e):e}set(t,e){return Vi(this,t,e)}remove(t){return Vi(this,t,d)}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 Q()}map(t,e){return this.withMutations((r)=>{r.forEach((s,i)=>{r.set(i,t.call(e,s,i,this))})})}keys(){if(!this._root)return ct();return Qe(this._root,!1,0)}values(){if(!this._root)return ct();return Qe(this._root,!1,1)}entries(){if(!this._root)return ct();return Qe(this._root,!1)}__iterator(t){if(!this._root)return ct();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 Q();return this.__ownerID=t,this.__altered=!1,this}return $s(this.size,this._root,t,this.__hash)}}G.isMap=fe;class js{constructor(t,e){this.ownerID=t,this.entries=e}get(t,e,r,s){return Zn(this.entries,r,s)}iterate(t,e){return Bn(this.entries,t,e)}update(t,e,r,s,i,n,h){let u=i===d,o=this.entries,c=0,f=o.length;for(;c<f;c++)if(I(s,o[c][0]))break;let _=c<f;if(_?o[c][1]===i:u)return this;if(T(h),u||!_)T(n);if(u&&f===1)return;if(!_&&!u&&f>=Wu)return Au(t,o,s,i);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(c===f-1)a.pop();else a[c]=a.pop();else a[c]=[s,i];else a.push([s,i]);if(l)return this.entries=a,this;return new js(t,a)}}class rr{constructor(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}iterate(t,e){return Hn(this.nodes,t,e)}get(t,e,r,s){let i=1<<((t===0?e:e>>>t)&A),n=this.bitmap;return(n&i)===0?s:this.nodes[tn(n&i-1)].get(t+z,e,r,s)}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&A,o=1<<u,c=this.bitmap,f=(c&o)!==0;if(!f&&i===d)return this;let _=tn(c&o-1),l=this.nodes,a=f?l[_]:void 0,y=Ks(a,t,e+z,r,s,i,n,h);if(y===a)return this;if(!f&&y&&l.length>=Ju)return Lu(t,l,c,u,y);if(f&&!y&&l.length===2&&vi(l[_^1]))return l[_^1];if(f&&y&&l.length===1&&vi(y))return y;let g=t&&t===this.ownerID,S=f?y?c:c^o:c|o,O=f?y?Qn(l,_,y,g):Ru(l,_,g):Du(l,_,y,g);if(g)return this.bitmap=S,this.nodes=O,this;return new rr(t,S,O)}}class Is{constructor(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}iterate(t,e){return Hn(this.nodes,t,e)}get(t,e,r,s){let i=(t===0?e:e>>>t)&A,n=this.nodes[i];return n?n.get(t+z,e,r,s):s}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&A,o=i===d,c=this.nodes,f=c[u];if(o&&!f)return this;let _=Ks(f,t,e+z,r,s,i,n,h);if(_===f)return this;let l=this.count;if(!f)l++;else if(!_){if(l--,l<Tu)return Uu(t,c,l,u)}let a=t&&t===this.ownerID,y=Qn(c,u,_,a);if(a)return this.count=l,this.nodes=y,this;return new Is(t,l,y)}}class sr{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}get(t,e,r,s){return Zn(this.entries,r,s)}iterate(t,e){return Bn(this.entries,t,e)}update(t,e,r,s,i,n,h){if(r!==this.keyHash){if(i===d)return this;return T(h),T(n),As(this,t,e,r,[s,i])}let u=i===d,o=this.entries,c=0,f=o.length;for(;c<f;c++)if(I(s,o[c][0]))break;let _=c<f;if(_?o[c][1]===i:u)return this;if(T(h),u||!_)T(n);if(u&&f===2)return new pt(t,this.keyHash,o[c^1]);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(c===f-1)a.pop();else a[c]=a.pop();else a[c]=[s,i];else a.push([s,i]);if(l)return this.entries=a,this;return new sr(t,this.keyHash,a)}}class pt{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 I(r,this.entry[0])?this.entry[1]:s}update(t,e,r,s,i,n,h){let u=i===d,o=I(s,this.entry[0]);if(o?i===this.entry[1]:u)return this;if(T(h),u){T(n);return}if(o){if(t&&t===this.ownerID)return this.entry[1]=i,this;return new pt(t,this.keyHash,[s,i])}return T(n),As(this,t,e,Z(s),[s,i])}}function Zn(t,e,r){for(let s=0,i=t.length;s<i;s++)if(I(e,t[s][0]))return t[s][1];return r}function Bn(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 Hn(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 L(()=>{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 c=h.nodes[e?o-u:u];if(c){if(c.entry)return n.value=i(c.entry),n;s={node:c,index:0,__prev:s}}continue}s=s.__prev}return K})}var $s=(t,e,r,s)=>new qs(t,e,r,s),Ni,Q=()=>Ni||(Ni=$s(0));function Vi(t,e,r){let s,i;if(!t._root){if(r===d)return t;i=1,s=new js(t.__ownerID,[[e,r]])}else{let n=is(),h=is();if(s=Ks(t._root,t.__ownerID,0,Z(e),e,r,n,h),!h.value)return t;i=t.size+(n.value?r===d?-1:1:0)}if(t.__ownerID)return t.size=i,t._root=s,t.__hash=void 0,t.__altered=!0,t;return s?$s(i,s):Q()}function Ks(t,e,r,s,i,n,h,u){if(!t){if(n===d)return t;return T(u),T(h),new pt(e,s,[i,n])}return t.update(e,r,s,i,n,h,u)}var vi=(t)=>t.constructor===pt||t.constructor===sr;function As(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)&A,h=(r===0?s:s>>>r)&A,u=new pt(e,s,i),o=n===h?[As(t,e,r+z,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 Ve;let i=new pt(t,Z(r),[r,s]);for(let[n,h]of e)i=i.update(t,0,Z(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,c=e.length;u<c;u++,o<<=1){let f=e[u];if(f!==void 0&&u!==s)i|=o,h[n++]=f}return new rr(t,i,h)}function Lu(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 Is(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 Qn(t,e,r,s){let i=s?t:t.slice();return i[e]=r,i}function Du(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 Ru(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,Tu=q/4;function xe(t){if(Array.isArray(t))return t.slice();return{...t}}var Us=(t,e,r)=>Ls(t,e,Xu(r));function Ls(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:H,h=s?(u)=>{if(i===t)i=xe(i);i.push(u)}:(u,o)=>{let c=Object.hasOwn(i,o),f=c&&r?r(i[o],u,o):u;if(!c||f!==i[o]){if(i===t)i=xe(i);i[o]=f}};for(let u of e)n(u).forEach(h);return i}function Xu(t){function e(r,s,i){return nt(r)&&nt(s)&&Zu(r,s)?Ls(r,[s],e):t?t(r,s,i):s}return e}function Zu(t,e){let r=ht(t),s=ht(e);return j(r)===j(s)&&w(r)===w(s)}function Bu(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=xe(t);if(Array.isArray(r))r.splice(e,1);else delete r[e];return r}function Hu(t,e,r){if(!nt(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(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 Zt(t,e,r,s){if(!s)s=r,r=void 0;let i=Gn(x(t),t,$n(e),0,r,s);return i===d?r:i}function Gn(t,e,r,s,i,n){let h=e===d;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(te)}]: ${e}`);let u=r[s],o=h?d:Kn(e,u,d),c=Gn(o===d?t:x(o),o,r,s+1,i,n);if(c===o)return e;if(c===d)return Bu(e,u);let f=h?t?Q():{}:e;return Hu(f,u,c)}var Qu=(t,e)=>Zt(t,e,()=>d),Gu=(t,e,r)=>Zt(t,e,d,()=>r);function Yn(t,e,r,s){return Zt(t,[e],r,s)}function le(){return this.__ensureOwner()}function ae(){return this.__ownerID?this:this.__ensureOwner(new Ve)}function Ds(){return this.__altered}function ye(t){let e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Yu(t,e){return gs(this,t,e)}function Pu(t){return An(this,t)}function Lt(t){return Qu(this,t)}function Rs(t,e){return Gu(this,t,e)}function Ws(t,e,r){return typeof t==="function"?t(this):Yn(this,t,e,r)}function Js(t,e,r){return Zt(this,t,e,r)}function en(){$(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}function hs(...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=H(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)=>{Yn(i,u,d,(o)=>o===d?h:r(o,h,u))}:(h,u)=>{i.set(u,h)};for(let h of s)h.forEach(n)})}function xn(...t){return Us(this,t)}function Fn(t,...e){return Us(this,e,t)}function Ts(t,...e){return Zt(this,t,Q(),(r)=>Ls(r,e))}function Xs(t,...e){return Zt(this,t,Q(),(r)=>Us(r,e))}function wt(t,e){Object.assign(t.prototype,e)}var U=(t)=>{let e=re();if(t===void 0||t===null)return e;if(ls(t))return t;let r=yt(t),s=r.size;if(s===0)return e;if($(s),s>0&&s<q)return ge(0,s,z,null,new _t(r.toArray()));return e.withMutations((i)=>{i.setSize(s),r.forEach((n,h)=>i.set(h,n))})};U.of=(...t)=>U(t);class kn extends Ut{static{wt(this,{asImmutable:le,asMutable:ae,deleteIn:Lt,mergeDeepIn:Xs,mergeIn:Ts,setIn:Rs,update:Ws,updateIn:Js,wasAltered:Ds,withMutations:ye,removeIn:Lt,[pn]:!0,[he]:this.prototype.remove,merge:this.prototype.concat,[Symbol.toStringTag]:"Immutable.List",[Symbol.iterator]:this.prototype.values})}constructor(t,e,r,s,i,n,h){super();this.size=e-t,this._origin=t,this._capacity=e,this._level=r,this._root=s,this._tail=i,this.__ownerID=n,this.__hash=h,this.__altered=!1}create(t){return U(t)}toString(){return this.__toString("List [","]")}get(t,e){if(t=st(this,t),t>=0&&t<this.size){t+=this._origin;let r=Vn(this,t);return r&&r.array[t&A]}return e}set(t,e){return xu(this,t,e)}remove(t){return!this.has(t)?this:t===0?this.shift():t===this.size-1?this.pop():this.splice(t,1)}insert(t,e){return this.splice(t,0,e)}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=this._origin=this._capacity=0,this._level=z,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this;return re()}push(...t){let e=this.size;return this.withMutations((r)=>{rt(r,0,e+t.length);for(let s=0;s<t.length;s++)r.set(e+s,t[s])})}pop(){return rt(this,0,-1)}unshift(...t){return this.withMutations((e)=>{rt(e,-t.length);for(let r=0;r<t.length;r++)e.set(r,t[r])})}shift(){return rt(this,1)}shuffle(t=Math.random){return this.withMutations((e)=>{let r=e.size,s,i;while(r)s=Math.floor(t()*r--),i=e.get(s),e.set(s,e.get(r)),e.set(r,i)})}concat(...t){let e=[];for(let r of t){let s=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 U(e[0]);return this.withMutations((r)=>{e.forEach((s)=>s.forEach((i)=>r.push(i)))})}setSize(t){return rt(this,0,t)}map(t,e){return this.withMutations((r)=>{for(let s=0;s<this.size;s++)r.set(s,t.call(e,r.get(s),s,this))})}slice(t,e){let r=this.size;if(ue(t,e,r))return this;return rt(this,Jt(t,r),oe(e,r))}__iterate(t,e){let r=e?this.size:0;return Cu(this,(s)=>t(s,e?--r:r++,this),e),e?this.size-r:r}__iterator(t){let e=t?this.size:0,r=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 me(this.size)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return re();return this.__ownerID=t,this.__altered=!1,this}return ge(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash)}}U.isList=ls;class _t{constructor(t,e){this.array=t,this.ownerID=e}removeBefore(t,e,r){if((r&(1<<e+z)-1)===0||this.array.length===0)return this;let s=r>>>e&A;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-z,r),n===u&&i)return this}if(i&&!n)return this;let h=Dt(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+z:q)||this.array.length===0)return this;let s=r-1>>>e&A;if(s>=this.array.length)return this;let i;if(e>0){let h=this.array[s];if(i=h?.removeAfter(t,e-z,r),i===h&&s===this.array.length-1)return this}let n=Dt(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=Rt(s),n=t._tail,h=[];o(t._root,t._level,0);let u={done:!1,value:void 0};return L(()=>{while(h.length>0){let c=h[h.length-1];if(c.from===c.to){h.pop();continue}let f=e?--c.to:c.from++;if(c.isLeaf)return u.value=c.array?.[f],u;let _=c.array?.[f],l=c.level-z,a=c.offset+(f<<c.level);o(_,l,a)}return K});function o(c,f,_){if(f===0){let l=_===i?n?.array:c?.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=c?.array,a=_>r?0:r-_>>f,y=(s-_>>f)+1;if(y>q)y=q;if(a!==y)h.push({array:l,from:a,to:y,level:f,offset:_,isLeaf:!1})}}}function Cu(t,e,r){let{_origin:s,_capacity:i}=t,n=Rt(i),h=t._tail,u=t._level,o=t._root;return u===0?mn(o,0,s,i,n,h,e,r):Nn(o,u,0,s,i,n,h,e,r)}function mn(t,e,r,s,i,n,h,u){let o=e===i?n?.array:t?.array,c=e>r?0:r-e,f=s-e;if(f>q)f=q;while(c!==f){let _=u?--f:c++;if(h(o?.[_])===!1)return!1}}function Nn(t,e,r,s,i,n,h,u,o){let c=t?.array,f=r>s?0:s-r>>e,_=(i-r>>e)+1;if(_>q)_=q;let l=e-z;while(f!==_){let a=o?--_:f++,y=r+(a<<e);if((l===0?mn(c?.[a],y,s,i,n,h,u,o):Nn(c?.[a],l,y,s,i,n,h,u,o))===!1)return!1}}var ge=(t,e,r,s,i,n,h)=>new kn(t,e,r,s,i,n,h),re=()=>ge(0,0,z);function xu(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=is();if(e>=Rt(t._capacity))s=us(s,t.__ownerID,0,e,r,n);else i=us(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 ge(t._origin,t._capacity,t._level,i,s)}function us(t,e,r,s,i,n){let h=s>>>r&A,u=t&&h<t.array.length;if(!u&&i===void 0)return t;let o;if(r>0){let c=t&&t.array[h],f=us(c,e,r-z,s,i,n);if(f===c)return t;return o=Dt(t,e),o.array[h]=f,o}if(u&&t.array[h]===i)return t;if(n)T(n);if(o=Dt(t,e),i===void 0&&h===o.array.length-1)o.array.pop();else o.array[h]=i;return o}function Dt(t,e){if(e&&e===t?.ownerID)return t;return new _t(t?.array.slice()??[],e)}function Vn(t,e){if(e>=Rt(t._capacity))return t._tail;if(e<1<<t._level+z){let{_root:r,_level:s}=t;while(r&&s>0)r=r.array[e>>>s&A],s-=z;return r}}function rt(t,e,r){if(e!==void 0)e|=0;if(r!==void 0)r|=0;let s=t.__ownerID||new Ve,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:c}=t,f=0;while(h+f<0)c=new _t(c?.array.length?[void 0,c]:[],s),o+=z,f+=1<<o;if(f)h+=f,i+=f,u+=f,n+=f;let _=Rt(n),l=Rt(u);while(l>=1<<o+z)c=new _t(c?.array.length?[c]:[],s),o+=z;let a=t._tail,y=l<_?Vn(t,u-1):l>_?new _t([],s):a;if(a&&l>_&&h<n&&a.array.length){c=Dt(c,s);let g=c;for(let S=o;S>z;S-=z){let O=_>>>S&A;g=g.array[O]=Dt(g.array[O],s)}g.array[_>>>z&A]=a}if(u<n)y=y&&y.removeAfter(s,0,u);if(h>=l)h-=l,u-=l,o=z,c=null,y=y&&y.removeBefore(s,0,h);else if(h>i||l<_){f=0;while(c){let g=h>>>o&A;if(g!==l>>>o&A)break;if(g)f+=(1<<o)*g;o-=z,c=c.array[g]}if(c&&h>i)c=c.removeBefore(s,o,h-f);if(c&&l<_)c=c.removeAfter(s,o,l-f);if(f)h-=f,u-=f}if(t.__ownerID)return t.size=u-h,t._origin=h,t._capacity=u,t._level=o,t._root=c,t._tail=y,t.__hash=void 0,t.__altered=!0,t;return ge(h,u,o,c,y)}var Rt=(t)=>t<q?0:t-1>>>z<<z,P=(t)=>t===void 0||t===null?se():ve(t)?t:se().withMutations((e)=>{let r=H(t);$(r.size),r.forEach((s,i)=>e.set(i,s))});P.of=(...t)=>P(t);class vn extends qs{static{wt(this,{[it]:!0,[he]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.OrderedMap",keys:B.prototype.keys,values:B.prototype.values,__iterate:B.prototype.__iterate})}constructor(t,e,r,s){super(t?t.size:0,void 0,r,s);this._map=t,this._list=e}create(t){return 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 se()}set(t,e){return sn(this,t,e)}remove(t){return sn(this,t,d)}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 se();return this.__ownerID=t,this.__altered=!1,this._map=e,this._list=r,this}return Zs(e,r,t,this.__hash)}}P.isOrderedMap=ve;var Zs=(t,e,r,s)=>new vn(t,e,r,s),se=()=>Zs(Q(),re());function sn(t,e,r){let{_map:s,_list:i}=t,n=s.get(e),h=n!==void 0,u,o;if(r===d){if(!h)return t;if(i.size>=q&&i.size>=s.size*2){let c=[];if(i.forEach((f,_)=>{if(f!==void 0&&n!==_)c.push(f)}),o=re().withMutations((f)=>{for(let _=0;_<c.length;_++)f.set(_,c[_])}),u=Q().withMutations((f)=>{for(let _=0;_<c.length;_++)f.set(c[_][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 c=i.size;u=s.set(e,c),o=i.set(c,[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 Fe=(t)=>t===void 0||t===null?ke():ys(t)?t:ke().pushAll(t);Fe.of=(...t)=>Fe(t);class th extends Ut{static{wt(this,{asImmutable:le,asMutable:ae,wasAltered:Ds,withMutations:ye,[Sn]:!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=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 rs(this,e,r)}pushAll(t){if(t=yt(t),t.size===0)return this;if(this.size===0&&ys(t))return t;$(t.size);let e=this.size,r=this._head;return t.__iterate((s)=>{e++,r={value:s,next:r}},!0),rs(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 ke()}slice(t,e){if(ue(t,e,this.size))return this;let r=Jt(t,this.size);if(oe(e,this.size)!==this.size)return Ut.prototype.slice.call(this,t,e);let i=this.size-r,n=this._head;while(r--)n=n.next;return rs(this,i,n)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return ke();return this.__ownerID=t,this.__altered=!1,this}return Bs(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 L(()=>{if(!t)return K;return e.value=t.value,t=t.next,e})}keys(){return me(this.size)}}Fe.isStack=ys;function rs(t,e,r){if(t.__ownerID)return t.size=e,t._head=r,t.__hash=void 0,t.__altered=!0,t;return Bs(e,r)}var Bs=(t,e,r,s)=>new th(t,e,r,s),nn,ke=()=>nn||(nn=Bs(0)),E=(t)=>t===void 0||t===null?ie():as(t)&&!m(t)?t:ie().withMutations((e)=>{let r=gt(t);$(r.size),r.forEach((s)=>e.add(s))});E.of=(...t)=>E(t);E.fromKeys=(t)=>E(H(t).keySeq());E.intersect=(t)=>{return t=N(t).toArray(),t.length?E(t.pop()).intersect(...t):ie()};E.union=(t)=>{let e=N(t).toArray();return e.length?E(e.pop()).union(...e):ie()};class Hs extends er{static{wt(this,{withMutations:ye,asImmutable:le,asMutable:ae,[zn]:!0,[he]: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 E(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 E(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 ie()}__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)}}E.isSet=as;var eh=(t,e)=>new Hs(t,e),hn,ie=()=>hn||(hn=eh(Q()));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 Wt=(t)=>t===void 0||t===null?os():bn(t)?t:os().withMutations((e)=>{let r=gt(t);$(r.size),r.forEach((s)=>e.add(s))});Wt.of=(...t)=>Wt(t);Wt.fromKeys=(t)=>Wt(H(t).keySeq());class rh extends Hs{static{wt(this,{[it]:!0,[Symbol.toStringTag]:"Immutable.OrderedSet",zip:es.zip,zipWith:es.zipWith,zipAll:es.zipAll})}create(t){return Wt(t)}toString(){return this.__toString("OrderedSet {","}")}__empty(){return os()}__make(t,e){return sh(t,e)}}Wt.isOrderedSet=bn;var sh=(t,e)=>new rh(t,e),os=()=>sh(se());function Fu(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 de=(t,e)=>{let r;Fu(t);let s=function(h){if(h instanceof s)return h;if(!(this instanceof s))return new s(h);if(!r){r=!0;let u=Object.keys(t),o=i._indices={};i._keys=u,i._defaultValues=t;for(let c=0;c<u.length;c++){let f=u[c];if(o[f]=c,i[f])console.warn(`Cannot define ${Qs(this)} with property "${f}" since that property name is part of the Record API.`);else mu(i,f)}}return this.__ownerID=void 0,this._values=U().withMutations((u)=>{u.setSize(this._keys.length),H(h).forEach((o,c)=>{u.set(this._indices[c],o===this._defaultValues[c]?void 0:o)})}),this},i=s.prototype=Object.create(ku);if(i.constructor=s,i.create=s,e)s.displayName=e;return s};class ih{static{wt(this,{asImmutable:le,asMutable:ae,deleteIn:Lt,getIn:Yu,hasIn:Pu,merge:hs,mergeWith:Pn,mergeDeep:xn,mergeDeepWith:Fn,mergeDeepIn:Xs,mergeIn:Ts,setIn:Rs,toObject:en,update:Ws,updateIn:Js,withMutations:ye,removeIn:Lt,toJSON:en,[On]:!0,[he]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Record"})}toString(){let t=this._keys.map((e)=>`${e}: ${te(this.get(e))}`).join(", ");return`${Qs(this)} { ${t} }`}equals(t){return this===t||at(t)&&Kt(this).equals(Kt(t))}hashCode(){return Kt(this).hashCode()}has(t){return Object.hasOwn(this._indices,t)}get(t,e){if(!this.has(t))return e;let r=this._indices[t],s=this._values.get(r);return s===void 0?this._defaultValues[t]:s}set(t,e){if(this.has(t)){let r=this._values.set(this._indices[t],e===this._defaultValues[t]?void 0:e);if(r!==this._values&&!this.__ownerID)return ss(this,r)}return this}remove(t){return this.set(t)}clear(){let t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:ss(this,t)}wasAltered(){return this._values.wasAltered()}toSeq(){return Kt(this)}toJS(){return Ce(this)}entries(){return this.__iterator()}__iterate(t,e){return Kt(this).__iterate(t,e)}__iterator(t){return Kt(this).__iterator(t)}__ensureOwner(t){if(t===this.__ownerID)return this;let e=this._values.__ensureOwner(t);if(!t)return this.__ownerID=t,this._values=e,this;return ss(this,e,t)}}de.isRecord=at;var Qs=(t)=>t.constructor.displayName||t.constructor.name||"Record";class nh extends Tt{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 Kt=(t)=>new nh(t);de.getDescriptiveName=Qs;var ku=ih.prototype;function ss(t,e,r){let s=Object.create(Object.getPrototypeOf(t));return s._values=e,s.__ownerID=r,s}function mu(t,e){Object.defineProperty(t,e,{get(){return this.get(e)},set(r){vt(this.__ownerID,"Cannot set on an immutable record."),this.set(e,r)}})}var on=(t,e,r=1)=>{if(vt(r!==0,"Cannot step a Range by 0"),vt(t!==void 0,"You must define a start value when using Range"),vt(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 Gs(t,e,r,s)};class Gs extends dt{_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(ue(t,e,this.size))return this;if(t=Jt(t,this.size),e=oe(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 L(()=>{if(s===t)return K;return i.value=r,r+=e,s++,i})}keys(){return me(this.size)}equals(t){return t instanceof Gs?this._start===t._start&&this._end===t._end&&this._step===t._step:ds(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}class cs extends dt{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 I(this._value,t)}slice(t,e){let r=this.size;return ue(t,e,r)?this:new cs(this._value,oe(e,r)-Jt(t,r))}reverse(){return this}indexOf(t){if(I(this._value,t))return 0;return-1}lastIndexOf(t){if(I(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 L(()=>{if(r===t)return K;return r++,s.value=e,s})}keys(){return me(this.size)}equals(t){return t instanceof cs?this.size===t.size&&I(this._value,t._value):ds(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var hh=Symbol("BadValue"),fh=(t)=>t;class W{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 Ps{isValid(t){return!0}getMessage(t){return"Invalid"}}class _h extends Ps{}var Nu=new _h;class V extends Ps{constructor(t,e){super();this._isValid=t,this._getMessage=e}isValid(t){return this._isValid(t)}getMessage(t){return this._getMessage(t)}}var Vu=new V((t)=>Number.isInteger(t),()=>"Integer expected"),vu=new V((t)=>Number.isFinite(t),()=>"Float expected"),to=new V((t)=>typeof t==="boolean",()=>"Boolean expected"),eo=new V((t)=>typeof t==="string",()=>"String expected"),ro=new V((t)=>U.isList(t),()=>"List expected"),so=new V((t)=>G.isMap(t),()=>"Map expected"),io=new V((t)=>P.isOrderedMap(t),()=>"OrderedMap expected"),no=new V((t)=>E.isSet(t),()=>"Set expected"),ho=(t)=>!!t;class Cs extends W{constructor(t,e=!1){super("bool",t,to,ho,e)}extendProtoForType(t,e){let{name:r}=this;t[`toggle${e}`]=function(){return this.set(r,!this.get(r,!1))},t[`set${e}`]=function(s){return this.set(r,!!s)}}}class ir extends W{constructor(t,e=null){super("any",t,Nu,fh,e)}toDataDef(){let{defaultValue:t}=this;return{type:Ys(t)??"any",defaultValue:t?.toJS?t.toJS():t}}}var uo=(t)=>t?.toString?.()??"";class xs extends W{constructor(t,e=""){super("text",t,eo,uo,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 oo=(t)=>Number.isFinite(t)?Math.trunc(t):null;class lh extends W{constructor(t,e=0){super("int",t,Vu,oo,e)}}var co=(t)=>null;class Fs extends W{constructor(t,e=0){super("float",t,vu,co,e)}}var Ys=(t)=>t?.constructor?.getMetaClass?.()?.name;class ah{constructor(t){this.typeName=t}isValid(t){return Ys(t)===this.typeName}getMessage(t){let e=Ys(t);return`Expected "${this.typeName}", got "${e}"`}}class yh extends W{constructor(t,e,r){super(t,e,new ah(t),fh,null);this.args=r}toDataDef(){return{component:this.typeName,args:this.args}}}var uh=Symbol("NONE");function Bt(t,e,r){dh(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=U(),fo=(t)=>Array.isArray(t)?U(t):null;class ks extends W{constructor(t,e=gh){super("list",t,ro,fo,e)}extendProtoForType(t,e){let{name:r}=this;Bt(t,r,e),t[`pushIn${e}`]=function(s){return this.set(r,this.get(r).push(s))},t[`insertIn${e}At`]=function(s,i){return this.set(r,this.get(r).insert(s,i))}}}var _o=(t)=>G(t);class ms extends W{constructor(t,e=G()){super("map",t,so,_o,e)}extendProtoForType(t,e){Bt(t,this.name,e)}}var lo=(t)=>P(t);class Ns extends W{constructor(t,e=P()){super("omap",t,io,lo,e)}extendProtoForType(t,e){Bt(t,this.name,e)}}function dh(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=E(),ao=(t)=>Array.isArray(t)?E(t):t instanceof Set?E(t):null;class Vs extends W{constructor(t,e=oh){super("set",t,no,ao,e)}extendProtoForType(t,e){let{name:r}=this;dh(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 ch(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 ph{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]=ch(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]=ch(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]:de(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 nr=new Map,yo={text:xs,int:lh,float:Fs,bool:Cs,list:ks,map:ms,omap:Ns,set:Vs,any:ir};function go(t,{fields:e={},methods:r,statics:s}){let i=new ph(t);for(let n in e){let h=e[n],u=typeof h;if(u==="string")i.addField(n,h,xs);else if(u==="number")i.addField(n,h,Fs);else if(u==="boolean")i.addField(n,h,Cs);else if(U.isList(h)||Array.isArray(h))i.addField(n,U(h),ks);else if(E.isSet(h)||h instanceof Set)i.addField(n,E(h),Vs);else if(P.isOrderedMap(h))i.addField(n,h,Ns);else if(h?.type&&h?.defaultValue!==void 0){let o=yo[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(G.isMap(h)||h?.constructor===Object)i.addField(n,G(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 po=(t)=>new Xr(t.name??"Comp",go(t.name,t),t.view??"Not Defined",t.views,t.style,t.commonStyle??"",t.globalStyle??"",t.computed,t.input,t.logic,t.bubble,t.response,t.alter,t.dynamic,t.on);var wo=["nid","cid","eid","vid","si","sk"];class vs{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??Eo,this.cache=h??new Rr}setNullCache(){this.cache=new Dr}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 wo)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"),c=this.renderMetadata("Comp",{nid:s}),f=this.renderFragment([c,o.render(t,this)]);return this.cache.set(e,h,f),f}renderEach(t,e,r,s){let{seq:i,filter:n,loopWith:h}=e.eval(t),[u,o]=this.getSeqInfo(i),c=[],f=h.call(t.it,i);for(let[_,l]of o(i))if(n.call(t.it,_,l,f)){let a=t.enter(l,{key:_},!0),y=this.renderIt(a,r,_,s);c.push(this.renderMetadata("Each",{nid:r,[u]:_})),c.push(y)}return c}renderEachWhen(t,e,r,s){let{seq:i,filter:n,loopWith:h,enricher:u}=e.eval(t),[o,c]=this.getSeqInfo(i),f=!!u,_=[],l=h.call(t.it,i);for(let[a,y]of c(i))if(n.call(t.it,a,y,l)){let g={key:a,value:y},S=`${s}-${a}`,O;if(f)u.call(t.it,g,a,y,l),O=this.cache.get2(t.it,y,S);else O=this.cache.get(y,S);if(O){_.push(this.renderMetadata("Each",{nid:s,[o]:a})),_.push(O);continue}let bt=t.enter(y,g,!1),Mt=r.render(bt,this);if(_.push(this.renderMetadata("Each",{nid:s,[o]:a})),f)this.cache.set2(t.it,y,S,Mt);else this.cache.set(y,S,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*zo(t){let e=0;for(let r of t)yield[e++,r]}function*So(t){for(let[e,r]of t.toSeq().entries())yield[e,r]}var hr=new Map,Oo=["si",zo],bo=["sk",So],Mo=["si",function*(e){}];function Eo(t){return j(t)?Oo:w(t)?bo:hr.get(t?.constructor)??Mo}class zt{constructor(t=G(),e=U()){this.items=t,this.order=e,this.$=0}_clonish(t,e){return new zt(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 qo=(t)=>null;class wh{isValid(t){return t instanceof zt}getMessage(t){return"KList expected"}}var jo=new wh;class zh extends W{constructor(t,e=new zt){super("KList",t,jo,qo,e)}extendProtoForType(t,e){Bt(t,this.name,e);let{name:r}=this;Bt(t,r,e),t[`pushIn${e}`]=function(s){return this.set(r,this.get(r).push(s))}}}nr.set(zt,zh);function*Io(t){for(let e of t.order)yield[e,t.items.get(e)]}hr.set(zt,["data-sk",Io]);function ti(t){return t[4]==="-"&&(t[0]==="d"||t[0]==="a")}function Sh(t,e){return t[e]}function pe(t,e,r){t[e]=r}function bh(t,e,r){for(let s in e){let i=e[s];if(i===void 0)$o(t,s,r);else if(ti(s))t.setAttribute(s,i);else if(typeof i==="object"&&i!==null)Ko(t,r,s,i);else pe(t,s,i)}}function $o(t,e,r){let s=r[e];if(ti(e))t.removeAttribute(e);else if(typeof s==="string"){pe(t,e,"");let i=e==="className"?"class":e==="htmlFor"?"for":e;t.removeAttribute(i)}else pe(t,e,null)}function Ko(t,e,r,s){let i=e?.[r];if(i&&typeof i==="object"&&Object.getPrototypeOf(i)!==Object.getPrototypeOf(s)){pe(t,r,s);return}let n=Sh(t,r);if(typeof n!=="object"||n===null)pe(t,r,{}),n=Sh(t,r);let h=n;for(let u in s)h[u]=s[u]}class Mh{type;message;constructor(t,e){this.type=t,this.message=e}}class Eh extends Mh{duplicatedKeys;parentTag;parentIndex;constructor(t,e,r){let s=[...t].join(", ");super("DuplicatedKeys",`Duplicate keys found: [${s}] in ${e||"fragment"} at index ${r}. Nodes with duplicated keys are matched positionally.`);this.duplicatedKeys=t,this.parentTag=e,this.parentIndex=r}}class Gt{isEqualTo(t){return this===t}toDom(t){return null}}function qh(t){return t instanceof Qt?t.key:void 0}function St(t,e){let r=qh(t);return r&&e?.has(r)?void 0:r}function Ao(t){return t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function"}function ei(t,e){if(e==null)return;if(Ao(e))for(let r of e)ei(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{text;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 Ht extends Gt{text;constructor(t){super();this.text=t}get nodeType(){return 8}isEqualTo(t){return t instanceof Ht&&this.text===t.text}toDom(t){return t.document.createComment(this.text)}}class v extends Gt{childs;constructor(t){super();let e=[];ei(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{tag;attrs;childs;key;namespace;attrCount;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,this.attrCount=Object.keys(this.attrs).length}get nodeType(){return 1}isEqualTo(t){if(!(t instanceof Qt)||this.tag!==t.tag||this.key!==t.key||this.namespace!==t.namespace||this.attrCount!==t.attrCount||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=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);bh(r,this.attrs,{});for(let s of this.childs){let i=s.toDom(t);if(i)r.appendChild(i)}return r}}function jh(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=jh(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){let r=ur(e);if(r.free.length===e.length)return{children:e,moves:null,duplicatedKeys:r.duplicatedKeys};let s=ur(t),i=r.duplicatedKeys||s.duplicatedKeys?new Set([...r.duplicatedKeys||[],...s.duplicatedKeys||[]]):null;if(s.free.length===t.length)return{children:e,moves:null,duplicatedKeys:i};let n,h,u;if(i){let y=ur(e,i);n=y.keys,h=y.free,u=ur(t,i).keys}else n=r.keys,h=r.free,u=s.keys;let o=[],c=0,f=h.length,_=0;for(let y=0;y<t.length;y++){let g=t[y],S=St(g,i);if(S)if(Object.hasOwn(n,S)){let O=n[S];o.push(e[O])}else _++,o.push(null);else if(c<f){let O=h[c++];o.push(e[O])}else _++,o.push(null)}let l=c>=h.length?e.length:h[c];for(let y=0;y<e.length;y++){let g=e[y],S=St(g,i);if(S){if(!Object.hasOwn(u,S))o.push(g)}else if(y>=l)o.push(g)}let a=Lo(o,e,n,i,_);return{children:o,moves:a,duplicatedKeys:i}}function Lo(t,e,r,s,i){let n=t.slice(),h=0,u=[],o=[],c=Array(e.length);for(let f=0;f<e.length;f++)c[f]=St(e[f],s);for(let f=0;f<e.length;){let _=c[f],l=n[h],a=St(l,s);while(l===null&&n.length)n.splice(h,1),u.push({from:h,key:null}),l=n[h],a=St(l,s);if(l&&a===_){h++,f++;continue}if(_){if(a&&r[a]!==f+1){if(n.splice(h,1),u.push({from:h,key:a}),l=n[h],a=St(l,s),l&&a===_){h++,f++;continue}}o.push({key:_,to:f}),f++;continue}if(a){n.splice(h,1),u.push({from:h,key:a});continue}f++}while(h<n.length){let f=n[h];n.splice(h,1),u.push({from:h,key:St(f,s)})}if(u.length===i&&!o.length)return null;return{removes:u,inserts:o}}function ur(t,e){let r={},s=[],i=null;for(let n=0;n<t.length;n++){let h=qh(t[n]);if(h&&!e?.has(h)){if(h in r)i??=new Set,i.add(h);r[h]=n}else s.push(n)}return{keys:r,free:s,duplicatedKeys:i}}function Do(t,e,r){let s=t.parentNode,i=e.toDom(r);if(s&&i&&i!==t)s.replaceChild(i,t);return i||t}function Ih(t,e,r,s){if(e===r||e.isEqualTo(r))return t;if(e instanceof we&&r instanceof we||e instanceof Ht&&r instanceof Ht)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=jh(e.attrs,r.attrs);if(i)bh(t,i,e.attrs);return Oh(t,e.childs,r.childs,e.tag,s),t}if(e instanceof v&&r instanceof v)return Oh(t,e.childs,r.childs,null,s),t;return Do(t,r,s)}function Oh(t,e,r,s,i){if(e.length===0){for(let l of r){let a=l.toDom(i);if(a)t.appendChild(a)}return}if(r.length===0){while(t.firstChild)t.removeChild(t.firstChild);return}let n=Uo(e,r),h=n.children;if(n.duplicatedKeys&&i.onWarning)i.onWarning(new Eh(n.duplicatedKeys,s,0));let u=Array.from(t.childNodes),o=e.length,c=h.length,f=Math.max(o,c),_=[];for(let l=0;l<f;l++){let a=e[l],y=h[l];if(!a&&y){let g=y.toDom(i);if(g)t.appendChild(g)}else if(a&&y){let g=u[l];if(g)Ih(g,a,y,i)}else if(a&&!y){if(!n.moves&&u[l])_.push(u[l])}}for(let l of _)if(l.parentNode===t)t.removeChild(l);if(n.moves)Ro(t,n.moves)}function Ro(t,e){let r=t.childNodes,s={};for(let n of e.removes){let h=r[n.from];if(n.key)s[n.key]=h;t.removeChild(h)}let i=r.length;for(let n=0;n<e.inserts.length;n++){let h=e.inserts[n],u=s[h.key];if(u)t.insertBefore(u,h.to>=i++?null:r[h.to])}}var or=new WeakMap;function $h(t,e,r){let s=or.get(e),i=t instanceof v;if(s){let h=s.vnode instanceof v;if(h===i){let u=h?e:s.dom,o=Ih(u,s.vnode,t,r);return or.set(e,{vnode:t,dom:i?e:o}),o}or.delete(e)}let n=t.toDom(r);if(n)e.innerHTML="",e.appendChild(n),or.set(e,{vnode:t,dom:i?e:n});return n}function Kh(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(ti(o))i[o]=String(e[o]);else i[o]=e[o];let u=[];return ei(u,r),new Qt(s,i,u,n,h)}var{raw:Fc,raw:kc}=String;function mc(t,e){return new Kr(t,e)}var Wo=(t)=>typeof t==="string"?document.querySelector(t):t;function Nc(t){let e=Wo(t),r=new Xe,s=(o)=>new v(o),i=(o)=>new Ht(o),n={document},h=(o,c)=>$h(o,c,n),u=new vs(r,Kh,s,i,h);return new Fr(e,h,r,u,k)}async function hf(t,e,r="margaui-css"){let s=performance.now(),i=await Jo(t,e),n=performance.now();return kr(r,i),n-s}async function Jo(t,e,r){t.ParseContext=Be,t.compile();let s=new Set(r??[]);for(let i of t.comps.byId.values())for(let n in i.views){let h=i.views[n];for(let u of h.ctx.classes)s.add(u)}return await e(Array.from(s))}var To="RENDER_IT_OUTSIDE_OF_LOOP",Xo="UNKNOWN_EVENT_MODIFIER",Zo="UNKNOWN_HANDLER_ARG_NAME",Bo="INPUT_HANDLER_NOT_IMPLEMENTED",Ho="INPUT_HANDLER_METHOD_NOT_IMPLEMENTED",Qo="INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD",Go="INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER",Yo="FIELD_VAL_NOT_DEFINED",Po="COMPUTED_VAL_NOT_DEFINED",Co="UNKNOWN_REQUEST_NAME",xo="UNKNOWN_COMPONENT_NAME",Fo="warn",Ah="error",ko="hint";function af(t,e=new Uh){rc(e,t),sc(e,t);for(let r in t.views)mo(e,t.views[r],t);return e}function mo(t,e,r){No(t,e),vo(t,e),ec(t,e,r)}function No(t,e){let{nodes:r}=e.ctx;for(let s=0;s<r.length;s++){let i=r[s];if(i instanceof De){let n=r[s+1];if(!(n instanceof We||n instanceof Nt))t.error(To,{node:i})}}}var Vo={};function vo(t,e){for(let r of e.ctx.events)for(let s of r.handlers){let{name:i,modifiers:n}=s,h=Lr[i]??Vo;for(let u of n)if(h[u]===void 0)t.warn(Xo,{name:i,modifier:u,handler:s,event:r})}}function tc(t){switch(t){case"value":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 ec(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 c of o.handlers){let{args:f}=c.handlerCall;for(let _=0;_<f.length;_++){let l=f[_];Ot(t,l,u,h,s,i)}}}function rc(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 c of o.handlers){let{handlerVal:f}=c.handlerCall;if(f instanceof be){if(r[f.name]===void 0){if(t.warn(Bo,{name:f.name,handler:c,event:o}),n[f.name]!==void 0)t.hint(Go,{name:f.name,handler:c,event:o})}}else if(f instanceof Ct){if(n[f.name]===void 0){if(t.warn(Ho,{name:f.name,handler:c,event:o}),r[f.name]!==void 0)t.hint(Qo,{name:f.name,handler:c,event:o})}}}}}function Ot(t,e,r,s,i,n){if(e instanceof qe||e instanceof Ct){let{name:h}=e;if(r[h]===void 0&&s[h]===void 0)t.error(Yo,{val:e,name:h})}else if(e instanceof je){let{name:h}=e;if(i[h]===void 0)t.error(Po,{val:e,name:h})}else if(e instanceof Ie)Ot(t,e.seqVal,r,s,i,n),Ot(t,e.keyVal,r,s,i,n);else if(e instanceof Ee){if(n.lookupRequest(e.name)===null)t.warn(Co,{name:e.name})}else if(e instanceof Me){if(n.lookupComponent(e.name)===null)t.warn(xo,{name:e.name})}else if(e instanceof F&&!tc(e.name))t.warn(Zo,{name:e.name});else if(!(e instanceof J))console.log(e)}function sc(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 c=i[o];for(let f of c.ctx.attrs){let{attrs:_,wrapperAttrs:l,textChild:a}=f;if(_ instanceof Ke){for(let y of _.items)if(y instanceof jt)Ot(t,y.value,u,h,r,s)}if(l!==null)for(let{val:y}of l)Ot(t,y,u,h,r,s);if(a)Ot(t,a,u,h,r,s)}for(let f of c.ctx.nodes)if(f.val)Ot(t,f.val,u,h,r,s)}}class Uh{constructor(){this.reports=[]}error(t,e){this.report(t,e,Ah)}warn(t,e){this.report(t,e,Fo)}hint(t,e){this.report(t,e,ko)}report(t,e={},r=Ah){this.reports.push({id:t,info:e,level:r})}}class ic 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{Nc as tutuca,hr as seqInfoByClass,mc as macro,ve as isOrderedMap,ve as isOMap,fe as isMap,ls as isList,w as isKeyed,j as isIndexed,fe as isIMap,kc as html,nr as fieldsByClass,Fc as css,po as component,Jo as compileClassesToStyleText,hf as compileClassesToStyle,mo as checkView,af as checkComponent,Co as UNKNOWN_REQUEST_NAME,Zo as UNKNOWN_HANDLER_ARG_NAME,Xo as UNKNOWN_EVENT_MODIFIER,xo as UNKNOWN_COMPONENT_NAME,de as Record,To as RENDER_IT_OUTSIDE_OF_LOOP,k as ParseContext,P as OMap,U as List,ic as LintParseContext,Uh as LintContext,Fo as LEVEL_WARN,ko as LEVEL_HINT,Ah as LEVEL_ERROR,zt as KList,E as ISet,Bo as INPUT_HANDLER_NOT_IMPLEMENTED,Ho as INPUT_HANDLER_METHOD_NOT_IMPLEMENTED,Go as INPUT_HANDLER_METHOD_FOR_INPUT_HANDLER,Qo as INPUT_HANDLER_FOR_INPUT_HANDLER_METHOD,G as IMap,Yo as FIELD_VAL_NOT_DEFINED,Po as COMPUTED_VAL_NOT_DEFINED};
|
package/dist/tutuca-extra.js
CHANGED
|
@@ -8038,10 +8038,10 @@ async function compileClassesToStyle(app, compileClasses, styleId = "margaui-css
|
|
|
8038
8038
|
injectCss(styleId, css2);
|
|
8039
8039
|
return t2 - t1;
|
|
8040
8040
|
}
|
|
8041
|
-
async function compileClassesToStyleText(app, compileClasses) {
|
|
8041
|
+
async function compileClassesToStyleText(app, compileClasses, extraCSSClasses) {
|
|
8042
8042
|
app.ParseContext = ParseCtxClassSetCollector;
|
|
8043
8043
|
app.compile();
|
|
8044
|
-
const classes = new Set;
|
|
8044
|
+
const classes = new Set(extraCSSClasses ?? []);
|
|
8045
8045
|
for (const Comp of app.comps.byId.values()) {
|
|
8046
8046
|
for (const key in Comp.views) {
|
|
8047
8047
|
const view = Comp.views[key];
|
package/dist/tutuca-extra.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
class xt{lookup(t,e=null){return e}setValue(t,e){return t}updateBindings(t,e){}isFrame=!0}class Mt extends xt{constructor(t){super();this.binds=t}lookup(t,e){return t}setValue(t,e){return e}withIndex(t){return new Mt({...this.binds,key:t})}withKey(t){return new Mt({...this.binds,key:t})}updateBindings(t,e){Object.assign(e,this.binds)}isFrame=!1}class ye extends xt{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 ve(this.field,t)}withKey(t){return new Ve(this.field,t)}}class Ne extends xt{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 Ve extends Ne{}class ve extends Ne{}var D=Symbol("NONE");class tr extends xt{constructor(t,e){super();this.seqField=t,this.keyField=e}lookup(t,e=null){let r=t?.get(this.seqField,D),s=t?.get(this.keyField,D);return s!==D&&r?.get?r.get(s,e):e}setValue(t,e){let r=t?.get(this.seqField,D),s=t?.get(this.keyField,D);return r===D||s===D?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,D),r===D)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,D),s===D)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,D),r===D)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=[],c=null,f=[],_=!0;while(t&&t!==r&&u<s){if(t?.dataset){let{nid:l,si:a,sk:d}=Ys(t.previousSibling),{eid:y,cid:S,vid:O}=t.dataset;if(y!==void 0)o.push(y);if(S!==void 0){let Ot=i.getComponentForId(+S,O);if(_){if(c=Ah(Ot,o,O,e),c===null&&n)return Kh;_=!1}let bt=$h(Ot,f,O);if(bt)h.push(bt);o=[],f=[]}if(l!==void 0)f.push({nid:l,si:a,sk:d})}u+=1,t=t.parentNode}return[new V(h.reverse()),c]}static fromEvent(t,e,r,s,i=!0){let{type:n,target:h}=t;return V.fromNodeAndEventName(h,n,e,r,s,i)}}var Gs={};function Ys(t){if(t?.nodeType===8&&t.textContent[0]==="§"){let e=Ys(t.previousSibling);if(e!==Gs)return e;try{return JSON.parse(t.textContent.slice(1,-1))}catch(r){console.warn(r,t)}}return Gs}function Ah(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 $h(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],c=i.pathInNext?t.getNodeForId(+o,r).val.toPathItem():i.toPathItem();if(c!==null)return h!==void 0?c.withIndex(+h):u?c.withKey(u):c}return null}var Kh=[null,null];class er{constructor(){this.pathChanges=[]}add(t){return this.pathChanges.push(t),this}field(t){return this.add(new ye(t))}index(t,e){return this.add(new ve(t,e))}key(t,e){return this.add(new Ve(t,e))}}var Uh=/^[a-zA-Z][a-zA-Z0-9_]*$/,nt=(t)=>Uh.test(t),Lh=/^-?[0-9]+(\.[0-9]+)?$/,Cs=(t,e)=>sr.parse(t,e),Qt=(t,e)=>new Q(t),Dh=(t,e)=>nt(t)?new ht(t):null,Rh=(t,e)=>nt(t)?new Ns(t):null,Wh=(t,e)=>nt(t)?new nr(t):null,Th=(t,e)=>nt(t)?new ti(t):null,Jh=(t,e)=>nt(t)?new ei(t):null,Xh=(t,e)=>nt(t)?new ri(t):null,Hh=(t,e)=>nt(t)?new Vs(t):null;class Ps{constructor(){this.allowFieldOnly(),this.bindValIt=new nr("it"),this.nullConstVal=new Q(null)}const(t){return new Q(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 si(s,i):null}parse(t,e){switch(Zh(t)){case ii:return this.parseIfOk(t,e,this.okStrTpl,Cs);case hi:return this.parseIfOk(t,e,this.okStrTpl,Qt);case ni:return this._parseSeqAccess(t,e);case pe:return this.parseIfOk(t,e,this.okStrTpl,Cs)}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,Qt);case 39:return this.parseIfOk(t.slice(1,-1),e,this.okStrTpl,Qt);case 64:return this.parseIfOk(t.slice(1),e,this.okBind,Wh);case 42:return this.parseIfOk(t.slice(1),e,this.okDyn,Th);case 46:return this.parseIfOk(t.slice(1),e,this.okField,Jh);case 36:return this.parseIfOk(t.slice(1),e,this.okComputed,Xh);case 33:return this.parseIfOk(t.slice(1),e,this.okRequest,Hh)}let s=Lh.test(t)?parseFloat(t):null;if(Number.isFinite(s))return this.parseIfOk(s,e,this.okConst,Qt);else if(t==="true"||t==="false")return this.parseIfOk(t==="true",e,this.okConst,Qt);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,Rh);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.toRawFieldVal?s.toRawFieldVal():new r(s.name)}parseHandlerName(t,e){return this._parseHandler(t,e,Fs)}parseAlter(t,e){return this._parseHandler(t,e,ms)}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 ge{render(t,e){}eval(t){}toPathItem(){return null}}class Q extends ge{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 rr extends ge{}class sr extends rr{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)==="}"?g.parseText(h.slice(1,-1),e):new Q(h);s[n]=o,i&&=o instanceof Q}return i?new Q(s.map((n)=>n.value).join("")):new sr(s)}}class ht extends rr{constructor(t){super();this.name=t}eval(t){return t.lookupName(this.name)}toString(){return this.name}}class Fs extends ht{eval(t){return t.getInputHandler(this.name)??ks("input",this.name)}}class ms extends ht{eval(t){return t.getAlterHandler(this.name)??ks("alter",this.name)}}var ks=(t,e)=>function(...r){return console.warn("handler not found",{type:t,name:e,args:r},this),this};class Ns extends ht{eval(t){return t.lookupType(this.name)}}class Vs extends ht{eval(t){return t.lookupRequest(this.name)}toString(){return`!${this.name}`}}class vs extends ht{eval(t){return t.lookupFieldRaw(this.name)}toString(){return`.${this.name}`}}class ir extends ge{render(t,e){return this.eval(t)}}class Gt extends ir{constructor(t){super();this.name=t}}class nr extends Gt{eval(t){return t.lookupBind(this.name)}toString(){return`@${this.name}`}}class ti extends Gt{eval(t){return t.lookupDynamic(this.name)}toPathItem(){return null}toString(){return`*${this.name}`}}class ei extends Gt{eval(t){return t.lookupField(this.name)}toPathItem(){return new ye(this.name)}toRawFieldVal(){return new vs(this.name)}toString(){return`.${this.name}`}}class ri extends Gt{eval(t){return t.lookupComputed(this.name)}toString(){return`$${this.name}`}}class si extends ir{constructor(t,e){super();this.seqVal=t,this.keyVal=e}toPathItem(){return new tr(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 ii=0,ni=1,pe=2,hi=3;function Zh(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 ii;case 125:return hi}if(e>0||r>0)return e===1&&r===1?ni:pe;return-1}var g=new Ps;class Et{constructor(t){this.items=t}eval(t){return{}}static parse(t,e,r=!1){return cr(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",xh=new Set(Bh.split(","));class ui{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?g.parseAll(e,this.px):g.parseAttr(e,this.px);if(s!==null)this.attrs??=[],this.attrs.push(new ze(t,s)),this.hasDynamic||=!(s instanceof Q)}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=g.parseCondValue(e,this.px);if(r)this.ifAttr=new fi(t.slice(3),r),this.attrs??=[],this.attrs.push(this.ifAttr),this.hasDynamic=!0}parseThen(t){if(this.ifAttr)this.ifAttr.thenVal=g.parseAttr(t,this.px)??Yt}parseElse(t){if(this.ifAttr)this.ifAttr.elseVal=g.parseAttr(t,this.px)??Yt}parseEvent(t,e){let[r,...s]=t.slice(3).split("+"),i=fr.parse(e,this.px);if(i){if(this.events===null)this.events=this.px.registerEvents(),this.attrs??=[],this.attrs.push(new we("data-eid",g.const(this.events.id)));this.events.add(r,i,s)}}parseDirective(t,e){switch(e){case"dangerouslysetinnerhtml":this.attrs??=[],this.attrs.push(new ci(g.parseText(t,this.px))),this.hasDynamic=!0;return;case"slot":this.pushWrapper("slot",t,g.const(t));return;case"push-view":this.pushWrapper("push-view",t,g.parseText(t,this.px));return;case"text":this.textChild=g.parseText(t,this.px)??g.const("");return;case"show":this.pushWrapper("show",t,g.parseCondValue(t,this.px));return;case"hide":this.pushWrapper("hide",t,g.parseCondValue(t,this.px));return;case"each":this.eachAttr=this.pushWrapper("each",t,g.parseEach(t,this.px));return;case"enrich-with":if(this.eachAttr!==null)this.eachAttr.enrichWithVal=g.parseAlter(t,this.px);else this.pushWrapper("scope",t,g.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=g.parseAlter(t,this.px)}_parseLoopWith(t){if(this.eachAttr!==null)this.eachAttr.loopWithVal=g.parseAlter(t,this.px)}parse(t,e=!1){for(let{name:n,value:h}of t){let u=n.charCodeAt(0);if(u===58)this.parseAttr(n===":viewbox"?"viewBox":n.slice(1),h,e);else if(u===64)this.parseDirective(h,n.slice(1));else{this.attrs??=[];let o=h===""&&xh.has(n)?!0:h;this.attrs.push(new we(n,g.const(o)))}}let{attrs:r,hasDynamic:s}=this;return[s?new oi(r):ur.fromAttrs(r??[]),this.wrapperAttrs,this.textChild]}}class ur extends Et{eval(t){return this.items}static fromAttrs(t){let e={};for(let r of t)e[r.name]=r.value.eval(null);return new ur(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 oi extends Et{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 we(t,new Q(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 ze extends or{constructor(t,e){super(t);this.value=e}eval(t){return this.value.eval(t)}}class we extends ze{}class ci extends ze{constructor(t){super("dangerouslySetInnerHTML",t??g.nullConstVal)}eval(t){return{__html:`${this.value.eval(t)}`}}}var Yt=g.nullConstVal;class fi extends or{constructor(t,e){super(t);this.condVal=e,this.thenVal=this.elseVal=Yt}get anyBranchIsSet(){return this.thenVal!==Yt||this.elseVal!==Yt}eval(t){return this.condVal.eval(t)?this.thenVal.eval(t):this.elseVal.eval(t)}}var hr=null;function cr(t){return hr??=new ui(t),hr.clear(t),hr}class fr{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=g.parseHandlerName(r,e);if(i===null)return null;let n=Array(s.length);g.allowHandlerArg();for(let h=0;h<s.length;h++){let u=g.parse(s[h],e);n[h]=u!==null?u:g.nullConstVal}return new fr(i,n)}}class _r{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 qt{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 Pt extends qt{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 Ct extends Pt{render(t,e){return e.renderComment(this.v)}}function Qh(t){for(let e=0;e<t.length;e++){let r=t[e];if(r.isConstant())t[e]=new zr(r);else r.optimize()}}function yr(t){if(t.isConstant())return new zr(t);return t.optimize(),t}class pr extends qt{constructor(t){super();this.childs=t}isConstant(){return this.childs.every((t)=>t.isConstant())}optimize(){Qh(this.childs)}}class Se extends pr{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 Oe extends pr{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 lr=(t)=>t.length===1?t[0]:new Oe(t),Gh=/^[a-zA-Z][a-zA-Z0-9-]*$/,_i=null;class v extends qt{constructor(t,e){super();this.nodeId=t,this.val=e}toPathItem(){return this.val.toPathItem()}static parse(t,e){_i??=e.newDOMParser();let r=_i.parseFromString(t,"text/html").body.childNodes;return v.fromDOM(r[0]??new e.Text(""),e)}static fromDOM(t,e){if(e.isTextNode(t))return new Pt(t.textContent);else if(e.isCommentNode(t))return new Ct(t.textContent);let{childNodes:r,attributes:s,tagName:i}=t,n=Array(r.length);for(let h=0;h<r.length;h++)n[h]=v.fromDOM(r[h],e);if(i==="X"){if(s.length===0)return lr(n);let{name:h,value:u}=s[0],o=s.getNamedItem("as")?.value??null;switch(h){case"slot":return new Me(null,g.const(u),lr(n));case"text":return new dr(null,g.parseText(u,e)??g.const(""));case"render":return e.addNodeIf(wi,g.parseRender(u,e),o);case"render-it":return e.addNodeIf(zi,g.bindValIt,o);case"render-each":return wr.parse(e,g,u,o,s)}return new Ct(`Error: InvalidSpecialTagOp ${h}=${u}`)}else if(i.charCodeAt(1)===58&&i.charCodeAt(0)===88){let h=i.slice(2).toLowerCase();if(h==="slot"){let c=s.getNamedItem("name")?.value??"_";return e.frame.macroSlots[c]??lr(n)}let[u,o]=Et.parse(s,e,!0);return e.onAttributes(u,o,null),li(e.newMacroNode(h,u.toMacroVars(),n),e,o)}else if(Gh.test(i)){let[h,u,o]=Et.parse(s,e);if(e.onAttributes(h,u,o),o)n.unshift(new dr(null,o));let c=i!=="PRE"?mh(n):n;return li(new Se(i.toLowerCase(),h,c),e,u)}return new Ct(`Error: InvalidTagName ${i}`)}}function li(t,e,r){if(r)for(let s=r.length-1;s>=0;s--){let i=Yh(r[s],e);if(i)i.wrapNode(t),t=i}return t}function Yh(t,e){let r=Fh[t.name],s=r.register?e.addNodeIf(r,t.val):new r(null,t.val);if(t.name==="each")s.iterInfo.enrichWithVal=t.enrichWithVal??null,s.iterInfo.whenVal=t.whenVal??null,s.iterInfo.loopWithVal=t.loopWithVal??null;return s}class gi extends qt{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 Ct(`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=yr(this.node)}}class gr{constructor(t,e){this.defaults=t,this.rawView=e}expand(t){return v.parse(this.rawView,t)}}class be extends v{constructor(t,e,r){super(t,e);this.viewId=r}}class wi extends be{render(t,e){let r=t.enter(this.val.eval(t),{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}}class zi extends be{render(t,e){return e.renderIt(t,this.nodeId,"",this.viewId)}pathInNext=!0}class wr extends be{constructor(t,e,r){super(t,e,r);this.iterInfo=new Sr(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(wr,e.parseEach(r,t),s);if(n!==null){let h=cr(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 dr extends v{render(t,e){return e.renderText(this.val.eval(t))}}class zr extends qt{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 ut extends v{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=yr(this.node)}static register=!1}class Si extends ut{render(t,e){return this.val.eval(t)?this.node.render(t,e):e.renderEmpty()}}class Oi extends ut{render(t,e){return this.val.eval(t)?e.renderEmpty():this.node.render(t,e)}}class bi extends ut{render(t,e){return this.node.render(t.pushViewName(this.val.eval(t)),e)}}class Me extends ut{optimize(){this.node.optimize()}}class Mi extends ut{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 Mt({})}wrapNode(t){this.node=t,this.node.setDataAttr("data-nid",this.nodeId)}static register=!0}class Ei extends ut{constructor(t,e){super(t,e);this.iterInfo=new Sr(e,null,null,null)}render(t,e){return e.renderEachWhen(t,this.iterInfo,this.node,this.nodeId)}toPathItem(){return new Mt({})}static register=!0}class Sr{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)??Ph,i=this.enrichWithVal?.eval(t)??null;return{seq:e,filter:r,loopWith:s,enricher:i}}}var Ch=(t,e,r)=>!0,Ph=(t)=>({seq:t}),Fh={slot:Me,show:Si,hide:Oi,each:Ei,scope:Mi,"push-view":bi};class ot{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 ot(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 qi(t);return this.events.push(e),e}newMacroNode(t,e,r){let s=[],i={_:new Oe(s)};for(let h of r)if(h instanceof Me)i[h.val.value]=h.node;else if(!(h instanceof Pt)||!h.isWhiteSpace())s.push(h);let n=new gi(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 ar=(t)=>t instanceof Pt&&t.isWhiteSpace(),ai=(t)=>t instanceof Se||t instanceof Oe&&t.childs[0]instanceof Se;function mh(t){let e=t.length;if(e===0)return t;let r=0,s=!1;if(ar(t[0]))r=1,s=!0;if(e>1&&ar(t[e-1]))e-=1,s=!0;for(let i=1;i<e-1;i++){let n=t[i];if(ar(n)&&ai(t[i-1])&&ai(t[i+1])&&n.hasNewLine())n.condenseWhiteSpace()}return s?t.slice(r,e):t}class Ee{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=v.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=yr(this.anode)}render(t,e){return this.anode.render(t,e)}}class qi{constructor(t){this.id=t,this.handlers=[]}add(t,e,r){this.handlers.push(new ji(t,e,r))}*genEventNames(){for(let t of this.handlers)yield t.name}getHandlersFor(t){let e=null;for(let r of this.handlers)if(r.handlesEventName(t))e??=[],e.push(r);return e}}class ji{constructor(t,e,r){this.name=t,this.handlerCall=e,this.modifierWrapper=eu(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 kh=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),qe=(t)=>(e)=>(r,s,i,n)=>t(n)?e(r,s,i,n):r,di=(t)=>qe((e)=>e.e.key===t),yi=qe(({e:t})=>kh&&t.metaKey||t.ctrlKey),Nh=qe(({e:t})=>t.metaKey),Vh=qe(({e:t})=>t.altKey),pi={ctrl:yi,cmd:yi,meta:Nh,alt:Vh},vh={keydown:{send:di("Enter"),cancel:di("Escape"),...pi},click:{...pi}},tu=(t,e)=>t;function eu(t,e){if(e.length===0)return tu;let r=vh[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 Or{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 br{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 Mr{getKey(t,e,r){return r.call(t)}}class Er{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 je{constructor(){this.getComponentSymbol=Symbol("getComponent"),this.byId=new Map,this.computedCache=new Er}setNullComputedCache(){this.computedCache=new Mr}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
2
|
`)}}class Ie{constructor(t=new je,e=null){this.comps=t,this.parent=e,this.byName={},this.reqsByName={},this.macros={}}enter(){return new Ie(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 _r(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 qr{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 Ii extends qr{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 jt=(t)=>typeof t==="string",ru=0;class jr{constructor(t,e,r,s={},i="",n="",h="",u={},o={},c={},f={},_={},l={},a={},d={}){this.id=ru++,this.name=t,this.Class=e,this.views={main:new Ee("main",r,i)},this.commonStyle=n,this.globalStyle=h,this.computed=u,this.input=o,this.logic=c,this.bubble=f,this.response=_,this.alter=l,this.on={stackEnter:d?.stackEnter??Ai};for(let y in s){let S=s[y],{view:O,style:Ot}=jt(S)?{view:S}:S;this.views[y]=new Ee(y,O,Ot)}this._rawDynamic=a,this.dynamic={},this.scope=null}compile(t){for(let e in this._rawDynamic){let r=this._rawDynamic[e];if(jt(r)){let s=g.parseDynamic(r,this.views.main.ctx);this.dynamic[e]=new qr(e,s,Symbol(e))}else if(jt(r?.default)&&jt(r?.for)){let s=g.parseDynamic(r.default,this.views.main.ctx),[i,n]=r.for.split(".");if(jt(i)&&jt(n))this.dynamic[e]=new Ii(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 Ai(t){return t}var $i=Symbol("STOP"),$r=Symbol("NEXT");class Ft{constructor(t,e){this.head=t,this.tail=e}push(t){return new Ft(t,this)}lookup(t,e=null){let{tail:r}=this,s=this.head.lookup(t);return s===$i?e:s===$r?r!==null?r.lookup(t,e):e:s}*[Symbol.iterator](){let t=this;while(t!==null)yield t.head,t=t.tail}}class Ir{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?$i:$r:e}}class Ar{constructor(t){this.bindings=t}lookup(t){let e=this.bindings[t];return e===void 0?$r:e}}class J{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 J(t,e.tail.head.it,e.tail,r,s,i)}static root(t,e,r){let s=new Ft(new Ir(e,{it:e},!0),null),i=new Ft(new Ar({}),null),n=new Ft("main",null);return new J(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 Ir(t,e,r));return new J(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 J(e,r,s,i,n.push(t),h)}withDynamicBindings(t){let e={},r=this.comps.getCompFor(this.it);for(let c of t)r.dynamic[c].evalAndBind(this,e);let{comps:s,it:i,binds:n,views:h,ctx:u}=this,o=this.dynBinds.push(new Ar(e));return new J(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){return this.comps.lookupComputed(this.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 Ki{constructor(t){this.value=t,this.changeSubs=[]}onChange(t){this.changeSubs.push(t)}set(t,e){let r=this.value;this.value=t;for(let s of this.changeSubs)s({value:t,old:r,info:e,timestamp:Date.now()})}update(t,e){return this.set(t(this.value),e)}}class Kr{constructor(t,e){this.comps=t,this.transactions=[],this.state=new Ki(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 Dr(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)??su(e),o=s?.onResName??e,c=(f,_,l,a,d)=>{let S=new Li(t,this,f??_,f?[l]:[a,d],i);return this.pushTransaction(S)};try{let f=await u.fn.apply(null,r);return c(s?.onOkName,o,f,f,null)}catch(f){return c(s?.onErrorName,o,f,null,f)}}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 Ui(t,e,r,this,s))}}function su(t){return()=>{throw Error(`Request not found: ${t}`)}}function iu(){return this}class Ur{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 J.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 nu=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac");function hu(t){return t.target.type==="checkbox"?t.target.checked:(t instanceof CustomEvent?t.detail:t.target.value)??null}class Ui extends Ur{constructor(t,e,r,s,i){super(t,s);this.e=e,this.handler=r,this.dragInfo=i}buildRootStack(t,e){return J.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 Rr(this.path,this.transactor,this),n[u]=n[u].toHandlerArg(h);return[i,n]}lookupName(t){let{e}=this;switch(t){case"value":return hu(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 nu&&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 Wr(this.path,this.transactor,this);case"dragInfo":return this.dragInfo}return null}}class Lr extends Ur{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]??iu}getHandlerAndArgs(t,e,r){return[this.getHandlerForName(r.getCompFor(e)),[...this.args,new Wr(this.path,this.transactor,this)]]}}class Li extends Lr{handlerProp="response"}class Dr extends Lr{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 Dr{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 Rr{constructor(t,e,r=null){this.path=t,this.transactor=e,this.parent=r}get at(){return new Wi(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 Wr extends Rr{stopPropagation(){return this.parent.stopPropagation()}}class Wi extends er{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 Tr{constructor(t,e,r,s,i){this.rootNode=t,this.comps=r,this.compStack=new Ie(r),this.transactor=new Kr(r,null),this.ParseContext=i,this.renderer=s,this.renderFn=e,this.maxEventNodeDepth=1/0,this._transactNextBatchId=this._evictCacheId=null,this._eventNames=new Set(["dragstart","dragover","dragend"]),this.dragInfo=this.curDragOver=null,this.transactor.onTransactionPushed=(n)=>{if(this._transactNextBatchId===null)this._scheduleNextTransactionBatchExecution()},this._compiled=!1}get state(){return this.transactor.state}handleEvent(t){let e=t.type==="dragstart",r=t.type==="dragover",s=t.type==="dragend",{rootNode:i,maxEventNodeDepth:n,comps:h}=this,u=!(r||e||s),[o,c]=V.fromEvent(t,i,n,h,u);if(r){let f=uu(t.target,this.rootNode,50);if(f!==null)t.preventDefault(),this._cleanDragOverAttrs(),this.curDragOver=f,f.dataset.draggingover=this.dragInfo.type}else if(e){t.target.dataset.dragging=1;let f=this.state.value,_=o.lookup(f),l=t.target.dataset.dragtype??"?",a=o.buildStack(this.makeStack(f));this.dragInfo=new Ti(o,a,t,_,l,t.target)}else if(s)delete this.dragInfo.node.dataset.dragging,this.dragInfo=null,this._cleanDragOverAttrs();if(o!==null&&c!==null)for(let f of c)this.transactor.transactInputNow(o,t,f,this.dragInfo)}makeStack(t){return J.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()}),Jr("tutuca-app",this.comps.compileStyles()),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 Jr(t,e){let r=document.createElement("style"),s=document.head.querySelector(`#${t}`);if(s)document.head.removeChild(s);r.id=t,r.innerHTML=e,document.head.appendChild(r)}function uu(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 Ti{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 Ae extends ot{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,f=new Ae(s,i,n,h,u,o,{macroName:t,macroVars:e,macroSlots:r},this);return f.classes=this.classes,f}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),h)this._addClasses(h.value)}else if(typeof i?.value==="string")this._addClasses(i.value)}else{let s=t.items.class;if(s)this._addClasses(s)}}}function mt(t,e){if(!t)throw Error(e)}function A(t){mt(t!==1/0,"Cannot perform this action with an infinite size.")}function Ji(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 ou=(t,e)=>e,cu=(t,e)=>[e,t],Xr=(t)=>function(...e){return!t.apply(this,e)},Xi=(t)=>function(...e){return-t.apply(this,e)};function un(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 Hi=(t,e)=>t<e?1:t>e?-1:0,$={done:!0,value:void 0};class on{constructor(t){this.next=t}[Symbol.iterator](){return this}}function L(t){return new on(t)}function M(t){let e=[void 0,void 0],r={done:!1,value:void 0};return L(()=>{if(t(e))return r.value=[e[0],e[1]],r;return $})}var fu=L(()=>$),ct=()=>fu;function Xe(t){let e=0,r={done:!1,value:void 0};return L(()=>{if(e===t)return $;return r.value=e++,r})}function ee(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 cn(t){if(Array.isArray(t))return!0;return!!He(t)}var _u=(t)=>!!(t&&typeof t.next==="function");function fn(t){return He(t)?.call(t)}function He(t){let e=t&&t[Symbol.iterator];if(typeof e==="function")return e}function lu(t){let e=He(t);return e&&e===t.entries}function au(t){let e=He(t);return e&&e===t.keys}var re="delete",z=5,q=1<<z,K=q-1,p={},Cr=()=>({value:!1});function T(t){if(t)t.value=!0}class Ze{}function At(t){if(t.size===void 0)t.size=t.__iterate(_n);return t.size}function et(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 _n=()=>!0,ln=(t)=>t<0||Object.is(t,-0),se=(t,e,r)=>(t===0&&!ln(t)||r!==void 0&&(t??0)<=-r)&&(e===void 0||r!==void 0&&e>=r),an=(t,e,r)=>t===void 0?r:ln(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)=>an(t,e,0),ie=(t,e)=>an(t,e,e),dn="@@__IMMUTABLE_ITERABLE__@@",Le="@@__IMMUTABLE_KEYED__@@",De="@@__IMMUTABLE_INDEXED__@@",rt="@@__IMMUTABLE_ORDERED__@@",ne="@@__IMMUTABLE_SEQ__@@",yn="@@__IMMUTABLE_LIST__@@",pn="@@__IMMUTABLE_MAP__@@",gn="@@__IMMUTABLE_SET__@@",wn="@@__IMMUTABLE_STACK__@@",zn="@@__IMMUTABLE_RECORD__@@";function C(t,e){return typeof t==="object"&&t!==null&&e in t}var R=(t)=>C(t,dn),w=(t)=>C(t,Le),j=(t)=>C(t,De),Vr=(t)=>w(t)||j(t),F=(t)=>C(t,rt),vr=(t)=>C(t,ne),ts=(t)=>C(t,yn),he=(t)=>C(t,pn),es=(t)=>C(t,gn),rs=(t)=>C(t,wn),at=(t)=>C(t,zn),P=(t)=>R(t)||at(t),Be=(t)=>he(t)&&F(t),Sn=(t)=>es(t)&&F(t),Zi=(t)=>typeof t==="object"&&t!==null&&typeof t.equals==="function"&&typeof t.hashCode==="function";function On(t){let e=G(t);return e._iter=t,e.size=t.size,e.flip=()=>t,e.reverse=function(){let r=t.reverse.call(this);return r.flip=()=>t.reverse(),r},e.has=(r)=>t.includes(r),e.includes=(r)=>t.has(r),e.cacheResult=Tt,e.__iterate=function(r,s){return t.__iterate((i,n)=>r(n,i,this),s)},e.__iteratorUncached=function(r){return ee(t.__iterator(r),(s,i,n)=>{n[0]=i,n[1]=s})},e}function bn(t,e,r){let s=G(t);return s.size=t.size,s.has=(i)=>t.has(i),s.get=(i,n)=>{let h=t.get(i,p);return h===p?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 ee(t.__iterator(i),(n,h,u)=>{u[0]=n,u[1]=e.call(r,h,n,t)})},s}function Mn(t,e){let r=G(t);if(r._iter=t,r.size=t.size,r.reverse=()=>t,t.flip)r.flip=function(){let s=On(t);return s.reverse=()=>t.flip(),s};return r.get=(s,i)=>t.get(e?s:-1-s,i),r.has=(s)=>t.has(e?s:-1-s),r.includes=(s)=>t.includes(s),r.cacheResult=Tt,r.__iterate=function(s,i){let n=0;if(i)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 ee(t.__iterator(!s),(h,u,o)=>{o[0]=e?h:s?n-++i:i++,o[1]=u})},r}function En(t,e,r,s){let i=t.size;if(se(e,r,i))return t;if(i===void 0&&(e<0||r<0))return En(t.toSeq().cacheResult(),e,r,s);let n=Rt(e,i),u=ie(r,i)-n,o;if(!Number.isNaN(u))o=Math.max(0,u);let c=G(t);if(c.size=o===0?o:t.size&&o||void 0,!s&&vr(t)&&o>=0)c.get=function(f,_){return f=et(this,f),f>=0&&f<o?t.get(f+n,_):_};return c.__iterateUncached=function(f,_){if(o!==0&&_)return this.cacheResult().__iterate(f,_);if(o===0)return 0;let l=0,a=0;return t.__iterate((d,y)=>{if(l<n){l++;return}if(o!==void 0&&a>=o)return!1;if(a++,f(d,s?y:a-1,this)===!1)return!1},_),a},c.__iteratorUncached=function(f){if(o!==0&&f)return this.cacheResult().__iterator(f);if(o===0)return ct();let _=t.__iterator(f),l=0,a=0;if(s)return L(()=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return $;let d=_.next();if(d.done)return d;return a++,d});return M((d)=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return!1;let y=_.next();if(y.done)return!1;return a++,d[0]=a-1,d[1]=y.value[1],!0})},c}function Bi(t,e,r){if(!e)e=un;let s=w(t),i=0,n=t.toSeq().map((h,u)=>[u,h,i++,r?r(h,u,t):h]).valueSeq().toArray();return n.sort((h,u)=>e(h[3],u[3])||h[2]-u[2]).forEach(s?(h,u)=>{n[u].length=2}:(h,u)=>{n[u]=h[1]}),s?us(n):j(t)?lt(n):Nt(n)}function $e(t,e,r){if(!e)e=un;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 Hr(t,e,r,s){let i=G(t),n=new ue(r).map((h)=>h.size);return i.size=s?n.max():n.min(),i.__iterate=function(h,u){let o=this.__iterator(u),c=0,f;while(!(f=o.next()).done)if(h(f.value[1],c++,this)===!1)break;return c},i.__iteratorUncached=function(h){let u=r.map((_)=>{let l=m(_);return fn(h?l.reverse():l)}),o=0,c=Array(u.length),f=Array(u.length);return M((_)=>{let l=s;for(let a=0;a<u.length;a++)c[a]=u[a].next(),l=s?l&&c[a].done:l||c[a].done;if(l)return!1;for(let a=0;a<c.length;a++)f[a]=c[a].value;return _[0]=o++,_[1]=e(...f),!0})},i}function qn(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 du(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 st=(t)=>typeof t==="object"&&(P(t)||Array.isArray(t)||du(t));function jn(t){if(qn(t)&&typeof t!=="string")return t;if(F(t))return t.toArray();throw TypeError(`Invalid keyPath: expected Ordered Collection or Array: ${t}`)}var yu=(t,e)=>P(t)?t.has(e):st(t)&&Object.hasOwn(t,e);function In(t,e,r){return P(t)?t.get(e,r):!yu(t,e)?r:typeof t.get==="function"?t.get(e):t[e]}function ss(t,e,r){let s=jn(e),i=0;while(i!==s.length)if(t=In(t,s[i++],p),t===p)return r;return t}var An=(t,e)=>ss(t,e,p)!==p;function I(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!!(Zi(t)&&Zi(e)&&t.equals(e))}function Re(t){if(!t||typeof t!=="object")return t;if(!R(t)){if(!st(t))return t;t=it(t)}if(w(t)){let r={};return t.__iterate((s,i)=>{r[String(i)]=Re(s)}),r}let e=[];return t.__iterate((r)=>{e.push(Re(r))}),e}function is(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||w(t)!==w(e)||j(t)!==j(e)||F(t)!==F(e))return!1;if(t.size===0&&e.size===0)return!0;let r=!Vr(t);if(F(t)){let h=t.entries();return!!(e.every((u,o)=>{let c=h.next().value;return c&&I(c[1],u)&&(r||I(c[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?!I(h,t.get(u,p)):!I(t.get(u,p),h))return i=!1,!1;return!0});return i&&t.size===n}var xe=(t)=>t>>>1&1073741824|t&3221225471;function X(t){if(t===null||t===void 0)return Qi(t);if(typeof t.hashCode==="function")return xe(t.hashCode(t));let e=Su(t);if(e===null||e===void 0)return Qi(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return pu(e);case"string":return e.length>Ou?gu(e):Pr(e);case"object":case"function":return zu(e);case"symbol":return wu(e);default:if(typeof e.toString==="function")return Pr(e.toString());throw Error(`Value type ${typeof e} cannot be hashed.`)}}var Qi=(t)=>t===null?1108378658:1108378659;function pu(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 xe(e)}function gu(t){let e=xr[t];if(e===void 0){if(e=Pr(t),Br===bu)Br=0,xr={};Br++,xr[t]=e}return e}function Pr(t){let e=0;for(let r=0;r<t.length;r++)e=31*e+t.charCodeAt(r)|0;return xe(e)}function wu(t){let e=Yi[t];if(e!==void 0)return e;return e=$n(),Yi[t]=e,e}function zu(t){let e=Gi.get(t);if(e!==void 0)return e;return e=$n(),Gi.set(t,e),e}var Su=(t)=>t.valueOf!==Object.prototype.valueOf?t.valueOf():t;function $n(){let t=++Zr;if(Zr&1073741824)Zr=0;return t}var Gi=new WeakMap,Yi=Object.create(null),Zr=0,Ou=16,bu=255,Br=0,xr={};function Mu(t){if(t.size===1/0)return 0;let e=F(t),r=w(t),s=e?1:0;return t.__iterate(r?e?(i,n)=>{s=31*s+Ci(X(i),X(n))|0}:(i,n)=>{s=s+Ci(X(i),X(n))|0}:e?(i)=>{s=31*s+X(i)|0}:(i)=>{s=s+X(i)|0}),Eu(t.size,s)}var Ci=(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=xe(e^e>>>16),e}function kt(t){try{return typeof t==="string"?JSON.stringify(t):String(t)}catch{return JSON.stringify(t)}}var b=(t,e)=>t===e?t:vr(t)?e:t.create?t.create(e):t.constructor(e),qu=(t,e)=>b(t,(w(t)?Z:j(t)?dt:yt)(e)),Pi=(...t)=>t,m=(t)=>R(t)?t:it(t);class H{size=0;static{this.prototype[dn]=!0,this.prototype.__toStringMapper=kt,this.prototype[Symbol.iterator]=this.prototype.values,this.prototype.toJSON=this.prototype.toArray,this.prototype.contains=this.prototype.includes}equals(t){return is(this,t)}hashCode(){return this.__hash??(this.__hash=Mu(this))}toArray(){A(this.size);let t=Array(this.size||0),e=w(this),r=0;return this.__iterate((s,i)=>{t[r++]=e?[i,s]:s}),t}toIndexedSeq(){return new Rn(this)}toJS(){return Re(this)}toKeyedSeq(){return new ls(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 Wn(this)}toSeq(){return j(this)?this.toIndexedSeq():w(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=w(this),r=[this,...t].map((s)=>{if(!R(s))s=e?Un(s):Ln(Array.isArray(s)?s:[s]);else if(e)s=Z(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&&w(s)||j(this)&&j(s))return s}return b(this,new Dn(r))}includes(t){return this.some((e)=>I(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=w(this),i=G(r);if(s)i.has=(n)=>{let h=r.get(n,p);return h!==p&&!!t.call(e,h,n,r)},i.get=(n,h)=>{let u=r.get(n,p);return u!==p&&t.call(e,u,n,r)?u:h};return i.__iterateUncached=function(n,h){let u=0;return r.__iterate((o,c)=>{if(t.call(e,o,c,r))return u++,n(o,s?c:u-1,this)},h),u},i.__iteratorUncached=function(n){let h=r.__iterator(n),u=0;return M((o)=>{while(!0){let c=h.next();if(c.done)return!1;let f=c.value[0],_=c.value[1];if(t.call(e,_,f,r))return o[0]=s?f:u++,o[1]=_,!0}})},b(this,i)}partition(t,e){let r=w(this),s=[[],[]];return this.__iterate((i,n)=>{s[t.call(e,i,n,this)?1:0].push(r?[n,i]:i)}),s.map((i)=>qu(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 L(()=>{let r=t.next();if(r.done)return $;return e.value=r.value[0],e})}map(t,e){return b(this,bn(this,t,e))}reduce(t,e=p,r){return Ji(this,t,e,r,e===p,!1)}reduceRight(t,e=p,r){return Ji(this,t,e,r,e===p,!0)}reverse(){return b(this,Mn(this,w(this)))}slice(t,e){return b(this,En(this,t,e,w(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 b(this,Bi(this,t))}values(){let t=this.__iterator(),e={done:!1,value:void 0};return L(()=>{let r=t.next();if(r.done)return $;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 ue(t._cache);let e=t.toSeq().map(cu).toIndexedSeq();return e.fromEntrySeq=()=>t.toSeq(),e}filterNot(t,e){return this.filter(Xr(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(_n,null,t)}flatMap(t,e){return b(this,this.toSeq().map((r,s)=>(w(this)?Z:j(this)?dt:yt)(t.call(e,r,s,this))).flatten(!0))}flatten(t){let e=this,r=w(this),s=G(e);return s.__iterateUncached=function(i,n){if(n)return this.cacheResult().__iterate(i,n);let h=0,u=!1;function o(c,f){c.__iterate((_,l)=>{if((!t||f<t)&&R(_))o(_,f+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],c=o.iterator.next();if(c.done){h.pop();continue}let f=c.value[1];if((!t||o.depth<t)&&R(f)){h.push({iterator:f.__iterator(i),depth:o.depth+1});continue}return u[0]=r?c.value[0]:n++,u[1]=f,!0}return!1})},b(this,s)}fromEntrySeq(){return new Tn(this)}get(t,e){return this.find((r,s)=>I(s,t),void 0,e)}getIn(t,e){return ss(this,t,e)}groupBy(t,e){throw Error("groupBy: not patched — import CollectionConversions")}has(t){return this.get(t,p)!==p}hasIn(t){return An(this,t)}isSubset(t){let e=typeof t.includes==="function"?t:m(t);return this.every((r)=>e.includes(r))}isSuperset(t){return(typeof t.isSubset==="function"?t:m(t)).isSubset(this)}keyOf(t){return this.findKey((e)=>I(e,t))}keySeq(){return this.toSeq().map(ou).toIndexedSeq()}last(t){return this.toSeq().reverse().first(t)}lastKeyOf(t){return this.toKeyedSeq().reverse().keyOf(t)}max(t){return $e(this,t)}maxBy(t,e){return $e(this,e,t)}min(t){return $e(this,t?Xi(t):Hi)}minBy(t,e){return $e(this,e?Xi(e):Hi,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=w(this),i=G(r);return i.__iterateUncached=function(n,h){if(h)return this.cacheResult().__iterate(n,h);let u=!0,o=0;return r.__iterate((c,f)=>{if(u&&t.call(e,c,f,this))return;return u=!1,o++,n(c,s?f: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,c=!0;return M((f)=>{while(!0){let _=h.next();if(_.done)return!1;let l=_.value[0],a=_.value[1];if(c&&t.call(e,a,l,o))continue;return c=!1,f[0]=s?l:u++,f[1]=a,!0}})},b(this,i)}skipUntil(t,e){return this.skipWhile(Xr(t),e)}sortBy(t,e){return b(this,Bi(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=G(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 L(()=>{if(u)return $;let o=n.next();if(o.done)return o;if(!t.call(e,o.value[1],o.value[0],h))return u=!0,$;return o})},b(this,s)}takeUntil(t,e){return this.takeWhile(Xr(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 Z=(t)=>w(t)?t:us(t);class ns extends H{static{this.prototype[Le]=!0,this.prototype.__toStringMapper=(t,e)=>`${kt(e)}: ${kt(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 b(this,On(this))}mapEntries(t,e){let r=0;return b(this,this.toSeq().map((s,i)=>t.call(e,[i,s],r++,this)).fromEntrySeq())}mapKeys(t,e){return b(this,this.toSeq().flip().map((r,s)=>t.call(e,r,s,this)).flip())}}var dt=(t)=>j(t)?t:lt(t);class $t extends H{static{this.prototype[De]=!0,this.prototype[rt]=!0}toKeyedSeq(){return new ls(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=p,...r){if(t===void 0)return this;let s=e!==p;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 b(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=et(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=et(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=G(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((c)=>{if(o)return o=!1,c[0]=n++,c[1]=u,!0;let f=i.next();if(f.done)return!1;let _=f.value[1];if(!h)return u=_,o=!0,c[0]=n++,c[1]=t,!0;return h=!1,c[0]=n++,c[1]=_,!0})},b(this,r)}interleave(...t){let e=[this,...t],r=Hr(this.toSeq(),lt.of,e),s=r.flatten(!0);if(r.size)s.size=r.size*e.length;return b(this,s)}keySeq(){throw Error("keySeq: not patched — import CollectionConversions")}last(t){return this.get(-1,t)}zip(...t){return this.zipWith(Pi,...t)}zipAll(...t){let e=[this,...t];return b(this,Hr(this,Pi,e,!0))}zipWith(t,...e){let r=[this,...e];return b(this,Hr(this,t,r))}}var yt=(t)=>R(t)&&!Vr(t)?t:Nt(t);class Qe extends H{static{this.prototype.has=H.prototype.includes,this.prototype.contains=H.prototype.includes,this.prototype.keys=Qe.prototype.values}get(t,e){return this.has(t)?t:e}includes(t){return this.has(t)}keySeq(){return this.valueSeq()}}m.Keyed=Z;m.Indexed=dt;m.Set=yt;var Qr=$t.prototype,it=(t)=>t===void 0||t===null?fs():P(t)?t.toSeq():ju(t),G=(t)=>Object.create((w(t)?Wt:j(t)?pt:os).prototype);class ft extends H{static{this.prototype[ne]=!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 L(()=>{if(s===r)return $;return i.value=e[t?r-++s:s++],i})}return this.__iteratorUncached(t)}}var hs={cacheResult:ft.prototype.cacheResult,__iterateUncached:ft.prototype.__iterateUncached,__iterate:ft.prototype.__iterate,__iterator:ft.prototype.__iterator},us=(t)=>t===void 0||t===null?fs().toKeyedSeq():R(t)?w(t)?t.toSeq():t.fromEntrySeq():at(t)?t.toSeq():Un(t);class Wt extends ns{static{this.prototype[ne]=!0,Object.assign(this.prototype,hs)}toSeq(){return this}toKeyedSeq(){return this}}var lt=(t)=>t===void 0||t===null?fs():R(t)?w(t)?t.entrySeq():t.toIndexedSeq():at(t)?t.toSeq().entrySeq():Ln(t);lt.of=(...t)=>lt(t);class pt extends $t{static{this.prototype[ne]=!0,Object.assign(this.prototype,hs)}toSeq(){return this}toIndexedSeq(){return this}toString(){return this.__toString("Seq [","]")}}var Nt=(t)=>(R(t)&&!Vr(t)?t:lt(t)).toSetSeq();Nt.of=(...t)=>Nt(t);class os extends Qe{static{this.prototype[ne]=!0,Object.assign(this.prototype,hs)}toSeq(){return this}toSetSeq(){return this}}it.isSeq=vr;it.Keyed=us;it.Set=Nt;it.Indexed=lt;class ue extends pt{constructor(t){super();this._array=t,this.size=t.length}get(t,e){return this.has(t)?this._array[et(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 cs extends Wt{static{this.prototype[rt]=!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 Kn extends pt{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=fn(e);if(!_u(r))return ct();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 fs=()=>new ue([]),_s=(t)=>qn(t)?new ue(t):cn(t)?new Kn(t):void 0;function Un(t){let e=_s(t);if(e)return e.fromEntrySeq();if(typeof t==="object")return new cs(t);throw TypeError(`Expected Array or collection object of [k, v] entries, or keyed object: ${t}`)}function Ln(t){let e=_s(t);if(e)return e;throw TypeError(`Expected Array or collection object of values: ${t}`)}function ju(t){let e=_s(t);if(e)return lu(t)?e.fromEntrySeq():au(t)?e.toSetSeq():e;if(typeof t==="object")return new cs(t);throw TypeError(`Expected Array or collection object of values, or keyed object: ${t}`)}class Dn extends ft{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[Le])this[Le]=!0;if(i[De])this[De]=!0;if(i[rt])this[rt]=!0}__iterateUncached(t,e){if(this._wrappedIterables.length===0)return 0;if(e)return this.cacheResult().__iterate(t,e);let r=this._wrappedIterables,s=!w(this),i=0,n=!1;for(let h of r)if(h.__iterate((u,o)=>{if(t(u,s?i++:o,this)===!1)return n=!0,!1},e),n)break;return i}__iteratorUncached(t){if(this._wrappedIterables.length===0)return ct();if(t)return this.cacheResult().__iterator(t);let e=this._wrappedIterables,r=!w(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 L(()=>n()||$)}}class ls extends Wt{static{this.prototype[rt]=!0}constructor(t,e){super();this._iter=t,this._useKeys=e,this.size=t.size}cacheResult(){return Tt.call(this)}get(t,e){return this._iter.get(t,e)}has(t){return this._iter.has(t)}valueSeq(){return this._iter.valueSeq()}reverse(){let t=Mn(this,!0);if(!this._useKeys)t.valueSeq=()=>this._iter.toSeq().reverse();return t}map(t,e){let r=bn(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 pt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Tt.call(this)}includes(t){return this._iter.includes(t)}__iterateUncached(t,e){let r=0;if(e)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 ee(this._iter.__iterator(t),(s,i,n)=>{n[0]=t?r-++e:e++,n[1]=i})}}class Wn extends os{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Tt.call(this)}has(t){return this._iter.includes(t)}__iterateUncached(t,e){return this._iter.__iterate((r)=>t(r,r,this),e)}__iteratorUncached(t){return ee(this._iter.__iterator(t),(e,r,s)=>{s[0]=r,s[1]=r})}}class Tn extends Wt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Tt.call(this)}entrySeq(){return this._iter.toSeq()}__iterateUncached(t,e){let r=0;return this._iter.__iterate((s)=>{if(s){Fi(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){Fi(i);let n=R(i);return r[0]=n?i.get(0):i[0],r[1]=n?i.get(1):i[1],!0}}})}}function Tt(){if(this._iter.cacheResult)return this._iter.cacheResult(),this.size=this._iter.size,this;return ft.prototype.cacheResult.call(this)}function Fi(t){if(t!==Object(t))throw TypeError(`Expected [K, V] tuple: ${t}`)}var x=(t)=>t===void 0||t===null?B():he(t)&&!F(t)?t:B().withMutations((e)=>{let r=Z(t);A(r.size),r.forEach((s,i)=>e.set(i,s))});class as extends ns{static{wt(this,{asImmutable:oe,asMutable:ce,deleteIn:Kt,merge:Fr,mergeWith:Qn,mergeDeep:Yn,mergeDeepWith:Cn,mergeDeepIn:js,mergeIn:qs,setIn:bs,update:Ms,updateIn:Es,wasAltered:Os,withMutations:fe,removeIn:Kt,concat:Fr,[pn]:!0,[re]: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 x(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 ki(this,t,e)}remove(t){return ki(this,t,p)}deleteAll(t){let e=m(t);if(e.size===0)return this;return this.withMutations((r)=>{e.forEach((s)=>r.remove(s))})}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this;return B()}map(t,e){return this.withMutations((r)=>{r.forEach((s,i)=>{r.set(i,t.call(e,s,i,this))})})}keys(){if(!this._root)return ct();return Ke(this._root,!1,0)}values(){if(!this._root)return ct();return Ke(this._root,!1,1)}entries(){if(!this._root)return ct();return Ke(this._root,!1)}__iterator(t){if(!this._root)return ct();return Ke(this._root,t)}__iterate(t,e){let r=0;if(this._root)this._root.iterate(([s,i])=>{return r++,t(i,s,this)},e);return r}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return B();return this.__ownerID=t,this.__altered=!1,this}return ps(this.size,this._root,t,this.__hash)}}x.isMap=he;class ds{constructor(t,e){this.ownerID=t,this.entries=e}get(t,e,r,s){return Jn(this.entries,r,s)}iterate(t,e){return Xn(this.entries,t,e)}update(t,e,r,s,i,n,h){let u=i===p,o=this.entries,c=0,f=o.length;for(;c<f;c++)if(I(s,o[c][0]))break;let _=c<f;if(_?o[c][1]===i:u)return this;if(T(h),u||!_)T(n);if(u&&f===1)return;if(!_&&!u&&f>=Lu)return Iu(t,o,s,i);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(c===f-1)a.pop();else a[c]=a.pop();else a[c]=[s,i];else a.push([s,i]);if(l)return this.entries=a,this;return new ds(t,a)}}class Ge{constructor(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}iterate(t,e){return Hn(this.nodes,t,e)}get(t,e,r,s){let i=1<<((t===0?e:e>>>t)&K),n=this.bitmap;return(n&i)===0?s:this.nodes[Vi(n&i-1)].get(t+z,e,r,s)}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&K,o=1<<u,c=this.bitmap,f=(c&o)!==0;if(!f&&i===p)return this;let _=Vi(c&o-1),l=this.nodes,a=f?l[_]:void 0,d=gs(a,t,e+z,r,s,i,n,h);if(d===a)return this;if(!f&&d&&l.length>=Du)return $u(t,l,c,u,d);if(f&&!d&&l.length===2&&Ni(l[_^1]))return l[_^1];if(f&&d&&l.length===1&&Ni(d))return d;let y=t&&t===this.ownerID,S=f?d?c:c^o:c|o,O=f?d?Zn(l,_,d,y):Uu(l,_,y):Ku(l,_,d,y);if(y)return this.bitmap=S,this.nodes=O,this;return new Ge(t,S,O)}}class ys{constructor(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}iterate(t,e){return Hn(this.nodes,t,e)}get(t,e,r,s){let i=(t===0?e:e>>>t)&K,n=this.nodes[i];return n?n.get(t+z,e,r,s):s}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&K,o=i===p,c=this.nodes,f=c[u];if(o&&!f)return this;let _=gs(f,t,e+z,r,s,i,n,h);if(_===f)return this;let l=this.count;if(!f)l++;else if(!_){if(l--,l<Ru)return Au(t,c,l,u)}let a=t&&t===this.ownerID,d=Zn(c,u,_,a);if(a)return this.count=l,this.nodes=d,this;return new ys(t,l,d)}}class Ye{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}get(t,e,r,s){return Jn(this.entries,r,s)}iterate(t,e){return Xn(this.entries,t,e)}update(t,e,r,s,i,n,h){if(r!==this.keyHash){if(i===p)return this;return T(h),T(n),ws(this,t,e,r,[s,i])}let u=i===p,o=this.entries,c=0,f=o.length;for(;c<f;c++)if(I(s,o[c][0]))break;let _=c<f;if(_?o[c][1]===i:u)return this;if(T(h),u||!_)T(n);if(u&&f===2)return new gt(t,this.keyHash,o[c^1]);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(c===f-1)a.pop();else a[c]=a.pop();else a[c]=[s,i];else a.push([s,i]);if(l)return this.entries=a,this;return new Ye(t,this.keyHash,a)}}class gt{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 I(r,this.entry[0])?this.entry[1]:s}update(t,e,r,s,i,n,h){let u=i===p,o=I(s,this.entry[0]);if(o?i===this.entry[1]:u)return this;if(T(h),u){T(n);return}if(o){if(t&&t===this.ownerID)return this.entry[1]=i,this;return new gt(t,this.keyHash,[s,i])}return T(n),ws(this,t,e,X(s),[s,i])}}function Jn(t,e,r){for(let s=0,i=t.length;s<i;s++)if(I(e,t[s][0]))return t[s][1];return r}function Xn(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 Hn(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 Ke(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 L(()=>{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 c=h.nodes[e?o-u:u];if(c){if(c.entry)return n.value=i(c.entry),n;s={node:c,index:0,__prev:s}}continue}s=s.__prev}return $})}var ps=(t,e,r,s)=>new as(t,e,r,s),mi,B=()=>mi||(mi=ps(0));function ki(t,e,r){let s,i;if(!t._root){if(r===p)return t;i=1,s=new ds(t.__ownerID,[[e,r]])}else{let n=Cr(),h=Cr();if(s=gs(t._root,t.__ownerID,0,X(e),e,r,n,h),!h.value)return t;i=t.size+(n.value?r===p?-1:1:0)}if(t.__ownerID)return t.size=i,t._root=s,t.__hash=void 0,t.__altered=!0,t;return s?ps(i,s):B()}function gs(t,e,r,s,i,n,h,u){if(!t){if(n===p)return t;return T(u),T(h),new gt(e,s,[i,n])}return t.update(e,r,s,i,n,h,u)}var Ni=(t)=>t.constructor===gt||t.constructor===Ye;function ws(t,e,r,s,i){if(t.keyHash===s)return new Ye(e,s,[t.entry,i]);let n=(r===0?t.keyHash:t.keyHash>>>r)&K,h=(r===0?s:s>>>r)&K,u=new gt(e,s,i),o=n===h?[ws(t,e,r+z,s,i)]:n<h?[t,u]:[u,t];return new Ge(e,1<<n|1<<h,o)}function Iu(t,e,r,s){if(!t)t=new Ze;let i=new gt(t,X(r),[r,s]);for(let[n,h]of e)i=i.update(t,0,X(n),n,h);return i}function Au(t,e,r,s){let i=0,n=0,h=Array(r);for(let u=0,o=1,c=e.length;u<c;u++,o<<=1){let f=e[u];if(f!==void 0&&u!==s)i|=o,h[n++]=f}return new Ge(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 ys(t,n+1,h)}function Vi(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 Zn(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 Uu(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 Lu=q/4,Du=q/2,Ru=q/4;function We(t){if(Array.isArray(t))return t.slice();return{...t}}var zs=(t,e,r)=>Ss(t,e,Wu(r));function Ss(t,e,r){if(!st(t))throw TypeError(`Cannot merge into non-data-structure value: ${t}`);if(P(t))return typeof r==="function"&&t.mergeWith?t.mergeWith(r,...e):t.merge?t.merge(...e):t.concat(...e);let s=Array.isArray(t),i=t,n=s?dt:Z,h=s?(u)=>{if(i===t)i=We(i);i.push(u)}:(u,o)=>{let c=Object.hasOwn(i,o),f=c&&r?r(i[o],u,o):u;if(!c||f!==i[o]){if(i===t)i=We(i);i[o]=f}};for(let u of e)n(u).forEach(h);return i}function Wu(t){function e(r,s,i){return st(r)&&st(s)&&Tu(r,s)?Ss(r,[s],e):t?t(r,s,i):s}return e}function Tu(t,e){let r=it(t),s=it(e);return j(r)===j(s)&&w(r)===w(s)}function Ju(t,e){if(!st(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(P(t)){if(!t.remove)throw TypeError(`Cannot update immutable value without .remove() method: ${t}`);return t.remove(e)}if(!Object.hasOwn(t,e))return t;let r=We(t);if(Array.isArray(r))r.splice(e,1);else delete r[e];return r}function Xu(t,e,r){if(!st(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(P(t)){if(!t.set)throw TypeError(`Cannot update immutable value without .set() method: ${t}`);return t.set(e,r)}if(Object.hasOwn(t,e)&&r===t[e])return t;let s=We(t);return s[e]=r,s}function Jt(t,e,r,s){if(!s)s=r,r=void 0;let i=Bn(P(t),t,jn(e),0,r,s);return i===p?r:i}function Bn(t,e,r,s,i,n){let h=e===p;if(s===r.length){let _=h?i:e,l=n(_);return l===_?e:l}if(!h&&!st(e))throw TypeError(`Cannot update within non-data-structure value in path [${Array.from(r).slice(0,s).map(kt)}]: ${e}`);let u=r[s],o=h?p:In(e,u,p),c=Bn(o===p?t:P(o),o,r,s+1,i,n);if(c===o)return e;if(c===p)return Ju(e,u);let f=h?t?B():{}:e;return Xu(f,u,c)}var Hu=(t,e)=>Jt(t,e,()=>p),Zu=(t,e,r)=>Jt(t,e,p,()=>r);function xn(t,e,r,s){return Jt(t,[e],r,s)}function oe(){return this.__ensureOwner()}function ce(){return this.__ownerID?this:this.__ensureOwner(new Ze)}function Os(){return this.__altered}function fe(t){let e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Bu(t,e){return ss(this,t,e)}function xu(t){return An(this,t)}function Kt(t){return Hu(this,t)}function bs(t,e){return Zu(this,t,e)}function Ms(t,e,r){return typeof t==="function"?t(this):xn(this,t,e,r)}function Es(t,e,r){return Jt(this,t,e,r)}function vi(){A(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}function Fr(...t){return Gn(this,t)}function Qn(t,...e){if(typeof t!=="function")throw TypeError(`Invalid merger function: ${t}`);return Gn(this,e,t)}function Gn(t,e,r){let s=[];for(let i of e){let n=Z(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,p,(o)=>o===p?h:r(o,h,u))}:(h,u)=>{i.set(u,h)};for(let h of s)h.forEach(n)})}function Yn(...t){return zs(this,t)}function Cn(t,...e){return zs(this,e,t)}function qs(t,...e){return Jt(this,t,B(),(r)=>Ss(r,e))}function js(t,...e){return Jt(this,t,B(),(r)=>zs(r,e))}function wt(t,e){Object.assign(t.prototype,e)}var U=(t)=>{let e=Vt();if(t===void 0||t===null)return e;if(ts(t))return t;let r=dt(t),s=r.size;if(s===0)return e;if(A(s),s>0&&s<q)return _e(0,s,z,null,new _t(r.toArray()));return e.withMutations((i)=>{i.setSize(s),r.forEach((n,h)=>i.set(h,n))})};U.of=(...t)=>U(t);class Pn extends $t{static{wt(this,{asImmutable:oe,asMutable:ce,deleteIn:Kt,mergeDeepIn:js,mergeIn:qs,setIn:bs,update:Ms,updateIn:Es,wasAltered:Os,withMutations:fe,removeIn:Kt,[yn]:!0,[re]:this.prototype.remove,merge:this.prototype.concat,[Symbol.toStringTag]:"Immutable.List",[Symbol.iterator]:this.prototype.values})}constructor(t,e,r,s,i,n,h){super();this.size=e-t,this._origin=t,this._capacity=e,this._level=r,this._root=s,this._tail=i,this.__ownerID=n,this.__hash=h,this.__altered=!1}create(t){return U(t)}toString(){return this.__toString("List [","]")}get(t,e){if(t=et(this,t),t>=0&&t<this.size){t+=this._origin;let r=kn(this,t);return r&&r.array[t&K]}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=z,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this;return Vt()}push(...t){let e=this.size;return this.withMutations((r)=>{tt(r,0,e+t.length);for(let s=0;s<t.length;s++)r.set(e+s,t[s])})}pop(){return tt(this,0,-1)}unshift(...t){return this.withMutations((e)=>{tt(e,-t.length);for(let r=0;r<t.length;r++)e.set(r,t[r])})}shift(){return tt(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=dt(typeof r!=="string"&&cn(r)?r:[r]);if(s.size!==0)e.push(s)}if(e.length===0)return this;if(this.size===0&&!this.__ownerID&&e.length===1)return U(e[0]);return this.withMutations((r)=>{e.forEach((s)=>s.forEach((i)=>r.push(i)))})}setSize(t){return tt(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(se(t,e,r))return this;return tt(this,Rt(t,r),ie(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=tn(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 tn(this,!1)}keys(){return Xe(this.size)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return Vt();return this.__ownerID=t,this.__altered=!1,this}return _e(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash)}}U.isList=ts;class _t{constructor(t,e){this.array=t,this.ownerID=e}removeBefore(t,e,r){if((r&(1<<e+z)-1)===0||this.array.length===0)return this;let s=r>>>e&K;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-z,r),n===u&&i)return this}if(i&&!n)return this;let h=Ut(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+z:q)||this.array.length===0)return this;let s=r-1>>>e&K;if(s>=this.array.length)return this;let i;if(e>0){let h=this.array[s];if(i=h?.removeAfter(t,e-z,r),i===h&&s===this.array.length-1)return this}let n=Ut(this,t);if(n.array.splice(s+1),i)n.array[s]=i;return n}}function tn(t,e){let{_origin:r,_capacity:s}=t,i=Lt(s),n=t._tail,h=[];o(t._root,t._level,0);let u={done:!1,value:void 0};return L(()=>{while(h.length>0){let c=h[h.length-1];if(c.from===c.to){h.pop();continue}let f=e?--c.to:c.from++;if(c.isLeaf)return u.value=c.array?.[f],u;let _=c.array?.[f],l=c.level-z,a=c.offset+(f<<c.level);o(_,l,a)}return $});function o(c,f,_){if(f===0){let l=_===i?n?.array:c?.array,a=_>r?0:r-_,d=s-_;if(d>q)d=q;if(a!==d)h.push({array:l,from:a,to:d,isLeaf:!0})}else{let l=c?.array,a=_>r?0:r-_>>f,d=(s-_>>f)+1;if(d>q)d=q;if(a!==d)h.push({array:l,from:a,to:d,level:f,offset:_,isLeaf:!1})}}}function Qu(t,e,r){let{_origin:s,_capacity:i}=t,n=Lt(i),h=t._tail,u=t._level,o=t._root;return u===0?Fn(o,0,s,i,n,h,e,r):mn(o,u,0,s,i,n,h,e,r)}function Fn(t,e,r,s,i,n,h,u){let o=e===i?n?.array:t?.array,c=e>r?0:r-e,f=s-e;if(f>q)f=q;while(c!==f){let _=u?--f:c++;if(h(o?.[_])===!1)return!1}}function mn(t,e,r,s,i,n,h,u,o){let c=t?.array,f=r>s?0:s-r>>e,_=(i-r>>e)+1;if(_>q)_=q;let l=e-z;while(f!==_){let a=o?--_:f++,d=r+(a<<e);if((l===0?Fn(c?.[a],d,s,i,n,h,u,o):mn(c?.[a],l,d,s,i,n,h,u,o))===!1)return!1}}var _e=(t,e,r,s,i,n,h)=>new Pn(t,e,r,s,i,n,h),Vt=()=>_e(0,0,z);function Gu(t,e,r){if(e=et(t,e),Number.isNaN(e))return t;if(e>=t.size||e<0)return t.withMutations((h)=>{if(e<0)tt(h,e).set(0,r);else tt(h,0,e+1).set(e,r)});e+=t._origin;let{_tail:s,_root:i}=t,n=Cr();if(e>=Lt(t._capacity))s=mr(s,t.__ownerID,0,e,r,n);else i=mr(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 _e(t._origin,t._capacity,t._level,i,s)}function mr(t,e,r,s,i,n){let h=s>>>r&K,u=t&&h<t.array.length;if(!u&&i===void 0)return t;let o;if(r>0){let c=t&&t.array[h],f=mr(c,e,r-z,s,i,n);if(f===c)return t;return o=Ut(t,e),o.array[h]=f,o}if(u&&t.array[h]===i)return t;if(n)T(n);if(o=Ut(t,e),i===void 0&&h===o.array.length-1)o.array.pop();else o.array[h]=i;return o}function Ut(t,e){if(e&&e===t?.ownerID)return t;return new _t(t?.array.slice()??[],e)}function kn(t,e){if(e>=Lt(t._capacity))return t._tail;if(e<1<<t._level+z){let{_root:r,_level:s}=t;while(r&&s>0)r=r.array[e>>>s&K],s-=z;return r}}function tt(t,e,r){if(e!==void 0)e|=0;if(r!==void 0)r|=0;let s=t.__ownerID||new Ze,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:c}=t,f=0;while(h+f<0)c=new _t(c?.array.length?[void 0,c]:[],s),o+=z,f+=1<<o;if(f)h+=f,i+=f,u+=f,n+=f;let _=Lt(n),l=Lt(u);while(l>=1<<o+z)c=new _t(c?.array.length?[c]:[],s),o+=z;let a=t._tail,d=l<_?kn(t,u-1):l>_?new _t([],s):a;if(a&&l>_&&h<n&&a.array.length){c=Ut(c,s);let y=c;for(let S=o;S>z;S-=z){let O=_>>>S&K;y=y.array[O]=Ut(y.array[O],s)}y.array[_>>>z&K]=a}if(u<n)d=d&&d.removeAfter(s,0,u);if(h>=l)h-=l,u-=l,o=z,c=null,d=d&&d.removeBefore(s,0,h);else if(h>i||l<_){f=0;while(c){let y=h>>>o&K;if(y!==l>>>o&K)break;if(y)f+=(1<<o)*y;o-=z,c=c.array[y]}if(c&&h>i)c=c.removeBefore(s,o,h-f);if(c&&l<_)c=c.removeAfter(s,o,l-f);if(f)h-=f,u-=f}if(t.__ownerID)return t.size=u-h,t._origin=h,t._capacity=u,t._level=o,t._root=c,t._tail=d,t.__hash=void 0,t.__altered=!0,t;return _e(h,u,o,c,d)}var Lt=(t)=>t<q?0:t-1>>>z<<z,Y=(t)=>t===void 0||t===null?vt():Be(t)?t:vt().withMutations((e)=>{let r=Z(t);A(r.size),r.forEach((s,i)=>e.set(i,s))});Y.of=(...t)=>Y(t);class Nn extends as{static{wt(this,{[rt]:!0,[re]: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 Y(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 vt()}set(t,e){return en(this,t,e)}remove(t){return en(this,t,p)}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 vt();return this.__ownerID=t,this.__altered=!1,this._map=e,this._list=r,this}return Is(e,r,t,this.__hash)}}Y.isOrderedMap=Be;var Is=(t,e,r,s)=>new Nn(t,e,r,s),vt=()=>Is(B(),Vt());function en(t,e,r){let{_map:s,_list:i}=t,n=s.get(e),h=n!==void 0,u,o;if(r===p){if(!h)return t;if(i.size>=q&&i.size>=s.size*2){let c=[];if(i.forEach((f,_)=>{if(f!==void 0&&n!==_)c.push(f)}),o=Vt().withMutations((f)=>{for(let _=0;_<c.length;_++)f.set(_,c[_])}),u=B().withMutations((f)=>{for(let _=0;_<c.length;_++)f.set(c[_][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 c=i.size;u=s.set(e,c),o=i.set(c,[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 Is(u,o)}var Te=(t)=>t===void 0||t===null?Je():rs(t)?t:Je().pushAll(t);Te.of=(...t)=>Te(t);class Vn extends $t{static{wt(this,{asImmutable:oe,asMutable:ce,wasAltered:Os,withMutations:fe,[wn]:!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 Te(t)}toString(){return this.__toString("Stack [","]")}get(t,e){let r=this._head;t=et(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 Gr(this,e,r)}pushAll(t){if(t=dt(t),t.size===0)return this;if(this.size===0&&rs(t))return t;A(t.size);let e=this.size,r=this._head;return t.__iterate((s)=>{e++,r={value:s,next:r}},!0),Gr(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 Je()}slice(t,e){if(se(t,e,this.size))return this;let r=Rt(t,this.size);if(ie(e,this.size)!==this.size)return $t.prototype.slice.call(this,t,e);let i=this.size-r,n=this._head;while(r--)n=n.next;return Gr(this,i,n)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return Je();return this.__ownerID=t,this.__altered=!1,this}return As(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 L(()=>{if(!t)return $;return e.value=t.value,t=t.next,e})}keys(){return Xe(this.size)}}Te.isStack=rs;function Gr(t,e,r){if(t.__ownerID)return t.size=e,t._head=r,t.__hash=void 0,t.__altered=!0,t;return As(e,r)}var As=(t,e,r,s)=>new Vn(t,e,r,s),rn,Je=()=>rn||(rn=As(0)),E=(t)=>t===void 0||t===null?te():es(t)&&!F(t)?t:te().withMutations((e)=>{let r=yt(t);A(r.size),r.forEach((s)=>e.add(s))});E.of=(...t)=>E(t);E.fromKeys=(t)=>E(Z(t).keySeq());E.intersect=(t)=>{return t=m(t).toArray(),t.length?E(t.pop()).intersect(...t):te()};E.union=(t)=>{let e=m(t).toArray();return e.length?E(e.pop()).union(...e):te()};class $s extends Qe{static{wt(this,{withMutations:fe,asImmutable:oe,asMutable:ce,[gn]:!0,[re]: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 E(t)}toString(){return this.__toString("Set {","}")}has(t){return this._map.has(t)}add(t){return Ue(this,this._map.set(t,t))}remove(t){return Ue(this,this._map.remove(t))}clear(){return Ue(this,this._map.clear())}map(t,e){let r=!1,s=Ue(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 E(t[0]);return this.withMutations((e)=>{for(let r of t)if(typeof r==="string")e.add(r);else yt(r).forEach((s)=>e.add(s))})}intersect(...t){return nn(this,t,(e,r)=>!r.every((s)=>s.includes(e)))}subtract(...t){return nn(this,t,(e,r)=>r.some((s)=>s.includes(e)))}wasAltered(){return this._map.wasAltered()}__iterator(t){return this._map.__iterator(t)}__empty(){return te()}__make(t,e){return vn(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)}}E.isSet=es;var vn=(t,e)=>new $s(t,e),sn,te=()=>sn||(sn=vn(B()));function nn(t,e,r){if(e.length===0)return t;return e=e.map((s)=>yt(s)),t.withMutations((s)=>{t.forEach((i)=>{if(r(i,e))s.remove(i)})})}function Ue(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 Dt=(t)=>t===void 0||t===null?kr():Sn(t)?t:kr().withMutations((e)=>{let r=yt(t);A(r.size),r.forEach((s)=>e.add(s))});Dt.of=(...t)=>Dt(t);Dt.fromKeys=(t)=>Dt(Z(t).keySeq());class th extends $s{static{wt(this,{[rt]:!0,[Symbol.toStringTag]:"Immutable.OrderedSet",zip:Qr.zip,zipWith:Qr.zipWith,zipAll:Qr.zipAll})}create(t){return Dt(t)}toString(){return this.__toString("OrderedSet {","}")}__empty(){return kr()}__make(t,e){return eh(t,e)}}Dt.isOrderedSet=Sn;var eh=(t,e)=>new th(t,e),kr=()=>eh(vt());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(P(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(t===null||typeof t!=="object")throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}var le=(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 c=0;c<u.length;c++){let f=u[c];if(o[f]=c,i[f])console.warn(`Cannot define ${Ks(this)} with property "${f}" since that property name is part of the Record API.`);else Pu(i,f)}}return this.__ownerID=void 0,this._values=U().withMutations((u)=>{u.setSize(this._keys.length),Z(h).forEach((o,c)=>{u.set(this._indices[c],o===this._defaultValues[c]?void 0:o)})}),this},i=s.prototype=Object.create(Cu);if(i.constructor=s,i.create=s,e)s.displayName=e;return s};class rh{static{wt(this,{asImmutable:oe,asMutable:ce,deleteIn:Kt,getIn:Bu,hasIn:xu,merge:Fr,mergeWith:Qn,mergeDeep:Yn,mergeDeepWith:Cn,mergeDeepIn:js,mergeIn:qs,setIn:bs,toObject:vi,update:Ms,updateIn:Es,withMutations:fe,removeIn:Kt,toJSON:vi,[zn]:!0,[re]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Record"})}toString(){let t=this._keys.map((e)=>`${e}: ${kt(this.get(e))}`).join(", ");return`${Ks(this)} { ${t} }`}equals(t){return this===t||at(t)&&It(this).equals(It(t))}hashCode(){return It(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 Yr(this,r)}return this}remove(t){return this.set(t)}clear(){let t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:Yr(this,t)}wasAltered(){return this._values.wasAltered()}toSeq(){return It(this)}toJS(){return Re(this)}entries(){return this.__iterator()}__iterate(t,e){return It(this).__iterate(t,e)}__iterator(t){return It(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 Yr(this,e,t)}}le.isRecord=at;var Ks=(t)=>t.constructor.displayName||t.constructor.name||"Record";class sh extends Wt{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 It=(t)=>new sh(t);le.getDescriptiveName=Ks;var Cu=rh.prototype;function Yr(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 hn=(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 Us(t,e,r,s)};class Us extends pt{_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+et(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(se(t,e,this.size))return this;if(t=Rt(t,this.size),e=ie(e,this.size),e<=t)return hn(0,0);return hn(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 L(()=>{if(s===t)return $;return i.value=r,r+=e,s++,i})}keys(){return Xe(this.size)}equals(t){return t instanceof Us?this._start===t._start&&this._end===t._end&&this._step===t._step:is(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}class Nr extends pt{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 I(this._value,t)}slice(t,e){let r=this.size;return se(t,e,r)?this:new Nr(this._value,ie(e,r)-Rt(t,r))}reverse(){return this}indexOf(t){if(I(this._value,t))return 0;return-1}lastIndexOf(t){if(I(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 L(()=>{if(r===t)return $;return r++,s.value=e,s})}keys(){return Xe(this.size)}equals(t){return t instanceof Nr?this.size===t.size&&I(this._value,t._value):is(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var ih=Symbol("BadValue"),oh=(t)=>t;class W{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,ih);if(h===ih)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 Ds{isValid(t){return!0}getMessage(t){return"Invalid"}}class ch extends Ds{}var Fu=new ch;class k extends Ds{constructor(t,e){super();this._isValid=t,this._getMessage=e}isValid(t){return this._isValid(t)}getMessage(t){return this._getMessage(t)}}var mu=new k((t)=>Number.isInteger(t),()=>"Integer expected"),ku=new k((t)=>Number.isFinite(t),()=>"Float expected"),Nu=new k((t)=>typeof t==="boolean",()=>"Boolean expected"),Vu=new k((t)=>typeof t==="string",()=>"String expected"),vu=new k((t)=>U.isList(t),()=>"List expected"),to=new k((t)=>x.isMap(t),()=>"Map expected"),eo=new k((t)=>Y.isOrderedMap(t),()=>"OrderedMap expected"),ro=new k((t)=>E.isSet(t),()=>"Set expected"),so=(t)=>!!t;class Rs extends W{constructor(t,e=!1){super("bool",t,Nu,so,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 Ce extends W{constructor(t,e=null){super("any",t,Fu,oh,e)}toDataDef(){let{defaultValue:t}=this;return{type:Ls(t)??"any",defaultValue:t?.toJS?t.toJS():t}}}var io=(t)=>t?.toString?.()??"";class Ws extends W{constructor(t,e=""){super("text",t,Vu,io,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 no=(t)=>Number.isFinite(t)?Math.trunc(t):null;class fh extends W{constructor(t,e=0){super("int",t,mu,no,e)}}var ho=(t)=>null;class Ts extends W{constructor(t,e=0){super("float",t,ku,ho,e)}}var Ls=(t)=>t?.constructor?.getMetaClass?.()?.name;class _h{constructor(t){this.typeName=t}isValid(t){return Ls(t)===this.typeName}getMessage(t){let e=Ls(t);return`Expected "${this.typeName}", got "${e}"`}}class lh extends W{constructor(t,e,r){super(t,e,new _h(t),oh,null);this.args=r}toDataDef(){return{component:this.typeName,args:this.args}}}var nh=Symbol("NONE");function Xt(t,e,r){dh(t,e,ah),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,nh);if(u!==nh)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 ah=U(),uo=(t)=>Array.isArray(t)?U(t):null;class Js extends W{constructor(t,e=ah){super("list",t,vu,uo,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 oo=(t)=>x(t);class Xs extends W{constructor(t,e=x()){super("map",t,to,oo,e)}extendProtoForType(t,e){Xt(t,this.name,e)}}var co=(t)=>Y(t);class Hs extends W{constructor(t,e=Y()){super("omap",t,eo,co,e)}extendProtoForType(t,e){Xt(t,this.name,e)}}function dh(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 hh=E(),fo=(t)=>Array.isArray(t)?E(t):t instanceof Set?E(t):null;class Zs extends W{constructor(t,e=hh){super("set",t,ro,fo,e)}extendProtoForType(t,e){let{name:r}=this;dh(t,r,hh),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 uh(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 yh{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]=uh(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]=uh(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]:le(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 lh(e,t,r);return this.compFields.add(t),this.fields[t]=s,s}}var Pe=new Map,_o={text:Ws,int:fh,float:Ts,bool:Rs,list:Js,map:Xs,omap:Hs,set:Zs,any:Ce};function lo(t,{fields:e={},methods:r,statics:s}){let i=new yh(t);for(let n in e){let h=e[n],u=typeof h;if(u==="string")i.addField(n,h,Ws);else if(u==="number")i.addField(n,h,Ts);else if(u==="boolean")i.addField(n,h,Rs);else if(U.isList(h)||Array.isArray(h))i.addField(n,U(h),Js);else if(E.isSet(h)||h instanceof Set)i.addField(n,E(h),Zs);else if(Y.isOrderedMap(h))i.addField(n,h,Hs);else if(h?.type&&h?.defaultValue!==void 0){let o=_o[h.type]??Ce;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(x.isMap(h)||h?.constructor===Object)i.addField(n,x(h),Xs);else{let o=Pe.get(h?.constructor)??Ce;i.addField(n,h,o)}}if(r)i.methods(r);if(s)i.statics(s);return i.build()}var ao=(t)=>new jr(t.name??"Comp",lo(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 yo=["nid","cid","eid","vid","si","sk"];class Bs{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??Oo,this.cache=h??new br}setNullCache(){this.cache=new Or}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 yo)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"),c=this.renderMetadata("Comp",{nid:s}),f=this.renderFragment([c,o.render(t,this)]);return this.cache.set(e,h,f),f}renderEach(t,e,r,s){let{seq:i,filter:n,loopWith:h}=e.eval(t),[u,o]=this.getSeqInfo(i),c=[],f=h.call(t.it,i);for(let[_,l]of o(i))if(n.call(t.it,_,l,f)){let a=t.enter(l,{key:_},!0),d=this.renderIt(a,r,_,s);c.push(this.renderMetadata("Each",{nid:r,[u]:_})),c.push(d)}return c}renderEachWhen(t,e,r,s){let{seq:i,filter:n,loopWith:h,enricher:u}=e.eval(t),[o,c]=this.getSeqInfo(i),f=!!u,_=[],l=h.call(t.it,i);for(let[a,d]of c(i))if(n.call(t.it,a,d,l)){let y={key:a,value:d},S=`${s}-${a}`,O;if(f)u.call(t.it,y,a,d,l),O=this.cache.get2(t.it,d,S);else O=this.cache.get(d,S);if(O){_.push(this.renderMetadata("Each",{nid:s,[o]:a})),_.push(O);continue}let Ot=t.enter(d,y,!1),bt=r.render(Ot,this);if(_.push(this.renderMetadata("Each",{nid:s,[o]:a})),f)this.cache.set2(t.it,d,S,bt);else this.cache.set(d,S,bt);_.push(bt)}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*po(t){let e=0;for(let r of t)yield[e++,r]}function*go(t){for(let[e,r]of t.toSeq().entries())yield[e,r]}var Fe=new Map,wo=["si",po],zo=["sk",go],So=["si",function*(e){}];function Oo(t){return j(t)?wo:w(t)?zo:Fe.get(t?.constructor)??So}class zt{constructor(t=x(),e=U()){this.items=t,this.order=e,this.$=0}_clonish(t,e){return new zt(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 ph{isValid(t){return t instanceof zt}getMessage(t){return"KList expected"}}var Mo=new ph;class gh extends W{constructor(t,e=new zt){super("KList",t,Mo,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))}}}Pe.set(zt,gh);function*Eo(t){for(let e of t.order)yield[e,t.items.get(e)]}Fe.set(zt,["data-sk",Eo]);function xs(t){return t[4]==="-"&&(t[0]==="d"||t[0]==="a")}function wh(t,e){return t[e]}function ae(t,e,r){t[e]=r}function Sh(t,e,r){for(let s in e){let i=e[s];if(i===void 0)qo(t,s,r);else if(xs(s))t.setAttribute(s,i);else if(typeof i==="object"&&i!==null)jo(t,r,s,i);else ae(t,s,i)}}function qo(t,e,r){let s=r[e];if(xs(e))t.removeAttribute(e);else if(typeof s==="string"){ae(t,e,"");let i=e==="className"?"class":e==="htmlFor"?"for":e;t.removeAttribute(i)}else ae(t,e,null)}function jo(t,e,r,s){let i=e?.[r];if(i&&typeof i==="object"&&Object.getPrototypeOf(i)!==Object.getPrototypeOf(s)){ae(t,r,s);return}let n=wh(t,r);if(typeof n!=="object"||n===null)ae(t,r,{}),n=wh(t,r);let h=n;for(let u in s)h[u]=s[u]}class Oh{type;message;constructor(t,e){this.type=t,this.message=e}}class bh extends Oh{duplicatedKeys;parentTag;parentIndex;constructor(t,e,r){let s=[...t].join(", ");super("DuplicatedKeys",`Duplicate keys found: [${s}] in ${e||"fragment"} at index ${r}. Nodes with duplicated keys are matched positionally.`);this.duplicatedKeys=t,this.parentTag=e,this.parentIndex=r}}class Bt{isEqualTo(t){return this===t}toDom(t){return null}}function Mh(t){return t instanceof Zt?t.key:void 0}function St(t,e){let r=Mh(t);return r&&e?.has(r)?void 0:r}function Io(t){return t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function"}function Qs(t,e){if(e==null)return;if(Io(e))for(let r of e)Qs(t,r);else if(e instanceof Bt)if(e instanceof N)t.push(...e.childs);else t.push(e);else t.push(new de(e))}class de extends Bt{text;constructor(t){super();this.text=String(t)}get nodeType(){return 3}isEqualTo(t){return t instanceof de&&this.text===t.text}toDom(t){return t.document.createTextNode(this.text)}}class Ht extends Bt{text;constructor(t){super();this.text=t}get nodeType(){return 8}isEqualTo(t){return t instanceof Ht&&this.text===t.text}toDom(t){return t.document.createComment(this.text)}}class N extends Bt{childs;constructor(t){super();let e=[];Qs(e,t),this.childs=e}get nodeType(){return 11}isEqualTo(t){if(!(t instanceof N)||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 Zt extends Bt{tag;attrs;childs;key;namespace;attrCount;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,this.attrCount=Object.keys(this.attrs).length}get nodeType(){return 1}isEqualTo(t){if(!(t instanceof Zt)||this.tag!==t.tag||this.key!==t.key||this.namespace!==t.namespace||this.attrCount!==t.attrCount||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=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);Sh(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(typeof i==="object"&&i!==null&&typeof n==="object"&&n!==null)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 Ao(t,e){let r=me(e);if(r.free.length===e.length)return{children:e,moves:null,duplicatedKeys:r.duplicatedKeys};let s=me(t),i=r.duplicatedKeys||s.duplicatedKeys?new Set([...r.duplicatedKeys||[],...s.duplicatedKeys||[]]):null;if(s.free.length===t.length)return{children:e,moves:null,duplicatedKeys:i};let n,h,u;if(i){let d=me(e,i);n=d.keys,h=d.free,u=me(t,i).keys}else n=r.keys,h=r.free,u=s.keys;let o=[],c=0,f=h.length,_=0;for(let d=0;d<t.length;d++){let y=t[d],S=St(y,i);if(S)if(Object.hasOwn(n,S)){let O=n[S];o.push(e[O])}else _++,o.push(null);else if(c<f){let O=h[c++];o.push(e[O])}else _++,o.push(null)}let l=c>=h.length?e.length:h[c];for(let d=0;d<e.length;d++){let y=e[d],S=St(y,i);if(S){if(!Object.hasOwn(u,S))o.push(y)}else if(d>=l)o.push(y)}let a=$o(o,e,n,i,_);return{children:o,moves:a,duplicatedKeys:i}}function $o(t,e,r,s,i){let n=t.slice(),h=0,u=[],o=[],c=Array(e.length);for(let f=0;f<e.length;f++)c[f]=St(e[f],s);for(let f=0;f<e.length;){let _=c[f],l=n[h],a=St(l,s);while(l===null&&n.length)n.splice(h,1),u.push({from:h,key:null}),l=n[h],a=St(l,s);if(l&&a===_){h++,f++;continue}if(_){if(a&&r[a]!==f+1){if(n.splice(h,1),u.push({from:h,key:a}),l=n[h],a=St(l,s),l&&a===_){h++,f++;continue}}o.push({key:_,to:f}),f++;continue}if(a){n.splice(h,1),u.push({from:h,key:a});continue}f++}while(h<n.length){let f=n[h];n.splice(h,1),u.push({from:h,key:St(f,s)})}if(u.length===i&&!o.length)return null;return{removes:u,inserts:o}}function me(t,e){let r={},s=[],i=null;for(let n=0;n<t.length;n++){let h=Mh(t[n]);if(h&&!e?.has(h)){if(h in r)i??=new Set,i.add(h);r[h]=n}else s.push(n)}return{keys:r,free:s,duplicatedKeys:i}}function Ko(t,e,r){let s=t.parentNode,i=e.toDom(r);if(s&&i&&i!==t)s.replaceChild(i,t);return i||t}function qh(t,e,r,s){if(e===r||e.isEqualTo(r))return t;if(e instanceof de&&r instanceof de||e instanceof Ht&&r instanceof Ht)return t.data=r.text,t;if(e instanceof Zt&&r instanceof Zt&&e.tag===r.tag&&e.namespace===r.namespace&&e.key===r.key){let i=Eh(e.attrs,r.attrs);if(i)Sh(t,i,e.attrs);return zh(t,e.childs,r.childs,e.tag,s),t}if(e instanceof N&&r instanceof N)return zh(t,e.childs,r.childs,null,s),t;return Ko(t,r,s)}function zh(t,e,r,s,i){if(e.length===0){for(let l of r){let a=l.toDom(i);if(a)t.appendChild(a)}return}if(r.length===0){while(t.firstChild)t.removeChild(t.firstChild);return}let n=Ao(e,r),h=n.children;if(n.duplicatedKeys&&i.onWarning)i.onWarning(new bh(n.duplicatedKeys,s,0));let u=Array.from(t.childNodes),o=e.length,c=h.length,f=Math.max(o,c),_=[];for(let l=0;l<f;l++){let a=e[l],d=h[l];if(!a&&d){let y=d.toDom(i);if(y)t.appendChild(y)}else if(a&&d){let y=u[l];if(y)qh(y,a,d,i)}else if(a&&!d){if(!n.moves&&u[l])_.push(u[l])}}for(let l of _)if(l.parentNode===t)t.removeChild(l);if(n.moves)Uo(t,n.moves)}function Uo(t,e){let r=t.childNodes,s={};for(let n of e.removes){let h=r[n.from];if(n.key)s[n.key]=h;t.removeChild(h)}let i=r.length;for(let n=0;n<e.inserts.length;n++){let h=e.inserts[n],u=s[h.key];if(u)t.insertBefore(u,h.to>=i++?null:r[h.to])}}var ke=new WeakMap;function jh(t,e,r){let s=ke.get(e),i=t instanceof N;if(s){let h=s.vnode instanceof N;if(h===i){let u=h?e:s.dom,o=qh(u,s.vnode,t,r);return ke.set(e,{vnode:t,dom:i?e:o}),o}ke.delete(e)}let n=t.toDom(r);if(n)e.innerHTML="",e.appendChild(n),ke.set(e,{vnode:t,dom:i?e:n});return n}function Ih(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(xs(o))i[o]=String(e[o]);else i[o]=e[o];let u=[];return Qs(u,r),new Zt(s,i,u,n,h)}var{raw:Mc,raw:Ec}=String;function qc(t,e){return new gr(t,e)}var Lo=(t)=>typeof t==="string"?document.querySelector(t):t;function jc(t){let e=Lo(t),r=new je,s=(o)=>new N(o),i=(o)=>new Ht(o),n={document},h=(o,c)=>jh(o,c,n),u=new Bs(r,Ih,s,i,h);return new Tr(e,h,r,u,ot)}async function Rc(t,e,r="margaui-css"){let s=performance.now(),i=await Do(t,e),n=performance.now();return Jr(r,i),n-s}async function Do(t,e){t.ParseContext=Ae,t.compile();let r=new Set;for(let s of t.comps.byId.values())for(let i in s.views){let n=s.views[i];for(let h of n.ctx.classes)r.add(h)}return await e(Array.from(r))}export{jc as tutuca,Fe as seqInfoByClass,qc as macro,Be as isOrderedMap,Be as isOMap,he as isMap,ts as isList,w as isKeyed,j as isIndexed,he as isIMap,Ec as html,Pe as fieldsByClass,Mc as css,ao as component,Do as compileClassesToStyleText,Rc as compileClassesToStyle,le as Record,ot as ParseContext,Y as OMap,U as List,zt as KList,E as ISet,x as IMap};
|
|
3
|
+
`)}}function Ai(t){return t}var $i=Symbol("STOP"),$r=Symbol("NEXT");class Ft{constructor(t,e){this.head=t,this.tail=e}push(t){return new Ft(t,this)}lookup(t,e=null){let{tail:r}=this,s=this.head.lookup(t);return s===$i?e:s===$r?r!==null?r.lookup(t,e):e:s}*[Symbol.iterator](){let t=this;while(t!==null)yield t.head,t=t.tail}}class Ir{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?$i:$r:e}}class Ar{constructor(t){this.bindings=t}lookup(t){let e=this.bindings[t];return e===void 0?$r:e}}class J{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 J(t,e.tail.head.it,e.tail,r,s,i)}static root(t,e,r){let s=new Ft(new Ir(e,{it:e},!0),null),i=new Ft(new Ar({}),null),n=new Ft("main",null);return new J(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 Ir(t,e,r));return new J(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 J(e,r,s,i,n.push(t),h)}withDynamicBindings(t){let e={},r=this.comps.getCompFor(this.it);for(let c of t)r.dynamic[c].evalAndBind(this,e);let{comps:s,it:i,binds:n,views:h,ctx:u}=this,o=this.dynBinds.push(new Ar(e));return new J(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){return this.comps.lookupComputed(this.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 Ki{constructor(t){this.value=t,this.changeSubs=[]}onChange(t){this.changeSubs.push(t)}set(t,e){let r=this.value;this.value=t;for(let s of this.changeSubs)s({value:t,old:r,info:e,timestamp:Date.now()})}update(t,e){return this.set(t(this.value),e)}}class Kr{constructor(t,e){this.comps=t,this.transactions=[],this.state=new Ki(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 Dr(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)??su(e),o=s?.onResName??e,c=(f,_,l,a,d)=>{let S=new Li(t,this,f??_,f?[l]:[a,d],i);return this.pushTransaction(S)};try{let f=await u.fn.apply(null,r);return c(s?.onOkName,o,f,f,null)}catch(f){return c(s?.onErrorName,o,f,null,f)}}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 Ui(t,e,r,this,s))}}function su(t){return()=>{throw Error(`Request not found: ${t}`)}}function iu(){return this}class Ur{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 J.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 nu=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac");function hu(t){return t.target.type==="checkbox"?t.target.checked:(t instanceof CustomEvent?t.detail:t.target.value)??null}class Ui extends Ur{constructor(t,e,r,s,i){super(t,s);this.e=e,this.handler=r,this.dragInfo=i}buildRootStack(t,e){return J.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 Rr(this.path,this.transactor,this),n[u]=n[u].toHandlerArg(h);return[i,n]}lookupName(t){let{e}=this;switch(t){case"value":return hu(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 nu&&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 Wr(this.path,this.transactor,this);case"dragInfo":return this.dragInfo}return null}}class Lr extends Ur{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]??iu}getHandlerAndArgs(t,e,r){return[this.getHandlerForName(r.getCompFor(e)),[...this.args,new Wr(this.path,this.transactor,this)]]}}class Li extends Lr{handlerProp="response"}class Dr extends Lr{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 Dr{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 Rr{constructor(t,e,r=null){this.path=t,this.transactor=e,this.parent=r}get at(){return new Wi(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 Wr extends Rr{stopPropagation(){return this.parent.stopPropagation()}}class Wi extends er{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 Tr{constructor(t,e,r,s,i){this.rootNode=t,this.comps=r,this.compStack=new Ie(r),this.transactor=new Kr(r,null),this.ParseContext=i,this.renderer=s,this.renderFn=e,this.maxEventNodeDepth=1/0,this._transactNextBatchId=this._evictCacheId=null,this._eventNames=new Set(["dragstart","dragover","dragend"]),this.dragInfo=this.curDragOver=null,this.transactor.onTransactionPushed=(n)=>{if(this._transactNextBatchId===null)this._scheduleNextTransactionBatchExecution()},this._compiled=!1}get state(){return this.transactor.state}handleEvent(t){let e=t.type==="dragstart",r=t.type==="dragover",s=t.type==="dragend",{rootNode:i,maxEventNodeDepth:n,comps:h}=this,u=!(r||e||s),[o,c]=V.fromEvent(t,i,n,h,u);if(r){let f=uu(t.target,this.rootNode,50);if(f!==null)t.preventDefault(),this._cleanDragOverAttrs(),this.curDragOver=f,f.dataset.draggingover=this.dragInfo.type}else if(e){t.target.dataset.dragging=1;let f=this.state.value,_=o.lookup(f),l=t.target.dataset.dragtype??"?",a=o.buildStack(this.makeStack(f));this.dragInfo=new Ti(o,a,t,_,l,t.target)}else if(s)delete this.dragInfo.node.dataset.dragging,this.dragInfo=null,this._cleanDragOverAttrs();if(o!==null&&c!==null)for(let f of c)this.transactor.transactInputNow(o,t,f,this.dragInfo)}makeStack(t){return J.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()}),Jr("tutuca-app",this.comps.compileStyles()),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 Jr(t,e){let r=document.createElement("style"),s=document.head.querySelector(`#${t}`);if(s)document.head.removeChild(s);r.id=t,r.innerHTML=e,document.head.appendChild(r)}function uu(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 Ti{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 Ae extends ot{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,f=new Ae(s,i,n,h,u,o,{macroName:t,macroVars:e,macroSlots:r},this);return f.classes=this.classes,f}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),h)this._addClasses(h.value)}else if(typeof i?.value==="string")this._addClasses(i.value)}else{let s=t.items.class;if(s)this._addClasses(s)}}}function mt(t,e){if(!t)throw Error(e)}function A(t){mt(t!==1/0,"Cannot perform this action with an infinite size.")}function Ji(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 ou=(t,e)=>e,cu=(t,e)=>[e,t],Xr=(t)=>function(...e){return!t.apply(this,e)},Xi=(t)=>function(...e){return-t.apply(this,e)};function un(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 Hi=(t,e)=>t<e?1:t>e?-1:0,$={done:!0,value:void 0};class on{constructor(t){this.next=t}[Symbol.iterator](){return this}}function L(t){return new on(t)}function M(t){let e=[void 0,void 0],r={done:!1,value:void 0};return L(()=>{if(t(e))return r.value=[e[0],e[1]],r;return $})}var fu=L(()=>$),ct=()=>fu;function Xe(t){let e=0,r={done:!1,value:void 0};return L(()=>{if(e===t)return $;return r.value=e++,r})}function ee(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 cn(t){if(Array.isArray(t))return!0;return!!He(t)}var _u=(t)=>!!(t&&typeof t.next==="function");function fn(t){return He(t)?.call(t)}function He(t){let e=t&&t[Symbol.iterator];if(typeof e==="function")return e}function lu(t){let e=He(t);return e&&e===t.entries}function au(t){let e=He(t);return e&&e===t.keys}var re="delete",z=5,q=1<<z,K=q-1,p={},Cr=()=>({value:!1});function T(t){if(t)t.value=!0}class Ze{}function At(t){if(t.size===void 0)t.size=t.__iterate(_n);return t.size}function et(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 _n=()=>!0,ln=(t)=>t<0||Object.is(t,-0),se=(t,e,r)=>(t===0&&!ln(t)||r!==void 0&&(t??0)<=-r)&&(e===void 0||r!==void 0&&e>=r),an=(t,e,r)=>t===void 0?r:ln(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)=>an(t,e,0),ie=(t,e)=>an(t,e,e),dn="@@__IMMUTABLE_ITERABLE__@@",Le="@@__IMMUTABLE_KEYED__@@",De="@@__IMMUTABLE_INDEXED__@@",rt="@@__IMMUTABLE_ORDERED__@@",ne="@@__IMMUTABLE_SEQ__@@",yn="@@__IMMUTABLE_LIST__@@",pn="@@__IMMUTABLE_MAP__@@",gn="@@__IMMUTABLE_SET__@@",wn="@@__IMMUTABLE_STACK__@@",zn="@@__IMMUTABLE_RECORD__@@";function C(t,e){return typeof t==="object"&&t!==null&&e in t}var R=(t)=>C(t,dn),w=(t)=>C(t,Le),j=(t)=>C(t,De),Vr=(t)=>w(t)||j(t),F=(t)=>C(t,rt),vr=(t)=>C(t,ne),ts=(t)=>C(t,yn),he=(t)=>C(t,pn),es=(t)=>C(t,gn),rs=(t)=>C(t,wn),at=(t)=>C(t,zn),P=(t)=>R(t)||at(t),Be=(t)=>he(t)&&F(t),Sn=(t)=>es(t)&&F(t),Zi=(t)=>typeof t==="object"&&t!==null&&typeof t.equals==="function"&&typeof t.hashCode==="function";function On(t){let e=G(t);return e._iter=t,e.size=t.size,e.flip=()=>t,e.reverse=function(){let r=t.reverse.call(this);return r.flip=()=>t.reverse(),r},e.has=(r)=>t.includes(r),e.includes=(r)=>t.has(r),e.cacheResult=Tt,e.__iterate=function(r,s){return t.__iterate((i,n)=>r(n,i,this),s)},e.__iteratorUncached=function(r){return ee(t.__iterator(r),(s,i,n)=>{n[0]=i,n[1]=s})},e}function bn(t,e,r){let s=G(t);return s.size=t.size,s.has=(i)=>t.has(i),s.get=(i,n)=>{let h=t.get(i,p);return h===p?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 ee(t.__iterator(i),(n,h,u)=>{u[0]=n,u[1]=e.call(r,h,n,t)})},s}function Mn(t,e){let r=G(t);if(r._iter=t,r.size=t.size,r.reverse=()=>t,t.flip)r.flip=function(){let s=On(t);return s.reverse=()=>t.flip(),s};return r.get=(s,i)=>t.get(e?s:-1-s,i),r.has=(s)=>t.has(e?s:-1-s),r.includes=(s)=>t.includes(s),r.cacheResult=Tt,r.__iterate=function(s,i){let n=0;if(i)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 ee(t.__iterator(!s),(h,u,o)=>{o[0]=e?h:s?n-++i:i++,o[1]=u})},r}function En(t,e,r,s){let i=t.size;if(se(e,r,i))return t;if(i===void 0&&(e<0||r<0))return En(t.toSeq().cacheResult(),e,r,s);let n=Rt(e,i),u=ie(r,i)-n,o;if(!Number.isNaN(u))o=Math.max(0,u);let c=G(t);if(c.size=o===0?o:t.size&&o||void 0,!s&&vr(t)&&o>=0)c.get=function(f,_){return f=et(this,f),f>=0&&f<o?t.get(f+n,_):_};return c.__iterateUncached=function(f,_){if(o!==0&&_)return this.cacheResult().__iterate(f,_);if(o===0)return 0;let l=0,a=0;return t.__iterate((d,y)=>{if(l<n){l++;return}if(o!==void 0&&a>=o)return!1;if(a++,f(d,s?y:a-1,this)===!1)return!1},_),a},c.__iteratorUncached=function(f){if(o!==0&&f)return this.cacheResult().__iterator(f);if(o===0)return ct();let _=t.__iterator(f),l=0,a=0;if(s)return L(()=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return $;let d=_.next();if(d.done)return d;return a++,d});return M((d)=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return!1;let y=_.next();if(y.done)return!1;return a++,d[0]=a-1,d[1]=y.value[1],!0})},c}function Bi(t,e,r){if(!e)e=un;let s=w(t),i=0,n=t.toSeq().map((h,u)=>[u,h,i++,r?r(h,u,t):h]).valueSeq().toArray();return n.sort((h,u)=>e(h[3],u[3])||h[2]-u[2]).forEach(s?(h,u)=>{n[u].length=2}:(h,u)=>{n[u]=h[1]}),s?us(n):j(t)?lt(n):Nt(n)}function $e(t,e,r){if(!e)e=un;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 Hr(t,e,r,s){let i=G(t),n=new ue(r).map((h)=>h.size);return i.size=s?n.max():n.min(),i.__iterate=function(h,u){let o=this.__iterator(u),c=0,f;while(!(f=o.next()).done)if(h(f.value[1],c++,this)===!1)break;return c},i.__iteratorUncached=function(h){let u=r.map((_)=>{let l=m(_);return fn(h?l.reverse():l)}),o=0,c=Array(u.length),f=Array(u.length);return M((_)=>{let l=s;for(let a=0;a<u.length;a++)c[a]=u[a].next(),l=s?l&&c[a].done:l||c[a].done;if(l)return!1;for(let a=0;a<c.length;a++)f[a]=c[a].value;return _[0]=o++,_[1]=e(...f),!0})},i}function qn(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 du(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 st=(t)=>typeof t==="object"&&(P(t)||Array.isArray(t)||du(t));function jn(t){if(qn(t)&&typeof t!=="string")return t;if(F(t))return t.toArray();throw TypeError(`Invalid keyPath: expected Ordered Collection or Array: ${t}`)}var yu=(t,e)=>P(t)?t.has(e):st(t)&&Object.hasOwn(t,e);function In(t,e,r){return P(t)?t.get(e,r):!yu(t,e)?r:typeof t.get==="function"?t.get(e):t[e]}function ss(t,e,r){let s=jn(e),i=0;while(i!==s.length)if(t=In(t,s[i++],p),t===p)return r;return t}var An=(t,e)=>ss(t,e,p)!==p;function I(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!!(Zi(t)&&Zi(e)&&t.equals(e))}function Re(t){if(!t||typeof t!=="object")return t;if(!R(t)){if(!st(t))return t;t=it(t)}if(w(t)){let r={};return t.__iterate((s,i)=>{r[String(i)]=Re(s)}),r}let e=[];return t.__iterate((r)=>{e.push(Re(r))}),e}function is(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||w(t)!==w(e)||j(t)!==j(e)||F(t)!==F(e))return!1;if(t.size===0&&e.size===0)return!0;let r=!Vr(t);if(F(t)){let h=t.entries();return!!(e.every((u,o)=>{let c=h.next().value;return c&&I(c[1],u)&&(r||I(c[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?!I(h,t.get(u,p)):!I(t.get(u,p),h))return i=!1,!1;return!0});return i&&t.size===n}var xe=(t)=>t>>>1&1073741824|t&3221225471;function X(t){if(t===null||t===void 0)return Qi(t);if(typeof t.hashCode==="function")return xe(t.hashCode(t));let e=Su(t);if(e===null||e===void 0)return Qi(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return pu(e);case"string":return e.length>Ou?gu(e):Pr(e);case"object":case"function":return zu(e);case"symbol":return wu(e);default:if(typeof e.toString==="function")return Pr(e.toString());throw Error(`Value type ${typeof e} cannot be hashed.`)}}var Qi=(t)=>t===null?1108378658:1108378659;function pu(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 xe(e)}function gu(t){let e=xr[t];if(e===void 0){if(e=Pr(t),Br===bu)Br=0,xr={};Br++,xr[t]=e}return e}function Pr(t){let e=0;for(let r=0;r<t.length;r++)e=31*e+t.charCodeAt(r)|0;return xe(e)}function wu(t){let e=Yi[t];if(e!==void 0)return e;return e=$n(),Yi[t]=e,e}function zu(t){let e=Gi.get(t);if(e!==void 0)return e;return e=$n(),Gi.set(t,e),e}var Su=(t)=>t.valueOf!==Object.prototype.valueOf?t.valueOf():t;function $n(){let t=++Zr;if(Zr&1073741824)Zr=0;return t}var Gi=new WeakMap,Yi=Object.create(null),Zr=0,Ou=16,bu=255,Br=0,xr={};function Mu(t){if(t.size===1/0)return 0;let e=F(t),r=w(t),s=e?1:0;return t.__iterate(r?e?(i,n)=>{s=31*s+Ci(X(i),X(n))|0}:(i,n)=>{s=s+Ci(X(i),X(n))|0}:e?(i)=>{s=31*s+X(i)|0}:(i)=>{s=s+X(i)|0}),Eu(t.size,s)}var Ci=(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=xe(e^e>>>16),e}function kt(t){try{return typeof t==="string"?JSON.stringify(t):String(t)}catch{return JSON.stringify(t)}}var b=(t,e)=>t===e?t:vr(t)?e:t.create?t.create(e):t.constructor(e),qu=(t,e)=>b(t,(w(t)?Z:j(t)?dt:yt)(e)),Pi=(...t)=>t,m=(t)=>R(t)?t:it(t);class H{size=0;static{this.prototype[dn]=!0,this.prototype.__toStringMapper=kt,this.prototype[Symbol.iterator]=this.prototype.values,this.prototype.toJSON=this.prototype.toArray,this.prototype.contains=this.prototype.includes}equals(t){return is(this,t)}hashCode(){return this.__hash??(this.__hash=Mu(this))}toArray(){A(this.size);let t=Array(this.size||0),e=w(this),r=0;return this.__iterate((s,i)=>{t[r++]=e?[i,s]:s}),t}toIndexedSeq(){return new Rn(this)}toJS(){return Re(this)}toKeyedSeq(){return new ls(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 Wn(this)}toSeq(){return j(this)?this.toIndexedSeq():w(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=w(this),r=[this,...t].map((s)=>{if(!R(s))s=e?Un(s):Ln(Array.isArray(s)?s:[s]);else if(e)s=Z(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&&w(s)||j(this)&&j(s))return s}return b(this,new Dn(r))}includes(t){return this.some((e)=>I(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=w(this),i=G(r);if(s)i.has=(n)=>{let h=r.get(n,p);return h!==p&&!!t.call(e,h,n,r)},i.get=(n,h)=>{let u=r.get(n,p);return u!==p&&t.call(e,u,n,r)?u:h};return i.__iterateUncached=function(n,h){let u=0;return r.__iterate((o,c)=>{if(t.call(e,o,c,r))return u++,n(o,s?c:u-1,this)},h),u},i.__iteratorUncached=function(n){let h=r.__iterator(n),u=0;return M((o)=>{while(!0){let c=h.next();if(c.done)return!1;let f=c.value[0],_=c.value[1];if(t.call(e,_,f,r))return o[0]=s?f:u++,o[1]=_,!0}})},b(this,i)}partition(t,e){let r=w(this),s=[[],[]];return this.__iterate((i,n)=>{s[t.call(e,i,n,this)?1:0].push(r?[n,i]:i)}),s.map((i)=>qu(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 L(()=>{let r=t.next();if(r.done)return $;return e.value=r.value[0],e})}map(t,e){return b(this,bn(this,t,e))}reduce(t,e=p,r){return Ji(this,t,e,r,e===p,!1)}reduceRight(t,e=p,r){return Ji(this,t,e,r,e===p,!0)}reverse(){return b(this,Mn(this,w(this)))}slice(t,e){return b(this,En(this,t,e,w(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 b(this,Bi(this,t))}values(){let t=this.__iterator(),e={done:!1,value:void 0};return L(()=>{let r=t.next();if(r.done)return $;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 ue(t._cache);let e=t.toSeq().map(cu).toIndexedSeq();return e.fromEntrySeq=()=>t.toSeq(),e}filterNot(t,e){return this.filter(Xr(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(_n,null,t)}flatMap(t,e){return b(this,this.toSeq().map((r,s)=>(w(this)?Z:j(this)?dt:yt)(t.call(e,r,s,this))).flatten(!0))}flatten(t){let e=this,r=w(this),s=G(e);return s.__iterateUncached=function(i,n){if(n)return this.cacheResult().__iterate(i,n);let h=0,u=!1;function o(c,f){c.__iterate((_,l)=>{if((!t||f<t)&&R(_))o(_,f+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],c=o.iterator.next();if(c.done){h.pop();continue}let f=c.value[1];if((!t||o.depth<t)&&R(f)){h.push({iterator:f.__iterator(i),depth:o.depth+1});continue}return u[0]=r?c.value[0]:n++,u[1]=f,!0}return!1})},b(this,s)}fromEntrySeq(){return new Tn(this)}get(t,e){return this.find((r,s)=>I(s,t),void 0,e)}getIn(t,e){return ss(this,t,e)}groupBy(t,e){throw Error("groupBy: not patched — import CollectionConversions")}has(t){return this.get(t,p)!==p}hasIn(t){return An(this,t)}isSubset(t){let e=typeof t.includes==="function"?t:m(t);return this.every((r)=>e.includes(r))}isSuperset(t){return(typeof t.isSubset==="function"?t:m(t)).isSubset(this)}keyOf(t){return this.findKey((e)=>I(e,t))}keySeq(){return this.toSeq().map(ou).toIndexedSeq()}last(t){return this.toSeq().reverse().first(t)}lastKeyOf(t){return this.toKeyedSeq().reverse().keyOf(t)}max(t){return $e(this,t)}maxBy(t,e){return $e(this,e,t)}min(t){return $e(this,t?Xi(t):Hi)}minBy(t,e){return $e(this,e?Xi(e):Hi,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=w(this),i=G(r);return i.__iterateUncached=function(n,h){if(h)return this.cacheResult().__iterate(n,h);let u=!0,o=0;return r.__iterate((c,f)=>{if(u&&t.call(e,c,f,this))return;return u=!1,o++,n(c,s?f: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,c=!0;return M((f)=>{while(!0){let _=h.next();if(_.done)return!1;let l=_.value[0],a=_.value[1];if(c&&t.call(e,a,l,o))continue;return c=!1,f[0]=s?l:u++,f[1]=a,!0}})},b(this,i)}skipUntil(t,e){return this.skipWhile(Xr(t),e)}sortBy(t,e){return b(this,Bi(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=G(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 L(()=>{if(u)return $;let o=n.next();if(o.done)return o;if(!t.call(e,o.value[1],o.value[0],h))return u=!0,$;return o})},b(this,s)}takeUntil(t,e){return this.takeWhile(Xr(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 Z=(t)=>w(t)?t:us(t);class ns extends H{static{this.prototype[Le]=!0,this.prototype.__toStringMapper=(t,e)=>`${kt(e)}: ${kt(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 b(this,On(this))}mapEntries(t,e){let r=0;return b(this,this.toSeq().map((s,i)=>t.call(e,[i,s],r++,this)).fromEntrySeq())}mapKeys(t,e){return b(this,this.toSeq().flip().map((r,s)=>t.call(e,r,s,this)).flip())}}var dt=(t)=>j(t)?t:lt(t);class $t extends H{static{this.prototype[De]=!0,this.prototype[rt]=!0}toKeyedSeq(){return new ls(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=p,...r){if(t===void 0)return this;let s=e!==p;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 b(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=et(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=et(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=G(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((c)=>{if(o)return o=!1,c[0]=n++,c[1]=u,!0;let f=i.next();if(f.done)return!1;let _=f.value[1];if(!h)return u=_,o=!0,c[0]=n++,c[1]=t,!0;return h=!1,c[0]=n++,c[1]=_,!0})},b(this,r)}interleave(...t){let e=[this,...t],r=Hr(this.toSeq(),lt.of,e),s=r.flatten(!0);if(r.size)s.size=r.size*e.length;return b(this,s)}keySeq(){throw Error("keySeq: not patched — import CollectionConversions")}last(t){return this.get(-1,t)}zip(...t){return this.zipWith(Pi,...t)}zipAll(...t){let e=[this,...t];return b(this,Hr(this,Pi,e,!0))}zipWith(t,...e){let r=[this,...e];return b(this,Hr(this,t,r))}}var yt=(t)=>R(t)&&!Vr(t)?t:Nt(t);class Qe extends H{static{this.prototype.has=H.prototype.includes,this.prototype.contains=H.prototype.includes,this.prototype.keys=Qe.prototype.values}get(t,e){return this.has(t)?t:e}includes(t){return this.has(t)}keySeq(){return this.valueSeq()}}m.Keyed=Z;m.Indexed=dt;m.Set=yt;var Qr=$t.prototype,it=(t)=>t===void 0||t===null?fs():P(t)?t.toSeq():ju(t),G=(t)=>Object.create((w(t)?Wt:j(t)?pt:os).prototype);class ft extends H{static{this.prototype[ne]=!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 L(()=>{if(s===r)return $;return i.value=e[t?r-++s:s++],i})}return this.__iteratorUncached(t)}}var hs={cacheResult:ft.prototype.cacheResult,__iterateUncached:ft.prototype.__iterateUncached,__iterate:ft.prototype.__iterate,__iterator:ft.prototype.__iterator},us=(t)=>t===void 0||t===null?fs().toKeyedSeq():R(t)?w(t)?t.toSeq():t.fromEntrySeq():at(t)?t.toSeq():Un(t);class Wt extends ns{static{this.prototype[ne]=!0,Object.assign(this.prototype,hs)}toSeq(){return this}toKeyedSeq(){return this}}var lt=(t)=>t===void 0||t===null?fs():R(t)?w(t)?t.entrySeq():t.toIndexedSeq():at(t)?t.toSeq().entrySeq():Ln(t);lt.of=(...t)=>lt(t);class pt extends $t{static{this.prototype[ne]=!0,Object.assign(this.prototype,hs)}toSeq(){return this}toIndexedSeq(){return this}toString(){return this.__toString("Seq [","]")}}var Nt=(t)=>(R(t)&&!Vr(t)?t:lt(t)).toSetSeq();Nt.of=(...t)=>Nt(t);class os extends Qe{static{this.prototype[ne]=!0,Object.assign(this.prototype,hs)}toSeq(){return this}toSetSeq(){return this}}it.isSeq=vr;it.Keyed=us;it.Set=Nt;it.Indexed=lt;class ue extends pt{constructor(t){super();this._array=t,this.size=t.length}get(t,e){return this.has(t)?this._array[et(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 cs extends Wt{static{this.prototype[rt]=!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 Kn extends pt{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=fn(e);if(!_u(r))return ct();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 fs=()=>new ue([]),_s=(t)=>qn(t)?new ue(t):cn(t)?new Kn(t):void 0;function Un(t){let e=_s(t);if(e)return e.fromEntrySeq();if(typeof t==="object")return new cs(t);throw TypeError(`Expected Array or collection object of [k, v] entries, or keyed object: ${t}`)}function Ln(t){let e=_s(t);if(e)return e;throw TypeError(`Expected Array or collection object of values: ${t}`)}function ju(t){let e=_s(t);if(e)return lu(t)?e.fromEntrySeq():au(t)?e.toSetSeq():e;if(typeof t==="object")return new cs(t);throw TypeError(`Expected Array or collection object of values, or keyed object: ${t}`)}class Dn extends ft{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[Le])this[Le]=!0;if(i[De])this[De]=!0;if(i[rt])this[rt]=!0}__iterateUncached(t,e){if(this._wrappedIterables.length===0)return 0;if(e)return this.cacheResult().__iterate(t,e);let r=this._wrappedIterables,s=!w(this),i=0,n=!1;for(let h of r)if(h.__iterate((u,o)=>{if(t(u,s?i++:o,this)===!1)return n=!0,!1},e),n)break;return i}__iteratorUncached(t){if(this._wrappedIterables.length===0)return ct();if(t)return this.cacheResult().__iterator(t);let e=this._wrappedIterables,r=!w(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 L(()=>n()||$)}}class ls extends Wt{static{this.prototype[rt]=!0}constructor(t,e){super();this._iter=t,this._useKeys=e,this.size=t.size}cacheResult(){return Tt.call(this)}get(t,e){return this._iter.get(t,e)}has(t){return this._iter.has(t)}valueSeq(){return this._iter.valueSeq()}reverse(){let t=Mn(this,!0);if(!this._useKeys)t.valueSeq=()=>this._iter.toSeq().reverse();return t}map(t,e){let r=bn(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 pt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Tt.call(this)}includes(t){return this._iter.includes(t)}__iterateUncached(t,e){let r=0;if(e)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 ee(this._iter.__iterator(t),(s,i,n)=>{n[0]=t?r-++e:e++,n[1]=i})}}class Wn extends os{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Tt.call(this)}has(t){return this._iter.includes(t)}__iterateUncached(t,e){return this._iter.__iterate((r)=>t(r,r,this),e)}__iteratorUncached(t){return ee(this._iter.__iterator(t),(e,r,s)=>{s[0]=r,s[1]=r})}}class Tn extends Wt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Tt.call(this)}entrySeq(){return this._iter.toSeq()}__iterateUncached(t,e){let r=0;return this._iter.__iterate((s)=>{if(s){Fi(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){Fi(i);let n=R(i);return r[0]=n?i.get(0):i[0],r[1]=n?i.get(1):i[1],!0}}})}}function Tt(){if(this._iter.cacheResult)return this._iter.cacheResult(),this.size=this._iter.size,this;return ft.prototype.cacheResult.call(this)}function Fi(t){if(t!==Object(t))throw TypeError(`Expected [K, V] tuple: ${t}`)}var x=(t)=>t===void 0||t===null?B():he(t)&&!F(t)?t:B().withMutations((e)=>{let r=Z(t);A(r.size),r.forEach((s,i)=>e.set(i,s))});class as extends ns{static{wt(this,{asImmutable:oe,asMutable:ce,deleteIn:Kt,merge:Fr,mergeWith:Qn,mergeDeep:Yn,mergeDeepWith:Cn,mergeDeepIn:js,mergeIn:qs,setIn:bs,update:Ms,updateIn:Es,wasAltered:Os,withMutations:fe,removeIn:Kt,concat:Fr,[pn]:!0,[re]: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 x(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 ki(this,t,e)}remove(t){return ki(this,t,p)}deleteAll(t){let e=m(t);if(e.size===0)return this;return this.withMutations((r)=>{e.forEach((s)=>r.remove(s))})}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this;return B()}map(t,e){return this.withMutations((r)=>{r.forEach((s,i)=>{r.set(i,t.call(e,s,i,this))})})}keys(){if(!this._root)return ct();return Ke(this._root,!1,0)}values(){if(!this._root)return ct();return Ke(this._root,!1,1)}entries(){if(!this._root)return ct();return Ke(this._root,!1)}__iterator(t){if(!this._root)return ct();return Ke(this._root,t)}__iterate(t,e){let r=0;if(this._root)this._root.iterate(([s,i])=>{return r++,t(i,s,this)},e);return r}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return B();return this.__ownerID=t,this.__altered=!1,this}return ps(this.size,this._root,t,this.__hash)}}x.isMap=he;class ds{constructor(t,e){this.ownerID=t,this.entries=e}get(t,e,r,s){return Jn(this.entries,r,s)}iterate(t,e){return Xn(this.entries,t,e)}update(t,e,r,s,i,n,h){let u=i===p,o=this.entries,c=0,f=o.length;for(;c<f;c++)if(I(s,o[c][0]))break;let _=c<f;if(_?o[c][1]===i:u)return this;if(T(h),u||!_)T(n);if(u&&f===1)return;if(!_&&!u&&f>=Lu)return Iu(t,o,s,i);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(c===f-1)a.pop();else a[c]=a.pop();else a[c]=[s,i];else a.push([s,i]);if(l)return this.entries=a,this;return new ds(t,a)}}class Ge{constructor(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}iterate(t,e){return Hn(this.nodes,t,e)}get(t,e,r,s){let i=1<<((t===0?e:e>>>t)&K),n=this.bitmap;return(n&i)===0?s:this.nodes[Vi(n&i-1)].get(t+z,e,r,s)}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&K,o=1<<u,c=this.bitmap,f=(c&o)!==0;if(!f&&i===p)return this;let _=Vi(c&o-1),l=this.nodes,a=f?l[_]:void 0,d=gs(a,t,e+z,r,s,i,n,h);if(d===a)return this;if(!f&&d&&l.length>=Du)return $u(t,l,c,u,d);if(f&&!d&&l.length===2&&Ni(l[_^1]))return l[_^1];if(f&&d&&l.length===1&&Ni(d))return d;let y=t&&t===this.ownerID,S=f?d?c:c^o:c|o,O=f?d?Zn(l,_,d,y):Uu(l,_,y):Ku(l,_,d,y);if(y)return this.bitmap=S,this.nodes=O,this;return new Ge(t,S,O)}}class ys{constructor(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}iterate(t,e){return Hn(this.nodes,t,e)}get(t,e,r,s){let i=(t===0?e:e>>>t)&K,n=this.nodes[i];return n?n.get(t+z,e,r,s):s}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&K,o=i===p,c=this.nodes,f=c[u];if(o&&!f)return this;let _=gs(f,t,e+z,r,s,i,n,h);if(_===f)return this;let l=this.count;if(!f)l++;else if(!_){if(l--,l<Ru)return Au(t,c,l,u)}let a=t&&t===this.ownerID,d=Zn(c,u,_,a);if(a)return this.count=l,this.nodes=d,this;return new ys(t,l,d)}}class Ye{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}get(t,e,r,s){return Jn(this.entries,r,s)}iterate(t,e){return Xn(this.entries,t,e)}update(t,e,r,s,i,n,h){if(r!==this.keyHash){if(i===p)return this;return T(h),T(n),ws(this,t,e,r,[s,i])}let u=i===p,o=this.entries,c=0,f=o.length;for(;c<f;c++)if(I(s,o[c][0]))break;let _=c<f;if(_?o[c][1]===i:u)return this;if(T(h),u||!_)T(n);if(u&&f===2)return new gt(t,this.keyHash,o[c^1]);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(c===f-1)a.pop();else a[c]=a.pop();else a[c]=[s,i];else a.push([s,i]);if(l)return this.entries=a,this;return new Ye(t,this.keyHash,a)}}class gt{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 I(r,this.entry[0])?this.entry[1]:s}update(t,e,r,s,i,n,h){let u=i===p,o=I(s,this.entry[0]);if(o?i===this.entry[1]:u)return this;if(T(h),u){T(n);return}if(o){if(t&&t===this.ownerID)return this.entry[1]=i,this;return new gt(t,this.keyHash,[s,i])}return T(n),ws(this,t,e,X(s),[s,i])}}function Jn(t,e,r){for(let s=0,i=t.length;s<i;s++)if(I(e,t[s][0]))return t[s][1];return r}function Xn(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 Hn(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 Ke(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 L(()=>{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 c=h.nodes[e?o-u:u];if(c){if(c.entry)return n.value=i(c.entry),n;s={node:c,index:0,__prev:s}}continue}s=s.__prev}return $})}var ps=(t,e,r,s)=>new as(t,e,r,s),mi,B=()=>mi||(mi=ps(0));function ki(t,e,r){let s,i;if(!t._root){if(r===p)return t;i=1,s=new ds(t.__ownerID,[[e,r]])}else{let n=Cr(),h=Cr();if(s=gs(t._root,t.__ownerID,0,X(e),e,r,n,h),!h.value)return t;i=t.size+(n.value?r===p?-1:1:0)}if(t.__ownerID)return t.size=i,t._root=s,t.__hash=void 0,t.__altered=!0,t;return s?ps(i,s):B()}function gs(t,e,r,s,i,n,h,u){if(!t){if(n===p)return t;return T(u),T(h),new gt(e,s,[i,n])}return t.update(e,r,s,i,n,h,u)}var Ni=(t)=>t.constructor===gt||t.constructor===Ye;function ws(t,e,r,s,i){if(t.keyHash===s)return new Ye(e,s,[t.entry,i]);let n=(r===0?t.keyHash:t.keyHash>>>r)&K,h=(r===0?s:s>>>r)&K,u=new gt(e,s,i),o=n===h?[ws(t,e,r+z,s,i)]:n<h?[t,u]:[u,t];return new Ge(e,1<<n|1<<h,o)}function Iu(t,e,r,s){if(!t)t=new Ze;let i=new gt(t,X(r),[r,s]);for(let[n,h]of e)i=i.update(t,0,X(n),n,h);return i}function Au(t,e,r,s){let i=0,n=0,h=Array(r);for(let u=0,o=1,c=e.length;u<c;u++,o<<=1){let f=e[u];if(f!==void 0&&u!==s)i|=o,h[n++]=f}return new Ge(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 ys(t,n+1,h)}function Vi(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 Zn(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 Uu(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 Lu=q/4,Du=q/2,Ru=q/4;function We(t){if(Array.isArray(t))return t.slice();return{...t}}var zs=(t,e,r)=>Ss(t,e,Wu(r));function Ss(t,e,r){if(!st(t))throw TypeError(`Cannot merge into non-data-structure value: ${t}`);if(P(t))return typeof r==="function"&&t.mergeWith?t.mergeWith(r,...e):t.merge?t.merge(...e):t.concat(...e);let s=Array.isArray(t),i=t,n=s?dt:Z,h=s?(u)=>{if(i===t)i=We(i);i.push(u)}:(u,o)=>{let c=Object.hasOwn(i,o),f=c&&r?r(i[o],u,o):u;if(!c||f!==i[o]){if(i===t)i=We(i);i[o]=f}};for(let u of e)n(u).forEach(h);return i}function Wu(t){function e(r,s,i){return st(r)&&st(s)&&Tu(r,s)?Ss(r,[s],e):t?t(r,s,i):s}return e}function Tu(t,e){let r=it(t),s=it(e);return j(r)===j(s)&&w(r)===w(s)}function Ju(t,e){if(!st(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(P(t)){if(!t.remove)throw TypeError(`Cannot update immutable value without .remove() method: ${t}`);return t.remove(e)}if(!Object.hasOwn(t,e))return t;let r=We(t);if(Array.isArray(r))r.splice(e,1);else delete r[e];return r}function Xu(t,e,r){if(!st(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(P(t)){if(!t.set)throw TypeError(`Cannot update immutable value without .set() method: ${t}`);return t.set(e,r)}if(Object.hasOwn(t,e)&&r===t[e])return t;let s=We(t);return s[e]=r,s}function Jt(t,e,r,s){if(!s)s=r,r=void 0;let i=Bn(P(t),t,jn(e),0,r,s);return i===p?r:i}function Bn(t,e,r,s,i,n){let h=e===p;if(s===r.length){let _=h?i:e,l=n(_);return l===_?e:l}if(!h&&!st(e))throw TypeError(`Cannot update within non-data-structure value in path [${Array.from(r).slice(0,s).map(kt)}]: ${e}`);let u=r[s],o=h?p:In(e,u,p),c=Bn(o===p?t:P(o),o,r,s+1,i,n);if(c===o)return e;if(c===p)return Ju(e,u);let f=h?t?B():{}:e;return Xu(f,u,c)}var Hu=(t,e)=>Jt(t,e,()=>p),Zu=(t,e,r)=>Jt(t,e,p,()=>r);function xn(t,e,r,s){return Jt(t,[e],r,s)}function oe(){return this.__ensureOwner()}function ce(){return this.__ownerID?this:this.__ensureOwner(new Ze)}function Os(){return this.__altered}function fe(t){let e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Bu(t,e){return ss(this,t,e)}function xu(t){return An(this,t)}function Kt(t){return Hu(this,t)}function bs(t,e){return Zu(this,t,e)}function Ms(t,e,r){return typeof t==="function"?t(this):xn(this,t,e,r)}function Es(t,e,r){return Jt(this,t,e,r)}function vi(){A(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}function Fr(...t){return Gn(this,t)}function Qn(t,...e){if(typeof t!=="function")throw TypeError(`Invalid merger function: ${t}`);return Gn(this,e,t)}function Gn(t,e,r){let s=[];for(let i of e){let n=Z(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,p,(o)=>o===p?h:r(o,h,u))}:(h,u)=>{i.set(u,h)};for(let h of s)h.forEach(n)})}function Yn(...t){return zs(this,t)}function Cn(t,...e){return zs(this,e,t)}function qs(t,...e){return Jt(this,t,B(),(r)=>Ss(r,e))}function js(t,...e){return Jt(this,t,B(),(r)=>zs(r,e))}function wt(t,e){Object.assign(t.prototype,e)}var U=(t)=>{let e=Vt();if(t===void 0||t===null)return e;if(ts(t))return t;let r=dt(t),s=r.size;if(s===0)return e;if(A(s),s>0&&s<q)return _e(0,s,z,null,new _t(r.toArray()));return e.withMutations((i)=>{i.setSize(s),r.forEach((n,h)=>i.set(h,n))})};U.of=(...t)=>U(t);class Pn extends $t{static{wt(this,{asImmutable:oe,asMutable:ce,deleteIn:Kt,mergeDeepIn:js,mergeIn:qs,setIn:bs,update:Ms,updateIn:Es,wasAltered:Os,withMutations:fe,removeIn:Kt,[yn]:!0,[re]:this.prototype.remove,merge:this.prototype.concat,[Symbol.toStringTag]:"Immutable.List",[Symbol.iterator]:this.prototype.values})}constructor(t,e,r,s,i,n,h){super();this.size=e-t,this._origin=t,this._capacity=e,this._level=r,this._root=s,this._tail=i,this.__ownerID=n,this.__hash=h,this.__altered=!1}create(t){return U(t)}toString(){return this.__toString("List [","]")}get(t,e){if(t=et(this,t),t>=0&&t<this.size){t+=this._origin;let r=kn(this,t);return r&&r.array[t&K]}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=z,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this;return Vt()}push(...t){let e=this.size;return this.withMutations((r)=>{tt(r,0,e+t.length);for(let s=0;s<t.length;s++)r.set(e+s,t[s])})}pop(){return tt(this,0,-1)}unshift(...t){return this.withMutations((e)=>{tt(e,-t.length);for(let r=0;r<t.length;r++)e.set(r,t[r])})}shift(){return tt(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=dt(typeof r!=="string"&&cn(r)?r:[r]);if(s.size!==0)e.push(s)}if(e.length===0)return this;if(this.size===0&&!this.__ownerID&&e.length===1)return U(e[0]);return this.withMutations((r)=>{e.forEach((s)=>s.forEach((i)=>r.push(i)))})}setSize(t){return tt(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(se(t,e,r))return this;return tt(this,Rt(t,r),ie(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=tn(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 tn(this,!1)}keys(){return Xe(this.size)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return Vt();return this.__ownerID=t,this.__altered=!1,this}return _e(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash)}}U.isList=ts;class _t{constructor(t,e){this.array=t,this.ownerID=e}removeBefore(t,e,r){if((r&(1<<e+z)-1)===0||this.array.length===0)return this;let s=r>>>e&K;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-z,r),n===u&&i)return this}if(i&&!n)return this;let h=Ut(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+z:q)||this.array.length===0)return this;let s=r-1>>>e&K;if(s>=this.array.length)return this;let i;if(e>0){let h=this.array[s];if(i=h?.removeAfter(t,e-z,r),i===h&&s===this.array.length-1)return this}let n=Ut(this,t);if(n.array.splice(s+1),i)n.array[s]=i;return n}}function tn(t,e){let{_origin:r,_capacity:s}=t,i=Lt(s),n=t._tail,h=[];o(t._root,t._level,0);let u={done:!1,value:void 0};return L(()=>{while(h.length>0){let c=h[h.length-1];if(c.from===c.to){h.pop();continue}let f=e?--c.to:c.from++;if(c.isLeaf)return u.value=c.array?.[f],u;let _=c.array?.[f],l=c.level-z,a=c.offset+(f<<c.level);o(_,l,a)}return $});function o(c,f,_){if(f===0){let l=_===i?n?.array:c?.array,a=_>r?0:r-_,d=s-_;if(d>q)d=q;if(a!==d)h.push({array:l,from:a,to:d,isLeaf:!0})}else{let l=c?.array,a=_>r?0:r-_>>f,d=(s-_>>f)+1;if(d>q)d=q;if(a!==d)h.push({array:l,from:a,to:d,level:f,offset:_,isLeaf:!1})}}}function Qu(t,e,r){let{_origin:s,_capacity:i}=t,n=Lt(i),h=t._tail,u=t._level,o=t._root;return u===0?Fn(o,0,s,i,n,h,e,r):mn(o,u,0,s,i,n,h,e,r)}function Fn(t,e,r,s,i,n,h,u){let o=e===i?n?.array:t?.array,c=e>r?0:r-e,f=s-e;if(f>q)f=q;while(c!==f){let _=u?--f:c++;if(h(o?.[_])===!1)return!1}}function mn(t,e,r,s,i,n,h,u,o){let c=t?.array,f=r>s?0:s-r>>e,_=(i-r>>e)+1;if(_>q)_=q;let l=e-z;while(f!==_){let a=o?--_:f++,d=r+(a<<e);if((l===0?Fn(c?.[a],d,s,i,n,h,u,o):mn(c?.[a],l,d,s,i,n,h,u,o))===!1)return!1}}var _e=(t,e,r,s,i,n,h)=>new Pn(t,e,r,s,i,n,h),Vt=()=>_e(0,0,z);function Gu(t,e,r){if(e=et(t,e),Number.isNaN(e))return t;if(e>=t.size||e<0)return t.withMutations((h)=>{if(e<0)tt(h,e).set(0,r);else tt(h,0,e+1).set(e,r)});e+=t._origin;let{_tail:s,_root:i}=t,n=Cr();if(e>=Lt(t._capacity))s=mr(s,t.__ownerID,0,e,r,n);else i=mr(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 _e(t._origin,t._capacity,t._level,i,s)}function mr(t,e,r,s,i,n){let h=s>>>r&K,u=t&&h<t.array.length;if(!u&&i===void 0)return t;let o;if(r>0){let c=t&&t.array[h],f=mr(c,e,r-z,s,i,n);if(f===c)return t;return o=Ut(t,e),o.array[h]=f,o}if(u&&t.array[h]===i)return t;if(n)T(n);if(o=Ut(t,e),i===void 0&&h===o.array.length-1)o.array.pop();else o.array[h]=i;return o}function Ut(t,e){if(e&&e===t?.ownerID)return t;return new _t(t?.array.slice()??[],e)}function kn(t,e){if(e>=Lt(t._capacity))return t._tail;if(e<1<<t._level+z){let{_root:r,_level:s}=t;while(r&&s>0)r=r.array[e>>>s&K],s-=z;return r}}function tt(t,e,r){if(e!==void 0)e|=0;if(r!==void 0)r|=0;let s=t.__ownerID||new Ze,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:c}=t,f=0;while(h+f<0)c=new _t(c?.array.length?[void 0,c]:[],s),o+=z,f+=1<<o;if(f)h+=f,i+=f,u+=f,n+=f;let _=Lt(n),l=Lt(u);while(l>=1<<o+z)c=new _t(c?.array.length?[c]:[],s),o+=z;let a=t._tail,d=l<_?kn(t,u-1):l>_?new _t([],s):a;if(a&&l>_&&h<n&&a.array.length){c=Ut(c,s);let y=c;for(let S=o;S>z;S-=z){let O=_>>>S&K;y=y.array[O]=Ut(y.array[O],s)}y.array[_>>>z&K]=a}if(u<n)d=d&&d.removeAfter(s,0,u);if(h>=l)h-=l,u-=l,o=z,c=null,d=d&&d.removeBefore(s,0,h);else if(h>i||l<_){f=0;while(c){let y=h>>>o&K;if(y!==l>>>o&K)break;if(y)f+=(1<<o)*y;o-=z,c=c.array[y]}if(c&&h>i)c=c.removeBefore(s,o,h-f);if(c&&l<_)c=c.removeAfter(s,o,l-f);if(f)h-=f,u-=f}if(t.__ownerID)return t.size=u-h,t._origin=h,t._capacity=u,t._level=o,t._root=c,t._tail=d,t.__hash=void 0,t.__altered=!0,t;return _e(h,u,o,c,d)}var Lt=(t)=>t<q?0:t-1>>>z<<z,Y=(t)=>t===void 0||t===null?vt():Be(t)?t:vt().withMutations((e)=>{let r=Z(t);A(r.size),r.forEach((s,i)=>e.set(i,s))});Y.of=(...t)=>Y(t);class Nn extends as{static{wt(this,{[rt]:!0,[re]: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 Y(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 vt()}set(t,e){return en(this,t,e)}remove(t){return en(this,t,p)}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 vt();return this.__ownerID=t,this.__altered=!1,this._map=e,this._list=r,this}return Is(e,r,t,this.__hash)}}Y.isOrderedMap=Be;var Is=(t,e,r,s)=>new Nn(t,e,r,s),vt=()=>Is(B(),Vt());function en(t,e,r){let{_map:s,_list:i}=t,n=s.get(e),h=n!==void 0,u,o;if(r===p){if(!h)return t;if(i.size>=q&&i.size>=s.size*2){let c=[];if(i.forEach((f,_)=>{if(f!==void 0&&n!==_)c.push(f)}),o=Vt().withMutations((f)=>{for(let _=0;_<c.length;_++)f.set(_,c[_])}),u=B().withMutations((f)=>{for(let _=0;_<c.length;_++)f.set(c[_][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 c=i.size;u=s.set(e,c),o=i.set(c,[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 Is(u,o)}var Te=(t)=>t===void 0||t===null?Je():rs(t)?t:Je().pushAll(t);Te.of=(...t)=>Te(t);class Vn extends $t{static{wt(this,{asImmutable:oe,asMutable:ce,wasAltered:Os,withMutations:fe,[wn]:!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 Te(t)}toString(){return this.__toString("Stack [","]")}get(t,e){let r=this._head;t=et(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 Gr(this,e,r)}pushAll(t){if(t=dt(t),t.size===0)return this;if(this.size===0&&rs(t))return t;A(t.size);let e=this.size,r=this._head;return t.__iterate((s)=>{e++,r={value:s,next:r}},!0),Gr(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 Je()}slice(t,e){if(se(t,e,this.size))return this;let r=Rt(t,this.size);if(ie(e,this.size)!==this.size)return $t.prototype.slice.call(this,t,e);let i=this.size-r,n=this._head;while(r--)n=n.next;return Gr(this,i,n)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return Je();return this.__ownerID=t,this.__altered=!1,this}return As(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 L(()=>{if(!t)return $;return e.value=t.value,t=t.next,e})}keys(){return Xe(this.size)}}Te.isStack=rs;function Gr(t,e,r){if(t.__ownerID)return t.size=e,t._head=r,t.__hash=void 0,t.__altered=!0,t;return As(e,r)}var As=(t,e,r,s)=>new Vn(t,e,r,s),rn,Je=()=>rn||(rn=As(0)),E=(t)=>t===void 0||t===null?te():es(t)&&!F(t)?t:te().withMutations((e)=>{let r=yt(t);A(r.size),r.forEach((s)=>e.add(s))});E.of=(...t)=>E(t);E.fromKeys=(t)=>E(Z(t).keySeq());E.intersect=(t)=>{return t=m(t).toArray(),t.length?E(t.pop()).intersect(...t):te()};E.union=(t)=>{let e=m(t).toArray();return e.length?E(e.pop()).union(...e):te()};class $s extends Qe{static{wt(this,{withMutations:fe,asImmutable:oe,asMutable:ce,[gn]:!0,[re]: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 E(t)}toString(){return this.__toString("Set {","}")}has(t){return this._map.has(t)}add(t){return Ue(this,this._map.set(t,t))}remove(t){return Ue(this,this._map.remove(t))}clear(){return Ue(this,this._map.clear())}map(t,e){let r=!1,s=Ue(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 E(t[0]);return this.withMutations((e)=>{for(let r of t)if(typeof r==="string")e.add(r);else yt(r).forEach((s)=>e.add(s))})}intersect(...t){return nn(this,t,(e,r)=>!r.every((s)=>s.includes(e)))}subtract(...t){return nn(this,t,(e,r)=>r.some((s)=>s.includes(e)))}wasAltered(){return this._map.wasAltered()}__iterator(t){return this._map.__iterator(t)}__empty(){return te()}__make(t,e){return vn(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)}}E.isSet=es;var vn=(t,e)=>new $s(t,e),sn,te=()=>sn||(sn=vn(B()));function nn(t,e,r){if(e.length===0)return t;return e=e.map((s)=>yt(s)),t.withMutations((s)=>{t.forEach((i)=>{if(r(i,e))s.remove(i)})})}function Ue(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 Dt=(t)=>t===void 0||t===null?kr():Sn(t)?t:kr().withMutations((e)=>{let r=yt(t);A(r.size),r.forEach((s)=>e.add(s))});Dt.of=(...t)=>Dt(t);Dt.fromKeys=(t)=>Dt(Z(t).keySeq());class th extends $s{static{wt(this,{[rt]:!0,[Symbol.toStringTag]:"Immutable.OrderedSet",zip:Qr.zip,zipWith:Qr.zipWith,zipAll:Qr.zipAll})}create(t){return Dt(t)}toString(){return this.__toString("OrderedSet {","}")}__empty(){return kr()}__make(t,e){return eh(t,e)}}Dt.isOrderedSet=Sn;var eh=(t,e)=>new th(t,e),kr=()=>eh(vt());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(P(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(t===null||typeof t!=="object")throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}var le=(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 c=0;c<u.length;c++){let f=u[c];if(o[f]=c,i[f])console.warn(`Cannot define ${Ks(this)} with property "${f}" since that property name is part of the Record API.`);else Pu(i,f)}}return this.__ownerID=void 0,this._values=U().withMutations((u)=>{u.setSize(this._keys.length),Z(h).forEach((o,c)=>{u.set(this._indices[c],o===this._defaultValues[c]?void 0:o)})}),this},i=s.prototype=Object.create(Cu);if(i.constructor=s,i.create=s,e)s.displayName=e;return s};class rh{static{wt(this,{asImmutable:oe,asMutable:ce,deleteIn:Kt,getIn:Bu,hasIn:xu,merge:Fr,mergeWith:Qn,mergeDeep:Yn,mergeDeepWith:Cn,mergeDeepIn:js,mergeIn:qs,setIn:bs,toObject:vi,update:Ms,updateIn:Es,withMutations:fe,removeIn:Kt,toJSON:vi,[zn]:!0,[re]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Record"})}toString(){let t=this._keys.map((e)=>`${e}: ${kt(this.get(e))}`).join(", ");return`${Ks(this)} { ${t} }`}equals(t){return this===t||at(t)&&It(this).equals(It(t))}hashCode(){return It(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 Yr(this,r)}return this}remove(t){return this.set(t)}clear(){let t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:Yr(this,t)}wasAltered(){return this._values.wasAltered()}toSeq(){return It(this)}toJS(){return Re(this)}entries(){return this.__iterator()}__iterate(t,e){return It(this).__iterate(t,e)}__iterator(t){return It(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 Yr(this,e,t)}}le.isRecord=at;var Ks=(t)=>t.constructor.displayName||t.constructor.name||"Record";class sh extends Wt{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 It=(t)=>new sh(t);le.getDescriptiveName=Ks;var Cu=rh.prototype;function Yr(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 hn=(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 Us(t,e,r,s)};class Us extends pt{_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+et(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(se(t,e,this.size))return this;if(t=Rt(t,this.size),e=ie(e,this.size),e<=t)return hn(0,0);return hn(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 L(()=>{if(s===t)return $;return i.value=r,r+=e,s++,i})}keys(){return Xe(this.size)}equals(t){return t instanceof Us?this._start===t._start&&this._end===t._end&&this._step===t._step:is(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}class Nr extends pt{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 I(this._value,t)}slice(t,e){let r=this.size;return se(t,e,r)?this:new Nr(this._value,ie(e,r)-Rt(t,r))}reverse(){return this}indexOf(t){if(I(this._value,t))return 0;return-1}lastIndexOf(t){if(I(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 L(()=>{if(r===t)return $;return r++,s.value=e,s})}keys(){return Xe(this.size)}equals(t){return t instanceof Nr?this.size===t.size&&I(this._value,t._value):is(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var ih=Symbol("BadValue"),oh=(t)=>t;class W{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,ih);if(h===ih)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 Ds{isValid(t){return!0}getMessage(t){return"Invalid"}}class ch extends Ds{}var Fu=new ch;class k extends Ds{constructor(t,e){super();this._isValid=t,this._getMessage=e}isValid(t){return this._isValid(t)}getMessage(t){return this._getMessage(t)}}var mu=new k((t)=>Number.isInteger(t),()=>"Integer expected"),ku=new k((t)=>Number.isFinite(t),()=>"Float expected"),Nu=new k((t)=>typeof t==="boolean",()=>"Boolean expected"),Vu=new k((t)=>typeof t==="string",()=>"String expected"),vu=new k((t)=>U.isList(t),()=>"List expected"),to=new k((t)=>x.isMap(t),()=>"Map expected"),eo=new k((t)=>Y.isOrderedMap(t),()=>"OrderedMap expected"),ro=new k((t)=>E.isSet(t),()=>"Set expected"),so=(t)=>!!t;class Rs extends W{constructor(t,e=!1){super("bool",t,Nu,so,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 Ce extends W{constructor(t,e=null){super("any",t,Fu,oh,e)}toDataDef(){let{defaultValue:t}=this;return{type:Ls(t)??"any",defaultValue:t?.toJS?t.toJS():t}}}var io=(t)=>t?.toString?.()??"";class Ws extends W{constructor(t,e=""){super("text",t,Vu,io,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 no=(t)=>Number.isFinite(t)?Math.trunc(t):null;class fh extends W{constructor(t,e=0){super("int",t,mu,no,e)}}var ho=(t)=>null;class Ts extends W{constructor(t,e=0){super("float",t,ku,ho,e)}}var Ls=(t)=>t?.constructor?.getMetaClass?.()?.name;class _h{constructor(t){this.typeName=t}isValid(t){return Ls(t)===this.typeName}getMessage(t){let e=Ls(t);return`Expected "${this.typeName}", got "${e}"`}}class lh extends W{constructor(t,e,r){super(t,e,new _h(t),oh,null);this.args=r}toDataDef(){return{component:this.typeName,args:this.args}}}var nh=Symbol("NONE");function Xt(t,e,r){dh(t,e,ah),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,nh);if(u!==nh)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 ah=U(),uo=(t)=>Array.isArray(t)?U(t):null;class Js extends W{constructor(t,e=ah){super("list",t,vu,uo,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 oo=(t)=>x(t);class Xs extends W{constructor(t,e=x()){super("map",t,to,oo,e)}extendProtoForType(t,e){Xt(t,this.name,e)}}var co=(t)=>Y(t);class Hs extends W{constructor(t,e=Y()){super("omap",t,eo,co,e)}extendProtoForType(t,e){Xt(t,this.name,e)}}function dh(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 hh=E(),fo=(t)=>Array.isArray(t)?E(t):t instanceof Set?E(t):null;class Zs extends W{constructor(t,e=hh){super("set",t,ro,fo,e)}extendProtoForType(t,e){let{name:r}=this;dh(t,r,hh),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 uh(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 yh{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]=uh(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]=uh(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]:le(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 lh(e,t,r);return this.compFields.add(t),this.fields[t]=s,s}}var Pe=new Map,_o={text:Ws,int:fh,float:Ts,bool:Rs,list:Js,map:Xs,omap:Hs,set:Zs,any:Ce};function lo(t,{fields:e={},methods:r,statics:s}){let i=new yh(t);for(let n in e){let h=e[n],u=typeof h;if(u==="string")i.addField(n,h,Ws);else if(u==="number")i.addField(n,h,Ts);else if(u==="boolean")i.addField(n,h,Rs);else if(U.isList(h)||Array.isArray(h))i.addField(n,U(h),Js);else if(E.isSet(h)||h instanceof Set)i.addField(n,E(h),Zs);else if(Y.isOrderedMap(h))i.addField(n,h,Hs);else if(h?.type&&h?.defaultValue!==void 0){let o=_o[h.type]??Ce;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(x.isMap(h)||h?.constructor===Object)i.addField(n,x(h),Xs);else{let o=Pe.get(h?.constructor)??Ce;i.addField(n,h,o)}}if(r)i.methods(r);if(s)i.statics(s);return i.build()}var ao=(t)=>new jr(t.name??"Comp",lo(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 yo=["nid","cid","eid","vid","si","sk"];class Bs{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??Oo,this.cache=h??new br}setNullCache(){this.cache=new Or}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 yo)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"),c=this.renderMetadata("Comp",{nid:s}),f=this.renderFragment([c,o.render(t,this)]);return this.cache.set(e,h,f),f}renderEach(t,e,r,s){let{seq:i,filter:n,loopWith:h}=e.eval(t),[u,o]=this.getSeqInfo(i),c=[],f=h.call(t.it,i);for(let[_,l]of o(i))if(n.call(t.it,_,l,f)){let a=t.enter(l,{key:_},!0),d=this.renderIt(a,r,_,s);c.push(this.renderMetadata("Each",{nid:r,[u]:_})),c.push(d)}return c}renderEachWhen(t,e,r,s){let{seq:i,filter:n,loopWith:h,enricher:u}=e.eval(t),[o,c]=this.getSeqInfo(i),f=!!u,_=[],l=h.call(t.it,i);for(let[a,d]of c(i))if(n.call(t.it,a,d,l)){let y={key:a,value:d},S=`${s}-${a}`,O;if(f)u.call(t.it,y,a,d,l),O=this.cache.get2(t.it,d,S);else O=this.cache.get(d,S);if(O){_.push(this.renderMetadata("Each",{nid:s,[o]:a})),_.push(O);continue}let Ot=t.enter(d,y,!1),bt=r.render(Ot,this);if(_.push(this.renderMetadata("Each",{nid:s,[o]:a})),f)this.cache.set2(t.it,d,S,bt);else this.cache.set(d,S,bt);_.push(bt)}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*po(t){let e=0;for(let r of t)yield[e++,r]}function*go(t){for(let[e,r]of t.toSeq().entries())yield[e,r]}var Fe=new Map,wo=["si",po],zo=["sk",go],So=["si",function*(e){}];function Oo(t){return j(t)?wo:w(t)?zo:Fe.get(t?.constructor)??So}class zt{constructor(t=x(),e=U()){this.items=t,this.order=e,this.$=0}_clonish(t,e){return new zt(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 ph{isValid(t){return t instanceof zt}getMessage(t){return"KList expected"}}var Mo=new ph;class gh extends W{constructor(t,e=new zt){super("KList",t,Mo,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))}}}Pe.set(zt,gh);function*Eo(t){for(let e of t.order)yield[e,t.items.get(e)]}Fe.set(zt,["data-sk",Eo]);function xs(t){return t[4]==="-"&&(t[0]==="d"||t[0]==="a")}function wh(t,e){return t[e]}function ae(t,e,r){t[e]=r}function Sh(t,e,r){for(let s in e){let i=e[s];if(i===void 0)qo(t,s,r);else if(xs(s))t.setAttribute(s,i);else if(typeof i==="object"&&i!==null)jo(t,r,s,i);else ae(t,s,i)}}function qo(t,e,r){let s=r[e];if(xs(e))t.removeAttribute(e);else if(typeof s==="string"){ae(t,e,"");let i=e==="className"?"class":e==="htmlFor"?"for":e;t.removeAttribute(i)}else ae(t,e,null)}function jo(t,e,r,s){let i=e?.[r];if(i&&typeof i==="object"&&Object.getPrototypeOf(i)!==Object.getPrototypeOf(s)){ae(t,r,s);return}let n=wh(t,r);if(typeof n!=="object"||n===null)ae(t,r,{}),n=wh(t,r);let h=n;for(let u in s)h[u]=s[u]}class Oh{type;message;constructor(t,e){this.type=t,this.message=e}}class bh extends Oh{duplicatedKeys;parentTag;parentIndex;constructor(t,e,r){let s=[...t].join(", ");super("DuplicatedKeys",`Duplicate keys found: [${s}] in ${e||"fragment"} at index ${r}. Nodes with duplicated keys are matched positionally.`);this.duplicatedKeys=t,this.parentTag=e,this.parentIndex=r}}class Bt{isEqualTo(t){return this===t}toDom(t){return null}}function Mh(t){return t instanceof Zt?t.key:void 0}function St(t,e){let r=Mh(t);return r&&e?.has(r)?void 0:r}function Io(t){return t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function"}function Qs(t,e){if(e==null)return;if(Io(e))for(let r of e)Qs(t,r);else if(e instanceof Bt)if(e instanceof N)t.push(...e.childs);else t.push(e);else t.push(new de(e))}class de extends Bt{text;constructor(t){super();this.text=String(t)}get nodeType(){return 3}isEqualTo(t){return t instanceof de&&this.text===t.text}toDom(t){return t.document.createTextNode(this.text)}}class Ht extends Bt{text;constructor(t){super();this.text=t}get nodeType(){return 8}isEqualTo(t){return t instanceof Ht&&this.text===t.text}toDom(t){return t.document.createComment(this.text)}}class N extends Bt{childs;constructor(t){super();let e=[];Qs(e,t),this.childs=e}get nodeType(){return 11}isEqualTo(t){if(!(t instanceof N)||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 Zt extends Bt{tag;attrs;childs;key;namespace;attrCount;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,this.attrCount=Object.keys(this.attrs).length}get nodeType(){return 1}isEqualTo(t){if(!(t instanceof Zt)||this.tag!==t.tag||this.key!==t.key||this.namespace!==t.namespace||this.attrCount!==t.attrCount||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=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);Sh(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(typeof i==="object"&&i!==null&&typeof n==="object"&&n!==null)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 Ao(t,e){let r=me(e);if(r.free.length===e.length)return{children:e,moves:null,duplicatedKeys:r.duplicatedKeys};let s=me(t),i=r.duplicatedKeys||s.duplicatedKeys?new Set([...r.duplicatedKeys||[],...s.duplicatedKeys||[]]):null;if(s.free.length===t.length)return{children:e,moves:null,duplicatedKeys:i};let n,h,u;if(i){let d=me(e,i);n=d.keys,h=d.free,u=me(t,i).keys}else n=r.keys,h=r.free,u=s.keys;let o=[],c=0,f=h.length,_=0;for(let d=0;d<t.length;d++){let y=t[d],S=St(y,i);if(S)if(Object.hasOwn(n,S)){let O=n[S];o.push(e[O])}else _++,o.push(null);else if(c<f){let O=h[c++];o.push(e[O])}else _++,o.push(null)}let l=c>=h.length?e.length:h[c];for(let d=0;d<e.length;d++){let y=e[d],S=St(y,i);if(S){if(!Object.hasOwn(u,S))o.push(y)}else if(d>=l)o.push(y)}let a=$o(o,e,n,i,_);return{children:o,moves:a,duplicatedKeys:i}}function $o(t,e,r,s,i){let n=t.slice(),h=0,u=[],o=[],c=Array(e.length);for(let f=0;f<e.length;f++)c[f]=St(e[f],s);for(let f=0;f<e.length;){let _=c[f],l=n[h],a=St(l,s);while(l===null&&n.length)n.splice(h,1),u.push({from:h,key:null}),l=n[h],a=St(l,s);if(l&&a===_){h++,f++;continue}if(_){if(a&&r[a]!==f+1){if(n.splice(h,1),u.push({from:h,key:a}),l=n[h],a=St(l,s),l&&a===_){h++,f++;continue}}o.push({key:_,to:f}),f++;continue}if(a){n.splice(h,1),u.push({from:h,key:a});continue}f++}while(h<n.length){let f=n[h];n.splice(h,1),u.push({from:h,key:St(f,s)})}if(u.length===i&&!o.length)return null;return{removes:u,inserts:o}}function me(t,e){let r={},s=[],i=null;for(let n=0;n<t.length;n++){let h=Mh(t[n]);if(h&&!e?.has(h)){if(h in r)i??=new Set,i.add(h);r[h]=n}else s.push(n)}return{keys:r,free:s,duplicatedKeys:i}}function Ko(t,e,r){let s=t.parentNode,i=e.toDom(r);if(s&&i&&i!==t)s.replaceChild(i,t);return i||t}function qh(t,e,r,s){if(e===r||e.isEqualTo(r))return t;if(e instanceof de&&r instanceof de||e instanceof Ht&&r instanceof Ht)return t.data=r.text,t;if(e instanceof Zt&&r instanceof Zt&&e.tag===r.tag&&e.namespace===r.namespace&&e.key===r.key){let i=Eh(e.attrs,r.attrs);if(i)Sh(t,i,e.attrs);return zh(t,e.childs,r.childs,e.tag,s),t}if(e instanceof N&&r instanceof N)return zh(t,e.childs,r.childs,null,s),t;return Ko(t,r,s)}function zh(t,e,r,s,i){if(e.length===0){for(let l of r){let a=l.toDom(i);if(a)t.appendChild(a)}return}if(r.length===0){while(t.firstChild)t.removeChild(t.firstChild);return}let n=Ao(e,r),h=n.children;if(n.duplicatedKeys&&i.onWarning)i.onWarning(new bh(n.duplicatedKeys,s,0));let u=Array.from(t.childNodes),o=e.length,c=h.length,f=Math.max(o,c),_=[];for(let l=0;l<f;l++){let a=e[l],d=h[l];if(!a&&d){let y=d.toDom(i);if(y)t.appendChild(y)}else if(a&&d){let y=u[l];if(y)qh(y,a,d,i)}else if(a&&!d){if(!n.moves&&u[l])_.push(u[l])}}for(let l of _)if(l.parentNode===t)t.removeChild(l);if(n.moves)Uo(t,n.moves)}function Uo(t,e){let r=t.childNodes,s={};for(let n of e.removes){let h=r[n.from];if(n.key)s[n.key]=h;t.removeChild(h)}let i=r.length;for(let n=0;n<e.inserts.length;n++){let h=e.inserts[n],u=s[h.key];if(u)t.insertBefore(u,h.to>=i++?null:r[h.to])}}var ke=new WeakMap;function jh(t,e,r){let s=ke.get(e),i=t instanceof N;if(s){let h=s.vnode instanceof N;if(h===i){let u=h?e:s.dom,o=qh(u,s.vnode,t,r);return ke.set(e,{vnode:t,dom:i?e:o}),o}ke.delete(e)}let n=t.toDom(r);if(n)e.innerHTML="",e.appendChild(n),ke.set(e,{vnode:t,dom:i?e:n});return n}function Ih(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(xs(o))i[o]=String(e[o]);else i[o]=e[o];let u=[];return Qs(u,r),new Zt(s,i,u,n,h)}var{raw:Mc,raw:Ec}=String;function qc(t,e){return new gr(t,e)}var Lo=(t)=>typeof t==="string"?document.querySelector(t):t;function jc(t){let e=Lo(t),r=new je,s=(o)=>new N(o),i=(o)=>new Ht(o),n={document},h=(o,c)=>jh(o,c,n),u=new Bs(r,Ih,s,i,h);return new Tr(e,h,r,u,ot)}async function Rc(t,e,r="margaui-css"){let s=performance.now(),i=await Do(t,e),n=performance.now();return Jr(r,i),n-s}async function Do(t,e,r){t.ParseContext=Ae,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))}export{jc as tutuca,Fe as seqInfoByClass,qc as macro,Be as isOrderedMap,Be as isOMap,he as isMap,ts as isList,w as isKeyed,j as isIndexed,he as isIMap,Ec as html,Pe as fieldsByClass,Mc as css,ao as component,Do as compileClassesToStyleText,Rc as compileClassesToStyle,le as Record,ot as ParseContext,Y as OMap,U as List,zt as KList,E as ISet,x as IMap};
|