@visulima/packem 1.0.0-alpha.96 → 1.0.0-alpha.97

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,19 +1,19 @@
1
- "use strict";var yt=Object.defineProperty;var m=(e,t)=>yt(e,"name",{value:t,configurable:!0});const vt=require("node:module"),ie=require("node:process"),v=require("@visulima/colorize"),$=require("@visulima/fs"),_=require("@visulima/humanizer"),bt=require("@visulima/package/package-json"),f=require("@visulima/path"),he=require("@visulima/tsconfig"),$t=require("defu"),jt=require("hookable"),J=require("rollup"),ae=require("node:fs/promises"),wt=require("@rollup/plugin-alias"),kt=require("@rollup/plugin-commonjs"),xt=require("@rollup/plugin-dynamic-import-vars"),Fe=require("@rollup/plugin-node-resolve"),Et=require("@rollup/plugin-replace"),St=require("@rollup/plugin-wasm"),Ot=require("rollup-plugin-polyfill-node"),Nt=require("rollup-plugin-visualizer"),Me=require("semver"),Dt=require("node:assert/strict"),D=require("@rollup/pluginutils"),_t=require("magic-string"),Pt=require("glob-parent"),Te=require("tinyglobby"),H=require("mlly"),Ct=require("oxc-parser"),k=require("./shared/constants-lwnJ_PjR.cjs"),It=require("@rollup/plugin-json"),Rt=require("rollup-plugin-license"),Ft=require("node:crypto"),Ae=require("node:url"),Mt=require("@babel/parser"),Tt=require("jiti"),le=require("node:fs"),At=require("@visulima/find-cache-dir"),Jt=require("@visulima/fs/error"),Lt=require("@visulima/path/utils"),qt=require("is-glob"),Bt=require("fastest-levenshtein");var ye=typeof document<"u"?document.currentScript:null;const E=m(e=>e&&typeof e=="object"&&"default"in e?e.default:e,"_interopDefaultCompat"),ve=E(vt),Je=E(wt),Wt=E(kt),Ut=E(xt),Le=E(Et),Vt=E(Ot),G=E(Dt),I=E(_t),zt=E(Pt),Ht=E(It),Gt=E(Rt),qe=E(Tt),be=E(qt);var Xt=Object.defineProperty,Kt=m((e,t)=>Xt(e,"name",{value:t,configurable:!0}),"a$f");const re=Kt((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var Yt=Object.defineProperty,Qt=m((e,t)=>Yt(e,"name",{value:t,configurable:!0}),"a$e");const A=Qt(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var Zt=Object.defineProperty,eo=m((e,t)=>Zt(e,"name",{value:t,configurable:!0}),"a$d");const Be=eo((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var to=Object.defineProperty,We=m((e,t)=>to(e,"name",{value:t,configurable:!0}),"s$g");const oo=We((e,t,o)=>{const n=o??new Map;return(...s)=>{const r=t?typeof t=="function"?t(...s):t:JSON.stringify({args:s}),i=n.get(r);if(i!==void 0)return i;const l=e(...s);return n.set(r,l),l}},"memoize"),no=We(e=>{const t=new Map;return o=>oo(e,o,t)},"memoizeByKey");var ro=Object.defineProperty,q=m((e,t)=>ro(e,"name",{value:t,configurable:!0}),"r$b");const so=q(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;G(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 D.extractAssignedNames(t.id))yield o;break}}},"exportName"),io=q(function*(e){if(e.declaration)for(const t of so(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"),ao=q(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),lo=q(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),co=q(function*(e,t){G(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*ao(n);break}case"ExportDefaultDeclaration":{yield*lo();break}case"ExportNamedDeclaration":{yield*io(n);break}}},"parseExports");var po=Object.defineProperty,B=m((e,t)=>po(e,"name",{value:t,configurable:!0}),"n$b");const Ue=B(async function(e,t,o){const n=await e.resolve(t,o.id);if(G(n,`Rollup can't resolve ${t} from ${o.id}`),n.external)return null;const s=await e.load(n);return G(s,`Rollup doesn't have a module for id ${n.id}`),s},"getImportedModule"),uo=B(async function*(e,t,o){const n=await Ue(e,t.source,o);n&&(yield*ce(e,n))},"gatherBarrelReExports"),mo=B(async function*(e,t,o){const n=await Ue(e,t.source,o);if(!n)return;const s=new Map(t.bindings.map(r=>[r.importedName,r]));for await(const r of ce(e,n)){const i=s.get(r.exportedName);i&&(yield{...r,exportedName:i.exportedName})}},"gatherNamedReExports"),fo=B(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),ce=B(async function*(e,t){for(const o of co(e,t))o.from==="self"?yield*fo(t,o):o.type==="barrel"?yield*uo(e,o,t):yield*mo(e,o,t)},"gatherExports");var go=Object.defineProperty,ho=m((e,t)=>go(e,"name",{value:t,configurable:!0}),"r$a");const yo=ho(()=>({moduleParsed:{async handler(e){if(e.isEntry)for await(const t of ce(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 vo=Object.defineProperty,$e=m((e,t)=>vo(e,"name",{value:t,configurable:!0}),"u$b");const Ve=$e(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk:$e(async(n,s,r)=>{if(s.type!=="chunk"||!s.isEntry)return null;if(r.format==="cjs"&&r.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(i===null||i.length<3)return null;const l=new I(n);l.replace("",""),l.replaceAll(/exports\.(.*) = (.*);/g,"module.module.exports.$1 = $2;"),e&&l.append(`
1
+ "use strict";var ht=Object.defineProperty;var m=(e,t)=>ht(e,"name",{value:t,configurable:!0});const yt=require("node:module"),ie=require("node:process"),v=require("@visulima/colorize"),$=require("@visulima/fs"),_=require("@visulima/humanizer"),vt=require("@visulima/package/package-json"),f=require("@visulima/path"),he=require("@visulima/tsconfig"),bt=require("defu"),$t=require("hookable"),J=require("rollup"),ae=require("node:fs/promises"),jt=require("@rollup/plugin-alias"),wt=require("@rollup/plugin-commonjs"),kt=require("@rollup/plugin-dynamic-import-vars"),Re=require("@rollup/plugin-node-resolve"),xt=require("@rollup/plugin-replace"),Et=require("@rollup/plugin-wasm"),St=require("rollup-plugin-polyfill-node"),Ot=require("rollup-plugin-visualizer"),Fe=require("semver"),Nt=require("node:assert/strict"),D=require("@rollup/pluginutils"),Dt=require("magic-string"),_t=require("glob-parent"),Me=require("tinyglobby"),H=require("mlly"),Pt=require("oxc-parser"),k=require("./shared/constants-lwnJ_PjR.cjs"),Ct=require("@rollup/plugin-json"),It=require("rollup-plugin-license"),Rt=require("node:crypto"),Ae=require("node:url"),Ft=require("@babel/parser"),Mt=require("jiti"),le=require("node:fs"),At=require("@visulima/find-cache-dir"),Tt=require("@visulima/fs/error"),Jt=require("@visulima/path/utils"),Lt=require("is-glob"),qt=require("fastest-levenshtein");var ye=typeof document<"u"?document.currentScript:null;const E=m(e=>e&&typeof e=="object"&&"default"in e?e.default:e,"_interopDefaultCompat"),ve=E(yt),Te=E(jt),Bt=E(wt),Wt=E(kt),Je=E(xt),Ut=E(St),G=E(Nt),I=E(Dt),zt=E(_t),Vt=E(Ct),Ht=E(It),Le=E(Mt),be=E(Lt);var Gt=Object.defineProperty,Xt=m((e,t)=>Gt(e,"name",{value:t,configurable:!0}),"a$e");const re=Xt((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var Kt=Object.defineProperty,Yt=m((e,t)=>Kt(e,"name",{value:t,configurable:!0}),"a$d");const T=Yt(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var Qt=Object.defineProperty,Zt=m((e,t)=>Qt(e,"name",{value:t,configurable:!0}),"a$c");const qe=Zt((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var eo=Object.defineProperty,Be=m((e,t)=>eo(e,"name",{value:t,configurable:!0}),"s$g");const to=Be((e,t,o)=>{const n=o??new Map;return(...s)=>{const r=t?typeof t=="function"?t(...s):t:JSON.stringify({args:s}),i=n.get(r);if(i!==void 0)return i;const l=e(...s);return n.set(r,l),l}},"memoize"),oo=Be(e=>{const t=new Map;return o=>to(e,o,t)},"memoizeByKey");var no=Object.defineProperty,q=m((e,t)=>no(e,"name",{value:t,configurable:!0}),"r$b");const ro=q(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;G(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 D.extractAssignedNames(t.id))yield o;break}}},"exportName"),so=q(function*(e){if(e.declaration)for(const t of ro(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"),io=q(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),ao=q(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),lo=q(function*(e,t){G(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*io(n);break}case"ExportDefaultDeclaration":{yield*ao();break}case"ExportNamedDeclaration":{yield*so(n);break}}},"parseExports");var co=Object.defineProperty,B=m((e,t)=>co(e,"name",{value:t,configurable:!0}),"n$b");const We=B(async function(e,t,o){const n=await e.resolve(t,o.id);if(G(n,`Rollup can't resolve ${t} from ${o.id}`),n.external)return null;const s=await e.load(n);return G(s,`Rollup doesn't have a module for id ${n.id}`),s},"getImportedModule"),po=B(async function*(e,t,o){const n=await We(e,t.source,o);n&&(yield*ce(e,n))},"gatherBarrelReExports"),uo=B(async function*(e,t,o){const n=await We(e,t.source,o);if(!n)return;const s=new Map(t.bindings.map(r=>[r.importedName,r]));for await(const r of ce(e,n)){const i=s.get(r.exportedName);i&&(yield{...r,exportedName:i.exportedName})}},"gatherNamedReExports"),mo=B(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),ce=B(async function*(e,t){for(const o of lo(e,t))o.from==="self"?yield*mo(t,o):o.type==="barrel"?yield*po(e,o,t):yield*uo(e,o,t)},"gatherExports");var fo=Object.defineProperty,go=m((e,t)=>fo(e,"name",{value:t,configurable:!0}),"r$a");const ho=go(()=>({moduleParsed:{async handler(e){if(e.isEntry)for await(const t of ce(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 yo=Object.defineProperty,$e=m((e,t)=>yo(e,"name",{value:t,configurable:!0}),"u$b");const Ue=$e(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk:$e(async(n,s,r)=>{if(s.type!=="chunk"||!s.isEntry)return null;if(r.format==="cjs"&&r.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(i===null||i.length<3)return null;const l=new I(n);l.replace("",""),l.replaceAll(/exports\.(.*) = (.*);/g,"module.module.exports.$1 = $2;"),e&&l.append(`
2
2
  module.module.exports = `+i[2]+";");let a=l.toString();return a=a.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+s.fileName+".",prefix:"plugin:cjs-interop"}),{code:a,map:l.generateMap({hires:!0})}}if(r.format==="es"&&/\.d\.(?:ts|cts)$/.test(s.fileName)){if(o!=="commonjs"&&s.fileName.endsWith(".d.mts"))return null;const i=[];let l;const a=/export\s\{\s(.*)\s\}/g;for(;(l=a.exec(n))!==null;)l.index===a.lastIndex&&a.lastIndex++,l.forEach(d=>{i.push(d)});if(i.length===0)return null;const c=i.at(-1).split(", ");let p="";for(const d of c)if(!d.includes("type")&&d.includes("as")){const[u,g]=d.split(" as ");g==="default"&&(p=u)}if(p!==""){const d=new I(n);return d.replace(new RegExp(`(,s)?${p} as default(,)?`),""),d.append(`
3
3
 
4
- export = `+p+";"),t.debug({message:"Applied CommonJS interop to entry chunk "+s.fileName+".",prefix:"plugin:cjs-interop"}),{code:d.toString().replace(/export\s\{\s\s\};/,""),map:d.generateMap({hires:!0})}}}return null},"renderChunk")}),"cjsInteropPlugin");var bo=Object.defineProperty,$o=m((e,t)=>bo(e,"name",{value:t,configurable:!0}),"u$a");const jo=$o((e,t)=>{const o=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:s}=n;return Array.isArray(s)?s=s.map(r=>{if(typeof r=="string")return{src:r};if(typeof r=="object"&&"src"in r)return r}).filter(Boolean):typeof s=="string"&&(s=[{src:s}]),{async buildStart(){const r=await Promise.all(s.flatMap(i=>Array.isArray(i.src)?i.src.map(l=>({...i,src:l})):i).map(async i=>await Te.glob(A(i.src),{ignore:A(i.exclude).filter(Boolean)}).then(l=>({dest:i.dest??"",parent:zt(i.src),src:l}))));for(const i of r)for(const l of i.src){let a;o.has(l)?a=o.get(l):(a={copied:[],dest:[],timestamp:0},o.set(l,a));const c=n.flatten?f.normalize(i.dest):f.join(i.dest,f.relative(i.parent,f.dirname(l)));a.dest.includes(c)||a.dest.push(c),this.addWatchFile(l)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([i,l])=>{let a;try{const c=await ae.stat(i);if(!c.isFile())return;const p=c.mtime.getTime();p>l.timestamp&&(l.timestamp=p,l.copied=[]),a=await $.readFile(i,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const c of l.dest){if(n.copyOnce&&l.copied.includes(c))continue;const p=f.basename(i),d=f.join(c,p);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:d,source:a,type:"asset"}),t.debug({message:`copied ${i} → ${d}`,prefix:"plugin:copy"}),l.copied.push(c)}catch(u){t.error({context:[u],message:`error copying file ${i} → ${d}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var wo=Object.defineProperty,Y=m((e,t)=>wo(e,"name",{value:t,configurable:!0}),"t$6");const ko=/\Wrequire(?:\.resolve)?\(/,xo=Y((e,t)=>{if(ie.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,s=!1;if(e.includes("__filename")&&(o=!0),e.includes("__dirname")&&(n=!0),ko.test(e)&&(s=!0),!o&&!n&&!s)return null;const r=H.findStaticImports(e).pop(),i=r?r.end:0,l=new I(e);return l.appendRight(i,t(o,n,s)),{code:l.toString(),map:l.generateMap()}},"CJSToESM"),Eo=Y((e,t,o)=>{let n="";return(e||t)&&(n+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
4
+ export = `+p+";"),t.debug({message:"Applied CommonJS interop to entry chunk "+s.fileName+".",prefix:"plugin:cjs-interop"}),{code:d.toString().replace(/export\s\{\s\s\};/,""),map:d.generateMap({hires:!0})}}}return null},"renderChunk")}),"cjsInteropPlugin");var vo=Object.defineProperty,bo=m((e,t)=>vo(e,"name",{value:t,configurable:!0}),"u$a");const $o=bo((e,t)=>{const o=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:s}=n;return Array.isArray(s)?s=s.map(r=>{if(typeof r=="string")return{src:r};if(typeof r=="object"&&"src"in r)return r}).filter(Boolean):typeof s=="string"&&(s=[{src:s}]),{async buildStart(){const r=await Promise.all(s.flatMap(i=>Array.isArray(i.src)?i.src.map(l=>({...i,src:l})):i).map(async i=>await Me.glob(T(i.src),{ignore:T(i.exclude).filter(Boolean)}).then(l=>({dest:i.dest??"",parent:zt(i.src),src:l}))));for(const i of r)for(const l of i.src){let a;o.has(l)?a=o.get(l):(a={copied:[],dest:[],timestamp:0},o.set(l,a));const c=n.flatten?f.normalize(i.dest):f.join(i.dest,f.relative(i.parent,f.dirname(l)));a.dest.includes(c)||a.dest.push(c),this.addWatchFile(l)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([i,l])=>{let a;try{const c=await ae.stat(i);if(!c.isFile())return;const p=c.mtime.getTime();p>l.timestamp&&(l.timestamp=p,l.copied=[]),a=await $.readFile(i,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const c of l.dest){if(n.copyOnce&&l.copied.includes(c))continue;const p=f.basename(i),d=f.join(c,p);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:d,source:a,type:"asset"}),t.debug({message:`copied ${i} → ${d}`,prefix:"plugin:copy"}),l.copied.push(c)}catch(u){t.error({context:[u],message:`error copying file ${i} → ${d}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var jo=Object.defineProperty,Y=m((e,t)=>jo(e,"name",{value:t,configurable:!0}),"t$6");const wo=/\Wrequire(?:\.resolve)?\(/,ko=Y((e,t)=>{if(ie.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,s=!1;if(e.includes("__filename")&&(o=!0),e.includes("__dirname")&&(n=!0),wo.test(e)&&(s=!0),!o&&!n&&!s)return null;const r=H.findStaticImports(e).pop(),i=r?r.end:0,l=new I(e);return l.appendRight(i,t(o,n,s)),{code:l.toString(),map:l.generateMap()}},"CJSToESM"),xo=Y((e,t,o)=>{let n="";return(e||t)&&(n+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
5
5
  `),t&&(n+=`import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
6
6
  `),o&&(n+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
7
7
  `),(e||t)&&(n+=`const __filename = __cjs_url__.fileURLToPath(import.meta.url);
8
8
  `),t&&(n+=`const __dirname = __cjs_path__.dirname(__filename);
9
9
  `),o&&(n+=`const require = __cjs_mod__.createRequire(import.meta.url);
10
- `),n},"generateCJSShim"),So=Y((e,t,o)=>{let n="";return o&&(n+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
10
+ `),n},"generateCJSShim"),Eo=Y((e,t,o)=>{let n="";return o&&(n+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
11
11
  `),e&&(n+=`const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
12
12
  `),t&&(n+=`const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
13
13
  `),o&&(n+=`const require = __cjs_mod__.createRequire(import.meta.url);
14
- `),n},"generateCJSShimNode20_11"),Oo=Y((e,t)=>{const o=D.createFilter(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(n,s,r){if(r.format==="es"&&o(s.fileName)){let i=Eo;if(e.engines?.node){const l=Me.minVersion(e.engines.node);l&&l.major>=20&&l.minor>=11&&(i=So)}return xo(n,i)}return null}}},"esmShimCjsSyntaxPlugin");var No=Object.defineProperty,Do=m((e,t)=>No(e,"name",{value:t,configurable:!0}),"n$9");const _o=Do(()=>({name:"packem:cjs",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 Po=Object.defineProperty,Co=m((e,t)=>Po(e,"name",{value:t,configurable:!0}),"s$e");const Io=Co((...e)=>{if(e.length===0)return"";if(e.length===1)return f.dirname(e[0]);e=e.map(s=>f.toNamespacedPath(s));const[t,...o]=e;let n=t.split("/");for(const s of o){const r=s.split("/",n.length);let i=0;for(const l of r)if(l===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 Ro=Object.defineProperty,ee=m((e,t)=>Ro(e,"name",{value:t,configurable:!0}),"m$5");const Fo=ee((e,t,o,n={})=>{const s=D.createFilter(n.include,n.exclude),r={},i=ee((c,p)=>{r[c.replace(/\..?[jt]s$/,"")]=p},"addOutput");async function l(c,p){if(!s(p))return;const{errors:d,sourceText:u}=await e(p,c);if(d.length>0){if(n.ignoreErrors){this.warn(d[0]);return}return this.error(d[0])}i(p,u);let g;try{const h=await Ct.parseAsync(c,{sourceFilename:p});g=JSON.parse(h.program)}catch{return}const y=g.body.filter(h=>h.type!=="ImportDeclaration"?!1:h.importKind==="type"?!0:(h.specifiers||[]).every(w=>w.type==="ImportSpecifier"&&w.importKind==="type"));for await(const h of y){const w=await this.resolve(h.source.value,p);if(!w)return;const j=w.id;if(s(j)&&!r[j.replace(k.ENDING_RE,"")])try{const b=await $.readFile(j);await l.call(this,b,j)}catch{}}}m(l,"g"),ee(l,"transform");const a=o==="module"?"es":"cjs";return{name:"packem:isolated-declarations",renderStart(c,{input:p}){const d=Io(...Array.isArray(p)?p:Object.values(p));typeof c.entryFileNames=="function"&&(c.entryFileNames=c.entryFileNames({name:c.name}));const u=c.entryFileNames.replace(/\.(.)?[jt]s$/,(g,y)=>`.d.${y||""}ts`);for(const[g,y]of Object.entries(r)){(t===!0||t==="compatible")&&c.format===a&&this.emitFile({fileName:u.replace("[name]",f.relative(d,g)).replace(a==="cjs"?".cts":".mts",".ts"),source:y,type:"asset"});const h=y.includes("from '")?"'":'"';this.emitFile({fileName:u.replace("[name]",f.relative(d,g)),source:y.replaceAll(/from\s+['"]([^'"]+)['"]/g,(w,j)=>`from ${h}${j.replace(k.ENDING_RE,"")}${c.format==="cjs"?".cts":".mts"}${h}`),type:"asset"})}},transform:l}},"isolatedDeclarationsPlugin");var Mo=Object.defineProperty,To=m((e,t)=>Mo(e,"name",{value:t,configurable:!0}),"n$8");const je="export default ",ze=To(e=>{const t=Ht(e);return{...t,name:"packem:json",transform(o,n){const s=t.transform?.call(this,o,n);return s&&typeof s!="string"&&"code"in s&&s.code?.startsWith(je)&&(s.code=s.code.replace(je,"module.exports = ")),s}}},"JSONPlugin");class Ao{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,s){t&&o&&(n!=null?t[o][n]=s:t[o]=s)}remove(t,o,n){t&&o&&(n!=null?t[o].splice(n,1):delete t[o])}}class Jo extends Ao{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,s){if(t){if(this.enter){const i=this.should_skip,l=this.should_remove,a=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,n,s),this.replacement&&(t=this.replacement,this.replace(o,n,s,t)),this.should_remove&&this.remove(o,n,s);const c=this.should_skip,p=this.should_remove;if(this.should_skip=i,this.should_remove=l,this.replacement=a,c)return t;if(p)return null}let r;for(r in t){const i=t[r];if(i&&typeof i=="object")if(Array.isArray(i)){const l=i;for(let a=0;a<l.length;a+=1){const c=l[a];we(c)&&(this.visit(c,t,r,a)||a--)}}else we(i)&&this.visit(i,t,r,null)}if(this.leave){const i=this.replacement,l=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,n,s),this.replacement&&(t=this.replacement,this.replace(o,n,s,t)),this.should_remove&&this.remove(o,n,s);const a=this.should_remove;if(this.replacement=i,this.should_remove=l,a)return null}}return t}}function we(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(we,"isNode");function He(e,{enter:t,leave:o}){return new Jo(t,o).visit(e,null)}m(He,"walk");var Lo=Object.defineProperty,qo=m((e,t)=>Lo(e,"name",{value:t,configurable:!0}),"u$9");const Bo=qo(({attributes:e,logger:t})=>{const o=D.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,s){if(!o(s))return null;let r=null;try{r=this.parse(n,{allowReturnOutsideFunction:!0})}catch(a){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${s}" and remove the jsx attribute.`}),t.warn(a),null}let i=!1;const l=new I(n);return He(r,{enter(a){if(a.type==="CallExpression"&&a.callee.type==="Identifier"&&a.callee.name==="jsx"){const c=a.arguments.filter(p=>p.type==="ObjectExpression"&&Array.isArray(p.properties));for(const p of c)for(const d of p.properties)d.type==="Property"&&d.key.type==="Literal"&&d.value.type==="Literal"&&e.includes(d.key.value)&&(l.overwrite(d.start-2,d.end,""),i=!0)}}}),i?{code:l.toString(),map:l.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Wo=Object.defineProperty,pe=m((e,t)=>Wo(e,"name",{value:t,configurable:!0}),"g$3");const Uo=pe(e=>{const t=[],o=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):o.push(n)}),[...o.sort(),...t.sort()]},"sortLicenses"),Vo=pe((e,t,o)=>{const n=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(n.test(e))return e.replace(n,`$1
14
+ `),n},"generateCJSShimNode20_11"),So=Y((e,t)=>{const o=D.createFilter(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(n,s,r){if(r.format==="es"&&o(s.fileName)){let i=xo;if(e.engines?.node){const l=Fe.minVersion(e.engines.node);l&&l.major>=20&&l.minor>=11&&(i=Eo)}return ko(n,i)}return null}}},"esmShimCjsSyntaxPlugin");var Oo=Object.defineProperty,No=m((e,t)=>Oo(e,"name",{value:t,configurable:!0}),"n$9");const Do=No(()=>({name:"packem:cjs",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 _o=Object.defineProperty,Po=m((e,t)=>_o(e,"name",{value:t,configurable:!0}),"s$e");const Co=Po((...e)=>{if(e.length===0)return"";if(e.length===1)return f.dirname(e[0]);e=e.map(s=>f.toNamespacedPath(s));const[t,...o]=e;let n=t.split("/");for(const s of o){const r=s.split("/",n.length);let i=0;for(const l of r)if(l===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 Io=Object.defineProperty,ee=m((e,t)=>Io(e,"name",{value:t,configurable:!0}),"m$5");const Ro=ee((e,t,o,n={})=>{const s=D.createFilter(n.include,n.exclude),r={},i=ee((c,p)=>{r[c.replace(/\..?[jt]s$/,"")]=p},"addOutput");async function l(c,p){if(!s(p))return;const{errors:d,sourceText:u}=await e(p,c);if(d.length>0){if(n.ignoreErrors){this.warn(d[0]);return}return this.error(d[0])}i(p,u);let g;try{const h=await Pt.parseAsync(c,{sourceFilename:p});g=JSON.parse(h.program)}catch{return}const y=g.body.filter(h=>h.type!=="ImportDeclaration"?!1:h.importKind==="type"?!0:(h.specifiers||[]).every(w=>w.type==="ImportSpecifier"&&w.importKind==="type"));for await(const h of y){const w=await this.resolve(h.source.value,p);if(!w)return;const j=w.id;if(s(j)&&!r[j.replace(k.ENDING_RE,"")])try{const b=await $.readFile(j);await l.call(this,b,j)}catch{}}}m(l,"g"),ee(l,"transform");const a=o==="module"?"es":"cjs";return{name:"packem:isolated-declarations",renderStart(c,{input:p}){const d=Co(...Array.isArray(p)?p:Object.values(p));typeof c.entryFileNames=="function"&&(c.entryFileNames=c.entryFileNames({name:c.name}));const u=c.entryFileNames.replace(/\.(.)?[jt]s$/,(g,y)=>`.d.${y||""}ts`);for(const[g,y]of Object.entries(r)){(t===!0||t==="compatible")&&c.format===a&&this.emitFile({fileName:u.replace("[name]",f.relative(d,g)).replace(a==="cjs"?".cts":".mts",".ts"),source:y,type:"asset"});const h=y.includes("from '")?"'":'"';this.emitFile({fileName:u.replace("[name]",f.relative(d,g)),source:y.replaceAll(/from\s+['"]([^'"]+)['"]/g,(w,j)=>`from ${h}${j.replace(k.ENDING_RE,"")}${c.format==="cjs"?".cts":".mts"}${h}`),type:"asset"})}},transform:l}},"isolatedDeclarationsPlugin");var Fo=Object.defineProperty,Mo=m((e,t)=>Fo(e,"name",{value:t,configurable:!0}),"n$8");const je="export default ",ze=Mo(e=>{const t=Vt(e);return{...t,name:"packem:json",transform(o,n){const s=t.transform?.call(this,o,n);return s&&typeof s!="string"&&"code"in s&&s.code?.startsWith(je)&&(s.code=s.code.replace(je,"module.exports = ")),s}}},"JSONPlugin");class Ao{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,s){t&&o&&(n!=null?t[o][n]=s:t[o]=s)}remove(t,o,n){t&&o&&(n!=null?t[o].splice(n,1):delete t[o])}}class To extends Ao{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,s){if(t){if(this.enter){const i=this.should_skip,l=this.should_remove,a=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,n,s),this.replacement&&(t=this.replacement,this.replace(o,n,s,t)),this.should_remove&&this.remove(o,n,s);const c=this.should_skip,p=this.should_remove;if(this.should_skip=i,this.should_remove=l,this.replacement=a,c)return t;if(p)return null}let r;for(r in t){const i=t[r];if(i&&typeof i=="object")if(Array.isArray(i)){const l=i;for(let a=0;a<l.length;a+=1){const c=l[a];we(c)&&(this.visit(c,t,r,a)||a--)}}else we(i)&&this.visit(i,t,r,null)}if(this.leave){const i=this.replacement,l=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,n,s),this.replacement&&(t=this.replacement,this.replace(o,n,s,t)),this.should_remove&&this.remove(o,n,s);const a=this.should_remove;if(this.replacement=i,this.should_remove=l,a)return null}}return t}}function we(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(we,"isNode");function Ve(e,{enter:t,leave:o}){return new To(t,o).visit(e,null)}m(Ve,"walk");var Jo=Object.defineProperty,Lo=m((e,t)=>Jo(e,"name",{value:t,configurable:!0}),"u$9");const qo=Lo(({attributes:e,logger:t})=>{const o=D.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,s){if(!o(s))return null;let r=null;try{r=this.parse(n,{allowReturnOutsideFunction:!0})}catch(a){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${s}" and remove the jsx attribute.`}),t.warn(a),null}let i=!1;const l=new I(n);return Ve(r,{enter(a){if(a.type==="CallExpression"&&a.callee.type==="Identifier"&&a.callee.name==="jsx"){const c=a.arguments.filter(p=>p.type==="ObjectExpression"&&Array.isArray(p.properties));for(const p of c)for(const d of p.properties)d.type==="Property"&&d.key.type==="Literal"&&d.value.type==="Literal"&&e.includes(d.key.value)&&(l.overwrite(d.start-2,d.end,""),i=!0)}}}),i?{code:l.toString(),map:l.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Bo=Object.defineProperty,pe=m((e,t)=>Bo(e,"name",{value:t,configurable:!0}),"g$3");const Wo=pe(e=>{const t=[],o=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):o.push(n)}),[...o.sort(),...t.sort()]},"sortLicenses"),Uo=pe((e,t,o)=>{const n=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(n.test(e))return e.replace(n,`$1
15
15
  ${o}
16
- $2`)},"replaceContentWithin"),Ge=pe(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:n,marker:s,mode:r,packageName:i})=>Gt({thirdParty(l){const a=new Set,c=l.sort(({name:d},{name:u})=>(d||0)>(u||0)?1:(u||0)>(d||0)?-1:0).map(({author:d,contributors:u,license:g,licenseText:y,maintainers:h,name:w,repository:j})=>{let b="## "+w+`
16
+ $2`)},"replaceContentWithin"),He=pe(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:n,marker:s,mode:r,packageName:i})=>Ht({thirdParty(l){const a=new Set,c=l.sort(({name:d},{name:u})=>(d||0)>(u||0)?1:(u||0)>(d||0)?-1:0).map(({author:d,contributors:u,license:g,licenseText:y,maintainers:h,name:w,repository:j})=>{let b="## "+w+`
17
17
  `;g&&(b+=`License: ${g}
18
18
  `);const S=new Set;for(const N of[d,...h,...u]){const M=typeof N=="string"?N:N?.name;M&&S.add(M)}return S.size>0&&(b+=`By: ${[...S].join(", ")}
19
19
  `),j&&(b+=`Repository: ${typeof j=="string"?j:j.url}
@@ -25,24 +25,24 @@ $2`)},"replaceContentWithin"),Ge=pe(({dtsMarker:e,licenseFilePath:t,licenseTempl
25
25
  `),g&&a.add(g),b}).join(`
26
26
  ---------------------------------------
27
27
 
28
- `);if(c===""){n.info({message:"No dependencies license information found.",prefix:"plugin:license:"+r});return}const p=o(Uo(a),c,i);try{const d=$.readFileSync(t),u=Vo(d,s,p);if(!u){n.error({message:`Could not find the license marker: <!-- ${s} --> in ${t}`,prefix:"plugin:license:"+r});return}d!==u&&($.writeFileSync(t,u),n.info({message:`${t} updated.`,prefix:"plugin:license:"+r}))}catch(d){n.error(d)}}}),"license");var zo=Object.defineProperty,Ho=m((e,t)=>zo(e,"name",{value:t,configurable:!0}),"i$a");const Go=Ho(e=>({async buildEnd(){const t=[];for(const n of this.getModuleIds()){const s=this.getModuleInfo(n);if(s!=null&&!s.isExternal)for(const r of s.importedIds)t.push({source:n,target:r})}if(Array.isArray(t)&&t.length===0)return;const o=f.resolve(e.rootDir,e.outDir,"graph.json");$.writeJsonSync(o,t)},name:"packem:metafile"}),"metafilePlugin");var Xo=Object.defineProperty,Xe=m((e,t)=>Xo(e,"name",{value:t,configurable:!0}),"n$7");let ke=!1;const Ko=Xe(e=>{e.logger.info(`Compatibility mode enabled. This will generate a typesVersions field ${e.options.writeTypesVersionsToPackageJson?"and write it to package.json":" and display it in the console"}.`);const t=[];for(const o of e.buildEntries.filter(n=>!n.chunk))o.type==="entry"&&o.path.endsWith(".cjs")&&t.push("./"+f.join(e.options.outDir,o.path.replace(/\.cjs$/,".d.ts")));if(e.options.writeTypesVersionsToPackageJson){const o=f.join(e.options.rootDir,"package.json"),n=$.readJsonSync(o);$.writeJsonSync(o,{...n,typesVersions:{...n.typesVersions,"*":{"*":t.sort()}}},{detectIndent:!0})}else e.logger.info(`Please add the following field into your package.json to enable node 10 compatibility:
28
+ `);if(c===""){n.info({message:"No dependencies license information found.",prefix:"plugin:license:"+r});return}const p=o(Wo(a),c,i);try{const d=$.readFileSync(t),u=Uo(d,s,p);if(!u){n.error({message:`Could not find the license marker: <!-- ${s} --> in ${t}`,prefix:"plugin:license:"+r});return}d!==u&&($.writeFileSync(t,u),n.info({message:`${t} updated.`,prefix:"plugin:license:"+r}))}catch(d){n.error(d)}}}),"license");var zo=Object.defineProperty,Vo=m((e,t)=>zo(e,"name",{value:t,configurable:!0}),"i$a");const Ho=Vo(e=>({async buildEnd(){const t=[];for(const n of this.getModuleIds()){const s=this.getModuleInfo(n);if(s!=null&&!s.isExternal)for(const r of s.importedIds)t.push({source:n,target:r})}if(Array.isArray(t)&&t.length===0)return;const o=f.resolve(e.rootDir,e.outDir,"graph.json");$.writeJsonSync(o,t)},name:"packem:metafile"}),"metafilePlugin");var Go=Object.defineProperty,Ge=m((e,t)=>Go(e,"name",{value:t,configurable:!0}),"n$7");const Xo=Ge(e=>{e.logger.info({message:"Declaration compatibility mode is enabled.",prefix:"dts"});const t=[];for(const o of e.buildEntries.filter(n=>!n.chunk))o.type==="entry"&&o.path.endsWith(".cjs")&&t.push("./"+f.join(e.options.outDir,o.path.replace(/\.cjs$/,".d.ts")));if(e.options.writeTypesVersionsToPackageJson&&t.length>0){const o=f.join(e.options.rootDir,"package.json"),n=$.readJsonSync(o);$.writeJsonSync(o,{...n,typesVersions:{...n.typesVersions,"*":{"*":t.sort()}}},{detectIndent:!0})}else t.length>0&&e.logger.info(`Please add the following field into your package.json to enable node 10 compatibility:
29
29
 
30
- ${JSON.stringify({typesVersions:{"*":{"*":t.sort()}}},null,4)}`)},"generateNode10Compatibility"),Yo=Xe(e=>({name:"packem:node10-compatibility",writeBundle(){ke||e.options.declaration!=="compatible"||(Ko(e),ke=!0)}}),"node10Compatibility");var Qo=Object.defineProperty,Zo=m((e,t)=>Qo(e,"name",{value:t,configurable:!0}),"r$7");const R=Zo(e=>{const t=Ft.createHash("md5");return t.update(e),t.digest("hex")},"getHash");var en=Object.defineProperty,Ke=m((e,t)=>en(e,"name",{value:t,configurable:!0}),"d$7");const T=Ke(e=>e.handler||e,"getHandler"),O=Ke((e,t,o="")=>({...e,async buildEnd(n){e.buildEnd&&await T(e.buildEnd).call(this,n)},async buildStart(n){e.buildStart&&await T(e.buildStart).call(this,n)},async load(n){if(!e.load)return null;const s=f.join(o,e.name),r=f.join("load",R(n));if(t.has(r,s))return await t.get(r,s);const i=await T(e.load).call(this,n);return t.set(r,i,s),i},name:`cached(${e.name})`,async resolveId(n,s,r){if(!e.resolveId)return null;const i=f.join(o,e.name),l=f.join("resolveId",R(n),s?R(s):"",R(JSON.stringify(r)));if(t.has(l,i))return await t.get(l,i);const a=await T(e.resolveId).call(this,n,s,r);return t.set(l,a,i),a},async transform(n,s){if(!e.transform)return null;const r=f.join(o,e.name),i=f.join("transform",R(s),R(n));if(t.has(i,r))return await t.get(i,r);const l=await T(e.transform).call(this,n,s);return t.set(i,l,r),l}}),"cachingPlugin");var tn=Object.defineProperty,on=m((e,t)=>tn(e,"name",{value:t,configurable:!0}),"n$6");const nn=on(()=>({name:"prependDirective",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 rn=Object.defineProperty,sn=m((e,t)=>rn(e,"name",{value:t,configurable:!0}),"c$a");const an=sn(({directiveRegex:e,exclude:t=[],include:o=[],logger:n})=>{const s={},r={},i=D.createFilter(o,t);return{name:"packem:preserve-directives",onLog(l,a){return a.code==="MODULE_LEVEL_DIRECTIVE"&&l==="warn"?!1:null},renderChunk:{handler(l,a,{sourcemap:c}){const p=a.moduleIds.map(g=>s[g]?s[g]:null).reduce((g,y)=>(y&&y.forEach(h=>{g.add(h)}),g),new Set),d=new I(l);p.size>0&&(n.debug({message:`directives for chunk "${a.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),d.prepend(`${[...p].map(g=>`'${g}';`).join(`
30
+ ${JSON.stringify({typesVersions:{"*":{"*":t.sort()}}},null,4)}`)},"generateNode10Compatibility"),Ko=Ge(e=>({name:"packem:node10-compatibility",writeBundle(){e.options.declaration==="compatible"&&Xo(e)}}),"node10Compatibility");var Yo=Object.defineProperty,Qo=m((e,t)=>Yo(e,"name",{value:t,configurable:!0}),"r$7");const R=Qo(e=>{const t=Rt.createHash("md5");return t.update(e),t.digest("hex")},"getHash");var Zo=Object.defineProperty,Xe=m((e,t)=>Zo(e,"name",{value:t,configurable:!0}),"d$7");const A=Xe(e=>e.handler||e,"getHandler"),O=Xe((e,t,o="")=>({...e,async buildEnd(n){e.buildEnd&&await A(e.buildEnd).call(this,n)},async buildStart(n){e.buildStart&&await A(e.buildStart).call(this,n)},async load(n){if(!e.load)return null;const s=f.join(o,e.name),r=f.join("load",R(n));if(t.has(r,s))return await t.get(r,s);const i=await A(e.load).call(this,n);return t.set(r,i,s),i},name:`cached(${e.name})`,async resolveId(n,s,r){if(!e.resolveId)return null;const i=f.join(o,e.name),l=f.join("resolveId",R(n),s?R(s):"",R(JSON.stringify(r)));if(t.has(l,i))return await t.get(l,i);const a=await A(e.resolveId).call(this,n,s,r);return t.set(l,a,i),a},async transform(n,s){if(!e.transform)return null;const r=f.join(o,e.name),i=f.join("transform",R(s),R(n));if(t.has(i,r))return await t.get(i,r);const l=await A(e.transform).call(this,n,s);return t.set(i,l,r),l}}),"cachingPlugin");var en=Object.defineProperty,tn=m((e,t)=>en(e,"name",{value:t,configurable:!0}),"n$6");const on=tn(()=>({name:"prependDirective",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 nn=Object.defineProperty,rn=m((e,t)=>nn(e,"name",{value:t,configurable:!0}),"c$a");const sn=rn(({directiveRegex:e,exclude:t=[],include:o=[],logger:n})=>{const s={},r={},i=D.createFilter(o,t);return{name:"packem:preserve-directives",onLog(l,a){return a.code==="MODULE_LEVEL_DIRECTIVE"&&l==="warn"?!1:null},renderChunk:{handler(l,a,{sourcemap:c}){const p=a.moduleIds.map(g=>s[g]?s[g]:null).reduce((g,y)=>(y&&y.forEach(h=>{g.add(h)}),g),new Set),d=new I(l);p.size>0&&(n.debug({message:`directives for chunk "${a.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),d.prepend(`${[...p].map(g=>`'${g}';`).join(`
32
32
  `)}
33
33
  `));let u=null;return a.facadeModuleId&&typeof r[a.facadeModuleId]=="string"&&(u=r[a.facadeModuleId]),u&&(n.debug({message:`shebang for chunk "${a.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),d.prepend(`${u}
34
- `)),p.size===0&&u===null?null:{code:d.toString(),map:c?d.generateMap({hires:!0}):null}},order:"post"},transform(l,a){if(!i(a))return null;let c=!1;const p=new I(l);if(l.startsWith("#")&&l[1]==="!"){let u=0;for(let g=2,y=l.length;g<y;g++){const h=l.codePointAt(g);if(h===10||h===13||h===8232||h===8233){u=g;break}}u&&(r[a]=l.slice(0,u),p.remove(0,u+1),c=!0,n.debug({message:`shebang for module "${a}" is preserved.`,prefix:"plugin:preserve-directives"}))}let d=null;try{d=this.parse(p.toString(),{allowReturnOutsideFunction:!0})}catch(u){return this.warn({code:"PARSE_ERROR",message:`failed to parse "${a}" and extract the directives.`}),n.warn(u),null}if(d.type!=="Program")return null;for(const u of d.body.filter(Boolean)){if(u.type!=="ExpressionStatement")break;let g=null;"directive"in u?g=u.directive:u.expression.type==="Literal"&&typeof u.expression.value=="string"&&e.test(u.expression.value)&&(g=u.expression.value),g!=="use strict"&&g&&(s[a]||=new Set,s[a].add(g),"start"in u&&typeof u.start=="number"&&"end"in u&&typeof u.end=="number"&&(p.remove(u.start,u.end),c=!0),n.debug({message:`directive "${g}" for module "${a}" is preserved.`,prefix:"plugin:preserve-directives"}))}return c?{code:p.toString(),map:p.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...s[a]??[]],shebang:r[a]??null}}}:null}}},"preserveDirectives");var ln=Object.defineProperty,cn=m((e,t)=>ln(e,"name",{value:t,configurable:!0}),"t$4");const pn=cn(e=>{const t=D.createFilter(e.include,e.exclude);return{name:"packem:raw",transform(o,n){return t(n)?{code:`export default ${JSON.stringify(o)}`,map:null}:null}}},"rawPlugin");var un=Object.defineProperty,dn=m((e,t)=>un(e,"name",{value:t,configurable:!0}),"l$8");const te="\0__file_url__",Ye=dn(()=>({async load(e){if(e.startsWith(te)){const t=Ae.fileURLToPath(e.slice(te.length));return await $.readFile(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${te}${e}`}}),"resolveFileUrl");var mn=Object.defineProperty,Q=m((e,t)=>mn(e,"name",{value:t,configurable:!0}),"i$7");const ue=/^#![^\n]*/,se=Q(async e=>{await ae.chmod(e,493).catch(()=>{})},"makeExecutable"),fn=Q((e,t=`#!/usr/bin/env node
35
- `)=>({name:"packem:shebang",renderChunk:{handler(o,n,s){if(!n.isEntry||!n.facadeModuleId||o.startsWith("#")&&o[1]==="!")return null;if(e.includes(n.name)){const r=new I(o);return r.prepend(t),{code:r.toString(),map:s.sourcemap?r.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,n){for(const[s,r]of Object.entries(n))if(r.type==="chunk"&&ue.test(r.code)&&o.dir){const i=f.resolve(o.dir,s);await se(i)}}}),"shebangPlugin"),gn=Q(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ue,"")}}),"removeShebangPlugin"),hn=Q((e,t=`
36
- `)=>{const o=ue.exec(e);return o?o+t:""},"getShebang");var yn=Object.defineProperty,F=m((e,t)=>yn(e,"name",{value:t,configurable:!0}),"r$6");const vn=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,bn=/MIT License|MIT license|BSD license/,$n=/\n{2,}/g,jn=/\b(\w+)\$\d+\b/g,wn=/[-/\\^$*+?.()|[\]{}]/g,kn=F(e=>e.replaceAll(wn,"\\$&"),"escapeRegex"),xn=F(e=>[...new Set(e)],"unique"),En=F(e=>e.replaceAll(vn,t=>bn.test(t)?"":t).replaceAll($n,`
34
+ `)),p.size===0&&u===null?null:{code:d.toString(),map:c?d.generateMap({hires:!0}):null}},order:"post"},transform(l,a){if(!i(a))return null;let c=!1;const p=new I(l);if(l.startsWith("#")&&l[1]==="!"){let u=0;for(let g=2,y=l.length;g<y;g++){const h=l.codePointAt(g);if(h===10||h===13||h===8232||h===8233){u=g;break}}u&&(r[a]=l.slice(0,u),p.remove(0,u+1),c=!0,n.debug({message:`shebang for module "${a}" is preserved.`,prefix:"plugin:preserve-directives"}))}let d=null;try{d=this.parse(p.toString(),{allowReturnOutsideFunction:!0})}catch(u){return this.warn({code:"PARSE_ERROR",message:`failed to parse "${a}" and extract the directives.`}),n.warn(u),null}if(d.type!=="Program")return null;for(const u of d.body.filter(Boolean)){if(u.type!=="ExpressionStatement")break;let g=null;"directive"in u?g=u.directive:u.expression.type==="Literal"&&typeof u.expression.value=="string"&&e.test(u.expression.value)&&(g=u.expression.value),g!=="use strict"&&g&&(s[a]||=new Set,s[a].add(g),"start"in u&&typeof u.start=="number"&&"end"in u&&typeof u.end=="number"&&(p.remove(u.start,u.end),c=!0),n.debug({message:`directive "${g}" for module "${a}" is preserved.`,prefix:"plugin:preserve-directives"}))}return c?{code:p.toString(),map:p.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...s[a]??[]],shebang:r[a]??null}}}:null}}},"preserveDirectives");var an=Object.defineProperty,ln=m((e,t)=>an(e,"name",{value:t,configurable:!0}),"t$4");const cn=ln(e=>{const t=D.createFilter(e.include,e.exclude);return{name:"packem:raw",transform(o,n){return t(n)?{code:`export default ${JSON.stringify(o)}`,map:null}:null}}},"rawPlugin");var pn=Object.defineProperty,un=m((e,t)=>pn(e,"name",{value:t,configurable:!0}),"l$8");const te="\0__file_url__",Ke=un(()=>({async load(e){if(e.startsWith(te)){const t=Ae.fileURLToPath(e.slice(te.length));return await $.readFile(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${te}${e}`}}),"resolveFileUrl");var dn=Object.defineProperty,Q=m((e,t)=>dn(e,"name",{value:t,configurable:!0}),"i$7");const ue=/^#![^\n]*/,se=Q(async e=>{await ae.chmod(e,493).catch(()=>{})},"makeExecutable"),mn=Q((e,t=`#!/usr/bin/env node
35
+ `)=>({name:"packem:shebang",renderChunk:{handler(o,n,s){if(!n.isEntry||!n.facadeModuleId||o.startsWith("#")&&o[1]==="!")return null;if(e.includes(n.name)){const r=new I(o);return r.prepend(t),{code:r.toString(),map:s.sourcemap?r.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,n){for(const[s,r]of Object.entries(n))if(r.type==="chunk"&&ue.test(r.code)&&o.dir){const i=f.resolve(o.dir,s);await se(i)}}}),"shebangPlugin"),fn=Q(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ue,"")}}),"removeShebangPlugin"),gn=Q((e,t=`
36
+ `)=>{const o=ue.exec(e);return o?o+t:""},"getShebang");var hn=Object.defineProperty,F=m((e,t)=>hn(e,"name",{value:t,configurable:!0}),"r$6");const yn=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,vn=/MIT License|MIT license|BSD license/,bn=/\n{2,}/g,$n=/\b(\w+)\$\d+\b/g,jn=/[-/\\^$*+?.()|[\]{}]/g,wn=F(e=>e.replaceAll(jn,"\\$&"),"escapeRegex"),kn=F(e=>[...new Set(e)],"unique"),xn=F(e=>e.replaceAll(yn,t=>vn.test(t)?"":t).replaceAll(bn,`
37
37
 
38
- `),"cleanUnnecessaryComments"),xe=new Map;function Qe(e,t,{identifierReplacements:o},n){const s=H.findStaticImports(e);for(const i in o){const l=s.find(c=>c.specifier===i&&c.imports.includes("{"));if(!l){this.warn(`${t.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const a=o[i];for(const c in a){if(!l.imports.includes(c))throw new Error(`${t.fileName} does not import "${c}" from "${i}" for replacement`);const p=a[c],d=kn(c);p.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${d},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${d}\\b`,"g"),p)}}const r=xn(Array.from(e.matchAll(jn),i=>i[0]));if(r.length>0){const i=r.map(a=>`
39
- - ${a}`).join(""),l=t.fileName.replace(/\.[^/.]+$/,"");xe.has(l)||n.warn({message:`${t.fileName} contains confusing identifier names${i}
38
+ `),"cleanUnnecessaryComments"),ke=new Map;function Ye(e,t,{identifierReplacements:o},n){const s=H.findStaticImports(e);for(const i in o){const l=s.find(c=>c.specifier===i&&c.imports.includes("{"));if(!l){this.warn(`${t.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const a=o[i];for(const c in a){if(!l.imports.includes(c))throw new Error(`${t.fileName} does not import "${c}" from "${i}" for replacement`);const p=a[c],d=wn(c);p.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${d},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${d}\\b`,"g"),p)}}const r=kn(Array.from(e.matchAll($n),i=>i[0]));if(r.length>0){const i=r.map(a=>`
39
+ - ${a}`).join(""),l=t.fileName.replace(/\.[^/.]+$/,"");ke.has(l)||n.warn({message:`${t.fileName} contains confusing identifier names${i}
40
40
 
41
- To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),xe.set(l,!0)}return e}m(Qe,"I$1");F(Qe,"replaceConfusingTypeNames");const Sn=F((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 Ze(e,t){if(e.includes("@internal")){const o=new I(e),n=Mt.parse(e,{plugins:["typescript"],sourceType:"module"});if(He(n,{enter(s){Sn(o,s)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}m(Ze,"S$1");F(Ze,"stripInternalTypes");const On=F((e,t)=>({name:"packem:patch-types",renderChunk(o,n){return o=Qe.call(this,o,n,e,t),o=Ze.call(this,o,n),o=En(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var Nn=Object.defineProperty,et=m((e,t)=>Nn(e,"name",{value:t,configurable:!0}),"m$4");const tt=et((e,t=!0)=>{if(!e)return null;const{config:o,path:n}=e;if(!o.compilerOptions)return null;const{baseUrl:s,paths:r}=o.compilerOptions;if(!s)return null;const i=f.resolve(f.dirname(n),s),l=[];if(r)for(const[a,c]of Object.entries(r)){let p;a==="@"||a==="~"||a==="#"?p=new RegExp(`^${a}/(.+)$`):p=new RegExp(`^${[...a].map(u=>u==="*"?"(.+)":u.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let d=0;for(const u of c){const g=[...D.normalizePath(f.resolve(i,u))].map(y=>y==="*"?"$"+(++d+""):y==="$"?"$$":y).join("");l.push({find:p,replacement:g})}}return t&&l.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...D.normalizePath(i)].map(a=>a==="$"?"$$":a).join("")}/$1`}),l},"getConfigAlias"),ot=et((e,t)=>{const o=tt(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,s,r){if(!o||n.includes("\0"))return null;for(const{find:i,replacement:l}of o)if(i.test(n)){const a=n.replace(i,l),c=await this.resolve(a,s,{skipSelf:!0,...r});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 Dn=Object.defineProperty,nt=m((e,t)=>Dn(e,"name",{value:t,configurable:!0}),"u$5");const _n=nt((e,t)=>{if(!t)return null;const{config:o,path:n}=t;if(!o.compilerOptions)return null;const{rootDirs:s}=o.compilerOptions;if(!s)return null;const r=[];for(const i of s){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${n}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${n}.`);r.push(f.resolve(e,i))}return r},"getRootDirectories"),rt=nt((e,t,o)=>{const n=_n(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(s,r,i){if(n===null||n.length===0)return null;if(s.startsWith("."))for(const l of n){const a=f.join(l,s),c=await this.resolve(a,r,{skipSelf:!0,...i});if(c)return t.debug({message:`Resolved ${s} to ${c.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),c.id}return null}}},"resolveTsconfigRootDirectories");var Pn=Object.defineProperty,Cn=m((e,t)=>Pn(e,"name",{value:t,configurable:!0}),"r$5");const st=Cn(()=>{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 In=Object.defineProperty,Rn=m((e,t)=>In(e,"name",{value:t,configurable:!0}),"s$a");const Fn=Rn(e=>{const t=f.basename(e).split(".");if(t.length>=2){const[o,n]=t.slice(-2),s=t[0],r=/^(\w+)-runtime$/.exec(o)?.[1];if(k.DEFAULT_EXTENSIONS.includes(n)&&r&&r.length>0)return s+"-"+r}},"getCustomModuleLayer");var Mn=Object.defineProperty,Tn=m((e,t)=>Mn(e,"name",{value:t,configurable:!0}),"i$6");const oe=Tn(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var An=Object.defineProperty,Ee=m((e,t)=>An(e,"name",{value:t,configurable:!0}),"c$7");const Jn=Ee((e,t)=>{const o=new Map;return Ee(function(n,s){const r=s.getModuleInfo(n);if(!r)return;const{isEntry:i}=r,l=r.meta,a=oe(l);if(!i){const c=o.get(n);if(c)return c;const p=Fn(n);if(p)return o.set(n,p),p}if(i){const c=s.getModuleIds();for(const p of c)s.getModuleInfo(p)&&oe(l)===a&&(e.has(p)||e.set(p,new Set),e.get(p).add([n,a]))}if(a&&!i&&e.has(n)){const c=[...e.get(n)];if(c.some(([d])=>{if(t.some(u=>u.path===d)){const u=s.getModuleInfo(d);return oe(u?u.meta:{})===a}return!1}))return;if(c.every(([,d])=>d===a))return o.has(n)?o.get(n):void 0;const p=f.basename(n,f.extname(n))+"-"+a;return o.set(n,p),p}},"splitChunks")},"createSplitChunks");var Ln=Object.defineProperty,qn=m((e,t)=>Ln(e,"name",{value:t,configurable:!0}),"n$4");const P=qn((e,t)=>e.isDynamicEntry?`chunks/[name].${t}`:`shared/${e.name}-[hash].${t}`,"getChunkFilename");var Bn=Object.defineProperty,Wn=m((e,t)=>Bn(e,"name",{value:t,configurable:!0}),"s$8");const Un=process.platform==="win32",Se=Wn((e,t)=>{const o=Un?"\\":"/";return e.name?.includes("node_modules"+o+".pnpm")?(e.name.replace("node_modules"+o+".pnpm","external")+"."+t).replace("node_modules"+o,""):e.name?.includes("node_modules")?e.name.replace("node_modules","external")+"."+t:"[name]."+t},"getEntryFileNames");var Vn=Object.defineProperty,zn=m((e,t)=>Vn(e,"name",{value:t,configurable:!0}),"p$1");const de=zn((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 s in n){if(s.startsWith("#"))continue;const r=n[s];typeof r=="string"&&(o[s]=f.join(e.options.rootDir,r))}}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 Hn=Object.defineProperty,x=m((e,t)=>Hn(e,"name",{value:t,configurable:!0}),"l$7");const Gn=x((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"+ie.versions.node.split(".")[0];if(t.pkg.engines?.node){const n=Me.minVersion(t.pkg.engines.node);n&&(o="node"+n.major)}if(t.options.rollup.esbuild.target){const n=A(t.options.rollup.esbuild.target);n.some(s=>s.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...A(o),...n])])}else t.options.rollup.esbuild.target=A(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"),it=x((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 "${v.cyan(f.relative(f.resolve(),e.id))}"
41
+ To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),ke.set(l,!0)}return e}m(Ye,"I$1");F(Ye,"replaceConfusingTypeNames");const En=F((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 Qe(e,t){if(e.includes("@internal")){const o=new I(e),n=Ft.parse(e,{plugins:["typescript"],sourceType:"module"});if(Ve(n,{enter(s){En(o,s)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}m(Qe,"S$1");F(Qe,"stripInternalTypes");const Sn=F((e,t)=>({name:"packem:patch-types",renderChunk(o,n){return o=Ye.call(this,o,n,e,t),o=Qe.call(this,o,n),o=xn(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var On=Object.defineProperty,Ze=m((e,t)=>On(e,"name",{value:t,configurable:!0}),"m$4");const et=Ze((e,t=!0)=>{if(!e)return null;const{config:o,path:n}=e;if(!o.compilerOptions)return null;const{baseUrl:s,paths:r}=o.compilerOptions;if(!s)return null;const i=f.resolve(f.dirname(n),s),l=[];if(r)for(const[a,c]of Object.entries(r)){let p;a==="@"||a==="~"||a==="#"?p=new RegExp(`^${a}/(.+)$`):p=new RegExp(`^${[...a].map(u=>u==="*"?"(.+)":u.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let d=0;for(const u of c){const g=[...D.normalizePath(f.resolve(i,u))].map(y=>y==="*"?"$"+(++d+""):y==="$"?"$$":y).join("");l.push({find:p,replacement:g})}}return t&&l.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...D.normalizePath(i)].map(a=>a==="$"?"$$":a).join("")}/$1`}),l},"getConfigAlias"),tt=Ze((e,t)=>{const o=et(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,s,r){if(!o||n.includes("\0"))return null;for(const{find:i,replacement:l}of o)if(i.test(n)){const a=n.replace(i,l),c=await this.resolve(a,s,{skipSelf:!0,...r});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 Nn=Object.defineProperty,ot=m((e,t)=>Nn(e,"name",{value:t,configurable:!0}),"u$5");const Dn=ot((e,t)=>{if(!t)return null;const{config:o,path:n}=t;if(!o.compilerOptions)return null;const{rootDirs:s}=o.compilerOptions;if(!s)return null;const r=[];for(const i of s){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${n}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${n}.`);r.push(f.resolve(e,i))}return r},"getRootDirectories"),nt=ot((e,t,o)=>{const n=Dn(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(s,r,i){if(n===null||n.length===0)return null;if(s.startsWith("."))for(const l of n){const a=f.join(l,s),c=await this.resolve(a,r,{skipSelf:!0,...i});if(c)return t.debug({message:`Resolved ${s} to ${c.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),c.id}return null}}},"resolveTsconfigRootDirectories");var _n=Object.defineProperty,Pn=m((e,t)=>_n(e,"name",{value:t,configurable:!0}),"r$5");const rt=Pn(()=>{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 Cn=Object.defineProperty,In=m((e,t)=>Cn(e,"name",{value:t,configurable:!0}),"s$a");const Rn=In(e=>{const t=f.basename(e).split(".");if(t.length>=2){const[o,n]=t.slice(-2),s=t[0],r=/^(\w+)-runtime$/.exec(o)?.[1];if(k.DEFAULT_EXTENSIONS.includes(n)&&r&&r.length>0)return s+"-"+r}},"getCustomModuleLayer");var Fn=Object.defineProperty,Mn=m((e,t)=>Fn(e,"name",{value:t,configurable:!0}),"i$6");const oe=Mn(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var An=Object.defineProperty,xe=m((e,t)=>An(e,"name",{value:t,configurable:!0}),"c$7");const Tn=xe((e,t)=>{const o=new Map;return xe(function(n,s){const r=s.getModuleInfo(n);if(!r)return;const{isEntry:i}=r,l=r.meta,a=oe(l);if(!i){const c=o.get(n);if(c)return c;const p=Rn(n);if(p)return o.set(n,p),p}if(i){const c=s.getModuleIds();for(const p of c)s.getModuleInfo(p)&&oe(l)===a&&(e.has(p)||e.set(p,new Set),e.get(p).add([n,a]))}if(a&&!i&&e.has(n)){const c=[...e.get(n)];if(c.some(([d])=>{if(t.some(u=>u.path===d)){const u=s.getModuleInfo(d);return oe(u?u.meta:{})===a}return!1}))return;if(c.every(([,d])=>d===a))return o.has(n)?o.get(n):void 0;const p=f.basename(n,f.extname(n))+"-"+a;return o.set(n,p),p}},"splitChunks")},"createSplitChunks");var Jn=Object.defineProperty,Ln=m((e,t)=>Jn(e,"name",{value:t,configurable:!0}),"n$4");const P=Ln((e,t)=>e.isDynamicEntry?`chunks/[name].${t}`:`shared/${e.name}-[hash].${t}`,"getChunkFilename");var qn=Object.defineProperty,Bn=m((e,t)=>qn(e,"name",{value:t,configurable:!0}),"s$8");const Wn=process.platform==="win32",Ee=Bn((e,t)=>{const o=Wn?"\\":"/";return e.name?.includes("node_modules"+o+".pnpm")?(e.name.replace("node_modules"+o+".pnpm","external")+"."+t).replace("node_modules"+o,""):e.name?.includes("node_modules")?e.name.replace("node_modules","external")+"."+t:"[name]."+t},"getEntryFileNames");var Un=Object.defineProperty,zn=m((e,t)=>Un(e,"name",{value:t,configurable:!0}),"p$1");const de=zn((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 s in n){if(s.startsWith("#"))continue;const r=n[s];typeof r=="string"&&(o[s]=f.join(e.options.rootDir,r))}}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 Vn=Object.defineProperty,x=m((e,t)=>Vn(e,"name",{value:t,configurable:!0}),"l$7");const Hn=x((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"+ie.versions.node.split(".")[0];if(t.pkg.engines?.node){const n=Fe.minVersion(t.pkg.engines.node);n&&(o="node"+n.major)}if(t.options.rollup.esbuild.target){const n=T(t.options.rollup.esbuild.target);n.some(s=>s.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...T(o),...n])])}else t.options.rollup.esbuild.target=T(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"),st=x((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 "${v.cyan(f.relative(f.resolve(),e.id))}"
42
42
  Is the module installed? Note:
43
43
  ↳ to inline a module into your bundle, install it to "devDependencies".
44
- ↳ 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"),Oe=new Map,at=x((e,t,o)=>{const n=x(r=>{for(const[i,l]of Object.entries(t))if(r.startsWith(i))return r.replace(i,l)},"findAlias"),s=tt(e.tsconfig,!1);return{external(r){const i=n(r);i&&(r=i);const l=Be(r);if(re(e.options.externals,l)||re(e.options.externals,r))return!0;const{pkg:a}=e;if(r.startsWith(".")||f.isAbsolute(r)||/src[/\\]/.test(r)||a.name&&r.startsWith(a.name)||a?.imports?.[r]!==void 0)return!1;if(s){for(const{find:c}of s)if(c.test(r))return e.logger.debug({message:`Resolved alias ${r} to ${c.source}`,prefix:o}),!1}return Oe.has(r)||e.logger.info({message:'Inlined implicit external "'+v.cyan(r)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),Oe.set(r,!0),!1},input:Object.fromEntries(e.options.entries.map(r=>[r.name,f.resolve(e.options.rootDir,r.input)])),logLevel:e.options.debug?"debug":"info",onLog:x((r,i)=>{let l=i.message;switch(i.stack&&(l=`${l}
45
- ${i.stack}`),r){case"info":{e.logger.info({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(r,i){it(r,e)||r.code||i(r)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),lt=x(async(e,t)=>{const o=de(e,"build");let n;e.options.rollup.resolve&&(n=O(Fe.nodeResolve({...e.options.rollup.resolve}),t));const s=e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Jn(e.dependencyGraphMap,e.buildEntries),preserveModules:!1};return{...at(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:x(r=>P(r,"cjs"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:x(r=>Se(r,"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,...s},e.options.emitESM&&{chunkFileNames:x(r=>P(r,"mjs"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:x(r=>Se(r,"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,...s}].filter(Boolean),plugins:[O(Ye(),t),O(st(),t),e.tsconfig&&O(rt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&O(ot(e.tsconfig,e.logger),t),e.options.rollup.replace&&Le({sourcemap:e.options.sourcemap,...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Je({customResolver:n,...e.options.rollup.alias,entries:o}),n,e.options.rollup.polyfillNode&&Vt({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&ze({...e.options.rollup.json}),yo(),e.options.rollup.wsam&&St.wasm(e.options.rollup.wsam),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&Fo(e.options.isolatedDeclarationTransformer,e.options.declaration,e.pkg.type,e.options.rollup.isolatedDeclarations),e.options.transformer?.(Gn(e.options.transformerName,e)),an({directiveRegex:/^['|"](use (\w+))['|"]$/,...e.options.rollup.preserveDirectives,logger:e.logger}),fn(e.options.entries.filter(r=>r.executable).map(r=>r.name).filter(Boolean)),e.options.cjsInterop&&e.options.emitCJS&&Ve({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&_o(),e.options.rollup.dynamicVars&&Ut(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&O(Wt({sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&Oo(e.pkg,e.options.rollup.shim),e.options.rollup.raw&&pn(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&Bo({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&Go({outDir:f.resolve(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&jo(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&Ge({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}),nn(),e.options.rollup.visualizer&&Nt.visualizer({brotliSize:!0,filename:"packem-bundle-analyze.html",gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,title:"Packem Visualizer",...e.options.rollup.visualizer})].filter(Boolean)}},"getRollupOptions"),Xn=x(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"),Kn=no(Xn),ct=x(async(e,t)=>{const o=de(e,"types"),n={load(l){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(l)?null:""},name:"packem:ignore-files"},s=e.tsconfig?.config.compilerOptions;delete s?.lib;let r;e.options.rollup.resolve&&(r=O(Fe.nodeResolve({...e.options.rollup.resolve}),t));const i="dts-plugin:"+process.pid+e.tsconfig.path;return{...at(e,o,"dts"),onwarn(l,a){it(l,e)||l.code!=="EMPTY_BUNDLE"&&a(l)},output:[e.options.emitCJS&&{chunkFileNames:x(l=>P(l,"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:x(l=>P(l,"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:x(l=>P(l,"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:[O(Ye(),t),O(st(),t),e.options.rollup.json&&ze({...e.options.rollup.json}),n,e.tsconfig&&O(rt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&O(ot(e.tsconfig,e.logger),t),e.options.rollup.replace&&Le({sourcemap:e.options.sourcemap,...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Je({customResolver:r,...e.options.rollup.alias,entries:o}),r,await Kn(i)(e),e.options.cjsInterop&&e.options.emitCJS&&Ve({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&On(e.options.rollup.patchTypes,e.logger),gn(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Ge({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}),Yo(e)].filter(Boolean)}},"getRollupDtsOptions");var Yn=Object.defineProperty,Qn=m((e,t)=>Yn(e,"name",{value:t,configurable:!0}),"c$6");const ne=Qn(async(e,t,o)=>{const n=await lt(e,t);if(await e.hooks.callHook("rollup:options",e,n),Object.keys(n.input).length===0)return;const s="rollup-build.json";n.cache=t.get(s,o);const r=await J.rollup(n);t.set(s,r.cache,o),await e.hooks.callHook("rollup:build",e,r);const i=new Map;for(const l of n.output){const{output:a}=await r.write(l),c=new Set,p=a.filter(u=>u.type==="chunk");for(const u of p){c.add(u.fileName);for(const g of u.imports)e.usedImports.add(g);u.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(u.code,"utf8"),chunks:u.imports.filter(g=>p.find(y=>y.fileName===g)),exports:u.exports,modules:Object.entries(u.modules).map(([g,y])=>({bytes:y.renderedLength,id:g})),path:u.fileName,type:"entry"})}const d=a.filter(u=>u.type==="asset");for(const u of d)i.has(u.fileName)||i.set(u.fileName,{bytes:Buffer.byteLength(u.source,"utf8"),path:u.fileName,type:"asset"});for(const u of c)e.usedImports.delete(u)}e.buildEntries.push(...i.values())},"build");var Zn=Object.defineProperty,W=m((e,t)=>Zn(e,"name",{value:t,configurable:!0}),"a$7");const U=W(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 ct(e,t);if(await e.hooks.callHook("rollup:dts:options",e,n),Object.keys(n.input).length===0)return;const s="rollup-dts.json";n.cache=t.get(s,o);const r=await J.rollup(n);t.set(s,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:W(i=>P(i,"d.cts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await r.write({chunkFileNames:W(i=>P(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:W(i=>P(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 er=Object.defineProperty,tr=m((e,t)=>er(e,"name",{value:t,configurable:!0}),"y$1");const or=tr((e,t,o)=>e.reduce((n,s)=>{const r=s[t],i=s[o];return n[r]||(n[r]={}),n[r][i]||(n[r][i]=[]),n[r][i].push(s),n},{}),"groupByKeys");var nr=Object.defineProperty,X=m((e,t)=>nr(e,"name",{value:t,configurable:!0}),"b$1");const rr=X((e,t,o)=>{const n=X(r=>f.relative(t.options.rootDir,f.resolve(t.options.outDir,r)),"rPath");let s=!1;for(const r of t.buildEntries.filter(i=>!i.chunk)){let i=r.bytes??0;for(const a of r.chunks??[])i+=t.buildEntries.find(c=>c.path===a)?.bytes??0;let l=` ${v.bold(n(r.path))} (${["total size: "+v.cyan(_.formatBytes(i)),r.type!=="asset"&&r.bytes&&"chunk size: "+v.cyan(_.formatBytes(r.bytes))].filter(Boolean).join(", ")})`;if(l+=r.exports?.length?`
44
+ ↳ 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"),Se=new Map,it=x((e,t,o)=>{const n=x(r=>{for(const[i,l]of Object.entries(t))if(r.startsWith(i))return r.replace(i,l)},"findAlias"),s=et(e.tsconfig,!1);return{external(r){const i=n(r);i&&(r=i);const l=qe(r);if(re(e.options.externals,l)||re(e.options.externals,r))return!0;const{pkg:a}=e;if(r.startsWith(".")||f.isAbsolute(r)||/src[/\\]/.test(r)||a.name&&r.startsWith(a.name)||a?.imports?.[r]!==void 0)return!1;if(s){for(const{find:c}of s)if(c.test(r))return e.logger.debug({message:`Resolved alias ${r} to ${c.source}`,prefix:o}),!1}return Se.has(r)||e.logger.info({message:'Inlined implicit external "'+v.cyan(r)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),Se.set(r,!0),!1},input:Object.fromEntries(e.options.entries.map(r=>[r.name,f.resolve(e.options.rootDir,r.input)])),logLevel:e.options.debug?"debug":"info",onLog:x((r,i)=>{let l=i.message;switch(i.stack&&(l=`${l}
45
+ ${i.stack}`),r){case"info":{e.logger.info({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(r,i){st(r,e)||r.code||i(r)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),at=x(async(e,t)=>{const o=de(e,"build");let n;e.options.rollup.resolve&&(n=O(Re.nodeResolve({...e.options.rollup.resolve}),t));const s=e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Tn(e.dependencyGraphMap,e.buildEntries),preserveModules:!1};return{...it(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:x(r=>P(r,"cjs"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:x(r=>Ee(r,"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,...s},e.options.emitESM&&{chunkFileNames:x(r=>P(r,"mjs"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:x(r=>Ee(r,"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,...s}].filter(Boolean),plugins:[O(Ke(),t),O(rt(),t),e.tsconfig&&O(nt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&O(tt(e.tsconfig,e.logger),t),e.options.rollup.replace&&Je({sourcemap:e.options.sourcemap,...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Te({customResolver:n,...e.options.rollup.alias,entries:o}),n,e.options.rollup.polyfillNode&&Ut({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&ze({...e.options.rollup.json}),ho(),e.options.rollup.wsam&&Et.wasm(e.options.rollup.wsam),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&Ro(e.options.isolatedDeclarationTransformer,e.options.declaration,e.pkg.type,e.options.rollup.isolatedDeclarations),e.options.transformer?.(Hn(e.options.transformerName,e)),sn({directiveRegex:/^['|"](use (\w+))['|"]$/,...e.options.rollup.preserveDirectives,logger:e.logger}),mn(e.options.entries.filter(r=>r.executable).map(r=>r.name).filter(Boolean)),e.options.cjsInterop&&e.options.emitCJS&&Ue({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Do(),e.options.rollup.dynamicVars&&Wt(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&O(Bt({sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&So(e.pkg,e.options.rollup.shim),e.options.rollup.raw&&cn(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&qo({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&Ho({outDir:f.resolve(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&$o(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&He({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}),on(),e.options.rollup.visualizer&&Ot.visualizer({brotliSize:!0,filename:"packem-bundle-analyze.html",gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,title:"Packem Visualizer",...e.options.rollup.visualizer})].filter(Boolean)}},"getRollupOptions"),Gn=x(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"),Xn=oo(Gn),lt=x(async(e,t)=>{const o=de(e,"types"),n={load(l){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(l)?null:""},name:"packem:ignore-files"},s=e.tsconfig?.config.compilerOptions;delete s?.lib;let r;e.options.rollup.resolve&&(r=O(Re.nodeResolve({...e.options.rollup.resolve}),t));const i="dts-plugin:"+process.pid+e.tsconfig.path;return{...it(e,o,"dts"),onwarn(l,a){st(l,e)||l.code!=="EMPTY_BUNDLE"&&a(l)},output:[e.options.emitCJS&&{chunkFileNames:x(l=>P(l,"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:x(l=>P(l,"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:x(l=>P(l,"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:[O(Ke(),t),O(rt(),t),e.options.rollup.json&&ze({...e.options.rollup.json}),n,e.tsconfig&&O(nt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&O(tt(e.tsconfig,e.logger),t),e.options.rollup.replace&&Je({sourcemap:e.options.sourcemap,...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Te({customResolver:r,...e.options.rollup.alias,entries:o}),r,await Xn(i)(e),e.options.cjsInterop&&e.options.emitCJS&&Ue({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&Sn(e.options.rollup.patchTypes,e.logger),fn(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&He({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}),Ko(e)].filter(Boolean)}},"getRollupDtsOptions");var Kn=Object.defineProperty,Yn=m((e,t)=>Kn(e,"name",{value:t,configurable:!0}),"c$6");const ne=Yn(async(e,t,o)=>{const n=await at(e,t);if(await e.hooks.callHook("rollup:options",e,n),Object.keys(n.input).length===0)return;const s="rollup-build.json";n.cache=t.get(s,o);const r=await J.rollup(n);t.set(s,r.cache,o),await e.hooks.callHook("rollup:build",e,r);const i=new Map;for(const l of n.output){const{output:a}=await r.write(l),c=new Set,p=a.filter(u=>u.type==="chunk");for(const u of p){c.add(u.fileName);for(const g of u.imports)e.usedImports.add(g);u.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(u.code,"utf8"),chunks:u.imports.filter(g=>p.find(y=>y.fileName===g)),exports:u.exports,modules:Object.entries(u.modules).map(([g,y])=>({bytes:y.renderedLength,id:g})),path:u.fileName,type:"entry"})}const d=a.filter(u=>u.type==="asset");for(const u of d)i.has(u.fileName)||i.set(u.fileName,{bytes:Buffer.byteLength(u.source,"utf8"),path:u.fileName,type:"asset"});for(const u of c)e.usedImports.delete(u)}e.buildEntries.push(...i.values())},"build");var Qn=Object.defineProperty,W=m((e,t)=>Qn(e,"name",{value:t,configurable:!0}),"a$7");const U=W(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 lt(e,t);if(await e.hooks.callHook("rollup:dts:options",e,n),Object.keys(n.input).length===0)return;const s="rollup-dts.json";n.cache=t.get(s,o);const r=await J.rollup(n);t.set(s,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:W(i=>P(i,"d.cts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await r.write({chunkFileNames:W(i=>P(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:W(i=>P(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 Zn=Object.defineProperty,er=m((e,t)=>Zn(e,"name",{value:t,configurable:!0}),"y$1");const tr=er((e,t,o)=>e.reduce((n,s)=>{const r=s[t],i=s[o];return n[r]||(n[r]={}),n[r][i]||(n[r][i]=[]),n[r][i].push(s),n},{}),"groupByKeys");var or=Object.defineProperty,X=m((e,t)=>or(e,"name",{value:t,configurable:!0}),"b$1");const nr=X((e,t,o)=>{const n=X(r=>f.relative(t.options.rootDir,f.resolve(t.options.outDir,r)),"rPath");let s=!1;for(const r of t.buildEntries.filter(i=>!i.chunk)){let i=r.bytes??0;for(const a of r.chunks??[])i+=t.buildEntries.find(c=>c.path===a)?.bytes??0;let l=` ${v.bold(n(r.path))} (${["total size: "+v.cyan(_.formatBytes(i)),r.type!=="asset"&&r.bytes&&"chunk size: "+v.cyan(_.formatBytes(r.bytes))].filter(Boolean).join(", ")})`;if(l+=r.exports?.length?`
46
46
  exports: `+v.gray(r.exports.join(", ")):"",r.chunks?.length&&(l+=`
47
47
  ${r.chunks.map(a=>{const c=t.buildEntries.find(p=>p.path===a)??{};return v.gray(" └─ "+n(a)+v.bold(c.bytes?" ("+_.formatBytes(c?.bytes)+")":""))}).join(`
48
48
  `)}`),r.modules&&r.modules.length>0){const a=r.modules.filter(c=>c.id.includes("node_modules")).sort((c,p)=>(p.bytes||0)-(c.bytes||0)).map(c=>v.gray(" 📦 "+n(c.id)+v.bold(c.bytes?" ("+_.formatBytes(c.bytes)+")":""))).join(`
@@ -55,26 +55,26 @@ ${r.chunks.map(a=>{const c=t.buildEntries.find(p=>p.path===a)??{};return v.gray(
55
55
  types: `+v.bold(n(p.path))+" (total size: "+v.cyan(_.formatBytes(p.bytes??0))+")"}}s=!0,l+=`
56
56
 
57
57
  `,e.raw(r.chunk?v.gray(l):l)}return s&&e.raw("Σ Total dist size (byte size):",v.cyan(_.formatBytes(t.buildEntries.reduce((r,i)=>r+(i.bytes??0),0))),`
58
- `),s},"showSizeInformation"),sr=X((e,t)=>{const o=or(e.options.entries,"environment","runtime"),n=[];for(const[s,r]of Object.entries(o))for(const[i,l]of Object.entries(r)){const a={...e};(s!=="undefined"||i!=="undefined")&&e.logger.info("Preparing build for "+(s==="undefined"?"":v.cyan(s)+" environment"+(i==="undefined"?"":" with "))+(i==="undefined"?"":v.cyan(i)+" runtime")),a.options.rollup.replace?(a.options.rollup.replace.values===void 0&&(a.options.rollup.replace.values={}),s!=="undefined"&&(a.options.rollup.replace.values={...a.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(s)}),a.options.rollup.replace.values={...a.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="";s!=="undefined"&&(c+=s+"/"),i!=="undefined"&&(c+=i+"/");let p=!1;a.options.minify!==void 0&&(p=a.options.minify),s==="development"?p=!1:s==="production"&&(p=!0);const d=[],u=[],g=[],y=[];for(const h of l)h.cjs&&h.esm?d.push(h):h.cjs?g.push(h):h.esm?u.push(h):h.declaration&&y.push(h);if(d.length>0){const h={...a,options:{...a.options,emitCJS:!0,emitESM:!0,entries:d,minify:p}};n.push(ne(h,t,c));const w=h.options.entries.filter(j=>j.declaration);e.options.declaration&&w.length>0&&n.push(U({...h,options:{...h.options,entries:w}},t,c))}if(u.length>0){const h={...a,options:{...a.options,emitCJS:!1,emitESM:!0,entries:u,minify:p}};n.push(ne(h,t,c));const w=h.options.entries.filter(j=>j.declaration);e.options.declaration&&w.length>0&&n.push(U({...h,options:{...h.options,entries:w}},t,c))}if(g.length>0){const h={...a,options:{...a.options,emitCJS:!0,emitESM:!1,entries:g,minify:p}};n.push(ne(h,t,c));const w=h.options.entries.filter(j=>j.declaration);e.options.declaration&&w.length>0&&n.push(U({...h,options:{...h.options,entries:w}},t,c))}if(a.options.declaration&&y.length>0){const h={...a,options:{...a.options,emitCJS:!1,emitESM:!1,entries:y,minify:p}};n.push(U(h,t,c))}}return n},"prepareRollupConfig"),ir=X(async(e,t,o)=>{await e.hooks.callHook("build:before",e),e.options.minify&&e.logger.info("Minification is enabled, the output will be minified");const n=t.dependencies?.typescript!==void 0||t.devDependencies?.typescript!==void 0;if(e.options.declaration&&e.tsconfig===void 0&&n)throw new Error("Cannot build declaration files without a tsconfig.json");n?e.options.declaration===!1&&e.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(e.options.declaration=!1,e.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),e.options.declaration&&e.logger.info("Using typescript version: "+v.cyan(t.devDependencies?.typescript??t.dependencies?.typescript??"unknown")),e.options.declaration&&(t.dependencies?.typescript||t.devDependencies?.typescript)&&!e.tsconfig?.config.compilerOptions?.isolatedModules&&e.logger.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
58
+ `),s},"showSizeInformation"),rr=X((e,t)=>{const o=tr(e.options.entries,"environment","runtime"),n=[];for(const[s,r]of Object.entries(o))for(const[i,l]of Object.entries(r)){const a={...e};(s!=="undefined"||i!=="undefined")&&e.logger.info("Preparing build for "+(s==="undefined"?"":v.cyan(s)+" environment"+(i==="undefined"?"":" with "))+(i==="undefined"?"":v.cyan(i)+" runtime")),a.options.rollup.replace?(a.options.rollup.replace.values===void 0&&(a.options.rollup.replace.values={}),s!=="undefined"&&(a.options.rollup.replace.values={...a.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(s)}),a.options.rollup.replace.values={...a.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="";s!=="undefined"&&(c+=s+"/"),i!=="undefined"&&(c+=i+"/");let p=!1;a.options.minify!==void 0&&(p=a.options.minify),s==="development"?p=!1:s==="production"&&(p=!0);const d=[],u=[],g=[],y=[];for(const h of l)h.cjs&&h.esm?d.push(h):h.cjs?g.push(h):h.esm?u.push(h):h.declaration&&y.push(h);if(d.length>0){const h={...a,options:{...a.options,emitCJS:!0,emitESM:!0,entries:d,minify:p}};n.push(ne(h,t,c));const w=h.options.entries.filter(j=>j.declaration);e.options.declaration&&w.length>0&&n.push(U({...h,options:{...h.options,entries:w}},t,c))}if(u.length>0){const h={...a,options:{...a.options,emitCJS:!1,emitESM:!0,entries:u,minify:p}};n.push(ne(h,t,c));const w=h.options.entries.filter(j=>j.declaration);e.options.declaration&&w.length>0&&n.push(U({...h,options:{...h.options,entries:w}},t,c))}if(g.length>0){const h={...a,options:{...a.options,emitCJS:!0,emitESM:!1,entries:g,minify:p}};n.push(ne(h,t,c));const w=h.options.entries.filter(j=>j.declaration);e.options.declaration&&w.length>0&&n.push(U({...h,options:{...h.options,entries:w}},t,c))}if(a.options.declaration&&y.length>0){const h={...a,options:{...a.options,emitCJS:!1,emitESM:!1,entries:y,minify:p}};n.push(U(h,t,c))}}return n},"prepareRollupConfig"),sr=X(async(e,t,o)=>{await e.hooks.callHook("build:before",e),e.options.minify&&e.logger.info("Minification is enabled, the output will be minified");const n=t.dependencies?.typescript!==void 0||t.devDependencies?.typescript!==void 0;if(e.options.declaration&&e.tsconfig===void 0&&n)throw new Error("Cannot build declaration files without a tsconfig.json");n?e.options.declaration===!1&&e.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(e.options.declaration=!1,e.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),e.options.declaration&&e.logger.info("Using typescript version: "+v.cyan(t.devDependencies?.typescript??t.dependencies?.typescript??"unknown")),e.options.declaration&&(t.dependencies?.typescript||t.devDependencies?.typescript)&&!e.tsconfig?.config.compilerOptions?.isolatedModules&&e.logger.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
59
59
  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.
60
- 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 Promise.all(sr(e,o)),e.logger.success(v.green(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const s of $.walk(f.join(e.options.rootDir,e.options.outDir))){let r=e.buildEntries.find(i=>f.join(e.options.rootDir,e.options.outDir,i.path)===s.path);if(r||(r={chunk:!0,path:s.path},e.buildEntries.push(r)),!r.bytes){const i=await ae.stat(f.resolve(e.options.rootDir,e.options.outDir,s.path));r.bytes=i.size}}return await e.hooks.callHook("build:done",e),rr(e.logger,e,t)},"build");var ar=Object.defineProperty,lr=m((e,t)=>ar(e,"name",{value:t,configurable:!0}),"r$3");const pt=lr((e,t)=>qe(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var cr=Object.defineProperty,pr=m((e,t)=>cr(e,"name",{value:t,configurable:!0}),"i$4");const me=pr(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var ur=Object.defineProperty,dr=m((e,t)=>ur(e,"name",{value:t,configurable:!0}),"r$1");const L=dr((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var mr=Object.defineProperty,ut=m((e,t)=>mr(e,"name",{value:t,configurable:!0}),"e$1");const K=ut(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),dt=ut((e,t,o,n)=>{if(n){const i=K(n);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[s,...r]=t;return dt(s,r,o,n)},"inferExportType");var fr=Object.defineProperty,gr=m((e,t)=>fr(e,"name",{value:t,configurable:!0}),"i$2");const hr=new Set(["import","require","node","node-addons","default","types","deno","browser",...k.SPECIAL_EXPORT_CONVENTIONS]),fe=gr((e,t,o,n=[])=>{if(!e)return[];if(typeof e=="string"){const s=K(e);if(s&&s!==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:s??t}]}return Object.entries(e).filter(([s])=>!s.endsWith(".json")).flatMap(([s,r])=>o===!1&&s==="types"?[]:typeof r=="string"?{file:r,key:"exports",...hr.has(s)?{subKey:s}:{},type:dt(s,n,t,r)}:fe(r,t,o,[...n,s]))},"extractExportFilenames");var yr=Object.defineProperty,Z=m((e,t)=>yr(e,"name",{value:t,configurable:!0}),"c$3");const vr=Z((e,t)=>e.key==="exports"&&e.subKey===k.PRODUCTION_ENV?k.PRODUCTION_ENV:e.key==="exports"&&e.subKey===k.DEVELOPMENT_ENV?k.DEVELOPMENT_ENV:t,"getEnvironment"),V=Z((e,t,o,n,s,r)=>{const i=vr(s,r.environment);let l="node";for(const p of k.RUNTIME_EXPORT_CONVENTIONS)if(s.file.includes("."+p+".")||s.subKey===p){l=p;break}let a=e.find(p=>p.input===t&&p.environment===i&&p.runtime===l);a===void 0&&(a=e[e.push({environment:i,input:t,runtime:l})-1]),o&&(a.outDir=n),s.isExecutable?(a.executable=!0,a.declaration=!1,s.type==="cjs"&&(a.cjs=!0),s.type==="esm"&&(a.esm=!0)):(/\.d\.[mc]?ts$/.test(s.file)&&r.options.declaration!==!1&&(a.declaration=r.options.declaration),s.type==="cjs"&&(a.cjs=!0),s.type==="esm"&&(a.esm=!0));const c=s.file.replace(f.extname(s.file),"").replace(new RegExp(`^./${r.options.outDir.replace(/^\.\//,"")}/`),"");k.SPECIAL_EXPORT_CONVENTIONS.has(s.subKey)&&!t.includes(c)&&(a.fileAlias=c)},"createOrUpdateEntry");let Ne=!1;const De=Z(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"),br=Z((e,t,o)=>{const n=[];t.sort((l,a)=>l.split("/").length-a.split("/").length);const s=e.type==="module"?"esm":"cjs";s==="esm"&&(o.options.emitESM=!0),s==="cjs"&&(o.options.emitCJS=!0);const r=fe(e.exports,s,o.options.declaration);if(e.bin){const l=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const a of l){const c=K(a);if(c&&c!==s)throw new Error(`Exported file "${a}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);r.push({file:a,isExecutable:!0,key:"bin",type:c??s})}}e.main&&r.push({file:e.main,key:"main",type:K(e.main)??s}),e.module&&r.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(De(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),r.push({file:e.types??e.typings,key:"types"}));const i=[];for(const l of r){o.options.declaration===void 0&&(l.key==="types"||l.subKey==="types")&&(o.options.declaration=l.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&l.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&l.type==="esm"&&(o.options.emitESM=!0);const a=l.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=a.endsWith("/");if(c&&["./","/"].includes(a))continue;const p=a.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),d="(?<=/|$)",u=c?"":"\\.\\w+$";if(l.file.includes("/*")&&l.key==="exports"){Ne||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Ne=!0);const w=[],j=new RegExp(d+p.replace("*","(.*)")+u),b=new RegExp(d+p.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+u);for(const S of t)(j.test(S)||k.SPECIAL_EXPORT_CONVENTIONS.has(l.subKey)&&b.test(S))&&w.push(S);if(w.length===0){n.push(`Could not find entrypoint for \`${l.file}\``);continue}for(const S of w)V(i,S,c,a,l,o);continue}const g=new RegExp(d+p+u);let y=t.find(w=>g.test(w));if(k.SPECIAL_EXPORT_CONVENTIONS.has(l.subKey)&&y===void 0){const w=new RegExp(d+p.replace(/(.*)\.[^.]*$/,"$1")+u);y=t.find(j=>w.test(j))}if(y===void 0){$.isAccessibleSync(f.resolve(o.options.rootDir,l.file))||n.push(`Could not find entrypoint for \`${l.file}\``);continue}(y.endsWith(".ts")||y.endsWith(".cts")||y.endsWith(".mts"))&&$.isAccessibleSync(y)&&De(o);const h=y.replace(k.ENDING_RE,"");$.isAccessibleSync(h+".cts")&&$.isAccessibleSync(h+".mts")?(V(i,h+".cts",c,a,{...l,type:"cjs"},o),V(i,h+".mts",c,a,{...l,type:"esm"},o)):V(i,y,c,a,l,o)}return{entries:i,warnings:n}},"inferEntries");var $r=Object.defineProperty,jr=m((e,t)=>$r(e,"name",{value:t,configurable:!0}),"o$3");const wr=jr((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 kr=Object.defineProperty,xr=m((e,t)=>kr(e,"name",{value:t,configurable:!0}),"l$6");const Er={hooks:{"build:prepare":xr(function(e){if(e.options.entries.length>0)return;const t=f.join(e.options.rootDir,e.options.sourceDir);if(!le.existsSync(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=$.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(me(n.publishConfig)),n=wr(n,e.options.declaration));const s=br(n,o,e);for(const r of s.warnings)L(e,r);if(e.options.entries.push(...s.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",v.cyan(e.options.entries.map(r=>r.fileAlias?v.bold(r.fileAlias)+" => "+v.bold(r.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):v.bold(r.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),v.gray([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(r=>`[${r}]`).join(" ")))},"build:prepare")}};var Sr=Object.defineProperty,Or=m((e,t)=>Sr(e,"name",{value:t,configurable:!0}),"n$1");const Nr=Or((e,t)=>{if(e==="auto")e=Er;else{if(e==="none")return{};typeof e=="string"&&(e=pt(e,t))}return typeof e=="function"&&(e=e()),e},"resolvePreset");var Dr=Object.defineProperty,_r=m((e,t)=>Dr(e,"name",{value:t,configurable:!0}),"o$2");const Pr=_r((e,t)=>{const o=qe(t,{esmResolve:!0,interopDefault:!0});try{return o.resolve(e)}catch(n){if(n.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:n});return e}},"tryResolve");var Cr=Object.defineProperty,Ir=m((e,t)=>Cr(e,"name",{value:t,configurable:!0}),"u$2");const Rr=Ir(async e=>{const t=await H.resolvePath("jiti",{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:ye&&ye.src||new URL("create-bundler.cjs",document.baseURI).href}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...de(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const n of e.options.entries){const s=f.resolve(e.options.rootDir,e.options.outDir,n.name),r=f.normalize(Pr(n.input,e.options.rootDir)||n.input),i=r.slice(0,Math.max(0,r.length-f.extname(r).length)),l=await $.readFile(r),a=hn(l);e.options.emitCJS&&await $.writeFile(`${s}.cjs`,a+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`module.exports = _jiti(${JSON.stringify(r)})`].join(`
60
+ 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 Promise.all(rr(e,o)),e.logger.success(v.green(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const s of $.walk(f.join(e.options.rootDir,e.options.outDir))){let r=e.buildEntries.find(i=>f.join(e.options.rootDir,e.options.outDir,i.path)===s.path);if(r||(r={chunk:!0,path:s.path},e.buildEntries.push(r)),!r.bytes){const i=await ae.stat(f.resolve(e.options.rootDir,e.options.outDir,s.path));r.bytes=i.size}}return await e.hooks.callHook("build:done",e),nr(e.logger,e,t)},"build");var ir=Object.defineProperty,ar=m((e,t)=>ir(e,"name",{value:t,configurable:!0}),"r$3");const ct=ar((e,t)=>Le(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var lr=Object.defineProperty,cr=m((e,t)=>lr(e,"name",{value:t,configurable:!0}),"i$4");const me=cr(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var pr=Object.defineProperty,ur=m((e,t)=>pr(e,"name",{value:t,configurable:!0}),"r$1");const L=ur((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var dr=Object.defineProperty,pt=m((e,t)=>dr(e,"name",{value:t,configurable:!0}),"e$1");const K=pt(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),ut=pt((e,t,o,n)=>{if(n){const i=K(n);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[s,...r]=t;return ut(s,r,o,n)},"inferExportType");var mr=Object.defineProperty,fr=m((e,t)=>mr(e,"name",{value:t,configurable:!0}),"i$2");const gr=new Set(["import","require","node","node-addons","default","types","deno","browser",...k.SPECIAL_EXPORT_CONVENTIONS]),fe=fr((e,t,o,n=[])=>{if(!e)return[];if(typeof e=="string"){const s=K(e);if(s&&s!==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:s??t}]}return Object.entries(e).filter(([s])=>!s.endsWith(".json")).flatMap(([s,r])=>o===!1&&s==="types"?[]:typeof r=="string"?{file:r,key:"exports",...gr.has(s)?{subKey:s}:{},type:ut(s,n,t,r)}:fe(r,t,o,[...n,s]))},"extractExportFilenames");var hr=Object.defineProperty,Z=m((e,t)=>hr(e,"name",{value:t,configurable:!0}),"c$3");const yr=Z((e,t)=>e.key==="exports"&&e.subKey===k.PRODUCTION_ENV?k.PRODUCTION_ENV:e.key==="exports"&&e.subKey===k.DEVELOPMENT_ENV?k.DEVELOPMENT_ENV:t,"getEnvironment"),z=Z((e,t,o,n,s,r)=>{const i=yr(s,r.environment);let l="node";for(const p of k.RUNTIME_EXPORT_CONVENTIONS)if(s.file.includes("."+p+".")||s.subKey===p){l=p;break}let a=e.find(p=>p.input===t&&p.environment===i&&p.runtime===l);a===void 0&&(a=e[e.push({environment:i,input:t,runtime:l})-1]),o&&(a.outDir=n),s.isExecutable?(a.executable=!0,a.declaration=!1,s.type==="cjs"&&(a.cjs=!0),s.type==="esm"&&(a.esm=!0)):(/\.d\.[mc]?ts$/.test(s.file)&&r.options.declaration!==!1&&(a.declaration=r.options.declaration),s.type==="cjs"&&(a.cjs=!0),s.type==="esm"&&(a.esm=!0));const c=s.file.replace(f.extname(s.file),"").replace(new RegExp(`^./${r.options.outDir.replace(/^\.\//,"")}/`),"");k.SPECIAL_EXPORT_CONVENTIONS.has(s.subKey)&&!t.includes(c)&&(a.fileAlias=c)},"createOrUpdateEntry");let Oe=!1;const Ne=Z(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"),vr=Z((e,t,o)=>{const n=[];t.sort((l,a)=>l.split("/").length-a.split("/").length);const s=e.type==="module"?"esm":"cjs";s==="esm"&&(o.options.emitESM=!0),s==="cjs"&&(o.options.emitCJS=!0);const r=fe(e.exports,s,o.options.declaration);if(e.bin){const l=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const a of l){const c=K(a);if(c&&c!==s)throw new Error(`Exported file "${a}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);r.push({file:a,isExecutable:!0,key:"bin",type:c??s})}}e.main&&r.push({file:e.main,key:"main",type:K(e.main)??s}),e.module&&r.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(Ne(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),r.push({file:e.types??e.typings,key:"types"}));const i=[];for(const l of r){o.options.declaration===void 0&&(l.key==="types"||l.subKey==="types")&&(o.options.declaration=l.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&l.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&l.type==="esm"&&(o.options.emitESM=!0);const a=l.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=a.endsWith("/");if(c&&["./","/"].includes(a))continue;const p=a.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),d="(?<=/|$)",u=c?"":"\\.\\w+$";if(l.file.includes("/*")&&l.key==="exports"){Oe||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Oe=!0);const w=[],j=new RegExp(d+p.replace("*","(.*)")+u),b=new RegExp(d+p.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+u);for(const S of t)(j.test(S)||k.SPECIAL_EXPORT_CONVENTIONS.has(l.subKey)&&b.test(S))&&w.push(S);if(w.length===0){n.push(`Could not find entrypoint for \`${l.file}\``);continue}for(const S of w)z(i,S,c,a,l,o);continue}const g=new RegExp(d+p+u);let y=t.find(w=>g.test(w));if(k.SPECIAL_EXPORT_CONVENTIONS.has(l.subKey)&&y===void 0){const w=new RegExp(d+p.replace(/(.*)\.[^.]*$/,"$1")+u);y=t.find(j=>w.test(j))}if(y===void 0){$.isAccessibleSync(f.resolve(o.options.rootDir,l.file))||n.push(`Could not find entrypoint for \`${l.file}\``);continue}(y.endsWith(".ts")||y.endsWith(".cts")||y.endsWith(".mts"))&&$.isAccessibleSync(y)&&Ne(o);const h=y.replace(k.ENDING_RE,"");$.isAccessibleSync(h+".cts")&&$.isAccessibleSync(h+".mts")?(z(i,h+".cts",c,a,{...l,type:"cjs"},o),z(i,h+".mts",c,a,{...l,type:"esm"},o)):z(i,y,c,a,l,o)}return{entries:i,warnings:n}},"inferEntries");var br=Object.defineProperty,$r=m((e,t)=>br(e,"name",{value:t,configurable:!0}),"o$3");const jr=$r((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 wr=Object.defineProperty,kr=m((e,t)=>wr(e,"name",{value:t,configurable:!0}),"l$6");const xr={hooks:{"build:prepare":kr(function(e){if(e.options.entries.length>0)return;const t=f.join(e.options.rootDir,e.options.sourceDir);if(!le.existsSync(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=$.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(me(n.publishConfig)),n=jr(n,e.options.declaration));const s=vr(n,o,e);for(const r of s.warnings)L(e,r);if(e.options.entries.push(...s.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",v.cyan(e.options.entries.map(r=>r.fileAlias?v.bold(r.fileAlias)+" => "+v.bold(r.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):v.bold(r.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),v.gray([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(r=>`[${r}]`).join(" ")))},"build:prepare")}};var Er=Object.defineProperty,Sr=m((e,t)=>Er(e,"name",{value:t,configurable:!0}),"n$1");const Or=Sr((e,t)=>{if(e==="auto")e=xr;else{if(e==="none")return{};typeof e=="string"&&(e=ct(e,t))}return typeof e=="function"&&(e=e()),e},"resolvePreset");var Nr=Object.defineProperty,Dr=m((e,t)=>Nr(e,"name",{value:t,configurable:!0}),"o$2");const _r=Dr((e,t)=>{const o=Le(t,{esmResolve:!0,interopDefault:!0});try{return o.resolve(e)}catch(n){if(n.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:n});return e}},"tryResolve");var Pr=Object.defineProperty,Cr=m((e,t)=>Pr(e,"name",{value:t,configurable:!0}),"u$2");const Ir=Cr(async e=>{const t=await H.resolvePath("jiti",{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:ye&&ye.src||new URL("create-bundler.cjs",document.baseURI).href}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...de(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const n of e.options.entries){const s=f.resolve(e.options.rootDir,e.options.outDir,n.name),r=f.normalize(_r(n.input,e.options.rootDir)||n.input),i=r.slice(0,Math.max(0,r.length-f.extname(r).length)),l=await $.readFile(r),a=gn(l);e.options.emitCJS&&await $.writeFile(`${s}.cjs`,a+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`module.exports = _jiti(${JSON.stringify(r)})`].join(`
61
61
  `));let c=[];try{c=await H.resolveModuleExportNames(r,{extensions:k.DEFAULT_EXTENSIONS})}catch(d){L(e,`Cannot analyze ${r} for exports: ${d.toString()}`);return}const p=c.includes("default")||c.length===0;await $.writeFile(`${s}.mjs`,a+[`import jiti from ${JSON.stringify(Ae.pathToFileURL(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(r)})} */`,`const _module = await _jiti.import(${JSON.stringify(r)});`,p?`
62
62
  export default _module;`:"",...c.filter(d=>d!=="default").map(d=>`export const ${d} = _module.${d};`)].join(`
63
63
  `)),await $.writeFile(`${s}.d.cts`,[`export * from ${JSON.stringify(i)};`,p?`export { default } from ${JSON.stringify(i)};`:""].join(`
64
64
  `)),await $.writeFile(`${s}.d.mts`,[`export * from ${JSON.stringify(r)};`,p?`export { default } from ${JSON.stringify(r)};`:""].join(`
65
- `)),a&&(await se(`${s}.cjs`),await se(`${s}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Fr=Object.defineProperty,ge=m((e,t)=>Fr(e,"name",{value:t,configurable:!0}),"i$1");const Mr=ge(e=>{const{message:t,name:o="Error",stack:n}=e;if(!n)return n;const s=`${o}: ${t}
66
- `;return n.startsWith(s)?n.slice(s.length):n},"extractStack"),Tr=ge(e=>`
65
+ `)),a&&(await se(`${s}.cjs`),await se(`${s}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Rr=Object.defineProperty,ge=m((e,t)=>Rr(e,"name",{value:t,configurable:!0}),"i$1");const Fr=ge(e=>{const{message:t,name:o="Error",stack:n}=e;if(!n)return n;const s=`${o}: ${t}
66
+ `;return n.startsWith(s)?n.slice(s.length):n},"extractStack"),Mr=ge(e=>`
67
67
  ${e.replaceAll(/^\n|\n$/g,"")}
68
- `,"normalizeCodeFrame"),mt=ge(e=>{const t=Mr(e);let o=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(o+=`
68
+ `,"normalizeCodeFrame"),dt=ge(e=>{const t=Fr(e);let o=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(o+=`
69
69
  file: ${v.cyan(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(o+=`
70
- `+v.yellow(Tr(e.frame))),e.message=o,t!==void 0&&(e.stack=`${e.message}
71
- ${t}`)},"enhanceRollupError");var Ar=Object.defineProperty,ft=m((e,t)=>Ar(e,"name",{value:t,configurable:!0}),"l$4");const _e=ft((e,t,o)=>{const n="watcher:"+t;e.on("change",(s,{event:r})=>{o.info({message:`${v.cyan(f.relative(".",s))} was ${r}d`,prefix:n})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:n})}),e.on("event",async s=>{switch(s.code){case"END":{o.success({message:"Rebuild "+t+" finished",prefix:n});break}case"BUNDLE_START":{o.info({message:v.cyan("build started..."),prefix:n});break}case"BUNDLE_END":{await s.result.close(),o.info({message:v.cyan(`built in ${s.duration+""}ms.`),prefix:n});break}case"ERROR":{mt(s.error),o.error({context:[s.error],message:"Rebuild "+t+" failed: "+s.error.message,prefix:n});break}}})},"watchHandler"),Jr=ft(async(e,t)=>{const o=await lt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;o.cache=t.get("rollup-watch"),typeof o.watch=="object"&&o.watch.include===void 0&&(o.watch.include=[f.join(e.options.sourceDir,"**")],o.watch.chokidar={cwd:e.options.rootDir,...o.watch.chokidar});const n=J.watch(o);await e.hooks.callHook("rollup:watch",e,n);const s=[...Array.isArray(o.input)?o.input:typeof o.input=="string"?[o.input]:Object.keys(o.input??{})];let r="Starting watchers for entries:";for(const i of s)r+=v.gray(`
72
- └─ ${f.relative(process.cwd(),i)}`);if(e.logger.info(r),_e(n,"bundle",e.logger),e.options.declaration){const i=await ct(e,t);await e.hooks.callHook("rollup:dts:options",e,i);const l=J.watch(i);await e.hooks.callHook("rollup:watch",e,l),_e(l,"types",e.logger)}},"watch");var Lr=Object.defineProperty,qr=m((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"a$4");class Br{static{m(this,"p")}static{qr(this,"FileCache")}#n;#e;#r;#t=!0;#o=new Map;#s;constructor(t,o,n){this.#n=t,this.#e=At.findCacheDirSync("@visulima/packem",{cwd:t}),this.#r=o,this.#s=n,this.#e===void 0?n.debug("Could not create cache directory."):n.debug(`Cache path is: ${this.#e}`)}set isEnabled(t){this.#t=t}get cachePath(){return this.#e}has(t,o){return!this.#t||this.#e===void 0?!1:$.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(!$.isAccessibleSync(n))return;const s=$.readFileSync(n);try{const r=JSON.parse(s);return this.#o.set(n,r),r}catch{this.#s.warn(`Could not parse cache file: ${n}, deleting the broken cache file.`),this.#o.delete(n),le.rmSync(n,{force:!0});return}}set(t,o,n){if(!this.#t||this.#e===void 0||o===void 0)return;const s=this.getFilePath(t,n);typeof o=="object"&&(o=JSON.stringify(o)),$.writeFileSync(s,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 Wr=Object.defineProperty,z=m((e,t)=>Wr(e,"name",{value:t,configurable:!0}),"l$3");const Ur=D.createFilter,Vr=z((e,t)=>{const{sideEffects:o}=t;let n;if(typeof o=="boolean")n=z(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)n=z(()=>!1,"hasSideEffects");else{const s=o.map(r=>r.includes("/")?r:`**/${r}`);n=Ur(s,null,{resolve:e})}else n=z(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var zr=Object.defineProperty,Hr=m((e,t)=>zr(e,"name",{value:t,configurable:!0}),"r");const Pe=Hr((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
70
+ `+v.yellow(Mr(e.frame))),e.message=o,t!==void 0&&(e.stack=`${e.message}
71
+ ${t}`)},"enhanceRollupError");var Ar=Object.defineProperty,mt=m((e,t)=>Ar(e,"name",{value:t,configurable:!0}),"l$4");const De=mt((e,t,o)=>{const n="watcher:"+t;e.on("change",(s,{event:r})=>{o.info({message:`${v.cyan(f.relative(".",s))} was ${r}d`,prefix:n})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:n})}),e.on("event",async s=>{switch(s.code){case"END":{o.success({message:"Rebuild "+t+" finished",prefix:n});break}case"BUNDLE_START":{o.info({message:v.cyan("build started..."),prefix:n});break}case"BUNDLE_END":{await s.result.close(),o.info({message:v.cyan(`built in ${s.duration+""}ms.`),prefix:n});break}case"ERROR":{dt(s.error),o.error({context:[s.error],message:"Rebuild "+t+" failed: "+s.error.message,prefix:n});break}}})},"watchHandler"),Tr=mt(async(e,t)=>{const o=await at(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;o.cache=t.get("rollup-watch"),typeof o.watch=="object"&&o.watch.include===void 0&&(o.watch.include=[f.join(e.options.sourceDir,"**")],o.watch.chokidar={cwd:e.options.rootDir,...o.watch.chokidar});const n=J.watch(o);await e.hooks.callHook("rollup:watch",e,n);const s=[...Array.isArray(o.input)?o.input:typeof o.input=="string"?[o.input]:Object.keys(o.input??{})];let r="Starting watchers for entries:";for(const i of s)r+=v.gray(`
72
+ └─ ${f.relative(process.cwd(),i)}`);if(e.logger.info(r),De(n,"bundle",e.logger),e.options.declaration){const i=await lt(e,t);await e.hooks.callHook("rollup:dts:options",e,i);const l=J.watch(i);await e.hooks.callHook("rollup:watch",e,l),De(l,"types",e.logger)}},"watch");var Jr=Object.defineProperty,Lr=m((e,t)=>Jr(e,"name",{value:t,configurable:!0}),"a$4");class qr{static{m(this,"p")}static{Lr(this,"FileCache")}#n;#e;#r;#t=!0;#o=new Map;#s;constructor(t,o,n){this.#n=t,this.#e=At.findCacheDirSync("@visulima/packem",{cwd:t}),this.#r=o,this.#s=n,this.#e===void 0?n.debug("Could not create cache directory."):n.debug(`Cache path is: ${this.#e}`)}set isEnabled(t){this.#t=t}get cachePath(){return this.#e}has(t,o){return!this.#t||this.#e===void 0?!1:$.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(!$.isAccessibleSync(n))return;const s=$.readFileSync(n);try{const r=JSON.parse(s);return this.#o.set(n,r),r}catch{this.#s.warn(`Could not parse cache file: ${n}, deleting the broken cache file.`),this.#o.delete(n),le.rmSync(n,{force:!0});return}}set(t,o,n){if(!this.#t||this.#e===void 0||o===void 0)return;const s=this.getFilePath(t,n);typeof o=="object"&&(o=JSON.stringify(o)),$.writeFileSync(s,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 Br=Object.defineProperty,V=m((e,t)=>Br(e,"name",{value:t,configurable:!0}),"l$3");const Wr=D.createFilter,Ur=V((e,t)=>{const{sideEffects:o}=t;let n;if(typeof o=="boolean")n=V(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)n=V(()=>!1,"hasSideEffects");else{const s=o.map(r=>r.includes("/")?r:`**/${r}`);n=Wr(s,null,{resolve:e})}else n=V(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var zr=Object.defineProperty,Vr=m((e,t)=>zr(e,"name",{value:t,configurable:!0}),"r");const _e=Vr((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
73
73
  `),e.logger.warn(`Build is done with some warnings:
74
74
 
75
75
  ${[...e.warnings].map(o=>`- ${o}`).join(`
76
- `)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logBuildErrors");var Gr=Object.defineProperty,gt=m((e,t)=>Gr(e,"name",{value:t,configurable:!0}),"n");const Ce=gt(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(k.ENDING_RE,"")}if(!e.input)throw new Error(`Missing entry input: ${me(e)}`);Lt.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):(t.options.emitCJS!==void 0&&e.cjs===void 0&&(e.cjs=t.options.emitCJS),t.options.emitESM!==void 0&&e.esm===void 0&&(e.esm=t.options.emitESM)),e.outDir=f.resolve(t.options.rootDir,e.outDir??t.options.outDir)},"extendEntry"),Xr=gt(async e=>{e.options.entries=e.options.entries.map(t=>typeof t=="string"?{input:t,isGlob:be(t)}:{...t,isGlob:be(t.input)});for(const t of e.options.entries.filter(o=>o.isGlob)){const{isGlob:o,...n}=t,s=Te.globSync([n.input],{cwd:e.options.rootDir,dot:!1,ignore:["**/node_modules/**"],onlyFiles:!0});if(s.length===0)throw new Jt.NotFoundError("No files found in the glob pattern: "+v.cyan(f.join(e.options.rootDir,n.input)));for(const r of s)e.options.entries.push({...n,input:f.resolve(e.options.rootDir,r)});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 Ce(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 Ce(t,e)},"prepareEntries");var Kr=Object.defineProperty,Yr=m((e,t)=>Kr(e,"name",{value:t,configurable:!0}),"a$2");const Qr=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,Zr=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"]),Ie=Yr(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(Qr.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(Zr.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const n=f.resolve(o);if(!$.isAccessibleSync(n))throw new Error(`Target path "${n}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var es=Object.defineProperty,ts=m((e,t)=>es(e,"name",{value:t,configurable:!0}),"o");const os=ts(e=>{const t=new Set,o=new Set(Object.keys(e.pkg?.dependencies??{})),n=new Set;for(const s of e.usedImports)o.delete(s),t.add(s);if(e.pkg?.dependencies)for(const s of Object.keys(e.pkg?.dependencies))o.delete(s);for(const s of t){const r=Be(s);!re(e.options.externals,s)&&!s.startsWith("chunks/")&&e.pkg?.dependencies?.[r]===void 0&&e.pkg?.peerDependencies?.[r]===void 0&&n.add(s)}o.size>0&&L(e,`Potential unused dependencies found: ${[...o].map(s=>v.cyan(s)).join(", ")}`),n.size>0&&L(e,`Potential implicit dependencies found: ${[...n].map(s=>v.cyan(s)).join(", ")}`)},"validateDependencies");var ns=Object.defineProperty,ht=m((e,t)=>ns(e,"name",{value:t,configurable:!0}),"i");const rs=ht((e,t)=>Bt.distance(e,t)<=e.length/3||t.includes(e),"isSimilar"),ss=ht((e,t)=>{const o=e.toLowerCase();return t.filter(n=>rs(n.toLowerCase(),o))},"findAlternatives");var is=Object.defineProperty,Re=m((e,t)=>is(e,"name",{value:t,configurable:!0}),"s");const as=Re((e,t)=>{const o=new Set([...typeof e.bin=="string"?[e.bin]:Object.values(e.bin??{}),e.main,e.module,t.options.declaration?e.types:"",t.options.declaration?e.typings:"",...fe(e.exports,e.type==="module"?"esm":"cjs",t.options.declaration).map(s=>s.file)].map(s=>s&&f.resolve(t.options.rootDir,s.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const s of o)s&&!s.includes("*")&&!le.existsSync(s)&&n.push(s.replace(`${t.options.rootDir}/`,""));if(n.length>0){const s=Re(l=>f.relative(t.options.rootDir,f.resolve(t.options.outDir,l)),"rPath"),r=t.buildEntries.filter(l=>!l.chunk).map(l=>s(l.path));let i="Potential missing or wrong package.json files:";for(const l of n){const a=ss(l,r);i+=`
77
- - `+v.cyan(l)+(a.length>0?v.grey` (did you mean ${a.map(c=>`"${c}"`).join(", ")}?)`:"")}L(t,i)}},"validatePackage");var ls=Object.defineProperty,C=m((e,t)=>ls(e,"name",{value:t,configurable:!0}),"d");const cs=C(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"),ps=C((e,t,o,n,s,r,i,l,a,c)=>{const p=cs(c?.config.compilerOptions?.jsx),d=$t.defu(i,r,l,{alias:{},cjsInterop:!1,clean:!0,debug:s,declaration:void 0,emitCJS:void 0,emitESM:void 0,entries:[],externals:[...ve.builtinModules,...ve.builtinModules.map(u=>`node:${u}`)],failOnWarn:!0,fileCache:!0,minify:n===k.PRODUCTION_ENV,name:(a.name??"").split("/").pop()??"default",outDir:c?.config.compilerOptions?.outDir??"dist",replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{extensions:[".mjs",".js",".json",".node",".cjs"],ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:c?.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",include:/\.[jt]sx?$/,jsx:p,jsxDev:c?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:c?.config.compilerOptions?.jsxFactory,jsxFragment:c?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:c?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,sourcesContent:!1,target:c?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:c?.config},isolatedDeclarations:{exclude:k.EXCLUDE_REGEXP,ignoreErrors:!1,include:[/\.[cm]?ts$/]},json:{preferConst:!0},license:{dependenciesTemplate:C((u,g,y)=>`
76
+ `)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logBuildErrors");var Hr=Object.defineProperty,ft=m((e,t)=>Hr(e,"name",{value:t,configurable:!0}),"n");const Pe=ft(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(k.ENDING_RE,"")}if(!e.input)throw new Error(`Missing entry input: ${me(e)}`);Jt.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):(t.options.emitCJS!==void 0&&e.cjs===void 0&&(e.cjs=t.options.emitCJS),t.options.emitESM!==void 0&&e.esm===void 0&&(e.esm=t.options.emitESM)),e.outDir=f.resolve(t.options.rootDir,e.outDir??t.options.outDir)},"extendEntry"),Gr=ft(async e=>{e.options.entries=e.options.entries.map(t=>typeof t=="string"?{input:t,isGlob:be(t)}:{...t,isGlob:be(t.input)});for(const t of e.options.entries.filter(o=>o.isGlob)){const{isGlob:o,...n}=t,s=Me.globSync([n.input],{cwd:e.options.rootDir,dot:!1,ignore:["**/node_modules/**"],onlyFiles:!0});if(s.length===0)throw new Tt.NotFoundError("No files found in the glob pattern: "+v.cyan(f.join(e.options.rootDir,n.input)));for(const r of s)e.options.entries.push({...n,input:f.resolve(e.options.rootDir,r)});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 Pe(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 Pe(t,e)},"prepareEntries");var Xr=Object.defineProperty,Kr=m((e,t)=>Xr(e,"name",{value:t,configurable:!0}),"a$2");const Yr=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,Qr=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"]),Ce=Kr(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(Yr.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(Qr.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const n=f.resolve(o);if(!$.isAccessibleSync(n))throw new Error(`Target path "${n}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var Zr=Object.defineProperty,es=m((e,t)=>Zr(e,"name",{value:t,configurable:!0}),"o");const ts=es(e=>{const t=new Set,o=new Set(Object.keys(e.pkg?.dependencies??{})),n=new Set;for(const s of e.usedImports)o.delete(s),t.add(s);if(e.pkg?.dependencies)for(const s of Object.keys(e.pkg?.dependencies))o.delete(s);for(const s of t){const r=qe(s);!re(e.options.externals,s)&&!s.startsWith("chunks/")&&e.pkg?.dependencies?.[r]===void 0&&e.pkg?.peerDependencies?.[r]===void 0&&n.add(s)}o.size>0&&L(e,`Potential unused dependencies found: ${[...o].map(s=>v.cyan(s)).join(", ")}`),n.size>0&&L(e,`Potential implicit dependencies found: ${[...n].map(s=>v.cyan(s)).join(", ")}`)},"validateDependencies");var os=Object.defineProperty,gt=m((e,t)=>os(e,"name",{value:t,configurable:!0}),"i");const ns=gt((e,t)=>qt.distance(e,t)<=e.length/3||t.includes(e),"isSimilar"),rs=gt((e,t)=>{const o=e.toLowerCase();return t.filter(n=>ns(n.toLowerCase(),o))},"findAlternatives");var ss=Object.defineProperty,Ie=m((e,t)=>ss(e,"name",{value:t,configurable:!0}),"s");const is=Ie((e,t)=>{const o=new Set([...typeof e.bin=="string"?[e.bin]:Object.values(e.bin??{}),e.main,e.module,t.options.declaration?e.types:"",t.options.declaration?e.typings:"",...fe(e.exports,e.type==="module"?"esm":"cjs",t.options.declaration).map(s=>s.file)].map(s=>s&&f.resolve(t.options.rootDir,s.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const s of o)s&&!s.includes("*")&&!le.existsSync(s)&&n.push(s.replace(`${t.options.rootDir}/`,""));if(n.length>0){const s=Ie(l=>f.relative(t.options.rootDir,f.resolve(t.options.outDir,l)),"rPath"),r=t.buildEntries.filter(l=>!l.chunk).map(l=>s(l.path));let i="Potential missing or wrong package.json files:";for(const l of n){const a=rs(l,r);i+=`
77
+ - `+v.cyan(l)+(a.length>0?v.grey` (did you mean ${a.map(c=>`"${c}"`).join(", ")}?)`:"")}L(t,i)}},"validatePackage");var as=Object.defineProperty,C=m((e,t)=>as(e,"name",{value:t,configurable:!0}),"d");const ls=C(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"),cs=C((e,t,o,n,s,r,i,l,a,c)=>{const p=ls(c?.config.compilerOptions?.jsx),d=bt.defu(i,r,l,{alias:{},cjsInterop:!1,clean:!0,debug:s,declaration:void 0,emitCJS:void 0,emitESM:void 0,entries:[],externals:[...ve.builtinModules,...ve.builtinModules.map(u=>`node:${u}`)],failOnWarn:!0,fileCache:!0,minify:n===k.PRODUCTION_ENV,name:(a.name??"").split("/").pop()??"default",outDir:c?.config.compilerOptions?.outDir??"dist",replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{extensions:[".mjs",".js",".json",".node",".cjs"],ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:c?.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",include:/\.[jt]sx?$/,jsx:p,jsxDev:c?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:c?.config.compilerOptions?.jsxFactory,jsxFragment:c?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:c?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,sourcesContent:!1,target:c?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:c?.config},isolatedDeclarations:{exclude:k.EXCLUDE_REGEXP,ignoreErrors:!1,include:[/\.[cm]?ts$/]},json:{preferConst:!0},license:{dependenciesTemplate:C((u,g,y)=>`
78
78
  # Licenses of bundled dependencies
79
79
  The published ${y} artifact additionally contains code with the following licenses:
80
80
  `+(u.length>0?`${u.join(", ")}
@@ -88,9 +88,9 @@ The published ${y} artifact additionally contains code with the following licens
88
88
 
89
89
  `:`
90
90
  `)+`# Bundled types:
91
- `+g,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDirectives:{exclude:k.EXCLUDE_REGEXP,include:[/\.(?:m|c)?(?:j|t)sx?$/]},preserveDynamicImports:!0,raw:{exclude:k.EXCLUDE_REGEXP,include:[/\.(md|txt|css|htm|html|data)$/]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,extensions:k.DEFAULT_EXTENSIONS,preferBuiltins:!1},shim:{exclude:[/node_modules/],include:[/\.(js|cjs|mjs|tsx|mts|cts)$/]},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:c?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:n===k.PRODUCTION_ENV,...c?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(c.config.compilerOptions.jsx)?{jsxFragmentPragma:c.config.compilerOptions.jsxFragmentFactory,jsxImportSource:c.config.compilerOptions.jsxImportSource,jsxPragma:c.config.compilerOptions.jsxFactory,jsxRuntime:p,transforms:["typescript","jsx",...c.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...c?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:/\.[jt]sx?$/,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:c?.config.compilerOptions?.experimentalDecorators,syntax:c?"typescript":"ecmascript",[c?"tsx":"jsx"]:!0},target:c?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:c?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:c?.config.compilerOptions?.experimentalDecorators,react:{development:n!==k.PRODUCTION_ENV,pragma:c?.config.compilerOptions?.jsxFactory,pragmaFrag:c?.config.compilerOptions?.jsxFragmentFactory,runtime:p,throwIfNamespace:!0},treatConstEnumAsEnum:c?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:c?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"},transform:{decoratorVersion:"2022-03"}},treeshake:{moduleSideEffects:Vr(t,a),preset:"recommended",propertyReadSideEffects:!0},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:k.EXCLUDE_REGEXP}},rootDir:t,sourceDir:"src",sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!d.transformerName){const u=new Map([...Object.entries(a.dependencies??{}),...Object.entries(a.devDependencies??{})]);let g="0.0.0";if(u.has("esbuild"))d.transformerName="esbuild",g=u.get("esbuild");else if(u.has("@swc/core"))d.transformerName="swc",g=u.get("@swc/core");else if(u.has("sucrase"))d.transformerName="sucrase",g=u.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 "+v.cyan("rollup ")+J.VERSION),e.info({message:"Using "+v.cyan(d.transformerName)+" "+g,prefix:"transformer"})}return d.rollup.resolve&&d.rollup.resolve.preferBuiltins===!0&&(d.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),a.dependencies&&d.externals.push(...Object.keys(a.dependencies)),a.peerDependencies&&d.externals.push(...Object.keys(a.peerDependencies)),a.optionalDependencies&&d.externals.push(...Object.keys(a.optionalDependencies)),Ie(d.alias),d.rollup.alias&&d.rollup.alias.entries&&Ie(d.rollup.alias.entries),d},"generateOptions"),us=C(async(e,t,o,n,s,r,i,l,a)=>{const c=Nr(i.preset??r.preset??"auto",t),p=ps(e,t,o,n,s,r,i,c,l,a);$.ensureDirSync(f.join(p.rootDir,p.outDir));const d={buildEntries:[],dependencyGraphMap:new Map,environment:n,hooks:jt.createHooks(),logger:e,mode:o,options:p,pkg:l,tsconfig:a,usedImports:new Set,warnings:new Set};return c.hooks&&d.hooks.addHooks(c.hooks),r.hooks&&d.hooks.addHooks(r.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},"createContext"),ds=C(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 $.emptyDir(o))},"cleanDistributionDirectories"),ms=C(async(e,t,o,n,s={})=>{const{configPath:r,debug:i,tsconfigPath:l,...a}=s;n.wrapAll(),e=f.resolve(ie.cwd(),e),n.debug("Root directory:",e);const c=f.join(e,"package.json");if(!$.isAccessibleSync(c))throw new Error("package.json not found at "+c);const p=bt.parsePackageJson(c);n.debug("Using package.json found at",c);let d;if(l){const u=f.join(e,l);if(!await $.isAccessible(u))throw new Error("tsconfig.json not found at "+u);d={config:he.readTsConfig(u),path:u},n.info("Using tsconfig settings at",u)}else if(p.dependencies?.typescript||p.devDependencies?.typescript)try{d=await he.findTsConfig(e),n.debug("Using tsconfig settings found at",d.path)}catch{n.info("No tsconfig.json or jsconfig.json found.")}try{let u=r??"";if(!u){const N=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const M of N)if($.isAccessibleSync(f.join(e,M))){u="./"+M;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(u))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");let g=pt(u,e);typeof g=="function"&&(g=g(o,t)),n.debug("Using packem config found at",f.join(e,u));const y=Date.now(),h=C(()=>_.duration(Math.floor(Date.now()-y)),"getDuration"),w=R(JSON.stringify({version:p.version,...p.dependencies,...p.devDependencies,...p.peerDependencies,...p.peerDependenciesMeta,browser:p.browser,eNode:p.engines?.node,exports:p.exports,main:p.main,module:p.module,type:p.type,types:p.types})),j=new Br(e,w,n);j.cachePath&&!$.isAccessibleSync(f.join(j.cachePath,w))&&$.isAccessibleSync(j.cachePath)&&(n.info("Clearing file cache because the cache key has changed."),await $.emptyDir(j.cachePath));const b=await us(n,e,t,o,i??!1,a,g,p,d);if(j.isEnabled=b.options.fileCache,await Xr(b),b.logger.info(v.cyan((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+b.options.name)),b.logger.debug(`${v.bold("Root dir:")} ${b.options.rootDir}
91
+ `+g,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDirectives:{exclude:k.EXCLUDE_REGEXP,include:[/\.(?:m|c)?(?:j|t)sx?$/]},preserveDynamicImports:!0,raw:{exclude:k.EXCLUDE_REGEXP,include:[/\.(md|txt|css|htm|html|data)$/]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,extensions:k.DEFAULT_EXTENSIONS,preferBuiltins:!1},shim:{exclude:[/node_modules/],include:[/\.(js|cjs|mjs|tsx|mts|cts)$/]},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:c?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:n===k.PRODUCTION_ENV,...c?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(c.config.compilerOptions.jsx)?{jsxFragmentPragma:c.config.compilerOptions.jsxFragmentFactory,jsxImportSource:c.config.compilerOptions.jsxImportSource,jsxPragma:c.config.compilerOptions.jsxFactory,jsxRuntime:p,transforms:["typescript","jsx",...c.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...c?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:/\.[jt]sx?$/,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:c?.config.compilerOptions?.experimentalDecorators,syntax:c?"typescript":"ecmascript",[c?"tsx":"jsx"]:!0},target:c?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:c?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:c?.config.compilerOptions?.experimentalDecorators,react:{development:n!==k.PRODUCTION_ENV,pragma:c?.config.compilerOptions?.jsxFactory,pragmaFrag:c?.config.compilerOptions?.jsxFragmentFactory,runtime:p,throwIfNamespace:!0},treatConstEnumAsEnum:c?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:c?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"},transform:{decoratorVersion:"2022-03"}},treeshake:{moduleSideEffects:Ur(t,a),preset:"recommended",propertyReadSideEffects:!0},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:k.EXCLUDE_REGEXP}},rootDir:t,sourceDir:"src",sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!d.transformerName){const u=new Map([...Object.entries(a.dependencies??{}),...Object.entries(a.devDependencies??{})]);let g="0.0.0";if(u.has("esbuild"))d.transformerName="esbuild",g=u.get("esbuild");else if(u.has("@swc/core"))d.transformerName="swc",g=u.get("@swc/core");else if(u.has("sucrase"))d.transformerName="sucrase",g=u.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 "+v.cyan("rollup ")+J.VERSION),e.info({message:"Using "+v.cyan(d.transformerName)+" "+g,prefix:"transformer"})}return d.rollup.resolve&&d.rollup.resolve.preferBuiltins===!0&&(d.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),a.dependencies&&d.externals.push(...Object.keys(a.dependencies)),a.peerDependencies&&d.externals.push(...Object.keys(a.peerDependencies)),a.optionalDependencies&&d.externals.push(...Object.keys(a.optionalDependencies)),Ce(d.alias),d.rollup.alias&&d.rollup.alias.entries&&Ce(d.rollup.alias.entries),d},"generateOptions"),ps=C(async(e,t,o,n,s,r,i,l,a)=>{const c=Or(i.preset??r.preset??"auto",t),p=cs(e,t,o,n,s,r,i,c,l,a);$.ensureDirSync(f.join(p.rootDir,p.outDir));const d={buildEntries:[],dependencyGraphMap:new Map,environment:n,hooks:$t.createHooks(),logger:e,mode:o,options:p,pkg:l,tsconfig:a,usedImports:new Set,warnings:new Set};return c.hooks&&d.hooks.addHooks(c.hooks),r.hooks&&d.hooks.addHooks(r.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},"createContext"),us=C(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 $.emptyDir(o))},"cleanDistributionDirectories"),ds=C(async(e,t,o,n,s={})=>{const{configPath:r,debug:i,tsconfigPath:l,...a}=s;n.wrapAll(),e=f.resolve(ie.cwd(),e),n.debug("Root directory:",e);const c=f.join(e,"package.json");if(!$.isAccessibleSync(c))throw new Error("package.json not found at "+c);const p=vt.parsePackageJson(c);n.debug("Using package.json found at",c);let d;if(l){const u=f.join(e,l);if(!await $.isAccessible(u))throw new Error("tsconfig.json not found at "+u);d={config:he.readTsConfig(u),path:u},n.info("Using tsconfig settings at",u)}else if(p.dependencies?.typescript||p.devDependencies?.typescript)try{d=await he.findTsConfig(e),n.debug("Using tsconfig settings found at",d.path)}catch{n.info("No tsconfig.json or jsconfig.json found.")}try{let u=r??"";if(!u){const N=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const M of N)if($.isAccessibleSync(f.join(e,M))){u="./"+M;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(u))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");let g=ct(u,e);typeof g=="function"&&(g=g(o,t)),n.debug("Using packem config found at",f.join(e,u));const y=Date.now(),h=C(()=>_.duration(Math.floor(Date.now()-y)),"getDuration"),w=R(JSON.stringify({version:p.version,...p.dependencies,...p.devDependencies,...p.peerDependencies,...p.peerDependenciesMeta,browser:p.browser,eNode:p.engines?.node,exports:p.exports,main:p.main,module:p.module,type:p.type,types:p.types})),j=new qr(e,w,n);j.cachePath&&!$.isAccessibleSync(f.join(j.cachePath,w))&&$.isAccessibleSync(j.cachePath)&&(n.info("Clearing file cache because the cache key has changed."),await $.emptyDir(j.cachePath));const b=await ps(n,e,t,o,i??!1,a,g,p,d);if(j.isEnabled=b.options.fileCache,await Gr(b),b.logger.info(v.cyan((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+b.options.name)),b.logger.debug(`${v.bold("Root dir:")} ${b.options.rootDir}
92
92
  ${v.bold("Entries:")}
93
93
  ${b.options.entries.map(N=>` ${me(N)}`).join(`
94
- `)}`),await ds(b),b.options.stub){await Rr(b),await b.hooks.callHook("build:done",b);return}if(t==="watch"){if(b.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await Jr(b,j),Pe(b,!1);return}const S=await ir(b,p,j);await b.hooks.callHook("validate:before",b),os(b),as(p,b),await b.hooks.callHook("validate:done",b),Pe(b,S),n.raw(`
94
+ `)}`),await us(b),b.options.stub){await Ir(b),await b.hooks.callHook("build:done",b);return}if(t==="watch"){if(b.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await Tr(b,j),_e(b,!1);return}const S=await sr(b,p,j);await b.hooks.callHook("validate:before",b),ts(b),is(p,b),await b.hooks.callHook("validate:done",b),_e(b,S),n.raw(`
95
95
  ⚡️ Build run in `+h()),n.restoreAll()}catch(u){throw n.raw(`
96
- `),mt(u),u}},"createBundler");module.exports=ms;
96
+ `),dt(u),u}},"createBundler");module.exports=ds;