mancha 0.13.4 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- const t={};function e(t){0}class i{constructor(t,e){this.privateDoNotAccessOrElseWrappedAttributePrefix=e}toString(){return this.privateDoNotAccessOrElseWrappedAttributePrefix}}const s=i;function r(t){if(function(t){return t instanceof i}(t))return t.privateDoNotAccessOrElseWrappedAttributePrefix;throw new Error("")}function n(t){return Object.isFrozen(t)&&Object.isFrozen(t.raw)}function a(t){return-1===t.toString().indexOf("`")}a((t=>t``))||a((t=>t`\0`))||a((t=>t`\n`))||a((t=>t`\u0000`)),n``&&n`\0`&&n`\n`&&n`\u0000`;function o(e){const i=e[0].toLowerCase();return new s(t,i)}let l,c="google#safe";function h(){var t;return""!==c&&null!==(t=function(){if("undefined"!=typeof window)return window.trustedTypes}())&&void 0!==t?t:null}class u{constructor(t,i){e(),this.privateDoNotAccessOrElseWrappedHtml=t}toString(){return this.privateDoNotAccessOrElseWrappedHtml.toString()}}function d(e,i){return null!=i?i:new u(e,t)}"undefined"!=typeof window&&window.TrustedHTML;function p(t){var e;const i=t;return d(i,null===(e=function(){var t,e;if(void 0===l)try{l=null!==(e=null===(t=h())||void 0===t?void 0:t.createPolicy(c,{createHTML:t=>t,createScript:t=>t,createScriptURL:t=>t}))&&void 0!==e?e:null}catch(t){l=null}return l}())||void 0===e?void 0:e.createHTML(i))}function f(t){var e;if(null===(e=h())||void 0===e?void 0:e.isHTML(t))return t;if(t instanceof u)return t.privateDoNotAccessOrElseWrappedHtml;throw new Error("")}"undefined"!=typeof window&&window.TrustedScriptURL;"undefined"!=typeof window&&window.TrustedScript;function _(t,e){e.appendChild(t);let i=(new XMLSerializer).serializeToString(e);return i=i.slice(i.indexOf(">")+1,i.lastIndexOf("</")),p(i)}const m=["data:","http:","https:","mailto:","ftp:"],E=/^\s*(?!javascript:)(?:[\w+.-]+:|[^:/?#]*(?:[/?#]|$))/i;function v(t){if(!function(t){const e=!E.test(t);return e}(t))return t}function w(t){return v(t)}function b(t){const e=function(t){let e;try{e=new URL(t)}catch(t){return"https:"}return e.protocol}(t);return void 0!==e&&-1!==m.indexOf(e.toLowerCase())?t:"about:invalid#zClosurez"}function g(t,e){const i=e.createRange();i.selectNode(e.body);return function(t,e){return t.createContextualFragment(f(e))}(i,p(t))}function A(t){const e=t.nodeName;return"string"==typeof e?e:"FORM"}function y(t){return 3===t.nodeType}function T(t){const e=t.nodeType;return 1===e||"number"!=typeof e}var R,O;function N(t){try{return new URL(t,window.document.baseURI)}catch(t){return new URL("about:invalid")}}function I(t){return{valueOf:t}.valueOf()}!function(t){t[t.STYLE_TAG=0]="STYLE_TAG",t[t.STYLE_ATTRIBUTE=1]="STYLE_ATTRIBUTE",t[t.HTML_ATTRIBUTE=2]="HTML_ATTRIBUTE"}(R||(R={}));class P{constructor(t,e,i,s,r){this.allowedElements=t,this.elementPolicies=e,this.allowedGlobalAttributes=i,this.globalAttributePolicies=s,this.globallyAllowedAttributePrefixes=r}isAllowedElement(t){return"FORM"!==t&&(this.allowedElements.has(t)||this.elementPolicies.has(t))}getAttributePolicy(t,e){const i=this.elementPolicies.get(e);if(null==i?void 0:i.has(t))return i.get(t);if(this.allowedGlobalAttributes.has(t))return{policyAction:O.KEEP};const s=this.globalAttributePolicies.get(t);return s||(this.globallyAllowedAttributePrefixes&&[...this.globallyAllowedAttributePrefixes].some((e=>0===t.indexOf(e)))?{policyAction:O.KEEP}:{policyAction:O.DROP})}}!function(t){t[t.DROP=0]="DROP",t[t.KEEP=1]="KEEP",t[t.KEEP_AND_SANITIZE_URL=2]="KEEP_AND_SANITIZE_URL",t[t.KEEP_AND_NORMALIZE=3]="KEEP_AND_NORMALIZE",t[t.KEEP_AND_SANITIZE_STYLE=4]="KEEP_AND_SANITIZE_STYLE",t[t.KEEP_AND_USE_RESOURCE_URL_POLICY=5]="KEEP_AND_USE_RESOURCE_URL_POLICY",t[t.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET=6]="KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET"}(O||(O={}));const x=new Set(["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"]);const S=["ARTICLE","SECTION","NAV","ASIDE","H1","H2","H3","H4","H5","H6","HEADER","FOOTER","ADDRESS","P","HR","PRE","BLOCKQUOTE","OL","UL","LH","LI","DL","DT","DD","FIGURE","FIGCAPTION","MAIN","DIV","EM","STRONG","SMALL","S","CITE","Q","DFN","ABBR","RUBY","RB","RT","RTC","RP","DATA","TIME","CODE","VAR","SAMP","KBD","SUB","SUP","I","B","U","MARK","BDI","BDO","SPAN","BR","WBR","INS","DEL","PICTURE","PARAM","TRACK","MAP","TABLE","CAPTION","COLGROUP","COL","TBODY","THEAD","TFOOT","TR","TD","TH","SELECT","DATALIST","OPTGROUP","OPTION","OUTPUT","PROGRESS","METER","FIELDSET","LEGEND","DETAILS","SUMMARY","MENU","DIALOG","SLOT","CANVAS","FONT","CENTER","ACRONYM","BASEFONT","BIG","DIR","HGROUP","STRIKE","TT"],C=[["A",new Map([["href",{policyAction:O.KEEP_AND_SANITIZE_URL}]])],["AREA",new Map([["href",{policyAction:O.KEEP_AND_SANITIZE_URL}]])],["LINK",new Map([["href",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY,conditions:new Map([["rel",new Set(["alternate","author","bookmark","canonical","cite","help","icon","license","next","prefetch","dns-prefetch","prerender","preconnect","preload","prev","search","subresource"])]])}]])],["SOURCE",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["IMG",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["VIDEO",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}]])],["AUDIO",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}]])]],L=["title","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-current","aria-disabled","aria-dropeffect","aria-expanded","aria-haspopup","aria-hidden","aria-invalid","aria-label","aria-level","aria-live","aria-multiline","aria-multiselectable","aria-orientation","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","alt","align","autocapitalize","autocomplete","autocorrect","autofocus","autoplay","bgcolor","border","cellpadding","cellspacing","checked","color","cols","colspan","controls","datetime","disabled","download","draggable","enctype","face","formenctype","frameborder","height","hreflang","hidden","ismap","label","lang","loop","max","maxlength","media","minlength","min","multiple","muted","nonce","open","placeholder","preload","rel","required","reversed","role","rows","rowspan","selected","shape","size","sizes","slot","span","spellcheck","start","step","summary","translate","type","valign","value","width","wrap","itemscope","itemtype","itemid","itemprop","itemref"],k=[["dir",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["dir",new Set(["auto","ltr","rtl"])]])))}],["async",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["async",new Set(["async"])]])))}],["cite",{policyAction:O.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["loading",new Set(["eager","lazy"])]])))}],["poster",{policyAction:O.KEEP_AND_SANITIZE_URL}],["target",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["target",new Set(["_self","_blank"])]])))}]],D=new P(new Set(S),new Map(C),new Set(L),new Map(k));new P(new Set(I((()=>S.concat(["STYLE"])))),new Map(C),new Set(I((()=>L.concat(["id","name","class"])))),new Map(I((()=>k.concat([["style",{policyAction:O.KEEP_AND_SANITIZE_STYLE}]])))));class U{constructor(t,i,s,r,n){this.sanitizerTable=t,this.styleElementSanitizer=s,this.styleAttributeSanitizer=r,this.resourceUrlPolicy=n,this.changes=[],e()}sanitizeAssertUnchanged(t){return this.sanitize(t)}sanitize(t){const e=document.implementation.createHTMLDocument("");return _(this.sanitizeToFragmentInternal(t,e),e.body)}sanitizeToFragment(t){const e=document.implementation.createHTMLDocument("");return this.sanitizeToFragmentInternal(t,e)}sanitizeToFragmentInternal(t,e){const i=g(t,e),s=document.createTreeWalker(i,5,(t=>this.nodeFilter(t)));let r=s.nextNode();const n=e.createDocumentFragment();let a=n;for(;null!==r;){let t;if(y(r))if(this.styleElementSanitizer&&"STYLE"===a.nodeName){const e=this.styleElementSanitizer(r.data);t=this.createTextNode(e)}else t=this.sanitizeTextNode(r);else{if(!T(r)){throw new Error("")}t=this.sanitizeElementNode(r,e)}if(a.appendChild(t),r=s.firstChild(),r)a=t;else for(;!(r=s.nextSibling())&&(r=s.parentNode());)a=a.parentNode}return n}createTextNode(t){return document.createTextNode(t)}sanitizeTextNode(t){return this.createTextNode(t.data)}sanitizeElementNode(t,e){const i=A(t),s=e.createElement(i),r=t.attributes;for(const{name:t,value:e}of r){const n=this.sanitizerTable.getAttributePolicy(t,i);if(this.satisfiesAllConditions(n.conditions,r))switch(n.policyAction){case O.KEEP:z(s,t,e);break;case O.KEEP_AND_SANITIZE_URL:const r=b(e);r!==e&&this.recordChange(`Url in attribute ${t} was modified during sanitization. Original url:"${e}" was sanitized to: "${r}"`),z(s,t,r);break;case O.KEEP_AND_NORMALIZE:z(s,t,e.toLowerCase());break;case O.KEEP_AND_SANITIZE_STYLE:if(this.styleAttributeSanitizer){z(s,t,this.styleAttributeSanitizer(e))}else z(s,t,e);break;case O.KEEP_AND_USE_RESOURCE_URL_POLICY:if(this.resourceUrlPolicy){const r={type:R.HTML_ATTRIBUTE,attributeName:t,tagName:i},n=N(e),a=this.resourceUrlPolicy(n,r);a&&z(s,t,a.toString())}else z(s,t,e);break;case O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET:if(this.resourceUrlPolicy){const r={type:R.HTML_ATTRIBUTE,attributeName:t,tagName:i},n=$(e),a={parts:[]};for(const t of n.parts){const e=N(t.url),i=this.resourceUrlPolicy(e,r);i&&a.parts.push({url:i.toString(),descriptor:t.descriptor})}z(s,t,M(a))}else z(s,t,e);break;case O.DROP:this.recordChange(`Attribute: ${t} was dropped`)}else this.recordChange(`Not all conditions satisfied for attribute: ${t}.`)}return s}nodeFilter(t){if(y(t))return 1;if(!T(t))return 2;const e=A(t);return null===e?(this.recordChange(`Node name was null for node: ${t}`),2):this.sanitizerTable.isAllowedElement(e)?1:(this.recordChange(`Element: ${e} was dropped`),2)}recordChange(t){0}satisfiesAllConditions(t,e){var i;if(!t)return!0;for(const[s,r]of t){const t=null===(i=e.getNamedItem(s))||void 0===i?void 0:i.value;if(t&&!r.has(t))return!1}return!0}}function z(t,e,i){t.setAttribute(e,i)}function $(t){const e=[];for(const i of t.split(",")){const[t,s]=i.trim().split(/\s+/,2);e.push({url:t,descriptor:s})}return{parts:e}}function M(t){return t.parts.map((t=>{const{url:e,descriptor:i}=t;return`${e}${i?` ${i}`:""}`})).join(" , ")}class F{constructor(){this.calledBuild=!1,this.sanitizerTable=D}onlyAllowElements(t){const e=new Set,i=new Map;for(let s of t){if(s=s.toUpperCase(),!this.sanitizerTable.isAllowedElement(s))throw new Error(`Element: ${s}, is not allowed by html5_contract.textpb`);const t=this.sanitizerTable.elementPolicies.get(s);void 0!==t?i.set(s,t):e.add(s)}return this.sanitizerTable=new P(e,i,this.sanitizerTable.allowedGlobalAttributes,this.sanitizerTable.globalAttributePolicies),this}allowCustomElement(t,e){const i=new Set(this.sanitizerTable.allowedElements),s=new Map(this.sanitizerTable.elementPolicies);if(t=t.toUpperCase(),r=t,x.has(r.toUpperCase())||!/^[a-z][-_.a-z0-9]*-[-_.a-z0-9]*$/i.test(r))throw new Error(`Element: ${t} is not a custom element`);var r;if(e){const i=new Map;for(const t of e)i.set(t,{policyAction:O.KEEP});s.set(t,i)}else i.add(t);return this.sanitizerTable=new P(i,s,this.sanitizerTable.allowedGlobalAttributes,this.sanitizerTable.globalAttributePolicies),this}onlyAllowAttributes(t){const e=new Set,i=new Map,s=new Map;for(const s of t)this.sanitizerTable.allowedGlobalAttributes.has(s)&&e.add(s),this.sanitizerTable.globalAttributePolicies.has(s)&&i.set(s,this.sanitizerTable.globalAttributePolicies.get(s));for(const[e,i]of this.sanitizerTable.elementPolicies.entries()){const r=new Map;for(const[e,s]of i.entries())t.has(e)&&r.set(e,s);s.set(e,r)}return this.sanitizerTable=new P(this.sanitizerTable.allowedElements,s,e,i),this}allowDataAttributes(t){const e=new Set(this.sanitizerTable.allowedGlobalAttributes);for(const i of t){if(0!==i.indexOf("data-"))throw new Error(`data attribute: ${i} does not begin with the prefix "data-"`);e.add(i)}return this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,e,this.sanitizerTable.globalAttributePolicies),this}allowStyleAttributes(){const t=new Map(this.sanitizerTable.globalAttributePolicies);return t.set("style",{policyAction:O.KEEP_AND_SANITIZE_STYLE}),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,this.sanitizerTable.allowedGlobalAttributes,t),this}allowClassAttributes(){const t=new Set(this.sanitizerTable.allowedGlobalAttributes);return t.add("class"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,t,this.sanitizerTable.globalAttributePolicies),this}allowIdAttributes(){const t=new Set(this.sanitizerTable.allowedGlobalAttributes);return t.add("id"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,t,this.sanitizerTable.globalAttributePolicies),this}allowIdReferenceAttributes(){const t=new Set(this.sanitizerTable.allowedGlobalAttributes);return t.add("aria-activedescendant").add("aria-controls").add("aria-labelledby").add("aria-owns").add("for").add("list"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,t,this.sanitizerTable.globalAttributePolicies),this}withResourceUrlPolicy(t){return this.resourceUrlPolicy=t,this}build(){if(this.calledBuild)throw new Error("this sanitizer has already called build");return this.calledBuild=!0,new U(this.sanitizerTable,t,void 0,void 0,this.resourceUrlPolicy)}}function G(t,e,i,s){if(0===t.length){throw new Error("")}const n=t.map((t=>r(t))),a=i.toLowerCase();if(n.every((t=>0!==a.indexOf(t))))throw new Error(`Attribute "${i}" does not match any of the allowed prefixes.`);e.setAttribute(i,s)}function K(t,e,i){return t.parseFromString(f(e),i)}Error;const W=[o`:`,o`style`,o`class`];function*Y(t,e=new Set){const i=new Set,s=Array.from(t.childNodes).filter((t=>!e.has(t)));for(yield t;s.length;){const t=s.shift();i.has(t)||(i.add(t),yield t),t.childNodes&&Array.from(t.childNodes).filter((t=>!e.has(t))).forEach((t=>s.push(t)))}}function H(t,e){return void 0!==t?.[e]}function B(t,e){return"function"==typeof t?.[e]}function V(t){return t.replace(/-./g,(t=>t[1].toUpperCase()))}function Z(t,e){return H(t,"attribs")?t.attribs?.[e]??null:t.getAttribute?.(e)??null}function j(t,e,i=""){return Z(t,i+e)||(t.dataset?.[V(e)]??null)}function q(t,e,i){H(t,"attribs")?t.attribs[e]=i:t.setAttribute?.(e,i)}function X(t,e,i){H(t,"attribs")?t.attribs[e]=i:G(W,t,e,i)}function Q(t,e,i){switch(e){case"disabled":return void(t.disabled=i);case"selected":return void(t.selected=i);case"checked":return void(t.checked=i);default:t[e]=i}}function J(t,e){H(t,"attribs")?delete t.attribs[e]:t.removeAttribute?.(e)}function tt(t,e,i=""){J(t,`${i}${e}`),J(t,`data-${e}`)}function et(t,e,i){if(H(t,"attribs")&&H(e,"attribs"))e.attribs[i]=t.attribs[i];else if(i.startsWith("data-")){const s=V(i.slice(5));e.dataset[s]=t.dataset?.[s]}else{const s=t?.getAttribute?.(i);X(e,i,s||"")}}function it(t){if(H(t,"firstElementChild"))return t.firstElementChild;return Array.from(t.children).find((t=>1===t.nodeType))}function st(t,...e){if(B(t,"replaceWith"))return t.replaceWith(...e);{const i=t,s=i.parentNode,r=Array.from(s.childNodes).indexOf(i);e.forEach((t=>t.parentNode=s)),s.childNodes=[].concat(Array.from(s.childNodes).slice(0,r)).concat(e).concat(Array.from(s.childNodes).slice(r+1))}}function rt(t,...e){B(t,"replaceChildren")?t.replaceChildren(...e):(t.childNodes=e,e.forEach((e=>e.parentNode=t)))}function nt(t,e){return B(e,"appendChild")?t.appendChild(e):(t.childNodes.push(e),e.parentNode=t,e)}function at(t,e){return B(e,"removeChild")?t.removeChild(e):(rt(t,...Array.from(t.childNodes).filter((t=>t!==e))),e)}function ot(t,e,i){return i?B(t,"insertBefore")?t.insertBefore(e,i):(st(i,e,i),e):nt(t,e)}function lt(t,e=0){return t?t.length<=e?t:t.slice(0,e-1)+"…":""}function ct(t,e=0){return globalThis.DocumentFragment&&t instanceof DocumentFragment?Array.from(t.childNodes).map((t=>ct(t,e))).join(""):lt(t.outerHTML||t.nodeValue||String(t),e)}function ht(t){return t.includes("/")?t.split("/").slice(0,-1).join("/"):""}class ut{iterable;constructor(t){this.iterable=t}filter(t){return new ut(ut.filterGenerator(t,this.iterable))}map(t){return new ut(ut.mapGenerator(t,this.iterable))}find(t){for(const e of this.iterable)if(t(e))return e}array(){return Array.from(this.iterable)}*generator(){for(const t of this.iterable)yield t}static*filterGenerator(t,e){for(const i of e)t(i)&&(yield i)}static*mapGenerator(t,e){for(const i of e)yield t(i)}static equals(t,e){const i=t[Symbol.iterator](),s=e[Symbol.iterator]();let r=i.next(),n=s.next();for(;!r.done&&!n.done;){if(r.value!==n.value)return!1;r=i.next(),n=s.next()}return r.done===n.done}}var dt;!function(t){t.resolveIncludes=async function(t,e){const i=t,s=i.tagName?.toLowerCase();if(!["include","link"].includes(s))return;if("link"===s&&"subresource"!==Z(i,"rel"))return;this.log("include directive found in:\n",ct(t,128)),this.log("include params:",e);const r="link"===i.tagName.toLocaleLowerCase()?"href":"src",n=Z(i,r);if(!n)throw new Error(`"${r}" attribute missing from ${ct(t,128)}.`);const a=[];"include"===s&&a.push("src"),"link"===s&&a.push("rel","href");const o=e=>{const s=it(e);for(const t of Array.from(i.attributes))s&&!a.includes(t.name)&&et(i,s,t.name);st(t,...e.childNodes)},l={...e,rootDocument:!1,maxdepth:e?.maxdepth-1};if(0===l.maxdepth)throw new Error("Maximum recursion depth reached.");if(n.includes("://")||n.startsWith("//"))this.log("Including remote file from absolute path:",n),await this.preprocessRemote(n,l).then(o);else if(e?.dirpath?.includes("://")||e?.dirpath?.startsWith("//")){const t=n.startsWith("/")?n:`${e.dirpath}/${n}`;this.log("Including remote file from relative path:",t),await this.preprocessRemote(t,l).then(o)}else if("/"===n.charAt(0))this.log("Including local file from absolute path:",n),await this.preprocessLocal(n,l).then(o);else{const t=e?.dirpath&&"."!==e?.dirpath?`${e?.dirpath}/${n}`:n;this.log("Including local file from relative path:",t),await this.preprocessLocal(t,l).then(o)}},t.rebaseRelativePaths=async function(t,e){const i=t,s=i.tagName?.toLowerCase();if(!e?.dirpath)return;const r=Z(i,"src"),n=Z(i,"href"),a=r||n;if(!a||((o=a).includes("://")||o.startsWith("/")||o.startsWith("#")||o.startsWith("data:")))return;var o;const l=`${e.dirpath}/${a}`;this.log("Rebasing relative path as:",l),H(i,"attribs")?X(i,r?"src":"href",l):"img"===s?i.src=l:"a"===s?function(t,e){const i=w(e);void 0!==i&&(t.href=i)}(i,l):"source"===s||"audio"===s||"video"===s||"track"===s||"input"===s?i.src=l:"area"===s?function(t,e){const i=w(e);void 0!==i&&(t.href=i)}(i,l):this.log("Unable to rebase relative path for element:",s)},t.registerCustomElements=async function(t,e){const i=t,s=i.tagName?.toLowerCase(),r=(Z(i,"is")||Z(i,"alt"))?.toLowerCase();if(["template","div"].includes(s)&&r){if("div"===s&&"template"!==Z(i,"role"))return;this._customElements.has(r)||(this.log(`Registering custom element: ${r}\n`,ct(i,128)),this._customElements.set(r,i),at(i.parentNode,i))}},t.resolveCustomElements=async function(t,e){const i=t,s=i.tagName?.toLowerCase();let r=s;if("div"===r&&(r=Z(i,"role")?.toLowerCase()||r),r&&this._customElements.has(r)){this.log(`Processing custom element: ${r}\n`,ct(i,128));const e=this._customElements.get(r),n=(e.content||e).cloneNode(!0),a=it(n);if(a)for(const t of Array.from(i.attributes))"div"===s&&"role"===t.name||et(i,a,t.name);const o=new ut(Y(n)).find((t=>"slot"===t.tagName?.toLowerCase()));o&&st(o,...i.childNodes),st(t,...n.childNodes)}},t.resolveTextNodeExpressions=async function(t,e){const i=t.nodeValue||"";if(3!==t.nodeType||!i?.trim())return;this.log("Processing node content value:\n",lt(i,128));const s=new RegExp(/{{ ([^}]+) }}/gm),r=Array.from(i.matchAll(s)).map((t=>t[1]));return this.effect((function(){let e=i;for(const i of r){const s=this.eval(i,{$elem:t});e=e.replace(`{{ ${i} }}`,String(s))}t.nodeValue=e}))},t.resolveDataAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"data",":");if(s){this.log(":data attribute found in:\n",ct(t,128)),tt(i,"data",":");const r=e?.rootNode===t?this:this.subrenderer();t.renderer=r;const n=r.eval(s,{$elem:t});if(await Promise.all(Object.entries(n).map((([t,e])=>r.set(t,e)))),r!==this)for(const e of Y(t,this._skipNodes))this._skipNodes.add(e);await r.mount(t,e)}},t.resolveClassAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"class",":");if(s){this.log(":class attribute found in:\n",ct(t,128)),tt(i,"class",":");const e=Z(i,"class")||"";return this.effect((function(){const r=this.eval(s,{$elem:t});X(i,"class",(r?`${e} ${r}`:e).trim())}))}},t.resolveTextAttributes=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"text",":");if(s){this.log(":text attribute found in:\n",ct(t,128)),tt(i,"text",":");const e=e=>this.textContent(t,e);return this.effect((function(){e(this.eval(s,{$elem:t}))}))}},t.resolveHtmlAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"html",":");return s?(this.log(":html attribute found in:\n",ct(t,128)),tt(i,"html",":"),this.effect((function(){const r=this.eval(s,{$elem:t});return new Promise((async t=>{const s=await this.preprocessString(r,e);await this.renderNode(s),rt(i,s),t()}))}))):void 0},t.resolveEventAttributes=async function(t,e){if(this._skipNodes.has(t))return;const i=t;for(const e of Array.from(i.attributes||[]))if(e.name.startsWith(":on:")||e.name.startsWith("data-on-")){const s=e.name.split(":on:",2).at(-1)?.split("data-on-",2).at(-1)||"";if(!s)throw new Error(`Invalid event attribute: ${e.name}`);this.log(e.name,"attribute found in:\n",ct(t,128)),J(i,e.name);const r="submit"===s&&"FORM"===i.tagName.toUpperCase();t.addEventListener?.(s,(i=>(r&&i.preventDefault(),this.eval(e.value,{$elem:t,$event:i}))))}},t.resolveForAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"for",":")?.trim();if(s){this.log(":for attribute found in:\n",ct(t,128)),tt(i,"for",":");for(const e of Y(t,this._skipNodes))this._skipNodes.add(e);const r=Z(i,"style")||"";q(i,"style","display: none;");const n=t.parentNode,a=this.createElement("template",t.ownerDocument);ot(n,a,t),at(n,t),nt(a,t),this.log(":for template:\n",ct(a,128));const o=s.split(" in ",2);if(2!==o.length)throw new Error(`Invalid :for format: \`${s}\`. Expected "{key} in {expression}".`);const l=[],[c,h]=o;await this.effect((function(){const i=this.eval(h,{$elem:t});if(this.log(":for list items:",i),l.splice(0,l.length).forEach((t=>{at(n,t),this._skipNodes.delete(t)})),!Array.isArray(i))return console.error(`Expression did not yield a list: \`${h}\` => \`${i}\``),Promise.resolve();const s=[];for(const n of i){const i=this.subrenderer();i.set(c,n);const a=t.cloneNode(!0);q(a,"style",r),l.push(a),this._skipNodes.add(a),s.push(i.mount(a,e)),this.log("Rendered list child:\n",ct(a,128))}const o=a.nextSibling;for(const t of l)ot(n,t,o);return Promise.all(s)}))}},t.resolveBindAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"bind",":");if(s){this.log(":bind attribute found in:\n",ct(t,128));const e=["change","input"],r=Z(i,":bind:on")?.split(",")||i.dataset?.bindOn?.split(",")||e;tt(i,"bind",":"),J(i,":bind:on"),J(i,"data-bind-on");const n="checkbox"===Z(i,"type")?"checked":"value";this.effect((function(){const e=this.eval(s,{$elem:t});"checked"===n?i.checked=!!e:i.value=e}));const a=`${s} = $elem.${n}`;for(const e of r)t.addEventListener(e,(()=>this.eval(a,{$elem:t})))}},t.resolveShowAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"show",":");if(s){this.log(":show attribute found in:\n",ct(t,128)),tt(i,"show",":");const e="none"===i.style?.display?"":i.style?.display??Z(i,"style")?.split(";")?.find((t=>"display"===t.split(":")[0]))?.split(":")?.at(1)?.trim();this.effect((function(){const r=this.eval(s,{$elem:t});i.style?i.style.display=r?e:"none":X(i,"style",`display: ${r?e:"none"};`)}))}},t.resolveCustomAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t;for(const e of Array.from(i.attributes||[])){const s=":attr:",r="data-attr-";if(e.name.startsWith(s)||e.name.startsWith(r)){this.log(e.name,"attribute found in:\n",ct(t,128)),J(i,e.name);const n=e.name.split(s,2).at(-1)?.split(r,2).at(-1);this.effect((function(){const s=this.eval(e.value,{$elem:t});q(i,n,s)}))}}},t.resolveCustomProperty=async function(t,e){if(this._skipNodes.has(t))return;const i=t;for(const e of Array.from(i.attributes||[])){const s=":prop:",r="data-prop-";if(e.name.startsWith(s)||e.name.startsWith(r)){this.log(e.name,"property found in:\n",ct(t,128)),J(i,e.name);const n=e.name.split(s,2).at(-1)?.split(r,2).at(-1),a=V(n);this.effect((function(){const s=this.eval(e.value,{$elem:t});Q(i,a,s)}))}}}}(dt||(dt={}));const pt=["this"],ft=["+","-","!"],_t=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],mt={"!":0,":":0,",":0,")":0,"]":0,"}":0,"|>":1,"?":2,"??":3,"||":4,"&&":5,"|":6,"^":7,"&":8,"!=":9,"==":9,"!==":9,"===":9,">=":10,">":10,"<=":10,"<":10,"+":11,"-":11,"%":12,"/":12,"*":12,"(":13,"[":13,".":13,"{":13},Et=["==","!=","<=",">=","||","&&","??","|>"],vt=["===","!=="];var wt;!function(t){t[t.STRING=1]="STRING",t[t.IDENTIFIER=2]="IDENTIFIER",t[t.DOT=3]="DOT",t[t.COMMA=4]="COMMA",t[t.COLON=5]="COLON",t[t.INTEGER=6]="INTEGER",t[t.DECIMAL=7]="DECIMAL",t[t.OPERATOR=8]="OPERATOR",t[t.GROUPER=9]="GROUPER",t[t.KEYWORD=10]="KEYWORD",t[t.ARROW=11]="ARROW"}(wt||(wt={}));const bt=(t,e,i=0)=>({kind:t,value:e,precedence:i}),gt=t=>95===t||36===t||65<=(t&=-33)&&t<=90,At=t=>48<=t&&t<=57;class yt{_input;_index=-1;_tokenStart=0;_next;constructor(t){this._input=t,this._advance()}nextToken(){for(;9===(t=this._next)||10===t||13===t||32===t;)this._advance(!0);var t;if((t=>34===t||39===t)(this._next))return this._tokenizeString();if(gt(this._next))return this._tokenizeIdentOrKeyword();if(At(this._next))return this._tokenizeNumber();if(46===this._next)return this._tokenizeDot();if(44===this._next)return this._tokenizeComma();if(58===this._next)return this._tokenizeColon();if((t=>43===t||45===t||42===t||47===t||33===t||38===t||37===t||60===t||61===t||62===t||63===t||94===t||124===t)(this._next))return this._tokenizeOperator();if((t=>40===t||41===t||91===t||93===t||123===t||125===t)(this._next))return this._tokenizeGrouper();if(this._advance(),void 0!==this._next)throw new Error(`Expected end of input, got ${this._next}`)}_advance(t){this._index++,this._index<this._input.length?(this._next=this._input.charCodeAt(this._index),!0===t&&(this._tokenStart=this._index)):this._next=void 0}_getValue(t=0){const e=this._input.substring(this._tokenStart,this._index+t);return 0===t&&this._clearValue(),e}_clearValue(){this._tokenStart=this._index}_tokenizeString(){const t="unterminated string",e=this._next;for(this._advance(!0);this._next!==e;){if(void 0===this._next)throw new Error(t);if(92===this._next&&(this._advance(),void 0===this._next))throw new Error(t);this._advance()}const i=bt(wt.STRING,this._getValue().replace(/\\(.)/g,((t,e)=>{switch(e){case"n":return"\n";case"r":return"\r";case"t":return"\t";case"b":return"\b";case"f":return"\f";default:return e}})));return this._advance(),i}_tokenizeIdentOrKeyword(){do{this._advance()}while(t=this._next,gt(t)||At(t));var t;const e=this._getValue(),i=(s=e,-1!==pt.indexOf(s)?wt.KEYWORD:wt.IDENTIFIER);var s;return bt(i,e)}_tokenizeNumber(){do{this._advance()}while(At(this._next));return 46===this._next?this._tokenizeDot():bt(wt.INTEGER,this._getValue())}_tokenizeDot(){return this._advance(),At(this._next)?this._tokenizeFraction():(this._clearValue(),bt(wt.DOT,".",13))}_tokenizeComma(){return this._advance(!0),bt(wt.COMMA,",")}_tokenizeColon(){return this._advance(!0),bt(wt.COLON,":")}_tokenizeFraction(){do{this._advance()}while(At(this._next));return bt(wt.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let t=this._getValue(2);if(-1!==vt.indexOf(t))this._advance(),this._advance();else{if(t=this._getValue(1),"=>"===t)return this._advance(),bt(wt.ARROW,t);-1!==Et.indexOf(t)&&this._advance()}return t=this._getValue(),bt(wt.OPERATOR,t,mt[t])}_tokenizeGrouper(){const t=String.fromCharCode(this._next),e=bt(wt.GROUPER,t,mt[t]);return this._advance(!0),e}}class Tt{_kind;_tokenizer;_ast;_token;_value;constructor(t,e){this._tokenizer=new yt(t),this._ast=e}parse(){return this._advance(),this._parseExpression()}_advance(t,e){if(!this._matches(t,e))throw new Error(`Expected kind ${t} (${e}), was ${this._token?.kind} (${this._token?.value})`);const i=this._tokenizer.nextToken();this._token=i,this._kind=i?.kind,this._value=i?.value}_matches(t,e){return!(t&&this._kind!==t||e&&this._value!==e)}_parseExpression(){if(!this._token)return this._ast.empty();const t=this._parseUnary();return void 0===t?void 0:this._parsePrecedence(t,0)}_parsePrecedence(t,e){if(void 0===t)throw new Error("Expected left to be defined.");for(;this._token;)if(this._matches(wt.GROUPER,"(")){const e=this._parseArguments();t=this._ast.invoke(t,void 0,e)}else if(this._matches(wt.GROUPER,"[")){const e=this._parseIndex();t=this._ast.index(t,e)}else if(this._matches(wt.DOT)){this._advance();const e=this._parseUnary();t=this._makeInvokeOrGetter(t,e)}else{if(this._matches(wt.KEYWORD))break;if(!(this._matches(wt.OPERATOR)&&this._token.precedence>=e))break;t="?"===this._value?this._parseTernary(t):this._parseBinary(t,this._token)}return t}_makeInvokeOrGetter(t,e){if(void 0===e)throw new Error("expected identifier");if("ID"===e.type)return this._ast.getter(t,e.value);if("Invoke"===e.type&&"ID"===e.receiver.type){const i=e.receiver;return this._ast.invoke(t,i.value,e.arguments)}throw new Error(`expected identifier: ${e}`)}_parseBinary(t,e){if(-1===_t.indexOf(e.value))throw new Error(`unknown operator: ${e.value}`);this._advance();let i=this._parseUnary();for(;(this._kind===wt.OPERATOR||this._kind===wt.DOT||this._kind===wt.GROUPER)&&this._token.precedence>e.precedence;)i=this._parsePrecedence(i,this._token.precedence);return this._ast.binary(t,e.value,i)}_parseUnary(){if(this._matches(wt.OPERATOR)){const t=this._value;if(this._advance(),"+"===t||"-"===t){if(this._matches(wt.INTEGER))return this._parseInteger(t);if(this._matches(wt.DECIMAL))return this._parseDecimal(t)}if(-1===ft.indexOf(t))throw new Error(`unexpected token: ${t}`);const e=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(t,e)}return this._parsePrimary()}_parseTernary(t){this._advance(wt.OPERATOR,"?");const e=this._parseExpression();this._advance(wt.COLON);const i=this._parseExpression();return this._ast.ternary(t,e,i)}_parsePrimary(){switch(this._kind){case wt.KEYWORD:const t=this._value;if("this"===t)return this._advance(),this._ast.id(t);if(-1!==pt.indexOf(t))throw new Error(`unexpected keyword: ${t}`);throw new Error(`unrecognized keyword: ${t}`);case wt.IDENTIFIER:return this._parseInvokeOrIdentifier();case wt.STRING:return this._parseString();case wt.INTEGER:return this._parseInteger();case wt.DECIMAL:return this._parseDecimal();case wt.GROUPER:return"("===this._value?this._parseParenOrFunction():"{"===this._value?this._parseMap():"["===this._value?this._parseList():void 0;case wt.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){const t=[];do{if(this._advance(),this._matches(wt.GROUPER,"]"))break;t.push(this._parseExpression())}while(this._matches(wt.COMMA));return this._advance(wt.GROUPER,"]"),this._ast.list(t)}_parseMap(){const t={};do{if(this._advance(),this._matches(wt.GROUPER,"}"))break;const e=this._value;(this._matches(wt.STRING)||this._matches(wt.IDENTIFIER))&&this._advance(),this._advance(wt.COLON),t[e]=this._parseExpression()}while(this._matches(wt.COMMA));return this._advance(wt.GROUPER,"}"),this._ast.map(t)}_parseInvokeOrIdentifier(){const t=this._value;if("true"===t)return this._advance(),this._ast.literal(!0);if("false"===t)return this._advance(),this._ast.literal(!1);if("null"===t)return this._advance(),this._ast.literal(null);if("undefined"===t)return this._advance(),this._ast.literal(void 0);const e=this._parseIdentifier(),i=this._parseArguments();return i?this._ast.invoke(e,void 0,i):e}_parseIdentifier(){if(!this._matches(wt.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);const t=this._value;return this._advance(),this._ast.id(t)}_parseArguments(){if(!this._matches(wt.GROUPER,"("))return;const t=[];do{if(this._advance(),this._matches(wt.GROUPER,")"))break;const e=this._parseExpression();t.push(e)}while(this._matches(wt.COMMA));return this._advance(wt.GROUPER,")"),t}_parseIndex(){this._advance();const t=this._parseExpression();return this._advance(wt.GROUPER,"]"),t}_parseParenOrFunction(){const t=this._parseArguments();if(this._matches(wt.ARROW)){this._advance();const e=this._parseExpression(),i=t?.map((t=>t.value))??[];return this._ast.arrowFunction(i,e)}return this._ast.paren(t[0])}_parseString(){const t=this._ast.literal(this._value);return this._advance(),t}_parseInteger(t=""){const e=this._ast.literal(parseInt(`${t}${this._value}`,10));return this._advance(),e}_parseDecimal(t=""){const e=this._ast.literal(parseFloat(`${t}${this._value}`));return this._advance(),e}}const Rt={"+":(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,e)=>e(t),"|>":(t,e)=>e(t)},Ot={"+":t=>t,"-":t=>-t,"!":t=>!t};class Nt{timeouts=new Map;debounce(t,e){return new Promise(((i,s)=>{const r=this.timeouts.get(e);r&&clearTimeout(r),this.timeouts.set(e,setTimeout((()=>{try{i(e()),this.timeouts.delete(e)}catch(t){s(t)}}),t))}))}}const It=new class{empty(){return{type:"Empty",evaluate:t=>t,getIds:t=>t}}literal(t){return{type:"Literal",value:t,evaluate(t){return this.value},getIds:t=>t}}id(t){return{type:"ID",value:t,evaluate(t){return"this"===this.value?t:t?.[this.value]},getIds(t){return t.push(this.value),t}}}unary(t,e){const i=Ot[t];return{type:"Unary",operator:t,child:e,evaluate(t){return i(this.child.evaluate(t))},getIds(t){return this.child.getIds(t)}}}binary(t,e,i){const s=Rt[e];return{type:"Binary",operator:e,left:t,right:i,evaluate(t){if("="===this.operator){if("ID"!==this.left.type&&"Getter"!==this.left.type&&"Index"!==this.left.type)throw new Error(`Invalid assignment target: ${this.left}`);const e=this.right.evaluate(t);let i,s;return"Getter"===this.left.type?(i=this.left.receiver.evaluate(t),s=this.left.name):"Index"===this.left.type?(i=this.left.receiver.evaluate(t),s=this.left.argument.evaluate(t)):"ID"===this.left.type&&(i=t,s=this.left.value),void 0===i?void 0:i[s]=e}return s(this.left.evaluate(t),this.right.evaluate(t))},getIds(t){return this.left.getIds(t),this.right.getIds(t),t}}}getter(t,e){return{type:"Getter",receiver:t,name:e,evaluate(t){return this.receiver.evaluate(t)?.[this.name]},getIds(t){return this.receiver.getIds(t),t}}}invoke(t,e,i){if(null!=e&&"string"!=typeof e)throw new Error("method not a string");return{type:"Invoke",receiver:t,method:e,arguments:i,evaluate(t){const i=this.receiver.evaluate(t),s=this.method?i:t?.this??t,r=this.method?i?.[e]:i,n=(this.arguments??[]).map((e=>e?.evaluate(t)));return r?.apply?.(s,n)},getIds(t){return this.receiver.getIds(t),this.arguments?.forEach((e=>e?.getIds(t))),t}}}paren(t){return t}index(t,e){return{type:"Index",receiver:t,argument:e,evaluate(t){return this.receiver.evaluate(t)?.[this.argument.evaluate(t)]},getIds(t){return this.receiver.getIds(t),t}}}ternary(t,e,i){return{type:"Ternary",condition:t,trueExpr:e,falseExpr:i,evaluate(t){return this.condition.evaluate(t)?this.trueExpr.evaluate(t):this.falseExpr.evaluate(t)},getIds(t){return this.condition.getIds(t),this.trueExpr.getIds(t),this.falseExpr.getIds(t),t}}}map(t){return{type:"Map",entries:t,evaluate(e){const i={};if(t&&this.entries)for(const s in t){const t=this.entries[s];t&&(i[s]=t.evaluate(e))}return i},getIds(e){if(t&&this.entries)for(const i in t){const t=this.entries[i];t&&t.getIds(e)}return e}}}list(t){return{type:"List",items:t,evaluate(t){return this.items?.map((e=>e?.evaluate(t)))},getIds(t){return this.items?.forEach((e=>e?.getIds(t))),t}}}arrowFunction(t,e){return{type:"ArrowFunction",params:t,body:e,evaluate(t){const e=this.params,i=this.body;return function(...s){const r=Object.fromEntries(e.map(((t,e)=>[t,s[e]]))),n=new Proxy(t??{},{set:(t,e,i)=>(r.hasOwnProperty(e)&&(r[e]=i),t[e]=i),get:(t,e)=>r.hasOwnProperty(e)?r[e]:t[e]});return i.evaluate(n)}},getIds(t){return this.body.getIds(t).filter((t=>!this.params.includes(t)))}}}};function Pt(t,e){const i=t?._store;return i?.has(e)?i.get(e):i?.has("$parent")?Pt(i.get("$parent"),e):null}function xt(t,e){const i=t?._store;return i?.has(e)?t:i?.has("$parent")?xt(i.get("$parent"),e):null}class St extends Nt{evalkeys=["$elem","$event"];expressionCache=new Map;observers=new Map;_observer=null;_store=new Map;_lock=Promise.resolve();constructor(t){super();for(let[e,i]of Object.entries(t||{}))this.set(e,i)}wrapFunction(t){return(...e)=>t.call(this.$,...e)}wrapObject(t,e){return null==t||((i=t)instanceof St||i.__is_proxy__)||t.constructor!==Object&&!Array.isArray(t)?t:new Proxy(t,{deleteProperty:(t,i)=>i in t&&(delete t[i],e(),!0),set:(i,s,r,n)=>{"object"==typeof r&&null!=t&&(r=this.wrapObject(r,e));const a=Reflect.set(i,s,r,n);return e(),a},get:(t,e,i)=>"__is_proxy__"===e||Reflect.get(t,e,i)});var i}watch(t,e){const i=xt(this,t);if(!i)throw new Error(`Cannot watch key "${t}" as it does not exist in the store.`);i.observers.has(t)||i.observers.set(t,new Set),i.observers.get(t)?.has(e)||i.observers.get(t)?.add(e)}async notify(t,e=10){const i=xt(this,t),s=Array.from(i?.observers.get(t)||[]);await this.debounce(e,(()=>Promise.all(s.map((t=>t.call(this.proxify(t)))))))}get(t,e){return e&&this.watch(t,e),Pt(this,t)}async set(t,e){if(e===this._store.get(t))return;const i=()=>this.notify(t);e&&"function"==typeof e&&(e=this.wrapFunction(e)),e&&"object"==typeof e&&(e=this.wrapObject(e,i)),function(t,e,i){const s=xt(t,e);s?s._store.set(e,i):t._store.set(e,i)}(this,t,e),await i()}del(t){this._store.delete(t),this.observers.delete(t)}has(t){return this._store.has(t)}effect(t){return t.call(this.proxify(t))}proxify(t){const e=Array.from(this._store.entries()).map((([t])=>t)),i=Object.fromEntries(e.map((t=>[t,void 0])));return new Proxy(i,{get:(e,i,s)=>"string"==typeof i&&xt(this,i)?this.get(i,t):"$"===i?this.proxify(t):Reflect.get(this,i,s),set:(t,e,i,s)=>("string"!=typeof e||e in this?Reflect.set(this,e,i,s):this.set(e,i),!0)})}get $(){return this.proxify()}makeEvalFunction(t){if(t.includes(";"))throw new Error("Complex expressions are not supported.");let e=null;if(t.includes(" = ")){const[i,s]=t.split(" = ");e=i.trim(),t=s.trim()}return(i,s)=>{const r=((t,e)=>new Tt(t,e).parse())(t,It),n=r?.getIds([])?.map((t=>[t,s[t]??i[t]??globalThis[t]])),a=r?.evaluate(Object.fromEntries(n||[]));if(!e)return a;!function(t,e,i){const s=e.split(".");for(let e=0;e<s.length-1;e++)s[e]in t||(t[s[e]]={}),t=t[s[e]];t[s[s.length-1]]=i}(i,e,a)}}cachedExpressionFunction(t){return t=t.trim(),this.expressionCache.has(t)||this.expressionCache.set(t,this.makeEvalFunction(t)),this.expressionCache.get(t)}eval(t,e={}){const i=this._observer?this:this.$;if(this._store.has(t))return i[t];{const s=this.cachedExpressionFunction(t);try{return s(i,e)}catch(e){return console.error(`Failed to evaluate expression: ${t}`),console.error(e),null}}}}class Ct extends St{debugging=!1;dirpath="";_skipNodes=new Set;_customElements=new Map;debug(t){return this.debugging=t,this}async fetchRemote(t,e){return fetch(t,{cache:e?.cache??"default"}).then((t=>t.text()))}async fetchLocal(t,e){return this.fetchRemote(t,e)}async preprocessString(t,e){this.log("Preprocessing string content with params:\n",e);const i=this.parseHTML(t,e);return await this.preprocessNode(i,e),i}async preprocessRemote(t,e){const i={};e?.cache&&(i.cache=e.cache);const s=await fetch(t,i).then((t=>t.text()));return this.preprocessString(s,{...e,dirpath:ht(t),rootDocument:e?.rootDocument??!t.endsWith(".tpl.html")})}async preprocessLocal(t,e){const i=await this.fetchLocal(t,e);return this.preprocessString(i,{...e,dirpath:ht(t),rootDocument:e?.rootDocument??!t.endsWith(".tpl.html")})}subrenderer(){const t=(new this.constructor).debug(this.debugging);return t._store.set("$parent",this),t._store.set("$rootRenderer",this.get("$rootRenderer")??this),t._customElements=this._customElements,t}log(...t){this.debugging&&console.debug(...t)}async preprocessNode(t,e){e={dirpath:this.dirpath,maxdepth:10,...e};const i=new ut(Y(t,this._skipNodes)).map((async t=>{this.log("Preprocessing node:\n",ct(t,128)),await dt.resolveIncludes.call(this,t,e),await dt.rebaseRelativePaths.call(this,t,e),await dt.registerCustomElements.call(this,t,e),await dt.resolveCustomElements.call(this,t,e)}));return await Promise.all(i.generator()),t}async renderNode(t,e){for(const i of Y(t,this._skipNodes))this.log("Rendering node:\n",ct(i,128)),await dt.resolveForAttribute.call(this,i,e),await dt.resolveDataAttribute.call(this,i,e),await dt.resolveTextAttributes.call(this,i,e),await dt.resolveHtmlAttribute.call(this,i,e),await dt.resolveShowAttribute.call(this,i,e),await dt.resolveClassAttribute.call(this,i,e),await dt.resolveBindAttribute.call(this,i,e),await dt.resolveEventAttributes.call(this,i,e),await dt.resolveTextNodeExpressions.call(this,i,e),await dt.resolveCustomAttribute.call(this,i,e),await dt.resolveCustomProperty.call(this,i,e);return t}async mount(t,e){e={...e,rootNode:t},Q(t,"renderer",this),this._store.set("$rootNode",t),await this.preprocessNode(t,e),await this.renderNode(t,e)}}const Lt=[":data",":for",":text",":html",":show",":class",":bind",":on:click",":on:input",":on:change",":on:submit",":attr:src",":attr:href",":attr:title",":prop:checked",":prop:selected",":prop:disabled"];class kt extends Ct{impl="safe_browser";dirpath=ht(globalThis.location?.href??"http://localhost/");parseHTML(t,e={rootDocument:!1}){for(const e of Lt)t=t.replace(new RegExp(`\\s:${e.slice(1)}=`,"g"),` data-${e.slice(1).replace(":","-")}=`);t=(t=(t=t.replace(/<include(.*) src="([^"]+)"(.*)><\/include>/g,'<link $1 rel="subresource" href="$2" $3>')).replace(/<template is="([^"]+)">([\s\S]*)<\/template>/g,'<div role="template" alt="$1">$2</div>')).replace(/<(\w+)-(\w+)(.*)>([\s\S]*)<\/(\w+)-(\w+)>/g,'<div role="$1-$2" $3>$4</div>');const i=Lt.map((t=>`data-${t.slice(1).replace(":","-")}`));i.push("data-testid");const s=(new F).allowDataAttributes(i).allowClassAttributes().allowStyleAttributes().build();if(this.log("parseHTML",t),this.log("sanitized",String(s.sanitize(t))),e.rootDocument){return K(new DOMParser,s.sanitize(t),"text/html")}return s.sanitizeToFragment(t)}serializeHTML(t){return(new XMLSerializer).serializeToString(t).replace(/\s?xmlns="[^"]+"/gm,"")}preprocessLocal(t,e){return this.preprocessRemote(t,e)}createElement(t,e){return(e||document).createElement(t)}textContent(t,e){t.textContent=e}}const Dt=new kt;export{Dt as Mancha,kt as Renderer};
1
+ const e={};function t(e){0}class i{constructor(e,t){this.privateDoNotAccessOrElseWrappedAttributePrefix=t}toString(){return this.privateDoNotAccessOrElseWrappedAttributePrefix}}const s=i;function r(e){if(function(e){return e instanceof i}(e))return e.privateDoNotAccessOrElseWrappedAttributePrefix;throw new Error("")}function n(e){return Object.isFrozen(e)&&Object.isFrozen(e.raw)}function a(e){return-1===e.toString().indexOf("`")}a((e=>e``))||a((e=>e`\0`))||a((e=>e`\n`))||a((e=>e`\u0000`)),n``&&n`\0`&&n`\n`&&n`\u0000`;function o(t){const i=t[0].toLowerCase();return new s(e,i)}let l,c="google#safe";function h(){var e;return""!==c&&null!==(e=function(){if("undefined"!=typeof window)return window.trustedTypes}())&&void 0!==e?e:null}class u{constructor(e,i){t(),this.privateDoNotAccessOrElseWrappedHtml=e}toString(){return this.privateDoNotAccessOrElseWrappedHtml.toString()}}function d(t,i){return null!=i?i:new u(t,e)}"undefined"!=typeof window&&window.TrustedHTML;function p(e){var t;const i=e;return d(i,null===(t=function(){var e,t;if(void 0===l)try{l=null!==(t=null===(e=h())||void 0===e?void 0:e.createPolicy(c,{createHTML:e=>e,createScript:e=>e,createScriptURL:e=>e}))&&void 0!==t?t:null}catch(e){l=null}return l}())||void 0===t?void 0:t.createHTML(i))}function f(e){var t;if(null===(t=h())||void 0===t?void 0:t.isHTML(e))return e;if(e instanceof u)return e.privateDoNotAccessOrElseWrappedHtml;throw new Error("")}"undefined"!=typeof window&&window.TrustedScriptURL;"undefined"!=typeof window&&window.TrustedScript;function _(e,t){t.appendChild(e);let i=(new XMLSerializer).serializeToString(t);return i=i.slice(i.indexOf(">")+1,i.lastIndexOf("</")),p(i)}const m=["data:","http:","https:","mailto:","ftp:"],E=/^\s*(?!javascript:)(?:[\w+.-]+:|[^:/?#]*(?:[/?#]|$))/i;function w(e){if(!function(e){const t=!E.test(e);return t}(e))return e}function v(e){return w(e)}function b(e){const t=function(e){let t;try{t=new URL(e)}catch(e){return"https:"}return t.protocol}(e);return void 0!==t&&-1!==m.indexOf(t.toLowerCase())?e:"about:invalid#zClosurez"}function g(e,t){const i=t.createRange();i.selectNode(t.body);return function(e,t){return e.createContextualFragment(f(t))}(i,p(e))}function A(e){const t=e.nodeName;return"string"==typeof t?t:"FORM"}function y(e){return 3===e.nodeType}function R(e){const t=e.nodeType;return 1===t||"number"!=typeof t}var T,O;function N(e){try{return new URL(e,window.document.baseURI)}catch(e){return new URL("about:invalid")}}function I(e){return{valueOf:e}.valueOf()}!function(e){e[e.STYLE_TAG=0]="STYLE_TAG",e[e.STYLE_ATTRIBUTE=1]="STYLE_ATTRIBUTE",e[e.HTML_ATTRIBUTE=2]="HTML_ATTRIBUTE"}(T||(T={}));class P{constructor(e,t,i,s,r){this.allowedElements=e,this.elementPolicies=t,this.allowedGlobalAttributes=i,this.globalAttributePolicies=s,this.globallyAllowedAttributePrefixes=r}isAllowedElement(e){return"FORM"!==e&&(this.allowedElements.has(e)||this.elementPolicies.has(e))}getAttributePolicy(e,t){const i=this.elementPolicies.get(t);if(null==i?void 0:i.has(e))return i.get(e);if(this.allowedGlobalAttributes.has(e))return{policyAction:O.KEEP};const s=this.globalAttributePolicies.get(e);return s||(this.globallyAllowedAttributePrefixes&&[...this.globallyAllowedAttributePrefixes].some((t=>0===e.indexOf(t)))?{policyAction:O.KEEP}:{policyAction:O.DROP})}}!function(e){e[e.DROP=0]="DROP",e[e.KEEP=1]="KEEP",e[e.KEEP_AND_SANITIZE_URL=2]="KEEP_AND_SANITIZE_URL",e[e.KEEP_AND_NORMALIZE=3]="KEEP_AND_NORMALIZE",e[e.KEEP_AND_SANITIZE_STYLE=4]="KEEP_AND_SANITIZE_STYLE",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY=5]="KEEP_AND_USE_RESOURCE_URL_POLICY",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET=6]="KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET"}(O||(O={}));const S=new Set(["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"]);const x=["ARTICLE","SECTION","NAV","ASIDE","H1","H2","H3","H4","H5","H6","HEADER","FOOTER","ADDRESS","P","HR","PRE","BLOCKQUOTE","OL","UL","LH","LI","DL","DT","DD","FIGURE","FIGCAPTION","MAIN","DIV","EM","STRONG","SMALL","S","CITE","Q","DFN","ABBR","RUBY","RB","RT","RTC","RP","DATA","TIME","CODE","VAR","SAMP","KBD","SUB","SUP","I","B","U","MARK","BDI","BDO","SPAN","BR","WBR","INS","DEL","PICTURE","PARAM","TRACK","MAP","TABLE","CAPTION","COLGROUP","COL","TBODY","THEAD","TFOOT","TR","TD","TH","SELECT","DATALIST","OPTGROUP","OPTION","OUTPUT","PROGRESS","METER","FIELDSET","LEGEND","DETAILS","SUMMARY","MENU","DIALOG","SLOT","CANVAS","FONT","CENTER","ACRONYM","BASEFONT","BIG","DIR","HGROUP","STRIKE","TT"],C=[["A",new Map([["href",{policyAction:O.KEEP_AND_SANITIZE_URL}]])],["AREA",new Map([["href",{policyAction:O.KEEP_AND_SANITIZE_URL}]])],["LINK",new Map([["href",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY,conditions:new Map([["rel",new Set(["alternate","author","bookmark","canonical","cite","help","icon","license","next","prefetch","dns-prefetch","prerender","preconnect","preload","prev","search","subresource"])]])}]])],["SOURCE",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["IMG",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["VIDEO",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}]])],["AUDIO",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}]])]],L=["title","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-current","aria-disabled","aria-dropeffect","aria-expanded","aria-haspopup","aria-hidden","aria-invalid","aria-label","aria-level","aria-live","aria-multiline","aria-multiselectable","aria-orientation","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","alt","align","autocapitalize","autocomplete","autocorrect","autofocus","autoplay","bgcolor","border","cellpadding","cellspacing","checked","color","cols","colspan","controls","datetime","disabled","download","draggable","enctype","face","formenctype","frameborder","height","hreflang","hidden","ismap","label","lang","loop","max","maxlength","media","minlength","min","multiple","muted","nonce","open","placeholder","preload","rel","required","reversed","role","rows","rowspan","selected","shape","size","sizes","slot","span","spellcheck","start","step","summary","translate","type","valign","value","width","wrap","itemscope","itemtype","itemid","itemprop","itemref"],k=[["dir",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["dir",new Set(["auto","ltr","rtl"])]])))}],["async",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["async",new Set(["async"])]])))}],["cite",{policyAction:O.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["loading",new Set(["eager","lazy"])]])))}],["poster",{policyAction:O.KEEP_AND_SANITIZE_URL}],["target",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["target",new Set(["_self","_blank"])]])))}]],D=new P(new Set(x),new Map(C),new Set(L),new Map(k));new P(new Set(I((()=>x.concat(["STYLE"])))),new Map(C),new Set(I((()=>L.concat(["id","name","class"])))),new Map(I((()=>k.concat([["style",{policyAction:O.KEEP_AND_SANITIZE_STYLE}]])))));class U{constructor(e,i,s,r,n){this.sanitizerTable=e,this.styleElementSanitizer=s,this.styleAttributeSanitizer=r,this.resourceUrlPolicy=n,this.changes=[],t()}sanitizeAssertUnchanged(e){return this.sanitize(e)}sanitize(e){const t=document.implementation.createHTMLDocument("");return _(this.sanitizeToFragmentInternal(e,t),t.body)}sanitizeToFragment(e){const t=document.implementation.createHTMLDocument("");return this.sanitizeToFragmentInternal(e,t)}sanitizeToFragmentInternal(e,t){const i=g(e,t),s=document.createTreeWalker(i,5,(e=>this.nodeFilter(e)));let r=s.nextNode();const n=t.createDocumentFragment();let a=n;for(;null!==r;){let e;if(y(r))if(this.styleElementSanitizer&&"STYLE"===a.nodeName){const t=this.styleElementSanitizer(r.data);e=this.createTextNode(t)}else e=this.sanitizeTextNode(r);else{if(!R(r)){throw new Error("")}e=this.sanitizeElementNode(r,t)}if(a.appendChild(e),r=s.firstChild(),r)a=e;else for(;!(r=s.nextSibling())&&(r=s.parentNode());)a=a.parentNode}return n}createTextNode(e){return document.createTextNode(e)}sanitizeTextNode(e){return this.createTextNode(e.data)}sanitizeElementNode(e,t){const i=A(e),s=t.createElement(i),r=e.attributes;for(const{name:e,value:t}of r){const n=this.sanitizerTable.getAttributePolicy(e,i);if(this.satisfiesAllConditions(n.conditions,r))switch(n.policyAction){case O.KEEP:z(s,e,t);break;case O.KEEP_AND_SANITIZE_URL:const r=b(t);r!==t&&this.recordChange(`Url in attribute ${e} was modified during sanitization. Original url:"${t}" was sanitized to: "${r}"`),z(s,e,r);break;case O.KEEP_AND_NORMALIZE:z(s,e,t.toLowerCase());break;case O.KEEP_AND_SANITIZE_STYLE:if(this.styleAttributeSanitizer){z(s,e,this.styleAttributeSanitizer(t))}else z(s,e,t);break;case O.KEEP_AND_USE_RESOURCE_URL_POLICY:if(this.resourceUrlPolicy){const r={type:T.HTML_ATTRIBUTE,attributeName:e,tagName:i},n=N(t),a=this.resourceUrlPolicy(n,r);a&&z(s,e,a.toString())}else z(s,e,t);break;case O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET:if(this.resourceUrlPolicy){const r={type:T.HTML_ATTRIBUTE,attributeName:e,tagName:i},n=$(t),a={parts:[]};for(const e of n.parts){const t=N(e.url),i=this.resourceUrlPolicy(t,r);i&&a.parts.push({url:i.toString(),descriptor:e.descriptor})}z(s,e,M(a))}else z(s,e,t);break;case O.DROP:this.recordChange(`Attribute: ${e} was dropped`)}else this.recordChange(`Not all conditions satisfied for attribute: ${e}.`)}return s}nodeFilter(e){if(y(e))return 1;if(!R(e))return 2;const t=A(e);return null===t?(this.recordChange(`Node name was null for node: ${e}`),2):this.sanitizerTable.isAllowedElement(t)?1:(this.recordChange(`Element: ${t} was dropped`),2)}recordChange(e){0}satisfiesAllConditions(e,t){var i;if(!e)return!0;for(const[s,r]of e){const e=null===(i=t.getNamedItem(s))||void 0===i?void 0:i.value;if(e&&!r.has(e))return!1}return!0}}function z(e,t,i){e.setAttribute(t,i)}function $(e){const t=[];for(const i of e.split(",")){const[e,s]=i.trim().split(/\s+/,2);t.push({url:e,descriptor:s})}return{parts:t}}function M(e){return e.parts.map((e=>{const{url:t,descriptor:i}=e;return`${t}${i?` ${i}`:""}`})).join(" , ")}class F{constructor(){this.calledBuild=!1,this.sanitizerTable=D}onlyAllowElements(e){const t=new Set,i=new Map;for(let s of e){if(s=s.toUpperCase(),!this.sanitizerTable.isAllowedElement(s))throw new Error(`Element: ${s}, is not allowed by html5_contract.textpb`);const e=this.sanitizerTable.elementPolicies.get(s);void 0!==e?i.set(s,e):t.add(s)}return this.sanitizerTable=new P(t,i,this.sanitizerTable.allowedGlobalAttributes,this.sanitizerTable.globalAttributePolicies),this}allowCustomElement(e,t){const i=new Set(this.sanitizerTable.allowedElements),s=new Map(this.sanitizerTable.elementPolicies);if(e=e.toUpperCase(),r=e,S.has(r.toUpperCase())||!/^[a-z][-_.a-z0-9]*-[-_.a-z0-9]*$/i.test(r))throw new Error(`Element: ${e} is not a custom element`);var r;if(t){const i=new Map;for(const e of t)i.set(e,{policyAction:O.KEEP});s.set(e,i)}else i.add(e);return this.sanitizerTable=new P(i,s,this.sanitizerTable.allowedGlobalAttributes,this.sanitizerTable.globalAttributePolicies),this}onlyAllowAttributes(e){const t=new Set,i=new Map,s=new Map;for(const s of e)this.sanitizerTable.allowedGlobalAttributes.has(s)&&t.add(s),this.sanitizerTable.globalAttributePolicies.has(s)&&i.set(s,this.sanitizerTable.globalAttributePolicies.get(s));for(const[t,i]of this.sanitizerTable.elementPolicies.entries()){const r=new Map;for(const[t,s]of i.entries())e.has(t)&&r.set(t,s);s.set(t,r)}return this.sanitizerTable=new P(this.sanitizerTable.allowedElements,s,t,i),this}allowDataAttributes(e){const t=new Set(this.sanitizerTable.allowedGlobalAttributes);for(const i of e){if(0!==i.indexOf("data-"))throw new Error(`data attribute: ${i} does not begin with the prefix "data-"`);t.add(i)}return this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,t,this.sanitizerTable.globalAttributePolicies),this}allowStyleAttributes(){const e=new Map(this.sanitizerTable.globalAttributePolicies);return e.set("style",{policyAction:O.KEEP_AND_SANITIZE_STYLE}),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,this.sanitizerTable.allowedGlobalAttributes,e),this}allowClassAttributes(){const e=new Set(this.sanitizerTable.allowedGlobalAttributes);return e.add("class"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,e,this.sanitizerTable.globalAttributePolicies),this}allowIdAttributes(){const e=new Set(this.sanitizerTable.allowedGlobalAttributes);return e.add("id"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,e,this.sanitizerTable.globalAttributePolicies),this}allowIdReferenceAttributes(){const e=new Set(this.sanitizerTable.allowedGlobalAttributes);return e.add("aria-activedescendant").add("aria-controls").add("aria-labelledby").add("aria-owns").add("for").add("list"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,e,this.sanitizerTable.globalAttributePolicies),this}withResourceUrlPolicy(e){return this.resourceUrlPolicy=e,this}build(){if(this.calledBuild)throw new Error("this sanitizer has already called build");return this.calledBuild=!0,new U(this.sanitizerTable,e,void 0,void 0,this.resourceUrlPolicy)}}function G(e,t,i,s){if(0===e.length){throw new Error("")}const n=e.map((e=>r(e))),a=i.toLowerCase();if(n.every((e=>0!==a.indexOf(e))))throw new Error(`Attribute "${i}" does not match any of the allowed prefixes.`);t.setAttribute(i,s)}function K(e,t,i){return e.parseFromString(f(t),i)}Error;const H=[o`:`,o`style`,o`class`];function*W(e,t=new Set){const i=new Set,s=Array.from(e.childNodes).filter((e=>!t.has(e)));for(yield e;s.length;){const e=s.shift();i.has(e)||(i.add(e),yield e),e.childNodes&&Array.from(e.childNodes).filter((e=>!t.has(e))).forEach((e=>s.push(e)))}}function Y(e,t){return void 0!==e?.[t]}function B(e,t){return"function"==typeof e?.[t]}function V(e){return e.replace(/-./g,(e=>e[1].toUpperCase()))}function Z(e,t){return Y(e,"attribs")?e.attribs?.[t]??null:e.getAttribute?.(t)??null}function j(e,t,i=""){return Z(e,i+t)||(e.dataset?.[V(t)]??null)}function q(e,t,i){Y(e,"attribs")?e.attribs[t]=i:e.setAttribute?.(t,i)}function X(e,t,i){Y(e,"attribs")?e.attribs[t]=i:G(H,e,t,i)}function Q(e,t,i){switch(t){case"disabled":return void(e.disabled=i);case"selected":return void(e.selected=i);case"checked":return void(e.checked=i);default:e[t]=i}}function J(e,t){Y(e,"attribs")?delete e.attribs[t]:e.removeAttribute?.(t)}function ee(e,t,i=""){J(e,`${i}${t}`),J(e,`data-${t}`)}function te(e,t,i){if(Y(e,"attribs")&&Y(t,"attribs"))t.attribs[i]=e.attribs[i];else if(i.startsWith("data-")){const s=V(i.slice(5));t.dataset[s]=e.dataset?.[s]}else{const s=e?.getAttribute?.(i);X(t,i,s||"")}}function ie(e){if(Y(e,"firstElementChild"))return e.firstElementChild;return Array.from(e.children).find((e=>1===e.nodeType))}function se(e,...t){if(B(e,"replaceWith"))return e.replaceWith(...t);{const i=e,s=i.parentNode,r=Array.from(s.childNodes).indexOf(i);t.forEach((e=>e.parentNode=s)),s.childNodes=[].concat(Array.from(s.childNodes).slice(0,r)).concat(t).concat(Array.from(s.childNodes).slice(r+1))}}function re(e,...t){B(e,"replaceChildren")?e.replaceChildren(...t):(e.childNodes=t,t.forEach((t=>t.parentNode=e)))}function ne(e,t){return B(t,"appendChild")?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,t)}function ae(e,t){return B(t,"removeChild")?e.removeChild(t):(re(e,...Array.from(e.childNodes).filter((e=>e!==t))),t)}function oe(e,t,i){return i?B(e,"insertBefore")?e.insertBefore(t,i):(se(i,t,i),t):ne(e,t)}function le(e,t=0){return e?e.length<=t?e:e.slice(0,t-1)+"…":""}function ce(e,t=0){return globalThis.DocumentFragment&&e instanceof DocumentFragment?Array.from(e.childNodes).map((e=>ce(e,t))).join(""):le(e.outerHTML||e.nodeValue||String(e),t)}function he(e){return e.includes("/")?e.split("/").slice(0,-1).join("/"):""}class ue{iterable;constructor(e){this.iterable=e}filter(e){return new ue(ue.filterGenerator(e,this.iterable))}map(e){return new ue(ue.mapGenerator(e,this.iterable))}find(e){for(const t of this.iterable)if(e(t))return t}array(){return Array.from(this.iterable)}*generator(){for(const e of this.iterable)yield e}static*filterGenerator(e,t){for(const i of t)e(i)&&(yield i)}static*mapGenerator(e,t){for(const i of t)yield e(i)}static equals(e,t){const i=e[Symbol.iterator](),s=t[Symbol.iterator]();let r=i.next(),n=s.next();for(;!r.done&&!n.done;){if(r.value!==n.value)return!1;r=i.next(),n=s.next()}return r.done===n.done}}var de;!function(e){e.resolveIncludes=async function(e,t){const i=e,s=i.tagName?.toLowerCase();if(!["include","link"].includes(s))return;if("link"===s&&"subresource"!==Z(i,"rel"))return;this.log("include directive found in:\n",ce(e,128)),this.log("include params:",t);const r="link"===i.tagName.toLocaleLowerCase()?"href":"src",n=Z(i,r);if(!n)throw new Error(`"${r}" attribute missing from ${ce(e,128)}.`);const a=[];"include"===s&&a.push("src"),"link"===s&&a.push("rel","href");const o=t=>{const s=ie(t);for(const e of Array.from(i.attributes))s&&!a.includes(e.name)&&te(i,s,e.name);se(e,...t.childNodes)},l={...t,rootDocument:!1,maxdepth:t?.maxdepth-1};if(0===l.maxdepth)throw new Error("Maximum recursion depth reached.");if(n.includes("://")||n.startsWith("//"))this.log("Including remote file from absolute path:",n),await this.preprocessRemote(n,l).then(o);else if(t?.dirpath?.includes("://")||t?.dirpath?.startsWith("//")){const e=n.startsWith("/")?n:`${t.dirpath}/${n}`;this.log("Including remote file from relative path:",e),await this.preprocessRemote(e,l).then(o)}else if("/"===n.charAt(0))this.log("Including local file from absolute path:",n),await this.preprocessLocal(n,l).then(o);else{const e=t?.dirpath&&"."!==t?.dirpath?`${t?.dirpath}/${n}`:n;this.log("Including local file from relative path:",e),await this.preprocessLocal(e,l).then(o)}},e.rebaseRelativePaths=async function(e,t){const i=e,s=i.tagName?.toLowerCase();if(!t?.dirpath)return;const r=Z(i,"src"),n=Z(i,"href"),a=r||n;if(!a||((o=a).includes("://")||o.startsWith("/")||o.startsWith("#")||o.startsWith("data:")))return;var o;const l=`${t.dirpath}/${a}`;this.log("Rebasing relative path as:",l),Y(i,"attribs")?X(i,r?"src":"href",l):"img"===s?i.src=l:"a"===s?function(e,t){const i=v(t);void 0!==i&&(e.href=i)}(i,l):"source"===s||"audio"===s||"video"===s||"track"===s||"input"===s?i.src=l:"area"===s?function(e,t){const i=v(t);void 0!==i&&(e.href=i)}(i,l):this.log("Unable to rebase relative path for element:",s)},e.registerCustomElements=async function(e,t){const i=e,s=i.tagName?.toLowerCase(),r=(Z(i,"is")||Z(i,"alt"))?.toLowerCase();if(["template","div"].includes(s)&&r){if("div"===s&&"template"!==Z(i,"role"))return;this._customElements.has(r)||(this.log(`Registering custom element: ${r}\n`,ce(i,128)),this._customElements.set(r,i),ae(i.parentNode,i))}},e.resolveCustomElements=async function(e,t){const i=e,s=i.tagName?.toLowerCase();let r=s;if("div"===r&&(r=Z(i,"role")?.toLowerCase()||r),r&&this._customElements.has(r)){this.log(`Processing custom element: ${r}\n`,ce(i,128));const t=this._customElements.get(r),n=(t.content||t).cloneNode(!0),a=ie(n);if(a)for(const e of Array.from(i.attributes))"div"===s&&"role"===e.name||te(i,a,e.name);const o=new ue(W(n)).find((e=>"slot"===e.tagName?.toLowerCase()));o&&se(o,...i.childNodes),se(e,...n.childNodes)}},e.resolveTextNodeExpressions=async function(e,t){const i=e.nodeValue||"";if(3!==e.nodeType||!i?.trim())return;this.log("Processing node content value:\n",le(i,128));const s=new RegExp(/{{ ([^}]+) }}/gm),r=Array.from(i.matchAll(s)).map((e=>e[1]));return this.effect((function(){let t=i;for(const i of r){const s=this.eval(i,{$elem:e});t=t.replace(`{{ ${i} }}`,String(s))}e.nodeValue=t}))},e.resolveDataAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,s=j(i,"data",":");if(s){this.log(":data attribute found in:\n",ce(e,128)),ee(i,"data",":");const r=t?.rootNode===e?this:this.subrenderer();e.renderer=r;const n=r.eval(s,{$elem:e});if(await Promise.all(Object.entries(n).map((([e,t])=>r._store.set(e,t)))),r!==this)for(const t of W(e,this._skipNodes))this._skipNodes.add(t);await r.mount(e,t)}},e.resolveClassAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,s=j(i,"class",":");if(s){this.log(":class attribute found in:\n",ce(e,128)),ee(i,"class",":");const t=Z(i,"class")||"";return this.effect((function(){const r=this.eval(s,{$elem:e});X(i,"class",(r?`${t} ${r}`:t).trim())}))}},e.resolveTextAttributes=async function(e,t){if(this._skipNodes.has(e))return;const i=e,s=j(i,"text",":");if(s){this.log(":text attribute found in:\n",ce(e,128)),ee(i,"text",":");const t=t=>this.textContent(e,t);return this.effect((function(){t(this.eval(s,{$elem:e}))}))}},e.resolveHtmlAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,s=j(i,"html",":");return s?(this.log(":html attribute found in:\n",ce(e,128)),ee(i,"html",":"),this.effect((function(){const r=this.eval(s,{$elem:e});return new Promise((async e=>{const s=await this.preprocessString(r,t);await this.renderNode(s),re(i,s),e()}))}))):void 0},e.resolveEventAttributes=async function(e,t){if(this._skipNodes.has(e))return;const i=e;for(const t of Array.from(i.attributes||[]))if(t.name.startsWith(":on:")||t.name.startsWith("data-on-")){const s=t.name.split(":on:",2).at(-1)?.split("data-on-",2).at(-1)||"";if(!s)throw new Error(`Invalid event attribute: ${t.name}`);this.log(t.name,"attribute found in:\n",ce(e,128)),J(i,t.name);const r="submit"===s&&"FORM"===i.tagName.toUpperCase();e.addEventListener?.(s,(i=>(r&&i.preventDefault(),this.eval(t.value,{$elem:e,$event:i}))))}},e.resolveForAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,s=j(i,"for",":")?.trim();if(s){this.log(":for attribute found in:\n",ce(e,128)),ee(i,"for",":");for(const t of W(e,this._skipNodes))this._skipNodes.add(t);const r=Z(i,"style")||"";q(i,"style","display: none;");const n=e.parentNode,a=this.createElement("template",e.ownerDocument);oe(n,a,e),ae(n,e),ne(a,e),this.log(":for template:\n",ce(a,128));const o=s.split(" in ",2);if(2!==o.length)throw new Error(`Invalid :for format: \`${s}\`. Expected "{key} in {expression}".`);const l=[],[c,h]=o;await this.effect((function(){const i=this.eval(h,{$elem:e});if(this.log(":for list items:",i),l.splice(0,l.length).forEach((e=>{ae(n,e),this._skipNodes.delete(e)})),!Array.isArray(i))return console.error(`Expression did not yield a list: \`${h}\` => \`${i}\``),Promise.resolve();const s=[];for(const n of i){const i=this.subrenderer();i._store.set(c,n);const a=e.cloneNode(!0);q(a,"style",r),l.push(a),this._skipNodes.add(a),s.push(i.mount(a,t)),this.log("Rendered list child:\n",ce(a,128))}const o=a.nextSibling;for(const e of l)oe(n,e,o);return Promise.all(s)}))}},e.resolveBindAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,s=j(i,"bind",":");if(s){this.log(":bind attribute found in:\n",ce(e,128));const t=["change","input"],r=Z(i,":bind:on")?.split(",")||i.dataset?.bindOn?.split(",")||t;ee(i,"bind",":"),J(i,":bind:on"),J(i,"data-bind-on");const n="checkbox"===Z(i,"type")?"checked":"value";s.includes(".")||this.has(s)||this.set(s,null),this.effect((function(){const t=this.eval(s,{$elem:e});"checked"===n?i.checked=!!t:i.value=t}));const a=`${s} = $elem.${n}`;for(const t of r)e.addEventListener(t,(()=>this.eval(a,{$elem:e})))}},e.resolveShowAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,s=j(i,"show",":");if(s){this.log(":show attribute found in:\n",ce(e,128)),ee(i,"show",":");const t="none"===i.style?.display?"":i.style?.display??Z(i,"style")?.split(";")?.find((e=>"display"===e.split(":")[0]))?.split(":")?.at(1)?.trim();this.effect((function(){const r=this.eval(s,{$elem:e});i.style?i.style.display=r?t:"none":X(i,"style",`display: ${r?t:"none"};`)}))}},e.resolveCustomAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e;for(const t of Array.from(i.attributes||[])){const s=":attr:",r="data-attr-";if(t.name.startsWith(s)||t.name.startsWith(r)){this.log(t.name,"attribute found in:\n",ce(e,128)),J(i,t.name);const n=t.name.split(s,2).at(-1)?.split(r,2).at(-1);this.effect((function(){const s=this.eval(t.value,{$elem:e});q(i,n,s)}))}}},e.resolveCustomProperty=async function(e,t){if(this._skipNodes.has(e))return;const i=e;for(const t of Array.from(i.attributes||[])){const s=":prop:",r="data-prop-";if(t.name.startsWith(s)||t.name.startsWith(r)){this.log(t.name,"property found in:\n",ce(e,128)),J(i,t.name);const n=t.name.split(s,2).at(-1)?.split(r,2).at(-1),a=V(n);this.effect((function(){const s=this.eval(t.value,{$elem:e});Q(i,a,s)}))}}}}(de||(de={}));const pe=["this"],fe=["+","-","!"],_e=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],me={"!":0,":":0,",":0,")":0,"]":0,"}":0,"|>":1,"?":2,"??":3,"||":4,"&&":5,"|":6,"^":7,"&":8,"!=":9,"==":9,"!==":9,"===":9,">=":10,">":10,"<=":10,"<":10,"+":11,"-":11,"%":12,"/":12,"*":12,"(":13,"[":13,".":13,"{":13},Ee=["==","!=","<=",">=","||","&&","??","|>"],we=["===","!=="];var ve;!function(e){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"}(ve||(ve={}));const be=(e,t,i=0)=>({kind:e,value:t,precedence:i}),ge=e=>95===e||36===e||65<=(e&=-33)&&e<=90,Ae=e=>48<=e&&e<=57;class ye{_input;_index=-1;_tokenStart=0;_next;constructor(e){this._input=e,this._advance()}nextToken(){for(;9===(e=this._next)||10===e||13===e||32===e;)this._advance(!0);var e;if((e=>34===e||39===e)(this._next))return this._tokenizeString();if(ge(this._next))return this._tokenizeIdentOrKeyword();if(Ae(this._next))return this._tokenizeNumber();if(46===this._next)return this._tokenizeDot();if(44===this._next)return this._tokenizeComma();if(58===this._next)return this._tokenizeColon();if((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===e)(this._next))return this._tokenizeOperator();if((e=>40===e||41===e||91===e||93===e||123===e||125===e)(this._next))return this._tokenizeGrouper();if(this._advance(),void 0!==this._next)throw new Error(`Expected end of input, got ${this._next}`)}_advance(e){this._index++,this._index<this._input.length?(this._next=this._input.charCodeAt(this._index),!0===e&&(this._tokenStart=this._index)):this._next=void 0}_getValue(e=0){const t=this._input.substring(this._tokenStart,this._index+e);return 0===e&&this._clearValue(),t}_clearValue(){this._tokenStart=this._index}_tokenizeString(){const e="unterminated string",t=this._next;for(this._advance(!0);this._next!==t;){if(void 0===this._next)throw new Error(e);if(92===this._next&&(this._advance(),void 0===this._next))throw new Error(e);this._advance()}const i=be(ve.STRING,this._getValue().replace(/\\(.)/g,((e,t)=>{switch(t){case"n":return"\n";case"r":return"\r";case"t":return"\t";case"b":return"\b";case"f":return"\f";default:return t}})));return this._advance(),i}_tokenizeIdentOrKeyword(){do{this._advance()}while(e=this._next,ge(e)||Ae(e));var e;const t=this._getValue(),i=(s=t,-1!==pe.indexOf(s)?ve.KEYWORD:ve.IDENTIFIER);var s;return be(i,t)}_tokenizeNumber(){do{this._advance()}while(Ae(this._next));return 46===this._next?this._tokenizeDot():be(ve.INTEGER,this._getValue())}_tokenizeDot(){return this._advance(),Ae(this._next)?this._tokenizeFraction():(this._clearValue(),be(ve.DOT,".",13))}_tokenizeComma(){return this._advance(!0),be(ve.COMMA,",")}_tokenizeColon(){return this._advance(!0),be(ve.COLON,":")}_tokenizeFraction(){do{this._advance()}while(Ae(this._next));return be(ve.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(-1!==we.indexOf(e))this._advance(),this._advance();else{if(e=this._getValue(1),"=>"===e)return this._advance(),be(ve.ARROW,e);-1!==Ee.indexOf(e)&&this._advance()}return e=this._getValue(),be(ve.OPERATOR,e,me[e])}_tokenizeGrouper(){const e=String.fromCharCode(this._next),t=be(ve.GROUPER,e,me[e]);return this._advance(!0),t}}class Re{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new ye(e),this._ast=t}parse(){return this._advance(),this._parseExpression()}_advance(e,t){if(!this._matches(e,t))throw new Error(`Expected kind ${e} (${t}), was ${this._token?.kind} (${this._token?.value})`);const i=this._tokenizer.nextToken();this._token=i,this._kind=i?.kind,this._value=i?.value}_matches(e,t){return!(e&&this._kind!==e||t&&this._value!==t)}_parseExpression(){if(!this._token)return this._ast.empty();const e=this._parseUnary();return void 0===e?void 0:this._parsePrecedence(e,0)}_parsePrecedence(e,t){if(void 0===e)throw new Error("Expected left to be defined.");for(;this._token;)if(this._matches(ve.GROUPER,"(")){const t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(ve.GROUPER,"[")){const t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(ve.DOT)){this._advance();const t=this._parseUnary();e=this._makeInvokeOrGetter(e,t)}else{if(this._matches(ve.KEYWORD))break;if(!(this._matches(ve.OPERATOR)&&this._token.precedence>=t))break;e="?"===this._value?this._parseTernary(e):this._parseBinary(e,this._token)}return e}_makeInvokeOrGetter(e,t){if(void 0===t)throw new Error("expected identifier");if("ID"===t.type)return this._ast.getter(e,t.value);if("Invoke"===t.type&&"ID"===t.receiver.type){const i=t.receiver;return this._ast.invoke(e,i.value,t.arguments)}throw new Error(`expected identifier: ${t}`)}_parseBinary(e,t){if(-1===_e.indexOf(t.value))throw new Error(`unknown operator: ${t.value}`);this._advance();let i=this._parseUnary();for(;(this._kind===ve.OPERATOR||this._kind===ve.DOT||this._kind===ve.GROUPER)&&this._token.precedence>t.precedence;)i=this._parsePrecedence(i,this._token.precedence);return this._ast.binary(e,t.value,i)}_parseUnary(){if(this._matches(ve.OPERATOR)){const e=this._value;if(this._advance(),"+"===e||"-"===e){if(this._matches(ve.INTEGER))return this._parseInteger(e);if(this._matches(ve.DECIMAL))return this._parseDecimal(e)}if(-1===fe.indexOf(e))throw new Error(`unexpected token: ${e}`);const t=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(e,t)}return this._parsePrimary()}_parseTernary(e){this._advance(ve.OPERATOR,"?");const t=this._parseExpression();this._advance(ve.COLON);const i=this._parseExpression();return this._ast.ternary(e,t,i)}_parsePrimary(){switch(this._kind){case ve.KEYWORD:const e=this._value;if("this"===e)return this._advance(),this._ast.id(e);if(-1!==pe.indexOf(e))throw new Error(`unexpected keyword: ${e}`);throw new Error(`unrecognized keyword: ${e}`);case ve.IDENTIFIER:return this._parseInvokeOrIdentifier();case ve.STRING:return this._parseString();case ve.INTEGER:return this._parseInteger();case ve.DECIMAL:return this._parseDecimal();case ve.GROUPER:return"("===this._value?this._parseParenOrFunction():"{"===this._value?this._parseMap():"["===this._value?this._parseList():void 0;case ve.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){const e=[];do{if(this._advance(),this._matches(ve.GROUPER,"]"))break;e.push(this._parseExpression())}while(this._matches(ve.COMMA));return this._advance(ve.GROUPER,"]"),this._ast.list(e)}_parseMap(){const e={};do{if(this._advance(),this._matches(ve.GROUPER,"}"))break;const t=this._value;(this._matches(ve.STRING)||this._matches(ve.IDENTIFIER))&&this._advance(),this._advance(ve.COLON),e[t]=this._parseExpression()}while(this._matches(ve.COMMA));return this._advance(ve.GROUPER,"}"),this._ast.map(e)}_parseInvokeOrIdentifier(){const e=this._value;if("true"===e)return this._advance(),this._ast.literal(!0);if("false"===e)return this._advance(),this._ast.literal(!1);if("null"===e)return this._advance(),this._ast.literal(null);if("undefined"===e)return this._advance(),this._ast.literal(void 0);const t=this._parseIdentifier(),i=this._parseArguments();return i?this._ast.invoke(t,void 0,i):t}_parseIdentifier(){if(!this._matches(ve.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);const e=this._value;return this._advance(),this._ast.id(e)}_parseArguments(){if(!this._matches(ve.GROUPER,"("))return;const e=[];do{if(this._advance(),this._matches(ve.GROUPER,")"))break;const t=this._parseExpression();e.push(t)}while(this._matches(ve.COMMA));return this._advance(ve.GROUPER,")"),e}_parseIndex(){this._advance();const e=this._parseExpression();return this._advance(ve.GROUPER,"]"),e}_parseParenOrFunction(){const e=this._parseArguments();if(this._matches(ve.ARROW)){this._advance();const t=this._parseExpression(),i=e?.map((e=>e.value))??[];return this._ast.arrowFunction(i,t)}return this._ast.paren(e[0])}_parseString(){const e=this._ast.literal(this._value);return this._advance(),e}_parseInteger(e=""){const t=this._ast.literal(parseInt(`${e}${this._value}`,10));return this._advance(),t}_parseDecimal(e=""){const t=this._ast.literal(parseFloat(`${e}${this._value}`));return this._advance(),t}}const Te={"+":(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),"|>":(e,t)=>t(e)},Oe={"+":e=>e,"-":e=>-e,"!":e=>!e};class Ne{timeouts=new Map;debounce(e,t){return new Promise(((i,s)=>{const r=this.timeouts.get(t);r&&clearTimeout(r),this.timeouts.set(t,setTimeout((()=>{try{i(t()),this.timeouts.delete(t)}catch(e){s(e)}}),e))}))}}const Ie=new class{empty(){return{type:"Empty",evaluate:e=>e,getIds:e=>e}}literal(e){return{type:"Literal",value:e,evaluate(e){return this.value},getIds:e=>e}}id(e){return{type:"ID",value:e,evaluate(e){return"this"===this.value?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(e,t){const i=Oe[e];return{type:"Unary",operator:e,child:t,evaluate(e){return i(this.child.evaluate(e))},getIds(e){return this.child.getIds(e)}}}binary(e,t,i){const s=Te[t];return{type:"Binary",operator:t,left:e,right:i,evaluate(e){if("="===this.operator){if("ID"!==this.left.type&&"Getter"!==this.left.type&&"Index"!==this.left.type)throw new Error(`Invalid assignment target: ${this.left}`);const t=this.right.evaluate(e);let i,s;return"Getter"===this.left.type?(i=this.left.receiver.evaluate(e),s=this.left.name):"Index"===this.left.type?(i=this.left.receiver.evaluate(e),s=this.left.argument.evaluate(e)):"ID"===this.left.type&&(i=e,s=this.left.value),void 0===i?void 0:i[s]=t}return s(this.left.evaluate(e),this.right.evaluate(e))},getIds(e){return this.left.getIds(e),this.right.getIds(e),e}}}getter(e,t){return{type:"Getter",receiver:e,name:t,evaluate(e){return this.receiver.evaluate(e)?.[this.name]},getIds(e){return this.receiver.getIds(e),e}}}invoke(e,t,i){if(null!=t&&"string"!=typeof t)throw new Error("method not a string");return{type:"Invoke",receiver:e,method:t,arguments:i,evaluate(e){const i=this.receiver.evaluate(e),s=this.method?i:e?.this??e,r=this.method?i?.[t]:i,n=(this.arguments??[]).map((t=>t?.evaluate(e)));return r?.apply?.(s,n)},getIds(e){return this.receiver.getIds(e),this.arguments?.forEach((t=>t?.getIds(e))),e}}}paren(e){return e}index(e,t){return{type:"Index",receiver:e,argument:t,evaluate(e){return this.receiver.evaluate(e)?.[this.argument.evaluate(e)]},getIds(e){return this.receiver.getIds(e),e}}}ternary(e,t,i){return{type:"Ternary",condition:e,trueExpr:t,falseExpr:i,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",entries:e,evaluate(t){const i={};if(e&&this.entries)for(const s in e){const e=this.entries[s];e&&(i[s]=e.evaluate(t))}return i},getIds(t){if(e&&this.entries)for(const i in e){const e=this.entries[i];e&&e.getIds(t)}return t}}}list(e){return{type:"List",items:e,evaluate(e){return this.items?.map((t=>t?.evaluate(e)))},getIds(e){return this.items?.forEach((t=>t?.getIds(e))),e}}}arrowFunction(e,t){return{type:"ArrowFunction",params:e,body:t,evaluate(e){const t=this.params,i=this.body;return function(...s){const r=Object.fromEntries(t.map(((e,t)=>[e,s[t]]))),n=new Proxy(e??{},{set:(e,t,i)=>(r.hasOwnProperty(t)&&(r[t]=i),e[t]=i),get:(e,t)=>r.hasOwnProperty(t)?r[t]:e[t]});return i.evaluate(n)}},getIds(e){return this.body.getIds(e).filter((e=>!this.params.includes(e)))}}}};function Pe(e,t){const i=e?._store;return i?.has(t)?i.get(t):i?.has("$parent")?Pe(i.get("$parent"),t):null}function Se(e,t){const i=e?._store;return i?.has(t)?e:i?.has("$parent")?Se(i.get("$parent"),t):null}class xe extends Ne{evalkeys=["$elem","$event"];expressionCache=new Map;observers=new Map;keyHandlers=new Map;_observer=null;_store=new Map;_lock=Promise.resolve();constructor(e){super();for(let[t,i]of Object.entries(e||{}))this.set(t,i)}wrapFunction(e){return(...t)=>e.call(this.$,...t)}wrapObject(e,t){return null==e||((i=e)instanceof xe||i.__is_proxy__)||e.constructor!==Object&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,i)=>i in e&&(delete e[i],t(),!0),set:(i,s,r,n)=>{"object"==typeof r&&null!=e&&(r=this.wrapObject(r,t));const a=Reflect.set(i,s,r,n);return t(),a},get:(e,t,i)=>"__is_proxy__"===t||Reflect.get(e,t,i)});var i}watch(e,t){const i=Se(this,e);if(!i)throw new Error(`Cannot watch key "${e}" as it does not exist in the store.`);i.observers.has(e)||i.observers.set(e,new Set),i.observers.get(e)?.has(t)||i.observers.get(e)?.add(t)}addKeyHandler(e,t){this.keyHandlers.has(e)||this.keyHandlers.set(e,new Set),this.keyHandlers.get(e).add(t)}async notify(e,t=10){const i=Se(this,e),s=Array.from(i?.observers.get(e)||[]);await this.debounce(t,(()=>Promise.all(s.map((e=>e.call(this.proxify(e)))))))}get(e,t){return t&&this.watch(e,t),Pe(this,e)}async set(e,t){if(t===this._store.get(e))return;const i=()=>this.notify(e);t&&"function"==typeof t&&(t=this.wrapFunction(t)),t&&"object"==typeof t&&(t=this.wrapObject(t,i)),function(e,t,i){const s=Se(e,t);s?s._store.set(t,i):e._store.set(t,i)}(this,e,t);for(const[i,s]of this.keyHandlers.entries())if(i.test(e))for(const i of s)await Promise.resolve(i.call(this.$,e,t));await i()}async del(e){await this.set(e,null),this._store.delete(e),this.observers.delete(e)}has(e){return this._store.has(e)}effect(e){return e.call(this.proxify(e))}proxify(e){const t=Array.from(this._store.entries()).map((([e])=>e)),i=Object.fromEntries(t.map((e=>[e,null])));return new Proxy(i,{get:(t,i,s)=>"string"==typeof i&&Se(this,i)?this.get(i,e):"$"===i?this.proxify(e):Reflect.get(this,i,s),set:(e,t,i,s)=>("string"!=typeof t||t in this?Reflect.set(this,t,i,s):this.set(t,i),!0)})}get $(){return this.proxify()}makeEvalFunction(e){if(e.includes(";"))throw new Error("Complex expressions are not supported.");let t=null;if(e.includes(" = ")){const[i,s]=e.split(" = ");t=i.trim(),e=s.trim()}return(i,s)=>{const r=((e,t)=>new Re(e,t).parse())(e,Ie),n=r?.getIds([])?.map((e=>[e,s[e]??i[e]??globalThis[e]])),a=r?.evaluate(Object.fromEntries(n||[]));if(!t)return a;!function(e,t,i){const s=t.split(".");for(let t=0;t<s.length-1;t++)s[t]in e||(e[s[t]]={}),e=e[s[t]];e[s[s.length-1]]=i}(i,t,a)}}cachedExpressionFunction(e){return e=e.trim(),this.expressionCache.has(e)||this.expressionCache.set(e,this.makeEvalFunction(e)),this.expressionCache.get(e)}eval(e,t={}){const i=this._observer?this:this.$;if(this._store.has(e))return i[e];{const s=this.cachedExpressionFunction(e);try{return s(i,t)}catch(t){return console.error(`Failed to evaluate expression: ${e}`),console.error(t),null}}}}class Ce extends xe{debugging=!1;dirpath="";_skipNodes=new Set;_customElements=new Map;debug(e){return this.debugging=e,this}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:\n",t);const i=this.parseHTML(e,t);return await this.preprocessNode(i,t),i}async preprocessRemote(e,t){const i={};t?.cache&&(i.cache=t.cache);const s=await fetch(e,i).then((e=>e.text()));return this.preprocessString(s,{...t,dirpath:he(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}async preprocessLocal(e,t){const i=await this.fetchLocal(e,t);return this.preprocessString(i,{...t,dirpath:he(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}subrenderer(){const 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.debugging&&console.debug(...e)}async preprocessNode(e,t){t={dirpath:this.dirpath,maxdepth:10,...t};const i=new ue(W(e,this._skipNodes)).map((async e=>{this.log("Preprocessing node:\n",ce(e,128)),await de.resolveIncludes.call(this,e,t),await de.rebaseRelativePaths.call(this,e,t),await de.registerCustomElements.call(this,e,t),await de.resolveCustomElements.call(this,e,t)}));return await Promise.all(i.generator()),e}async renderNode(e,t){for(const i of W(e,this._skipNodes))this.log("Rendering node:\n",ce(i,128)),await de.resolveForAttribute.call(this,i,t),await de.resolveDataAttribute.call(this,i,t),await de.resolveTextAttributes.call(this,i,t),await de.resolveHtmlAttribute.call(this,i,t),await de.resolveShowAttribute.call(this,i,t),await de.resolveClassAttribute.call(this,i,t),await de.resolveBindAttribute.call(this,i,t),await de.resolveEventAttributes.call(this,i,t),await de.resolveTextNodeExpressions.call(this,i,t),await de.resolveCustomAttribute.call(this,i,t),await de.resolveCustomProperty.call(this,i,t);return e}async mount(e,t){t={...t,rootNode:e},Q(e,"renderer",this),this.has("$rootRenderer")||this._store.set("$rootRenderer",this),this._store.set("$rootNode",e),await this.preprocessNode(e,t),await this.renderNode(e,t),this.get("$rootRenderer")===this&&function(e){const t="$$",i=()=>{const i=new URL(window.location.href),s=new Set;for(const[r,n]of i.searchParams.entries()){const i=`${t}${r}`;s.add(i),e.get(i)!==n&&e.set(i,n)}const r=Object.keys(e.$).filter((e=>e.startsWith(t)));for(const t of r)s.has(t)||e.del(t)};i(),e.addKeyHandler(new RegExp("^\\$\\$"),((e,t)=>{const i=new URL(window.location.href),s=e.substring(2);let r=!1;if(t){const e=String(t);i.searchParams.get(s)!==e&&(i.searchParams.set(s,e),r=!0)}else i.searchParams.has(s)&&(i.searchParams.delete(s),r=!0);r&&window.history.replaceState({},"",i.toString())})),window.addEventListener("popstate",i)}(this)}}const Le=[":data",":for",":text",":html",":show",":class",":bind",":on:click",":on:input",":on:change",":on:submit",":attr:src",":attr:href",":attr:title",":prop:checked",":prop:selected",":prop:disabled"];class ke extends Ce{impl="safe_browser";dirpath=he(globalThis.location?.href??"http://localhost/");parseHTML(e,t={rootDocument:!1}){for(const t of Le)e=e.replace(new RegExp(`\\s:${t.slice(1)}=`,"g"),` data-${t.slice(1).replace(":","-")}=`);e=(e=(e=e.replace(/<include(.*) src="([^"]+)"(.*)><\/include>/g,'<link $1 rel="subresource" href="$2" $3>')).replace(/<template is="([^"]+)">([\s\S]*)<\/template>/g,'<div role="template" alt="$1">$2</div>')).replace(/<(\w+)-(\w+)(.*)>([\s\S]*)<\/(\w+)-(\w+)>/g,'<div role="$1-$2" $3>$4</div>');const i=Le.map((e=>`data-${e.slice(1).replace(":","-")}`));i.push("data-testid");const s=(new F).allowDataAttributes(i).allowClassAttributes().allowStyleAttributes().build();if(this.log("parseHTML",e),this.log("sanitized",String(s.sanitize(e))),t.rootDocument){return K(new DOMParser,s.sanitize(e),"text/html")}return s.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)}textContent(e,t){e.textContent=t}}const De=new ke;export{De as Mancha,ke as Renderer};
package/dist/store.d.ts CHANGED
@@ -2,6 +2,7 @@ type SignalStoreProxy = SignalStore & {
2
2
  [key: string]: any;
3
3
  };
4
4
  type Observer<T> = (this: SignalStoreProxy) => T;
5
+ type KeyValueHandler = (this: SignalStoreProxy, key: string, value: any) => void;
5
6
  declare abstract class IDebouncer {
6
7
  timeouts: Map<Function, ReturnType<typeof setTimeout>>;
7
8
  debounce<T>(millis: number, callback: () => T | Promise<T>): Promise<T>;
@@ -16,6 +17,7 @@ export declare class SignalStore extends IDebouncer {
16
17
  protected readonly evalkeys: string[];
17
18
  protected readonly expressionCache: Map<string, Function>;
18
19
  protected readonly observers: Map<string, Set<Observer<unknown>>>;
20
+ protected readonly keyHandlers: Map<RegExp, Set<KeyValueHandler>>;
19
21
  protected _observer: Observer<unknown> | null;
20
22
  readonly _store: Map<string, unknown>;
21
23
  _lock: Promise<void>;
@@ -25,10 +27,11 @@ export declare class SignalStore extends IDebouncer {
25
27
  private wrapFunction;
26
28
  private wrapObject;
27
29
  watch<T>(key: string, observer: Observer<T>): void;
30
+ addKeyHandler(pattern: RegExp, handler: KeyValueHandler): void;
28
31
  notify(key: string, debounceMillis?: number): Promise<void>;
29
32
  get<T>(key: string, observer?: Observer<T>): unknown | null;
30
33
  set(key: string, value: unknown): Promise<void>;
31
- del(key: string): void;
34
+ del(key: string): Promise<void>;
32
35
  has(key: string): boolean;
33
36
  effect<T>(observer: Observer<T>): T;
34
37
  private proxify;
package/dist/store.js CHANGED
@@ -71,6 +71,7 @@ export class SignalStore extends IDebouncer {
71
71
  evalkeys = ["$elem", "$event"];
72
72
  expressionCache = new Map();
73
73
  observers = new Map();
74
+ keyHandlers = new Map();
74
75
  _observer = null;
75
76
  _store = new Map();
76
77
  _lock = Promise.resolve();
@@ -127,6 +128,12 @@ export class SignalStore extends IDebouncer {
127
128
  owner.observers.get(key)?.add(observer);
128
129
  }
129
130
  }
131
+ addKeyHandler(pattern, handler) {
132
+ if (!this.keyHandlers.has(pattern)) {
133
+ this.keyHandlers.set(pattern, new Set());
134
+ }
135
+ this.keyHandlers.get(pattern).add(handler);
136
+ }
130
137
  async notify(key, debounceMillis = REACTIVE_DEBOUNCE_MILLIS) {
131
138
  const owner = getAncestorKeyStore(this, key);
132
139
  const observers = Array.from(owner?.observers.get(key) || []);
@@ -148,9 +155,20 @@ export class SignalStore extends IDebouncer {
148
155
  value = this.wrapObject(value, callback);
149
156
  }
150
157
  setAncestorValue(this, key, value);
158
+ // Invoke any key handlers.
159
+ for (const [pattern, handlers] of this.keyHandlers.entries()) {
160
+ if (pattern.test(key)) {
161
+ for (const handler of handlers) {
162
+ await Promise.resolve(handler.call(this.$, key, value));
163
+ }
164
+ }
165
+ }
166
+ // Invoke the callback to notify observers.
151
167
  await callback();
152
168
  }
153
- del(key) {
169
+ async del(key) {
170
+ // By setting to null, we trigger observers before deletion.
171
+ await this.set(key, null);
154
172
  this._store.delete(key);
155
173
  this.observers.delete(key);
156
174
  }
@@ -162,7 +180,7 @@ export class SignalStore extends IDebouncer {
162
180
  }
163
181
  proxify(observer) {
164
182
  const keys = Array.from(this._store.entries()).map(([key]) => key);
165
- const keyval = Object.fromEntries(keys.map((key) => [key, undefined]));
183
+ const keyval = Object.fromEntries(keys.map((key) => [key, null]));
166
184
  return new Proxy(keyval, {
167
185
  get: (_, prop, receiver) => {
168
186
  if (typeof prop === "string" && getAncestorKeyStore(this, prop)) {
package/dist/store.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,MAAe,UAAU;IACvB,QAAQ,GAAiD,IAAI,GAAG,EAAE,CAAC;IAEnE,QAAQ,CAAI,MAAc,EAAE,QAA8B;QACxD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC5C,IAAI,OAAO;gBAAE,YAAY,CAAC,OAAO,CAAC,CAAC;YACnC,IAAI,CAAC,QAAQ,CAAC,GAAG,CACf,QAAQ,EACR,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI,CAAC;oBACH,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;oBACpB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBACjC,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,MAAM,CAAC,GAAG,CAAC,CAAC;gBACd,CAAC;YACH,CAAC,EAAE,MAAM,CAAC,CACX,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,wCAAwC;AACxC,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAE3C,0BAA0B;AAC1B,MAAM,WAAW,GAAG,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;AAE/C,SAAS,WAAW,CAAmB,MAAS;IAC9C,OAAO,MAAM,YAAY,WAAW,IAAK,MAAc,CAAC,cAA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AAC,GAAG,CAAC,CAAC;gBACnB,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -46,7 +46,7 @@ export const assert = {
46
46
  if (!globalThis.window) {
47
47
  // Import JSDOM dynamically, because it's not available in browser context.
48
48
  const { JSDOM } = await import("jsdom");
49
- const dom = new JSDOM();
49
+ const dom = new JSDOM(``, { url: "http://localhost/" });
50
50
  // Types.
51
51
  globalThis.Document = globalThis.Document || dom.window.Document;
52
52
  globalThis.DocumentFragment = globalThis.DocumentFragment || dom.window.DocumentFragment;
@@ -55,5 +55,6 @@ if (!globalThis.window) {
55
55
  globalThis.document = globalThis.document || dom.window.document;
56
56
  globalThis.DOMParser = globalThis.DOMParser || dom.window.DOMParser;
57
57
  globalThis.XMLSerializer = globalThis.XMLSerializer || dom.window.XMLSerializer;
58
+ globalThis.PopStateEvent = globalThis.PopStateEvent || dom.window.PopStateEvent;
58
59
  }
59
60
  //# sourceMappingURL=test_utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"test_utils.js","sourceRoot":"","sources":["../src/test_utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,UAAU,SAAS,CAAC,IAAa;IACrC,IAAI,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC;;QACrD,OAAO,QAAQ,CAAC,YAAY,CAAC,IAAW,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAa;IAC1C,IAAI,WAAW,CAAC,IAAI,EAAE,aAAa,CAAC;QAAE,OAAO,IAAI,CAAC,WAAW,CAAC;;QACzD,OAAO,QAAQ,CAAC,WAAW,CAAC,IAAW,CA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AK,GAAG,CAAC,MAAgD,CAAC;IAC/F,UAAU,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC;IACjE,UAAU,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;IACpE,UAAU,CAAC,aAAa,GAAG,UAAU,CAAC,aAAa,IAAI,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC;IAChF,UAAU,CAAC,aAAa,GAAG,UAAU,CAAC,aAAa,IAAI,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC;AAClF,CAAC"}
@@ -16,7 +16,10 @@ For example, a basic form might look like this
16
16
 
17
17
  ```html
18
18
  <body :data="{ name: null }">
19
- <form class="flex flex-col max-w-md p-4 bg-white rounded-lg" :on:submit="console.log('submitted')">
19
+ <form
20
+ class="flex flex-col max-w-md p-4 bg-white rounded-lg"
21
+ :on:submit="console.log('submitted')"
22
+ >
20
23
  <label class="w-full mb-4">
21
24
  <span class="block text-sm font-medium text-gray-700">Name</span>
22
25
  <input
@@ -127,3 +130,32 @@ the `<script>` tag that imports `Mancha`, and explicitly call the `mount()` func
127
130
  await $.mount(document.body);
128
131
  </script>
129
132
  ```
133
+
134
+ ## URL Query Parameter Binding
135
+
136
+ `mancha` makes it easy to synchronize your application's state with the URL query parameters. This is particularly useful for maintaining state across page reloads or for creating shareable links.
137
+
138
+ This feature works automatically for any variable prefixed with `$$`. When a `$$` variable is changed in your application, the URL is updated. Conversely, when the page loads, `mancha` reads the query parameters from the URL and populates the corresponding `$$` variables in your application's state.
139
+
140
+ Here's how you can use it:
141
+
142
+ ```html
143
+ <body :data="{ $$search: '' }">
144
+ <form class="flex flex-col max-w-md p-4 bg-white rounded-lg">
145
+ <label class="w-full mb-4">
146
+ <span class="block text-sm font-medium text-gray-700">Search</span>
147
+ <input
148
+ type="text"
149
+ :bind="$$search"
150
+ class="w-full mt-1 p-2 border border-gray-300 rounded-md focus:border-indigo-500"
151
+ placeholder="Type to see the URL change..."
152
+ />
153
+ </label>
154
+ <div :show="$$search" class="mt-2">
155
+ <p>Current search query: <span class="font-mono">{{ $$search }}</span></p>
156
+ </div>
157
+ </form>
158
+ </body>
159
+ ```
160
+
161
+ In this example, the input field is bound to `$$search`. As you type, the URL will be updated with a `search` query parameter (e.g., `?search=your-text`). If you reload the page with the query parameter in the URL, the input field will be automatically populated with the value from the URL.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mancha",
3
- "version": "0.13.4",
3
+ "version": "0.14.0",
4
4
  "description": "Javscript HTML rendering engine",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -11,7 +11,7 @@
11
11
  "build": "npx gulp build",
12
12
  "prepare": "npm run build",
13
13
  "test_node": "mocha dist/*.test.js",
14
- "test_browser": "web-test-runner --node-resolve --compatibility all --puppeteer dist/*browser.test.js --no-sandbox",
14
+ "test_browser": "web-test-runner dist/*browser.test.js --node-resolve --compatibility all --playwright --browsers chromium --no-sandbox",
15
15
  "test": "npm run test_node && npm run test_browser",
16
16
  "check_size": "brotli -c dist/mancha.js | wc -c",
17
17
  "cli": "node dist/cli.js"
@@ -47,6 +47,7 @@
47
47
  "@types/path-browserify": "^1.0.1",
48
48
  "@types/yargs": "^17.0.29",
49
49
  "@web/test-runner": "^0.19.0",
50
+ "@web/test-runner-playwright": "^0.11.1",
50
51
  "@web/test-runner-puppeteer": "^0.17.0",
51
52
  "chai": "^5.1.2",
52
53
  "chai-as-promised": "^8.0.1",