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

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