@visulima/packem 1.0.0-alpha.79 → 1.0.0-alpha.80

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.80](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.79...@visulima/packem@1.0.0-alpha.80) (2024-08-20)
2
+
3
+ ### Features
4
+
5
+ * fixed more tests, fixed overwrite of cli -> config file -> base config ([655b999](https://github.com/visulima/packem/commit/655b99937221defc50c28ba1eea511ccd6ce0c90))
6
+
1
7
  ## @visulima/packem [1.0.0-alpha.79](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.78...@visulima/packem@1.0.0-alpha.79) (2024-08-20)
2
8
 
3
9
  ### Features
package/dist/cli.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var h=Object.defineProperty;var p=(n,o)=>h(n,"name",{value:o,configurable:!0});const k=require("@visulima/cerebro"),E=require("@visulima/pail/reporter"),d=require("node:process"),l=require("./shared/packem.CFplOoR-.cjs"),b=require("./create-bundler.cjs"),j=require("@antfu/install-pkg"),a=require("@clack/prompts"),m=require("@visulima/fs"),w=require("@visulima/package/package-json"),u=require("@visulima/path"),N=p(n=>n&&typeof n=="object"&&"default"in n?n.default:n,"_interopDefaultCompat"),C=N(k),V="@visulima/packem",O="1.0.0-alpha.78";var D=Object.defineProperty,g=p((n,o)=>D(n,"name",{value:o,configurable:!0}),"a");const P=g(n=>{n.addCommand({description:"Demonstrate options required",execute:g(async({logger:o,options:e})=>{let s="build";e.watch?s="watch":e.jit&&(s="jit");const r={};let t;if(d.env.NODE_ENV&&[l.DEVELOPMENT_ENV,l.PRODUCTION_ENV].includes(d.env.NODE_ENV)&&(t=d.env.NODE_ENV),e.env)for(const i of e.env)if(i.key==="NODE_ENV"){if(t)throw new Error("NODE_ENV was already set, this can't be overridden.");t=i.value}else r["process.env."+i.key]=JSON.stringify(i.value);t===void 0&&(e.production?t=l.PRODUCTION_ENV:e.development&&(t=l.DEVELOPMENT_ENV));try{await b(e.dir,s,t,o,{cjsInterop:e.cjsInterop,clean:e.clean,configPath:e.config??void 0,debug:e.debug,minify:e.minify===void 0?t===l.PRODUCTION_ENV:e.minify,replace:{...r},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(i){o.error(i),d.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(o=>{const[e,s]=o.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 S=Object.defineProperty,v=p((n,o)=>S(n,"name",{value:o,configurable:!0}),"m");const _=v(n=>{n.addCommand({description:"Initialize packem configuration",execute:v(async({logger:o,options:e})=>{if(a.intro("Welcome to packem setup"),m.isAccessibleSync(u.join(e.dir,"packem.config.ts"))){o.info("Packem project already initialized, you can use `packem build` to build your project");return}if(a.isCancel(e.transformer)){a.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 r=w.parsePackageJson(s),t=[];if(r.dependencies&&t.push(...Object.keys(r.dependencies)),r.devDependencies&&t.push(...Object.keys(r.devDependencies)),e.transformer===void 0&&(e.transformer=await a.select({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!t.includes(e.transformer)&&await a.confirm({message:"Do you want to install "+e.transformer+"?"}))){const i=a.spinner();i.start("Installing "+e.transformer),await j.installPackage(e.transformer==="swc"?"@swc/core":e.transformer,{cwd:e.dir,dev:!0,silent:!0}),i.stop("")}if(t.includes("typescript")||r.type==="module"){const i=`import { defineConfig } from "@visulima/packem/config";
2
+ "use strict";var h=Object.defineProperty;var p=(n,o)=>h(n,"name",{value:o,configurable:!0});const k=require("@visulima/cerebro"),E=require("@visulima/pail/reporter"),d=require("node:process"),l=require("./shared/packem.CFplOoR-.cjs"),b=require("./create-bundler.cjs"),j=require("@antfu/install-pkg"),a=require("@clack/prompts"),m=require("@visulima/fs"),w=require("@visulima/package/package-json"),u=require("@visulima/path"),N=p(n=>n&&typeof n=="object"&&"default"in n?n.default:n,"_interopDefaultCompat"),C=N(k),V="@visulima/packem",O="1.0.0-alpha.79";var D=Object.defineProperty,g=p((n,o)=>D(n,"name",{value:o,configurable:!0}),"a");const P=g(n=>{n.addCommand({description:"Demonstrate options required",execute:g(async({logger:o,options:e})=>{let s="build";e.watch?s="watch":e.jit&&(s="jit");const r={};let t;if(d.env.NODE_ENV&&[l.DEVELOPMENT_ENV,l.PRODUCTION_ENV].includes(d.env.NODE_ENV)&&(t=d.env.NODE_ENV),e.env)for(const i of e.env)if(i.key==="NODE_ENV"){if(t)throw new Error("NODE_ENV was already set, this can't be overridden.");t=i.value}else r["process.env."+i.key]=JSON.stringify(i.value);t===void 0&&(e.production?t=l.PRODUCTION_ENV:e.development&&(t=l.DEVELOPMENT_ENV));try{await b(e.dir,s,t,o,{cjsInterop:e.cjsInterop,clean:e.clean,configPath:e.config??void 0,debug:e.debug,minify:e.minify===void 0?t===l.PRODUCTION_ENV:e.minify,replace:{...r},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(i){o.error(i),d.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(o=>{const[e,s]=o.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 S=Object.defineProperty,v=p((n,o)=>S(n,"name",{value:o,configurable:!0}),"m");const _=v(n=>{n.addCommand({description:"Initialize packem configuration",execute:v(async({logger:o,options:e})=>{if(a.intro("Welcome to packem setup"),m.isAccessibleSync(u.join(e.dir,"packem.config.ts"))){o.info("Packem project already initialized, you can use `packem build` to build your project");return}if(a.isCancel(e.transformer)){a.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 r=w.parsePackageJson(s),t=[];if(r.dependencies&&t.push(...Object.keys(r.dependencies)),r.devDependencies&&t.push(...Object.keys(r.devDependencies)),e.transformer===void 0&&(e.transformer=await a.select({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!t.includes(e.transformer)&&await a.confirm({message:"Do you want to install "+e.transformer+"?"}))){const i=a.spinner();i.start("Installing "+e.transformer),await j.installPackage(e.transformer==="swc"?"@swc/core":e.transformer,{cwd:e.dir,dev:!0,silent:!0}),i.stop("")}if(t.includes("typescript")||r.type==="module"){const i=`import { defineConfig } from "@visulima/packem/config";
3
3
  import transformer from "@visulima/packem/transformer/${e.transformer}";
4
4
 
5
5
  export default defineConfig({
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  var b=Object.defineProperty;var m=(n,i)=>b(n,"name",{value:i,configurable:!0});import w from"@visulima/cerebro";import{SimpleReporter as E}from"@visulima/pail/reporter";import{env as l,exit as j}from"node:process";import{b as y,P as d}from"./shared/packem.C_T1EDp8.mjs";import C from"./create-bundler.mjs";import{installPackage as N}from"@antfu/install-pkg";import{intro as V,isCancel as O,cancel as D,select as P,confirm as x,spinner as f,outro as S}from"@clack/prompts";import{isAccessibleSync as v,writeFileSync as h}from"@visulima/fs";import{parsePackageJson as B}from"@visulima/package/package-json";import{join as s}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 z="@visulima/packem",I="1.0.0-alpha.78";var _=Object.defineProperty,u=m((n,i)=>_(n,"name",{value:i,configurable:!0}),"a");const T=u(n=>{n.addCommand({description:"Demonstrate options required",execute:u(async({logger:i,options:e})=>{let a="build";e.watch?a="watch":e.jit&&(a="jit");const r={};let o;if(l.NODE_ENV&&[y,d].includes(l.NODE_ENV)&&(o=l.NODE_ENV),e.env)for(const t of e.env)if(t.key==="NODE_ENV"){if(o)throw new Error("NODE_ENV was already set, this can't be overridden.");o=t.value}else r["process.env."+t.key]=JSON.stringify(t.value);o===void 0&&(e.production?o=d:e.development&&(o=y));try{await C(e.dir,a,o,i,{cjsInterop:e.cjsInterop,clean:e.clean,configPath:e.config??void 0,debug:e.debug,minify:e.minify===void 0?o===d:e.minify,replace:{...r},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),j(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(i=>{const[e,a]=i.split("=");return{key:e,value:a}},"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 J=Object.defineProperty,k=m((n,i)=>J(n,"name",{value:i,configurable:!0}),"m");const R=k(n=>{n.addCommand({description:"Initialize packem configuration",execute:k(async({logger:i,options:e})=>{if(V("Welcome to packem setup"),v(s(e.dir,"packem.config.ts"))){i.info("Packem project already initialized, you can use `packem build` to build your project");return}if(O(e.transformer)){D("Operation cancelled");return}const a=s(e.dir,"package.json");if(!v(a))throw new Error("No package.json found in the directory");const r=B(a),o=[];if(r.dependencies&&o.push(...Object.keys(r.dependencies)),r.devDependencies&&o.push(...Object.keys(r.devDependencies)),e.transformer===void 0&&(e.transformer=await P({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!o.includes(e.transformer)&&await x({message:"Do you want to install "+e.transformer+"?"}))){const t=f();t.start("Installing "+e.transformer),await N(e.transformer==="swc"?"@swc/core":e.transformer,{cwd:e.dir,dev:!0,silent:!0}),t.stop("")}if(o.includes("typescript")||r.type==="module"){const t=`import { defineConfig } from "@visulima/packem/config";
4
+ const z="@visulima/packem",I="1.0.0-alpha.79";var _=Object.defineProperty,u=m((n,i)=>_(n,"name",{value:i,configurable:!0}),"a");const T=u(n=>{n.addCommand({description:"Demonstrate options required",execute:u(async({logger:i,options:e})=>{let a="build";e.watch?a="watch":e.jit&&(a="jit");const r={};let o;if(l.NODE_ENV&&[y,d].includes(l.NODE_ENV)&&(o=l.NODE_ENV),e.env)for(const t of e.env)if(t.key==="NODE_ENV"){if(o)throw new Error("NODE_ENV was already set, this can't be overridden.");o=t.value}else r["process.env."+t.key]=JSON.stringify(t.value);o===void 0&&(e.production?o=d:e.development&&(o=y));try{await C(e.dir,a,o,i,{cjsInterop:e.cjsInterop,clean:e.clean,configPath:e.config??void 0,debug:e.debug,minify:e.minify===void 0?o===d:e.minify,replace:{...r},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),j(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(i=>{const[e,a]=i.split("=");return{key:e,value:a}},"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 J=Object.defineProperty,k=m((n,i)=>J(n,"name",{value:i,configurable:!0}),"m");const R=k(n=>{n.addCommand({description:"Initialize packem configuration",execute:k(async({logger:i,options:e})=>{if(V("Welcome to packem setup"),v(s(e.dir,"packem.config.ts"))){i.info("Packem project already initialized, you can use `packem build` to build your project");return}if(O(e.transformer)){D("Operation cancelled");return}const a=s(e.dir,"package.json");if(!v(a))throw new Error("No package.json found in the directory");const r=B(a),o=[];if(r.dependencies&&o.push(...Object.keys(r.dependencies)),r.devDependencies&&o.push(...Object.keys(r.devDependencies)),e.transformer===void 0&&(e.transformer=await P({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!o.includes(e.transformer)&&await x({message:"Do you want to install "+e.transformer+"?"}))){const t=f();t.start("Installing "+e.transformer),await N(e.transformer==="swc"?"@swc/core":e.transformer,{cwd:e.dir,dev:!0,silent:!0}),t.stop("")}if(o.includes("typescript")||r.type==="module"){const t=`import { defineConfig } from "@visulima/packem/config";
5
5
  import transformer from "@visulima/packem/transformer/${e.transformer}";
6
6
 
7
7
  export default defineConfig({
@@ -1,11 +1,11 @@
1
- "use strict";var ut=Object.defineProperty;var f=(e,t)=>ut(e,"name",{value:t,configurable:!0});const V=require("node:fs/promises"),dt=require("node:module"),oe=require("node:process"),h=require("@visulima/colorize"),y=require("@visulima/fs"),_=require("@visulima/humanizer"),mt=require("@visulima/package/package-json"),m=require("@visulima/path"),pe=require("@visulima/tsconfig"),ft=require("defu"),gt=require("hookable"),T=require("rollup"),b=require("./shared/packem.CFplOoR-.cjs"),De=require("node:url"),W=require("mlly"),ht=require("magic-string"),yt=require("jiti"),H=require("node:fs"),vt=require("@rollup/plugin-alias"),bt=require("@rollup/plugin-commonjs"),$t=require("@rollup/plugin-dynamic-import-vars"),Ne=require("@rollup/plugin-node-resolve"),jt=require("@rollup/plugin-replace"),wt=require("@rollup/plugin-wasm"),kt=require("rollup-plugin-polyfill-node"),Et=require("rollup-plugin-visualizer"),Pe=require("semver"),xt=require("glob-parent"),Ce=require("tinyglobby"),M=require("@rollup/pluginutils"),St=require("@rollup/plugin-json"),Ot=require("rollup-plugin-license"),_t=require("node:crypto"),Dt=require("@babel/parser"),Nt=require("@visulima/find-cache-dir"),ue=require("@visulima/fs/error"),Pt=require("is-glob"),Ct=require("fastest-levenshtein");var de=typeof document<"u"?document.currentScript:null;const E=f(e=>e&&typeof e=="object"&&"default"in e?e.default:e,"_interopDefaultCompat"),me=E(dt),N=E(ht),Me=E(yt),Ie=E(vt),Mt=E(bt),It=E($t),Re=E(jt),Rt=E(kt),Ft=E(xt),Tt=E(St),At=E(Ot),fe=E(Pt);var Lt=Object.defineProperty,G=f((e,t)=>Lt(e,"name",{value:t,configurable:!0}),"i$d");const ne=/^#![^\n]*/,ee=G(async e=>{await V.chmod(e,493).catch(()=>{})},"makeExecutable"),Jt=G((e,t=`#!/usr/bin/env node
1
+ "use strict";var ut=Object.defineProperty;var f=(e,t)=>ut(e,"name",{value:t,configurable:!0});const V=require("node:fs/promises"),dt=require("node:module"),oe=require("node:process"),h=require("@visulima/colorize"),y=require("@visulima/fs"),_=require("@visulima/humanizer"),mt=require("@visulima/package/package-json"),m=require("@visulima/path"),pe=require("@visulima/tsconfig"),ft=require("defu"),gt=require("hookable"),T=require("rollup"),$=require("./shared/packem.CFplOoR-.cjs"),De=require("node:url"),W=require("mlly"),ht=require("magic-string"),yt=require("jiti"),H=require("node:fs"),vt=require("@rollup/plugin-alias"),bt=require("@rollup/plugin-commonjs"),$t=require("@rollup/plugin-dynamic-import-vars"),Ne=require("@rollup/plugin-node-resolve"),jt=require("@rollup/plugin-replace"),wt=require("@rollup/plugin-wasm"),kt=require("rollup-plugin-polyfill-node"),Et=require("rollup-plugin-visualizer"),Pe=require("semver"),xt=require("glob-parent"),Ce=require("tinyglobby"),M=require("@rollup/pluginutils"),St=require("@rollup/plugin-json"),Ot=require("rollup-plugin-license"),_t=require("node:crypto"),Dt=require("@babel/parser"),Nt=require("@visulima/find-cache-dir"),ue=require("@visulima/fs/error"),Pt=require("is-glob"),Ct=require("fastest-levenshtein");var de=typeof document<"u"?document.currentScript:null;const x=f(e=>e&&typeof e=="object"&&"default"in e?e.default:e,"_interopDefaultCompat"),me=x(dt),N=x(ht),Me=x(yt),Fe=x(vt),Mt=x(bt),Ft=x($t),Ie=x(jt),It=x(kt),Rt=x(xt),Tt=x(St),At=x(Ot),fe=x(Pt);var Lt=Object.defineProperty,G=f((e,t)=>Lt(e,"name",{value:t,configurable:!0}),"i$d");const ne=/^#![^\n]*/,ee=G(async e=>{await V.chmod(e,493).catch(()=>{})},"makeExecutable"),Jt=G((e,t=`#!/usr/bin/env node
2
2
  `)=>({name:"packem:shebang",renderChunk:{handler(o,n,r){if(!n.isEntry||!n.facadeModuleId||o.startsWith("#")&&o[1]==="!")return null;if(e.includes(n.name)){const s=new N(o);return s.prepend(t),{code:s.toString(),map:r.sourcemap?s.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,n){for(const[r,s]of Object.entries(n))if(s.type==="chunk"&&ne.test(s.code)&&o.dir){const i=m.resolve(o.dir,r);await ee(i)}}}),"shebangPlugin"),qt=G(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ne,"")}}),"removeShebangPlugin"),Bt=G((e,t=`
3
3
  `)=>{const o=ne.exec(e);return o?o+t:""},"getShebang");var Ut=Object.defineProperty,Wt=f((e,t)=>Ut(e,"name",{value:t,configurable:!0}),"p$2");const re=Wt((e,t)=>{let o={};if(e.pkg.name&&(o[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:n}=e.pkg;for(const r in n){if(r.startsWith("#"))continue;const s=n[r];typeof s=="string"&&(o[r]=m.join(e.options.rootDir,s))}}return o={...o,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(o,Object.fromEntries(e.options.rollup.alias.entries.map(n=>[n.find,n.replacement]))):Object.assign(o,e.options.rollup.alias.entries??e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(o),prefix:t}),o},"resolveAliases");var zt=Object.defineProperty,Vt=f((e,t)=>zt(e,"name",{value:t,configurable:!0}),"o$4");const Ht=Vt((e,t)=>{const o=Me(t,{esmResolve:!0,interopDefault:!0});try{return o.resolve(e)}catch(n){if(n.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:n});return e}},"tryResolve");var Gt=Object.defineProperty,Xt=f((e,t)=>Gt(e,"name",{value:t,configurable:!0}),"r$9");const A=Xt((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Kt=Object.defineProperty,Yt=f((e,t)=>Kt(e,"name",{value:t,configurable:!0}),"u$a");const Qt=Yt(async e=>{const t=await W.resolvePath("jiti",{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:de&&de.src||new URL("create-bundler.cjs",document.baseURI).href}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...re(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const n of e.options.entries){const r=m.resolve(e.options.rootDir,e.options.outDir,n.name),s=m.normalize(Ht(n.input,e.options.rootDir)||n.input),i=s.slice(0,Math.max(0,s.length-m.extname(s).length)),l=await y.readFile(s),c=Bt(l);e.options.emitCJS&&await y.writeFile(`${r}.cjs`,c+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`module.exports = _jiti(${JSON.stringify(s)})`].join(`
4
- `));let a=[];try{a=await W.resolveModuleExportNames(s,{extensions:b.DEFAULT_EXTENSIONS})}catch(p){A(e,`Cannot analyze ${s} for exports: ${p.toString()}`);return}const u=a.includes("default")||a.length===0;await y.writeFile(`${r}.mjs`,c+[`import jiti from ${JSON.stringify(De.pathToFileURL(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`const _module = await _jiti.import(${JSON.stringify(s)});`,u?`
4
+ `));let a=[];try{a=await W.resolveModuleExportNames(s,{extensions:$.DEFAULT_EXTENSIONS})}catch(p){A(e,`Cannot analyze ${s} for exports: ${p.toString()}`);return}const u=a.includes("default")||a.length===0;await y.writeFile(`${r}.mjs`,c+[`import jiti from ${JSON.stringify(De.pathToFileURL(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`const _module = await _jiti.import(${JSON.stringify(s)});`,u?`
5
5
  export default _module;`:"",...a.filter(p=>p!=="default").map(p=>`export const ${p} = _module.${p};`)].join(`
6
6
  `)),await y.writeFile(`${r}.d.cts`,[`export * from ${JSON.stringify(i)};`,u?`export { default } from ${JSON.stringify(i)};`:""].join(`
7
7
  `)),await y.writeFile(`${r}.d.mts`,[`export * from ${JSON.stringify(s)};`,u?`export { default } from ${JSON.stringify(s)};`:""].join(`
8
- `)),c&&(await ee(`${r}.cjs`),await ee(`${r}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Zt=Object.defineProperty,eo=f((e,t)=>Zt(e,"name",{value:t,configurable:!0}),"r$8");const Fe=eo((e,t)=>Me(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var to=Object.defineProperty,oo=f((e,t)=>to(e,"name",{value:t,configurable:!0}),"i$a");const se=oo(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var no=Object.defineProperty,Te=f((e,t)=>no(e,"name",{value:t,configurable:!0}),"e$1");const z=Te(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Ae=Te((e,t,o,n)=>{if(n){const i=z(n);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[r,...s]=t;return Ae(r,s,o,n)},"inferExportType");var ro=Object.defineProperty,so=f((e,t)=>ro(e,"name",{value:t,configurable:!0}),"i$9");const io=["import","require","node","node-addons","default","production","types","deno","browser","development","react-native","react-server"],ie=so((e,t,o,n=[])=>{if(!e)return[];if(typeof e=="string"){const r=z(e);if(r&&r!==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:r??t}]}return Object.entries(e).filter(([r])=>!r.endsWith(".json")).flatMap(([r,s])=>o===!1&&r==="types"?[]:typeof s=="string"?{file:s,key:"exports",...io.includes(r)?{subKey:r}:{},type:Ae(r,n,t,s)}:ie(s,t,o,[...n,r]))},"extractExportFilenames");var ao=Object.defineProperty,X=f((e,t)=>ao(e,"name",{value:t,configurable:!0}),"m$9");const lo=X((e,t)=>e.key==="exports"&&e.subKey===b.PRODUCTION_ENV?b.PRODUCTION_ENV:e.key==="exports"&&e.subKey===b.DEVELOPMENT_ENV?b.DEVELOPMENT_ENV:t,"getEnvironment"),J=X((e,t,o,n,r,s,i)=>{const l=lo(r,i);let c=e.find(a=>a.input===t&&a.environment===l);if(c===void 0&&(c=e[e.push({input:t})-1]),o&&(c.outDir=n),r.isExecutable)c.executable=!0,c.declaration=!1,r.type==="cjs"&&(c.cjs=!0),r.type==="esm"&&(c.esm=!0);else{/\.d\.[mc]?ts$/.test(r.file)&&s!==!1&&(c.declaration=s),r.type==="cjs"&&(c.cjs=!0),r.type==="esm"&&(c.esm=!0);for(const a of b.RUNTIME_EXPORT_CONVENTIONS)if(r.file.includes("."+a+".")){c.runtime=a;break}}c.runtime===void 0&&(c.runtime="node"),c.environment=l,[b.DEVELOPMENT_ENV,b.PRODUCTION_ENV].includes(r.subKey)&&r.file.includes("."+r.subKey+".")&&(c.fileAlias=!0)},"createOrUpdateEntry"),ge=/(?:\.d\.[mc]?ts|\.\w+)$/;let he=!1;const ye=X(e=>{if(e.pkg?.dependencies?.typescript===void 0&&e.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},"validateIfTypescriptIsInstalled"),co=X((e,t,o)=>{const n=[];t.sort((l,c)=>l.split("/").length-c.split("/").length);const r=e.type==="module"?"esm":"cjs";r==="esm"&&(o.options.emitESM=!0),r==="cjs"&&(o.options.emitCJS=!0);const s=ie(e.exports,r,o.options.declaration);if(e.bin){const l=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const c of l){const a=z(c);if(a&&a!==r)throw new Error(`Exported file "${c}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);s.push({file:c,isExecutable:!0,key:"bin",type:a})}}e.main&&s.push({file:e.main,key:"main",type:z(e.main)??r}),e.module&&s.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(ye(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),s.push({file:e.types??e.typings,key:"types"}));const i=[];for(const l of s){o.options.declaration===void 0&&(l.key==="types"||l.subKey==="types")&&(o.options.declaration=l.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&l.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&l.type==="esm"&&(o.options.emitESM=!0);const c=l.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),a=c.endsWith("/");if(a&&["./","/"].includes(c))continue;let u=c.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./","");if((l.subKey===b.DEVELOPMENT_ENV||l.subKey===b.PRODUCTION_ENV)&&(u=u.replace("."+l.subKey,"")),l.file.includes("/*")&&l.key==="exports"){he||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),he=!0);const g=[],$=new RegExp("(?<=/|$)"+u.replace("*","(.*)")+(a?"":"\\.\\w+"));for(const O of t)$.test(O)&&g.push(O.replace(ge,""));if(g.length===0){n.push(`Could not find entrypoint for \`${l.file}\``);continue}for(const O of g)J(i,O,a,c,l,o.options.declaration,o.environment);continue}const p=new RegExp("(?<=/|$)"+u+(a?"":"\\.\\w+")),d=t.find(g=>p.test(g))?.replace(ge,"");if(!d){H.existsSync(m.resolve(o.options.rootDir,l.file))||n.push(`Could not find entrypoint for \`${l.file}\``);continue}(y.isAccessibleSync(d+".ts")||y.isAccessibleSync(d+".cts")||y.isAccessibleSync(d+".mts"))&&ye(o),y.isAccessibleSync(d+".cts")&&y.isAccessibleSync(d+".mts")?(J(i,d+".cts",a,c,{...l,type:"cjs"},o.options.declaration,o.environment),J(i,d+".mts",a,c,{...l,type:"esm"},o.options.declaration,o.environment)):J(i,d,a,c,l,o.options.declaration,o.environment)}return{entries:i,warnings:n}},"inferEntries");var po=Object.defineProperty,uo=f((e,t)=>po(e,"name",{value:t,configurable:!0}),"o$3");const mo=uo((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 fo=Object.defineProperty,go=f((e,t)=>fo(e,"name",{value:t,configurable:!0}),"t$6");const ho={hooks:{"build:prepare":go(function(e){if(e.options.entries.length>0)return;const t=m.join(e.options.rootDir,e.options.sourceDir);if(!H.existsSync(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=y.collectSync(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let n={...e.pkg};n.publishConfig&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(n.publishConfig).join(", ")+'".'),e.logger.debug(se(n.publishConfig)),n=mo(n,e.options.declaration));const r=co(n,o,e);for(const s of r.warnings)A(e,s);if(e.options.entries.push(...r.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",h.cyan(e.options.entries.map(s=>h.bold(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),h.gray([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var yo=Object.defineProperty,vo=f((e,t)=>yo(e,"name",{value:t,configurable:!0}),"n$6");const bo=vo((e,t)=>{if(e==="auto")e=ho;else{if(e==="none")return{};typeof e=="string"&&(e=Fe(e,t))}return typeof e=="function"&&(e=e()),e},"resolvePreset");var $o=Object.defineProperty,jo=f((e,t)=>$o(e,"name",{value:t,configurable:!0}),"a$b");const te=jo((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var wo=Object.defineProperty,ko=f((e,t)=>wo(e,"name",{value:t,configurable:!0}),"a$a");const F=ko(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var Eo=Object.defineProperty,xo=f((e,t)=>Eo(e,"name",{value:t,configurable:!0}),"a$9");const Le=xo((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var So=Object.defineProperty,Je=f((e,t)=>So(e,"name",{value:t,configurable:!0}),"s$9");const Oo=Je((e,t,o)=>{const n=o??new Map;return(...r)=>{const s=t?typeof t=="function"?t(...r):t:JSON.stringify({args:r}),i=n.get(s);if(i!==void 0)return i;const l=e(...r);return n.set(s,l),l}},"memoize"),_o=Je(e=>{const t=new Map;return o=>Oo(e,o,t)},"memoizeByKey");var Do=Object.defineProperty,No=f((e,t)=>Do(e,"name",{value:t,configurable:!0}),"m$8");const qe=No(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk(n,r,s){if(r.type!=="chunk"||!r.isEntry)return null;if(s.format==="cjs"&&s.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(i===null||i.length<3)return null;const l=new N(n);l.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),l.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&l.append(`
8
+ `)),c&&(await ee(`${r}.cjs`),await ee(`${r}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Zt=Object.defineProperty,eo=f((e,t)=>Zt(e,"name",{value:t,configurable:!0}),"r$8");const Re=eo((e,t)=>Me(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var to=Object.defineProperty,oo=f((e,t)=>to(e,"name",{value:t,configurable:!0}),"i$a");const se=oo(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var no=Object.defineProperty,Te=f((e,t)=>no(e,"name",{value:t,configurable:!0}),"e$1");const z=Te(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Ae=Te((e,t,o,n)=>{if(n){const i=z(n);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[r,...s]=t;return Ae(r,s,o,n)},"inferExportType");var ro=Object.defineProperty,so=f((e,t)=>ro(e,"name",{value:t,configurable:!0}),"i$9");const io=["import","require","node","node-addons","default","production","types","deno","browser","development","react-native","react-server"],ie=so((e,t,o,n=[])=>{if(!e)return[];if(typeof e=="string"){const r=z(e);if(r&&r!==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:r??t}]}return Object.entries(e).filter(([r])=>!r.endsWith(".json")).flatMap(([r,s])=>o===!1&&r==="types"?[]:typeof s=="string"?{file:s,key:"exports",...io.includes(r)?{subKey:r}:{},type:Ae(r,n,t,s)}:ie(s,t,o,[...n,r]))},"extractExportFilenames");var ao=Object.defineProperty,X=f((e,t)=>ao(e,"name",{value:t,configurable:!0}),"m$9");const lo=X((e,t)=>e.key==="exports"&&e.subKey===$.PRODUCTION_ENV?$.PRODUCTION_ENV:e.key==="exports"&&e.subKey===$.DEVELOPMENT_ENV?$.DEVELOPMENT_ENV:t,"getEnvironment"),J=X((e,t,o,n,r,s,i)=>{const l=lo(r,i);let c=e.find(a=>a.input===t&&a.environment===l);if(c===void 0&&(c=e[e.push({input:t})-1]),o&&(c.outDir=n),r.isExecutable)c.executable=!0,c.declaration=!1,r.type==="cjs"&&(c.cjs=!0),r.type==="esm"&&(c.esm=!0);else{/\.d\.[mc]?ts$/.test(r.file)&&s!==!1&&(c.declaration=s),r.type==="cjs"&&(c.cjs=!0),r.type==="esm"&&(c.esm=!0);for(const a of $.RUNTIME_EXPORT_CONVENTIONS)if(r.file.includes("."+a+".")){c.runtime=a;break}}c.runtime===void 0&&(c.runtime="node"),c.environment=l,[$.DEVELOPMENT_ENV,$.PRODUCTION_ENV].includes(r.subKey)&&r.file.includes("."+r.subKey+".")&&(c.fileAlias=!0)},"createOrUpdateEntry"),ge=/(?:\.d\.[mc]?ts|\.\w+)$/;let he=!1;const ye=X(e=>{if(e.pkg?.dependencies?.typescript===void 0&&e.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},"validateIfTypescriptIsInstalled"),co=X((e,t,o)=>{const n=[];t.sort((l,c)=>l.split("/").length-c.split("/").length);const r=e.type==="module"?"esm":"cjs";r==="esm"&&(o.options.emitESM=!0),r==="cjs"&&(o.options.emitCJS=!0);const s=ie(e.exports,r,o.options.declaration);if(e.bin){const l=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const c of l){const a=z(c);if(a&&a!==r)throw new Error(`Exported file "${c}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);s.push({file:c,isExecutable:!0,key:"bin",type:a??r})}}e.main&&s.push({file:e.main,key:"main",type:z(e.main)??r}),e.module&&s.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(ye(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),s.push({file:e.types??e.typings,key:"types"}));const i=[];for(const l of s){o.options.declaration===void 0&&(l.key==="types"||l.subKey==="types")&&(o.options.declaration=l.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&l.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&l.type==="esm"&&(o.options.emitESM=!0);const c=l.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),a=c.endsWith("/");if(a&&["./","/"].includes(c))continue;let u=c.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./","");if((l.subKey===$.DEVELOPMENT_ENV||l.subKey===$.PRODUCTION_ENV)&&(u=u.replace("."+l.subKey,"")),l.file.includes("/*")&&l.key==="exports"){he||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),he=!0);const g=[],v=new RegExp("(?<=/|$)"+u.replace("*","(.*)")+(a?"":"\\.\\w+"));for(const w of t)v.test(w)&&g.push(w.replace(ge,""));if(g.length===0){n.push(`Could not find entrypoint for \`${l.file}\``);continue}for(const w of g)J(i,w,a,c,l,o.options.declaration,o.environment);continue}const p=new RegExp("(?<=/|$)"+u+(a?"":"\\.\\w+")),d=t.find(g=>p.test(g))?.replace(ge,"");if(!d){H.existsSync(m.resolve(o.options.rootDir,l.file))||n.push(`Could not find entrypoint for \`${l.file}\``);continue}(y.isAccessibleSync(d+".ts")||y.isAccessibleSync(d+".cts")||y.isAccessibleSync(d+".mts"))&&ye(o),y.isAccessibleSync(d+".cts")&&y.isAccessibleSync(d+".mts")?(J(i,d+".cts",a,c,{...l,type:"cjs"},o.options.declaration,o.environment),J(i,d+".mts",a,c,{...l,type:"esm"},o.options.declaration,o.environment)):J(i,d,a,c,l,o.options.declaration,o.environment)}return{entries:i,warnings:n}},"inferEntries");var po=Object.defineProperty,uo=f((e,t)=>po(e,"name",{value:t,configurable:!0}),"o$3");const mo=uo((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 fo=Object.defineProperty,go=f((e,t)=>fo(e,"name",{value:t,configurable:!0}),"t$6");const ho={hooks:{"build:prepare":go(function(e){if(e.options.entries.length>0)return;const t=m.join(e.options.rootDir,e.options.sourceDir);if(!H.existsSync(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=y.collectSync(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let n={...e.pkg};n.publishConfig&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(n.publishConfig).join(", ")+'".'),e.logger.debug(se(n.publishConfig)),n=mo(n,e.options.declaration));const r=co(n,o,e);for(const s of r.warnings)A(e,s);if(e.options.entries.push(...r.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",h.cyan(e.options.entries.map(s=>h.bold(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),h.gray([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var yo=Object.defineProperty,vo=f((e,t)=>yo(e,"name",{value:t,configurable:!0}),"n$6");const bo=vo((e,t)=>{if(e==="auto")e=ho;else{if(e==="none")return{};typeof e=="string"&&(e=Re(e,t))}return typeof e=="function"&&(e=e()),e},"resolvePreset");var $o=Object.defineProperty,jo=f((e,t)=>$o(e,"name",{value:t,configurable:!0}),"a$b");const te=jo((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var wo=Object.defineProperty,ko=f((e,t)=>wo(e,"name",{value:t,configurable:!0}),"a$a");const R=ko(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var Eo=Object.defineProperty,xo=f((e,t)=>Eo(e,"name",{value:t,configurable:!0}),"a$9");const Le=xo((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var So=Object.defineProperty,Je=f((e,t)=>So(e,"name",{value:t,configurable:!0}),"s$9");const Oo=Je((e,t,o)=>{const n=o??new Map;return(...r)=>{const s=t?typeof t=="function"?t(...r):t:JSON.stringify({args:r}),i=n.get(s);if(i!==void 0)return i;const l=e(...r);return n.set(s,l),l}},"memoize"),_o=Je(e=>{const t=new Map;return o=>Oo(e,o,t)},"memoizeByKey");var Do=Object.defineProperty,No=f((e,t)=>Do(e,"name",{value:t,configurable:!0}),"m$8");const qe=No(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk(n,r,s){if(r.type!=="chunk"||!r.isEntry)return null;if(s.format==="cjs"&&s.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(i===null||i.length<3)return null;const l=new N(n);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 c=l.toString();return c=c.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:c,map:l.generateMap({hires:!0})}}if(s.format==="es"&&/\.d\.(?:ts|cts)$/.test(r.fileName)){if(o!=="commonjs"&&r.fileName.endsWith(".d.ts"))return null;const i=/export\s\{\s(.*)\s\}/i.exec(n);if(i===null||i.length<2)return null;const l=i[1].split(", "),c=[];let a="";for(const p of l)if(!p.includes("type"))if(p.includes("as")){const[d,g]=p.split(" as ");if(g==="default"&&(a=d,!e))continue;c.push(g+": typeof "+d+";")}else c.push(p+": typeof "+p+";");const u=new N(n);return u.replace(" "+a+" as default,",""),u.append(`
10
10
 
11
11
  declare const defaultExport: {
@@ -13,7 +13,7 @@ declare const defaultExport: {
13
13
  `)+`
14
14
  }`+(a?" & typeof "+a:"")+`;
15
15
 
16
- export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:u.toString(),map:u.generateMap({hires:!0})}}return null}}),"cjsInterop");var Po=Object.defineProperty,Co=f((e,t)=>Po(e,"name",{value:t,configurable:!0}),"u$7");const Mo=Co((e,t)=>{const o=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:r}=n;return Array.isArray(r)?r=r.map(s=>{if(typeof s=="string")return{src:s};if(typeof s=="object"&&"src"in s)return s}).filter(Boolean):typeof r=="string"&&(r=[{src:r}]),{async buildStart(){const s=await Promise.all(r.flatMap(i=>Array.isArray(i.src)?i.src.map(l=>({...i,src:l})):i).map(async i=>await Ce.glob(F(i.src),{ignore:F(i.exclude).filter(Boolean)}).then(l=>({dest:i.dest??"",parent:Ft(i.src),src:l}))));for(const i of s)for(const l of i.src){let c;o.has(l)?c=o.get(l):(c={copied:[],dest:[],timestamp:0},o.set(l,c));const a=n.flatten?m.normalize(i.dest):m.join(i.dest,m.relative(i.parent,m.dirname(l)));c.dest.includes(a)||c.dest.push(a),this.addWatchFile(l)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([i,l])=>{let c;try{const a=await V.stat(i);if(!a.isFile())return;const u=a.mtime.getTime();u>l.timestamp&&(l.timestamp=u,l.copied=[]),c=await y.readFile(i,{buffer:!0})}catch(a){t.error({context:[a],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const a of l.dest){if(n.copyOnce&&l.copied.includes(a))continue;const u=m.basename(i),p=m.join(a,u);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:p,source:c,type:"asset"}),t.debug({message:`copied ${i} → ${p}`,prefix:"plugin:copy"}),l.copied.push(a)}catch(d){t.error({context:[d],message:`error copying file ${i} → ${p}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Io=Object.defineProperty,K=f((e,t)=>Io(e,"name",{value:t,configurable:!0}),"t$4");const Ro=/\Wrequire(?:\.resolve)?\(/,Fo=K((e,t)=>{if(oe.env.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes("// -- packem CommonJS __filename shim")||e.includes("// -- packem CommonJS __dirname shim")||e.includes("// -- packem CommonJS require shim")))return null;let o=!1,n=!1,r=!1;if(e.includes("__filename")&&(o=!0),e.includes("__dirname")&&(n=!0),Ro.test(e)&&(r=!0),!o&&!n&&!r)return null;const s=W.findStaticImports(e).pop(),i=s?s.end:0,l=new N(e);return l.appendRight(i,t(o,n,r)),{code:l.toString(),map:l.generateMap()}},"CJSToESM"),To=K((e,t,o)=>{let n="";return(e||t)&&(n+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
16
+ export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:u.toString(),map:u.generateMap({hires:!0})}}return null}}),"cjsInterop");var Po=Object.defineProperty,Co=f((e,t)=>Po(e,"name",{value:t,configurable:!0}),"u$7");const Mo=Co((e,t)=>{const o=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:r}=n;return Array.isArray(r)?r=r.map(s=>{if(typeof s=="string")return{src:s};if(typeof s=="object"&&"src"in s)return s}).filter(Boolean):typeof r=="string"&&(r=[{src:r}]),{async buildStart(){const s=await Promise.all(r.flatMap(i=>Array.isArray(i.src)?i.src.map(l=>({...i,src:l})):i).map(async i=>await Ce.glob(R(i.src),{ignore:R(i.exclude).filter(Boolean)}).then(l=>({dest:i.dest??"",parent:Rt(i.src),src:l}))));for(const i of s)for(const l of i.src){let c;o.has(l)?c=o.get(l):(c={copied:[],dest:[],timestamp:0},o.set(l,c));const a=n.flatten?m.normalize(i.dest):m.join(i.dest,m.relative(i.parent,m.dirname(l)));c.dest.includes(a)||c.dest.push(a),this.addWatchFile(l)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([i,l])=>{let c;try{const a=await V.stat(i);if(!a.isFile())return;const u=a.mtime.getTime();u>l.timestamp&&(l.timestamp=u,l.copied=[]),c=await y.readFile(i,{buffer:!0})}catch(a){t.error({context:[a],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const a of l.dest){if(n.copyOnce&&l.copied.includes(a))continue;const u=m.basename(i),p=m.join(a,u);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:p,source:c,type:"asset"}),t.debug({message:`copied ${i} → ${p}`,prefix:"plugin:copy"}),l.copied.push(a)}catch(d){t.error({context:[d],message:`error copying file ${i} → ${p}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Fo=Object.defineProperty,K=f((e,t)=>Fo(e,"name",{value:t,configurable:!0}),"t$4");const Io=/\Wrequire(?:\.resolve)?\(/,Ro=K((e,t)=>{if(oe.env.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes("// -- packem CommonJS __filename shim")||e.includes("// -- packem CommonJS __dirname shim")||e.includes("// -- packem CommonJS require shim")))return null;let o=!1,n=!1,r=!1;if(e.includes("__filename")&&(o=!0),e.includes("__dirname")&&(n=!0),Io.test(e)&&(r=!0),!o&&!n&&!r)return null;const s=W.findStaticImports(e).pop(),i=s?s.end:0,l=new N(e);return l.appendRight(i,t(o,n,r)),{code:l.toString(),map:l.generateMap()}},"CJSToESM"),To=K((e,t,o)=>{let n="";return(e||t)&&(n+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
17
17
  `),t&&(n+=`import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
18
18
  `),o&&(n+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
19
19
  `),(e||t)&&(n+=`const __filename = __cjs_url__.fileURLToPath(import.meta.url);
@@ -23,59 +23,59 @@ export default defaultExport;`),t.debug({message:"Applied CommonJS interop to en
23
23
  `),e&&(n+=`const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
24
24
  `),t&&(n+=`const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
25
25
  `),o&&(n+=`const require = __cjs_mod__.createRequire(import.meta.url);
26
- `),n},"generateCJSShimNode20_11"),Lo=K((e,t)=>{const o=M.createFilter(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(n,r,s){if(s.format==="es"&&o(r.fileName)){let i=To;if(e.engines?.node){const l=Pe.minVersion(e.engines.node);l&&l.major>=20&&l.minor>=11&&(i=Ao)}return Fo(n,i)}return null}}},"esmShimCjsSyntaxPlugin");var Jo=Object.defineProperty,qo=f((e,t)=>Jo(e,"name",{value:t,configurable:!0}),"n$3");const Bo=qo(()=>({name:"packem:cjs",renderChunk(e,t,o){return o.format==="es"||o.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(o.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var Uo=Object.defineProperty,ve=f((e,t)=>Uo(e,"name",{value:t,configurable:!0}),"c$8");const Wo=ve(e=>(t,o={})=>{const n=M.createFilter(o.include,o.exclude),r={},s=ve((i,l)=>{r[i.replace(/\..?[jt]s$/,"")]=l},"addOutput");return{generateBundle(i,l){let{entryFileNames:c}=i;typeof c=="function"&&(c=c(l));const a=c.replace(/\.(.)?[jt]s$/,(u,p)=>`.d.${p||""}ts`);for(const[u,p]of Object.entries(r))this.emitFile({fileName:a.replace("[name]",m.relative(e,u)),source:p,type:"asset"})},name:"packem:isolated-declarations",async transform(i,l){if(!n(l))return;const c=await t(l,i),{errors:a,sourceText:u}=c;a.length>0?o.ignoreErrors?this.warn(a[0]):this.error(a[0]):s(l,u)}}},"isolatedDeclarationsPlugin");var zo=Object.defineProperty,Vo=f((e,t)=>zo(e,"name",{value:t,configurable:!0}),"n$2");const be="export default ",Be=Vo(e=>{const t=Tt(e);return{...t,name:"packem:json",transform(o,n){const r=t.transform?.call(this,o,n);return r&&typeof r!="string"&&"code"in r&&r.code?.startsWith(be)&&(r.code=r.code.replace(be,"module.exports = ")),r}}},"JSONPlugin");class Ho{static{f(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:f(()=>this.should_skip=!0,"skip"),remove:f(()=>this.should_remove=!0,"remove"),replace:f(t=>this.replacement=t,"replace")}}replace(t,o,n,r){t&&o&&(n!=null?t[o][n]=r:t[o]=r)}remove(t,o,n){t&&o&&(n!=null?t[o].splice(n,1):delete t[o])}}class Go extends Ho{static{f(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:f(()=>this.should_skip=!0,"skip"),remove:f(()=>this.should_remove=!0,"remove"),replace:f(n=>this.replacement=n,"replace")},this.enter=t,this.leave=o}visit(t,o,n,r){if(t){if(this.enter){const i=this.should_skip,l=this.should_remove,c=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const a=this.should_skip,u=this.should_remove;if(this.should_skip=i,this.should_remove=l,this.replacement=c,a)return t;if(u)return null}let s;for(s in t){const i=t[s];if(i&&typeof i=="object")if(Array.isArray(i)){const l=i;for(let c=0;c<l.length;c+=1){const a=l[c];$e(a)&&(this.visit(a,t,s,c)||c--)}}else $e(i)&&this.visit(i,t,s,null)}if(this.leave){const i=this.replacement,l=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const c=this.should_remove;if(this.replacement=i,this.should_remove=l,c)return null}}return t}}function $e(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}f($e,"isNode");function Ue(e,{enter:t,leave:o}){return new Go(t,o).visit(e,null)}f(Ue,"walk");var Xo=Object.defineProperty,Ko=f((e,t)=>Xo(e,"name",{value:t,configurable:!0}),"u$6");const Yo=Ko(({attributes:e,logger:t})=>{const o=M.createFilter([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(n,r){if(!o(r))return null;let s=null;try{s=this.parse(n,{allowReturnOutsideFunction:!0})}catch(c){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${r}" and remove the jsx attribute.`}),t.warn(c),null}let i=!1;const l=new N(n);return Ue(s,{enter(c){if(c.type==="CallExpression"&&c.callee.type==="Identifier"&&c.callee.name==="jsx"){const a=c.arguments.filter(u=>u.type==="ObjectExpression"&&Array.isArray(u.properties));for(const u of a)for(const p of u.properties)p.type==="Property"&&p.key.type==="Literal"&&p.value.type==="Literal"&&e.includes(p.key.value)&&(l.overwrite(p.start-2,p.end,""),i=!0)}}}),i?{code:l.toString(),map:l.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Qo=Object.defineProperty,ae=f((e,t)=>Qo(e,"name",{value:t,configurable:!0}),"g$3");const Zo=ae(e=>{const t=[],o=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):o.push(n)}),[...o.sort(),...t.sort()]},"sortLicenses"),en=ae((e,t,o)=>{const n=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(n.test(e))return e.replace(n,`$1
26
+ `),n},"generateCJSShimNode20_11"),Lo=K((e,t)=>{const o=M.createFilter(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(n,r,s){if(s.format==="es"&&o(r.fileName)){let i=To;if(e.engines?.node){const l=Pe.minVersion(e.engines.node);l&&l.major>=20&&l.minor>=11&&(i=Ao)}return Ro(n,i)}return null}}},"esmShimCjsSyntaxPlugin");var Jo=Object.defineProperty,qo=f((e,t)=>Jo(e,"name",{value:t,configurable:!0}),"n$3");const Bo=qo(()=>({name:"packem:cjs",renderChunk(e,t,o){return o.format==="es"||o.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(o.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var Uo=Object.defineProperty,ve=f((e,t)=>Uo(e,"name",{value:t,configurable:!0}),"c$8");const Wo=ve(e=>(t,o={})=>{const n=M.createFilter(o.include,o.exclude),r={},s=ve((i,l)=>{r[i.replace(/\..?[jt]s$/,"")]=l},"addOutput");return{generateBundle(i,l){let{entryFileNames:c}=i;typeof c=="function"&&(c=c(l));const a=c.replace(/\.(.)?[jt]s$/,(u,p)=>`.d.${p||""}ts`);for(const[u,p]of Object.entries(r))this.emitFile({fileName:a.replace("[name]",m.relative(e,u)),source:p,type:"asset"})},name:"packem:isolated-declarations",async transform(i,l){if(!n(l))return;const c=await t(l,i),{errors:a,sourceText:u}=c;a.length>0?o.ignoreErrors?this.warn(a[0]):this.error(a[0]):s(l,u)}}},"isolatedDeclarationsPlugin");var zo=Object.defineProperty,Vo=f((e,t)=>zo(e,"name",{value:t,configurable:!0}),"n$2");const be="export default ",Be=Vo(e=>{const t=Tt(e);return{...t,name:"packem:json",transform(o,n){const r=t.transform?.call(this,o,n);return r&&typeof r!="string"&&"code"in r&&r.code?.startsWith(be)&&(r.code=r.code.replace(be,"module.exports = ")),r}}},"JSONPlugin");class Ho{static{f(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:f(()=>this.should_skip=!0,"skip"),remove:f(()=>this.should_remove=!0,"remove"),replace:f(t=>this.replacement=t,"replace")}}replace(t,o,n,r){t&&o&&(n!=null?t[o][n]=r:t[o]=r)}remove(t,o,n){t&&o&&(n!=null?t[o].splice(n,1):delete t[o])}}class Go extends Ho{static{f(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:f(()=>this.should_skip=!0,"skip"),remove:f(()=>this.should_remove=!0,"remove"),replace:f(n=>this.replacement=n,"replace")},this.enter=t,this.leave=o}visit(t,o,n,r){if(t){if(this.enter){const i=this.should_skip,l=this.should_remove,c=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const a=this.should_skip,u=this.should_remove;if(this.should_skip=i,this.should_remove=l,this.replacement=c,a)return t;if(u)return null}let s;for(s in t){const i=t[s];if(i&&typeof i=="object")if(Array.isArray(i)){const l=i;for(let c=0;c<l.length;c+=1){const a=l[c];$e(a)&&(this.visit(a,t,s,c)||c--)}}else $e(i)&&this.visit(i,t,s,null)}if(this.leave){const i=this.replacement,l=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const c=this.should_remove;if(this.replacement=i,this.should_remove=l,c)return null}}return t}}function $e(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}f($e,"isNode");function Ue(e,{enter:t,leave:o}){return new Go(t,o).visit(e,null)}f(Ue,"walk");var Xo=Object.defineProperty,Ko=f((e,t)=>Xo(e,"name",{value:t,configurable:!0}),"u$6");const Yo=Ko(({attributes:e,logger:t})=>{const o=M.createFilter([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(n,r){if(!o(r))return null;let s=null;try{s=this.parse(n,{allowReturnOutsideFunction:!0})}catch(c){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${r}" and remove the jsx attribute.`}),t.warn(c),null}let i=!1;const l=new N(n);return Ue(s,{enter(c){if(c.type==="CallExpression"&&c.callee.type==="Identifier"&&c.callee.name==="jsx"){const a=c.arguments.filter(u=>u.type==="ObjectExpression"&&Array.isArray(u.properties));for(const u of a)for(const p of u.properties)p.type==="Property"&&p.key.type==="Literal"&&p.value.type==="Literal"&&e.includes(p.key.value)&&(l.overwrite(p.start-2,p.end,""),i=!0)}}}),i?{code:l.toString(),map:l.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Qo=Object.defineProperty,ae=f((e,t)=>Qo(e,"name",{value:t,configurable:!0}),"g$4");const Zo=ae(e=>{const t=[],o=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):o.push(n)}),[...o.sort(),...t.sort()]},"sortLicenses"),en=ae((e,t,o)=>{const n=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(n.test(e))return e.replace(n,`$1
27
27
  ${o}
28
- $2`)},"replaceContentWithin"),We=ae(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:n,marker:r,mode:s,packageName:i})=>At({thirdParty(l){const c=new Set,a=l.sort(({name:p},{name:d})=>(p||0)>(d||0)?1:(d||0)>(p||0)?-1:0).map(({author:p,contributors:d,license:g,licenseText:$,maintainers:O,name:L,repository:k})=>{let v="## "+L+`
29
- `;g&&(v+=`License: ${g}
30
- `);const P=new Set;for(const S of[p,...O,...d]){const ce=typeof S=="string"?S:S?.name;ce&&P.add(ce)}return P.size>0&&(v+=`By: ${[...P].join(", ")}
31
- `),k&&(v+=`Repository: ${typeof k=="string"?k:k.url}
32
- `),$&&(v+=`
33
- `+$.trim().replaceAll(/\r\n|\r/g,`
28
+ $2`)},"replaceContentWithin"),We=ae(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:n,marker:r,mode:s,packageName:i})=>At({thirdParty(l){const c=new Set,a=l.sort(({name:p},{name:d})=>(p||0)>(d||0)?1:(d||0)>(p||0)?-1:0).map(({author:p,contributors:d,license:g,licenseText:v,maintainers:w,name:L,repository:E})=>{let b="## "+L+`
29
+ `;g&&(b+=`License: ${g}
30
+ `);const P=new Set;for(const O of[p,...w,...d]){const ce=typeof O=="string"?O:O?.name;ce&&P.add(ce)}return P.size>0&&(b+=`By: ${[...P].join(", ")}
31
+ `),E&&(b+=`Repository: ${typeof E=="string"?E:E.url}
32
+ `),v&&(b+=`
33
+ `+v.trim().replaceAll(/\r\n|\r/g,`
34
34
  `).replaceAll(`<!-- ${r} -->`,"").replaceAll(e?`<!-- ${e} -->`:"","").trim().split(`
35
- `).map(S=>S?`> ${S}`:">").join(`
35
+ `).map(O=>O?`> ${O}`:">").join(`
36
36
  `)+`
37
- `),g&&c.add(g),v}).join(`
37
+ `),g&&c.add(g),b}).join(`
38
38
  ---------------------------------------
39
39
 
40
- `);if(a===""){n.info({message:"No dependencies license information found.",prefix:"plugin:license:"+s});return}const u=o(Zo(c),a,i);try{const p=y.readFileSync(t),d=en(p,r,u);if(!d){n.error({message:`Could not find the license marker: <!-- ${r} --> in ${t}`,prefix:"plugin:license:"+s});return}p!==d&&(y.writeFileSync(t,d),n.info({message:`${t} updated.`,prefix:"plugin:license:"+s}))}catch(p){n.error(p)}}}),"license");var tn=Object.defineProperty,on=f((e,t)=>tn(e,"name",{value:t,configurable:!0}),"i$7");const nn=on(e=>({async buildEnd(){const t=[];for(const n of this.getModuleIds()){const r=this.getModuleInfo(n);if(r!=null&&!r.isExternal)for(const s of r.importedIds)t.push({source:n,target:s})}if(Array.isArray(t)&&t.length===0)return;const o=m.resolve(e.rootDir,e.outDir,"graph.json");y.writeJsonSync(o,t)},name:"packem:metafile"}),"metafilePlugin");var rn=Object.defineProperty,sn=f((e,t)=>rn(e,"name",{value:t,configurable:!0}),"r$4");const C=sn(e=>{const t=_t.createHash("md5");return t.update(e),t.digest("hex")},"getHash");var an=Object.defineProperty,ze=f((e,t)=>an(e,"name",{value:t,configurable:!0}),"m$5");const R=ze(e=>e.handler||e,"getHandler"),x=ze((e,t)=>({...e,async buildEnd(o){e.buildEnd&&await R(e.buildEnd).call(this,o)},async buildStart(o){e.buildStart&&await R(e.buildStart).call(this,o)},async load(o){if(!e.load)return null;const n=m.join("load",C(o));if(t.has(n,e.name))return await t.get(n,e.name);const r=await R(e.load).call(this,o);return t.set(n,r,e.name),r},name:`cached(${e.name})`,async resolveId(o,n,r){if(!e.resolveId)return null;const s=m.join("resolveId",C(o),n?C(n):"",C(JSON.stringify(r)));if(t.has(s,e.name))return await t.get(s,e.name);const i=await R(e.resolveId).call(this,o,n,r);return t.set(s,i,e.name),i},async transform(o,n){if(!e.transform)return null;const r=m.join("transform",C(n),C(o));if(t.has(r,e.name))return await t.get(r,e.name);const s=await R(e.transform).call(this,o,n);return t.set(r,s,e.name),s}}),"cachingPlugin");var ln=Object.defineProperty,cn=f((e,t)=>ln(e,"name",{value:t,configurable:!0}),"c$6");const pn=/\.(?:m|c)?(?:j|t)sx?$/,un=/^use \w+$/,dn=cn(e=>{const t={},o={};return{name:"packem:preserve-directives",onLog(n,r){return r.code==="MODULE_LEVEL_DIRECTIVE"&&n==="warn"?!1:null},renderChunk:{handler(n,r,{sourcemap:s}){const i=r.moduleIds.map(a=>t[a]?t[a]:null).reduce((a,u)=>(u&&u.forEach(p=>{a.add(p)}),a),new Set),l=new N(n);i.size>0&&(e.debug({message:`directives for chunk "${r.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),l.prepend(`${[...i].map(a=>`'${a}';`).join(`
40
+ `);if(a===""){n.info({message:"No dependencies license information found.",prefix:"plugin:license:"+s});return}const u=o(Zo(c),a,i);try{const p=y.readFileSync(t),d=en(p,r,u);if(!d){n.error({message:`Could not find the license marker: <!-- ${r} --> in ${t}`,prefix:"plugin:license:"+s});return}p!==d&&(y.writeFileSync(t,d),n.info({message:`${t} updated.`,prefix:"plugin:license:"+s}))}catch(p){n.error(p)}}}),"license");var tn=Object.defineProperty,on=f((e,t)=>tn(e,"name",{value:t,configurable:!0}),"i$7");const nn=on(e=>({async buildEnd(){const t=[];for(const n of this.getModuleIds()){const r=this.getModuleInfo(n);if(r!=null&&!r.isExternal)for(const s of r.importedIds)t.push({source:n,target:s})}if(Array.isArray(t)&&t.length===0)return;const o=m.resolve(e.rootDir,e.outDir,"graph.json");y.writeJsonSync(o,t)},name:"packem:metafile"}),"metafilePlugin");var rn=Object.defineProperty,sn=f((e,t)=>rn(e,"name",{value:t,configurable:!0}),"r$4");const C=sn(e=>{const t=_t.createHash("md5");return t.update(e),t.digest("hex")},"getHash");var an=Object.defineProperty,ze=f((e,t)=>an(e,"name",{value:t,configurable:!0}),"m$5");const I=ze(e=>e.handler||e,"getHandler"),S=ze((e,t)=>({...e,async buildEnd(o){e.buildEnd&&await I(e.buildEnd).call(this,o)},async buildStart(o){e.buildStart&&await I(e.buildStart).call(this,o)},async load(o){if(!e.load)return null;const n=m.join("load",C(o));if(t.has(n,e.name))return await t.get(n,e.name);const r=await I(e.load).call(this,o);return t.set(n,r,e.name),r},name:`cached(${e.name})`,async resolveId(o,n,r){if(!e.resolveId)return null;const s=m.join("resolveId",C(o),n?C(n):"",C(JSON.stringify(r)));if(t.has(s,e.name))return await t.get(s,e.name);const i=await I(e.resolveId).call(this,o,n,r);return t.set(s,i,e.name),i},async transform(o,n){if(!e.transform)return null;const r=m.join("transform",C(n),C(o));if(t.has(r,e.name))return await t.get(r,e.name);const s=await I(e.transform).call(this,o,n);return t.set(r,s,e.name),s}}),"cachingPlugin");var ln=Object.defineProperty,cn=f((e,t)=>ln(e,"name",{value:t,configurable:!0}),"c$6");const pn=/\.(?:m|c)?(?:j|t)sx?$/,un=/^use \w+$/,dn=cn(e=>{const t={},o={};return{name:"packem:preserve-directives",onLog(n,r){return r.code==="MODULE_LEVEL_DIRECTIVE"&&n==="warn"?!1:null},renderChunk:{handler(n,r,{sourcemap:s}){const i=r.moduleIds.map(a=>t[a]?t[a]:null).reduce((a,u)=>(u&&u.forEach(p=>{a.add(p)}),a),new Set),l=new N(n);i.size>0&&(e.debug({message:`directives for chunk "${r.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),l.prepend(`${[...i].map(a=>`'${a}';`).join(`
41
41
  `)}
42
42
  `));let c=null;return r.facadeModuleId&&typeof o[r.facadeModuleId]=="string"&&(c=o[r.facadeModuleId]),c&&(e.debug({message:`shebang for chunk "${r.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),l.prepend(`${c}
43
- `)),i.size===0&&c===null?null:{code:l.toString(),map:s?l.generateMap({hires:!0}):null}},order:"post"},transform:{handler(n,r){const s=m.extname(r);if(!pn.test(s))return null;let i=!1;const l=new N(n);if(n.startsWith("#")&&n[1]==="!"){let a=0;for(let u=2,p=n.length;u<p;u++){const d=n.codePointAt(u);if(d===10||d===13||d===8232||d===8233){a=u;break}}a&&(o[r]=n.slice(0,a),l.remove(0,a+1),i=!0,e.debug({message:`shebang for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}let c=null;try{c=this.parse(l.toString(),{allowReturnOutsideFunction:!0})}catch(a){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${r}" and extract the directives.`}),e.warn(a),null}if(c.type!=="Program")return null;for(const a of c.body.filter(Boolean)){if(a.type!=="ExpressionStatement")break;let u=null;"directive"in a?u=a.directive:a.expression.type==="Literal"&&typeof a.expression.value=="string"&&un.test(a.expression.value)&&(u=a.expression.value),u!=="use strict"&&u&&(t[r]||=new Set,t[r].add(u),"start"in a&&typeof a.start=="number"&&"end"in a&&typeof a.end=="number"&&(l.remove(a.start,a.end),i=!0),e.debug({message:`directive "${u}" for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}return i?{code:l.toString(),map:l.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[r]??[]],shebang:o[r]??null}}}:null},order:"post"}}},"preserveDirectives");var mn=Object.defineProperty,fn=f((e,t)=>mn(e,"name",{value:t,configurable:!0}),"t$2");const gn=fn(e=>{const t=M.createFilter(e.include,e.exclude);return{name:"packem:raw",transform(o,n){return t(n)?{code:`export default ${JSON.stringify(o)}`,map:null}:null}}},"rawPlugin");var hn=Object.defineProperty,yn=f((e,t)=>hn(e,"name",{value:t,configurable:!0}),"l$4");const Y="\0__file_url__",Ve=yn(()=>({async load(e){if(e.startsWith(Y)){const t=De.fileURLToPath(e.slice(Y.length));return await y.readFile(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${Y}${e}`}}),"resolveFileUrl");var vn=Object.defineProperty,I=f((e,t)=>vn(e,"name",{value:t,configurable:!0}),"r$3");const bn=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,$n=/MIT License|MIT license|BSD license/,jn=/\n{2,}/g,wn=/\b(\w+)\$\d+\b/g,kn=/[-/\\^$*+?.()|[\]{}]/g,En=I(e=>e.replaceAll(kn,"\\$&"),"escapeRegex"),xn=I(e=>[...new Set(e)],"unique"),Sn=I(e=>e.replaceAll(bn,t=>$n.test(t)?"":t).replaceAll(jn,`
43
+ `)),i.size===0&&c===null?null:{code:l.toString(),map:s?l.generateMap({hires:!0}):null}},order:"post"},transform:{handler(n,r){const s=m.extname(r);if(!pn.test(s))return null;let i=!1;const l=new N(n);if(n.startsWith("#")&&n[1]==="!"){let a=0;for(let u=2,p=n.length;u<p;u++){const d=n.codePointAt(u);if(d===10||d===13||d===8232||d===8233){a=u;break}}a&&(o[r]=n.slice(0,a),l.remove(0,a+1),i=!0,e.debug({message:`shebang for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}let c=null;try{c=this.parse(l.toString(),{allowReturnOutsideFunction:!0})}catch(a){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${r}" and extract the directives.`}),e.warn(a),null}if(c.type!=="Program")return null;for(const a of c.body.filter(Boolean)){if(a.type!=="ExpressionStatement")break;let u=null;"directive"in a?u=a.directive:a.expression.type==="Literal"&&typeof a.expression.value=="string"&&un.test(a.expression.value)&&(u=a.expression.value),u!=="use strict"&&u&&(t[r]||=new Set,t[r].add(u),"start"in a&&typeof a.start=="number"&&"end"in a&&typeof a.end=="number"&&(l.remove(a.start,a.end),i=!0),e.debug({message:`directive "${u}" for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}return i?{code:l.toString(),map:l.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[r]??[]],shebang:o[r]??null}}}:null},order:"post"}}},"preserveDirectives");var mn=Object.defineProperty,fn=f((e,t)=>mn(e,"name",{value:t,configurable:!0}),"t$2");const gn=fn(e=>{const t=M.createFilter(e.include,e.exclude);return{name:"packem:raw",transform(o,n){return t(n)?{code:`export default ${JSON.stringify(o)}`,map:null}:null}}},"rawPlugin");var hn=Object.defineProperty,yn=f((e,t)=>hn(e,"name",{value:t,configurable:!0}),"l$4");const Y="\0__file_url__",Ve=yn(()=>({async load(e){if(e.startsWith(Y)){const t=De.fileURLToPath(e.slice(Y.length));return await y.readFile(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${Y}${e}`}}),"resolveFileUrl");var vn=Object.defineProperty,F=f((e,t)=>vn(e,"name",{value:t,configurable:!0}),"r$3");const bn=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,$n=/MIT License|MIT license|BSD license/,jn=/\n{2,}/g,wn=/\b(\w+)\$\d+\b/g,kn=/[-/\\^$*+?.()|[\]{}]/g,En=F(e=>e.replaceAll(kn,"\\$&"),"escapeRegex"),xn=F(e=>[...new Set(e)],"unique"),Sn=F(e=>e.replaceAll(bn,t=>$n.test(t)?"":t).replaceAll(jn,`
44
44
 
45
45
  `),"cleanUnnecessaryComments"),je=new Map;function He(e,t,{identifierReplacements:o},n){const r=W.findStaticImports(e);for(const i in o){const l=r.find(a=>a.specifier===i&&a.imports.includes("{"));if(!l){this.warn(`${t.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const c=o[i];for(const a in c){if(!l.imports.includes(a))throw new Error(`${t.fileName} does not import "${a}" from "${i}" for replacement`);const u=c[a],p=En(a);u.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${p},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${p}\\b`,"g"),u)}}const s=xn(Array.from(e.matchAll(wn),i=>i[0]));if(s.length>0){const i=s.map(c=>`
46
46
  - ${c}`).join(""),l=t.fileName.replace(/\.[^/.]+$/,"");je.has(l)||n.warn({message:`${t.fileName} contains confusing identifier names${i}
47
47
 
48
- To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),je.set(l,!0)}return e}f(He,"I$1");I(He,"replaceConfusingTypeNames");function Ge(e,t){if(t.leadingComments?.some(o=>o.type==="CommentBlock"&&o.value.includes("@internal"))){const o=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,o),!0}return!1}f(Ge,"N");I(Ge,"removeInternal");function Xe(e,t){if(e.includes("@internal")){const o=new N(e),n=Dt.parse(e,{plugins:["typescript"],sourceType:"module"});if(Ue(n,{enter(r){Ge(o,r)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}f(Xe,"S");I(Xe,"stripInternalTypes");const On=I((e,t)=>({name:"packem:patch-types",renderChunk(o,n){return o=He.call(this,o,n,e,t),o=Xe.call(this,o,n),o=Sn(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var _n=Object.defineProperty,Ke=f((e,t)=>_n(e,"name",{value:t,configurable:!0}),"m$3");const Ye=Ke((e,t=!0)=>{if(!e)return null;const{config:o,path:n}=e;if(!o.compilerOptions)return null;const{baseUrl:r,paths:s}=o.compilerOptions;if(!r)return null;const i=m.resolve(m.dirname(n),r),l=[];if(s)for(const[c,a]of Object.entries(s)){let u;c==="@"||c==="~"||c==="#"?u=new RegExp(`^${c}/(.+)$`):u=new RegExp(`^${[...c].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let p=0;for(const d of a){const g=[...M.normalizePath(m.resolve(i,d))].map($=>$==="*"?"$"+(++p+""):$==="$"?"$$":$).join("");l.push({find:u,replacement:g})}}return t&&l.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...M.normalizePath(i)].map(c=>c==="$"?"$$":c).join("")}/$1`}),l},"getConfigAlias"),Qe=Ke((e,t)=>{const o=Ye(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,r,s){if(!o||n.includes("\0"))return null;for(const{find:i,replacement:l}of o)if(i.test(n)){const c=n.replace(i,l),a=await this.resolve(c,r,{skipSelf:!0,...s});if(a)return t.debug({message:`Resolved ${n} to ${a.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),a.id}return null}}},"resolveTsconfigPaths");var Dn=Object.defineProperty,Ze=f((e,t)=>Dn(e,"name",{value:t,configurable:!0}),"u$4");const Nn=Ze((e,t)=>{if(!t)return null;const{config:o,path:n}=t;if(!o.compilerOptions)return null;const{rootDirs:r}=o.compilerOptions;if(!r)return null;const s=[];for(const i of r){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${n}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${n}.`);s.push(m.resolve(e,i))}return s},"getRootDirectories"),et=Ze((e,t,o)=>{const n=Nn(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(r,s,i){if(n===null||n.length===0)return null;if(r.startsWith("."))for(const l of n){const c=m.join(l,r),a=await this.resolve(c,s,{skipSelf:!0,...i});if(a)return t.debug({message:`Resolved ${r} to ${a.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),a.id}return null}}},"resolveTsconfigRootDirectories");var Pn=Object.defineProperty,Cn=f((e,t)=>Pn(e,"name",{value:t,configurable:!0}),"r$2");const tt=Cn(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,o,n){return e.test(t)&&o?await this.resolve(t.replace(/js(x?)$/,"ts$1"),o,n):null}}},"resolveTypescriptMjsCts");var Mn=Object.defineProperty,In=f((e,t)=>Mn(e,"name",{value:t,configurable:!0}),"s$6");const Rn=In(e=>{const t=m.basename(e).split(".");if(t.length>=2){const[o,n]=t.slice(-2),r=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if(b.DEFAULT_EXTENSIONS.includes(n)&&s&&s.length>0)return r+"-"+s}},"getCustomModuleLayer");var Fn=Object.defineProperty,Tn=f((e,t)=>Fn(e,"name",{value:t,configurable:!0}),"i$3");const Q=Tn(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var An=Object.defineProperty,we=f((e,t)=>An(e,"name",{value:t,configurable:!0}),"c$4");const ke=we((e,t)=>{const o=new Map;return we(function(n,r){const s=r.getModuleInfo(n);if(!s)return;const{isEntry:i}=s,l=s.meta,c=Q(l);if(!i){const a=o.get(n);if(a)return a;const u=Rn(n);if(u)return o.set(n,u),u}if(i){const a=r.getModuleIds();for(const u of a)r.getModuleInfo(u)&&Q(l)===c&&(e.has(u)||e.set(u,new Set),e.get(u).add([n,c]))}if(c&&!i&&e.has(n)){const a=[...e.get(n)];if(a.some(([p])=>{if(t.some(d=>d.path===p)){const d=r.getModuleInfo(p);return Q(d?d.meta:{})===c}return!1}))return;if(a.every(([,p])=>p===c))return o.has(n)?o.get(n):void 0;const u=m.basename(n,m.extname(n))+"-"+c;return o.set(n,u),u}},"splitChunks")},"createSplitChunks");var Ln=Object.defineProperty,Jn=f((e,t)=>Ln(e,"name",{value:t,configurable:!0}),"n");const D=Jn((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var qn=Object.defineProperty,Bn=f((e,t)=>qn(e,"name",{value:t,configurable:!0}),"s$4");const Un=process.platform==="win32",Ee=Bn((e,t)=>{const o=Un?"\\":"/";return e.name?.includes("node_modules"+o+".pnpm")?(e.name.replace("node_modules"+o+".pnpm","external")+"."+t).replace("node_modules"+o,""):e.name?.includes("node_modules")?e.name.replace("node_modules","external")+"."+t:"[name]."+t},"getEntryFileNames");var Wn=Object.defineProperty,j=f((e,t)=>Wn(e,"name",{value:t,configurable:!0}),"p$1");const zn=j((e,t)=>{if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");t.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(t.logger.warn(["ES3 target is not supported by esbuild, so ES5 will be used instead..","Please set 'target' option in tsconfig to at least ES5 to disable this error"].join(" ")),t.tsconfig.config.compilerOptions.target="es5",t.options.rollup.esbuild.target="es5");let o="node"+oe.versions.node.split(".")[0];if(t.pkg.engines?.node){const n=Pe.minVersion(t.pkg.engines.node);n&&(o="node"+n.major)}if(t.options.rollup.esbuild.target){const n=F(t.options.rollup.esbuild.target);n.some(r=>r.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...F(o),...n])])}else t.options.rollup.esbuild.target=F(o);return t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{logger:t.logger,minify:t.options.minify,minifyWhitespace:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{toplevel:!0},sourceMap:t.options.sourcemap,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return{...t.options.rollup.sucrase}}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),ot=j((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT")throw new Error(`Failed to resolve the module "${e.exporter}" imported by "${h.cyan(m.relative(m.resolve(),e.id))}"
48
+ To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),je.set(l,!0)}return e}f(He,"I$1");F(He,"replaceConfusingTypeNames");function Ge(e,t){if(t.leadingComments?.some(o=>o.type==="CommentBlock"&&o.value.includes("@internal"))){const o=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,o),!0}return!1}f(Ge,"N");F(Ge,"removeInternal");function Xe(e,t){if(e.includes("@internal")){const o=new N(e),n=Dt.parse(e,{plugins:["typescript"],sourceType:"module"});if(Ue(n,{enter(r){Ge(o,r)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}f(Xe,"S");F(Xe,"stripInternalTypes");const On=F((e,t)=>({name:"packem:patch-types",renderChunk(o,n){return o=He.call(this,o,n,e,t),o=Xe.call(this,o,n),o=Sn(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var _n=Object.defineProperty,Ke=f((e,t)=>_n(e,"name",{value:t,configurable:!0}),"m$3");const Ye=Ke((e,t=!0)=>{if(!e)return null;const{config:o,path:n}=e;if(!o.compilerOptions)return null;const{baseUrl:r,paths:s}=o.compilerOptions;if(!r)return null;const i=m.resolve(m.dirname(n),r),l=[];if(s)for(const[c,a]of Object.entries(s)){let u;c==="@"||c==="~"||c==="#"?u=new RegExp(`^${c}/(.+)$`):u=new RegExp(`^${[...c].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let p=0;for(const d of a){const g=[...M.normalizePath(m.resolve(i,d))].map(v=>v==="*"?"$"+(++p+""):v==="$"?"$$":v).join("");l.push({find:u,replacement:g})}}return t&&l.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...M.normalizePath(i)].map(c=>c==="$"?"$$":c).join("")}/$1`}),l},"getConfigAlias"),Qe=Ke((e,t)=>{const o=Ye(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,r,s){if(!o||n.includes("\0"))return null;for(const{find:i,replacement:l}of o)if(i.test(n)){const c=n.replace(i,l),a=await this.resolve(c,r,{skipSelf:!0,...s});if(a)return t.debug({message:`Resolved ${n} to ${a.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),a.id}return null}}},"resolveTsconfigPaths");var Dn=Object.defineProperty,Ze=f((e,t)=>Dn(e,"name",{value:t,configurable:!0}),"u$4");const Nn=Ze((e,t)=>{if(!t)return null;const{config:o,path:n}=t;if(!o.compilerOptions)return null;const{rootDirs:r}=o.compilerOptions;if(!r)return null;const s=[];for(const i of r){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${n}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${n}.`);s.push(m.resolve(e,i))}return s},"getRootDirectories"),et=Ze((e,t,o)=>{const n=Nn(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(r,s,i){if(n===null||n.length===0)return null;if(r.startsWith("."))for(const l of n){const c=m.join(l,r),a=await this.resolve(c,s,{skipSelf:!0,...i});if(a)return t.debug({message:`Resolved ${r} to ${a.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),a.id}return null}}},"resolveTsconfigRootDirectories");var Pn=Object.defineProperty,Cn=f((e,t)=>Pn(e,"name",{value:t,configurable:!0}),"r$2");const tt=Cn(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,o,n){return e.test(t)&&o?await this.resolve(t.replace(/js(x?)$/,"ts$1"),o,n):null}}},"resolveTypescriptMjsCts");var Mn=Object.defineProperty,Fn=f((e,t)=>Mn(e,"name",{value:t,configurable:!0}),"s$6");const In=Fn(e=>{const t=m.basename(e).split(".");if(t.length>=2){const[o,n]=t.slice(-2),r=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if($.DEFAULT_EXTENSIONS.includes(n)&&s&&s.length>0)return r+"-"+s}},"getCustomModuleLayer");var Rn=Object.defineProperty,Tn=f((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"i$3");const Q=Tn(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var An=Object.defineProperty,we=f((e,t)=>An(e,"name",{value:t,configurable:!0}),"c$4");const ke=we((e,t)=>{const o=new Map;return we(function(n,r){const s=r.getModuleInfo(n);if(!s)return;const{isEntry:i}=s,l=s.meta,c=Q(l);if(!i){const a=o.get(n);if(a)return a;const u=In(n);if(u)return o.set(n,u),u}if(i){const a=r.getModuleIds();for(const u of a)r.getModuleInfo(u)&&Q(l)===c&&(e.has(u)||e.set(u,new Set),e.get(u).add([n,c]))}if(c&&!i&&e.has(n)){const a=[...e.get(n)];if(a.some(([p])=>{if(t.some(d=>d.path===p)){const d=r.getModuleInfo(p);return Q(d?d.meta:{})===c}return!1}))return;if(a.every(([,p])=>p===c))return o.has(n)?o.get(n):void 0;const u=m.basename(n,m.extname(n))+"-"+c;return o.set(n,u),u}},"splitChunks")},"createSplitChunks");var Ln=Object.defineProperty,Jn=f((e,t)=>Ln(e,"name",{value:t,configurable:!0}),"n");const D=Jn((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var qn=Object.defineProperty,Bn=f((e,t)=>qn(e,"name",{value:t,configurable:!0}),"s$4");const Un=process.platform==="win32",Ee=Bn((e,t)=>{const o=Un?"\\":"/";return e.name?.includes("node_modules"+o+".pnpm")?(e.name.replace("node_modules"+o+".pnpm","external")+"."+t).replace("node_modules"+o,""):e.name?.includes("node_modules")?e.name.replace("node_modules","external")+"."+t:"[name]."+t},"getEntryFileNames");var Wn=Object.defineProperty,j=f((e,t)=>Wn(e,"name",{value:t,configurable:!0}),"p$1");const zn=j((e,t)=>{if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");t.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(t.logger.warn(["ES3 target is not supported by esbuild, so ES5 will be used instead..","Please set 'target' option in tsconfig to at least ES5 to disable this error"].join(" ")),t.tsconfig.config.compilerOptions.target="es5",t.options.rollup.esbuild.target="es5");let o="node"+oe.versions.node.split(".")[0];if(t.pkg.engines?.node){const n=Pe.minVersion(t.pkg.engines.node);n&&(o="node"+n.major)}if(t.options.rollup.esbuild.target){const n=R(t.options.rollup.esbuild.target);n.some(r=>r.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...R(o),...n])])}else t.options.rollup.esbuild.target=R(o);return t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{logger:t.logger,minify:t.options.minify,minifyWhitespace:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{toplevel:!0},sourceMap:t.options.sourcemap,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return{...t.options.rollup.sucrase}}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),ot=j((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT")throw new Error(`Failed to resolve the module "${e.exporter}" imported by "${h.cyan(m.relative(m.resolve(),e.id))}"
49
49
  Is the module installed? Note:
50
50
  ↳ to inline a module into your bundle, install it to "devDependencies".
51
51
  ↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MODULE_LEVEL_DIRECTIVE"?!0:e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),xe=new Map,nt=j((e,t,o)=>{const n=j(s=>{for(const[i,l]of Object.entries(t))if(s.startsWith(i))return s.replace(i,l)},"findAlias"),r=Ye(e.tsconfig,!1);return{external(s){const i=n(s);i&&(s=i);const l=Le(s);if(te(e.options.externals,l)||te(e.options.externals,s))return!0;const{pkg:c}=e;if(s.startsWith(".")||m.isAbsolute(s)||/src[/\\]/.test(s)||c.name&&s.startsWith(c.name)||c?.imports?.[s]!==void 0)return!1;if(r){for(const{find:a}of r)if(a.test(s))return e.logger.debug({message:`Resolved alias ${s} to ${a.source}`,prefix:o}),!1}return xe.has(s)||e.logger.info({message:'Inlined implicit external "'+h.cyan(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),xe.set(s,!0),!1},input:Object.fromEntries(e.options.entries.map(s=>[s.name,m.resolve(e.options.rootDir,s.input)])),logLevel:e.options.debug?"debug":"info",onLog:j((s,i)=>{let l=i.message;switch(i.stack&&(l=`${l}
52
- ${i.stack}`),s){case"info":{e.logger.info({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(s,i){ot(s,e)||s.code||i(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),rt=j(async(e,t)=>{const o=re(e,"build");let n;return e.options.rollup.resolve&&(n=x(Ne.nodeResolve({extensions:b.DEFAULT_EXTENSIONS,...e.options.rollup.resolve}),t)),{...nt(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:j(r=>D(e,r,"cjs"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:j(r=>Ee(r,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:ke(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:j(r=>D(e,r,"mjs"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:j(r=>Ee(r,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:ke(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[x(Ve(),t),x(tt(),t),e.tsconfig&&x(et(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&x(Qe(e.tsconfig,e.logger),t),e.options.rollup.replace&&Re({sourcemap:e.options.sourcemap,...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Ie({customResolver:n,...e.options.rollup.alias,entries:o}),n,e.options.rollup.polyfillNode&&Rt({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&Be({...e.options.rollup.json}),dn(e.logger),Jt(e.options.entries.filter(r=>r.executable).map(r=>r.name).filter(Boolean)),e.options.rollup.wsam&&wt.wasm(e.options.rollup.wsam),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&Wo(m.join(e.options.rootDir,e.options.sourceDir))(e.options.isolatedDeclarationTransformer,e.options.rollup.isolatedDeclarations),e.options.transformer?.(zn(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&qe({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Bo(),e.options.rollup.dynamicVars&&It(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&x(Mt({extensions:b.DEFAULT_EXTENSIONS,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&Lo(e.pkg,e.options.rollup.shim),e.options.rollup.raw&&gn(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&Yo({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&nn({outDir:m.resolve(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&Mo(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&We({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.rollup.visualizer&&Et.visualizer({brotliSize:!0,filename:"packem-bundle-analyze.html",gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,title:"Packem Visualizer",...e.options.rollup.visualizer})].filter(Boolean)}},"getRollupOptions"),Vn=j(async e=>{const{dts:t}=require("rollup-plugin-dts");return t({compilerOptions:{...e.options.rollup.dts.compilerOptions,incremental:void 0,inlineSources:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},respectExternal:e.options.rollup.dts.respectExternal,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),Hn=_o(Vn),st=j(async(e,t)=>{const o=re(e,"types"),n={load(l){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(l)?null:""},name:"packem:ignore-files"},r=e.tsconfig?.config.compilerOptions;delete r?.lib;let s;e.options.rollup.resolve&&(s=x(Ne.nodeResolve({extensions:b.DEFAULT_EXTENSIONS,...e.options.rollup.resolve}),t));const i="dts-plugin:"+process.pid+e.tsconfig.path;return{...nt(e,o,"dts"),onwarn(l,c){ot(l,e)||l.code!=="EMPTY_BUNDLE"&&c(l)},output:[e.options.emitCJS&&{chunkFileNames:j(l=>D(e,l,"d.cts"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:j(l=>D(e,l,"d.mts"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.declaration==="compatible"&&{chunkFileNames:j(l=>D(e,l,"d.ts"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[x(Ve(),t),x(tt(),t),e.options.rollup.json&&Be({...e.options.rollup.json}),n,e.tsconfig&&x(et(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&x(Qe(e.tsconfig,e.logger),t),e.options.rollup.replace&&Re({sourcemap:e.options.sourcemap,...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Ie({customResolver:s,...e.options.rollup.alias,entries:o}),s,await Hn(i)(e),e.options.cjsInterop&&e.options.emitCJS&&qe({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&On(e.options.rollup.patchTypes,e.logger),qt(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&We({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var Gn=Object.defineProperty,Xn=f((e,t)=>Gn(e,"name",{value:t,configurable:!0}),"c$3");const Z=Xn(async(e,t)=>{const o=await rt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;const n="rollup-build.json";o.cache=t.get(n);const r=await T.rollup(o);t.set(n,r.cache),await e.hooks.callHook("rollup:build",e,r);const s=new Map;for(const i of o.output){const{output:l}=await r.write(i),c=new Set,a=l.filter(p=>p.type==="chunk");for(const p of a){c.add(p.fileName);for(const d of p.imports)e.usedImports.add(d);p.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(p.code,"utf8"),chunks:p.imports.filter(d=>a.find(g=>g.fileName===d)),exports:p.exports,modules:Object.entries(p.modules).map(([d,g])=>({bytes:g.renderedLength,id:d})),path:p.fileName,type:"entry"})}const u=l.filter(p=>p.type==="asset");for(const p of u)s.has(p.fileName)||s.set(p.fileName,{bytes:Buffer.byteLength(p.source,"utf8"),path:p.fileName,type:"asset"});for(const p of c)e.usedImports.delete(p)}e.buildEntries.push(...s.values())},"build");var Kn=Object.defineProperty,q=f((e,t)=>Kn(e,"name",{value:t,configurable:!0}),"a$5");const B=q(async(e,t)=>{if(e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer){e.logger.debug({message:"Skipping declaration file generation as isolated declaration transformer is enabled.",prefix:"dts"});return}const o=await st(e,t);if(await e.hooks.callHook("rollup:dts:options",e,o),Object.keys(o.input).length===0)return;const n="rollup-dts.json";o.cache=t.get(n);const r=await T.rollup(o);t.set(n,r.cache),await e.hooks.callHook("rollup:dts:build",e,r),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await r.write({chunkFileNames:q(s=>D(e,s,"d.cts"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await r.write({chunkFileNames:q(s=>D(e,s,"d.mts"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),e.options.declaration==="compatible"&&await r.write({chunkFileNames:q(s=>D(e,s,"d.cjs"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var Yn=Object.defineProperty,le=f((e,t)=>Yn(e,"name",{value:t,configurable:!0}),"i$1");const Qn=le(e=>{const{message:t,name:o="Error",stack:n}=e;if(!n)return n;const r=`${o}: ${t}
52
+ ${i.stack}`),s){case"info":{e.logger.info({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(s,i){ot(s,e)||s.code||i(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),rt=j(async(e,t)=>{const o=re(e,"build");let n;return e.options.rollup.resolve&&(n=S(Ne.nodeResolve({extensions:$.DEFAULT_EXTENSIONS,...e.options.rollup.resolve}),t)),{...nt(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:j(r=>D(e,r,"cjs"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:j(r=>Ee(r,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:ke(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:j(r=>D(e,r,"mjs"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:j(r=>Ee(r,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:ke(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[S(Ve(),t),S(tt(),t),e.tsconfig&&S(et(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&S(Qe(e.tsconfig,e.logger),t),e.options.rollup.replace&&Ie({sourcemap:e.options.sourcemap,...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Fe({customResolver:n,...e.options.rollup.alias,entries:o}),n,e.options.rollup.polyfillNode&&It({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&Be({...e.options.rollup.json}),dn(e.logger),Jt(e.options.entries.filter(r=>r.executable).map(r=>r.name).filter(Boolean)),e.options.rollup.wsam&&wt.wasm(e.options.rollup.wsam),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&Wo(m.join(e.options.rootDir,e.options.sourceDir))(e.options.isolatedDeclarationTransformer,e.options.rollup.isolatedDeclarations),e.options.transformer?.(zn(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&qe({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Bo(),e.options.rollup.dynamicVars&&Ft(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&S(Mt({extensions:$.DEFAULT_EXTENSIONS,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&Lo(e.pkg,e.options.rollup.shim),e.options.rollup.raw&&gn(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&Yo({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&nn({outDir:m.resolve(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&Mo(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&We({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.rollup.visualizer&&Et.visualizer({brotliSize:!0,filename:"packem-bundle-analyze.html",gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,title:"Packem Visualizer",...e.options.rollup.visualizer})].filter(Boolean)}},"getRollupOptions"),Vn=j(async e=>{const{dts:t}=require("rollup-plugin-dts");return t({compilerOptions:{...e.options.rollup.dts.compilerOptions,incremental:void 0,inlineSources:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},respectExternal:e.options.rollup.dts.respectExternal,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),Hn=_o(Vn),st=j(async(e,t)=>{const o=re(e,"types"),n={load(l){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(l)?null:""},name:"packem:ignore-files"},r=e.tsconfig?.config.compilerOptions;delete r?.lib;let s;e.options.rollup.resolve&&(s=S(Ne.nodeResolve({extensions:$.DEFAULT_EXTENSIONS,...e.options.rollup.resolve}),t));const i="dts-plugin:"+process.pid+e.tsconfig.path;return{...nt(e,o,"dts"),onwarn(l,c){ot(l,e)||l.code!=="EMPTY_BUNDLE"&&c(l)},output:[e.options.emitCJS&&{chunkFileNames:j(l=>D(e,l,"d.cts"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:j(l=>D(e,l,"d.mts"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.declaration==="compatible"&&{chunkFileNames:j(l=>D(e,l,"d.ts"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[S(Ve(),t),S(tt(),t),e.options.rollup.json&&Be({...e.options.rollup.json}),n,e.tsconfig&&S(et(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&S(Qe(e.tsconfig,e.logger),t),e.options.rollup.replace&&Ie({sourcemap:e.options.sourcemap,...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Fe({customResolver:s,...e.options.rollup.alias,entries:o}),s,await Hn(i)(e),e.options.cjsInterop&&e.options.emitCJS&&qe({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&On(e.options.rollup.patchTypes,e.logger),qt(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&We({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var Gn=Object.defineProperty,Xn=f((e,t)=>Gn(e,"name",{value:t,configurable:!0}),"c$3");const Z=Xn(async(e,t)=>{const o=await rt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;const n="rollup-build.json";o.cache=t.get(n);const r=await T.rollup(o);t.set(n,r.cache),await e.hooks.callHook("rollup:build",e,r);const s=new Map;for(const i of o.output){const{output:l}=await r.write(i),c=new Set,a=l.filter(p=>p.type==="chunk");for(const p of a){c.add(p.fileName);for(const d of p.imports)e.usedImports.add(d);p.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(p.code,"utf8"),chunks:p.imports.filter(d=>a.find(g=>g.fileName===d)),exports:p.exports,modules:Object.entries(p.modules).map(([d,g])=>({bytes:g.renderedLength,id:d})),path:p.fileName,type:"entry"})}const u=l.filter(p=>p.type==="asset");for(const p of u)s.has(p.fileName)||s.set(p.fileName,{bytes:Buffer.byteLength(p.source,"utf8"),path:p.fileName,type:"asset"});for(const p of c)e.usedImports.delete(p)}e.buildEntries.push(...s.values())},"build");var Kn=Object.defineProperty,q=f((e,t)=>Kn(e,"name",{value:t,configurable:!0}),"a$5");const B=q(async(e,t)=>{if(e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer){e.logger.debug({message:"Skipping declaration file generation as isolated declaration transformer is enabled.",prefix:"dts"});return}const o=await st(e,t);if(await e.hooks.callHook("rollup:dts:options",e,o),Object.keys(o.input).length===0)return;const n="rollup-dts.json";o.cache=t.get(n);const r=await T.rollup(o);t.set(n,r.cache),await e.hooks.callHook("rollup:dts:build",e,r),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await r.write({chunkFileNames:q(s=>D(e,s,"d.cts"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await r.write({chunkFileNames:q(s=>D(e,s,"d.mts"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),e.options.declaration==="compatible"&&await r.write({chunkFileNames:q(s=>D(e,s,"d.cjs"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var Yn=Object.defineProperty,le=f((e,t)=>Yn(e,"name",{value:t,configurable:!0}),"i$1");const Qn=le(e=>{const{message:t,name:o="Error",stack:n}=e;if(!n)return n;const r=`${o}: ${t}
53
53
  `;return n.startsWith(r)?n.slice(r.length):n},"extractStack"),Zn=le(e=>`
54
54
  ${e.replaceAll(/^\n|\n$/g,"")}
55
55
  `,"normalizeCodeFrame"),it=le(e=>{const t=Qn(e);let o=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(o+=`
56
56
  file: ${h.cyan(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(o+=`
57
57
  `+h.yellow(Zn(e.frame))),e.message=o,t!==void 0&&(e.stack=`${e.message}
58
58
  ${t}`)},"enhanceRollupError");var er=Object.defineProperty,at=f((e,t)=>er(e,"name",{value:t,configurable:!0}),"l$3");const Se=at((e,t,o)=>{const n="watcher:"+t;e.on("change",(r,{event:s})=>{o.info({message:`${h.cyan(m.relative(".",r))} was ${s}d`,prefix:n})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:n})}),e.on("event",async r=>{switch(r.code){case"END":{o.success({message:"Rebuild "+t+" finished",prefix:n});break}case"BUNDLE_START":{o.info({message:h.cyan("build started..."),prefix:n});break}case"BUNDLE_END":{await r.result.close(),o.info({message:h.cyan(`built in ${r.duration+""}ms.`),prefix:n});break}case"ERROR":{it(r.error),o.error({context:[r.error],message:"Rebuild "+t+" failed: "+r.error.message,prefix:n});break}}})},"watchHandler"),tr=at(async(e,t)=>{const o=await rt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;o.cache=t.get("rollup-watch"),typeof o.watch=="object"&&o.watch.include===void 0&&(o.watch.include=[m.join(e.options.sourceDir,"**")],o.watch.chokidar={cwd:e.options.rootDir,...o.watch.chokidar});const n=T.watch(o);await e.hooks.callHook("rollup:watch",e,n);const r=[...Array.isArray(o.input)?o.input:typeof o.input=="string"?[o.input]:Object.keys(o.input??{})];let s="Starting watchers for entries:";for(const i of r)s+=h.gray(`
59
- └─ ${m.relative(process.cwd(),i)}`);if(e.logger.info(s),Se(n,"bundle",e.logger),e.options.declaration){const i=await st(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 or=Object.defineProperty,nr=f((e,t)=>or(e,"name",{value:t,configurable:!0}),"a$3");class rr{static{f(this,"p")}static{nr(this,"FileCache")}#n;#e;#r;#t=!0;#o=new Map;#s;constructor(t,o,n){this.#n=t,this.#e=Nt.findCacheDirSync("@visulima/packem",{cwd:t}),this.#r=o,this.#s=n,this.#e===void 0?n.debug("Could not create cache directory."):n.debug(`Cache path is: ${this.#e}`)}set isEnabled(t){this.#t=t}get cachePath(){return this.#e}has(t,o){return!this.#t||this.#e===void 0?!1:y.isAccessibleSync(this.getFilePath(t,o))}get(t,o){if(!this.#t||this.#e===void 0)return;const n=this.getFilePath(t,o);if(this.#o.has(n))return this.#o.get(n);if(!y.isAccessibleSync(n))return;const r=y.readFileSync(n);try{const s=JSON.parse(r);return this.#o.set(n,s),s}catch{this.#s.warn(`Could not parse cache file: ${n}, deleting the broken cache file.`),this.#o.delete(n),H.rmSync(n,{force:!0});return}}set(t,o,n){if(!this.#t||this.#e===void 0||o===void 0)return;const r=this.getFilePath(t,n);typeof o=="object"&&(o=JSON.stringify(o)),y.writeFileSync(r,o,{overwrite:!0})}getFilePath(t,o){let n=t.replaceAll(m.toNamespacedPath(this.#n),"");return n=n.replaceAll(":","-"),m.join(this.#e,this.#r,o?.replaceAll(":","-")??"",m.toNamespacedPath(n))}}var sr=Object.defineProperty,U=f((e,t)=>sr(e,"name",{value:t,configurable:!0}),"l$2");const ir=M.createFilter,ar=U((e,t)=>{const{sideEffects:o}=t;let n;if(typeof o=="boolean")n=U(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)n=U(()=>!1,"hasSideEffects");else{const r=o.map(s=>s.includes("/")?s:`**/${s}`);n=ir(r,null,{resolve:e})}else n=U(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var lr=Object.defineProperty,cr=f((e,t)=>lr(e,"name",{value:t,configurable:!0}),"y");const pr=cr((e,t,o)=>e.reduce((n,r)=>{const s=r[t],i=r[o];return n[s]||(n[s]={}),n[s][i]||(n[s][i]=[]),n[s][i].push(r),n},{}),"groupByKeys");var ur=Object.defineProperty,lt=f((e,t)=>ur(e,"name",{value:t,configurable:!0}),"r");const dr=lt(e=>e.replace(/\.(?:js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension"),mr=lt(async(e,t)=>{e.options.entries=e.options.entries.map(n=>typeof n=="string"?{input:n,isGlob:fe(n)}:{...n,isGlob:fe(n.input)});const o=[];for(const n of e.options.entries.filter(r=>r.isGlob)){const{isGlob:r,...s}=n,i=Ce.globSync([s.input],{cwd:e.options.rootDir,dot:!1,ignore:["**/node_modules/**"],onlyFiles:!0});if(i.length===0)throw new ue.NotFoundError("No files found in the glob pattern: "+h.cyan(m.join(e.options.rootDir,s.input)));for(const l of i)e.options.entries.push({...s,input:m.resolve(e.options.rootDir,l)});e.options.entries.splice(e.options.entries.indexOf(n),1)}for await(const n of e.options.entries){if(typeof n.name!="string"){let r=m.isAbsolute(n.input)?m.relative(t,n.input):m.normalize(n.input);r.startsWith("./")&&(r=r.slice(2)),n.name=dr(r.replace(new RegExp(`^${e.options.sourceDir}/`),"")),n.fileAlias&&o.push({...n,name:n.name+"."+n.environment})}if(!n.input)throw new Error(`Missing entry input: ${se(n)}`);if(n.input=m.resolve(e.options.rootDir,n.input),e.options.declaration&&n.declaration===void 0&&(n.declaration=e.options.declaration),e.options.emitCJS!==void 0&&n.cjs===void 0&&(n.cjs=e.options.emitCJS),e.options.emitESM!==void 0&&n.esm===void 0&&(n.esm=e.options.emitESM),!y.isAccessibleSync(n.input)){const r=new Set(await V.readdir(m.dirname(n.input)));let s=!1;for(const i of b.DEFAULT_EXTENSIONS)if(r.has(m.basename(n.input)+i)){s=!0;break}if(!s)throw new ue.NotFoundError("Your configured entry: "+h.cyan(n.input)+" does not exist.")}n.outDir=m.resolve(e.options.rootDir,n.outDir??e.options.outDir)}e.options.entries.push(...o)},"prepareEntries");var fr=Object.defineProperty,gr=f((e,t)=>fr(e,"name",{value:t,configurable:!0}),"a$2");const hr=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,yr=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"]),Oe=gr(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(hr.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(yr.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const n=m.resolve(o);if(!y.isAccessibleSync(n))throw new Error(`Target path "${n}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var vr=Object.defineProperty,br=f((e,t)=>vr(e,"name",{value:t,configurable:!0}),"o");const $r=br(e=>{const t=new Set,o=new Set(Object.keys(e.pkg?.dependencies??{})),n=new Set;for(const r of e.usedImports)o.delete(r),t.add(r);if(e.pkg?.dependencies)for(const r of Object.keys(e.pkg?.dependencies))o.delete(r);for(const r of t){const s=Le(r);!te(e.options.externals,r)&&!r.startsWith("chunks/")&&e.pkg?.dependencies?.[s]===void 0&&e.pkg?.peerDependencies?.[s]===void 0&&n.add(r)}o.size>0&&A(e,`Potential unused dependencies found: ${[...o].map(r=>h.cyan(r)).join(", ")}`),n.size>0&&A(e,`Potential implicit dependencies found: ${[...n].map(r=>h.cyan(r)).join(", ")}`)},"validateDependencies");var jr=Object.defineProperty,ct=f((e,t)=>jr(e,"name",{value:t,configurable:!0}),"i");const wr=ct((e,t)=>Ct.distance(e,t)<=e.length/3||t.includes(e),"isSimilar"),kr=ct((e,t)=>{const o=e.toLowerCase();return t.filter(n=>wr(n.toLowerCase(),o))},"findAlternatives");var Er=Object.defineProperty,_e=f((e,t)=>Er(e,"name",{value:t,configurable:!0}),"s");const xr=_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:"",...ie(e.exports,e.type==="module"?"esm":"cjs",t.options.declaration).map(r=>r.file)].map(r=>r&&m.resolve(t.options.rootDir,r.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const r of o)r&&!r.includes("*")&&!H.existsSync(r)&&n.push(r.replace(`${t.options.rootDir}/`,""));if(n.length>0){const r=_e(l=>m.relative(t.options.rootDir,m.resolve(t.options.outDir,l)),"rPath"),s=t.buildEntries.filter(l=>!l.chunk).map(l=>r(l.path));let i="Potential missing or wrong package.json files:";for(const l of n){const c=kr(l,s);i+=`
60
- - `+h.cyan(l)+(c.length>0?h.grey` (did you mean ${c.map(a=>`"${a}"`).join(", ")}?)`:"")}A(t,i)}},"validatePackage");var Sr=Object.defineProperty,w=f((e,t)=>Sr(e,"name",{value:t,configurable:!0}),"h");const pt=w((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
59
+ └─ ${m.relative(process.cwd(),i)}`);if(e.logger.info(s),Se(n,"bundle",e.logger),e.options.declaration){const i=await st(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 or=Object.defineProperty,nr=f((e,t)=>or(e,"name",{value:t,configurable:!0}),"a$3");class rr{static{f(this,"p")}static{nr(this,"FileCache")}#n;#e;#r;#t=!0;#o=new Map;#s;constructor(t,o,n){this.#n=t,this.#e=Nt.findCacheDirSync("@visulima/packem",{cwd:t}),this.#r=o,this.#s=n,this.#e===void 0?n.debug("Could not create cache directory."):n.debug(`Cache path is: ${this.#e}`)}set isEnabled(t){this.#t=t}get cachePath(){return this.#e}has(t,o){return!this.#t||this.#e===void 0?!1:y.isAccessibleSync(this.getFilePath(t,o))}get(t,o){if(!this.#t||this.#e===void 0)return;const n=this.getFilePath(t,o);if(this.#o.has(n))return this.#o.get(n);if(!y.isAccessibleSync(n))return;const r=y.readFileSync(n);try{const s=JSON.parse(r);return this.#o.set(n,s),s}catch{this.#s.warn(`Could not parse cache file: ${n}, deleting the broken cache file.`),this.#o.delete(n),H.rmSync(n,{force:!0});return}}set(t,o,n){if(!this.#t||this.#e===void 0||o===void 0)return;const r=this.getFilePath(t,n);typeof o=="object"&&(o=JSON.stringify(o)),y.writeFileSync(r,o,{overwrite:!0})}getFilePath(t,o){let n=t.replaceAll(m.toNamespacedPath(this.#n),"");return n=n.replaceAll(":","-"),m.join(this.#e,this.#r,o?.replaceAll(":","-")??"",m.toNamespacedPath(n))}}var sr=Object.defineProperty,U=f((e,t)=>sr(e,"name",{value:t,configurable:!0}),"l$2");const ir=M.createFilter,ar=U((e,t)=>{const{sideEffects:o}=t;let n;if(typeof o=="boolean")n=U(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)n=U(()=>!1,"hasSideEffects");else{const r=o.map(s=>s.includes("/")?s:`**/${s}`);n=ir(r,null,{resolve:e})}else n=U(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var lr=Object.defineProperty,cr=f((e,t)=>lr(e,"name",{value:t,configurable:!0}),"y");const pr=cr((e,t,o)=>e.reduce((n,r)=>{const s=r[t],i=r[o];return n[s]||(n[s]={}),n[s][i]||(n[s][i]=[]),n[s][i].push(r),n},{}),"groupByKeys");var ur=Object.defineProperty,lt=f((e,t)=>ur(e,"name",{value:t,configurable:!0}),"r");const dr=lt(e=>e.replace(/\.(?:js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension"),mr=lt(async(e,t)=>{e.options.entries=e.options.entries.map(n=>typeof n=="string"?{input:n,isGlob:fe(n)}:{...n,isGlob:fe(n.input)});const o=[];for(const n of e.options.entries.filter(r=>r.isGlob)){const{isGlob:r,...s}=n,i=Ce.globSync([s.input],{cwd:e.options.rootDir,dot:!1,ignore:["**/node_modules/**"],onlyFiles:!0});if(i.length===0)throw new ue.NotFoundError("No files found in the glob pattern: "+h.cyan(m.join(e.options.rootDir,s.input)));for(const l of i)e.options.entries.push({...s,input:m.resolve(e.options.rootDir,l)});e.options.entries.splice(e.options.entries.indexOf(n),1)}for await(const n of e.options.entries){if(typeof n.name!="string"){let r=m.isAbsolute(n.input)?m.relative(t,n.input):m.normalize(n.input);r.startsWith("./")&&(r=r.slice(2)),n.name=dr(r.replace(new RegExp(`^${e.options.sourceDir}/`),"")),n.fileAlias&&o.push({...n,name:n.name+"."+n.environment})}if(!n.input)throw new Error(`Missing entry input: ${se(n)}`);if(n.input=m.resolve(e.options.rootDir,n.input),e.options.declaration&&n.declaration===void 0&&(n.declaration=e.options.declaration),e.options.emitCJS!==void 0&&n.cjs===void 0&&(n.cjs=e.options.emitCJS),e.options.emitESM!==void 0&&n.esm===void 0&&(n.esm=e.options.emitESM),!y.isAccessibleSync(n.input)){const r=new Set(await V.readdir(m.dirname(n.input)));let s=!1;for(const i of $.DEFAULT_EXTENSIONS)if(r.has(m.basename(n.input)+i)){s=!0;break}if(!s)throw new ue.NotFoundError("Your configured entry: "+h.cyan(n.input)+" does not exist.")}n.outDir=m.resolve(e.options.rootDir,n.outDir??e.options.outDir)}e.options.entries.push(...o)},"prepareEntries");var fr=Object.defineProperty,gr=f((e,t)=>fr(e,"name",{value:t,configurable:!0}),"a$2");const hr=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,yr=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"]),Oe=gr(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(hr.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(yr.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const n=m.resolve(o);if(!y.isAccessibleSync(n))throw new Error(`Target path "${n}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var vr=Object.defineProperty,br=f((e,t)=>vr(e,"name",{value:t,configurable:!0}),"o");const $r=br(e=>{const t=new Set,o=new Set(Object.keys(e.pkg?.dependencies??{})),n=new Set;for(const r of e.usedImports)o.delete(r),t.add(r);if(e.pkg?.dependencies)for(const r of Object.keys(e.pkg?.dependencies))o.delete(r);for(const r of t){const s=Le(r);!te(e.options.externals,r)&&!r.startsWith("chunks/")&&e.pkg?.dependencies?.[s]===void 0&&e.pkg?.peerDependencies?.[s]===void 0&&n.add(r)}o.size>0&&A(e,`Potential unused dependencies found: ${[...o].map(r=>h.cyan(r)).join(", ")}`),n.size>0&&A(e,`Potential implicit dependencies found: ${[...n].map(r=>h.cyan(r)).join(", ")}`)},"validateDependencies");var jr=Object.defineProperty,ct=f((e,t)=>jr(e,"name",{value:t,configurable:!0}),"i");const wr=ct((e,t)=>Ct.distance(e,t)<=e.length/3||t.includes(e),"isSimilar"),kr=ct((e,t)=>{const o=e.toLowerCase();return t.filter(n=>wr(n.toLowerCase(),o))},"findAlternatives");var Er=Object.defineProperty,_e=f((e,t)=>Er(e,"name",{value:t,configurable:!0}),"s");const xr=_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:"",...ie(e.exports,e.type==="module"?"esm":"cjs",t.options.declaration).map(r=>r.file)].map(r=>r&&m.resolve(t.options.rootDir,r.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const r of o)r&&!r.includes("*")&&!H.existsSync(r)&&n.push(r.replace(`${t.options.rootDir}/`,""));if(n.length>0){const r=_e(l=>m.relative(t.options.rootDir,m.resolve(t.options.outDir,l)),"rPath"),s=t.buildEntries.filter(l=>!l.chunk).map(l=>r(l.path));let i="Potential missing or wrong package.json files:";for(const l of n){const c=kr(l,s);i+=`
60
+ - `+h.cyan(l)+(c.length>0?h.grey` (did you mean ${c.map(a=>`"${a}"`).join(", ")}?)`:"")}A(t,i)}},"validatePackage");var Sr=Object.defineProperty,k=f((e,t)=>Sr(e,"name",{value:t,configurable:!0}),"g");const pt=k((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
61
61
  `),e.logger.warn(`Build is done with some warnings:
62
62
 
63
63
  ${[...e.warnings].map(o=>`- ${o}`).join(`
64
- `)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logErrors"),Or=w(e=>{switch(e){case"preserve":case"react-native":return"preserve";case"react":return"transform";case"react-jsx":case"react-jsxdev":return"automatic";default:return}},"resolveTsconfigJsxToJsxRuntime"),_r=w((e,t,o,n,r,s,i,l,c,a)=>{const u=Or(a?.config.compilerOptions?.jsx),p=ft.defu(i,s,l,{alias:{},clean:!0,debug:r,declaration:void 0,emitCJS:void 0,emitESM:void 0,entries:[],externals:[...me.builtinModules,...me.builtinModules.map(d=>`node:${d}`)],failOnWarn:!0,fileCache:!0,minify:n===b.PRODUCTION_ENV,name:(c.name??"").split("/").pop()??"default",outDir:"dist",replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:a?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,moduleResolution:100,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},esbuild:{charset:"utf8",include:/\.[jt]sx?$/,jsx:u,jsxDev:a?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:a?.config.compilerOptions?.jsxFactory,jsxFragment:a?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:a?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,sourcesContent:!1,target:a?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:a?.config},isolatedDeclarations:{exclude:b.EXCLUDE_REGEXP,ignoreErrors:!1,include:[/\.[cm]?ts$/]},json:{preferConst:!0},license:{dependenciesTemplate:w((d,g,$)=>`
64
+ `)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logErrors"),Or=k(e=>{switch(e){case"preserve":case"react-native":return"preserve";case"react":return"transform";case"react-jsx":case"react-jsxdev":return"automatic";default:return}},"resolveTsconfigJsxToJsxRuntime"),_r=k((e,t,o,n,r,s,i,l,c,a)=>{const u=Or(a?.config.compilerOptions?.jsx),p=ft.defu(i,s,l,{alias:{},clean:!0,debug:r,declaration:void 0,emitCJS:void 0,emitESM:void 0,entries:[],externals:[...me.builtinModules,...me.builtinModules.map(d=>`node:${d}`)],failOnWarn:!0,fileCache:!0,minify:n===$.PRODUCTION_ENV,name:(c.name??"").split("/").pop()??"default",outDir:"dist",replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:a?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,moduleResolution:100,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},esbuild:{charset:"utf8",include:/\.[jt]sx?$/,jsx:u,jsxDev:a?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:a?.config.compilerOptions?.jsxFactory,jsxFragment:a?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:a?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,sourcesContent:!1,target:a?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:a?.config},isolatedDeclarations:{exclude:$.EXCLUDE_REGEXP,ignoreErrors:!1,include:[/\.[cm]?ts$/]},json:{preferConst:!0},license:{dependenciesTemplate:k((d,g,v)=>`
65
65
  # Licenses of bundled dependencies
66
- The published ${$} artifact additionally contains code with the following licenses:
66
+ The published ${v} artifact additionally contains code with the following licenses:
67
67
  `+(d.length>0?`${d.join(", ")}
68
68
 
69
69
  `:`
70
70
  `)+`# Bundled dependencies:
71
- `+g,"dependenciesTemplate"),dtsTemplate:w((d,g,$)=>`
71
+ `+g,"dependenciesTemplate"),dtsTemplate:k((d,g,v)=>`
72
72
  # Licenses of bundled types
73
- The published ${$} artifact additionally contains code with the following licenses:
73
+ The published ${v} artifact additionally contains code with the following licenses:
74
74
  `+(d.length>0?`${d.join(", ")}
75
75
 
76
76
  `:`
77
77
  `)+`# Bundled types:
78
- `+g,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:b.EXCLUDE_REGEXP,include:[/\.(md|txt|css|htm|html|data)$/]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:{exclude:[/node_modules/],include:[/\.(js|cjs|mjs|tsx|mts|cts)$/]},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:a?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:n===b.PRODUCTION_ENV,...a?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(a.config.compilerOptions.jsx)?{jsxFragmentPragma:a.config.compilerOptions.jsxFragmentFactory,jsxImportSource:a.config.compilerOptions.jsxImportSource,jsxPragma:a.config.compilerOptions.jsxFactory,jsxRuntime:u,transforms:["typescript","jsx",...a.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...a?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:/\.[jt]sx?$/,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:a?.config.compilerOptions?.experimentalDecorators,syntax:a?"typescript":"ecmascript",[a?"tsx":"jsx"]:!0},target:a?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:a?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:a?.config.compilerOptions?.experimentalDecorators,react:{development:n!==b.PRODUCTION_ENV,pragma:a?.config.compilerOptions?.jsxFactory,pragmaFrag:a?.config.compilerOptions?.jsxFragmentFactory,runtime:u,throwIfNamespace:!0},treatConstEnumAsEnum:a?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:a?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"},transform:{decoratorVersion:"2022-03"}},treeshake:{moduleSideEffects:ar(t,c),preset:"recommended"},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:b.EXCLUDE_REGEXP}},rootDir:t,sourceDir:"src",sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!p.transformerName){const d=new Map([...Object.entries(c.dependencies??{}),...Object.entries(c.devDependencies??{})]);let g="0.0.0";if(d.has("esbuild"))p.transformerName="esbuild",g=d.get("esbuild");else if(d.has("@swc/core"))p.transformerName="swc",g=d.get("@swc/core");else if(d.has("sucrase"))p.transformerName="sucrase",g=d.get("sucrase");else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info("Using "+h.cyan("rollup ")+T.VERSION),e.info({message:"Using "+h.cyan(p.transformerName)+" "+g,prefix:"transformer"})}return p.rollup.resolve&&p.rollup.resolve.preferBuiltins===!0&&(p.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),c.dependencies&&p.externals.push(...Object.keys(c.dependencies)),c.peerDependencies&&p.externals.push(...Object.keys(c.peerDependencies)),c.optionalDependencies&&p.externals.push(...Object.keys(c.optionalDependencies)),Oe(p.alias),p.rollup.alias&&p.rollup.alias.entries&&Oe(p.rollup.alias.entries),p},"generateOptions"),Dr=w((e,t,o)=>{const n=w(s=>m.relative(t.options.rootDir,m.resolve(t.options.outDir,s)),"rPath");let r=!1;for(const s of t.buildEntries.filter(i=>!i.chunk)){let i=s.bytes??0;for(const c of s.chunks??[])i+=t.buildEntries.find(a=>a.path===c)?.bytes??0;let l=` ${h.bold(n(s.path))} (${["total size: "+h.cyan(_.formatBytes(i)),s.type!=="asset"&&s.bytes&&"chunk size: "+h.cyan(_.formatBytes(s.bytes))].filter(Boolean).join(", ")})`;if(l+=s.exports?.length?`
78
+ `+g,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:$.EXCLUDE_REGEXP,include:[/\.(md|txt|css|htm|html|data)$/]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:{exclude:[/node_modules/],include:[/\.(js|cjs|mjs|tsx|mts|cts)$/]},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:a?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:n===$.PRODUCTION_ENV,...a?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(a.config.compilerOptions.jsx)?{jsxFragmentPragma:a.config.compilerOptions.jsxFragmentFactory,jsxImportSource:a.config.compilerOptions.jsxImportSource,jsxPragma:a.config.compilerOptions.jsxFactory,jsxRuntime:u,transforms:["typescript","jsx",...a.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...a?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:/\.[jt]sx?$/,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:a?.config.compilerOptions?.experimentalDecorators,syntax:a?"typescript":"ecmascript",[a?"tsx":"jsx"]:!0},target:a?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:a?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:a?.config.compilerOptions?.experimentalDecorators,react:{development:n!==$.PRODUCTION_ENV,pragma:a?.config.compilerOptions?.jsxFactory,pragmaFrag:a?.config.compilerOptions?.jsxFragmentFactory,runtime:u,throwIfNamespace:!0},treatConstEnumAsEnum:a?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:a?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"},transform:{decoratorVersion:"2022-03"}},treeshake:{moduleSideEffects:ar(t,c),preset:"recommended"},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:$.EXCLUDE_REGEXP}},rootDir:t,sourceDir:"src",sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!p.transformerName){const d=new Map([...Object.entries(c.dependencies??{}),...Object.entries(c.devDependencies??{})]);let g="0.0.0";if(d.has("esbuild"))p.transformerName="esbuild",g=d.get("esbuild");else if(d.has("@swc/core"))p.transformerName="swc",g=d.get("@swc/core");else if(d.has("sucrase"))p.transformerName="sucrase",g=d.get("sucrase");else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info("Using "+h.cyan("rollup ")+T.VERSION),e.info({message:"Using "+h.cyan(p.transformerName)+" "+g,prefix:"transformer"})}return p.rollup.resolve&&p.rollup.resolve.preferBuiltins===!0&&(p.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),c.dependencies&&p.externals.push(...Object.keys(c.dependencies)),c.peerDependencies&&p.externals.push(...Object.keys(c.peerDependencies)),c.optionalDependencies&&p.externals.push(...Object.keys(c.optionalDependencies)),Oe(p.alias),p.rollup.alias&&p.rollup.alias.entries&&Oe(p.rollup.alias.entries),p},"generateOptions"),Dr=k((e,t,o)=>{const n=k(s=>m.relative(t.options.rootDir,m.resolve(t.options.outDir,s)),"rPath");let r=!1;for(const s of t.buildEntries.filter(i=>!i.chunk)){let i=s.bytes??0;for(const c of s.chunks??[])i+=t.buildEntries.find(a=>a.path===c)?.bytes??0;let l=` ${h.bold(n(s.path))} (${["total size: "+h.cyan(_.formatBytes(i)),s.type!=="asset"&&s.bytes&&"chunk size: "+h.cyan(_.formatBytes(s.bytes))].filter(Boolean).join(", ")})`;if(l+=s.exports?.length?`
79
79
  exports: `+h.gray(s.exports.join(", ")):"",s.chunks?.length&&(l+=`
80
80
  ${s.chunks.map(c=>{const a=t.buildEntries.find(u=>u.path===c)??{};return h.gray(" └─ "+n(c)+h.bold(a.bytes?" ("+_.formatBytes(a?.bytes)+")":""))}).join(`
81
81
  `)}`),s.modules&&s.modules.length>0){const c=s.modules.filter(a=>a.id.includes("node_modules")).sort((a,u)=>(u.bytes||0)-(a.bytes||0)).map(a=>h.gray(" 📦 "+n(a.id)+h.bold(a.bytes?" ("+_.formatBytes(a.bytes)+")":""))).join(`
@@ -88,11 +88,11 @@ ${s.chunks.map(c=>{const a=t.buildEntries.find(u=>u.path===c)??{};return h.gray(
88
88
  types: `+h.bold(n(u.path))+" (total size: "+h.cyan(_.formatBytes(u.bytes??0))+")"}}r=!0,l+=`
89
89
 
90
90
  `,e.raw(s.chunk?h.gray(l):l)}return r&&e.raw("Σ Total dist size (byte size):",h.cyan(_.formatBytes(t.buildEntries.reduce((s,i)=>s+(i.bytes??0),0))),`
91
- `),r},"showSizeInformation"),Nr=w(async(e,t,o,n,r,s,i,l,c)=>{const a=bo(i.preset??s.preset??"auto",t),u=_r(e,t,o,n,r,s,i,a,l,c);y.ensureDirSync(m.join(u.rootDir,u.outDir));const p={buildEntries:[],dependencyGraphMap:new Map,environment:n,hooks:gt.createHooks(),logger:e,mode:o,options:u,pkg:l,tsconfig:c,usedImports:new Set,warnings:new Set};return a.hooks&&p.hooks.addHooks(a.hooks),s.hooks&&p.hooks.addHooks(s.hooks),i.hooks&&p.hooks.addHooks(i.hooks),await p.hooks.callHook("build:prepare",p),p.options.emitESM===void 0&&p.logger.info("Emitting of ESM bundles, is disabled."),p.options.emitCJS===void 0&&p.logger.info("Emitting of CJS bundles, is disabled."),p},"createContext"),Pr=w(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(n=>n.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(n=>o.startsWith(n))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${m.relative(e.options.rootDir,o)}\``),await y.emptyDir(o))},"cleanDistributionDirectories"),Cr=w((e,t)=>{const o=pr(e.options.entries,"environment","runtime"),n=[];for(const[r,s]of Object.entries(o))for(const[i,l]of Object.entries(s)){(r!=="undefined"||i!=="undefined")&&e.logger.info("Preparing build for "+(r==="undefined"?"":h.cyan(r)+" environment"+(i==="undefined"?"":" with "))+(i==="undefined"?"":h.cyan(i)+" runtime")),e.options.rollup.replace?(e.options.rollup.replace.values={...e.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(r)},i==="edge-light"&&(e.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.");const c=[],a=[],u=[],p=[];for(const d of l)d.cjs&&d.esm?c.push(d):d.cjs?u.push(d):d.esm?a.push(d):d.declaration&&p.push(d);if(c.length>0){const d={...e,options:{...e.options,emitCJS:!0,emitESM:!0,entries:c,minify:r!=="development"&&e.options.minify}};n.push(Z(d,t));const g=d.options.entries.filter($=>$.declaration);e.options.declaration&&g.length>0&&n.push(B({...d,options:{...d.options,entries:g}},t))}if(a.length>0){const d={...e,options:{...e.options,emitCJS:!1,emitESM:!0,entries:a,minify:r!=="development"&&e.options.minify}};n.push(Z(d,t));const g=d.options.entries.filter($=>$.declaration);e.options.declaration&&g.length>0&&n.push(B({...d,options:{...d.options,entries:g}},t))}if(u.length>0){const d={...e,options:{...e.options,emitCJS:!0,emitESM:!1,entries:u,minify:r!=="development"&&e.options.minify}};n.push(Z(d,t));const g=d.options.entries.filter($=>$.declaration);e.options.declaration&&g.length>0&&n.push(B({...d,options:{...d.options,entries:g}},t))}if(e.options.declaration&&p.length>0){const d={...e,options:{...e.options,emitCJS:!1,emitESM:!1,entries:p,minify:r!=="development"&&e.options.minify}};n.push(B(d,t))}}return n},"prepareRollupConfig"),Mr=w(async(e,t,o)=>{await e.hooks.callHook("build:before",e),e.options.minify&&e.logger.info("Minification is enabled, the output will be minified");const n=t.dependencies?.typescript!==void 0||t.devDependencies?.typescript!==void 0;if(e.options.declaration&&e.tsconfig===void 0&&n)throw new Error("Cannot build declaration files without a tsconfig.json");n?e.options.declaration===!1&&e.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(e.options.declaration=!1,e.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),e.options.declaration&&e.logger.info("Using typescript version: "+h.cyan(t.devDependencies?.typescript??t.dependencies?.typescript??"unknown")),e.options.declaration&&(t.dependencies?.typescript||t.devDependencies?.typescript)&&!e.tsconfig?.config.compilerOptions?.isolatedModules&&e.logger.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
91
+ `),r},"showSizeInformation"),Nr=k(async(e,t,o,n,r,s,i,l,c)=>{const a=bo(i.preset??s.preset??"auto",t),u=_r(e,t,o,n,r,s,i,a,l,c);y.ensureDirSync(m.join(u.rootDir,u.outDir));const p={buildEntries:[],dependencyGraphMap:new Map,environment:n,hooks:gt.createHooks(),logger:e,mode:o,options:u,pkg:l,tsconfig:c,usedImports:new Set,warnings:new Set};return a.hooks&&p.hooks.addHooks(a.hooks),s.hooks&&p.hooks.addHooks(s.hooks),i.hooks&&p.hooks.addHooks(i.hooks),await p.hooks.callHook("build:prepare",p),p.options.emitESM===void 0&&p.logger.info("Emitting of ESM bundles, is disabled."),p.options.emitCJS===void 0&&p.logger.info("Emitting of CJS bundles, is disabled."),p},"createContext"),Pr=k(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(n=>n.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(n=>o.startsWith(n))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${m.relative(e.options.rootDir,o)}\``),await y.emptyDir(o))},"cleanDistributionDirectories"),Cr=k((e,t)=>{const o=pr(e.options.entries,"environment","runtime"),n=[];for(const[r,s]of Object.entries(o))for(const[i,l]of Object.entries(s)){(r!=="undefined"||i!=="undefined")&&e.logger.info("Preparing build for "+(r==="undefined"?"":h.cyan(r)+" environment"+(i==="undefined"?"":" with "))+(i==="undefined"?"":h.cyan(i)+" runtime")),e.options.rollup.replace?(e.options.rollup.replace.values={...e.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(r)},i==="edge-light"&&(e.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.");const c=[],a=[],u=[],p=[];for(const g of l)g.cjs&&g.esm?c.push(g):g.cjs?u.push(g):g.esm?a.push(g):g.declaration&&p.push(g);let d=r!=="development"&&e.options.minify;if(e.options.minify&&(d=!0),c.length>0){const g={...e,options:{...e.options,emitCJS:!0,emitESM:!0,entries:c,minify:d}};n.push(Z(g,t));const v=g.options.entries.filter(w=>w.declaration);e.options.declaration&&v.length>0&&n.push(B({...g,options:{...g.options,entries:v}},t))}if(a.length>0){const g={...e,options:{...e.options,emitCJS:!1,emitESM:!0,entries:a,minify:d}};n.push(Z(g,t));const v=g.options.entries.filter(w=>w.declaration);e.options.declaration&&v.length>0&&n.push(B({...g,options:{...g.options,entries:v}},t))}if(u.length>0){const g={...e,options:{...e.options,emitCJS:!0,emitESM:!1,entries:u,minify:d}};n.push(Z(g,t));const v=g.options.entries.filter(w=>w.declaration);e.options.declaration&&v.length>0&&n.push(B({...g,options:{...g.options,entries:v}},t))}if(e.options.declaration&&p.length>0){const g={...e,options:{...e.options,emitCJS:!1,emitESM:!1,entries:p,minify:d}};n.push(B(g,t))}}return n},"prepareRollupConfig"),Mr=k(async(e,t,o)=>{await e.hooks.callHook("build:before",e),e.options.minify&&e.logger.info("Minification is enabled, the output will be minified");const n=t.dependencies?.typescript!==void 0||t.devDependencies?.typescript!==void 0;if(e.options.declaration&&e.tsconfig===void 0&&n)throw new Error("Cannot build declaration files without a tsconfig.json");n?e.options.declaration===!1&&e.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(e.options.declaration=!1,e.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),e.options.declaration&&e.logger.info("Using typescript version: "+h.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
92
  Because none of the third-party transpiler, packem uses under the hood is type-aware, some techniques or features often used in TypeScript are not properly checked and can cause mis-compilation or even runtime errors.
93
- To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),await Promise.all(Cr(e,o)),e.logger.success(h.green(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const s of y.walk(m.join(e.options.rootDir,e.options.outDir))){let i=e.buildEntries.find(l=>m.join(e.options.rootDir,e.options.outDir,l.path)===s.path);if(i||(i={chunk:!0,path:s.path},e.buildEntries.push(i)),!i.bytes){const l=await V.stat(m.resolve(e.options.rootDir,e.options.outDir,s.path));i.bytes=l.size}}const r=Dr(e.logger,e,t);$r(e),xr(t,e),await e.hooks.callHook("build:done",e),pt(e,r)},"build"),Ir=w(async(e,t,o,n,r={})=>{const{configPath:s,debug:i,tsconfigPath:l,...c}=r;n.wrapAll(),e=m.resolve(oe.cwd(),e),n.debug("Root directory:",e);const a=m.join(e,"package.json");if(!y.isAccessibleSync(a))throw new Error("package.json not found at "+a);const u=mt.parsePackageJson(a);n.debug("Using package.json found at",a);let p;if(l){const d=m.join(e,l);if(!await y.isAccessible(d))throw new Error("tsconfig.json not found at "+d);p={config:pe.readTsConfig(d),path:d},n.info("Using tsconfig settings at",d)}else if(u.dependencies?.typescript||u.devDependencies?.typescript)try{p=await pe.findTsConfig(e),n.debug("Using tsconfig settings found at",p.path)}catch{n.info("No tsconfig.json or jsconfig.json found.")}try{let d=s??"";if(!d){const P=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const S of P)if(y.isAccessibleSync(m.join(e,S))){d="./"+S;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(d))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");let g=Fe(d,e);typeof g=="function"&&(g=g(o,t)),n.debug("Using packem config found at",m.join(e,d));const $=Date.now(),O=w(()=>_.duration(Math.floor(Date.now()-$)),"getDuration"),L=C(JSON.stringify({version:u.version,...u.dependencies,...u.devDependencies,...u.peerDependencies,...u.peerDependenciesMeta,browser:u.browser,eNode:u.engines?.node,exports:u.exports,main:u.main,module:u.module,type:u.type,types:u.types})),k=new rr(e,L,n);k.cachePath&&!y.isAccessibleSync(m.join(k.cachePath,L))&&y.isAccessibleSync(k.cachePath)&&(n.info("Clearing file cache because the cache key has changed."),await y.emptyDir(k.cachePath));const v=await Nr(n,e,t,o,i??!1,c,g,u,p);if(k.isEnabled=v.options.fileCache,await mr(v,e),v.logger.info(h.cyan((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+v.options.name)),v.logger.debug(`${h.bold("Root dir:")} ${v.options.rootDir}
93
+ To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),await Promise.all(Cr(e,o)),e.logger.success(h.green(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const s of y.walk(m.join(e.options.rootDir,e.options.outDir))){let i=e.buildEntries.find(l=>m.join(e.options.rootDir,e.options.outDir,l.path)===s.path);if(i||(i={chunk:!0,path:s.path},e.buildEntries.push(i)),!i.bytes){const l=await V.stat(m.resolve(e.options.rootDir,e.options.outDir,s.path));i.bytes=l.size}}const r=Dr(e.logger,e,t);$r(e),xr(t,e),await e.hooks.callHook("build:done",e),pt(e,r)},"build"),Fr=k(async(e,t,o,n,r={})=>{const{configPath:s,debug:i,tsconfigPath:l,...c}=r;n.wrapAll(),e=m.resolve(oe.cwd(),e),n.debug("Root directory:",e);const a=m.join(e,"package.json");if(!y.isAccessibleSync(a))throw new Error("package.json not found at "+a);const u=mt.parsePackageJson(a);n.debug("Using package.json found at",a);let p;if(l){const d=m.join(e,l);if(!await y.isAccessible(d))throw new Error("tsconfig.json not found at "+d);p={config:pe.readTsConfig(d),path:d},n.info("Using tsconfig settings at",d)}else if(u.dependencies?.typescript||u.devDependencies?.typescript)try{p=await pe.findTsConfig(e),n.debug("Using tsconfig settings found at",p.path)}catch{n.info("No tsconfig.json or jsconfig.json found.")}try{let d=s??"";if(!d){const P=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const O of P)if(y.isAccessibleSync(m.join(e,O))){d="./"+O;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(d))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");let g=Re(d,e);typeof g=="function"&&(g=g(o,t)),n.debug("Using packem config found at",m.join(e,d));const v=Date.now(),w=k(()=>_.duration(Math.floor(Date.now()-v)),"getDuration"),L=C(JSON.stringify({version:u.version,...u.dependencies,...u.devDependencies,...u.peerDependencies,...u.peerDependenciesMeta,browser:u.browser,eNode:u.engines?.node,exports:u.exports,main:u.main,module:u.module,type:u.type,types:u.types})),E=new rr(e,L,n);E.cachePath&&!y.isAccessibleSync(m.join(E.cachePath,L))&&y.isAccessibleSync(E.cachePath)&&(n.info("Clearing file cache because the cache key has changed."),await y.emptyDir(E.cachePath));const b=await Nr(n,e,t,o,i??!1,c,g,u,p);if(E.isEnabled=b.options.fileCache,await mr(b,e),b.logger.info(h.cyan((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+b.options.name)),b.logger.debug(`${h.bold("Root dir:")} ${b.options.rootDir}
94
94
  ${h.bold("Entries:")}
95
- ${v.options.entries.map(P=>` ${se(P)}`).join(`
96
- `)}`),await Pr(v),v.options.stub){await Qt(v),await v.hooks.callHook("build:done",v);return}if(t==="watch"){if(v.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await tr(v,k),pt(v,!1);return}await Mr(v,u,k),n.raw(`
97
- ⚡️ Build run in `+O()),n.restoreAll()}catch(d){throw n.raw(`
98
- `),it(d),d}},"createBundler");module.exports=Ir;
95
+ ${b.options.entries.map(P=>` ${se(P)}`).join(`
96
+ `)}`),await Pr(b),b.options.stub){await Qt(b),await b.hooks.callHook("build:done",b);return}if(t==="watch"){if(b.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await tr(b,E),pt(b,!1);return}await Mr(b,u,E),n.raw(`
97
+ ⚡️ Build run in `+w()),n.restoreAll()}catch(d){throw n.raw(`
98
+ `),it(d),d}},"createBundler");module.exports=Fr;
@@ -1,25 +1,25 @@
1
- var Et=Object.defineProperty;var m=(e,t)=>Et(e,"name",{value:t,configurable:!0});import{chmod as Ot,stat as Ae,readdir as St}from"node:fs/promises";import ve from"node:module";import{env as Dt,versions as _t,cwd as Nt}from"node:process";import{cyan as h,bold as D,gray as I,yellow as Pt,grey as Ct,green as Mt}from"@visulima/colorize";import{readFile as se,writeFile as U,isAccessibleSync as w,collectSync as It,readFileSync as Je,writeFileSync as Le,writeJsonSync as Rt,ensureDirSync as Ft,emptyDir as We,walk as Tt,isAccessible as At}from"@visulima/fs";import{formatBytes as C,duration as Jt}from"@visulima/humanizer";import{parsePackageJson as Lt}from"@visulima/package/package-json";import{resolve as g,join as b,normalize as ae,extname as le,relative as O,dirname as ce,basename as Y,isAbsolute as Be,toNamespacedPath as be}from"@visulima/path";import{readTsConfig as Wt,findTsConfig as Bt}from"@visulima/tsconfig";import{defu as Ut}from"defu";import{createHooks as zt}from"hookable";import{rollup as Ue,watch as $e,VERSION as Ht}from"rollup";import{a as T,P as R,b as G,R as qt,E as ee}from"./shared/packem.C_T1EDp8.mjs";import{pathToFileURL as Vt,fileURLToPath as Gt}from"node:url";import{resolvePath as Kt,resolveModuleExportNames as Yt,findStaticImports as ze}from"mlly";import N from"magic-string";import He from"jiti";import{existsSync as pe,rmSync as Xt}from"node:fs";import qe from"@rollup/plugin-alias";import Qt from"@rollup/plugin-commonjs";import Zt from"@rollup/plugin-dynamic-import-vars";import{nodeResolve as Ve}from"@rollup/plugin-node-resolve";import Ge from"@rollup/plugin-replace";import{wasm as eo}from"@rollup/plugin-wasm";import to from"rollup-plugin-polyfill-node";import{visualizer as oo}from"rollup-plugin-visualizer";import{minVersion as Ke}from"semver";import no from"glob-parent";import{glob as ro,globSync as io}from"tinyglobby";import{createFilter as W,normalizePath as we}from"@rollup/pluginutils";import so from"@rollup/plugin-json";import ao from"rollup-plugin-license";import{createHash as lo}from"node:crypto";import{parse as co}from"@babel/parser";import{findCacheDirSync as po}from"@visulima/find-cache-dir";import{NotFoundError as je}from"@visulima/fs/error";import ke from"is-glob";import{distance as uo}from"fastest-levenshtein";import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
1
+ var Et=Object.defineProperty;var m=(e,t)=>Et(e,"name",{value:t,configurable:!0});import{chmod as Ot,stat as Ae,readdir as St}from"node:fs/promises";import ve from"node:module";import{env as Dt,versions as _t,cwd as Nt}from"node:process";import{cyan as y,bold as D,gray as I,yellow as Pt,grey as Ct,green as Mt}from"@visulima/colorize";import{readFile as ie,writeFile as U,isAccessibleSync as j,collectSync as It,readFileSync as Je,writeFileSync as Le,writeJsonSync as Rt,ensureDirSync as Ft,emptyDir as We,walk as Tt,isAccessible as At}from"@visulima/fs";import{formatBytes as C,duration as Jt}from"@visulima/humanizer";import{parsePackageJson as Lt}from"@visulima/package/package-json";import{resolve as g,join as b,normalize as ae,extname as le,relative as S,dirname as ce,basename as Y,isAbsolute as Be,toNamespacedPath as be}from"@visulima/path";import{readTsConfig as Wt,findTsConfig as Bt}from"@visulima/tsconfig";import{defu as Ut}from"defu";import{createHooks as zt}from"hookable";import{rollup as Ue,watch as $e,VERSION as Ht}from"rollup";import{a as T,P as R,b as G,R as qt,E as ee}from"./shared/packem.C_T1EDp8.mjs";import{pathToFileURL as Vt,fileURLToPath as Gt}from"node:url";import{resolvePath as Kt,resolveModuleExportNames as Yt,findStaticImports as ze}from"mlly";import N from"magic-string";import He from"jiti";import{existsSync as pe,rmSync as Xt}from"node:fs";import qe from"@rollup/plugin-alias";import Qt from"@rollup/plugin-commonjs";import Zt from"@rollup/plugin-dynamic-import-vars";import{nodeResolve as Ve}from"@rollup/plugin-node-resolve";import Ge from"@rollup/plugin-replace";import{wasm as eo}from"@rollup/plugin-wasm";import to from"rollup-plugin-polyfill-node";import{visualizer as oo}from"rollup-plugin-visualizer";import{minVersion as Ke}from"semver";import no from"glob-parent";import{glob as ro,globSync as so}from"tinyglobby";import{createFilter as W,normalizePath as we}from"@rollup/pluginutils";import io from"@rollup/plugin-json";import ao from"rollup-plugin-license";import{createHash as lo}from"node:crypto";import{parse as co}from"@babel/parser";import{findCacheDirSync as po}from"@visulima/find-cache-dir";import{NotFoundError as je}from"@visulima/fs/error";import ke from"is-glob";import{distance as uo}from"fastest-levenshtein";import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
2
2
  import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
3
3
  import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
4
4
  const __filename = __cjs_url__.fileURLToPath(import.meta.url);
5
5
  const __dirname = __cjs_path__.dirname(__filename);
6
6
  const require = __cjs_mod__.createRequire(import.meta.url);
7
7
  var mo=Object.defineProperty,X=m((e,t)=>mo(e,"name",{value:t,configurable:!0}),"i$d");const ue=/^#![^\n]*/,re=X(async e=>{await Ot(e,493).catch(()=>{})},"makeExecutable"),fo=X((e,t=`#!/usr/bin/env node
8
- `)=>({name:"packem:shebang",renderChunk:{handler(o,n,r){if(!n.isEntry||!n.facadeModuleId||o.startsWith("#")&&o[1]==="!")return null;if(e.includes(n.name)){const i=new N(o);return i.prepend(t),{code:i.toString(),map:r.sourcemap?i.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,n){for(const[r,i]of Object.entries(n))if(i.type==="chunk"&&ue.test(i.code)&&o.dir){const s=g(o.dir,r);await re(s)}}}),"shebangPlugin"),go=X(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ue,"")}}),"removeShebangPlugin"),ho=X((e,t=`
9
- `)=>{const o=ue.exec(e);return o?o+t:""},"getShebang");var yo=Object.defineProperty,vo=m((e,t)=>yo(e,"name",{value:t,configurable:!0}),"p$2");const de=vo((e,t)=>{let o={};if(e.pkg.name&&(o[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:n}=e.pkg;for(const r in n){if(r.startsWith("#"))continue;const i=n[r];typeof i=="string"&&(o[r]=b(e.options.rootDir,i))}}return o={...o,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(o,Object.fromEntries(e.options.rollup.alias.entries.map(n=>[n.find,n.replacement]))):Object.assign(o,e.options.rollup.alias.entries??e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(o),prefix:t}),o},"resolveAliases");var bo=Object.defineProperty,$o=m((e,t)=>bo(e,"name",{value:t,configurable:!0}),"o$4");const wo=$o((e,t)=>{const o=He(t,{esmResolve:!0,interopDefault:!0});try{return o.resolve(e)}catch(n){if(n.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:n});return e}},"tryResolve");var jo=Object.defineProperty,ko=m((e,t)=>jo(e,"name",{value:t,configurable:!0}),"r$9");const L=ko((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var xo=Object.defineProperty,Eo=m((e,t)=>xo(e,"name",{value:t,configurable:!0}),"u$a");const Oo=Eo(async e=>{const t=await Kt("jiti",{url:import.meta.url}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...de(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const n of e.options.entries){const r=g(e.options.rootDir,e.options.outDir,n.name),i=ae(wo(n.input,e.options.rootDir)||n.input),s=i.slice(0,Math.max(0,i.length-le(i).length)),l=await se(i),c=ho(l);e.options.emitCJS&&await U(`${r}.cjs`,c+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`module.exports = _jiti(${JSON.stringify(i)})`].join(`
10
- `));let a=[];try{a=await Yt(i,{extensions:T})}catch(p){L(e,`Cannot analyze ${i} for exports: ${p.toString()}`);return}const u=a.includes("default")||a.length===0;await U(`${r}.mjs`,c+[`import jiti from ${JSON.stringify(Vt(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`const _module = await _jiti.import(${JSON.stringify(i)});`,u?`
8
+ `)=>({name:"packem:shebang",renderChunk:{handler(o,n,r){if(!n.isEntry||!n.facadeModuleId||o.startsWith("#")&&o[1]==="!")return null;if(e.includes(n.name)){const s=new N(o);return s.prepend(t),{code:s.toString(),map:r.sourcemap?s.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,n){for(const[r,s]of Object.entries(n))if(s.type==="chunk"&&ue.test(s.code)&&o.dir){const i=g(o.dir,r);await re(i)}}}),"shebangPlugin"),go=X(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ue,"")}}),"removeShebangPlugin"),ho=X((e,t=`
9
+ `)=>{const o=ue.exec(e);return o?o+t:""},"getShebang");var yo=Object.defineProperty,vo=m((e,t)=>yo(e,"name",{value:t,configurable:!0}),"p$2");const de=vo((e,t)=>{let o={};if(e.pkg.name&&(o[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:n}=e.pkg;for(const r in n){if(r.startsWith("#"))continue;const s=n[r];typeof s=="string"&&(o[r]=b(e.options.rootDir,s))}}return o={...o,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(o,Object.fromEntries(e.options.rollup.alias.entries.map(n=>[n.find,n.replacement]))):Object.assign(o,e.options.rollup.alias.entries??e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(o),prefix:t}),o},"resolveAliases");var bo=Object.defineProperty,$o=m((e,t)=>bo(e,"name",{value:t,configurable:!0}),"o$4");const wo=$o((e,t)=>{const o=He(t,{esmResolve:!0,interopDefault:!0});try{return o.resolve(e)}catch(n){if(n.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:n});return e}},"tryResolve");var jo=Object.defineProperty,ko=m((e,t)=>jo(e,"name",{value:t,configurable:!0}),"r$9");const L=ko((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var xo=Object.defineProperty,Eo=m((e,t)=>xo(e,"name",{value:t,configurable:!0}),"u$a");const Oo=Eo(async e=>{const t=await Kt("jiti",{url:import.meta.url}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...de(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const n of e.options.entries){const r=g(e.options.rootDir,e.options.outDir,n.name),s=ae(wo(n.input,e.options.rootDir)||n.input),i=s.slice(0,Math.max(0,s.length-le(s).length)),l=await ie(s),c=ho(l);e.options.emitCJS&&await U(`${r}.cjs`,c+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`module.exports = _jiti(${JSON.stringify(s)})`].join(`
10
+ `));let a=[];try{a=await Yt(s,{extensions:T})}catch(p){L(e,`Cannot analyze ${s} for exports: ${p.toString()}`);return}const u=a.includes("default")||a.length===0;await U(`${r}.mjs`,c+[`import jiti from ${JSON.stringify(Vt(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`const _module = await _jiti.import(${JSON.stringify(s)});`,u?`
11
11
  export default _module;`:"",...a.filter(p=>p!=="default").map(p=>`export const ${p} = _module.${p};`)].join(`
12
- `)),await U(`${r}.d.cts`,[`export * from ${JSON.stringify(s)};`,u?`export { default } from ${JSON.stringify(s)};`:""].join(`
13
- `)),await U(`${r}.d.mts`,[`export * from ${JSON.stringify(i)};`,u?`export { default } from ${JSON.stringify(i)};`:""].join(`
14
- `)),c&&(await re(`${r}.cjs`),await re(`${r}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var So=Object.defineProperty,Do=m((e,t)=>So(e,"name",{value:t,configurable:!0}),"r$8");const Ye=Do((e,t)=>He(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var _o=Object.defineProperty,No=m((e,t)=>_o(e,"name",{value:t,configurable:!0}),"i$a");const me=No(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var Po=Object.defineProperty,Xe=m((e,t)=>Po(e,"name",{value:t,configurable:!0}),"e$1");const K=Xe(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Qe=Xe((e,t,o,n)=>{if(n){const s=K(n);if(s)return s}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[r,...i]=t;return Qe(r,i,o,n)},"inferExportType");var Co=Object.defineProperty,Mo=m((e,t)=>Co(e,"name",{value:t,configurable:!0}),"i$9");const Io=["import","require","node","node-addons","default","production","types","deno","browser","development","react-native","react-server"],fe=Mo((e,t,o,n=[])=>{if(!e)return[];if(typeof e=="string"){const r=K(e);if(r&&r!==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:r??t}]}return Object.entries(e).filter(([r])=>!r.endsWith(".json")).flatMap(([r,i])=>o===!1&&r==="types"?[]:typeof i=="string"?{file:i,key:"exports",...Io.includes(r)?{subKey:r}:{},type:Qe(r,n,t,i)}:fe(i,t,o,[...n,r]))},"extractExportFilenames");var Ro=Object.defineProperty,Q=m((e,t)=>Ro(e,"name",{value:t,configurable:!0}),"m$9");const Fo=Q((e,t)=>e.key==="exports"&&e.subKey===R?R:e.key==="exports"&&e.subKey===G?G:t,"getEnvironment"),z=Q((e,t,o,n,r,i,s)=>{const l=Fo(r,s);let c=e.find(a=>a.input===t&&a.environment===l);if(c===void 0&&(c=e[e.push({input:t})-1]),o&&(c.outDir=n),r.isExecutable)c.executable=!0,c.declaration=!1,r.type==="cjs"&&(c.cjs=!0),r.type==="esm"&&(c.esm=!0);else{/\.d\.[mc]?ts$/.test(r.file)&&i!==!1&&(c.declaration=i),r.type==="cjs"&&(c.cjs=!0),r.type==="esm"&&(c.esm=!0);for(const a of qt)if(r.file.includes("."+a+".")){c.runtime=a;break}}c.runtime===void 0&&(c.runtime="node"),c.environment=l,[G,R].includes(r.subKey)&&r.file.includes("."+r.subKey+".")&&(c.fileAlias=!0)},"createOrUpdateEntry"),xe=/(?:\.d\.[mc]?ts|\.\w+)$/;let Ee=!1;const Oe=Q(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"),To=Q((e,t,o)=>{const n=[];t.sort((l,c)=>l.split("/").length-c.split("/").length);const r=e.type==="module"?"esm":"cjs";r==="esm"&&(o.options.emitESM=!0),r==="cjs"&&(o.options.emitCJS=!0);const i=fe(e.exports,r,o.options.declaration);if(e.bin){const l=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const c of l){const a=K(c);if(a&&a!==r)throw new Error(`Exported file "${c}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);i.push({file:c,isExecutable:!0,key:"bin",type:a})}}e.main&&i.push({file:e.main,key:"main",type:K(e.main)??r}),e.module&&i.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(Oe(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),i.push({file:e.types??e.typings,key:"types"}));const s=[];for(const l of i){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 c=l.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),a=c.endsWith("/");if(a&&["./","/"].includes(c))continue;let u=c.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./","");if((l.subKey===G||l.subKey===R)&&(u=u.replace("."+l.subKey,"")),l.file.includes("/*")&&l.key==="exports"){Ee||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Ee=!0);const f=[],v=new RegExp("(?<=/|$)"+u.replace("*","(.*)")+(a?"":"\\.\\w+"));for(const S of t)v.test(S)&&f.push(S.replace(xe,""));if(f.length===0){n.push(`Could not find entrypoint for \`${l.file}\``);continue}for(const S of f)z(s,S,a,c,l,o.options.declaration,o.environment);continue}const p=new RegExp("(?<=/|$)"+u+(a?"":"\\.\\w+")),d=t.find(f=>p.test(f))?.replace(xe,"");if(!d){pe(g(o.options.rootDir,l.file))||n.push(`Could not find entrypoint for \`${l.file}\``);continue}(w(d+".ts")||w(d+".cts")||w(d+".mts"))&&Oe(o),w(d+".cts")&&w(d+".mts")?(z(s,d+".cts",a,c,{...l,type:"cjs"},o.options.declaration,o.environment),z(s,d+".mts",a,c,{...l,type:"esm"},o.options.declaration,o.environment)):z(s,d,a,c,l,o.options.declaration,o.environment)}return{entries:s,warnings:n}},"inferEntries");var Ao=Object.defineProperty,Jo=m((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"o$3");const Lo=Jo((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 Wo=Object.defineProperty,Bo=m((e,t)=>Wo(e,"name",{value:t,configurable:!0}),"t$6");const Uo={hooks:{"build:prepare":Bo(function(e){if(e.options.entries.length>0)return;const t=b(e.options.rootDir,e.options.sourceDir);if(!pe(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=It(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let n={...e.pkg};n.publishConfig&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(n.publishConfig).join(", ")+'".'),e.logger.debug(me(n.publishConfig)),n=Lo(n,e.options.declaration));const r=To(n,o,e);for(const i of r.warnings)L(e,i);if(e.options.entries.push(...r.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",h(e.options.entries.map(i=>D(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),I([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))},"build:prepare")}};var zo=Object.defineProperty,Ho=m((e,t)=>zo(e,"name",{value:t,configurable:!0}),"n$6");const qo=Ho((e,t)=>{if(e==="auto")e=Uo;else{if(e==="none")return{};typeof e=="string"&&(e=Ye(e,t))}return typeof e=="function"&&(e=e()),e},"resolvePreset");var Vo=Object.defineProperty,Go=m((e,t)=>Vo(e,"name",{value:t,configurable:!0}),"a$b");const ie=Go((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var Ko=Object.defineProperty,Yo=m((e,t)=>Ko(e,"name",{value:t,configurable:!0}),"a$a");const J=Yo(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var Xo=Object.defineProperty,Qo=m((e,t)=>Xo(e,"name",{value:t,configurable:!0}),"a$9");const Ze=Qo((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var Zo=Object.defineProperty,et=m((e,t)=>Zo(e,"name",{value:t,configurable:!0}),"s$9");const en=et((e,t,o)=>{const n=o??new Map;return(...r)=>{const i=t?typeof t=="function"?t(...r):t:JSON.stringify({args:r}),s=n.get(i);if(s!==void 0)return s;const l=e(...r);return n.set(i,l),l}},"memoize"),tn=et(e=>{const t=new Map;return o=>en(e,o,t)},"memoizeByKey");var on=Object.defineProperty,nn=m((e,t)=>on(e,"name",{value:t,configurable:!0}),"m$8");const tt=nn(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk(n,r,i){if(r.type!=="chunk"||!r.isEntry)return null;if(i.format==="cjs"&&i.exports==="auto"){const s=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(s===null||s.length<3)return null;const l=new N(n);l.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),l.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&l.append(`
15
- module.exports.default = `+s[2]+";");let c=l.toString();return c=c.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:c,map:l.generateMap({hires:!0})}}if(i.format==="es"&&/\.d\.(?:ts|cts)$/.test(r.fileName)){if(o!=="commonjs"&&r.fileName.endsWith(".d.ts"))return null;const s=/export\s\{\s(.*)\s\}/i.exec(n);if(s===null||s.length<2)return null;const l=s[1].split(", "),c=[];let a="";for(const p of l)if(!p.includes("type"))if(p.includes("as")){const[d,f]=p.split(" as ");if(f==="default"&&(a=d,!e))continue;c.push(f+": typeof "+d+";")}else c.push(p+": typeof "+p+";");const u=new N(n);return u.replace(" "+a+" as default,",""),u.append(`
12
+ `)),await U(`${r}.d.cts`,[`export * from ${JSON.stringify(i)};`,u?`export { default } from ${JSON.stringify(i)};`:""].join(`
13
+ `)),await U(`${r}.d.mts`,[`export * from ${JSON.stringify(s)};`,u?`export { default } from ${JSON.stringify(s)};`:""].join(`
14
+ `)),c&&(await re(`${r}.cjs`),await re(`${r}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var So=Object.defineProperty,Do=m((e,t)=>So(e,"name",{value:t,configurable:!0}),"r$8");const Ye=Do((e,t)=>He(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var _o=Object.defineProperty,No=m((e,t)=>_o(e,"name",{value:t,configurable:!0}),"i$a");const me=No(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var Po=Object.defineProperty,Xe=m((e,t)=>Po(e,"name",{value:t,configurable:!0}),"e$1");const K=Xe(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Qe=Xe((e,t,o,n)=>{if(n){const i=K(n);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[r,...s]=t;return Qe(r,s,o,n)},"inferExportType");var Co=Object.defineProperty,Mo=m((e,t)=>Co(e,"name",{value:t,configurable:!0}),"i$9");const Io=["import","require","node","node-addons","default","production","types","deno","browser","development","react-native","react-server"],fe=Mo((e,t,o,n=[])=>{if(!e)return[];if(typeof e=="string"){const r=K(e);if(r&&r!==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:r??t}]}return Object.entries(e).filter(([r])=>!r.endsWith(".json")).flatMap(([r,s])=>o===!1&&r==="types"?[]:typeof s=="string"?{file:s,key:"exports",...Io.includes(r)?{subKey:r}:{},type:Qe(r,n,t,s)}:fe(s,t,o,[...n,r]))},"extractExportFilenames");var Ro=Object.defineProperty,Q=m((e,t)=>Ro(e,"name",{value:t,configurable:!0}),"m$9");const Fo=Q((e,t)=>e.key==="exports"&&e.subKey===R?R:e.key==="exports"&&e.subKey===G?G:t,"getEnvironment"),z=Q((e,t,o,n,r,s,i)=>{const l=Fo(r,i);let c=e.find(a=>a.input===t&&a.environment===l);if(c===void 0&&(c=e[e.push({input:t})-1]),o&&(c.outDir=n),r.isExecutable)c.executable=!0,c.declaration=!1,r.type==="cjs"&&(c.cjs=!0),r.type==="esm"&&(c.esm=!0);else{/\.d\.[mc]?ts$/.test(r.file)&&s!==!1&&(c.declaration=s),r.type==="cjs"&&(c.cjs=!0),r.type==="esm"&&(c.esm=!0);for(const a of qt)if(r.file.includes("."+a+".")){c.runtime=a;break}}c.runtime===void 0&&(c.runtime="node"),c.environment=l,[G,R].includes(r.subKey)&&r.file.includes("."+r.subKey+".")&&(c.fileAlias=!0)},"createOrUpdateEntry"),xe=/(?:\.d\.[mc]?ts|\.\w+)$/;let Ee=!1;const Oe=Q(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"),To=Q((e,t,o)=>{const n=[];t.sort((l,c)=>l.split("/").length-c.split("/").length);const r=e.type==="module"?"esm":"cjs";r==="esm"&&(o.options.emitESM=!0),r==="cjs"&&(o.options.emitCJS=!0);const s=fe(e.exports,r,o.options.declaration);if(e.bin){const l=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const c of l){const a=K(c);if(a&&a!==r)throw new Error(`Exported file "${c}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);s.push({file:c,isExecutable:!0,key:"bin",type:a??r})}}e.main&&s.push({file:e.main,key:"main",type:K(e.main)??r}),e.module&&s.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(Oe(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),s.push({file:e.types??e.typings,key:"types"}));const i=[];for(const l of s){o.options.declaration===void 0&&(l.key==="types"||l.subKey==="types")&&(o.options.declaration=l.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&l.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&l.type==="esm"&&(o.options.emitESM=!0);const c=l.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),a=c.endsWith("/");if(a&&["./","/"].includes(c))continue;let u=c.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./","");if((l.subKey===G||l.subKey===R)&&(u=u.replace("."+l.subKey,"")),l.file.includes("/*")&&l.key==="exports"){Ee||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Ee=!0);const f=[],h=new RegExp("(?<=/|$)"+u.replace("*","(.*)")+(a?"":"\\.\\w+"));for(const w of t)h.test(w)&&f.push(w.replace(xe,""));if(f.length===0){n.push(`Could not find entrypoint for \`${l.file}\``);continue}for(const w of f)z(i,w,a,c,l,o.options.declaration,o.environment);continue}const p=new RegExp("(?<=/|$)"+u+(a?"":"\\.\\w+")),d=t.find(f=>p.test(f))?.replace(xe,"");if(!d){pe(g(o.options.rootDir,l.file))||n.push(`Could not find entrypoint for \`${l.file}\``);continue}(j(d+".ts")||j(d+".cts")||j(d+".mts"))&&Oe(o),j(d+".cts")&&j(d+".mts")?(z(i,d+".cts",a,c,{...l,type:"cjs"},o.options.declaration,o.environment),z(i,d+".mts",a,c,{...l,type:"esm"},o.options.declaration,o.environment)):z(i,d,a,c,l,o.options.declaration,o.environment)}return{entries:i,warnings:n}},"inferEntries");var Ao=Object.defineProperty,Jo=m((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"o$3");const Lo=Jo((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 Wo=Object.defineProperty,Bo=m((e,t)=>Wo(e,"name",{value:t,configurable:!0}),"t$6");const Uo={hooks:{"build:prepare":Bo(function(e){if(e.options.entries.length>0)return;const t=b(e.options.rootDir,e.options.sourceDir);if(!pe(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=It(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let n={...e.pkg};n.publishConfig&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(n.publishConfig).join(", ")+'".'),e.logger.debug(me(n.publishConfig)),n=Lo(n,e.options.declaration));const r=To(n,o,e);for(const s of r.warnings)L(e,s);if(e.options.entries.push(...r.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",y(e.options.entries.map(s=>D(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),I([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var zo=Object.defineProperty,Ho=m((e,t)=>zo(e,"name",{value:t,configurable:!0}),"n$6");const qo=Ho((e,t)=>{if(e==="auto")e=Uo;else{if(e==="none")return{};typeof e=="string"&&(e=Ye(e,t))}return typeof e=="function"&&(e=e()),e},"resolvePreset");var Vo=Object.defineProperty,Go=m((e,t)=>Vo(e,"name",{value:t,configurable:!0}),"a$b");const se=Go((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var Ko=Object.defineProperty,Yo=m((e,t)=>Ko(e,"name",{value:t,configurable:!0}),"a$a");const J=Yo(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var Xo=Object.defineProperty,Qo=m((e,t)=>Xo(e,"name",{value:t,configurable:!0}),"a$9");const Ze=Qo((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var Zo=Object.defineProperty,et=m((e,t)=>Zo(e,"name",{value:t,configurable:!0}),"s$9");const en=et((e,t,o)=>{const n=o??new Map;return(...r)=>{const s=t?typeof t=="function"?t(...r):t:JSON.stringify({args:r}),i=n.get(s);if(i!==void 0)return i;const l=e(...r);return n.set(s,l),l}},"memoize"),tn=et(e=>{const t=new Map;return o=>en(e,o,t)},"memoizeByKey");var on=Object.defineProperty,nn=m((e,t)=>on(e,"name",{value:t,configurable:!0}),"m$8");const tt=nn(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk(n,r,s){if(r.type!=="chunk"||!r.isEntry)return null;if(s.format==="cjs"&&s.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(i===null||i.length<3)return null;const l=new N(n);l.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),l.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&l.append(`
15
+ module.exports.default = `+i[2]+";");let c=l.toString();return c=c.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:c,map:l.generateMap({hires:!0})}}if(s.format==="es"&&/\.d\.(?:ts|cts)$/.test(r.fileName)){if(o!=="commonjs"&&r.fileName.endsWith(".d.ts"))return null;const i=/export\s\{\s(.*)\s\}/i.exec(n);if(i===null||i.length<2)return null;const l=i[1].split(", "),c=[];let a="";for(const p of l)if(!p.includes("type"))if(p.includes("as")){const[d,f]=p.split(" as ");if(f==="default"&&(a=d,!e))continue;c.push(f+": typeof "+d+";")}else c.push(p+": typeof "+p+";");const u=new N(n);return u.replace(" "+a+" as default,",""),u.append(`
16
16
 
17
17
  declare const defaultExport: {
18
18
  `+(c.length>0?" ":"")+c.join(`
19
19
  `)+`
20
20
  }`+(a?" & typeof "+a:"")+`;
21
21
 
22
- export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:u.toString(),map:u.generateMap({hires:!0})}}return null}}),"cjsInterop");var rn=Object.defineProperty,sn=m((e,t)=>rn(e,"name",{value:t,configurable:!0}),"u$7");const an=sn((e,t)=>{const o=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:r}=n;return Array.isArray(r)?r=r.map(i=>{if(typeof i=="string")return{src:i};if(typeof i=="object"&&"src"in i)return i}).filter(Boolean):typeof r=="string"&&(r=[{src:r}]),{async buildStart(){const i=await Promise.all(r.flatMap(s=>Array.isArray(s.src)?s.src.map(l=>({...s,src:l})):s).map(async s=>await ro(J(s.src),{ignore:J(s.exclude).filter(Boolean)}).then(l=>({dest:s.dest??"",parent:no(s.src),src:l}))));for(const s of i)for(const l of s.src){let c;o.has(l)?c=o.get(l):(c={copied:[],dest:[],timestamp:0},o.set(l,c));const a=n.flatten?ae(s.dest):b(s.dest,O(s.parent,ce(l)));c.dest.includes(a)||c.dest.push(a),this.addWatchFile(l)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([s,l])=>{let c;try{const a=await Ae(s);if(!a.isFile())return;const u=a.mtime.getTime();u>l.timestamp&&(l.timestamp=u,l.copied=[]),c=await se(s,{buffer:!0})}catch(a){t.error({context:[a],message:`error reading file ${s}`,prefix:"plugin:copy"});return}for(const a of l.dest){if(n.copyOnce&&l.copied.includes(a))continue;const u=Y(s),p=b(a,u);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:p,source:c,type:"asset"}),t.debug({message:`copied ${s} → ${p}`,prefix:"plugin:copy"}),l.copied.push(a)}catch(d){t.error({context:[d],message:`error copying file ${s} → ${p}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var ln=Object.defineProperty,Z=m((e,t)=>ln(e,"name",{value:t,configurable:!0}),"t$4");const cn=/\Wrequire(?:\.resolve)?\(/,pn=Z((e,t)=>{if(Dt.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes("// -- packem CommonJS __filename shim")||e.includes("// -- packem CommonJS __dirname shim")||e.includes("// -- packem CommonJS require shim")))return null;let o=!1,n=!1,r=!1;if(e.includes("__filename")&&(o=!0),e.includes("__dirname")&&(n=!0),cn.test(e)&&(r=!0),!o&&!n&&!r)return null;const i=ze(e).pop(),s=i?i.end:0,l=new N(e);return l.appendRight(s,t(o,n,r)),{code:l.toString(),map:l.generateMap()}},"CJSToESM"),un=Z((e,t,o)=>{let n="";return(e||t)&&(n+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
22
+ export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:u.toString(),map:u.generateMap({hires:!0})}}return null}}),"cjsInterop");var rn=Object.defineProperty,sn=m((e,t)=>rn(e,"name",{value:t,configurable:!0}),"u$7");const an=sn((e,t)=>{const o=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:r}=n;return Array.isArray(r)?r=r.map(s=>{if(typeof s=="string")return{src:s};if(typeof s=="object"&&"src"in s)return s}).filter(Boolean):typeof r=="string"&&(r=[{src:r}]),{async buildStart(){const s=await Promise.all(r.flatMap(i=>Array.isArray(i.src)?i.src.map(l=>({...i,src:l})):i).map(async i=>await ro(J(i.src),{ignore:J(i.exclude).filter(Boolean)}).then(l=>({dest:i.dest??"",parent:no(i.src),src:l}))));for(const i of s)for(const l of i.src){let c;o.has(l)?c=o.get(l):(c={copied:[],dest:[],timestamp:0},o.set(l,c));const a=n.flatten?ae(i.dest):b(i.dest,S(i.parent,ce(l)));c.dest.includes(a)||c.dest.push(a),this.addWatchFile(l)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([i,l])=>{let c;try{const a=await Ae(i);if(!a.isFile())return;const u=a.mtime.getTime();u>l.timestamp&&(l.timestamp=u,l.copied=[]),c=await ie(i,{buffer:!0})}catch(a){t.error({context:[a],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const a of l.dest){if(n.copyOnce&&l.copied.includes(a))continue;const u=Y(i),p=b(a,u);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:p,source:c,type:"asset"}),t.debug({message:`copied ${i} → ${p}`,prefix:"plugin:copy"}),l.copied.push(a)}catch(d){t.error({context:[d],message:`error copying file ${i} → ${p}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var ln=Object.defineProperty,Z=m((e,t)=>ln(e,"name",{value:t,configurable:!0}),"t$4");const cn=/\Wrequire(?:\.resolve)?\(/,pn=Z((e,t)=>{if(Dt.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes("// -- packem CommonJS __filename shim")||e.includes("// -- packem CommonJS __dirname shim")||e.includes("// -- packem CommonJS require shim")))return null;let o=!1,n=!1,r=!1;if(e.includes("__filename")&&(o=!0),e.includes("__dirname")&&(n=!0),cn.test(e)&&(r=!0),!o&&!n&&!r)return null;const s=ze(e).pop(),i=s?s.end:0,l=new N(e);return l.appendRight(i,t(o,n,r)),{code:l.toString(),map:l.generateMap()}},"CJSToESM"),un=Z((e,t,o)=>{let n="";return(e||t)&&(n+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
23
23
  `),t&&(n+=`import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
24
24
  `),o&&(n+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
25
25
  `),(e||t)&&(n+=`const __filename = __cjs_url__.fileURLToPath(import.meta.url);
@@ -29,76 +29,76 @@ export default defaultExport;`),t.debug({message:"Applied CommonJS interop to en
29
29
  `),e&&(n+=`const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
30
30
  `),t&&(n+=`const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
31
31
  `),o&&(n+=`const require = __cjs_mod__.createRequire(import.meta.url);
32
- `),n},"generateCJSShimNode20_11"),mn=Z((e,t)=>{const o=W(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(n,r,i){if(i.format==="es"&&o(r.fileName)){let s=un;if(e.engines?.node){const l=Ke(e.engines.node);l&&l.major>=20&&l.minor>=11&&(s=dn)}return pn(n,s)}return null}}},"esmShimCjsSyntaxPlugin");var fn=Object.defineProperty,gn=m((e,t)=>fn(e,"name",{value:t,configurable:!0}),"n$3");const hn=gn(()=>({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 yn=Object.defineProperty,Se=m((e,t)=>yn(e,"name",{value:t,configurable:!0}),"c$8");const vn=Se(e=>(t,o={})=>{const n=W(o.include,o.exclude),r={},i=Se((s,l)=>{r[s.replace(/\..?[jt]s$/,"")]=l},"addOutput");return{generateBundle(s,l){let{entryFileNames:c}=s;typeof c=="function"&&(c=c(l));const a=c.replace(/\.(.)?[jt]s$/,(u,p)=>`.d.${p||""}ts`);for(const[u,p]of Object.entries(r))this.emitFile({fileName:a.replace("[name]",O(e,u)),source:p,type:"asset"})},name:"packem:isolated-declarations",async transform(s,l){if(!n(l))return;const c=await t(l,s),{errors:a,sourceText:u}=c;a.length>0?o.ignoreErrors?this.warn(a[0]):this.error(a[0]):i(l,u)}}},"isolatedDeclarationsPlugin");var bn=Object.defineProperty,$n=m((e,t)=>bn(e,"name",{value:t,configurable:!0}),"n$2");const De="export default ",ot=$n(e=>{const t=so(e);return{...t,name:"packem:json",transform(o,n){const r=t.transform?.call(this,o,n);return r&&typeof r!="string"&&"code"in r&&r.code?.startsWith(De)&&(r.code=r.code.replace(De,"module.exports = ")),r}}},"JSONPlugin");class wn{static{m(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(t=>this.replacement=t,"replace")}}replace(t,o,n,r){t&&o&&(n!=null?t[o][n]=r:t[o]=r)}remove(t,o,n){t&&o&&(n!=null?t[o].splice(n,1):delete t[o])}}class jn extends wn{static{m(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(n=>this.replacement=n,"replace")},this.enter=t,this.leave=o}visit(t,o,n,r){if(t){if(this.enter){const s=this.should_skip,l=this.should_remove,c=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const a=this.should_skip,u=this.should_remove;if(this.should_skip=s,this.should_remove=l,this.replacement=c,a)return t;if(u)return null}let i;for(i in t){const s=t[i];if(s&&typeof s=="object")if(Array.isArray(s)){const l=s;for(let c=0;c<l.length;c+=1){const a=l[c];_e(a)&&(this.visit(a,t,i,c)||c--)}}else _e(s)&&this.visit(s,t,i,null)}if(this.leave){const s=this.replacement,l=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const c=this.should_remove;if(this.replacement=s,this.should_remove=l,c)return null}}return t}}function _e(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(_e,"isNode");function nt(e,{enter:t,leave:o}){return new jn(t,o).visit(e,null)}m(nt,"walk");var kn=Object.defineProperty,xn=m((e,t)=>kn(e,"name",{value:t,configurable:!0}),"u$6");const En=xn(({attributes:e,logger:t})=>{const o=W([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(n,r){if(!o(r))return null;let i=null;try{i=this.parse(n,{allowReturnOutsideFunction:!0})}catch(c){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${r}" and remove the jsx attribute.`}),t.warn(c),null}let s=!1;const l=new N(n);return nt(i,{enter(c){if(c.type==="CallExpression"&&c.callee.type==="Identifier"&&c.callee.name==="jsx"){const a=c.arguments.filter(u=>u.type==="ObjectExpression"&&Array.isArray(u.properties));for(const u of a)for(const p of u.properties)p.type==="Property"&&p.key.type==="Literal"&&p.value.type==="Literal"&&e.includes(p.key.value)&&(l.overwrite(p.start-2,p.end,""),s=!0)}}}),s?{code:l.toString(),map:l.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var On=Object.defineProperty,ge=m((e,t)=>On(e,"name",{value:t,configurable:!0}),"g$3");const Sn=ge(e=>{const t=[],o=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):o.push(n)}),[...o.sort(),...t.sort()]},"sortLicenses"),Dn=ge((e,t,o)=>{const n=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(n.test(e))return e.replace(n,`$1
32
+ `),n},"generateCJSShimNode20_11"),mn=Z((e,t)=>{const o=W(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(n,r,s){if(s.format==="es"&&o(r.fileName)){let i=un;if(e.engines?.node){const l=Ke(e.engines.node);l&&l.major>=20&&l.minor>=11&&(i=dn)}return pn(n,i)}return null}}},"esmShimCjsSyntaxPlugin");var fn=Object.defineProperty,gn=m((e,t)=>fn(e,"name",{value:t,configurable:!0}),"n$3");const hn=gn(()=>({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 yn=Object.defineProperty,Se=m((e,t)=>yn(e,"name",{value:t,configurable:!0}),"c$8");const vn=Se(e=>(t,o={})=>{const n=W(o.include,o.exclude),r={},s=Se((i,l)=>{r[i.replace(/\..?[jt]s$/,"")]=l},"addOutput");return{generateBundle(i,l){let{entryFileNames:c}=i;typeof c=="function"&&(c=c(l));const a=c.replace(/\.(.)?[jt]s$/,(u,p)=>`.d.${p||""}ts`);for(const[u,p]of Object.entries(r))this.emitFile({fileName:a.replace("[name]",S(e,u)),source:p,type:"asset"})},name:"packem:isolated-declarations",async transform(i,l){if(!n(l))return;const c=await t(l,i),{errors:a,sourceText:u}=c;a.length>0?o.ignoreErrors?this.warn(a[0]):this.error(a[0]):s(l,u)}}},"isolatedDeclarationsPlugin");var bn=Object.defineProperty,$n=m((e,t)=>bn(e,"name",{value:t,configurable:!0}),"n$2");const De="export default ",ot=$n(e=>{const t=io(e);return{...t,name:"packem:json",transform(o,n){const r=t.transform?.call(this,o,n);return r&&typeof r!="string"&&"code"in r&&r.code?.startsWith(De)&&(r.code=r.code.replace(De,"module.exports = ")),r}}},"JSONPlugin");class wn{static{m(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(t=>this.replacement=t,"replace")}}replace(t,o,n,r){t&&o&&(n!=null?t[o][n]=r:t[o]=r)}remove(t,o,n){t&&o&&(n!=null?t[o].splice(n,1):delete t[o])}}class jn extends wn{static{m(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(n=>this.replacement=n,"replace")},this.enter=t,this.leave=o}visit(t,o,n,r){if(t){if(this.enter){const i=this.should_skip,l=this.should_remove,c=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const a=this.should_skip,u=this.should_remove;if(this.should_skip=i,this.should_remove=l,this.replacement=c,a)return t;if(u)return null}let s;for(s in t){const i=t[s];if(i&&typeof i=="object")if(Array.isArray(i)){const l=i;for(let c=0;c<l.length;c+=1){const a=l[c];_e(a)&&(this.visit(a,t,s,c)||c--)}}else _e(i)&&this.visit(i,t,s,null)}if(this.leave){const i=this.replacement,l=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const c=this.should_remove;if(this.replacement=i,this.should_remove=l,c)return null}}return t}}function _e(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(_e,"isNode");function nt(e,{enter:t,leave:o}){return new jn(t,o).visit(e,null)}m(nt,"walk");var kn=Object.defineProperty,xn=m((e,t)=>kn(e,"name",{value:t,configurable:!0}),"u$6");const En=xn(({attributes:e,logger:t})=>{const o=W([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(n,r){if(!o(r))return null;let s=null;try{s=this.parse(n,{allowReturnOutsideFunction:!0})}catch(c){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${r}" and remove the jsx attribute.`}),t.warn(c),null}let i=!1;const l=new N(n);return nt(s,{enter(c){if(c.type==="CallExpression"&&c.callee.type==="Identifier"&&c.callee.name==="jsx"){const a=c.arguments.filter(u=>u.type==="ObjectExpression"&&Array.isArray(u.properties));for(const u of a)for(const p of u.properties)p.type==="Property"&&p.key.type==="Literal"&&p.value.type==="Literal"&&e.includes(p.key.value)&&(l.overwrite(p.start-2,p.end,""),i=!0)}}}),i?{code:l.toString(),map:l.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var On=Object.defineProperty,ge=m((e,t)=>On(e,"name",{value:t,configurable:!0}),"g$4");const Sn=ge(e=>{const t=[],o=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):o.push(n)}),[...o.sort(),...t.sort()]},"sortLicenses"),Dn=ge((e,t,o)=>{const n=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(n.test(e))return e.replace(n,`$1
33
33
  ${o}
34
- $2`)},"replaceContentWithin"),rt=ge(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:n,marker:r,mode:i,packageName:s})=>ao({thirdParty(l){const c=new Set,a=l.sort(({name:p},{name:d})=>(p||0)>(d||0)?1:(d||0)>(p||0)?-1:0).map(({author:p,contributors:d,license:f,licenseText:v,maintainers:S,name:B,repository:k})=>{let y="## "+B+`
35
- `;f&&(y+=`License: ${f}
36
- `);const P=new Set;for(const E of[p,...S,...d]){const ye=typeof E=="string"?E:E?.name;ye&&P.add(ye)}return P.size>0&&(y+=`By: ${[...P].join(", ")}
37
- `),k&&(y+=`Repository: ${typeof k=="string"?k:k.url}
38
- `),v&&(y+=`
39
- `+v.trim().replaceAll(/\r\n|\r/g,`
34
+ $2`)},"replaceContentWithin"),rt=ge(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:n,marker:r,mode:s,packageName:i})=>ao({thirdParty(l){const c=new Set,a=l.sort(({name:p},{name:d})=>(p||0)>(d||0)?1:(d||0)>(p||0)?-1:0).map(({author:p,contributors:d,license:f,licenseText:h,maintainers:w,name:B,repository:x})=>{let v="## "+B+`
35
+ `;f&&(v+=`License: ${f}
36
+ `);const P=new Set;for(const O of[p,...w,...d]){const ye=typeof O=="string"?O:O?.name;ye&&P.add(ye)}return P.size>0&&(v+=`By: ${[...P].join(", ")}
37
+ `),x&&(v+=`Repository: ${typeof x=="string"?x:x.url}
38
+ `),h&&(v+=`
39
+ `+h.trim().replaceAll(/\r\n|\r/g,`
40
40
  `).replaceAll(`<!-- ${r} -->`,"").replaceAll(e?`<!-- ${e} -->`:"","").trim().split(`
41
- `).map(E=>E?`> ${E}`:">").join(`
41
+ `).map(O=>O?`> ${O}`:">").join(`
42
42
  `)+`
43
- `),f&&c.add(f),y}).join(`
43
+ `),f&&c.add(f),v}).join(`
44
44
  ---------------------------------------
45
45
 
46
- `);if(a===""){n.info({message:"No dependencies license information found.",prefix:"plugin:license:"+i});return}const u=o(Sn(c),a,s);try{const p=Je(t),d=Dn(p,r,u);if(!d){n.error({message:`Could not find the license marker: <!-- ${r} --> in ${t}`,prefix:"plugin:license:"+i});return}p!==d&&(Le(t,d),n.info({message:`${t} updated.`,prefix:"plugin:license:"+i}))}catch(p){n.error(p)}}}),"license");var _n=Object.defineProperty,Nn=m((e,t)=>_n(e,"name",{value:t,configurable:!0}),"i$7");const Pn=Nn(e=>({async buildEnd(){const t=[];for(const n of this.getModuleIds()){const r=this.getModuleInfo(n);if(r!=null&&!r.isExternal)for(const i of r.importedIds)t.push({source:n,target:i})}if(Array.isArray(t)&&t.length===0)return;const o=g(e.rootDir,e.outDir,"graph.json");Rt(o,t)},name:"packem:metafile"}),"metafilePlugin");var Cn=Object.defineProperty,Mn=m((e,t)=>Cn(e,"name",{value:t,configurable:!0}),"r$4");const M=Mn(e=>{const t=lo("md5");return t.update(e),t.digest("hex")},"getHash");var In=Object.defineProperty,it=m((e,t)=>In(e,"name",{value:t,configurable:!0}),"m$5");const A=it(e=>e.handler||e,"getHandler"),x=it((e,t)=>({...e,async buildEnd(o){e.buildEnd&&await A(e.buildEnd).call(this,o)},async buildStart(o){e.buildStart&&await A(e.buildStart).call(this,o)},async load(o){if(!e.load)return null;const n=b("load",M(o));if(t.has(n,e.name))return await t.get(n,e.name);const r=await A(e.load).call(this,o);return t.set(n,r,e.name),r},name:`cached(${e.name})`,async resolveId(o,n,r){if(!e.resolveId)return null;const i=b("resolveId",M(o),n?M(n):"",M(JSON.stringify(r)));if(t.has(i,e.name))return await t.get(i,e.name);const s=await A(e.resolveId).call(this,o,n,r);return t.set(i,s,e.name),s},async transform(o,n){if(!e.transform)return null;const r=b("transform",M(n),M(o));if(t.has(r,e.name))return await t.get(r,e.name);const i=await A(e.transform).call(this,o,n);return t.set(r,i,e.name),i}}),"cachingPlugin");var Rn=Object.defineProperty,Fn=m((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"c$6");const Tn=/\.(?:m|c)?(?:j|t)sx?$/,An=/^use \w+$/,Jn=Fn(e=>{const t={},o={};return{name:"packem:preserve-directives",onLog(n,r){return r.code==="MODULE_LEVEL_DIRECTIVE"&&n==="warn"?!1:null},renderChunk:{handler(n,r,{sourcemap:i}){const s=r.moduleIds.map(a=>t[a]?t[a]:null).reduce((a,u)=>(u&&u.forEach(p=>{a.add(p)}),a),new Set),l=new N(n);s.size>0&&(e.debug({message:`directives for chunk "${r.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),l.prepend(`${[...s].map(a=>`'${a}';`).join(`
46
+ `);if(a===""){n.info({message:"No dependencies license information found.",prefix:"plugin:license:"+s});return}const u=o(Sn(c),a,i);try{const p=Je(t),d=Dn(p,r,u);if(!d){n.error({message:`Could not find the license marker: <!-- ${r} --> in ${t}`,prefix:"plugin:license:"+s});return}p!==d&&(Le(t,d),n.info({message:`${t} updated.`,prefix:"plugin:license:"+s}))}catch(p){n.error(p)}}}),"license");var _n=Object.defineProperty,Nn=m((e,t)=>_n(e,"name",{value:t,configurable:!0}),"i$7");const Pn=Nn(e=>({async buildEnd(){const t=[];for(const n of this.getModuleIds()){const r=this.getModuleInfo(n);if(r!=null&&!r.isExternal)for(const s of r.importedIds)t.push({source:n,target:s})}if(Array.isArray(t)&&t.length===0)return;const o=g(e.rootDir,e.outDir,"graph.json");Rt(o,t)},name:"packem:metafile"}),"metafilePlugin");var Cn=Object.defineProperty,Mn=m((e,t)=>Cn(e,"name",{value:t,configurable:!0}),"r$4");const M=Mn(e=>{const t=lo("md5");return t.update(e),t.digest("hex")},"getHash");var In=Object.defineProperty,st=m((e,t)=>In(e,"name",{value:t,configurable:!0}),"m$5");const A=st(e=>e.handler||e,"getHandler"),E=st((e,t)=>({...e,async buildEnd(o){e.buildEnd&&await A(e.buildEnd).call(this,o)},async buildStart(o){e.buildStart&&await A(e.buildStart).call(this,o)},async load(o){if(!e.load)return null;const n=b("load",M(o));if(t.has(n,e.name))return await t.get(n,e.name);const r=await A(e.load).call(this,o);return t.set(n,r,e.name),r},name:`cached(${e.name})`,async resolveId(o,n,r){if(!e.resolveId)return null;const s=b("resolveId",M(o),n?M(n):"",M(JSON.stringify(r)));if(t.has(s,e.name))return await t.get(s,e.name);const i=await A(e.resolveId).call(this,o,n,r);return t.set(s,i,e.name),i},async transform(o,n){if(!e.transform)return null;const r=b("transform",M(n),M(o));if(t.has(r,e.name))return await t.get(r,e.name);const s=await A(e.transform).call(this,o,n);return t.set(r,s,e.name),s}}),"cachingPlugin");var Rn=Object.defineProperty,Fn=m((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"c$6");const Tn=/\.(?:m|c)?(?:j|t)sx?$/,An=/^use \w+$/,Jn=Fn(e=>{const t={},o={};return{name:"packem:preserve-directives",onLog(n,r){return r.code==="MODULE_LEVEL_DIRECTIVE"&&n==="warn"?!1:null},renderChunk:{handler(n,r,{sourcemap:s}){const i=r.moduleIds.map(a=>t[a]?t[a]:null).reduce((a,u)=>(u&&u.forEach(p=>{a.add(p)}),a),new Set),l=new N(n);i.size>0&&(e.debug({message:`directives for chunk "${r.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),l.prepend(`${[...i].map(a=>`'${a}';`).join(`
47
47
  `)}
48
48
  `));let c=null;return r.facadeModuleId&&typeof o[r.facadeModuleId]=="string"&&(c=o[r.facadeModuleId]),c&&(e.debug({message:`shebang for chunk "${r.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),l.prepend(`${c}
49
- `)),s.size===0&&c===null?null:{code:l.toString(),map:i?l.generateMap({hires:!0}):null}},order:"post"},transform:{handler(n,r){const i=le(r);if(!Tn.test(i))return null;let s=!1;const l=new N(n);if(n.startsWith("#")&&n[1]==="!"){let a=0;for(let u=2,p=n.length;u<p;u++){const d=n.codePointAt(u);if(d===10||d===13||d===8232||d===8233){a=u;break}}a&&(o[r]=n.slice(0,a),l.remove(0,a+1),s=!0,e.debug({message:`shebang for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}let c=null;try{c=this.parse(l.toString(),{allowReturnOutsideFunction:!0})}catch(a){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${r}" and extract the directives.`}),e.warn(a),null}if(c.type!=="Program")return null;for(const a of c.body.filter(Boolean)){if(a.type!=="ExpressionStatement")break;let u=null;"directive"in a?u=a.directive:a.expression.type==="Literal"&&typeof a.expression.value=="string"&&An.test(a.expression.value)&&(u=a.expression.value),u!=="use strict"&&u&&(t[r]||=new Set,t[r].add(u),"start"in a&&typeof a.start=="number"&&"end"in a&&typeof a.end=="number"&&(l.remove(a.start,a.end),s=!0),e.debug({message:`directive "${u}" for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}return s?{code:l.toString(),map:l.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[r]??[]],shebang:o[r]??null}}}:null},order:"post"}}},"preserveDirectives");var Ln=Object.defineProperty,Wn=m((e,t)=>Ln(e,"name",{value:t,configurable:!0}),"t$2");const Bn=Wn(e=>{const t=W(e.include,e.exclude);return{name:"packem:raw",transform(o,n){return t(n)?{code:`export default ${JSON.stringify(o)}`,map:null}:null}}},"rawPlugin");var Un=Object.defineProperty,zn=m((e,t)=>Un(e,"name",{value:t,configurable:!0}),"l$4");const te="\0__file_url__",st=zn(()=>({async load(e){if(e.startsWith(te)){const t=Gt(e.slice(te.length));return await se(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${te}${e}`}}),"resolveFileUrl");var Hn=Object.defineProperty,F=m((e,t)=>Hn(e,"name",{value:t,configurable:!0}),"r$3");const qn=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Vn=/MIT License|MIT license|BSD license/,Gn=/\n{2,}/g,Kn=/\b(\w+)\$\d+\b/g,Yn=/[-/\\^$*+?.()|[\]{}]/g,Xn=F(e=>e.replaceAll(Yn,"\\$&"),"escapeRegex"),Qn=F(e=>[...new Set(e)],"unique"),Zn=F(e=>e.replaceAll(qn,t=>Vn.test(t)?"":t).replaceAll(Gn,`
49
+ `)),i.size===0&&c===null?null:{code:l.toString(),map:s?l.generateMap({hires:!0}):null}},order:"post"},transform:{handler(n,r){const s=le(r);if(!Tn.test(s))return null;let i=!1;const l=new N(n);if(n.startsWith("#")&&n[1]==="!"){let a=0;for(let u=2,p=n.length;u<p;u++){const d=n.codePointAt(u);if(d===10||d===13||d===8232||d===8233){a=u;break}}a&&(o[r]=n.slice(0,a),l.remove(0,a+1),i=!0,e.debug({message:`shebang for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}let c=null;try{c=this.parse(l.toString(),{allowReturnOutsideFunction:!0})}catch(a){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${r}" and extract the directives.`}),e.warn(a),null}if(c.type!=="Program")return null;for(const a of c.body.filter(Boolean)){if(a.type!=="ExpressionStatement")break;let u=null;"directive"in a?u=a.directive:a.expression.type==="Literal"&&typeof a.expression.value=="string"&&An.test(a.expression.value)&&(u=a.expression.value),u!=="use strict"&&u&&(t[r]||=new Set,t[r].add(u),"start"in a&&typeof a.start=="number"&&"end"in a&&typeof a.end=="number"&&(l.remove(a.start,a.end),i=!0),e.debug({message:`directive "${u}" for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}return i?{code:l.toString(),map:l.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[r]??[]],shebang:o[r]??null}}}:null},order:"post"}}},"preserveDirectives");var Ln=Object.defineProperty,Wn=m((e,t)=>Ln(e,"name",{value:t,configurable:!0}),"t$2");const Bn=Wn(e=>{const t=W(e.include,e.exclude);return{name:"packem:raw",transform(o,n){return t(n)?{code:`export default ${JSON.stringify(o)}`,map:null}:null}}},"rawPlugin");var Un=Object.defineProperty,zn=m((e,t)=>Un(e,"name",{value:t,configurable:!0}),"l$4");const te="\0__file_url__",it=zn(()=>({async load(e){if(e.startsWith(te)){const t=Gt(e.slice(te.length));return await ie(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${te}${e}`}}),"resolveFileUrl");var Hn=Object.defineProperty,F=m((e,t)=>Hn(e,"name",{value:t,configurable:!0}),"r$3");const qn=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Vn=/MIT License|MIT license|BSD license/,Gn=/\n{2,}/g,Kn=/\b(\w+)\$\d+\b/g,Yn=/[-/\\^$*+?.()|[\]{}]/g,Xn=F(e=>e.replaceAll(Yn,"\\$&"),"escapeRegex"),Qn=F(e=>[...new Set(e)],"unique"),Zn=F(e=>e.replaceAll(qn,t=>Vn.test(t)?"":t).replaceAll(Gn,`
50
50
 
51
- `),"cleanUnnecessaryComments"),Ne=new Map;function at(e,t,{identifierReplacements:o},n){const r=ze(e);for(const s in o){const l=r.find(a=>a.specifier===s&&a.imports.includes("{"));if(!l){this.warn(`${t.fileName} does not import "${s}" for replacement`),process.exitCode=1;continue}const c=o[s];for(const a in c){if(!l.imports.includes(a))throw new Error(`${t.fileName} does not import "${a}" from "${s}" for replacement`);const u=c[a],p=Xn(a);u.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${p},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${p}\\b`,"g"),u)}}const i=Qn(Array.from(e.matchAll(Kn),s=>s[0]));if(i.length>0){const s=i.map(c=>`
52
- - ${c}`).join(""),l=t.fileName.replace(/\.[^/.]+$/,"");Ne.has(l)||n.warn({message:`${t.fileName} contains confusing identifier names${s}
51
+ `),"cleanUnnecessaryComments"),Ne=new Map;function at(e,t,{identifierReplacements:o},n){const r=ze(e);for(const i in o){const l=r.find(a=>a.specifier===i&&a.imports.includes("{"));if(!l){this.warn(`${t.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const c=o[i];for(const a in c){if(!l.imports.includes(a))throw new Error(`${t.fileName} does not import "${a}" from "${i}" for replacement`);const u=c[a],p=Xn(a);u.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${p},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${p}\\b`,"g"),u)}}const s=Qn(Array.from(e.matchAll(Kn),i=>i[0]));if(s.length>0){const i=s.map(c=>`
52
+ - ${c}`).join(""),l=t.fileName.replace(/\.[^/.]+$/,"");Ne.has(l)||n.warn({message:`${t.fileName} contains confusing identifier names${i}
53
53
 
54
- To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),Ne.set(l,!0)}return e}m(at,"I$1");F(at,"replaceConfusingTypeNames");function lt(e,t){if(t.leadingComments?.some(o=>o.type==="CommentBlock"&&o.value.includes("@internal"))){const o=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,o),!0}return!1}m(lt,"N");F(lt,"removeInternal");function ct(e,t){if(e.includes("@internal")){const o=new N(e),n=co(e,{plugins:["typescript"],sourceType:"module"});if(nt(n,{enter(r){lt(o,r)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}m(ct,"S");F(ct,"stripInternalTypes");const er=F((e,t)=>({name:"packem:patch-types",renderChunk(o,n){return o=at.call(this,o,n,e,t),o=ct.call(this,o,n),o=Zn(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var tr=Object.defineProperty,pt=m((e,t)=>tr(e,"name",{value:t,configurable:!0}),"m$3");const ut=pt((e,t=!0)=>{if(!e)return null;const{config:o,path:n}=e;if(!o.compilerOptions)return null;const{baseUrl:r,paths:i}=o.compilerOptions;if(!r)return null;const s=g(ce(n),r),l=[];if(i)for(const[c,a]of Object.entries(i)){let u;c==="@"||c==="~"||c==="#"?u=new RegExp(`^${c}/(.+)$`):u=new RegExp(`^${[...c].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let p=0;for(const d of a){const f=[...we(g(s,d))].map(v=>v==="*"?"$"+(++p+""):v==="$"?"$$":v).join("");l.push({find:u,replacement:f})}}return t&&l.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...we(s)].map(c=>c==="$"?"$$":c).join("")}/$1`}),l},"getConfigAlias"),dt=pt((e,t)=>{const o=ut(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,r,i){if(!o||n.includes("\0"))return null;for(const{find:s,replacement:l}of o)if(s.test(n)){const c=n.replace(s,l),a=await this.resolve(c,r,{skipSelf:!0,...i});if(a)return t.debug({message:`Resolved ${n} to ${a.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),a.id}return null}}},"resolveTsconfigPaths");var or=Object.defineProperty,mt=m((e,t)=>or(e,"name",{value:t,configurable:!0}),"u$4");const nr=mt((e,t)=>{if(!t)return null;const{config:o,path:n}=t;if(!o.compilerOptions)return null;const{rootDirs:r}=o.compilerOptions;if(!r)return null;const i=[];for(const s of r){if(s.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${n}.`);if(s.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${n}.`);i.push(g(e,s))}return i},"getRootDirectories"),ft=mt((e,t,o)=>{const n=nr(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(r,i,s){if(n===null||n.length===0)return null;if(r.startsWith("."))for(const l of n){const c=b(l,r),a=await this.resolve(c,i,{skipSelf:!0,...s});if(a)return t.debug({message:`Resolved ${r} to ${a.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),a.id}return null}}},"resolveTsconfigRootDirectories");var rr=Object.defineProperty,ir=m((e,t)=>rr(e,"name",{value:t,configurable:!0}),"r$2");const gt=ir(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,o,n){return e.test(t)&&o?await this.resolve(t.replace(/js(x?)$/,"ts$1"),o,n):null}}},"resolveTypescriptMjsCts");var sr=Object.defineProperty,ar=m((e,t)=>sr(e,"name",{value:t,configurable:!0}),"s$6");const lr=ar(e=>{const t=Y(e).split(".");if(t.length>=2){const[o,n]=t.slice(-2),r=t[0],i=/^(\w+)-runtime$/.exec(o)?.[1];if(T.includes(n)&&i&&i.length>0)return r+"-"+i}},"getCustomModuleLayer");var cr=Object.defineProperty,pr=m((e,t)=>cr(e,"name",{value:t,configurable:!0}),"i$3");const oe=pr(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var ur=Object.defineProperty,Pe=m((e,t)=>ur(e,"name",{value:t,configurable:!0}),"c$4");const Ce=Pe((e,t)=>{const o=new Map;return Pe(function(n,r){const i=r.getModuleInfo(n);if(!i)return;const{isEntry:s}=i,l=i.meta,c=oe(l);if(!s){const a=o.get(n);if(a)return a;const u=lr(n);if(u)return o.set(n,u),u}if(s){const a=r.getModuleIds();for(const u of a)r.getModuleInfo(u)&&oe(l)===c&&(e.has(u)||e.set(u,new Set),e.get(u).add([n,c]))}if(c&&!s&&e.has(n)){const a=[...e.get(n)];if(a.some(([p])=>{if(t.some(d=>d.path===p)){const d=r.getModuleInfo(p);return oe(d?d.meta:{})===c}return!1}))return;if(a.every(([,p])=>p===c))return o.has(n)?o.get(n):void 0;const u=Y(n,le(n))+"-"+c;return o.set(n,u),u}},"splitChunks")},"createSplitChunks");var dr=Object.defineProperty,mr=m((e,t)=>dr(e,"name",{value:t,configurable:!0}),"n");const _=mr((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var fr=Object.defineProperty,gr=m((e,t)=>fr(e,"name",{value:t,configurable:!0}),"s$4");const hr=process.platform==="win32",Me=gr((e,t)=>{const o=hr?"\\":"/";return e.name?.includes("node_modules"+o+".pnpm")?(e.name.replace("node_modules"+o+".pnpm","external")+"."+t).replace("node_modules"+o,""):e.name?.includes("node_modules")?e.name.replace("node_modules","external")+"."+t:"[name]."+t},"getEntryFileNames");var yr=Object.defineProperty,$=m((e,t)=>yr(e,"name",{value:t,configurable:!0}),"p$1");const vr=$((e,t)=>{if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");t.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(t.logger.warn(["ES3 target is not supported by esbuild, so ES5 will be used instead..","Please set 'target' option in tsconfig to at least ES5 to disable this error"].join(" ")),t.tsconfig.config.compilerOptions.target="es5",t.options.rollup.esbuild.target="es5");let o="node"+_t.node.split(".")[0];if(t.pkg.engines?.node){const n=Ke(t.pkg.engines.node);n&&(o="node"+n.major)}if(t.options.rollup.esbuild.target){const n=J(t.options.rollup.esbuild.target);n.some(r=>r.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...J(o),...n])])}else t.options.rollup.esbuild.target=J(o);return t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{logger:t.logger,minify:t.options.minify,minifyWhitespace:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{toplevel:!0},sourceMap:t.options.sourcemap,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return{...t.options.rollup.sucrase}}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),ht=$((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT")throw new Error(`Failed to resolve the module "${e.exporter}" imported by "${h(O(g(),e.id))}"
54
+ To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),Ne.set(l,!0)}return e}m(at,"I$1");F(at,"replaceConfusingTypeNames");function lt(e,t){if(t.leadingComments?.some(o=>o.type==="CommentBlock"&&o.value.includes("@internal"))){const o=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,o),!0}return!1}m(lt,"N");F(lt,"removeInternal");function ct(e,t){if(e.includes("@internal")){const o=new N(e),n=co(e,{plugins:["typescript"],sourceType:"module"});if(nt(n,{enter(r){lt(o,r)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}m(ct,"S");F(ct,"stripInternalTypes");const er=F((e,t)=>({name:"packem:patch-types",renderChunk(o,n){return o=at.call(this,o,n,e,t),o=ct.call(this,o,n),o=Zn(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var tr=Object.defineProperty,pt=m((e,t)=>tr(e,"name",{value:t,configurable:!0}),"m$3");const ut=pt((e,t=!0)=>{if(!e)return null;const{config:o,path:n}=e;if(!o.compilerOptions)return null;const{baseUrl:r,paths:s}=o.compilerOptions;if(!r)return null;const i=g(ce(n),r),l=[];if(s)for(const[c,a]of Object.entries(s)){let u;c==="@"||c==="~"||c==="#"?u=new RegExp(`^${c}/(.+)$`):u=new RegExp(`^${[...c].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let p=0;for(const d of a){const f=[...we(g(i,d))].map(h=>h==="*"?"$"+(++p+""):h==="$"?"$$":h).join("");l.push({find:u,replacement:f})}}return t&&l.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...we(i)].map(c=>c==="$"?"$$":c).join("")}/$1`}),l},"getConfigAlias"),dt=pt((e,t)=>{const o=ut(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,r,s){if(!o||n.includes("\0"))return null;for(const{find:i,replacement:l}of o)if(i.test(n)){const c=n.replace(i,l),a=await this.resolve(c,r,{skipSelf:!0,...s});if(a)return t.debug({message:`Resolved ${n} to ${a.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),a.id}return null}}},"resolveTsconfigPaths");var or=Object.defineProperty,mt=m((e,t)=>or(e,"name",{value:t,configurable:!0}),"u$4");const nr=mt((e,t)=>{if(!t)return null;const{config:o,path:n}=t;if(!o.compilerOptions)return null;const{rootDirs:r}=o.compilerOptions;if(!r)return null;const s=[];for(const i of r){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${n}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${n}.`);s.push(g(e,i))}return s},"getRootDirectories"),ft=mt((e,t,o)=>{const n=nr(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(r,s,i){if(n===null||n.length===0)return null;if(r.startsWith("."))for(const l of n){const c=b(l,r),a=await this.resolve(c,s,{skipSelf:!0,...i});if(a)return t.debug({message:`Resolved ${r} to ${a.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),a.id}return null}}},"resolveTsconfigRootDirectories");var rr=Object.defineProperty,sr=m((e,t)=>rr(e,"name",{value:t,configurable:!0}),"r$2");const gt=sr(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,o,n){return e.test(t)&&o?await this.resolve(t.replace(/js(x?)$/,"ts$1"),o,n):null}}},"resolveTypescriptMjsCts");var ir=Object.defineProperty,ar=m((e,t)=>ir(e,"name",{value:t,configurable:!0}),"s$6");const lr=ar(e=>{const t=Y(e).split(".");if(t.length>=2){const[o,n]=t.slice(-2),r=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if(T.includes(n)&&s&&s.length>0)return r+"-"+s}},"getCustomModuleLayer");var cr=Object.defineProperty,pr=m((e,t)=>cr(e,"name",{value:t,configurable:!0}),"i$3");const oe=pr(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var ur=Object.defineProperty,Pe=m((e,t)=>ur(e,"name",{value:t,configurable:!0}),"c$4");const Ce=Pe((e,t)=>{const o=new Map;return Pe(function(n,r){const s=r.getModuleInfo(n);if(!s)return;const{isEntry:i}=s,l=s.meta,c=oe(l);if(!i){const a=o.get(n);if(a)return a;const u=lr(n);if(u)return o.set(n,u),u}if(i){const a=r.getModuleIds();for(const u of a)r.getModuleInfo(u)&&oe(l)===c&&(e.has(u)||e.set(u,new Set),e.get(u).add([n,c]))}if(c&&!i&&e.has(n)){const a=[...e.get(n)];if(a.some(([p])=>{if(t.some(d=>d.path===p)){const d=r.getModuleInfo(p);return oe(d?d.meta:{})===c}return!1}))return;if(a.every(([,p])=>p===c))return o.has(n)?o.get(n):void 0;const u=Y(n,le(n))+"-"+c;return o.set(n,u),u}},"splitChunks")},"createSplitChunks");var dr=Object.defineProperty,mr=m((e,t)=>dr(e,"name",{value:t,configurable:!0}),"n");const _=mr((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var fr=Object.defineProperty,gr=m((e,t)=>fr(e,"name",{value:t,configurable:!0}),"s$4");const hr=process.platform==="win32",Me=gr((e,t)=>{const o=hr?"\\":"/";return e.name?.includes("node_modules"+o+".pnpm")?(e.name.replace("node_modules"+o+".pnpm","external")+"."+t).replace("node_modules"+o,""):e.name?.includes("node_modules")?e.name.replace("node_modules","external")+"."+t:"[name]."+t},"getEntryFileNames");var yr=Object.defineProperty,$=m((e,t)=>yr(e,"name",{value:t,configurable:!0}),"p$1");const vr=$((e,t)=>{if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");t.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(t.logger.warn(["ES3 target is not supported by esbuild, so ES5 will be used instead..","Please set 'target' option in tsconfig to at least ES5 to disable this error"].join(" ")),t.tsconfig.config.compilerOptions.target="es5",t.options.rollup.esbuild.target="es5");let o="node"+_t.node.split(".")[0];if(t.pkg.engines?.node){const n=Ke(t.pkg.engines.node);n&&(o="node"+n.major)}if(t.options.rollup.esbuild.target){const n=J(t.options.rollup.esbuild.target);n.some(r=>r.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...J(o),...n])])}else t.options.rollup.esbuild.target=J(o);return t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{logger:t.logger,minify:t.options.minify,minifyWhitespace:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{toplevel:!0},sourceMap:t.options.sourcemap,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return{...t.options.rollup.sucrase}}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),ht=$((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT")throw new Error(`Failed to resolve the module "${e.exporter}" imported by "${y(S(g(),e.id))}"
55
55
  Is the module installed? Note:
56
56
  ↳ to inline a module into your bundle, install it to "devDependencies".
57
- ↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MODULE_LEVEL_DIRECTIVE"?!0:e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),Ie=new Map,yt=$((e,t,o)=>{const n=$(i=>{for(const[s,l]of Object.entries(t))if(i.startsWith(s))return i.replace(s,l)},"findAlias"),r=ut(e.tsconfig,!1);return{external(i){const s=n(i);s&&(i=s);const l=Ze(i);if(ie(e.options.externals,l)||ie(e.options.externals,i))return!0;const{pkg:c}=e;if(i.startsWith(".")||Be(i)||/src[/\\]/.test(i)||c.name&&i.startsWith(c.name)||c?.imports?.[i]!==void 0)return!1;if(r){for(const{find:a}of r)if(a.test(i))return e.logger.debug({message:`Resolved alias ${i} to ${a.source}`,prefix:o}),!1}return Ie.has(i)||e.logger.info({message:'Inlined implicit external "'+h(i)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),Ie.set(i,!0),!1},input:Object.fromEntries(e.options.entries.map(i=>[i.name,g(e.options.rootDir,i.input)])),logLevel:e.options.debug?"debug":"info",onLog:$((i,s)=>{let l=s.message;switch(s.stack&&(l=`${l}
58
- ${s.stack}`),i){case"info":{e.logger.info({message:l,prefix:o+(s.plugin?":plugin:"+s.plugin:"")});return}case"warn":{e.logger.warn({message:l,prefix:o+(s.plugin?":plugin:"+s.plugin:"")});return}case"debug":e.logger.debug({message:l,prefix:o+(s.plugin?":plugin:"+s.plugin:"")})}},"onLog"),onwarn(i,s){ht(i,e)||i.code||s(i)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),vt=$(async(e,t)=>{const o=de(e,"build");let n;return e.options.rollup.resolve&&(n=x(Ve({extensions:T,...e.options.rollup.resolve}),t)),{...yt(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:$(r=>_(e,r,"cjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:$(r=>Me(r,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Ce(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:$(r=>_(e,r,"mjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:$(r=>Me(r,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Ce(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[x(st(),t),x(gt(),t),e.tsconfig&&x(ft(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&x(dt(e.tsconfig,e.logger),t),e.options.rollup.replace&&Ge({sourcemap:e.options.sourcemap,...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&qe({customResolver:n,...e.options.rollup.alias,entries:o}),n,e.options.rollup.polyfillNode&&to({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&ot({...e.options.rollup.json}),Jn(e.logger),fo(e.options.entries.filter(r=>r.executable).map(r=>r.name).filter(Boolean)),e.options.rollup.wsam&&eo(e.options.rollup.wsam),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&vn(b(e.options.rootDir,e.options.sourceDir))(e.options.isolatedDeclarationTransformer,e.options.rollup.isolatedDeclarations),e.options.transformer?.(vr(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&tt({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&hn(),e.options.rollup.dynamicVars&&Zt(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&x(Qt({extensions:T,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&mn(e.pkg,e.options.rollup.shim),e.options.rollup.raw&&Bn(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&En({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&Pn({outDir:g(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&an(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&rt({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.rollup.visualizer&&oo({brotliSize:!0,filename:"packem-bundle-analyze.html",gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,title:"Packem Visualizer",...e.options.rollup.visualizer})].filter(Boolean)}},"getRollupOptions"),br=$(async e=>{const{dts:t}=require("rollup-plugin-dts");return t({compilerOptions:{...e.options.rollup.dts.compilerOptions,incremental:void 0,inlineSources:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},respectExternal:e.options.rollup.dts.respectExternal,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),$r=tn(br),bt=$(async(e,t)=>{const o=de(e,"types"),n={load(l){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(l)?null:""},name:"packem:ignore-files"},r=e.tsconfig?.config.compilerOptions;delete r?.lib;let i;e.options.rollup.resolve&&(i=x(Ve({extensions:T,...e.options.rollup.resolve}),t));const s="dts-plugin:"+process.pid+e.tsconfig.path;return{...yt(e,o,"dts"),onwarn(l,c){ht(l,e)||l.code!=="EMPTY_BUNDLE"&&c(l)},output:[e.options.emitCJS&&{chunkFileNames:$(l=>_(e,l,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:$(l=>_(e,l,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.declaration==="compatible"&&{chunkFileNames:$(l=>_(e,l,"d.ts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[x(st(),t),x(gt(),t),e.options.rollup.json&&ot({...e.options.rollup.json}),n,e.tsconfig&&x(ft(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&x(dt(e.tsconfig,e.logger),t),e.options.rollup.replace&&Ge({sourcemap:e.options.sourcemap,...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&qe({customResolver:i,...e.options.rollup.alias,entries:o}),i,await $r(s)(e),e.options.cjsInterop&&e.options.emitCJS&&tt({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&er(e.options.rollup.patchTypes,e.logger),go(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&rt({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var wr=Object.defineProperty,jr=m((e,t)=>wr(e,"name",{value:t,configurable:!0}),"c$3");const ne=jr(async(e,t)=>{const o=await vt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;const n="rollup-build.json";o.cache=t.get(n);const r=await Ue(o);t.set(n,r.cache),await e.hooks.callHook("rollup:build",e,r);const i=new Map;for(const s of o.output){const{output:l}=await r.write(s),c=new Set,a=l.filter(p=>p.type==="chunk");for(const p of a){c.add(p.fileName);for(const d of p.imports)e.usedImports.add(d);p.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(p.code,"utf8"),chunks:p.imports.filter(d=>a.find(f=>f.fileName===d)),exports:p.exports,modules:Object.entries(p.modules).map(([d,f])=>({bytes:f.renderedLength,id:d})),path:p.fileName,type:"entry"})}const u=l.filter(p=>p.type==="asset");for(const p of u)i.has(p.fileName)||i.set(p.fileName,{bytes:Buffer.byteLength(p.source,"utf8"),path:p.fileName,type:"asset"});for(const p of c)e.usedImports.delete(p)}e.buildEntries.push(...i.values())},"build");var kr=Object.defineProperty,H=m((e,t)=>kr(e,"name",{value:t,configurable:!0}),"a$5");const q=H(async(e,t)=>{if(e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer){e.logger.debug({message:"Skipping declaration file generation as isolated declaration transformer is enabled.",prefix:"dts"});return}const o=await bt(e,t);if(await e.hooks.callHook("rollup:dts:options",e,o),Object.keys(o.input).length===0)return;const n="rollup-dts.json";o.cache=t.get(n);const r=await Ue(o);t.set(n,r.cache),await e.hooks.callHook("rollup:dts:build",e,r),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await r.write({chunkFileNames:H(i=>_(e,i,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await r.write({chunkFileNames:H(i=>_(e,i,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),e.options.declaration==="compatible"&&await r.write({chunkFileNames:H(i=>_(e,i,"d.mjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var xr=Object.defineProperty,he=m((e,t)=>xr(e,"name",{value:t,configurable:!0}),"i$1");const Er=he(e=>{const{message:t,name:o="Error",stack:n}=e;if(!n)return n;const r=`${o}: ${t}
57
+ ↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MODULE_LEVEL_DIRECTIVE"?!0:e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),Ie=new Map,yt=$((e,t,o)=>{const n=$(s=>{for(const[i,l]of Object.entries(t))if(s.startsWith(i))return s.replace(i,l)},"findAlias"),r=ut(e.tsconfig,!1);return{external(s){const i=n(s);i&&(s=i);const l=Ze(s);if(se(e.options.externals,l)||se(e.options.externals,s))return!0;const{pkg:c}=e;if(s.startsWith(".")||Be(s)||/src[/\\]/.test(s)||c.name&&s.startsWith(c.name)||c?.imports?.[s]!==void 0)return!1;if(r){for(const{find:a}of r)if(a.test(s))return e.logger.debug({message:`Resolved alias ${s} to ${a.source}`,prefix:o}),!1}return Ie.has(s)||e.logger.info({message:'Inlined implicit external "'+y(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),Ie.set(s,!0),!1},input:Object.fromEntries(e.options.entries.map(s=>[s.name,g(e.options.rootDir,s.input)])),logLevel:e.options.debug?"debug":"info",onLog:$((s,i)=>{let l=i.message;switch(i.stack&&(l=`${l}
58
+ ${i.stack}`),s){case"info":{e.logger.info({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(s,i){ht(s,e)||s.code||i(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),vt=$(async(e,t)=>{const o=de(e,"build");let n;return e.options.rollup.resolve&&(n=E(Ve({extensions:T,...e.options.rollup.resolve}),t)),{...yt(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:$(r=>_(e,r,"cjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:$(r=>Me(r,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Ce(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:$(r=>_(e,r,"mjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:$(r=>Me(r,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Ce(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[E(it(),t),E(gt(),t),e.tsconfig&&E(ft(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&E(dt(e.tsconfig,e.logger),t),e.options.rollup.replace&&Ge({sourcemap:e.options.sourcemap,...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&qe({customResolver:n,...e.options.rollup.alias,entries:o}),n,e.options.rollup.polyfillNode&&to({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&ot({...e.options.rollup.json}),Jn(e.logger),fo(e.options.entries.filter(r=>r.executable).map(r=>r.name).filter(Boolean)),e.options.rollup.wsam&&eo(e.options.rollup.wsam),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&vn(b(e.options.rootDir,e.options.sourceDir))(e.options.isolatedDeclarationTransformer,e.options.rollup.isolatedDeclarations),e.options.transformer?.(vr(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&tt({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&hn(),e.options.rollup.dynamicVars&&Zt(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&E(Qt({extensions:T,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&mn(e.pkg,e.options.rollup.shim),e.options.rollup.raw&&Bn(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&En({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&Pn({outDir:g(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&an(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&rt({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.rollup.visualizer&&oo({brotliSize:!0,filename:"packem-bundle-analyze.html",gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,title:"Packem Visualizer",...e.options.rollup.visualizer})].filter(Boolean)}},"getRollupOptions"),br=$(async e=>{const{dts:t}=require("rollup-plugin-dts");return t({compilerOptions:{...e.options.rollup.dts.compilerOptions,incremental:void 0,inlineSources:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},respectExternal:e.options.rollup.dts.respectExternal,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),$r=tn(br),bt=$(async(e,t)=>{const o=de(e,"types"),n={load(l){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(l)?null:""},name:"packem:ignore-files"},r=e.tsconfig?.config.compilerOptions;delete r?.lib;let s;e.options.rollup.resolve&&(s=E(Ve({extensions:T,...e.options.rollup.resolve}),t));const i="dts-plugin:"+process.pid+e.tsconfig.path;return{...yt(e,o,"dts"),onwarn(l,c){ht(l,e)||l.code!=="EMPTY_BUNDLE"&&c(l)},output:[e.options.emitCJS&&{chunkFileNames:$(l=>_(e,l,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:$(l=>_(e,l,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.declaration==="compatible"&&{chunkFileNames:$(l=>_(e,l,"d.ts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[E(it(),t),E(gt(),t),e.options.rollup.json&&ot({...e.options.rollup.json}),n,e.tsconfig&&E(ft(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&E(dt(e.tsconfig,e.logger),t),e.options.rollup.replace&&Ge({sourcemap:e.options.sourcemap,...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&qe({customResolver:s,...e.options.rollup.alias,entries:o}),s,await $r(i)(e),e.options.cjsInterop&&e.options.emitCJS&&tt({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&er(e.options.rollup.patchTypes,e.logger),go(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&rt({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var wr=Object.defineProperty,jr=m((e,t)=>wr(e,"name",{value:t,configurable:!0}),"c$3");const ne=jr(async(e,t)=>{const o=await vt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;const n="rollup-build.json";o.cache=t.get(n);const r=await Ue(o);t.set(n,r.cache),await e.hooks.callHook("rollup:build",e,r);const s=new Map;for(const i of o.output){const{output:l}=await r.write(i),c=new Set,a=l.filter(p=>p.type==="chunk");for(const p of a){c.add(p.fileName);for(const d of p.imports)e.usedImports.add(d);p.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(p.code,"utf8"),chunks:p.imports.filter(d=>a.find(f=>f.fileName===d)),exports:p.exports,modules:Object.entries(p.modules).map(([d,f])=>({bytes:f.renderedLength,id:d})),path:p.fileName,type:"entry"})}const u=l.filter(p=>p.type==="asset");for(const p of u)s.has(p.fileName)||s.set(p.fileName,{bytes:Buffer.byteLength(p.source,"utf8"),path:p.fileName,type:"asset"});for(const p of c)e.usedImports.delete(p)}e.buildEntries.push(...s.values())},"build");var kr=Object.defineProperty,H=m((e,t)=>kr(e,"name",{value:t,configurable:!0}),"a$5");const q=H(async(e,t)=>{if(e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer){e.logger.debug({message:"Skipping declaration file generation as isolated declaration transformer is enabled.",prefix:"dts"});return}const o=await bt(e,t);if(await e.hooks.callHook("rollup:dts:options",e,o),Object.keys(o.input).length===0)return;const n="rollup-dts.json";o.cache=t.get(n);const r=await Ue(o);t.set(n,r.cache),await e.hooks.callHook("rollup:dts:build",e,r),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await r.write({chunkFileNames:H(s=>_(e,s,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await r.write({chunkFileNames:H(s=>_(e,s,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),e.options.declaration==="compatible"&&await r.write({chunkFileNames:H(s=>_(e,s,"d.mjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var xr=Object.defineProperty,he=m((e,t)=>xr(e,"name",{value:t,configurable:!0}),"i$1");const Er=he(e=>{const{message:t,name:o="Error",stack:n}=e;if(!n)return n;const r=`${o}: ${t}
59
59
  `;return n.startsWith(r)?n.slice(r.length):n},"extractStack"),Or=he(e=>`
60
60
  ${e.replaceAll(/^\n|\n$/g,"")}
61
61
  `,"normalizeCodeFrame"),$t=he(e=>{const t=Er(e);let o=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(o+=`
62
- file: ${h(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(o+=`
62
+ file: ${y(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(o+=`
63
63
  `+Pt(Or(e.frame))),e.message=o,t!==void 0&&(e.stack=`${e.message}
64
- ${t}`)},"enhanceRollupError");var Sr=Object.defineProperty,wt=m((e,t)=>Sr(e,"name",{value:t,configurable:!0}),"l$3");const Re=wt((e,t,o)=>{const n="watcher:"+t;e.on("change",(r,{event:i})=>{o.info({message:`${h(O(".",r))} was ${i}d`,prefix:n})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:n})}),e.on("event",async r=>{switch(r.code){case"END":{o.success({message:"Rebuild "+t+" finished",prefix:n});break}case"BUNDLE_START":{o.info({message:h("build started..."),prefix:n});break}case"BUNDLE_END":{await r.result.close(),o.info({message:h(`built in ${r.duration+""}ms.`),prefix:n});break}case"ERROR":{$t(r.error),o.error({context:[r.error],message:"Rebuild "+t+" failed: "+r.error.message,prefix:n});break}}})},"watchHandler"),Dr=wt(async(e,t)=>{const o=await vt(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=[b(e.options.sourceDir,"**")],o.watch.chokidar={cwd:e.options.rootDir,...o.watch.chokidar});const n=$e(o);await e.hooks.callHook("rollup:watch",e,n);const r=[...Array.isArray(o.input)?o.input:typeof o.input=="string"?[o.input]:Object.keys(o.input??{})];let i="Starting watchers for entries:";for(const s of r)i+=I(`
65
- └─ ${O(process.cwd(),s)}`);if(e.logger.info(i),Re(n,"bundle",e.logger),e.options.declaration){const s=await bt(e,t);await e.hooks.callHook("rollup:dts:options",e,s);const l=$e(s);await e.hooks.callHook("rollup:watch",e,l),Re(l,"types",e.logger)}},"watch");var _r=Object.defineProperty,Nr=m((e,t)=>_r(e,"name",{value:t,configurable:!0}),"a$3");class Pr{static{m(this,"p")}static{Nr(this,"FileCache")}#n;#e;#r;#t=!0;#o=new Map;#i;constructor(t,o,n){this.#n=t,this.#e=po("@visulima/packem",{cwd:t}),this.#r=o,this.#i=n,this.#e===void 0?n.debug("Could not create cache directory."):n.debug(`Cache path is: ${this.#e}`)}set isEnabled(t){this.#t=t}get cachePath(){return this.#e}has(t,o){return!this.#t||this.#e===void 0?!1:w(this.getFilePath(t,o))}get(t,o){if(!this.#t||this.#e===void 0)return;const n=this.getFilePath(t,o);if(this.#o.has(n))return this.#o.get(n);if(!w(n))return;const r=Je(n);try{const i=JSON.parse(r);return this.#o.set(n,i),i}catch{this.#i.warn(`Could not parse cache file: ${n}, deleting the broken cache file.`),this.#o.delete(n),Xt(n,{force:!0});return}}set(t,o,n){if(!this.#t||this.#e===void 0||o===void 0)return;const r=this.getFilePath(t,n);typeof o=="object"&&(o=JSON.stringify(o)),Le(r,o,{overwrite:!0})}getFilePath(t,o){let n=t.replaceAll(be(this.#n),"");return n=n.replaceAll(":","-"),b(this.#e,this.#r,o?.replaceAll(":","-")??"",be(n))}}var Cr=Object.defineProperty,V=m((e,t)=>Cr(e,"name",{value:t,configurable:!0}),"l$2");const Mr=W,Ir=V((e,t)=>{const{sideEffects:o}=t;let n;if(typeof o=="boolean")n=V(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)n=V(()=>!1,"hasSideEffects");else{const r=o.map(i=>i.includes("/")?i:`**/${i}`);n=Mr(r,null,{resolve:e})}else n=V(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var Rr=Object.defineProperty,Fr=m((e,t)=>Rr(e,"name",{value:t,configurable:!0}),"y");const Tr=Fr((e,t,o)=>e.reduce((n,r)=>{const i=r[t],s=r[o];return n[i]||(n[i]={}),n[i][s]||(n[i][s]=[]),n[i][s].push(r),n},{}),"groupByKeys");var Ar=Object.defineProperty,jt=m((e,t)=>Ar(e,"name",{value:t,configurable:!0}),"r");const Jr=jt(e=>e.replace(/\.(?:js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension"),Lr=jt(async(e,t)=>{e.options.entries=e.options.entries.map(n=>typeof n=="string"?{input:n,isGlob:ke(n)}:{...n,isGlob:ke(n.input)});const o=[];for(const n of e.options.entries.filter(r=>r.isGlob)){const{isGlob:r,...i}=n,s=io([i.input],{cwd:e.options.rootDir,dot:!1,ignore:["**/node_modules/**"],onlyFiles:!0});if(s.length===0)throw new je("No files found in the glob pattern: "+h(b(e.options.rootDir,i.input)));for(const l of s)e.options.entries.push({...i,input:g(e.options.rootDir,l)});e.options.entries.splice(e.options.entries.indexOf(n),1)}for await(const n of e.options.entries){if(typeof n.name!="string"){let r=Be(n.input)?O(t,n.input):ae(n.input);r.startsWith("./")&&(r=r.slice(2)),n.name=Jr(r.replace(new RegExp(`^${e.options.sourceDir}/`),"")),n.fileAlias&&o.push({...n,name:n.name+"."+n.environment})}if(!n.input)throw new Error(`Missing entry input: ${me(n)}`);if(n.input=g(e.options.rootDir,n.input),e.options.declaration&&n.declaration===void 0&&(n.declaration=e.options.declaration),e.options.emitCJS!==void 0&&n.cjs===void 0&&(n.cjs=e.options.emitCJS),e.options.emitESM!==void 0&&n.esm===void 0&&(n.esm=e.options.emitESM),!w(n.input)){const r=new Set(await St(ce(n.input)));let i=!1;for(const s of T)if(r.has(Y(n.input)+s)){i=!0;break}if(!i)throw new je("Your configured entry: "+h(n.input)+" does not exist.")}n.outDir=g(e.options.rootDir,n.outDir??e.options.outDir)}e.options.entries.push(...o)},"prepareEntries");var Wr=Object.defineProperty,Br=m((e,t)=>Wr(e,"name",{value:t,configurable:!0}),"a$2");const Ur=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,zr=new Set(["abstract","await","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"]),Fe=Br(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(Ur.test(t))throw new Error(`Alias name "${t}" is invalid. Alias names should start with a letter or underscore and only contain letters, numbers, underscores, and dashes.`);if(zr.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const n=g(o);if(!w(n))throw new Error(`Target path "${n}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var Hr=Object.defineProperty,qr=m((e,t)=>Hr(e,"name",{value:t,configurable:!0}),"o");const Vr=qr(e=>{const t=new Set,o=new Set(Object.keys(e.pkg?.dependencies??{})),n=new Set;for(const r of e.usedImports)o.delete(r),t.add(r);if(e.pkg?.dependencies)for(const r of Object.keys(e.pkg?.dependencies))o.delete(r);for(const r of t){const i=Ze(r);!ie(e.options.externals,r)&&!r.startsWith("chunks/")&&e.pkg?.dependencies?.[i]===void 0&&e.pkg?.peerDependencies?.[i]===void 0&&n.add(r)}o.size>0&&L(e,`Potential unused dependencies found: ${[...o].map(r=>h(r)).join(", ")}`),n.size>0&&L(e,`Potential implicit dependencies found: ${[...n].map(r=>h(r)).join(", ")}`)},"validateDependencies");var Gr=Object.defineProperty,kt=m((e,t)=>Gr(e,"name",{value:t,configurable:!0}),"i");const Kr=kt((e,t)=>uo(e,t)<=e.length/3||t.includes(e),"isSimilar"),Yr=kt((e,t)=>{const o=e.toLowerCase();return t.filter(n=>Kr(n.toLowerCase(),o))},"findAlternatives");var Xr=Object.defineProperty,Te=m((e,t)=>Xr(e,"name",{value:t,configurable:!0}),"s");const Qr=Te((e,t)=>{const o=new Set([...typeof e.bin=="string"?[e.bin]:Object.values(e.bin??{}),e.main,e.module,t.options.declaration?e.types:"",t.options.declaration?e.typings:"",...fe(e.exports,e.type==="module"?"esm":"cjs",t.options.declaration).map(r=>r.file)].map(r=>r&&g(t.options.rootDir,r.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const r of o)r&&!r.includes("*")&&!pe(r)&&n.push(r.replace(`${t.options.rootDir}/`,""));if(n.length>0){const r=Te(l=>O(t.options.rootDir,g(t.options.outDir,l)),"rPath"),i=t.buildEntries.filter(l=>!l.chunk).map(l=>r(l.path));let s="Potential missing or wrong package.json files:";for(const l of n){const c=Yr(l,i);s+=`
66
- - `+h(l)+(c.length>0?Ct` (did you mean ${c.map(a=>`"${a}"`).join(", ")}?)`:"")}L(t,s)}},"validatePackage");var Zr=Object.defineProperty,j=m((e,t)=>Zr(e,"name",{value:t,configurable:!0}),"h");const xt=j((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
64
+ ${t}`)},"enhanceRollupError");var Sr=Object.defineProperty,wt=m((e,t)=>Sr(e,"name",{value:t,configurable:!0}),"l$3");const Re=wt((e,t,o)=>{const n="watcher:"+t;e.on("change",(r,{event:s})=>{o.info({message:`${y(S(".",r))} was ${s}d`,prefix:n})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:n})}),e.on("event",async r=>{switch(r.code){case"END":{o.success({message:"Rebuild "+t+" finished",prefix:n});break}case"BUNDLE_START":{o.info({message:y("build started..."),prefix:n});break}case"BUNDLE_END":{await r.result.close(),o.info({message:y(`built in ${r.duration+""}ms.`),prefix:n});break}case"ERROR":{$t(r.error),o.error({context:[r.error],message:"Rebuild "+t+" failed: "+r.error.message,prefix:n});break}}})},"watchHandler"),Dr=wt(async(e,t)=>{const o=await vt(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=[b(e.options.sourceDir,"**")],o.watch.chokidar={cwd:e.options.rootDir,...o.watch.chokidar});const n=$e(o);await e.hooks.callHook("rollup:watch",e,n);const r=[...Array.isArray(o.input)?o.input:typeof o.input=="string"?[o.input]:Object.keys(o.input??{})];let s="Starting watchers for entries:";for(const i of r)s+=I(`
65
+ └─ ${S(process.cwd(),i)}`);if(e.logger.info(s),Re(n,"bundle",e.logger),e.options.declaration){const i=await bt(e,t);await e.hooks.callHook("rollup:dts:options",e,i);const l=$e(i);await e.hooks.callHook("rollup:watch",e,l),Re(l,"types",e.logger)}},"watch");var _r=Object.defineProperty,Nr=m((e,t)=>_r(e,"name",{value:t,configurable:!0}),"a$3");class Pr{static{m(this,"p")}static{Nr(this,"FileCache")}#n;#e;#r;#t=!0;#o=new Map;#s;constructor(t,o,n){this.#n=t,this.#e=po("@visulima/packem",{cwd:t}),this.#r=o,this.#s=n,this.#e===void 0?n.debug("Could not create cache directory."):n.debug(`Cache path is: ${this.#e}`)}set isEnabled(t){this.#t=t}get cachePath(){return this.#e}has(t,o){return!this.#t||this.#e===void 0?!1:j(this.getFilePath(t,o))}get(t,o){if(!this.#t||this.#e===void 0)return;const n=this.getFilePath(t,o);if(this.#o.has(n))return this.#o.get(n);if(!j(n))return;const r=Je(n);try{const s=JSON.parse(r);return this.#o.set(n,s),s}catch{this.#s.warn(`Could not parse cache file: ${n}, deleting the broken cache file.`),this.#o.delete(n),Xt(n,{force:!0});return}}set(t,o,n){if(!this.#t||this.#e===void 0||o===void 0)return;const r=this.getFilePath(t,n);typeof o=="object"&&(o=JSON.stringify(o)),Le(r,o,{overwrite:!0})}getFilePath(t,o){let n=t.replaceAll(be(this.#n),"");return n=n.replaceAll(":","-"),b(this.#e,this.#r,o?.replaceAll(":","-")??"",be(n))}}var Cr=Object.defineProperty,V=m((e,t)=>Cr(e,"name",{value:t,configurable:!0}),"l$2");const Mr=W,Ir=V((e,t)=>{const{sideEffects:o}=t;let n;if(typeof o=="boolean")n=V(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)n=V(()=>!1,"hasSideEffects");else{const r=o.map(s=>s.includes("/")?s:`**/${s}`);n=Mr(r,null,{resolve:e})}else n=V(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var Rr=Object.defineProperty,Fr=m((e,t)=>Rr(e,"name",{value:t,configurable:!0}),"y");const Tr=Fr((e,t,o)=>e.reduce((n,r)=>{const s=r[t],i=r[o];return n[s]||(n[s]={}),n[s][i]||(n[s][i]=[]),n[s][i].push(r),n},{}),"groupByKeys");var Ar=Object.defineProperty,jt=m((e,t)=>Ar(e,"name",{value:t,configurable:!0}),"r");const Jr=jt(e=>e.replace(/\.(?:js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension"),Lr=jt(async(e,t)=>{e.options.entries=e.options.entries.map(n=>typeof n=="string"?{input:n,isGlob:ke(n)}:{...n,isGlob:ke(n.input)});const o=[];for(const n of e.options.entries.filter(r=>r.isGlob)){const{isGlob:r,...s}=n,i=so([s.input],{cwd:e.options.rootDir,dot:!1,ignore:["**/node_modules/**"],onlyFiles:!0});if(i.length===0)throw new je("No files found in the glob pattern: "+y(b(e.options.rootDir,s.input)));for(const l of i)e.options.entries.push({...s,input:g(e.options.rootDir,l)});e.options.entries.splice(e.options.entries.indexOf(n),1)}for await(const n of e.options.entries){if(typeof n.name!="string"){let r=Be(n.input)?S(t,n.input):ae(n.input);r.startsWith("./")&&(r=r.slice(2)),n.name=Jr(r.replace(new RegExp(`^${e.options.sourceDir}/`),"")),n.fileAlias&&o.push({...n,name:n.name+"."+n.environment})}if(!n.input)throw new Error(`Missing entry input: ${me(n)}`);if(n.input=g(e.options.rootDir,n.input),e.options.declaration&&n.declaration===void 0&&(n.declaration=e.options.declaration),e.options.emitCJS!==void 0&&n.cjs===void 0&&(n.cjs=e.options.emitCJS),e.options.emitESM!==void 0&&n.esm===void 0&&(n.esm=e.options.emitESM),!j(n.input)){const r=new Set(await St(ce(n.input)));let s=!1;for(const i of T)if(r.has(Y(n.input)+i)){s=!0;break}if(!s)throw new je("Your configured entry: "+y(n.input)+" does not exist.")}n.outDir=g(e.options.rootDir,n.outDir??e.options.outDir)}e.options.entries.push(...o)},"prepareEntries");var Wr=Object.defineProperty,Br=m((e,t)=>Wr(e,"name",{value:t,configurable:!0}),"a$2");const Ur=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,zr=new Set(["abstract","await","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"]),Fe=Br(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(Ur.test(t))throw new Error(`Alias name "${t}" is invalid. Alias names should start with a letter or underscore and only contain letters, numbers, underscores, and dashes.`);if(zr.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const n=g(o);if(!j(n))throw new Error(`Target path "${n}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var Hr=Object.defineProperty,qr=m((e,t)=>Hr(e,"name",{value:t,configurable:!0}),"o");const Vr=qr(e=>{const t=new Set,o=new Set(Object.keys(e.pkg?.dependencies??{})),n=new Set;for(const r of e.usedImports)o.delete(r),t.add(r);if(e.pkg?.dependencies)for(const r of Object.keys(e.pkg?.dependencies))o.delete(r);for(const r of t){const s=Ze(r);!se(e.options.externals,r)&&!r.startsWith("chunks/")&&e.pkg?.dependencies?.[s]===void 0&&e.pkg?.peerDependencies?.[s]===void 0&&n.add(r)}o.size>0&&L(e,`Potential unused dependencies found: ${[...o].map(r=>y(r)).join(", ")}`),n.size>0&&L(e,`Potential implicit dependencies found: ${[...n].map(r=>y(r)).join(", ")}`)},"validateDependencies");var Gr=Object.defineProperty,kt=m((e,t)=>Gr(e,"name",{value:t,configurable:!0}),"i");const Kr=kt((e,t)=>uo(e,t)<=e.length/3||t.includes(e),"isSimilar"),Yr=kt((e,t)=>{const o=e.toLowerCase();return t.filter(n=>Kr(n.toLowerCase(),o))},"findAlternatives");var Xr=Object.defineProperty,Te=m((e,t)=>Xr(e,"name",{value:t,configurable:!0}),"s");const Qr=Te((e,t)=>{const o=new Set([...typeof e.bin=="string"?[e.bin]:Object.values(e.bin??{}),e.main,e.module,t.options.declaration?e.types:"",t.options.declaration?e.typings:"",...fe(e.exports,e.type==="module"?"esm":"cjs",t.options.declaration).map(r=>r.file)].map(r=>r&&g(t.options.rootDir,r.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const r of o)r&&!r.includes("*")&&!pe(r)&&n.push(r.replace(`${t.options.rootDir}/`,""));if(n.length>0){const r=Te(l=>S(t.options.rootDir,g(t.options.outDir,l)),"rPath"),s=t.buildEntries.filter(l=>!l.chunk).map(l=>r(l.path));let i="Potential missing or wrong package.json files:";for(const l of n){const c=Yr(l,s);i+=`
66
+ - `+y(l)+(c.length>0?Ct` (did you mean ${c.map(a=>`"${a}"`).join(", ")}?)`:"")}L(t,i)}},"validatePackage");var Zr=Object.defineProperty,k=m((e,t)=>Zr(e,"name",{value:t,configurable:!0}),"g");const xt=k((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
67
67
  `),e.logger.warn(`Build is done with some warnings:
68
68
 
69
69
  ${[...e.warnings].map(o=>`- ${o}`).join(`
70
- `)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logErrors"),ei=j(e=>{switch(e){case"preserve":case"react-native":return"preserve";case"react":return"transform";case"react-jsx":case"react-jsxdev":return"automatic";default:return}},"resolveTsconfigJsxToJsxRuntime"),ti=j((e,t,o,n,r,i,s,l,c,a)=>{const u=ei(a?.config.compilerOptions?.jsx),p=Ut(s,i,l,{alias:{},clean:!0,debug:r,declaration:void 0,emitCJS:void 0,emitESM:void 0,entries:[],externals:[...ve.builtinModules,...ve.builtinModules.map(d=>`node:${d}`)],failOnWarn:!0,fileCache:!0,minify:n===R,name:(c.name??"").split("/").pop()??"default",outDir:"dist",replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:a?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,moduleResolution:100,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},esbuild:{charset:"utf8",include:/\.[jt]sx?$/,jsx:u,jsxDev:a?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:a?.config.compilerOptions?.jsxFactory,jsxFragment:a?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:a?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,sourcesContent:!1,target:a?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:a?.config},isolatedDeclarations:{exclude:ee,ignoreErrors:!1,include:[/\.[cm]?ts$/]},json:{preferConst:!0},license:{dependenciesTemplate:j((d,f,v)=>`
70
+ `)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logErrors"),es=k(e=>{switch(e){case"preserve":case"react-native":return"preserve";case"react":return"transform";case"react-jsx":case"react-jsxdev":return"automatic";default:return}},"resolveTsconfigJsxToJsxRuntime"),ts=k((e,t,o,n,r,s,i,l,c,a)=>{const u=es(a?.config.compilerOptions?.jsx),p=Ut(i,s,l,{alias:{},clean:!0,debug:r,declaration:void 0,emitCJS:void 0,emitESM:void 0,entries:[],externals:[...ve.builtinModules,...ve.builtinModules.map(d=>`node:${d}`)],failOnWarn:!0,fileCache:!0,minify:n===R,name:(c.name??"").split("/").pop()??"default",outDir:"dist",replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:a?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,moduleResolution:100,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},esbuild:{charset:"utf8",include:/\.[jt]sx?$/,jsx:u,jsxDev:a?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:a?.config.compilerOptions?.jsxFactory,jsxFragment:a?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:a?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,sourcesContent:!1,target:a?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:a?.config},isolatedDeclarations:{exclude:ee,ignoreErrors:!1,include:[/\.[cm]?ts$/]},json:{preferConst:!0},license:{dependenciesTemplate:k((d,f,h)=>`
71
71
  # Licenses of bundled dependencies
72
- The published ${v} artifact additionally contains code with the following licenses:
72
+ The published ${h} artifact additionally contains code with the following licenses:
73
73
  `+(d.length>0?`${d.join(", ")}
74
74
 
75
75
  `:`
76
76
  `)+`# Bundled dependencies:
77
- `+f,"dependenciesTemplate"),dtsTemplate:j((d,f,v)=>`
77
+ `+f,"dependenciesTemplate"),dtsTemplate:k((d,f,h)=>`
78
78
  # Licenses of bundled types
79
- The published ${v} artifact additionally contains code with the following licenses:
79
+ The published ${h} artifact additionally contains code with the following licenses:
80
80
  `+(d.length>0?`${d.join(", ")}
81
81
 
82
82
  `:`
83
83
  `)+`# Bundled types:
84
- `+f,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:ee,include:[/\.(md|txt|css|htm|html|data)$/]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:{exclude:[/node_modules/],include:[/\.(js|cjs|mjs|tsx|mts|cts)$/]},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:a?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:n===R,...a?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(a.config.compilerOptions.jsx)?{jsxFragmentPragma:a.config.compilerOptions.jsxFragmentFactory,jsxImportSource:a.config.compilerOptions.jsxImportSource,jsxPragma:a.config.compilerOptions.jsxFactory,jsxRuntime:u,transforms:["typescript","jsx",...a.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...a?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:/\.[jt]sx?$/,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:a?.config.compilerOptions?.experimentalDecorators,syntax:a?"typescript":"ecmascript",[a?"tsx":"jsx"]:!0},target:a?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:a?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:a?.config.compilerOptions?.experimentalDecorators,react:{development:n!==R,pragma:a?.config.compilerOptions?.jsxFactory,pragmaFrag:a?.config.compilerOptions?.jsxFragmentFactory,runtime:u,throwIfNamespace:!0},treatConstEnumAsEnum:a?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:a?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"},transform:{decoratorVersion:"2022-03"}},treeshake:{moduleSideEffects:Ir(t,c),preset:"recommended"},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:ee}},rootDir:t,sourceDir:"src",sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!p.transformerName){const d=new Map([...Object.entries(c.dependencies??{}),...Object.entries(c.devDependencies??{})]);let f="0.0.0";if(d.has("esbuild"))p.transformerName="esbuild",f=d.get("esbuild");else if(d.has("@swc/core"))p.transformerName="swc",f=d.get("@swc/core");else if(d.has("sucrase"))p.transformerName="sucrase",f=d.get("sucrase");else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info("Using "+h("rollup ")+Ht),e.info({message:"Using "+h(p.transformerName)+" "+f,prefix:"transformer"})}return p.rollup.resolve&&p.rollup.resolve.preferBuiltins===!0&&(p.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),c.dependencies&&p.externals.push(...Object.keys(c.dependencies)),c.peerDependencies&&p.externals.push(...Object.keys(c.peerDependencies)),c.optionalDependencies&&p.externals.push(...Object.keys(c.optionalDependencies)),Fe(p.alias),p.rollup.alias&&p.rollup.alias.entries&&Fe(p.rollup.alias.entries),p},"generateOptions"),oi=j((e,t,o)=>{const n=j(i=>O(t.options.rootDir,g(t.options.outDir,i)),"rPath");let r=!1;for(const i of t.buildEntries.filter(s=>!s.chunk)){let s=i.bytes??0;for(const c of i.chunks??[])s+=t.buildEntries.find(a=>a.path===c)?.bytes??0;let l=` ${D(n(i.path))} (${["total size: "+h(C(s)),i.type!=="asset"&&i.bytes&&"chunk size: "+h(C(i.bytes))].filter(Boolean).join(", ")})`;if(l+=i.exports?.length?`
85
- exports: `+I(i.exports.join(", ")):"",i.chunks?.length&&(l+=`
86
- ${i.chunks.map(c=>{const a=t.buildEntries.find(u=>u.path===c)??{};return I(" └─ "+n(c)+D(a.bytes?" ("+C(a?.bytes)+")":""))}).join(`
87
- `)}`),i.modules&&i.modules.length>0){const c=i.modules.filter(a=>a.id.includes("node_modules")).sort((a,u)=>(u.bytes||0)-(a.bytes||0)).map(a=>I(" 📦 "+n(a.id)+D(a.bytes?" ("+C(a.bytes)+")":""))).join(`
84
+ `+f,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:ee,include:[/\.(md|txt|css|htm|html|data)$/]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:{exclude:[/node_modules/],include:[/\.(js|cjs|mjs|tsx|mts|cts)$/]},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:a?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:n===R,...a?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(a.config.compilerOptions.jsx)?{jsxFragmentPragma:a.config.compilerOptions.jsxFragmentFactory,jsxImportSource:a.config.compilerOptions.jsxImportSource,jsxPragma:a.config.compilerOptions.jsxFactory,jsxRuntime:u,transforms:["typescript","jsx",...a.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...a?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:/\.[jt]sx?$/,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:a?.config.compilerOptions?.experimentalDecorators,syntax:a?"typescript":"ecmascript",[a?"tsx":"jsx"]:!0},target:a?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:a?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:a?.config.compilerOptions?.experimentalDecorators,react:{development:n!==R,pragma:a?.config.compilerOptions?.jsxFactory,pragmaFrag:a?.config.compilerOptions?.jsxFragmentFactory,runtime:u,throwIfNamespace:!0},treatConstEnumAsEnum:a?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:a?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"},transform:{decoratorVersion:"2022-03"}},treeshake:{moduleSideEffects:Ir(t,c),preset:"recommended"},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:ee}},rootDir:t,sourceDir:"src",sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!p.transformerName){const d=new Map([...Object.entries(c.dependencies??{}),...Object.entries(c.devDependencies??{})]);let f="0.0.0";if(d.has("esbuild"))p.transformerName="esbuild",f=d.get("esbuild");else if(d.has("@swc/core"))p.transformerName="swc",f=d.get("@swc/core");else if(d.has("sucrase"))p.transformerName="sucrase",f=d.get("sucrase");else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info("Using "+y("rollup ")+Ht),e.info({message:"Using "+y(p.transformerName)+" "+f,prefix:"transformer"})}return p.rollup.resolve&&p.rollup.resolve.preferBuiltins===!0&&(p.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),c.dependencies&&p.externals.push(...Object.keys(c.dependencies)),c.peerDependencies&&p.externals.push(...Object.keys(c.peerDependencies)),c.optionalDependencies&&p.externals.push(...Object.keys(c.optionalDependencies)),Fe(p.alias),p.rollup.alias&&p.rollup.alias.entries&&Fe(p.rollup.alias.entries),p},"generateOptions"),os=k((e,t,o)=>{const n=k(s=>S(t.options.rootDir,g(t.options.outDir,s)),"rPath");let r=!1;for(const s of t.buildEntries.filter(i=>!i.chunk)){let i=s.bytes??0;for(const c of s.chunks??[])i+=t.buildEntries.find(a=>a.path===c)?.bytes??0;let l=` ${D(n(s.path))} (${["total size: "+y(C(i)),s.type!=="asset"&&s.bytes&&"chunk size: "+y(C(s.bytes))].filter(Boolean).join(", ")})`;if(l+=s.exports?.length?`
85
+ exports: `+I(s.exports.join(", ")):"",s.chunks?.length&&(l+=`
86
+ ${s.chunks.map(c=>{const a=t.buildEntries.find(u=>u.path===c)??{};return I(" └─ "+n(c)+D(a.bytes?" ("+C(a?.bytes)+")":""))}).join(`
87
+ `)}`),s.modules&&s.modules.length>0){const c=s.modules.filter(a=>a.id.includes("node_modules")).sort((a,u)=>(u.bytes||0)-(a.bytes||0)).map(a=>I(" 📦 "+n(a.id)+D(a.bytes?" ("+C(a.bytes)+")":""))).join(`
88
88
  `);l+=c.length>0?`
89
89
  inlined modules:
90
- `+c:""}if(t.options.declaration&&i.type==="entry"){let c=i.path.replace(/\.js$/,".d.ts"),a="commonjs";i.path.endsWith(".cjs")?c=i.path.replace(/\.cjs$/,".d.cts"):i.path.endsWith(".mjs")&&(a="module",c=i.path.replace(/\.mjs$/,".d.mts"));const u=t.buildEntries.find(p=>p.path.endsWith(c));if(u){let p;(t.options.declaration===!0||t.options.declaration==="compatible")&&!c.includes(".d.ts")&&(c=c.replace(a==="commonjs"?".d.c":".d.m",".d."),p=t.buildEntries.find(d=>d.path.endsWith(c))),l+=p&&a===o.type?`
90
+ `+c:""}if(t.options.declaration&&s.type==="entry"){let c=s.path.replace(/\.js$/,".d.ts"),a="commonjs";s.path.endsWith(".cjs")?c=s.path.replace(/\.cjs$/,".d.cts"):s.path.endsWith(".mjs")&&(a="module",c=s.path.replace(/\.mjs$/,".d.mts"));const u=t.buildEntries.find(p=>p.path.endsWith(c));if(u){let p;(t.options.declaration===!0||t.options.declaration==="compatible")&&!c.includes(".d.ts")&&(c=c.replace(a==="commonjs"?".d.c":".d.m",".d."),p=t.buildEntries.find(d=>d.path.endsWith(c))),l+=p&&a===o.type?`
91
91
  types:
92
- `+[u,p].map(d=>I(" └─ ")+D(n(d.path))+" (total size: "+h(C(d.bytes??0))+")").join(`
92
+ `+[u,p].map(d=>I(" └─ ")+D(n(d.path))+" (total size: "+y(C(d.bytes??0))+")").join(`
93
93
  `):`
94
- types: `+D(n(u.path))+" (total size: "+h(C(u.bytes??0))+")"}}r=!0,l+=`
94
+ types: `+D(n(u.path))+" (total size: "+y(C(u.bytes??0))+")"}}r=!0,l+=`
95
95
 
96
- `,e.raw(i.chunk?I(l):l)}return r&&e.raw("Σ Total dist size (byte size):",h(C(t.buildEntries.reduce((i,s)=>i+(s.bytes??0),0))),`
97
- `),r},"showSizeInformation"),ni=j(async(e,t,o,n,r,i,s,l,c)=>{const a=qo(s.preset??i.preset??"auto",t),u=ti(e,t,o,n,r,i,s,a,l,c);Ft(b(u.rootDir,u.outDir));const p={buildEntries:[],dependencyGraphMap:new Map,environment:n,hooks:zt(),logger:e,mode:o,options:u,pkg:l,tsconfig:c,usedImports:new Set,warnings:new Set};return a.hooks&&p.hooks.addHooks(a.hooks),i.hooks&&p.hooks.addHooks(i.hooks),s.hooks&&p.hooks.addHooks(s.hooks),await p.hooks.callHook("build:prepare",p),p.options.emitESM===void 0&&p.logger.info("Emitting of ESM bundles, is disabled."),p.options.emitCJS===void 0&&p.logger.info("Emitting of CJS bundles, is disabled."),p},"createContext"),ri=j(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(n=>n.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(n=>o.startsWith(n))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${O(e.options.rootDir,o)}\``),await We(o))},"cleanDistributionDirectories"),ii=j((e,t)=>{const o=Tr(e.options.entries,"environment","runtime"),n=[];for(const[r,i]of Object.entries(o))for(const[s,l]of Object.entries(i)){(r!=="undefined"||s!=="undefined")&&e.logger.info("Preparing build for "+(r==="undefined"?"":h(r)+" environment"+(s==="undefined"?"":" with "))+(s==="undefined"?"":h(s)+" runtime")),e.options.rollup.replace?(e.options.rollup.replace.values={...e.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(r)},s==="edge-light"&&(e.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.");const c=[],a=[],u=[],p=[];for(const d of l)d.cjs&&d.esm?c.push(d):d.cjs?u.push(d):d.esm?a.push(d):d.declaration&&p.push(d);if(c.length>0){const d={...e,options:{...e.options,emitCJS:!0,emitESM:!0,entries:c,minify:r!=="development"&&e.options.minify}};n.push(ne(d,t));const f=d.options.entries.filter(v=>v.declaration);e.options.declaration&&f.length>0&&n.push(q({...d,options:{...d.options,entries:f}},t))}if(a.length>0){const d={...e,options:{...e.options,emitCJS:!1,emitESM:!0,entries:a,minify:r!=="development"&&e.options.minify}};n.push(ne(d,t));const f=d.options.entries.filter(v=>v.declaration);e.options.declaration&&f.length>0&&n.push(q({...d,options:{...d.options,entries:f}},t))}if(u.length>0){const d={...e,options:{...e.options,emitCJS:!0,emitESM:!1,entries:u,minify:r!=="development"&&e.options.minify}};n.push(ne(d,t));const f=d.options.entries.filter(v=>v.declaration);e.options.declaration&&f.length>0&&n.push(q({...d,options:{...d.options,entries:f}},t))}if(e.options.declaration&&p.length>0){const d={...e,options:{...e.options,emitCJS:!1,emitESM:!1,entries:p,minify:r!=="development"&&e.options.minify}};n.push(q(d,t))}}return n},"prepareRollupConfig"),si=j(async(e,t,o)=>{await e.hooks.callHook("build:before",e),e.options.minify&&e.logger.info("Minification is enabled, the output will be minified");const n=t.dependencies?.typescript!==void 0||t.devDependencies?.typescript!==void 0;if(e.options.declaration&&e.tsconfig===void 0&&n)throw new Error("Cannot build declaration files without a tsconfig.json");n?e.options.declaration===!1&&e.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(e.options.declaration=!1,e.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),e.options.declaration&&e.logger.info("Using typescript version: "+h(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.
96
+ `,e.raw(s.chunk?I(l):l)}return r&&e.raw("Σ Total dist size (byte size):",y(C(t.buildEntries.reduce((s,i)=>s+(i.bytes??0),0))),`
97
+ `),r},"showSizeInformation"),ns=k(async(e,t,o,n,r,s,i,l,c)=>{const a=qo(i.preset??s.preset??"auto",t),u=ts(e,t,o,n,r,s,i,a,l,c);Ft(b(u.rootDir,u.outDir));const p={buildEntries:[],dependencyGraphMap:new Map,environment:n,hooks:zt(),logger:e,mode:o,options:u,pkg:l,tsconfig:c,usedImports:new Set,warnings:new Set};return a.hooks&&p.hooks.addHooks(a.hooks),s.hooks&&p.hooks.addHooks(s.hooks),i.hooks&&p.hooks.addHooks(i.hooks),await p.hooks.callHook("build:prepare",p),p.options.emitESM===void 0&&p.logger.info("Emitting of ESM bundles, is disabled."),p.options.emitCJS===void 0&&p.logger.info("Emitting of CJS bundles, is disabled."),p},"createContext"),rs=k(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(n=>n.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(n=>o.startsWith(n))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${S(e.options.rootDir,o)}\``),await We(o))},"cleanDistributionDirectories"),ss=k((e,t)=>{const o=Tr(e.options.entries,"environment","runtime"),n=[];for(const[r,s]of Object.entries(o))for(const[i,l]of Object.entries(s)){(r!=="undefined"||i!=="undefined")&&e.logger.info("Preparing build for "+(r==="undefined"?"":y(r)+" environment"+(i==="undefined"?"":" with "))+(i==="undefined"?"":y(i)+" runtime")),e.options.rollup.replace?(e.options.rollup.replace.values={...e.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(r)},i==="edge-light"&&(e.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.");const c=[],a=[],u=[],p=[];for(const f of l)f.cjs&&f.esm?c.push(f):f.cjs?u.push(f):f.esm?a.push(f):f.declaration&&p.push(f);let d=r!=="development"&&e.options.minify;if(e.options.minify&&(d=!0),c.length>0){const f={...e,options:{...e.options,emitCJS:!0,emitESM:!0,entries:c,minify:d}};n.push(ne(f,t));const h=f.options.entries.filter(w=>w.declaration);e.options.declaration&&h.length>0&&n.push(q({...f,options:{...f.options,entries:h}},t))}if(a.length>0){const f={...e,options:{...e.options,emitCJS:!1,emitESM:!0,entries:a,minify:d}};n.push(ne(f,t));const h=f.options.entries.filter(w=>w.declaration);e.options.declaration&&h.length>0&&n.push(q({...f,options:{...f.options,entries:h}},t))}if(u.length>0){const f={...e,options:{...e.options,emitCJS:!0,emitESM:!1,entries:u,minify:d}};n.push(ne(f,t));const h=f.options.entries.filter(w=>w.declaration);e.options.declaration&&h.length>0&&n.push(q({...f,options:{...f.options,entries:h}},t))}if(e.options.declaration&&p.length>0){const f={...e,options:{...e.options,emitCJS:!1,emitESM:!1,entries:p,minify:d}};n.push(q(f,t))}}return n},"prepareRollupConfig"),is=k(async(e,t,o)=>{await e.hooks.callHook("build:before",e),e.options.minify&&e.logger.info("Minification is enabled, the output will be minified");const n=t.dependencies?.typescript!==void 0||t.devDependencies?.typescript!==void 0;if(e.options.declaration&&e.tsconfig===void 0&&n)throw new Error("Cannot build declaration files without a tsconfig.json");n?e.options.declaration===!1&&e.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(e.options.declaration=!1,e.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),e.options.declaration&&e.logger.info("Using typescript version: "+y(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
98
  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.
99
- 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(ii(e,o)),e.logger.success(Mt(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const i of Tt(b(e.options.rootDir,e.options.outDir))){let s=e.buildEntries.find(l=>b(e.options.rootDir,e.options.outDir,l.path)===i.path);if(s||(s={chunk:!0,path:i.path},e.buildEntries.push(s)),!s.bytes){const l=await Ae(g(e.options.rootDir,e.options.outDir,i.path));s.bytes=l.size}}const r=oi(e.logger,e,t);Vr(e),Qr(t,e),await e.hooks.callHook("build:done",e),xt(e,r)},"build"),qi=j(async(e,t,o,n,r={})=>{const{configPath:i,debug:s,tsconfigPath:l,...c}=r;n.wrapAll(),e=g(Nt(),e),n.debug("Root directory:",e);const a=b(e,"package.json");if(!w(a))throw new Error("package.json not found at "+a);const u=Lt(a);n.debug("Using package.json found at",a);let p;if(l){const d=b(e,l);if(!await At(d))throw new Error("tsconfig.json not found at "+d);p={config:Wt(d),path:d},n.info("Using tsconfig settings at",d)}else if(u.dependencies?.typescript||u.devDependencies?.typescript)try{p=await Bt(e),n.debug("Using tsconfig settings found at",p.path)}catch{n.info("No tsconfig.json or jsconfig.json found.")}try{let d=i??"";if(!d){const P=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const E of P)if(w(b(e,E))){d="./"+E;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(d))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");let f=Ye(d,e);typeof f=="function"&&(f=f(o,t)),n.debug("Using packem config found at",b(e,d));const v=Date.now(),S=j(()=>Jt(Math.floor(Date.now()-v)),"getDuration"),B=M(JSON.stringify({version:u.version,...u.dependencies,...u.devDependencies,...u.peerDependencies,...u.peerDependenciesMeta,browser:u.browser,eNode:u.engines?.node,exports:u.exports,main:u.main,module:u.module,type:u.type,types:u.types})),k=new Pr(e,B,n);k.cachePath&&!w(b(k.cachePath,B))&&w(k.cachePath)&&(n.info("Clearing file cache because the cache key has changed."),await We(k.cachePath));const y=await ni(n,e,t,o,s??!1,c,f,u,p);if(k.isEnabled=y.options.fileCache,await Lr(y,e),y.logger.info(h((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+y.options.name)),y.logger.debug(`${D("Root dir:")} ${y.options.rootDir}
99
+ 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(ss(e,o)),e.logger.success(Mt(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const s of Tt(b(e.options.rootDir,e.options.outDir))){let i=e.buildEntries.find(l=>b(e.options.rootDir,e.options.outDir,l.path)===s.path);if(i||(i={chunk:!0,path:s.path},e.buildEntries.push(i)),!i.bytes){const l=await Ae(g(e.options.rootDir,e.options.outDir,s.path));i.bytes=l.size}}const r=os(e.logger,e,t);Vr(e),Qr(t,e),await e.hooks.callHook("build:done",e),xt(e,r)},"build"),qs=k(async(e,t,o,n,r={})=>{const{configPath:s,debug:i,tsconfigPath:l,...c}=r;n.wrapAll(),e=g(Nt(),e),n.debug("Root directory:",e);const a=b(e,"package.json");if(!j(a))throw new Error("package.json not found at "+a);const u=Lt(a);n.debug("Using package.json found at",a);let p;if(l){const d=b(e,l);if(!await At(d))throw new Error("tsconfig.json not found at "+d);p={config:Wt(d),path:d},n.info("Using tsconfig settings at",d)}else if(u.dependencies?.typescript||u.devDependencies?.typescript)try{p=await Bt(e),n.debug("Using tsconfig settings found at",p.path)}catch{n.info("No tsconfig.json or jsconfig.json found.")}try{let d=s??"";if(!d){const P=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const O of P)if(j(b(e,O))){d="./"+O;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(d))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");let f=Ye(d,e);typeof f=="function"&&(f=f(o,t)),n.debug("Using packem config found at",b(e,d));const h=Date.now(),w=k(()=>Jt(Math.floor(Date.now()-h)),"getDuration"),B=M(JSON.stringify({version:u.version,...u.dependencies,...u.devDependencies,...u.peerDependencies,...u.peerDependenciesMeta,browser:u.browser,eNode:u.engines?.node,exports:u.exports,main:u.main,module:u.module,type:u.type,types:u.types})),x=new Pr(e,B,n);x.cachePath&&!j(b(x.cachePath,B))&&j(x.cachePath)&&(n.info("Clearing file cache because the cache key has changed."),await We(x.cachePath));const v=await ns(n,e,t,o,i??!1,c,f,u,p);if(x.isEnabled=v.options.fileCache,await Lr(v,e),v.logger.info(y((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+v.options.name)),v.logger.debug(`${D("Root dir:")} ${v.options.rootDir}
100
100
  ${D("Entries:")}
101
- ${y.options.entries.map(P=>` ${me(P)}`).join(`
102
- `)}`),await ri(y),y.options.stub){await Oo(y),await y.hooks.callHook("build:done",y);return}if(t==="watch"){if(y.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await Dr(y,k),xt(y,!1);return}await si(y,u,k),n.raw(`
103
- ⚡️ Build run in `+S()),n.restoreAll()}catch(d){throw n.raw(`
104
- `),$t(d),d}},"createBundler");export{qi as default};
101
+ ${v.options.entries.map(P=>` ${me(P)}`).join(`
102
+ `)}`),await rs(v),v.options.stub){await Oo(v),await v.hooks.callHook("build:done",v);return}if(t==="watch"){if(v.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await Dr(v,x),xt(v,!1);return}await is(v,u,x),n.raw(`
103
+ ⚡️ Build run in `+w()),n.restoreAll()}catch(d){throw n.raw(`
104
+ `),$t(d),d}},"createBundler");export{qs as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/packem",
3
- "version": "1.0.0-alpha.79",
3
+ "version": "1.0.0-alpha.80",
4
4
  "description": "A fast and modern bundler for Node.js and TypeScript.",
5
5
  "keywords": [
6
6
  "anolilab",