tutuca 0.9.2 → 0.9.4
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/LICENSE +1 -1
- package/dist/tutuca-dev.js +75 -261
- package/dist/tutuca-dev.min.js +3 -3
- package/dist/tutuca-extra.js +75 -261
- package/dist/tutuca-extra.min.js +3 -3
- package/dist/tutuca.js +1009 -1195
- package/dist/tutuca.min.js +3 -3
- package/package.json +3 -3
package/dist/tutuca.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
function xe(t){return t[4]==="-"&&(t[0]==="d"||t[0]==="a")}function Hs(t,e){return t[e]}function Ht(t,e,r){t[e]=r}function Bs(t,e,r){for(let s in e){let i=e[s];if(i===void 0)Mh(t,s,r);else if(xe(s))t.setAttribute(s,i);else if(typeof i==="object"&&i!==null)Eh(t,r,s,i);else Ht(t,s,i)}}function Mh(t,e,r){let s=r[e];if(xe(e))t.removeAttribute(e);else if(typeof s==="string"){Ht(t,e,"");let i=e==="className"?"class":e==="htmlFor"?"for":e;t.removeAttribute(i)}else Ht(t,e,null)}function Eh(t,e,r,s){let i=e?.[r];if(i&&typeof i==="object"&&Object.getPrototypeOf(i)!==Object.getPrototypeOf(s)){Ht(t,r,s);return}let n=Hs(t,r);if(typeof n!=="object"||n===null)Ht(t,r,{}),n=Hs(t,r);let h=n;for(let u in s)h[u]=s[u]}class Qs{type;message;constructor(t,e){this.type=t,this.message=e}}class Gs extends Qs{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 Mt{isEqualTo(t){return this===t}toDom(t){return null}}function Ys(t){return t instanceof bt?t.key:void 0}function nt(t,e){let r=Ys(t);return r&&e?.has(r)?void 0:r}function qh(t){return t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function"}function Ce(t,e){if(e==null)return;if(qh(e))for(let r of e)Ce(t,r);else if(e instanceof Mt)if(e instanceof C)t.push(...e.childs);else t.push(e);else t.push(new Tt(e))}class Tt extends Mt{text;constructor(t){super();this.text=String(t)}get nodeType(){return 3}isEqualTo(t){return t instanceof Tt&&this.text===t.text}toDom(t){return t.document.createTextNode(this.text)}}class Ot extends Mt{text;constructor(t){super();this.text=t}get nodeType(){return 8}isEqualTo(t){return t instanceof Ot&&this.text===t.text}toDom(t){return t.document.createComment(this.text)}}class C extends Mt{childs;constructor(t){super();let e=[];Ce(e,t),this.childs=e}get nodeType(){return 11}isEqualTo(t){if(!(t instanceof C)||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 bt extends Mt{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 bt)||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);Bs(r,this.attrs,{});for(let s of this.childs){let i=s.toDom(t);if(i)r.appendChild(i)}return r}}function Ps(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=Ps(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 jh(t,e){let r=ae(e);if(r.free.length===e.length)return{children:e,moves:null,duplicatedKeys:r.duplicatedKeys};let s=ae(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=ae(e,i);n=y.keys,h=y.free,u=ae(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 p=t[y],S=nt(p,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 p=e[y],S=nt(p,i);if(S){if(!Object.hasOwn(u,S))o.push(p)}else if(y>=l)o.push(p)}let a=Ih(o,e,n,i,_);return{children:o,moves:a,duplicatedKeys:i}}function Ih(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]=nt(e[f],s);for(let f=0;f<e.length;){let _=c[f],l=n[h],a=nt(l,s);while(l===null&&n.length)n.splice(h,1),u.push({from:h,key:null}),l=n[h],a=nt(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=nt(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:nt(f,s)})}if(u.length===i&&!o.length)return null;return{removes:u,inserts:o}}function ae(t,e){let r={},s=[],i=null;for(let n=0;n<t.length;n++){let h=Ys(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 Uh(t,e,r){let s=t.parentNode,i=e.toDom(r);if(s&&i&&i!==t)s.replaceChild(i,t);return i||t}function xs(t,e,r,s){if(e===r||e.isEqualTo(r))return t;if(e instanceof Tt&&r instanceof Tt||e instanceof Ot&&r instanceof Ot)return t.data=r.text,t;if(e instanceof bt&&r instanceof bt&&e.tag===r.tag&&e.namespace===r.namespace&&e.key===r.key){let i=Ps(e.attrs,r.attrs);if(i)Bs(t,i,e.attrs);return Ts(t,e.childs,r.childs,e.tag,s),t}if(e instanceof C&&r instanceof C)return Ts(t,e.childs,r.childs,null,s),t;return Uh(t,r,s)}function Ts(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=jh(e,r),h=n.children;if(n.duplicatedKeys&&i.onWarning)i.onWarning(new Gs(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 p=y.toDom(i);if(p)t.appendChild(p)}else if(a&&y){let p=u[l];if(p)xs(p,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)Ah(t,n.moves)}function Ah(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 ye=new WeakMap;function Cs(t,e,r){let s=ye.get(e),i=t instanceof C;if(s){let h=s.vnode instanceof C;if(h===i){let u=h?e:s.dom,o=xs(u,s.vnode,t,r);return ye.set(e,{vnode:t,dom:i?e:o}),o}ye.delete(e)}let n=t.toDom(r);if(n)e.innerHTML="",e.appendChild(n),ye.set(e,{vnode:t,dom:i?e:n});return n}function Fs(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(xe(o))i[o]=String(e[o]);else i[o]=e[o];let u=[];return Ce(u,r),new bt(s,i,u,n,h)}class Bt{lookup(t,e=null){return e}setValue(t,e){return t}updateBindings(t,e){}isFrame=!0}class Et extends Bt{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 pe extends Bt{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 Ne(this.field,t)}withKey(t){return new ke(this.field,t)}}class Fe extends Bt{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 ke extends Fe{}class Ne extends Fe{}var L=Symbol("NONE");class Ve extends Bt{constructor(t,e){super();this.seqField=t,this.keyField=e}lookup(t,e=null){let r=t?.get(this.seqField,L),s=t?.get(this.keyField,L);return s!==L&&r?.get?r.get(s,e):e}setValue(t,e){let r=t?.get(this.seqField,L),s=t?.get(this.keyField,L);return r===L||s===L?t:t.set(this.seqField,r.set(s,e))}updateBindings(t,e){e.key=t?.get(this.keyField,null)}}class m{constructor(t=[]){this.steps=t}concat(t){return new m(this.steps.concat(t))}popStep(){return new m(this.steps.slice(0,-1))}lookup(t,e=null){let r=t;for(let s of this.steps)if(r=s.lookup(r,L),r===L)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,L),s===L)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,L),r===L)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}=Ns(t.previousSibling),{eid:p,cid:S,vid:O}=t.dataset;if(p!==void 0)o.push(p);if(S!==void 0){let zt=i.getComponentForId(+S,O);if(_){if(c=$h(zt,o,O,e),c===null&&n)return Lh;_=!1}let St=Kh(zt,f,O);if(St)h.push(St);o=[],f=[]}if(l!==void 0)f.push({nid:l,si:a,sk:y})}u+=1,t=t.parentNode}return[new m(h.reverse()),c]}static fromEvent(t,e,r,s,i=!0){let{type:n,target:h}=t;return m.fromNodeAndEventName(h,n,e,r,s,i)}}var ks={};function Ns(t){if(t?.nodeType===8&&t.textContent[0]==="§"){let e=Ns(t.previousSibling);if(e!==ks)return e;try{return JSON.parse(t.textContent.slice(1,-1))}catch(r){console.warn(r,t)}}return ks}function $h(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 Kh(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 Lh=[null,null];class me{constructor(){this.pathChanges=[]}add(t){return this.pathChanges.push(t),this}field(t){return this.add(new pe(t))}index(t,e){return this.add(new Ne(t,e))}key(t,e){return this.add(new ke(t,e))}}var Dh=/^[a-zA-Z][a-zA-Z0-9_]*$/,ht=(t)=>Dh.test(t),Rh=/^-?[0-9]+(\.[0-9]+)?$/,Vs=(t,e)=>tr.parse(t,e),Qt=(t,e)=>new Q(t),Wh=(t,e)=>ht(t)?new ut(t):null,Jh=(t,e)=>ht(t)?new ri(t):null,Xh=(t,e)=>ht(t)?new rr(t):null,Zh=(t,e)=>ht(t)?new ni(t):null,Hh=(t,e)=>ht(t)?new hi(t):null,Th=(t,e)=>ht(t)?new ui(t):null,Bh=(t,e)=>ht(t)?new si(t):null;class ms{constructor(){this.allowFieldOnly(),this.bindValIt=new rr("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 oi(s,i):null}parse(t,e){switch(Qh(t)){case ci:return this.parseIfOk(t,e,this.okStrTpl,Vs);case _i:return this.parseIfOk(t,e,this.okStrTpl,Qt);case fi:return this._parseSeqAccess(t,e);case ge:return this.parseIfOk(t,e,this.okStrTpl,Vs)}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,Xh);case 42:return this.parseIfOk(t.slice(1),e,this.okDyn,Zh);case 46:return this.parseIfOk(t.slice(1),e,this.okField,Hh);case 36:return this.parseIfOk(t.slice(1),e,this.okComputed,Th);case 33:return this.parseIfOk(t.slice(1),e,this.okRequest,Bh)}let s=Rh.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,Wh);else if(r>=65&&r<=90)return this.parseIfOk(t,e,this.okType,Jh);return null}parseDynamic(t,e){return this.allowFieldOnly(),this.okComputed=!0,this.parse(t,e)}parseEach(t,e){return this.allowFieldOnly(),this.okComputed=!0,this.okDyn=!0,this.parse(t,e)}allowHandlerArg(){this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okType=!0,this.okRequest=!0,this.okName=!0,this.okConst=!0}parseHandlerArg(t,e){return this.allowHandlerArg(),this.parse(t,e)}_parseHandler(t,e,r){this.allowFieldOnly(),this.okName=!0;let s=this.parse(t,e);return s.toRawFieldVal?s.toRawFieldVal():new r(s.name)}parseHandlerName(t,e){return this._parseHandler(t,e,vs)}parseAlter(t,e){return this._parseHandler(t,e,ti)}parseAttr(t,e){return this.parseText(t,e)}parseAll(t,e){return this.allowHandlerArg(),this.okStrTpl=!0,this.okSeqAccess=!0,this.parse(t,e)}parseCondValue(t,e){return this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okConst=!0,this.parse(t,e)}parseText(t,e){return this.allowFieldOnly(),this.okBind=!0,this.okComputed=!0,this.okDyn=!0,this.okConst=!0,this.okStrTpl=!0,this.parse(t,e)}parseRender(t,e){return this.allowFieldOnly(),this.okSeqAccess=!0,this.parse(t,e)}}class de{render(t,e){}eval(t){}toPathItem(){return null}}class Q extends de{constructor(t){super();this.value=t}render(t,e){return this.value}eval(t){return this.value}toString(){let t=this.value;return typeof t==="string"?`'${t}'`:`${t}`}}class ve extends de{}class tr extends ve{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)==="}"?d.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 tr(s)}}class ut extends ve{constructor(t){super();this.name=t}eval(t){return t.lookupName(this.name)}toString(){return this.name}}class vs extends ut{eval(t){return t.getInputHandler(this.name)??ei("input",this.name)}}class ti extends ut{eval(t){return t.getAlterHandler(this.name)??ei("alter",this.name)}}var ei=(t,e)=>function(...r){return console.warn("handler not found",{type:t,name:e,args:r},this),this};class ri extends ut{eval(t){return t.lookupType(this.name)}}class si extends ut{eval(t){return t.lookupRequest(this.name)}toString(){return`!${this.name}`}}class ii extends ut{eval(t){return t.lookupFieldRaw(this.name)}toString(){return`.${this.name}`}}class er extends de{render(t,e){return this.eval(t)}}class Gt extends er{constructor(t){super();this.name=t}}class rr extends Gt{eval(t){return t.lookupBind(this.name)}toString(){return`@${this.name}`}}class ni extends Gt{eval(t){return t.lookupDynamic(this.name)}toPathItem(){return null}toString(){return`*${this.name}`}}class hi extends Gt{eval(t){return t.lookupField(this.name)}toPathItem(){return new pe(this.name)}toRawFieldVal(){return new ii(this.name)}toString(){return`.${this.name}`}}class ui extends Gt{eval(t){return t.lookupComputed(this.name)}toString(){return`$${this.name}`}}class oi extends er{constructor(t,e){super();this.seqVal=t,this.keyVal=e}toPathItem(){return new Ve(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,ge=2,_i=3;function Qh(t){let e=0,r=0;for(let s=0;s<t.length;s++)switch(t.charCodeAt(s)){case 91:if(e>0)return ge;e+=1;break;case 93:if(r>0||e===0)return ge;r+=1;break;case 123:return ci;case 125:return _i}if(e>0||r>0)return e===1&&r===1?fi:ge;return-1}var d=new ms;class qt{constructor(t){this.items=t}eval(t){return{}}static parse(t,e,r=!1){return hr(e).parse(t,r)}isConstant(){return!1}}var Gh="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",Yh=new Set(Gh.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?d.parseAll(e,this.px):d.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=d.parseCondValue(e,this.px);if(r)this.ifAttr=new pi(t.slice(3),r),this.attrs??=[],this.attrs.push(this.ifAttr),this.hasDynamic=!0}parseThen(t){if(this.ifAttr)this.ifAttr.thenVal=d.parseAttr(t,this.px)??Yt}parseElse(t){if(this.ifAttr)this.ifAttr.elseVal=d.parseAttr(t,this.px)??Yt}parseEvent(t,e){let[r,...s]=t.slice(3).split("+"),i=ur.parse(e,this.px);if(i){if(this.events===null)this.events=this.px.registerEvents(),this.attrs??=[],this.attrs.push(new we("data-eid",d.const(this.events.id)));this.events.add(r,i,s)}}parseDirective(t,e){switch(e){case"dangerouslysetinnerhtml":this.attrs??=[],this.attrs.push(new yi(d.parseText(t,this.px))),this.hasDynamic=!0;return;case"slot":this.pushWrapper("slot",t,d.const(t));return;case"push-view":this.pushWrapper("push-view",t,d.parseText(t,this.px));return;case"text":this.textChild=d.parseText(t,this.px)??d.const("");return;case"show":this.pushWrapper("show",t,d.parseCondValue(t,this.px));return;case"hide":this.pushWrapper("hide",t,d.parseCondValue(t,this.px));return;case"each":this.eachAttr=this.pushWrapper("each",t,d.parseEach(t,this.px));return;case"enrich-with":if(this.eachAttr!==null)this.eachAttr.enrichWithVal=d.parseAlter(t,this.px);else this.pushWrapper("scope",t,d.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=d.parseAlter(t,this.px)}_parseLoopWith(t){if(this.eachAttr!==null)this.eachAttr.loopWithVal=d.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===""&&Yh.has(n)?!0:h;this.attrs.push(new we(n,d.const(o)))}}let{attrs:r,hasDynamic:s}=this;return[s?new ai(r):ir.fromAttrs(r??[]),this.wrapperAttrs,this.textChild]}}class ir 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 ir(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 ai 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 we(t,new Q(e)))}toMacroVars(){let t={};for(let e of this.items)t[e.name]=e.value.toString();return t}}class nr{constructor(t){this.name=t}}class ze extends nr{constructor(t,e){super(t);this.value=e}eval(t){return this.value.eval(t)}}class we extends ze{}class yi extends ze{constructor(t){super("dangerouslySetInnerHTML",t??d.nullConstVal)}eval(t){return{__html:`${this.value.eval(t)}`}}}var Yt=d.nullConstVal;class pi extends nr{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 sr=null;function hr(t){return sr??=new li(t),sr.clear(t),sr}class ur{constructor(t,e=[]){this.handlerVal=t,this.args=e}getHandlerAndArgs(t,e){let r=Array(this.args.length);for(let s=0;s<r.length;s++)r[s]=this.args[s].eval(t);return[this.handlerVal.eval(t),r]}static parse(t,e){let[r,...s]=t.trim().split(/\s+/),i=d.parseHandlerName(r,e);if(i===null)return null;let n=Array(s.length);d.allowHandlerArg();for(let h=0;h<s.length;h++){let u=d.parse(s[h],e);n[h]=u!==null?u:d.nullConstVal}return new ur(i,n)}}class or{constructor(t,e){this.name=t,this.fn=e}toHandlerArg(t){let e=(...r)=>t.request(this.name,r);return e.withOpts=(...r)=>t.request(this.name,r.slice(0,-1),r.at(-1)),e}}class jt{render(t,e){return e.renderEmpty()}setDataAttr(t,e){console.warn("setDataAttr not implemented for",this,{key:t,val:e})}isConstant(){return!1}optimize(){}}class xt extends jt{constructor(t){super();this.v=t}render(t,e){return e.renderText(this.v)}isWhiteSpace(){for(let t=0;t<this.v.length;t++){let e=this.v.charCodeAt(t);if(!(e===32||e===10||e===9||e===13))return!1}return!0}hasNewLine(){for(let t=0;t<this.v.length;t++){let e=this.v.charCodeAt(t);if(e===10||e===13)return!0}return!1}condenseWhiteSpace(){this.v=""}isConstant(){return!0}setDataAttr(t,e){}}class Pt extends xt{render(t,e){return e.renderComment(this.v)}}function Ph(t){for(let e=0;e<t.length;e++){let r=t[e];if(r.isConstant())t[e]=new gr(r);else r.optimize()}}function lr(t){if(t.isConstant())return new gr(t);return t.optimize(),t}class ar extends jt{constructor(t){super();this.childs=t}isConstant(){return this.childs.every((t)=>t.isConstant())}optimize(){Ph(this.childs)}}class Se extends ar{constructor(t,e,r){super(r);this.tagName=t,this.attrs=e}render(t,e){let r=Array(this.childs.length);for(let s=0;s<r.length;s++)r[s]=this.childs[s]?.render?.(t,e)??null;return e.renderTag(this.tagName,this.attrs.eval(t),r)}setDataAttr(t,e){this.attrs.setDataAttr(t,e)}isConstant(){return this.attrs.isConstant()&&super.isConstant()}}class Oe extends ar{render(t,e){return e.renderFragment(this.childs.map((r)=>r?.render(t,e)))}setDataAttr(t,e){for(let r of this.childs)r.setDataAttr(t,e)}}var cr=(t)=>t.length===1?t[0]:new Oe(t),xh=/^[a-zA-Z][a-zA-Z0-9-]*$/,gi=null;class v extends jt{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 v.fromDOM(r[0]??new e.Text(""),e)}static fromDOM(t,e){if(e.isTextNode(t))return new xt(t.textContent);else if(e.isCommentNode(t))return new Pt(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 cr(n);let{name:h,value:u}=s[0],o=s.getNamedItem("as")?.value??null;switch(h){case"slot":return new Me(null,d.const(u),cr(n));case"text":return new _r(null,d.parseText(u,e)??d.const(""));case"render":return e.addNodeIf(Mi,d.parseRender(u,e),o);case"render-it":return e.addNodeIf(Ei,d.bindValIt,o);case"render-each":return pr.parse(e,d,u,o,s)}return new Pt(`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]??cr(n)}let[u,o]=qt.parse(s,e,!0);return e.onAttributes(u,o,null),di(e.newMacroNode(h,u.toMacroVars(),n),e,o)}else if(xh.test(i)){let[h,u,o]=qt.parse(s,e);if(e.onAttributes(h,u,o),o)n.unshift(new _r(null,o));let c=i!=="PRE"?Vh(n):n;return di(new Se(i.toLowerCase(),h,c),e,u)}return new Pt(`Error: InvalidTagName ${i}`)}}function di(t,e,r){if(r)for(let s=r.length-1;s>=0;s--){let i=Ch(r[s],e);if(i)i.wrapNode(t),t=i}return t}function Ch(t,e){let r=Nh[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 bi extends jt{constructor(t,e,r,s){super();this.name=t,this.attrs=e,this.slots=r,this.px=s,this.node=null,this.dataAttrs={}}compile(t){let{name:e,attrs:r,slots:s}=this;if(this.px.isInsideMacro(e))throw Error(`Recursive macro expansion: ${e}`);let i=t.lookupMacro(e);if(i===null)this.node=new Pt(`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=lr(this.node)}}class yr{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 Mi extends be{render(t,e){let r=t.enter(this.val.eval(t),{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}}class Ei extends be{render(t,e){return e.renderIt(t,this.nodeId,"",this.viewId)}pathInNext=!0}class pr extends be{constructor(t,e,r){super(t,e,r);this.iterInfo=new dr(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(pr,e.parseEach(r,t),s);if(n!==null){let h=hr(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 _r extends v{render(t,e){return e.renderText(this.val.eval(t))}}class gr extends jt{constructor(t){super();this.node=t,this._render=(e,r)=>{let s=t.render(e,r);return this._render=(i,n)=>s,s}}render(t,e){return this._render(t,e)}}class ot extends 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=lr(this.node)}static register=!1}class qi extends ot{render(t,e){return this.val.eval(t)?this.node.render(t,e):e.renderEmpty()}}class ji extends ot{render(t,e){return this.val.eval(t)?e.renderEmpty():this.node.render(t,e)}}class Ii extends ot{render(t,e){return this.node.render(t.pushViewName(this.val.eval(t)),e)}}class Me extends ot{optimize(){this.node.optimize()}}class Ui 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 Ai extends ot{constructor(t,e){super(t,e);this.iterInfo=new dr(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 dr{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)??Fh,s=this.loopWithVal?.eval(t)??kh,i=this.enrichWithVal?.eval(t)??null;return{seq:e,filter:r,loopWith:s,enricher:i}}}var Fh=(t,e,r)=>!0,kh=(t)=>({seq:t}),Nh={slot:Me,show:qi,hide:ji,each:Ai,scope:Ui,"push-view":Ii};class Ct{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 Ct(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 $i(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 xt)||!h.isWhiteSpace())s.push(h);let n=new bi(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 fr=(t)=>t instanceof xt&&t.isWhiteSpace(),wi=(t)=>t instanceof Se||t instanceof Oe&&t.childs[0]instanceof Se;function Vh(t){let e=t.length;if(e===0)return t;let r=0,s=!1;if(fr(t[0]))r=1,s=!0;if(e>1&&fr(t[e-1]))e-=1,s=!0;for(let i=1;i<e-1;i++){let n=t[i];if(fr(n)&&wi(t[i-1])&&wi(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=lr(this.anode)}render(t,e){return this.anode.render(t,e)}}class $i{constructor(t){this.id=t,this.handlers=[]}add(t,e,r){this.handlers.push(new Ki(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 Ki{constructor(t,e,r){this.name=t,this.handlerCall=e,this.modifierWrapper=su(t,r),this.modifiers=r}handlesEventName(t){return this.name===t}getHandlerAndArgs(t,e){let r=this.handlerCall.getHandlerAndArgs(t,e);return r[0]=this.modifierWrapper(r[0],e),r}}var mh=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),qe=(t)=>(e)=>(r,s,i,n)=>t(n)?e(r,s,i,n):r,zi=(t)=>qe((e)=>e.e.key===t),Si=qe(({e:t})=>mh&&t.metaKey||t.ctrlKey),vh=qe(({e:t})=>t.metaKey),tu=qe(({e:t})=>t.altKey),Oi={ctrl:Si,cmd:Si,meta:vh,alt:tu},eu={keydown:{send:zi("Enter"),cancel:zi("Escape"),...Oi},click:{...Oi}},ru=(t,e)=>t;function su(t,e){if(e.length===0)return ru;let r=eu[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 wr{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 zr{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 Sr{getKey(t,e,r){return r.call(t)}}class Or{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 Or}setNullComputedCache(){this.computedCache=new Sr}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:Di}getInputHandlerFor(t,e){return this.getCompFor(t)?.input[e]??null}getAlterHandlerFor(t,e){return this.getCompFor(t)?.alter[e]??null}getRequestFor(t,e){let r=this.getCompFor(t);return r?r.scope.lookupRequest(e):null}lookupComputed(t,e){let r=this.getCompFor(t)?.computed[e];return r?this.computedCache.getKey(t,e,r):null}compileStyles(){let t=[];for(let e of this.byId.values())t.push(e.compileStyle());return t.join(`
|
|
2
|
-
`)}}class
|
|
3
|
-
`)}}function Di(t){return t}var Ri=Symbol("STOP"),jr=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===Ri?e:s===jr?r!==null?r.lookup(t,e):e:s}*[Symbol.iterator](){let t=this;while(t!==null)yield t.head,t=t.tail}}class Er{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?Ri:jr:e}}class qr{constructor(t){this.bindings=t}lookup(t){let e=this.bindings[t];return e===void 0?jr: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 Er(e,{it:e},!0),null),i=new Ft(new qr({}),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 Er(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 qr(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 Wi{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 Ir{constructor(t,e){this.comps=t,this.transactions=[],this.state=new Wi(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 $r(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 Zi(t,this,e,r,i,n))}async pushRequest(t,e,r=[],s={},i=null){let n=this.state.value,h=t.lookup(n),u=this.comps.getRequestFor(h,e)??nu(e),o=s?.onResName??e,c=(f,_,l,a,y)=>{let S=new Xi(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 Ji(t,e,r,this,s))}}function nu(t){return()=>{throw Error(`Request not found: ${t}`)}}function hu(){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 Hi,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 uu=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac");function ou(t){return t.target.type==="checkbox"?t.target.checked:(t instanceof CustomEvent?t.detail:t.target.value)??null}class Ji 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 Kr(this.path,this.transactor,this),n[u]=n[u].toHandlerArg(h);return[i,n]}lookupName(t){let{e}=this;switch(t){case"value":return ou(e);case"target":return e.target;case"event":return e;case"isAlt":return e.altKey;case"isShift":return e.shiftKey;case"isCtrl":case"isCmd":return uu&&e.metaKey||e.ctrlKey;case"key":return e.key;case"keyCode":return e.keyCode;case"isUpKey":return e.key==="ArrowUp";case"isDownKey":return e.key==="ArrowDown";case"isSend":return e.key==="Enter";case"isCancel":return e.key==="Escape";case"isTabKey":return e.key==="Tab";case"ctx":return new Lr(this.path,this.transactor,this);case"dragInfo":return this.dragInfo}return null}}class Ar 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]??hu}getHandlerAndArgs(t,e,r){return[this.getHandlerForName(r.getCompFor(e)),[...this.args,new Lr(this.path,this.transactor,this)]]}}class Xi extends Ar{handlerProp="response"}class $r extends Ar{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 Zi extends $r{handlerProp="bubble";stopPropagation(){this.opts.bubbles=!1}}class Hi{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 Kr{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 Lr extends Kr{stopPropagation(){return this.parent.stopPropagation()}}class Ti extends me{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 Dr{constructor(t,e,r,s,i){this.rootNode=t,this.comps=r,this.compStack=new Ie(r),this.transactor=new Ir(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]=m.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 Bi(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()}),cu("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 m([]),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 cu(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 Bi{constructor(t,e,r,s,i,n){this.path=t,this.stack=e,this.e=r,this.value=s,this.type=i,this.node=n}lookupBind(t){return this.stack.lookupBind(t)}}function kt(t,e){if(!t)throw Error(e)}function U(t){kt(t!==1/0,"Cannot perform this action with an infinite size.")}function Qi(t,e,r,s,i,n){return U(t.size),t.__iterate((h,u,o)=>{if(i)i=!1,r=h;else r=e.call(s,r,h,u,o)},n),r}var _u=(t,e)=>e,lu=(t,e)=>[e,t],Rr=(t)=>function(...e){return!t.apply(this,e)},Gi=(t)=>function(...e){return-t.apply(this,e)};function ln(t,e){if(t===void 0&&e===void 0)return 0;if(t===void 0)return 1;if(e===void 0)return-1;return t>e?1:t<e?-1:0}var Yi=(t,e)=>t<e?1:t>e?-1:0,A={done:!0,value:void 0};class an{constructor(t){this.next=t}[Symbol.iterator](){return this}}function K(t){return new an(t)}function M(t){let e=[void 0,void 0],r={done:!1,value:void 0};return K(()=>{if(t(e))return r.value=[e[0],e[1]],r;return A})}var au=K(()=>A),ct=()=>au;function Xe(t){let e=0,r={done:!1,value:void 0};return K(()=>{if(e===t)return A;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 yn(t){if(Array.isArray(t))return!0;return!!Ze(t)}var yu=(t)=>!!(t&&typeof t.next==="function");function pn(t){return Ze(t)?.call(t)}function Ze(t){let e=t&&t[Symbol.iterator];if(typeof e==="function")return e}function pu(t){let e=Ze(t);return e&&e===t.entries}function gu(t){let e=Ze(t);return e&&e===t.keys}var re="delete",z=5,q=1<<z,$=q-1,g={},Qr=()=>({value:!1});function W(t){if(t)t.value=!0}class He{}function At(t){if(t.size===void 0)t.size=t.__iterate(gn);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 gn=()=>!0,dn=(t)=>t<0||Object.is(t,-0),se=(t,e,r)=>(t===0&&!dn(t)||r!==void 0&&(t??0)<=-r)&&(e===void 0||r!==void 0&&e>=r),wn=(t,e,r)=>t===void 0?r:dn(t)?e===1/0?e:Math.max(0,e+t)|0:e===void 0||e===t?t:Math.min(e,t)|0,Wt=(t,e)=>wn(t,e,0),ie=(t,e)=>wn(t,e,e),zn="@@__IMMUTABLE_ITERABLE__@@",Ke="@@__IMMUTABLE_KEYED__@@",Le="@@__IMMUTABLE_INDEXED__@@",rt="@@__IMMUTABLE_ORDERED__@@",ne="@@__IMMUTABLE_SEQ__@@",Sn="@@__IMMUTABLE_LIST__@@",On="@@__IMMUTABLE_MAP__@@",bn="@@__IMMUTABLE_SET__@@",Mn="@@__IMMUTABLE_STACK__@@",En="@@__IMMUTABLE_RECORD__@@";function P(t,e){return typeof t==="object"&&t!==null&&e in t}var D=(t)=>P(t,zn),w=(t)=>P(t,Ke),j=(t)=>P(t,Le),Fr=(t)=>w(t)||j(t),F=(t)=>P(t,rt),kr=(t)=>P(t,ne),Nr=(t)=>P(t,Sn),he=(t)=>P(t,On),Vr=(t)=>P(t,bn),mr=(t)=>P(t,Mn),at=(t)=>P(t,En),x=(t)=>D(t)||at(t),Te=(t)=>he(t)&&F(t),qn=(t)=>Vr(t)&&F(t),Pi=(t)=>typeof t==="object"&&t!==null&&typeof t.equals==="function"&&typeof t.hashCode==="function";function jn(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=Xt,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 In(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,g);return h===g?n:e.call(r,h,i,t)},s.__iterate=function(i,n){return t.__iterate((h,u)=>i(e.call(r,h,u,t),u,this),n)},s.__iteratorUncached=function(i){return ee(t.__iterator(i),(n,h,u)=>{u[0]=n,u[1]=e.call(r,h,n,t)})},s}function Un(t,e){let r=G(t);if(r._iter=t,r.size=t.size,r.reverse=()=>t,t.flip)r.flip=function(){let s=jn(t);return s.reverse=()=>t.flip(),s};return r.get=(s,i)=>t.get(e?s:-1-s,i),r.has=(s)=>t.has(e?s:-1-s),r.includes=(s)=>t.includes(s),r.cacheResult=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 ee(t.__iterator(!s),(h,u,o)=>{o[0]=e?h:s?n-++i:i++,o[1]=u})},r}function An(t,e,r,s){let i=t.size;if(se(e,r,i))return t;if(i===void 0&&(e<0||r<0))return An(t.toSeq().cacheResult(),e,r,s);let n=Wt(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&&kr(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((y,p)=>{if(l<n){l++;return}if(o!==void 0&&a>=o)return!1;if(a++,f(y,s?p: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 K(()=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return A;let y=_.next();if(y.done)return y;return a++,y});return M((y)=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return!1;let p=_.next();if(p.done)return!1;return a++,y[0]=a-1,y[1]=p.value[1],!0})},c}function xi(t,e,r){if(!e)e=ln;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?ss(n):j(t)?lt(n):Vt(n)}function Ue(t,e,r){if(!e)e=ln;if(r){let s=t.toSeq().map((i,n)=>[i,r(i,n,t)]).reduce((i,n)=>Ci(e,i[1],n[1])?n:i);return s&&s[0]}return t.reduce((s,i)=>Ci(e,s,i)?i:s)}function Ci(t,e,r){let s=t(r,e);return s===0&&r!==e&&(r===void 0||r===null||Number.isNaN(r))||s>0}function Wr(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=k(_);return pn(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 $n(t){if(Array.isArray(t)||typeof t==="string")return!0;return t&&typeof t==="object"&&Number.isInteger(t.length)&&t.length>=0&&(t.length===0?Object.keys(t).length===1:Object.hasOwn(t,t.length-1))}function 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"&&(x(t)||Array.isArray(t)||du(t));function Kn(t){if($n(t)&&typeof t!=="string")return t;if(F(t))return t.toArray();throw TypeError(`Invalid keyPath: expected Ordered Collection or Array: ${t}`)}var wu=(t,e)=>x(t)?t.has(e):st(t)&&Object.hasOwn(t,e);function Ln(t,e,r){return x(t)?t.get(e,r):!wu(t,e)?r:typeof t.get==="function"?t.get(e):t[e]}function vr(t,e,r){let s=Kn(e),i=0;while(i!==s.length)if(t=Ln(t,s[i++],g),t===g)return r;return t}var Dn=(t,e)=>vr(t,e,g)!==g;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!!(Pi(t)&&Pi(e)&&t.equals(e))}function De(t){if(!t||typeof t!=="object")return t;if(!D(t)){if(!st(t))return t;t=it(t)}if(w(t)){let r={};return t.__iterate((s,i)=>{r[String(i)]=De(s)}),r}let e=[];return t.__iterate((r)=>{e.push(De(r))}),e}function ts(t,e){if(t===e)return!0;if(!D(e)||t.size!==void 0&&e.size!==void 0&&t.size!==e.size||t.__hash!==void 0&&e.__hash!==void 0&&t.__hash!==e.__hash||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=!Fr(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,g)):!I(t.get(u,g),h))return i=!1,!1;return!0});return i&&t.size===n}var Be=(t)=>t>>>1&1073741824|t&3221225471;function X(t){if(t===null||t===void 0)return Fi(t);if(typeof t.hashCode==="function")return Be(t.hashCode(t));let e=Mu(t);if(e===null||e===void 0)return Fi(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return zu(e);case"string":return e.length>Eu?Su(e):Gr(e);case"object":case"function":return bu(e);case"symbol":return Ou(e);default:if(typeof e.toString==="function")return Gr(e.toString());throw Error(`Value type ${typeof e} cannot be hashed.`)}}var Fi=(t)=>t===null?1108378658:1108378659;function zu(t){if(Number.isNaN(t)||t===1/0)return 0;let e=t|0;if(e!==t)e^=t*4294967295;while(t>4294967295)t/=4294967295,e^=t;return Be(e)}function Su(t){let e=Zr[t];if(e===void 0){if(e=Gr(t),Xr===qu)Xr=0,Zr={};Xr++,Zr[t]=e}return e}function Gr(t){let e=0;for(let r=0;r<t.length;r++)e=31*e+t.charCodeAt(r)|0;return Be(e)}function Ou(t){let e=Ni[t];if(e!==void 0)return e;return e=Rn(),Ni[t]=e,e}function bu(t){let e=ki.get(t);if(e!==void 0)return e;return e=Rn(),ki.set(t,e),e}var Mu=(t)=>t.valueOf!==Object.prototype.valueOf?t.valueOf():t;function Rn(){let t=++Jr;if(Jr&1073741824)Jr=0;return t}var ki=new WeakMap,Ni=Object.create(null),Jr=0,Eu=16,qu=255,Xr=0,Zr={};function ju(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+Vi(X(i),X(n))|0}:(i,n)=>{s=s+Vi(X(i),X(n))|0}:e?(i)=>{s=31*s+X(i)|0}:(i)=>{s=s+X(i)|0}),Iu(t.size,s)}var Vi=(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=Be(e^e>>>16),e}function Nt(t){try{return typeof t==="string"?JSON.stringify(t):String(t)}catch{return JSON.stringify(t)}}var b=(t,e)=>t===e?t:kr(t)?e:t.create?t.create(e):t.constructor(e),Uu=(t,e)=>b(t,(w(t)?H:j(t)?yt:pt)(e)),mi=(...t)=>t,k=(t)=>D(t)?t:it(t);class Z{size=0;static{this.prototype[zn]=!0,this.prototype.__toStringMapper=Nt,this.prototype[Symbol.iterator]=this.prototype.values,this.prototype.toJSON=this.prototype.toArray,this.prototype.contains=this.prototype.includes}equals(t){return ts(this,t)}hashCode(){return this.__hash??(this.__hash=ju(this))}toArray(){U(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 Hn(this)}toJS(){return De(this)}toKeyedSeq(){return new os(this,!0)}toMap(){throw Error("toMap: not patched — import CollectionConversions")}toObject(){U(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}toOrderedMap(){throw Error("toOrderedMap: not patched — import CollectionConversions")}toOrderedSet(){throw Error("toOrderedSet: not patched — import CollectionConversions")}toSet(){throw Error("toSet: not patched — import CollectionConversions")}toSetSeq(){return new 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(!D(s))s=e?Jn(s):Xn(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 Zn(r))}includes(t){return this.some((e)=>I(e,t))}every(t,e){U(this.size);let r=!0;return this.__iterate((s,i,n)=>{if(!t.call(e,s,i,n))return r=!1,!1}),r}entries(){return this.__iterator()}filter(t,e){let r=this,s=w(this),i=G(r);if(s)i.has=(n)=>{let h=r.get(n,g);return h!==g&&!!t.call(e,h,n,r)},i.get=(n,h)=>{let u=r.get(n,g);return u!==g&&t.call(e,u,n,r)?u:h};return i.__iterateUncached=function(n,h){let u=0;return r.__iterate((o,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)=>Uu(this,i))}find(t,e,r){let s=this.findEntry(t,e);return s?s[1]:r}forEach(t,e){return U(this.size),this.__iterate(e?t.bind(e):t)}join(t){U(this.size),t=t!==void 0?String(t):",";let e="",r=!0;return this.__iterate((s)=>{if(r)r=!1;else e+=t;e+=s!==null&&s!==void 0?String(s):""}),e}keys(){let t=this.__iterator(),e={done:!1,value:void 0};return K(()=>{let r=t.next();if(r.done)return A;return e.value=r.value[0],e})}map(t,e){return b(this,In(this,t,e))}reduce(t,e=g,r){return Qi(this,t,e,r,e===g,!1)}reduceRight(t,e=g,r){return Qi(this,t,e,r,e===g,!0)}reverse(){return b(this,Un(this,w(this)))}slice(t,e){return b(this,An(this,t,e,w(this)))}some(t,e){U(this.size);let r=!1;return this.__iterate((s,i,n)=>{if(t.call(e,s,i,n))return r=!0,!1}),r}sort(t){return b(this,xi(this,t))}values(){let t=this.__iterator(),e={done:!1,value:void 0};return K(()=>{let r=t.next();if(r.done)return A;return e.value=r.value[1],e})}butLast(){return this.slice(0,-1)}isEmpty(){return this.size!==void 0?this.size===0:!this.some(()=>!0)}count(t,e){return At(t?this.toSeq().filter(t,e):this)}countBy(t,e){throw Error("countBy: not patched — import CollectionConversions")}entrySeq(){let t=this;if(t._cache)return new ue(t._cache);let e=t.toSeq().map(lu).toIndexedSeq();return e.fromEntrySeq=()=>t.toSeq(),e}filterNot(t,e){return this.filter(Rr(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(gn,null,t)}flatMap(t,e){return b(this,this.toSeq().map((r,s)=>(w(this)?H:j(this)?yt:pt)(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)&&D(_))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)&&D(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 Bn(this)}get(t,e){return this.find((r,s)=>I(s,t),void 0,e)}getIn(t,e){return vr(this,t,e)}groupBy(t,e){throw Error("groupBy: not patched — import CollectionConversions")}has(t){return this.get(t,g)!==g}hasIn(t){return Dn(this,t)}isSubset(t){let e=typeof t.includes==="function"?t:k(t);return this.every((r)=>e.includes(r))}isSuperset(t){return(typeof t.isSubset==="function"?t:k(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 Ue(this,t)}maxBy(t,e){return Ue(this,e,t)}min(t){return Ue(this,t?Gi(t):Yi)}minBy(t,e){return Ue(this,e?Gi(e):Yi,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(Rr(t),e)}sortBy(t,e){return b(this,xi(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 K(()=>{if(u)return A;let o=n.next();if(o.done)return o;if(!t.call(e,o.value[1],o.value[0],h))return u=!0,A;return o})},b(this,s)}takeUntil(t,e){return this.takeWhile(Rr(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:ss(t);class es extends Z{static{this.prototype[Ke]=!0,this.prototype.__toStringMapper=(t,e)=>`${Nt(e)}: ${Nt(t)}`,this.prototype[Symbol.iterator]=Z.prototype.entries,this.prototype.toJSON=function(){U(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}}flip(){return b(this,jn(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 $t extends Z{static{this.prototype[Le]=!0,this.prototype[rt]=!0}toKeyedSeq(){return new os(this,!1)}findIndex(t,e){let r=this.findEntry(t,e);return r?r[0]:-1}indexOf(t){let e=this.keyOf(t);return e===void 0?-1:e}lastIndexOf(t){let e=this.lastKeyOf(t);return e===void 0?-1:e}splice(t,e=g,...r){if(t===void 0)return this;let s=e!==g;if(e=s?Math.max(e||0,0):0,s&&!e&&r.length===0)return this;t=Wt(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=Wr(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(mi,...t)}zipAll(...t){let e=[this,...t];return b(this,Wr(this,mi,e,!0))}zipWith(t,...e){let r=[this,...e];return b(this,Wr(this,t,r))}}var pt=(t)=>D(t)&&!Fr(t)?t:Vt(t);class Qe extends Z{static{this.prototype.has=Z.prototype.includes,this.prototype.contains=Z.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()}}k.Keyed=H;k.Indexed=yt;k.Set=pt;var Hr=$t.prototype,it=(t)=>t===void 0||t===null?hs():x(t)?t.toSeq():Au(t),G=(t)=>Object.create((w(t)?Jt:j(t)?gt:is).prototype);class ft extends Z{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 K(()=>{if(s===r)return A;return i.value=e[t?r-++s:s++],i})}return this.__iteratorUncached(t)}}var rs={cacheResult:ft.prototype.cacheResult,__iterateUncached:ft.prototype.__iterateUncached,__iterate:ft.prototype.__iterate,__iterator:ft.prototype.__iterator},ss=(t)=>t===void 0||t===null?hs().toKeyedSeq():D(t)?w(t)?t.toSeq():t.fromEntrySeq():at(t)?t.toSeq():Jn(t);class Jt extends es{static{this.prototype[ne]=!0,Object.assign(this.prototype,rs)}toSeq(){return this}toKeyedSeq(){return this}}var lt=(t)=>t===void 0||t===null?hs():D(t)?w(t)?t.entrySeq():t.toIndexedSeq():at(t)?t.toSeq().entrySeq():Xn(t);lt.of=(...t)=>lt(t);class gt extends $t{static{this.prototype[ne]=!0,Object.assign(this.prototype,rs)}toSeq(){return this}toIndexedSeq(){return this}toString(){return this.__toString("Seq [","]")}}var Vt=(t)=>(D(t)&&!Fr(t)?t:lt(t)).toSetSeq();Vt.of=(...t)=>Vt(t);class is extends Qe{static{this.prototype[ne]=!0,Object.assign(this.prototype,rs)}toSeq(){return this}toSetSeq(){return this}}it.isSeq=kr;it.Keyed=ss;it.Set=Vt;it.Indexed=lt;class ue extends gt{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 ns extends Jt{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 Wn extends gt{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=pn(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 hs=()=>new ue([]),us=(t)=>$n(t)?new ue(t):yn(t)?new Wn(t):void 0;function Jn(t){let e=us(t);if(e)return e.fromEntrySeq();if(typeof t==="object")return new ns(t);throw TypeError(`Expected Array or collection object of [k, v] entries, or keyed object: ${t}`)}function Xn(t){let e=us(t);if(e)return e;throw TypeError(`Expected Array or collection object of values: ${t}`)}function Au(t){let e=us(t);if(e)return pu(t)?e.fromEntrySeq():gu(t)?e.toSetSeq():e;if(typeof t==="object")return new ns(t);throw TypeError(`Expected Array or collection object of values, or keyed object: ${t}`)}class Zn 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[Ke])this[Ke]=!0;if(i[Le])this[Le]=!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 K(()=>n()||A)}}class os extends Jt{static{this.prototype[rt]=!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=Un(this,!0);if(!this._useKeys)t.valueSeq=()=>this._iter.toSeq().reverse();return t}map(t,e){let r=In(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 Hn extends gt{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 ee(this._iter.__iterator(t),(s,i,n)=>{n[0]=t?r-++e:e++,n[1]=i})}}class Tn extends is{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 ee(this._iter.__iterator(t),(e,r,s)=>{s[0]=r,s[1]=r})}}class Bn extends Jt{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){vi(s),r++;let i=D(s);return t(i?s.get(1):s[1],i?s.get(0):s[0],this)}},e),r}__iteratorUncached(t){let e=this._iter.__iterator(t);return M((r)=>{while(!0){let s=e.next();if(s.done)return!1;let i=s.value[1];if(i){vi(i);let n=D(i);return r[0]=n?i.get(0):i[0],r[1]=n?i.get(1):i[1],!0}}})}}function Xt(){if(this._iter.cacheResult)return this._iter.cacheResult(),this.size=this._iter.size,this;return ft.prototype.cacheResult.call(this)}function vi(t){if(t!==Object(t))throw TypeError(`Expected [K, V] tuple: ${t}`)}var N=(t)=>t===void 0||t===null?T():he(t)&&!F(t)?t:T().withMutations((e)=>{let r=H(t);U(r.size),r.forEach((s,i)=>e.set(i,s))});class cs extends es{static{wt(this,{asImmutable:oe,asMutable:ce,deleteIn:Kt,merge:Yr,mergeWith:Fn,mergeDeep:Nn,mergeDeepWith:Vn,mergeDeepIn:bs,mergeIn:Os,setIn:ws,update:zs,updateIn:Ss,wasAltered:ds,withMutations:fe,removeIn:Kt,concat:Yr,[On]:!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 N(t)}toString(){return this.__toString("Map {","}")}get(t,e){return this._root?this._root.get(0,X(t),t,e):e}set(t,e){return en(this,t,e)}remove(t){return en(this,t,g)}deleteAll(t){let e=k(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 T()}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 Ae(this._root,!1,0)}values(){if(!this._root)return ct();return Ae(this._root,!1,1)}entries(){if(!this._root)return ct();return Ae(this._root,!1)}__iterator(t){if(!this._root)return ct();return Ae(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 T();return this.__ownerID=t,this.__altered=!1,this}return ls(this.size,this._root,t,this.__hash)}}N.isMap=he;class fs{constructor(t,e){this.ownerID=t,this.entries=e}get(t,e,r,s){return Qn(this.entries,r,s)}iterate(t,e){return Gn(this.entries,t,e)}update(t,e,r,s,i,n,h){let u=i===g,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(W(h),u||!_)W(n);if(u&&f===1)return;if(!_&&!u&&f>=Wu)return $u(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 fs(t,a)}}class Ge{constructor(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}iterate(t,e){return Yn(this.nodes,t,e)}get(t,e,r,s){let i=1<<((t===0?e:e>>>t)&$),n=this.bitmap;return(n&i)===0?s:this.nodes[sn(n&i-1)].get(t+z,e,r,s)}update(t,e,r,s,i,n,h){let u=(e===0?r:r>>>e)&$,o=1<<u,c=this.bitmap,f=(c&o)!==0;if(!f&&i===g)return this;let _=sn(c&o-1),l=this.nodes,a=f?l[_]:void 0,y=as(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&&rn(l[_^1]))return l[_^1];if(f&&y&&l.length===1&&rn(y))return y;let p=t&&t===this.ownerID,S=f?y?c:c^o:c|o,O=f?y?Pn(l,_,y,p):Ru(l,_,p):Du(l,_,y,p);if(p)return this.bitmap=S,this.nodes=O,this;return new Ge(t,S,O)}}class _s{constructor(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}iterate(t,e){return Yn(this.nodes,t,e)}get(t,e,r,s){let i=(t===0?e:e>>>t)&$,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)&$,o=i===g,c=this.nodes,f=c[u];if(o&&!f)return this;let _=as(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<Xu)return Ku(t,c,l,u)}let a=t&&t===this.ownerID,y=Pn(c,u,_,a);if(a)return this.count=l,this.nodes=y,this;return new _s(t,l,y)}}class Ye{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}get(t,e,r,s){return Qn(this.entries,r,s)}iterate(t,e){return Gn(this.entries,t,e)}update(t,e,r,s,i,n,h){if(r!==this.keyHash){if(i===g)return this;return W(h),W(n),ys(this,t,e,r,[s,i])}let u=i===g,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(W(h),u||!_)W(n);if(u&&f===2)return new dt(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 dt{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===g,o=I(s,this.entry[0]);if(o?i===this.entry[1]:u)return this;if(W(h),u){W(n);return}if(o){if(t&&t===this.ownerID)return this.entry[1]=i,this;return new dt(t,this.keyHash,[s,i])}return W(n),ys(this,t,e,X(s),[s,i])}}function Qn(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 Gn(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 Yn(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 Ae(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 K(()=>{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 A})}var ls=(t,e,r,s)=>new cs(t,e,r,s),tn,T=()=>tn||(tn=ls(0));function en(t,e,r){let s,i;if(!t._root){if(r===g)return t;i=1,s=new fs(t.__ownerID,[[e,r]])}else{let n=Qr(),h=Qr();if(s=as(t._root,t.__ownerID,0,X(e),e,r,n,h),!h.value)return t;i=t.size+(n.value?r===g?-1:1:0)}if(t.__ownerID)return t.size=i,t._root=s,t.__hash=void 0,t.__altered=!0,t;return s?ls(i,s):T()}function as(t,e,r,s,i,n,h,u){if(!t){if(n===g)return t;return W(u),W(h),new dt(e,s,[i,n])}return t.update(e,r,s,i,n,h,u)}var rn=(t)=>t.constructor===dt||t.constructor===Ye;function ys(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)&$,h=(r===0?s:s>>>r)&$,u=new dt(e,s,i),o=n===h?[ys(t,e,r+z,s,i)]:n<h?[t,u]:[u,t];return new Ge(e,1<<n|1<<h,o)}function $u(t,e,r,s){if(!t)t=new He;let i=new dt(t,X(r),[r,s]);for(let[n,h]of e)i=i.update(t,0,X(n),n,h);return i}function Ku(t,e,r,s){let i=0,n=0,h=Array(r);for(let u=0,o=1,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 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 _s(t,n+1,h)}function sn(t){return t-=t>>1&1431655765,t=(t&858993459)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,t+=t>>16,t&127}function Pn(t,e,r,s){let i=s?t:t.slice();return i[e]=r,i}function 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,Xu=q/4;function Re(t){if(Array.isArray(t))return t.slice();return{...t}}var ps=(t,e,r)=>gs(t,e,Zu(r));function gs(t,e,r){if(!st(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=Re(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=Re(i);i[o]=f}};for(let u of e)n(u).forEach(h);return i}function Zu(t){function e(r,s,i){return st(r)&&st(s)&&Hu(r,s)?gs(r,[s],e):t?t(r,s,i):s}return e}function Hu(t,e){let r=it(t),s=it(e);return j(r)===j(s)&&w(r)===w(s)}function Tu(t,e){if(!st(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=Re(t);if(Array.isArray(r))r.splice(e,1);else delete r[e];return r}function Bu(t,e,r){if(!st(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=Re(t);return s[e]=r,s}function Zt(t,e,r,s){if(!s)s=r,r=void 0;let i=xn(x(t),t,Kn(e),0,r,s);return i===g?r:i}function xn(t,e,r,s,i,n){let h=e===g;if(s===r.length){let _=h?i:e,l=n(_);return l===_?e:l}if(!h&&!st(e))throw TypeError(`Cannot update within non-data-structure value in path [${Array.from(r).slice(0,s).map(Nt)}]: ${e}`);let u=r[s],o=h?g:Ln(e,u,g),c=xn(o===g?t:x(o),o,r,s+1,i,n);if(c===o)return e;if(c===g)return Tu(e,u);let f=h?t?T():{}:e;return Bu(f,u,c)}var Qu=(t,e)=>Zt(t,e,()=>g),Gu=(t,e,r)=>Zt(t,e,g,()=>r);function Cn(t,e,r,s){return Zt(t,[e],r,s)}function oe(){return this.__ensureOwner()}function ce(){return this.__ownerID?this:this.__ensureOwner(new He)}function ds(){return this.__altered}function fe(t){let e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Yu(t,e){return vr(this,t,e)}function Pu(t){return Dn(this,t)}function Kt(t){return Qu(this,t)}function ws(t,e){return Gu(this,t,e)}function zs(t,e,r){return typeof t==="function"?t(this):Cn(this,t,e,r)}function Ss(t,e,r){return Zt(this,t,e,r)}function nn(){U(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}function Yr(...t){return kn(this,t)}function Fn(t,...e){if(typeof t!=="function")throw TypeError(`Invalid merger function: ${t}`);return kn(this,e,t)}function kn(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)=>{Cn(i,u,g,(o)=>o===g?h:r(o,h,u))}:(h,u)=>{i.set(u,h)};for(let h of s)h.forEach(n)})}function Nn(...t){return ps(this,t)}function Vn(t,...e){return ps(this,e,t)}function Os(t,...e){return Zt(this,t,T(),(r)=>gs(r,e))}function bs(t,...e){return Zt(this,t,T(),(r)=>ps(r,e))}function wt(t,e){Object.assign(t.prototype,e)}var R=(t)=>{let e=mt();if(t===void 0||t===null)return e;if(Nr(t))return t;let r=yt(t),s=r.size;if(s===0)return e;if(U(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))})};R.of=(...t)=>R(t);class mn extends $t{static{wt(this,{asImmutable:oe,asMutable:ce,deleteIn:Kt,mergeDeepIn:bs,mergeIn:Os,setIn:ws,update:zs,updateIn:Ss,wasAltered:ds,withMutations:fe,removeIn:Kt,[Sn]:!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 R(t)}toString(){return this.__toString("List [","]")}get(t,e){if(t=et(this,t),t>=0&&t<this.size){t+=this._origin;let r=eh(this,t);return r&&r.array[t&$]}return e}set(t,e){return Cu(this,t,e)}remove(t){return!this.has(t)?this:t===0?this.shift():t===this.size-1?this.pop():this.splice(t,1)}insert(t,e){return this.splice(t,0,e)}clear(){if(this.size===0)return this;if(this.__ownerID)return this.size=this._origin=this._capacity=0,this._level=z,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this;return mt()}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=yt(typeof r!=="string"&&yn(r)?r:[r]);if(s.size!==0)e.push(s)}if(e.length===0)return this;if(this.size===0&&!this.__ownerID&&e.length===1)return R(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,Wt(t,r),ie(e,r))}__iterate(t,e){let r=e?this.size:0;return xu(this,(s)=>t(s,e?--r:r++,this),e),e?this.size-r:r}__iterator(t){let e=t?this.size:0,r=hn(this,t);return M((s)=>{let i=r.next();if(i.done)return!1;return s[0]=t?--e:e++,s[1]=i.value,!0})}values(){return hn(this,!1)}keys(){return Xe(this.size)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return mt();return this.__ownerID=t,this.__altered=!1,this}return _e(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash)}}R.isList=Nr;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&$;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=Lt(this,t);if(!i)for(let u=0;u<s;u++)h.array[u]=void 0;if(n)h.array[s]=n;return h}removeAfter(t,e,r){if(r===(e?1<<e+z:q)||this.array.length===0)return this;let s=r-1>>>e&$;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=Lt(this,t);if(n.array.splice(s+1),i)n.array[s]=i;return n}}function hn(t,e){let{_origin:r,_capacity:s}=t,i=Dt(s),n=t._tail,h=[];o(t._root,t._level,0);let u={done:!1,value:void 0};return K(()=>{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 A});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 xu(t,e,r){let{_origin:s,_capacity:i}=t,n=Dt(i),h=t._tail,u=t._level,o=t._root;return u===0?vn(o,0,s,i,n,h,e,r):th(o,u,0,s,i,n,h,e,r)}function vn(t,e,r,s,i,n,h,u){let o=e===i?n?.array:t?.array,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 th(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?vn(c?.[a],y,s,i,n,h,u,o):th(c?.[a],l,y,s,i,n,h,u,o))===!1)return!1}}var _e=(t,e,r,s,i,n,h)=>new mn(t,e,r,s,i,n,h),mt=()=>_e(0,0,z);function Cu(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=Qr();if(e>=Dt(t._capacity))s=Pr(s,t.__ownerID,0,e,r,n);else i=Pr(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 Pr(t,e,r,s,i,n){let h=s>>>r&$,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=Pr(c,e,r-z,s,i,n);if(f===c)return t;return o=Lt(t,e),o.array[h]=f,o}if(u&&t.array[h]===i)return t;if(n)W(n);if(o=Lt(t,e),i===void 0&&h===o.array.length-1)o.array.pop();else o.array[h]=i;return o}function Lt(t,e){if(e&&e===t?.ownerID)return t;return new _t(t?.array.slice()??[],e)}function eh(t,e){if(e>=Dt(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&$],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 He,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 _=Dt(n),l=Dt(u);while(l>=1<<o+z)c=new _t(c?.array.length?[c]:[],s),o+=z;let a=t._tail,y=l<_?eh(t,u-1):l>_?new _t([],s):a;if(a&&l>_&&h<n&&a.array.length){c=Lt(c,s);let p=c;for(let S=o;S>z;S-=z){let O=_>>>S&$;p=p.array[O]=Lt(p.array[O],s)}p.array[_>>>z&$]=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 p=h>>>o&$;if(p!==l>>>o&$)break;if(p)f+=(1<<o)*p;o-=z,c=c.array[p]}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 _e(h,u,o,c,y)}var Dt=(t)=>t<q?0:t-1>>>z<<z,Y=(t)=>t===void 0||t===null?vt():Te(t)?t:vt().withMutations((e)=>{let r=H(t);U(r.size),r.forEach((s,i)=>e.set(i,s))});Y.of=(...t)=>Y(t);class rh extends cs{static{wt(this,{[rt]:!0,[re]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.OrderedMap",keys:Z.prototype.keys,values:Z.prototype.values,__iterate:Z.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 un(this,t,e)}remove(t){return un(this,t,g)}entries(){return this.__iterator(!1)}__iterator(t){let e=this._list.__iterator(t);return M((r)=>{while(!0){let s=e.next();if(s.done)return!1;let i=s.value[1];if(i)return r[0]=i[0],r[1]=i[1],!0}})}__ensureOwner(t){if(t===this.__ownerID)return this;let e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);if(!t){if(this.size===0)return vt();return this.__ownerID=t,this.__altered=!1,this._map=e,this._list=r,this}return Ms(e,r,t,this.__hash)}}Y.isOrderedMap=Te;var Ms=(t,e,r,s)=>new rh(t,e,r,s),vt=()=>Ms(T(),mt());function un(t,e,r){let{_map:s,_list:i}=t,n=s.get(e),h=n!==void 0,u,o;if(r===g){if(!h)return t;if(i.size>=q&&i.size>=s.size*2){let c=[];if(i.forEach((f,_)=>{if(f!==void 0&&n!==_)c.push(f)}),o=mt().withMutations((f)=>{for(let _=0;_<c.length;_++)f.set(_,c[_])}),u=T().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 Ms(u,o)}var We=(t)=>t===void 0||t===null?Je():mr(t)?t:Je().pushAll(t);We.of=(...t)=>We(t);class sh extends $t{static{wt(this,{asImmutable:oe,asMutable:ce,wasAltered:ds,withMutations:fe,[Mn]:!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 We(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 Tr(this,e,r)}pushAll(t){if(t=yt(t),t.size===0)return this;if(this.size===0&&mr(t))return t;U(t.size);let e=this.size,r=this._head;return t.__iterate((s)=>{e++,r={value:s,next:r}},!0),Tr(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=Wt(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 Tr(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 Es(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 K(()=>{if(!t)return A;return e.value=t.value,t=t.next,e})}keys(){return Xe(this.size)}}We.isStack=mr;function Tr(t,e,r){if(t.__ownerID)return t.size=e,t._head=r,t.__hash=void 0,t.__altered=!0,t;return Es(e,r)}var Es=(t,e,r,s)=>new sh(t,e,r,s),on,Je=()=>on||(on=Es(0)),E=(t)=>t===void 0||t===null?te():Vr(t)&&!F(t)?t:te().withMutations((e)=>{let r=pt(t);U(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=k(t).toArray(),t.length?E(t.pop()).intersect(...t):te()};E.union=(t)=>{let e=k(t).toArray();return e.length?E(e.pop()).union(...e):te()};class qs extends Qe{static{wt(this,{withMutations:fe,asImmutable:oe,asMutable:ce,[bn]:!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 $e(this,this._map.set(t,t))}remove(t){return $e(this,this._map.remove(t))}clear(){return $e(this,this._map.clear())}map(t,e){let r=!1,s=$e(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 pt(r).forEach((s)=>e.add(s))})}intersect(...t){return fn(this,t,(e,r)=>!r.every((s)=>s.includes(e)))}subtract(...t){return fn(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 ih(t,e)}__ensureOwner(t){if(t===this.__ownerID)return this;let e=this._map.__ensureOwner(t);if(!t){if(this.size===0)return this.__empty();return this.__ownerID=t,this._map=e,this}return this.__make(e,t)}}E.isSet=Vr;var ih=(t,e)=>new qs(t,e),cn,te=()=>cn||(cn=ih(T()));function fn(t,e,r){if(e.length===0)return t;return e=e.map((s)=>pt(s)),t.withMutations((s)=>{t.forEach((i)=>{if(r(i,e))s.remove(i)})})}function $e(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 Rt=(t)=>t===void 0||t===null?xr():qn(t)?t:xr().withMutations((e)=>{let r=pt(t);U(r.size),r.forEach((s)=>e.add(s))});Rt.of=(...t)=>Rt(t);Rt.fromKeys=(t)=>Rt(H(t).keySeq());class nh extends qs{static{wt(this,{[rt]:!0,[Symbol.toStringTag]:"Immutable.OrderedSet",zip:Hr.zip,zipWith:Hr.zipWith,zipAll:Hr.zipAll})}create(t){return Rt(t)}toString(){return this.__toString("OrderedSet {","}")}__empty(){return xr()}__make(t,e){return hh(t,e)}}Rt.isOrderedSet=qn;var hh=(t,e)=>new nh(t,e),xr=()=>hh(vt());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 le=(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 ${js(this)} with property "${f}" since that property name is part of the Record API.`);else Nu(i,f)}}return this.__ownerID=void 0,this._values=R().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 uh{static{wt(this,{asImmutable:oe,asMutable:ce,deleteIn:Kt,getIn:Yu,hasIn:Pu,merge:Yr,mergeWith:Fn,mergeDeep:Nn,mergeDeepWith:Vn,mergeDeepIn:bs,mergeIn:Os,setIn:ws,toObject:nn,update:zs,updateIn:Ss,withMutations:fe,removeIn:Kt,toJSON:nn,[En]:!0,[re]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Record"})}toString(){let t=this._keys.map((e)=>`${e}: ${Nt(this.get(e))}`).join(", ");return`${js(this)} { ${t} }`}equals(t){return this===t||at(t)&&Ut(this).equals(Ut(t))}hashCode(){return Ut(this).hashCode()}has(t){return Object.hasOwn(this._indices,t)}get(t,e){if(!this.has(t))return e;let r=this._indices[t],s=this._values.get(r);return s===void 0?this._defaultValues[t]:s}set(t,e){if(this.has(t)){let r=this._values.set(this._indices[t],e===this._defaultValues[t]?void 0:e);if(r!==this._values&&!this.__ownerID)return Br(this,r)}return this}remove(t){return this.set(t)}clear(){let t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:Br(this,t)}wasAltered(){return this._values.wasAltered()}toSeq(){return Ut(this)}toJS(){return De(this)}entries(){return this.__iterator()}__iterate(t,e){return Ut(this).__iterate(t,e)}__iterator(t){return Ut(this).__iterator(t)}__ensureOwner(t){if(t===this.__ownerID)return this;let e=this._values.__ensureOwner(t);if(!t)return this.__ownerID=t,this._values=e,this;return Br(this,e,t)}}le.isRecord=at;var js=(t)=>t.constructor.displayName||t.constructor.name||"Record";class oh extends Jt{constructor(t){super();this._record=t,this.size=t._keys.length}get(t,e){return this._record.get(t,e)}has(t){return this._record.has(t)}__iterateUncached(t,e){let r=this._record,s=r._keys,i=s.length,n=0;while(n!==i){let h=e?i-++n:n++,u=s[h];if(t(r.get(u),u,this)===!1)break}return n}__iteratorUncached(t){let e=this._record,r=e._keys,s=r.length,i=0;return M((n)=>{if(i===s)return!1;let h=t?s-++i:i++,u=r[h];return n[0]=u,n[1]=e.get(u),!0})}}var Ut=(t)=>new oh(t);le.getDescriptiveName=js;var ku=uh.prototype;function Br(t,e,r){let s=Object.create(Object.getPrototypeOf(t));return s._values=e,s.__ownerID=r,s}function Nu(t,e){Object.defineProperty(t,e,{get(){return this.get(e)},set(r){kt(this.__ownerID,"Cannot set on an immutable record."),this.set(e,r)}})}var _n=(t,e,r=1)=>{if(kt(r!==0,"Cannot step a Range by 0"),kt(t!==void 0,"You must define a start value when using Range"),kt(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 Is(t,e,r,s)};class Is extends gt{_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=Wt(t,this.size),e=ie(e,this.size),e<=t)return _n(0,0);return _n(this.get(t,this._end),this.get(e,this._end),this._step)}indexOf(t){let e=t-this._start;if(e%this._step===0){let r=e/this._step;if(r>=0&&r<this.size)return r}return-1}lastIndexOf(t){return this.indexOf(t)}__iterateUncached(t,e=!1){let r=this.size,s=this._step,i=e?this._start+(r-1)*s:this._start,n=0;while(n!==r){let h=i;i+=e?-s:s;let u=e?r-++n:n++;if(t(h,u,this)===!1)break}return n}__iteratorUncached(t=!1){let e=this.size,r=this._step,s=t?this._start+(e-1)*r:this._start,i=0;return M((n)=>{if(i===e)return!1;let h=s;return s+=t?-r:r,n[0]=t?e-++i:i++,n[1]=h,!0})}values(){let t=this.size,e=this._step,r=this._start,s=0,i={done:!1,value:void 0};return K(()=>{if(s===t)return A;return i.value=r,r+=e,s++,i})}keys(){return Xe(this.size)}equals(t){return t instanceof Is?this._start===t._start&&this._end===t._end&&this._step===t._step:ts(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}class Cr extends gt{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 Cr(this._value,ie(e,r)-Wt(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 K(()=>{if(r===t)return A;return r++,s.value=e,s})}keys(){return Xe(this.size)}equals(t){return t instanceof Cr?this.size===t.size&&I(this._value,t._value):ts(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var Vu=["nid","cid","eid","vid","si","sk"];class Us{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??so,this.cache=h??new zr}setNullCache(){this.cache=new wr}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 Vu)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 p={key:a,value:y},S=`${s}-${a}`,O;if(f)u.call(t.it,p,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 zt=t.enter(y,p,!1),St=r.render(zt,this);if(_.push(this.renderMetadata("Each",{nid:s,[o]:a})),f)this.cache.set2(t.it,y,S,St);else this.cache.set(y,S,St);_.push(St)}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*mu(t){let e=0;for(let r of t)yield[e++,r]}function*vu(t){for(let[e,r]of t.toSeq().entries())yield[e,r]}var ch=new Map,to=["si",mu],eo=["sk",vu],ro=["si",function*(e){}];function so(t){return j(t)?to:w(t)?eo:ch.get(t?.constructor)??ro}var fh=Symbol("BadValue"),yh=(t)=>t;class B{constructor(t,e,r,s,i=null){this.type=t,this.name=e,this.typeCheck=r,this.coercer=s,this.checks=[],this.defaultValue=i}toDataDef(){let{type:t,defaultValue:e}=this;return{type:t,defaultValue:e?.toJS?e.toJS():e}}getFirstFailingCheck(t){if(!this.typeCheck.isValid(t))return this.typeCheck;for(let e of this.checks)if(!e.isValid(t))return e;return null}isValid(t){return this.getFirstFailingCheck(t)===null}addCheck(t){return this.checks.push(t),this}coerceOr(t,e=null){if(this.isValid(t))return t;let r=this.coercer(t);return this.isValid(r)?r:e}coerceOrDefault(t){return this.coerceOr(t,this.defaultValue)}extendProtoForType(t,e){}extendProto(t){let{name:e}=this,r=e[0].toUpperCase()+e.slice(1),s=`set${r}`,i=this;t[s]=function(n){let h=i.coerceOr(n,fh);if(h===fh)return console.warn("invalid value",n),this;return this.set(e,h)},t[`update${r}`]=function(n){return this[s](n(this.get(e)))},t[`reset${r}`]=function(){return this.set(e,i.defaultValue)},t[`is${r}NotSet`]=function(){return this.get(e)==null},t[`is${r}Set`]=function(){return this.get(e)!=null},this.extendProtoForType(t,r)}}class $s{isValid(t){return!0}getMessage(t){return"Invalid"}}class ph extends $s{}var io=new ph;class V extends $s{constructor(t,e){super();this._isValid=t,this._getMessage=e}isValid(t){return this._isValid(t)}getMessage(t){return this._getMessage(t)}}var no=new V((t)=>Number.isInteger(t),()=>"Integer expected"),ho=new V((t)=>Number.isFinite(t),()=>"Float expected"),uo=new V((t)=>typeof t==="boolean",()=>"Boolean expected"),oo=new V((t)=>typeof t==="string",()=>"String expected"),co=new V((t)=>R.isList(t),()=>"List expected"),fo=new V((t)=>N.isMap(t),()=>"Map expected"),_o=new V((t)=>Y.isOrderedMap(t),()=>"OrderedMap expected"),lo=new V((t)=>E.isSet(t),()=>"Set expected"),ao=(t)=>!!t;class Ks extends B{constructor(t,e=!1){super("bool",t,uo,ao,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 Pe extends B{constructor(t,e=null){super("any",t,io,yh,e)}toDataDef(){let{defaultValue:t}=this;return{type:As(t)??"any",defaultValue:t?.toJS?t.toJS():t}}}var yo=(t)=>t?.toString?.()??"";class Ls extends B{constructor(t,e=""){super("text",t,oo,yo,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 po=(t)=>Number.isFinite(t)?Math.trunc(t):null;class gh extends B{constructor(t,e=0){super("int",t,no,po,e)}}var go=(t)=>null;class Ds extends B{constructor(t,e=0){super("float",t,ho,go,e)}}var As=(t)=>t?.constructor?.getMetaClass?.()?.name;class dh{constructor(t){this.typeName=t}isValid(t){return As(t)===this.typeName}getMessage(t){let e=As(t);return`Expected "${this.typeName}", got "${e}"`}}class wh extends B{constructor(t,e,r){super(t,e,new dh(t),yh,null);this.args=r}toDataDef(){return{component:this.typeName,args:this.args}}}var _h=Symbol("NONE");function Rs(t,e,r){Sh(t,e,zh),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,_h);if(u!==_h)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 zh=R(),wo=(t)=>Array.isArray(t)?R(t):null;class Ws extends B{constructor(t,e=zh){super("list",t,co,wo,e)}extendProtoForType(t,e){let{name:r}=this;Rs(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 zo=(t)=>N(t);class Js extends B{constructor(t,e=N()){super("map",t,fo,zo,e)}extendProtoForType(t,e){Rs(t,this.name,e)}}var So=(t)=>Y(t);class Xs extends B{constructor(t,e=Y()){super("omap",t,_o,So,e)}extendProtoForType(t,e){Rs(t,this.name,e)}}function Sh(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 lh=E(),Oo=(t)=>Array.isArray(t)?E(t):t instanceof Set?E(t):null;class Zs extends B{constructor(t,e=lh){super("set",t,lo,Oo,e)}extendProtoForType(t,e){let{name:r}=this;Sh(t,r,lh),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 ah(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 Oh{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]=ah(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]=ah(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 wh(e,t,r);return this.compFields.add(t),this.fields[t]=s,s}}var bh=new Map,bo={text:Ls,int:gh,float:Ds,bool:Ks,list:Ws,map:Js,omap:Xs,set:Zs,any:Pe};function Mo(t,{fields:e={},methods:r,statics:s}){let i=new Oh(t);for(let n in e){let h=e[n],u=typeof h;if(u==="string")i.addField(n,h,Ls);else if(u==="number")i.addField(n,h,Ds);else if(u==="boolean")i.addField(n,h,Ks);else if(R.isList(h)||Array.isArray(h))i.addField(n,R(h),Ws);else if(E.isSet(h)||h instanceof Set)i.addField(n,E(h),Zs);else if(Y.isOrderedMap(h))i.addField(n,h,Xs);else if(h?.type&&h?.defaultValue!==void 0){let o=bo[h.type]??Pe;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(N.isMap(h)||h?.constructor===Object)i.addField(n,N(h),Js);else{let o=bh.get(h?.constructor)??Pe;i.addField(n,h,o)}}if(r)i.methods(r);if(s)i.statics(s);return i.build()}var Eo=(t)=>new Mr(t.name??"Comp",Mo(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{raw:cc,raw:fc}=String;function _c(t,e){return new yr(t,e)}var qo=(t)=>typeof t==="string"?document.querySelector(t):t;function lc(t){let e=qo(t),r=new je,s=(o)=>new C(o),i=(o)=>new Ot(o),n={document},h=(o,c)=>Cs(o,c,n),u=new Us(r,Fs,s,i,h);return new Dr(e,h,r,u,Ct)}export{lc as tutuca,ch as seqInfoByClass,_c as macro,Te as isOrderedMap,Te as isOMap,he as isMap,Nr as isList,w as isKeyed,j as isIndexed,he as isIMap,fc as html,bh as fieldsByClass,cc as css,Eo as component,le as Record,Ct as ParseContext,Y as OMap,R as List,E as ISet,N as IMap};
|
|
1
|
+
class Tt{lookup(t,e=null){return e}setValue(t,e){return t}updateBindings(t,e){}isFrame=!0}class St extends Tt{constructor(t){super();this.binds=t}lookup(t,e){return t}setValue(t,e){return e}withIndex(t){return new St({...this.binds,key:t})}withKey(t){return new St({...this.binds,key:t})}updateBindings(t,e){Object.assign(e,this.binds)}isFrame=!1}class _e extends Tt{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 Pe(this.field,t)}withKey(t){return new Ye(this.field,t)}}class Ge extends Tt{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 Ye extends Ge{}class Pe extends Ge{}var K=Symbol("NONE");class Ce extends Tt{constructor(t,e){super();this.seqField=t,this.keyField=e}lookup(t,e=null){let r=t?.get(this.seqField,K),i=t?.get(this.keyField,K);return i!==K&&r?.get?r.get(i,e):e}setValue(t,e){let r=t?.get(this.seqField,K),i=t?.get(this.keyField,K);return r===K||i===K?t:t.set(this.seqField,r.set(i,e))}updateBindings(t,e){e.key=t?.get(this.keyField,null)}}class m{constructor(t=[]){this.steps=t}concat(t){return new m(this.steps.concat(t))}popStep(){return new m(this.steps.slice(0,-1))}lookup(t,e=null){let r=t;for(let i of this.steps)if(r=i.lookup(r,K),r===K)return e;return r}setValue(t,e){let r=Array(this.steps.length),i=t;for(let n=0;n<this.steps.length;n++)if(r[n]=i,i=this.steps[n].lookup(i,K),i===K)return t;let s=e;for(let n=this.steps.length-1;n>=0;n--)s=this.steps[n].setValue(r[n],s),r[n]=s;return s}buildStack(t){let e=t.it,r=e;for(let i of this.steps){if(r=i.lookup(r,K),r===K)return console.warn("bad PathItem",{root:e,curVal:r,step:i,path:this}),null;i.updateBindings(r,t.binds.head.bindings),t=t.enter(r,{},i.isFrame)}return t}static fromNodeAndEventName(t,e,r,i,s,n=!0){let h=[],u=0,o=[],f=null,c=[],_=!0;while(t&&t!==r&&u<i){if(t?.dataset){let{nid:l,si:a,sk:g}=Ti(t.previousSibling),{eid:w,cid:S,vid:q}=t.dataset;if(w!==void 0)o.push(w);if(S!==void 0){let dt=s.getComponentForId(+S,q);if(_){if(f=dh(dt,o,q,e),f===null&&n)return Sh;_=!1}let zt=zh(dt,c,q);if(zt)h.push(zt);o=[],c=[]}if(l!==void 0)c.push({nid:l,si:a,sk:g})}u+=1,t=t.parentNode}return[new m(h.reverse()),f]}static fromEvent(t,e,r,i,s=!0){let{type:n,target:h}=t;return m.fromNodeAndEventName(h,n,e,r,i,s)}}var Hi={};function Ti(t){if(t?.nodeType===8&&t.textContent[0]==="§"){let e=Ti(t.previousSibling);if(e!==Hi)return e;try{return JSON.parse(t.textContent.slice(1,-1))}catch(r){console.warn(r,t)}}return Hi}function dh(t,e,r,i){for(let s of e){let n=t.getEventForId(+s,r).getHandlersFor(i);if(n!==null)return n}return null}function zh(t,e,r){for(let i=0;i<e.length;i++){let s=t.getNodeForId(+e[i].nid,r),n=s.pathInNext?i+1:i,{si:h,sk:u,nid:o}=e[n],f=s.pathInNext?t.getNodeForId(+o,r).val.toPathItem():s.toPathItem();if(f!==null)return h!==void 0?f.withIndex(+h):u?f.withKey(u):f}return null}var Sh=[null,null];class xe{constructor(){this.pathChanges=[]}add(t){return this.pathChanges.push(t),this}field(t){return this.add(new _e(t))}index(t,e){return this.add(new Pe(t,e))}key(t,e){return this.add(new Ye(t,e))}}var Oh=/^[a-zA-Z][a-zA-Z0-9_]*$/,nt=(t)=>Oh.test(t),bh=/^-?[0-9]+(\.[0-9]+)?$/,Xi=(t,e)=>ke.parse(t,e),Xt=(t,e)=>new Q(t),Mh=(t,e)=>nt(t)?new ht(t):null,Eh=(t,e)=>nt(t)?new Yi(t):null,qh=(t,e)=>nt(t)?new Ve(t):null,jh=(t,e)=>nt(t)?new xi(t):null,Uh=(t,e)=>nt(t)?new Fi(t):null,Ah=(t,e)=>nt(t)?new ki(t):null,Ih=(t,e)=>nt(t)?new Pi(t):null;class Zi{constructor(){this.allowFieldOnly(),this.bindValIt=new Ve("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,i){return r?i(t,e):null}_parseSeqAccess(t,e){if(!this.okSeqAccess)return null;let r=t.indexOf("[");this.allowFieldOnly();let i=this.parse(t.slice(0,r),e),s=this.parse(t.slice(r+1,-1),e);return i&&s?new Ni(i,s):null}parse(t,e){switch($h(t)){case Vi:return this.parseIfOk(t,e,this.okStrTpl,Xi);case vi:return this.parseIfOk(t,e,this.okStrTpl,Xt);case mi:return this._parseSeqAccess(t,e);case le:return this.parseIfOk(t,e,this.okStrTpl,Xi)}let r=t.charCodeAt(0);switch(r){case 94:{let s=e.frame.macroVars?.[t.slice(1)];if(s!==void 0)return this.parse(s,e);return null}case 126:return this.parseIfOk(t.slice(1),e,this.okStrTpl,Xt);case 39:return this.parseIfOk(t.slice(1,-1),e,this.okStrTpl,Xt);case 64:return this.parseIfOk(t.slice(1),e,this.okBind,qh);case 42:return this.parseIfOk(t.slice(1),e,this.okDyn,jh);case 46:return this.parseIfOk(t.slice(1),e,this.okField,Uh);case 36:return this.parseIfOk(t.slice(1),e,this.okComputed,Ah);case 33:return this.parseIfOk(t.slice(1),e,this.okRequest,Ih)}let i=bh.test(t)?parseFloat(t):null;if(Number.isFinite(i))return this.parseIfOk(i,e,this.okConst,Xt);else if(t==="true"||t==="false")return this.parseIfOk(t==="true",e,this.okConst,Xt);else if(r>=97&&r<=122)return this.parseIfOk(t,e,this.okName,Mh);else if(r>=65&&r<=90)return this.parseIfOk(t,e,this.okType,Eh);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 i=this.parse(t,e);return i.toRawFieldVal?i.toRawFieldVal():new r(i.name)}parseHandlerName(t,e){return this._parseHandler(t,e,Bi)}parseAlter(t,e){return this._parseHandler(t,e,Qi)}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 ae{render(t,e){}eval(t){}toPathItem(){return null}}class Q extends ae{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 Fe extends ae{}class ke extends Fe{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),i=Array(r.length),s=!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 Q(h);i[n]=o,s&&=o instanceof Q}return s?new Q(i.map((n)=>n.value).join("")):new ke(i)}}class ht extends Fe{constructor(t){super();this.name=t}eval(t){return t.lookupName(this.name)}toString(){return this.name}}class Bi extends ht{eval(t){return t.getInputHandler(this.name)??Gi("input",this.name)}}class Qi extends ht{eval(t){return t.getAlterHandler(this.name)??Gi("alter",this.name)}}var Gi=(t,e)=>function(...r){return console.warn("handler not found",{type:t,name:e,args:r},this),this};class Yi extends ht{eval(t){return t.lookupType(this.name)}}class Pi extends ht{eval(t){return t.lookupRequest(this.name)}toString(){return`!${this.name}`}}class Ci extends ht{eval(t){return t.lookupFieldRaw(this.name)}toString(){return`.${this.name}`}}class Ne extends ae{render(t,e){return this.eval(t)}}class Zt extends Ne{constructor(t){super();this.name=t}}class Ve extends Zt{eval(t){return t.lookupBind(this.name)}toString(){return`@${this.name}`}}class xi extends Zt{eval(t){return t.lookupDynamic(this.name)}toPathItem(){return null}toString(){return`*${this.name}`}}class Fi extends Zt{eval(t){return t.lookupField(this.name)}toPathItem(){return new _e(this.name)}toRawFieldVal(){return new Ci(this.name)}toString(){return`.${this.name}`}}class ki extends Zt{eval(t){return t.lookupComputed(this.name)}toString(){return`$${this.name}`}}class Ni extends Ne{constructor(t,e){super();this.seqVal=t,this.keyVal=e}toPathItem(){return new Ce(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 Vi=0,mi=1,le=2,vi=3;function $h(t){let e=0,r=0;for(let i=0;i<t.length;i++)switch(t.charCodeAt(i)){case 91:if(e>0)return le;e+=1;break;case 93:if(r>0||e===0)return le;r+=1;break;case 123:return Vi;case 125:return vi}if(e>0||r>0)return e===1&&r===1?mi:le;return-1}var p=new Zi;class Ot{constructor(t){this.items=t}eval(t){return{}}static parse(t,e,r=!1){return er(e).parse(t,r)}isConstant(){return!1}}var Lh="itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected",Kh=new Set(Lh.split(","));class ts{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 i=r?p.parseAll(e,this.px):p.parseAttr(e,this.px);if(i!==null)this.attrs??=[],this.attrs.push(new ye(t,i)),this.hasDynamic||=!(i instanceof Q)}pushWrapper(t,e,r){let i={name:t,val:r,raw:e};return this.wrapperAttrs??=[],this.wrapperAttrs.push(i),i}parseIf(t,e){let r=p.parseCondValue(e,this.px);if(r)this.ifAttr=new is(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)??Bt}parseElse(t){if(this.ifAttr)this.ifAttr.elseVal=p.parseAttr(t,this.px)??Bt}parseEvent(t,e){let[r,...i]=t.slice(3).split("+"),s=rr.parse(e,this.px);if(s){if(this.events===null)this.events=this.px.registerEvents(),this.attrs??=[],this.attrs.push(new ge("data-eid",p.const(this.events.id)));this.events.add(r,s,i)}}parseDirective(t,e){switch(e){case"dangerouslysetinnerhtml":this.attrs??=[],this.attrs.push(new rs(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===""&&Kh.has(n)?!0:h;this.attrs.push(new ge(n,p.const(o)))}}let{attrs:r,hasDynamic:i}=this;return[i?new es(r):ve.fromAttrs(r??[]),this.wrapperAttrs,this.textChild]}}class ve extends Ot{eval(t){return this.items}static fromAttrs(t){let e={};for(let r of t)e[r.name]=r.value.eval(null);return new ve(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 es extends Ot{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 ge(t,new Q(e)))}toMacroVars(){let t={};for(let e of this.items)t[e.name]=e.value.toString();return t}}class tr{constructor(t){this.name=t}}class ye extends tr{constructor(t,e){super(t);this.value=e}eval(t){return this.value.eval(t)}}class ge extends ye{}class rs extends ye{constructor(t){super("dangerouslySetInnerHTML",t??p.nullConstVal)}eval(t){return{__html:`${this.value.eval(t)}`}}}var Bt=p.nullConstVal;class is extends tr{constructor(t,e){super(t);this.condVal=e,this.thenVal=this.elseVal=Bt}get anyBranchIsSet(){return this.thenVal!==Bt||this.elseVal!==Bt}eval(t){return this.condVal.eval(t)?this.thenVal.eval(t):this.elseVal.eval(t)}}var me=null;function er(t){return me??=new ts(t),me.clear(t),me}class rr{constructor(t,e=[]){this.handlerVal=t,this.args=e}getHandlerAndArgs(t,e){let r=Array(this.args.length);for(let i=0;i<r.length;i++)r[i]=this.args[i].eval(t);return[this.handlerVal.eval(t),r]}static parse(t,e){let[r,...i]=t.trim().split(/\s+/),s=p.parseHandlerName(r,e);if(s===null)return null;let n=Array(i.length);p.allowHandlerArg();for(let h=0;h<i.length;h++){let u=p.parse(i[h],e);n[h]=u!==null?u:p.nullConstVal}return new rr(s,n)}}class ir{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 bt{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 Gt extends bt{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 Qt extends Gt{render(t,e){return e.renderComment(this.v)}}function Dh(t){for(let e=0;e<t.length;e++){let r=t[e];if(r.isConstant())t[e]=new _r(r);else r.optimize()}}function ur(t){if(t.isConstant())return new _r(t);return t.optimize(),t}class or extends bt{constructor(t){super();this.childs=t}isConstant(){return this.childs.every((t)=>t.isConstant())}optimize(){Dh(this.childs)}}class pe extends or{constructor(t,e,r){super(r);this.tagName=t,this.attrs=e}render(t,e){let r=Array(this.childs.length);for(let i=0;i<r.length;i++)r[i]=this.childs[i]?.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 we extends or{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 sr=(t)=>t.length===1?t[0]:new we(t),Rh=/^[a-zA-Z][a-zA-Z0-9-]*$/,ss=null;class v extends bt{constructor(t,e){super();this.nodeId=t,this.val=e}toPathItem(){return this.val.toPathItem()}static parse(t,e){ss??=e.newDOMParser();let r=ss.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 Gt(t.textContent);else if(e.isCommentNode(t))return new Qt(t.textContent);let{childNodes:r,attributes:i,tagName:s}=t,n=Array(r.length);for(let h=0;h<r.length;h++)n[h]=v.fromDOM(r[h],e);if(s==="X"){if(i.length===0)return sr(n);let{name:h,value:u}=i[0],o=i.getNamedItem("as")?.value??null;switch(h){case"slot":return new ze(null,p.const(u),sr(n));case"text":return new hr(null,p.parseText(u,e)??p.const(""));case"render":return e.addNodeIf(_s,p.parseRender(u,e),o);case"render-it":return e.addNodeIf(ls,p.bindValIt,o);case"render-each":return cr.parse(e,p,u,o,i)}return new Qt(`Error: InvalidSpecialTagOp ${h}=${u}`)}else if(s.charCodeAt(1)===58&&s.charCodeAt(0)===88){let h=s.slice(2).toLowerCase();if(h==="slot"){let f=i.getNamedItem("name")?.value??"_";return e.frame.macroSlots[f]??sr(n)}let[u,o]=Ot.parse(i,e,!0);return e.onAttributes(u,o,null),ns(e.newMacroNode(h,u.toMacroVars(),n),e,o)}else if(Rh.test(s)){let[h,u,o]=Ot.parse(i,e);if(e.onAttributes(h,u,o),o)n.unshift(new hr(null,o));let f=s!=="PRE"?Xh(n):n;return ns(new pe(s.toLowerCase(),h,f),e,u)}return new Qt(`Error: InvalidTagName ${s}`)}}function ns(t,e,r){if(r)for(let i=r.length-1;i>=0;i--){let s=Wh(r[i],e);if(s)s.wrapNode(t),t=s}return t}function Wh(t,e){let r=Th[t.name],i=r.register?e.addNodeIf(r,t.val):new r(null,t.val);if(t.name==="each")i.iterInfo.enrichWithVal=t.enrichWithVal??null,i.iterInfo.whenVal=t.whenVal??null,i.iterInfo.loopWithVal=t.loopWithVal??null;return i}class cs extends bt{constructor(t,e,r,i){super();this.name=t,this.attrs=e,this.slots=r,this.px=i,this.node=null,this.dataAttrs={}}compile(t){let{name:e,attrs:r,slots:i}=this;if(this.px.isInsideMacro(e))throw Error(`Recursive macro expansion: ${e}`);let s=t.lookupMacro(e);if(s===null)this.node=new Qt(`bad macro: ${e}`);else{let n={...s.defaults,...r};this.node=s.expand(this.px.enterMacro(e,n,i));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=ur(this.node)}}class fr{constructor(t,e){this.defaults=t,this.rawView=e}expand(t){return v.parse(this.rawView,t)}}class de extends v{constructor(t,e,r){super(t,e);this.viewId=r}}class _s extends de{render(t,e){let r=t.enter(this.val.eval(t),{},!0);return e.renderIt(r,this.nodeId,"",this.viewId)}}class ls extends de{render(t,e){return e.renderIt(t,this.nodeId,"",this.viewId)}pathInNext=!0}class cr extends de{constructor(t,e,r){super(t,e,r);this.iterInfo=new lr(e,null,null,null)}render(t,e){return e.renderEach(t,this.iterInfo,this.nodeId,this.viewId)}static parse(t,e,r,i,s){let n=t.addNodeIf(cr,e.parseEach(r,t),i);if(n!==null){let h=er(t);h.eachAttr=h.pushWrapper("each",r,n.val);let u=s.getNamedItem("when");u&&h._parseWhen(u.value);let o=s.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 hr extends v{render(t,e){return e.renderText(this.val.eval(t))}}class _r extends bt{constructor(t){super();this.node=t,this._render=(e,r)=>{let i=t.render(e,r);return this._render=(s,n)=>i,i}}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=ur(this.node)}static register=!1}class as extends ut{render(t,e){return this.val.eval(t)?this.node.render(t,e):e.renderEmpty()}}class gs extends ut{render(t,e){return this.val.eval(t)?e.renderEmpty():this.node.render(t,e)}}class ys extends ut{render(t,e){return this.node.render(t.pushViewName(this.val.eval(t)),e)}}class ze extends ut{optimize(){this.node.optimize()}}class ps 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 St({})}wrapNode(t){this.node=t,this.node.setDataAttr("data-nid",this.nodeId)}static register=!0}class ws extends ut{constructor(t,e){super(t,e);this.iterInfo=new lr(e,null,null,null)}render(t,e){return e.renderEachWhen(t,this.iterInfo,this.node,this.nodeId)}toPathItem(){return new St({})}static register=!0}class lr{constructor(t,e,r,i){this.val=t,this.whenVal=e,this.loopWithVal=r,this.enrichWithVal=i}eval(t){let e=this.val.eval(t)??[],r=this.whenVal?.eval(t)??Jh,i=this.loopWithVal?.eval(t)??Hh,s=this.enrichWithVal?.eval(t)??null;return{seq:e,filter:r,loopWith:i,enricher:s}}}var Jh=(t,e,r)=>!0,Hh=(t)=>({seq:t}),Th={slot:ze,show:as,hide:gs,each:ws,scope:ps,"push-view":ys};class Yt{constructor(t,e,r,i,s,n,h,u){this.nodes=i??[],this.events=s??[],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:i,Text:s,Comment:n,nodes:h,events:u,macroNodes:o}=this;return new Yt(i,s,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 i=this.nodes.length,s=new t(i,e,r);return this.nodes.push(s),s}return null}registerEvents(){let t=this.events.length,e=new ds(t);return this.events.push(e),e}newMacroNode(t,e,r){let i=[],s={_:new we(i)};for(let h of r)if(h instanceof ze)s[h.val.value]=h.node;else if(!(h instanceof Gt)||!h.isWhiteSpace())i.push(h);let n=new cs(t,e,s,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 nr=(t)=>t instanceof Gt&&t.isWhiteSpace(),hs=(t)=>t instanceof pe||t instanceof we&&t.childs[0]instanceof pe;function Xh(t){let e=t.length;if(e===0)return t;let r=0,i=!1;if(nr(t[0]))r=1,i=!0;if(e>1&&nr(t[e-1]))e-=1,i=!0;for(let s=1;s<e-1;s++){let n=t[s];if(nr(n)&&hs(t[s-1])&&hs(t[s+1])&&n.hasNewLine())n.condenseWhiteSpace()}return i?t.slice(r,e):t}class Se{constructor(t,e,r="",i=null,s=null){this.name=t,this.anode=i,this.style=r,this.ctx=s,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=ur(this.anode)}render(t,e){return this.anode.render(t,e)}}class ds{constructor(t){this.id=t,this.handlers=[]}add(t,e,r){this.handlers.push(new zs(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 zs{constructor(t,e,r){this.name=t,this.handlerCall=e,this.modifierWrapper=Ph(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 Zh=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac"),Oe=(t)=>(e)=>(r,i,s,n)=>t(n)?e(r,i,s,n):r,us=(t)=>Oe((e)=>e.e.key===t),os=Oe(({e:t})=>Zh&&t.metaKey||t.ctrlKey),Bh=Oe(({e:t})=>t.metaKey),Qh=Oe(({e:t})=>t.altKey),fs={ctrl:os,cmd:os,meta:Bh,alt:Qh},Gh={keydown:{send:us("Enter"),cancel:us("Escape"),...fs},click:{...fs}},Yh=(t,e)=>t;function Ph(t,e){if(e.length===0)return Yh;let r=Gh[t]??{},i=(s,n,h,u)=>n.apply(s,h);for(let s of e){let n=r[s];if(n!==void 0)i=n(i)}return(s,n)=>function(...h){return i(this,s,h,n)}}class ar{get(t,e){}set(t,e,r){}get2(t,e,r){}set2(t,e,r,i){}evict(){return{hit:0,miss:0,badKey:0}}}class gr{constructor(){this.hit=this.miss=this.badKey=0,this.map=new WeakMap}_returnValue(t){if(t===void 0)this.miss+=1;else this.hit+=1;return t}get(t,e){return this._returnValue(this.map.get(t)?.[e])}set(t,e,r){let i=this.map.get(t);if(i)i[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,i){let s=this.map.get(t);if(s){let n=s.get(e);if(n)n[r]=i;else s.set(e,{[r]:i})}else if(typeof t==="object"&&typeof e==="object"){let n=new WeakMap;n.set(e,{[r]:i}),this.map.set(t,n)}else this.badKey+=1}evict(){let{hit:t,miss:e,badKey:r}=this;return this.hit=this.miss=this.badKey=0,this.map=new WeakMap,{hit:t,miss:e,badKey:r}}}class yr{getKey(t,e,r){return r.call(t)}}class pr{constructor(){this.map=new WeakMap}getKey(t,e,r){let i=this.map.get(t);if(i){let n=i[e];if(n!==void 0)return n;let h=r.call(t)??null;return i[e]=h,h}let s=r.call(t)??null;return this.map.set(t,{[e]:s}),s}}class be{constructor(){this.getComponentSymbol=Symbol("getComponent"),this.byId=new Map,this.computedCache=new pr}setNullComputedCache(){this.computedCache=new yr}registerComponent(t){t.Class.prototype[this.getComponentSymbol]=()=>t,this.byId.set(t.id,t)}getComponentForId(t){return this.byId.get(t)??null}getCompFor(t){return t?.[this.getComponentSymbol]?.()??null}getOnEnterFor(t){let e=this.getCompFor(t);return e?e.on.stackEnter:Os}getInputHandlerFor(t,e){return this.getCompFor(t)?.input[e]??null}getAlterHandlerFor(t,e){return this.getCompFor(t)?.alter[e]??null}getRequestFor(t,e){let r=this.getCompFor(t);return r?r.scope.lookupRequest(e):null}lookupComputed(t,e){let r=this.getCompFor(t)?.computed[e];return r?this.computedCache.getKey(t,e,r):null}compileStyles(){let t=[];for(let e of this.byId.values())t.push(e.compileStyle());return t.join(`
|
|
2
|
+
`)}}class Me{constructor(t=new be,e=null){this.comps=t,this.parent=e,this.byName={},this.reqsByName={},this.macros={}}enter(){return new Me(this.comps,this)}registerComponents(t,e={}){for(let r=0;r<t.length;r++){let i=t[r];i.scope=this.enter(),this.comps.registerComponent(i),this.byName[i.name]=i;let s=e[i.name];if(s)this.byName[s]=i}}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 ir(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 wr{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 Ss extends wr{constructor(t,e,r,i){super(t,e,null);this.compName=r,this.dynName=i}_resolveSymbol(t){return t.lookupType(this.compName)?.dynamic[this.dynName]?.symbol??null}getSymbol(t){return this.symbol??=this._resolveSymbol(t),this.symbol}}var Mt=(t)=>typeof t==="string",Ch=0;class dr{constructor(t,e,r,i={},s="",n="",h="",u={},o={},f={},c={},_={},l={},a={},g={}){this.id=Ch++,this.name=t,this.Class=e,this.views={main:new Se("main",r,s)},this.commonStyle=n,this.globalStyle=h,this.computed=u,this.input=o,this.logic=f,this.bubble=c,this.response=_,this.alter=l,this.on={stackEnter:g?.stackEnter??Os};for(let w in i){let S=i[w],{view:q,style:dt}=Mt(S)?{view:S}:S;this.views[w]=new Se(w,q,dt)}this._rawDynamic=a,this.dynamic={},this.scope=null}compile(t){for(let e in this._rawDynamic){let r=this._rawDynamic[e];if(Mt(r)){let i=p.parseDynamic(r,this.views.main.ctx);this.dynamic[e]=new wr(e,i,Symbol(e))}else if(Mt(r?.default)&&Mt(r?.for)){let i=p.parseDynamic(r.default,this.views.main.ctx),[s,n]=r.for.split(".");if(Mt(s)&&Mt(n))this.dynamic[e]=new Ss(e,i,s,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:i}=this,s=e?[`[data-cid="${t}"]{${e}}`]:[];if(r!=="")s.push(r);for(let n in i){let{style:h}=i[n];if(h!=="")s.push(`[data-cid="${t}"][data-vid="${n}"]{${h}}`)}return s.join(`
|
|
3
|
+
`)}}function Os(t){return t}var bs=Symbol("STOP"),Or=Symbol("NEXT");class Pt{constructor(t,e){this.head=t,this.tail=e}push(t){return new Pt(t,this)}lookup(t,e=null){let{tail:r}=this,i=this.head.lookup(t);return i===bs?e:i===Or?r!==null?r.lookup(t,e):e:i}*[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?bs:Or:e}}class Sr{constructor(t){this.bindings=t}lookup(t){let e=this.bindings[t];return e===void 0?Or:e}}class J{constructor(t,e,r,i,s,n=null){this.comps=t,this.it=e,this.binds=r,this.dynBinds=i,this.views=s,this.ctx=n;let h=[...s].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:i,ctx:s}=this;return e.head.isFrame?this:new J(t,e.tail.head.it,e.tail,r,i,s)}static root(t,e,r){let i=new Pt(new zr(e,{it:e},!0),null),s=new Pt(new Sr({}),null),n=new Pt("main",null);return new J(t,e,i,s,n,r)._enrichOnEnter()}enter(t,e={},r=!0){let{comps:i,binds:s,dynBinds:n,views:h,ctx:u}=this,o=s.push(new zr(t,e,r));return new J(i,t,o,n,h,u)._enrichOnEnter()}pushViewName(t){let{comps:e,it:r,binds:i,dynBinds:s,views:n,ctx:h}=this;return new J(e,r,i,s,n.push(t),h)}withDynamicBindings(t){let e={},r=this.comps.getCompFor(this.it);for(let f of t)r.dynamic[f].evalAndBind(this,e);let{comps:i,it:s,binds:n,views:h,ctx:u}=this,o=this.dynBinds.push(new Sr(e));return new J(i,s,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 i=t[r];if(i!==void 0)return i}return t[e]}}class Ms{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 i of this.changeSubs)i({value:t,old:r,info:e,timestamp:Date.now()})}update(t,e){return this.set(t(this.value),e)}}class br{constructor(t,e){this.comps=t,this.transactions=[],this.state=new Ms(e),this.onTransactionPushed=()=>{}}pushTransaction(t){return this.transactions.push(t),this.onTransactionPushed(t),t}pushLogic(t,e,r=[],i={},s=null){return this.pushTransaction(new qr(t,this,e,r,s,i))}pushBubble(t,e,r=[],i={},s=null){let n=i.skipSelf?{...i,skipSelf:!1}:i;return this.pushTransaction(new js(t,this,e,r,s,n))}async pushRequest(t,e,r=[],i={},s=null){let n=this.state.value,h=t.lookup(n),u=this.comps.getRequestFor(h,e)??xh(e),o=i?.onResName??e,f=(c,_,l,a,g)=>{let S=new qs(t,this,c??_,c?[l]:[a,g],s);return this.pushTransaction(S)};try{let c=await u.fn.apply(null,r);return f(i?.onOkName,o,c,c,null)}catch(c){return f(i?.onErrorName,o,c,null,c)}}get hasPendingTransactions(){return this.transactions.length>0}transactNext(){if(this.hasPendingTransactions)this.transact(this.transactions.shift())}transactAll(){while(this.hasPendingTransactions)this.transact(this.transactions.shift())}transact(t){let e=this.state.value,r=t.run(e,this.comps);if(r!==void 0)this.state.set(r,{transaction:t}),t.afterTransaction();else console.warn("undefined new state",{curState:e,transaction:t})}transactInputNow(t,e,r,i){this.transact(new Es(t,e,r,this,i))}}function xh(t){return()=>{throw Error(`Request not found: ${t}`)}}function Fh(){return this}class Mr{constructor(t,e){this.path=t,this.transactor=e,this.parentTransaction=null,this._task=null}get task(){return this._task??=new Us,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[i,s]=this.getHandlerAndArgs(t,e,r);return i.apply(e,s)}getHandlerAndArgs(t,e,r){return null}updateRootValue(t,e){let r=this.path.lookup(t),i=this.callHandler(t,r,e);return this._task?.complete?.({value:i,old:r}),r!==i?this.path.setValue(t,i):t}lookupName(t){return null}}var kh=(globalThis.navigator?.userAgent??"").toLowerCase().includes("mac");function Nh(t){return t.target.type==="checkbox"?t.target.checked:(t instanceof CustomEvent?t.detail:t.target.value)??null}class Es extends Mr{constructor(t,e,r,i,s){super(t,i);this.e=e,this.handler=r,this.dragInfo=s}buildRootStack(t,e){return J.root(e,t,this)}getHandlerAndArgs(t,e,r){let i=this.buildStack(t,r),[s,n]=this.handler.getHandlerAndArgs(i,this),h;for(let u=0;u<n.length;u++)if(n[u]?.toHandlerArg)h??=new jr(this.path,this.transactor,this),n[u]=n[u].toHandlerArg(h);return[s,n]}lookupName(t){let{e}=this;switch(t){case"value":return Nh(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 kh&&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 Ur(this.path,this.transactor,this);case"dragInfo":return this.dragInfo}return null}}class Er extends Mr{constructor(t,e,r,i,s,n={}){super(t,e,s);this.name=r,this.args=i,this.opts=n}handlerProp=null;getHandlerForName(t){return t?.[this.handlerProp]?.[this.name]??Fh}getHandlerAndArgs(t,e,r){return[this.getHandlerForName(r.getCompFor(e)),[...this.args,new Ur(this.path,this.transactor,this)]]}}class qs extends Er{handlerProp="response"}class qr extends Er{handlerProp="logic";run(t,e){return this.opts.skipSelf?t:this.updateRootValue(t,e)}afterTransaction(){let{path:t,name:e,args:r,opts:i}=this;if(i.bubbles&&t.steps.length>0)this.transactor.pushBubble(t.popStep(),e,r,i,this)}}class js extends qr{handlerProp="bubble";stopPropagation(){this.opts.bubbles=!1}}class Us{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 jr{constructor(t,e,r=null){this.path=t,this.transactor=e,this.parent=r}get at(){return new As(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,i){return this.transactor.pushLogic(t,e,r,i,this.parent)}request(t,e,r){return this.requestAtPath(this.path,t,e,r)}requestAtPath(t,e,r,i){return this.transactor.pushRequest(t,e,r,i,this.parent)}lookupTypeFor(t,e){return this.transactor.comps.getCompFor(e).scope.lookupComponent(t)}}class Ur extends jr{stopPropagation(){return this.parent.stopPropagation()}}class As extends xe{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 Ar{constructor(t,e,r,i,s){this.rootNode=t,this.comps=r,this.compStack=new Me(r),this.transactor=new br(r,null),this.ParseContext=s,this.renderer=i,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",i=t.type==="dragend",{rootNode:s,maxEventNodeDepth:n,comps:h}=this,u=!(r||e||i),[o,f]=m.fromEvent(t,s,n,h,u);if(r){let c=Vh(t.target,this.rootNode,50);if(c!==null)t.preventDefault(),this._cleanDragOverAttrs(),this.curDragOver=c,c.dataset.draggingover=this.dragInfo.type}else if(e){t.target.dataset.dragging=1;let c=this.state.value,_=o.lookup(c),l=t.target.dataset.dragtype??"?",a=o.buildStack(this.makeStack(c));this.dragInfo=new $s(o,a,t,_,l,t.target)}else if(i)delete this.dragInfo.node.dataset.dragging,this.dragInfo=null,this._cleanDragOverAttrs();if(o!==null&&f!==null)for(let c of f)this.transactor.transactInputNow(o,t,c,this.dragInfo)}makeStack(t){return 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()}),Is("tutuca-app",this.comps.compileStyles(),t?.head??document.head),t?.noCache)this.renderer.setNullCache(),this.comps.setNullComputedCache();else this.startCacheEvictionInterval();this.render()}stop(){this.stopCacheEvictionInterval();for(let t of this._eventNames)this.rootNode.removeEventListener(t,this)}dispatchLogicAtRoot(t,e,r){return this.transactor.pushLogic(new m([]),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 Is(t,e,r=document.head){let i=document.createElement("style"),s=r.querySelector(`#${t}`);if(s)r.removeChild(s);i.id=t,i.innerHTML=e,r.appendChild(i)}function Vh(t,e,r){let i=t;while(r-- >0&&i!==e){if(i.dataset?.droptarget!==void 0)return i;i=i.parentNode}return null}class $s{constructor(t,e,r,i,s,n){this.path=t,this.stack=e,this.e=r,this.value=i,this.type=s,this.node=n}lookupBind(t){return this.stack.lookupBind(t)}}function Ct(t,e){if(!t)throw Error(e)}function A(t){Ct(t!==1/0,"Cannot perform this action with an infinite size.")}function Ls(t,e,r,i,s,n){return A(t.size),t.__iterate((h,u,o)=>{if(s)s=!1,r=h;else r=e.call(i,r,h,u,o)},n),r}var mh=(t,e)=>e,vh=(t,e)=>[e,t],Ir=(t)=>function(...e){return!t.apply(this,e)},Ks=(t)=>function(...e){return-t.apply(this,e)};function tn(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 Ds=(t,e)=>t<e?1:t>e?-1:0,I={done:!0,value:void 0};class en{constructor(t){this.next=t}[Symbol.iterator](){return this}}function L(t){return new en(t)}function b(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 I})}var tu=L(()=>I),ot=()=>tu;function De(t){let e=0,r={done:!1,value:void 0};return L(()=>{if(e===t)return I;return r.value=e++,r})}function mt(t,e){return b((r)=>{let i=t.next();if(i.done)return!1;return e(i.value[0],i.value[1],r),!0})}function rn(t){if(Array.isArray(t))return!0;return!!Re(t)}var eu=(t)=>!!(t&&typeof t.next==="function");function sn(t){return Re(t)?.call(t)}function Re(t){let e=t&&t[Symbol.iterator];if(typeof e==="function")return e}function ru(t){let e=Re(t);return e&&e===t.entries}function iu(t){let e=Re(t);return e&&e===t.keys}var vt="delete",z=5,E=1<<z,$=E-1,y={},Hr=()=>({value:!1});function W(t){if(t)t.value=!0}class We{}function qt(t){if(t.size===void 0)t.size=t.__iterate(nn);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?qt(t)+e:e}var nn=()=>!0,hn=(t)=>t<0||Object.is(t,-0),te=(t,e,r)=>(t===0&&!hn(t)||r!==void 0&&(t??0)<=-r)&&(e===void 0||r!==void 0&&e>=r),un=(t,e,r)=>t===void 0?r:hn(t)?e===1/0?e:Math.max(0,e+t)|0:e===void 0||e===t?t:Math.min(e,t)|0,Lt=(t,e)=>un(t,e,0),ee=(t,e)=>un(t,e,e),on="@@__IMMUTABLE_ITERABLE__@@",Ue="@@__IMMUTABLE_KEYED__@@",Ae="@@__IMMUTABLE_INDEXED__@@",rt="@@__IMMUTABLE_ORDERED__@@",re="@@__IMMUTABLE_SEQ__@@",fn="@@__IMMUTABLE_LIST__@@",cn="@@__IMMUTABLE_MAP__@@",_n="@@__IMMUTABLE_SET__@@",ln="@@__IMMUTABLE_STACK__@@",an="@@__IMMUTABLE_RECORD__@@";function P(t,e){return typeof t==="object"&&t!==null&&e in t}var D=(t)=>P(t,on),d=(t)=>P(t,Ue),j=(t)=>P(t,Ae),Gr=(t)=>d(t)||j(t),x=(t)=>P(t,rt),Yr=(t)=>P(t,re),Pr=(t)=>P(t,fn),ie=(t)=>P(t,cn),Cr=(t)=>P(t,_n),xr=(t)=>P(t,ln),lt=(t)=>P(t,an),C=(t)=>D(t)||lt(t),Je=(t)=>ie(t)&&x(t),gn=(t)=>Cr(t)&&x(t),Rs=(t)=>typeof t==="object"&&t!==null&&typeof t.equals==="function"&&typeof t.hashCode==="function";function yn(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=Dt,e.__iterate=function(r,i){return t.__iterate((s,n)=>r(n,s,this),i)},e.__iteratorUncached=function(r){return mt(t.__iterator(r),(i,s,n)=>{n[0]=s,n[1]=i})},e}function pn(t,e,r){let i=G(t);return i.size=t.size,i.has=(s)=>t.has(s),i.get=(s,n)=>{let h=t.get(s,y);return h===y?n:e.call(r,h,s,t)},i.__iterate=function(s,n){return t.__iterate((h,u)=>s(e.call(r,h,u,t),u,this),n)},i.__iteratorUncached=function(s){return mt(t.__iterator(s),(n,h,u)=>{u[0]=n,u[1]=e.call(r,h,n,t)})},i}function wn(t,e){let r=G(t);if(r._iter=t,r.size=t.size,r.reverse=()=>t,t.flip)r.flip=function(){let i=yn(t);return i.reverse=()=>t.flip(),i};return r.get=(i,s)=>t.get(e?i:-1-i,s),r.has=(i)=>t.has(e?i:-1-i),r.includes=(i)=>t.includes(i),r.cacheResult=Dt,r.__iterate=function(i,s){let n=0;if(s)qt(t);return t.__iterate((h,u)=>i(h,e?u:s?this.size-++n:n++,this),!s)},r.__iteratorUncached=function(i){let s=0;if(i)qt(t);let n=this.size;return mt(t.__iterator(!i),(h,u,o)=>{o[0]=e?h:i?n-++s:s++,o[1]=u})},r}function dn(t,e,r,i){let s=t.size;if(te(e,r,s))return t;if(s===void 0&&(e<0||r<0))return dn(t.toSeq().cacheResult(),e,r,i);let n=Lt(e,s),u=ee(r,s)-n,o;if(!Number.isNaN(u))o=Math.max(0,u);let f=G(t);if(f.size=o===0?o:t.size&&o||void 0,!i&&Yr(t)&&o>=0)f.get=function(c,_){return c=et(this,c),c>=0&&c<o?t.get(c+n,_):_};return f.__iterateUncached=function(c,_){if(o!==0&&_)return this.cacheResult().__iterate(c,_);if(o===0)return 0;let l=0,a=0;return t.__iterate((g,w)=>{if(l<n){l++;return}if(o!==void 0&&a>=o)return!1;if(a++,c(g,i?w:a-1,this)===!1)return!1},_),a},f.__iteratorUncached=function(c){if(o!==0&&c)return this.cacheResult().__iterator(c);if(o===0)return ot();let _=t.__iterator(c),l=0,a=0;if(i)return L(()=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return I;let g=_.next();if(g.done)return g;return a++,g});return b((g)=>{while(l<n)l++,_.next();if(o!==void 0&&a>=o)return!1;let w=_.next();if(w.done)return!1;return a++,g[0]=a-1,g[1]=w.value[1],!0})},f}function Ws(t,e,r){if(!e)e=tn;let i=d(t),s=0,n=t.toSeq().map((h,u)=>[u,h,s++,r?r(h,u,t):h]).valueSeq().toArray();return n.sort((h,u)=>e(h[3],u[3])||h[2]-u[2]).forEach(i?(h,u)=>{n[u].length=2}:(h,u)=>{n[u]=h[1]}),i?mr(n):j(t)?_t(n):Ft(n)}function Ee(t,e,r){if(!e)e=tn;if(r){let i=t.toSeq().map((s,n)=>[s,r(s,n,t)]).reduce((s,n)=>Js(e,s[1],n[1])?n:s);return i&&i[0]}return t.reduce((i,s)=>Js(e,i,s)?s:i)}function Js(t,e,r){let i=t(r,e);return i===0&&r!==e&&(r===void 0||r===null||Number.isNaN(r))||i>0}function $r(t,e,r,i){let s=G(t),n=new se(r).map((h)=>h.size);return s.size=i?n.max():n.min(),s.__iterate=function(h,u){let o=this.__iterator(u),f=0,c;while(!(c=o.next()).done)if(h(c.value[1],f++,this)===!1)break;return f},s.__iteratorUncached=function(h){let u=r.map((_)=>{let l=F(_);return sn(h?l.reverse():l)}),o=0,f=Array(u.length),c=Array(u.length);return b((_)=>{let l=i;for(let a=0;a<u.length;a++)f[a]=u[a].next(),l=i?l&&f[a].done:l||f[a].done;if(l)return!1;for(let a=0;a<f.length;a++)c[a]=f[a].value;return _[0]=o++,_[1]=e(...c),!0})},s}function zn(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 su(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,i=Object.getPrototypeOf(e);while(i!==null)r=i,i=Object.getPrototypeOf(r);return r===e}var it=(t)=>typeof t==="object"&&(C(t)||Array.isArray(t)||su(t));function Sn(t){if(zn(t)&&typeof t!=="string")return t;if(x(t))return t.toArray();throw TypeError(`Invalid keyPath: expected Ordered Collection or Array: ${t}`)}var nu=(t,e)=>C(t)?t.has(e):it(t)&&Object.hasOwn(t,e);function On(t,e,r){return C(t)?t.get(e,r):!nu(t,e)?r:typeof t.get==="function"?t.get(e):t[e]}function Fr(t,e,r){let i=Sn(e),s=0;while(s!==i.length)if(t=On(t,i[s++],y),t===y)return r;return t}var bn=(t,e)=>Fr(t,e,y)!==y;function U(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!!(Rs(t)&&Rs(e)&&t.equals(e))}function Ie(t){if(!t||typeof t!=="object")return t;if(!D(t)){if(!it(t))return t;t=st(t)}if(d(t)){let r={};return t.__iterate((i,s)=>{r[String(s)]=Ie(i)}),r}let e=[];return t.__iterate((r)=>{e.push(Ie(r))}),e}function kr(t,e){if(t===e)return!0;if(!D(e)||t.size!==void 0&&e.size!==void 0&&t.size!==e.size||t.__hash!==void 0&&e.__hash!==void 0&&t.__hash!==e.__hash||d(t)!==d(e)||j(t)!==j(e)||x(t)!==x(e))return!1;if(t.size===0&&e.size===0)return!0;let r=!Gr(t);if(x(t)){let h=t.entries();return!!(e.every((u,o)=>{let f=h.next().value;return f&&U(f[1],u)&&(r||U(f[0],o))})&&h.next().done)}let i=!1;if(t.size===void 0)if(e.size===void 0){if(typeof t.cacheResult==="function")t.cacheResult()}else{i=!0;let h=t;t=e,e=h}let s=!0,n=e.__iterate((h,u)=>{if(r?!t.has(h):i?!U(h,t.get(u,y)):!U(t.get(u,y),h))return s=!1,!1;return!0});return s&&t.size===n}var He=(t)=>t>>>1&1073741824|t&3221225471;function H(t){if(t===null||t===void 0)return Hs(t);if(typeof t.hashCode==="function")return He(t.hashCode(t));let e=cu(t);if(e===null||e===void 0)return Hs(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return hu(e);case"string":return e.length>_u?uu(e):Tr(e);case"object":case"function":return fu(e);case"symbol":return ou(e);default:if(typeof e.toString==="function")return Tr(e.toString());throw Error(`Value type ${typeof e} cannot be hashed.`)}}var Hs=(t)=>t===null?1108378658:1108378659;function hu(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 He(e)}function uu(t){let e=Dr[t];if(e===void 0){if(e=Tr(t),Kr===lu)Kr=0,Dr={};Kr++,Dr[t]=e}return e}function Tr(t){let e=0;for(let r=0;r<t.length;r++)e=31*e+t.charCodeAt(r)|0;return He(e)}function ou(t){let e=Xs[t];if(e!==void 0)return e;return e=Mn(),Xs[t]=e,e}function fu(t){let e=Ts.get(t);if(e!==void 0)return e;return e=Mn(),Ts.set(t,e),e}var cu=(t)=>t.valueOf!==Object.prototype.valueOf?t.valueOf():t;function Mn(){let t=++Lr;if(Lr&1073741824)Lr=0;return t}var Ts=new WeakMap,Xs=Object.create(null),Lr=0,_u=16,lu=255,Kr=0,Dr={};function au(t){if(t.size===1/0)return 0;let e=x(t),r=d(t),i=e?1:0;return t.__iterate(r?e?(s,n)=>{i=31*i+Zs(H(s),H(n))|0}:(s,n)=>{i=i+Zs(H(s),H(n))|0}:e?(s)=>{i=31*i+H(s)|0}:(s)=>{i=i+H(s)|0}),gu(t.size,i)}var Zs=(t,e)=>t^e+2654435769+(t<<6)+(t>>2)|0;function gu(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=He(e^e>>>16),e}function xt(t){try{return typeof t==="string"?JSON.stringify(t):String(t)}catch{return JSON.stringify(t)}}var O=(t,e)=>t===e?t:Yr(t)?e:t.create?t.create(e):t.constructor(e),yu=(t,e)=>O(t,(d(t)?X:j(t)?at:gt)(e)),Bs=(...t)=>t,F=(t)=>D(t)?t:st(t);class T{size=0;static{this.prototype[on]=!0,this.prototype.__toStringMapper=xt,this.prototype[Symbol.iterator]=this.prototype.values,this.prototype.toJSON=this.prototype.toArray,this.prototype.contains=this.prototype.includes}equals(t){return kr(this,t)}hashCode(){return this.__hash??(this.__hash=au(this))}toArray(){A(this.size);let t=Array(this.size||0),e=d(this),r=0;return this.__iterate((i,s)=>{t[r++]=e?[s,i]:i}),t}toIndexedSeq(){return new An(this)}toJS(){return Ie(this)}toKeyedSeq(){return new ii(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 In(this)}toSeq(){return j(this)?this.toIndexedSeq():d(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=d(this),r=[this,...t].map((i)=>{if(!D(i))i=e?qn(i):jn(Array.isArray(i)?i:[i]);else if(e)i=X(i);return i}).filter((i)=>i.size!==0);if(r.length===0)return this;if(r.length===1){let i=r[0];if(i===this||e&&d(i)||j(this)&&j(i))return i}return O(this,new Un(r))}includes(t){return this.some((e)=>U(e,t))}every(t,e){A(this.size);let r=!0;return this.__iterate((i,s,n)=>{if(!t.call(e,i,s,n))return r=!1,!1}),r}entries(){return this.__iterator()}filter(t,e){let r=this,i=d(this),s=G(r);if(i)s.has=(n)=>{let h=r.get(n,y);return h!==y&&!!t.call(e,h,n,r)},s.get=(n,h)=>{let u=r.get(n,y);return u!==y&&t.call(e,u,n,r)?u:h};return s.__iterateUncached=function(n,h){let u=0;return r.__iterate((o,f)=>{if(t.call(e,o,f,r))return u++,n(o,i?f:u-1,this)},h),u},s.__iteratorUncached=function(n){let h=r.__iterator(n),u=0;return b((o)=>{while(!0){let f=h.next();if(f.done)return!1;let c=f.value[0],_=f.value[1];if(t.call(e,_,c,r))return o[0]=i?c:u++,o[1]=_,!0}})},O(this,s)}partition(t,e){let r=d(this),i=[[],[]];return this.__iterate((s,n)=>{i[t.call(e,s,n,this)?1:0].push(r?[n,s]:s)}),i.map((s)=>yu(this,s))}find(t,e,r){let i=this.findEntry(t,e);return i?i[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((i)=>{if(r)r=!1;else e+=t;e+=i!==null&&i!==void 0?String(i):""}),e}keys(){let t=this.__iterator(),e={done:!1,value:void 0};return L(()=>{let r=t.next();if(r.done)return I;return e.value=r.value[0],e})}map(t,e){return O(this,pn(this,t,e))}reduce(t,e=y,r){return Ls(this,t,e,r,e===y,!1)}reduceRight(t,e=y,r){return Ls(this,t,e,r,e===y,!0)}reverse(){return O(this,wn(this,d(this)))}slice(t,e){return O(this,dn(this,t,e,d(this)))}some(t,e){A(this.size);let r=!1;return this.__iterate((i,s,n)=>{if(t.call(e,i,s,n))return r=!0,!1}),r}sort(t){return O(this,Ws(this,t))}values(){let t=this.__iterator(),e={done:!1,value:void 0};return L(()=>{let r=t.next();if(r.done)return I;return e.value=r.value[1],e})}butLast(){return this.slice(0,-1)}isEmpty(){return this.size!==void 0?this.size===0:!this.some(()=>!0)}count(t,e){return qt(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 se(t._cache);let e=t.toSeq().map(vh).toIndexedSeq();return e.fromEntrySeq=()=>t.toSeq(),e}filterNot(t,e){return this.filter(Ir(t),e)}findEntry(t,e,r){let i=r;return this.__iterate((s,n,h)=>{if(t.call(e,s,n,h))return i=[n,s],!1}),i}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(nn,null,t)}flatMap(t,e){return O(this,this.toSeq().map((r,i)=>(d(this)?X:j(this)?at:gt)(t.call(e,r,i,this))).flatten(!0))}flatten(t){let e=this,r=d(this),i=G(e);return i.__iterateUncached=function(s,n){if(n)return this.cacheResult().__iterate(s,n);let h=0,u=!1;function o(f,c){f.__iterate((_,l)=>{if((!t||c<t)&&D(_))o(_,c+1);else if(h++,s(_,r?l:h-1,i)===!1)u=!0;if(u)return!1},n)}return o(e,0),h},i.__iteratorUncached=function(s){if(s)return this.cacheResult().__iterator(s);let n=0,h=[{iterator:e.__iterator(s),depth:0}];return b((u)=>{while(h.length>0){let o=h[h.length-1],f=o.iterator.next();if(f.done){h.pop();continue}let c=f.value[1];if((!t||o.depth<t)&&D(c)){h.push({iterator:c.__iterator(s),depth:o.depth+1});continue}return u[0]=r?f.value[0]:n++,u[1]=c,!0}return!1})},O(this,i)}fromEntrySeq(){return new $n(this)}get(t,e){return this.find((r,i)=>U(i,t),void 0,e)}getIn(t,e){return Fr(this,t,e)}groupBy(t,e){throw Error("groupBy: not patched — import CollectionConversions")}has(t){return this.get(t,y)!==y}hasIn(t){return bn(this,t)}isSubset(t){let e=typeof t.includes==="function"?t:F(t);return this.every((r)=>e.includes(r))}isSuperset(t){return(typeof t.isSubset==="function"?t:F(t)).isSubset(this)}keyOf(t){return this.findKey((e)=>U(e,t))}keySeq(){return this.toSeq().map(mh).toIndexedSeq()}last(t){return this.toSeq().reverse().first(t)}lastKeyOf(t){return this.toKeyedSeq().reverse().keyOf(t)}max(t){return Ee(this,t)}maxBy(t,e){return Ee(this,e,t)}min(t){return Ee(this,t?Ks(t):Ds)}minBy(t,e){return Ee(this,e?Ks(e):Ds,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,i=d(this),s=G(r);return s.__iterateUncached=function(n,h){if(h)return this.cacheResult().__iterate(n,h);let u=!0,o=0;return r.__iterate((f,c)=>{if(u&&t.call(e,f,c,this))return;return u=!1,o++,n(f,i?c:o-1,this)},h),o},s.__iteratorUncached=function(n){if(n)return this.cacheResult().__iterator(n);let h=r.__iterator(n),u=0,o=this,f=!0;return b((c)=>{while(!0){let _=h.next();if(_.done)return!1;let l=_.value[0],a=_.value[1];if(f&&t.call(e,a,l,o))continue;return f=!1,c[0]=i?l:u++,c[1]=a,!0}})},O(this,s)}skipUntil(t,e){return this.skipWhile(Ir(t),e)}sortBy(t,e){return O(this,Ws(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,i=G(r);return i.__iterateUncached=function(s,n){if(n)return this.cacheResult().__iterate(s,n);let h=0;return r.__iterate((u,o)=>{if(!t.call(e,u,o,this))return!1;return h++,s(u,o,this)},n),h},i.__iteratorUncached=function(s){if(s)return this.cacheResult().__iterator(s);let n=r.__iterator(s),h=this,u=!1;return L(()=>{if(u)return I;let o=n.next();if(o.done)return o;if(!t.call(e,o.value[1],o.value[0],h))return u=!0,I;return o})},O(this,i)}takeUntil(t,e){return this.takeWhile(Ir(t),e)}update(t){return t(this)}valueSeq(){return this.toIndexedSeq()}__iterate(t,e=!1){let r=this.__iterator(e),i=0,s;while(!(s=r.next()).done)if(i++,t(s.value[1],s.value[0],this)===!1)break;return i}__iterator(t=!1){throw Error("CollectionImpl does not implement __iterator. Use a subclass instead.")}}var X=(t)=>d(t)?t:mr(t);class Nr extends T{static{this.prototype[Ue]=!0,this.prototype.__toStringMapper=(t,e)=>`${xt(e)}: ${xt(t)}`,this.prototype[Symbol.iterator]=T.prototype.entries,this.prototype.toJSON=function(){A(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}}flip(){return O(this,yn(this))}mapEntries(t,e){let r=0;return O(this,this.toSeq().map((i,s)=>t.call(e,[s,i],r++,this)).fromEntrySeq())}mapKeys(t,e){return O(this,this.toSeq().flip().map((r,i)=>t.call(e,r,i,this)).flip())}}var at=(t)=>j(t)?t:_t(t);class jt extends T{static{this.prototype[Ae]=!0,this.prototype[rt]=!0}toKeyedSeq(){return new ii(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=y,...r){if(t===void 0)return this;let i=e!==y;if(e=i?Math.max(e||0,0):0,i&&!e&&r.length===0)return this;t=Lt(t,t<0?this.count():this.size);let s=this.slice(0,t);return O(this,!i?s:s.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,i)=>i===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(i,s){let n=0,h=!0;return e.__iterate((u)=>{if(!h){if(i(t,n++,this)===!1)return!1}return h=!1,i(u,n++,this)},s),n},r.__iteratorUncached=function(i){let s=e.__iterator(i),n=0,h=!0,u,o=!1;return b((f)=>{if(o)return o=!1,f[0]=n++,f[1]=u,!0;let c=s.next();if(c.done)return!1;let _=c.value[1];if(!h)return u=_,o=!0,f[0]=n++,f[1]=t,!0;return h=!1,f[0]=n++,f[1]=_,!0})},O(this,r)}interleave(...t){let e=[this,...t],r=$r(this.toSeq(),_t.of,e),i=r.flatten(!0);if(r.size)i.size=r.size*e.length;return O(this,i)}keySeq(){throw Error("keySeq: not patched — import CollectionConversions")}last(t){return this.get(-1,t)}zip(...t){return this.zipWith(Bs,...t)}zipAll(...t){let e=[this,...t];return O(this,$r(this,Bs,e,!0))}zipWith(t,...e){let r=[this,...e];return O(this,$r(this,t,r))}}var gt=(t)=>D(t)&&!Gr(t)?t:Ft(t);class Te extends T{static{this.prototype.has=T.prototype.includes,this.prototype.contains=T.prototype.includes,this.prototype.keys=Te.prototype.values}get(t,e){return this.has(t)?t:e}includes(t){return this.has(t)}keySeq(){return this.valueSeq()}}F.Keyed=X;F.Indexed=at;F.Set=gt;var Rr=jt.prototype,st=(t)=>t===void 0||t===null?ei():C(t)?t.toSeq():pu(t),G=(t)=>Object.create((d(t)?Kt:j(t)?yt:vr).prototype);class ft extends T{static{this.prototype[re]=!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),i=0,s;while(!(s=r.next()).done)if(i++,t(s.value[1],s.value[0],this)===!1)break;return i}__iterate(t,e){let r=this._cache;if(r){let i=r.length,s=0;while(s!==i){let n=r[e?i-++s:s++];if(t(n[1],n[0],this)===!1)break}return s}return this.__iterateUncached(t,e)}__iterator(t){let e=this._cache;if(e){let r=e.length,i=0,s={done:!1,value:void 0};return L(()=>{if(i===r)return I;return s.value=e[t?r-++i:i++],s})}return this.__iteratorUncached(t)}}var Vr={cacheResult:ft.prototype.cacheResult,__iterateUncached:ft.prototype.__iterateUncached,__iterate:ft.prototype.__iterate,__iterator:ft.prototype.__iterator},mr=(t)=>t===void 0||t===null?ei().toKeyedSeq():D(t)?d(t)?t.toSeq():t.fromEntrySeq():lt(t)?t.toSeq():qn(t);class Kt extends Nr{static{this.prototype[re]=!0,Object.assign(this.prototype,Vr)}toSeq(){return this}toKeyedSeq(){return this}}var _t=(t)=>t===void 0||t===null?ei():D(t)?d(t)?t.entrySeq():t.toIndexedSeq():lt(t)?t.toSeq().entrySeq():jn(t);_t.of=(...t)=>_t(t);class yt extends jt{static{this.prototype[re]=!0,Object.assign(this.prototype,Vr)}toSeq(){return this}toIndexedSeq(){return this}toString(){return this.__toString("Seq [","]")}}var Ft=(t)=>(D(t)&&!Gr(t)?t:_t(t)).toSetSeq();Ft.of=(...t)=>Ft(t);class vr extends Te{static{this.prototype[re]=!0,Object.assign(this.prototype,Vr)}toSeq(){return this}toSetSeq(){return this}}st.isSeq=Yr;st.Keyed=mr;st.Set=Ft;st.Indexed=_t;class se extends yt{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,i=r.length,s=0;while(s!==i){let n=e?i-++s:s++;if(t(r[n],n,this)===!1)break}return s}__iteratorUncached(t){let e=this._array,r=e.length,i=0;return b((s)=>{if(i===r)return!1;let n=t?r-++i:i++;return s[0]=n,s[1]=e[n],!0})}}class ti extends Kt{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,i=this._keys,s=i.length,n=0;while(n!==s){let h=i[e?s-++n:n++];if(t(r[h],h,this)===!1)break}return n}__iteratorUncached(t){let e=this._object,r=this._keys,i=r.length,s=0;return b((n)=>{if(s===i)return!1;let h=r[t?i-++s:s++];return n[0]=h,n[1]=e[h],!0})}}class En extends yt{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 i of this._collection){if(t(i,r,this)===!1)break;r++}return r}__iteratorUncached(t){if(t)return this.cacheResult().__iterator(t);let e=this._collection,r=sn(e);if(!eu(r))return ot();let i=0;return b((s)=>{let n=r.next();if(n.done)return!1;return s[0]=i++,s[1]=n.value,!0})}}var ei=()=>new se([]),ri=(t)=>zn(t)?new se(t):rn(t)?new En(t):void 0;function qn(t){let e=ri(t);if(e)return e.fromEntrySeq();if(typeof t==="object")return new ti(t);throw TypeError(`Expected Array or collection object of [k, v] entries, or keyed object: ${t}`)}function jn(t){let e=ri(t);if(e)return e;throw TypeError(`Expected Array or collection object of values: ${t}`)}function pu(t){let e=ri(t);if(e)return ru(t)?e.fromEntrySeq():iu(t)?e.toSetSeq():e;if(typeof t==="object")return new ti(t);throw TypeError(`Expected Array or collection object of values, or keyed object: ${t}`)}class Un extends ft{constructor(t){super();let e=[],r=0,i=!0;for(let n of t)if(n._wrappedIterables){for(let h of n._wrappedIterables)if(e.push(h),i){let u=h.size;if(u!==void 0)r+=u;else i=!1}}else if(e.push(n),i){let h=n.size;if(h!==void 0)r+=h;else i=!1}this._wrappedIterables=e,this.size=i?r:void 0;let s=this._wrappedIterables[0];if(s[Ue])this[Ue]=!0;if(s[Ae])this[Ae]=!0;if(s[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,i=!d(this),s=0,n=!1;for(let h of r)if(h.__iterate((u,o)=>{if(t(u,i?s++:o,this)===!1)return n=!0,!1},e),n)break;return s}__iteratorUncached(t){if(this._wrappedIterables.length===0)return ot();if(t)return this.cacheResult().__iterator(t);let e=this._wrappedIterables,r=!d(this),i=0,s=e[0].__iterator(t);function n(){while(i<e.length){let h=s.next();if(!h.done)return h;if(i++,i<e.length)s=e[i].__iterator(t)}return}if(r){let h=0;return b((u)=>{let o=n();if(!o)return!1;return u[0]=h++,u[1]=o.value[1],!0})}return L(()=>n()||I)}}class ii extends Kt{static{this.prototype[rt]=!0}constructor(t,e){super();this._iter=t,this._useKeys=e,this.size=t.size}cacheResult(){return Dt.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=wn(this,!0);if(!this._useKeys)t.valueSeq=()=>this._iter.toSeq().reverse();return t}map(t,e){let r=pn(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 An extends yt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Dt.call(this)}includes(t){return this._iter.includes(t)}__iterateUncached(t,e){let r=0;if(e)qt(this);let i=this.size;return this._iter.__iterate((s)=>{let n=e?i-++r:r++;return t(s,n,this)},e),r}__iteratorUncached(t){let e=0;if(t)qt(this);let r=this.size;return mt(this._iter.__iterator(t),(i,s,n)=>{n[0]=t?r-++e:e++,n[1]=s})}}class In extends vr{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Dt.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 mt(this._iter.__iterator(t),(e,r,i)=>{i[0]=r,i[1]=r})}}class $n extends Kt{constructor(t){super();this._iter=t,this.size=t.size}cacheResult(){return Dt.call(this)}entrySeq(){return this._iter.toSeq()}__iterateUncached(t,e){let r=0;return this._iter.__iterate((i)=>{if(i){Qs(i),r++;let s=D(i);return t(s?i.get(1):i[1],s?i.get(0):i[0],this)}},e),r}__iteratorUncached(t){let e=this._iter.__iterator(t);return b((r)=>{while(!0){let i=e.next();if(i.done)return!1;let s=i.value[1];if(s){Qs(s);let n=D(s);return r[0]=n?s.get(0):s[0],r[1]=n?s.get(1):s[1],!0}}})}}function Dt(){if(this._iter.cacheResult)return this._iter.cacheResult(),this.size=this._iter.size,this;return ft.prototype.cacheResult.call(this)}function Qs(t){if(t!==Object(t))throw TypeError(`Expected [K, V] tuple: ${t}`)}var k=(t)=>t===void 0||t===null?Z():ie(t)&&!x(t)?t:Z().withMutations((e)=>{let r=X(t);A(r.size),r.forEach((i,s)=>e.set(s,i))});class si extends Nr{static{wt(this,{asImmutable:ne,asMutable:he,deleteIn:Ut,merge:Xr,mergeWith:Hn,mergeDeep:Xn,mergeDeepWith:Zn,mergeDeepIn:wi,mergeIn:pi,setIn:ai,update:gi,updateIn:yi,wasAltered:li,withMutations:ue,removeIn:Ut,concat:Xr,[cn]:!0,[vt]:this.prototype.remove,removeAll:this.prototype.deleteAll,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Map"})}constructor(t,e,r,i){super();this.size=t,this._root=e,this.__ownerID=r,this.__hash=i,this.__altered=!1}create(t){return k(t)}toString(){return this.__toString("Map {","}")}get(t,e){return this._root?this._root.get(0,H(t),t,e):e}set(t,e){return Ys(this,t,e)}remove(t){return Ys(this,t,y)}deleteAll(t){let e=F(t);if(e.size===0)return this;return this.withMutations((r)=>{e.forEach((i)=>r.remove(i))})}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 Z()}map(t,e){return this.withMutations((r)=>{r.forEach((i,s)=>{r.set(s,t.call(e,i,s,this))})})}keys(){if(!this._root)return ot();return qe(this._root,!1,0)}values(){if(!this._root)return ot();return qe(this._root,!1,1)}entries(){if(!this._root)return ot();return qe(this._root,!1)}__iterator(t){if(!this._root)return ot();return qe(this._root,t)}__iterate(t,e){let r=0;if(this._root)this._root.iterate(([i,s])=>{return r++,t(s,i,this)},e);return r}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return Z();return this.__ownerID=t,this.__altered=!1,this}return ui(this.size,this._root,t,this.__hash)}}k.isMap=ie;class ni{constructor(t,e){this.ownerID=t,this.entries=e}get(t,e,r,i){return Ln(this.entries,r,i)}iterate(t,e){return Kn(this.entries,t,e)}update(t,e,r,i,s,n,h){let u=s===y,o=this.entries,f=0,c=o.length;for(;f<c;f++)if(U(i,o[f][0]))break;let _=f<c;if(_?o[f][1]===s:u)return this;if(W(h),u||!_)W(n);if(u&&c===1)return;if(!_&&!u&&c>=bu)return wu(t,o,i,s);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(f===c-1)a.pop();else a[f]=a.pop();else a[f]=[i,s];else a.push([i,s]);if(l)return this.entries=a,this;return new ni(t,a)}}class Xe{constructor(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}iterate(t,e){return Dn(this.nodes,t,e)}get(t,e,r,i){let s=1<<((t===0?e:e>>>t)&$),n=this.bitmap;return(n&s)===0?i:this.nodes[Cs(n&s-1)].get(t+z,e,r,i)}update(t,e,r,i,s,n,h){let u=(e===0?r:r>>>e)&$,o=1<<u,f=this.bitmap,c=(f&o)!==0;if(!c&&s===y)return this;let _=Cs(f&o-1),l=this.nodes,a=c?l[_]:void 0,g=oi(a,t,e+z,r,i,s,n,h);if(g===a)return this;if(!c&&g&&l.length>=Mu)return zu(t,l,f,u,g);if(c&&!g&&l.length===2&&Ps(l[_^1]))return l[_^1];if(c&&g&&l.length===1&&Ps(g))return g;let w=t&&t===this.ownerID,S=c?g?f:f^o:f|o,q=c?g?Rn(l,_,g,w):Ou(l,_,w):Su(l,_,g,w);if(w)return this.bitmap=S,this.nodes=q,this;return new Xe(t,S,q)}}class hi{constructor(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}iterate(t,e){return Dn(this.nodes,t,e)}get(t,e,r,i){let s=(t===0?e:e>>>t)&$,n=this.nodes[s];return n?n.get(t+z,e,r,i):i}update(t,e,r,i,s,n,h){let u=(e===0?r:r>>>e)&$,o=s===y,f=this.nodes,c=f[u];if(o&&!c)return this;let _=oi(c,t,e+z,r,i,s,n,h);if(_===c)return this;let l=this.count;if(!c)l++;else if(!_){if(l--,l<Eu)return du(t,f,l,u)}let a=t&&t===this.ownerID,g=Rn(f,u,_,a);if(a)return this.count=l,this.nodes=g,this;return new hi(t,l,g)}}class Ze{constructor(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}get(t,e,r,i){return Ln(this.entries,r,i)}iterate(t,e){return Kn(this.entries,t,e)}update(t,e,r,i,s,n,h){if(r!==this.keyHash){if(s===y)return this;return W(h),W(n),fi(this,t,e,r,[i,s])}let u=s===y,o=this.entries,f=0,c=o.length;for(;f<c;f++)if(U(i,o[f][0]))break;let _=f<c;if(_?o[f][1]===s:u)return this;if(W(h),u||!_)W(n);if(u&&c===2)return new pt(t,this.keyHash,o[f^1]);let l=t&&t===this.ownerID,a=l?o:o.slice();if(_)if(u)if(f===c-1)a.pop();else a[f]=a.pop();else a[f]=[i,s];else a.push([i,s]);if(l)return this.entries=a,this;return new Ze(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,i){return U(r,this.entry[0])?this.entry[1]:i}update(t,e,r,i,s,n,h){let u=s===y,o=U(i,this.entry[0]);if(o?s===this.entry[1]:u)return this;if(W(h),u){W(n);return}if(o){if(t&&t===this.ownerID)return this.entry[1]=s,this;return new pt(t,this.keyHash,[i,s])}return W(n),fi(this,t,e,H(i),[i,s])}}function Ln(t,e,r){for(let i=0,s=t.length;i<s;i++)if(U(e,t[i][0]))return t[i][1];return r}function Kn(t,e,r){for(let i=0,s=t.length-1;i<=s;i++)if(e(t[r?s-i:i])===!1)return!1}function Dn(t,e,r){for(let i=0,s=t.length-1;i<=s;i++)if(t[r?s-i:i]?.iterate(e,r)===!1)return!1}function qe(t,e,r){let i={node:t,index:0,__prev:null},s=r!==void 0?(h)=>h[r]:(h)=>h,n={done:!1,value:void 0};return L(()=>{while(i){let h=i.node,u=i.index++,o;if(h.entry){if(u===0)return n.value=s(h.entry),n}else if(h.entries){if(o=h.entries.length-1,u<=o)return n.value=s(h.entries[e?o-u:u]),n}else if(o=h.nodes.length-1,u<=o){let f=h.nodes[e?o-u:u];if(f){if(f.entry)return n.value=s(f.entry),n;i={node:f,index:0,__prev:i}}continue}i=i.__prev}return I})}var ui=(t,e,r,i)=>new si(t,e,r,i),Gs,Z=()=>Gs||(Gs=ui(0));function Ys(t,e,r){let i,s;if(!t._root){if(r===y)return t;s=1,i=new ni(t.__ownerID,[[e,r]])}else{let n=Hr(),h=Hr();if(i=oi(t._root,t.__ownerID,0,H(e),e,r,n,h),!h.value)return t;s=t.size+(n.value?r===y?-1:1:0)}if(t.__ownerID)return t.size=s,t._root=i,t.__hash=void 0,t.__altered=!0,t;return i?ui(s,i):Z()}function oi(t,e,r,i,s,n,h,u){if(!t){if(n===y)return t;return W(u),W(h),new pt(e,i,[s,n])}return t.update(e,r,i,s,n,h,u)}var Ps=(t)=>t.constructor===pt||t.constructor===Ze;function fi(t,e,r,i,s){if(t.keyHash===i)return new Ze(e,i,[t.entry,s]);let n=(r===0?t.keyHash:t.keyHash>>>r)&$,h=(r===0?i:i>>>r)&$,u=new pt(e,i,s),o=n===h?[fi(t,e,r+z,i,s)]:n<h?[t,u]:[u,t];return new Xe(e,1<<n|1<<h,o)}function wu(t,e,r,i){if(!t)t=new We;let s=new pt(t,H(r),[r,i]);for(let[n,h]of e)s=s.update(t,0,H(n),n,h);return s}function du(t,e,r,i){let s=0,n=0,h=Array(r);for(let u=0,o=1,f=e.length;u<f;u++,o<<=1){let c=e[u];if(c!==void 0&&u!==i)s|=o,h[n++]=c}return new Xe(t,s,h)}function zu(t,e,r,i,s){let n=0,h=Array(E);for(let u=0;r!==0;u++,r>>>=1)h[u]=r&1?e[n++]:void 0;return h[i]=s,new hi(t,n+1,h)}function Cs(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 Rn(t,e,r,i){let s=i?t:t.slice();return s[e]=r,s}function Su(t,e,r,i){let s=t.length+1;if(i&&e+1===s)return t[e]=r,t;let n=Array(s),h=0;for(let u=0;u<s;u++)if(u===e)n[u]=r,h=-1;else n[u]=t[u+h];return n}function Ou(t,e,r){let i=t.length-1;if(r&&e===i)return t.pop(),t;let s=Array(i),n=0;for(let h=0;h<i;h++){if(h===e)n=1;s[h]=t[h+n]}return s}var bu=E/4,Mu=E/2,Eu=E/4;function $e(t){if(Array.isArray(t))return t.slice();return{...t}}var ci=(t,e,r)=>_i(t,e,qu(r));function _i(t,e,r){if(!it(t))throw TypeError(`Cannot merge into non-data-structure value: ${t}`);if(C(t))return typeof r==="function"&&t.mergeWith?t.mergeWith(r,...e):t.merge?t.merge(...e):t.concat(...e);let i=Array.isArray(t),s=t,n=i?at:X,h=i?(u)=>{if(s===t)s=$e(s);s.push(u)}:(u,o)=>{let f=Object.hasOwn(s,o),c=f&&r?r(s[o],u,o):u;if(!f||c!==s[o]){if(s===t)s=$e(s);s[o]=c}};for(let u of e)n(u).forEach(h);return s}function qu(t){function e(r,i,s){return it(r)&&it(i)&&ju(r,i)?_i(r,[i],e):t?t(r,i,s):i}return e}function ju(t,e){let r=st(t),i=st(e);return j(r)===j(i)&&d(r)===d(i)}function Uu(t,e){if(!it(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(C(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=$e(t);if(Array.isArray(r))r.splice(e,1);else delete r[e];return r}function Au(t,e,r){if(!it(t))throw TypeError(`Cannot update non-data-structure value: ${t}`);if(C(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 i=$e(t);return i[e]=r,i}function Rt(t,e,r,i){if(!i)i=r,r=void 0;let s=Wn(C(t),t,Sn(e),0,r,i);return s===y?r:s}function Wn(t,e,r,i,s,n){let h=e===y;if(i===r.length){let _=h?s:e,l=n(_);return l===_?e:l}if(!h&&!it(e))throw TypeError(`Cannot update within non-data-structure value in path [${Array.from(r).slice(0,i).map(xt)}]: ${e}`);let u=r[i],o=h?y:On(e,u,y),f=Wn(o===y?t:C(o),o,r,i+1,s,n);if(f===o)return e;if(f===y)return Uu(e,u);let c=h?t?Z():{}:e;return Au(c,u,f)}var Iu=(t,e)=>Rt(t,e,()=>y),$u=(t,e,r)=>Rt(t,e,y,()=>r);function Jn(t,e,r,i){return Rt(t,[e],r,i)}function ne(){return this.__ensureOwner()}function he(){return this.__ownerID?this:this.__ensureOwner(new We)}function li(){return this.__altered}function ue(t){let e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Lu(t,e){return Fr(this,t,e)}function Ku(t){return bn(this,t)}function Ut(t){return Iu(this,t)}function ai(t,e){return $u(this,t,e)}function gi(t,e,r){return typeof t==="function"?t(this):Jn(this,t,e,r)}function yi(t,e,r){return Rt(this,t,e,r)}function xs(){A(this.size);let t={};return this.__iterate((e,r)=>{t[r]=e}),t}function Xr(...t){return Tn(this,t)}function Hn(t,...e){if(typeof t!=="function")throw TypeError(`Invalid merger function: ${t}`);return Tn(this,e,t)}function Tn(t,e,r){let i=[];for(let s of e){let n=X(s);if(n.size!==0)i.push(n)}if(i.length===0)return t;if(t.toSeq().size===0&&!t.__ownerID&&i.length===1)return lt(t)?t:t.create(i[0]);return t.withMutations((s)=>{let n=r?(h,u)=>{Jn(s,u,y,(o)=>o===y?h:r(o,h,u))}:(h,u)=>{s.set(u,h)};for(let h of i)h.forEach(n)})}function Xn(...t){return ci(this,t)}function Zn(t,...e){return ci(this,e,t)}function pi(t,...e){return Rt(this,t,Z(),(r)=>_i(r,e))}function wi(t,...e){return Rt(this,t,Z(),(r)=>ci(r,e))}function wt(t,e){Object.assign(t.prototype,e)}var R=(t)=>{let e=kt();if(t===void 0||t===null)return e;if(Pr(t))return t;let r=at(t),i=r.size;if(i===0)return e;if(A(i),i>0&&i<E)return oe(0,i,z,null,new ct(r.toArray()));return e.withMutations((s)=>{s.setSize(i),r.forEach((n,h)=>s.set(h,n))})};R.of=(...t)=>R(t);class Bn extends jt{static{wt(this,{asImmutable:ne,asMutable:he,deleteIn:Ut,mergeDeepIn:wi,mergeIn:pi,setIn:ai,update:gi,updateIn:yi,wasAltered:li,withMutations:ue,removeIn:Ut,[fn]:!0,[vt]:this.prototype.remove,merge:this.prototype.concat,[Symbol.toStringTag]:"Immutable.List",[Symbol.iterator]:this.prototype.values})}constructor(t,e,r,i,s,n,h){super();this.size=e-t,this._origin=t,this._capacity=e,this._level=r,this._root=i,this._tail=s,this.__ownerID=n,this.__hash=h,this.__altered=!1}create(t){return R(t)}toString(){return this.__toString("List [","]")}get(t,e){if(t=et(this,t),t>=0&&t<this.size){t+=this._origin;let r=Yn(this,t);return r&&r.array[t&$]}return e}set(t,e){return Ru(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 kt()}push(...t){let e=this.size;return this.withMutations((r)=>{tt(r,0,e+t.length);for(let i=0;i<t.length;i++)r.set(e+i,t[i])})}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,i,s;while(r)i=Math.floor(t()*r--),s=e.get(i),e.set(i,e.get(r)),e.set(r,s)})}concat(...t){let e=[];for(let r of t){let i=at(typeof r!=="string"&&rn(r)?r:[r]);if(i.size!==0)e.push(i)}if(e.length===0)return this;if(this.size===0&&!this.__ownerID&&e.length===1)return R(e[0]);return this.withMutations((r)=>{e.forEach((i)=>i.forEach((s)=>r.push(s)))})}setSize(t){return tt(this,0,t)}map(t,e){return this.withMutations((r)=>{for(let i=0;i<this.size;i++)r.set(i,t.call(e,r.get(i),i,this))})}slice(t,e){let r=this.size;if(te(t,e,r))return this;return tt(this,Lt(t,r),ee(e,r))}__iterate(t,e){let r=e?this.size:0;return Du(this,(i)=>t(i,e?--r:r++,this),e),e?this.size-r:r}__iterator(t){let e=t?this.size:0,r=Fs(this,t);return b((i)=>{let s=r.next();if(s.done)return!1;return i[0]=t?--e:e++,i[1]=s.value,!0})}values(){return Fs(this,!1)}keys(){return De(this.size)}__ensureOwner(t){if(t===this.__ownerID)return this;if(!t){if(this.size===0)return kt();return this.__ownerID=t,this.__altered=!1,this}return oe(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash)}}R.isList=Pr;class ct{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 i=r>>>e&$;if(i>=this.array.length)return new ct([],t);let s=i===0,n;if(e>0){let u=this.array[i];if(n=u?.removeBefore(t,e-z,r),n===u&&s)return this}if(s&&!n)return this;let h=At(this,t);if(!s)for(let u=0;u<i;u++)h.array[u]=void 0;if(n)h.array[i]=n;return h}removeAfter(t,e,r){if(r===(e?1<<e+z:E)||this.array.length===0)return this;let i=r-1>>>e&$;if(i>=this.array.length)return this;let s;if(e>0){let h=this.array[i];if(s=h?.removeAfter(t,e-z,r),s===h&&i===this.array.length-1)return this}let n=At(this,t);if(n.array.splice(i+1),s)n.array[i]=s;return n}}function Fs(t,e){let{_origin:r,_capacity:i}=t,s=It(i),n=t._tail,h=[];o(t._root,t._level,0);let u={done:!1,value:void 0};return L(()=>{while(h.length>0){let f=h[h.length-1];if(f.from===f.to){h.pop();continue}let c=e?--f.to:f.from++;if(f.isLeaf)return u.value=f.array?.[c],u;let _=f.array?.[c],l=f.level-z,a=f.offset+(c<<f.level);o(_,l,a)}return I});function o(f,c,_){if(c===0){let l=_===s?n?.array:f?.array,a=_>r?0:r-_,g=i-_;if(g>E)g=E;if(a!==g)h.push({array:l,from:a,to:g,isLeaf:!0})}else{let l=f?.array,a=_>r?0:r-_>>c,g=(i-_>>c)+1;if(g>E)g=E;if(a!==g)h.push({array:l,from:a,to:g,level:c,offset:_,isLeaf:!1})}}}function Du(t,e,r){let{_origin:i,_capacity:s}=t,n=It(s),h=t._tail,u=t._level,o=t._root;return u===0?Qn(o,0,i,s,n,h,e,r):Gn(o,u,0,i,s,n,h,e,r)}function Qn(t,e,r,i,s,n,h,u){let o=e===s?n?.array:t?.array,f=e>r?0:r-e,c=i-e;if(c>E)c=E;while(f!==c){let _=u?--c:f++;if(h(o?.[_])===!1)return!1}}function Gn(t,e,r,i,s,n,h,u,o){let f=t?.array,c=r>i?0:i-r>>e,_=(s-r>>e)+1;if(_>E)_=E;let l=e-z;while(c!==_){let a=o?--_:c++,g=r+(a<<e);if((l===0?Qn(f?.[a],g,i,s,n,h,u,o):Gn(f?.[a],l,g,i,s,n,h,u,o))===!1)return!1}}var oe=(t,e,r,i,s,n,h)=>new Bn(t,e,r,i,s,n,h),kt=()=>oe(0,0,z);function Ru(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:i,_root:s}=t,n=Hr();if(e>=It(t._capacity))i=Zr(i,t.__ownerID,0,e,r,n);else s=Zr(s,t.__ownerID,t._level,e,r,n);if(!n.value)return t;if(t.__ownerID)return t._root=s,t._tail=i,t.__hash=void 0,t.__altered=!0,t;return oe(t._origin,t._capacity,t._level,s,i)}function Zr(t,e,r,i,s,n){let h=i>>>r&$,u=t&&h<t.array.length;if(!u&&s===void 0)return t;let o;if(r>0){let f=t&&t.array[h],c=Zr(f,e,r-z,i,s,n);if(c===f)return t;return o=At(t,e),o.array[h]=c,o}if(u&&t.array[h]===s)return t;if(n)W(n);if(o=At(t,e),s===void 0&&h===o.array.length-1)o.array.pop();else o.array[h]=s;return o}function At(t,e){if(e&&e===t?.ownerID)return t;return new ct(t?.array.slice()??[],e)}function Yn(t,e){if(e>=It(t._capacity))return t._tail;if(e<1<<t._level+z){let{_root:r,_level:i}=t;while(r&&i>0)r=r.array[e>>>i&$],i-=z;return r}}function tt(t,e,r){if(e!==void 0)e|=0;if(r!==void 0)r|=0;let i=t.__ownerID||new We,s=t._origin,n=t._capacity,h=s+e,u=r===void 0?n:r<0?n+r:s+r;if(h===s&&u===n)return t;if(h>=u)return t.clear();let{_level:o,_root:f}=t,c=0;while(h+c<0)f=new ct(f?.array.length?[void 0,f]:[],i),o+=z,c+=1<<o;if(c)h+=c,s+=c,u+=c,n+=c;let _=It(n),l=It(u);while(l>=1<<o+z)f=new ct(f?.array.length?[f]:[],i),o+=z;let a=t._tail,g=l<_?Yn(t,u-1):l>_?new ct([],i):a;if(a&&l>_&&h<n&&a.array.length){f=At(f,i);let w=f;for(let S=o;S>z;S-=z){let q=_>>>S&$;w=w.array[q]=At(w.array[q],i)}w.array[_>>>z&$]=a}if(u<n)g=g&&g.removeAfter(i,0,u);if(h>=l)h-=l,u-=l,o=z,f=null,g=g&&g.removeBefore(i,0,h);else if(h>s||l<_){c=0;while(f){let w=h>>>o&$;if(w!==l>>>o&$)break;if(w)c+=(1<<o)*w;o-=z,f=f.array[w]}if(f&&h>s)f=f.removeBefore(i,o,h-c);if(f&&l<_)f=f.removeAfter(i,o,l-c);if(c)h-=c,u-=c}if(t.__ownerID)return t.size=u-h,t._origin=h,t._capacity=u,t._level=o,t._root=f,t._tail=g,t.__hash=void 0,t.__altered=!0,t;return oe(h,u,o,f,g)}var It=(t)=>t<E?0:t-1>>>z<<z,Y=(t)=>t===void 0||t===null?Nt():Je(t)?t:Nt().withMutations((e)=>{let r=X(t);A(r.size),r.forEach((i,s)=>e.set(s,i))});Y.of=(...t)=>Y(t);class Pn extends si{static{wt(this,{[rt]:!0,[vt]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.OrderedMap",keys:T.prototype.keys,values:T.prototype.values,__iterate:T.prototype.__iterate})}constructor(t,e,r,i){super(t?t.size:0,void 0,r,i);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 Nt()}set(t,e){return ks(this,t,e)}remove(t){return ks(this,t,y)}entries(){return this.__iterator(!1)}__iterator(t){let e=this._list.__iterator(t);return b((r)=>{while(!0){let i=e.next();if(i.done)return!1;let s=i.value[1];if(s)return r[0]=s[0],r[1]=s[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 Nt();return this.__ownerID=t,this.__altered=!1,this._map=e,this._list=r,this}return di(e,r,t,this.__hash)}}Y.isOrderedMap=Je;var di=(t,e,r,i)=>new Pn(t,e,r,i),Nt=()=>di(Z(),kt());function ks(t,e,r){let{_map:i,_list:s}=t,n=i.get(e),h=n!==void 0,u,o;if(r===y){if(!h)return t;if(s.size>=E&&s.size>=i.size*2){let f=[];if(s.forEach((c,_)=>{if(c!==void 0&&n!==_)f.push(c)}),o=kt().withMutations((c)=>{for(let _=0;_<f.length;_++)c.set(_,f[_])}),u=Z().withMutations((c)=>{for(let _=0;_<f.length;_++)c.set(f[_][0],_)}),t.__ownerID)u.__ownerID=o.__ownerID=t.__ownerID}else u=i.remove(e),o=n===s.size-1?s.pop():s.set(n,void 0)}else if(h){if(r===s.get(n)[1])return t;u=i,o=s.set(n,[e,r])}else{let f=s.size;u=i.set(e,f),o=s.set(f,[e,r])}if(t.__ownerID)return t.size=u.size,t._map=u,t._list=o,t.__hash=void 0,t.__altered=!0,t;return di(u,o)}var Le=(t)=>t===void 0||t===null?Ke():xr(t)?t:Ke().pushAll(t);Le.of=(...t)=>Le(t);class Cn extends jt{static{wt(this,{asImmutable:ne,asMutable:he,wasAltered:li,withMutations:ue,[ln]:!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,i){super();this.size=t,this._head=e,this.__ownerID=r,this.__hash=i,this.__altered=!1}create(t){return Le(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 i=t.length-1;i>=0;i--)r={value:t[i],next:r};return Wr(this,e,r)}pushAll(t){if(t=at(t),t.size===0)return this;if(this.size===0&&xr(t))return t;A(t.size);let e=this.size,r=this._head;return t.__iterate((i)=>{e++,r={value:i,next:r}},!0),Wr(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(te(t,e,this.size))return this;let r=Lt(t,this.size);if(ee(e,this.size)!==this.size)return jt.prototype.slice.call(this,t,e);let s=this.size-r,n=this._head;while(r--)n=n.next;return Wr(this,s,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 zi(this.size,this._head,t,this.__hash)}__iterate(t,e){if(e){let s=this.toArray(),n=s.length,h=0;while(h!==n)if(t(s[n-++h],n-h,this)===!1)break;return h}let r=0,i=this._head;while(i){if(t(i.value,r++,this)===!1)break;i=i.next}return r}__iterator(t){if(t){let i=this.toArray(),s=i.length,n=0;return b((h)=>{if(n===s)return!1;let u=s-++n;return h[0]=u,h[1]=i[u],!0})}let e=0,r=this._head;return b((i)=>{if(!r)return!1;return i[0]=e++,i[1]=r.value,r=r.next,!0})}values(){let t=this._head,e={done:!1,value:void 0};return L(()=>{if(!t)return I;return e.value=t.value,t=t.next,e})}keys(){return De(this.size)}}Le.isStack=xr;function Wr(t,e,r){if(t.__ownerID)return t.size=e,t._head=r,t.__hash=void 0,t.__altered=!0,t;return zi(e,r)}var zi=(t,e,r,i)=>new Cn(t,e,r,i),Ns,Ke=()=>Ns||(Ns=zi(0)),M=(t)=>t===void 0||t===null?Vt():Cr(t)&&!x(t)?t:Vt().withMutations((e)=>{let r=gt(t);A(r.size),r.forEach((i)=>e.add(i))});M.of=(...t)=>M(t);M.fromKeys=(t)=>M(X(t).keySeq());M.intersect=(t)=>{return t=F(t).toArray(),t.length?M(t.pop()).intersect(...t):Vt()};M.union=(t)=>{let e=F(t).toArray();return e.length?M(e.pop()).union(...e):Vt()};class Si extends Te{static{wt(this,{withMutations:ue,asImmutable:ne,asMutable:he,[_n]:!0,[vt]:this.prototype.remove,merge:this.prototype.union,concat:this.prototype.union,[Symbol.toStringTag]:"Immutable.Set"})}constructor(t,e){super();this.size=t?t.size:0,this._map=t,this.__ownerID=e}create(t){return M(t)}toString(){return this.__toString("Set {","}")}has(t){return this._map.has(t)}add(t){return je(this,this._map.set(t,t))}remove(t){return je(this,this._map.remove(t))}clear(){return je(this,this._map.clear())}map(t,e){let r=!1,i=je(this,this._map.mapEntries(([,s])=>{let n=t.call(e,s,s,this);if(n!==s)r=!0;return[n,n]},e));return r?i:this}union(...t){if(t=t.filter((e)=>e.size!==0),t.length===0)return this;if(this.size===0&&!this.__ownerID&&t.length===1)return M(t[0]);return this.withMutations((e)=>{for(let r of t)if(typeof r==="string")e.add(r);else gt(r).forEach((i)=>e.add(i))})}intersect(...t){return ms(this,t,(e,r)=>!r.every((i)=>i.includes(e)))}subtract(...t){return ms(this,t,(e,r)=>r.some((i)=>i.includes(e)))}wasAltered(){return this._map.wasAltered()}__iterator(t){return this._map.__iterator(t)}__empty(){return Vt()}__make(t,e){return xn(t,e)}__ensureOwner(t){if(t===this.__ownerID)return this;let e=this._map.__ensureOwner(t);if(!t){if(this.size===0)return this.__empty();return this.__ownerID=t,this._map=e,this}return this.__make(e,t)}}M.isSet=Cr;var xn=(t,e)=>new Si(t,e),Vs,Vt=()=>Vs||(Vs=xn(Z()));function ms(t,e,r){if(e.length===0)return t;return e=e.map((i)=>gt(i)),t.withMutations((i)=>{t.forEach((s)=>{if(r(s,e))i.remove(s)})})}function je(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 $t=(t)=>t===void 0||t===null?Br():gn(t)?t:Br().withMutations((e)=>{let r=gt(t);A(r.size),r.forEach((i)=>e.add(i))});$t.of=(...t)=>$t(t);$t.fromKeys=(t)=>$t(X(t).keySeq());class Fn extends Si{static{wt(this,{[rt]:!0,[Symbol.toStringTag]:"Immutable.OrderedSet",zip:Rr.zip,zipWith:Rr.zipWith,zipAll:Rr.zipAll})}create(t){return $t(t)}toString(){return this.__toString("OrderedSet {","}")}__empty(){return Br()}__make(t,e){return kn(t,e)}}$t.isOrderedSet=gn;var kn=(t,e)=>new Fn(t,e),Br=()=>kn(Nt());function Wu(t){if(lt(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(C(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 fe=(t,e)=>{let r;Wu(t);let i=function(h){if(h instanceof i)return h;if(!(this instanceof i))return new i(h);if(!r){r=!0;let u=Object.keys(t),o=s._indices={};s._keys=u,s._defaultValues=t;for(let f=0;f<u.length;f++){let c=u[f];if(o[c]=f,s[c])console.warn(`Cannot define ${Oi(this)} with property "${c}" since that property name is part of the Record API.`);else Hu(s,c)}}return this.__ownerID=void 0,this._values=R().withMutations((u)=>{u.setSize(this._keys.length),X(h).forEach((o,f)=>{u.set(this._indices[f],o===this._defaultValues[f]?void 0:o)})}),this},s=i.prototype=Object.create(Ju);if(s.constructor=i,s.create=i,e)i.displayName=e;return i};class Nn{static{wt(this,{asImmutable:ne,asMutable:he,deleteIn:Ut,getIn:Lu,hasIn:Ku,merge:Xr,mergeWith:Hn,mergeDeep:Xn,mergeDeepWith:Zn,mergeDeepIn:wi,mergeIn:pi,setIn:ai,toObject:xs,update:gi,updateIn:yi,withMutations:ue,removeIn:Ut,toJSON:xs,[an]:!0,[vt]:this.prototype.remove,[Symbol.iterator]:this.prototype.entries,[Symbol.toStringTag]:"Immutable.Record"})}toString(){let t=this._keys.map((e)=>`${e}: ${xt(this.get(e))}`).join(", ");return`${Oi(this)} { ${t} }`}equals(t){return this===t||lt(t)&&Et(this).equals(Et(t))}hashCode(){return Et(this).hashCode()}has(t){return Object.hasOwn(this._indices,t)}get(t,e){if(!this.has(t))return e;let r=this._indices[t],i=this._values.get(r);return i===void 0?this._defaultValues[t]:i}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 Jr(this,r)}return this}remove(t){return this.set(t)}clear(){let t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:Jr(this,t)}wasAltered(){return this._values.wasAltered()}toSeq(){return Et(this)}toJS(){return Ie(this)}entries(){return this.__iterator()}__iterate(t,e){return Et(this).__iterate(t,e)}__iterator(t){return Et(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 Jr(this,e,t)}}fe.isRecord=lt;var Oi=(t)=>t.constructor.displayName||t.constructor.name||"Record";class Vn extends Kt{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,i=r._keys,s=i.length,n=0;while(n!==s){let h=e?s-++n:n++,u=i[h];if(t(r.get(u),u,this)===!1)break}return n}__iteratorUncached(t){let e=this._record,r=e._keys,i=r.length,s=0;return b((n)=>{if(s===i)return!1;let h=t?i-++s:s++,u=r[h];return n[0]=u,n[1]=e.get(u),!0})}}var Et=(t)=>new Vn(t);fe.getDescriptiveName=Oi;var Ju=Nn.prototype;function Jr(t,e,r){let i=Object.create(Object.getPrototypeOf(t));return i._values=e,i.__ownerID=r,i}function Hu(t,e){Object.defineProperty(t,e,{get(){return this.get(e)},set(r){Ct(this.__ownerID,"Cannot set on an immutable record."),this.set(e,r)}})}var vs=(t,e,r=1)=>{if(Ct(r!==0,"Cannot step a Range by 0"),Ct(t!==void 0,"You must define a start value when using Range"),Ct(e!==void 0,"You must define an end value when using Range"),r=Math.abs(r),e<t)r=-r;let i=Math.max(0,Math.ceil((e-t)/r-1)+1);return new bi(t,e,r,i)};class bi extends yt{_start;_end;_step;constructor(t,e,r,i){super();this._start=t,this._end=e,this._step=r,this.size=i}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(te(t,e,this.size))return this;if(t=Lt(t,this.size),e=ee(e,this.size),e<=t)return vs(0,0);return vs(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,i=this._step,s=e?this._start+(r-1)*i:this._start,n=0;while(n!==r){let h=s;s+=e?-i:i;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,i=t?this._start+(e-1)*r:this._start,s=0;return b((n)=>{if(s===e)return!1;let h=i;return i+=t?-r:r,n[0]=t?e-++s:s++,n[1]=h,!0})}values(){let t=this.size,e=this._step,r=this._start,i=0,s={done:!1,value:void 0};return L(()=>{if(i===t)return I;return s.value=r,r+=e,i++,s})}keys(){return De(this.size)}equals(t){return t instanceof bi?this._start===t._start&&this._end===t._end&&this._step===t._step:kr(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}class Qr extends yt{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 U(this._value,t)}slice(t,e){let r=this.size;return te(t,e,r)?this:new Qr(this._value,ee(e,r)-Lt(t,r))}reverse(){return this}indexOf(t){if(U(this._value,t))return 0;return-1}lastIndexOf(t){if(U(this._value,t))return this.size;return-1}__iterateUncached(t,e){let r=this.size,i=0;while(i!==r)if(t(this._value,e?r-++i:i++,this)===!1)break;return i}__iteratorUncached(t){let e=this.size,r=this._value,i=0;return b((s)=>{if(i===e)return!1;return s[0]=t?e-++i:i++,s[1]=r,!0})}values(){let t=this.size,e=this._value,r=0,i={done:!1,value:void 0};return L(()=>{if(r===t)return I;return r++,i.value=e,i})}keys(){return De(this.size)}equals(t){return t instanceof Qr?this.size===t.size&&U(this._value,t._value):kr(this,t)}static{this.prototype[Symbol.iterator]=this.prototype.values}}var Tu=["nid","cid","eid","vid","si","sk"];class Mi{constructor(t,e,r,i,s,n,h){this.comps=t,this.h=e,this.fragment=r,this.comment=i,this.renderFn=s,this.getSeqInfo=n??Yu,this.cache=h??new gr}setNullCache(){this.cache=new ar}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 i=this.renderToDOM(t,e,this.renderFn);if(r){let s=i.querySelectorAll("[data-nid],[data-cid],[data-eid]");for(let{dataset:n}of s)for(let h of Tu)delete n[h]}return i.innerHTML}renderRoot(t,e,r=null){let i=this.comps.getCompFor(e),s=i.getView(r).anode.nodeId??null;return i?this._rValComp(t,e,i,s,"ROOT",r):null}renderIt(t,e,r,i){let s=this.comps.getCompFor(t.it);return s?this._rValComp(t,t.it,s,e,r,i):null}_rValComp(t,e,r,i,s,n){let h=`${n??t.viewsId??""}${i}-${s}`,u=this.cache.get(e,h);if(u)return u;let o=n?r.getView(n):t.lookupBestView(r.views,"main"),f=this.renderMetadata("Comp",{nid:i}),c=this.renderFragment([f,o.render(t,this)]);return this.cache.set(e,h,c),c}renderEach(t,e,r,i){let{seq:s,filter:n,loopWith:h}=e.eval(t),[u,o]=this.getSeqInfo(s),f=[],c=h.call(t.it,s);for(let[_,l]of o(s))if(n.call(t.it,_,l,c)){let a=t.enter(l,{key:_},!0),g=this.renderIt(a,r,_,i);f.push(this.renderMetadata("Each",{nid:r,[u]:_})),f.push(g)}return f}renderEachWhen(t,e,r,i){let{seq:s,filter:n,loopWith:h,enricher:u}=e.eval(t),[o,f]=this.getSeqInfo(s),c=!!u,_=[],l=h.call(t.it,s);for(let[a,g]of f(s))if(n.call(t.it,a,g,l)){let w={key:a,value:g},S=`${i}-${a}`,q;if(c)u.call(t.it,w,a,g,l),q=this.cache.get2(t.it,g,S);else q=this.cache.get(g,S);if(q){_.push(this.renderMetadata("Each",{nid:i,[o]:a})),_.push(q);continue}let dt=t.enter(g,w,!1),zt=r.render(dt,this);if(_.push(this.renderMetadata("Each",{nid:i,[o]:a})),c)this.cache.set2(t.it,g,S,zt);else this.cache.set(g,S,zt);_.push(zt)}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*Xu(t){let e=0;for(let r of t)yield[e++,r]}function*Zu(t){for(let[e,r]of t.toSeq().entries())yield[e,r]}var mn=new Map,Bu=["si",Xu],Qu=["sk",Zu],Gu=["si",function*(e){}];function Yu(t){return j(t)?Bu:d(t)?Qu:mn.get(t?.constructor)??Gu}function qi(t){return t[4]==="-"&&(t[0]==="d"||t[0]==="a")}function th(t,e,r){for(let i in e){let s=e[i];if(s===void 0)Pu(t,i,r);else if(qi(i))t.setAttribute(i,s);else if(i==="dangerouslySetInnerHTML")t.innerHTML=s.__html??"";else if(typeof s==="object"&&s!==null)Cu(t,r,i,s);else if(i==="className")t.setAttribute("class",s);else t[i]=s}}function Pu(t,e,r){let i=r[e];if(e==="dangerouslySetInnerHTML")t.innerHTML="";else if(qi(e))t.removeAttribute(e);else if(typeof i==="string"){if(e!=="className")t[e]="";let s=e==="className"?"class":e==="htmlFor"?"for":e;t.removeAttribute(s)}else t[e]=null}function Cu(t,e,r,i){let s=e?.[r];if(s&&typeof s==="object"&&Object.getPrototypeOf(s)!==Object.getPrototypeOf(i)){t[r]=i;return}let n=t[r];if(typeof n!=="object"||n===null)t[r]={},n=t[r];let h=n;for(let u in i)h[u]=i[u]}class Ht{isEqualTo(t){return this===t}toDom(t){return null}}function Ei(t){return t instanceof Jt?t.key:void 0}function xu(t){return t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function"}function ji(t,e){if(e==null)return;if(xu(e))for(let r of e)ji(t,r);else if(e instanceof Ht)if(e instanceof N)t.push(...e.childs);else t.push(e);else t.push(new ce(e))}class ce extends Ht{constructor(t){super();this.text=String(t)}get nodeType(){return 3}isEqualTo(t){return t instanceof ce&&this.text===t.text}toDom(t){return t.document.createTextNode(this.text)}}class Wt extends Ht{constructor(t){super();this.text=t}get nodeType(){return 8}isEqualTo(t){return t instanceof Wt&&this.text===t.text}toDom(t){return t.document.createComment(this.text)}}class N extends Ht{constructor(t){super();let e=[];ji(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 i=r.toDom(t);if(i)e.appendChild(i)}return e}}class Jt extends Ht{constructor(t,e,r,i,s){super();this.tag=t,this.attrs=e??{},this.childs=r??[],this.key=i!=null?String(i):void 0,this.namespace=typeof s==="string"?s:null}get nodeType(){return 1}isEqualTo(t){if(!(t instanceof Jt)||this.tag!==t.tag||this.key!==t.key||this.namespace!==t.namespace||this.childs.length!==t.childs.length)return!1;for(let e in this.attrs)if(this.attrs[e]!==t.attrs[e])return!1;for(let e in t.attrs)if(!Object.hasOwn(this.attrs,e))return!1;for(let e=0;e<this.childs.length;e++)if(!this.childs[e].isEqualTo(t.childs[e]))return!1;return!0}toDom(t){let e=t.document,r=this.namespace===null?e.createElement(this.tag):e.createElementNS(this.namespace,this.tag);th(r,this.attrs,{});for(let i of this.childs){let s=i.toDom(t);if(s)r.appendChild(s)}return r}}function eh(t,e){let r=null;for(let i in t){if(!Object.hasOwn(e,i)){r??={},r[i]=void 0;continue}let s=t[i],n=e[i];if(s===n);else if(typeof s==="object"&&s!==null&&typeof n==="object"&&n!==null)if(Object.getPrototypeOf(n)!==Object.getPrototypeOf(s))r??={},r[i]=n;else{let h=eh(s,n);if(h)r??={},r[i]=h}else r??={},r[i]=n}for(let i in e)if(!Object.hasOwn(t,i))r??={},r[i]=e[i];return r}function Fu(t,e,r){let i=t.parentNode,s=e.toDom(r);if(i&&s&&s!==t)i.replaceChild(s,t);return s||t}function rh(t,e,r,i){if(e===r||e.isEqualTo(r))return t;if(e instanceof ce&&r instanceof ce||e instanceof Wt&&r instanceof Wt)return t.data=r.text,t;if(e instanceof Jt&&r instanceof Jt&&e.tag===r.tag&&e.namespace===r.namespace&&e.key===r.key){let s=eh(e.attrs,r.attrs);if(s)th(t,s,e.attrs);if(!r.attrs.dangerouslySetInnerHTML)vn(t,e.childs,r.childs,e.tag,i);return t}if(e instanceof N&&r instanceof N)return vn(t,e.childs,r.childs,null,i),t;return Fu(t,r,i)}function vn(t,e,r,i,s){if(e.length===0){for(let f of r){let c=f.toDom(s);if(c)t.appendChild(c)}return}if(r.length===0){while(t.firstChild)t.removeChild(t.firstChild);return}let n=Array.from(t.childNodes),h={};for(let f=0;f<e.length;f++){let c=Ei(e[f]);if(c!=null)h[c]=f}let u=new Uint8Array(e.length),o=0;for(let f=0;f<r.length;f++){let c=r[f],_=Ei(c),l=-1;if(_!=null){if(_ in h&&!u[h[_]])l=h[_]}else while(o<e.length){if(!u[o]&&Ei(e[o])==null){l=o++;break}o++}if(l>=0){u[l]=1;let a=n[l],g=rh(a,e[l],c,s),w=t.childNodes[f]??null;if(g!==w)t.insertBefore(g,w)}else{let a=c.toDom(s);if(a){let g=t.childNodes[f]??null;t.insertBefore(a,g)}}}for(let f=e.length-1;f>=0;f--)if(!u[f]&&n[f].parentNode===t)t.removeChild(n[f])}var Be=new WeakMap;function ih(t,e,r){let i=Be.get(e),s=t instanceof N;if(i){let h=i.vnode instanceof N;if(h===s){let u=h?e:i.dom,o=rh(u,i.vnode,t,r);return Be.set(e,{vnode:t,dom:s?e:o}),o}Be.delete(e)}let n=t.toDom(r);if(n)e.innerHTML="",e.appendChild(n),Be.set(e,{vnode:t,dom:s?e:n});return n}function sh(t,e,r){let i=t.toUpperCase(),s={},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")s.className=e[o];else if(o==="for")s.htmlFor=e[o];else if(qi(o))s[o]=String(e[o]);else s[o]=e[o];let u=[];return ji(u,r),new Jt(i,s,u,n,h)}var nh=Symbol("BadValue"),fh=(t)=>t;class B{constructor(t,e,r,i,s=null){this.type=t,this.name=e,this.typeCheck=r,this.coercer=i,this.checks=[],this.defaultValue=s}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),i=`set${r}`,s=this;t[i]=function(n){let h=s.coerceOr(n,nh);if(h===nh)return console.warn("invalid value",n),this;return this.set(e,h)},t[`update${r}`]=function(n){return this[i](n(this.get(e)))},t[`reset${r}`]=function(){return this.set(e,s.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 Ai{isValid(t){return!0}getMessage(t){return"Invalid"}}class ch extends Ai{}var ku=new ch;class V extends Ai{constructor(t,e){super();this._isValid=t,this._getMessage=e}isValid(t){return this._isValid(t)}getMessage(t){return this._getMessage(t)}}var Nu=new V((t)=>Number.isInteger(t),()=>"Integer expected"),Vu=new V((t)=>Number.isFinite(t),()=>"Float expected"),mu=new V((t)=>typeof t==="boolean",()=>"Boolean expected"),vu=new V((t)=>typeof t==="string",()=>"String expected"),to=new V((t)=>R.isList(t),()=>"List expected"),eo=new V((t)=>k.isMap(t),()=>"Map expected"),ro=new V((t)=>Y.isOrderedMap(t),()=>"OrderedMap expected"),io=new V((t)=>M.isSet(t),()=>"Set expected"),so=(t)=>!!t;class Ii extends B{constructor(t,e=!1){super("bool",t,mu,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(i){return this.set(r,!!i)}}}class Qe extends B{constructor(t,e=null){super("any",t,ku,fh,e)}toDataDef(){let{defaultValue:t}=this;return{type:Ui(t)??"any",defaultValue:t?.toJS?t.toJS():t}}}var no=(t)=>t?.toString?.()??"";class $i extends B{constructor(t,e=""){super("text",t,vu,no,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 ho=(t)=>Number.isFinite(t)?Math.trunc(t):null;class _h extends B{constructor(t,e=0){super("int",t,Nu,ho,e)}}var uo=(t)=>null;class Li extends B{constructor(t,e=0){super("float",t,Vu,uo,e)}}var Ui=(t)=>t?.constructor?.getMetaClass?.()?.name;class lh{constructor(t){this.typeName=t}isValid(t){return Ui(t)===this.typeName}getMessage(t){let e=Ui(t);return`Expected "${this.typeName}", got "${e}"`}}class ah extends B{constructor(t,e,r){super(t,e,new lh(t),fh,null);this.args=r}toDataDef(){return{component:this.typeName,args:this.args}}}var hh=Symbol("NONE");function Ki(t,e,r){yh(t,e,gh),t[`setIn${r}At`]=function(s,n){return this.set(e,this.get(e).set(s,n))},t[`getIn${r}At`]=function(s,n){return this.get(e).get(s,n)},t[`updateIn${r}At`]=function(s,n){let h=this.get(e),u=h.get(s,hh);if(u!==hh)return this.set(e,h.set(s,n(u)));return console.warn("key",s,"not found in",e,h),this};function i(s){return this.set(e,this.get(e).delete(s))}t[`deleteIn${r}At`]=i,t[`removeIn${r}At`]=i}var gh=R(),oo=(t)=>Array.isArray(t)?R(t):null;class Di extends B{constructor(t,e=gh){super("list",t,to,oo,e)}extendProtoForType(t,e){let{name:r}=this;Ki(t,r,e),t[`pushIn${e}`]=function(i){return this.set(r,this.get(r).push(i))},t[`insertIn${e}At`]=function(i,s){return this.set(r,this.get(r).insert(i,s))}}}var fo=(t)=>k(t);class Ri extends B{constructor(t,e=k()){super("map",t,eo,fo,e)}extendProtoForType(t,e){Ki(t,this.name,e)}}var co=(t)=>Y(t);class Wi extends B{constructor(t,e=Y()){super("omap",t,ro,co,e)}extendProtoForType(t,e){Ki(t,this.name,e)}}function yh(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 uh=M(),_o=(t)=>Array.isArray(t)?M(t):t instanceof Set?M(t):null;class Ji extends B{constructor(t,e=uh){super("set",t,io,_o,e)}extendProtoForType(t,e){let{name:r}=this;yh(t,r,uh),t[`addIn${e}`]=function(i){return this.set(r,this.get(r).add(i))},t[`deleteIn${e}`]=function(i){return this.set(r,this.get(r).delete(i))},t[`removeIn${e}`]=t[`deleteIn${e}`],t[`hasIn${e}`]=function(i){return this.get(r).has(i)},t[`toggleIn${e}`]=function(i){let s=this.get(r);return this.set(r,s.has(i)?s.delete(i):s.add(i))}}}function oh(t,e,r){let i=e.lookupComponent(t.type);return console.assert(i!==null,"component not found",{field:t}),i?.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(i={},s={}){let n={};for(let h in i){let u=e[h];if(r.has(h))n[h]=oh(u,s.scope,i[h]);else if(u===void 0){console.warn("extra argument to constructor:",t,h,i);continue}n[h]=u.coerceOrDefault(i[h])}for(let h of r)if(n[h]===void 0)n[h]=oh(e[h],s.scope,i[h]);return this(n)}}}build(){let t={},e={},{name:r,_methods:i,fields:s}=this;for(let u in s){let o=s[u];t[u]=o.defaultValue,o.extendProto(e)}let n={[r]:fe(t,r)}[r];Object.assign(n.prototype,e,i);let h={fields:s,name:r,methods:i};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 i in e)t[i]=e[i];return this}addField(t,e,r){let i=new r(t,e);return this.fields[t]=i,i}addCompField(t,e,r){let i=new ah(e,t,r);return this.compFields.add(t),this.fields[t]=i,i}}var wh=new Map,lo={text:$i,int:_h,float:Li,bool:Ii,list:Di,map:Ri,omap:Wi,set:Ji,any:Qe};function ao(t,{fields:e={},methods:r,statics:i}){let s=new ph(t);for(let n in e){let h=e[n],u=typeof h;if(u==="string")s.addField(n,h,$i);else if(u==="number")s.addField(n,h,Li);else if(u==="boolean")s.addField(n,h,Ii);else if(R.isList(h)||Array.isArray(h))s.addField(n,R(h),Di);else if(M.isSet(h)||h instanceof Set)s.addField(n,M(h),Ji);else if(Y.isOrderedMap(h))s.addField(n,h,Wi);else if(h?.type&&h?.defaultValue!==void 0){let o=lo[h.type]??Qe;s.addField(n,new o().coerceOr(h.defaultValue),o)}else if(h?.component&&h?.args!==void 0)s.addCompField(n,h.component,h.args);else if(k.isMap(h)||h?.constructor===Object)s.addField(n,k(h),Ri);else{let o=wh.get(h?.constructor)??Qe;s.addField(n,h,o)}}if(r)s.methods(r);if(i)s.statics(i);return s.build()}var go=(t)=>new dr(t.name??"Comp",ao(t.name,t),t.view??"Not Defined",t.views,t.style,t.commonStyle??"",t.globalStyle??"",t.computed,t.input,t.logic,t.bubble,t.response,t.alter,t.dynamic,t.on);var{raw:tf,raw:ef}=String;function rf(t,e){return new fr(t,e)}var yo=(t)=>typeof t==="string"?document.querySelector(t):t;function sf(t){let e=yo(t),r=new be,i=(o)=>new N(o),s=(o)=>new Wt(o),n={document},h=(o,f)=>ih(o,f,n),u=new Mi(r,sh,i,s,h);return new Ar(e,h,r,u,Yt)}export{sf as tutuca,mn as seqInfoByClass,rf as macro,Je as isOrderedMap,Je as isOMap,ie as isMap,Pr as isList,d as isKeyed,j as isIndexed,ie as isIMap,Is as injectCss,ef as html,wh as fieldsByClass,tf as css,go as component,fe as Record,Yt as ParseContext,Y as OMap,R as List,M as ISet,k as IMap};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tutuca",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Zero-dependency frontend framework with immutable state and virtual DOM",
|
|
6
6
|
"main": "./dist/tutuca.js",
|
|
@@ -28,8 +28,7 @@
|
|
|
28
28
|
],
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
|
31
|
-
"url": "git+https://github.com/marianoguerra/tutuca.git"
|
|
32
|
-
"directory": "tutuca"
|
|
31
|
+
"url": "git+https://github.com/marianoguerra/tutuca.git"
|
|
33
32
|
},
|
|
34
33
|
"engines": {
|
|
35
34
|
"node": ">=18"
|
|
@@ -42,6 +41,7 @@
|
|
|
42
41
|
"homepage": "https://github.com/marianoguerra/tutuca#readme",
|
|
43
42
|
"devDependencies": {
|
|
44
43
|
"@biomejs/biome": "^2.4.9",
|
|
44
|
+
"fast-check": "^4.5.3",
|
|
45
45
|
"jsdom": "^28.1.0",
|
|
46
46
|
"prettier": "^3.8.1"
|
|
47
47
|
}
|