pkgroll 2.24.0 → 2.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -20,7 +20,7 @@ var Mn=Object.defineProperty;var l=(e,t)=>Mn(e,"name",{value:t,configurable:!0})
20
20
  `:"")+(u?this.indentText({text:this.render(u),spaces:n}):"")}
21
21
  `}table({tableData:t,tableOptions:u,tableBreakpoints:n}){return qu(t.map(r=>r.map(s=>this.render(s))),n?Gu(n):u)}flagParameter(t){return t===Boolean?"":t===String?"<string>":t===Number?"<number>":Array.isArray(t)?this.flagParameter(t[0]):"<value>"}flagOperator(t){return" "}flagName(t){const{flag:u,flagFormatted:n,aliasesEnabled:r,aliasFormatted:s}=t;let o="";if(s?o+=`${s}, `:r&&(o+=" "),o+=n,"placeholder"in u&&typeof u.placeholder=="string")o+=`${this.flagOperator(t)}${u.placeholder}`;else{const i=this.flagParameter("type"in u?u.type:u);i&&(o+=`${this.flagOperator(t)}${i}`)}return o}flagDefault(t){return JSON.stringify(t)}flagDescription({flag:t}){let u="description"in t?t.description??"":"";if("default"in t){let{default:n}=t;typeof n=="function"&&(n=n()),n&&(u+=` (default: ${this.flagDefault(n)})`)}return u}render(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(u=>this.render(u)).join(`
22
22
  `);if("type"in t&&this[t.type]){const u=this[t.type];if(typeof u=="function")return u.call(this,t.data)}throw new Error(`Invalid node type: ${JSON.stringify(t)}`)}}const Oe=A(e=>e.length>0&&!e.includes(" "),"isValidScriptName"),{stringify:L}=JSON,nr=/[|\\{}()[\]^$+*?.]/;function le(e){const t=[];let u,n;for(const r of e){if(n)throw new Error(`Invalid parameter: Spread parameter ${L(n)} must be last`);const s=r[0],o=r.at(-1);let i;if(s==="<"&&o===">"&&(i=!0,u))throw new Error(`Invalid parameter: Required parameter ${L(r)} cannot come after optional parameter ${L(u)}`);if(s==="["&&o==="]"&&(i=!1,u=r),i===void 0)throw new Error(`Invalid parameter: ${L(r)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let a=r.slice(1,-1);const c=a.slice(-3)==="...";c&&(n=r,a=a.slice(0,-3));const D=a.match(nr);if(D)throw new Error(`Invalid parameter: ${L(r)}. Invalid character found ${L(D[0])}`);t.push({name:a,required:i,spread:c})}return t}l(le,"b"),A(le,"parseParameters");function ce(e,t,u,n){for(let r=0;r<t.length;r+=1){const{name:s,required:o,spread:i}=t[r],a=Yu(s);if(a in e)throw new Error(`Invalid parameter: ${L(s)} is used more than once.`);const c=i?u.slice(r):u[r];if(i&&(r=t.length),o&&(!c||i&&c.length===0))return console.error(`Error: Missing required parameter ${L(s)}
23
- `),n(),process.exit(1);e[a]=c}}l(ce,"v$1"),A(ce,"mapParametersToArguments");function Mt(e){return e===void 0||e!==!1}l(Mt,"G$1"),A(Mt,"helpEnabled");function Te(e,t,u,n){const r={...t.flags},s=t.version&&!("version"in r);s&&(r.version={type:Boolean,description:"Show version"});const{help:o}=t,i=Mt(o);i&&!("help"in r)&&(r.help={type:Boolean,alias:"h",description:"Show help"});const a=bu(r,n,{ignore:t.ignoreArgv}),c=A(()=>{console.log(t.version)},"showVersion");if(s&&a.flags.version===!0)return c(),process.exit(0);const D=new tr,F=i&&o?.render?o.render:g=>D.render(g),f=A(g=>{const w=Xu({...t,...g?{help:g}:{},flags:r});console.log(F(w,D))},"showHelp");if(i&&a.flags.help===!0)return f(),process.exit(0);if(t.parameters){let{parameters:g}=t,w=a._;const S=g.indexOf("--"),$=g.slice(S+1),d=Object.create(null);if(S>-1&&$.length>0){g=g.slice(0,S);const b=a._["--"];w=w.slice(0,-b.length||void 0),ce(d,le(g),w,f),ce(d,le($),b,f)}else ce(d,le(g),w,f);Object.assign(a._,d)}const p={...a,showVersion:c,showHelp:f},C={command:e,...p};if(typeof u=="function"){const g=u(p);if(g&&"then"in g)return Object.assign(Promise.resolve(g),C)}return C}l(Te,"j"),A(Te,"cliBase");function Ut(e,t){const u=new Map;for(const n of t){const r=[n.options.name],{alias:s}=n.options;s&&(Array.isArray(s)?r.push(...s):r.push(s));for(const o of r){if(u.has(o))throw new Error(`Duplicate command name found: ${L(o)}`);u.set(o,n)}}return u.get(e)}l(Ut,"K$1"),A(Ut,"getCommand");function Vt(e,t,u=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!Oe(e.name)))throw new Error(`Invalid script name: ${L(e.name)}`);const n=u[0];if(e.commands&&n&&Oe(n)){const r=Ut(n,e.commands);if(r)return Te(r.options.name,{...r.options,parent:e},r.callback,u.slice(1))}return Te(void 0,e,t,u)}l(Vt,"Q$1"),A(Vt,"cli");function ur(e,t){if(!e)throw new Error("Command options are required");const{name:u}=e;if(u===void 0)throw new Error("Command name is required");if(!Oe(u))throw new Error(`Invalid command name ${JSON.stringify(u)}. Command names must be one word.`);return{options:e,callback:t}}l(ur,"X$1"),A(ur,"command");var rr="2.24.0";const M=l(e=>_.promises.access(e).then(()=>!0,()=>!1),"fsExists");let V=!0;const J=typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};let X=0;if(J.process&&J.process.env&&J.process.stdout){const{FORCE_COLOR:e,NODE_DISABLE_COLORS:t,NO_COLOR:u,TERM:n,COLORTERM:r}=J.process.env;t||u||e==="0"?V=!1:e==="1"||e==="2"||e==="3"?V=!0:n==="dumb"?V=!1:"CI"in J.process.env&&["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(s=>s in J.process.env)?V=!0:V=process.stdout.isTTY,V&&(process.platform==="win32"||r&&(r==="truecolor"||r==="24bit")?X=3:n&&(n.endsWith("-256color")||n.endsWith("256"))?X=2:X=1)}let zt={enabled:V,supportLevel:X};function sr(e,t,u=1){const n=`\x1B[${e}m`,r=`\x1B[${t}m`,s=new RegExp(`\\x1b\\[${t}m`,"g");return o=>zt.enabled&&zt.supportLevel>=u?n+(""+o).replace(s,n)+r:""+o}l(sr,"kolorist");const or=sr(2,22),De=l(e=>e.replaceAll("\\","/"),"slash"),T=l((e,t)=>(!h.isAbsolute(e)&&!e.startsWith(".")&&!e.startsWith("/")&&(e=`./${e}`),t&&!e.endsWith("/")&&(e+="/"),e),"normalizePath"),ir=l(()=>new Date().toLocaleTimeString(),"currentTime"),K=l((...e)=>console.log(or(ir()),...e),"log"),ar=process.cwd(),fe=l(e=>T(h.relative(ar,e)),"formatPath"),lr=l(async e=>{const t=await P.readFile(e,"utf8");try{return Zn(t)}catch(u){throw new Error(`Failed to parse ${fe(e)}: ${u.message}`)}},"readPackageYaml"),qt=l(async e=>{const t=await P.readFile(e,"utf8");try{return JSON.parse(t)}catch(u){throw new Error(`Failed to parse ${fe(e)}: ${u.message}`)}},"readPackageJson"),cr=l(async e=>{const t=h.join(e,"package.yaml");if(await M(t))return{packageJson:await lr(t),packageJsonPath:t};const u=h.join(e,"package.json");if(await M(u))return{packageJson:await qt(u),packageJsonPath:u};throw new Error(`package.json not found at: ${u} (also checked for package.yaml)`)},"readPackage"),Dr=l(e=>{let t=!1;if(e.includes("=")){const[u,n]=e.split("=");e=n,t=u==="bin"||u==="binary"}return{type:"legacy",source:"cli",outputPath:T(e),isExecutable:t}},"parseCliInputFlag"),fr=l(({imports:e},t)=>{const u={};if(e)for(const n in e){if(n.startsWith("#"))continue;const r=e[n];typeof r=="string"&&(u[n]=h.join(t,r))}return u},"getAliases"),dr=l(e=>{const{publishConfig:t}=e;if(!t)return;const u=["bin","main","exports","types","module"];for(const n of u)t[n]&&(e[n]=t[n])},"applyPublishConfig"),z=l(e=>{if(e.endsWith(".mjs"))return"module";if(e.endsWith(".cjs"))return"commonjs";if(e.endsWith(".d.ts")||e.endsWith(".d.cts")||e.endsWith(".d.mts"))return"types"},"getFileType"),pr=l(e=>e[0]===".","isPath"),Jt=l(e=>e.slice(1).filter(t=>typeof t=="string"&&t[0]!=="."),"getConditions"),de=l((e,t,u,n=[u])=>{if(!e)return[];if(typeof e=="string")return[{source:{type:"package.json",path:[...n]},type:u,conditions:[],format:z(e)||t,outputPath:T(e)}];if(Array.isArray(e))return e.flatMap((s,o)=>{const i=[...n,o];return typeof s=="string"?pr(s)?{source:{type:"package.json",path:[...i]},type:u,conditions:Jt(i),format:z(s)||t,outputPath:T(s)}:[]:de(s,t,u,i)});const r=u==="imports"&&n.length===1;return Object.entries(e).flatMap(([s,o])=>{if(r&&s[0]!=="#")return[];const i=[...n,s];if(typeof o=="string"){const a=Jt(i),c={type:u,source:{type:"package.json",path:i},outputPath:T(o),conditions:a};return a.includes("types")?{...c,format:"types"}:{...c,format:z(o)||t}}return de(o,t,u,i)})},"parsePackageMap"),Fr=l((e,t)=>{const u=[],n=e.main;n&&u.push({source:{type:"package.json",path:["main"]},type:"legacy",format:z(n)??t,outputPath:T(n)});const r=e.module;r&&u.push({source:{type:"package.json",path:["module"]},type:"legacy",format:"module",outputPath:T(r)});const s=e.types;s&&u.push({source:{type:"package.json",path:["types"]},type:"legacy",format:"types",outputPath:T(s)});const{bin:o}=e;if(o)if(typeof o=="string")u.push({source:{type:"package.json",path:["bin"]},type:"binary",format:z(o)??t,outputPath:T(o)});else for(const[i,a]of Object.entries(o))u.push({source:{type:"package.json",path:["bin",i]},type:"binary",format:z(a)??t,outputPath:T(a)});if(e.exports){const i=de(e.exports,t,"exports");u.push(...i)}if(e.imports){const i=de(e.imports,t,"imports");u.push(...i)}return u},"getPkgEntryPoints"),mr=l(async(e,t)=>{for(const u of t){const n=e+u;if(await M(n))return{srcExtension:u,sourcePath:n}}},"tryExtensions"),Pe={".d.ts":[".d.ts",".d.mts",".d.cts",".ts",".tsx",".mts",".cts"],".d.mts":[".d.mts",".d.ts",".d.cts",".ts",".tsx",".mts",".cts"],".d.cts":[".d.cts",".d.ts",".d.mts",".ts",".tsx",".mts",".cts"],".js":[".js",".ts",".tsx",".mts",".cts"],".mjs":[".mjs",".js",".cjs",".mts",".cts",".ts",".tsx"],".cjs":[".cjs",".js",".mjs",".mts",".cts",".ts",".tsx"]},Kt=Object.keys(Pe),hr=l(async(e,t)=>{const{outputPath:u}=e,n=Kt.find(o=>u.endsWith(o));if(!n)return{error:`Unsupported extension (must be ${Kt.join("|")})`,exportEntry:e};const r=u.slice(t.dist.length,-n.length),s=await mr(Z.join(t.srcResolved,r),Pe[n]);return s?{exportEntry:e,distExtension:n,srcdist:t,...s}:{error:`Source file not found: ${Z.join(t.src,r)}(${Pe[n].join("|")})`,exportEntry:e}},"getSourcePath"),gr=l(async e=>{try{return await P.readdir(e,{withFileTypes:!0})}catch(t){const{code:u}=t;if(u==="ENOENT")return[];throw t}},"safeReaddir"),Gt=l(async(e,t)=>{const u=await gr(e);return(await Promise.all(u.map(async r=>{const s=Z.join(e,r.name);return r.isDirectory()?Gt(s,t):r.isFile()?Z.relative(t,s):[]}))).flat()},"getDirectoryFilesRecursive"),Ht=new Map,Yt=l(async e=>{let t=Ht.get(e);return t||(t=Gt(e,e),Ht.set(e,t)),t},"getDirectoryFiles"),pe=/\.[^./]+$/,Zt=l((e,t)=>{const u=t.at(-1);if(!e.endsWith(u))return;if(t.some(r=>r.includes("/"))){const r=e.split("/").filter(Boolean);for(let s=1;s<=r.length;s+=1){const o=r.slice(0,s).join("/"),i=o+t.join(o);if(i===e)return i}}else for(let r=1;r<=e.length;r+=1){const s=e.slice(0,r),o=s+t.join(s);if(o===e)return o}},"extractWildcardMatch"),Cr=l(async(e,t)=>{const u=Array.from(t).sort((r,s)=>s.dist.length-r.dist.length);return(await Promise.all(e.map(async r=>{if(typeof r.source=="string"||r.source.path[0]!=="exports"&&r.source.path[0]!=="imports"||!r.outputPath.includes("*"))return[r];const s=r.source.path[1];if(!s.includes("*"))return[r];const o=r.outputPath.match(/\.d\.[cm]?ts$/)||r.outputPath.match(pe);if(!o)return[{exportEntry:r,error:`Wildcard pattern must include a file extension (e.g., ".mjs", ".cjs"). Pattern: ${s}`}];const[i]=o,a=r.outputPath.slice(0,-i.length),[c,...D]=a.split("*"),F=c.lastIndexOf("/"),f=F===-1?c:c.slice(0,F+1),p=F>=0?c.slice(F+1):"",C=l($=>{const d=$.replace(pe,""),b=d.split("/").at(-1)||"";if(p&&!b.startsWith(p))return!1;if(D.length===1){const B=D[0];return!(B&&!(B.includes("/")?d:b).endsWith(B))}const k=p?b.slice(p.length):d;return!!Zt(k,D)},"matchesPattern");if(f==="./")return(await Promise.all(u.map(async d=>{const b=d.srcResolved;return(await Yt(b)).flatMap(B=>{if(!C(B))return[];const E=B.replace(pe,"");return[{...r,outputPath:d.dist+E+i}]})}))).flat();const g=u.find(({dist:$})=>f===$||f.startsWith($));if(!g)return[];const w=h.posix.join(g.srcResolved,f.slice(g.dist.length));return(await Yt(w)).flatMap($=>{if(!C($))return[];const d=$.replace(pe,"");if(D.length>1){const b=Zt(d,D);return[{...r,outputPath:f+b+i}]}return[{...r,outputPath:f+d+i}]})}))).flat()},"expandBuildOutputWildcards"),Er=l(async(e,t,u)=>{dr(t);const n=t.type??"commonjs",r=await Cr(Fr(t,n),e);u.length>0&&r.push(...u.map(o=>({...o,format:z(o.outputPath)??n})));const s=new Map;return await Promise.all(r.map(async o=>{if("error"in o)return o;const i=e.find(({dist:c})=>o.outputPath.startsWith(c));if(!i)return{exportEntry:o,error:"Ignoring file outside of dist directories"};const a=s.get(o.outputPath);if(a){if(a.format!==o.format)throw new Error(`Conflicting export types "${a.format}" & "${o.format}" found for ${o.outputPath}`)}else s.set(o.outputPath,o);return await hr(o,i)}))},"getBuildEntryPoints"),ee=Symbol("entry"),yr=l(e=>({name:"esbuild-transform",transform:{filter:{id:/\.([cm]?[jt]s|[jt]sx)$/},async handler(t,u){const n=await st(t,{...e,supported:{"import-meta":!0},loader:"default",sourcefile:u.replace(/\.[cm]ts/,".ts")});return{code:n.code,map:n.map||null}}}}),"esbuildTransform"),Br=l(e=>{if(e==="es")return"esm";if(e==="cjs"||e==="iife")return e},"getEsbuildFormat"),wr=l(e=>({name:"esbuild-minify",renderChunk:l(async(t,u,n)=>{const r=await st(t,{...e,format:Br(n.format),minify:!0,keepNames:!0});return{code:r.code,map:r.map||null}},"renderChunk")}),"esbuildMinify"),Ie=l((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2],"compareSemver"),Qt=l(({target:e})=>{const t=e.some(u=>{if(u=u.trim(),!u.startsWith("node"))return;const n=u.slice(4).split(".").map(Number),r=[n[0],n[1]??0,n[2]??0];return!(Ie(r,[12,20,0])>=0&&Ie(r,[13,0,0])<0||Ie(r,[14,13,1])>=0)});return{name:"node-builtins",resolveId:l(u=>{const n=u.startsWith("node:");if(t&&n&&(u=u.slice(5)),ru.includes(u)||n)return{id:u,external:!0}},"resolveId")}},"nodeBuiltins"),br=l(e=>{const t=e.filter(n=>n.exportEntry.type==="binary");if(t.length===0)return{name:"patch-binary"};let u;return{name:"patch-binary",options:l(()=>{u=new Set(t.flatMap(n=>n.inputNames))},"options"),renderChunk:l((n,r,s)=>{if(!r.isEntry||!r.facadeModuleId||!u.has(r.name))return;const o=new se(n);return o.prepend(`#!/usr/bin/env node
23
+ `),n(),process.exit(1);e[a]=c}}l(ce,"v$1"),A(ce,"mapParametersToArguments");function Mt(e){return e===void 0||e!==!1}l(Mt,"G$1"),A(Mt,"helpEnabled");function Te(e,t,u,n){const r={...t.flags},s=t.version&&!("version"in r);s&&(r.version={type:Boolean,description:"Show version"});const{help:o}=t,i=Mt(o);i&&!("help"in r)&&(r.help={type:Boolean,alias:"h",description:"Show help"});const a=bu(r,n,{ignore:t.ignoreArgv}),c=A(()=>{console.log(t.version)},"showVersion");if(s&&a.flags.version===!0)return c(),process.exit(0);const D=new tr,F=i&&o?.render?o.render:g=>D.render(g),f=A(g=>{const w=Xu({...t,...g?{help:g}:{},flags:r});console.log(F(w,D))},"showHelp");if(i&&a.flags.help===!0)return f(),process.exit(0);if(t.parameters){let{parameters:g}=t,w=a._;const S=g.indexOf("--"),$=g.slice(S+1),d=Object.create(null);if(S>-1&&$.length>0){g=g.slice(0,S);const b=a._["--"];w=w.slice(0,-b.length||void 0),ce(d,le(g),w,f),ce(d,le($),b,f)}else ce(d,le(g),w,f);Object.assign(a._,d)}const p={...a,showVersion:c,showHelp:f},C={command:e,...p};if(typeof u=="function"){const g=u(p);if(g&&"then"in g)return Object.assign(Promise.resolve(g),C)}return C}l(Te,"j"),A(Te,"cliBase");function Ut(e,t){const u=new Map;for(const n of t){const r=[n.options.name],{alias:s}=n.options;s&&(Array.isArray(s)?r.push(...s):r.push(s));for(const o of r){if(u.has(o))throw new Error(`Duplicate command name found: ${L(o)}`);u.set(o,n)}}return u.get(e)}l(Ut,"K$1"),A(Ut,"getCommand");function Vt(e,t,u=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!Oe(e.name)))throw new Error(`Invalid script name: ${L(e.name)}`);const n=u[0];if(e.commands&&n&&Oe(n)){const r=Ut(n,e.commands);if(r)return Te(r.options.name,{...r.options,parent:e},r.callback,u.slice(1))}return Te(void 0,e,t,u)}l(Vt,"Q$1"),A(Vt,"cli");function ur(e,t){if(!e)throw new Error("Command options are required");const{name:u}=e;if(u===void 0)throw new Error("Command name is required");if(!Oe(u))throw new Error(`Invalid command name ${JSON.stringify(u)}. Command names must be one word.`);return{options:e,callback:t}}l(ur,"X$1"),A(ur,"command");var rr="2.24.1";const M=l(e=>_.promises.access(e).then(()=>!0,()=>!1),"fsExists");let V=!0;const J=typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};let X=0;if(J.process&&J.process.env&&J.process.stdout){const{FORCE_COLOR:e,NODE_DISABLE_COLORS:t,NO_COLOR:u,TERM:n,COLORTERM:r}=J.process.env;t||u||e==="0"?V=!1:e==="1"||e==="2"||e==="3"?V=!0:n==="dumb"?V=!1:"CI"in J.process.env&&["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(s=>s in J.process.env)?V=!0:V=process.stdout.isTTY,V&&(process.platform==="win32"||r&&(r==="truecolor"||r==="24bit")?X=3:n&&(n.endsWith("-256color")||n.endsWith("256"))?X=2:X=1)}let zt={enabled:V,supportLevel:X};function sr(e,t,u=1){const n=`\x1B[${e}m`,r=`\x1B[${t}m`,s=new RegExp(`\\x1b\\[${t}m`,"g");return o=>zt.enabled&&zt.supportLevel>=u?n+(""+o).replace(s,n)+r:""+o}l(sr,"kolorist");const or=sr(2,22),De=l(e=>e.replaceAll("\\","/"),"slash"),T=l((e,t)=>(!h.isAbsolute(e)&&!e.startsWith(".")&&!e.startsWith("/")&&(e=`./${e}`),t&&!e.endsWith("/")&&(e+="/"),e),"normalizePath"),ir=l(()=>new Date().toLocaleTimeString(),"currentTime"),K=l((...e)=>console.log(or(ir()),...e),"log"),ar=process.cwd(),fe=l(e=>T(h.relative(ar,e)),"formatPath"),lr=l(async e=>{const t=await P.readFile(e,"utf8");try{return Zn(t)}catch(u){throw new Error(`Failed to parse ${fe(e)}: ${u.message}`)}},"readPackageYaml"),qt=l(async e=>{const t=await P.readFile(e,"utf8");try{return JSON.parse(t)}catch(u){throw new Error(`Failed to parse ${fe(e)}: ${u.message}`)}},"readPackageJson"),cr=l(async e=>{const t=h.join(e,"package.yaml");if(await M(t))return{packageJson:await lr(t),packageJsonPath:t};const u=h.join(e,"package.json");if(await M(u))return{packageJson:await qt(u),packageJsonPath:u};throw new Error(`package.json not found at: ${u} (also checked for package.yaml)`)},"readPackage"),Dr=l(e=>{let t=!1;if(e.includes("=")){const[u,n]=e.split("=");e=n,t=u==="bin"||u==="binary"}return{type:"legacy",source:"cli",outputPath:T(e),isExecutable:t}},"parseCliInputFlag"),fr=l(({imports:e},t)=>{const u={};if(e)for(const n in e){if(n.startsWith("#"))continue;const r=e[n];typeof r=="string"&&(u[n]=h.join(t,r))}return u},"getAliases"),dr=l(e=>{const{publishConfig:t}=e;if(!t)return;const u=["bin","main","exports","types","module"];for(const n of u)t[n]&&(e[n]=t[n])},"applyPublishConfig"),z=l(e=>{if(e.endsWith(".mjs"))return"module";if(e.endsWith(".cjs"))return"commonjs";if(e.endsWith(".d.ts")||e.endsWith(".d.cts")||e.endsWith(".d.mts"))return"types"},"getFileType"),pr=l(e=>e[0]===".","isPath"),Jt=l(e=>e.slice(1).filter(t=>typeof t=="string"&&t[0]!=="."),"getConditions"),de=l((e,t,u,n=[u])=>{if(!e)return[];if(typeof e=="string")return[{source:{type:"package.json",path:[...n]},type:u,conditions:[],format:z(e)||t,outputPath:T(e)}];if(Array.isArray(e))return e.flatMap((s,o)=>{const i=[...n,o];return typeof s=="string"?pr(s)?{source:{type:"package.json",path:[...i]},type:u,conditions:Jt(i),format:z(s)||t,outputPath:T(s)}:[]:de(s,t,u,i)});const r=u==="imports"&&n.length===1;return Object.entries(e).flatMap(([s,o])=>{if(r&&s[0]!=="#")return[];const i=[...n,s];if(typeof o=="string"){const a=Jt(i),c={type:u,source:{type:"package.json",path:i},outputPath:T(o),conditions:a};return a.includes("types")?{...c,format:"types"}:{...c,format:z(o)||t}}return de(o,t,u,i)})},"parsePackageMap"),Fr=l((e,t)=>{const u=[],n=e.main;n&&u.push({source:{type:"package.json",path:["main"]},type:"legacy",format:z(n)??t,outputPath:T(n)});const r=e.module;r&&u.push({source:{type:"package.json",path:["module"]},type:"legacy",format:"module",outputPath:T(r)});const s=e.types;s&&u.push({source:{type:"package.json",path:["types"]},type:"legacy",format:"types",outputPath:T(s)});const{bin:o}=e;if(o)if(typeof o=="string")u.push({source:{type:"package.json",path:["bin"]},type:"binary",format:z(o)??t,outputPath:T(o)});else for(const[i,a]of Object.entries(o))u.push({source:{type:"package.json",path:["bin",i]},type:"binary",format:z(a)??t,outputPath:T(a)});if(e.exports){const i=de(e.exports,t,"exports");u.push(...i)}if(e.imports){const i=de(e.imports,t,"imports");u.push(...i)}return u},"getPkgEntryPoints"),mr=l(async(e,t)=>{for(const u of t){const n=e+u;if(await M(n))return{srcExtension:u,sourcePath:n}}},"tryExtensions"),Pe={".d.ts":[".d.ts",".d.mts",".d.cts",".ts",".tsx",".mts",".cts"],".d.mts":[".d.mts",".d.ts",".d.cts",".ts",".tsx",".mts",".cts"],".d.cts":[".d.cts",".d.ts",".d.mts",".ts",".tsx",".mts",".cts"],".js":[".js",".ts",".tsx",".mts",".cts"],".mjs":[".mjs",".js",".cjs",".mts",".cts",".ts",".tsx"],".cjs":[".cjs",".js",".mjs",".mts",".cts",".ts",".tsx"]},Kt=Object.keys(Pe),hr=l(async(e,t)=>{const{outputPath:u}=e,n=Kt.find(o=>u.endsWith(o));if(!n)return{error:`Unsupported extension (must be ${Kt.join("|")})`,exportEntry:e};const r=u.slice(t.dist.length,-n.length),s=await mr(Z.join(t.srcResolved,r),Pe[n]);return s?{exportEntry:e,distExtension:n,srcdist:t,...s}:{error:`Source file not found: ${Z.join(t.src,r)}(${Pe[n].join("|")})`,exportEntry:e}},"getSourcePath"),gr=l(async e=>{try{return await P.readdir(e,{withFileTypes:!0})}catch(t){const{code:u}=t;if(u==="ENOENT")return[];throw t}},"safeReaddir"),Gt=l(async(e,t)=>{const u=await gr(e);return(await Promise.all(u.map(async r=>{const s=Z.join(e,r.name);return r.isDirectory()?Gt(s,t):r.isFile()?Z.relative(t,s):[]}))).flat()},"getDirectoryFilesRecursive"),Ht=new Map,Yt=l(async e=>{let t=Ht.get(e);return t||(t=Gt(e,e),Ht.set(e,t)),t},"getDirectoryFiles"),pe=/\.[^./]+$/,Zt=l((e,t)=>{const u=t.at(-1);if(!e.endsWith(u))return;if(t.some(r=>r.includes("/"))){const r=e.split("/").filter(Boolean);for(let s=1;s<=r.length;s+=1){const o=r.slice(0,s).join("/"),i=o+t.join(o);if(i===e)return i}}else for(let r=1;r<=e.length;r+=1){const s=e.slice(0,r),o=s+t.join(s);if(o===e)return o}},"extractWildcardMatch"),Cr=l(async(e,t)=>{const u=Array.from(t).sort((r,s)=>s.dist.length-r.dist.length);return(await Promise.all(e.map(async r=>{if(typeof r.source=="string"||r.source.path[0]!=="exports"&&r.source.path[0]!=="imports"||!r.outputPath.includes("*"))return[r];const s=r.source.path[1];if(!s.includes("*"))return[r];const o=r.outputPath.match(/\.d\.[cm]?ts$/)||r.outputPath.match(pe);if(!o)return[{exportEntry:r,error:`Wildcard pattern must include a file extension (e.g., ".mjs", ".cjs"). Pattern: ${s}`}];const[i]=o,a=r.outputPath.slice(0,-i.length),[c,...D]=a.split("*"),F=c.lastIndexOf("/"),f=F===-1?c:c.slice(0,F+1),p=F>=0?c.slice(F+1):"",C=l($=>{const d=$.replace(pe,""),b=d.split("/").at(-1)||"";if(p&&!b.startsWith(p))return!1;if(D.length===1){const B=D[0];return!(B&&!(B.includes("/")?d:b).endsWith(B))}const k=p?b.slice(p.length):d;return!!Zt(k,D)},"matchesPattern");if(f==="./")return(await Promise.all(u.map(async d=>{const b=d.srcResolved;return(await Yt(b)).flatMap(B=>{if(!C(B))return[];const E=B.replace(pe,"");return[{...r,outputPath:d.dist+E+i}]})}))).flat();const g=u.find(({dist:$})=>f===$||f.startsWith($));if(!g)return[];const w=h.posix.join(g.srcResolved,f.slice(g.dist.length));return(await Yt(w)).flatMap($=>{if(!C($))return[];const d=$.replace(pe,"");if(D.length>1){const b=Zt(d,D);return[{...r,outputPath:f+b+i}]}return[{...r,outputPath:f+d+i}]})}))).flat()},"expandBuildOutputWildcards"),Er=l(async(e,t,u)=>{dr(t);const n=t.type??"commonjs",r=await Cr(Fr(t,n),e);u.length>0&&r.push(...u.map(o=>({...o,format:z(o.outputPath)??n})));const s=new Map;return await Promise.all(r.map(async o=>{if("error"in o)return o;const i=e.find(({dist:c})=>o.outputPath.startsWith(c));if(!i)return{exportEntry:o,error:"Ignoring file outside of dist directories"};const a=s.get(o.outputPath);if(a){if(a.format!==o.format)throw new Error(`Conflicting export types "${a.format}" & "${o.format}" found for ${o.outputPath}`)}else s.set(o.outputPath,o);return await hr(o,i)}))},"getBuildEntryPoints"),ee=Symbol("entry"),yr=l(e=>({name:"esbuild-transform",transform:{filter:{id:/\.([cm]?[jt]s|[jt]sx)$/},async handler(t,u){const n=await st(t,{...e,supported:{"import-meta":!0},loader:"default",sourcefile:u.replace(/\.[cm]ts/,".ts")});return{code:n.code,map:n.map||null}}}}),"esbuildTransform"),Br=l(e=>{if(e==="es")return"esm";if(e==="cjs"||e==="iife")return e},"getEsbuildFormat"),wr=l(e=>({name:"esbuild-minify",renderChunk:l(async(t,u,n)=>{const r=await st(t,{...e,format:Br(n.format),minify:!0,keepNames:!0});return{code:r.code,map:r.map||null}},"renderChunk")}),"esbuildMinify"),Ie=l((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2],"compareSemver"),Qt=l(({target:e})=>{const t=e.some(u=>{if(u=u.trim(),!u.startsWith("node"))return;const n=u.slice(4).split(".").map(Number),r=[n[0],n[1]??0,n[2]??0];return!(Ie(r,[12,20,0])>=0&&Ie(r,[13,0,0])<0||Ie(r,[14,13,1])>=0)});return{name:"node-builtins",resolveId:l(u=>{const n=u.startsWith("node:");if(t&&n&&(u=u.slice(5)),ru.includes(u)||n)return{id:u,external:!0}},"resolveId")}},"nodeBuiltins"),br=l(e=>{const t=e.filter(n=>n.exportEntry.type==="binary");if(t.length===0)return{name:"patch-binary"};let u;return{name:"patch-binary",options:l(()=>{u=new Set(t.flatMap(n=>n.inputNames))},"options"),renderChunk:l((n,r,s)=>{if(!r.isEntry||!r.facadeModuleId||!u.has(r.name))return;const o=new se(n);return o.prepend(`#!/usr/bin/env node
24
24
  `),{code:o.toString(),map:s.sourcemap?o.generateMap({hires:!0}):void 0}},"renderChunk"),writeBundle:l(async(n,r)=>{const s=new Set(Object.keys(r).map(o=>T(Z.join(n.dir,o))));await Promise.all(t.map(async({exportEntry:o})=>{const{outputPath:i}=o;s.has(i)&&await _.promises.chmod(i,493)}))},"writeBundle")}},"patchBinary"),Xt=l(e=>{const t=e.indexOf("/");if(t===-1)return[e,void 0];if(e[0]==="@"){const u=e.indexOf("/",t+1);return u===-1?[e,void 0]:[e.slice(0,u),e.slice(u+1)]}return[e.slice(0,t),e.slice(t+1)]},"parseSpecifier"),en=l(e=>{const t=e[0];return!(t==="."||t==="/"||t==="#"||h.isAbsolute(e))},"isBareSpecifier"),Ne=l((e,t=process.cwd())=>De(h.relative(t,e)).split("/").includes("node_modules"),"isFromNodeModules"),tn=l(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"resolve-js-to-ts",async resolveId(t,u,n){if(u&&e.test(t)){if(!Ne(u)){const i=t.replace(/js(x?)$/,"ts$1");return this.resolve(i,u,{...n,skipSelf:!0})}const r=await this.resolve(t,u,{...n,skipSelf:!0});if(r)return r;const s=t.replace(/js(x?)$/,"ts$1"),o=await this.resolve(s,u,{...n,skipSelf:!0});if(o)return o}return null}}},"resolveJsToTs"),nn=l(e=>e!==null&&typeof e=="object","A"),G=l((e,t)=>Object.assign(new Error(`[${e}]: ${t}`),{code:e}),"a"),un="ERR_INVALID_PACKAGE_CONFIG",Re="ERR_INVALID_PACKAGE_TARGET",vr="ERR_PACKAGE_PATH_NOT_EXPORTED",Ar=/^\d+$/,$r=/^(\.{1,2}|node_modules)$/i,xr=/\/|\\/;var rn=(e=>(e.Export="exports",e.Import="imports",e))(rn||{});const _e=l((e,t,u,n,r)=>{if(t==null)return[];if(typeof t=="string"){const[s,...o]=t.split(xr);if(s===".."||o.some(i=>$r.test(i)))throw G(Re,`Invalid "${e}" target "${t}" defined in the package config`);return[r?t.replace(/\*/g,r):t]}if(Array.isArray(t))return t.flatMap(s=>_e(e,s,u,n,r));if(nn(t)){for(const s of Object.keys(t)){if(Ar.test(s))throw G(un,"Cannot contain numeric property keys");if(s==="default"||n.includes(s))return _e(e,t[s],u,n,r)}return[]}throw G(Re,`Invalid "${e}" target "${t}"`)},"f"),te="*",kr=l((e,t)=>{const u=e.indexOf(te),n=t.indexOf(te);return u===n?t.length>e.length:n>u},"m");function jr(e,t){if(!t.includes(te)&&e.hasOwnProperty(t))return[t];let u,n;for(const r of Object.keys(e))if(r.includes(te)){const[s,o,i]=r.split(te);if(i===void 0&&t.startsWith(s)&&t.endsWith(o)){const a=t.slice(s.length,-o.length||void 0);a&&(!u||kr(u,r))&&(u=r,n=a)}}return[u,n]}l(jr,"d");const Sr=l(e=>Object.keys(e).reduce((t,u)=>{const n=u===""||u[0]!==".";if(t===void 0||t===n)return n;throw G(un,'"exports" cannot contain some keys starting with "." and some not')},void 0),"p"),Or=/^\w+:/,Tr=l((e,t,u)=>{if(!e)throw new Error('"exports" is required');t=t===""?".":`./${t}`,(typeof e=="string"||Array.isArray(e)||nn(e)&&Sr(e))&&(e={".":e});const[n,r]=jr(e,t),s=_e(rn.Export,e[n],t,u,r);if(s.length===0)throw G(vr,t==="."?'No "exports" main defined':`Package subpath '${t}' is not defined by "exports"`);for(const o of s)if(!o.startsWith("./")&&!Or.test(o))throw G(Re,`Invalid "exports" target "${o}" defined in the package config`);return s},"v");var Pr=Object.defineProperty,m=l((e,t)=>Pr(e,"name",{value:t,configurable:!0}),"o");function I(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}l(I,"h"),m(I,"slash");const Le=m(e=>{const t=_[e];return(u,...n)=>{const r=`${e}:${n.join(":")}`;let s=u?.get(r);return s===void 0&&(s=Reflect.apply(t,_,n),u?.set(r,s)),s}},"cacheFs"),N=Le("existsSync"),Ir=Le("readFileSync"),Fe=Le("statSync"),sn=m((e,t,u)=>{for(;;){const n=h.posix.join(e,t);if(N(u,n))return n;const r=h.dirname(e);if(r===e)return;e=r}},"findUp"),We=/^\.{1,2}(\/.*)?$/,Me=m(e=>{const t=I(e);return We.test(t)?t:`./${t}`},"normalizeRelativePath");function on(e,t=!1){const u=e.length;let n=0,r="",s=0,o=16,i=0,a=0,c=0,D=0,F=0;function f(d,b){let k=0,B=0;for(;k<d;){let E=e.charCodeAt(n);if(E>=48&&E<=57)B=B*16+E-48;else if(E>=65&&E<=70)B=B*16+E-65+10;else if(E>=97&&E<=102)B=B*16+E-97+10;else break;n++,k++}return k<d&&(B=-1),B}l(f,"y"),m(f,"scanHexDigits");function p(d){n=d,r="",s=0,o=16,F=0}l(p,"v"),m(p,"setPosition");function C(){let d=n;if(e.charCodeAt(n)===48)n++;else for(n++;n<e.length&&q(e.charCodeAt(n));)n++;if(n<e.length&&e.charCodeAt(n)===46)if(n++,n<e.length&&q(e.charCodeAt(n)))for(n++;n<e.length&&q(e.charCodeAt(n));)n++;else return F=3,e.substring(d,n);let b=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&&q(e.charCodeAt(n))){for(n++;n<e.length&&q(e.charCodeAt(n));)n++;b=n}else F=3;return e.substring(d,b)}l(C,"j"),m(C,"scanNumber");function g(){let d="",b=n;for(;;){if(n>=u){d+=e.substring(b,n),F=2;break}const k=e.charCodeAt(n);if(k===34){d+=e.substring(b,n),n++;break}if(k===92){if(d+=e.substring(b,n),n++,n>=u){F=2;break}switch(e.charCodeAt(n++)){case 34:d+='"';break;case 92:d+="\\";break;case 47:d+="/";break;case 98:d+="\b";break;case 102:d+="\f";break;case 110:d+=`
25
25
  `;break;case 114:d+="\r";break;case 116:d+=" ";break;case 117:const B=f(4);B>=0?d+=String.fromCharCode(B):F=4;break;default:F=5}b=n;continue}if(k>=0&&k<=31)if(H(k)){d+=e.substring(b,n),F=2;break}else F=6;n++}return d}l(g,"d"),m(g,"scanString");function w(){if(r="",F=0,s=n,a=i,D=c,n>=u)return s=u,o=17;let d=e.charCodeAt(n);if(me(d)){do n++,r+=String.fromCharCode(d),d=e.charCodeAt(n);while(me(d));return o=15}if(H(d))return n++,r+=String.fromCharCode(d),d===13&&e.charCodeAt(n)===10&&(n++,r+=`
26
26
  `),i++,c=n,o=14;switch(d){case 123:return n++,o=1;case 125:return n++,o=2;case 91:return n++,o=3;case 93:return n++,o=4;case 58:return n++,o=6;case 44:return n++,o=5;case 34:return n++,r=g(),o=10;case 47:const b=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<u&&!H(e.charCodeAt(n));)n++;return r=e.substring(b,n),o=12}if(e.charCodeAt(n+1)===42){n+=2;const k=u-1;let B=!1;for(;n<k;){const E=e.charCodeAt(n);if(E===42&&e.charCodeAt(n+1)===47){n+=2,B=!0;break}n++,H(E)&&(E===13&&e.charCodeAt(n)===10&&n++,i++,c=n)}return B||(n++,F=1),r=e.substring(b,n),o=13}return r+=String.fromCharCode(d),n++,o=16;case 45:if(r+=String.fromCharCode(d),n++,n===u||!q(e.charCodeAt(n)))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+=C(),o=11;default:for(;n<u&&S(d);)n++,d=e.charCodeAt(n);if(s!==n){switch(r=e.substring(s,n),r){case"true":return o=8;case"false":return o=9;case"null":return o=7}return o=16}return r+=String.fromCharCode(d),n++,o=16}}l(w,"A"),m(w,"scanNext");function S(d){if(me(d)||H(d))return!1;switch(d){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}l(S,"E"),m(S,"isUnknownContentCharacter");function $(){let d;do d=w();while(d>=12&&d<=15);return d}return l($,"B"),m($,"scanNextNonTrivia"),{setPosition:p,getPosition:m(()=>n,"getPosition"),scan:t?$:w,getToken:m(()=>o,"getToken"),getTokenValue:m(()=>r,"getTokenValue"),getTokenOffset:m(()=>s,"getTokenOffset"),getTokenLength:m(()=>n-s,"getTokenLength"),getTokenStartLine:m(()=>a,"getTokenStartLine"),getTokenStartCharacter:m(()=>s-D,"getTokenStartCharacter"),getTokenError:m(()=>F,"getTokenError")}}l(on,"Le"),m(on,"createScanner");function me(e){return e===32||e===9}l(me,"X"),m(me,"isWhiteSpace");function H(e){return e===10||e===13}l(H,"S"),m(H,"isLineBreak");function q(e){return e>=48&&e<=57}l(q,"$"),m(q,"isDigit");var an;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"})(an||(an={})),new Array(20).fill(0).map((e,t)=>" ".repeat(t));const Y=200;new Array(Y).fill(0).map((e,t)=>`
@@ -42,4 +42,4 @@ No bundled dependencies.`;const n=e.slice().sort((r,s)=>r.name!==s.name?r.name<s
42
42
 
43
43
  ${n}`},"formatLicenseContent"),$s=l(async(e,t)=>{const u=As(t);if(!await Ze(e)){await P.mkdir(h.dirname(e),{recursive:!0}),await P.writeFile(e,u,"utf8"),console.log(`License file created: ${e}`);return}const n=await P.readFile(e,"utf8"),r=Es.exec(n);let s;r?s=n.slice(0,r.index)+u:s=`${n.trimEnd()}
44
44
 
45
- ${u}`,n!==s&&(await P.writeFile(e,s,"utf8"),console.log(`License file updated: ${e}`))},"writeLicenseFile"),xs=l(e=>{const t=process.cwd();let u=!1;return{name:"pkgroll-license",async generateBundle(n,r){if(this.meta.watchMode||u)return;u=!0;const s=await bs(r);let o;typeof e=="string"?o=h.resolve(t,e):o=await Pn(t)??h.join(t,"LICENSE"),await $s(o,s)}}},"licensePlugin"),ks=l((e,t,u,n,r,s)=>{const o=Object.fromEntries(e.env.map(({key:c,value:D})=>[`process.env.${c}`,JSON.stringify(D)])),i=Object.fromEntries(e.define.map(({key:c,value:D})=>[c,D])),a={target:e.target,sourcemap:e.sourcemap,tsconfigRaw:r?.config,define:{...o,...i}};return{input:{},preserveEntrySignatures:"strict",plugins:[rt(),Qt(e),...r?[An(r)]:[],tu({entries:u}),kn(),ps(),On(t),tn(),Qn({extensions:[".mjs",".js",".ts",".jsx",".tsx",".json"],exportConditions:e.exportCondition}),ss(),eu(),yr(a),gs(),Xn({ignoreDynamicRequires:!0,extensions:[".js",".ts",".jsx",".tsx"],transformMixedEsModules:!0}),nu({warnOnError:!0}),ls(),cs(s),...e.minify?[wr(a)]:[],br(n),...e.license?[xs(e.license)]:[]],output:[]}},"getPkgConfig"),js=l(async(e,t,u)=>{const[n,r]=await Promise.all([import("./rollup-plugin-dts-DArk-PDL.mjs"),import("./local-typescript-loader-CSvrvK-x.mjs")]);return{input:{},preserveEntrySignatures:"strict",plugins:[rt(),kn(),Qt(e),...u?[An(u)]:[],On(t,{skipUnlistedWarnings:!0,forTypes:!0}),tn(),n.default({respectExternal:!0,compilerOptions:{composite:!1,preserveSymlinks:!1,module:r.default.ModuleKind.Preserve,moduleResolution:r.default.ModuleResolutionKind.Bundler},tsconfig:u?.path,sourcemap:!!(e.sourcemap||u?.config.compilerOptions?.declarationMap)})],output:[]}},"getDtsConfig"),Ss=l(e=>{if(e.length===0)return"";const t=e.map(s=>s.split("/")),u=t[0],n=Math.min(...t.map(s=>s.length)),r=[];for(let s=0;s<n;s+=1){const o=u[s];if(t.every(i=>i[s]===o))r.push(o);else break}return r.length===0?"/":r.join("/")||"/"},"getCommonPath"),Os=l(async(e,t,u,n,r,s)=>{const o=T(Ss(e.map(({dist:c})=>c)),!0);for(const c of e)c.distPrefix=c.dist.slice(o.length);const i=e,a=Object.create(null);for(const c of t){const{sourcePath:D,srcExtension:F,distExtension:f,exportEntry:p}=c,C=c.srcdist,g=C.distPrefix+D.slice(C.srcResolved.length,-F.length);if(c.inputNames=[g],p.format==="types"){let d=a.dts;d||(d=await js(u,r,s),a.dts=d),d.input[g]||(d.input[g]=D);const b=d.output;if(b[f])b[f][ee].inputNames.push(g);else{const k={dir:o,entryFileNames:`[name]${f}`,chunkFileNames:`${C.distPrefix}[name]-[hash]${f}`,exports:"auto",format:"esm",sourcemap:u.sourcemap||s?.config.compilerOptions?.declarationMap,[ee]:c};b.push(k),b[f]=k}continue}let w=a.pkg;if(!w){const d=i[0].dist;w=ks(u,r,n,t,s,d),a.pkg=w}w.input[g]||(w.input[g]=D);const S=w.output,$=`${p.format}-${f}`;if(S[$])S[$][ee].inputNames.push(g);else{const d={dir:o,exports:"auto",format:p.format,sourcemap:u.sourcemap,entryFileNames:`[name]${f}`,chunkFileNames:`${C.distPrefix}[name]-[hash]${f}`,[ee]:c};S.push(d),S[$]=d}}return Object.values(a)},"getRollupConfigs"),Ts=l(e=>{if(!e)return zr();const t=h.resolve(e),u=gn(t);return{path:t,config:u}},"getTsconfig"),Ps=l(async e=>{await M(e)&&await _.promises.rm(e,{recursive:!0,force:!0})},"cleanDist"),Is=/^[$_\p{ID_Start}][$\u200C\u200D\p{ID_Continue}]*$/u,Ns=new Set(["do","if","in","for","int","new","try","var","byte","case","char","else","enum","goto","long","null","this","true","void","with","break","catch","class","const","false","final","float","short","super","throw","while","delete","double","export","import","native","public","return","static","switch","throws","typeof","boolean","default","extends","finally","package","private","abstract","continue","debugger","function","volatile","interface","protected","transient","implements","instanceof","synchronized"]),Rs=l(e=>!Is.test(e)||Ns.has(e),"propertyNeedsQuotes"),_s=l(e=>e.map((t,u)=>typeof t=="number"?`[${t}]`:Rs(t)?`[${JSON.stringify(t)}]`:u>0?`.${t}`:t).join(""),"prettyPath"),Ls=l(e=>({name:"filter-unnecessary-outputs",generateBundle:l((t,u)=>{const n=Object.keys(u).filter(o=>u[o].type==="chunk"),r=[];for(const o of n){const i=u[o];i.isEntry&&e.includes(i.name)&&r.push(o)}const s=new Set;for(;r.length>0;){const o=r.shift(),i=u[o];if(!i||s.has(o))continue;s.add(o);const a=[...i.imports,...i.dynamicImports];for(const c of a)r.push(c)}for(const o of n)s.has(o)||delete u[o]},"generateBundle")}),"filterUnnecessaryOutputs"),{stringify:Nn}=JSON,Rn=l(e=>{const[t,u]=e.split("=",2);return{key:t,value:u}},"keyValue"),R=Vt({name:"pkgroll",version:rr,flags:{input:{type:[Dr],alias:"i",description:"Dist paths for source files to bundle (Only use if you cannot use package.json entries)"},src:{type:String,description:"Source directory (Deprecated, use `srcdist` instead)",default:"./src"},dist:{type:String,description:"Distribution directory (Deprecated, use `srcdist` instead)",default:"./dist"},srcdist:{type:[String],description:"Source and distribution folder pairs (eg. default `src: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"},tsconfig:{type:String,description:"Custom tsconfig.json file path",alias:"p"},watch:{type:Boolean,description:"Watch mode",alias:"w",default:!1},env:{type:[Rn],description:"Compile-time environment variables (eg. --env.NODE_ENV=production)"},define:{type:[Rn],description:"Targeted strings to replace (eg. --define.process.env.NODE_ENV='production')"},exportCondition:{type:[String],description:"Export conditions for resolving dependency export and import maps (eg. --export-condition=node)"},sourcemap:{type:l(e=>{if(e==="")return!0;if(e==="inline")return e;throw new Error(`Invalid sourcemap option ${Nn(e)}`)},"type"),description:"Sourcemap generation. Provide `inline` option for inline sourcemap (eg. --sourcemap, --sourcemap=inline)"},cleanDist:{type:Boolean,description:"Clean dist before bundling",default:!1},license:{type:l(e=>e===""?!0:e,"type"),description:"Generate licenses for bundled dependencies. Optionally specify output path (eg. --license, --license=NOTICES.txt)"}},help:{description:"Minimalistic package bundler",render:l((e,t)=>(t.flagOperator=u=>u.name==="env"?".key=":" ",t.render(e)),"render")}}),Qe=process.cwd(),ne=[];if(R.flags.srcdist.length>0)for(const e of R.flags.srcdist){const[t,u]=e.split(":",2);if(!t||!u)throw new Error(`Invalid src:dist pair ${Nn(e)}. Expected format: src:dist`);ne.push({src:T(t,!0),srcResolved:T(_.realpathSync.native(t),!0),dist:T(u,!0)})}else ne.push({src:T(R.flags.src,!0),srcResolved:T(_.realpathSync.native(R.flags.src),!0),dist:T(R.flags.dist,!0)});const _n=Ts(R.flags.tsconfig),Ln=_n?.config.compilerOptions?.target;Ln&&R.flags.target.push(Ln);const Wn=l(async()=>{const{packageJson:e}=await cr(Qe),t=await Er(ne,e,R.flags.input);for(const n of t)if("error"in n){const{exportEntry:r}=n,s=typeof r.source=="string"?r.source:`${r.source.type}#${_s(r.source.path)}`;console.warn(`Warning (${s}):`,n.error)}const u=t.filter(n=>!("error"in n));if(u.length===0)throw new Error("No entry points found");return Os(ne,u,R.flags,fr(e,Qe),e,_n)},"generateRollupConfigs");(async()=>{if(R.flags.cleanDist&&await Promise.all(ne.map(({dist:e})=>Ps(e))),R.flags.watch){K("Watch initialized");let e=[];const t=l(async()=>{e=(await Wn()).map(s=>{const o=Hn(s);return o.on("event",async i=>{if(i.code==="BUNDLE_START"){const a=Array.isArray(i.input)?i.input:Object.values(i.input);K("Building",...a.map(fe))}if(i.code==="BUNDLE_END")try{await Promise.all(s.output.map(c=>i.result.write(c)));const a=Array.isArray(i.input)?i.input:Object.values(i.input);K("Built",...a.map(fe))}finally{await i.result.close()}i.code==="ERROR"&&(K("Error:",i.error.message),await i.result?.close())}),o})},"startWatchers"),u=l(async()=>{await Promise.all(e.map(r=>r.close())),e=[]},"closeWatchers");await t();let n;_.watch(h.join(Qe,"package.json"),()=>{clearTimeout(n),n=setTimeout(async()=>{K("package.json changed, restarting...");try{await u(),await t()}catch(r){K("Error:",r.message)}},100)})}else{const e=await Wn();await Promise.all(e.map(async t=>{const u=await Gn(t);try{await Promise.all(t.output.map(n=>{const r=n[ee].inputNames;return n.plugins=[Ls(r)],u.write(n)}))}finally{await u.close()}}))}})().catch(e=>{Yn(e),console.error("Error:",e instanceof Error?e.message:String(e)),process.exit(1)});
45
+ ${u}`,n!==s&&(await P.writeFile(e,s,"utf8"),console.log(`License file updated: ${e}`))},"writeLicenseFile"),xs=l(e=>{const t=process.cwd();let u=!1;return{name:"pkgroll-license",async generateBundle(n,r){if(this.meta.watchMode||u)return;u=!0;const s=await bs(r);let o;typeof e=="string"?o=h.resolve(t,e):o=await Pn(t)??h.join(t,"LICENSE"),await $s(o,s)}}},"licensePlugin"),ks=l((e,t,u,n,r,s)=>{const o=Object.fromEntries(e.env.map(({key:c,value:D})=>[`process.env.${c}`,JSON.stringify(D)])),i=Object.fromEntries(e.define.map(({key:c,value:D})=>[c,D])),a={target:e.target,sourcemap:e.sourcemap,tsconfigRaw:r?.config,define:{...o,...i}};return{input:{},preserveEntrySignatures:"strict",plugins:[rt(),Qt(e),...r?[An(r)]:[],tu({entries:u}),kn(),ps(),On(t),tn(),Qn({extensions:[".mjs",".js",".ts",".jsx",".tsx",".json"],exportConditions:e.exportCondition}),ss(),eu(),yr(a),gs(),Xn({ignoreDynamicRequires:!0,extensions:[".js",".ts",".jsx",".tsx"],transformMixedEsModules:!0}),nu({warnOnError:!0}),ls(),cs(s),...e.minify?[wr(a)]:[],br(n),...e.license?[xs(e.license)]:[]],output:[]}},"getPkgConfig"),js=l(async(e,t,u)=>{const[n,r]=await Promise.all([import("./rollup-plugin-dts-BUQLp_V-.mjs"),import("./local-typescript-loader-CSvrvK-x.mjs")]);return{input:{},preserveEntrySignatures:"strict",plugins:[rt(),kn(),Qt(e),...u?[An(u)]:[],On(t,{skipUnlistedWarnings:!0,forTypes:!0}),tn(),n.default({respectExternal:!0,compilerOptions:{composite:!1,preserveSymlinks:!1,module:r.default.ModuleKind.Preserve,moduleResolution:r.default.ModuleResolutionKind.Bundler},tsconfig:u?.path,sourcemap:!!(e.sourcemap||u?.config.compilerOptions?.declarationMap)})],output:[]}},"getDtsConfig"),Ss=l(e=>{if(e.length===0)return"";const t=e.map(s=>s.split("/")),u=t[0],n=Math.min(...t.map(s=>s.length)),r=[];for(let s=0;s<n;s+=1){const o=u[s];if(t.every(i=>i[s]===o))r.push(o);else break}return r.length===0?"/":r.join("/")||"/"},"getCommonPath"),Os=l(async(e,t,u,n,r,s)=>{const o=T(Ss(e.map(({dist:c})=>c)),!0);for(const c of e)c.distPrefix=c.dist.slice(o.length);const i=e,a=Object.create(null);for(const c of t){const{sourcePath:D,srcExtension:F,distExtension:f,exportEntry:p}=c,C=c.srcdist,g=C.distPrefix+D.slice(C.srcResolved.length,-F.length);if(c.inputNames=[g],p.format==="types"){let d=a.dts;d||(d=await js(u,r,s),a.dts=d),d.input[g]||(d.input[g]=D);const b=d.output;if(b[f])b[f][ee].inputNames.push(g);else{const k={dir:o,entryFileNames:`[name]${f}`,chunkFileNames:`${C.distPrefix}[name]-[hash]${f}`,exports:"auto",format:"esm",sourcemap:u.sourcemap||s?.config.compilerOptions?.declarationMap,[ee]:c};b.push(k),b[f]=k}continue}let w=a.pkg;if(!w){const d=i[0].dist;w=ks(u,r,n,t,s,d),a.pkg=w}w.input[g]||(w.input[g]=D);const S=w.output,$=`${p.format}-${f}`;if(S[$])S[$][ee].inputNames.push(g);else{const d={dir:o,exports:"auto",format:p.format,sourcemap:u.sourcemap,entryFileNames:`[name]${f}`,chunkFileNames:`${C.distPrefix}[name]-[hash]${f}`,[ee]:c};S.push(d),S[$]=d}}return Object.values(a)},"getRollupConfigs"),Ts=l(e=>{if(!e)return zr();const t=h.resolve(e),u=gn(t);return{path:t,config:u}},"getTsconfig"),Ps=l(async e=>{await M(e)&&await _.promises.rm(e,{recursive:!0,force:!0})},"cleanDist"),Is=/^[$_\p{ID_Start}][$\u200C\u200D\p{ID_Continue}]*$/u,Ns=new Set(["do","if","in","for","int","new","try","var","byte","case","char","else","enum","goto","long","null","this","true","void","with","break","catch","class","const","false","final","float","short","super","throw","while","delete","double","export","import","native","public","return","static","switch","throws","typeof","boolean","default","extends","finally","package","private","abstract","continue","debugger","function","volatile","interface","protected","transient","implements","instanceof","synchronized"]),Rs=l(e=>!Is.test(e)||Ns.has(e),"propertyNeedsQuotes"),_s=l(e=>e.map((t,u)=>typeof t=="number"?`[${t}]`:Rs(t)?`[${JSON.stringify(t)}]`:u>0?`.${t}`:t).join(""),"prettyPath"),Ls=l(e=>({name:"filter-unnecessary-outputs",generateBundle:l((t,u)=>{const n=Object.keys(u).filter(o=>u[o].type==="chunk"),r=[];for(const o of n){const i=u[o];i.isEntry&&e.includes(i.name)&&r.push(o)}const s=new Set;for(;r.length>0;){const o=r.shift(),i=u[o];if(!i||s.has(o))continue;s.add(o);const a=[...i.imports,...i.dynamicImports];for(const c of a)r.push(c)}for(const o of n)s.has(o)||delete u[o]},"generateBundle")}),"filterUnnecessaryOutputs"),{stringify:Nn}=JSON,Rn=l(e=>{const[t,u]=e.split("=",2);return{key:t,value:u}},"keyValue"),R=Vt({name:"pkgroll",version:rr,flags:{input:{type:[Dr],alias:"i",description:"Dist paths for source files to bundle (Only use if you cannot use package.json entries)"},src:{type:String,description:"Source directory (Deprecated, use `srcdist` instead)",default:"./src"},dist:{type:String,description:"Distribution directory (Deprecated, use `srcdist` instead)",default:"./dist"},srcdist:{type:[String],description:"Source and distribution folder pairs (eg. default `src: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"},tsconfig:{type:String,description:"Custom tsconfig.json file path",alias:"p"},watch:{type:Boolean,description:"Watch mode",alias:"w",default:!1},env:{type:[Rn],description:"Compile-time environment variables (eg. --env.NODE_ENV=production)"},define:{type:[Rn],description:"Targeted strings to replace (eg. --define.process.env.NODE_ENV='production')"},exportCondition:{type:[String],description:"Export conditions for resolving dependency export and import maps (eg. --export-condition=node)"},sourcemap:{type:l(e=>{if(e==="")return!0;if(e==="inline")return e;throw new Error(`Invalid sourcemap option ${Nn(e)}`)},"type"),description:"Sourcemap generation. Provide `inline` option for inline sourcemap (eg. --sourcemap, --sourcemap=inline)"},cleanDist:{type:Boolean,description:"Clean dist before bundling",default:!1},license:{type:l(e=>e===""?!0:e,"type"),description:"Generate licenses for bundled dependencies. Optionally specify output path (eg. --license, --license=NOTICES.txt)"}},help:{description:"Minimalistic package bundler",render:l((e,t)=>(t.flagOperator=u=>u.name==="env"?".key=":" ",t.render(e)),"render")}}),Qe=process.cwd(),ne=[];if(R.flags.srcdist.length>0)for(const e of R.flags.srcdist){const[t,u]=e.split(":",2);if(!t||!u)throw new Error(`Invalid src:dist pair ${Nn(e)}. Expected format: src:dist`);ne.push({src:T(t,!0),srcResolved:T(_.realpathSync.native(t),!0),dist:T(u,!0)})}else ne.push({src:T(R.flags.src,!0),srcResolved:T(_.realpathSync.native(R.flags.src),!0),dist:T(R.flags.dist,!0)});const _n=Ts(R.flags.tsconfig),Ln=_n?.config.compilerOptions?.target;Ln&&R.flags.target.push(Ln);const Wn=l(async()=>{const{packageJson:e}=await cr(Qe),t=await Er(ne,e,R.flags.input);for(const n of t)if("error"in n){const{exportEntry:r}=n,s=typeof r.source=="string"?r.source:`${r.source.type}#${_s(r.source.path)}`;console.warn(`Warning (${s}):`,n.error)}const u=t.filter(n=>!("error"in n));if(u.length===0)throw new Error("No entry points found");return Os(ne,u,R.flags,fr(e,Qe),e,_n)},"generateRollupConfigs");(async()=>{if(R.flags.cleanDist&&await Promise.all(ne.map(({dist:e})=>Ps(e))),R.flags.watch){K("Watch initialized");let e=[];const t=l(async()=>{e=(await Wn()).map(s=>{const o=Hn(s);return o.on("event",async i=>{if(i.code==="BUNDLE_START"){const a=Array.isArray(i.input)?i.input:Object.values(i.input);K("Building",...a.map(fe))}if(i.code==="BUNDLE_END")try{await Promise.all(s.output.map(c=>i.result.write(c)));const a=Array.isArray(i.input)?i.input:Object.values(i.input);K("Built",...a.map(fe))}finally{await i.result.close()}i.code==="ERROR"&&(K("Error:",i.error.message),await i.result?.close())}),o})},"startWatchers"),u=l(async()=>{await Promise.all(e.map(r=>r.close())),e=[]},"closeWatchers");await t();let n;_.watch(h.join(Qe,"package.json"),()=>{clearTimeout(n),n=setTimeout(async()=>{K("package.json changed, restarting...");try{await u(),await t()}catch(r){K("Error:",r.message)}},100)})}else{const e=await Wn();await Promise.all(e.map(async t=>{const u=await Gn(t);try{await Promise.all(t.output.map(n=>{const r=n[ee].inputNames;return n.plugins=[Ls(r)],u.write(n)}))}finally{await u.close()}}))}})().catch(e=>{Yn(e),console.error("Error:",e instanceof Error?e.message:String(e)),process.exit(1)});
@@ -0,0 +1,36 @@
1
+ var Xe=Object.defineProperty;var c=(n,e)=>Xe(n,"name",{value:e,configurable:!0});import{createRequire as Qe}from"node:module";const Ye=Qe(import.meta.url);import*as T from"node:path";import i from"typescript";import{createRequire as Ze}from"node:module";import X from"magic-string";import ce from"node:fs/promises";var le=44,et=59,ue="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",pe=new Uint8Array(64),fe=new Uint8Array(128);for(let n=0;n<ue.length;n++){const e=ue.charCodeAt(n);pe[n]=e,fe[e]=n}function K(n,e){let t=0,r=0,s=0;do{const a=n.next();s=fe[a],t|=(s&31)<<r,r+=5}while(s&32);const o=t&1;return t>>>=1,o&&(t=-2147483648|-t),e+t}c(K,"decodeInteger");function z(n,e,t){let r=e-t;r=r<0?-r<<1|1:r<<1;do{let s=r&31;r>>>=5,r>0&&(s|=32),n.write(pe[s])}while(r>0);return e}c(z,"encodeInteger");function me(n,e){return n.pos>=e?!1:n.peek()!==le}c(me,"hasMoreVlq");var de=1024*16,he=typeof TextDecoder<"u"?new TextDecoder:typeof Buffer<"u"?{decode(n){return Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString()}}:{decode(n){let e="";for(let t=0;t<n.length;t++)e+=String.fromCharCode(n[t]);return e}},tt=class{static{c(this,"StringWriter")}constructor(){this.pos=0,this.out="",this.buffer=new Uint8Array(de)}write(n){const{buffer:e}=this;e[this.pos++]=n,this.pos===de&&(this.out+=he.decode(e),this.pos=0)}flush(){const{buffer:n,out:e,pos:t}=this;return t>0?e+he.decode(n.subarray(0,t)):e}},nt=class{static{c(this,"StringReader")}constructor(n){this.pos=0,this.buffer=n}next(){return this.buffer.charCodeAt(this.pos++)}peek(){return this.buffer.charCodeAt(this.pos)}indexOf(n){const{buffer:e,pos:t}=this,r=e.indexOf(n,t);return r===-1?e.length:r}};function Q(n){const{length:e}=n,t=new nt(n),r=[];let s=0,o=0,a=0,l=0,m=0;do{const p=t.indexOf(";"),d=[];let h=!0,u=0;for(s=0;t.pos<p;){let g;s=K(t,s),s<u&&(h=!1),u=s,me(t,p)?(o=K(t,o),a=K(t,a),l=K(t,l),me(t,p)?(m=K(t,m),g=[s,o,a,l,m]):g=[s,o,a,l]):g=[s],d.push(g),t.pos++}h||rt(d),r.push(d),t.pos=p+1}while(t.pos<=e);return r}c(Q,"decode");function rt(n){n.sort(st)}c(rt,"sort");function st(n,e){return n[0]-e[0]}c(st,"sortComparator$1");function ge(n){const e=new tt;let t=0,r=0,s=0,o=0;for(let a=0;a<n.length;a++){const l=n[a];if(a>0&&e.write(et),l.length===0)continue;let m=0;for(let p=0;p<l.length;p++){const d=l[p];p>0&&e.write(le),m=z(e,d[0],m),d.length!==1&&(t=z(e,d[1],t),r=z(e,d[2],r),s=z(e,d[3],s),d.length!==4&&(o=z(e,d[4],o)))}}return e.flush()}c(ge,"encode");const it=/^[\w+.-]+:\/\//,ot=/^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/,at=/^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;function ct(n){return it.test(n)}c(ct,"isAbsoluteUrl");function lt(n){return n.startsWith("//")}c(lt,"isSchemeRelativeUrl");function ye(n){return n.startsWith("/")}c(ye,"isAbsolutePath");function ut(n){return n.startsWith("file:")}c(ut,"isFileUrl");function xe(n){return/^[.?#]/.test(n)}c(xe,"isRelative");function q(n){const e=ot.exec(n);return Se(e[1],e[2]||"",e[3],e[4]||"",e[5]||"/",e[6]||"",e[7]||"")}c(q,"parseAbsoluteUrl");function pt(n){const e=at.exec(n),t=e[2];return Se("file:","",e[1]||"","",ye(t)?t:"/"+t,e[3]||"",e[4]||"")}c(pt,"parseFileUrl");function Se(n,e,t,r,s,o,a){return{scheme:n,user:e,host:t,port:r,path:s,query:o,hash:a,type:7}}c(Se,"makeUrl");function ve(n){if(lt(n)){const t=q("http:"+n);return t.scheme="",t.type=6,t}if(ye(n)){const t=q("http://foo.com"+n);return t.scheme="",t.host="",t.type=5,t}if(ut(n))return pt(n);if(ct(n))return q(n);const e=q("http://foo.com/"+n);return e.scheme="",e.host="",e.type=n?n.startsWith("?")?3:n.startsWith("#")?2:4:1,e}c(ve,"parseUrl");function ft(n){if(n.endsWith("/.."))return n;const e=n.lastIndexOf("/");return n.slice(0,e+1)}c(ft,"stripPathFilename");function mt(n,e){Ee(e,e.type),n.path==="/"?n.path=e.path:n.path=ft(e.path)+n.path}c(mt,"mergePaths");function Ee(n,e){const t=e<=4,r=n.path.split("/");let s=1,o=0,a=!1;for(let m=1;m<r.length;m++){const p=r[m];if(!p){a=!0;continue}if(a=!1,p!=="."){if(p===".."){o?(a=!0,o--,s--):t&&(r[s++]=p);continue}r[s++]=p,o++}}let l="";for(let m=1;m<s;m++)l+="/"+r[m];(!l||a&&!l.endsWith("/.."))&&(l+="/"),n.path=l}c(Ee,"normalizePath");function dt(n,e){if(!n&&!e)return"";const t=ve(n);let r=t.type;if(e&&r!==7){const o=ve(e),a=o.type;switch(r){case 1:t.hash=o.hash;case 2:t.query=o.query;case 3:case 4:mt(t,o);case 5:t.user=o.user,t.host=o.host,t.port=o.port;case 6:t.scheme=o.scheme}a>r&&(r=a)}Ee(t,r);const s=t.query+t.hash;switch(r){case 2:case 3:return s;case 4:{const o=t.path.slice(1);return o?xe(e||n)&&!xe(o)?"./"+o+s:o+s:s||"."}case 5:return t.path+s;default:return t.scheme+"//"+t.user+t.host+t.port+t.path+s}}c(dt,"resolve");function ht(n){if(!n)return"";const e=n.lastIndexOf("/");return n.slice(0,e+1)}c(ht,"stripFilename");function gt(n,e){const t=ht(n),r=e?e+"/":"";return s=>dt(r+(s||""),t)}c(gt,"resolver");var k=0;function yt(n,e){const t=Te(n,0);if(t===n.length)return n;e||(n=n.slice());for(let r=t;r<n.length;r=Te(n,r+1))n[r]=St(n[r],e);return n}c(yt,"maybeSort");function Te(n,e){for(let t=e;t<n.length;t++)if(!xt(n[t]))return t;return n.length}c(Te,"nextUnsortedSegmentLine");function xt(n){for(let e=1;e<n.length;e++)if(n[e][k]<n[e-1][k])return!1;return!0}c(xt,"isSorted");function St(n,e){return e||(n=n.slice()),n.sort(vt)}c(St,"sortSegments");function vt(n,e){return n[k]-e[k]}c(vt,"sortComparator");var H=!1;function Et(n,e,t,r){for(;t<=r;){const s=t+(r-t>>1),o=n[s][k]-e;if(o===0)return H=!0,s;o<0?t=s+1:r=s-1}return H=!1,t-1}c(Et,"binarySearch");function Tt(n,e,t){for(let r=t-1;r>=0&&n[r][k]===e;t=r--);return t}c(Tt,"lowerBound");function Nt(){return{lastKey:-1,lastNeedle:-1,lastIndex:-1}}c(Nt,"memoizedState");function Ct(n,e,t,r){const{lastKey:s,lastNeedle:o,lastIndex:a}=t;let l=0,m=n.length-1;if(r===s){if(e===o)return H=a!==-1&&n[a][k]===e,a;e>=o?l=a===-1?0:a:m=a}return t.lastKey=r,t.lastNeedle=e,t.lastIndex=Et(n,e,l,m)}c(Ct,"memoizedBinarySearch");function wt(n){return typeof n=="string"?JSON.parse(n):n}c(wt,"parse$1");var Ne=class{static{c(this,"TraceMap")}constructor(n,e){const t=typeof n=="string";if(!t&&n._decodedMemo)return n;const r=wt(n),{version:s,file:o,names:a,sourceRoot:l,sources:m,sourcesContent:p}=r;this.version=s,this.file=o,this.names=a||[],this.sourceRoot=l,this.sources=m,this.sourcesContent=p,this.ignoreList=r.ignoreList||r.x_google_ignoreList||void 0;const d=gt(e,l);this.resolvedSources=m.map(d);const{mappings:h}=r;if(typeof h=="string")this._encoded=h,this._decoded=void 0;else if(Array.isArray(h))this._encoded=void 0,this._decoded=yt(h,t);else throw r.sections?new Error("TraceMap passed sectioned source map, please use FlattenMap export instead"):new Error(`invalid source map: ${JSON.stringify(r)}`);this._decodedMemo=Nt(),this._bySources=void 0,this._bySourceMemos=void 0}};function Ln(n){return n}c(Ln,"cast$1");function Ce(n){var e;return(e=n)._decoded||(e._decoded=Q(n._encoded))}c(Ce,"decodedMappings");function Dt(n,e,t){const r=Ce(n);if(e>=r.length)return null;const s=r[e],o=bt(s,n._decodedMemo,e,t);return o===-1?null:s[o]}c(Dt,"traceSegment");function bt(n,e,t,r,s){let o=Ct(n,r,e,t);return H&&(o=Tt(n,r,o)),o===-1||o===n.length?-1:o}c(bt,"traceSegmentInternal");var Y=class{static{c(this,"SetArray")}constructor(){this._indexes={__proto__:null},this.array=[]}};function _n(n){return n}c(_n,"cast");function we(n,e){return n._indexes[e]}c(we,"get");function V(n,e){const t=we(n,e);if(t!==void 0)return t;const{array:r,_indexes:s}=n,o=r.push(e);return s[e]=o-1}c(V,"put");function It(n,e){const t=we(n,e);if(t===void 0)return;const{array:r,_indexes:s}=n;for(let o=t+1;o<r.length;o++){const a=r[o];r[o-1]=a,s[a]--}s[e]=void 0,r.pop()}c(It,"remove");var Mt=0,Ft=1,Ot=2,Rt=3,At=4,De=-1,Pt=class{static{c(this,"GenMapping")}constructor({file:n,sourceRoot:e}={}){this._names=new Y,this._sources=new Y,this._sourcesContent=[],this._mappings=[],this.file=n,this.sourceRoot=e,this._ignoreList=new Y}};function $n(n){return n}c($n,"cast2");var Lt=c((n,e,t,r,s,o,a,l)=>kt(!0,n,e,t,r,s,o,a),"maybeAddSegment");function _t(n,e,t){const{_sources:r,_sourcesContent:s}=n,o=V(r,e);s[o]=t}c(_t,"setSourceContent");function $t(n,e,t=!0){const{_sources:r,_sourcesContent:s,_ignoreList:o}=n,a=V(r,e);a===s.length&&(s[a]=null),t?V(o,a):It(o,a)}c($t,"setIgnore");function be(n){const{_mappings:e,_sources:t,_sourcesContent:r,_names:s,_ignoreList:o}=n;return Kt(e),{version:3,file:n.file||void 0,names:s.array,sourceRoot:n.sourceRoot||void 0,sources:t.array,sourcesContent:r,mappings:e,ignoreList:o.array}}c(be,"toDecodedMap");function Bt(n){const e=be(n);return Object.assign({},e,{mappings:ge(e.mappings)})}c(Bt,"toEncodedMap");function kt(n,e,t,r,s,o,a,l,m){const{_mappings:p,_sources:d,_sourcesContent:h,_names:u}=e,g=jt(p,t),x=Ut(g,r);if(!s)return zt(g,x)?void 0:Ie(g,x,[r]);const S=V(d,s),E=l?V(u,l):De;if(S===h.length&&(h[S]=null),!Vt(g,x,S,o,a,E))return Ie(g,x,l?[r,S,o,a,E]:[r,S,o,a])}c(kt,"addSegmentInternal");function jt(n,e){for(let t=n.length;t<=e;t++)n[t]=[];return n[e]}c(jt,"getIndex");function Ut(n,e){let t=n.length;for(let r=t-1;r>=0;t=r--){const s=n[r];if(e>=s[Mt])break}return t}c(Ut,"getColumnIndex");function Ie(n,e,t){for(let r=n.length;r>e;r--)n[r]=n[r-1];n[e]=t}c(Ie,"insert");function Kt(n){const{length:e}=n;let t=e;for(let r=t-1;r>=0&&!(n[r].length>0);t=r,r--);t<e&&(n.length=t)}c(Kt,"removeEmptyFinalLines");function zt(n,e){return e===0?!0:n[e-1].length===1}c(zt,"skipSourceless");function Vt(n,e,t,r,s,o){if(e===0)return!1;const a=n[e-1];return a.length===1?!1:t===a[Ft]&&r===a[Ot]&&s===a[Rt]&&o===(a.length===5?a[At]:De)}c(Vt,"skipSource");var Me=Fe("",-1,-1,"",null,!1),Jt=[];function Fe(n,e,t,r,s,o){return{source:n,line:e,column:t,name:r,content:s,ignore:o}}c(Fe,"SegmentObject");function Oe(n,e,t,r,s){return{map:n,sources:e,source:t,content:r,ignore:s}}c(Oe,"Source");function Re(n,e){return Oe(n,e,"",null,!1)}c(Re,"MapSource");function Wt(n,e,t){return Oe(null,Jt,n,e,t)}c(Wt,"OriginalSource");function Gt(n){const e=new Pt({file:n.map.file}),{sources:t,map:r}=n,s=r.names,o=Ce(r);for(let a=0;a<o.length;a++){const l=o[a];for(let m=0;m<l.length;m++){const p=l[m],d=p[0];let h=Me;if(p.length!==1){const D=t[p[1]];if(h=Ae(D,p[2],p[3],p.length===5?s[p[4]]:""),h==null)continue}const{column:u,line:g,name:x,content:S,source:E,ignore:N}=h;Lt(e,a,d,E,g,u,x),E&&S!=null&&_t(e,E,S),N&&$t(e,E,!0)}}return e}c(Gt,"traceMappings");function Ae(n,e,t,r){if(!n.map)return Fe(n.source,e,t,r,n.content,n.ignore);const s=Dt(n.map,e,t);return s==null?null:s.length===1?Me:Ae(n.sources[s[1]],s[2],s[3],s.length===5?n.map.names[s[4]]:r)}c(Ae,"originalPositionFor");function qt(n){return Array.isArray(n)?n:[n]}c(qt,"asArray");function Ht(n,e){const t=qt(n).map(o=>new Ne(o,"")),r=t.pop();for(let o=0;o<t.length;o++)if(t[o].sources.length>1)throw new Error(`Transformation map ${o} must have exactly one source file.
2
+ Did you specify these with the most recent transformation maps first?`);let s=Pe(r,e,"",0);for(let o=t.length-1;o>=0;o--)s=Re(t[o],[s]);return s}c(Ht,"buildSourceMapTree");function Pe(n,e,t,r){const{resolvedSources:s,sourcesContent:o,ignoreList:a}=n,l=r+1,m=s.map((p,d)=>{const h={importer:t,depth:l,source:p||"",content:void 0,ignore:void 0},u=e(h.source,h),{source:g}=h;if(u)return Pe(new Ne(u,g),e,g,l);const x=o?o[d]:null,S=a?a.includes(d):!1;return Wt(g,x,S)});return Re(n,m)}c(Pe,"build");var Xt=class{static{c(this,"SourceMap")}constructor(n,e){const t=e.decodedMappings?be(n):Bt(n);this.version=t.version,this.file=t.file,this.mappings=t.mappings,this.names=t.names,this.ignoreList=t.ignoreList,this.sourceRoot=t.sourceRoot,this.sources=t.sources,e.excludeContent||(this.sourcesContent=t.sourcesContent)}toString(){return JSON.stringify(this)}};function Qt(n,e,t){const r={excludeContent:!1,decodedMappings:!1},s=Ht(n,e);return new Xt(Gt(s),r)}c(Qt,"remapping");function Yt(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}c(Yt,"getDefaultExportFromCjs");var Z={},Le;function Zt(){return Le||(Le=1,(function(n){Object.defineProperty(n,"commentRegex",{get:c(function(){return/^\s*?\/[\/\*][@#]\s+?sourceMappingURL=data:(((?:application|text)\/json)(?:;charset=([^;,]+?)?)?)?(?:;(base64))?,(.*?)$/mg},"getCommentRegex")}),Object.defineProperty(n,"mapFileCommentRegex",{get:c(function(){return/(?:\/\/[@#][ \t]+?sourceMappingURL=([^\s'"`]+?)[ \t]*?$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*?(?:\*\/){1}[ \t]*?$)/mg},"getMapFileCommentRegex")});var e;typeof Buffer<"u"?typeof Buffer.from=="function"?e=t:e=r:e=s;function t(u){return Buffer.from(u,"base64").toString()}c(t,"decodeBase64WithBufferFrom");function r(u){if(typeof value=="number")throw new TypeError("The value to decode must not be of type number.");return new Buffer(u,"base64").toString()}c(r,"decodeBase64WithNewBuffer");function s(u){return decodeURIComponent(escape(atob(u)))}c(s,"decodeBase64WithAtob");function o(u){return u.split(",").pop()}c(o,"stripComment");function a(u,g){var x=n.mapFileCommentRegex.exec(u),S=x[1]||x[2];try{var u=g(S);return u!=null&&typeof u.catch=="function"?u.catch(E):u}catch(N){E(N)}function E(N){throw new Error("An error occurred while trying to read the map file at "+S+`
3
+ `+N.stack)}c(E,"throwError")}c(a,"readFromFileMap");function l(u,g){g=g||{},g.hasComment&&(u=o(u)),g.encoding==="base64"?u=e(u):g.encoding==="uri"&&(u=decodeURIComponent(u)),(g.isJSON||g.encoding)&&(u=JSON.parse(u)),this.sourcemap=u}c(l,"Converter"),l.prototype.toJSON=function(u){return JSON.stringify(this.sourcemap,null,u)},typeof Buffer<"u"?typeof Buffer.from=="function"?l.prototype.toBase64=m:l.prototype.toBase64=p:l.prototype.toBase64=d;function m(){var u=this.toJSON();return Buffer.from(u,"utf8").toString("base64")}c(m,"encodeBase64WithBufferFrom");function p(){var u=this.toJSON();if(typeof u=="number")throw new TypeError("The json to encode must not be of type number.");return new Buffer(u,"utf8").toString("base64")}c(p,"encodeBase64WithNewBuffer");function d(){var u=this.toJSON();return btoa(unescape(encodeURIComponent(u)))}c(d,"encodeBase64WithBtoa"),l.prototype.toURI=function(){var u=this.toJSON();return encodeURIComponent(u)},l.prototype.toComment=function(u){var g,x,S;return u!=null&&u.encoding==="uri"?(g="",x=this.toURI()):(g=";base64",x=this.toBase64()),S="sourceMappingURL=data:application/json;charset=utf-8"+g+","+x,u!=null&&u.multiline?"/*# "+S+" */":"//# "+S},l.prototype.toObject=function(){return JSON.parse(this.toJSON())},l.prototype.addProperty=function(u,g){if(this.sourcemap.hasOwnProperty(u))throw new Error('property "'+u+'" already exists on the sourcemap, use set property instead');return this.setProperty(u,g)},l.prototype.setProperty=function(u,g){return this.sourcemap[u]=g,this},l.prototype.getProperty=function(u){return this.sourcemap[u]},n.fromObject=function(u){return new l(u)},n.fromJSON=function(u){return new l(u,{isJSON:!0})},n.fromURI=function(u){return new l(u,{encoding:"uri"})},n.fromBase64=function(u){return new l(u,{encoding:"base64"})},n.fromComment=function(u){var g,x;return u=u.replace(/^\/\*/g,"//").replace(/\*\/$/g,""),g=n.commentRegex.exec(u),x=g&&g[4]||"uri",new l(u,{encoding:x,hasComment:!0})};function h(u){return new l(u,{isJSON:!0})}c(h,"makeConverter"),n.fromMapFileComment=function(u,g){if(typeof g=="string")throw new Error("String directory paths are no longer supported with `fromMapFileComment`\nPlease review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading");var x=a(u,g);return x!=null&&typeof x.then=="function"?x.then(h):h(x)},n.fromSource=function(u){var g=u.match(n.commentRegex);return g?n.fromComment(g.pop()):null},n.fromMapFileSource=function(u,g){if(typeof g=="string")throw new Error("String directory paths are no longer supported with `fromMapFileSource`\nPlease review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading");var x=u.match(n.mapFileCommentRegex);return x?n.fromMapFileComment(x.pop(),g):null},n.removeComments=function(u){return u.replace(n.commentRegex,"")},n.removeMapFileComments=function(u){return u.replace(n.mapFileCommentRegex,"")},n.generateMapFileComment=function(u,g){var x="sourceMappingURL="+u;return g&&g.multiline?"/*# "+x+" */":"//# "+x}})(Z)),Z}c(Zt,"requireConvertSourceMap");var en=Zt(),_e=Yt(en);function tn(n){return{...n,compilerOptions:n.compilerOptions??{},respectExternal:n.respectExternal??!1,includeExternal:n.includeExternal??[],sourcemap:n.sourcemap??!1}}c(tn,"resolveDefaultOptions");const j=/\.d\.(c|m)?tsx?$/,ee=/\.json$/,$e=/((\.d)?\.(c|m)?(t|j)sx?|\.json)$/;function te(n){return n.replace($e,"")}c(te,"trimExtension");function Be(n){return n.replace($e,".d.ts")}c(Be,"getDeclarationId");function J(n,e){return i.createSourceFile(n,e,i.ScriptTarget.Latest,!0)}c(J,"parse");const ne={getCurrentDirectory:c(()=>i.sys.getCurrentDirectory(),"getCurrentDirectory"),getNewLine:c(()=>i.sys.newLine,"getNewLine"),getCanonicalFileName:i.sys.useCaseSensitiveFileNames?n=>n:n=>n.toLowerCase()},nn={declaration:!0,noEmit:!1,emitDeclarationOnly:!0,noEmitOnError:!0,checkJs:!1,declarationMap:!1,skipLibCheck:!0,preserveSymlinks:!0,target:i.ScriptTarget.ESNext,resolveJsonModule:!0},W=new Map,U=c((...n)=>process.env.DTS_LOG_CACHE?console.log("[cache]",...n):null,"logCache");function ke([n,e],t){for(U(n),W.set(n,t);n!==e&&n!==T.dirname(n);){if(n=T.dirname(n),U("up",n),W.has(n))return U("has",n);W.set(n,t)}}c(ke,"cacheConfig");function re(n,e,t,r){const s={...nn,...e,...r===!0&&{declarationMap:!0}};let o=T.dirname(n),a=[];const l=t||o;if(W.has(l))U("HIT",l);else{U("miss",l);const h=t?T.resolve(process.cwd(),t):i.findConfigFile(o,i.sys.fileExists);if(!h)return{dtsFiles:a,dirName:o,compilerOptions:s};const u=o;o=T.dirname(h);const{config:g,error:x}=i.readConfigFile(h,i.sys.readFile);if(x)return console.error(i.formatDiagnostic(x,ne)),{dtsFiles:a,dirName:o,compilerOptions:s};U("tsconfig",g);const S=i.parseJsonConfigFileContent(g,i.sys,o);ke(t?[t,t]:[u,o],S)}const{fileNames:m,options:p,errors:d}=W.get(l);return a=m.filter(h=>j.test(h)),d.length?(console.error(i.formatDiagnostics(d,ne)),{dtsFiles:a,dirName:o,compilerOptions:s}):{dtsFiles:a,dirName:o,compilerOptions:{...p,...s}}}c(re,"getCompilerOptions");function rn(n,e,t,r){const{dtsFiles:s,compilerOptions:o}=re(n,e,t,r);return i.createProgram([n].concat(Array.from(s)),o,i.createCompilerHost(o,!0))}c(rn,"createProgram$1");function sn(n,e,t,r){const s=[],o=new Set;let a=[],l="",m={};for(let p of n){if(j.test(p))continue;p=T.resolve(p);const d=re(p,e,t,r);if(d.dtsFiles.forEach(o.add,o),!a.length){a.push(p),{dirName:l,compilerOptions:m}=d;continue}if(d.dirName===l)a.push(p);else{const h=i.createCompilerHost(m,!0),u=i.createProgram(a.concat(Array.from(o)),m,h);s.push(u),a=[p],{dirName:l,compilerOptions:m}=d}}if(a.length){const p=i.createCompilerHost(m,!0),d=i.createProgram(a.concat(Array.from(o)),m,p);s.push(d)}return s}c(sn,"createPrograms");function on(){let n;try{return{codeFrameColumns:n}=Ye("@babel/code-frame"),n}catch{try{return{codeFrameColumns:n}=Ze(import.meta.url)("@babel/code-frame"),n}catch{}}}c(on,"getCodeFrame");function an(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}}}c(an,"getLocation");function cn(n){const e=on(),r=n.getSourceFile().getFullText(),s=an(n);return e?`
4
+ `+e(r,s,{highlightCode:!0}):`
5
+ ${s.start.line}:${s.start.column}: \`${n.getFullText().trim()}\``}c(cn,"frameNode");class w extends Error{static{c(this,"UnsupportedSyntaxError")}constructor(e,t="Syntax not yet supported"){super(`${t}
6
+ ${cn(e)}`)}}class ln{static{c(this,"NamespaceFixer")}constructor(e){this.sourceFile=e}findNamespaces(){const e=[],t={};for(const r of this.sourceFile.statements){const s={start:r.getStart(),end:r.getEnd()};if(i.isEmptyStatement(r)){e.unshift({name:"",exports:[],location:s});continue}if((i.isImportDeclaration(r)||i.isExportDeclaration(r))&&r.moduleSpecifier&&i.isStringLiteral(r.moduleSpecifier)){const{text:d}=r.moduleSpecifier;if(d.startsWith(".")&&(d.endsWith(".d.ts")||d.endsWith(".d.cts")||d.endsWith(".d.mts"))){const h=r.moduleSpecifier.getStart()+1,u=r.moduleSpecifier.getEnd()-1;e.unshift({name:"",exports:[],location:{start:h,end:u},textBeforeCodeAfter:d.replace(/\.d\.ts$/,".js").replace(/\.d\.cts$/,".cjs").replace(/\.d\.mts$/,".mjs")})}}if(i.isModuleDeclaration(r)&&r.body&&i.isModuleBlock(r.body)){for(const d of r.body.statements)if(i.isExportDeclaration(d)&&d.exportClause){if(i.isNamespaceExport(d.exportClause))continue;for(const h of d.exportClause.elements)h.propertyName&&h.propertyName.getText()==h.name.getText()&&e.unshift({name:"",exports:[],location:{start:h.propertyName.getEnd(),end:h.name.getEnd()}})}}if(i.isClassDeclaration(r)?t[r.name.getText()]={type:"class",generics:r.typeParameters}:i.isFunctionDeclaration(r)?t[r.name.getText()]={type:"function"}:i.isInterfaceDeclaration(r)?t[r.name.getText()]={type:"interface",generics:r.typeParameters}:i.isTypeAliasDeclaration(r)?t[r.name.getText()]={type:"type",generics:r.typeParameters}:i.isModuleDeclaration(r)&&i.isIdentifier(r.name)?t[r.name.getText()]={type:"namespace"}:i.isEnumDeclaration(r)&&(t[r.name.getText()]={type:"enum"}),!i.isVariableStatement(r))continue;const{declarations:o}=r.declarationList;if(o.length!==1)continue;const a=o[0],l=a.name.getText();if(!a.initializer||!i.isCallExpression(a.initializer)){t[l]={type:"var"};continue}const m=a.initializer.arguments[0];if(!a.initializer.expression.getFullText().includes("/*#__PURE__*/Object.freeze")||!i.isObjectLiteralExpression(m))continue;const p=[];for(const d of m.properties){if(!i.isPropertyAssignment(d)||!(i.isIdentifier(d.name)||i.isStringLiteral(d.name))||d.name.text!=="__proto__"&&!i.isIdentifier(d.initializer))throw new w(d,"Expected a property assignment");d.name.text!=="__proto__"&&p.push({exportedName:d.name.text,localName:d.initializer.getText()})}e.unshift({name:l,exports:p,location:s})}return{namespaces:e,itemTypes:t}}fix(){let e=this.sourceFile.getFullText();const{namespaces:t,itemTypes:r}=this.findNamespaces();for(const s of t){const o=e.slice(s.location.end);e=e.slice(0,s.location.start);for(const{exportedName:a,localName:l}of s.exports)if(a===l){const{type:m,generics:p}=r[l]||{};if(m==="interface"||m==="type"){const d=je(p);e+=`type ${s.name}_${a}${d.in} = ${l}${d.out};
7
+ `}else if(m==="enum"||m==="class"){const d=je(p);e+=`type ${s.name}_${a}${d.in} = ${l}${d.out};
8
+ `,e+=`declare const ${s.name}_${a}: typeof ${l};
9
+ `}else m==="namespace"?e+=`import ${s.name}_${a} = ${l};
10
+ `:e+=`declare const ${s.name}_${a}: typeof ${l};
11
+ `}if(s.name){e+=`declare namespace ${s.name} {
12
+ `,e+=` export {
13
+ `;for(const{exportedName:a,localName:l}of s.exports)a===l?e+=` ${s.name}_${a} as ${a},
14
+ `:e+=` ${l} as ${a},
15
+ `;e+=` };
16
+ `,e+="}"}e+=s.textBeforeCodeAfter??"",e+=o}return e}}function je(n){return!n||!n.length?{in:"",out:""}:{in:`<${n.map(e=>e.getText()).join(", ")}>`,out:`<${n.map(e=>e.name.getText()).join(", ")}>`}}c(je,"renderTypeParams");let Ue=1;function un(n){return I({type:"Program",sourceType:"module",body:[]},{start:n.getFullStart(),end:n.getEnd()})}c(un,"createProgram");function pn(n){const e={type:"Identifier",name:String(Ue++)};return{ident:e,expr:{type:"AssignmentPattern",left:e,right:n}}}c(pn,"createReference");function M(n){return I({type:"Identifier",name:n.getText()},n)}c(M,"createIdentifier");function fn(n){const e=I({type:"FunctionExpression",id:null,params:[],body:{type:"BlockStatement",body:[]}},n),t=I({type:"ExpressionStatement",expression:{type:"CallExpression",callee:{type:"Identifier",name:String(Ue++)},arguments:[e],optional:!1}},n);return{fn:e,iife:t}}c(fn,"createIIFE");function mn(){const n={type:"ArrayExpression",elements:[]};return{expr:n,stmt:{type:"ReturnStatement",argument:n}}}c(mn,"createReturn");function dn(n,e){return I({type:"FunctionDeclaration",id:I({type:"Identifier",name:i.idText(n)},n),params:[],body:{type:"BlockStatement",body:[]}},e)}c(dn,"createDeclaration");function A(n){if(i.isLiteralExpression(n))return{type:"Literal",value:n.text};if(i.isPropertyAccessExpression(n)){if(i.isPrivateIdentifier(n.name))throw new w(n.name);return I({type:"MemberExpression",computed:!1,optional:!1,object:A(n.expression),property:A(n.name)},{start:n.expression.getStart(),end:n.name.getEnd()})}if(i.isObjectLiteralExpression(n))return I({type:"ObjectExpression",properties:n.properties.map(e=>{if(i.isPropertyAssignment(e))return I({type:"Property",key:i.isIdentifier(e.name)?M(e.name):A(e.name),value:A(e.initializer),kind:"init",method:!1,shorthand:!1,computed:i.isComputedPropertyName(e.name)},e);if(i.isShorthandPropertyAssignment(e))return I({type:"Property",key:M(e.name),value:M(e.name),kind:"init",method:!1,shorthand:!0,computed:!1},e);throw new w(e,"Unsupported property type in object literal")})},n);if(i.isArrayLiteralExpression(n))return I({type:"ArrayExpression",elements:n.elements.map(e=>{if(i.isExpression(e))return A(e);throw new w(e,"Unsupported element type in array literal")})},n);if(i.isIdentifier(n))return M(n);if(n.kind==i.SyntaxKind.NullKeyword)return{type:"Literal",value:null};throw new w(n)}c(A,"convertExpression");function I(n,e){const t="start"in e?e:{start:e.getStart(),end:e.getEnd()};return Object.assign(n,t)}c(I,"withStartEnd");function G(n,e){return(i.getCombinedModifierFlags(n)&e)===e}c(G,"matchesModifier");class hn{static{c(this,"LanguageService")}constructor(e){this.fileName="index.d.ts";const t={getCompilationSettings:c(()=>({noEmit:!0,noResolve:!0,skipLibCheck:!0,declaration:!1,checkJs:!1,declarationMap:!1,target:i.ScriptTarget.ESNext}),"getCompilationSettings"),getScriptFileNames:c(()=>[this.fileName],"getScriptFileNames"),getScriptVersion:c(()=>"1","getScriptVersion"),getScriptSnapshot:c(r=>r===this.fileName?i.ScriptSnapshot.fromString(e):void 0,"getScriptSnapshot"),getCurrentDirectory:c(()=>"","getCurrentDirectory"),getDefaultLibFileName:c(()=>"","getDefaultLibFileName"),fileExists:c(r=>r===this.fileName,"fileExists"),readFile:c(r=>r===this.fileName?e:void 0,"readFile")};this.service=i.createLanguageService(t,i.createDocumentRegistry(void 0,""),i.LanguageServiceMode.PartialSemantic)}findReferenceCount(e){const t=this.service.findReferences(this.fileName,e.getStart());return t?.length?t.reduce((r,s)=>r+s.references.length,0):0}}class gn{static{c(this,"TypeOnlyFixer")}constructor(e,t){this.DEBUG=!!process.env.DTS_EXPORTS_FIXER_DEBUG,this.types=new Set,this.values=new Set,this.typeHints=new Map,this.reExportTypeHints=new Map,this.importNodes=[],this.exportNodes=[],this.rawCode=t,this.source=J(e,t),this.code=new X(t)}fix(){return this.analyze(this.source.statements),(this.typeHints.size||this.reExportTypeHints.size)&&(this.service=new hn(this.rawCode),this.importNodes.forEach(e=>this.fixTypeOnlyImport(e))),this.types.size&&this.exportNodes.forEach(e=>this.fixTypeOnlyExport(e)),this.types.size?{magicCode:this.code}:{code:this.rawCode,map:null}}fixTypeOnlyImport(e){let t=!1;const r=[],s=[],o=e.moduleSpecifier.getText(),a=e.importClause.name,l=e.importClause.namedBindings;if(a){const m=a.text;this.isTypeOnly(m)?this.isUselessImport(a)?t=!0:r.push(`import type ${m} from ${o};`):s.push(`import ${m} from ${o};`)}if(l&&i.isNamespaceImport(l)){const m=l.name.text;this.isTypeOnly(m)?this.isUselessImport(l.name)?t=!0:r.push(`import type * as ${m} from ${o};`):s.push(`import * as ${m} from ${o};`)}if(l&&i.isNamedImports(l)){const m=[],p=[];for(const d of l.elements)this.isTypeOnly(d.name.text)?this.isUselessImport(d.name)?t=!0:m.push(d.getText()):p.push(d.getText());m.length&&r.push(`import type { ${m.join(", ")} } from ${o};`),p.length&&s.push(`import { ${p.join(", ")} } from ${o};`)}(r.length||t)&&this.code.overwrite(e.getStart(),e.getEnd(),[...s,...r].join(`
17
+ ${Ke(e)}`))}fixTypeOnlyExport(e){const t=[],r=[],s=e.moduleSpecifier?.getText();if(i.isNamespaceExport(e.exportClause)){const o=e.exportClause.name.text;this.isReExportTypeOnly(o)?t.push(`export type * as ${o} from ${s};`):r.push(`export * as ${o} from ${s};`)}if(i.isNamedExports(e.exportClause)){const o=[],a=[];for(const l of e.exportClause.elements){const m=l.propertyName?.text||l.name.text;(e.moduleSpecifier?this.isReExportTypeOnly(l.name.text):this.isTypeOnly(m))?o.push(l.getText()):a.push(l.getText())}o.length&&t.push(`export type { ${o.join(", ")} }${s?` from ${s}`:""};`),a.length&&r.push(`export { ${a.join(", ")} }${s?` from ${s}`:""};`)}t.length&&this.code.overwrite(e.getStart(),e.getEnd(),[...r,...t].join(`
18
+ ${Ke(e)}`))}analyze(e){for(const t of e){if(this.DEBUG&&console.log(t.getText(),t.kind),i.isImportDeclaration(t)&&t.importClause){this.importNodes.push(t);continue}if(i.isExportDeclaration(t)&&t.exportClause){this.exportNodes.push(t);continue}if(i.isInterfaceDeclaration(t)){this.DEBUG&&console.log(`${t.name.getFullText()} is a type`),this.types.add(t.name.text);continue}if(i.isTypeAliasDeclaration(t)){const r=t.name.text;this.DEBUG&&console.log(`${t.name.getFullText()} is a type`),this.types.add(r);continue}if(i.isEnumDeclaration(t)||i.isFunctionDeclaration(t)||i.isClassDeclaration(t)||i.isVariableStatement(t)){if(i.isVariableStatement(t))for(const r of t.declarationList.declarations)i.isIdentifier(r.name)&&(this.DEBUG&&console.log(`${r.name.getFullText()} is a value (from var statement)`),this.values.add(r.name.text));else t.name&&(this.DEBUG&&console.log(`${t.name.getFullText()} is a value (from declaration)`),this.values.add(t.name.text));continue}if(i.isModuleBlock(t)){this.analyze(t.statements);continue}if(i.isModuleDeclaration(t)){t.name&&i.isIdentifier(t.name)&&(this.DEBUG&&console.log(`${t.name.getFullText()} is a value (from module declaration)`),this.values.add(t.name.text)),this.analyze(t.getChildren());continue}this.DEBUG&&console.log("unhandled statement",t.getFullText(),t.kind)}}isUselessImport(e){const t=this.service.findReferenceCount(e),r=this.typeHints.get(e.text);return r&&r+1>=t}isTypeOnly(e){return this.typeHints.has(e)||this.types.has(e)&&!this.values.has(e)}isReExportTypeOnly(e){return this.reExportTypeHints.has(e)}}function Ke(n){const e=n.getFullText().match(/^(?:\n*)([ ]*)/);return" ".repeat(e?.[1]?.length||0)}c(Ke,"getNodeIndent");function ze(n,e,t){for(const r of n.statements)se(e,r),i.isModuleDeclaration(r)&&r.body&&i.isModuleBlock(r.body)&&ze(r.body,e)}c(ze,"preProcessNamespaceBody");function yn({sourceFile:n,isEntry:e,isJSON:t}){const r=new X(n.getFullText()),s=!e&&xn(n),o=new Set,a=new Set;let l="";const m=new Map,p=new Map;for(const f of n.statements){if(i.isEmptyStatement(f)){r.remove(f.getStart(),f.getEnd());continue}if(i.isImportDeclaration(f)){if(!f.importClause)continue;f.importClause.name&&o.add(f.importClause.name.text),f.importClause.namedBindings&&(i.isNamespaceImport(f.importClause.namedBindings)?o.add(f.importClause.namedBindings.name.text):f.importClause.namedBindings.elements.forEach(y=>o.add(y.name.text)))}else if(i.isEnumDeclaration(f)||i.isFunctionDeclaration(f)||i.isInterfaceDeclaration(f)||i.isClassDeclaration(f)||i.isTypeAliasDeclaration(f)||i.isModuleDeclaration(f)){if(f.name){const y=f.name.getText();o.add(y),G(f,i.ModifierFlags.ExportDefault)?l=y:(s&&i.isIdentifier(f.name)||G(f,i.ModifierFlags.Export))&&a.add(y),f.flags&i.NodeFlags.GlobalAugmentation||P(y,[ie(f),Ve(f)])}i.isModuleDeclaration(f)&&(f.body&&i.isModuleBlock(f.body)&&ze(f.body,r),Sn(r,f)),se(r,f)}else if(i.isVariableStatement(f)){const{declarations:y}=f.declarationList,v=G(f,i.ModifierFlags.Export);for(const F of f.declarationList.declarations)if(i.isIdentifier(F.name)){const R=F.name.getText();o.add(R),(s||v)&&a.add(R)}if(se(r,f),y.length===1){const F=y[0];i.isIdentifier(F.name)&&P(F.name.getText(),[ie(f),Ve(f)])}else{const F=y.slice(),R=F.shift();P(R.name.getText(),[ie(f),R.getEnd()]);for(const B of F)i.isIdentifier(B.name)&&P(B.name.getText(),[B.getFullStart(),B.getEnd()])}const{flags:C}=f.declarationList,L=`declare ${C&i.NodeFlags.Let?"let":C&i.NodeFlags.Const?"const":"var"} `,$=f.declarationList.getChildren().find(F=>F.kind===i.SyntaxKind.SyntaxList).getChildren();let _=0;for(const F of $)if(F.kind===i.SyntaxKind.CommaToken)_=F.getStart(),r.remove(_,F.getEnd());else if(_){r.appendLeft(_,`;
19
+ `);const R=F.getFullStart(),B=r.slice(R,F.getStart()),ae=B.length-B.trimStart().length;ae?r.overwrite(R,R+ae,L):r.appendLeft(R,L)}}}for(const f of n.statements){if(N(f),i.isExportAssignment(f)&&!f.isExportEquals&&(i.isObjectLiteralExpression(f.expression)||i.isArrayLiteralExpression(f.expression))){l||(l=b("export_default")),r.overwrite(f.getStart(),f.expression.getStart(),`declare var ${l} = `);continue}if(G(f,i.ModifierFlags.ExportDefault)&&(i.isFunctionDeclaration(f)||i.isClassDeclaration(f))){if(f.name)continue;l||(l=b("export_default"));const y=f.getChildren(),v=y.findIndex($=>$.kind===i.SyntaxKind.ClassKeyword||$.kind===i.SyntaxKind.FunctionKeyword),C=y[v],O=y[v+1];if(O.kind>=i.SyntaxKind.FirstPunctuation&&O.kind<=i.SyntaxKind.LastPunctuation){const $=r.slice(C.getEnd(),O.getStart())!=" ";r.appendLeft(O.getStart(),`${$?" ":""}${l}`)}else r.appendRight(C.getEnd(),` ${l}`)}}for(const f of p.values()){const v=f.pop()[0];for(const C of f)r.move(C[0],C[1],v)}l&&r.append(`
20
+ export default ${l};
21
+ `),a.size&&r.append(`
22
+ export { ${[...a].join(", ")} };
23
+ `),t&&a.size&&(l=b("export_default"),r.append([`
24
+ declare const ${l}: {`,[...a].map(f=>` ${f}: typeof ${f};`).join(`
25
+ `),"};",`export default ${l};
26
+ `].join(`
27
+ `)));for(const[f,y]of m.entries())r.prepend(`import * as ${y} from "${f}";
28
+ `);const d=n.getLineStarts(),h=new Set;for(const f of n.typeReferenceDirectives){h.add(f.fileName);const{line:y}=n.getLineAndCharacterOfPosition(f.pos),v=d[y];let C=n.getLineEndOfPosition(f.pos);r.slice(C,C+1)===`
29
+ `&&(C+=1),r.remove(v,C)}const u=new Set;for(const f of n.referencedFiles){u.add(f.fileName);const{line:y}=n.getLineAndCharacterOfPosition(f.pos),v=d[y];let C=n.getLineEndOfPosition(f.pos);r.slice(C,C+1)===`
30
+ `&&(C+=1),r.remove(v,C)}const g=n.getFullText(),x=i.getLeadingCommentRanges(g,n.endOfFileToken.getFullStart()),S=n.statements[n.statements.length-1],E=S?i.getTrailingCommentRanges(g,S.getEnd()):void 0;for(const f of[...x??[],...E??[]]){if(f.kind!==i.SyntaxKind.SingleLineCommentTrivia)continue;const y=g.slice(f.pos,f.end);if(!/\/\/[#@]\s*sourceMappingURL=/.test(y))continue;let v=f.pos;v>0&&g[v-1]===`
31
+ `&&(v-=1),r.remove(v,f.end);break}return{code:r,typeReferences:h,fileReferences:u};function N(f){if(i.forEachChild(f,N),i.isImportTypeNode(f)){if(!i.isLiteralTypeNode(f.argument)||!i.isStringLiteral(f.argument.literal))throw new w(f,"inline imports should have a literal argument");const y=f.argument.literal.text,v=f.getChildren(),C=v.find(_=>_.kind===i.SyntaxKind.ImportKeyword).getStart();let O=f.getEnd();const L=v.find(_=>_.kind===i.SyntaxKind.DotToken||_.kind===i.SyntaxKind.LessThanToken);L&&(O=L.getStart());const $=D(y);r.overwrite(C,O,$)}}function D(f){let y=m.get(f);return y||(y=b(vn(f)),m.set(f,y)),y}function b(f){let y=f;for(;o.has(y);)y=`_${y}`;return o.add(y),y}function P(f,y){let v=p.get(f);if(!v)v=[y],p.set(f,v);else{const C=v[v.length-1];C[1]===y[0]?C[1]=y[1]:v.push(y)}}}c(yn,"preProcess");function xn(n){let e=!1;for(const t of n.statements){if(i.isExportDeclaration(t)||i.isExportAssignment(t))return!1;(e||i.isImportDeclaration(t)||G(t,i.ModifierFlags.Export))&&(e=!0)}return e}c(xn,"isGlobalModule");function se(n,e){if(!i.canHaveModifiers(e))return;if(e.parent.kind===i.SyntaxKind.SourceFile){let r=!1;const s=i.isEnumDeclaration(e)||i.isClassDeclaration(e)||i.isFunctionDeclaration(e)||i.isModuleDeclaration(e)||i.isVariableStatement(e);for(const o of e.modifiers??[])switch(o.kind){case i.SyntaxKind.ExportKeyword:case i.SyntaxKind.DefaultKeyword:n.remove(o.getStart(),o.getEnd()+1);break;case i.SyntaxKind.DeclareKeyword:r=!0}s&&!r&&n.appendRight(e.getStart(),"declare ")}}c(se,"fixModifiers");function Sn(n,e){if(!(!e.body||!i.isModuleBlock(e.body))){for(const t of e.body.statements)if(i.isExportDeclaration(t)&&t.exportClause){if(i.isNamespaceExport(t.exportClause))continue;for(const r of t.exportClause.elements)r.propertyName||n.appendLeft(r.name.getEnd(),` as ${r.name.getText()}`)}}}c(Sn,"duplicateExports");function vn(n){return n.replace(/[^a-zA-Z0-9_$]/g,()=>"_")}c(vn,"getSafeName");function ie(n){const e=n.getFullStart();return e+(Je(n,e)?1:0)}c(ie,"getStart");function Ve(n){const e=n.getEnd();return e+(Je(n,e)?1:0)}c(Ve,"getEnd");function Je(n,e){return n.getSourceFile().getFullText()[e]===`
32
+ `}c(Je,"newlineAt");const En=new Set([i.SyntaxKind.LiteralType,i.SyntaxKind.VoidKeyword,i.SyntaxKind.UnknownKeyword,i.SyntaxKind.AnyKeyword,i.SyntaxKind.BooleanKeyword,i.SyntaxKind.NumberKeyword,i.SyntaxKind.StringKeyword,i.SyntaxKind.ObjectKeyword,i.SyntaxKind.NullKeyword,i.SyntaxKind.UndefinedKeyword,i.SyntaxKind.SymbolKeyword,i.SyntaxKind.NeverKeyword,i.SyntaxKind.ThisKeyword,i.SyntaxKind.ThisType,i.SyntaxKind.BigIntKeyword]);class We{static{c(this,"DeclarationScope")}constructor({id:e,range:t}){if(this.scopes=[],e)this.declaration=dn(e,t);else{const{iife:s,fn:o}=fn(t);this.iife=s,this.declaration=o}const r=mn();this.declaration.body.body.push(r.stmt),this.returnExpr=r.expr}pushScope(){this.scopes.push(new Set)}popScope(e=1){for(let t=0;t<e;t++)this.scopes.pop()}pushTypeVariable(e){const t=e.getText();this.scopes[this.scopes.length-1]?.add(t)}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 o of this.scopes)if(o.has(t))return}if(t==="this")return;const{ident:r,expr:s}=pn(e);this.declaration.params.push(s),this.returnExpr.elements.push(r)}pushIdentifierReference(e){this.pushReference(M(e))}convertEntityName(e){return i.isIdentifier(e)?M(e):I({type:"MemberExpression",computed:!1,optional:!1,object:this.convertEntityName(e.left),property:M(e.right)},e)}convertPropertyAccess(e){if(!i.isIdentifier(e.expression)&&!i.isPropertyAccessExpression(e.expression))throw new w(e.expression);if(i.isPrivateIdentifier(e.name))throw new w(e.name);const t=i.isIdentifier(e.expression)?M(e.expression):this.convertPropertyAccess(e.expression);return I({type:"MemberExpression",computed:!1,optional:!1,object:t,property:M(e.name)},e)}convertComputedPropertyName(e){if(!e.name||!i.isComputedPropertyName(e.name))return;const{expression:t}=e.name;if(!(i.isLiteralExpression(t)||i.isPrefixUnaryExpression(t))){if(i.isIdentifier(t))return this.pushReference(M(t));if(i.isPropertyAccessExpression(t))return this.pushReference(this.convertPropertyAccess(t));throw new w(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(A(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(i.isPropertyDeclaration(t)||i.isPropertySignature(t)||i.isIndexSignatureDeclaration(t)){i.isPropertyDeclaration(t)&&t.initializer&&i.isPropertyAccessExpression(t.initializer)&&this.pushReference(this.convertPropertyAccess(t.initializer)),this.convertComputedPropertyName(t),this.convertTypeNode(t.type);continue}if(i.isMethodDeclaration(t)||i.isMethodSignature(t)||i.isConstructorDeclaration(t)||i.isConstructSignatureDeclaration(t)||i.isCallSignatureDeclaration(t)||i.isGetAccessorDeclaration(t)||i.isSetAccessorDeclaration(t))this.convertParametersAndType(t);else throw new w(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&&!En.has(e.kind)){if(i.isTypeReferenceNode(e)){this.pushReference(this.convertEntityName(e.typeName)),this.convertTypeArguments(e);return}if(i.isTypeLiteralNode(e)){this.convertMembers(e.members);return}if(i.isArrayTypeNode(e)){this.convertTypeNode(e.elementType);return}if(i.isTupleTypeNode(e)){for(const t of e.elements)this.convertTypeNode(t);return}if(i.isNamedTupleMember(e)||i.isParenthesizedTypeNode(e)||i.isTypeOperatorNode(e)||i.isTypePredicateNode(e)){this.convertTypeNode(e.type);return}if(i.isUnionTypeNode(e)||i.isIntersectionTypeNode(e)){for(const t of e.types)this.convertTypeNode(t);return}if(i.isMappedTypeNode(e)){const{typeParameter:t,type:r,nameType:s}=e;this.convertTypeNode(t.constraint),this.pushScope(),this.pushTypeVariable(t.name),this.convertTypeNode(r),s&&this.convertTypeNode(s),this.popScope();return}if(i.isConditionalTypeNode(e)){this.convertTypeNode(e.checkType),this.pushScope(),this.convertTypeNode(e.extendsType),this.convertTypeNode(e.trueType),this.convertTypeNode(e.falseType),this.popScope();return}if(i.isIndexedAccessTypeNode(e)){this.convertTypeNode(e.objectType),this.convertTypeNode(e.indexType);return}if(i.isFunctionOrConstructorTypeNode(e)){this.convertParametersAndType(e);return}if(i.isTypeQueryNode(e)){const t=this.convertEntityName(e.exprName);this.pushReference(t),this.convertTypeArguments(e);return}if(i.isRestTypeNode(e)){this.convertTypeNode(e.type);return}if(i.isOptionalTypeNode(e)){this.convertTypeNode(e.type);return}if(i.isTemplateLiteralTypeNode(e)){for(const t of e.templateSpans)this.convertTypeNode(t.type);return}if(i.isInferTypeNode(e)){const{typeParameter:t}=e;this.convertTypeNode(t.constraint),this.pushTypeVariable(t.name);return}else throw new w(e)}}convertNamespace(e,t=!1){if(this.pushScope(),t&&e.body&&i.isModuleDeclaration(e.body)){this.convertNamespace(e.body,!0);return}if(!e.body||!i.isModuleBlock(e.body))throw new w(e,'namespace must have a "ModuleBlock" body.');const{statements:r}=e.body;for(const s of r){if(i.isEnumDeclaration(s)||i.isFunctionDeclaration(s)||i.isClassDeclaration(s)||i.isInterfaceDeclaration(s)||i.isTypeAliasDeclaration(s)||i.isModuleDeclaration(s)){if(s.name&&i.isIdentifier(s.name))this.pushTypeVariable(s.name);else throw new w(s,"non-Identifier name not supported");continue}if(i.isVariableStatement(s)){for(const o of s.declarationList.declarations)if(i.isIdentifier(o.name))this.pushTypeVariable(o.name);else throw new w(o,"non-Identifier name not supported");continue}if(i.isImportDeclaration(s)){if(s.importClause&&(s.importClause.name&&this.pushTypeVariable(s.importClause.name),s.importClause.namedBindings))if(i.isNamespaceImport(s.importClause.namedBindings))this.pushTypeVariable(s.importClause.namedBindings.name);else for(const o of s.importClause.namedBindings.elements)this.pushTypeVariable(o.name);continue}if(i.isImportEqualsDeclaration(s)){this.pushTypeVariable(s.name);continue}if(!i.isExportDeclaration(s))throw new w(s,"namespace child (hoisting) not supported yet")}for(const s of r){if(i.isVariableStatement(s)){for(const o of s.declarationList.declarations)o.type&&this.convertTypeNode(o.type);continue}if(i.isFunctionDeclaration(s)){this.convertParametersAndType(s);continue}if(i.isInterfaceDeclaration(s)||i.isClassDeclaration(s)){const o=this.convertTypeParameters(s.typeParameters);this.convertHeritageClauses(s),this.convertMembers(s.members),this.popScope(o);continue}if(i.isTypeAliasDeclaration(s)){const o=this.convertTypeParameters(s.typeParameters);this.convertTypeNode(s.type),this.popScope(o);continue}if(i.isModuleDeclaration(s)){this.convertNamespace(s,t);continue}if(!i.isEnumDeclaration(s)&&!i.isImportDeclaration(s)){if(i.isImportEqualsDeclaration(s)){i.isEntityName(s.moduleReference)&&this.pushReference(this.convertEntityName(s.moduleReference));continue}if(i.isExportDeclaration(s)){if(s.exportClause){if(i.isNamespaceExport(s.exportClause))throw new w(s.exportClause);for(const o of s.exportClause.elements){const a=o.propertyName||o.name;this.pushIdentifierReference(a)}}}else throw new w(s,"namespace child (walking) not supported yet")}}this.popScope()}}function Tn({sourceFile:n}){return new Nn(n).transform()}c(Tn,"convert");class Nn{static{c(this,"Transformer")}constructor(e){this.sourceFile=e,this.declarations=new Map,this.ast=un(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 l=new We({range:r});return this.pushStatement(l.iife),l}const s=t.getText(),o=new We({id:t,range:r}),a=this.declarations.get(s);if(a){a.pushIdentifierReference(t),a.declaration.end=r.end;const l=this.ast.body.findIndex(m=>m==a.declaration);for(let m=l+1;m<this.ast.body.length;m++){const p=this.ast.body[m];p.start=p.end=r.end}}else this.pushStatement(o.declaration),this.declarations.set(s,o);return a||o}convertStatement(e){if(i.isEnumDeclaration(e))return this.convertEnumDeclaration(e);if(i.isFunctionDeclaration(e))return this.convertFunctionDeclaration(e);if(i.isInterfaceDeclaration(e)||i.isClassDeclaration(e))return this.convertClassOrInterfaceDeclaration(e);if(i.isTypeAliasDeclaration(e))return this.convertTypeAliasDeclaration(e);if(i.isVariableStatement(e))return this.convertVariableStatement(e);if(i.isExportDeclaration(e)||i.isExportAssignment(e))return this.convertExportDeclaration(e);if(i.isModuleDeclaration(e))return this.convertNamespaceDeclaration(e);if(e.kind===i.SyntaxKind.NamespaceExportDeclaration)return this.removeStatement(e);if(i.isImportDeclaration(e)||i.isImportEqualsDeclaration(e))return this.convertImportDeclaration(e);throw new w(e)}removeStatement(e){this.pushStatement(I({type:"ExpressionStatement",expression:{type:"Literal",value:"pls remove me"}},e))}convertNamespaceDeclaration(e){if(e.flags&i.NodeFlags.GlobalAugmentation||!i.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 w(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 w(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 w(e,"VariableStatement with more than one declaration not yet supported");for(const r of t){if(!i.isIdentifier(r.name))throw new w(e,"VariableDeclaration must have a name");const s=this.createDeclaration(e,r.name);s.convertTypeNode(r.type),r.initializer&&this.trackExpressionReferences(r.initializer,s)}}trackExpressionReferences(e,t){if(i.isIdentifier(e))t.pushIdentifierReference(e);else if(i.isObjectLiteralExpression(e))for(const r of e.properties)i.isShorthandPropertyAssignment(r)?t.pushIdentifierReference(r.name):i.isPropertyAssignment(r)&&this.trackExpressionReferences(r.initializer,t);else if(i.isArrayLiteralExpression(e))for(const r of e.elements)i.isExpression(r)&&this.trackExpressionReferences(r,t);else i.isPropertyAccessExpression(e)&&this.trackExpressionReferences(e.expression,t)}convertExportDeclaration(e){if(i.isExportAssignment(e)){this.pushStatement(I({type:"ExportDefaultDeclaration",declaration:A(e.expression)},e));return}const t=e.moduleSpecifier?A(e.moduleSpecifier):void 0;if(!e.exportClause)this.pushStatement(I({type:"ExportAllDeclaration",source:t,exported:null,attributes:[]},e));else if(i.isNamespaceExport(e.exportClause))this.pushStatement(I({type:"ExportAllDeclaration",source:t,exported:M(e.exportClause.name),attributes:[]},e));else{const r=[];for(const s of e.exportClause.elements)r.push(this.convertExportSpecifier(s));this.pushStatement(I({type:"ExportNamedDeclaration",declaration:null,specifiers:r,source:t,attributes:[]},e))}}convertImportDeclaration(e){if(i.isImportEqualsDeclaration(e)){if(i.isEntityName(e.moduleReference)){const s=this.createDeclaration(e,e.name);s.pushReference(s.convertEntityName(e.moduleReference));return}if(!i.isExternalModuleReference(e.moduleReference))throw new w(e,"ImportEquals should have a literal source.");this.pushStatement(I({type:"ImportDeclaration",specifiers:[{type:"ImportDefaultSpecifier",local:M(e.name)}],source:A(e.moduleReference.expression),attributes:[]},e));return}const t=A(e.moduleSpecifier),r=e.importClause&&e.importClause.namedBindings?this.convertNamedImportBindings(e.importClause.namedBindings):[];e.importClause&&e.importClause.name&&r.push({type:"ImportDefaultSpecifier",local:M(e.importClause.name)}),this.pushStatement(I({type:"ImportDeclaration",specifiers:r,source:t,attributes:[]},e))}convertNamedImportBindings(e){return i.isNamedImports(e)?e.elements.map(t=>{const r=M(t.name),s=t.propertyName?M(t.propertyName):r;return{type:"ImportSpecifier",local:r,imported:s}}):[{type:"ImportNamespaceSpecifier",local:M(e.name)}]}convertExportSpecifier(e){const t=M(e.name);return{type:"ExportSpecifier",exported:t,local:e.propertyName?M(e.propertyName):t}}}class Cn{static{c(this,"RelativeModuleDeclarationFixer")}constructor(e,t,r,s){this.sourcemap=r,this.DEBUG=!!process.env.DTS_EXPORTS_FIXER_DEBUG,this.relativeModuleDeclarations=[],this.source=J(e,t.toString()),this.code=t,this.name=s||"./index"}fix(){this.analyze(this.source.statements);for(const e of this.relativeModuleDeclarations){const t=e.getStart(),r=e.getEnd(),s=e.name.kind===i.SyntaxKind.StringLiteral&&"singleQuote"in e.name&&e.name.singleQuote?"'":'"',o=`declare module ${s}${this.name}${s} ${e.body.getText()}`;this.code.overwrite(t,r,o)}return{code:this.code.toString(),map:this.relativeModuleDeclarations.length&&this.sourcemap?this.code.generateMap():null}}analyze(e){for(const t of e)i.isModuleDeclaration(t)&&t.body&&i.isModuleBlock(t.body)&&/^\.\.?\//.test(t.name.text)&&(this.DEBUG&&console.log(`Found relative module declaration: ${t.name.text} in ${this.source.fileName}`),this.relativeModuleDeclarations.push(t))}}function wn(n,e,t){const r=Q(n),s=Q(e.mappings),o=t.split(`
33
+ `),a=[];for(let l=0;l<r.length;l+=1){const m=r[l];if(!m||m.length===0){a.push([]);continue}const p=m.find(D=>D.length>=4);if(!p){a.push(m);continue}const[,d,h]=p;if(d!==0||h===void 0||h<0||h>=s.length){a.push(m);continue}const u=s[h];if(!u||u.length===0){a.push(m);continue}const g=p[0],x=p.length>=4?p[3]:0,S=g-(x??0),E=o[l]||"",N=[];for(const D of u){const b=D[0]+S;b<0||b>E.length||(D.length===5?N.push([b,D[1],D[2],D[3],D[4]]):D.length===4?N.push([b,D[1],D[2],D[3]]):N.push([b]))}N.sort((D,b)=>D[0]-b[0]),a.push(N)}return ge(a)}c(wn,"hydrateSourcemap");async function Dn(n){const{fileName:e,originalCode:t,inputMapText:r}=n;if(r)try{return JSON.parse(r)}catch{return null}const s=_e.fromSource(t);if(s)return s.toObject();const o=c(async a=>{const l=a.split(/[?#]/)[0],m=T.resolve(T.dirname(e),l);return ce.readFile(m,"utf8")},"readMap");try{const a=await _e.fromMapFileSource(t,o);if(a)return a.toObject()}catch{}try{const a=await ce.readFile(e+".map","utf8");return JSON.parse(a)}catch{return null}}c(Dn,"loadInputSourcemap");const bn=c(n=>{const e=new Map,t=new Map,r=new Map;return{name:"dts-transform",buildStart(){e.clear(),t.clear(),r.clear()},options({onLog:s,...o}){return{...o,onLog(a,l,m){a==="warn"&&l.code==="CIRCULAR_DEPENDENCY"||(s?s(a,l,m):m(a,l))},treeshake:{moduleSideEffects:"no-external",propertyReadSideEffects:!0,unknownGlobalSideEffects:!1}}},outputOptions(s){return{...s,chunkFileNames:s.chunkFileNames||"[name]-[hash].d.ts",entryFileNames:s.entryFileNames||"[name].d.ts",format:"es",exports:"named",compact:!1,freeze:!0,interop:"esModule",generatedCode:Object.assign({symbols:!1},s.generatedCode),strict:!1}},transform(s,o,a){const l=te(o),m=this.getModuleIds(),p=Array.from(m).find(N=>te(N)===l),d=!!(p&&this.getModuleInfo(p)?.isEntry),h=!!(p&&ee.test(p)),u=s;let g=J(o,s);const x=yn({sourceFile:g,isEntry:d,isJSON:h});e.set(g.fileName,x.typeReferences),t.set(g.fileName,x.fileReferences),s=x.code.toString(),g=J(o,s);const S=Tn({sourceFile:g});if(process.env.DTS_DUMP_AST&&(console.log(o),console.log(s),console.log(JSON.stringify(S.ast.body,void 0,2))),!n)return{code:s,ast:S.ast};const E=x.code.generateMap({hires:!0,source:o});return j.test(o)&&r.set(o,{fileName:o,originalCode:u,inputMapText:a}),{code:s,ast:S.ast,map:E}},renderChunk(s,o,a){const l=J(o.fileName,s),m=new ln(l),p=new Set,d=new Set;for(const S of Object.keys(o.modules)){for(const E of e.get(S.split("\\").join("/"))||[])p.add(E);for(const E of t.get(S.split("\\").join("/"))||[])if(E.startsWith(".")){const N=T.join(T.dirname(S),E),D=a.file&&T.dirname(a.file)||o.facadeModuleId&&T.dirname(o.facadeModuleId)||".";let b=T.relative(D,N).split("\\").join("/");b[0]!=="."&&(b="./"+b),d.add(b)}else d.add(E)}let h=Ge(Array.from(d,S=>`/// <reference path="${S}" />`));h+=Ge(Array.from(p,S=>`/// <reference types="${S}" />`)),h+=m.fix(),h||(h+=`
34
+ export { };`);const g=new gn(o.fileName,h).fix();return new Cn(o.fileName,"magicCode"in g&&g.magicCode?g.magicCode:new X(h),!!a.sourcemap,"./"+T.basename(o.fileName,".d.ts")).fix()},async generateBundle(s,o){if(!s.sourcemap)return;const a=new Map,l=Array.from(r.entries()),m=await Promise.all(l.map(async([h,u])=>({fileName:h,inputMap:await Dn(u)}))),p=c(h=>/^[a-z][a-z0-9+.-]*:\/\//i.test(h),"isUrl");for(const{fileName:h,inputMap:u}of m)if(u&&u.sources){const g=T.dirname(h);let x;u.sourceRoot?x=p(u.sourceRoot)?u.sourceRoot:T.resolve(g,u.sourceRoot):x=g;const S=p(x);a.set(h,{version:u.version??3,sources:u.sources.map(E=>{if(E===null)return null;if(p(E))return E;if(S){const N=x.endsWith("/")?x:x+"/";return new URL(E,N).toString()}return T.isAbsolute(E)?E:T.resolve(x,E)}),mappings:u.mappings,names:u.names})}const d=s.dir||(s.file?T.dirname(s.file):process.cwd());for(const h of Object.values(o)){if(h.type!=="chunk"||!h.map)continue;const u=T.join(d,T.dirname(h.fileName)),g=c(y=>p(y)?y:(T.isAbsolute(y)?T.relative(u,y):y).replaceAll("\\","/"),"toRelativeSourcePath"),x=c(y=>y===null?null:g(y),"toRelativeSourcePathOrNull"),S=new Map;for(const y of h.map.sources){if(!y||p(y))continue;const v=T.resolve(u,y);let C=a.get(v);if(!C&&/\.[cm]?[tj]sx?$/.test(v)&&!v.endsWith(".d.ts")){const O=v.replace(/\.[cm]?[tj]sx?$/,".d.ts");C=a.get(O)}C&&S.set(v,C)}if(S.size===0){if(delete h.map.sourcesContent,h.map.sources.length===0&&h.facadeModuleId){const y=a.get(h.facadeModuleId);if(y&&y.sources.length>0){const v=y.sources.map(x);h.map.sources=v}}qe(o,h.fileName,{sources:h.map.sources.map(x),mappings:h.map.mappings,names:h.map.names||[]});continue}const N=h.map.sources.length===1&&S.size===1?Array.from(S.values())[0]:null,D=N&&N.sources.length===1;let b,P,f;if(D&&N)b=N.sources.map(x),P=wn(h.map.mappings,N,h.code),f=N.names||[];else{const y=new Set,v=Qt(h.map,C=>{const O=T.resolve(u,C);if(y.has(O))return null;y.add(O);const L=S.get(O);return L||null});b=v.sources.map(x),P=typeof v.mappings=="string"?v.mappings:"",f=v.names||[]}h.map.sources=b,delete h.map.sourcesContent,h.map.mappings=P,h.map.names=f,qe(o,h.fileName,{sources:b,mappings:P,names:f})}}}},"transform");function Ge(n){return n.length?n.join(`
35
+ `)+`
36
+ `:""}c(Ge,"writeBlock");function qe(n,e,t){const r=`${e}.map`,s=n[r];s&&s.type==="asset"&&(s.source=JSON.stringify({version:3,file:T.basename(e),...t}))}c(qe,"updateSourcemapAsset");const In=/\.([cm]ts|[tj]sx?)$/;function oe({entries:n,programs:e,resolvedOptions:t},r,s){const{compilerOptions:o,tsconfig:a}=t;if(!e.length&&j.test(r))return{code:s};const l=n.includes(r),m=e.find(p=>{if(l)return p.getRootFileNames().includes(r);{const d=p.getSourceFile(r);return d&&p.isSourceFileFromExternalLibrary(d)?!1:!!d}});if(m){const p=m.getSourceFile(r);return{code:p?.getFullText(),source:p,program:m}}else if(i.sys.fileExists(r)){if(e.length>0&&j.test(r)&&(t.includeExternal.length>0||t.respectExternal))return{code:s};const p=rn(r,o,a,t.sourcemap);e.push(p);const d=p.getSourceFile(r);return{code:d?.getFullText(),source:d,program:p}}else return null}c(oe,"getModule");const He=c((n={})=>{const e={entries:[],programs:[],resolvedOptions:tn(n)},t=bn(e.resolvedOptions.sourcemap);return{name:"dts",outputOptions:t.outputOptions,renderChunk:t.renderChunk,generateBundle:t.generateBundle,options(r){let{input:s=[]}=r;if(!Array.isArray(s))s=typeof s=="string"?[s]:Object.values(s);else if(s.length>1){r.input={};for(const o of s){let a=te(o);T.isAbsolute(o)?a=T.basename(a):a=T.normalize(a),r.input[a]=o}}return e.programs=sn(Object.values(s),e.resolvedOptions.compilerOptions,e.resolvedOptions.tsconfig,e.resolvedOptions.sourcemap),t.options.call(this,r)},transform(r,s){if(!In.test(s)&&!ee.test(s))return null;const o=c(p=>{if(p.program){const d=T.dirname(s);p.program.getSourceFiles().map(u=>u.fileName).filter(u=>u.startsWith(d)).forEach(this.addWatchFile)}},"watchFiles"),a=c(()=>{const p=oe(e,s,r);return p?(o(p),t.transform.call(this,p.code,s)):null},"handleDtsFile"),l=c(()=>{const p=Be(s),d=oe(e,p,r);return d?(o(d),t.transform.call(this,d.code,p)):null},"treatTsAsDts"),m=c(()=>{const p=oe(e,s,r);if(!p||!p.source||!p.program)return null;o(p);const d=Be(s);let h,u;const{emitSkipped:g,diagnostics:x}=p.program.emit(p.source,(E,N)=>{E.endsWith(".map")?u=N:h=N},void 0,!0,void 0,!0);if(g){const E=x.filter(N=>N.category===i.DiagnosticCategory.Error);E.length&&(console.error(i.formatDiagnostics(E,ne)),this.error("Failed to compile. Check the logs above."))}if(!h)return null;const S=h.replace(/\n?\/\/# sourceMappingURL=[^\n]+/,"");return t.transform.call(this,S,d,u)},"generateDts");return j.test(s)?a():ee.test(s)?m():l()??m()},resolveId(r,s){if(!s){e.entries.push(T.resolve(r));return}s=s.split("\\").join("/");let o=e.resolvedOptions.compilerOptions;if(e.resolvedOptions.tsconfig){const l=r.startsWith(".")?T.resolve(T.dirname(s),r):r;o=re(l,e.resolvedOptions.compilerOptions,e.resolvedOptions.tsconfig,e.resolvedOptions.sourcemap).compilerOptions}const{resolvedModule:a}=i.resolveModuleName(r,s,o,i.sys);if(a)return a.isExternalLibraryImport&&a.packageId&&e.resolvedOptions.includeExternal.includes(a.packageId.name)?{id:T.resolve(a.resolvedFileName)}:!e.resolvedOptions.respectExternal&&a.isExternalLibraryImport?{id:r,external:!0}:{id:T.resolve(a.resolvedFileName)}}}},"plugin");export{He as default,He as dts};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pkgroll",
3
- "version": "2.24.0",
3
+ "version": "2.24.1",
4
4
  "description": "Zero-config rollup bundler",
5
5
  "keywords": [
6
6
  "zero config",
@@ -1,35 +0,0 @@
1
- var Ge=Object.defineProperty;var c=(n,e)=>Ge(n,"name",{value:e,configurable:!0});import{createRequire as qe}from"node:module";const He=qe(import.meta.url);import*as N from"node:path";import i from"typescript";import{createRequire as Xe}from"node:module";import W from"magic-string";import ie from"node:fs/promises";var oe=44,Qe=59,ae="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ce=new Uint8Array(64),le=new Uint8Array(128);for(let n=0;n<ae.length;n++){const e=ae.charCodeAt(n);ce[n]=e,le[e]=n}function B(n,e){let t=0,r=0,s=0;do{const a=n.next();s=le[a],t|=(s&31)<<r,r+=5}while(s&32);const o=t&1;return t>>>=1,o&&(t=-2147483648|-t),e+t}c(B,"decodeInteger");function j(n,e,t){let r=e-t;r=r<0?-r<<1|1:r<<1;do{let s=r&31;r>>>=5,r>0&&(s|=32),n.write(ce[s])}while(r>0);return e}c(j,"encodeInteger");function ue(n,e){return n.pos>=e?!1:n.peek()!==oe}c(ue,"hasMoreVlq");var pe=1024*16,fe=typeof TextDecoder<"u"?new TextDecoder:typeof Buffer<"u"?{decode(n){return Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString()}}:{decode(n){let e="";for(let t=0;t<n.length;t++)e+=String.fromCharCode(n[t]);return e}},Ye=class{static{c(this,"StringWriter")}constructor(){this.pos=0,this.out="",this.buffer=new Uint8Array(pe)}write(n){const{buffer:e}=this;e[this.pos++]=n,this.pos===pe&&(this.out+=fe.decode(e),this.pos=0)}flush(){const{buffer:n,out:e,pos:t}=this;return t>0?e+fe.decode(n.subarray(0,t)):e}},Ze=class{static{c(this,"StringReader")}constructor(n){this.pos=0,this.buffer=n}next(){return this.buffer.charCodeAt(this.pos++)}peek(){return this.buffer.charCodeAt(this.pos)}indexOf(n){const{buffer:e,pos:t}=this,r=e.indexOf(n,t);return r===-1?e.length:r}};function G(n){const{length:e}=n,t=new Ze(n),r=[];let s=0,o=0,a=0,u=0,m=0;do{const f=t.indexOf(";"),d=[];let h=!0,l=0;for(s=0;t.pos<f;){let y;s=B(t,s),s<l&&(h=!1),l=s,ue(t,f)?(o=B(t,o),a=B(t,a),u=B(t,u),ue(t,f)?(m=B(t,m),y=[s,o,a,u,m]):y=[s,o,a,u]):y=[s],d.push(y),t.pos++}h||et(d),r.push(d),t.pos=f+1}while(t.pos<=e);return r}c(G,"decode");function et(n){n.sort(tt)}c(et,"sort");function tt(n,e){return n[0]-e[0]}c(tt,"sortComparator$1");function me(n){const e=new Ye;let t=0,r=0,s=0,o=0;for(let a=0;a<n.length;a++){const u=n[a];if(a>0&&e.write(Qe),u.length===0)continue;let m=0;for(let f=0;f<u.length;f++){const d=u[f];f>0&&e.write(oe),m=j(e,d[0],m),d.length!==1&&(t=j(e,d[1],t),r=j(e,d[2],r),s=j(e,d[3],s),d.length!==4&&(o=j(e,d[4],o)))}}return e.flush()}c(me,"encode");const nt=/^[\w+.-]+:\/\//,rt=/^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/,st=/^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;function it(n){return nt.test(n)}c(it,"isAbsoluteUrl");function ot(n){return n.startsWith("//")}c(ot,"isSchemeRelativeUrl");function de(n){return n.startsWith("/")}c(de,"isAbsolutePath");function at(n){return n.startsWith("file:")}c(at,"isFileUrl");function he(n){return/^[.?#]/.test(n)}c(he,"isRelative");function V(n){const e=rt.exec(n);return ye(e[1],e[2]||"",e[3],e[4]||"",e[5]||"/",e[6]||"",e[7]||"")}c(V,"parseAbsoluteUrl");function ct(n){const e=st.exec(n),t=e[2];return ye("file:","",e[1]||"","",de(t)?t:"/"+t,e[3]||"",e[4]||"")}c(ct,"parseFileUrl");function ye(n,e,t,r,s,o,a){return{scheme:n,user:e,host:t,port:r,path:s,query:o,hash:a,type:7}}c(ye,"makeUrl");function ge(n){if(ot(n)){const t=V("http:"+n);return t.scheme="",t.type=6,t}if(de(n)){const t=V("http://foo.com"+n);return t.scheme="",t.host="",t.type=5,t}if(at(n))return ct(n);if(it(n))return V(n);const e=V("http://foo.com/"+n);return e.scheme="",e.host="",e.type=n?n.startsWith("?")?3:n.startsWith("#")?2:4:1,e}c(ge,"parseUrl");function lt(n){if(n.endsWith("/.."))return n;const e=n.lastIndexOf("/");return n.slice(0,e+1)}c(lt,"stripPathFilename");function ut(n,e){xe(e,e.type),n.path==="/"?n.path=e.path:n.path=lt(e.path)+n.path}c(ut,"mergePaths");function xe(n,e){const t=e<=4,r=n.path.split("/");let s=1,o=0,a=!1;for(let m=1;m<r.length;m++){const f=r[m];if(!f){a=!0;continue}if(a=!1,f!=="."){if(f===".."){o?(a=!0,o--,s--):t&&(r[s++]=f);continue}r[s++]=f,o++}}let u="";for(let m=1;m<s;m++)u+="/"+r[m];(!u||a&&!u.endsWith("/.."))&&(u+="/"),n.path=u}c(xe,"normalizePath");function pt(n,e){if(!n&&!e)return"";const t=ge(n);let r=t.type;if(e&&r!==7){const o=ge(e),a=o.type;switch(r){case 1:t.hash=o.hash;case 2:t.query=o.query;case 3:case 4:ut(t,o);case 5:t.user=o.user,t.host=o.host,t.port=o.port;case 6:t.scheme=o.scheme}a>r&&(r=a)}xe(t,r);const s=t.query+t.hash;switch(r){case 2:case 3:return s;case 4:{const o=t.path.slice(1);return o?he(e||n)&&!he(o)?"./"+o+s:o+s:s||"."}case 5:return t.path+s;default:return t.scheme+"//"+t.user+t.host+t.port+t.path+s}}c(pt,"resolve");function ft(n){if(!n)return"";const e=n.lastIndexOf("/");return n.slice(0,e+1)}c(ft,"stripFilename");function mt(n,e){const t=ft(n),r=e?e+"/":"";return s=>pt(r+(s||""),t)}c(mt,"resolver");var L=0;function dt(n,e){const t=Se(n,0);if(t===n.length)return n;e||(n=n.slice());for(let r=t;r<n.length;r=Se(n,r+1))n[r]=yt(n[r],e);return n}c(dt,"maybeSort");function Se(n,e){for(let t=e;t<n.length;t++)if(!ht(n[t]))return t;return n.length}c(Se,"nextUnsortedSegmentLine");function ht(n){for(let e=1;e<n.length;e++)if(n[e][L]<n[e-1][L])return!1;return!0}c(ht,"isSorted");function yt(n,e){return e||(n=n.slice()),n.sort(gt)}c(yt,"sortSegments");function gt(n,e){return n[L]-e[L]}c(gt,"sortComparator");var J=!1;function xt(n,e,t,r){for(;t<=r;){const s=t+(r-t>>1),o=n[s][L]-e;if(o===0)return J=!0,s;o<0?t=s+1:r=s-1}return J=!1,t-1}c(xt,"binarySearch");function St(n,e,t){for(let r=t-1;r>=0&&n[r][L]===e;t=r--);return t}c(St,"lowerBound");function vt(){return{lastKey:-1,lastNeedle:-1,lastIndex:-1}}c(vt,"memoizedState");function Et(n,e,t,r){const{lastKey:s,lastNeedle:o,lastIndex:a}=t;let u=0,m=n.length-1;if(r===s){if(e===o)return J=a!==-1&&n[a][L]===e,a;e>=o?u=a===-1?0:a:m=a}return t.lastKey=r,t.lastNeedle=e,t.lastIndex=xt(n,e,u,m)}c(Et,"memoizedBinarySearch");function Nt(n){return typeof n=="string"?JSON.parse(n):n}c(Nt,"parse$1");var ve=class{static{c(this,"TraceMap")}constructor(n,e){const t=typeof n=="string";if(!t&&n._decodedMemo)return n;const r=Nt(n),{version:s,file:o,names:a,sourceRoot:u,sources:m,sourcesContent:f}=r;this.version=s,this.file=o,this.names=a||[],this.sourceRoot=u,this.sources=m,this.sourcesContent=f,this.ignoreList=r.ignoreList||r.x_google_ignoreList||void 0;const d=mt(e,u);this.resolvedSources=m.map(d);const{mappings:h}=r;if(typeof h=="string")this._encoded=h,this._decoded=void 0;else if(Array.isArray(h))this._encoded=void 0,this._decoded=dt(h,t);else throw r.sections?new Error("TraceMap passed sectioned source map, please use FlattenMap export instead"):new Error(`invalid source map: ${JSON.stringify(r)}`);this._decodedMemo=vt(),this._bySources=void 0,this._bySourceMemos=void 0}};function On(n){return n}c(On,"cast$1");function Ee(n){var e;return(e=n)._decoded||(e._decoded=G(n._encoded))}c(Ee,"decodedMappings");function Tt(n,e,t){const r=Ee(n);if(e>=r.length)return null;const s=r[e],o=Ct(s,n._decodedMemo,e,t);return o===-1?null:s[o]}c(Tt,"traceSegment");function Ct(n,e,t,r,s){let o=Et(n,r,e,t);return J&&(o=St(n,r,o)),o===-1||o===n.length?-1:o}c(Ct,"traceSegmentInternal");var q=class{static{c(this,"SetArray")}constructor(){this._indexes={__proto__:null},this.array=[]}};function Rn(n){return n}c(Rn,"cast");function Ne(n,e){return n._indexes[e]}c(Ne,"get");function k(n,e){const t=Ne(n,e);if(t!==void 0)return t;const{array:r,_indexes:s}=n,o=r.push(e);return s[e]=o-1}c(k,"put");function wt(n,e){const t=Ne(n,e);if(t===void 0)return;const{array:r,_indexes:s}=n;for(let o=t+1;o<r.length;o++){const a=r[o];r[o-1]=a,s[a]--}s[e]=void 0,r.pop()}c(wt,"remove");var Dt=0,bt=1,It=2,Mt=3,Ft=4,Te=-1,Ot=class{static{c(this,"GenMapping")}constructor({file:n,sourceRoot:e}={}){this._names=new q,this._sources=new q,this._sourcesContent=[],this._mappings=[],this.file=n,this.sourceRoot=e,this._ignoreList=new q}};function An(n){return n}c(An,"cast2");var Rt=c((n,e,t,r,s,o,a,u)=>_t(!0,n,e,t,r,s,o,a),"maybeAddSegment");function At(n,e,t){const{_sources:r,_sourcesContent:s}=n,o=k(r,e);s[o]=t}c(At,"setSourceContent");function Pt(n,e,t=!0){const{_sources:r,_sourcesContent:s,_ignoreList:o}=n,a=k(r,e);a===s.length&&(s[a]=null),t?k(o,a):wt(o,a)}c(Pt,"setIgnore");function Ce(n){const{_mappings:e,_sources:t,_sourcesContent:r,_names:s,_ignoreList:o}=n;return jt(e),{version:3,file:n.file||void 0,names:s.array,sourceRoot:n.sourceRoot||void 0,sources:t.array,sourcesContent:r,mappings:e,ignoreList:o.array}}c(Ce,"toDecodedMap");function Lt(n){const e=Ce(n);return Object.assign({},e,{mappings:me(e.mappings)})}c(Lt,"toEncodedMap");function _t(n,e,t,r,s,o,a,u,m){const{_mappings:f,_sources:d,_sourcesContent:h,_names:l}=e,y=$t(f,t),x=Bt(y,r);if(!s)return kt(y,x)?void 0:we(y,x,[r]);const S=k(d,s),v=u?k(l,u):Te;if(S===h.length&&(h[S]=null),!Ut(y,x,S,o,a,v))return we(y,x,u?[r,S,o,a,v]:[r,S,o,a])}c(_t,"addSegmentInternal");function $t(n,e){for(let t=n.length;t<=e;t++)n[t]=[];return n[e]}c($t,"getIndex");function Bt(n,e){let t=n.length;for(let r=t-1;r>=0;t=r--){const s=n[r];if(e>=s[Dt])break}return t}c(Bt,"getColumnIndex");function we(n,e,t){for(let r=n.length;r>e;r--)n[r]=n[r-1];n[e]=t}c(we,"insert");function jt(n){const{length:e}=n;let t=e;for(let r=t-1;r>=0&&!(n[r].length>0);t=r,r--);t<e&&(n.length=t)}c(jt,"removeEmptyFinalLines");function kt(n,e){return e===0?!0:n[e-1].length===1}c(kt,"skipSourceless");function Ut(n,e,t,r,s,o){if(e===0)return!1;const a=n[e-1];return a.length===1?!1:t===a[bt]&&r===a[It]&&s===a[Mt]&&o===(a.length===5?a[Ft]:Te)}c(Ut,"skipSource");var De=be("",-1,-1,"",null,!1),Kt=[];function be(n,e,t,r,s,o){return{source:n,line:e,column:t,name:r,content:s,ignore:o}}c(be,"SegmentObject");function Ie(n,e,t,r,s){return{map:n,sources:e,source:t,content:r,ignore:s}}c(Ie,"Source");function Me(n,e){return Ie(n,e,"",null,!1)}c(Me,"MapSource");function zt(n,e,t){return Ie(null,Kt,n,e,t)}c(zt,"OriginalSource");function Vt(n){const e=new Ot({file:n.map.file}),{sources:t,map:r}=n,s=r.names,o=Ee(r);for(let a=0;a<o.length;a++){const u=o[a];for(let m=0;m<u.length;m++){const f=u[m],d=f[0];let h=De;if(f.length!==1){const g=t[f[1]];if(h=Fe(g,f[2],f[3],f.length===5?s[f[4]]:""),h==null)continue}const{column:l,line:y,name:x,content:S,source:v,ignore:p}=h;Rt(e,a,d,v,y,l,x),v&&S!=null&&At(e,v,S),p&&Pt(e,v,!0)}}return e}c(Vt,"traceMappings");function Fe(n,e,t,r){if(!n.map)return be(n.source,e,t,r,n.content,n.ignore);const s=Tt(n.map,e,t);return s==null?null:s.length===1?De:Fe(n.sources[s[1]],s[2],s[3],s.length===5?n.map.names[s[4]]:r)}c(Fe,"originalPositionFor");function Jt(n){return Array.isArray(n)?n:[n]}c(Jt,"asArray");function Wt(n,e){const t=Jt(n).map(o=>new ve(o,"")),r=t.pop();for(let o=0;o<t.length;o++)if(t[o].sources.length>1)throw new Error(`Transformation map ${o} must have exactly one source file.
2
- Did you specify these with the most recent transformation maps first?`);let s=Oe(r,e,"",0);for(let o=t.length-1;o>=0;o--)s=Me(t[o],[s]);return s}c(Wt,"buildSourceMapTree");function Oe(n,e,t,r){const{resolvedSources:s,sourcesContent:o,ignoreList:a}=n,u=r+1,m=s.map((f,d)=>{const h={importer:t,depth:u,source:f||"",content:void 0,ignore:void 0},l=e(h.source,h),{source:y}=h;if(l)return Oe(new ve(l,y),e,y,u);const x=o?o[d]:null,S=a?a.includes(d):!1;return zt(y,x,S)});return Me(n,m)}c(Oe,"build");var Gt=class{static{c(this,"SourceMap")}constructor(n,e){const t=e.decodedMappings?Ce(n):Lt(n);this.version=t.version,this.file=t.file,this.mappings=t.mappings,this.names=t.names,this.ignoreList=t.ignoreList,this.sourceRoot=t.sourceRoot,this.sources=t.sources,e.excludeContent||(this.sourcesContent=t.sourcesContent)}toString(){return JSON.stringify(this)}};function qt(n,e,t){const r={excludeContent:!1,decodedMappings:!1},s=Wt(n,e);return new Gt(Vt(s),r)}c(qt,"remapping");function Ht(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}c(Ht,"getDefaultExportFromCjs");var H={},Re;function Xt(){return Re||(Re=1,(function(n){Object.defineProperty(n,"commentRegex",{get:c(function(){return/^\s*?\/[\/\*][@#]\s+?sourceMappingURL=data:(((?:application|text)\/json)(?:;charset=([^;,]+?)?)?)?(?:;(base64))?,(.*?)$/mg},"getCommentRegex")}),Object.defineProperty(n,"mapFileCommentRegex",{get:c(function(){return/(?:\/\/[@#][ \t]+?sourceMappingURL=([^\s'"`]+?)[ \t]*?$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*?(?:\*\/){1}[ \t]*?$)/mg},"getMapFileCommentRegex")});var e;typeof Buffer<"u"?typeof Buffer.from=="function"?e=t:e=r:e=s;function t(l){return Buffer.from(l,"base64").toString()}c(t,"decodeBase64WithBufferFrom");function r(l){if(typeof value=="number")throw new TypeError("The value to decode must not be of type number.");return new Buffer(l,"base64").toString()}c(r,"decodeBase64WithNewBuffer");function s(l){return decodeURIComponent(escape(atob(l)))}c(s,"decodeBase64WithAtob");function o(l){return l.split(",").pop()}c(o,"stripComment");function a(l,y){var x=n.mapFileCommentRegex.exec(l),S=x[1]||x[2];try{var l=y(S);return l!=null&&typeof l.catch=="function"?l.catch(v):l}catch(p){v(p)}function v(p){throw new Error("An error occurred while trying to read the map file at "+S+`
3
- `+p.stack)}c(v,"throwError")}c(a,"readFromFileMap");function u(l,y){y=y||{},y.hasComment&&(l=o(l)),y.encoding==="base64"?l=e(l):y.encoding==="uri"&&(l=decodeURIComponent(l)),(y.isJSON||y.encoding)&&(l=JSON.parse(l)),this.sourcemap=l}c(u,"Converter"),u.prototype.toJSON=function(l){return JSON.stringify(this.sourcemap,null,l)},typeof Buffer<"u"?typeof Buffer.from=="function"?u.prototype.toBase64=m:u.prototype.toBase64=f:u.prototype.toBase64=d;function m(){var l=this.toJSON();return Buffer.from(l,"utf8").toString("base64")}c(m,"encodeBase64WithBufferFrom");function f(){var l=this.toJSON();if(typeof l=="number")throw new TypeError("The json to encode must not be of type number.");return new Buffer(l,"utf8").toString("base64")}c(f,"encodeBase64WithNewBuffer");function d(){var l=this.toJSON();return btoa(unescape(encodeURIComponent(l)))}c(d,"encodeBase64WithBtoa"),u.prototype.toURI=function(){var l=this.toJSON();return encodeURIComponent(l)},u.prototype.toComment=function(l){var y,x,S;return l!=null&&l.encoding==="uri"?(y="",x=this.toURI()):(y=";base64",x=this.toBase64()),S="sourceMappingURL=data:application/json;charset=utf-8"+y+","+x,l!=null&&l.multiline?"/*# "+S+" */":"//# "+S},u.prototype.toObject=function(){return JSON.parse(this.toJSON())},u.prototype.addProperty=function(l,y){if(this.sourcemap.hasOwnProperty(l))throw new Error('property "'+l+'" already exists on the sourcemap, use set property instead');return this.setProperty(l,y)},u.prototype.setProperty=function(l,y){return this.sourcemap[l]=y,this},u.prototype.getProperty=function(l){return this.sourcemap[l]},n.fromObject=function(l){return new u(l)},n.fromJSON=function(l){return new u(l,{isJSON:!0})},n.fromURI=function(l){return new u(l,{encoding:"uri"})},n.fromBase64=function(l){return new u(l,{encoding:"base64"})},n.fromComment=function(l){var y,x;return l=l.replace(/^\/\*/g,"//").replace(/\*\/$/g,""),y=n.commentRegex.exec(l),x=y&&y[4]||"uri",new u(l,{encoding:x,hasComment:!0})};function h(l){return new u(l,{isJSON:!0})}c(h,"makeConverter"),n.fromMapFileComment=function(l,y){if(typeof y=="string")throw new Error("String directory paths are no longer supported with `fromMapFileComment`\nPlease review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading");var x=a(l,y);return x!=null&&typeof x.then=="function"?x.then(h):h(x)},n.fromSource=function(l){var y=l.match(n.commentRegex);return y?n.fromComment(y.pop()):null},n.fromMapFileSource=function(l,y){if(typeof y=="string")throw new Error("String directory paths are no longer supported with `fromMapFileSource`\nPlease review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading");var x=l.match(n.mapFileCommentRegex);return x?n.fromMapFileComment(x.pop(),y):null},n.removeComments=function(l){return l.replace(n.commentRegex,"")},n.removeMapFileComments=function(l){return l.replace(n.mapFileCommentRegex,"")},n.generateMapFileComment=function(l,y){var x="sourceMappingURL="+l;return y&&y.multiline?"/*# "+x+" */":"//# "+x}})(H)),H}c(Xt,"requireConvertSourceMap");var Qt=Xt(),Ae=Ht(Qt);function Yt(n){return{...n,compilerOptions:n.compilerOptions??{},respectExternal:n.respectExternal??!1,includeExternal:n.includeExternal??[],sourcemap:n.sourcemap??!1}}c(Yt,"resolveDefaultOptions");const _=/\.d\.(c|m)?tsx?$/,X=/\.json$/,Pe=/((\.d)?\.(c|m)?(t|j)sx?|\.json)$/;function Q(n){return n.replace(Pe,"")}c(Q,"trimExtension");function Le(n){return n.replace(Pe,".d.ts")}c(Le,"getDeclarationId");function U(n,e){return i.createSourceFile(n,e,i.ScriptTarget.Latest,!0)}c(U,"parse");const Y={getCurrentDirectory:c(()=>i.sys.getCurrentDirectory(),"getCurrentDirectory"),getNewLine:c(()=>i.sys.newLine,"getNewLine"),getCanonicalFileName:i.sys.useCaseSensitiveFileNames?n=>n:n=>n.toLowerCase()},Zt={declaration:!0,noEmit:!1,emitDeclarationOnly:!0,noEmitOnError:!0,checkJs:!1,declarationMap:!1,skipLibCheck:!0,preserveSymlinks:!0,target:i.ScriptTarget.ESNext,resolveJsonModule:!0},K=new Map,$=c((...n)=>process.env.DTS_LOG_CACHE?console.log("[cache]",...n):null,"logCache");function _e([n,e],t){for($(n),K.set(n,t);n!==e&&n!==N.dirname(n);){if(n=N.dirname(n),$("up",n),K.has(n))return $("has",n);K.set(n,t)}}c(_e,"cacheConfig");function Z(n,e,t,r){const s={...Zt,...e,...r===!0&&{declarationMap:!0}};let o=N.dirname(n),a=[];const u=t||o;if(K.has(u))$("HIT",u);else{$("miss",u);const h=t?N.resolve(process.cwd(),t):i.findConfigFile(o,i.sys.fileExists);if(!h)return{dtsFiles:a,dirName:o,compilerOptions:s};const l=o;o=N.dirname(h);const{config:y,error:x}=i.readConfigFile(h,i.sys.readFile);if(x)return console.error(i.formatDiagnostic(x,Y)),{dtsFiles:a,dirName:o,compilerOptions:s};$("tsconfig",y);const S=i.parseJsonConfigFileContent(y,i.sys,o);_e(t?[t,t]:[l,o],S)}const{fileNames:m,options:f,errors:d}=K.get(u);return a=m.filter(h=>_.test(h)),d.length?(console.error(i.formatDiagnostics(d,Y)),{dtsFiles:a,dirName:o,compilerOptions:s}):{dtsFiles:a,dirName:o,compilerOptions:{...f,...s}}}c(Z,"getCompilerOptions");function en(n,e,t,r){const{dtsFiles:s,compilerOptions:o}=Z(n,e,t,r);return i.createProgram([n].concat(Array.from(s)),o,i.createCompilerHost(o,!0))}c(en,"createProgram$1");function tn(n,e,t,r){const s=[],o=new Set;let a=[],u="",m={};for(let f of n){if(_.test(f))continue;f=N.resolve(f);const d=Z(f,e,t,r);if(d.dtsFiles.forEach(o.add,o),!a.length){a.push(f),{dirName:u,compilerOptions:m}=d;continue}if(d.dirName===u)a.push(f);else{const h=i.createCompilerHost(m,!0),l=i.createProgram(a.concat(Array.from(o)),m,h);s.push(l),a=[f],{dirName:u,compilerOptions:m}=d}}if(a.length){const f=i.createCompilerHost(m,!0),d=i.createProgram(a.concat(Array.from(o)),m,f);s.push(d)}return s}c(tn,"createPrograms");function nn(){let n;try{return{codeFrameColumns:n}=He("@babel/code-frame"),n}catch{try{return{codeFrameColumns:n}=Xe(import.meta.url)("@babel/code-frame"),n}catch{}}}c(nn,"getCodeFrame");function rn(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}}}c(rn,"getLocation");function sn(n){const e=nn(),r=n.getSourceFile().getFullText(),s=rn(n);return e?`
4
- `+e(r,s,{highlightCode:!0}):`
5
- ${s.start.line}:${s.start.column}: \`${n.getFullText().trim()}\``}c(sn,"frameNode");class w extends Error{static{c(this,"UnsupportedSyntaxError")}constructor(e,t="Syntax not yet supported"){super(`${t}
6
- ${sn(e)}`)}}class on{static{c(this,"NamespaceFixer")}constructor(e){this.sourceFile=e}findNamespaces(){const e=[],t={};for(const r of this.sourceFile.statements){const s={start:r.getStart(),end:r.getEnd()};if(i.isEmptyStatement(r)){e.unshift({name:"",exports:[],location:s});continue}if((i.isImportDeclaration(r)||i.isExportDeclaration(r))&&r.moduleSpecifier&&i.isStringLiteral(r.moduleSpecifier)){const{text:d}=r.moduleSpecifier;if(d.startsWith(".")&&(d.endsWith(".d.ts")||d.endsWith(".d.cts")||d.endsWith(".d.mts"))){const h=r.moduleSpecifier.getStart()+1,l=r.moduleSpecifier.getEnd()-1;e.unshift({name:"",exports:[],location:{start:h,end:l},textBeforeCodeAfter:d.replace(/\.d\.ts$/,".js").replace(/\.d\.cts$/,".cjs").replace(/\.d\.mts$/,".mjs")})}}if(i.isModuleDeclaration(r)&&r.body){let d=r.body;for(;i.isModuleDeclaration(d)&&d.body;)d=d.body;if(!i.isModuleBlock(d))continue;for(const h of d.statements)if(i.isExportDeclaration(h)&&h.exportClause){if(i.isNamespaceExport(h.exportClause))continue;for(const l of h.exportClause.elements)l.propertyName&&l.propertyName.getText()==l.name.getText()&&e.unshift({name:"",exports:[],location:{start:l.propertyName.getEnd(),end:l.name.getEnd()}})}}if(i.isClassDeclaration(r)?t[r.name.getText()]={type:"class",generics:r.typeParameters}:i.isFunctionDeclaration(r)?t[r.name.getText()]={type:"function"}:i.isInterfaceDeclaration(r)?t[r.name.getText()]={type:"interface",generics:r.typeParameters}:i.isTypeAliasDeclaration(r)?t[r.name.getText()]={type:"type",generics:r.typeParameters}:i.isModuleDeclaration(r)&&i.isIdentifier(r.name)?t[r.name.getText()]={type:"namespace"}:i.isEnumDeclaration(r)&&(t[r.name.getText()]={type:"enum"}),!i.isVariableStatement(r))continue;const{declarations:o}=r.declarationList;if(o.length!==1)continue;const a=o[0],u=a.name.getText();if(!a.initializer||!i.isCallExpression(a.initializer)){t[u]={type:"var"};continue}const m=a.initializer.arguments[0];if(!a.initializer.expression.getFullText().includes("/*#__PURE__*/Object.freeze")||!i.isObjectLiteralExpression(m))continue;const f=[];for(const d of m.properties){if(!i.isPropertyAssignment(d)||!(i.isIdentifier(d.name)||i.isStringLiteral(d.name))||d.name.text!=="__proto__"&&!i.isIdentifier(d.initializer))throw new w(d,"Expected a property assignment");d.name.text!=="__proto__"&&f.push({exportedName:d.name.text,localName:d.initializer.getText()})}e.unshift({name:u,exports:f,location:s})}return{namespaces:e,itemTypes:t}}fix(){let e=this.sourceFile.getFullText();const{namespaces:t,itemTypes:r}=this.findNamespaces();for(const s of t){const o=e.slice(s.location.end);e=e.slice(0,s.location.start);for(const{exportedName:a,localName:u}of s.exports)if(a===u){const{type:m,generics:f}=r[u]||{};if(m==="interface"||m==="type"){const d=$e(f);e+=`type ${s.name}_${a}${d.in} = ${u}${d.out};
7
- `}else if(m==="enum"||m==="class"){const d=$e(f);e+=`type ${s.name}_${a}${d.in} = ${u}${d.out};
8
- `,e+=`declare const ${s.name}_${a}: typeof ${u};
9
- `}else m==="namespace"?e+=`import ${s.name}_${a} = ${u};
10
- `:e+=`declare const ${s.name}_${a}: typeof ${u};
11
- `}if(s.name){e+=`declare namespace ${s.name} {
12
- `,e+=` export {
13
- `;for(const{exportedName:a,localName:u}of s.exports)a===u?e+=` ${s.name}_${a} as ${a},
14
- `:e+=` ${u} as ${a},
15
- `;e+=` };
16
- `,e+="}"}e+=s.textBeforeCodeAfter??"",e+=o}return e}}function $e(n){return!n||!n.length?{in:"",out:""}:{in:`<${n.map(e=>e.getText()).join(", ")}>`,out:`<${n.map(e=>e.name.getText()).join(", ")}>`}}c($e,"renderTypeParams");let Be=1;function an(n){return I({type:"Program",sourceType:"module",body:[]},{start:n.getFullStart(),end:n.getEnd()})}c(an,"createProgram");function cn(n){const e={type:"Identifier",name:String(Be++)};return{ident:e,expr:{type:"AssignmentPattern",left:e,right:n}}}c(cn,"createReference");function M(n){return I({type:"Identifier",name:n.getText()},n)}c(M,"createIdentifier");function ln(n){const e=I({type:"FunctionExpression",id:null,params:[],body:{type:"BlockStatement",body:[]}},n),t=I({type:"ExpressionStatement",expression:{type:"CallExpression",callee:{type:"Identifier",name:String(Be++)},arguments:[e],optional:!1}},n);return{fn:e,iife:t}}c(ln,"createIIFE");function un(){const n={type:"ArrayExpression",elements:[]};return{expr:n,stmt:{type:"ReturnStatement",argument:n}}}c(un,"createReturn");function pn(n,e){return I({type:"FunctionDeclaration",id:I({type:"Identifier",name:i.idText(n)},n),params:[],body:{type:"BlockStatement",body:[]}},e)}c(pn,"createDeclaration");function A(n){if(i.isLiteralExpression(n))return{type:"Literal",value:n.text};if(i.isPropertyAccessExpression(n)){if(i.isPrivateIdentifier(n.name))throw new w(n.name);return I({type:"MemberExpression",computed:!1,optional:!1,object:A(n.expression),property:A(n.name)},{start:n.expression.getStart(),end:n.name.getEnd()})}if(i.isObjectLiteralExpression(n))return I({type:"ObjectExpression",properties:n.properties.map(e=>{if(i.isPropertyAssignment(e))return I({type:"Property",key:i.isIdentifier(e.name)?M(e.name):A(e.name),value:A(e.initializer),kind:"init",method:!1,shorthand:!1,computed:i.isComputedPropertyName(e.name)},e);if(i.isShorthandPropertyAssignment(e))return I({type:"Property",key:M(e.name),value:M(e.name),kind:"init",method:!1,shorthand:!0,computed:!1},e);throw new w(e,"Unsupported property type in object literal")})},n);if(i.isArrayLiteralExpression(n))return I({type:"ArrayExpression",elements:n.elements.map(e=>{if(i.isExpression(e))return A(e);throw new w(e,"Unsupported element type in array literal")})},n);if(i.isIdentifier(n))return M(n);if(n.kind==i.SyntaxKind.NullKeyword)return{type:"Literal",value:null};throw new w(n)}c(A,"convertExpression");function I(n,e){const t="start"in e?e:{start:e.getStart(),end:e.getEnd()};return Object.assign(n,t)}c(I,"withStartEnd");function z(n,e){return(i.getCombinedModifierFlags(n)&e)===e}c(z,"matchesModifier");class fn{static{c(this,"LanguageService")}constructor(e){this.fileName="index.d.ts";const t={getCompilationSettings:c(()=>({noEmit:!0,noResolve:!0,skipLibCheck:!0,declaration:!1,checkJs:!1,declarationMap:!1,target:i.ScriptTarget.ESNext}),"getCompilationSettings"),getScriptFileNames:c(()=>[this.fileName],"getScriptFileNames"),getScriptVersion:c(()=>"1","getScriptVersion"),getScriptSnapshot:c(r=>r===this.fileName?i.ScriptSnapshot.fromString(e):void 0,"getScriptSnapshot"),getCurrentDirectory:c(()=>"","getCurrentDirectory"),getDefaultLibFileName:c(()=>"","getDefaultLibFileName"),fileExists:c(r=>r===this.fileName,"fileExists"),readFile:c(r=>r===this.fileName?e:void 0,"readFile")};this.service=i.createLanguageService(t,i.createDocumentRegistry(void 0,""),i.LanguageServiceMode.PartialSemantic)}findReferenceCount(e){const t=this.service.findReferences(this.fileName,e.getStart());return t?.length?t.reduce((r,s)=>r+s.references.length,0):0}}class mn{static{c(this,"TypeOnlyFixer")}constructor(e,t){this.DEBUG=!!process.env.DTS_EXPORTS_FIXER_DEBUG,this.types=new Set,this.values=new Set,this.typeHints=new Map,this.reExportTypeHints=new Map,this.importNodes=[],this.exportNodes=[],this.rawCode=t,this.source=U(e,t),this.code=new W(t)}fix(){return this.analyze(this.source.statements),(this.typeHints.size||this.reExportTypeHints.size)&&(this.service=new fn(this.rawCode),this.importNodes.forEach(e=>this.fixTypeOnlyImport(e))),this.types.size&&this.exportNodes.forEach(e=>this.fixTypeOnlyExport(e)),this.types.size?{magicCode:this.code}:{code:this.rawCode,map:null}}fixTypeOnlyImport(e){let t=!1;const r=[],s=[],o=e.moduleSpecifier.getText(),a=e.importClause.name,u=e.importClause.namedBindings;if(a){const m=a.text;this.isTypeOnly(m)?this.isUselessImport(a)?t=!0:r.push(`import type ${m} from ${o};`):s.push(`import ${m} from ${o};`)}if(u&&i.isNamespaceImport(u)){const m=u.name.text;this.isTypeOnly(m)?this.isUselessImport(u.name)?t=!0:r.push(`import type * as ${m} from ${o};`):s.push(`import * as ${m} from ${o};`)}if(u&&i.isNamedImports(u)){const m=[],f=[];for(const d of u.elements)this.isTypeOnly(d.name.text)?this.isUselessImport(d.name)?t=!0:m.push(d.getText()):f.push(d.getText());m.length&&r.push(`import type { ${m.join(", ")} } from ${o};`),f.length&&s.push(`import { ${f.join(", ")} } from ${o};`)}(r.length||t)&&this.code.overwrite(e.getStart(),e.getEnd(),[...s,...r].join(`
17
- ${je(e)}`))}fixTypeOnlyExport(e){const t=[],r=[],s=e.moduleSpecifier?.getText();if(i.isNamespaceExport(e.exportClause)){const o=e.exportClause.name.text;this.isReExportTypeOnly(o)?t.push(`export type * as ${o} from ${s};`):r.push(`export * as ${o} from ${s};`)}if(i.isNamedExports(e.exportClause)){const o=[],a=[];for(const u of e.exportClause.elements){const m=u.propertyName?.text||u.name.text;(e.moduleSpecifier?this.isReExportTypeOnly(u.name.text):this.isTypeOnly(m))?o.push(u.getText()):a.push(u.getText())}o.length&&t.push(`export type { ${o.join(", ")} }${s?` from ${s}`:""};`),a.length&&r.push(`export { ${a.join(", ")} }${s?` from ${s}`:""};`)}t.length&&this.code.overwrite(e.getStart(),e.getEnd(),[...r,...t].join(`
18
- ${je(e)}`))}analyze(e){for(const t of e){if(this.DEBUG&&console.log(t.getText(),t.kind),i.isImportDeclaration(t)&&t.importClause){this.importNodes.push(t);continue}if(i.isExportDeclaration(t)&&t.exportClause){this.exportNodes.push(t);continue}if(i.isInterfaceDeclaration(t)){this.DEBUG&&console.log(`${t.name.getFullText()} is a type`),this.types.add(t.name.text);continue}if(i.isTypeAliasDeclaration(t)){const r=t.name.text;this.DEBUG&&console.log(`${t.name.getFullText()} is a type`),this.types.add(r);continue}if(i.isEnumDeclaration(t)||i.isFunctionDeclaration(t)||i.isClassDeclaration(t)||i.isVariableStatement(t)){if(i.isVariableStatement(t))for(const r of t.declarationList.declarations)i.isIdentifier(r.name)&&(this.DEBUG&&console.log(`${r.name.getFullText()} is a value (from var statement)`),this.values.add(r.name.text));else t.name&&(this.DEBUG&&console.log(`${t.name.getFullText()} is a value (from declaration)`),this.values.add(t.name.text));continue}if(i.isModuleBlock(t)){this.analyze(t.statements);continue}if(i.isModuleDeclaration(t)){t.name&&i.isIdentifier(t.name)&&(this.DEBUG&&console.log(`${t.name.getFullText()} is a value (from module declaration)`),this.values.add(t.name.text)),this.analyze(t.getChildren());continue}this.DEBUG&&console.log("unhandled statement",t.getFullText(),t.kind)}}isUselessImport(e){const t=this.service.findReferenceCount(e),r=this.typeHints.get(e.text);return r&&r+1>=t}isTypeOnly(e){return this.typeHints.has(e)||this.types.has(e)&&!this.values.has(e)}isReExportTypeOnly(e){return this.reExportTypeHints.has(e)}}function je(n){const e=n.getFullText().match(/^(?:\n*)([ ]*)/);return" ".repeat(e?.[1]?.length||0)}c(je,"getNodeIndent");function ee(n,e,t){if(i.isModuleDeclaration(n)){n.body&&(i.isModuleBlock(n.body)||i.isModuleDeclaration(n.body))&&ee(n.body,e);return}for(const r of n.statements)te(e,r),i.isModuleDeclaration(r)&&r.body&&(i.isModuleBlock(r.body)||i.isModuleDeclaration(r.body))&&ee(r.body,e)}c(ee,"preProcessNamespaceBody");function dn({sourceFile:n,isEntry:e,isJSON:t}){const r=new W(n.getFullText()),s=!e&&hn(n),o=new Set,a=new Set;let u="";const m=new Map,f=new Map;for(const p of n.statements){if(i.isEmptyStatement(p)){r.remove(p.getStart(),p.getEnd());continue}if(i.isImportDeclaration(p)){if(!p.importClause)continue;p.importClause.name&&o.add(p.importClause.name.text),p.importClause.namedBindings&&(i.isNamespaceImport(p.importClause.namedBindings)?o.add(p.importClause.namedBindings.name.text):p.importClause.namedBindings.elements.forEach(g=>o.add(g.name.text)))}else if(i.isEnumDeclaration(p)||i.isFunctionDeclaration(p)||i.isInterfaceDeclaration(p)||i.isClassDeclaration(p)||i.isTypeAliasDeclaration(p)||i.isModuleDeclaration(p)){if(p.name){const g=p.name.getText();o.add(g),z(p,i.ModifierFlags.ExportDefault)?u=g:(s&&i.isIdentifier(p.name)||z(p,i.ModifierFlags.Export))&&a.add(g),p.flags&i.NodeFlags.GlobalAugmentation||v(g,[ne(p),Ue(p)])}i.isModuleDeclaration(p)&&(p.body&&(i.isModuleBlock(p.body)||i.isModuleDeclaration(p.body))&&ee(p.body,r),ke(r,p)),te(r,p)}else if(i.isVariableStatement(p)){const{declarations:g}=p.declarationList,E=z(p,i.ModifierFlags.Export);for(const b of p.declarationList.declarations)if(i.isIdentifier(b.name)){const R=b.name.getText();o.add(R),(s||E)&&a.add(R)}if(te(r,p),g.length===1){const b=g[0];i.isIdentifier(b.name)&&v(b.name.getText(),[ne(p),Ue(p)])}else{const b=g.slice(),R=b.shift();v(R.name.getText(),[ne(p),R.getEnd()]);for(const P of b)i.isIdentifier(P.name)&&v(P.name.getText(),[P.getFullStart(),P.getEnd()])}const{flags:T}=p.declarationList,C=`declare ${T&i.NodeFlags.Let?"let":T&i.NodeFlags.Const?"const":"var"} `,D=p.declarationList.getChildren().find(b=>b.kind===i.SyntaxKind.SyntaxList).getChildren();let F=0;for(const b of D)if(b.kind===i.SyntaxKind.CommaToken)F=b.getStart(),r.remove(F,b.getEnd());else if(F){r.appendLeft(F,`;
19
- `);const R=b.getFullStart(),P=r.slice(R,b.getStart()),se=P.length-P.trimStart().length;se?r.overwrite(R,R+se,C):r.appendLeft(R,C)}}}for(const p of n.statements){if(y(p),i.isExportAssignment(p)&&!p.isExportEquals&&(i.isObjectLiteralExpression(p.expression)||i.isArrayLiteralExpression(p.expression))){u||(u=S("export_default")),r.overwrite(p.getStart(),p.expression.getStart(),`declare var ${u} = `);continue}if(z(p,i.ModifierFlags.ExportDefault)&&(i.isFunctionDeclaration(p)||i.isClassDeclaration(p))){if(p.name)continue;u||(u=S("export_default"));const g=p.getChildren(),E=g.findIndex(D=>D.kind===i.SyntaxKind.ClassKeyword||D.kind===i.SyntaxKind.FunctionKeyword),T=g[E],O=g[E+1];if(O.kind>=i.SyntaxKind.FirstPunctuation&&O.kind<=i.SyntaxKind.LastPunctuation){const D=r.slice(T.getEnd(),O.getStart())!=" ";r.appendLeft(O.getStart(),`${D?" ":""}${u}`)}else r.appendRight(T.getEnd(),` ${u}`)}}for(const p of f.values()){const E=p.pop()[0];for(const T of p)r.move(T[0],T[1],E)}u&&r.append(`
20
- export default ${u};
21
- `),a.size&&r.append(`
22
- export { ${[...a].join(", ")} };
23
- `),t&&a.size&&(u=S("export_default"),r.append([`
24
- declare const ${u}: {`,[...a].map(p=>` ${p}: typeof ${p};`).join(`
25
- `),"};",`export default ${u};
26
- `].join(`
27
- `)));for(const[p,g]of m.entries())r.prepend(`import * as ${g} from "${p}";
28
- `);const d=n.getLineStarts(),h=new Set;for(const p of n.typeReferenceDirectives){h.add(p.fileName);const{line:g}=n.getLineAndCharacterOfPosition(p.pos),E=d[g];let T=n.getLineEndOfPosition(p.pos);r.slice(T,T+1)===`
29
- `&&(T+=1),r.remove(E,T)}const l=new Set;for(const p of n.referencedFiles){l.add(p.fileName);const{line:g}=n.getLineAndCharacterOfPosition(p.pos),E=d[g];let T=n.getLineEndOfPosition(p.pos);r.slice(T,T+1)===`
30
- `&&(T+=1),r.remove(E,T)}return{code:r,typeReferences:h,fileReferences:l};function y(p){if(i.forEachChild(p,y),i.isImportTypeNode(p)){if(!i.isLiteralTypeNode(p.argument)||!i.isStringLiteral(p.argument.literal))throw new w(p,"inline imports should have a literal argument");const g=p.argument.literal.text,E=p.getChildren(),T=E.find(F=>F.kind===i.SyntaxKind.ImportKeyword).getStart();let O=p.getEnd();const C=E.find(F=>F.kind===i.SyntaxKind.DotToken||F.kind===i.SyntaxKind.LessThanToken);C&&(O=C.getStart());const D=x(g);r.overwrite(T,O,D)}}function x(p){let g=m.get(p);return g||(g=S(yn(p)),m.set(p,g)),g}function S(p){let g=p;for(;o.has(g);)g=`_${g}`;return o.add(g),g}function v(p,g){let E=f.get(p);if(!E)E=[g],f.set(p,E);else{const T=E[E.length-1];T[1]===g[0]?T[1]=g[1]:E.push(g)}}}c(dn,"preProcess");function hn(n){let e=!1;for(const t of n.statements){if(i.isExportDeclaration(t)||i.isExportAssignment(t))return!1;(e||i.isImportDeclaration(t)||z(t,i.ModifierFlags.Export))&&(e=!0)}return e}c(hn,"isGlobalModule");function te(n,e){if(!i.canHaveModifiers(e))return;if(e.parent.kind===i.SyntaxKind.SourceFile){let r=!1;const s=i.isEnumDeclaration(e)||i.isClassDeclaration(e)||i.isFunctionDeclaration(e)||i.isModuleDeclaration(e)||i.isVariableStatement(e);for(const o of e.modifiers??[])switch(o.kind){case i.SyntaxKind.ExportKeyword:case i.SyntaxKind.DefaultKeyword:n.remove(o.getStart(),o.getEnd()+1);break;case i.SyntaxKind.DeclareKeyword:r=!0}s&&!r&&n.appendRight(e.getStart(),"declare ")}}c(te,"fixModifiers");function ke(n,e){if(e.body){if(i.isModuleDeclaration(e.body)){ke(n,e.body);return}if(i.isModuleBlock(e.body)){for(const t of e.body.statements)if(i.isExportDeclaration(t)&&t.exportClause){if(i.isNamespaceExport(t.exportClause))continue;for(const r of t.exportClause.elements)r.propertyName||n.appendLeft(r.name.getEnd(),` as ${r.name.getText()}`)}}}}c(ke,"duplicateExports");function yn(n){return n.replace(/[^a-zA-Z0-9_$]/g,()=>"_")}c(yn,"getSafeName");function ne(n){const e=n.getFullStart();return e+(Ke(n,e)?1:0)}c(ne,"getStart");function Ue(n){const e=n.getEnd();return e+(Ke(n,e)?1:0)}c(Ue,"getEnd");function Ke(n,e){return n.getSourceFile().getFullText()[e]===`
31
- `}c(Ke,"newlineAt");const gn=new Set([i.SyntaxKind.LiteralType,i.SyntaxKind.VoidKeyword,i.SyntaxKind.UnknownKeyword,i.SyntaxKind.AnyKeyword,i.SyntaxKind.BooleanKeyword,i.SyntaxKind.NumberKeyword,i.SyntaxKind.StringKeyword,i.SyntaxKind.ObjectKeyword,i.SyntaxKind.NullKeyword,i.SyntaxKind.UndefinedKeyword,i.SyntaxKind.SymbolKeyword,i.SyntaxKind.NeverKeyword,i.SyntaxKind.ThisKeyword,i.SyntaxKind.ThisType,i.SyntaxKind.BigIntKeyword]);class ze{static{c(this,"DeclarationScope")}constructor({id:e,range:t}){if(this.scopes=[],e)this.declaration=pn(e,t);else{const{iife:s,fn:o}=ln(t);this.iife=s,this.declaration=o}const r=un();this.declaration.body.body.push(r.stmt),this.returnExpr=r.expr}pushScope(){this.scopes.push(new Set)}popScope(e=1){for(let t=0;t<e;t++)this.scopes.pop()}pushTypeVariable(e){const t=e.getText();this.scopes[this.scopes.length-1]?.add(t)}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 o of this.scopes)if(o.has(t))return}if(t==="this")return;const{ident:r,expr:s}=cn(e);this.declaration.params.push(s),this.returnExpr.elements.push(r)}pushIdentifierReference(e){this.pushReference(M(e))}convertEntityName(e){return i.isIdentifier(e)?M(e):I({type:"MemberExpression",computed:!1,optional:!1,object:this.convertEntityName(e.left),property:M(e.right)},e)}convertPropertyAccess(e){if(!i.isIdentifier(e.expression)&&!i.isPropertyAccessExpression(e.expression))throw new w(e.expression);if(i.isPrivateIdentifier(e.name))throw new w(e.name);const t=i.isIdentifier(e.expression)?M(e.expression):this.convertPropertyAccess(e.expression);return I({type:"MemberExpression",computed:!1,optional:!1,object:t,property:M(e.name)},e)}convertComputedPropertyName(e){if(!e.name||!i.isComputedPropertyName(e.name))return;const{expression:t}=e.name;if(!(i.isLiteralExpression(t)||i.isPrefixUnaryExpression(t))){if(i.isIdentifier(t))return this.pushReference(M(t));if(i.isPropertyAccessExpression(t))return this.pushReference(this.convertPropertyAccess(t));throw new w(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(A(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(i.isPropertyDeclaration(t)||i.isPropertySignature(t)||i.isIndexSignatureDeclaration(t)){i.isPropertyDeclaration(t)&&t.initializer&&i.isPropertyAccessExpression(t.initializer)&&this.pushReference(this.convertPropertyAccess(t.initializer)),this.convertComputedPropertyName(t),this.convertTypeNode(t.type);continue}if(i.isMethodDeclaration(t)||i.isMethodSignature(t)||i.isConstructorDeclaration(t)||i.isConstructSignatureDeclaration(t)||i.isCallSignatureDeclaration(t)||i.isGetAccessorDeclaration(t)||i.isSetAccessorDeclaration(t))this.convertParametersAndType(t);else throw new w(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&&!gn.has(e.kind)){if(i.isTypeReferenceNode(e)){this.pushReference(this.convertEntityName(e.typeName)),this.convertTypeArguments(e);return}if(i.isTypeLiteralNode(e)){this.convertMembers(e.members);return}if(i.isArrayTypeNode(e)){this.convertTypeNode(e.elementType);return}if(i.isTupleTypeNode(e)){for(const t of e.elements)this.convertTypeNode(t);return}if(i.isNamedTupleMember(e)||i.isParenthesizedTypeNode(e)||i.isTypeOperatorNode(e)||i.isTypePredicateNode(e)){this.convertTypeNode(e.type);return}if(i.isUnionTypeNode(e)||i.isIntersectionTypeNode(e)){for(const t of e.types)this.convertTypeNode(t);return}if(i.isMappedTypeNode(e)){const{typeParameter:t,type:r,nameType:s}=e;this.convertTypeNode(t.constraint),this.pushScope(),this.pushTypeVariable(t.name),this.convertTypeNode(r),s&&this.convertTypeNode(s),this.popScope();return}if(i.isConditionalTypeNode(e)){this.convertTypeNode(e.checkType),this.pushScope(),this.convertTypeNode(e.extendsType),this.convertTypeNode(e.trueType),this.convertTypeNode(e.falseType),this.popScope();return}if(i.isIndexedAccessTypeNode(e)){this.convertTypeNode(e.objectType),this.convertTypeNode(e.indexType);return}if(i.isFunctionOrConstructorTypeNode(e)){this.convertParametersAndType(e);return}if(i.isTypeQueryNode(e)){const t=this.convertEntityName(e.exprName);this.pushReference(t),this.convertTypeArguments(e);return}if(i.isRestTypeNode(e)){this.convertTypeNode(e.type);return}if(i.isOptionalTypeNode(e)){this.convertTypeNode(e.type);return}if(i.isTemplateLiteralTypeNode(e)){for(const t of e.templateSpans)this.convertTypeNode(t.type);return}if(i.isInferTypeNode(e)){const{typeParameter:t}=e;this.convertTypeNode(t.constraint),this.pushTypeVariable(t.name);return}else throw new w(e)}}convertNamespace(e,t=!1){if(this.pushScope(),t&&e.body&&i.isModuleDeclaration(e.body)){this.convertNamespace(e.body,!0);return}if(!e.body||!i.isModuleBlock(e.body))throw new w(e,'namespace must have a "ModuleBlock" body.');const{statements:r}=e.body;for(const s of r){if(i.isEnumDeclaration(s)||i.isFunctionDeclaration(s)||i.isClassDeclaration(s)||i.isInterfaceDeclaration(s)||i.isTypeAliasDeclaration(s)||i.isModuleDeclaration(s)){if(s.name&&i.isIdentifier(s.name))this.pushTypeVariable(s.name);else throw new w(s,"non-Identifier name not supported");continue}if(i.isVariableStatement(s)){for(const o of s.declarationList.declarations)if(i.isIdentifier(o.name))this.pushTypeVariable(o.name);else throw new w(o,"non-Identifier name not supported");continue}if(i.isImportDeclaration(s)){if(s.importClause&&(s.importClause.name&&this.pushTypeVariable(s.importClause.name),s.importClause.namedBindings))if(i.isNamespaceImport(s.importClause.namedBindings))this.pushTypeVariable(s.importClause.namedBindings.name);else for(const o of s.importClause.namedBindings.elements)this.pushTypeVariable(o.name);continue}if(i.isImportEqualsDeclaration(s)){this.pushTypeVariable(s.name);continue}if(!i.isExportDeclaration(s))throw new w(s,"namespace child (hoisting) not supported yet")}for(const s of r){if(i.isVariableStatement(s)){for(const o of s.declarationList.declarations)o.type&&this.convertTypeNode(o.type);continue}if(i.isFunctionDeclaration(s)){this.convertParametersAndType(s);continue}if(i.isInterfaceDeclaration(s)||i.isClassDeclaration(s)){const o=this.convertTypeParameters(s.typeParameters);this.convertHeritageClauses(s),this.convertMembers(s.members),this.popScope(o);continue}if(i.isTypeAliasDeclaration(s)){const o=this.convertTypeParameters(s.typeParameters);this.convertTypeNode(s.type),this.popScope(o);continue}if(i.isModuleDeclaration(s)){this.convertNamespace(s,t);continue}if(!i.isEnumDeclaration(s)&&!i.isImportDeclaration(s)){if(i.isImportEqualsDeclaration(s)){i.isEntityName(s.moduleReference)&&this.pushReference(this.convertEntityName(s.moduleReference));continue}if(i.isExportDeclaration(s)){if(s.exportClause){if(i.isNamespaceExport(s.exportClause))throw new w(s.exportClause);for(const o of s.exportClause.elements){const a=o.propertyName||o.name;this.pushIdentifierReference(a)}}}else throw new w(s,"namespace child (walking) not supported yet")}}this.popScope()}}function xn({sourceFile:n}){return new Sn(n).transform()}c(xn,"convert");class Sn{static{c(this,"Transformer")}constructor(e){this.sourceFile=e,this.declarations=new Map,this.ast=an(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 u=new ze({range:r});return this.pushStatement(u.iife),u}const s=t.getText(),o=new ze({id:t,range:r}),a=this.declarations.get(s);if(a){a.pushIdentifierReference(t),a.declaration.end=r.end;const u=this.ast.body.findIndex(m=>m==a.declaration);for(let m=u+1;m<this.ast.body.length;m++){const f=this.ast.body[m];f.start=f.end=r.end}}else this.pushStatement(o.declaration),this.declarations.set(s,o);return a||o}convertStatement(e){if(i.isEnumDeclaration(e))return this.convertEnumDeclaration(e);if(i.isFunctionDeclaration(e))return this.convertFunctionDeclaration(e);if(i.isInterfaceDeclaration(e)||i.isClassDeclaration(e))return this.convertClassOrInterfaceDeclaration(e);if(i.isTypeAliasDeclaration(e))return this.convertTypeAliasDeclaration(e);if(i.isVariableStatement(e))return this.convertVariableStatement(e);if(i.isExportDeclaration(e)||i.isExportAssignment(e))return this.convertExportDeclaration(e);if(i.isModuleDeclaration(e))return this.convertNamespaceDeclaration(e);if(e.kind===i.SyntaxKind.NamespaceExportDeclaration)return this.removeStatement(e);if(i.isImportDeclaration(e)||i.isImportEqualsDeclaration(e))return this.convertImportDeclaration(e);throw new w(e)}removeStatement(e){this.pushStatement(I({type:"ExpressionStatement",expression:{type:"Literal",value:"pls remove me"}},e))}convertNamespaceDeclaration(e){if(e.flags&i.NodeFlags.GlobalAugmentation||!i.isIdentifier(e.name)){this.createDeclaration(e).convertNamespace(e,!0);return}const r=this.createDeclaration(e,e.name);r.pushIdentifierReference(e.name),r.convertNamespace(e,!0)}convertEnumDeclaration(e){this.createDeclaration(e,e.name).pushIdentifierReference(e.name)}convertFunctionDeclaration(e){if(!e.name)throw new w(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 w(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 w(e,"VariableStatement with more than one declaration not yet supported");for(const r of t){if(!i.isIdentifier(r.name))throw new w(e,"VariableDeclaration must have a name");const s=this.createDeclaration(e,r.name);s.convertTypeNode(r.type),r.initializer&&this.trackExpressionReferences(r.initializer,s)}}trackExpressionReferences(e,t){if(i.isIdentifier(e))t.pushIdentifierReference(e);else if(i.isObjectLiteralExpression(e))for(const r of e.properties)i.isShorthandPropertyAssignment(r)?t.pushIdentifierReference(r.name):i.isPropertyAssignment(r)&&this.trackExpressionReferences(r.initializer,t);else if(i.isArrayLiteralExpression(e))for(const r of e.elements)i.isExpression(r)&&this.trackExpressionReferences(r,t);else i.isPropertyAccessExpression(e)&&this.trackExpressionReferences(e.expression,t)}convertExportDeclaration(e){if(i.isExportAssignment(e)){this.pushStatement(I({type:"ExportDefaultDeclaration",declaration:A(e.expression)},e));return}const t=e.moduleSpecifier?A(e.moduleSpecifier):void 0;if(!e.exportClause)this.pushStatement(I({type:"ExportAllDeclaration",source:t,exported:null,attributes:[]},e));else if(i.isNamespaceExport(e.exportClause))this.pushStatement(I({type:"ExportAllDeclaration",source:t,exported:M(e.exportClause.name),attributes:[]},e));else{const r=[];for(const s of e.exportClause.elements)r.push(this.convertExportSpecifier(s));this.pushStatement(I({type:"ExportNamedDeclaration",declaration:null,specifiers:r,source:t,attributes:[]},e))}}convertImportDeclaration(e){if(i.isImportEqualsDeclaration(e)){if(i.isEntityName(e.moduleReference)){const s=this.createDeclaration(e,e.name);s.pushReference(s.convertEntityName(e.moduleReference));return}if(!i.isExternalModuleReference(e.moduleReference))throw new w(e,"ImportEquals should have a literal source.");this.pushStatement(I({type:"ImportDeclaration",specifiers:[{type:"ImportDefaultSpecifier",local:M(e.name)}],source:A(e.moduleReference.expression),attributes:[]},e));return}const t=A(e.moduleSpecifier),r=e.importClause&&e.importClause.namedBindings?this.convertNamedImportBindings(e.importClause.namedBindings):[];e.importClause&&e.importClause.name&&r.push({type:"ImportDefaultSpecifier",local:M(e.importClause.name)}),this.pushStatement(I({type:"ImportDeclaration",specifiers:r,source:t,attributes:[]},e))}convertNamedImportBindings(e){return i.isNamedImports(e)?e.elements.map(t=>{const r=M(t.name),s=t.propertyName?M(t.propertyName):r;return{type:"ImportSpecifier",local:r,imported:s}}):[{type:"ImportNamespaceSpecifier",local:M(e.name)}]}convertExportSpecifier(e){const t=M(e.name);return{type:"ExportSpecifier",exported:t,local:e.propertyName?M(e.propertyName):t}}}class vn{static{c(this,"RelativeModuleDeclarationFixer")}constructor(e,t,r,s){this.sourcemap=r,this.DEBUG=!!process.env.DTS_EXPORTS_FIXER_DEBUG,this.relativeModuleDeclarations=[],this.source=U(e,t.toString()),this.code=t,this.name=s||"./index"}fix(){this.analyze(this.source.statements);for(const e of this.relativeModuleDeclarations){const t=e.getStart(),r=e.getEnd(),s=e.name.kind===i.SyntaxKind.StringLiteral&&"singleQuote"in e.name&&e.name.singleQuote?"'":'"',o=`declare module ${s}${this.name}${s} ${e.body.getText()}`;this.code.overwrite(t,r,o)}return{code:this.code.toString(),map:this.relativeModuleDeclarations.length&&this.sourcemap?this.code.generateMap():null}}analyze(e){for(const t of e)i.isModuleDeclaration(t)&&t.body&&i.isModuleBlock(t.body)&&/^\.\.?\//.test(t.name.text)&&(this.DEBUG&&console.log(`Found relative module declaration: ${t.name.text} in ${this.source.fileName}`),this.relativeModuleDeclarations.push(t))}}function En(n,e,t){const r=G(n),s=G(e.mappings),o=t.split(`
32
- `),a=[];for(let u=0;u<r.length;u+=1){const m=r[u];if(!m||m.length===0){a.push([]);continue}const f=m.find(g=>g.length>=4);if(!f){a.push(m);continue}const[,d,h]=f;if(d!==0||h===void 0||h<0||h>=s.length){a.push(m);continue}const l=s[h];if(!l||l.length===0){a.push(m);continue}const y=f[0],x=f.length>=4?f[3]:0,S=y-(x??0),v=o[u]||"",p=[];for(const g of l){const E=g[0]+S;E<0||E>v.length||(g.length===5?p.push([E,g[1],g[2],g[3],g[4]]):g.length===4?p.push([E,g[1],g[2],g[3]]):p.push([E]))}p.sort((g,E)=>g[0]-E[0]),a.push(p)}return me(a)}c(En,"hydrateSourcemap");async function Nn(n){const{fileName:e,originalCode:t,inputMapText:r}=n;if(r)try{return JSON.parse(r)}catch{return null}const s=Ae.fromSource(t);if(s)return s.toObject();const o=c(async a=>{const u=a.split(/[?#]/)[0],m=N.resolve(N.dirname(e),u);return ie.readFile(m,"utf8")},"readMap");try{const a=await Ae.fromMapFileSource(t,o);if(a)return a.toObject()}catch{}try{const a=await ie.readFile(e+".map","utf8");return JSON.parse(a)}catch{return null}}c(Nn,"loadInputSourcemap");const Tn=c(n=>{const e=new Map,t=new Map,r=new Map;return{name:"dts-transform",buildStart(){e.clear(),t.clear(),r.clear()},options({onLog:s,...o}){return{...o,onLog(a,u,m){a==="warn"&&u.code==="CIRCULAR_DEPENDENCY"||(s?s(a,u,m):m(a,u))},treeshake:{moduleSideEffects:"no-external",propertyReadSideEffects:!0,unknownGlobalSideEffects:!1}}},outputOptions(s){return{...s,chunkFileNames:s.chunkFileNames||"[name]-[hash].d.ts",entryFileNames:s.entryFileNames||"[name].d.ts",format:"es",exports:"named",compact:!1,freeze:!0,interop:"esModule",generatedCode:Object.assign({symbols:!1},s.generatedCode),strict:!1}},transform(s,o,a){const u=Q(o),m=this.getModuleIds(),f=Array.from(m).find(v=>Q(v)===u),d=!!(f&&this.getModuleInfo(f)?.isEntry),h=!!(f&&X.test(f));let l=U(o,s);const y=dn({sourceFile:l,isEntry:d,isJSON:h});e.set(l.fileName,y.typeReferences),t.set(l.fileName,y.fileReferences),s=y.code.toString(),l=U(o,s);const x=xn({sourceFile:l});if(process.env.DTS_DUMP_AST&&(console.log(o),console.log(s),console.log(JSON.stringify(x.ast.body,void 0,2))),!n)return{code:s,ast:x.ast};const S=y.code.generateMap({hires:!0,source:o});return _.test(o)&&r.set(o,{fileName:o,originalCode:s,inputMapText:a}),{code:s,ast:x.ast,map:S}},renderChunk(s,o,a){const u=U(o.fileName,s),m=new on(u),f=new Set,d=new Set;for(const S of Object.keys(o.modules)){for(const v of e.get(S.split("\\").join("/"))||[])f.add(v);for(const v of t.get(S.split("\\").join("/"))||[])if(v.startsWith(".")){const p=N.join(N.dirname(S),v),g=a.file&&N.dirname(a.file)||o.facadeModuleId&&N.dirname(o.facadeModuleId)||".";let E=N.relative(g,p).split("\\").join("/");E[0]!=="."&&(E="./"+E),d.add(E)}else d.add(v)}let h=Ve(Array.from(d,S=>`/// <reference path="${S}" />`));h+=Ve(Array.from(f,S=>`/// <reference types="${S}" />`)),h+=m.fix(),h||(h+=`
33
- export { };`);const y=new mn(o.fileName,h).fix();return new vn(o.fileName,"magicCode"in y&&y.magicCode?y.magicCode:new W(h),!!a.sourcemap,"./"+N.basename(o.fileName,".d.ts")).fix()},async generateBundle(s,o){if(!s.sourcemap)return;const a=new Map,u=Array.from(r.entries()),m=await Promise.all(u.map(async([h,l])=>({fileName:h,inputMap:await Nn(l)}))),f=c(h=>/^[a-z][a-z0-9+.-]*:\/\//i.test(h),"isUrl");for(const{fileName:h,inputMap:l}of m)if(l&&l.sources){const y=N.dirname(h);let x;l.sourceRoot?x=f(l.sourceRoot)?l.sourceRoot:N.resolve(y,l.sourceRoot):x=y;const S=f(x);a.set(h,{version:l.version??3,sources:l.sources.map(v=>{if(v===null)return null;if(f(v))return v;if(S){const p=x.endsWith("/")?x:x+"/";return new URL(v,p).toString()}return N.isAbsolute(v)?v:N.resolve(x,v)}),mappings:l.mappings,names:l.names})}const d=s.dir||(s.file?N.dirname(s.file):process.cwd());for(const h of Object.values(o)){if(h.type!=="chunk"||!h.map)continue;const l=N.join(d,N.dirname(h.fileName)),y=c(C=>f(C)?C:(N.isAbsolute(C)?N.relative(l,C):C).replaceAll("\\","/"),"toRelativeSourcePath"),x=c(C=>C===null?null:y(C),"toRelativeSourcePathOrNull"),S=new Map;for(const C of h.map.sources){if(!C||f(C))continue;const D=N.resolve(l,C);let F=a.get(D);if(!F&&/\.[cm]?[tj]sx?$/.test(D)&&!D.endsWith(".d.ts")){const b=D.replace(/\.[cm]?[tj]sx?$/,".d.ts");F=a.get(b)}F&&S.set(D,F)}if(S.size===0){if(delete h.map.sourcesContent,h.map.sources.length===0&&h.facadeModuleId){const C=a.get(h.facadeModuleId);if(C&&C.sources.length>0){const D=C.sources.map(x);h.map.sources=D}}Je(o,h.fileName,{sources:h.map.sources.map(x),mappings:h.map.mappings,names:h.map.names||[]});continue}const p=h.map.sources.length===1&&S.size===1?Array.from(S.values())[0]:null,g=p&&p.sources.length===1;let E,T,O;if(g&&p)E=p.sources.map(x),T=En(h.map.mappings,p,h.code),O=p.names||[];else{const C=new Set,D=qt(h.map,F=>{const b=N.resolve(l,F);if(C.has(b))return null;C.add(b);const R=S.get(b);return R||null});E=D.sources.map(x),T=typeof D.mappings=="string"?D.mappings:"",O=D.names||[]}h.map.sources=E,delete h.map.sourcesContent,h.map.mappings=T,h.map.names=O,Je(o,h.fileName,{sources:E,mappings:T,names:O})}}}},"transform");function Ve(n){return n.length?n.join(`
34
- `)+`
35
- `:""}c(Ve,"writeBlock");function Je(n,e,t){const r=`${e}.map`,s=n[r];s&&s.type==="asset"&&(s.source=JSON.stringify({version:3,file:N.basename(e),...t}))}c(Je,"updateSourcemapAsset");const Cn=/\.([cm]ts|[tj]sx?)$/;function re({entries:n,programs:e,resolvedOptions:t},r,s){const{compilerOptions:o,tsconfig:a}=t;if(!e.length&&_.test(r))return{code:s};const u=n.includes(r),m=e.find(f=>{if(u)return f.getRootFileNames().includes(r);{const d=f.getSourceFile(r);return d&&f.isSourceFileFromExternalLibrary(d)?!1:!!d}});if(m){const f=m.getSourceFile(r);return{code:f?.getFullText(),source:f,program:m}}else if(i.sys.fileExists(r)){if(e.length>0&&_.test(r)&&(t.includeExternal.length>0||t.respectExternal))return{code:s};const f=en(r,o,a,t.sourcemap);e.push(f);const d=f.getSourceFile(r);return{code:d?.getFullText(),source:d,program:f}}else return null}c(re,"getModule");const We=c((n={})=>{const e={entries:[],programs:[],resolvedOptions:Yt(n)},t=Tn(e.resolvedOptions.sourcemap);return{name:"dts",outputOptions:t.outputOptions,renderChunk:t.renderChunk,generateBundle:t.generateBundle,options(r){let{input:s=[]}=r;if(!Array.isArray(s))s=typeof s=="string"?[s]:Object.values(s);else if(s.length>1){r.input={};for(const o of s){let a=Q(o);N.isAbsolute(o)?a=N.basename(a):a=N.normalize(a),r.input[a]=o}}return e.programs=tn(Object.values(s),e.resolvedOptions.compilerOptions,e.resolvedOptions.tsconfig,e.resolvedOptions.sourcemap),t.options.call(this,r)},transform(r,s){if(!Cn.test(s)&&!X.test(s))return null;const o=c(f=>{if(f.program){const d=N.dirname(s);f.program.getSourceFiles().map(l=>l.fileName).filter(l=>l.startsWith(d)).forEach(this.addWatchFile)}},"watchFiles"),a=c(()=>{const f=re(e,s,r);return f?(o(f),t.transform.call(this,f.code,s)):null},"handleDtsFile"),u=c(()=>{const f=Le(s),d=re(e,f,r);return d?(o(d),t.transform.call(this,d.code,f)):null},"treatTsAsDts"),m=c(()=>{const f=re(e,s,r);if(!f||!f.source||!f.program)return null;o(f);const d=Le(s);let h,l;const{emitSkipped:y,diagnostics:x}=f.program.emit(f.source,(v,p)=>{v.endsWith(".map")?l=p:h=p},void 0,!0,void 0,!0);if(y){const v=x.filter(p=>p.category===i.DiagnosticCategory.Error);v.length&&(console.error(i.formatDiagnostics(v,Y)),this.error("Failed to compile. Check the logs above."))}if(!h)return null;const S=h.replace(/\n?\/\/# sourceMappingURL=[^\n]+/,"");return t.transform.call(this,S,d,l)},"generateDts");return _.test(s)?a():X.test(s)?m():u()??m()},resolveId(r,s){if(!s){e.entries.push(N.resolve(r));return}s=s.split("\\").join("/");let o=e.resolvedOptions.compilerOptions;if(e.resolvedOptions.tsconfig){const u=r.startsWith(".")?N.resolve(N.dirname(s),r):r;o=Z(u,e.resolvedOptions.compilerOptions,e.resolvedOptions.tsconfig,e.resolvedOptions.sourcemap).compilerOptions}const{resolvedModule:a}=i.resolveModuleName(r,s,o,i.sys);if(a)return a.isExternalLibraryImport&&a.packageId&&e.resolvedOptions.includeExternal.includes(a.packageId.name)?{id:N.resolve(a.resolvedFileName)}:!e.resolvedOptions.respectExternal&&a.isExternalLibraryImport?{id:r,external:!0}:{id:N.resolve(a.resolvedFileName)}}}},"plugin");export{We as default,We as dts};