@homedev/objector 1.2.42 → 1.2.44

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.
Files changed (2) hide show
  1. package/dist/index.js +12 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,13 +1,14 @@
1
- var Mr=Object.create;var{getPrototypeOf:jr,defineProperty:U,getOwnPropertyNames:ae}=Object;var le=Object.prototype.hasOwnProperty,M=(e,r,t)=>{for(let o of ae(r))if(!le.call(e,o)&&o!=="default")U(e,o,{get:()=>r[o],enumerable:!0});if(t){for(let o of ae(r))if(!le.call(t,o)&&o!=="default")U(t,o,{get:()=>r[o],enumerable:!0});return t}},Nr=(e,r,t)=>{t=e!=null?Mr(jr(e)):{};let o=r||!e||!e.__esModule?U(t,"default",{value:e,enumerable:!0}):t;for(let i of ae(e))if(!le.call(o,i))U(o,i,{get:()=>e[i],enumerable:!0});return o};var Wr=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var W=(e,r)=>{for(var t in r)U(e,t,{get:r[t],enumerable:!0,configurable:!0,set:(o)=>r[t]=()=>o})};var _r=Wr((ri,Fr)=>{var{defineProperty:Ee,getOwnPropertyNames:Ot,getOwnPropertyDescriptor:At}=Object,$t=Object.prototype.hasOwnProperty,$r=new WeakMap,St=(e)=>{var r=$r.get(e),t;if(r)return r;if(r=Ee({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function")Ot(e).map((o)=>!$t.call(r,o)&&Ee(r,o,{get:()=>e[o],enumerable:!(t=At(e,o))||t.enumerable}));return $r.set(e,r),r},Ft=(e,r)=>{for(var t in r)Ee(e,t,{get:r[t],enumerable:!0,configurable:!0,set:(o)=>r[t]=()=>o})},Sr={};Ft(Sr,{splitWithQuotes:()=>Mt,splitNested:()=>_t});Fr.exports=St(Sr);var _t=(e,r,t="(",o=")")=>{let i=0,n="",a=[];for(let s of e){if(n+=s,s===t)i++;if(s===o)i--;if(i===0&&s===r)a.push(n.slice(0,-1)),n=""}if(n)a.push(n);return a},Mt=(e,r=",")=>{let t=[],o=e.length,i=r.length,n=0,a=(s)=>{if(s+i>o)return!1;for(let u=0;u<i;u++)if(e[s+u]!==r[u])return!1;return!0};while(n<o){while(n<o&&e[n]===" ")n++;if(n>=o)break;let s="",u=e[n]==='"'||e[n]==="'";if(u){let m=e[n++];while(n<o&&e[n]!==m)s+=e[n++];if(n<o)n++}else{while(n<o&&!a(n)){let m=e[n];if(m==='"'||m==="'"){s+=m,n++;while(n<o&&e[n]!==m)s+=e[n++];if(n<o)s+=e[n++]}else s+=e[n++]}s=s.trim()}if(s)t.push({value:s,quoted:u});if(a(n))n+=i}return t}});var We={};W(We,{processFields:()=>$,makeFieldProcessorMap:()=>F,makeFieldProcessorList:()=>Ne,makeFieldProcessor:()=>z,getProcessor:()=>q,getArgs:()=>pe});var Cr=Object.create,{getPrototypeOf:Rr,defineProperty:Oe,getOwnPropertyNames:xr}=Object,Lr=Object.prototype.hasOwnProperty,Ir=(e,r,t)=>{t=e!=null?Cr(Rr(e)):{};let o=r||!e||!e.__esModule?Oe(t,"default",{value:e,enumerable:!0}):t;for(let i of xr(e))if(!Lr.call(o,i))Oe(o,i,{get:()=>e[i],enumerable:!0});return o},Ur=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Dr=Ur((e,r)=>{var{defineProperty:t,getOwnPropertyNames:o,getOwnPropertyDescriptor:i}=Object,n=Object.prototype.hasOwnProperty,a=new WeakMap,s=(l)=>{var c=a.get(l),b;if(c)return c;if(c=t({},"__esModule",{value:!0}),l&&typeof l==="object"||typeof l==="function")o(l).map((p)=>!n.call(c,p)&&t(c,p,{get:()=>l[p],enumerable:!(b=i(l,p))||b.enumerable}));return a.set(l,c),c},u=(l,c)=>{for(var b in c)t(l,b,{get:c[b],enumerable:!0,configurable:!0,set:(p)=>c[b]=()=>p})},m={};u(m,{splitWithQuotes:()=>g,splitNested:()=>y}),r.exports=s(m);var y=(l,c,b="(",p=")")=>{let d=0,f="",k=[];for(let w of l){if(f+=w,w===b)d++;if(w===p)d--;if(d===0&&w===c)k.push(f.slice(0,-1)),f=""}if(f)k.push(f);return k},g=(l,c=",")=>{let b=[],p=l.length,d=c.length,f=0,k=(w)=>{if(w+d>p)return!1;for(let E=0;E<d;E++)if(l[w+E]!==c[E])return!1;return!0};while(f<p){while(f<p&&l[f]===" ")f++;if(f>=p)break;let w="",E=l[f]==='"'||l[f]==="'";if(E){let A=l[f++];while(f<p&&l[f]!==A)w+=l[f++];if(f<p)f++}else{while(f<p&&!k(f)){let A=l[f];if(A==='"'||A==="'"){w+=A,f++;while(f<p&&l[f]!==A)w+=l[f++];if(f<p)w+=l[f++]}else w+=l[f++]}w=w.trim()}if(w)b.push({value:w,quoted:E});if(k(f))f+=d}return b}}),Br=Ir(Dr(),1),H;((e)=>{e[e.Explore=0]="Explore",e[e.SkipSiblings=1]="SkipSiblings",e[e.NoExplore=2]="NoExplore",e[e.ReplaceParent=3]="ReplaceParent",e[e.DeleteParent=4]="DeleteParent",e[e.MergeParent=5]="MergeParent",e[e.ReplaceItem=6]="ReplaceItem",e[e.DeleteItem=7]="DeleteItem"})(H||={});class O{action;by;skipSiblings;reexplore;constructor(e,r,t,o){this.action=e,this.by=r,this.skipSiblings=t,this.reexplore=o}static _explore=new O(0);static _noExplore=new O(2);static _skipSiblings=new O(1);static _deleteParent=new O(4);static ReplaceParent(e,r){return new O(3,e,void 0,r)}static SkipSiblings(){return O._skipSiblings}static Explore(){return O._explore}static NoExplore(){return O._noExplore}static DeleteParent(){return O._deleteParent}static MergeParent(e){return new O(5,e)}static ReplaceItem(e,r){return new O(6,e,r)}static DeleteItem(e){return new O(7,void 0,e)}}var Jr=async(e,r)=>{let t=new WeakSet,o=[],i=[],n=async(s,u,m)=>{let y=s===null,g=y?O.Explore():await r({key:s,value:u,path:o,parent:m,parents:i});if(u&&typeof u==="object"&&g.action===0){if(t.has(u))return g;if(t.add(u),!y)o.push(s),i.push(m);let l=u;while(await a(l,s,m))l=m[s];if(!y)i.pop(),o.pop()}return g},a=async(s,u,m)=>{let y=Object.keys(s),g=y.length;for(let l=0;l<g;l++){let c=y[l],b=s[c],p=await n(c,b,s),d=p.action;if(d===0||d===2)continue;if(d===6){if(s[c]=p.by,p.skipSiblings)return;continue}if(d===7){if(delete s[c],p.skipSiblings)return;continue}if(d===1)return;if(d===3){if(u===null)throw Error("Cannot replace root object");if(m[u]=p.by,p.reexplore)return!0;return}if(d===4){if(u===null)throw Error("Cannot delete root object");delete m[u];return}if(d===5)delete s[c],Object.assign(s,p.by)}};await n(null,e,null)},Yr=Object.create,{getPrototypeOf:Tr,defineProperty:Ae,getOwnPropertyNames:Qr}=Object,Gr=Object.prototype.hasOwnProperty,Kr=(e,r,t)=>{t=e!=null?Yr(Tr(e)):{};let o=r||!e||!e.__esModule?Ae(t,"default",{value:e,enumerable:!0}):t;for(let i of Qr(e))if(!Gr.call(o,i))Ae(o,i,{get:()=>e[i],enumerable:!0});return o},Zr=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Vr=Zr((e,r)=>{var{defineProperty:t,getOwnPropertyNames:o,getOwnPropertyDescriptor:i}=Object,n=Object.prototype.hasOwnProperty,a=new WeakMap,s=(l)=>{var c=a.get(l),b;if(c)return c;if(c=t({},"__esModule",{value:!0}),l&&typeof l==="object"||typeof l==="function")o(l).map((p)=>!n.call(c,p)&&t(c,p,{get:()=>l[p],enumerable:!(b=i(l,p))||b.enumerable}));return a.set(l,c),c},u=(l,c)=>{for(var b in c)t(l,b,{get:c[b],enumerable:!0,configurable:!0,set:(p)=>c[b]=()=>p})},m={};u(m,{splitWithQuotes:()=>g,splitNested:()=>y}),r.exports=s(m);var y=(l,c,b="(",p=")")=>{let d=0,f="",k=[];for(let w of l){if(f+=w,w===b)d++;if(w===p)d--;if(d===0&&w===c)k.push(f.slice(0,-1)),f=""}if(f)k.push(f);return k},g=(l,c=",")=>{let b=[],p=l.length,d=c.length,f=0,k=(w)=>{if(w+d>p)return!1;for(let E=0;E<d;E++)if(l[w+E]!==c[E])return!1;return!0};while(f<p){while(f<p&&l[f]===" ")f++;if(f>=p)break;let w="",E=l[f]==='"'||l[f]==="'";if(E){let A=l[f++];while(f<p&&l[f]!==A)w+=l[f++];if(f<p)f++}else{while(f<p&&!k(f)){let A=l[f];if(A==='"'||A==="'"){w+=A,f++;while(f<p&&l[f]!==A)w+=l[f++];if(f<p)w+=l[f++]}else w+=l[f++]}w=w.trim()}if(w)b.push({value:w,quoted:E});if(k(f))f+=d}return b}}),Xr=Kr(Vr(),1),Hr=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,qr=/^([^[\]]*)\[([^\]]*)]$/,ue=(e,r,t,o)=>{if(e.startsWith("{")&&e.endsWith("}")){let i=e.substring(1,e.length-1);return D(r,i,t)?.toString()}return o?e:void 0},zr=(e,r,t,o)=>{let i=ue(r,t,o);if(i)return D(e,i,o);let n=Hr.exec(r);if(n){let[,s,u,m]=n,y=ue(s.trim(),t,o,!0),g=ue(m.trim(),t,o,!0);if(Array.isArray(e)&&(u==="="||u==="==")&&y)return e.find((l)=>l?.[y]==g)}let a=qr.exec(r);if(a){let[,s,u]=a;return e?.[s]?.[u]}return e?.[r]},D=(e,r,t)=>{let o=void 0,i=void 0,n=r??"",a=(g)=>{if(!g)return[g,!1];return g.endsWith("?")?[g.substring(0,g.length-1),!0]:[g,!1]},s=(g,l)=>{let[c,b]=a(l.pop());if(!c){if(t?.set!==void 0&&i!==void 0&&o!==void 0)o[i]=t.set;return g}let p=zr(g,c,e,t);if(p===void 0){if(b||t?.optional||t?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${c}" in "${n}"`)}return o=g,i=c,s(p,l)},u=Xr.splitNested(n,t?.separator??".","{","}"),m=void 0;if(u.length>0&&u[u.length-1].startsWith("?="))m=u.pop()?.substring(2);u.reverse();let y=s(e,u);if(y===void 0)return m??t?.defaultValue;return y},$e=(e,r)=>{if(typeof e.value==="string"){if(e.quoted)return e.value;if(e.value.startsWith("[")&&e.value.endsWith("]")){let t=e.value.slice(1,-1);if(t.trim()==="")return[];return t.split(";").map((o)=>{let i=o.trim();if(!isNaN(+i))return+i;return i})}if(e.value.startsWith("{")&&e.value.endsWith("}")){if(e.value.slice(1,-1).trim()==="")return{}}if(e.value==="null")return null;if(e.value==="undefined")return;if(e.value.startsWith("@"))return e.value.slice(1);if(!isNaN(+e.value))return+e.value}return r(e.value)},X=(e,r,t,o,i,n)=>{let a=o?.(e)??e,s=i(a);if(s[0])return s[1];if(!r){let u=D(t,e),m=i(u);if(m[0])return m[1]}throw Error(n)},Se=(e,r,t,o,i)=>{let n=typeof e.types==="function"?e.types(o,r.value,i):e.types?.[o];if(!n||n==="ref")return $e(r,(s)=>D(t,s));let a=$e(r,()=>r.value);if(Array.isArray(n)){if(!n.includes(a))throw Error(`Argument ${o.toString()} must be one of [${n.join(", ")}]: ${a}`);return a}if(typeof n==="string"){if(n.endsWith("?")){let s=n.slice(0,-1);if(r.value==="null")return O.ReplaceItem(null);if(r.value==="undefined")return O.ReplaceItem(void 0);if(r.value==="")return"";n=s}switch(n){case"any":return a;case"array":return X(a,r.quoted,t,null,(s)=>[Array.isArray(s),s],`Argument ${o.toString()} must be an array: ${a}`);case"object":return X(a,r.quoted,t,null,(s)=>[typeof s==="object"&&s!==null,s],`Argument ${o.toString()} must be an object: ${a}`);case"number":return X(a,r.quoted,t,(s)=>Number(s),(s)=>[!isNaN(s),s],`Argument ${o.toString()} must be a number: ${a}`);case"boolean":return X(a,r.quoted,t,null,(s)=>{if([!0,"true","1",1,"yes","on"].includes(s))return[!0,!0];if([!1,"false","0",0,"no","off"].includes(s))return[!0,!1];if([null,"null","undefined",void 0,""].includes(s))return[!0,!1];if(Array.isArray(s))return[!0,s.length>0];return[!1,!1]},`Argument ${o.toString()} must be a boolean: ${a}`);case"string":return a.toString();default:throw Error(`Unknown type for argument ${o.toString()}: ${n}`)}}return n(a,t,o,r.quoted)},q=(e,r)=>{let t=e?.[r];if(t===void 0)throw Error(`Unhandled field processor type: ${r}`);return typeof t==="function"?{options:{},fn:t}:{options:t,fn:t.fn}},Fe=(e)=>!e.quoted&&e.value.startsWith("."),Pr=(e)=>{let r={};for(let t of e){if(!Fe(t))continue;let o=t.value.indexOf("="),i=o>-1?t.value.slice(1,o):t.value.slice(1),n=o>-1?t.value.slice(o+1):"";if(n.length>=2){let a=n[0],s=n[n.length-1];if(a==='"'&&s==='"'||a==="'"&&s==="'")n=n.slice(1,-1)}if(!r[i])r[i]=[];r[i].push(n)}return r},pe=(e,r,t)=>{let o=Br.splitWithQuotes(e??""),i=Pr(o),n=o.filter((s)=>!Fe(s)),a=r.options.processArgs===!1?[]:n.map((s,u)=>Se(r.options,s,t,u,n));return{rawArgs:n,parsedArgs:a,tags:i}},et=(e)=>{return e!==null&&typeof e==="object"&&"action"in e},rt=(e,r)=>r.keys!==void 0&&e.key.startsWith(".")&&r.keys[e.key.substring(1)]!==void 0,tt=async(e,r,t,o)=>{let{key:i,parent:n}=e,a=q(o.keys,i.substring(1));if(a.options.processArgs!==!1&&(typeof a.options.types==="function"||a.options.types?.[0]!==void 0))e.value=Se(a.options,{value:e.value,quoted:!1},t,0,[]);if(typeof e.value!=="string")await $(e.value,{...o,root:{...t,parent:e.parent,parents:e.parents},filters:[...o.filters??[],...a.options.filters??[]]});let s=await a.fn({path:r,root:t,parent:n,key:i,options:o,value:e.value,args:[],rawArgs:[],tags:{}});return et(s)?s:O.ReplaceParent(s)},_e=(e)=>{let r=[],t=0;while(t<e.length)if(e[t]==="$"&&e[t+1]==="("&&(t===0||e[t-1]!=="\\")){let o=t;t+=2;let i=1;for(;t<e.length;t++)if(e[t]==="(")i++;else if(e[t]===")"){if(i--,i===0){r.push([o,t]);break}}if(i!==0)throw Error(`Unmatched opening $( at position ${o.toString()}`);t++}else t++;return r},fe=Symbol.for("@homedev/fields:OverrideResult"),ot=(e)=>({[fe]:!0,value:e}),nt=(e)=>{return e!==null&&typeof e==="object"&&fe in e&&e[fe]===!0},Me=async(e,r,t)=>{for(let o=r.length-1;o>=0;o--){let[i,n]=r[o],a=e.slice(i+2,n),s=await Me(a,_e(a),t);if(typeof s==="object")return s;let u=await t(s,e);if(nt(u))return u.value;e=e.slice(0,i)+u+e.slice(n+1)}return e},it=async(e,r)=>Me(e,_e(e),r),st=(e)=>{return e!==null&&typeof e==="object"&&"action"in e},at=async(e,r,t,o)=>{let i=await(async()=>{let n=/([\w\d.-_/]+):(.+)/.exec(e);if(!n)return await D(r,e);let[a,s,u]=n,m=q(o.sources,s),y=pe(u,m,r);return await m.fn({args:y.parsedArgs,rawArgs:y.rawArgs,tags:y.tags,key:s,options:o,root:r,path:t,value:null})})();if(i===null||i===void 0)return"";if(typeof i==="object")return ot(i);return i},lt=(e)=>{let r=/{%\s*section\s+([\w\d_-]+)\s*%}([\s\S]*?){%\s*endsection\s+\1\s*%}/g,t,o=[],i=[];while((t=r.exec(e))!==null){let[a,s,u]=t;i.push({fullMatch:a,name:s,body:u})}let n=e;for(let{fullMatch:a,name:s,body:u}of i){let m={},y=u.trim(),g=y.indexOf("---");if(g!==-1){let l=y.slice(0,g).trim();y=y.slice(g+3).trim();try{m=Bun.YAML.parse(l)??{}}catch(c){throw Error(`Failed to parse YAML config for section ${s}: ${c.message}`)}}o.push({name:s,config:m,content:y}),n=n.replace(a,"")}return{sections:o,content:n.trim()}},je=async(e,r,t,o)=>{let i=o?.onSection?lt(r):null,n=r;if(i){n=i.content;for(let s of i.sections){if(Object.keys(s.config).length>0)await $(s.config,o);let u=await o.onSection(s,e,t,o);if(u===!0)n=n+s.content;else if(typeof u==="string")n=n+u}}let a=await it(n,(s)=>at(s,t,e,o));if(st(a))return a;if(a===n){if(i?.sections.length)return O.ReplaceItem(a);return O.Explore()}if(typeof a==="string"){let s=await je(e,a,t,o);if(s.action!==H.Explore)return s}return O.ReplaceItem(a)},$=async(e,r)=>{return r??={},await Jr(e,async(t)=>{let o=[...t.path,t.key].join(".");if(r?.filters?.length&&r.filters.some((s)=>s.test(o)))return O.NoExplore();let i=t.path.length===0,n=t.parents.length>0?t.parents.toReversed():[];if(i){if(n.length>0)throw Error("Root object should not have a parent");n=r?.root?.parents?[r.root.parent,...r.root.parents.toReversed()]:[]}let a={...e,...r.root,this:t.parent,parent:n.length>0?n[0]:null,parents:n};try{if(t.key.startsWith("$"))return O.NoExplore();let s=O.Explore();if(typeof t.value==="string")switch(s=await je(o,t.value,a,r),s.action){case H.Explore:break;case H.ReplaceItem:t.value=s.by;break;default:return s}if(rt(t,r))s=await tt(t,o,a,r);return s}catch(s){throw Error(`${s.message}
2
- (${o})`)}}),e},z=(e,r)=>r?{fn:(t)=>e(...t.args),types:r}:(t)=>e(...t.args),Ne=(e,r)=>Object.fromEntries(e.map((t)=>[t.name,z(t,r?.types?.[t.name])])),F=(e,r)=>Object.fromEntries((r?.keys??Object.keys(e)).map((t)=>[t,z(e[t],r?.types?.[t])]));var Be={};W(Be,{writeOutputs:()=>re,writeOutput:()=>ye,writeFormat:()=>me,locate:()=>R,loadFormat:()=>P,importList:()=>ge,importGlob:()=>De,globMap:()=>ee,exists:()=>B});import Ce from"fs/promises";import ce from"path";import ut from"path";import ft from"fs/promises";import Ie from"fs/promises";import Re from"path";import xe from"path";import Le from"path";var B=async(e)=>{try{return await Ce.access(e,Ce.constants.R_OK),!0}catch{return!1}},R=async(e,r)=>{let t=!ce.isAbsolute(e)&&r?["",...r]:[""];for(let o of t){let i=ce.join(o,e);if(await B(i))return ce.resolve(i)}throw Error(`File not found: "${e}"`)},P=async(e,r)=>{let t=await R(e,r?.dirs),o=await Bun.file(t).text(),i=ut.dirname(t),n={"[.]json$":JSON.parse,"[.](yml|yaml)$":Bun.YAML.parse,"[.]toml$":Bun.TOML.parse,...r?.parsers},a=Object.entries(n).find((s)=>t.match(s[0]));if(!a)throw Error(`Unhandled file type: ${e}`);return{content:a[1](o),fullPath:t,folderPath:i}},me=async(e,r,t="text")=>{switch(t){case"yaml":await Bun.write(e,Bun.YAML.stringify(r));break;case"json":await Bun.write(e,JSON.stringify(r));break;case"text":default:await Bun.write(e,r.toString())}},ee=async(e,r)=>{if(typeof e==="string"&&!e.includes("*"))return await r.map(e,0,[]);let t=await Array.fromAsync(ft.glob(e,{cwd:r.cwd})),o=r.filter?t.filter(r.filter):t;return await Promise.all(o.map(r.map))},re=async(e,r)=>{if(r?.targetDirectory&&r?.removeFirst)try{await Ie.rm(r?.targetDirectory,{recursive:!0,force:!0})}catch(t){throw Error(`Failed to clean the output directory: ${t.message}`)}for(let t of e)await ye(t,r)},ye=async(e,r)=>{let t=Re.join(r?.targetDirectory??".",e.name),o=Re.dirname(t);if(r?.classes){if(e.class!==void 0&&!r.classes.includes(e.class))return;if(r.classRequired&&e.class===void 0)throw Error(`Output "${e.name}" is missing class field`)}if(r?.writing?.(e)===!1)return;try{await Ie.mkdir(o,{recursive:!0})}catch(i){throw Error(`Failed to create target directory "${o}" for output "${t}": ${i.message}`)}try{await me(t,e.value,e.type??"text")}catch(i){throw Error(`Failed to write output "${t}": ${i.message}`)}},Ue=(e)=>e?Le.isAbsolute(e)?e:Le.join(process.cwd(),e):process.cwd(),ge=async(e,r)=>{let t=[];for(let o of e)try{let i=!xe.isAbsolute(o)?xe.join(Ue(r?.cwd),o):o;if(r?.filter?.(i)===!1)continue;let n=await import(i);if(r?.resolveDefault==="only"&&!n.default)throw Error(`Module ${o} does not have a default export`);let a=r?.resolveDefault?n.default??n:n,s=r?.map?await r.map(a,o):a;if(s!==void 0)t.push(s)}catch(i){if(r?.fail?.(o,i)===!1)continue;throw Error(`Failed to import module ${o}: ${i.message??i}`)}return t},De=async(e,r)=>{let t=[];for(let o of e){let i=await Array.fromAsync(new Bun.Glob(o).scan({cwd:Ue(r?.cwd),absolute:!0}));t.push(...await ge(i,r))}return t};var Ke={};W(Ke,{toObjectWithKey:()=>Je,toObject:()=>te,toList:()=>x,sortBy:()=>Qe,nonNullMap:()=>Ye,defined:()=>Te,deepClone:()=>j,asyncMap:()=>Ge});var x=(e,r="name")=>Object.entries(e).map(([t,o])=>({[r]:t,...o})),Je=(e,r="name")=>Object.fromEntries(e.map((t)=>[t[r],t])),te=(e,r="name")=>Object.fromEntries(e.map((t)=>{let{[r]:o,...i}=t;return[o,i]})),Ye=(e,r)=>{if(!e)return[];let t=[],o=0;for(let i of e)if(i!==null&&i!==void 0)t.push(r(i,o,e)),o++;return t},Te=(e,r="Value is undefined")=>{if(e===void 0)throw Error(r);return e},Qe=(e,r,t=(o,i)=>o-i)=>e.slice().sort((o,i)=>t(r(o),r(i))),Ge=async(e,r)=>Promise.all(e.map(r)),j=(e)=>{if(typeof structuredClone<"u")try{return structuredClone(e)}catch{}return JSON.parse(JSON.stringify(e))};var Ve={};W(Ve,{navigate:()=>de,find:()=>Ze,NavigateResult:()=>h,NavigateAction:()=>we});var we;((e)=>{e[e.Explore=0]="Explore",e[e.SkipSiblings=1]="SkipSiblings",e[e.NoExplore=2]="NoExplore",e[e.ReplaceParent=3]="ReplaceParent",e[e.DeleteParent=4]="DeleteParent",e[e.MergeParent=5]="MergeParent",e[e.ReplaceItem=6]="ReplaceItem",e[e.DeleteItem=7]="DeleteItem"})(we||={});class h{action;by;skipSiblings;reexplore;constructor(e,r,t,o){this.action=e,this.by=r,this.skipSiblings=t,this.reexplore=o}static _explore=new h(0);static _noExplore=new h(2);static _skipSiblings=new h(1);static _deleteParent=new h(4);static ReplaceParent(e,r){return new h(3,e,void 0,r)}static SkipSiblings(){return h._skipSiblings}static Explore(){return h._explore}static NoExplore(){return h._noExplore}static DeleteParent(){return h._deleteParent}static MergeParent(e){return new h(5,e)}static ReplaceItem(e,r){return new h(6,e,r)}static DeleteItem(e){return new h(7,void 0,e)}}var de=async(e,r)=>{let t=new WeakSet,o=[],i=[],n=async(s,u,m)=>{let y=s===null,g=y?h.Explore():await r({key:s,value:u,path:o,parent:m,parents:i});if(u&&typeof u==="object"&&g.action===0){if(t.has(u))return g;if(t.add(u),!y)o.push(s),i.push(m);let l=u;while(await a(l,s,m))l=m[s];if(!y)i.pop(),o.pop()}return g},a=async(s,u,m)=>{let y=Object.keys(s),g=y.length;for(let l=0;l<g;l++){let c=y[l],b=s[c],p=await n(c,b,s),d=p.action;if(d===0||d===2)continue;if(d===6){if(s[c]=p.by,p.skipSiblings)return;continue}if(d===7){if(delete s[c],p.skipSiblings)return;continue}if(d===1)return;if(d===3){if(u===null)throw Error("Cannot replace root object");if(m[u]=p.by,p.reexplore)return!0;return}if(d===4){if(u===null)throw Error("Cannot delete root object");delete m[u];return}if(d===5)delete s[c],Object.assign(s,p.by)}};await n(null,e,null)},Ze=async(e,r)=>{let t=[];return await de(e,(o)=>{if(r([...o.path,o.key].join("."),o.value))t.push(o.value);return h.Explore()}),t};var Xe=(e)=>({output:(r)=>{delete r.parent[r.key];for(let t of Array.isArray(r.value)?r.value:[r.value])if(typeof t==="string")e.output({name:t,value:r.parent});else e.output({...t,value:t.value??r.parent});return h.SkipSiblings()}});import pt from"path";var He=(e)=>({load:async(r)=>{let t=r.options.globalContext;for(let{file:o}of Array.isArray(r.value)?r.value:[r.value]){if(!o)throw Error("File reference required");await e.load(o,t.file&&pt.dirname(t.file))}return h.DeleteItem()}});var qe={};W(qe,{mergeAll:()=>J,merge:()=>N});var N=(e,r,t)=>{for(let o of Object.keys(r)){if(e[o]===void 0)continue;let i=r[o],n=e[o];if(typeof n!==typeof i||Array.isArray(n)!==Array.isArray(i)){let s=t?.mismatch?.(o,n,i,e,r);if(s!==void 0){r[o]=s;continue}throw Error(`Type mismatch: ${o}`)}let a=t?.mode?.(o,n,i,e,r)??r[".merge"]??"merge";switch(a){case"source":r[o]=n;continue;case"target":continue;case"skip":delete r[o],delete e[o];continue;case"merge":break;default:throw Error(`Unknown merge mode: ${a}`)}if(typeof n==="object")if(Array.isArray(n))i.push(...n);else{if(t?.navigate?.(o,n,i,e,r)===!1)continue;N(n,i,t)}else{if(n===i)continue;let s=t?.conflict?.(o,n,i,e,r);r[o]=s===void 0?i:s}}for(let o of Object.keys(e))if(r[o]===void 0)r[o]=e[o]},J=(e,r)=>{let t={};for(let o of e.toReversed())N(o,t,r);return t};class be{cache=new Map;maxSize;constructor(e=100){this.maxSize=e}get(e){return this.cache.get(e)}set(e,r){this.evictIfNeeded(),this.cache.set(e,r)}has(e){return this.cache.has(e)}clear(){this.cache.clear()}setMaxSize(e){this.maxSize=e}size(){return this.cache.size}evictIfNeeded(){if(this.cache.size>=this.maxSize){let e=null,r=1/0;for(let[t,o]of this.cache.entries())if(o.timestamp<r)r=o.timestamp,e=t;if(e)this.cache.delete(e)}}}var Pe={};W(Pe,{select:()=>v});var ct=Object.create,{getPrototypeOf:mt,defineProperty:ze,getOwnPropertyNames:yt}=Object,gt=Object.prototype.hasOwnProperty,wt=(e,r,t)=>{t=e!=null?ct(mt(e)):{};let o=r||!e||!e.__esModule?ze(t,"default",{value:e,enumerable:!0}):t;for(let i of yt(e))if(!gt.call(o,i))ze(o,i,{get:()=>e[i],enumerable:!0});return o},dt=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),bt=dt((e,r)=>{var{defineProperty:t,getOwnPropertyNames:o,getOwnPropertyDescriptor:i}=Object,n=Object.prototype.hasOwnProperty,a=new WeakMap,s=(l)=>{var c=a.get(l),b;if(c)return c;if(c=t({},"__esModule",{value:!0}),l&&typeof l==="object"||typeof l==="function")o(l).map((p)=>!n.call(c,p)&&t(c,p,{get:()=>l[p],enumerable:!(b=i(l,p))||b.enumerable}));return a.set(l,c),c},u=(l,c)=>{for(var b in c)t(l,b,{get:c[b],enumerable:!0,configurable:!0,set:(p)=>c[b]=()=>p})},m={};u(m,{splitWithQuotes:()=>g,splitNested:()=>y}),r.exports=s(m);var y=(l,c,b="(",p=")")=>{let d=0,f="",k=[];for(let w of l){if(f+=w,w===b)d++;if(w===p)d--;if(d===0&&w===c)k.push(f.slice(0,-1)),f=""}if(f)k.push(f);return k},g=(l,c=",")=>{let b=[],p=l.length,d=c.length,f=0,k=(w)=>{if(w+d>p)return!1;for(let E=0;E<d;E++)if(l[w+E]!==c[E])return!1;return!0};while(f<p){while(f<p&&l[f]===" ")f++;if(f>=p)break;let w="",E=l[f]==='"'||l[f]==="'";if(E){let A=l[f++];while(f<p&&l[f]!==A)w+=l[f++];if(f<p)f++}else{while(f<p&&!k(f)){let A=l[f];if(A==='"'||A==="'"){w+=A,f++;while(f<p&&l[f]!==A)w+=l[f++];if(f<p)w+=l[f++]}else w+=l[f++]}w=w.trim()}if(w)b.push({value:w,quoted:E});if(k(f))f+=d}return b}}),ht=wt(bt(),1),vt=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,kt=/^([^[\]]*)\[([^\]]*)]$/,he=(e,r,t,o)=>{if(e.startsWith("{")&&e.endsWith("}")){let i=e.substring(1,e.length-1);return v(r,i,t)?.toString()}return o?e:void 0},Et=(e,r,t,o)=>{let i=he(r,t,o);if(i)return v(e,i,o);let n=vt.exec(r);if(n){let[,s,u,m]=n,y=he(s.trim(),t,o,!0),g=he(m.trim(),t,o,!0);if(Array.isArray(e)&&(u==="="||u==="==")&&y)return e.find((l)=>l?.[y]==g)}let a=kt.exec(r);if(a){let[,s,u]=a;return e?.[s]?.[u]}return e?.[r]},v=(e,r,t)=>{let o=void 0,i=void 0,n=r??"",a=(g)=>{if(!g)return[g,!1];return g.endsWith("?")?[g.substring(0,g.length-1),!0]:[g,!1]},s=(g,l)=>{let[c,b]=a(l.pop());if(!c){if(t?.set!==void 0&&i!==void 0&&o!==void 0)o[i]=t.set;return g}let p=Et(g,c,e,t);if(p===void 0){if(b||t?.optional||t?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${c}" in "${n}"`)}return o=g,i=c,s(p,l)},u=ht.splitNested(n,t?.separator??".","{","}"),m=void 0;if(u.length>0&&u[u.length-1].startsWith("?="))m=u.pop()?.substring(2);u.reverse();let y=s(e,u);if(y===void 0)return m??t?.defaultValue;return y};var er=(e)=>{if(typeof e.value==="string")return e.parent;let r=e.value.model;if(!r)return e.parent;if(typeof r==="string")return v(e.root,r);return r};var rr=(e)=>{if(typeof e.value==="string")return v(e.root,e.value);if(Array.isArray(e.value))return e.value;let r=e.value;if(typeof r.from==="string")return v(e.root,r.from);return r.from};var tr=async(e,r)=>{let t=e.value;if(t.selector===void 0)return r;if(typeof t.selector!=="string"){let o=JSON.parse(JSON.stringify(t.selector));return await $(o,{...e.options,root:{...e.root,result:r}}),o}return await v({...e.root,result:r},t.selector)};import L from"path";class I{constructor(){}static normalize(e){return L.normalize(L.resolve(e))}static resolveInContext(e,r){let t=r??process.cwd(),o=L.isAbsolute(e)?e:L.join(t,e);return this.normalize(o)}static isDirectoryPattern(e){return e.endsWith("/")}static isGlobPattern(e){return e.includes("*")}static toAbsolute(e,r){if(L.isAbsolute(e))return e;return L.join(r??process.cwd(),e)}}var or={};W(or,{conditionPredicatesTypes:()=>Y,conditionPredicates:()=>_});var _={and:(...e)=>e.every((r)=>!!r),or:(...e)=>e.some((r)=>!!r),xor:(...e)=>e.filter((r)=>!!r).length===1,true:(...e)=>e.every((r)=>!!r),false:(...e)=>e.every((r)=>!r),eq:(...e)=>e.every((r)=>r===e[0]),ne:(...e)=>e.some((r)=>r!==e[0]),lt:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]<r),le:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]<=r),gt:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]>r),ge:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]>=r),in:(e,r)=>{if(Array.isArray(r))return r.includes(e);if(typeof e==="string")return e.includes(r);if(Array.isArray(e))return e.includes(r);return!1},notin:(e,r)=>!_.in(e,r),contains:(e,r)=>e.includes(r),notcontains:(e,r)=>!e.includes(r),containsi:(e,r)=>e.toLowerCase().includes(r.toLowerCase()),notcontainsi:(e,r)=>!e.toLowerCase().includes(r.toLowerCase()),null:(...e)=>e.every((r)=>r===null||r===void 0),notnull:(...e)=>e.every((r)=>r!==null&&r!==void 0),empty:(...e)=>e.every((r)=>r===""),notempty:(...e)=>e.every((r)=>r!==""),nullorempty:(...e)=>e.every((r)=>r===null||r===void 0||r===""),notnullorempty:(...e)=>e.every((r)=>r!==null&&r!==void 0&&r!=="")},Y={and:()=>"boolean",or:()=>"boolean",xor:()=>"boolean",true:()=>"boolean",false:()=>"boolean",lt:()=>"number",le:()=>"number",gt:()=>"number",ge:()=>"number"};var nr=()=>({each:{filters:[/select|model/],fn:async(e)=>{let r=e.value;delete e.parent[e.key];let t=await rr(e),o=await er(e);if(!Array.isArray(t))throw Error('Key "each" requires a source list');if(o===void 0)throw Error('Key "each" must define a model');if(r.extend?.model)o=J([r.model,...Array.isArray(r.extend.model)?r.extend.model:[r.extend.model]]);let i=[];for(let n=0;n<t.length;n++){let a=j(o);if(await $(a,{...e.options,root:{...e.root,index:n,item:t[n],instance:a}}),r.extend?.result){let s=r.extend.result;a=J([a,...Array.isArray(s)?s:[s]])}i.push(await tr(e,a))}return i}}});var ir=()=>({concat:async(e)=>{let r=[];for(let t of Array.isArray(e.value)?e.value:[e.value])r.push(...await v(e.root,t));return r.filter((t)=>t!==void 0)}});var sr=()=>({extends:async(e)=>{let r=async(t,o)=>{for(let i of Array.isArray(o)?o:[o]){let n=await v(e.root,i),a=j(n);if(a[e.key])await r(a,a[e.key]);await $(a,{...e.options}),N(a,t),delete t[e.key]}};return await r(e.parent,e.value),h.Explore()},group:(e)=>{let r=e.root.parent,t=e.value,{items:o,...i}=t;return t.items.forEach((n)=>r.push({...i,...n})),h.DeleteParent()}});var ar=(e)=>({skip:{types:{0:"boolean"},fn:(r)=>r.value?h.DeleteParent():h.DeleteItem()},metadata:({path:r,value:t})=>{return e.metadata(r,t),h.DeleteItem()},if:{types:{0:"boolean"},fn:async(r)=>{let t=r.parent[".then"],o=r.parent[".else"];if(t!==void 0)delete r.parent[".then"];if(o!==void 0)delete r.parent[".else"];let i=r.value?t:o;if(i===void 0)return h.DeleteItem();if(typeof i==="string")return(await $({value:i},{...r.options,root:{...r.root}})).value;return h.ReplaceParent(i,!0)}},switch:(r)=>{let t=r.value;if(!t.cases)throw Error("Missing cases for switch");if(t.cases[t.from]!==void 0)return h.ReplaceParent(t.cases[t.from],!0);if(t.default!==void 0)return h.ReplaceParent(t.default,!0);return h.DeleteParent()}});var lr=()=>({from:async({root:e,parent:r,value:t})=>{let o=await v(e,t);if(o===null||o===void 0)throw Error(`Unable to resolve reference: ${t}`);if(r.content){if(Array.isArray(r.content)&&Array.isArray(o))return[...o,...r.content];return N(o,r.content),r.content}return o}});import ur from"node:vm";var fr=(e)=>({modules:async(r)=>{for(let[t,o]of Object.entries(r.value)){let i=ur.createContext({console,objector:e,document:r.root}),n=new ur.SourceTextModule(o,{identifier:t,context:i});await n.link((a)=>{throw Error(`Module ${a} is not allowed`)}),await n.evaluate(),e.sources(Object.fromEntries(Object.entries(n.namespace).map(([a,s])=>[`${t}.${a}`,(u)=>s(u,...u.args)])))}return h.DeleteItem()}});import pr from"fs/promises";import T from"path";var cr=(e)=>({include:async(r)=>{let{file:t}=r.options.globalContext;return await ee(r.args[0],{cwd:T.dirname(t),filter:(o)=>T.basename(t)!==o,map:async(o)=>e.load(o,T.dirname(t),{parent:r.root})})},exists:async({args:[r]})=>await B(r),file:async(r)=>await pr.readFile(await R(r.args[0],e.getIncludeDirectories())).then((t)=>t.toString()),scan:async(r)=>{let t=[],i=(()=>{let s=r.args[2]??["**/node_modules/**"],u=typeof s==="string"?s.split(",").map((m)=>m.trim()):s;if(!Array.isArray(u))throw Error("Scan exclusion must be a list");return u})(),{file:n}=r.options.globalContext,a=r.args[1]?await R(r.args[1],e.getIncludeDirectories()):T.dirname(n);for await(let s of pr.glob(r.args[0],{cwd:a,exclude:(u)=>i.some((m)=>T.matchesGlob(u,m))}))t.push(s);return t}});var mr=()=>F({env:(e)=>process.env[e]});var gr={};W(gr,{tokenize:()=>yr,snake:()=>G,pascal:()=>Q,padBlock:()=>C,changeCase:()=>K,capital:()=>oe,camel:()=>ne});var Q=(e)=>e.replace(/((?:[_ ]+)\w|^\w)/g,(r,t)=>t.toUpperCase()).replace(/[_ ]/g,""),oe=(e)=>e.replace(/((?:[ ]+)\w|^\w)/g,(r,t)=>t.toUpperCase()),ne=(e)=>{let r=Q(e);return r.charAt(0).toLowerCase()+r.slice(1)},G=(e,r="_")=>e.replace(/([a-z])([A-Z])/g,`$1${r}$2`).replace(/\s+/g,r).toLowerCase(),K=(e,r)=>{switch(r){case"upper":return e.toUpperCase();case"lower":return e.toLowerCase();default:return e}},C=(e,r,t=`
3
- `,o=" ")=>{let i=o.repeat(r);return e.split(t).map((n)=>i+n).join(t)},yr=(e,r,t=/\${([^}]+)}/g)=>{return e.replace(t,(o,i)=>{let n=r[i];if(n===null||n===void 0)return"";if(typeof n==="string")return n;if(typeof n==="number"||typeof n==="boolean")return String(n);return String(n)})};var ie=(e,r=0,t)=>{let o=" ".repeat(r),i=" ".repeat(r+1);if(e===null||e===void 0)return"null";else if(typeof e==="boolean")return String(e);else if(typeof e==="number")return String(e);else if(typeof e==="string")return`"${e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`;else if(Array.isArray(e)){if(e.length===0)return"[]";return`[
4
- ${e.map((a)=>`${i}${ie(a,r+1)},`).join(`
1
+ var Tr=Object.create;var{getPrototypeOf:Jr,defineProperty:U,getOwnPropertyNames:pe}=Object;var ce=Object.prototype.hasOwnProperty,_=(e,r,t)=>{for(let n of pe(r))if(!ce.call(e,n)&&n!=="default")U(e,n,{get:()=>r[n],enumerable:!0});if(t){for(let n of pe(r))if(!ce.call(t,n)&&n!=="default")U(t,n,{get:()=>r[n],enumerable:!0});return t}},Qr=(e,r,t)=>{t=e!=null?Tr(Jr(e)):{};let n=r||!e||!e.__esModule?U(t,"default",{value:e,enumerable:!0}):t;for(let o of pe(e))if(!ce.call(n,o))U(n,o,{get:()=>e[o],enumerable:!0});return n};var Xr=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var N=(e,r)=>{for(var t in r)U(e,t,{get:r[t],enumerable:!0,configurable:!0,set:(n)=>r[t]=()=>n})};var Yr=Xr((zs,Br)=>{var{defineProperty:Se,getOwnPropertyNames:Tt,getOwnPropertyDescriptor:Jt}=Object,Qt=Object.prototype.hasOwnProperty,Ir=new WeakMap,Xt=(e)=>{var r=Ir.get(e),t;if(r)return r;if(r=Se({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function")Tt(e).map((n)=>!Qt.call(r,n)&&Se(r,n,{get:()=>e[n],enumerable:!(t=Jt(e,n))||t.enumerable}));return Ir.set(e,r),r},Gt=(e,r)=>{for(var t in r)Se(e,t,{get:r[t],enumerable:!0,configurable:!0,set:(n)=>r[t]=()=>n})},Ur={};Gt(Ur,{splitWithQuotes:()=>Zt,splitNested:()=>Kt});Br.exports=Xt(Ur);var Kt=(e,r,t="(",n=")")=>{let o=0,s="",i=[];for(let a of e){if(s+=a,a===t)o++;if(a===n)o--;if(o===0&&a===r)i.push(s.slice(0,-1)),s=""}if(s)i.push(s);return i},Zt=(e,r=",")=>{let t=[],n=e.length,o=r.length,s=0,i=(a)=>{if(a+o>n)return!1;for(let u=0;u<o;u++)if(e[a+u]!==r[u])return!1;return!0};while(s<n){while(s<n&&e[s]===" ")s++;if(s>=n)break;let a="",u=e[s]==='"'||e[s]==="'";if(u){let m=e[s++];while(s<n&&e[s]!==m)a+=e[s++];if(s<n)s++}else{while(s<n&&!i(s)){let m=e[s];if(m==='"'||m==="'"){a+=m,s++;while(s<n&&e[s]!==m)a+=e[s++];if(s<n)a+=e[s++]}else a+=e[s++]}a=a.trim()}if(a)t.push({value:a,quoted:u});if(i(s))s+=o}return t}});var Le={};N(Le,{processFields:()=>O,makeFieldProcessorMap:()=>S,makeFieldProcessorList:()=>Ce,makeFieldProcessor:()=>z,getProcessor:()=>P,getArgs:()=>ye});var Gr=Object.create,{getPrototypeOf:Kr,defineProperty:je,getOwnPropertyNames:Zr}=Object,Vr=Object.prototype.hasOwnProperty,Hr=(e,r,t)=>{t=e!=null?Gr(Kr(e)):{};let n=r||!e||!e.__esModule?je(t,"default",{value:e,enumerable:!0}):t;for(let o of Zr(e))if(!Vr.call(n,o))je(n,o,{get:()=>e[o],enumerable:!0});return n},qr=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),xr=qr((e,r)=>{var{defineProperty:t,getOwnPropertyNames:n,getOwnPropertyDescriptor:o}=Object,s=Object.prototype.hasOwnProperty,i=new WeakMap,a=(l)=>{var c=i.get(l),b;if(c)return c;if(c=t({},"__esModule",{value:!0}),l&&typeof l==="object"||typeof l==="function")n(l).map((p)=>!s.call(c,p)&&t(c,p,{get:()=>l[p],enumerable:!(b=o(l,p))||b.enumerable}));return i.set(l,c),c},u=(l,c)=>{for(var b in c)t(l,b,{get:c[b],enumerable:!0,configurable:!0,set:(p)=>c[b]=()=>p})},m={};u(m,{splitWithQuotes:()=>g,splitNested:()=>y}),r.exports=a(m);var y=(l,c,b="(",p=")")=>{let w=0,f="",E=[];for(let d of l){if(f+=d,d===b)w++;if(d===p)w--;if(w===0&&d===c)E.push(f.slice(0,-1)),f=""}if(f)E.push(f);return E},g=(l,c=",")=>{let b=[],p=l.length,w=c.length,f=0,E=(d)=>{if(d+w>p)return!1;for(let A=0;A<w;A++)if(l[d+A]!==c[A])return!1;return!0};while(f<p){while(f<p&&l[f]===" ")f++;if(f>=p)break;let d="",A=l[f]==='"'||l[f]==="'";if(A){let M=l[f++];while(f<p&&l[f]!==M)d+=l[f++];if(f<p)f++}else{while(f<p&&!E(f)){let M=l[f];if(M==='"'||M==="'"){d+=M,f++;while(f<p&&l[f]!==M)d+=l[f++];if(f<p)d+=l[f++]}else d+=l[f++]}d=d.trim()}if(d)b.push({value:d,quoted:A});if(E(f))f+=w}return b}}),Pr=Hr(xr(),1),x;((e)=>{e[e.Explore=0]="Explore",e[e.SkipSiblings=1]="SkipSiblings",e[e.NoExplore=2]="NoExplore",e[e.ReplaceParent=3]="ReplaceParent",e[e.DeleteParent=4]="DeleteParent",e[e.MergeParent=5]="MergeParent",e[e.ReplaceItem=6]="ReplaceItem",e[e.DeleteItem=7]="DeleteItem"})(x||={});class k{action;by;skipSiblings;reexplore;constructor(e,r,t,n){this.action=e,this.by=r,this.skipSiblings=t,this.reexplore=n}static _explore=new k(0);static _noExplore=new k(2);static _skipSiblings=new k(1);static _deleteParent=new k(4);static ReplaceParent(e,r){return new k(3,e,void 0,r)}static SkipSiblings(){return k._skipSiblings}static Explore(){return k._explore}static NoExplore(){return k._noExplore}static DeleteParent(){return k._deleteParent}static MergeParent(e){return new k(5,e)}static ReplaceItem(e,r){return new k(6,e,r)}static DeleteItem(e){return new k(7,void 0,e)}}var zr=async(e,r)=>{let t=new WeakSet,n=[],o=[],s=async(a,u,m)=>{let y=a===null,g=y?k.Explore():await r({key:a,value:u,path:n,parent:m,parents:o});if(u&&typeof u==="object"&&g.action===0){if(t.has(u))return g;if(t.add(u),!y)n.push(a),o.push(m);let l=u;while(await i(l,a,m))l=m[a];if(!y)o.pop(),n.pop()}return g},i=async(a,u,m)=>{let y=Object.keys(a),g=y.length;for(let l=0;l<g;l++){let c=y[l],b=a[c],p=await s(c,b,a),w=p.action;if(w===0||w===2)continue;if(w===6){if(a[c]=p.by,p.skipSiblings)return;continue}if(w===7){if(delete a[c],p.skipSiblings)return;continue}if(w===1)return;if(w===3){if(u===null)throw Error("Cannot replace root object");if(m[u]=p.by,p.reexplore)return!0;return}if(w===4){if(u===null)throw Error("Cannot delete root object");delete m[u];return}if(w===5)delete a[c],Object.assign(a,p.by)}};await s(null,e,null)},et=Object.create,{getPrototypeOf:rt,defineProperty:Fe,getOwnPropertyNames:tt}=Object,nt=Object.prototype.hasOwnProperty,ot=(e,r,t)=>{t=e!=null?et(rt(e)):{};let n=r||!e||!e.__esModule?Fe(t,"default",{value:e,enumerable:!0}):t;for(let o of tt(e))if(!nt.call(n,o))Fe(n,o,{get:()=>e[o],enumerable:!0});return n},st=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),at=st((e,r)=>{var{defineProperty:t,getOwnPropertyNames:n,getOwnPropertyDescriptor:o}=Object,s=Object.prototype.hasOwnProperty,i=new WeakMap,a=(l)=>{var c=i.get(l),b;if(c)return c;if(c=t({},"__esModule",{value:!0}),l&&typeof l==="object"||typeof l==="function")n(l).map((p)=>!s.call(c,p)&&t(c,p,{get:()=>l[p],enumerable:!(b=o(l,p))||b.enumerable}));return i.set(l,c),c},u=(l,c)=>{for(var b in c)t(l,b,{get:c[b],enumerable:!0,configurable:!0,set:(p)=>c[b]=()=>p})},m={};u(m,{splitWithQuotes:()=>g,splitNested:()=>y}),r.exports=a(m);var y=(l,c,b="(",p=")")=>{let w=0,f="",E=[];for(let d of l){if(f+=d,d===b)w++;if(d===p)w--;if(w===0&&d===c)E.push(f.slice(0,-1)),f=""}if(f)E.push(f);return E},g=(l,c=",")=>{let b=[],p=l.length,w=c.length,f=0,E=(d)=>{if(d+w>p)return!1;for(let A=0;A<w;A++)if(l[d+A]!==c[A])return!1;return!0};while(f<p){while(f<p&&l[f]===" ")f++;if(f>=p)break;let d="",A=l[f]==='"'||l[f]==="'";if(A){let M=l[f++];while(f<p&&l[f]!==M)d+=l[f++];if(f<p)f++}else{while(f<p&&!E(f)){let M=l[f];if(M==='"'||M==="'"){d+=M,f++;while(f<p&&l[f]!==M)d+=l[f++];if(f<p)d+=l[f++]}else d+=l[f++]}d=d.trim()}if(d)b.push({value:d,quoted:A});if(E(f))f+=w}return b}}),it=ot(at(),1),lt=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,ut=/^([^[\]]*)\[([^\]]*)]$/,me=(e,r,t,n)=>{if(e.startsWith("{")&&e.endsWith("}")){let o=e.substring(1,e.length-1);return B(r,o,t)?.toString()}return n?e:void 0},ft=(e,r,t,n)=>{let o=me(r,t,n);if(o)return B(e,o,n);let s=lt.exec(r);if(s){let[,a,u,m]=s,y=me(a.trim(),t,n,!0),g=me(m.trim(),t,n,!0);if(Array.isArray(e)&&(u==="="||u==="==")&&y)return e.find((l)=>l?.[y]==g)}let i=ut.exec(r);if(i){let[,a,u]=i;return e?.[a]?.[u]}return e?.[r]},B=(e,r,t)=>{let n=void 0,o=void 0,s=r??"",i=(g)=>{if(!g)return[g,!1];return g.endsWith("?")?[g.substring(0,g.length-1),!0]:[g,!1]},a=(g,l)=>{let[c,b]=i(l.pop());if(!c){if(t?.set!==void 0&&o!==void 0&&n!==void 0)n[o]=t.set;return g}let p=ft(g,c,e,t);if(p===void 0){if(b||t?.optional||t?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${c}" in "${s}"`)}return n=g,o=c,a(p,l)},u=it.splitNested(s,t?.separator??".","{","}"),m=void 0;if(u.length>0&&u[u.length-1].startsWith("?="))m=u.pop()?.substring(2);u.reverse();let y=a(e,u);if(y===void 0)return m??t?.defaultValue;return y},De=(e,r)=>{if(typeof e.value==="string"){if(e.quoted)return e.value;if(e.value.startsWith("[")&&e.value.endsWith("]")){let t=e.value.slice(1,-1);if(t.trim()==="")return[];return t.split(";").map((n)=>{let o=n.trim();if(!isNaN(+o))return+o;return o})}if(e.value.startsWith("{")&&e.value.endsWith("}")){if(e.value.slice(1,-1).trim()==="")return{}}if(e.value==="null")return null;if(e.value==="undefined")return;if(e.value.startsWith("@"))return e.value.slice(1);if(!isNaN(+e.value))return+e.value}return r(e.value)},q=(e,r,t,n,o,s)=>{let i=n?.(e)??e,a=o(i);if(a[0])return a[1];if(!r){let u=B(t,e),m=o(u);if(m[0])return m[1]}throw Error(s)},_e=(e,r,t,n,o)=>{let s=typeof e.types==="function"?e.types(n,r.value,o):e.types?.[n];if(!s||s==="ref")return De(r,(a)=>B(t,a));let i=De(r,()=>r.value);if(Array.isArray(s)){if(!s.includes(i))throw Error(`Argument ${n.toString()} must be one of [${s.join(", ")}]: ${i}`);return i}if(typeof s==="string"){if(s.endsWith("?")){let a=s.slice(0,-1);if(r.value==="null")return k.ReplaceItem(null);if(r.value==="undefined")return k.ReplaceItem(void 0);if(r.value==="")return"";s=a}switch(s){case"any":return i;case"array":return q(i,r.quoted,t,null,(a)=>[Array.isArray(a),a],`Argument ${n.toString()} must be an array: ${i}`);case"object":return q(i,r.quoted,t,null,(a)=>[typeof a==="object"&&a!==null,a],`Argument ${n.toString()} must be an object: ${i}`);case"number":return q(i,r.quoted,t,(a)=>Number(a),(a)=>[!isNaN(a),a],`Argument ${n.toString()} must be a number: ${i}`);case"boolean":return q(i,r.quoted,t,null,(a)=>{if([!0,"true","1",1,"yes","on"].includes(a))return[!0,!0];if([!1,"false","0",0,"no","off"].includes(a))return[!0,!1];if([null,"null","undefined",void 0,""].includes(a))return[!0,!1];if(Array.isArray(a))return[!0,a.length>0];return[!1,!1]},`Argument ${n.toString()} must be a boolean: ${i}`);case"string":return i.toString();default:throw Error(`Unknown type for argument ${n.toString()}: ${s}`)}}return s(i,t,n,r.quoted)},P=(e,r)=>{let t=e?.[r];if(t===void 0)throw Error(`Unhandled field processor type: ${r}`);return typeof t==="function"?{options:{},fn:t}:{options:t,fn:t.fn}},Re=(e)=>!e.quoted&&e.value.startsWith("."),pt=(e)=>{let r={};for(let t of e){if(!Re(t))continue;let n=t.value.indexOf("="),o=n>-1?t.value.slice(1,n):t.value.slice(1),s=n>-1?t.value.slice(n+1):"";if(s.length>=2){let i=s[0],a=s[s.length-1];if(i==='"'&&a==='"'||i==="'"&&a==="'")s=s.slice(1,-1)}if(!r[o])r[o]=[];r[o].push(s)}return r},ye=(e,r,t)=>{let n=Pr.splitWithQuotes(e??""),o=pt(n),s=n.filter((a)=>!Re(a)),i=r.options.processArgs===!1?[]:s.map((a,u)=>_e(r.options,a,t,u,s));return{rawArgs:s,parsedArgs:i,tags:o}},ct=(e)=>{return e!==null&&typeof e==="object"&&"action"in e},mt=(e,r)=>r.keys!==void 0&&e.key.startsWith(".")&&r.keys[e.key.substring(1)]!==void 0,gt=async(e,r,t,n)=>{let{key:o,parent:s}=e,i=P(n.keys,o.substring(1));if(i.options.processArgs!==!1&&(typeof i.options.types==="function"||i.options.types?.[0]!==void 0))e.value=_e(i.options,{value:e.value,quoted:!1},t,0,[]);if(typeof e.value!=="string")await O(e.value,{...n,root:{...t,parent:e.parent,parents:e.parents},filters:[...n.filters??[],...i.options.filters??[]]});let a=await i.fn({path:r,root:t,parent:s,key:o,options:n,value:e.value,args:[],rawArgs:[],tags:{}});return ct(a)?a:k.ReplaceParent(a)},Ne=(e)=>{let r=[],t=0;while(t<e.length)if(e[t]==="$"&&e[t+1]==="("&&(t===0||e[t-1]!=="\\")){let n=t;t+=2;let o=1;for(;t<e.length;t++)if(e[t]==="(")o++;else if(e[t]===")"){if(o--,o===0){r.push([n,t]);break}}if(o!==0)throw Error(`Unmatched opening $( at position ${n.toString()}`);t++}else t++;return r},ge=Symbol.for("@homedev/fields:OverrideResult"),yt=(e)=>({[ge]:!0,value:e}),dt=(e)=>{return e!==null&&typeof e==="object"&&ge in e&&e[ge]===!0},We=async(e,r,t)=>{for(let n=r.length-1;n>=0;n--){let[o,s]=r[n],i=e.slice(o+2,s),a=await We(i,Ne(i),t);if(typeof a==="object")return a;let u=await t(a,e);if(dt(u))return u.value;e=e.slice(0,o)+u+e.slice(s+1)}return e},wt=async(e,r)=>We(e,Ne(e),r),bt=(e)=>{return e!==null&&typeof e==="object"&&"action"in e},ht=/([\w\d.-_/]+):(.+)/,vt=async(e,r,t,n)=>{let o=await(async()=>{let s=ht.exec(e);if(!s)return await B(r,e);let[i,a,u]=s,m=P(n.sources,a),y=ye(u,m,r);return await m.fn({args:y.parsedArgs,rawArgs:y.rawArgs,tags:y.tags,key:a,options:n,root:r,path:t,value:null})})();if(o===null||o===void 0)return"";if(typeof o==="object")return yt(o);return o},Et=(e)=>{let r=/{%\s*section\s+([\w\d_-]+)\s*%}([\s\S]*?){%\s*endsection\s+\1\s*%}/g,t,n=[],o=[];while((t=r.exec(e))!==null){let[a,u,m]=t,y=t.index,g=y+a.length;if(e[g]===`
2
+ `)g++;o.push({start:y,end:g,name:u,body:m})}let s=[],i=0;for(let{start:a,end:u,name:m,body:y}of o){if(a>i)s.push(e.slice(i,a));i=u;let g={},l=y.trim(),c=l.indexOf("---");if(c!==-1){let b=l.slice(0,c).trim();l=l.slice(c+3).trim();try{g=Bun.YAML.parse(b)??{}}catch(p){throw Error(`Failed to parse YAML config for section ${m}: ${p.message}`)}}n.push({name:m,config:g,content:l})}if(i<e.length)s.push(e.slice(i));return{sections:n,content:s.join("")}},$e=async(e,r,t,n)=>{let o=n?.onSection?Et(r):null,s=r;if(o){s=o.content;for(let a of o.sections){if(Object.keys(a.config).length>0)await O(a.config,n);let u=await n.onSection(a,e,t,n);if(u===!0)s=s+a.content;else if(typeof u==="string")s=s+u}}let i=await wt(s,(a)=>vt(a,t,e,n));if(bt(i))return i;if(i===s){if(o?.sections.length)return k.ReplaceItem(i);return k.Explore()}if(typeof i==="string"){let a=await $e(e,i,t,n);if(a.action!==x.Explore)return a}return k.ReplaceItem(i)},O=async(e,r)=>{return r??={},await zr(e,async(t)=>{let n=[...t.path,t.key].join(".");if(r?.filters?.length&&r.filters.some((a)=>a.test(n)))return k.NoExplore();let o=t.path.length===0,s=t.parents.length>0?t.parents.toReversed():[];if(o){if(s.length>0)throw Error("Root object should not have a parent");s=r?.root?.parents?[r.root.parent,...r.root.parents.toReversed()]:[]}let i={...e,...r.root,this:t.parent,parent:s.length>0?s[0]:null,parents:s};try{if(t.key.startsWith("$"))return k.NoExplore();let a=k.Explore();if(typeof t.value==="string")switch(a=await $e(n,t.value,i,r),a.action){case x.Explore:break;case x.ReplaceItem:t.value=a.by;break;default:return a}if(mt(t,r))a=await gt(t,n,i,r);return a}catch(a){throw Error(`${a.message}
3
+ (${n})`)}}),e},z=(e,r)=>r?{fn:(t)=>e(...t.args),types:r}:(t)=>e(...t.args),Ce=(e,r)=>Object.fromEntries(e.map((t)=>[t.name,z(t,r?.types?.[t.name])])),S=(e,r)=>Object.fromEntries((r?.keys??Object.keys(e)).map((t)=>[t,z(e[t],r?.types?.[t])]));var Xe={};N(Xe,{writeOutputs:()=>te,writeOutput:()=>be,writeFormat:()=>we,locate:()=>$,loadFormat:()=>ee,importList:()=>he,importGlob:()=>Qe,globMap:()=>re,exists:()=>Y});import Ie from"fs/promises";import de from"path";import At from"path";import kt from"fs/promises";import Te from"fs/promises";import Ue from"path";import Be from"path";import Ye from"path";var Y=async(e)=>{try{return await Ie.access(e,Ie.constants.R_OK),!0}catch{return!1}},$=async(e,r)=>{let t=!de.isAbsolute(e)&&r?["",...r]:[""];for(let n of t){let o=de.join(n,e);if(await Y(o))return de.resolve(o)}throw Error(`File not found: "${e}"`)},ee=async(e,r)=>{let t=await $(e,r?.dirs),n=await Bun.file(t).text(),o=At.dirname(t),s={"[.]json$":JSON.parse,"[.](yml|yaml)$":Bun.YAML.parse,"[.]toml$":Bun.TOML.parse,...r?.parsers},i=Object.entries(s).find((a)=>t.match(a[0]));if(!i)throw Error(`Unhandled file type: ${e}`);return{content:i[1](n),fullPath:t,folderPath:o}},we=async(e,r,t="text")=>{switch(t){case"yaml":await Bun.write(e,Bun.YAML.stringify(r));break;case"json":await Bun.write(e,JSON.stringify(r));break;case"text":default:await Bun.write(e,r.toString())}},re=async(e,r)=>{if(typeof e==="string"&&!e.includes("*"))return await r.map(e,0,[]);let t=await Array.fromAsync(kt.glob(e,{cwd:r.cwd})),n=r.filter?t.filter(r.filter):t;return await Promise.all(n.map(r.map))},te=async(e,r)=>{if(r?.targetDirectory&&r?.removeFirst)try{await Te.rm(r?.targetDirectory,{recursive:!0,force:!0})}catch(t){throw Error(`Failed to clean the output directory: ${t.message}`)}for(let t of e)await be(t,r)},be=async(e,r)=>{let t=Ue.join(r?.targetDirectory??".",e.name),n=Ue.dirname(t);if(r?.classes){if(e.class!==void 0&&!r.classes.includes(e.class))return;if(r.classRequired&&e.class===void 0)throw Error(`Output "${e.name}" is missing class field`)}if(r?.writing?.(e)===!1)return;try{await Te.mkdir(n,{recursive:!0})}catch(o){throw Error(`Failed to create target directory "${n}" for output "${t}": ${o.message}`)}try{await we(t,e.value,e.type??"text")}catch(o){throw Error(`Failed to write output "${t}": ${o.message}`)}},Je=(e)=>e?Ye.isAbsolute(e)?e:Ye.join(process.cwd(),e):process.cwd(),he=async(e,r)=>{let t=[];for(let n of e)try{let o=!Be.isAbsolute(n)?Be.join(Je(r?.cwd),n):n;if(r?.filter?.(o)===!1)continue;let s=await import(o);if(r?.resolveDefault==="only"&&!s.default)throw Error(`Module ${n} does not have a default export`);let i=r?.resolveDefault?s.default??s:s,a=r?.map?await r.map(i,n):i;if(a!==void 0)t.push(a)}catch(o){if(r?.fail?.(n,o)===!1)continue;throw Error(`Failed to import module ${n}: ${o.message??o}`)}return t},Qe=async(e,r)=>{let t=[];for(let n of e){let o=await Array.fromAsync(new Bun.Glob(n).scan({cwd:Je(r?.cwd),absolute:!0}));t.push(...await he(o,r))}return t};var qe={};N(qe,{toObjectWithKey:()=>Ge,toObject:()=>ne,toList:()=>C,sortBy:()=>Ve,nonNullMap:()=>Ke,defined:()=>Ze,deepClone:()=>F,asyncMap:()=>He});var C=(e,r="name")=>Object.entries(e).map(([t,n])=>({[r]:t,...n})),Ge=(e,r="name")=>Object.fromEntries(e.map((t)=>[t[r],t])),ne=(e,r="name")=>Object.fromEntries(e.map((t)=>{let{[r]:n,...o}=t;return[n,o]})),Ke=(e,r)=>{if(!e)return[];let t=[],n=0;for(let o of e)if(o!==null&&o!==void 0)t.push(r(o,n,e)),n++;return t},Ze=(e,r="Value is undefined")=>{if(e===void 0)throw Error(r);return e},Ve=(e,r,t=(n,o)=>n-o)=>e.slice().sort((n,o)=>t(r(n),r(o))),He=async(e,r)=>Promise.all(e.map(r)),F=(e)=>{if(typeof structuredClone<"u")try{return structuredClone(e)}catch{}return JSON.parse(JSON.stringify(e))};var Pe={};N(Pe,{navigate:()=>Ee,find:()=>xe,NavigateResult:()=>h,NavigateAction:()=>ve});var ve;((e)=>{e[e.Explore=0]="Explore",e[e.SkipSiblings=1]="SkipSiblings",e[e.NoExplore=2]="NoExplore",e[e.ReplaceParent=3]="ReplaceParent",e[e.DeleteParent=4]="DeleteParent",e[e.MergeParent=5]="MergeParent",e[e.ReplaceItem=6]="ReplaceItem",e[e.DeleteItem=7]="DeleteItem"})(ve||={});class h{action;by;skipSiblings;reexplore;constructor(e,r,t,n){this.action=e,this.by=r,this.skipSiblings=t,this.reexplore=n}static _explore=new h(0);static _noExplore=new h(2);static _skipSiblings=new h(1);static _deleteParent=new h(4);static ReplaceParent(e,r){return new h(3,e,void 0,r)}static SkipSiblings(){return h._skipSiblings}static Explore(){return h._explore}static NoExplore(){return h._noExplore}static DeleteParent(){return h._deleteParent}static MergeParent(e){return new h(5,e)}static ReplaceItem(e,r){return new h(6,e,r)}static DeleteItem(e){return new h(7,void 0,e)}}var Ee=async(e,r)=>{let t=new WeakSet,n=[],o=[],s=async(a,u,m)=>{let y=a===null,g=y?h.Explore():await r({key:a,value:u,path:n,parent:m,parents:o});if(u&&typeof u==="object"&&g.action===0){if(t.has(u))return g;if(t.add(u),!y)n.push(a),o.push(m);let l=u;while(await i(l,a,m))l=m[a];if(!y)o.pop(),n.pop()}return g},i=async(a,u,m)=>{let y=Object.keys(a),g=y.length;for(let l=0;l<g;l++){let c=y[l],b=a[c],p=await s(c,b,a),w=p.action;if(w===0||w===2)continue;if(w===6){if(a[c]=p.by,p.skipSiblings)return;continue}if(w===7){if(delete a[c],p.skipSiblings)return;continue}if(w===1)return;if(w===3){if(u===null)throw Error("Cannot replace root object");if(m[u]=p.by,p.reexplore)return!0;return}if(w===4){if(u===null)throw Error("Cannot delete root object");delete m[u];return}if(w===5)delete a[c],Object.assign(a,p.by)}};await s(null,e,null)},xe=async(e,r)=>{let t=[];return await Ee(e,(n)=>{if(r([...n.path,n.key].join("."),n.value))t.push(n.value);return h.Explore()}),t};var ze=(e)=>({output:(r)=>{delete r.parent[r.key];for(let t of Array.isArray(r.value)?r.value:[r.value])if(typeof t==="string")e.output({name:t,value:r.parent});else e.output({...t,value:t.value??r.parent});return h.SkipSiblings()}});import Mt from"path";var er=(e)=>({load:async(r)=>{let t=r.options.globalContext;for(let{file:n}of Array.isArray(r.value)?r.value:[r.value]){if(!n)throw Error("File reference required");await e.load(n,t.file&&Mt.dirname(t.file))}return h.DeleteItem()}});var rr={};N(rr,{mergeAll:()=>T,merge:()=>R});var R=(e,r,t)=>{for(let n of Object.keys(r)){if(e[n]===void 0)continue;let o=r[n],s=e[n];if(typeof s!==typeof o||Array.isArray(s)!==Array.isArray(o)){let a=t?.mismatch?.(n,s,o,e,r);if(a!==void 0){r[n]=a;continue}throw Error(`Type mismatch: ${n}`)}let i=t?.mode?.(n,s,o,e,r)??r[".merge"]??"merge";switch(i){case"source":r[n]=s;continue;case"target":continue;case"skip":delete r[n],delete e[n];continue;case"merge":break;default:throw Error(`Unknown merge mode: ${i}`)}if(typeof s==="object")if(Array.isArray(s))o.push(...s);else{if(t?.navigate?.(n,s,o,e,r)===!1)continue;R(s,o,t)}else{if(s===o)continue;let a=t?.conflict?.(n,s,o,e,r);r[n]=a===void 0?o:a}}for(let n of Object.keys(e))if(r[n]===void 0)r[n]=e[n]},T=(e,r)=>{let t={};for(let n of e.toReversed())R(n,t,r);return t};class Ae{cache=new Map;maxSize;constructor(e=100){this.maxSize=e}get(e){return this.cache.get(e)}set(e,r){this.evictIfNeeded(),this.cache.set(e,r)}has(e){return this.cache.has(e)}clear(){this.cache.clear()}setMaxSize(e){this.maxSize=e}size(){return this.cache.size}evictIfNeeded(){if(this.cache.size>=this.maxSize){let e=null,r=1/0;for(let[t,n]of this.cache.entries())if(n.timestamp<r)r=n.timestamp,e=t;if(e)this.cache.delete(e)}}}var nr={};N(nr,{select:()=>v});var Ot=Object.create,{getPrototypeOf:St,defineProperty:tr,getOwnPropertyNames:jt}=Object,Ft=Object.prototype.hasOwnProperty,Dt=(e,r,t)=>{t=e!=null?Ot(St(e)):{};let n=r||!e||!e.__esModule?tr(t,"default",{value:e,enumerable:!0}):t;for(let o of jt(e))if(!Ft.call(n,o))tr(n,o,{get:()=>e[o],enumerable:!0});return n},_t=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Rt=_t((e,r)=>{var{defineProperty:t,getOwnPropertyNames:n,getOwnPropertyDescriptor:o}=Object,s=Object.prototype.hasOwnProperty,i=new WeakMap,a=(l)=>{var c=i.get(l),b;if(c)return c;if(c=t({},"__esModule",{value:!0}),l&&typeof l==="object"||typeof l==="function")n(l).map((p)=>!s.call(c,p)&&t(c,p,{get:()=>l[p],enumerable:!(b=o(l,p))||b.enumerable}));return i.set(l,c),c},u=(l,c)=>{for(var b in c)t(l,b,{get:c[b],enumerable:!0,configurable:!0,set:(p)=>c[b]=()=>p})},m={};u(m,{splitWithQuotes:()=>g,splitNested:()=>y}),r.exports=a(m);var y=(l,c,b="(",p=")")=>{let w=0,f="",E=[];for(let d of l){if(f+=d,d===b)w++;if(d===p)w--;if(w===0&&d===c)E.push(f.slice(0,-1)),f=""}if(f)E.push(f);return E},g=(l,c=",")=>{let b=[],p=l.length,w=c.length,f=0,E=(d)=>{if(d+w>p)return!1;for(let A=0;A<w;A++)if(l[d+A]!==c[A])return!1;return!0};while(f<p){while(f<p&&l[f]===" ")f++;if(f>=p)break;let d="",A=l[f]==='"'||l[f]==="'";if(A){let M=l[f++];while(f<p&&l[f]!==M)d+=l[f++];if(f<p)f++}else{while(f<p&&!E(f)){let M=l[f];if(M==='"'||M==="'"){d+=M,f++;while(f<p&&l[f]!==M)d+=l[f++];if(f<p)d+=l[f++]}else d+=l[f++]}d=d.trim()}if(d)b.push({value:d,quoted:A});if(E(f))f+=w}return b}}),Nt=Dt(Rt(),1),Wt=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,$t=/^([^[\]]*)\[([^\]]*)]$/,ke=(e,r,t,n)=>{if(e.startsWith("{")&&e.endsWith("}")){let o=e.substring(1,e.length-1);return v(r,o,t)?.toString()}return n?e:void 0},Ct=(e,r,t,n)=>{let o=ke(r,t,n);if(o)return v(e,o,n);let s=Wt.exec(r);if(s){let[,a,u,m]=s,y=ke(a.trim(),t,n,!0),g=ke(m.trim(),t,n,!0);if(Array.isArray(e)&&(u==="="||u==="==")&&y)return e.find((l)=>l?.[y]==g)}let i=$t.exec(r);if(i){let[,a,u]=i;return e?.[a]?.[u]}return e?.[r]},v=(e,r,t)=>{let n=void 0,o=void 0,s=r??"",i=(g)=>{if(!g)return[g,!1];return g.endsWith("?")?[g.substring(0,g.length-1),!0]:[g,!1]},a=(g,l)=>{let[c,b]=i(l.pop());if(!c){if(t?.set!==void 0&&o!==void 0&&n!==void 0)n[o]=t.set;return g}let p=Ct(g,c,e,t);if(p===void 0){if(b||t?.optional||t?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${c}" in "${s}"`)}return n=g,o=c,a(p,l)},u=Nt.splitNested(s,t?.separator??".","{","}"),m=void 0;if(u.length>0&&u[u.length-1].startsWith("?="))m=u.pop()?.substring(2);u.reverse();let y=a(e,u);if(y===void 0)return m??t?.defaultValue;return y};var oe=(e)=>{if(typeof e.value==="string")return e.parent;let r=e.value.model;if(!r)return e.parent;if(typeof r==="string")return v(e.root,r);return r};var se=(e)=>{if(typeof e.value==="string")return v(e.root,e.value);if(Array.isArray(e.value))return e.value;let r=e.value;if(typeof r.from==="string")return v(e.root,r.from);return r.from};var ae=async(e,r)=>{let t=e.value;if(t.selector===void 0)return r;if(typeof t.selector!=="string"){let n=JSON.parse(JSON.stringify(t.selector));return await O(n,{...e.options,root:{...e.root,result:r}}),n}return await v({...e.root,result:r},t.selector)};import L from"path";class I{constructor(){}static normalize(e){return L.normalize(L.resolve(e))}static resolveInContext(e,r){let t=r??process.cwd(),n=L.isAbsolute(e)?e:L.join(t,e);return this.normalize(n)}static isDirectoryPattern(e){return e.endsWith("/")}static isGlobPattern(e){return e.includes("*")}static toAbsolute(e,r){if(L.isAbsolute(e))return e;return L.join(r??process.cwd(),e)}}var or={};N(or,{conditionPredicatesTypes:()=>J,conditionPredicates:()=>D});var D={and:(...e)=>e.every((r)=>!!r),or:(...e)=>e.some((r)=>!!r),xor:(...e)=>e.filter((r)=>!!r).length===1,true:(...e)=>e.every((r)=>!!r),false:(...e)=>e.every((r)=>!r),eq:(...e)=>e.every((r)=>r===e[0]),ne:(...e)=>e.some((r)=>r!==e[0]),lt:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]<r),le:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]<=r),gt:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]>r),ge:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]>=r),in:(e,r)=>{if(Array.isArray(r))return r.includes(e);if(typeof e==="string")return e.includes(r);if(Array.isArray(e))return e.includes(r);return!1},notin:(e,r)=>!D.in(e,r),contains:(e,r)=>e.includes(r),notcontains:(e,r)=>!e.includes(r),containsi:(e,r)=>e.toLowerCase().includes(r.toLowerCase()),notcontainsi:(e,r)=>!e.toLowerCase().includes(r.toLowerCase()),null:(...e)=>e.every((r)=>r===null||r===void 0),notnull:(...e)=>e.every((r)=>r!==null&&r!==void 0),empty:(...e)=>e.every((r)=>r===""),notempty:(...e)=>e.every((r)=>r!==""),nullorempty:(...e)=>e.every((r)=>r===null||r===void 0||r===""),notnullorempty:(...e)=>e.every((r)=>r!==null&&r!==void 0&&r!=="")},J={and:()=>"boolean",or:()=>"boolean",xor:()=>"boolean",true:()=>"boolean",false:()=>"boolean",lt:()=>"number",le:()=>"number",gt:()=>"number",ge:()=>"number"};var sr=()=>({each:{filters:[/select|model/],fn:async(e)=>{let r=e.value;delete e.parent[e.key];let t=await se(e),n=await oe(e);if(!Array.isArray(t))throw Error('Key "each" requires a source list');if(n===void 0)throw Error('Key "each" must define a model');if(r.extend?.model)n=T([r.model,...Array.isArray(r.extend.model)?r.extend.model:[r.extend.model]]);let o=[];for(let s=0;s<t.length;s++){let i=F(n);if(await O(i,{...e.options,root:{...e.root,index:s,item:t[s],instance:i}}),r.extend?.result){let a=r.extend.result;i=T([i,...Array.isArray(a)?a:[a]])}o.push(await ae(e,i))}return o}}});var ar=()=>({map:{filters:[/select|model/],fn:async(e)=>{delete e.parent[e.key];let r=await se(e),t=await oe(e);if(!Array.isArray(r))throw Error('Key "map" requires a source list');if(t===void 0)throw Error('Key "map" must define a model');let n=[];for(let o=0;o<r.length;o++){let s=F(t);await O(s,{...e.options,root:{...e.root,index:o,item:r[o],instance:s}}),n.push(await ae(e,s))}return n}}});var ir=()=>({concat:async(e)=>{let r=[];for(let t of Array.isArray(e.value)?e.value:[e.value])r.push(...await v(e.root,t));return r.filter((t)=>t!==void 0)}});var lr=()=>({extends:async(e)=>{let r=async(t,n)=>{for(let o of Array.isArray(n)?n:[n]){let s=await v(e.root,o),i=F(s);if(i[e.key])await r(i,i[e.key]);await O(i,{...e.options}),R(i,t),delete t[e.key]}};return await r(e.parent,e.value),h.Explore()},group:(e)=>{let r=e.root.parent,t=e.value,{items:n,...o}=t;return t.items.forEach((s)=>r.push({...o,...s})),h.DeleteParent()}});var ur=(e)=>({skip:{types:{0:"boolean"},fn:(r)=>r.value?h.DeleteParent():h.DeleteItem()},metadata:({path:r,value:t})=>{return e.metadata(r,t),h.DeleteItem()},if:{types:{0:"boolean"},fn:async(r)=>{let t=r.parent[".then"],n=r.parent[".else"];if(t!==void 0)delete r.parent[".then"];if(n!==void 0)delete r.parent[".else"];let o=r.value?t:n;if(o===void 0)return h.DeleteItem();if(typeof o==="string")return(await O({value:o},{...r.options,root:{...r.root}})).value;return h.ReplaceParent(o,!0)}},switch:(r)=>{let t=r.value;if(!t.cases)throw Error("Missing cases for switch");if(t.cases[t.from]!==void 0)return h.ReplaceParent(t.cases[t.from],!0);if(t.default!==void 0)return h.ReplaceParent(t.default,!0);return h.DeleteParent()}});var fr=()=>({from:async({root:e,parent:r,value:t})=>{let n=await v(e,t);if(n===null||n===void 0)throw Error(`Unable to resolve reference: ${t}`);if(r.content){if(Array.isArray(r.content)&&Array.isArray(n))return[...n,...r.content];return R(n,r.content),r.content}return n}});import pr from"node:vm";var cr=(e)=>({modules:async(r)=>{for(let[t,n]of Object.entries(r.value)){let o=pr.createContext({console,objector:e,document:r.root}),s=new pr.SourceTextModule(n,{identifier:t,context:o});await s.link((i)=>{throw Error(`Module ${i} is not allowed`)}),await s.evaluate(),e.sources(Object.fromEntries(Object.entries(s.namespace).map(([i,a])=>[`${t}.${i}`,(u)=>a(u,...u.args)])))}return h.DeleteItem()}});var mr=()=>({try:{fn:(e)=>{let r=e.parent[".catch"];if(r!==void 0)delete e.parent[".catch"];try{return e.value}catch(t){if(r!==void 0)return r;return h.DeleteItem()}}}});var gr=()=>({let:{fn:(e)=>{let r=e.value;return Object.assign(e.root,r),h.DeleteItem()}}});var yr=()=>({tap:{fn:(e)=>{return console.log(`[tap] ${e.path}:`,e.value),e.value}}});import dr from"fs/promises";import Q from"path";var wr=(e)=>({include:async(r)=>{let{file:t}=r.options.globalContext;return await re(r.args[0],{cwd:Q.dirname(t),filter:(n)=>Q.basename(t)!==n,map:async(n)=>e.load(n,Q.dirname(t),r.root)})},exists:async({args:[r]})=>await Y(r),file:async(r)=>await dr.readFile(await $(r.args[0],e.getIncludeDirectories())).then((t)=>t.toString()),scan:async(r)=>{let t=[],o=(()=>{let a=r.args[2]??["**/node_modules/**"],u=typeof a==="string"?a.split(",").map((m)=>m.trim()):a;if(!Array.isArray(u))throw Error("Scan exclusion must be a list");return u})(),{file:s}=r.options.globalContext,i=r.args[1]?await $(r.args[1],e.getIncludeDirectories()):Q.dirname(s);for await(let a of dr.glob(r.args[0],{cwd:i,exclude:(u)=>o.some((m)=>Q.matchesGlob(u,m))}))t.push(a);return t}});var br=()=>S({env:(e)=>process.env[e]});var vr={};N(vr,{tokenize:()=>hr,snake:()=>G,pascal:()=>X,padBlock:()=>W,changeCase:()=>K,capital:()=>ie,camel:()=>le});var X=(e)=>e.replace(/((?:[_ ]+)\w|^\w)/g,(r,t)=>t.toUpperCase()).replace(/[_ ]/g,""),ie=(e)=>e.replace(/((?:[ ]+)\w|^\w)/g,(r,t)=>t.toUpperCase()),le=(e)=>{let r=X(e);return r.charAt(0).toLowerCase()+r.slice(1)},G=(e,r="_")=>e.replace(/([a-z])([A-Z])/g,`$1${r}$2`).replace(/\s+/g,r).toLowerCase(),K=(e,r)=>{switch(r){case"upper":return e.toUpperCase();case"lower":return e.toLowerCase();default:return e}},W=(e,r,t=`
4
+ `,n=" ")=>{let o=n.repeat(r);return e.split(t).map((s)=>o+s).join(t)},hr=(e,r,t=/\${([^}]+)}/g)=>{return e.replace(t,(n,o)=>{let s=r[o];if(s===null||s===void 0)return"";if(typeof s==="string")return s;if(typeof s==="number"||typeof s==="boolean")return String(s);return String(s)})};var ue=(e,r=0,t)=>{let n=" ".repeat(r),o=" ".repeat(r+1);if(e===null||e===void 0)return"null";else if(typeof e==="boolean")return String(e);else if(typeof e==="number")return String(e);else if(typeof e==="string")return`"${e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`;else if(Array.isArray(e)){if(e.length===0)return"[]";return`[
5
+ ${e.map((i)=>`${o}${ue(i,r+1)},`).join(`
5
6
  `)}
6
- ${o}]`}else if(typeof e==="object"){let n=Object.entries(e).sort((s,u)=>t?.sortKeys?s[0].localeCompare(u[0]):0);if(n.length===0)return"{}";return`{
7
- ${n.map(([s,u])=>`${i}${s} = ${ie(u,r+1,t)}`).join(`
7
+ ${n}]`}else if(typeof e==="object"){let s=Object.entries(e).sort((a,u)=>t?.sortKeys?a[0].localeCompare(u[0]):0);if(s.length===0)return"{}";return`{
8
+ ${s.map(([a,u])=>`${o}${a} = ${ue(u,r+1,t)}`).join(`
8
9
  `)}
9
- ${o}}`}else return String(e)},Z=(e)=>{if(!e)return e;return e.replaceAll("\\n",`
10
- `).replaceAll("\\$","$").replaceAll("\\t","\t")};var wr=()=>({substring:{types:{0:"ref",1:"number",2:"number"},fn:(e)=>e.args[0].substring(e.args[1],e.args[2])},repeat:{types:{0:"ref",1:"number"},fn:({args:[e,r]})=>e.repeat(r)},uuid:(e)=>crypto.randomUUID(),pad:{types:{0:"ref",1:"number",2:"string"},fn:({args:[e,r],tags:t})=>{let o=t.join?.[0]??`
11
- `,i=t.padChar?.[0]??" ";return C(e,r??2,o,i)}},formatAs:{types:{1:["json","yaml","terraform"]},fn:({args:[e,r],tags:t})=>{switch(r){case"json":return JSON.stringify(e,null,2);case"yaml":return Bun.YAML.stringify(e,null,2);case"terraform":{let o=!!(t?.sort?.length||t?.sortKeys?.length);return ie(e,0,{sortKeys:o})}}throw Error("Unsupported format: "+String(r))}},...F({pascal:Q,camel:ne,capital:oe,fromYaml:Bun.YAML.parse,fromJson:JSON.parse,toYaml:(e,r)=>Bun.YAML.stringify(e,null,r??2),toJson:(e,r)=>JSON.stringify(e,null,r!==0?r??2:void 0),concat:(...e)=>e.join(""),len:(e)=>e.length,reverse:(e)=>e.split("").reverse().join(""),trim:(e)=>e.trim(),ltrim:(e)=>e.trimStart(),rtrim:(e)=>e.trimEnd(),lower:(e)=>e.toLowerCase(),upper:(e)=>e.toUpperCase(),snake:(e,r)=>K(G(e,"_"),r),kebab:(e,r)=>K(G(e,"-"),r),encode:(e,r)=>Buffer.from(e).toString(r??"base64"),decode:(e,r)=>Buffer.from(e,r??"base64").toString()})});var dr=()=>({...F({merge:(...e)=>e.flatMap((r)=>r)}),join:({args:[e],root:r,tags:t})=>{let o=t.key?.[0],i=t.separator?.[0]??t.sep?.[0],n=t.finalize?.length>0,a=Z(i);if(typeof e==="string"){if(n&&e.length&&a)return e+a;return e}if(!Array.isArray(e))throw Error("Object is not a list");let s=((o?.length)?e.map((g)=>v({...r,...g},o)):e).join(a),u=t.pad?.[0]??"0",m=t.padChar?.[0]??" ",y=n&&s.length&&a?s+a:s;return u?C(y,parseInt(u),`
12
- `,m):y},list:({args:e})=>x(e[0],e[1]),object:({args:e})=>te(e[0],e[1]),range:({args:[e,r,t]})=>{let o=parseInt(e),i=parseInt(r),n=parseInt(t)||1;if(isNaN(o))throw Error("Invalid range: start value '"+String(e)+"' is not a number");if(isNaN(i))throw Error("Invalid range: end value '"+String(r)+"' is not a number");if(n===0)throw Error("Invalid range: step cannot be zero");if((i-o)/n<0)throw Error("Invalid range: step "+String(n)+" has wrong direction for range "+String(o)+" to "+String(i));return Array.from({length:Math.floor((i-o)/n)+1},(a,s)=>o+s*n)},filter:{types:(e,r,t)=>{switch(e){case 0:return"array";case 1:return Object.keys(_)}return Y[t[1].value]?.(e-2,r,t.slice(2))},fn:({args:[e,r,t],root:o,tags:i})=>{if(e===null||e===void 0)throw Error("Filter source cannot be null or undefined");if(!Array.isArray(e))throw Error("Filter source must be an array");let n=i.key?.[0],a=_[r];if(n){let u=Array(e.length);for(let y=0;y<e.length;y++)try{u[y]=v({...o,...e[y]},n)}catch{u[y]=Symbol("invalid")}let m=[];for(let y=0;y<e.length;y++){let g=u[y];if(typeof g!=="symbol"&&t===void 0?a(g):a(g,t))m.push(e[y])}return m}let s=[];for(let u of e)if(t===void 0?a(u):a(u,t))s.push(u);return s}}});var br=()=>({each:{processArgs:!1,fn:async({rawArgs:[e,r,...t],root:o,options:i,tags:n})=>{let a=async(p)=>p.quoted?Z(p.value):await v(o,p.value),s=await v(o,e.value),u=await a(r),m=n.key?.[0],y=Array.isArray(s)?s:x(s),g=[],l=await Promise.all(t.map(async(p)=>await a(p))),c={...o,item:void 0,index:0,params:l,instance:void 0,parent:o.this,tags:n},b={...i,root:c};for(let p=0;p<y.length;p++){let d=j(u),f={instance:d},k=typeof u==="string"?f:d;if(c.item=y[p],c.index=p,c.instance=d,n?.root?.[0])Object.assign(c,await v(c,n.root[0]));if(await $(k,b),m!==void 0)g.push(await v(f.instance,m));else g.push(f.instance)}if(n.join?.length){if(g.length===0)return"";let p=Z(n.join[0]),d=n.pad?.[0]??"0",f=n.padChar?.[0]??" ",k=n.finalize?.length&&p?p:"",w=`${g.join(p)}${k}`;return d?C(w,parseInt(d),`
13
- `,f):w}return g}}});var V=async(e,r,t)=>e.rawArgs[r].quoted?e.rawArgs[r].value:await v(e.root,e.rawArgs[r].value,{defaultValue:t}),hr=()=>({switch:{processArgs:!1,fn:async(e)=>{let r=await V(e,0,!1),t=await V(e,1);if(t[r]===void 0){if(e.rawArgs.length>2)return V(e,2);throw Error(`Unhandled switch case: ${r}`)}return t[r]}}});var vr=()=>F({log:console.log});var kr=()=>({if:{types:{0:"boolean"},fn:(e)=>e.args[0]?e.args[1]:e.args[2]},check:{types:{0:Object.keys(_)},fn:(e)=>_[e.args[0]](...e.args.slice(1))},...F(_,{types:Y})});var Er=(e)=>({default:{processArgs:!1,fn:async(r)=>{for(let t=0;t<r.rawArgs.length;t++)if(r.rawArgs[t]?.value!==void 0){let i=await V(r,t,null);if(i!==null)return i}if(r.tags.nullable?.length)return h.DeleteItem();if(r.tags.fail?.length)throw Error(`No valid value found for default (${r.rawArgs.map((t)=>t.value).join(", ")})`);return""}},section:(r)=>{let t=r.args[0],o=e.getSection(t);if(!o)throw Error(`Section not found: ${t}`);return o.content}});var Or=()=>({convert:({args:[e,r,t]})=>{switch(r){case"string":return String(e);case"number":{let o=Number(e);if(!isNaN(o))return h.ReplaceItem(o);break}case"boolean":if(e==="true"||e===!0||e===1||e==="1"||e==="yes"||e==="on")return h.ReplaceItem(!0);else if(e==="false"||e===!1||e===0||e==="0"||e==="no"||e==="off")return h.ReplaceItem(!1);break;default:throw Error(`Unsupported type for convert: ${r}`)}if(t!==void 0)return h.ReplaceItem(t);throw Error(`Failed to convert value to ${r}`)},isType:({args:[e,r]})=>{let o=(()=>{switch(r){case"string":return typeof e==="string";case"number":return typeof e==="number";case"boolean":return typeof e==="boolean";case"object":return e!==null&&typeof e==="object"&&!Array.isArray(e);case"array":return Array.isArray(e);case"null":return e===null;case"undefined":return e===void 0;case"function":return typeof e==="function";default:throw Error(`Unknown type for isType: ${r}`)}})();return h.ReplaceItem(o)},typeOf:({args:[e]})=>{if(e===null)return"null";else if(Array.isArray(e))return"array";else return typeof e}});var Ar=(e)=>e.keys(Xe(e)).keys(He(e)).keys(nr()).keys(lr()).keys(ir()).keys(sr()).keys(ar(e)).keys(fr(e)).sources(cr(e)).sources(mr()).sources(wr()).sources(Or()).sources(dr()).sources(br()).sources(hr()).sources(vr()).sources(kr()).sources(Er(e)).fieldOptions({onSection:(r)=>{e.section(r)}});import se from"path";class ve{includeDirectories=[];baseIncludeDirectories=[];includes=[];addDirectories(...e){this.includeDirectories.push(...e),this.baseIncludeDirectories.push(...e)}getDirectories(){return this.includeDirectories}reset(){this.includeDirectories=[...this.baseIncludeDirectories]}restore(e){this.includeDirectories=[...e]}snapshot(){return[...this.includeDirectories]}addFiles(...e){this.includes.push(...e)}getPendingAndClear(){let e=[...this.includes];return this.includes.length=0,e}async processPatterns(e,r,t){let o=[];for(let i of e)if(I.isGlobPattern(i)){let n=new Bun.Glob(i);for await(let a of n.scan({cwd:r,absolute:!0}))if(!t.included.includes(a))o.push(a)}else if(I.isDirectoryPattern(i)){let n=se.isAbsolute(i)?i:se.join(r,i);if(!this.includeDirectories.includes(n))this.includeDirectories.push(n)}else o.push(i);return o}buildSearchDirs(e){let r=e?[e]:[];return r.push(...this.includeDirectories.map((t)=>se.isAbsolute(t)?t:se.join(e??process.cwd(),t))),r}}class ke{includeManager;loadFn;constructor(e,r){this.includeManager=e;this.loadFn=r}async processIncludes(e,r,t){let o=[];if(e.content.includes)o.push(...e.content.includes),delete e.content.includes;o.push(...this.includeManager.getPendingAndClear());let i=await this.includeManager.processPatterns(o,e.folderPath,t);for(let n of i)N(await this.loadFn(n,e.folderPath,{parent:e.content,...r},!0,t),e.content)}}var S={};W(S,{writeOutputs:()=>re,writeOutput:()=>ye,writeFormat:()=>me,tokenize:()=>yr,toObjectWithKey:()=>Je,toObject:()=>te,toList:()=>x,sortBy:()=>Qe,snake:()=>G,select:()=>v,processFields:()=>$,pascal:()=>Q,padBlock:()=>C,nonNullMap:()=>Ye,navigate:()=>de,mergeAll:()=>J,merge:()=>N,makeFieldProcessorMap:()=>F,makeFieldProcessorList:()=>Ne,makeFieldProcessor:()=>z,locate:()=>R,loadFormat:()=>P,importList:()=>ge,importGlob:()=>De,globMap:()=>ee,getProcessor:()=>q,getArgs:()=>pe,find:()=>Ze,exists:()=>B,defined:()=>Te,deepClone:()=>j,conditionPredicates:()=>_,changeCase:()=>K,capital:()=>oe,camel:()=>ne,asyncMap:()=>Ge,NavigateResult:()=>h,NavigateAction:()=>we});M(S,Nr(_r(),1));var Ai=S;class jt{includeManager=new ve;includeProcessor;cacheManager=new be(100);outputs=[];vars={};fields={sources:{},keys:{}};objectMetadata={};currentContext=null;sections={};constructor(){this.includeProcessor=new ke(this.includeManager,this.load.bind(this)),this.use(Ar)}use(e){return e(this),this}includeDirectory(...e){return this.includeManager.addDirectories(...e),this}getIncludeDirectories(){return this.includeManager.getDirectories()}include(...e){return this.includeManager.addFiles(...e),this}keys(e){return Object.assign(this.fields.keys,{...this.fields.keys,...e}),this}sources(e){return Object.assign(this.fields.sources,{...this.fields.sources,...e}),this}variables(e){return this.vars={...this.vars,...e},this}getOutputs(){return this.outputs}output(e){return this.outputs.push(e),this}metadata(e,r){return this.objectMetadata[e]=r,this}getMetadata(e){return this.objectMetadata[e]}getAllMetadata(){return this.objectMetadata}setCacheMaxSize(e){return this.cacheManager.setMaxSize(e),this}clearCache(){return this.cacheManager.clear(),this}getCurrentContext(){return this.currentContext}fieldOptions(e){return this.fields={...this.fields,...e},this}section(e){return this.sections[e.name]=e,this}getSection(e){return this.sections[e]}filter(e){return this.fields.filters??=[],this.fields.filters?.push(e),this}async loadObject(e,r,t){return await $(e,{...this.fields,globalContext:{file:t?.fullPath??"@internal"},root:{...r,...this.fields.root,...this.vars,context:this.currentContext,sections:this.sections,$document:{root:{content:e},fileName:t?.fileName??"@internal",folder:t?.folderPath??"@internal",fullPath:t?.fullPath??"@internal"}}}),e}async load(e,r,t,o,i){let n=this.includeManager.snapshot();try{this.includeManager.reset();let a=this.includeManager.buildSearchDirs(r);if(i)this.currentContext=i;this.currentContext??={included:[],document:null};let s=await P(e,{dirs:a}),u=I.normalize(s.fullPath);if(this.currentContext.included.push(u),!s.content)return null;let m=this.cacheManager.get(u),y;if(m)y=m.raw;else y=s.content,this.cacheManager.set(u,{raw:y,timestamp:Date.now()});let g=j(y);s.content=g,await this.includeProcessor.processIncludes(s,t,this.currentContext);let l;if(o!==!0)l=await this.loadObject(s.content,t,{fileName:s.fullPath,folderPath:s.folderPath,fullPath:s.fullPath});else l=s.content;return this.currentContext.document=l,l}catch(a){throw this.includeManager.restore(n),a}finally{this.includeManager.restore(n)}}async writeAll(e){await re(this.getOutputs(),e)}}export{Ai as default,jt as Objector};
10
+ ${n}}`}else return String(e)},Z=(e)=>{if(!e)return e;return e.replaceAll("\\n",`
11
+ `).replaceAll("\\$","$").replaceAll("\\t","\t")};var Er=()=>({substring:{types:{0:"ref",1:"number",2:"number"},fn:(e)=>e.args[0].substring(e.args[1],e.args[2])},repeat:{types:{0:"ref",1:"number"},fn:({args:[e,r]})=>e.repeat(r)},uuid:(e)=>crypto.randomUUID(),pad:{types:{0:"ref",1:"number",2:"string"},fn:({args:[e,r],tags:t})=>{let n=t.join?.[0]??`
12
+ `,o=t.padChar?.[0]??" ";return W(e,r??2,n,o)}},formatAs:{types:{1:["json","yaml","terraform"]},fn:({args:[e,r],tags:t})=>{switch(r){case"json":return JSON.stringify(e,null,2);case"yaml":return Bun.YAML.stringify(e,null,2);case"terraform":{let n=!!(t?.sort?.length||t?.sortKeys?.length);return ue(e,0,{sortKeys:n})}}throw Error("Unsupported format: "+String(r))}},...S({pascal:X,camel:le,capital:ie,fromYaml:Bun.YAML.parse,fromJson:JSON.parse,toYaml:(e,r)=>Bun.YAML.stringify(e,null,r??2),toJson:(e,r)=>JSON.stringify(e,null,r!==0?r??2:void 0),concat:(...e)=>e.join(""),len:(e)=>e.length,reverse:(e)=>e.split("").reverse().join(""),trim:(e)=>e.trim(),ltrim:(e)=>e.trimStart(),rtrim:(e)=>e.trimEnd(),lower:(e)=>e.toLowerCase(),upper:(e)=>e.toUpperCase(),snake:(e,r)=>K(G(e,"_"),r),kebab:(e,r)=>K(G(e,"-"),r),encode:(e,r)=>Buffer.from(e).toString(r??"base64"),decode:(e,r)=>Buffer.from(e,r??"base64").toString()})});var Ar=()=>({...S({merge:(...e)=>e.flatMap((r)=>r)}),join:({args:[e],root:r,tags:t})=>{let n=t.key?.[0],o=t.separator?.[0]??t.sep?.[0],s=t.finalize?.length>0,i=Z(o);if(typeof e==="string"){if(s&&e.length&&i)return e+i;return e}if(!Array.isArray(e))throw Error("Object is not a list");let a=((n?.length)?e.map((g)=>v({...r,...g},n)):e).join(i),u=t.pad?.[0]??"0",m=t.padChar?.[0]??" ",y=s&&a.length&&i?a+i:a;return u?W(y,parseInt(u),`
13
+ `,m):y},list:({args:e})=>C(e[0],e[1]),object:({args:e})=>ne(e[0],e[1]),range:({args:[e,r,t]})=>{let n=parseInt(e),o=parseInt(r),s=parseInt(t)||1;if(isNaN(n))throw Error("Invalid range: start value '"+String(e)+"' is not a number");if(isNaN(o))throw Error("Invalid range: end value '"+String(r)+"' is not a number");if(s===0)throw Error("Invalid range: step cannot be zero");if((o-n)/s<0)throw Error("Invalid range: step "+String(s)+" has wrong direction for range "+String(n)+" to "+String(o));return Array.from({length:Math.floor((o-n)/s)+1},(i,a)=>n+a*s)},filter:{types:(e,r,t)=>{switch(e){case 0:return"array";case 1:return Object.keys(D)}return J[t[1].value]?.(e-2,r,t.slice(2))},fn:({args:[e,r,t],root:n,tags:o})=>{if(e===null||e===void 0)throw Error("Filter source cannot be null or undefined");if(!Array.isArray(e))throw Error("Filter source must be an array");let s=o.key?.[0],i=D[r];if(s){let u=Array(e.length);for(let y=0;y<e.length;y++)try{u[y]=v({...n,...e[y]},s)}catch{u[y]=Symbol("invalid")}let m=[];for(let y=0;y<e.length;y++){let g=u[y];if(typeof g!=="symbol"&&t===void 0?i(g):i(g,t))m.push(e[y])}return m}let a=[];for(let u of e)if(t===void 0?i(u):i(u,t))a.push(u);return a}}});var kr=()=>({each:{processArgs:!1,fn:async({rawArgs:[e,r,...t],root:n,options:o,tags:s})=>{let i=async(p)=>p.quoted?Z(p.value):await v(n,p.value),a=await v(n,e.value),u=await i(r),m=s.key?.[0],y=Array.isArray(a)?a:C(a),g=[],l=await Promise.all(t.map(async(p)=>await i(p))),c={...n,item:void 0,index:0,params:l,instance:void 0,parent:n.this,tags:s},b={...o,root:c};for(let p=0;p<y.length;p++){let w=F(u),f={instance:w},E=typeof u==="string"?f:w;if(c.item=y[p],c.index=p,c.instance=w,s?.root?.[0])Object.assign(c,await v(c,s.root[0]));if(await O(E,b),m!==void 0)g.push(await v(f.instance,m));else g.push(f.instance)}if(s.join?.length){if(g.length===0)return"";let p=Z(s.join[0]),w=s.pad?.[0]??"0",f=s.padChar?.[0]??" ",E=s.finalize?.length&&p?p:"",d=`${g.join(p)}${E}`;return w?W(d,parseInt(w),`
14
+ `,f):d}return g}}});var V=async(e,r,t)=>e.rawArgs[r].quoted?e.rawArgs[r].value:await v(e.root,e.rawArgs[r].value,{defaultValue:t}),Mr=()=>({switch:{processArgs:!1,fn:async(e)=>{let r=await V(e,0,!1),t=await V(e,1);if(t[r]===void 0){if(e.rawArgs.length>2)return V(e,2);throw Error(`Unhandled switch case: ${r}`)}return t[r]}}});var Or=()=>S({log:console.log});var Sr=()=>({if:{types:{0:"boolean"},fn:(e)=>e.args[0]?e.args[1]:e.args[2]},check:{types:{0:Object.keys(D)},fn:(e)=>D[e.args[0]](...e.args.slice(1))},...S(D,{types:J})});var jr=(e)=>({default:{processArgs:!1,fn:async(r)=>{for(let t=0;t<r.rawArgs.length;t++)if(r.rawArgs[t]?.value!==void 0){let o=await V(r,t,null);if(o!==null)return o}if(r.tags.nullable?.length)return h.DeleteItem();if(r.tags.fail?.length)throw Error(`No valid value found for default (${r.rawArgs.map((t)=>t.value).join(", ")})`);return""}},section:(r)=>{let t=r.args[0],n=e.getSection(t);if(!n)throw Error(`Section not found: ${t}`);return n.content}});var Fr=()=>({convert:({args:[e,r,t]})=>{switch(r){case"string":return String(e);case"number":{let n=Number(e);if(!isNaN(n))return h.ReplaceItem(n);break}case"boolean":if(e==="true"||e===!0||e===1||e==="1"||e==="yes"||e==="on")return h.ReplaceItem(!0);else if(e==="false"||e===!1||e===0||e==="0"||e==="no"||e==="off")return h.ReplaceItem(!1);break;default:throw Error(`Unsupported type for convert: ${r}`)}if(t!==void 0)return h.ReplaceItem(t);throw Error(`Failed to convert value to ${r}`)},isType:({args:[e,r]})=>{let n=(()=>{switch(r){case"string":return typeof e==="string";case"number":return typeof e==="number";case"boolean":return typeof e==="boolean";case"object":return e!==null&&typeof e==="object"&&!Array.isArray(e);case"array":return Array.isArray(e);case"null":return e===null;case"undefined":return e===void 0;case"function":return typeof e==="function";default:throw Error(`Unknown type for isType: ${r}`)}})();return h.ReplaceItem(n)},typeOf:({args:[e]})=>{if(e===null)return"null";else if(Array.isArray(e))return"array";else return typeof e}});var Dr=()=>({...S({add:(...e)=>e.reduce((r,t)=>r+t,0),subtract:(e,r)=>e-r,multiply:(...e)=>e.reduce((r,t)=>r*t,1),divide:(e,r)=>{if(r===0)throw Error("Division by zero");return e/r},modulo:(e,r)=>e%r,power:(e,r)=>Math.pow(e,r),sqrt:(e)=>Math.sqrt(e),abs:(e)=>Math.abs(e),floor:(e)=>Math.floor(e),ceil:(e)=>Math.ceil(e),round:(e,r)=>{let t=Math.pow(10,r??0);return Math.round(e*t)/t},min:(...e)=>Math.min(...e),max:(...e)=>Math.max(...e),clamp:(e,r,t)=>Math.max(r,Math.min(t,e)),random:(e,r)=>{let t=e??0,n=r??1;return Math.random()*(n-t)+t}})});var _r=()=>({now:()=>new Date,timestamp:(e)=>{let r=e.args?.[0];return(r?new Date(r):new Date).getTime()},iso:(e)=>{let r=e.args?.[0];return(r?new Date(r):new Date).toISOString()},utc:(e)=>{let r=e.args?.[0];return(r?new Date(r):new Date).toUTCString()},format:(e)=>{let r=e.args?.[0],t=e.args?.[1],n=new Date(r),o=n.getFullYear(),s=String(n.getMonth()+1).padStart(2,"0"),i=String(n.getDate()).padStart(2,"0"),a=String(n.getHours()).padStart(2,"0"),u=String(n.getMinutes()).padStart(2,"0"),m=String(n.getSeconds()).padStart(2,"0");return t.replace("YYYY",String(o)).replace("MM",s).replace("DD",i).replace("HH",a).replace("mm",u).replace("ss",m)},parse:(e)=>{let r=e.args?.[0];return new Date(r).getTime()},year:(e)=>{let r=e.args?.[0];return(r?new Date(r):new Date).getFullYear()},month:(e)=>{let r=e.args?.[0];return(r?new Date(r):new Date).getMonth()+1},day:(e)=>{let r=e.args?.[0];return(r?new Date(r):new Date).getDate()},dayOfWeek:(e)=>{let r=e.args?.[0];return(r?new Date(r):new Date).getDay()},hours:(e)=>{let r=e.args?.[0];return(r?new Date(r):new Date).getHours()},minutes:(e)=>{let r=e.args?.[0];return(r?new Date(r):new Date).getMinutes()},seconds:(e)=>{let r=e.args?.[0];return(r?new Date(r):new Date).getSeconds()}});var Rr=()=>{return{unique:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1];if(!Array.isArray(r))return r;let n=new Set;return r.filter((o)=>{let s=typeof t==="function"?t(o):t?o[t]:o;if(n.has(s))return!1;return n.add(s),!0})},groupBy:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1];if(!Array.isArray(r))return r;let n={};return r.forEach((o)=>{let s=typeof t==="function"?String(t(o)):String(o[t]);if(!n[s])n[s]=[];n[s].push(o)}),n},partition:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1];if(!Array.isArray(r))return[[],[]];if(typeof t!=="function")return[r,[]];let n=[],o=[];return r.forEach((s)=>{(t(s)?n:o).push(s)}),[n,o]},chunk:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1]??1;if(!Array.isArray(r))return[];let n=[];for(let o=0;o<r.length;o+=t)n.push(r.slice(o,o+t));return n},flatten:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1]??1;if(!Array.isArray(r))return[r];let n=[],o=(s,i)=>{for(let a of s)if(Array.isArray(a)&&i>0)o(a,i-1);else n.push(a)};return o(r,t),n},compact:(e)=>{let r=e.args?.[0]??e.value;if(!Array.isArray(r))return r;return r.filter((t)=>t!==null&&t!==void 0)},head:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1];if(!Array.isArray(r))return r;return t?r.slice(0,t):r[0]},tail:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1];if(!Array.isArray(r))return r;return t?r.slice(-t):r[r.length-1]}}};import{createHash as H}from"crypto";var Nr=()=>({md5:(e)=>{let r=e.args?.[0]??e.value;return H("md5").update(r).digest("hex")},sha1:(e)=>{let r=e.args?.[0]??e.value;return H("sha1").update(r).digest("hex")},sha256:(e)=>{let r=e.args?.[0]??e.value;return H("sha256").update(r).digest("hex")},sha512:(e)=>{let r=e.args?.[0]??e.value;return H("sha512").update(r).digest("hex")},hash:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1]??"sha256";return H(t).update(r).digest("hex")},base64Encode:(e)=>{let r=e.args?.[0]??e.value,t=typeof r==="string"?r:JSON.stringify(r);return Buffer.from(t).toString("base64")},base64Decode:(e)=>{let r=e.args?.[0]??e.value;return Buffer.from(r,"base64").toString("utf-8")},hexEncode:(e)=>{let r=e.args?.[0]??e.value;return Buffer.from(r).toString("hex")},hexDecode:(e)=>{let r=e.args?.[0]??e.value;return Buffer.from(r,"hex").toString("utf-8")}});var Wr=()=>({test:(e)=>{let r=e.args?.[0],t=e.args?.[1],n=e.args?.[2];return new RegExp(r,n).test(t)},match:(e)=>{let r=e.args?.[0],t=e.args?.[1],n=e.args?.[2],o=new RegExp(r,n);return t.match(o)},matchAll:(e)=>{let r=e.args?.[0],t=e.args?.[1],n=e.args?.[2],o=new RegExp(r,n);return Array.from(t.matchAll(o))},replace:(e)=>{let r=e.args?.[0],t=e.args?.[1],n=e.args?.[2],o=e.args?.[3],s=new RegExp(r,o);return n.replace(s,t)},replaceAll:(e)=>{let r=e.args?.[0],t=e.args?.[1],n=e.args?.[2],o=e.args?.[3]??"g",s=new RegExp(r,o);return n.replace(s,t)},split:(e)=>{let r=e.args?.[0],t=e.args?.[1],n=e.args?.[2],o=new RegExp(r,n);return t.split(o)},exec:(e)=>{let r=e.args?.[0],t=e.args?.[1],n=e.args?.[2];return new RegExp(r,n).exec(t)},search:(e)=>{let r=e.args?.[0],t=e.args?.[1],n=e.args?.[2],o=new RegExp(r,n);return t.search(o)}});import{resolve as Lt,dirname as It,basename as Ut,normalize as Bt,join as Yt}from"path";var $r=()=>({...S({pathJoin:(...e)=>Yt(...e),resolve:(...e)=>Lt(...e),dirname:(e)=>It(e),basename:(e,r)=>Ut(e,r),normalize:(e)=>Bt(e),extname:(e)=>{let r=/\.[^.]*$/.exec(e);return r?r[0]:""},relative:(e,r)=>{let t=e.split("/"),n=r.split("/"),o=0;while(o<t.length&&o<n.length&&t[o]===n[o])o++;let s=t.length-o,i=n.slice(o);return[...Array(s).fill("..")].concat(i).join("/")},isAbsolute:(e)=>e.startsWith("/"),segments:(e)=>e.split("/").filter(Boolean)})});var Cr=()=>({isEmail:(e)=>{let r=e.args?.[0]??e.value;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r)},isUrl:(e)=>{let r=e.args?.[0]??e.value;try{return new URL(r),!0}catch{return!1}},isJson:(e)=>{let r=e.args?.[0]??e.value;try{return JSON.parse(r),!0}catch{return!1}},isUuid:(e)=>{let r=e.args?.[0]??e.value;return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r)},minLength:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1];return r?.length>=t},maxLength:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1];return r?.length<=t},length:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1];return r?.length===t},isNumber:(e)=>{let r=e.args?.[0]??e.value;return typeof r==="number"&&!isNaN(r)},isString:(e)=>{return typeof(e.args?.[0]??e.value)==="string"},isBoolean:(e)=>{return typeof(e.args?.[0]??e.value)==="boolean"},isArray:(e)=>{let r=e.args?.[0]??e.value;return Array.isArray(r)},isObject:(e)=>{let r=e.args?.[0]??e.value;return r!==null&&typeof r==="object"&&!Array.isArray(r)},isEmpty:(e)=>{let r=e.args?.[0]??e.value;if(r===null||r===void 0)return!0;if(typeof r==="string"||Array.isArray(r))return r.length===0;if(typeof r==="object")return Object.keys(r).length===0;return!1},isTruthy:(e)=>{return!!(e.args?.[0]??e.value)},isFalsy:(e)=>{return!(e.args?.[0]??e.value)},inRange:(e)=>{let r=e.args?.[0],t=e.args?.[1],n=e.args?.[2];return r>=t&&r<=n},matches:(e)=>{let r=e.args?.[0],t=e.args?.[1];return new RegExp(t).test(r)},includes:(e)=>{let r=e.args?.[0],t=e.args?.[1];if(typeof r==="string")return r.includes(String(t));return Array.isArray(r)&&r.includes(t)},startsWith:(e)=>{let r=e.args?.[0],t=e.args?.[1];return r.startsWith(t)},endsWith:(e)=>{let r=e.args?.[0],t=e.args?.[1];return r.endsWith(t)}});var Lr=(e)=>e.keys(ze(e)).keys(er(e)).keys(sr()).keys(ar()).keys(fr()).keys(ir()).keys(lr()).keys(ur(e)).keys(cr(e)).keys(mr()).keys(gr()).keys(yr()).sources(wr(e)).sources(br()).sources(Er()).sources(Fr()).sources(Ar()).sources(kr()).sources(Mr()).sources(Or()).sources(Sr()).sources(jr(e)).sources(Dr()).sources(_r()).sources(Rr()).sources(Nr()).sources(Wr()).sources($r()).sources(Cr()).fieldOptions({onSection:(r)=>{e.section(r)}});import fe from"path";class Me{includeDirectories=[];baseIncludeDirectories=[];includes=[];addDirectories(...e){this.includeDirectories.push(...e),this.baseIncludeDirectories.push(...e)}getDirectories(){return this.includeDirectories}reset(){this.includeDirectories=[...this.baseIncludeDirectories]}restore(e){this.includeDirectories=[...e]}snapshot(){return[...this.includeDirectories]}addFiles(...e){this.includes.push(...e)}getPendingAndClear(){let e=[...this.includes];return this.includes.length=0,e}async processPatterns(e,r,t){let n=[];for(let o of e)if(I.isGlobPattern(o)){let s=new Bun.Glob(o);for await(let i of s.scan({cwd:r,absolute:!0}))if(!t.included.includes(i))n.push(i)}else if(I.isDirectoryPattern(o)){let s=fe.isAbsolute(o)?o:fe.join(r,o);if(!this.includeDirectories.includes(s))this.includeDirectories.push(s)}else n.push(o);return n}buildSearchDirs(e){let r=e?[e]:[];return r.push(...this.includeDirectories.map((t)=>fe.isAbsolute(t)?t:fe.join(e??process.cwd(),t))),r}}class Oe{includeManager;loadFn;constructor(e,r){this.includeManager=e;this.loadFn=r}async processIncludes(e,r,t){let n=[];if(e.content.includes)n.push(...e.content.includes),delete e.content.includes;n.push(...this.includeManager.getPendingAndClear());let o=await this.includeManager.processPatterns(n,e.folderPath,t);for(let s of o)R(await this.loadFn(s,e.folderPath,{parent:e.content,...r},!0,t),e.content)}}var j={};N(j,{writeOutputs:()=>te,writeOutput:()=>be,writeFormat:()=>we,tokenize:()=>hr,toObjectWithKey:()=>Ge,toObject:()=>ne,toList:()=>C,sortBy:()=>Ve,snake:()=>G,select:()=>v,processFields:()=>O,pascal:()=>X,padBlock:()=>W,nonNullMap:()=>Ke,navigate:()=>Ee,mergeAll:()=>T,merge:()=>R,makeFieldProcessorMap:()=>S,makeFieldProcessorList:()=>Ce,makeFieldProcessor:()=>z,locate:()=>$,loadFormat:()=>ee,importList:()=>he,importGlob:()=>Qe,globMap:()=>re,getProcessor:()=>P,getArgs:()=>ye,find:()=>xe,exists:()=>Y,defined:()=>Ze,deepClone:()=>F,conditionPredicates:()=>D,changeCase:()=>K,capital:()=>ie,camel:()=>le,asyncMap:()=>He,NavigateResult:()=>h,NavigateAction:()=>ve});_(j,Qr(Yr(),1));var Aa=j;class Vt{includeManager=new Me;includeProcessor;cacheManager=new Ae(100);outputs=[];vars={};fields={sources:{},keys:{}};objectMetadata={};currentContext=null;sections={};constructor(){this.includeProcessor=new Oe(this.includeManager,this.load.bind(this)),this.use(Lr)}use(e){return e(this),this}includeDirectory(...e){return this.includeManager.addDirectories(...e),this}getIncludeDirectories(){return this.includeManager.getDirectories()}include(...e){return this.includeManager.addFiles(...e),this}keys(e){return Object.assign(this.fields.keys,{...this.fields.keys,...e}),this}sources(e){return Object.assign(this.fields.sources,{...this.fields.sources,...e}),this}variables(e){return this.vars={...this.vars,...e},this}getOutputs(){return this.outputs}output(e){return this.outputs.push(e),this}metadata(e,r){return this.objectMetadata[e]=r,this}getMetadata(e){return this.objectMetadata[e]}getAllMetadata(){return this.objectMetadata}setCacheMaxSize(e){return this.cacheManager.setMaxSize(e),this}clearCache(){return this.cacheManager.clear(),this}getCurrentContext(){return this.currentContext}fieldOptions(e){return this.fields={...this.fields,...e},this}section(e){return this.sections[e.name]=e,this}getSection(e){return this.sections[e]}filter(e){return this.fields.filters??=[],this.fields.filters.push(e),this}async loadObject(e,r,t){return await O(e,{...this.fields,globalContext:{file:t?.fullPath??"@internal"},root:{...r,...this.fields.root,...this.vars,context:this.currentContext,sections:this.sections,$document:{root:{content:e},fileName:t?.fileName??"@internal",folder:t?.folderPath??"@internal",fullPath:t?.fullPath??"@internal"}}}),e}async load(e,r,t,n,o){let s=this.includeManager.snapshot();try{this.includeManager.reset();let i=this.includeManager.buildSearchDirs(r);if(o)this.currentContext=o;this.currentContext??={included:[],document:null};let a=await ee(e,{dirs:i}),u=I.normalize(a.fullPath);if(this.currentContext.included.push(u),!a.content)return null;let m=this.cacheManager.get(u),y;if(m)y=m.raw;else y=a.content,this.cacheManager.set(u,{raw:y,timestamp:Date.now()});let g=F(y);a.content=g,await this.includeProcessor.processIncludes(a,t,this.currentContext);let l;if(n!==!0)l=await this.loadObject(a.content,t,{fileName:a.fullPath,folderPath:a.folderPath,fullPath:a.fullPath});else l=a.content;return this.currentContext.document=l,l}catch(i){throw this.includeManager.restore(s),i}finally{this.includeManager.restore(s)}}async writeAll(e){await te(this.getOutputs(),e)}}export{Aa as default,Vt as Objector};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homedev/objector",
3
- "version": "1.2.42",
3
+ "version": "1.2.44",
4
4
  "description": "object extensions for YAML/JSON",
5
5
  "author": "julzor",
6
6
  "license": "ISC",