mancha 0.21.2 → 0.21.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/dist/mancha.js CHANGED
@@ -13,37 +13,7 @@ function a(e,t){let n=r(t);n!==void 0&&(e.href=n)}let o={};var s=class{construct
13
13
  * @license
14
14
  * SPDX-License-Identifier: Apache-2.0
15
15
  */
16
- function _(e,t){e.textContent=g(t)}function v(e){return l(e[0].toLowerCase())}function y(e){let t=e[0];return h(t)}function ee(e){return h(e.map(g).join(``))}function te(e){let t=e.childNodes;for(let e=0;e<t.length;e++){let n=t[e];n.prev=e>0?t[e-1]:null,n.next=e<t.length-1?t[e+1]:null}}let ne=[v`:`,v`style`,v`class`];function*b(e,t=new Set){let n=new Set,r=Array.from(e.childNodes).filter(e=>!t.has(e));for(yield e;r.length;){let e=r.shift();n.has(e)||(n.add(e),yield e),e.childNodes&&Array.from(e.childNodes).filter(e=>!t.has(e)).forEach(e=>{r.push(e)})}}function x(e,t){return e?.[t]!==void 0}function S(e,t){return typeof e?.[t]==`function`}function C(e){return e.replace(/-./g,e=>e[1].toUpperCase())}function w(e,t){return e.attribs?e.attribs[t]??null:e.getAttribute?.(t)??null}function re(e,t){return e.attribs?t in e.attribs:e.hasAttribute?.(t)??!1}function T(e,t,n=``){return w(e,n+t)||w(e,`data-${t}`)||(e.dataset?.[C(t)]??null)}function E(e,t,n){e.attribs?e.attribs[t]=n:e.setAttribute?.(t,n)}function D(e,t,n){e.attribs?e.attribs[t]=n:f(ne,e,t,n)}function O(e,t,n){switch(t){case`disabled`:e.disabled=n;return;case`selected`:e.selected=n;return;case`checked`:e.checked=n;return;default:e[t]=n}}function k(e,t){e.attribs?delete e.attribs[t]:e.removeAttribute?.(t)}function ie(e,t,n,r=``){re(e,`${r}${t}`)?E(e,`${r}${t}`,n):re(e,`data-${t}`)?E(e,`data-${t}`,n):E(e,`${r}${t}`,n)}function A(e,t,n=``){k(e,`${n}${t}`),k(e,`data-${t}`)}function ae(e,t,n){if(e.attribs&&t.attribs)t.attribs[n]=e.attribs[n];else if(n.startsWith(`data-`)){let r=C(n.slice(5));t.dataset&&e.dataset&&(t.dataset[r]=e.dataset[r])}else{let r=e?.getAttribute?.(n);D(t,n,r||``)}}function oe(e){return x(e,`firstElementChild`)?e.firstElementChild:Array.from(e.children).find(e=>e.nodeType===1)}function j(e,...t){if(S(e,`replaceWith`)){e.replaceWith(...t);return}else{let n=e,r=n.parentNode;if(!r)return;let i=Array.from(r.childNodes).indexOf(n);n.parentNode=null,t.forEach(e=>{e.parentNode=r}),r.childNodes=[].concat(Array.from(r.childNodes).slice(0,i),t,Array.from(r.childNodes).slice(i+1)),te(r)}}function se(e,...t){S(e,`replaceChildren`)?e.replaceChildren(...t):(e.childNodes=t,t.forEach(t=>{t.parentNode=e}),te(e))}function ce(e,t){return S(t,`appendChild`)?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,te(e),t)}function M(e,t){return S(t,`removeChild`)?e.removeChild(t):(se(e,...Array.from(e.childNodes).filter(e=>e!==t)),t)}function N(e,t,n){return n?S(e,`insertBefore`)?e.insertBefore(t,n):(t.parentNode&&M(t.parentNode,t),j(n,t,n),t):ce(e,t)}function le(e,t=0){return e?e.length<=t?e:`${e.slice(0,t-1)}…`:``}function P(e,t=0){return globalThis.DocumentFragment&&e instanceof DocumentFragment?Array.from(e.childNodes).map(e=>P(e,t)).join(``):le(e.outerHTML||e.nodeValue||String(e),t)}function ue(e){return e.includes(`/`)?e.split(`/`).slice(0,-1).join(`/`):``}function de(e){return!e.includes(`://`)&&!e.startsWith(`/`)&&!e.startsWith(`#`)&&!e.startsWith(`data:`)}var fe=class e{iterable;constructor(e){this.iterable=e}filter(t){return new e(e.filterGenerator(t,this.iterable))}map(t){return new e(e.mapGenerator(t,this.iterable))}find(e){for(let t of this.iterable)if(e(t))return t}array(){return Array.from(this.iterable)}*generator(){for(let e of this.iterable)yield e}static*filterGenerator(e,t){for(let n of t)e(n)&&(yield n)}static*mapGenerator(e,t){for(let n of t)yield e(n)}static equals(e,t){let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(i.value!==a.value)return!1;i=n.next(),a=r.next()}return i.done===a.done}};let F;(function(e){e.resolveIncludes=async function(e,t){let n=e,r=n.tagName?.toLowerCase();if(![`include`,`link`].includes(r)||r===`link`&&w(n,`rel`)!==`subresource`)return;this.log(`include directive found in:
17
- `,P(e,128)),this.log(`include params:`,t);let i=n.tagName.toLocaleLowerCase()===`link`?`href`:`src`,a=w(n,i);if(!a)throw Error(`"${i}" attribute missing from ${P(e,128)}.`);let o=[];r===`include`&&o.push(`src`),r===`link`&&o.push(`rel`,`href`);let s=t=>{let r=oe(t);for(let e of Array.from(n.attributes))r&&!o.includes(e.name)&&ae(n,r,e.name);j(e,...t.childNodes)},c={...t,rootDocument:!1,maxdepth:(t?.maxdepth??100)-1};if(c.maxdepth===0)throw Error(`Maximum recursion depth reached.`);if(a.includes(`://`)||a.startsWith(`//`))this.log(`Including remote file from absolute path:`,a),await this.preprocessRemote(a,c).then(s);else if(t?.dirpath?.includes(`://`)||t?.dirpath?.startsWith(`//`)){let e=a.startsWith(`/`)?a:`${t.dirpath}/${a}`;this.log(`Including remote file from relative path:`,e),await this.preprocessRemote(e,c).then(s)}else if(a.charAt(0)===`/`)this.log(`Including local file from absolute path:`,a),await this.preprocessLocal(a,c).then(s);else{let e=t?.dirpath&&t?.dirpath!==`.`?`${t?.dirpath}/${a}`:a;this.log(`Including local file from relative path:`,e),await this.preprocessLocal(e,c).then(s)}},e.rebaseRelativePaths=function(e,t){let n=e,r=n.tagName?.toLowerCase();if(!t?.dirpath)return;let o=w(n,`src`),s=w(n,`href`),c=T(n,`render`,`:`),l=o||s||c;if(!l||!de(l))return;let u=`${t.dirpath}/${l}`;this.log(`Rebasing relative path as:`,u),c?ie(n,`render`,u,`:`):x(n,`attribs`)?D(n,o?`src`:`href`,u):r===`img`?n.src=u:r===`a`?i(n,u):r===`source`||r===`audio`||r===`video`||r===`track`||r===`input`?n.src=u:r===`area`?a(n,u):this.log(`Unable to rebase relative path for element:`,r)},e.registerCustomElements=function(e,t){let n=e,r=n.tagName?.toLowerCase(),i=(w(n,`is`)||w(n,`alt`))?.toLowerCase();if([`template`,`div`].includes(r)&&i){if(r===`div`&&w(n,`role`)!==`template`)return;if(!this._customElements.has(i)){this.log(`Registering custom element: ${i}\n`,P(n,128));let e=n.content||n,r=Array.from(b(e));for(let e=1;e<r.length;e++)F.rebaseRelativePaths.call(this,r[e],t);this._customElements.set(i,n),n?.parentNode&&M(n.parentNode,n)}}},e.resolveCustomElements=function(e,t){let n=e,r=n.tagName?.toLowerCase(),i=r;if(i===`div`&&(i=w(n,`role`)?.toLowerCase()||i),i&&this._customElements.has(i)){this.log(`Processing custom element: ${i}\n`,P(n,128));let t=this._customElements.get(i),a=(t.content||t).cloneNode(!0),o=oe(a);if(o)for(let e of Array.from(n.attributes))(r!==`div`||e.name!==`role`)&&ae(n,o,e.name);let s=new fe(b(a)).find(e=>e.tagName?.toLowerCase()===`slot`);s&&j(s,...n.childNodes),j(e,...a.childNodes)}},e.resolveTextNodeExpressions=function(e,t){let n=e.nodeValue||``;if(e.nodeType!==3||!n?.trim())return;this.log(`Processing node content value:
18
- `,le(n,128));let r=new RegExp(/{{ ([^}]+) }}/gm),i=Array.from(n.matchAll(r)).map(e=>e[1]);return this.effect(function(){let t=n;for(let n of i){let r=this.eval(n,{$elem:e});t=t.replace(`{{ ${n} }}`,r==null?``:String(r))}e.nodeValue=t},{directive:`text`,element:e.parentElement??void 0,expression:i.join(`, `)})},e.resolveDataAttribute=async function(e,t){if(this._skipNodes.has(e))return;let n=e,r=T(n,`data`,`:`);if(r){this.log(`:data attribute found in:
19
- `,P(e,128)),A(n,`data`,`:`);let i;x(e,`renderer`)?(i=e.renderer,this.log(`Reusing existing subrenderer for node:`,P(e,64))):(i=this.subrenderer(),O(e,`renderer`,i),this.log(`Created and attached new subrenderer for node:`,P(e,64)));let a=i.eval(r,{$elem:e});if(await Promise.all(Object.entries(a).map(([e,t])=>e.startsWith(`$$`)?(i._store.get(`$rootRenderer`)||i).set(e,t):i.set(e,t,!0))),i===this)return;for(let t of b(e,this._skipNodes))this._skipNodes.add(t);await i.mount(e,t)}},e.resolveClassAttribute=function(e,t){if(this._skipNodes.has(e))return;let n=e,r=T(n,`class`,`:`);if(r){this.log(`:class attribute found in:
20
- `,P(e,128)),A(n,`class`,`:`);let t=w(n,`class`)||``;return this.effect(function(){let i=this.eval(r,{$elem:e});D(n,`class`,(i?`${t} ${i}`:t).trim())},{directive:`class`,element:n,expression:r})}},e.resolveTextAttributes=function(e,t){if(this._skipNodes.has(e))return;let n=e,r=T(n,`text`,`:`);if(r){this.log(`:text attribute found in:
21
- `,P(e,128)),A(n,`text`,`:`);let t=t=>this.textContent(e,t);return this.effect(function(){let n=this.eval(r,{$elem:e});t(n==null?``:String(n))},{directive:`:text`,element:n,expression:r})}},e.resolveHtmlAttribute=async function(e,t){if(this._skipNodes.has(e))return;let n=e,r=T(n,`html`,`:`);if(r){this.log(`:html attribute found in:
22
- `,P(e,128)),A(n,`html`,`:`);let i=null;return this.effect(function(){let a=this.eval(r,{$elem:e});return new Promise(e=>{(async()=>{i&&=(i.dispose(),null);let r=this.subrenderer();i=r;let o=await r.preprocessString(a,t);await r.renderNode(o),se(n,o),r._store.set(`$rootNode`,n),e()})()})},{directive:`:html`,element:n,expression:r})}},e.resolveEventAttributes=function(e,t){if(this._skipNodes.has(e))return;let n=e;for(let t of Array.from(n.attributes||[]))if(t.name.startsWith(`:on:`)||t.name.startsWith(`data-on-`)){let r=``,i=[];if(t.name.startsWith(`:on:`)?[r,...i]=t.name.substring(4).split(`.`):t.name.startsWith(`data-on-`)&&([r,...i]=t.name.substring(8).split(`.`)),!r)throw Error(`Invalid event attribute: ${t.name}`);this.log(t.name,`attribute found in:
23
- `,P(e,128)),A(n,t.name);let a=r===`submit`&&n.tagName.toUpperCase()===`FORM`;e.addEventListener?.(r,n=>((i.includes(`prevent`)||a)&&n.preventDefault(),this.eval(t.value,{$elem:e,$event:n})))}},e.resolveForAttribute=async function(e,t){if(this._skipNodes.has(e))return;let n=e,r=T(n,`for`,`:`)?.trim();if(r){this.log(`:for attribute found in:
24
- `,P(e,128)),A(n,`for`,`:`);let i=T(n,`key`,`:`);i&&A(n,`key`,`:`);for(let t of b(e,this._skipNodes))this._skipNodes.add(t);let a=w(n,`style`)||``;E(n,`style`,`display: none;`);let o=e.parentNode;if(!o)return;let s=this.createElement(`template`,e.ownerDocument);N(o,s,e),M(o,e),`content`in s?ce(s.content,e):ce(s,e),this.log(`:for template:
25
- `,P(s,128));let c=r.split(` in `,2);if(c.length!==2)throw Error(`Invalid :for format: \`${r}\`. Expected "{key} in {expression}".`);let l=i?T(n,`data`,`:`):null,u=new Map,d=[],f=[],[p,m]=c;await this.effect(function(){let n=this.eval(m,{$elem:e});if(this.log(`:for list items:`,n),!Array.isArray(n)){console.error(`Expression did not yield a list: \`${m}\` => \`${n}\``);return}if(i){let r=new Set,c=new Map,d=[],f=s.nextSibling;for(let s=0;s<n.length;s++){let m=n[s],h=this.eval(i,{[p]:m,$index:s});r.has(h)&&console.warn(`:for duplicate key detected: ${h}. Using last item.`),r.add(h);let g,_,v=u.get(h);if(v){if(g=v.node,_=v.subrenderer,d.push(_.set(p,m,!0)),d.push(_.set(`$index`,s,!0)),l&&x(g,`renderer`)){let e=g.renderer,t=e.eval(l,{$elem:g});d.push(...Object.entries(t).map(([t,n])=>e.set(t,n,!0)))}g===f||g.nextSibling===f||N(o,g,f)}else{_=this.subrenderer(),_.set(p,m,!0),_.set(`$index`,s,!0);let n=e.cloneNode(!0);N(o,n,f),this._skipNodes.add(n),d.push(_.mount(n,t).then(()=>{E(n,`style`,a)})),g=n,this.log(`Rendered list child:
26
- `,P(n,128))}c.set(h,{node:g,subrenderer:_}),f=g.nextSibling}for(let[e,{node:t,subrenderer:n}]of u)r.has(e)||(n.dispose(),t.parentNode&&M(t.parentNode,t),this._skipNodes.delete(t));u.clear();for(let[e,t]of c)u.set(e,t);return Promise.all(d).then(()=>{})}else{f.splice(0,f.length).forEach(e=>{e.dispose()}),d.splice(0,d.length).forEach(e=>{e.parentNode&&M(e.parentNode,e),this._skipNodes.delete(e)});let r=s.nextSibling,i=[];for(let s=0;s<n.length;s++){let c=n[s],l=this.subrenderer();l.set(p,c,!0),l.set(`$index`,s,!0);let u=e.cloneNode(!0);N(o,u,r),d.push(u),f.push(l),this._skipNodes.add(u),i.push(l.mount(u,t).then(()=>{E(u,`style`,a)})),this.log(`Rendered list child:
27
- `,P(u,128))}return Promise.all(i).then(()=>{})}},{directive:`:for`,element:n,expression:r})}},e.resolveBindAttribute=function(e,t){if(this._skipNodes.has(e))return;let n=e,r=T(n,`bind`,`:`);if(r){this.log(`:bind attribute found in:
28
- `,P(e,128));let t=w(n,`:bind:on`)?.split(`,`)||n.dataset?.bindOn?.split(`,`)||[`change`,`input`];A(n,`bind`,`:`),k(n,`:bind:on`),k(n,`data-bind-on`);let i=w(n,`type`)===`checkbox`?`checked`:`value`;!r.includes(`.`)&&!this.has(r)&&this.set(r,``);let a=this;this.effect(function(){let t=this.eval(r,{$elem:e});i===`checked`?n.checked=!!t:(n.value=t,n.value!==t&&t!=null&&a._pendingValueRetries.push(()=>{n.value=t}))},{directive:`:bind`,element:n,expression:r});let o=`${r} = $elem.${i}`;for(let n of t)e.addEventListener(n,()=>this.eval(o,{$elem:e}))}},e.resolveIfAttribute=function(e,t){if(this._skipNodes.has(e))return;let n=e,r=T(n,`if`,`:`);if(r){this.log(`:if attribute found in:
29
- `,P(e,128)),A(n,`if`,`:`);let t=this.createComment(` :if placeholder `,e.ownerDocument);this.effect(function(){this.eval(r,{$elem:e})?!n.parentNode&&t.parentNode&&j(t,n):n.parentNode&&j(n,t)},{directive:`:if`,element:n,expression:r})}},e.resolveShowAttribute=function(e,t){if(this._skipNodes.has(e))return;let n=e,r=T(n,`show`,`:`);if(r){this.log(`:show attribute found in:
30
- `,P(e,128)),A(n,`show`,`:`);let t=n.style?.display===`none`?``:n.style?.display??w(n,`style`)?.split(`;`)?.find(e=>e.split(`:`)[0]===`display`)?.split(`:`)?.at(1)?.trim();this.effect(function(){let i=this.eval(r,{$elem:e});n.style?n.style.display=i?t:`none`:D(n,`style`,`display: ${i?t:`none`};`)},{directive:`:show`,element:n,expression:r})}},e.resolveCustomAttribute=function(e,t){if(this._skipNodes.has(e))return;let n=e;for(let t of Array.from(n.attributes||[])){let r=`:attr:`,i=`data-attr-`;if(t.name.startsWith(r)||t.name.startsWith(i)){this.log(t.name,`attribute found in:
31
- `,P(e,128)),k(n,t.name);let a=(t.name.split(r,2).at(-1)||``).split(i,2).at(-1)??``;this.effect(function(){E(n,a,this.eval(t.value,{$elem:e}))},{directive:`:attr:${a}`,element:n,expression:t.value})}}},e.resolveCustomProperty=function(e,t){if(this._skipNodes.has(e))return;let n=e;for(let t of Array.from(n.attributes||[])){let r=`:prop:`,i=`data-prop-`;if(t.name.startsWith(r)||t.name.startsWith(i)){this.log(t.name,`property found in:
32
- `,P(e,128)),k(n,t.name);let a=C((t.name.split(r,2).at(-1)||``).split(i,2).at(-1)??``);this.effect(function(){O(n,a,this.eval(t.value,{$elem:e}))},{directive:`:prop:${a}`,element:n,expression:t.value})}}},e.stripTypes=(e,t)=>{let n=e;w(n,`:types`)&&k(n,`:types`),w(n,`data-types`)&&k(n,`data-types`)},e.resolveRenderAttribute=async function(e,t){if(this._skipNodes.has(e))return;let n=e,r=T(n,`render`,`:`);if(!r)return;this.log(`:render attribute found: ${r}`),A(n,`render`,`:`);let i;x(e,`renderer`)?(i=e.renderer,this.log(`Reusing existing subrenderer for :render:`,P(e,64))):(i=this.subrenderer(),O(n,`renderer`,i)),await i.mount(e,t);for(let t of b(e,this._skipNodes))this._skipNodes.add(t);try{let e=await import(r);typeof e.default==`function`?await e.default(n,i):e.default!==void 0&&console.warn(`Module ${r} default export is not a function`)}catch(e){console.error(`Failed to execute render init from ${r}:`,e)}}})(F||={});function pe(){return new URL(globalThis.window?.location?.href||`http://localhost/`)}function me(e){return e.substring(2)}function he(e){return`\$\$${e}`}function ge(e){return e.keys().filter(e=>e.startsWith(`$$`))}async function _e(e,t){for(let[n,r]of t.searchParams.entries()){let t=he(n);e.get(t)!==r&&await e.set(t,r)}}function ve(e,t,n){let r=me(t),i=!1;if(!n)e.searchParams.has(r)&&(e.searchParams.delete(r),i=!0);else{let t=String(n);e.searchParams.get(r)!==t&&(e.searchParams.set(r,t),i=!0)}return i}function ye(e,t){let n=!1;for(let r of ge(t))ve(e,r,t.get(r))&&(n=!0);n&&globalThis.window?.history?.replaceState({},``,e.toString())}function be(e){return async()=>{let t=pe(),n=new Set;for(let[r,i]of t.searchParams.entries()){let t=he(r);n.add(t),e.get(t)!==i&&e.set(t,i)}let r=ge(e);for(let t of r)n.has(t)||e.del(t)}}async function xe(e){let t=pe();await _e(e,t),ye(t,e),e.addKeyHandler(/^\$\$/,(e,t)=>{let n=pe();ve(n,e,t)&&globalThis.window?.history?.replaceState({},``,n.toString())}),globalThis.window?.addEventListener(`popstate`,be(e))}
33
- /*
34
- * @license
35
- * Portions Copyright (c) 2013, the Dart project authors.
36
- */
37
- let Se=new Set([`this`,`typeof`]),Ce=new Set([`in`]),we=new Set([`+`,`-`,`!`,`typeof`]),Te=new Set([`=`,`+`,`-`,`*`,`/`,`%`,`^`,`==`,`!=`,`>`,`<`,`>=`,`<=`,`||`,`&&`,`??`,`&`,`===`,`!==`,`|`,`in`]),I={"!":0,":":0,",":0,")":0,"]":0,"}":0,"?":2,"??":3,"||":4,"&&":5,"|":6,"^":7,"&":8,"!=":9,"==":9,"!==":9,"===":9,">=":10,">":10,"<=":10,"<":10,in:10,"+":11,"-":11,"%":12,"/":12,"*":12,"(":13,"[":13,".":13,"?.":13,"{":13},Ee={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,"==":(e,t)=>e==t,"!=":(e,t)=>e!=t,"===":(e,t)=>e===t,"!==":(e,t)=>e!==t,">":(e,t)=>e>t,">=":(e,t)=>e>=t,"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,"||":(e,t)=>e||t,"&&":(e,t)=>e&&t,"??":(e,t)=>e??t,"|":(e,t)=>t(e),in:(e,t)=>e in t},De={"+":e=>e,"-":e=>-e,"!":e=>!e,typeof:e=>typeof e};var Oe=class{empty(){return{type:`Empty`,evaluate(e){return e},getIds(e){return e}}}literal(e){return{type:`Literal`,value:e,evaluate(e){return this.value},getIds(e){return e}}}id(e){return{type:`ID`,value:e,evaluate(e){return this.value===`this`?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(e,t){let n=De[e];return{type:`Unary`,operator:e,child:t,evaluate(e){return n(this.child.evaluate(e))},getIds(e){return this.child.getIds(e)}}}binary(e,t,n){let r=Ee[t];return{type:`Binary`,operator:t,left:e,right:n,evaluate(e){if(this.operator===`=`){if(this.left.type!==`ID`&&this.left.type!==`Getter`&&this.left.type!==`Index`)throw Error(`Invalid assignment target: ${this.left}`);let t=this.right.evaluate(e),n,r;return this.left.type===`Getter`?(n=this.left.receiver.evaluate(e),r=this.left.name):this.left.type===`Index`?(n=this.left.receiver.evaluate(e),r=String(this.left.argument.evaluate(e))):this.left.type===`ID`&&(n=e,r=this.left.value),n===void 0?void 0:(n[r]=t,t)}return r(this.left.evaluate(e),this.right.evaluate(e))},getIds(e){return this.left.getIds(e),this.right.getIds(e),e}}}getter(e,t,n){return{type:`Getter`,receiver:e,name:t,optional:n,evaluate(e){let t=this.receiver.evaluate(e);if(!(this.optional&&t==null))return t?.[this.name]},getIds(e){return this.receiver.getIds(e),e}}}invoke(e,t,n,r){if(t!=null&&typeof t!=`string`)throw Error(`method not a string`);return{type:`Invoke`,receiver:e,method:t,arguments:n,optional:r,evaluate(e){let t=this.receiver.evaluate(e);if(this.optional&&t==null)return;let n=this.method?t:e?.this??e,r=this.method?t?.[this.method]:t,i=this.arguments??[],a=[];for(let t of i)if(t?.type===`SpreadElement`){let n=t.evaluate(e);n&&typeof n[Symbol.iterator]==`function`&&a.push(...n)}else a.push(t?.evaluate(e));return r?.apply?.(n,a)},getIds(e){return this.receiver.getIds(e),this.arguments?.forEach(t=>{t?.getIds(e)}),e}}}paren(e){return e}index(e,t,n){return{type:`Index`,receiver:e,argument:t,optional:n,evaluate(e){let t=this.receiver.evaluate(e);if(this.optional&&t==null)return;let n=this.argument.evaluate(e);return t?.[n]},getIds(e){return this.receiver.getIds(e),e}}}ternary(e,t,n){return{type:`Ternary`,condition:e,trueExpr:t,falseExpr:n,evaluate(e){return this.condition.evaluate(e)?this.trueExpr.evaluate(e):this.falseExpr.evaluate(e)},getIds(e){return this.condition.getIds(e),this.trueExpr.getIds(e),this.falseExpr.getIds(e),e}}}map(e){return{type:`Map`,properties:e,evaluate(t){let n={};if(e&&this.properties)for(let e of this.properties)e.type===`SpreadProperty`?Object.assign(n,e.evaluate(t)):n[e.key]=e.value.evaluate(t);return n},getIds(t){if(e&&this.properties)for(let e of this.properties)e.type===`SpreadProperty`?e.expression.getIds(t):e.value.getIds(t);return t}}}property(e,t){return{type:`Property`,key:e,value:t,evaluate(e){return this.value.evaluate(e)},getIds(e){return this.value.getIds(e)}}}list(e){return{type:`List`,items:e,evaluate(e){if(!this.items)return[];let t=[];for(let n of this.items)if(n?.type===`SpreadElement`){let r=n.evaluate(e);r&&typeof r[Symbol.iterator]==`function`&&t.push(...r)}else t.push(n?.evaluate(e));return t},getIds(e){return this.items?.forEach(t=>{t?.getIds(e)}),e}}}arrowFunction(e,t){return{type:`ArrowFunction`,params:e,body:t,evaluate(e){let t=this.params,n=this.body;return function(...r){let i=Object.fromEntries(t.map((e,t)=>[e,r[t]])),a=this??e??{},o=new Proxy(a,{set(e,t,n){return Object.hasOwn(i,t)&&(i[t]=n),e[t]=n,n},get(e,t){return Object.hasOwn(i,t)?i[t]:e[t]}});return n.evaluate(o)}},getIds(e){return this.body.getIds(e).filter(e=>!this.params.includes(e))}}}spreadProperty(e){return{type:`SpreadProperty`,expression:e,evaluate(e){return this.expression.evaluate(e)},getIds(e){return this.expression.getIds(e)}}}spreadElement(e){return{type:`SpreadElement`,expression:e,evaluate(e){return this.expression.evaluate(e)},getIds(e){return this.expression.getIds(e)}}}};
38
- /*
39
- * @license
40
- * Portions Copyright (c) 2013, the Dart project authors.
41
- */
42
- let ke=new Set([`==`,`!=`,`<=`,`>=`,`||`,`&&`,`??`,`?.`]),Ae=new Set([`===`,`!==`]),L=function(e){return e[e.STRING=1]=`STRING`,e[e.IDENTIFIER=2]=`IDENTIFIER`,e[e.DOT=3]=`DOT`,e[e.COMMA=4]=`COMMA`,e[e.COLON=5]=`COLON`,e[e.INTEGER=6]=`INTEGER`,e[e.DECIMAL=7]=`DECIMAL`,e[e.OPERATOR=8]=`OPERATOR`,e[e.GROUPER=9]=`GROUPER`,e[e.KEYWORD=10]=`KEYWORD`,e[e.ARROW=11]=`ARROW`,e[e.OPTIONAL_DOT=12]=`OPTIONAL_DOT`,e[e.SPREAD=13]=`SPREAD`,e}({}),R=(e,t,n=0)=>({kind:e,value:t,precedence:n}),je=e=>e===9||e===10||e===13||e===32,Me=e=>{if(e===95||e===36)return!0;let t=e&-33;return 65<=t&&t<=90},Ne=e=>Me(e)||z(e),Pe=e=>Se.has(e),Fe=e=>e===34||e===39,z=e=>48<=e&&e<=57,Ie=e=>e===43||e===45||e===42||e===47||e===33||e===38||e===37||e===60||e===61||e===62||e===63||e===94||e===124,Le=e=>e===40||e===41||e===91||e===93||e===123||e===125,Re=e=>e.replace(/\\(.)/g,(e,t)=>{switch(t){case`n`:return`
43
- `;case`r`:return`\r`;case`t`:return` `;case`b`:return`\b`;case`f`:return`\f`;default:return t}});var ze=class{_input;_index=-1;_tokenStart=0;_next;constructor(e){this._input=e,this._advance()}nextToken(){for(;je(this._next??-1);)this._advance(!0);if(Fe(this._next??-1))return this._tokenizeString();if(Me(this._next??-1))return this._tokenizeIdentOrKeyword();if(z(this._next??-1))return this._tokenizeNumber();if(this._next===46)return this._tokenizeDot();if(this._next===44)return this._tokenizeComma();if(this._next===58)return this._tokenizeColon();if(Ie(this._next??-1))return this._tokenizeOperator();if(Le(this._next??-1))return this._tokenizeGrouper();if(this._advance(),this._next!==void 0)throw Error(`Expected end of input, got ${this._next}`)}_advance(e){this._index++,this._index<this._input.length?(this._next=this._input.charCodeAt(this._index),e===!0&&(this._tokenStart=this._index)):this._next=void 0}_getValue(e=0){let t=this._input.substring(this._tokenStart,this._index+e);return e===0&&this._clearValue(),t}_clearValue(){this._tokenStart=this._index}_tokenizeString(){let e=this._next;for(this._advance(!0);this._next!==e;){if(this._next===void 0||this._next===92&&(this._advance(),this._next===void 0))throw Error(`unterminated string`);this._advance()}let t=R(L.STRING,Re(this._getValue()));return this._advance(),t}_tokenizeIdentOrKeyword(){do this._advance();while(Ne(this._next??-1));let e=this._getValue();return R(Pe(e)?L.KEYWORD:Ce.has(e)?L.OPERATOR:L.IDENTIFIER,e,I[e]??0)}_tokenizeNumber(){do this._advance();while(z(this._next??-1));return this._next===46?this._tokenizeDot():R(L.INTEGER,this._getValue())}_tokenizeDot(){if(this._advance(),z(this._next??-1))return this._tokenizeFraction();if(this._next===46){if(this._advance(),this._next===46)return this._advance(),this._clearValue(),R(L.SPREAD,`...`);throw Error(`Unexpected token ..`)}return this._clearValue(),R(L.DOT,`.`,13)}_tokenizeComma(){return this._advance(!0),R(L.COMMA,`,`)}_tokenizeColon(){return this._advance(!0),R(L.COLON,`:`)}_tokenizeFraction(){do this._advance();while(z(this._next??-1));return R(L.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(Ae.has(e))this._advance(),this._advance();else{if(e=this._getValue(1),e===`=>`)return this._advance(),R(L.ARROW,e);ke.has(e)&&this._advance()}return e=this._getValue(),e===`?.`?R(L.OPTIONAL_DOT,e,13):R(L.OPERATOR,e,I[e])}_tokenizeGrouper(){let e=String.fromCharCode(this._next??0),t=R(L.GROUPER,e,I[e]);return this._advance(!0),t}};let Be=(e,t)=>new Ve(e,t).parse();var Ve=class{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new ze(e),this._ast=t}parse(){this._advance();let e=this._parseExpression();if(this._token)throw Error(`Unexpected token: ${this._token.value}`);return e}_advance(e,t){if(!this._matches(e,t))throw Error(`Expected kind ${e} (${t}), was ${this._token?.kind} (${this._token?.value})`);let n=this._tokenizer.nextToken();this._token=n,this._kind=n?.kind,this._value=n?.value}_matches(e,t){return!(e&&this._kind!==e||t&&this._value!==t)}_parseExpression(){if(!this._token)return this._ast.empty();let e=this._parseUnary();return e===void 0?void 0:this._parsePrecedence(e,0)}_parsePrecedence(e,t){if(e===void 0)throw Error(`Expected left to be defined.`);for(;this._token;)if(this._matches(L.GROUPER,`(`)){let t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(L.GROUPER,`[`)){let t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(L.DOT)||this._matches(L.OPTIONAL_DOT)){let t=this._kind===L.OPTIONAL_DOT;if(this._advance(),t&&this._matches(L.GROUPER,`[`)){let t=this._parseIndex();e=this._ast.index(e,t,!0)}else if(t&&this._matches(L.GROUPER,`(`)){let t=this._parseArguments();e=this._ast.invoke(e,void 0,t,!0)}else{let n=this._parseUnary();e=this._makeInvokeOrGetter(e,n,t)}}else if(this._matches(L.KEYWORD))break;else if(this._matches(L.OPERATOR)&&this._token.precedence>=t)e=this._value===`?`?this._parseTernary(e):this._parseBinary(e,this._token);else break;return e}_makeInvokeOrGetter(e,t,n){if(t===void 0)throw Error(`expected identifier`);if(t.type===`ID`)return this._ast.getter(e,t.value,n);if(t.type===`Invoke`&&t.receiver.type===`ID`){let r=t.receiver;return this._ast.invoke(e,r.value,t.arguments,n)}else throw Error(`expected identifier: ${t}`)}_parseBinary(e,t){if(!Te.has(t.value))throw Error(`unknown operator: ${t.value}`);this._advance();let n=this._parseUnary();for(;(this._kind===L.OPERATOR||this._kind===L.DOT||this._kind===L.GROUPER)&&this._token&&(this._token.precedence??0)>t.precedence;)n=this._parsePrecedence(n,this._token?.precedence??0);if(n===void 0)throw Error(`Expected expression after ${t.value}`);return this._ast.binary(e,t.value,n)}_parseUnary(){if(this._matches(L.KEYWORD,`typeof`)){this._advance();let e=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(`typeof`,e)}if(this._matches(L.OPERATOR)){let e=this._value;if(this._advance(),e===`+`||e===`-`){if(this._matches(L.INTEGER))return this._parseInteger(e);if(this._matches(L.DECIMAL))return this._parseDecimal(e)}if(!e||!we.has(e))throw Error(`unexpected token: ${e}`);let t=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(e,t)}return this._parsePrimary()}_parseTernary(e){this._advance(L.OPERATOR,`?`);let t=this._parseExpression();this._advance(L.COLON);let n=this._parseExpression();return this._ast.ternary(e,t,n)}_parsePrimary(){switch(this._kind){case L.KEYWORD:{let e=this._value??``;if(e===`this`)return this._advance(),this._ast.id(e);throw Se.has(e)?Error(`unexpected keyword: ${e}`):Error(`unrecognized keyword: ${e}`)}case L.IDENTIFIER:return this._parseInvokeOrIdentifier();case L.STRING:return this._parseString();case L.INTEGER:return this._parseInteger();case L.DECIMAL:return this._parseDecimal();case L.GROUPER:return this._value===`(`?this._parseParenOrFunction():this._value===`{`?this._parseMap():this._value===`[`?this._parseList():void 0;case L.COLON:throw Error(`unexpected token ":"`);default:return}}_parseList(){let e=[];do{if(this._advance(),this._matches(L.GROUPER,`]`))break;if(this._matches(L.SPREAD)){this._advance();let t=this._parseExpression();t&&e.push(this._ast.spreadElement(t))}else e.push(this._parseExpression())}while(this._matches(L.COMMA));return this._advance(L.GROUPER,`]`),this._ast.list(e)}_parseMap(){let e=[];do{if(this._advance(),this._matches(L.GROUPER,`}`))break;if(this._matches(L.SPREAD)){this._advance();let t=this._parseExpression();t&&e.push(this._ast.spreadProperty(t))}else{let t=this._value??``;if((this._matches(L.STRING)||this._matches(L.IDENTIFIER))&&this._advance(),this._matches(L.COLON)){this._advance(L.COLON);let n=this._parseExpression();n&&e.push(this._ast.property(t,n))}else e.push(this._ast.property(t,this._ast.id(t)))}}while(this._matches(L.COMMA));return this._advance(L.GROUPER,`}`),this._ast.map(e)}_parseInvokeOrIdentifier(){let e=this._value;if(e===`true`)return this._advance(),this._ast.literal(!0);if(e===`false`)return this._advance(),this._ast.literal(!1);if(e===`null`)return this._advance(),this._ast.literal(null);if(e===`undefined`)return this._advance(),this._ast.literal(void 0);let t=this._parseIdentifier(),n=this._parseArguments();return n?this._ast.invoke(t,void 0,n):t}_parseIdentifier(){if(!this._matches(L.IDENTIFIER))throw Error(`expected identifier: ${this._value}`);let e=this._value;return this._advance(),this._ast.id(e??``)}_parseArguments(){if(!this._matches(L.GROUPER,`(`))return;let e=[];do{if(this._advance(),this._matches(L.GROUPER,`)`))break;if(this._matches(L.SPREAD)){this._advance();let t=this._parseExpression();t&&e.push(this._ast.spreadElement(t))}else{let t=this._parseExpression();e.push(t)}}while(this._matches(L.COMMA));return this._advance(L.GROUPER,`)`),e}_parseIndex(){this._advance();let e=this._parseExpression();return this._advance(L.GROUPER,`]`),e}_parseParenOrFunction(){let e=this._parseArguments();if(this._matches(L.ARROW)){this._advance();let t=this._parseExpression(),n=e?.map(e=>e.value)??[];return this._ast.arrowFunction(n,t)}else return this._ast.paren(e?.[0])}_parseString(){let e=this._ast.literal(this._value??``);return this._advance(),e}_parseInteger(e=``){let t=this._ast.literal(parseInt(`${e}${this._value}`,10));return this._advance(),t}_parseDecimal(e=``){let t=this._ast.literal(parseFloat(`${e}${this._value}`));return this._advance(),t}};let B=Symbol(`__computed__`);function V(e){return typeof e==`object`&&!!e&&B in e&&e[B]===!0}let He=new Oe,H=`__is_proxy__`;function Ue(e){return e instanceof Ke||e[H]===!0}function We(e,t){let n=e?._store;if(n?.has(t))return n.get(t);if(n?.has(`$parent`))return We(n.get(`$parent`),t)}function U(e,t){let n=e?._store;return n?.has(t)?e:n?.has(`$parent`)?U(n.get(`$parent`),t):null}function Ge(e,t,n){let r=U(e,t);r?r._store.set(t,n):e._store.set(t,n)}var Ke=class e{evalkeys=[`$elem`,`$event`];expressionCache=new Map;observers=new Map;keyHandlers=new Map;_store=new Map;_lock=Promise.resolve();_notify=new Map;_computedDepth=0;constructor(e){for(let[t,n]of Object.entries(e||{}))this.set(t,n)}wrapObject(e,t){if(e==null||Ue(e)||Object.isFrozen(e)||Object.isSealed(e))return e;let n=Object.getPrototypeOf(e);return!(n===Object.prototype||n===null)&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,n)=>typeof n==`string`&&n in e?(delete e[n],t(),!0):!1,set:(e,n,r,i)=>{if(Reflect.get(e,n,i)===r)return!0;typeof r==`object`&&r&&(r=this.wrapObject(r,t));let a=Reflect.set(e,n,r,i);return t(),a},get:(e,n,r)=>{if(n===H)return!0;let i=Reflect.get(e,n,r);if(typeof i==`object`&&i&&!Ue(i)){let a=this.wrapObject(i,t);if(a!==i)return Reflect.set(e,n,a,r),a}return i}})}watch(e,t){let n=U(this,e);if(!n)throw Error(`Cannot watch key "${e}" as it does not exist in the store.`);n.observers.has(e)||n.observers.set(e,new Set),Array.from(n.observers.get(e)||[]).some(e=>e.observer===t)||n.observers.get(e)?.add({observer:t,store:this})}addKeyHandler(e,t){this.keyHandlers.has(e)||this.keyHandlers.set(e,new Set),this.keyHandlers.get(e)?.add(t)}tagObserversForComputed(e,t){for(let n of this.observers.values())for(let r of n)r.observer===e&&r.store===this&&(r.computedKey=t);let n=this._store.get(`$parent`);for(;n;){for(let r of n.observers.values())for(let n of r)n.observer===e&&n.store===this&&(n.computedKey=t);n=n._store.get(`$parent`)}}markDependentComputedsDirty(e){let t=U(this,e)?.observers.get(e);if(t){for(let e of t)if(e.computedKey){let t=e.store._store.get(e.computedKey);V(t)&&!t.dirty&&(t.dirty=!0,e.store.markDependentComputedsDirty(e.computedKey))}}}async notify(e,t=10){let n=U(this,e),r=Array.from(n?.observers.get(e)||[]),i=this._notify.get(e);if(i!==`executing`)return i&&clearTimeout(i),new Promise(i=>{this._notify.set(e,setTimeout(async()=>{this._notify.set(e,`executing`);try{await Promise.all(r.map(e=>e.observer.call(e.store.proxify(e.observer))))}finally{this._notify.delete(e)}let t=n?.observers.get(e);if(t)for(let e of r){let n=e.store._store.has(`$parent`),r=e.store._store.get(`$rootNode`);n&&r&&!r.isConnected&&t.delete(e)}i()},t))})}get(e,t){t&&this.watch(e,t);let n=We(this,e);if(V(n)){if(n.dirty){this._computedDepth++;try{let t=this.proxify(n.effectFn);n.value=n.fn.call(t,t),n.dirty=!1,n.effectFn&&this.tagObserversForComputed(n.effectFn,e),this.markDependentComputedsDirty(e)}finally{this._computedDepth--}}return n.value}return n}setupComputed(e,t){let n=this,r={[B]:!0,fn:t,dirty:!0};this._store.set(e,r);let i=function(){n._computedDepth++;try{let i=t.call(this,this);if(r.value!==i){r.value=i;let t=U(n,e),a=Array.from(t?.observers.get(e)||[]);for(let e of a)e.observer.call(e.store.proxify(e.observer))}r.dirty=!1}finally{n._computedDepth--}};r.effectFn=i,this.effect(i,{directive:`computed`,id:e}),this.tagObserversForComputed(i,e)}async set(e,t,n){if(V(t)){this.setupComputed(e,t.fn);return}if(this._store.has(e)&&t===this._store.get(e))return;let r=()=>(this.markDependentComputedsDirty(e),this.notify(e));if(t&&typeof t==`object`&&(t=this.wrapObject(t,r)),n?this._store.set(e,t):Ge(this,e,t),!n){for(let[n,r]of this.keyHandlers.entries())if(n.test(e))for(let n of r)await Promise.resolve(n.call(this.$,e,t))}await r()}async del(e){await this.set(e,null),this._store.delete(e),this.observers.delete(e)}dispose(){for(let e of this.observers.values())e.clear();this.observers.clear();let e=this._store.get(`$parent`);for(;e;){for(let t of e.observers.values())for(let e of t)e.store===this&&t.delete(e);e=e._store.get(`$parent`)}}keys(){return Array.from(this._store.keys())}has(e){return this._store.has(e)}getObserverStats(){let e={},t=0;for(let[n,r]of this.observers)e[n]=r.size,t+=r.size;return{totalKeys:this.observers.size,totalObservers:t,byKey:e}}effect(e,t){return e.call(this.proxify(e))}$computed(e){return{[B]:!0,fn:e,dirty:!0}}proxify(t){let n=Array.from(this._store.entries()).map(([e])=>e),r=Object.fromEntries(n.map(e=>[e,null])),i=(e,t,n)=>typeof e==`function`&&t!==`constructor`?(...t)=>e.call(n,...t):e;return new Proxy(r,{has:(e,t)=>typeof t==`string`&&(U(this,t)||Reflect.has(this,t))?!0:Reflect.has(r,t),get:(n,r,a)=>{if(typeof r==`string`){if(U(this,r)){let n=this.get(r,t);return t&&n instanceof e?n.proxify(t):i(n,r,a)}if(t&&r!==H&&!Reflect.has(this,r))return this.set(r,void 0),this.get(r,t)}return r===`$`?this.proxify(t):i(Reflect.get(this,r,a),r,a)},set:(e,t,n,r)=>(typeof t!=`string`||t in this?Reflect.set(this,t,n,r):(this._computedDepth>0&&console.warn(`[mancha] Computed wrote to '${t}'. Computeds should be pure; use $effect for side effects.`),this.set(t,n)),!0)})}get $(){return this.proxify()}makeEvalFunction(e){return(t,n)=>{let r=Be(e,He),i=new Proxy(n,{has(e,n){return n in e||n in t||n in globalThis},get(e,n){if(typeof n==`string`)return n in e?e[n]:n in t?t[n]:n in globalThis?globalThis[n]:t[n]},set(e,n,r){return typeof n==`string`?n in e?(e[n]=r,!0):(t[n]=r,!0):!1}});return r?.evaluate(i)}}cachedExpressionFunction(e){e=e.trim(),this.expressionCache.has(e)||this.expressionCache.set(e,this.makeEvalFunction(e));let t=this.expressionCache.get(e);if(!t)throw Error(`Failed to retrieve cached expression: ${e}`);return t}eval(e,t={}){let n=this.$;if(this._store.has(e))return n[e];{let r=this.cachedExpressionFunction(e);try{return r(n,t)}catch(t){return console.error(`Failed to evaluate expression: ${e}`),console.error(t),null}}}$resolve(e,t){let n={$pending:!0,$result:null,$error:null};return Promise.resolve().then(()=>e(t)).then(e=>{n.$result=e}).catch(e=>{n.$error=e instanceof Error?e:Error(String(e))}).finally(()=>{n.$pending=!1}),n}},qe=class e extends Ke{_debugLevel=`off`;dirpath=``;_perfData={lifecycle:{},effects:new Map};static DEBUG_LEVELS=[`off`,`lifecycle`,`effects`,`verbose`];_skipNodes=new Set;_customElements=new Map;_pendingValueRetries=[];debug(e){return typeof e==`boolean`?this._debugLevel=e?`lifecycle`:`off`:this._debugLevel=e,this}get debugging(){return this._debugLevel!==`off`}shouldLog(t){return e.DEBUG_LEVELS.indexOf(this._debugLevel)>=e.DEBUG_LEVELS.indexOf(t)}clearPerformanceReport(){this._perfData={lifecycle:{},effects:new Map}}getNodePath(e){let t=[],n=e;for(;n?.tagName;){let e=n.tagName.toLowerCase(),r=n.parentElement;if(r){let i=Array.from(r.children).filter(t=>t.tagName.toLowerCase()===e);if(i.length>1){let r=i.indexOf(n)+1;t.unshift(`${e}:nth-child(${r})`)}else t.unshift(e)}else t.unshift(e);n=r}return t.join(`>`)}buildObserverId(e){let t=e?.directive??`unknown`,n=le(e?.expression??``,32),r=e?.element,i=e?.id??(r?r.dataset?.perfid??r.id??r.dataset?.testid??this.getNodePath(r):`unknown`);return n?`${t}:${i}:${n}`:`${t}:${i}`}recordObserverExecution(e,t){let n=this.buildObserverId(e),r=this._perfData.effects.get(n)??{count:0,totalTime:0};r.count++,r.totalTime+=t,this._perfData.effects.set(n,r)}getPerformanceReport(){let e=Array.from(this._perfData.effects.entries()),t={};for(let[n,r]of e){let e=n.split(`:`)[0];t[e]||(t[e]={count:0,totalTime:0}),t[e].count+=r.count,t[e].totalTime+=r.totalTime}let n=e.map(([e,t])=>({id:e,executionCount:t.count,totalTime:t.totalTime,avgTime:t.count>0?t.totalTime/t.count:0})).sort((e,t)=>t.totalTime-e.totalTime).slice(0,10);return{lifecycle:this._perfData.lifecycle,effects:{total:e.length,byDirective:t,slowest:n},observers:this.getObserverStats()}}effect(e,t){let n=this;function r(){if(!n.shouldLog(`lifecycle`))return e.call(this);let r=performance.now(),i=e.call(this),a=performance.now()-r;return t&&n.recordObserverExecution(t,a),a>16&&console.warn(`[mancha] Slow observer (${a.toFixed(1)}ms):`,n.buildObserverId(t)),n.shouldLog(`effects`)&&console.debug(`[mancha] Observer (${a.toFixed(2)}ms):`,n.buildObserverId(t)),i}return super.effect(r,t)}async fetchRemote(e,t){return fetch(e,{cache:t?.cache??`default`}).then(e=>e.text())}async fetchLocal(e,t){return this.fetchRemote(e,t)}async preprocessString(e,t){this.log(`Preprocessing string content with params:
44
- `,t);let n=this.parseHTML(e,t);return await this.preprocessNode(n,t),n}async preprocessRemote(e,t){let n={};t?.cache&&(n.cache=t.cache);let r=await fetch(e,n).then(e=>e.text());return this.preprocessString(r,{...t,dirpath:ue(e),rootDocument:t?.rootDocument??!e.endsWith(`.tpl.html`)})}async preprocessLocal(e,t){let n=await this.fetchLocal(e,t);return this.preprocessString(n,{...t,dirpath:ue(e),rootDocument:t?.rootDocument??!e.endsWith(`.tpl.html`)})}subrenderer(){let e=new this.constructor().debug(this.debugging);return e._store.set(`$parent`,this),e._store.set(`$rootRenderer`,this.get(`$rootRenderer`)??this),e._customElements=this._customElements,e}log(...e){this.shouldLog(`verbose`)&&console.debug(...e)}async preprocessNode(e,t){let n=this.shouldLog(`lifecycle`)?performance.now():0;t={dirpath:this.dirpath,maxdepth:10,...t};let r=new fe(b(e,this._skipNodes)).map(async e=>{this.log(`Preprocessing node:
45
- `,P(e,128)),await F.resolveIncludes.call(this,e,t),await F.rebaseRelativePaths.call(this,e,t),await F.registerCustomElements.call(this,e,t),await F.resolveCustomElements.call(this,e,t)});return await Promise.all(r.generator()),n&&(this._perfData.lifecycle.preprocessTime=(this._perfData.lifecycle.preprocessTime??0)+(performance.now()-n)),e}async renderNode(e,t){let n=this.shouldLog(`lifecycle`)?performance.now():0;for(let n of b(e,this._skipNodes))this.log(`Rendering node:
46
- `,P(n,128)),await F.resolveForAttribute.call(this,n,t),await F.resolveRenderAttribute.call(this,n,t),await F.resolveDataAttribute.call(this,n,t),await F.resolveTextAttributes.call(this,n,t),await F.resolveHtmlAttribute.call(this,n,t),await F.resolveIfAttribute.call(this,n,t),await F.resolveShowAttribute.call(this,n,t),await F.resolveClassAttribute.call(this,n,t),await F.resolveBindAttribute.call(this,n,t),await F.resolveEventAttributes.call(this,n,t),await F.resolveTextNodeExpressions.call(this,n,t),await F.resolveCustomAttribute.call(this,n,t),await F.resolveCustomProperty.call(this,n,t),await F.stripTypes.call(this,n,t);for(let e of this._pendingValueRetries.splice(0))e();return n&&(this._perfData.lifecycle.renderTime=(this._perfData.lifecycle.renderTime??0)+(performance.now()-n)),e}async mount(e,t){let n=this.shouldLog(`lifecycle`)?performance.now():0;n&&this.clearPerformanceReport(),t={...t,rootNode:e},O(e,`renderer`,this),this._store.set(`$rootNode`,e),this.has(`$rootRenderer`)||this._store.set(`$rootRenderer`,this),this.get(`$rootRenderer`)===this&&await xe(this),await this.preprocessNode(e,t),await this.renderNode(e,t),n&&(this._perfData.lifecycle.mountTime=performance.now()-n)}};function Je(){return ee([y`*,::before,::after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}`,y`html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-family:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal}`,y`body{margin:0;line-height:inherit}`,y`hr{height:0;color:inherit;border-top-width:1px}`,y`abbr:where([title]){text-decoration:underline dotted}`,y`b,strong{font-weight:bolder}`,y`code,kbd,samp,pre{font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;font-size:1em}`,y`small{font-size:80%}`,y`sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}`,y`sub{bottom:-0.25em}`,y`sup{top:-0.5em}`,y`button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}`,y`button,select{text-transform:none}`,y`button,[type='button'],[type='reset'],[type='submit']{-webkit-appearance:button;background-color:transparent;background-image:none;cursor:pointer}`,y`:-moz-focusring{outline:auto}`,y`:-moz-ui-invalid{box-shadow:none}`,y`progress{vertical-align:baseline}`,y`::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}`,y`[type='search']{-webkit-appearance:textfield;outline-offset:-2px}`,y`::-webkit-search-decoration{-webkit-appearance:none}`,y`::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}`,y`summary{display:list-item}`,y`blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}`,y`fieldset{margin:0;padding:0}`,y`legend{padding:0}`,y`ol,ul,menu{list-style:none;margin:0;padding:0}`,y`textarea{resize:vertical}`,y`::placeholder{opacity:1;color:#9ca3af}`,y`button,[role="button"]{cursor:pointer}`,y`:disabled{cursor:default;pointer-events:none;opacity:0.75}`,y`img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}`,y`img,video{max-width:100%;height:auto}`,y`[hidden]{display:none}`,y`dialog{padding:0}`,y`dialog::backdrop{background:rgba(0,0,0,0.5)}`])}function Ye(){return ee([y`html{`,y`max-width: 70ch;`,y`padding: 2em 1em;`,y`margin: auto;`,y`line-height: 1.75;`,y`font-size: 1.25em;`,y`font-family: sans-serif;`,y`}`,y`h1,h2,h3,h4,h5,h6{`,y`margin: 1em 0 0.5em;`,y`}`,y`p,ul,ol{`,y`margin-bottom: 1em;`,y`color: #1d1d1d;`,y`}`])}let Xe={sm:640,md:768,lg:1024,xl:1280},Ze=Object.entries(Xe),W=.25,G=[...Array(15)].map((e,t)=>t+1),Qe=[16,20,24,28,32,36,40,48,56,64],$e=[72,80,96,128,160,192,256,320,384,512],K=[...G,...Qe,...$e,...Object.values(Xe)],q=Array.from({length:20},(e,t)=>(t+1)*5),et=[0,10,20,30,40,50,60,70,80,90,100],tt=[25,50,75,100,150,200,300,500,700,1e3],nt=[`hover`,`focus`,`disabled`],rt={margin:`m`,padding:`p`},it={width:`w`,height:`h`},at={top:`top`,right:`right`,bottom:`bottom`,left:`left`},ot={"min-width":`min-w`,"min-height":`min-h`,"max-width":`max-w`,"max-height":`max-h`},st={"font-mono":{"font-family":`monospace`},"font-sans":{"font-family":`sans-serif`},"font-serif":{"font-family":`serif`},"font-cursive":{"font-family":`cursive`},"text-xs":{"font-size":`.75rem`,"line-height":`calc(1 / 0.75)`},"text-sm":{"font-size":`.875rem`,"line-height":`calc(1.25 / 0.875)`},"text-base":{"font-size":`1rem`,"line-height":`calc(1.5 / 1)`},"text-lg":{"font-size":`1.125rem`,"line-height":`calc(1.75 / 1.125)`},"text-xl":{"font-size":`1.25rem`,"line-height":`calc(1.75 / 1.25)`},"text-2xl":{"font-size":`1.5rem`,"line-height":`calc(2 / 1.5)`},"text-3xl":{"font-size":`1.875rem`,"line-height":`calc(2.25 / 1.875)`},"text-4xl":{"font-size":`2.25rem`,"line-height":`calc(2.5 / 2.25)`},"text-5xl":{"font-size":`3rem`,"line-height":`1`},"text-6xl":{"font-size":`3.75rem`,"line-height":`1`},"text-7xl":{"font-size":`4.5rem`,"line-height":`1`},"font-thin":{"font-weight":100},"font-extralight":{"font-weight":200},"font-light":{"font-weight":300},"font-normal":{"font-weight":400},"font-medium":{"font-weight":500},"font-semibold":{"font-weight":600},"font-bold":{"font-weight":700},"font-extrabold":{"font-weight":800},"font-black":{"font-weight":900},italic:{"font-style":`italic`},"not-italic":{"font-style":`normal`},"w-max":{width:`max-content`},"w-min":{width:`min-content`},"w-fit":{width:`fit-content`},"h-max":{height:`max-content`},"h-min":{height:`min-content`},"h-fit":{height:`fit-content`},"size-auto":{width:`auto`,height:`auto`},"size-px":{width:`1px`,height:`1px`},"size-full":{width:`100%`,height:`100%`},"size-dvw":{width:`100dvw`,height:`100dvw`},"size-dvh":{width:`100dvh`,height:`100dvh`},"size-lvw":{width:`100lvw`,height:`100lvw`},"size-lvh":{width:`100lvh`,height:`100lvh`},"size-svw":{width:`100svw`,height:`100svw`},"size-svh":{width:`100svh`,height:`100svh`},"size-min":{width:`min-content`,height:`min-content`},"size-max":{width:`max-content`,height:`max-content`},"size-fit":{width:`fit-content`,height:`fit-content`},"tracking-tighter":{"letter-spacing":`-0.05em`},"tracking-tight":{"letter-spacing":`-0.025em`},"tracking-normal":{"letter-spacing":`0`},"tracking-wide":{"letter-spacing":`0.025em`},"tracking-wider":{"letter-spacing":`0.05em`},"tracking-widest":{"letter-spacing":`0.1em`},"leading-none":{"line-height":`1`},"leading-tight":{"line-height":`1.25`},"leading-snug":{"line-height":`1.375`},"leading-normal":{"line-height":`1.5`},"leading-relaxed":{"line-height":`1.625`},"leading-loose":{"line-height":`2`},"text-left":{"text-align":`left`},"text-right":{"text-align":`right`},"text-center":{"text-align":`center`},"text-justify":{"text-align":`justify`},underline:{"text-decoration":`underline`},"no-underline":{"text-decoration":`none`},"decoration-none":{"text-decoration":`none`},"line-through":{"text-decoration":`line-through`},uppercase:{"text-transform":`uppercase`},lowercase:{"text-transform":`lowercase`},capitalize:{"text-transform":`capitalize`},truncate:{"white-space":`nowrap`,overflow:`hidden`,"text-overflow":`ellipsis`},"text-elipsis":{"text-overflow":`ellipsis`},"text-clip":{"text-overflow":`clip`},"text-wrap":{"text-wrap":`wrap`},"text-nowrap":{"text-wrap":`nowrap`},"text-balance":{"text-wrap":`balance`},"text-pretty":{"text-wrap":`pretty`},"whitespace-normal":{"white-space":`normal`},"whitespace-nowrap":{"white-space":`nowrap`},"whitespace-pre":{"white-space":`pre`},"whitespace-pre-line":{"white-space":`pre-line`},"whitespace-pre-wrap":{"white-space":`pre-wrap`},"whitespace-break-spaces":{"white-space":`break-spaces`},relative:{position:`relative`},fixed:{position:`fixed`},absolute:{position:`absolute`},sticky:{position:`sticky`},"object-contain":{"object-fit":`contain`},"object-cover":{"object-fit":`cover`},"object-fill":{"object-fit":`fill`},"object-none":{"object-fit":`none`},block:{display:`block`},contents:{display:`contents`},hidden:{display:`none`},inline:{display:`inline`},"inline-block":{display:`inline-block`},visible:{visibility:`visible`},invisible:{visibility:`hidden`},collapse:{visibility:`collapse`},"list-none":{"list-style-type":`none`},"list-disc":{"list-style-type":`disc`},"list-decimal":{"list-style-type":`decimal`},flex:{display:`flex`},grid:{display:`grid`},"flex-1":{flex:`1 1 0%`},"flex-inline":{display:`inline-flex`},"flex-row":{"flex-direction":`row`},"flex-col":{"flex-direction":`column`},"flex-row-reverse":{"flex-direction":`row-reverse`},"flex-col-reverse":{"flex-direction":`column-reverse`},"flex-wrap":{"flex-wrap":`wrap`},"flex-wrap-reverse":{"flex-wrap":`wrap-reverse`},"flex-nowrap":{"flex-wrap":`nowrap`},"justify-start":{"justify-content":`flex-start`},"justify-end":{"justify-content":`flex-end`},"justify-center":{"justify-content":`center`},"justify-between":{"justify-content":`space-between`},"justify-around":{"justify-content":`space-around`},"justify-evenly":{"justify-content":`space-evenly`},"justify-stretch":{"justify-content":`stretch`},"items-start":{"align-items":`flex-start`},"items-end":{"align-items":`flex-end`},"items-center":{"align-items":`center`},"items-stretch":{"align-items":`stretch`},"flex-grow":{"flex-grow":1},"flex-shrink":{"flex-shrink":1},"align-baseline":{"vertical-align":`baseline`},"align-top":{"vertical-align":`top`},"align-middle":{"vertical-align":`middle`},"align-bottom":{"vertical-align":`bottom`},"align-text-top":{"vertical-align":`text-top`},"align-text-bottom":{"vertical-align":`text-bottom`},"overflow-auto":{overflow:`auto`},"overflow-x-auto":{"overflow-x":`auto`},"overflow-y-auto":{"overflow-y":`auto`},"overflow-hidden":{overflow:`hidden`},"overflow-x-hidden":{"overflow-x":`hidden`},"overflow-y-hidden":{"overflow-y":`hidden`},"overflow-visible":{overflow:`visible`},"overscroll-auto":{"overscroll-behavior":`auto`},"overscroll-contain":{"overscroll-behavior":`contain`},"overscroll-none":{"overscroll-behavior":`none`},"overscroll-x-auto":{"overscroll-behavior-x":`auto`},"overscroll-x-contain":{"overscroll-behavior-x":`contain`},"overscroll-x-none":{"overscroll-behavior-x":`none`},"overscroll-y-auto":{"overscroll-behavior-y":`auto`},"overscroll-y-contain":{"overscroll-behavior-y":`contain`},"overscroll-y-none":{"overscroll-behavior-y":`none`},"z-auto":{"z-index":`auto`},"cursor-pointer":{cursor:`pointer`},"cursor-wait":{cursor:`wait`},"cursor-not-allowed":{cursor:`not-allowed`},"select-none":{"user-select":`none`},"select-all":{"user-select":`all`},"pointer-events-auto":{"pointer-events":`auto`},"pointer-events-none":{"pointer-events":`none`},"box-border":{"box-sizing":`border-box`},"box-content":{"box-sizing":`content-box`},resize:{resize:`both`},"resize-x":{resize:`horizontal`},"resize-y":{resize:`vertical`},"resize-none":{resize:`none`},"appearance-none":{appearance:`none`,"-webkit-appearance":`none`,"-moz-appearance":`none`},border:{border:`1px solid`},"border-none":{border:`none`},"border-solid":{"border-style":`solid`},"border-dashed":{"border-style":`dashed`},"border-dotted":{"border-style":`dotted`},"border-collapse":{"border-collapse":`collapse`},"rounded-none":{"border-radius":`0`},rounded:{"border-radius":`.25rem`},"rounded-sm":{"border-radius":`.125rem`},"rounded-md":{"border-radius":`.375rem`},"rounded-lg":{"border-radius":`.5rem`},"rounded-xl":{"border-radius":`.75rem`},"rounded-full":{"border-radius":`9999px`},"shadow-2xs":{"box-shadow":`0 1px rgb(0 0 0 / 0.05)`},"shadow-xs":{"box-shadow":`0 1px 2px 0 rgb(0 0 0 / 0.05)`},shadow:{"box-shadow":`0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)`},"shadow-sm":{"box-shadow":`0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)`},"shadow-md":{"box-shadow":`0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)`},"shadow-lg":{"box-shadow":`0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)`},"shadow-xl":{"box-shadow":`0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)`},"shadow-2xl":{"box-shadow":`0 25px 50px -12px rgb(0 0 0 / 0.25)`},"shadow-inner":{"box-shadow":`inset 0 2px 4px 0 rgb(0 0 0 / 0.05)`},"shadow-none":{"box-shadow":`0 0 #0000`},ring:{"box-shadow":`var(--ring-inset, ) 0 0 0 3px rgb(59 130 246 / 0.5)`},"ring-0":{"box-shadow":`var(--ring-inset, ) 0 0 0 0px rgb(59 130 246 / 0.5)`},"ring-1":{"box-shadow":`var(--ring-inset, ) 0 0 0 1px rgb(59 130 246 / 0.5)`},"ring-2":{"box-shadow":`var(--ring-inset, ) 0 0 0 2px rgb(59 130 246 / 0.5)`},"ring-4":{"box-shadow":`var(--ring-inset, ) 0 0 0 4px rgb(59 130 246 / 0.5)`},"ring-8":{"box-shadow":`var(--ring-inset, ) 0 0 0 8px rgb(59 130 246 / 0.5)`},"ring-inset":{"--ring-inset":`inset`},outline:{"outline-style":`solid`},"outline-none":{outline:`2px solid transparent`,"outline-offset":`2px`},"outline-dashed":{"outline-style":`dashed`},"outline-dotted":{"outline-style":`dotted`},"outline-double":{"outline-style":`double`},"outline-0":{"outline-width":`0px`},"outline-1":{"outline-width":`1px`},"outline-2":{"outline-width":`2px`},"outline-4":{"outline-width":`4px`},"outline-8":{"outline-width":`8px`},"outline-offset-0":{"outline-offset":`0px`},"outline-offset-1":{"outline-offset":`1px`},"outline-offset-2":{"outline-offset":`2px`},"outline-offset-4":{"outline-offset":`4px`},"outline-offset-8":{"outline-offset":`8px`},"aspect-auto":{"aspect-ratio":`auto`},"aspect-square":{"aspect-ratio":`1 / 1`},"aspect-video":{"aspect-ratio":`16 / 9`},"backdrop-blur-none":{"backdrop-filter":`blur(0)`},"backdrop-blur-sm":{"backdrop-filter":`blur(4px)`},"backdrop-blur":{"backdrop-filter":`blur(8px)`},"backdrop-blur-md":{"backdrop-filter":`blur(12px)`},"backdrop-blur-lg":{"backdrop-filter":`blur(16px)`},"backdrop-blur-xl":{"backdrop-filter":`blur(24px)`},"backdrop-blur-2xl":{"backdrop-filter":`blur(40px)`},"backdrop-blur-3xl":{"backdrop-filter":`blur(64px)`},"transition-none":{transition:`none`},transition:{"transition-property":`all`,"transition-timing-function":`ease-in-out`,"transition-duration":`var(--transition-duration, 150ms)`},"animate-none":{animation:`none`},"animate-spin":{animation:`spin 1s linear infinite`},"animate-ping":{animation:`ping 1s cubic-bezier(0, 0, 0.2, 1) infinite`},"animate-pulse":{animation:`pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite`},"bg-auto":{"background-size":`auto`},"bg-cover":{"background-size":`cover`},"bg-contain":{"background-size":`contain`},"bg-no-repeat":{"background-repeat":`no-repeat`},"bg-fixed":{"background-attachment":`fixed`},"bg-local":{"background-attachment":`local`},"bg-scroll":{"background-attachment":`scroll`},"min-h-screen":{"min-height":`100vh`},"max-h-screen":{"max-height":`100vh`},"min-w-screen":{"min-width":`100vw`},"h-dvh":{height:`100dvh`},"h-svh":{height:`100svh`},"h-lvh":{height:`100lvh`},"w-dvw":{width:`100dvw`},"w-svw":{width:`100svw`},"w-lvw":{width:`100lvw`},"min-h-dvh":{"min-height":`100dvh`},"min-h-svh":{"min-height":`100svh`},"min-h-lvh":{"min-height":`100lvh`},"flex-none":{flex:`none`},"flex-auto":{flex:`1 1 auto`},"flex-initial":{flex:`0 1 auto`},grow:{"flex-grow":`1`},"grow-0":{"flex-grow":`0`},shrink:{"flex-shrink":`1`},"shrink-0":{"flex-shrink":`0`},"self-auto":{"align-self":`auto`},"self-start":{"align-self":`flex-start`},"self-end":{"align-self":`flex-end`},"self-center":{"align-self":`center`},"self-stretch":{"align-self":`stretch`},"self-baseline":{"align-self":`baseline`},"content-normal":{"align-content":`normal`},"content-start":{"align-content":`flex-start`},"content-end":{"align-content":`flex-end`},"content-center":{"align-content":`center`},"content-between":{"align-content":`space-between`},"content-around":{"align-content":`space-around`},"content-evenly":{"align-content":`space-evenly`},"content-stretch":{"align-content":`stretch`},"items-baseline":{"align-items":`baseline`},"inset-0":{inset:`0`},"inset-auto":{inset:`auto`},"inset-x-0":{left:`0`,right:`0`},"inset-y-0":{top:`0`,bottom:`0`},"inset-x-auto":{left:`auto`,right:`auto`},"inset-y-auto":{top:`auto`,bottom:`auto`},"sr-only":{position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,"white-space":`nowrap`,"border-width":`0`},"not-sr-only":{position:`static`,width:`auto`,height:`auto`,padding:`0`,margin:`0`,overflow:`visible`,clip:`auto`,"white-space":`normal`}},ct=[`@keyframes spin {
16
+ function _(e,t){e.textContent=g(t)}let v={sm:640,md:768,lg:1024,xl:1280},ee=Object.entries(v),y=.25,b=[...Array(15)].map((e,t)=>t+1),te=[16,20,24,28,32,36,40,48,56,64],ne=[72,80,96,128,160,192,256,320,384,512],x=[...b,...te,...ne,...Object.values(v)],S=Array.from({length:20},(e,t)=>(t+1)*5),re=[0,10,20,30,40,50,60,70,80,90,100],ie=[25,50,75,100,150,200,300,500,700,1e3],ae=[`hover`,`focus`,`disabled`],C={margin:`m`,padding:`p`},oe={width:`w`,height:`h`},se={top:`top`,right:`right`,bottom:`bottom`,left:`left`},ce={"min-width":`min-w`,"min-height":`min-h`,"max-width":`max-w`,"max-height":`max-h`},le={"font-mono":{"font-family":`monospace`},"font-sans":{"font-family":`sans-serif`},"font-serif":{"font-family":`serif`},"font-cursive":{"font-family":`cursive`},"text-xs":{"font-size":`.75rem`,"line-height":`calc(1 / 0.75)`},"text-sm":{"font-size":`.875rem`,"line-height":`calc(1.25 / 0.875)`},"text-base":{"font-size":`1rem`,"line-height":`calc(1.5 / 1)`},"text-lg":{"font-size":`1.125rem`,"line-height":`calc(1.75 / 1.125)`},"text-xl":{"font-size":`1.25rem`,"line-height":`calc(1.75 / 1.25)`},"text-2xl":{"font-size":`1.5rem`,"line-height":`calc(2 / 1.5)`},"text-3xl":{"font-size":`1.875rem`,"line-height":`calc(2.25 / 1.875)`},"text-4xl":{"font-size":`2.25rem`,"line-height":`calc(2.5 / 2.25)`},"text-5xl":{"font-size":`3rem`,"line-height":`1`},"text-6xl":{"font-size":`3.75rem`,"line-height":`1`},"text-7xl":{"font-size":`4.5rem`,"line-height":`1`},"font-thin":{"font-weight":100},"font-extralight":{"font-weight":200},"font-light":{"font-weight":300},"font-normal":{"font-weight":400},"font-medium":{"font-weight":500},"font-semibold":{"font-weight":600},"font-bold":{"font-weight":700},"font-extrabold":{"font-weight":800},"font-black":{"font-weight":900},italic:{"font-style":`italic`},"not-italic":{"font-style":`normal`},"w-max":{width:`max-content`},"w-min":{width:`min-content`},"w-fit":{width:`fit-content`},"h-max":{height:`max-content`},"h-min":{height:`min-content`},"h-fit":{height:`fit-content`},"size-auto":{width:`auto`,height:`auto`},"size-px":{width:`1px`,height:`1px`},"size-full":{width:`100%`,height:`100%`},"size-dvw":{width:`100dvw`,height:`100dvw`},"size-dvh":{width:`100dvh`,height:`100dvh`},"size-lvw":{width:`100lvw`,height:`100lvw`},"size-lvh":{width:`100lvh`,height:`100lvh`},"size-svw":{width:`100svw`,height:`100svw`},"size-svh":{width:`100svh`,height:`100svh`},"size-min":{width:`min-content`,height:`min-content`},"size-max":{width:`max-content`,height:`max-content`},"size-fit":{width:`fit-content`,height:`fit-content`},"tracking-tighter":{"letter-spacing":`-0.05em`},"tracking-tight":{"letter-spacing":`-0.025em`},"tracking-normal":{"letter-spacing":`0`},"tracking-wide":{"letter-spacing":`0.025em`},"tracking-wider":{"letter-spacing":`0.05em`},"tracking-widest":{"letter-spacing":`0.1em`},"leading-none":{"line-height":`1`},"leading-tight":{"line-height":`1.25`},"leading-snug":{"line-height":`1.375`},"leading-normal":{"line-height":`1.5`},"leading-relaxed":{"line-height":`1.625`},"leading-loose":{"line-height":`2`},"text-left":{"text-align":`left`},"text-right":{"text-align":`right`},"text-center":{"text-align":`center`},"text-justify":{"text-align":`justify`},underline:{"text-decoration":`underline`},"no-underline":{"text-decoration":`none`},"decoration-none":{"text-decoration":`none`},"line-through":{"text-decoration":`line-through`},uppercase:{"text-transform":`uppercase`},lowercase:{"text-transform":`lowercase`},capitalize:{"text-transform":`capitalize`},truncate:{"white-space":`nowrap`,overflow:`hidden`,"text-overflow":`ellipsis`},"text-elipsis":{"text-overflow":`ellipsis`},"text-clip":{"text-overflow":`clip`},"text-wrap":{"text-wrap":`wrap`},"text-nowrap":{"text-wrap":`nowrap`},"text-balance":{"text-wrap":`balance`},"text-pretty":{"text-wrap":`pretty`},"whitespace-normal":{"white-space":`normal`},"whitespace-nowrap":{"white-space":`nowrap`},"whitespace-pre":{"white-space":`pre`},"whitespace-pre-line":{"white-space":`pre-line`},"whitespace-pre-wrap":{"white-space":`pre-wrap`},"whitespace-break-spaces":{"white-space":`break-spaces`},relative:{position:`relative`},fixed:{position:`fixed`},absolute:{position:`absolute`},sticky:{position:`sticky`},"object-contain":{"object-fit":`contain`},"object-cover":{"object-fit":`cover`},"object-fill":{"object-fit":`fill`},"object-none":{"object-fit":`none`},block:{display:`block`},contents:{display:`contents`},hidden:{display:`none`},inline:{display:`inline`},"inline-block":{display:`inline-block`},visible:{visibility:`visible`},invisible:{visibility:`hidden`},collapse:{visibility:`collapse`},"list-none":{"list-style-type":`none`},"list-disc":{"list-style-type":`disc`},"list-decimal":{"list-style-type":`decimal`},flex:{display:`flex`},grid:{display:`grid`},"flex-1":{flex:`1 1 0%`},"flex-inline":{display:`inline-flex`},"flex-row":{"flex-direction":`row`},"flex-col":{"flex-direction":`column`},"flex-row-reverse":{"flex-direction":`row-reverse`},"flex-col-reverse":{"flex-direction":`column-reverse`},"flex-wrap":{"flex-wrap":`wrap`},"flex-wrap-reverse":{"flex-wrap":`wrap-reverse`},"flex-nowrap":{"flex-wrap":`nowrap`},"justify-start":{"justify-content":`flex-start`},"justify-end":{"justify-content":`flex-end`},"justify-center":{"justify-content":`center`},"justify-between":{"justify-content":`space-between`},"justify-around":{"justify-content":`space-around`},"justify-evenly":{"justify-content":`space-evenly`},"justify-stretch":{"justify-content":`stretch`},"items-start":{"align-items":`flex-start`},"items-end":{"align-items":`flex-end`},"items-center":{"align-items":`center`},"items-stretch":{"align-items":`stretch`},"flex-grow":{"flex-grow":1},"flex-shrink":{"flex-shrink":1},"align-baseline":{"vertical-align":`baseline`},"align-top":{"vertical-align":`top`},"align-middle":{"vertical-align":`middle`},"align-bottom":{"vertical-align":`bottom`},"align-text-top":{"vertical-align":`text-top`},"align-text-bottom":{"vertical-align":`text-bottom`},"overflow-auto":{overflow:`auto`},"overflow-x-auto":{"overflow-x":`auto`},"overflow-y-auto":{"overflow-y":`auto`},"overflow-hidden":{overflow:`hidden`},"overflow-x-hidden":{"overflow-x":`hidden`},"overflow-y-hidden":{"overflow-y":`hidden`},"overflow-visible":{overflow:`visible`},"overscroll-auto":{"overscroll-behavior":`auto`},"overscroll-contain":{"overscroll-behavior":`contain`},"overscroll-none":{"overscroll-behavior":`none`},"overscroll-x-auto":{"overscroll-behavior-x":`auto`},"overscroll-x-contain":{"overscroll-behavior-x":`contain`},"overscroll-x-none":{"overscroll-behavior-x":`none`},"overscroll-y-auto":{"overscroll-behavior-y":`auto`},"overscroll-y-contain":{"overscroll-behavior-y":`contain`},"overscroll-y-none":{"overscroll-behavior-y":`none`},"z-auto":{"z-index":`auto`},"cursor-pointer":{cursor:`pointer`},"cursor-wait":{cursor:`wait`},"cursor-not-allowed":{cursor:`not-allowed`},"select-none":{"user-select":`none`},"select-all":{"user-select":`all`},"pointer-events-auto":{"pointer-events":`auto`},"pointer-events-none":{"pointer-events":`none`},"box-border":{"box-sizing":`border-box`},"box-content":{"box-sizing":`content-box`},resize:{resize:`both`},"resize-x":{resize:`horizontal`},"resize-y":{resize:`vertical`},"resize-none":{resize:`none`},"appearance-none":{appearance:`none`,"-webkit-appearance":`none`,"-moz-appearance":`none`},border:{border:`1px solid`},"border-none":{border:`none`},"border-solid":{"border-style":`solid`},"border-dashed":{"border-style":`dashed`},"border-dotted":{"border-style":`dotted`},"border-collapse":{"border-collapse":`collapse`},"rounded-none":{"border-radius":`0`},rounded:{"border-radius":`.25rem`},"rounded-sm":{"border-radius":`.125rem`},"rounded-md":{"border-radius":`.375rem`},"rounded-lg":{"border-radius":`.5rem`},"rounded-xl":{"border-radius":`.75rem`},"rounded-full":{"border-radius":`9999px`},"shadow-2xs":{"box-shadow":`0 1px rgb(0 0 0 / 0.05)`},"shadow-xs":{"box-shadow":`0 1px 2px 0 rgb(0 0 0 / 0.05)`},shadow:{"box-shadow":`0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)`},"shadow-sm":{"box-shadow":`0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)`},"shadow-md":{"box-shadow":`0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)`},"shadow-lg":{"box-shadow":`0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)`},"shadow-xl":{"box-shadow":`0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)`},"shadow-2xl":{"box-shadow":`0 25px 50px -12px rgb(0 0 0 / 0.25)`},"shadow-inner":{"box-shadow":`inset 0 2px 4px 0 rgb(0 0 0 / 0.05)`},"shadow-none":{"box-shadow":`0 0 #0000`},ring:{"box-shadow":`var(--ring-inset, ) 0 0 0 3px rgb(59 130 246 / 0.5)`},"ring-0":{"box-shadow":`var(--ring-inset, ) 0 0 0 0px rgb(59 130 246 / 0.5)`},"ring-1":{"box-shadow":`var(--ring-inset, ) 0 0 0 1px rgb(59 130 246 / 0.5)`},"ring-2":{"box-shadow":`var(--ring-inset, ) 0 0 0 2px rgb(59 130 246 / 0.5)`},"ring-4":{"box-shadow":`var(--ring-inset, ) 0 0 0 4px rgb(59 130 246 / 0.5)`},"ring-8":{"box-shadow":`var(--ring-inset, ) 0 0 0 8px rgb(59 130 246 / 0.5)`},"ring-inset":{"--ring-inset":`inset`},outline:{"outline-style":`solid`},"outline-none":{outline:`2px solid transparent`,"outline-offset":`2px`},"outline-dashed":{"outline-style":`dashed`},"outline-dotted":{"outline-style":`dotted`},"outline-double":{"outline-style":`double`},"outline-0":{"outline-width":`0px`},"outline-1":{"outline-width":`1px`},"outline-2":{"outline-width":`2px`},"outline-4":{"outline-width":`4px`},"outline-8":{"outline-width":`8px`},"outline-offset-0":{"outline-offset":`0px`},"outline-offset-1":{"outline-offset":`1px`},"outline-offset-2":{"outline-offset":`2px`},"outline-offset-4":{"outline-offset":`4px`},"outline-offset-8":{"outline-offset":`8px`},"aspect-auto":{"aspect-ratio":`auto`},"aspect-square":{"aspect-ratio":`1 / 1`},"aspect-video":{"aspect-ratio":`16 / 9`},"backdrop-blur-none":{"backdrop-filter":`blur(0)`},"backdrop-blur-sm":{"backdrop-filter":`blur(4px)`},"backdrop-blur":{"backdrop-filter":`blur(8px)`},"backdrop-blur-md":{"backdrop-filter":`blur(12px)`},"backdrop-blur-lg":{"backdrop-filter":`blur(16px)`},"backdrop-blur-xl":{"backdrop-filter":`blur(24px)`},"backdrop-blur-2xl":{"backdrop-filter":`blur(40px)`},"backdrop-blur-3xl":{"backdrop-filter":`blur(64px)`},"transition-none":{transition:`none`},transition:{"transition-property":`all`,"transition-timing-function":`ease-in-out`,"transition-duration":`var(--transition-duration, 150ms)`},"animate-none":{animation:`none`},"animate-spin":{animation:`spin 1s linear infinite`},"animate-ping":{animation:`ping 1s cubic-bezier(0, 0, 0.2, 1) infinite`},"animate-pulse":{animation:`pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite`},"bg-auto":{"background-size":`auto`},"bg-cover":{"background-size":`cover`},"bg-contain":{"background-size":`contain`},"bg-no-repeat":{"background-repeat":`no-repeat`},"bg-fixed":{"background-attachment":`fixed`},"bg-local":{"background-attachment":`local`},"bg-scroll":{"background-attachment":`scroll`},"min-h-screen":{"min-height":`100vh`},"max-h-screen":{"max-height":`100vh`},"min-w-screen":{"min-width":`100vw`},"h-dvh":{height:`100dvh`},"h-svh":{height:`100svh`},"h-lvh":{height:`100lvh`},"w-dvw":{width:`100dvw`},"w-svw":{width:`100svw`},"w-lvw":{width:`100lvw`},"min-h-dvh":{"min-height":`100dvh`},"min-h-svh":{"min-height":`100svh`},"min-h-lvh":{"min-height":`100lvh`},"flex-none":{flex:`none`},"flex-auto":{flex:`1 1 auto`},"flex-initial":{flex:`0 1 auto`},grow:{"flex-grow":`1`},"grow-0":{"flex-grow":`0`},shrink:{"flex-shrink":`1`},"shrink-0":{"flex-shrink":`0`},"self-auto":{"align-self":`auto`},"self-start":{"align-self":`flex-start`},"self-end":{"align-self":`flex-end`},"self-center":{"align-self":`center`},"self-stretch":{"align-self":`stretch`},"self-baseline":{"align-self":`baseline`},"content-normal":{"align-content":`normal`},"content-start":{"align-content":`flex-start`},"content-end":{"align-content":`flex-end`},"content-center":{"align-content":`center`},"content-between":{"align-content":`space-between`},"content-around":{"align-content":`space-around`},"content-evenly":{"align-content":`space-evenly`},"content-stretch":{"align-content":`stretch`},"items-baseline":{"align-items":`baseline`},"inset-0":{inset:`0`},"inset-auto":{inset:`auto`},"inset-x-0":{left:`0`,right:`0`},"inset-y-0":{top:`0`,bottom:`0`},"inset-x-auto":{left:`auto`,right:`auto`},"inset-y-auto":{top:`auto`,bottom:`auto`},"sr-only":{position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,"white-space":`nowrap`,"border-width":`0`},"not-sr-only":{position:`static`,width:`auto`,height:`auto`,padding:`0`,margin:`0`,overflow:`visible`,clip:`auto`,"white-space":`normal`}},ue=[`@keyframes spin {
47
17
  from { transform: rotate(0deg) }
48
18
  to { transform: rotate(360deg) }
49
19
  }`,`@keyframes ping {
@@ -54,5 +24,35 @@ let ke=new Set([`==`,`!=`,`<=`,`>=`,`||`,`&&`,`??`,`?.`]),Ae=new Set([`===`,`!==
54
24
  }`,`@keyframes pulse {
55
25
  0%, 100% { opacity: 1 }
56
26
  50% { opacity: .5 }
57
- }`],lt={red:{50:`#ffebee`,100:`#ffcdd2`,200:`#ef9a9a`,300:`#e57373`,400:`#ef5350`,500:`#f44336`,600:`#e53935`,700:`#d32f2f`,800:`#c62828`,900:`#b71c1c`},pink:{50:`#fce4ec`,100:`#f8bbd0`,200:`#f48fb1`,300:`#f06292`,400:`#ec407a`,500:`#e91e63`,600:`#d81b60`,700:`#c2185b`,800:`#ad1457`,900:`#880e4f`},purple:{50:`#f3e5f5`,100:`#e1bee7`,200:`#ce93d8`,300:`#ba68c8`,400:`#ab47bc`,500:`#9c27b0`,600:`#8e24aa`,700:`#7b1fa2`,800:`#6a1b9a`,900:`#4a148c`},"deep-purple":{50:`#ede7f6`,100:`#d1c4e9`,200:`#b39ddb`,300:`#9575cd`,400:`#7e57c2`,500:`#673ab7`,600:`#5e35b1`,700:`#512da8`,800:`#4527a0`,900:`#311b92`},indigo:{50:`#e8eaf6`,100:`#c5cae9`,200:`#9fa8da`,300:`#7986cb`,400:`#5c6bc0`,500:`#3f51b5`,600:`#3949ab`,700:`#303f9f`,800:`#283593`,900:`#1a237e`},blue:{50:`#e3f2fd`,100:`#bbdefb`,200:`#90caf9`,300:`#64b5f6`,400:`#42a5f5`,500:`#2196f3`,600:`#1e88e5`,700:`#1976d2`,800:`#1565c0`,900:`#0d47a1`},"light-blue":{50:`#e1f5fe`,100:`#b3e5fc`,200:`#81d4fa`,300:`#4fc3f7`,400:`#29b6f6`,500:`#03a9f4`,600:`#039be5`,700:`#0288d1`,800:`#0277bd`,900:`#01579b`},cyan:{50:`#e0f7fa`,100:`#b2ebf2`,200:`#80deea`,300:`#4dd0e1`,400:`#26c6da`,500:`#00bcd4`,600:`#00acc1`,700:`#0097a7`,800:`#00838f`,900:`#006064`},teal:{50:`#e0f2f1`,100:`#b2dfdb`,200:`#80cbc4`,300:`#4db6ac`,400:`#26a69a`,500:`#009688`,600:`#00897b`,700:`#00796b`,800:`#00695c`,900:`#004d40`},green:{50:`#e8f5e9`,100:`#c8e6c9`,200:`#a5d6a7`,300:`#81c784`,400:`#66bb6a`,500:`#4caf50`,600:`#43a047`,700:`#388e3c`,800:`#2e7d32`,900:`#1b5e20`},"light-green":{50:`#f1f8e9`,100:`#dcedc8`,200:`#c5e1a5`,300:`#aed581`,400:`#9ccc65`,500:`#8bc34a`,600:`#7cb342`,700:`#689f38`,800:`#558b2f`,900:`#33691e`},lime:{50:`#f9fbe7`,100:`#f0f4c3`,200:`#e6ee9c`,300:`#dce775`,400:`#d4e157`,500:`#cddc39`,600:`#c0ca33`,700:`#afb42b`,800:`#9e9d24`,900:`#827717`},yellow:{50:`#fffde7`,100:`#fff9c4`,200:`#fff59d`,300:`#fff176`,400:`#ffee58`,500:`#ffeb3b`,600:`#fdd835`,700:`#fbc02d`,800:`#f9a825`,900:`#f57f17`},amber:{50:`#fff8e1`,100:`#ffecb3`,200:`#ffe082`,300:`#ffd54f`,400:`#ffca28`,500:`#ffc107`,600:`#ffb300`,700:`#ffa000`,800:`#ff8f00`,900:`#ff6f00`},orange:{50:`#fff3e0`,100:`#ffe0b2`,200:`#ffcc80`,300:`#ffb74d`,400:`#ffa726`,500:`#ff9800`,600:`#fb8c00`,700:`#f57c00`,800:`#ef6c00`,900:`#e65100`},"deep-orange":{50:`#fbe9e7`,100:`#ffccbc`,200:`#ffab91`,300:`#ff8a65`,400:`#ff7043`,500:`#ff5722`,600:`#f4511e`,700:`#e64a19`,800:`#d84315`,900:`#bf360c`},brown:{50:`#efebe9`,100:`#d7ccc8`,200:`#bcaaa4`,300:`#a1887f`,400:`#8d6e63`,500:`#795548`,600:`#6d4c41`,700:`#5d4037`,800:`#4e342e`,900:`#3e2723`},gray:{50:`#fafafa`,100:`#f5f5f5`,200:`#eeeeee`,300:`#e0e0e0`,400:`#bdbdbd`,500:`#9e9e9e`,600:`#757575`,700:`#616161`,800:`#424242`,900:`#212121`},"blue-gray":{50:`#eceff1`,100:`#cfd8dc`,200:`#b0bec5`,300:`#90a4ae`,400:`#78909c`,500:`#607d8b`,600:`#546e7a`,700:`#455a64`,800:`#37474f`,900:`#263238`}};function ut(e){return nt.map(t=>`.${t}\\:${e}:${t}`)}function dt(e,t){return Ze.map(([n,r])=>`@media (min-width: ${r}px) { .${n}\\:${e} { ${t} } }`)}function J(e){return e.flatMap(([e,t])=>[`.${e} { ${t} }`,`${ut(e).join(`,`)} { ${t} }`,...dt(e,t)])}function ft(e){return e.flatMap(([e,t])=>[`.${e} { ${t} }`,`${ut(e).join(`,`)} { ${t} }`])}function pt(e,t){let n=e[0]===`@`,r=t[0]===`@`;return n&&!r?1:!n&&r?-1:e.localeCompare(t)}function Y(e){return J(Object.entries(e).flatMap(([e,t])=>[[`${t}-0`,`${e}: 0`],[`${t}-screen`,`${e}: 100v${e.includes(`height`)?`h`:`w`}`],[`${t}-full`,`${e}: 100%`],...K.map(n=>[`${t}-${n}`,`${e}: ${n*W}rem`]),...K.map(n=>[`-${t}-${n}`,`${e}: -${n*W}rem`]),...K.map(n=>[`${t}-${n}px`,`${e}: ${n}px`]),...K.map(n=>[`-${t}-${n}px`,`${e}: -${n}px`]),...q.map(n=>[`${t}-${n}\\%`,`${e}: ${n}%`]),...q.map(n=>[`-${t}-${n}\\%`,`${e}: -${n}%`]),...Ze.map(([n,r])=>[`${t}-${n}`,`${e}: ${r}px`])]))}function mt(e){return J(Object.entries(e).flatMap(([e,t])=>[[`${t}-auto`,`${e}: auto`],[`${t}x-auto`,`${e}-left: auto; ${e}-right: auto;`],[`${t}y-auto`,`${e}-top: auto; ${e}-bottom: auto;`],[`${t}x-0`,`${e}-left: 0; ${e}-right: 0;`],[`${t}y-0`,`${e}-top: 0; ${e}-bottom: 0;`],...K.map(n=>[`${t}x-${n}`,`${e}-left: ${n*W}rem; ${e}-right: ${n*W}rem;`]),...K.map(n=>[`${t}y-${n}`,`${e}-top: ${n*W}rem; ${e}-bottom: ${n*W}rem;`]),...K.map(n=>[`${t}x-${n}px`,`${e}-left: ${n}px; ${e}-right: ${n}px;`]),...K.map(n=>[`${t}y-${n}px`,`${e}-top: ${n}px; ${e}-bottom: ${n}px;`]),...q.map(n=>[`${t}x-${n}\\%`,`${e}-left: ${n}%; ${e}-right: ${n}%;`]),...q.map(n=>[`${t}y-${n}\\%`,`${e}-top: ${n}%; ${e}-bottom: ${n}%;`])]))}function ht(e){return J(Object.entries(e).flatMap(([e,t])=>[[`${t}t-0`,`${e}-top: 0`],[`${t}b-0`,`${e}-bottom: 0`],[`${t}l-0`,`${e}-left: 0`],[`${t}r-0`,`${e}-right: 0`],[`${t}t-auto`,`${e}-top: auto`],[`${t}b-auto`,`${e}-bottom: auto`],[`${t}l-auto`,`${e}-left: auto`],[`${t}r-auto`,`${e}-right: auto`],...[``,`-`].flatMap(n=>[...K.map(r=>[`${n}${t}t-${r}`,`${e}-top: ${n}${r*W}rem`]),...K.map(r=>[`${n}${t}b-${r}`,`${e}-bottom: ${n}${r*W}rem`]),...K.map(r=>[`${n}${t}l-${r}`,`${e}-left: ${n}${r*W}rem`]),...K.map(r=>[`${n}${t}r-${r}`,`${e}-right: ${n}${r*W}rem`]),...K.map(r=>[`${n}${t}t-${r}px`,`${e}-top: ${n}${r}px`]),...K.map(r=>[`${n}${t}b-${r}px`,`${e}-bottom: ${n}${r}px`]),...K.map(r=>[`${n}${t}l-${r}px`,`${e}-left: ${n}${r}px`]),...K.map(r=>[`${n}${t}r-${r}px`,`${e}-right: ${n}${r}px`]),...q.map(r=>[`${n}${t}t-${r}\\%`,`${e}-top: ${n}${r}%`]),...q.map(r=>[`${n}${t}b-${r}\\%`,`${e}-bottom: ${n}${r}%`]),...q.map(r=>[`${n}${t}l-${r}\\%`,`${e}-left: ${n}${r}%`]),...q.map(r=>[`${n}${t}r-${r}\\%`,`${e}-right: ${n}${r}%`])])]))}function gt(){return J([[`border`,`border: 1px`],[`border-x`,`border-inline-width: 1px`],[`border-y`,`border-block-width: 1px`],...[0,...G].map(e=>[`border-${e}`,`border-width: ${e}px`]),...[0,...G].map(e=>[`border-x-${e}`,`border-inline-width: ${e}px;`]),...[0,...G].map(e=>[`border-y-${e}`,`border-block-width: ${e}px;`]),...[`top`,`bottom`,`left`,`right`].flatMap(e=>[[`border-${e.slice(0,1)}`,`border-${e}: 1px`],...[0,...G].map(t=>[`border-${e.slice(0,1)}-${t}`,`border-${e}-width: ${t}px`])])])}function _t(){return J(q.map(e=>[`z-${e}`,`z-index: ${e}`]))}function vt(){return J(tt.map(e=>[`duration-${e}`,`--transition-duration: ${e}ms; transition-duration: ${e}ms`]))}function yt(){return J([[`space-x-0 > *`,`margin-left: 0`],[`space-y-0 > *`,`margin-top: 0`],...K.map(e=>[`space-x-${e} > :not(:first-child)`,`margin-left: ${e*W}rem`]),...K.map(e=>[`space-y-${e} > :not(:first-child)`,`margin-top: ${e*W}rem`]),...K.map(e=>[`space-x-${e}px > :not(:first-child)`,`margin-left: ${e}px`]),...K.map(e=>[`space-y-${e}px > :not(:first-child)`,`margin-top: ${e}px`]),[`gap-0`,`gap: 0`],...K.map(e=>[`gap-${e}`,`gap: ${e*W}rem`]),...K.map(e=>[`gap-${e}px`,`gap: ${e}px`]),...K.map(e=>[`gap-x-${e}`,`column-gap: ${e*W}rem`]),...K.map(e=>[`gap-y-${e}`,`row-gap: ${e*W}rem`]),...K.map(e=>[`gap-x-${e}px`,`column-gap: ${e}px`]),...K.map(e=>[`gap-y-${e}px`,`row-gap: ${e}px`]),[`divide-x > :not(:last-child)`,`border-inline-end-width: 1px`],[`divide-y > :not(:last-child)`,`border-bottom-width: 1px`],[`divide-x-0 > :not(:last-child)`,`border-inline-end-width: 0px`],[`divide-y-0 > :not(:last-child)`,`border-bottom-width: 0px`],...[2,4,8].map(e=>[`divide-x-${e} > :not(:last-child)`,`border-inline-end-width: ${e}px`]),...[2,4,8].map(e=>[`divide-y-${e} > :not(:last-child)`,`border-bottom-width: ${e}px`]),[`divide-solid > :not(:last-child)`,`border-style: solid`],[`divide-dashed > :not(:last-child)`,`border-style: dashed`],[`divide-dotted > :not(:last-child)`,`border-style: dotted`],[`divide-none > :not(:last-child)`,`border-style: none`]])}function bt(){return J([...Array.from({length:100},(e,t)=>[`text-${t}px`,`font-size: ${t}px`]),...Array.from({length:100},(e,t)=>[`text-${t*W}rem`,`font-size: ${t*W}rem`])])}function xt(){return J([...Array.from({length:12},(e,t)=>t+1).map(e=>[`grid-cols-${e}`,`grid-template-columns: repeat(${e}, minmax(0, 1fr))`]),[`grid-cols-none`,`grid-template-columns: none`],...Array.from({length:12},(e,t)=>t+1).map(e=>[`col-span-${e}`,`grid-column: span ${e} / span ${e}`]),[`col-span-full`,`grid-column: 1 / -1`],...Array.from({length:13},(e,t)=>t+1).map(e=>[`col-start-${e}`,`grid-column-start: ${e}`]),[`col-start-auto`,`grid-column-start: auto`],...Array.from({length:13},(e,t)=>t+1).map(e=>[`col-end-${e}`,`grid-column-end: ${e}`]),[`col-end-auto`,`grid-column-end: auto`]])}function St(){return Object.entries(st).flatMap(([e,t])=>{let n=Object.entries(t).map(([e,t])=>`${e}: ${t}`).join(`; `);return[`.${e} { ${n} }`,`${ut(e).join(`,`)} { ${n} }`,...dt(e,n)]})}function Ct(e){let t=0,n=0,r=0;return e.length===4?(t=parseInt(e[1]+e[1],16),n=parseInt(e[2]+e[2],16),r=parseInt(e[3]+e[3],16)):e.length===7&&(t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16)),`${t} ${n} ${r}`}function wt(){let e=(e,t)=>{let n=[[`text-${e}`,`color: ${t}`],[`fill-${e}`,`fill: ${t}`],[`bg-${e}`,`background-color: ${t}`],[`border-${e}`,`border-color: ${t}`]];if(t.startsWith(`#`)){let r=Ct(t);for(let t of et){let i=t/100;n.push([`text-${e}\\/${t}`,`color: rgb(${r} / ${i})`],[`bg-${e}\\/${t}`,`background-color: rgb(${r} / ${i})`],[`border-${e}\\/${t}`,`border-color: rgb(${r} / ${i})`])}}return n};return ft([...e(`white`,`#fff`),...e(`black`,`#000`),...e(`transparent`,`transparent`),...Object.entries(lt).flatMap(([t,n])=>[...e(t,n[500]),...Object.entries(n).flatMap(([n,r])=>e(`${t}-${n}`,r))])])}function Tt(){return J([[`opacity-0`,`opacity: 0`],...q.map(e=>[`opacity-${e}`,`opacity: ${e/100}`])])}let Et=null;function Dt(){return Et===null&&(Et=[...ct,...St(),...wt(),...Tt(),..._t(),...vt(),...Y(at),...Y(it),...mt(it),...ht(rt),...Y(rt),...mt(rt),...yt(),...Y(ot),...gt(),...bt(),...xt()].sort(pt).join(`
58
- `)),Et}var X=class extends qe{impl=`browser`;dirpath=ue(globalThis.location?.href??`http://localhost/`);parseHTML(e,t={rootDocument:!1}){if(t.rootDocument)return new DOMParser().parseFromString(e,`text/html`);{let t=document.createRange();return t.selectNodeContents(document.body),t.createContextualFragment(e)}}serializeHTML(e){return new XMLSerializer().serializeToString(e).replace(/\s?xmlns="[^"]+"/gm,``)}preprocessLocal(e,t){return this.preprocessRemote(e,t)}createElement(e,t){return(t||document).createElement(e)}createComment(e,t){return(t||document).createComment(e)}textContent(e,t){e.textContent=t}};new X;function Ot(e){for(let t of e){let e=document.createElement(`style`);switch(t){case`minimal`:_(e,Ye());break;case`basic`:_(e,Je());break;case`utils`:e.textContent=Dt();break;default:console.error(`Unknown style name: "${t}"`);continue}globalThis.document.head.appendChild(e)}}let kt=`mancha-cloak`;function At(e,t){let n=`${e.join(`, `)} { opacity: 0 !important; ${t>0?`transition: opacity ${t}ms ease-in-out !important;`:``} }`,r=document.getElementById(kt);r||(r=document.createElement(`style`),r.id=kt,document.head.appendChild(r)),r.textContent=n}function jt(e){let t=!1;return async()=>{if(t)return;t=!0;let n=document.getElementById(kt);if(n){if(e!==!1){let t=n.sheet;t&&t.cssRules.length>0&&t.cssRules[0].style.setProperty(`opacity`,`1`,`important`),await new Promise(t=>setTimeout(t,e))}n.remove()}}}async function Z(e={}){let t;document.documentElement.classList.add(`mancha-loading`);let n=e.cloak?e.cloak===!0?{}:e.cloak:void 0;if(n){let r=e.target?Array.isArray(e.target)?e.target:[e.target]:[`body`],i=n.selector&&(Array.isArray(n.selector)||typeof n.selector==`string`)?Array.isArray(n.selector)?n.selector:[n.selector]:r,a=n.duration??0;At(i,a),t=jt(a>0?a:!1)}else t=jt(!1);document.readyState===`loading`&&await new Promise(e=>{window.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0})});let r=e.renderer??new X;if(e.css&&e.css.length>0&&Ot(e.css),e.debug&&r.debug(!0),e.state)for(let[t,n]of Object.entries(e.state))await r.set(t,n);try{if(e.callback)await e.callback(r);else if(e.target){let t=Array.isArray(e.target)?e.target:[e.target];for(let n of t){let t=globalThis.document.querySelector(n);t?await r.mount(t,{cache:e.cache}):console.error(`Target element not found: "${n}"`)}}}finally{document.documentElement.classList.remove(`mancha-loading`),t&&await t()}return r}let Q=globalThis.document?.currentScript,$=new X;if($.initMancha=Z,globalThis.Mancha=$,Q?.hasAttribute(`init`)){let e=Q.hasAttribute(`debug`),t=Q.getAttribute(`cache`)||void 0,n=Q.getAttribute(`target`)?.split(`+`)||[`body`],r=Q.getAttribute(`css`)?.split(`+`),i,a=Q.getAttribute(`cloak`);if(a===`false`)i=void 0;else if(a&&!Number.isNaN(parseInt(a,10))){let e=parseInt(a,10);i=e>0?{duration:e}:!0}else i=!0;Z({renderer:$,css:r,target:n,debug:e,cache:t,cloak:i})}else if(Q?.hasAttribute(`css`)){let e=Q.getAttribute(`css`)?.split(`+`);Z({css:e})}return $})();
27
+ }`],de={red:{50:`#ffebee`,100:`#ffcdd2`,200:`#ef9a9a`,300:`#e57373`,400:`#ef5350`,500:`#f44336`,600:`#e53935`,700:`#d32f2f`,800:`#c62828`,900:`#b71c1c`},pink:{50:`#fce4ec`,100:`#f8bbd0`,200:`#f48fb1`,300:`#f06292`,400:`#ec407a`,500:`#e91e63`,600:`#d81b60`,700:`#c2185b`,800:`#ad1457`,900:`#880e4f`},purple:{50:`#f3e5f5`,100:`#e1bee7`,200:`#ce93d8`,300:`#ba68c8`,400:`#ab47bc`,500:`#9c27b0`,600:`#8e24aa`,700:`#7b1fa2`,800:`#6a1b9a`,900:`#4a148c`},"deep-purple":{50:`#ede7f6`,100:`#d1c4e9`,200:`#b39ddb`,300:`#9575cd`,400:`#7e57c2`,500:`#673ab7`,600:`#5e35b1`,700:`#512da8`,800:`#4527a0`,900:`#311b92`},indigo:{50:`#e8eaf6`,100:`#c5cae9`,200:`#9fa8da`,300:`#7986cb`,400:`#5c6bc0`,500:`#3f51b5`,600:`#3949ab`,700:`#303f9f`,800:`#283593`,900:`#1a237e`},blue:{50:`#e3f2fd`,100:`#bbdefb`,200:`#90caf9`,300:`#64b5f6`,400:`#42a5f5`,500:`#2196f3`,600:`#1e88e5`,700:`#1976d2`,800:`#1565c0`,900:`#0d47a1`},"light-blue":{50:`#e1f5fe`,100:`#b3e5fc`,200:`#81d4fa`,300:`#4fc3f7`,400:`#29b6f6`,500:`#03a9f4`,600:`#039be5`,700:`#0288d1`,800:`#0277bd`,900:`#01579b`},cyan:{50:`#e0f7fa`,100:`#b2ebf2`,200:`#80deea`,300:`#4dd0e1`,400:`#26c6da`,500:`#00bcd4`,600:`#00acc1`,700:`#0097a7`,800:`#00838f`,900:`#006064`},teal:{50:`#e0f2f1`,100:`#b2dfdb`,200:`#80cbc4`,300:`#4db6ac`,400:`#26a69a`,500:`#009688`,600:`#00897b`,700:`#00796b`,800:`#00695c`,900:`#004d40`},green:{50:`#e8f5e9`,100:`#c8e6c9`,200:`#a5d6a7`,300:`#81c784`,400:`#66bb6a`,500:`#4caf50`,600:`#43a047`,700:`#388e3c`,800:`#2e7d32`,900:`#1b5e20`},"light-green":{50:`#f1f8e9`,100:`#dcedc8`,200:`#c5e1a5`,300:`#aed581`,400:`#9ccc65`,500:`#8bc34a`,600:`#7cb342`,700:`#689f38`,800:`#558b2f`,900:`#33691e`},lime:{50:`#f9fbe7`,100:`#f0f4c3`,200:`#e6ee9c`,300:`#dce775`,400:`#d4e157`,500:`#cddc39`,600:`#c0ca33`,700:`#afb42b`,800:`#9e9d24`,900:`#827717`},yellow:{50:`#fffde7`,100:`#fff9c4`,200:`#fff59d`,300:`#fff176`,400:`#ffee58`,500:`#ffeb3b`,600:`#fdd835`,700:`#fbc02d`,800:`#f9a825`,900:`#f57f17`},amber:{50:`#fff8e1`,100:`#ffecb3`,200:`#ffe082`,300:`#ffd54f`,400:`#ffca28`,500:`#ffc107`,600:`#ffb300`,700:`#ffa000`,800:`#ff8f00`,900:`#ff6f00`},orange:{50:`#fff3e0`,100:`#ffe0b2`,200:`#ffcc80`,300:`#ffb74d`,400:`#ffa726`,500:`#ff9800`,600:`#fb8c00`,700:`#f57c00`,800:`#ef6c00`,900:`#e65100`},"deep-orange":{50:`#fbe9e7`,100:`#ffccbc`,200:`#ffab91`,300:`#ff8a65`,400:`#ff7043`,500:`#ff5722`,600:`#f4511e`,700:`#e64a19`,800:`#d84315`,900:`#bf360c`},brown:{50:`#efebe9`,100:`#d7ccc8`,200:`#bcaaa4`,300:`#a1887f`,400:`#8d6e63`,500:`#795548`,600:`#6d4c41`,700:`#5d4037`,800:`#4e342e`,900:`#3e2723`},gray:{50:`#fafafa`,100:`#f5f5f5`,200:`#eeeeee`,300:`#e0e0e0`,400:`#bdbdbd`,500:`#9e9e9e`,600:`#757575`,700:`#616161`,800:`#424242`,900:`#212121`},"blue-gray":{50:`#eceff1`,100:`#cfd8dc`,200:`#b0bec5`,300:`#90a4ae`,400:`#78909c`,500:`#607d8b`,600:`#546e7a`,700:`#455a64`,800:`#37474f`,900:`#263238`}};function fe(e){return ae.map(t=>`.${t}\\:${e}:${t}`)}function pe(e,t){return ee.map(([n,r])=>`@media (min-width: ${r}px) { .${n}\\:${e} { ${t} } }`)}function w(e){return e.flatMap(([e,t])=>[`.${e} { ${t} }`,`${fe(e).join(`,`)} { ${t} }`,...pe(e,t)])}function me(e){return e.flatMap(([e,t])=>[`.${e} { ${t} }`,`${fe(e).join(`,`)} { ${t} }`])}function he(e,t){let n=e[0]===`@`,r=t[0]===`@`;return n&&!r?1:!n&&r?-1:e.localeCompare(t)}function T(e){return w(Object.entries(e).flatMap(([e,t])=>[[`${t}-0`,`${e}: 0`],[`${t}-screen`,`${e}: 100v${e.includes(`height`)?`h`:`w`}`],[`${t}-full`,`${e}: 100%`],...x.map(n=>[`${t}-${n}`,`${e}: ${n*y}rem`]),...x.map(n=>[`-${t}-${n}`,`${e}: -${n*y}rem`]),...x.map(n=>[`${t}-${n}px`,`${e}: ${n}px`]),...x.map(n=>[`-${t}-${n}px`,`${e}: -${n}px`]),...S.map(n=>[`${t}-${n}\\%`,`${e}: ${n}%`]),...S.map(n=>[`-${t}-${n}\\%`,`${e}: -${n}%`]),...ee.map(([n,r])=>[`${t}-${n}`,`${e}: ${r}px`])]))}function ge(e){return w(Object.entries(e).flatMap(([e,t])=>[[`${t}-auto`,`${e}: auto`],[`${t}x-auto`,`${e}-left: auto; ${e}-right: auto;`],[`${t}y-auto`,`${e}-top: auto; ${e}-bottom: auto;`],[`${t}x-0`,`${e}-left: 0; ${e}-right: 0;`],[`${t}y-0`,`${e}-top: 0; ${e}-bottom: 0;`],...x.map(n=>[`${t}x-${n}`,`${e}-left: ${n*y}rem; ${e}-right: ${n*y}rem;`]),...x.map(n=>[`${t}y-${n}`,`${e}-top: ${n*y}rem; ${e}-bottom: ${n*y}rem;`]),...x.map(n=>[`${t}x-${n}px`,`${e}-left: ${n}px; ${e}-right: ${n}px;`]),...x.map(n=>[`${t}y-${n}px`,`${e}-top: ${n}px; ${e}-bottom: ${n}px;`]),...S.map(n=>[`${t}x-${n}\\%`,`${e}-left: ${n}%; ${e}-right: ${n}%;`]),...S.map(n=>[`${t}y-${n}\\%`,`${e}-top: ${n}%; ${e}-bottom: ${n}%;`])]))}function _e(e){return w(Object.entries(e).flatMap(([e,t])=>[[`${t}t-0`,`${e}-top: 0`],[`${t}b-0`,`${e}-bottom: 0`],[`${t}l-0`,`${e}-left: 0`],[`${t}r-0`,`${e}-right: 0`],[`${t}t-auto`,`${e}-top: auto`],[`${t}b-auto`,`${e}-bottom: auto`],[`${t}l-auto`,`${e}-left: auto`],[`${t}r-auto`,`${e}-right: auto`],...[``,`-`].flatMap(n=>[...x.map(r=>[`${n}${t}t-${r}`,`${e}-top: ${n}${r*y}rem`]),...x.map(r=>[`${n}${t}b-${r}`,`${e}-bottom: ${n}${r*y}rem`]),...x.map(r=>[`${n}${t}l-${r}`,`${e}-left: ${n}${r*y}rem`]),...x.map(r=>[`${n}${t}r-${r}`,`${e}-right: ${n}${r*y}rem`]),...x.map(r=>[`${n}${t}t-${r}px`,`${e}-top: ${n}${r}px`]),...x.map(r=>[`${n}${t}b-${r}px`,`${e}-bottom: ${n}${r}px`]),...x.map(r=>[`${n}${t}l-${r}px`,`${e}-left: ${n}${r}px`]),...x.map(r=>[`${n}${t}r-${r}px`,`${e}-right: ${n}${r}px`]),...S.map(r=>[`${n}${t}t-${r}\\%`,`${e}-top: ${n}${r}%`]),...S.map(r=>[`${n}${t}b-${r}\\%`,`${e}-bottom: ${n}${r}%`]),...S.map(r=>[`${n}${t}l-${r}\\%`,`${e}-left: ${n}${r}%`]),...S.map(r=>[`${n}${t}r-${r}\\%`,`${e}-right: ${n}${r}%`])])]))}function ve(){return w([[`border`,`border: 1px`],[`border-x`,`border-inline-width: 1px`],[`border-y`,`border-block-width: 1px`],...[0,...b].map(e=>[`border-${e}`,`border-width: ${e}px`]),...[0,...b].map(e=>[`border-x-${e}`,`border-inline-width: ${e}px;`]),...[0,...b].map(e=>[`border-y-${e}`,`border-block-width: ${e}px;`]),...[`top`,`bottom`,`left`,`right`].flatMap(e=>[[`border-${e.slice(0,1)}`,`border-${e}: 1px`],...[0,...b].map(t=>[`border-${e.slice(0,1)}-${t}`,`border-${e}-width: ${t}px`])])])}function ye(){return w(S.map(e=>[`z-${e}`,`z-index: ${e}`]))}function be(){return w(ie.map(e=>[`duration-${e}`,`--transition-duration: ${e}ms; transition-duration: ${e}ms`]))}function xe(){return w([[`space-x-0 > *`,`margin-left: 0`],[`space-y-0 > *`,`margin-top: 0`],...x.map(e=>[`space-x-${e} > :not(:first-child)`,`margin-left: ${e*y}rem`]),...x.map(e=>[`space-y-${e} > :not(:first-child)`,`margin-top: ${e*y}rem`]),...x.map(e=>[`space-x-${e}px > :not(:first-child)`,`margin-left: ${e}px`]),...x.map(e=>[`space-y-${e}px > :not(:first-child)`,`margin-top: ${e}px`]),[`gap-0`,`gap: 0`],...x.map(e=>[`gap-${e}`,`gap: ${e*y}rem`]),...x.map(e=>[`gap-${e}px`,`gap: ${e}px`]),...x.map(e=>[`gap-x-${e}`,`column-gap: ${e*y}rem`]),...x.map(e=>[`gap-y-${e}`,`row-gap: ${e*y}rem`]),...x.map(e=>[`gap-x-${e}px`,`column-gap: ${e}px`]),...x.map(e=>[`gap-y-${e}px`,`row-gap: ${e}px`]),[`divide-x > :not(:last-child)`,`border-inline-end-width: 1px`],[`divide-y > :not(:last-child)`,`border-bottom-width: 1px`],[`divide-x-0 > :not(:last-child)`,`border-inline-end-width: 0px`],[`divide-y-0 > :not(:last-child)`,`border-bottom-width: 0px`],...[2,4,8].map(e=>[`divide-x-${e} > :not(:last-child)`,`border-inline-end-width: ${e}px`]),...[2,4,8].map(e=>[`divide-y-${e} > :not(:last-child)`,`border-bottom-width: ${e}px`]),[`divide-solid > :not(:last-child)`,`border-style: solid`],[`divide-dashed > :not(:last-child)`,`border-style: dashed`],[`divide-dotted > :not(:last-child)`,`border-style: dotted`],[`divide-none > :not(:last-child)`,`border-style: none`]])}function Se(){return w([...Array.from({length:100},(e,t)=>[`text-${t}px`,`font-size: ${t}px`]),...Array.from({length:100},(e,t)=>[`text-${t*y}rem`,`font-size: ${t*y}rem`])])}function Ce(){return w([`column`,`row`].flatMap(e=>{let t=e.slice(0,3);return[...Array.from({length:12},(e,t)=>t+1).map(n=>[`grid-${t}s-${n}`,`grid-template-${e}s: repeat(${n}, minmax(0, 1fr))`]),[`grid-${t}s-none`,`grid-template-${e}s: none`],...Array.from({length:12},(e,t)=>t+1).map(n=>[`${t}-span-${n}`,`grid-${e}: span ${n} / span ${n}`]),[`${t}-span-full`,`grid-${e}: 1 / -1`],...Array.from({length:13},(e,t)=>t+1).map(n=>[`${t}-start-${n}`,`grid-${e}-start: ${n}`]),[`${t}-start-auto`,`grid-${e}-start: auto`],...Array.from({length:13},(e,t)=>t+1).map(n=>[`${t}-end-${n}`,`grid-${e}-end: ${n}`]),[`${t}-end-auto`,`grid-${e}-end: auto`]]}))}function we(){return Object.entries(le).flatMap(([e,t])=>{let n=Object.entries(t).map(([e,t])=>`${e}: ${t}`).join(`; `);return[`.${e} { ${n} }`,`${fe(e).join(`,`)} { ${n} }`,...pe(e,n)]})}function Te(e){let t=0,n=0,r=0;return e.length===4?(t=parseInt(e[1]+e[1],16),n=parseInt(e[2]+e[2],16),r=parseInt(e[3]+e[3],16)):e.length===7&&(t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16)),`${t} ${n} ${r}`}function Ee(){let e=(e,t)=>{let n=[[`text-${e}`,`color: ${t}`],[`fill-${e}`,`fill: ${t}`],[`bg-${e}`,`background-color: ${t}`],[`border-${e}`,`border-color: ${t}`]];if(t.startsWith(`#`)){let r=Te(t);for(let t of re){let i=t/100;n.push([`text-${e}\\/${t}`,`color: rgb(${r} / ${i})`],[`bg-${e}\\/${t}`,`background-color: rgb(${r} / ${i})`],[`border-${e}\\/${t}`,`border-color: rgb(${r} / ${i})`])}}return n};return me([...e(`white`,`#fff`),...e(`black`,`#000`),...e(`transparent`,`transparent`),...Object.entries(de).flatMap(([t,n])=>[...e(t,n[500]),...Object.entries(n).flatMap(([n,r])=>e(`${t}-${n}`,r))])])}function De(){return w([[`opacity-0`,`opacity: 0`],...S.map(e=>[`opacity-${e}`,`opacity: ${e/100}`])])}let E=null;function Oe(){return E===null&&(E=[...ue,...we(),...Ee(),...De(),...ye(),...be(),...T(se),...T(oe),...ge(oe),..._e(C),...T(C),...ge(C),...xe(),...T(ce),...ve(),...Se(),...Ce()].sort(he).join(`
28
+ `)),E}let ke={w:`width`,h:`height`,"min-w":`min-width`,"min-h":`min-height`,"max-w":`max-width`,"max-h":`max-height`,m:`margin`,mt:`margin-top`,mr:`margin-right`,mb:`margin-bottom`,ml:`margin-left`,mx:`margin-inline`,my:`margin-block`,p:`padding`,pt:`padding-top`,pr:`padding-right`,pb:`padding-bottom`,pl:`padding-left`,px:`padding-inline`,py:`padding-block`,top:`top`,right:`right`,bottom:`bottom`,left:`left`,gap:`gap`,"gap-x":`column-gap`,"gap-y":`row-gap`,text:`font-size`,z:`z-index`,bg:`background-color`,border:`border-color`},Ae=/^(-?)([\w-]+)-\[(.+)\]$/,je=/^(hover|focus|disabled|sm|md|lg|xl):(.+)$/,Me=[`hover`,`focus`,`disabled`],Ne=new Set,D=null;function Pe(){return typeof document<`u`&&typeof CSSStyleSheet<`u`&&typeof document.createElement==`function`}function Fe(e){return e.replace(/[[\]#.:>+~()'"]/g,`\\$&`)}function Ie(){if(!Pe())return null;if(D)return D;let e=document.createElement(`style`);return e.setAttribute(`data-mancha`,`custom`),document.head.appendChild(e),e.sheet?(D=e.sheet,D):null}function Le(e){let t=e.match(Ae);if(!t)return null;let[,n,r,i]=t,a=ke[r];return a?{property:a,value:n?`-${i}`:i}:null}function Re(e,t){let n=t?`${t.name}:${e}`:e;if(Ne.has(n))return!0;let r=Le(e);if(!r)return!1;let i=Ie();if(!i)return!1;let{property:a,value:o}=r,s=Fe(n),c;c=t?t.type===`pseudo`?`.${s}:${t.name} { ${a}: ${o}; }`:`@media (min-width: ${v[t.name]}px) { .${s} { ${a}: ${o}; } }`:`.${s} { ${a}: ${o}; }`;try{return i.insertRule(c,i.cssRules.length),Ne.add(n),!0}catch(e){return console.warn(`Failed to inject CSS rule: ${c}`,e),!1}}function ze(e){if(!(!e||!e.includes(`[`)))for(let t of e.trim().split(/\s+/)){let e=t.match(je);if(e){let[,t,n]=e,r=Me.includes(t),i=t in v;if(r||i){Re(n,{type:r?`pseudo`:`media`,name:t});continue}}Re(t)}}function Be(e=document){if(!Pe())return;let t=e.querySelectorAll(`[class]`);for(let e of t){let t=e.getAttribute(`class`);t&&ze(t)}}function O(e){return l(e[0].toLowerCase())}function k(e){let t=e[0];return h(t)}function Ve(e){return h(e.map(g).join(``))}function A(e){let t=e.childNodes;for(let e=0;e<t.length;e++){let n=t[e];n.prev=e>0?t[e-1]:null,n.next=e<t.length-1?t[e+1]:null}}let He=[O`:`,O`style`,O`class`];function*j(e,t=new Set){let n=new Set,r=Array.from(e.childNodes).filter(e=>!t.has(e));for(yield e;r.length;){let e=r.shift();n.has(e)||(n.add(e),yield e),e.childNodes&&Array.from(e.childNodes).filter(e=>!t.has(e)).forEach(e=>{r.push(e)})}}function M(e,t){return e?.[t]!==void 0}function N(e,t){return typeof e?.[t]==`function`}function P(e){return e.replace(/-./g,e=>e[1].toUpperCase())}function F(e,t){return e.attribs?e.attribs[t]??null:e.getAttribute?.(t)??null}function Ue(e,t){return e.attribs?t in e.attribs:e.hasAttribute?.(t)??!1}function I(e,t,n=``){return F(e,n+t)||F(e,`data-${t}`)||(e.dataset?.[P(t)]??null)}function L(e,t,n){e.attribs?e.attribs[t]=n:e.setAttribute?.(t,n)}function R(e,t,n){e.attribs?e.attribs[t]=n:f(He,e,t,n)}function z(e,t,n){switch(t){case`disabled`:e.disabled=n;return;case`selected`:e.selected=n;return;case`checked`:e.checked=n;return;default:e[t]=n}}function B(e,t){e.attribs?delete e.attribs[t]:e.removeAttribute?.(t)}function We(e,t,n,r=``){Ue(e,`${r}${t}`)?L(e,`${r}${t}`,n):Ue(e,`data-${t}`)?L(e,`data-${t}`,n):L(e,`${r}${t}`,n)}function V(e,t,n=``){B(e,`${n}${t}`),B(e,`data-${t}`)}function Ge(e,t,n){if(e.attribs&&t.attribs)t.attribs[n]=e.attribs[n];else if(n.startsWith(`data-`)){let r=P(n.slice(5));t.dataset&&e.dataset&&(t.dataset[r]=e.dataset[r])}else{let r=e?.getAttribute?.(n);R(t,n,r||``)}}function Ke(e){return M(e,`firstElementChild`)?e.firstElementChild:Array.from(e.children).find(e=>e.nodeType===1)}function H(e,...t){if(N(e,`replaceWith`)){e.replaceWith(...t);return}else{let n=e,r=n.parentNode;if(!r)return;let i=Array.from(r.childNodes).indexOf(n);n.parentNode=null,t.forEach(e=>{e.parentNode=r}),r.childNodes=[].concat(Array.from(r.childNodes).slice(0,i),t,Array.from(r.childNodes).slice(i+1)),A(r)}}function qe(e,...t){N(e,`replaceChildren`)?e.replaceChildren(...t):(e.childNodes=t,t.forEach(t=>{t.parentNode=e}),A(e))}function Je(e,t){return N(t,`appendChild`)?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,A(e),t)}function U(e,t){return N(t,`removeChild`)?e.removeChild(t):(qe(e,...Array.from(e.childNodes).filter(e=>e!==t)),t)}function W(e,t,n){return n?N(e,`insertBefore`)?e.insertBefore(t,n):(t.parentNode&&U(t.parentNode,t),H(n,t,n),t):Je(e,t)}function Ye(e,t=0){return e?e.length<=t?e:`${e.slice(0,t-1)}…`:``}function G(e,t=0){return globalThis.DocumentFragment&&e instanceof DocumentFragment?Array.from(e.childNodes).map(e=>G(e,t)).join(``):Ye(e.outerHTML||e.nodeValue||String(e),t)}function Xe(e){return e.includes(`/`)?e.split(`/`).slice(0,-1).join(`/`):``}function Ze(e){return!e.includes(`://`)&&!e.startsWith(`/`)&&!e.startsWith(`#`)&&!e.startsWith(`data:`)}var Qe=class e{iterable;constructor(e){this.iterable=e}filter(t){return new e(e.filterGenerator(t,this.iterable))}map(t){return new e(e.mapGenerator(t,this.iterable))}find(e){for(let t of this.iterable)if(e(t))return t}array(){return Array.from(this.iterable)}*generator(){for(let e of this.iterable)yield e}static*filterGenerator(e,t){for(let n of t)e(n)&&(yield n)}static*mapGenerator(e,t){for(let n of t)yield e(n)}static equals(e,t){let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(i.value!==a.value)return!1;i=n.next(),a=r.next()}return i.done===a.done}};let K;(function(e){e.resolveIncludes=async function(e,t){let n=e,r=n.tagName?.toLowerCase();if(![`include`,`link`].includes(r)||r===`link`&&F(n,`rel`)!==`subresource`)return;this.log(`include directive found in:
29
+ `,G(e,128)),this.log(`include params:`,t);let i=n.tagName.toLocaleLowerCase()===`link`?`href`:`src`,a=F(n,i);if(!a)throw Error(`"${i}" attribute missing from ${G(e,128)}.`);let o=[];r===`include`&&o.push(`src`),r===`link`&&o.push(`rel`,`href`);let s=t=>{let r=Ke(t);for(let e of Array.from(n.attributes))r&&!o.includes(e.name)&&Ge(n,r,e.name);H(e,...t.childNodes)},c={...t,rootDocument:!1,maxdepth:(t?.maxdepth??100)-1};if(c.maxdepth===0)throw Error(`Maximum recursion depth reached.`);if(a.includes(`://`)||a.startsWith(`//`))this.log(`Including remote file from absolute path:`,a),await this.preprocessRemote(a,c).then(s);else if(t?.dirpath?.includes(`://`)||t?.dirpath?.startsWith(`//`)){let e=a.startsWith(`/`)?a:`${t.dirpath}/${a}`;this.log(`Including remote file from relative path:`,e),await this.preprocessRemote(e,c).then(s)}else if(a.charAt(0)===`/`)this.log(`Including local file from absolute path:`,a),await this.preprocessLocal(a,c).then(s);else{let e=t?.dirpath&&t?.dirpath!==`.`?`${t?.dirpath}/${a}`:a;this.log(`Including local file from relative path:`,e),await this.preprocessLocal(e,c).then(s)}},e.rebaseRelativePaths=function(e,t){let n=e,r=n.tagName?.toLowerCase();if(!t?.dirpath)return;let o=F(n,`src`),s=F(n,`href`),c=I(n,`render`,`:`),l=o||s||c;if(!l||!Ze(l))return;let u=`${t.dirpath}/${l}`;this.log(`Rebasing relative path as:`,u),c?We(n,`render`,u,`:`):M(n,`attribs`)?R(n,o?`src`:`href`,u):r===`img`?n.src=u:r===`a`?i(n,u):r===`source`||r===`audio`||r===`video`||r===`track`||r===`input`?n.src=u:r===`area`?a(n,u):this.log(`Unable to rebase relative path for element:`,r)},e.registerCustomElements=function(e,t){let n=e,r=n.tagName?.toLowerCase(),i=(F(n,`is`)||F(n,`alt`))?.toLowerCase();if([`template`,`div`].includes(r)&&i){if(r===`div`&&F(n,`role`)!==`template`)return;if(!this._customElements.has(i)){this.log(`Registering custom element: ${i}\n`,G(n,128));let e=n.content||n,r=Array.from(j(e));for(let e=1;e<r.length;e++)K.rebaseRelativePaths.call(this,r[e],t);this._customElements.set(i,n),n?.parentNode&&U(n.parentNode,n)}}},e.resolveCustomElements=function(e,t){let n=e,r=n.tagName?.toLowerCase(),i=r;if(i===`div`&&(i=F(n,`role`)?.toLowerCase()||i),i&&this._customElements.has(i)){this.log(`Processing custom element: ${i}\n`,G(n,128));let t=this._customElements.get(i),a=(t.content||t).cloneNode(!0),o=Ke(a);if(o)for(let e of Array.from(n.attributes))(r!==`div`||e.name!==`role`)&&Ge(n,o,e.name);let s=new Qe(j(a)).find(e=>e.tagName?.toLowerCase()===`slot`);s&&H(s,...n.childNodes),H(e,...a.childNodes)}},e.resolveTextNodeExpressions=function(e,t){let n=e.nodeValue||``;if(e.nodeType!==3||!n?.trim())return;this.log(`Processing node content value:
30
+ `,Ye(n,128));let r=new RegExp(/{{ ([^}]+) }}/gm),i=Array.from(n.matchAll(r)).map(e=>e[1]);return this.effect(function(){let t=n;for(let n of i){let r=this.eval(n,{$elem:e});t=t.replace(`{{ ${n} }}`,r==null?``:String(r))}e.nodeValue=t},{directive:`text`,element:e.parentElement??void 0,expression:i.join(`, `)})},e.resolveDataAttribute=async function(e,t){if(this._skipNodes.has(e))return;let n=e,r=I(n,`data`,`:`);if(r){this.log(`:data attribute found in:
31
+ `,G(e,128)),V(n,`data`,`:`);let i;M(e,`renderer`)?(i=e.renderer,this.log(`Reusing existing subrenderer for node:`,G(e,64))):(i=this.subrenderer(),z(e,`renderer`,i),this.log(`Created and attached new subrenderer for node:`,G(e,64)));let a=i.eval(r,{$elem:e});if(await Promise.all(Object.entries(a).map(([e,t])=>e.startsWith(`$$`)?(i._store.get(`$rootRenderer`)||i).set(e,t):i.set(e,t,!0))),i===this)return;for(let t of j(e,this._skipNodes))this._skipNodes.add(t);await i.mount(e,t)}},e.resolveClassAttribute=function(e,t){if(this._skipNodes.has(e))return;let n=e,r=I(n,`class`,`:`);if(r){this.log(`:class attribute found in:
32
+ `,G(e,128)),V(n,`class`,`:`);let t=F(n,`class`)||``;return this.effect(function(){let i=this.eval(r,{$elem:e});R(n,`class`,(i?`${t} ${i}`:t).trim())},{directive:`class`,element:n,expression:r})}},e.resolveTextAttributes=function(e,t){if(this._skipNodes.has(e))return;let n=e,r=I(n,`text`,`:`);if(r){this.log(`:text attribute found in:
33
+ `,G(e,128)),V(n,`text`,`:`);let t=t=>this.textContent(e,t);return this.effect(function(){let n=this.eval(r,{$elem:e});t(n==null?``:String(n))},{directive:`:text`,element:n,expression:r})}},e.resolveHtmlAttribute=async function(e,t){if(this._skipNodes.has(e))return;let n=e,r=I(n,`html`,`:`);if(r){this.log(`:html attribute found in:
34
+ `,G(e,128)),V(n,`html`,`:`);let i=null;return this.effect(function(){let a=this.eval(r,{$elem:e});return new Promise(e=>{(async()=>{i&&=(i.dispose(),null);let r=this.subrenderer();i=r;let o=await r.preprocessString(a,t);await r.renderNode(o),qe(n,o),r._store.set(`$rootNode`,n),e()})()})},{directive:`:html`,element:n,expression:r})}},e.resolveEventAttributes=function(e,t){if(this._skipNodes.has(e))return;let n=e;for(let t of Array.from(n.attributes||[]))if(t.name.startsWith(`:on:`)||t.name.startsWith(`data-on-`)){let r=``,i=[];if(t.name.startsWith(`:on:`)?[r,...i]=t.name.substring(4).split(`.`):t.name.startsWith(`data-on-`)&&([r,...i]=t.name.substring(8).split(`.`)),!r)throw Error(`Invalid event attribute: ${t.name}`);this.log(t.name,`attribute found in:
35
+ `,G(e,128)),V(n,t.name);let a=r===`submit`&&n.tagName.toUpperCase()===`FORM`;e.addEventListener?.(r,n=>((i.includes(`prevent`)||a)&&n.preventDefault(),this.eval(t.value,{$elem:e,$event:n})))}},e.resolveForAttribute=async function(e,t){if(this._skipNodes.has(e))return;let n=e,r=I(n,`for`,`:`)?.trim();if(r){this.log(`:for attribute found in:
36
+ `,G(e,128)),V(n,`for`,`:`);let i=I(n,`key`,`:`);i&&V(n,`key`,`:`);for(let t of j(e,this._skipNodes))this._skipNodes.add(t);let a=F(n,`style`)||``;L(n,`style`,`display: none;`);let o=e.parentNode;if(!o)return;let s=this.createElement(`template`,e.ownerDocument);W(o,s,e),U(o,e),`content`in s?Je(s.content,e):Je(s,e),this.log(`:for template:
37
+ `,G(s,128));let c=r.split(` in `,2);if(c.length!==2)throw Error(`Invalid :for format: \`${r}\`. Expected "{key} in {expression}".`);let l=i?I(n,`data`,`:`):null,u=new Map,d=[],f=[],[p,m]=c;await this.effect(function(){let n=this.eval(m,{$elem:e});if(this.log(`:for list items:`,n),!Array.isArray(n)){console.error(`Expression did not yield a list: \`${m}\` => \`${n}\``);return}if(i){let r=new Set,c=new Map,d=[],f=s.nextSibling;for(let s=0;s<n.length;s++){let m=n[s],h=this.eval(i,{[p]:m,$index:s});r.has(h)&&console.warn(`:for duplicate key detected: ${h}. Using last item.`),r.add(h);let g,_,v=u.get(h);if(v){if(g=v.node,_=v.subrenderer,d.push(_.set(p,m,!0)),d.push(_.set(`$index`,s,!0)),l&&M(g,`renderer`)){let e=g.renderer,t=e.eval(l,{$elem:g});d.push(...Object.entries(t).map(([t,n])=>e.set(t,n,!0)))}g===f||g.nextSibling===f||W(o,g,f)}else{_=this.subrenderer(),_.set(p,m,!0),_.set(`$index`,s,!0);let n=e.cloneNode(!0);W(o,n,f),this._skipNodes.add(n),d.push(_.mount(n,t).then(()=>{L(n,`style`,a)})),g=n,this.log(`Rendered list child:
38
+ `,G(n,128))}c.set(h,{node:g,subrenderer:_}),f=g.nextSibling}for(let[e,{node:t,subrenderer:n}]of u)r.has(e)||(n.dispose(),t.parentNode&&U(t.parentNode,t),this._skipNodes.delete(t));u.clear();for(let[e,t]of c)u.set(e,t);return Promise.all(d).then(()=>{})}else{f.splice(0,f.length).forEach(e=>{e.dispose()}),d.splice(0,d.length).forEach(e=>{e.parentNode&&U(e.parentNode,e),this._skipNodes.delete(e)});let r=s.nextSibling,i=[];for(let s=0;s<n.length;s++){let c=n[s],l=this.subrenderer();l.set(p,c,!0),l.set(`$index`,s,!0);let u=e.cloneNode(!0);W(o,u,r),d.push(u),f.push(l),this._skipNodes.add(u),i.push(l.mount(u,t).then(()=>{L(u,`style`,a)})),this.log(`Rendered list child:
39
+ `,G(u,128))}return Promise.all(i).then(()=>{})}},{directive:`:for`,element:n,expression:r})}},e.resolveBindAttribute=function(e,t){if(this._skipNodes.has(e))return;let n=e,r=I(n,`bind`,`:`);if(r){this.log(`:bind attribute found in:
40
+ `,G(e,128));let t=F(n,`:bind:on`)?.split(`,`)||n.dataset?.bindOn?.split(`,`)||[`change`,`input`];V(n,`bind`,`:`),B(n,`:bind:on`),B(n,`data-bind-on`);let i=F(n,`type`)===`checkbox`?`checked`:`value`;!r.includes(`.`)&&!this.has(r)&&this.set(r,``);let a=this;this.effect(function(){let t=this.eval(r,{$elem:e});i===`checked`?n.checked=!!t:(n.value=t,n.value!==t&&t!=null&&a._pendingValueRetries.push(()=>{n.value=t}))},{directive:`:bind`,element:n,expression:r});let o=`${r} = $elem.${i}`;for(let n of t)e.addEventListener(n,()=>this.eval(o,{$elem:e}))}},e.resolveIfAttribute=function(e,t){if(this._skipNodes.has(e))return;let n=e,r=I(n,`if`,`:`);if(r){this.log(`:if attribute found in:
41
+ `,G(e,128)),V(n,`if`,`:`);let t=this.createComment(` :if placeholder `,e.ownerDocument);this.effect(function(){this.eval(r,{$elem:e})?!n.parentNode&&t.parentNode&&H(t,n):n.parentNode&&H(n,t)},{directive:`:if`,element:n,expression:r})}},e.resolveShowAttribute=function(e,t){if(this._skipNodes.has(e))return;let n=e,r=I(n,`show`,`:`);if(r){this.log(`:show attribute found in:
42
+ `,G(e,128)),V(n,`show`,`:`);let t=n.style?.display===`none`?``:n.style?.display??F(n,`style`)?.split(`;`)?.find(e=>e.split(`:`)[0]===`display`)?.split(`:`)?.at(1)?.trim();this.effect(function(){let i=this.eval(r,{$elem:e});n.style?n.style.display=i?t:`none`:R(n,`style`,`display: ${i?t:`none`};`)},{directive:`:show`,element:n,expression:r})}},e.resolveCustomAttribute=function(e,t){if(this._skipNodes.has(e))return;let n=e;for(let t of Array.from(n.attributes||[])){let r=`:attr:`,i=`data-attr-`;if(t.name.startsWith(r)||t.name.startsWith(i)){this.log(t.name,`attribute found in:
43
+ `,G(e,128)),B(n,t.name);let a=(t.name.split(r,2).at(-1)||``).split(i,2).at(-1)??``;this.effect(function(){L(n,a,this.eval(t.value,{$elem:e}))},{directive:`:attr:${a}`,element:n,expression:t.value})}}},e.resolveCustomProperty=function(e,t){if(this._skipNodes.has(e))return;let n=e;for(let t of Array.from(n.attributes||[])){let r=`:prop:`,i=`data-prop-`;if(t.name.startsWith(r)||t.name.startsWith(i)){this.log(t.name,`property found in:
44
+ `,G(e,128)),B(n,t.name);let a=P((t.name.split(r,2).at(-1)||``).split(i,2).at(-1)??``);this.effect(function(){z(n,a,this.eval(t.value,{$elem:e}))},{directive:`:prop:${a}`,element:n,expression:t.value})}}},e.stripTypes=(e,t)=>{let n=e;F(n,`:types`)&&B(n,`:types`),F(n,`data-types`)&&B(n,`data-types`)},e.resolveRenderAttribute=async function(e,t){if(this._skipNodes.has(e))return;let n=e,r=I(n,`render`,`:`);if(!r)return;this.log(`:render attribute found: ${r}`),V(n,`render`,`:`);let i;M(e,`renderer`)?(i=e.renderer,this.log(`Reusing existing subrenderer for :render:`,G(e,64))):(i=this.subrenderer(),z(n,`renderer`,i)),await i.mount(e,t);for(let t of j(e,this._skipNodes))this._skipNodes.add(t);try{let e=await import(r);typeof e.default==`function`?await e.default(n,i):e.default!==void 0&&console.warn(`Module ${r} default export is not a function`)}catch(e){console.error(`Failed to execute render init from ${r}:`,e)}}})(K||={});function $e(){return new URL(globalThis.window?.location?.href||`http://localhost/`)}function et(e){return e.substring(2)}function tt(e){return`\$\$${e}`}function nt(e){return e.keys().filter(e=>e.startsWith(`$$`))}async function rt(e,t){for(let[n,r]of t.searchParams.entries()){let t=tt(n);e.get(t)!==r&&await e.set(t,r)}}function it(e,t,n){let r=et(t),i=!1;if(!n)e.searchParams.has(r)&&(e.searchParams.delete(r),i=!0);else{let t=String(n);e.searchParams.get(r)!==t&&(e.searchParams.set(r,t),i=!0)}return i}function at(e,t){let n=!1;for(let r of nt(t))it(e,r,t.get(r))&&(n=!0);n&&globalThis.window?.history?.replaceState({},``,e.toString())}function ot(e){return async()=>{let t=$e(),n=new Set;for(let[r,i]of t.searchParams.entries()){let t=tt(r);n.add(t),e.get(t)!==i&&e.set(t,i)}let r=nt(e);for(let t of r)n.has(t)||e.del(t)}}async function st(e){let t=$e();await rt(e,t),at(t,e),e.addKeyHandler(/^\$\$/,(e,t)=>{let n=$e();it(n,e,t)&&globalThis.window?.history?.replaceState({},``,n.toString())}),globalThis.window?.addEventListener(`popstate`,ot(e))}
45
+ /*
46
+ * @license
47
+ * Portions Copyright (c) 2013, the Dart project authors.
48
+ */
49
+ let ct=new Set([`this`,`typeof`]),lt=new Set([`in`]),ut=new Set([`+`,`-`,`!`,`typeof`]),dt=new Set([`=`,`+`,`-`,`*`,`/`,`%`,`^`,`==`,`!=`,`>`,`<`,`>=`,`<=`,`||`,`&&`,`??`,`&`,`===`,`!==`,`|`,`in`]),ft={"!":0,":":0,",":0,")":0,"]":0,"}":0,"?":2,"??":3,"||":4,"&&":5,"|":6,"^":7,"&":8,"!=":9,"==":9,"!==":9,"===":9,">=":10,">":10,"<=":10,"<":10,in:10,"+":11,"-":11,"%":12,"/":12,"*":12,"(":13,"[":13,".":13,"?.":13,"{":13},pt={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,"==":(e,t)=>e==t,"!=":(e,t)=>e!=t,"===":(e,t)=>e===t,"!==":(e,t)=>e!==t,">":(e,t)=>e>t,">=":(e,t)=>e>=t,"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,"||":(e,t)=>e||t,"&&":(e,t)=>e&&t,"??":(e,t)=>e??t,"|":(e,t)=>t(e),in:(e,t)=>e in t},mt={"+":e=>e,"-":e=>-e,"!":e=>!e,typeof:e=>typeof e};var ht=class{empty(){return{type:`Empty`,evaluate(e){return e},getIds(e){return e}}}literal(e){return{type:`Literal`,value:e,evaluate(e){return this.value},getIds(e){return e}}}id(e){return{type:`ID`,value:e,evaluate(e){return this.value===`this`?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(e,t){let n=mt[e];return{type:`Unary`,operator:e,child:t,evaluate(e){return n(this.child.evaluate(e))},getIds(e){return this.child.getIds(e)}}}binary(e,t,n){let r=pt[t];return{type:`Binary`,operator:t,left:e,right:n,evaluate(e){if(this.operator===`=`){if(this.left.type!==`ID`&&this.left.type!==`Getter`&&this.left.type!==`Index`)throw Error(`Invalid assignment target: ${this.left}`);let t=this.right.evaluate(e),n,r;return this.left.type===`Getter`?(n=this.left.receiver.evaluate(e),r=this.left.name):this.left.type===`Index`?(n=this.left.receiver.evaluate(e),r=String(this.left.argument.evaluate(e))):this.left.type===`ID`&&(n=e,r=this.left.value),n===void 0?void 0:(n[r]=t,t)}return r(this.left.evaluate(e),this.right.evaluate(e))},getIds(e){return this.left.getIds(e),this.right.getIds(e),e}}}getter(e,t,n){return{type:`Getter`,receiver:e,name:t,optional:n,evaluate(e){let t=this.receiver.evaluate(e);if(!(this.optional&&t==null))return t?.[this.name]},getIds(e){return this.receiver.getIds(e),e}}}invoke(e,t,n,r){if(t!=null&&typeof t!=`string`)throw Error(`method not a string`);return{type:`Invoke`,receiver:e,method:t,arguments:n,optional:r,evaluate(e){let t=this.receiver.evaluate(e);if(this.optional&&t==null)return;let n=this.method?t:e?.this??e,r=this.method?t?.[this.method]:t,i=this.arguments??[],a=[];for(let t of i)if(t?.type===`SpreadElement`){let n=t.evaluate(e);n&&typeof n[Symbol.iterator]==`function`&&a.push(...n)}else a.push(t?.evaluate(e));return r?.apply?.(n,a)},getIds(e){return this.receiver.getIds(e),this.arguments?.forEach(t=>{t?.getIds(e)}),e}}}paren(e){return e}index(e,t,n){return{type:`Index`,receiver:e,argument:t,optional:n,evaluate(e){let t=this.receiver.evaluate(e);if(this.optional&&t==null)return;let n=this.argument.evaluate(e);return t?.[n]},getIds(e){return this.receiver.getIds(e),e}}}ternary(e,t,n){return{type:`Ternary`,condition:e,trueExpr:t,falseExpr:n,evaluate(e){return this.condition.evaluate(e)?this.trueExpr.evaluate(e):this.falseExpr.evaluate(e)},getIds(e){return this.condition.getIds(e),this.trueExpr.getIds(e),this.falseExpr.getIds(e),e}}}map(e){return{type:`Map`,properties:e,evaluate(t){let n={};if(e&&this.properties)for(let e of this.properties)e.type===`SpreadProperty`?Object.assign(n,e.evaluate(t)):n[e.key]=e.value.evaluate(t);return n},getIds(t){if(e&&this.properties)for(let e of this.properties)e.type===`SpreadProperty`?e.expression.getIds(t):e.value.getIds(t);return t}}}property(e,t){return{type:`Property`,key:e,value:t,evaluate(e){return this.value.evaluate(e)},getIds(e){return this.value.getIds(e)}}}list(e){return{type:`List`,items:e,evaluate(e){if(!this.items)return[];let t=[];for(let n of this.items)if(n?.type===`SpreadElement`){let r=n.evaluate(e);r&&typeof r[Symbol.iterator]==`function`&&t.push(...r)}else t.push(n?.evaluate(e));return t},getIds(e){return this.items?.forEach(t=>{t?.getIds(e)}),e}}}arrowFunction(e,t){return{type:`ArrowFunction`,params:e,body:t,evaluate(e){let t=this.params,n=this.body;return function(...r){let i=Object.fromEntries(t.map((e,t)=>[e,r[t]])),a=this??e??{},o=new Proxy(a,{set(e,t,n){return Object.hasOwn(i,t)&&(i[t]=n),e[t]=n,n},get(e,t){return Object.hasOwn(i,t)?i[t]:e[t]}});return n.evaluate(o)}},getIds(e){return this.body.getIds(e).filter(e=>!this.params.includes(e))}}}spreadProperty(e){return{type:`SpreadProperty`,expression:e,evaluate(e){return this.expression.evaluate(e)},getIds(e){return this.expression.getIds(e)}}}spreadElement(e){return{type:`SpreadElement`,expression:e,evaluate(e){return this.expression.evaluate(e)},getIds(e){return this.expression.getIds(e)}}}};
50
+ /*
51
+ * @license
52
+ * Portions Copyright (c) 2013, the Dart project authors.
53
+ */
54
+ let gt=new Set([`==`,`!=`,`<=`,`>=`,`||`,`&&`,`??`,`?.`]),_t=new Set([`===`,`!==`]),q=function(e){return e[e.STRING=1]=`STRING`,e[e.IDENTIFIER=2]=`IDENTIFIER`,e[e.DOT=3]=`DOT`,e[e.COMMA=4]=`COMMA`,e[e.COLON=5]=`COLON`,e[e.INTEGER=6]=`INTEGER`,e[e.DECIMAL=7]=`DECIMAL`,e[e.OPERATOR=8]=`OPERATOR`,e[e.GROUPER=9]=`GROUPER`,e[e.KEYWORD=10]=`KEYWORD`,e[e.ARROW=11]=`ARROW`,e[e.OPTIONAL_DOT=12]=`OPTIONAL_DOT`,e[e.SPREAD=13]=`SPREAD`,e}({}),J=(e,t,n=0)=>({kind:e,value:t,precedence:n}),vt=e=>e===9||e===10||e===13||e===32,yt=e=>{if(e===95||e===36)return!0;let t=e&-33;return 65<=t&&t<=90},bt=e=>yt(e)||Y(e),xt=e=>ct.has(e),St=e=>e===34||e===39,Y=e=>48<=e&&e<=57,Ct=e=>e===43||e===45||e===42||e===47||e===33||e===38||e===37||e===60||e===61||e===62||e===63||e===94||e===124,wt=e=>e===40||e===41||e===91||e===93||e===123||e===125,Tt=e=>e.replace(/\\(.)/g,(e,t)=>{switch(t){case`n`:return`
55
+ `;case`r`:return`\r`;case`t`:return` `;case`b`:return`\b`;case`f`:return`\f`;default:return t}});var Et=class{_input;_index=-1;_tokenStart=0;_next;constructor(e){this._input=e,this._advance()}nextToken(){for(;vt(this._next??-1);)this._advance(!0);if(St(this._next??-1))return this._tokenizeString();if(yt(this._next??-1))return this._tokenizeIdentOrKeyword();if(Y(this._next??-1))return this._tokenizeNumber();if(this._next===46)return this._tokenizeDot();if(this._next===44)return this._tokenizeComma();if(this._next===58)return this._tokenizeColon();if(Ct(this._next??-1))return this._tokenizeOperator();if(wt(this._next??-1))return this._tokenizeGrouper();if(this._advance(),this._next!==void 0)throw Error(`Expected end of input, got ${this._next}`)}_advance(e){this._index++,this._index<this._input.length?(this._next=this._input.charCodeAt(this._index),e===!0&&(this._tokenStart=this._index)):this._next=void 0}_getValue(e=0){let t=this._input.substring(this._tokenStart,this._index+e);return e===0&&this._clearValue(),t}_clearValue(){this._tokenStart=this._index}_tokenizeString(){let e=this._next;for(this._advance(!0);this._next!==e;){if(this._next===void 0||this._next===92&&(this._advance(),this._next===void 0))throw Error(`unterminated string`);this._advance()}let t=J(q.STRING,Tt(this._getValue()));return this._advance(),t}_tokenizeIdentOrKeyword(){do this._advance();while(bt(this._next??-1));let e=this._getValue();return J(xt(e)?q.KEYWORD:lt.has(e)?q.OPERATOR:q.IDENTIFIER,e,ft[e]??0)}_tokenizeNumber(){do this._advance();while(Y(this._next??-1));return this._next===46?this._tokenizeDot():J(q.INTEGER,this._getValue())}_tokenizeDot(){if(this._advance(),Y(this._next??-1))return this._tokenizeFraction();if(this._next===46){if(this._advance(),this._next===46)return this._advance(),this._clearValue(),J(q.SPREAD,`...`);throw Error(`Unexpected token ..`)}return this._clearValue(),J(q.DOT,`.`,13)}_tokenizeComma(){return this._advance(!0),J(q.COMMA,`,`)}_tokenizeColon(){return this._advance(!0),J(q.COLON,`:`)}_tokenizeFraction(){do this._advance();while(Y(this._next??-1));return J(q.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(_t.has(e))this._advance(),this._advance();else{if(e=this._getValue(1),e===`=>`)return this._advance(),J(q.ARROW,e);gt.has(e)&&this._advance()}return e=this._getValue(),e===`?.`?J(q.OPTIONAL_DOT,e,13):J(q.OPERATOR,e,ft[e])}_tokenizeGrouper(){let e=String.fromCharCode(this._next??0),t=J(q.GROUPER,e,ft[e]);return this._advance(!0),t}};let Dt=(e,t)=>new Ot(e,t).parse();var Ot=class{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new Et(e),this._ast=t}parse(){this._advance();let e=this._parseExpression();if(this._token)throw Error(`Unexpected token: ${this._token.value}`);return e}_advance(e,t){if(!this._matches(e,t))throw Error(`Expected kind ${e} (${t}), was ${this._token?.kind} (${this._token?.value})`);let n=this._tokenizer.nextToken();this._token=n,this._kind=n?.kind,this._value=n?.value}_matches(e,t){return!(e&&this._kind!==e||t&&this._value!==t)}_parseExpression(){if(!this._token)return this._ast.empty();let e=this._parseUnary();return e===void 0?void 0:this._parsePrecedence(e,0)}_parsePrecedence(e,t){if(e===void 0)throw Error(`Expected left to be defined.`);for(;this._token;)if(this._matches(q.GROUPER,`(`)){let t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(q.GROUPER,`[`)){let t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(q.DOT)||this._matches(q.OPTIONAL_DOT)){let t=this._kind===q.OPTIONAL_DOT;if(this._advance(),t&&this._matches(q.GROUPER,`[`)){let t=this._parseIndex();e=this._ast.index(e,t,!0)}else if(t&&this._matches(q.GROUPER,`(`)){let t=this._parseArguments();e=this._ast.invoke(e,void 0,t,!0)}else{let n=this._parseUnary();e=this._makeInvokeOrGetter(e,n,t)}}else if(this._matches(q.KEYWORD))break;else if(this._matches(q.OPERATOR)&&this._token.precedence>=t)e=this._value===`?`?this._parseTernary(e):this._parseBinary(e,this._token);else break;return e}_makeInvokeOrGetter(e,t,n){if(t===void 0)throw Error(`expected identifier`);if(t.type===`ID`)return this._ast.getter(e,t.value,n);if(t.type===`Invoke`&&t.receiver.type===`ID`){let r=t.receiver;return this._ast.invoke(e,r.value,t.arguments,n)}else throw Error(`expected identifier: ${t}`)}_parseBinary(e,t){if(!dt.has(t.value))throw Error(`unknown operator: ${t.value}`);this._advance();let n=this._parseUnary();for(;(this._kind===q.OPERATOR||this._kind===q.DOT||this._kind===q.GROUPER)&&this._token&&(this._token.precedence??0)>t.precedence;)n=this._parsePrecedence(n,this._token?.precedence??0);if(n===void 0)throw Error(`Expected expression after ${t.value}`);return this._ast.binary(e,t.value,n)}_parseUnary(){if(this._matches(q.KEYWORD,`typeof`)){this._advance();let e=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(`typeof`,e)}if(this._matches(q.OPERATOR)){let e=this._value;if(this._advance(),e===`+`||e===`-`){if(this._matches(q.INTEGER))return this._parseInteger(e);if(this._matches(q.DECIMAL))return this._parseDecimal(e)}if(!e||!ut.has(e))throw Error(`unexpected token: ${e}`);let t=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(e,t)}return this._parsePrimary()}_parseTernary(e){this._advance(q.OPERATOR,`?`);let t=this._parseExpression();this._advance(q.COLON);let n=this._parseExpression();return this._ast.ternary(e,t,n)}_parsePrimary(){switch(this._kind){case q.KEYWORD:{let e=this._value??``;if(e===`this`)return this._advance(),this._ast.id(e);throw ct.has(e)?Error(`unexpected keyword: ${e}`):Error(`unrecognized keyword: ${e}`)}case q.IDENTIFIER:return this._parseInvokeOrIdentifier();case q.STRING:return this._parseString();case q.INTEGER:return this._parseInteger();case q.DECIMAL:return this._parseDecimal();case q.GROUPER:return this._value===`(`?this._parseParenOrFunction():this._value===`{`?this._parseMap():this._value===`[`?this._parseList():void 0;case q.COLON:throw Error(`unexpected token ":"`);default:return}}_parseList(){let e=[];do{if(this._advance(),this._matches(q.GROUPER,`]`))break;if(this._matches(q.SPREAD)){this._advance();let t=this._parseExpression();t&&e.push(this._ast.spreadElement(t))}else e.push(this._parseExpression())}while(this._matches(q.COMMA));return this._advance(q.GROUPER,`]`),this._ast.list(e)}_parseMap(){let e=[];do{if(this._advance(),this._matches(q.GROUPER,`}`))break;if(this._matches(q.SPREAD)){this._advance();let t=this._parseExpression();t&&e.push(this._ast.spreadProperty(t))}else{let t=this._value??``;if((this._matches(q.STRING)||this._matches(q.IDENTIFIER))&&this._advance(),this._matches(q.COLON)){this._advance(q.COLON);let n=this._parseExpression();n&&e.push(this._ast.property(t,n))}else e.push(this._ast.property(t,this._ast.id(t)))}}while(this._matches(q.COMMA));return this._advance(q.GROUPER,`}`),this._ast.map(e)}_parseInvokeOrIdentifier(){let e=this._value;if(e===`true`)return this._advance(),this._ast.literal(!0);if(e===`false`)return this._advance(),this._ast.literal(!1);if(e===`null`)return this._advance(),this._ast.literal(null);if(e===`undefined`)return this._advance(),this._ast.literal(void 0);let t=this._parseIdentifier(),n=this._parseArguments();return n?this._ast.invoke(t,void 0,n):t}_parseIdentifier(){if(!this._matches(q.IDENTIFIER))throw Error(`expected identifier: ${this._value}`);let e=this._value;return this._advance(),this._ast.id(e??``)}_parseArguments(){if(!this._matches(q.GROUPER,`(`))return;let e=[];do{if(this._advance(),this._matches(q.GROUPER,`)`))break;if(this._matches(q.SPREAD)){this._advance();let t=this._parseExpression();t&&e.push(this._ast.spreadElement(t))}else{let t=this._parseExpression();e.push(t)}}while(this._matches(q.COMMA));return this._advance(q.GROUPER,`)`),e}_parseIndex(){this._advance();let e=this._parseExpression();return this._advance(q.GROUPER,`]`),e}_parseParenOrFunction(){let e=this._parseArguments();if(this._matches(q.ARROW)){this._advance();let t=this._parseExpression(),n=e?.map(e=>e.value)??[];return this._ast.arrowFunction(n,t)}else return this._ast.paren(e?.[0])}_parseString(){let e=this._ast.literal(this._value??``);return this._advance(),e}_parseInteger(e=``){let t=this._ast.literal(parseInt(`${e}${this._value}`,10));return this._advance(),t}_parseDecimal(e=``){let t=this._ast.literal(parseFloat(`${e}${this._value}`));return this._advance(),t}};let X=Symbol(`__computed__`);function kt(e){return typeof e==`object`&&!!e&&X in e&&e[X]===!0}let At=new ht,jt=`__is_proxy__`;function Mt(e){return e instanceof Ft||e[jt]===!0}function Nt(e,t){let n=e?._store;if(n?.has(t))return n.get(t);if(n?.has(`$parent`))return Nt(n.get(`$parent`),t)}function Z(e,t){let n=e?._store;return n?.has(t)?e:n?.has(`$parent`)?Z(n.get(`$parent`),t):null}function Pt(e,t,n){let r=Z(e,t);r?r._store.set(t,n):e._store.set(t,n)}var Ft=class e{evalkeys=[`$elem`,`$event`];expressionCache=new Map;observers=new Map;keyHandlers=new Map;_store=new Map;_lock=Promise.resolve();_notify=new Map;_computedDepth=0;constructor(e){for(let[t,n]of Object.entries(e||{}))this.set(t,n)}wrapObject(e,t){if(e==null||Mt(e)||Object.isFrozen(e)||Object.isSealed(e))return e;let n=Object.getPrototypeOf(e);return!(n===Object.prototype||n===null)&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,n)=>typeof n==`string`&&n in e?(delete e[n],t(),!0):!1,set:(e,n,r,i)=>{if(Reflect.get(e,n,i)===r)return!0;typeof r==`object`&&r&&(r=this.wrapObject(r,t));let a=Reflect.set(e,n,r,i);return t(),a},get:(e,n,r)=>{if(n===jt)return!0;let i=Reflect.get(e,n,r);if(typeof i==`object`&&i&&!Mt(i)){let a=this.wrapObject(i,t);if(a!==i)return Reflect.set(e,n,a,r),a}return i}})}watch(e,t){let n=Z(this,e);if(!n)throw Error(`Cannot watch key "${e}" as it does not exist in the store.`);n.observers.has(e)||n.observers.set(e,new Set),Array.from(n.observers.get(e)||[]).some(e=>e.observer===t)||n.observers.get(e)?.add({observer:t,store:this})}addKeyHandler(e,t){this.keyHandlers.has(e)||this.keyHandlers.set(e,new Set),this.keyHandlers.get(e)?.add(t)}tagObserversForComputed(e,t){for(let n of this.observers.values())for(let r of n)r.observer===e&&r.store===this&&(r.computedKey=t);let n=this._store.get(`$parent`);for(;n;){for(let r of n.observers.values())for(let n of r)n.observer===e&&n.store===this&&(n.computedKey=t);n=n._store.get(`$parent`)}}markDependentComputedsDirty(e){let t=Z(this,e)?.observers.get(e);if(t){for(let e of t)if(e.computedKey){let t=e.store._store.get(e.computedKey);kt(t)&&!t.dirty&&(t.dirty=!0,e.store.markDependentComputedsDirty(e.computedKey))}}}async notify(e,t=10){let n=Z(this,e),r=Array.from(n?.observers.get(e)||[]),i=this._notify.get(e);if(i!==`executing`)return i&&clearTimeout(i),new Promise(i=>{this._notify.set(e,setTimeout(async()=>{this._notify.set(e,`executing`);try{await Promise.all(r.map(e=>e.observer.call(e.store.proxify(e.observer))))}finally{this._notify.delete(e)}let t=n?.observers.get(e);if(t)for(let e of r){let n=e.store._store.has(`$parent`),r=e.store._store.get(`$rootNode`);n&&r&&!r.isConnected&&!r.parentNode&&t.delete(e)}i()},t))})}get(e,t){t&&this.watch(e,t);let n=Nt(this,e);if(kt(n)){if(n.dirty){this._computedDepth++;try{let t=this.proxify(n.effectFn);n.value=n.fn.call(t,t),n.dirty=!1,n.effectFn&&this.tagObserversForComputed(n.effectFn,e),this.markDependentComputedsDirty(e)}finally{this._computedDepth--}}return n.value}return n}setupComputed(e,t){let n=this,r={[X]:!0,fn:t,dirty:!0};this._store.set(e,r);let i=function(){n._computedDepth++;try{let i=t.call(this,this);if(r.value!==i){r.value=i;let t=Z(n,e),a=Array.from(t?.observers.get(e)||[]);for(let e of a)e.observer.call(e.store.proxify(e.observer))}r.dirty=!1}finally{n._computedDepth--}};r.effectFn=i,this.effect(i,{directive:`computed`,id:e}),this.tagObserversForComputed(i,e)}async set(e,t,n){if(kt(t)){this.setupComputed(e,t.fn);return}if(this._store.has(e)&&t===this._store.get(e))return;let r=()=>(this.markDependentComputedsDirty(e),this.notify(e));if(t&&typeof t==`object`&&(t=this.wrapObject(t,r)),n?this._store.set(e,t):Pt(this,e,t),!n){for(let[n,r]of this.keyHandlers.entries())if(n.test(e))for(let n of r)await Promise.resolve(n.call(this.$,e,t))}await r()}async del(e){await this.set(e,null),this._store.delete(e),this.observers.delete(e)}dispose(){for(let e of this.observers.values())e.clear();this.observers.clear();let e=this._store.get(`$parent`);for(;e;){for(let t of e.observers.values())for(let e of t)e.store===this&&t.delete(e);e=e._store.get(`$parent`)}}keys(){return Array.from(this._store.keys())}has(e){return this._store.has(e)}getObserverStats(){let e={},t=0;for(let[n,r]of this.observers)e[n]=r.size,t+=r.size;return{totalKeys:this.observers.size,totalObservers:t,byKey:e}}effect(e,t){return e.call(this.proxify(e))}$computed(e){return{[X]:!0,fn:e,dirty:!0}}proxify(t){let n=Array.from(this._store.entries()).map(([e])=>e),r=Object.fromEntries(n.map(e=>[e,null])),i=(e,t,n)=>typeof e==`function`&&t!==`constructor`?(...t)=>e.call(n,...t):e;return new Proxy(r,{has:(e,t)=>typeof t==`string`&&(Z(this,t)||Reflect.has(this,t))?!0:Reflect.has(r,t),get:(n,r,a)=>{if(typeof r==`string`){if(Z(this,r)){let n=this.get(r,t);return t&&n instanceof e?n.proxify(t):i(n,r,a)}if(t&&r!==jt&&!Reflect.has(this,r))return this.set(r,void 0),this.get(r,t)}return r===`$`?this.proxify(t):i(Reflect.get(this,r,a),r,a)},set:(e,t,n,r)=>(typeof t!=`string`||t in this?Reflect.set(this,t,n,r):(this._computedDepth>0&&console.warn(`[mancha] Computed wrote to '${t}'. Computeds should be pure; use $effect for side effects.`),this.set(t,n)),!0)})}get $(){return this.proxify()}makeEvalFunction(e){return(t,n)=>{let r=Dt(e,At),i=new Proxy(n,{has(e,n){return n in e||n in t||n in globalThis},get(e,n){if(typeof n==`string`)return n in e?e[n]:n in t?t[n]:n in globalThis?globalThis[n]:t[n]},set(e,n,r){return typeof n==`string`?n in e?(e[n]=r,!0):(t[n]=r,!0):!1}});return r?.evaluate(i)}}cachedExpressionFunction(e){e=e.trim(),this.expressionCache.has(e)||this.expressionCache.set(e,this.makeEvalFunction(e));let t=this.expressionCache.get(e);if(!t)throw Error(`Failed to retrieve cached expression: ${e}`);return t}eval(e,t={}){let n=this.$;if(this._store.has(e))return n[e];{let r=this.cachedExpressionFunction(e);try{return r(n,t)}catch(t){return console.error(`Failed to evaluate expression: ${e}`),console.error(t),null}}}$resolve(e,t){let n={$pending:!0,$result:null,$error:null};return Promise.resolve().then(()=>e(t)).then(e=>{n.$result=e}).catch(e=>{n.$error=e instanceof Error?e:Error(String(e))}).finally(()=>{n.$pending=!1}),n}},It=class e extends Ft{_debugLevel=`off`;dirpath=``;_perfData={lifecycle:{},effects:new Map};static DEBUG_LEVELS=[`off`,`lifecycle`,`effects`,`verbose`];_skipNodes=new Set;_customElements=new Map;_pendingValueRetries=[];debug(e){return typeof e==`boolean`?this._debugLevel=e?`lifecycle`:`off`:this._debugLevel=e,this}get debugging(){return this._debugLevel!==`off`}shouldLog(t){return e.DEBUG_LEVELS.indexOf(this._debugLevel)>=e.DEBUG_LEVELS.indexOf(t)}clearPerformanceReport(){this._perfData={lifecycle:{},effects:new Map}}getNodePath(e){let t=[],n=e;for(;n?.tagName;){let e=n.tagName.toLowerCase(),r=n.parentElement;if(r){let i=Array.from(r.children).filter(t=>t.tagName.toLowerCase()===e);if(i.length>1){let r=i.indexOf(n)+1;t.unshift(`${e}:nth-child(${r})`)}else t.unshift(e)}else t.unshift(e);n=r}return t.join(`>`)}buildObserverId(e){let t=e?.directive??`unknown`,n=Ye(e?.expression??``,32),r=e?.element,i=e?.id??(r?r.dataset?.perfid??r.id??r.dataset?.testid??this.getNodePath(r):`unknown`);return n?`${t}:${i}:${n}`:`${t}:${i}`}recordObserverExecution(e,t){let n=this.buildObserverId(e),r=this._perfData.effects.get(n)??{count:0,totalTime:0};r.count++,r.totalTime+=t,this._perfData.effects.set(n,r)}getPerformanceReport(){let e=Array.from(this._perfData.effects.entries()),t={};for(let[n,r]of e){let e=n.split(`:`)[0];t[e]||(t[e]={count:0,totalTime:0}),t[e].count+=r.count,t[e].totalTime+=r.totalTime}let n=e.map(([e,t])=>({id:e,executionCount:t.count,totalTime:t.totalTime,avgTime:t.count>0?t.totalTime/t.count:0})).sort((e,t)=>t.totalTime-e.totalTime).slice(0,10);return{lifecycle:this._perfData.lifecycle,effects:{total:e.length,byDirective:t,slowest:n},observers:this.getObserverStats()}}effect(e,t){let n=this;function r(){if(!n.shouldLog(`lifecycle`))return e.call(this);let r=performance.now(),i=e.call(this),a=performance.now()-r;return t&&n.recordObserverExecution(t,a),a>16&&console.warn(`[mancha] Slow observer (${a.toFixed(1)}ms):`,n.buildObserverId(t)),n.shouldLog(`effects`)&&console.debug(`[mancha] Observer (${a.toFixed(2)}ms):`,n.buildObserverId(t)),i}return super.effect(r,t)}async fetchRemote(e,t){return fetch(e,{cache:t?.cache??`default`}).then(e=>e.text())}async fetchLocal(e,t){return this.fetchRemote(e,t)}async preprocessString(e,t){this.log(`Preprocessing string content with params:
56
+ `,t);let n=this.parseHTML(e,t);return await this.preprocessNode(n,t),n}async preprocessRemote(e,t){let n={};t?.cache&&(n.cache=t.cache);let r=await fetch(e,n).then(e=>e.text());return this.preprocessString(r,{...t,dirpath:Xe(e),rootDocument:t?.rootDocument??!e.endsWith(`.tpl.html`)})}async preprocessLocal(e,t){let n=await this.fetchLocal(e,t);return this.preprocessString(n,{...t,dirpath:Xe(e),rootDocument:t?.rootDocument??!e.endsWith(`.tpl.html`)})}subrenderer(){let e=new this.constructor().debug(this.debugging);return e._store.set(`$parent`,this),e._store.set(`$rootRenderer`,this.get(`$rootRenderer`)??this),e._customElements=this._customElements,e}log(...e){this.shouldLog(`verbose`)&&console.debug(...e)}async preprocessNode(e,t){let n=this.shouldLog(`lifecycle`)?performance.now():0;t={dirpath:this.dirpath,maxdepth:10,...t};let r=new Qe(j(e,this._skipNodes)).map(async e=>{this.log(`Preprocessing node:
57
+ `,G(e,128)),await K.resolveIncludes.call(this,e,t),await K.rebaseRelativePaths.call(this,e,t),await K.registerCustomElements.call(this,e,t),await K.resolveCustomElements.call(this,e,t)});return await Promise.all(r.generator()),n&&(this._perfData.lifecycle.preprocessTime=(this._perfData.lifecycle.preprocessTime??0)+(performance.now()-n)),e}async renderNode(e,t){let n=this.shouldLog(`lifecycle`)?performance.now():0;for(let n of j(e,this._skipNodes))this.log(`Rendering node:
58
+ `,G(n,128)),await K.resolveForAttribute.call(this,n,t),await K.resolveRenderAttribute.call(this,n,t),await K.resolveDataAttribute.call(this,n,t),await K.resolveTextAttributes.call(this,n,t),await K.resolveHtmlAttribute.call(this,n,t),await K.resolveIfAttribute.call(this,n,t),await K.resolveShowAttribute.call(this,n,t),await K.resolveClassAttribute.call(this,n,t),await K.resolveBindAttribute.call(this,n,t),await K.resolveEventAttributes.call(this,n,t),await K.resolveTextNodeExpressions.call(this,n,t),await K.resolveCustomAttribute.call(this,n,t),await K.resolveCustomProperty.call(this,n,t),await K.stripTypes.call(this,n,t);for(let e of this._pendingValueRetries.splice(0))e();return n&&(this._perfData.lifecycle.renderTime=(this._perfData.lifecycle.renderTime??0)+(performance.now()-n)),e}async mount(e,t){let n=this.shouldLog(`lifecycle`)?performance.now():0;n&&this.clearPerformanceReport(),t={...t,rootNode:e},z(e,`renderer`,this),this._store.set(`$rootNode`,e),this.has(`$rootRenderer`)||this._store.set(`$rootRenderer`,this),this.get(`$rootRenderer`)===this&&await st(this),await this.preprocessNode(e,t),await this.renderNode(e,t),n&&(this._perfData.lifecycle.mountTime=performance.now()-n)}};function Lt(){return Ve([k`*,::before,::after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}`,k`html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-family:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal}`,k`body{margin:0;line-height:inherit}`,k`hr{height:0;color:inherit;border-top-width:1px}`,k`abbr:where([title]){text-decoration:underline dotted}`,k`b,strong{font-weight:bolder}`,k`code,kbd,samp,pre{font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;font-size:1em}`,k`small{font-size:80%}`,k`sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}`,k`sub{bottom:-0.25em}`,k`sup{top:-0.5em}`,k`button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}`,k`button,select{text-transform:none}`,k`button,[type='button'],[type='reset'],[type='submit']{-webkit-appearance:button;background-color:transparent;background-image:none;cursor:pointer}`,k`:-moz-focusring{outline:auto}`,k`:-moz-ui-invalid{box-shadow:none}`,k`progress{vertical-align:baseline}`,k`::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}`,k`[type='search']{-webkit-appearance:textfield;outline-offset:-2px}`,k`::-webkit-search-decoration{-webkit-appearance:none}`,k`::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}`,k`summary{display:list-item}`,k`blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}`,k`fieldset{margin:0;padding:0}`,k`legend{padding:0}`,k`ol,ul,menu{list-style:none;margin:0;padding:0}`,k`textarea{resize:vertical}`,k`::placeholder{opacity:1;color:#9ca3af}`,k`button,[role="button"]{cursor:pointer}`,k`:disabled{cursor:default;pointer-events:none;opacity:0.75}`,k`img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}`,k`img,video{max-width:100%;height:auto}`,k`[hidden]{display:none}`,k`dialog{padding:0}`,k`dialog::backdrop{background:rgba(0,0,0,0.5)}`])}function Rt(){return Ve([k`html{`,k`max-width: 70ch;`,k`padding: 2em 1em;`,k`margin: auto;`,k`line-height: 1.75;`,k`font-size: 1.25em;`,k`font-family: sans-serif;`,k`}`,k`h1,h2,h3,h4,h5,h6{`,k`margin: 1em 0 0.5em;`,k`}`,k`p,ul,ol{`,k`margin-bottom: 1em;`,k`color: #1d1d1d;`,k`}`])}var zt=class extends It{impl=`browser`;dirpath=Xe(globalThis.location?.href??`http://localhost/`);parseHTML(e,t={rootDocument:!1}){if(t.rootDocument)return new DOMParser().parseFromString(e,`text/html`);{let t=document.createRange();return t.selectNodeContents(document.body),t.createContextualFragment(e)}}serializeHTML(e){return new XMLSerializer().serializeToString(e).replace(/\s?xmlns="[^"]+"/gm,``)}preprocessLocal(e,t){return this.preprocessRemote(e,t)}createElement(e,t){return(t||document).createElement(e)}createComment(e,t){return(t||document).createComment(e)}textContent(e,t){e.textContent=t}};new zt;function Bt(e){for(let t of e){if(t=t.trim(),t===`custom`){Be(document);continue}let e=document.createElement(`style`);switch(t){case`minimal`:_(e,Rt());break;case`basic`:_(e,Lt());break;case`utils`:e.textContent=Oe();break;default:console.error(`Unknown style name: "${t}"`);continue}globalThis.document.head.appendChild(e)}}let Vt=`mancha-cloak`;function Ht(e,t){let n=`${e.join(`, `)} { opacity: 0 !important; ${t>0?`transition: opacity ${t}ms ease-in-out !important;`:``} }`,r=document.getElementById(Vt);r||(r=document.createElement(`style`),r.id=Vt,document.head.appendChild(r)),r.textContent=n}function Ut(e){let t=!1;return async()=>{if(t)return;t=!0;let n=document.getElementById(Vt);if(n){if(e!==!1){let t=n.sheet;t&&t.cssRules.length>0&&t.cssRules[0].style.setProperty(`opacity`,`1`,`important`),await new Promise(t=>setTimeout(t,e))}n.remove()}}}async function Wt(e={}){let t;document.documentElement.classList.add(`mancha-loading`);let n=e.cloak?e.cloak===!0?{}:e.cloak:void 0;if(n){let r=e.target?Array.isArray(e.target)?e.target:[e.target]:[`body`],i=n.selector&&(Array.isArray(n.selector)||typeof n.selector==`string`)?Array.isArray(n.selector)?n.selector:[n.selector]:r,a=n.duration??0;Ht(i,a),t=Ut(a>0?a:!1)}else t=Ut(!1);document.readyState===`loading`&&await new Promise(e=>{window.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0})});let r=e.renderer??new zt;if(e.css&&e.css.length>0&&Bt(e.css),e.debug&&r.debug(!0),e.state)for(let[t,n]of Object.entries(e.state))await r.set(t,n);try{if(e.callback)await e.callback(r);else if(e.target){let t=Array.isArray(e.target)?e.target:[e.target];for(let n of t){let t=globalThis.document.querySelector(n);t?await r.mount(t,{cache:e.cache}):console.error(`Target element not found: "${n}"`)}}}finally{document.documentElement.classList.remove(`mancha-loading`),t&&await t()}return r}let Q=globalThis.document?.currentScript,$=new zt;if($.initMancha=Wt,globalThis.Mancha=$,Q?.hasAttribute(`init`)){let e=Q.hasAttribute(`debug`),t=Q.getAttribute(`cache`)||void 0,n=Q.getAttribute(`target`)?.split(`+`).map(e=>e.trim())||[`body`],r=Q.getAttribute(`css`)?.split(`+`).map(e=>e.trim()).filter(e=>e!==``),i,a=Q.getAttribute(`cloak`);if(a===`false`)i=void 0;else if(a&&!Number.isNaN(parseInt(a,10))){let e=parseInt(a,10);i=e>0?{duration:e}:!0}else i=!0;Wt({renderer:$,css:r,target:n,debug:e,cache:t,cloak:i})}else if(Q?.hasAttribute(`css`)){let e=Q.getAttribute(`css`)?.split(`+`).map(e=>e.trim()).filter(e=>e!==``);Wt({css:e})}return $})();
@@ -1 +1 @@
1
- {"version":3,"file":"mancha.js","sourceRoot":"","sources":["../src/mancha.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAElE,gDAAgD;AAChD,MAAM,aAAa,GAAG,UAAU,CAAC,QAAQ,EAAE,aAAa,CAAC;AAEzD,qEAAqE;AACrE,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;AAChC,0EAA0E;AAC1E,QAAQ,CAAC,UAAU,GAAG,UAAU,CAAC;AACjC,UAAU,CAAC,MAAM,GAAG,QAAmE,CAAC;AAExF,6FAA6F;AAC7F,IAAI,aAAa,EAAE,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;IACzC,sDAAsD;IACtD,MAAM,KAAK,GAAG,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,WAAW,GAAI,aAAa,CAAC,YAAY,CAAC,OAAO,CAAkB,IAAI,SAAS,CAAC;IACvF,MAAM,MAAM,GAAG,aAAa,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5E,MAAM,QAAQ,GAAG,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,GAAG,CAA0B,CAAC;IAExF,iDAAiD;IACjD,oCAAoC;IACpC,8DAA8D;IAC9D,gFAAgF;IAChF,IAAI,KAAiD,CAAC;IACtD,MAAM,UAAU,GAAG,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACvD,IAAI,UAAU,KAAK,OAAO,EAAE,CAAC;QAC5B,KAAK,GAAG,SAAS,CAAC;IACnB,CAAC;SAAM,IAAI,UAAU,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;QAClE,MAAM,QAAQ,GAAG,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAC1C,KAAK,GAAG,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5C,CAAC;SAAM,CAAC;QACP,+CAA+C;QAC/C,KAAK,GAAG,IAAI,CAAC;IACd,CAAC;IAED,0EAA0E;IAC1E,4DAA4D;IAC5D,UAAU,CAAC;QACV,QAAQ,EAAE,QAAQ;QAClB,GAAG,EAAE,QAAQ;QACb,MAAM;QACN,KAAK;QACL,KAAK,EAAE,WAAW;QAClB,KAAK;KACL,CAAC,CAAC;AACJ,CAAC;KAAM,IAAI,aAAa,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;IAC/C,gFAAgF;IAChF,MAAM,UAAU,GAAG,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,GAAG,CAAc,CAAC;IAC9E,UAAU,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC;AACjC,CAAC;AAED,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"mancha.js","sourceRoot":"","sources":["../src/mancha.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAElE,gDAAgD;AAChD,MAAM,aAAa,GAAG,UAAU,CAAC,QAAQ,EAAE,aAAa,CAAC;AAEzD,qEAAqE;AACrE,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;AAChC,0EAA0E;AAC1E,QAAQ,CAAC,UAAU,GAAG,UAAU,CAAC;AACjC,UAAU,CAAC,MAAM,GAAG,QAAmE,CAAC;AAExF,6FAA6F;AAC7F,IAAI,aAAa,EAAE,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;IACzC,sDAAsD;IACtD,MAAM,KAAK,GAAG,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,WAAW,GAAI,aAAa,CAAC,YAAY,CAAC,OAAO,CAAkB,IAAI,SAAS,CAAC;IACvF,MAAM,MAAM,GAAG,aAAa;SAC1B,YAAY,CAAC,QAAQ,CAAC;QACvB,EAAE,KAAK,CAAC,GAAG,CAAC;SACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,QAAQ,GAAG,aAAa;SAC5B,YAAY,CAAC,KAAK,CAAC;QACpB,EAAE,KAAK,CAAC,GAAG,CAAC;SACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAa,CAAC;SAC/B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAE,CAAY,KAAK,EAAE,CAAC,CAAC;IAEtC,iDAAiD;IACjD,oCAAoC;IACpC,8DAA8D;IAC9D,gFAAgF;IAChF,IAAI,KAAiD,CAAC;IACtD,MAAM,UAAU,GAAG,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACvD,IAAI,UAAU,KAAK,OAAO,EAAE,CAAC;QAC5B,KAAK,GAAG,SAAS,CAAC;IACnB,CAAC;SAAM,IAAI,UAAU,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;QAClE,MAAM,QAAQ,GAAG,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAC1C,KAAK,GAAG,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5C,CAAC;SAAM,CAAC;QACP,+CAA+C;QAC/C,KAAK,GAAG,IAAI,CAAC;IACd,CAAC;IAED,0EAA0E;IAC1E,4DAA4D;IAC5D,UAAU,CAAC;QACV,QAAQ,EAAE,QAAQ;QAClB,GAAG,EAAE,QAAQ;QACb,MAAM;QACN,KAAK;QACL,KAAK,EAAE,WAAW;QAClB,KAAK;KACL,CAAC,CAAC;AACJ,CAAC;KAAM,IAAI,aAAa,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;IAC/C,gFAAgF;IAChF,MAAM,UAAU,GAAG,aAAa;SAC9B,YAAY,CAAC,KAAK,CAAC;QACpB,EAAE,KAAK,CAAC,GAAG,CAAC;SACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAa,CAAC;SAC/B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAE,CAAY,KAAK,EAAE,CAAc,CAAC;IACnD,UAAU,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC;AACjC,CAAC;AAED,eAAe,QAAQ,CAAC"}
@@ -25,7 +25,7 @@ const L=new Set([`this`,`typeof`]),ie=new Set([`in`]),ae=new Set([`+`,`-`,`!`,`t
25
25
  * Portions Copyright (c) 2013, the Dart project authors.
26
26
  */
27
27
  const z=new Set([`==`,`!=`,`<=`,`>=`,`||`,`&&`,`??`,`?.`]),B=new Set([`===`,`!==`]);let V=function(e){return e[e.STRING=1]=`STRING`,e[e.IDENTIFIER=2]=`IDENTIFIER`,e[e.DOT=3]=`DOT`,e[e.COMMA=4]=`COMMA`,e[e.COLON=5]=`COLON`,e[e.INTEGER=6]=`INTEGER`,e[e.DECIMAL=7]=`DECIMAL`,e[e.OPERATOR=8]=`OPERATOR`,e[e.GROUPER=9]=`GROUPER`,e[e.KEYWORD=10]=`KEYWORD`,e[e.ARROW=11]=`ARROW`,e[e.OPTIONAL_DOT=12]=`OPTIONAL_DOT`,e[e.SPREAD=13]=`SPREAD`,e}({});const H=(e,t,n=0)=>({kind:e,value:t,precedence:n}),U=e=>e===9||e===10||e===13||e===32,W=e=>{if(e===95||e===36)return!0;let t=e&-33;return 65<=t&&t<=90},ue=e=>W(e)||G(e),de=e=>L.has(e),fe=e=>e===34||e===39,G=e=>48<=e&&e<=57,pe=e=>e===43||e===45||e===42||e===47||e===33||e===38||e===37||e===60||e===61||e===62||e===63||e===94||e===124,me=e=>e===40||e===41||e===91||e===93||e===123||e===125,he=e=>e.replace(/\\(.)/g,(e,t)=>{switch(t){case`n`:return`
28
- `;case`r`:return`\r`;case`t`:return` `;case`b`:return`\b`;case`f`:return`\f`;default:return t}});var ge=class{_input;_index=-1;_tokenStart=0;_next;constructor(e){this._input=e,this._advance()}nextToken(){for(;U(this._next??-1);)this._advance(!0);if(fe(this._next??-1))return this._tokenizeString();if(W(this._next??-1))return this._tokenizeIdentOrKeyword();if(G(this._next??-1))return this._tokenizeNumber();if(this._next===46)return this._tokenizeDot();if(this._next===44)return this._tokenizeComma();if(this._next===58)return this._tokenizeColon();if(pe(this._next??-1))return this._tokenizeOperator();if(me(this._next??-1))return this._tokenizeGrouper();if(this._advance(),this._next!==void 0)throw Error(`Expected end of input, got ${this._next}`)}_advance(e){this._index++,this._index<this._input.length?(this._next=this._input.charCodeAt(this._index),e===!0&&(this._tokenStart=this._index)):this._next=void 0}_getValue(e=0){let t=this._input.substring(this._tokenStart,this._index+e);return e===0&&this._clearValue(),t}_clearValue(){this._tokenStart=this._index}_tokenizeString(){let e=this._next;for(this._advance(!0);this._next!==e;){if(this._next===void 0||this._next===92&&(this._advance(),this._next===void 0))throw Error(`unterminated string`);this._advance()}let t=H(V.STRING,he(this._getValue()));return this._advance(),t}_tokenizeIdentOrKeyword(){do this._advance();while(ue(this._next??-1));let e=this._getValue();return H(de(e)?V.KEYWORD:ie.has(e)?V.OPERATOR:V.IDENTIFIER,e,R[e]??0)}_tokenizeNumber(){do this._advance();while(G(this._next??-1));return this._next===46?this._tokenizeDot():H(V.INTEGER,this._getValue())}_tokenizeDot(){if(this._advance(),G(this._next??-1))return this._tokenizeFraction();if(this._next===46){if(this._advance(),this._next===46)return this._advance(),this._clearValue(),H(V.SPREAD,`...`);throw Error(`Unexpected token ..`)}return this._clearValue(),H(V.DOT,`.`,13)}_tokenizeComma(){return this._advance(!0),H(V.COMMA,`,`)}_tokenizeColon(){return this._advance(!0),H(V.COLON,`:`)}_tokenizeFraction(){do this._advance();while(G(this._next??-1));return H(V.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(B.has(e))this._advance(),this._advance();else{if(e=this._getValue(1),e===`=>`)return this._advance(),H(V.ARROW,e);z.has(e)&&this._advance()}return e=this._getValue(),e===`?.`?H(V.OPTIONAL_DOT,e,13):H(V.OPERATOR,e,R[e])}_tokenizeGrouper(){let e=String.fromCharCode(this._next??0),t=H(V.GROUPER,e,R[e]);return this._advance(!0),t}};const _e=(e,t)=>new ve(e,t).parse();var ve=class{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new ge(e),this._ast=t}parse(){this._advance();let e=this._parseExpression();if(this._token)throw Error(`Unexpected token: ${this._token.value}`);return e}_advance(e,t){if(!this._matches(e,t))throw Error(`Expected kind ${e} (${t}), was ${this._token?.kind} (${this._token?.value})`);let n=this._tokenizer.nextToken();this._token=n,this._kind=n?.kind,this._value=n?.value}_matches(e,t){return!(e&&this._kind!==e||t&&this._value!==t)}_parseExpression(){if(!this._token)return this._ast.empty();let e=this._parseUnary();return e===void 0?void 0:this._parsePrecedence(e,0)}_parsePrecedence(e,t){if(e===void 0)throw Error(`Expected left to be defined.`);for(;this._token;)if(this._matches(V.GROUPER,`(`)){let t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(V.GROUPER,`[`)){let t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(V.DOT)||this._matches(V.OPTIONAL_DOT)){let t=this._kind===V.OPTIONAL_DOT;if(this._advance(),t&&this._matches(V.GROUPER,`[`)){let t=this._parseIndex();e=this._ast.index(e,t,!0)}else if(t&&this._matches(V.GROUPER,`(`)){let t=this._parseArguments();e=this._ast.invoke(e,void 0,t,!0)}else{let n=this._parseUnary();e=this._makeInvokeOrGetter(e,n,t)}}else if(this._matches(V.KEYWORD))break;else if(this._matches(V.OPERATOR)&&this._token.precedence>=t)e=this._value===`?`?this._parseTernary(e):this._parseBinary(e,this._token);else break;return e}_makeInvokeOrGetter(e,t,n){if(t===void 0)throw Error(`expected identifier`);if(t.type===`ID`)return this._ast.getter(e,t.value,n);if(t.type===`Invoke`&&t.receiver.type===`ID`){let r=t.receiver;return this._ast.invoke(e,r.value,t.arguments,n)}else throw Error(`expected identifier: ${t}`)}_parseBinary(e,t){if(!oe.has(t.value))throw Error(`unknown operator: ${t.value}`);this._advance();let n=this._parseUnary();for(;(this._kind===V.OPERATOR||this._kind===V.DOT||this._kind===V.GROUPER)&&this._token&&(this._token.precedence??0)>t.precedence;)n=this._parsePrecedence(n,this._token?.precedence??0);if(n===void 0)throw Error(`Expected expression after ${t.value}`);return this._ast.binary(e,t.value,n)}_parseUnary(){if(this._matches(V.KEYWORD,`typeof`)){this._advance();let e=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(`typeof`,e)}if(this._matches(V.OPERATOR)){let e=this._value;if(this._advance(),e===`+`||e===`-`){if(this._matches(V.INTEGER))return this._parseInteger(e);if(this._matches(V.DECIMAL))return this._parseDecimal(e)}if(!e||!ae.has(e))throw Error(`unexpected token: ${e}`);let t=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(e,t)}return this._parsePrimary()}_parseTernary(e){this._advance(V.OPERATOR,`?`);let t=this._parseExpression();this._advance(V.COLON);let n=this._parseExpression();return this._ast.ternary(e,t,n)}_parsePrimary(){switch(this._kind){case V.KEYWORD:{let e=this._value??``;if(e===`this`)return this._advance(),this._ast.id(e);throw L.has(e)?Error(`unexpected keyword: ${e}`):Error(`unrecognized keyword: ${e}`)}case V.IDENTIFIER:return this._parseInvokeOrIdentifier();case V.STRING:return this._parseString();case V.INTEGER:return this._parseInteger();case V.DECIMAL:return this._parseDecimal();case V.GROUPER:return this._value===`(`?this._parseParenOrFunction():this._value===`{`?this._parseMap():this._value===`[`?this._parseList():void 0;case V.COLON:throw Error(`unexpected token ":"`);default:return}}_parseList(){let e=[];do{if(this._advance(),this._matches(V.GROUPER,`]`))break;if(this._matches(V.SPREAD)){this._advance();let t=this._parseExpression();t&&e.push(this._ast.spreadElement(t))}else e.push(this._parseExpression())}while(this._matches(V.COMMA));return this._advance(V.GROUPER,`]`),this._ast.list(e)}_parseMap(){let e=[];do{if(this._advance(),this._matches(V.GROUPER,`}`))break;if(this._matches(V.SPREAD)){this._advance();let t=this._parseExpression();t&&e.push(this._ast.spreadProperty(t))}else{let t=this._value??``;if((this._matches(V.STRING)||this._matches(V.IDENTIFIER))&&this._advance(),this._matches(V.COLON)){this._advance(V.COLON);let n=this._parseExpression();n&&e.push(this._ast.property(t,n))}else e.push(this._ast.property(t,this._ast.id(t)))}}while(this._matches(V.COMMA));return this._advance(V.GROUPER,`}`),this._ast.map(e)}_parseInvokeOrIdentifier(){let e=this._value;if(e===`true`)return this._advance(),this._ast.literal(!0);if(e===`false`)return this._advance(),this._ast.literal(!1);if(e===`null`)return this._advance(),this._ast.literal(null);if(e===`undefined`)return this._advance(),this._ast.literal(void 0);let t=this._parseIdentifier(),n=this._parseArguments();return n?this._ast.invoke(t,void 0,n):t}_parseIdentifier(){if(!this._matches(V.IDENTIFIER))throw Error(`expected identifier: ${this._value}`);let e=this._value;return this._advance(),this._ast.id(e??``)}_parseArguments(){if(!this._matches(V.GROUPER,`(`))return;let e=[];do{if(this._advance(),this._matches(V.GROUPER,`)`))break;if(this._matches(V.SPREAD)){this._advance();let t=this._parseExpression();t&&e.push(this._ast.spreadElement(t))}else{let t=this._parseExpression();e.push(t)}}while(this._matches(V.COMMA));return this._advance(V.GROUPER,`)`),e}_parseIndex(){this._advance();let e=this._parseExpression();return this._advance(V.GROUPER,`]`),e}_parseParenOrFunction(){let e=this._parseArguments();if(this._matches(V.ARROW)){this._advance();let t=this._parseExpression(),n=e?.map(e=>e.value)??[];return this._ast.arrowFunction(n,t)}else return this._ast.paren(e?.[0])}_parseString(){let e=this._ast.literal(this._value??``);return this._advance(),e}_parseInteger(e=``){let t=this._ast.literal(parseInt(`${e}${this._value}`,10));return this._advance(),t}_parseDecimal(e=``){let t=this._ast.literal(parseFloat(`${e}${this._value}`));return this._advance(),t}};const K=Symbol(`__computed__`);function q(e){return typeof e==`object`&&!!e&&K in e&&e[K]===!0}const J=new le,Y=`__is_proxy__`;function X(e){return e instanceof $||e[Y]===!0}function Z(e,t){let n=e?._store;if(n?.has(t))return n.get(t);if(n?.has(`$parent`))return Z(n.get(`$parent`),t)}function Q(e,t){let n=e?._store;return n?.has(t)?e:n?.has(`$parent`)?Q(n.get(`$parent`),t):null}function ye(e,t,n){let r=Q(e,t);r?r._store.set(t,n):e._store.set(t,n)}var $=class e{evalkeys=[`$elem`,`$event`];expressionCache=new Map;observers=new Map;keyHandlers=new Map;_store=new Map;_lock=Promise.resolve();_notify=new Map;_computedDepth=0;constructor(e){for(let[t,n]of Object.entries(e||{}))this.set(t,n)}wrapObject(e,t){if(e==null||X(e)||Object.isFrozen(e)||Object.isSealed(e))return e;let n=Object.getPrototypeOf(e);return!(n===Object.prototype||n===null)&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,n)=>typeof n==`string`&&n in e?(delete e[n],t(),!0):!1,set:(e,n,r,i)=>{if(Reflect.get(e,n,i)===r)return!0;typeof r==`object`&&r&&(r=this.wrapObject(r,t));let a=Reflect.set(e,n,r,i);return t(),a},get:(e,n,r)=>{if(n===Y)return!0;let i=Reflect.get(e,n,r);if(typeof i==`object`&&i&&!X(i)){let a=this.wrapObject(i,t);if(a!==i)return Reflect.set(e,n,a,r),a}return i}})}watch(e,t){let n=Q(this,e);if(!n)throw Error(`Cannot watch key "${e}" as it does not exist in the store.`);n.observers.has(e)||n.observers.set(e,new Set),Array.from(n.observers.get(e)||[]).some(e=>e.observer===t)||n.observers.get(e)?.add({observer:t,store:this})}addKeyHandler(e,t){this.keyHandlers.has(e)||this.keyHandlers.set(e,new Set),this.keyHandlers.get(e)?.add(t)}tagObserversForComputed(e,t){for(let n of this.observers.values())for(let r of n)r.observer===e&&r.store===this&&(r.computedKey=t);let n=this._store.get(`$parent`);for(;n;){for(let r of n.observers.values())for(let n of r)n.observer===e&&n.store===this&&(n.computedKey=t);n=n._store.get(`$parent`)}}markDependentComputedsDirty(e){let t=Q(this,e)?.observers.get(e);if(t){for(let e of t)if(e.computedKey){let t=e.store._store.get(e.computedKey);q(t)&&!t.dirty&&(t.dirty=!0,e.store.markDependentComputedsDirty(e.computedKey))}}}async notify(e,t=10){let n=Q(this,e),r=Array.from(n?.observers.get(e)||[]),i=this._notify.get(e);if(i!==`executing`)return i&&clearTimeout(i),new Promise(i=>{this._notify.set(e,setTimeout(async()=>{this._notify.set(e,`executing`);try{await Promise.all(r.map(e=>e.observer.call(e.store.proxify(e.observer))))}finally{this._notify.delete(e)}let t=n?.observers.get(e);if(t)for(let e of r){let n=e.store._store.has(`$parent`),r=e.store._store.get(`$rootNode`);n&&r&&!r.isConnected&&t.delete(e)}i()},t))})}get(e,t){t&&this.watch(e,t);let n=Z(this,e);if(q(n)){if(n.dirty){this._computedDepth++;try{let t=this.proxify(n.effectFn);n.value=n.fn.call(t,t),n.dirty=!1,n.effectFn&&this.tagObserversForComputed(n.effectFn,e),this.markDependentComputedsDirty(e)}finally{this._computedDepth--}}return n.value}return n}setupComputed(e,t){let n=this,r={[K]:!0,fn:t,dirty:!0};this._store.set(e,r);let i=function(){n._computedDepth++;try{let i=t.call(this,this);if(r.value!==i){r.value=i;let t=Q(n,e),a=Array.from(t?.observers.get(e)||[]);for(let e of a)e.observer.call(e.store.proxify(e.observer))}r.dirty=!1}finally{n._computedDepth--}};r.effectFn=i,this.effect(i,{directive:`computed`,id:e}),this.tagObserversForComputed(i,e)}async set(e,t,n){if(q(t)){this.setupComputed(e,t.fn);return}if(this._store.has(e)&&t===this._store.get(e))return;let r=()=>(this.markDependentComputedsDirty(e),this.notify(e));if(t&&typeof t==`object`&&(t=this.wrapObject(t,r)),n?this._store.set(e,t):ye(this,e,t),!n){for(let[n,r]of this.keyHandlers.entries())if(n.test(e))for(let n of r)await Promise.resolve(n.call(this.$,e,t))}await r()}async del(e){await this.set(e,null),this._store.delete(e),this.observers.delete(e)}dispose(){for(let e of this.observers.values())e.clear();this.observers.clear();let e=this._store.get(`$parent`);for(;e;){for(let t of e.observers.values())for(let e of t)e.store===this&&t.delete(e);e=e._store.get(`$parent`)}}keys(){return Array.from(this._store.keys())}has(e){return this._store.has(e)}getObserverStats(){let e={},t=0;for(let[n,r]of this.observers)e[n]=r.size,t+=r.size;return{totalKeys:this.observers.size,totalObservers:t,byKey:e}}effect(e,t){return e.call(this.proxify(e))}$computed(e){return{[K]:!0,fn:e,dirty:!0}}proxify(t){let n=Array.from(this._store.entries()).map(([e])=>e),r=Object.fromEntries(n.map(e=>[e,null])),i=(e,t,n)=>typeof e==`function`&&t!==`constructor`?(...t)=>e.call(n,...t):e;return new Proxy(r,{has:(e,t)=>typeof t==`string`&&(Q(this,t)||Reflect.has(this,t))?!0:Reflect.has(r,t),get:(n,r,a)=>{if(typeof r==`string`){if(Q(this,r)){let n=this.get(r,t);return t&&n instanceof e?n.proxify(t):i(n,r,a)}if(t&&r!==Y&&!Reflect.has(this,r))return this.set(r,void 0),this.get(r,t)}return r===`$`?this.proxify(t):i(Reflect.get(this,r,a),r,a)},set:(e,t,n,r)=>(typeof t!=`string`||t in this?Reflect.set(this,t,n,r):(this._computedDepth>0&&console.warn(`[mancha] Computed wrote to '${t}'. Computeds should be pure; use $effect for side effects.`),this.set(t,n)),!0)})}get $(){return this.proxify()}makeEvalFunction(e){return(t,n)=>{let r=_e(e,J),i=new Proxy(n,{has(e,n){return n in e||n in t||n in globalThis},get(e,n){if(typeof n==`string`)return n in e?e[n]:n in t?t[n]:n in globalThis?globalThis[n]:t[n]},set(e,n,r){return typeof n==`string`?n in e?(e[n]=r,!0):(t[n]=r,!0):!1}});return r?.evaluate(i)}}cachedExpressionFunction(e){e=e.trim(),this.expressionCache.has(e)||this.expressionCache.set(e,this.makeEvalFunction(e));let t=this.expressionCache.get(e);if(!t)throw Error(`Failed to retrieve cached expression: ${e}`);return t}eval(e,t={}){let n=this.$;if(this._store.has(e))return n[e];{let r=this.cachedExpressionFunction(e);try{return r(n,t)}catch(t){return console.error(`Failed to evaluate expression: ${e}`),console.error(t),null}}}$resolve(e,t){let n={$pending:!0,$result:null,$error:null};return Promise.resolve().then(()=>e(t)).then(e=>{n.$result=e}).catch(e=>{n.$error=e instanceof Error?e:Error(String(e))}).finally(()=>{n.$pending=!1}),n}},be=class e extends ${_debugLevel=`off`;dirpath=``;_perfData={lifecycle:{},effects:new Map};static DEBUG_LEVELS=[`off`,`lifecycle`,`effects`,`verbose`];_skipNodes=new Set;_customElements=new Map;_pendingValueRetries=[];debug(e){return typeof e==`boolean`?this._debugLevel=e?`lifecycle`:`off`:this._debugLevel=e,this}get debugging(){return this._debugLevel!==`off`}shouldLog(t){return e.DEBUG_LEVELS.indexOf(this._debugLevel)>=e.DEBUG_LEVELS.indexOf(t)}clearPerformanceReport(){this._perfData={lifecycle:{},effects:new Map}}getNodePath(e){let t=[],n=e;for(;n?.tagName;){let e=n.tagName.toLowerCase(),r=n.parentElement;if(r){let i=Array.from(r.children).filter(t=>t.tagName.toLowerCase()===e);if(i.length>1){let r=i.indexOf(n)+1;t.unshift(`${e}:nth-child(${r})`)}else t.unshift(e)}else t.unshift(e);n=r}return t.join(`>`)}buildObserverId(e){let t=e?.directive??`unknown`,n=E(e?.expression??``,32),r=e?.element,i=e?.id??(r?r.dataset?.perfid??r.id??r.dataset?.testid??this.getNodePath(r):`unknown`);return n?`${t}:${i}:${n}`:`${t}:${i}`}recordObserverExecution(e,t){let n=this.buildObserverId(e),r=this._perfData.effects.get(n)??{count:0,totalTime:0};r.count++,r.totalTime+=t,this._perfData.effects.set(n,r)}getPerformanceReport(){let e=Array.from(this._perfData.effects.entries()),t={};for(let[n,r]of e){let e=n.split(`:`)[0];t[e]||(t[e]={count:0,totalTime:0}),t[e].count+=r.count,t[e].totalTime+=r.totalTime}let n=e.map(([e,t])=>({id:e,executionCount:t.count,totalTime:t.totalTime,avgTime:t.count>0?t.totalTime/t.count:0})).sort((e,t)=>t.totalTime-e.totalTime).slice(0,10);return{lifecycle:this._perfData.lifecycle,effects:{total:e.length,byDirective:t,slowest:n},observers:this.getObserverStats()}}effect(e,t){let n=this;function r(){if(!n.shouldLog(`lifecycle`))return e.call(this);let r=performance.now(),i=e.call(this),a=performance.now()-r;return t&&n.recordObserverExecution(t,a),a>16&&console.warn(`[mancha] Slow observer (${a.toFixed(1)}ms):`,n.buildObserverId(t)),n.shouldLog(`effects`)&&console.debug(`[mancha] Observer (${a.toFixed(2)}ms):`,n.buildObserverId(t)),i}return super.effect(r,t)}async fetchRemote(e,t){return fetch(e,{cache:t?.cache??`default`}).then(e=>e.text())}async fetchLocal(e,t){return this.fetchRemote(e,t)}async preprocessString(e,t){this.log(`Preprocessing string content with params:
28
+ `;case`r`:return`\r`;case`t`:return` `;case`b`:return`\b`;case`f`:return`\f`;default:return t}});var ge=class{_input;_index=-1;_tokenStart=0;_next;constructor(e){this._input=e,this._advance()}nextToken(){for(;U(this._next??-1);)this._advance(!0);if(fe(this._next??-1))return this._tokenizeString();if(W(this._next??-1))return this._tokenizeIdentOrKeyword();if(G(this._next??-1))return this._tokenizeNumber();if(this._next===46)return this._tokenizeDot();if(this._next===44)return this._tokenizeComma();if(this._next===58)return this._tokenizeColon();if(pe(this._next??-1))return this._tokenizeOperator();if(me(this._next??-1))return this._tokenizeGrouper();if(this._advance(),this._next!==void 0)throw Error(`Expected end of input, got ${this._next}`)}_advance(e){this._index++,this._index<this._input.length?(this._next=this._input.charCodeAt(this._index),e===!0&&(this._tokenStart=this._index)):this._next=void 0}_getValue(e=0){let t=this._input.substring(this._tokenStart,this._index+e);return e===0&&this._clearValue(),t}_clearValue(){this._tokenStart=this._index}_tokenizeString(){let e=this._next;for(this._advance(!0);this._next!==e;){if(this._next===void 0||this._next===92&&(this._advance(),this._next===void 0))throw Error(`unterminated string`);this._advance()}let t=H(V.STRING,he(this._getValue()));return this._advance(),t}_tokenizeIdentOrKeyword(){do this._advance();while(ue(this._next??-1));let e=this._getValue();return H(de(e)?V.KEYWORD:ie.has(e)?V.OPERATOR:V.IDENTIFIER,e,R[e]??0)}_tokenizeNumber(){do this._advance();while(G(this._next??-1));return this._next===46?this._tokenizeDot():H(V.INTEGER,this._getValue())}_tokenizeDot(){if(this._advance(),G(this._next??-1))return this._tokenizeFraction();if(this._next===46){if(this._advance(),this._next===46)return this._advance(),this._clearValue(),H(V.SPREAD,`...`);throw Error(`Unexpected token ..`)}return this._clearValue(),H(V.DOT,`.`,13)}_tokenizeComma(){return this._advance(!0),H(V.COMMA,`,`)}_tokenizeColon(){return this._advance(!0),H(V.COLON,`:`)}_tokenizeFraction(){do this._advance();while(G(this._next??-1));return H(V.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(B.has(e))this._advance(),this._advance();else{if(e=this._getValue(1),e===`=>`)return this._advance(),H(V.ARROW,e);z.has(e)&&this._advance()}return e=this._getValue(),e===`?.`?H(V.OPTIONAL_DOT,e,13):H(V.OPERATOR,e,R[e])}_tokenizeGrouper(){let e=String.fromCharCode(this._next??0),t=H(V.GROUPER,e,R[e]);return this._advance(!0),t}};const _e=(e,t)=>new ve(e,t).parse();var ve=class{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new ge(e),this._ast=t}parse(){this._advance();let e=this._parseExpression();if(this._token)throw Error(`Unexpected token: ${this._token.value}`);return e}_advance(e,t){if(!this._matches(e,t))throw Error(`Expected kind ${e} (${t}), was ${this._token?.kind} (${this._token?.value})`);let n=this._tokenizer.nextToken();this._token=n,this._kind=n?.kind,this._value=n?.value}_matches(e,t){return!(e&&this._kind!==e||t&&this._value!==t)}_parseExpression(){if(!this._token)return this._ast.empty();let e=this._parseUnary();return e===void 0?void 0:this._parsePrecedence(e,0)}_parsePrecedence(e,t){if(e===void 0)throw Error(`Expected left to be defined.`);for(;this._token;)if(this._matches(V.GROUPER,`(`)){let t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(V.GROUPER,`[`)){let t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(V.DOT)||this._matches(V.OPTIONAL_DOT)){let t=this._kind===V.OPTIONAL_DOT;if(this._advance(),t&&this._matches(V.GROUPER,`[`)){let t=this._parseIndex();e=this._ast.index(e,t,!0)}else if(t&&this._matches(V.GROUPER,`(`)){let t=this._parseArguments();e=this._ast.invoke(e,void 0,t,!0)}else{let n=this._parseUnary();e=this._makeInvokeOrGetter(e,n,t)}}else if(this._matches(V.KEYWORD))break;else if(this._matches(V.OPERATOR)&&this._token.precedence>=t)e=this._value===`?`?this._parseTernary(e):this._parseBinary(e,this._token);else break;return e}_makeInvokeOrGetter(e,t,n){if(t===void 0)throw Error(`expected identifier`);if(t.type===`ID`)return this._ast.getter(e,t.value,n);if(t.type===`Invoke`&&t.receiver.type===`ID`){let r=t.receiver;return this._ast.invoke(e,r.value,t.arguments,n)}else throw Error(`expected identifier: ${t}`)}_parseBinary(e,t){if(!oe.has(t.value))throw Error(`unknown operator: ${t.value}`);this._advance();let n=this._parseUnary();for(;(this._kind===V.OPERATOR||this._kind===V.DOT||this._kind===V.GROUPER)&&this._token&&(this._token.precedence??0)>t.precedence;)n=this._parsePrecedence(n,this._token?.precedence??0);if(n===void 0)throw Error(`Expected expression after ${t.value}`);return this._ast.binary(e,t.value,n)}_parseUnary(){if(this._matches(V.KEYWORD,`typeof`)){this._advance();let e=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(`typeof`,e)}if(this._matches(V.OPERATOR)){let e=this._value;if(this._advance(),e===`+`||e===`-`){if(this._matches(V.INTEGER))return this._parseInteger(e);if(this._matches(V.DECIMAL))return this._parseDecimal(e)}if(!e||!ae.has(e))throw Error(`unexpected token: ${e}`);let t=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(e,t)}return this._parsePrimary()}_parseTernary(e){this._advance(V.OPERATOR,`?`);let t=this._parseExpression();this._advance(V.COLON);let n=this._parseExpression();return this._ast.ternary(e,t,n)}_parsePrimary(){switch(this._kind){case V.KEYWORD:{let e=this._value??``;if(e===`this`)return this._advance(),this._ast.id(e);throw L.has(e)?Error(`unexpected keyword: ${e}`):Error(`unrecognized keyword: ${e}`)}case V.IDENTIFIER:return this._parseInvokeOrIdentifier();case V.STRING:return this._parseString();case V.INTEGER:return this._parseInteger();case V.DECIMAL:return this._parseDecimal();case V.GROUPER:return this._value===`(`?this._parseParenOrFunction():this._value===`{`?this._parseMap():this._value===`[`?this._parseList():void 0;case V.COLON:throw Error(`unexpected token ":"`);default:return}}_parseList(){let e=[];do{if(this._advance(),this._matches(V.GROUPER,`]`))break;if(this._matches(V.SPREAD)){this._advance();let t=this._parseExpression();t&&e.push(this._ast.spreadElement(t))}else e.push(this._parseExpression())}while(this._matches(V.COMMA));return this._advance(V.GROUPER,`]`),this._ast.list(e)}_parseMap(){let e=[];do{if(this._advance(),this._matches(V.GROUPER,`}`))break;if(this._matches(V.SPREAD)){this._advance();let t=this._parseExpression();t&&e.push(this._ast.spreadProperty(t))}else{let t=this._value??``;if((this._matches(V.STRING)||this._matches(V.IDENTIFIER))&&this._advance(),this._matches(V.COLON)){this._advance(V.COLON);let n=this._parseExpression();n&&e.push(this._ast.property(t,n))}else e.push(this._ast.property(t,this._ast.id(t)))}}while(this._matches(V.COMMA));return this._advance(V.GROUPER,`}`),this._ast.map(e)}_parseInvokeOrIdentifier(){let e=this._value;if(e===`true`)return this._advance(),this._ast.literal(!0);if(e===`false`)return this._advance(),this._ast.literal(!1);if(e===`null`)return this._advance(),this._ast.literal(null);if(e===`undefined`)return this._advance(),this._ast.literal(void 0);let t=this._parseIdentifier(),n=this._parseArguments();return n?this._ast.invoke(t,void 0,n):t}_parseIdentifier(){if(!this._matches(V.IDENTIFIER))throw Error(`expected identifier: ${this._value}`);let e=this._value;return this._advance(),this._ast.id(e??``)}_parseArguments(){if(!this._matches(V.GROUPER,`(`))return;let e=[];do{if(this._advance(),this._matches(V.GROUPER,`)`))break;if(this._matches(V.SPREAD)){this._advance();let t=this._parseExpression();t&&e.push(this._ast.spreadElement(t))}else{let t=this._parseExpression();e.push(t)}}while(this._matches(V.COMMA));return this._advance(V.GROUPER,`)`),e}_parseIndex(){this._advance();let e=this._parseExpression();return this._advance(V.GROUPER,`]`),e}_parseParenOrFunction(){let e=this._parseArguments();if(this._matches(V.ARROW)){this._advance();let t=this._parseExpression(),n=e?.map(e=>e.value)??[];return this._ast.arrowFunction(n,t)}else return this._ast.paren(e?.[0])}_parseString(){let e=this._ast.literal(this._value??``);return this._advance(),e}_parseInteger(e=``){let t=this._ast.literal(parseInt(`${e}${this._value}`,10));return this._advance(),t}_parseDecimal(e=``){let t=this._ast.literal(parseFloat(`${e}${this._value}`));return this._advance(),t}};const K=Symbol(`__computed__`);function q(e){return typeof e==`object`&&!!e&&K in e&&e[K]===!0}const J=new le,Y=`__is_proxy__`;function X(e){return e instanceof $||e[Y]===!0}function Z(e,t){let n=e?._store;if(n?.has(t))return n.get(t);if(n?.has(`$parent`))return Z(n.get(`$parent`),t)}function Q(e,t){let n=e?._store;return n?.has(t)?e:n?.has(`$parent`)?Q(n.get(`$parent`),t):null}function ye(e,t,n){let r=Q(e,t);r?r._store.set(t,n):e._store.set(t,n)}var $=class e{evalkeys=[`$elem`,`$event`];expressionCache=new Map;observers=new Map;keyHandlers=new Map;_store=new Map;_lock=Promise.resolve();_notify=new Map;_computedDepth=0;constructor(e){for(let[t,n]of Object.entries(e||{}))this.set(t,n)}wrapObject(e,t){if(e==null||X(e)||Object.isFrozen(e)||Object.isSealed(e))return e;let n=Object.getPrototypeOf(e);return!(n===Object.prototype||n===null)&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,n)=>typeof n==`string`&&n in e?(delete e[n],t(),!0):!1,set:(e,n,r,i)=>{if(Reflect.get(e,n,i)===r)return!0;typeof r==`object`&&r&&(r=this.wrapObject(r,t));let a=Reflect.set(e,n,r,i);return t(),a},get:(e,n,r)=>{if(n===Y)return!0;let i=Reflect.get(e,n,r);if(typeof i==`object`&&i&&!X(i)){let a=this.wrapObject(i,t);if(a!==i)return Reflect.set(e,n,a,r),a}return i}})}watch(e,t){let n=Q(this,e);if(!n)throw Error(`Cannot watch key "${e}" as it does not exist in the store.`);n.observers.has(e)||n.observers.set(e,new Set),Array.from(n.observers.get(e)||[]).some(e=>e.observer===t)||n.observers.get(e)?.add({observer:t,store:this})}addKeyHandler(e,t){this.keyHandlers.has(e)||this.keyHandlers.set(e,new Set),this.keyHandlers.get(e)?.add(t)}tagObserversForComputed(e,t){for(let n of this.observers.values())for(let r of n)r.observer===e&&r.store===this&&(r.computedKey=t);let n=this._store.get(`$parent`);for(;n;){for(let r of n.observers.values())for(let n of r)n.observer===e&&n.store===this&&(n.computedKey=t);n=n._store.get(`$parent`)}}markDependentComputedsDirty(e){let t=Q(this,e)?.observers.get(e);if(t){for(let e of t)if(e.computedKey){let t=e.store._store.get(e.computedKey);q(t)&&!t.dirty&&(t.dirty=!0,e.store.markDependentComputedsDirty(e.computedKey))}}}async notify(e,t=10){let n=Q(this,e),r=Array.from(n?.observers.get(e)||[]),i=this._notify.get(e);if(i!==`executing`)return i&&clearTimeout(i),new Promise(i=>{this._notify.set(e,setTimeout(async()=>{this._notify.set(e,`executing`);try{await Promise.all(r.map(e=>e.observer.call(e.store.proxify(e.observer))))}finally{this._notify.delete(e)}let t=n?.observers.get(e);if(t)for(let e of r){let n=e.store._store.has(`$parent`),r=e.store._store.get(`$rootNode`);n&&r&&!r.isConnected&&!r.parentNode&&t.delete(e)}i()},t))})}get(e,t){t&&this.watch(e,t);let n=Z(this,e);if(q(n)){if(n.dirty){this._computedDepth++;try{let t=this.proxify(n.effectFn);n.value=n.fn.call(t,t),n.dirty=!1,n.effectFn&&this.tagObserversForComputed(n.effectFn,e),this.markDependentComputedsDirty(e)}finally{this._computedDepth--}}return n.value}return n}setupComputed(e,t){let n=this,r={[K]:!0,fn:t,dirty:!0};this._store.set(e,r);let i=function(){n._computedDepth++;try{let i=t.call(this,this);if(r.value!==i){r.value=i;let t=Q(n,e),a=Array.from(t?.observers.get(e)||[]);for(let e of a)e.observer.call(e.store.proxify(e.observer))}r.dirty=!1}finally{n._computedDepth--}};r.effectFn=i,this.effect(i,{directive:`computed`,id:e}),this.tagObserversForComputed(i,e)}async set(e,t,n){if(q(t)){this.setupComputed(e,t.fn);return}if(this._store.has(e)&&t===this._store.get(e))return;let r=()=>(this.markDependentComputedsDirty(e),this.notify(e));if(t&&typeof t==`object`&&(t=this.wrapObject(t,r)),n?this._store.set(e,t):ye(this,e,t),!n){for(let[n,r]of this.keyHandlers.entries())if(n.test(e))for(let n of r)await Promise.resolve(n.call(this.$,e,t))}await r()}async del(e){await this.set(e,null),this._store.delete(e),this.observers.delete(e)}dispose(){for(let e of this.observers.values())e.clear();this.observers.clear();let e=this._store.get(`$parent`);for(;e;){for(let t of e.observers.values())for(let e of t)e.store===this&&t.delete(e);e=e._store.get(`$parent`)}}keys(){return Array.from(this._store.keys())}has(e){return this._store.has(e)}getObserverStats(){let e={},t=0;for(let[n,r]of this.observers)e[n]=r.size,t+=r.size;return{totalKeys:this.observers.size,totalObservers:t,byKey:e}}effect(e,t){return e.call(this.proxify(e))}$computed(e){return{[K]:!0,fn:e,dirty:!0}}proxify(t){let n=Array.from(this._store.entries()).map(([e])=>e),r=Object.fromEntries(n.map(e=>[e,null])),i=(e,t,n)=>typeof e==`function`&&t!==`constructor`?(...t)=>e.call(n,...t):e;return new Proxy(r,{has:(e,t)=>typeof t==`string`&&(Q(this,t)||Reflect.has(this,t))?!0:Reflect.has(r,t),get:(n,r,a)=>{if(typeof r==`string`){if(Q(this,r)){let n=this.get(r,t);return t&&n instanceof e?n.proxify(t):i(n,r,a)}if(t&&r!==Y&&!Reflect.has(this,r))return this.set(r,void 0),this.get(r,t)}return r===`$`?this.proxify(t):i(Reflect.get(this,r,a),r,a)},set:(e,t,n,r)=>(typeof t!=`string`||t in this?Reflect.set(this,t,n,r):(this._computedDepth>0&&console.warn(`[mancha] Computed wrote to '${t}'. Computeds should be pure; use $effect for side effects.`),this.set(t,n)),!0)})}get $(){return this.proxify()}makeEvalFunction(e){return(t,n)=>{let r=_e(e,J),i=new Proxy(n,{has(e,n){return n in e||n in t||n in globalThis},get(e,n){if(typeof n==`string`)return n in e?e[n]:n in t?t[n]:n in globalThis?globalThis[n]:t[n]},set(e,n,r){return typeof n==`string`?n in e?(e[n]=r,!0):(t[n]=r,!0):!1}});return r?.evaluate(i)}}cachedExpressionFunction(e){e=e.trim(),this.expressionCache.has(e)||this.expressionCache.set(e,this.makeEvalFunction(e));let t=this.expressionCache.get(e);if(!t)throw Error(`Failed to retrieve cached expression: ${e}`);return t}eval(e,t={}){let n=this.$;if(this._store.has(e))return n[e];{let r=this.cachedExpressionFunction(e);try{return r(n,t)}catch(t){return console.error(`Failed to evaluate expression: ${e}`),console.error(t),null}}}$resolve(e,t){let n={$pending:!0,$result:null,$error:null};return Promise.resolve().then(()=>e(t)).then(e=>{n.$result=e}).catch(e=>{n.$error=e instanceof Error?e:Error(String(e))}).finally(()=>{n.$pending=!1}),n}},be=class e extends ${_debugLevel=`off`;dirpath=``;_perfData={lifecycle:{},effects:new Map};static DEBUG_LEVELS=[`off`,`lifecycle`,`effects`,`verbose`];_skipNodes=new Set;_customElements=new Map;_pendingValueRetries=[];debug(e){return typeof e==`boolean`?this._debugLevel=e?`lifecycle`:`off`:this._debugLevel=e,this}get debugging(){return this._debugLevel!==`off`}shouldLog(t){return e.DEBUG_LEVELS.indexOf(this._debugLevel)>=e.DEBUG_LEVELS.indexOf(t)}clearPerformanceReport(){this._perfData={lifecycle:{},effects:new Map}}getNodePath(e){let t=[],n=e;for(;n?.tagName;){let e=n.tagName.toLowerCase(),r=n.parentElement;if(r){let i=Array.from(r.children).filter(t=>t.tagName.toLowerCase()===e);if(i.length>1){let r=i.indexOf(n)+1;t.unshift(`${e}:nth-child(${r})`)}else t.unshift(e)}else t.unshift(e);n=r}return t.join(`>`)}buildObserverId(e){let t=e?.directive??`unknown`,n=E(e?.expression??``,32),r=e?.element,i=e?.id??(r?r.dataset?.perfid??r.id??r.dataset?.testid??this.getNodePath(r):`unknown`);return n?`${t}:${i}:${n}`:`${t}:${i}`}recordObserverExecution(e,t){let n=this.buildObserverId(e),r=this._perfData.effects.get(n)??{count:0,totalTime:0};r.count++,r.totalTime+=t,this._perfData.effects.set(n,r)}getPerformanceReport(){let e=Array.from(this._perfData.effects.entries()),t={};for(let[n,r]of e){let e=n.split(`:`)[0];t[e]||(t[e]={count:0,totalTime:0}),t[e].count+=r.count,t[e].totalTime+=r.totalTime}let n=e.map(([e,t])=>({id:e,executionCount:t.count,totalTime:t.totalTime,avgTime:t.count>0?t.totalTime/t.count:0})).sort((e,t)=>t.totalTime-e.totalTime).slice(0,10);return{lifecycle:this._perfData.lifecycle,effects:{total:e.length,byDirective:t,slowest:n},observers:this.getObserverStats()}}effect(e,t){let n=this;function r(){if(!n.shouldLog(`lifecycle`))return e.call(this);let r=performance.now(),i=e.call(this),a=performance.now()-r;return t&&n.recordObserverExecution(t,a),a>16&&console.warn(`[mancha] Slow observer (${a.toFixed(1)}ms):`,n.buildObserverId(t)),n.shouldLog(`effects`)&&console.debug(`[mancha] Observer (${a.toFixed(2)}ms):`,n.buildObserverId(t)),i}return super.effect(r,t)}async fetchRemote(e,t){return fetch(e,{cache:t?.cache??`default`}).then(e=>e.text())}async fetchLocal(e,t){return this.fetchRemote(e,t)}async preprocessString(e,t){this.log(`Preprocessing string content with params:
29
29
  `,t);let n=this.parseHTML(e,t);return await this.preprocessNode(n,t),n}async preprocessRemote(e,t){let n={};t?.cache&&(n.cache=t.cache);let r=await fetch(e,n).then(e=>e.text());return this.preprocessString(r,{...t,dirpath:O(e),rootDocument:t?.rootDocument??!e.endsWith(`.tpl.html`)})}async preprocessLocal(e,t){let n=await this.fetchLocal(e,t);return this.preprocessString(n,{...t,dirpath:O(e),rootDocument:t?.rootDocument??!e.endsWith(`.tpl.html`)})}subrenderer(){let e=new this.constructor().debug(this.debugging);return e._store.set(`$parent`,this),e._store.set(`$rootRenderer`,this.get(`$rootRenderer`)??this),e._customElements=this._customElements,e}log(...e){this.shouldLog(`verbose`)&&console.debug(...e)}async preprocessNode(e,t){let n=this.shouldLog(`lifecycle`)?performance.now():0;t={dirpath:this.dirpath,maxdepth:10,...t};let r=new A(o(e,this._skipNodes)).map(async e=>{this.log(`Preprocessing node:
30
30
  `,D(e,128)),await j.resolveIncludes.call(this,e,t),await j.rebaseRelativePaths.call(this,e,t),await j.registerCustomElements.call(this,e,t),await j.resolveCustomElements.call(this,e,t)});return await Promise.all(r.generator()),n&&(this._perfData.lifecycle.preprocessTime=(this._perfData.lifecycle.preprocessTime??0)+(performance.now()-n)),e}async renderNode(e,t){let n=this.shouldLog(`lifecycle`)?performance.now():0;for(let n of o(e,this._skipNodes))this.log(`Rendering node:
31
31
  `,D(n,128)),await j.resolveForAttribute.call(this,n,t),await j.resolveRenderAttribute.call(this,n,t),await j.resolveDataAttribute.call(this,n,t),await j.resolveTextAttributes.call(this,n,t),await j.resolveHtmlAttribute.call(this,n,t),await j.resolveIfAttribute.call(this,n,t),await j.resolveShowAttribute.call(this,n,t),await j.resolveClassAttribute.call(this,n,t),await j.resolveBindAttribute.call(this,n,t),await j.resolveEventAttributes.call(this,n,t),await j.resolveTextNodeExpressions.call(this,n,t),await j.resolveCustomAttribute.call(this,n,t),await j.resolveCustomProperty.call(this,n,t),await j.stripTypes.call(this,n,t);for(let e of this._pendingValueRetries.splice(0))e();return n&&(this._perfData.lifecycle.renderTime=(this._perfData.lifecycle.renderTime??0)+(performance.now()-n)),e}async mount(e,t){let n=this.shouldLog(`lifecycle`)?performance.now():0;n&&this.clearPerformanceReport(),t={...t,rootNode:e},h(e,`renderer`,this),this._store.set(`$rootNode`,e),this.has(`$rootRenderer`)||this._store.set(`$rootRenderer`,this),this.get(`$rootRenderer`)===this&&await re(this),await this.preprocessNode(e,t),await this.renderNode(e,t),n&&(this._perfData.lifecycle.mountTime=performance.now()-n)}};export{O as n,be as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./renderer-C2znMiAH.js";import{safeDomParser as n}from"safevalues/dom";import{HtmlSanitizerBuilder as r}from"safevalues";const i=`:data,:for,:key,:text,:html,:show,:if,:class,:bind,:render,:on:click,:on:click.prevent,:on:input,:on:input.prevent,:on:change,:on:change.prevent,:on:submit,:on:submit.prevent,:attr:src,:attr:href,:attr:title,:attr:data-testid,:prop:src,:prop:href,:prop:checked,:prop:selected,:prop:disabled`.split(`,`),a=e=>`data-${e.slice(1).replace(`:`,`-`)}`,o=i.map(e=>a(e)),s=[`data-testid`,`data-perfid`],c=[...o,...s];var l=class extends t{impl=`safe_browser`;dirpath=e(globalThis.location?.href??`http://localhost/`);parseHTML(e,t={rootDocument:!1}){for(let t of i)e=e.replace(RegExp(`\\s:${t.slice(1)}=`,`g`),` data-${t.slice(1).replace(`:`,`-`)}=`);e=e.replace(/<include(.*) src="([^"]+)"(.*)><\/include>/g,`<link $1 rel="subresource" href="$2" $3>`),e=e.replace(/<template is="([^"]+)">([\s\S]*)<\/template>/g,`<div role="template" alt="$1">$2</div>`),e=e.replace(/<(\w+)-(\w+)(.*)>([\s\S]*)<\/(\w+)-(\w+)>/g,`<div role="$1-$2" $3>$4</div>`);let a=new r().allowDataAttributes(c).allowClassAttributes().allowStyleAttributes().build();if(this.log(`parseHTML`,e),this.log(`sanitized`,String(a.sanitize(e))),t.rootDocument){let t=new DOMParser;return n.parseFromString(t,a.sanitize(e),`text/html`)}else return a.sanitizeToFragment(e)}serializeHTML(e){return new XMLSerializer().serializeToString(e).replace(/\s?xmlns="[^"]+"/gm,``)}preprocessLocal(e,t){return this.preprocessRemote(e,t)}createElement(e,t){return(t||document).createElement(e)}createComment(e,t){return(t||document).createComment(e)}textContent(e,t){e.textContent=t}};const u=new l;export{u as Mancha,l as Renderer};
1
+ import{n as e,t}from"./renderer-D5EM0ZYN.js";import{safeDomParser as n}from"safevalues/dom";import{HtmlSanitizerBuilder as r}from"safevalues";const i=`:data,:for,:key,:text,:html,:show,:if,:class,:bind,:render,:on:click,:on:click.prevent,:on:input,:on:input.prevent,:on:change,:on:change.prevent,:on:submit,:on:submit.prevent,:attr:src,:attr:href,:attr:title,:attr:data-testid,:prop:src,:prop:href,:prop:checked,:prop:selected,:prop:disabled`.split(`,`),a=e=>`data-${e.slice(1).replace(`:`,`-`)}`,o=i.map(e=>a(e)),s=[`data-testid`,`data-perfid`],c=[...o,...s];var l=class extends t{impl=`safe_browser`;dirpath=e(globalThis.location?.href??`http://localhost/`);parseHTML(e,t={rootDocument:!1}){for(let t of i)e=e.replace(RegExp(`\\s:${t.slice(1)}=`,`g`),` data-${t.slice(1).replace(`:`,`-`)}=`);e=e.replace(/<include(.*) src="([^"]+)"(.*)><\/include>/g,`<link $1 rel="subresource" href="$2" $3>`),e=e.replace(/<template is="([^"]+)">([\s\S]*)<\/template>/g,`<div role="template" alt="$1">$2</div>`),e=e.replace(/<(\w+)-(\w+)(.*)>([\s\S]*)<\/(\w+)-(\w+)>/g,`<div role="$1-$2" $3>$4</div>`);let a=new r().allowDataAttributes(c).allowClassAttributes().allowStyleAttributes().build();if(this.log(`parseHTML`,e),this.log(`sanitized`,String(a.sanitize(e))),t.rootDocument){let t=new DOMParser;return n.parseFromString(t,a.sanitize(e),`text/html`)}else return a.sanitizeToFragment(e)}serializeHTML(e){return new XMLSerializer().serializeToString(e).replace(/\s?xmlns="[^"]+"/gm,``)}preprocessLocal(e,t){return this.preprocessRemote(e,t)}createElement(e,t){return(t||document).createElement(e)}createComment(e,t){return(t||document).createComment(e)}textContent(e,t){e.textContent=t}};const u=new l;export{u as Mancha,l as Renderer};
package/dist/store.js CHANGED
@@ -230,15 +230,18 @@ export class SignalStore {
230
230
  finally {
231
231
  this._notify.delete(key);
232
232
  }
233
- // Lazy cleanup: remove observers whose store's $rootNode is disconnected.
233
+ // Lazy cleanup: remove observers whose store's $rootNode is orphaned.
234
234
  // This handles memory leaks from removed :for items, replaced :html content, etc.
235
235
  // Only applies to subrenderers (stores with $parent) - root renderer observers persist.
236
+ // A node is considered orphaned if it's both disconnected AND has no parent node.
237
+ // Nodes inside a DocumentFragment (e.g., during mount before DOM attachment)
238
+ // have parentNode != null and should NOT be cleaned up.
236
239
  const observerSet = owner?.observers.get(key);
237
240
  if (observerSet) {
238
241
  for (const entry of entries) {
239
242
  const hasParent = entry.store._store.has("$parent");
240
243
  const rootNode = entry.store._store.get("$rootNode");
241
- if (hasParent && rootNode && !rootNode.isConnected) {
244
+ if (hasParent && rootNode && !rootNode.isConnected && !rootNode.parentNode) {
242
245
  observerSet.delete(entry);
243
246
  }
244
247
  }