@visulima/packem 1.0.3 → 1.0.5

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.
package/dist/cli.mjs CHANGED
@@ -1,27 +1,27 @@
1
1
  #!/usr/bin/env node
2
- var ro=Object.defineProperty;var m=(e,t)=>ro(e,"name",{value:t,configurable:!0});import no from"@visulima/cerebro";import{SimpleReporter as io}from"@visulima/pail/reporter";import{env as ae,versions as so,cwd as ao,exit as lo}from"node:process";import{readdirSync as Ne,existsSync as ut}from"node:fs";import{stat as dt,chmod as co,rm as po}from"node:fs/promises";import Je from"node:module";import{cyan as k,bold as N,gray as I,green as uo,yellow as mo,grey as fo}from"@visulima/colorize";import{findCacheDirSync as go}from"@visulima/find-cache-dir";import{readFile as mt,readFileSync as Y,writeFileSync as A,writeJsonSync as ge,readJsonSync as Pe,walk as yo,isAccessibleSync as S,collectSync as ho,ensureDirSync as vo,emptyDir as bo,isAccessible as wo}from"@visulima/fs";import{formatBytes as T,duration as $o}from"@visulima/humanizer";import{normalize as Ce,join as b,relative as O,dirname as z,basename as ye,toNamespacedPath as le,resolve as $,extname as ft,isAbsolute as gt}from"@visulima/path";import{readTsConfig as jo,findTsConfig as ko}from"@visulima/tsconfig";import{defu as xo}from"defu";import{createHooks as Eo}from"hookable";import{createJiti as yt}from"jiti";import{rollup as ht,watch as Be,VERSION as Do}from"rollup";import vt from"@rollup/plugin-alias";import So from"@rollup/plugin-commonjs";import Oo from"@rollup/plugin-dynamic-import-vars";import{nodeResolve as bt}from"@rollup/plugin-node-resolve";import wt from"@rollup/plugin-replace";import{wasm as No}from"@rollup/plugin-wasm";import Po from"rollup-plugin-polyfill-node";import{visualizer as Co}from"rollup-plugin-visualizer";import{minVersion as $t,valid as _o,coerce as To}from"semver";import ce from"node:assert/strict";import{extractAssignedNames as Io,createFilter as U,normalizePath as Le}from"@rollup/pluginutils";import F from"magic-string";import Mo from"glob-parent";import{glob as Ao,globSync as Ro}from"tinyglobby";import{findStaticImports as jt,resolveModuleExportNames as Fo,resolvePath as We}from"mlly";import{parseAsync as Jo}from"oxc-parser";import Bo from"@rollup/plugin-json";import Lo from"rollup-plugin-license";import{createHash as Wo}from"node:crypto";import{fileURLToPath as Vo}from"node:url";import{parse as zo}from"@babel/parser";import{Application as Uo}from"typedoc";import{parsePackageJson as kt}from"@visulima/package/package-json";import{NotFoundError as qo}from"@visulima/fs/error";import{isRelative as Ko}from"@visulima/path/utils";import Ve from"is-glob";import{distance as Ho}from"fastest-levenshtein";import{installPackage as we}from"@antfu/install-pkg";import{intro as Go,confirm as W,spinner as K,log as ze,select as Ue,cancel as Xo,outro as Yo}from"@clack/prompts";import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
2
+ var ro=Object.defineProperty;var m=(e,t)=>ro(e,"name",{value:t,configurable:!0});import no from"@visulima/cerebro";import{SimpleReporter as io}from"@visulima/pail/reporter";import{env as ae,versions as so,cwd as ao,exit as lo}from"node:process";import{readdirSync as Ne,existsSync as pt}from"node:fs";import{stat as ut,chmod as co,rm as po}from"node:fs/promises";import Fe from"node:module";import{cyan as k,bold as N,gray as I,green as uo,yellow as mo,grey as fo}from"@visulima/colorize";import{findCacheDirSync as go}from"@visulima/find-cache-dir";import{readFile as dt,readFileSync as Y,writeFileSync as A,writeJsonSync as ge,readJsonSync as Pe,walk as yo,isAccessibleSync as S,collectSync as ho,ensureDirSync as vo,emptyDir as bo,isAccessible as wo}from"@visulima/fs";import{formatBytes as T,duration as $o}from"@visulima/humanizer";import{normalize as mt,join as b,relative as O,dirname as z,basename as ye,toNamespacedPath as le,resolve as $,extname as ft,isAbsolute as gt}from"@visulima/path";import{readTsConfig as jo,findTsConfig as ko}from"@visulima/tsconfig";import{defu as xo}from"defu";import{createHooks as Eo}from"hookable";import{createJiti as yt}from"jiti";import{rollup as ht,watch as Je,VERSION as Do}from"rollup";import vt from"@rollup/plugin-alias";import So from"@rollup/plugin-commonjs";import Oo from"@rollup/plugin-dynamic-import-vars";import{nodeResolve as bt}from"@rollup/plugin-node-resolve";import wt from"@rollup/plugin-replace";import{wasm as No}from"@rollup/plugin-wasm";import Po from"rollup-plugin-polyfill-node";import{visualizer as Co}from"rollup-plugin-visualizer";import{minVersion as $t,valid as _o,coerce as To}from"semver";import ce from"node:assert/strict";import{extractAssignedNames as Io,createFilter as U,normalizePath as Be}from"@rollup/pluginutils";import F from"magic-string";import Mo from"glob-parent";import{glob as Ao,globSync as Ro}from"tinyglobby";import{findStaticImports as jt,fileURLToPath as Fo,resolveModuleExportNames as Jo,resolvePath as Le}from"mlly";import{parseAsync as Bo}from"oxc-parser";import Lo from"@rollup/plugin-json";import Wo from"rollup-plugin-license";import{createHash as Vo}from"node:crypto";import{fileURLToPath as zo}from"node:url";import{parse as Uo}from"@babel/parser";import{Application as qo}from"typedoc";import{parsePackageJson as kt}from"@visulima/package/package-json";import{NotFoundError as Ko}from"@visulima/fs/error";import{isRelative as Ho}from"@visulima/path/utils";import We from"is-glob";import{distance as Go}from"fastest-levenshtein";import{installPackage as we}from"@antfu/install-pkg";import{intro as Xo,confirm as W,spinner as K,log as Ve,select as ze,cancel as Yo,outro as Qo}from"@clack/prompts";import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
3
3
  import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
4
4
  import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
5
5
  const __filename = __cjs_url__.fileURLToPath(import.meta.url);
6
6
  const __dirname = __cjs_path__.dirname(__filename);
7
7
  const require = __cjs_mod__.createRequire(import.meta.url);
8
- const Qo="@visulima/packem",Zo="1.0.2",_e=[".mjs",".js",".json",".node",".cjs",".ts",".cts",".mts",".tsx",".jsx"],C="production",Q="development",Te=new Set(["react-server","react-native","edge-light"]),pe=new Set([Q,C,...Te]),V=/node_modules/,J=/(?:\.d\.[mc]?tsx?|\.\w+)$/,er="packem_chunks",tr="packem_shared",H=/\.(?:m|c)?(?:j|t)sx?$/;var or=Object.defineProperty,rr=m((e,t)=>or(e,"name",{value:t,configurable:!0}),"a$g");const De=rr((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var nr=Object.defineProperty,ir=m((e,t)=>nr(e,"name",{value:t,configurable:!0}),"a$f");const X=ir(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var sr=Object.defineProperty,ar=m((e,t)=>sr(e,"name",{value:t,configurable:!0}),"a$e");const xt=ar((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var lr=Object.defineProperty,Et=m((e,t)=>lr(e,"name",{value:t,configurable:!0}),"s$g");const cr=Et((e,t,o)=>{const r=o??new Map;return(...n)=>{const i=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),s=r.get(i);if(s!==void 0)return s;const a=e(...n);return r.set(i,a),a}},"memoize"),pr=Et(e=>{const t=new Map;return o=>cr(e,o,t)},"memoizeByKey");var ur=Object.defineProperty,Z=m((e,t)=>ur(e,"name",{value:t,configurable:!0}),"r$f");const dr=Z(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;ce(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 Io(t.id))yield o;break}}},"exportName"),mr=Z(function*(e){if(e.declaration)for(const t of dr(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"),fr=Z(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),gr=Z(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),yr=Z(function*(e,t){ce(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*fr(r);break}case"ExportDefaultDeclaration":{yield*gr();break}case"ExportNamedDeclaration":{yield*mr(r);break}}},"parseExports");var hr=Object.defineProperty,ee=m((e,t)=>hr(e,"name",{value:t,configurable:!0}),"n$9");const Dt=ee(async function(e,t,o){const r=await e.resolve(t,o.id);if(ce(r,`Rollup can't resolve ${t} from ${o.id}`),r.external)return null;const n=await e.load(r);return ce(n,`Rollup doesn't have a module for id ${r.id}`),n},"getImportedModule"),vr=ee(async function*(e,t,o){const r=await Dt(e,t.source,o);r&&(yield*Ie(e,r))},"gatherBarrelReExports"),br=ee(async function*(e,t,o){const r=await Dt(e,t.source,o);if(!r)return;const n=new Map(t.bindings.map(i=>[i.importedName,i]));for await(const i of Ie(e,r)){const s=n.get(i.exportedName);s&&(yield{...i,exportedName:s.exportedName})}},"gatherNamedReExports"),wr=ee(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),Ie=ee(async function*(e,t){for(const o of yr(e,t))o.from==="self"?yield*wr(t,o):o.type==="barrel"?yield*vr(e,o,t):yield*br(e,o,t)},"gatherExports");var $r=Object.defineProperty,jr=m((e,t)=>$r(e,"name",{value:t,configurable:!0}),"r$e");const kr=jr(()=>({moduleParsed:{async handler(e){if(e.isEntry)for await(const t of Ie(this,e))t.id!==e.id&&this.emitFile({id:t.id,name:t.exportedName,preserveSignature:"exports-only",type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");var xr=Object.defineProperty,Er=m((e,t)=>xr(e,"name",{value:t,configurable:!0}),"r$d");const Dr=Er((e,t)=>{const o=e,r=[];let n;for(;(n=o.exec(t))!==null;)n.index===o.lastIndex&&o.lastIndex++,n.forEach(i=>{r.push(i)});return r.filter(Boolean)},"getRegexMatches");var Sr=Object.defineProperty,Or=m((e,t)=>Sr(e,"name",{value:t,configurable:!0}),"a$d");const St=Or(e=>{const t=Dr(/export\s(\{\s(.*)\s\}|default\s.*);/g,e);if(t.length===0)return null;const o=t.at(-1).split(", ");let r="";for(const n of o)if(!n.includes("type")&&(n.includes("default ")&&(r=n.split("default ")[1]),n.includes("as"))){const[i,s]=n.split(" as ");s==="default"&&(r=i)}if(r!==""){const n=new F(e);return n.replace(new RegExp(`(,s)?${r} as default(,)?`),""),n.replace(new RegExp(`export default ${r};
8
+ const Zo="@visulima/packem",er="1.0.4",Ce=[".mjs",".js",".json",".node",".cjs",".ts",".cts",".mts",".tsx",".jsx"],C="production",Q="development",_e=new Set(["react-server","react-native","edge-light"]),pe=new Set([Q,C,..._e]),V=/node_modules/,J=/(?:\.d\.[mc]?tsx?|\.\w+)$/,tr="packem_chunks",or="packem_shared",H=/\.(?:m|c)?(?:j|t)sx?$/;var rr=Object.defineProperty,nr=m((e,t)=>rr(e,"name",{value:t,configurable:!0}),"a$g");const De=nr((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var ir=Object.defineProperty,sr=m((e,t)=>ir(e,"name",{value:t,configurable:!0}),"a$f");const X=sr(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var ar=Object.defineProperty,lr=m((e,t)=>ar(e,"name",{value:t,configurable:!0}),"a$e");const xt=lr((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var cr=Object.defineProperty,Et=m((e,t)=>cr(e,"name",{value:t,configurable:!0}),"s$g");const pr=Et((e,t,o)=>{const r=o??new Map;return(...n)=>{const i=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),s=r.get(i);if(s!==void 0)return s;const a=e(...n);return r.set(i,a),a}},"memoize"),ur=Et(e=>{const t=new Map;return o=>pr(e,o,t)},"memoizeByKey");var dr=Object.defineProperty,Z=m((e,t)=>dr(e,"name",{value:t,configurable:!0}),"r$f");const mr=Z(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;ce(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 Io(t.id))yield o;break}}},"exportName"),fr=Z(function*(e){if(e.declaration)for(const t of mr(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"),gr=Z(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),yr=Z(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),hr=Z(function*(e,t){ce(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*gr(r);break}case"ExportDefaultDeclaration":{yield*yr();break}case"ExportNamedDeclaration":{yield*fr(r);break}}},"parseExports");var vr=Object.defineProperty,ee=m((e,t)=>vr(e,"name",{value:t,configurable:!0}),"n$9");const Dt=ee(async function(e,t,o){const r=await e.resolve(t,o.id);if(ce(r,`Rollup can't resolve ${t} from ${o.id}`),r.external)return null;const n=await e.load(r);return ce(n,`Rollup doesn't have a module for id ${r.id}`),n},"getImportedModule"),br=ee(async function*(e,t,o){const r=await Dt(e,t.source,o);r&&(yield*Te(e,r))},"gatherBarrelReExports"),wr=ee(async function*(e,t,o){const r=await Dt(e,t.source,o);if(!r)return;const n=new Map(t.bindings.map(i=>[i.importedName,i]));for await(const i of Te(e,r)){const s=n.get(i.exportedName);s&&(yield{...i,exportedName:s.exportedName})}},"gatherNamedReExports"),$r=ee(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),Te=ee(async function*(e,t){for(const o of hr(e,t))o.from==="self"?yield*$r(t,o):o.type==="barrel"?yield*br(e,o,t):yield*wr(e,o,t)},"gatherExports");var jr=Object.defineProperty,kr=m((e,t)=>jr(e,"name",{value:t,configurable:!0}),"r$e");const xr=kr(()=>({moduleParsed:{async handler(e){if(e.isEntry)for await(const t of Te(this,e))t.id!==e.id&&this.emitFile({id:t.id,name:t.exportedName,preserveSignature:"exports-only",type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");var Er=Object.defineProperty,Dr=m((e,t)=>Er(e,"name",{value:t,configurable:!0}),"r$d");const Sr=Dr((e,t)=>{const o=e,r=[];let n;for(;(n=o.exec(t))!==null;)n.index===o.lastIndex&&o.lastIndex++,n.forEach(i=>{r.push(i)});return r.filter(Boolean)},"getRegexMatches");var Or=Object.defineProperty,Nr=m((e,t)=>Or(e,"name",{value:t,configurable:!0}),"a$d");const St=Nr(e=>{const t=Sr(/export\s(\{\s(.*)\s\}|default\s.*);/g,e);if(t.length===0)return null;const o=t.at(-1).split(", ");let r="";for(const n of o)if(!n.includes("type")&&(n.includes("default ")&&(r=n.split("default ")[1]),n.includes("as"))){const[i,s]=n.split(" as ");s==="default"&&(r=i)}if(r!==""){const n=new F(e);return n.replace(new RegExp(`(,s)?${r} as default(,)?`),""),n.replace(new RegExp(`export default ${r};
9
9
  ?`),""),n.append(`
10
10
 
11
- export = `+r+";"),{code:n.toString().replace(/export\s\{\s\s\};/,""),map:n.generateMap({hires:!0})}}return null},"patchCjsDefaultExport");var Nr=Object.defineProperty,qe=m((e,t)=>Nr(e,"name",{value:t,configurable:!0}),"i$b");const Ot=qe(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk:qe(async(r,n,i)=>{if(n.type!=="chunk"||!n.isEntry)return null;if(i.format==="cjs"&&i.exports==="auto"){const s=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(s===null||s.length<3)return null;const a=new F(r);a.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&a.append(`
12
- module.exports.default = `+s[2]+";");let l=a.toString();return l=l.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:l,map:a.generateMap({hires:!0})}}return i.format==="es"&&/\.d\.(?:ts|cts)$/.test(n.fileName)?o!=="commonjs"&&n.fileName.endsWith(".d.mts")?null:St(r):null},"renderChunk")}),"cjsInteropPlugin");var Pr=Object.defineProperty,Cr=m((e,t)=>Pr(e,"name",{value:t,configurable:!0}),"f$9");const _r=Cr((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(i=>{if(typeof i=="string")return{src:i};if(typeof i=="object"&&"src"in i)return i}).filter(Boolean):typeof n=="string"&&(n=[{src:n}]),{async buildStart(){const i=await Promise.all(n.flatMap(s=>Array.isArray(s.src)?s.src.map(a=>({...s,src:a})):s).map(async s=>await Ao(X(s.src),{ignore:X(s.exclude).filter(Boolean)}).then(a=>({dest:s.dest??"",parent:Mo(s.src),src:a}))));for(const s of i)for(const a of s.src){let l;o.has(a)?l=o.get(a):(l={copied:[],dest:[],timestamp:0},o.set(a,l));const c=r.flatten?Ce(s.dest):b(s.dest,O(s.parent,z(a)));l.dest.includes(c)||l.dest.push(c),this.addWatchFile(a)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([s,a])=>{let l;try{const c=await dt(s);if(!c.isFile())return;const d=c.mtime.getTime();d>a.timestamp&&(a.timestamp=d,a.copied=[]),l=await mt(s,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${s}`,prefix:"plugin:copy"});return}for(const c of a.dest){if(r.copyOnce&&a.copied.includes(c))continue;const d=ye(s),p=b(c,d);try{this.emitFile({[r.exactFileNames?"fileName":"name"]:p,source:l,type:"asset"}),t.debug({message:`copied ${s} → ${p}`,prefix:"plugin:copy"}),a.copied.push(c)}catch(u){t.error({context:[u],message:`error copying file ${s} → ${p}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Tr=Object.defineProperty,he=m((e,t)=>Tr(e,"name",{value:t,configurable:!0}),"t$a");const Ir=/\Wrequire(?:\.resolve)?\(/,Mr=he((e,t)=>{if(ae.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),Ir.test(e)&&(n=!0),!o&&!r&&!n)return null;const i=jt(e).pop(),s=i?i.end:0,a=new F(e);return a.appendRight(s,t(o,r,n)),{code:a.toString(),map:a.generateMap()}},"CJSToESM"),Ar=he((e,t,o)=>{let r="";return(e||t)&&(r+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
11
+ export = `+r+";"),{code:n.toString().replace(/export\s\{\s\s\};/,""),map:n.generateMap({hires:!0})}}return null},"patchCjsDefaultExport");var Pr=Object.defineProperty,Ue=m((e,t)=>Pr(e,"name",{value:t,configurable:!0}),"i$b");const Ot=Ue(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk:Ue(async(r,n,i)=>{if(n.type!=="chunk"||!n.isEntry)return null;if(i.format==="cjs"&&i.exports==="auto"){const s=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(s===null||s.length<3)return null;const a=new F(r);a.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&a.append(`
12
+ module.exports.default = `+s[2]+";");let l=a.toString();return l=l.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:l,map:a.generateMap({hires:!0})}}return i.format==="es"&&/\.d\.(?:ts|cts)$/.test(n.fileName)?o!=="commonjs"&&n.fileName.endsWith(".d.mts")?null:St(r):null},"renderChunk")}),"cjsInteropPlugin");var Cr=Object.defineProperty,_r=m((e,t)=>Cr(e,"name",{value:t,configurable:!0}),"f$9");const Tr=_r((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(i=>{if(typeof i=="string")return{src:i};if(typeof i=="object"&&"src"in i)return i}).filter(Boolean):typeof n=="string"&&(n=[{src:n}]),{async buildStart(){const i=await Promise.all(n.flatMap(s=>Array.isArray(s.src)?s.src.map(a=>({...s,src:a})):s).map(async s=>await Ao(X(s.src),{ignore:X(s.exclude).filter(Boolean)}).then(a=>({dest:s.dest??"",parent:Mo(s.src),src:a}))));for(const s of i)for(const a of s.src){let l;o.has(a)?l=o.get(a):(l={copied:[],dest:[],timestamp:0},o.set(a,l));const c=r.flatten?mt(s.dest):b(s.dest,O(s.parent,z(a)));l.dest.includes(c)||l.dest.push(c),this.addWatchFile(a)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([s,a])=>{let l;try{const c=await ut(s);if(!c.isFile())return;const d=c.mtime.getTime();d>a.timestamp&&(a.timestamp=d,a.copied=[]),l=await dt(s,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${s}`,prefix:"plugin:copy"});return}for(const c of a.dest){if(r.copyOnce&&a.copied.includes(c))continue;const d=ye(s),p=b(c,d);try{this.emitFile({[r.exactFileNames?"fileName":"name"]:p,source:l,type:"asset"}),t.debug({message:`copied ${s} → ${p}`,prefix:"plugin:copy"}),a.copied.push(c)}catch(u){t.error({context:[u],message:`error copying file ${s} → ${p}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Ir=Object.defineProperty,he=m((e,t)=>Ir(e,"name",{value:t,configurable:!0}),"t$a");const Mr=/\Wrequire(?:\.resolve)?\(/,Ar=he((e,t)=>{if(ae.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),Mr.test(e)&&(n=!0),!o&&!r&&!n)return null;const i=jt(e).pop(),s=i?i.end:0,a=new F(e);return a.appendRight(s,t(o,r,n)),{code:a.toString(),map:a.generateMap()}},"CJSToESM"),Rr=he((e,t,o)=>{let r="";return(e||t)&&(r+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
13
13
  `),t&&(r+=`import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
14
14
  `),o&&(r+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
15
15
  `),(e||t)&&(r+=`const __filename = __cjs_url__.fileURLToPath(import.meta.url);
16
16
  `),t&&(r+=`const __dirname = __cjs_path__.dirname(__filename);
17
17
  `),o&&(r+=`const require = __cjs_mod__.createRequire(import.meta.url);
18
- `),r},"generateCJSShim"),Rr=he((e,t,o)=>{let r="";return o&&(r+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
18
+ `),r},"generateCJSShim"),Fr=he((e,t,o)=>{let r="";return o&&(r+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
19
19
  `),e&&(r+=`const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
20
20
  `),t&&(r+=`const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
21
21
  `),o&&(r+=`const require = __cjs_mod__.createRequire(import.meta.url);
22
- `),r},"generateCJSShimNode20_11"),Fr=he((e,t)=>{const o=U(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(r,n,i){if(i.format==="es"&&o(n.fileName)){let s=Ar;if(e.engines?.node){const a=$t(e.engines.node);a&&a.major>=20&&a.minor>=11&&(s=Rr)}return Mr(r,s)}return null}}},"esmShimCjsSyntaxPlugin");var Jr=Object.defineProperty,Br=m((e,t)=>Jr(e,"name",{value:t,configurable:!0}),"m$c");const Lr=Br(()=>({name:"packem:fix-dynamic-import-extension",renderChunk(e,t,o){return o.format==="es"||o.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(o.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var Wr=Object.defineProperty,Vr=m((e,t)=>Wr(e,"name",{value:t,configurable:!0}),"a$c");const zr=Vr((e,t)=>{const o=e.replace(/^\.\//,""),r=t.replace(/^\.\//,"");if(r.startsWith(o))return e+r.slice(o.length);if(e.endsWith(t))return e;const n=e.split("/"),i=t.split("/");let s=n.length-1,a=i.length-1;for(;s>=0&&a>=0&&n[s]===i[a];)s--,a--;const l=n.slice(0,s).join("/"),c=i.slice(a).join("/");return l+(c?"/"+c:"")},"extendString");var Ur=Object.defineProperty,qr=m((e,t)=>Ur(e,"name",{value:t,configurable:!0}),"s$d");const Kr=qr((...e)=>{if(e.length===0)return"";if(e.length===1)return z(e[0]);e=e.map(n=>le(n));const[t,...o]=e;let r=t.split("/");for(const n of o){const i=n.split("/",r.length);let s=0;for(const a of i)if(a===r[s])s+=1;else{r=r.slice(0,s);break}r=r.slice(0,s)}return r.length<=1&&r[0]===""?`/${r[0]}`:r.join("/")},"lowestCommonAncestor");var Hr=Object.defineProperty,$e=m((e,t)=>Hr(e,"name",{value:t,configurable:!0}),"m$a");const Gr=$e((e,t,o,r,n={})=>{const i=U(n.include,n.exclude),s={},a=$e((c,d)=>{s[c.replace(J,"")]=d},"addOutput");async function l(c,d){if(!i(d))return;let p;try{const f=await Jo(c,{sourceFilename:d});p=JSON.parse(f.program)}catch{}if(p){const f=p.body.filter(h=>h.type==="ImportDeclaration"||h.type==="ExportAllDeclaration"||h.type==="ExportNamedDeclaration");for(const h of f){if(!h.source||ye(h.source.value).includes("."))continue;const w=await this.resolve(h.source.value,d);if(!(!w||w.external)&&(w.id.endsWith(".ts")||w.id.endsWith(".cts")||w.id.endsWith(".mts")||w.id.endsWith(".tsx"))){const x=w.id.replace(e+"/","");c=c.replaceAll('from "'+h.source.value+'"','from "'+zr(h.source.value,x)+'"')}}}const{errors:u,sourceText:g}=await t(d,c);if(u.length>0){if(n.ignoreErrors){this.warn(u[0]);return}return this.error(u[0])}if(a(d,g),!p)return;const y=p.body.filter(f=>f.type==="ImportDeclaration"?f.importKind==="type"?!0:f.specifiers?.every(h=>h.type==="ImportSpecifier"&&h.importKind==="type"):f.type==="ExportNamedDeclaration"||f.type==="ExportAllDeclaration"?f.exportKind==="type"?!0:f.type==="ExportNamedDeclaration"&&f.specifiers?.every(h=>h.type==="ExportSpecifier"&&h.exportKind==="type"):!1);for await(const f of y){if(!f.source)continue;const h=await this.resolve(f.source.value,d);if(!h)return;const w=h.id;if(i(w)&&!s[w.replace(J,"")])try{const x=await mt(w);await l.call(this,x,w)}catch{}}}return m(l,"h"),$e(l,"transform"),{name:"packem:isolated-declarations",async renderStart(c,{input:d}){const p=Kr(...Array.isArray(d)?d:Object.values(d));typeof c.entryFileNames=="function"&&(c.entryFileNames=c.entryFileNames({name:c.name}));const u=c.entryFileNames.replace(/\.(.)?[jt]sx?$/,(g,y)=>`.d.${y||""}ts`);for await(let[g,y]of Object.entries(s)){if(r&&c.format==="cjs"){const h=St(y);h!==null&&(y=h.code)}const f=y.includes("from '")?"'":'"';(o===!0||o==="compatible")&&c.format==="cjs"&&this.emitFile({fileName:u.replace("[name]",O(p,g)).replace(".cts",".ts"),source:y.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(h,w,x,v)=>w+f+(v||x)+".d.ts"+f+";"),type:"asset"}),this.emitFile({fileName:u.replace("[name]",O(p,g)),source:y.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(h,w,x,v)=>w+f+(v||x)+(c.format==="cjs"?".d.cts":".d.mts")+f+";"),type:"asset"})}},transform:l}},"isolatedDeclarationsPlugin");var Xr=Object.defineProperty,Yr=m((e,t)=>Xr(e,"name",{value:t,configurable:!0}),"n$7");const Ke="export default ",Nt=Yr(e=>{const t=Bo(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(Ke)&&(n.code=n.code.replace(Ke,"module.exports = ")),n}}},"JSONPlugin");class Qr{static{m(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(t=>this.replacement=t,"replace")}}replace(t,o,r,n){t&&o&&(r!=null?t[o][r]=n:t[o]=n)}remove(t,o,r){t&&o&&(r!=null?t[o].splice(r,1):delete t[o])}}class Zr extends Qr{static{m(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(r=>this.replacement=r,"replace")},this.enter=t,this.leave=o}visit(t,o,r,n){if(t){if(this.enter){const s=this.should_skip,a=this.should_remove,l=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,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,d=this.should_remove;if(this.should_skip=s,this.should_remove=a,this.replacement=l,c)return t;if(d)return null}let i;for(i in t){const s=t[i];if(s&&typeof s=="object")if(Array.isArray(s)){const a=s;for(let l=0;l<a.length;l+=1){const c=a[l];He(c)&&(this.visit(c,t,i,l)||l--)}}else He(s)&&this.visit(s,t,i,null)}if(this.leave){const s=this.replacement,a=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,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=s,this.should_remove=a,l)return null}}return t}}function He(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(He,"isNode");function Pt(e,{enter:t,leave:o}){return new Zr(t,o).visit(e,null)}m(Pt,"walk");var en=Object.defineProperty,tn=m((e,t)=>en(e,"name",{value:t,configurable:!0}),"u$8");const on=tn(({attributes:e,logger:t})=>{const o=U([/\.[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 i=null;try{i=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 s=!1;const a=new F(r);return Pt(i,{enter(l){if(l.type==="CallExpression"&&l.callee.type==="Identifier"&&l.callee.name==="jsx"){const c=l.arguments.filter(d=>d.type==="ObjectExpression"&&Array.isArray(d.properties));for(const d of c)for(const p of d.properties)p.type==="Property"&&p.key.type==="Literal"&&p.value.type==="Literal"&&e.includes(p.key.value)&&(a.overwrite(p.start-2,p.end,""),s=!0)}}}),s?{code:a.toString(),map:a.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var rn=Object.defineProperty,nn=m((e,t)=>rn(e,"name",{value:t,configurable:!0}),"r$b");const Ct=nn((e,t,o)=>{const r=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- /${t} -->)`,"g");if(r.test(e))return e.replace(r,`$1
22
+ `),r},"generateCJSShimNode20_11"),Jr=he((e,t)=>{const o=U(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(r,n,i){if(i.format==="es"&&o(n.fileName)){let s=Rr;if(e.engines?.node){const a=$t(e.engines.node);a&&a.major>=20&&a.minor>=11&&(s=Fr)}return Ar(r,s)}return null}}},"esmShimCjsSyntaxPlugin");var Br=Object.defineProperty,Lr=m((e,t)=>Br(e,"name",{value:t,configurable:!0}),"m$c");const Wr=Lr(()=>({name:"packem:fix-dynamic-import-extension",renderChunk(e,t,o){return o.format==="es"||o.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(o.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var Vr=Object.defineProperty,zr=m((e,t)=>Vr(e,"name",{value:t,configurable:!0}),"a$c");const Ur=zr((e,t)=>{const o=e.replace(/^\.\//,""),r=t.replace(/^\.\//,"");if(r.startsWith(o))return e+r.slice(o.length);if(e.endsWith(t))return e;const n=e.split("/"),i=t.split("/");let s=n.length-1,a=i.length-1;for(;s>=0&&a>=0&&n[s]===i[a];)s--,a--;const l=n.slice(0,s).join("/"),c=i.slice(a).join("/");return l+(c?"/"+c:"")},"extendString");var qr=Object.defineProperty,Kr=m((e,t)=>qr(e,"name",{value:t,configurable:!0}),"s$d");const Hr=Kr((...e)=>{if(e.length===0)return"";if(e.length===1)return z(e[0]);e=e.map(n=>le(n));const[t,...o]=e;let r=t.split("/");for(const n of o){const i=n.split("/",r.length);let s=0;for(const a of i)if(a===r[s])s+=1;else{r=r.slice(0,s);break}r=r.slice(0,s)}return r.length<=1&&r[0]===""?`/${r[0]}`:r.join("/")},"lowestCommonAncestor");var Gr=Object.defineProperty,$e=m((e,t)=>Gr(e,"name",{value:t,configurable:!0}),"m$a");const Xr=$e((e,t,o,r,n={})=>{const i=U(n.include,n.exclude),s={},a=$e((c,d)=>{s[c.replace(J,"")]=d},"addOutput");async function l(c,d){if(!i(d))return;let p;try{const f=await Bo(c,{sourceFilename:d});p=JSON.parse(f.program)}catch{}if(p){const f=p.body.filter(h=>h.type==="ImportDeclaration"||h.type==="ExportAllDeclaration"||h.type==="ExportNamedDeclaration");for(const h of f){if(!h.source||ye(h.source.value).includes("."))continue;const w=await this.resolve(h.source.value,d);if(!(!w||w.external)&&(w.id.endsWith(".ts")||w.id.endsWith(".cts")||w.id.endsWith(".mts")||w.id.endsWith(".tsx"))){const x=w.id.replace(e+"/","");c=c.replaceAll('from "'+h.source.value+'"','from "'+Ur(h.source.value,x)+'"')}}}const{errors:u,sourceText:g}=await t(d,c);if(u.length>0){if(n.ignoreErrors){this.warn(u[0]);return}return this.error(u[0])}if(a(d,g),!p)return;const y=p.body.filter(f=>f.type==="ImportDeclaration"?f.importKind==="type"?!0:f.specifiers?.every(h=>h.type==="ImportSpecifier"&&h.importKind==="type"):f.type==="ExportNamedDeclaration"||f.type==="ExportAllDeclaration"?f.exportKind==="type"?!0:f.type==="ExportNamedDeclaration"&&f.specifiers?.every(h=>h.type==="ExportSpecifier"&&h.exportKind==="type"):!1);for await(const f of y){if(!f.source)continue;const h=await this.resolve(f.source.value,d);if(!h)return;const w=h.id;if(i(w)&&!s[w.replace(J,"")])try{const x=await dt(w);await l.call(this,x,w)}catch{}}}return m(l,"h"),$e(l,"transform"),{name:"packem:isolated-declarations",async renderStart(c,{input:d}){const p=Hr(...Array.isArray(d)?d:Object.values(d));typeof c.entryFileNames=="function"&&(c.entryFileNames=c.entryFileNames({name:c.name}));const u=c.entryFileNames.replace(/\.(.)?[jt]sx?$/,(g,y)=>`.d.${y||""}ts`);for await(let[g,y]of Object.entries(s)){if(r&&c.format==="cjs"){const h=St(y);h!==null&&(y=h.code)}const f=y.includes("from '")?"'":'"';(o===!0||o==="compatible")&&c.format==="cjs"&&this.emitFile({fileName:u.replace("[name]",O(p,g)).replace(".cts",".ts"),source:y.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(h,w,x,v)=>w+f+(v||x)+".d.ts"+f+";"),type:"asset"}),this.emitFile({fileName:u.replace("[name]",O(p,g)),source:y.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(h,w,x,v)=>w+f+(v||x)+(c.format==="cjs"?".d.cts":".d.mts")+f+";"),type:"asset"})}},transform:l}},"isolatedDeclarationsPlugin");var Yr=Object.defineProperty,Qr=m((e,t)=>Yr(e,"name",{value:t,configurable:!0}),"n$7");const qe="export default ",Nt=Qr(e=>{const t=Lo(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(qe)&&(n.code=n.code.replace(qe,"module.exports = ")),n}}},"JSONPlugin");class Zr{static{m(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(t=>this.replacement=t,"replace")}}replace(t,o,r,n){t&&o&&(r!=null?t[o][r]=n:t[o]=n)}remove(t,o,r){t&&o&&(r!=null?t[o].splice(r,1):delete t[o])}}class en extends Zr{static{m(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(r=>this.replacement=r,"replace")},this.enter=t,this.leave=o}visit(t,o,r,n){if(t){if(this.enter){const s=this.should_skip,a=this.should_remove,l=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,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,d=this.should_remove;if(this.should_skip=s,this.should_remove=a,this.replacement=l,c)return t;if(d)return null}let i;for(i in t){const s=t[i];if(s&&typeof s=="object")if(Array.isArray(s)){const a=s;for(let l=0;l<a.length;l+=1){const c=a[l];Ke(c)&&(this.visit(c,t,i,l)||l--)}}else Ke(s)&&this.visit(s,t,i,null)}if(this.leave){const s=this.replacement,a=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,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=s,this.should_remove=a,l)return null}}return t}}function Ke(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(Ke,"isNode");function Pt(e,{enter:t,leave:o}){return new en(t,o).visit(e,null)}m(Pt,"walk");var tn=Object.defineProperty,on=m((e,t)=>tn(e,"name",{value:t,configurable:!0}),"u$8");const rn=on(({attributes:e,logger:t})=>{const o=U([/\.[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 i=null;try{i=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 s=!1;const a=new F(r);return Pt(i,{enter(l){if(l.type==="CallExpression"&&l.callee.type==="Identifier"&&l.callee.name==="jsx"){const c=l.arguments.filter(d=>d.type==="ObjectExpression"&&Array.isArray(d.properties));for(const d of c)for(const p of d.properties)p.type==="Property"&&p.key.type==="Literal"&&p.value.type==="Literal"&&e.includes(p.key.value)&&(a.overwrite(p.start-2,p.end,""),s=!0)}}}),s?{code:a.toString(),map:a.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var nn=Object.defineProperty,sn=m((e,t)=>nn(e,"name",{value:t,configurable:!0}),"r$b");const Ct=sn((e,t,o)=>{const r=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- /${t} -->)`,"g");if(r.test(e))return e.replace(r,`$1
23
23
  ${o}
24
- $2`)},"replaceContentWithin");var sn=Object.defineProperty,_t=m((e,t)=>sn(e,"name",{value:t,configurable:!0}),"d$b");const an=_t(e=>{const t=[],o=[];return e.forEach(r=>{r.startsWith("(")?t.push(r):o.push(r)}),[...o.sort(),...t.sort()]},"sortLicenses"),Tt=_t(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:r,marker:n,mode:i,packageName:s})=>Lo({thirdParty(a){const l=new Set,c=a.sort(({name:p},{name:u})=>(p||0)>(u||0)?1:(u||0)>(p||0)?-1:0).map(({author:p,contributors:u,license:g,licenseText:y,maintainers:f,name:h,repository:w})=>{let x="## "+h+`
24
+ $2`)},"replaceContentWithin");var an=Object.defineProperty,_t=m((e,t)=>an(e,"name",{value:t,configurable:!0}),"d$b");const ln=_t(e=>{const t=[],o=[];return e.forEach(r=>{r.startsWith("(")?t.push(r):o.push(r)}),[...o.sort(),...t.sort()]},"sortLicenses"),Tt=_t(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:r,marker:n,mode:i,packageName:s})=>Wo({thirdParty(a){const l=new Set,c=a.sort(({name:p},{name:u})=>(p||0)>(u||0)?1:(u||0)>(p||0)?-1:0).map(({author:p,contributors:u,license:g,licenseText:y,maintainers:f,name:h,repository:w})=>{let x="## "+h+`
25
25
  `;g&&(x+=`License: ${g}
26
26
  `);const v=new Set;for(const _ of[p,...f,...u]){const te=typeof _=="string"?_:_?.name;te&&v.add(te)}return v.size>0&&(x+=`By: ${[...v].join(", ")}
27
27
  `),w&&(x+=`Repository: ${typeof w=="string"?w:w.url}
@@ -33,26 +33,26 @@ $2`)},"replaceContentWithin");var sn=Object.defineProperty,_t=m((e,t)=>sn(e,"nam
33
33
  `),g&&l.add(g),x}).join(`
34
34
  ---------------------------------------
35
35
 
36
- `);if(c===""){r.info({message:"No dependencies license information found.",prefix:"plugin:license:"+i});return}const d=o(an(l),c,s);try{const p=Y(t),u=Ct(p,n,d);if(!u){r.error({message:`Could not find the license marker: <!-- ${n} --><!-- /${n} --> in ${t}`,prefix:"plugin:license:"+i});return}p!==u&&(A(t,u),r.info({message:`${t} updated.`,prefix:"plugin:license:"+i}))}catch(p){r.error(p)}}}),"license");var ln=Object.defineProperty,cn=m((e,t)=>ln(e,"name",{value:t,configurable:!0}),"i$9");const pn=cn(e=>({async buildEnd(){const t=[];for(const r of this.getModuleIds()){const n=this.getModuleInfo(r);if(n!=null&&!n.isExternal)for(const i of n.importedIds)t.push({source:r,target:i})}if(Array.isArray(t)&&t.length===0)return;const o=$(e.rootDir,e.outDir,"graph.json");ge(o,t)},name:"packem:metafile"}),"metafilePlugin");var un=Object.defineProperty,dn=m((e,t)=>un(e,"name",{value:t,configurable:!0}),"g$7");let Ge=!1;const mn=dn((e,t,o,r,n,i)=>{if(i!=="*"&&_o(To(i))===null)throw new Error("Invalid typeScriptVersion option. It must be a valid semver range.");return{name:"packem:node10-compatibility",writeBundle(){Ge||(e.info({message:"Declaration node10 compatibility mode is enabled.",prefix:"plugin:node10-compatibility"}),Ge=!0);const s={};for(const c of t)for(const d of c.exportKey)d.includes("/*")?s[d]=["./"+b(o,z(c.name),"*.d.ts")]:s[d]=[...s[d]??[],"./"+b(o,c.name+".d.ts")];const a=b(r,"package.json"),l=Pe(a);n==="file"&&Object.keys(s).length>0?(ge(a,{...l,typesVersions:{...l.typesVersions,[i]:s}},{detectIndent:!0}),e.info({message:'Your package.json "typesVersions" field has been updated.',prefix:"plugin:node10-compatibility"})):Object.keys(s).length>0&&e.info({message:`Please add the following field into your package.json to enable node 10 compatibility:
36
+ `);if(c===""){r.info({message:"No dependencies license information found.",prefix:"plugin:license:"+i});return}const d=o(ln(l),c,s);try{const p=Y(t),u=Ct(p,n,d);if(!u){r.error({message:`Could not find the license marker: <!-- ${n} --><!-- /${n} --> in ${t}`,prefix:"plugin:license:"+i});return}p!==u&&(A(t,u),r.info({message:`${t} updated.`,prefix:"plugin:license:"+i}))}catch(p){r.error(p)}}}),"license");var cn=Object.defineProperty,pn=m((e,t)=>cn(e,"name",{value:t,configurable:!0}),"i$9");const un=pn(e=>({async buildEnd(){const t=[];for(const r of this.getModuleIds()){const n=this.getModuleInfo(r);if(n!=null&&!n.isExternal)for(const i of n.importedIds)t.push({source:r,target:i})}if(Array.isArray(t)&&t.length===0)return;const o=$(e.rootDir,e.outDir,"graph.json");ge(o,t)},name:"packem:metafile"}),"metafilePlugin");var dn=Object.defineProperty,mn=m((e,t)=>dn(e,"name",{value:t,configurable:!0}),"g$7");let He=!1;const fn=mn((e,t,o,r,n,i)=>{if(i!=="*"&&_o(To(i))===null)throw new Error("Invalid typeScriptVersion option. It must be a valid semver range.");return{name:"packem:node10-compatibility",writeBundle(){He||(e.info({message:"Declaration node10 compatibility mode is enabled.",prefix:"plugin:node10-compatibility"}),He=!0);const s={};for(const c of t)for(const d of c.exportKey)d.includes("/*")?s[d]=["./"+b(o,z(c.name),"*.d.ts")]:s[d]=[...s[d]??[],"./"+b(o,c.name+".d.ts")];const a=b(r,"package.json"),l=Pe(a);n==="file"&&Object.keys(s).length>0?(ge(a,{...l,typesVersions:{...l.typesVersions,[i]:s}},{detectIndent:!0}),e.info({message:'Your package.json "typesVersions" field has been updated.',prefix:"plugin:node10-compatibility"})):Object.keys(s).length>0&&e.info({message:`Please add the following field into your package.json to enable node 10 compatibility:
37
37
 
38
38
  ${JSON.stringify({typesVersions:{"*":s}},null,4)}
39
- `,prefix:"plugin:node10-compatibility"})}}},"node10CompatibilityPlugin");var fn=Object.defineProperty,gn=m((e,t)=>fn(e,"name",{value:t,configurable:!0}),"r$a");const M=gn(e=>{const t=Wo("md5");return t.update(e),t.digest("hex")},"getHash");var yn=Object.defineProperty,It=m((e,t)=>yn(e,"name",{value:t,configurable:!0}),"d$a");const G=It(e=>e.handler||e,"getHandler"),E=It((e,t,o="")=>({...e,async buildEnd(r){e.buildEnd&&await G(e.buildEnd).call(this,r)},async buildStart(r){e.buildStart&&await G(e.buildStart).call(this,r)},async load(r){if(!e.load)return null;const n=b(o,e.name),i=b("load",M(r));if(t.has(i,n))return await t.get(i,n);const s=await G(e.load).call(this,r);return t.set(i,s,n),s},name:`cached(${e.name})`,async resolveId(r,n,i){if(!e.resolveId)return null;const s=b(o,e.name),a=b("resolveId",M(r),n?M(n):"",M(JSON.stringify(i)));if(t.has(a,s))return await t.get(a,s);const l=await G(e.resolveId).call(this,r,n,i);return t.set(a,l,s),l},async transform(r,n){if(!e.transform)return null;const i=b(o,e.name),s=b("transform",M(n),M(r));if(t.has(s,i))return await t.get(s,i);const a=await G(e.transform).call(this,r,n);return t.set(s,a,i),a}}),"cachingPlugin");var hn=Object.defineProperty,vn=m((e,t)=>hn(e,"name",{value:t,configurable:!0}),"n$6");const bn=vn(()=>({name:"packem:prepend-directive",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}';
40
- `+e}return null},order:"post"}}),"prependDirectivePlugin");var wn=Object.defineProperty,$n=m((e,t)=>wn(e,"name",{value:t,configurable:!0}),"c$8");const jn=$n(({directiveRegex:e,exclude:t=[],include:o=[],logger:r})=>{const n={},i={},s=U(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 d=l.moduleIds.map(g=>n[g]?n[g]:null).reduce((g,y)=>(y&&y.forEach(f=>{g.add(f)}),g),new Set),p=new F(a);d.size>0&&(r.debug({message:`directives for chunk "${l.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),p.prepend(`${[...d].map(g=>`'${g}';`).join(`
39
+ `,prefix:"plugin:node10-compatibility"})}}},"node10CompatibilityPlugin");var gn=Object.defineProperty,yn=m((e,t)=>gn(e,"name",{value:t,configurable:!0}),"r$a");const M=yn(e=>{const t=Vo("md5");return t.update(e),t.digest("hex")},"getHash");var hn=Object.defineProperty,It=m((e,t)=>hn(e,"name",{value:t,configurable:!0}),"d$a");const G=It(e=>e.handler||e,"getHandler"),E=It((e,t,o="")=>({...e,async buildEnd(r){e.buildEnd&&await G(e.buildEnd).call(this,r)},async buildStart(r){e.buildStart&&await G(e.buildStart).call(this,r)},async load(r){if(!e.load)return null;const n=b(o,e.name),i=b("load",M(r));if(t.has(i,n))return await t.get(i,n);const s=await G(e.load).call(this,r);return t.set(i,s,n),s},name:`cached(${e.name})`,async resolveId(r,n,i){if(!e.resolveId)return null;const s=b(o,e.name),a=b("resolveId",M(r),n?M(n):"",M(JSON.stringify(i)));if(t.has(a,s))return await t.get(a,s);const l=await G(e.resolveId).call(this,r,n,i);return t.set(a,l,s),l},async transform(r,n){if(!e.transform)return null;const i=b(o,e.name),s=b("transform",M(n),M(r));if(t.has(s,i))return await t.get(s,i);const a=await G(e.transform).call(this,r,n);return t.set(s,a,i),a}}),"cachingPlugin");var vn=Object.defineProperty,bn=m((e,t)=>vn(e,"name",{value:t,configurable:!0}),"n$6");const wn=bn(()=>({name:"packem:prepend-directive",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}';
40
+ `+e}return null},order:"post"}}),"prependDirectivePlugin");var $n=Object.defineProperty,jn=m((e,t)=>$n(e,"name",{value:t,configurable:!0}),"c$8");const kn=jn(({directiveRegex:e,exclude:t=[],include:o=[],logger:r})=>{const n={},i={},s=U(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 d=l.moduleIds.map(g=>n[g]?n[g]:null).reduce((g,y)=>(y&&y.forEach(f=>{g.add(f)}),g),new Set),p=new F(a);d.size>0&&(r.debug({message:`directives for chunk "${l.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),p.prepend(`${[...d].map(g=>`'${g}';`).join(`
41
41
  `)}
42
42
  `));let u;return l.facadeModuleId&&typeof i[l.facadeModuleId]=="string"&&(u=i[l.facadeModuleId]),u&&(r.debug({message:`shebang for chunk "${l.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),p.prepend(`${u}
43
- `)),d.size===0&&u===void 0?null:{code:p.toString(),map:c?p.generateMap({hires:!0}):null}},order:"post"},transform(a,l){if(!s(l))return null;let c=!1;const d=new F(a);if(a.startsWith("#")&&a[1]==="!"){let u=0;for(let g=2,y=a.length;g<y;g++){const f=a.codePointAt(g);if(f===10||f===13||f===8232||f===8233){u=g;break}}u&&(i[l]=a.slice(0,u),d.remove(0,u+1),c=!0,r.debug({message:`shebang for module "${l}" is preserved.`,prefix:"plugin:preserve-directives"}))}let p=null;try{p=this.parse(d.toString(),{allowReturnOutsideFunction:!0})}catch(u){return this.warn({code:"PARSE_ERROR",message:`failed to parse "${l}" and extract the directives.`}),r.warn(u),null}if(p.type!=="Program")return null;for(const u of p.body.filter(Boolean)){if(u.type!=="ExpressionStatement")break;let g=null;"directive"in u?g=u.directive:u.expression.type==="Literal"&&typeof u.expression.value=="string"&&e.test(u.expression.value)&&(g=u.expression.value),g!=="use strict"&&g&&(n[l]||=new Set,n[l].add(g),"start"in u&&typeof u.start=="number"&&"end"in u&&typeof u.end=="number"&&(d.remove(u.start,u.end),c=!0),r.debug({message:`directive "${g}" for module "${l}" is preserved.`,prefix:"plugin:preserve-directives"}))}return c?{code:d.toString(),map:d.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...n[l]??[]],shebang:i[l]??null}}}:null}}},"preserveDirectives");var kn=Object.defineProperty,xn=m((e,t)=>kn(e,"name",{value:t,configurable:!0}),"t$8");const En=xn(e=>{const t=U(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 Dn=Object.defineProperty,Sn=m((e,t)=>Dn(e,"name",{value:t,configurable:!0}),"r$9");const Mt=Sn(()=>({name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return Vo(e)}}),"resolveFileUrl");var On=Object.defineProperty,ve=m((e,t)=>On(e,"name",{value:t,configurable:!0}),"i$6");const ue=/^#![^\n]*/,Se=ve(async e=>{await co(e,493).catch(()=>{})},"makeExecutable"),Nn=ve((e,t)=>({name:"packem:shebang",renderChunk:{handler(o,r,n){if(!r.isEntry||!r.facadeModuleId)return null;const i=o.startsWith("#")&&o[1]==="!";if(i&&t.replace)return o.replace(ue,t.shebang+`
43
+ `)),d.size===0&&u===void 0?null:{code:p.toString(),map:c?p.generateMap({hires:!0}):null}},order:"post"},transform(a,l){if(!s(l))return null;let c=!1;const d=new F(a);if(a.startsWith("#")&&a[1]==="!"){let u=0;for(let g=2,y=a.length;g<y;g++){const f=a.codePointAt(g);if(f===10||f===13||f===8232||f===8233){u=g;break}}u&&(i[l]=a.slice(0,u),d.remove(0,u+1),c=!0,r.debug({message:`shebang for module "${l}" is preserved.`,prefix:"plugin:preserve-directives"}))}let p=null;try{p=this.parse(d.toString(),{allowReturnOutsideFunction:!0})}catch(u){return this.warn({code:"PARSE_ERROR",message:`failed to parse "${l}" and extract the directives.`}),r.warn(u),null}if(p.type!=="Program")return null;for(const u of p.body.filter(Boolean)){if(u.type!=="ExpressionStatement")break;let g=null;"directive"in u?g=u.directive:u.expression.type==="Literal"&&typeof u.expression.value=="string"&&e.test(u.expression.value)&&(g=u.expression.value),g!=="use strict"&&g&&(n[l]||=new Set,n[l].add(g),"start"in u&&typeof u.start=="number"&&"end"in u&&typeof u.end=="number"&&(d.remove(u.start,u.end),c=!0),r.debug({message:`directive "${g}" for module "${l}" is preserved.`,prefix:"plugin:preserve-directives"}))}return c?{code:d.toString(),map:d.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...n[l]??[]],shebang:i[l]??null}}}:null}}},"preserveDirectives");var xn=Object.defineProperty,En=m((e,t)=>xn(e,"name",{value:t,configurable:!0}),"t$8");const Dn=En(e=>{const t=U(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 Sn=Object.defineProperty,On=m((e,t)=>Sn(e,"name",{value:t,configurable:!0}),"r$9");const Mt=On(()=>({name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return zo(e)}}),"resolveFileUrl");var Nn=Object.defineProperty,ve=m((e,t)=>Nn(e,"name",{value:t,configurable:!0}),"i$6");const ue=/^#![^\n]*/,Se=ve(async e=>{await co(e,493).catch(()=>{})},"makeExecutable"),Pn=ve((e,t)=>({name:"packem:shebang",renderChunk:{handler(o,r,n){if(!r.isEntry||!r.facadeModuleId)return null;const i=o.startsWith("#")&&o[1]==="!";if(i&&t.replace)return o.replace(ue,t.shebang+`
44
44
  `);if(i)return null;if(e.includes(r.name)){const s=new F(o);return s.prepend(t.shebang+`
45
- `),{code:s.toString(),map:n.sourcemap?s.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,r){for(const[n,i]of Object.entries(r))if(i.type==="chunk"&&ue.test(i.code)&&o.dir){const s=$(o.dir,n);await Se(s)}}}),"shebangPlugin"),Pn=ve(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ue,"")}}),"removeShebangPlugin"),Cn=ve((e,t=`
46
- `)=>{const o=ue.exec(e);return o?o+t:""},"getShebang");var _n=Object.defineProperty,B=m((e,t)=>_n(e,"name",{value:t,configurable:!0}),"r$8");const Tn=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,In=/MIT License|MIT license|BSD license/,Mn=/\n{2,}/g,An=/\b(\w+)\$\d+\b/g,Rn=/[-/\\^$*+?.()|[\]{}]/g,Fn=B(e=>e.replaceAll(Rn,"\\$&"),"escapeRegex"),Jn=B(e=>[...new Set(e)],"unique"),Bn=B(e=>e.replaceAll(Tn,t=>In.test(t)?"":t).replaceAll(Mn,`
45
+ `),{code:s.toString(),map:n.sourcemap?s.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,r){for(const[n,i]of Object.entries(r))if(i.type==="chunk"&&ue.test(i.code)&&o.dir){const s=$(o.dir,n);await Se(s)}}}),"shebangPlugin"),Cn=ve(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ue,"")}}),"removeShebangPlugin"),_n=ve((e,t=`
46
+ `)=>{const o=ue.exec(e);return o?o+t:""},"getShebang");var Tn=Object.defineProperty,B=m((e,t)=>Tn(e,"name",{value:t,configurable:!0}),"r$8");const In=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Mn=/MIT License|MIT license|BSD license/,An=/\n{2,}/g,Rn=/\b(\w+)\$\d+\b/g,Fn=/[-/\\^$*+?.()|[\]{}]/g,Jn=B(e=>e.replaceAll(Fn,"\\$&"),"escapeRegex"),Bn=B(e=>[...new Set(e)],"unique"),Ln=B(e=>e.replaceAll(In,t=>Mn.test(t)?"":t).replaceAll(An,`
47
47
 
48
- `),"cleanUnnecessaryComments"),Xe=new Map;function At(e,t,{identifierReplacements:o},r){const n=jt(e);for(const s in o){const a=n.find(c=>c.specifier===s&&c.imports.includes("{"));if(!a){this.warn(`${t.fileName} does not import "${s}" for replacement`),process.exitCode=1;continue}const l=o[s];for(const c in l){if(!a.imports.includes(c))throw new Error(`${t.fileName} does not import "${c}" from "${s}" for replacement`);const d=l[c],p=Fn(c);d.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${p},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${p}\\b`,"g"),d)}}const i=Jn(Array.from(e.matchAll(An),s=>s[0]));if(i.length>0){const s=i.map(l=>`
49
- - ${l}`).join(""),a=t.fileName.replace(/\.[^/.]+$/,"");Xe.has(a)||r.warn({message:`${t.fileName} contains confusing identifier names${s}
48
+ `),"cleanUnnecessaryComments"),Ge=new Map;function At(e,t,{identifierReplacements:o},r){const n=jt(e);for(const s in o){const a=n.find(c=>c.specifier===s&&c.imports.includes("{"));if(!a){this.warn(`${t.fileName} does not import "${s}" for replacement`),process.exitCode=1;continue}const l=o[s];for(const c in l){if(!a.imports.includes(c))throw new Error(`${t.fileName} does not import "${c}" from "${s}" for replacement`);const d=l[c],p=Jn(c);d.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${p},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${p}\\b`,"g"),d)}}const i=Bn(Array.from(e.matchAll(Rn),s=>s[0]));if(i.length>0){const s=i.map(l=>`
49
+ - ${l}`).join(""),a=t.fileName.replace(/\.[^/.]+$/,"");Ge.has(a)||r.warn({message:`${t.fileName} contains confusing identifier names${s}
50
50
 
51
- 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}m(At,"I");B(At,"replaceConfusingTypeNames");const Ln=B((e,t)=>{if(t.leadingComments?.some(o=>o.type==="CommentBlock"&&o.value.includes("@internal"))){const o=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,o),!0}return!1},"removeInternal");function Rt(e,t){if(e.includes("@internal")){const o=new F(e),r=zo(e,{plugins:["typescript"],sourceType:"module"});if(Pt(r,{enter(n){Ln(o,n)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}m(Rt,"S$1");B(Rt,"stripInternalTypes");const Wn=B((e,t)=>({name:"packem:patch-types",renderChunk(o,r){return o=At.call(this,o,r,e,t),o=Rt.call(this,o,r),o=Bn(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var Vn=Object.defineProperty,Ft=m((e,t)=>Vn(e,"name",{value:t,configurable:!0}),"m$9");const Jt=Ft((e,t=!0)=>{if(!e)return null;const{config:o,path:r}=e;if(!o.compilerOptions)return null;const{baseUrl:n,paths:i}=o.compilerOptions;if(!n)return null;const s=$(z(r),n),a=[];if(i)for(const[l,c]of Object.entries(i)){let d;l==="@"||l==="~"||l==="#"?d=new RegExp(`^${l}/(.+)$`):d=new RegExp(`^${[...l].map(u=>u==="*"?"(.+)":u.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let p=0;for(const u of c){const g=[...Le($(s,u))].map(y=>y==="*"?"$"+(++p+""):y==="$"?"$$":y).join("");a.push({find:d,replacement:g})}}return t&&a.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...Le(s)].map(l=>l==="$"?"$$":l).join("")}/$1`}),a},"getConfigAlias"),Bt=Ft((e,t)=>{const o=Jt(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(r,n,i){if(!o||r.includes("\0"))return null;for(const{find:s,replacement:a}of o)if(s.test(r)){const l=r.replace(s,a),c=await this.resolve(l,n,{skipSelf:!0,...i});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 zn=Object.defineProperty,Lt=m((e,t)=>zn(e,"name",{value:t,configurable:!0}),"u$5");const Un=Lt((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 i=[];for(const s of n){if(s.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${r}.`);if(s.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${r}.`);i.push($(e,s))}return i},"getRootDirectories"),Wt=Lt((e,t,o)=>{const r=Un(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,i,s){if(r===null||r.length===0)return null;if(n.startsWith("."))for(const a of r){const l=b(a,n),c=await this.resolve(l,i,{skipSelf:!0,...s});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 qn=Object.defineProperty,Kn=m((e,t)=>qn(e,"name",{value:t,configurable:!0}),"r$7");const Vt=Kn(()=>{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 Hn=Object.defineProperty,zt=m((e,t)=>Hn(e,"name",{value:t,configurable:!0}),"u$4");const Ye=zt((e,t,o,r)=>{const n=e.findIndex(s=>typeof s=="object"?s.name===o:!1);if(n===-1)throw new Error(`Plugin with name "${o}" was not found, try one of: ${e.map(s=>{if(typeof s=="object")return s.name}).filter(Boolean).join(", ")}`);const i=r?n+1:n;return e.splice(i,0,t),e},"appendPlugin"),Ut=zt((e,t)=>{if(!t)return e;for(const{after:o=void 0,before:r=void 0,plugin:n}of t)e=o?Ye(e,n,o,!0):Ye(e,n,r,!1);return e},"appendPlugins");var Gn=Object.defineProperty,Xn=m((e,t)=>Gn(e,"name",{value:t,configurable:!0}),"s$8");const Yn=Xn(e=>{const t=ye(e).split(".");if(t.length>=2){const[o,r]=t.slice(-2),n=t[0],i=/^(\w+)-runtime$/.exec(o)?.[1];if(_e.includes(r)&&i&&i.length>0)return n+"-"+i}},"getCustomModuleLayer");var Qn=Object.defineProperty,Zn=m((e,t)=>Qn(e,"name",{value:t,configurable:!0}),"i$5");const je=Zn(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var ei=Object.defineProperty,Qe=m((e,t)=>ei(e,"name",{value:t,configurable:!0}),"d$8");const ti=Qe((e,t)=>{const o=new Map;return Qe(function(r,n){const i=n.getModuleInfo(r);if(!i)return;const{isEntry:s}=i,a=i.meta,l=je(a);if(!s){const c=o.get(r);if(c)return c;const d=Yn(r);if(d)return o.set(r,d),d}if(s){const c=n.getModuleIds();for(const d of c)n.getModuleInfo(d)&&je(a)===l&&(e.has(d)||e.set(d,new Set),e.get(d).add([r,l]))}if(l&&!s&&e.has(r)){const c=[...e.get(r)];if(c.some(([p])=>{if(t.some(u=>u.path===p)){const u=n.getModuleInfo(p);return je(u?u.meta:{})===l}return!1}))return;if(c.every(([,p])=>p===l))return o.has(r)?o.get(r):void 0;const d=ye(r,ft(r))+"-"+l;return o.set(r,d),d}},"splitChunks")},"createSplitChunks");var oi=Object.defineProperty,ri=m((e,t)=>oi(e,"name",{value:t,configurable:!0}),"n$4");const R=ri((e,t)=>e.isDynamicEntry?`${er}/[name].${t}`:`${tr}/${e.name}-[hash].${t}`,"getChunkFilename");var ni=Object.defineProperty,ii=m((e,t)=>ni(e,"name",{value:t,configurable:!0}),"s$6");const si=process.platform==="win32",Ze=ii((e,t)=>{const o=si?"\\":"/";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 ai=Object.defineProperty,li=m((e,t)=>ai(e,"name",{value:t,configurable:!0}),"p$2");const Me=li((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 i=r[n];typeof i=="string"&&(o[n]=b(e.options.rootDir,i))}}return o={...o,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(o,Object.fromEntries(e.options.rollup.alias.entries.map(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 ci=Object.defineProperty,D=m((e,t)=>ci(e,"name",{value:t,configurable:!0}),"p$1");const pi=D((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"+so.node.split(".")[0];if(t.pkg.engines?.node){const r=$t(t.pkg.engines.node);r&&(o="node"+r.major)}if(t.options.rollup.esbuild.target){const r=X(t.options.rollup.esbuild.target);r.some(n=>n.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...X(o),...r])])}else t.options.rollup.esbuild.target=X(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"),qt=D((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 "${k(O($(),e.id))}"
51
+ To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),Ge.set(a,!0)}return e}m(At,"I");B(At,"replaceConfusingTypeNames");const Wn=B((e,t)=>{if(t.leadingComments?.some(o=>o.type==="CommentBlock"&&o.value.includes("@internal"))){const o=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,o),!0}return!1},"removeInternal");function Rt(e,t){if(e.includes("@internal")){const o=new F(e),r=Uo(e,{plugins:["typescript"],sourceType:"module"});if(Pt(r,{enter(n){Wn(o,n)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}m(Rt,"S$1");B(Rt,"stripInternalTypes");const Vn=B((e,t)=>({name:"packem:patch-types",renderChunk(o,r){return o=At.call(this,o,r,e,t),o=Rt.call(this,o,r),o=Ln(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var zn=Object.defineProperty,Ft=m((e,t)=>zn(e,"name",{value:t,configurable:!0}),"m$9");const Jt=Ft((e,t=!0)=>{if(!e)return null;const{config:o,path:r}=e;if(!o.compilerOptions)return null;const{baseUrl:n,paths:i}=o.compilerOptions;if(!n)return null;const s=$(z(r),n),a=[];if(i)for(const[l,c]of Object.entries(i)){let d;l==="@"||l==="~"||l==="#"?d=new RegExp(`^${l}/(.+)$`):d=new RegExp(`^${[...l].map(u=>u==="*"?"(.+)":u.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let p=0;for(const u of c){const g=[...Be($(s,u))].map(y=>y==="*"?"$"+(++p+""):y==="$"?"$$":y).join("");a.push({find:d,replacement:g})}}return t&&a.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...Be(s)].map(l=>l==="$"?"$$":l).join("")}/$1`}),a},"getConfigAlias"),Bt=Ft((e,t)=>{const o=Jt(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(r,n,i){if(!o||r.includes("\0"))return null;for(const{find:s,replacement:a}of o)if(s.test(r)){const l=r.replace(s,a),c=await this.resolve(l,n,{skipSelf:!0,...i});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 Un=Object.defineProperty,Lt=m((e,t)=>Un(e,"name",{value:t,configurable:!0}),"u$5");const qn=Lt((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 i=[];for(const s of n){if(s.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${r}.`);if(s.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${r}.`);i.push($(e,s))}return i},"getRootDirectories"),Wt=Lt((e,t,o)=>{const r=qn(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,i,s){if(r===null||r.length===0)return null;if(n.startsWith("."))for(const a of r){const l=b(a,n),c=await this.resolve(l,i,{skipSelf:!0,...s});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 Kn=Object.defineProperty,Hn=m((e,t)=>Kn(e,"name",{value:t,configurable:!0}),"r$7");const Vt=Hn(()=>{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 Gn=Object.defineProperty,zt=m((e,t)=>Gn(e,"name",{value:t,configurable:!0}),"u$4");const Xe=zt((e,t,o,r)=>{const n=e.findIndex(s=>typeof s=="object"?s.name===o:!1);if(n===-1)throw new Error(`Plugin with name "${o}" was not found, try one of: ${e.map(s=>{if(typeof s=="object")return s.name}).filter(Boolean).join(", ")}`);const i=r?n+1:n;return e.splice(i,0,t),e},"appendPlugin"),Ut=zt((e,t)=>{if(!t)return e;for(const{after:o=void 0,before:r=void 0,plugin:n}of t)e=o?Xe(e,n,o,!0):Xe(e,n,r,!1);return e},"appendPlugins");var Xn=Object.defineProperty,Yn=m((e,t)=>Xn(e,"name",{value:t,configurable:!0}),"s$8");const Qn=Yn(e=>{const t=ye(e).split(".");if(t.length>=2){const[o,r]=t.slice(-2),n=t[0],i=/^(\w+)-runtime$/.exec(o)?.[1];if(Ce.includes(r)&&i&&i.length>0)return n+"-"+i}},"getCustomModuleLayer");var Zn=Object.defineProperty,ei=m((e,t)=>Zn(e,"name",{value:t,configurable:!0}),"i$5");const je=ei(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var ti=Object.defineProperty,Ye=m((e,t)=>ti(e,"name",{value:t,configurable:!0}),"d$8");const oi=Ye((e,t)=>{const o=new Map;return Ye(function(r,n){const i=n.getModuleInfo(r);if(!i)return;const{isEntry:s}=i,a=i.meta,l=je(a);if(!s){const c=o.get(r);if(c)return c;const d=Qn(r);if(d)return o.set(r,d),d}if(s){const c=n.getModuleIds();for(const d of c)n.getModuleInfo(d)&&je(a)===l&&(e.has(d)||e.set(d,new Set),e.get(d).add([r,l]))}if(l&&!s&&e.has(r)){const c=[...e.get(r)];if(c.some(([p])=>{if(t.some(u=>u.path===p)){const u=n.getModuleInfo(p);return je(u?u.meta:{})===l}return!1}))return;if(c.every(([,p])=>p===l))return o.has(r)?o.get(r):void 0;const d=ye(r,ft(r))+"-"+l;return o.set(r,d),d}},"splitChunks")},"createSplitChunks");var ri=Object.defineProperty,ni=m((e,t)=>ri(e,"name",{value:t,configurable:!0}),"n$4");const R=ni((e,t)=>e.isDynamicEntry?`${tr}/[name].${t}`:`${or}/${e.name}-[hash].${t}`,"getChunkFilename");var ii=Object.defineProperty,si=m((e,t)=>ii(e,"name",{value:t,configurable:!0}),"s$6");const ai=process.platform==="win32",Qe=si((e,t)=>{const o=ai?"\\":"/";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 li=Object.defineProperty,ci=m((e,t)=>li(e,"name",{value:t,configurable:!0}),"p$2");const Ie=ci((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 i=r[n];typeof i=="string"&&(o[n]=b(e.options.rootDir,i))}}return o={...o,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(o,Object.fromEntries(e.options.rollup.alias.entries.map(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 pi=Object.defineProperty,D=m((e,t)=>pi(e,"name",{value:t,configurable:!0}),"p$1");const ui=D((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"+so.node.split(".")[0];if(t.pkg.engines?.node){const r=$t(t.pkg.engines.node);r&&(o="node"+r.major)}if(t.options.rollup.esbuild.target){const r=X(t.options.rollup.esbuild.target);r.some(n=>n.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...X(o),...r])])}else t.options.rollup.esbuild.target=X(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"),qt=D((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 "${k(O($(),e.id))}"
52
52
  Is the module installed? Note:
53
53
  ↳ to inline a module into your bundle, install it to "devDependencies".
54
- ↳ 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"),et=new Map,ke=new Map,Kt=D((e,t,o)=>{const r=D(i=>{for(const[s,a]of Object.entries(t))if(i.startsWith(s))return i.replace(s,a)},"findAlias"),n=Jt(e.tsconfig,!1);return{external(i){const s=r(i);s&&(i=s);const a=xt(i);if(De(e.options.externals,a)||De(e.options.externals,i))return!0;const{pkg:l}=e;if(i.startsWith(".")||gt(i)||/src[/\\]/.test(i)||l.name&&i.startsWith(l.name))return!1;if(l.imports)for(const[c,d]of Object.entries(l.imports)){if(c===i)return!1;if(c.includes("*")){let p;ke.has(c)?p=ke.get(c):(p=Ne(b(e.options.rootDir,d.replace("/*","")),{withFileTypes:!0}).filter(u=>u.isFile()).map(u=>u.name),ke.set(c,p));for(const u of p)if(u.replace(J,"")===i.replace(J,"").replace("#",""))return!1}}if(n){for(const{find:c}of n)if(c.test(i))return e.logger.debug({message:`Resolved alias ${i} to ${c.source}`,prefix:o}),!1}return et.has(i)||e.logger.info({message:'Inlined implicit external "'+k(i)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),et.set(i,!0),!1},input:Object.fromEntries(e.options.entries.map(i=>[i.name,$(e.options.rootDir,i.input)])),logLevel:e.options.debug?"debug":"info",onLog:D((i,s)=>{let a=s.message;switch(s.stack&&(a=`${a}
55
- ${s.stack}`),i){case"info":{e.logger.info({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")})}},"onLog"),onwarn(i,s){qt(i,e)||i.code||s(i)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),Ht=D(async(e,t)=>{const o=Me(e,"build");let r;e.options.rollup.resolve&&(r=E(bt({...e.options.rollup.resolve}),t));const n=e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:ti(e.dependencyGraphMap,e.buildEntries),preserveModules:!1};return{...Kt(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:D(i=>R(i,"cjs"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:D(i=>Ze(i,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...n},e.options.emitESM&&{chunkFileNames:D(i=>R(i,"mjs"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:D(i=>Ze(i,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...n}].filter(Boolean),plugins:Ut([E(Mt(),t),E(Vt(),t),e.tsconfig&&E(Wt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&E(Bt(e.tsconfig,e.logger),t),e.options.rollup.replace&&wt({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&vt({customResolver:r,...e.options.rollup.alias,entries:o}),r,e.options.rollup.polyfillNode&&Po({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&Nt({...e.options.rollup.json}),kr(),e.options.rollup.wasm&&No(e.options.rollup.wasm),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&Gr(b(e.options.rootDir,e.options.sourceDir),e.options.isolatedDeclarationTransformer,e.options.declaration,!!e.options.rollup.cjsInterop,e.options.rollup.isolatedDeclarations),e.options.transformer(pi(e.options.transformerName,e)),E(jn({directiveRegex:/^['|"](use (\w+))['|"]$/,...e.options.rollup.preserveDirectives,logger:e.logger}),t),e.options.rollup.shebang&&Nn(e.options.entries.filter(i=>i.executable).map(i=>i.name).filter(Boolean),e.options.rollup.shebang),e.options.cjsInterop&&e.options.emitCJS&&Ot({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Lr(),e.options.rollup.dynamicVars&&Oo(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&E(So({sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{name:"packem:preserve-dynamic-imports",renderDynamicImport(){return{left:"import(",right:")"}}},e.options.cjsInterop&&e.options.rollup.shim&&Fr(e.pkg,e.options.rollup.shim),e.options.rollup.raw&&E(En(e.options.rollup.raw),t),e.options.rollup.jsxRemoveAttributes&&E(on({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),t),e.options.rollup.metafile&&pn({outDir:$(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&_r(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&Tt({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),bn(),e.options.emitCJS&&e.mode==="build"&&e.options.declaration==="compatible"&&e.options.rollup.node10Compatibility&&mn(e.logger,e.options.entries,e.options.outDir,e.options.rootDir,e.options.rollup.node10Compatibility.writeToPackageJson?"file":"console",e.options.rollup.node10Compatibility.typeScriptVersion??"*"),e.options.analyze&&e.options.rollup.visualizer!==!1&&Co({brotliSize:!0,gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,...e.options.rollup.visualizer,filename:"packem-bundle-analyze.html",title:"Packem Visualizer"})].filter(Boolean),e.options.rollup.plugins)}},"getRollupOptions"),ui=D(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"),di=pr(ui),Gt=D(async(e,t)=>{const o=Me(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 i;e.options.rollup.resolve&&(i=E(bt({...e.options.rollup.resolve}),t));const s="dts-plugin:"+process.pid+e.tsconfig.path;return{...Kt(e,o,"dts"),onwarn(a,l){qt(a,e)||a.code!=="EMPTY_BUNDLE"&&l(a)},output:[e.options.emitCJS&&{chunkFileNames:D(a=>R(a,"d.cts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:D(a=>R(a,"d.mts"),"chunkFileNames"),dir:$(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:D(a=>R(a,"d.ts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:Ut([E(Mt(),t),E(Vt(),t),e.options.rollup.json&&Nt({...e.options.rollup.json}),r,e.tsconfig&&E(Wt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&E(Bt(e.tsconfig,e.logger),t),e.options.rollup.replace&&wt({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&vt({customResolver:i,...e.options.rollup.alias,entries:o}),i,await di(s)(e),e.options.cjsInterop&&e.options.emitCJS&&Ot({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&E(Wn(e.options.rollup.patchTypes,e.logger),t),Pn(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Tt({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean),e.options.rollup.plugins)}},"getRollupDtsOptions");var mi=Object.defineProperty,fi=m((e,t)=>mi(e,"name",{value:t,configurable:!0}),"f$4");const tt="rollup-build.json",xe=fi(async(e,t,o)=>{const r=await Ht(e,t);if(await e.hooks.callHook("rollup:options",e,r),Object.keys(r.input).length===0)return;(!e.options.rollup.isolatedDeclarations||!e.options.isolatedDeclarationTransformer)&&(r.cache=t.get(tt,o));const n=await ht(r);t.set(tt,n.cache,o),await e.hooks.callHook("rollup:build",e,n);const i=new Map;for(const s of r.output){const{output:a}=await n.write(s),l=new Set,c=a.filter(p=>p.type==="chunk");for(const p of c){l.add(p.fileName);for(const u of p.imports)e.usedImports.add(u);p.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(p.code,"utf8"),chunks:p.imports.filter(u=>c.find(g=>g.fileName===u)),exports:p.exports,modules:Object.entries(p.modules).map(([u,g])=>({bytes:g.renderedLength,id:u})),path:p.fileName,type:"entry"})}const d=a.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 l)e.usedImports.delete(p)}e.buildEntries.push(...i.values())},"build");var gi=Object.defineProperty,oe=m((e,t)=>gi(e,"name",{value:t,configurable:!0}),"a$7");const ot="rollup-dts.json",re=oe(async(e,t,o)=>{if(e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer){e.logger.info({message:"Using isolated declaration transformer to generate declaration files...",prefix:"dts"});return}const r=await Gt(e,t);if(await e.hooks.callHook("rollup:dts:options",e,r),Object.keys(r.input).length===0)return;r.cache=t.get(ot,o);const n=await ht(r);t.set(ot,n.cache,o),await e.hooks.callHook("rollup:dts:build",e,n),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await n.write({chunkFileNames:oe(i=>R(i,"d.cts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await n.write({chunkFileNames:oe(i=>R(i,"d.mts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),e.options.declaration==="compatible"&&await n.write({chunkFileNames:oe(i=>R(i,"d.mjs"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var yi=Object.defineProperty,hi=m((e,t)=>yi(e,"name",{value:t,configurable:!0}),"y$2");const vi=hi((e,t,o)=>e.reduce((r,n)=>{const i=n[t],s=n[o];return r[i]||(r[i]={}),r[i][s]||(r[i][s]=[]),r[i][s].push(n),r},{}),"groupByKeys");var bi=Object.defineProperty,de=m((e,t)=>bi(e,"name",{value:t,configurable:!0}),"j$1");const wi=de((e,t)=>{const o=de(s=>O(t.options.rootDir,$(t.options.outDir,s)),"rPath");let r=!1;const n=[],i=t.buildEntries.filter(s=>s.type==="entry");if(i.length>0){e.raw(`Entries:
54
+ ↳ 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"),Ze=new Map,ke=new Map,Kt=D((e,t,o)=>{const r=D(i=>{for(const[s,a]of Object.entries(t))if(i.startsWith(s))return i.replace(s,a)},"findAlias"),n=Jt(e.tsconfig,!1);return{external(i){const s=r(i);s&&(i=s);const a=xt(i);if(De(e.options.externals,a)||De(e.options.externals,i))return!0;const{pkg:l}=e;if(i.startsWith(".")||gt(i)||/src[/\\]/.test(i)||l.name&&i.startsWith(l.name))return!1;if(l.imports)for(const[c,d]of Object.entries(l.imports)){if(c===i)return!1;if(c.includes("*")){let p;ke.has(c)?p=ke.get(c):(p=Ne(b(e.options.rootDir,d.replace("/*","")),{withFileTypes:!0}).filter(u=>u.isFile()).map(u=>u.name),ke.set(c,p));for(const u of p)if(u.replace(J,"")===i.replace(J,"").replace("#",""))return!1}}if(n){for(const{find:c}of n)if(c.test(i))return e.logger.debug({message:`Resolved alias ${i} to ${c.source}`,prefix:o}),!1}return Ze.has(i)||e.logger.info({message:'Inlined implicit external "'+k(i)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),Ze.set(i,!0),!1},input:Object.fromEntries(e.options.entries.map(i=>[i.name,$(e.options.rootDir,i.input)])),logLevel:e.options.debug?"debug":"info",onLog:D((i,s)=>{let a=s.message;switch(s.stack&&(a=`${a}
55
+ ${s.stack}`),i){case"info":{e.logger.info({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")})}},"onLog"),onwarn(i,s){qt(i,e)||i.code||s(i)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),Ht=D(async(e,t)=>{const o=Ie(e,"build");let r;e.options.rollup.resolve&&(r=E(bt({...e.options.rollup.resolve}),t));const n=e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:oi(e.dependencyGraphMap,e.buildEntries),preserveModules:!1};return{...Kt(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:D(i=>R(i,"cjs"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:D(i=>Qe(i,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...n},e.options.emitESM&&{chunkFileNames:D(i=>R(i,"mjs"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:D(i=>Qe(i,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...n}].filter(Boolean),plugins:Ut([E(Mt(),t),E(Vt(),t),e.tsconfig&&E(Wt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&E(Bt(e.tsconfig,e.logger),t),e.options.rollup.replace&&wt({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&vt({customResolver:r,...e.options.rollup.alias,entries:o}),r,e.options.rollup.polyfillNode&&Po({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&Nt({...e.options.rollup.json}),xr(),e.options.rollup.wasm&&No(e.options.rollup.wasm),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&Xr(b(e.options.rootDir,e.options.sourceDir),e.options.isolatedDeclarationTransformer,e.options.declaration,!!e.options.rollup.cjsInterop,e.options.rollup.isolatedDeclarations),e.options.transformer(ui(e.options.transformerName,e)),E(kn({directiveRegex:/^['|"](use (\w+))['|"]$/,...e.options.rollup.preserveDirectives,logger:e.logger}),t),e.options.rollup.shebang&&Pn(e.options.entries.filter(i=>i.executable).map(i=>i.name).filter(Boolean),e.options.rollup.shebang),e.options.cjsInterop&&e.options.emitCJS&&Ot({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Wr(),e.options.rollup.dynamicVars&&Oo(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&E(So({sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{name:"packem:preserve-dynamic-imports",renderDynamicImport(){return{left:"import(",right:")"}}},e.options.cjsInterop&&e.options.rollup.shim&&Jr(e.pkg,e.options.rollup.shim),e.options.rollup.raw&&E(Dn(e.options.rollup.raw),t),e.options.rollup.jsxRemoveAttributes&&E(rn({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),t),e.options.rollup.metafile&&un({outDir:$(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&Tr(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&Tt({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),wn(),e.options.emitCJS&&e.mode==="build"&&e.options.declaration==="compatible"&&e.options.rollup.node10Compatibility&&fn(e.logger,e.options.entries,e.options.outDir,e.options.rootDir,e.options.rollup.node10Compatibility.writeToPackageJson?"file":"console",e.options.rollup.node10Compatibility.typeScriptVersion??"*"),e.options.analyze&&e.options.rollup.visualizer!==!1&&Co({brotliSize:!0,gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,...e.options.rollup.visualizer,filename:"packem-bundle-analyze.html",title:"Packem Visualizer"})].filter(Boolean),e.options.rollup.plugins)}},"getRollupOptions"),di=D(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"),mi=ur(di),Gt=D(async(e,t)=>{const o=Ie(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 i;e.options.rollup.resolve&&(i=E(bt({...e.options.rollup.resolve}),t));const s="dts-plugin:"+process.pid+e.tsconfig.path;return{...Kt(e,o,"dts"),onwarn(a,l){qt(a,e)||a.code!=="EMPTY_BUNDLE"&&l(a)},output:[e.options.emitCJS&&{chunkFileNames:D(a=>R(a,"d.cts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:D(a=>R(a,"d.mts"),"chunkFileNames"),dir:$(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:D(a=>R(a,"d.ts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:Ut([E(Mt(),t),E(Vt(),t),e.options.rollup.json&&Nt({...e.options.rollup.json}),r,e.tsconfig&&E(Wt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&E(Bt(e.tsconfig,e.logger),t),e.options.rollup.replace&&wt({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&vt({customResolver:i,...e.options.rollup.alias,entries:o}),i,await mi(s)(e),e.options.cjsInterop&&e.options.emitCJS&&Ot({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&E(Vn(e.options.rollup.patchTypes,e.logger),t),Cn(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Tt({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean),e.options.rollup.plugins)}},"getRollupDtsOptions");var fi=Object.defineProperty,gi=m((e,t)=>fi(e,"name",{value:t,configurable:!0}),"f$4");const et="rollup-build.json",xe=gi(async(e,t,o)=>{const r=await Ht(e,t);if(await e.hooks.callHook("rollup:options",e,r),Object.keys(r.input).length===0)return;(!e.options.rollup.isolatedDeclarations||!e.options.isolatedDeclarationTransformer)&&(r.cache=t.get(et,o));const n=await ht(r);t.set(et,n.cache,o),await e.hooks.callHook("rollup:build",e,n);const i=new Map;for(const s of r.output){const{output:a}=await n.write(s),l=new Set,c=a.filter(p=>p.type==="chunk");for(const p of c){l.add(p.fileName);for(const u of p.imports)e.usedImports.add(u);p.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(p.code,"utf8"),chunks:p.imports.filter(u=>c.find(g=>g.fileName===u)),exports:p.exports,modules:Object.entries(p.modules).map(([u,g])=>({bytes:g.renderedLength,id:u})),path:p.fileName,type:"entry"})}const d=a.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 l)e.usedImports.delete(p)}e.buildEntries.push(...i.values())},"build");var yi=Object.defineProperty,oe=m((e,t)=>yi(e,"name",{value:t,configurable:!0}),"a$7");const tt="rollup-dts.json",re=oe(async(e,t,o)=>{if(e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer){e.logger.info({message:"Using isolated declaration transformer to generate declaration files...",prefix:"dts"});return}const r=await Gt(e,t);if(await e.hooks.callHook("rollup:dts:options",e,r),Object.keys(r.input).length===0)return;r.cache=t.get(tt,o);const n=await ht(r);t.set(tt,n.cache,o),await e.hooks.callHook("rollup:dts:build",e,n),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await n.write({chunkFileNames:oe(i=>R(i,"d.cts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await n.write({chunkFileNames:oe(i=>R(i,"d.mts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),e.options.declaration==="compatible"&&await n.write({chunkFileNames:oe(i=>R(i,"d.mjs"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var hi=Object.defineProperty,vi=m((e,t)=>hi(e,"name",{value:t,configurable:!0}),"y$2");const bi=vi((e,t,o)=>e.reduce((r,n)=>{const i=n[t],s=n[o];return r[i]||(r[i]={}),r[i][s]||(r[i][s]=[]),r[i][s].push(n),r},{}),"groupByKeys");var wi=Object.defineProperty,de=m((e,t)=>wi(e,"name",{value:t,configurable:!0}),"j$1");const $i=de((e,t)=>{const o=de(s=>O(t.options.rootDir,$(t.options.outDir,s)),"rPath");let r=!1;const n=[],i=t.buildEntries.filter(s=>s.type==="entry");if(i.length>0){e.raw(`Entries:
56
56
  `);for(const s of i){let a=s.bytes??0;for(const c of s.chunks??[])a+=t.buildEntries.find(d=>d.path===c)?.bytes??0;let l=` ${N(o(s.path))} (${["total size: "+k(T(a)),s.bytes&&"chunk size: "+k(T(s.bytes))].filter(Boolean).join(", ")})`;if(l+=s.exports?.length?`
57
57
  exports: `+I(s.exports.join(", ")):"",s.chunks?.length&&(l+=`
58
58
  ${s.chunks.map(c=>{const d=t.buildEntries.find(p=>p.path===c)??{};return I(" └─ "+o(c)+N(d.bytes?" ("+T(d?.bytes)+")":""))}).join(`
@@ -69,25 +69,25 @@ ${s.chunks.map(c=>{const d=t.buildEntries.find(p=>p.path===c)??{};return I("
69
69
  └─ `)+N(o(a.path))+" (total size: "+k(T(a.bytes??0))+")");s+=`
70
70
 
71
71
  `,e.raw(s)}return r&&e.raw("Σ Total dist size (byte size):",k(T(t.buildEntries.reduce((s,a)=>s+(a.bytes??0),0))),`
72
- `),r},"showSizeInformation"),$i=de((e,t)=>{const o=vi(e.options.entries,"environment","runtime"),r=[];for(const[n,i]of Object.entries(o))for(const[s,a]of Object.entries(i)){const l={...e};!e.options.dtsOnly&&(n!=="undefined"||s!=="undefined")&&e.logger.info("Preparing build for "+(n==="undefined"?"":k(n)+" environment"+(s==="undefined"?"":" with "))+(s==="undefined"?"":k(s)+" 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)}),l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","EdgeRuntime"].join(".")]:JSON.stringify(s==="edge-light")}):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let c="";n!=="undefined"&&(c+=n+"/"),s!=="undefined"&&(c+=s+"/");let d=!1;l.options.minify!==void 0&&(d=l.options.minify),n==="development"?d=!1:n==="production"&&(d=!0);const p=[],u=[],g=[],y=[];for(const f of a)f.cjs&&f.esm?p.push(f):f.cjs?g.push(f):f.esm?u.push(f):f.declaration&&y.push(f);if(p.length>0){const f={...l,options:{...l.options,emitCJS:!0,emitESM:!0,entries:p,minify:d}};if(e.options.dtsOnly||r.push(xe(f,t,c)),e.options.declaration){const h=f.options.entries.filter(w=>w.declaration);h.length>0&&r.push(re({...f,options:{...f.options,entries:h}},t,c))}}if(u.length>0){const f={...l,options:{...l.options,emitCJS:!1,emitESM:!0,entries:u,minify:d}};if(e.options.dtsOnly||r.push(xe(f,t,c)),e.options.declaration){const h=f.options.entries.filter(w=>w.declaration);h.length>0&&r.push(re({...f,options:{...f.options,entries:h}},t,c))}}if(g.length>0){const f={...l,options:{...l.options,emitCJS:!0,emitESM:!1,entries:g,minify:d}};if(e.options.dtsOnly||r.push(xe(f,t,c)),e.options.declaration){const h=f.options.entries.filter(w=>w.declaration);h.length>0&&r.push(re({...f,options:{...f.options,entries:h}},t,c))}}if(l.options.declaration&&y.length>0){const f={...l,options:{...l.options,emitCJS:!1,emitESM:!1,entries:y,minify:d}};r.push(re(f,t,c))}}return r.filter(Boolean)},"prepareRollupConfig"),ji=de(async(e,t)=>{await e.hooks.callHook("build:before",e),await Promise.all($i(e,t)),e.logger.success(uo(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const o of yo(b(e.options.rootDir,e.options.outDir))){let r=e.buildEntries.find(n=>b(e.options.rootDir,e.options.outDir,n.path)===o.path);if(r||(r={chunk:!0,path:o.path},e.buildEntries.push(r)),!r.bytes){const n=await dt($(e.options.rootDir,e.options.outDir,o.path));r.bytes=n.size}}return await e.hooks.callHook("build:done",e),wi(e.logger,e)},"build");var ki=Object.defineProperty,xi=m((e,t)=>ki(e,"name",{value:t,configurable:!0}),"r$5");const j=xi((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Ei=Object.defineProperty,Xt=m((e,t)=>Ei(e,"name",{value:t,configurable:!0}),"t$4");const me=Xt(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Oe=Xt((e,t,o,r)=>{if(e==="module-sync")return"esm";if(r){const s=me(r);if(s)return s}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[n,...i]=t;return Oe(n,i,o,r)},"inferExportType");var Di=Object.defineProperty,Si=m((e,t)=>Di(e,"name",{value:t,configurable:!0}),"y$1");const Oi=new Set(["electron","import","require","node","node-addons","default","types","deno","browser","module-sync","bun","workerd",...Te,...pe]),Ae=Si((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=me(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}]}if(typeof e=="object"){const n=Object.entries(e).filter(([s])=>!s.endsWith(".json"));let i=[];for(const[s,a]of n)if(typeof a=="string"){let l={};Number.isInteger(+s)?l={exportKey:"*"}:s.startsWith("./")?l={exportKey:s.replace("./","")}:l={exportKey:s==="."?".":"*",subKey:s},i.push({...l,file:a,key:"exports",type:Oe(s,r,t,a)})}else if(typeof a=="object"&&a!==null)for(const[l,c]of Object.entries(a)){if(o===!1&&l==="types")return[];const d=Number.isInteger(+s)?l:s;typeof c=="string"?i.push({exportKey:d.replace("./",""),file:c,key:"exports",...Oi.has(l)?{subKey:l}:{},type:Oe(l,r,t,c)}):i=[...i,...Ae({[d]:c},t,o,[...r,l])]}return i}return[]},"extractExportFilenames");var Ni=Object.defineProperty,be=m((e,t)=>Ni(e,"name",{value:t,configurable:!0}),"c$3");const Pi=be((e,t)=>e.key==="exports"&&e.subKey===C?C:e.key==="exports"&&e.subKey===Q?Q:t,"getEnvironment"),ne=be((e,t,o,r,n,i,s)=>{const a=Pi(n,i.environment);let l="node";for(const p of Te)if(n.file.includes("."+p+".")||n.subKey===p){l=p;break}let c=e.find(p=>p.input===t&&p.environment===a&&p.runtime===l);c===void 0?c=e[e.push({environment:a,exportKey:new Set([n.exportKey].filter(Boolean)),input:t,runtime:l})-1]:c.exportKey&&n.exportKey&&c.exportKey.add(n.exportKey),s&&(c.isGlob=!0),o&&(c.outDir=r),n.isExecutable?(c.executable=!0,c.declaration=!1,n.type==="cjs"?c.cjs=!0:n.type==="esm"&&(c.esm=!0)):(/\.d\.[mc]?ts$/.test(n.file)&&i.options.declaration!==!1&&(c.declaration=i.options.declaration),n.type==="cjs"?c.cjs=!0:n.type==="esm"&&(c.esm=!0));const d=n.file.replace(ft(n.file),"").replace(new RegExp(`^./${i.options.outDir.replace(/^\.\//,"")}/`),"");pe.has(n.subKey)&&!t.includes(d)&&(c.fileAlias=d)},"createOrUpdateEntry");let rt=!1;const nt=be(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"),Ci=be((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 i=Ae(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=me(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"}".`);i.push({file:l,isExecutable:!0,key:"bin",type:c??n})}}e.main&&i.push({file:e.main,key:"main",type:me(e.main)??n}),e.module&&i.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(nt(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),i.push({file:e.types??e.typings,key:"types"}));const s=[];for(const a of i){o.options.declaration===void 0&&(a.key==="types"||a.subKey==="types")&&(o.options.declaration=a.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&a.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&a.type==="esm"&&(o.options.emitESM=!0);const l=a.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const d=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),p="(?<=/|$)",u=c?"":"\\.\\w+$";if(a.file.includes("/*")&&a.key==="exports"){rt||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),rt=!0);const h=[],w=new RegExp(p+d.replace("*","(.*)")+u),x=new RegExp(p+d.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+u);for(const v of t)(w.test(v)||pe.has(a.subKey)&&x.test(v))&&h.push(v);if(h.length===0){r.push(`Could not find entrypoint for \`${a.file}\``);continue}for(const v of h)ne(s,v,c,l,a,o,!0);continue}const g=new RegExp(p+d+u);let y=t.find(h=>g.test(h));if(pe.has(a.subKey)&&y===void 0){const h=new RegExp(p+d.replace(/(.*)\.[^.]*$/,"$1")+u);y=t.find(w=>h.test(w))}if(y===void 0){S($(o.options.rootDir,a.file))||r.push(`Could not find entrypoint for \`${a.file}\``);continue}(y.endsWith(".ts")||y.endsWith(".cts")||y.endsWith(".mts"))&&S(y)&&nt(o);const f=le(y.replace(J,""));S(f+".cts")&&S(f+".mts")?(ne(s,f+".cts",c,l,{...a,type:"cjs"},o,!1),ne(s,f+".mts",c,l,{...a,type:"esm"},o,!1)):ne(s,y,c,l,a,o,!1)}return{entries:s,warnings:r}},"inferEntries");var _i=Object.defineProperty,Ti=m((e,t)=>_i(e,"name",{value:t,configurable:!0}),"o$3");const Ii=Ti((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 Mi=Object.defineProperty,Ai=m((e,t)=>Mi(e,"name",{value:t,configurable:!0}),"t$3");const Ri={hooks:{"build:prepare":Ai(function(e){if(e.options.entries.length>0)return;const t=b(e.options.rootDir,e.options.sourceDir);if(!ut(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=ho(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(r.publishConfig),r=Ii(r,e.options.declaration));const n=Ci(r,o,e);for(const i of n.warnings)j(e,i);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:",k(e.options.entries.map(i=>i.fileAlias?N(i.fileAlias)+" => "+N(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):N(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),I([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))},"build:prepare")}};var Fi=Object.defineProperty,Ji=m((e,t)=>Fi(e,"name",{value:t,configurable:!0}),"t$2");const Bi=Ji(async(e,t)=>{if(e==="auto")e=Ri;else{if(e==="none")return{};typeof e=="string"&&(e=await t.import(e)||{})}return typeof e=="function"&&(e=e()),e},"resolvePreset");var Li=Object.defineProperty,Wi=m((e,t)=>Li(e,"name",{value:t,configurable:!0}),"j");const Vi=Wi(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,o=[],r=JSON.stringify({...e.options.jiti,alias:{...Me(e,"jit"),...e.options.jiti.alias},transformOptions:{...e.options.jiti.transformOptions,babel:{...e.options.jiti.transformOptions?.babel,plugins:"__$BABEL_PLUGINS"}}},null,2).replace('"__$BABEL_PLUGINS"',Array.isArray(t)?"["+t.map((n,i)=>{if(Array.isArray(n)){const[s,...a]=n;return o.push(s),"["+["plugin"+i,...a.map(l=>JSON.stringify(l))].join(", ")+"]"}return o.push(n),"plugin"+i}).join(",")+"]":"[]");for(const n of e.options.entries){const i=$(e.options.rootDir,e.options.outDir,n.name),s=Ce(e.jiti.esmResolve(n.input,{try:!0})??n.input),a=s.replace(J,""),l=Y(s),c=Cn(l);let d=[];try{d=await Fo(s,{extensions:_e})}catch(u){j(e,`Cannot analyze ${s} for exports: ${u.toString()}`);return}const p=d.includes("default")||d.length===0;if(e.options.emitESM){const u=O(z(i),await We("jiti",{conditions:["node","import"],url:import.meta.url})),g=a+".d.mts";A(`${i}.mjs`,c+['import { createJiti } from "'+u+'";',...o.map((y,f)=>"import plugin"+f+' from "'+y+'";'),"","const jiti = createJiti(import.meta.url, "+r+");","",'/** @type {import("'+g+'")} */','const _module = await jiti.import("'+s+'");',p?`
72
+ `),r},"showSizeInformation"),ji=de((e,t)=>{const o=bi(e.options.entries,"environment","runtime"),r=[];for(const[n,i]of Object.entries(o))for(const[s,a]of Object.entries(i)){const l={...e};!e.options.dtsOnly&&(n!=="undefined"||s!=="undefined")&&e.logger.info("Preparing build for "+(n==="undefined"?"":k(n)+" environment"+(s==="undefined"?"":" with "))+(s==="undefined"?"":k(s)+" 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)}),l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","EdgeRuntime"].join(".")]:JSON.stringify(s==="edge-light")}):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let c="";n!=="undefined"&&(c+=n+"/"),s!=="undefined"&&(c+=s+"/");let d=!1;l.options.minify!==void 0&&(d=l.options.minify),n==="development"?d=!1:n==="production"&&(d=!0);const p=[],u=[],g=[],y=[];for(const f of a)f.cjs&&f.esm?p.push(f):f.cjs?g.push(f):f.esm?u.push(f):f.declaration&&y.push(f);if(p.length>0){const f={...l,options:{...l.options,emitCJS:!0,emitESM:!0,entries:p,minify:d}};if(e.options.dtsOnly||r.push(xe(f,t,c)),e.options.declaration){const h=f.options.entries.filter(w=>w.declaration);h.length>0&&r.push(re({...f,options:{...f.options,entries:h}},t,c))}}if(u.length>0){const f={...l,options:{...l.options,emitCJS:!1,emitESM:!0,entries:u,minify:d}};if(e.options.dtsOnly||r.push(xe(f,t,c)),e.options.declaration){const h=f.options.entries.filter(w=>w.declaration);h.length>0&&r.push(re({...f,options:{...f.options,entries:h}},t,c))}}if(g.length>0){const f={...l,options:{...l.options,emitCJS:!0,emitESM:!1,entries:g,minify:d}};if(e.options.dtsOnly||r.push(xe(f,t,c)),e.options.declaration){const h=f.options.entries.filter(w=>w.declaration);h.length>0&&r.push(re({...f,options:{...f.options,entries:h}},t,c))}}if(l.options.declaration&&y.length>0){const f={...l,options:{...l.options,emitCJS:!1,emitESM:!1,entries:y,minify:d}};r.push(re(f,t,c))}}return r.filter(Boolean)},"prepareRollupConfig"),ki=de(async(e,t)=>{await e.hooks.callHook("build:before",e),await Promise.all(ji(e,t)),e.logger.success(uo(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const o of yo(b(e.options.rootDir,e.options.outDir))){let r=e.buildEntries.find(n=>b(e.options.rootDir,e.options.outDir,n.path)===o.path);if(r||(r={chunk:!0,path:o.path},e.buildEntries.push(r)),!r.bytes){const n=await ut($(e.options.rootDir,e.options.outDir,o.path));r.bytes=n.size}}return await e.hooks.callHook("build:done",e),$i(e.logger,e)},"build");var xi=Object.defineProperty,Ei=m((e,t)=>xi(e,"name",{value:t,configurable:!0}),"r$5");const j=Ei((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Di=Object.defineProperty,Xt=m((e,t)=>Di(e,"name",{value:t,configurable:!0}),"t$4");const me=Xt(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Oe=Xt((e,t,o,r)=>{if(e==="module-sync")return"esm";if(r){const s=me(r);if(s)return s}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[n,...i]=t;return Oe(n,i,o,r)},"inferExportType");var Si=Object.defineProperty,Oi=m((e,t)=>Si(e,"name",{value:t,configurable:!0}),"y$1");const Ni=new Set(["electron","import","require","node","node-addons","default","types","deno","browser","module-sync","bun","workerd",..._e,...pe]),Me=Oi((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=me(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}]}if(typeof e=="object"){const n=Object.entries(e).filter(([s])=>!s.endsWith(".json"));let i=[];for(const[s,a]of n)if(typeof a=="string"){let l={};Number.isInteger(+s)?l={exportKey:"*"}:s.startsWith("./")?l={exportKey:s.replace("./","")}:l={exportKey:s==="."?".":"*",subKey:s},i.push({...l,file:a,key:"exports",type:Oe(s,r,t,a)})}else if(typeof a=="object"&&a!==null)for(const[l,c]of Object.entries(a)){if(o===!1&&l==="types")continue;const d=Number.isInteger(+s)?l:s;typeof c=="string"?i.push({exportKey:d.replace("./",""),file:c,key:"exports",...Ni.has(l)?{subKey:l}:{},type:Oe(l,r,t,c)}):i=[...i,...Me({[d]:c},t,o,[...r,l])]}return i}return[]},"extractExportFilenames");var Pi=Object.defineProperty,be=m((e,t)=>Pi(e,"name",{value:t,configurable:!0}),"c$3");const Ci=be((e,t)=>e.key==="exports"&&e.subKey===C?C:e.key==="exports"&&e.subKey===Q?Q:t,"getEnvironment"),ne=be((e,t,o,r,n,i,s)=>{const a=Ci(n,i.environment);let l="node";for(const p of _e)if(n.file.includes("."+p+".")||n.subKey===p){l=p;break}let c=e.find(p=>p.input===t&&p.environment===a&&p.runtime===l);c===void 0?c=e[e.push({environment:a,exportKey:new Set([n.exportKey].filter(Boolean)),input:t,runtime:l})-1]:c.exportKey&&n.exportKey&&c.exportKey.add(n.exportKey),s&&(c.isGlob=!0),o&&(c.outDir=r),n.isExecutable?(c.executable=!0,c.declaration=!1,n.type==="cjs"?c.cjs=!0:n.type==="esm"&&(c.esm=!0)):(/\.d\.[mc]?ts$/.test(n.file)&&i.options.declaration!==!1&&(c.declaration=i.options.declaration),n.type==="cjs"?c.cjs=!0:n.type==="esm"&&(c.esm=!0));const d=n.file.replace(ft(n.file),"").replace(new RegExp(`^./${i.options.outDir.replace(/^\.\//,"")}/`),"");pe.has(n.subKey)&&!t.includes(d)&&(c.fileAlias=d)},"createOrUpdateEntry");let ot=!1;const rt=be(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"),_i=be((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 i=Me(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=me(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"}".`);i.push({file:l,isExecutable:!0,key:"bin",type:c??n})}}e.main&&i.push({file:e.main,key:"main",type:me(e.main)??n}),e.module&&i.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(rt(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),i.push({file:e.types??e.typings,key:"types"}));const s=[];for(const a of i){o.options.declaration===void 0&&(a.key==="types"||a.subKey==="types")&&(o.options.declaration=a.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&a.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&a.type==="esm"&&(o.options.emitESM=!0);const l=a.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const d=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),p="(?<=/|$)",u=c?"":"\\.\\w+$";if(a.file.includes("/*")&&a.key==="exports"){ot||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),ot=!0);const h=[],w=new RegExp(p+d.replace("*","(.*)")+u),x=new RegExp(p+d.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+u);for(const v of t)(w.test(v)||pe.has(a.subKey)&&x.test(v))&&h.push(v);if(h.length===0){r.push(`Could not find entrypoint for \`${a.file}\``);continue}for(const v of h)ne(s,v,c,l,a,o,!0);continue}const g=new RegExp(p+d+u);let y=t.find(h=>g.test(h));if(pe.has(a.subKey)&&y===void 0){const h=new RegExp(p+d.replace(/(.*)\.[^.]*$/,"$1")+u);y=t.find(w=>h.test(w))}if(y===void 0){S($(o.options.rootDir,a.file))||r.push(`Could not find entrypoint for \`${a.file}\``);continue}(y.endsWith(".ts")||y.endsWith(".cts")||y.endsWith(".mts"))&&S(y)&&rt(o);const f=le(y.replace(J,""));S(f+".cts")&&S(f+".mts")?(ne(s,f+".cts",c,l,{...a,type:"cjs"},o,!1),ne(s,f+".mts",c,l,{...a,type:"esm"},o,!1)):ne(s,y,c,l,a,o,!1)}return{entries:s,warnings:r}},"inferEntries");var Ti=Object.defineProperty,Ii=m((e,t)=>Ti(e,"name",{value:t,configurable:!0}),"o$3");const Mi=Ii((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 Ai=Object.defineProperty,Ri=m((e,t)=>Ai(e,"name",{value:t,configurable:!0}),"t$3");const Fi={hooks:{"build:prepare":Ri(function(e){if(e.options.entries.length>0)return;const t=b(e.options.rootDir,e.options.sourceDir);if(!pt(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=ho(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(r.publishConfig),r=Mi(r,e.options.declaration));const n=_i(r,o,e);for(const i of n.warnings)j(e,i);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:",k(e.options.entries.map(i=>i.fileAlias?N(i.fileAlias)+" => "+N(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):N(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),I([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))},"build:prepare")}};var Ji=Object.defineProperty,Bi=m((e,t)=>Ji(e,"name",{value:t,configurable:!0}),"t$2");const Li=Bi(async(e,t)=>{if(e==="auto")e=Fi;else{if(e==="none")return{};typeof e=="string"&&(e=await t.import(e)||{})}return typeof e=="function"&&(e=e()),e},"resolvePreset");var Wi=Object.defineProperty,Vi=m((e,t)=>Wi(e,"name",{value:t,configurable:!0}),"j");const zi=Vi(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,o=[],r=JSON.stringify({...e.options.jiti,alias:{...Ie(e,"jit"),...e.options.jiti.alias},transformOptions:{...e.options.jiti.transformOptions,babel:{...e.options.jiti.transformOptions?.babel,plugins:"__$BABEL_PLUGINS"}}},null,2).replace('"__$BABEL_PLUGINS"',Array.isArray(t)?"["+t.map((n,i)=>{if(Array.isArray(n)){const[s,...a]=n;return o.push(s),"["+["plugin"+i,...a.map(l=>JSON.stringify(l))].join(", ")+"]"}return o.push(n),"plugin"+i}).join(",")+"]":"[]");for(const n of e.options.entries){const i=$(e.options.rootDir,e.options.outDir,n.name),s=Fo(e.jiti.esmResolve(n.input,{try:!0})??n.input),a=s.replace(J,""),l=Y(s),c=_n(l);let d=[];try{d=await Jo(s,{extensions:Ce})}catch(u){j(e,`Cannot analyze ${s} for exports: ${u.toString()}`);return}const p=d.includes("default")||d.length===0;if(e.options.emitESM){const u=O(z(i),await Le("jiti",{conditions:["node","import"],url:import.meta.url})),g=a+".d.mts";A(`${i}.mjs`,c+['import { createJiti } from "'+u+'";',...o.map((y,f)=>"import plugin"+f+' from "'+y+'";'),"","const jiti = createJiti(import.meta.url, "+r+");","",'/** @type {import("'+g+'")} */','const _module = await jiti.import("'+s+'");',p?`
73
73
  export default _module;`:"",...d.filter(y=>y!=="default").map(y=>`export const ${y} = _module.${y};`)].join(`
74
74
  `)),e.options.declaration&&A(`${i}.d.mts`,'export * from "'+g+`";
75
- `+(p?'export { default } from "'+g+'";':""))}if(e.options.emitCJS){const u=O(z(i),await We("jiti",{conditions:["node","require"],url:import.meta.url})),g=a+".d.cts";A(`${i}.cjs`,c+['const { createJiti } = require("'+u+'");',...o.map((y,f)=>"const plugin"+f+" = require("+JSON.stringify(y)+")"),"","const jiti = createJiti(__filename, "+r+");","",'/** @type {import("'+g+'")} */','module.exports = jiti("'+s+'")'].join(`
75
+ `+(p?'export { default } from "'+g+'";':""))}if(e.options.emitCJS){const u=O(z(i),await Le("jiti",{conditions:["node","require"],url:import.meta.url})),g=a+".d.cts";A(`${i}.cjs`,c+['const { createJiti } = require("'+u+'");',...o.map((y,f)=>"const plugin"+f+" = require("+JSON.stringify(y)+")"),"","const jiti = createJiti(__filename, "+r+");","",'/** @type {import("'+g+'")} */','module.exports = jiti("'+s+'")'].join(`
76
76
  `)),e.options.declaration&&A(i+".d.cts",'export * from "'+g+`";
77
- `+(p?'export { default } from "'+g+'";':""))}c&&(await Se(`${i}.cjs`),await Se(`${i}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var zi=Object.defineProperty,Re=m((e,t)=>zi(e,"name",{value:t,configurable:!0}),"i$3");const Ui=Re(e=>{const{message:t,name:o="Error",stack:r}=e;if(!r)return r;const n=`${o}: ${t}
78
- `;return r.startsWith(n)?r.slice(n.length):r},"extractStack"),qi=Re(e=>`
77
+ `+(p?'export { default } from "'+g+'";':""))}c&&(await Se(`${i}.cjs`),await Se(`${i}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Ui=Object.defineProperty,Ae=m((e,t)=>Ui(e,"name",{value:t,configurable:!0}),"i$3");const qi=Ae(e=>{const{message:t,name:o="Error",stack:r}=e;if(!r)return r;const n=`${o}: ${t}
78
+ `;return r.startsWith(n)?r.slice(n.length):r},"extractStack"),Ki=Ae(e=>`
79
79
  ${e.replaceAll(/^\n|\n$/g,"")}
80
- `,"normalizeCodeFrame"),Yt=Re(e=>{const t=Ui(e);let o=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(o+=`
80
+ `,"normalizeCodeFrame"),Yt=Ae(e=>{const t=qi(e);let o=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(o+=`
81
81
  file: ${k(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(o+=`
82
- `+mo(qi(e.frame))),e.message=o,t!==void 0&&(e.stack=`${e.message}
83
- ${t}`)},"enhanceRollupError");var Ki=Object.defineProperty,Qt=m((e,t)=>Ki(e,"name",{value:t,configurable:!0}),"p");const fe="rollup-watch.json",it=Qt((e,t,o,r)=>{const n="watcher:"+o;e.on("change",(i,{event:s})=>{r.logger.info({message:`${k(O(".",i))} was ${s}d`,prefix:n})}),e.on("restart",()=>{r.logger.info({message:"Rebuilding "+o+"...",prefix:n})}),e.on("event",async i=>{switch(i.code){case"END":{r.logger.success({message:"Rebuild "+o+" finished",prefix:n});break}case"BUNDLE_START":{r.logger.info({message:k("build started..."),prefix:n});break}case"BUNDLE_END":{await i.result.close(),t.set(o==="bundle"?fe:"dts-"+fe,i.result.cache),r.logger.info({message:k(`built in ${i.duration+""}ms.`),prefix:n});break}case"ERROR":{Yt(i.error),r.logger.error({context:[i.error],message:"Rebuild "+o+" failed: "+i.error.message,prefix:n});break}}})},"watchHandler"),Hi=Qt(async(e,t)=>{const o=await Ht(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;(!e.options.rollup.isolatedDeclarations||!e.options.isolatedDeclarationTransformer)&&(o.cache=t.get(fe)),e.options.rollup.watch&&typeof o.watch=="object"&&o.watch.include===void 0&&(o.watch={...o.watch,...e.options.rollup.watch},o.watch.include=[b(e.options.sourceDir,"**","*"),"package.json"],Array.isArray(e.options.rollup.watch.include)?o.watch.include=[...o.watch.include,...e.options.rollup.watch.include]:e.options.rollup.watch.include&&o.watch.include.push(e.options.rollup.watch.include),o.watch.chokidar={cwd:e.options.rootDir,...o.watch.chokidar,ignored:["**/.git/**","**/node_modules/**","**/test-results/**",...o.watch.chokidar?.ignored??[]]});const r=Be(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 i="Starting watchers for entries:";for(const s of n)i+=I(`
84
- └─ ${O(process.cwd(),s)}`);if(e.logger.info(i),it(r,t,"bundle",e),e.options.declaration){const s=await Gt(e,t);s.cache=t.get("dts-"+fe),await e.hooks.callHook("rollup:dts:options",e,s);const a=Be(s);await e.hooks.callHook("rollup:watch",e,a),it(a,t,"types",e)}},"watch");var Gi=Object.defineProperty,Xi=m((e,t)=>Gi(e,"name",{value:t,configurable:!0}),"m$4");const Yi=Xi(async(e,t,o,r)=>{if(t.length===0)return;const{format:n,marker:i,output:s,plugin:a,readmePath:l,...c}=e;if(n==="inline"&&l===void 0)throw new Error("The `readmePath` option is required when using the `inline` format.");const d=t.map(g=>g.input),p=await Uo.bootstrapWithPlugins({...c,compilerOptions:{allowJs:!0,declaration:!1,declarationMap:!1,esModuleInterop:!0,module:99,moduleResolution:100,noEmit:!0,noImplicitAny:!1,skipLibCheck:!0,sourceMap:!1,target:99,...c.compilerOptions},entryPoints:d,hideGenerator:!0,plugin:[...a??[],require.resolve("@ckeditor/typedoc-plugins/lib/module-fixer"),require.resolve("@ckeditor/typedoc-plugins/lib/symbol-fixer"),require.resolve("@ckeditor/typedoc-plugins/lib/interface-augmentation-fixer"),require.resolve("@ckeditor/typedoc-plugins/lib/event-inheritance-fixer"),require.resolve("@ckeditor/typedoc-plugins/lib/purge-private-api-docs"),require.resolve("@ckeditor/typedoc-plugins/lib/tag-error"),require.resolve("@ckeditor/typedoc-plugins/lib/tag-event"),require.resolve("@ckeditor/typedoc-plugins/lib/tag-observable"),require.resolve("typedoc-plugin-rename-defaults"),...n==="inline"||n==="markdown"?["typedoc-plugin-markdown"]:[]],...n==="inline"?{hideBreadcrumbs:!0,hidePageHeader:!0,navigation:!1,outputFileStrategy:"modules",useCodeBlocks:!0}:{}},[]),u=await p.convert();if(u&&(await(n==="json"?p.generateJson(u,o):p.generateDocs(u,o)),n==="inline")){if(i===void 0)throw new Error("The `marker` option is required when using the `inline` format.");const g=Ne(o,{withFileTypes:!0}).filter(f=>f.isFile());let y="";for(const f of g)f.name==="README.md"&&t.length>1||(y+=Y(b(o,f.name)).replaceAll(`<!-- ${i}`,`<!-- _REPLACE_${i}`).replaceAll("<!-- ${marker}",`<!-- _REPLACE_\\${i}`));if(y!==""){const f=Y(l),h=Ct(f,i,`
85
- `+y);if(!h){r.error({message:`Could not find the typedoc marker: <!-- ${i} --><!-- /${i} --> in ${l}`,prefix:"typedoc"});return}if(f===h)return;h&&A(l,h.replaceAll(`<!-- _REPLACE_${i}`,`<!-- ${i}`).replaceAll(`<!-- _REPLACE_\\${i}`,"<!-- ${marker}"),{overwrite:!0})}}},"generateReferenceDocumentation");var Qi=Object.defineProperty,Zi=m((e,t)=>Qi(e,"name",{value:t,configurable:!0}),"i$2");const st=Zi((e,t,o,r)=>{try{let n={};const i=b(t,"keystore.json");r&&S(i)&&(n=Pe(i)),n[e]===void 0&&(n[e]=new Date().toISOString()),ge(i,n,{overwrite:!0})}catch(n){o.debug({context:n,message:n.message,prefix:"cache-key-store"})}},"createOrUpdateKeyStorage");var es=Object.defineProperty,Zt=m((e,t)=>es(e,"name",{value:t,configurable:!0}),"s$4");const ts=Zt(e=>{try{JSON.parse(e)}catch{return!1}return!0},"isJson");let os=class{static{m(this,"g")}static{Zt(this,"FileCache")}#r;#e;#n;#t=!0;#o=new Map;constructor(t,o,r,n){this.#r=t,this.#n=r,o===void 0?n.debug({message:"Could not create cache directory.",prefix:"file-cache"}):(this.#e=o,n.debug({message:"Cache path is: "+this.#e,prefix:"file-cache"}))}set isEnabled(t){this.#t=t}has(t,o){return!this.#t||this.#e===void 0?!1:S(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(!S(r))return;const n=Y(r);if(ts(n)){const i=JSON.parse(n);return this.#o.set(r,i),i}return this.#o.set(r,n),n}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)),A(n,o,{overwrite:!0})}getFilePath(t,o){let r=t.replaceAll(le(this.#r),"");return r=r.replaceAll(":","-"),b(this.#e,this.#n,o?.replaceAll(":","-")??"",le(r))}};var rs=Object.defineProperty,ie=m((e,t)=>rs(e,"name",{value:t,configurable:!0}),"l$4");const ns=U,is=ie((e,t)=>{const{sideEffects:o}=t;let r;if(typeof o=="boolean")r=ie(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)r=ie(()=>!1,"hasSideEffects");else{const n=o.map(i=>i.includes("/")?i:`**/${i}`);r=ns(n,null,{resolve:e})}else r=ie(()=>null,"hasSideEffects");return r},"getPackageSideEffect");var ss=Object.defineProperty,as=m((e,t)=>ss(e,"name",{value:t,configurable:!0}),"n");const eo=as(e=>{const t=b(e,"package.json");if(!S(t))throw new Error("package.json not found at "+t);return{packageJson:kt(t),packageJsonPath:t}},"loadPackageJson");var ls=Object.defineProperty,cs=m((e,t)=>ls(e,"name",{value:t,configurable:!0}),"r$3");const at=cs((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
82
+ `+mo(Ki(e.frame))),e.message=o,t!==void 0&&(e.stack=`${e.message}
83
+ ${t}`)},"enhanceRollupError");var Hi=Object.defineProperty,Qt=m((e,t)=>Hi(e,"name",{value:t,configurable:!0}),"p");const fe="rollup-watch.json",nt=Qt((e,t,o,r)=>{const n="watcher:"+o;e.on("change",(i,{event:s})=>{r.logger.info({message:`${k(O(".",i))} was ${s}d`,prefix:n})}),e.on("restart",()=>{r.logger.info({message:"Rebuilding "+o+"...",prefix:n})}),e.on("event",async i=>{switch(i.code){case"END":{r.logger.success({message:"Rebuild "+o+" finished",prefix:n});break}case"BUNDLE_START":{r.logger.info({message:k("build started..."),prefix:n});break}case"BUNDLE_END":{await i.result.close(),t.set(o==="bundle"?fe:"dts-"+fe,i.result.cache),r.logger.info({message:k(`built in ${i.duration+""}ms.`),prefix:n});break}case"ERROR":{Yt(i.error),r.logger.error({context:[i.error],message:"Rebuild "+o+" failed: "+i.error.message,prefix:n});break}}})},"watchHandler"),Gi=Qt(async(e,t)=>{const o=await Ht(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;(!e.options.rollup.isolatedDeclarations||!e.options.isolatedDeclarationTransformer)&&(o.cache=t.get(fe)),e.options.rollup.watch&&typeof o.watch=="object"&&o.watch.include===void 0&&(o.watch={...o.watch,...e.options.rollup.watch},o.watch.include=[b(e.options.sourceDir,"**","*"),"package.json"],Array.isArray(e.options.rollup.watch.include)?o.watch.include=[...o.watch.include,...e.options.rollup.watch.include]:e.options.rollup.watch.include&&o.watch.include.push(e.options.rollup.watch.include),o.watch.chokidar={cwd:e.options.rootDir,...o.watch.chokidar,ignored:["**/.git/**","**/node_modules/**","**/test-results/**",...o.watch.chokidar?.ignored??[]]});const r=Je(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 i="Starting watchers for entries:";for(const s of n)i+=I(`
84
+ └─ ${O(process.cwd(),s)}`);if(e.logger.info(i),nt(r,t,"bundle",e),e.options.declaration){const s=await Gt(e,t);s.cache=t.get("dts-"+fe),await e.hooks.callHook("rollup:dts:options",e,s);const a=Je(s);await e.hooks.callHook("rollup:watch",e,a),nt(a,t,"types",e)}},"watch");var Xi=Object.defineProperty,Yi=m((e,t)=>Xi(e,"name",{value:t,configurable:!0}),"m$4");const Qi=Yi(async(e,t,o,r)=>{if(t.length===0)return;const{format:n,marker:i,output:s,plugin:a,readmePath:l,...c}=e;if(n==="inline"&&l===void 0)throw new Error("The `readmePath` option is required when using the `inline` format.");const d=t.map(g=>g.input),p=await qo.bootstrapWithPlugins({...c,compilerOptions:{allowJs:!0,declaration:!1,declarationMap:!1,esModuleInterop:!0,module:99,moduleResolution:100,noEmit:!0,noImplicitAny:!1,skipLibCheck:!0,sourceMap:!1,target:99,...c.compilerOptions},entryPoints:d,hideGenerator:!0,plugin:[...a??[],require.resolve("@ckeditor/typedoc-plugins/lib/module-fixer"),require.resolve("@ckeditor/typedoc-plugins/lib/symbol-fixer"),require.resolve("@ckeditor/typedoc-plugins/lib/interface-augmentation-fixer"),require.resolve("@ckeditor/typedoc-plugins/lib/event-inheritance-fixer"),require.resolve("@ckeditor/typedoc-plugins/lib/purge-private-api-docs"),require.resolve("@ckeditor/typedoc-plugins/lib/tag-error"),require.resolve("@ckeditor/typedoc-plugins/lib/tag-event"),require.resolve("@ckeditor/typedoc-plugins/lib/tag-observable"),require.resolve("typedoc-plugin-rename-defaults"),...n==="inline"||n==="markdown"?["typedoc-plugin-markdown"]:[]],...n==="inline"?{hideBreadcrumbs:!0,hidePageHeader:!0,navigation:!1,outputFileStrategy:"modules",useCodeBlocks:!0}:{}},[]),u=await p.convert();if(u&&(await(n==="json"?p.generateJson(u,o):p.generateDocs(u,o)),n==="inline")){if(i===void 0)throw new Error("The `marker` option is required when using the `inline` format.");const g=Ne(o,{withFileTypes:!0}).filter(f=>f.isFile());let y="";for(const f of g)f.name==="README.md"&&t.length>1||(y+=Y(b(o,f.name)).replaceAll(`<!-- ${i}`,`<!-- _REPLACE_${i}`).replaceAll("<!-- ${marker}",`<!-- _REPLACE_\\${i}`));if(y!==""){const f=Y(l),h=Ct(f,i,`
85
+ `+y);if(!h){r.error({message:`Could not find the typedoc marker: <!-- ${i} --><!-- /${i} --> in ${l}`,prefix:"typedoc"});return}if(f===h)return;h&&A(l,h.replaceAll(`<!-- _REPLACE_${i}`,`<!-- ${i}`).replaceAll(`<!-- _REPLACE_\\${i}`,"<!-- ${marker}"),{overwrite:!0})}}},"generateReferenceDocumentation");var Zi=Object.defineProperty,es=m((e,t)=>Zi(e,"name",{value:t,configurable:!0}),"i$2");const it=es((e,t,o,r)=>{try{let n={};const i=b(t,"keystore.json");r&&S(i)&&(n=Pe(i)),n[e]===void 0&&(n[e]=new Date().toISOString()),ge(i,n,{overwrite:!0})}catch(n){o.debug({context:n,message:n.message,prefix:"cache-key-store"})}},"createOrUpdateKeyStorage");var ts=Object.defineProperty,Zt=m((e,t)=>ts(e,"name",{value:t,configurable:!0}),"s$4");const os=Zt(e=>{try{JSON.parse(e)}catch{return!1}return!0},"isJson");let rs=class{static{m(this,"g")}static{Zt(this,"FileCache")}#r;#e;#n;#t=!0;#o=new Map;constructor(t,o,r,n){this.#r=t,this.#n=r,o===void 0?n.debug({message:"Could not create cache directory.",prefix:"file-cache"}):(this.#e=o,n.debug({message:"Cache path is: "+this.#e,prefix:"file-cache"}))}set isEnabled(t){this.#t=t}has(t,o){return!this.#t||this.#e===void 0?!1:S(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(!S(r))return;const n=Y(r);if(os(n)){const i=JSON.parse(n);return this.#o.set(r,i),i}return this.#o.set(r,n),n}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)),A(n,o,{overwrite:!0})}getFilePath(t,o){let r=t.replaceAll(le(this.#r),"");return r=r.replaceAll(":","-"),b(this.#e,this.#n,o?.replaceAll(":","-")??"",le(r))}};var ns=Object.defineProperty,ie=m((e,t)=>ns(e,"name",{value:t,configurable:!0}),"l$4");const is=U,ss=ie((e,t)=>{const{sideEffects:o}=t;let r;if(typeof o=="boolean")r=ie(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)r=ie(()=>!1,"hasSideEffects");else{const n=o.map(i=>i.includes("/")?i:`**/${i}`);r=is(n,null,{resolve:e})}else r=ie(()=>null,"hasSideEffects");return r},"getPackageSideEffect");var as=Object.defineProperty,ls=m((e,t)=>as(e,"name",{value:t,configurable:!0}),"n");const eo=ls(e=>{const t=b(e,"package.json");if(!S(t))throw new Error("package.json not found at "+t);return{packageJson:kt(t),packageJsonPath:t}},"loadPackageJson");var cs=Object.defineProperty,ps=m((e,t)=>cs(e,"name",{value:t,configurable:!0}),"r$3");const st=ps((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
86
86
  `),e.logger.warn(`Build is done with some warnings:
87
87
 
88
88
  ${[...e.warnings].map(o=>`- ${o}`).join(`
89
- `)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logBuildErrors");var ps=Object.defineProperty,to=m((e,t)=>ps(e,"name",{value:t,configurable:!0}),"r$2");const lt=to(async(e,t)=>{if(typeof e.name!="string"){let o=gt(e.input)?O(t.options.rootDir,e.input):Ce(e.input);o.startsWith("./")&&(o=o.slice(2)),e.name=o.replace(new RegExp(`^${t.options.sourceDir}/`),"").replace(J,"")}if(!e.input)throw new Error(`Missing entry input: ${JSON.stringify(e)}`);Ko(e.input)&&(e.input=$(t.options.rootDir,e.input)),t.options.declaration&&e.declaration===void 0&&(e.declaration=t.options.declaration),e.executable&&(e.cjs===void 0||e.esm===void 0)?t.pkg.type==="commonjs"&&e.cjs===void 0&&t.options.emitCJS!==void 0?(e.cjs=t.options.emitCJS,e.esm=!1):t.pkg.type==="module"&&e.esm===void 0&&t.options.emitESM!==void 0&&(e.esm=t.options.emitESM,e.cjs=!1):e.cjs===void 0&&e.esm===void 0&&(t.options.emitCJS!==void 0&&(e.cjs=t.options.emitCJS),t.options.emitESM!==void 0&&(e.esm=t.options.emitESM)),e.outDir=$(t.options.rootDir,e.outDir??t.options.outDir)},"extendEntry"),us=to(async e=>{e.options.entries=e.options.entries.map(t=>typeof t=="string"?{input:t,isGlob:Ve(t)}:{...t,exportKey:t.exportKey??new Set,isGlob:Ve(t.input)});for(const t of e.options.entries.filter(o=>o.isGlob)){const{isGlob:o,...r}=t,n=["**/.git/**","**/node_modules/**","**/test-results/**"];if(e.options.rollup.watch){if(typeof e.options.rollup.watch.exclude=="string")n.push(e.options.rollup.watch.exclude);else if(Array.isArray(e.options.rollup.watch.exclude))for(const s of e.options.rollup.watch.exclude)typeof s=="string"&&n.push(s)}const i=Ro([r.input],{cwd:e.options.rootDir,dot:!1,ignore:n,onlyFiles:!0});if(i.length===0)throw new qo("No files found in the glob pattern: "+k(b(e.options.rootDir,r.input)));for(const s of i)e.options.entries.push({...r,input:$(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 lt(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 lt(t,e)},"prepareEntries");var ds=Object.defineProperty,ms=m((e,t)=>ds(e,"name",{value:t,configurable:!0}),"o$1");const fs=ms(e=>{if(e.options.validation?.packageJson?.dependencies===!1)return;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 i=xt(n);!De(e.options.externals,n)&&!n.startsWith("chunks/")&&e.pkg?.dependencies?.[i]===void 0&&e.pkg?.peerDependencies?.[i]===void 0&&r.add(n)}o.size>0&&j(e,`Potential unused dependencies found: ${[...o].map(n=>k(n)).join(", ")}`),r.size>0&&j(e,`Potential implicit dependencies found: ${[...r].map(n=>k(n)).join(", ")}`)},"validateDependencies");var gs=Object.defineProperty,oo=m((e,t)=>gs(e,"name",{value:t,configurable:!0}),"i$1");const ys=oo((e,t)=>Ho(e,t)<=e.length/3||t.includes(e),"isSimilar"),hs=oo((e,t)=>{const o=e.toLowerCase();return t.filter(r=>ys(r.toLowerCase(),o))},"findAlternatives");var vs=Object.defineProperty,ct=m((e,t)=>vs(e,"name",{value:t,configurable:!0}),"r$1");const bs=ct(e=>{const{options:t}=e;if(t.validation?.packageJson?.exports===!1)return;const o=t.validation?.packageJson,r=new Set([t.declaration&&o?.types?e.pkg.types:"",t.declaration&&o?.types?e.pkg.typings:"",...t.dtsOnly||o?.bin===!1?[""]:typeof e.pkg.bin=="string"?[e.pkg.bin]:Object.values(e.pkg.bin??{}),t.dtsOnly&&o?.main===!1?"":e.pkg.main,t.dtsOnly&&o?.module===!1?"":e.pkg.module,...o?.exports===!1?[]:Ae(e.pkg.exports,e.pkg.type==="module"?"esm":"cjs",t.declaration).map(a=>t.dtsOnly?a.subKey==="types"?a.file:void 0:a.file)].filter(Boolean).map(a=>a&&$(t.rootDir,a.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const a of r)a&&!a.includes("*")&&!ut(a)&&n.push(a.replace(`${t.rootDir}/`,""));const i=ct(a=>O(t.rootDir,$(t.outDir,a)),"rPath"),s=e.buildEntries.filter(a=>!a.chunk).map(a=>i(a.path));if(n.length>0){let a="Potential missing or wrong package.json files:";for(const l of n){const c=hs(l,s);a+=`
90
- - `+k(l)+(c.length>0?fo` (did you mean ${c.map(d=>`"${d}"`).join(", ")}?)`:"")}j(e,a)}},"validatePackageEntries");var ws=Object.defineProperty,$s=m((e,t)=>ws(e,"name",{value:t,configurable:!0}),"l$2");const js=$s(e=>{const{options:{validation:t},pkg:o}=e;o.name===void 0&&t?.packageJson?.name!==!1&&j(e,"The 'name' field is missing in your package.json. Please provide a valid package name."),t?.packageJson?.files!==!1&&(o.files===void 0?j(e,"The 'files' field is missing in your package.json. Add the files to be included in the package."):o.files.length===0?j(e,"The 'files' field in your package.json is empty. Please specify the files to be included in the package."):o.files.some(i=>i.includes(e.options.outDir))||j(e,`The 'files' field in your package.json is missing the '${e.options.outDir}' directory. Ensure the output directory is included.`));const r=o.type==="commonjs"||o.type===void 0,n=o.type==="module";if(r?(t?.packageJson?.main!==!1&&(o.main===void 0&&j(e,"The 'main' field is missing in your package.json. This field should point to your main entry file."),o.main?.includes(".mjs")&&j(e,"The 'main' field in your package.json should not use a '.mjs' extension for CommonJS modules.")),t?.packageJson?.module!==!1&&(o.module===void 0&&e.options.emitESM&&j(e,"The 'module' field is missing in your package.json, but you are emitting ES modules."),o.module&&o.main&&o.module===o.main&&j(e,`Conflict detected: The 'module' and 'main' fields both point to '${o.module}'. Please ensure they refer to different module types.`),e.options.emitESM&&o.module?.includes(".cjs")&&j(e,"The 'module' field in your package.json should not use a '.cjs' extension for ES modules."))):n&&(o.exports===void 0&&!e.options.emitCJS?t?.packageJson?.exports!==!1&&j(e,"The 'exports' field is missing in your package.json. Define module exports explicitly."):e.options.emitCJS&&(t?.packageJson?.main!==!1&&o.main===void 0&&j(e,"The 'main' field is missing in your package.json. This field is needed when emitting CommonJS modules."),t?.packageJson?.module!==!1&&(o.module===void 0&&j(e,"The 'module' field is missing in your package.json. This field is necessary when emitting ES modules."),o.module?.includes(".cjs")&&j(e,"The 'module' field should not use a '.cjs' extension for ES modules."),o.module&&o.main&&o.module===o.main&&j(e,`Conflict detected: The 'module' and 'main' fields both point to '${o.module}'. Please ensure they refer to different module types.`)),t?.packageJson?.exports!==!1&&o.exports===void 0&&j(e,"The 'exports' field is missing in your package.json. This field is required for defining explicit exports."))),o.exports,t?.packageJson?.bin!==!1){if(typeof o.bin=="string"&&o.bin.includes(r?".mjs":".cjs"))j(e,`The 'bin' field in your package.json should not use a ${r?".mjs":".cjs"} extension for ${r?"CommonJS":"ES modules"} binaries.`);else if(typeof o.bin=="object")for(const[i,s]of Object.entries(o.bin))s&&s.includes(r?".mjs":".cjs")&&j(e,`The 'bin.${i}' field in your package.json should not use a ${r?".mjs":".cjs"} extension for ${r?"CommonJS":"ES modules"} binaries.`)}e.options.declaration&&(o.types===void 0&&o.typings===void 0&&t?.packageJson?.types!==!1&&j(e,"The 'types' field is missing in your package.json. This field should point to your type definitions file."),(e.options.declaration===!0||e.options.declaration==="compatible")&&t?.packageJson?.typesVersions!==!1&&(o.typesVersions===void 0||Object.keys(o.typesVersions).length===0)&&j(e,"No 'typesVersions' field found in your package.json. Consider adding this field, or change the declaration option to 'node16' or 'false'."))},"validatePackageFields");var ks=Object.defineProperty,xs=m((e,t)=>ks(e,"name",{value:t,configurable:!0}),"i");const Es=xs(e=>{const{packageJson:t}=eo(e.options.rootDir);e.pkg=t,fs(e),js(e),bs(e)},"validator");var Ds=Object.defineProperty,Ss=m((e,t)=>Ds(e,"name",{value:t,configurable:!0}),"a");const Os=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,Ns=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"]),pt=Ss(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(Os.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(Ns.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const r=$(o);if(!S(r))throw new Error(`Target path "${r}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var Ps=Object.defineProperty,P=m((e,t)=>Ps(e,"name",{value:t,configurable:!0}),"g");const Cs=P(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=P((e,t,o,r,n,i,s,a,l)=>{const c=Cs(l?.config.compilerOptions?.jsx),d=xo(i,n,s,{alias:{},cjsInterop:!1,clean:!0,debug:r,declaration:void 0,emitCJS:void 0,emitESM:void 0,entries:[],externals:[...Je.builtinModules,...Je.builtinModules.map(p=>`node:${p}`)],failOnWarn:!0,fileCache:!0,jiti:{alias:{},debug:r,interopDefault:!0},minify:o===C,name:(a.name??"").split("/").pop()??"default",outDir:l?.config.compilerOptions?.outDir??"dist",rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{extensions:[".mjs",".js",".json",".node",".cjs"],ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:l?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,moduleResolution:100,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},esbuild:{charset:"utf8",exclude:V,jsx:c,jsxDev:l?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:l?.config.compilerOptions?.jsxFactory,jsxFragment:l?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:l?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,sourcesContent:!1,target:l?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:l?.config},isolatedDeclarations:{exclude:V,ignoreErrors:!1,include:H},json:{preferConst:!0},license:{dependenciesTemplate:P((p,u,g)=>`
89
+ `)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logBuildErrors");var us=Object.defineProperty,to=m((e,t)=>us(e,"name",{value:t,configurable:!0}),"r$2");const at=to(async(e,t)=>{if(typeof e.name!="string"){let o=gt(e.input)?O(t.options.rootDir,e.input):mt(e.input);o.startsWith("./")&&(o=o.slice(2)),e.name=o.replace(new RegExp(`^${t.options.sourceDir}/`),"").replace(J,"")}if(!e.input)throw new Error(`Missing entry input: ${JSON.stringify(e)}`);Ho(e.input)&&(e.input=$(t.options.rootDir,e.input)),t.options.declaration&&e.declaration===void 0&&(e.declaration=t.options.declaration),e.executable&&(e.cjs===void 0||e.esm===void 0)?t.pkg.type==="commonjs"&&e.cjs===void 0&&t.options.emitCJS!==void 0?(e.cjs=t.options.emitCJS,e.esm=!1):t.pkg.type==="module"&&e.esm===void 0&&t.options.emitESM!==void 0&&(e.esm=t.options.emitESM,e.cjs=!1):e.cjs===void 0&&e.esm===void 0&&(t.options.emitCJS!==void 0&&(e.cjs=t.options.emitCJS),t.options.emitESM!==void 0&&(e.esm=t.options.emitESM)),e.outDir=$(t.options.rootDir,e.outDir??t.options.outDir)},"extendEntry"),ds=to(async e=>{e.options.entries=e.options.entries.map(t=>typeof t=="string"?{input:t,isGlob:We(t)}:{...t,exportKey:t.exportKey??new Set,isGlob:We(t.input)});for(const t of e.options.entries.filter(o=>o.isGlob)){const{isGlob:o,...r}=t,n=["**/.git/**","**/node_modules/**","**/test-results/**"];if(e.options.rollup.watch){if(typeof e.options.rollup.watch.exclude=="string")n.push(e.options.rollup.watch.exclude);else if(Array.isArray(e.options.rollup.watch.exclude))for(const s of e.options.rollup.watch.exclude)typeof s=="string"&&n.push(s)}const i=Ro([r.input],{cwd:e.options.rootDir,dot:!1,ignore:n,onlyFiles:!0});if(i.length===0)throw new Ko("No files found in the glob pattern: "+k(b(e.options.rootDir,r.input)));for(const s of i)e.options.entries.push({...r,input:$(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 at(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 at(t,e)},"prepareEntries");var ms=Object.defineProperty,fs=m((e,t)=>ms(e,"name",{value:t,configurable:!0}),"o$1");const gs=fs(e=>{if(e.options.validation?.packageJson?.dependencies===!1)return;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 i=xt(n);!De(e.options.externals,n)&&!n.startsWith("chunks/")&&e.pkg?.dependencies?.[i]===void 0&&e.pkg?.peerDependencies?.[i]===void 0&&r.add(n)}o.size>0&&j(e,`Potential unused dependencies found: ${[...o].map(n=>k(n)).join(", ")}`),r.size>0&&j(e,`Potential implicit dependencies found: ${[...r].map(n=>k(n)).join(", ")}`)},"validateDependencies");var ys=Object.defineProperty,oo=m((e,t)=>ys(e,"name",{value:t,configurable:!0}),"i$1");const hs=oo((e,t)=>Go(e,t)<=e.length/3||t.includes(e),"isSimilar"),vs=oo((e,t)=>{const o=e.toLowerCase();return t.filter(r=>hs(r.toLowerCase(),o))},"findAlternatives");var bs=Object.defineProperty,lt=m((e,t)=>bs(e,"name",{value:t,configurable:!0}),"r$1");const ws=lt(e=>{const{options:t}=e;if(t.validation?.packageJson?.exports===!1)return;const o=t.validation?.packageJson,r=new Set([t.declaration&&o?.types?e.pkg.types:"",t.declaration&&o?.types?e.pkg.typings:"",...t.dtsOnly||o?.bin===!1?[""]:typeof e.pkg.bin=="string"?[e.pkg.bin]:Object.values(e.pkg.bin??{}),t.dtsOnly&&o?.main===!1?"":e.pkg.main,t.dtsOnly&&o?.module===!1?"":e.pkg.module,...o?.exports===!1?[]:Me(e.pkg.exports,e.pkg.type==="module"?"esm":"cjs",t.declaration).map(a=>t.dtsOnly?a.subKey==="types"?a.file:void 0:a.file)].filter(Boolean).map(a=>a&&$(t.rootDir,a.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const a of r)a&&!a.includes("*")&&!pt(a)&&n.push(a.replace(`${t.rootDir}/`,""));const i=lt(a=>O(t.rootDir,$(t.outDir,a)),"rPath"),s=e.buildEntries.filter(a=>!a.chunk).map(a=>i(a.path));if(n.length>0){let a="Potential missing or wrong package.json files:";for(const l of n){const c=vs(l,s);a+=`
90
+ - `+k(l)+(c.length>0?fo` (did you mean ${c.map(d=>`"${d}"`).join(", ")}?)`:"")}j(e,a)}},"validatePackageEntries");var $s=Object.defineProperty,js=m((e,t)=>$s(e,"name",{value:t,configurable:!0}),"l$2");const ks=js(e=>{const{options:{validation:t},pkg:o}=e;o.name===void 0&&t?.packageJson?.name!==!1&&j(e,"The 'name' field is missing in your package.json. Please provide a valid package name."),t?.packageJson?.files!==!1&&(o.files===void 0?j(e,"The 'files' field is missing in your package.json. Add the files to be included in the package."):o.files.length===0?j(e,"The 'files' field in your package.json is empty. Please specify the files to be included in the package."):o.files.some(i=>i.includes(e.options.outDir))||j(e,`The 'files' field in your package.json is missing the '${e.options.outDir}' directory. Ensure the output directory is included.`));const r=o.type==="commonjs"||o.type===void 0,n=o.type==="module";if(r?(t?.packageJson?.main!==!1&&(o.main===void 0&&j(e,"The 'main' field is missing in your package.json. This field should point to your main entry file."),o.main?.includes(".mjs")&&j(e,"The 'main' field in your package.json should not use a '.mjs' extension for CommonJS modules.")),t?.packageJson?.module!==!1&&(o.module===void 0&&e.options.emitESM&&j(e,"The 'module' field is missing in your package.json, but you are emitting ES modules."),o.module&&o.main&&o.module===o.main&&j(e,`Conflict detected: The 'module' and 'main' fields both point to '${o.module}'. Please ensure they refer to different module types.`),e.options.emitESM&&o.module?.includes(".cjs")&&j(e,"The 'module' field in your package.json should not use a '.cjs' extension for ES modules."))):n&&(o.exports===void 0&&!e.options.emitCJS?t?.packageJson?.exports!==!1&&j(e,"The 'exports' field is missing in your package.json. Define module exports explicitly."):e.options.emitCJS&&(t?.packageJson?.main!==!1&&o.main===void 0&&j(e,"The 'main' field is missing in your package.json. This field is needed when emitting CommonJS modules."),t?.packageJson?.module!==!1&&(o.module===void 0&&j(e,"The 'module' field is missing in your package.json. This field is necessary when emitting ES modules."),o.module?.includes(".cjs")&&j(e,"The 'module' field should not use a '.cjs' extension for ES modules."),o.module&&o.main&&o.module===o.main&&j(e,`Conflict detected: The 'module' and 'main' fields both point to '${o.module}'. Please ensure they refer to different module types.`)),t?.packageJson?.exports!==!1&&o.exports===void 0&&j(e,"The 'exports' field is missing in your package.json. This field is required for defining explicit exports."))),o.exports,t?.packageJson?.bin!==!1){if(typeof o.bin=="string"&&o.bin.includes(r?".mjs":".cjs"))j(e,`The 'bin' field in your package.json should not use a ${r?".mjs":".cjs"} extension for ${r?"CommonJS":"ES modules"} binaries.`);else if(typeof o.bin=="object")for(const[i,s]of Object.entries(o.bin))s&&s.includes(r?".mjs":".cjs")&&j(e,`The 'bin.${i}' field in your package.json should not use a ${r?".mjs":".cjs"} extension for ${r?"CommonJS":"ES modules"} binaries.`)}e.options.declaration&&(o.types===void 0&&o.typings===void 0&&t?.packageJson?.types!==!1&&j(e,"The 'types' field is missing in your package.json. This field should point to your type definitions file."),(e.options.declaration===!0||e.options.declaration==="compatible")&&t?.packageJson?.typesVersions!==!1&&(o.typesVersions===void 0||Object.keys(o.typesVersions).length===0)&&j(e,"No 'typesVersions' field found in your package.json. Consider adding this field, or change the declaration option to 'node16' or 'false'."))},"validatePackageFields");var xs=Object.defineProperty,Es=m((e,t)=>xs(e,"name",{value:t,configurable:!0}),"i");const Ds=Es(e=>{const{packageJson:t}=eo(e.options.rootDir);e.pkg=t,gs(e),ks(e),ws(e)},"validator");var Ss=Object.defineProperty,Os=m((e,t)=>Ss(e,"name",{value:t,configurable:!0}),"a");const Ns=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,Ps=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"]),ct=Os(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(Ns.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(Ps.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const r=$(o);if(!S(r))throw new Error(`Target path "${r}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var Cs=Object.defineProperty,P=m((e,t)=>Cs(e,"name",{value:t,configurable:!0}),"g");const _s=P(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"),Ts=P((e,t,o,r,n,i,s,a,l)=>{const c=_s(l?.config.compilerOptions?.jsx),d=xo(i,n,s,{alias:{},cjsInterop:!1,clean:!0,debug:r,declaration:void 0,emitCJS:void 0,emitESM:void 0,entries:[],externals:[...Fe.builtinModules,...Fe.builtinModules.map(p=>`node:${p}`)],failOnWarn:!0,fileCache:!0,jiti:{alias:{},debug:r,interopDefault:!0},minify:o===C,name:(a.name??"").split("/").pop()??"default",outDir:l?.config.compilerOptions?.outDir??"dist",rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{extensions:[".mjs",".js",".json",".node",".cjs"],ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:l?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,moduleResolution:100,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},esbuild:{charset:"utf8",exclude:V,jsx:c,jsxDev:l?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:l?.config.compilerOptions?.jsxFactory,jsxFragment:l?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:l?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,sourcesContent:!1,target:l?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:l?.config},isolatedDeclarations:{exclude:V,ignoreErrors:!1,include:H},json:{preferConst:!0},license:{dependenciesTemplate:P((p,u,g)=>`
91
91
  # Licenses of bundled dependencies
92
92
  The published ${g} artifact additionally contains code with the following licenses:
93
93
  `+(p.length>0?`${p.join(", ")}
@@ -101,15 +101,15 @@ The published ${g} artifact additionally contains code with the following licens
101
101
 
102
102
  `:`
103
103
  `)+`# Bundled types:
104
- `+u,"dtsTemplate")},node10Compatibility:{},patchTypes:{},polyfillNode:{},preserveDirectives:{exclude:V,include:H},preserveDynamicImports:!0,raw:{exclude:V,include:[/\.(md|txt|css|htm|html|data)$/]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,exportConditions:["module-sync"],extensions:_e,preferBuiltins:!1},shebang:{replace:!1,shebang:"#!/usr/bin/env node"},shim:{exclude:V,include:H},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:l?.config.compilerOptions?.esModuleInterop===!1,include:H,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:o===C,...l?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(l.config.compilerOptions.jsx)?{jsxFragmentPragma:l.config.compilerOptions.jsxFragmentFactory,jsxImportSource:l.config.compilerOptions.jsxImportSource,jsxPragma:l.config.compilerOptions.jsxFactory,jsxRuntime:c,transforms:["typescript","jsx",...l.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...l?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:H,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:l?.config.compilerOptions?.experimentalDecorators,syntax:l?"typescript":"ecmascript",[l?"tsx":"jsx"]:!0},target:l?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:l?.config.compilerOptions?.emitDecoratorMetadata,decoratorVersion:"2022-03",legacyDecorator:l?.config.compilerOptions?.experimentalDecorators,react:{development:o!==C,pragma:l?.config.compilerOptions?.jsxFactory,pragmaFrag:l?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:l?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:l?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:is(t,a),preset:"recommended",propertyReadSideEffects:!0},visualizer:{},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:V}},rootDir:t,sourceDir:"src",sourcemap:!1,transformerName:void 0,typedoc:{excludePrivate:!0,groupOrder:["Classes","Constructors","Accessors","Methods","Functions","Namespaces","Variables","Enumerations","Interfaces","Type Aliases","*"],kindSortOrder:["Project","Module","Class","Interface","Function","Namespace","Variable","Enum","EnumMember","TypeAlias","Reference","Constructor","Property","Accessor","Method","Parameter","TypeParameter","TypeLiteral","CallSignature","ConstructorSignature","IndexSignature","GetSignature","SetSignature"],marker:"TYPEDOC",name:a.name??"unknown",pretty:!0,readme:"none",showConfig:r,tsconfig:l?.path}});if(!d.transformerName){const p=new Map([...Object.entries(a.dependencies??{}),...Object.entries(a.devDependencies??{})]);let u="0.0.0";if(p.has("esbuild"))d.transformerName="esbuild",u=p.get("esbuild");else if(p.has("@swc/core"))d.transformerName="swc",u=p.get("@swc/core");else if(p.has("sucrase"))d.transformerName="sucrase",u=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 "+k("rollup ")+Do),e.info({message:"Using "+k(d.transformerName)+" "+u,prefix:"transformer"})}return d.rollup.resolve&&d.rollup.resolve.preferBuiltins===!0&&(d.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),a.dependencies&&d.externals.push(...Object.keys(a.dependencies)),a.peerDependencies&&d.externals.push(...Object.keys(a.peerDependencies)),a.optionalDependencies&&d.externals.push(...Object.keys(a.optionalDependencies)),pt(d.alias),d.rollup.alias&&d.rollup.alias.entries&&pt(d.rollup.alias.entries),d},"generateOptions"),Ts=P(async(e,t,o,r,n,i,s,a,l,c)=>{const d=await Bi(s.preset??i.preset??"auto",c),p=_s(e,t,r,n,i,s,d,a,l);vo(b(p.rootDir,p.outDir));const u={buildEntries:[],dependencyGraphMap:new Map,environment:r,hooks:Eo(),jiti:yt(p.rootDir,p.jiti),logger:e,mode:o,options:p,pkg:a,tsconfig:l,usedImports:new Set,warnings:new Set};d.hooks&&u.hooks.addHooks(d.hooks),i.hooks&&u.hooks.addHooks(i.hooks),s.hooks&&u.hooks.addHooks(s.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.options.minify&&u.logger.info("Minification is enabled, the output will be minified");const g=a.dependencies?.typescript!==void 0||a.devDependencies?.typescript!==void 0;if(u.options.declaration&&u.tsconfig===void 0&&g)throw new Error("Cannot build declaration files without a tsconfig.json");return g?u.options.declaration===!1&&u.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(u.options.declaration=!1,u.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),u.options.declaration&&u.logger.info("Using typescript version: "+k(a.devDependencies?.typescript??a.dependencies?.typescript??"unknown")),u.options.declaration&&(a.dependencies?.typescript||a.devDependencies?.typescript)&&!u.tsconfig?.config.compilerOptions?.isolatedModules&&u.logger.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
104
+ `+u,"dtsTemplate")},node10Compatibility:{},patchTypes:{},polyfillNode:{},preserveDirectives:{exclude:V,include:H},preserveDynamicImports:!0,raw:{exclude:V,include:[/\.(md|txt|css|htm|html|data)$/]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,exportConditions:["module-sync"],extensions:Ce,preferBuiltins:!1},shebang:{replace:!1,shebang:"#!/usr/bin/env node"},shim:{exclude:V,include:H},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:l?.config.compilerOptions?.esModuleInterop===!1,include:H,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:o===C,...l?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(l.config.compilerOptions.jsx)?{jsxFragmentPragma:l.config.compilerOptions.jsxFragmentFactory,jsxImportSource:l.config.compilerOptions.jsxImportSource,jsxPragma:l.config.compilerOptions.jsxFactory,jsxRuntime:c,transforms:["typescript","jsx",...l.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...l?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:H,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:l?.config.compilerOptions?.experimentalDecorators,syntax:l?"typescript":"ecmascript",[l?"tsx":"jsx"]:!0},target:l?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:l?.config.compilerOptions?.emitDecoratorMetadata,decoratorVersion:"2022-03",legacyDecorator:l?.config.compilerOptions?.experimentalDecorators,react:{development:o!==C,pragma:l?.config.compilerOptions?.jsxFactory,pragmaFrag:l?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:l?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:l?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:ss(t,a),preset:"recommended",propertyReadSideEffects:!0},visualizer:{},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:V}},rootDir:t,sourceDir:"src",sourcemap:!1,transformerName:void 0,typedoc:{excludePrivate:!0,groupOrder:["Classes","Constructors","Accessors","Methods","Functions","Namespaces","Variables","Enumerations","Interfaces","Type Aliases","*"],kindSortOrder:["Project","Module","Class","Interface","Function","Namespace","Variable","Enum","EnumMember","TypeAlias","Reference","Constructor","Property","Accessor","Method","Parameter","TypeParameter","TypeLiteral","CallSignature","ConstructorSignature","IndexSignature","GetSignature","SetSignature"],marker:"TYPEDOC",name:a.name??"unknown",pretty:!0,readme:"none",showConfig:r,tsconfig:l?.path}});if(!d.transformerName){const p=new Map([...Object.entries(a.dependencies??{}),...Object.entries(a.devDependencies??{})]);let u="0.0.0";if(p.has("esbuild"))d.transformerName="esbuild",u=p.get("esbuild");else if(p.has("@swc/core"))d.transformerName="swc",u=p.get("@swc/core");else if(p.has("sucrase"))d.transformerName="sucrase",u=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 "+k("rollup ")+Do),e.info({message:"Using "+k(d.transformerName)+" "+u,prefix:"transformer"})}return d.rollup.resolve&&d.rollup.resolve.preferBuiltins===!0&&(d.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),a.dependencies&&d.externals.push(...Object.keys(a.dependencies)),a.peerDependencies&&d.externals.push(...Object.keys(a.peerDependencies)),a.optionalDependencies&&d.externals.push(...Object.keys(a.optionalDependencies)),ct(d.alias),d.rollup.alias&&d.rollup.alias.entries&&ct(d.rollup.alias.entries),d},"generateOptions"),Is=P(async(e,t,o,r,n,i,s,a,l,c)=>{const d=await Li(s.preset??i.preset??"auto",c),p=Ts(e,t,r,n,i,s,d,a,l);vo(b(p.rootDir,p.outDir));const u={buildEntries:[],dependencyGraphMap:new Map,environment:r,hooks:Eo(),jiti:yt(p.rootDir,p.jiti),logger:e,mode:o,options:p,pkg:a,tsconfig:l,usedImports:new Set,warnings:new Set};d.hooks&&u.hooks.addHooks(d.hooks),i.hooks&&u.hooks.addHooks(i.hooks),s.hooks&&u.hooks.addHooks(s.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.options.minify&&u.logger.info("Minification is enabled, the output will be minified");const g=a.dependencies?.typescript!==void 0||a.devDependencies?.typescript!==void 0;if(u.options.declaration&&u.tsconfig===void 0&&g)throw new Error("Cannot build declaration files without a tsconfig.json");return g?u.options.declaration===!1&&u.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(u.options.declaration=!1,u.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),u.options.declaration&&u.logger.info("Using typescript version: "+k(a.devDependencies?.typescript??a.dependencies?.typescript??"unknown")),u.options.declaration&&(a.dependencies?.typescript||a.devDependencies?.typescript)&&!u.tsconfig?.config.compilerOptions?.isolatedModules&&u.logger.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
105
105
  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.
106
- 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 us(u),u},"createContext"),Is=P(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: \`./${O(e.options.rootDir,o)}\``),await bo(o))},"cleanDistributionDirectories"),Ms=P(async(e,t,o)=>{if(e&&S(b(e,"keystore1.json"))){const r=Pe(b(e,"keystore.json")),n=Ne(e,{withFileTypes:!0}).filter(s=>s.isDirectory());let i=o;for await(const s of n)r[s.name]||(await po(b(e,s.name),{force:!0,recursive:!0}),i&&t.raw(`
106
+ 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 ds(u),u},"createContext"),Ms=P(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: \`./${O(e.options.rootDir,o)}\``),await bo(o))},"cleanDistributionDirectories"),As=P(async(e,t,o)=>{if(e&&S(b(e,"keystore1.json"))){const r=Pe(b(e,"keystore.json")),n=Ne(e,{withFileTypes:!0}).filter(s=>s.isDirectory());let i=o;for await(const s of n)r[s.name]||(await po(b(e,s.name),{force:!0,recursive:!0}),i&&t.raw(`
107
107
 
108
- `),t.info({message:"Removing "+s.name+" file cache, the cache key is not used anymore.",prefix:"file-cache"}),i=!1)}},"removeOldCacheFolders"),As=P(e=>{switch(e){case"jit":return"Stubbing";case"watch":return"Watching";case"tsdoc":return"Generating TSDoc";default:return"Building"}},"getMode"),Rs=P(async(e,t,o,r,n={})=>{const{configPath:i,debug:s,tsconfigPath:a,...l}=n;r.wrapAll(),e=$(ao(),e),r.debug("Root directory:",e);const{packageJson:c,packageJsonPath:d}=eo(e);r.debug("Using package.json found at",d);let p;if(a){const y=b(e,a);if(!await wo(y))throw new Error("tsconfig.json not found at "+y);p={config:jo(y),path:y},r.info("Using tsconfig settings at",y)}else if(c.dependencies?.typescript||c.devDependencies?.typescript)try{p=await ko(e),r.debug("Using tsconfig settings found at",p.path)}catch{r.info("No tsconfig.json or jsconfig.json found.")}const u=go("@visulima/packem",{cwd:e});let g=!1;try{let y=i??"";if(!y){const q=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const L of q)if(S(b(e,L))){y="./"+L;break}}const f=yt(e,{debug:s,interopDefault:!0});if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(y))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");let h=await f.import(y,{try:!0})||{};typeof h=="function"&&(h=await h(o,t)),r.debug("Using packem config found at",b(e,y));const w=M(JSON.stringify({version:c.version,...c.dependencies,...c.devDependencies,...c.peerDependencies,...c.peerDependenciesMeta,browser:c.browser,eNode:c.engines?.node,exports:c.exports,main:c.main,module:c.module,type:c.type,types:c.types}))+M(JSON.stringify(h));u&&st(w,u,r);const x=new os(e,u,w,r),v=await Ts(r,e,t,o,s??!1,l,h,c,p,f);x.isEnabled=v.options.fileCache,v.logger.info(k(As(t)+" "+v.options.name)),v.logger.debug({context:v.options.entries,message:`${N("Root dir:")} ${v.options.rootDir}
109
- ${N("Entries:")}}`}),await Is(v);const _=Date.now(),te=P(()=>$o(Math.floor(Date.now()-_)),"getDuration");if(t==="watch"){if(v.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await Hi(v,x),at(v,!1);return}if(t==="jit"?(await Vi(v),await v.hooks.callHook("build:done",v)):(g=await ji(v,x),await v.hooks.callHook("validate:before",v),Es(v),await v.hooks.callHook("validate:done",v),at(v,g)),v.options.typedoc&&v.options.typedoc.format!==void 0){let q="unknown";c.dependencies?.typedoc?q=c.dependencies.typedoc:c.devDependencies?.typedoc&&(q=c.devDependencies.typedoc),u&&st("typedoc",u,r,!0),g&&v.logger.raw(`
110
- `),v.logger.info({message:"Using "+k("typedoc")+" "+q+" to generate reference documentation",prefix:"typedoc"}),await v.hooks.callHook("typedoc:before",v);let L=b(v.options.rootDir,"api-docs");v.options.typedoc.format==="inline"&&u&&(L=b(u,"typedoc")),v.options.typedoc.output&&(L=v.options.typedoc.output),await Yi(v.options.typedoc,v.options.entries,L,v.logger),await v.hooks.callHook("typedoc:done",v)}r.raw(`
108
+ `),t.info({message:"Removing "+s.name+" file cache, the cache key is not used anymore.",prefix:"file-cache"}),i=!1)}},"removeOldCacheFolders"),Rs=P(e=>{switch(e){case"jit":return"Stubbing";case"watch":return"Watching";case"tsdoc":return"Generating TSDoc";default:return"Building"}},"getMode"),Fs=P(async(e,t,o,r,n={})=>{const{configPath:i,debug:s,tsconfigPath:a,...l}=n;r.wrapAll(),e=$(ao(),e),r.debug("Root directory:",e);const{packageJson:c,packageJsonPath:d}=eo(e);r.debug("Using package.json found at",d);let p;if(a){const y=b(e,a);if(!await wo(y))throw new Error("tsconfig.json not found at "+y);p={config:jo(y),path:y},r.info("Using tsconfig settings at",y)}else if(c.dependencies?.typescript||c.devDependencies?.typescript)try{p=await ko(e),r.debug("Using tsconfig settings found at",p.path)}catch{r.info("No tsconfig.json or jsconfig.json found.")}const u=go("@visulima/packem",{cwd:e});let g=!1;try{let y=i??"";if(!y){const q=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const L of q)if(S(b(e,L))){y="./"+L;break}}const f=yt(e,{debug:s,interopDefault:!0});if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(y))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");let h=await f.import(y,{try:!0})||{};typeof h=="function"&&(h=await h(o,t)),r.debug("Using packem config found at",b(e,y));const w=M(JSON.stringify({version:c.version,...c.dependencies,...c.devDependencies,...c.peerDependencies,...c.peerDependenciesMeta,browser:c.browser,eNode:c.engines?.node,exports:c.exports,main:c.main,module:c.module,type:c.type,types:c.types}))+M(JSON.stringify(h));u&&it(w,u,r);const x=new rs(e,u,w,r),v=await Is(r,e,t,o,s??!1,l,h,c,p,f);x.isEnabled=v.options.fileCache,v.logger.info(k(Rs(t)+" "+v.options.name)),v.logger.debug({context:v.options.entries,message:`${N("Root dir:")} ${v.options.rootDir}
109
+ ${N("Entries:")}}`}),await Ms(v);const _=Date.now(),te=P(()=>$o(Math.floor(Date.now()-_)),"getDuration");if(t==="watch"){if(v.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await Gi(v,x),st(v,!1);return}if(t==="jit"?(await zi(v),await v.hooks.callHook("build:done",v)):(g=await ki(v,x),await v.hooks.callHook("validate:before",v),Ds(v),await v.hooks.callHook("validate:done",v),st(v,g)),v.options.typedoc&&v.options.typedoc.format!==void 0){let q="unknown";c.dependencies?.typedoc?q=c.dependencies.typedoc:c.devDependencies?.typedoc&&(q=c.devDependencies.typedoc),u&&it("typedoc",u,r,!0),g&&v.logger.raw(`
110
+ `),v.logger.info({message:"Using "+k("typedoc")+" "+q+" to generate reference documentation",prefix:"typedoc"}),await v.hooks.callHook("typedoc:before",v);let L=b(v.options.rootDir,"api-docs");v.options.typedoc.format==="inline"&&u&&(L=b(u,"typedoc")),v.options.typedoc.output&&(L=v.options.typedoc.output),await Qi(v.options.typedoc,v.options.entries,L,v.logger),await v.hooks.callHook("typedoc:done",v)}r.raw(`
111
111
  ⚡️ Build run in `+te()),r.restoreAll()}catch(y){throw r.raw(`
112
- `),Yt(y),y}finally{await Ms(u,r,g)}},"createBundler");var Fs=Object.defineProperty,Ee=m((e,t)=>Fs(e,"name",{value:t,configurable:!0}),"o");const Js=Ee(e=>{e.addCommand({description:"Demonstrate options required",execute:Ee(async({logger:t,options:o})=>{let r="build";o.watch?r="watch":o.jit&&(r="jit");const n={};let i;if(ae.NODE_ENV&&[Q,C].includes(ae.NODE_ENV)&&(i=ae.NODE_ENV),o.env)for(const s of o.env)if(s.key==="NODE_ENV"){if(i)throw new Error("NODE_ENV was already set, this can't be overridden.");i=s.value}else n["process.env."+s.key]=JSON.stringify(s.value);i===void 0&&(o.production?i=C:o.development&&(i=Q));try{await Rs(o.dir,r,i,t,{analyze:o.analyze,cjsInterop:o.cjsInterop,clean:o.clean,configPath:o.config??void 0,debug:o.debug,dtsOnly:o.dtsOnly,minify:o.minify===void 0?i===C:o.minify,rollup:{esbuild:{target:o.target},license:{path:o.license},metafile:o.metafile,replace:{values:n}},sourcemap:o.analyze||o.sourcemap,tsconfigPath:o.tsconfig??void 0,validation:o.validation===!1?{packageJson:{bin:!1,dependencies:!1,exports:!1,files:!1,main:!1,module:!1,name:!1,types:!1,typesVersions:!1}}:{},...o.typedoc?{typedoc:{format:"html"}}:{}})}catch(s){t.error(s),lo(1)}},"execute"),name:"build",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{alias:"t",description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",name:"target"},{description:"Use a custom config file",name:"config",type:String},{description:"Path to the tsconfig.json file",name:"tsconfig",type:String},{description:"Minify the output",name:"minify",type:Boolean},{description:"Generate sourcemaps (experimental)",name:"sourcemap",type:Boolean},{conflicts:"jit",description:"Watch for changes",name:"watch",type:Boolean},{conflicts:"watch",description:"Stub the package for JIT compilation",name:"jit",type:Boolean},{description:"Compile-time environment variables (eg. --env.NODE_ENV=production)",multiple:!0,name:"env",type:Ee(t=>{const[o,r]=t.split("=");return{key:o,value:r}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean},{conflicts:"development",description:"Run code in production environment",name:"production",type:Boolean},{conflicts:"production",description:"Run code in development environment",name:"development",type:Boolean},{description:"Do not clean the dist directory before building",name:"no-clean",type:Boolean},{description:"Only generate .d.ts files",name:"dts-only",type:Boolean},{description:"Enable or disable the output validation",name:"no-validation",type:Boolean},{description:"Generate type documentation",name:"typedoc",type:Boolean}]})},"createBuildCommand");var Bs=Object.defineProperty,se=m((e,t)=>Bs(e,"name",{value:t,configurable:!0}),"l");const Ls=se(e=>{e.addCommand({description:"Initialize packem configuration",execute:se(async({logger:t,options:o})=>{if(Go("Welcome to packem setup"),S(b(o.dir,"packem.config.ts"))){t.info("Packem project already initialized, you can use `packem build` to build your project");return}const r=b(o.dir,"package.json");if(!S(r))throw new Error("No package.json found in the directory");const n=kt(r),i=[];n.dependencies&&i.push(...Object.keys(n.dependencies)),n.devDependencies&&i.push(...Object.keys(n.devDependencies));const s=!!(n.devDependencies?.typescript??n.dependencies?.typescript);if(o.typescript===void 0&&!s){if(o.typescript=await W({message:"Do you want to install TypeScript?"}),o.typescript){const p=K();p.start("Installing typescript@latest"),await we("typescript@latest",{cwd:o.dir,dev:!0,silent:!0}),p.stop("")}}else ze.message("TypeScript version "+(n.devDependencies?.typescript??n.dependencies?.typescript)+" is already installed");if(!S(b(o.dir,"tsconfig.json"))){const p=await W({message:"Do you want to use generate a tsconfig.json?"}),u=await W({message:"Do you want to run your code in the DOM?"});if(p){const g=K();g.start("Generating tsconfig.json"),ge(b(o.dir,"tsconfig.json"),{compilerOptions:{esModuleInterop:!0,skipLibCheck:!0,target:"es2022",allowJs:!0,resolveJsonModule:!0,moduleDetection:"force",isolatedModules:!0,verbatimModuleSyntax:!0,strict:!0,noUncheckedIndexedAccess:!0,noImplicitOverride:!0,module:"NodeNext",outDir:"dist",sourceMap:!0,declaration:!0,lib:u?["es2022","dom","dom.iterable"]:["es2022"]}}),g.stop("")}}if(i.includes("esbuild")?o.transformer="esbuild":i.includes("@swc/core")?o.transformer="swc":i.includes("sucrase")&&(o.transformer="sucrase"),o.transformer===void 0){if(o.transformer=await Ue({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),o.transformer&&!i.includes(o.transformer)&&await W({message:"Do you want to install "+o.transformer+"?"})){const p=K();p.start("Installing "+o.transformer),await we(o.transformer==="swc"?"@swc/core":o.transformer,{cwd:o.dir,dev:!0,silent:!0}),p.stop("")}}else ze.message("Transformer "+o.transformer+" is already installed.");let a=!0;if(o.isolatedDeclarationTransformer===void 0&&(a=await W({message:"Do you want to use an isolated declaration types?",initialValue:!1})),o.isolatedDeclarationTransformer===void 0&&a&&(o.isolatedDeclarationTransformer=await Ue({message:"Pick a isolated declaration transformer",options:[{label:"Typescript",value:"typescript"},{label:"swc",value:"swc"},{label:"OXC",value:"oxc"},{label:"None",value:null}]}),o.isolatedDeclarationTransformer!==null)){let p;switch(o.isolatedDeclarationTransformer){case"typescript":{p="typescript";break}case"swc":{p="@swc/core";break}case"oxc":{p="oxc-transform";break}default:Xo("Invalid isolated declaration transformer")}if(p!==void 0&&!i.includes(p)&&await W({message:"Do you want to install "+p+"?"})){const u=K();u.start("Installing "+o.isolatedDeclarationTransformer),await we(p,{cwd:o.dir,dev:!0,silent:!0}),u.stop("")}}let l="";s||n.type==="module"?l=`import { defineConfig } from "@visulima/packem/config";
112
+ `),Yt(y),y}finally{await As(u,r,g)}},"createBundler");var Js=Object.defineProperty,Ee=m((e,t)=>Js(e,"name",{value:t,configurable:!0}),"o");const Bs=Ee(e=>{e.addCommand({description:"Demonstrate options required",execute:Ee(async({logger:t,options:o})=>{let r="build";o.watch?r="watch":o.jit&&(r="jit");const n={};let i;if(ae.NODE_ENV&&[Q,C].includes(ae.NODE_ENV)&&(i=ae.NODE_ENV),o.env)for(const s of o.env)if(s.key==="NODE_ENV"){if(i)throw new Error("NODE_ENV was already set, this can't be overridden.");i=s.value}else n["process.env."+s.key]=JSON.stringify(s.value);i===void 0&&(o.production?i=C:o.development&&(i=Q));try{await Fs(o.dir,r,i,t,{analyze:o.analyze,cjsInterop:o.cjsInterop,clean:o.clean,configPath:o.config??void 0,debug:o.debug,dtsOnly:o.dtsOnly,minify:o.minify===void 0?i===C:o.minify,rollup:{esbuild:{target:o.target},license:{path:o.license},metafile:o.metafile,replace:{values:n}},sourcemap:o.analyze||o.sourcemap,tsconfigPath:o.tsconfig??void 0,validation:o.validation===!1?{packageJson:{bin:!1,dependencies:!1,exports:!1,files:!1,main:!1,module:!1,name:!1,types:!1,typesVersions:!1}}:{},...o.typedoc?{typedoc:{format:"html"}}:{}})}catch(s){t.error(s),lo(1)}},"execute"),name:"build",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{alias:"t",description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",name:"target"},{description:"Use a custom config file",name:"config",type:String},{description:"Path to the tsconfig.json file",name:"tsconfig",type:String},{description:"Minify the output",name:"minify",type:Boolean},{description:"Generate sourcemaps (experimental)",name:"sourcemap",type:Boolean},{conflicts:"jit",description:"Watch for changes",name:"watch",type:Boolean},{conflicts:"watch",description:"Stub the package for JIT compilation",name:"jit",type:Boolean},{description:"Compile-time environment variables (eg. --env.NODE_ENV=production)",multiple:!0,name:"env",type:Ee(t=>{const[o,r]=t.split("=");return{key:o,value:r}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean},{conflicts:"development",description:"Run code in production environment",name:"production",type:Boolean},{conflicts:"production",description:"Run code in development environment",name:"development",type:Boolean},{description:"Do not clean the dist directory before building",name:"no-clean",type:Boolean},{description:"Only generate .d.ts files",name:"dts-only",type:Boolean},{description:"Enable or disable the output validation",name:"no-validation",type:Boolean},{description:"Generate type documentation",name:"typedoc",type:Boolean}]})},"createBuildCommand");var Ls=Object.defineProperty,se=m((e,t)=>Ls(e,"name",{value:t,configurable:!0}),"l");const Ws=se(e=>{e.addCommand({description:"Initialize packem configuration",execute:se(async({logger:t,options:o})=>{if(Xo("Welcome to packem setup"),S(b(o.dir,"packem.config.ts"))){t.info("Packem project already initialized, you can use `packem build` to build your project");return}const r=b(o.dir,"package.json");if(!S(r))throw new Error("No package.json found in the directory");const n=kt(r),i=[];n.dependencies&&i.push(...Object.keys(n.dependencies)),n.devDependencies&&i.push(...Object.keys(n.devDependencies));const s=!!(n.devDependencies?.typescript??n.dependencies?.typescript);if(o.typescript===void 0&&!s){if(o.typescript=await W({message:"Do you want to install TypeScript?"}),o.typescript){const p=K();p.start("Installing typescript@latest"),await we("typescript@latest",{cwd:o.dir,dev:!0,silent:!0}),p.stop("")}}else Ve.message("TypeScript version "+(n.devDependencies?.typescript??n.dependencies?.typescript)+" is already installed");if(!S(b(o.dir,"tsconfig.json"))){const p=await W({message:"Do you want to use generate a tsconfig.json?"}),u=await W({message:"Do you want to run your code in the DOM?"});if(p){const g=K();g.start("Generating tsconfig.json"),ge(b(o.dir,"tsconfig.json"),{compilerOptions:{esModuleInterop:!0,skipLibCheck:!0,target:"es2022",allowJs:!0,resolveJsonModule:!0,moduleDetection:"force",isolatedModules:!0,verbatimModuleSyntax:!0,strict:!0,noUncheckedIndexedAccess:!0,noImplicitOverride:!0,module:"NodeNext",outDir:"dist",sourceMap:!0,declaration:!0,lib:u?["es2022","dom","dom.iterable"]:["es2022"]}}),g.stop("")}}if(i.includes("esbuild")?o.transformer="esbuild":i.includes("@swc/core")?o.transformer="swc":i.includes("sucrase")&&(o.transformer="sucrase"),o.transformer===void 0){if(o.transformer=await ze({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),o.transformer&&!i.includes(o.transformer)&&await W({message:"Do you want to install "+o.transformer+"?"})){const p=K();p.start("Installing "+o.transformer),await we(o.transformer==="swc"?"@swc/core":o.transformer,{cwd:o.dir,dev:!0,silent:!0}),p.stop("")}}else Ve.message("Transformer "+o.transformer+" is already installed.");let a=!0;if(o.isolatedDeclarationTransformer===void 0&&(a=await W({message:"Do you want to use an isolated declaration types?",initialValue:!1})),o.isolatedDeclarationTransformer===void 0&&a&&(o.isolatedDeclarationTransformer=await ze({message:"Pick a isolated declaration transformer",options:[{label:"Typescript",value:"typescript"},{label:"swc",value:"swc"},{label:"OXC",value:"oxc"},{label:"None",value:null}]}),o.isolatedDeclarationTransformer!==null)){let p;switch(o.isolatedDeclarationTransformer){case"typescript":{p="typescript";break}case"swc":{p="@swc/core";break}case"oxc":{p="oxc-transform";break}default:Yo("Invalid isolated declaration transformer")}if(p!==void 0&&!i.includes(p)&&await W({message:"Do you want to install "+p+"?"})){const u=K();u.start("Installing "+o.isolatedDeclarationTransformer),await we(p,{cwd:o.dir,dev:!0,silent:!0}),u.stop("")}}let l="";s||n.type==="module"?l=`import { defineConfig } from "@visulima/packem/config";
113
113
  import transformer from "@visulima/packem/transformer/${o.transformer}";
114
114
  ${!a||!o.isolatedDeclarationTransformer?"":`import isolatedDeclarationTransformer from "@visulima/packem/dts/isolated/transformer/${o.isolatedDeclarationTransformer}";
115
115
  `}
@@ -125,4 +125,4 @@ module.exports = defineConfig({
125
125
  transformer${!a||!o.isolatedDeclarationTransformer?"":`,
126
126
  isolatedDeclarationTransformer`}
127
127
  });
128
- `;const c=K(),d=s?"ts":"js";c.start("Creating packem.config."+d),A(b(o.dir,"packem.config."+d),l),c.stop("Created packem.config."+d),Yo("Now you can run `packem build` to build your project")},"execute"),name:"init",options:[{defaultValue:".",description:"The directory to initialize",name:"dir",type:String},{description:"Choose a transformer",name:"transformer",type:se(t=>{if(typeof t=="string"&&["esbuild","sucrase","swc"].includes(t))return t;throw new Error("Invalid transformer, please choose one of 'swc', 'sucrase' or 'esbuild'")},"type")},{description:"Choose a isolated declaration transformer",name:"isolated-declaration-transformer",type:se(t=>{if(typeof t=="string"&&["none","oxc","swc","typescript"].includes(t))return t;throw new Error("Invalid isolated declaration isolated declaration, please choose one of 'none', 'oxc', 'swc' or 'typescript'")},"type")},{Description:"Use TypeScript",name:"typescript",type:Boolean}]})},"createInitCommand"),Fe=new no("packem",{logger:{reporters:[new io({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:Qo,packageVersion:Zo});Ls(Fe);Js(Fe);Fe.run({shouldExitProcess:!1});
128
+ `;const c=K(),d=s?"ts":"js";c.start("Creating packem.config."+d),A(b(o.dir,"packem.config."+d),l),c.stop("Created packem.config."+d),Qo("Now you can run `packem build` to build your project")},"execute"),name:"init",options:[{defaultValue:".",description:"The directory to initialize",name:"dir",type:String},{description:"Choose a transformer",name:"transformer",type:se(t=>{if(typeof t=="string"&&["esbuild","sucrase","swc"].includes(t))return t;throw new Error("Invalid transformer, please choose one of 'swc', 'sucrase' or 'esbuild'")},"type")},{description:"Choose a isolated declaration transformer",name:"isolated-declaration-transformer",type:se(t=>{if(typeof t=="string"&&["none","oxc","swc","typescript"].includes(t))return t;throw new Error("Invalid isolated declaration isolated declaration, please choose one of 'none', 'oxc', 'swc' or 'typescript'")},"type")},{Description:"Use TypeScript",name:"typescript",type:Boolean}]})},"createInitCommand"),Re=new no("packem",{logger:{reporters:[new io({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:Zo,packageVersion:er});Ws(Re);Bs(Re);Re.run({shouldExitProcess:!1});