@visulima/packem 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,83 +1,86 @@
1
- "use strict";var St=Object.defineProperty;var m=(e,t)=>St(e,"name",{value:t,configurable:!0});const oe=require("node:fs"),ne=require("node:fs/promises"),Ot=require("node:module"),ge=require("node:process"),b=require("@visulima/colorize"),Dt=require("@visulima/find-cache-dir"),k=require("@visulima/fs"),_=require("@visulima/humanizer"),f=require("@visulima/path"),je=require("@visulima/tsconfig"),Nt=require("defu"),_t=require("hookable"),Le=require("jiti"),B=require("rollup"),Pt=require("@rollup/plugin-alias"),Ct=require("@rollup/plugin-commonjs"),Rt=require("@rollup/plugin-dynamic-import-vars"),Be=require("@rollup/plugin-node-resolve"),Tt=require("@rollup/plugin-replace"),It=require("@rollup/plugin-wasm"),At=require("rollup-plugin-polyfill-node"),Mt=require("rollup-plugin-visualizer"),H=require("semver"),$=require("./packem_shared/constants-ISPLmXDX.cjs"),Ft=require("node:assert/strict"),P=require("@rollup/pluginutils"),Jt=require("magic-string"),Lt=require("glob-parent"),X=require("tinyglobby"),F=require("mlly"),Bt=require("oxc-parser"),Wt=require("@rollup/plugin-json"),qt=require("rollup-plugin-license"),We=require("./packem_shared/create-or-update-key-storage-DslhcsTU.cjs"),Ut=require("node:crypto"),Vt=require("node:url"),zt=require("@babel/parser"),Gt=require("@visulima/package/package-json"),Kt=require("@visulima/fs/error"),Xt=require("@visulima/path/utils"),Ht=require("fastest-levenshtein");var M=typeof document<"u"?document.currentScript:null;const N=m(e=>e&&typeof e=="object"&&"default"in e?e.default:e,"_interopDefaultCompat"),we=N(Ot),qe=N(Pt),Yt=N(Ct),Qt=N(Rt),Ue=N(Tt),Zt=N(At),Y=N(Ft),I=N(Jt),eo=N(Lt),to=N(Wt),oo=N(qt);var no=Object.defineProperty,ro=m((e,t)=>no(e,"name",{value:t,configurable:!0}),"a$g");const de=ro((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var io=Object.defineProperty,so=m((e,t)=>io(e,"name",{value:t,configurable:!0}),"a$f");const L=so(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var ao=Object.defineProperty,lo=m((e,t)=>ao(e,"name",{value:t,configurable:!0}),"a$e");const Ve=lo((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var co=Object.defineProperty,ze=m((e,t)=>co(e,"name",{value:t,configurable:!0}),"s$e");const po=ze((e,t,o)=>{const n=o??new Map;return(...r)=>{const i=t?typeof t=="function"?t(...r):t:JSON.stringify({args:r}),s=n.get(i);if(s!==void 0)return s;const a=e(...r);return n.set(i,a),a}},"memoize"),uo=ze(e=>{const t=new Map;return o=>po(e,o,t)},"memoizeByKey");var fo=Object.defineProperty,W=m((e,t)=>fo(e,"name",{value:t,configurable:!0}),"r$d");const mo=W(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;Y(t,"Expected class/function to have a name"),yield t.name;break}case"VariableDeclaration":{for(const t of e.declaration.declarations)for(const o of P.extractAssignedNames(t.id))yield o;break}}},"exportName"),go=W(function*(e){if(e.declaration)for(const t of mo(e))yield{exportedName:t,from:"self",type:"named"};else if(e.source)yield{bindings:e.specifiers.map(t=>({exportedName:t.exported.name,importedName:t.local.name})),from:"other",source:e.source.value,type:"named"};else for(const t of e.specifiers)yield{exportedName:t.exported.name,from:"self",type:"named"}},"parseExportNamed"),ho=W(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),yo=W(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),vo=W(function*(e,t){Y(t.code!=null,`Module ${t.id} doesn't have associated code`);const o=e.parse(t.code);for(const n of o.body)switch(n.type){case"ExportAllDeclaration":{yield*ho(n);break}case"ExportDefaultDeclaration":{yield*yo();break}case"ExportNamedDeclaration":{yield*go(n);break}}},"parseExports");var bo=Object.defineProperty,q=m((e,t)=>bo(e,"name",{value:t,configurable:!0}),"n$a");const Ge=q(async function(e,t,o){const n=await e.resolve(t,o.id);if(Y(n,`Rollup can't resolve ${t} from ${o.id}`),n.external)return null;const r=await e.load(n);return Y(r,`Rollup doesn't have a module for id ${n.id}`),r},"getImportedModule"),jo=q(async function*(e,t,o){const n=await Ge(e,t.source,o);n&&(yield*he(e,n))},"gatherBarrelReExports"),wo=q(async function*(e,t,o){const n=await Ge(e,t.source,o);if(!n)return;const r=new Map(t.bindings.map(i=>[i.importedName,i]));for await(const i of he(e,n)){const s=r.get(i.exportedName);s&&(yield{...i,exportedName:s.exportedName})}},"gatherNamedReExports"),$o=q(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),he=q(async function*(e,t){for(const o of vo(e,t))o.from==="self"?yield*$o(t,o):o.type==="barrel"?yield*jo(e,o,t):yield*wo(e,o,t)},"gatherExports");var ko=Object.defineProperty,Eo=m((e,t)=>ko(e,"name",{value:t,configurable:!0}),"r$c");const xo=Eo(()=>({moduleParsed:{async handler(e){if(e.isEntry)for await(const t of he(this,e))t.id!==e.id&&this.emitFile({id:t.id,name:t.exportedName,preserveSignature:"exports-only",type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");var So=Object.defineProperty,Oo=m((e,t)=>So(e,"name",{value:t,configurable:!0}),"r$b");const Do=Oo((e,t)=>{const o=e,n=[];let r;for(;(r=o.exec(t))!==null;)r.index===o.lastIndex&&o.lastIndex++,r.forEach(i=>{n.push(i)});return n.filter(Boolean)},"getRegexMatches");var No=Object.defineProperty,_o=m((e,t)=>No(e,"name",{value:t,configurable:!0}),"a$d");const Ke=_o(e=>{const t=Do(/export\s(\{\s(.*)\s\}|default\s.*);/g,e);if(t.length===0)return null;const o=t.at(-1).split(", ");let n="";for(const r of o)if(!r.includes("type")&&(r.includes("default ")&&(n=r.split("default ")[1]),r.includes("as"))){const[i,s]=r.split(" as ");s==="default"&&(n=i)}if(n!==""){const r=new I(e);return r.replace(new RegExp(`(,s)?${n} as default(,)?`),""),r.replace(new RegExp(`export default ${n};
1
+ "use strict";var Dt=Object.defineProperty;var m=(e,t)=>Dt(e,"name",{value:t,configurable:!0});const oe=require("node:fs"),ne=require("node:fs/promises"),Nt=require("node:module"),ge=require("node:process"),j=require("@visulima/colorize"),_t=require("@visulima/find-cache-dir"),k=require("@visulima/fs"),_=require("@visulima/humanizer"),f=require("@visulima/path"),je=require("@visulima/tsconfig"),Pt=require("defu"),Ct=require("hookable"),Le=require("jiti"),B=require("rollup"),Tt=require("@rollup/plugin-alias"),Rt=require("@rollup/plugin-commonjs"),It=require("@rollup/plugin-dynamic-import-vars"),Be=require("@rollup/plugin-node-resolve"),At=require("@rollup/plugin-replace"),Mt=require("@rollup/plugin-wasm"),Ft=require("rollup-plugin-polyfill-node"),Jt=require("rollup-plugin-visualizer"),H=require("semver"),$=require("./packem_shared/constants-ISPLmXDX.cjs"),Lt=require("node:assert/strict"),C=require("@rollup/pluginutils"),Bt=require("magic-string"),Wt=require("glob-parent"),X=require("tinyglobby"),F=require("mlly"),qt=require("oxc-parser"),Ut=require("@rollup/plugin-json"),Vt=require("rollup-plugin-license"),We=require("./packem_shared/create-or-update-key-storage-DslhcsTU.cjs"),zt=require("node:crypto"),Gt=require("node:url"),Kt=require("@babel/parser"),Xt=require("@visulima/package/package-json"),Ht=require("@visulima/fs/error"),Yt=require("@visulima/path/utils"),Qt=require("fastest-levenshtein");var M=typeof document<"u"?document.currentScript:null;const N=m(e=>e&&typeof e=="object"&&"default"in e?e.default:e,"_interopDefaultCompat"),we=N(Nt),qe=N(Tt),Zt=N(Rt),eo=N(It),Ue=N(At),to=N(Ft),Y=N(Lt),I=N(Bt),oo=N(Wt),no=N(Ut),ro=N(Vt);var io=Object.defineProperty,so=m((e,t)=>io(e,"name",{value:t,configurable:!0}),"a$g");const de=so((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var ao=Object.defineProperty,lo=m((e,t)=>ao(e,"name",{value:t,configurable:!0}),"a$f");const L=lo(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var co=Object.defineProperty,po=m((e,t)=>co(e,"name",{value:t,configurable:!0}),"a$e");const Ve=po((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var uo=Object.defineProperty,ze=m((e,t)=>uo(e,"name",{value:t,configurable:!0}),"s$e");const fo=ze((e,t,o)=>{const n=o??new Map;return(...r)=>{const s=t?typeof t=="function"?t(...r):t:JSON.stringify({args:r}),i=n.get(s);if(i!==void 0)return i;const a=e(...r);return n.set(s,a),a}},"memoize"),mo=ze(e=>{const t=new Map;return o=>fo(e,o,t)},"memoizeByKey");var go=Object.defineProperty,W=m((e,t)=>go(e,"name",{value:t,configurable:!0}),"r$d");const ho=W(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;Y(t,"Expected class/function to have a name"),yield t.name;break}case"VariableDeclaration":{for(const t of e.declaration.declarations)for(const o of C.extractAssignedNames(t.id))yield o;break}}},"exportName"),yo=W(function*(e){if(e.declaration)for(const t of ho(e))yield{exportedName:t,from:"self",type:"named"};else if(e.source)yield{bindings:e.specifiers.map(t=>({exportedName:t.exported.name,importedName:t.local.name})),from:"other",source:e.source.value,type:"named"};else for(const t of e.specifiers)yield{exportedName:t.exported.name,from:"self",type:"named"}},"parseExportNamed"),vo=W(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),bo=W(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),jo=W(function*(e,t){Y(t.code!=null,`Module ${t.id} doesn't have associated code`);const o=e.parse(t.code);for(const n of o.body)switch(n.type){case"ExportAllDeclaration":{yield*vo(n);break}case"ExportDefaultDeclaration":{yield*bo();break}case"ExportNamedDeclaration":{yield*yo(n);break}}},"parseExports");var wo=Object.defineProperty,q=m((e,t)=>wo(e,"name",{value:t,configurable:!0}),"n$b");const Ge=q(async function(e,t,o){const n=await e.resolve(t,o.id);if(Y(n,`Rollup can't resolve ${t} from ${o.id}`),n.external)return null;const r=await e.load(n);return Y(r,`Rollup doesn't have a module for id ${n.id}`),r},"getImportedModule"),$o=q(async function*(e,t,o){const n=await Ge(e,t.source,o);n&&(yield*he(e,n))},"gatherBarrelReExports"),ko=q(async function*(e,t,o){const n=await Ge(e,t.source,o);if(!n)return;const r=new Map(t.bindings.map(s=>[s.importedName,s]));for await(const s of he(e,n)){const i=r.get(s.exportedName);i&&(yield{...s,exportedName:i.exportedName})}},"gatherNamedReExports"),Eo=q(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),he=q(async function*(e,t){for(const o of jo(e,t))o.from==="self"?yield*Eo(t,o):o.type==="barrel"?yield*$o(e,o,t):yield*ko(e,o,t)},"gatherExports");var xo=Object.defineProperty,So=m((e,t)=>xo(e,"name",{value:t,configurable:!0}),"r$c");const Oo=So(()=>({moduleParsed:{async handler(e){if(e.isEntry)for await(const t of he(this,e))t.id!==e.id&&this.emitFile({id:t.id,name:t.exportedName,preserveSignature:"exports-only",type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");var Do=Object.defineProperty,No=m((e,t)=>Do(e,"name",{value:t,configurable:!0}),"r$b");const _o=No((e,t)=>{const o=e,n=[];let r;for(;(r=o.exec(t))!==null;)r.index===o.lastIndex&&o.lastIndex++,r.forEach(s=>{n.push(s)});return n.filter(Boolean)},"getRegexMatches");var Po=Object.defineProperty,Co=m((e,t)=>Po(e,"name",{value:t,configurable:!0}),"a$d");const Ke=Co(e=>{const t=_o(/export\s(\{\s(.*)\s\}|default\s.*);/g,e);if(t.length===0)return null;const o=t.at(-1).split(", ");let n="";for(const r of o)if(!r.includes("type")&&(r.includes("default ")&&(n=r.split("default ")[1]),r.includes("as"))){const[s,i]=r.split(" as ");i==="default"&&(n=s)}if(n!==""){const r=new I(e);return r.replace(new RegExp(`(,s)?${n} as default(,)?`),""),r.replace(new RegExp(`export default ${n};
2
2
  ?`),""),r.append(`
3
3
 
4
- export = `+n+";"),{code:r.toString().replace(/export\s\{\s\s\};/,""),map:r.generateMap({hires:!0})}}return null},"patchCjsDefaultExport");var Po=Object.defineProperty,$e=m((e,t)=>Po(e,"name",{value:t,configurable:!0}),"i$9");const Xe=$e(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk:$e(async(n,r,i)=>{if(r.type!=="chunk"||!r.isEntry)return null;if(i.format==="cjs"&&i.exports==="auto"){const s=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(s===null||s.length<3)return null;const a=new I(n);a.replace("",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.module.exports.$1 = $2;"),e&&a.append(`
5
- module.module.exports = `+s[2]+";");let l=a.toString();return l=l.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:l,map:a.generateMap({hires:!0})}}return i.format==="es"&&/\.d\.(?:ts|cts)$/.test(r.fileName)?o!=="commonjs"&&r.fileName.endsWith(".d.mts")?null:Ke(n):null},"renderChunk")}),"cjsInteropPlugin");var Co=Object.defineProperty,Ro=m((e,t)=>Co(e,"name",{value:t,configurable:!0}),"f$a");const To=Ro((e,t)=>{const o=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:r}=n;return Array.isArray(r)?r=r.map(i=>{if(typeof i=="string")return{src:i};if(typeof i=="object"&&"src"in i)return i}).filter(Boolean):typeof r=="string"&&(r=[{src:r}]),{async buildStart(){const i=await Promise.all(r.flatMap(s=>Array.isArray(s.src)?s.src.map(a=>({...s,src:a})):s).map(async s=>await X.glob(L(s.src),{ignore:L(s.exclude).filter(Boolean)}).then(a=>({dest:s.dest??"",parent:eo(s.src),src:a}))));for(const s of i)for(const a of s.src){let l;o.has(a)?l=o.get(a):(l={copied:[],dest:[],timestamp:0},o.set(a,l));const c=n.flatten?f.normalize(s.dest):f.join(s.dest,f.relative(s.parent,f.dirname(a)));l.dest.includes(c)||l.dest.push(c),this.addWatchFile(a)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([s,a])=>{let l;try{const c=await ne.stat(s);if(!c.isFile())return;const u=c.mtime.getTime();u>a.timestamp&&(a.timestamp=u,a.copied=[]),l=await k.readFile(s,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${s}`,prefix:"plugin:copy"});return}for(const c of a.dest){if(n.copyOnce&&a.copied.includes(c))continue;const u=f.basename(s),p=f.join(c,u);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:p,source:l,type:"asset"}),t.debug({message:`copied ${s} → ${p}`,prefix:"plugin:copy"}),a.copied.push(c)}catch(d){t.error({context:[d],message:`error copying file ${s} → ${p}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Io=Object.defineProperty,re=m((e,t)=>Io(e,"name",{value:t,configurable:!0}),"t$a");const Ao=/\Wrequire(?:\.resolve)?\(/,Mo=re((e,t)=>{if(ge.env.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes("// -- packem CommonJS __filename shim")||e.includes("// -- packem CommonJS __dirname shim")||e.includes("// -- packem CommonJS require shim")))return null;let o=!1,n=!1,r=!1;if(e.includes("__filename")&&(o=!0),e.includes("__dirname")&&(n=!0),Ao.test(e)&&(r=!0),!o&&!n&&!r)return null;const i=F.findStaticImports(e).pop(),s=i?i.end:0,a=new I(e);return a.appendRight(s,t(o,n,r)),{code:a.toString(),map:a.generateMap()}},"CJSToESM"),Fo=re((e,t,o)=>{let n="";return(e||t)&&(n+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
4
+ export = `+n+";"),{code:r.toString().replace(/export\s\{\s\s\};/,""),map:r.generateMap({hires:!0})}}return null},"patchCjsDefaultExport");var To=Object.defineProperty,$e=m((e,t)=>To(e,"name",{value:t,configurable:!0}),"i$9");const Xe=$e(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk:$e(async(n,r,s)=>{if(r.type!=="chunk"||!r.isEntry)return null;if(s.format==="cjs"&&s.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(i===null||i.length<3)return null;const a=new I(n);a.replace("",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.module.exports.$1 = $2;"),e&&a.append(`
5
+ module.module.exports = `+i[2]+";");let l=a.toString();return l=l.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:l,map:a.generateMap({hires:!0})}}return s.format==="es"&&/\.d\.(?:ts|cts)$/.test(r.fileName)?o!=="commonjs"&&r.fileName.endsWith(".d.mts")?null:Ke(n):null},"renderChunk")}),"cjsInteropPlugin");var Ro=Object.defineProperty,Io=m((e,t)=>Ro(e,"name",{value:t,configurable:!0}),"f$a");const Ao=Io((e,t)=>{const o=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:r}=n;return Array.isArray(r)?r=r.map(s=>{if(typeof s=="string")return{src:s};if(typeof s=="object"&&"src"in s)return s}).filter(Boolean):typeof r=="string"&&(r=[{src:r}]),{async buildStart(){const s=await Promise.all(r.flatMap(i=>Array.isArray(i.src)?i.src.map(a=>({...i,src:a})):i).map(async i=>await X.glob(L(i.src),{ignore:L(i.exclude).filter(Boolean)}).then(a=>({dest:i.dest??"",parent:oo(i.src),src:a}))));for(const i of s)for(const a of i.src){let l;o.has(a)?l=o.get(a):(l={copied:[],dest:[],timestamp:0},o.set(a,l));const c=n.flatten?f.normalize(i.dest):f.join(i.dest,f.relative(i.parent,f.dirname(a)));l.dest.includes(c)||l.dest.push(c),this.addWatchFile(a)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([i,a])=>{let l;try{const c=await ne.stat(i);if(!c.isFile())return;const u=c.mtime.getTime();u>a.timestamp&&(a.timestamp=u,a.copied=[]),l=await k.readFile(i,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const c of a.dest){if(n.copyOnce&&a.copied.includes(c))continue;const u=f.basename(i),p=f.join(c,u);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:p,source:l,type:"asset"}),t.debug({message:`copied ${i} → ${p}`,prefix:"plugin:copy"}),a.copied.push(c)}catch(d){t.error({context:[d],message:`error copying file ${i} → ${p}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Mo=Object.defineProperty,re=m((e,t)=>Mo(e,"name",{value:t,configurable:!0}),"t$9");const Fo=/\Wrequire(?:\.resolve)?\(/,Jo=re((e,t)=>{if(ge.env.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes("// -- packem CommonJS __filename shim")||e.includes("// -- packem CommonJS __dirname shim")||e.includes("// -- packem CommonJS require shim")))return null;let o=!1,n=!1,r=!1;if(e.includes("__filename")&&(o=!0),e.includes("__dirname")&&(n=!0),Fo.test(e)&&(r=!0),!o&&!n&&!r)return null;const s=F.findStaticImports(e).pop(),i=s?s.end:0,a=new I(e);return a.appendRight(i,t(o,n,r)),{code:a.toString(),map:a.generateMap()}},"CJSToESM"),Lo=re((e,t,o)=>{let n="";return(e||t)&&(n+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
6
6
  `),t&&(n+=`import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
7
7
  `),o&&(n+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
8
8
  `),(e||t)&&(n+=`const __filename = __cjs_url__.fileURLToPath(import.meta.url);
9
9
  `),t&&(n+=`const __dirname = __cjs_path__.dirname(__filename);
10
10
  `),o&&(n+=`const require = __cjs_mod__.createRequire(import.meta.url);
11
- `),n},"generateCJSShim"),Jo=re((e,t,o)=>{let n="";return o&&(n+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
11
+ `),n},"generateCJSShim"),Bo=re((e,t,o)=>{let n="";return o&&(n+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
12
12
  `),e&&(n+=`const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
13
13
  `),t&&(n+=`const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
14
14
  `),o&&(n+=`const require = __cjs_mod__.createRequire(import.meta.url);
15
- `),n},"generateCJSShimNode20_11"),Lo=re((e,t)=>{const o=P.createFilter(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(n,r,i){if(i.format==="es"&&o(r.fileName)){let s=Fo;if(e.engines?.node){const a=H.minVersion(e.engines.node);a&&a.major>=20&&a.minor>=11&&(s=Jo)}return Mo(n,s)}return null}}},"esmShimCjsSyntaxPlugin");var Bo=Object.defineProperty,Wo=m((e,t)=>Bo(e,"name",{value:t,configurable:!0}),"m$9");const qo=Wo(()=>({name:"packem:fix-dynamic-import-extension",renderChunk(e,t,o){return o.format==="es"||o.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(o.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var Uo=Object.defineProperty,Vo=m((e,t)=>Uo(e,"name",{value:t,configurable:!0}),"a$c");const zo=Vo((e,t)=>{const o=e.replace(/^\.\//,""),n=t.replace(/^\.\//,"");if(n.startsWith(o))return e+n.slice(o.length);if(e.endsWith(t))return e;const r=e.split("/"),i=t.split("/");let s=r.length-1,a=i.length-1;for(;s>=0&&a>=0&&r[s]===i[a];)s--,a--;const l=r.slice(0,s).join("/"),c=i.slice(a).join("/");return l+(c?"/"+c:"")},"extendString");var Go=Object.defineProperty,Ko=m((e,t)=>Go(e,"name",{value:t,configurable:!0}),"s$b");const Xo=Ko((...e)=>{if(e.length===0)return"";if(e.length===1)return f.dirname(e[0]);e=e.map(r=>f.toNamespacedPath(r));const[t,...o]=e;let n=t.split("/");for(const r of o){const i=r.split("/",n.length);let s=0;for(const a of i)if(a===n[s])s+=1;else{n=n.slice(0,s);break}n=n.slice(0,s)}return n.length<=1&&n[0]===""?`/${n[0]}`:n.join("/")},"lowestCommonAncestor");var Ho=Object.defineProperty,le=m((e,t)=>Ho(e,"name",{value:t,configurable:!0}),"m$7");const Yo=le((e,t,o,n,r={})=>{const i=P.createFilter(r.include,r.exclude),s={},a=le((c,u)=>{s[c.replace($.ENDING_RE,"")]=u},"addOutput");async function l(c,u){if(!i(u))return;let p;try{const g=await Bt.parseAsync(c,{sourceFilename:u});p=JSON.parse(g.program)}catch{}if(p){const g=p.body.filter(v=>v.type==="ImportDeclaration"||v.type==="ExportAllDeclaration"||v.type==="ExportNamedDeclaration");for(const v of g){if(!v.source||f.basename(v.source.value).includes("."))continue;const w=await this.resolve(v.source.value,u);if(!(!w||w.external)&&(w.id.endsWith(".ts")||w.id.endsWith(".cts")||w.id.endsWith(".mts")||w.id.endsWith(".tsx")||w.id.endsWith(".ctsx")||w.id.endsWith(".mtsx"))){const x=w.id.replace(e+"/","");c=c.replaceAll('from "'+v.source.value+'"','from "'+zo(v.source.value,x)+'"')}}}const{errors:d,sourceText:h}=await t(u,c);if(d.length>0){if(r.ignoreErrors){this.warn(d[0]);return}return this.error(d[0])}if(a(u,h),!p)return;const y=p.body.filter(g=>g.type==="ImportDeclaration"?g.importKind==="type"?!0:g.specifiers?.every(v=>v.type==="ImportSpecifier"&&v.importKind==="type"):g.type==="ExportNamedDeclaration"||g.type==="ExportAllDeclaration"?g.exportKind==="type"?!0:g.type==="ExportNamedDeclaration"&&g.specifiers?.every(v=>v.type==="ExportSpecifier"&&v.exportKind==="type"):!1);for await(const g of y){if(!g.source)continue;const v=await this.resolve(g.source.value,u);if(!v)return;const w=v.id;if(i(w)&&!s[w.replace($.ENDING_RE,"")])try{const x=await k.readFile(w);await l.call(this,x,w)}catch{}}}return m(l,"h"),le(l,"transform"),{name:"packem:isolated-declarations",async renderStart(c,{input:u}){const p=Xo(...Array.isArray(u)?u:Object.values(u));typeof c.entryFileNames=="function"&&(c.entryFileNames=c.entryFileNames({name:c.name}));const d=c.entryFileNames.replace(/\.(.)?[jt]sx?$/,(h,y)=>`.d.${y||""}ts`);for await(let[h,y]of Object.entries(s)){if(n&&c.format==="cjs"){const v=Ke(y);v!==null&&(y=v.code)}const g=y.includes("from '")?"'":'"';(o===!0||o==="compatible")&&c.format==="cjs"&&this.emitFile({fileName:d.replace("[name]",f.relative(p,h)).replace(".cts",".ts"),source:y.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(v,w,x,j)=>w+g+(j||x)+".d.ts"+g+";"),type:"asset"}),this.emitFile({fileName:d.replace("[name]",f.relative(p,h)),source:y.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(v,w,x,j)=>w+g+(j||x)+(c.format==="cjs"?".d.cts":".d.mts")+g+";"),type:"asset"})}},transform:l}},"isolatedDeclarationsPlugin");var Qo=Object.defineProperty,Zo=m((e,t)=>Qo(e,"name",{value:t,configurable:!0}),"n$8");const ke="export default ",He=Zo(e=>{const t=to(e);return{...t,name:"packem:json",transform(o,n){const r=t.transform?.call(this,o,n);return r&&typeof r!="string"&&"code"in r&&r.code?.startsWith(ke)&&(r.code=r.code.replace(ke,"module.exports = ")),r}}},"JSONPlugin");class en{static{m(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(t=>this.replacement=t,"replace")}}replace(t,o,n,r){t&&o&&(n!=null?t[o][n]=r:t[o]=r)}remove(t,o,n){t&&o&&(n!=null?t[o].splice(n,1):delete t[o])}}class tn extends en{static{m(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(n=>this.replacement=n,"replace")},this.enter=t,this.leave=o}visit(t,o,n,r){if(t){if(this.enter){const s=this.should_skip,a=this.should_remove,l=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const c=this.should_skip,u=this.should_remove;if(this.should_skip=s,this.should_remove=a,this.replacement=l,c)return t;if(u)return null}let i;for(i in t){const s=t[i];if(s&&typeof s=="object")if(Array.isArray(s)){const a=s;for(let l=0;l<a.length;l+=1){const c=a[l];Ee(c)&&(this.visit(c,t,i,l)||l--)}}else Ee(s)&&this.visit(s,t,i,null)}if(this.leave){const s=this.replacement,a=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const l=this.should_remove;if(this.replacement=s,this.should_remove=a,l)return null}}return t}}function Ee(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(Ee,"isNode");function Ye(e,{enter:t,leave:o}){return new tn(t,o).visit(e,null)}m(Ye,"walk");var on=Object.defineProperty,nn=m((e,t)=>on(e,"name",{value:t,configurable:!0}),"u$8");const rn=nn(({attributes:e,logger:t})=>{const o=P.createFilter([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(n,r){if(!o(r))return null;let i=null;try{i=this.parse(n,{allowReturnOutsideFunction:!0})}catch(l){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${r}" and remove the jsx attribute.`}),t.warn(l),null}let s=!1;const a=new I(n);return Ye(i,{enter(l){if(l.type==="CallExpression"&&l.callee.type==="Identifier"&&l.callee.name==="jsx"){const c=l.arguments.filter(u=>u.type==="ObjectExpression"&&Array.isArray(u.properties));for(const u of c)for(const p of u.properties)p.type==="Property"&&p.key.type==="Literal"&&p.value.type==="Literal"&&e.includes(p.key.value)&&(a.overwrite(p.start-2,p.end,""),s=!0)}}}),s?{code:a.toString(),map:a.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var sn=Object.defineProperty,Qe=m((e,t)=>sn(e,"name",{value:t,configurable:!0}),"d$a");const an=Qe(e=>{const t=[],o=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):o.push(n)}),[...o.sort(),...t.sort()]},"sortLicenses"),Ze=Qe(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:n,marker:r,mode:i,packageName:s})=>oo({thirdParty(a){const l=new Set,c=a.sort(({name:p},{name:d})=>(p||0)>(d||0)?1:(d||0)>(p||0)?-1:0).map(({author:p,contributors:d,license:h,licenseText:y,maintainers:g,name:v,repository:w})=>{let x="## "+v+`
15
+ `),n},"generateCJSShimNode20_11"),Wo=re((e,t)=>{const o=C.createFilter(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(n,r,s){if(s.format==="es"&&o(r.fileName)){let i=Lo;if(e.engines?.node){const a=H.minVersion(e.engines.node);a&&a.major>=20&&a.minor>=11&&(i=Bo)}return Jo(n,i)}return null}}},"esmShimCjsSyntaxPlugin");var qo=Object.defineProperty,Uo=m((e,t)=>qo(e,"name",{value:t,configurable:!0}),"m$9");const Vo=Uo(()=>({name:"packem:fix-dynamic-import-extension",renderChunk(e,t,o){return o.format==="es"||o.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(o.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var zo=Object.defineProperty,Go=m((e,t)=>zo(e,"name",{value:t,configurable:!0}),"a$c");const Ko=Go((e,t)=>{const o=e.replace(/^\.\//,""),n=t.replace(/^\.\//,"");if(n.startsWith(o))return e+n.slice(o.length);if(e.endsWith(t))return e;const r=e.split("/"),s=t.split("/");let i=r.length-1,a=s.length-1;for(;i>=0&&a>=0&&r[i]===s[a];)i--,a--;const l=r.slice(0,i).join("/"),c=s.slice(a).join("/");return l+(c?"/"+c:"")},"extendString");var Xo=Object.defineProperty,Ho=m((e,t)=>Xo(e,"name",{value:t,configurable:!0}),"s$b");const Yo=Ho((...e)=>{if(e.length===0)return"";if(e.length===1)return f.dirname(e[0]);e=e.map(r=>f.toNamespacedPath(r));const[t,...o]=e;let n=t.split("/");for(const r of o){const s=r.split("/",n.length);let i=0;for(const a of s)if(a===n[i])i+=1;else{n=n.slice(0,i);break}n=n.slice(0,i)}return n.length<=1&&n[0]===""?`/${n[0]}`:n.join("/")},"lowestCommonAncestor");var Qo=Object.defineProperty,le=m((e,t)=>Qo(e,"name",{value:t,configurable:!0}),"m$7");const Zo=le((e,t,o,n,r={})=>{const s=C.createFilter(r.include,r.exclude),i={},a=le((c,u)=>{i[c.replace($.ENDING_RE,"")]=u},"addOutput");async function l(c,u){if(!s(u))return;let p;try{const g=await qt.parseAsync(c,{sourceFilename:u});p=JSON.parse(g.program)}catch{}if(p){const g=p.body.filter(v=>v.type==="ImportDeclaration"||v.type==="ExportAllDeclaration"||v.type==="ExportNamedDeclaration");for(const v of g){if(!v.source||f.basename(v.source.value).includes("."))continue;const w=await this.resolve(v.source.value,u);if(!(!w||w.external)&&(w.id.endsWith(".ts")||w.id.endsWith(".cts")||w.id.endsWith(".mts")||w.id.endsWith(".tsx")||w.id.endsWith(".ctsx")||w.id.endsWith(".mtsx"))){const x=w.id.replace(e+"/","");c=c.replaceAll('from "'+v.source.value+'"','from "'+Ko(v.source.value,x)+'"')}}}const{errors:d,sourceText:h}=await t(u,c);if(d.length>0){if(r.ignoreErrors){this.warn(d[0]);return}return this.error(d[0])}if(a(u,h),!p)return;const y=p.body.filter(g=>g.type==="ImportDeclaration"?g.importKind==="type"?!0:g.specifiers?.every(v=>v.type==="ImportSpecifier"&&v.importKind==="type"):g.type==="ExportNamedDeclaration"||g.type==="ExportAllDeclaration"?g.exportKind==="type"?!0:g.type==="ExportNamedDeclaration"&&g.specifiers?.every(v=>v.type==="ExportSpecifier"&&v.exportKind==="type"):!1);for await(const g of y){if(!g.source)continue;const v=await this.resolve(g.source.value,u);if(!v)return;const w=v.id;if(s(w)&&!i[w.replace($.ENDING_RE,"")])try{const x=await k.readFile(w);await l.call(this,x,w)}catch{}}}return m(l,"h"),le(l,"transform"),{name:"packem:isolated-declarations",async renderStart(c,{input:u}){const p=Yo(...Array.isArray(u)?u:Object.values(u));typeof c.entryFileNames=="function"&&(c.entryFileNames=c.entryFileNames({name:c.name}));const d=c.entryFileNames.replace(/\.(.)?[jt]sx?$/,(h,y)=>`.d.${y||""}ts`);for await(let[h,y]of Object.entries(i)){if(n&&c.format==="cjs"){const v=Ke(y);v!==null&&(y=v.code)}const g=y.includes("from '")?"'":'"';(o===!0||o==="compatible")&&c.format==="cjs"&&this.emitFile({fileName:d.replace("[name]",f.relative(p,h)).replace(".cts",".ts"),source:y.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(v,w,x,b)=>w+g+(b||x)+".d.ts"+g+";"),type:"asset"}),this.emitFile({fileName:d.replace("[name]",f.relative(p,h)),source:y.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(v,w,x,b)=>w+g+(b||x)+(c.format==="cjs"?".d.cts":".d.mts")+g+";"),type:"asset"})}},transform:l}},"isolatedDeclarationsPlugin");var en=Object.defineProperty,tn=m((e,t)=>en(e,"name",{value:t,configurable:!0}),"n$9");const ke="export default ",He=tn(e=>{const t=no(e);return{...t,name:"packem:json",transform(o,n){const r=t.transform?.call(this,o,n);return r&&typeof r!="string"&&"code"in r&&r.code?.startsWith(ke)&&(r.code=r.code.replace(ke,"module.exports = ")),r}}},"JSONPlugin");class on{static{m(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(t=>this.replacement=t,"replace")}}replace(t,o,n,r){t&&o&&(n!=null?t[o][n]=r:t[o]=r)}remove(t,o,n){t&&o&&(n!=null?t[o].splice(n,1):delete t[o])}}class nn extends on{static{m(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(n=>this.replacement=n,"replace")},this.enter=t,this.leave=o}visit(t,o,n,r){if(t){if(this.enter){const i=this.should_skip,a=this.should_remove,l=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const c=this.should_skip,u=this.should_remove;if(this.should_skip=i,this.should_remove=a,this.replacement=l,c)return t;if(u)return null}let s;for(s in t){const i=t[s];if(i&&typeof i=="object")if(Array.isArray(i)){const a=i;for(let l=0;l<a.length;l+=1){const c=a[l];Ee(c)&&(this.visit(c,t,s,l)||l--)}}else Ee(i)&&this.visit(i,t,s,null)}if(this.leave){const i=this.replacement,a=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const l=this.should_remove;if(this.replacement=i,this.should_remove=a,l)return null}}return t}}function Ee(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(Ee,"isNode");function Ye(e,{enter:t,leave:o}){return new nn(t,o).visit(e,null)}m(Ye,"walk");var rn=Object.defineProperty,sn=m((e,t)=>rn(e,"name",{value:t,configurable:!0}),"u$8");const an=sn(({attributes:e,logger:t})=>{const o=C.createFilter([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(n,r){if(!o(r))return null;let s=null;try{s=this.parse(n,{allowReturnOutsideFunction:!0})}catch(l){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${r}" and remove the jsx attribute.`}),t.warn(l),null}let i=!1;const a=new I(n);return Ye(s,{enter(l){if(l.type==="CallExpression"&&l.callee.type==="Identifier"&&l.callee.name==="jsx"){const c=l.arguments.filter(u=>u.type==="ObjectExpression"&&Array.isArray(u.properties));for(const u of c)for(const p of u.properties)p.type==="Property"&&p.key.type==="Literal"&&p.value.type==="Literal"&&e.includes(p.key.value)&&(a.overwrite(p.start-2,p.end,""),i=!0)}}}),i?{code:a.toString(),map:a.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var ln=Object.defineProperty,Qe=m((e,t)=>ln(e,"name",{value:t,configurable:!0}),"d$a");const cn=Qe(e=>{const t=[],o=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):o.push(n)}),[...o.sort(),...t.sort()]},"sortLicenses"),Ze=Qe(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:n,marker:r,mode:s,packageName:i})=>ro({thirdParty(a){const l=new Set,c=a.sort(({name:p},{name:d})=>(p||0)>(d||0)?1:(d||0)>(p||0)?-1:0).map(({author:p,contributors:d,license:h,licenseText:y,maintainers:g,name:v,repository:w})=>{let x="## "+v+`
16
16
  `;h&&(x+=`License: ${h}
17
- `);const j=new Set;for(const C of[p,...g,...d]){const U=typeof C=="string"?C:C?.name;U&&j.add(U)}return j.size>0&&(x+=`By: ${[...j].join(", ")}
17
+ `);const b=new Set;for(const P of[p,...g,...d]){const U=typeof P=="string"?P:P?.name;U&&b.add(U)}return b.size>0&&(x+=`By: ${[...b].join(", ")}
18
18
  `),w&&(x+=`Repository: ${typeof w=="string"?w:w.url}
19
19
  `),y&&(x+=`
20
20
  `+y.trim().replaceAll(/\r\n|\r/g,`
21
21
  `).replaceAll(`<!-- ${r} -->`,"").replaceAll(e?`<!-- ${e} -->`:"","").replaceAll(`<!-- /${r} -->`,"").replaceAll(e?`<!-- /${e} -->`:"","").trim().split(`
22
- `).map(C=>C?`> ${C}`:">").join(`
22
+ `).map(P=>P?`> ${P}`:">").join(`
23
23
  `)+`
24
24
  `),h&&l.add(h),x}).join(`
25
25
  ---------------------------------------
26
26
 
27
- `);if(c===""){n.info({message:"No dependencies license information found.",prefix:"plugin:license:"+i});return}const u=o(an(l),c,s);try{const p=k.readFileSync(t),d=We.g(p,r,u);if(!d){n.error({message:`Could not find the license marker: <!-- ${r} --><!-- /${r} --> in ${t}`,prefix:"plugin:license:"+i});return}p!==d&&(k.writeFileSync(t,d),n.info({message:`${t} updated.`,prefix:"plugin:license:"+i}))}catch(p){n.error(p)}}}),"license");var ln=Object.defineProperty,cn=m((e,t)=>ln(e,"name",{value:t,configurable:!0}),"i$7");const pn=cn(e=>({async buildEnd(){const t=[];for(const n of this.getModuleIds()){const r=this.getModuleInfo(n);if(r!=null&&!r.isExternal)for(const i of r.importedIds)t.push({source:n,target:i})}if(Array.isArray(t)&&t.length===0)return;const o=f.resolve(e.rootDir,e.outDir,"graph.json");k.writeJsonSync(o,t)},name:"packem:metafile"}),"metafilePlugin");var un=Object.defineProperty,dn=m((e,t)=>un(e,"name",{value:t,configurable:!0}),"g$6");let xe=!1;const fn=dn((e,t,o,n,r,i)=>{if(i!=="*"&&H.valid(H.coerce(i))===null)throw new Error("Invalid typeScriptVersion option. It must be a valid semver range.");return{name:"packem:node10-compatibility",writeBundle(){xe||(e.info({message:"Declaration node10 compatibility mode is enabled.",prefix:"plugin:node10-compatibility"}),xe=!0);const s={};for(const c of t)for(const u of c.exportKey)u.includes("/*")?s[u]=["./"+f.join(o,f.dirname(c.name),"*.d.ts")]:s[u]=[...s[u]??[],"./"+f.join(o,c.name+".d.ts")];const a=f.join(n,"package.json"),l=k.readJsonSync(a);r==="file"&&Object.keys(s).length>0?(k.writeJsonSync(a,{...l,typesVersions:{...l.typesVersions,[i]:s}},{detectIndent:!0}),e.info({message:'Your package.json "typesVersions" field has been updated.',prefix:"plugin:node10-compatibility"})):Object.keys(s).length>0&&e.info({message:`Please add the following field into your package.json to enable node 10 compatibility:
27
+ `);if(c===""){n.info({message:"No dependencies license information found.",prefix:"plugin:license:"+s});return}const u=o(cn(l),c,i);try{const p=k.readFileSync(t),d=We.g(p,r,u);if(!d){n.error({message:`Could not find the license marker: <!-- ${r} --><!-- /${r} --> in ${t}`,prefix:"plugin:license:"+s});return}p!==d&&(k.writeFileSync(t,d),n.info({message:`${t} updated.`,prefix:"plugin:license:"+s}))}catch(p){n.error(p)}}}),"license");var pn=Object.defineProperty,un=m((e,t)=>pn(e,"name",{value:t,configurable:!0}),"i$7");const dn=un(e=>({async buildEnd(){const t=[];for(const n of this.getModuleIds()){const r=this.getModuleInfo(n);if(r!=null&&!r.isExternal)for(const s of r.importedIds)t.push({source:n,target:s})}if(Array.isArray(t)&&t.length===0)return;const o=f.resolve(e.rootDir,e.outDir,"graph.json");k.writeJsonSync(o,t)},name:"packem:metafile"}),"metafilePlugin");var fn=Object.defineProperty,mn=m((e,t)=>fn(e,"name",{value:t,configurable:!0}),"g$5");let xe=!1;const gn=mn((e,t,o,n,r,s)=>{if(s!=="*"&&H.valid(H.coerce(s))===null)throw new Error("Invalid typeScriptVersion option. It must be a valid semver range.");return{name:"packem:node10-compatibility",writeBundle(){xe||(e.info({message:"Declaration node10 compatibility mode is enabled.",prefix:"plugin:node10-compatibility"}),xe=!0);const i={};for(const c of t)for(const u of c.exportKey)u.includes("/*")?i[u]=["./"+f.join(o,f.dirname(c.name),"*.d.ts")]:i[u]=[...i[u]??[],"./"+f.join(o,c.name+".d.ts")];const a=f.join(n,"package.json"),l=k.readJsonSync(a);r==="file"&&Object.keys(i).length>0?(k.writeJsonSync(a,{...l,typesVersions:{...l.typesVersions,[s]:i}},{detectIndent:!0}),e.info({message:'Your package.json "typesVersions" field has been updated.',prefix:"plugin:node10-compatibility"})):Object.keys(i).length>0&&e.info({message:`Please add the following field into your package.json to enable node 10 compatibility:
28
28
 
29
- ${JSON.stringify({typesVersions:{"*":s}},null,4)}
30
- `,prefix:"plugin:node10-compatibility"})}}},"node10CompatibilityPlugin");var mn=Object.defineProperty,gn=m((e,t)=>mn(e,"name",{value:t,configurable:!0}),"r$9");const R=gn(e=>{const t=Ut.createHash("md5");return t.update(e),t.digest("hex")},"getHash");var hn=Object.defineProperty,et=m((e,t)=>hn(e,"name",{value:t,configurable:!0}),"d$9");const J=et(e=>e.handler||e,"getHandler"),S=et((e,t,o="")=>({...e,async buildEnd(n){e.buildEnd&&await J(e.buildEnd).call(this,n)},async buildStart(n){e.buildStart&&await J(e.buildStart).call(this,n)},async load(n){if(!e.load)return null;const r=f.join(o,e.name),i=f.join("load",R(n));if(t.has(i,r))return await t.get(i,r);const s=await J(e.load).call(this,n);return t.set(i,s,r),s},name:`cached(${e.name})`,async resolveId(n,r,i){if(!e.resolveId)return null;const s=f.join(o,e.name),a=f.join("resolveId",R(n),r?R(r):"",R(JSON.stringify(i)));if(t.has(a,s))return await t.get(a,s);const l=await J(e.resolveId).call(this,n,r,i);return t.set(a,l,s),l},async transform(n,r){if(!e.transform)return null;const i=f.join(o,e.name),s=f.join("transform",R(r),R(n));if(t.has(s,i))return await t.get(s,i);const a=await J(e.transform).call(this,n,r);return t.set(s,a,i),a}}),"cachingPlugin");var yn=Object.defineProperty,vn=m((e,t)=>yn(e,"name",{value:t,configurable:!0}),"n$7");const bn=vn(()=>({name:"packem:prepend-directive",transform:{handler(e,t){const o=this.getModuleInfo(t);if(o?.meta.preserveDirectives){const n=o.meta.preserveDirectives.directives[0];if(n)return`'${n.value}';
31
- `+e}return null},order:"post"}}),"prependDirectivePlugin");var jn=Object.defineProperty,wn=m((e,t)=>jn(e,"name",{value:t,configurable:!0}),"c$8");const $n=wn(({directiveRegex:e,exclude:t=[],include:o=[],logger:n})=>{const r={},i={},s=P.createFilter(o,t);return{name:"packem:preserve-directives",onLog(a,l){return l.code==="MODULE_LEVEL_DIRECTIVE"&&a==="warn"?!1:null},renderChunk:{handler(a,l,{sourcemap:c}){const u=l.moduleIds.map(h=>r[h]?r[h]:null).reduce((h,y)=>(y&&y.forEach(g=>{h.add(g)}),h),new Set),p=new I(a);u.size>0&&(n.debug({message:`directives for chunk "${l.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),p.prepend(`${[...u].map(h=>`'${h}';`).join(`
29
+ ${JSON.stringify({typesVersions:{"*":i}},null,4)}
30
+ `,prefix:"plugin:node10-compatibility"})}}},"node10CompatibilityPlugin");var hn=Object.defineProperty,yn=m((e,t)=>hn(e,"name",{value:t,configurable:!0}),"r$9");const T=yn(e=>{const t=zt.createHash("md5");return t.update(e),t.digest("hex")},"getHash");var vn=Object.defineProperty,et=m((e,t)=>vn(e,"name",{value:t,configurable:!0}),"d$9");const J=et(e=>e.handler||e,"getHandler"),S=et((e,t,o="")=>({...e,async buildEnd(n){e.buildEnd&&await J(e.buildEnd).call(this,n)},async buildStart(n){e.buildStart&&await J(e.buildStart).call(this,n)},async load(n){if(!e.load)return null;const r=f.join(o,e.name),s=f.join("load",T(n));if(t.has(s,r))return await t.get(s,r);const i=await J(e.load).call(this,n);return t.set(s,i,r),i},name:`cached(${e.name})`,async resolveId(n,r,s){if(!e.resolveId)return null;const i=f.join(o,e.name),a=f.join("resolveId",T(n),r?T(r):"",T(JSON.stringify(s)));if(t.has(a,i))return await t.get(a,i);const l=await J(e.resolveId).call(this,n,r,s);return t.set(a,l,i),l},async transform(n,r){if(!e.transform)return null;const s=f.join(o,e.name),i=f.join("transform",T(r),T(n));if(t.has(i,s))return await t.get(i,s);const a=await J(e.transform).call(this,n,r);return t.set(i,a,s),a}}),"cachingPlugin");var bn=Object.defineProperty,jn=m((e,t)=>bn(e,"name",{value:t,configurable:!0}),"n$8");const wn=jn(()=>({name:"packem:prepend-directive",transform:{handler(e,t){const o=this.getModuleInfo(t);if(o?.meta.preserveDirectives){const n=o.meta.preserveDirectives.directives[0];if(n)return`'${n.value}';
31
+ `+e}return null},order:"post"}}),"prependDirectivePlugin");var $n=Object.defineProperty,kn=m((e,t)=>$n(e,"name",{value:t,configurable:!0}),"c$8");const En=kn(({directiveRegex:e,exclude:t=[],include:o=[],logger:n})=>{const r={},s={},i=C.createFilter(o,t);return{name:"packem:preserve-directives",onLog(a,l){return l.code==="MODULE_LEVEL_DIRECTIVE"&&a==="warn"?!1:null},renderChunk:{handler(a,l,{sourcemap:c}){const u=l.moduleIds.map(h=>r[h]?r[h]:null).reduce((h,y)=>(y&&y.forEach(g=>{h.add(g)}),h),new Set),p=new I(a);u.size>0&&(n.debug({message:`directives for chunk "${l.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),p.prepend(`${[...u].map(h=>`'${h}';`).join(`
32
32
  `)}
33
- `));let d;return l.facadeModuleId&&typeof i[l.facadeModuleId]=="string"&&(d=i[l.facadeModuleId]),d&&(n.debug({message:`shebang for chunk "${l.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),p.prepend(`${d}
34
- `)),u.size===0&&d===void 0?null:{code:p.toString(),map:c?p.generateMap({hires:!0}):null}},order:"post"},transform(a,l){if(!s(l))return null;let c=!1;const u=new I(a);if(a.startsWith("#")&&a[1]==="!"){let d=0;for(let h=2,y=a.length;h<y;h++){const g=a.codePointAt(h);if(g===10||g===13||g===8232||g===8233){d=h;break}}d&&(i[l]=a.slice(0,d),u.remove(0,d+1),c=!0,n.debug({message:`shebang for module "${l}" is preserved.`,prefix:"plugin:preserve-directives"}))}let p=null;try{p=this.parse(u.toString(),{allowReturnOutsideFunction:!0})}catch(d){return this.warn({code:"PARSE_ERROR",message:`failed to parse "${l}" and extract the directives.`}),n.warn(d),null}if(p.type!=="Program")return null;for(const d of p.body.filter(Boolean)){if(d.type!=="ExpressionStatement")break;let h=null;"directive"in d?h=d.directive:d.expression.type==="Literal"&&typeof d.expression.value=="string"&&e.test(d.expression.value)&&(h=d.expression.value),h!=="use strict"&&h&&(r[l]||=new Set,r[l].add(h),"start"in d&&typeof d.start=="number"&&"end"in d&&typeof d.end=="number"&&(u.remove(d.start,d.end),c=!0),n.debug({message:`directive "${h}" for module "${l}" is preserved.`,prefix:"plugin:preserve-directives"}))}return c?{code:u.toString(),map:u.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...r[l]??[]],shebang:i[l]??null}}}:null}}},"preserveDirectives");var kn=Object.defineProperty,En=m((e,t)=>kn(e,"name",{value:t,configurable:!0}),"n$6");const xn=En(e=>{const t=P.createFilter(e.include,e.exclude);return{async load(o){return o.includes("?raw")?await this.load({id:o.replace(/\?raw$/,"")}):null},name:"packem:raw",transform(o,n){return!t(n)&&!n.includes("?raw")?null:(n.includes("?raw")||(o=`export default ${JSON.stringify(o)}`),{code:o,map:{mappings:""}})}}},"rawPlugin");var Sn=Object.defineProperty,On=m((e,t)=>Sn(e,"name",{value:t,configurable:!0}),"r$8");const tt=On(()=>({name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return Vt.fileURLToPath(e)}}),"resolveFileUrl");var Dn=Object.defineProperty,ie=m((e,t)=>Dn(e,"name",{value:t,configurable:!0}),"i$5");const Q=/^#![^\n]*/,fe=ie(async e=>{await ne.chmod(e,493).catch(()=>{})},"makeExecutable"),Nn=ie((e,t)=>({name:"packem:shebang",renderChunk:{handler(o,n,r){if(!n.isEntry||!n.facadeModuleId)return null;const i=o.startsWith("#")&&o[1]==="!";if(i&&t.replace)return o.replace(Q,t.shebang+`
35
- `);if(i)return null;if(e.includes(n.name)){const s=new I(o);return s.prepend(t.shebang+`
36
- `),{code:s.toString(),map:r.sourcemap?s.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,n){for(const[r,i]of Object.entries(n))if(i.type==="chunk"&&Q.test(i.code)&&o.dir){const s=f.resolve(o.dir,r);await fe(s)}}}),"shebangPlugin"),_n=ie(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(Q,"")}}),"removeShebangPlugin"),Pn=ie((e,t=`
37
- `)=>{const o=Q.exec(e);return o?o+t:""},"getShebang");var Cn=Object.defineProperty,A=m((e,t)=>Cn(e,"name",{value:t,configurable:!0}),"r$7");const Rn=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Tn=/MIT License|MIT license|BSD license/,In=/\n{2,}/g,An=/\b(\w+)\$\d+\b/g,Mn=/[-/\\^$*+?.()|[\]{}]/g,Fn=A(e=>e.replaceAll(Mn,"\\$&"),"escapeRegex"),Jn=A(e=>[...new Set(e)],"unique"),Ln=A(e=>e.replaceAll(Rn,t=>Tn.test(t)?"":t).replaceAll(In,`
33
+ `));let d;return l.facadeModuleId&&typeof s[l.facadeModuleId]=="string"&&(d=s[l.facadeModuleId]),d&&(n.debug({message:`shebang for chunk "${l.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),p.prepend(`${d}
34
+ `)),u.size===0&&d===void 0?null:{code:p.toString(),map:c?p.generateMap({hires:!0}):null}},order:"post"},transform(a,l){if(!i(l))return null;let c=!1;const u=new I(a);if(a.startsWith("#")&&a[1]==="!"){let d=0;for(let h=2,y=a.length;h<y;h++){const g=a.codePointAt(h);if(g===10||g===13||g===8232||g===8233){d=h;break}}d&&(s[l]=a.slice(0,d),u.remove(0,d+1),c=!0,n.debug({message:`shebang for module "${l}" is preserved.`,prefix:"plugin:preserve-directives"}))}let p=null;try{p=this.parse(u.toString(),{allowReturnOutsideFunction:!0})}catch(d){return this.warn({code:"PARSE_ERROR",message:`failed to parse "${l}" and extract the directives.`}),n.warn(d),null}if(p.type!=="Program")return null;for(const d of p.body.filter(Boolean)){if(d.type!=="ExpressionStatement")break;let h=null;"directive"in d?h=d.directive:d.expression.type==="Literal"&&typeof d.expression.value=="string"&&e.test(d.expression.value)&&(h=d.expression.value),h!=="use strict"&&h&&(r[l]||=new Set,r[l].add(h),"start"in d&&typeof d.start=="number"&&"end"in d&&typeof d.end=="number"&&(u.remove(d.start,d.end),c=!0),n.debug({message:`directive "${h}" for module "${l}" is preserved.`,prefix:"plugin:preserve-directives"}))}return c?{code:u.toString(),map:u.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...r[l]??[]],shebang:s[l]??null}}}:null}}},"preserveDirectives");var xn=Object.defineProperty,Sn=m((e,t)=>xn(e,"name",{value:t,configurable:!0}),"n$7");const On=Sn(e=>{const t=C.createFilter(e.include,e.exclude);return{async load(o){return o.includes("?raw")?await this.load({id:o.replace(/\?raw$/,"")}):null},name:"packem:raw",transform(o,n){return!t(n)&&!n.includes("?raw")?null:(n.includes("?raw")||(o=`export default ${JSON.stringify(o)}`),{code:o,map:{mappings:""}})}}},"rawPlugin");var Dn=Object.defineProperty,Nn=m((e,t)=>Dn(e,"name",{value:t,configurable:!0}),"r$8");const tt=Nn(()=>({name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return Gt.fileURLToPath(e)}}),"resolveFileUrl");var _n=Object.defineProperty,ie=m((e,t)=>_n(e,"name",{value:t,configurable:!0}),"i$5");const Q=/^#![^\n]*/,fe=ie(async e=>{await ne.chmod(e,493).catch(()=>{})},"makeExecutable"),Pn=ie((e,t)=>({name:"packem:shebang",renderChunk:{handler(o,n,r){if(!n.isEntry||!n.facadeModuleId)return null;const s=o.startsWith("#")&&o[1]==="!";if(s&&t.replace)return o.replace(Q,t.shebang+`
35
+ `);if(s)return null;if(e.includes(n.name)){const i=new I(o);return i.prepend(t.shebang+`
36
+ `),{code:i.toString(),map:r.sourcemap?i.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,n){for(const[r,s]of Object.entries(n))if(s.type==="chunk"&&Q.test(s.code)&&o.dir){const i=f.resolve(o.dir,r);await fe(i)}}}),"shebangPlugin"),Cn=ie(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(Q,"")}}),"removeShebangPlugin"),Tn=ie((e,t=`
37
+ `)=>{const o=Q.exec(e);return o?o+t:""},"getShebang");var Rn=Object.defineProperty,A=m((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"r$7");const In=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,An=/MIT License|MIT license|BSD license/,Mn=/\n{2,}/g,Fn=/\b(\w+)\$\d+\b/g,Jn=/[-/\\^$*+?.()|[\]{}]/g,Ln=A(e=>e.replaceAll(Jn,"\\$&"),"escapeRegex"),Bn=A(e=>[...new Set(e)],"unique"),Wn=A(e=>e.replaceAll(In,t=>An.test(t)?"":t).replaceAll(Mn,`
38
38
 
39
- `),"cleanUnnecessaryComments"),Se=new Map;function ot(e,t,{identifierReplacements:o},n){const r=F.findStaticImports(e);for(const s in o){const a=r.find(c=>c.specifier===s&&c.imports.includes("{"));if(!a){this.warn(`${t.fileName} does not import "${s}" for replacement`),process.exitCode=1;continue}const l=o[s];for(const c in l){if(!a.imports.includes(c))throw new Error(`${t.fileName} does not import "${c}" from "${s}" for replacement`);const u=l[c],p=Fn(c);u.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${p},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${p}\\b`,"g"),u)}}const i=Jn(Array.from(e.matchAll(An),s=>s[0]));if(i.length>0){const s=i.map(l=>`
40
- - ${l}`).join(""),a=t.fileName.replace(/\.[^/.]+$/,"");Se.has(a)||n.warn({message:`${t.fileName} contains confusing identifier names${s}
39
+ `),"cleanUnnecessaryComments"),Se=new Map;function ot(e,t,{identifierReplacements:o},n){const r=F.findStaticImports(e);for(const i in o){const a=r.find(c=>c.specifier===i&&c.imports.includes("{"));if(!a){this.warn(`${t.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const l=o[i];for(const c in l){if(!a.imports.includes(c))throw new Error(`${t.fileName} does not import "${c}" from "${i}" for replacement`);const u=l[c],p=Ln(c);u.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${p},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${p}\\b`,"g"),u)}}const s=Bn(Array.from(e.matchAll(Fn),i=>i[0]));if(s.length>0){const i=s.map(l=>`
40
+ - ${l}`).join(""),a=t.fileName.replace(/\.[^/.]+$/,"");Se.has(a)||n.warn({message:`${t.fileName} contains confusing identifier names${i}
41
41
 
42
- To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),Se.set(a,!0)}return e}m(ot,"I");A(ot,"replaceConfusingTypeNames");const Bn=A((e,t)=>{if(t.leadingComments?.some(o=>o.type==="CommentBlock"&&o.value.includes("@internal"))){const o=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,o),!0}return!1},"removeInternal");function nt(e,t){if(e.includes("@internal")){const o=new I(e),n=zt.parse(e,{plugins:["typescript"],sourceType:"module"});if(Ye(n,{enter(r){Bn(o,r)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}m(nt,"S$1");A(nt,"stripInternalTypes");const Wn=A((e,t)=>({name:"packem:patch-types",renderChunk(o,n){return o=ot.call(this,o,n,e,t),o=nt.call(this,o,n),o=Ln(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var qn=Object.defineProperty,rt=m((e,t)=>qn(e,"name",{value:t,configurable:!0}),"m$6");const it=rt((e,t=!0)=>{if(!e)return null;const{config:o,path:n}=e;if(!o.compilerOptions)return null;const{baseUrl:r,paths:i}=o.compilerOptions;if(!r)return null;const s=f.resolve(f.dirname(n),r),a=[];if(i)for(const[l,c]of Object.entries(i)){let u;l==="@"||l==="~"||l==="#"?u=new RegExp(`^${l}/(.+)$`):u=new RegExp(`^${[...l].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let p=0;for(const d of c){const h=[...P.normalizePath(f.resolve(s,d))].map(y=>y==="*"?"$"+(++p+""):y==="$"?"$$":y).join("");a.push({find:u,replacement:h})}}return t&&a.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...P.normalizePath(s)].map(l=>l==="$"?"$$":l).join("")}/$1`}),a},"getConfigAlias"),st=rt((e,t)=>{const o=it(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,r,i){if(!o||n.includes("\0"))return null;for(const{find:s,replacement:a}of o)if(s.test(n)){const l=n.replace(s,a),c=await this.resolve(l,r,{skipSelf:!0,...i});if(c)return t.debug({message:`Resolved ${n} to ${c.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),c.id}return null}}},"resolveTsconfigPaths");var Un=Object.defineProperty,at=m((e,t)=>Un(e,"name",{value:t,configurable:!0}),"u$5");const Vn=at((e,t)=>{if(!t)return null;const{config:o,path:n}=t;if(!o.compilerOptions)return null;const{rootDirs:r}=o.compilerOptions;if(!r)return null;const i=[];for(const s of r){if(s.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${n}.`);if(s.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${n}.`);i.push(f.resolve(e,s))}return i},"getRootDirectories"),lt=at((e,t,o)=>{const n=Vn(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(r,i,s){if(n===null||n.length===0)return null;if(r.startsWith("."))for(const a of n){const l=f.join(a,r),c=await this.resolve(l,i,{skipSelf:!0,...s});if(c)return t.debug({message:`Resolved ${r} to ${c.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),c.id}return null}}},"resolveTsconfigRootDirectories");var zn=Object.defineProperty,Gn=m((e,t)=>zn(e,"name",{value:t,configurable:!0}),"r$6");const ct=Gn(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,o,n){return e.test(t)&&o?await this.resolve(t.replace(/js(x?)$/,"ts$1"),o,n):null}}},"resolveTypescriptMjsCts");var Kn=Object.defineProperty,pt=m((e,t)=>Kn(e,"name",{value:t,configurable:!0}),"u$4");const Oe=pt((e,t,o,n)=>{const r=e.findIndex(s=>typeof s=="object"?s.name===o:!1);if(r===-1)throw new Error(`Plugin with name "${o}" was not found, try one of: ${e.map(s=>{if(typeof s=="object")return s.name}).filter(Boolean).join(", ")}`);const i=n?r+1:r;return e.splice(i,0,t),e},"appendPlugin"),ut=pt((e,t)=>{if(!t)return e;for(const{after:o=void 0,before:n=void 0,plugin:r}of t)e=o?Oe(e,r,o,!0):Oe(e,r,n,!1);return e},"appendPlugins");var Xn=Object.defineProperty,Hn=m((e,t)=>Xn(e,"name",{value:t,configurable:!0}),"s$7");const Yn=Hn(e=>{const t=f.basename(e).split(".");if(t.length>=2){const[o,n]=t.slice(-2),r=t[0],i=/^(\w+)-runtime$/.exec(o)?.[1];if($.DEFAULT_EXTENSIONS.includes(n)&&i&&i.length>0)return r+"-"+i}},"getCustomModuleLayer");var Qn=Object.defineProperty,Zn=m((e,t)=>Qn(e,"name",{value:t,configurable:!0}),"i$4");const ce=Zn(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var er=Object.defineProperty,De=m((e,t)=>er(e,"name",{value:t,configurable:!0}),"d$7");const tr=De((e,t)=>{const o=new Map;return De(function(n,r){const i=r.getModuleInfo(n);if(!i)return;const{isEntry:s}=i,a=i.meta,l=ce(a);if(!s){const c=o.get(n);if(c)return c;const u=Yn(n);if(u)return o.set(n,u),u}if(s){const c=r.getModuleIds();for(const u of c)r.getModuleInfo(u)&&ce(a)===l&&(e.has(u)||e.set(u,new Set),e.get(u).add([n,l]))}if(l&&!s&&e.has(n)){const c=[...e.get(n)];if(c.some(([p])=>{if(t.some(d=>d.path===p)){const d=r.getModuleInfo(p);return ce(d?d.meta:{})===l}return!1}))return;if(c.every(([,p])=>p===l))return o.has(n)?o.get(n):void 0;const u=f.basename(n,f.extname(n))+"-"+l;return o.set(n,u),u}},"splitChunks")},"createSplitChunks");var or=Object.defineProperty,nr=m((e,t)=>or(e,"name",{value:t,configurable:!0}),"n$4");const T=nr((e,t)=>e.isDynamicEntry?`${$.CHUNKS_PACKEM_FOLDER}/[name].${t}`:`${$.SHARED_PACKEM_FOLDER}/${e.name}-[hash].${t}`,"getChunkFilename");var rr=Object.defineProperty,ir=m((e,t)=>rr(e,"name",{value:t,configurable:!0}),"o$4");const sr=process.platform==="win32",Ne=ir((e,t)=>{const o=sr?"\\":"/";for(let n of Array.isArray(e.names)?e.names:[]){if(n.includes("node_modules"+o+".pnpm"))return n=n.replace("node_modules"+o+".pnpm","external")+"."+t,n.replace("node_modules"+o,"");if(n.includes("node_modules"))return n.replace("node_modules","external")+"."+t}return"[name]."+t},"getEntryFileNames");var ar=Object.defineProperty,lr=m((e,t)=>ar(e,"name",{value:t,configurable:!0}),"p$2");const ye=lr((e,t)=>{let o={};if(e.pkg.name&&(o[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:n}=e.pkg;for(const r in n){if(r.startsWith("#"))continue;const i=n[r];typeof i=="string"&&(o[r]=f.join(e.options.rootDir,i))}}return o={...o,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(o,Object.fromEntries(e.options.rollup.alias.entries.map(n=>[n.find,n.replacement]))):Object.assign(o,e.options.rollup.alias.entries??e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(o),prefix:t}),o},"resolveAliases");var cr=Object.defineProperty,O=m((e,t)=>cr(e,"name",{value:t,configurable:!0}),"p$1");const pr=O((e,t)=>{if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");t.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(t.logger.warn(["ES3 target is not supported by esbuild, so ES5 will be used instead..","Please set 'target' option in tsconfig to at least ES5 to disable this error"].join(" ")),t.tsconfig.config.compilerOptions.target="es5",t.options.rollup.esbuild.target="es5");let o="node"+ge.versions.node.split(".")[0];if(t.pkg.engines?.node){const n=H.minVersion(t.pkg.engines.node);n&&(o="node"+n.major)}if(t.options.rollup.esbuild.target){const n=L(t.options.rollup.esbuild.target);n.some(r=>r.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...L(o),...n])])}else t.options.rollup.esbuild.target=L(o);return t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{logger:t.logger,minify:t.options.minify,minifyWhitespace:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{topLevel:!0},sourceMap:t.options.sourcemap,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return t.options.rollup.sucrase}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),dt=O((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT")throw new Error(`Failed to resolve the module "${e.exporter}" imported by "${b.cyan(f.relative(f.resolve(),e.id))}"
42
+ To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),Se.set(a,!0)}return e}m(ot,"I");A(ot,"replaceConfusingTypeNames");const qn=A((e,t)=>{if(t.leadingComments?.some(o=>o.type==="CommentBlock"&&o.value.includes("@internal"))){const o=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,o),!0}return!1},"removeInternal");function nt(e,t){if(e.includes("@internal")){const o=new I(e),n=Kt.parse(e,{plugins:["typescript"],sourceType:"module"});if(Ye(n,{enter(r){qn(o,r)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}m(nt,"S$1");A(nt,"stripInternalTypes");const Un=A((e,t)=>({name:"packem:patch-types",renderChunk(o,n){return o=ot.call(this,o,n,e,t),o=nt.call(this,o,n),o=Wn(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var Vn=Object.defineProperty,rt=m((e,t)=>Vn(e,"name",{value:t,configurable:!0}),"m$6");const it=rt((e,t=!0)=>{if(!e)return null;const{config:o,path:n}=e;if(!o.compilerOptions)return null;const{baseUrl:r,paths:s}=o.compilerOptions;if(!r)return null;const i=f.resolve(f.dirname(n),r),a=[];if(s)for(const[l,c]of Object.entries(s)){let u;l==="@"||l==="~"||l==="#"?u=new RegExp(`^${l}/(.+)$`):u=new RegExp(`^${[...l].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let p=0;for(const d of c){const h=[...C.normalizePath(f.resolve(i,d))].map(y=>y==="*"?"$"+(++p+""):y==="$"?"$$":y).join("");a.push({find:u,replacement:h})}}return t&&a.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...C.normalizePath(i)].map(l=>l==="$"?"$$":l).join("")}/$1`}),a},"getConfigAlias"),st=rt((e,t)=>{const o=it(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,r,s){if(!o||n.includes("\0"))return null;for(const{find:i,replacement:a}of o)if(i.test(n)){const l=n.replace(i,a),c=await this.resolve(l,r,{skipSelf:!0,...s});if(c)return t.debug({message:`Resolved ${n} to ${c.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),c.id}return null}}},"resolveTsconfigPaths");var zn=Object.defineProperty,at=m((e,t)=>zn(e,"name",{value:t,configurable:!0}),"u$5");const Gn=at((e,t)=>{if(!t)return null;const{config:o,path:n}=t;if(!o.compilerOptions)return null;const{rootDirs:r}=o.compilerOptions;if(!r)return null;const s=[];for(const i of r){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${n}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${n}.`);s.push(f.resolve(e,i))}return s},"getRootDirectories"),lt=at((e,t,o)=>{const n=Gn(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(r,s,i){if(n===null||n.length===0)return null;if(r.startsWith("."))for(const a of n){const l=f.join(a,r),c=await this.resolve(l,s,{skipSelf:!0,...i});if(c)return t.debug({message:`Resolved ${r} to ${c.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),c.id}return null}}},"resolveTsconfigRootDirectories");var Kn=Object.defineProperty,Xn=m((e,t)=>Kn(e,"name",{value:t,configurable:!0}),"r$6");const ct=Xn(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,o,n){return e.test(t)&&o?await this.resolve(t.replace(/js(x?)$/,"ts$1"),o,n):null}}},"resolveTypescriptMjsCts");var Hn=Object.defineProperty,pt=m((e,t)=>Hn(e,"name",{value:t,configurable:!0}),"u$4");const Oe=pt((e,t,o,n)=>{const r=e.findIndex(i=>typeof i=="object"?i.name===o:!1);if(r===-1)throw new Error(`Plugin with name "${o}" was not found, try one of: ${e.map(i=>{if(typeof i=="object")return i.name}).filter(Boolean).join(", ")}`);const s=n?r+1:r;return e.splice(s,0,t),e},"appendPlugin"),ut=pt((e,t)=>{if(!t)return e;for(const{after:o=void 0,before:n=void 0,plugin:r}of t)e=o?Oe(e,r,o,!0):Oe(e,r,n,!1);return e},"appendPlugins");var Yn=Object.defineProperty,Qn=m((e,t)=>Yn(e,"name",{value:t,configurable:!0}),"s$7");const Zn=Qn(e=>{const t=f.basename(e).split(".");if(t.length>=2){const[o,n]=t.slice(-2),r=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if($.DEFAULT_EXTENSIONS.includes(n)&&s&&s.length>0)return r+"-"+s}},"getCustomModuleLayer");var er=Object.defineProperty,tr=m((e,t)=>er(e,"name",{value:t,configurable:!0}),"i$4");const ce=tr(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var or=Object.defineProperty,De=m((e,t)=>or(e,"name",{value:t,configurable:!0}),"d$7");const nr=De((e,t)=>{const o=new Map;return De(function(n,r){const s=r.getModuleInfo(n);if(!s)return;const{isEntry:i}=s,a=s.meta,l=ce(a);if(!i){const c=o.get(n);if(c)return c;const u=Zn(n);if(u)return o.set(n,u),u}if(i){const c=r.getModuleIds();for(const u of c)r.getModuleInfo(u)&&ce(a)===l&&(e.has(u)||e.set(u,new Set),e.get(u).add([n,l]))}if(l&&!i&&e.has(n)){const c=[...e.get(n)];if(c.some(([p])=>{if(t.some(d=>d.path===p)){const d=r.getModuleInfo(p);return ce(d?d.meta:{})===l}return!1}))return;if(c.every(([,p])=>p===l))return o.has(n)?o.get(n):void 0;const u=f.basename(n,f.extname(n))+"-"+l;return o.set(n,u),u}},"splitChunks")},"createSplitChunks");var rr=Object.defineProperty,ir=m((e,t)=>rr(e,"name",{value:t,configurable:!0}),"n$5");const R=ir((e,t)=>e.isDynamicEntry?`${$.CHUNKS_PACKEM_FOLDER}/[name].${t}`:`${$.SHARED_PACKEM_FOLDER}/${e.name}-[hash].${t}`,"getChunkFilename");var sr=Object.defineProperty,ar=m((e,t)=>sr(e,"name",{value:t,configurable:!0}),"o$4");const lr=process.platform==="win32",Ne=ar((e,t)=>{const o=lr?"\\":"/";for(let n of Array.isArray(e.names)?e.names:[]){if(n.includes("node_modules"+o+".pnpm"))return n=n.replace("node_modules"+o+".pnpm","external")+"."+t,n.replace("node_modules"+o,"");if(n.includes("node_modules"))return n.replace("node_modules","external")+"."+t}return"[name]."+t},"getEntryFileNames");var cr=Object.defineProperty,pr=m((e,t)=>cr(e,"name",{value:t,configurable:!0}),"p$2");const ye=pr((e,t)=>{let o={};if(e.pkg.name&&(o[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:n}=e.pkg;for(const r in n){if(r.startsWith("#"))continue;const s=n[r];typeof s=="string"&&(o[r]=f.join(e.options.rootDir,s))}}return o={...o,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(o,Object.fromEntries(e.options.rollup.alias.entries.map(n=>[n.find,n.replacement]))):Object.assign(o,e.options.rollup.alias.entries??e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(o),prefix:t}),o},"resolveAliases");var ur=Object.defineProperty,O=m((e,t)=>ur(e,"name",{value:t,configurable:!0}),"p$1");const dr=O((e,t)=>{if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");t.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(t.logger.warn(["ES3 target is not supported by esbuild, so ES5 will be used instead..","Please set 'target' option in tsconfig to at least ES5 to disable this error"].join(" ")),t.tsconfig.config.compilerOptions.target="es5",t.options.rollup.esbuild.target="es5");let o="node"+ge.versions.node.split(".")[0];if(t.pkg.engines?.node){const n=H.minVersion(t.pkg.engines.node);n&&(o="node"+n.major)}if(t.options.rollup.esbuild.target){const n=L(t.options.rollup.esbuild.target);n.some(r=>r.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...L(o),...n])])}else t.options.rollup.esbuild.target=L(o);return t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{logger:t.logger,minify:t.options.minify,minifyWhitespace:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{topLevel:!0},sourceMap:t.options.sourcemap,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return t.options.rollup.sucrase}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),dt=O((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT")throw new Error(`Failed to resolve the module "${e.exporter}" imported by "${j.cyan(f.relative(f.resolve(),e.id))}"
43
43
  Is the module installed? Note:
44
44
  ↳ to inline a module into your bundle, install it to "devDependencies".
45
- ↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MODULE_LEVEL_DIRECTIVE"?!0:e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),_e=new Map,pe=new Map,ft=O((e,t,o)=>{const n=O(i=>{for(const[s,a]of Object.entries(t))if(i.startsWith(s))return i.replace(s,a)},"findAlias"),r=it(e.tsconfig,!1);return{external(i){const s=n(i);s&&(i=s);const a=Ve(i);if(de(e.options.externals,a)||de(e.options.externals,i))return!0;const{pkg:l}=e;if(i.startsWith(".")||f.isAbsolute(i)||/src[/\\]/.test(i)||l.name&&i.startsWith(l.name))return!1;if(l.imports)for(const[c,u]of Object.entries(l.imports)){if(c===i)return!1;if(c.includes("*")){let p;pe.has(c)?p=pe.get(c):(p=oe.readdirSync(f.join(e.options.rootDir,u.replace("/*","")),{withFileTypes:!0}).filter(d=>d.isFile()).map(d=>d.name),pe.set(c,p));for(const d of p)if(d.replace($.ENDING_RE,"")===i.replace($.ENDING_RE,"").replace("#",""))return!1}}if(r){for(const{find:c}of r)if(c.test(i))return e.logger.debug({message:`Resolved alias ${i} to ${c.source}`,prefix:o}),!1}return _e.has(i)||e.logger.info({message:'Inlined implicit external "'+b.cyan(i)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),_e.set(i,!0),!1},input:Object.fromEntries(e.options.entries.map(i=>[i.name,f.resolve(e.options.rootDir,i.input)])),logLevel:e.options.debug?"debug":"info",onLog:O((i,s)=>{let a=s.message;switch(s.stack&&(a=`${a}
46
- ${s.stack}`),i){case"info":{e.logger.info({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")})}},"onLog"),onwarn(i,s){dt(i,e)||i.code||s(i)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),mt=O(async(e,t)=>{const o=ye(e,"build");let n;e.options.rollup.resolve&&(n=S(Be.nodeResolve({...e.options.rollup.resolve}),t));const r=e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:tr(e.dependencyGraphMap,e.buildEntries),preserveModules:!1};return{...ft(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:O(i=>T(i,"cjs"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:O(i=>Ne(i,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...r},e.options.emitESM&&{chunkFileNames:O(i=>T(i,"mjs"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:O(i=>Ne(i,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...r}].filter(Boolean),plugins:ut([S(tt(),t),S(ct(),t),e.tsconfig&&S(lt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&S(st(e.tsconfig,e.logger),t),e.options.rollup.replace&&Ue({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&qe({customResolver:n,...e.options.rollup.alias,entries:o}),n,e.options.rollup.polyfillNode&&Zt({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&He({...e.options.rollup.json}),xo(),e.options.rollup.wasm&&It.wasm(e.options.rollup.wasm),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&Yo(f.join(e.options.rootDir,e.options.sourceDir),e.options.isolatedDeclarationTransformer,e.options.declaration,!!e.options.rollup.cjsInterop,e.options.rollup.isolatedDeclarations),e.options.rollup.raw&&S(xn(e.options.rollup.raw),t),e.options.transformer(pr(e.options.transformerName,e)),S($n({directiveRegex:/^['|"](use (\w+))['|"]$/,...e.options.rollup.preserveDirectives,logger:e.logger}),t),e.options.rollup.shebang&&Nn(e.options.entries.filter(i=>i.executable).map(i=>i.name).filter(Boolean),e.options.rollup.shebang),e.options.cjsInterop&&e.options.emitCJS&&Xe({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&qo(),e.options.rollup.dynamicVars&&Qt(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&S(Yt({sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{name:"packem:preserve-dynamic-imports",renderDynamicImport(){return{left:"import(",right:")"}}},e.options.cjsInterop&&e.options.rollup.shim&&Lo(e.pkg,e.options.rollup.shim),e.options.rollup.jsxRemoveAttributes&&S(rn({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),t),e.options.rollup.metafile&&pn({outDir:f.resolve(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&To(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&Ze({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),bn(),e.options.emitCJS&&e.mode==="build"&&e.options.declaration==="compatible"&&e.options.rollup.node10Compatibility&&fn(e.logger,e.options.entries,e.options.outDir,e.options.rootDir,e.options.rollup.node10Compatibility.writeToPackageJson?"file":"console",e.options.rollup.node10Compatibility.typeScriptVersion??"*"),e.options.analyze&&e.options.rollup.visualizer!==!1&&Mt.visualizer({brotliSize:!0,gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,...e.options.rollup.visualizer,filename:"packem-bundle-analyze.html",title:"Packem Visualizer"})].filter(Boolean),e.options.rollup.plugins)}},"getRollupOptions"),ur=O(async e=>{const{dts:t}=require("rollup-plugin-dts");return t({compilerOptions:{...e.options.rollup.dts.compilerOptions,incremental:void 0,inlineSources:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},respectExternal:e.options.rollup.dts.respectExternal,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),dr=uo(ur),gt=O(async(e,t)=>{const o=ye(e,"types"),n={load(a){return/\.(?:js|cjs|mjs|jsx|ts|tsx|ctsx|mtsx|mts|json)$/.test(a)?null:""},name:"packem:ignore-files"},r=e.tsconfig?.config.compilerOptions;delete r?.lib;let i;e.options.rollup.resolve&&(i=S(Be.nodeResolve({...e.options.rollup.resolve}),t));const s="dts-plugin:"+process.pid+e.tsconfig.path;return{...ft(e,o,"dts"),onwarn(a,l){dt(a,e)||a.code!=="EMPTY_BUNDLE"&&l(a)},output:[e.options.emitCJS&&{chunkFileNames:O(a=>T(a,"d.cts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:O(a=>T(a,"d.mts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.declaration==="compatible"&&{chunkFileNames:O(a=>T(a,"d.ts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:ut([S(tt(),t),S(ct(),t),e.options.rollup.json&&He({...e.options.rollup.json}),n,e.tsconfig&&S(lt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&S(st(e.tsconfig,e.logger),t),e.options.rollup.replace&&Ue({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&qe({customResolver:i,...e.options.rollup.alias,entries:o}),i,await dr(s)(e),e.options.cjsInterop&&e.options.emitCJS&&Xe({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&S(Wn(e.options.rollup.patchTypes,e.logger),t),_n(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Ze({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean),e.options.rollup.plugins)}},"getRollupDtsOptions");var fr=Object.defineProperty,mr=m((e,t)=>fr(e,"name",{value:t,configurable:!0}),"f$5");const Pe="rollup-build.json",ue=mr(async(e,t,o)=>{const n=await mt(e,t);if(await e.hooks.callHook("rollup:options",e,n),Object.keys(n.input).length===0)return;(!e.options.rollup.isolatedDeclarations||!e.options.isolatedDeclarationTransformer)&&(n.cache=t.get(Pe,o));const r=await B.rollup(n);t.set(Pe,r.cache,o),await e.hooks.callHook("rollup:build",e,r);const i=new Map;for(const s of n.output){const{output:a}=await r.write(s),l=new Set,c=a.filter(p=>p.type==="chunk");for(const p of c){l.add(p.fileName);for(const d of p.imports)e.usedImports.add(d);p.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(p.code,"utf8"),chunks:p.imports.filter(d=>c.find(h=>h.fileName===d)),exports:p.exports,modules:Object.entries(p.modules).map(([d,h])=>({bytes:h.renderedLength,id:d})),path:p.fileName,type:"entry"})}const u=a.filter(p=>p.type==="asset");for(const p of u)i.has(p.fileName)||i.set(p.fileName,{bytes:Buffer.byteLength(p.source,"utf8"),path:p.fileName,type:"asset"});for(const p of l)e.usedImports.delete(p)}e.buildEntries.push(...i.values())},"build");var gr=Object.defineProperty,V=m((e,t)=>gr(e,"name",{value:t,configurable:!0}),"a$6");const Ce="rollup-dts.json",z=V(async(e,t,o)=>{if(e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer){e.logger.info({message:"Using isolated declaration transformer to generate declaration files...",prefix:"dts"});return}const n=await gt(e,t);if(await e.hooks.callHook("rollup:dts:options",e,n),Object.keys(n.input).length===0)return;n.cache=t.get(Ce,o);const r=await B.rollup(n);t.set(Ce,r.cache,o),await e.hooks.callHook("rollup:dts:build",e,r),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await r.write({chunkFileNames:V(i=>T(i,"d.cts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await r.write({chunkFileNames:V(i=>T(i,"d.mts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),e.options.declaration==="compatible"&&await r.write({chunkFileNames:V(i=>T(i,"d.cjs"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var hr=Object.defineProperty,yr=m((e,t)=>hr(e,"name",{value:t,configurable:!0}),"y$2");const vr=yr((e,t,o)=>e.reduce((n,r)=>{const i=r[t],s=r[o];return n[i]||(n[i]={}),n[i][s]||(n[i][s]=[]),n[i][s].push(r),n},{}),"groupByKeys");var br=Object.defineProperty,Z=m((e,t)=>br(e,"name",{value:t,configurable:!0}),"j$1");const jr=Z((e,t)=>{const o=Z(s=>f.relative(t.options.rootDir,f.resolve(t.options.outDir,s)),"rPath");let n=!1;const r=[],i=t.buildEntries.filter(s=>s.type==="entry");if(i.length>0){e.raw(`Entries:
47
- `);for(const s of i){let a=s.bytes??0;for(const c of s.chunks??[])a+=t.buildEntries.find(u=>u.path===c)?.bytes??0;let l=` ${b.bold(o(s.path))} (${["total size: "+b.cyan(_.formatBytes(a)),s.bytes&&"chunk size: "+b.cyan(_.formatBytes(s.bytes))].filter(Boolean).join(", ")})`;if(l+=s.exports?.length?`
48
- exports: `+b.gray(s.exports.join(", ")):"",s.chunks?.length&&(l+=`
49
- ${s.chunks.map(c=>{const u=t.buildEntries.find(p=>p.path===c)??{};return b.gray(" └─ "+o(c)+b.bold(u.bytes?" ("+_.formatBytes(u?.bytes)+")":""))}).join(`
50
- `)}`),s.modules&&s.modules.length>0){const c=s.modules.filter(u=>u.id.includes("node_modules")).sort((u,p)=>(p.bytes||0)-(u.bytes||0)).map(u=>b.gray(" 📦 "+o(u.id)+b.bold(u.bytes?" ("+_.formatBytes(u.bytes)+")":""))).join(`
45
+ ↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MODULE_LEVEL_DIRECTIVE"?!0:e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),_e=new Map,pe=new Map,ft=O((e,t,o)=>{const n=O(s=>{for(const[i,a]of Object.entries(t))if(s.startsWith(i))return s.replace(i,a)},"findAlias"),r=it(e.tsconfig,!1);return{external(s){const i=n(s);i&&(s=i);const a=Ve(s);if(de(e.options.externals,a)||de(e.options.externals,s))return!0;const{pkg:l}=e;if(s.startsWith(".")||f.isAbsolute(s)||/src[/\\]/.test(s)||l.name&&s.startsWith(l.name))return!1;if(l.imports)for(const[c,u]of Object.entries(l.imports)){if(c===s)return!1;if(c.includes("*")){let p;pe.has(c)?p=pe.get(c):(p=oe.readdirSync(f.join(e.options.rootDir,u.replace("/*","")),{withFileTypes:!0}).filter(d=>d.isFile()).map(d=>d.name),pe.set(c,p));for(const d of p)if(d.replace($.ENDING_RE,"")===s.replace($.ENDING_RE,"").replace("#",""))return!1}}if(r){for(const{find:c}of r)if(c.test(s))return e.logger.debug({message:`Resolved alias ${s} to ${c.source}`,prefix:o}),!1}return _e.has(s)||e.logger.info({message:'Inlined implicit external "'+j.cyan(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),_e.set(s,!0),!1},input:Object.fromEntries(e.options.entries.map(s=>[s.name,f.resolve(e.options.rootDir,s.input)])),logLevel:e.options.debug?"debug":"info",onLog:O((s,i)=>{let a=i.message;switch(i.stack&&(a=`${a}
46
+ ${i.stack}`),s){case"info":{e.logger.info({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(s,i){dt(s,e)||s.code||i(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),mt=O(async(e,t)=>{const o=ye(e,"build");let n;e.options.rollup.resolve&&(n=S(Be.nodeResolve({...e.options.rollup.resolve}),t));const r=e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:nr(e.dependencyGraphMap,e.buildEntries),preserveModules:!1};return{...ft(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:O(s=>R(s,"cjs"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:O(s=>Ne(s,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...r},e.options.emitESM&&{chunkFileNames:O(s=>R(s,"mjs"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:O(s=>Ne(s,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...r}].filter(Boolean),plugins:ut([S(tt(),t),S(ct(),t),e.tsconfig&&S(lt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&S(st(e.tsconfig,e.logger),t),e.options.rollup.replace&&Ue({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&qe({customResolver:n,...e.options.rollup.alias,entries:o}),n,e.options.rollup.polyfillNode&&to({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&He({...e.options.rollup.json}),Oo(),e.options.rollup.wasm&&Mt.wasm(e.options.rollup.wasm),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&Zo(f.join(e.options.rootDir,e.options.sourceDir),e.options.isolatedDeclarationTransformer,e.options.declaration,!!e.options.rollup.cjsInterop,e.options.rollup.isolatedDeclarations),e.options.rollup.raw&&S(On(e.options.rollup.raw),t),e.options.transformer(dr(e.options.transformerName,e)),S(En({directiveRegex:/^['|"](use (\w+))['|"]$/,...e.options.rollup.preserveDirectives,logger:e.logger}),t),e.options.rollup.shebang&&Pn(e.options.entries.filter(s=>s.executable).map(s=>s.name).filter(Boolean),e.options.rollup.shebang),e.options.cjsInterop&&e.options.emitCJS&&Xe({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Vo(),e.options.rollup.dynamicVars&&eo(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&S(Zt({sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{name:"packem:preserve-dynamic-imports",renderDynamicImport(){return{left:"import(",right:")"}}},e.options.cjsInterop&&e.options.rollup.shim&&Wo(e.pkg,e.options.rollup.shim),e.options.rollup.jsxRemoveAttributes&&S(an({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),t),e.options.rollup.metafile&&dn({outDir:f.resolve(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&Ao(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&Ze({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),wn(),e.options.emitCJS&&e.mode==="build"&&e.options.declaration==="compatible"&&e.options.rollup.node10Compatibility&&gn(e.logger,e.options.entries,e.options.outDir,e.options.rootDir,e.options.rollup.node10Compatibility.writeToPackageJson?"file":"console",e.options.rollup.node10Compatibility.typeScriptVersion??"*"),e.options.analyze&&e.options.rollup.visualizer!==!1&&Jt.visualizer({brotliSize:!0,gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,...e.options.rollup.visualizer,filename:"packem-bundle-analyze.html",title:"Packem Visualizer"})].filter(Boolean),e.options.rollup.plugins)}},"getRollupOptions"),fr=O(async e=>{const{dts:t}=require("rollup-plugin-dts");return t({compilerOptions:{...e.options.rollup.dts.compilerOptions,incremental:void 0,inlineSources:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},respectExternal:e.options.rollup.dts.respectExternal,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),mr=mo(fr),gt=O(async(e,t)=>{const o=ye(e,"types"),n={load(a){return/\.(?:js|cjs|mjs|jsx|ts|tsx|ctsx|mtsx|mts|json)$/.test(a)?null:""},name:"packem:ignore-files"},r=e.tsconfig?.config.compilerOptions;delete r?.lib;let s;e.options.rollup.resolve&&(s=S(Be.nodeResolve({...e.options.rollup.resolve}),t));const i="dts-plugin:"+process.pid+e.tsconfig.path;return{...ft(e,o,"dts"),onwarn(a,l){dt(a,e)||a.code!=="EMPTY_BUNDLE"&&l(a)},output:[e.options.emitCJS&&{chunkFileNames:O(a=>R(a,"d.cts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:O(a=>R(a,"d.mts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.declaration==="compatible"&&{chunkFileNames:O(a=>R(a,"d.ts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:ut([S(tt(),t),S(ct(),t),e.options.rollup.json&&He({...e.options.rollup.json}),n,e.tsconfig&&S(lt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&S(st(e.tsconfig,e.logger),t),e.options.rollup.replace&&Ue({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&qe({customResolver:s,...e.options.rollup.alias,entries:o}),s,await mr(i)(e),e.options.cjsInterop&&e.options.emitCJS&&Xe({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&S(Un(e.options.rollup.patchTypes,e.logger),t),Cn(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Ze({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean),e.options.rollup.plugins)}},"getRollupDtsOptions");var gr=Object.defineProperty,hr=m((e,t)=>gr(e,"name",{value:t,configurable:!0}),"f$5");const Pe="rollup-build.json",ue=hr(async(e,t,o)=>{const n=await mt(e,t);if(await e.hooks.callHook("rollup:options",e,n),Object.keys(n.input).length===0)return;(!e.options.rollup.isolatedDeclarations||!e.options.isolatedDeclarationTransformer)&&(n.cache=t.get(Pe,o));const r=await B.rollup(n);t.set(Pe,r.cache,o),await e.hooks.callHook("rollup:build",e,r);const s=new Map;for(const i of n.output){const{output:a}=await r.write(i),l=new Set,c=a.filter(p=>p.type==="chunk");for(const p of c){l.add(p.fileName);for(const d of p.imports)e.usedImports.add(d);p.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(p.code,"utf8"),chunks:p.imports.filter(d=>c.find(h=>h.fileName===d)),exports:p.exports,modules:Object.entries(p.modules).map(([d,h])=>({bytes:h.renderedLength,id:d})),path:p.fileName,type:"entry"})}const u=a.filter(p=>p.type==="asset");for(const p of u)s.has(p.fileName)||s.set(p.fileName,{bytes:Buffer.byteLength(p.source,"utf8"),path:p.fileName,type:"asset"});for(const p of l)e.usedImports.delete(p)}e.buildEntries.push(...s.values())},"build");var yr=Object.defineProperty,V=m((e,t)=>yr(e,"name",{value:t,configurable:!0}),"a$6");const Ce="rollup-dts.json",z=V(async(e,t,o)=>{if(e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer){e.logger.info({message:"Using isolated declaration transformer to generate declaration files...",prefix:"dts"});return}const n=await gt(e,t);if(await e.hooks.callHook("rollup:dts:options",e,n),Object.keys(n.input).length===0)return;n.cache=t.get(Ce,o);const r=await B.rollup(n);t.set(Ce,r.cache,o),await e.hooks.callHook("rollup:dts:build",e,r),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await r.write({chunkFileNames:V(s=>R(s,"d.cts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await r.write({chunkFileNames:V(s=>R(s,"d.mts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),e.options.declaration==="compatible"&&await r.write({chunkFileNames:V(s=>R(s,"d.cjs"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var vr=Object.defineProperty,br=m((e,t)=>vr(e,"name",{value:t,configurable:!0}),"y$2");const jr=br((e,t,o)=>e.reduce((n,r)=>{const s=r[t],i=r[o];return n[s]||(n[s]={}),n[s][i]||(n[s][i]=[]),n[s][i].push(r),n},{}),"groupByKeys");var wr=Object.defineProperty,Z=m((e,t)=>wr(e,"name",{value:t,configurable:!0}),"j$1");const $r=Z((e,t)=>{const o=Z(i=>f.relative(t.options.rootDir,f.resolve(t.options.outDir,i)),"rPath");let n=!1;const r=[],s=t.buildEntries.filter(i=>i.type==="entry");if(s.length>0){e.raw(`Entries:
47
+ `);for(const i of s){let a=i.bytes??0;for(const c of i.chunks??[])a+=t.buildEntries.find(u=>u.path===c)?.bytes??0;let l=` ${j.bold(o(i.path))} (${["total size: "+j.cyan(_.formatBytes(a)),i.bytes&&"chunk size: "+j.cyan(_.formatBytes(i.bytes))].filter(Boolean).join(", ")})`;if(l+=i.exports?.length?`
48
+ exports: `+j.gray(i.exports.join(", ")):"",i.chunks?.length&&(l+=`
49
+ ${i.chunks.map(c=>{const u=t.buildEntries.find(p=>p.path===c)??{};return j.gray(" └─ "+o(c)+j.bold(u.bytes?" ("+_.formatBytes(u?.bytes)+")":""))}).join(`
50
+ `)}`),i.modules&&i.modules.length>0){const c=i.modules.filter(u=>u.id.includes("node_modules")).sort((u,p)=>(p.bytes||0)-(u.bytes||0)).map(u=>j.gray(" 📦 "+o(u.id)+j.bold(u.bytes?" ("+_.formatBytes(u.bytes)+")":""))).join(`
51
51
  `);l+=c.length>0?`
52
52
  inlined modules:
53
- `+c:""}if(t.options.declaration){let c=s.path.replace(/\.js$/,".d.ts"),u="commonjs";s.path.endsWith(".cjs")?c=s.path.replace(/\.cjs$/,".d.cts"):s.path.endsWith(".mjs")&&(u="module",c=s.path.replace(/\.mjs$/,".d.mts"));const p=t.buildEntries.find(d=>d.path.endsWith(c));if(p){r.push(p.path);let d;c.includes(".d.ts")||(c=c.replace(".d.c",".d."),d=t.buildEntries.find(h=>h.path.endsWith(c))),d&&(r.push(d.path),l+=u==="commonjs"?`
53
+ `+c:""}if(t.options.declaration){let c=i.path.replace(/\.js$/,".d.ts"),u="commonjs";i.path.endsWith(".cjs")?c=i.path.replace(/\.cjs$/,".d.cts"):i.path.endsWith(".mjs")&&(u="module",c=i.path.replace(/\.mjs$/,".d.mts"));const p=t.buildEntries.find(d=>d.path.endsWith(c));if(p){r.push(p.path);let d;c.includes(".d.ts")||(c=c.replace(".d.c",".d."),d=t.buildEntries.find(h=>h.path.endsWith(c))),d&&(r.push(d.path),l+=u==="commonjs"?`
54
54
  types:
55
- `+[p,d].map(h=>b.gray(" └─ ")+b.bold(o(h.path))+" (total size: "+b.cyan(_.formatBytes(h.bytes??0))+")").join(`
55
+ `+[p,d].map(h=>j.gray(" └─ ")+j.bold(o(h.path))+" (total size: "+j.cyan(_.formatBytes(h.bytes??0))+")").join(`
56
56
  `):`
57
- types: `+b.bold(o(p.path))+" (total size: "+b.cyan(_.formatBytes(p.bytes??0))+")")}}n=!0,l+=`
57
+ types: `+j.bold(o(p.path))+" (total size: "+j.cyan(_.formatBytes(p.bytes??0))+")")}}n=!0,l+=`
58
58
 
59
- `,e.raw(s.chunk?b.gray(l):l)}}if(t.buildEntries.filter(s=>s.type==="asset").length>0){let s="Assets:";for(const a of t.buildEntries.filter(l=>l.type==="asset"))r.includes(a.path)||(s+=b.gray(`
60
- └─ `)+b.bold(o(a.path))+" (total size: "+b.cyan(_.formatBytes(a.bytes??0))+")");s+=`
59
+ `,e.raw(i.chunk?j.gray(l):l)}}if(t.buildEntries.filter(i=>i.type==="asset").length>0){let i="Assets:";for(const a of t.buildEntries.filter(l=>l.type==="asset"))r.includes(a.path)||(i+=j.gray(`
60
+ └─ `)+j.bold(o(a.path))+" (total size: "+j.cyan(_.formatBytes(a.bytes??0))+")");i+=`
61
61
 
62
- `,e.raw(s)}return n&&e.raw("Σ Total dist size (byte size):",b.cyan(_.formatBytes(t.buildEntries.reduce((s,a)=>s+(a.bytes??0),0))),`
63
- `),n},"showSizeInformation"),wr=Z((e,t)=>{const o=vr(e.options.entries,"environment","runtime"),n=[];for(const[r,i]of Object.entries(o))for(const[s,a]of Object.entries(i)){const l={...e};!e.options.dtsOnly&&(r!=="undefined"||s!=="undefined")&&e.logger.info("Preparing build for "+(r==="undefined"?"":b.cyan(r)+" environment"+(s==="undefined"?"":" with "))+(s==="undefined"?"":b.cyan(s)+" runtime")),l.options.rollup.replace?(l.options.rollup.replace.values===void 0&&(l.options.rollup.replace.values={}),r!=="undefined"&&(l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(r)}),l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","EdgeRuntime"].join(".")]:JSON.stringify(s==="edge-light")}):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let c="";r!=="undefined"&&(c+=r+"/"),s!=="undefined"&&(c+=s+"/");let u=!1;l.options.minify!==void 0&&(u=l.options.minify),r==="development"?u=!1:r==="production"&&(u=!0);const p=[],d=[],h=[],y=[];for(const g of a)g.cjs&&g.esm?p.push(g):g.cjs?h.push(g):g.esm?d.push(g):g.declaration&&y.push(g);if(p.length>0){const g={...l,options:{...l.options,emitCJS:!0,emitESM:!0,entries:p,minify:u}};if(e.options.dtsOnly||n.push(ue(g,t,c)),e.options.declaration){const v=g.options.entries.filter(w=>w.declaration);v.length>0&&n.push(z({...g,options:{...g.options,entries:v}},t,c))}}if(d.length>0){const g={...l,options:{...l.options,emitCJS:!1,emitESM:!0,entries:d,minify:u}};if(e.options.dtsOnly||n.push(ue(g,t,c)),e.options.declaration){const v=g.options.entries.filter(w=>w.declaration);v.length>0&&n.push(z({...g,options:{...g.options,entries:v}},t,c))}}if(h.length>0){const g={...l,options:{...l.options,emitCJS:!0,emitESM:!1,entries:h,minify:u}};if(e.options.dtsOnly||n.push(ue(g,t,c)),e.options.declaration){const v=g.options.entries.filter(w=>w.declaration);v.length>0&&n.push(z({...g,options:{...g.options,entries:v}},t,c))}}if(l.options.declaration&&y.length>0){const g={...l,options:{...l.options,emitCJS:!1,emitESM:!1,entries:y,minify:u}};n.push(z(g,t,c))}}return n.filter(Boolean)},"prepareRollupConfig"),$r=Z(async(e,t)=>{await e.hooks.callHook("build:before",e),await Promise.all(wr(e,t)),e.logger.success(b.green(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const o of k.walk(f.join(e.options.rootDir,e.options.outDir))){let n=e.buildEntries.find(r=>f.join(e.options.rootDir,e.options.outDir,r.path)===o.path);if(n||(n={chunk:!0,path:o.path},e.buildEntries.push(n)),!n.bytes){const r=await ne.stat(f.resolve(e.options.rootDir,e.options.outDir,o.path));n.bytes=r.size}}return await e.hooks.callHook("build:done",e),jr(e.logger,e)},"build");var kr=Object.defineProperty,Er=m((e,t)=>kr(e,"name",{value:t,configurable:!0}),"r$4");const E=Er((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var xr=Object.defineProperty,ht=m((e,t)=>xr(e,"name",{value:t,configurable:!0}),"t$5");const ee=ht(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),me=ht((e,t,o,n)=>{if(e==="module-sync")return"esm";if(n){const s=ee(n);if(s)return s}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[r,...i]=t;return me(r,i,o,n)},"inferExportType");var Sr=Object.defineProperty,Or=m((e,t)=>Sr(e,"name",{value:t,configurable:!0}),"y$1");const Dr=new Set(["electron","import","require","node","node-addons","default","types","deno","browser","module-sync","bun","workerd",...$.RUNTIME_EXPORT_CONVENTIONS,...$.SPECIAL_EXPORT_CONVENTIONS]),ve=Or((e,t,o,n=[])=>{if(!e)return[];if(typeof e=="string"){const r=ee(e);if(r&&r!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:r??t}]}if(typeof e=="object"){const r=Object.entries(e).filter(([s])=>!s.endsWith(".json"));let i=[];for(const[s,a]of r)if(typeof a=="string"){let l={};Number.isInteger(+s)?l={exportKey:"*"}:s.startsWith("./")?l={exportKey:s.replace("./","")}:l={exportKey:s==="."?".":"*",subKey:s},i.push({...l,file:a,key:"exports",type:me(s,n,t,a)})}else if(typeof a=="object"&&a!==null)for(const[l,c]of Object.entries(a)){if(o===!1&&l==="types")continue;const u=Number.isInteger(+s)?l:s;typeof c=="string"?i.push({exportKey:u.replace("./",""),file:c,key:"exports",...Dr.has(l)?{subKey:l}:{},type:me(l,n,t,c)}):i=[...i,...ve({[u]:c},t,o,[...n,l])]}return i}return[]},"extractExportFilenames");var Nr=Object.defineProperty,se=m((e,t)=>Nr(e,"name",{value:t,configurable:!0}),"c$3");const _r=se((e,t)=>e.key==="exports"&&e.subKey===$.PRODUCTION_ENV?$.PRODUCTION_ENV:e.key==="exports"&&e.subKey===$.DEVELOPMENT_ENV?$.DEVELOPMENT_ENV:t,"getEnvironment"),G=se((e,t,o,n,r,i,s)=>{const a=_r(r,i.environment);let l="node";for(const p of $.RUNTIME_EXPORT_CONVENTIONS)if(r.file.includes("."+p+".")||r.subKey===p){l=p;break}let c=e.find(p=>p.input===t&&p.environment===a&&p.runtime===l);c===void 0?c=e[e.push({environment:a,exportKey:new Set([r.exportKey].filter(Boolean)),input:t,runtime:l})-1]:c.exportKey&&r.exportKey&&c.exportKey.add(r.exportKey),s&&(c.isGlob=!0),o&&(c.outDir=n),r.isExecutable?(c.executable=!0,c.declaration=!1,r.type==="cjs"?c.cjs=!0:r.type==="esm"&&(c.esm=!0)):(/\.d\.[mc]?ts$/.test(r.file)&&i.options.declaration!==!1&&(c.declaration=i.options.declaration),r.type==="cjs"?c.cjs=!0:r.type==="esm"&&(c.esm=!0));const u=r.file.replace(f.extname(r.file),"").replace(new RegExp(`^./${i.options.outDir.replace(/^\.\//,"")}/`),"");$.SPECIAL_EXPORT_CONVENTIONS.has(r.subKey)&&!t.includes(u)&&(c.fileAlias=u)},"createOrUpdateEntry");let Re=!1;const Te=se(e=>{if(e.pkg?.dependencies?.typescript===void 0&&e.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},"validateIfTypescriptIsInstalled"),Pr=se((e,t,o)=>{const n=[];t.sort((a,l)=>a.split("/").length-l.split("/").length);const r=e.type==="module"?"esm":"cjs";r==="esm"&&(o.options.emitESM=!0),r==="cjs"&&(o.options.emitCJS=!0);const i=ve(e.exports,r,o.options.declaration);if(e.bin){const a=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const l of a){const c=ee(l);if(c&&c!==r)throw new Error(`Exported file "${l}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);i.push({file:l,isExecutable:!0,key:"bin",type:c??r})}}e.main&&i.push({file:e.main,key:"main",type:ee(e.main)??r}),e.module&&i.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(Te(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),i.push({file:e.types??e.typings,key:"types"}));const s=[];for(const a of i){o.options.declaration===void 0&&(a.key==="types"||a.subKey==="types")&&(o.options.declaration=a.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&a.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&a.type==="esm"&&(o.options.emitESM=!0);const l=a.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const u=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),p="(?<=/|$)",d=c?"":"\\.\\w+$";if(a.file.includes("/*")&&a.key==="exports"){Re||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Re=!0);const v=[],w=new RegExp(p+u.replace("*","(.*)")+d),x=new RegExp(p+u.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+d);for(const j of t)(w.test(j)||$.SPECIAL_EXPORT_CONVENTIONS.has(a.subKey)&&x.test(j))&&v.push(j);if(v.length===0){n.push(`Could not find entrypoint for \`${a.file}\``);continue}for(const j of v)G(s,j,c,l,a,o,!0);continue}const h=new RegExp(p+u+d);let y=t.find(v=>h.test(v));if($.SPECIAL_EXPORT_CONVENTIONS.has(a.subKey)&&y===void 0){const v=new RegExp(p+u.replace(/(.*)\.[^.]*$/,"$1")+d);y=t.find(w=>v.test(w))}if(y===void 0){k.isAccessibleSync(f.resolve(o.options.rootDir,a.file))||n.push(`Could not find entrypoint for \`${a.file}\``);continue}(y.endsWith(".ts")||y.endsWith(".cts")||y.endsWith(".mts"))&&k.isAccessibleSync(y)&&Te(o);const g=f.toNamespacedPath(y.replace($.ENDING_RE,""));k.isAccessibleSync(g+".cts")&&k.isAccessibleSync(g+".mts")?(G(s,g+".cts",c,l,{...a,type:"cjs"},o,!1),G(s,g+".mts",c,l,{...a,type:"esm"},o,!1)):G(s,y,c,l,a,o,!1)}return{entries:s,warnings:n}},"inferEntries");var Cr=Object.defineProperty,Rr=m((e,t)=>Cr(e,"name",{value:t,configurable:!0}),"o$3");const Tr=Rr((e,t)=>{const{publishConfig:o}=e;return o&&(o.bin&&(typeof o.bin=="object"||typeof o.bin=="string")&&(e.bin=o.bin),o.type&&typeof o.type=="string"&&o.type!==""&&(e.type=o.type),o.main&&typeof o.main=="string"&&o.main!==""&&(e.main=o.main),o.module&&typeof o.module=="string"&&o.module!==""&&(e.module=o.module),t===void 0&&o.types&&typeof o.types=="string"&&o.types!==""?e.types=o.types:t===void 0&&o.typings&&typeof o.typings=="string"&&o.typings!==""&&(e.typings=o.typings),o.exports&&typeof o.exports=="object"&&(e.exports=o.exports)),e},"overwriteWithPublishConfig");var Ir=Object.defineProperty,Ar=m((e,t)=>Ir(e,"name",{value:t,configurable:!0}),"t$4");const Mr={hooks:{"build:prepare":Ar(function(e){if(e.options.entries.length>0)return;const t=f.join(e.options.rootDir,e.options.sourceDir);if(!oe.existsSync(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=k.collectSync(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let n={...e.pkg};n.publishConfig&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(n.publishConfig).join(", ")+'".'),e.logger.debug(n.publishConfig),n=Tr(n,e.options.declaration));const r=Pr(n,o,e);for(const i of r.warnings)E(e,i);if(e.options.entries.push(...r.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",b.cyan(e.options.entries.map(i=>i.fileAlias?b.bold(i.fileAlias)+" => "+b.bold(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):b.bold(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),b.gray([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))},"build:prepare")}};var Fr=Object.defineProperty,Jr=m((e,t)=>Fr(e,"name",{value:t,configurable:!0}),"t$3");const Lr=Jr(async(e,t)=>{if(e==="auto")e=Mr;else{if(e==="none")return{};typeof e=="string"&&(e=await t.import(e)||{})}return typeof e=="function"&&(e=e()),e},"resolvePreset");var Br=Object.defineProperty,Wr=m((e,t)=>Br(e,"name",{value:t,configurable:!0}),"j");const qr=Wr(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,o=[],n=JSON.stringify({...e.options.jiti,alias:{...ye(e,"jit"),...e.options.jiti.alias},transformOptions:{...e.options.jiti.transformOptions,babel:{...e.options.jiti.transformOptions?.babel,plugins:"__$BABEL_PLUGINS"}}},null,2).replace('"__$BABEL_PLUGINS"',Array.isArray(t)?"["+t.map((r,i)=>{if(Array.isArray(r)){const[s,...a]=r;return o.push(s),"["+["plugin"+i,...a.map(l=>JSON.stringify(l))].join(", ")+"]"}return o.push(r),"plugin"+i}).join(",")+"]":"[]");for(const r of e.options.entries){const i=f.resolve(e.options.rootDir,e.options.outDir,r.name),s=F.fileURLToPath(e.jiti.esmResolve(r.input,{try:!0})??r.input),a=s.replace($.ENDING_RE,""),l=k.readFileSync(s),c=Pn(l);let u=[];try{u=await F.resolveModuleExportNames(s,{extensions:$.DEFAULT_EXTENSIONS})}catch(d){E(e,`Cannot analyze ${s} for exports: ${d.toString()}`);return}const p=u.includes("default")||u.length===0;if(e.options.emitESM){const d=f.relative(f.dirname(i),await F.resolvePath("jiti",{conditions:["node","import"],url:typeof document>"u"?require("url").pathToFileURL(__filename).href:M&&M.tagName.toUpperCase()==="SCRIPT"&&M.src||new URL("create-bundler.cjs",document.baseURI).href})),h=a+".d.mts";k.writeFileSync(`${i}.mjs`,c+['import { createJiti } from "'+d+'";',...o.map((y,g)=>"import plugin"+g+' from "'+y+'";'),"","const jiti = createJiti(import.meta.url, "+n+");","",'/** @type {import("'+h+'")} */','const _module = await jiti.import("'+s+'");',p?`
62
+ `,e.raw(i)}return n&&e.raw("Σ Total dist size (byte size):",j.cyan(_.formatBytes(t.buildEntries.reduce((i,a)=>i+(a.bytes??0),0))),`
63
+ `),n},"showSizeInformation"),kr=Z((e,t)=>{const o=jr(e.options.entries,"environment","runtime"),n=[];for(const[r,s]of Object.entries(o))for(const[i,a]of Object.entries(s)){const l={...e};!e.options.dtsOnly&&(r!=="undefined"||i!=="undefined")&&e.logger.info("Preparing build for "+(r==="undefined"?"":j.cyan(r)+" environment"+(i==="undefined"?"":" with "))+(i==="undefined"?"":j.cyan(i)+" runtime")),l.options.rollup.replace?(l.options.rollup.replace.values===void 0&&(l.options.rollup.replace.values={}),r!=="undefined"&&(l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(r)}),l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","EdgeRuntime"].join(".")]:JSON.stringify(i==="edge-light")}):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let c="";r!=="undefined"&&(c+=r+"/"),i!=="undefined"&&(c+=i+"/");let u=!1;l.options.minify!==void 0&&(u=l.options.minify),r==="development"?u=!1:r==="production"&&(u=!0);const p=[],d=[],h=[],y=[];for(const g of a)g.cjs&&g.esm?p.push(g):g.cjs?h.push(g):g.esm?d.push(g):g.declaration&&y.push(g);if(p.length>0){const g={...l,options:{...l.options,emitCJS:!0,emitESM:!0,entries:p,minify:u}};if(e.options.dtsOnly||n.push(ue(g,t,c)),e.options.declaration){const v=g.options.entries.filter(w=>w.declaration);v.length>0&&n.push(z({...g,options:{...g.options,entries:v}},t,c))}}if(d.length>0){const g={...l,options:{...l.options,emitCJS:!1,emitESM:!0,entries:d,minify:u}};if(e.options.dtsOnly||n.push(ue(g,t,c)),e.options.declaration){const v=g.options.entries.filter(w=>w.declaration);v.length>0&&n.push(z({...g,options:{...g.options,entries:v}},t,c))}}if(h.length>0){const g={...l,options:{...l.options,emitCJS:!0,emitESM:!1,entries:h,minify:u}};if(e.options.dtsOnly||n.push(ue(g,t,c)),e.options.declaration){const v=g.options.entries.filter(w=>w.declaration);v.length>0&&n.push(z({...g,options:{...g.options,entries:v}},t,c))}}if(l.options.declaration&&y.length>0){const g={...l,options:{...l.options,emitCJS:!1,emitESM:!1,entries:y,minify:u}};n.push(z(g,t,c))}}return n.filter(Boolean)},"prepareRollupConfig"),Er=Z(async(e,t)=>{await e.hooks.callHook("build:before",e),await Promise.all(kr(e,t)),e.logger.success(j.green(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const o of k.walk(f.join(e.options.rootDir,e.options.outDir))){let n=e.buildEntries.find(r=>f.join(e.options.rootDir,e.options.outDir,r.path)===o.path);if(n||(n={chunk:!0,path:o.path},e.buildEntries.push(n)),!n.bytes){const r=await ne.stat(f.resolve(e.options.rootDir,e.options.outDir,o.path));n.bytes=r.size}}return await e.hooks.callHook("build:done",e),$r(e.logger,e)},"build");var xr=Object.defineProperty,Sr=m((e,t)=>xr(e,"name",{value:t,configurable:!0}),"r$4");const E=Sr((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Or=Object.defineProperty,ht=m((e,t)=>Or(e,"name",{value:t,configurable:!0}),"t$4");const ee=ht(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),me=ht((e,t,o,n)=>{if(e==="module-sync")return"esm";if(n){const i=ee(n);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[r,...s]=t;return me(r,s,o,n)},"inferExportType");var Dr=Object.defineProperty,Nr=m((e,t)=>Dr(e,"name",{value:t,configurable:!0}),"y$1");const _r=new Set(["electron","import","require","node","node-addons","default","types","deno","browser","module-sync","bun","workerd",...$.RUNTIME_EXPORT_CONVENTIONS,...$.SPECIAL_EXPORT_CONVENTIONS]),ve=Nr((e,t,o,n=[])=>{if(!e)return[];if(typeof e=="string"){const r=ee(e);if(r&&r!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:r??t}]}if(typeof e=="object"){const r=Object.entries(e).filter(([i])=>!i.endsWith(".json"));let s=[];for(const[i,a]of r)if(typeof a=="string"){let l={};Number.isInteger(+i)?l={exportKey:"*"}:i.startsWith("./")?l={exportKey:i.replace("./","")}:l={exportKey:i==="."?".":"*",subKey:i},s.push({...l,file:a,key:"exports",type:me(i,n,t,a)})}else if(typeof a=="object"&&a!==null)for(const[l,c]of Object.entries(a)){if(o===!1&&l==="types")continue;const u=Number.isInteger(+i)?l:i;typeof c=="string"?s.push({exportKey:u.replace("./",""),file:c,key:"exports",..._r.has(l)?{subKey:l}:{},type:me(l,n,t,c)}):s=[...s,...ve({[u]:c},t,o,[...n,l])]}return s}return[]},"extractExportFilenames");var Pr=Object.defineProperty,se=m((e,t)=>Pr(e,"name",{value:t,configurable:!0}),"c$3");const Cr=se((e,t)=>e.key==="exports"&&e.subKey===$.PRODUCTION_ENV?$.PRODUCTION_ENV:e.key==="exports"&&e.subKey===$.DEVELOPMENT_ENV?$.DEVELOPMENT_ENV:t,"getEnvironment"),G=se((e,t,o,n,r,s,i)=>{const a=Cr(r,s.environment);let l="node";for(const p of $.RUNTIME_EXPORT_CONVENTIONS)if(r.file.includes("."+p+".")||r.subKey===p){l=p;break}let c=e.find(p=>p.input===t&&p.environment===a&&p.runtime===l);c===void 0?c=e[e.push({environment:a,exportKey:new Set([r.exportKey].filter(Boolean)),input:t,runtime:l})-1]:c.exportKey&&r.exportKey&&c.exportKey.add(r.exportKey),i&&(c.isGlob=!0),o&&(c.outDir=n),r.isExecutable?(c.executable=!0,c.declaration=!1,r.type==="cjs"?c.cjs=!0:r.type==="esm"&&(c.esm=!0)):(/\.d\.[mc]?ts$/.test(r.file)&&s.options.declaration!==!1&&(c.declaration=s.options.declaration),r.type==="cjs"?c.cjs=!0:r.type==="esm"&&(c.esm=!0));const u=r.file.replace(f.extname(r.file),"").replace(new RegExp(`^./${s.options.outDir.replace(/^\.\//,"")}/`),"");$.SPECIAL_EXPORT_CONVENTIONS.has(r.subKey)&&!t.includes(u)&&(c.fileAlias=u)},"createOrUpdateEntry");let Te=!1;const Re=se(e=>{if(e.pkg?.dependencies?.typescript===void 0&&e.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},"validateIfTypescriptIsInstalled"),Tr=se((e,t,o)=>{const n=[];t.sort((a,l)=>a.split("/").length-l.split("/").length);const r=e.type==="module"?"esm":"cjs";r==="esm"&&(o.options.emitESM=!0),r==="cjs"&&(o.options.emitCJS=!0);const s=ve(e.exports,r,o.options.declaration);if(e.bin){const a=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const l of a){const c=ee(l);if(c&&c!==r)throw new Error(`Exported file "${l}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);s.push({file:l,isExecutable:!0,key:"bin",type:c??r})}}e.main&&s.push({file:e.main,key:"main",type:ee(e.main)??r}),e.module&&s.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(Re(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),s.push({file:e.types??e.typings,key:"types"}));const i=[];for(const a of s){o.options.declaration===void 0&&(a.key==="types"||a.subKey==="types")&&(o.options.declaration=a.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&a.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&a.type==="esm"&&(o.options.emitESM=!0);const l=a.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const u=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),p="(?<=/|$)",d=c?"":"\\.\\w+$";if(a.file.includes("/*")&&a.key==="exports"){Te||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Te=!0);const v=[],w=new RegExp(p+u.replace("*","(.*)")+d),x=new RegExp(p+u.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+d);for(const b of t)(w.test(b)||$.SPECIAL_EXPORT_CONVENTIONS.has(a.subKey)&&x.test(b))&&v.push(b);if(v.length===0){n.push(`Could not find entrypoint for \`${a.file}\``);continue}for(const b of v)G(i,b,c,l,a,o,!0);continue}const h=new RegExp(p+u+d);let y=t.find(v=>h.test(v));if($.SPECIAL_EXPORT_CONVENTIONS.has(a.subKey)&&y===void 0){const v=new RegExp(p+u.replace(/(.*)\.[^.]*$/,"$1")+d);y=t.find(w=>v.test(w))}if(y===void 0){k.isAccessibleSync(f.resolve(o.options.rootDir,a.file))||n.push(`Could not find entrypoint for \`${a.file}\``);continue}(y.endsWith(".ts")||y.endsWith(".cts")||y.endsWith(".mts"))&&k.isAccessibleSync(y)&&Re(o);const g=f.toNamespacedPath(y.replace($.ENDING_RE,""));k.isAccessibleSync(g+".cts")&&k.isAccessibleSync(g+".mts")?(G(i,g+".cts",c,l,{...a,type:"cjs"},o,!1),G(i,g+".mts",c,l,{...a,type:"esm"},o,!1)):G(i,y,c,l,a,o,!1)}return{entries:i,warnings:n}},"inferEntries");var Rr=Object.defineProperty,Ir=m((e,t)=>Rr(e,"name",{value:t,configurable:!0}),"o$3");const Ar=Ir((e,t)=>{const{publishConfig:o}=e;return o&&(o.bin&&(typeof o.bin=="object"||typeof o.bin=="string")&&(e.bin=o.bin),o.type&&typeof o.type=="string"&&o.type!==""&&(e.type=o.type),o.main&&typeof o.main=="string"&&o.main!==""&&(e.main=o.main),o.module&&typeof o.module=="string"&&o.module!==""&&(e.module=o.module),t===void 0&&o.types&&typeof o.types=="string"&&o.types!==""?e.types=o.types:t===void 0&&o.typings&&typeof o.typings=="string"&&o.typings!==""&&(e.typings=o.typings),o.exports&&typeof o.exports=="object"&&(e.exports=o.exports)),e},"overwriteWithPublishConfig");var Mr=Object.defineProperty,Fr=m((e,t)=>Mr(e,"name",{value:t,configurable:!0}),"t$3");const Jr={hooks:{"build:prepare":Fr(function(e){if(e.options.entries.length>0)return;const t=f.join(e.options.rootDir,e.options.sourceDir);if(!oe.existsSync(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=k.collectSync(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let n={...e.pkg};n.publishConfig&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(n.publishConfig).join(", ")+'".'),e.logger.debug(n.publishConfig),n=Ar(n,e.options.declaration));const r=Tr(n,o,e);for(const s of r.warnings)E(e,s);if(e.options.entries.push(...r.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",j.cyan(e.options.entries.map(s=>s.fileAlias?j.bold(s.fileAlias)+" => "+j.bold(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):j.bold(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),j.gray([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var Lr=Object.defineProperty,Br=m((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"t$2");const Wr=Br(async(e,t)=>{if(e==="auto")e=Jr;else{if(e==="none")return{};typeof e=="string"&&(e=await t.import(e)||{})}return typeof e=="function"&&(e=e()),e},"resolvePreset");var qr=Object.defineProperty,Ur=m((e,t)=>qr(e,"name",{value:t,configurable:!0}),"j");const Vr=Ur(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,o=[],n=JSON.stringify({...e.options.jiti,alias:{...ye(e,"jit"),...e.options.jiti.alias},transformOptions:{...e.options.jiti.transformOptions,babel:{...e.options.jiti.transformOptions?.babel,plugins:"__$BABEL_PLUGINS"}}},null,2).replace('"__$BABEL_PLUGINS"',Array.isArray(t)?"["+t.map((r,s)=>{if(Array.isArray(r)){const[i,...a]=r;return o.push(i),"["+["plugin"+s,...a.map(l=>JSON.stringify(l))].join(", ")+"]"}return o.push(r),"plugin"+s}).join(",")+"]":"[]");for(const r of e.options.entries){const s=f.resolve(e.options.rootDir,e.options.outDir,r.name),i=F.fileURLToPath(e.jiti.esmResolve(r.input,{try:!0})??r.input),a=i.replace($.ENDING_RE,""),l=k.readFileSync(i),c=Tn(l);let u=[];try{u=await F.resolveModuleExportNames(i,{extensions:$.DEFAULT_EXTENSIONS})}catch(d){E(e,`Cannot analyze ${i} for exports: ${d.toString()}`);return}const p=u.includes("default")||u.length===0;if(e.options.emitESM){const d=f.relative(f.dirname(s),await F.resolvePath("jiti",{conditions:["node","import"],url:typeof document>"u"?require("url").pathToFileURL(__filename).href:M&&M.tagName.toUpperCase()==="SCRIPT"&&M.src||new URL("packem.cjs",document.baseURI).href})),h=a+".d.mts";k.writeFileSync(`${s}.mjs`,c+['import { createJiti } from "'+d+'";',...o.map((y,g)=>"import plugin"+g+' from "'+y+'";'),"","const jiti = createJiti(import.meta.url, "+n+");","",'/** @type {import("'+h+'")} */','const _module = await jiti.import("'+i+'");',p?`
64
64
  export default _module;`:"",...u.filter(y=>y!=="default").map(y=>`export const ${y} = _module.${y};`)].join(`
65
- `)),e.options.declaration&&k.writeFileSync(`${i}.d.mts`,'export * from "'+h+`";
66
- `+(p?'export { default } from "'+h+'";':""))}if(e.options.emitCJS){const d=f.relative(f.dirname(i),await F.resolvePath("jiti",{conditions:["node","require"],url:typeof document>"u"?require("url").pathToFileURL(__filename).href:M&&M.tagName.toUpperCase()==="SCRIPT"&&M.src||new URL("create-bundler.cjs",document.baseURI).href})),h=a+".d.cts";k.writeFileSync(`${i}.cjs`,c+['const { createJiti } = require("'+d+'");',...o.map((y,g)=>"const plugin"+g+" = require("+JSON.stringify(y)+")"),"","const jiti = createJiti(__filename, "+n+");","",'/** @type {import("'+h+'")} */','module.exports = jiti("'+s+'")'].join(`
67
- `)),e.options.declaration&&k.writeFileSync(i+".d.cts",'export * from "'+h+`";
68
- `+(p?'export { default } from "'+h+'";':""))}c&&(await fe(`${i}.cjs`),await fe(`${i}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Ur=Object.defineProperty,be=m((e,t)=>Ur(e,"name",{value:t,configurable:!0}),"i$2");const Vr=be(e=>{const{message:t,name:o="Error",stack:n}=e;if(!n)return n;const r=`${o}: ${t}
69
- `;return n.startsWith(r)?n.slice(r.length):n},"extractStack"),zr=be(e=>`
65
+ `)),e.options.declaration&&k.writeFileSync(`${s}.d.mts`,'export * from "'+h+`";
66
+ `+(p?'export { default } from "'+h+'";':""))}if(e.options.emitCJS){const d=f.relative(f.dirname(s),await F.resolvePath("jiti",{conditions:["node","require"],url:typeof document>"u"?require("url").pathToFileURL(__filename).href:M&&M.tagName.toUpperCase()==="SCRIPT"&&M.src||new URL("packem.cjs",document.baseURI).href})),h=a+".d.cts";k.writeFileSync(`${s}.cjs`,c+['const { createJiti } = require("'+d+'");',...o.map((y,g)=>"const plugin"+g+" = require("+JSON.stringify(y)+")"),"","const jiti = createJiti(__filename, "+n+");","",'/** @type {import("'+h+'")} */','module.exports = jiti("'+i+'")'].join(`
67
+ `)),e.options.declaration&&k.writeFileSync(s+".d.cts",'export * from "'+h+`";
68
+ `+(p?'export { default } from "'+h+'";':""))}c&&(await fe(`${s}.cjs`),await fe(`${s}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var zr=Object.defineProperty,be=m((e,t)=>zr(e,"name",{value:t,configurable:!0}),"i$2");const Gr=be(e=>{const{message:t,name:o="Error",stack:n}=e;if(!n)return n;const r=`${o}: ${t}
69
+ `;return n.startsWith(r)?n.slice(r.length):n},"extractStack"),Kr=be(e=>`
70
70
  ${e.replaceAll(/^\n|\n$/g,"")}
71
- `,"normalizeCodeFrame"),yt=be(e=>{const t=Vr(e);let o=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(o+=`
72
- file: ${b.cyan(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(o+=`
73
- `+b.yellow(zr(e.frame))),e.message=o,t!==void 0&&(e.stack=`${e.message}
74
- ${t}`)},"enhanceRollupError");var Gr=Object.defineProperty,vt=m((e,t)=>Gr(e,"name",{value:t,configurable:!0}),"p");const te="rollup-watch.json",Ie=vt((e,t,o,n)=>{const r="watcher:"+o;e.on("change",(i,{event:s})=>{n.logger.info({message:`${b.cyan(f.relative(".",i))} was ${s}d`,prefix:r})}),e.on("restart",()=>{n.logger.info({message:"Rebuilding "+o+"...",prefix:r})}),e.on("event",async i=>{switch(i.code){case"END":{n.logger.success({message:"Rebuild "+o+" finished",prefix:r});break}case"BUNDLE_START":{n.logger.info({message:b.cyan("build started..."),prefix:r});break}case"BUNDLE_END":{await i.result.close(),t.set(o==="bundle"?te:"dts-"+te,i.result.cache),n.logger.info({message:b.cyan(`built in ${i.duration+""}ms.`),prefix:r});break}case"ERROR":{yt(i.error),n.logger.error({context:[i.error],message:"Rebuild "+o+" failed: "+i.error.message,prefix:r});break}}})},"watchHandler"),Kr=vt(async(e,t)=>{const o=await mt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;(!e.options.rollup.isolatedDeclarations||!e.options.isolatedDeclarationTransformer)&&(o.cache=t.get(te)),e.options.rollup.watch&&typeof o.watch=="object"&&o.watch.include===void 0&&(o.watch={...o.watch,...e.options.rollup.watch},o.watch.include=[f.join(e.options.sourceDir,"**","*"),"package.json"],Array.isArray(e.options.rollup.watch.include)?o.watch.include=[...o.watch.include,...e.options.rollup.watch.include]:e.options.rollup.watch.include&&o.watch.include.push(e.options.rollup.watch.include),o.watch.chokidar={cwd:e.options.rootDir,...o.watch.chokidar,ignored:["**/.git/**","**/node_modules/**","**/test-results/**",...o.watch.chokidar?.ignored??[]]});const n=B.watch(o);await e.hooks.callHook("rollup:watch",e,n);const r=[...Array.isArray(o.input)?o.input:typeof o.input=="string"?[o.input]:Object.keys(o.input??{})];let i="Starting watchers for entries:";for(const s of r)i+=b.gray(`
75
- └─ ${f.relative(process.cwd(),s)}`);if(e.logger.info(i),Ie(n,t,"bundle",e),e.options.declaration){const s=await gt(e,t);s.cache=t.get("dts-"+te),await e.hooks.callHook("rollup:dts:options",e,s);const a=B.watch(s);await e.hooks.callHook("rollup:watch",e,a),Ie(a,t,"types",e)}},"watch");var Xr=Object.defineProperty,bt=m((e,t)=>Xr(e,"name",{value:t,configurable:!0}),"s$4");const Hr=bt(e=>{try{JSON.parse(e)}catch{return!1}return!0},"isJson");let Yr=class{static{m(this,"g")}static{bt(this,"FileCache")}#n;#e;#r;#t=!0;#o=new Map;constructor(t,o,n,r){this.#n=t,this.#r=n,o===void 0?r.debug({message:"Could not create cache directory.",prefix:"file-cache"}):(this.#e=o,r.debug({message:"Cache path is: "+this.#e,prefix:"file-cache"}))}set isEnabled(t){this.#t=t}has(t,o){return!this.#t||this.#e===void 0?!1:k.isAccessibleSync(this.getFilePath(t,o))}get(t,o){if(!this.#t||this.#e===void 0)return;const n=this.getFilePath(t,o);if(this.#o.has(n))return this.#o.get(n);if(!k.isAccessibleSync(n))return;const r=k.readFileSync(n);if(Hr(r)){const i=JSON.parse(r);return this.#o.set(n,i),i}return this.#o.set(n,r),r}set(t,o,n){if(!this.#t||this.#e===void 0||o===void 0)return;const r=this.getFilePath(t,n);typeof o=="object"&&(o=JSON.stringify(o)),k.writeFileSync(r,o,{overwrite:!0})}getFilePath(t,o){let n=t.replaceAll(f.toNamespacedPath(this.#n),"");return n=n.replaceAll(":","-"),f.join(this.#e,this.#r,o?.replaceAll(":","-")??"",f.toNamespacedPath(n))}};var Qr=Object.defineProperty,Zr=m((e,t)=>Qr(e,"name",{value:t,configurable:!0}),"t$1");const ei=Zr(async(e,t="")=>{let o=t;if(!o){const n=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for await(const r of n)if(await k.isAccessible(f.join(e,r))){o="./"+r;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(o))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");return o},"findPackemFile");var ti=Object.defineProperty,K=m((e,t)=>ti(e,"name",{value:t,configurable:!0}),"l$3");const oi=P.createFilter,ni=K((e,t)=>{const{sideEffects:o}=t;let n;if(typeof o=="boolean")n=K(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)n=K(()=>!1,"hasSideEffects");else{const r=o.map(i=>i.includes("/")?i:`**/${i}`);n=oi(r,null,{resolve:e})}else n=K(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var ri=Object.defineProperty,ii=m((e,t)=>ri(e,"name",{value:t,configurable:!0}),"n");const jt=ii(e=>{const t=f.join(e,"package.json");if(!k.isAccessibleSync(t))throw new Error("package.json not found at "+t);return{packageJson:Gt.parsePackageJson(t),packageJsonPath:t}},"loadPackageJson");var si=Object.defineProperty,ai=m((e,t)=>si(e,"name",{value:t,configurable:!0}),"r$2");const Ae=ai((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
71
+ `,"normalizeCodeFrame"),yt=be(e=>{const t=Gr(e);let o=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(o+=`
72
+ file: ${j.cyan(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(o+=`
73
+ `+j.yellow(Kr(e.frame))),e.message=o,t!==void 0&&(e.stack=`${e.message}
74
+ ${t}`)},"enhanceRollupError");var Xr=Object.defineProperty,vt=m((e,t)=>Xr(e,"name",{value:t,configurable:!0}),"n$1");const te="rollup-watch.json",Ie=vt(({context:e,fileCache:t,mode:o,runBuilder:n,watcher:r})=>{const s="watcher:"+o;r.on("change",(i,{event:a})=>{e.logger.info({message:`${j.cyan(f.relative(".",i))} was ${a}d`,prefix:s})}),r.on("restart",()=>{e.logger.info({message:"Rebuilding ...",prefix:s})}),r.on("event",async i=>{switch(i.code){case"END":{e.logger.success({message:"Rebuild finished",prefix:s});break}case"BUNDLE_START":{e.logger.info({message:j.cyan("build started..."),prefix:s});break}case"BUNDLE_END":{await i.result.close(),t.set(o==="bundle"?te:"dts-"+te,i.result.cache),e.logger.raw(`
75
+ ⚡️ Build run in `+i.duration+`ms
76
+
77
+ `),n&&await n(!0);break}case"ERROR":{yt(i.error),e.logger.error({context:[i.error],message:"Rebuild failed: "+i.error.message,prefix:s});break}}})},"watchHandler"),Hr=vt(async(e,t,o)=>{const n=await mt(e,t);if(await e.hooks.callHook("rollup:options",e,n),Object.keys(n.input).length===0)return;(!e.options.rollup.isolatedDeclarations||!e.options.isolatedDeclarationTransformer)&&(n.cache=t.get(te)),e.options.rollup.watch&&typeof n.watch=="object"&&n.watch.include===void 0&&(n.watch={...n.watch,...e.options.rollup.watch},n.watch.include=[f.join(e.options.sourceDir,"**","*"),"package.json"],Array.isArray(e.options.rollup.watch.include)?n.watch.include=[...n.watch.include,...e.options.rollup.watch.include]:e.options.rollup.watch.include&&n.watch.include.push(e.options.rollup.watch.include),n.watch.chokidar={cwd:e.options.rootDir,...n.watch.chokidar,ignored:["**/.git/**","**/node_modules/**","**/test-results/**",...n.watch.chokidar?.ignored??[]]});const r=B.watch(n);await e.hooks.callHook("rollup:watch",e,r);const s=[...Array.isArray(n.input)?n.input:typeof n.input=="string"?[n.input]:Object.keys(n.input??{})];let i="Starting watcher for entries:";for(const a of s)i+=j.gray(`
78
+ └─ ${f.relative(process.cwd(),a)}`);if(e.logger.info(i),Ie({context:e,fileCache:t,mode:"bundle",runBuilder:o,watcher:r}),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer)e.logger.info({message:"Using isolated declaration transformer to generate declaration files...",prefix:"dts"});else if(e.options.declaration){const a=await gt(e,t);a.cache=t.get("dts-"+te),await e.hooks.callHook("rollup:dts:options",e,a);const l=B.watch(a);await e.hooks.callHook("rollup:watch",e,l),Ie({context:e,fileCache:t,mode:"types",watcher:l})}},"watch");var Yr=Object.defineProperty,bt=m((e,t)=>Yr(e,"name",{value:t,configurable:!0}),"s$4");const Qr=bt(e=>{try{JSON.parse(e)}catch{return!1}return!0},"isJson");let Zr=class{static{m(this,"g")}static{bt(this,"FileCache")}#n;#e;#r;#t=!0;#o=new Map;constructor(t,o,n,r){this.#n=t,this.#r=n,o===void 0?r.debug({message:"Could not create cache directory.",prefix:"file-cache"}):(this.#e=o,r.debug({message:"Cache path is: "+this.#e,prefix:"file-cache"}))}set isEnabled(t){this.#t=t}has(t,o){return!this.#t||this.#e===void 0?!1:k.isAccessibleSync(this.getFilePath(t,o))}get(t,o){if(!this.#t||this.#e===void 0)return;const n=this.getFilePath(t,o);if(this.#o.has(n))return this.#o.get(n);if(!k.isAccessibleSync(n))return;const r=k.readFileSync(n);if(Qr(r)){const s=JSON.parse(r);return this.#o.set(n,s),s}return this.#o.set(n,r),r}set(t,o,n){if(!this.#t||this.#e===void 0||o===void 0)return;const r=this.getFilePath(t,n);typeof o=="object"&&(o=JSON.stringify(o)),k.writeFileSync(r,o,{overwrite:!0})}getFilePath(t,o){let n=t.replaceAll(f.toNamespacedPath(this.#n),"");return n=n.replaceAll(":","-"),f.join(this.#e,this.#r,o?.replaceAll(":","-")??"",f.toNamespacedPath(n))}};var ei=Object.defineProperty,ti=m((e,t)=>ei(e,"name",{value:t,configurable:!0}),"t$1");const oi=ti(async(e,t="")=>{let o=t;if(!o){const n=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for await(const r of n)if(await k.isAccessible(f.join(e,r))){o="./"+r;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(o))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");return o},"findPackemFile");var ni=Object.defineProperty,K=m((e,t)=>ni(e,"name",{value:t,configurable:!0}),"l$3");const ri=C.createFilter,ii=K((e,t)=>{const{sideEffects:o}=t;let n;if(typeof o=="boolean")n=K(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)n=K(()=>!1,"hasSideEffects");else{const r=o.map(s=>s.includes("/")?s:`**/${s}`);n=ri(r,null,{resolve:e})}else n=K(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var si=Object.defineProperty,ai=m((e,t)=>si(e,"name",{value:t,configurable:!0}),"n");const jt=ai(e=>{const t=f.join(e,"package.json");if(!k.isAccessibleSync(t))throw new Error("package.json not found at "+t);return{packageJson:Xt.parsePackageJson(t),packageJsonPath:t}},"loadPackageJson");var li=Object.defineProperty,ci=m((e,t)=>li(e,"name",{value:t,configurable:!0}),"r$2");const Ae=ci((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
76
79
  `),e.logger.warn(`Build is done with some warnings:
77
80
 
78
81
  ${[...e.warnings].map(o=>`- ${o}`).join(`
79
- `)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logBuildErrors");var li=Object.defineProperty,wt=m((e,t)=>li(e,"name",{value:t,configurable:!0}),"r$1");const Me=wt(async(e,t)=>{if(typeof e.name!="string"){let o=f.isAbsolute(e.input)?f.relative(t.options.rootDir,e.input):f.normalize(e.input);o.startsWith("./")&&(o=o.slice(2)),e.name=o.replace(new RegExp(`^${t.options.sourceDir}/`),"").replace($.ENDING_RE,"")}if(!e.input)throw new Error(`Missing entry input: ${JSON.stringify(e)}`);Xt.isRelative(e.input)&&(e.input=f.resolve(t.options.rootDir,e.input)),t.options.declaration&&e.declaration===void 0&&(e.declaration=t.options.declaration),e.executable&&(e.cjs===void 0||e.esm===void 0)?t.pkg.type==="commonjs"&&e.cjs===void 0&&t.options.emitCJS!==void 0?(e.cjs=t.options.emitCJS,e.esm=!1):t.pkg.type==="module"&&e.esm===void 0&&t.options.emitESM!==void 0&&(e.esm=t.options.emitESM,e.cjs=!1):e.cjs===void 0&&e.esm===void 0&&(t.options.emitCJS!==void 0&&(e.cjs=t.options.emitCJS),t.options.emitESM!==void 0&&(e.esm=t.options.emitESM)),e.outDir=f.resolve(t.options.rootDir,e.outDir??t.options.outDir)},"extendEntry"),ci=wt(async e=>{e.options.entries=e.options.entries.map(t=>typeof t=="string"?{input:t,isGlob:X.isDynamicPattern(t)}:{...t,exportKey:t.exportKey??new Set,isGlob:X.isDynamicPattern(t.input)});for(const t of e.options.entries.filter(o=>o.isGlob)){const{isGlob:o,...n}=t,r=["**/.git/**","**/node_modules/**","**/test-results/**"];if(e.options.rollup.watch){if(typeof e.options.rollup.watch.exclude=="string")r.push(e.options.rollup.watch.exclude);else if(Array.isArray(e.options.rollup.watch.exclude))for(const s of e.options.rollup.watch.exclude)typeof s=="string"&&r.push(s)}const i=X.globSync([n.input],{cwd:e.options.rootDir,dot:!1,ignore:r,onlyFiles:!0});if(i.length===0)throw new Kt.NotFoundError("No files found in the glob pattern: "+b.cyan(f.join(e.options.rootDir,n.input)));for(const s of i)e.options.entries.push({...n,input:f.resolve(e.options.rootDir,s)});e.options.entries.splice(e.options.entries.indexOf(t),1)}for await(const t of e.options.entries.filter(o=>o.fileAlias===void 0))await Me(t,e);for await(const t of e.options.entries.filter(o=>o.fileAlias!==void 0))t.name=t.fileAlias,t.fileAlias=void 0,await Me(t,e)},"prepareEntries");var pi=Object.defineProperty,ui=m((e,t)=>pi(e,"name",{value:t,configurable:!0}),"o");const di=ui(e=>{if(e.options.validation?.packageJson?.dependencies===!1)return;const t=new Set,o=new Set(Object.keys(e.pkg?.dependencies??{})),n=new Set;for(const r of e.usedImports)o.delete(r),t.add(r);if(e.pkg?.dependencies)for(const r of Object.keys(e.pkg?.dependencies))o.delete(r);for(const r of t){const i=Ve(r);!de(e.options.externals,r)&&!r.startsWith("chunks/")&&e.pkg?.dependencies?.[i]===void 0&&e.pkg?.peerDependencies?.[i]===void 0&&n.add(r)}o.size>0&&E(e,`Potential unused dependencies found: ${[...o].map(r=>b.cyan(r)).join(", ")}`),n.size>0&&E(e,`Potential implicit dependencies found: ${[...n].map(r=>b.cyan(r)).join(", ")}`)},"validateDependencies");var fi=Object.defineProperty,$t=m((e,t)=>fi(e,"name",{value:t,configurable:!0}),"i$1");const mi=$t((e,t)=>Ht.distance(e,t)<=e.length/3||t.includes(e),"isSimilar"),gi=$t((e,t)=>{const o=e.toLowerCase();return t.filter(n=>mi(n.toLowerCase(),o))},"findAlternatives");var hi=Object.defineProperty,Fe=m((e,t)=>hi(e,"name",{value:t,configurable:!0}),"r");const yi=Fe(e=>{const{options:t}=e;if(t.validation?.packageJson?.exports===!1)return;const o=t.validation?.packageJson,n=new Set([t.declaration&&o?.types?e.pkg.types:"",t.declaration&&o?.types?e.pkg.typings:"",...t.dtsOnly||o?.bin===!1?[""]:typeof e.pkg.bin=="string"?[e.pkg.bin]:Object.values(e.pkg.bin??{}),t.dtsOnly&&o?.main===!1?"":e.pkg.main,t.dtsOnly&&o?.module===!1?"":e.pkg.module,...o?.exports===!1?[]:ve(e.pkg.exports,e.pkg.type==="module"?"esm":"cjs",t.declaration).map(a=>t.dtsOnly?a.subKey==="types"?a.file:void 0:a.file)].filter(Boolean).map(a=>a&&f.resolve(t.rootDir,a.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),r=[];for(const a of n)a&&!a.includes("*")&&!oe.existsSync(a)&&r.push(a.replace(`${t.rootDir}/`,""));const i=Fe(a=>f.relative(t.rootDir,f.resolve(t.outDir,a)),"rPath"),s=e.buildEntries.filter(a=>!a.chunk).map(a=>i(a.path));if(r.length>0){let a="Potential missing or wrong package.json files:";for(const l of r){const c=gi(l,s);a+=`
80
- - `+b.cyan(l)+(c.length>0?b.grey` (did you mean ${c.map(u=>`"${u}"`).join(", ")}?)`:"")}E(e,a)}},"validatePackageEntries");var vi=Object.defineProperty,bi=m((e,t)=>vi(e,"name",{value:t,configurable:!0}),"l$1");const ji=bi(e=>{const{options:{validation:t},pkg:o}=e;o.name===void 0&&t?.packageJson?.name!==!1&&E(e,"The 'name' field is missing in your package.json. Please provide a valid package name."),t?.packageJson?.files!==!1&&(o.files===void 0?E(e,"The 'files' field is missing in your package.json. Add the files to be included in the package."):o.files.length===0?E(e,"The 'files' field in your package.json is empty. Please specify the files to be included in the package."):o.files.some(i=>i.includes(e.options.outDir))||E(e,`The 'files' field in your package.json is missing the '${e.options.outDir}' directory. Ensure the output directory is included.`));const n=o.type==="commonjs"||o.type===void 0,r=o.type==="module";if(n?(t?.packageJson?.main!==!1&&(o.main===void 0&&E(e,"The 'main' field is missing in your package.json. This field should point to your main entry file."),o.main?.includes(".mjs")&&E(e,"The 'main' field in your package.json should not use a '.mjs' extension for CommonJS modules.")),t?.packageJson?.module!==!1&&(o.module===void 0&&e.options.emitESM&&E(e,"The 'module' field is missing in your package.json, but you are emitting ES modules."),o.module&&o.main&&o.module===o.main&&E(e,`Conflict detected: The 'module' and 'main' fields both point to '${o.module}'. Please ensure they refer to different module types.`),e.options.emitESM&&o.module?.includes(".cjs")&&E(e,"The 'module' field in your package.json should not use a '.cjs' extension for ES modules."))):r&&(o.exports===void 0&&!e.options.emitCJS?t?.packageJson?.exports!==!1&&E(e,"The 'exports' field is missing in your package.json. Define module exports explicitly."):e.options.emitCJS&&(t?.packageJson?.main!==!1&&o.main===void 0&&E(e,"The 'main' field is missing in your package.json. This field is needed when emitting CommonJS modules."),t?.packageJson?.module!==!1&&(o.module===void 0&&E(e,"The 'module' field is missing in your package.json. This field is necessary when emitting ES modules."),o.module?.includes(".cjs")&&E(e,"The 'module' field should not use a '.cjs' extension for ES modules."),o.module&&o.main&&o.module===o.main&&E(e,`Conflict detected: The 'module' and 'main' fields both point to '${o.module}'. Please ensure they refer to different module types.`)),t?.packageJson?.exports!==!1&&o.exports===void 0&&E(e,"The 'exports' field is missing in your package.json. This field is required for defining explicit exports."))),o.exports,t?.packageJson?.bin!==!1){if(typeof o.bin=="string"&&o.bin.includes(n?".mjs":".cjs"))E(e,`The 'bin' field in your package.json should not use a ${n?".mjs":".cjs"} extension for ${n?"CommonJS":"ES modules"} binaries.`);else if(typeof o.bin=="object")for(const[i,s]of Object.entries(o.bin))s&&s.includes(n?".mjs":".cjs")&&E(e,`The 'bin.${i}' field in your package.json should not use a ${n?".mjs":".cjs"} extension for ${n?"CommonJS":"ES modules"} binaries.`)}if(e.options.declaration){let i=!0;o.type==="module"&&(i=!!o.main?.endsWith(".cjs")),o.types===void 0&&o.typings===void 0&&i&&t?.packageJson?.types!==!1&&E(e,"The 'types' field is missing in your package.json. This field should point to your type definitions file."),(e.options.declaration===!0||e.options.declaration==="compatible")&&i&&t?.packageJson?.typesVersions!==!1&&(o.typesVersions===void 0||Object.keys(o.typesVersions).length===0)&&E(e,"No 'typesVersions' field found in your package.json. Consider adding this field, or change the declaration option to 'node16' or 'false'.")}},"validatePackageFields");var wi=Object.defineProperty,$i=m((e,t)=>wi(e,"name",{value:t,configurable:!0}),"i");const ki=$i(e=>{const{packageJson:t}=jt(e.options.rootDir);e.pkg=t,di(e),ji(e),yi(e)},"validator");var Ei=Object.defineProperty,xi=m((e,t)=>Ei(e,"name",{value:t,configurable:!0}),"a");const Si=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,Oi=new Set(["abstract","await","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"]),Je=xi(e=>{if(!Array.isArray(e)&&e!==null)for(const[t,o]of Object.entries(e)){if(typeof t!="string"||t.trim()==="")throw new Error(`Alias name "${t}" is invalid. Alias names should be non-empty strings.`);if(Si.test(t))throw new Error(`Alias name "${t}" is invalid. Alias names should start with a letter or underscore and only contain letters, numbers, underscores, and dashes.`);if(Oi.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const n=f.resolve(o);if(!k.isAccessibleSync(n))throw new Error(`Target path "${n}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var Di=Object.defineProperty,D=m((e,t)=>Di(e,"name",{value:t,configurable:!0}),"u");const Ni=D(e=>{switch(e){case"preserve":case"react-native":return"preserve";case"react":return"transform";case"react-jsx":case"react-jsxdev":return"automatic";default:return}},"resolveTsconfigJsxToJsxRuntime"),_i=D((e,t,o,n,r,i,s,a,l)=>{const c=Ni(l?.config.compilerOptions?.jsx),u=Nt.defu(i,r,s,{alias:{},cjsInterop:!1,clean:!0,debug:n,declaration:void 0,emitCJS:void 0,emitESM:void 0,entries:[],externals:[...we.builtinModules,...we.builtinModules.map(p=>`node:${p}`)],failOnWarn:!0,fileCache:!0,jiti:{alias:{},debug:n,interopDefault:!0},minify:o===$.PRODUCTION_ENV,name:(a.name??"").split("/").pop()??"default",outDir:l?.config.compilerOptions?.outDir??"dist",rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{extensions:[".mjs",".js",".json",".node",".cjs"],ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:l?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,moduleResolution:100,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},esbuild:{charset:"utf8",exclude:$.EXCLUDE_REGEXP,jsx:c,jsxDev:l?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:l?.config.compilerOptions?.jsxFactory,jsxFragment:l?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:l?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,sourcesContent:!1,target:l?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:l?.config},isolatedDeclarations:{exclude:$.EXCLUDE_REGEXP,ignoreErrors:!1,include:$.ALLOWED_TRANSFORM_EXTENSIONS_REGEX},json:{preferConst:!0},license:{dependenciesTemplate:D((p,d,h)=>`
82
+ `)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logBuildErrors");var pi=Object.defineProperty,wt=m((e,t)=>pi(e,"name",{value:t,configurable:!0}),"r$1");const Me=wt(async(e,t)=>{if(typeof e.name!="string"){let o=f.isAbsolute(e.input)?f.relative(t.options.rootDir,e.input):f.normalize(e.input);o.startsWith("./")&&(o=o.slice(2)),e.name=o.replace(new RegExp(`^${t.options.sourceDir}/`),"").replace($.ENDING_RE,"")}if(!e.input)throw new Error(`Missing entry input: ${JSON.stringify(e)}`);Yt.isRelative(e.input)&&(e.input=f.resolve(t.options.rootDir,e.input)),t.options.declaration&&e.declaration===void 0&&(e.declaration=t.options.declaration),e.executable&&(e.cjs===void 0||e.esm===void 0)?t.pkg.type==="commonjs"&&e.cjs===void 0&&t.options.emitCJS!==void 0?(e.cjs=t.options.emitCJS,e.esm=!1):t.pkg.type==="module"&&e.esm===void 0&&t.options.emitESM!==void 0&&(e.esm=t.options.emitESM,e.cjs=!1):e.cjs===void 0&&e.esm===void 0&&(t.options.emitCJS!==void 0&&(e.cjs=t.options.emitCJS),t.options.emitESM!==void 0&&(e.esm=t.options.emitESM)),e.outDir=f.resolve(t.options.rootDir,e.outDir??t.options.outDir)},"extendEntry"),ui=wt(async e=>{e.options.entries=e.options.entries.map(t=>typeof t=="string"?{input:t,isGlob:X.isDynamicPattern(t)}:{...t,exportKey:t.exportKey??new Set,isGlob:X.isDynamicPattern(t.input)});for(const t of e.options.entries.filter(o=>o.isGlob)){const{isGlob:o,...n}=t,r=["**/.git/**","**/node_modules/**","**/test-results/**"];if(e.options.rollup.watch){if(typeof e.options.rollup.watch.exclude=="string")r.push(e.options.rollup.watch.exclude);else if(Array.isArray(e.options.rollup.watch.exclude))for(const i of e.options.rollup.watch.exclude)typeof i=="string"&&r.push(i)}const s=X.globSync([n.input],{cwd:e.options.rootDir,dot:!1,ignore:r,onlyFiles:!0});if(s.length===0)throw new Ht.NotFoundError("No files found in the glob pattern: "+j.cyan(f.join(e.options.rootDir,n.input)));for(const i of s)e.options.entries.push({...n,input:f.resolve(e.options.rootDir,i)});e.options.entries.splice(e.options.entries.indexOf(t),1)}for await(const t of e.options.entries.filter(o=>o.fileAlias===void 0))await Me(t,e);for await(const t of e.options.entries.filter(o=>o.fileAlias!==void 0))t.name=t.fileAlias,t.fileAlias=void 0,await Me(t,e)},"prepareEntries");var di=Object.defineProperty,fi=m((e,t)=>di(e,"name",{value:t,configurable:!0}),"o");const mi=fi(e=>{if(e.options.validation?.packageJson?.dependencies===!1)return;const t=new Set,o=new Set(Object.keys(e.pkg?.dependencies??{})),n=new Set;for(const r of e.usedImports)o.delete(r),t.add(r);if(e.pkg?.dependencies)for(const r of Object.keys(e.pkg?.dependencies))o.delete(r);for(const r of t){const s=Ve(r);!de(e.options.externals,r)&&!r.startsWith("chunks/")&&e.pkg?.dependencies?.[s]===void 0&&e.pkg?.peerDependencies?.[s]===void 0&&n.add(r)}o.size>0&&E(e,`Potential unused dependencies found: ${[...o].map(r=>j.cyan(r)).join(", ")}`),n.size>0&&E(e,`Potential implicit dependencies found: ${[...n].map(r=>j.cyan(r)).join(", ")}`)},"validateDependencies");var gi=Object.defineProperty,$t=m((e,t)=>gi(e,"name",{value:t,configurable:!0}),"i$1");const hi=$t((e,t)=>Qt.distance(e,t)<=e.length/3||t.includes(e),"isSimilar"),yi=$t((e,t)=>{const o=e.toLowerCase();return t.filter(n=>hi(n.toLowerCase(),o))},"findAlternatives");var vi=Object.defineProperty,Fe=m((e,t)=>vi(e,"name",{value:t,configurable:!0}),"r");const bi=Fe(e=>{const{options:t}=e;if(t.validation?.packageJson?.exports===!1)return;const o=t.validation?.packageJson,n=new Set([t.declaration&&o?.types?e.pkg.types:"",t.declaration&&o?.types?e.pkg.typings:"",...t.dtsOnly||o?.bin===!1?[""]:typeof e.pkg.bin=="string"?[e.pkg.bin]:Object.values(e.pkg.bin??{}),t.dtsOnly&&o?.main===!1?"":e.pkg.main,t.dtsOnly&&o?.module===!1?"":e.pkg.module,...o?.exports===!1?[]:ve(e.pkg.exports,e.pkg.type==="module"?"esm":"cjs",t.declaration).map(a=>t.dtsOnly?a.subKey==="types"?a.file:void 0:a.file)].filter(Boolean).map(a=>a&&f.resolve(t.rootDir,a.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),r=[];for(const a of n)a&&!a.includes("*")&&!oe.existsSync(a)&&r.push(a.replace(`${t.rootDir}/`,""));const s=Fe(a=>f.relative(t.rootDir,f.resolve(t.outDir,a)),"rPath"),i=e.buildEntries.filter(a=>!a.chunk).map(a=>s(a.path));if(r.length>0){let a="Potential missing or wrong package.json files:";for(const l of r){const c=yi(l,i);a+=`
83
+ - `+j.cyan(l)+(c.length>0?j.grey` (did you mean ${c.map(u=>`"${u}"`).join(", ")}?)`:"")}E(e,a)}},"validatePackageEntries");var ji=Object.defineProperty,wi=m((e,t)=>ji(e,"name",{value:t,configurable:!0}),"l$1");const $i=wi(e=>{const{options:{validation:t},pkg:o}=e;o.name===void 0&&t?.packageJson?.name!==!1&&E(e,"The 'name' field is missing in your package.json. Please provide a valid package name."),t?.packageJson?.files!==!1&&(o.files===void 0?E(e,"The 'files' field is missing in your package.json. Add the files to be included in the package."):o.files.length===0?E(e,"The 'files' field in your package.json is empty. Please specify the files to be included in the package."):o.files.some(s=>s.includes(e.options.outDir))||E(e,`The 'files' field in your package.json is missing the '${e.options.outDir}' directory. Ensure the output directory is included.`));const n=o.type==="commonjs"||o.type===void 0,r=o.type==="module";if(n?(t?.packageJson?.main!==!1&&(o.main===void 0&&E(e,"The 'main' field is missing in your package.json. This field should point to your main entry file."),o.main?.includes(".mjs")&&E(e,"The 'main' field in your package.json should not use a '.mjs' extension for CommonJS modules.")),t?.packageJson?.module!==!1&&(o.module===void 0&&e.options.emitESM&&E(e,"The 'module' field is missing in your package.json, but you are emitting ES modules."),o.module&&o.main&&o.module===o.main&&E(e,`Conflict detected: The 'module' and 'main' fields both point to '${o.module}'. Please ensure they refer to different module types.`),e.options.emitESM&&o.module?.includes(".cjs")&&E(e,"The 'module' field in your package.json should not use a '.cjs' extension for ES modules."))):r&&(o.exports===void 0&&!e.options.emitCJS?t?.packageJson?.exports!==!1&&E(e,"The 'exports' field is missing in your package.json. Define module exports explicitly."):e.options.emitCJS&&(t?.packageJson?.main!==!1&&o.main===void 0&&E(e,"The 'main' field is missing in your package.json. This field is needed when emitting CommonJS modules."),t?.packageJson?.module!==!1&&(o.module===void 0&&E(e,"The 'module' field is missing in your package.json. This field is necessary when emitting ES modules."),o.module?.includes(".cjs")&&E(e,"The 'module' field should not use a '.cjs' extension for ES modules."),o.module&&o.main&&o.module===o.main&&E(e,`Conflict detected: The 'module' and 'main' fields both point to '${o.module}'. Please ensure they refer to different module types.`)),t?.packageJson?.exports!==!1&&o.exports===void 0&&E(e,"The 'exports' field is missing in your package.json. This field is required for defining explicit exports."))),o.exports,t?.packageJson?.bin!==!1){if(typeof o.bin=="string"&&o.bin.includes(n?".mjs":".cjs"))E(e,`The 'bin' field in your package.json should not use a ${n?".mjs":".cjs"} extension for ${n?"CommonJS":"ES modules"} binaries.`);else if(typeof o.bin=="object")for(const[s,i]of Object.entries(o.bin))i&&i.includes(n?".mjs":".cjs")&&E(e,`The 'bin.${s}' field in your package.json should not use a ${n?".mjs":".cjs"} extension for ${n?"CommonJS":"ES modules"} binaries.`)}if(e.options.declaration){let s=!0;o.type==="module"&&(s=!!o.main?.endsWith(".cjs")),o.types===void 0&&o.typings===void 0&&s&&t?.packageJson?.types!==!1&&E(e,"The 'types' field is missing in your package.json. This field should point to your type definitions file."),(e.options.declaration===!0||e.options.declaration==="compatible")&&s&&t?.packageJson?.typesVersions!==!1&&(o.typesVersions===void 0||Object.keys(o.typesVersions).length===0)&&E(e,"No 'typesVersions' field found in your package.json. Consider adding this field, or change the declaration option to 'node16' or 'false'.")}},"validatePackageFields");var ki=Object.defineProperty,Ei=m((e,t)=>ki(e,"name",{value:t,configurable:!0}),"i");const xi=Ei(e=>{const{packageJson:t}=jt(e.options.rootDir);e.pkg=t,mi(e),$i(e),bi(e)},"validator");var Si=Object.defineProperty,Oi=m((e,t)=>Si(e,"name",{value:t,configurable:!0}),"a");const Di=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,Ni=new Set(["abstract","await","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"]),Je=Oi(e=>{if(!Array.isArray(e)&&e!==null)for(const[t,o]of Object.entries(e)){if(typeof t!="string"||t.trim()==="")throw new Error(`Alias name "${t}" is invalid. Alias names should be non-empty strings.`);if(Di.test(t))throw new Error(`Alias name "${t}" is invalid. Alias names should start with a letter or underscore and only contain letters, numbers, underscores, and dashes.`);if(Ni.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const n=f.resolve(o);if(!k.isAccessibleSync(n))throw new Error(`Target path "${n}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var _i=Object.defineProperty,D=m((e,t)=>_i(e,"name",{value:t,configurable:!0}),"u");const Pi=D(e=>{switch(e){case"preserve":case"react-native":return"preserve";case"react":return"transform";case"react-jsx":case"react-jsxdev":return"automatic";default:return}},"resolveTsconfigJsxToJsxRuntime"),Ci=D((e,t,o,n,r,s,i,a,l)=>{const c=Pi(l?.config.compilerOptions?.jsx),u=Pt.defu(s,r,i,{alias:{},cjsInterop:!1,clean:!0,debug:n,declaration:void 0,emitCJS:void 0,emitESM:void 0,entries:[],externals:[...we.builtinModules,...we.builtinModules.map(p=>`node:${p}`)],failOnWarn:!0,fileCache:!0,jiti:{alias:{},debug:n,interopDefault:!0},minify:o===$.PRODUCTION_ENV,name:(a.name??"").split("/").pop()??"default",outDir:l?.config.compilerOptions?.outDir??"dist",rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{extensions:[".mjs",".js",".json",".node",".cjs"],ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:l?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,moduleResolution:100,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},esbuild:{charset:"utf8",exclude:$.EXCLUDE_REGEXP,jsx:c,jsxDev:l?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:l?.config.compilerOptions?.jsxFactory,jsxFragment:l?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:l?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,sourcesContent:!1,target:l?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:l?.config},isolatedDeclarations:{exclude:$.EXCLUDE_REGEXP,ignoreErrors:!1,include:$.ALLOWED_TRANSFORM_EXTENSIONS_REGEX},json:{preferConst:!0},license:{dependenciesTemplate:D((p,d,h)=>`
81
84
  # Licenses of bundled dependencies
82
85
  The published ${h} artifact additionally contains code with the following licenses:
83
86
  `+(p.length>0?`${p.join(", ")}
@@ -91,13 +94,15 @@ The published ${h} artifact additionally contains code with the following licens
91
94
 
92
95
  `:`
93
96
  `)+`# Bundled types:
94
- `+d,"dtsTemplate")},node10Compatibility:{},patchTypes:{},polyfillNode:{},preserveDirectives:{exclude:$.EXCLUDE_REGEXP,include:$.ALLOWED_TRANSFORM_EXTENSIONS_REGEX},preserveDynamicImports:!0,raw:{exclude:$.EXCLUDE_REGEXP,include:[/\.(md|txt|css|htm|html|data)$/]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,exportConditions:["module-sync"],extensions:$.DEFAULT_EXTENSIONS,preferBuiltins:!1},shebang:{replace:!1,shebang:"#!/usr/bin/env node"},shim:{exclude:$.EXCLUDE_REGEXP,include:$.ALLOWED_TRANSFORM_EXTENSIONS_REGEX},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:l?.config.compilerOptions?.esModuleInterop===!1,include:$.ALLOWED_TRANSFORM_EXTENSIONS_REGEX,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:o===$.PRODUCTION_ENV,...l?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(l.config.compilerOptions.jsx)?{jsxFragmentPragma:l.config.compilerOptions.jsxFragmentFactory,jsxImportSource:l.config.compilerOptions.jsxImportSource,jsxPragma:l.config.compilerOptions.jsxFactory,jsxRuntime:c,transforms:["typescript","jsx",...l.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...l?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:$.ALLOWED_TRANSFORM_EXTENSIONS_REGEX,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:l?.config.compilerOptions?.experimentalDecorators,syntax:l?"typescript":"ecmascript",[l?"tsx":"jsx"]:!0},target:l?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:l?.config.compilerOptions?.emitDecoratorMetadata,decoratorVersion:"2022-03",legacyDecorator:l?.config.compilerOptions?.experimentalDecorators,react:{development:o!==$.PRODUCTION_ENV,pragma:l?.config.compilerOptions?.jsxFactory,pragmaFrag:l?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:l?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:l?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:ni(t,a),preset:"recommended",propertyReadSideEffects:!0},visualizer:{},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:$.EXCLUDE_REGEXP}},rootDir:t,sourceDir:"src",sourcemap:!1,transformerName:void 0,typedoc:{excludePrivate:!0,groupOrder:["Classes","Constructors","Accessors","Methods","Functions","Namespaces","Variables","Enumerations","Interfaces","Type Aliases","*"],kindSortOrder:["Project","Module","Class","Interface","Function","Namespace","Variable","Enum","EnumMember","TypeAlias","Reference","Constructor","Property","Accessor","Method","Parameter","TypeParameter","TypeLiteral","CallSignature","ConstructorSignature","IndexSignature","GetSignature","SetSignature"],marker:"TYPEDOC",name:a.name??"unknown",pretty:!0,readme:"none",showConfig:n,tsconfig:l?.path}});if(!u.transformerName){const p=new Map([...Object.entries(a.dependencies??{}),...Object.entries(a.devDependencies??{})]);let d="0.0.0";if(p.has("esbuild"))u.transformerName="esbuild",d=p.get("esbuild");else if(p.has("@swc/core"))u.transformerName="swc",d=p.get("@swc/core");else if(p.has("sucrase"))u.transformerName="sucrase",d=p.get("sucrase");else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info("Using "+b.cyan("rollup ")+B.VERSION),e.info({message:"Using "+b.cyan(u.transformerName)+" "+d,prefix:"transformer"})}return u.rollup.resolve&&u.rollup.resolve.preferBuiltins===!0&&(u.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),a.dependencies&&u.externals.push(...Object.keys(a.dependencies)),a.peerDependencies&&u.externals.push(...Object.keys(a.peerDependencies)),a.optionalDependencies&&u.externals.push(...Object.keys(a.optionalDependencies)),Je(u.alias),u.rollup.alias&&u.rollup.alias.entries&&Je(u.rollup.alias.entries),u},"generateOptions"),Pi=D(async(e,t,o,n,r,i,s,a,l,c)=>{const u=await Lr(s.preset??i.preset??"auto",c),p=_i(e,t,n,r,i,s,u,a,l);k.ensureDirSync(f.join(p.rootDir,p.outDir));const d={buildEntries:[],dependencyGraphMap:new Map,environment:n,hooks:_t.createHooks(),jiti:Le.createJiti(p.rootDir,p.jiti),logger:e,mode:o,options:p,pkg:a,tsconfig:l,usedImports:new Set,warnings:new Set};u.hooks&&d.hooks.addHooks(u.hooks),i.hooks&&d.hooks.addHooks(i.hooks),s.hooks&&d.hooks.addHooks(s.hooks),await d.hooks.callHook("build:prepare",d),d.options.emitESM===void 0&&d.logger.info("Emitting of ESM bundles, is disabled."),d.options.emitCJS===void 0&&d.logger.info("Emitting of CJS bundles, is disabled."),d.options.minify&&d.logger.info("Minification is enabled, the output will be minified");const h=a.dependencies?.typescript!==void 0||a.devDependencies?.typescript!==void 0;if(d.options.declaration&&d.tsconfig===void 0&&h)throw new Error("Cannot build declaration files without a tsconfig.json");return h?d.options.declaration===!1&&d.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(d.options.declaration=!1,d.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),d.options.declaration&&d.logger.info("Using typescript version: "+b.cyan(a.devDependencies?.typescript??a.dependencies?.typescript??"unknown")),d.options.declaration&&(a.dependencies?.typescript||a.devDependencies?.typescript)&&!d.tsconfig?.config.compilerOptions?.isolatedModules&&d.logger.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
97
+ `+d,"dtsTemplate")},node10Compatibility:{},patchTypes:{},polyfillNode:{},preserveDirectives:{exclude:$.EXCLUDE_REGEXP,include:$.ALLOWED_TRANSFORM_EXTENSIONS_REGEX},preserveDynamicImports:!0,raw:{exclude:$.EXCLUDE_REGEXP,include:[/\.(md|txt|css|htm|html|data)$/]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,exportConditions:["module-sync"],extensions:$.DEFAULT_EXTENSIONS,preferBuiltins:!1},shebang:{replace:!1,shebang:"#!/usr/bin/env node"},shim:{exclude:$.EXCLUDE_REGEXP,include:$.ALLOWED_TRANSFORM_EXTENSIONS_REGEX},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:l?.config.compilerOptions?.esModuleInterop===!1,include:$.ALLOWED_TRANSFORM_EXTENSIONS_REGEX,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:o===$.PRODUCTION_ENV,...l?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(l.config.compilerOptions.jsx)?{jsxFragmentPragma:l.config.compilerOptions.jsxFragmentFactory,jsxImportSource:l.config.compilerOptions.jsxImportSource,jsxPragma:l.config.compilerOptions.jsxFactory,jsxRuntime:c,transforms:["typescript","jsx",...l.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...l?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:$.ALLOWED_TRANSFORM_EXTENSIONS_REGEX,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:l?.config.compilerOptions?.experimentalDecorators,syntax:l?"typescript":"ecmascript",[l?"tsx":"jsx"]:!0},target:l?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:l?.config.compilerOptions?.emitDecoratorMetadata,decoratorVersion:"2022-03",legacyDecorator:l?.config.compilerOptions?.experimentalDecorators,react:{development:o!==$.PRODUCTION_ENV,pragma:l?.config.compilerOptions?.jsxFactory,pragmaFrag:l?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:l?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:l?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:ii(t,a),preset:"recommended",propertyReadSideEffects:!0},visualizer:{},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:$.EXCLUDE_REGEXP}},rootDir:t,sourceDir:"src",sourcemap:!1,transformerName:void 0,typedoc:{excludePrivate:!0,groupOrder:["Classes","Constructors","Accessors","Methods","Functions","Namespaces","Variables","Enumerations","Interfaces","Type Aliases","*"],kindSortOrder:["Project","Module","Class","Interface","Function","Namespace","Variable","Enum","EnumMember","TypeAlias","Reference","Constructor","Property","Accessor","Method","Parameter","TypeParameter","TypeLiteral","CallSignature","ConstructorSignature","IndexSignature","GetSignature","SetSignature"],marker:"TYPEDOC",name:a.name??"unknown",pretty:!0,readme:"none",showConfig:n,tsconfig:l?.path}});if(!u.transformerName){const p=new Map([...Object.entries(a.dependencies??{}),...Object.entries(a.devDependencies??{})]);let d="0.0.0";if(p.has("esbuild"))u.transformerName="esbuild",d=p.get("esbuild");else if(p.has("@swc/core"))u.transformerName="swc",d=p.get("@swc/core");else if(p.has("sucrase"))u.transformerName="sucrase",d=p.get("sucrase");else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info("Using "+j.cyan("rollup ")+B.VERSION),e.info({message:"Using "+j.cyan(u.transformerName)+" "+d,prefix:"transformer"})}return u.rollup.resolve&&u.rollup.resolve.preferBuiltins===!0&&(u.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),a.dependencies&&u.externals.push(...Object.keys(a.dependencies)),a.peerDependencies&&u.externals.push(...Object.keys(a.peerDependencies)),a.optionalDependencies&&u.externals.push(...Object.keys(a.optionalDependencies)),Je(u.alias),u.rollup.alias&&u.rollup.alias.entries&&Je(u.rollup.alias.entries),u},"generateOptions"),Ti=D(async(e,t,o,n,r,s,i,a,l,c)=>{const u=await Wr(i.preset??s.preset??"auto",c),p=Ci(e,t,n,r,s,i,u,a,l);k.ensureDirSync(f.join(p.rootDir,p.outDir));const d={buildEntries:[],dependencyGraphMap:new Map,environment:n,hooks:Ct.createHooks(),jiti:Le.createJiti(p.rootDir,p.jiti),logger:e,mode:o,options:p,pkg:a,tsconfig:l,usedImports:new Set,warnings:new Set};u.hooks&&d.hooks.addHooks(u.hooks),s.hooks&&d.hooks.addHooks(s.hooks),i.hooks&&d.hooks.addHooks(i.hooks),await d.hooks.callHook("build:prepare",d),d.options.emitESM===void 0&&d.logger.info("Emitting of ESM bundles, is disabled."),d.options.emitCJS===void 0&&d.logger.info("Emitting of CJS bundles, is disabled."),d.options.minify&&d.logger.info("Minification is enabled, the output will be minified");const h=a.dependencies?.typescript!==void 0||a.devDependencies?.typescript!==void 0;if(d.options.declaration&&d.tsconfig===void 0&&h)throw new Error("Cannot build declaration files without a tsconfig.json");return h?d.options.declaration===!1&&d.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(d.options.declaration=!1,d.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),d.options.declaration&&d.logger.info("Using typescript version: "+j.cyan(a.devDependencies?.typescript??a.dependencies?.typescript??"unknown")),d.options.declaration&&(a.dependencies?.typescript||a.devDependencies?.typescript)&&!d.tsconfig?.config.compilerOptions?.isolatedModules&&d.logger.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
95
98
  Because none of the third-party transpiler, packem uses under the hood is type-aware, some techniques or features often used in TypeScript are not properly checked and can cause mis-compilation or even runtime errors.
96
- To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),await ci(d),d},"createContext"),Ci=D(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(n=>n.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(n=>o.startsWith(n))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${f.relative(e.options.rootDir,o)}\``),await k.emptyDir(o))},"cleanDistributionDirectories"),Ri=D(async(e,t,o)=>{if(e&&k.isAccessibleSync(f.join(e,"keystore1.json"))){const n=k.readJsonSync(f.join(e,"keystore.json")),r=oe.readdirSync(e,{withFileTypes:!0}).filter(s=>s.isDirectory());let i=o;for await(const s of r)n[s.name]||(await ne.rm(f.join(e,s.name),{force:!0,recursive:!0}),i&&t.raw(`
99
+ To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),await ui(d),d},"createContext"),Ri=D(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(n=>n.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(n=>o.startsWith(n))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${f.relative(e.options.rootDir,o)}\``),await k.emptyDir(o))},"cleanDistributionDirectories"),Ii=D(async(e,t,o)=>{if(e&&k.isAccessibleSync(f.join(e,"keystore1.json"))){const n=k.readJsonSync(f.join(e,"keystore.json")),r=oe.readdirSync(e,{withFileTypes:!0}).filter(i=>i.isDirectory());let s=o;for await(const i of r)n[i.name]||(await ne.rm(f.join(e,i.name),{force:!0,recursive:!0}),s&&t.raw(`
100
+
101
+ `),t.info({message:"Removing "+i.name+" file cache, the cache key is not used anymore.",prefix:"file-cache"}),s=!1)}},"removeOldCacheFolders"),Ai=D(e=>{switch(e){case"jit":return"Stubbing";case"watch":return"Watching";case"tsdoc":return"Generating TSDoc";default:return"Building"}},"getMode"),Mi=D(async(e,t,o,n,r={})=>{const{configPath:s,debug:i,tsconfigPath:a,...l}=r;n.wrapAll(),e=f.resolve(ge.cwd(),e),n.debug("Root directory:",e);const{packageJson:c,packageJsonPath:u}=jt(e);n.debug("Using package.json found at",u);let p;if(a){const y=f.join(e,a);if(!await k.isAccessible(y))throw new Error("tsconfig.json not found at "+y);p={config:je.readTsConfig(y),path:y},n.info("Using tsconfig settings at",y)}else if(c.dependencies?.typescript||c.devDependencies?.typescript)try{p=await je.findTsConfig(e),n.debug("Using tsconfig settings found at",p.path)}catch{n.info("No tsconfig.json or jsconfig.json found.")}const d=_t.findCacheDirSync("@visulima/packem",{cwd:e});let h=!1;try{const y=await oi(e,s??""),g=Le.createJiti(e,{debug:i});let v=await g.import(y,{default:!0,try:!0})||{};typeof v=="function"&&(v=await v(o,t)),n.debug("Using packem config found at",f.join(e,y));const w=T(JSON.stringify({version:c.version,...c.dependencies,...c.devDependencies,...c.peerDependencies,...c.peerDependenciesMeta,browser:c.browser,eNode:c.engines?.node,exports:c.exports,main:c.main,module:c.module,type:c.type,types:c.types}))+T(JSON.stringify(v));d&&We.d(w,d,n);const x=new Zr(e,d,w,n),b=await Ti(n,e,t,o,i??!1,l,v,c,p,g);x.isEnabled=b.options.fileCache,b.logger.info(j.cyan(Ai(t)+" "+b.options.name)),b.logger.debug({context:b.options.entries,message:`${j.bold("Root dir:")} ${b.options.rootDir}
102
+ ${j.bold("Entries:")}}`}),await Ri(b);const P=D(async Et=>{for await(const[ae,xt]of Object.entries(b.options.builder??{})){b.logger.raw(`
103
+ `),await b.hooks.callHook("builder:before",ae,b);const St=Date.now(),Ot=D(()=>_.duration(Math.floor(Date.now()-St)),"getBuilderDuration");await xt(b,d,x,h),await b.hooks.callHook("builder:done",ae,b),b.logger.raw(`
104
+ ⚡️ `+ae+" run in "+Ot()),Et&&b.logger.raw(`
97
105
 
98
- `),t.info({message:"Removing "+s.name+" file cache, the cache key is not used anymore.",prefix:"file-cache"}),i=!1)}},"removeOldCacheFolders"),Ti=D(e=>{switch(e){case"jit":return"Stubbing";case"watch":return"Watching";case"tsdoc":return"Generating TSDoc";default:return"Building"}},"getMode"),Ii=D(async(e,t,o,n,r={})=>{const{configPath:i,debug:s,tsconfigPath:a,...l}=r;n.wrapAll(),e=f.resolve(ge.cwd(),e),n.debug("Root directory:",e);const{packageJson:c,packageJsonPath:u}=jt(e);n.debug("Using package.json found at",u);let p;if(a){const y=f.join(e,a);if(!await k.isAccessible(y))throw new Error("tsconfig.json not found at "+y);p={config:je.readTsConfig(y),path:y},n.info("Using tsconfig settings at",y)}else if(c.dependencies?.typescript||c.devDependencies?.typescript)try{p=await je.findTsConfig(e),n.debug("Using tsconfig settings found at",p.path)}catch{n.info("No tsconfig.json or jsconfig.json found.")}const d=Dt.findCacheDirSync("@visulima/packem",{cwd:e});let h=!1;try{const y=await ei(e,i??""),g=Le.createJiti(e,{debug:s});let v=await g.import(y,{default:!0,try:!0})||{};typeof v=="function"&&(v=await v(o,t)),n.debug("Using packem config found at",f.join(e,y));const w=R(JSON.stringify({version:c.version,...c.dependencies,...c.devDependencies,...c.peerDependencies,...c.peerDependenciesMeta,browser:c.browser,eNode:c.engines?.node,exports:c.exports,main:c.main,module:c.module,type:c.type,types:c.types}))+R(JSON.stringify(v));d&&We.d(w,d,n);const x=new Yr(e,d,w,n),j=await Pi(n,e,t,o,s??!1,l,v,c,p,g);x.isEnabled=j.options.fileCache,j.logger.info(b.cyan(Ti(t)+" "+j.options.name)),j.logger.debug({context:j.options.entries,message:`${b.bold("Root dir:")} ${j.options.rootDir}
99
- ${b.bold("Entries:")}}`}),await Ci(j);const C=Date.now(),U=D(()=>_.duration(Math.floor(Date.now()-C)),"getDuration");if(t==="watch"){if(j.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await Kr(j,x),Ae(j,!1);return}t==="jit"?(await qr(j),await j.hooks.callHook("build:done",j)):(h=await $r(j,x),await j.hooks.callHook("validate:before",j),ki(j),await j.hooks.callHook("validate:done",j),Ae(j,h)),j.logger.raw(`
100
- ⚡️ Build run in `+U());for await(const[ae,kt]of Object.entries(j.options.builder??{})){j.logger.raw(`
101
- `),await j.hooks.callHook("builder:before",ae,j);const Et=Date.now(),xt=D(()=>_.duration(Math.floor(Date.now()-Et)),"getBuilderDuration");await kt(j,d,x,h),await j.hooks.callHook("builder:done",ae,j),j.logger.raw(`
102
- ⚡️ `+ae+" run in "+xt())}j.logger.restoreAll()}catch(y){throw n.raw(`
103
- `),yt(y),y}finally{await Ri(d,n,h)}},"createBundler");module.exports=Ii;
106
+ `)}},"runBuilder"),U=Date.now(),kt=D(()=>_.duration(Math.floor(Date.now()-U)),"getDuration");if(t==="watch"){if(b.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await Hr(b,x,P),Ae(b,!1);return}t==="jit"?(await Vr(b),await b.hooks.callHook("build:done",b)):(h=await Er(b,x),await b.hooks.callHook("validate:before",b),xi(b),await b.hooks.callHook("validate:done",b),Ae(b,h)),b.logger.raw(`
107
+ ⚡️ Build run in `+kt()),await P()}catch(y){throw n.raw(`
108
+ `),yt(y),y}finally{n.restoreAll(),await Ii(d,n,h)}},"packem");module.exports=Mi;