mutorjs 1.3.3 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var pe=Object.defineProperty;var Le=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var Ye=Object.prototype.hasOwnProperty;var Ge=(e,r)=>{for(var t in r)pe(e,t,{get:r[t],enumerable:!0})},Je=(e,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of We(r))!Ye.call(e,o)&&o!==t&&pe(e,o,{get:()=>r[o],enumerable:!(s=Le(r,o))||s.enumerable});return e};var qe=e=>Je(pe({},"__esModule",{value:!0}),e);var tt={};Ge(tt,{handleBuildCommand:()=>Fe,handleCompileCommand:()=>Me,handleRenderCommand:()=>je,parseArgs:()=>Ie,safeParseJsonFile:()=>ce,safeReadFile:()=>ae,safeWriteFile:()=>ge});module.exports=qe(tt);var $=require("fs"),F=require("process");var be="1.3.3";var Te=require("fs"),P=require("fs/promises"),B=require("path");function ue(e,r){return`${" ".repeat(e+r)}^`}var g=class e extends Error{constructor(t){super(t);this.name="MutorError";Object.setPrototypeOf(this,e.prototype)}},W=class e extends g{constructor(t,s,o,c,p){let m=s.toString().length+2,i=`${t}
2
+ "use strict";var pe=Object.defineProperty;var Le=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var Ye=Object.prototype.hasOwnProperty;var Ge=(e,r)=>{for(var t in r)pe(e,t,{get:r[t],enumerable:!0})},Je=(e,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of We(r))!Ye.call(e,o)&&o!==t&&pe(e,o,{get:()=>r[o],enumerable:!(s=Le(r,o))||s.enumerable});return e};var qe=e=>Je(pe({},"__esModule",{value:!0}),e);var tt={};Ge(tt,{handleBuildCommand:()=>Fe,handleCompileCommand:()=>Me,handleRenderCommand:()=>je,parseArgs:()=>Ie,safeParseJsonFile:()=>ce,safeReadFile:()=>ae,safeWriteFile:()=>ge});module.exports=qe(tt);var $=require("fs"),F=require("process");var be="1.3.4";var Te=require("fs"),P=require("fs/promises"),B=require("path");function ue(e,r){return`${" ".repeat(e+r)}^`}var g=class e extends Error{constructor(t){super(t);this.name="MutorError";Object.setPrototypeOf(this,e.prototype)}},W=class e extends g{constructor(t,s,o,c,p){let m=s.toString().length+2,i=`${t}
3
3
 
4
4
  `;i+=`at ${p}:${s}:${c+1}
5
5
  `,s>1&&(i+=`${(s-1).toString().padStart(m-2)} | ...
@@ -8,7 +8,7 @@
8
8
  `).length,o=e.lastIndexOf(`
9
9
  `,r-1)+1;return[s,o]}function Z(e,r){let t=e.indexOf(`
10
10
  `,r);return e.slice(r,t===-1?void 0:t).replaceAll(" "," ")}function q(e,r){let{scope:t,forbiddenProps:s,allowedProps:o}=r;function c(a){return t.includes(a)?a:`ctx.${a}`}function p(a){switch(a.type){case 17:return"}";case 5:return a.value;case 4:return`\`${/\$\\/.test(a.value)?z(a.value):a.value}\``;case 10:return a.true?"true":"false";case 12:return"null";case 11:return"undefined";case 7:return c(a.value);case 9:return`(${p(a.expr)})`;case 2:return`${a.operator}${p(a.expr)}`;case 0:return`${p(a.left)} ${a.operator} ${p(a.right)}`;case 1:return`${p(a.condition)} ? ${p(a.left)} : ${p(a.right)}`;case 8:return i(a);case 3:return u(a);case 6:return m(a);case 13:return h(a);case 16:return"} else {";case 14:return y(a);case 15:return w(a);default:throw new g(`Unsupported expression type: ${a.type}`)}}function m(a){if(a.left.type!==7)throw{message:"Invalid usage of namespace operator.",pos:a.pos};return`namespaces.${a.left.value}.${a.right.value}`}function i(a){let b=p(a.left);if(a.bracketNotation){let d=p(a.right),O=a.optional?"?.":"";return a.right.type===4||a.right.type===5?`${b}${O}[${d}]`:`${b}${O}[validateComputedProps(${d}, allowedProps, forbiddenProps)]`}else{let d=a.right.value,O=a.optional?"?.":".";if(s.has(d)&&!o.has(d))throw{message:"Forbidden property access.",pos:a.right.pos};return`${b}${O}${d}`}}function u(a){let b=p(a.expr),d=a.optional?"?.":"",O=a.args.map(R=>p(R)).join(", ");return`${b}${d}(${O})`}function h(a){let{iterable:b,loopType:d,variable:O}=a;return`for(const ${O} ${d===1?"in":"of"} ${q(b,r)}){`}function y(a){let{condition:b}=a;return`if(${q(b,r)}){`}function w(a){let{condition:b}=a;return`}else if(${q(b,r)}){`}return p(e)}function H(e){switch(e){case 0:return"identifier";case 1:return"keyword";case 2:return"number";case 4:return"operator";case 3:return"string"}}function fe(e,r){let t=0,s=!1;function o(n,l){let f=e[t],A=e[e.length-1];if(!f)throw{message:`Unexpected end of expression. Expected ${l?`'${l}'`:`${n===0?"an":"a"} ${H(n)}`}.`,pos:A.pos+A.value.length-1};if(f.type!==n)throw{message:`Unexpected token type. Expected ${l?`'${l}'`:H(n)} but got ${H(f.type)} instead.`,pos:f.pos};if(l!==void 0&&f.value!==l)throw{message:`Unexpected token '${f?.value}'. Expected ${n===0?"an":"a"} ${H(n)} instead.`,pos:f.pos};return e[t++]}function c(){let n=e[t-1].pos,l=o(0).value,f;try{f=o(1,"in")}catch{f=o(1,"of")}let A=f.value==="in"?1:0,L=S();return{type:13,loopType:A,iterable:L,variable:l,pos:n}}function p(){let n=S();return{condition:n,pos:n.pos,type:14}}function m(){let n=e[t-1].pos;try{return o(1,"if"),{...p(),type:15,pos:n}}catch{return{type:16,pos:n}}}function i(){let n=[];if(e[t]?.type===4&&e[t]?.value===")")return n;for(n.push(S());e[t]?.type===4&&e[t]?.value===","&&e[t]?.value!==")";)t++,n.push(S());return n}function u(){let n=e[t++];if(n?.type===2)return{type:5,value:n.value,pos:n.pos};if(n?.type===3)return{type:4,value:n.value,pos:n.pos};if(n?.type===1){if(n.value==="for"&&t===1)return c();if(n.value==="true"||n.value==="false")return{type:10,true:n.value==="true",pos:n.pos};if(n.value==="undefined")return{type:11,pos:n.pos};if(n.value==="null")return{type:12,pos:n.pos};if(n.value==="end"&&e.length===1)return{type:17,pos:n.pos};if(n.value==="if"&&t===1)return p();if(n.value==="else"&&t===1)return m()}if(n?.type===0)return{type:7,value:n.value,pos:n.pos};if(n?.type===4&&n.value==="("){let l=S();return o(4,")"),{type:9,expr:l,pos:n.pos}}if(n?.type===4&&Pe.has(n.value)){let l=n.value,f=S();return{type:2,operator:l,expr:f,pos:n.pos}}throw t>e.length?{message:"Unexpected end of expression.",pos:e[e.length-1].pos}:{message:`Unexpected token '${n?.value}'.`,pos:n.pos}}function h(){let n=u();for(;e[t];){let l=e[t];if(l?.type===4&&l?.value==="("){if(t++,!s&&!r.allowFnCalls)throw{message:"Function calls are not allowed.",pos:e[t-1].pos};let f=i();o(4,")"),n={type:3,expr:n,args:f,pos:e[t-1].pos}}else if(l?.type===4&&l?.value==="?."&&e[t+1]?.type===4&&e[t+1]?.value==="("){if(t++,t++,!s&&!r.allowFnCalls)throw{message:"Function calls are not allowed.",pos:e[t-1].pos};let f=i();o(4,")"),n={type:3,expr:n,args:f,optional:!0,pos:e[t-1].pos}}else if(l?.type===4&&Ce.has(l?.value)){let f=l?.value==="::",A=l?.value==="[",L=l?.value==="?.";if(t++,f&&(e[t-2]?.type!==0||e[t]?.type!==0))throw{message:`Invalid namespaces access. Expected syntax <IDENTIFIER>::<IDENTIFIER>, but got '${e[t-2]?.value}::${e[t]?.value}' instead.`,pos:e[t]?.pos};if(f){s=!0;let C=u();n={type:6,left:n,right:C,pos:e[t-1].pos}}else if(A){let C=S();o(4,"]"),n={type:8,right:C,left:n,bracketNotation:!0,pos:e[t-1].pos}}else if(L)if(e[t]?.type===4&&e[t]?.value==="["){t++;let C=S();o(4,"]"),n={type:8,left:n,right:C,bracketNotation:!0,optional:!0,pos:e[t-1].pos}}else{let C=u();n={type:8,left:n,right:C,optional:!0,pos:e[t-1].pos}}else{let C=u();n={type:8,left:n,right:C,pos:e[t-1].pos}}}else break}return s=!1,n}function y(){let n=h();for(;e[t]?.type===4&&Re.has(e[t]?.value);){let l=e[t++].value,f=h();n={type:0,left:n,right:f,operator:l,pos:e[t-1].pos}}return n}function w(){let n=y();for(;e[t]?.type===4&&Se.has(e[t]?.value);){let l=e[t++].value,f=y();n={type:0,left:n,right:f,operator:l,pos:e[t-1].pos}}return n}function a(){let n=w();for(;e[t]?.type===4&&le.has(e[t]?.value);){let l=e[t++].value,f=w();n={type:0,left:n,right:f,operator:l,pos:e[t-1].pos}}return n}function b(){let n=a();for(;e[t]?.type===4&&le.has(e[t]?.value);){let l=e[t++].value,f=a();n={type:0,left:n,right:f,operator:l,pos:e[t-1].pos}}return n}function d(){let n=b();for(;e[t]?.type===4&&xe.has(e[t]?.value);){let l=e[t++].value,f=b();n={type:0,left:n,right:f,operator:l,pos:e[t-1].pos}}return n}function O(){let n=R();for(;e[t]?.type===4&&e[t]?.value==="||";){let l=e[t++].value,f=R();n={type:0,left:n,right:f,operator:l,pos:e[t-1].pos}}return n}function R(){let n=U();for(;e[t]?.type===4&&e[t]?.value==="&&";){let l=e[t++].value,f=U();n={type:0,left:n,right:f,operator:l,pos:e[t-1].pos}}return n}function U(){let n=d();for(;e[t]?.type===4&&e[t]?.value==="??";){let l=e[t++].value,f=d();n={type:0,left:n,right:f,operator:l,pos:e[t-1].pos}}return n}function S(){let n=O();if(e[t]?.type!==4||e[t]?.value!=="?")return n;t++;let l=S();o(4,":");let f=S();return{type:1,left:l,right:f,condition:n,pos:e[t-1].pos}}let te=S();if(t!==e.length)throw{pos:e[t].pos,message:`Unexpected end of expression.
11
- Expected end of expression but found "${e[t].value}".`};return te}function de(e,{delimiters:r}){let t=`${r.openingTag}${r.whitespaceTrim}`,s=`${r.whitespaceTrim}${r.closingTag}`,o=e.startsWith(t),c=e.endsWith(s),p=e.startsWith(o?t+r.commentTag:r.openingTag+r.commentTag);if(p)return{isComment:p,leftTrim:o,rightTrim:c};let m=e.slice(o?t.length:r.openingTag.length,e.length-(c?s.length:r.closingTag.length)),i=m.trim(),u=i.startsWith("for")||i.startsWith("if")||i.startsWith("else"),h=i.startsWith("for")||i.startsWith("if"),y=i==="end",w=i.startsWith("for");return{leftTrim:o,rightTrim:c,inner:m,isBlock:u,isBlockEnd:y,hasContext:w,requiresBlockClose:h}}function me(e){let r=0,t="",s=[];function o(){let i="";if(/[a-zA-Z$_]/.test(t)){let u=r;for(;/[a-zA-Z$_0-9]/.test(e[u])&&u<e.length;)i+=e[u],u++;s.push({type:Oe.has(i)?1:0,value:i,pos:r}),r=u,t=e[r]}}function c(){if(t!=='"'&&t!=="'"&&t!=="`")return!1;let i=t,u=r,h=r+1,y="";for(;h<e.length;){let w=e[h];if(w==="\\"){if(h+1>=e.length)throw{pos:h,message:"Unexpected end of string after escape character."};y+=w,y+=e[h+1],h+=2;continue}if(w===i)break;y+=w,h++}if(h>=e.length||e[h]!==i)throw{pos:u,message:`String literal missing closing ${i}.`};return s.push({type:3,value:y,pos:u}),r=h+1,!0}function p(){if(/[0-9]/.test(t)){let i=r,u="";for(;/[0-9.oxe]/.test(e[i])&&i<e.length;)u+=e[i],i++;let h=Number(u);if(Number.isNaN(h))throw{pos:r,message:"Found invalid number literal."};s.push({type:2,value:`${h}`,pos:r}),r=i-1,t=e[r]}}function m(){let i=`${t}${e[r+1]}`;if(k.has(i)){s.push({type:4,value:i,pos:r}),r++;return}if(k.has(t)){s.push({type:4,value:t,pos:r});return}}for(;r<e.length;){if(t=e[r],p(),o(),c(),m(),!/[a-zA-Z$_0-9\s\t\r\n'"`]/.test(t)&&!k.has(t)&&!k.has(e[r-1]+t))throw{message:`Unexpected token '${t}' in expression.`,pos:r};r++}return s}function he(e,r,t){let s=[],o=[],{delimiters:c,keepOpeningTagEscapeDelimiter:p,allowFnCalls:m,allowedProps:i,forbiddenProps:u,autoEscape:h}=r,y=!1,w=0,a='let acc="";';for(;w<e.length;){let O=function(){let E=d,T=0;for(;E>=c.openingTagEscape.length&&e.slice(E-c.openingTagEscape.length,E)===c.openingTagEscape;)T++,E-=c.openingTagEscape.length;return T%2===1};var b=O;let d=e.indexOf(c.openingTag,w);if(d===-1){let E=e.slice(w);y&&(E=E.trimStart()),E&&(a+=`acc+=\`${z(E)}\`;`);break}if(O()){let E=e.slice(w,p?d+c.openingTagEscape.length+1:d-c.openingTag.length+1);y&&(E=E.trimStart(),y=!1),a+=`acc+=\`${z(E)}\`;`,p||(a+=`acc+=\`${c.openingTag}\`;`),w=d+c.openingTag.length;continue}let R=e.indexOf(c.closingTag,d);if(R===-1){let[E,T]=V(e,d),I=Z(e,T);throw new W("No closing tag found.",E,I,d,t.path)}let U=e.slice(d,R+c.closingTag.length),{inner:S,leftTrim:te,rightTrim:n,isBlock:l,isBlockEnd:f,hasContext:A,requiresBlockClose:L,isComment:C}=de(U,{delimiters:c}),j=e.slice(w,d);j&&(y&&(j=j.trimStart()),te&&(j=j.trimEnd()),j&&(a+=`acc+=\`${z(j)}\`;`)),y=!1,w=R+c.closingTag.length;try{if(!C){let E=me(S),T=fe(E,{allowFnCalls:m});if(l&&L&&A?(s.push(T.variable),o.push({type:0,pos:d})):l&&L&&!A&&o.push({type:1,pos:d}),f){let re=o.pop();if(re?.type===0&&s.pop(),re===void 0)throw{message:"Unexpected end of block",pos:d}}let I=q(T,{allowedProps:i,forbiddenProps:u,scope:s});l||f?a+=I:a+=h&&!I.startsWith("namespaces.Mutor.include")?`acc+=escapeFn(${I});`:`acc+=${I};`}n&&(y=!0)}catch(E){let{message:T,pos:I}=E,re=te?c.whitespaceTrim.length+c.openingTag.length:c.openingTag.length,Ee=d+I+re,[Be,_e]=V(e,Ee),Ue=Z(e,_e);throw new W(T,Be,Ue,Ee-_e,t.path)}}if(o.length){let d=o.pop()?.pos,[O,R]=V(e,d),U=Z(e,R);throw new W("Unclosed block detected.",O,U,d-R,t.path)}return a+="return acc;",new Function("ctx","namespaces","allowedProps","forbiddenProps","escapeFn","validateComputedProps",a)}var Q=class{constructor(r={}){this.__currentRenderedPath="";this.__includeStack=new Set;this.__cacheSize=0;this.__config={...N};this.__compiledTemplatesMap=new Map;this.__currentContext=null;this.__namespaces={...Ne,Mutor:{include:(r,t)=>{if(this.__includeStack.has(r))throw new g(`Circular include detected:
11
+ Expected end of expression but found "${e[t].value}".`};return te}function de(e,{delimiters:r}){let t=`${r.openingTag}${r.whitespaceTrim}`,s=`${r.whitespaceTrim}${r.closingTag}`,o=e.startsWith(t),c=e.endsWith(s),p=e.startsWith(o?t+r.commentTag:r.openingTag+r.commentTag);if(p)return{isComment:p,leftTrim:o,rightTrim:c};let m=e.slice(o?t.length:r.openingTag.length,e.length-(c?s.length:r.closingTag.length)),i=m.trim(),u=i.startsWith("for")||i.startsWith("if")||i.startsWith("else"),h=i.startsWith("for")||i.startsWith("if"),y=i==="end",w=i.startsWith("for");return{leftTrim:o,rightTrim:c,inner:m,isBlock:u,isBlockEnd:y,hasContext:w,requiresBlockClose:h}}function me(e){let r=0,t="",s=[];function o(){let i="";if(/[a-zA-Z$_]/.test(t)){let u=r;for(;/[a-zA-Z$_0-9]/.test(e[u])&&u<e.length;)i+=e[u],u++;s.push({type:Oe.has(i)?1:0,value:i,pos:r}),r=u,t=e[r]}}function c(){if(t!=='"'&&t!=="'"&&t!=="`")return!1;let i=t,u=r,h=r+1,y="";for(;h<e.length;){let w=e[h];if(w==="\\"){if(h+1>=e.length)throw{pos:h,message:"Unexpected end of string after escape character."};y+=w,y+=e[h+1],h+=2;continue}if(w===i)break;y+=w,h++}if(h>=e.length||e[h]!==i)throw{pos:u,message:`String literal missing closing ${i}.`};s.push({type:3,value:y,pos:u}),r=h}function p(){if(/[0-9]/.test(t)){let i=r,u="";for(;/[0-9.oxe]/.test(e[i])&&i<e.length;)u+=e[i],i++;let h=Number(u);if(Number.isNaN(h))throw{pos:r,message:"Found invalid number literal."};s.push({type:2,value:`${h}`,pos:r}),r=i-1,t=e[r]}}function m(){let i=`${t}${e[r+1]}`;if(k.has(i)){s.push({type:4,value:i,pos:r}),r++;return}if(k.has(t)){s.push({type:4,value:t,pos:r});return}}for(;r<e.length;){if(t=e[r],p(),o(),c(),m(),!/[a-zA-Z$_0-9\s\t\r\n'"`]/.test(t)&&!k.has(t)&&!k.has(e[r-1]+t))throw{message:`Unexpected token '${t}' in expression.`,pos:r};r++}return s}function he(e,r,t){let s=[],o=[],{delimiters:c,keepOpeningTagEscapeDelimiter:p,allowFnCalls:m,allowedProps:i,forbiddenProps:u,autoEscape:h}=r,y=!1,w=0,a='let acc="";';for(;w<e.length;){let O=function(){let E=d,T=0;for(;E>=c.openingTagEscape.length&&e.slice(E-c.openingTagEscape.length,E)===c.openingTagEscape;)T++,E-=c.openingTagEscape.length;return T%2===1};var b=O;let d=e.indexOf(c.openingTag,w);if(d===-1){let E=e.slice(w);y&&(E=E.trimStart()),E&&(a+=`acc+=\`${z(E)}\`;`);break}if(O()){let E=e.slice(w,p?d+c.openingTagEscape.length+1:d-c.openingTag.length+1);y&&(E=E.trimStart(),y=!1),a+=`acc+=\`${z(E)}\`;`,p||(a+=`acc+=\`${c.openingTag}\`;`),w=d+c.openingTag.length;continue}let R=e.indexOf(c.closingTag,d);if(R===-1){let[E,T]=V(e,d),I=Z(e,T);throw new W("No closing tag found.",E,I,d,t.path)}let U=e.slice(d,R+c.closingTag.length),{inner:S,leftTrim:te,rightTrim:n,isBlock:l,isBlockEnd:f,hasContext:A,requiresBlockClose:L,isComment:C}=de(U,{delimiters:c}),j=e.slice(w,d);j&&(y&&(j=j.trimStart()),te&&(j=j.trimEnd()),j&&(a+=`acc+=\`${z(j)}\`;`)),y=!1,w=R+c.closingTag.length;try{if(!C){let E=me(S),T=fe(E,{allowFnCalls:m});if(l&&L&&A?(s.push(T.variable),o.push({type:0,pos:d})):l&&L&&!A&&o.push({type:1,pos:d}),f){let re=o.pop();if(re?.type===0&&s.pop(),re===void 0)throw{message:"Unexpected end of block",pos:d}}let I=q(T,{allowedProps:i,forbiddenProps:u,scope:s});l||f?a+=I:a+=h&&!I.startsWith("namespaces.Mutor.include")?`acc+=escapeFn(${I});`:`acc+=${I};`}n&&(y=!0)}catch(E){let{message:T,pos:I}=E,re=te?c.whitespaceTrim.length+c.openingTag.length:c.openingTag.length,Ee=d+I+re,[Be,_e]=V(e,Ee),Ue=Z(e,_e);throw new W(T,Be,Ue,Ee-_e,t.path)}}if(o.length){let d=o.pop()?.pos,[O,R]=V(e,d),U=Z(e,R);throw new W("Unclosed block detected.",O,U,d-R,t.path)}return a+="return acc;",new Function("ctx","namespaces","allowedProps","forbiddenProps","escapeFn","validateComputedProps",a)}var Q=class{constructor(r={}){this.__currentRenderedPath="";this.__includeStack=new Set;this.__cacheSize=0;this.__config={...N};this.__compiledTemplatesMap=new Map;this.__currentContext=null;this.__namespaces={...Ne,Mutor:{include:(r,t)=>{if(this.__includeStack.has(r))throw new g(`Circular include detected:
12
12
  ${Array.from(this.__includeStack).join(`
13
13
  `)}
14
14
  ${r}`);try{return this.__includeStack.add(r),this.renderComponent(r,t??this.__currentContext)}finally{this.__includeStack.delete(r)}}}};this.addConfig(r),Object.defineProperty(this.__namespaces.Mutor,"$$context",{get:()=>this.__currentContext})}addConfig(r){let{autoEscape:t,delimiters:s,allowedProps:o,forbiddenProps:c,keepOpeningTagEscapeDelimiter:p,allowFnCalls:m,cache:i,build:u}=r;return this.__config={build:{include:new Set([...u?.include||N.build.include]),exclude:new Set([...N.build.exclude,...u?.exclude||[]])},autoEscape:t===!0?!0:t!==!1,allowedProps:o||N.allowedProps,allowFnCalls:!!m,cache:{...N.cache,...i||{}},forbiddenProps:new Set([...N.forbiddenProps,...c||[]]),keepOpeningTagEscapeDelimiter:p===!0?!0:p!==!1,delimiters:{...N.delimiters,...s||{}}},this.__config}restoreDefaultConfig(){this.__config={...N}}compile(r){return he(r,this.__config,{path:this.__currentRenderedPath||"anonymous"})}render(r,t){let s=this.__currentContext;s!==t&&(this.__currentContext=t);let o=this.compile(r)(J(t),this.__namespaces,this.__config.allowedProps,this.__config.forbiddenProps,Y,G);return this.__currentContext=s,o}renderComponent(r,t){if(!this.__compiledTemplatesMap.has(r))throw new g(`No template exists with the identifier '${r}'`);let s=this.__currentRenderedPath,o=this.__currentContext,c=this.__compiledTemplatesMap.get(r);this.__currentContext=t,this.__currentRenderedPath=r;let p=c.fn(J(t),this.__namespaces,this.__config.allowedProps,this.__config.forbiddenProps,Y,G);return this.__currentContext=o,this.__currentRenderedPath=s,p}registerComponent(r,t){let s=t.length*2+500;if(this.__cacheSize+s>this.__config.cache.maxSize&&!this.createEntrySpaceForTemplate(s))throw new g(`The template for the component '${r}' is too large. Consider increasing 'cache.maxSize' in the config`);this.__cacheSize+=t.length*2+500,this.__compiledTemplatesMap.set(r,{fn:this.compile(t),size:s})}reset(){this.__config={...N},this.__compiledTemplatesMap.clear(),this.__currentContext=null,this.__cacheSize=0}createEntrySpaceForTemplate(r){if(this.__cacheSize+r<this.__config.cache.maxSize)return!0;if(r>this.__config.cache.maxSize)return!1;let t=this.__compiledTemplatesMap.entries().next().value;if(t){let[s,o]=t;this.__compiledTemplatesMap.delete(s),this.__cacheSize-=o.size}return this.createEntrySpaceForTemplate(r)}getDiagnostics(){let r=this.__config.cache.maxSize;return{bytesUsed:this.__cacheSize,bytesMax:r,readableUsed:`${(this.__cacheSize/1024/1024).toFixed(2)} MB`,readableMax:`${(r/1024/1024).toFixed(2)} MB`,totalEntries:this.__compiledTemplatesMap.size,percentFull:r>0?Math.min(100,Math.round(this.__cacheSize/r*100)):0,avgTemplateSize:this.__compiledTemplatesMap.size>0?Math.round(this.__cacheSize/this.__compiledTemplatesMap.size):0}}};var X=class extends Q{constructor(r={}){super(r),this.__namespaces.Mutor.include=(t,s)=>{let o=_(this.__currentRenderedPath,t);if(this.__includeStack.has(o))throw new g(`Circular include detected: