mancha 0.13.3 → 0.13.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +1 -1
- package/dist/mancha.js +1 -1
- package/dist/plugins.js +4 -2
- package/dist/plugins.js.map +1 -1
- package/dist/renderer.js +3 -3
- package/dist/renderer.js.map +1 -1
- package/dist/safe_browser.js +1 -1
- package/dist/store.d.ts +6 -6
- package/dist/store.js +30 -25
- package/dist/store.js.map +1 -1
- package/package.json +1 -1
package/dist/safe_browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e={};function t(e){0}class i{constructor(e,t){this.privateDoNotAccessOrElseWrappedAttributePrefix=t}toString(){return this.privateDoNotAccessOrElseWrappedAttributePrefix}}const r=i;function s(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 r(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 v(e){if(!function(e){const t=!E.test(e);return t}(e))return e}function w(e){return v(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 T(e){const t=e.nodeType;return 1===t||"number"!=typeof t}var R,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"}(R||(R={}));class P{constructor(e,t,i,r,s){this.allowedElements=e,this.elementPolicies=t,this.allowedGlobalAttributes=i,this.globalAttributePolicies=r,this.globallyAllowedAttributePrefixes=s}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 r=this.globalAttributePolicies.get(e);return r||(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 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(e,i,r,s,n){this.sanitizerTable=e,this.styleElementSanitizer=r,this.styleAttributeSanitizer=s,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),r=document.createTreeWalker(i,5,(e=>this.nodeFilter(e)));let s=r.nextNode();const n=t.createDocumentFragment();let a=n;for(;null!==s;){let e;if(y(s))if(this.styleElementSanitizer&&"STYLE"===a.nodeName){const t=this.styleElementSanitizer(s.data);e=this.createTextNode(t)}else e=this.sanitizeTextNode(s);else{if(!T(s)){throw new Error("")}e=this.sanitizeElementNode(s,t)}if(a.appendChild(e),s=r.firstChild(),s)a=e;else for(;!(s=r.nextSibling())&&(s=r.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),r=t.createElement(i),s=e.attributes;for(const{name:e,value:t}of s){const n=this.sanitizerTable.getAttributePolicy(e,i);if(this.satisfiesAllConditions(n.conditions,s))switch(n.policyAction){case O.KEEP:z(r,e,t);break;case O.KEEP_AND_SANITIZE_URL:const s=b(t);s!==t&&this.recordChange(`Url in attribute ${e} was modified during sanitization. Original url:"${t}" was sanitized to: "${s}"`),z(r,e,s);break;case O.KEEP_AND_NORMALIZE:z(r,e,t.toLowerCase());break;case O.KEEP_AND_SANITIZE_STYLE:if(this.styleAttributeSanitizer){z(r,e,this.styleAttributeSanitizer(t))}else z(r,e,t);break;case O.KEEP_AND_USE_RESOURCE_URL_POLICY:if(this.resourceUrlPolicy){const s={type:R.HTML_ATTRIBUTE,attributeName:e,tagName:i},n=N(t),a=this.resourceUrlPolicy(n,s);a&&z(r,e,a.toString())}else z(r,e,t);break;case O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET:if(this.resourceUrlPolicy){const s={type:R.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,s);i&&a.parts.push({url:i.toString(),descriptor:e.descriptor})}z(r,e,M(a))}else z(r,e,t);break;case O.DROP:this.recordChange(`Attribute: ${e} was dropped`)}else this.recordChange(`Not all conditions satisfied for attribute: ${e}.`)}return r}nodeFilter(e){if(y(e))return 1;if(!T(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[r,s]of e){const e=null===(i=t.getNamedItem(r))||void 0===i?void 0:i.value;if(e&&!s.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,r]=i.trim().split(/\s+/,2);t.push({url:e,descriptor:r})}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 r of e){if(r=r.toUpperCase(),!this.sanitizerTable.isAllowedElement(r))throw new Error(`Element: ${r}, is not allowed by html5_contract.textpb`);const e=this.sanitizerTable.elementPolicies.get(r);void 0!==e?i.set(r,e):t.add(r)}return this.sanitizerTable=new P(t,i,this.sanitizerTable.allowedGlobalAttributes,this.sanitizerTable.globalAttributePolicies),this}allowCustomElement(e,t){const i=new Set(this.sanitizerTable.allowedElements),r=new Map(this.sanitizerTable.elementPolicies);if(e=e.toUpperCase(),s=e,x.has(s.toUpperCase())||!/^[a-z][-_.a-z0-9]*-[-_.a-z0-9]*$/i.test(s))throw new Error(`Element: ${e} is not a custom element`);var s;if(t){const i=new Map;for(const e of t)i.set(e,{policyAction:O.KEEP});r.set(e,i)}else i.add(e);return this.sanitizerTable=new P(i,r,this.sanitizerTable.allowedGlobalAttributes,this.sanitizerTable.globalAttributePolicies),this}onlyAllowAttributes(e){const t=new Set,i=new Map,r=new Map;for(const r of e)this.sanitizerTable.allowedGlobalAttributes.has(r)&&t.add(r),this.sanitizerTable.globalAttributePolicies.has(r)&&i.set(r,this.sanitizerTable.globalAttributePolicies.get(r));for(const[t,i]of this.sanitizerTable.elementPolicies.entries()){const s=new Map;for(const[t,r]of i.entries())e.has(t)&&s.set(t,r);r.set(t,s)}return this.sanitizerTable=new P(this.sanitizerTable.allowedElements,r,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,r){if(0===e.length){throw new Error("")}const n=e.map((e=>s(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,r)}function K(e,t,i){return e.parseFromString(f(t),i)}Error;const W=[o`:`,o`style`,o`class`];function*Y(e,t=new Set){const i=new Set,r=Array.from(e.childNodes).filter((e=>!t.has(e)));for(yield e;r.length;){const e=r.shift();i.has(e)||(i.add(e),yield e),e.childNodes&&Array.from(e.childNodes).filter((e=>!t.has(e))).forEach((e=>r.push(e)))}}function H(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 H(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){H(e,"attribs")?e.attribs[t]=i:e.setAttribute?.(t,i)}function X(e,t,i){H(e,"attribs")?e.attribs[t]=i:G(W,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){H(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(H(e,"attribs")&&H(t,"attribs"))t.attribs[i]=e.attribs[i];else if(i.startsWith("data-")){const r=V(i.slice(5));t.dataset[r]=e.dataset?.[r]}else{const r=e?.getAttribute?.(i);X(t,i,r||"")}}function ie(e){if(H(e,"firstElementChild"))return e.firstElementChild;return Array.from(e.children).find((e=>1===e.nodeType))}function re(e,...t){if(B(e,"replaceWith"))return e.replaceWith(...t);{const i=e,r=i.parentNode,s=Array.from(r.childNodes).indexOf(i);t.forEach((e=>e.parentNode=r)),r.childNodes=[].concat(Array.from(r.childNodes).slice(0,s)).concat(t).concat(Array.from(r.childNodes).slice(s+1))}}function se(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):(se(e,...Array.from(e.childNodes).filter((e=>e!==t))),t)}function oe(e,t,i){return i?B(e,"insertBefore")?e.insertBefore(t,i):(re(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](),r=t[Symbol.iterator]();let s=i.next(),n=r.next();for(;!s.done&&!n.done;){if(s.value!==n.value)return!1;s=i.next(),n=r.next()}return s.done===n.done}}var de;!function(e){e.resolveIncludes=async function(e,t){const i=e,r=i.tagName?.toLowerCase();if(!["include","link"].includes(r))return;if("link"===r&&"subresource"!==Z(i,"rel"))return;this.log("include directive found in:\n",ce(e,128)),this.log("include params:",t);const s="link"===i.tagName.toLocaleLowerCase()?"href":"src",n=Z(i,s);if(!n)throw new Error(`"${s}" attribute missing from ${ce(e,128)}.`);const a=[];"include"===r&&a.push("src"),"link"===r&&a.push("rel","href");const o=t=>{const r=ie(t);for(const e of Array.from(i.attributes))r&&!a.includes(e.name)&&te(i,r,e.name);re(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,r=i.tagName?.toLowerCase();if(!t?.dirpath)return;const s=Z(i,"src"),n=Z(i,"href"),a=s||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),H(i,"attribs")?X(i,s?"src":"href",l):"img"===r?i.src=l:"a"===r?function(e,t){const i=w(t);void 0!==i&&(e.href=i)}(i,l):"source"===r||"audio"===r||"video"===r||"track"===r||"input"===r?i.src=l:"area"===r?function(e,t){const i=w(t);void 0!==i&&(e.href=i)}(i,l):this.log("Unable to rebase relative path for element:",r)},e.registerCustomElements=async function(e,t){const i=e,r=i.tagName?.toLowerCase(),s=(Z(i,"is")||Z(i,"alt"))?.toLowerCase();if(["template","div"].includes(r)&&s){if("div"===r&&"template"!==Z(i,"role"))return;this._customElements.has(s)||(this.log(`Registering custom element: ${s}\n`,ce(i,128)),this._customElements.set(s,i),ae(i.parentNode,i))}},e.resolveCustomElements=async function(e,t){const i=e,r=i.tagName?.toLowerCase();let s=r;if("div"===s&&(s=Z(i,"role")?.toLowerCase()||s),s&&this._customElements.has(s)){this.log(`Processing custom element: ${s}\n`,ce(i,128));const t=this._customElements.get(s),n=(t.content||t).cloneNode(!0),a=ie(n);if(a)for(const e of Array.from(i.attributes))"div"===r&&"role"===e.name||te(i,a,e.name);const o=new ue(Y(n)).find((e=>"slot"===e.tagName?.toLowerCase()));o&&re(o,...i.childNodes),re(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 r=new RegExp(/{{ ([^}]+) }}/gm),s=Array.from(i.matchAll(r)).map((e=>e[1]));return this.effect((function(){let t=i;for(const i of s){const r=this.eval(i,{$elem:e});t=t.replace(`{{ ${i} }}`,String(r))}e.nodeValue=t}))},e.resolveDataAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,r=j(i,"data",":");if(r){this.log(":data attribute found in:\n",ce(e,128)),ee(i,"data",":");const s=t?.rootNode===e?this:this.subrenderer();e.renderer=s;const n=s.eval(r,{$elem:e});if(await Promise.all(Object.entries(n).map((([e,t])=>s.set(e,t)))),s!==this)for(const t of Y(e,this._skipNodes))this._skipNodes.add(t);await s.mount(e,t)}},e.resolveClassAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,r=j(i,"class",":");if(r){this.log(":class attribute found in:\n",ce(e,128)),ee(i,"class",":");const t=Z(i,"class")||"";return this.effect((function(){const s=this.eval(r,{$elem:e});X(i,"class",(s?`${t} ${s}`:t).trim())}))}},e.resolveTextAttributes=async function(e,t){if(this._skipNodes.has(e))return;const i=e,r=j(i,"text",":");if(r){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(r,{$elem:e}))}))}},e.resolveHtmlAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,r=j(i,"html",":");return r?(this.log(":html attribute found in:\n",ce(e,128)),ee(i,"html",":"),this.effect((function(){const s=this.eval(r,{$elem:e});return new Promise((async e=>{const r=await this.preprocessString(s,t);await this.renderNode(r),se(i,r),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 r=t.name.split(":on:",2).at(-1)?.split("data-on-",2).at(-1)||"";if(!r)throw new Error(`Invalid event attribute: ${t.name}`);this.log(t.name,"attribute found in:\n",ce(e,128)),J(i,t.name);const s="submit"===r&&"FORM"===i.tagName.toUpperCase();e.addEventListener?.(r,(i=>(s&&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,r=j(i,"for",":")?.trim();if(r){this.log(":for attribute found in:\n",ce(e,128)),ee(i,"for",":");for(const t of Y(e,this._skipNodes))this._skipNodes.add(t);const s=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=r.split(" in ",2);if(2!==o.length)throw new Error(`Invalid :for format: \`${r}\`. 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 r=[];for(const n of i){const i=this.subrenderer();i.set(c,n);const a=e.cloneNode(!0);q(a,"style",s),l.push(a),this._skipNodes.add(a),r.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(r)}))}},e.resolveBindAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,r=j(i,"bind",":");if(r){this.log(":bind attribute found in:\n",ce(e,128));const t=["change","input"],s=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";this.effect((function(){const t=this.eval(r,{$elem:e});"checked"===n?i.checked=!!t:i.value=t}));const a=`${r} = $elem.${n}`;for(const t of s)e.addEventListener(t,(()=>this.eval(a,{$elem:e})))}},e.resolveShowAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,r=j(i,"show",":");if(r){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 s=this.eval(r,{$elem:e});i.style?i.style.display=s?t:"none":X(i,"style",`display: ${s?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 r=":attr:",s="data-attr-";if(t.name.startsWith(r)||t.name.startsWith(s)){this.log(t.name,"attribute found in:\n",ce(e,128)),J(i,t.name);const n=t.name.split(r,2).at(-1)?.split(s,2).at(-1);this.effect((function(){const r=this.eval(t.value,{$elem:e});q(i,n,r)}))}}},e.resolveCustomProperty=async function(e,t){if(this._skipNodes.has(e))return;const i=e;for(const t of Array.from(i.attributes||[])){const r=":prop:",s="data-prop-";if(t.name.startsWith(r)||t.name.startsWith(s)){this.log(t.name,"property found in:\n",ce(e,128)),J(i,t.name);const n=t.name.split(r,2).at(-1)?.split(s,2).at(-1),a=V(n);this.effect((function(){const r=this.eval(t.value,{$elem:e});Q(i,a,r)}))}}}}(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=["==","!=","<=",">=","||","&&","??","|>"],ve=["===","!=="];var we;!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"}(we||(we={}));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(we.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=(r=t,-1!==pe.indexOf(r)?we.KEYWORD:we.IDENTIFIER);var r;return be(i,t)}_tokenizeNumber(){do{this._advance()}while(Ae(this._next));return 46===this._next?this._tokenizeDot():be(we.INTEGER,this._getValue())}_tokenizeDot(){return this._advance(),Ae(this._next)?this._tokenizeFraction():(this._clearValue(),be(we.DOT,".",13))}_tokenizeComma(){return this._advance(!0),be(we.COMMA,",")}_tokenizeColon(){return this._advance(!0),be(we.COLON,":")}_tokenizeFraction(){do{this._advance()}while(Ae(this._next));return be(we.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(-1!==ve.indexOf(e))this._advance(),this._advance();else{if(e=this._getValue(1),"=>"===e)return this._advance(),be(we.ARROW,e);-1!==Ee.indexOf(e)&&this._advance()}return e=this._getValue(),be(we.OPERATOR,e,me[e])}_tokenizeGrouper(){const e=String.fromCharCode(this._next),t=be(we.GROUPER,e,me[e]);return this._advance(!0),t}}class Te{_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(we.GROUPER,"(")){const t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(we.GROUPER,"[")){const t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(we.DOT)){this._advance();const t=this._parseUnary();e=this._makeInvokeOrGetter(e,t)}else{if(this._matches(we.KEYWORD))break;if(!(this._matches(we.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===we.OPERATOR||this._kind===we.DOT||this._kind===we.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(we.OPERATOR)){const e=this._value;if(this._advance(),"+"===e||"-"===e){if(this._matches(we.INTEGER))return this._parseInteger(e);if(this._matches(we.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(we.OPERATOR,"?");const t=this._parseExpression();this._advance(we.COLON);const i=this._parseExpression();return this._ast.ternary(e,t,i)}_parsePrimary(){switch(this._kind){case we.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 we.IDENTIFIER:return this._parseInvokeOrIdentifier();case we.STRING:return this._parseString();case we.INTEGER:return this._parseInteger();case we.DECIMAL:return this._parseDecimal();case we.GROUPER:return"("===this._value?this._parseParenOrFunction():"{"===this._value?this._parseMap():"["===this._value?this._parseList():void 0;case we.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){const e=[];do{if(this._advance(),this._matches(we.GROUPER,"]"))break;e.push(this._parseExpression())}while(this._matches(we.COMMA));return this._advance(we.GROUPER,"]"),this._ast.list(e)}_parseMap(){const e={};do{if(this._advance(),this._matches(we.GROUPER,"}"))break;const t=this._value;(this._matches(we.STRING)||this._matches(we.IDENTIFIER))&&this._advance(),this._advance(we.COLON),e[t]=this._parseExpression()}while(this._matches(we.COMMA));return this._advance(we.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(we.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);const e=this._value;return this._advance(),this._ast.id(e)}_parseArguments(){if(!this._matches(we.GROUPER,"("))return;const e=[];do{if(this._advance(),this._matches(we.GROUPER,")"))break;const t=this._parseExpression();e.push(t)}while(this._matches(we.COMMA));return this._advance(we.GROUPER,")"),e}_parseIndex(){this._advance();const e=this._parseExpression();return this._advance(we.GROUPER,"]"),e}_parseParenOrFunction(){const e=this._parseArguments();if(this._matches(we.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 Re={"+":(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,r)=>{const s=this.timeouts.get(t);s&&clearTimeout(s),this.timeouts.set(t,setTimeout((()=>{try{i(t()),this.timeouts.delete(t)}catch(e){r(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 r=Re[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,r;return"Getter"===this.left.type?(i=this.left.receiver.evaluate(e),r=this.left.name):"Index"===this.left.type?(i=this.left.receiver.evaluate(e),r=this.left.argument.evaluate(e)):"ID"===this.left.type&&(i=e,r=this.left.value),void 0===i?void 0:i[r]=t}return r(this.left.evaluate(e),this.right.evaluate(e))},getIds(e){return this.left.getIds(e),this.right.getIds(e),e}}}getter(e,t){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),r=this.method?i:e?.this??e,s=this.method?i?.[t]:i,n=(this.arguments??[]).map((t=>t?.evaluate(e)));return s?.apply?.(r,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 r in e){const e=this.entries[r];e&&(i[r]=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(...r){const s=Object.fromEntries(t.map(((e,t)=>[e,r[t]]))),n=new Proxy(e??{},{set:(e,t,i)=>(s.hasOwnProperty(t)&&(s[t]=i),e[t]=i),get:(e,t)=>s.hasOwnProperty(t)?s[t]:e[t]});return i.evaluate(n)}},getIds(e){return this.body.getIds(e).filter((e=>!this.params.includes(e)))}}}};function Pe(e,t){if(e.has(t))return e.get(t);if(e.has("$parent")){return Pe(e.get("$parent"),t)}return null}function xe(e,t){if(e.has(t))return e;if(e.has("$parent")){return xe(e.get("$parent"),t)}return null}class Se extends Ne{evalkeys=["$elem","$event"];expressionCache=new Map;store=new Map;observers=new Map;_observer=null;_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 Se||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,r,s,n)=>{"object"==typeof s&&null!=e&&(s=this.wrapObject(s,t));const a=Reflect.set(i,r,s,n);return t(),a},get:(e,t,i)=>"__is_proxy__"===t||Reflect.get(e,t,i)});var i}watch(e,t){this.observers.has(e)||this.observers.set(e,new Set),this.observers.get(e)?.has(t)||this.observers.get(e)?.add(t)}async notify(e,t=10){const i=Array.from(this.observers.get(e)||[]);await this.debounce(t,(()=>Promise.all(i.map((e=>e.call(this.proxify(e)))))))}get(e,t){return t&&this.watch(e,t),Pe(this.store,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 r=xe(e,t);r?r.set(t,i):e.set(t,i)}(this.store,e,t),await i()}del(e){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,void 0])));return new Proxy(i,{get:(t,i,r)=>"string"==typeof i&&xe(this.store,i)?this.get(i,e):"$"===i?this.proxify(e):Reflect.get(this,i,r),set:(e,t,i,r)=>("string"!=typeof t||t in this?Reflect.set(this,t,i,r):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,r]=e.split(" = ");t=i.trim(),e=r.trim()}return(i,r)=>{const s=((e,t)=>new Te(e,t).parse())(e,Ie),n=s?.getIds([])?.map((e=>[e,r[e]??i[e]??globalThis[e]])),a=s?.evaluate(Object.fromEntries(n||[]));if(!t)return a;!function(e,t,i){const r=t.split(".");for(let t=0;t<r.length-1;t++)r[t]in e||(e[r[t]]={}),e=e[r[t]];e[r[r.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 r=this.cachedExpressionFunction(e);try{return r(i,t)}catch(t){return console.error(`Failed to evaluate expression: ${e}`),console.error(t),null}}}}class Ce extends Se{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 r=await fetch(e,i).then((e=>e.text()));return this.preprocessString(r,{...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(Y(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 Y(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.store.set("$rootNode",e),await this.preprocessNode(e,t),await this.renderNode(e,t)}}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 r=(new F).allowDataAttributes(i).allowClassAttributes().allowStyleAttributes().build();if(this.log("parseHTML",e),this.log("sanitized",String(r.sanitize(e))),t.rootDocument){return K(new DOMParser,r.sanitize(e),"text/html")}return r.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};
|
|
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._store.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._store.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};
|
package/dist/store.d.ts
CHANGED
|
@@ -8,24 +8,24 @@ declare abstract class IDebouncer {
|
|
|
8
8
|
}
|
|
9
9
|
/** Default debouncer time in millis. */
|
|
10
10
|
export declare const REACTIVE_DEBOUNCE_MILLIS = 10;
|
|
11
|
-
export declare function getAncestorValue(store:
|
|
12
|
-
export declare function getAncestorKeyStore(store:
|
|
13
|
-
export declare function setAncestorValue(store:
|
|
11
|
+
export declare function getAncestorValue(store: SignalStore | null, key: string): unknown | null;
|
|
12
|
+
export declare function getAncestorKeyStore(store: SignalStore | null, key: string): SignalStore | null;
|
|
13
|
+
export declare function setAncestorValue(store: SignalStore, key: string, value: unknown): void;
|
|
14
14
|
export declare function setNestedProperty(obj: any, path: string, value: any): void;
|
|
15
15
|
export declare class SignalStore extends IDebouncer {
|
|
16
16
|
protected readonly evalkeys: string[];
|
|
17
17
|
protected readonly expressionCache: Map<string, Function>;
|
|
18
|
-
protected readonly store: Map<string, unknown>;
|
|
19
18
|
protected readonly observers: Map<string, Set<Observer<unknown>>>;
|
|
20
19
|
protected _observer: Observer<unknown> | null;
|
|
20
|
+
readonly _store: Map<string, unknown>;
|
|
21
21
|
_lock: Promise<void>;
|
|
22
22
|
constructor(data?: {
|
|
23
23
|
[key: string]: any;
|
|
24
24
|
});
|
|
25
25
|
private wrapFunction;
|
|
26
26
|
private wrapObject;
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
watch<T>(key: string, observer: Observer<T>): void;
|
|
28
|
+
notify(key: string, debounceMillis?: number): Promise<void>;
|
|
29
29
|
get<T>(key: string, observer?: Observer<T>): unknown | null;
|
|
30
30
|
set(key: string, value: unknown): Promise<void>;
|
|
31
31
|
del(key: string): void;
|
package/dist/store.js
CHANGED
|
@@ -26,24 +26,24 @@ function isProxified(object) {
|
|
|
26
26
|
return object instanceof SignalStore || object["__is_proxy__"];
|
|
27
27
|
}
|
|
28
28
|
export function getAncestorValue(store, key) {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const map = store?._store;
|
|
30
|
+
if (map?.has(key)) {
|
|
31
|
+
return map.get(key);
|
|
31
32
|
}
|
|
32
|
-
else if (
|
|
33
|
-
|
|
34
|
-
return getAncestorValue(parent, key);
|
|
33
|
+
else if (map?.has("$parent")) {
|
|
34
|
+
return getAncestorValue(map.get("$parent"), key);
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
export function getAncestorKeyStore(store, key) {
|
|
41
|
-
|
|
41
|
+
const map = store?._store;
|
|
42
|
+
if (map?.has(key)) {
|
|
42
43
|
return store;
|
|
43
44
|
}
|
|
44
|
-
else if (
|
|
45
|
-
|
|
46
|
-
return getAncestorKeyStore(parent, key);
|
|
45
|
+
else if (map?.has("$parent")) {
|
|
46
|
+
return getAncestorKeyStore(map.get("$parent"), key);
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
49
|
return null;
|
|
@@ -52,10 +52,10 @@ export function getAncestorKeyStore(store, key) {
|
|
|
52
52
|
export function setAncestorValue(store, key, value) {
|
|
53
53
|
const ancestor = getAncestorKeyStore(store, key);
|
|
54
54
|
if (ancestor) {
|
|
55
|
-
ancestor.set(key, value);
|
|
55
|
+
ancestor._store.set(key, value);
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
58
|
-
store.set(key, value);
|
|
58
|
+
store._store.set(key, value);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
export function setNestedProperty(obj, path, value) {
|
|
@@ -70,9 +70,9 @@ export function setNestedProperty(obj, path, value) {
|
|
|
70
70
|
export class SignalStore extends IDebouncer {
|
|
71
71
|
evalkeys = ["$elem", "$event"];
|
|
72
72
|
expressionCache = new Map();
|
|
73
|
-
store = new Map();
|
|
74
73
|
observers = new Map();
|
|
75
74
|
_observer = null;
|
|
75
|
+
_store = new Map();
|
|
76
76
|
_lock = Promise.resolve();
|
|
77
77
|
constructor(data) {
|
|
78
78
|
super();
|
|
@@ -116,24 +116,29 @@ export class SignalStore extends IDebouncer {
|
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
118
|
watch(key, observer) {
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
const owner = getAncestorKeyStore(this, key);
|
|
120
|
+
if (!owner) {
|
|
121
|
+
throw new Error(`Cannot watch key "${key}" as it does not exist in the store.`);
|
|
121
122
|
}
|
|
122
|
-
if (!
|
|
123
|
-
|
|
123
|
+
if (!owner.observers.has(key)) {
|
|
124
|
+
owner.observers.set(key, new Set());
|
|
125
|
+
}
|
|
126
|
+
if (!owner.observers.get(key)?.has(observer)) {
|
|
127
|
+
owner.observers.get(key)?.add(observer);
|
|
124
128
|
}
|
|
125
129
|
}
|
|
126
130
|
async notify(key, debounceMillis = REACTIVE_DEBOUNCE_MILLIS) {
|
|
127
|
-
const
|
|
131
|
+
const owner = getAncestorKeyStore(this, key);
|
|
132
|
+
const observers = Array.from(owner?.observers.get(key) || []);
|
|
128
133
|
await this.debounce(debounceMillis, () => Promise.all(observers.map((observer) => observer.call(this.proxify(observer)))));
|
|
129
134
|
}
|
|
130
135
|
get(key, observer) {
|
|
131
136
|
if (observer)
|
|
132
137
|
this.watch(key, observer);
|
|
133
|
-
return getAncestorValue(this
|
|
138
|
+
return getAncestorValue(this, key);
|
|
134
139
|
}
|
|
135
140
|
async set(key, value) {
|
|
136
|
-
if (value === this.
|
|
141
|
+
if (value === this._store.get(key))
|
|
137
142
|
return;
|
|
138
143
|
const callback = () => this.notify(key);
|
|
139
144
|
if (value && typeof value === "function") {
|
|
@@ -142,25 +147,25 @@ export class SignalStore extends IDebouncer {
|
|
|
142
147
|
if (value && typeof value === "object") {
|
|
143
148
|
value = this.wrapObject(value, callback);
|
|
144
149
|
}
|
|
145
|
-
setAncestorValue(this
|
|
150
|
+
setAncestorValue(this, key, value);
|
|
146
151
|
await callback();
|
|
147
152
|
}
|
|
148
153
|
del(key) {
|
|
149
|
-
this.
|
|
154
|
+
this._store.delete(key);
|
|
150
155
|
this.observers.delete(key);
|
|
151
156
|
}
|
|
152
157
|
has(key) {
|
|
153
|
-
return this.
|
|
158
|
+
return this._store.has(key);
|
|
154
159
|
}
|
|
155
160
|
effect(observer) {
|
|
156
161
|
return observer.call(this.proxify(observer));
|
|
157
162
|
}
|
|
158
163
|
proxify(observer) {
|
|
159
|
-
const keys = Array.from(this.
|
|
164
|
+
const keys = Array.from(this._store.entries()).map(([key]) => key);
|
|
160
165
|
const keyval = Object.fromEntries(keys.map((key) => [key, undefined]));
|
|
161
166
|
return new Proxy(keyval, {
|
|
162
167
|
get: (_, prop, receiver) => {
|
|
163
|
-
if (typeof prop === "string" && getAncestorKeyStore(this
|
|
168
|
+
if (typeof prop === "string" && getAncestorKeyStore(this, prop)) {
|
|
164
169
|
return this.get(prop, observer);
|
|
165
170
|
}
|
|
166
171
|
else if (prop === "$") {
|
|
@@ -231,7 +236,7 @@ export class SignalStore extends IDebouncer {
|
|
|
231
236
|
eval(expr, args = {}) {
|
|
232
237
|
// Determine whether we have already been proxified to avoid doing it again.
|
|
233
238
|
const thisArg = this._observer ? this : this.$;
|
|
234
|
-
if (this.
|
|
239
|
+
if (this._store.has(expr)) {
|
|
235
240
|
// Shortcut: if the expression is just an item from the value store, use that directly.
|
|
236
241
|
return thisArg[expr];
|
|
237
242
|
}
|
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,Q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