@visulima/packem 1.0.0-alpha.85 → 1.0.0-alpha.86

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