@visulima/packem 1.0.0-alpha.89 → 1.0.0-alpha.90

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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## @visulima/packem [1.0.0-alpha.90](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.89...@visulima/packem@1.0.0-alpha.90) (2024-09-02)
2
+
3
+ ### Bug Fixes
4
+
5
+ * improved edge runtime, fixed some tests ([c0fc7a5](https://github.com/visulima/packem/commit/c0fc7a564081264d9d41eaf220ba619c00ba1608))
6
+
1
7
  ## @visulima/packem [1.0.0-alpha.89](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.88...@visulima/packem@1.0.0-alpha.89) (2024-09-02)
2
8
 
3
9
  ### Bug Fixes
package/dist/cli.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var w=Object.defineProperty;var d=(r,i)=>w(r,"name",{value:i,configurable:!0});const h=require("@visulima/cerebro"),b=require("@visulima/pail/reporter"),p=require("node:process"),l=require("./shared/constants-lwnJ_PjR.cjs"),E=require("./create-bundler.cjs"),v=require("@antfu/install-pkg"),o=require("@clack/prompts"),m=require("@visulima/fs"),D=require("@visulima/package/package-json"),u=require("@visulima/path"),j=d(r=>r&&typeof r=="object"&&"default"in r?r.default:r,"_interopDefaultCompat"),N=j(h),C="@visulima/packem",O="1.0.0-alpha.88";var V=Object.defineProperty,g=d((r,i)=>V(r,"name",{value:i,configurable:!0}),"a");const P=g(r=>{r.addCommand({description:"Demonstrate options required",execute:g(async({logger:i,options:e})=>{let s="build";e.watch?s="watch":e.jit&&(s="jit");const a={};let n;if(p.env.NODE_ENV&&[l.DEVELOPMENT_ENV,l.PRODUCTION_ENV].includes(p.env.NODE_ENV)&&(n=p.env.NODE_ENV),e.env)for(const t of e.env)if(t.key==="NODE_ENV"){if(n)throw new Error("NODE_ENV was already set, this can't be overridden.");n=t.value}else a["process.env."+t.key]=JSON.stringify(t.value);n===void 0&&(e.production?n=l.PRODUCTION_ENV:e.development&&(n=l.DEVELOPMENT_ENV));try{await E(e.dir,s,n,i,{cjsInterop:e.cjsInterop,clean:e.clean,configPath:e.config??void 0,debug:e.debug,minify:e.minify===void 0?n===l.PRODUCTION_ENV:e.minify,replace:{...a},rollup:{esbuild:{target:e.target},license:{path:e.license},metafile:e.metafile,...e.analyze?{visualizer:{}}:{visualizer:!1}},sourcemap:e.sourcemap,tsconfigPath:e.tsconfig??void 0})}catch(t){i.error(t),p.exit(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:g(i=>{const[e,s]=i.split("=");return{key:e,value:s}},"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}]})},"createBuildCommand");var T=Object.defineProperty,k=d((r,i)=>T(r,"name",{value:i,configurable:!0}),"m");const x=k(r=>{r.addCommand({description:"Initialize packem configuration",execute:k(async({logger:i,options:e})=>{if(o.intro("Welcome to packem setup"),m.isAccessibleSync(u.join(e.dir,"packem.config.ts"))){i.info("Packem project already initialized, you can use `packem build` to build your project");return}if(o.isCancel(e.transformer)){o.cancel("Operation cancelled");return}const s=u.join(e.dir,"package.json");if(!m.isAccessibleSync(s))throw new Error("No package.json found in the directory");const a=D.parsePackageJson(s),n=[];if(a.dependencies&&n.push(...Object.keys(a.dependencies)),a.devDependencies&&n.push(...Object.keys(a.devDependencies)),e.transformer===void 0&&(e.transformer=await o.select({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!n.includes(e.transformer)&&await o.confirm({message:"Do you want to install "+e.transformer+"?"}))){const t=o.spinner();t.start("Installing "+e.transformer),await v.installPackage(e.transformer==="swc"?"@swc/core":e.transformer,{cwd:e.dir,dev:!0,silent:!0}),t.stop("")}if(e.isolatedDeclarationTransformer===void 0&&(e.isolatedDeclarationTransformer=await o.select({message:"Pick a isolated declaration transformer",options:[{label:"Typescript",value:"typescript"},{label:"swc",value:"swc"},{label:"OXC",value:"oxc"},{label:"None",value:null}]}),e.isolatedDeclarationTransformer!==null)){let t;switch(e.isolatedDeclarationTransformer){case"typescript":{t="typescript";break}case"swc":{t="@swc/core";break}case"oxc":{t="oxc-transform";break}default:o.cancel("Invalid isolated declaration transformer")}if(t&&!n.includes(t)&&await o.confirm({message:"Do you want to install "+t+"?"})){const c=o.spinner();c.start("Installing "+e.isolatedDeclarationTransformer),await v.installPackage(t,{cwd:e.dir,dev:!0,silent:!0}),c.stop("")}}if(n.includes("typescript")||a.type==="module"){const t=`import { defineConfig } from "@visulima/packem/config";
2
+ "use strict";var w=Object.defineProperty;var d=(r,i)=>w(r,"name",{value:i,configurable:!0});const h=require("@visulima/cerebro"),b=require("@visulima/pail/reporter"),p=require("node:process"),l=require("./shared/constants-lwnJ_PjR.cjs"),E=require("./create-bundler.cjs"),v=require("@antfu/install-pkg"),o=require("@clack/prompts"),m=require("@visulima/fs"),D=require("@visulima/package/package-json"),u=require("@visulima/path"),j=d(r=>r&&typeof r=="object"&&"default"in r?r.default:r,"_interopDefaultCompat"),N=j(h),C="@visulima/packem",O="1.0.0-alpha.89";var V=Object.defineProperty,g=d((r,i)=>V(r,"name",{value:i,configurable:!0}),"a");const P=g(r=>{r.addCommand({description:"Demonstrate options required",execute:g(async({logger:i,options:e})=>{let s="build";e.watch?s="watch":e.jit&&(s="jit");const a={};let n;if(p.env.NODE_ENV&&[l.DEVELOPMENT_ENV,l.PRODUCTION_ENV].includes(p.env.NODE_ENV)&&(n=p.env.NODE_ENV),e.env)for(const t of e.env)if(t.key==="NODE_ENV"){if(n)throw new Error("NODE_ENV was already set, this can't be overridden.");n=t.value}else a["process.env."+t.key]=JSON.stringify(t.value);n===void 0&&(e.production?n=l.PRODUCTION_ENV:e.development&&(n=l.DEVELOPMENT_ENV));try{await E(e.dir,s,n,i,{cjsInterop:e.cjsInterop,clean:e.clean,configPath:e.config??void 0,debug:e.debug,minify:e.minify===void 0?n===l.PRODUCTION_ENV:e.minify,replace:{...a},rollup:{esbuild:{target:e.target},license:{path:e.license},metafile:e.metafile,...e.analyze?{visualizer:{}}:{visualizer:!1}},sourcemap:e.sourcemap,tsconfigPath:e.tsconfig??void 0})}catch(t){i.error(t),p.exit(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:g(i=>{const[e,s]=i.split("=");return{key:e,value:s}},"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}]})},"createBuildCommand");var T=Object.defineProperty,k=d((r,i)=>T(r,"name",{value:i,configurable:!0}),"m");const x=k(r=>{r.addCommand({description:"Initialize packem configuration",execute:k(async({logger:i,options:e})=>{if(o.intro("Welcome to packem setup"),m.isAccessibleSync(u.join(e.dir,"packem.config.ts"))){i.info("Packem project already initialized, you can use `packem build` to build your project");return}if(o.isCancel(e.transformer)){o.cancel("Operation cancelled");return}const s=u.join(e.dir,"package.json");if(!m.isAccessibleSync(s))throw new Error("No package.json found in the directory");const a=D.parsePackageJson(s),n=[];if(a.dependencies&&n.push(...Object.keys(a.dependencies)),a.devDependencies&&n.push(...Object.keys(a.devDependencies)),e.transformer===void 0&&(e.transformer=await o.select({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!n.includes(e.transformer)&&await o.confirm({message:"Do you want to install "+e.transformer+"?"}))){const t=o.spinner();t.start("Installing "+e.transformer),await v.installPackage(e.transformer==="swc"?"@swc/core":e.transformer,{cwd:e.dir,dev:!0,silent:!0}),t.stop("")}if(e.isolatedDeclarationTransformer===void 0&&(e.isolatedDeclarationTransformer=await o.select({message:"Pick a isolated declaration transformer",options:[{label:"Typescript",value:"typescript"},{label:"swc",value:"swc"},{label:"OXC",value:"oxc"},{label:"None",value:null}]}),e.isolatedDeclarationTransformer!==null)){let t;switch(e.isolatedDeclarationTransformer){case"typescript":{t="typescript";break}case"swc":{t="@swc/core";break}case"oxc":{t="oxc-transform";break}default:o.cancel("Invalid isolated declaration transformer")}if(t&&!n.includes(t)&&await o.confirm({message:"Do you want to install "+t+"?"})){const c=o.spinner();c.start("Installing "+e.isolatedDeclarationTransformer),await v.installPackage(t,{cwd:e.dir,dev:!0,silent:!0}),c.stop("")}}if(n.includes("typescript")||a.type==="module"){const t=`import { defineConfig } from "@visulima/packem/config";
3
3
  import transformer from "@visulima/packem/transformer/${e.transformer}";
4
4
  ${e.isolatedDeclarationTransformer===null?"":`import isolatedDeclarationTransformer from "@visulima/packem/dts/isolated/transformer/${e.isolatedDeclarationTransformer}";
5
5
  `}
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  var E=Object.defineProperty;var p=(a,t)=>E(a,"name",{value:t,configurable:!0});import C from"@visulima/cerebro";import{SimpleReporter as N}from"@visulima/pail/reporter";import{env as d,exit as V}from"node:process";import{b as y,P as f}from"./shared/constants-DcRh98q_.mjs";import x from"./create-bundler.mjs";import{installPackage as v}from"@antfu/install-pkg";import{intro as O,isCancel as T,cancel as w,select as h,confirm as k,spinner as c,outro as P}from"@clack/prompts";import{isAccessibleSync as b,writeFileSync as j}from"@visulima/fs";import{parsePackageJson as S}from"@visulima/package/package-json";import{join as l}from"@visulima/path";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
3
3
  const require = __cjs_mod__.createRequire(import.meta.url);
4
- const B="@visulima/packem",I="1.0.0-alpha.88";var z=Object.defineProperty,u=p((a,t)=>z(a,"name",{value:t,configurable:!0}),"a");const _=u(a=>{a.addCommand({description:"Demonstrate options required",execute:u(async({logger:t,options:e})=>{let n="build";e.watch?n="watch":e.jit&&(n="jit");const i={};let o;if(d.NODE_ENV&&[y,f].includes(d.NODE_ENV)&&(o=d.NODE_ENV),e.env)for(const r of e.env)if(r.key==="NODE_ENV"){if(o)throw new Error("NODE_ENV was already set, this can't be overridden.");o=r.value}else i["process.env."+r.key]=JSON.stringify(r.value);o===void 0&&(e.production?o=f:e.development&&(o=y));try{await x(e.dir,n,o,t,{cjsInterop:e.cjsInterop,clean:e.clean,configPath:e.config??void 0,debug:e.debug,minify:e.minify===void 0?o===f:e.minify,replace:{...i},rollup:{esbuild:{target:e.target},license:{path:e.license},metafile:e.metafile,...e.analyze?{visualizer:{}}:{visualizer:!1}},sourcemap:e.sourcemap,tsconfigPath:e.tsconfig??void 0})}catch(r){t.error(r),V(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:u(t=>{const[e,n]=t.split("=");return{key:e,value:n}},"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}]})},"createBuildCommand");var $=Object.defineProperty,D=p((a,t)=>$(a,"name",{value:t,configurable:!0}),"m");const J=D(a=>{a.addCommand({description:"Initialize packem configuration",execute:D(async({logger:t,options:e})=>{if(O("Welcome to packem setup"),b(l(e.dir,"packem.config.ts"))){t.info("Packem project already initialized, you can use `packem build` to build your project");return}if(T(e.transformer)){w("Operation cancelled");return}const n=l(e.dir,"package.json");if(!b(n))throw new Error("No package.json found in the directory");const i=S(n),o=[];if(i.dependencies&&o.push(...Object.keys(i.dependencies)),i.devDependencies&&o.push(...Object.keys(i.devDependencies)),e.transformer===void 0&&(e.transformer=await h({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!o.includes(e.transformer)&&await k({message:"Do you want to install "+e.transformer+"?"}))){const r=c();r.start("Installing "+e.transformer),await v(e.transformer==="swc"?"@swc/core":e.transformer,{cwd:e.dir,dev:!0,silent:!0}),r.stop("")}if(e.isolatedDeclarationTransformer===void 0&&(e.isolatedDeclarationTransformer=await h({message:"Pick a isolated declaration transformer",options:[{label:"Typescript",value:"typescript"},{label:"swc",value:"swc"},{label:"OXC",value:"oxc"},{label:"None",value:null}]}),e.isolatedDeclarationTransformer!==null)){let r;switch(e.isolatedDeclarationTransformer){case"typescript":{r="typescript";break}case"swc":{r="@swc/core";break}case"oxc":{r="oxc-transform";break}default:w("Invalid isolated declaration transformer")}if(r&&!o.includes(r)&&await k({message:"Do you want to install "+r+"?"})){const s=c();s.start("Installing "+e.isolatedDeclarationTransformer),await v(r,{cwd:e.dir,dev:!0,silent:!0}),s.stop("")}}if(o.includes("typescript")||i.type==="module"){const r=`import { defineConfig } from "@visulima/packem/config";
4
+ const B="@visulima/packem",I="1.0.0-alpha.89";var z=Object.defineProperty,u=p((a,t)=>z(a,"name",{value:t,configurable:!0}),"a");const _=u(a=>{a.addCommand({description:"Demonstrate options required",execute:u(async({logger:t,options:e})=>{let n="build";e.watch?n="watch":e.jit&&(n="jit");const i={};let o;if(d.NODE_ENV&&[y,f].includes(d.NODE_ENV)&&(o=d.NODE_ENV),e.env)for(const r of e.env)if(r.key==="NODE_ENV"){if(o)throw new Error("NODE_ENV was already set, this can't be overridden.");o=r.value}else i["process.env."+r.key]=JSON.stringify(r.value);o===void 0&&(e.production?o=f:e.development&&(o=y));try{await x(e.dir,n,o,t,{cjsInterop:e.cjsInterop,clean:e.clean,configPath:e.config??void 0,debug:e.debug,minify:e.minify===void 0?o===f:e.minify,replace:{...i},rollup:{esbuild:{target:e.target},license:{path:e.license},metafile:e.metafile,...e.analyze?{visualizer:{}}:{visualizer:!1}},sourcemap:e.sourcemap,tsconfigPath:e.tsconfig??void 0})}catch(r){t.error(r),V(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:u(t=>{const[e,n]=t.split("=");return{key:e,value:n}},"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}]})},"createBuildCommand");var $=Object.defineProperty,D=p((a,t)=>$(a,"name",{value:t,configurable:!0}),"m");const J=D(a=>{a.addCommand({description:"Initialize packem configuration",execute:D(async({logger:t,options:e})=>{if(O("Welcome to packem setup"),b(l(e.dir,"packem.config.ts"))){t.info("Packem project already initialized, you can use `packem build` to build your project");return}if(T(e.transformer)){w("Operation cancelled");return}const n=l(e.dir,"package.json");if(!b(n))throw new Error("No package.json found in the directory");const i=S(n),o=[];if(i.dependencies&&o.push(...Object.keys(i.dependencies)),i.devDependencies&&o.push(...Object.keys(i.devDependencies)),e.transformer===void 0&&(e.transformer=await h({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!o.includes(e.transformer)&&await k({message:"Do you want to install "+e.transformer+"?"}))){const r=c();r.start("Installing "+e.transformer),await v(e.transformer==="swc"?"@swc/core":e.transformer,{cwd:e.dir,dev:!0,silent:!0}),r.stop("")}if(e.isolatedDeclarationTransformer===void 0&&(e.isolatedDeclarationTransformer=await h({message:"Pick a isolated declaration transformer",options:[{label:"Typescript",value:"typescript"},{label:"swc",value:"swc"},{label:"OXC",value:"oxc"},{label:"None",value:null}]}),e.isolatedDeclarationTransformer!==null)){let r;switch(e.isolatedDeclarationTransformer){case"typescript":{r="typescript";break}case"swc":{r="@swc/core";break}case"oxc":{r="oxc-transform";break}default:w("Invalid isolated declaration transformer")}if(r&&!o.includes(r)&&await k({message:"Do you want to install "+r+"?"})){const s=c();s.start("Installing "+e.isolatedDeclarationTransformer),await v(r,{cwd:e.dir,dev:!0,silent:!0}),s.stop("")}}if(o.includes("typescript")||i.type==="module"){const r=`import { defineConfig } from "@visulima/packem/config";
5
5
  import transformer from "@visulima/packem/transformer/${e.transformer}";
6
6
  ${e.isolatedDeclarationTransformer===null?"":`import isolatedDeclarationTransformer from "@visulima/packem/dts/isolated/transformer/${e.isolatedDeclarationTransformer}";
7
7
  `}
@@ -1,11 +1,11 @@
1
- "use strict";var ft=Object.defineProperty;var m=(e,t)=>ft(e,"name",{value:t,configurable:!0});const ne=require("node:fs/promises"),mt=require("node:module"),se=require("node:process"),v=require("@visulima/colorize"),$=require("@visulima/fs"),P=require("@visulima/humanizer"),gt=require("@visulima/package/package-json"),f=require("@visulima/path"),ge=require("@visulima/tsconfig"),ht=require("defu"),yt=require("hookable"),T=require("rollup"),k=require("./shared/constants-lwnJ_PjR.cjs"),Pe=require("node:url"),V=require("mlly"),vt=require("magic-string"),bt=require("jiti"),ie=require("node:fs"),$t=require("@rollup/plugin-alias"),wt=require("@rollup/plugin-commonjs"),jt=require("@rollup/plugin-dynamic-import-vars"),Ce=require("@rollup/plugin-node-resolve"),kt=require("@rollup/plugin-replace"),xt=require("@rollup/plugin-wasm"),Et=require("rollup-plugin-polyfill-node"),Ot=require("rollup-plugin-visualizer"),Re=require("semver"),St=require("node:assert/strict"),_=require("@rollup/pluginutils"),Nt=require("glob-parent"),Ie=require("tinyglobby"),Dt=require("oxc-parser"),_t=require("@rollup/plugin-json"),Pt=require("rollup-plugin-license"),Ct=require("node:crypto"),Rt=require("@babel/parser"),It=require("@visulima/find-cache-dir"),Ft=require("@visulima/fs/error"),Mt=require("@visulima/path/utils"),At=require("is-glob"),Tt=require("fastest-levenshtein");var he=typeof document<"u"?document.currentScript:null;const S=m(e=>e&&typeof e=="object"&&"default"in e?e.default:e,"_interopDefaultCompat"),ye=S(mt),R=S(vt),Fe=S(bt),Me=S($t),Jt=S(wt),Lt=S(jt),Ae=S(kt),qt=S(Et),H=S(St),Bt=S(Nt),Wt=S(_t),Ut=S(Pt),ve=S(At);var zt=Object.defineProperty,X=m((e,t)=>zt(e,"name",{value:t,configurable:!0}),"i$c");const ae=/^#![^\n]*/,oe=X(async e=>{await ne.chmod(e,493).catch(()=>{})},"makeExecutable"),Vt=X((e,t=`#!/usr/bin/env node
1
+ "use strict";var ft=Object.defineProperty;var m=(e,t)=>ft(e,"name",{value:t,configurable:!0});const ne=require("node:fs/promises"),mt=require("node:module"),se=require("node:process"),v=require("@visulima/colorize"),b=require("@visulima/fs"),P=require("@visulima/humanizer"),gt=require("@visulima/package/package-json"),f=require("@visulima/path"),ge=require("@visulima/tsconfig"),ht=require("defu"),yt=require("hookable"),T=require("rollup"),k=require("./shared/constants-lwnJ_PjR.cjs"),Pe=require("node:url"),V=require("mlly"),vt=require("magic-string"),bt=require("jiti"),ie=require("node:fs"),$t=require("@rollup/plugin-alias"),wt=require("@rollup/plugin-commonjs"),jt=require("@rollup/plugin-dynamic-import-vars"),Ce=require("@rollup/plugin-node-resolve"),kt=require("@rollup/plugin-replace"),xt=require("@rollup/plugin-wasm"),Et=require("rollup-plugin-polyfill-node"),Ot=require("rollup-plugin-visualizer"),Re=require("semver"),St=require("node:assert/strict"),_=require("@rollup/pluginutils"),Nt=require("glob-parent"),Ie=require("tinyglobby"),Dt=require("oxc-parser"),_t=require("@rollup/plugin-json"),Pt=require("rollup-plugin-license"),Ct=require("node:crypto"),Rt=require("@babel/parser"),It=require("@visulima/find-cache-dir"),Ft=require("@visulima/fs/error"),Mt=require("@visulima/path/utils"),At=require("is-glob"),Tt=require("fastest-levenshtein");var he=typeof document<"u"?document.currentScript:null;const S=m(e=>e&&typeof e=="object"&&"default"in e?e.default:e,"_interopDefaultCompat"),ye=S(mt),R=S(vt),Fe=S(bt),Me=S($t),Jt=S(wt),Lt=S(jt),Ae=S(kt),qt=S(Et),H=S(St),Bt=S(Nt),Wt=S(_t),Ut=S(Pt),ve=S(At);var zt=Object.defineProperty,X=m((e,t)=>zt(e,"name",{value:t,configurable:!0}),"i$c");const ae=/^#![^\n]*/,oe=X(async e=>{await ne.chmod(e,493).catch(()=>{})},"makeExecutable"),Vt=X((e,t=`#!/usr/bin/env node
2
2
  `)=>({name:"packem:shebang",renderChunk:{handler(o,r,s){if(!r.isEntry||!r.facadeModuleId||o.startsWith("#")&&o[1]==="!")return null;if(e.includes(r.name)){const n=new R(o);return n.prepend(t),{code:n.toString(),map:s.sourcemap?n.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,r){for(const[s,n]of Object.entries(r))if(n.type==="chunk"&&ae.test(n.code)&&o.dir){const i=f.resolve(o.dir,s);await oe(i)}}}),"shebangPlugin"),Ht=X(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ae,"")}}),"removeShebangPlugin"),Gt=X((e,t=`
3
- `)=>{const o=ae.exec(e);return o?o+t:""},"getShebang");var Xt=Object.defineProperty,Kt=m((e,t)=>Xt(e,"name",{value:t,configurable:!0}),"p$2");const le=Kt((e,t)=>{let o={};if(e.pkg.name&&(o[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:r}=e.pkg;for(const s in r){if(s.startsWith("#"))continue;const n=r[s];typeof n=="string"&&(o[s]=f.join(e.options.rootDir,n))}}return o={...o,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(o,Object.fromEntries(e.options.rollup.alias.entries.map(r=>[r.find,r.replacement]))):Object.assign(o,e.options.rollup.alias.entries??e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(o),prefix:t}),o},"resolveAliases");var Yt=Object.defineProperty,Qt=m((e,t)=>Yt(e,"name",{value:t,configurable:!0}),"o$4");const Zt=Qt((e,t)=>{const o=Fe(t,{esmResolve:!0,interopDefault:!0});try{return o.resolve(e)}catch(r){if(r.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:r});return e}},"tryResolve");var eo=Object.defineProperty,to=m((e,t)=>eo(e,"name",{value:t,configurable:!0}),"r$9");const J=to((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var oo=Object.defineProperty,ro=m((e,t)=>oo(e,"name",{value:t,configurable:!0}),"u$d");const no=ro(async e=>{const t=await V.resolvePath("jiti",{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:he&&he.src||new URL("create-bundler.cjs",document.baseURI).href}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...le(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const r of e.options.entries){const s=f.resolve(e.options.rootDir,e.options.outDir,r.name),n=f.normalize(Zt(r.input,e.options.rootDir)||r.input),i=n.slice(0,Math.max(0,n.length-f.extname(n).length)),l=await $.readFile(n),a=Gt(l);e.options.emitCJS&&await $.writeFile(`${s}.cjs`,a+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`module.exports = _jiti(${JSON.stringify(n)})`].join(`
4
- `));let c=[];try{c=await V.resolveModuleExportNames(n,{extensions:k.DEFAULT_EXTENSIONS})}catch(d){J(e,`Cannot analyze ${n} for exports: ${d.toString()}`);return}const p=c.includes("default")||c.length===0;await $.writeFile(`${s}.mjs`,a+[`import jiti from ${JSON.stringify(Pe.pathToFileURL(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(n)})} */`,`const _module = await _jiti.import(${JSON.stringify(n)});`,p?`
3
+ `)=>{const o=ae.exec(e);return o?o+t:""},"getShebang");var Xt=Object.defineProperty,Kt=m((e,t)=>Xt(e,"name",{value:t,configurable:!0}),"p$2");const le=Kt((e,t)=>{let o={};if(e.pkg.name&&(o[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:r}=e.pkg;for(const s in r){if(s.startsWith("#"))continue;const n=r[s];typeof n=="string"&&(o[s]=f.join(e.options.rootDir,n))}}return o={...o,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(o,Object.fromEntries(e.options.rollup.alias.entries.map(r=>[r.find,r.replacement]))):Object.assign(o,e.options.rollup.alias.entries??e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(o),prefix:t}),o},"resolveAliases");var Yt=Object.defineProperty,Qt=m((e,t)=>Yt(e,"name",{value:t,configurable:!0}),"o$4");const Zt=Qt((e,t)=>{const o=Fe(t,{esmResolve:!0,interopDefault:!0});try{return o.resolve(e)}catch(r){if(r.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:r});return e}},"tryResolve");var eo=Object.defineProperty,to=m((e,t)=>eo(e,"name",{value:t,configurable:!0}),"r$9");const J=to((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var oo=Object.defineProperty,ro=m((e,t)=>oo(e,"name",{value:t,configurable:!0}),"u$d");const no=ro(async e=>{const t=await V.resolvePath("jiti",{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:he&&he.src||new URL("create-bundler.cjs",document.baseURI).href}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...le(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const r of e.options.entries){const s=f.resolve(e.options.rootDir,e.options.outDir,r.name),n=f.normalize(Zt(r.input,e.options.rootDir)||r.input),i=n.slice(0,Math.max(0,n.length-f.extname(n).length)),l=await b.readFile(n),a=Gt(l);e.options.emitCJS&&await b.writeFile(`${s}.cjs`,a+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`module.exports = _jiti(${JSON.stringify(n)})`].join(`
4
+ `));let c=[];try{c=await V.resolveModuleExportNames(n,{extensions:k.DEFAULT_EXTENSIONS})}catch(d){J(e,`Cannot analyze ${n} for exports: ${d.toString()}`);return}const p=c.includes("default")||c.length===0;await b.writeFile(`${s}.mjs`,a+[`import jiti from ${JSON.stringify(Pe.pathToFileURL(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(n)})} */`,`const _module = await _jiti.import(${JSON.stringify(n)});`,p?`
5
5
  export default _module;`:"",...c.filter(d=>d!=="default").map(d=>`export const ${d} = _module.${d};`)].join(`
6
- `)),await $.writeFile(`${s}.d.cts`,[`export * from ${JSON.stringify(i)};`,p?`export { default } from ${JSON.stringify(i)};`:""].join(`
7
- `)),await $.writeFile(`${s}.d.mts`,[`export * from ${JSON.stringify(n)};`,p?`export { default } from ${JSON.stringify(n)};`:""].join(`
8
- `)),a&&(await oe(`${s}.cjs`),await oe(`${s}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var so=Object.defineProperty,io=m((e,t)=>so(e,"name",{value:t,configurable:!0}),"r$8");const Te=io((e,t)=>Fe(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var ao=Object.defineProperty,lo=m((e,t)=>ao(e,"name",{value:t,configurable:!0}),"i$9");const ce=lo(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var co=Object.defineProperty,Je=m((e,t)=>co(e,"name",{value:t,configurable:!0}),"e$2");const G=Je(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Le=Je((e,t,o,r)=>{if(r){const i=G(r);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[s,...n]=t;return Le(s,n,o,r)},"inferExportType");var po=Object.defineProperty,uo=m((e,t)=>po(e,"name",{value:t,configurable:!0}),"i$8");const fo=new Set(["import","require","node","node-addons","default","types","deno","browser",...k.SPECIAL_EXPORT_CONVENTIONS]),pe=uo((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const s=G(e);if(s&&s!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:s??t}]}return Object.entries(e).filter(([s])=>!s.endsWith(".json")).flatMap(([s,n])=>o===!1&&s==="types"?[]:typeof n=="string"?{file:n,key:"exports",...fo.has(s)?{subKey:s}:{},type:Le(s,r,t,n)}:pe(n,t,o,[...r,s]))},"extractExportFilenames");var mo=Object.defineProperty,K=m((e,t)=>mo(e,"name",{value:t,configurable:!0}),"c$b");const go=K((e,t)=>e.key==="exports"&&e.subKey===k.PRODUCTION_ENV?k.PRODUCTION_ENV:e.key==="exports"&&e.subKey===k.DEVELOPMENT_ENV?k.DEVELOPMENT_ENV:t,"getEnvironment"),B=K((e,t,o,r,s,n)=>{const i=go(s,n.environment);let l="node";for(const p of k.RUNTIME_EXPORT_CONVENTIONS)if(s.file.includes("."+p+".")||s.subKey===p){l=p;break}let a=e.find(p=>p.input===t&&p.environment===i&&p.runtime===l);a===void 0&&(a=e[e.push({environment:i,input:t,runtime:l})-1]),o&&(a.outDir=r),s.isExecutable?(a.executable=!0,a.declaration=!1,s.type==="cjs"&&(a.cjs=!0),s.type==="esm"&&(a.esm=!0)):(/\.d\.[mc]?ts$/.test(s.file)&&n.options.declaration!==!1&&(a.declaration=n.options.declaration),s.type==="cjs"&&(a.cjs=!0),s.type==="esm"&&(a.esm=!0));const c=s.file.replace(f.extname(s.file),"").replace(new RegExp(`^./${n.options.outDir.replace(/^\.\//,"")}/`),"");k.SPECIAL_EXPORT_CONVENTIONS.has(s.subKey)&&!t.includes(c)&&(a.fileAlias=c)},"createOrUpdateEntry");let be=!1;const $e=K(e=>{if(e.pkg?.dependencies?.typescript===void 0&&e.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},"validateIfTypescriptIsInstalled"),ho=K((e,t,o)=>{const r=[];t.sort((l,a)=>l.split("/").length-a.split("/").length);const s=e.type==="module"?"esm":"cjs";s==="esm"&&(o.options.emitESM=!0),s==="cjs"&&(o.options.emitCJS=!0);const n=pe(e.exports,s,o.options.declaration);if(e.bin){const l=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const a of l){const c=G(a);if(c&&c!==s)throw new Error(`Exported file "${a}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);n.push({file:a,isExecutable:!0,key:"bin",type:c??s})}}e.main&&n.push({file:e.main,key:"main",type:G(e.main)??s}),e.module&&n.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&($e(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),n.push({file:e.types??e.typings,key:"types"}));const i=[];for(const l of n){o.options.declaration===void 0&&(l.key==="types"||l.subKey==="types")&&(o.options.declaration=l.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&l.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&l.type==="esm"&&(o.options.emitESM=!0);const a=l.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=a.endsWith("/");if(c&&["./","/"].includes(a))continue;const p=a.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),d="(?<=/|$)",u=c?"":"\\.\\w+$";if(l.file.includes("/*")&&l.key==="exports"){be||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),be=!0);const b=[],w=new RegExp(d+p.replace("*","(.*)")+u),j=new RegExp(d+p.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+u);for(const E of t)(w.test(E)||k.SPECIAL_EXPORT_CONVENTIONS.has(l.subKey)&&j.test(E))&&b.push(E);if(b.length===0){r.push(`Could not find entrypoint for \`${l.file}\``);continue}for(const E of b)B(i,E,c,a,l,o);continue}const g=new RegExp(d+p+u);let y=t.find(b=>g.test(b));if(k.SPECIAL_EXPORT_CONVENTIONS.has(l.subKey)&&y===void 0){const b=new RegExp(d+p.replace(/(.*)\.[^.]*$/,"$1")+u);y=t.find(w=>b.test(w))}if(y===void 0){$.isAccessibleSync(f.resolve(o.options.rootDir,l.file))||r.push(`Could not find entrypoint for \`${l.file}\``);continue}(y.endsWith(".ts")||y.endsWith(".cts")||y.endsWith(".mts"))&&$.isAccessibleSync(y)&&$e(o);const h=y.replace(k.ENDING_RE,"");$.isAccessibleSync(h+".cts")&&$.isAccessibleSync(h+".mts")?(B(i,h+".cts",c,a,{...l,type:"cjs"},o),B(i,h+".mts",c,a,{...l,type:"esm"},o)):B(i,y,c,a,l,o)}return{entries:i,warnings:r}},"inferEntries");var yo=Object.defineProperty,vo=m((e,t)=>yo(e,"name",{value:t,configurable:!0}),"o$3");const bo=vo((e,t)=>{const{publishConfig:o}=e;return o&&(o.bin&&(typeof o.bin=="object"||typeof o.bin=="string")&&(e.bin=o.bin),o.type&&typeof o.type=="string"&&o.type!==""&&(e.type=o.type),o.main&&typeof o.main=="string"&&o.main!==""&&(e.main=o.main),o.module&&typeof o.module=="string"&&o.module!==""&&(e.module=o.module),t===void 0&&o.types&&typeof o.types=="string"&&o.types!==""?e.types=o.types:t===void 0&&o.typings&&typeof o.typings=="string"&&o.typings!==""&&(e.typings=o.typings),o.exports&&typeof o.exports=="object"&&(e.exports=o.exports)),e},"overwriteWithPublishConfig");var $o=Object.defineProperty,wo=m((e,t)=>$o(e,"name",{value:t,configurable:!0}),"l$9");const jo={hooks:{"build:prepare":wo(function(e){if(e.options.entries.length>0)return;const t=f.join(e.options.rootDir,e.options.sourceDir);if(!ie.existsSync(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=$.collectSync(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let r={...e.pkg};r.publishConfig&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(r.publishConfig).join(", ")+'".'),e.logger.debug(ce(r.publishConfig)),r=bo(r,e.options.declaration));const s=ho(r,o,e);for(const n of s.warnings)J(e,n);if(e.options.entries.push(...s.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",v.cyan(e.options.entries.map(n=>n.fileAlias?v.bold(n.fileAlias)+" => "+v.bold(n.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):v.bold(n.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),v.gray([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(n=>`[${n}]`).join(" ")))},"build:prepare")}};var ko=Object.defineProperty,xo=m((e,t)=>ko(e,"name",{value:t,configurable:!0}),"n$9");const Eo=xo((e,t)=>{if(e==="auto")e=jo;else{if(e==="none")return{};typeof e=="string"&&(e=Te(e,t))}return typeof e=="function"&&(e=e()),e},"resolvePreset");var Oo=Object.defineProperty,So=m((e,t)=>Oo(e,"name",{value:t,configurable:!0}),"a$c");const re=So((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var No=Object.defineProperty,Do=m((e,t)=>No(e,"name",{value:t,configurable:!0}),"a$b");const A=Do(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var _o=Object.defineProperty,Po=m((e,t)=>_o(e,"name",{value:t,configurable:!0}),"a$a");const qe=Po((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var Co=Object.defineProperty,Be=m((e,t)=>Co(e,"name",{value:t,configurable:!0}),"s$c");const Ro=Be((e,t,o)=>{const r=o??new Map;return(...s)=>{const n=t?typeof t=="function"?t(...s):t:JSON.stringify({args:s}),i=r.get(n);if(i!==void 0)return i;const l=e(...s);return r.set(n,l),l}},"memoize"),Io=Be(e=>{const t=new Map;return o=>Ro(e,o,t)},"memoizeByKey");var Fo=Object.defineProperty,L=m((e,t)=>Fo(e,"name",{value:t,configurable:!0}),"r$5");const Mo=L(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;H(t,"Expected class/function to have a name"),yield t.name;break}case"VariableDeclaration":{for(const t of e.declaration.declarations)for(const o of _.extractAssignedNames(t.id))yield o;break}}},"exportName"),Ao=L(function*(e){if(e.declaration)for(const t of Mo(e))yield{exportedName:t,from:"self",type:"named"};else if(e.source)yield{bindings:e.specifiers.map(t=>({exportedName:t.exported.name,importedName:t.local.name})),from:"other",source:e.source.value,type:"named"};else for(const t of e.specifiers)yield{exportedName:t.exported.name,from:"self",type:"named"}},"parseExportNamed"),To=L(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),Jo=L(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),Lo=L(function*(e,t){H(t.code!=null,`Module ${t.id} doesn't have associated code`);const o=e.parse(t.code);for(const r of o.body)switch(r.type){case"ExportAllDeclaration":{yield*To(r);break}case"ExportDefaultDeclaration":{yield*Jo();break}case"ExportNamedDeclaration":{yield*Ao(r);break}}},"parseExports");var qo=Object.defineProperty,q=m((e,t)=>qo(e,"name",{value:t,configurable:!0}),"n$6");const We=q(async function(e,t,o){const r=await e.resolve(t,o.id);if(H(r,`Rollup can't resolve ${t} from ${o.id}`),r.external)return null;const s=await e.load(r);return H(s,`Rollup doesn't have a module for id ${r.id}`),s},"getImportedModule"),Bo=q(async function*(e,t,o){const r=await We(e,t.source,o);r&&(yield*ue(e,r))},"gatherBarrelReExports"),Wo=q(async function*(e,t,o){const r=await We(e,t.source,o);if(!r)return;const s=new Map(t.bindings.map(n=>[n.importedName,n]));for await(const n of ue(e,r)){const i=s.get(n.exportedName);i&&(yield{...n,exportedName:i.exportedName})}},"gatherNamedReExports"),Uo=q(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),ue=q(async function*(e,t){for(const o of Lo(e,t))o.from==="self"?yield*Uo(t,o):o.type==="barrel"?yield*Bo(e,o,t):yield*Wo(e,o,t)},"gatherExports");var zo=Object.defineProperty,Vo=m((e,t)=>zo(e,"name",{value:t,configurable:!0}),"n$5");const Ho=Vo(({preserveChunkSignature:e=!1}={})=>({moduleParsed:{async handler(t){if(t.isEntry)for await(const o of ue(this,t))o.id!==t.id&&this.emitFile({id:o.id,name:o.exportedName,preserveSignature:e,type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");var Go=Object.defineProperty,Xo=m((e,t)=>Go(e,"name",{value:t,configurable:!0}),"m$7");const Ue=Xo(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk(r,s,n){if(s.type!=="chunk"||!s.isEntry)return null;if(n.format==="cjs"&&n.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(i===null||i.length<3)return null;const l=new R(r);l.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),l.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&l.append(`
6
+ `)),await b.writeFile(`${s}.d.cts`,[`export * from ${JSON.stringify(i)};`,p?`export { default } from ${JSON.stringify(i)};`:""].join(`
7
+ `)),await b.writeFile(`${s}.d.mts`,[`export * from ${JSON.stringify(n)};`,p?`export { default } from ${JSON.stringify(n)};`:""].join(`
8
+ `)),a&&(await oe(`${s}.cjs`),await oe(`${s}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var so=Object.defineProperty,io=m((e,t)=>so(e,"name",{value:t,configurable:!0}),"r$8");const Te=io((e,t)=>Fe(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var ao=Object.defineProperty,lo=m((e,t)=>ao(e,"name",{value:t,configurable:!0}),"i$9");const ce=lo(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var co=Object.defineProperty,Je=m((e,t)=>co(e,"name",{value:t,configurable:!0}),"e$2");const G=Je(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Le=Je((e,t,o,r)=>{if(r){const i=G(r);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[s,...n]=t;return Le(s,n,o,r)},"inferExportType");var po=Object.defineProperty,uo=m((e,t)=>po(e,"name",{value:t,configurable:!0}),"i$8");const fo=new Set(["import","require","node","node-addons","default","types","deno","browser",...k.SPECIAL_EXPORT_CONVENTIONS]),pe=uo((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const s=G(e);if(s&&s!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:s??t}]}return Object.entries(e).filter(([s])=>!s.endsWith(".json")).flatMap(([s,n])=>o===!1&&s==="types"?[]:typeof n=="string"?{file:n,key:"exports",...fo.has(s)?{subKey:s}:{},type:Le(s,r,t,n)}:pe(n,t,o,[...r,s]))},"extractExportFilenames");var mo=Object.defineProperty,K=m((e,t)=>mo(e,"name",{value:t,configurable:!0}),"c$c");const go=K((e,t)=>e.key==="exports"&&e.subKey===k.PRODUCTION_ENV?k.PRODUCTION_ENV:e.key==="exports"&&e.subKey===k.DEVELOPMENT_ENV?k.DEVELOPMENT_ENV:t,"getEnvironment"),B=K((e,t,o,r,s,n)=>{const i=go(s,n.environment);let l="node";for(const p of k.RUNTIME_EXPORT_CONVENTIONS)if(s.file.includes("."+p+".")||s.subKey===p){l=p;break}let a=e.find(p=>p.input===t&&p.environment===i&&p.runtime===l);a===void 0&&(a=e[e.push({environment:i,input:t,runtime:l})-1]),o&&(a.outDir=r),s.isExecutable?(a.executable=!0,a.declaration=!1,s.type==="cjs"&&(a.cjs=!0),s.type==="esm"&&(a.esm=!0)):(/\.d\.[mc]?ts$/.test(s.file)&&n.options.declaration!==!1&&(a.declaration=n.options.declaration),s.type==="cjs"&&(a.cjs=!0),s.type==="esm"&&(a.esm=!0));const c=s.file.replace(f.extname(s.file),"").replace(new RegExp(`^./${n.options.outDir.replace(/^\.\//,"")}/`),"");k.SPECIAL_EXPORT_CONVENTIONS.has(s.subKey)&&!t.includes(c)&&(a.fileAlias=c)},"createOrUpdateEntry");let be=!1;const $e=K(e=>{if(e.pkg?.dependencies?.typescript===void 0&&e.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},"validateIfTypescriptIsInstalled"),ho=K((e,t,o)=>{const r=[];t.sort((l,a)=>l.split("/").length-a.split("/").length);const s=e.type==="module"?"esm":"cjs";s==="esm"&&(o.options.emitESM=!0),s==="cjs"&&(o.options.emitCJS=!0);const n=pe(e.exports,s,o.options.declaration);if(e.bin){const l=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const a of l){const c=G(a);if(c&&c!==s)throw new Error(`Exported file "${a}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);n.push({file:a,isExecutable:!0,key:"bin",type:c??s})}}e.main&&n.push({file:e.main,key:"main",type:G(e.main)??s}),e.module&&n.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&($e(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),n.push({file:e.types??e.typings,key:"types"}));const i=[];for(const l of n){o.options.declaration===void 0&&(l.key==="types"||l.subKey==="types")&&(o.options.declaration=l.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&l.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&l.type==="esm"&&(o.options.emitESM=!0);const a=l.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=a.endsWith("/");if(c&&["./","/"].includes(a))continue;const p=a.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),d="(?<=/|$)",u=c?"":"\\.\\w+$";if(l.file.includes("/*")&&l.key==="exports"){be||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),be=!0);const w=[],$=new RegExp(d+p.replace("*","(.*)")+u),j=new RegExp(d+p.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+u);for(const E of t)($.test(E)||k.SPECIAL_EXPORT_CONVENTIONS.has(l.subKey)&&j.test(E))&&w.push(E);if(w.length===0){r.push(`Could not find entrypoint for \`${l.file}\``);continue}for(const E of w)B(i,E,c,a,l,o);continue}const g=new RegExp(d+p+u);let y=t.find(w=>g.test(w));if(k.SPECIAL_EXPORT_CONVENTIONS.has(l.subKey)&&y===void 0){const w=new RegExp(d+p.replace(/(.*)\.[^.]*$/,"$1")+u);y=t.find($=>w.test($))}if(y===void 0){b.isAccessibleSync(f.resolve(o.options.rootDir,l.file))||r.push(`Could not find entrypoint for \`${l.file}\``);continue}(y.endsWith(".ts")||y.endsWith(".cts")||y.endsWith(".mts"))&&b.isAccessibleSync(y)&&$e(o);const h=y.replace(k.ENDING_RE,"");b.isAccessibleSync(h+".cts")&&b.isAccessibleSync(h+".mts")?(B(i,h+".cts",c,a,{...l,type:"cjs"},o),B(i,h+".mts",c,a,{...l,type:"esm"},o)):B(i,y,c,a,l,o)}return{entries:i,warnings:r}},"inferEntries");var yo=Object.defineProperty,vo=m((e,t)=>yo(e,"name",{value:t,configurable:!0}),"o$3");const bo=vo((e,t)=>{const{publishConfig:o}=e;return o&&(o.bin&&(typeof o.bin=="object"||typeof o.bin=="string")&&(e.bin=o.bin),o.type&&typeof o.type=="string"&&o.type!==""&&(e.type=o.type),o.main&&typeof o.main=="string"&&o.main!==""&&(e.main=o.main),o.module&&typeof o.module=="string"&&o.module!==""&&(e.module=o.module),t===void 0&&o.types&&typeof o.types=="string"&&o.types!==""?e.types=o.types:t===void 0&&o.typings&&typeof o.typings=="string"&&o.typings!==""&&(e.typings=o.typings),o.exports&&typeof o.exports=="object"&&(e.exports=o.exports)),e},"overwriteWithPublishConfig");var $o=Object.defineProperty,wo=m((e,t)=>$o(e,"name",{value:t,configurable:!0}),"l$9");const jo={hooks:{"build:prepare":wo(function(e){if(e.options.entries.length>0)return;const t=f.join(e.options.rootDir,e.options.sourceDir);if(!ie.existsSync(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=b.collectSync(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let r={...e.pkg};r.publishConfig&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(r.publishConfig).join(", ")+'".'),e.logger.debug(ce(r.publishConfig)),r=bo(r,e.options.declaration));const s=ho(r,o,e);for(const n of s.warnings)J(e,n);if(e.options.entries.push(...s.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",v.cyan(e.options.entries.map(n=>n.fileAlias?v.bold(n.fileAlias)+" => "+v.bold(n.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):v.bold(n.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),v.gray([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(n=>`[${n}]`).join(" ")))},"build:prepare")}};var ko=Object.defineProperty,xo=m((e,t)=>ko(e,"name",{value:t,configurable:!0}),"n$9");const Eo=xo((e,t)=>{if(e==="auto")e=jo;else{if(e==="none")return{};typeof e=="string"&&(e=Te(e,t))}return typeof e=="function"&&(e=e()),e},"resolvePreset");var Oo=Object.defineProperty,So=m((e,t)=>Oo(e,"name",{value:t,configurable:!0}),"a$c");const re=So((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var No=Object.defineProperty,Do=m((e,t)=>No(e,"name",{value:t,configurable:!0}),"a$b");const A=Do(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var _o=Object.defineProperty,Po=m((e,t)=>_o(e,"name",{value:t,configurable:!0}),"a$a");const qe=Po((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var Co=Object.defineProperty,Be=m((e,t)=>Co(e,"name",{value:t,configurable:!0}),"s$c");const Ro=Be((e,t,o)=>{const r=o??new Map;return(...s)=>{const n=t?typeof t=="function"?t(...s):t:JSON.stringify({args:s}),i=r.get(n);if(i!==void 0)return i;const l=e(...s);return r.set(n,l),l}},"memoize"),Io=Be(e=>{const t=new Map;return o=>Ro(e,o,t)},"memoizeByKey");var Fo=Object.defineProperty,L=m((e,t)=>Fo(e,"name",{value:t,configurable:!0}),"r$5");const Mo=L(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;H(t,"Expected class/function to have a name"),yield t.name;break}case"VariableDeclaration":{for(const t of e.declaration.declarations)for(const o of _.extractAssignedNames(t.id))yield o;break}}},"exportName"),Ao=L(function*(e){if(e.declaration)for(const t of Mo(e))yield{exportedName:t,from:"self",type:"named"};else if(e.source)yield{bindings:e.specifiers.map(t=>({exportedName:t.exported.name,importedName:t.local.name})),from:"other",source:e.source.value,type:"named"};else for(const t of e.specifiers)yield{exportedName:t.exported.name,from:"self",type:"named"}},"parseExportNamed"),To=L(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),Jo=L(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),Lo=L(function*(e,t){H(t.code!=null,`Module ${t.id} doesn't have associated code`);const o=e.parse(t.code);for(const r of o.body)switch(r.type){case"ExportAllDeclaration":{yield*To(r);break}case"ExportDefaultDeclaration":{yield*Jo();break}case"ExportNamedDeclaration":{yield*Ao(r);break}}},"parseExports");var qo=Object.defineProperty,q=m((e,t)=>qo(e,"name",{value:t,configurable:!0}),"n$6");const We=q(async function(e,t,o){const r=await e.resolve(t,o.id);if(H(r,`Rollup can't resolve ${t} from ${o.id}`),r.external)return null;const s=await e.load(r);return H(s,`Rollup doesn't have a module for id ${r.id}`),s},"getImportedModule"),Bo=q(async function*(e,t,o){const r=await We(e,t.source,o);r&&(yield*ue(e,r))},"gatherBarrelReExports"),Wo=q(async function*(e,t,o){const r=await We(e,t.source,o);if(!r)return;const s=new Map(t.bindings.map(n=>[n.importedName,n]));for await(const n of ue(e,r)){const i=s.get(n.exportedName);i&&(yield{...n,exportedName:i.exportedName})}},"gatherNamedReExports"),Uo=q(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),ue=q(async function*(e,t){for(const o of Lo(e,t))o.from==="self"?yield*Uo(t,o):o.type==="barrel"?yield*Bo(e,o,t):yield*Wo(e,o,t)},"gatherExports");var zo=Object.defineProperty,Vo=m((e,t)=>zo(e,"name",{value:t,configurable:!0}),"n$5");const Ho=Vo(({preserveChunkSignature:e=!1}={})=>({moduleParsed:{async handler(t){if(t.isEntry)for await(const o of ue(this,t))o.id!==t.id&&this.emitFile({id:o.id,name:o.exportedName,preserveSignature:e,type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");var Go=Object.defineProperty,Xo=m((e,t)=>Go(e,"name",{value:t,configurable:!0}),"m$6");const Ue=Xo(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk(r,s,n){if(s.type!=="chunk"||!s.isEntry)return null;if(n.format==="cjs"&&n.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(i===null||i.length<3)return null;const l=new R(r);l.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),l.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&l.append(`
9
9
  module.exports.default = `+i[2]+";");let a=l.toString();return a=a.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+s.fileName+".",prefix:"plugin:cjs-interop"}),{code:a,map:l.generateMap({hires:!0})}}if(n.format==="es"&&/\.d\.(?:ts|cts)$/.test(s.fileName)){if(o!=="commonjs"&&s.fileName.endsWith(".d.ts"))return null;const i=/export\s\{\s(.*)\s\}/i.exec(r);if(i===null||i.length<2)return null;const l=i[1].split(", "),a=[];let c="";for(const d of l)if(!d.includes("type"))if(d.includes("as")){const[u,g]=d.split(" as ");if(g==="default"&&(c=u,!e))continue;a.push(g+": typeof "+u+";")}else a.push(d+": typeof "+d+";");const p=new R(r);return p.replace(" "+c+" as default,",""),p.append(`
10
10
 
11
11
  declare const defaultExport: {
@@ -13,7 +13,7 @@ declare const defaultExport: {
13
13
  `)+`
14
14
  }`+(c?" & typeof "+c:"")+`;
15
15
 
16
- export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+s.fileName+".",prefix:"plugin:cjs-interop"}),{code:p.toString(),map:p.generateMap({hires:!0})}}return null}}),"cjsInterop");var Ko=Object.defineProperty,Yo=m((e,t)=>Ko(e,"name",{value:t,configurable:!0}),"u$8");const Qo=Yo((e,t)=>{const o=new Map,r={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:s}=r;return Array.isArray(s)?s=s.map(n=>{if(typeof n=="string")return{src:n};if(typeof n=="object"&&"src"in n)return n}).filter(Boolean):typeof s=="string"&&(s=[{src:s}]),{async buildStart(){const n=await Promise.all(s.flatMap(i=>Array.isArray(i.src)?i.src.map(l=>({...i,src:l})):i).map(async i=>await Ie.glob(A(i.src),{ignore:A(i.exclude).filter(Boolean)}).then(l=>({dest:i.dest??"",parent:Bt(i.src),src:l}))));for(const i of n)for(const l of i.src){let a;o.has(l)?a=o.get(l):(a={copied:[],dest:[],timestamp:0},o.set(l,a));const c=r.flatten?f.normalize(i.dest):f.join(i.dest,f.relative(i.parent,f.dirname(l)));a.dest.includes(c)||a.dest.push(c),this.addWatchFile(l)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([i,l])=>{let a;try{const c=await ne.stat(i);if(!c.isFile())return;const p=c.mtime.getTime();p>l.timestamp&&(l.timestamp=p,l.copied=[]),a=await $.readFile(i,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const c of l.dest){if(r.copyOnce&&l.copied.includes(c))continue;const p=f.basename(i),d=f.join(c,p);try{this.emitFile({[r.exactFileNames?"fileName":"name"]:d,source:a,type:"asset"}),t.debug({message:`copied ${i} → ${d}`,prefix:"plugin:copy"}),l.copied.push(c)}catch(u){t.error({context:[u],message:`error copying file ${i} → ${d}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Zo=Object.defineProperty,Y=m((e,t)=>Zo(e,"name",{value:t,configurable:!0}),"t$5");const er=/\Wrequire(?:\.resolve)?\(/,tr=Y((e,t)=>{if(se.env.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes("// -- packem CommonJS __filename shim")||e.includes("// -- packem CommonJS __dirname shim")||e.includes("// -- packem CommonJS require shim")))return null;let o=!1,r=!1,s=!1;if(e.includes("__filename")&&(o=!0),e.includes("__dirname")&&(r=!0),er.test(e)&&(s=!0),!o&&!r&&!s)return null;const n=V.findStaticImports(e).pop(),i=n?n.end:0,l=new R(e);return l.appendRight(i,t(o,r,s)),{code:l.toString(),map:l.generateMap()}},"CJSToESM"),or=Y((e,t,o)=>{let r="";return(e||t)&&(r+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
16
+ export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+s.fileName+".",prefix:"plugin:cjs-interop"}),{code:p.toString(),map:p.generateMap({hires:!0})}}return null}}),"cjsInterop");var Ko=Object.defineProperty,Yo=m((e,t)=>Ko(e,"name",{value:t,configurable:!0}),"u$8");const Qo=Yo((e,t)=>{const o=new Map,r={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:s}=r;return Array.isArray(s)?s=s.map(n=>{if(typeof n=="string")return{src:n};if(typeof n=="object"&&"src"in n)return n}).filter(Boolean):typeof s=="string"&&(s=[{src:s}]),{async buildStart(){const n=await Promise.all(s.flatMap(i=>Array.isArray(i.src)?i.src.map(l=>({...i,src:l})):i).map(async i=>await Ie.glob(A(i.src),{ignore:A(i.exclude).filter(Boolean)}).then(l=>({dest:i.dest??"",parent:Bt(i.src),src:l}))));for(const i of n)for(const l of i.src){let a;o.has(l)?a=o.get(l):(a={copied:[],dest:[],timestamp:0},o.set(l,a));const c=r.flatten?f.normalize(i.dest):f.join(i.dest,f.relative(i.parent,f.dirname(l)));a.dest.includes(c)||a.dest.push(c),this.addWatchFile(l)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([i,l])=>{let a;try{const c=await ne.stat(i);if(!c.isFile())return;const p=c.mtime.getTime();p>l.timestamp&&(l.timestamp=p,l.copied=[]),a=await b.readFile(i,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const c of l.dest){if(r.copyOnce&&l.copied.includes(c))continue;const p=f.basename(i),d=f.join(c,p);try{this.emitFile({[r.exactFileNames?"fileName":"name"]:d,source:a,type:"asset"}),t.debug({message:`copied ${i} → ${d}`,prefix:"plugin:copy"}),l.copied.push(c)}catch(u){t.error({context:[u],message:`error copying file ${i} → ${d}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Zo=Object.defineProperty,Y=m((e,t)=>Zo(e,"name",{value:t,configurable:!0}),"t$5");const er=/\Wrequire(?:\.resolve)?\(/,tr=Y((e,t)=>{if(se.env.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes("// -- packem CommonJS __filename shim")||e.includes("// -- packem CommonJS __dirname shim")||e.includes("// -- packem CommonJS require shim")))return null;let o=!1,r=!1,s=!1;if(e.includes("__filename")&&(o=!0),e.includes("__dirname")&&(r=!0),er.test(e)&&(s=!0),!o&&!r&&!s)return null;const n=V.findStaticImports(e).pop(),i=n?n.end:0,l=new R(e);return l.appendRight(i,t(o,r,s)),{code:l.toString(),map:l.generateMap()}},"CJSToESM"),or=Y((e,t,o)=>{let r="";return(e||t)&&(r+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
17
17
  `),t&&(r+=`import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
18
18
  `),o&&(r+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
19
19
  `),(e||t)&&(r+=`const __filename = __cjs_url__.fileURLToPath(import.meta.url);
@@ -23,12 +23,12 @@ export default defaultExport;`),t.debug({message:"Applied CommonJS interop to en
23
23
  `),e&&(r+=`const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
24
24
  `),t&&(r+=`const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
25
25
  `),o&&(r+=`const require = __cjs_mod__.createRequire(import.meta.url);
26
- `),r},"generateCJSShimNode20_11"),nr=Y((e,t)=>{const o=_.createFilter(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(r,s,n){if(n.format==="es"&&o(s.fileName)){let i=or;if(e.engines?.node){const l=Re.minVersion(e.engines.node);l&&l.major>=20&&l.minor>=11&&(i=rr)}return tr(r,i)}return null}}},"esmShimCjsSyntaxPlugin");var sr=Object.defineProperty,ir=m((e,t)=>sr(e,"name",{value:t,configurable:!0}),"n$4");const ar=ir(()=>({name:"packem:cjs",renderChunk(e,t,o){return o.format==="es"||o.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(o.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var lr=Object.defineProperty,cr=m((e,t)=>lr(e,"name",{value:t,configurable:!0}),"s$a");const pr=cr((...e)=>{if(e.length===0)return"";if(e.length===1)return f.dirname(e[0]);e=e.map(s=>f.toNamespacedPath(s));const[t,...o]=e;let r=t.split("/");for(const s of o){const n=s.split("/",r.length);let i=0;for(const l of n)if(l===r[i])i+=1;else{r=r.slice(0,i);break}r=r.slice(0,i)}return r.length<=1&&r[0]===""?`/${r[0]}`:r.join("/")},"lowestCommonAncestor");var ur=Object.defineProperty,Q=m((e,t)=>ur(e,"name",{value:t,configurable:!0}),"m$5");const dr=Q((e,t,o,r={})=>{const s=_.createFilter(r.include,r.exclude),n={},i=Q((c,p)=>{n[c.replace(/\..?[jt]s$/,"")]=p},"addOutput");async function l(c,p){if(!s(p))return;const{errors:d,sourceText:u}=await e(p,c);if(d.length>0){if(r.ignoreErrors){this.warn(d[0]);return}return this.error(d[0])}i(p,u);let g;try{g=JSON.parse((await Dt.parseAsync(c,{sourceFilename:p})).program)}catch{return}const y=g.body.filter(h=>h.type!=="ImportDeclaration"?!1:h.importKind==="type"?!0:(h.specifiers||[]).every(b=>b.type==="ImportSpecifier"&&b.importKind==="type"));for await(const h of y)this.resolve(h.source.value,p).then(async b=>{if(!b)return;const w=b.id;if(s(w)&&!n[w.replace(k.ENDING_RE,"")])try{const j=await $.readFile(w);await l.call(this,j,w)}catch{}}).catch(b=>{console.log(b)})}m(l,"g"),Q(l,"transform");const a=o==="module"?"es":"cjs";return{name:"packem:isolated-declarations",renderStart(c,{input:p}){const d=pr(...Array.isArray(p)?p:Object.values(p));typeof c.entryFileNames=="function"&&(c.entryFileNames=c.entryFileNames({name:c.name}));const u=c.entryFileNames.replace(/\.(.)?[jt]s$/,(g,y)=>`.d.${y||""}ts`);for(const[g,y]of Object.entries(n)){(t===!0||t==="compatible")&&c.format===a&&this.emitFile({fileName:u.replace("[name]",f.relative(d,g)).replace(a==="cjs"?".cts":".mts",".ts"),source:y,type:"asset"});const h=y.includes("from '")?"'":'"';this.emitFile({fileName:u.replace("[name]",f.relative(d,g)),source:y.replaceAll(/from\s+['"]([^'"]+)['"]/g,(b,w)=>`from ${h}${w.replace(k.ENDING_RE,"")}${c.format==="cjs"?".cts":".mts"}${h}`),type:"asset"})}},transform:l}},"isolatedDeclarationsPlugin");var fr=Object.defineProperty,mr=m((e,t)=>fr(e,"name",{value:t,configurable:!0}),"n$3");const we="export default ",ze=mr(e=>{const t=Wt(e);return{...t,name:"packem:json",transform(o,r){const s=t.transform?.call(this,o,r);return s&&typeof s!="string"&&"code"in s&&s.code?.startsWith(we)&&(s.code=s.code.replace(we,"module.exports = ")),s}}},"JSONPlugin");class gr{static{m(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(t=>this.replacement=t,"replace")}}replace(t,o,r,s){t&&o&&(r!=null?t[o][r]=s:t[o]=s)}remove(t,o,r){t&&o&&(r!=null?t[o].splice(r,1):delete t[o])}}class hr extends gr{static{m(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(r=>this.replacement=r,"replace")},this.enter=t,this.leave=o}visit(t,o,r,s){if(t){if(this.enter){const i=this.should_skip,l=this.should_remove,a=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,r,s),this.replacement&&(t=this.replacement,this.replace(o,r,s,t)),this.should_remove&&this.remove(o,r,s);const c=this.should_skip,p=this.should_remove;if(this.should_skip=i,this.should_remove=l,this.replacement=a,c)return t;if(p)return null}let n;for(n in t){const i=t[n];if(i&&typeof i=="object")if(Array.isArray(i)){const l=i;for(let a=0;a<l.length;a+=1){const c=l[a];je(c)&&(this.visit(c,t,n,a)||a--)}}else je(i)&&this.visit(i,t,n,null)}if(this.leave){const i=this.replacement,l=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,r,s),this.replacement&&(t=this.replacement,this.replace(o,r,s,t)),this.should_remove&&this.remove(o,r,s);const a=this.should_remove;if(this.replacement=i,this.should_remove=l,a)return null}}return t}}function je(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(je,"isNode");function Ve(e,{enter:t,leave:o}){return new hr(t,o).visit(e,null)}m(Ve,"walk");var yr=Object.defineProperty,vr=m((e,t)=>yr(e,"name",{value:t,configurable:!0}),"u$7");const br=vr(({attributes:e,logger:t})=>{const o=_.createFilter([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(r,s){if(!o(s))return null;let n=null;try{n=this.parse(r,{allowReturnOutsideFunction:!0})}catch(a){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${s}" and remove the jsx attribute.`}),t.warn(a),null}let i=!1;const l=new R(r);return Ve(n,{enter(a){if(a.type==="CallExpression"&&a.callee.type==="Identifier"&&a.callee.name==="jsx"){const c=a.arguments.filter(p=>p.type==="ObjectExpression"&&Array.isArray(p.properties));for(const p of c)for(const d of p.properties)d.type==="Property"&&d.key.type==="Literal"&&d.value.type==="Literal"&&e.includes(d.key.value)&&(l.overwrite(d.start-2,d.end,""),i=!0)}}}),i?{code:l.toString(),map:l.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var $r=Object.defineProperty,de=m((e,t)=>$r(e,"name",{value:t,configurable:!0}),"g$4");const wr=de(e=>{const t=[],o=[];return e.forEach(r=>{r.startsWith("(")?t.push(r):o.push(r)}),[...o.sort(),...t.sort()]},"sortLicenses"),jr=de((e,t,o)=>{const r=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(r.test(e))return e.replace(r,`$1
26
+ `),r},"generateCJSShimNode20_11"),nr=Y((e,t)=>{const o=_.createFilter(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(r,s,n){if(n.format==="es"&&o(s.fileName)){let i=or;if(e.engines?.node){const l=Re.minVersion(e.engines.node);l&&l.major>=20&&l.minor>=11&&(i=rr)}return tr(r,i)}return null}}},"esmShimCjsSyntaxPlugin");var sr=Object.defineProperty,ir=m((e,t)=>sr(e,"name",{value:t,configurable:!0}),"n$4");const ar=ir(()=>({name:"packem:cjs",renderChunk(e,t,o){return o.format==="es"||o.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(o.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var lr=Object.defineProperty,cr=m((e,t)=>lr(e,"name",{value:t,configurable:!0}),"s$a");const pr=cr((...e)=>{if(e.length===0)return"";if(e.length===1)return f.dirname(e[0]);e=e.map(s=>f.toNamespacedPath(s));const[t,...o]=e;let r=t.split("/");for(const s of o){const n=s.split("/",r.length);let i=0;for(const l of n)if(l===r[i])i+=1;else{r=r.slice(0,i);break}r=r.slice(0,i)}return r.length<=1&&r[0]===""?`/${r[0]}`:r.join("/")},"lowestCommonAncestor");var ur=Object.defineProperty,Q=m((e,t)=>ur(e,"name",{value:t,configurable:!0}),"c$8");const dr=Q((e,t,o,r={})=>{const s=_.createFilter(r.include,r.exclude),n={},i=Q((c,p)=>{n[c.replace(/\..?[jt]s$/,"")]=p},"addOutput");async function l(c,p){if(!s(p))return;const{errors:d,sourceText:u}=await e(p,c);if(d.length>0){if(r.ignoreErrors){this.warn(d[0]);return}return this.error(d[0])}i(p,u);let g;try{g=JSON.parse((await Dt.parseAsync(c,{sourceFilename:p})).program)}catch{return}const y=g.body.filter(h=>h.type!=="ImportDeclaration"?!1:h.importKind==="type"?!0:(h.specifiers||[]).every(w=>w.type==="ImportSpecifier"&&w.importKind==="type"));for await(const h of y){const w=await this.resolve(h.source.value,p);if(!w)return;const $=w.id;if(s($)&&!n[$.replace(k.ENDING_RE,"")])try{const j=await b.readFile($);await l.call(this,j,$)}catch{}}}m(l,"g"),Q(l,"transform");const a=o==="module"?"es":"cjs";return{name:"packem:isolated-declarations",renderStart(c,{input:p}){const d=pr(...Array.isArray(p)?p:Object.values(p));typeof c.entryFileNames=="function"&&(c.entryFileNames=c.entryFileNames({name:c.name}));const u=c.entryFileNames.replace(/\.(.)?[jt]s$/,(g,y)=>`.d.${y||""}ts`);for(const[g,y]of Object.entries(n)){(t===!0||t==="compatible")&&c.format===a&&this.emitFile({fileName:u.replace("[name]",f.relative(d,g)).replace(a==="cjs"?".cts":".mts",".ts"),source:y,type:"asset"});const h=y.includes("from '")?"'":'"';this.emitFile({fileName:u.replace("[name]",f.relative(d,g)),source:y.replaceAll(/from\s+['"]([^'"]+)['"]/g,(w,$)=>`from ${h}${$.replace(k.ENDING_RE,"")}${c.format==="cjs"?".cts":".mts"}${h}`),type:"asset"})}},transform:l}},"isolatedDeclarationsPlugin");var fr=Object.defineProperty,mr=m((e,t)=>fr(e,"name",{value:t,configurable:!0}),"n$3");const we="export default ",ze=mr(e=>{const t=Wt(e);return{...t,name:"packem:json",transform(o,r){const s=t.transform?.call(this,o,r);return s&&typeof s!="string"&&"code"in s&&s.code?.startsWith(we)&&(s.code=s.code.replace(we,"module.exports = ")),s}}},"JSONPlugin");class gr{static{m(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(t=>this.replacement=t,"replace")}}replace(t,o,r,s){t&&o&&(r!=null?t[o][r]=s:t[o]=s)}remove(t,o,r){t&&o&&(r!=null?t[o].splice(r,1):delete t[o])}}class hr extends gr{static{m(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(r=>this.replacement=r,"replace")},this.enter=t,this.leave=o}visit(t,o,r,s){if(t){if(this.enter){const i=this.should_skip,l=this.should_remove,a=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,r,s),this.replacement&&(t=this.replacement,this.replace(o,r,s,t)),this.should_remove&&this.remove(o,r,s);const c=this.should_skip,p=this.should_remove;if(this.should_skip=i,this.should_remove=l,this.replacement=a,c)return t;if(p)return null}let n;for(n in t){const i=t[n];if(i&&typeof i=="object")if(Array.isArray(i)){const l=i;for(let a=0;a<l.length;a+=1){const c=l[a];je(c)&&(this.visit(c,t,n,a)||a--)}}else je(i)&&this.visit(i,t,n,null)}if(this.leave){const i=this.replacement,l=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,r,s),this.replacement&&(t=this.replacement,this.replace(o,r,s,t)),this.should_remove&&this.remove(o,r,s);const a=this.should_remove;if(this.replacement=i,this.should_remove=l,a)return null}}return t}}function je(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(je,"isNode");function Ve(e,{enter:t,leave:o}){return new hr(t,o).visit(e,null)}m(Ve,"walk");var yr=Object.defineProperty,vr=m((e,t)=>yr(e,"name",{value:t,configurable:!0}),"u$7");const br=vr(({attributes:e,logger:t})=>{const o=_.createFilter([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(r,s){if(!o(s))return null;let n=null;try{n=this.parse(r,{allowReturnOutsideFunction:!0})}catch(a){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${s}" and remove the jsx attribute.`}),t.warn(a),null}let i=!1;const l=new R(r);return Ve(n,{enter(a){if(a.type==="CallExpression"&&a.callee.type==="Identifier"&&a.callee.name==="jsx"){const c=a.arguments.filter(p=>p.type==="ObjectExpression"&&Array.isArray(p.properties));for(const p of c)for(const d of p.properties)d.type==="Property"&&d.key.type==="Literal"&&d.value.type==="Literal"&&e.includes(d.key.value)&&(l.overwrite(d.start-2,d.end,""),i=!0)}}}),i?{code:l.toString(),map:l.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var $r=Object.defineProperty,de=m((e,t)=>$r(e,"name",{value:t,configurable:!0}),"g$4");const wr=de(e=>{const t=[],o=[];return e.forEach(r=>{r.startsWith("(")?t.push(r):o.push(r)}),[...o.sort(),...t.sort()]},"sortLicenses"),jr=de((e,t,o)=>{const r=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(r.test(e))return e.replace(r,`$1
27
27
  ${o}
28
- $2`)},"replaceContentWithin"),He=de(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:r,marker:s,mode:n,packageName:i})=>Ut({thirdParty(l){const a=new Set,c=l.sort(({name:d},{name:u})=>(d||0)>(u||0)?1:(u||0)>(d||0)?-1:0).map(({author:d,contributors:u,license:g,licenseText:y,maintainers:h,name:b,repository:w})=>{let j="## "+b+`
28
+ $2`)},"replaceContentWithin"),He=de(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:r,marker:s,mode:n,packageName:i})=>Ut({thirdParty(l){const a=new Set,c=l.sort(({name:d},{name:u})=>(d||0)>(u||0)?1:(u||0)>(d||0)?-1:0).map(({author:d,contributors:u,license:g,licenseText:y,maintainers:h,name:w,repository:$})=>{let j="## "+w+`
29
29
  `;g&&(j+=`License: ${g}
30
30
  `);const E=new Set;for(const D of[d,...h,...u]){const me=typeof D=="string"?D:D?.name;me&&E.add(me)}return E.size>0&&(j+=`By: ${[...E].join(", ")}
31
- `),w&&(j+=`Repository: ${typeof w=="string"?w:w.url}
31
+ `),$&&(j+=`Repository: ${typeof $=="string"?$:$.url}
32
32
  `),y&&(j+=`
33
33
  `+y.trim().replaceAll(/\r\n|\r/g,`
34
34
  `).replaceAll(`<!-- ${s} -->`,"").replaceAll(e?`<!-- ${e} -->`:"","").trim().split(`
@@ -37,11 +37,11 @@ $2`)},"replaceContentWithin"),He=de(({dtsMarker:e,licenseFilePath:t,licenseTempl
37
37
  `),g&&a.add(g),j}).join(`
38
38
  ---------------------------------------
39
39
 
40
- `);if(c===""){r.info({message:"No dependencies license information found.",prefix:"plugin:license:"+n});return}const p=o(wr(a),c,i);try{const d=$.readFileSync(t),u=jr(d,s,p);if(!u){r.error({message:`Could not find the license marker: <!-- ${s} --> in ${t}`,prefix:"plugin:license:"+n});return}d!==u&&($.writeFileSync(t,u),r.info({message:`${t} updated.`,prefix:"plugin:license:"+n}))}catch(d){r.error(d)}}}),"license");var kr=Object.defineProperty,xr=m((e,t)=>kr(e,"name",{value:t,configurable:!0}),"i$5");const Er=xr(e=>({async buildEnd(){const t=[];for(const r of this.getModuleIds()){const s=this.getModuleInfo(r);if(s!=null&&!s.isExternal)for(const n of s.importedIds)t.push({source:r,target:n})}if(Array.isArray(t)&&t.length===0)return;const o=f.resolve(e.rootDir,e.outDir,"graph.json");$.writeJsonSync(o,t)},name:"packem:metafile"}),"metafilePlugin");var Or=Object.defineProperty,Sr=m((e,t)=>Or(e,"name",{value:t,configurable:!0}),"r$3");const I=Sr(e=>{const t=Ct.createHash("md5");return t.update(e),t.digest("hex")},"getHash");var Nr=Object.defineProperty,Ge=m((e,t)=>Nr(e,"name",{value:t,configurable:!0}),"d$4");const M=Ge(e=>e.handler||e,"getHandler"),N=Ge((e,t,o="")=>({...e,async buildEnd(r){e.buildEnd&&await M(e.buildEnd).call(this,r)},async buildStart(r){e.buildStart&&await M(e.buildStart).call(this,r)},async load(r){if(!e.load)return null;const s=f.join(o,e.name),n=f.join("load",I(r));if(t.has(n,s))return await t.get(n,s);const i=await M(e.load).call(this,r);return t.set(n,i,s),i},name:`cached(${e.name})`,async resolveId(r,s,n){if(!e.resolveId)return null;const i=f.join(o,e.name),l=f.join("resolveId",I(r),s?I(s):"",I(JSON.stringify(n)));if(t.has(l,i))return await t.get(l,i);const a=await M(e.resolveId).call(this,r,s,n);return t.set(l,a,i),a},async transform(r,s){if(!e.transform)return null;const n=f.join(o,e.name),i=f.join("transform",I(s),I(r));if(t.has(i,n))return await t.get(i,n);const l=await M(e.transform).call(this,r,s);return t.set(i,l,n),l}}),"cachingPlugin");var Dr=Object.defineProperty,_r=m((e,t)=>Dr(e,"name",{value:t,configurable:!0}),"n$2");const Pr=_r(()=>({name:"prependDirective",transform:{handler(e,t){const o=this.getModuleInfo(t);if(o?.meta.preserveDirectives){const r=o.meta.preserveDirectives.directives[0];if(r)return`'${r.value}';
40
+ `);if(c===""){r.info({message:"No dependencies license information found.",prefix:"plugin:license:"+n});return}const p=o(wr(a),c,i);try{const d=b.readFileSync(t),u=jr(d,s,p);if(!u){r.error({message:`Could not find the license marker: <!-- ${s} --> in ${t}`,prefix:"plugin:license:"+n});return}d!==u&&(b.writeFileSync(t,u),r.info({message:`${t} updated.`,prefix:"plugin:license:"+n}))}catch(d){r.error(d)}}}),"license");var kr=Object.defineProperty,xr=m((e,t)=>kr(e,"name",{value:t,configurable:!0}),"i$5");const Er=xr(e=>({async buildEnd(){const t=[];for(const r of this.getModuleIds()){const s=this.getModuleInfo(r);if(s!=null&&!s.isExternal)for(const n of s.importedIds)t.push({source:r,target:n})}if(Array.isArray(t)&&t.length===0)return;const o=f.resolve(e.rootDir,e.outDir,"graph.json");b.writeJsonSync(o,t)},name:"packem:metafile"}),"metafilePlugin");var Or=Object.defineProperty,Sr=m((e,t)=>Or(e,"name",{value:t,configurable:!0}),"r$3");const I=Sr(e=>{const t=Ct.createHash("md5");return t.update(e),t.digest("hex")},"getHash");var Nr=Object.defineProperty,Ge=m((e,t)=>Nr(e,"name",{value:t,configurable:!0}),"d$4");const M=Ge(e=>e.handler||e,"getHandler"),N=Ge((e,t,o="")=>({...e,async buildEnd(r){e.buildEnd&&await M(e.buildEnd).call(this,r)},async buildStart(r){e.buildStart&&await M(e.buildStart).call(this,r)},async load(r){if(!e.load)return null;const s=f.join(o,e.name),n=f.join("load",I(r));if(t.has(n,s))return await t.get(n,s);const i=await M(e.load).call(this,r);return t.set(n,i,s),i},name:`cached(${e.name})`,async resolveId(r,s,n){if(!e.resolveId)return null;const i=f.join(o,e.name),l=f.join("resolveId",I(r),s?I(s):"",I(JSON.stringify(n)));if(t.has(l,i))return await t.get(l,i);const a=await M(e.resolveId).call(this,r,s,n);return t.set(l,a,i),a},async transform(r,s){if(!e.transform)return null;const n=f.join(o,e.name),i=f.join("transform",I(s),I(r));if(t.has(i,n))return await t.get(i,n);const l=await M(e.transform).call(this,r,s);return t.set(i,l,n),l}}),"cachingPlugin");var Dr=Object.defineProperty,_r=m((e,t)=>Dr(e,"name",{value:t,configurable:!0}),"n$2");const Pr=_r(()=>({name:"prependDirective",transform:{handler(e,t){const o=this.getModuleInfo(t);if(o?.meta.preserveDirectives){const r=o.meta.preserveDirectives.directives[0];if(r)return`'${r.value}';
41
41
  `+e}return null},order:"post"}}),"prependDirectivePlugin");var Cr=Object.defineProperty,Rr=m((e,t)=>Cr(e,"name",{value:t,configurable:!0}),"c$6");const Ir=Rr(({directiveRegex:e,exclude:t=[],include:o=[],logger:r})=>{const s={},n={},i=_.createFilter(o,t);return{name:"packem:preserve-directives",onLog(l,a){return a.code==="MODULE_LEVEL_DIRECTIVE"&&l==="warn"?!1:null},renderChunk:{handler(l,a,{sourcemap:c}){const p=a.moduleIds.map(g=>s[g]?s[g]:null).reduce((g,y)=>(y&&y.forEach(h=>{g.add(h)}),g),new Set),d=new R(l);p.size>0&&(r.debug({message:`directives for chunk "${a.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),d.prepend(`${[...p].map(g=>`'${g}';`).join(`
42
42
  `)}
43
43
  `));let u=null;return a.facadeModuleId&&typeof n[a.facadeModuleId]=="string"&&(u=n[a.facadeModuleId]),u&&(r.debug({message:`shebang for chunk "${a.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),d.prepend(`${u}
44
- `)),p.size===0&&u===null?null:{code:d.toString(),map:c?d.generateMap({hires:!0}):null}},order:"post"},transform(l,a){if(!i(a))return null;let c=!1;const p=new R(l);if(l.startsWith("#")&&l[1]==="!"){let u=0;for(let g=2,y=l.length;g<y;g++){const h=l.codePointAt(g);if(h===10||h===13||h===8232||h===8233){u=g;break}}u&&(n[a]=l.slice(0,u),p.remove(0,u+1),c=!0,r.debug({message:`shebang for module "${a}" is preserved.`,prefix:"plugin:preserve-directives"}))}let d=null;try{d=this.parse(p.toString(),{allowReturnOutsideFunction:!0})}catch(u){return this.warn({code:"PARSE_ERROR",message:`failed to parse "${a}" and extract the directives.`}),r.warn(u),null}if(d.type!=="Program")return null;for(const u of d.body.filter(Boolean)){if(u.type!=="ExpressionStatement")break;let g=null;"directive"in u?g=u.directive:u.expression.type==="Literal"&&typeof u.expression.value=="string"&&e.test(u.expression.value)&&(g=u.expression.value),g!=="use strict"&&g&&(s[a]||=new Set,s[a].add(g),"start"in u&&typeof u.start=="number"&&"end"in u&&typeof u.end=="number"&&(p.remove(u.start,u.end),c=!0),r.debug({message:`directive "${g}" for module "${a}" is preserved.`,prefix:"plugin:preserve-directives"}))}return c?{code:p.toString(),map:p.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...s[a]??[]],shebang:n[a]??null}}}:null}}},"preserveDirectives");var Fr=Object.defineProperty,Mr=m((e,t)=>Fr(e,"name",{value:t,configurable:!0}),"t$3");const Ar=Mr(e=>{const t=_.createFilter(e.include,e.exclude);return{name:"packem:raw",transform(o,r){return t(r)?{code:`export default ${JSON.stringify(o)}`,map:null}:null}}},"rawPlugin");var Tr=Object.defineProperty,Jr=m((e,t)=>Tr(e,"name",{value:t,configurable:!0}),"l$5");const Z="\0__file_url__",Xe=Jr(()=>({async load(e){if(e.startsWith(Z)){const t=Pe.fileURLToPath(e.slice(Z.length));return await $.readFile(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${Z}${e}`}}),"resolveFileUrl");var Lr=Object.defineProperty,F=m((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"r$2");const qr=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Br=/MIT License|MIT license|BSD license/,Wr=/\n{2,}/g,Ur=/\b(\w+)\$\d+\b/g,zr=/[-/\\^$*+?.()|[\]{}]/g,Vr=F(e=>e.replaceAll(zr,"\\$&"),"escapeRegex"),Hr=F(e=>[...new Set(e)],"unique"),Gr=F(e=>e.replaceAll(qr,t=>Br.test(t)?"":t).replaceAll(Wr,`
44
+ `)),p.size===0&&u===null?null:{code:d.toString(),map:c?d.generateMap({hires:!0}):null}},order:"post"},transform(l,a){if(!i(a))return null;let c=!1;const p=new R(l);if(l.startsWith("#")&&l[1]==="!"){let u=0;for(let g=2,y=l.length;g<y;g++){const h=l.codePointAt(g);if(h===10||h===13||h===8232||h===8233){u=g;break}}u&&(n[a]=l.slice(0,u),p.remove(0,u+1),c=!0,r.debug({message:`shebang for module "${a}" is preserved.`,prefix:"plugin:preserve-directives"}))}let d=null;try{d=this.parse(p.toString(),{allowReturnOutsideFunction:!0})}catch(u){return this.warn({code:"PARSE_ERROR",message:`failed to parse "${a}" and extract the directives.`}),r.warn(u),null}if(d.type!=="Program")return null;for(const u of d.body.filter(Boolean)){if(u.type!=="ExpressionStatement")break;let g=null;"directive"in u?g=u.directive:u.expression.type==="Literal"&&typeof u.expression.value=="string"&&e.test(u.expression.value)&&(g=u.expression.value),g!=="use strict"&&g&&(s[a]||=new Set,s[a].add(g),"start"in u&&typeof u.start=="number"&&"end"in u&&typeof u.end=="number"&&(p.remove(u.start,u.end),c=!0),r.debug({message:`directive "${g}" for module "${a}" is preserved.`,prefix:"plugin:preserve-directives"}))}return c?{code:p.toString(),map:p.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...s[a]??[]],shebang:n[a]??null}}}:null}}},"preserveDirectives");var Fr=Object.defineProperty,Mr=m((e,t)=>Fr(e,"name",{value:t,configurable:!0}),"t$3");const Ar=Mr(e=>{const t=_.createFilter(e.include,e.exclude);return{name:"packem:raw",transform(o,r){return t(r)?{code:`export default ${JSON.stringify(o)}`,map:null}:null}}},"rawPlugin");var Tr=Object.defineProperty,Jr=m((e,t)=>Tr(e,"name",{value:t,configurable:!0}),"l$5");const Z="\0__file_url__",Xe=Jr(()=>({async load(e){if(e.startsWith(Z)){const t=Pe.fileURLToPath(e.slice(Z.length));return await b.readFile(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${Z}${e}`}}),"resolveFileUrl");var Lr=Object.defineProperty,F=m((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"r$2");const qr=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Br=/MIT License|MIT license|BSD license/,Wr=/\n{2,}/g,Ur=/\b(\w+)\$\d+\b/g,zr=/[-/\\^$*+?.()|[\]{}]/g,Vr=F(e=>e.replaceAll(zr,"\\$&"),"escapeRegex"),Hr=F(e=>[...new Set(e)],"unique"),Gr=F(e=>e.replaceAll(qr,t=>Br.test(t)?"":t).replaceAll(Wr,`
45
45
 
46
46
  `),"cleanUnnecessaryComments"),ke=new Map;function Ke(e,t,{identifierReplacements:o},r){const s=V.findStaticImports(e);for(const i in o){const l=s.find(c=>c.specifier===i&&c.imports.includes("{"));if(!l){this.warn(`${t.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const a=o[i];for(const c in a){if(!l.imports.includes(c))throw new Error(`${t.fileName} does not import "${c}" from "${i}" for replacement`);const p=a[c],d=Vr(c);p.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${d},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${d}\\b`,"g"),p)}}const n=Hr(Array.from(e.matchAll(Ur),i=>i[0]));if(n.length>0){const i=n.map(a=>`
47
47
  - ${a}`).join(""),l=t.fileName.replace(/\.[^/.]+$/,"");ke.has(l)||r.warn({message:`${t.fileName} contains confusing identifier names${i}
@@ -57,7 +57,7 @@ ${e.replaceAll(/^\n|\n$/g,"")}
57
57
  file: ${v.cyan(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(o+=`
58
58
  `+v.yellow(xn(e.frame))),e.message=o,t!==void 0&&(e.stack=`${e.message}
59
59
  ${t}`)},"enhanceRollupError");var En=Object.defineProperty,ct=m((e,t)=>En(e,"name",{value:t,configurable:!0}),"l$3");const Se=ct((e,t,o)=>{const r="watcher:"+t;e.on("change",(s,{event:n})=>{o.info({message:`${v.cyan(f.relative(".",s))} was ${n}d`,prefix:r})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:r})}),e.on("event",async s=>{switch(s.code){case"END":{o.success({message:"Rebuild "+t+" finished",prefix:r});break}case"BUNDLE_START":{o.info({message:v.cyan("build started..."),prefix:r});break}case"BUNDLE_END":{await s.result.close(),o.info({message:v.cyan(`built in ${s.duration+""}ms.`),prefix:r});break}case"ERROR":{lt(s.error),o.error({context:[s.error],message:"Rebuild "+t+" failed: "+s.error.message,prefix:r});break}}})},"watchHandler"),On=ct(async(e,t)=>{const o=await it(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;o.cache=t.get("rollup-watch"),typeof o.watch=="object"&&o.watch.include===void 0&&(o.watch.include=[f.join(e.options.sourceDir,"**")],o.watch.chokidar={cwd:e.options.rootDir,...o.watch.chokidar});const r=T.watch(o);await e.hooks.callHook("rollup:watch",e,r);const s=[...Array.isArray(o.input)?o.input:typeof o.input=="string"?[o.input]:Object.keys(o.input??{})];let n="Starting watchers for entries:";for(const i of s)n+=v.gray(`
60
- └─ ${f.relative(process.cwd(),i)}`);if(e.logger.info(n),Se(r,"bundle",e.logger),e.options.declaration){const i=await at(e,t);await e.hooks.callHook("rollup:dts:options",e,i);const l=T.watch(i);await e.hooks.callHook("rollup:watch",e,l),Se(l,"types",e.logger)}},"watch");var Sn=Object.defineProperty,Nn=m((e,t)=>Sn(e,"name",{value:t,configurable:!0}),"a$3");class Dn{static{m(this,"p")}static{Nn(this,"FileCache")}#r;#e;#n;#t=!0;#o=new Map;#s;constructor(t,o,r){this.#r=t,this.#e=It.findCacheDirSync("@visulima/packem",{cwd:t}),this.#n=o,this.#s=r,this.#e===void 0?r.debug("Could not create cache directory."):r.debug(`Cache path is: ${this.#e}`)}set isEnabled(t){this.#t=t}get cachePath(){return this.#e}has(t,o){return!this.#t||this.#e===void 0?!1:$.isAccessibleSync(this.getFilePath(t,o))}get(t,o){if(!this.#t||this.#e===void 0)return;const r=this.getFilePath(t,o);if(this.#o.has(r))return this.#o.get(r);if(!$.isAccessibleSync(r))return;const s=$.readFileSync(r);try{const n=JSON.parse(s);return this.#o.set(r,n),n}catch{this.#s.warn(`Could not parse cache file: ${r}, deleting the broken cache file.`),this.#o.delete(r),ie.rmSync(r,{force:!0});return}}set(t,o,r){if(!this.#t||this.#e===void 0||o===void 0)return;const s=this.getFilePath(t,r);typeof o=="object"&&(o=JSON.stringify(o)),$.writeFileSync(s,o,{overwrite:!0})}getFilePath(t,o){let r=t.replaceAll(f.toNamespacedPath(this.#r),"");return r=r.replaceAll(":","-"),f.join(this.#e,this.#n,o?.replaceAll(":","-")??"",f.toNamespacedPath(r))}}var _n=Object.defineProperty,z=m((e,t)=>_n(e,"name",{value:t,configurable:!0}),"l$2");const Pn=_.createFilter,Cn=z((e,t)=>{const{sideEffects:o}=t;let r;if(typeof o=="boolean")r=z(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)r=z(()=>!1,"hasSideEffects");else{const s=o.map(n=>n.includes("/")?n:`**/${n}`);r=Pn(s,null,{resolve:e})}else r=z(()=>null,"hasSideEffects");return r},"getPackageSideEffect");var Rn=Object.defineProperty,In=m((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"y");const Fn=In((e,t,o)=>e.reduce((r,s)=>{const n=s[t],i=s[o];return r[n]||(r[n]={}),r[n][i]||(r[n][i]=[]),r[n][i].push(s),r},{}),"groupByKeys");var Mn=Object.defineProperty,pt=m((e,t)=>Mn(e,"name",{value:t,configurable:!0}),"e");const Ne=pt(async(e,t)=>{if(typeof e.name!="string"){let o=f.isAbsolute(e.input)?f.relative(t.options.rootDir,e.input):f.normalize(e.input);o.startsWith("./")&&(o=o.slice(2)),e.name=o.replace(new RegExp(`^${t.options.sourceDir}/`),"").replace(k.ENDING_RE,"")}if(!e.input)throw new Error(`Missing entry input: ${ce(e)}`);Mt.isRelative(e.input)&&(e.input=f.resolve(t.options.rootDir,e.input)),t.options.declaration&&e.declaration===void 0&&(e.declaration=t.options.declaration),t.options.emitCJS!==void 0&&e.cjs===void 0&&(e.cjs=t.options.emitCJS),t.options.emitESM!==void 0&&e.esm===void 0&&(e.esm=t.options.emitESM),e.outDir=f.resolve(t.options.rootDir,e.outDir??t.options.outDir)},"extendEntry"),An=pt(async e=>{e.options.entries=e.options.entries.map(t=>typeof t=="string"?{input:t,isGlob:ve(t)}:{...t,isGlob:ve(t.input)});for(const t of e.options.entries.filter(o=>o.isGlob)){const{isGlob:o,...r}=t,s=Ie.globSync([r.input],{cwd:e.options.rootDir,dot:!1,ignore:["**/node_modules/**"],onlyFiles:!0});if(s.length===0)throw new Ft.NotFoundError("No files found in the glob pattern: "+v.cyan(f.join(e.options.rootDir,r.input)));for(const n of s)e.options.entries.push({...r,input:f.resolve(e.options.rootDir,n)});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 Ne(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 Ne(t,e)},"prepareEntries");var Tn=Object.defineProperty,Jn=m((e,t)=>Tn(e,"name",{value:t,configurable:!0}),"a$2");const Ln=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,qn=new Set(["abstract","await","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"]),De=Jn(e=>{if(!Array.isArray(e)&&e!==null)for(const[t,o]of Object.entries(e)){if(typeof t!="string"||t.trim()==="")throw new Error(`Alias name "${t}" is invalid. Alias names should be non-empty strings.`);if(Ln.test(t))throw new Error(`Alias name "${t}" is invalid. Alias names should start with a letter or underscore and only contain letters, numbers, underscores, and dashes.`);if(qn.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const r=f.resolve(o);if(!$.isAccessibleSync(r))throw new Error(`Target path "${r}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var Bn=Object.defineProperty,Wn=m((e,t)=>Bn(e,"name",{value:t,configurable:!0}),"o");const Un=Wn(e=>{const t=new Set,o=new Set(Object.keys(e.pkg?.dependencies??{})),r=new Set;for(const s of e.usedImports)o.delete(s),t.add(s);if(e.pkg?.dependencies)for(const s of Object.keys(e.pkg?.dependencies))o.delete(s);for(const s of t){const n=qe(s);!re(e.options.externals,s)&&!s.startsWith("chunks/")&&e.pkg?.dependencies?.[n]===void 0&&e.pkg?.peerDependencies?.[n]===void 0&&r.add(s)}o.size>0&&J(e,`Potential unused dependencies found: ${[...o].map(s=>v.cyan(s)).join(", ")}`),r.size>0&&J(e,`Potential implicit dependencies found: ${[...r].map(s=>v.cyan(s)).join(", ")}`)},"validateDependencies");var zn=Object.defineProperty,ut=m((e,t)=>zn(e,"name",{value:t,configurable:!0}),"i");const Vn=ut((e,t)=>Tt.distance(e,t)<=e.length/3||t.includes(e),"isSimilar"),Hn=ut((e,t)=>{const o=e.toLowerCase();return t.filter(r=>Vn(r.toLowerCase(),o))},"findAlternatives");var Gn=Object.defineProperty,_e=m((e,t)=>Gn(e,"name",{value:t,configurable:!0}),"s");const Xn=_e((e,t)=>{const o=new Set([...typeof e.bin=="string"?[e.bin]:Object.values(e.bin??{}),e.main,e.module,t.options.declaration?e.types:"",t.options.declaration?e.typings:"",...pe(e.exports,e.type==="module"?"esm":"cjs",t.options.declaration).map(s=>s.file)].map(s=>s&&f.resolve(t.options.rootDir,s.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),r=[];for(const s of o)s&&!s.includes("*")&&!ie.existsSync(s)&&r.push(s.replace(`${t.options.rootDir}/`,""));if(r.length>0){const s=_e(l=>f.relative(t.options.rootDir,f.resolve(t.options.outDir,l)),"rPath"),n=t.buildEntries.filter(l=>!l.chunk).map(l=>s(l.path));let i="Potential missing or wrong package.json files:";for(const l of r){const a=Hn(l,n);i+=`
60
+ └─ ${f.relative(process.cwd(),i)}`);if(e.logger.info(n),Se(r,"bundle",e.logger),e.options.declaration){const i=await at(e,t);await e.hooks.callHook("rollup:dts:options",e,i);const l=T.watch(i);await e.hooks.callHook("rollup:watch",e,l),Se(l,"types",e.logger)}},"watch");var Sn=Object.defineProperty,Nn=m((e,t)=>Sn(e,"name",{value:t,configurable:!0}),"a$3");class Dn{static{m(this,"p")}static{Nn(this,"FileCache")}#r;#e;#n;#t=!0;#o=new Map;#s;constructor(t,o,r){this.#r=t,this.#e=It.findCacheDirSync("@visulima/packem",{cwd:t}),this.#n=o,this.#s=r,this.#e===void 0?r.debug("Could not create cache directory."):r.debug(`Cache path is: ${this.#e}`)}set isEnabled(t){this.#t=t}get cachePath(){return this.#e}has(t,o){return!this.#t||this.#e===void 0?!1:b.isAccessibleSync(this.getFilePath(t,o))}get(t,o){if(!this.#t||this.#e===void 0)return;const r=this.getFilePath(t,o);if(this.#o.has(r))return this.#o.get(r);if(!b.isAccessibleSync(r))return;const s=b.readFileSync(r);try{const n=JSON.parse(s);return this.#o.set(r,n),n}catch{this.#s.warn(`Could not parse cache file: ${r}, deleting the broken cache file.`),this.#o.delete(r),ie.rmSync(r,{force:!0});return}}set(t,o,r){if(!this.#t||this.#e===void 0||o===void 0)return;const s=this.getFilePath(t,r);typeof o=="object"&&(o=JSON.stringify(o)),b.writeFileSync(s,o,{overwrite:!0})}getFilePath(t,o){let r=t.replaceAll(f.toNamespacedPath(this.#r),"");return r=r.replaceAll(":","-"),f.join(this.#e,this.#n,o?.replaceAll(":","-")??"",f.toNamespacedPath(r))}}var _n=Object.defineProperty,z=m((e,t)=>_n(e,"name",{value:t,configurable:!0}),"l$2");const Pn=_.createFilter,Cn=z((e,t)=>{const{sideEffects:o}=t;let r;if(typeof o=="boolean")r=z(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)r=z(()=>!1,"hasSideEffects");else{const s=o.map(n=>n.includes("/")?n:`**/${n}`);r=Pn(s,null,{resolve:e})}else r=z(()=>null,"hasSideEffects");return r},"getPackageSideEffect");var Rn=Object.defineProperty,In=m((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"y");const Fn=In((e,t,o)=>e.reduce((r,s)=>{const n=s[t],i=s[o];return r[n]||(r[n]={}),r[n][i]||(r[n][i]=[]),r[n][i].push(s),r},{}),"groupByKeys");var Mn=Object.defineProperty,pt=m((e,t)=>Mn(e,"name",{value:t,configurable:!0}),"e");const Ne=pt(async(e,t)=>{if(typeof e.name!="string"){let o=f.isAbsolute(e.input)?f.relative(t.options.rootDir,e.input):f.normalize(e.input);o.startsWith("./")&&(o=o.slice(2)),e.name=o.replace(new RegExp(`^${t.options.sourceDir}/`),"").replace(k.ENDING_RE,"")}if(!e.input)throw new Error(`Missing entry input: ${ce(e)}`);Mt.isRelative(e.input)&&(e.input=f.resolve(t.options.rootDir,e.input)),t.options.declaration&&e.declaration===void 0&&(e.declaration=t.options.declaration),t.options.emitCJS!==void 0&&e.cjs===void 0&&(e.cjs=t.options.emitCJS),t.options.emitESM!==void 0&&e.esm===void 0&&(e.esm=t.options.emitESM),e.outDir=f.resolve(t.options.rootDir,e.outDir??t.options.outDir)},"extendEntry"),An=pt(async e=>{e.options.entries=e.options.entries.map(t=>typeof t=="string"?{input:t,isGlob:ve(t)}:{...t,isGlob:ve(t.input)});for(const t of e.options.entries.filter(o=>o.isGlob)){const{isGlob:o,...r}=t,s=Ie.globSync([r.input],{cwd:e.options.rootDir,dot:!1,ignore:["**/node_modules/**"],onlyFiles:!0});if(s.length===0)throw new Ft.NotFoundError("No files found in the glob pattern: "+v.cyan(f.join(e.options.rootDir,r.input)));for(const n of s)e.options.entries.push({...r,input:f.resolve(e.options.rootDir,n)});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 Ne(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 Ne(t,e)},"prepareEntries");var Tn=Object.defineProperty,Jn=m((e,t)=>Tn(e,"name",{value:t,configurable:!0}),"a$2");const Ln=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,qn=new Set(["abstract","await","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"]),De=Jn(e=>{if(!Array.isArray(e)&&e!==null)for(const[t,o]of Object.entries(e)){if(typeof t!="string"||t.trim()==="")throw new Error(`Alias name "${t}" is invalid. Alias names should be non-empty strings.`);if(Ln.test(t))throw new Error(`Alias name "${t}" is invalid. Alias names should start with a letter or underscore and only contain letters, numbers, underscores, and dashes.`);if(qn.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const r=f.resolve(o);if(!b.isAccessibleSync(r))throw new Error(`Target path "${r}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var Bn=Object.defineProperty,Wn=m((e,t)=>Bn(e,"name",{value:t,configurable:!0}),"o");const Un=Wn(e=>{const t=new Set,o=new Set(Object.keys(e.pkg?.dependencies??{})),r=new Set;for(const s of e.usedImports)o.delete(s),t.add(s);if(e.pkg?.dependencies)for(const s of Object.keys(e.pkg?.dependencies))o.delete(s);for(const s of t){const n=qe(s);!re(e.options.externals,s)&&!s.startsWith("chunks/")&&e.pkg?.dependencies?.[n]===void 0&&e.pkg?.peerDependencies?.[n]===void 0&&r.add(s)}o.size>0&&J(e,`Potential unused dependencies found: ${[...o].map(s=>v.cyan(s)).join(", ")}`),r.size>0&&J(e,`Potential implicit dependencies found: ${[...r].map(s=>v.cyan(s)).join(", ")}`)},"validateDependencies");var zn=Object.defineProperty,ut=m((e,t)=>zn(e,"name",{value:t,configurable:!0}),"i");const Vn=ut((e,t)=>Tt.distance(e,t)<=e.length/3||t.includes(e),"isSimilar"),Hn=ut((e,t)=>{const o=e.toLowerCase();return t.filter(r=>Vn(r.toLowerCase(),o))},"findAlternatives");var Gn=Object.defineProperty,_e=m((e,t)=>Gn(e,"name",{value:t,configurable:!0}),"s");const Xn=_e((e,t)=>{const o=new Set([...typeof e.bin=="string"?[e.bin]:Object.values(e.bin??{}),e.main,e.module,t.options.declaration?e.types:"",t.options.declaration?e.typings:"",...pe(e.exports,e.type==="module"?"esm":"cjs",t.options.declaration).map(s=>s.file)].map(s=>s&&f.resolve(t.options.rootDir,s.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),r=[];for(const s of o)s&&!s.includes("*")&&!ie.existsSync(s)&&r.push(s.replace(`${t.options.rootDir}/`,""));if(r.length>0){const s=_e(l=>f.relative(t.options.rootDir,f.resolve(t.options.outDir,l)),"rPath"),n=t.buildEntries.filter(l=>!l.chunk).map(l=>s(l.path));let i="Potential missing or wrong package.json files:";for(const l of r){const a=Hn(l,n);i+=`
61
61
  - `+v.cyan(l)+(a.length>0?v.grey` (did you mean ${a.map(c=>`"${c}"`).join(", ")}?)`:"")}J(t,i)}},"validatePackage");var Kn=Object.defineProperty,O=m((e,t)=>Kn(e,"name",{value:t,configurable:!0}),"g");const dt=O((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
62
62
  `),e.logger.warn(`Build is done with some warnings:
63
63
 
@@ -89,11 +89,11 @@ ${n.chunks.map(a=>{const c=t.buildEntries.find(p=>p.path===a)??{};return v.gray(
89
89
  types: `+v.bold(r(p.path))+" (total size: "+v.cyan(P.formatBytes(p.bytes??0))+")"}}s=!0,l+=`
90
90
 
91
91
  `,e.raw(n.chunk?v.gray(l):l)}return s&&e.raw("Σ Total dist size (byte size):",v.cyan(P.formatBytes(t.buildEntries.reduce((n,i)=>n+(i.bytes??0),0))),`
92
- `),s},"showSizeInformation"),es=O(async(e,t,o,r,s,n,i,l,a)=>{const c=Eo(i.preset??n.preset??"auto",t),p=Qn(e,t,o,r,s,n,i,c,l,a);$.ensureDirSync(f.join(p.rootDir,p.outDir));const d={buildEntries:[],dependencyGraphMap:new Map,environment:r,hooks:yt.createHooks(),logger:e,mode:o,options:p,pkg:l,tsconfig:a,usedImports:new Set,warnings:new Set};return c.hooks&&d.hooks.addHooks(c.hooks),n.hooks&&d.hooks.addHooks(n.hooks),i.hooks&&d.hooks.addHooks(i.hooks),await d.hooks.callHook("build:prepare",d),d.options.emitESM===void 0&&d.logger.info("Emitting of ESM bundles, is disabled."),d.options.emitCJS===void 0&&d.logger.info("Emitting of CJS bundles, is disabled."),d},"createContext"),ts=O(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(r=>r.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(r=>o.startsWith(r))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${f.relative(e.options.rootDir,o)}\``),await $.emptyDir(o))},"cleanDistributionDirectories"),os=O((e,t)=>{const o=Fn(e.options.entries,"environment","runtime"),r=[];for(const[s,n]of Object.entries(o))for(const[i,l]of Object.entries(n)){const a={...e};(s!=="undefined"||i!=="undefined")&&e.logger.info("Preparing build for "+(s==="undefined"?"":v.cyan(s)+" environment"+(i==="undefined"?"":" with "))+(i==="undefined"?"":v.cyan(i)+" runtime")),a.options.rollup.replace?(a.options.rollup.replace.values===void 0&&(a.options.rollup.replace.values={}),s!=="undefined"&&(a.options.rollup.replace.values={...a.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(s)}),i==="edge-light"&&(a.options.rollup.replace.values.EdgeRuntime=JSON.stringify("edge-runtime"))):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let c="";s!=="undefined"&&(c+=s+"/"),i!=="undefined"&&(c+=i+"/");let p=!1;a.options.minify!==void 0&&(p=a.options.minify),s==="development"?p=!1:s==="production"&&(p=!0);const d=[],u=[],g=[],y=[];for(const h of l)h.cjs&&h.esm?d.push(h):h.cjs?g.push(h):h.esm?u.push(h):h.declaration&&y.push(h);if(d.length>0){const h={...a,options:{...a.options,emitCJS:!0,emitESM:!0,entries:d,minify:p}};r.push(te(h,t,c));const b=h.options.entries.filter(w=>w.declaration);e.options.declaration&&b.length>0&&r.push(U({...h,options:{...h.options,entries:b}},t,c))}if(u.length>0){const h={...a,options:{...a.options,emitCJS:!1,emitESM:!0,entries:u,minify:p}};r.push(te(h,t,c));const b=h.options.entries.filter(w=>w.declaration);e.options.declaration&&b.length>0&&r.push(U({...h,options:{...h.options,entries:b}},t,c))}if(g.length>0){const h={...a,options:{...a.options,emitCJS:!0,emitESM:!1,entries:g,minify:p}};r.push(te(h,t,c));const b=h.options.entries.filter(w=>w.declaration);e.options.declaration&&b.length>0&&r.push(U({...h,options:{...h.options,entries:b}},t,c))}if(a.options.declaration&&y.length>0){const h={...a,options:{...a.options,emitCJS:!1,emitESM:!1,entries:y,minify:p}};r.push(U(h,t,c))}}return r},"prepareRollupConfig"),rs=O(async(e,t,o)=>{await e.hooks.callHook("build:before",e),e.options.minify&&e.logger.info("Minification is enabled, the output will be minified");const r=t.dependencies?.typescript!==void 0||t.devDependencies?.typescript!==void 0;if(e.options.declaration&&e.tsconfig===void 0&&r)throw new Error("Cannot build declaration files without a tsconfig.json");r?e.options.declaration===!1&&e.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(e.options.declaration=!1,e.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),e.options.declaration&&e.logger.info("Using typescript version: "+v.cyan(t.devDependencies?.typescript??t.dependencies?.typescript??"unknown")),e.options.declaration&&(t.dependencies?.typescript||t.devDependencies?.typescript)&&!e.tsconfig?.config.compilerOptions?.isolatedModules&&e.logger.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
92
+ `),s},"showSizeInformation"),es=O(async(e,t,o,r,s,n,i,l,a)=>{const c=Eo(i.preset??n.preset??"auto",t),p=Qn(e,t,o,r,s,n,i,c,l,a);b.ensureDirSync(f.join(p.rootDir,p.outDir));const d={buildEntries:[],dependencyGraphMap:new Map,environment:r,hooks:yt.createHooks(),logger:e,mode:o,options:p,pkg:l,tsconfig:a,usedImports:new Set,warnings:new Set};return c.hooks&&d.hooks.addHooks(c.hooks),n.hooks&&d.hooks.addHooks(n.hooks),i.hooks&&d.hooks.addHooks(i.hooks),await d.hooks.callHook("build:prepare",d),d.options.emitESM===void 0&&d.logger.info("Emitting of ESM bundles, is disabled."),d.options.emitCJS===void 0&&d.logger.info("Emitting of CJS bundles, is disabled."),d},"createContext"),ts=O(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(r=>r.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(r=>o.startsWith(r))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${f.relative(e.options.rootDir,o)}\``),await b.emptyDir(o))},"cleanDistributionDirectories"),os=O((e,t)=>{const o=Fn(e.options.entries,"environment","runtime"),r=[];for(const[s,n]of Object.entries(o))for(const[i,l]of Object.entries(n)){const a={...e};(s!=="undefined"||i!=="undefined")&&e.logger.info("Preparing build for "+(s==="undefined"?"":v.cyan(s)+" environment"+(i==="undefined"?"":" with "))+(i==="undefined"?"":v.cyan(i)+" runtime")),a.options.rollup.replace?(a.options.rollup.replace.values===void 0&&(a.options.rollup.replace.values={}),s!=="undefined"&&(a.options.rollup.replace.values={...a.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(s)}),a.options.rollup.replace.values={...a.options.rollup.replace.values,[["process","env","EdgeRuntime"].join(".")]:JSON.stringify(i==="edge-light")}):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let c="";s!=="undefined"&&(c+=s+"/"),i!=="undefined"&&(c+=i+"/");let p=!1;a.options.minify!==void 0&&(p=a.options.minify),s==="development"?p=!1:s==="production"&&(p=!0);const d=[],u=[],g=[],y=[];for(const h of l)h.cjs&&h.esm?d.push(h):h.cjs?g.push(h):h.esm?u.push(h):h.declaration&&y.push(h);if(d.length>0){const h={...a,options:{...a.options,emitCJS:!0,emitESM:!0,entries:d,minify:p}};r.push(te(h,t,c));const w=h.options.entries.filter($=>$.declaration);e.options.declaration&&w.length>0&&r.push(U({...h,options:{...h.options,entries:w}},t,c))}if(u.length>0){const h={...a,options:{...a.options,emitCJS:!1,emitESM:!0,entries:u,minify:p}};r.push(te(h,t,c));const w=h.options.entries.filter($=>$.declaration);e.options.declaration&&w.length>0&&r.push(U({...h,options:{...h.options,entries:w}},t,c))}if(g.length>0){const h={...a,options:{...a.options,emitCJS:!0,emitESM:!1,entries:g,minify:p}};r.push(te(h,t,c));const w=h.options.entries.filter($=>$.declaration);e.options.declaration&&w.length>0&&r.push(U({...h,options:{...h.options,entries:w}},t,c))}if(a.options.declaration&&y.length>0){const h={...a,options:{...a.options,emitCJS:!1,emitESM:!1,entries:y,minify:p}};r.push(U(h,t,c))}}return r},"prepareRollupConfig"),rs=O(async(e,t,o)=>{await e.hooks.callHook("build:before",e),e.options.minify&&e.logger.info("Minification is enabled, the output will be minified");const r=t.dependencies?.typescript!==void 0||t.devDependencies?.typescript!==void 0;if(e.options.declaration&&e.tsconfig===void 0&&r)throw new Error("Cannot build declaration files without a tsconfig.json");r?e.options.declaration===!1&&e.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(e.options.declaration=!1,e.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),e.options.declaration&&e.logger.info("Using typescript version: "+v.cyan(t.devDependencies?.typescript??t.dependencies?.typescript??"unknown")),e.options.declaration&&(t.dependencies?.typescript||t.devDependencies?.typescript)&&!e.tsconfig?.config.compilerOptions?.isolatedModules&&e.logger.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
93
93
  Because none of the third-party transpiler, packem uses under the hood is type-aware, some techniques or features often used in TypeScript are not properly checked and can cause mis-compilation or even runtime errors.
94
- To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),await Promise.all(os(e,o)),e.logger.success(v.green(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const n of $.walk(f.join(e.options.rootDir,e.options.outDir))){let i=e.buildEntries.find(l=>f.join(e.options.rootDir,e.options.outDir,l.path)===n.path);if(i||(i={chunk:!0,path:n.path},e.buildEntries.push(i)),!i.bytes){const l=await ne.stat(f.resolve(e.options.rootDir,e.options.outDir,n.path));i.bytes=l.size}}const s=Zn(e.logger,e,t);Un(e),Xn(t,e),await e.hooks.callHook("build:done",e),dt(e,s)},"build"),ns=O(async(e,t,o,r,s={})=>{const{configPath:n,debug:i,tsconfigPath:l,...a}=s;r.wrapAll(),e=f.resolve(se.cwd(),e),r.debug("Root directory:",e);const c=f.join(e,"package.json");if(!$.isAccessibleSync(c))throw new Error("package.json not found at "+c);const p=gt.parsePackageJson(c);r.debug("Using package.json found at",c);let d;if(l){const u=f.join(e,l);if(!await $.isAccessible(u))throw new Error("tsconfig.json not found at "+u);d={config:ge.readTsConfig(u),path:u},r.info("Using tsconfig settings at",u)}else if(p.dependencies?.typescript||p.devDependencies?.typescript)try{d=await ge.findTsConfig(e),r.debug("Using tsconfig settings found at",d.path)}catch{r.info("No tsconfig.json or jsconfig.json found.")}try{let u=n??"";if(!u){const E=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const D of E)if($.isAccessibleSync(f.join(e,D))){u="./"+D;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(u))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");let g=Te(u,e);typeof g=="function"&&(g=g(o,t)),r.debug("Using packem config found at",f.join(e,u));const y=Date.now(),h=O(()=>P.duration(Math.floor(Date.now()-y)),"getDuration"),b=I(JSON.stringify({version:p.version,...p.dependencies,...p.devDependencies,...p.peerDependencies,...p.peerDependenciesMeta,browser:p.browser,eNode:p.engines?.node,exports:p.exports,main:p.main,module:p.module,type:p.type,types:p.types})),w=new Dn(e,b,r);w.cachePath&&!$.isAccessibleSync(f.join(w.cachePath,b))&&$.isAccessibleSync(w.cachePath)&&(r.info("Clearing file cache because the cache key has changed."),await $.emptyDir(w.cachePath));const j=await es(r,e,t,o,i??!1,a,g,p,d);if(w.isEnabled=j.options.fileCache,await An(j),j.logger.info(v.cyan((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+j.options.name)),j.logger.debug(`${v.bold("Root dir:")} ${j.options.rootDir}
94
+ To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),await Promise.all(os(e,o)),e.logger.success(v.green(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const n of b.walk(f.join(e.options.rootDir,e.options.outDir))){let i=e.buildEntries.find(l=>f.join(e.options.rootDir,e.options.outDir,l.path)===n.path);if(i||(i={chunk:!0,path:n.path},e.buildEntries.push(i)),!i.bytes){const l=await ne.stat(f.resolve(e.options.rootDir,e.options.outDir,n.path));i.bytes=l.size}}const s=Zn(e.logger,e,t);Un(e),Xn(t,e),await e.hooks.callHook("build:done",e),dt(e,s)},"build"),ns=O(async(e,t,o,r,s={})=>{const{configPath:n,debug:i,tsconfigPath:l,...a}=s;r.wrapAll(),e=f.resolve(se.cwd(),e),r.debug("Root directory:",e);const c=f.join(e,"package.json");if(!b.isAccessibleSync(c))throw new Error("package.json not found at "+c);const p=gt.parsePackageJson(c);r.debug("Using package.json found at",c);let d;if(l){const u=f.join(e,l);if(!await b.isAccessible(u))throw new Error("tsconfig.json not found at "+u);d={config:ge.readTsConfig(u),path:u},r.info("Using tsconfig settings at",u)}else if(p.dependencies?.typescript||p.devDependencies?.typescript)try{d=await ge.findTsConfig(e),r.debug("Using tsconfig settings found at",d.path)}catch{r.info("No tsconfig.json or jsconfig.json found.")}try{let u=n??"";if(!u){const E=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const D of E)if(b.isAccessibleSync(f.join(e,D))){u="./"+D;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(u))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");let g=Te(u,e);typeof g=="function"&&(g=g(o,t)),r.debug("Using packem config found at",f.join(e,u));const y=Date.now(),h=O(()=>P.duration(Math.floor(Date.now()-y)),"getDuration"),w=I(JSON.stringify({version:p.version,...p.dependencies,...p.devDependencies,...p.peerDependencies,...p.peerDependenciesMeta,browser:p.browser,eNode:p.engines?.node,exports:p.exports,main:p.main,module:p.module,type:p.type,types:p.types})),$=new Dn(e,w,r);$.cachePath&&!b.isAccessibleSync(f.join($.cachePath,w))&&b.isAccessibleSync($.cachePath)&&(r.info("Clearing file cache because the cache key has changed."),await b.emptyDir($.cachePath));const j=await es(r,e,t,o,i??!1,a,g,p,d);if($.isEnabled=j.options.fileCache,await An(j),j.logger.info(v.cyan((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+j.options.name)),j.logger.debug(`${v.bold("Root dir:")} ${j.options.rootDir}
95
95
  ${v.bold("Entries:")}
96
96
  ${j.options.entries.map(E=>` ${ce(E)}`).join(`
97
- `)}`),await ts(j),j.options.stub){await no(j),await j.hooks.callHook("build:done",j);return}if(t==="watch"){if(j.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await On(j,w),dt(j,!1);return}await rs(j,p,w),r.raw(`
97
+ `)}`),await ts(j),j.options.stub){await no(j),await j.hooks.callHook("build:done",j);return}if(t==="watch"){if(j.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await On(j,$),dt(j,!1);return}await rs(j,p,$),r.raw(`
98
98
  ⚡️ Build run in `+h()),r.restoreAll()}catch(u){throw r.raw(`
99
99
  `),lt(u),u}},"createBundler");module.exports=ns;
@@ -11,7 +11,7 @@ var $o=Object.defineProperty,te=m((e,t)=>$o(e,"name",{value:t,configurable:!0}),
11
11
  export default _module;`:"",...c.filter(d=>d!=="default").map(d=>`export const ${d} = _module.${d};`)].join(`
12
12
  `)),await z(`${s}.d.cts`,[`export * from ${JSON.stringify(i)};`,p?`export { default } from ${JSON.stringify(i)};`:""].join(`
13
13
  `)),await z(`${s}.d.mts`,[`export * from ${JSON.stringify(n)};`,p?`export { default } from ${JSON.stringify(n)};`:""].join(`
14
- `)),a&&(await ce(`${s}.cjs`),await ce(`${s}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Ro=Object.defineProperty,Io=m((e,t)=>Ro(e,"name",{value:t,configurable:!0}),"r$8");const et=Io((e,t)=>Ke(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var Fo=Object.defineProperty,Ao=m((e,t)=>Fo(e,"name",{value:t,configurable:!0}),"i$9");const ve=Ao(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var To=Object.defineProperty,tt=m((e,t)=>To(e,"name",{value:t,configurable:!0}),"e$2");const Z=tt(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),ot=tt((e,t,o,r)=>{if(r){const i=Z(r);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[s,...n]=t;return ot(s,n,o,r)},"inferExportType");var Jo=Object.defineProperty,Wo=m((e,t)=>Jo(e,"name",{value:t,configurable:!0}),"i$8");const Bo=new Set(["import","require","node","node-addons","default","types","deno","browser",...Y]),be=Wo((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const s=Z(e);if(s&&s!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:s??t}]}return Object.entries(e).filter(([s])=>!s.endsWith(".json")).flatMap(([s,n])=>o===!1&&s==="types"?[]:typeof n=="string"?{file:n,key:"exports",...Bo.has(s)?{subKey:s}:{},type:ot(s,r,t,n)}:be(n,t,o,[...r,s]))},"extractExportFilenames");var Lo=Object.defineProperty,oe=m((e,t)=>Lo(e,"name",{value:t,configurable:!0}),"c$b");const Uo=oe((e,t)=>e.key==="exports"&&e.subKey===J?J:e.key==="exports"&&e.subKey===Oe?Oe:t,"getEnvironment"),V=oe((e,t,o,r,s,n)=>{const i=Uo(s,n.environment);let l="node";for(const p of Gt)if(s.file.includes("."+p+".")||s.subKey===p){l=p;break}let a=e.find(p=>p.input===t&&p.environment===i&&p.runtime===l);a===void 0&&(a=e[e.push({environment:i,input:t,runtime:l})-1]),o&&(a.outDir=r),s.isExecutable?(a.executable=!0,a.declaration=!1,s.type==="cjs"&&(a.cjs=!0),s.type==="esm"&&(a.esm=!0)):(/\.d\.[mc]?ts$/.test(s.file)&&n.options.declaration!==!1&&(a.declaration=n.options.declaration),s.type==="cjs"&&(a.cjs=!0),s.type==="esm"&&(a.esm=!0));const c=s.file.replace(de(s.file),"").replace(new RegExp(`^./${n.options.outDir.replace(/^\.\//,"")}/`),"");Y.has(s.subKey)&&!t.includes(c)&&(a.fileAlias=c)},"createOrUpdateEntry");let Ne=!1;const _e=oe(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"),zo=oe((e,t,o)=>{const r=[];t.sort((l,a)=>l.split("/").length-a.split("/").length);const s=e.type==="module"?"esm":"cjs";s==="esm"&&(o.options.emitESM=!0),s==="cjs"&&(o.options.emitCJS=!0);const n=be(e.exports,s,o.options.declaration);if(e.bin){const l=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const a of l){const c=Z(a);if(c&&c!==s)throw new Error(`Exported file "${a}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);n.push({file:a,isExecutable:!0,key:"bin",type:c??s})}}e.main&&n.push({file:e.main,key:"main",type:Z(e.main)??s}),e.module&&n.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(_e(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),n.push({file:e.types??e.typings,key:"types"}));const i=[];for(const l of n){o.options.declaration===void 0&&(l.key==="types"||l.subKey==="types")&&(o.options.declaration=l.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&l.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&l.type==="esm"&&(o.options.emitESM=!0);const a=l.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=a.endsWith("/");if(c&&["./","/"].includes(a))continue;const p=a.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),d="(?<=/|$)",u=c?"":"\\.\\w+$";if(l.file.includes("/*")&&l.key==="exports"){Ne||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Ne=!0);const y=[],v=new RegExp(d+p.replace("*","(.*)")+u),$=new RegExp(d+p.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+u);for(const x of t)(v.test(x)||Y.has(l.subKey)&&$.test(x))&&y.push(x);if(y.length===0){r.push(`Could not find entrypoint for \`${l.file}\``);continue}for(const x of y)V(i,x,c,a,l,o);continue}const f=new RegExp(d+p+u);let h=t.find(y=>f.test(y));if(Y.has(l.subKey)&&h===void 0){const y=new RegExp(d+p.replace(/(.*)\.[^.]*$/,"$1")+u);h=t.find(v=>y.test(v))}if(h===void 0){S(b(o.options.rootDir,l.file))||r.push(`Could not find entrypoint for \`${l.file}\``);continue}(h.endsWith(".ts")||h.endsWith(".cts")||h.endsWith(".mts"))&&S(h)&&_e(o);const g=h.replace(X,"");S(g+".cts")&&S(g+".mts")?(V(i,g+".cts",c,a,{...l,type:"cjs"},o),V(i,g+".mts",c,a,{...l,type:"esm"},o)):V(i,h,c,a,l,o)}return{entries:i,warnings:r}},"inferEntries");var Ho=Object.defineProperty,Vo=m((e,t)=>Ho(e,"name",{value:t,configurable:!0}),"o$3");const qo=Vo((e,t)=>{const{publishConfig:o}=e;return o&&(o.bin&&(typeof o.bin=="object"||typeof o.bin=="string")&&(e.bin=o.bin),o.type&&typeof o.type=="string"&&o.type!==""&&(e.type=o.type),o.main&&typeof o.main=="string"&&o.main!==""&&(e.main=o.main),o.module&&typeof o.module=="string"&&o.module!==""&&(e.module=o.module),t===void 0&&o.types&&typeof o.types=="string"&&o.types!==""?e.types=o.types:t===void 0&&o.typings&&typeof o.typings=="string"&&o.typings!==""&&(e.typings=o.typings),o.exports&&typeof o.exports=="object"&&(e.exports=o.exports)),e},"overwriteWithPublishConfig");var Ko=Object.defineProperty,Go=m((e,t)=>Ko(e,"name",{value:t,configurable:!0}),"l$9");const Yo={hooks:{"build:prepare":Go(function(e){if(e.options.entries.length>0)return;const t=w(e.options.rootDir,e.options.sourceDir);if(!Ge(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=At(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(ve(r.publishConfig)),r=qo(r,e.options.declaration));const s=zo(r,o,e);for(const n of s.warnings)B(e,n);if(e.options.entries.push(...s.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",j(e.options.entries.map(n=>n.fileAlias?D(n.fileAlias)+" => "+D(n.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):D(n.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),I([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(n=>`[${n}]`).join(" ")))},"build:prepare")}};var Xo=Object.defineProperty,Qo=m((e,t)=>Xo(e,"name",{value:t,configurable:!0}),"n$9");const Zo=Qo((e,t)=>{if(e==="auto")e=Yo;else{if(e==="none")return{};typeof e=="string"&&(e=et(e,t))}return typeof e=="function"&&(e=e()),e},"resolvePreset");var er=Object.defineProperty,tr=m((e,t)=>er(e,"name",{value:t,configurable:!0}),"a$c");const pe=tr((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var or=Object.defineProperty,rr=m((e,t)=>or(e,"name",{value:t,configurable:!0}),"a$b");const W=rr(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var nr=Object.defineProperty,sr=m((e,t)=>nr(e,"name",{value:t,configurable:!0}),"a$a");const rt=sr((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var ir=Object.defineProperty,nt=m((e,t)=>ir(e,"name",{value:t,configurable:!0}),"s$c");const ar=nt((e,t,o)=>{const r=o??new Map;return(...s)=>{const n=t?typeof t=="function"?t(...s):t:JSON.stringify({args:s}),i=r.get(n);if(i!==void 0)return i;const l=e(...s);return r.set(n,l),l}},"memoize"),lr=nt(e=>{const t=new Map;return o=>ar(e,o,t)},"memoizeByKey");var cr=Object.defineProperty,L=m((e,t)=>cr(e,"name",{value:t,configurable:!0}),"r$5");const pr=L(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;Q(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"),ur=L(function*(e){if(e.declaration)for(const t of pr(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"),dr=L(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),mr=L(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),fr=L(function*(e,t){Q(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*dr(r);break}case"ExportDefaultDeclaration":{yield*mr();break}case"ExportNamedDeclaration":{yield*ur(r);break}}},"parseExports");var gr=Object.defineProperty,U=m((e,t)=>gr(e,"name",{value:t,configurable:!0}),"n$6");const st=U(async function(e,t,o){const r=await e.resolve(t,o.id);if(Q(r,`Rollup can't resolve ${t} from ${o.id}`),r.external)return null;const s=await e.load(r);return Q(s,`Rollup doesn't have a module for id ${r.id}`),s},"getImportedModule"),hr=U(async function*(e,t,o){const r=await st(e,t.source,o);r&&(yield*$e(e,r))},"gatherBarrelReExports"),yr=U(async function*(e,t,o){const r=await st(e,t.source,o);if(!r)return;const s=new Map(t.bindings.map(n=>[n.importedName,n]));for await(const n of $e(e,r)){const i=s.get(n.exportedName);i&&(yield{...n,exportedName:i.exportedName})}},"gatherNamedReExports"),vr=U(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),$e=U(async function*(e,t){for(const o of fr(e,t))o.from==="self"?yield*vr(t,o):o.type==="barrel"?yield*hr(e,o,t):yield*yr(e,o,t)},"gatherExports");var br=Object.defineProperty,$r=m((e,t)=>br(e,"name",{value:t,configurable:!0}),"n$5");const wr=$r(({preserveChunkSignature:e=!1}={})=>({moduleParsed:{async handler(t){if(t.isEntry)for await(const o of $e(this,t))o.id!==t.id&&this.emitFile({id:o.id,name:o.exportedName,preserveSignature:e,type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");var jr=Object.defineProperty,kr=m((e,t)=>jr(e,"name",{value:t,configurable:!0}),"m$7");const it=kr(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk(r,s,n){if(s.type!=="chunk"||!s.isEntry)return null;if(n.format==="cjs"&&n.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(i===null||i.length<3)return null;const l=new C(r);l.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),l.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&l.append(`
14
+ `)),a&&(await ce(`${s}.cjs`),await ce(`${s}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Ro=Object.defineProperty,Io=m((e,t)=>Ro(e,"name",{value:t,configurable:!0}),"r$8");const et=Io((e,t)=>Ke(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var Fo=Object.defineProperty,Ao=m((e,t)=>Fo(e,"name",{value:t,configurable:!0}),"i$9");const ve=Ao(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var To=Object.defineProperty,tt=m((e,t)=>To(e,"name",{value:t,configurable:!0}),"e$2");const Z=tt(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),ot=tt((e,t,o,r)=>{if(r){const i=Z(r);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[s,...n]=t;return ot(s,n,o,r)},"inferExportType");var Jo=Object.defineProperty,Wo=m((e,t)=>Jo(e,"name",{value:t,configurable:!0}),"i$8");const Bo=new Set(["import","require","node","node-addons","default","types","deno","browser",...Y]),be=Wo((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const s=Z(e);if(s&&s!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:s??t}]}return Object.entries(e).filter(([s])=>!s.endsWith(".json")).flatMap(([s,n])=>o===!1&&s==="types"?[]:typeof n=="string"?{file:n,key:"exports",...Bo.has(s)?{subKey:s}:{},type:ot(s,r,t,n)}:be(n,t,o,[...r,s]))},"extractExportFilenames");var Lo=Object.defineProperty,oe=m((e,t)=>Lo(e,"name",{value:t,configurable:!0}),"c$c");const Uo=oe((e,t)=>e.key==="exports"&&e.subKey===J?J:e.key==="exports"&&e.subKey===Oe?Oe:t,"getEnvironment"),V=oe((e,t,o,r,s,n)=>{const i=Uo(s,n.environment);let l="node";for(const p of Gt)if(s.file.includes("."+p+".")||s.subKey===p){l=p;break}let a=e.find(p=>p.input===t&&p.environment===i&&p.runtime===l);a===void 0&&(a=e[e.push({environment:i,input:t,runtime:l})-1]),o&&(a.outDir=r),s.isExecutable?(a.executable=!0,a.declaration=!1,s.type==="cjs"&&(a.cjs=!0),s.type==="esm"&&(a.esm=!0)):(/\.d\.[mc]?ts$/.test(s.file)&&n.options.declaration!==!1&&(a.declaration=n.options.declaration),s.type==="cjs"&&(a.cjs=!0),s.type==="esm"&&(a.esm=!0));const c=s.file.replace(de(s.file),"").replace(new RegExp(`^./${n.options.outDir.replace(/^\.\//,"")}/`),"");Y.has(s.subKey)&&!t.includes(c)&&(a.fileAlias=c)},"createOrUpdateEntry");let Ne=!1;const _e=oe(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"),zo=oe((e,t,o)=>{const r=[];t.sort((l,a)=>l.split("/").length-a.split("/").length);const s=e.type==="module"?"esm":"cjs";s==="esm"&&(o.options.emitESM=!0),s==="cjs"&&(o.options.emitCJS=!0);const n=be(e.exports,s,o.options.declaration);if(e.bin){const l=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const a of l){const c=Z(a);if(c&&c!==s)throw new Error(`Exported file "${a}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);n.push({file:a,isExecutable:!0,key:"bin",type:c??s})}}e.main&&n.push({file:e.main,key:"main",type:Z(e.main)??s}),e.module&&n.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(_e(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),n.push({file:e.types??e.typings,key:"types"}));const i=[];for(const l of n){o.options.declaration===void 0&&(l.key==="types"||l.subKey==="types")&&(o.options.declaration=l.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&l.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&l.type==="esm"&&(o.options.emitESM=!0);const a=l.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=a.endsWith("/");if(c&&["./","/"].includes(a))continue;const p=a.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),d="(?<=/|$)",u=c?"":"\\.\\w+$";if(l.file.includes("/*")&&l.key==="exports"){Ne||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Ne=!0);const v=[],y=new RegExp(d+p.replace("*","(.*)")+u),$=new RegExp(d+p.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+u);for(const x of t)(y.test(x)||Y.has(l.subKey)&&$.test(x))&&v.push(x);if(v.length===0){r.push(`Could not find entrypoint for \`${l.file}\``);continue}for(const x of v)V(i,x,c,a,l,o);continue}const f=new RegExp(d+p+u);let h=t.find(v=>f.test(v));if(Y.has(l.subKey)&&h===void 0){const v=new RegExp(d+p.replace(/(.*)\.[^.]*$/,"$1")+u);h=t.find(y=>v.test(y))}if(h===void 0){S(b(o.options.rootDir,l.file))||r.push(`Could not find entrypoint for \`${l.file}\``);continue}(h.endsWith(".ts")||h.endsWith(".cts")||h.endsWith(".mts"))&&S(h)&&_e(o);const g=h.replace(X,"");S(g+".cts")&&S(g+".mts")?(V(i,g+".cts",c,a,{...l,type:"cjs"},o),V(i,g+".mts",c,a,{...l,type:"esm"},o)):V(i,h,c,a,l,o)}return{entries:i,warnings:r}},"inferEntries");var Ho=Object.defineProperty,Vo=m((e,t)=>Ho(e,"name",{value:t,configurable:!0}),"o$3");const qo=Vo((e,t)=>{const{publishConfig:o}=e;return o&&(o.bin&&(typeof o.bin=="object"||typeof o.bin=="string")&&(e.bin=o.bin),o.type&&typeof o.type=="string"&&o.type!==""&&(e.type=o.type),o.main&&typeof o.main=="string"&&o.main!==""&&(e.main=o.main),o.module&&typeof o.module=="string"&&o.module!==""&&(e.module=o.module),t===void 0&&o.types&&typeof o.types=="string"&&o.types!==""?e.types=o.types:t===void 0&&o.typings&&typeof o.typings=="string"&&o.typings!==""&&(e.typings=o.typings),o.exports&&typeof o.exports=="object"&&(e.exports=o.exports)),e},"overwriteWithPublishConfig");var Ko=Object.defineProperty,Go=m((e,t)=>Ko(e,"name",{value:t,configurable:!0}),"l$9");const Yo={hooks:{"build:prepare":Go(function(e){if(e.options.entries.length>0)return;const t=w(e.options.rootDir,e.options.sourceDir);if(!Ge(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=At(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(ve(r.publishConfig)),r=qo(r,e.options.declaration));const s=zo(r,o,e);for(const n of s.warnings)B(e,n);if(e.options.entries.push(...s.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",j(e.options.entries.map(n=>n.fileAlias?D(n.fileAlias)+" => "+D(n.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):D(n.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),I([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(n=>`[${n}]`).join(" ")))},"build:prepare")}};var Xo=Object.defineProperty,Qo=m((e,t)=>Xo(e,"name",{value:t,configurable:!0}),"n$9");const Zo=Qo((e,t)=>{if(e==="auto")e=Yo;else{if(e==="none")return{};typeof e=="string"&&(e=et(e,t))}return typeof e=="function"&&(e=e()),e},"resolvePreset");var er=Object.defineProperty,tr=m((e,t)=>er(e,"name",{value:t,configurable:!0}),"a$c");const pe=tr((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var or=Object.defineProperty,rr=m((e,t)=>or(e,"name",{value:t,configurable:!0}),"a$b");const W=rr(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var nr=Object.defineProperty,sr=m((e,t)=>nr(e,"name",{value:t,configurable:!0}),"a$a");const rt=sr((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var ir=Object.defineProperty,nt=m((e,t)=>ir(e,"name",{value:t,configurable:!0}),"s$c");const ar=nt((e,t,o)=>{const r=o??new Map;return(...s)=>{const n=t?typeof t=="function"?t(...s):t:JSON.stringify({args:s}),i=r.get(n);if(i!==void 0)return i;const l=e(...s);return r.set(n,l),l}},"memoize"),lr=nt(e=>{const t=new Map;return o=>ar(e,o,t)},"memoizeByKey");var cr=Object.defineProperty,L=m((e,t)=>cr(e,"name",{value:t,configurable:!0}),"r$5");const pr=L(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;Q(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"),ur=L(function*(e){if(e.declaration)for(const t of pr(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"),dr=L(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),mr=L(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),fr=L(function*(e,t){Q(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*dr(r);break}case"ExportDefaultDeclaration":{yield*mr();break}case"ExportNamedDeclaration":{yield*ur(r);break}}},"parseExports");var gr=Object.defineProperty,U=m((e,t)=>gr(e,"name",{value:t,configurable:!0}),"n$6");const st=U(async function(e,t,o){const r=await e.resolve(t,o.id);if(Q(r,`Rollup can't resolve ${t} from ${o.id}`),r.external)return null;const s=await e.load(r);return Q(s,`Rollup doesn't have a module for id ${r.id}`),s},"getImportedModule"),hr=U(async function*(e,t,o){const r=await st(e,t.source,o);r&&(yield*$e(e,r))},"gatherBarrelReExports"),yr=U(async function*(e,t,o){const r=await st(e,t.source,o);if(!r)return;const s=new Map(t.bindings.map(n=>[n.importedName,n]));for await(const n of $e(e,r)){const i=s.get(n.exportedName);i&&(yield{...n,exportedName:i.exportedName})}},"gatherNamedReExports"),vr=U(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),$e=U(async function*(e,t){for(const o of fr(e,t))o.from==="self"?yield*vr(t,o):o.type==="barrel"?yield*hr(e,o,t):yield*yr(e,o,t)},"gatherExports");var br=Object.defineProperty,$r=m((e,t)=>br(e,"name",{value:t,configurable:!0}),"n$5");const wr=$r(({preserveChunkSignature:e=!1}={})=>({moduleParsed:{async handler(t){if(t.isEntry)for await(const o of $e(this,t))o.id!==t.id&&this.emitFile({id:o.id,name:o.exportedName,preserveSignature:e,type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");var jr=Object.defineProperty,kr=m((e,t)=>jr(e,"name",{value:t,configurable:!0}),"m$6");const it=kr(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk(r,s,n){if(s.type!=="chunk"||!s.isEntry)return null;if(n.format==="cjs"&&n.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(i===null||i.length<3)return null;const l=new C(r);l.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),l.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&l.append(`
15
15
  module.exports.default = `+i[2]+";");let a=l.toString();return a=a.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+s.fileName+".",prefix:"plugin:cjs-interop"}),{code:a,map:l.generateMap({hires:!0})}}if(n.format==="es"&&/\.d\.(?:ts|cts)$/.test(s.fileName)){if(o!=="commonjs"&&s.fileName.endsWith(".d.ts"))return null;const i=/export\s\{\s(.*)\s\}/i.exec(r);if(i===null||i.length<2)return null;const l=i[1].split(", "),a=[];let c="";for(const d of l)if(!d.includes("type"))if(d.includes("as")){const[u,f]=d.split(" as ");if(f==="default"&&(c=u,!e))continue;a.push(f+": typeof "+u+";")}else a.push(d+": typeof "+d+";");const p=new C(r);return p.replace(" "+c+" as default,",""),p.append(`
16
16
 
17
17
  declare const defaultExport: {
@@ -29,12 +29,12 @@ export default defaultExport;`),t.debug({message:"Applied CommonJS interop to en
29
29
  `),e&&(r+=`const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
30
30
  `),t&&(r+=`const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
31
31
  `),o&&(r+=`const require = __cjs_mod__.createRequire(import.meta.url);
32
- `),r},"generateCJSShimNode20_11"),Cr=re((e,t)=>{const o=A(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(r,s,n){if(n.format==="es"&&o(s.fileName)){let i=_r;if(e.engines?.node){const l=Ze(e.engines.node);l&&l.major>=20&&l.minor>=11&&(i=Pr)}return Nr(r,i)}return null}}},"esmShimCjsSyntaxPlugin");var Mr=Object.defineProperty,Rr=m((e,t)=>Mr(e,"name",{value:t,configurable:!0}),"n$4");const Ir=Rr(()=>({name:"packem:cjs",renderChunk(e,t,o){return o.format==="es"||o.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(o.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var Fr=Object.defineProperty,Ar=m((e,t)=>Fr(e,"name",{value:t,configurable:!0}),"s$a");const Tr=Ar((...e)=>{if(e.length===0)return"";if(e.length===1)return me(e[0]);e=e.map(s=>le(s));const[t,...o]=e;let r=t.split("/");for(const s of o){const n=s.split("/",r.length);let i=0;for(const l of n)if(l===r[i])i+=1;else{r=r.slice(0,i);break}r=r.slice(0,i)}return r.length<=1&&r[0]===""?`/${r[0]}`:r.join("/")},"lowestCommonAncestor");var Jr=Object.defineProperty,ne=m((e,t)=>Jr(e,"name",{value:t,configurable:!0}),"m$5");const Wr=ne((e,t,o,r={})=>{const s=A(r.include,r.exclude),n={},i=ne((c,p)=>{n[c.replace(/\..?[jt]s$/,"")]=p},"addOutput");async function l(c,p){if(!s(p))return;const{errors:d,sourceText:u}=await e(p,c);if(d.length>0){if(r.ignoreErrors){this.warn(d[0]);return}return this.error(d[0])}i(p,u);let f;try{f=JSON.parse((await po(c,{sourceFilename:p})).program)}catch{return}const h=f.body.filter(g=>g.type!=="ImportDeclaration"?!1:g.importKind==="type"?!0:(g.specifiers||[]).every(y=>y.type==="ImportSpecifier"&&y.importKind==="type"));for await(const g of h)this.resolve(g.source.value,p).then(async y=>{if(!y)return;const v=y.id;if(s(v)&&!n[v.replace(X,"")])try{const $=await ee(v);await l.call(this,$,v)}catch{}}).catch(y=>{console.log(y)})}m(l,"g"),ne(l,"transform");const a=o==="module"?"es":"cjs";return{name:"packem:isolated-declarations",renderStart(c,{input:p}){const d=Tr(...Array.isArray(p)?p:Object.values(p));typeof c.entryFileNames=="function"&&(c.entryFileNames=c.entryFileNames({name:c.name}));const u=c.entryFileNames.replace(/\.(.)?[jt]s$/,(f,h)=>`.d.${h||""}ts`);for(const[f,h]of Object.entries(n)){(t===!0||t==="compatible")&&c.format===a&&this.emitFile({fileName:u.replace("[name]",N(d,f)).replace(a==="cjs"?".cts":".mts",".ts"),source:h,type:"asset"});const g=h.includes("from '")?"'":'"';this.emitFile({fileName:u.replace("[name]",N(d,f)),source:h.replaceAll(/from\s+['"]([^'"]+)['"]/g,(y,v)=>`from ${g}${v.replace(X,"")}${c.format==="cjs"?".cts":".mts"}${g}`),type:"asset"})}},transform:l}},"isolatedDeclarationsPlugin");var Br=Object.defineProperty,Lr=m((e,t)=>Br(e,"name",{value:t,configurable:!0}),"n$3");const Pe="export default ",at=Lr(e=>{const t=uo(e);return{...t,name:"packem:json",transform(o,r){const s=t.transform?.call(this,o,r);return s&&typeof s!="string"&&"code"in s&&s.code?.startsWith(Pe)&&(s.code=s.code.replace(Pe,"module.exports = ")),s}}},"JSONPlugin");class Ur{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,s){t&&o&&(r!=null?t[o][r]=s:t[o]=s)}remove(t,o,r){t&&o&&(r!=null?t[o].splice(r,1):delete t[o])}}class zr extends Ur{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,s){if(t){if(this.enter){const i=this.should_skip,l=this.should_remove,a=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,r,s),this.replacement&&(t=this.replacement,this.replace(o,r,s,t)),this.should_remove&&this.remove(o,r,s);const c=this.should_skip,p=this.should_remove;if(this.should_skip=i,this.should_remove=l,this.replacement=a,c)return t;if(p)return null}let n;for(n in t){const i=t[n];if(i&&typeof i=="object")if(Array.isArray(i)){const l=i;for(let a=0;a<l.length;a+=1){const c=l[a];Ce(c)&&(this.visit(c,t,n,a)||a--)}}else Ce(i)&&this.visit(i,t,n,null)}if(this.leave){const i=this.replacement,l=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,r,s),this.replacement&&(t=this.replacement,this.replace(o,r,s,t)),this.should_remove&&this.remove(o,r,s);const a=this.should_remove;if(this.replacement=i,this.should_remove=l,a)return null}}return t}}function Ce(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(Ce,"isNode");function lt(e,{enter:t,leave:o}){return new zr(t,o).visit(e,null)}m(lt,"walk");var Hr=Object.defineProperty,Vr=m((e,t)=>Hr(e,"name",{value:t,configurable:!0}),"u$7");const qr=Vr(({attributes:e,logger:t})=>{const o=A([/\.[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,s){if(!o(s))return null;let n=null;try{n=this.parse(r,{allowReturnOutsideFunction:!0})}catch(a){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${s}" and remove the jsx attribute.`}),t.warn(a),null}let i=!1;const l=new C(r);return lt(n,{enter(a){if(a.type==="CallExpression"&&a.callee.type==="Identifier"&&a.callee.name==="jsx"){const c=a.arguments.filter(p=>p.type==="ObjectExpression"&&Array.isArray(p.properties));for(const p of c)for(const d of p.properties)d.type==="Property"&&d.key.type==="Literal"&&d.value.type==="Literal"&&e.includes(d.key.value)&&(l.overwrite(d.start-2,d.end,""),i=!0)}}}),i?{code:l.toString(),map:l.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Kr=Object.defineProperty,we=m((e,t)=>Kr(e,"name",{value:t,configurable:!0}),"g$4");const Gr=we(e=>{const t=[],o=[];return e.forEach(r=>{r.startsWith("(")?t.push(r):o.push(r)}),[...o.sort(),...t.sort()]},"sortLicenses"),Yr=we((e,t,o)=>{const r=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(r.test(e))return e.replace(r,`$1
32
+ `),r},"generateCJSShimNode20_11"),Cr=re((e,t)=>{const o=A(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(r,s,n){if(n.format==="es"&&o(s.fileName)){let i=_r;if(e.engines?.node){const l=Ze(e.engines.node);l&&l.major>=20&&l.minor>=11&&(i=Pr)}return Nr(r,i)}return null}}},"esmShimCjsSyntaxPlugin");var Mr=Object.defineProperty,Rr=m((e,t)=>Mr(e,"name",{value:t,configurable:!0}),"n$4");const Ir=Rr(()=>({name:"packem:cjs",renderChunk(e,t,o){return o.format==="es"||o.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(o.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var Fr=Object.defineProperty,Ar=m((e,t)=>Fr(e,"name",{value:t,configurable:!0}),"s$a");const Tr=Ar((...e)=>{if(e.length===0)return"";if(e.length===1)return me(e[0]);e=e.map(s=>le(s));const[t,...o]=e;let r=t.split("/");for(const s of o){const n=s.split("/",r.length);let i=0;for(const l of n)if(l===r[i])i+=1;else{r=r.slice(0,i);break}r=r.slice(0,i)}return r.length<=1&&r[0]===""?`/${r[0]}`:r.join("/")},"lowestCommonAncestor");var Jr=Object.defineProperty,ne=m((e,t)=>Jr(e,"name",{value:t,configurable:!0}),"c$8");const Wr=ne((e,t,o,r={})=>{const s=A(r.include,r.exclude),n={},i=ne((c,p)=>{n[c.replace(/\..?[jt]s$/,"")]=p},"addOutput");async function l(c,p){if(!s(p))return;const{errors:d,sourceText:u}=await e(p,c);if(d.length>0){if(r.ignoreErrors){this.warn(d[0]);return}return this.error(d[0])}i(p,u);let f;try{f=JSON.parse((await po(c,{sourceFilename:p})).program)}catch{return}const h=f.body.filter(g=>g.type!=="ImportDeclaration"?!1:g.importKind==="type"?!0:(g.specifiers||[]).every(v=>v.type==="ImportSpecifier"&&v.importKind==="type"));for await(const g of h){const v=await this.resolve(g.source.value,p);if(!v)return;const y=v.id;if(s(y)&&!n[y.replace(X,"")])try{const $=await ee(y);await l.call(this,$,y)}catch{}}}m(l,"g"),ne(l,"transform");const a=o==="module"?"es":"cjs";return{name:"packem:isolated-declarations",renderStart(c,{input:p}){const d=Tr(...Array.isArray(p)?p:Object.values(p));typeof c.entryFileNames=="function"&&(c.entryFileNames=c.entryFileNames({name:c.name}));const u=c.entryFileNames.replace(/\.(.)?[jt]s$/,(f,h)=>`.d.${h||""}ts`);for(const[f,h]of Object.entries(n)){(t===!0||t==="compatible")&&c.format===a&&this.emitFile({fileName:u.replace("[name]",N(d,f)).replace(a==="cjs"?".cts":".mts",".ts"),source:h,type:"asset"});const g=h.includes("from '")?"'":'"';this.emitFile({fileName:u.replace("[name]",N(d,f)),source:h.replaceAll(/from\s+['"]([^'"]+)['"]/g,(v,y)=>`from ${g}${y.replace(X,"")}${c.format==="cjs"?".cts":".mts"}${g}`),type:"asset"})}},transform:l}},"isolatedDeclarationsPlugin");var Br=Object.defineProperty,Lr=m((e,t)=>Br(e,"name",{value:t,configurable:!0}),"n$3");const Pe="export default ",at=Lr(e=>{const t=uo(e);return{...t,name:"packem:json",transform(o,r){const s=t.transform?.call(this,o,r);return s&&typeof s!="string"&&"code"in s&&s.code?.startsWith(Pe)&&(s.code=s.code.replace(Pe,"module.exports = ")),s}}},"JSONPlugin");class Ur{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,s){t&&o&&(r!=null?t[o][r]=s:t[o]=s)}remove(t,o,r){t&&o&&(r!=null?t[o].splice(r,1):delete t[o])}}class zr extends Ur{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,s){if(t){if(this.enter){const i=this.should_skip,l=this.should_remove,a=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,r,s),this.replacement&&(t=this.replacement,this.replace(o,r,s,t)),this.should_remove&&this.remove(o,r,s);const c=this.should_skip,p=this.should_remove;if(this.should_skip=i,this.should_remove=l,this.replacement=a,c)return t;if(p)return null}let n;for(n in t){const i=t[n];if(i&&typeof i=="object")if(Array.isArray(i)){const l=i;for(let a=0;a<l.length;a+=1){const c=l[a];Ce(c)&&(this.visit(c,t,n,a)||a--)}}else Ce(i)&&this.visit(i,t,n,null)}if(this.leave){const i=this.replacement,l=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,r,s),this.replacement&&(t=this.replacement,this.replace(o,r,s,t)),this.should_remove&&this.remove(o,r,s);const a=this.should_remove;if(this.replacement=i,this.should_remove=l,a)return null}}return t}}function Ce(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(Ce,"isNode");function lt(e,{enter:t,leave:o}){return new zr(t,o).visit(e,null)}m(lt,"walk");var Hr=Object.defineProperty,Vr=m((e,t)=>Hr(e,"name",{value:t,configurable:!0}),"u$7");const qr=Vr(({attributes:e,logger:t})=>{const o=A([/\.[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,s){if(!o(s))return null;let n=null;try{n=this.parse(r,{allowReturnOutsideFunction:!0})}catch(a){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${s}" and remove the jsx attribute.`}),t.warn(a),null}let i=!1;const l=new C(r);return lt(n,{enter(a){if(a.type==="CallExpression"&&a.callee.type==="Identifier"&&a.callee.name==="jsx"){const c=a.arguments.filter(p=>p.type==="ObjectExpression"&&Array.isArray(p.properties));for(const p of c)for(const d of p.properties)d.type==="Property"&&d.key.type==="Literal"&&d.value.type==="Literal"&&e.includes(d.key.value)&&(l.overwrite(d.start-2,d.end,""),i=!0)}}}),i?{code:l.toString(),map:l.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Kr=Object.defineProperty,we=m((e,t)=>Kr(e,"name",{value:t,configurable:!0}),"g$4");const Gr=we(e=>{const t=[],o=[];return e.forEach(r=>{r.startsWith("(")?t.push(r):o.push(r)}),[...o.sort(),...t.sort()]},"sortLicenses"),Yr=we((e,t,o)=>{const r=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(r.test(e))return e.replace(r,`$1
33
33
  ${o}
34
- $2`)},"replaceContentWithin"),ct=we(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:r,marker:s,mode:n,packageName:i})=>mo({thirdParty(l){const a=new Set,c=l.sort(({name:d},{name:u})=>(d||0)>(u||0)?1:(u||0)>(d||0)?-1:0).map(({author:d,contributors:u,license:f,licenseText:h,maintainers:g,name:y,repository:v})=>{let $="## "+y+`
34
+ $2`)},"replaceContentWithin"),ct=we(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:r,marker:s,mode:n,packageName:i})=>mo({thirdParty(l){const a=new Set,c=l.sort(({name:d},{name:u})=>(d||0)>(u||0)?1:(u||0)>(d||0)?-1:0).map(({author:d,contributors:u,license:f,licenseText:h,maintainers:g,name:v,repository:y})=>{let $="## "+v+`
35
35
  `;f&&($+=`License: ${f}
36
36
  `);const x=new Set;for(const _ of[d,...g,...u]){const ke=typeof _=="string"?_:_?.name;ke&&x.add(ke)}return x.size>0&&($+=`By: ${[...x].join(", ")}
37
- `),v&&($+=`Repository: ${typeof v=="string"?v:v.url}
37
+ `),y&&($+=`Repository: ${typeof y=="string"?y:y.url}
38
38
  `),h&&($+=`
39
39
  `+h.trim().replaceAll(/\r\n|\r/g,`
40
40
  `).replaceAll(`<!-- ${s} -->`,"").replaceAll(e?`<!-- ${e} -->`:"","").trim().split(`
@@ -95,11 +95,11 @@ ${n.chunks.map(a=>{const c=t.buildEntries.find(p=>p.path===a)??{};return I("
95
95
  types: `+D(r(p.path))+" (total size: "+j(M(p.bytes??0))+")"}}s=!0,l+=`
96
96
 
97
97
  `,e.raw(n.chunk?I(l):l)}return s&&e.raw("Σ Total dist size (byte size):",j(M(t.buildEntries.reduce((n,i)=>n+(i.bytes??0),0))),`
98
- `),s},"showSizeInformation"),Ds=E(async(e,t,o,r,s,n,i,l,a)=>{const c=Zo(i.preset??n.preset??"auto",t),p=Os(e,t,o,r,s,n,i,c,l,a);Jt(w(p.rootDir,p.outDir));const d={buildEntries:[],dependencyGraphMap:new Map,environment:r,hooks:qt(),logger:e,mode:o,options:p,pkg:l,tsconfig:a,usedImports:new Set,warnings:new Set};return c.hooks&&d.hooks.addHooks(c.hooks),n.hooks&&d.hooks.addHooks(n.hooks),i.hooks&&d.hooks.addHooks(i.hooks),await d.hooks.callHook("build:prepare",d),d.options.emitESM===void 0&&d.logger.info("Emitting of ESM bundles, is disabled."),d.options.emitCJS===void 0&&d.logger.info("Emitting of CJS bundles, is disabled."),d},"createContext"),Ns=E(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(r=>r.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(r=>o.startsWith(r))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${N(e.options.rootDir,o)}\``),await ze(o))},"cleanDistributionDirectories"),_s=E((e,t)=>{const o=cs(e.options.entries,"environment","runtime"),r=[];for(const[s,n]of Object.entries(o))for(const[i,l]of Object.entries(n)){const a={...e};(s!=="undefined"||i!=="undefined")&&e.logger.info("Preparing build for "+(s==="undefined"?"":j(s)+" environment"+(i==="undefined"?"":" with "))+(i==="undefined"?"":j(i)+" runtime")),a.options.rollup.replace?(a.options.rollup.replace.values===void 0&&(a.options.rollup.replace.values={}),s!=="undefined"&&(a.options.rollup.replace.values={...a.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(s)}),i==="edge-light"&&(a.options.rollup.replace.values.EdgeRuntime=JSON.stringify("edge-runtime"))):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let c="";s!=="undefined"&&(c+=s+"/"),i!=="undefined"&&(c+=i+"/");let p=!1;a.options.minify!==void 0&&(p=a.options.minify),s==="development"?p=!1:s==="production"&&(p=!0);const d=[],u=[],f=[],h=[];for(const g of l)g.cjs&&g.esm?d.push(g):g.cjs?f.push(g):g.esm?u.push(g):g.declaration&&h.push(g);if(d.length>0){const g={...a,options:{...a.options,emitCJS:!0,emitESM:!0,entries:d,minify:p}};r.push(ae(g,t,c));const y=g.options.entries.filter(v=>v.declaration);e.options.declaration&&y.length>0&&r.push(K({...g,options:{...g.options,entries:y}},t,c))}if(u.length>0){const g={...a,options:{...a.options,emitCJS:!1,emitESM:!0,entries:u,minify:p}};r.push(ae(g,t,c));const y=g.options.entries.filter(v=>v.declaration);e.options.declaration&&y.length>0&&r.push(K({...g,options:{...g.options,entries:y}},t,c))}if(f.length>0){const g={...a,options:{...a.options,emitCJS:!0,emitESM:!1,entries:f,minify:p}};r.push(ae(g,t,c));const y=g.options.entries.filter(v=>v.declaration);e.options.declaration&&y.length>0&&r.push(K({...g,options:{...g.options,entries:y}},t,c))}if(a.options.declaration&&h.length>0){const g={...a,options:{...a.options,emitCJS:!1,emitESM:!1,entries:h,minify:p}};r.push(K(g,t,c))}}return r},"prepareRollupConfig"),Ps=E(async(e,t,o)=>{await e.hooks.callHook("build:before",e),e.options.minify&&e.logger.info("Minification is enabled, the output will be minified");const r=t.dependencies?.typescript!==void 0||t.devDependencies?.typescript!==void 0;if(e.options.declaration&&e.tsconfig===void 0&&r)throw new Error("Cannot build declaration files without a tsconfig.json");r?e.options.declaration===!1&&e.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(e.options.declaration=!1,e.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),e.options.declaration&&e.logger.info("Using typescript version: "+j(t.devDependencies?.typescript??t.dependencies?.typescript??"unknown")),e.options.declaration&&(t.dependencies?.typescript||t.devDependencies?.typescript)&&!e.tsconfig?.config.compilerOptions?.isolatedModules&&e.logger.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
98
+ `),s},"showSizeInformation"),Ds=E(async(e,t,o,r,s,n,i,l,a)=>{const c=Zo(i.preset??n.preset??"auto",t),p=Os(e,t,o,r,s,n,i,c,l,a);Jt(w(p.rootDir,p.outDir));const d={buildEntries:[],dependencyGraphMap:new Map,environment:r,hooks:qt(),logger:e,mode:o,options:p,pkg:l,tsconfig:a,usedImports:new Set,warnings:new Set};return c.hooks&&d.hooks.addHooks(c.hooks),n.hooks&&d.hooks.addHooks(n.hooks),i.hooks&&d.hooks.addHooks(i.hooks),await d.hooks.callHook("build:prepare",d),d.options.emitESM===void 0&&d.logger.info("Emitting of ESM bundles, is disabled."),d.options.emitCJS===void 0&&d.logger.info("Emitting of CJS bundles, is disabled."),d},"createContext"),Ns=E(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(r=>r.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(r=>o.startsWith(r))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${N(e.options.rootDir,o)}\``),await ze(o))},"cleanDistributionDirectories"),_s=E((e,t)=>{const o=cs(e.options.entries,"environment","runtime"),r=[];for(const[s,n]of Object.entries(o))for(const[i,l]of Object.entries(n)){const a={...e};(s!=="undefined"||i!=="undefined")&&e.logger.info("Preparing build for "+(s==="undefined"?"":j(s)+" environment"+(i==="undefined"?"":" with "))+(i==="undefined"?"":j(i)+" runtime")),a.options.rollup.replace?(a.options.rollup.replace.values===void 0&&(a.options.rollup.replace.values={}),s!=="undefined"&&(a.options.rollup.replace.values={...a.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(s)}),a.options.rollup.replace.values={...a.options.rollup.replace.values,[["process","env","EdgeRuntime"].join(".")]:JSON.stringify(i==="edge-light")}):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let c="";s!=="undefined"&&(c+=s+"/"),i!=="undefined"&&(c+=i+"/");let p=!1;a.options.minify!==void 0&&(p=a.options.minify),s==="development"?p=!1:s==="production"&&(p=!0);const d=[],u=[],f=[],h=[];for(const g of l)g.cjs&&g.esm?d.push(g):g.cjs?f.push(g):g.esm?u.push(g):g.declaration&&h.push(g);if(d.length>0){const g={...a,options:{...a.options,emitCJS:!0,emitESM:!0,entries:d,minify:p}};r.push(ae(g,t,c));const v=g.options.entries.filter(y=>y.declaration);e.options.declaration&&v.length>0&&r.push(K({...g,options:{...g.options,entries:v}},t,c))}if(u.length>0){const g={...a,options:{...a.options,emitCJS:!1,emitESM:!0,entries:u,minify:p}};r.push(ae(g,t,c));const v=g.options.entries.filter(y=>y.declaration);e.options.declaration&&v.length>0&&r.push(K({...g,options:{...g.options,entries:v}},t,c))}if(f.length>0){const g={...a,options:{...a.options,emitCJS:!0,emitESM:!1,entries:f,minify:p}};r.push(ae(g,t,c));const v=g.options.entries.filter(y=>y.declaration);e.options.declaration&&v.length>0&&r.push(K({...g,options:{...g.options,entries:v}},t,c))}if(a.options.declaration&&h.length>0){const g={...a,options:{...a.options,emitCJS:!1,emitESM:!1,entries:h,minify:p}};r.push(K(g,t,c))}}return r},"prepareRollupConfig"),Ps=E(async(e,t,o)=>{await e.hooks.callHook("build:before",e),e.options.minify&&e.logger.info("Minification is enabled, the output will be minified");const r=t.dependencies?.typescript!==void 0||t.devDependencies?.typescript!==void 0;if(e.options.declaration&&e.tsconfig===void 0&&r)throw new Error("Cannot build declaration files without a tsconfig.json");r?e.options.declaration===!1&&e.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(e.options.declaration=!1,e.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),e.options.declaration&&e.logger.info("Using typescript version: "+j(t.devDependencies?.typescript??t.dependencies?.typescript??"unknown")),e.options.declaration&&(t.dependencies?.typescript||t.devDependencies?.typescript)&&!e.tsconfig?.config.compilerOptions?.isolatedModules&&e.logger.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
99
99
  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.
100
- To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),await Promise.all(_s(e,o)),e.logger.success(Ft(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const n of Wt(w(e.options.rootDir,e.options.outDir))){let i=e.buildEntries.find(l=>w(e.options.rootDir,e.options.outDir,l.path)===n.path);if(i||(i={chunk:!0,path:n.path},e.buildEntries.push(i)),!i.bytes){const l=await Be(b(e.options.rootDir,e.options.outDir,n.path));i.bytes=l.size}}const s=Ss(e.logger,e,t);vs(e),ks(t,e),await e.hooks.callHook("build:done",e),Dt(e,s)},"build"),$i=E(async(e,t,o,r,s={})=>{const{configPath:n,debug:i,tsconfigPath:l,...a}=s;r.wrapAll(),e=b(Mt(),e),r.debug("Root directory:",e);const c=w(e,"package.json");if(!S(c))throw new Error("package.json not found at "+c);const p=Ut(c);r.debug("Using package.json found at",c);let d;if(l){const u=w(e,l);if(!await Bt(u))throw new Error("tsconfig.json not found at "+u);d={config:zt(u),path:u},r.info("Using tsconfig settings at",u)}else if(p.dependencies?.typescript||p.devDependencies?.typescript)try{d=await Ht(e),r.debug("Using tsconfig settings found at",d.path)}catch{r.info("No tsconfig.json or jsconfig.json found.")}try{let u=n??"";if(!u){const x=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const _ of x)if(S(w(e,_))){u="./"+_;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(u))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");let f=et(u,e);typeof f=="function"&&(f=f(o,t)),r.debug("Using packem config found at",w(e,u));const h=Date.now(),g=E(()=>Lt(Math.floor(Date.now()-h)),"getDuration"),y=R(JSON.stringify({version:p.version,...p.dependencies,...p.devDependencies,...p.peerDependencies,...p.peerDependenciesMeta,browser:p.browser,eNode:p.engines?.node,exports:p.exports,main:p.main,module:p.module,type:p.type,types:p.types})),v=new rs(e,y,r);v.cachePath&&!S(w(v.cachePath,y))&&S(v.cachePath)&&(r.info("Clearing file cache because the cache key has changed."),await ze(v.cachePath));const $=await Ds(r,e,t,o,i??!1,a,f,p,d);if(v.isEnabled=$.options.fileCache,await us($),$.logger.info(j((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+$.options.name)),$.logger.debug(`${D("Root dir:")} ${$.options.rootDir}
100
+ To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),await Promise.all(_s(e,o)),e.logger.success(Ft(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const n of Wt(w(e.options.rootDir,e.options.outDir))){let i=e.buildEntries.find(l=>w(e.options.rootDir,e.options.outDir,l.path)===n.path);if(i||(i={chunk:!0,path:n.path},e.buildEntries.push(i)),!i.bytes){const l=await Be(b(e.options.rootDir,e.options.outDir,n.path));i.bytes=l.size}}const s=Ss(e.logger,e,t);vs(e),ks(t,e),await e.hooks.callHook("build:done",e),Dt(e,s)},"build"),$i=E(async(e,t,o,r,s={})=>{const{configPath:n,debug:i,tsconfigPath:l,...a}=s;r.wrapAll(),e=b(Mt(),e),r.debug("Root directory:",e);const c=w(e,"package.json");if(!S(c))throw new Error("package.json not found at "+c);const p=Ut(c);r.debug("Using package.json found at",c);let d;if(l){const u=w(e,l);if(!await Bt(u))throw new Error("tsconfig.json not found at "+u);d={config:zt(u),path:u},r.info("Using tsconfig settings at",u)}else if(p.dependencies?.typescript||p.devDependencies?.typescript)try{d=await Ht(e),r.debug("Using tsconfig settings found at",d.path)}catch{r.info("No tsconfig.json or jsconfig.json found.")}try{let u=n??"";if(!u){const x=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const _ of x)if(S(w(e,_))){u="./"+_;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(u))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");let f=et(u,e);typeof f=="function"&&(f=f(o,t)),r.debug("Using packem config found at",w(e,u));const h=Date.now(),g=E(()=>Lt(Math.floor(Date.now()-h)),"getDuration"),v=R(JSON.stringify({version:p.version,...p.dependencies,...p.devDependencies,...p.peerDependencies,...p.peerDependenciesMeta,browser:p.browser,eNode:p.engines?.node,exports:p.exports,main:p.main,module:p.module,type:p.type,types:p.types})),y=new rs(e,v,r);y.cachePath&&!S(w(y.cachePath,v))&&S(y.cachePath)&&(r.info("Clearing file cache because the cache key has changed."),await ze(y.cachePath));const $=await Ds(r,e,t,o,i??!1,a,f,p,d);if(y.isEnabled=$.options.fileCache,await us($),$.logger.info(j((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+$.options.name)),$.logger.debug(`${D("Root dir:")} ${$.options.rootDir}
101
101
  ${D("Entries:")}
102
102
  ${$.options.entries.map(x=>` ${ve(x)}`).join(`
103
- `)}`),await Ns($),$.options.stub){await Mo($),await $.hooks.callHook("build:done",$);return}if(t==="watch"){if($.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await es($,v),Dt($,!1);return}await Ps($,p,v),r.raw(`
103
+ `)}`),await Ns($),$.options.stub){await Mo($),await $.hooks.callHook("build:done",$);return}if(t==="watch"){if($.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await es($,y),Dt($,!1);return}await Ps($,p,y),r.raw(`
104
104
  ⚡️ Build run in `+g()),r.restoreAll()}catch(u){throw r.raw(`
105
105
  `),xt(u),u}},"createBundler");export{$i as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/packem",
3
- "version": "1.0.0-alpha.89",
3
+ "version": "1.0.0-alpha.90",
4
4
  "description": "A fast and modern bundler for Node.js and TypeScript.",
5
5
  "keywords": [
6
6
  "anolilab",