pkgroll 1.0.3 → 1.1.0

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # pkgroll
1
+ # 📦 🍣 pkgroll
2
2
 
3
3
  Write your code in ESM & TypeScript and bundle it to get ESM, CommonJS, and type declaration outputs with a single command!
4
4
 
@@ -18,7 +18,11 @@ npm install --save-dev pkgroll
18
18
  ## Quick setup
19
19
  1. Setup your project with source files in `src` and output in `dist` (configurable).
20
20
 
21
- 2. Specify output files in `package.json`:
21
+ 2. Define package entry-files in `package.json`.
22
+
23
+ [These configurations](https://nodejs.org/api/packages.html#package-entry-points) are for Node.js to determine how to import the package.
24
+
25
+ Pkgroll leverages the same configuration to determine how to build the package.
22
26
 
23
27
  ```json5
24
28
  {
@@ -177,10 +181,17 @@ Because _pkgroll_ uses Rollup, it's able to produce CJS modules that are minimal
177
181
  This means you can technically output in CommonJS to get ESM and CommonJS support.
178
182
 
179
183
  #### `require()` in ESM
180
- Sometimes it's useful to use `require()` or `require.resolve()` in ESM. This can be seamlessly compiled to CommonJS. But when compiling to ESM, Node.js will error because `require` doesn't exist in the module scope.
184
+ Sometimes it's useful to use `require()` or `require.resolve()` in ESM. ESM code that uses `require()` can be seamlessly compiled to CommonJS, but when compiling to ESM, Node.js will error because `require` doesn't exist in the module scope.
181
185
 
182
186
  When compiling to ESM, _Pkgroll_ detects `require()` usages and shims it with [`createRequire(import.meta.url)`](https://nodejs.org/api/module.html#modulecreaterequirefilename).
183
187
 
188
+ ### Environment variables
189
+ Pass in compile-time environment variables with the `--env` flag.
190
+
191
+ This will replace all instances of `process.env.NODE_ENV` with `'production'` and remove unused code:
192
+ ```sh
193
+ pkgroll --env.NODE_ENV=production
194
+ ```
184
195
 
185
196
  ### Minification
186
197
  Pass in the `--minify` flag to minify assets.
package/dist/cli.js CHANGED
@@ -1,33 +1,33 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var fs$1=require("fs"),require$$1=require("tty"),rollup=require("rollup"),path$1=require("path"),nodeResolve=require("@rollup/plugin-node-resolve"),commonjs=require("@rollup/plugin-commonjs"),json=require("@rollup/plugin-json"),alias=require("@rollup/plugin-alias"),replace=require("@rollup/plugin-replace"),inject=require("@rollup/plugin-inject"),pluginutils=require("@rollup/pluginutils"),esbuild=require("esbuild"),require$$2=require("module"),MagicString=require("magic-string");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var fs__default$1=_interopDefaultLegacy(fs$1),require$$1__default=_interopDefaultLegacy(require$$1),path__default$1=_interopDefaultLegacy(path$1),nodeResolve__default=_interopDefaultLegacy(nodeResolve),commonjs__default=_interopDefaultLegacy(commonjs),json__default=_interopDefaultLegacy(json),alias__default=_interopDefaultLegacy(alias),replace__default=_interopDefaultLegacy(replace),inject__default=_interopDefaultLegacy(inject),MagicString__default=_interopDefaultLegacy(MagicString);function commonjsRequire(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var m$1=Object.defineProperty,I$2=Object.getOwnPropertyDescriptor,D$1=Object.getOwnPropertyNames,K$2=Object.prototype.hasOwnProperty,L$2=e=>m$1(e,"__esModule",{value:!0}),M$1=(e,t)=>{for(var r in t)m$1(e,r,{get:t[r],enumerable:!0})},R$2=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of D$1(t))!K$2.call(e,o)&&(r||o!=="default")&&m$1(e,o,{get:()=>t[o],enumerable:!(n=I$2(t,o))||n.enumerable});return e},z$2=(e=>(t,r)=>e&&e.get(t)||(r=R$2(L$2({}),t,1),e&&e.set(t,r),r))(typeof WeakMap!="undefined"?new WeakMap:0),X$2={};M$1(X$2,{default:()=>j$2});var P$2=/-(\w)/g,A$1=e=>e.replace(P$2,(t,r)=>r.toUpperCase()),$$1=/\B([A-Z])/g,B$1=e=>e.replace($$1,"-$1").toLowerCase(),{stringify:u}=JSON,{hasOwnProperty:U$2}=Object.prototype,F=(e,t)=>U$2.call(e,t),W$2=/^--?/,q$2=/[.:=]/,C=e=>{let t=e.replace(W$2,""),r,n=t.match(q$2);if(n!=null&&n.index){let o=n.index;r=t.slice(o+1),t=t.slice(0,o)}return{flagName:t,flagValue:r}},G$2=/[\s.:=]/,J$2=(e,t)=>{let r=`Invalid flag name ${u(t)}:`;if(t.length===0)throw new Error(`${r} flag name cannot be empty}`);if(t.length===1)throw new Error(`${r} single characters are reserved for aliases`);let n=t.match(G$2);if(n)throw new Error(`${r} flag name cannot contain the character ${u(n==null?void 0:n[0])}`);let o;if(P$2.test(t)?o=A$1(t):$$1.test(t)&&(o=B$1(t)),o&&F(e,o))throw new Error(`${r} collides with flag ${u(o)}`)};function E$1(e){let t=new Map;for(let r in e){if(!F(e,r))continue;J$2(e,r);let n=e[r];if(n&&typeof n=="object"){let{alias:o}=n;if(typeof o=="string"){if(o.length===0)throw new Error(`Invalid flag alias ${u(r)}: flag alias cannot be empty`);if(o.length>1)throw new Error(`Invalid flag alias ${u(r)}: flag aliases can only be a single-character`);if(t.has(o))throw new Error(`Flag collision: Alias "${o}" is already used`);t.set(o,{name:r,schema:n})}}}return t}var Z$2=e=>!e||typeof e=="function"?!1:Array.isArray(e)||Array.isArray(e.type),v$2=e=>{let t={};for(let r in e)F(e,r)&&(t[r]=Z$2(e[r])?[]:void 0);return t},h$2=(e,t)=>e===Number&&t===""?Number.NaN:e===Boolean?t!=="false":t,_$2=(e,t)=>{for(let r in e){if(!F(e,r))continue;let n=e[r];if(!n)continue;let o=t[r];if(!(o!==void 0&&!(Array.isArray(o)&&o.length===0))&&"default"in n){let a=n.default;typeof a=="function"&&(a=a()),t[r]=a}}},x$2=(e,t)=>{if(!t)throw new Error(`Missing type on flag "${e}"`);return typeof t=="function"?t:Array.isArray(t)?t[0]:x$2(e,t.type)},H$1=/^-[\da-z]+/i,Q$2=/^--[\w-]{2,}/,S$2="--";function j$2(e,t=process.argv.slice(2)){let r=E$1(e),n={flags:v$2(e),unknownFlags:{},_:Object.assign([],{[S$2]:[]})},o,a=(g,l,Du)=>{let uu=x$2(g,l);Du=h$2(uu,Du),Du!==void 0&&!Number.isNaN(Du)?Array.isArray(n.flags[g])?n.flags[g].push(uu(Du)):n.flags[g]=uu(Du):o=eu=>{Array.isArray(n.flags[g])?n.flags[g].push(uu(h$2(uu,eu||""))):n.flags[g]=uu(h$2(uu,eu||"")),o=void 0}},s=(g,l)=>{g in n.unknownFlags||(n.unknownFlags[g]=[]),l!==void 0?n.unknownFlags[g].push(l):o=(Du=!0)=>{n.unknownFlags[g].push(Du),o=void 0}};for(let g=0;g<t.length;g+=1){let l=t[g];if(l===S$2){let uu=t.slice(g+1);n._[S$2]=uu,n._.push(...uu);break}let Du=H$1.test(l);if(Q$2.test(l)||Du){o&&o();let uu=C(l),{flagValue:eu}=uu,{flagName:tu}=uu;if(Du){for(let nu=0;nu<tu.length;nu+=1){let lu=tu[nu],Cu=r.get(lu),su=nu===tu.length-1;Cu?a(Cu.name,Cu.schema,su?eu:!0):s(lu,su?eu:!0)}continue}let ou=e[tu];if(!ou){let nu=A$1(tu);ou=e[nu],ou&&(tu=nu)}if(!ou){s(tu,eu);continue}a(tu,ou,eu)}else o?o(l):n._.push(l)}return o&&o(),_$2(e,n.flags),n}var dist$3=z$2(X$2),CD=Object.create,p$1=Object.defineProperty,tD=Object.defineProperties,eD=Object.getOwnPropertyDescriptor,ED=Object.getOwnPropertyDescriptors,nD=Object.getOwnPropertyNames,I$1=Object.getOwnPropertySymbols,rD=Object.getPrototypeOf,L$1=Object.prototype.hasOwnProperty,iD=Object.prototype.propertyIsEnumerable,T$1=(e,t,r)=>t in e?p$1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,c=(e,t)=>{for(var r in t||(t={}))L$1.call(t,r)&&T$1(e,r,t[r]);if(I$1)for(var r of I$1(t))iD.call(t,r)&&T$1(e,r,t[r]);return e},d=(e,t)=>tD(e,ED(t)),W$1=e=>p$1(e,"__esModule",{value:!0}),oD=(e,t)=>()=>(e&&(t=e(e=0)),t),BD=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),sD=(e,t)=>{for(var r in t)p$1(e,r,{get:t[r],enumerable:!0})},v$1=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of nD(t))!L$1.call(e,o)&&(r||o!=="default")&&p$1(e,o,{get:()=>t[o],enumerable:!(n=eD(t,o))||n.enumerable});return e},aD=(e,t)=>v$1(W$1(p$1(e!=null?CD(rD(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),lD=(e=>(t,r)=>e&&e.get(t)||(r=v$1(W$1({}),t,1),e&&e.set(t,r),r))(typeof WeakMap!="undefined"?new WeakMap:0),i=oD(()=>{}),j$1=BD((e,t)=>{i(),t.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}}),RD={};sD(RD,{breakpoints:()=>FD,default:()=>uD}),i(),i(),i();var N$1=e=>{var t,r,n;let o=(t=process.stdout.columns)!=null?t:Number.POSITIVE_INFINITY;return typeof e=="function"&&(e=e(o)),e||(e={}),Array.isArray(e)?{columns:e,stdoutColumns:o}:{columns:(r=e.columns)!=null?r:[],stdoutColumns:(n=e.stdoutColumns)!=null?n:o}};i(),i(),i(),i(),i();function x$1({onlyFirst:e=!1}={}){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}function h$1(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(x$1(),"")}i();function w(e){return Number.isInteger(e)?e>=4352&&(e<=4447||e===9001||e===9002||11904<=e&&e<=12871&&e!==12351||12880<=e&&e<=19903||19968<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65131||65281<=e&&e<=65376||65504<=e&&e<=65510||110592<=e&&e<=110593||127488<=e&&e<=127569||131072<=e&&e<=262141):!1}var k=aD(j$1(),1);function f$1(e){if(typeof e!="string"||e.length===0||(e=h$1(e),e.length===0))return 0;e=e.replace((0,k.default)()," ");let t=0;for(let r=0;r<e.length;r++){let n=e.codePointAt(r);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&r++,t+=w(n)?2:1)}return t}var m=e=>Math.max(...e.split(`
3
- `).map(f$1)),_$1=e=>{let t=[];for(let r of e){let{length:n}=r,o=n-t.length;for(let a=0;a<o;a+=1)t.push(0);for(let a=0;a<n;a+=1){let s=m(r[a]);s>t[a]&&(t[a]=s)}}return t};i();var z$1=/^\d+%$/,U$1={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},AD=(e,t)=>{var r;let n=[];for(let o=0;o<e.length;o+=1){let a=(r=t[o])!=null?r:"auto";if(typeof a=="number"||a==="auto"||a==="content-width"||typeof a=="string"&&z$1.test(a)){n.push(d(c({},U$1),{width:a,contentWidth:e[o]}));continue}if(a&&typeof a=="object"){let s=d(c(c({},U$1),a),{contentWidth:e[o]});s.horizontalPadding=s.paddingLeft+s.paddingRight,n.push(s);continue}throw new Error(`Invalid column width: ${JSON.stringify(a)}`)}return n};function fD(e,t){for(let r of e){let{width:n}=r;if(n==="content-width"&&(r.width=r.contentWidth),n==="auto"){let l=Math.min(20,r.contentWidth);r.width=l,r.autoOverflow=r.contentWidth-l}if(typeof n=="string"&&z$1.test(n)){let l=Number.parseFloat(n.slice(0,-1))/100;r.width=Math.floor(t*l)-(r.paddingLeft+r.paddingRight)}let{horizontalPadding:o}=r,a=1,s=a+o;if(s>=t){let l=s-t,Du=Math.ceil(r.paddingLeft/o*l),uu=l-Du;r.paddingLeft-=Du,r.paddingRight-=uu,r.horizontalPadding=r.paddingLeft+r.paddingRight}r.paddingLeftString=r.paddingLeft?" ".repeat(r.paddingLeft):"",r.paddingRightString=r.paddingRight?" ".repeat(r.paddingRight):"";let g=t-r.horizontalPadding;r.width=Math.max(Math.min(r.width,g),a)}}var G$1=()=>Object.assign([],{columns:0});function cD(e,t){let r=[G$1()],[n]=r;for(let o of e){let a=o.width+o.horizontalPadding;n.columns+a>t&&(n=G$1(),r.push(n)),n.push(o),n.columns+=a}for(let o of r){let a=o.reduce((tu,ou)=>tu+ou.width+ou.horizontalPadding,0),s=t-a;if(s===0)continue;let g=o.filter(tu=>"autoOverflow"in tu),l=g.filter(tu=>tu.autoOverflow>0),Du=l.reduce((tu,ou)=>tu+ou.autoOverflow,0),uu=Math.min(Du,s);for(let tu of l){let ou=Math.floor(tu.autoOverflow/Du*uu);tu.width+=ou,s-=ou}let eu=Math.floor(s/g.length);for(let tu=0;tu<g.length;tu+=1){let ou=g[tu];tu===g.length-1?ou.width+=s:ou.width+=eu,s-=eu}}return r}function Z$1(e,t,r){let n=AD(r,t);return fD(n,e),cD(n,e)}i(),i(),i();var y=10,V$1=(e=0)=>t=>`\x1B[${t+e}m`,Y$1=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,K$1=(e=0)=>(t,r,n)=>`\x1B[${38+e};2;${t};${r};${n}m`;function gD(){let e=new Map,t={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};t.color.gray=t.color.blackBright,t.bgColor.bgGray=t.bgColor.bgBlackBright,t.color.grey=t.color.blackBright,t.bgColor.bgGrey=t.bgColor.bgBlackBright;for(let[r,n]of Object.entries(t)){for(let[o,a]of Object.entries(n))t[o]={open:`\x1B[${a[0]}m`,close:`\x1B[${a[1]}m`},n[o]=t[o],e.set(a[0],a[1]);Object.defineProperty(t,r,{value:n,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",t.color.ansi=V$1(),t.color.ansi256=Y$1(),t.color.ansi16m=K$1(),t.bgColor.ansi=V$1(y),t.bgColor.ansi256=Y$1(y),t.bgColor.ansi16m=K$1(y),Object.defineProperties(t,{rgbToAnsi256:{value:(r,n,o)=>r===n&&n===o?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(n/255*5)+Math.round(o/255*5),enumerable:!1},hexToRgb:{value:r=>{let n=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(r.toString(16));if(!n)return[0,0,0];let{colorString:o}=n.groups;o.length===3&&(o=o.split("").map(s=>s+s).join(""));let a=Number.parseInt(o,16);return[a>>16&255,a>>8&255,a&255]},enumerable:!1},hexToAnsi256:{value:r=>t.rgbToAnsi256(...t.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value:r=>{if(r<8)return 30+r;if(r<16)return 90+(r-8);let n,o,a;if(r>=232)n=((r-232)*10+8)/255,o=n,a=n;else{r-=16;let l=r%36;n=Math.floor(r/36)/5,o=Math.floor(l/6)/5,a=l%6/5}let s=Math.max(n,o,a)*2;if(s===0)return 30;let g=30+(Math.round(a)<<2|Math.round(o)<<1|Math.round(n));return s===2&&(g+=60),g},enumerable:!1},rgbToAnsi:{value:(r,n,o)=>t.ansi256ToAnsi(t.rgbToAnsi256(r,n,o)),enumerable:!1},hexToAnsi:{value:r=>t.ansi256ToAnsi(t.hexToAnsi256(r)),enumerable:!1}}),t}var pD=gD(),q$1=pD,b$1=new Set(["\x1B","\x9B"]),dD=39,R$1="\x07",H="[",hD="]",J$1="m",O$1=`${hD}8;;`,Q$1=e=>`${b$1.values().next().value}${H}${e}${J$1}`,X$1=e=>`${b$1.values().next().value}${O$1}${e}${R$1}`,mD=e=>e.split(" ").map(t=>f$1(t)),M=(e,t,r)=>{let n=[...t],o=!1,a=!1,s=f$1(h$1(e[e.length-1]));for(let[g,l]of n.entries()){let Du=f$1(l);if(s+Du<=r?e[e.length-1]+=l:(e.push(l),s=0),b$1.has(l)&&(o=!0,a=n.slice(g+1).join("").startsWith(O$1)),o){a?l===R$1&&(o=!1,a=!1):l===J$1&&(o=!1);continue}s+=Du,s===r&&g<n.length-1&&(e.push(""),s=0)}!s&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},bD=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(f$1(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},xD=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",o,a,s=mD(e),g=[""];for(let[Du,uu]of e.split(" ").entries()){r.trim!==!1&&(g[g.length-1]=g[g.length-1].trimStart());let eu=f$1(g[g.length-1]);if(Du!==0&&(eu>=t&&(r.wordWrap===!1||r.trim===!1)&&(g.push(""),eu=0),(eu>0||r.trim===!1)&&(g[g.length-1]+=" ",eu++)),r.hard&&s[Du]>t){let tu=t-eu,ou=1+Math.floor((s[Du]-tu-1)/t);Math.floor((s[Du]-1)/t)<ou&&g.push(""),M(g,uu,t);continue}if(eu+s[Du]>t&&eu>0&&s[Du]>0){if(r.wordWrap===!1&&eu<t){M(g,uu,t);continue}g.push("")}if(eu+s[Du]>t&&r.wordWrap===!1){M(g,uu,t);continue}g[g.length-1]+=uu}r.trim!==!1&&(g=g.map(Du=>bD(Du)));let l=[...g.join(`
4
- `)];for(let[Du,uu]of l.entries()){if(n+=uu,b$1.has(uu)){let{groups:tu}=new RegExp(`(?:\\${H}(?<code>\\d+)m|\\${O$1}(?<uri>.*)${R$1})`).exec(l.slice(Du).join(""))||{groups:{}};if(tu.code!==void 0){let ou=Number.parseFloat(tu.code);o=ou===dD?void 0:ou}else tu.uri!==void 0&&(a=tu.uri.length===0?void 0:tu.uri)}let eu=q$1.codes.get(Number(o));l[Du+1]===`
5
- `?(a&&(n+=X$1("")),o&&eu&&(n+=Q$1(eu))):uu===`
6
- `&&(o&&eu&&(n+=Q$1(o)),a&&(n+=X$1(a)))}return n};function S$1(e,t,r){return String(e).normalize().replace(/\r\n/g,`
2
+ "use strict";var xD=require("fs"),kD=require("tty"),Bu=require("rollup"),SD=require("path"),TD=require("@rollup/plugin-node-resolve"),ND=require("@rollup/plugin-commonjs"),ID=require("@rollup/plugin-json"),MD=require("@rollup/plugin-alias"),RD=require("@rollup/plugin-replace"),LD=require("@rollup/plugin-inject"),qD=require("@rollup/pluginutils"),bu=require("esbuild"),WD=require("module"),UD=require("magic-string");function O(u){return u&&typeof u=="object"&&"default"in u?u:{default:u}}var P=O(xD),VD=O(kD),x=O(SD),zD=O(TD),GD=O(ND),ZD=O(ID),JD=O(MD),yu=O(RD),YD=O(LD),HD=O(UD);function KD(u){throw new Error('Could not dynamically require "'+u+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var eu={},tu=Object.defineProperty,QD=Object.getOwnPropertyDescriptor,XD=Object.getOwnPropertyNames,ue=Object.prototype.hasOwnProperty,De=u=>tu(u,"__esModule",{value:!0}),ee=(u,D)=>{for(var e in D)tu(u,e,{get:D[e],enumerable:!0})},te=(u,D,e,t)=>{if(D&&typeof D=="object"||typeof D=="function")for(let r of XD(D))!ue.call(u,r)&&(e||r!=="default")&&tu(u,r,{get:()=>D[r],enumerable:!(t=QD(D,r))||t.enumerable});return u},re=(u=>(D,e)=>u&&u.get(D)||(e=te(De({}),D,1),u&&u.set(D,e),e))(typeof WeakMap!="undefined"?new WeakMap:0),Au={};ee(Au,{default:()=>ge});var vu=/-(\w)/g,wu=u=>u.replace(vu,(D,e)=>e.toUpperCase()),$u=/\B([A-Z])/g,ne=u=>u.replace($u,"-$1").toLowerCase(),{stringify:L}=JSON,{hasOwnProperty:oe}=Object.prototype,J=(u,D)=>oe.call(u,D),ae=/^--?/,ie=/[.:=]/,se=u=>{let D=u.replace(ae,""),e,t=D.match(ie);if(t!=null&&t.index){let r=t.index;e=D.slice(r+1),D=D.slice(0,r)}return{flagName:D,flagValue:e}},le=/[\s.:=]/,Fe=(u,D)=>{let e=`Invalid flag name ${L(D)}:`;if(D.length===0)throw new Error(`${e} flag name cannot be empty}`);if(D.length===1)throw new Error(`${e} single characters are reserved for aliases`);let t=D.match(le);if(t)throw new Error(`${e} flag name cannot contain the character ${L(t==null?void 0:t[0])}`);let r;if(vu.test(D)?r=wu(D):$u.test(D)&&(r=ne(D)),r&&J(u,r))throw new Error(`${e} collides with flag ${L(r)}`)};function ce(u){let D=new Map;for(let e in u){if(!J(u,e))continue;Fe(u,e);let t=u[e];if(t&&typeof t=="object"){let{alias:r}=t;if(typeof r=="string"){if(r.length===0)throw new Error(`Invalid flag alias ${L(e)}: flag alias cannot be empty`);if(r.length>1)throw new Error(`Invalid flag alias ${L(e)}: flag aliases can only be a single-character`);if(D.has(r))throw new Error(`Flag collision: Alias "${r}" is already used`);D.set(r,{name:e,schema:t})}}}return D}var Ce=u=>!u||typeof u=="function"?!1:Array.isArray(u)||Array.isArray(u.type),fe=u=>{let D={};for(let e in u)J(u,e)&&(D[e]=Ce(u[e])?[]:void 0);return D},ru=(u,D)=>u===Number&&D===""?Number.NaN:u===Boolean?D!=="false":D,pe=(u,D)=>{for(let e in u){if(!J(u,e))continue;let t=u[e];if(!t)continue;let r=D[e];if(!(r!==void 0&&!(Array.isArray(r)&&r.length===0))&&"default"in t){let n=t.default;typeof n=="function"&&(n=n()),D[e]=n}}},Ou=(u,D)=>{if(!D)throw new Error(`Missing type on flag "${u}"`);return typeof D=="function"?D:Array.isArray(D)?D[0]:Ou(u,D.type)},de=/^-[\da-z]+/i,Ee=/^--[\w-]{2,}/,nu="--";function ge(u,D=process.argv.slice(2)){let e=ce(u),t={flags:fe(u),unknownFlags:{},_:Object.assign([],{[nu]:[]})},r,n=(i,a,s)=>{let l=Ou(i,a);s=ru(l,s),s!==void 0&&!Number.isNaN(s)?Array.isArray(t.flags[i])?t.flags[i].push(l(s)):t.flags[i]=l(s):r=F=>{Array.isArray(t.flags[i])?t.flags[i].push(l(ru(l,F||""))):t.flags[i]=l(ru(l,F||"")),r=void 0}},o=(i,a)=>{i in t.unknownFlags||(t.unknownFlags[i]=[]),a!==void 0?t.unknownFlags[i].push(a):r=(s=!0)=>{t.unknownFlags[i].push(s),r=void 0}};for(let i=0;i<D.length;i+=1){let a=D[i];if(a===nu){let l=D.slice(i+1);t._[nu]=l,t._.push(...l);break}let s=de.test(a);if(Ee.test(a)||s){r&&r();let l=se(a),{flagValue:F}=l,{flagName:c}=l;if(s){for(let p=0;p<c.length;p+=1){let E=c[p],B=e.get(E),g=p===c.length-1;B?n(B.name,B.schema,g?F:!0):o(E,g?F:!0)}continue}let f=u[c];if(!f){let p=wu(c);f=u[p],f&&(c=p)}if(!f){o(c,F);continue}n(c,f,F)}else r?r(a):t._.push(a)}return r&&r(),pe(u,t.flags),t}var he=re(Au),me=Object.create,q=Object.defineProperty,Be=Object.defineProperties,be=Object.getOwnPropertyDescriptor,ye=Object.getOwnPropertyDescriptors,Ae=Object.getOwnPropertyNames,ju=Object.getOwnPropertySymbols,ve=Object.getPrototypeOf,_u=Object.prototype.hasOwnProperty,we=Object.prototype.propertyIsEnumerable,Pu=(u,D,e)=>D in u?q(u,D,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[D]=e,Y=(u,D)=>{for(var e in D||(D={}))_u.call(D,e)&&Pu(u,e,D[e]);if(ju)for(var e of ju(D))we.call(D,e)&&Pu(u,e,D[e]);return u},ou=(u,D)=>Be(u,ye(D)),xu=u=>q(u,"__esModule",{value:!0}),$e=(u,D)=>()=>(u&&(D=u(u=0)),D),Oe=(u,D)=>()=>(D||u((D={exports:{}}).exports,D),D.exports),je=(u,D)=>{for(var e in D)q(u,e,{get:D[e],enumerable:!0})},ku=(u,D,e,t)=>{if(D&&typeof D=="object"||typeof D=="function")for(let r of Ae(D))!_u.call(u,r)&&(e||r!=="default")&&q(u,r,{get:()=>D[r],enumerable:!(t=be(D,r))||t.enumerable});return u},_e=(u,D)=>ku(xu(q(u!=null?me(ve(u)):{},"default",!D&&u&&u.__esModule?{get:()=>u.default,enumerable:!0}:{value:u,enumerable:!0})),u),Pe=(u=>(D,e)=>u&&u.get(D)||(e=ku(xu({}),D,1),u&&u.set(D,e),e))(typeof WeakMap!="undefined"?new WeakMap:0),v=$e(()=>{}),xe=Oe((u,D)=>{v(),D.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}}),Su={};je(Su,{breakpoints:()=>Dt,default:()=>Qe}),v(),v(),v();var ke=u=>{var D,e,t;let r=(D=process.stdout.columns)!=null?D:Number.POSITIVE_INFINITY;return typeof u=="function"&&(u=u(r)),u||(u={}),Array.isArray(u)?{columns:u,stdoutColumns:r}:{columns:(e=u.columns)!=null?e:[],stdoutColumns:(t=u.stdoutColumns)!=null?t:r}};v(),v(),v(),v(),v();function Se({onlyFirst:u=!1}={}){let D=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(D,u?void 0:"g")}function Tu(u){if(typeof u!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof u}\``);return u.replace(Se(),"")}v();function Te(u){return Number.isInteger(u)?u>=4352&&(u<=4447||u===9001||u===9002||11904<=u&&u<=12871&&u!==12351||12880<=u&&u<=19903||19968<=u&&u<=42182||43360<=u&&u<=43388||44032<=u&&u<=55203||63744<=u&&u<=64255||65040<=u&&u<=65049||65072<=u&&u<=65131||65281<=u&&u<=65376||65504<=u&&u<=65510||110592<=u&&u<=110593||127488<=u&&u<=127569||131072<=u&&u<=262141):!1}var Ne=_e(xe(),1);function k(u){if(typeof u!="string"||u.length===0||(u=Tu(u),u.length===0))return 0;u=u.replace((0,Ne.default)()," ");let D=0;for(let e=0;e<u.length;e++){let t=u.codePointAt(e);t<=31||t>=127&&t<=159||t>=768&&t<=879||(t>65535&&e++,D+=Te(t)?2:1)}return D}var Nu=u=>Math.max(...u.split(`
3
+ `).map(k)),Ie=u=>{let D=[];for(let e of u){let{length:t}=e,r=t-D.length;for(let n=0;n<r;n+=1)D.push(0);for(let n=0;n<t;n+=1){let o=Nu(e[n]);o>D[n]&&(D[n]=o)}}return D};v();var Iu=/^\d+%$/,Mu={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},Me=(u,D)=>{var e;let t=[];for(let r=0;r<u.length;r+=1){let n=(e=D[r])!=null?e:"auto";if(typeof n=="number"||n==="auto"||n==="content-width"||typeof n=="string"&&Iu.test(n)){t.push(ou(Y({},Mu),{width:n,contentWidth:u[r]}));continue}if(n&&typeof n=="object"){let o=ou(Y(Y({},Mu),n),{contentWidth:u[r]});o.horizontalPadding=o.paddingLeft+o.paddingRight,t.push(o);continue}throw new Error(`Invalid column width: ${JSON.stringify(n)}`)}return t};function Re(u,D){for(let e of u){let{width:t}=e;if(t==="content-width"&&(e.width=e.contentWidth),t==="auto"){let a=Math.min(20,e.contentWidth);e.width=a,e.autoOverflow=e.contentWidth-a}if(typeof t=="string"&&Iu.test(t)){let a=Number.parseFloat(t.slice(0,-1))/100;e.width=Math.floor(D*a)-(e.paddingLeft+e.paddingRight)}let{horizontalPadding:r}=e,n=1,o=n+r;if(o>=D){let a=o-D,s=Math.ceil(e.paddingLeft/r*a),l=a-s;e.paddingLeft-=s,e.paddingRight-=l,e.horizontalPadding=e.paddingLeft+e.paddingRight}e.paddingLeftString=e.paddingLeft?" ".repeat(e.paddingLeft):"",e.paddingRightString=e.paddingRight?" ".repeat(e.paddingRight):"";let i=D-e.horizontalPadding;e.width=Math.max(Math.min(e.width,i),n)}}var Ru=()=>Object.assign([],{columns:0});function Le(u,D){let e=[Ru()],[t]=e;for(let r of u){let n=r.width+r.horizontalPadding;t.columns+n>D&&(t=Ru(),e.push(t)),t.push(r),t.columns+=n}for(let r of e){let n=r.reduce((c,f)=>c+f.width+f.horizontalPadding,0),o=D-n;if(o===0)continue;let i=r.filter(c=>"autoOverflow"in c),a=i.filter(c=>c.autoOverflow>0),s=a.reduce((c,f)=>c+f.autoOverflow,0),l=Math.min(s,o);for(let c of a){let f=Math.floor(c.autoOverflow/s*l);c.width+=f,o-=f}let F=Math.floor(o/i.length);for(let c=0;c<i.length;c+=1){let f=i[c];c===i.length-1?f.width+=o:f.width+=F,o-=F}}return e}function qe(u,D,e){let t=Me(e,D);return Re(t,u),Le(t,u)}v(),v(),v();var au=10,Lu=(u=0)=>D=>`\x1B[${D+u}m`,qu=(u=0)=>D=>`\x1B[${38+u};5;${D}m`,Wu=(u=0)=>(D,e,t)=>`\x1B[${38+u};2;${D};${e};${t}m`;function We(){let u=new Map,D={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};D.color.gray=D.color.blackBright,D.bgColor.bgGray=D.bgColor.bgBlackBright,D.color.grey=D.color.blackBright,D.bgColor.bgGrey=D.bgColor.bgBlackBright;for(let[e,t]of Object.entries(D)){for(let[r,n]of Object.entries(t))D[r]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},t[r]=D[r],u.set(n[0],n[1]);Object.defineProperty(D,e,{value:t,enumerable:!1})}return Object.defineProperty(D,"codes",{value:u,enumerable:!1}),D.color.close="\x1B[39m",D.bgColor.close="\x1B[49m",D.color.ansi=Lu(),D.color.ansi256=qu(),D.color.ansi16m=Wu(),D.bgColor.ansi=Lu(au),D.bgColor.ansi256=qu(au),D.bgColor.ansi16m=Wu(au),Object.defineProperties(D,{rgbToAnsi256:{value:(e,t,r)=>e===t&&t===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(e.toString(16));if(!t)return[0,0,0];let{colorString:r}=t.groups;r.length===3&&(r=r.split("").map(o=>o+o).join(""));let n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:e=>D.rgbToAnsi256(...D.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,r,n;if(e>=232)t=((e-232)*10+8)/255,r=t,n=t;else{e-=16;let a=e%36;t=Math.floor(e/36)/5,r=Math.floor(a/6)/5,n=a%6/5}let o=Math.max(t,r,n)*2;if(o===0)return 30;let i=30+(Math.round(n)<<2|Math.round(r)<<1|Math.round(t));return o===2&&(i+=60),i},enumerable:!1},rgbToAnsi:{value:(e,t,r)=>D.ansi256ToAnsi(D.rgbToAnsi256(e,t,r)),enumerable:!1},hexToAnsi:{value:e=>D.ansi256ToAnsi(D.hexToAnsi256(e)),enumerable:!1}}),D}var Ue=We(),Ve=Ue,H=new Set(["\x1B","\x9B"]),ze=39,iu="\x07",Uu="[",Ge="]",Vu="m",su=`${Ge}8;;`,zu=u=>`${H.values().next().value}${Uu}${u}${Vu}`,Gu=u=>`${H.values().next().value}${su}${u}${iu}`,Ze=u=>u.split(" ").map(D=>k(D)),lu=(u,D,e)=>{let t=[...D],r=!1,n=!1,o=k(Tu(u[u.length-1]));for(let[i,a]of t.entries()){let s=k(a);if(o+s<=e?u[u.length-1]+=a:(u.push(a),o=0),H.has(a)&&(r=!0,n=t.slice(i+1).join("").startsWith(su)),r){n?a===iu&&(r=!1,n=!1):a===Vu&&(r=!1);continue}o+=s,o===e&&i<t.length-1&&(u.push(""),o=0)}!o&&u[u.length-1].length>0&&u.length>1&&(u[u.length-2]+=u.pop())},Je=u=>{let D=u.split(" "),e=D.length;for(;e>0&&!(k(D[e-1])>0);)e--;return e===D.length?u:D.slice(0,e).join(" ")+D.slice(e).join("")},Ye=(u,D,e={})=>{if(e.trim!==!1&&u.trim()==="")return"";let t="",r,n,o=Ze(u),i=[""];for(let[s,l]of u.split(" ").entries()){e.trim!==!1&&(i[i.length-1]=i[i.length-1].trimStart());let F=k(i[i.length-1]);if(s!==0&&(F>=D&&(e.wordWrap===!1||e.trim===!1)&&(i.push(""),F=0),(F>0||e.trim===!1)&&(i[i.length-1]+=" ",F++)),e.hard&&o[s]>D){let c=D-F,f=1+Math.floor((o[s]-c-1)/D);Math.floor((o[s]-1)/D)<f&&i.push(""),lu(i,l,D);continue}if(F+o[s]>D&&F>0&&o[s]>0){if(e.wordWrap===!1&&F<D){lu(i,l,D);continue}i.push("")}if(F+o[s]>D&&e.wordWrap===!1){lu(i,l,D);continue}i[i.length-1]+=l}e.trim!==!1&&(i=i.map(s=>Je(s)));let a=[...i.join(`
4
+ `)];for(let[s,l]of a.entries()){if(t+=l,H.has(l)){let{groups:c}=new RegExp(`(?:\\${Uu}(?<code>\\d+)m|\\${su}(?<uri>.*)${iu})`).exec(a.slice(s).join(""))||{groups:{}};if(c.code!==void 0){let f=Number.parseFloat(c.code);r=f===ze?void 0:f}else c.uri!==void 0&&(n=c.uri.length===0?void 0:c.uri)}let F=Ve.codes.get(Number(r));a[s+1]===`
5
+ `?(n&&(t+=Gu("")),r&&F&&(t+=zu(F))):l===`
6
+ `&&(r&&F&&(t+=zu(r)),n&&(t+=Gu(n)))}return t};function He(u,D,e){return String(u).normalize().replace(/\r\n/g,`
7
7
  `).split(`
8
- `).map(n=>xD(n,t,r)).join(`
9
- `)}var P$1=e=>Array.from({length:e}).fill("");function DD(e,t){let r=[],n=0;for(let o of e){let a=0,s=o.map(l=>{var Du;let uu=(Du=t[n])!=null?Du:"";n+=1,l.preprocess&&(uu=l.preprocess(uu)),m(uu)>l.width&&(uu=S$1(uu,l.width,{hard:!0}));let eu=uu.split(`
10
- `);if(l.postprocess){let{postprocess:tu}=l;eu=eu.map((ou,nu)=>tu.call(l,ou,nu))}return l.paddingTop&&eu.unshift(...P$1(l.paddingTop)),l.paddingBottom&&eu.push(...P$1(l.paddingBottom)),eu.length>a&&(a=eu.length),d(c({},l),{lines:eu})}),g=[];for(let l=0;l<a;l+=1){let Du=s.map(uu=>{var eu;let tu=(eu=uu.lines[l])!=null?eu:"",ou=Number.isFinite(uu.width)?" ".repeat(uu.width-f$1(tu)):"",nu=uu.paddingLeftString;return uu.align==="right"&&(nu+=ou),nu+=tu,uu.align==="left"&&(nu+=ou),nu+uu.paddingRightString}).join("");g.push(Du)}r.push(g.join(`
11
- `))}return r.join(`
12
- `)}function uD(e,t){if(!e||e.length===0)return"";let r=_$1(e),n=r.length;if(n===0)return"";let{stdoutColumns:o,columns:a}=N$1(t);if(a.length>n)throw new Error(`${a.length} columns defined, but only ${n} columns found`);let s=Z$1(o,a,r);return e.map(g=>DD(s,g)).join(`
13
- `)}i();var wD=["<",">","=",">=","<="];function yD(e){if(!wD.includes(e))throw new TypeError(`Invalid breakpoint operator: ${e}`)}function FD(e){let t=Object.keys(e).map(r=>{let[n,o]=r.split(" ");yD(n);let a=Number.parseInt(o,10);if(Number.isNaN(a))throw new TypeError(`Invalid breakpoint value: ${o}`);let s=e[r];return{operator:n,breakpoint:a,value:s}}).sort((r,n)=>n.breakpoint-r.breakpoint);return r=>{var n;return(n=t.find(({operator:o,breakpoint:a})=>o==="="&&r===a||o===">"&&r>a||o==="<"&&r<a||o===">="&&r>=a||o==="<="&&r<=a))==null?void 0:n.value}}var dist$2=lD(RD),W=Object.create,h=Object.defineProperty,Z=Object.defineProperties,z=Object.getOwnPropertyDescriptor,G=Object.getOwnPropertyDescriptors,Q=Object.getOwnPropertyNames,D=Object.getOwnPropertySymbols,X=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable,E=(e,t,r)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,f=(e,t)=>{for(var r in t||(t={}))T.call(t,r)&&E(e,r,t[r]);if(D)for(var r of D(t))Y.call(t,r)&&E(e,r,t[r]);return e},b=(e,t)=>Z(e,G(t)),S=e=>h(e,"__esModule",{value:!0}),ee=(e,t)=>{for(var r in t)h(e,r,{get:t[r],enumerable:!0})},B=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Q(t))!T.call(e,o)&&(r||o!=="default")&&h(e,o,{get:()=>t[o],enumerable:!(n=z(t,o))||n.enumerable});return e},v=(e,t)=>B(S(h(e!=null?W(X(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),te=(e=>(t,r)=>e&&e.get(t)||(r=B(S({}),t,1),e&&e.set(t,r),r))(typeof WeakMap!="undefined"?new WeakMap:0),ue={};ee(ue,{cli:()=>_,command:()=>J});var V=v(dist$3),R=e=>e.replace(/[-_ ](\w)/g,(t,r)=>r.toUpperCase()),I=e=>e.replace(/\B([A-Z])/g,"-$1").toLowerCase(),ne={"> 80":[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"auto"}],"> 40":[{width:"auto",paddingLeft:2,paddingRight:8,preprocess:e=>e.trim()},{width:"100%",paddingLeft:2,paddingBottom:1}],"> 0":{stdoutColumns:1e3,columns:[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"content-width"}]}};function j(e){let t=!1,r=Object.keys(e).sort((n,o)=>n.localeCompare(o)).map(n=>{let o=e[n],a="alias"in o;return a&&(t=!0),{name:n,flag:o,flagFormatted:`--${I(n)}`,aliasesEnabled:t,aliasFormatted:a?`-${o.alias}`:void 0}}).map(n=>(n.aliasesEnabled=t,[{type:"flagName",data:n},{type:"flagDescription",data:n}]));return{type:"table",data:{tableData:r,tableBreakpoints:ne}}}var K=e=>{var t;return!e||((t=e.version)!=null?t:e.help?e.help.version:void 0)},q=e=>{var t;let r="parent"in e&&((t=e.parent)==null?void 0:t.name);return(r?`${r} `:"")+e.name};function re(e){var t;let r=[];e.name&&r.push(q(e));let n=(t=K(e))!=null?t:"parent"in e&&K(e.parent);if(n&&r.push(`v${n}`),r.length!==0)return{id:"name",type:"text",data:`${r.join(" ")}
14
- `}}function ae(e){let{help:t}=e;if(!(!t||!t.description))return{id:"description",type:"text",data:`${t.description}
15
- `}}function se(e){var t;let r=e.help||{};if("usage"in r)return r.usage?{id:"usage",type:"section",data:{title:"Usage:",body:Array.isArray(r.usage)?r.usage.join(`
16
- `):r.usage}}:void 0;if(e.name){let n=[],o=[q(e)];if(e.flags&&Object.keys(e.flags).length>0&&o.push("[flags...]"),e.parameters&&e.parameters.length>0){let{parameters:a}=e,s=a.indexOf("--"),g=s>-1&&a.slice(s+1).some(l=>l.startsWith("<"));o.push(a.map(l=>l!=="--"?l:g?"--":"[--]").join(" "))}if(o.length>1&&n.push(o.join(" ")),"commands"in e&&((t=e.commands)==null?void 0:t.length)&&n.push(`${e.name} <command>`),n.length>0)return{id:"usage",type:"section",data:{title:"Usage:",body:n.join(`
17
- `)}}}}function ie(e){var t;if(!("commands"in e)||!((t=e.commands)!=null&&t.length))return;let r=e.commands.map(n=>[n.options.name,n.options.help?n.options.help.description:""]);return{id:"commands",type:"section",data:{title:"Commands:",body:{type:"table",data:{tableData:r,tableOptions:[{width:"content-width",paddingLeft:2,paddingRight:8}]}},indentBody:0}}}function oe(e){if(!(!e.flags||Object.keys(e.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:j(e.flags),indentBody:0}}}function me(e){let{help:t}=e;if(!t||!t.examples||t.examples.length===0)return;let{examples:r}=t;if(Array.isArray(r)&&(r=r.join(`
18
- `)),r)return{id:"examples",type:"section",data:{title:"Examples:",body:r}}}function le(e){if(!("alias"in e)||!e.alias)return;let{alias:t}=e,r=Array.isArray(t)?t.join(", "):t;return{id:"aliases",type:"section",data:{title:"Aliases:",body:r}}}var A=e=>[re,ae,se,ie,oe,me,le].map(t=>t(e)).filter(t=>Boolean(t)),L=v(require$$1__default.default),P=v(dist$2),pe=L.default.WriteStream.prototype.hasColors(),x=class{text(e){return e}bold(e){return pe?`\x1B[1m${e}\x1B[22m`:e.toLocaleUpperCase()}indentText({text:e,spaces:t}){return e.replace(/^/gm," ".repeat(t))}heading(e){return this.bold(e)}section({title:e,body:t,indentBody:r=2}){return`${(e?`${this.heading(e)}
19
- `:"")+(t?this.indentText({text:this.render(t),spaces:r}):"")}
20
- `}table({tableData:e,tableOptions:t,tableBreakpoints:r}){return(0,P.default)(e.map(n=>n.map(o=>this.render(o))),r?(0,P.breakpoints)(r):t)}flagParameter(e){return e===Boolean?"":e===String?"<string>":e===Number?"<number>":Array.isArray(e)?this.flagParameter(e[0]):"<value>"}flagOperator(){return" "}flagName({flag:e,flagFormatted:t,aliasesEnabled:r,aliasFormatted:n}){let o="";if(n?o+=`${n}, `:r&&(o+=" "),o+=t,"placeholder"in e&&typeof e.placeholder=="string")o+=`${this.flagOperator()}${e.placeholder}`;else{let a=this.flagParameter("type"in e?e.type:e);a&&(o+=`${this.flagOperator()}${a}`)}return o}flagDefault(e){return JSON.stringify(e)}flagDescription({flag:e}){var t;let r="description"in e&&(t=e.description)!=null?t:"";if("default"in e){let{default:n}=e;typeof n=="function"&&(n=n()),n&&(r+=` (default: ${this.flagDefault(n)})`)}return r}render(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(t=>this.render(t)).join(`
21
- `);if("type"in e&&this[e.type]){let t=this[e.type];if(typeof t=="function")return t.call(this,e.data)}throw new Error(`Invalid node type: ${JSON.stringify(e)}`)}},O=/^[\w.-]+$/,{stringify:p}=JSON,de=/[|\\{}()[\]^$+*?.]/;function $(e){let t=[],r,n;for(let o of e){if(n)throw new Error(`Invalid parameter: Spread parameter ${p(n)} must be last`);let a=o[0],s=o[o.length-1],g;if(a==="<"&&s===">"&&(g=!0,r))throw new Error(`Invalid parameter: Required parameter ${p(o)} cannot come after optional parameter ${p(r)}`);if(a==="["&&s==="]"&&(g=!1,r=o),g===void 0)throw new Error(`Invalid parameter: ${p(o)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let l=o.slice(1,-1),Du=l.slice(-3)==="...";Du&&(n=o,l=l.slice(0,-3));let uu=l.match(de);if(uu)throw new Error(`Invalid parameter: ${p(o)}. Invalid character found ${p(uu[0])}`);t.push({name:l,required:g,spread:Du})}return t}function N(e,t,r,n){for(let o=0;o<t.length;o+=1){let{name:a,required:s,spread:g}=t[o],l=R(a);if(l in e)throw new Error(`Invalid parameter: ${p(a)} is used more than once.`);let Du=g?r.slice(o):r[o];if(g&&(o=t.length),s&&(!Du||g&&Du.length===0))return console.error(`Error: Missing required parameter ${p(a)}
22
- `),n(),process.exit(1);e[l]=Du}}function ce(e){return e===void 0||e!==!1}function U(e,t,r,n){let o=f({},t.flags),a=t.version;a&&(o.version={type:Boolean,description:"Show version"});let{help:s}=t,g=ce(s);g&&!("help"in o)&&(o.help={type:Boolean,alias:"h",description:"Show help"});let l=(0,V.default)(o,n),Du=()=>{console.log(t.version)};if(a&&l.flags.version===!0)return Du(),process.exit(0);let uu=new x,eu=g&&(s==null?void 0:s.render)?s.render:nu=>uu.render(nu),tu=nu=>{let lu=A(b(f(f({},t),nu?{help:nu}:{}),{flags:o}));console.log(eu(lu,uu))};if(g&&l.flags.help===!0)return tu(),process.exit(0);if(t.parameters){let{parameters:nu}=t,lu=l._,Cu=nu.indexOf("--"),su=nu.slice(Cu+1),au=Object.create(null);if(Cu>-1&&su.length>0){nu=nu.slice(0,Cu);let ru=l._["--"];lu=lu.slice(0,-ru.length||void 0),N(au,$(nu),lu,tu),N(au,$(su),ru,tu)}else N(au,$(nu),lu,tu);Object.assign(l._,au)}let ou=b(f({},l),{showVersion:Du,showHelp:tu});return typeof r=="function"&&r(ou),f({command:e},ou)}function fe(e,t){let r=new Map;for(let n of t){let o=[n.options.name],{alias:a}=n.options;a&&(Array.isArray(a)?o.push(...a):o.push(a));for(let s of o){if(r.has(s))throw new Error(`Duplicate command name found: ${p(s)}`);r.set(s,n)}}return r.get(e)}function _(e,t,r=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!O.test(e.name)))throw new Error(`Invalid script name: ${p(e.name)}`);let n=r[0];if(e.commands&&O.test(n)){let o=fe(n,e.commands);if(o)return U(o.options.name,b(f({},o.options),{parent:e}),o.callback,r.slice(1))}return U(void 0,e,t,r)}function J(e,t){if(!e)throw new Error("Command options are required");let{name:r}=e;if(e.name===void 0)throw new Error("Command name is required");if(!O.test(r))throw new Error(`Invalid command name ${JSON.stringify(r)}. Command names must be one word.`);return{options:e,callback:t}}var dist$1=te(ue);const fsExists=e=>fs__default$1.default.promises.access(e).then(()=>!0,()=>!1),readPackageJson=async e=>{const t=path__default$1.default.join(e,"package.json");if(!await fsExists(t))throw new Error(`package.json not found at: ${t}`);const n=await fs__default$1.default.promises.readFile(t,"utf8");try{return JSON.parse(n)}catch(o){throw new Error(`Cannot parse package.json: ${o.message}`)}},hasPathPrefixPattern=/^[/.]/,normalizePath$1=(e,t)=>(hasPathPrefixPattern.test(e)||(e=`./${e}`),t&&!e.endsWith("/")&&(e+="/"),e);var __defProp$3=Object.defineProperty,__defProps$3=Object.defineProperties,__getOwnPropDescs$3=Object.getOwnPropertyDescriptors,__getOwnPropSymbols$3=Object.getOwnPropertySymbols,__hasOwnProp$3=Object.prototype.hasOwnProperty,__propIsEnum$3=Object.prototype.propertyIsEnumerable,__defNormalProp$3=(e,t,r)=>t in e?__defProp$3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues$3=(e,t)=>{for(var r in t||(t={}))__hasOwnProp$3.call(t,r)&&__defNormalProp$3(e,r,t[r]);if(__getOwnPropSymbols$3)for(var r of __getOwnPropSymbols$3(t))__propIsEnum$3.call(t,r)&&__defNormalProp$3(e,r,t[r]);return e},__spreadProps$3=(e,t)=>__defProps$3(e,__getOwnPropDescs$3(t));const getFileType=e=>{if(e.endsWith(".mjs"))return"module";if(e.endsWith(".cjs"))return"commonjs"},isPath=e=>e.startsWith(".");function parseExportsMap(e,t,r="exports"){if(e){if(typeof e=="string")return isPath(e)?[{outputPath:e,type:getFileType(e)||t,from:r}]:[];if(Array.isArray(e))return e.filter(isPath).map((o,a)=>({outputPath:o,type:getFileType(o)||t,from:`${r}[${a}]`}));if(typeof e=="object")return Object.entries(e).flatMap(([n,o])=>{if(typeof o=="string"){const a={outputPath:o,from:`${r}.${n}`};if(n==="require")return __spreadProps$3(__spreadValues$3({},a),{type:"commonjs"});if(n==="import")return __spreadProps$3(__spreadValues$3({},a),{type:getFileType(o)||t});if(n==="types")return __spreadProps$3(__spreadValues$3({},a),{type:"types"});if(n==="node")return __spreadProps$3(__spreadValues$3({},a),{type:getFileType(o)||t,platform:"node"});if(n==="default")return __spreadProps$3(__spreadValues$3({},a),{type:getFileType(o)||t})}return parseExportsMap(o,t,`${r}.${n}`)})}return[]}function addExportPath(e,t){t.outputPath=normalizePath$1(t.outputPath);const{outputPath:r,type:n,platform:o}=t,a=e[r];if(a){if(a.type!==n)throw new Error(`Conflicting export types "${a.type}" & "${n}" found for ${r}`);if(a.platform!==o)throw new Error(`Conflicting export platforms "${a.platform}" & "${o}" found for ${r}`)}e[r]=t}const getExportEntries=e=>{var t,r,n,o;const a={},s=(t=e.type)!=null?t:"commonjs";if(e.main){const g=e.main;addExportPath(a,{outputPath:g,type:(r=getFileType(g))!=null?r:s,from:"main"})}if(e.module&&addExportPath(a,{outputPath:e.module,type:"module",from:"module"}),e.types&&addExportPath(a,{outputPath:e.types,type:"types",from:"types"}),e.bin){const{bin:g}=e;if(typeof g=="string")addExportPath(a,{outputPath:g,type:(n=getFileType(g))!=null?n:s,isExecutable:!0,from:"bin"});else for(const[l,Du]of Object.entries(g))addExportPath(a,{outputPath:Du,type:(o=getFileType(Du))!=null?o:s,isExecutable:!0,from:`bin.${l}`})}if(e.exports){const g=parseExportsMap(e.exports,s);for(const l of g)addExportPath(a,l)}return Object.values(a)},externalProperties=["peerDependencies","dependencies","optionalDependencies"],getExternalDependencies=e=>{const t=[];for(const r of externalProperties){const n=e[r];n&&t.push(...Object.keys(n))}return t},getAliases=({imports:e},t)=>{const r={};if(e)for(const n in e){if(n.startsWith("#"))continue;const o=e[n];typeof o=="string"&&(r[n]=path__default$1.default.join(t,o))}return r},{stringify}=JSON;async function tryExtensions(e,t){for(const r of t){const n=e+r;if(await fsExists(n))return n}}const sourceExtensions={".d.ts":[".d.ts",".ts"],".js":[".js",".ts",".tsx"],".mjs":[".mjs",".js",".mts",".ts"],".cjs":[".cjs",".js",".cts",".ts"]};async function getSourcePath(e,t,r){if(!e.outputPath.startsWith(r))throw new Error(`Export path ${stringify(e.outputPath)} from ${stringify(`package.json#${e.from}`)} is not in directory ${r}`);const n=t+e.outputPath.slice(r.length);for(const o of Object.keys(sourceExtensions))if(e.outputPath.endsWith(o)){const a=await tryExtensions(n.slice(0,-o.length),sourceExtensions[o]);if(a)return a}throw new Error(`Could not find mathing source file for export path ${stringify(e.outputPath)}`)}var __defProp$2=Object.defineProperty,__defProps$2=Object.defineProperties,__getOwnPropDescs$2=Object.getOwnPropertyDescriptors,__getOwnPropSymbols$2=Object.getOwnPropertySymbols,__hasOwnProp$2=Object.prototype.hasOwnProperty,__propIsEnum$2=Object.prototype.propertyIsEnumerable,__defNormalProp$2=(e,t,r)=>t in e?__defProp$2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues$2=(e,t)=>{for(var r in t||(t={}))__hasOwnProp$2.call(t,r)&&__defNormalProp$2(e,r,t[r]);if(__getOwnPropSymbols$2)for(var r of __getOwnPropSymbols$2(t))__propIsEnum$2.call(t,r)&&__defNormalProp$2(e,r,t[r]);return e},__spreadProps$2=(e,t)=>__defProps$2(e,__getOwnPropDescs$2(t));const virtualModuleName="pkgroll:create-require",isEsmVariableName=`IS_ESM${Math.random().toString(36).slice(2)}`,createRequire=()=>__spreadProps$2(__spreadValues$2({},inject__default.default({require:virtualModuleName})),{name:"create-require",resolveId:e=>e===virtualModuleName?e:null,load(e){return e!==virtualModuleName?null:`
8
+ `).map(t=>Ye(t,D,e)).join(`
9
+ `)}var Zu=u=>Array.from({length:u}).fill("");function Ke(u,D){let e=[],t=0;for(let r of u){let n=0,o=r.map(a=>{var s;let l=(s=D[t])!=null?s:"";t+=1,a.preprocess&&(l=a.preprocess(l)),Nu(l)>a.width&&(l=He(l,a.width,{hard:!0}));let F=l.split(`
10
+ `);if(a.postprocess){let{postprocess:c}=a;F=F.map((f,p)=>c.call(a,f,p))}return a.paddingTop&&F.unshift(...Zu(a.paddingTop)),a.paddingBottom&&F.push(...Zu(a.paddingBottom)),F.length>n&&(n=F.length),ou(Y({},a),{lines:F})}),i=[];for(let a=0;a<n;a+=1){let s=o.map(l=>{var F;let c=(F=l.lines[a])!=null?F:"",f=Number.isFinite(l.width)?" ".repeat(l.width-k(c)):"",p=l.paddingLeftString;return l.align==="right"&&(p+=f),p+=c,l.align==="left"&&(p+=f),p+l.paddingRightString}).join("");i.push(s)}e.push(i.join(`
11
+ `))}return e.join(`
12
+ `)}function Qe(u,D){if(!u||u.length===0)return"";let e=Ie(u),t=e.length;if(t===0)return"";let{stdoutColumns:r,columns:n}=ke(D);if(n.length>t)throw new Error(`${n.length} columns defined, but only ${t} columns found`);let o=qe(r,n,e);return u.map(i=>Ke(o,i)).join(`
13
+ `)}v();var Xe=["<",">","=",">=","<="];function ut(u){if(!Xe.includes(u))throw new TypeError(`Invalid breakpoint operator: ${u}`)}function Dt(u){let D=Object.keys(u).map(e=>{let[t,r]=e.split(" ");ut(t);let n=Number.parseInt(r,10);if(Number.isNaN(n))throw new TypeError(`Invalid breakpoint value: ${r}`);let o=u[e];return{operator:t,breakpoint:n,value:o}}).sort((e,t)=>t.breakpoint-e.breakpoint);return e=>{var t;return(t=D.find(({operator:r,breakpoint:n})=>r==="="&&e===n||r===">"&&e>n||r==="<"&&e<n||r===">="&&e>=n||r==="<="&&e<=n))==null?void 0:t.value}}var et=Pe(Su),Ju;Object.defineProperty(eu,"__esModule",{value:!0});var tt=he,rt=VD.default,Yu=et;function Fu(u){return u&&typeof u=="object"&&"default"in u?u:{default:u}}var nt=Fu(tt),ot=Fu(rt),at=Fu(Yu);const it=u=>u.replace(/[-_ ](\w)/g,(D,e)=>e.toUpperCase()),st=u=>u.replace(/\B([A-Z])/g,"-$1").toLowerCase(),lt={"> 80":[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"auto"}],"> 40":[{width:"auto",paddingLeft:2,paddingRight:8,preprocess:u=>u.trim()},{width:"100%",paddingLeft:2,paddingBottom:1}],"> 0":{stdoutColumns:1e3,columns:[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"content-width"}]}};function Ft(u){let D=!1;const e=Object.keys(u).sort((t,r)=>t.localeCompare(r)).map(t=>{const r=u[t],n="alias"in r;return n&&(D=!0),{name:t,flag:r,flagFormatted:`--${st(t)}`,aliasesEnabled:D,aliasFormatted:n?`-${r.alias}`:void 0}}).map(t=>(t.aliasesEnabled=D,[{type:"flagName",data:t},{type:"flagDescription",data:t}]));return{type:"table",data:{tableData:e,tableBreakpoints:lt}}}const Hu=u=>{var D;return!u||((D=u.version)!=null?D:u.help?u.help.version:void 0)},Ku=u=>{var D;const e="parent"in u&&((D=u.parent)==null?void 0:D.name);return(e?`${e} `:"")+u.name};function ct(u){var D;const e=[];u.name&&e.push(Ku(u));const t=(D=Hu(u))!=null?D:"parent"in u&&Hu(u.parent);if(t&&e.push(`v${t}`),e.length!==0)return{id:"name",type:"text",data:`${e.join(" ")}
14
+ `}}function Ct(u){const{help:D}=u;if(!(!D||!D.description))return{id:"description",type:"text",data:`${D.description}
15
+ `}}function ft(u){var D;const e=u.help||{};if("usage"in e)return e.usage?{id:"usage",type:"section",data:{title:"Usage:",body:Array.isArray(e.usage)?e.usage.join(`
16
+ `):e.usage}}:void 0;if(u.name){const t=[],r=[Ku(u)];if(u.flags&&Object.keys(u.flags).length>0&&r.push("[flags...]"),u.parameters&&u.parameters.length>0){const{parameters:n}=u,o=n.indexOf("--"),i=o>-1&&n.slice(o+1).some(a=>a.startsWith("<"));r.push(n.map(a=>a!=="--"?a:i?"--":"[--]").join(" "))}if(r.length>1&&t.push(r.join(" ")),"commands"in u&&((D=u.commands)==null?void 0:D.length)&&t.push(`${u.name} <command>`),t.length>0)return{id:"usage",type:"section",data:{title:"Usage:",body:t.join(`
17
+ `)}}}}function pt(u){var D;if(!("commands"in u)||!((D=u.commands)!=null&&D.length))return;const e=u.commands.map(t=>[t.options.name,t.options.help?t.options.help.description:""]);return{id:"commands",type:"section",data:{title:"Commands:",body:{type:"table",data:{tableData:e,tableOptions:[{width:"content-width",paddingLeft:2,paddingRight:8}]}},indentBody:0}}}function dt(u){if(!(!u.flags||Object.keys(u.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:Ft(u.flags),indentBody:0}}}function Et(u){const{help:D}=u;if(!D||!D.examples||D.examples.length===0)return;let{examples:e}=D;if(Array.isArray(e)&&(e=e.join(`
18
+ `)),e)return{id:"examples",type:"section",data:{title:"Examples:",body:e}}}function gt(u){if(!("alias"in u)||!u.alias)return;const{alias:D}=u,e=Array.isArray(D)?D.join(", "):D;return{id:"aliases",type:"section",data:{title:"Aliases:",body:e}}}const ht=u=>[ct,Ct,ft,pt,dt,Et,gt].map(D=>D(u)).filter(D=>Boolean(D)),mt=ot.default.WriteStream.prototype.hasColors();class Bt{text(D){return D}bold(D){return mt?`\x1B[1m${D}\x1B[22m`:D.toLocaleUpperCase()}indentText({text:D,spaces:e}){return D.replace(/^/gm," ".repeat(e))}heading(D){return this.bold(D)}section({title:D,body:e,indentBody:t=2}){return`${(D?`${this.heading(D)}
19
+ `:"")+(e?this.indentText({text:this.render(e),spaces:t}):"")}
20
+ `}table({tableData:D,tableOptions:e,tableBreakpoints:t}){return at.default(D.map(r=>r.map(n=>this.render(n))),t?Yu.breakpoints(t):e)}flagParameter(D){return D===Boolean?"":D===String?"<string>":D===Number?"<number>":Array.isArray(D)?this.flagParameter(D[0]):"<value>"}flagOperator(D){return" "}flagName(D){const{flag:e,flagFormatted:t,aliasesEnabled:r,aliasFormatted:n}=D;let o="";if(n?o+=`${n}, `:r&&(o+=" "),o+=t,"placeholder"in e&&typeof e.placeholder=="string")o+=`${this.flagOperator(D)}${e.placeholder}`;else{const i=this.flagParameter("type"in e?e.type:e);i&&(o+=`${this.flagOperator(D)}${i}`)}return o}flagDefault(D){return JSON.stringify(D)}flagDescription({flag:D}){var e;let t="description"in D&&(e=D.description)!=null?e:"";if("default"in D){let{default:r}=D;typeof r=="function"&&(r=r()),r&&(t+=` (default: ${this.flagDefault(r)})`)}return t}render(D){if(typeof D=="string")return D;if(Array.isArray(D))return D.map(e=>this.render(e)).join(`
21
+ `);if("type"in D&&this[D.type]){const e=this[D.type];if(typeof e=="function")return e.call(this,D.data)}throw new Error(`Invalid node type: ${JSON.stringify(D)}`)}}const cu=/^[\w.-]+$/;var bt=Object.defineProperty,yt=Object.defineProperties,At=Object.getOwnPropertyDescriptors,Qu=Object.getOwnPropertySymbols,vt=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable,Xu=(u,D,e)=>D in u?bt(u,D,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[D]=e,T=(u,D)=>{for(var e in D||(D={}))vt.call(D,e)&&Xu(u,e,D[e]);if(Qu)for(var e of Qu(D))wt.call(D,e)&&Xu(u,e,D[e]);return u},Cu=(u,D)=>yt(u,At(D));const{stringify:j}=JSON,$t=/[|\\{}()[\]^$+*?.]/;function fu(u){const D=[];let e,t;for(const r of u){if(t)throw new Error(`Invalid parameter: Spread parameter ${j(t)} must be last`);const n=r[0],o=r[r.length-1];let i;if(n==="<"&&o===">"&&(i=!0,e))throw new Error(`Invalid parameter: Required parameter ${j(r)} cannot come after optional parameter ${j(e)}`);if(n==="["&&o==="]"&&(i=!1,e=r),i===void 0)throw new Error(`Invalid parameter: ${j(r)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let a=r.slice(1,-1);const s=a.slice(-3)==="...";s&&(t=r,a=a.slice(0,-3));const l=a.match($t);if(l)throw new Error(`Invalid parameter: ${j(r)}. Invalid character found ${j(l[0])}`);D.push({name:a,required:i,spread:s})}return D}function pu(u,D,e,t){for(let r=0;r<D.length;r+=1){const{name:n,required:o,spread:i}=D[r],a=it(n);if(a in u)throw new Error(`Invalid parameter: ${j(n)} is used more than once.`);const s=i?e.slice(r):e[r];if(i&&(r=D.length),o&&(!s||i&&s.length===0))return console.error(`Error: Missing required parameter ${j(n)}
22
+ `),t(),process.exit(1);u[a]=s}}function Ot(u){return u===void 0||u!==!1}function uD(u,D,e,t){const r=T({},D.flags),n=D.version;n&&(r.version={type:Boolean,description:"Show version"});const{help:o}=D,i=Ot(o);i&&!("help"in r)&&(r.help={type:Boolean,alias:"h",description:"Show help"});const a=nt.default(r,t),s=()=>{console.log(D.version)};if(n&&a.flags.version===!0)return s(),process.exit(0);const l=new Bt,F=i&&(o==null?void 0:o.render)?o.render:p=>l.render(p),c=p=>{const E=ht(Cu(T(T({},D),p?{help:p}:{}),{flags:r}));console.log(F(E,l))};if(i&&a.flags.help===!0)return c(),process.exit(0);if(D.parameters){let{parameters:p}=D,E=a._;const B=p.indexOf("--"),g=p.slice(B+1),d=Object.create(null);if(B>-1&&g.length>0){p=p.slice(0,B);const C=a._["--"];E=E.slice(0,-C.length||void 0),pu(d,fu(p),E,c),pu(d,fu(g),C,c)}else pu(d,fu(p),E,c);Object.assign(a._,d)}const f=Cu(T({},a),{showVersion:s,showHelp:c});return typeof e=="function"&&e(f),T({command:u},f)}function jt(u,D){const e=new Map;for(const t of D){const r=[t.options.name],{alias:n}=t.options;n&&(Array.isArray(n)?r.push(...n):r.push(n));for(const o of r){if(e.has(o))throw new Error(`Duplicate command name found: ${j(o)}`);e.set(o,t)}}return e.get(u)}function _t(u,D,e=process.argv.slice(2)){if(!u)throw new Error("Options is required");if("name"in u&&(!u.name||!cu.test(u.name)))throw new Error(`Invalid script name: ${j(u.name)}`);const t=e[0];if(u.commands&&cu.test(t)){const r=jt(t,u.commands);if(r)return uD(r.options.name,Cu(T({},r.options),{parent:u}),r.callback,e.slice(1))}return uD(void 0,u,D,e)}function Pt(u,D){if(!u)throw new Error("Command options are required");const{name:e}=u;if(u.name===void 0)throw new Error("Command name is required");if(!cu.test(e))throw new Error(`Invalid command name ${JSON.stringify(e)}. Command names must be one word.`);return{options:u,callback:D}}Ju=eu.cli=_t,eu.command=Pt;const DD=u=>P.default.promises.access(u).then(()=>!0,()=>!1),xt=async u=>{const D=x.default.join(u,"package.json");if(!await DD(D))throw new Error(`package.json not found at: ${D}`);const t=await P.default.promises.readFile(D,"utf8");try{return JSON.parse(t)}catch(r){throw new Error(`Cannot parse package.json: ${r.message}`)}},kt=/^[/.]/,K=(u,D)=>(!x.default.isAbsolute(u)&&!kt.test(u)&&(u=`./${u}`),D&&!u.endsWith("/")&&(u+="/"),u);var St=Object.defineProperty,Tt=Object.defineProperties,Nt=Object.getOwnPropertyDescriptors,eD=Object.getOwnPropertySymbols,It=Object.prototype.hasOwnProperty,Mt=Object.prototype.propertyIsEnumerable,tD=(u,D,e)=>D in u?St(u,D,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[D]=e,W=(u,D)=>{for(var e in D||(D={}))It.call(D,e)&&tD(u,e,D[e]);if(eD)for(var e of eD(D))Mt.call(D,e)&&tD(u,e,D[e]);return u},U=(u,D)=>Tt(u,Nt(D));const _=u=>{if(u.endsWith(".mjs"))return"module";if(u.endsWith(".cjs"))return"commonjs"},rD=u=>u.startsWith(".");function nD(u,D,e="exports"){if(u){if(typeof u=="string")return rD(u)?[{outputPath:u,type:_(u)||D,from:e}]:[];if(Array.isArray(u))return u.filter(rD).map((r,n)=>({outputPath:r,type:_(r)||D,from:`${e}[${n}]`}));if(typeof u=="object")return Object.entries(u).flatMap(([t,r])=>{if(typeof r=="string"){const n={outputPath:r,from:`${e}.${t}`};if(t==="require")return U(W({},n),{type:"commonjs"});if(t==="import")return U(W({},n),{type:_(r)||D});if(t==="types")return U(W({},n),{type:"types"});if(t==="node")return U(W({},n),{type:_(r)||D,platform:"node"});if(t==="default")return U(W({},n),{type:_(r)||D})}return nD(r,D,`${e}.${t}`)})}return[]}function N(u,D){D.outputPath=K(D.outputPath);const{outputPath:e,type:t,platform:r}=D,n=u[e];if(n){if(n.type!==t)throw new Error(`Conflicting export types "${n.type}" & "${t}" found for ${e}`);if(n.platform!==r)throw new Error(`Conflicting export platforms "${n.platform}" & "${r}" found for ${e}`)}u[e]=D}const Rt=u=>{var D,e,t,r;const n={},o=(D=u.type)!=null?D:"commonjs";if(u.main){const i=u.main;N(n,{outputPath:i,type:(e=_(i))!=null?e:o,from:"main"})}if(u.module&&N(n,{outputPath:u.module,type:"module",from:"module"}),u.types&&N(n,{outputPath:u.types,type:"types",from:"types"}),u.bin){const{bin:i}=u;if(typeof i=="string")N(n,{outputPath:i,type:(t=_(i))!=null?t:o,isExecutable:!0,from:"bin"});else for(const[a,s]of Object.entries(i))N(n,{outputPath:s,type:(r=_(s))!=null?r:o,isExecutable:!0,from:`bin.${a}`})}if(u.exports){const i=nD(u.exports,o);for(const a of i)N(n,a)}return Object.values(n)},Lt=["peerDependencies","dependencies","optionalDependencies"],qt=u=>{const D=[];for(const e of Lt){const t=u[e];t&&D.push(...Object.keys(t))}return D},Wt=({imports:u},D)=>{const e={};if(u)for(const t in u){if(t.startsWith("#"))continue;const r=u[t];typeof r=="string"&&(e[t]=x.default.join(D,r))}return e},{stringify:du}=JSON;async function Ut(u,D){for(const e of D){const t=u+e;if(await DD(t))return t}}const oD={".d.ts":[".d.ts",".ts"],".js":[".js",".ts",".tsx"],".mjs":[".mjs",".js",".cjs",".mts",".ts"],".cjs":[".cjs",".js",".mjs",".cts",".ts"]};async function Vt(u,D,e){if(!u.outputPath.startsWith(e))throw new Error(`Export path ${du(u.outputPath)} from ${du(`package.json#${u.from}`)} is not in directory ${e}`);const t=D+u.outputPath.slice(e.length);for(const r of Object.keys(oD))if(u.outputPath.endsWith(r)){const n=await Ut(t.slice(0,-r.length),oD[r]);if(n)return n}throw new Error(`Could not find mathing source file for export path ${du(u.outputPath)}`)}var zt=Object.defineProperty,Gt=Object.defineProperties,Zt=Object.getOwnPropertyDescriptors,aD=Object.getOwnPropertySymbols,Jt=Object.prototype.hasOwnProperty,Yt=Object.prototype.propertyIsEnumerable,iD=(u,D,e)=>D in u?zt(u,D,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[D]=e,Ht=(u,D)=>{for(var e in D||(D={}))Jt.call(D,e)&&iD(u,e,D[e]);if(aD)for(var e of aD(D))Yt.call(D,e)&&iD(u,e,D[e]);return u},Kt=(u,D)=>Gt(u,Zt(D));const Eu="pkgroll:create-require",sD=`IS_ESM${Math.random().toString(36).slice(2)}`,Qt=()=>Kt(Ht({},YD.default({require:Eu})),{name:"create-require",resolveId:u=>u===Eu?u:null,load(u){return u!==Eu?null:`
23
23
  import { createRequire } from 'module';
24
24
 
25
25
  export default (
26
- ${isEsmVariableName}
26
+ ${sD}
27
27
  ? createRequire(import.meta.url)
28
28
  : require
29
29
  );
30
- `}}),isFormatEsm=e=>({name:"create-require-insert-format",renderChunk:replace__default.default({[isEsmVariableName]:e}).renderChunk});var path=path__default$1.default,fs=fs__default$1.default;function _interopDefaultLegacy$1(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var path__default=_interopDefaultLegacy$1(path),fs__default=_interopDefaultLegacy$1(fs);function slash(e){const t=/^\\\\\?\\/.test(e),r=/[^\u0000-\u0080]+/.test(e);return t||r?e:e.replace(/\\/g,"/")}function findConfigFile(e,t){for(;;){const r=path__default.default.join(e,t);if(fs__default.default.existsSync(r))return slash(r);const n=path__default.default.dirname(e);if(n===e)return;e=n}}var require$1=commonjsRequire;function createScanner(e,t){t===void 0&&(t=!1);var r=e.length,n=0,o="",a=0,s=16,g=0,l=0,Du=0,uu=0,eu=0;function tu(ru,cu){for(var pu=0,fu=0;pu<ru||!cu;){var Fu=e.charCodeAt(n);if(Fu>=48&&Fu<=57)fu=fu*16+Fu-48;else if(Fu>=65&&Fu<=70)fu=fu*16+Fu-65+10;else if(Fu>=97&&Fu<=102)fu=fu*16+Fu-97+10;else break;n++,pu++}return pu<ru&&(fu=-1),fu}function ou(ru){n=ru,o="",a=0,s=16,eu=0}function nu(){var ru=n;if(e.charCodeAt(n)===48)n++;else for(n++;n<e.length&&isDigit(e.charCodeAt(n));)n++;if(n<e.length&&e.charCodeAt(n)===46)if(n++,n<e.length&&isDigit(e.charCodeAt(n)))for(n++;n<e.length&&isDigit(e.charCodeAt(n));)n++;else return eu=3,e.substring(ru,n);var cu=n;if(n<e.length&&(e.charCodeAt(n)===69||e.charCodeAt(n)===101))if(n++,(n<e.length&&e.charCodeAt(n)===43||e.charCodeAt(n)===45)&&n++,n<e.length&&isDigit(e.charCodeAt(n))){for(n++;n<e.length&&isDigit(e.charCodeAt(n));)n++;cu=n}else eu=3;return e.substring(ru,cu)}function lu(){for(var ru="",cu=n;;){if(n>=r){ru+=e.substring(cu,n),eu=2;break}var pu=e.charCodeAt(n);if(pu===34){ru+=e.substring(cu,n),n++;break}if(pu===92){if(ru+=e.substring(cu,n),n++,n>=r){eu=2;break}var fu=e.charCodeAt(n++);switch(fu){case 34:ru+='"';break;case 92:ru+="\\";break;case 47:ru+="/";break;case 98:ru+="\b";break;case 102:ru+="\f";break;case 110:ru+=`
31
- `;break;case 114:ru+="\r";break;case 116:ru+=" ";break;case 117:var Fu=tu(4,!0);Fu>=0?ru+=String.fromCharCode(Fu):eu=4;break;default:eu=5}cu=n;continue}if(pu>=0&&pu<=31)if(isLineBreak(pu)){ru+=e.substring(cu,n),eu=2;break}else eu=6;n++}return ru}function Cu(){if(o="",eu=0,a=n,l=g,uu=Du,n>=r)return a=r,s=17;var ru=e.charCodeAt(n);if(isWhiteSpace(ru)){do n++,o+=String.fromCharCode(ru),ru=e.charCodeAt(n);while(isWhiteSpace(ru));return s=15}if(isLineBreak(ru))return n++,o+=String.fromCharCode(ru),ru===13&&e.charCodeAt(n)===10&&(n++,o+=`
32
- `),g++,Du=n,s=14;switch(ru){case 123:return n++,s=1;case 125:return n++,s=2;case 91:return n++,s=3;case 93:return n++,s=4;case 58:return n++,s=6;case 44:return n++,s=5;case 34:return n++,o=lu(),s=10;case 47:var cu=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<r&&!isLineBreak(e.charCodeAt(n));)n++;return o=e.substring(cu,n),s=12}if(e.charCodeAt(n+1)===42){n+=2;for(var pu=r-1,fu=!1;n<pu;){var Fu=e.charCodeAt(n);if(Fu===42&&e.charCodeAt(n+1)===47){n+=2,fu=!0;break}n++,isLineBreak(Fu)&&(Fu===13&&e.charCodeAt(n)===10&&n++,g++,Du=n)}return fu||(n++,eu=1),o=e.substring(cu,n),s=13}return o+=String.fromCharCode(ru),n++,s=16;case 45:if(o+=String.fromCharCode(ru),n++,n===r||!isDigit(e.charCodeAt(n)))return s=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return o+=nu(),s=11;default:for(;n<r&&su(ru);)n++,ru=e.charCodeAt(n);if(a!==n){switch(o=e.substring(a,n),o){case"true":return s=8;case"false":return s=9;case"null":return s=7}return s=16}return o+=String.fromCharCode(ru),n++,s=16}}function su(ru){if(isWhiteSpace(ru)||isLineBreak(ru))return!1;switch(ru){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function au(){var ru;do ru=Cu();while(ru>=12&&ru<=15);return ru}return{setPosition:ou,getPosition:function(){return n},scan:t?au:Cu,getToken:function(){return s},getTokenValue:function(){return o},getTokenOffset:function(){return a},getTokenLength:function(){return n-a},getTokenStartLine:function(){return l},getTokenStartCharacter:function(){return a-uu},getTokenError:function(){return eu}}}function isWhiteSpace(e){return e===32||e===9||e===11||e===12||e===160||e===5760||e>=8192&&e<=8203||e===8239||e===8287||e===12288||e===65279}function isLineBreak(e){return e===10||e===13||e===8232||e===8233}function isDigit(e){return e>=48&&e<=57}var ParseOptions;(function(e){e.DEFAULT={allowTrailingComma:!1}})(ParseOptions||(ParseOptions={}));function parse$1(e,t,r){t===void 0&&(t=[]),r===void 0&&(r=ParseOptions.DEFAULT);var n=null,o=[],a=[];function s(l){Array.isArray(o)?o.push(l):n!==null&&(o[n]=l)}var g={onObjectBegin:function(){var l={};s(l),a.push(o),o=l,n=null},onObjectProperty:function(l){n=l},onObjectEnd:function(){o=a.pop()},onArrayBegin:function(){var l=[];s(l),a.push(o),o=l,n=null},onArrayEnd:function(){o=a.pop()},onLiteralValue:s,onError:function(l,Du,uu){t.push({error:l,offset:Du,length:uu})}};return visit(e,g,r),o[0]}function visit(e,t,r){r===void 0&&(r=ParseOptions.DEFAULT);var n=createScanner(e,!1);function o(iu){return iu?function(){return iu(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter())}:function(){return!0}}function a(iu){return iu?function(du){return iu(du,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter())}:function(){return!0}}var s=o(t.onObjectBegin),g=a(t.onObjectProperty),l=o(t.onObjectEnd),Du=o(t.onArrayBegin),uu=o(t.onArrayEnd),eu=a(t.onLiteralValue),tu=a(t.onSeparator),ou=o(t.onComment),nu=a(t.onError),lu=r&&r.disallowComments,Cu=r&&r.allowTrailingComma;function su(){for(;;){var iu=n.scan();switch(n.getTokenError()){case 4:au(14);break;case 5:au(15);break;case 3:au(13);break;case 1:lu||au(11);break;case 2:au(12);break;case 6:au(16);break}switch(iu){case 12:case 13:lu?au(10):ou();break;case 16:au(1);break;case 15:case 14:break;default:return iu}}}function au(iu,du,Eu){if(du===void 0&&(du=[]),Eu===void 0&&(Eu=[]),nu(iu),du.length+Eu.length>0)for(var gu=n.getToken();gu!==17;){if(du.indexOf(gu)!==-1){su();break}else if(Eu.indexOf(gu)!==-1)break;gu=su()}}function ru(iu){var du=n.getTokenValue();return iu?eu(du):g(du),su(),!0}function cu(){switch(n.getToken()){case 11:var iu=n.getTokenValue(),du=Number(iu);isNaN(du)&&(au(2),du=0),eu(du);break;case 7:eu(null);break;case 8:eu(!0);break;case 9:eu(!1);break;default:return!1}return su(),!0}function pu(){return n.getToken()!==10?(au(3,[],[2,5]),!1):(ru(!1),n.getToken()===6?(tu(":"),su(),hu()||au(4,[],[2,5])):au(5,[],[2,5]),!0)}function fu(){s(),su();for(var iu=!1;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(iu||au(4,[],[]),tu(","),su(),n.getToken()===2&&Cu)break}else iu&&au(6,[],[]);pu()||au(4,[],[2,5]),iu=!0}return l(),n.getToken()!==2?au(7,[2],[]):su(),!0}function Fu(){Du(),su();for(var iu=!1;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(iu||au(4,[],[]),tu(","),su(),n.getToken()===4&&Cu)break}else iu&&au(6,[],[]);hu()||au(4,[],[4,5]),iu=!0}return uu(),n.getToken()!==4?au(8,[4],[]):su(),!0}function hu(){switch(n.getToken()){case 3:return Fu();case 1:return fu();case 10:return ru(!0);default:return cu()}}return su(),n.getToken()===17?r.allowEmptyContent?!0:(au(4,[],[]),!1):hu()?(n.getToken()!==17&&au(9,[],[]),!0):(au(4,[],[]),!1)}var parse=parse$1;const normalizePath=e=>slash(/^[./]/.test(e)?e:`./${e}`);var __defProp$1=Object.defineProperty,__defProps$1=Object.defineProperties,__getOwnPropDescs$1=Object.getOwnPropertyDescriptors,__getOwnPropSymbols$1=Object.getOwnPropertySymbols,__hasOwnProp$1=Object.prototype.hasOwnProperty,__propIsEnum$1=Object.prototype.propertyIsEnumerable,__defNormalProp$1=(e,t,r)=>t in e?__defProp$1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues$1=(e,t)=>{for(var r in t||(t={}))__hasOwnProp$1.call(t,r)&&__defNormalProp$1(e,r,t[r]);if(__getOwnPropSymbols$1)for(var r of __getOwnPropSymbols$1(t))__propIsEnum$1.call(t,r)&&__defNormalProp$1(e,r,t[r]);return e},__spreadProps$1=(e,t)=>__defProps$1(e,__getOwnPropDescs$1(t));function readTsconfig(e){var t,r;const n=fs__default.default.realpathSync(e),o=path__default.default.dirname(n),a=fs__default.default.readFileSync(e,"utf8").trim();let s={};if(a&&(s=parse(a),!s||typeof s!="object"))throw new SyntaxError(`Failed to parse JSON: ${e}`);if(s.extends){let g=s.extends;try{g=require$1.resolve(g,{paths:[path__default.default.dirname(e)]})}catch(uu){if(uu.code==="MODULE_NOT_FOUND")try{g=require$1.resolve(path__default.default.join(g,"tsconfig.json"),{paths:[path__default.default.dirname(e)]})}catch{}}const l=readTsconfig(g);if(delete l.references,(t=l.compilerOptions)!=null&&t.baseUrl){const{compilerOptions:uu}=l;uu.baseUrl=path__default.default.relative(o,path__default.default.join(path__default.default.dirname(g),uu.baseUrl))}l.files&&(l.files=l.files.map(uu=>path__default.default.relative(o,path__default.default.join(path__default.default.dirname(g),uu)))),l.include&&(l.include=l.include.map(uu=>path__default.default.relative(o,path__default.default.join(path__default.default.dirname(g),uu)))),delete s.extends;const Du=__spreadProps$1(__spreadValues$1(__spreadValues$1({},l),s),{compilerOptions:__spreadValues$1(__spreadValues$1({},l.compilerOptions),s.compilerOptions)});l.watchOptions&&(Du.watchOptions=__spreadValues$1(__spreadValues$1({},l.watchOptions),s.watchOptions)),s=Du}if((r=s.compilerOptions)!=null&&r.baseUrl){const{compilerOptions:g}=s;g.baseUrl=normalizePath(g.baseUrl)}if(s.files&&(s.files=s.files.map(normalizePath)),s.include&&(s.include=s.include.map(slash)),s.watchOptions){const{watchOptions:g}=s;g.excludeDirectories&&(g.excludeDirectories=g.excludeDirectories.map(l=>slash(path__default.default.resolve(o,l))))}return s}function getTsconfig(e=process.cwd(),t="tsconfig.json"){const r=findConfigFile(e,t);if(!r)return null;const n=readTsconfig(r);return{path:r,config:n}}var dist=getTsconfig;const tsconfig=dist();var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));function esbuildTransform(e){const t=pluginutils.createFilter(/\.([cm]?ts|[jt]sx)$/);return{name:"esbuild-transform",async transform(r,n){var o;if(!t(n))return null;const a=await esbuild.transform(r,__spreadProps(__spreadValues({},e),{loader:"default",sourcefile:n.replace(/\.[cm]ts/,".ts"),tsconfigRaw:(o=tsconfig)==null?void 0:o.config}));return{code:a.code,map:a.map||null}}}}function esbuildMinify(e){return{name:"esbuild-minify",async renderChunk(t){const r=await esbuild.transform(t,__spreadProps(__spreadValues({},e),{minify:!0}));return{code:r.code,map:r.map||null}}}}const compareSemver=(e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2],externalizeNodeBuiltins=({target:e})=>{const t=e.some(r=>{var n,o;if(r=r.trim(),!r.startsWith("node"))return;const a=r.slice(4).split(".").map(Number),s=[a[0],(n=a[1])!=null?n:0,(o=a[2])!=null?o:0];return!(compareSemver(s,[12,20,0])>=0&&compareSemver(s,[13,0,0])<0||compareSemver(s,[14,13,1])>=0)});return{name:"externalize-node-builtins",resolveId:r=>{const n=r.startsWith("node:");if(t&&n&&(r=r.slice(5)),require$$2.builtinModules.includes(r)||n)return{id:r,external:!0}}}},patchBinary=e=>({name:"patch-binary",renderChunk(t,r,n){if(!r.isEntry||!r.facadeModuleId)return;const o=n.entryFileNames,a=`./${path__default$1.default.join(n.dir,o(r))}`;if(e.includes(a)){const s=new MagicString__default.default(t);return s.prepend(`#!/usr/bin/env node
33
- `),{code:s.toString(),map:n.sourcemap?s.generateMap({hires:!0}):void 0}}},async writeBundle(t,r){const n=t.entryFileNames,o=Object.values(r).map(async a=>{const s=a;if(s.isEntry&&s.facadeModuleId){const g=path__default$1.default.join(t.dir,n(s));await fs__default$1.default.promises.chmod(g,493)}});await Promise.all(o)}});function resolveTypescriptMjsCts(){const e=/\.(?:mjs|cjs)$/,t=/\.(?:mts|cts)$/;return{name:"resolve-typescript-mjs-cjs",resolveId(r,n,o){return e.test(r)&&n&&t.test(n)?this.resolve(r.replace(/js$/,"ts"),n,o):null}}}const getConfig={async type(e){const t=await Promise.resolve().then(function(){return require("./rollup-plugin-dts-4870e282.js")});return{input:[],preserveEntrySignatures:"strict",plugins:[externalizeNodeBuiltins(e),resolveTypescriptMjsCts(),t.default({respectExternal:!0})],output:[],external:[]}},app(e,t,r){const n={target:e.target};return{input:[],preserveEntrySignatures:"strict",plugins:[externalizeNodeBuiltins(e),resolveTypescriptMjsCts(),alias__default.default({entries:t}),nodeResolve__default.default({extensions:[".mjs",".js",".ts",".jsx",".tsx",".json"],exportConditions:["node","import","require","default"]}),commonjs__default.default(),json__default.default(),esbuildTransform(n),createRequire(),...e.minify?[esbuildMinify(n)]:[],patchBinary(r)],output:[],external:[]}}};async function getRollupConfigs(e,t,r,n,o,a){const s=r.filter(({exportEntry:l})=>l.isExecutable).map(({exportEntry:l})=>l.outputPath),g=Object.create(null);for(const{input:l,exportEntry:Du}of r){if(Du.type==="types"){let nu=g.type;nu||(nu=await getConfig.type(n),nu.external=a,g.type=nu),nu.input.push(l);const lu=".d.ts";nu.output=[{dir:t,entryFileNames:Cu=>fs__default$1.default.realpathSync(Cu.facadeModuleId).slice(e.length).replace(/\.\w+$/,lu),exports:"auto",format:"esm"}];continue}let uu=g.app;uu||(uu=getConfig.app(n,o,s),uu.external=a,g.app=uu),uu.input.includes(l)||uu.input.push(l);const eu=uu.output,tu=path__default$1.default.extname(Du.outputPath),ou=`${Du.type}-${tu}`;if(!eu[ou]){const nu={dir:t,exports:"auto",format:Du.type,chunkFileNames:`[name]-[hash]${tu}`,plugins:[isFormatEsm(Du.type==="module")],entryFileNames:lu=>lu.facadeModuleId.slice(e.length).replace(/\.\w+$/,tu)};eu.push(nu),eu[ou]=nu}}return g}let enabled=!0;const globalVar=typeof self!="undefined"?self:typeof window!="undefined"?window:typeof global!="undefined"?global:{};let supportLevel=0;if(globalVar.process&&globalVar.process.env&&globalVar.process.stdout){const{FORCE_COLOR:e,NODE_DISABLE_COLORS:t,TERM:r}=globalVar.process.env;t||e==="0"?enabled=!1:e==="1"?enabled=!0:r==="dumb"?enabled=!1:"CI"in globalVar.process.env&&["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(n=>n in globalVar.process.env)?enabled=!0:enabled=process.stdout.isTTY,enabled&&(supportLevel=r&&r.endsWith("-256color")?2:1)}let options={enabled,supportLevel};function kolorist(e,t,r=1){const n=`\x1B[${e}m`,o=`\x1B[${t}m`,a=new RegExp(`\\x1b\\[${t}m`,"g");return s=>options.enabled&&options.supportLevel>=r?n+(""+s).replace(a,n)+o:""+s}const gray=kolorist(90,39),currentTime=()=>new Date().toLocaleTimeString(),log=(...e)=>console.log(`[${gray(currentTime())}]`,...e);var _a,_b;const argv=dist$1.cli({name:"pkgroll",flags:{src:{type:String,description:"Source directory",default:"./src"},dist:{type:String,description:"Distribution directory",default:"./dist"},minify:{type:Boolean,description:"Minify output",alias:"m",default:!1},target:{type:[String],default:[`node${process.versions.node}`],description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",alias:"t"},watch:{type:Boolean,description:"Watch mode",alias:"w",default:!1}},help:{description:"Minimalistic package bundler"}}),cwd=process.cwd(),sourcePath=normalizePath$1(argv.flags.src,!0),distPath=normalizePath$1(argv.flags.dist,!0),tsconfigTarget=(_b=(_a=tsconfig)==null?void 0:_a.config.compilerOptions)==null?void 0:_b.target;tsconfigTarget&&argv.flags.target.push(tsconfigTarget),(async()=>{const e=await readPackageJson(cwd),t=getExportEntries(e);if(t.length===0)throw new Error("No export entries found in package.json");const r=await Promise.all(t.map(async s=>({input:await getSourcePath(s,sourcePath,distPath),exportEntry:s}))),n=getAliases(e,cwd),o=getExternalDependencies(e).filter(s=>!(s in n)).flatMap(s=>[s,new RegExp(`^${s}/`)]),a=await getRollupConfigs(normalizePath$1(fs__default$1.default.realpathSync(sourcePath),!0),distPath,r,argv.flags,n,o);argv.flags.watch?(log("Watch initialized"),Object.values(a).map(async s=>{rollup.watch(s).on("event",async l=>{l.code==="BUNDLE_START"&&log("Building",...Array.isArray(l.input)?l.input:[l.input]),l.code==="BUNDLE_END"&&(await Promise.all(s.output.map(Du=>l.result.write(Du))),log("Built",...Array.isArray(l.input)?l.input:[l.input])),l.code==="ERROR"&&log("Error:",l.error.message)})})):await Promise.all(Object.values(a).map(async s=>{const g=await rollup.rollup(s);return Promise.all(s.output.map(l=>g.write(l)))}))})().catch(e=>{console.error("Error:",e.message),process.exit(1)});
30
+ `}}),Xt=u=>({name:"create-require-insert-format",renderChunk:yu.default({[sD]:u}).renderChunk});var ur=x.default,Dr=P.default;function lD(u){return u&&typeof u=="object"&&"default"in u?u:{default:u}}var b=lD(ur),gu=lD(Dr);function Q(u){const D=/^\\\\\?\\/.test(u),e=/[^\u0000-\u0080]+/.test(u);return D||e?u:u.replace(/\\/g,"/")}function er(u,D){for(;;){const e=b.default.join(u,D);if(gu.default.existsSync(e))return Q(e);const t=b.default.dirname(u);if(t===u)return;u=t}}var FD=KD;function tr(u,D){D===void 0&&(D=!1);var e=u.length,t=0,r="",n=0,o=16,i=0,a=0,s=0,l=0,F=0;function c(C,y){for(var w=0,A=0;w<C||!y;){var m=u.charCodeAt(t);if(m>=48&&m<=57)A=A*16+m-48;else if(m>=65&&m<=70)A=A*16+m-65+10;else if(m>=97&&m<=102)A=A*16+m-97+10;else break;t++,w++}return w<C&&(A=-1),A}function f(C){t=C,r="",n=0,o=16,F=0}function p(){var C=t;if(u.charCodeAt(t)===48)t++;else for(t++;t<u.length&&I(u.charCodeAt(t));)t++;if(t<u.length&&u.charCodeAt(t)===46)if(t++,t<u.length&&I(u.charCodeAt(t)))for(t++;t<u.length&&I(u.charCodeAt(t));)t++;else return F=3,u.substring(C,t);var y=t;if(t<u.length&&(u.charCodeAt(t)===69||u.charCodeAt(t)===101))if(t++,(t<u.length&&u.charCodeAt(t)===43||u.charCodeAt(t)===45)&&t++,t<u.length&&I(u.charCodeAt(t))){for(t++;t<u.length&&I(u.charCodeAt(t));)t++;y=t}else F=3;return u.substring(C,y)}function E(){for(var C="",y=t;;){if(t>=e){C+=u.substring(y,t),F=2;break}var w=u.charCodeAt(t);if(w===34){C+=u.substring(y,t),t++;break}if(w===92){if(C+=u.substring(y,t),t++,t>=e){F=2;break}var A=u.charCodeAt(t++);switch(A){case 34:C+='"';break;case 92:C+="\\";break;case 47:C+="/";break;case 98:C+="\b";break;case 102:C+="\f";break;case 110:C+=`
31
+ `;break;case 114:C+="\r";break;case 116:C+=" ";break;case 117:var m=c(4,!0);m>=0?C+=String.fromCharCode(m):F=4;break;default:F=5}y=t;continue}if(w>=0&&w<=31)if(V(w)){C+=u.substring(y,t),F=2;break}else F=6;t++}return C}function B(){if(r="",F=0,n=t,a=i,l=s,t>=e)return n=e,o=17;var C=u.charCodeAt(t);if(hu(C)){do t++,r+=String.fromCharCode(C),C=u.charCodeAt(t);while(hu(C));return o=15}if(V(C))return t++,r+=String.fromCharCode(C),C===13&&u.charCodeAt(t)===10&&(t++,r+=`
32
+ `),i++,s=t,o=14;switch(C){case 123:return t++,o=1;case 125:return t++,o=2;case 91:return t++,o=3;case 93:return t++,o=4;case 58:return t++,o=6;case 44:return t++,o=5;case 34:return t++,r=E(),o=10;case 47:var y=t-1;if(u.charCodeAt(t+1)===47){for(t+=2;t<e&&!V(u.charCodeAt(t));)t++;return r=u.substring(y,t),o=12}if(u.charCodeAt(t+1)===42){t+=2;for(var w=e-1,A=!1;t<w;){var m=u.charCodeAt(t);if(m===42&&u.charCodeAt(t+1)===47){t+=2,A=!0;break}t++,V(m)&&(m===13&&u.charCodeAt(t)===10&&t++,i++,s=t)}return A||(t++,F=1),r=u.substring(y,t),o=13}return r+=String.fromCharCode(C),t++,o=16;case 45:if(r+=String.fromCharCode(C),t++,t===e||!I(u.charCodeAt(t)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return r+=p(),o=11;default:for(;t<e&&g(C);)t++,C=u.charCodeAt(t);if(n!==t){switch(r=u.substring(n,t),r){case"true":return o=8;case"false":return o=9;case"null":return o=7}return o=16}return r+=String.fromCharCode(C),t++,o=16}}function g(C){if(hu(C)||V(C))return!1;switch(C){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function d(){var C;do C=B();while(C>=12&&C<=15);return C}return{setPosition:f,getPosition:function(){return t},scan:D?d:B,getToken:function(){return o},getTokenValue:function(){return r},getTokenOffset:function(){return n},getTokenLength:function(){return t-n},getTokenStartLine:function(){return a},getTokenStartCharacter:function(){return n-l},getTokenError:function(){return F}}}function hu(u){return u===32||u===9||u===11||u===12||u===160||u===5760||u>=8192&&u<=8203||u===8239||u===8287||u===12288||u===65279}function V(u){return u===10||u===13||u===8232||u===8233}function I(u){return u>=48&&u<=57}var X;(function(u){u.DEFAULT={allowTrailingComma:!1}})(X||(X={}));function rr(u,D,e){D===void 0&&(D=[]),e===void 0&&(e=X.DEFAULT);var t=null,r=[],n=[];function o(a){Array.isArray(r)?r.push(a):t!==null&&(r[t]=a)}var i={onObjectBegin:function(){var a={};o(a),n.push(r),r=a,t=null},onObjectProperty:function(a){t=a},onObjectEnd:function(){r=n.pop()},onArrayBegin:function(){var a=[];o(a),n.push(r),r=a,t=null},onArrayEnd:function(){r=n.pop()},onLiteralValue:o,onError:function(a,s,l){D.push({error:a,offset:s,length:l})}};return nr(u,i,e),r[0]}function nr(u,D,e){e===void 0&&(e=X.DEFAULT);var t=tr(u,!1);function r(h){return h?function(){return h(t.getTokenOffset(),t.getTokenLength(),t.getTokenStartLine(),t.getTokenStartCharacter())}:function(){return!0}}function n(h){return h?function($){return h($,t.getTokenOffset(),t.getTokenLength(),t.getTokenStartLine(),t.getTokenStartCharacter())}:function(){return!0}}var o=r(D.onObjectBegin),i=n(D.onObjectProperty),a=r(D.onObjectEnd),s=r(D.onArrayBegin),l=r(D.onArrayEnd),F=n(D.onLiteralValue),c=n(D.onSeparator),f=r(D.onComment),p=n(D.onError),E=e&&e.disallowComments,B=e&&e.allowTrailingComma;function g(){for(;;){var h=t.scan();switch(t.getTokenError()){case 4:d(14);break;case 5:d(15);break;case 3:d(13);break;case 1:E||d(11);break;case 2:d(12);break;case 6:d(16);break}switch(h){case 12:case 13:E?d(10):f();break;case 16:d(1);break;case 15:case 14:break;default:return h}}}function d(h,$,G){if($===void 0&&($=[]),G===void 0&&(G=[]),p(h),$.length+G.length>0)for(var Z=t.getToken();Z!==17;){if($.indexOf(Z)!==-1){g();break}else if(G.indexOf(Z)!==-1)break;Z=g()}}function C(h){var $=t.getTokenValue();return h?F($):i($),g(),!0}function y(){switch(t.getToken()){case 11:var h=t.getTokenValue(),$=Number(h);isNaN($)&&(d(2),$=0),F($);break;case 7:F(null);break;case 8:F(!0);break;case 9:F(!1);break;default:return!1}return g(),!0}function w(){return t.getToken()!==10?(d(3,[],[2,5]),!1):(C(!1),t.getToken()===6?(c(":"),g(),Du()||d(4,[],[2,5])):d(5,[],[2,5]),!0)}function A(){o(),g();for(var h=!1;t.getToken()!==2&&t.getToken()!==17;){if(t.getToken()===5){if(h||d(4,[],[]),c(","),g(),t.getToken()===2&&B)break}else h&&d(6,[],[]);w()||d(4,[],[2,5]),h=!0}return a(),t.getToken()!==2?d(7,[2],[]):g(),!0}function m(){s(),g();for(var h=!1;t.getToken()!==4&&t.getToken()!==17;){if(t.getToken()===5){if(h||d(4,[],[]),c(","),g(),t.getToken()===4&&B)break}else h&&d(6,[],[]);Du()||d(4,[],[4,5]),h=!0}return l(),t.getToken()!==4?d(8,[4],[]):g(),!0}function Du(){switch(t.getToken()){case 3:return m();case 1:return A();case 10:return C(!0);default:return y()}}return g(),t.getToken()===17?e.allowEmptyContent?!0:(d(4,[],[]),!1):Du()?(t.getToken()!==17&&d(9,[],[]),!0):(d(4,[],[]),!1)}var or=rr;const cD=u=>Q(/^[./]/.test(u)?u:`./${u}`);var ar=Object.defineProperty,ir=Object.defineProperties,sr=Object.getOwnPropertyDescriptors,CD=Object.getOwnPropertySymbols,lr=Object.prototype.hasOwnProperty,Fr=Object.prototype.propertyIsEnumerable,fD=(u,D,e)=>D in u?ar(u,D,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[D]=e,M=(u,D)=>{for(var e in D||(D={}))lr.call(D,e)&&fD(u,e,D[e]);if(CD)for(var e of CD(D))Fr.call(D,e)&&fD(u,e,D[e]);return u},cr=(u,D)=>ir(u,sr(D));function pD(u){var D,e;const t=gu.default.realpathSync(u),r=b.default.dirname(t),n=gu.default.readFileSync(u,"utf8").trim();let o={};if(n&&(o=or(n),!o||typeof o!="object"))throw new SyntaxError(`Failed to parse JSON: ${u}`);if(o.extends){let i=o.extends;try{i=FD.resolve(i,{paths:[b.default.dirname(u)]})}catch(l){if(l.code==="MODULE_NOT_FOUND")try{i=FD.resolve(b.default.join(i,"tsconfig.json"),{paths:[b.default.dirname(u)]})}catch{}}const a=pD(i);if(delete a.references,(D=a.compilerOptions)!=null&&D.baseUrl){const{compilerOptions:l}=a;l.baseUrl=b.default.relative(r,b.default.join(b.default.dirname(i),l.baseUrl))}a.files&&(a.files=a.files.map(l=>b.default.relative(r,b.default.join(b.default.dirname(i),l)))),a.include&&(a.include=a.include.map(l=>b.default.relative(r,b.default.join(b.default.dirname(i),l)))),delete o.extends;const s=cr(M(M({},a),o),{compilerOptions:M(M({},a.compilerOptions),o.compilerOptions)});a.watchOptions&&(s.watchOptions=M(M({},a.watchOptions),o.watchOptions)),o=s}if((e=o.compilerOptions)!=null&&e.baseUrl){const{compilerOptions:i}=o;i.baseUrl=cD(i.baseUrl)}if(o.files&&(o.files=o.files.map(cD)),o.include&&(o.include=o.include.map(Q)),o.watchOptions){const{watchOptions:i}=o;i.excludeDirectories&&(i.excludeDirectories=i.excludeDirectories.map(a=>Q(b.default.resolve(r,a))))}return o}function Cr(u=process.cwd(),D="tsconfig.json"){const e=er(u,D);if(!e)return null;const t=pD(e);return{path:e,config:t}}var fr=Cr;const dD=fr();var pr=Object.defineProperty,dr=Object.defineProperties,Er=Object.getOwnPropertyDescriptors,ED=Object.getOwnPropertySymbols,gr=Object.prototype.hasOwnProperty,hr=Object.prototype.propertyIsEnumerable,gD=(u,D,e)=>D in u?pr(u,D,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[D]=e,hD=(u,D)=>{for(var e in D||(D={}))gr.call(D,e)&&gD(u,e,D[e]);if(ED)for(var e of ED(D))hr.call(D,e)&&gD(u,e,D[e]);return u},mD=(u,D)=>dr(u,Er(D));function mr(u){const D=qD.createFilter(/\.([cm]?ts|[jt]sx)$/);return{name:"esbuild-transform",async transform(e,t){var r;if(!D(t))return null;const n=await bu.transform(e,mD(hD({},u),{loader:"default",sourcefile:t.replace(/\.[cm]ts/,".ts"),tsconfigRaw:(r=dD)==null?void 0:r.config}));return{code:n.code,map:n.map||null}}}}const Br=u=>{if(u==="es")return"esm";if(u==="cjs"||u==="iife")return u};function br(u){return{name:"esbuild-minify",async renderChunk(D,e,t){const r=await bu.transform(D,mD(hD({},u),{format:Br(t.format),minify:!0}));return{code:r.code,map:r.map||null}}}}const mu=(u,D)=>u[0]-D[0]||u[1]-D[1]||u[2]-D[2],BD=({target:u})=>{const D=u.some(e=>{var t,r;if(e=e.trim(),!e.startsWith("node"))return;const n=e.slice(4).split(".").map(Number),o=[n[0],(t=n[1])!=null?t:0,(r=n[2])!=null?r:0];return!(mu(o,[12,20,0])>=0&&mu(o,[13,0,0])<0||mu(o,[14,13,1])>=0)});return{name:"externalize-node-builtins",resolveId:e=>{const t=e.startsWith("node:");if(D&&t&&(e=e.slice(5)),WD.builtinModules.includes(e)||t)return{id:e,external:!0}}}},yr=u=>({name:"patch-binary",renderChunk(D,e,t){if(!e.isEntry||!e.facadeModuleId)return;const r=t.entryFileNames,n=`./${x.default.join(t.dir,r(e))}`;if(u.includes(n)){const o=new HD.default(D);return o.prepend(`#!/usr/bin/env node
33
+ `),{code:o.toString(),map:t.sourcemap?o.generateMap({hires:!0}):void 0}}},async writeBundle(D,e){const t=D.entryFileNames,r=Object.values(e).map(async n=>{const o=n;if(o.isEntry&&o.facadeModuleId){const i=x.default.join(D.dir,t(o));await P.default.promises.chmod(i,493)}});await Promise.all(r)}});function bD(){const u=/\.(?:mjs|cjs)$/,D=/\.(?:mts|cts)$/;return{name:"resolve-typescript-mjs-cjs",resolveId(e,t,r){return u.test(e)&&t&&D.test(t)?this.resolve(e.replace(/js$/,"ts"),t,r):null}}}const yD={async type(u){const D=await Promise.resolve().then(function(){return require("./rollup-plugin-dts-845e9d7e.js")});return{input:[],preserveEntrySignatures:"strict",plugins:[BD(u),bD(),D.default({respectExternal:!0})],output:[],external:[]}},app(u,D,e,t){const r={target:u.target};return{input:[],preserveEntrySignatures:"strict",plugins:[BD(u),bD(),JD.default({entries:D}),zD.default({extensions:[".mjs",".js",".ts",".jsx",".tsx",".json"],exportConditions:["node","import","require","default"]}),...Object.keys(e).length>0?[yu.default({preventAssignment:!0,objectGuards:!0,values:e})]:[],GD.default(),ZD.default(),mr(r),Qt(),...u.minify?[br(r)]:[],yr(t)],output:[],external:[]}}};async function Ar(u,D,e,t,r,n){const o=e.filter(({exportEntry:s})=>s.isExecutable).map(({exportEntry:s})=>s.outputPath),i=Object.create(null),a=Object.fromEntries(t.env.map(({key:s,value:l})=>[`process.env.${s}`,JSON.stringify(l)]));for(const{input:s,exportEntry:l}of e){if(l.type==="types"){let E=i.type;E||(E=await yD.type(t),E.external=n,i.type=E),E.input.push(s);const B=".d.ts";E.output=[{dir:D,entryFileNames:g=>P.default.realpathSync.native(g.facadeModuleId).slice(u.length).replace(/\.\w+$/,B),exports:"auto",format:"esm"}];continue}let F=i.app;F||(F=yD.app(t,r,a,o),F.external=n,i.app=F),F.input.includes(s)||F.input.push(s);const c=F.output,f=x.default.extname(l.outputPath),p=`${l.type}-${f}`;if(!c[p]){const E={dir:D,exports:"auto",format:l.type,chunkFileNames:`[name]-[hash]${f}`,plugins:[Xt(l.type==="module")],entryFileNames:B=>P.default.realpathSync.native(B.facadeModuleId).slice(u.length).replace(/\.\w+$/,f)};c.push(E),c[p]=E}}return i}let S=!0;const R=typeof self!="undefined"?self:typeof window!="undefined"?window:typeof global!="undefined"?global:{};let AD=0;if(R.process&&R.process.env&&R.process.stdout){const{FORCE_COLOR:u,NODE_DISABLE_COLORS:D,TERM:e}=R.process.env;D||u==="0"?S=!1:u==="1"?S=!0:e==="dumb"?S=!1:"CI"in R.process.env&&["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(t=>t in R.process.env)?S=!0:S=process.stdout.isTTY,S&&(AD=e&&e.endsWith("-256color")?2:1)}let vD={enabled:S,supportLevel:AD};function vr(u,D,e=1){const t=`\x1B[${u}m`,r=`\x1B[${D}m`,n=new RegExp(`\\x1b\\[${D}m`,"g");return o=>vD.enabled&&vD.supportLevel>=e?t+(""+o).replace(n,t)+r:""+o}const wr=vr(90,39),$r=()=>new Date().toLocaleTimeString(),uu=(...u)=>console.log(`[${wr($r())}]`,...u);var wD,$D;const z=Ju({name:"pkgroll",flags:{src:{type:String,description:"Source directory",default:"./src"},dist:{type:String,description:"Distribution directory",default:"./dist"},minify:{type:Boolean,description:"Minify output",alias:"m",default:!1},target:{type:[String],default:[`node${process.versions.node}`],description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",alias:"t"},watch:{type:Boolean,description:"Watch mode",alias:"w",default:!1},env:{type:[function(D){const[e,t]=D.split("=");return{key:e,value:t}}],description:"Compile-time environment variables (eg. --env.NODE_ENV=production)"}},help:{description:"Minimalistic package bundler",render(u,D){return D.flagOperator=e=>e.name==="env"?".key=":" ",D.render(u)}}}),OD=process.cwd(),jD=K(z.flags.src,!0),_D=K(z.flags.dist,!0),PD=($D=(wD=dD)==null?void 0:wD.config.compilerOptions)==null?void 0:$D.target;PD&&z.flags.target.push(PD),(async()=>{const u=await xt(OD),D=Rt(u);if(D.length===0)throw new Error("No export entries found in package.json");const e=await Promise.all(D.map(async o=>({input:await Vt(o,jD,_D),exportEntry:o}))),t=Wt(u,OD),r=qt(u).filter(o=>!(o in t)).flatMap(o=>[o,new RegExp(`^${o}/`)]),n=await Ar(K(P.default.realpathSync.native(jD),!0),_D,e,z.flags,t,r);z.flags.watch?(uu("Watch initialized"),Object.values(n).map(async o=>{Bu.watch(o).on("event",async a=>{a.code==="BUNDLE_START"&&uu("Building",...Array.isArray(a.input)?a.input:[a.input]),a.code==="BUNDLE_END"&&(await Promise.all(o.output.map(s=>a.result.write(s))),uu("Built",...Array.isArray(a.input)?a.input:[a.input])),a.code==="ERROR"&&uu("Error:",a.error.message)})})):await Promise.all(Object.values(n).map(async o=>{const i=await Bu.rollup(o);return Promise.all(o.output.map(a=>i.write(a)))}))})().catch(u=>{console.error("Error:",u.message),process.exit(1)});
@@ -0,0 +1,24 @@
1
+ "use strict";var Q=Object.defineProperty,Z=Object.defineProperties;var X=Object.getOwnPropertyDescriptors;var O=Object.getOwnPropertySymbols;var ee=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable;var V=(i,e,t)=>e in i?Q(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,I=(i,e)=>{for(var t in e||(e={}))ee.call(e,t)&&V(i,t,e[t]);if(O)for(var t of O(e))te.call(e,t)&&V(i,t,e[t]);return i},K=(i,e)=>Z(i,X(e));var re=require("module"),ne=require("path"),ie=require("magic-string");function se(i){return i&&typeof i=="object"&&"default"in i?i:{default:i}}function ae(i){if(i&&i.__esModule)return i;var e=Object.create(null);return i&&Object.keys(i).forEach(function(t){if(t!=="default"){var n=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:function(){return i[t]}})}}),e.default=i,Object.freeze(e)}var T=ae(ne),oe=se(ie),M=require;function ce(){const i=process.cwd();try{return M.resolve("typescript",{paths:[i]})}catch{throw new Error(`Could not find \`typescript\` in ${i}`)}}var r=M(ce());const $=".d.ts",R={getCurrentDirectory:()=>r.sys.getCurrentDirectory(),getNewLine:()=>r.sys.newLine,getCanonicalFileName:r.sys.useCaseSensitiveFileNames?i=>i:i=>i.toLowerCase()},le={declaration:!0,noEmit:!1,emitDeclarationOnly:!0,noEmitOnError:!0,checkJs:!1,declarationMap:!1,skipLibCheck:!0,preserveSymlinks:!0,target:r.ScriptTarget.ESNext};function q(i,e){const t=I(I({},le),e);let n=T.dirname(i),s=[];const o=r.findConfigFile(n,r.sys.fileExists);if(!o)return{dtsFiles:s,dirName:n,compilerOptions:t};n=T.dirname(o);const{config:p,error:c}=r.readConfigFile(o,r.sys.readFile);if(c)return console.error(r.formatDiagnostic(c,R)),{dtsFiles:s,dirName:n,compilerOptions:t};const{fileNames:l,options:m,errors:f}=r.parseJsonConfigFileContent(p,r.sys,n);return s=l.filter(d=>d.endsWith($)),f.length?(console.error(r.formatDiagnostics(f,R)),{dtsFiles:s,dirName:n,compilerOptions:t}):{dtsFiles:s,dirName:n,compilerOptions:I(I({},m),t)}}function pe(i,e){const{dtsFiles:t,compilerOptions:n}=q(i,e);return r.createProgram([i].concat(Array.from(t)),n,r.createCompilerHost(n,!0))}function fe(i,e){const t=[];let n=[],s=new Set,o="",p={};for(let c of i){if(c.endsWith($))continue;c=T.resolve(c);const l=q(c,e);if(l.dtsFiles.forEach(s.add,s),!n.length){n.push(c),{dirName:o,compilerOptions:p}=l;continue}if(l.dirName===o)n.push(c);else{const m=r.createCompilerHost(p,!0),f=r.createProgram(n.concat(Array.from(s)),p,m);t.push(f),n=[c],{dirName:o,compilerOptions:p}=l}}if(n.length){const c=r.createCompilerHost(p,!0),l=r.createProgram(n.concat(Array.from(s)),p,c);t.push(l)}return t}function ue(){let i;try{return{codeFrameColumns:i}=M("@babel/code-frame"),i}catch{try{return{codeFrameColumns:i}=re.createRequire(typeof document=="undefined"?new(require("url")).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("rollup-plugin-dts-845e9d7e.js",document.baseURI).href)("@babel/code-frame"),i}catch{}}}function me(i){const e=i.getSourceFile(),t=e.getLineAndCharacterOfPosition(i.getStart()),n=e.getLineAndCharacterOfPosition(i.getEnd());return{start:{line:t.line+1,column:t.character+1},end:{line:n.line+1,column:n.character+1}}}function de(i){const e=ue(),n=i.getSourceFile().getFullText(),s=me(i);return e?`
2
+ `+e(n,s,{highlightCode:!0}):`
3
+ ${s.start.line}:${s.start.column}: \`${i.getFullText().trim()}\``}class h extends Error{constructor(e,t="Syntax not yet supported"){super(`${t}
4
+ ${de(e)}`)}}class ye{constructor(e){this.sourceFile=e}findNamespaces(){const e=[],t={};for(const n of this.sourceFile.statements){const s={start:n.getStart(),end:n.getEnd()};if(r.isEmptyStatement(n)){e.unshift({name:"",exports:[],location:s});continue}if((r.isImportDeclaration(n)||r.isExportDeclaration(n))&&n.moduleSpecifier&&r.isStringLiteral(n.moduleSpecifier)){let{text:f}=n.moduleSpecifier;if(f.startsWith(".")&&(f.endsWith(".d.ts")||f.endsWith(".d.cts")||f.endsWith(".d.mts"))){let d=n.moduleSpecifier.getStart()+1,w=n.moduleSpecifier.getEnd()-1;e.unshift({name:"",exports:[],location:{start:d,end:w},textBeforeCodeAfter:f.replace(/\.d\.ts$/,".js").replace(/\.d\.cts$/,".cjs").replace(/\.d\.mts$/,".mjs")})}}if(r.isModuleDeclaration(n)&&n.body&&r.isModuleBlock(n.body)){for(const f of n.body.statements)if(r.isExportDeclaration(f)&&f.exportClause){if(r.isNamespaceExport(f.exportClause))continue;for(const d of f.exportClause.elements)d.propertyName&&d.propertyName.getText()==d.name.getText()&&e.unshift({name:"",exports:[],location:{start:d.propertyName.getEnd(),end:d.name.getEnd()}})}}if(r.isClassDeclaration(n)?t[n.name.getText()]={type:"class",generics:n.typeParameters}:r.isFunctionDeclaration(n)?t[n.name.getText()]={type:"function"}:r.isInterfaceDeclaration(n)?t[n.name.getText()]={type:"interface",generics:n.typeParameters}:r.isTypeAliasDeclaration(n)?t[n.name.getText()]={type:"type",generics:n.typeParameters}:r.isModuleDeclaration(n)&&r.isIdentifier(n.name)?t[n.name.getText()]={type:"namespace"}:r.isEnumDeclaration(n)&&(t[n.name.getText()]={type:"enum"}),!r.isVariableStatement(n))continue;const{declarations:o}=n.declarationList;if(o.length!==1)continue;const p=o[0],c=p.name.getText();if(!p.initializer||!r.isCallExpression(p.initializer)){t[c]={type:"var"};continue}const l=p.initializer.arguments[0];if(!p.initializer.expression.getFullText().includes("/*#__PURE__*/Object.freeze")||!r.isObjectLiteralExpression(l))continue;const m=[];for(const f of l.properties){if(!r.isPropertyAssignment(f)||!(r.isIdentifier(f.name)||r.isStringLiteral(f.name))||f.name.text!=="__proto__"&&!r.isIdentifier(f.initializer))throw new h(f,"Expected a property assignment");f.name.text!=="__proto__"&&m.push({exportedName:f.name.text,localName:f.initializer.getText()})}e.unshift({name:c,exports:m,location:s})}return{namespaces:e,itemTypes:t}}fix(){var e;let t=this.sourceFile.getFullText();const{namespaces:n,itemTypes:s}=this.findNamespaces();for(const o of n){const p=t.slice(o.location.end);t=t.slice(0,o.location.start);for(const{exportedName:c,localName:l}of o.exports)if(c===l){const{type:m,generics:f}=s[l]||{};if(m==="interface"||m==="type"){const d=U(f);t+=`type ${o.name}_${c}${d.in} = ${l}${d.out};
5
+ `}else if(m==="enum"||m==="class"){const d=U(f);t+=`type ${o.name}_${c}${d.in} = ${l}${d.out};
6
+ `,t+=`declare const ${o.name}_${c}: typeof ${l};
7
+ `}else t+=`declare const ${o.name}_${c}: typeof ${l};
8
+ `}if(o.name){t+=`declare namespace ${o.name} {
9
+ `,t+=` export {
10
+ `;for(const{exportedName:c,localName:l}of o.exports)c===l?t+=` ${o.name}_${c} as ${c},
11
+ `:t+=` ${l} as ${c},
12
+ `;t+=` };
13
+ `,t+="}"}t+=(e=o.textBeforeCodeAfter)!==null&&e!==void 0?e:"",t+=p}return t}}function U(i){return!i||!i.length?{in:"",out:""}:{in:`<${i.map(e=>e.getText()).join(", ")}>`,out:`<${i.map(e=>e.name.getText()).join(", ")}>`}}let B=1;function he(i){return S({type:"Program",sourceType:"module",body:[]},{start:i.getFullStart(),end:i.getEnd()})}function ge(i){return{type:"AssignmentPattern",left:{type:"Identifier",name:String(B++)},right:i}}function v(i){return S({type:"Identifier",name:i.getText()},i)}function xe(i){const e=S({type:"FunctionExpression",id:null,params:[],body:{type:"BlockStatement",body:[]}},i),t=S({type:"ExpressionStatement",expression:{type:"CallExpression",callee:{type:"Identifier",name:String(B++)},arguments:[e],optional:!1}},i);return{fn:e,iife:t}}function Se(i,e){return S({type:"FunctionDeclaration",id:S({type:"Identifier",name:r.idText(i)},i),params:[],body:{type:"BlockStatement",body:[]}},e)}function P(i){if(r.isLiteralExpression(i))return{type:"Literal",value:i.text};if(r.isPropertyAccessExpression(i)){if(r.isPrivateIdentifier(i.name))throw new h(i.name);return S({type:"MemberExpression",computed:!1,optional:!1,object:P(i.expression),property:P(i.name)},{start:i.expression.getStart(),end:i.name.getEnd()})}if(r.isIdentifier(i))return v(i);if(i.kind==r.SyntaxKind.NullKeyword)return{type:"Literal",value:null};throw new h(i)}function S(i,e){let t="start"in e?e:{start:e.getStart(),end:e.getEnd()};return Object.assign(i,t)}function L(i,e){return(r.getCombinedModifierFlags(i)&e)===e}function ve({sourceFile:i}){const e=new oe.default(i.getFullText()),t=new Set,n=new Set;let s="";const o=new Map,p=new Map;for(const a of i.statements){if(r.isEmptyStatement(a)){e.remove(a.getStart(),a.getEnd());continue}if(r.isEnumDeclaration(a)||r.isFunctionDeclaration(a)||r.isInterfaceDeclaration(a)||r.isClassDeclaration(a)||r.isTypeAliasDeclaration(a)||r.isModuleDeclaration(a)){if(a.name){const u=a.name.getText();t.add(u),L(a,r.ModifierFlags.ExportDefault)?s=u:L(a,r.ModifierFlags.Export)&&n.add(u),a.flags&r.NodeFlags.GlobalAugmentation||N(u,[_(a),W(a)])}r.isModuleDeclaration(a)&&Te(e,a),z(e,a)}else if(r.isVariableStatement(a)){const{declarations:u}=a.declarationList,g=L(a,r.ModifierFlags.Export);for(const x of a.declarationList.declarations)if(r.isIdentifier(x.name)){const D=x.name.getText();t.add(D),g&&n.add(D)}if(z(e,a),u.length==1){const x=u[0];r.isIdentifier(x.name)&&N(x.name.getText(),[_(a),W(a)])}else{const x=u.slice(),D=x.shift();N(D.name.getText(),[_(a),D.getEnd()]);for(const C of x)r.isIdentifier(C.name)&&N(C.name.getText(),[C.getFullStart(),C.getEnd()])}const{flags:y}=a.declarationList,F=`declare ${y&r.NodeFlags.Let?"let":y&r.NodeFlags.Const?"const":"var"} `,A=a.declarationList.getChildren().find(x=>x.kind===r.SyntaxKind.SyntaxList).getChildren();let E=0;for(const x of A)if(x.kind===r.SyntaxKind.CommaToken)E=x.getStart(),e.remove(E,x.getEnd());else if(E){e.appendLeft(E,`;
14
+ `);const D=x.getFullStart(),C=e.slice(D,x.getStart());let j=C.length-C.trimStart().length;j?e.overwrite(D,D+j,F):e.appendLeft(D,F)}}}for(const a of i.statements)if(f(a),!!L(a,r.ModifierFlags.ExportDefault)&&(r.isFunctionDeclaration(a)||r.isClassDeclaration(a))){if(a.name)continue;s||(s=w("export_default"));const u=a.getChildren(),g=u.findIndex(A=>A.kind===r.SyntaxKind.ClassKeyword||A.kind===r.SyntaxKind.FunctionKeyword),y=u[g],b=u[g+1];b.kind>=r.SyntaxKind.FirstPunctuation&&b.kind<=r.SyntaxKind.LastPunctuation?e.appendLeft(b.getStart(),s):e.appendRight(y.getEnd(),` ${s}`)}for(const a of p.values()){const g=a.pop()[0];for(const y of a)e.move(y[0],y[1],g)}s&&e.append(`
15
+ export default ${s};
16
+ `),n.size&&e.append(`
17
+ export { ${[...n].join(", ")} };
18
+ `);for(const[a,u]of o.entries())e.prepend(`import * as ${u} from "${a}";
19
+ `);const c=i.getLineStarts(),l=new Set;for(const a of i.typeReferenceDirectives){l.add(a.fileName);const{line:u}=i.getLineAndCharacterOfPosition(a.pos),g=c[u];let y=i.getLineEndOfPosition(a.pos);e.slice(y,y+1)==`
20
+ `&&(y+=1),e.remove(g,y)}const m=new Set;for(const a of i.referencedFiles){m.add(a.fileName);const{line:u}=i.getLineAndCharacterOfPosition(a.pos),g=c[u];let y=i.getLineEndOfPosition(a.pos);e.slice(y,y+1)==`
21
+ `&&(y+=1),e.remove(g,y)}return{code:e,typeReferences:l,fileReferences:m};function f(a){if(r.forEachChild(a,f),r.isImportTypeNode(a)){if(!r.isLiteralTypeNode(a.argument)||!r.isStringLiteral(a.argument.literal))throw new h(a,"inline imports should have a literal argument");const u=a.argument.literal.text,g=a.getChildren(),y=g.find(E=>E.kind===r.SyntaxKind.ImportKeyword).getStart();let b=a.getEnd();const F=g.find(E=>E.kind===r.SyntaxKind.DotToken||E.kind===r.SyntaxKind.LessThanToken);F&&(b=F.getStart());const A=d(u);e.overwrite(y,b,A)}}function d(a){let u=o.get(a);return u||(u=w(a.replace(/[^a-zA-Z0-9_$]/g,()=>"_")),o.set(a,u)),u}function w(a){let u=a;for(;t.has(u);)u=`_${u}`;return t.add(u),u}function N(a,u){let g=p.get(a);if(!g)g=[u],p.set(a,g);else{const y=g[g.length-1];y[1]===u[0]?y[1]=u[1]:g.push(u)}}}function z(i,e){var t;let n=!1;const s=r.isClassDeclaration(e)||r.isFunctionDeclaration(e)||r.isModuleDeclaration(e)||r.isVariableStatement(e);for(const o of(t=e.modifiers)!==null&&t!==void 0?t:[])switch(o.kind){case r.SyntaxKind.ExportKeyword:case r.SyntaxKind.DefaultKeyword:i.remove(o.getStart(),o.getEnd()+1);break;case r.SyntaxKind.DeclareKeyword:n=!0}s&&!n&&i.appendRight(e.getStart(),"declare ")}function Te(i,e){if(!(!e.body||!r.isModuleBlock(e.body))){for(const t of e.body.statements)if(r.isExportDeclaration(t)&&t.exportClause){if(r.isNamespaceExport(t.exportClause))continue;for(const n of t.exportClause.elements)n.propertyName||i.appendLeft(n.name.getEnd(),` as ${n.name.getText()}`)}}}function _(i){const e=i.getFullStart();return e+(G(i,e)?1:0)}function W(i){const e=i.getEnd();return e+(G(i,e)?1:0)}function G(i,e){return i.getSourceFile().getFullText()[e]==`
22
+ `}const Ne=new Set([r.SyntaxKind.LiteralType,r.SyntaxKind.VoidKeyword,r.SyntaxKind.UnknownKeyword,r.SyntaxKind.AnyKeyword,r.SyntaxKind.BooleanKeyword,r.SyntaxKind.NumberKeyword,r.SyntaxKind.StringKeyword,r.SyntaxKind.ObjectKeyword,r.SyntaxKind.NullKeyword,r.SyntaxKind.UndefinedKeyword,r.SyntaxKind.SymbolKeyword,r.SyntaxKind.NeverKeyword,r.SyntaxKind.ThisKeyword,r.SyntaxKind.ThisType,r.SyntaxKind.BigIntKeyword]);class H{constructor({id:e,range:t}){if(this.scopes=[],e)this.declaration=Se(e,t);else{const{iife:n,fn:s}=xe(t);this.iife=n,this.declaration=s}}pushScope(){this.scopes.push(new Set)}popScope(e=1){for(let t=0;t<e;t++)this.scopes.pop()}pushTypeVariable(e){var t;const n=e.getText();(t=this.scopes[this.scopes.length-1])===null||t===void 0||t.add(n)}pushRaw(e){this.declaration.params.push(e)}pushReference(e){let t;if(e.type==="Identifier"?t=e.name:e.type==="MemberExpression"&&e.object.type==="Identifier"&&(t=e.object.name),t){for(const n of this.scopes)if(n.has(t))return}this.pushRaw(ge(e))}pushIdentifierReference(e){this.pushReference(v(e))}convertEntityName(e){return r.isIdentifier(e)?v(e):S({type:"MemberExpression",computed:!1,optional:!1,object:this.convertEntityName(e.left),property:v(e.right)},e)}convertPropertyAccess(e){if(!r.isIdentifier(e.expression)&&!r.isPropertyAccessExpression(e.expression))throw new h(e.expression);if(r.isPrivateIdentifier(e.name))throw new h(e.name);let t=r.isIdentifier(e.expression)?v(e.expression):this.convertPropertyAccess(e.expression);return S({type:"MemberExpression",computed:!1,optional:!1,object:t,property:v(e.name)},e)}convertComputedPropertyName(e){if(!e.name||!r.isComputedPropertyName(e.name))return;const{expression:t}=e.name;if(!(r.isLiteralExpression(t)||r.isPrefixUnaryExpression(t))){if(r.isIdentifier(t))return this.pushReference(v(t));if(r.isPropertyAccessExpression(t))return this.pushReference(this.convertPropertyAccess(t));throw new h(t)}}convertParametersAndType(e){this.convertComputedPropertyName(e);const t=this.convertTypeParameters(e.typeParameters);for(const n of e.parameters)this.convertTypeNode(n.type);this.convertTypeNode(e.type),this.popScope(t)}convertHeritageClauses(e){for(const t of e.heritageClauses||[])for(const n of t.types)this.pushReference(P(n.expression)),this.convertTypeArguments(n)}convertTypeArguments(e){if(!!e.typeArguments)for(const t of e.typeArguments)this.convertTypeNode(t)}convertMembers(e){for(const t of e){if(r.isPropertyDeclaration(t)||r.isPropertySignature(t)||r.isIndexSignatureDeclaration(t)){this.convertComputedPropertyName(t),this.convertTypeNode(t.type);continue}if(r.isMethodDeclaration(t)||r.isMethodSignature(t)||r.isConstructorDeclaration(t)||r.isConstructSignatureDeclaration(t)||r.isCallSignatureDeclaration(t)||r.isGetAccessorDeclaration(t)||r.isSetAccessorDeclaration(t))this.convertParametersAndType(t);else throw new h(t)}}convertTypeParameters(e){if(!e)return 0;for(const t of e)this.convertTypeNode(t.constraint),this.convertTypeNode(t.default),this.pushScope(),this.pushTypeVariable(t.name);return e.length}convertTypeNode(e){if(!!e&&!Ne.has(e.kind)){if(r.isTypeReferenceNode(e)){this.pushReference(this.convertEntityName(e.typeName)),this.convertTypeArguments(e);return}if(r.isTypeLiteralNode(e))return this.convertMembers(e.members);if(r.isArrayTypeNode(e))return this.convertTypeNode(e.elementType);if(r.isTupleTypeNode(e)){for(const t of e.elements)this.convertTypeNode(t);return}if(r.isNamedTupleMember(e)||r.isParenthesizedTypeNode(e)||r.isTypeOperatorNode(e)||r.isTypePredicateNode(e))return this.convertTypeNode(e.type);if(r.isUnionTypeNode(e)||r.isIntersectionTypeNode(e)){for(const t of e.types)this.convertTypeNode(t);return}if(r.isMappedTypeNode(e)){const{typeParameter:t,type:n,nameType:s}=e;this.convertTypeNode(t.constraint),this.pushScope(),this.pushTypeVariable(t.name),this.convertTypeNode(n),s&&this.convertTypeNode(s),this.popScope();return}if(r.isConditionalTypeNode(e)){this.convertTypeNode(e.checkType),this.pushScope(),this.convertTypeNode(e.extendsType),this.convertTypeNode(e.trueType),this.convertTypeNode(e.falseType),this.popScope();return}if(r.isIndexedAccessTypeNode(e)){this.convertTypeNode(e.objectType),this.convertTypeNode(e.indexType);return}if(r.isFunctionOrConstructorTypeNode(e)){this.convertParametersAndType(e);return}if(r.isTypeQueryNode(e)){this.pushReference(this.convertEntityName(e.exprName));return}if(r.isRestTypeNode(e)){this.convertTypeNode(e.type);return}if(r.isOptionalTypeNode(e)){this.convertTypeNode(e.type);return}if(r.isTemplateLiteralTypeNode(e)){for(const t of e.templateSpans)this.convertTypeNode(t.type);return}if(r.isInferTypeNode(e)){this.pushTypeVariable(e.typeParameter.name);return}else throw new h(e)}}convertNamespace(e,t=!1){if(this.pushScope(),t&&e.body&&r.isModuleDeclaration(e.body)){this.convertNamespace(e.body,!0);return}if(!e.body||!r.isModuleBlock(e.body))throw new h(e,'namespace must have a "ModuleBlock" body.');const{statements:n}=e.body;for(const s of n){if(r.isEnumDeclaration(s)||r.isFunctionDeclaration(s)||r.isClassDeclaration(s)||r.isInterfaceDeclaration(s)||r.isTypeAliasDeclaration(s)||r.isModuleDeclaration(s)){if(s.name&&r.isIdentifier(s.name))this.pushTypeVariable(s.name);else throw new h(s,"non-Identifier name not supported");continue}if(r.isVariableStatement(s)){for(const o of s.declarationList.declarations)if(r.isIdentifier(o.name))this.pushTypeVariable(o.name);else throw new h(o,"non-Identifier name not supported");continue}if(!r.isExportDeclaration(s))throw new h(s,"namespace child (hoisting) not supported yet")}for(const s of n){if(r.isVariableStatement(s)){for(const o of s.declarationList.declarations)o.type&&this.convertTypeNode(o.type);continue}if(r.isFunctionDeclaration(s)){this.convertParametersAndType(s);continue}if(r.isInterfaceDeclaration(s)||r.isClassDeclaration(s)){const o=this.convertTypeParameters(s.typeParameters);this.convertHeritageClauses(s),this.convertMembers(s.members),this.popScope(o);continue}if(r.isTypeAliasDeclaration(s)){const o=this.convertTypeParameters(s.typeParameters);this.convertTypeNode(s.type),this.popScope(o);continue}if(r.isModuleDeclaration(s)){this.convertNamespace(s,t);continue}if(!r.isEnumDeclaration(s))if(r.isExportDeclaration(s)){if(s.exportClause){if(r.isNamespaceExport(s.exportClause))throw new h(s.exportClause);for(const o of s.exportClause.elements){const p=o.propertyName||o.name;this.pushIdentifierReference(p)}}}else throw new h(s,"namespace child (walking) not supported yet")}this.popScope()}}function De({sourceFile:i}){return new Ee(i).transform()}class Ee{constructor(e){this.sourceFile=e,this.declarations=new Map,this.ast=he(e);for(const t of e.statements)this.convertStatement(t)}transform(){return{ast:this.ast}}pushStatement(e){this.ast.body.push(e)}createDeclaration(e,t){const n={start:e.getFullStart(),end:e.getEnd()};if(!t){const c=new H({range:n});return this.pushStatement(c.iife),c}const s=t.getText(),o=new H({id:t,range:n}),p=this.declarations.get(s);if(p){p.pushIdentifierReference(t),p.declaration.end=n.end;let c=this.ast.body.findIndex(l=>l==p.declaration);for(let l=c+1;l<this.ast.body.length;l++){const m=this.ast.body[l];m.start=m.end=n.end}}else this.pushStatement(o.declaration),this.declarations.set(s,o);return p||o}convertStatement(e){if(r.isEnumDeclaration(e))return this.convertEnumDeclaration(e);if(r.isFunctionDeclaration(e))return this.convertFunctionDeclaration(e);if(r.isInterfaceDeclaration(e)||r.isClassDeclaration(e))return this.convertClassOrInterfaceDeclaration(e);if(r.isTypeAliasDeclaration(e))return this.convertTypeAliasDeclaration(e);if(r.isVariableStatement(e))return this.convertVariableStatement(e);if(r.isExportDeclaration(e)||r.isExportAssignment(e))return this.convertExportDeclaration(e);if(r.isModuleDeclaration(e))return this.convertNamespaceDeclaration(e);if(e.kind==r.SyntaxKind.NamespaceExportDeclaration)return this.removeStatement(e);if(r.isImportDeclaration(e)||r.isImportEqualsDeclaration(e))return this.convertImportDeclaration(e);throw new h(e)}removeStatement(e){this.pushStatement(S({type:"ExpressionStatement",expression:{type:"Literal",value:"pls remove me"}},e))}convertNamespaceDeclaration(e){if(e.flags&r.NodeFlags.GlobalAugmentation||!r.isIdentifier(e.name)){this.createDeclaration(e).convertNamespace(e,!0);return}const n=this.createDeclaration(e,e.name);n.pushIdentifierReference(e.name),n.convertNamespace(e)}convertEnumDeclaration(e){this.createDeclaration(e,e.name).pushIdentifierReference(e.name)}convertFunctionDeclaration(e){if(!e.name)throw new h(e,"FunctionDeclaration should have a name");const t=this.createDeclaration(e,e.name);t.pushIdentifierReference(e.name),t.convertParametersAndType(e)}convertClassOrInterfaceDeclaration(e){if(!e.name)throw new h(e,"ClassDeclaration / InterfaceDeclaration should have a name");const t=this.createDeclaration(e,e.name),n=t.convertTypeParameters(e.typeParameters);t.convertHeritageClauses(e),t.convertMembers(e.members),t.popScope(n)}convertTypeAliasDeclaration(e){const t=this.createDeclaration(e,e.name),n=t.convertTypeParameters(e.typeParameters);t.convertTypeNode(e.type),t.popScope(n)}convertVariableStatement(e){const{declarations:t}=e.declarationList;if(t.length!==1)throw new h(e,"VariableStatement with more than one declaration not yet supported");for(const n of t){if(!r.isIdentifier(n.name))throw new h(e,"VariableDeclaration must have a name");this.createDeclaration(e,n.name).convertTypeNode(n.type)}}convertExportDeclaration(e){if(r.isExportAssignment(e)){this.pushStatement(S({type:"ExportDefaultDeclaration",declaration:P(e.expression)},e));return}const t=e.moduleSpecifier?P(e.moduleSpecifier):void 0;if(!e.exportClause)this.pushStatement(S({type:"ExportAllDeclaration",source:t,exported:null},e));else if(r.isNamespaceExport(e.exportClause))this.pushStatement(S({type:"ExportAllDeclaration",source:t,exported:v(e.exportClause.name)},e));else{const n=[];for(const s of e.exportClause.elements)n.push(this.convertExportSpecifier(s));this.pushStatement(S({type:"ExportNamedDeclaration",declaration:null,specifiers:n,source:t},e))}}convertImportDeclaration(e){if(r.isImportEqualsDeclaration(e)){if(!r.isExternalModuleReference(e.moduleReference))throw new h(e,"ImportEquals should have a literal source.");this.pushStatement(S({type:"ImportDeclaration",specifiers:[{type:"ImportDefaultSpecifier",local:v(e.name)}],source:P(e.moduleReference.expression)},e));return}const t=P(e.moduleSpecifier),n=e.importClause&&e.importClause.namedBindings?this.convertNamedImportBindings(e.importClause.namedBindings):[];e.importClause&&e.importClause.name&&n.push({type:"ImportDefaultSpecifier",local:v(e.importClause.name)}),this.pushStatement(S({type:"ImportDeclaration",specifiers:n,source:t},e))}convertNamedImportBindings(e){return r.isNamedImports(e)?e.elements.map(t=>{const n=v(t.name),s=t.propertyName?v(t.propertyName):n;return{type:"ImportSpecifier",local:n,imported:s}}):[{type:"ImportNamespaceSpecifier",local:v(e.name)}]}convertExportSpecifier(e){const t=v(e.name);return{type:"ExportSpecifier",exported:t,local:e.propertyName?v(e.propertyName):t}}}function k(i,e){return r.createSourceFile(i,e,r.ScriptTarget.Latest,!0)}const we=()=>{const i=new Map,e=new Map;return{name:"dts-transform",options(t){const{onwarn:n}=t;return K(I({},t),{onwarn(s,o){s.code!="CIRCULAR_DEPENDENCY"&&(n?n(s,o):o(s))},treeshake:{moduleSideEffects:"no-external",propertyReadSideEffects:!0,unknownGlobalSideEffects:!1}})},outputOptions(t){return K(I({},t),{chunkFileNames:t.chunkFileNames||"[name]-[hash].d.ts",entryFileNames:t.entryFileNames||"[name].d.ts",format:"es",exports:"named",compact:!1,freeze:!0,interop:!1,namespaceToStringTag:!1,strict:!1})},transform(t,n){let s=k(n,t);const o=ve({sourceFile:s});i.set(s.fileName,o.typeReferences),e.set(s.fileName,o.fileReferences),t=o.code.toString(),s=k(n,t);const p=De({sourceFile:s});return process.env.DTS_DUMP_AST&&(console.log(n),console.log(t),console.log(JSON.stringify(p.ast.body,void 0,2))),{code:t,ast:p.ast,map:o.code.generateMap()}},renderChunk(t,n,s){const o=k(n.fileName,t),p=new ye(o),c=new Set,l=new Set;for(const m of Object.keys(n.modules)){for(const f of i.get(m.split("\\").join("/"))||[])c.add(f);for(const f of e.get(m.split("\\").join("/"))||[])if(f.startsWith(".")){const d=T.join(T.dirname(m),f),w=s.file&&T.dirname(s.file)||n.facadeModuleId&&T.dirname(n.facadeModuleId)||".";let N=T.relative(w,d).split("\\").join("/");N[0]!=="."&&(N="./"+N),l.add(N)}else l.add(f)}return t=J(Array.from(l,m=>`/// <reference path="${m}" />`)),t+=J(Array.from(c,m=>`/// <reference types="${m}" />`)),t+=p.fix(),{code:t,map:{mappings:""}}}}};function J(i){return i.length?i.join(`
23
+ `)+`
24
+ `:""}const Y=/\.(t|j)sx?$/,be=(i={})=>{const e=we(),{respectExternal:t=!1,compilerOptions:n={}}=i;let s=[];function o(p){let c,l;return!s.length&&p.endsWith($)?c=!0:(l=s.find(m=>c=m.getSourceFile(p)),!l&&r.sys.fileExists(p)&&(s.push(l=pe(p,n)),c=l.getSourceFile(p))),{source:c,program:l}}return{name:"dts",options(p){let{input:c=[]}=p;if(!Array.isArray(c))c=typeof c=="string"?[c]:Object.values(c);else if(c.length>1){p.input={};for(const l of c){let m=l.replace(/((\.d)?\.(t|j)sx?)$/,"");T.isAbsolute(l)?m=T.basename(m):m=T.normalize(m),p.input[m]=l}}return s=fe(Object.values(c),n),e.options.call(this,p)},outputOptions:e.outputOptions,transform(p,c){const l=(a,u)=>(typeof a=="object"&&(p=a.getFullText()),e.transform.call(this,p,u));if(!Y.test(c))return null;if(c.endsWith($)){const{source:a}=o(c);return a?l(a,c):null}const m=c.replace(Y,$);let f=o(m);if(f.source)return l(f.source,m);if(f=o(c),typeof f.source!="object"||!f.program)return null;let d;const{emitSkipped:w,diagnostics:N}=f.program.emit(f.source,(a,u)=>{p=u,d=l(!0,m)},void 0,!0);if(w){const a=N.filter(u=>u.category===r.DiagnosticCategory.Error);a.length&&(console.error(r.formatDiagnostics(a,R)),this.error("Failed to compile. Check the logs above."))}return d},resolveId(p,c){if(!c)return;c=c.split("\\").join("/");const{resolvedModule:l}=r.nodeModuleNameResolver(p,c,n,r.sys);if(!!l)return!t&&l.isExternalLibraryImport?{id:p,external:!0}:{id:T.resolve(l.resolvedFileName)}},renderChunk:e.renderChunk}};exports.default=be;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pkgroll",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "description": "Zero-config rollup bundler",
5
5
  "keywords": [
6
6
  "zero config",
@@ -55,32 +55,32 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@rollup/plugin-alias": "^3.1.9",
58
- "@rollup/plugin-commonjs": "^21.0.3",
58
+ "@rollup/plugin-commonjs": "^21.1.0",
59
59
  "@rollup/plugin-inject": "^4.0.4",
60
60
  "@rollup/plugin-json": "^4.1.0",
61
- "@rollup/plugin-node-resolve": "^13.1.3",
61
+ "@rollup/plugin-node-resolve": "^13.2.1",
62
62
  "@rollup/plugin-replace": "^4.0.0",
63
- "@rollup/pluginutils": "^4.2.0",
64
- "esbuild": "^0.14.29",
63
+ "@rollup/pluginutils": "^4.2.1",
64
+ "esbuild": "^0.14.38",
65
65
  "magic-string": "^0.26.1",
66
- "rollup": "^2.70.1"
66
+ "rollup": "^2.70.2"
67
67
  },
68
68
  "devDependencies": {
69
- "@pvtnbr/eslint-config": "^0.19.1",
70
- "@types/node": "^17.0.23",
69
+ "@pvtnbr/eslint-config": "^0.20.0",
70
+ "@types/node": "^17.0.29",
71
71
  "@types/rimraf": "^3.0.2",
72
- "cleye": "^1.1.0",
73
- "eslint": "^8.12.0",
72
+ "cleye": "^1.2.0",
73
+ "eslint": "^8.14.0",
74
74
  "esno": "^0.14.1",
75
75
  "execa": "^6.1.0",
76
76
  "get-node": "^12.1.0",
77
77
  "get-tsconfig": "^3.0.1",
78
78
  "husky": "^4.3.8",
79
79
  "kolorist": "^1.5.1",
80
- "lint-staged": "^12.3.7",
80
+ "lint-staged": "^12.4.1",
81
81
  "manten": "^0.0.3",
82
82
  "rimraf": "^3.0.2",
83
- "rollup-plugin-dts": "^4.2.0",
83
+ "rollup-plugin-dts": "^4.2.1",
84
84
  "type-fest": "^2.12.2",
85
85
  "typescript": "^4.6.3"
86
86
  },
@@ -98,16 +98,6 @@
98
98
  "test"
99
99
  ]
100
100
  }
101
- ],
102
- "unicorn/prevent-abbreviations": [
103
- "error",
104
- {
105
- "replacements": {
106
- "pkg": false,
107
- "src": false,
108
- "dist": false
109
- }
110
- }
111
101
  ]
112
102
  }
113
103
  }
@@ -1,24 +0,0 @@
1
- "use strict";var F=Object.defineProperty,A=Object.defineProperties;var $=Object.getOwnPropertyDescriptors;var I=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable;var P=(n,e,t)=>e in n?F(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,N=(n,e)=>{for(var t in e||(e={}))L.call(e,t)&&P(n,t,e[t]);if(I)for(var t of I(e))K.call(e,t)&&P(n,t,e[t]);return n},b=(n,e)=>A(n,$(e));var require$$2=require("module"),path=require("path"),MagicString=require("magic-string");function _interopDefaultLegacy(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}function _interopNamespace(n){if(n&&n.__esModule)return n;var e=Object.create(null);return n&&Object.keys(n).forEach(function(t){if(t!=="default"){var r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:function(){return n[t]}})}}),e.default=n,Object.freeze(e)}var path__namespace=_interopNamespace(path),MagicString__default=_interopDefaultLegacy(MagicString),require$1=require;function getLocalTypescriptPath(){const n=process.cwd();try{return require$1.resolve("typescript",{paths:[n]})}catch{throw new Error(`Could not find \`typescript\` in ${n}`)}}var ts=require$1(getLocalTypescriptPath());const dts=".d.ts",formatHost={getCurrentDirectory:()=>ts.sys.getCurrentDirectory(),getNewLine:()=>ts.sys.newLine,getCanonicalFileName:ts.sys.useCaseSensitiveFileNames?n=>n:n=>n.toLowerCase()},DEFAULT_OPTIONS={declaration:!0,noEmit:!1,emitDeclarationOnly:!0,noEmitOnError:!0,checkJs:!1,declarationMap:!1,skipLibCheck:!0,preserveSymlinks:!0,target:ts.ScriptTarget.ESNext};function getCompilerOptions(n,e){const t=N(N({},DEFAULT_OPTIONS),e);let r=path__namespace.dirname(n),i=[];const a=ts.findConfigFile(r,ts.sys.fileExists);if(!a)return{dtsFiles:i,dirName:r,compilerOptions:t};r=path__namespace.dirname(a);const{config:c,error:o}=ts.readConfigFile(a,ts.sys.readFile);if(o)return console.error(ts.formatDiagnostic(o,formatHost)),{dtsFiles:i,dirName:r,compilerOptions:t};const{fileNames:l,options:u,errors:p}=ts.parseJsonConfigFileContent(c,ts.sys,r);return i=l.filter(m=>m.endsWith(dts)),p.length?(console.error(ts.formatDiagnostics(p,formatHost)),{dtsFiles:i,dirName:r,compilerOptions:t}):{dtsFiles:i,dirName:r,compilerOptions:N(N({},u),t)}}function createProgram$1(n,e){const{dtsFiles:t,compilerOptions:r}=getCompilerOptions(n,e);return ts.createProgram([n].concat(Array.from(t)),r,ts.createCompilerHost(r,!0))}function createPrograms(n,e){const t=[];let r=[],i=new Set,a="",c={};for(let o of n){if(o.endsWith(dts))continue;o=path__namespace.resolve(o);const l=getCompilerOptions(o,e);if(l.dtsFiles.forEach(i.add,i),!r.length){r.push(o),{dirName:a,compilerOptions:c}=l;continue}if(l.dirName===a)r.push(o);else{const u=ts.createCompilerHost(c,!0),p=ts.createProgram(r.concat(Array.from(i)),c,u);t.push(p),r=[o],{dirName:a,compilerOptions:c}=l}}if(r.length){const o=ts.createCompilerHost(c,!0),l=ts.createProgram(r.concat(Array.from(i)),c,o);t.push(l)}return t}function getCodeFrame(){let n;try{return{codeFrameColumns:n}=require$1("@babel/code-frame"),n}catch{try{return{codeFrameColumns:n}=require$$2.createRequire(typeof document=="undefined"?new(require("url")).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("rollup-plugin-dts-4870e282.js",document.baseURI).href)("@babel/code-frame"),n}catch{}}}function getLocation(n){const e=n.getSourceFile(),t=e.getLineAndCharacterOfPosition(n.getStart()),r=e.getLineAndCharacterOfPosition(n.getEnd());return{start:{line:t.line+1,column:t.character+1},end:{line:r.line+1,column:r.character+1}}}function frameNode(n){const e=getCodeFrame(),r=n.getSourceFile().getFullText(),i=getLocation(n);return e?`
2
- `+e(r,i,{highlightCode:!0}):`
3
- ${i.start.line}:${i.start.column}: \`${n.getFullText().trim()}\``}class UnsupportedSyntaxError extends Error{constructor(e,t="Syntax not yet supported"){super(`${t}
4
- ${frameNode(e)}`)}}class NamespaceFixer{constructor(e){this.sourceFile=e}findNamespaces(){const e=[],t={};for(const r of this.sourceFile.statements){const i={start:r.getStart(),end:r.getEnd()};if(ts.isEmptyStatement(r)){e.unshift({name:"",exports:[],location:i});continue}if((ts.isImportDeclaration(r)||ts.isExportDeclaration(r))&&r.moduleSpecifier&&ts.isStringLiteral(r.moduleSpecifier)){let{text:p}=r.moduleSpecifier;if(p.startsWith(".")&&(p.endsWith(".d.ts")||p.endsWith(".d.cts")||p.endsWith(".d.mts"))){let m=r.moduleSpecifier.getStart()+1,g=r.moduleSpecifier.getEnd()-1;e.unshift({name:"",exports:[],location:{start:m,end:g},textBeforeCodeAfter:p.replace(/\.d\.ts$/,".js").replace(/\.d\.cts$/,".cjs").replace(/\.d\.mts$/,".mjs")})}}if(ts.isModuleDeclaration(r)&&r.body&&ts.isModuleBlock(r.body)){for(const p of r.body.statements)if(ts.isExportDeclaration(p)&&p.exportClause){if(ts.isNamespaceExport(p.exportClause))continue;for(const m of p.exportClause.elements)m.propertyName&&m.propertyName.getText()==m.name.getText()&&e.unshift({name:"",exports:[],location:{start:m.propertyName.getEnd(),end:m.name.getEnd()}})}}if(ts.isClassDeclaration(r)?t[r.name.getText()]={type:"class",generics:r.typeParameters}:ts.isFunctionDeclaration(r)?t[r.name.getText()]={type:"function"}:ts.isInterfaceDeclaration(r)?t[r.name.getText()]={type:"interface",generics:r.typeParameters}:ts.isTypeAliasDeclaration(r)?t[r.name.getText()]={type:"type",generics:r.typeParameters}:ts.isModuleDeclaration(r)&&ts.isIdentifier(r.name)?t[r.name.getText()]={type:"namespace"}:ts.isEnumDeclaration(r)&&(t[r.name.getText()]={type:"enum"}),!ts.isVariableStatement(r))continue;const{declarations:a}=r.declarationList;if(a.length!==1)continue;const c=a[0],o=c.name.getText();if(!c.initializer||!ts.isCallExpression(c.initializer)){t[o]={type:"var"};continue}const l=c.initializer.arguments[0];if(!c.initializer.expression.getFullText().includes("/*#__PURE__*/Object.freeze")||!ts.isObjectLiteralExpression(l))continue;const u=[];for(const p of l.properties){if(!ts.isPropertyAssignment(p)||!(ts.isIdentifier(p.name)||ts.isStringLiteral(p.name))||p.name.text!=="__proto__"&&!ts.isIdentifier(p.initializer))throw new UnsupportedSyntaxError(p,"Expected a property assignment");p.name.text!=="__proto__"&&u.push({exportedName:p.name.text,localName:p.initializer.getText()})}e.unshift({name:o,exports:u,location:i})}return{namespaces:e,itemTypes:t}}fix(){var e;let t=this.sourceFile.getFullText();const{namespaces:r,itemTypes:i}=this.findNamespaces();for(const a of r){const c=t.slice(a.location.end);t=t.slice(0,a.location.start);for(const{exportedName:o,localName:l}of a.exports)if(o===l){const{type:u,generics:p}=i[l]||{};if(u==="interface"||u==="type"){const m=renderTypeParams(p);t+=`type ${a.name}_${o}${m.in} = ${l}${m.out};
5
- `}else if(u==="enum"||u==="class"){const m=renderTypeParams(p);t+=`type ${a.name}_${o}${m.in} = ${l}${m.out};
6
- `,t+=`declare const ${a.name}_${o}: typeof ${l};
7
- `}else t+=`declare const ${a.name}_${o}: typeof ${l};
8
- `}if(a.name){t+=`declare namespace ${a.name} {
9
- `,t+=` export {
10
- `;for(const{exportedName:o,localName:l}of a.exports)o===l?t+=` ${a.name}_${o} as ${o},
11
- `:t+=` ${l} as ${o},
12
- `;t+=` };
13
- `,t+="}"}t+=(e=a.textBeforeCodeAfter)!==null&&e!==void 0?e:"",t+=c}return t}}function renderTypeParams(n){return!n||!n.length?{in:"",out:""}:{in:`<${n.map(e=>e.getText()).join(", ")}>`,out:`<${n.map(e=>e.name.getText()).join(", ")}>`}}let IDs=1;function createProgram(n){return withStartEnd({type:"Program",sourceType:"module",body:[]},{start:n.getFullStart(),end:n.getEnd()})}function createReference(n){return{type:"AssignmentPattern",left:{type:"Identifier",name:String(IDs++)},right:n}}function createIdentifier(n){return withStartEnd({type:"Identifier",name:n.getText()},n)}function createIIFE(n){const e=withStartEnd({type:"FunctionExpression",id:null,params:[],body:{type:"BlockStatement",body:[]}},n),t=withStartEnd({type:"ExpressionStatement",expression:{type:"CallExpression",callee:{type:"Identifier",name:String(IDs++)},arguments:[e],optional:!1}},n);return{fn:e,iife:t}}function createDeclaration(n,e){return withStartEnd({type:"FunctionDeclaration",id:withStartEnd({type:"Identifier",name:ts.idText(n)},n),params:[],body:{type:"BlockStatement",body:[]}},e)}function convertExpression(n){if(ts.isLiteralExpression(n))return{type:"Literal",value:n.text};if(ts.isPropertyAccessExpression(n)){if(ts.isPrivateIdentifier(n.name))throw new UnsupportedSyntaxError(n.name);return withStartEnd({type:"MemberExpression",computed:!1,optional:!1,object:convertExpression(n.expression),property:convertExpression(n.name)},{start:n.expression.getStart(),end:n.name.getEnd()})}if(ts.isIdentifier(n))return createIdentifier(n);if(n.kind==ts.SyntaxKind.NullKeyword)return{type:"Literal",value:null};throw new UnsupportedSyntaxError(n)}function withStartEnd(n,e){let t="start"in e?e:{start:e.getStart(),end:e.getEnd()};return Object.assign(n,t)}function matchesModifier(n,e){return(ts.getCombinedModifierFlags(n)&e)===e}function preProcess({sourceFile:n}){const e=new MagicString__default.default(n.getFullText()),t=new Set,r=new Set;let i="";const a=new Map,c=new Map;for(const s of n.statements){if(ts.isEmptyStatement(s)){e.remove(s.getStart(),s.getEnd());continue}if(ts.isEnumDeclaration(s)||ts.isFunctionDeclaration(s)||ts.isInterfaceDeclaration(s)||ts.isClassDeclaration(s)||ts.isTypeAliasDeclaration(s)||ts.isModuleDeclaration(s)){if(s.name){const f=s.name.getText();t.add(f),matchesModifier(s,ts.ModifierFlags.ExportDefault)?i=f:matchesModifier(s,ts.ModifierFlags.Export)&&r.add(f),s.flags&ts.NodeFlags.GlobalAugmentation||D(f,[getStart(s),getEnd(s)])}ts.isModuleDeclaration(s)&&duplicateExports(e,s),fixModifiers(e,s)}else if(ts.isVariableStatement(s)){const{declarations:f}=s.declarationList,y=matchesModifier(s,ts.ModifierFlags.Export);for(const h of s.declarationList.declarations)if(ts.isIdentifier(h.name)){const x=h.name.getText();t.add(x),y&&r.add(x)}if(fixModifiers(e,s),f.length==1){const h=f[0];ts.isIdentifier(h.name)&&D(h.name.getText(),[getStart(s),getEnd(s)])}else{const h=f.slice(),x=h.shift();D(x.name.getText(),[getStart(s),x.getEnd()]);for(const T of h)ts.isIdentifier(T.name)&&D(T.name.getText(),[T.getFullStart(),T.getEnd()])}const{flags:d}=s.declarationList,E=`declare ${d&ts.NodeFlags.Let?"let":d&ts.NodeFlags.Const?"const":"var"} `,w=s.declarationList.getChildren().find(h=>h.kind===ts.SyntaxKind.SyntaxList).getChildren();let S=0;for(const h of w)if(h.kind===ts.SyntaxKind.CommaToken)S=h.getStart(),e.remove(S,h.getEnd());else if(S){e.appendLeft(S,`;
14
- `);const x=h.getFullStart(),T=e.slice(x,h.getStart());let C=T.length-T.trimStart().length;C?e.overwrite(x,x+C,E):e.appendLeft(x,E)}}}for(const s of n.statements)if(p(s),!!matchesModifier(s,ts.ModifierFlags.ExportDefault)&&(ts.isFunctionDeclaration(s)||ts.isClassDeclaration(s))){if(s.name)continue;i||(i=g("export_default"));const f=s.getChildren(),y=f.findIndex(w=>w.kind===ts.SyntaxKind.ClassKeyword||w.kind===ts.SyntaxKind.FunctionKeyword),d=f[y],v=f[y+1];v.kind>=ts.SyntaxKind.FirstPunctuation&&v.kind<=ts.SyntaxKind.LastPunctuation?e.appendLeft(v.getStart(),i):e.appendRight(d.getEnd(),` ${i}`)}for(const s of c.values()){const y=s.pop()[0];for(const d of s)e.move(d[0],d[1],y)}i&&e.append(`
15
- export default ${i};
16
- `),r.size&&e.append(`
17
- export { ${[...r].join(", ")} };
18
- `);for(const[s,f]of a.entries())e.prepend(`import * as ${f} from "${s}";
19
- `);const o=n.getLineStarts(),l=new Set;for(const s of n.typeReferenceDirectives){l.add(s.fileName);const{line:f}=n.getLineAndCharacterOfPosition(s.pos),y=o[f];let d=n.getLineEndOfPosition(s.pos);e.slice(d,d+1)==`
20
- `&&(d+=1),e.remove(y,d)}const u=new Set;for(const s of n.referencedFiles){u.add(path__namespace.join(path__namespace.dirname(n.fileName),s.fileName));const{line:f}=n.getLineAndCharacterOfPosition(s.pos),y=o[f];let d=n.getLineEndOfPosition(s.pos);e.slice(d,d+1)==`
21
- `&&(d+=1),e.remove(y,d)}return{code:e,typeReferences:l,fileReferences:u};function p(s){if(ts.forEachChild(s,p),ts.isImportTypeNode(s)){if(!ts.isLiteralTypeNode(s.argument)||!ts.isStringLiteral(s.argument.literal))throw new UnsupportedSyntaxError(s,"inline imports should have a literal argument");const f=s.argument.literal.text,y=s.getChildren(),d=y.find(S=>S.kind===ts.SyntaxKind.ImportKeyword).getStart();let v=s.getEnd();const E=y.find(S=>S.kind===ts.SyntaxKind.DotToken||S.kind===ts.SyntaxKind.LessThanToken);E&&(v=E.getStart());const w=m(f);e.overwrite(d,v,w)}}function m(s){let f=a.get(s);return f||(f=g(s.replace(/[^a-zA-Z0-9_$]/g,()=>"_")),a.set(s,f)),f}function g(s){let f=s;for(;t.has(f);)f=`_${f}`;return t.add(f),f}function D(s,f){let y=c.get(s);if(!y)y=[f],c.set(s,y);else{const d=y[y.length-1];d[1]===f[0]?d[1]=f[1]:y.push(f)}}}function fixModifiers(n,e){var t;let r=!1;const i=ts.isClassDeclaration(e)||ts.isFunctionDeclaration(e)||ts.isModuleDeclaration(e)||ts.isVariableStatement(e);for(const a of(t=e.modifiers)!==null&&t!==void 0?t:[])switch(a.kind){case ts.SyntaxKind.ExportKeyword:case ts.SyntaxKind.DefaultKeyword:n.remove(a.getStart(),a.getEnd()+1);break;case ts.SyntaxKind.DeclareKeyword:r=!0}i&&!r&&n.appendRight(e.getStart(),"declare ")}function duplicateExports(n,e){if(!(!e.body||!ts.isModuleBlock(e.body))){for(const t of e.body.statements)if(ts.isExportDeclaration(t)&&t.exportClause){if(ts.isNamespaceExport(t.exportClause))continue;for(const r of t.exportClause.elements)r.propertyName||n.appendLeft(r.name.getEnd(),` as ${r.name.getText()}`)}}}function getStart(n){const e=n.getFullStart();return e+(newlineAt(n,e)?1:0)}function getEnd(n){const e=n.getEnd();return e+(newlineAt(n,e)?1:0)}function newlineAt(n,e){return n.getSourceFile().getFullText()[e]==`
22
- `}const IGNORE_TYPENODES=new Set([ts.SyntaxKind.LiteralType,ts.SyntaxKind.VoidKeyword,ts.SyntaxKind.UnknownKeyword,ts.SyntaxKind.AnyKeyword,ts.SyntaxKind.BooleanKeyword,ts.SyntaxKind.NumberKeyword,ts.SyntaxKind.StringKeyword,ts.SyntaxKind.ObjectKeyword,ts.SyntaxKind.NullKeyword,ts.SyntaxKind.UndefinedKeyword,ts.SyntaxKind.SymbolKeyword,ts.SyntaxKind.NeverKeyword,ts.SyntaxKind.ThisKeyword,ts.SyntaxKind.ThisType,ts.SyntaxKind.BigIntKeyword]);class DeclarationScope{constructor({id:e,range:t}){if(this.scopes=[],e)this.declaration=createDeclaration(e,t);else{const{iife:r,fn:i}=createIIFE(t);this.iife=r,this.declaration=i}}pushScope(){this.scopes.push(new Set)}popScope(e=1){for(let t=0;t<e;t++)this.scopes.pop()}pushTypeVariable(e){var t;const r=e.getText();(t=this.scopes[this.scopes.length-1])===null||t===void 0||t.add(r)}pushRaw(e){this.declaration.params.push(e)}pushReference(e){let t;if(e.type==="Identifier"?t=e.name:e.type==="MemberExpression"&&e.object.type==="Identifier"&&(t=e.object.name),t){for(const r of this.scopes)if(r.has(t))return}this.pushRaw(createReference(e))}pushIdentifierReference(e){this.pushReference(createIdentifier(e))}convertEntityName(e){return ts.isIdentifier(e)?createIdentifier(e):withStartEnd({type:"MemberExpression",computed:!1,optional:!1,object:this.convertEntityName(e.left),property:createIdentifier(e.right)},e)}convertPropertyAccess(e){if(!ts.isIdentifier(e.expression)&&!ts.isPropertyAccessExpression(e.expression))throw new UnsupportedSyntaxError(e.expression);if(ts.isPrivateIdentifier(e.name))throw new UnsupportedSyntaxError(e.name);let t=ts.isIdentifier(e.expression)?createIdentifier(e.expression):this.convertPropertyAccess(e.expression);return withStartEnd({type:"MemberExpression",computed:!1,optional:!1,object:t,property:createIdentifier(e.name)},e)}convertComputedPropertyName(e){if(!e.name||!ts.isComputedPropertyName(e.name))return;const{expression:t}=e.name;if(!ts.isLiteralExpression(t)){if(ts.isIdentifier(t))return this.pushReference(createIdentifier(t));if(ts.isPropertyAccessExpression(t))return this.pushReference(this.convertPropertyAccess(t));throw new UnsupportedSyntaxError(t)}}convertParametersAndType(e){this.convertComputedPropertyName(e);const t=this.convertTypeParameters(e.typeParameters);for(const r of e.parameters)this.convertTypeNode(r.type);this.convertTypeNode(e.type),this.popScope(t)}convertHeritageClauses(e){for(const t of e.heritageClauses||[])for(const r of t.types)this.pushReference(convertExpression(r.expression)),this.convertTypeArguments(r)}convertTypeArguments(e){if(!!e.typeArguments)for(const t of e.typeArguments)this.convertTypeNode(t)}convertMembers(e){for(const t of e){if(ts.isPropertyDeclaration(t)||ts.isPropertySignature(t)||ts.isIndexSignatureDeclaration(t)){this.convertComputedPropertyName(t),this.convertTypeNode(t.type);continue}if(ts.isMethodDeclaration(t)||ts.isMethodSignature(t)||ts.isConstructorDeclaration(t)||ts.isConstructSignatureDeclaration(t)||ts.isCallSignatureDeclaration(t)||ts.isGetAccessorDeclaration(t)||ts.isSetAccessorDeclaration(t))this.convertParametersAndType(t);else throw new UnsupportedSyntaxError(t)}}convertTypeParameters(e){if(!e)return 0;for(const t of e)this.convertTypeNode(t.constraint),this.convertTypeNode(t.default),this.pushScope(),this.pushTypeVariable(t.name);return e.length}convertTypeNode(e){if(!!e&&!IGNORE_TYPENODES.has(e.kind)){if(ts.isTypeReferenceNode(e)){this.pushReference(this.convertEntityName(e.typeName)),this.convertTypeArguments(e);return}if(ts.isTypeLiteralNode(e))return this.convertMembers(e.members);if(ts.isArrayTypeNode(e))return this.convertTypeNode(e.elementType);if(ts.isTupleTypeNode(e)){for(const t of e.elements)this.convertTypeNode(t);return}if(ts.isNamedTupleMember(e)||ts.isParenthesizedTypeNode(e)||ts.isTypeOperatorNode(e)||ts.isTypePredicateNode(e))return this.convertTypeNode(e.type);if(ts.isUnionTypeNode(e)||ts.isIntersectionTypeNode(e)){for(const t of e.types)this.convertTypeNode(t);return}if(ts.isMappedTypeNode(e)){const{typeParameter:t,type:r,nameType:i}=e;this.convertTypeNode(t.constraint),this.pushScope(),this.pushTypeVariable(t.name),this.convertTypeNode(r),i&&this.convertTypeNode(i),this.popScope();return}if(ts.isConditionalTypeNode(e)){this.convertTypeNode(e.checkType),this.pushScope(),this.convertTypeNode(e.extendsType),this.convertTypeNode(e.trueType),this.convertTypeNode(e.falseType),this.popScope();return}if(ts.isIndexedAccessTypeNode(e)){this.convertTypeNode(e.objectType),this.convertTypeNode(e.indexType);return}if(ts.isFunctionOrConstructorTypeNode(e)){this.convertParametersAndType(e);return}if(ts.isTypeQueryNode(e)){this.pushReference(this.convertEntityName(e.exprName));return}if(ts.isRestTypeNode(e)){this.convertTypeNode(e.type);return}if(ts.isOptionalTypeNode(e)){this.convertTypeNode(e.type);return}if(ts.isTemplateLiteralTypeNode(e)){for(const t of e.templateSpans)this.convertTypeNode(t.type);return}if(ts.isInferTypeNode(e)){this.pushTypeVariable(e.typeParameter.name);return}else throw new UnsupportedSyntaxError(e)}}convertNamespace(e,t=!1){if(this.pushScope(),t&&e.body&&ts.isModuleDeclaration(e.body)){this.convertNamespace(e.body,!0);return}if(!e.body||!ts.isModuleBlock(e.body))throw new UnsupportedSyntaxError(e,'namespace must have a "ModuleBlock" body.');const{statements:r}=e.body;for(const i of r){if(ts.isEnumDeclaration(i)||ts.isFunctionDeclaration(i)||ts.isClassDeclaration(i)||ts.isInterfaceDeclaration(i)||ts.isTypeAliasDeclaration(i)||ts.isModuleDeclaration(i)){if(i.name&&ts.isIdentifier(i.name))this.pushTypeVariable(i.name);else throw new UnsupportedSyntaxError(i,"non-Identifier name not supported");continue}if(ts.isVariableStatement(i)){for(const a of i.declarationList.declarations)if(ts.isIdentifier(a.name))this.pushTypeVariable(a.name);else throw new UnsupportedSyntaxError(a,"non-Identifier name not supported");continue}if(!ts.isExportDeclaration(i))throw new UnsupportedSyntaxError(i,"namespace child (hoisting) not supported yet")}for(const i of r){if(ts.isVariableStatement(i)){for(const a of i.declarationList.declarations)a.type&&this.convertTypeNode(a.type);continue}if(ts.isFunctionDeclaration(i)){this.convertParametersAndType(i);continue}if(ts.isInterfaceDeclaration(i)||ts.isClassDeclaration(i)){const a=this.convertTypeParameters(i.typeParameters);this.convertHeritageClauses(i),this.convertMembers(i.members),this.popScope(a);continue}if(ts.isTypeAliasDeclaration(i)){const a=this.convertTypeParameters(i.typeParameters);this.convertTypeNode(i.type),this.popScope(a);continue}if(ts.isModuleDeclaration(i)){this.convertNamespace(i,t);continue}if(!ts.isEnumDeclaration(i))if(ts.isExportDeclaration(i)){if(i.exportClause){if(ts.isNamespaceExport(i.exportClause))throw new UnsupportedSyntaxError(i.exportClause);for(const a of i.exportClause.elements){const c=a.propertyName||a.name;this.pushIdentifierReference(c)}}}else throw new UnsupportedSyntaxError(i,"namespace child (walking) not supported yet")}this.popScope()}}function convert({sourceFile:n}){return new Transformer(n).transform()}class Transformer{constructor(e){this.sourceFile=e,this.declarations=new Map,this.ast=createProgram(e);for(const t of e.statements)this.convertStatement(t)}transform(){return{ast:this.ast}}pushStatement(e){this.ast.body.push(e)}createDeclaration(e,t){const r={start:e.getFullStart(),end:e.getEnd()};if(!t){const o=new DeclarationScope({range:r});return this.pushStatement(o.iife),o}const i=t.getText(),a=new DeclarationScope({id:t,range:r}),c=this.declarations.get(i);if(c){c.pushIdentifierReference(t),c.declaration.end=r.end;let o=this.ast.body.findIndex(l=>l==c.declaration);for(let l=o+1;l<this.ast.body.length;l++){const u=this.ast.body[l];u.start=u.end=r.end}}else this.pushStatement(a.declaration),this.declarations.set(i,a);return c||a}convertStatement(e){if(ts.isEnumDeclaration(e))return this.convertEnumDeclaration(e);if(ts.isFunctionDeclaration(e))return this.convertFunctionDeclaration(e);if(ts.isInterfaceDeclaration(e)||ts.isClassDeclaration(e))return this.convertClassOrInterfaceDeclaration(e);if(ts.isTypeAliasDeclaration(e))return this.convertTypeAliasDeclaration(e);if(ts.isVariableStatement(e))return this.convertVariableStatement(e);if(ts.isExportDeclaration(e)||ts.isExportAssignment(e))return this.convertExportDeclaration(e);if(ts.isModuleDeclaration(e))return this.convertNamespaceDeclaration(e);if(e.kind==ts.SyntaxKind.NamespaceExportDeclaration)return this.removeStatement(e);if(ts.isImportDeclaration(e)||ts.isImportEqualsDeclaration(e))return this.convertImportDeclaration(e);throw new UnsupportedSyntaxError(e)}removeStatement(e){this.pushStatement(withStartEnd({type:"ExpressionStatement",expression:{type:"Literal",value:"pls remove me"}},e))}convertNamespaceDeclaration(e){if(e.flags&ts.NodeFlags.GlobalAugmentation||!ts.isIdentifier(e.name)){this.createDeclaration(e).convertNamespace(e,!0);return}const r=this.createDeclaration(e,e.name);r.pushIdentifierReference(e.name),r.convertNamespace(e)}convertEnumDeclaration(e){this.createDeclaration(e,e.name).pushIdentifierReference(e.name)}convertFunctionDeclaration(e){if(!e.name)throw new UnsupportedSyntaxError(e,"FunctionDeclaration should have a name");const t=this.createDeclaration(e,e.name);t.pushIdentifierReference(e.name),t.convertParametersAndType(e)}convertClassOrInterfaceDeclaration(e){if(!e.name)throw new UnsupportedSyntaxError(e,"ClassDeclaration / InterfaceDeclaration should have a name");const t=this.createDeclaration(e,e.name),r=t.convertTypeParameters(e.typeParameters);t.convertHeritageClauses(e),t.convertMembers(e.members),t.popScope(r)}convertTypeAliasDeclaration(e){const t=this.createDeclaration(e,e.name),r=t.convertTypeParameters(e.typeParameters);t.convertTypeNode(e.type),t.popScope(r)}convertVariableStatement(e){const{declarations:t}=e.declarationList;if(t.length!==1)throw new UnsupportedSyntaxError(e,"VariableStatement with more than one declaration not yet supported");for(const r of t){if(!ts.isIdentifier(r.name))throw new UnsupportedSyntaxError(e,"VariableDeclaration must have a name");this.createDeclaration(e,r.name).convertTypeNode(r.type)}}convertExportDeclaration(e){if(ts.isExportAssignment(e)){this.pushStatement(withStartEnd({type:"ExportDefaultDeclaration",declaration:convertExpression(e.expression)},e));return}const t=e.moduleSpecifier?convertExpression(e.moduleSpecifier):void 0;if(!e.exportClause)this.pushStatement(withStartEnd({type:"ExportAllDeclaration",source:t,exported:null},e));else if(ts.isNamespaceExport(e.exportClause))this.pushStatement(withStartEnd({type:"ExportAllDeclaration",source:t,exported:createIdentifier(e.exportClause.name)},e));else{const r=[];for(const i of e.exportClause.elements)r.push(this.convertExportSpecifier(i));this.pushStatement(withStartEnd({type:"ExportNamedDeclaration",declaration:null,specifiers:r,source:t},e))}}convertImportDeclaration(e){if(ts.isImportEqualsDeclaration(e)){if(!ts.isExternalModuleReference(e.moduleReference))throw new UnsupportedSyntaxError(e,"ImportEquals should have a literal source.");this.pushStatement(withStartEnd({type:"ImportDeclaration",specifiers:[{type:"ImportDefaultSpecifier",local:createIdentifier(e.name)}],source:convertExpression(e.moduleReference.expression)},e));return}const t=convertExpression(e.moduleSpecifier),r=e.importClause&&e.importClause.namedBindings?this.convertNamedImportBindings(e.importClause.namedBindings):[];e.importClause&&e.importClause.name&&r.push({type:"ImportDefaultSpecifier",local:createIdentifier(e.importClause.name)}),this.pushStatement(withStartEnd({type:"ImportDeclaration",specifiers:r,source:t},e))}convertNamedImportBindings(e){return ts.isNamedImports(e)?e.elements.map(t=>{const r=createIdentifier(t.name),i=t.propertyName?createIdentifier(t.propertyName):r;return{type:"ImportSpecifier",local:r,imported:i}}):[{type:"ImportNamespaceSpecifier",local:createIdentifier(e.name)}]}convertExportSpecifier(e){const t=createIdentifier(e.name);return{type:"ExportSpecifier",exported:t,local:e.propertyName?createIdentifier(e.propertyName):t}}}function parse(n,e){return ts.createSourceFile(n,e,ts.ScriptTarget.Latest,!0)}const transform=()=>{const n=new Map,e=new Map;return{name:"dts-transform",options(t){const{onwarn:r}=t;return b(N({},t),{onwarn(i,a){i.code!="CIRCULAR_DEPENDENCY"&&(r?r(i,a):a(i))},treeshake:{moduleSideEffects:"no-external",propertyReadSideEffects:!0,unknownGlobalSideEffects:!1}})},outputOptions(t){return b(N({},t),{chunkFileNames:t.chunkFileNames||"[name]-[hash].d.ts",entryFileNames:t.entryFileNames||"[name].d.ts",format:"es",exports:"named",compact:!1,freeze:!0,interop:!1,namespaceToStringTag:!1,strict:!1})},transform(t,r){let i=parse(r,t);const a=preProcess({sourceFile:i});n.set(i.fileName,a.typeReferences),e.set(i.fileName,a.fileReferences),t=a.code.toString(),i=parse(r,t);const c=convert({sourceFile:i});return process.env.DTS_DUMP_AST&&(console.log(r),console.log(t),console.log(JSON.stringify(c.ast.body,void 0,2))),{code:t,ast:c.ast,map:a.code.generateMap()}},renderChunk(t,r,i){const a=parse(r.fileName,t),c=new NamespaceFixer(a),o=new Set,l=new Set;for(const u of Object.keys(r.modules)){for(const p of n.get(u.split("\\").join("/"))||[])o.add(p);for(const p of e.get(u.split("\\").join("/"))||[]){const m=i.file&&path__namespace.dirname(i.file)||r.facadeModuleId&&path__namespace.dirname(r.facadeModuleId)||".";let g=path__namespace.relative(m,p).split("\\").join("/");g[0]!=="."&&(g="./"+g),l.add(g)}}return t=writeBlock(Array.from(l,u=>`/// <reference path="${u}" />`)),t+=writeBlock(Array.from(o,u=>`/// <reference types="${u}" />`)),t+=c.fix(),{code:t,map:{mappings:""}}}}};function writeBlock(n){return n.length?n.join(`
23
- `)+`
24
- `:""}const tsx=/\.(t|j)sx?$/,plugin=(n={})=>{const e=transform(),{respectExternal:t=!1,compilerOptions:r={}}=n;let i=[];function a(c){let o,l;return!i.length&&c.endsWith(dts)?o=!0:(l=i.find(u=>o=u.getSourceFile(c)),!l&&ts.sys.fileExists(c)&&(i.push(l=createProgram$1(c,r)),o=l.getSourceFile(c))),{source:o,program:l}}return{name:"dts",options(c){let{input:o=[]}=c;if(!Array.isArray(o))o=typeof o=="string"?[o]:Object.values(o);else if(o.length>1){c.input={};for(const l of o){let u=l.replace(/((\.d)?\.(t|j)sx?)$/,"");path__namespace.isAbsolute(l)?u=path__namespace.basename(u):u=path__namespace.normalize(u),c.input[u]=l}}return i=createPrograms(Object.values(o),r),e.options.call(this,c)},outputOptions:e.outputOptions,transform(c,o){const l=(s,f)=>(typeof s=="object"&&(c=s.getFullText()),e.transform.call(this,c,f));if(!tsx.test(o))return null;if(o.endsWith(dts)){const{source:s}=a(o);return s?l(s,o):null}const u=o.replace(tsx,dts);let p=a(u);if(p.source)return l(p.source,u);if(p=a(o),typeof p.source!="object"||!p.program)return null;let m;const{emitSkipped:g,diagnostics:D}=p.program.emit(p.source,(s,f)=>{c=f,m=l(!0,u)},void 0,!0);if(g){const s=D.filter(f=>f.category===ts.DiagnosticCategory.Error);s.length&&(console.error(ts.formatDiagnostics(s,formatHost)),this.error("Failed to compile. Check the logs above."))}return m},resolveId(c,o){if(!o)return;o=o.split("\\").join("/");const{resolvedModule:l}=ts.nodeModuleNameResolver(c,o,r,ts.sys);if(!!l)return!t&&l.isExternalLibraryImport?{id:c,external:!0}:{id:path__namespace.resolve(l.resolvedFileName)}},renderChunk:e.renderChunk}};exports.default=plugin;