@jaredwray/fumanchu 4.3.0 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,11 +1,3182 @@
1
- "use strict";var Ln=Object.create;var H=Object.defineProperty;var Pn=Object.getOwnPropertyDescriptor;var Un=Object.getOwnPropertyNames;var In=Object.getPrototypeOf,vn=Object.prototype.hasOwnProperty;var Jn=(n,e)=>{for(var r in e)H(n,r,{get:e[r],enumerable:!0})},B=(n,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Un(e))!vn.call(n,o)&&o!==r&&H(n,o,{get:()=>e[o],enumerable:!(t=Pn(e,o))||t.enumerable});return n};var a=(n,e,r)=>(r=n!=null?Ln(In(n)):{},B(e||!n||!n.__esModule?H(r,"default",{value:n,enumerable:!0}):r,n)),qn=n=>B(H({},"__esModule",{value:!0}),n);var It={};Jn(It,{Handlebars:()=>Ct,HelperRegistry:()=>d,createHandlebars:()=>Pt,fumanchu:()=>Ut,handlebars:()=>zt,helpers:()=>Lt});module.exports=qn(It);var y=a(require("handlebars"),1);var Dn=(n,e)=>Array.isArray(n)?n.slice(e):[],Yn=(n,e)=>Array.isArray(n)?n.slice(0,-e):[],f=n=>n==null?[]:Array.isArray(n)?n:[n],Wn=(n,e)=>{if(Array.isArray(n))return typeof e!="number"?n[0]:n.slice(0,e)},Gn=(n,e)=>{if(!Array.isArray(n)&&typeof n!="string")return;if(typeof e!="number"){let t=n;return t[t.length-1]}let r=Math.abs(e);return n.slice(-r)},Qn=n=>n&&typeof n=="object"&&!Array.isArray(n)?Object.keys(n).length:typeof n=="string"||Array.isArray(n)?n.length:0,Zn=(n,e=", ")=>typeof n=="string"?n:Array.isArray(n)?n.join(e):"",Kn=function(n,e){if(!Array.isArray(n)||!e||typeof e.fn!="function")return e?.inverse?e.inverse(this)??"":"";if(n.length===0)return e.inverse?e.inverse(this)??"":"";let r=n.length,t=e.hash??{},o=e.data?{...e.data}:void 0,s="";for(let i=0;i<r;i++){let p=n[i],g={index:i,total:r,isFirst:i===0,isLast:i===r-1},zn={...o?{...o}:{},...t,...g},R;p!=null&&typeof p=="object"?R={...p,...t,...g}:R={value:p,...t,...g},s+=e.fn(R,{data:zn})}return s},M=[{name:"after",category:"array",compatibility:["browser","nodejs"],fn:Dn},{name:"before",category:"array",compatibility:["browser","nodejs"],fn:Yn},{name:"arrayify",category:"array",compatibility:["browser","nodejs"],fn:f},{name:"first",category:"array",compatibility:["browser","nodejs"],fn:Wn},{name:"last",category:"array",compatibility:["browser","nodejs"],fn:Gn},{name:"length",category:"array",compatibility:["browser","nodejs"],fn:Qn},{name:"join",category:"array",compatibility:["browser","nodejs"],fn:Zn},{name:"forEach",category:"array",compatibility:["browser","nodejs"],fn:Kn}];var _=a(require("fs"),1),C=a(require("path"),1),S=a(require("html-tag"),1),z=a(require("to-gfm-code-block"),1),Vn=(n,e)=>{let r=typeof e=="string"?e:C.default.extname(n).slice(1),t=_.default.readFileSync(n,"utf8");return(r==="markdown"||r==="md")&&(r="markdown",t=t.split("`").join("&#x60")),`${(0,z.default)(t,r).trim()}
2
- `},Xn=n=>(0,S.default)("script",{src:`https://gist.github.com/${n}.js`}),ne=n=>{if(!n||!n.id)throw new Error("jsfiddle helper expects an `id`");let{id:e,width:r="100%",height:t="300",skin:o="/presentation/",tabs:s="result,js,html,css",allowfullscreen:i="allowfullscreen",frameborder:p="0"}=n,g=`http://jsfiddle.net/${e}/embedded/${s}${o}`;return(0,S.default)("iframe",{width:r,height:t,src:g,allowfullscreen:i,frameborder:p})},L=[{name:"embed",category:"code",compatibility:["nodejs"],fn:Vn},{name:"gist",category:"code",compatibility:["browser","nodejs"],fn:Xn},{name:"jsfiddle",category:"code",compatibility:["browser","nodejs"],fn:ne}];var ee=n=>n==null?!0:Array.isArray(n)?n.length===0:typeof n=="object"?Object.keys(n).length===0:!1,re=(n,e,r)=>{if(Array.isArray(n)){let t="";for(let o=0;o<n.length;o++)t+=e(n[o],o);return t}if(n&&typeof n=="object"){let t="";for(let o of Object.keys(n))t+=e(n[o],o);return t}return r?r():""},P=[{name:"isEmpty",category:"collection",compatibility:["browser","nodejs"],fn:ee},{name:"iterate",category:"collection",compatibility:["browser","nodejs"],fn:re}];var te=(...n)=>n.every(Boolean),oe=(n,e,r)=>{switch(e){case"==":return n==r;case"===":return n===r;case"!=":return n!=r;case"!==":return n!==r;case"<":return n<r;case">":return n>r;case"<=":return n<=r;case">=":return n>=r;case"typeof":return typeof n===r;default:throw new Error(`helper {{compare}}: invalid operator: '${e}'`)}},se=(n,e,r=0)=>n==null?!1:typeof n=="string"||Array.isArray(n)?n.indexOf(e,r)>-1:typeof n=="object"?e in n:!1,ie=(...n)=>{for(let e of n)if(e!=null)return e;return""},ae=(n,e)=>n===e,ce=(n,e)=>n>e,pe=(n,e)=>n>=e,me=(n,e)=>n==null||e==null?!1:Array.isArray(n)||typeof n=="string"?n.indexOf(e)>-1:typeof n=="object"?e in n:!1,U=(n,e)=>{if(!n)return!0;let r=Array.isArray(e)?e:e!=null?[e]:["0","false","nada","nil","nay","nah","negative","no","none","nope","nul","null","nix","nyet","uh-uh","veto","zero"],t=typeof n=="string"?n.toLowerCase():null;for(let o of r)if(o===n||t!=null&&o===t)return!0;return!1},le=n=>U(n),ye=n=>!U(n),ge=n=>typeof n=="number"&&n%2===0,fe=(n,e)=>typeof n=="number"&&typeof e=="number"&&e%n===0,ue=n=>typeof n=="number"&&Math.abs(n%2)===1,be=(n,e)=>n==e,de=(n,e)=>n!=e,he=(n,e)=>n<e,we=(n,e)=>n<=e,je=(n,e)=>!n&&!e,ke=n=>!n,He=(...n)=>n.some(Boolean),xe=(n,e)=>n!==e,Oe=(n,e)=>n<=e,Ae=(n,e)=>n>=e,Ne=(n,e)=>n<e,$e=(n,e)=>n>e,I=[{name:"and",category:"comparison",compatibility:["browser","nodejs"],fn:te},{name:"compare",category:"comparison",compatibility:["browser","nodejs"],fn:oe},{name:"contains",category:"comparison",compatibility:["browser","nodejs"],fn:se},{name:"default",category:"comparison",compatibility:["browser","nodejs"],fn:ie},{name:"eq",category:"comparison",compatibility:["browser","nodejs"],fn:ae},{name:"gt",category:"comparison",compatibility:["browser","nodejs"],fn:ce},{name:"gte",category:"comparison",compatibility:["browser","nodejs"],fn:pe},{name:"has",category:"comparison",compatibility:["browser","nodejs"],fn:me},{name:"isFalsey",category:"comparison",compatibility:["browser","nodejs"],fn:le},{name:"isTruthy",category:"comparison",compatibility:["browser","nodejs"],fn:ye},{name:"ifEven",category:"comparison",compatibility:["browser","nodejs"],fn:ge},{name:"ifNth",category:"comparison",compatibility:["browser","nodejs"],fn:fe},{name:"ifOdd",category:"comparison",compatibility:["browser","nodejs"],fn:ue},{name:"is",category:"comparison",compatibility:["browser","nodejs"],fn:be},{name:"isnt",category:"comparison",compatibility:["browser","nodejs"],fn:de},{name:"lt",category:"comparison",compatibility:["browser","nodejs"],fn:he},{name:"lte",category:"comparison",compatibility:["browser","nodejs"],fn:we},{name:"neither",category:"comparison",compatibility:["browser","nodejs"],fn:je},{name:"not",category:"comparison",compatibility:["browser","nodejs"],fn:ke},{name:"or",category:"comparison",compatibility:["browser","nodejs"],fn:He},{name:"unlessEq",category:"comparison",compatibility:["browser","nodejs"],fn:xe},{name:"unlessGt",category:"comparison",compatibility:["browser","nodejs"],fn:Oe},{name:"unlessLt",category:"comparison",compatibility:["browser","nodejs"],fn:Ae},{name:"unlessGteq",category:"comparison",compatibility:["browser","nodejs"],fn:Ne},{name:"unlessLteq",category:"comparison",compatibility:["browser","nodejs"],fn:$e}];var J=require("chrono-node"),q=a(require("dayjs"),1),Re=()=>new Date().getFullYear().toString(),Se=n=>n.replace(/yyyy/g,"YYYY").replace(/yy/g,"YY").replace(/dd/g,"DD").replace(/mm/g,"MM").replace(/hh/g,"HH").replace(/ss/g,"SS"),v=(n,e)=>{let r=(0,J.parseDate)(n);if(!r)throw new Error(`Unable to parse date: ${n}`);let t=Se(e);return(0,q.default)(r).format(t)},D=[{name:"year",category:"date",compatibility:["browser","nodejs"],fn:Re},{name:"date",category:"date",compatibility:["browser","nodejs"],fn:v},{name:"moment",category:"date",compatibility:["browser","nodejs"],fn:v}];var x=a(require("fs"),1),Y=a(require("path"),1),W=a(require("is-glob"),1),G=a(require("micromatch"),1),Fe=(n,e)=>{if(n==null)return"0 B";let r=typeof n=="number"?n:n.length??0;if(!r)return"0 B";let t=typeof e=="number"?e:2,o=["B","kB","MB","GB","TB","PB","EB","ZB","YB"],s=10**t,i=o.length-1;do{let p=10**(i*3);if(p<=r+1)return`${Math.round(r*s/p)/s} ${o[i]}`}while(--i>=0);return`${r} B`},Ee=n=>x.default.readFileSync(n,"utf8"),Te=n=>!!(n&&typeof n=="object"&&"hash"in n),Be=(n,e)=>{let r=x.default.readdirSync(n).map(o=>Y.default.join(n,o)),t=Te(e)?void 0:e;if(typeof t=="function")return t(r);if(t instanceof RegExp)return r.filter(o=>t.test(o));if(typeof t=="string"){if((0,W.default)(t))return(0,G.default)(r,t);if(t==="isFile"||t==="isDirectory")return r.filter(o=>{let s=x.default.statSync(o);return t==="isFile"?s.isFile():s.isDirectory()})}return r},Q=[{name:"fileSize",category:"fs",compatibility:["nodejs"],fn:Fe},{name:"read",category:"fs",compatibility:["nodejs"],fn:Ee},{name:"readdir",category:"fs",compatibility:["nodejs"],fn:Be}];var O=a(require("path"),1),F=a(require("html-tag"),1),Z=a(require("striptags"),1);var u=(n={})=>Object.keys(n).map(e=>`${e}="${String(n[e]).replace(/^['"]|["']$/g,"")}"`).join(" "),Me=n=>{let e=u(n?.hash??{});return e.trim()?` ${e}`:""},_e=function(n,e){arguments.length<2&&(e=n,n=[]);let r=f(n??[]),t="";return this&&this.options&&(t=this.options.assets||""),e?.hash?.href&&(r=f(e.hash.href)),r.map(o=>{let s=O.default.extname(o),i=o;return/(^\/\/)|(:\/\/)/.test(o)||(i=O.default.posix.join(t,o)),s===".less"?`<link type="text/css" rel="stylesheet/less" href="${i}">`:`<link type="text/css" rel="stylesheet" href="${i}">`}).join(`
3
- `)},Ce=n=>{if(n&&typeof n=="object"&&!Array.isArray(n)){let r=u(n.hash??{});return`<script${r?` ${r}`:""}></script>`}return typeof n=="string"?`<script src="${n}"></script>`:f(n).map(r=>O.default.extname(r)===".coffee"?(0,F.default)("script",{type:"text/coffeescript",src:r}):(0,F.default)("script",{src:r})).join(`
4
- `)},ze=n=>typeof n!="string"?"":(0,Z.default)(n).trim(),Le=(n,e)=>{let r=u(e.hash??{}),t=n.map(s=>typeof s=="string"?s:e.fn(s));return`${r?`<ul ${r}>`:"<ul>"}${t.map(s=>`<li>${s}</li>`).join(`
5
- `)}</ul>`},Pe=(n,e)=>{let r=u(e.hash??{}),t=n.map(s=>typeof s=="string"?s:e.fn(s));return`${r?`<ol ${r}>`:"<ol>"}${t.map(s=>`<li>${s}</li>`).join(`
6
- `)}</ol>`},Ue=n=>{let e="",r="",t=n.full||!1,o={alt:n.alt,src:n.thumbnail,width:n.size.width,height:n.size.height},s={id:`image-${n.id}`},i={href:t,rel:"thumbnail"};return n.classes&&(n.classes.image&&(o.class=n.classes.image.join(" ")),n.classes.figure&&(s.class=n.classes.figure.join(" ")),n.classes.link&&(i.class=n.classes.link.join(" "))),e+=`<figure ${u(s)}>
7
- `,r+=`<img ${u(o)}>
8
- `,t?e+=`<a ${u(i)}>
9
- ${r}</a>
10
- `:e+=r,n.caption&&(e+=`<figcaption>${n.caption}</figcaption>
11
- `),e+="</figure>",e},K=[{name:"attr",category:"html",compatibility:["browser","nodejs"],fn:Me},{name:"css",category:"html",compatibility:["nodejs"],fn:_e},{name:"js",category:"html",compatibility:["nodejs"],fn:Ce},{name:"sanitize",category:"html",compatibility:["browser","nodejs"],fn:ze},{name:"ul",category:"html",compatibility:["browser","nodejs"],fn:Le},{name:"ol",category:"html",compatibility:["browser","nodejs"],fn:Pe},{name:"thumbnailImage",category:"html",compatibility:["browser","nodejs"],fn:Ue}];var h=(n,e)=>{if(!n||typeof n!="object")return;let r=Array.isArray(e)?e:e.split("."),t=n;for(let o of r){if(t==null||typeof t!="object")return;t=t[o]}return t},E=(n,e)=>{if(!n||typeof n!="object")return;let r=Array.isArray(e)?e:e.split(".");if(r.length===0)return;let t=n;for(let s=0;s<r.length-1;s++){if(t==null||typeof t!="object")return;t=t[r[s]]}let o=r[r.length-1];if(!(t==null||typeof t!="object"||!(o in t)))return{[o]:t[o]}};var Ie=function(n,e,r){if(e&&typeof e=="object"&&"hash"in e&&r===void 0&&(r=e,e={}),typeof n!="string")throw new Error('{{i18n}} helper expected "key" to be a string');let t={...this,...e,...r?.hash??{}},o=t.language||t.lang;if(typeof o!="string")throw new TypeError('{{i18n}} helper expected "language" to be a string');let s=t[o];if(typeof s>"u")throw new Error(`{{i18n}} helper cannot find language "${o}"`);let i=h(s,n);if(typeof i>"u")throw new Error('{{i18n}} helper cannot find property "'+String(n)+'" for language "'+o+'"');return String(i)},V=[{name:"i18n",category:"i18n",compatibility:["browser","nodejs"],fn:Ie}];var ve=(n,e,r,t)=>{let o=n>1||n===0?r:e;return t?`${n} ${o}`:o},Je=n=>{let e=Math.abs(Math.round(Number(n))),r=String(n),t=e%100;if([11,12,13].includes(t))return`${r}th`;switch(e%10){case 1:return`${r}st`;case 2:return`${r}nd`;case 3:return`${r}rd`;default:return`${r}th`}},X=[{name:"inflect",category:"inflection",compatibility:["browser","nodejs"],fn:ve},{name:"ordinalize",category:"inflection",compatibility:["browser","nodejs"],fn:Je}];var nn=a(require("logging-helpers"),1),{log:qe,ok:De,success:Ye,info:We,warning:Ge,warn:Qe,error:Ze,danger:Ke,bold:Ve,_debug:Xe,_inspect:nr}=nn.default,en=[{name:"log",category:"logging",compatibility:["nodejs"],fn:qe},{name:"ok",category:"logging",compatibility:["nodejs"],fn:De},{name:"success",category:"logging",compatibility:["nodejs"],fn:Ye},{name:"info",category:"logging",compatibility:["nodejs"],fn:We},{name:"warning",category:"logging",compatibility:["nodejs"],fn:Ge},{name:"warn",category:"logging",compatibility:["nodejs"],fn:Qe},{name:"error",category:"logging",compatibility:["nodejs"],fn:Ze},{name:"danger",category:"logging",compatibility:["nodejs"],fn:Ke},{name:"bold",category:"logging",compatibility:["nodejs"],fn:Ve},{name:"_debug",category:"logging",compatibility:["nodejs"],fn:Xe},{name:"_inspect",category:"logging",compatibility:["nodejs"],fn:nr}];var T=a(require("micromatch"),1),rn=(n,e,r)=>{let t=typeof e=="string"?e.split(/, */):e;return(0,T.default)(n,t,r)},er=(n,e,r)=>T.default.isMatch(n,e,r),rr=(...n)=>(console.log("the {{mm}} helper is depcrecated and will be removed"),console.log("in handlebars-helpers v1.0.0, please use the {{match}}"),console.log("helper instead."),rn(...n)),tn=[{name:"match",category:"match",compatibility:["browser","nodejs"],fn:rn},{name:"isMatch",category:"match",compatibility:["browser","nodejs"],fn:er},{name:"mm",category:"match",compatibility:["browser","nodejs"],fn:rr}];var A=n=>typeof n=="number"&&!Number.isNaN(n)||typeof n=="string"&&n.trim()!==""&&!Number.isNaN(Number(n)),c=(n,e="expected a number")=>{if(A(n))return Number(n);throw new TypeError(e)},tr=n=>{let e=c(n);return Math.abs(e)},or=(n,e)=>A(n)&&A(e)?Number(n)+Number(e):"",sr=(...n)=>{let e=n.flat().map(r=>Number(r));return sn(e)/e.length},ir=n=>{let e=c(n);return Math.ceil(e)},ar=(n,e)=>{let r=c(n,"expected the first argument to be a number"),t=c(e,"expected the second argument to be a number");return r/t},cr=n=>{let e=c(n);return Math.floor(e)},pr=(n,e)=>{let r=c(n,"expected the first argument to be a number"),t=c(e,"expected the second argument to be a number");return r-t},mr=(n,e)=>{let r=c(n,"expected the first argument to be a number"),t=c(e,"expected the second argument to be a number");return r%t},on=(n,e)=>{let r=c(n,"expected the first argument to be a number"),t=c(e,"expected the second argument to be a number");return r*t},lr=(n,e)=>{let r=c(n,"expected the first argument to be a number"),t=c(e,"expected the second argument to be a number");return r+t},yr=(n,e)=>{let r=c(n,"expected minimum to be a number"),t=c(e,"expected maximum to be a number");return r+Math.floor(Math.random()*(t-r+1))},gr=(n,e)=>n%e,fr=n=>{let e=c(n);return Math.round(e)},ur=(n,e)=>{let r=c(n,"expected the first argument to be a number"),t=c(e,"expected the second argument to be a number");return r-t},sn=(...n)=>{let e=n.flat(),r=0;for(let t of e)A(t)&&(r+=Number(t));return r},br=(n,e)=>on(n,e),an=[{name:"abs",category:"math",compatibility:["browser","nodejs"],fn:tr},{name:"add",category:"math",compatibility:["browser","nodejs"],fn:or},{name:"avg",category:"math",compatibility:["browser","nodejs"],fn:sr},{name:"ceil",category:"math",compatibility:["browser","nodejs"],fn:ir},{name:"divide",category:"math",compatibility:["browser","nodejs"],fn:ar},{name:"floor",category:"math",compatibility:["browser","nodejs"],fn:cr},{name:"minus",category:"math",compatibility:["browser","nodejs"],fn:pr},{name:"modulo",category:"math",compatibility:["browser","nodejs"],fn:mr},{name:"multiply",category:"math",compatibility:["browser","nodejs"],fn:on},{name:"plus",category:"math",compatibility:["browser","nodejs"],fn:lr},{name:"random",category:"math",compatibility:["browser","nodejs"],fn:yr},{name:"remainder",category:"math",compatibility:["browser","nodejs"],fn:gr},{name:"round",category:"math",compatibility:["browser","nodejs"],fn:fr},{name:"subtract",category:"math",compatibility:["browser","nodejs"],fn:ur},{name:"sum",category:"math",compatibility:["browser","nodejs"],fn:sn},{name:"times",category:"math",compatibility:["browser","nodejs"],fn:br}];var N=a(require("fs"),1),pn=a(require("path"),1),mn=a(require("process"),1),ln=a(require("ent"),1),yn=a(require("handlebars"),1),gn=require("remarkable"),cn=function(n,e){typeof n=="object"&&n&&"fn"in n&&typeof n.fn=="function"?(e=n,n=n.fn(this)):typeof n!="string"&&(n="");let r={cwd:mn.default.cwd(),...e},t=new gn.Remarkable({breaks:!0,html:!0,langPrefix:"lang-",typographer:!1,xhtmlOut:!1}),o=n;if(o&&o.length>0){let s=pn.default.resolve(r.cwd,o);N.default.existsSync(s)&&N.default.statSync(s).isFile()&&(o=N.default.readFileSync(s,"utf8"))}return new yn.default.SafeString(ln.default.decode(t.render(o)))},fn=[{name:"md",category:"markdown",compatibility:["nodejs"],fn:cn},{name:"markdown",category:"markdown",compatibility:["nodejs"],fn:cn}];var un=a(require("handlebars-helper-create-frame"),1),bn=a(require("handlebars-utils"),1),dn=a(require("kind-of"),1);var dr=un.default;function hr(n,e,r){return h(bn.default.options(this,e,r),n)}function wr(n){return n.fn(this)}var jr=dn.default;function kr(n){return n.hash&&Object.keys(n.hash).length?n.fn(n.hash):n.inverse(this)}var hn=[{name:"frame",category:"misc",compatibility:["browser","nodejs"],fn:dr},{name:"option",category:"misc",compatibility:["browser","nodejs"],fn:hr},{name:"noop",category:"misc",compatibility:["browser","nodejs"],fn:wr},{name:"typeOf",category:"misc",compatibility:["browser","nodejs"],fn:jr},{name:"withHash",category:"misc",compatibility:["browser","nodejs"],fn:kr}];var j=n=>typeof n=="number"&&!Number.isNaN(n),Hr=(n,e)=>{if(n==null)return"0 B";let r;if(typeof n=="string"){if(r=n.length,!r)return"0 B"}else if(j(n))r=Number(n);else if(typeof n.length=="number"){if(r=n.length,!r)return"0 B"}else return"0 B";let t=typeof e=="number"&&!Number.isNaN(e)?e:2,o=["B","kB","MB","GB","TB","PB","EB","ZB","YB"],s=10**t;for(let i=o.length-1;i>=0;i--){let p=10**(i*3);if(p<=r+1)return`${Math.round(r*s/p)/s} ${o[i]}`}return`${r}`},xr=n=>n.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,"),Or=n=>{let e=n.toString();return`(${e.substr(0,3)}) ${e.substr(3,3)}-${e.substr(6,4)}`},Ar=(n,e)=>{let r=j(n)?Number(n):0,o=10**(typeof e=="number"&&!Number.isNaN(e)?e:2),s=["k","m","b","t","q"];for(let i=s.length-1;i>=0;i--){let p=10**((i+1)*3);if(p<=r+1)return`${Math.round(r*o/p)/o}${s[i]}`}return`${r}`},Nr=(n,e)=>{let r=j(n)?Number(n):0,t=typeof e=="number"&&!Number.isNaN(e)?e:0;return Number(r).toExponential(t)},$r=(n,e)=>{let r=j(n)?Number(n):0,t=typeof e=="number"&&!Number.isNaN(e)?e:0;return Number(r).toFixed(t)},Rr=n=>parseFloat(String(n)),Sr=n=>parseInt(String(n),10),Fr=(n,e)=>{let r=j(n)?Number(n):0,t=typeof e=="number"&&!Number.isNaN(e)?e:1;return Number(r).toPrecision(t)},wn=[{name:"bytes",category:"number",compatibility:["browser","nodejs"],fn:Hr},{name:"addCommas",category:"number",compatibility:["browser","nodejs"],fn:xr},{name:"phoneNumber",category:"number",compatibility:["browser","nodejs"],fn:Or},{name:"toAbbr",category:"number",compatibility:["browser","nodejs"],fn:Ar},{name:"toExponential",category:"number",compatibility:["browser","nodejs"],fn:Nr},{name:"toFixed",category:"number",compatibility:["browser","nodejs"],fn:$r},{name:"toFloat",category:"number",compatibility:["browser","nodejs"],fn:Rr},{name:"toInt",category:"number",compatibility:["browser","nodejs"],fn:Sr},{name:"toPrecision",category:"number",compatibility:["browser","nodejs"],fn:Fr}];var $=n=>!!(n&&typeof n=="object"&&"hash"in n),jn=(n,e)=>({...n?.data||{},...e}),Er=(...n)=>{let e=[...n];if(e.length&&$(e[e.length-1])){let t=e.pop();e.push(t.hash)}let r={};for(let t of e)t&&typeof t=="object"&&!Array.isArray(t)&&Object.assign(r,t);return r},Tr=(n,e)=>{if(!$(e))return e?.inverse?.(n)??"";let r=jn(e,e.hash||{}),t="";for(let o in n)r.key=o,t+=e.fn(n[o],{data:r});return t},Br=(n,e)=>{if(!$(e))return e?.inverse?.(n)??"";let r=jn(e,e.hash||{}),t="";for(let o in n)Object.hasOwn(n,o)&&(r.key=o,t+=e.fn(n[o],{data:r}));return t},Mr=(...n)=>{let e=[];for(let r of n)(typeof r=="string"||typeof r=="number")&&e.push(r);return e.join(".")},_r=(n,e,r)=>{let t=h(e,n);return r&&typeof r.fn=="function"?t?r.fn(t):r.inverse?.(e):t},Cr=(n,e)=>E(e,n),zr=(n,e)=>Object.hasOwn(n,e),Lr=n=>!!n&&typeof n=="object"&&!Array.isArray(n),kn=n=>JSON.parse(n),Hn=(n,e)=>JSON.stringify(n,null,typeof e=="number"?e:0),Pr=(n,...e)=>{let r=[n,...e];if(r.length&&$(r[r.length-1])){let t=r.pop();r.push(t.hash)}return Object.assign(...r)},Ur=kn,Ir=Hn,vr=(n,e,r)=>{let t=f(n),o={};for(let s of t)o=Object.assign({},o,E(e,s));return r&&typeof r.fn=="function"?Object.keys(o).length?r.fn(o):r.inverse?.(e):o},xn=[{name:"extend",category:"object",compatibility:["browser","nodejs"],fn:Er},{name:"forIn",category:"object",compatibility:["browser","nodejs"],fn:Tr},{name:"forOwn",category:"object",compatibility:["browser","nodejs"],fn:Br},{name:"toPath",category:"object",compatibility:["browser","nodejs"],fn:Mr},{name:"get",category:"object",compatibility:["browser","nodejs"],fn:_r},{name:"getObject",category:"object",compatibility:["browser","nodejs"],fn:Cr},{name:"hasOwn",category:"object",compatibility:["browser","nodejs"],fn:zr},{name:"isObject",category:"object",compatibility:["browser","nodejs"],fn:Lr},{name:"JSONparse",category:"object",compatibility:["browser","nodejs"],fn:kn},{name:"JSONstringify",category:"object",compatibility:["browser","nodejs"],fn:Hn},{name:"merge",category:"object",compatibility:["browser","nodejs"],fn:Pr},{name:"parseJSON",category:"object",compatibility:["browser","nodejs"],fn:Ur},{name:"pick",category:"object",compatibility:["browser","nodejs"],fn:vr},{name:"stringify",category:"object",compatibility:["browser","nodejs"],fn:Ir}];var m=a(require("path"),1),Jr=(n,e,r)=>{let t=Object.prototype.toString.call(r).slice(8,-1).toLowerCase();return`Expected ${n} to be of type ${e}, but got ${t}`},l=(n,e)=>{if(typeof e!="string")throw new TypeError(Jr(n,"string",e));return e},qr=function(n,e){let r=l("filepath",n),t=e?.data?.root?.cwd??this?.cwd??process.cwd();return m.default.resolve(t,r)},Dr=n=>{let e=l("filepath",n);return m.default.dirname(e)},Yr=(n,e)=>{let r=l("first path",n),t=l("second path",e);return m.default.relative(m.default.dirname(r),t)},Wr=n=>{let e=l("filepath",n);return m.default.basename(e)},Gr=n=>{let e=l("filepath",n);return m.default.basename(e,m.default.extname(e))},Qr=n=>{let e=l("filepath",n);return m.default.extname(e)},Zr=function(n,...e){let r,t=e[e.length-1];typeof t=="object"&&t&&"data"in t&&(r=e.pop());let s=[r?.data?.root?.cwd??this?.cwd??process.cwd(),l("filepath",n),...e.map((i,p)=>l(`path${p}`,i))];return m.default.resolve(...s)},Kr=(n,e,r)=>{let t=l("filepath",n),o=Number(e),s=Number(r);return t.split(/[\\/]+/).slice(o,s).join("/")},On=[{name:"absolute",category:"path",compatibility:["nodejs"],fn:qr},{name:"dirname",category:"path",compatibility:["nodejs"],fn:Dr},{name:"relative",category:"path",compatibility:["nodejs"],fn:Yr},{name:"basename",category:"path",compatibility:["nodejs"],fn:Wr},{name:"stem",category:"path",compatibility:["nodejs"],fn:Gr},{name:"extname",category:"path",compatibility:["nodejs"],fn:Qr},{name:"resolve",category:"path",compatibility:["nodejs"],fn:Zr},{name:"segments",category:"path",compatibility:["nodejs"],fn:Kr}];var An=a(require("handlebars-utils"),1),Vr=(n,e,r)=>{let t=An.default.options({},e,r);return new RegExp(n,t.flags)},Xr=(n,e)=>{if(typeof n!="string")return!1;if(!(e instanceof RegExp))throw new TypeError("expected a regular expression");return e.test(n)},Nn=[{name:"toRegex",category:"regex",compatibility:["browser","nodejs"],fn:Vr},{name:"test",category:"regex",compatibility:["browser","nodejs"],fn:Xr}];var $n=n=>n.trim().replace(/^[-_.\W\s]+|[-_.\W\s]+$/g,""),w=(n,e)=>n.length===1?n.toLowerCase():$n(n).toLowerCase().replace(/[-_.\W\s]+(\w|$)/g,(t,o)=>e(o)),nt=(n,e)=>typeof n=="string"&&typeof e=="string"?n+e:n,et=n=>typeof n=="string"?w(n,e=>e.toUpperCase()):"",Rn=n=>typeof n!="string"||n.length===0?"":n.charAt(0).toUpperCase()+n.slice(1),rt=n=>typeof n!="string"?"":n.replace(/\w\S*/g,e=>Rn(e)),tt=(n,e)=>{if(typeof n!="string")return"";let r="";for(let t=0;t<e;t++)r+="&nbsp;";return r+n+r},ot=n=>typeof n=="string"?$n(n):"",st=n=>typeof n=="string"?w(n,e=>`-${e}`):"",it=n=>typeof n=="string"?w(n,e=>`.${e}`):"",Sn=(n,e,r)=>typeof n=="string"?(typeof r!="string"&&(r=""),n.length>e?n.slice(0,e-r.length)+r:n):"",at=(n,e)=>typeof n=="string"?n.length<=e?n:`${Sn(n,e)}\u2026`:"",ct=n=>typeof n=="string"?n.split(" ").join("-"):"",pt=n=>typeof n=="string",Fn=n=>typeof n=="object"&&n!==null&&"fn"in n&&typeof n.fn=="function"?String(n.fn()).toLowerCase():typeof n!="string"?"":n.toLowerCase(),mt=(...n)=>Fn(...n),lt=(n,e)=>{if(typeof n!="string")return"";let r=e.length,t=n.indexOf(e,0),o=0;for(;t>-1;)o++,t=n.indexOf(e,t+r);return o},yt=n=>{if(typeof n!="string")return"";let e=w(n,r=>r.toUpperCase());return e.charAt(0).toUpperCase()+e.slice(1)},gt=n=>typeof n=="string"?w(n,e=>`/${e}`):"",ft=(n,e)=>typeof n!="string"?"":(typeof e!="string"&&(e=" "),n.split(e).join("+")),ut=(n,e)=>typeof n=="string"&&typeof e=="string"?e+n:n,bt=(n,e)=>typeof n!="string"?"":typeof e!="string"?n:n.split(e).join(""),dt=(n,e)=>typeof n!="string"?"":typeof e!="string"?n:n.replace(e,""),ht=(n,e,r)=>typeof n!="string"?"":typeof e!="string"?n:(typeof r!="string"&&(r=""),n.split(e).join(r)),wt=(n,e,r)=>typeof n!="string"?"":typeof e!="string"?n:(typeof r!="string"&&(r=""),n.replace(e,r)),jt=n=>typeof n=="string"?n.split("").reverse().join(""):"",kt=n=>typeof n!="string"?"":n.replace(/((?:\S[^.?!]*)[.?!]*)/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()),Ht=n=>typeof n=="string"?w(n,e=>`_${e}`):"",xt=n=>typeof n=="string"?n.trim():"",Ot=n=>typeof n=="string"?n.replace(/^\s+/,""):"",At=n=>typeof n=="string"?n.replace(/\s+$/,""):"",Nt=(n,e,r)=>{if(typeof n=="string"&&typeof e=="number"&&Number.isFinite(e)){typeof r!="string"&&(r="...");let t=Math.trunc(e),o=n.split(" ");return t<o.length&&(o=o.slice(0,t)),o.join(" ").trim()+r}return""},$t=Nt,En=n=>typeof n=="object"&&n!==null&&"fn"in n&&typeof n.fn=="function"?String(n.fn()).toUpperCase():typeof n!="string"?"":n.toUpperCase(),Rt=(...n)=>En(...n),Tn=[{name:"append",category:"string",compatibility:["browser","nodejs"],fn:nt},{name:"camelcase",category:"string",compatibility:["browser","nodejs"],fn:et},{name:"capitalize",category:"string",compatibility:["browser","nodejs"],fn:Rn},{name:"capitalizeAll",category:"string",compatibility:["browser","nodejs"],fn:rt},{name:"center",category:"string",compatibility:["browser","nodejs"],fn:tt},{name:"chop",category:"string",compatibility:["browser","nodejs"],fn:ot},{name:"dashcase",category:"string",compatibility:["browser","nodejs"],fn:st},{name:"dotcase",category:"string",compatibility:["browser","nodejs"],fn:it},{name:"ellipsis",category:"string",compatibility:["browser","nodejs"],fn:at},{name:"hyphenate",category:"string",compatibility:["browser","nodejs"],fn:ct},{name:"isString",category:"string",compatibility:["browser","nodejs"],fn:pt},{name:"lowercase",category:"string",compatibility:["browser","nodejs"],fn:Fn},{name:"downcase",category:"string",compatibility:["browser","nodejs"],fn:mt},{name:"occurrences",category:"string",compatibility:["browser","nodejs"],fn:lt},{name:"pascalcase",category:"string",compatibility:["browser","nodejs"],fn:yt},{name:"pathcase",category:"string",compatibility:["browser","nodejs"],fn:gt},{name:"plusify",category:"string",compatibility:["browser","nodejs"],fn:ft},{name:"prepend",category:"string",compatibility:["browser","nodejs"],fn:ut},{name:"remove",category:"string",compatibility:["browser","nodejs"],fn:bt},{name:"removeFirst",category:"string",compatibility:["browser","nodejs"],fn:dt},{name:"replace",category:"string",compatibility:["browser","nodejs"],fn:ht},{name:"replaceFirst",category:"string",compatibility:["browser","nodejs"],fn:wt},{name:"reverse",category:"string",compatibility:["browser","nodejs"],fn:jt},{name:"sentence",category:"string",compatibility:["browser","nodejs"],fn:kt},{name:"snakecase",category:"string",compatibility:["browser","nodejs"],fn:Ht},{name:"trim",category:"string",compatibility:["browser","nodejs"],fn:xt},{name:"trimLeft",category:"string",compatibility:["browser","nodejs"],fn:Ot},{name:"trimRight",category:"string",compatibility:["browser","nodejs"],fn:At},{name:"truncate",category:"string",compatibility:["browser","nodejs"],fn:Sn},{name:"truncateWords",category:"string",compatibility:["browser","nodejs"],fn:$t},{name:"uppercase",category:"string",compatibility:["browser","nodejs"],fn:En},{name:"upcase",category:"string",compatibility:["browser","nodejs"],fn:Rt}];var Bn=require("querystring"),b=require("url"),k=["browser","nodejs"],Mn=n=>{if(typeof n=="string")return encodeURIComponent(n)},St=n=>{if(typeof n=="string")return(0,Bn.escape)(n)},_n=n=>{if(typeof n=="string")return decodeURIComponent(n)};function Ft(...n){return Mn.apply(this,n)}function Et(...n){return _n.apply(this,n)}var Tt=(n,e)=>(0,b.resolve)(String(n),String(e)),Bt=n=>(0,b.parse)(String(n)),Mt=n=>{if(typeof n=="string")return n.split("?")[0]},_t=n=>{if(typeof n=="string"){let e=(0,b.parse)(n);return e.protocol="",(0,b.format)(e)}},Cn=[{name:"encodeURI",category:"url",compatibility:k,fn:Mn},{name:"escape",category:"url",compatibility:["nodejs"],fn:St},{name:"decodeURI",category:"url",compatibility:k,fn:_n},{name:"url_encode",category:"url",compatibility:k,fn:Ft},{name:"url_decode",category:"url",compatibility:k,fn:Et},{name:"urlResolve",category:"url",compatibility:["nodejs"],fn:Tt},{name:"urlParse",category:"url",compatibility:["nodejs"],fn:Bt},{name:"stripQuerystring",category:"url",compatibility:k,fn:Mt},{name:"stripProtocol",category:"url",compatibility:["nodejs"],fn:_t}];var d=class{_helpers=[];constructor(){this.init()}get helpers(){return this._helpers}init(){this.registerHelpers(M),this.registerHelpers(P),this.registerHelpers(D),this.registerHelpers(Q),this.registerHelpers(L),this.registerHelpers(fn),this.registerHelpers(K),this.registerHelpers(I),this.registerHelpers(V),this.registerHelpers(X),this.registerHelpers(en),this.registerHelpers(tn),this.registerHelpers(an),this.registerHelpers(hn),this.registerHelpers(wn),this.registerHelpers(On),this.registerHelpers(Nn),this.registerHelpers(Tn),this.registerHelpers(Cn),this.registerHelpers(xn)}register(e){return this.has(e.name)||this._helpers.push(e),!1}registerHelpers(e){for(let r of e)this.register(r)}has(e){return this._helpers.some(r=>r.name===e)}filter(e){let r=this._helpers;return e.names&&(r=r.filter(t=>e.names?.includes(t.name))),e.categories&&(r=r.filter(t=>e.categories?.includes(t.category))),e.compatibility&&(r=r.filter(t=>t.compatibility?.some(o=>e.compatibility?.includes(o)))),r}load(e,r){let t=this._helpers;r&&(t=this.filter(r));for(let o of t)e.registerHelper(o.name,o.fn)}swap(e){for(let r of this._helpers)e.unregisterHelper(r.name),e.registerHelper(r.name,r.fn)}};var Ct=y.default,zt=y.default.create();function Lt(n){new d().load(n.handlebars??n.hbs)}async function Pt(){let n=new d,e=y.default.create();return Object.keys(y.default.partials).length>0&&e.registerPartial(y.default.partials),n.load(e),process.env.NODE_ENV==="development"&&console.warn("createHandlebars will be deprecated in future versions, use `fumanchu` instead."),e}function Ut(n){let e=new d,r=y.default.create();return n?.handlebars?r=n.handlebars:Object.keys(y.default.partials).length>0&&r.registerPartial(y.default.partials),e.load(r),r}0&&(module.exports={Handlebars,HelperRegistry,createHandlebars,fumanchu,handlebars,helpers});
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all2) => {
9
+ for (var name in all2)
10
+ __defProp(target, name, { get: all2[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ Handlebars: () => Handlebars3,
34
+ HelperRegistry: () => HelperRegistry,
35
+ createHandlebars: () => createHandlebars,
36
+ fumanchu: () => fumanchu,
37
+ handlebars: () => handlebars,
38
+ helpers: () => helpers21
39
+ });
40
+ module.exports = __toCommonJS(index_exports);
41
+ var import_handlebars3 = __toESM(require("handlebars"), 1);
42
+
43
+ // src/helpers/array.ts
44
+ var after = (array, n) => {
45
+ if (!Array.isArray(array)) return [];
46
+ return array.slice(n);
47
+ };
48
+ var before = (array, n) => {
49
+ if (!Array.isArray(array)) return [];
50
+ return array.slice(0, -n);
51
+ };
52
+ var arrayify = (value) => {
53
+ if (value == null) return [];
54
+ return Array.isArray(value) ? value : [value];
55
+ };
56
+ var first = (array, n) => {
57
+ if (!Array.isArray(array)) return void 0;
58
+ if (typeof n !== "number") {
59
+ return array[0];
60
+ }
61
+ return array.slice(0, n);
62
+ };
63
+ var last = (value, n) => {
64
+ if (!Array.isArray(value) && typeof value !== "string") {
65
+ return void 0;
66
+ }
67
+ if (typeof n !== "number") {
68
+ const array = value;
69
+ return array[array.length - 1];
70
+ }
71
+ const start = Math.abs(n);
72
+ if (typeof value === "string") {
73
+ return value.slice(-start);
74
+ }
75
+ return value.slice(-start);
76
+ };
77
+ var length = (value) => {
78
+ if (value && typeof value === "object" && !Array.isArray(value)) {
79
+ return Object.keys(value).length;
80
+ }
81
+ if (typeof value === "string" || Array.isArray(value)) {
82
+ return value.length;
83
+ }
84
+ return 0;
85
+ };
86
+ var join = (array, separator = ", ") => {
87
+ if (typeof array === "string") return array;
88
+ if (!Array.isArray(array)) return "";
89
+ return array.join(separator);
90
+ };
91
+ var forEach = function(collection, options2) {
92
+ if (!Array.isArray(collection) || !options2 || typeof options2.fn !== "function") {
93
+ return options2?.inverse ? options2.inverse(this) ?? "" : "";
94
+ }
95
+ if (collection.length === 0) {
96
+ return options2.inverse ? options2.inverse(this) ?? "" : "";
97
+ }
98
+ const total = collection.length;
99
+ const hash = options2.hash ?? {};
100
+ const baseData = options2.data ? { ...options2.data } : void 0;
101
+ let result = "";
102
+ for (let index = 0; index < total; index++) {
103
+ const value = collection[index];
104
+ const meta = {
105
+ index,
106
+ total,
107
+ isFirst: index === 0,
108
+ isLast: index === total - 1
109
+ };
110
+ const data = {
111
+ ...baseData ? { ...baseData } : {},
112
+ ...hash,
113
+ ...meta
114
+ };
115
+ let context;
116
+ if (value != null && typeof value === "object") {
117
+ context = { ...value, ...hash, ...meta };
118
+ } else {
119
+ context = { value, ...hash, ...meta };
120
+ }
121
+ result += options2.fn(context, { data });
122
+ }
123
+ return result;
124
+ };
125
+ var inArray = function(array, value, options2) {
126
+ if (!Array.isArray(array) || !options2) {
127
+ return "";
128
+ }
129
+ const found = array.includes(value);
130
+ if (found && options2.fn) {
131
+ return options2.fn(this);
132
+ }
133
+ if (!found && options2.inverse) {
134
+ return options2.inverse(this);
135
+ }
136
+ return "";
137
+ };
138
+ var isArray = (value) => {
139
+ return Array.isArray(value);
140
+ };
141
+ var itemAt = (array, idx) => {
142
+ if (!Array.isArray(array)) return void 0;
143
+ return array[idx];
144
+ };
145
+ var equalsLength = function(value, targetLength, options2) {
146
+ const actualLength = length(value);
147
+ const isEqual = actualLength === targetLength;
148
+ if (options2 && (options2.fn || options2.inverse)) {
149
+ if (isEqual && options2.fn) {
150
+ return options2.fn(this);
151
+ }
152
+ if (!isEqual && options2.inverse) {
153
+ return options2.inverse(this);
154
+ }
155
+ return "";
156
+ }
157
+ return isEqual;
158
+ };
159
+ var some = function(array, iter, options2) {
160
+ if (!Array.isArray(array) || typeof iter !== "function" || !options2) {
161
+ return options2?.inverse ? options2.inverse(this) ?? "" : "";
162
+ }
163
+ const hasSome = array.some(iter);
164
+ if (hasSome && options2.fn) {
165
+ return options2.fn(this);
166
+ }
167
+ if (!hasSome && options2.inverse) {
168
+ return options2.inverse(this);
169
+ }
170
+ return "";
171
+ };
172
+ var eachIndex = function(array, options2) {
173
+ if (!Array.isArray(array) || !options2 || typeof options2.fn !== "function") {
174
+ return options2?.inverse ? options2.inverse(this) ?? "" : "";
175
+ }
176
+ if (array.length === 0) {
177
+ return options2.inverse ? options2.inverse(this) ?? "" : "";
178
+ }
179
+ let result = "";
180
+ for (let index = 0; index < array.length; index++) {
181
+ const context = {
182
+ item: array[index],
183
+ index
184
+ };
185
+ result += options2.fn(context);
186
+ }
187
+ return result;
188
+ };
189
+ var withAfter = function(array, idx, options2) {
190
+ if (!Array.isArray(array) || !options2 || typeof options2.fn !== "function") {
191
+ return "";
192
+ }
193
+ const sliced = array.slice(idx + 1);
194
+ if (sliced.length === 0) {
195
+ return options2.inverse ? options2.inverse(this) ?? "" : "";
196
+ }
197
+ let result = "";
198
+ for (const item of sliced) {
199
+ result += options2.fn(item);
200
+ }
201
+ return result;
202
+ };
203
+ var withBefore = function(array, idx, options2) {
204
+ if (!Array.isArray(array) || !options2 || typeof options2.fn !== "function") {
205
+ return "";
206
+ }
207
+ const sliced = array.slice(0, idx);
208
+ if (sliced.length === 0) {
209
+ return options2.inverse ? options2.inverse(this) ?? "" : "";
210
+ }
211
+ let result = "";
212
+ for (const item of sliced) {
213
+ result += options2.fn(item);
214
+ }
215
+ return result;
216
+ };
217
+ var withFirst = function(array, n, options2) {
218
+ let count = 1;
219
+ let opts = options2;
220
+ if (typeof n === "object" && n !== null && !Array.isArray(n)) {
221
+ opts = n;
222
+ } else if (typeof n === "number") {
223
+ count = n;
224
+ }
225
+ if (!Array.isArray(array) || !opts || typeof opts.fn !== "function") {
226
+ return "";
227
+ }
228
+ if (array.length === 0) {
229
+ return opts.inverse ? opts.inverse(this) ?? "" : "";
230
+ }
231
+ const items = array.slice(0, count);
232
+ let result = "";
233
+ for (const item of items) {
234
+ result += opts.fn(item);
235
+ }
236
+ return result;
237
+ };
238
+ var withLast = function(array, n, options2) {
239
+ let count = 1;
240
+ let opts = options2;
241
+ if (typeof n === "object" && n !== null && !Array.isArray(n)) {
242
+ opts = n;
243
+ } else if (typeof n === "number") {
244
+ count = n;
245
+ }
246
+ if (!Array.isArray(array) || !opts || typeof opts.fn !== "function") {
247
+ return "";
248
+ }
249
+ if (array.length === 0) {
250
+ return opts.inverse ? opts.inverse(this) ?? "" : "";
251
+ }
252
+ const items = array.slice(-count);
253
+ let result = "";
254
+ for (const item of items) {
255
+ result += opts.fn(item);
256
+ }
257
+ return result;
258
+ };
259
+ var withGroup = function(array, size, options2) {
260
+ if (!Array.isArray(array) || typeof size !== "number" || size <= 0 || !options2 || typeof options2.fn !== "function") {
261
+ return "";
262
+ }
263
+ if (array.length === 0) {
264
+ return options2.inverse ? options2.inverse(this) ?? "" : "";
265
+ }
266
+ let result = "";
267
+ const groups = [];
268
+ for (let i = 0; i < array.length; i += size) {
269
+ groups.push(array.slice(i, i + size));
270
+ }
271
+ for (const group of groups) {
272
+ result += options2.fn(group);
273
+ }
274
+ return result;
275
+ };
276
+ var withSort = function(array, prop, options2) {
277
+ let sortProp;
278
+ let opts = options2;
279
+ if (typeof prop === "object" && prop !== null && !Array.isArray(prop)) {
280
+ opts = prop;
281
+ } else if (typeof prop === "string") {
282
+ sortProp = prop;
283
+ }
284
+ if (!Array.isArray(array) || !opts || typeof opts.fn !== "function") {
285
+ return "";
286
+ }
287
+ if (array.length === 0) {
288
+ return opts.inverse ? opts.inverse(this) ?? "" : "";
289
+ }
290
+ const sorted = [...array];
291
+ if (sortProp) {
292
+ sorted.sort((a, b) => {
293
+ const aVal = a?.[sortProp];
294
+ const bVal = b?.[sortProp];
295
+ if (aVal === bVal) return 0;
296
+ if (aVal == null) return 1;
297
+ if (bVal == null) return -1;
298
+ if (typeof aVal === "string" && typeof bVal === "string") {
299
+ return aVal.localeCompare(bVal);
300
+ }
301
+ return aVal < bVal ? -1 : 1;
302
+ });
303
+ } else {
304
+ sorted.sort((a, b) => {
305
+ if (a === b) return 0;
306
+ if (a == null) return 1;
307
+ if (b == null) return -1;
308
+ if (typeof a === "string" && typeof b === "string") {
309
+ return a.localeCompare(b);
310
+ }
311
+ return a < b ? -1 : 1;
312
+ });
313
+ }
314
+ const shouldReverse = opts.hash?.reverse === true || opts.hash?.reverse === "true";
315
+ if (shouldReverse) {
316
+ sorted.reverse();
317
+ }
318
+ let result = "";
319
+ for (const item of sorted) {
320
+ result += opts.fn(item);
321
+ }
322
+ return result;
323
+ };
324
+ var filter = function(array, value, options2) {
325
+ if (!Array.isArray(array) || !options2) {
326
+ return options2?.inverse ? options2.inverse(this) ?? "" : "";
327
+ }
328
+ const filtered = array.filter((item) => item === value);
329
+ if (filtered.length > 0 && options2.fn) {
330
+ return options2.fn(this);
331
+ }
332
+ if (filtered.length === 0 && options2.inverse) {
333
+ return options2.inverse(this);
334
+ }
335
+ return "";
336
+ };
337
+ var map = (array, fn) => {
338
+ if (!Array.isArray(array) || typeof fn !== "function") {
339
+ return [];
340
+ }
341
+ return array.map(fn);
342
+ };
343
+ var pluck = (collection, prop) => {
344
+ if (!Array.isArray(collection) || typeof prop !== "string") {
345
+ return [];
346
+ }
347
+ return collection.map((item) => {
348
+ if (item == null || typeof item !== "object") {
349
+ return void 0;
350
+ }
351
+ const parts = prop.split(".");
352
+ let value = item;
353
+ for (const part of parts) {
354
+ if (value == null || typeof value !== "object") {
355
+ return void 0;
356
+ }
357
+ value = value[part];
358
+ }
359
+ return value;
360
+ });
361
+ };
362
+ var reverse = (value) => {
363
+ if (typeof value === "string") {
364
+ return value.split("").reverse().join("");
365
+ }
366
+ if (Array.isArray(value)) {
367
+ return [...value].reverse();
368
+ }
369
+ return void 0;
370
+ };
371
+ var sort = (array, key) => {
372
+ if (!Array.isArray(array)) {
373
+ return [];
374
+ }
375
+ const sorted = [...array];
376
+ if (typeof key === "function") {
377
+ sorted.sort(key);
378
+ } else if (typeof key === "string") {
379
+ sorted.sort((a, b) => {
380
+ const aVal = a?.[key];
381
+ const bVal = b?.[key];
382
+ if (aVal === bVal) return 0;
383
+ if (aVal == null) return 1;
384
+ if (bVal == null) return -1;
385
+ if (typeof aVal === "string" && typeof bVal === "string") {
386
+ return aVal.localeCompare(bVal);
387
+ }
388
+ return aVal < bVal ? -1 : 1;
389
+ });
390
+ } else {
391
+ sorted.sort((a, b) => {
392
+ if (a === b) return 0;
393
+ if (a == null) return 1;
394
+ if (b == null) return -1;
395
+ if (typeof a === "string" && typeof b === "string") {
396
+ return a.localeCompare(b);
397
+ }
398
+ return a < b ? -1 : 1;
399
+ });
400
+ }
401
+ return sorted;
402
+ };
403
+ var sortBy = (array, ...props) => {
404
+ if (!Array.isArray(array) || props.length === 0) {
405
+ return [];
406
+ }
407
+ const sorted = [...array];
408
+ sorted.sort((a, b) => {
409
+ for (const prop of props) {
410
+ const aVal = a?.[prop];
411
+ const bVal = b?.[prop];
412
+ if (aVal === bVal) continue;
413
+ if (aVal == null) return 1;
414
+ if (bVal == null) return -1;
415
+ if (typeof aVal === "string" && typeof bVal === "string") {
416
+ const result = aVal.localeCompare(bVal);
417
+ if (result !== 0) return result;
418
+ } else {
419
+ return aVal < bVal ? -1 : 1;
420
+ }
421
+ }
422
+ return 0;
423
+ });
424
+ return sorted;
425
+ };
426
+ var unique = function(array, options2) {
427
+ if (!Array.isArray(array)) {
428
+ if (!options2) {
429
+ return [];
430
+ }
431
+ return options2.inverse ? options2.inverse(this) ?? "" : "";
432
+ }
433
+ const uniqueArray = [...new Set(array)];
434
+ if (!options2) {
435
+ return uniqueArray;
436
+ }
437
+ if (uniqueArray.length === 0 && options2.inverse) {
438
+ return options2.inverse(this);
439
+ }
440
+ if (uniqueArray.length > 0 && options2.fn) {
441
+ let result = "";
442
+ for (const item of uniqueArray) {
443
+ result += options2.fn(item);
444
+ }
445
+ return result;
446
+ }
447
+ return "";
448
+ };
449
+ var helpers = [
450
+ {
451
+ name: "after",
452
+ category: "array",
453
+ compatibility: ["browser", "nodejs"],
454
+ fn: after
455
+ },
456
+ {
457
+ name: "before",
458
+ category: "array",
459
+ compatibility: ["browser", "nodejs"],
460
+ fn: before
461
+ },
462
+ {
463
+ name: "arrayify",
464
+ category: "array",
465
+ compatibility: ["browser", "nodejs"],
466
+ fn: arrayify
467
+ },
468
+ {
469
+ name: "first",
470
+ category: "array",
471
+ compatibility: ["browser", "nodejs"],
472
+ fn: first
473
+ },
474
+ {
475
+ name: "last",
476
+ category: "array",
477
+ compatibility: ["browser", "nodejs"],
478
+ fn: last
479
+ },
480
+ {
481
+ name: "length",
482
+ category: "array",
483
+ compatibility: ["browser", "nodejs"],
484
+ fn: length
485
+ },
486
+ {
487
+ name: "join",
488
+ category: "array",
489
+ compatibility: ["browser", "nodejs"],
490
+ fn: join
491
+ },
492
+ {
493
+ name: "forEach",
494
+ category: "array",
495
+ compatibility: ["browser", "nodejs"],
496
+ fn: forEach
497
+ },
498
+ {
499
+ name: "inArray",
500
+ category: "array",
501
+ compatibility: ["browser", "nodejs"],
502
+ fn: inArray
503
+ },
504
+ {
505
+ name: "isArray",
506
+ category: "array",
507
+ compatibility: ["browser", "nodejs"],
508
+ fn: isArray
509
+ },
510
+ {
511
+ name: "itemAt",
512
+ category: "array",
513
+ compatibility: ["browser", "nodejs"],
514
+ fn: itemAt
515
+ },
516
+ {
517
+ name: "equalsLength",
518
+ category: "array",
519
+ compatibility: ["browser", "nodejs"],
520
+ fn: equalsLength
521
+ },
522
+ {
523
+ name: "some",
524
+ category: "array",
525
+ compatibility: ["browser", "nodejs"],
526
+ fn: some
527
+ },
528
+ {
529
+ name: "eachIndex",
530
+ category: "array",
531
+ compatibility: ["browser", "nodejs"],
532
+ fn: eachIndex
533
+ },
534
+ {
535
+ name: "withAfter",
536
+ category: "array",
537
+ compatibility: ["browser", "nodejs"],
538
+ fn: withAfter
539
+ },
540
+ {
541
+ name: "withBefore",
542
+ category: "array",
543
+ compatibility: ["browser", "nodejs"],
544
+ fn: withBefore
545
+ },
546
+ {
547
+ name: "withFirst",
548
+ category: "array",
549
+ compatibility: ["browser", "nodejs"],
550
+ fn: withFirst
551
+ },
552
+ {
553
+ name: "withLast",
554
+ category: "array",
555
+ compatibility: ["browser", "nodejs"],
556
+ fn: withLast
557
+ },
558
+ {
559
+ name: "withGroup",
560
+ category: "array",
561
+ compatibility: ["browser", "nodejs"],
562
+ fn: withGroup
563
+ },
564
+ {
565
+ name: "withSort",
566
+ category: "array",
567
+ compatibility: ["browser", "nodejs"],
568
+ fn: withSort
569
+ },
570
+ {
571
+ name: "filter",
572
+ category: "array",
573
+ compatibility: ["browser", "nodejs"],
574
+ fn: filter
575
+ },
576
+ {
577
+ name: "map",
578
+ category: "array",
579
+ compatibility: ["browser", "nodejs"],
580
+ fn: map
581
+ },
582
+ {
583
+ name: "pluck",
584
+ category: "array",
585
+ compatibility: ["browser", "nodejs"],
586
+ fn: pluck
587
+ },
588
+ {
589
+ name: "reverse",
590
+ category: "array",
591
+ compatibility: ["browser", "nodejs"],
592
+ fn: reverse
593
+ },
594
+ {
595
+ name: "sort",
596
+ category: "array",
597
+ compatibility: ["browser", "nodejs"],
598
+ fn: sort
599
+ },
600
+ {
601
+ name: "sortBy",
602
+ category: "array",
603
+ compatibility: ["browser", "nodejs"],
604
+ fn: sortBy
605
+ },
606
+ {
607
+ name: "unique",
608
+ category: "array",
609
+ compatibility: ["browser", "nodejs"],
610
+ fn: unique
611
+ }
612
+ ];
613
+
614
+ // src/helpers/code.ts
615
+ var import_node_fs = __toESM(require("fs"), 1);
616
+ var import_node_path = __toESM(require("path"), 1);
617
+ var import_html_tag = __toESM(require("html-tag"), 1);
618
+ var import_to_gfm_code_block = __toESM(require("to-gfm-code-block"), 1);
619
+ var embed = (filepath, language) => {
620
+ let ext = typeof language === "string" ? language : import_node_path.default.extname(filepath).slice(1);
621
+ let code = import_node_fs.default.readFileSync(filepath, "utf8");
622
+ if (ext === "markdown" || ext === "md") {
623
+ ext = "markdown";
624
+ code = code.split("`").join("&#x60");
625
+ }
626
+ return `${(0, import_to_gfm_code_block.default)(code, ext).trim()}
627
+ `;
628
+ };
629
+ var gist = (id) => {
630
+ return (0, import_html_tag.default)("script", { src: `https://gist.github.com/${id}.js` });
631
+ };
632
+ var jsfiddle = (options2) => {
633
+ if (!options2 || !options2.id) {
634
+ throw new Error("jsfiddle helper expects an `id`");
635
+ }
636
+ const {
637
+ id,
638
+ width = "100%",
639
+ height = "300",
640
+ skin = "/presentation/",
641
+ tabs = "result,js,html,css",
642
+ allowfullscreen = "allowfullscreen",
643
+ frameborder = "0"
644
+ } = options2;
645
+ const src = `http://jsfiddle.net/${id}/embedded/${tabs}${skin}`;
646
+ return (0, import_html_tag.default)("iframe", { width, height, src, allowfullscreen, frameborder });
647
+ };
648
+ var helpers2 = [
649
+ {
650
+ name: "embed",
651
+ category: "code",
652
+ compatibility: ["nodejs"],
653
+ fn: embed
654
+ },
655
+ {
656
+ name: "gist",
657
+ category: "code",
658
+ compatibility: ["browser", "nodejs"],
659
+ fn: gist
660
+ },
661
+ {
662
+ name: "jsfiddle",
663
+ category: "code",
664
+ compatibility: ["browser", "nodejs"],
665
+ fn: jsfiddle
666
+ }
667
+ ];
668
+
669
+ // src/helpers/collection.ts
670
+ var isEmpty = (collection) => {
671
+ if (collection == null) return true;
672
+ if (Array.isArray(collection)) return collection.length === 0;
673
+ if (typeof collection === "object")
674
+ return Object.keys(collection).length === 0;
675
+ return false;
676
+ };
677
+ var iterate = (collection, fn, inverse) => {
678
+ if (Array.isArray(collection)) {
679
+ let result = "";
680
+ for (let i = 0; i < collection.length; i++) {
681
+ result += fn(collection[i], i);
682
+ }
683
+ return result;
684
+ }
685
+ if (collection && typeof collection === "object") {
686
+ let result = "";
687
+ for (const key of Object.keys(collection)) {
688
+ result += fn(collection[key], key);
689
+ }
690
+ return result;
691
+ }
692
+ return inverse ? inverse() : "";
693
+ };
694
+ var helpers3 = [
695
+ {
696
+ name: "isEmpty",
697
+ category: "collection",
698
+ compatibility: ["browser", "nodejs"],
699
+ fn: isEmpty
700
+ },
701
+ {
702
+ name: "iterate",
703
+ category: "collection",
704
+ compatibility: ["browser", "nodejs"],
705
+ fn: iterate
706
+ }
707
+ ];
708
+
709
+ // src/helpers/comparison.ts
710
+ var and = (...values) => values.every(Boolean);
711
+ var compare = (a, operator, b) => {
712
+ switch (operator) {
713
+ case "==":
714
+ return a == b;
715
+ case "===":
716
+ return a === b;
717
+ case "!=":
718
+ return a != b;
719
+ case "!==":
720
+ return a !== b;
721
+ case "<":
722
+ return a < b;
723
+ case ">":
724
+ return a > b;
725
+ case "<=":
726
+ return a <= b;
727
+ case ">=":
728
+ return a >= b;
729
+ case "typeof":
730
+ return typeof a === b;
731
+ default:
732
+ throw new Error(`helper {{compare}}: invalid operator: '${operator}'`);
733
+ }
734
+ };
735
+ var contains = (collection, value, startIndex = 0) => {
736
+ if (collection == null) return false;
737
+ if (typeof collection === "string" || Array.isArray(collection)) {
738
+ return collection.indexOf(value, startIndex) > -1;
739
+ }
740
+ if (typeof collection === "object") {
741
+ return value in collection;
742
+ }
743
+ return false;
744
+ };
745
+ var defaultHelper = (...values) => {
746
+ for (const val of values) {
747
+ if (val != null) return val;
748
+ }
749
+ return "";
750
+ };
751
+ var eq = (a, b) => a === b;
752
+ var gt = (a, b) => a > b;
753
+ var gte = (a, b) => a >= b;
754
+ var has = (value, pattern) => {
755
+ if (value == null || pattern == null) return false;
756
+ if (Array.isArray(value) || typeof value === "string") {
757
+ return value.indexOf(pattern) > -1;
758
+ }
759
+ if (typeof value === "object") {
760
+ return pattern in value;
761
+ }
762
+ return false;
763
+ };
764
+ var falsey = (val, keywords) => {
765
+ if (!val) return true;
766
+ const words = Array.isArray(keywords) ? keywords : keywords != null ? [keywords] : [
767
+ "0",
768
+ "false",
769
+ "nada",
770
+ "nil",
771
+ "nay",
772
+ "nah",
773
+ "negative",
774
+ "no",
775
+ "none",
776
+ "nope",
777
+ "nul",
778
+ "null",
779
+ "nix",
780
+ "nyet",
781
+ "uh-uh",
782
+ "veto",
783
+ "zero"
784
+ ];
785
+ const lower = typeof val === "string" ? val.toLowerCase() : null;
786
+ for (const word of words) {
787
+ if (word === val) return true;
788
+ if (lower != null && word === lower) return true;
789
+ }
790
+ return false;
791
+ };
792
+ var isFalsey = (val) => falsey(val);
793
+ var isTruthy = (val) => !falsey(val);
794
+ var ifEven = (num) => typeof num === "number" && num % 2 === 0;
795
+ var ifNth = (a, b) => typeof a === "number" && typeof b === "number" && b % a === 0;
796
+ var ifOdd = (val) => typeof val === "number" && Math.abs(val % 2) === 1;
797
+ var is = (a, b) => a == b;
798
+ var isnt = (a, b) => a != b;
799
+ var lt = (a, b) => a < b;
800
+ var lte = (a, b) => a <= b;
801
+ var neither = (a, b) => !a && !b;
802
+ var not = (val) => !val;
803
+ var or = (...values) => values.some(Boolean);
804
+ var unlessEq = (a, b) => a !== b;
805
+ var unlessGt = (a, b) => a <= b;
806
+ var unlessLt = (a, b) => a >= b;
807
+ var unlessGteq = (a, b) => a < b;
808
+ var unlessLteq = (a, b) => a > b;
809
+ var helpers4 = [
810
+ {
811
+ name: "and",
812
+ category: "comparison",
813
+ compatibility: ["browser", "nodejs"],
814
+ fn: and
815
+ },
816
+ {
817
+ name: "compare",
818
+ category: "comparison",
819
+ compatibility: ["browser", "nodejs"],
820
+ fn: compare
821
+ },
822
+ {
823
+ name: "contains",
824
+ category: "comparison",
825
+ compatibility: ["browser", "nodejs"],
826
+ fn: contains
827
+ },
828
+ {
829
+ name: "default",
830
+ category: "comparison",
831
+ compatibility: ["browser", "nodejs"],
832
+ fn: defaultHelper
833
+ },
834
+ {
835
+ name: "eq",
836
+ category: "comparison",
837
+ compatibility: ["browser", "nodejs"],
838
+ fn: eq
839
+ },
840
+ {
841
+ name: "gt",
842
+ category: "comparison",
843
+ compatibility: ["browser", "nodejs"],
844
+ fn: gt
845
+ },
846
+ {
847
+ name: "gte",
848
+ category: "comparison",
849
+ compatibility: ["browser", "nodejs"],
850
+ fn: gte
851
+ },
852
+ {
853
+ name: "has",
854
+ category: "comparison",
855
+ compatibility: ["browser", "nodejs"],
856
+ fn: has
857
+ },
858
+ {
859
+ name: "isFalsey",
860
+ category: "comparison",
861
+ compatibility: ["browser", "nodejs"],
862
+ fn: isFalsey
863
+ },
864
+ {
865
+ name: "isTruthy",
866
+ category: "comparison",
867
+ compatibility: ["browser", "nodejs"],
868
+ fn: isTruthy
869
+ },
870
+ {
871
+ name: "ifEven",
872
+ category: "comparison",
873
+ compatibility: ["browser", "nodejs"],
874
+ fn: ifEven
875
+ },
876
+ {
877
+ name: "ifNth",
878
+ category: "comparison",
879
+ compatibility: ["browser", "nodejs"],
880
+ fn: ifNth
881
+ },
882
+ {
883
+ name: "ifOdd",
884
+ category: "comparison",
885
+ compatibility: ["browser", "nodejs"],
886
+ fn: ifOdd
887
+ },
888
+ {
889
+ name: "is",
890
+ category: "comparison",
891
+ compatibility: ["browser", "nodejs"],
892
+ fn: is
893
+ },
894
+ {
895
+ name: "isnt",
896
+ category: "comparison",
897
+ compatibility: ["browser", "nodejs"],
898
+ fn: isnt
899
+ },
900
+ {
901
+ name: "lt",
902
+ category: "comparison",
903
+ compatibility: ["browser", "nodejs"],
904
+ fn: lt
905
+ },
906
+ {
907
+ name: "lte",
908
+ category: "comparison",
909
+ compatibility: ["browser", "nodejs"],
910
+ fn: lte
911
+ },
912
+ {
913
+ name: "neither",
914
+ category: "comparison",
915
+ compatibility: ["browser", "nodejs"],
916
+ fn: neither
917
+ },
918
+ {
919
+ name: "not",
920
+ category: "comparison",
921
+ compatibility: ["browser", "nodejs"],
922
+ fn: not
923
+ },
924
+ {
925
+ name: "or",
926
+ category: "comparison",
927
+ compatibility: ["browser", "nodejs"],
928
+ fn: or
929
+ },
930
+ {
931
+ name: "unlessEq",
932
+ category: "comparison",
933
+ compatibility: ["browser", "nodejs"],
934
+ fn: unlessEq
935
+ },
936
+ {
937
+ name: "unlessGt",
938
+ category: "comparison",
939
+ compatibility: ["browser", "nodejs"],
940
+ fn: unlessGt
941
+ },
942
+ {
943
+ name: "unlessLt",
944
+ category: "comparison",
945
+ compatibility: ["browser", "nodejs"],
946
+ fn: unlessLt
947
+ },
948
+ {
949
+ name: "unlessGteq",
950
+ category: "comparison",
951
+ compatibility: ["browser", "nodejs"],
952
+ fn: unlessGteq
953
+ },
954
+ {
955
+ name: "unlessLteq",
956
+ category: "comparison",
957
+ compatibility: ["browser", "nodejs"],
958
+ fn: unlessLteq
959
+ }
960
+ ];
961
+
962
+ // src/helpers/date.ts
963
+ var import_chrono_node = require("chrono-node");
964
+ var import_dayjs = __toESM(require("dayjs"), 1);
965
+ var import_isBetween = __toESM(require("dayjs/plugin/isBetween.js"), 1);
966
+ var import_relativeTime = __toESM(require("dayjs/plugin/relativeTime.js"), 1);
967
+ var import_timezone = __toESM(require("dayjs/plugin/timezone.js"), 1);
968
+ var import_utc = __toESM(require("dayjs/plugin/utc.js"), 1);
969
+ import_dayjs.default.extend(import_relativeTime.default);
970
+ import_dayjs.default.extend(import_isBetween.default);
971
+ import_dayjs.default.extend(import_utc.default);
972
+ import_dayjs.default.extend(import_timezone.default);
973
+ var parseDateInput = (input) => {
974
+ if (!input) {
975
+ return (0, import_dayjs.default)();
976
+ }
977
+ if (typeof input === "string") {
978
+ const parsed = (0, import_chrono_node.parseDate)(input);
979
+ if (parsed) {
980
+ return (0, import_dayjs.default)(parsed);
981
+ }
982
+ return (0, import_dayjs.default)(input);
983
+ }
984
+ return (0, import_dayjs.default)(input);
985
+ };
986
+ var year = () => (/* @__PURE__ */ new Date()).getFullYear().toString();
987
+ var convertFormatString = (format2) => {
988
+ return format2.replace(/yyyy/g, "YYYY").replace(/yy/g, "YY").replace(/dd/g, "DD").replace(/mm/g, "MM").replace(/hh/g, "HH");
989
+ };
990
+ var date = (humanReadableDate, formatString) => {
991
+ const defaultFormat = "YYYY-MM-DD";
992
+ const format2 = formatString || defaultFormat;
993
+ const parsedDate = parseDateInput(humanReadableDate);
994
+ if (!parsedDate.isValid()) {
995
+ throw new Error(`Unable to parse date: ${humanReadableDate}`);
996
+ }
997
+ const convertedFormat = convertFormatString(format2);
998
+ return parsedDate.format(convertedFormat);
999
+ };
1000
+ var timestamp = () => {
1001
+ return Date.now().toString();
1002
+ };
1003
+ var now = (formatString) => {
1004
+ const defaultFormat = "YYYY-MM-DD HH:mm:ss";
1005
+ const format2 = formatString || defaultFormat;
1006
+ const convertedFormat = convertFormatString(format2);
1007
+ return (0, import_dayjs.default)().format(convertedFormat);
1008
+ };
1009
+ var fromNow = (dateInput) => {
1010
+ const parsed = parseDateInput(dateInput);
1011
+ if (!parsed.isValid()) {
1012
+ throw new Error(`Unable to parse date: ${dateInput}`);
1013
+ }
1014
+ return parsed.fromNow();
1015
+ };
1016
+ var toNow = (dateInput) => {
1017
+ const parsed = parseDateInput(dateInput);
1018
+ if (!parsed.isValid()) {
1019
+ throw new Error(`Unable to parse date: ${dateInput}`);
1020
+ }
1021
+ return parsed.toNow();
1022
+ };
1023
+ var ago = (dateInput) => {
1024
+ return fromNow(dateInput);
1025
+ };
1026
+ var dateAdd = (dateInput, amount, unit) => {
1027
+ const parsed = parseDateInput(dateInput);
1028
+ if (!parsed.isValid()) {
1029
+ throw new Error(`Unable to parse date: ${dateInput}`);
1030
+ }
1031
+ return parsed.add(amount, unit).format("YYYY-MM-DD HH:mm:ss");
1032
+ };
1033
+ var dateSubtract = (dateInput, amount, unit) => {
1034
+ const parsed = parseDateInput(dateInput);
1035
+ if (!parsed.isValid()) {
1036
+ throw new Error(`Unable to parse date: ${dateInput}`);
1037
+ }
1038
+ return parsed.subtract(amount, unit).format("YYYY-MM-DD HH:mm:ss");
1039
+ };
1040
+ var startOf = (dateInput, unit) => {
1041
+ const parsed = parseDateInput(dateInput);
1042
+ if (!parsed.isValid()) {
1043
+ throw new Error(`Unable to parse date: ${dateInput}`);
1044
+ }
1045
+ return parsed.startOf(unit).format("YYYY-MM-DD HH:mm:ss");
1046
+ };
1047
+ var endOf = (dateInput, unit) => {
1048
+ const parsed = parseDateInput(dateInput);
1049
+ if (!parsed.isValid()) {
1050
+ throw new Error(`Unable to parse date: ${dateInput}`);
1051
+ }
1052
+ return parsed.endOf(unit).format("YYYY-MM-DD HH:mm:ss");
1053
+ };
1054
+ var isBefore = (date1, date2) => {
1055
+ const parsed1 = parseDateInput(date1);
1056
+ const parsed2 = parseDateInput(date2);
1057
+ if (!parsed1.isValid() || !parsed2.isValid()) {
1058
+ throw new Error(`Unable to parse dates: ${date1}, ${date2}`);
1059
+ }
1060
+ return parsed1.isBefore(parsed2);
1061
+ };
1062
+ var isAfter = (date1, date2) => {
1063
+ const parsed1 = parseDateInput(date1);
1064
+ const parsed2 = parseDateInput(date2);
1065
+ if (!parsed1.isValid() || !parsed2.isValid()) {
1066
+ throw new Error(`Unable to parse dates: ${date1}, ${date2}`);
1067
+ }
1068
+ return parsed1.isAfter(parsed2);
1069
+ };
1070
+ var isSame = (date1, date2, unit) => {
1071
+ const parsed1 = parseDateInput(date1);
1072
+ const parsed2 = parseDateInput(date2);
1073
+ if (!parsed1.isValid() || !parsed2.isValid()) {
1074
+ throw new Error(`Unable to parse dates: ${date1}, ${date2}`);
1075
+ }
1076
+ return parsed1.isSame(parsed2, unit);
1077
+ };
1078
+ var isBetweenDates = (dateInput, startDate, endDate) => {
1079
+ const parsed = parseDateInput(dateInput);
1080
+ const parsedStart = parseDateInput(startDate);
1081
+ const parsedEnd = parseDateInput(endDate);
1082
+ if (!parsed.isValid() || !parsedStart.isValid() || !parsedEnd.isValid()) {
1083
+ throw new Error(
1084
+ `Unable to parse dates: ${dateInput}, ${startDate}, ${endDate}`
1085
+ );
1086
+ }
1087
+ return parsed.isBetween(parsedStart, parsedEnd, null, "[]");
1088
+ };
1089
+ var diff = (date1, date2, unit) => {
1090
+ const parsed1 = parseDateInput(date1);
1091
+ const parsed2 = parseDateInput(date2);
1092
+ if (!parsed1.isValid() || !parsed2.isValid()) {
1093
+ throw new Error(`Unable to parse dates: ${date1}, ${date2}`);
1094
+ }
1095
+ return parsed1.diff(parsed2, unit);
1096
+ };
1097
+ var toISOString = (dateInput) => {
1098
+ const parsed = parseDateInput(dateInput);
1099
+ if (!parsed.isValid()) {
1100
+ throw new Error(`Unable to parse date: ${dateInput}`);
1101
+ }
1102
+ return parsed.toISOString();
1103
+ };
1104
+ var dateTimezone = (dateInput, timezoneStr, formatString) => {
1105
+ const defaultFormat = "YYYY-MM-DD HH:mm:ss";
1106
+ const format2 = formatString || defaultFormat;
1107
+ const convertedFormat = convertFormatString(format2);
1108
+ const parsed = parseDateInput(dateInput);
1109
+ if (!parsed.isValid()) {
1110
+ throw new Error(`Unable to parse date: ${dateInput}`);
1111
+ }
1112
+ return parsed.tz(timezoneStr).format(convertedFormat);
1113
+ };
1114
+ var dateLocale = (dateInput, locale, formatString) => {
1115
+ const defaultFormat = "YYYY-MM-DD HH:mm:ss";
1116
+ const format2 = formatString || defaultFormat;
1117
+ const convertedFormat = convertFormatString(format2);
1118
+ const parsed = parseDateInput(dateInput);
1119
+ if (!parsed.isValid()) {
1120
+ throw new Error(`Unable to parse date: ${dateInput}`);
1121
+ }
1122
+ return parsed.locale(locale).format(convertedFormat);
1123
+ };
1124
+ var helpers5 = [
1125
+ {
1126
+ name: "year",
1127
+ category: "date",
1128
+ compatibility: ["browser", "nodejs"],
1129
+ fn: year
1130
+ },
1131
+ {
1132
+ name: "date",
1133
+ category: "date",
1134
+ compatibility: ["browser", "nodejs"],
1135
+ fn: date
1136
+ },
1137
+ {
1138
+ /* Adding this in for legacy support */
1139
+ name: "moment",
1140
+ category: "date",
1141
+ compatibility: ["browser", "nodejs"],
1142
+ fn: date
1143
+ },
1144
+ {
1145
+ name: "timestamp",
1146
+ category: "date",
1147
+ compatibility: ["browser", "nodejs"],
1148
+ fn: timestamp
1149
+ },
1150
+ {
1151
+ name: "now",
1152
+ category: "date",
1153
+ compatibility: ["browser", "nodejs"],
1154
+ fn: now
1155
+ },
1156
+ {
1157
+ name: "fromNow",
1158
+ category: "date",
1159
+ compatibility: ["browser", "nodejs"],
1160
+ fn: fromNow
1161
+ },
1162
+ {
1163
+ name: "toNow",
1164
+ category: "date",
1165
+ compatibility: ["browser", "nodejs"],
1166
+ fn: toNow
1167
+ },
1168
+ {
1169
+ name: "ago",
1170
+ category: "date",
1171
+ compatibility: ["browser", "nodejs"],
1172
+ fn: ago
1173
+ },
1174
+ {
1175
+ name: "dateAdd",
1176
+ category: "date",
1177
+ compatibility: ["browser", "nodejs"],
1178
+ fn: dateAdd
1179
+ },
1180
+ {
1181
+ name: "dateSubtract",
1182
+ category: "date",
1183
+ compatibility: ["browser", "nodejs"],
1184
+ fn: dateSubtract
1185
+ },
1186
+ {
1187
+ name: "startOf",
1188
+ category: "date",
1189
+ compatibility: ["browser", "nodejs"],
1190
+ fn: startOf
1191
+ },
1192
+ {
1193
+ name: "endOf",
1194
+ category: "date",
1195
+ compatibility: ["browser", "nodejs"],
1196
+ fn: endOf
1197
+ },
1198
+ {
1199
+ name: "isBefore",
1200
+ category: "date",
1201
+ compatibility: ["browser", "nodejs"],
1202
+ fn: isBefore
1203
+ },
1204
+ {
1205
+ name: "isAfter",
1206
+ category: "date",
1207
+ compatibility: ["browser", "nodejs"],
1208
+ fn: isAfter
1209
+ },
1210
+ {
1211
+ name: "isSame",
1212
+ category: "date",
1213
+ compatibility: ["browser", "nodejs"],
1214
+ fn: isSame
1215
+ },
1216
+ {
1217
+ name: "isBetween",
1218
+ category: "date",
1219
+ compatibility: ["browser", "nodejs"],
1220
+ fn: isBetweenDates
1221
+ },
1222
+ {
1223
+ name: "diff",
1224
+ category: "date",
1225
+ compatibility: ["browser", "nodejs"],
1226
+ fn: diff
1227
+ },
1228
+ {
1229
+ name: "toISOString",
1230
+ category: "date",
1231
+ compatibility: ["browser", "nodejs"],
1232
+ fn: toISOString
1233
+ },
1234
+ {
1235
+ name: "dateTimezone",
1236
+ category: "date",
1237
+ compatibility: ["browser", "nodejs"],
1238
+ fn: dateTimezone
1239
+ },
1240
+ {
1241
+ name: "dateLocale",
1242
+ category: "date",
1243
+ compatibility: ["browser", "nodejs"],
1244
+ fn: dateLocale
1245
+ }
1246
+ ];
1247
+
1248
+ // src/helpers/fs.ts
1249
+ var import_node_fs2 = __toESM(require("fs"), 1);
1250
+ var import_node_path2 = __toESM(require("path"), 1);
1251
+ var import_is_glob = __toESM(require("is-glob"), 1);
1252
+ var import_micromatch = __toESM(require("micromatch"), 1);
1253
+ var fileSize = (value, precision) => {
1254
+ if (value == null) return "0 B";
1255
+ const number = typeof value === "number" ? value : value.length ?? 0;
1256
+ if (!number) return "0 B";
1257
+ const precisionNumber = typeof precision === "number" ? precision : 2;
1258
+ const abbr = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
1259
+ const factor = 10 ** precisionNumber;
1260
+ let i = abbr.length - 1;
1261
+ do {
1262
+ const size = 10 ** (i * 3);
1263
+ if (size <= number + 1) {
1264
+ const num = Math.round(number * factor / size) / factor;
1265
+ return `${num} ${abbr[i]}`;
1266
+ }
1267
+ } while (--i >= 0);
1268
+ return `${number} B`;
1269
+ };
1270
+ var read = (filepath) => {
1271
+ return import_node_fs2.default.readFileSync(filepath, "utf8");
1272
+ };
1273
+ var isOptions = (value) => {
1274
+ return Boolean(
1275
+ value && typeof value === "object" && "hash" in value
1276
+ );
1277
+ };
1278
+ var readdir = (dir, filter2) => {
1279
+ const files = import_node_fs2.default.readdirSync(dir).map((fp) => import_node_path2.default.join(dir, fp));
1280
+ const filterArg = isOptions(filter2) ? void 0 : filter2;
1281
+ if (typeof filterArg === "function") {
1282
+ return filterArg(files);
1283
+ }
1284
+ if (filterArg instanceof RegExp) {
1285
+ return files.filter((fp) => filterArg.test(fp));
1286
+ }
1287
+ if (typeof filterArg === "string") {
1288
+ if ((0, import_is_glob.default)(filterArg)) {
1289
+ return (0, import_micromatch.default)(files, filterArg);
1290
+ }
1291
+ if (filterArg === "isFile" || filterArg === "isDirectory") {
1292
+ return files.filter((fp) => {
1293
+ const stat = import_node_fs2.default.statSync(fp);
1294
+ return filterArg === "isFile" ? stat.isFile() : stat.isDirectory();
1295
+ });
1296
+ }
1297
+ }
1298
+ return files;
1299
+ };
1300
+ var helpers6 = [
1301
+ {
1302
+ name: "fileSize",
1303
+ category: "fs",
1304
+ compatibility: ["nodejs"],
1305
+ fn: fileSize
1306
+ },
1307
+ {
1308
+ name: "read",
1309
+ category: "fs",
1310
+ compatibility: ["nodejs"],
1311
+ fn: read
1312
+ },
1313
+ {
1314
+ name: "readdir",
1315
+ category: "fs",
1316
+ compatibility: ["nodejs"],
1317
+ fn: readdir
1318
+ }
1319
+ ];
1320
+
1321
+ // src/helpers/html.ts
1322
+ var import_node_path3 = __toESM(require("path"), 1);
1323
+ var import_html_tag2 = __toESM(require("html-tag"), 1);
1324
+ var import_striptags = __toESM(require("striptags"), 1);
1325
+ var parseAttributes = (hash = {}) => Object.keys(hash).map((key) => `${key}="${String(hash[key]).replace(/^['"]|["']$/g, "")}"`).join(" ");
1326
+ var attr = (options2) => {
1327
+ const val = parseAttributes(options2?.hash ?? {});
1328
+ return val.trim() ? ` ${val}` : "";
1329
+ };
1330
+ var css = function(list, options2) {
1331
+ if (arguments.length < 2) {
1332
+ options2 = list;
1333
+ list = [];
1334
+ }
1335
+ let styles = arrayify(list ?? []);
1336
+ let assets = "";
1337
+ if (this && this.options) {
1338
+ assets = this.options.assets || "";
1339
+ }
1340
+ if (options2?.hash?.href) {
1341
+ styles = arrayify(options2.hash.href);
1342
+ }
1343
+ return styles.map((item) => {
1344
+ const ext = import_node_path3.default.extname(item);
1345
+ let fp = item;
1346
+ if (!/(^\/\/)|(:\/\/)/.test(item)) {
1347
+ fp = import_node_path3.default.posix.join(assets, item);
1348
+ }
1349
+ if (ext === ".less") {
1350
+ return `<link type="text/css" rel="stylesheet/less" href="${fp}">`;
1351
+ }
1352
+ return `<link type="text/css" rel="stylesheet" href="${fp}">`;
1353
+ }).join("\n");
1354
+ };
1355
+ var js = (context) => {
1356
+ if (context && typeof context === "object" && !Array.isArray(context)) {
1357
+ const attrStr = parseAttributes(context.hash ?? {});
1358
+ return `<script${attrStr ? ` ${attrStr}` : ""}></script>`;
1359
+ }
1360
+ if (typeof context === "string") {
1361
+ return `<script src="${context}"></script>`;
1362
+ }
1363
+ const items = arrayify(context);
1364
+ return items.map(
1365
+ (fp) => import_node_path3.default.extname(fp) === ".coffee" ? (0, import_html_tag2.default)("script", { type: "text/coffeescript", src: fp }) : (0, import_html_tag2.default)("script", { src: fp })
1366
+ ).join("\n");
1367
+ };
1368
+ var sanitize = (str) => {
1369
+ if (typeof str !== "string") return "";
1370
+ return (0, import_striptags.default)(str).trim();
1371
+ };
1372
+ var ul = (context, options2) => {
1373
+ const attrs = parseAttributes(options2.hash ?? {});
1374
+ const items = context.map(
1375
+ (item) => typeof item === "string" ? item : options2.fn(item)
1376
+ );
1377
+ const open = attrs ? `<ul ${attrs}>` : "<ul>";
1378
+ return `${open}${items.map((i) => `<li>${i}</li>`).join("\n")}</ul>`;
1379
+ };
1380
+ var ol = (context, options2) => {
1381
+ const attrs = parseAttributes(options2.hash ?? {});
1382
+ const items = context.map(
1383
+ (item) => typeof item === "string" ? item : options2.fn(item)
1384
+ );
1385
+ const open = attrs ? `<ol ${attrs}>` : "<ol>";
1386
+ return `${open}${items.map((i) => `<li>${i}</li>`).join("\n")}</ol>`;
1387
+ };
1388
+ var thumbnailImage = (context) => {
1389
+ let figure = "";
1390
+ let image = "";
1391
+ const link = context.full || false;
1392
+ const imageAttributes = {
1393
+ alt: context.alt,
1394
+ src: context.thumbnail,
1395
+ width: context.size.width,
1396
+ height: context.size.height
1397
+ };
1398
+ const figureAttributes = { id: `image-${context.id}` };
1399
+ const linkAttributes = { href: link, rel: "thumbnail" };
1400
+ if (context.classes) {
1401
+ if (context.classes.image) {
1402
+ imageAttributes.class = context.classes.image.join(" ");
1403
+ }
1404
+ if (context.classes.figure) {
1405
+ figureAttributes.class = context.classes.figure.join(" ");
1406
+ }
1407
+ if (context.classes.link) {
1408
+ linkAttributes.class = context.classes.link.join(" ");
1409
+ }
1410
+ }
1411
+ figure += `<figure ${parseAttributes(figureAttributes)}>
1412
+ `;
1413
+ image += `<img ${parseAttributes(imageAttributes)}>
1414
+ `;
1415
+ if (link) {
1416
+ figure += `<a ${parseAttributes(linkAttributes)}>
1417
+ ${image}</a>
1418
+ `;
1419
+ } else {
1420
+ figure += image;
1421
+ }
1422
+ if (context.caption) {
1423
+ figure += `<figcaption>${context.caption}</figcaption>
1424
+ `;
1425
+ }
1426
+ figure += "</figure>";
1427
+ return figure;
1428
+ };
1429
+ var helpers7 = [
1430
+ {
1431
+ name: "attr",
1432
+ category: "html",
1433
+ compatibility: ["browser", "nodejs"],
1434
+ fn: attr
1435
+ },
1436
+ {
1437
+ name: "css",
1438
+ category: "html",
1439
+ compatibility: ["nodejs"],
1440
+ fn: css
1441
+ },
1442
+ {
1443
+ name: "js",
1444
+ category: "html",
1445
+ compatibility: ["nodejs"],
1446
+ fn: js
1447
+ },
1448
+ {
1449
+ name: "sanitize",
1450
+ category: "html",
1451
+ compatibility: ["browser", "nodejs"],
1452
+ fn: sanitize
1453
+ },
1454
+ {
1455
+ name: "ul",
1456
+ category: "html",
1457
+ compatibility: ["browser", "nodejs"],
1458
+ fn: ul
1459
+ },
1460
+ {
1461
+ name: "ol",
1462
+ category: "html",
1463
+ compatibility: ["browser", "nodejs"],
1464
+ fn: ol
1465
+ },
1466
+ {
1467
+ name: "thumbnailImage",
1468
+ category: "html",
1469
+ compatibility: ["browser", "nodejs"],
1470
+ fn: thumbnailImage
1471
+ }
1472
+ ];
1473
+
1474
+ // src/utils.ts
1475
+ var get = (object, path6) => {
1476
+ if (!object || typeof object !== "object") return void 0;
1477
+ const keys = Array.isArray(path6) ? path6 : path6.split(".");
1478
+ let result = object;
1479
+ for (const key of keys) {
1480
+ if (result == null || typeof result !== "object") return void 0;
1481
+ result = result[key];
1482
+ }
1483
+ return result;
1484
+ };
1485
+ var getObject = (object, path6) => {
1486
+ if (!object || typeof object !== "object") return void 0;
1487
+ const keys = Array.isArray(path6) ? path6 : path6.split(".");
1488
+ if (keys.length === 0) return void 0;
1489
+ let current = object;
1490
+ for (let i = 0; i < keys.length - 1; i++) {
1491
+ if (current == null || typeof current !== "object") return void 0;
1492
+ current = current[keys[i]];
1493
+ }
1494
+ const finalKey = keys[keys.length - 1];
1495
+ if (current == null || typeof current !== "object" || !(finalKey in current)) {
1496
+ return void 0;
1497
+ }
1498
+ return { [finalKey]: current[finalKey] };
1499
+ };
1500
+ var options = (thisArg, locals, opts) => {
1501
+ const result = {};
1502
+ if (thisArg && typeof thisArg === "object" && thisArg.options) {
1503
+ Object.assign(result, thisArg.options);
1504
+ }
1505
+ if (locals && typeof locals === "object") {
1506
+ if ("hash" in locals) {
1507
+ Object.assign(result, locals.hash);
1508
+ } else {
1509
+ Object.assign(result, locals);
1510
+ }
1511
+ }
1512
+ if (opts && typeof opts === "object") {
1513
+ if ("hash" in opts) {
1514
+ Object.assign(result, opts.hash);
1515
+ } else {
1516
+ Object.assign(result, opts);
1517
+ }
1518
+ }
1519
+ return result;
1520
+ };
1521
+
1522
+ // src/helpers/i18n.ts
1523
+ var i18n = function(prop, locals, options2) {
1524
+ if (locals && typeof locals === "object" && "hash" in locals && options2 === void 0) {
1525
+ options2 = locals;
1526
+ locals = {};
1527
+ }
1528
+ if (typeof prop !== "string") {
1529
+ throw new Error('{{i18n}} helper expected "key" to be a string');
1530
+ }
1531
+ const context = {
1532
+ ...this,
1533
+ ...locals,
1534
+ ...options2?.hash ?? {}
1535
+ };
1536
+ const lang = context.language || context.lang;
1537
+ if (typeof lang !== "string") {
1538
+ throw new TypeError('{{i18n}} helper expected "language" to be a string');
1539
+ }
1540
+ const cache = context[lang];
1541
+ if (typeof cache === "undefined") {
1542
+ throw new Error(`{{i18n}} helper cannot find language "${lang}"`);
1543
+ }
1544
+ const result = get(cache, prop);
1545
+ if (typeof result === "undefined") {
1546
+ throw new Error(
1547
+ '{{i18n}} helper cannot find property "' + String(prop) + '" for language "' + lang + '"'
1548
+ );
1549
+ }
1550
+ return String(result);
1551
+ };
1552
+ var helpers8 = [
1553
+ {
1554
+ name: "i18n",
1555
+ category: "i18n",
1556
+ compatibility: ["browser", "nodejs"],
1557
+ fn: i18n
1558
+ }
1559
+ ];
1560
+
1561
+ // src/helpers/inflection.ts
1562
+ var inflect = (count, singular, plural, includeCount) => {
1563
+ const word = count > 1 || count === 0 ? plural : singular;
1564
+ return includeCount ? `${count} ${word}` : word;
1565
+ };
1566
+ var ordinalize = (value) => {
1567
+ const num = Math.abs(Math.round(Number(value)));
1568
+ const str = String(value);
1569
+ const res = num % 100;
1570
+ if ([11, 12, 13].includes(res)) {
1571
+ return `${str}th`;
1572
+ }
1573
+ switch (num % 10) {
1574
+ case 1:
1575
+ return `${str}st`;
1576
+ case 2:
1577
+ return `${str}nd`;
1578
+ case 3:
1579
+ return `${str}rd`;
1580
+ default:
1581
+ return `${str}th`;
1582
+ }
1583
+ };
1584
+ var helpers9 = [
1585
+ {
1586
+ name: "inflect",
1587
+ category: "inflection",
1588
+ compatibility: ["browser", "nodejs"],
1589
+ fn: inflect
1590
+ },
1591
+ {
1592
+ name: "ordinalize",
1593
+ category: "inflection",
1594
+ compatibility: ["browser", "nodejs"],
1595
+ fn: ordinalize
1596
+ }
1597
+ ];
1598
+
1599
+ // src/helpers/logging.ts
1600
+ var colors = {
1601
+ green: (str) => `\x1B[32m${str}\x1B[0m`,
1602
+ cyan: (str) => `\x1B[36m${str}\x1B[0m`,
1603
+ yellow: (str) => `\x1B[33m${str}\x1B[0m`,
1604
+ red: (str) => `\x1B[31m${str}\x1B[0m`,
1605
+ bold: (str) => `\x1B[1m${str}\x1B[0m`
1606
+ };
1607
+ function cleanArgs(args) {
1608
+ const last2 = args[args.length - 1];
1609
+ if (args.length > 1 && typeof last2 === "object" && last2 !== null && "hash" in last2) {
1610
+ return args.slice(0, -1);
1611
+ }
1612
+ return args;
1613
+ }
1614
+ function log(...args) {
1615
+ const cleanedArgs = cleanArgs(args);
1616
+ console.log(...cleanedArgs);
1617
+ return "";
1618
+ }
1619
+ function ok(...args) {
1620
+ const cleanedArgs = cleanArgs(args);
1621
+ const message = cleanedArgs.join(" ");
1622
+ console.log(colors.green(`\u2713 ${message}`));
1623
+ return "";
1624
+ }
1625
+ function success(...args) {
1626
+ const cleanedArgs = cleanArgs(args);
1627
+ const message = cleanedArgs.map((arg) => String(arg)).join(" ");
1628
+ console.log(colors.green(message));
1629
+ return "";
1630
+ }
1631
+ function info(...args) {
1632
+ const cleanedArgs = cleanArgs(args);
1633
+ const message = cleanedArgs.map((arg) => String(arg)).join(" ");
1634
+ console.log(colors.cyan(message));
1635
+ return "";
1636
+ }
1637
+ function warning(...args) {
1638
+ const cleanedArgs = cleanArgs(args);
1639
+ const message = cleanedArgs.map((arg) => String(arg)).join(" ");
1640
+ console.error(colors.yellow(message));
1641
+ return "";
1642
+ }
1643
+ var warn = warning;
1644
+ function error(...args) {
1645
+ const cleanedArgs = cleanArgs(args);
1646
+ const message = cleanedArgs.map((arg) => String(arg)).join(" ");
1647
+ console.error(colors.red(message));
1648
+ return "";
1649
+ }
1650
+ var danger = error;
1651
+ function bold(...args) {
1652
+ const cleanedArgs = cleanArgs(args);
1653
+ const message = cleanedArgs.map((arg) => String(arg)).join(" ");
1654
+ console.error(colors.bold(message));
1655
+ return "";
1656
+ }
1657
+ function _debug(...args) {
1658
+ const separator = "\u2500".repeat(50);
1659
+ console.error(colors.cyan(separator));
1660
+ if (args.length > 0) {
1661
+ const cleanedArgs = cleanArgs(args);
1662
+ console.error(colors.cyan("VALUE:"), cleanedArgs[0]);
1663
+ }
1664
+ if (this && Object.keys(this).length > 0) {
1665
+ console.error(colors.cyan("CONTEXT:"), this);
1666
+ }
1667
+ console.error(colors.cyan(separator));
1668
+ return "";
1669
+ }
1670
+ function _inspect(context, options2) {
1671
+ const val = JSON.stringify(context, null, 2);
1672
+ const type = options2?.hash?.type || "html";
1673
+ return switchOutput(type, val);
1674
+ }
1675
+ function switchOutput(type, json) {
1676
+ if (type[0] === ".") {
1677
+ type = type.slice(1);
1678
+ }
1679
+ switch (type) {
1680
+ case "md":
1681
+ return `
1682
+ \`\`\`json
1683
+ ${json}
1684
+ \`\`\`
1685
+ `;
1686
+ case "html":
1687
+ return `<div class="highlight highlight-json">
1688
+ <pre><code>
1689
+ ${json}</code></pre></div>`;
1690
+ default:
1691
+ return json;
1692
+ }
1693
+ }
1694
+ var helpers10 = [
1695
+ {
1696
+ name: "log",
1697
+ category: "logging",
1698
+ compatibility: ["nodejs"],
1699
+ fn: log
1700
+ },
1701
+ {
1702
+ name: "ok",
1703
+ category: "logging",
1704
+ compatibility: ["nodejs"],
1705
+ fn: ok
1706
+ },
1707
+ {
1708
+ name: "success",
1709
+ category: "logging",
1710
+ compatibility: ["nodejs"],
1711
+ fn: success
1712
+ },
1713
+ {
1714
+ name: "info",
1715
+ category: "logging",
1716
+ compatibility: ["nodejs"],
1717
+ fn: info
1718
+ },
1719
+ {
1720
+ name: "warning",
1721
+ category: "logging",
1722
+ compatibility: ["nodejs"],
1723
+ fn: warning
1724
+ },
1725
+ {
1726
+ name: "warn",
1727
+ category: "logging",
1728
+ compatibility: ["nodejs"],
1729
+ fn: warn
1730
+ },
1731
+ {
1732
+ name: "error",
1733
+ category: "logging",
1734
+ compatibility: ["nodejs"],
1735
+ fn: error
1736
+ },
1737
+ {
1738
+ name: "danger",
1739
+ category: "logging",
1740
+ compatibility: ["nodejs"],
1741
+ fn: danger
1742
+ },
1743
+ {
1744
+ name: "bold",
1745
+ category: "logging",
1746
+ compatibility: ["nodejs"],
1747
+ fn: bold
1748
+ },
1749
+ {
1750
+ name: "_debug",
1751
+ category: "logging",
1752
+ compatibility: ["nodejs"],
1753
+ fn: _debug
1754
+ },
1755
+ {
1756
+ name: "_inspect",
1757
+ category: "logging",
1758
+ compatibility: ["nodejs"],
1759
+ fn: _inspect
1760
+ }
1761
+ ];
1762
+
1763
+ // src/helpers/match.ts
1764
+ var import_micromatch2 = __toESM(require("micromatch"), 1);
1765
+ var match = (files, patterns, options2) => {
1766
+ const pats = typeof patterns === "string" ? patterns.split(/, */) : patterns;
1767
+ return (0, import_micromatch2.default)(files, pats, options2);
1768
+ };
1769
+ var isMatch = (filepath, pattern, options2) => {
1770
+ return import_micromatch2.default.isMatch(filepath, pattern, options2);
1771
+ };
1772
+ var mm = (...args) => {
1773
+ console.log("the {{mm}} helper is depcrecated and will be removed");
1774
+ console.log("in handlebars-helpers v1.0.0, please use the {{match}}");
1775
+ console.log("helper instead.");
1776
+ return match(...args);
1777
+ };
1778
+ var helpers11 = [
1779
+ {
1780
+ name: "match",
1781
+ category: "match",
1782
+ compatibility: ["browser", "nodejs"],
1783
+ fn: match
1784
+ },
1785
+ {
1786
+ name: "isMatch",
1787
+ category: "match",
1788
+ compatibility: ["browser", "nodejs"],
1789
+ fn: isMatch
1790
+ },
1791
+ {
1792
+ name: "mm",
1793
+ category: "match",
1794
+ compatibility: ["browser", "nodejs"],
1795
+ fn: mm
1796
+ }
1797
+ ];
1798
+
1799
+ // src/helpers/math.ts
1800
+ var isNumeric = (value) => typeof value === "number" && !Number.isNaN(value) || typeof value === "string" && value.trim() !== "" && !Number.isNaN(Number(value));
1801
+ var toNumber = (value, message = "expected a number") => {
1802
+ if (isNumeric(value)) {
1803
+ return Number(value);
1804
+ }
1805
+ throw new TypeError(message);
1806
+ };
1807
+ var abs = (value) => {
1808
+ const num = toNumber(value);
1809
+ return Math.abs(num);
1810
+ };
1811
+ var add = (a, b) => {
1812
+ if (isNumeric(a) && isNumeric(b)) {
1813
+ return Number(a) + Number(b);
1814
+ }
1815
+ return "";
1816
+ };
1817
+ var avg = (...values) => {
1818
+ const flat = values.flat().map((n) => Number(n));
1819
+ return sum(flat) / flat.length;
1820
+ };
1821
+ var ceil = (value) => {
1822
+ const num = toNumber(value);
1823
+ return Math.ceil(num);
1824
+ };
1825
+ var divide = (a, b) => {
1826
+ const numA = toNumber(a, "expected the first argument to be a number");
1827
+ const numB = toNumber(b, "expected the second argument to be a number");
1828
+ return numA / numB;
1829
+ };
1830
+ var floor = (value) => {
1831
+ const num = toNumber(value);
1832
+ return Math.floor(num);
1833
+ };
1834
+ var minus = (a, b) => {
1835
+ const numA = toNumber(a, "expected the first argument to be a number");
1836
+ const numB = toNumber(b, "expected the second argument to be a number");
1837
+ return numA - numB;
1838
+ };
1839
+ var modulo = (a, b) => {
1840
+ const numA = toNumber(a, "expected the first argument to be a number");
1841
+ const numB = toNumber(b, "expected the second argument to be a number");
1842
+ return numA % numB;
1843
+ };
1844
+ var multiply = (a, b) => {
1845
+ const numA = toNumber(a, "expected the first argument to be a number");
1846
+ const numB = toNumber(b, "expected the second argument to be a number");
1847
+ return numA * numB;
1848
+ };
1849
+ var plus = (a, b) => {
1850
+ const numA = toNumber(a, "expected the first argument to be a number");
1851
+ const numB = toNumber(b, "expected the second argument to be a number");
1852
+ return numA + numB;
1853
+ };
1854
+ var random = (min, max) => {
1855
+ const minNum = toNumber(min, "expected minimum to be a number");
1856
+ const maxNum = toNumber(max, "expected maximum to be a number");
1857
+ return minNum + Math.floor(Math.random() * (maxNum - minNum + 1));
1858
+ };
1859
+ var remainder = (a, b) => a % b;
1860
+ var round = (value) => {
1861
+ const num = toNumber(value);
1862
+ return Math.round(num);
1863
+ };
1864
+ var subtract = (a, b) => {
1865
+ const numA = toNumber(a, "expected the first argument to be a number");
1866
+ const numB = toNumber(b, "expected the second argument to be a number");
1867
+ return numA - numB;
1868
+ };
1869
+ var sum = (...values) => {
1870
+ const flat = values.flat();
1871
+ let total = 0;
1872
+ for (const value of flat) {
1873
+ if (isNumeric(value)) {
1874
+ total += Number(value);
1875
+ }
1876
+ }
1877
+ return total;
1878
+ };
1879
+ var times = (a, b) => multiply(a, b);
1880
+ var helpers12 = [
1881
+ {
1882
+ name: "abs",
1883
+ category: "math",
1884
+ compatibility: ["browser", "nodejs"],
1885
+ fn: abs
1886
+ },
1887
+ {
1888
+ name: "add",
1889
+ category: "math",
1890
+ compatibility: ["browser", "nodejs"],
1891
+ fn: add
1892
+ },
1893
+ {
1894
+ name: "avg",
1895
+ category: "math",
1896
+ compatibility: ["browser", "nodejs"],
1897
+ fn: avg
1898
+ },
1899
+ {
1900
+ name: "ceil",
1901
+ category: "math",
1902
+ compatibility: ["browser", "nodejs"],
1903
+ fn: ceil
1904
+ },
1905
+ {
1906
+ name: "divide",
1907
+ category: "math",
1908
+ compatibility: ["browser", "nodejs"],
1909
+ fn: divide
1910
+ },
1911
+ {
1912
+ name: "floor",
1913
+ category: "math",
1914
+ compatibility: ["browser", "nodejs"],
1915
+ fn: floor
1916
+ },
1917
+ {
1918
+ name: "minus",
1919
+ category: "math",
1920
+ compatibility: ["browser", "nodejs"],
1921
+ fn: minus
1922
+ },
1923
+ {
1924
+ name: "modulo",
1925
+ category: "math",
1926
+ compatibility: ["browser", "nodejs"],
1927
+ fn: modulo
1928
+ },
1929
+ {
1930
+ name: "multiply",
1931
+ category: "math",
1932
+ compatibility: ["browser", "nodejs"],
1933
+ fn: multiply
1934
+ },
1935
+ {
1936
+ name: "plus",
1937
+ category: "math",
1938
+ compatibility: ["browser", "nodejs"],
1939
+ fn: plus
1940
+ },
1941
+ {
1942
+ name: "random",
1943
+ category: "math",
1944
+ compatibility: ["browser", "nodejs"],
1945
+ fn: random
1946
+ },
1947
+ {
1948
+ name: "remainder",
1949
+ category: "math",
1950
+ compatibility: ["browser", "nodejs"],
1951
+ fn: remainder
1952
+ },
1953
+ {
1954
+ name: "round",
1955
+ category: "math",
1956
+ compatibility: ["browser", "nodejs"],
1957
+ fn: round
1958
+ },
1959
+ {
1960
+ name: "subtract",
1961
+ category: "math",
1962
+ compatibility: ["browser", "nodejs"],
1963
+ fn: subtract
1964
+ },
1965
+ {
1966
+ name: "sum",
1967
+ category: "math",
1968
+ compatibility: ["browser", "nodejs"],
1969
+ fn: sum
1970
+ },
1971
+ {
1972
+ name: "times",
1973
+ category: "math",
1974
+ compatibility: ["browser", "nodejs"],
1975
+ fn: times
1976
+ }
1977
+ ];
1978
+
1979
+ // src/helpers/md.ts
1980
+ var import_node_fs3 = __toESM(require("fs"), 1);
1981
+ var import_node_path4 = __toESM(require("path"), 1);
1982
+ var import_node_process = __toESM(require("process"), 1);
1983
+ var import_ent = __toESM(require("ent"), 1);
1984
+ var import_handlebars = __toESM(require("handlebars"), 1);
1985
+ var import_remarkable = require("remarkable");
1986
+ var renderMarkdown = function(input, options2) {
1987
+ if (typeof input === "object" && input && "fn" in input && typeof input.fn === "function") {
1988
+ options2 = input;
1989
+ input = input.fn(this);
1990
+ } else if (typeof input !== "string") {
1991
+ input = "";
1992
+ }
1993
+ const options_ = { cwd: import_node_process.default.cwd(), ...options2 };
1994
+ const md = new import_remarkable.Remarkable({
1995
+ breaks: true,
1996
+ html: true,
1997
+ langPrefix: "lang-",
1998
+ typographer: false,
1999
+ xhtmlOut: false
2000
+ });
2001
+ let string_ = input;
2002
+ if (string_ && string_.length > 0) {
2003
+ const filepath = import_node_path4.default.resolve(options_.cwd, string_);
2004
+ if (import_node_fs3.default.existsSync(filepath) && import_node_fs3.default.statSync(filepath).isFile()) {
2005
+ string_ = import_node_fs3.default.readFileSync(filepath, "utf8");
2006
+ }
2007
+ }
2008
+ return new import_handlebars.default.SafeString(import_ent.default.decode(md.render(string_)));
2009
+ };
2010
+ var helpers13 = [
2011
+ {
2012
+ name: "md",
2013
+ category: "markdown",
2014
+ compatibility: ["nodejs"],
2015
+ fn: renderMarkdown
2016
+ },
2017
+ {
2018
+ name: "markdown",
2019
+ category: "markdown",
2020
+ compatibility: ["nodejs"],
2021
+ fn: renderMarkdown
2022
+ }
2023
+ ];
2024
+
2025
+ // src/helpers/misc.ts
2026
+ var import_handlebars2 = __toESM(require("handlebars"), 1);
2027
+ var import_kind_of = __toESM(require("kind-of"), 1);
2028
+ function frame(context, options2) {
2029
+ if (typeof context === "object" && context !== null && "hash" in context) {
2030
+ options2 = context;
2031
+ context = options2.data;
2032
+ }
2033
+ const data = import_handlebars2.default.createFrame(context || {});
2034
+ if (typeof options2 !== "object" || options2 === null) {
2035
+ options2 = {};
2036
+ }
2037
+ if (options2.hash && typeof options2.hash === "object") {
2038
+ Object.assign(data, options2.hash);
2039
+ }
2040
+ return options2.fn(this, { data });
2041
+ }
2042
+ function option(prop, locals, opts) {
2043
+ return get(options(this, locals, opts), prop);
2044
+ }
2045
+ function noop(options2) {
2046
+ return options2.fn(this);
2047
+ }
2048
+ var typeOf = import_kind_of.default;
2049
+ function withHash(options2) {
2050
+ if (options2.hash && Object.keys(options2.hash).length) {
2051
+ return options2.fn(options2.hash);
2052
+ }
2053
+ return options2.inverse(this);
2054
+ }
2055
+ var helpers14 = [
2056
+ {
2057
+ name: "frame",
2058
+ category: "misc",
2059
+ compatibility: ["browser", "nodejs"],
2060
+ fn: frame
2061
+ },
2062
+ {
2063
+ name: "option",
2064
+ category: "misc",
2065
+ compatibility: ["browser", "nodejs"],
2066
+ fn: option
2067
+ },
2068
+ {
2069
+ name: "noop",
2070
+ category: "misc",
2071
+ compatibility: ["browser", "nodejs"],
2072
+ fn: noop
2073
+ },
2074
+ {
2075
+ name: "typeOf",
2076
+ category: "misc",
2077
+ compatibility: ["browser", "nodejs"],
2078
+ fn: typeOf
2079
+ },
2080
+ {
2081
+ name: "withHash",
2082
+ category: "misc",
2083
+ compatibility: ["browser", "nodejs"],
2084
+ fn: withHash
2085
+ }
2086
+ ];
2087
+
2088
+ // src/helpers/number.ts
2089
+ var isNumeric2 = (value) => typeof value === "number" && !Number.isNaN(value);
2090
+ var bytes = (value, precision) => {
2091
+ if (value == null) return "0 B";
2092
+ let num;
2093
+ if (typeof value === "string") {
2094
+ num = value.length;
2095
+ if (!num) return "0 B";
2096
+ } else if (isNumeric2(value)) {
2097
+ num = Number(value);
2098
+ } else if (typeof value.length === "number") {
2099
+ num = value.length;
2100
+ if (!num) return "0 B";
2101
+ } else {
2102
+ return "0 B";
2103
+ }
2104
+ const prec = typeof precision === "number" && !Number.isNaN(precision) ? precision : 2;
2105
+ const abbr = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
2106
+ const factor = 10 ** prec;
2107
+ for (let i = abbr.length - 1; i >= 0; i--) {
2108
+ const size = 10 ** (i * 3);
2109
+ if (size <= num + 1) {
2110
+ const val = Math.round(num * factor / size) / factor;
2111
+ return `${val} ${abbr[i]}`;
2112
+ }
2113
+ }
2114
+ return `${num}`;
2115
+ };
2116
+ var addCommas = (num) => num.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
2117
+ var phoneNumber = (num) => {
2118
+ const str = num.toString();
2119
+ return `(${str.substr(0, 3)}) ${str.substr(3, 3)}-${str.substr(6, 4)}`;
2120
+ };
2121
+ var toAbbr = (value, precision) => {
2122
+ const num = isNumeric2(value) ? Number(value) : 0;
2123
+ const prec = typeof precision === "number" && !Number.isNaN(precision) ? precision : 2;
2124
+ const factor = 10 ** prec;
2125
+ const abbr = ["k", "m", "b", "t", "q"];
2126
+ for (let i = abbr.length - 1; i >= 0; i--) {
2127
+ const size = 10 ** ((i + 1) * 3);
2128
+ if (size <= num + 1) {
2129
+ const val = Math.round(num * factor / size) / factor;
2130
+ return `${val}${abbr[i]}`;
2131
+ }
2132
+ }
2133
+ return `${num}`;
2134
+ };
2135
+ var toExponential = (value, digits) => {
2136
+ const num = isNumeric2(value) ? Number(value) : 0;
2137
+ const d = typeof digits === "number" && !Number.isNaN(digits) ? digits : 0;
2138
+ return Number(num).toExponential(d);
2139
+ };
2140
+ var toFixed = (value, digits) => {
2141
+ const num = isNumeric2(value) ? Number(value) : 0;
2142
+ const d = typeof digits === "number" && !Number.isNaN(digits) ? digits : 0;
2143
+ return Number(num).toFixed(d);
2144
+ };
2145
+ var toFloat = (value) => parseFloat(String(value));
2146
+ var toInt = (value) => parseInt(String(value), 10);
2147
+ var toPrecision = (value, precision) => {
2148
+ const num = isNumeric2(value) ? Number(value) : 0;
2149
+ const prec = typeof precision === "number" && !Number.isNaN(precision) ? precision : 1;
2150
+ return Number(num).toPrecision(prec);
2151
+ };
2152
+ var helpers15 = [
2153
+ {
2154
+ name: "bytes",
2155
+ category: "number",
2156
+ compatibility: ["browser", "nodejs"],
2157
+ fn: bytes
2158
+ },
2159
+ {
2160
+ name: "addCommas",
2161
+ category: "number",
2162
+ compatibility: ["browser", "nodejs"],
2163
+ fn: addCommas
2164
+ },
2165
+ {
2166
+ name: "phoneNumber",
2167
+ category: "number",
2168
+ compatibility: ["browser", "nodejs"],
2169
+ fn: phoneNumber
2170
+ },
2171
+ {
2172
+ name: "toAbbr",
2173
+ category: "number",
2174
+ compatibility: ["browser", "nodejs"],
2175
+ fn: toAbbr
2176
+ },
2177
+ {
2178
+ name: "toExponential",
2179
+ category: "number",
2180
+ compatibility: ["browser", "nodejs"],
2181
+ fn: toExponential
2182
+ },
2183
+ {
2184
+ name: "toFixed",
2185
+ category: "number",
2186
+ compatibility: ["browser", "nodejs"],
2187
+ fn: toFixed
2188
+ },
2189
+ {
2190
+ name: "toFloat",
2191
+ category: "number",
2192
+ compatibility: ["browser", "nodejs"],
2193
+ fn: toFloat
2194
+ },
2195
+ {
2196
+ name: "toInt",
2197
+ category: "number",
2198
+ compatibility: ["browser", "nodejs"],
2199
+ fn: toInt
2200
+ },
2201
+ {
2202
+ name: "toPrecision",
2203
+ category: "number",
2204
+ compatibility: ["browser", "nodejs"],
2205
+ fn: toPrecision
2206
+ }
2207
+ ];
2208
+
2209
+ // src/helpers/object.ts
2210
+ var isOptions2 = (value) => {
2211
+ return Boolean(value && typeof value === "object" && "hash" in value);
2212
+ };
2213
+ var createFrame = (options2, hash) => ({
2214
+ ...options2?.data || {},
2215
+ ...hash
2216
+ });
2217
+ var extend = (...objects) => {
2218
+ const args = [...objects];
2219
+ if (args.length && isOptions2(args[args.length - 1])) {
2220
+ const opts = args.pop();
2221
+ args.push(opts.hash);
2222
+ }
2223
+ const result = {};
2224
+ for (const obj of args) {
2225
+ if (obj && typeof obj === "object" && !Array.isArray(obj)) {
2226
+ Object.assign(result, obj);
2227
+ }
2228
+ }
2229
+ return result;
2230
+ };
2231
+ var forIn = (obj, options2) => {
2232
+ if (!isOptions2(options2)) {
2233
+ return options2?.inverse?.(obj) ?? "";
2234
+ }
2235
+ const data = createFrame(options2, options2.hash || {});
2236
+ let result = "";
2237
+ for (const key in obj) {
2238
+ data.key = key;
2239
+ result += options2.fn(obj[key], { data });
2240
+ }
2241
+ return result;
2242
+ };
2243
+ var forOwn = (obj, options2) => {
2244
+ if (!isOptions2(options2)) {
2245
+ return options2?.inverse?.(obj) ?? "";
2246
+ }
2247
+ const data = createFrame(options2, options2.hash || {});
2248
+ let result = "";
2249
+ for (const key in obj) {
2250
+ if (Object.hasOwn(obj, key)) {
2251
+ data.key = key;
2252
+ result += options2.fn(obj[key], { data });
2253
+ }
2254
+ }
2255
+ return result;
2256
+ };
2257
+ var toPath = (...prop) => {
2258
+ const parts = [];
2259
+ for (const p of prop) {
2260
+ if (typeof p === "string" || typeof p === "number") {
2261
+ parts.push(p);
2262
+ }
2263
+ }
2264
+ return parts.join(".");
2265
+ };
2266
+ var getHelper = (prop, context, options2) => {
2267
+ const val = get(context, prop);
2268
+ if (options2 && typeof options2.fn === "function") {
2269
+ return val ? options2.fn(val) : options2.inverse?.(context);
2270
+ }
2271
+ return val;
2272
+ };
2273
+ var getObjectHelper = (prop, context) => {
2274
+ return getObject(context, prop);
2275
+ };
2276
+ var hasOwn = (context, key) => {
2277
+ return Object.hasOwn(context, key);
2278
+ };
2279
+ var isObject = (value) => {
2280
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
2281
+ };
2282
+ var JSONparse = (str) => {
2283
+ return JSON.parse(str);
2284
+ };
2285
+ var JSONstringify = (obj, indent) => {
2286
+ const ind = typeof indent === "number" ? indent : 0;
2287
+ return JSON.stringify(obj, null, ind);
2288
+ };
2289
+ var merge = (context, ...objects) => {
2290
+ const args = [context, ...objects];
2291
+ if (args.length && isOptions2(args[args.length - 1])) {
2292
+ const opts = args.pop();
2293
+ args.push(opts.hash);
2294
+ }
2295
+ return Object.assign(...args);
2296
+ };
2297
+ var parseJSON = JSONparse;
2298
+ var stringify = JSONstringify;
2299
+ var pick = (props, context, options2) => {
2300
+ const keys = arrayify(props);
2301
+ let result = {};
2302
+ for (const key of keys) {
2303
+ result = Object.assign({}, result, getObject(context, key));
2304
+ }
2305
+ if (options2 && typeof options2.fn === "function") {
2306
+ if (Object.keys(result).length) {
2307
+ return options2.fn(result);
2308
+ }
2309
+ return options2.inverse?.(context);
2310
+ }
2311
+ return result;
2312
+ };
2313
+ var helpers16 = [
2314
+ {
2315
+ name: "extend",
2316
+ category: "object",
2317
+ compatibility: ["browser", "nodejs"],
2318
+ fn: extend
2319
+ },
2320
+ {
2321
+ name: "forIn",
2322
+ category: "object",
2323
+ compatibility: ["browser", "nodejs"],
2324
+ fn: forIn
2325
+ },
2326
+ {
2327
+ name: "forOwn",
2328
+ category: "object",
2329
+ compatibility: ["browser", "nodejs"],
2330
+ fn: forOwn
2331
+ },
2332
+ {
2333
+ name: "toPath",
2334
+ category: "object",
2335
+ compatibility: ["browser", "nodejs"],
2336
+ fn: toPath
2337
+ },
2338
+ {
2339
+ name: "get",
2340
+ category: "object",
2341
+ compatibility: ["browser", "nodejs"],
2342
+ fn: getHelper
2343
+ },
2344
+ {
2345
+ name: "getObject",
2346
+ category: "object",
2347
+ compatibility: ["browser", "nodejs"],
2348
+ fn: getObjectHelper
2349
+ },
2350
+ {
2351
+ name: "hasOwn",
2352
+ category: "object",
2353
+ compatibility: ["browser", "nodejs"],
2354
+ fn: hasOwn
2355
+ },
2356
+ {
2357
+ name: "isObject",
2358
+ category: "object",
2359
+ compatibility: ["browser", "nodejs"],
2360
+ fn: isObject
2361
+ },
2362
+ {
2363
+ name: "JSONparse",
2364
+ category: "object",
2365
+ compatibility: ["browser", "nodejs"],
2366
+ fn: JSONparse
2367
+ },
2368
+ {
2369
+ name: "JSONstringify",
2370
+ category: "object",
2371
+ compatibility: ["browser", "nodejs"],
2372
+ fn: JSONstringify
2373
+ },
2374
+ {
2375
+ name: "merge",
2376
+ category: "object",
2377
+ compatibility: ["browser", "nodejs"],
2378
+ fn: merge
2379
+ },
2380
+ {
2381
+ name: "parseJSON",
2382
+ category: "object",
2383
+ compatibility: ["browser", "nodejs"],
2384
+ fn: parseJSON
2385
+ },
2386
+ {
2387
+ name: "pick",
2388
+ category: "object",
2389
+ compatibility: ["browser", "nodejs"],
2390
+ fn: pick
2391
+ },
2392
+ {
2393
+ name: "stringify",
2394
+ category: "object",
2395
+ compatibility: ["browser", "nodejs"],
2396
+ fn: stringify
2397
+ }
2398
+ ];
2399
+
2400
+ // src/helpers/path.ts
2401
+ var import_node_path5 = __toESM(require("path"), 1);
2402
+ var expectedType = (variableName, expectedType2, variableValue) => {
2403
+ const actualType = Object.prototype.toString.call(variableValue).slice(8, -1).toLowerCase();
2404
+ return `Expected ${variableName} to be of type ${expectedType2}, but got ${actualType}`;
2405
+ };
2406
+ var assertString = (name, value) => {
2407
+ if (typeof value !== "string") {
2408
+ throw new TypeError(expectedType(name, "string", value));
2409
+ }
2410
+ return value;
2411
+ };
2412
+ var absolute = function(filepath, options2) {
2413
+ const fp = assertString("filepath", filepath);
2414
+ const cwd = options2?.data?.root?.cwd ?? this?.cwd ?? process.cwd();
2415
+ return import_node_path5.default.resolve(cwd, fp);
2416
+ };
2417
+ var dirname = (filepath) => {
2418
+ const fp = assertString("filepath", filepath);
2419
+ return import_node_path5.default.dirname(fp);
2420
+ };
2421
+ var relative = (a, b) => {
2422
+ const from = assertString("first path", a);
2423
+ const to = assertString("second path", b);
2424
+ return import_node_path5.default.relative(import_node_path5.default.dirname(from), to);
2425
+ };
2426
+ var basename = (filepath) => {
2427
+ const fp = assertString("filepath", filepath);
2428
+ return import_node_path5.default.basename(fp);
2429
+ };
2430
+ var stem = (filepath) => {
2431
+ const fp = assertString("filepath", filepath);
2432
+ return import_node_path5.default.basename(fp, import_node_path5.default.extname(fp));
2433
+ };
2434
+ var extname = (filepath) => {
2435
+ const fp = assertString("filepath", filepath);
2436
+ return import_node_path5.default.extname(fp);
2437
+ };
2438
+ var resolveFn = function(filepath, ...paths) {
2439
+ let options2;
2440
+ const last2 = paths[paths.length - 1];
2441
+ if (typeof last2 === "object" && last2 && "data" in last2) {
2442
+ options2 = paths.pop();
2443
+ }
2444
+ const cwd = options2?.data?.root?.cwd ?? this?.cwd ?? process.cwd();
2445
+ const all2 = [
2446
+ cwd,
2447
+ assertString("filepath", filepath),
2448
+ ...paths.map((p, i) => assertString(`path${i}`, p))
2449
+ ];
2450
+ return import_node_path5.default.resolve(...all2);
2451
+ };
2452
+ var segments = (filepath, a, b) => {
2453
+ const fp = assertString("filepath", filepath);
2454
+ const start = Number(a);
2455
+ const end = Number(b);
2456
+ const segmentsArr = fp.split(/[\\/]+/);
2457
+ return segmentsArr.slice(start, end).join("/");
2458
+ };
2459
+ var helpers17 = [
2460
+ {
2461
+ name: "absolute",
2462
+ category: "path",
2463
+ compatibility: ["nodejs"],
2464
+ fn: absolute
2465
+ },
2466
+ {
2467
+ name: "dirname",
2468
+ category: "path",
2469
+ compatibility: ["nodejs"],
2470
+ fn: dirname
2471
+ },
2472
+ {
2473
+ name: "relative",
2474
+ category: "path",
2475
+ compatibility: ["nodejs"],
2476
+ fn: relative
2477
+ },
2478
+ {
2479
+ name: "basename",
2480
+ category: "path",
2481
+ compatibility: ["nodejs"],
2482
+ fn: basename
2483
+ },
2484
+ {
2485
+ name: "stem",
2486
+ category: "path",
2487
+ compatibility: ["nodejs"],
2488
+ fn: stem
2489
+ },
2490
+ {
2491
+ name: "extname",
2492
+ category: "path",
2493
+ compatibility: ["nodejs"],
2494
+ fn: extname
2495
+ },
2496
+ {
2497
+ name: "resolve",
2498
+ category: "path",
2499
+ compatibility: ["nodejs"],
2500
+ fn: resolveFn
2501
+ },
2502
+ {
2503
+ name: "segments",
2504
+ category: "path",
2505
+ compatibility: ["nodejs"],
2506
+ fn: segments
2507
+ }
2508
+ ];
2509
+
2510
+ // src/helpers/regex.ts
2511
+ var toRegex = (str, locals, opts) => {
2512
+ const mergedOpts = options({}, locals, opts);
2513
+ return new RegExp(str, mergedOpts.flags);
2514
+ };
2515
+ var test = (str, regex) => {
2516
+ if (typeof str !== "string") {
2517
+ return false;
2518
+ }
2519
+ if (!(regex instanceof RegExp)) {
2520
+ throw new TypeError("expected a regular expression");
2521
+ }
2522
+ return regex.test(str);
2523
+ };
2524
+ var helpers18 = [
2525
+ {
2526
+ name: "toRegex",
2527
+ category: "regex",
2528
+ compatibility: ["browser", "nodejs"],
2529
+ fn: toRegex
2530
+ },
2531
+ {
2532
+ name: "test",
2533
+ category: "regex",
2534
+ compatibility: ["browser", "nodejs"],
2535
+ fn: test
2536
+ }
2537
+ ];
2538
+
2539
+ // src/helpers/string.ts
2540
+ var chop = (str) => str.trim().replace(/^[-_.\W\s]+|[-_.\W\s]+$/g, "");
2541
+ var changecase = (str, fn) => {
2542
+ if (str.length === 1) return str.toLowerCase();
2543
+ const res = chop(str).toLowerCase();
2544
+ return res.replace(/[-_.\W\s]+(\w|$)/g, (_, ch) => fn(ch));
2545
+ };
2546
+ var append = (str, suffix) => {
2547
+ if (typeof str === "string" && typeof suffix === "string") {
2548
+ return str + suffix;
2549
+ }
2550
+ return str;
2551
+ };
2552
+ var camelcase = (str) => typeof str === "string" ? changecase(str, (ch) => ch.toUpperCase()) : "";
2553
+ var capitalize = (str) => {
2554
+ if (typeof str !== "string" || str.length === 0) return "";
2555
+ return str.charAt(0).toUpperCase() + str.slice(1);
2556
+ };
2557
+ var capitalizeAll = (str) => {
2558
+ if (typeof str !== "string") return "";
2559
+ return str.replace(/\w\S*/g, (word) => capitalize(word));
2560
+ };
2561
+ var center = (str, spaces) => {
2562
+ if (typeof str !== "string") return "";
2563
+ let space = "";
2564
+ for (let i = 0; i < spaces; i++) {
2565
+ space += "&nbsp;";
2566
+ }
2567
+ return space + str + space;
2568
+ };
2569
+ var chopStr = (str) => typeof str === "string" ? chop(str) : "";
2570
+ var dashcase = (str) => typeof str === "string" ? changecase(str, (ch) => `-${ch}`) : "";
2571
+ var dotcase = (str) => typeof str === "string" ? changecase(str, (ch) => `.${ch}`) : "";
2572
+ var truncate = (str, limit, suffix) => {
2573
+ if (typeof str === "string") {
2574
+ if (typeof suffix !== "string") {
2575
+ suffix = "";
2576
+ }
2577
+ if (str.length > limit) {
2578
+ return str.slice(0, limit - suffix.length) + suffix;
2579
+ }
2580
+ return str;
2581
+ }
2582
+ return "";
2583
+ };
2584
+ var ellipsis = (str, limit) => {
2585
+ if (typeof str === "string") {
2586
+ if (str.length <= limit) {
2587
+ return str;
2588
+ }
2589
+ return `${truncate(str, limit)}\u2026`;
2590
+ }
2591
+ return "";
2592
+ };
2593
+ var hyphenate = (str) => typeof str === "string" ? str.split(" ").join("-") : "";
2594
+ var isString = (value) => typeof value === "string";
2595
+ var lowercase = (str) => {
2596
+ if (typeof str === "object" && str !== null && "fn" in str && typeof str.fn === "function") {
2597
+ return String(str.fn()).toLowerCase();
2598
+ }
2599
+ if (typeof str !== "string") return "";
2600
+ return str.toLowerCase();
2601
+ };
2602
+ var downcase = (str) => lowercase(str);
2603
+ var occurrences = (str, substring) => {
2604
+ if (typeof str !== "string") return "";
2605
+ const len = substring.length;
2606
+ let pos = str.indexOf(substring, 0);
2607
+ let n = 0;
2608
+ while (pos > -1) {
2609
+ n++;
2610
+ pos = str.indexOf(substring, pos + len);
2611
+ }
2612
+ return n;
2613
+ };
2614
+ var pascalcase = (str) => {
2615
+ if (typeof str !== "string") return "";
2616
+ const res = changecase(str, (ch) => ch.toUpperCase());
2617
+ return res.charAt(0).toUpperCase() + res.slice(1);
2618
+ };
2619
+ var pathcase = (str) => typeof str === "string" ? changecase(str, (ch) => `/${ch}`) : "";
2620
+ var plusify = (str, ch) => {
2621
+ if (typeof str !== "string") return "";
2622
+ if (typeof ch !== "string") ch = " ";
2623
+ return str.split(ch).join("+");
2624
+ };
2625
+ var prepend = (str, prefix) => {
2626
+ return typeof str === "string" && typeof prefix === "string" ? prefix + str : str;
2627
+ };
2628
+ var remove = (str, ch) => {
2629
+ if (typeof str !== "string") return "";
2630
+ if (typeof ch !== "string") return str;
2631
+ return str.split(ch).join("");
2632
+ };
2633
+ var removeFirst = (str, ch) => {
2634
+ if (typeof str !== "string") return "";
2635
+ if (typeof ch !== "string") return str;
2636
+ return str.replace(ch, "");
2637
+ };
2638
+ var replace = (str, a, b) => {
2639
+ if (typeof str !== "string") return "";
2640
+ if (typeof a !== "string") return str;
2641
+ if (typeof b !== "string") b = "";
2642
+ return str.split(a).join(b);
2643
+ };
2644
+ var replaceFirst = (str, a, b) => {
2645
+ if (typeof str !== "string") return "";
2646
+ if (typeof a !== "string") return str;
2647
+ if (typeof b !== "string") b = "";
2648
+ return str.replace(a, b);
2649
+ };
2650
+ var reverse2 = (str) => typeof str === "string" ? str.split("").reverse().join("") : "";
2651
+ var sentence = (str) => {
2652
+ if (typeof str !== "string") return "";
2653
+ return str.replace(
2654
+ /((?:\S[^.?!]*)[.?!]*)/g,
2655
+ (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase()
2656
+ );
2657
+ };
2658
+ var snakecase = (str) => typeof str === "string" ? changecase(str, (ch) => `_${ch}`) : "";
2659
+ var trim = (str) => typeof str === "string" ? str.trim() : "";
2660
+ var trimLeft = (str) => typeof str === "string" ? str.replace(/^\s+/, "") : "";
2661
+ var trimRight = (str) => typeof str === "string" ? str.replace(/\s+$/, "") : "";
2662
+ var truncateWords = (str, count, suffix) => {
2663
+ if (typeof str === "string" && typeof count === "number" && Number.isFinite(count)) {
2664
+ if (typeof suffix !== "string") {
2665
+ suffix = "...";
2666
+ }
2667
+ const num = Math.trunc(count);
2668
+ let arr = str.split(" ");
2669
+ if (num < arr.length) {
2670
+ arr = arr.slice(0, num);
2671
+ }
2672
+ const val = arr.join(" ").trim();
2673
+ return val + suffix;
2674
+ }
2675
+ return "";
2676
+ };
2677
+ var truncateWordsAlias = truncateWords;
2678
+ var uppercase = (str) => {
2679
+ if (typeof str === "object" && str !== null && "fn" in str && typeof str.fn === "function") {
2680
+ return String(str.fn()).toUpperCase();
2681
+ }
2682
+ if (typeof str !== "string") return "";
2683
+ return str.toUpperCase();
2684
+ };
2685
+ var upcase = (str) => uppercase(str);
2686
+ var split = (str, character) => {
2687
+ if (typeof str !== "string") return "";
2688
+ if (typeof character !== "string") character = "";
2689
+ return str.split(character);
2690
+ };
2691
+ var startsWith = (prefix, testString, _options) => {
2692
+ if (typeof prefix !== "string" || typeof testString !== "string") {
2693
+ return false;
2694
+ }
2695
+ return testString.startsWith(prefix);
2696
+ };
2697
+ var titleize = (str) => {
2698
+ if (typeof str !== "string") return "";
2699
+ return str.replace(/\w\S*/g, (word) => {
2700
+ return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
2701
+ });
2702
+ };
2703
+ var raw = (options2) => {
2704
+ if (options2 && typeof options2.fn === "function") {
2705
+ return options2.fn();
2706
+ }
2707
+ return "";
2708
+ };
2709
+ var helpers19 = [
2710
+ {
2711
+ name: "append",
2712
+ category: "string",
2713
+ compatibility: ["browser", "nodejs"],
2714
+ fn: append
2715
+ },
2716
+ {
2717
+ name: "camelcase",
2718
+ category: "string",
2719
+ compatibility: ["browser", "nodejs"],
2720
+ fn: camelcase
2721
+ },
2722
+ {
2723
+ name: "capitalize",
2724
+ category: "string",
2725
+ compatibility: ["browser", "nodejs"],
2726
+ fn: capitalize
2727
+ },
2728
+ {
2729
+ name: "capitalizeAll",
2730
+ category: "string",
2731
+ compatibility: ["browser", "nodejs"],
2732
+ fn: capitalizeAll
2733
+ },
2734
+ {
2735
+ name: "center",
2736
+ category: "string",
2737
+ compatibility: ["browser", "nodejs"],
2738
+ fn: center
2739
+ },
2740
+ {
2741
+ name: "chop",
2742
+ category: "string",
2743
+ compatibility: ["browser", "nodejs"],
2744
+ fn: chopStr
2745
+ },
2746
+ {
2747
+ name: "dashcase",
2748
+ category: "string",
2749
+ compatibility: ["browser", "nodejs"],
2750
+ fn: dashcase
2751
+ },
2752
+ {
2753
+ name: "dotcase",
2754
+ category: "string",
2755
+ compatibility: ["browser", "nodejs"],
2756
+ fn: dotcase
2757
+ },
2758
+ {
2759
+ name: "ellipsis",
2760
+ category: "string",
2761
+ compatibility: ["browser", "nodejs"],
2762
+ fn: ellipsis
2763
+ },
2764
+ {
2765
+ name: "hyphenate",
2766
+ category: "string",
2767
+ compatibility: ["browser", "nodejs"],
2768
+ fn: hyphenate
2769
+ },
2770
+ {
2771
+ name: "isString",
2772
+ category: "string",
2773
+ compatibility: ["browser", "nodejs"],
2774
+ fn: isString
2775
+ },
2776
+ {
2777
+ name: "lowercase",
2778
+ category: "string",
2779
+ compatibility: ["browser", "nodejs"],
2780
+ fn: lowercase
2781
+ },
2782
+ {
2783
+ name: "downcase",
2784
+ category: "string",
2785
+ compatibility: ["browser", "nodejs"],
2786
+ fn: downcase
2787
+ },
2788
+ {
2789
+ name: "occurrences",
2790
+ category: "string",
2791
+ compatibility: ["browser", "nodejs"],
2792
+ fn: occurrences
2793
+ },
2794
+ {
2795
+ name: "pascalcase",
2796
+ category: "string",
2797
+ compatibility: ["browser", "nodejs"],
2798
+ fn: pascalcase
2799
+ },
2800
+ {
2801
+ name: "pathcase",
2802
+ category: "string",
2803
+ compatibility: ["browser", "nodejs"],
2804
+ fn: pathcase
2805
+ },
2806
+ {
2807
+ name: "plusify",
2808
+ category: "string",
2809
+ compatibility: ["browser", "nodejs"],
2810
+ fn: plusify
2811
+ },
2812
+ {
2813
+ name: "prepend",
2814
+ category: "string",
2815
+ compatibility: ["browser", "nodejs"],
2816
+ fn: prepend
2817
+ },
2818
+ {
2819
+ name: "remove",
2820
+ category: "string",
2821
+ compatibility: ["browser", "nodejs"],
2822
+ fn: remove
2823
+ },
2824
+ {
2825
+ name: "removeFirst",
2826
+ category: "string",
2827
+ compatibility: ["browser", "nodejs"],
2828
+ fn: removeFirst
2829
+ },
2830
+ {
2831
+ name: "replace",
2832
+ category: "string",
2833
+ compatibility: ["browser", "nodejs"],
2834
+ fn: replace
2835
+ },
2836
+ {
2837
+ name: "replaceFirst",
2838
+ category: "string",
2839
+ compatibility: ["browser", "nodejs"],
2840
+ fn: replaceFirst
2841
+ },
2842
+ {
2843
+ name: "reverse",
2844
+ category: "string",
2845
+ compatibility: ["browser", "nodejs"],
2846
+ fn: reverse2
2847
+ },
2848
+ {
2849
+ name: "sentence",
2850
+ category: "string",
2851
+ compatibility: ["browser", "nodejs"],
2852
+ fn: sentence
2853
+ },
2854
+ {
2855
+ name: "snakecase",
2856
+ category: "string",
2857
+ compatibility: ["browser", "nodejs"],
2858
+ fn: snakecase
2859
+ },
2860
+ {
2861
+ name: "trim",
2862
+ category: "string",
2863
+ compatibility: ["browser", "nodejs"],
2864
+ fn: trim
2865
+ },
2866
+ {
2867
+ name: "trimLeft",
2868
+ category: "string",
2869
+ compatibility: ["browser", "nodejs"],
2870
+ fn: trimLeft
2871
+ },
2872
+ {
2873
+ name: "trimRight",
2874
+ category: "string",
2875
+ compatibility: ["browser", "nodejs"],
2876
+ fn: trimRight
2877
+ },
2878
+ {
2879
+ name: "truncate",
2880
+ category: "string",
2881
+ compatibility: ["browser", "nodejs"],
2882
+ fn: truncate
2883
+ },
2884
+ {
2885
+ name: "truncateWords",
2886
+ category: "string",
2887
+ compatibility: ["browser", "nodejs"],
2888
+ fn: truncateWordsAlias
2889
+ },
2890
+ {
2891
+ name: "uppercase",
2892
+ category: "string",
2893
+ compatibility: ["browser", "nodejs"],
2894
+ fn: uppercase
2895
+ },
2896
+ {
2897
+ name: "upcase",
2898
+ category: "string",
2899
+ compatibility: ["browser", "nodejs"],
2900
+ fn: upcase
2901
+ },
2902
+ {
2903
+ name: "split",
2904
+ category: "string",
2905
+ compatibility: ["browser", "nodejs"],
2906
+ fn: split
2907
+ },
2908
+ {
2909
+ name: "startsWith",
2910
+ category: "string",
2911
+ compatibility: ["browser", "nodejs"],
2912
+ fn: startsWith
2913
+ },
2914
+ {
2915
+ name: "titleize",
2916
+ category: "string",
2917
+ compatibility: ["browser", "nodejs"],
2918
+ fn: titleize
2919
+ },
2920
+ {
2921
+ name: "raw",
2922
+ category: "string",
2923
+ compatibility: ["browser", "nodejs"],
2924
+ fn: raw
2925
+ }
2926
+ ];
2927
+
2928
+ // src/helpers/url.ts
2929
+ var import_node_querystring = require("querystring");
2930
+ var import_node_url = require("url");
2931
+ var all = ["browser", "nodejs"];
2932
+ var encodeUri = (str) => {
2933
+ if (typeof str === "string") {
2934
+ return encodeURIComponent(str);
2935
+ }
2936
+ };
2937
+ var escapeFn = (str) => {
2938
+ if (typeof str === "string") {
2939
+ return (0, import_node_querystring.escape)(str);
2940
+ }
2941
+ };
2942
+ var decodeUri = (str) => {
2943
+ if (typeof str === "string") {
2944
+ return decodeURIComponent(str);
2945
+ }
2946
+ };
2947
+ function urlEncode(...args) {
2948
+ return encodeUri.apply(this, args);
2949
+ }
2950
+ function urlDecode(...args) {
2951
+ return decodeUri.apply(this, args);
2952
+ }
2953
+ var urlResolve = (base, href) => (0, import_node_url.resolve)(String(base), String(href));
2954
+ var urlParse = (str) => (0, import_node_url.parse)(String(str));
2955
+ var stripQuerystring = (str) => {
2956
+ if (typeof str === "string") {
2957
+ return str.split("?")[0];
2958
+ }
2959
+ };
2960
+ var stripProtocol = (str) => {
2961
+ if (typeof str === "string") {
2962
+ const parsed = (0, import_node_url.parse)(str);
2963
+ parsed.protocol = "";
2964
+ return (0, import_node_url.format)(parsed);
2965
+ }
2966
+ };
2967
+ var helpers20 = [
2968
+ {
2969
+ name: "encodeURI",
2970
+ category: "url",
2971
+ compatibility: all,
2972
+ fn: encodeUri
2973
+ },
2974
+ {
2975
+ name: "escape",
2976
+ category: "url",
2977
+ compatibility: ["nodejs"],
2978
+ fn: escapeFn
2979
+ },
2980
+ {
2981
+ name: "decodeURI",
2982
+ category: "url",
2983
+ compatibility: all,
2984
+ fn: decodeUri
2985
+ },
2986
+ {
2987
+ name: "url_encode",
2988
+ category: "url",
2989
+ compatibility: all,
2990
+ fn: urlEncode
2991
+ },
2992
+ {
2993
+ name: "url_decode",
2994
+ category: "url",
2995
+ compatibility: all,
2996
+ fn: urlDecode
2997
+ },
2998
+ {
2999
+ name: "urlResolve",
3000
+ category: "url",
3001
+ compatibility: ["nodejs"],
3002
+ fn: urlResolve
3003
+ },
3004
+ {
3005
+ name: "urlParse",
3006
+ category: "url",
3007
+ compatibility: ["nodejs"],
3008
+ fn: urlParse
3009
+ },
3010
+ {
3011
+ name: "stripQuerystring",
3012
+ category: "url",
3013
+ compatibility: all,
3014
+ fn: stripQuerystring
3015
+ },
3016
+ {
3017
+ name: "stripProtocol",
3018
+ category: "url",
3019
+ compatibility: ["nodejs"],
3020
+ fn: stripProtocol
3021
+ }
3022
+ ];
3023
+
3024
+ // src/helper-registry.ts
3025
+ var HelperRegistry = class {
3026
+ _helpers = [];
3027
+ constructor() {
3028
+ this.init();
3029
+ }
3030
+ /**
3031
+ * Get all registered helpers.
3032
+ * @returns {Helper[]} The array of registered helpers.
3033
+ */
3034
+ get helpers() {
3035
+ return this._helpers;
3036
+ }
3037
+ /**
3038
+ * Initialize the helper registry. This is performed during the construction of the registry such as new HelperRegistry().
3039
+ */
3040
+ init() {
3041
+ this.registerHelpers(helpers);
3042
+ this.registerHelpers(helpers3);
3043
+ this.registerHelpers(helpers5);
3044
+ this.registerHelpers(helpers6);
3045
+ this.registerHelpers(helpers2);
3046
+ this.registerHelpers(helpers13);
3047
+ this.registerHelpers(helpers7);
3048
+ this.registerHelpers(helpers4);
3049
+ this.registerHelpers(helpers8);
3050
+ this.registerHelpers(helpers9);
3051
+ this.registerHelpers(helpers10);
3052
+ this.registerHelpers(helpers11);
3053
+ this.registerHelpers(helpers12);
3054
+ this.registerHelpers(helpers14);
3055
+ this.registerHelpers(helpers15);
3056
+ this.registerHelpers(helpers17);
3057
+ this.registerHelpers(helpers18);
3058
+ this.registerHelpers(helpers19);
3059
+ this.registerHelpers(helpers20);
3060
+ this.registerHelpers(helpers16);
3061
+ }
3062
+ /**
3063
+ * Register a helper.
3064
+ * @param {Helper} helper The helper to register.
3065
+ * @returns True if the helper was registered, false otherwise.
3066
+ */
3067
+ register(helper) {
3068
+ const result = false;
3069
+ if (!this.has(helper.name)) {
3070
+ this._helpers.push(helper);
3071
+ }
3072
+ return result;
3073
+ }
3074
+ /**
3075
+ * Register multiple helpers.
3076
+ * @param {Helper[]} helpers The array of helpers to register.
3077
+ */
3078
+ registerHelpers(helpers22) {
3079
+ for (const helper of helpers22) {
3080
+ this.register(helper);
3081
+ }
3082
+ }
3083
+ /**
3084
+ * Check if a helper is registered.
3085
+ * @param name The name of the helper.
3086
+ * @returns True if the helper is registered, false otherwise.
3087
+ */
3088
+ has(name) {
3089
+ return this._helpers.some((helper) => helper.name === name);
3090
+ }
3091
+ /**
3092
+ * Filter helpers by the given criteria.
3093
+ * @param filter The filter criteria.
3094
+ * @returns The filtered helpers.
3095
+ */
3096
+ filter(filter2) {
3097
+ let result = this._helpers;
3098
+ if (filter2.names) {
3099
+ result = result.filter((helper) => filter2.names?.includes(helper.name));
3100
+ }
3101
+ if (filter2.categories) {
3102
+ result = result.filter(
3103
+ (helper) => filter2.categories?.includes(helper.category)
3104
+ );
3105
+ }
3106
+ if (filter2.compatibility) {
3107
+ result = result.filter(
3108
+ (helper) => helper.compatibility?.some((c) => filter2.compatibility?.includes(c))
3109
+ );
3110
+ }
3111
+ return result;
3112
+ }
3113
+ /**
3114
+ * Load Handlebars helpers.
3115
+ * @param {Handlebars} handlebars The Handlebars instance.
3116
+ * @returns {void}
3117
+ */
3118
+ load(handlebars2, filters) {
3119
+ let helpers22 = this._helpers;
3120
+ if (filters) {
3121
+ helpers22 = this.filter(filters);
3122
+ }
3123
+ for (const helper of helpers22) {
3124
+ handlebars2.registerHelper(helper.name, helper.fn);
3125
+ }
3126
+ }
3127
+ /**
3128
+ * Swap Handlebars helpers. This is used when you want to swap out legacy helpers for fumanchu helpers.
3129
+ * @param handlebars The Handlebars instance.
3130
+ * @returns {void}
3131
+ */
3132
+ swap(handlebars2) {
3133
+ for (const helper of this._helpers) {
3134
+ handlebars2.unregisterHelper(helper.name);
3135
+ handlebars2.registerHelper(helper.name, helper.fn);
3136
+ }
3137
+ }
3138
+ };
3139
+
3140
+ // src/index.ts
3141
+ var Handlebars3 = import_handlebars3.default;
3142
+ var handlebars = import_handlebars3.default.create();
3143
+ function helpers21(options2) {
3144
+ const registry = new HelperRegistry();
3145
+ registry.load(options2.handlebars ?? options2.hbs);
3146
+ }
3147
+ async function createHandlebars() {
3148
+ const registry = new HelperRegistry();
3149
+ const handlebars2 = import_handlebars3.default.create();
3150
+ if (Object.keys(import_handlebars3.default.partials).length > 0) {
3151
+ handlebars2.registerPartial(import_handlebars3.default.partials);
3152
+ }
3153
+ registry.load(handlebars2);
3154
+ if (process.env.NODE_ENV === "development") {
3155
+ console.warn(
3156
+ "createHandlebars will be deprecated in future versions, use `fumanchu` instead."
3157
+ );
3158
+ }
3159
+ return handlebars2;
3160
+ }
3161
+ function fumanchu(options2) {
3162
+ const registry = new HelperRegistry();
3163
+ let handlebars2 = import_handlebars3.default.create();
3164
+ if (options2?.handlebars) {
3165
+ handlebars2 = options2.handlebars;
3166
+ } else if (Object.keys(import_handlebars3.default.partials).length > 0) {
3167
+ handlebars2.registerPartial(import_handlebars3.default.partials);
3168
+ }
3169
+ registry.load(handlebars2);
3170
+ return handlebars2;
3171
+ }
3172
+ // Annotate the CommonJS export names for ESM import in node:
3173
+ 0 && (module.exports = {
3174
+ Handlebars,
3175
+ HelperRegistry,
3176
+ createHandlebars,
3177
+ fumanchu,
3178
+ handlebars,
3179
+ helpers
3180
+ });
3181
+ /* v8 ignore next -- @preserve */
3182
+ /* c8 ignore next -- @preserve */