@kosatyi/ejs 0.0.97 → 0.0.98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ejs={})}(this,(function(t){"use strict";function e(t,e,n,r,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}function n(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function r(){r=function(){return e};var t,e={},n=Object.prototype,o=n.hasOwnProperty,i=Object.defineProperty||function(t,e,n){t[e]=n.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function l(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,n){return t[e]=n}}function f(t,e,n,r){var o=e&&e.prototype instanceof y?e:y,a=Object.create(o.prototype),c=new N(r||[]);return i(a,"_invoke",{value:P(t,n,c)}),a}function h(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p="suspendedStart",v="suspendedYield",g="executing",b="completed",m={};function y(){}function d(){}function w(){}var E={};l(E,c,(function(){return this}));var x=Object.getPrototypeOf,j=x&&x(x(R([])));j&&j!==n&&o.call(j,c)&&(E=j);var O=w.prototype=y.prototype=Object.create(E);function L(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function n(r,i,a,c){var u=h(t[r],t,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&o.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var r;i(this,"_invoke",{value:function(t,o){function i(){return new e((function(e,r){n(t,o,e,r)}))}return r=r?r.then(i,i):i()}})}function P(e,n,r){var o=p;return function(i,a){if(o===g)throw Error("Generator is already running");if(o===b){if("throw"===i)throw a;return{value:t,done:!0}}for(r.method=i,r.arg=a;;){var c=r.delegate;if(c){var u=F(c,r);if(u){if(u===m)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===p)throw o=b,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=g;var s=h(e,n,r);if("normal"===s.type){if(o=r.done?b:v,s.arg===m)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(o=b,r.method="throw",r.arg=s.arg)}}}function F(e,n){var r=n.method,o=e.iterator[r];if(o===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,F(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var i=h(o,e.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,m;var a=i.arg;return a?a.done?(n[e.resultName]=a.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,m):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function R(e){if(e||""===e){var n=e[c];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function n(){for(;++r<e.length;)if(o.call(e,r))return n.value=e[r],n.done=!1,n;return n.value=t,n.done=!0,n};return i.next=i}}throw new TypeError(typeof e+" is not iterable")}return d.prototype=w,i(O,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:d,configurable:!0}),d.displayName=l(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,l(t,s,"GeneratorFunction")),t.prototype=Object.create(O),t},e.awrap=function(t){return{__await:t}},L(k.prototype),l(k.prototype,u,(function(){return this})),e.AsyncIterator=k,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new k(f(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},L(O),l(O,s,"Generator"),l(O,c,(function(){return this})),l(O,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=R,N.prototype={constructor:N,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var n in this)"t"===n.charAt(0)&&o.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function r(r,o){return c.type="throw",c.arg=e,n.next=r,o&&(n.method="next",n.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),s=o.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&o.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),T(n),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;T(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:R(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),m}},e}var o=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},i=function(t){return Array.isArray(t)},a=function(t){return"function"==typeof t},c=function(t){return"string"==typeof t},u=function(t){return"boolean"==typeof t},s=function(t){return void 0===t},l="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),f={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},h={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},p=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},v=p(h),g=p(f),b=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(v,(function(t){return h[t]}))},m=function(t,e){var n=t;return null==n?"":!0===Boolean(e)?b(n):n},y=function(t,e){return Boolean(t instanceof e)},d=function(t,e,n){for(var r=t,o=String(e).split("."),i=o.pop(),c=0;c<o.length;c++){var u=o[c];if(a(r.toJSON)&&(r=r.toJSON()),n&&!1===r.hasOwnProperty(u)){r={};break}r=r[u]=r[u]||{}}return a(r.toJSON)&&(r=r.toJSON()),[r,i]},w=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},E=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return n.filter((function(t){return t})).reduce((function(t,e){return Object.assign(t,e)}),t)},x=function(){},j=function(t,e){var n;for(n in t)L(t,n)&&e(t[n],n,t)},O=function(t,e){return function(t,e){var n=t instanceof Array,r=n?[]:{};return j(t,(function(t,o,i){var a=e(t,o,i);!1===s(a)&&(n?r.push(a):r[o]=a)})),r}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},L=function(t,e){return t&&t.hasOwnProperty(e)},k={export:"ejsPrecompiled",cache:!0,chokidar:null,path:"views",resolver:function(t,e){return Promise.resolve(["resolver is not defined",t,e].join(" "))},extension:"ejs",rmWhitespace:!0,withObject:!0,globalHelpers:[],vars:{SCOPE:"ejs",COMPONENT:"ui",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},P=function(t,e){E(t,{path:o(c,k.path,t.path,e.path),export:o(c,k.export,t.export,e.export),resolver:o(a,k.resolver,t.resolver,e.resolver),extension:o(c,k.extension,t.extension,e.extension),withObject:o(u,k.withObject,t.withObject,e.withObject),rmWhitespace:o(u,k.rmWhitespace,t.rmWhitespace,e.rmWhitespace),cache:o(u,k.cache,t.cache,e.cache),token:E({},k.token,t.token,e.token),vars:E({},k.vars,t.vars,e.vars),globalHelpers:o(i,k.globalHelpers,t.globalHelpers,e.globalHelpers)})},F="undefined"!=typeof globalThis?globalThis:window||self;function S(t){if(!1===y(this,S))return new S;var e={enabled:!0,list:{}};this.configure=function(t){e.enabled=t.cache,!1===l&&this.load(F[t.export])},this.clear=function(){e.list={}},this.load=function(t){return e.enabled&&E(e.list,t||{}),this},this.get=function(t){if(e.enabled)return e.list[t]},this.set=function(t,n){return e.enabled&&(e.list[t]=n),this},this.resolve=function(t){return Promise.resolve(this.get(t))},this.remove=function(t){delete e.list[t]},this.exist=function(t){return L(e.list,t)}}var T=[{symbol:"-",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(t){return"')\n/**".concat(t,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(t){return"')\n".concat(t.trim(),"\n").concat(this.BUFFER,"('")}}];function N(t){if(!1===y(this,N))return new N(t);var e={};this.configure=function(t){e.withObject=t.withObject,e.rmWhitespace=t.rmWhitespace,e.token=t.token,e.vars=t.vars,e.globalHelpers=t.globalHelpers,e.matches=[],e.formats=[],e.slurp={match:"[s\t\n]*",start:[e.token.start,"_"],end:["_",e.token.end]},T.forEach((function(t){e.matches.push(e.token.start.concat(t.symbol).concat(e.token.regex).concat(e.token.end)),e.formats.push(t.format.bind(e.vars))})),e.regex=new RegExp(e.matches.join("|").concat("|$"),"g"),e.slurpStart=new RegExp([e.slurp.match,e.slurp.start.join("")].join(""),"gm"),e.slurpEnd=new RegExp([e.slurp.end.join(""),e.slurp.match].join(""),"gm")},this.compile=function(t,n){var r=e.vars,o=r.SCOPE,i=r.SAFE,a=r.BUFFER,c=r.COMPONENT,u=e.globalHelpers;t=String(t),e.rmWhitespace&&(t=t.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=t.replace(e.slurpStart,e.token.start).replace(e.slurpEnd,e.token.end);var s,l,h,p="".concat(a,"('");s=e.regex,l=function(n,r,o){p+=(""+t.slice(r,o)).replace(g,(function(t){return"\\"+f[t]})),n.forEach((function(t,n){t&&(p+=e.formats[n](t))}))},h=0,t.replace(s,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return l(t,h,e),h=e+n.length,n})),p="try{".concat(p+="');","}catch(e){return ").concat(a,".error(e)}"),e.withObject&&(p="with(".concat(o,"){").concat(p,"}")),p="".concat(a,".start();").concat(p,"return ").concat(a,".end();"),p+="\n//# sourceURL=".concat(n);var v=null,b=[o,c,a,i].concat(u);try{(v=Function.apply(null,b.concat(p))).source="(function(".concat(b.join(","),"){\n").concat(p,"\n});")}catch(t){throw t.filename=n,t.source=p,t}return v},this.configure(t)}function R(t,e,n){if(!1===y(this,R))return new R(t,e,n);if(!1===y(e,S))throw new TypeError("cache is not instance of Cache");if(!1===y(n,N))throw new TypeError("compiler is not instance of Compiler");var r={},o=function(t){return r.resolver(r.path,t)};this.configure=function(t){r.path=t.path,r.cache=t.cache,a(t.resolver)&&(r.resolver=t.resolver)},this.get=function(t){return e.exist(t)?e.resolve(t):o(t).then((function(r){return function(t,n){return e.set(t,n),n}(t,function(t,e){return a(t)?t:n.compile(t,e)}(r,t))}))},this.configure(t)}var B=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],_=" ",A='"',C="/",M="<",$=">",U=function(t,e,n){var r=[],o=-1===B.indexOf(t),i=function(t,e){var n=[];return j(t,(function(t,r,o){var i=e(t,r,o);!1===s(i)&&n.push(i)})),n}(e,(function(t,e){if(null!=t)return[b(e),[A,b(t),A].join("")].join("=")})).join(_);return r.push([M,t,_,i,$].join("")),n&&o&&r.push(n instanceof Array?n.join(""):n),o&&r.push([M,C,t,$].join("")),r.join("")};function q(t){this.name="TemplateError",this.message=t,Error.call(this)}function H(t){q.call(this),this.name="TemplateNotFound",this.message=t}function G(t){q.call(this),this.name="TemplateSyntaxError",this.message=t}function W(t){return Promise.all(t||[]).then((function(t){return t.join("")})).catch((function(t){return t}))}function J(){var t=[],e=[];function n(t){e.push(t)}return n.start=function(){e=[]},n.backup=function(){t.push(e.concat()),e=[]},n.restore=function(){var n=e.concat();return e=t.pop(),W(n)},n.error=function(t){return e=t,Promise.reject(new G(e.message));var e},n.end=function(){return W(e)},n}function Y(t){if(!1===y(this,Y))return new Y(t);this.configure=function(t,e){var r,o=t.vars,i=o.BLOCKS,u=o.MACRO,s=o.EXTEND,l=o.LAYOUT,f=o.BUFFER,h=o.COMPONENT;function p(t){this[i]={},this[u]={},E(this,t||{})}this.create=function(t){return new p(t)},this.helpers=function(t){E(p.prototype,t||{})},p.prototype=E({},e||{}),Object.defineProperties(p.prototype,(n(n(n(n(n(n(n(n(n(n(r={},f,{value:J(),writable:!0,configurable:!1,enumerable:!1}),i,{value:{},writable:!0,configurable:!1,enumerable:!1}),u,{value:{},writable:!0,configurable:!1,enumerable:!1}),l,{value:!1,writable:!0,configurable:!1,enumerable:!1}),s,{value:!1,writable:!0,configurable:!1,enumerable:!1}),"getMacro",{value:function(){return this[u]},writable:!1,configurable:!1,enumerable:!1}),"getBuffer",{value:function(){return this[f]},writable:!1,configurable:!1,enumerable:!1}),"getComponent",{value:function(){var t=this;return h in t?function(){return t[h].apply(t,arguments)}:function(){console.log("%s function not defined",h)}},writable:!1,configurable:!1,enumerable:!1}),"getBlocks",{value:function(){return this[i]},writable:!1,configurable:!1,enumerable:!1}),"setExtend",{value:function(t){this[s]=t},writable:!1,configurable:!1,enumerable:!1}),n(n(n(n(n(n(n(n(n(n(r,"getExtend",{value:function(){return this[s]},writable:!1,configurable:!1,enumerable:!1}),"setLayout",{value:function(t){this[l]=t},writable:!1,configurable:!1,enumerable:!1}),"getLayout",{value:function(){return this[l]},writable:!1,configurable:!1,enumerable:!1}),"clone",{value:function(t){var e=[l,s,f];return!0===t&&e.push(i),O(this,e)},writable:!1,configurable:!1,enumerable:!1}),"extend",{value:function(t){this.setExtend(!0),this.setLayout(t)},writable:!1,configurable:!1,enumerable:!1}),"echo",{value:function(t){var e=this.getBuffer();[].slice.call(arguments).forEach(e)},writable:!1,configurable:!1,enumerable:!1}),"fn",{value:function(t){var e=this.getBuffer(),n=this;return function(){return e.backup(),a(t)&&t.apply(n,arguments),e.restore()}},writable:!1,configurable:!1,enumerable:!1}),"get",{value:function(t,e){var n=d(this,t,!0),r=n.shift(),o=n.pop();return L(r,o)?r[o]:e},writable:!0,configurable:!0,enumerable:!1}),"set",{value:function(t,e){var n=d(this,t,!1),r=n.shift(),o=n.pop();return this.getExtend()&&L(r,o)?r[o]:r[o]=e},writable:!1,configurable:!1,enumerable:!1}),"macro",{value:function(t,e){var n=this.getMacro(),r=this.fn(e),o=this;n[t]=function(){return o.echo(r.apply(void 0,arguments))}},writable:!1,configurable:!1,enumerable:!1}),n(n(n(n(n(n(n(n(n(n(r,"call",{value:function(t){var e=this.getMacro()[t],n=[].slice.call(arguments,1);if(a(e))return e.apply(e,n)},writable:!1,configurable:!1,enumerable:!1}),"block",{value:function(t,e){var n=this,r=this.getBlocks();if(r[t]=r[t]||[],r[t].push(this.fn(e)),!this.getExtend()){var o=Object.assign([],r[t]),i=function(){return o.shift()},a=function(){var t=i();return t?function(){n.echo(t(a()))}:x};this.echo(i()(a()))}},writable:!1,configurable:!1,enumerable:!1}),"hasBlock",{value:function(t){return this.getBlocks().hasOwnProperty(t)},writable:!1,configurable:!1,enumerable:!1}),"include",{value:function(t,e,n){var r=!1===n?{}:this.clone(!0),o=E(r,e||{}),i=this.render(t,o);this.echo(i)},writable:!1,configurable:!1,enumerable:!1}),"promiseResolve",{value:function(t,e){return Promise.resolve(a(t)?this.fn(t)():t).then(e.bind(this))},writable:!1,configurable:!1,enumerable:!1}),"use",{value:function(t,e){this.echo(this.promiseResolve(this.require(t),(function(t){var n=this.getMacro();j(t,(function(t,r){n[[e,r].join(".")]=t}))})))},writable:!1,configurable:!1,enumerable:!1}),"async",{value:function(t,e){this.echo(this.promiseResolve(t,(function(t){return this.fn(e)(t)})))},writable:!1,configurable:!1,enumerable:!1}),"each",{value:function(t,e){c(t)&&(t=this.get(t,[])),j(t,e)},writable:!1,configurable:!1,enumerable:!1}),"element",{value:function(t,e,n){return U(t,e,n)},writable:!1,configurable:!1,enumerable:!1}),"el",{value:function(t,e,n){this.echo(this.promiseResolve(n,(function(n){return this.element(t,e,n)})))},writable:!1,configurable:!1,enumerable:!1})))},this.configure(t)}Object.setPrototypeOf(q.prototype,Error.prototype),Object.assign(q.prototype,{code:1}),q.prototype.getCode=function(){return this.code},q.prototype.getMessage=function(){return this.message},q.prototype.toString=function(){return this.getMessage()},Object.setPrototypeOf(H.prototype,q.prototype),Object.assign(H.prototype,{code:404}),Object.setPrototypeOf(G.prototype,q.prototype),Object.assign(G.prototype,{code:500});var I=Math.floor(1e12*Math.random()).toString(36),D={},K=new function t(e){if(!1===y(this,t))return new t(e);var n={},r={};P(r,e||{});var o=new Y(r),i=new N(r),c=new S,u=new R(r,c,i),s=function(t,e){var n=r.globalHelpers,o=[e,e.getComponent(),e.getBuffer(),m].concat(n.filter((function(t){return a(e[t])})).map((function(t){return e[t].bind(e)})));return u.get(t).then((function(t){return t.apply(e,o)}))},l=function(t,e){var n=w(t,r.extension),i=o.create(e);return s(n,i).then((function(t){if(i.getExtend()){i.setExtend(!1);var e=i.getLayout(),n=i.clone();return l(e,n)}return t}))};return this.configure=function(t){return P(r,t=t||{}),o.configure(r,n),i.configure(r),c.configure(r),u.configure(r),r},this.render=function(t,e){return l(t,e)},this.helpers=function(t){o.helpers(E(n,t))},this.preload=function(t){return c.load(t||{})},this.create=function(e){return new t(e)},this.compile=function(t,e){return i.compile(t,e)},this.context=function(t){return o.create(t)},this.helpers({require:function(t){var e=w(t,r.extension),n=o.create({});return s(e,n).then((function(){return n.getMacro()}))},render:l}),this}({cache:!1,withObject:!1,resolver:function(t,e){return new Promise((function(t,n){D.hasOwnProperty(e)?t(D[e]):n(new H("template ".concat(e," not found")))}))}}),X=K.render,z=K.context,Q=K.helpers,V=K.configure,Z=K.create,tt=function(t,e){return t=new URL(t),e&&(t.protocol="https:"),t.origin};var et=I;t.TemplateError=q,t.TemplateNotFound=H,t.TemplateSyntaxError=G,t.configure=V,t.context=z,t.create=Z,t.helpers=Q,t.render=X,t.setRenderer=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.version,o=void 0===n?I:n,i=t.secure,a=void 0===i||i;return function(){var t,n=(t=r().mark((function t(e,n){return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e.data=z({}),e.data.set("version",o),e.data.set("origin",tt(e.req.url,a)),e.data.set("path",e.req.path),e.data.set("query",e.req.query()),e.ejs=function(t,n){return X(t,Object.assign({param:e.req.param()},e.data,n))},e.helpers=function(t){return Q(t)},e.render=function(t,n){return e.html(e.ejs(t,n))},t.next=10,n();case 10:case"end":return t.stop()}}),t)})),function(){var n=this,r=arguments;return new Promise((function(o,i){var a=t.apply(n,r);function c(t){e(a,o,i,c,u,"next",t)}function u(t){e(a,o,i,c,u,"throw",t)}c(void 0)}))});return function(t,e){return n.apply(this,arguments)}}()},t.setTemplates=function(t){Object.assign(D,t||{})},t.version=et}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ejs={})}(this,(function(t){"use strict";function e(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}function n(t,e,n,r,o,i,c){try{var u=t[i](c),a=u.value}catch(t){return void n(t)}u.done?e(a):Promise.resolve(a).then(r,o)}function r(t,e,n){return e=l(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,v()?Reflect.construct(e,n||[],l(t).constructor):e.apply(t,n))}function o(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function c(t,n){return t.get(e(t,n))}function u(t,e,n){o(t,e),e.set(t,n)}function a(t,n,r){return t.set(e(t,n),r),r}function s(t,e){o(t,e),e.add(t)}function f(t,e,n){return e&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,d(r.key),r)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function h(t,e,n){return(e=d(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l(t){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},l(t)}function p(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&g(t,e)}function v(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(v=function(){return!!t})()}function y(){y=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},c=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",a=i.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,n){return t[e]=n}}function f(t,e,n,r){var i=e&&e.prototype instanceof m?e:m,c=Object.create(i.prototype),u=new T(r||[]);return o(c,"_invoke",{value:L(t,n,u)}),c}function h(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var l="suspendedStart",p="suspendedYield",v="executing",g="completed",d={};function m(){}function w(){}function b(){}var k={};s(k,c,(function(){return this}));var j=Object.getPrototypeOf,E=j&&j(j(R([])));E&&E!==n&&r.call(E,c)&&(k=E);var O=b.prototype=m.prototype=Object.create(k);function x(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function P(t,e){function n(o,i,c,u){var a=h(t[o],t,i);if("throw"!==a.type){var s=a.arg,f=s.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,c,u)}),(function(t){n("throw",t,c,u)})):e.resolve(f).then((function(t){s.value=t,c(s)}),(function(t){return n("throw",t,c,u)}))}u(a.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function L(e,n,r){var o=l;return function(i,c){if(o===v)throw Error("Generator is already running");if(o===g){if("throw"===i)throw c;return{value:t,done:!0}}for(r.method=i,r.arg=c;;){var u=r.delegate;if(u){var a=S(u,r);if(a){if(a===d)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===l)throw o=g,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=v;var s=h(e,n,r);if("normal"===s.type){if(o=r.done?g:p,s.arg===d)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(o=g,r.method="throw",r.arg=s.arg)}}}function S(e,n){var r=n.method,o=e.iterator[r];if(o===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,S(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),d;var i=h(o,e.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,d;var c=i.arg;return c?c.done?(n[e.resultName]=c.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,d):c:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,d)}function F(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function M(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(F,this),this.reset(!0)}function R(e){if(e||""===e){var n=e[c];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function n(){for(;++o<e.length;)if(r.call(e,o))return n.value=e[o],n.done=!1,n;return n.value=t,n.done=!0,n};return i.next=i}}throw new TypeError(typeof e+" is not iterable")}return w.prototype=b,o(O,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:w,configurable:!0}),w.displayName=s(b,a,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,a,"GeneratorFunction")),t.prototype=Object.create(O),t},e.awrap=function(t){return{__await:t}},x(P.prototype),s(P.prototype,u,(function(){return this})),e.AsyncIterator=P,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var c=new P(f(t,n,r,o),i);return e.isGeneratorFunction(n)?c:c.next().then((function(t){return t.done?t.value:c.next()}))},x(O),s(O,a,"Generator"),s(O,c,(function(){return this})),s(O,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=R,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(M),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function o(r,o){return u.type="throw",u.arg=e,n.next=r,o&&(n.method="next",n.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var c=this.tryEntries[i],u=c.completion;if("root"===c.tryLoc)return o("end");if(c.tryLoc<=this.prev){var a=r.call(c,"catchLoc"),s=r.call(c,"finallyLoc");if(a&&s){if(this.prev<c.catchLoc)return o(c.catchLoc,!0);if(this.prev<c.finallyLoc)return o(c.finallyLoc)}else if(a){if(this.prev<c.catchLoc)return o(c.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<c.finallyLoc)return o(c.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var c=i?i.completion:{};return c.type=t,c.arg=e,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(c)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),M(n),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;M(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:R(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),d}},e}function g(t,e){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},g(t,e)}function d(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}function m(t){var e="function"==typeof Map?new Map:void 0;return m=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(v())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var o=new(t.bind.apply(t,r));return n&&g(o,n.prototype),o}(t,arguments,l(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),g(n,t)},m(t)}var w=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},b=function(t){return Array.isArray(t)},k=function(t){return"function"==typeof t},j=function(t){return"string"==typeof t},E=function(t){return"boolean"==typeof t},O=function(t){return void 0===t},x="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),P={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},L={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},S=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},F=S(L),M=S(P),T=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(F,(function(t){return L[t]}))},R=function(t,e){var n=t;return null==n?"":!0===Boolean(e)?T(n):n},W=function(t,e){if(!1===function(t,e){return Boolean(t instanceof e)}(t,e))throw new TypeError("".concat(t," in not instance of ").concat(e))},_=function(t,e,n){for(var r=t,o=String(e).split("."),i=o.pop(),c=0;c<o.length;c++){var u=o[c];if(k(r.toJSON)&&(r=r.toJSON()),n&&!1===r.hasOwnProperty(u)){r={};break}r=r[u]=r[u]||{}}return k(r.toJSON)&&(r=r.toJSON()),[r,i]},B=function(t){(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).forEach((function(e){e in t&&(t[e]=t[e].bind(t))}))},N=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},A=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return n.filter((function(t){return t})).reduce((function(t,e){return Object.assign(t,e)}),t)},C=function(){},$=function(t,e){var n;for(n in t)q(t,n)&&e(t[n],n,t)},U=function(t,e){return function(t,e){var n=t instanceof Array,r=n?[]:{};return $(t,(function(t,o,i){var c=e(t,o,i);!1===O(c)&&(n?r.push(c):r[o]=c)})),r}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},q=function(t,e){return t&&t.hasOwnProperty(e)},H={export:"ejsPrecompiled",cache:!0,chokidar:null,path:"views",resolver:function(t,e){return Promise.resolve(["resolver is not defined",t,e].join(" "))},extension:"ejs",rmWhitespace:!0,withObject:!0,globalHelpers:[],vars:{SCOPE:"ejs",COMPONENT:"ui",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},G=function(t,e){A(t,{path:w(j,H.path,t.path,e.path),export:w(j,H.export,t.export,e.export),resolver:w(k,H.resolver,t.resolver,e.resolver),extension:w(j,H.extension,t.extension,e.extension),withObject:w(E,H.withObject,t.withObject,e.withObject),rmWhitespace:w(E,H.rmWhitespace,t.rmWhitespace,e.rmWhitespace),cache:w(E,H.cache,t.cache,e.cache),token:A({},H.token,t.token,e.token),vars:A({},H.vars,t.vars,e.vars),globalHelpers:w(b,H.globalHelpers,t.globalHelpers,e.globalHelpers)})},J="undefined"!=typeof globalThis?globalThis:window||self,Y=new WeakMap,D=new WeakMap,I=function(){return f((function t(e){i(this,t),u(this,Y,!0),u(this,D,{}),B(this,["configure"]),this.configure(e)}),[{key:"load",value:function(t){c(Y,this)&&A(c(D,this),t||{})}},{key:"get",value:function(t){if(c(Y,this))return c(D,this)[t]}},{key:"set",value:function(t,e){c(Y,this)&&(c(D,this)[t]=e)}},{key:"exist",value:function(t){return q(c(D,this),t)}},{key:"clear",value:function(){a(D,this,{})}},{key:"remove",value:function(t){delete c(D,this)[t]}},{key:"resolve",value:function(t){return Promise.resolve(this.get(t))}},{key:"configure",value:function(t){a(Y,this,t.cache),!1===x&&this.load(J[t.export])}}])}(),K=new WeakMap,X=new WeakMap,z=function(){return f((function t(e){i(this,t),u(this,K,{}),u(this,X,[{symbol:"-",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(t){return"')\n/**".concat(t,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(t){return"')\n".concat(t.trim(),"\n").concat(this.BUFFER,"('")}}]),B(this,["configure","compile"]),this.configure(e)}),[{key:"configure",value:function(t){var e=this;c(K,this).withObject=t.withObject,c(K,this).rmWhitespace=t.rmWhitespace,c(K,this).token=t.token,c(K,this).vars=t.vars,c(K,this).globalHelpers=t.globalHelpers,c(K,this).matches=[],c(K,this).formats=[],c(K,this).slurp={match:"[s\t\n]*",start:[c(K,this).token.start,"_"],end:["_",c(K,this).token.end]},c(X,this).forEach((function(t){c(K,e).matches.push(c(K,e).token.start.concat(t.symbol).concat(c(K,e).token.regex).concat(c(K,e).token.end)),c(K,e).formats.push(t.format.bind(c(K,e).vars))})),c(K,this).regex=new RegExp(c(K,this).matches.join("|").concat("|$"),"g"),c(K,this).slurpStart=new RegExp([c(K,this).slurp.match,c(K,this).slurp.start.join("")].join(""),"gm"),c(K,this).slurpEnd=new RegExp([c(K,this).slurp.end.join(""),c(K,this).slurp.match].join(""),"gm")}},{key:"compile",value:function(t,e){var n=this,r=c(K,this).vars,o=r.SCOPE,i=r.SAFE,u=r.BUFFER,a=r.COMPONENT,s=c(K,this).globalHelpers;c(K,this).rmWhitespace&&(t=String(t).replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=String(t).replace(c(K,this).slurpStart,c(K,this).token.start).replace(c(K,this).slurpEnd,c(K,this).token.end);var f,h,l,p="".concat(u,"('");f=c(K,this).regex,h=function(e,r,o){p+=(""+t.slice(r,o)).replace(M,(function(t){return"\\"+P[t]})),e.forEach((function(t,e){t&&(p+=c(K,n).formats[e](t))}))},l=0,t.replace(f,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return h(t,l,e),l=e+n.length,n})),p="try{".concat(p+="');","}catch(e){return ").concat(u,".error(e)}"),c(K,this).withObject&&(p="with(".concat(o,"){").concat(p,"}")),p="".concat(u,".start();").concat(p,"return ").concat(u,".end();"),p+="\n//# sourceURL=".concat(e);var v=null,y=[o,a,u,i].concat(s);try{(v=Function.apply(null,y.concat(p))).source="(function(".concat(y.join(","),"){\n").concat(p,"\n});")}catch(t){throw t.filename=e,t.source=p,t}return v}}])}(),Q=new WeakMap,V=new WeakMap,Z=new WeakMap,tt=new WeakMap,et=new WeakSet,nt=function(){return f((function t(e,n,r){i(this,t),s(this,et),u(this,Q,void 0),u(this,V,void 0),u(this,Z,void 0),u(this,tt,void 0),W(n,I),W(r,z),a(V,this,n),a(Z,this,r),B(this,["configure","get"]),this.configure(e)}),[{key:"configure",value:function(t){a(Q,this,t.path),k(t.resolver)&&a(tt,this,t.resolver)}},{key:"get",value:function(t){var n=this;return c(V,this).exist(t)?c(V,this).resolve(t):e(et,this,rt).call(this,t).then((function(r){return e(et,n,ot).call(n,t,e(et,n,it).call(n,r,t))}))}}])}();function rt(t){return c(tt,this).call(this,c(Q,this),t)}function ot(t,e){return c(V,this).set(t,e),e}function it(t,e){return k(t)?t:c(Z,this).compile(t,e)}var ct=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],ut=" ",at='"',st="/",ft="<",ht=">",lt=function(t,e,n){var r=[],o=-1===ct.indexOf(t),i=function(t,e){var n=[];return $(t,(function(t,r,o){var i=e(t,r,o);!1===O(i)&&n.push(i)})),n}(e,(function(t,e){if(null!=t)return[T(e),[at,T(t),at].join("")].join("=")})).join(ut);return r.push([ft,t,ut,i,ht].join("")),n&&o&&r.push(n instanceof Array?n.join(""):n),o&&r.push([ft,st,t,ht].join("")),r.join("")},pt=function(t){function e(t){var n;return i(this,e),h(n=r(this,e),"code",0),n.message=t,n}return p(e,t),f(e,[{key:"getCode",value:function(){return this.code}},{key:"getMessage",value:function(){return this.message}},{key:"toString",value:function(){return this.getMessage()}}])}(m(Error)),vt=function(t){function e(){var t;i(this,e);for(var n=arguments.length,o=new Array(n),c=0;c<n;c++)o[c]=arguments[c];return h(t=r(this,e,[].concat(o)),"code",404),t}return p(e,t),f(e)}(pt),yt=function(t){function e(){var t;i(this,e);for(var n=arguments.length,o=new Array(n),c=0;c<n;c++)o[c]=arguments[c];return h(t=r(this,e,[].concat(o)),"code",500),t}return p(e,t),f(e)}(pt);function gt(t){return Promise.all(t||[]).then((function(t){return t.join("")})).catch((function(t){return t}))}function dt(){var t=[],e=[],n=function(t){e.push(t)};return n.start=function(){e=[]},n.backup=function(){t.push(e.concat()),e=[]},n.restore=function(){var n=e.concat();return e=t.pop(),gt(n)},n.error=function(t){return e=t,Promise.reject(new yt(e.message));var e},n.end=function(){return gt(e)},n}var mt=new WeakMap,wt=function(){return f((function t(e,n){i(this,t),u(this,mt,void 0),B(this,["create","helpers","configure"]),this.configure(e,n)}),[{key:"create",value:function(t){return new(c(mt,this))(t)}},{key:"configure",value:function(t,e){a(mt,this,function(t,e){var n,r=t.vars,o=r.BLOCKS,i=r.MACRO,c=r.EXTEND,u=r.LAYOUT,a=r.BUFFER,s=r.COMPONENT,f=r.SAFE,l=r.SCOPE;function p(t){this[o]={},this[i]={},Object.assign(this,U(t,[l,a,f,s]))}return Object.assign(p.prototype,e),Object.defineProperties(p.prototype,(h(h(h(h(h(h(h(h(h(h(n={},a,{value:dt()}),o,{value:{},writable:!0}),i,{value:{},writable:!0}),u,{value:!1,writable:!0}),c,{value:!1,writable:!0}),"getMacro",{value:function(){return this[i]}}),"getBuffer",{value:function(){return this[a]}}),"getComponent",{value:function(){var t=this;return s in t?function(){return t[s].apply(t,arguments)}:function(){console.log("%s function not defined",s)}}}),"getBlocks",{value:function(){return this[o]}}),"setExtend",{value:function(t){this[c]=t}}),h(h(h(h(h(h(h(h(h(h(n,"getExtend",{value:function(){return this[c]}}),"setLayout",{value:function(t){this[u]=t}}),"getLayout",{value:function(){return this[u]}}),"clone",{value:function(t){var e=[u,c,a];return!0===t&&e.push(o),U(this,e)}}),"extend",{value:function(t){this.setExtend(!0),this.setLayout(t)}}),"echo",{value:function(t){var e=this.getBuffer();[].slice.call(arguments).forEach(e)}}),"fn",{value:function(t){var e=this.getBuffer(),n=this;return function(){return e.backup(),k(t)&&t.apply(n,arguments),e.restore()}}}),"get",{value:function(t,e){var n=_(this,t,!0),r=n.shift(),o=n.pop();return q(r,o)?r[o]:e}}),"set",{value:function(t,e){var n=_(this,t,!1),r=n.shift(),o=n.pop();return this.getExtend()&&q(r,o)?r[o]:r[o]=e}}),"macro",{value:function(t,e){var n=this.getMacro(),r=this.fn(e),o=this;n[t]=function(){return o.echo(r.apply(void 0,arguments))}}}),h(h(h(h(h(h(h(h(h(h(n,"call",{value:function(t){var e=this.getMacro()[t],n=[].slice.call(arguments,1);if(k(e))return e.apply(e,n)}}),"block",{value:function(t,e){var n=this,r=this.getBlocks();if(r[t]=r[t]||[],r[t].push(this.fn(e)),!this.getExtend()){var o=Object.assign([],r[t]),i=function(){return o.shift()},c=function(){var t=i();return t?function(){n.echo(t(c()))}:C};this.echo(i()(c()))}}}),"hasBlock",{value:function(t){return this.getBlocks().hasOwnProperty(t)}}),"include",{value:function(t,e,n){var r=!1===n?{}:this.clone(!0),o=A(r,e||{}),i=this.render(t,o);this.echo(i)}}),"promiseResolve",{value:function(t,e){return Promise.resolve(k(t)?this.fn(t)():t).then(e.bind(this))}}),"use",{value:function(t,e){this.echo(this.promiseResolve(this.require(t),(function(t){var n=this.getMacro();$(t,(function(t,r){n[[e,r].join(".")]=t}))})))}}),"async",{value:function(t,e){this.echo(this.promiseResolve(t,(function(t){return this.fn(e)(t)})))}}),"each",{value:function(t,e){j(t)&&(t=this.get(t,[])),$(t,e)}}),"element",{value:function(t,e,n){return lt(t,e,n)}}),"el",{value:function(t,e,n){this.echo(this.promiseResolve(n,(function(n){return this.element(t,e,n)})))}}))),p}(t,e))}},{key:"helpers",value:function(t){A(c(mt,this).prototype,t||{})}}])}(),bt=new WeakMap,kt=new WeakMap,jt=new WeakMap,Et=new WeakMap,Ot=new WeakMap,xt=new WeakMap,Pt=new WeakSet;function Lt(t,e){var n=c(bt,this).globalHelpers,r=[e,e.getComponent(),e.getBuffer(),R].concat(n.filter((function(t){return k(e[t])})).map((function(t){return e[t].bind(e)})));return c(xt,this).get(t).then((function(t){return t.apply(e,r)}))}function St(t){var n=N(t,c(bt,this).extension),r=this.context({});return e(Pt,this,Lt).call(this,n,r).then((function(){return r.getMacro()}))}var Ft={},Mt=function(t,e){return(t=new URL(t)).protocol=e?"https:":"http:",t.origin},Tt=new(function(){return f((function t(n){i(this,t),s(this,Pt),u(this,bt,{}),u(this,kt,{}),u(this,jt,void 0),u(this,Et,void 0),u(this,Ot,void 0),u(this,xt,void 0),G(c(bt,this),n||{}),a(jt,this,new wt(c(bt,this),c(kt,this))),a(Et,this,new z(c(bt,this))),a(Ot,this,new I(c(bt,this))),a(xt,this,new nt(c(bt,this),c(Ot,this),c(Et,this))),B(this,["configure","create","render","context","preload","compile","helpers"]),this.helpers({require:e(Pt,this,St),render:this.render})}),[{key:"configure",value:function(t){return G(c(bt,this),t||{}),c(jt,this).configure(c(bt,this),c(kt,this)),c(Et,this).configure(c(bt,this)),c(Ot,this).configure(c(bt,this)),c(xt,this).configure(c(bt,this)),c(bt,this)}},{key:"render",value:function(t,n){var r=this,o=N(t,c(bt,this).extension),i=this.context(n);return e(Pt,this,Lt).call(this,o,i).then((function(t){if(i.getExtend()){i.setExtend(!1);var e=i.getLayout(),n=i.clone();return r.render(e,n)}return t}))}},{key:"helpers",value:function(t){c(jt,this).helpers(A(c(kt,this),t))}},{key:"context",value:function(t){return c(jt,this).create(t)}},{key:"compile",value:function(t,e){return c(Et,this).compile(t,e)}},{key:"preload",value:function(t){return c(Ot,this).load(t||{})}},{key:"create",value:function(t){return new this.constructor(t)}}])}())({cache:!1,withObject:!1,resolver:function(t,e){return new Promise((function(t,n){Ft.hasOwnProperty(e)?t(Ft[e]):n(new vt("template ".concat(e," not found")))}))}}),Rt=Tt.render,Wt=Tt.context,_t=Tt.helpers,Bt=Tt.configure,Nt=Tt.create;t.TemplateError=pt,t.TemplateNotFound=vt,t.TemplateSyntaxError=yt,t.configure=Bt,t.context=Wt,t.create=Nt,t.helpers=_t,t.render=Rt,t.setRenderer=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.version,r=t.secure,o=void 0===r||r;return function(){var t,r=(t=y().mark((function t(n,r){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n.data=Wt({}),n.data.set("version",e),n.data.set("origin",Mt(n.req.url,o)),n.data.set("path",n.req.path),n.data.set("query",n.req.query()),n.ejs=function(t,e){return Rt(t,Object.assign({param:n.req.param()},n.data,e))},n.helpers=function(t){return _t(t)},n.render=function(t,e){return n.html(n.ejs(t,e))},t.next=10,r();case 10:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(o,i){var c=t.apply(e,r);function u(t){n(c,o,i,u,a,"next",t)}function a(t){n(c,o,i,u,a,"throw",t)}u(void 0)}))});return function(t,e){return r.apply(this,arguments)}}()},t.setTemplates=function(t){Object.assign(Ft,t||{})}}));
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "EJS Templates",
4
4
  "homepage": "https://github.com/kosatyi/ejs",
5
5
  "type": "module",
6
- "version": "0.0.97",
6
+ "version": "0.0.98",
7
7
  "main": "dist/cjs/index.js",
8
8
  "module": "dist/esm/index.js",
9
9
  "browser": "dist/umd/browser.js",
package/types/global.d.ts CHANGED
@@ -2,6 +2,10 @@ import type { EJS } from './ejs'
2
2
 
3
3
  declare global {
4
4
  const ejs: EJS
5
+ interface Window extends EJS {}
6
+ namespace NodeJS {
7
+ interface Global extends EJS {}
8
+ }
5
9
  }
6
10
 
7
11
  export = global