@stacksjs/build 0.75.538 → 0.75.539

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.
Files changed (2) hide show
  1. package/dist/index.js +119 -119
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -1,53 +1,53 @@
1
1
  // @bun
2
- var me=(e,t,i)=>()=>{if(e)try{t=e(e=0)}catch(r){i=[r]}if(i)throw i[0];return t};var Xd=import.meta.require;function or(e){if(ih)return Bun.hash(e);let t=0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);t=(t<<5)-t+r,t=t&t}return t}var ih;var Bo=me(()=>{ih=typeof globalThis.Bun?.hash==="function"});import{existsSync as Hr,mkdirSync as rh,readFileSync as jo,renameSync as nh,rmdirSync as oh,rmSync as ol,statSync as rl,writeFileSync as sl}from"fs";import{join as Go,relative as Kr,resolve as nl}from"path";function sh(e){try{ol(Go(e,al),{force:!0});try{oh(e)}catch{}}catch{}}class Vo{cacheDir;manifestPath;manifest=null;configHash;constructor(e,t){this.cacheDir=nl(e.cwd,e.cacheDir??qr),this.manifestPath=Go(this.cacheDir,al),this.configHash=this.hashConfig(e,t)}hashConfig(e,t){let i={resolutionContext:t,keepComments:e.keepComments,importOrder:e.importOrder,outputStructure:e.outputStructure,moduleSpecifierMode:e.moduleSpecifierMode??"preserve",root:nl(e.cwd,e.root),exclude:e.exclude??[],isolatedDeclarations:e.isolatedDeclarations,declarationMap:e.declarationMap,indentStyle:e.indentStyle,indentSize:e.indentSize,prettier:e.prettier,typeMappings:e.typeMappings?{includeDefaults:e.typeMappings.includeDefaults,presets:e.typeMappings.presets,cacheKey:e.typeMappings.cacheKey,rules:e.typeMappings.rules.map((r)=>({pattern:typeof r.pattern==="string"?{kind:"string",value:r.pattern}:{kind:"regex",source:r.pattern.source,flags:r.pattern.flags},replacement:r.replacement,global:r.global,priority:r.priority,hasCondition:Boolean(r.condition)}))}:void 0,lineEnding:e.lineEnding,normalizeOutput:e.normalizeOutput,declarationOrder:e.declarationOrder,plugins:e.plugins?.map((r)=>({name:r.name,version:r.version,cacheKey:r.cacheKey}))};return String(or(JSON.stringify(i)))}hashString(e){return String(or(e))}load(){try{if(!Hr(this.manifestPath))return!1;let e=jo(this.manifestPath,"utf-8"),t=JSON.parse(e);if(t.version!==_o)return!1;if(t.configHash!==this.configHash)return!1;if(!t.entries||typeof t.entries!=="object"||Array.isArray(t.entries))return!1;return this.manifest=t,!0}catch{return!1}}save(){if(!this.manifest)this.manifest={version:_o,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};if(this.manifest.updatedAt=Date.now(),!Hr(this.cacheDir))rh(this.cacheDir,{recursive:!0});let e=`${this.manifestPath}.${process.pid}.tmp`;try{sl(e,JSON.stringify(this.manifest,null,2)),nh(e,this.manifestPath)}finally{if(Hr(e))ol(e,{force:!0})}}needsRegeneration(e,t){return this.getCachedIfValid(e,t)===null}getCached(e,t){return this.getCachedIfValid(e,t)}getCachedIfValid(e,t){if(!this.manifest)return null;let i=Kr(t,e),r=this.manifest.entries[i];if(!r)return null;if(typeof r.dtsContent!=="string"||typeof r.dtsHash!=="string"||r.configHash!==this.configHash||this.hashString(r.dtsContent)!==r.dtsHash)return null;try{let n=rl(e),{mtimeMs:o,ctimeMs:s}=n;if(n.size!==r.sourceSize)return null;if(o!==r.sourceMtime||s!==r.sourceCtime){let l=jo(e,"utf-8");if(this.hashString(l)!==r.sourceHash)return null;r.sourceMtime=o,r.sourceCtime=s}return r.dtsContent}catch{return null}}update(e,t,i,r){if(!this.manifest)this.manifest={version:_o,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};let n=Kr(r,e),o,s,l;try{let a=rl(e);o=a.mtimeMs,s=a.ctimeMs,l=a.size}catch{o=Date.now(),s=o,l=Buffer.byteLength(t)}this.manifest.entries[n]={sourcePath:n,sourceHash:this.hashString(t),sourceMtime:o,sourceCtime:s,sourceSize:l,dtsContent:i,dtsHash:this.hashString(i),generatedAt:Date.now(),configHash:this.configHash}}remove(e,t){if(!this.manifest)return;let i=Kr(t,e);delete this.manifest.entries[i]}clear(){this.manifest=null,sh(this.cacheDir)}getStats(){if(!this.manifest)return{entries:0,size:0};let e=Object.keys(this.manifest.entries).length,t=0;for(let i of Object.values(this.manifest.entries))t+=i.dtsContent.length;return{entries:e,size:t}}prune(e,t){if(!this.manifest)return 0;let i=0,r=new Set(Array.from(e).map((n)=>Kr(t,n)));for(let n of Object.keys(this.manifest.entries))if(!r.has(n))delete this.manifest.entries[n],i++;return i}}function ll(e){let t=Go(e,".gitignore");try{let i="";if(Hr(t))i=jo(t,"utf-8");if(!i.split(/\r?\n/).some((r)=>r.trim()===qr||r.trim()===`${qr}/`)){let r=i.trimEnd(),n=`${r}${r?`
2
+ var me=(e,t,i)=>()=>{if(e)try{t=e(e=0)}catch(r){i=[r]}if(i)throw i[0];return t};var Xd=import.meta.require;function sr(e){if(ih)return Bun.hash(e);let t=0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);t=(t<<5)-t+r,t=t&t}return t}var ih;var jo=me(()=>{ih=typeof globalThis.Bun?.hash==="function"});import{existsSync as Hr,mkdirSync as rh,readFileSync as Vo,renameSync as nh,rmdirSync as oh,rmSync as sl,statSync as nl,writeFileSync as al}from"fs";import{join as Uo,relative as Kr,resolve as ol}from"path";function sh(e){try{sl(Uo(e,ll),{force:!0});try{oh(e)}catch{}}catch{}}class zo{cacheDir;manifestPath;manifest=null;configHash;constructor(e,t){this.cacheDir=ol(e.cwd,e.cacheDir??qr),this.manifestPath=Uo(this.cacheDir,ll),this.configHash=this.hashConfig(e,t)}hashConfig(e,t){let i={resolutionContext:t,keepComments:e.keepComments,importOrder:e.importOrder,outputStructure:e.outputStructure,moduleSpecifierMode:e.moduleSpecifierMode??"preserve",root:ol(e.cwd,e.root),exclude:e.exclude??[],isolatedDeclarations:e.isolatedDeclarations,declarationMap:e.declarationMap,indentStyle:e.indentStyle,indentSize:e.indentSize,prettier:e.prettier,typeMappings:e.typeMappings?{includeDefaults:e.typeMappings.includeDefaults,presets:e.typeMappings.presets,cacheKey:e.typeMappings.cacheKey,rules:e.typeMappings.rules.map((r)=>({pattern:typeof r.pattern==="string"?{kind:"string",value:r.pattern}:{kind:"regex",source:r.pattern.source,flags:r.pattern.flags},replacement:r.replacement,global:r.global,priority:r.priority,hasCondition:Boolean(r.condition)}))}:void 0,lineEnding:e.lineEnding,normalizeOutput:e.normalizeOutput,declarationOrder:e.declarationOrder,plugins:e.plugins?.map((r)=>({name:r.name,version:r.version,cacheKey:r.cacheKey}))};return String(sr(JSON.stringify(i)))}hashString(e){return String(sr(e))}load(){try{if(!Hr(this.manifestPath))return!1;let e=Vo(this.manifestPath,"utf-8"),t=JSON.parse(e);if(t.version!==Go)return!1;if(t.configHash!==this.configHash)return!1;if(!t.entries||typeof t.entries!=="object"||Array.isArray(t.entries))return!1;return this.manifest=t,!0}catch{return!1}}save(){if(!this.manifest)this.manifest={version:Go,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};if(this.manifest.updatedAt=Date.now(),!Hr(this.cacheDir))rh(this.cacheDir,{recursive:!0});let e=`${this.manifestPath}.${process.pid}.tmp`;try{al(e,JSON.stringify(this.manifest,null,2)),nh(e,this.manifestPath)}finally{if(Hr(e))sl(e,{force:!0})}}needsRegeneration(e,t){return this.getCachedIfValid(e,t)===null}getCached(e,t){return this.getCachedIfValid(e,t)}getCachedIfValid(e,t){if(!this.manifest)return null;let i=Kr(t,e),r=this.manifest.entries[i];if(!r)return null;if(typeof r.dtsContent!=="string"||typeof r.dtsHash!=="string"||r.configHash!==this.configHash||this.hashString(r.dtsContent)!==r.dtsHash)return null;try{let n=nl(e),{mtimeMs:o,ctimeMs:s}=n;if(n.size!==r.sourceSize)return null;if(o!==r.sourceMtime||s!==r.sourceCtime){let l=Vo(e,"utf-8");if(this.hashString(l)!==r.sourceHash)return null;r.sourceMtime=o,r.sourceCtime=s}return r.dtsContent}catch{return null}}update(e,t,i,r){if(!this.manifest)this.manifest={version:Go,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};let n=Kr(r,e),o,s,l;try{let a=nl(e);o=a.mtimeMs,s=a.ctimeMs,l=a.size}catch{o=Date.now(),s=o,l=Buffer.byteLength(t)}this.manifest.entries[n]={sourcePath:n,sourceHash:this.hashString(t),sourceMtime:o,sourceCtime:s,sourceSize:l,dtsContent:i,dtsHash:this.hashString(i),generatedAt:Date.now(),configHash:this.configHash}}remove(e,t){if(!this.manifest)return;let i=Kr(t,e);delete this.manifest.entries[i]}clear(){this.manifest=null,sh(this.cacheDir)}getStats(){if(!this.manifest)return{entries:0,size:0};let e=Object.keys(this.manifest.entries).length,t=0;for(let i of Object.values(this.manifest.entries))t+=i.dtsContent.length;return{entries:e,size:t}}prune(e,t){if(!this.manifest)return 0;let i=0,r=new Set(Array.from(e).map((n)=>Kr(t,n)));for(let n of Object.keys(this.manifest.entries))if(!r.has(n))delete this.manifest.entries[n],i++;return i}}function cl(e){let t=Uo(e,".gitignore");try{let i="";if(Hr(t))i=Vo(t,"utf-8");if(!i.split(/\r?\n/).some((r)=>r.trim()===qr||r.trim()===`${qr}/`)){let r=i.trimEnd(),n=`${r}${r?`
3
3
 
4
4
  `:""}# dtsx cache
5
5
  ${qr}/
6
- `;sl(t,n)}}catch{}}var _o=24,qr=".dtsx-cache",al="manifest.json";var cl=me(()=>{Bo()});import{readFile as ah,stat as Y0,writeFile as lh}from"fs/promises";async function fl(e,t){if(Jr)return globalThis.Bun.write(e,t);let i=typeof t==="string"?t:t instanceof ArrayBuffer?Buffer.from(t):t;return await lh(e,i),typeof t==="string"?Buffer.byteLength(t):t.byteLength}async function vt(e){if(Jr)return globalThis.Bun.file(e).text();return ah(e,"utf-8")}var Jr,X0;var sr=me(()=>{Jr=typeof globalThis.Bun<"u",X0=!Jr&&typeof process<"u"&&!!process.versions?.node});function ul(e,t){let i=Number.isFinite(t)?Math.max(1,Math.floor(t)):1;if(e===void 0||!Number.isFinite(e))return i;return Math.max(1,Math.floor(e))}var dl=()=>{};function Qr(e){return e.endsWith(".vue")}function ch(e){let t={script:null,scriptSetup:null},i=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,r;while((r=i.exec(e))!==null){let n=r[1]||"",o=/lang\s*=\s*["']([^"']+)["']/i.exec(n)?.[1]?.toLowerCase()??"js",s={content:r[2]??"",attrs:n,setup:/\bsetup\b/.test(n),lang:o};if(s.setup)t.scriptSetup=s;else t.script=s}return t}function bt(e,t){let i=e[t];t++;while(t<e.length){let r=e[t];if(r==="\\"){t+=2;continue}if(r===i)return t+1;t++}return t}function xt(e,t){t++;let i=0;while(t<e.length){let r=e[t];if(r==="\\"){t+=2;continue}if(r==="`"&&i===0)return t+1;if(r==="$"&&e[t+1]==="{"){i++,t+=2;continue}if(r==="}"){if(i>0)i--;t++;continue}t++}return t}function Wt(e,t){if(e[t+1]==="/"){let i=e.indexOf(`
7
- `,t+2);return i===-1?e.length:i+1}if(e[t+1]==="*"){let i=e.indexOf("*/",t+2);return i===-1?e.length:i+2}return t+1}function zo(e,t){let i=e[t];if(i==='"'||i==="'")return bt(e,t);if(i==="`")return xt(e,t);if(i==="/"&&(e[t+1]==="/"||e[t+1]==="*"))return Wt(e,t);return t}function Ko(e){let t=e.split(""),i=0;while(i<e.length){let r=zo(e,i);if(r>i){for(let n=i;n<r;n++)if(t[n]!==`
8
- `&&t[n]!=="\r")t[n]=" ";i=r;continue}i++}return t.join("")}function nt(e,t,i,r){let n=0,o=t;while(o<e.length){let s=e[o];if(s==='"'||s==="'"){o=bt(e,o);continue}if(s==="`"){o=xt(e,o);continue}if(s==="/"&&(e[o+1]==="/"||e[o+1]==="*")){o=Wt(e,o);continue}if(s===i)n++;else if(s===r){if(n--,n===0)return o}o++}return-1}function Ho(e,t){let i=0,r=t;while(r<e.length){let n=e[r];if(n==='"'||n==="'"){r=bt(e,r);continue}if(n==="`"){r=xt(e,r);continue}if(n==="/"&&(e[r+1]==="/"||e[r+1]==="*")){r=Wt(e,r);continue}if(n==="="&&e[r+1]===">"){r+=2;continue}if(n==="<")i++;else if(n===">"){if(i--,i===0)return r}r++}return-1}function Oi(e,t=","){let i=[],r=0,n="",o=0;while(o<e.length){let s=e[o];if(s==='"'||s==="'"){let l=bt(e,o);n+=e.slice(o,l),o=l;continue}if(s==="`"){let l=xt(e,o);n+=e.slice(o,l),o=l;continue}if(s==="/"&&(e[o+1]==="/"||e[o+1]==="*")){o=Wt(e,o);continue}if(s==="{"||s==="["||s==="("||s==="<")r++;else if(s==="}"||s==="]"||s===")"||s===">")r--;if(s===t&&r===0){i.push(n),n="",o++;continue}n+=s,o++}if(n.trim()!=="")i.push(n);return i}function cr(e){let t=e.trim();if(!t.startsWith("{"))return[];let i=nt(t,0,"{","}");if(i===-1)return[];let r=t.slice(1,i),n=[];for(let o of Oi(r)){let s=-1,l=0;for(let u=0;u<o.length;u++){let d=o[u];if(d==='"'||d==="'"){u=bt(o,u)-1;continue}if(d==="`"){u=xt(o,u)-1;continue}if(d==="{"||d==="["||d==="("||d==="<")l++;else if(d==="}"||d==="]"||d===")"||d===">")l--;else if(d===":"&&l===0){s=u;break}}if(s!==-1){n.push({key:ar(o.slice(0,s).trim()),value:o.slice(s+1).trim(),isMethod:!1});continue}let a=/^([A-Za-z_$][\w$]*|['"][^'"]+['"])\s*\(/.exec(o.trim());if(a){n.push({key:ar(a[1]),value:o.trim(),isMethod:!0});continue}let f=o.trim();if(f)n.push({key:ar(f),value:"",isMethod:!1})}return n}function ar(e){if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);return e}function lr(e){return/^[A-Za-z_$][\w$]*$/.test(e)?e:JSON.stringify(e)}function fr(e,t){let i=new RegExp(`\\b${t}\\b`,"g"),r;while((r=i.exec(e))!==null){let n=r.index+r[0].length;while(n<e.length&&/\s/.test(e[n]))n++;let o=null;if(e[n]==="<"){let a=Ho(e,n);if(a===-1)return null;o=e.slice(n+1,a).trim(),n=a+1;while(n<e.length&&/\s/.test(e[n]))n++}if(e[n]!=="(")continue;let s=nt(e,n,"(",")");if(s===-1)return null;let l=Oi(e.slice(n+1,s));return{generic:o,arg:l.length>0?l[0].trim():null}}return null}function fh(e,t){let i=pl(e,t);if(!i)return null;return i.kind==="interface"?e.slice(i.bodyStart,i.end):e.slice(i.bodyStart,i.end).trim()}function pl(e,t){let i=new RegExp(`\\binterface\\s+${t}\\b[^{]*\\{`,"m").exec(e);if(i){let n=i.index+i[0].length-1,o=nt(e,n,"{","}");if(o!==-1)return{kind:"interface",start:i.index,end:o+1,bodyStart:n}}let r=new RegExp(`\\btype\\s+${t}\\b[^=]*=`,"m").exec(e);if(r){let n=r.index+r[0].length,o=0,s=n;while(n<e.length){let l=e[n];if(l==='"'||l==="'"){n=bt(e,n);continue}if(l==="`"){n=xt(e,n);continue}if(l==="{"||l==="["||l==="("||l==="<")o++;else if(l==="}"||l==="]"||l===")"||l===">")o--;else if((l===";"||l===`
9
- `)&&o===0)break;n++}return{kind:"type",start:r.index,end:n,bodyStart:s}}return null}function uh(e){let t=e.search(/\bas\s+PropType\s*</);if(t===-1)return null;let i=e.indexOf("<",t),r=Ho(e,i);if(r===-1)return null;if(e.slice(r+1).trim()!=="")return null;return e.slice(i+1,r).trim()}function Uo(e){let t=e.trim(),i=uh(t);if(i!==null)return{type:i,optional:!0};if(t==="null")return{type:"unknown",optional:!0};if(t.startsWith("[")){let r=nt(t,0,"[","]");if(r!==-1){let n=Oi(t.slice(1,r)).map((o)=>Uo(o).type).filter((o)=>o!=="unknown");return{type:n.length>0?[...new Set(n)].join(" | "):"unknown",optional:!0}}}if(t.startsWith("{")){let r=cr(t),n=r.find((a)=>a.key==="type"),o=r.find((a)=>a.key==="required"),s=n?Uo(n.value).type:"unknown",l=!(o&&o.value.trim()==="true");return{type:s,optional:l}}if(hl[t])return{type:hl[t],optional:!0};if(/^[A-Za-z_$][\w$.]*$/.test(t))return{type:t,optional:!0};return{type:"unknown",optional:!0}}function en(e){let t=e.trim();if(t.startsWith("{")){let i=cr(t);if(i.length===0)return"{}";return`{ ${i.map((r)=>{if(r.isMethod||r.value==="")return`${lr(r.key)}?: unknown`;let n=Uo(r.value);return`${lr(r.key)}${n.optional?"?":""}: ${n.type}`}).join(", ")} }`}if(t.startsWith("[")){let i=nt(t,0,"[","]");if(i===-1)return null;let r=Oi(t.slice(1,i)).map((n)=>ar(n.trim())).filter((n)=>n!=="");if(r.length===0)return"{}";return`{ ${r.map((n)=>`${lr(n)}?: unknown`).join(", ")} }`}return null}function dh(e){let t=e.trim();if(!t.startsWith("["))return null;let i=nt(t,0,"[","]");if(i===-1)return null;let r=Oi(t.slice(1,i)).map((n)=>n.trim());if(r.length===0)return"{}";if(!r.every((n)=>n.startsWith("'")&&n.endsWith("'")||n.startsWith('"')&&n.endsWith('"')))return"string[]";return`[${r.map((n)=>JSON.stringify(ar(n))).join(", ")}]`}function hh(e){let t=e.trim();if(!t.startsWith("{"))return null;let i=cr(t);if(i.length===0)return"{}";return`{ ${i.map((r)=>`${JSON.stringify(r.key)}: (...args: any[]) => void`).join(", ")} }`}function ml(e){return dh(e)??hh(e)}function ph(e){let t=[],i=0,r="",n=0;while(n<e.length){let o=e[n];if(o==='"'||o==="'"){let s=bt(e,n);r+=e.slice(n,s),n=s;continue}if(o==="`"){let s=xt(e,n);r+=e.slice(n,s),n=s;continue}if(o==="/"&&(e[n+1]==="/"||e[n+1]==="*")){let s=Wt(e,n);r+=e.slice(n,s),n=s;continue}if(o==="="&&e[n+1]===">"){r+="=>",n+=2;continue}if(o==="{"||o==="["||o==="("||o==="<")i++;else if(o==="}"||o==="]"||o===")"||o===">")i--;if((o===";"||o===","||o===`
10
- `)&&i===0){if(r.trim()!=="")t.push(r.trim());r="",n++;continue}r+=o,n++}if(r.trim()!=="")t.push(r.trim());return t}function mh(e){let t=e.trim();if(!t.startsWith("{"))return null;let i=nt(t,0,"{","}");if(i===-1||t.slice(i+1).trim()!=="")return null;let r=ph(t.slice(1,i));if(r.length===0)return"{}";let n=[];for(let o of r){let s=/^\(\s*\w+\s*:\s*/.exec(o);if(!s)return null;let l=s[0].length,a=o[l];if(a!=="'"&&a!=='"'&&a!=="`")return null;let f=bt(o,l),u=o.slice(l+1,f-1),d=nt(o,o.indexOf("(",0),"(",")");if(d===-1)return null;let h=o.slice(l,d),p=Oi(h).slice(1),m=o.slice(d+1).trim();if(m.startsWith(":"))m=m.slice(1).trim();if(m==="")m="void";n.push(`${JSON.stringify(u)}: (${p.map((c)=>c.trim()).join(", ")}) => ${m}`)}return`{ ${n.join(", ")} }`}function qo(e){let t=e;for(let i of["defineProps","defineEmits","defineExpose","defineSlots","defineOptions"])t=gh(t,i);return t}function gh(e,t){let i=new RegExp(`\\b${t}\\b`,"g"),r=[],n=e,o;while((o=i.exec(e))!==null){let s=e.lastIndexOf(`
11
- `,o.index)+1,l=e.slice(s,o.index),a=/^\s*(?:(?:const|let|var)\s+[A-Za-z_$][\w$]*\s*(?::[^=]+)?=\s*)?(withDefaults\s*\(\s*)?$/.exec(l);if(!a)continue;let f=o.index+o[0].length;while(f<e.length&&/\s/.test(e[f]))f++;if(e[f]==="<"){let h=Ho(e,f);if(h===-1)continue;f=h+1;while(f<e.length&&/\s/.test(e[f]))f++}if(e[f]!=="(")continue;let u=nt(e,f,"(",")");if(u===-1)continue;if(a[1]){let h=s+l.length-a[1].length,p=e.indexOf("(",h);if(p!==-1){let m=nt(e,p,"(",")");if(m!==-1)u=m}}let d=u+1;while(d<e.length&&e[d]!==`
6
+ `;al(t,n)}}catch{}}var Go=24,qr=".dtsx-cache",ll="manifest.json";var fl=me(()=>{jo()});import{readFile as ah,stat as Q0,writeFile as lh}from"fs/promises";async function ul(e,t){if(Jr)return globalThis.Bun.write(e,t);let i=typeof t==="string"?t:t instanceof ArrayBuffer?Buffer.from(t):t;return await lh(e,i),typeof t==="string"?Buffer.byteLength(t):t.byteLength}async function vt(e){if(Jr)return globalThis.Bun.file(e).text();return ah(e,"utf-8")}var Jr,e1;var ar=me(()=>{Jr=typeof globalThis.Bun<"u",e1=!Jr&&typeof process<"u"&&!!process.versions?.node});function dl(e,t){let i=Number.isFinite(t)?Math.max(1,Math.floor(t)):1;if(e===void 0||!Number.isFinite(e))return i;return Math.max(1,Math.floor(e))}var hl=()=>{};function Qr(e){return e.endsWith(".vue")}function ch(e){let t={script:null,scriptSetup:null},i=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,r;while((r=i.exec(e))!==null){let n=r[1]||"",o=/lang\s*=\s*["']([^"']+)["']/i.exec(n)?.[1]?.toLowerCase()??"js",s={content:r[2]??"",attrs:n,setup:/\bsetup\b/.test(n),lang:o};if(s.setup)t.scriptSetup=s;else t.script=s}return t}function bt(e,t){let i=e[t];t++;while(t<e.length){let r=e[t];if(r==="\\"){t+=2;continue}if(r===i)return t+1;t++}return t}function xt(e,t){t++;let i=0;while(t<e.length){let r=e[t];if(r==="\\"){t+=2;continue}if(r==="`"&&i===0)return t+1;if(r==="$"&&e[t+1]==="{"){i++,t+=2;continue}if(r==="}"){if(i>0)i--;t++;continue}t++}return t}function Wt(e,t){if(e[t+1]==="/"){let i=e.indexOf(`
7
+ `,t+2);return i===-1?e.length:i+1}if(e[t+1]==="*"){let i=e.indexOf("*/",t+2);return i===-1?e.length:i+2}return t+1}function Ho(e,t){let i=e[t];if(i==='"'||i==="'")return bt(e,t);if(i==="`")return xt(e,t);if(i==="/"&&(e[t+1]==="/"||e[t+1]==="*"))return Wt(e,t);return t}function qo(e){let t=e.split(""),i=0;while(i<e.length){let r=Ho(e,i);if(r>i){for(let n=i;n<r;n++)if(t[n]!==`
8
+ `&&t[n]!=="\r")t[n]=" ";i=r;continue}i++}return t.join("")}function nt(e,t,i,r){let n=0,o=t;while(o<e.length){let s=e[o];if(s==='"'||s==="'"){o=bt(e,o);continue}if(s==="`"){o=xt(e,o);continue}if(s==="/"&&(e[o+1]==="/"||e[o+1]==="*")){o=Wt(e,o);continue}if(s===i)n++;else if(s===r){if(n--,n===0)return o}o++}return-1}function Jo(e,t){let i=0,r=t;while(r<e.length){let n=e[r];if(n==='"'||n==="'"){r=bt(e,r);continue}if(n==="`"){r=xt(e,r);continue}if(n==="/"&&(e[r+1]==="/"||e[r+1]==="*")){r=Wt(e,r);continue}if(n==="="&&e[r+1]===">"){r+=2;continue}if(n==="<")i++;else if(n===">"){if(i--,i===0)return r}r++}return-1}function Ri(e,t=","){let i=[],r=0,n="",o=0;while(o<e.length){let s=e[o];if(s==='"'||s==="'"){let l=bt(e,o);n+=e.slice(o,l),o=l;continue}if(s==="`"){let l=xt(e,o);n+=e.slice(o,l),o=l;continue}if(s==="/"&&(e[o+1]==="/"||e[o+1]==="*")){o=Wt(e,o);continue}if(s==="{"||s==="["||s==="("||s==="<")r++;else if(s==="}"||s==="]"||s===")"||s===">")r--;if(s===t&&r===0){i.push(n),n="",o++;continue}n+=s,o++}if(n.trim()!=="")i.push(n);return i}function fr(e){let t=e.trim();if(!t.startsWith("{"))return[];let i=nt(t,0,"{","}");if(i===-1)return[];let r=t.slice(1,i),n=[];for(let o of Ri(r)){let s=-1,l=0;for(let u=0;u<o.length;u++){let d=o[u];if(d==='"'||d==="'"){u=bt(o,u)-1;continue}if(d==="`"){u=xt(o,u)-1;continue}if(d==="{"||d==="["||d==="("||d==="<")l++;else if(d==="}"||d==="]"||d===")"||d===">")l--;else if(d===":"&&l===0){s=u;break}}if(s!==-1){n.push({key:lr(o.slice(0,s).trim()),value:o.slice(s+1).trim(),isMethod:!1});continue}let a=/^([A-Za-z_$][\w$]*|['"][^'"]+['"])\s*\(/.exec(o.trim());if(a){n.push({key:lr(a[1]),value:o.trim(),isMethod:!0});continue}let f=o.trim();if(f)n.push({key:lr(f),value:"",isMethod:!1})}return n}function lr(e){if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);return e}function cr(e){return/^[A-Za-z_$][\w$]*$/.test(e)?e:JSON.stringify(e)}function ur(e,t){let i=new RegExp(`\\b${t}\\b`,"g"),r;while((r=i.exec(e))!==null){let n=r.index+r[0].length;while(n<e.length&&/\s/.test(e[n]))n++;let o=null;if(e[n]==="<"){let a=Jo(e,n);if(a===-1)return null;o=e.slice(n+1,a).trim(),n=a+1;while(n<e.length&&/\s/.test(e[n]))n++}if(e[n]!=="(")continue;let s=nt(e,n,"(",")");if(s===-1)return null;let l=Ri(e.slice(n+1,s));return{generic:o,arg:l.length>0?l[0].trim():null}}return null}function fh(e,t){let i=ml(e,t);if(!i)return null;return i.kind==="interface"?e.slice(i.bodyStart,i.end):e.slice(i.bodyStart,i.end).trim()}function ml(e,t){let i=new RegExp(`\\binterface\\s+${t}\\b[^{]*\\{`,"m").exec(e);if(i){let n=i.index+i[0].length-1,o=nt(e,n,"{","}");if(o!==-1)return{kind:"interface",start:i.index,end:o+1,bodyStart:n}}let r=new RegExp(`\\btype\\s+${t}\\b[^=]*=`,"m").exec(e);if(r){let n=r.index+r[0].length,o=0,s=n;while(n<e.length){let l=e[n];if(l==='"'||l==="'"){n=bt(e,n);continue}if(l==="`"){n=xt(e,n);continue}if(l==="{"||l==="["||l==="("||l==="<")o++;else if(l==="}"||l==="]"||l===")"||l===">")o--;else if((l===";"||l===`
9
+ `)&&o===0)break;n++}return{kind:"type",start:r.index,end:n,bodyStart:s}}return null}function uh(e){let t=e.search(/\bas\s+PropType\s*</);if(t===-1)return null;let i=e.indexOf("<",t),r=Jo(e,i);if(r===-1)return null;if(e.slice(r+1).trim()!=="")return null;return e.slice(i+1,r).trim()}function Ko(e){let t=e.trim(),i=uh(t);if(i!==null)return{type:i,optional:!0};if(t==="null")return{type:"unknown",optional:!0};if(t.startsWith("[")){let r=nt(t,0,"[","]");if(r!==-1){let n=Ri(t.slice(1,r)).map((o)=>Ko(o).type).filter((o)=>o!=="unknown");return{type:n.length>0?[...new Set(n)].join(" | "):"unknown",optional:!0}}}if(t.startsWith("{")){let r=fr(t),n=r.find((a)=>a.key==="type"),o=r.find((a)=>a.key==="required"),s=n?Ko(n.value).type:"unknown",l=!(o&&o.value.trim()==="true");return{type:s,optional:l}}if(pl[t])return{type:pl[t],optional:!0};if(/^[A-Za-z_$][\w$.]*$/.test(t))return{type:t,optional:!0};return{type:"unknown",optional:!0}}function en(e){let t=e.trim();if(t.startsWith("{")){let i=fr(t);if(i.length===0)return"{}";return`{ ${i.map((r)=>{if(r.isMethod||r.value==="")return`${cr(r.key)}?: unknown`;let n=Ko(r.value);return`${cr(r.key)}${n.optional?"?":""}: ${n.type}`}).join(", ")} }`}if(t.startsWith("[")){let i=nt(t,0,"[","]");if(i===-1)return null;let r=Ri(t.slice(1,i)).map((n)=>lr(n.trim())).filter((n)=>n!=="");if(r.length===0)return"{}";return`{ ${r.map((n)=>`${cr(n)}?: unknown`).join(", ")} }`}return null}function dh(e){let t=e.trim();if(!t.startsWith("["))return null;let i=nt(t,0,"[","]");if(i===-1)return null;let r=Ri(t.slice(1,i)).map((n)=>n.trim());if(r.length===0)return"{}";if(!r.every((n)=>n.startsWith("'")&&n.endsWith("'")||n.startsWith('"')&&n.endsWith('"')))return"string[]";return`[${r.map((n)=>JSON.stringify(lr(n))).join(", ")}]`}function hh(e){let t=e.trim();if(!t.startsWith("{"))return null;let i=fr(t);if(i.length===0)return"{}";return`{ ${i.map((r)=>`${JSON.stringify(r.key)}: (...args: any[]) => void`).join(", ")} }`}function gl(e){return dh(e)??hh(e)}function ph(e){let t=[],i=0,r="",n=0;while(n<e.length){let o=e[n];if(o==='"'||o==="'"){let s=bt(e,n);r+=e.slice(n,s),n=s;continue}if(o==="`"){let s=xt(e,n);r+=e.slice(n,s),n=s;continue}if(o==="/"&&(e[n+1]==="/"||e[n+1]==="*")){let s=Wt(e,n);r+=e.slice(n,s),n=s;continue}if(o==="="&&e[n+1]===">"){r+="=>",n+=2;continue}if(o==="{"||o==="["||o==="("||o==="<")i++;else if(o==="}"||o==="]"||o===")"||o===">")i--;if((o===";"||o===","||o===`
10
+ `)&&i===0){if(r.trim()!=="")t.push(r.trim());r="",n++;continue}r+=o,n++}if(r.trim()!=="")t.push(r.trim());return t}function mh(e){let t=e.trim();if(!t.startsWith("{"))return null;let i=nt(t,0,"{","}");if(i===-1||t.slice(i+1).trim()!=="")return null;let r=ph(t.slice(1,i));if(r.length===0)return"{}";let n=[];for(let o of r){let s=/^\(\s*\w+\s*:\s*/.exec(o);if(!s)return null;let l=s[0].length,a=o[l];if(a!=="'"&&a!=='"'&&a!=="`")return null;let f=bt(o,l),u=o.slice(l+1,f-1),d=nt(o,o.indexOf("(",0),"(",")");if(d===-1)return null;let h=o.slice(l,d),p=Ri(h).slice(1),m=o.slice(d+1).trim();if(m.startsWith(":"))m=m.slice(1).trim();if(m==="")m="void";n.push(`${JSON.stringify(u)}: (${p.map((c)=>c.trim()).join(", ")}) => ${m}`)}return`{ ${n.join(", ")} }`}function Yo(e){let t=e;for(let i of["defineProps","defineEmits","defineExpose","defineSlots","defineOptions"])t=gh(t,i);return t}function gh(e,t){let i=new RegExp(`\\b${t}\\b`,"g"),r=[],n=e,o;while((o=i.exec(e))!==null){let s=e.lastIndexOf(`
11
+ `,o.index)+1,l=e.slice(s,o.index),a=/^\s*(?:(?:const|let|var)\s+[A-Za-z_$][\w$]*\s*(?::[^=]+)?=\s*)?(withDefaults\s*\(\s*)?$/.exec(l);if(!a)continue;let f=o.index+o[0].length;while(f<e.length&&/\s/.test(e[f]))f++;if(e[f]==="<"){let h=Jo(e,f);if(h===-1)continue;f=h+1;while(f<e.length&&/\s/.test(e[f]))f++}if(e[f]!=="(")continue;let u=nt(e,f,"(",")");if(u===-1)continue;if(a[1]){let h=s+l.length-a[1].length,p=e.indexOf("(",h);if(p!==-1){let m=nt(e,p,"(",")");if(m!==-1)u=m}}let d=u+1;while(d<e.length&&e[d]!==`
12
12
  `&&/\s|;/.test(e[d]))d++;if(e[d]===`
13
- `)d++;r.push([s,d])}for(let s=r.length-1;s>=0;s--)n=n.slice(0,r[s][0])+n.slice(r[s][1]);return n}function Jo(e){let t=yh(e);if(t!==-1){let i=/^export\s+default\b/.exec(e.slice(t))?.[0];if(!i)return{options:null,script:e,passthrough:!1};let r=t+i.length;while(r<e.length&&/\s/.test(e[r]))r++;let n=-1,o=-1,s=-1;if(e[r]==="{")n=r,o=nt(e,r,"{","}"),s=o;else if(e.startsWith("defineComponent",r)){let f=e.indexOf("(",r);if(f!==-1){let u=f+1;while(u<e.length&&/\s/.test(e[u]))u++;if(e[u]==="{")n=u,o=nt(e,u,"{","}"),s=nt(e,f,"(",")")}}if(n===-1||o===-1||s===-1)return{options:null,script:e,passthrough:!0};let l=s+1;if(e[l]===";")l++;let a=(e.slice(0,t)+e.slice(l)).trim();return{options:e.slice(n,o+1),script:a,passthrough:!1}}return{options:null,script:e,passthrough:!1}}function yh(e){let t=0,i=0;while(i<e.length){let r=e[i];if(r==='"'||r==="'"){i=bt(e,i);continue}if(r==="`"){i=xt(e,i);continue}if(r==="/"&&(e[i+1]==="/"||e[i+1]==="*")){i=Wt(e,i);continue}if(r==="{"||r==="["||r==="(")t++;else if(r==="}"||r==="]"||r===")")t=Math.max(0,t-1);else if(t===0&&e.startsWith("export",i)){let n=i===0?"":e[i-1],o=e[i+6]??"";if(!/[\w$]/.test(n)&&!/[\w$]/.test(o)){if(/^export\s+default\b/.exec(e.slice(i)))return i}}i++}return-1}function Yr(e,t){let i=cr(e).find((r)=>r.key===t);return i&&i.value!==""?i.value:null}function Xr(e,t){let i=Ch(e),r=e;for(let n=i.length-1;n>=0;n--){let o=i[n],s=r.slice(0,o.start)+r.slice(o.end);if(wh(s,o.name))continue;if(new RegExp(`\\btypeof\\s+${o.name}\\b`).test(t))continue;r=s}return r}function wh(e,t){let i=0;while(i<e.length){let r=e[i];if(r==='"'||r==="'"){i=bt(e,i);continue}if(r==="`"){i=xt(e,i);continue}if(r==="/"&&(e[i+1]==="/"||e[i+1]==="*")){i=Wt(e,i);continue}if(/[A-Za-z_$]/.test(r)){let n=i+1;while(n<e.length&&/[\w$]/.test(e[n]))n++;if(e.slice(i,n)===t)return!0;i=n;continue}i++}return!1}function Ch(e){let t=[],i=vh(e),r=/^[ \t]*(const|let|var|(?:async[ \t]+)?function)[ \t]+([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=?/gm,n;while((n=r.exec(e))!==null){let o=e.lastIndexOf(`
13
+ `)d++;r.push([s,d])}for(let s=r.length-1;s>=0;s--)n=n.slice(0,r[s][0])+n.slice(r[s][1]);return n}function Xo(e){let t=yh(e);if(t!==-1){let i=/^export\s+default\b/.exec(e.slice(t))?.[0];if(!i)return{options:null,script:e,passthrough:!1};let r=t+i.length;while(r<e.length&&/\s/.test(e[r]))r++;let n=-1,o=-1,s=-1;if(e[r]==="{")n=r,o=nt(e,r,"{","}"),s=o;else if(e.startsWith("defineComponent",r)){let f=e.indexOf("(",r);if(f!==-1){let u=f+1;while(u<e.length&&/\s/.test(e[u]))u++;if(e[u]==="{")n=u,o=nt(e,u,"{","}"),s=nt(e,f,"(",")")}}if(n===-1||o===-1||s===-1)return{options:null,script:e,passthrough:!0};let l=s+1;if(e[l]===";")l++;let a=(e.slice(0,t)+e.slice(l)).trim();return{options:e.slice(n,o+1),script:a,passthrough:!1}}return{options:null,script:e,passthrough:!1}}function yh(e){let t=0,i=0;while(i<e.length){let r=e[i];if(r==='"'||r==="'"){i=bt(e,i);continue}if(r==="`"){i=xt(e,i);continue}if(r==="/"&&(e[i+1]==="/"||e[i+1]==="*")){i=Wt(e,i);continue}if(r==="{"||r==="["||r==="(")t++;else if(r==="}"||r==="]"||r===")")t=Math.max(0,t-1);else if(t===0&&e.startsWith("export",i)){let n=i===0?"":e[i-1],o=e[i+6]??"";if(!/[\w$]/.test(n)&&!/[\w$]/.test(o)){if(/^export\s+default\b/.exec(e.slice(i)))return i}}i++}return-1}function Yr(e,t){let i=fr(e).find((r)=>r.key===t);return i&&i.value!==""?i.value:null}function Xr(e,t){let i=Ch(e),r=e;for(let n=i.length-1;n>=0;n--){let o=i[n],s=r.slice(0,o.start)+r.slice(o.end);if(wh(s,o.name))continue;if(new RegExp(`\\btypeof\\s+${o.name}\\b`).test(t))continue;r=s}return r}function wh(e,t){let i=0;while(i<e.length){let r=e[i];if(r==='"'||r==="'"){i=bt(e,i);continue}if(r==="`"){i=xt(e,i);continue}if(r==="/"&&(e[i+1]==="/"||e[i+1]==="*")){i=Wt(e,i);continue}if(/[A-Za-z_$]/.test(r)){let n=i+1;while(n<e.length&&/[\w$]/.test(e[n]))n++;if(e.slice(i,n)===t)return!0;i=n;continue}i++}return!1}function Ch(e){let t=[],i=vh(e),r=/^[ \t]*(const|let|var|(?:async[ \t]+)?function)[ \t]+([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=?/gm,n;while((n=r.exec(e))!==null){let o=e.lastIndexOf(`
14
14
  `,n.index)+1;if(!i.has(o))continue;if(/\bexport\b/.test(e.slice(o,n.index)))continue;let s=n[1],l=n[2],a=n.index+n[0].length,f=-1;if(s.endsWith("function")){let u=e.indexOf("(",a);if(u===-1)continue;let d=nt(e,u,"(",")");if(d===-1)continue;a=d+1;while(a<e.length&&/\s/.test(e[a]))a++;if(e[a]===":")while(a<e.length&&e[a]!=="{"&&e[a]!==`
15
15
  `)a++;while(a<e.length&&/\s/.test(e[a])&&e[a]!==`
16
16
  `)a++;if(e[a]!=="{")continue;let h=nt(e,a,"{","}");if(h===-1)continue;f=h+1}else{let u=0;while(a<e.length){let d=e[a];if(d==='"'||d==="'"){a=bt(e,a);continue}if(d==="`"){a=xt(e,a);continue}if(d==="/"&&(e[a+1]==="/"||e[a+1]==="*")){a=Wt(e,a);continue}if(d==="{"||d==="["||d==="(")u++;else if(d==="}"||d==="]"||d===")")u--;else if(d===";"&&u===0){f=a+1;break}else if(d===`
17
17
  `&&u===0){f=a;break}a++}if(f===-1)f=e.length}if(e[f]===`
18
18
  `)f++;t.push({name:l,start:n.index,end:f})}return t}function vh(e){let t=new Set([0]),i=0,r=0;while(r<e.length){let n=e[r];if(n==='"'||n==="'"){r=bt(e,r);continue}if(n==="`"){r=xt(e,r);continue}if(n==="/"&&(e[r+1]==="/"||e[r+1]==="*")){r=Wt(e,r);continue}if(n==="{"||n==="["||n==="(")i++;else if(n==="}"||n==="]"||n===")")i=Math.max(0,i-1);if(n===`
19
19
  `&&i===0)t.add(r+1);r++}return t}function Zr(e,t,i){let r=e.indexOf(i);if(r===-1)return e;let n=e.lastIndexOf(`
20
- `,r)+1;if(/\bexport\b/.test(e.slice(n,r)))return e;let o=e.slice(0,r)+e.slice(r+i.length);if(new RegExp(`\\b${t}\\b`).test(o))return e;return o}function Yo(e){let t="",i=0,r=()=>{for(let o=t.length-1;o>=0;o--)if(!/\s/.test(t[o]))return t[o];return""},n=(o)=>{for(let s=o;s<e.length;s++)if(!/\s/.test(e[s]))return e[s];return""};while(i<e.length){let o=e[i];if(o==='"'||o==="'"){let s=bt(e,i);t+=e.slice(i,s),i=s;continue}if(o==="`"){let s=xt(e,i);t+=e.slice(i,s),i=s;continue}if(o==="/"&&e[i+1]==="*"){let s=Wt(e,i);t+=e.slice(i,s).replace(/\s*\n\s*/g," "),i=s;continue}if(o==="/"&&e[i+1]==="/"){let s=i+2;while(s<e.length&&e[s]!==`
20
+ `,r)+1;if(/\bexport\b/.test(e.slice(n,r)))return e;let o=e.slice(0,r)+e.slice(r+i.length);if(new RegExp(`\\b${t}\\b`).test(o))return e;return o}function Zo(e){let t="",i=0,r=()=>{for(let o=t.length-1;o>=0;o--)if(!/\s/.test(t[o]))return t[o];return""},n=(o)=>{for(let s=o;s<e.length;s++)if(!/\s/.test(e[s]))return e[s];return""};while(i<e.length){let o=e[i];if(o==='"'||o==="'"){let s=bt(e,i);t+=e.slice(i,s),i=s;continue}if(o==="`"){let s=xt(e,i);t+=e.slice(i,s),i=s;continue}if(o==="/"&&e[i+1]==="*"){let s=Wt(e,i);t+=e.slice(i,s).replace(/\s*\n\s*/g," "),i=s;continue}if(o==="/"&&e[i+1]==="/"){let s=i+2;while(s<e.length&&e[s]!==`
21
21
  `)s++;let l=e.slice(i+2,s).trim();if(l!==""&&!l.includes("*/"))t+=`/* ${l} */`;i=s;continue}if(o===`
22
- `){let s=r(),l=n(i+1);if(s===""||l===""){i++;continue}let a=bh(t);if(!a&&("{;,(<:=[".includes(s)||"}),]>;|&".includes(l))){if(!t.endsWith(" ")&&!t.endsWith(";"))t+=" "}else if(a){if(!t.endsWith(" "))t+=" "}else{if(t.endsWith(" "))t=t.slice(0,-1);t+="; "}i++;while(i<e.length&&(e[i]===" "||e[i]==="\t"))i++;continue}t+=o,i++}return t}function bh(e){let t=e.length-1;while(t>=0&&/\s/.test(e[t]))t--;if(t<1||e[t]!=="/"||e[t-1]!=="*")return!1;let i=e.lastIndexOf("/*",t);if(i===-1)return!1;for(let r=i-1;r>=0;r--){let n=e[r];if(/\s/.test(n))continue;return"{;,(<:".includes(n)}return!0}function tn(e,t){let i=[e,t].filter((r)=>r!==null);for(let r of i){let n=fr(r,"defineProps");if(!n)continue;if(n.generic){let o=n.generic;if(o.startsWith("{"))return{type:o};if(/^[A-Za-z_$][\w$]*$/.test(o)){for(let s of i){let l=pl(s,o);if(!l)continue;let a=fh(s,o);if(a===null)continue;return{type:a,inlinedLocal:{name:o,declText:s.slice(l.start,l.end)}}}return{type:o}}return{type:o}}if(n.arg){let o=en(n.arg);if(o!==null)return{type:o}}}return null}function Xo(e,t){let i=[e,t].filter((r)=>r!==null);for(let r of i){let n=fr(r,"defineEmits");if(!n)continue;if(n.generic)return mh(n.generic)??n.generic;if(n.arg){let o=ml(n.arg);if(o!==null)return o}}return null}function Zo(e,t){let i=[e,t].filter((r)=>r!==null);for(let r of i){let n=fr(r,"defineExpose");if(!n||!n.arg||!n.arg.startsWith("{"))continue;let o=cr(n.arg);if(o.length===0)return null;return`{ ${o.map((s)=>{if(s.value===""&&/^[A-Za-z_$][\w$]*$/.test(s.key))return`${lr(s.key)}: typeof ${s.key}`;let l=s.isMethod||/=>|^\s*function\b/.test(s.value);return`${lr(s.key)}: ${l?"(...args: any[]) => any":"unknown"}`}).join(", ")} }`}return null}function rn(e){let t=ch(e),i="",r=null,n=null;if(t.script){let v=Jo(t.script.content);if(v.passthrough)return t.scriptSetup?`${t.script.content}
23
- ${t.scriptSetup.content}`:t.script.content;if(i=v.script,v.options){let b=Yr(v.options,"props");if(b)r=en(b);let C=Yr(v.options,"emits");if(C)n=ml(C)}}let o=t.scriptSetup?.content??null,s=o!==null?qo(o):null,l=tn(o,o!==null?null:i),a=l?.type??r??"{}",f=Xo(o,null)??n,u=Zo(o,null),d=l?.inlinedLocal;if(d){if(i=Zr(i,d.name,d.declText),s!==null)s=Zr(s,d.name,d.declText)}let h=[a,u??"{}"];if(f)h.push("{}","{}","{}","{}","{}",f);let p=Yo(`DefineComponent<${h.join(", ")}>`),m=[],c=Xr(i,p);if(c.trim()!=="")m.push(c);if(s&&s.trim()!==""){let v=Xr(s,p);if(v.trim()!=="")m.push(v)}return m.push("import type { DefineComponent } from 'vue'"),m.push(`type __DtsxComponentType = ${p}`),m.push("const __dtsx_component__: __DtsxComponentType = null as unknown as __DtsxComponentType"),m.push("export default __dtsx_component__"),m.join(`
24
- `)}var hl;var nn=me(()=>{hl={String:"string",Number:"number",Boolean:"boolean",Array:"unknown[]",Object:"Record<string, unknown>",Function:"(...args: any[]) => any",Symbol:"symbol",Promise:"Promise<unknown>",Date:"Date",BigInt:"bigint"}});function on(e){return e.endsWith(".stx")}function $h(e){let t=[],i=/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi,r;while((r=i.exec(e))!==null){let n=r[1]??"",o=/\blang\s*=\s*["']([^"']+)["']/i.exec(n)?.[1]?.toLowerCase()??(/\b(?:type\s*=\s*["'](?:text\/)?typescript["']|typescript)\b/i.test(n)?"ts":"js"),s=/\bserver\b/i.test(n)?"server":/\bclient\b/i.test(n)?"client":"universal";t.push({content:r[2]??"",kind:"script",attrs:n,context:s,lang:o,start:r.index})}return t}function Eh(e){let t=[],i=/^[ \t]*@ts[ \t]*(?:\r?\n|$)/gm,r;while((r=i.exec(e))!==null){let n=i.lastIndex,o=/^[ \t]*@endts[ \t]*(?:\r?\n|$)/gm;o.lastIndex=n;let s=o.exec(e),l=s?.index??e.length;if(t.push({content:e.slice(n,l),kind:"ts",attrs:"",context:"universal",lang:"ts",start:r.index}),!s)break;i.lastIndex=o.lastIndex}return t}function xh(e){return[...$h(e),...Eh(e)].sort((t,i)=>t.start-i.start)}function Sh(e){if(e.kind==="ts"||e.context!=="universal"||e.lang==="ts")return!0;return/\b(?:defineProps|defineEmits|defineExpose|defineSlots)\b|\bexport\s|\b(?:interface|type)\s+[A-Za-z_$]/.test(e.content)}function Ah(e){let t=/(?:\$?props)\s+as\s+/g,i;while((i=t.exec(e))!==null){let r=t.lastIndex;while(r<e.length&&/\s/.test(e[r]))r++;if(e[r]==="{"){let s=nt(e,r,"{","}");if(s!==-1)return e.slice(r,s+1).trim();continue}let n=/^[A-Za-z_$][\w$]*/.exec(e.slice(r))?.[0];if(!n)continue;let o=r+n.length;while(o<e.length&&/\s/.test(e[o]))o++;if(e[o]==="<"){let s=nt(e,o,"<",">");if(s!==-1)o=s+1}return e.slice(r,o).trim()}return null}function kh(e){return/\b(?:const|let|var)\s+\$?props\s*:\s*([^=;\n]+)/.exec(e)?.[1]?.trim()??null}function Th(e){let t=/^\s*(?:\|\||\?\?)\s*([^;\n]+)/.exec(e)?.[1]?.trim();if(/^['"`]/.test(t??""))return"string";if(/^(?:true|false)\b/.test(t??""))return"boolean";if(/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)\b/.test(t??""))return"number";if(/^\[/.test(t??""))return"unknown[]";if(/^\{/.test(t??""))return"Record<string, unknown>";if(/^\s*(?:===?|!==?)\s*(?:true|false)\b/.test(e))return"boolean";return"unknown"}function Oh(e,t){if(!e||e==="unknown")return t;if(t==="unknown"||e===t)return e;return[...new Set([...e.split(" | "),...t.split(" | ")])].join(" | ")}function Rh(e){let t=Ko(e),i=new Map,r=/\$props(?:\.([A-Za-z_$][\w$]*)|\[\s*(['"])([^'"\n]+)\2\s*\])/g,n;while((n=r.exec(e))!==null){if(t.slice(n.index,n.index+6)!=="$props")continue;let o=n[1]??n[3],s=Th(e.slice(r.lastIndex));i.set(o,Oh(i.get(o),s))}if(i.size===0)return null;return{type:`{ ${[...i].map(([o,s])=>`${/^[A-Za-z_$][\w$]*$/.test(o)?o:JSON.stringify(o)}?: ${s}`).join(", ")} }`}}function Ph(e){let t=tn(e,null);if(t)return t;let i=Ah(e)??kh(e);if(!i)return Rh(e);if(/^[A-Za-z_$][\w$]*$/.test(i)){let r=i.replace(/[$]/g,"\\$&");if(new RegExp(`\\bexport\\s+(?:declare\\s+)?(?:interface|type)\\s+${r}\\b`).test(e))return{type:i}}return tn(`${e}
25
- defineProps<${i}>()`,null)}function Mh(e){return qo(e)}function gl(e){let t=Ko(e).trimStart();if(t==="")return!0;return/^(?:import\b|export\b|declare\b|interface\b|type\b|(?:export\s+)?namespace\b|(?:export\s+)?module\b|(?:abstract\s+)?class\b|const\b|let\b|var\b|(?:async\s+)?function\b)/.test(t)}function Dh(e){let t=[],i=0,r=0,n=0;while(n<e.length){let s=e[n],l=zo(e,n);if(l>n){n=l;continue}if(s==="{"||s==="["||s==="(")r++;else if(s==="}"||s==="]"||s===")")r=Math.max(0,r-1);if((s===";"||s===`
26
- `)&&r===0){let a=n+1;if(!gl(e.slice(i,a)))t.push([i,a]);i=a}n++}if(i<e.length&&!gl(e.slice(i)))t.push([i,e.length]);let o=e;for(let s=t.length-1;s>=0;s--)o=o.slice(0,t[s][0])+o.slice(t[s][1]);return o}function sn(e){let t=xh(e).filter(Sh).map((c)=>c.content).join(`
27
- `),i=null,r=Jo(t);if(r.passthrough)return t;if(t=r.script,r.options){let c=Yr(r.options,"props");if(c)i=en(c)}let n=t,o=Mh(t),s=Ph(n),l=s?.type??i??"{}",a=Xo(n,null),f=Zo(n,null),u=fr(n,"defineSlots")?.generic??null,d=s?.inlinedLocal;if(d)o=Zr(o,d.name,d.declText);let h=`DefineComponent<${l}>`,p=[];if(a)p.push(`readonly __stxEmits?: ${a}`);if(u)p.push(`readonly __stxSlots?: ${u}`);if(f)p.push(`readonly __stxExposed?: ${f}`);if(p.length>0)h+=` & { ${p.join(", ")} }`;h=Yo(h),o=Dh(Xr(o,h));let m=["import type { DefineComponent } from '@stacksjs/stx'",`type __DtsxStxComponentType = ${h}`,"const __dtsx_component__: __DtsxStxComponentType = null as unknown as __DtsxStxComponentType","export default __dtsx_component__"];if(o.trim()!=="")m.push(o);return m.join(`
28
- `)}var Qo=me(()=>{nn()});function dt(e){return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36||e>127}function He(e){return dt(e)||e>=48&&e<=57}function yl(e,t){let i=t;for(;;){while(i>=0&&(e.charCodeAt(i)===32||e.charCodeAt(i)===9||e.charCodeAt(i)===10||e.charCodeAt(i)===13))i--;if(i<0)return-1;if(e.charCodeAt(i)===47&&i>0&&e.charCodeAt(i-1)===42){let o=e.lastIndexOf("/*",i-2);if(o===-1)return-1;i=o-1;continue}let r=e.lastIndexOf(`
29
- `,i)+1,n=Ih(e,r,i);if(n!==-1){i=n-1;continue}return i}}function Ih(e,t,i){let r=0;for(let n=t;n<=i;n++){let o=e.charCodeAt(n);if(r){if(o===92){n++;continue}if(o===r)r=0;continue}if(o===39||o===34||o===96){r=o;continue}if(o===47&&n+1<=i&&e.charCodeAt(n+1)===47)return n}return-1}function wl(e){return e===61||e===40||e===91||e===33||e===38||e===124||e===63||e===58||e===44||e===59||e===123||e===125||e===94||e===126||e===43||e===45||e===42||e===37||e===60||e===62}function Cl(e){return e==="return"||e==="typeof"||e==="void"||e==="delete"||e==="throw"||e==="new"||e==="in"||e==="of"||e==="case"||e==="instanceof"||e==="yield"||e==="await"||e==="else"||e==="do"}function Nh(e,t){let i=[],r=[],n=0,o=!1,s="",l="",a=!0,f=0,u=(d,h=!1)=>{l=s,s=d,a=h};while(f<=t){let d=e.charCodeAt(f);if(o){if(d===92){f+=2;continue}if(d===96)o=!1,u("literal");else if(d===36&&e.charCodeAt(f+1)===123)r.push(n++),o=!1,u("{",!0),f++;f++;continue}if(d===32||d===9||d===10||d===13){f++;continue}if(d===47&&e.charCodeAt(f+1)===47){let h=e.indexOf(`
30
- `,f+2);f=h===-1?e.length:h+1;continue}if(d===47&&e.charCodeAt(f+1)===42){let h=e.indexOf("*/",f+2);f=h===-1?e.length:h+2;continue}if(d===39||d===34){let h=d;f++;while(f<e.length){let p=e.charCodeAt(f++);if(p===92)f++;else if(p===h)break}u("literal");continue}if(d===96){o=!0,f++;continue}if(dt(d)||d===35&&dt(e.charCodeAt(f+1))){let h=f++;while(He(e.charCodeAt(f)))f++;let p=e.slice(h,f);u(p,s!=="."&&Cl(p));continue}if(d===40){let h=l!=="."&&(s==="if"||s==="while"||s==="for"||s==="with"||s==="switch"||s==="catch"||s==="await"&&l==="for");i.push(h),u("(",!0)}else if(d===41){let h=i.pop()??!1;if(f===t)return h;u(")",h)}else if(d===47&&a){f=ur(e,f),u("literal");continue}else{if(d===123)n++;else if(d===125){if(n--,r.at(-1)===n)r.pop(),o=!0}u(e[f],d===47||wl(d))}f++}return!1}function an(e,t){let i=yl(e,t-1);if(i<0)return!0;let r=e.charCodeAt(i);if(r===41)return Nh(e,i);if(wl(r))return!0;if(He(r)){let n=i;while(n>=0&&He(e.charCodeAt(n)))n--;let o=e.charCodeAt(yl(e,n));if(o===46||o===35)return!1;return Cl(e.slice(n+1,i+1))}return!1}function ur(e,t){let i=t,r=e.length;i++;let n=!1;while(i<r){let o=e.charCodeAt(i);if(o===92){i+=2;continue}if(n){if(o===93)n=!1;i++;continue}if(o===91){n=!0,i++;continue}if(o===47){i++;break}if(o===10||o===13)break;i++}while(i<r&&He(e.charCodeAt(i)))i++;return i}var dr=()=>{};function ce(e){let t=[],i=e.length,r=0;function n(){let s=r++;while(r<i){let l=e.charCodeAt(r);if(l===92)r+=2;else if(l===96){t.push({start:s,end:++r,kind:"literal"});return}else if(l===36&&e.charCodeAt(r+1)===123)t.push({start:s,end:r+1,kind:"literal"}),t.push({start:r+1,end:r+2,kind:"punctuation"}),r+=2,o(!0),s=r;else r++}t.push({start:s,end:r,kind:"literal"})}function o(s=!1){let l=0;while(r<i){let a=r,f=e.charCodeAt(r);if(f===32||f>=9&&f<=13||f>127&&/\s/.test(e[r])){r++;continue}if(f===47){let u=e.charCodeAt(r+1);if(u===47){let d=e.indexOf(`
31
- `,r+2);r=d===-1?i:d+1;continue}if(u===42){let d=e.indexOf("*/",r+2);r=d===-1?i:d+2;continue}if(an(e,r)){r=ur(e,r),t.push({start:a,end:r,kind:"literal"});continue}}else if(f===96){n();continue}else if(f===34||f===39){r++;let u=!1;while(r<i){let d=e.charCodeAt(r++);if(d===92)r++;else if(d===f){u=!0;break}}t.push({start:a,end:Math.min(r,i),kind:u?"quoted":"literal"});continue}else if(dt(f)){while(He(e.charCodeAt(++r)));t.push({start:a,end:r,kind:"word"});continue}if(t.push({start:a,end:++r,kind:"punctuation"}),s){if(f===123)l++;else if(f===125){if(l===0)return;l--}}}}return o(),t}function mi(e){if(e!==vl)bl=ce(e),vl=e;return bl}function wt(e){let t="",i=e.length-1;for(let r=1;r<i;r++){if(e[r]!=="\\"){t+=e[r];continue}let n=e[++r];if(r>=i)return;switch(n){case`
22
+ `){let s=r(),l=n(i+1);if(s===""||l===""){i++;continue}let a=bh(t);if(!a&&("{;,(<:=[".includes(s)||"}),]>;|&".includes(l))){if(!t.endsWith(" ")&&!t.endsWith(";"))t+=" "}else if(a){if(!t.endsWith(" "))t+=" "}else{if(t.endsWith(" "))t=t.slice(0,-1);t+="; "}i++;while(i<e.length&&(e[i]===" "||e[i]==="\t"))i++;continue}t+=o,i++}return t}function bh(e){let t=e.length-1;while(t>=0&&/\s/.test(e[t]))t--;if(t<1||e[t]!=="/"||e[t-1]!=="*")return!1;let i=e.lastIndexOf("/*",t);if(i===-1)return!1;for(let r=i-1;r>=0;r--){let n=e[r];if(/\s/.test(n))continue;return"{;,(<:".includes(n)}return!0}function tn(e,t){let i=[e,t].filter((r)=>r!==null);for(let r of i){let n=ur(r,"defineProps");if(!n)continue;if(n.generic){let o=n.generic;if(o.startsWith("{"))return{type:o};if(/^[A-Za-z_$][\w$]*$/.test(o)){for(let s of i){let l=ml(s,o);if(!l)continue;let a=fh(s,o);if(a===null)continue;return{type:a,inlinedLocal:{name:o,declText:s.slice(l.start,l.end)}}}return{type:o}}return{type:o}}if(n.arg){let o=en(n.arg);if(o!==null)return{type:o}}}return null}function Qo(e,t){let i=[e,t].filter((r)=>r!==null);for(let r of i){let n=ur(r,"defineEmits");if(!n)continue;if(n.generic)return mh(n.generic)??n.generic;if(n.arg){let o=gl(n.arg);if(o!==null)return o}}return null}function es(e,t){let i=[e,t].filter((r)=>r!==null);for(let r of i){let n=ur(r,"defineExpose");if(!n||!n.arg||!n.arg.startsWith("{"))continue;let o=fr(n.arg);if(o.length===0)return null;return`{ ${o.map((s)=>{if(s.value===""&&/^[A-Za-z_$][\w$]*$/.test(s.key))return`${cr(s.key)}: typeof ${s.key}`;let l=s.isMethod||/=>|^\s*function\b/.test(s.value);return`${cr(s.key)}: ${l?"(...args: any[]) => any":"unknown"}`}).join(", ")} }`}return null}function rn(e){let t=ch(e),i="",r=null,n=null;if(t.script){let C=Xo(t.script.content);if(C.passthrough)return t.scriptSetup?`${t.script.content}
23
+ ${t.scriptSetup.content}`:t.script.content;if(i=C.script,C.options){let b=Yr(C.options,"props");if(b)r=en(b);let v=Yr(C.options,"emits");if(v)n=gl(v)}}let o=t.scriptSetup?.content??null,s=o!==null?Yo(o):null,l=tn(o,o!==null?null:i),a=l?.type??r??"{}",f=Qo(o,null)??n,u=es(o,null),d=l?.inlinedLocal;if(d){if(i=Zr(i,d.name,d.declText),s!==null)s=Zr(s,d.name,d.declText)}let h=[a,u??"{}"];if(f)h.push("{}","{}","{}","{}","{}",f);let p=Zo(`DefineComponent<${h.join(", ")}>`),m=[],c=Xr(i,p);if(c.trim()!=="")m.push(c);if(s&&s.trim()!==""){let C=Xr(s,p);if(C.trim()!=="")m.push(C)}return m.push("import type { DefineComponent } from 'vue'"),m.push(`type __DtsxComponentType = ${p}`),m.push("const __dtsx_component__: __DtsxComponentType = null as unknown as __DtsxComponentType"),m.push("export default __dtsx_component__"),m.join(`
24
+ `)}var pl;var nn=me(()=>{pl={String:"string",Number:"number",Boolean:"boolean",Array:"unknown[]",Object:"Record<string, unknown>",Function:"(...args: any[]) => any",Symbol:"symbol",Promise:"Promise<unknown>",Date:"Date",BigInt:"bigint"}});function on(e){return e.endsWith(".stx")}function $h(e){let t=[],i=/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi,r;while((r=i.exec(e))!==null){let n=r[1]??"",o=/\blang\s*=\s*["']([^"']+)["']/i.exec(n)?.[1]?.toLowerCase()??(/\b(?:type\s*=\s*["'](?:text\/)?typescript["']|typescript)\b/i.test(n)?"ts":"js"),s=/\bserver\b/i.test(n)?"server":/\bclient\b/i.test(n)?"client":"universal";t.push({content:r[2]??"",kind:"script",attrs:n,context:s,lang:o,start:r.index})}return t}function Eh(e){let t=[],i=/^[ \t]*@ts[ \t]*(?:\r?\n|$)/gm,r;while((r=i.exec(e))!==null){let n=i.lastIndex,o=/^[ \t]*@endts[ \t]*(?:\r?\n|$)/gm;o.lastIndex=n;let s=o.exec(e),l=s?.index??e.length;if(t.push({content:e.slice(n,l),kind:"ts",attrs:"",context:"universal",lang:"ts",start:r.index}),!s)break;i.lastIndex=o.lastIndex}return t}function xh(e){return[...$h(e),...Eh(e)].sort((t,i)=>t.start-i.start)}function Sh(e){if(e.kind==="ts"||e.context!=="universal"||e.lang==="ts")return!0;return/\b(?:defineProps|defineEmits|defineExpose|defineSlots)\b|\bexport\s|\b(?:interface|type)\s+[A-Za-z_$]/.test(e.content)}function Ah(e){let t=/(?:\$?props)\s+as\s+/g,i;while((i=t.exec(e))!==null){let r=t.lastIndex;while(r<e.length&&/\s/.test(e[r]))r++;if(e[r]==="{"){let s=nt(e,r,"{","}");if(s!==-1)return e.slice(r,s+1).trim();continue}let n=/^[A-Za-z_$][\w$]*/.exec(e.slice(r))?.[0];if(!n)continue;let o=r+n.length;while(o<e.length&&/\s/.test(e[o]))o++;if(e[o]==="<"){let s=nt(e,o,"<",">");if(s!==-1)o=s+1}return e.slice(r,o).trim()}return null}function kh(e){return/\b(?:const|let|var)\s+\$?props\s*:\s*([^=;\n]+)/.exec(e)?.[1]?.trim()??null}function Th(e){let t=/^\s*(?:\|\||\?\?)\s*([^;\n]+)/.exec(e)?.[1]?.trim();if(/^['"`]/.test(t??""))return"string";if(/^(?:true|false)\b/.test(t??""))return"boolean";if(/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)\b/.test(t??""))return"number";if(/^\[/.test(t??""))return"unknown[]";if(/^\{/.test(t??""))return"Record<string, unknown>";if(/^\s*(?:===?|!==?)\s*(?:true|false)\b/.test(e))return"boolean";return"unknown"}function Oh(e,t){if(!e||e==="unknown")return t;if(t==="unknown"||e===t)return e;return[...new Set([...e.split(" | "),...t.split(" | ")])].join(" | ")}function Rh(e){let t=qo(e),i=new Map,r=/\$props(?:\.([A-Za-z_$][\w$]*)|\[\s*(['"])([^'"\n]+)\2\s*\])/g,n;while((n=r.exec(e))!==null){if(t.slice(n.index,n.index+6)!=="$props")continue;let o=n[1]??n[3],s=Th(e.slice(r.lastIndex));i.set(o,Oh(i.get(o),s))}if(i.size===0)return null;return{type:`{ ${[...i].map(([o,s])=>`${/^[A-Za-z_$][\w$]*$/.test(o)?o:JSON.stringify(o)}?: ${s}`).join(", ")} }`}}function Ph(e){let t=tn(e,null);if(t)return t;let i=Ah(e)??kh(e);if(!i)return Rh(e);if(/^[A-Za-z_$][\w$]*$/.test(i)){let r=i.replace(/[$]/g,"\\$&");if(new RegExp(`\\bexport\\s+(?:declare\\s+)?(?:interface|type)\\s+${r}\\b`).test(e))return{type:i}}return tn(`${e}
25
+ defineProps<${i}>()`,null)}function Mh(e){return Yo(e)}function yl(e){let t=qo(e).trimStart();if(t==="")return!0;return/^(?:import\b|export\b|declare\b|interface\b|type\b|(?:export\s+)?namespace\b|(?:export\s+)?module\b|(?:abstract\s+)?class\b|const\b|let\b|var\b|(?:async\s+)?function\b)/.test(t)}function Dh(e){let t=[],i=0,r=0,n=0;while(n<e.length){let s=e[n],l=Ho(e,n);if(l>n){n=l;continue}if(s==="{"||s==="["||s==="(")r++;else if(s==="}"||s==="]"||s===")")r=Math.max(0,r-1);if((s===";"||s===`
26
+ `)&&r===0){let a=n+1;if(!yl(e.slice(i,a)))t.push([i,a]);i=a}n++}if(i<e.length&&!yl(e.slice(i)))t.push([i,e.length]);let o=e;for(let s=t.length-1;s>=0;s--)o=o.slice(0,t[s][0])+o.slice(t[s][1]);return o}function sn(e){let t=xh(e).filter(Sh).map((c)=>c.content).join(`
27
+ `),i=null,r=Xo(t);if(r.passthrough)return t;if(t=r.script,r.options){let c=Yr(r.options,"props");if(c)i=en(c)}let n=t,o=Mh(t),s=Ph(n),l=s?.type??i??"{}",a=Qo(n,null),f=es(n,null),u=ur(n,"defineSlots")?.generic??null,d=s?.inlinedLocal;if(d)o=Zr(o,d.name,d.declText);let h=`DefineComponent<${l}>`,p=[];if(a)p.push(`readonly __stxEmits?: ${a}`);if(u)p.push(`readonly __stxSlots?: ${u}`);if(f)p.push(`readonly __stxExposed?: ${f}`);if(p.length>0)h+=` & { ${p.join(", ")} }`;h=Zo(h),o=Dh(Xr(o,h));let m=["import type { DefineComponent } from '@stacksjs/stx'",`type __DtsxStxComponentType = ${h}`,"const __dtsx_component__: __DtsxStxComponentType = null as unknown as __DtsxStxComponentType","export default __dtsx_component__"];if(o.trim()!=="")m.push(o);return m.join(`
28
+ `)}var ts=me(()=>{nn()});function dt(e){return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36||e>127}function He(e){return dt(e)||e>=48&&e<=57}function wl(e,t){let i=t;for(;;){while(i>=0&&(e.charCodeAt(i)===32||e.charCodeAt(i)===9||e.charCodeAt(i)===10||e.charCodeAt(i)===13))i--;if(i<0)return-1;if(e.charCodeAt(i)===47&&i>0&&e.charCodeAt(i-1)===42){let o=e.lastIndexOf("/*",i-2);if(o===-1)return-1;i=o-1;continue}let r=e.lastIndexOf(`
29
+ `,i)+1,n=Ih(e,r,i);if(n!==-1){i=n-1;continue}return i}}function Ih(e,t,i){let r=0;for(let n=t;n<=i;n++){let o=e.charCodeAt(n);if(r){if(o===92){n++;continue}if(o===r)r=0;continue}if(o===39||o===34||o===96){r=o;continue}if(o===47&&n+1<=i&&e.charCodeAt(n+1)===47)return n}return-1}function Cl(e){return e===61||e===40||e===91||e===33||e===38||e===124||e===63||e===58||e===44||e===59||e===123||e===125||e===94||e===126||e===43||e===45||e===42||e===37||e===60||e===62}function vl(e){return e==="return"||e==="typeof"||e==="void"||e==="delete"||e==="throw"||e==="new"||e==="in"||e==="of"||e==="case"||e==="instanceof"||e==="yield"||e==="await"||e==="else"||e==="do"}function Nh(e,t){let i=[],r=[],n=0,o=!1,s="",l="",a=!0,f=0,u=(d,h=!1)=>{l=s,s=d,a=h};while(f<=t){let d=e.charCodeAt(f);if(o){if(d===92){f+=2;continue}if(d===96)o=!1,u("literal");else if(d===36&&e.charCodeAt(f+1)===123)r.push(n++),o=!1,u("{",!0),f++;f++;continue}if(d===32||d===9||d===10||d===13){f++;continue}if(d===47&&e.charCodeAt(f+1)===47){let h=e.indexOf(`
30
+ `,f+2);f=h===-1?e.length:h+1;continue}if(d===47&&e.charCodeAt(f+1)===42){let h=e.indexOf("*/",f+2);f=h===-1?e.length:h+2;continue}if(d===39||d===34){let h=d;f++;while(f<e.length){let p=e.charCodeAt(f++);if(p===92)f++;else if(p===h)break}u("literal");continue}if(d===96){o=!0,f++;continue}if(dt(d)||d===35&&dt(e.charCodeAt(f+1))){let h=f++;while(He(e.charCodeAt(f)))f++;let p=e.slice(h,f);u(p,s!=="."&&vl(p));continue}if(d===40){let h=l!=="."&&(s==="if"||s==="while"||s==="for"||s==="with"||s==="switch"||s==="catch"||s==="await"&&l==="for");i.push(h),u("(",!0)}else if(d===41){let h=i.pop()??!1;if(f===t)return h;u(")",h)}else if(d===47&&a){f=dr(e,f),u("literal");continue}else{if(d===123)n++;else if(d===125){if(n--,r.at(-1)===n)r.pop(),o=!0}u(e[f],d===47||Cl(d))}f++}return!1}function an(e,t){let i=wl(e,t-1);if(i<0)return!0;let r=e.charCodeAt(i);if(r===41)return Nh(e,i);if(Cl(r))return!0;if(He(r)){let n=i;while(n>=0&&He(e.charCodeAt(n)))n--;let o=e.charCodeAt(wl(e,n));if(o===46||o===35)return!1;return vl(e.slice(n+1,i+1))}return!1}function dr(e,t){let i=t,r=e.length;i++;let n=!1;while(i<r){let o=e.charCodeAt(i);if(o===92){i+=2;continue}if(n){if(o===93)n=!1;i++;continue}if(o===91){n=!0,i++;continue}if(o===47){i++;break}if(o===10||o===13)break;i++}while(i<r&&He(e.charCodeAt(i)))i++;return i}var hr=()=>{};function ce(e){let t=[],i=e.length,r=0;function n(){let s=r++;while(r<i){let l=e.charCodeAt(r);if(l===92)r+=2;else if(l===96){t.push({start:s,end:++r,kind:"literal"});return}else if(l===36&&e.charCodeAt(r+1)===123)t.push({start:s,end:r+1,kind:"literal"}),t.push({start:r+1,end:r+2,kind:"punctuation"}),r+=2,o(!0),s=r;else r++}t.push({start:s,end:r,kind:"literal"})}function o(s=!1){let l=0;while(r<i){let a=r,f=e.charCodeAt(r);if(f===32||f>=9&&f<=13||f>127&&/\s/.test(e[r])){r++;continue}if(f===47){let u=e.charCodeAt(r+1);if(u===47){let d=e.indexOf(`
31
+ `,r+2);r=d===-1?i:d+1;continue}if(u===42){let d=e.indexOf("*/",r+2);r=d===-1?i:d+2;continue}if(an(e,r)){r=dr(e,r),t.push({start:a,end:r,kind:"literal"});continue}}else if(f===96){n();continue}else if(f===34||f===39){r++;let u=!1;while(r<i){let d=e.charCodeAt(r++);if(d===92)r++;else if(d===f){u=!0;break}}t.push({start:a,end:Math.min(r,i),kind:u?"quoted":"literal"});continue}else if(dt(f)){while(He(e.charCodeAt(++r)));t.push({start:a,end:r,kind:"word"});continue}if(t.push({start:a,end:++r,kind:"punctuation"}),s){if(f===123)l++;else if(f===125){if(l===0)return;l--}}}}return o(),t}function mi(e){if(e!==bl)$l=ce(e),bl=e;return $l}function wt(e){let t="",i=e.length-1;for(let r=1;r<i;r++){if(e[r]!=="\\"){t+=e[r];continue}let n=e[++r];if(r>=i)return;switch(n){case`
32
32
  `:break;case"\r":if(e[r+1]===`
33
33
  `)r++;break;case"n":t+=`
34
- `;break;case"r":t+="\r";break;case"t":t+="\t";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;case"0":if(/\d/.test(e[r+1]??""))return;t+="\x00";break;case"x":case"u":{let o=n==="u"&&e[r+1]==="{",s=r+(o?2:1),l=o?e.indexOf("}",s):s+(n==="x"?2:4),a=e.slice(s,l);if(l<s||l>i||!/^[\da-f]+$/i.test(a)||o&&a.length>6)return;let f=Number.parseInt(a,16);if(f>1114111)return;t+=String.fromCodePoint(f),r=o?l:l-1;break}default:if(/\d/.test(n))return;t+=n}}return t}function oi(e,t){let i=t;for(let r of e){let n=r.charCodeAt(0);if(r===t||r==="\\")i+=`\\${r}`;else if(n<32||n===8232||n===8233||r.length===1&&n>=55296&&n<=57343)i+=`\\u${n.toString(16).padStart(4,"0")}`;else i+=r}return i+t}function ln(e){let t=ce(e),i=(l)=>t[l]?e.slice(t[l].start,t[l].end):"";if(i(0)!=="import")return;let r=i(1)==="type"&&i(2)!=="=",n=r?2:1;if(t[n]?.kind!=="word"||i(n+1)!=="="||i(n+2)!=="require"||i(n+3)!=="("||t[n+4]?.kind!=="quoted"||i(n+5)!==")")return;let o=n+6;if(t.length!==o&&!(t.length===o+1&&i(o)===";"))return;let s=wt(i(n+4));if(s===void 0)return;return{name:i(n),source:s,isTypeOnly:r,end:t[t.length-1].end}}function Rt(e){let t=ce(e),i=[],r=new Set,n=(h)=>h>=0&&h<t.length?e.slice(t[h].start,t[h].end):"",o=(h)=>t[h]?.kind==="quoted",s=(h)=>t[h]?.kind==="word",l=[],a=!1,f=0;if(e.includes("declare")&&e.includes("module"))for(let h=0;h<t.length;h++){let p=n(h);if(f===0&&s(h)&&n(h-1)!=="."&&n(h-1)!=="#"){if(p==="export"||p==="import"&&n(h+1)!=="("&&n(h+1)!==".")a=!0;if(p==="declare"&&n(h+1)==="module"&&o(h+2)&&n(h+3)==="{")l.push(h+2)}if(p==="{"||p==="("||p==="[")f++;else if(p==="}"||p===")"||p==="]")f--}function u(h,p=!1){if(n(h)==="*"){if(n(h+1)==="as")return s(h+2)||p&&o(h+2)?h+3:-1;return p?h+1:-1}if(n(h)!=="{")return-1;let m=1;for(let c=h+1;c<t.length;c++)if(n(c)==="{")m++;else if(n(c)==="}"&&--m===0)return c+1;else if(t[c].kind==="literal"||n(c)===";")return-1;return-1}function d(h,p,m,c){let v=t[h];if(!v||v.kind!=="quoted"||r.has(v.start))return;let b=wt(e.slice(v.start,v.end));if(b===void 0)return;r.add(v.start),i.push({specifier:b,kind:p,isTypeOnly:m,category:c,start:v.start,end:v.end})}for(let h=0;h<t.length;h++){if(!s(h)||n(h-1)==="."||n(h-1)==="#")continue;let p=n(h),m=h+1;if(p==="export"){let c=n(m)==="type";if(c)m++;let v=n(m)==="*"?n(m+1)==="as"?"export-star-as":"export-star":"export-named",b=u(m,!0);if(b>=0&&n(b)==="from")d(b+1,v,c,"export")}else if(p==="import"){if(o(m)){d(m,"import",!1,"static-import");continue}if(n(m)==="("){if(n(m+2)===")"||n(m+2)===",")d(m+1,"import",!1,"import-type");continue}let c=n(m)==="type"&&n(m+1)!=="from"&&n(m+1)!=="="&&n(m+1)!==",";if(c)m++;if(s(m)){if(m++,n(m)==="="){if(n(m+1)==="require"&&n(m+2)==="("&&n(m+4)===")")d(m+3,"import",c,"static-import");continue}if(n(m)===",")m=u(m+1)}else m=u(m);if(m>=0&&n(m)==="from")d(m+1,"import",c,"static-import")}}if(a&&l.length){for(let h of l)d(h,"import",!0,"augmentation");i.sort((h,p)=>h.start-p.start)}return i}var vl,bl;var ht=me(()=>{dr();bl=[]});function cn(e,t){let i=ce(e),r=0,n=0;for(let o=0;o<i.length;o++){let s=i[o],l=e.slice(s.start,s.end),a=i[o+1];if(r===0&&l==="function"&&a?.kind==="word"&&e.slice(a.start,a.end)===t)n++;if(["{","(","["].includes(l))r++;else if(["}",")","]"].includes(l))r--}return n}var es=me(()=>{ht()});function $l(e){let t=ce(e),i=(a)=>t[a]?e.slice(t[a].start,t[a].end):"",r=new Map,n=[];for(let a=0;a<t.length;a++)if(["(","[","{"].includes(i(a)))n.push(a);else if([")","]","}"].includes(i(a))){let f=n.pop();if(f===void 0||!["()","[]","{}"].includes(i(f)+i(a)))throw Error("Unbalanced binding pattern");r.set(f,a)}if(n.length)throw Error("Unbalanced binding pattern");for(let a=0;a<t.length;a++){if(i(a)!=="<")continue;let f=["=",",","(",":","?","[","{"].includes(i(a-1)),u=1;for(let d=a+1;d<t.length;d++){if(i(d)==="="&&i(d+1)!==">"&&u===1&&!f)break;if(i(d)==="<")u++;else if(i(d)===">"&&i(d-1)!=="="&&--u===0){if(d+1===t.length||["(","[",".",",","}","]",")","?",":",";","=",">"].includes(i(d+1)))r.set(a,d);break}let h=r.get(d);if(h!==void 0)d=h}}let o=(a,f)=>({text:a<f?e.slice(t[a].start,t[f-1].end):"",offset:t[a]?.start??e.length}),s=(a,f,u)=>{for(let d=a;d<f;d++){if(i(d)===u)return d;let h=r.get(d);if(h!==void 0)d=h}return},l=(a,f)=>{let u=s(a,f,"="),d=u===void 0?void 0:o(u+1,f);if(u!==void 0)f=u;if(a+1===f&&t[a]?.kind==="word")return{kind:"name",name:i(a),defaultValue:d};let h=i(a)==="{"?"object":i(a)==="["?"array":void 0;if(!h||r.get(a)!==f-1)throw Error(`Invalid binding target: ${o(a,f).text}`);let p=[],m=a+1;while(m<f-1){let c=s(m,f-1,","),v=c??f-1;if(m===v)p.push(void 0);else if(i(m)==="."&&i(m+1)==="."&&i(m+2)===".")p.push({rest:!0,target:l(m+3,v)});else if(h==="array")p.push({rest:!1,target:l(m,v)});else if(i(m)==="["){let b=r.get(m);if(b===void 0||i(b+1)!==":")throw Error("Computed binding needs a target");p.push({computed:o(m+1,b),rest:!1,target:l(b+2,v)})}else{let b=m+1;if(t[m].kind!=="word"&&t[m].kind!=="quoted")while(b<v&&i(b)!==":")b++;let C=i(b)===":";if(!C&&t[m].kind!=="word")throw Error("Invalid object binding key");p.push({key:o(m,C?b:m+1).text,rest:!1,target:l(C?b+1:m,v)})}if(c===void 0)break;m=c+1}return{kind:h,elements:p,defaultValue:d}};return l(0,t.length)}function ts(e,t){if(e.kind==="name")t.push(e.name);else for(let i of e.elements)if(i)ts(i.target,t)}function El(e){let t=[];return ts($l(e),t),t}function xl(e){let t=$l(e.pattern),i=[];if(ts(t,i),!i.length)return[];let r=[e.root],n=!1,o={start:e.root.start,end:e.root.end},s=(a,f)=>{let u=e.allocateName();return r.push({kind:"variable",name:u,text:`declare ${f} ${u}: unknown;`,value:a.text,initializerStart:e.patternOffset+a.offset,modifiers:[f],isExported:!1,...o}),u},l=(a,f)=>{if(a.defaultValue){let C=s(a.defaultValue,e.kind),k=e.allocateName();f=`(${f}) extends infer ${k} ? ${k} extends undefined ? typeof ${C} : ${k} : never`}if(a.kind==="name"){let C=n?void 0:e.comments;n=!0,r.push({kind:"variable",name:a.name,text:`${e.exported?"export ":""}declare ${e.kind} ${a.name}: ${f};`,typeAnnotation:f,modifiers:[e.kind],isExported:e.exported,leadingComments:C,...o});return}let u=a.elements,d=[],h=[],p=[];for(let C of u){if(!C){d.push("");continue}let k=e.allocateName(),W=C.key;if(C.computed)W=`[${s(C.computed,"const")}]`;d.push(C.rest?`...${k}`:a.kind==="object"?`${W}: ${k}`:k),h.push({target:C.target,index:p.length}),p.push(`typeof ${k}`)}let m=e.allocateName(),c=e.allocateName(),v=e.allocateName(),b=a.kind==="object"?`{ ${d.join(", ")} }`:`[${d.join(", ")}]`;r.push({kind:"function",name:m,text:`declare function ${m}(${b}: ${f}): [${p.join(", ")}];`,isExported:!1,...o}),r.push({kind:"type",name:c,text:`type ${c} = (typeof ${m}) extends (...args: never[]) => infer ${v} ? ${v} : never;`,isExported:!1,...o});for(let C of h)l(C.target,`${c}[${C.index}]`)};return l(t,`typeof ${e.root.name}`),r}var is=me(()=>{ht()});function Pt(e,t,i=0){if(i>=64)return;let r=e.trim(),n=ce(r);if(!n.length)return;if(n[0].start!==0||n[n.length-1].end!==r.length)return Pt(r.slice(n[0].start,n[n.length-1].end),t,i+1);if(n.length===1&&n[0].kind==="quoted")return wt(r);if(n.length===1&&n[0].kind==="word"){let u=t.get(r);return typeof u==="object"?void 0:u}if(Sl.exec(r)?.[0].length===r.length){let u=Number(r.replaceAll("_",""));return Number.isFinite(u)?u:void 0}let o=0,s;for(let u=0;u<n.length;u++){let d=n[u],h=r.slice(d.start,d.end);if(d.kind!=="punctuation")continue;if(["(","[","{"].includes(h)){o++;continue}if([")","]","}"].includes(h)){o--;continue}let p=Sl.exec(r.slice(d.start));if(p){while(n[u+1]?.start<d.start+p[0].length)u++;continue}if(o)continue;let m=Wh.find((b)=>r.startsWith(b,d.start));if(!m)continue;let c=n[u-1],v=c?r.slice(c.start,c.end):"";if(!(!c||c.kind==="punctuation"&&![")","]"].includes(v)&&!/\d/.test(v))&&(!s||rs[m]<s.priority||rs[m]===s.priority&&m!=="**"))s={start:d.start,operator:m,priority:rs[m]};while(n[u+1]?.start<d.start+m.length)u++}if(s){let u=Pt(r.slice(0,s.start),t,i+1),d=Pt(r.slice(s.start+s.operator.length),t,i+1);if(u===void 0||d===void 0)return;if(s.operator==="+"&&(typeof u==="string"||typeof d==="string"))return String(u)+String(d);if(typeof u!=="number"||typeof d!=="number")return;let h;switch(s.operator){case"+":h=u+d;break;case"-":h=u-d;break;case"*":h=u*d;break;case"/":h=u/d;break;case"%":h=u%d;break;case"**":h=u**d;break;case"<<":h=u<<d;break;case">>":h=u>>d;break;case">>>":h=u>>>d;break;case"|":h=u|d;break;case"^":h=u^d;break;case"&":h=u&d;break;default:return}return Number.isFinite(h)?h:void 0}if(r.startsWith("(")&&r.endsWith(")")){let u=0;if(n.every((d,h)=>{let p=r.slice(d.start,d.end);if(p==="(")u++;if(p===")")u--;return u!==0||h===n.length-1}))return Pt(r.slice(1,-1),t,i+1)}if(["+","-","~"].includes(r[0])){let u=Pt(r.slice(1),t,i+1);if(typeof u!=="number")return;return r[0]==="-"?-u:r[0]==="~"?~u:u}if(!r.startsWith("`")||!r.endsWith("`"))return;let l="",a=1;for(let u=1;u<r.length-1;u++){if(r[u]==="\\"){u++;continue}if(r[u]!=="$"||r[u+1]!=="{")continue;let d=wt(`\`${r.slice(a,u)}\``);if(d===void 0)return;l+=d;let h=0,p=n.find((c)=>{if(c.start<u+2||c.kind!=="punctuation")return!1;let v=r.slice(c.start,c.end);if(v==="{")h++;if(v!=="}")return!1;if(h===0)return!0;return h--,!1});if(!p)return;let m=Pt(r.slice(u+2,p.start),t,i+1);if(m===void 0)return;l+=String(m),u=p.start,a=u+1}let f=wt(`\`${r.slice(a,-1)}\``);return f===void 0?void 0:l+f}function Al(e,t){let i=[...new Set([...e,...t.values()])];if(!i.some((s)=>s.kind==="variable"&&typeof s.value==="string"&&/[\[{]/.test(s.value)))return;i.sort((s,l)=>(s.start??0)-(l.start??0));let r=new Map,n=new Map,o=i.some((s)=>s.name==="Symbol");for(let s of i){if(s.kind!=="variable"||typeof s.value!=="string")continue;if(s.value.includes("{")||s.value.includes("[")){let u=new Map(r);u.mutableBindingTypes=new Map(n),s.computedKeyConstants=u}let l=ce(s.value),a=l.length===1&&l[0].kind==="word"?r.get(s.value.slice(l[0].start,l[0].end)):void 0;if(s.typeAnnotation==="unique symbol"||s.typeAnnotation==="symbol"||typeof a==="object"||!o&&l[0]?.kind==="word"&&s.value.slice(l[0].start,l[0].end)==="Symbol"&&["(","."].includes(s.value.slice(l[1]?.start,l[1]?.end))){r.set(s.name,Fh);continue}if(s.modifiers?.[0]!=="const"||s.typeAnnotation||s.modifiers.includes("const assertion"))continue;let f=Pt(s.value,r);if(f!==void 0){if(r.set(s.name,f),!(l.length===1&&l[0].kind==="word")||n.has(s.value.trim()))n.set(s.name,typeof f)}else if(s.value.trim()==="true"||s.value.trim()==="false")n.set(s.name,"boolean");else if(l.length===1&&l[0].kind==="word"){let u=n.get(s.value.trim());if(u)n.set(s.name,u)}}}function kl(e,t){if(!e.trimStart().startsWith("[")||!e.includes("`"))return;let i=ce(e);if(e[i[0]?.start]!=="["||e[i[1]?.start]!=="`"||e[i.at(-1)?.start??-1]!=="]")return;let r=e.slice(i[0].end,i.at(-1).start).trim(),n=Pt(r,t??new Map);return typeof n==="string"?{name:oi(n,"'")}:{index:!0}}function Tl(e,t){if(!t||!e.trimStart().startsWith("["))return!1;let i=ce(e);return i.length===3&&e[i[0].start]==="["&&i[1].kind==="word"&&e[i[2].start]==="]"&&typeof t.get(e.slice(i[1].start,i[1].end))==="object"}function Ol(e){if(!e.trimStart().startsWith("[")||!e.includes("`"))return!1;let t=ce(e);return e[t[1]?.start]==="`"&&t.some((i)=>i.kind==="punctuation"&&e[i.start]==="{")}var Fh,Sl,rs,Wh;var fn=me(()=>{ht();Fh={kind:"symbol"},Sl=/^(?:0[xX][\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|(?:[\d_]+(?:\.[\d_]*)?|\.[\d_]+)(?:[eE][+-]?[\d_]+)?)/,rs={"|":1,"^":2,"&":3,"<<":4,">>":4,">>>":4,"+":5,"-":5,"*":6,"/":6,"%":6,"**":7},Wh=[">>>","<<",">>","**","+","-","*","/","%","|","^","&"]});function un(e){let t=ce(e);if(t.length!==1||t[0].kind!=="word")return;let i=e.slice(t[0].start,t[0].end);return["true","false","null","undefined","this","super"].includes(i)?void 0:i}function ns(e){let t=ce(e);if(t.length===0)return!0;let i=t[t.length-1],r=e.slice(i.start,i.end);if(i.kind==="word"&&(r==="is"||r==="extends"))return!0;if(r==="|"||r==="&")return!0;let n=t[t.length-2];return r===">"&&n!==void 0&&e.slice(n.start,n.end)==="="}function Ri(e){return Pl(e,mi(e))}function Rl(e){for(let t=1024;t<e.length;t*=8){let i=e.slice(0,t),r=Ml(i,ce(i),t);if(r!==void 0)return r}return Pl(e,ce(e))}function Pl(e,t){return Ml(e,t,1/0)??!1}function Ml(e,t,i){let r=0;for(let n=0;n<t.length;n++){let o=t[n];if(o.end>=i)return;if(o.kind==="punctuation"){let l=e.charCodeAt(o.start);if(l===123||l===40||l===91)r++;else if(l===125||l===41||l===93)r--;continue}if(r!==0||o.kind!=="word"||o.end-o.start!==6)continue;let s=e.slice(o.start,o.end);if(s==="export")return!0;if(s==="import"){let l=t[n+1];if(l===void 0?i!==1/0:l.end>=i)return;let a=l?e.slice(l.start,l.end):"";if(a!=="("&&a!==".")return!0}}return i===1/0?!1:void 0}function Dl(e){if(e.isExported)return!1;if(["function","variable","interface","type","class","enum","namespace"].includes(e.kind))return!0;return e.kind==="module"&&(e.moduleForm==="namespace"||e.moduleForm==="identifier")}function Il(e,t){let i=e.text,r=ce(i),n=(d)=>r[d]?i.slice(r[d].start,r[d].end):"",o=(d)=>r[d]?.kind==="word",s=new Map,l=[];for(let d=0;d<r.length;d++){let h=n(d);if(h==="("||h==="["||h==="{"||h==="<")l.push(d);else if(h===")"||h==="]"||h==="}"||h===">"&&n(d-1)!=="="){let p=l.at(-1);if(p!==void 0&&(n(p)==="("&&h===")"||n(p)==="["&&h==="]"||n(p)==="{"&&h==="}"||n(p)==="<"&&h===">"))l.pop(),s.set(p,d)}}let a=[];for(let d=0;d<r.length;d++){if(n(d)!=="(")continue;let h=s.get(d);if(h===void 0||!(n(h+1)===":"||n(h+1)==="="&&n(h+2)===">"))continue;let p=new Set,m=d+1;while(m<h){let v=m;while(v<h&&n(v)!==","){let k=s.get(v);if(k!==void 0)v=k+1;else v++}let b=m;while(b<v&&n(b)!==":"&&n(b)!=="="){let k=s.get(b);if(k!==void 0)b=k+1;else b++}let C=m;while([".","public","private","protected","readonly","override"].includes(n(C)))C++;if(n(C)==="{"||n(C)==="[")for(let k of El(i.slice(r[C].start,r[b-1].end)))p.add(k);else if(o(C))p.add(n(C));m=v+1}let c=h+(n(h+1)===":"?2:3);while(c<r.length){if([";",",",")","]","}"].includes(n(c))||n(c)===">"&&n(c-1)!=="=")break;let v=s.get(c);if(v!==void 0)c=v+1;else c++}a.push({start:d,end:c,names:p})}let f=(d)=>{if(!o(d))return;let h=n(d);if(!a.some((p)=>d>=p.start&&d<p.end&&p.names.has(h)))t.add(h)},u=(d,h)=>{for(let p=d;p<h;p++){if(n(p)==="<"&&s.has(p)){p=s.get(p);continue}if(!o(p)||n(p-1)==="."||n(p+1)===":")continue;if(["true","false","null","undefined","new","this","super","as","satisfies","typeof","void","keyof"].includes(n(p)))continue;f(p)}};for(let d=0;d<r.length;d++){if(n(d)==="typeof")f(d+1);if(n(d)==="export"){let h=d+1;if(n(h)==="default"){if(!["function","class","abstract"].includes(n(h+1)))u(h+1,r.length);continue}if(n(h)==="type")h++;if(n(h)==="{"){let p=s.get(h);if(p===void 0||n(p+1)==="from")continue;for(let m=h+1;m<p;){if(n(m)==="type"&&o(m+1)&&n(m+1)!=="as")m++;f(m);while(m<p&&n(m)!==",")m++;m++}}}if(n(d)==="["){let h=s.get(d);if(h!==void 0&&[":","?","("].includes(n(h+1))&&n(d+2)!==":"&&n(d+2)!=="in")u(d+1,h)}}if(e.kind==="class"){let d=-1;for(let h=0;h<r.length&&n(h)!=="{";h++)if(n(h)==="<"&&s.has(h))h=s.get(h);else if(n(h)==="extends"){d=h;break}if(d!==-1){let h=d+1;while(h<r.length&&n(h)!=="{"&&n(h)!=="implements"){let p=s.get(h);if(p!==void 0)h=p+1;else h++}u(d+1,h)}}}var hr=me(()=>{ht();is()});function os(e){return typeof e==="string"?oi(e,"'"):String(e)}function Lh(e,t,i=new Map){let r=ce(e),n=new Map(i),o=new Map,s=[],l=1,a=0,f=0;for(let d=1;d<r.length;d++){let h=r[d],p=e.slice(h.start,h.end);if(h.kind==="punctuation"&&a===0&&(p===","||p==="}")){let m=r.slice(l,d),c=m[0];if(c){let v=c.kind==="quoted"?wt(e.slice(c.start,c.end)):e.slice(c.start,c.end),b=m.findIndex((k)=>k.kind==="punctuation"&&e[k.start]==="="),C=f;if(b>=0){let k=m.slice(b+1),W="",A=m[b].end;for(let R=0;R+2<k.length;R++){let[V,B,O]=k.slice(R,R+3);if(V.kind!=="word"||O.kind!=="word"||e.slice(B.start,B.end)!==".")continue;let z=n.get(`${e.slice(V.start,V.end)}.${e.slice(O.start,O.end)}`);if(z===void 0||typeof z==="object")continue;W+=e.slice(A,V.start)+os(z),A=O.end,R+=2}W+=e.slice(A,m.at(-1).end),C=Pt(W,n),s.push({start:m[b].start,end:m.at(-1).end,text:C===void 0?"":`= ${os(C)}`})}else if(C!==void 0)s.push({start:c.end,end:c.end,text:` = ${os(C)}`});if(f=typeof C==="number"?C+1:void 0,v!==void 0){if(n.delete(v),n.delete(`${t}.${v}`),C!==void 0)o.set(v,C),n.set(v,C),n.set(`${t}.${v}`,C)}}l=d+1}else if(h.kind==="punctuation"){if("([{".includes(p))a++;else if(")]}".includes(p))a--}}let u=e;for(let d of s.reverse())u=u.slice(0,d.start)+d.text+u.slice(d.end);return{body:u,members:o}}function Nl(e,t){let i=[...new Set([...e,...t.values()])];if(!i.some((n)=>n.kind==="enum"))return;i.sort((n,o)=>(n.start??0)-(o.start??0));let r=new Map;for(let n of i)if(n.kind==="enum"){let o=n.text.indexOf("{");if(o<0)continue;if(ce(n.text.slice(0,o)).some((l)=>n.text.slice(l.start,l.end)==="declare"))continue;let s=Lh(n.text.slice(o),n.name,r);n.text=n.text.slice(0,o)+s.body;for(let[l,a]of s.members)r.set(`${n.name}.${l}`,a)}else if(n.kind==="variable"&&n.modifiers?.[0]==="const"&&!n.typeAnnotation&&!n.modifiers.includes("const assertion")&&typeof n.value==="string"){let o=Pt(n.value,r);if(o!==void 0)r.set(n.name,o)}}var Fl=me(()=>{ht();fn()});function Wl(e,t){if(t.kind!=="punctuation")return 0;let i=e.slice(t.start,t.end);if("([{<".includes(i))return 1;if(")]}".includes(i)||i===">"&&e[t.start-1]!=="=")return-1;return 0}function dn(e){if(!e.includes("?"))return e;let t=e.trim(),i=t.startsWith("(")&&t.endsWith(")"),r=e.indexOf(t)+(i?1:0),n=i?t.slice(1,-1):t,o=[[]],s=0;for(let h of ce(n)){if(h.kind==="punctuation"&&n[h.start]===","&&s===0)o.push([]);else o[o.length-1].push(h);s+=Wl(n,h)}let l=o.map((h)=>{let p=0,m=-1;for(let[C,k]of h.entries()){if(p===0&&k.kind==="punctuation"&&n[k.start]===":"){m=C;break}p+=Wl(n,k)}let c=m>0&&n[h[m-1].start]==="?"?h[m-1]:void 0,v=h[0]?n.slice(h[0].start,h[0].end):"",b=h[0]&&n.startsWith("...",h[0].start);return{tokens:h,colon:m,question:c,required:h.length>0&&!c&&!b&&v!=="this"}}),a=-1;for(let[h,p]of l.entries())if(p.required)a=h;let f=[];for(let[h,p]of l.entries()){if(h>=a||!p.question||p.colon<0)continue;let m=p.tokens[p.colon+1],c=p.tokens.at(-1);if(!m||!c)continue;f.push({start:r+p.question.start,end:r+p.question.end,text:""},{start:r+m.start,end:r+m.start,text:"("},{start:r+c.end,end:r+c.end,text:") | undefined"})}if(!f.length)return e;let u=[],d=0;for(let h of f)u.push(e.slice(d,h.start),h.text),d=h.end;return u.push(e.slice(d)),u.join("")}function Ll(e){return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function Bl(e,t){if(t>=e.length||!Ll(e.charCodeAt(t)))return t;let i=t+1;while(i<e.length&&(Ll(e.charCodeAt(i))||e.charCodeAt(i)>=48&&e.charCodeAt(i)<=57))i++;return i}function ss(e,t){let i=t;while(i<e.length&&e.charCodeAt(i)<=32)i++;return i}function pr(e,t){if(t.trim()!=="{}")return null;let i=e.trim();if(i.length<2||i[0]!=="{"||i[i.length-1]!=="}")return null;let r=i.slice(1,-1),n=[],o=0,s=0;for(let a=0;a<r.length;a++){let f=r.charCodeAt(a);if(f===34||f===39||f===96){a++;while(a<r.length&&r.charCodeAt(a)!==f){if(r.charCodeAt(a)===92)a++;a++}if(a>=r.length)return null;continue}if(f===47&&(r.charCodeAt(a+1)===47||r.charCodeAt(a+1)===42))return null;if(f===40||f===91||f===123)o++;else if(f===41||f===93||f===125){if(--o<0)return null}else if(f===44&&o===0)n.push(r.slice(s,a)),s=a+1}if(o!==0)return null;if(r.slice(s).trim()||n.length===0)n.push(r.slice(s));let l=[];for(let a of n){let f=a.trim(),u=Bl(f,0);if(u===0)return null;let d=f.slice(0,u),h=d,p=ss(f,u);if(f.charCodeAt(p)===58){let c=ss(f,p+1),v=Bl(f,c);if(v===c)return null;h=f.slice(c,v),p=ss(f,v)}if(f.charCodeAt(p)!==61||f.charCodeAt(p+1)===61||f.charCodeAt(p+1)===62)return null;let m=f.slice(p+1).trim();if(!m)return null;l.push({key:d,alias:h,value:m})}return l}function hn(e,t){let i=e.map((n)=>n.key===n.alias?n.key:`${n.key}: ${n.alias}`).join(", "),r=e.map((n)=>{let o=t(n.value),s=o==="unknown"||o==="any"?o:`${o.includes("=>")?`(${o})`:o} | undefined`;return`${n.key}?: ${s}`}).join("; ");return`{ ${i} }?: { ${r} }`}var as=me(()=>{ht()});function Lt(e,t=!0){if(!t||!e||e.length===0)return"";if(e.length===1){let r=e[0];if(r.length>0&&r.charCodeAt(0)>32&&r.charCodeAt(r.length-1)>32)return`${r}
34
+ `;break;case"r":t+="\r";break;case"t":t+="\t";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;case"0":if(/\d/.test(e[r+1]??""))return;t+="\x00";break;case"x":case"u":{let o=n==="u"&&e[r+1]==="{",s=r+(o?2:1),l=o?e.indexOf("}",s):s+(n==="x"?2:4),a=e.slice(s,l);if(l<s||l>i||!/^[\da-f]+$/i.test(a)||o&&a.length>6)return;let f=Number.parseInt(a,16);if(f>1114111)return;t+=String.fromCodePoint(f),r=o?l:l-1;break}default:if(/\d/.test(n))return;t+=n}}return t}function oi(e,t){let i=t;for(let r of e){let n=r.charCodeAt(0);if(r===t||r==="\\")i+=`\\${r}`;else if(n<32||n===8232||n===8233||r.length===1&&n>=55296&&n<=57343)i+=`\\u${n.toString(16).padStart(4,"0")}`;else i+=r}return i+t}function ln(e){let t=ce(e),i=(l)=>t[l]?e.slice(t[l].start,t[l].end):"";if(i(0)!=="import")return;let r=i(1)==="type"&&i(2)!=="=",n=r?2:1;if(t[n]?.kind!=="word"||i(n+1)!=="="||i(n+2)!=="require"||i(n+3)!=="("||t[n+4]?.kind!=="quoted"||i(n+5)!==")")return;let o=n+6;if(t.length!==o&&!(t.length===o+1&&i(o)===";"))return;let s=wt(i(n+4));if(s===void 0)return;return{name:i(n),source:s,isTypeOnly:r,end:t[t.length-1].end}}function Rt(e){let t=ce(e),i=[],r=new Set,n=(h)=>h>=0&&h<t.length?e.slice(t[h].start,t[h].end):"",o=(h)=>t[h]?.kind==="quoted",s=(h)=>t[h]?.kind==="word",l=[],a=!1,f=0;if(e.includes("declare")&&e.includes("module"))for(let h=0;h<t.length;h++){let p=n(h);if(f===0&&s(h)&&n(h-1)!=="."&&n(h-1)!=="#"){if(p==="export"||p==="import"&&n(h+1)!=="("&&n(h+1)!==".")a=!0;if(p==="declare"&&n(h+1)==="module"&&o(h+2)&&n(h+3)==="{")l.push(h+2)}if(p==="{"||p==="("||p==="[")f++;else if(p==="}"||p===")"||p==="]")f--}function u(h,p=!1){if(n(h)==="*"){if(n(h+1)==="as")return s(h+2)||p&&o(h+2)?h+3:-1;return p?h+1:-1}if(n(h)!=="{")return-1;let m=1;for(let c=h+1;c<t.length;c++)if(n(c)==="{")m++;else if(n(c)==="}"&&--m===0)return c+1;else if(t[c].kind==="literal"||n(c)===";")return-1;return-1}function d(h,p,m,c){let C=t[h];if(!C||C.kind!=="quoted"||r.has(C.start))return;let b=wt(e.slice(C.start,C.end));if(b===void 0)return;r.add(C.start),i.push({specifier:b,kind:p,isTypeOnly:m,category:c,start:C.start,end:C.end})}for(let h=0;h<t.length;h++){if(!s(h)||n(h-1)==="."||n(h-1)==="#")continue;let p=n(h),m=h+1;if(p==="export"){let c=n(m)==="type";if(c)m++;let C=n(m)==="*"?n(m+1)==="as"?"export-star-as":"export-star":"export-named",b=u(m,!0);if(b>=0&&n(b)==="from")d(b+1,C,c,"export")}else if(p==="import"){if(o(m)){d(m,"import",!1,"static-import");continue}if(n(m)==="("){if(n(m+2)===")"||n(m+2)===",")d(m+1,"import",!1,"import-type");continue}let c=n(m)==="type"&&n(m+1)!=="from"&&n(m+1)!=="="&&n(m+1)!==",";if(c)m++;if(s(m)){if(m++,n(m)==="="){if(n(m+1)==="require"&&n(m+2)==="("&&n(m+4)===")")d(m+3,"import",c,"static-import");continue}if(n(m)===",")m=u(m+1)}else m=u(m);if(m>=0&&n(m)==="from")d(m+1,"import",c,"static-import")}}if(a&&l.length){for(let h of l)d(h,"import",!0,"augmentation");i.sort((h,p)=>h.start-p.start)}return i}var bl,$l;var ht=me(()=>{hr();$l=[]});function cn(e,t){let i=ce(e),r=0,n=0;for(let o=0;o<i.length;o++){let s=i[o],l=e.slice(s.start,s.end),a=i[o+1];if(r===0&&l==="function"&&a?.kind==="word"&&e.slice(a.start,a.end)===t)n++;if(["{","(","["].includes(l))r++;else if(["}",")","]"].includes(l))r--}return n}var is=me(()=>{ht()});function El(e){let t=ce(e),i=(a)=>t[a]?e.slice(t[a].start,t[a].end):"",r=new Map,n=[];for(let a=0;a<t.length;a++)if(["(","[","{"].includes(i(a)))n.push(a);else if([")","]","}"].includes(i(a))){let f=n.pop();if(f===void 0||!["()","[]","{}"].includes(i(f)+i(a)))throw Error("Unbalanced binding pattern");r.set(f,a)}if(n.length)throw Error("Unbalanced binding pattern");for(let a=0;a<t.length;a++){if(i(a)!=="<")continue;let f=["=",",","(",":","?","[","{"].includes(i(a-1)),u=1;for(let d=a+1;d<t.length;d++){if(i(d)==="="&&i(d+1)!==">"&&u===1&&!f)break;if(i(d)==="<")u++;else if(i(d)===">"&&i(d-1)!=="="&&--u===0){if(d+1===t.length||["(","[",".",",","}","]",")","?",":",";","=",">"].includes(i(d+1)))r.set(a,d);break}let h=r.get(d);if(h!==void 0)d=h}}let o=(a,f)=>({text:a<f?e.slice(t[a].start,t[f-1].end):"",offset:t[a]?.start??e.length}),s=(a,f,u)=>{for(let d=a;d<f;d++){if(i(d)===u)return d;let h=r.get(d);if(h!==void 0)d=h}return},l=(a,f)=>{let u=s(a,f,"="),d=u===void 0?void 0:o(u+1,f);if(u!==void 0)f=u;if(a+1===f&&t[a]?.kind==="word")return{kind:"name",name:i(a),defaultValue:d};let h=i(a)==="{"?"object":i(a)==="["?"array":void 0;if(!h||r.get(a)!==f-1)throw Error(`Invalid binding target: ${o(a,f).text}`);let p=[],m=a+1;while(m<f-1){let c=s(m,f-1,","),C=c??f-1;if(m===C)p.push(void 0);else if(i(m)==="."&&i(m+1)==="."&&i(m+2)===".")p.push({rest:!0,target:l(m+3,C)});else if(h==="array")p.push({rest:!1,target:l(m,C)});else if(i(m)==="["){let b=r.get(m);if(b===void 0||i(b+1)!==":")throw Error("Computed binding needs a target");p.push({computed:o(m+1,b),rest:!1,target:l(b+2,C)})}else{let b=m+1;if(t[m].kind!=="word"&&t[m].kind!=="quoted")while(b<C&&i(b)!==":")b++;let v=i(b)===":";if(!v&&t[m].kind!=="word")throw Error("Invalid object binding key");p.push({key:o(m,v?b:m+1).text,rest:!1,target:l(v?b+1:m,C)})}if(c===void 0)break;m=c+1}return{kind:h,elements:p,defaultValue:d}};return l(0,t.length)}function rs(e,t){if(e.kind==="name")t.push(e.name);else for(let i of e.elements)if(i)rs(i.target,t)}function fn(e){let t=[];return rs(El(e),t),t}function xl(e){let t=El(e.pattern),i=[];if(rs(t,i),!i.length)return[];let r=[e.root],n=!1,o={start:e.root.start,end:e.root.end},s=(a,f)=>{let u=e.allocateName();return r.push({kind:"variable",name:u,text:`declare ${f} ${u}: unknown;`,value:a.text,initializerStart:e.patternOffset+a.offset,modifiers:[f],isExported:!1,...o}),u},l=(a,f)=>{if(a.defaultValue){let v=s(a.defaultValue,e.kind),k=e.allocateName();f=`(${f}) extends infer ${k} ? ${k} extends undefined ? typeof ${v} : ${k} : never`}if(a.kind==="name"){let v=n?void 0:e.comments;n=!0,r.push({kind:"variable",name:a.name,text:`${e.exported?"export ":""}declare ${e.kind} ${a.name}: ${f};`,typeAnnotation:f,modifiers:[e.kind],isExported:e.exported,leadingComments:v,...o});return}let u=a.elements,d=[],h=[],p=[];for(let v of u){if(!v){d.push("");continue}let k=e.allocateName(),W=v.key;if(v.computed)W=`[${s(v.computed,"const")}]`;d.push(v.rest?`...${k}`:a.kind==="object"?`${W}: ${k}`:k),h.push({target:v.target,index:p.length}),p.push(`typeof ${k}`)}let m=e.allocateName(),c=e.allocateName(),C=e.allocateName(),b=a.kind==="object"?`{ ${d.join(", ")} }`:`[${d.join(", ")}]`;r.push({kind:"function",name:m,text:`declare function ${m}(${b}: ${f}): [${p.join(", ")}];`,isExported:!1,...o}),r.push({kind:"type",name:c,text:`type ${c} = (typeof ${m}) extends (...args: never[]) => infer ${C} ? ${C} : never;`,isExported:!1,...o});for(let v of h)l(v.target,`${c}[${v.index}]`)};return l(t,`typeof ${e.root.name}`),r}var un=me(()=>{ht()});function Pt(e,t,i=0){if(i>=64)return;let r=e.trim(),n=ce(r);if(!n.length)return;if(n[0].start!==0||n[n.length-1].end!==r.length)return Pt(r.slice(n[0].start,n[n.length-1].end),t,i+1);if(n.length===1&&n[0].kind==="quoted")return wt(r);if(n.length===1&&n[0].kind==="word"){let u=t.get(r);return typeof u==="object"?void 0:u}if(Sl.exec(r)?.[0].length===r.length){let u=Number(r.replaceAll("_",""));return Number.isFinite(u)?u:void 0}let o=0,s;for(let u=0;u<n.length;u++){let d=n[u],h=r.slice(d.start,d.end);if(d.kind!=="punctuation")continue;if(["(","[","{"].includes(h)){o++;continue}if([")","]","}"].includes(h)){o--;continue}let p=Sl.exec(r.slice(d.start));if(p){while(n[u+1]?.start<d.start+p[0].length)u++;continue}if(o)continue;let m=Wh.find((b)=>r.startsWith(b,d.start));if(!m)continue;let c=n[u-1],C=c?r.slice(c.start,c.end):"";if(!(!c||c.kind==="punctuation"&&![")","]"].includes(C)&&!/\d/.test(C))&&(!s||ns[m]<s.priority||ns[m]===s.priority&&m!=="**"))s={start:d.start,operator:m,priority:ns[m]};while(n[u+1]?.start<d.start+m.length)u++}if(s){let u=Pt(r.slice(0,s.start),t,i+1),d=Pt(r.slice(s.start+s.operator.length),t,i+1);if(u===void 0||d===void 0)return;if(s.operator==="+"&&(typeof u==="string"||typeof d==="string"))return String(u)+String(d);if(typeof u!=="number"||typeof d!=="number")return;let h;switch(s.operator){case"+":h=u+d;break;case"-":h=u-d;break;case"*":h=u*d;break;case"/":h=u/d;break;case"%":h=u%d;break;case"**":h=u**d;break;case"<<":h=u<<d;break;case">>":h=u>>d;break;case">>>":h=u>>>d;break;case"|":h=u|d;break;case"^":h=u^d;break;case"&":h=u&d;break;default:return}return Number.isFinite(h)?h:void 0}if(r.startsWith("(")&&r.endsWith(")")){let u=0;if(n.every((d,h)=>{let p=r.slice(d.start,d.end);if(p==="(")u++;if(p===")")u--;return u!==0||h===n.length-1}))return Pt(r.slice(1,-1),t,i+1)}if(["+","-","~"].includes(r[0])){let u=Pt(r.slice(1),t,i+1);if(typeof u!=="number")return;return r[0]==="-"?-u:r[0]==="~"?~u:u}if(!r.startsWith("`")||!r.endsWith("`"))return;let l="",a=1;for(let u=1;u<r.length-1;u++){if(r[u]==="\\"){u++;continue}if(r[u]!=="$"||r[u+1]!=="{")continue;let d=wt(`\`${r.slice(a,u)}\``);if(d===void 0)return;l+=d;let h=0,p=n.find((c)=>{if(c.start<u+2||c.kind!=="punctuation")return!1;let C=r.slice(c.start,c.end);if(C==="{")h++;if(C!=="}")return!1;if(h===0)return!0;return h--,!1});if(!p)return;let m=Pt(r.slice(u+2,p.start),t,i+1);if(m===void 0)return;l+=String(m),u=p.start,a=u+1}let f=wt(`\`${r.slice(a,-1)}\``);return f===void 0?void 0:l+f}function Al(e,t){let i=[...new Set([...e,...t.values()])];if(!i.some((s)=>s.kind==="variable"&&typeof s.value==="string"&&/[\[{]/.test(s.value)))return;i.sort((s,l)=>(s.start??0)-(l.start??0));let r=new Map,n=new Map,o=i.some((s)=>s.name==="Symbol");for(let s of i){if(s.kind!=="variable"||typeof s.value!=="string")continue;if(s.value.includes("{")||s.value.includes("[")){let u=new Map(r);u.mutableBindingTypes=new Map(n),s.computedKeyConstants=u}let l=ce(s.value),a=l.length===1&&l[0].kind==="word"?r.get(s.value.slice(l[0].start,l[0].end)):void 0;if(s.typeAnnotation==="unique symbol"||s.typeAnnotation==="symbol"||typeof a==="object"||!o&&l[0]?.kind==="word"&&s.value.slice(l[0].start,l[0].end)==="Symbol"&&["(","."].includes(s.value.slice(l[1]?.start,l[1]?.end))){r.set(s.name,Fh);continue}if(s.modifiers?.[0]!=="const"||s.typeAnnotation||s.modifiers.includes("const assertion"))continue;let f=Pt(s.value,r);if(f!==void 0){if(r.set(s.name,f),!(l.length===1&&l[0].kind==="word")||n.has(s.value.trim()))n.set(s.name,typeof f)}else if(s.value.trim()==="true"||s.value.trim()==="false")n.set(s.name,"boolean");else if(l.length===1&&l[0].kind==="word"){let u=n.get(s.value.trim());if(u)n.set(s.name,u)}}}function kl(e,t){if(!e.trimStart().startsWith("[")||!e.includes("`"))return;let i=ce(e);if(e[i[0]?.start]!=="["||e[i[1]?.start]!=="`"||e[i.at(-1)?.start??-1]!=="]")return;let r=e.slice(i[0].end,i.at(-1).start).trim(),n=Pt(r,t??new Map);return typeof n==="string"?{name:oi(n,"'")}:{index:!0}}function Tl(e,t){if(!t||!e.trimStart().startsWith("["))return!1;let i=ce(e);return i.length===3&&e[i[0].start]==="["&&i[1].kind==="word"&&e[i[2].start]==="]"&&typeof t.get(e.slice(i[1].start,i[1].end))==="object"}function Ol(e){if(!e.trimStart().startsWith("[")||!e.includes("`"))return!1;let t=ce(e);return e[t[1]?.start]==="`"&&t.some((i)=>i.kind==="punctuation"&&e[i.start]==="{")}var Fh,Sl,ns,Wh;var dn=me(()=>{ht();Fh={kind:"symbol"},Sl=/^(?:0[xX][\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|(?:[\d_]+(?:\.[\d_]*)?|\.[\d_]+)(?:[eE][+-]?[\d_]+)?)/,ns={"|":1,"^":2,"&":3,"<<":4,">>":4,">>>":4,"+":5,"-":5,"*":6,"/":6,"%":6,"**":7},Wh=[">>>","<<",">>","**","+","-","*","/","%","|","^","&"]});function hn(e){let t=ce(e);if(t.length!==1||t[0].kind!=="word")return;let i=e.slice(t[0].start,t[0].end);return["true","false","null","undefined","this","super"].includes(i)?void 0:i}function os(e){let t=ce(e);if(t.length===0)return!0;let i=t[t.length-1],r=e.slice(i.start,i.end);if(i.kind==="word"&&(r==="is"||r==="extends"))return!0;if(r==="|"||r==="&")return!0;let n=t[t.length-2];return r===">"&&n!==void 0&&e.slice(n.start,n.end)==="="}function Pi(e){return Pl(e,mi(e))}function Rl(e){for(let t=1024;t<e.length;t*=8){let i=e.slice(0,t),r=Ml(i,ce(i),t);if(r!==void 0)return r}return Pl(e,ce(e))}function Pl(e,t){return Ml(e,t,1/0)??!1}function Ml(e,t,i){let r=0;for(let n=0;n<t.length;n++){let o=t[n];if(o.end>=i)return;if(o.kind==="punctuation"){let l=e.charCodeAt(o.start);if(l===123||l===40||l===91)r++;else if(l===125||l===41||l===93)r--;continue}if(r!==0||o.kind!=="word"||o.end-o.start!==6)continue;let s=e.slice(o.start,o.end);if(s==="export")return!0;if(s==="import"){let l=t[n+1];if(l===void 0?i!==1/0:l.end>=i)return;let a=l?e.slice(l.start,l.end):"";if(a!=="("&&a!==".")return!0}}return i===1/0?!1:void 0}function Dl(e){if(e.isExported)return!1;if(["function","variable","interface","type","class","enum","namespace"].includes(e.kind))return!0;return e.kind==="module"&&(e.moduleForm==="namespace"||e.moduleForm==="identifier")}function Il(e,t){let i=e.text,r=ce(i),n=(d)=>r[d]?i.slice(r[d].start,r[d].end):"",o=(d)=>r[d]?.kind==="word",s=new Map,l=[];for(let d=0;d<r.length;d++){let h=n(d);if(h==="("||h==="["||h==="{"||h==="<")l.push(d);else if(h===")"||h==="]"||h==="}"||h===">"&&n(d-1)!=="="){let p=l.at(-1);if(p!==void 0&&(n(p)==="("&&h===")"||n(p)==="["&&h==="]"||n(p)==="{"&&h==="}"||n(p)==="<"&&h===">"))l.pop(),s.set(p,d)}}let a=[];for(let d=0;d<r.length;d++){if(n(d)!=="(")continue;let h=s.get(d);if(h===void 0||!(n(h+1)===":"||n(h+1)==="="&&n(h+2)===">"))continue;let p=new Set,m=d+1;while(m<h){let C=m;while(C<h&&n(C)!==","){let k=s.get(C);if(k!==void 0)C=k+1;else C++}let b=m;while(b<C&&n(b)!==":"&&n(b)!=="="){let k=s.get(b);if(k!==void 0)b=k+1;else b++}let v=m;while([".","public","private","protected","readonly","override"].includes(n(v)))v++;if(n(v)==="{"||n(v)==="[")for(let k of fn(i.slice(r[v].start,r[b-1].end)))p.add(k);else if(o(v))p.add(n(v));m=C+1}let c=h+(n(h+1)===":"?2:3);while(c<r.length){if([";",",",")","]","}"].includes(n(c))||n(c)===">"&&n(c-1)!=="=")break;let C=s.get(c);if(C!==void 0)c=C+1;else c++}a.push({start:d,end:c,names:p})}let f=(d)=>{if(!o(d))return;let h=n(d);if(!a.some((p)=>d>=p.start&&d<p.end&&p.names.has(h)))t.add(h)},u=(d,h)=>{for(let p=d;p<h;p++){if(n(p)==="<"&&s.has(p)){p=s.get(p);continue}if(!o(p)||n(p-1)==="."||n(p+1)===":")continue;if(["true","false","null","undefined","new","this","super","as","satisfies","typeof","void","keyof"].includes(n(p)))continue;f(p)}};for(let d=0;d<r.length;d++){if(n(d)==="typeof")f(d+1);if(n(d)==="export"){let h=d+1;if(n(h)==="default"){if(!["function","class","abstract"].includes(n(h+1)))u(h+1,r.length);continue}if(n(h)==="type")h++;if(n(h)==="{"){let p=s.get(h);if(p===void 0||n(p+1)==="from")continue;for(let m=h+1;m<p;){if(n(m)==="type"&&o(m+1)&&n(m+1)!=="as")m++;f(m);while(m<p&&n(m)!==",")m++;m++}}}if(n(d)==="["){let h=s.get(d);if(h!==void 0&&[":","?","("].includes(n(h+1))&&n(d+2)!==":"&&n(d+2)!=="in")u(d+1,h)}}if(e.kind==="class"){let d=-1;for(let h=0;h<r.length&&n(h)!=="{";h++)if(n(h)==="<"&&s.has(h))h=s.get(h);else if(n(h)==="extends"){d=h;break}if(d!==-1){let h=d+1;while(h<r.length&&n(h)!=="{"&&n(h)!=="implements"){let p=s.get(h);if(p!==void 0)h=p+1;else h++}u(d+1,h)}}}var pr=me(()=>{ht();un()});function ss(e){return typeof e==="string"?oi(e,"'"):String(e)}function Lh(e,t,i=new Map){let r=ce(e),n=new Map(i),o=new Map,s=[],l=1,a=0,f=0;for(let d=1;d<r.length;d++){let h=r[d],p=e.slice(h.start,h.end);if(h.kind==="punctuation"&&a===0&&(p===","||p==="}")){let m=r.slice(l,d),c=m[0];if(c){let C=c.kind==="quoted"?wt(e.slice(c.start,c.end)):e.slice(c.start,c.end),b=m.findIndex((k)=>k.kind==="punctuation"&&e[k.start]==="="),v=f;if(b>=0){let k=m.slice(b+1),W="",A=m[b].end;for(let R=0;R+2<k.length;R++){let[V,B,O]=k.slice(R,R+3);if(V.kind!=="word"||O.kind!=="word"||e.slice(B.start,B.end)!==".")continue;let z=n.get(`${e.slice(V.start,V.end)}.${e.slice(O.start,O.end)}`);if(z===void 0||typeof z==="object")continue;W+=e.slice(A,V.start)+ss(z),A=O.end,R+=2}W+=e.slice(A,m.at(-1).end),v=Pt(W,n),s.push({start:m[b].start,end:m.at(-1).end,text:v===void 0?"":`= ${ss(v)}`})}else if(v!==void 0)s.push({start:c.end,end:c.end,text:` = ${ss(v)}`});if(f=typeof v==="number"?v+1:void 0,C!==void 0){if(n.delete(C),n.delete(`${t}.${C}`),v!==void 0)o.set(C,v),n.set(C,v),n.set(`${t}.${C}`,v)}}l=d+1}else if(h.kind==="punctuation"){if("([{".includes(p))a++;else if(")]}".includes(p))a--}}let u=e;for(let d of s.reverse())u=u.slice(0,d.start)+d.text+u.slice(d.end);return{body:u,members:o}}function Nl(e,t){let i=[...new Set([...e,...t.values()])];if(!i.some((n)=>n.kind==="enum"))return;i.sort((n,o)=>(n.start??0)-(o.start??0));let r=new Map;for(let n of i)if(n.kind==="enum"){let o=n.text.indexOf("{");if(o<0)continue;if(ce(n.text.slice(0,o)).some((l)=>n.text.slice(l.start,l.end)==="declare"))continue;let s=Lh(n.text.slice(o),n.name,r);n.text=n.text.slice(0,o)+s.body;for(let[l,a]of s.members)r.set(`${n.name}.${l}`,a)}else if(n.kind==="variable"&&n.modifiers?.[0]==="const"&&!n.typeAnnotation&&!n.modifiers.includes("const assertion")&&typeof n.value==="string"){let o=Pt(n.value,r);if(o!==void 0)r.set(n.name,o)}}var Fl=me(()=>{ht();dn()});function Wl(e,t){if(t.kind!=="punctuation")return 0;let i=e.slice(t.start,t.end);if("([{<".includes(i))return 1;if(")]}".includes(i)||i===">"&&e[t.start-1]!=="=")return-1;return 0}function pn(e){if(!e.includes("?"))return e;let t=e.trim(),i=t.startsWith("(")&&t.endsWith(")"),r=e.indexOf(t)+(i?1:0),n=i?t.slice(1,-1):t,o=[[]],s=0;for(let h of ce(n)){if(h.kind==="punctuation"&&n[h.start]===","&&s===0)o.push([]);else o[o.length-1].push(h);s+=Wl(n,h)}let l=o.map((h)=>{let p=0,m=-1;for(let[v,k]of h.entries()){if(p===0&&k.kind==="punctuation"&&n[k.start]===":"){m=v;break}p+=Wl(n,k)}let c=m>0&&n[h[m-1].start]==="?"?h[m-1]:void 0,C=h[0]?n.slice(h[0].start,h[0].end):"",b=h[0]&&n.startsWith("...",h[0].start);return{tokens:h,colon:m,question:c,required:h.length>0&&!c&&!b&&C!=="this"}}),a=-1;for(let[h,p]of l.entries())if(p.required)a=h;let f=[];for(let[h,p]of l.entries()){if(h>=a||!p.question||p.colon<0)continue;let m=p.tokens[p.colon+1],c=p.tokens.at(-1);if(!m||!c)continue;f.push({start:r+p.question.start,end:r+p.question.end,text:""},{start:r+m.start,end:r+m.start,text:"("},{start:r+c.end,end:r+c.end,text:") | undefined"})}if(!f.length)return e;let u=[],d=0;for(let h of f)u.push(e.slice(d,h.start),h.text),d=h.end;return u.push(e.slice(d)),u.join("")}function Ll(e){return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36}function Bl(e,t){if(t>=e.length||!Ll(e.charCodeAt(t)))return t;let i=t+1;while(i<e.length&&(Ll(e.charCodeAt(i))||e.charCodeAt(i)>=48&&e.charCodeAt(i)<=57))i++;return i}function as(e,t){let i=t;while(i<e.length&&e.charCodeAt(i)<=32)i++;return i}function mr(e,t){if(t.trim()!=="{}")return null;let i=e.trim();if(i.length<2||i[0]!=="{"||i[i.length-1]!=="}")return null;let r=i.slice(1,-1),n=[],o=0,s=0;for(let a=0;a<r.length;a++){let f=r.charCodeAt(a);if(f===34||f===39||f===96){a++;while(a<r.length&&r.charCodeAt(a)!==f){if(r.charCodeAt(a)===92)a++;a++}if(a>=r.length)return null;continue}if(f===47&&(r.charCodeAt(a+1)===47||r.charCodeAt(a+1)===42))return null;if(f===40||f===91||f===123)o++;else if(f===41||f===93||f===125){if(--o<0)return null}else if(f===44&&o===0)n.push(r.slice(s,a)),s=a+1}if(o!==0)return null;if(r.slice(s).trim()||n.length===0)n.push(r.slice(s));let l=[];for(let a of n){let f=a.trim(),u=Bl(f,0);if(u===0)return null;let d=f.slice(0,u),h=d,p=as(f,u);if(f.charCodeAt(p)===58){let c=as(f,p+1),C=Bl(f,c);if(C===c)return null;h=f.slice(c,C),p=as(f,C)}if(f.charCodeAt(p)!==61||f.charCodeAt(p+1)===61||f.charCodeAt(p+1)===62)return null;let m=f.slice(p+1).trim();if(!m)return null;l.push({key:d,alias:h,value:m})}return l}function mn(e,t){let i=e.map((n)=>n.key===n.alias?n.key:`${n.key}: ${n.alias}`).join(", "),r=e.map((n)=>{let o=t(n.value),s=o==="unknown"||o==="any"?o:`${o.includes("=>")?`(${o})`:o} | undefined`;return`${n.key}?: ${s}`}).join("; ");return`{ ${i} }?: { ${r} }`}var ls=me(()=>{ht()});function Lt(e,t=!0){if(!t||!e||e.length===0)return"";if(e.length===1){let r=e[0];if(r.length>0&&r.charCodeAt(0)>32&&r.charCodeAt(r.length-1)>32)return`${r}
35
35
  `;return`${r.trim()}
36
36
  `}let i="";for(let r=0;r<e.length;r++){if(r>0)i+=`
37
37
  `;i+=e[r].trim()}return`${i}
38
- `}function mr(e){return e.replaceAll("*/","*\\/")}var pn=()=>{};function fs(e){return Yl(e).replace(/\n[ \t]*(?=\n)/g,"")}function Yl(e){if(e.indexOf("/*")===-1)return e.trim();let t=[],i=0,r=0,n=e.length;while(r<n)if(e.charCodeAt(r)===47&&r+1<n&&e.charCodeAt(r+1)===42){if(r>i)t.push(e.substring(i,r));r+=2;while(r<n-1){if(e.charCodeAt(r)===42&&e.charCodeAt(r+1)===47){r+=2;break}r++}i=r}else r++;if(i<n)t.push(e.substring(i));return t.join("").trim()}function gs(){bn=!0,pt=null}function ys(){bn=!1;let e=pt;return pt=null,e}function _l(e,t){if(t===2)return e===48||e===49;if(t===8)return e>=48&&e<=55;if(t===10)return e>=48&&e<=57;return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function Pi(e,t,i){let r=!1,n=!1;while(t.at<e.length){let o=e.charCodeAt(t.at);if(_l(o,i))r=!0,n=!1,t.at++;else if(o===95&&r&&!n&&t.at+1<e.length&&_l(e.charCodeAt(t.at+1),i))n=!0,t.at++;else break}return r&&!n}function Xl(e,t){if(e.charCodeAt(t)!==48||t+1>=e.length)return 0;let i=e.charCodeAt(t+1)|32;return i===120?16:i===98?2:i===111?8:0}function wi(e){if(e.length===0)return!1;let t={at:0};if(e.charCodeAt(0)===45)t.at++;if(t.at>=e.length)return!1;let i=Xl(e,t.at);if(i)return t.at+=2,Pi(e,t,i)&&t.at===e.length;let r=Pi(e,t,10);if(e.charCodeAt(t.at)===46){t.at++;let o=Pi(e,t,10);if(!r&&!o)return!1}else if(!r)return!1;let n=e.charCodeAt(t.at);if(n===101||n===69){if(t.at++,e.charCodeAt(t.at)===43||e.charCodeAt(t.at)===45)t.at++;if(!Pi(e,t,10))return!1}return t.at===e.length}function Bh(e){if(e.length<2||e.charCodeAt(e.length-1)!==110)return!1;let t=e.slice(0,-1),i={at:0};if(t.charCodeAt(0)===45)i.at++;if(i.at>=t.length)return!1;let r=Xl(t,i.at);if(r)return i.at+=2,Pi(t,i,r)&&i.at===t.length;return Pi(t,i,10)&&i.at===t.length}function mn(e){return e.includes("_")?e.replaceAll("_",""):e}function ls(e,t){let i=0,r=0;while((r=e.indexOf(t,r))!==-1)i++,r+=t.length;return i}function jl(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===36||e===95||e===46||e===58||e===45}function gn(e){let t=e.trim();if(t.length<3||t.charCodeAt(0)!==60)return!1;if(t.startsWith("<>"))return t.endsWith("</>");let i=t.charCodeAt(1);if(!(i>=65&&i<=90||i>=97&&i<=122||i===36||i===95))return!1;let r=2;while(r<t.length&&jl(t.charCodeAt(r)))r++;let n=t.slice(1,r),o=t.charCodeAt(r);if(o>32&&o!==62&&o!==47)return!1;if(t.endsWith("/>"))return!0;let s=t.lastIndexOf("</");if(s===-1)return!1;let l=s+2;while(l<t.length&&jl(t.charCodeAt(l)))l++;return t.slice(s+2,l)===n&&t.charCodeAt(l)===62&&l===t.length-1}function yn(e){let t=e.length,i=!1;for(let s=1;s<t;s++)if(e.charCodeAt(s)<=32&&e.charCodeAt(s-1)<=32){i=!0;break}if(!i)for(let s=0;s<t;s++){let l=e.charCodeAt(s);if(l===10||l===13||l===9){i=!0;break}}if(!i)return e;let r=[],n=-1,o=!1;for(let s=0;s<t;s++)if(e.charCodeAt(s)<=32){if(!o){if(n>=0)r.push(e.substring(n,s));r.push(" "),o=!0,n=-1}}else{if(o||n<0)n=s;o=!1}if(n>=0)r.push(e.substring(n));return r.join("")}function Te(e,t=!1,i=!1,r=0,n){if(!e||typeof e!=="string")return"unknown";if(r>=vn)return"unknown";let o=e.trim();if(gn(o))return"JSX.Element";if(o.startsWith("BigInt("))return"bigint";if(o.startsWith("Symbol.for("))return"symbol";if(o.includes(".raw`")||o.includes("String.raw`"))return"string";if(o.startsWith("`")&&o.endsWith("`")){if(!t||o.includes("${")||o.includes(`
39
- `)||o.includes("\r"))return"string";return o}if(o.charCodeAt(0)===39||o.charCodeAt(0)===34){let l=_h(o);if(l!==null){if(l==="string"||!t)return"string";return l}}if(wi(o)){if(!t)return"number";return mn(o)}if(o==="true"||o==="false"){if(!t)return"boolean";return o}if(o==="null")return"null";if(o==="undefined")return"undefined";if(o.startsWith("[")&&o.endsWith("]"))return ds(o,t,r+1,n);if(o.startsWith("{")&&o.endsWith("}"))return sc(o,t,r+1,n);if(o.startsWith("class ")||o.startsWith("class{"))return ip(o);if(o.startsWith("new "))return tp(o);if(o.endsWith("as const")){let l=o.slice(0,-8).trim();if(l.startsWith("[")&&l.endsWith("]")){let a=l.slice(1,-1).trim();if(!a)return"readonly []";let f=yr(a),u=[];for(let d=0;d<f.length;d++){let h=f[d].trim();if(h.startsWith("...")){let p=h.slice(3).trim();if(yi(p))u.push(`...typeof ${p}`);else{let m=Te(p,!0,!1,r+1,n);u.push(m.startsWith("readonly [")||m.endsWith("[]")?`...${m}`:"...unknown[]")}}else u.push(Te(h,!0,!1,r+1,n))}return`readonly [${u.join(", ")}]`}return Te(l,!0,i,r+1,n)}if(Mi(o)!==-1||o.startsWith("function")||o.startsWith("async"))return lc(o,i,r,t);if(o.startsWith("`")&&o.endsWith("`"))return ep(o,t);if(o.startsWith("Promise."))return rc(o,t,r,n);if(o.startsWith("await "))return"unknown";if(o.startsWith("typeof ")&&cs(o.slice(7)))return"string";if(o.startsWith("void ")&&cs(o.slice(5)))return"undefined";if(o.startsWith("delete ")&&cs(o.slice(7)))return"boolean";if(Bh(o)){if(t)return mn(o);return"bigint"}if(o.startsWith("Symbol(")||o==="Symbol.for")return"symbol";let s=Cr(o);if(s!==null)return s;if(Zl(o))return"boolean";if(Uh(o))return"number";return"unknown"}function Gl(e){let t=e.charCodeAt(0);if(t!==39&&t!==34)return!1;return Bt(e,0,t)===e.length}function _h(e){if(Gl(e))return e;let t=jh(e);if(t.length<2)return null;let i=!1,r=!0,n="";for(let o of t){let s=o.trim();if(Gl(s))i=!0,n+=Gh(s);else r=!1}if(r)return Vh(n);if(i)return"string";return null}function jh(e){let t=[],i=0,r=0,n=0;while(n<e.length){let o=e.charCodeAt(n);if(o===39||o===34||o===96){n=Bt(e,n,o);continue}if(o===40||o===91||o===123)i++;else if(o===41||o===93||o===125)i--;else if(o===43&&i===0)t.push(e.slice(r,n)),r=n+1;n++}return t.push(e.slice(r)),t}function Gh(e){return e.slice(1,-1).replace(/\\(.)/g,(t,i)=>{if(i==="n")return`
40
- `;if(i==="t")return"\t";if(i==="r")return"\r";if(i==="0")return"\x00";return i})}function Vh(e){return`'${e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function Uh(e){if(e==="")return!1;let t=!1,i=!1;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n>=48&&n<=57){t=!0;continue}if(n===43||n===45||n===42||n===47||n===37){i=!0;continue}if(n===46||n===40||n===41||n<=32)continue;return!1}return t&&i}function Zl(e){let t=0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);if(r===34||r===39||r===96){i=Bt(e,i,r)-1;continue}if(r===40||r===91||r===123){t++;continue}if(r===41||r===93||r===125){t--;continue}if(t!==0)continue;if(e.startsWith("===",i)||e.startsWith("!==",i)||e.startsWith("==",i)||e.startsWith("!=",i)||e.startsWith(">=",i)||e.startsWith("<=",i))return!0;if((r===62||r===60)&&e.charCodeAt(i-1)!==61&&e.charCodeAt(i+1)!==61)return!0}return!1}function zh(e,t=!1,i=0,r){return Te(e,t,!0,i,r)}function Kt(e,t=!1,i="",r,n){let o=us(i,r),s=[],l=!1,a=0;while(a<e.length){let u=e.charCodeAt(a);if(u===34||u===39||u===96){a=Bt(e,a,u);continue}if(u===47&&e.charCodeAt(a+1)===47){a+=2;while(a<e.length&&e.charCodeAt(a)!==10&&e.charCodeAt(a)!==13)a++;continue}if(u===47&&e.charCodeAt(a+1)===42){let d=e.indexOf("*/",a+2);a=d===-1?e.length:d+2;continue}if(e.startsWith("function",a)&&gr(e,a,8)||e.startsWith("class",a)&&gr(e,a,5)){let d=Qh(e,a);if(d!==-1){a=wn(e,d);continue}}if(u===61&&e.charCodeAt(a+1)===62){let d=ic(e,a+2);if(e.charCodeAt(d)===123){a=wn(e,d);continue}}if(e.startsWith("return",a)&&(a===0||!Mt(e.charCodeAt(a-1)))&&!Mt(e.charCodeAt(a+6))){a+=6;let d=!1;while(a<e.length&&e.charCodeAt(a)<=32){let C=e.charCodeAt(a);if(C===10||C===13)d=!0;a++}if(d||a>=e.length||e.charCodeAt(a)===59||e.charCodeAt(a)===125){l=!0;continue}let h=a,p=0,m=0,c=0;while(a<e.length){let C=e.charCodeAt(a);if(C===34||C===39||C===96){a=Bt(e,a,C);continue}if(C===47&&e.charCodeAt(a+1)===47){if(p===0&&m===0&&c===0)break;while(a<e.length&&e.charCodeAt(a)!==10&&e.charCodeAt(a)!==13)a++;continue}if(C===47&&e.charCodeAt(a+1)===42){let k=e.indexOf("*/",a+2);a=k===-1?e.length:k+2;continue}if(C===40)p++;else if(C===41)p--;else if(C===91)m++;else if(C===93)m--;else if(C===123)c++;else if(C===125){if(c===0&&p===0&&m===0)break;c--}else if(C===59&&p===0&&m===0&&c===0)break;else if((C===10||C===13)&&p===0&&m===0&&c===0){let k=a+1;while(k<e.length&&e.charCodeAt(k)<=32)k++;if(e.startsWith("return",k)&&!Mt(e.charCodeAt(k+6)))break}a++}let v=e.slice(h,a).trim(),b=fs(St(v,o,r,n,h));if(!s.includes(b))s.push(b);continue}a++}if(l&&!s.includes("undefined"))s.push("undefined");let f=s.includes("unknown")?"unknown":s.length===0?"void":ec(s);return t&&!f.startsWith("Promise<")?`Promise<${f}>`:f}function us(e,t){let i=new Map,r=e.startsWith("(")&&e.endsWith(")")?e.slice(1,-1):e,n=ce(r),o=0,s=0,l=[];for(let a of n){let f=r.slice(a.start,a.end);if(f===","&&s===0)l.push(r.slice(o,a.start)),o=a.end;if(["(","[","{","<"].includes(f))s++;else if([")","]","}"].includes(f)||f===">"&&r[a.start-1]!=="=")s--}l.push(r.slice(o));for(let a of l){let f=ce(a),u=-1,d=-1,h=0;for(let v of f){let b=a.slice(v.start,v.end);if(h===0&&b===":"&&u===-1)u=v.start;if(h===0&&b==="="&&a[v.end]!==">"){d=v.start;break}if(["(","[","{","<"].includes(b))h++;else if([")","]","}"].includes(b)||b===">"&&a[v.start-1]!=="=")h--}let p=a.slice(0,u!==-1?u:d!==-1?d:void 0).trim().replace(/^\.\.\./,"").replace(/\?$/,""),m=u===-1&&d!==-1&&!a.trim().startsWith("...")?pr(p,a.slice(d+1)):null;if(m){for(let v of m)i.set(v.alias,t?.(v.value)??Te(v.value,!1));continue}if(!wr(p))continue;let c=u!==-1?a.slice(u+1,d!==-1?d:void 0).trim():"";if(!c&&d!==-1){let v=a.slice(d+1).trim();c=t?.(v)??Te(v,!1)}if(c){if(d===-1&&a.slice(0,u).trim().endsWith("?"))c=`(${c}) | undefined`;i.set(p,c)}}return i}function Kh(e,t){let i=Object.hasOwn(Vl,e)?Vl[e]:void 0;return i&&Object.hasOwn(i,t)?i[t]:void 0}function zt(e){return e.includes(`
38
+ `}function gr(e){return e.replaceAll("*/","*\\/")}var gn=()=>{};function us(e){return Yl(e).replace(/\n[ \t]*(?=\n)/g,"")}function Yl(e){if(e.indexOf("/*")===-1)return e.trim();let t=[],i=0,r=0,n=e.length;while(r<n)if(e.charCodeAt(r)===47&&r+1<n&&e.charCodeAt(r+1)===42){if(r>i)t.push(e.substring(i,r));r+=2;while(r<n-1){if(e.charCodeAt(r)===42&&e.charCodeAt(r+1)===47){r+=2;break}r++}i=r}else r++;if(i<n)t.push(e.substring(i));return t.join("").trim()}function ys(){En=!0,pt=null}function ws(){En=!1;let e=pt;return pt=null,e}function _l(e,t){if(t===2)return e===48||e===49;if(t===8)return e>=48&&e<=55;if(t===10)return e>=48&&e<=57;return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function Mi(e,t,i){let r=!1,n=!1;while(t.at<e.length){let o=e.charCodeAt(t.at);if(_l(o,i))r=!0,n=!1,t.at++;else if(o===95&&r&&!n&&t.at+1<e.length&&_l(e.charCodeAt(t.at+1),i))n=!0,t.at++;else break}return r&&!n}function Xl(e,t){if(e.charCodeAt(t)!==48||t+1>=e.length)return 0;let i=e.charCodeAt(t+1)|32;return i===120?16:i===98?2:i===111?8:0}function Ci(e){if(e.length===0)return!1;let t={at:0};if(e.charCodeAt(0)===45)t.at++;if(t.at>=e.length)return!1;let i=Xl(e,t.at);if(i)return t.at+=2,Mi(e,t,i)&&t.at===e.length;let r=Mi(e,t,10);if(e.charCodeAt(t.at)===46){t.at++;let o=Mi(e,t,10);if(!r&&!o)return!1}else if(!r)return!1;let n=e.charCodeAt(t.at);if(n===101||n===69){if(t.at++,e.charCodeAt(t.at)===43||e.charCodeAt(t.at)===45)t.at++;if(!Mi(e,t,10))return!1}return t.at===e.length}function Bh(e){if(e.length<2||e.charCodeAt(e.length-1)!==110)return!1;let t=e.slice(0,-1),i={at:0};if(t.charCodeAt(0)===45)i.at++;if(i.at>=t.length)return!1;let r=Xl(t,i.at);if(r)return i.at+=2,Mi(t,i,r)&&i.at===t.length;return Mi(t,i,10)&&i.at===t.length}function yn(e){return e.includes("_")?e.replaceAll("_",""):e}function cs(e,t){let i=0,r=0;while((r=e.indexOf(t,r))!==-1)i++,r+=t.length;return i}function jl(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===36||e===95||e===46||e===58||e===45}function wn(e){let t=e.trim();if(t.length<3||t.charCodeAt(0)!==60)return!1;if(t.startsWith("<>"))return t.endsWith("</>");let i=t.charCodeAt(1);if(!(i>=65&&i<=90||i>=97&&i<=122||i===36||i===95))return!1;let r=2;while(r<t.length&&jl(t.charCodeAt(r)))r++;let n=t.slice(1,r),o=t.charCodeAt(r);if(o>32&&o!==62&&o!==47)return!1;if(t.endsWith("/>"))return!0;let s=t.lastIndexOf("</");if(s===-1)return!1;let l=s+2;while(l<t.length&&jl(t.charCodeAt(l)))l++;return t.slice(s+2,l)===n&&t.charCodeAt(l)===62&&l===t.length-1}function Cn(e){let t=e.length,i=!1;for(let s=1;s<t;s++)if(e.charCodeAt(s)<=32&&e.charCodeAt(s-1)<=32){i=!0;break}if(!i)for(let s=0;s<t;s++){let l=e.charCodeAt(s);if(l===10||l===13||l===9){i=!0;break}}if(!i)return e;let r=[],n=-1,o=!1;for(let s=0;s<t;s++)if(e.charCodeAt(s)<=32){if(!o){if(n>=0)r.push(e.substring(n,s));r.push(" "),o=!0,n=-1}}else{if(o||n<0)n=s;o=!1}if(n>=0)r.push(e.substring(n));return r.join("")}function Te(e,t=!1,i=!1,r=0,n){if(!e||typeof e!=="string")return"unknown";if(r>=$n)return"unknown";let o=e.trim();if(wn(o))return"JSX.Element";if(o.startsWith("BigInt("))return"bigint";if(o.startsWith("Symbol.for("))return"symbol";if(o.includes(".raw`")||o.includes("String.raw`"))return"string";if(o.startsWith("`")&&o.endsWith("`")){if(!t||o.includes("${")||o.includes(`
39
+ `)||o.includes("\r"))return"string";return o}if(o.charCodeAt(0)===39||o.charCodeAt(0)===34){let l=_h(o);if(l!==null){if(l==="string"||!t)return"string";return l}}if(Ci(o)){if(!t)return"number";return yn(o)}if(o==="true"||o==="false"){if(!t)return"boolean";return o}if(o==="null")return"null";if(o==="undefined")return"undefined";if(o.startsWith("[")&&o.endsWith("]"))return hs(o,t,r+1,n);if(o.startsWith("{")&&o.endsWith("}"))return sc(o,t,r+1,n);if(o.startsWith("class ")||o.startsWith("class{"))return op(o);if(o.startsWith("new "))return np(o);if(o.endsWith("as const")){let l=o.slice(0,-8).trim();if(l.startsWith("[")&&l.endsWith("]")){let a=l.slice(1,-1).trim();if(!a)return"readonly []";let f=wr(a),u=[];for(let d=0;d<f.length;d++){let h=f[d].trim();if(h.startsWith("...")){let p=h.slice(3).trim();if(yi(p))u.push(`...typeof ${p}`);else{let m=Te(p,!0,!1,r+1,n);u.push(m.startsWith("readonly [")||m.endsWith("[]")?`...${m}`:"...unknown[]")}}else u.push(Te(h,!0,!1,r+1,n))}return`readonly [${u.join(", ")}]`}return Te(l,!0,i,r+1,n)}if(wi(o)!==-1||o.startsWith("function")||o.startsWith("async"))return lc(o,i,r,t);if(o.startsWith("`")&&o.endsWith("`"))return rp(o,t);if(o.startsWith("Promise."))return rc(o,t,r,n);if(o.startsWith("await "))return"unknown";if(o.startsWith("typeof ")&&fs(o.slice(7)))return"string";if(o.startsWith("void ")&&fs(o.slice(5)))return"undefined";if(o.startsWith("delete ")&&fs(o.slice(7)))return"boolean";if(Bh(o)){if(t)return yn(o);return"bigint"}if(o.startsWith("Symbol(")||o==="Symbol.for")return"symbol";let s=Cr(o);if(s!==null)return s;if(Zl(o))return"boolean";if(Uh(o))return"number";return"unknown"}function Gl(e){let t=e.charCodeAt(0);if(t!==39&&t!==34)return!1;return Bt(e,0,t)===e.length}function _h(e){if(Gl(e))return e;let t=jh(e);if(t.length<2)return null;let i=!1,r=!0,n="";for(let o of t){let s=o.trim();if(Gl(s))i=!0,n+=Gh(s);else r=!1}if(r)return Vh(n);if(i)return"string";return null}function jh(e){let t=[],i=0,r=0,n=0;while(n<e.length){let o=e.charCodeAt(n);if(o===39||o===34||o===96){n=Bt(e,n,o);continue}if(o===40||o===91||o===123)i++;else if(o===41||o===93||o===125)i--;else if(o===43&&i===0)t.push(e.slice(r,n)),r=n+1;n++}return t.push(e.slice(r)),t}function Gh(e){return e.slice(1,-1).replace(/\\(.)/g,(t,i)=>{if(i==="n")return`
40
+ `;if(i==="t")return"\t";if(i==="r")return"\r";if(i==="0")return"\x00";return i})}function Vh(e){return`'${e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function Uh(e){if(e==="")return!1;let t=!1,i=!1;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n>=48&&n<=57){t=!0;continue}if(n===43||n===45||n===42||n===47||n===37){i=!0;continue}if(n===46||n===40||n===41||n<=32)continue;return!1}return t&&i}function Zl(e){let t=0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);if(r===34||r===39||r===96){i=Bt(e,i,r)-1;continue}if(r===40||r===91||r===123){t++;continue}if(r===41||r===93||r===125){t--;continue}if(t!==0)continue;if(e.startsWith("===",i)||e.startsWith("!==",i)||e.startsWith("==",i)||e.startsWith("!=",i)||e.startsWith(">=",i)||e.startsWith("<=",i))return!0;if((r===62||r===60)&&e.charCodeAt(i-1)!==61&&e.charCodeAt(i+1)!==61)return!0}return!1}function zh(e,t=!1,i=0,r){return Te(e,t,!0,i,r)}function Kt(e,t=!1,i="",r,n){let o=ds(i,r),s=[],l=!1,a=0;while(a<e.length){let u=e.charCodeAt(a);if(u===34||u===39||u===96){a=Bt(e,a,u);continue}if(u===47&&e.charCodeAt(a+1)===47){a+=2;while(a<e.length&&e.charCodeAt(a)!==10&&e.charCodeAt(a)!==13)a++;continue}if(u===47&&e.charCodeAt(a+1)===42){let d=e.indexOf("*/",a+2);a=d===-1?e.length:d+2;continue}if(e.startsWith("function",a)&&yr(e,a,8)||e.startsWith("class",a)&&yr(e,a,5)){let d=ip(e,a);if(d!==-1){a=vn(e,d);continue}}if(u===61&&e.charCodeAt(a+1)===62){let d=ic(e,a+2);if(e.charCodeAt(d)===123){a=vn(e,d);continue}}if(e.startsWith("return",a)&&(a===0||!Mt(e.charCodeAt(a-1)))&&!Mt(e.charCodeAt(a+6))){a+=6;let d=!1;while(a<e.length&&e.charCodeAt(a)<=32){let v=e.charCodeAt(a);if(v===10||v===13)d=!0;a++}if(d||a>=e.length||e.charCodeAt(a)===59||e.charCodeAt(a)===125){l=!0;continue}let h=a,p=0,m=0,c=0;while(a<e.length){let v=e.charCodeAt(a);if(v===34||v===39||v===96){a=Bt(e,a,v);continue}if(v===47&&e.charCodeAt(a+1)===47){if(p===0&&m===0&&c===0)break;while(a<e.length&&e.charCodeAt(a)!==10&&e.charCodeAt(a)!==13)a++;continue}if(v===47&&e.charCodeAt(a+1)===42){let k=e.indexOf("*/",a+2);a=k===-1?e.length:k+2;continue}if(v===40)p++;else if(v===41)p--;else if(v===91)m++;else if(v===93)m--;else if(v===123)c++;else if(v===125){if(c===0&&p===0&&m===0)break;c--}else if(v===59&&p===0&&m===0&&c===0)break;else if((v===10||v===13)&&p===0&&m===0&&c===0){let k=a+1;while(k<e.length&&e.charCodeAt(k)<=32)k++;if(e.startsWith("return",k)&&!Mt(e.charCodeAt(k+6)))break}a++}let C=e.slice(h,a).trim(),b=us(St(C,o,r,n,h));if(!s.includes(b))s.push(b);continue}a++}if(l&&!s.includes("undefined"))s.push("undefined");let f=s.includes("unknown")?"unknown":s.length===0?"void":ec(s);return t&&!f.startsWith("Promise<")?`Promise<${f}>`:f}function ds(e,t){let i=new Map,r=e.startsWith("(")&&e.endsWith(")")?e.slice(1,-1):e,n=ce(r),o=0,s=0,l=[];for(let a of n){let f=r.slice(a.start,a.end);if(f===","&&s===0)l.push(r.slice(o,a.start)),o=a.end;if(["(","[","{","<"].includes(f))s++;else if([")","]","}"].includes(f)||f===">"&&r[a.start-1]!=="=")s--}l.push(r.slice(o));for(let a of l){let f=ce(a),u=-1,d=-1,h=0;for(let C of f){let b=a.slice(C.start,C.end);if(h===0&&b===":"&&u===-1)u=C.start;if(h===0&&b==="="&&a[C.end]!==">"){d=C.start;break}if(["(","[","{","<"].includes(b))h++;else if([")","]","}"].includes(b)||b===">"&&a[C.start-1]!=="=")h--}let p=a.slice(0,u!==-1?u:d!==-1?d:void 0).trim().replace(/^\.\.\./,"").replace(/\?$/,""),m=u===-1&&d!==-1&&!a.trim().startsWith("...")?mr(p,a.slice(d+1)):null;if(m){for(let C of m)i.set(C.alias,t?.(C.value)??Te(C.value,!1));continue}if(!Di(p)){if(p.startsWith("{")||p.startsWith("["))for(let C of fn(p))i.set(C,"unknown");continue}let c=u!==-1?a.slice(u+1,d!==-1?d:void 0).trim():"";if(!c&&d!==-1){let C=a.slice(d+1).trim();c=t?.(C)??Te(C,!1)}if(c){if(d===-1&&a.slice(0,u).trim().endsWith("?"))c=`(${c}) | undefined`;i.set(p,c)}else i.set(p,"unknown")}return i}function Kh(e,t){let i=Object.hasOwn(Vl,e)?Vl[e]:void 0;return i&&Object.hasOwn(i,t)?i[t]:void 0}function zt(e){return e.includes(`
41
41
  `)?e.replaceAll(`
42
42
  `,`
43
- `):e}function Hh(e,t){if(e=e.trim(),!e.startsWith("{")||!e.endsWith("}"))return;let i=e.slice(1,-1),r=ce(i),n=0,o=0;for(let s=0;s<=r.length;s++){let l=r[s],a=l?i.slice(l.start,l.end):";";if(o===0&&(a===";"||a===",")){let f=i.slice(n,l?.start).trim(),u=f.indexOf(":");if(u!==-1&&f.slice(0,u).trim()===t)return f.slice(u+1).trim();n=l?.end??i.length}if(["(","[","{","<"].includes(a))o++;else if([")","]","}"].includes(a)||a===">"&&l&&i[l.start-1]!=="=")o--}return}function St(e,t,i,r,n=0,o=0){if(o>=vn)return"unknown";let s=e.trim();while($n(s))s=s.slice(1,-1).trim();let l=i?.(s);if(l)return l;if(gn(s))return"JSX.Element";if(s.startsWith("await ")){let b=St(s.slice(6),t,i,r,n,o+1);return b.startsWith("Promise<")&&b.endsWith(">")?b.slice(8,-1):b}if(t.has(s))return t.get(s);let a=/^([\w$]+)\.([\w$]+(?:\.[\w$]+)*)$/.exec(s),f;if(a){let b=t.get(a[1]),C=b&&Hh(b,a[2]);if(C)return C;if(b)f=`typeof ${s}`}if(s.startsWith("!"))return"boolean";if(s.startsWith("fetch("))return"Promise<Response>";if(Zh(s))return Te(s,!1);let u=tc(s);if(u){let b=St(u.whenTrue,t,i,r,n,o+1),C=St(u.whenFalse,t,i,r,n,o+1);return b===C?b:ec([b,C])}for(let b of["??","||","&&"]){let C=Ql(s,b);if(C!==-1){let k=St(s.slice(0,C),t,i,r,n,o+1),W=St(s.slice(C+b.length),t,i,r,n,o+1);return Jh(k,W,b)}}let d=qh(s);if(d&&r)return r(d,n);if(Zl(s))return"boolean";let h=0;for(let b=s.length-1;b>=0;b--){let C=s.charCodeAt(b);if(C===41||C===93||C===125)h++;else if(C===40||C===91||C===123)h--;else if(h===0&&(C===43||C===45||C===42||C===47||C===37)){let k=St(s.slice(0,b),t,i,r,n,o+1),W=St(s.slice(b+1),t,i,r,n,o+1);if(C===43&&(k==="string"||W==="string"))return"string";if(k==="number"&&W==="number")return"number";break}}if(s.startsWith("[")&&s.endsWith("]")){let b=yr(s.slice(1,-1));if(b.some((C)=>C.trim().startsWith("..."))){let C=b.map((k)=>{let W=k.trim();if(!W)return"undefined";let A=W.startsWith("..."),R=St(A?W.slice(3):W,t,i,r,n,o+1);return A?`(NonNullable<${R}> extends Iterable<infer Element> ? Element : never)`:R});return`(${[...new Set(C)].join(" | ")||"never"})[]`}}let p=f??(s.startsWith("{")&&s.endsWith("}")?sc(s,!1,o+1,void 0,(b)=>St(b,t,i,r,n,o+1)):Te(s,!1)),m=ce(p),c="",v=0;for(let b=0;b<m.length;b++){let C=m[b];if(C.kind!=="word"||p.slice(C.start,C.end)!=="typeof")continue;let k=m[b+1];if(!k||k.kind!=="word")continue;let W=t.get(p.slice(k.start,k.end)),A=W,R=!W,V=C.start,B=k.end,O=b,z=[];b++;while(m[b+1]&&p.slice(m[b+1].start,m[b+1].end)==="."&&m[b+2]?.kind==="word"){let be=m[b+2];if(z.push(p.slice(be.start,be.end)),!R)W=`(${W})["${p.slice(be.start,be.end)}"]`;B=be.end,b+=2}let X=O>=2&&p.slice(m[O-2].start,m[O-2].end)==="ReturnType"&&p.slice(m[O-1].start,m[O-1].end)==="<"&&m[b+1]&&p.slice(m[b+1].start,m[b+1].end)===">",ae=A&&X&&z.length===1?Kh(A.trim(),z[0]):void 0;if(ae){V=m[O-2].start,B=m[++b].end;let be=V===0&&B===p.length;c+=p.slice(v,V)+(be||!ae.includes("|")?ae:`(${ae})`),v=B;continue}if(R&&X)V=m[O-2].start,B=m[++b].end;c+=p.slice(v,V)+(W??"unknown"),v=B}return c+p.slice(v)}function qh(e){let t=ce(e),i=0,r=-1;for(let o=0;o<t.length;o++){let s=t[o],l=e.slice(s.start,s.end);if(s.kind!=="punctuation"&&s.kind!=="word")continue;if(["(","[","{"].includes(l))i++;else if([")","]","}"].includes(l))i--;else if(!i&&l==="as"&&o>0&&e.slice(t[o-1].start,t[o-1].end)!==".")r=o}if(r===-1||r+1===t.length)return;let n=e.slice(t[r].end).trim();if(n==="const")return;i=0;for(let o of t.slice(r+1)){if(o.kind!=="punctuation")continue;let s=e.slice(o.start,o.end);if(!i&&["??","||","&&"].some((l)=>e.startsWith(l,o.start)))return;if(["(","[","{","<"].includes(s))i++;else if([")","]","}",">"].includes(s))i--;else if(!i&&["+","-","*","/","%","=","!",";"].includes(s))return}return n}function Ql(e,t){let i=0;for(let r of ce(e)){if(r.kind!=="punctuation")continue;let n=e.slice(r.start,r.end);if(["(","[","{"].includes(n))i++;else if([")","]","}"].includes(n))i--;if(!i&&e.startsWith(t,r.start))return r.start}return-1}function Jh(e,t,i){if(e.trim()==="unknown")return i==="&&"||t.trim()==="unknown"?"unknown":`{} | ${t}`;let r="false | 0 | 0n | '' | null | undefined";if(i==="??")return`([${e}] extends [NonNullable<${e}>] ? ${e} : NonNullable<${e}> | ${t})`;if(i==="||")return`([${e}] extends [object] ? ${e} : [Exclude<${e}, object> & (${r})] extends [never] ? ${e} : Exclude<NonNullable<${e}>, ${r}> | ${t})`;return`([${e}] extends [object] ? ${t} : [${e}] extends [${r}] ? ${e} : unknown extends (${e}) ? ${e} : (Exclude<${e}, object> & (${r})) | ${t})`}function Yh(e){let t=`(NonNullable<${e}> extends infer __dtsx_spread_value ? { -readonly [__dtsx_spread_key in keyof __dtsx_spread_value]: __dtsx_spread_value[__dtsx_spread_key] } : never)`,i=`(NonNullable<${e}> extends infer __dtsx_spread_value ? { -readonly [__dtsx_spread_key in keyof __dtsx_spread_value]?: __dtsx_spread_value[__dtsx_spread_key] } : never)`;return`([${e}] extends [null | undefined] ? {} : [${e}] extends [NonNullable<${e}>] ? ${t} : ${i})`}function Xh(e,t){let i=e.trim();while($n(i))i=i.slice(1,-1).trim();let r=Ql(i,"??");if(r!==-1&&i.slice(r+2).trim()==="{}")return Yh(t(i.slice(0,r)));let n=tc(i);if(n){if(n.whenFalse.trim()==="{}")return`Partial<${t(n.whenTrue)}>`;if(n.whenTrue.trim()==="{}")return`Partial<${t(n.whenFalse)}>`}return t(i)}function ec(e){return e.map((t)=>e.length>1&&Mi(t)!==-1?`(${t})`:t).join(" | ")}function Ul(e){let t=0;while(t<e.length){let n=e.charCodeAt(t);if(n<=32)t++;else if(n===47&&e.charCodeAt(t+1)===47){t+=2;while(t<e.length&&e.charCodeAt(t)!==10&&e.charCodeAt(t)!==13)t++}else if(n===47&&e.charCodeAt(t+1)===42){let o=e.indexOf("*/",t+2);t=o===-1?e.length:o+2}else break}let i=t,r=t;while(r<e.length){let n=e.charCodeAt(r);if(n===34||n===39||n===96){r=Bt(e,r,n),i=r;continue}if(n===92){r=Math.min(r+2,e.length),i=r;continue}if(n===47&&e.charCodeAt(r+1)===47){while(r<e.length&&e.charCodeAt(r)!==10&&e.charCodeAt(r)!==13)r++;continue}if(n===47&&e.charCodeAt(r+1)===42){let o=e.indexOf("*/",r+2);r=o===-1?e.length:o+2;continue}if(r++,n>32)i=r}return e.slice(t,i)}function cs(e){let t=0;for(let i=0;i<e.length;i++){let r=e[i];if(r==="'"||r==='"'||r==="`"){let n=i+1;while(n<e.length&&e[n]!==r){if(e[n]==="\\")n++;n++}i=n;continue}if(r==="("||r==="["||r==="{")t++;else if(r===")"||r==="]"||r==="}")t--;else if(t!==0)continue;else if(r==="?"){if(e[i+1]!==".")return!1}else if("=!<>&|+-*/%,:".includes(r))return!1;else if(r===" "||r==="\t"||r===`
44
- `||r==="\r"){let n=e.slice(i).trimStart();if(n&&n[0]!=="."&&n[0]!=="?"&&n[0]!=="("&&n[0]!=="[")return!1}}return!0}function Zh(e){if(e.startsWith("function")&&gr(e,0,8))return!0;let t=Mi(e);if(t===-1)return!1;let i=e.slice(0,t).trim();if(i.startsWith("async")&&gr(i,0,5))i=i.slice(5).trim();if(i.startsWith("<")){let n=ot(i,0,"<",">");if(n===-1)return!1;i=i.slice(n+1).trim()}if(i.startsWith("(")){let n=ot(i,0,"(",")");if(n===-1)return!1;let o=i.slice(n+1).trim();if(o&&!o.startsWith(":"))return!1}let r=ms(i);return $n(r.params)||wr(r.params)}function $n(e){if(!e.startsWith("(")||!e.endsWith(")"))return!1;let t=0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);if(r===40)t++;else if(r===41&&--t===0)return i===e.length-1}return!1}function tc(e){let t=0,i=-1;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n===34||n===39||n===96){r=Bt(e,r,n)-1;continue}if(n===47&&(e.charCodeAt(r+1)===47||e.charCodeAt(r+1)===42)){if(e.charCodeAt(r+1)===47)while(r+1<e.length&&e.charCodeAt(r+1)!==10&&e.charCodeAt(r+1)!==13)r++;else{let o=e.indexOf("*/",r+2);r=o===-1?e.length:o+1}continue}if(n===40||n===91||n===123)t++;else if(n===41||n===93||n===125)t--;else if(n===63&&t===0&&e.charCodeAt(r+1)!==63)i=r;else if(n===58&&t===0&&i!==-1)return{whenTrue:Ul(e.slice(i+1,r)),whenFalse:Ul(e.slice(r+1))}}return null}function gr(e,t,i){return(t===0||!Mt(e.charCodeAt(t-1)))&&!Mt(e.charCodeAt(t+i))}function ic(e,t){let i=t;while(i<e.length){if(e.charCodeAt(i)<=32){i++;continue}if(e.startsWith("//",i)){while(i<e.length&&e.charCodeAt(i)!==10&&e.charCodeAt(i)!==13)i++;continue}if(e.startsWith("/*",i)){let r=e.indexOf("*/",i+2);i=r<0?e.length:r+2;continue}break}return i}function Qh(e,t){let i=0,r=0,n=0,o=!1,s=!1;for(let l=t;l<e.length;l++){if(l=ic(e,l),l>=e.length)break;let a=e.charCodeAt(l);if(a===34||a===39||a===96){l=Bt(e,l,a)-1,s=!1;continue}if(Mt(a)||a>=128){let f=l;while(l+1<e.length&&(Mt(e.charCodeAt(l+1))||e.charCodeAt(l+1)>=128))l++;s=o&&["keyof","typeof","readonly","unique","new","abstract","infer","extends"].includes(e.slice(f,l+1));continue}if(a===61&&e.charCodeAt(l+1)===62){l++,s=o;continue}if(a===40)i++;else if(a===41)i--,s=!1;else if(a===91)r++;else if(a===93)r--,s=!1;else if(a===60&&i===0&&r===0)n++;else if(a===62&&n>0&&i===0&&r===0)n--,s=!1;else if(a===123)if(i||r||n||o&&s)l=wn(e,l)-1,s=!1;else return l;else if(i===0&&r===0&&n===0){if(a===58)o=!0,s=!0;else if(o&&[124,38,63].includes(a))s=!0;else if(a===59)return-1}}return-1}function wn(e,t){let i=1,r=t+1;while(r<e.length&&i>0){let n=e.charCodeAt(r);if(n===34||n===39||n===96){r=Bt(e,r,n);continue}if(n===47&&e.charCodeAt(r+1)===47){r+=2;while(r<e.length&&e.charCodeAt(r)!==10&&e.charCodeAt(r)!==13)r++;continue}if(n===47&&e.charCodeAt(r+1)===42){let o=e.indexOf("*/",r+2);r=o===-1?e.length:o+2;continue}if(n===123)i++;else if(n===125)i--;r++}return r}function Bt(e,t,i){let r=t+1;while(r<e.length){let n=e.charCodeAt(r);if(n===92){r+=2;continue}if(i===96&&n===36&&e.charCodeAt(r+1)===123){r=wn(e,r+1);continue}if(r++,n===i)break}return r}function ep(e,t){if(e.includes(".raw`")||e.includes("String.raw`"))return"string";if(!t||e.includes("${")||e.includes(`
45
- `)||e.includes("\r"))return"string";return e}function tp(e){let t=4;while(t<e.length&&e.charCodeAt(t)<=32)t++;let i=t,r=e.charCodeAt(t);if(r<65||r>90)return"unknown";while(t<e.length&&(Mt(e.charCodeAt(t))||e.charCodeAt(t)===46))t++;if(t===i)return"unknown";let n=e.slice(i,t);{let o=e.slice(t),s=o;if(o.startsWith("<")){let a=0,f=-1;for(let u=0;u<o.length;u++)if(o[u]==="<")a++;else if(o[u]===">"){if(a--,a===0){f=u;break}}if(f!==-1){let u=o.slice(0,f+1);s=o.slice(f+1);let d=s.indexOf("(");if(d!==-1){let h=0,p=-1;for(let m=d;m<s.length;m++)if(s[m]==="(")h++;else if(s[m]===")"){if(h--,h===0){p=m;break}}if(p!==-1){if(s.slice(p+1).trimStart().startsWith("."))return"unknown"}}return`${n}${u}`}}let l=s.indexOf("(");if(l!==-1){let a=0,f=-1;for(let u=l;u<s.length;u++)if(s[u]==="(")a++;else if(s[u]===")"){if(a--,a===0){f=u;break}}if(f!==-1){if(s.slice(f+1).trimStart().startsWith("."))return"unknown"}}switch(n){case"Date":return"Date";case"Map":return"Map<any, any>";case"Set":return"Set<any>";case"WeakMap":return"WeakMap<any, any>";case"WeakSet":return"WeakSet<any>";case"RegExp":return"RegExp";case"Error":return"Error";case"Array":return"any[]";case"Object":return"object";case"Function":return"Function";case"Promise":return"Promise<any>";default:return n}}return"unknown"}function ip(e){return"{ new (...args: any[]): any }"}function rc(e,t,i=0,r){if(e.startsWith("Promise.resolve(")){let n=e.indexOf(")",16);if(n!==-1){let o=e.slice(16,n).trim();if(o)return`Promise<${Te(o,t,!1,i+1,r)}>`}return"Promise<unknown>"}if(e.startsWith("Promise.reject("))return"Promise<never>";if(e.startsWith("Promise.all(")){let n=e.indexOf("[",12),o=e.lastIndexOf("]");if(n!==-1&&o>n){let s=e.slice(n+1,o).trim(),l=yr(s),a=[];for(let f=0;f<l.length;f++){let u=l[f].trim();if(u.startsWith("Promise.resolve(")){let d=rc(u,t,i+1,r),h=d.indexOf("<"),p=d.lastIndexOf(">");a.push(h!==-1&&p>h?d.slice(h+1,p):"unknown")}else a.push(Te(u,t,!1,i+1,r))}return`Promise<[${a.join(", ")}]>`}return"Promise<unknown[]>"}return"Promise<unknown>"}function ds(e,t,i=0,r){let n=e.slice(1,-1).trim();if(!n)return"never[]";if(i>=vn)return"unknown[]";let o=yr(n),s=!1;for(let p=0;p<o.length;p++){let m=o[p],c=m.length;while(c>0&&m.charCodeAt(c-1)<=32)c--;if(c>=8&&m.slice(c-8,c)==="as const"){s=!0;break}}if(s){let p=[];for(let m=0;m<o.length;m++){let c=o[m].trim();if(c.endsWith("as const")){let v=c.slice(0,-8).trim();if(v.startsWith("[")&&v.endsWith("]")){let b=v.slice(1,-1).trim(),C=yr(b),k=[];for(let W=0;W<C.length;W++)k.push(Te(C[W].trim(),!0,!1,i+1,r));p.push(`readonly [${k.join(", ")}]`)}else p.push(Te(v,!0,!1,i+1,r))}else if(c.startsWith("[")&&c.endsWith("]"))p.push(ds(c,!0,i+1,r));else p.push(Te(c,!0,!1,i+1,r))}return`readonly [
43
+ `):e}function Hh(e,t){if(e=e.trim(),!e.startsWith("{")||!e.endsWith("}"))return;let i=e.slice(1,-1),r=ce(i),n=0,o=0;for(let s=0;s<=r.length;s++){let l=r[s],a=l?i.slice(l.start,l.end):";";if(o===0&&(a===";"||a===",")){let f=i.slice(n,l?.start).trim(),u=f.indexOf(":");if(u!==-1&&f.slice(0,u).trim()===t)return f.slice(u+1).trim();n=l?.end??i.length}if(["(","[","{","<"].includes(a))o++;else if([")","]","}"].includes(a)||a===">"&&l&&i[l.start-1]!=="=")o--}return}function St(e,t,i,r,n=0,o=0){if(o>=$n)return"unknown";let s=e.trim();while(xn(s))s=s.slice(1,-1).trim();let l=i?.(s);if(l)return l;if(wn(s))return"JSX.Element";if(s.startsWith("await ")){let b=St(s.slice(6),t,i,r,n,o+1);return b.startsWith("Promise<")&&b.endsWith(">")?b.slice(8,-1):b}if(t.has(s))return t.get(s);let a=/^([\w$]+)\.([\w$]+(?:\.[\w$]+)*)$/.exec(s),f;if(a){let b=t.get(a[1]),v=b&&Hh(b,a[2]);if(v)return v;if(b)f=`typeof ${s}`}if(s.startsWith("!"))return"boolean";if(s.startsWith("fetch("))return"Promise<Response>";if(tp(s))return Te(s,!1);let u=tc(s);if(u){let b=St(u.whenTrue,t,i,r,n,o+1),v=St(u.whenFalse,t,i,r,n,o+1);return b===v?b:ec([b,v])}for(let b of["??","||","&&"]){let v=Ql(s,b);if(v!==-1){let k=St(s.slice(0,v),t,i,r,n,o+1),W=St(s.slice(v+b.length),t,i,r,n,o+1);return Zh(k,W,b)}}let d=qh(s);if(d&&r)return r(d,n);if(Zl(s))return"boolean";let h=0;for(let b=s.length-1;b>=0;b--){let v=s.charCodeAt(b);if(v===41||v===93||v===125)h++;else if(v===40||v===91||v===123)h--;else if(h===0&&(v===43||v===45||v===42||v===47||v===37)){let k=St(s.slice(0,b),t,i,r,n,o+1),W=St(s.slice(b+1),t,i,r,n,o+1);if(v===43&&(k==="string"||W==="string"))return"string";if(k==="number"&&W==="number")return"number";break}}if(s.startsWith("[")&&s.endsWith("]")){let b=wr(s.slice(1,-1));if(b.some((v)=>v.trim().startsWith("..."))){let v=b.map((k)=>{let W=k.trim();if(!W)return"undefined";let A=W.startsWith("..."),R=St(A?W.slice(3):W,t,i,r,n,o+1);return A?`(NonNullable<${R}> extends Iterable<infer Element> ? Element : never)`:R});return`(${[...new Set(v)].join(" | ")||"never"})[]`}}let p=f??(s.startsWith("{")&&s.endsWith("}")?sc(s,!1,o+1,void 0,(b)=>St(b,t,i,r,n,o+1)):Te(s,!1));if(p==="unknown"&&Di(s)&&r)return r(`typeof ${s}`,n);let m=ce(p),c="",C=0;for(let b=0;b<m.length;b++){let v=m[b];if(v.kind!=="word"||p.slice(v.start,v.end)!=="typeof")continue;let k=m[b+1];if(!k||k.kind!=="word")continue;let W=t.get(p.slice(k.start,k.end)),A=W,R=!W,V=v.start,B=k.end,O=b,z=[];b++;while(m[b+1]&&p.slice(m[b+1].start,m[b+1].end)==="."&&m[b+2]?.kind==="word"){let be=m[b+2];if(z.push(p.slice(be.start,be.end)),!R)W=`(${W})["${p.slice(be.start,be.end)}"]`;B=be.end,b+=2}let X=O>=2&&p.slice(m[O-2].start,m[O-2].end)==="ReturnType"&&p.slice(m[O-1].start,m[O-1].end)==="<"&&m[b+1]&&p.slice(m[b+1].start,m[b+1].end)===">",ae=A&&X&&z.length===1?Kh(A.trim(),z[0]):void 0;if(ae){V=m[O-2].start,B=m[++b].end;let be=V===0&&B===p.length;c+=p.slice(C,V)+(be||!ae.includes("|")?ae:`(${ae})`),C=B;continue}if(R&&X)V=m[O-2].start,B=m[++b].end;c+=p.slice(C,V)+(W??"unknown"),C=B}return c+p.slice(C)}function qh(e){let t=ce(e),i=0,r=-1;for(let o=0;o<t.length;o++){let s=t[o],l=e.slice(s.start,s.end);if(s.kind!=="punctuation"&&s.kind!=="word")continue;if(["(","[","{"].includes(l))i++;else if([")","]","}"].includes(l))i--;else if(!i&&l==="as"&&o>0&&e.slice(t[o-1].start,t[o-1].end)!==".")r=o}if(r===-1||r+1===t.length)return;let n=e.slice(t[r].end).trim();if(n==="const")return;i=0;for(let o of t.slice(r+1)){if(o.kind!=="punctuation")continue;let s=e.slice(o.start,o.end);if(!i&&["??","||","&&"].some((l)=>e.startsWith(l,o.start)))return;if(["(","[","{","<"].includes(s))i++;else if([")","]","}",">"].includes(s))i--;else if(!i&&["+","-","*","/","%","=","!",";"].includes(s))return}return n}function Ql(e,t){let i=0;for(let r of ce(e)){if(r.kind!=="punctuation")continue;let n=e.slice(r.start,r.end);if(["(","[","{"].includes(n))i++;else if([")","]","}"].includes(n))i--;if(!i&&e.startsWith(t,r.start))return r.start}return-1}function Jh(e){if(e.includes("=>"))return null;let t=[],i=0,r=0;for(let n=0;n<=e.length;n++){let o=n===e.length?"|":e[n];if(o==="'"||o==='"'||o==="`"){n++;while(n<e.length&&e[n]!==o)n+=e[n]==="\\"?2:1;if(n>=e.length)return null}else if(o==="("||o==="["||o==="{"||o==="<")i++;else if(o===")"||o==="]"||o==="}"||o===">")i--;else if(o==="|"&&i===0){let s=e.slice(r,n).trim();if(s)t.push(s);r=n+1}if(i<0)return null}return i===0?t:null}function Yh(e,t){let i=Jh(t);if(!i)return`${e} | ${t}`;let r=[];for(let f of[e,...i]){if(f==="unknown")return"unknown";if(!r.includes(f))r.push(f)}let n=r.includes("boolean")||r.includes("true")&&r.includes("false"),o=r.includes("string"),s=r.includes("number"),l=[],a=!1;for(let f of r)if(n&&(f==="true"||f==="false"||f==="boolean")){if(!a)l.push("boolean");a=!0}else if(o&&Xh(f))continue;else if(s&&/^-?\d+(?:\.\d+)?$/.test(f))continue;else l.push(f);return l.join(" | ")}function Xh(e){let t=e[0];return e.length>=2&&(t==="'"||t==='"')&&e.endsWith(t)&&!e.slice(1,-1).includes(t)}function Zh(e,t,i){let r=wi(t)!==-1?`(${t.trim()})`:t;if(e.trim()==="unknown")return i==="&&"||r.trim()==="unknown"?"unknown":`{} | ${r}`;let n=e.trim();if(n==="boolean"||n==="string"||n==="number"){if(i==="??")return n;return Yh(i==="||"?n==="boolean"?"true":n:n==="boolean"?"false":n==="string"?"''":"0",r)}let o="false | 0 | 0n | '' | null | undefined";if(i==="??")return`([${e}] extends [NonNullable<${e}>] ? ${e} : NonNullable<${e}> | ${r})`;if(i==="||")return`([${e}] extends [object] ? ${e} : [Exclude<${e}, object> & (${o})] extends [never] ? ${e} : Exclude<NonNullable<${e}>, ${o}> | ${r})`;return`([${e}] extends [object] ? ${r} : [${e}] extends [${o}] ? ${e} : unknown extends (${e}) ? ${e} : (Exclude<${e}, object> & (${o})) | ${r})`}function Qh(e){let t=`(NonNullable<${e}> extends infer __dtsx_spread_value ? { -readonly [__dtsx_spread_key in keyof __dtsx_spread_value]: __dtsx_spread_value[__dtsx_spread_key] } : never)`,i=`(NonNullable<${e}> extends infer __dtsx_spread_value ? { -readonly [__dtsx_spread_key in keyof __dtsx_spread_value]?: __dtsx_spread_value[__dtsx_spread_key] } : never)`;return`([${e}] extends [null | undefined] ? {} : [${e}] extends [NonNullable<${e}>] ? ${t} : ${i})`}function ep(e,t){let i=e.trim();while(xn(i))i=i.slice(1,-1).trim();let r=Ql(i,"??");if(r!==-1&&i.slice(r+2).trim()==="{}")return Qh(t(i.slice(0,r)));let n=tc(i);if(n){if(n.whenFalse.trim()==="{}")return`Partial<${t(n.whenTrue)}>`;if(n.whenTrue.trim()==="{}")return`Partial<${t(n.whenFalse)}>`}return t(i)}function ec(e){return e.map((t)=>e.length>1&&wi(t)!==-1?`(${t})`:t).join(" | ")}function Ul(e){let t=0;while(t<e.length){let n=e.charCodeAt(t);if(n<=32)t++;else if(n===47&&e.charCodeAt(t+1)===47){t+=2;while(t<e.length&&e.charCodeAt(t)!==10&&e.charCodeAt(t)!==13)t++}else if(n===47&&e.charCodeAt(t+1)===42){let o=e.indexOf("*/",t+2);t=o===-1?e.length:o+2}else break}let i=t,r=t;while(r<e.length){let n=e.charCodeAt(r);if(n===34||n===39||n===96){r=Bt(e,r,n),i=r;continue}if(n===92){r=Math.min(r+2,e.length),i=r;continue}if(n===47&&e.charCodeAt(r+1)===47){while(r<e.length&&e.charCodeAt(r)!==10&&e.charCodeAt(r)!==13)r++;continue}if(n===47&&e.charCodeAt(r+1)===42){let o=e.indexOf("*/",r+2);r=o===-1?e.length:o+2;continue}if(r++,n>32)i=r}return e.slice(t,i)}function fs(e){let t=0;for(let i=0;i<e.length;i++){let r=e[i];if(r==="'"||r==='"'||r==="`"){let n=i+1;while(n<e.length&&e[n]!==r){if(e[n]==="\\")n++;n++}i=n;continue}if(r==="("||r==="["||r==="{")t++;else if(r===")"||r==="]"||r==="}")t--;else if(t!==0)continue;else if(r==="?"){if(e[i+1]!==".")return!1}else if("=!<>&|+-*/%,:".includes(r))return!1;else if(r===" "||r==="\t"||r===`
44
+ `||r==="\r"){let n=e.slice(i).trimStart();if(n&&n[0]!=="."&&n[0]!=="?"&&n[0]!=="("&&n[0]!=="[")return!1}}return!0}function tp(e){if(e.startsWith("function")&&yr(e,0,8))return!0;let t=wi(e);if(t===-1)return!1;let i=e.slice(0,t).trim();if(i.startsWith("async")&&yr(i,0,5))i=i.slice(5).trim();if(i.startsWith("<")){let n=ot(i,0,"<",">");if(n===-1)return!1;i=i.slice(n+1).trim()}if(i.startsWith("(")){let n=ot(i,0,"(",")");if(n===-1)return!1;let o=i.slice(n+1).trim();if(o&&!o.startsWith(":"))return!1}let r=gs(i);return xn(r.params)||Di(r.params)}function xn(e){if(!e.startsWith("(")||!e.endsWith(")"))return!1;let t=0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);if(r===40)t++;else if(r===41&&--t===0)return i===e.length-1}return!1}function tc(e){let t=0,i=-1;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n===34||n===39||n===96){r=Bt(e,r,n)-1;continue}if(n===47&&(e.charCodeAt(r+1)===47||e.charCodeAt(r+1)===42)){if(e.charCodeAt(r+1)===47)while(r+1<e.length&&e.charCodeAt(r+1)!==10&&e.charCodeAt(r+1)!==13)r++;else{let o=e.indexOf("*/",r+2);r=o===-1?e.length:o+1}continue}if(n===40||n===91||n===123)t++;else if(n===41||n===93||n===125)t--;else if(n===63&&t===0&&e.charCodeAt(r+1)!==63)i=r;else if(n===58&&t===0&&i!==-1)return{whenTrue:Ul(e.slice(i+1,r)),whenFalse:Ul(e.slice(r+1))}}return null}function yr(e,t,i){return(t===0||!Mt(e.charCodeAt(t-1)))&&!Mt(e.charCodeAt(t+i))}function ic(e,t){let i=t;while(i<e.length){if(e.charCodeAt(i)<=32){i++;continue}if(e.startsWith("//",i)){while(i<e.length&&e.charCodeAt(i)!==10&&e.charCodeAt(i)!==13)i++;continue}if(e.startsWith("/*",i)){let r=e.indexOf("*/",i+2);i=r<0?e.length:r+2;continue}break}return i}function ip(e,t){let i=0,r=0,n=0,o=!1,s=!1;for(let l=t;l<e.length;l++){if(l=ic(e,l),l>=e.length)break;let a=e.charCodeAt(l);if(a===34||a===39||a===96){l=Bt(e,l,a)-1,s=!1;continue}if(Mt(a)||a>=128){let f=l;while(l+1<e.length&&(Mt(e.charCodeAt(l+1))||e.charCodeAt(l+1)>=128))l++;s=o&&["keyof","typeof","readonly","unique","new","abstract","infer","extends"].includes(e.slice(f,l+1));continue}if(a===61&&e.charCodeAt(l+1)===62){l++,s=o;continue}if(a===40)i++;else if(a===41)i--,s=!1;else if(a===91)r++;else if(a===93)r--,s=!1;else if(a===60&&i===0&&r===0)n++;else if(a===62&&n>0&&i===0&&r===0)n--,s=!1;else if(a===123)if(i||r||n||o&&s)l=vn(e,l)-1,s=!1;else return l;else if(i===0&&r===0&&n===0){if(a===58)o=!0,s=!0;else if(o&&[124,38,63].includes(a))s=!0;else if(a===59)return-1}}return-1}function vn(e,t){let i=1,r=t+1;while(r<e.length&&i>0){let n=e.charCodeAt(r);if(n===34||n===39||n===96){r=Bt(e,r,n);continue}if(n===47&&e.charCodeAt(r+1)===47){r+=2;while(r<e.length&&e.charCodeAt(r)!==10&&e.charCodeAt(r)!==13)r++;continue}if(n===47&&e.charCodeAt(r+1)===42){let o=e.indexOf("*/",r+2);r=o===-1?e.length:o+2;continue}if(n===123)i++;else if(n===125)i--;r++}return r}function Bt(e,t,i){let r=t+1;while(r<e.length){let n=e.charCodeAt(r);if(n===92){r+=2;continue}if(i===96&&n===36&&e.charCodeAt(r+1)===123){r=vn(e,r+1);continue}if(r++,n===i)break}return r}function rp(e,t){if(e.includes(".raw`")||e.includes("String.raw`"))return"string";if(!t||e.includes("${")||e.includes(`
45
+ `)||e.includes("\r"))return"string";return e}function np(e){let t=4;while(t<e.length&&e.charCodeAt(t)<=32)t++;let i=t,r=e.charCodeAt(t);if(r<65||r>90)return"unknown";while(t<e.length&&(Mt(e.charCodeAt(t))||e.charCodeAt(t)===46))t++;if(t===i)return"unknown";let n=e.slice(i,t);{let o=e.slice(t),s=o;if(o.startsWith("<")){let a=0,f=-1;for(let u=0;u<o.length;u++)if(o[u]==="<")a++;else if(o[u]===">"){if(a--,a===0){f=u;break}}if(f!==-1){let u=o.slice(0,f+1);s=o.slice(f+1);let d=s.indexOf("(");if(d!==-1){let h=0,p=-1;for(let m=d;m<s.length;m++)if(s[m]==="(")h++;else if(s[m]===")"){if(h--,h===0){p=m;break}}if(p!==-1){if(s.slice(p+1).trimStart().startsWith("."))return"unknown"}}return`${n}${u}`}}let l=s.indexOf("(");if(l!==-1){let a=0,f=-1;for(let u=l;u<s.length;u++)if(s[u]==="(")a++;else if(s[u]===")"){if(a--,a===0){f=u;break}}if(f!==-1){if(s.slice(f+1).trimStart().startsWith("."))return"unknown"}}switch(n){case"Date":return"Date";case"Map":return"Map<any, any>";case"Set":return"Set<any>";case"WeakMap":return"WeakMap<any, any>";case"WeakSet":return"WeakSet<any>";case"RegExp":return"RegExp";case"Error":return"Error";case"Array":return"any[]";case"Object":return"object";case"Function":return"Function";case"Promise":return"Promise<any>";default:return n}}return"unknown"}function op(e){return"{ new (...args: any[]): any }"}function rc(e,t,i=0,r){if(e.startsWith("Promise.resolve(")){let n=e.indexOf(")",16);if(n!==-1){let o=e.slice(16,n).trim();if(o)return`Promise<${Te(o,t,!1,i+1,r)}>`}return"Promise<unknown>"}if(e.startsWith("Promise.reject("))return"Promise<never>";if(e.startsWith("Promise.all(")){let n=e.indexOf("[",12),o=e.lastIndexOf("]");if(n!==-1&&o>n){let s=e.slice(n+1,o).trim(),l=wr(s),a=[];for(let f=0;f<l.length;f++){let u=l[f].trim();if(u.startsWith("Promise.resolve(")){let d=rc(u,t,i+1,r),h=d.indexOf("<"),p=d.lastIndexOf(">");a.push(h!==-1&&p>h?d.slice(h+1,p):"unknown")}else a.push(Te(u,t,!1,i+1,r))}return`Promise<[${a.join(", ")}]>`}return"Promise<unknown[]>"}return"Promise<unknown>"}function hs(e,t,i=0,r){let n=e.slice(1,-1).trim();if(!n)return"never[]";if(i>=$n)return"unknown[]";let o=wr(n),s=!1;for(let p=0;p<o.length;p++){let m=o[p],c=m.length;while(c>0&&m.charCodeAt(c-1)<=32)c--;if(c>=8&&m.slice(c-8,c)==="as const"){s=!0;break}}if(s){let p=[];for(let m=0;m<o.length;m++){let c=o[m].trim();if(c.endsWith("as const")){let C=c.slice(0,-8).trim();if(C.startsWith("[")&&C.endsWith("]")){let b=C.slice(1,-1).trim(),v=wr(b),k=[];for(let W=0;W<v.length;W++)k.push(Te(v[W].trim(),!0,!1,i+1,r));p.push(`readonly [${k.join(", ")}]`)}else p.push(Te(C,!0,!1,i+1,r))}else if(c.startsWith("[")&&c.endsWith("]"))p.push(hs(c,!0,i+1,r));else p.push(Te(c,!0,!1,i+1,r))}return`readonly [
46
46
  ${p.join(` |
47
47
  `)}
48
- ]`}let l=bn&&!t,a=[],f=[];for(let p of o){let m=p.trim(),c=pt;if(pt=null,m.startsWith("...")){let v=m.slice(3).trim(),b=Te(v,!1,!1,i+1,r);if(b.endsWith("[]"))a.push(b.slice(0,-2));else if(b.startsWith("readonly [")&&b.endsWith("]"))a.push(b.slice(10,-1));else if(yi(v))a.push(`(typeof ${v})[number]`);else a.push("unknown")}else if(m.startsWith("[")&&m.endsWith("]"))a.push(ds(m,t,i+1,r));else a.push(zh(m,t,i+1,r));if(l)f.push(pt);pt=c}if(l)if(hs(e))pt=yn(e);else{let p=[];for(let m=0;m<o.length;m++){let c=o[m].trim();if(c.endsWith("as const"))continue;if(Cn(c)||c==="null"||c==="undefined")p.push(c);else if(c.startsWith("[")&&hs(c))p.push(yn(c));else if(c.startsWith("{")){if(f[m])p.push(f[m])}else{let v=Te(c,!1,!1,0,r);if(v!=="unknown")p.push(v)}}if(p.length>0)pt=`[${p.join(", ")}]`}if(t)return`readonly [${a.join(", ")}]`;let u=new Set,d=[],h=!0;for(let p of a){if(!u.has(p))u.add(p),d.push(p);if(h){if(!(wi(p)||p==="true"||p==="false"||p.charCodeAt(0)===34&&p.charCodeAt(p.length-1)===34||p.charCodeAt(0)===39&&p.charCodeAt(p.length-1)===39))h=!1}}if(h&&a.length<=10)return`readonly [${a.join(", ")}]`;if(d.length===1)return`${d[0]}[]`;return`(${d.join(" | ")})[]`}function yr(e){let t=[],i=0,r=!1,n=0,o=-1,s=0;for(let l=0;l<e.length;l++){let a=e.charCodeAt(l);if(r){if(a===92)l++;else if(a===n)r=!1;s=l+1;continue}if(a===47&&e.charCodeAt(l+1)===47){let f=e.indexOf(`
49
- `,l+2);l=(f===-1?e.length:f)-1;continue}if(a===47&&e.charCodeAt(l+1)===42){let f=e.indexOf("*/",l+2);l=(f===-1?e.length:f+2)-1;continue}if(a===32||a===9||a===10||a===13)continue;if(a===44&&i===0){if(o!==-1)t.push(e.slice(o,s));o=-1;continue}if(a===34||a===39||a===96)r=!0,n=a;else if(a===91||a===123||a===40)i++;else if(a===93||a===125||a===41)i--;if(o===-1)o=l;s=l+1}if(o!==-1)t.push(e.slice(o,s));return t}function Cn(e){if(wi(e))return!0;if(e==="true"||e==="false")return!0;if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return!0;return!1}function nc(e){return e==="number"||e==="string"||e==="boolean"}function oc(e){let t=[],i=0;while(i<e.length){while(i<e.length&&e.charCodeAt(i)<=32)i++;if(e.startsWith("/*",i)){let r=e.indexOf("*/",i+2);if(r===-1)break;t.push(e.slice(i,r+2)),i=r+2}else if(e.startsWith("//",i)){let r=i;while(r<e.length&&e.charCodeAt(r)!==10&&e.charCodeAt(r)!==13)r++;t.push(e.slice(i,r).trimEnd()),i=r}else break}return t}function ws(e,t,i){let r=t.trim();if(!nc(i)||!Cn(r))return"";let n=(e??[]).map((s)=>s.trim()).filter((s)=>s.startsWith("/**")||s.startsWith("//")).join(`
50
- `),o;if(n.includes("@defaultValue"))o=n;else{let s=`@defaultValue ${mr(r)}`;if(!n)o=`/** ${s} */`;else{let l=n.lastIndexOf("*/");if(l!==-1){let a=n.slice(0,l).trimEnd();if(a.startsWith("/** ")&&!a.includes(`
48
+ ]`}let l=En&&!t,a=[],f=[];for(let p of o){let m=p.trim(),c=pt;if(pt=null,m.startsWith("...")){let C=m.slice(3).trim(),b=Te(C,!1,!1,i+1,r);if(b.endsWith("[]"))a.push(b.slice(0,-2));else if(b.startsWith("readonly [")&&b.endsWith("]"))a.push(b.slice(10,-1));else if(yi(C))a.push(`(typeof ${C})[number]`);else a.push("unknown")}else if(m.startsWith("[")&&m.endsWith("]"))a.push(hs(m,t,i+1,r));else a.push(zh(m,t,i+1,r));if(l)f.push(pt);pt=c}if(l)if(ps(e))pt=Cn(e);else{let p=[];for(let m=0;m<o.length;m++){let c=o[m].trim();if(c.endsWith("as const"))continue;if(bn(c)||c==="null"||c==="undefined")p.push(c);else if(c.startsWith("[")&&ps(c))p.push(Cn(c));else if(c.startsWith("{")){if(f[m])p.push(f[m])}else{let C=Te(c,!1,!1,0,r);if(C!=="unknown")p.push(C)}}if(p.length>0)pt=`[${p.join(", ")}]`}if(t)return`readonly [${a.join(", ")}]`;let u=new Set,d=[],h=!0;for(let p of a){if(!u.has(p))u.add(p),d.push(p);if(h){if(!(Ci(p)||p==="true"||p==="false"||p.charCodeAt(0)===34&&p.charCodeAt(p.length-1)===34||p.charCodeAt(0)===39&&p.charCodeAt(p.length-1)===39))h=!1}}if(h&&a.length<=10)return`readonly [${a.join(", ")}]`;if(d.length===1)return`${d[0]}[]`;return`(${d.join(" | ")})[]`}function wr(e){let t=[],i=0,r=!1,n=0,o=-1,s=0;for(let l=0;l<e.length;l++){let a=e.charCodeAt(l);if(r){if(a===92)l++;else if(a===n)r=!1;s=l+1;continue}if(a===47&&e.charCodeAt(l+1)===47){let f=e.indexOf(`
49
+ `,l+2);l=(f===-1?e.length:f)-1;continue}if(a===47&&e.charCodeAt(l+1)===42){let f=e.indexOf("*/",l+2);l=(f===-1?e.length:f+2)-1;continue}if(a===32||a===9||a===10||a===13)continue;if(a===44&&i===0){if(o!==-1)t.push(e.slice(o,s));o=-1;continue}if(a===34||a===39||a===96)r=!0,n=a;else if(a===91||a===123||a===40)i++;else if(a===93||a===125||a===41)i--;if(o===-1)o=l;s=l+1}if(o!==-1)t.push(e.slice(o,s));return t}function bn(e){if(Ci(e))return!0;if(e==="true"||e==="false")return!0;if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return!0;return!1}function nc(e){return e==="number"||e==="string"||e==="boolean"}function oc(e){let t=[],i=0;while(i<e.length){while(i<e.length&&e.charCodeAt(i)<=32)i++;if(e.startsWith("/*",i)){let r=e.indexOf("*/",i+2);if(r===-1)break;t.push(e.slice(i,r+2)),i=r+2}else if(e.startsWith("//",i)){let r=i;while(r<e.length&&e.charCodeAt(r)!==10&&e.charCodeAt(r)!==13)r++;t.push(e.slice(i,r).trimEnd()),i=r}else break}return t}function Cs(e,t,i){let r=t.trim();if(!nc(i)||!bn(r))return"";let n=(e??[]).map((s)=>s.trim()).filter((s)=>s.startsWith("/**")||s.startsWith("//")).join(`
50
+ `),o;if(n.includes("@defaultValue"))o=n;else{let s=`@defaultValue ${gr(r)}`;if(!n)o=`/** ${s} */`;else{let l=n.lastIndexOf("*/");if(l!==-1){let a=n.slice(0,l).trimEnd();if(a.startsWith("/** ")&&!a.includes(`
51
51
  `))a=`/**
52
52
  * ${a.slice(4)}`;o=`${a}
53
53
  * ${s}
@@ -57,42 +57,42 @@ defineProps<${i}>()`,null)}function Mh(e){return qo(e)}function gl(e){let t=Ko(e
57
57
  */`}}return o.split(`
58
58
  `).map((s)=>{let l=s.trim();if(!l)return"";return l.startsWith("*")?` ${l}`:` ${l}`}).join(`
59
59
  `)+`
60
- `}function hs(e){let t=!1,i=0,r=e.length;for(let n=0;n<r;n++){let o=e.charCodeAt(n);if(t){if(o===92){n++;continue}if(o===i)t=!1;continue}if(o===34||o===39||o===96){t=!0,i=o;continue}if(o===61&&n+1<r&&e.charCodeAt(n+1)===62)return!1;if(o===47&&(e.charCodeAt(n+1)===47||e.charCodeAt(n+1)===42))return!1;if(o>=97&&o<=122){let s=n;while(n<r&&(e.charCodeAt(n)>=97&&e.charCodeAt(n)<=122||e.charCodeAt(n)>=65&&e.charCodeAt(n)<=90||e.charCodeAt(n)>=48&&e.charCodeAt(n)<=57||e.charCodeAt(n)===95||e.charCodeAt(n)===36))n++;let l=e.slice(s,n);if(l==="new"||l==="async"||l==="await"||l==="function"||l==="yield"||l==="console"||l==="process")return!1;let a=n;while(a<r&&e.charCodeAt(a)<=32)a++;if(a<r&&e.charCodeAt(a)===40)return!1;n--}}return!0}function sc(e,t,i=0,r,n){let o=e.slice(1,-1).trim();if(!o)return"{}";if(i>=vn)return"Record<string, unknown>";let s=sp(o),l=new Set(s.flatMap(([b])=>{let C=ql(ps(b).key);return C?.kind==="get"?[C.name]:[]})),a=[],f=[],u=[],d=!1,h=bn&&!t,p=[],m=0;for(let[b,C]of s){let{comments:k,key:W}=ps(b),A=k?`${k}
61
- `:"",R=ql(W);if(R&&Ol(R.name))continue;let V=W,B=!1;if(W==="..."){let we=C.trim(),ge=n?Xh(we,n):yi(we)?`typeof ${we}`:Te(we,t,!1,i+1,r);if(ge!=="unknown")f.push(ge);if(h&&(yi(we)||we.startsWith("{")))p.push(`...${yn(we)}`);continue}let O=pt;pt=null;let z,X=C.trim();if(X===W&&wr(X))z=(t?void 0:r?.mutableBindingTypes?.get(X))??`typeof ${X}`;else if(cp(X)){B=!0;let we=fp(W);if(we){V=we.name;let ge="";if(X.startsWith("async "))ge="async ";if(X.charCodeAt(ge.length)===42)ge+="*";z=Jl(we.name,ge+we.typeParams+X.slice(ge.length))}else z=Jl(W,X)}else{if(z=n?.(C)??Te(C,t,!1,i+1,r),z==="unknown"&&yi(X))z=(t?void 0:r?.mutableBindingTypes?.get(X))??`typeof ${X}`;if(z.includes("=>")||z.includes("function")||z.includes("async"))z=zl(z)}let ae=pt;pt=O;let be=V,ke=C.trim(),ve=kl(V,r);if(!Tl(R?.name??V,r)&&!(R?.kind==="set"&&l.has(R.name)))u.push(R?lp(R.kind,z):z);if(ve&&"index"in ve)d=!0;else{if(ve&&"name"in ve)V=ve.name;if(R){let we=ap(R.kind,R.name,z);if(we){a.push(`${A}${zt(we)}`);continue}}if(!t&&nc(z)&&Cn(ke))a.push(`${A}/** @defaultValue ${mr(ke)} */
62
- ${V}: ${zt(z)}`);else a.push(`${A}${t?"readonly ":""}${V}: ${zt(z)}`)}if(h){let we=Yl(be);if(ke.endsWith("as const"));else if(Cn(ke))p.push(`${we}: ${ke}`);else if(ke.startsWith("[")&&hs(ke))p.push(`${we}: ${yn(ke)}`);else if(ke.startsWith("{")){if(ae)p.push(`${we}: ${ae}`)}else if(B)p.push(`${we}: ${fs(zl(z))}`),m++;else if(!ke.startsWith("[")&&(ke.includes("=>")||ke.startsWith("function")||ke.startsWith("async"))){let ge=lc(ke,!1,0,!0);p.push(`${we}: ${fs(ge)}`),m++}}}if(h&&p.length>m){let b=i>0?(i-1)/2:0,C=`{ ${p.join(", ")} }`;if(C.length<=80)pt=C;else{let k=" ".repeat((b+1)*2),W=" ".repeat(b*2);pt=`{
60
+ `}function ps(e){let t=!1,i=0,r=e.length;for(let n=0;n<r;n++){let o=e.charCodeAt(n);if(t){if(o===92){n++;continue}if(o===i)t=!1;continue}if(o===34||o===39||o===96){t=!0,i=o;continue}if(o===61&&n+1<r&&e.charCodeAt(n+1)===62)return!1;if(o===47&&(e.charCodeAt(n+1)===47||e.charCodeAt(n+1)===42))return!1;if(o>=97&&o<=122){let s=n;while(n<r&&(e.charCodeAt(n)>=97&&e.charCodeAt(n)<=122||e.charCodeAt(n)>=65&&e.charCodeAt(n)<=90||e.charCodeAt(n)>=48&&e.charCodeAt(n)<=57||e.charCodeAt(n)===95||e.charCodeAt(n)===36))n++;let l=e.slice(s,n);if(l==="new"||l==="async"||l==="await"||l==="function"||l==="yield"||l==="console"||l==="process")return!1;let a=n;while(a<r&&e.charCodeAt(a)<=32)a++;if(a<r&&e.charCodeAt(a)===40)return!1;n--}}return!0}function sc(e,t,i=0,r,n){let o=e.slice(1,-1).trim();if(!o)return"{}";if(i>=$n)return"Record<string, unknown>";let s=cp(o),l=new Set(s.flatMap(([b])=>{let v=ql(ms(b).key);return v?.kind==="get"?[v.name]:[]})),a=[],f=[],u=[],d=!1,h=En&&!t,p=[],m=0;for(let[b,v]of s){let{comments:k,key:W}=ms(b),A=k?`${k}
61
+ `:"",R=ql(W);if(R&&Ol(R.name))continue;let V=W,B=!1;if(W==="..."){let we=v.trim(),ge=n?ep(we,n):yi(we)?`typeof ${we}`:Te(we,t,!1,i+1,r);if(ge!=="unknown")f.push(ge);if(h&&(yi(we)||we.startsWith("{")))p.push(`...${Cn(we)}`);continue}let O=pt;pt=null;let z,X=v.trim();if(X===W&&Di(X))z=n?.(v)??(t?void 0:r?.mutableBindingTypes?.get(X))??`typeof ${X}`;else if(dp(X)){B=!0;let we=hp(W);if(we){V=we.name;let ge="";if(X.startsWith("async "))ge="async ";if(X.charCodeAt(ge.length)===42)ge+="*";z=Jl(we.name,ge+we.typeParams+X.slice(ge.length))}else z=Jl(W,X)}else{if(z=n?.(v)??Te(v,t,!1,i+1,r),z==="unknown"&&yi(X))z=(t?void 0:r?.mutableBindingTypes?.get(X))??`typeof ${X}`;if(z.includes("=>")||z.includes("function")||z.includes("async"))z=zl(z)}let ae=pt;pt=O;let be=V,ke=v.trim(),ve=kl(V,r);if(!Tl(R?.name??V,r)&&!(R?.kind==="set"&&l.has(R.name)))u.push(R?up(R.kind,z):z);if(ve&&"index"in ve)d=!0;else{if(ve&&"name"in ve)V=ve.name;if(R){let we=fp(R.kind,R.name,z);if(we){a.push(`${A}${zt(we)}`);continue}}if(!t&&nc(z)&&bn(ke))a.push(`${A}/** @defaultValue ${gr(ke)} */
62
+ ${V}: ${zt(z)}`);else a.push(`${A}${t?"readonly ":""}${V}: ${zt(z)}`)}if(h){let we=Yl(be);if(ke.endsWith("as const"));else if(bn(ke))p.push(`${we}: ${ke}`);else if(ke.startsWith("[")&&ps(ke))p.push(`${we}: ${Cn(ke)}`);else if(ke.startsWith("{")){if(ae)p.push(`${we}: ${ae}`)}else if(B)p.push(`${we}: ${us(zl(z))}`),m++;else if(!ke.startsWith("[")&&(ke.includes("=>")||ke.startsWith("function")||ke.startsWith("async"))){let ge=lc(ke,!1,0,!0);p.push(`${we}: ${us(ge)}`),m++}}}if(h&&p.length>m){let b=i>0?(i-1)/2:0,v=`{ ${p.join(", ")} }`;if(v.length<=80)pt=v;else{let k=" ".repeat((b+1)*2),W=" ".repeat(b*2);pt=`{
63
63
  ${k}${p.join(`,
64
64
  ${k}`)}
65
- ${W}}`}}if(d&&f.length===0){let b=[...new Set(u)].map((C)=>C.includes("=>")||C.includes(" & ")?`(${C})`:C);a.unshift(`${t?"readonly ":""}[x: string]: ${zt(b.join(" | "))}`)}let c=a.length>0?`{
65
+ ${W}}`}}if(d&&f.length===0){let b=[...new Set(u)].map((v)=>v.includes("=>")||v.includes(" & ")?`(${v})`:v);a.unshift(`${t?"readonly ":""}[x: string]: ${zt(b.join(" | "))}`)}let c=a.length>0?`{
66
66
  ${a.join(`;
67
67
  `)}
68
- }`:"{}";if(f.length===0)return c;let v=f[0];for(let b=1;b<f.length;b++)v=`Omit<${v}, keyof ${f[b]}> & ${f[b]}`;return a.length>0?`Omit<${v}, keyof ${c}> & ${c}`:v}function wr(e){if(!e)return!1;let t=e.charCodeAt(0);if(!(t>=65&&t<=90||t>=97&&t<=122||t===95||t===36||t>127))return!1;for(let i=1;i<e.length;i++)if(!Mt(e.charCodeAt(i)))return!1;return!0}function yi(e){let t=e.split(".");return t.length>0&&t.every(wr)}function rp(e){let t=!1,i="";for(let r=0;r<e.length;r++){let n=e[r];if(t){if(n==="\\")r++;else if(n===i)t=!1;continue}if(n==='"'||n==="'"||n==="`"){t=!0,i=n;continue}if(n==="(")return r;if(n==="<"){let o=ot(e,r,"<",">");if(o!==-1)r=o}}return-1}function Cr(e){if(e.length<3||!e.endsWith(")"))return null;let t=rp(e);if(t===-1||ot(e,t,"(",")")!==e.length-1)return null;let i=e.slice(0,t).trim(),r=!1;if(i.endsWith("?."))r=!0,i=i.slice(0,-2).trim();let n=i,o=!1,s=i.indexOf("<");if(s!==-1){if(ot(i,s,"<",">")!==i.length-1)return null;n=i.slice(0,s).trim(),o=!0}if(!yi(n))return null;let l=e.slice(t+1,-1).trim(),a=Mi(l)!==-1||l.startsWith("function")||l.startsWith("async function"),f=yi(l),u=!a&&l.endsWith(")")&&Cr(l)!==null,d=n.indexOf(".");if(d!==-1){if(n.indexOf(".",d+1)!==-1)return null}else if(!o&&!r&&!a&&!f&&!u)return null;let h=`ReturnType<typeof ${i}>`;return r?`${h} | undefined`:h}function zl(e){let t=e.split(`
68
+ }`:"{}";if(f.length===0)return c;let C=f[0];for(let b=1;b<f.length;b++)C=`Omit<${C}, keyof ${f[b]}> & ${f[b]}`;return a.length>0?`Omit<${C}, keyof ${c}> & ${c}`:C}function Di(e){if(!e)return!1;let t=e.charCodeAt(0);if(!(t>=65&&t<=90||t>=97&&t<=122||t===95||t===36||t>127))return!1;for(let i=1;i<e.length;i++)if(!Mt(e.charCodeAt(i)))return!1;return!0}function yi(e){let t=e.split(".");return t.length>0&&t.every(Di)}function sp(e){let t=!1,i="";for(let r=0;r<e.length;r++){let n=e[r];if(t){if(n==="\\")r++;else if(n===i)t=!1;continue}if(n==='"'||n==="'"||n==="`"){t=!0,i=n;continue}if(n==="(")return r;if(n==="<"){let o=ot(e,r,"<",">");if(o!==-1)r=o}}return-1}function Cr(e){if(e.length<3||!e.endsWith(")"))return null;let t=sp(e);if(t===-1||ot(e,t,"(",")")!==e.length-1)return null;let i=e.slice(0,t).trim(),r=!1;if(i.endsWith("?."))r=!0,i=i.slice(0,-2).trim();let n=i,o=!1,s=i.indexOf("<");if(s!==-1){if(ot(i,s,"<",">")!==i.length-1)return null;n=i.slice(0,s).trim(),o=!0}if(!yi(n))return null;let l=e.slice(t+1,-1).trim(),a=wi(l)!==-1||l.startsWith("function")||l.startsWith("async function"),f=yi(l),u=!a&&l.endsWith(")")&&Cr(l)!==null,d=n.indexOf(".");if(d!==-1){if(n.indexOf(".",d+1)!==-1)return null}else if(!o&&!r&&!a&&!f&&!u)return null;let h=`ReturnType<typeof ${i}>`;return r?`${h} | undefined`:h}function zl(e){let t=e.split(`
69
69
  `).map((f)=>ac(f)).join(`
70
- `),i=t.indexOf("async");if(i!==-1){let f=i>0?t.charCodeAt(i-1):32,u=i+5<t.length?t.charCodeAt(i+5):32;if(!Mt(f)&&!Mt(u))t=(t.slice(0,i)+t.slice(i+5)).trim()}let r=t.indexOf("(");if(r!==-1){let f=ot(t,r,"(",")");if(f!==-1){let u=t.slice(r,f+1),d=gi(u);t=t.slice(0,r)+d+t.slice(f+1)}}let n=t.length,o="",s=[],l=!1,a=!1;for(let f=0;f<n;f++){let u=t.charCodeAt(f);if(u===123||u===40)s.push(u);else if(u===125||u===41)s.pop();if(u<=32){if(l=!0,u===10||u===13)a=!0;continue}if(l&&o.length>0){let d=(s.length>0?s[s.length-1]:0)===123;if(a&&d){let h=o.charCodeAt(o.length-1),p=h===59||h===44||h===123||u===125,m=o.length>=2&&o.charCodeAt(o.length-1)===47&&o.charCodeAt(o.length-2)===42;if(!p&&!m)o+="; ";else o+=" "}else o+=" "}l=!1,a=!1,o+=t[f]}return o.trim()}function Mt(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===95||e===36}function gi(e){let t=e.trim(),i,r=!1;if(t.startsWith("(")&&t.endsWith(")"))i=t.slice(1,-1),r=!0;else i=t;let n=i.trim();if(!n)return r?"()":"";let o=!1;{let m=0;for(let c=0;c<n.length;c++){let v=n.charCodeAt(c);if(v===40||v===60||v===91||v===123)m++;else if(v===41||v===93||v===125||v===62&&n.charCodeAt(c-1)!==61)m--;else if(m===0&&v===61){let b=c>0?n.charCodeAt(c-1):0,C=c+1<n.length?n.charCodeAt(c+1):0;if(b!==61&&b!==33&&b!==60&&b!==62&&C!==61&&C!==62){o=!0;break}}}}if(!o)return t;let s=[],l=[],a=0,f=0,u=!1,d=0;for(let m=0;m<=n.length;m++){if(m===n.length){s.push(n.slice(a));break}let c=n.charCodeAt(m);if(u){if(c===92){m++;continue}if(c===d)u=!1;continue}if(c===47&&m+1<n.length){let v=n.charCodeAt(m+1);if(v===42){m+=2;while(m+1<n.length&&!(n.charCodeAt(m)===42&&n.charCodeAt(m+1)===47))m++;m++;continue}if(v===47){while(m<n.length&&n.charCodeAt(m)!==10)m++;continue}}if(c===39||c===34||c===96){u=!0,d=c;continue}if(c===40||c===60||c===91||c===123)f++;else if(c===41||c===93||c===125||c===62&&n.charCodeAt(m-1)!==61)f--;else if(c===44&&f===0){s.push(n.slice(a,m));let v=",",b=m+1;while(b<n.length&&n.charCodeAt(b)<=32)v+=n[b],b++;l.push(v),a=b}}let h=[];for(let m of s){let c=m.trim();if(!c){h.push(m);continue}if(c.startsWith("//"))continue;let v=ac(c),b=m.slice(0,m.length-m.trimStart().length);h.push(b+np(v))}let p=h[0]||"";for(let m=1;m<h.length;m++)p+=(l[m-1]||", ")+h[m];return dn(r?`(${p})`:p)}function ac(e){let t=!1,i=0;for(let r=0;r<e.length-1;r++){let n=e.charCodeAt(r);if(t){if(n===92){r++;continue}if(n===i)t=!1;continue}if(n===39||n===34||n===96){t=!0,i=n;continue}if(n===47&&e.charCodeAt(r+1)===47)return e.slice(0,r).trimEnd()}return e}function np(e){if(e.startsWith("..."))return e;let t=-1,i=-1,r=0,n=!1,o=0;for(let l=0;l<e.length;l++){let a=e.charCodeAt(l);if(n){if(a===92){l++;continue}if(a===o)n=!1;continue}if(a===47&&l+1<e.length){let f=e.charCodeAt(l+1);if(f===42){l+=2;while(l+1<e.length&&!(e.charCodeAt(l)===42&&e.charCodeAt(l+1)===47))l++;l++;continue}if(f===47){while(l<e.length&&e.charCodeAt(l)!==10)l++;continue}}if(a===39||a===34||a===96){n=!0,o=a;continue}if(a===40||a===60||a===91||a===123)r++;else if(a===41||a===93||a===125||a===62&&e.charCodeAt(l-1)!==61)r--;else if(r===0){if(a===58&&t===-1)t=l;else if(a===61&&i===-1&&(l===0||e.charCodeAt(l-1)!==61)&&(l+1>=e.length||e.charCodeAt(l+1)!==61&&e.charCodeAt(l+1)!==62))i=l}}let s=i!==-1;if(t!==-1&&(i===-1||t<i)){let l=e.slice(0,t).trim(),a=i!==-1?e.slice(t+1,i).trim():e.slice(t+1).trim(),f=s&&!l.endsWith("?")?"?":"";return`${l}${f}: ${a}`}else if(i!==-1){let l=e.slice(0,i).trim(),a=pr(l,e.slice(i+1));if(a)return hn(a,Kl);let f=!l.endsWith("?")?"?":"";return`${l}${f}: ${Kl(e.slice(i+1))}`}return e}function Kl(e){let t=e.trim();if(t==="true"||t==="false")return"boolean";if(wi(t))return"number";if(t.startsWith("'")&&t.endsWith("'")||t.startsWith('"')&&t.endsWith('"'))return"string";if(t.startsWith("["))return"unknown[]";if(t.startsWith("{"))return"Record<string, unknown>";return"unknown"}function op(e){let t=0,i=e.length;while(t<i){while(t<i&&(e.charCodeAt(t)===32||e.charCodeAt(t)===9||e.charCodeAt(t)===10||e.charCodeAt(t)===13))t++;if(t+1<i&&e.charCodeAt(t)===47&&e.charCodeAt(t+1)===42){t+=2;while(t+1<i&&!(e.charCodeAt(t)===42&&e.charCodeAt(t+1)===47))t++;t+=2;continue}break}return t}function ps(e){let t=[],i=0,r=e.length;while(i<r){while(i<r&&e.charCodeAt(i)<=32)i++;if(i+1>=r||e.charCodeAt(i)!==47||e.charCodeAt(i+1)!==42)break;let n=i;i+=2;while(i+1<r&&!(e.charCodeAt(i)===42&&e.charCodeAt(i+1)===47))i++;i=Math.min(i+2,r),t.push(e.slice(n,i).trim())}return{comments:t.join(`
71
- `),key:e.slice(i).trim()}}function sp(e){let t=[],i="",r="",n=0,o=!1,s="",l=!0,a=!1,f=0,u=!1,d=!1,h=0,p=!1,m=!1;for(let c=0;c<e.length;c++){let v=e.charCodeAt(c),b=c>0?e.charCodeAt(c-1):0,C=c<e.length-1?e.charCodeAt(c+1):0;if(!o&&!a&&v===47&&C===47){i=i.replace(/[ \t]+$/,""),c+=2;while(c<e.length&&e.charCodeAt(c)!==10)c++;c--;continue}if(!o&&!a&&v===47&&C===42){a=!0,f=1,i+="/*",c++;continue}else if(a&&v===42&&C===47){if(f--,i+="*/",c++,f===0)a=!1;continue}else if(a&&v===47&&C===42){f++,i+="/*",c++;continue}let k=e[c];if(!o&&!a&&(v===34||v===39||v===96))o=!0,s=k,i+=k;else if(o&&k===s&&b!==92)o=!1,i+=k;else if(!o&&!a)if(v===46&&C===46&&e.charCodeAt(c+2)===46&&n===0&&l)r=`${i.trim()}...`,i="",l=!1,p=!1,c+=2;else if(v===40&&n===0&&l&&h===0){r=i.trim();let W=op(r),A=W>0?r.slice(0,W):"",R=r.slice(W),V="";if(R.startsWith("async ")||R.startsWith("async\t")||R.startsWith(`async
72
- `))R=R.slice(6).trimStart(),V="async ";if(R.startsWith("*"))R=R.slice(1).trimStart(),V+="*";r=A+R,i=V+k,l=!1,p=!0,m=!1,n=1}else if(v===123||v===91||v===40){if(n++,i+=k,m&&v===123)m=!1}else if(v===125||v===93||v===41){if(n--,i+=k,v===41&&n===0&&!l&&!p)u=!0;if(p){if(v===41&&n===0&&!m)m=!0;else if(v===125&&n===0)p=!1,m=!1}}else if(v===58&&n===0&&l&&h===0)r=i.trim(),i="",l=!1;else if(v===58&&n===0&&u)d=!0,i+=k;else if(v===60&&d)h++,i+=k;else if(v===60&&l&&n===0)h++,i+=k;else if(v===62&&h>0&&b!==61)h--,i+=k;else if(v===61&&C===62&&d&&h===0)d=!1,u=!1,i+=k;else if(v===44&&n===0&&h===0&&!m){if(r&&i.trim()){let W=i.trim();t.push([r,W])}else if(l&&i.trim())Hl(t,i.trim());i="",r="",l=!0,u=!1,d=!1,h=0}else i+=k;else i+=k}if(r&&i.trim()){let c=i.trim();t.push([r,c])}else if(l&&i.trim())Hl(t,i.trim());return t}function Hl(e,t){let{comments:i,key:r}=ps(t);if(wr(r))e.push([i?`${i}
73
- ${r}`:r,r]);else if(r.startsWith("...")&&r.length>3)e.push(["...",r.slice(3).trim()])}function ql(e){let t=e.trim();if(t.startsWith("get ")&&t.length>4){let i=t.slice(4).trim();if(i)return{kind:"get",name:i}}if(t.startsWith("set ")&&t.length>4){let i=t.slice(4).trim();if(i)return{kind:"set",name:i}}return null}function ap(e,t,i){let r=i.trim();if(r.charCodeAt(0)!==40)return null;let n=ot(r,0,"(",")");if(n===-1)return null;let o=r.slice(1,n).trim(),s=r.slice(n+1).trimStart();if(!s.startsWith("=>"))return null;let l=s.slice(2).trim();if(e==="get")return`get ${t}(): ${l||"unknown"}`;return`set ${t}(${o})`}function lp(e,t){let i=t.trim(),r=ot(i,0,"(",")");if(!i.startsWith("(")||r===-1)return"unknown";if(e==="get"){let l=i.slice(r+1).trim();return l.startsWith("=>")?l.slice(2).trim():"unknown"}let n=i.slice(1,r).trim(),o=n.startsWith("{")?ot(n,0,"{","}"):n.startsWith("[")?ot(n,0,"[","]"):0,s=n.indexOf(":",Math.max(0,o));return s===-1?"unknown":n.slice(s+1).trim()}function cp(e){let t=e;if(t.startsWith("async ")||t.startsWith("async\t"))t=t.slice(5).trimStart();if(t.startsWith("*"))t=t.slice(1).trimStart();if(!t.startsWith("("))return!1;let i=0;for(let r=0;r<t.length;r++){let n=t.charCodeAt(r);if(n===40)i++;else if(n===41){if(i--,i===0){let o=t.slice(r+1).trimStart();if(o.startsWith("{"))return!0;if(o.startsWith(":")){let s=Cs(o,1);if(s?.kind==="arrow")return!1;if(s?.kind==="body")return!0}return!1}}}return!1}function fp(e){let t=e.trimEnd();if(!t.endsWith(">"))return null;let i=0,r=-1;for(let o=t.length-1;o>=0;o--){let s=t.charCodeAt(o);if(s===62){if(o>0&&t.charCodeAt(o-1)===61)continue;i++}else if(s===60){if(i--,i===0){r=o;break}}}if(r===-1)return null;let n=t.slice(0,r).trimEnd();if(!n)return null;return{name:n,typeParams:t.slice(r)}}function Jl(e,t){let i=t.trimStart(),r=!1,n=!1;if(i.startsWith("async ")||i.startsWith("async\t"))r=!0,i=i.slice(5).trimStart();if(i.startsWith("*"))n=!0,i=i.slice(1).trimStart();let o="";if(i.charCodeAt(0)===60){let h=0,p=-1;for(let m=0;m<i.length;m++)if(i.charCodeAt(m)===60)h++;else if(i.charCodeAt(m)===62&&!(m>0&&i.charCodeAt(m-1)===61)){if(h--,h===0){p=m;break}}if(p!==-1)o=i.slice(0,p+1),i=i.slice(p+1).trimStart()}let s=i.indexOf("("),l=ot(i,s,"(",")");if(s===-1||l===-1)return"() => unknown";let a=i.slice(s,l+1),f="unknown",u=i.slice(l+1).trimStart();if(u.charCodeAt(0)===58){let h=u.slice(1),p=Cs(h,0);if(p)f=h.slice(0,p.index).trim();else f=h.trim()}if(f==="unknown"&&!n&&u.charCodeAt(0)===123){let h=ot(u,0,"{","}");if(h!==-1){let p=Kt(u.slice(1,h),r,a);if(p!=="unknown"&&p!=="Promise<unknown>")f=r&&p.startsWith("Promise<")?p.slice(8,-1):p;else if(r)f="Promise<unknown>"}}if(f==="unknown"){if(r&&n)f="AsyncGenerator<unknown, void, unknown>";else if(n)f="Generator<unknown, void, unknown>";else if(r)f="Promise<void>"}else if(r&&!f.startsWith("Promise<")&&!f.startsWith("AsyncGenerator<"))f=`Promise<${f}>`;let d=gi(a);return`${o}${d} => ${f}`}function Cs(e,t){let i=0,r=0,n=0,o=0,s=!1,l=0;for(let a=t;a<e.length;a++){let f=e.charCodeAt(a);if(s){if(f===92)a++;else if(f===l)s=!1;continue}if(f===34||f===39||f===96){s=!0,l=f;continue}if(f===40)i++;else if(f===41&&i>0)i--;else if(f===91)r++;else if(f===93&&r>0)r--;else if(f===60)n++;else if(f===62&&n>0&&e.charCodeAt(a-1)!==61)n--;else if(f===125&&o>0)o--;else if(f===123){let u=i>0||r>0||n>0||o>0,d=e.slice(t,a).trimEnd(),h=d.charCodeAt(d.length-1),p=d.length===0||h===38||h===124||h===40||h===44||h===58||h===61||h===91;if(u||p)o++;else return{index:a,kind:"body"}}else if(f===61&&a+1<e.length&&e.charCodeAt(a+1)===62&&i===0&&r===0&&n===0&&o===0)return{index:a,kind:"arrow"}}return null}function ot(e,t,i,r){let n=0;for(let o=t;o<e.length;o++)if(e[o]===i)n++;else if(e[o]===r){if(r===">"&&o>0&&e[o-1]==="=")continue;if(n--,n===0)return o}return-1}function Mi(e){let t=0,i=0,r=!1,n="";for(let o=0;o<e.length-1;o++){let s=e[o],l=e[o+1],a=o>0?e[o-1]:"";if(!r&&(s==='"'||s==="'"||s==="`"))r=!0,n=s;else if(r&&s===n&&a!=="\\")r=!1;if(!r){if(s==="<"){let f=ot(e,o,"<",">");if(f!==-1){o=f;continue}}if(s==="(")t++;else if(s===")")t--;else if(s==="[")i++;else if(s==="]")i--;if(s==="="&&l===">"&&t===0&&i===0)return o}}return-1}function lc(e,t=!1,i=0,r=!0){let n=e.trim();if(n.length>200&&ls(n,"=>")>2&&ls(n,"<")>5&&!n.startsWith("function"))return t?"((...args: any[]) => any)":"(...args: any[]) => any";if(n.startsWith("async ")&&n.includes("=>")){let s=n.slice(5).trim(),l=Mi(s);if(l===-1)return t?"(() => Promise<unknown>)":"() => Promise<unknown>";let a=s.substring(0,l).trim(),f=s.substring(l+2).trim(),u=ms(a),{params:d,returnType:h}=u;if(d=gi(d),d==="()"||d==="")d="()";else if(!d.startsWith("("))d=`(${d})`;let p=h;if(p);else if(f.startsWith("{"))p=Kt(f.slice(1,f.endsWith("}")?-1:void 0),!0,u.params);else p=St(f,us(u.params));let m=`${d} => ${h||p.startsWith("Promise<")?p:`Promise<${p}>`}`;return t?`(${m})`:m}if(n.includes("=>")){let s="",l=n;if(n.startsWith("<")){let v=ot(n,0,"<",">");if(v!==-1)s=n.substring(0,v+1),l=n.substring(v+1).trim()}let a=Mi(l);if(a===-1)return t?"(() => unknown)":"() => unknown";let f=l.substring(0,a).trim(),u=l.substring(a+2).trim(),d=ms(f),{params:h,returnType:p}=d;if(h=gi(h),h==="()"||h==="")h="()";else if(!h.startsWith("("))h=`(${h})`;let m="unknown";if(p)m=p;else if(u.startsWith("{"))m=Kt(u.slice(1,u.endsWith("}")?-1:void 0),!1,d.params);else if(gn(u)||$n(u)&&gn(u.slice(1,-1).trim()))m="JSX.Element";else if(u.includes("=>")){let v=u.trimStart(),b=v.indexOf("("),C=b!==-1?ot(v,b,"(",")"):-1,k=C!==-1?v.indexOf("=>",C):-1;if(b===0&&C!==-1&&k!==-1){let W=v.substring(b+1,C).trim(),A=gi(W);if(s.includes("T")&&A.includes("T"))m=`(${A}) => T`;else m=`(${A}) => any`}else m="any"}else m=St(u,us(d.params));let c=`${s}${h} => ${m}`;return t?`(${c})`:c}if(n.startsWith("function")){let s=8,l=n.length;while(s<l&&n.charCodeAt(s)<=32)s++;let a=!1;if(s<l&&n.charCodeAt(s)===42){a=!0,s++;while(s<l&&n.charCodeAt(s)<=32)s++}let f="";if(s<l&&n.charCodeAt(s)===60){let h=s,p=1;s++;while(s<l&&p>0){let m=n.charCodeAt(s);if(m===60)p++;else if(m===62&&n.charCodeAt(s-1)!==61)p--;s++}f=n.substring(h,s);while(s<l&&n.charCodeAt(s)<=32)s++}let u=n.indexOf("(",s);if(u!==-1){let h=1,p=u+1;while(p<l&&h>0){let k=n.charCodeAt(p);if(k===40)h++;else if(k===41)h--;p++}let m=n.substring(u+1,p-1).trim(),c=m?gi(`(${m})`):"()";if(a){let k=n.substring(p).trim(),W=k.indexOf("Generator<");if(W!==-1){let R=W+10,V=k.indexOf(">",R);if(V!==-1){let B=k.substring(R,V),O=`${f}${c} => Generator<${B}>`;return t?`(${O})`:O}}let A=`${f}${c} => Generator<any, any, any>`;return t?`(${A})`:A}let v="unknown",b=n.substring(p).trimStart();if(b.charCodeAt(0)===58){let k=b.slice(1),W=Cs(k,0),A=(W?k.slice(0,W.index):k).trim();if(A)v=A}let C=`${f}${c} => ${v}`;return t?`(${C})`:C}let d="(...args: any[]) => unknown";return t?`(${d})`:d}if(n.includes("=>")&&n.includes("(")&&n.includes(")")){if(n.length>100||ls(n,"=>")>2){let s="";if(n.charCodeAt(0)===60){let d=ot(n,0,"<",">");if(d!==-1)s=n.substring(0,d+1)}let l=n.indexOf("("),a=l!==-1?ot(n,l,"(",")"):-1,f=l!==-1&&a!==-1?n.substring(l,a+1):"(...args: any[])";f=gi(f);let u=`${s}${f} => any`;return t?`(${u})`:u}return t?`(${n})`:n}let o="() => unknown";return t?`(${o})`:o}function ms(e){let t=e.trim();if(!t.startsWith("("))return{params:t,returnType:""};let i=ot(t,0,"(",")");if(i===-1)return{params:t,returnType:""};let r=t.slice(i+1).trim();return{params:t.slice(0,i+1),returnType:r.startsWith(":")?r.slice(1).trim():""}}function cc(e){let t=e.trim();if(t==="any"||t==="object"||t==="unknown")return!0;if(t.startsWith("Record<")&&t.endsWith(">"))return!0;if(t.startsWith("Array<")&&t.endsWith(">"))return!0;if(/^\{\s*\[[^\]]*\]:\s*(any|string|number|unknown)\s*\}$/.test(t))return!0;return!1}function En(e){let t=-1,i=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);if(o===34||o===39||o===96){n=Bt(e,n,o)-1;continue}if(o===47&&e.charCodeAt(n+1)===47){while(n<e.length&&e.charCodeAt(n)!==10)n++;continue}if(o===47&&e.charCodeAt(n+1)===42){let s=e.indexOf("*/",n+2);n=s===-1?e.length:s+1;continue}if(o===47){let s=n-1;while(s>=0&&e.charCodeAt(s)<=32)s--;if(s<0||"([{:;,=!?&|+*-~>".includes(e[s])){let l=!1;for(n++;n<e.length;n++){let a=e.charCodeAt(n);if(a===92)n++;else if(a===91)l=!0;else if(a===93)l=!1;else if(a===47&&!l)break}continue}}if(o===40||o===91||o===123)i++;else if(o===41||o===93||o===125)i--;else if(i===0&&e.startsWith("satisfies",n)&&gr(e,n,9)&&e[n-1]!==".")t=n}if(t===-1)return null;let r=e.slice(t+9).trim();if(r.endsWith(";"))r=r.slice(0,-1).trim();return r||null}var vn=20,bn=!1,pt=null,Vl;var vr=me(()=>{ht();fn();as();pn();Vl={string:{at:"string | undefined",charAt:"string",charCodeAt:"number",codePointAt:"number | undefined",concat:"string",endsWith:"boolean",includes:"boolean",indexOf:"number",lastIndexOf:"number",localeCompare:"number",normalize:"string",padEnd:"string",padStart:"string",repeat:"string",replace:"string",replaceAll:"string",search:"number",slice:"string",split:"string[]",startsWith:"boolean",substring:"string",toLocaleLowerCase:"string",toLocaleUpperCase:"string",toLowerCase:"string",toString:"string",toUpperCase:"string",trim:"string",trimEnd:"string",trimStart:"string",valueOf:"string"},number:{toExponential:"string",toFixed:"string",toLocaleString:"string",toPrecision:"string",toString:"string",valueOf:"number"},bigint:{toLocaleString:"string",toString:"string",valueOf:"bigint"},boolean:{toString:"string",valueOf:"boolean"}}});function fc(e,t,i,r){let n=new Map,o=new Map;for(let h of[...t,...i.values(),...[...r.values()].flat()])if(n.set(h.name,h),h.kind==="function"&&!o.has(h.name))o.set(h.name,h);for(let[h,p]of r)if(p.length)o.set(h,p[0]);if(!o.size)return;let s=new Set;for(let[h,p]of r)if(p.length>1)s.add(h);let l=new Map;for(let h of t)if(h.kind==="function"){let p=(l.get(h.name)??0)+1;if(l.set(h.name,p),p>1)s.add(h.name)}let a=mi(e),f=(h)=>a[h]?e.slice(a[h].start,a[h].end):"",u=new Map,d=0;for(let h=0;h<a.length;h++){let p=a[h];if(p.kind==="punctuation"){let R=e.charCodeAt(p.start);if(R===40||R===91||R===123)d++;else if(R===41||R===93||R===125)d--;continue}if(d||a[h+2]?.kind!=="word"||f(h+1)!=="."||f(h+3)!=="=")continue;let m=f(h);if(!o.has(m))continue;let c=f(h+2),v=h+4,b=v,C=0;for(;b<a.length;b++){let R=f(b);if(!C&&R===";")break;if(!C&&b>v&&/[\r\n]/.test(e.slice(a[b-1].end,a[b].start))&&(["export","const","let","var","function","class"].includes(R)||o.has(R)&&f(b+1)==="."))break;if(["(","[","{"].includes(R))C++;else if([")","]","}"].includes(R))C--}if(b===v)continue;let k=uc(e.slice(a[v].start,a[b-1].end),n,s),W=u.get(m);if(!W)u.set(m,W=new Map);let A=W.get(c);if(!A)W.set(c,A=[]);if(!A.includes(k))A.push(k);h=b-1}for(let[h,p]of u){let m=o.get(h),c=[...p].map(([b,C])=>` let ${b}: ${C.map((k)=>k.includes("=>")&&C.length>1?`(${k})`:k).join(" | ")};`).join(`
74
- `),v=m.isExported&&!m.isDefault?"export ":"";if(m.isDefault)m.text=m.text.replace("export default function ","declare function ");if(m.text+=`
75
- ${v}declare namespace ${h} {
70
+ `),i=t.indexOf("async");if(i!==-1){let f=i>0?t.charCodeAt(i-1):32,u=i+5<t.length?t.charCodeAt(i+5):32;if(!Mt(f)&&!Mt(u))t=(t.slice(0,i)+t.slice(i+5)).trim()}let r=t.indexOf("(");if(r!==-1){let f=ot(t,r,"(",")");if(f!==-1){let u=t.slice(r,f+1),d=gi(u);t=t.slice(0,r)+d+t.slice(f+1)}}let n=t.length,o="",s=[],l=!1,a=!1;for(let f=0;f<n;f++){let u=t.charCodeAt(f);if(u===123||u===40)s.push(u);else if(u===125||u===41)s.pop();if(u<=32){if(l=!0,u===10||u===13)a=!0;continue}if(l&&o.length>0){let d=(s.length>0?s[s.length-1]:0)===123;if(a&&d){let h=o.charCodeAt(o.length-1),p=h===59||h===44||h===123||u===125,m=o.length>=2&&o.charCodeAt(o.length-1)===47&&o.charCodeAt(o.length-2)===42;if(!p&&!m)o+="; ";else o+=" "}else o+=" "}l=!1,a=!1,o+=t[f]}return o.trim()}function Mt(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===95||e===36}function gi(e){let t=e.trim(),i,r=!1;if(t.startsWith("(")&&t.endsWith(")"))i=t.slice(1,-1),r=!0;else i=t;let n=i.trim();if(!n)return r?"()":"";let o=!1;{let m=0;for(let c=0;c<n.length;c++){let C=n.charCodeAt(c);if(C===40||C===60||C===91||C===123)m++;else if(C===41||C===93||C===125||C===62&&n.charCodeAt(c-1)!==61)m--;else if(m===0&&C===61){let b=c>0?n.charCodeAt(c-1):0,v=c+1<n.length?n.charCodeAt(c+1):0;if(b!==61&&b!==33&&b!==60&&b!==62&&v!==61&&v!==62){o=!0;break}}}}if(!o)return t;let s=[],l=[],a=0,f=0,u=!1,d=0;for(let m=0;m<=n.length;m++){if(m===n.length){s.push(n.slice(a));break}let c=n.charCodeAt(m);if(u){if(c===92){m++;continue}if(c===d)u=!1;continue}if(c===47&&m+1<n.length){let C=n.charCodeAt(m+1);if(C===42){m+=2;while(m+1<n.length&&!(n.charCodeAt(m)===42&&n.charCodeAt(m+1)===47))m++;m++;continue}if(C===47){while(m<n.length&&n.charCodeAt(m)!==10)m++;continue}}if(c===39||c===34||c===96){u=!0,d=c;continue}if(c===40||c===60||c===91||c===123)f++;else if(c===41||c===93||c===125||c===62&&n.charCodeAt(m-1)!==61)f--;else if(c===44&&f===0){s.push(n.slice(a,m));let C=",",b=m+1;while(b<n.length&&n.charCodeAt(b)<=32)C+=n[b],b++;l.push(C),a=b}}let h=[];for(let m of s){let c=m.trim();if(!c){h.push(m);continue}if(c.startsWith("//"))continue;let C=ac(c),b=m.slice(0,m.length-m.trimStart().length);h.push(b+ap(C))}let p=h[0]||"";for(let m=1;m<h.length;m++)p+=(l[m-1]||", ")+h[m];return pn(r?`(${p})`:p)}function ac(e){let t=!1,i=0;for(let r=0;r<e.length-1;r++){let n=e.charCodeAt(r);if(t){if(n===92){r++;continue}if(n===i)t=!1;continue}if(n===39||n===34||n===96){t=!0,i=n;continue}if(n===47&&e.charCodeAt(r+1)===47)return e.slice(0,r).trimEnd()}return e}function ap(e){if(e.startsWith("..."))return e;let t=-1,i=-1,r=0,n=!1,o=0;for(let l=0;l<e.length;l++){let a=e.charCodeAt(l);if(n){if(a===92){l++;continue}if(a===o)n=!1;continue}if(a===47&&l+1<e.length){let f=e.charCodeAt(l+1);if(f===42){l+=2;while(l+1<e.length&&!(e.charCodeAt(l)===42&&e.charCodeAt(l+1)===47))l++;l++;continue}if(f===47){while(l<e.length&&e.charCodeAt(l)!==10)l++;continue}}if(a===39||a===34||a===96){n=!0,o=a;continue}if(a===40||a===60||a===91||a===123)r++;else if(a===41||a===93||a===125||a===62&&e.charCodeAt(l-1)!==61)r--;else if(r===0){if(a===58&&t===-1)t=l;else if(a===61&&i===-1&&(l===0||e.charCodeAt(l-1)!==61)&&(l+1>=e.length||e.charCodeAt(l+1)!==61&&e.charCodeAt(l+1)!==62))i=l}}let s=i!==-1;if(t!==-1&&(i===-1||t<i)){let l=e.slice(0,t).trim(),a=i!==-1?e.slice(t+1,i).trim():e.slice(t+1).trim(),f=s&&!l.endsWith("?")?"?":"";return`${l}${f}: ${a}`}else if(i!==-1){let l=e.slice(0,i).trim(),a=mr(l,e.slice(i+1));if(a)return mn(a,Kl);let f=!l.endsWith("?")?"?":"";return`${l}${f}: ${Kl(e.slice(i+1))}`}return e}function Kl(e){let t=e.trim();if(t==="true"||t==="false")return"boolean";if(Ci(t))return"number";if(t.startsWith("'")&&t.endsWith("'")||t.startsWith('"')&&t.endsWith('"'))return"string";if(t.startsWith("["))return"unknown[]";if(t.startsWith("{"))return"Record<string, unknown>";return"unknown"}function lp(e){let t=0,i=e.length;while(t<i){while(t<i&&(e.charCodeAt(t)===32||e.charCodeAt(t)===9||e.charCodeAt(t)===10||e.charCodeAt(t)===13))t++;if(t+1<i&&e.charCodeAt(t)===47&&e.charCodeAt(t+1)===42){t+=2;while(t+1<i&&!(e.charCodeAt(t)===42&&e.charCodeAt(t+1)===47))t++;t+=2;continue}break}return t}function ms(e){let t=[],i=0,r=e.length;while(i<r){while(i<r&&e.charCodeAt(i)<=32)i++;if(i+1>=r||e.charCodeAt(i)!==47||e.charCodeAt(i+1)!==42)break;let n=i;i+=2;while(i+1<r&&!(e.charCodeAt(i)===42&&e.charCodeAt(i+1)===47))i++;i=Math.min(i+2,r),t.push(e.slice(n,i).trim())}return{comments:t.join(`
71
+ `),key:e.slice(i).trim()}}function cp(e){let t=[],i="",r="",n=0,o=!1,s="",l=!0,a=!1,f=0,u=!1,d=!1,h=0,p=!1,m=!1;for(let c=0;c<e.length;c++){let C=e.charCodeAt(c),b=c>0?e.charCodeAt(c-1):0,v=c<e.length-1?e.charCodeAt(c+1):0;if(!o&&!a&&C===47&&v===47){i=i.replace(/[ \t]+$/,""),c+=2;while(c<e.length&&e.charCodeAt(c)!==10)c++;c--;continue}if(!o&&!a&&C===47&&v===42){a=!0,f=1,i+="/*",c++;continue}else if(a&&C===42&&v===47){if(f--,i+="*/",c++,f===0)a=!1;continue}else if(a&&C===47&&v===42){f++,i+="/*",c++;continue}let k=e[c];if(!o&&!a&&(C===34||C===39||C===96))o=!0,s=k,i+=k;else if(o&&k===s&&b!==92)o=!1,i+=k;else if(!o&&!a)if(C===46&&v===46&&e.charCodeAt(c+2)===46&&n===0&&l)r=`${i.trim()}...`,i="",l=!1,p=!1,c+=2;else if(C===40&&n===0&&l&&h===0){r=i.trim();let W=lp(r),A=W>0?r.slice(0,W):"",R=r.slice(W),V="";if(R.startsWith("async ")||R.startsWith("async\t")||R.startsWith(`async
72
+ `))R=R.slice(6).trimStart(),V="async ";if(R.startsWith("*"))R=R.slice(1).trimStart(),V+="*";r=A+R,i=V+k,l=!1,p=!0,m=!1,n=1}else if(C===123||C===91||C===40){if(n++,i+=k,m&&C===123)m=!1}else if(C===125||C===93||C===41){if(n--,i+=k,C===41&&n===0&&!l&&!p)u=!0;if(p){if(C===41&&n===0&&!m)m=!0;else if(C===125&&n===0)p=!1,m=!1}}else if(C===58&&n===0&&l&&h===0)r=i.trim(),i="",l=!1;else if(C===58&&n===0&&u)d=!0,i+=k;else if(C===60&&d)h++,i+=k;else if(C===60&&l&&n===0)h++,i+=k;else if(C===62&&h>0&&b!==61)h--,i+=k;else if(C===61&&v===62&&d&&h===0)d=!1,u=!1,i+=k;else if(C===44&&n===0&&h===0&&!m){if(r&&i.trim()){let W=i.trim();t.push([r,W])}else if(l&&i.trim())Hl(t,i.trim());i="",r="",l=!0,u=!1,d=!1,h=0}else i+=k;else i+=k}if(r&&i.trim()){let c=i.trim();t.push([r,c])}else if(l&&i.trim())Hl(t,i.trim());return t}function Hl(e,t){let{comments:i,key:r}=ms(t);if(Di(r))e.push([i?`${i}
73
+ ${r}`:r,r]);else if(r.startsWith("...")&&r.length>3)e.push(["...",r.slice(3).trim()])}function ql(e){let t=e.trim();if(t.startsWith("get ")&&t.length>4){let i=t.slice(4).trim();if(i)return{kind:"get",name:i}}if(t.startsWith("set ")&&t.length>4){let i=t.slice(4).trim();if(i)return{kind:"set",name:i}}return null}function fp(e,t,i){let r=i.trim();if(r.charCodeAt(0)!==40)return null;let n=ot(r,0,"(",")");if(n===-1)return null;let o=r.slice(1,n).trim(),s=r.slice(n+1).trimStart();if(!s.startsWith("=>"))return null;let l=s.slice(2).trim();if(e==="get")return`get ${t}(): ${l||"unknown"}`;return`set ${t}(${o})`}function up(e,t){let i=t.trim(),r=ot(i,0,"(",")");if(!i.startsWith("(")||r===-1)return"unknown";if(e==="get"){let l=i.slice(r+1).trim();return l.startsWith("=>")?l.slice(2).trim():"unknown"}let n=i.slice(1,r).trim(),o=n.startsWith("{")?ot(n,0,"{","}"):n.startsWith("[")?ot(n,0,"[","]"):0,s=n.indexOf(":",Math.max(0,o));return s===-1?"unknown":n.slice(s+1).trim()}function dp(e){let t=e;if(t.startsWith("async ")||t.startsWith("async\t"))t=t.slice(5).trimStart();if(t.startsWith("*"))t=t.slice(1).trimStart();if(!t.startsWith("("))return!1;let i=0;for(let r=0;r<t.length;r++){let n=t.charCodeAt(r);if(n===40)i++;else if(n===41){if(i--,i===0){let o=t.slice(r+1).trimStart();if(o.startsWith("{"))return!0;if(o.startsWith(":")){let s=vs(o,1);if(s?.kind==="arrow")return!1;if(s?.kind==="body")return!0}return!1}}}return!1}function hp(e){let t=e.trimEnd();if(!t.endsWith(">"))return null;let i=0,r=-1;for(let o=t.length-1;o>=0;o--){let s=t.charCodeAt(o);if(s===62){if(o>0&&t.charCodeAt(o-1)===61)continue;i++}else if(s===60){if(i--,i===0){r=o;break}}}if(r===-1)return null;let n=t.slice(0,r).trimEnd();if(!n)return null;return{name:n,typeParams:t.slice(r)}}function Jl(e,t){let i=t.trimStart(),r=!1,n=!1;if(i.startsWith("async ")||i.startsWith("async\t"))r=!0,i=i.slice(5).trimStart();if(i.startsWith("*"))n=!0,i=i.slice(1).trimStart();let o="";if(i.charCodeAt(0)===60){let h=0,p=-1;for(let m=0;m<i.length;m++)if(i.charCodeAt(m)===60)h++;else if(i.charCodeAt(m)===62&&!(m>0&&i.charCodeAt(m-1)===61)){if(h--,h===0){p=m;break}}if(p!==-1)o=i.slice(0,p+1),i=i.slice(p+1).trimStart()}let s=i.indexOf("("),l=ot(i,s,"(",")");if(s===-1||l===-1)return"() => unknown";let a=i.slice(s,l+1),f="unknown",u=i.slice(l+1).trimStart();if(u.charCodeAt(0)===58){let h=u.slice(1),p=vs(h,0);if(p)f=h.slice(0,p.index).trim();else f=h.trim()}if(f==="unknown"&&!n&&u.charCodeAt(0)===123){let h=ot(u,0,"{","}");if(h!==-1){let p=Kt(u.slice(1,h),r,a);if(p!=="unknown"&&p!=="Promise<unknown>")f=r&&p.startsWith("Promise<")?p.slice(8,-1):p;else if(r)f="Promise<unknown>"}}if(f==="unknown"){if(r&&n)f="AsyncGenerator<unknown, void, unknown>";else if(n)f="Generator<unknown, void, unknown>";else if(r)f="Promise<void>"}else if(r&&!f.startsWith("Promise<")&&!f.startsWith("AsyncGenerator<"))f=`Promise<${f}>`;let d=gi(a);return`${o}${d} => ${f}`}function vs(e,t){let i=0,r=0,n=0,o=0,s=!1,l=0;for(let a=t;a<e.length;a++){let f=e.charCodeAt(a);if(s){if(f===92)a++;else if(f===l)s=!1;continue}if(f===34||f===39||f===96){s=!0,l=f;continue}if(f===40)i++;else if(f===41&&i>0)i--;else if(f===91)r++;else if(f===93&&r>0)r--;else if(f===60)n++;else if(f===62&&n>0&&e.charCodeAt(a-1)!==61)n--;else if(f===125&&o>0)o--;else if(f===123){let u=i>0||r>0||n>0||o>0,d=e.slice(t,a).trimEnd(),h=d.charCodeAt(d.length-1),p=d.length===0||h===38||h===124||h===40||h===44||h===58||h===61||h===91;if(u||p)o++;else return{index:a,kind:"body"}}else if(f===61&&a+1<e.length&&e.charCodeAt(a+1)===62&&i===0&&r===0&&n===0&&o===0)return{index:a,kind:"arrow"}}return null}function ot(e,t,i,r){let n=0;for(let o=t;o<e.length;o++)if(e[o]===i)n++;else if(e[o]===r){if(r===">"&&o>0&&e[o-1]==="=")continue;if(n--,n===0)return o}return-1}function wi(e){let t=0,i=0,r=!1,n="";for(let o=0;o<e.length-1;o++){let s=e[o],l=e[o+1],a=o>0?e[o-1]:"";if(!r&&(s==='"'||s==="'"||s==="`"))r=!0,n=s;else if(r&&s===n&&a!=="\\")r=!1;if(!r){if(s==="<"){let f=ot(e,o,"<",">");if(f!==-1){o=f;continue}}if(s==="(")t++;else if(s===")")t--;else if(s==="[")i++;else if(s==="]")i--;if(s==="="&&l===">"&&t===0&&i===0)return o}}return-1}function lc(e,t=!1,i=0,r=!0){let n=e.trim();if(n.length>200&&cs(n,"=>")>2&&cs(n,"<")>5&&!n.startsWith("function"))return t?"((...args: any[]) => any)":"(...args: any[]) => any";if(n.startsWith("async ")&&n.includes("=>")){let s=n.slice(5).trim(),l=wi(s);if(l===-1)return t?"(() => Promise<unknown>)":"() => Promise<unknown>";let a=s.substring(0,l).trim(),f=s.substring(l+2).trim(),u=gs(a),{params:d,returnType:h}=u;if(d=gi(d),d==="()"||d==="")d="()";else if(!d.startsWith("("))d=`(${d})`;let p=h;if(p);else if(f.startsWith("{"))p=Kt(f.slice(1,f.endsWith("}")?-1:void 0),!0,u.params);else p=St(f,ds(u.params));let m=`${d} => ${h||p.startsWith("Promise<")?p:`Promise<${p}>`}`;return t?`(${m})`:m}if(n.includes("=>")){let s="",l=n;if(n.startsWith("<")){let C=ot(n,0,"<",">");if(C!==-1)s=n.substring(0,C+1),l=n.substring(C+1).trim()}let a=wi(l);if(a===-1)return t?"(() => unknown)":"() => unknown";let f=l.substring(0,a).trim(),u=l.substring(a+2).trim(),d=gs(f),{params:h,returnType:p}=d;if(h=gi(h),h==="()"||h==="")h="()";else if(!h.startsWith("("))h=`(${h})`;let m="unknown";if(p)m=p;else if(u.startsWith("{"))m=Kt(u.slice(1,u.endsWith("}")?-1:void 0),!1,d.params);else if(wn(u)||xn(u)&&wn(u.slice(1,-1).trim()))m="JSX.Element";else if(u.includes("=>")){let C=u.trimStart(),b=C.indexOf("("),v=b!==-1?ot(C,b,"(",")"):-1,k=v!==-1?C.indexOf("=>",v):-1;if(b===0&&v!==-1&&k!==-1){let W=C.substring(b+1,v).trim(),A=gi(W);if(s.includes("T")&&A.includes("T"))m=`(${A}) => T`;else m=`(${A}) => any`}else m="any"}else m=St(u,ds(d.params));let c=`${s}${h} => ${m}`;return t?`(${c})`:c}if(n.startsWith("function")){let s=8,l=n.length;while(s<l&&n.charCodeAt(s)<=32)s++;let a=!1;if(s<l&&n.charCodeAt(s)===42){a=!0,s++;while(s<l&&n.charCodeAt(s)<=32)s++}let f="";if(s<l&&n.charCodeAt(s)===60){let h=s,p=1;s++;while(s<l&&p>0){let m=n.charCodeAt(s);if(m===60)p++;else if(m===62&&n.charCodeAt(s-1)!==61)p--;s++}f=n.substring(h,s);while(s<l&&n.charCodeAt(s)<=32)s++}let u=n.indexOf("(",s);if(u!==-1){let h=1,p=u+1;while(p<l&&h>0){let k=n.charCodeAt(p);if(k===40)h++;else if(k===41)h--;p++}let m=n.substring(u+1,p-1).trim(),c=m?gi(`(${m})`):"()";if(a){let k=n.substring(p).trim(),W=k.indexOf("Generator<");if(W!==-1){let R=W+10,V=k.indexOf(">",R);if(V!==-1){let B=k.substring(R,V),O=`${f}${c} => Generator<${B}>`;return t?`(${O})`:O}}let A=`${f}${c} => Generator<any, any, any>`;return t?`(${A})`:A}let C="unknown",b=n.substring(p).trimStart();if(b.charCodeAt(0)===58){let k=b.slice(1),W=vs(k,0),A=(W?k.slice(0,W.index):k).trim();if(A)C=A}let v=`${f}${c} => ${C}`;return t?`(${v})`:v}let d="(...args: any[]) => unknown";return t?`(${d})`:d}if(n.includes("=>")&&n.includes("(")&&n.includes(")")){if(n.length>100||cs(n,"=>")>2){let s="";if(n.charCodeAt(0)===60){let d=ot(n,0,"<",">");if(d!==-1)s=n.substring(0,d+1)}let l=n.indexOf("("),a=l!==-1?ot(n,l,"(",")"):-1,f=l!==-1&&a!==-1?n.substring(l,a+1):"(...args: any[])";f=gi(f);let u=`${s}${f} => any`;return t?`(${u})`:u}return t?`(${n})`:n}let o="() => unknown";return t?`(${o})`:o}function gs(e){let t=e.trim();if(!t.startsWith("("))return{params:t,returnType:""};let i=ot(t,0,"(",")");if(i===-1)return{params:t,returnType:""};let r=t.slice(i+1).trim();return{params:t.slice(0,i+1),returnType:r.startsWith(":")?r.slice(1).trim():""}}function cc(e){let t=e.trim();if(t==="any"||t==="object"||t==="unknown")return!0;if(t.startsWith("Record<")&&t.endsWith(">"))return!0;if(t.startsWith("Array<")&&t.endsWith(">"))return!0;if(/^\{\s*\[[^\]]*\]:\s*(any|string|number|unknown)\s*\}$/.test(t))return!0;return!1}function Sn(e){let t=-1,i=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);if(o===34||o===39||o===96){n=Bt(e,n,o)-1;continue}if(o===47&&e.charCodeAt(n+1)===47){while(n<e.length&&e.charCodeAt(n)!==10)n++;continue}if(o===47&&e.charCodeAt(n+1)===42){let s=e.indexOf("*/",n+2);n=s===-1?e.length:s+1;continue}if(o===47){let s=n-1;while(s>=0&&e.charCodeAt(s)<=32)s--;if(s<0||"([{:;,=!?&|+*-~>".includes(e[s])){let l=!1;for(n++;n<e.length;n++){let a=e.charCodeAt(n);if(a===92)n++;else if(a===91)l=!0;else if(a===93)l=!1;else if(a===47&&!l)break}continue}}if(o===40||o===91||o===123)i++;else if(o===41||o===93||o===125)i--;else if(i===0&&e.startsWith("satisfies",n)&&yr(e,n,9)&&e[n-1]!==".")t=n}if(t===-1)return null;let r=e.slice(t+9).trim();if(r.endsWith(";"))r=r.slice(0,-1).trim();return r||null}var $n=20,En=!1,pt=null,Vl;var vr=me(()=>{ht();un();dn();ls();gn();Vl={string:{at:"string | undefined",charAt:"string",charCodeAt:"number",codePointAt:"number | undefined",concat:"string",endsWith:"boolean",includes:"boolean",indexOf:"number",lastIndexOf:"number",localeCompare:"number",normalize:"string",padEnd:"string",padStart:"string",repeat:"string",replace:"string",replaceAll:"string",search:"number",slice:"string",split:"string[]",startsWith:"boolean",substring:"string",toLocaleLowerCase:"string",toLocaleUpperCase:"string",toLowerCase:"string",toString:"string",toUpperCase:"string",trim:"string",trimEnd:"string",trimStart:"string",valueOf:"string"},number:{toExponential:"string",toFixed:"string",toLocaleString:"string",toPrecision:"string",toString:"string",valueOf:"number"},bigint:{toLocaleString:"string",toString:"string",valueOf:"bigint"},boolean:{toString:"string",valueOf:"boolean"}}});function fc(e,t,i,r){let n=new Map,o=new Map;for(let h of[...t,...i.values(),...[...r.values()].flat()])if(n.set(h.name,h),h.kind==="function"&&!o.has(h.name))o.set(h.name,h);for(let[h,p]of r)if(p.length)o.set(h,p[0]);if(!o.size)return;let s=new Set;for(let[h,p]of r)if(p.length>1)s.add(h);let l=new Map;for(let h of t)if(h.kind==="function"){let p=(l.get(h.name)??0)+1;if(l.set(h.name,p),p>1)s.add(h.name)}let a=mi(e),f=(h)=>a[h]?e.slice(a[h].start,a[h].end):"",u=new Map,d=0;for(let h=0;h<a.length;h++){let p=a[h];if(p.kind==="punctuation"){let R=e.charCodeAt(p.start);if(R===40||R===91||R===123)d++;else if(R===41||R===93||R===125)d--;continue}if(d||a[h+2]?.kind!=="word"||f(h+1)!=="."||f(h+3)!=="=")continue;let m=f(h);if(!o.has(m))continue;let c=f(h+2),C=h+4,b=C,v=0;for(;b<a.length;b++){let R=f(b);if(!v&&R===";")break;if(!v&&b>C&&/[\r\n]/.test(e.slice(a[b-1].end,a[b].start))&&(["export","const","let","var","function","class"].includes(R)||o.has(R)&&f(b+1)==="."))break;if(["(","[","{"].includes(R))v++;else if([")","]","}"].includes(R))v--}if(b===C)continue;let k=uc(e.slice(a[C].start,a[b-1].end),n,s),W=u.get(m);if(!W)u.set(m,W=new Map);let A=W.get(c);if(!A)W.set(c,A=[]);if(!A.includes(k))A.push(k);h=b-1}for(let[h,p]of u){let m=o.get(h),c=[...p].map(([b,v])=>` let ${b}: ${v.map((k)=>k.includes("=>")&&v.length>1?`(${k})`:k).join(" | ")};`).join(`
74
+ `),C=m.isExported&&!m.isDefault?"export ":"";if(m.isDefault)m.text=m.text.replace("export default function ","declare function ");if(m.text+=`
75
+ ${C}declare namespace ${h} {
76
76
  ${c}
77
77
  }`,m.isDefault)m.text+=`
78
- export default ${h};`}}function uc(e,t,i,r=0){let n=e.trim(),o=t.get(n);if(o?.kind==="variable"&&r<64){if(o.typeAnnotation)return o.typeAnnotation==="unique symbol"?`typeof ${n}`:o.typeAnnotation;if(typeof o.value==="string")return uc(o.value,t,i,r+1)}let s=Te(n,!1);if(s!=="unknown")return s;let l=ce(n);if(l[0]?.kind==="word"&&l[1]&&n.slice(l[1].start,l[1].end)==="("&&n.endsWith(")")){let a=0,f=-1;for(let h=1;h<l.length;h++){let p=n.slice(l[h].start,l[h].end);if(p==="(")a++;else if(p===")"&&--a===0){f=h;break}}if(f!==l.length-1)return s;let u=n.slice(l[0].start,l[0].end),d=t.get(u);if(d?.kind==="function"&&!d.generics&&!i.has(u))return`ReturnType<typeof ${u}>`}if(/^[$A-Z_a-z][$\w]*(?:\.[$A-Z_a-z][$\w]*)*$/.test(n))return`typeof ${n}`;return s}var dc=me(()=>{ht();vr()});function up(e){if(e.includes(`
78
+ export default ${h};`}}function uc(e,t,i,r=0){let n=e.trim(),o=t.get(n);if(o?.kind==="variable"&&r<64){if(o.typeAnnotation)return o.typeAnnotation==="unique symbol"?`typeof ${n}`:o.typeAnnotation;if(typeof o.value==="string")return uc(o.value,t,i,r+1)}let s=Te(n,!1);if(s!=="unknown")return s;let l=ce(n);if(l[0]?.kind==="word"&&l[1]&&n.slice(l[1].start,l[1].end)==="("&&n.endsWith(")")){let a=0,f=-1;for(let h=1;h<l.length;h++){let p=n.slice(l[h].start,l[h].end);if(p==="(")a++;else if(p===")"&&--a===0){f=h;break}}if(f!==l.length-1)return s;let u=n.slice(l[0].start,l[0].end),d=t.get(u);if(d?.kind==="function"&&!d.generics&&!i.has(u))return`ReturnType<typeof ${u}>`}if(/^[$A-Z_a-z][$\w]*(?:\.[$A-Z_a-z][$\w]*)*$/.test(n))return`typeof ${n}`;return s}var dc=me(()=>{ht();vr()});function pp(e){if(e.includes(`
79
79
  `))return`/**
80
80
  * ${e}
81
81
  */
82
82
  `;return`/** ${e} */
83
- `}function dp(e){let t=e.indexOf("{");if(t===-1)return-1;let i=e.indexOf("<");if(i===-1||i>t)return t;let r=0,n=!1,o="";for(let s=0;s<e.length;s++){let l=e[s],a=s>0?e[s-1]:"";if(!n&&(l==='"'||l==="'"||l==="`"))n=!0,o=l;else if(n&&l===o&&a!=="\\")n=!1;if(!n){if(l==="<")r++;else if(l===">")r--;else if(l==="{"&&r===0)return s}}return-1}function hc(e,t=!0){return Lt(e.leadingComments,t)+e.text}function Di(e,t=!0){if(e.inferenceError)throw Object.assign(Error(`Cannot infer alias '${e.name}': unsupported source value flow`),{code:e.inferenceError});let i=Lt(e.leadingComments,t);if(!e.typeAnnotation&&e.inferredType)return i+e.text;if(e.typeAnnotation&&!e.value)return i+e.text;let r="";if(e.isExported)r+="export ";r+="declare ";let n=e.modifiers?.[0]||"const";r+=`${n} `,r+=e.name;let{typeAnnotation:o,value:s}=e,l=!o&&s?En(s):null;if(l)o=l;else if(!o&&s&&s.trim().endsWith("as const"))o=Te(s,!0,!1,0,e.computedKeyConstants);else if(!o&&s&&n==="const"){let f=s.trim(),u=f.startsWith("{")||f.startsWith("[");if(u)gs();o=Te(s,!u,!1,0,e.computedKeyConstants)}else if(!o&&s)o=Te(s,n==="const",!1,0,e.computedKeyConstants);if(!o)o="unknown";let a="";if(t&&s&&!e.typeAnnotation&&!s.trim().endsWith("as const")){let f=s.trim();if(n!=="const"){if((o==="string"||o==="number"||o==="boolean")&&f.length>0)a=`@defaultValue ${f}`}else if(f.startsWith("{")||f.startsWith("[")){let u=ys();if(u)if(u.includes(`
83
+ `}function mp(e){let t=e.indexOf("{");if(t===-1)return-1;let i=e.indexOf("<");if(i===-1||i>t)return t;let r=0,n=!1,o="";for(let s=0;s<e.length;s++){let l=e[s],a=s>0?e[s-1]:"";if(!n&&(l==='"'||l==="'"||l==="`"))n=!0,o=l;else if(n&&l===o&&a!=="\\")n=!1;if(!n){if(l==="<")r++;else if(l===">")r--;else if(l==="{"&&r===0)return s}}return-1}function hc(e,t=!0){return Lt(e.leadingComments,t)+e.text}function Ii(e,t=!0){if(e.inferenceError)throw Object.assign(Error(`Cannot infer alias '${e.name}': unsupported source value flow`),{code:e.inferenceError});let i=Lt(e.leadingComments,t);if(!e.typeAnnotation&&e.inferredType)return i+e.text;if(e.typeAnnotation&&!e.value)return i+e.text;let r="";if(e.isExported)r+="export ";r+="declare ";let n=e.modifiers?.[0]||"const";r+=`${n} `,r+=e.name;let{typeAnnotation:o,value:s}=e,l=!o&&s?Sn(s):null;if(l)o=l;else if(!o&&s&&s.trim().endsWith("as const"))o=Te(s,!0,!1,0,e.computedKeyConstants);else if(!o&&s&&n==="const"){let f=s.trim(),u=f.startsWith("{")||f.startsWith("[");if(u)ys();o=Te(s,!u,!1,0,e.computedKeyConstants)}else if(!o&&s)o=Te(s,n==="const",!1,0,e.computedKeyConstants);if(!o)o="unknown";let a="";if(t&&s&&!e.typeAnnotation&&!s.trim().endsWith("as const")){let f=s.trim();if(n!=="const"){if((o==="string"||o==="number"||o==="boolean")&&f.length>0)a=`@defaultValue ${f}`}else if(f.startsWith("{")||f.startsWith("[")){let u=ws();if(u)if(u.includes(`
84
84
  `))a=`@defaultValue
85
85
  * \`\`\`ts
86
86
  ${u.split(`
87
87
  `).map((d)=>` * ${d}`).join(`
88
88
  `)}
89
- * \`\`\``;else a=`@defaultValue \`${u}\``}}else if(t&&s&&e.typeAnnotation&&cc(e.typeAnnotation)){gs();let f=s.trim(),u=f.endsWith("as const")?f.slice(0,-8).trim():f;Te(u,!1,!1,0,e.computedKeyConstants);let d=ys();if(d)if(d.includes(`
89
+ * \`\`\``;else a=`@defaultValue \`${u}\``}}else if(t&&s&&e.typeAnnotation&&cc(e.typeAnnotation)){ys();let f=s.trim(),u=f.endsWith("as const")?f.slice(0,-8).trim():f;Te(u,!1,!1,0,e.computedKeyConstants);let d=ws();if(d)if(d.includes(`
90
90
  `))a=`@defaultValue
91
91
  * \`\`\`ts
92
92
  ${d.split(`
93
93
  `).map((h)=>` * ${h}`).join(`
94
94
  `)}
95
- * \`\`\``;else a=`@defaultValue \`${d}\``}if(a=mr(a),r+=`: ${o};`,a&&i&&i.includes("@defaultValue"))a="";if(a&&i){let f=i.trimEnd(),u=f.lastIndexOf("*/");if(u!==-1){let d=f.slice(0,u).trimEnd();if(d.startsWith("/** ")&&!d.includes(`
95
+ * \`\`\``;else a=`@defaultValue \`${d}\``}if(a=gr(a),r+=`: ${o};`,a&&i&&i.includes("@defaultValue"))a="";if(a&&i){let f=i.trimEnd(),u=f.lastIndexOf("*/");if(u!==-1){let d=f.slice(0,u).trimEnd();if(d.startsWith("/** ")&&!d.includes(`
96
96
  `))d=`/**
97
97
  * ${d.slice(4)}`;return`${d}
98
98
  * ${a}
@@ -101,54 +101,54 @@ ${d.split(`
101
101
  * ${f.replace(/^\/\/\s*/,"")}
102
102
  * ${a}
103
103
  */
104
- ${r}`}if(a)return`${up(a)}${r}`;return i+r}function pc(e,t=!0){let i=Lt(e.leadingComments,t),r=e.text;if(r.startsWith("export declare interface")||r.startsWith("declare interface"))return i+r;let n="";if(e.isExported)n+="export ";if(n+="declare interface ",n+=e.name,e.generics)n+=e.generics;if(e.extends)n+=` extends ${e.extends}`;let o=dp(e.text);if(o!==-1)n+=` ${e.text.slice(o)}`;else n+=" {}";return i+n}function mc(e,t=!0){let i=Lt(e.leadingComments,t);if(e.text.includes("{")&&e.text.includes("}")&&e.text.includes("from"))return i+e.text;let r="";if(e.isExported)r+="export ";if(!e.isExported&&!e.text.includes(" from "))r+="declare ";let n=e.text.indexOf("type ");if(n!==-1){let s=e.text.slice(n),l=s.length;while(l>0&&(s.charCodeAt(l-1)===59||s.charCodeAt(l-1)===32||s.charCodeAt(l-1)===10||s.charCodeAt(l-1)===13))l--;if(l<s.length)s=s.slice(0,l);r+=s}else{if(r+=`type ${e.name}`,e.generics)r+=e.generics;r+=" = any"}let o=r.trimEnd();if(!o.endsWith(";")&&!o.endsWith("}"))r+=";";return i+r}function gc(e,t=!0){return Lt(e.leadingComments,t)+e.text}function yc(e,t=!0){let i=Lt(e.leadingComments,t),r="";if(e.isExported)r+="export ";if(r+="declare ",e.modifiers?.includes("const"))r+="const ";r+="enum ",r+=e.name;let n=e.text.indexOf("{");if(n!==-1)r+=` ${e.text.slice(n)}`;else r+=" {}";return i+r}function wc(e,t=!0){let i=Lt(e.leadingComments,t);if(e.text.startsWith("declare global"))return i+e.text;if(e.source||(e.name.startsWith('"')||e.name.startsWith("'")||e.name.startsWith("`"))){let o="declare module ";o+=e.name;let s=e.text.indexOf("{");if(s!==-1)o+=` ${e.text.slice(s)}`;else o+=" {}";return i+o}let r="";if(e.isExported)r+="export ";if(!e.modifiers?.includes("declare"))r+="declare ";r+="namespace ",r+=e.name;let n=e.text.indexOf("{");if(n!==-1)r+=` ${e.text.slice(n)}`;else r+=" {}";return i+r}var xn=me(()=>{pn();vr()});function Cc(e){let t=Ci.get(e);if(t)return Ci.delete(e),Ci.set(e,t),t;return null}function vc(e,t){if(Ci.set(e,t),Ci.size>200){let i=0;for(let r of Ci.keys()){if(i++>=20)break;Ci.delete(r)}}}var Ci;var bc=me(()=>{Ci=new Map});function vs(e){return Rt(e).find((t)=>t.category==="static-import")}function hp(e){return ce(e).map((t)=>e.slice(t.start,t.end)).join(" ")}function pp(e){let t=vs(e);return t?e.lastIndexOf(" from ",t.start):-1}function Sn(e){let t=vs(e);return t?oi(t.specifier,"'"):void 0}function vi(e){let t=Cc(e);if(t)return t;let i=bi(e),r=i?[i.defaultName,i.namespaceName,...i.namedItems.map((n)=>n.name)].filter((n)=>n!==null):[];return vc(e,r),r}function mp(e){let t=[],i=0;for(let n of ce(e)){if(n.kind!=="punctuation"||e.slice(n.start,n.end)!==",")continue;let o=e.slice(i,n.start).trim();if(o)t.push(o);i=n.end}let r=e.slice(i).trim();if(r)t.push(r);return t}function bi(e){e=hp(e);let t=ln(e);if(t)return{defaultName:t.name,namedItems:[],source:t.source,isTypeOnly:t.isTypeOnly,isNamespace:!1,namespaceName:null,isImportEquals:!0};let i=pp(e);if(i===-1)return null;let r=vs(e);if(!r)return null;let n=r.specifier,o=e.slice(0,i).trim(),s=r.isTypeOnly;if(o.startsWith("import "))o=o.slice(7).trim();if(s&&o.startsWith("type "))o=o.slice(5).trim();let l=null,a=[],f=!1,u=null,d=o.includes("{")?-1:o.indexOf("* as ");if(d!==-1)return f=!0,u=o.slice(d+5).trim(),l=o.slice(0,d).trim().replace(/,$/,"").trim()||null,{defaultName:l,namedItems:[],source:n,isTypeOnly:s,isNamespace:f,namespaceName:u};let h=o.indexOf("{"),p=o.lastIndexOf("}");if(h!==-1&&p!==-1){let m=o.slice(0,h).trim();if(m.endsWith(","))l=m.slice(0,-1).trim()||null;let c=o.slice(h+1,p),v=mp(c);for(let b of v){let C=gp(b),k=C?b.slice(5).trim():b,W=k.lastIndexOf(" as "),A,R;if(W!==-1)R=k.slice(0,W).trim(),A=k.slice(W+4).trim();else A=k,R=k;a.push({name:A,originalName:R,isTypeOnly:s||C,isDefault:!1})}}else l=o.trim()||null;return{defaultName:l,namedItems:a,source:n,isTypeOnly:s,isNamespace:f,namespaceName:u}}function gp(e){let t=ce(e),i=t[0];if(!i||i.kind!=="word"||e.slice(i.start,i.end)!=="type"||t.length<2)return!1;return!(t.length===3&&e.slice(t[1].start,t[1].end)==="as")}var $i=me(()=>{ht();bc()});function bs(e,t){let i=(r)=>ce(r).map((n)=>r.slice(n.start,n.end)).join("");return i(e)===i(t)}function Ec(e){if(["number","string","boolean","bigint","symbol","undefined","null"].includes(e))return e;let t=Te(e,!1);return["number","string","boolean","bigint","undefined","null"].includes(t)?t:void 0}function $c(e,t){if(bs(e,t))return e;let i=Ec(t);if(!i)return;let r=ce(e),n=0,o=0,s=[];for(let a of r){let f=e.slice(a.start,a.end);if(f==="("||f==="["||f==="{"||f==="<")n++;else if(f===")"||f==="]"||f==="}"||f===">")n--;else if(f==="|"&&n===0)s.push(e.slice(o,a.start).trim()),o=a.end}s.push(e.slice(o).trim());let l=s.find((a)=>bs(a,t));if(l)return l;if(s.includes(i))return i==="boolean"&&(t==="true"||t==="false")?t:i;return}function xc(e,t,i,r=new Set){let n=new Map,o=[],s=new Set;for(let T of[...t,...i.values()]){if(s.has(T))continue;if(s.add(T),o.push(T),T.kind==="import")for(let j of vi(T.text))n.set(j,{declared:`typeof ${j}`,flow:`typeof ${j}`,unresolved:!1});else if(["function","class","enum"].includes(T.kind))n.set(T.name,{declared:`typeof ${T.name}`,flow:`typeof ${T.name}`,unresolved:!1});else if(T.kind==="variable")n.set(T.name,{declared:T.typeAnnotation,unresolved:!1})}o.sort((T,j)=>(T.start??0)-(j.start??0));let l=new Set(o.filter((T)=>T.kind==="function"&&!T.generics).map((T)=>T.name));for(let T of r)l.add(T);let a=new Map,f=(T)=>{if(T=T.trimStart(),a.has(T))return a.get(T);if(a.set(T,void 0),!dt(T.charCodeAt(0)))return;let j=1;while(He(T.charCodeAt(j)))j++;if(!l.has(T.slice(0,j)))return;let M=ce(T);if(M[0]?.kind!=="word"||!M[1]||T.slice(M[1].start,M[1].end)!=="(")return;let _=1;for(let G=2;G<M.length;G++){let Y=T.slice(M[G].start,M[G].end);if(Y==="(")_++;else if(Y===")"&&--_===0){let re=G===M.length-1?T.slice(M[0].start,M[0].end):void 0;return a.set(T,re),re}}return},u=new Set(o.filter((T)=>T.kind==="variable"&&!T.typeAnnotation&&typeof T.value==="string").map((T)=>f(T.value)).filter((T)=>T!==void 0)).size?mi(e):void 0,d=new Map;if(u){let T=0;for(let j=0;j<u.length;j++){let M=e.slice(u[j].start,u[j].end);if(T===0&&M==="function"){let _=u[j+1],G=_&&e.slice(_.start,_.end)==="*"?u[j+2]:_;if(G?.kind==="word"){let Y=e.slice(G.start,G.end);d.set(Y,(d.get(Y)??0)+1)}}if(["{","(","["].includes(M))T++;else if(["}",")","]"].includes(M))T--}}let h=new Map;for(let T of o)if(T.kind==="function"&&!T.generics&&d.get(T.name)===1)h.set(T.name,T);for(let T of r){let j=o.find((M)=>M.kind==="import"&&vi(M.text).includes(T));if(j)h.set(T,j)}let p="__dtsx_call_result";while(e.includes(p))p+="_";let m=(T)=>`(typeof ${T}) extends (...args: never[]) => infer ${p} ? ${p} : never`,c=new Map,v=!1;for(let T of o){if(T.kind!=="variable"||T.typeAnnotation||typeof T.value!=="string")continue;let j=f(T.value);if(j&&h.has(j))c.set(T,m(j)),n.get(T.name).active=!0,n.get(j).active=!0,v=!0;if(T.modifiers?.[0]!=="const")continue;let M=un(T.value);if(!M||M===T.name||!n.has(M))continue;n.get(M).active=!0,n.get(T.name).active=!0,v=!0}if(!v)return;let b=u??mi(e),C=(T)=>b[T]?e.slice(b[T].start,b[T].end):"",k=new Map,W=new Map,A=new Set,R=new Set,V=new Set,B=new Map,O=[];for(let T=0;T<b.length;T++){let j=C(T),M=O.at(-1);if(M!==void 0)W.set(T,M);if(j==="{"&&["=","(","[",",",":","?","return","yield"].includes(C(T-1)))A.add(T);if(["(","[","{"].includes(j))O.push(T);else if([")","]","}"].includes(j)){let _=O.at(-1);if(_!==void 0&&["()","[]","{}"].includes(C(_)+j))O.pop(),k.set(_,T)}}let z=new Map;for(let T=0;T<b.length;){if(b[T].kind!=="punctuation"){T++;continue}let j=[">>>=","**=","&&=","||=","??=","<<=",">>=","===","!==",">>>","**","&&","||","??","<<",">>","=>","==","!=","<=",">=","++","--","+=","-=","*=","/=","%=","&=","|=","^=","="].find((_)=>e.startsWith(_,b[T].start))??C(T);z.set(T,j);let M=b[T].start+j.length;do T++;while(T<b.length&&b[T].start<M)}for(let T=0;T<b.length;T++){let j=we(T);if(j!==void 0)R.add(j)}for(let T of R)fe(T);let X=0;function ae(T){let j=un(T);if(j){let Y=n.get(j);return{type:Y?.flow,unresolved:Y?.unresolved??!1}}let M=f(T),_=M?h.get(M):void 0;if(_)return{type:_.returnType&&Ec(_.returnType)?_.returnType:m(M),unresolved:!1};let G=Te(T,!0);return{type:G==="unknown"?void 0:G,unresolved:!1}}function be(T){return z.get(T)??""}function ke(T){if(b[T]?.kind!=="word"||V.has(T)||C(T-1)==="."||C(T-1)==="#"&&C(T-2)===".")return;let j=n.get(C(T));if(!j?.active)return;let M=be(T+1);if(["=","+=","-=","*=","/=","%=","**=","<<=",">>=",">>>=","&=","|=","^=","&&=","||=","??="].includes(M))return{binding:j,operator:M};if(["++","--"].includes(M)&&!/[\r\n]/.test(e.slice(b[T].end,b[T+1].start)))return{binding:j,operator:M};if(T>=2&&["++","--"].includes(be(T-2))){let _=b[T-3],G=_&&(_.kind==="word"||_.kind==="quoted"||[")","]"].includes(C(T-3)));if(!_||!G||/[\r\n;]/.test(e.slice(_.end,b[T-2].start)))return{binding:j,operator:be(T-2)}}return}function ve(T){let j=ke(T);return j?.operator==="="?j.binding:void 0}function we(T){if(b[T]?.kind!=="word"||C(T)!=="class"||C(T-1)==="."||["(",":","="].includes(C(T+1)))return;let j=T+1,M=0;while(j<b.length){let _=C(j);if(_==="{"&&M===0)return j;if(_==="class"){let G=we(j);if(G!==void 0){j=(k.get(G)??G)+1;continue}}if(_==="function"){let G=xe(j,b.length);if(G){j=G.end;continue}}if(_==="<")M++;else if(_===">"&&be(j-1)!=="=>"&&M>0)M--;if(_===";")break;j=(k.get(j)??j)+1}return}function ge(T,j,M){let _=T,G=!1,Y=M?["public","protected","private","static","abstract","override","declare","readonly","accessor","async","get","set"]:["async","get","set"];while(Y.includes(C(_))&&!["(","<","?","!",":","=",";","}"].includes(C(_+1))){if(C(_)==="static")G=!0;_++}if(C(_)==="*")_++;if(M&&C(_)==="#")_++;if(C(_)==="["){let Ae=k.get(_);return Ae===void 0?void 0:{next:Ae+1,isStatic:G}}if(b[_]?.kind==="word"||b[_]?.kind==="quoted")return{next:_+1,isStatic:G};let re=_+1;while(re<j&&b[re-1].end===b[re].start&&!["(","<","?","!",":","=",";","}","[","{",","].includes(C(re)))re++;if(_<j&&Te(e.slice(b[_].start,b[re-1].end),!1)==="number")return{next:re,isStatic:G};return}function ie(T,j,M){let _=ge(T,j,M);if(!_)return;let G=_.next;if(M&&["?","!"].includes(C(G)))G++;if(C(G)==="<"){let Y=1;G++;while(G<j&&Y>0){if(C(G)==="<")Y++;else if(C(G)===">"&&be(G-1)!=="=>")Y--;G=(k.get(G)??G)+1}if(Y!==0)return}return G}function I(T,j,M){return ie(T,j,M)===j}function K(T,j){let M=0,_=-1;for(let G=T;G<j;G=(k.get(G)??G)+1)if(C(G)==="<"&&(M>0||G>T&&(b[G-1].kind==="word"||[")","]"].includes(C(G-1))))){if(M===0)_=G;M++}else if(C(G)===">"&&be(G-1)!=="=>"&&M>0){if(M--,G===j-1&&M===0)return _<G-1}return!1}function Q(T,j){if(C(T)==="static"&&C(T+1)==="{")return!0;let M=ie(T,j,!0);return M!==void 0&&(M===j||["(",":","=",";","}"].includes(C(M)))}function oe(T,j,M=!1){let _=k.get(j)??b.length,G=T;while(G<_){if(C(G)===";"||M&&be(G)==="=")return G;if(G>T&&W.get(G)===j&&/[\r\n]/.test(e.slice(b[G-1].end,b[G].start))){let Y=C(G-1),re=!(Y===">"&&K(T,G)&&Q(G,_))&&["+","-","*","/","%","=","<",">","&","|","^","!","~","?",":",",",".","(","[","{","as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","yield","void"].includes(Y),Ae=[".","?",":",")","]","}",",","+","-","*","/","%","<",">","=","&","|","^","`","(","[","as","satisfies","instanceof","in"].includes(C(G));if(!re&&!Ae)return G}G=(k.get(G)??G)+1}return _}function ue(T,j){for(let M=T;M<j;M++){if(C(M)==="["&&k.has(M)){M=k.get(M);continue}if(b[M].kind==="word")V.add(M)}}function fe(T){let j=k.get(T)??b.length,M=T+1;while(M<j){if(C(M)===";"){M++;continue}if(C(M)==="static"&&C(M+1)==="{"){M=(k.get(M+1)??M+1)+1;continue}let _=ge(M,j,!0);if(!_){M++;continue}let G=ie(M,j,!0);if(G===void 0){M++;continue}if(ue(M,G),C(G)==="("){let re=k.get(G),Ae=re===void 0?void 0:Ee(re,j);if(Ae!==void 0){M=(k.get(Ae)??Ae)+1;continue}}let Y=G;if(C(Y)===":")Y=oe(Y+1,T,!0);if(be(Y)==="="){ue(M,Y+1);let re=Y+1,Ae=oe(re,T);if(!_.isStatic&&Ae>re)B.set(re,Ae);M=Ae}else{let re=oe(G,T);ue(M,re),M=Math.max(M+1,re)}}}function pe(T){let j=W.get(T);if(j===void 0)return!1;let M=R.has(j);if(!M&&!A.has(j))return!1;if(I(j+1,T,M))return!0;for(let _=j+1;_<T;_++){let G=W.get(_),Y=W.get(_)===j&&(C(_)===","||M&&C(_)===";"),re=M&&C(_)==="}"&&G!==void 0&&W.get(G)===j,Ae=M&&W.get(_+1)===j&&/[\r\n]/.test(e.slice(b[_].end,b[_+1].start));if((Y||re||Ae)&&I(_+1,T,M))return!0}return!1}function Ee(T,j){let M=T+1,_=C(M)===":"?M+1:void 0;while(M<j){if(C(M)==="{"&&(_===void 0||!ns(e.slice(b[_].start,b[M].start))))return M;if(_===void 0)return;M=(k.get(M)??M)+1}return}function xe(T,j){let M=-1;if(C(T)==="("){let G=k.get(T);if(G!==void 0&&pe(T))M=Ee(G,j)??-1;else if(G!==void 0&&be(G+1)==="=>")M=G+3;else if(G!==void 0&&C(G+1)===":"){let Y=G+2;while(Y<j&&C(Y)!==";"){if(be(Y)==="=>"){M=Y+2;break}Y=(k.get(Y)??Y)+1}}}else if(b[T]?.kind==="word"&&be(T+1)==="=>")M=T+3;else if(C(T)==="function"){let G=T+1;while(G<j&&C(G)!=="(")G=(k.get(G)??G)+1;let Y=k.get(G);if(Y===void 0)return;M=Y+1;let re=C(M)===":"?M+1:void 0;while(M<j){if(C(M)==="{"&&(re===void 0||!ns(e.slice(b[re].start,b[M].start))))break;M=(k.get(M)??M)+1}}if(M<0||M>=j)return;if(C(M)==="{")return{start:T,end:(k.get(M)??j-1)+1};let _=M;while(_<j&&![",",";",")","]","}"].includes(C(_)))_=(k.get(_)??_)+1;return{start:T,end:_}}function Je(T,j,M=!0){for(let _=T;_<j;_++){let G=B.get(_);if(G!==void 0){_=Math.min(G,j)-1;continue}let Y=M?xe(_,j):void 0;if(Y){let Ae=Y.end;while(C(Ae)===")")Ae++;if(C(Ae)==="("||C(Ae)==="."&&["call","apply"].includes(C(Ae+1))&&C(Ae+2)==="(")Je(Y.start,Y.end,!1);_=Y.end-1;continue}let re=ke(_);if(re)re.binding.flow=void 0,re.binding.unresolved=!0}}function hi(T){let j=!1;while(X<b.length&&b[X].start<T){let M=C(X);if(["if","else","for","while","do","switch","try","catch","finally","with"].includes(M))j=!0;if(M===";")j=!1;if(M==="("||M==="{"||M==="["){let Y=k.get(X)??X+1;while(Y<b.length&&b[Y].start>=T)Y--;if(Je(X+1,Y),X=Y+1,M==="{")j=!1;continue}let _=ve(X);if(_){let Y=X+2,re=Y,Ae=[];while(re<b.length&&b[re].start<T){let ct=C(re);if(Ae.length===0&&(ct===";"||re>Y&&/[\r\n]/.test(e.slice(b[re-1].end,b[re].start))&&(ve(re)||["if","for","while","switch","try","do","return","throw"].includes(ct))))break;if(ct==="("||ct==="{"||ct==="[")Ae.push(ct==="("?")":ct==="{"?"}":"]");else if(ct===Ae.at(-1))Ae.pop();re++}let Ot=re>Y?e.slice(b[Y].start,b[re-1].end):"";Je(Y,re);let Ut=ae(Ot);_.flow=!j&&Ut.type?_.declared?$c(_.declared,Ut.type):Ut.type:void 0,_.unresolved=j||Ut.unresolved||!_.flow,X=re;continue}let G=ke(X);if(G)G.binding.flow=void 0,G.binding.unresolved=!0;X++}}for(let T of o){hi(T.start??0);let j=X;while(X<b.length&&b[X].start<(T.end??0))X++;if(T.kind!=="variable")continue;if(T.initializerStart!==void 0){let Ot=j;while(Ot<X&&b[Ot].start<T.initializerStart)Ot++;Je(Ot,X)}let M=n.get(T.name);if(!M.active)continue;let _=typeof T.value==="string"?T.value:"";if(!_){M.flow=M.declared;continue}let G=ae(_),Y=un(_),re=Y?n.get(Y):void 0,Ae=c.get(T);if(Ae)T.inferredType=Ae,T.text=`${T.isExported?"export ":""}declare ${T.modifiers?.[0]??"const"} ${T.name}: ${Ae};`;else if(!T.typeAnnotation&&T.modifiers?.[0]==="const"&&Y&&Y!==T.name&&re){if(G.unresolved)T.inferenceError="DTSX_UNSUPPORTED_VALUE_FLOW";else if(G.type)T.inferredType=re.declared&&bs(re.declared,G.type)?`typeof ${Y}`:G.type,T.text=`${T.isExported?"export ":""}declare const ${T.name}: ${T.inferredType};`}if(T.typeAnnotation)M.flow=G.type?$c(T.typeAnnotation,G.type)??T.typeAnnotation:T.typeAnnotation;else if(T.inferredType)M.declared=T.inferredType,M.flow=T.inferredType;else{let Ot=T.modifiers?.[0]==="const",Ut=_.trim().startsWith("{")||_.trim().startsWith("["),ct=Te(_,Ot&&!Ut);M.declared=ct==="unknown"?void 0:ct,M.flow=M.declared}M.unresolved=G.unresolved}}var Sc=me(()=>{dr();ht();hr();$i();vr()});function yp(e,t,i,r,n=""){let o=new Map,s={start:0,end:e.length,header:0,name:"",children:[],results:new Map},l=ce(e),a=[],f=[],u=[],d=new Map;for(let c=0;c<l.length;c++){let v=l[c];if(v.kind!=="punctuation")continue;let b=e.slice(v.start,v.end);if(b==="(")u.push(c);else if(b===")"){let C=u.pop();if(C!==void 0)d.set(c,C)}else if(b==="{")f.push(c);else if(b==="}"){let C=f.pop();if(C===void 0)continue;let k=l[C].start,W=C-1,A=W>=0?e.slice(l[W].start,l[W].end):"";if(A===")"){let R=d.get(W);if(R!==void 0&&R>0&&["if","for","while","switch","catch","with"].includes(e.slice(l[R-1].start,l[R-1].end)))k=l[R-1].start}else if(["else","try","finally","do"].includes(A))k=l[W].start;a.push({open:l[C].start,close:v.start,header:k})}}let h=0,p=(c,v=new Set)=>{let b=new Set(v),C=ce(e.slice(c.start,c.end)),k=0;for(let z=0;z+1<C.length;z++){let X=e.slice(c.start+C[z].start,c.start+C[z].end);if(X==="{")k++;else if(X==="}")k--;else if(!k&&["type","interface"].includes(X))b.add(e.slice(c.start+C[z+1].start,c.start+C[z+1].end))}let W="",A=c.start,R=[...c.results].map(([z,X])=>({type:z,name:X}));for(let z of c.children.sort((X,ae)=>X.header-ae.header)){let X=p(z,b);W+=e.slice(A,z.header)+`
104
+ ${r}`}if(a)return`${pp(a)}${r}`;return i+r}function pc(e,t=!0){let i=Lt(e.leadingComments,t),r=e.text;if(r.startsWith("export declare interface")||r.startsWith("declare interface"))return i+r;let n="";if(e.isExported)n+="export ";if(n+="declare interface ",n+=e.name,e.generics)n+=e.generics;if(e.extends)n+=` extends ${e.extends}`;let o=mp(e.text);if(o!==-1)n+=` ${e.text.slice(o)}`;else n+=" {}";return i+n}function mc(e,t=!0){let i=Lt(e.leadingComments,t);if(e.text.includes("{")&&e.text.includes("}")&&e.text.includes("from"))return i+e.text;let r="";if(e.isExported)r+="export ";if(!e.isExported&&!e.text.includes(" from "))r+="declare ";let n=e.text.indexOf("type ");if(n!==-1){let s=e.text.slice(n),l=s.length;while(l>0&&(s.charCodeAt(l-1)===59||s.charCodeAt(l-1)===32||s.charCodeAt(l-1)===10||s.charCodeAt(l-1)===13))l--;if(l<s.length)s=s.slice(0,l);r+=s}else{if(r+=`type ${e.name}`,e.generics)r+=e.generics;r+=" = any"}let o=r.trimEnd();if(!o.endsWith(";")&&!o.endsWith("}"))r+=";";return i+r}function gc(e,t=!0){return Lt(e.leadingComments,t)+e.text}function yc(e,t=!0){let i=Lt(e.leadingComments,t),r="";if(e.isExported)r+="export ";if(r+="declare ",e.modifiers?.includes("const"))r+="const ";r+="enum ",r+=e.name;let n=e.text.indexOf("{");if(n!==-1)r+=` ${e.text.slice(n)}`;else r+=" {}";return i+r}function wc(e,t=!0){let i=Lt(e.leadingComments,t);if(e.text.startsWith("declare global"))return i+e.text;if(e.source||(e.name.startsWith('"')||e.name.startsWith("'")||e.name.startsWith("`"))){let o="declare module ";o+=e.name;let s=e.text.indexOf("{");if(s!==-1)o+=` ${e.text.slice(s)}`;else o+=" {}";return i+o}let r="";if(e.isExported)r+="export ";if(!e.modifiers?.includes("declare"))r+="declare ";r+="namespace ",r+=e.name;let n=e.text.indexOf("{");if(n!==-1)r+=` ${e.text.slice(n)}`;else r+=" {}";return i+r}var An=me(()=>{gn();vr()});function Cc(e){let t=vi.get(e);if(t)return vi.delete(e),vi.set(e,t),t;return null}function vc(e,t){if(vi.set(e,t),vi.size>200){let i=0;for(let r of vi.keys()){if(i++>=20)break;vi.delete(r)}}}var vi;var bc=me(()=>{vi=new Map});function bs(e){return Rt(e).find((t)=>t.category==="static-import")}function gp(e){return ce(e).map((t)=>e.slice(t.start,t.end)).join(" ")}function yp(e){let t=bs(e);return t?e.lastIndexOf(" from ",t.start):-1}function kn(e){let t=bs(e);return t?oi(t.specifier,"'"):void 0}function bi(e){let t=Cc(e);if(t)return t;let i=$i(e),r=i?[i.defaultName,i.namespaceName,...i.namedItems.map((n)=>n.name)].filter((n)=>n!==null):[];return vc(e,r),r}function wp(e){let t=[],i=0;for(let n of ce(e)){if(n.kind!=="punctuation"||e.slice(n.start,n.end)!==",")continue;let o=e.slice(i,n.start).trim();if(o)t.push(o);i=n.end}let r=e.slice(i).trim();if(r)t.push(r);return t}function $i(e){e=gp(e);let t=ln(e);if(t)return{defaultName:t.name,namedItems:[],source:t.source,isTypeOnly:t.isTypeOnly,isNamespace:!1,namespaceName:null,isImportEquals:!0};let i=yp(e);if(i===-1)return null;let r=bs(e);if(!r)return null;let n=r.specifier,o=e.slice(0,i).trim(),s=r.isTypeOnly;if(o.startsWith("import "))o=o.slice(7).trim();if(s&&o.startsWith("type "))o=o.slice(5).trim();let l=null,a=[],f=!1,u=null,d=o.includes("{")?-1:o.indexOf("* as ");if(d!==-1)return f=!0,u=o.slice(d+5).trim(),l=o.slice(0,d).trim().replace(/,$/,"").trim()||null,{defaultName:l,namedItems:[],source:n,isTypeOnly:s,isNamespace:f,namespaceName:u};let h=o.indexOf("{"),p=o.lastIndexOf("}");if(h!==-1&&p!==-1){let m=o.slice(0,h).trim();if(m.endsWith(","))l=m.slice(0,-1).trim()||null;let c=o.slice(h+1,p),C=wp(c);for(let b of C){let v=Cp(b),k=v?b.slice(5).trim():b,W=k.lastIndexOf(" as "),A,R;if(W!==-1)R=k.slice(0,W).trim(),A=k.slice(W+4).trim();else A=k,R=k;a.push({name:A,originalName:R,isTypeOnly:s||v,isDefault:!1})}}else l=o.trim()||null;return{defaultName:l,namedItems:a,source:n,isTypeOnly:s,isNamespace:f,namespaceName:u}}function Cp(e){let t=ce(e),i=t[0];if(!i||i.kind!=="word"||e.slice(i.start,i.end)!=="type"||t.length<2)return!1;return!(t.length===3&&e.slice(t[1].start,t[1].end)==="as")}var Ei=me(()=>{ht();bc()});function $s(e,t){let i=(r)=>ce(r).map((n)=>r.slice(n.start,n.end)).join("");return i(e)===i(t)}function Ec(e){if(["number","string","boolean","bigint","symbol","undefined","null"].includes(e))return e;let t=Te(e,!1);return["number","string","boolean","bigint","undefined","null"].includes(t)?t:void 0}function $c(e,t){if($s(e,t))return e;let i=Ec(t);if(!i)return;let r=ce(e),n=0,o=0,s=[];for(let a of r){let f=e.slice(a.start,a.end);if(f==="("||f==="["||f==="{"||f==="<")n++;else if(f===")"||f==="]"||f==="}"||f===">")n--;else if(f==="|"&&n===0)s.push(e.slice(o,a.start).trim()),o=a.end}s.push(e.slice(o).trim());let l=s.find((a)=>$s(a,t));if(l)return l;if(s.includes(i))return i==="boolean"&&(t==="true"||t==="false")?t:i;return}function xc(e,t,i,r=new Set){let n=new Map,o=[],s=new Set;for(let T of[...t,...i.values()]){if(s.has(T))continue;if(s.add(T),o.push(T),T.kind==="import")for(let j of bi(T.text))n.set(j,{declared:`typeof ${j}`,flow:`typeof ${j}`,unresolved:!1});else if(["function","class","enum"].includes(T.kind))n.set(T.name,{declared:`typeof ${T.name}`,flow:`typeof ${T.name}`,unresolved:!1});else if(T.kind==="variable")n.set(T.name,{declared:T.typeAnnotation,unresolved:!1})}o.sort((T,j)=>(T.start??0)-(j.start??0));let l=new Set(o.filter((T)=>T.kind==="function"&&!T.generics).map((T)=>T.name));for(let T of r)l.add(T);let a=new Map,f=(T)=>{if(T=T.trimStart(),a.has(T))return a.get(T);if(a.set(T,void 0),!dt(T.charCodeAt(0)))return;let j=1;while(He(T.charCodeAt(j)))j++;if(!l.has(T.slice(0,j)))return;let M=ce(T);if(M[0]?.kind!=="word"||!M[1]||T.slice(M[1].start,M[1].end)!=="(")return;let _=1;for(let G=2;G<M.length;G++){let Y=T.slice(M[G].start,M[G].end);if(Y==="(")_++;else if(Y===")"&&--_===0){let re=G===M.length-1?T.slice(M[0].start,M[0].end):void 0;return a.set(T,re),re}}return},u=new Set(o.filter((T)=>T.kind==="variable"&&!T.typeAnnotation&&typeof T.value==="string").map((T)=>f(T.value)).filter((T)=>T!==void 0)).size?mi(e):void 0,d=new Map;if(u){let T=0;for(let j=0;j<u.length;j++){let M=e.slice(u[j].start,u[j].end);if(T===0&&M==="function"){let _=u[j+1],G=_&&e.slice(_.start,_.end)==="*"?u[j+2]:_;if(G?.kind==="word"){let Y=e.slice(G.start,G.end);d.set(Y,(d.get(Y)??0)+1)}}if(["{","(","["].includes(M))T++;else if(["}",")","]"].includes(M))T--}}let h=new Map;for(let T of o)if(T.kind==="function"&&!T.generics&&d.get(T.name)===1)h.set(T.name,T);for(let T of r){let j=o.find((M)=>M.kind==="import"&&bi(M.text).includes(T));if(j)h.set(T,j)}let p="__dtsx_call_result";while(e.includes(p))p+="_";let m=(T)=>`(typeof ${T}) extends (...args: never[]) => infer ${p} ? ${p} : never`,c=new Map,C=!1;for(let T of o){if(T.kind!=="variable"||T.typeAnnotation||typeof T.value!=="string")continue;let j=f(T.value);if(j&&h.has(j))c.set(T,m(j)),n.get(T.name).active=!0,n.get(j).active=!0,C=!0;if(T.modifiers?.[0]!=="const")continue;let M=hn(T.value);if(!M||M===T.name||!n.has(M))continue;n.get(M).active=!0,n.get(T.name).active=!0,C=!0}if(!C)return;let b=u??mi(e),v=(T)=>b[T]?e.slice(b[T].start,b[T].end):"",k=new Map,W=new Map,A=new Set,R=new Set,V=new Set,B=new Map,O=[];for(let T=0;T<b.length;T++){let j=v(T),M=O.at(-1);if(M!==void 0)W.set(T,M);if(j==="{"&&["=","(","[",",",":","?","return","yield"].includes(v(T-1)))A.add(T);if(["(","[","{"].includes(j))O.push(T);else if([")","]","}"].includes(j)){let _=O.at(-1);if(_!==void 0&&["()","[]","{}"].includes(v(_)+j))O.pop(),k.set(_,T)}}let z=new Map;for(let T=0;T<b.length;){if(b[T].kind!=="punctuation"){T++;continue}let j=[">>>=","**=","&&=","||=","??=","<<=",">>=","===","!==",">>>","**","&&","||","??","<<",">>","=>","==","!=","<=",">=","++","--","+=","-=","*=","/=","%=","&=","|=","^=","="].find((_)=>e.startsWith(_,b[T].start))??v(T);z.set(T,j);let M=b[T].start+j.length;do T++;while(T<b.length&&b[T].start<M)}for(let T=0;T<b.length;T++){let j=we(T);if(j!==void 0)R.add(j)}for(let T of R)fe(T);let X=0;function ae(T){let j=hn(T);if(j){let Y=n.get(j);return{type:Y?.flow,unresolved:Y?.unresolved??!1}}let M=f(T),_=M?h.get(M):void 0;if(_)return{type:_.returnType&&Ec(_.returnType)?_.returnType:m(M),unresolved:!1};let G=Te(T,!0);return{type:G==="unknown"?void 0:G,unresolved:!1}}function be(T){return z.get(T)??""}function ke(T){if(b[T]?.kind!=="word"||V.has(T)||v(T-1)==="."||v(T-1)==="#"&&v(T-2)===".")return;let j=n.get(v(T));if(!j?.active)return;let M=be(T+1);if(["=","+=","-=","*=","/=","%=","**=","<<=",">>=",">>>=","&=","|=","^=","&&=","||=","??="].includes(M))return{binding:j,operator:M};if(["++","--"].includes(M)&&!/[\r\n]/.test(e.slice(b[T].end,b[T+1].start)))return{binding:j,operator:M};if(T>=2&&["++","--"].includes(be(T-2))){let _=b[T-3],G=_&&(_.kind==="word"||_.kind==="quoted"||[")","]"].includes(v(T-3)));if(!_||!G||/[\r\n;]/.test(e.slice(_.end,b[T-2].start)))return{binding:j,operator:be(T-2)}}return}function ve(T){let j=ke(T);return j?.operator==="="?j.binding:void 0}function we(T){if(b[T]?.kind!=="word"||v(T)!=="class"||v(T-1)==="."||["(",":","="].includes(v(T+1)))return;let j=T+1,M=0;while(j<b.length){let _=v(j);if(_==="{"&&M===0)return j;if(_==="class"){let G=we(j);if(G!==void 0){j=(k.get(G)??G)+1;continue}}if(_==="function"){let G=xe(j,b.length);if(G){j=G.end;continue}}if(_==="<")M++;else if(_===">"&&be(j-1)!=="=>"&&M>0)M--;if(_===";")break;j=(k.get(j)??j)+1}return}function ge(T,j,M){let _=T,G=!1,Y=M?["public","protected","private","static","abstract","override","declare","readonly","accessor","async","get","set"]:["async","get","set"];while(Y.includes(v(_))&&!["(","<","?","!",":","=",";","}"].includes(v(_+1))){if(v(_)==="static")G=!0;_++}if(v(_)==="*")_++;if(M&&v(_)==="#")_++;if(v(_)==="["){let Ae=k.get(_);return Ae===void 0?void 0:{next:Ae+1,isStatic:G}}if(b[_]?.kind==="word"||b[_]?.kind==="quoted")return{next:_+1,isStatic:G};let re=_+1;while(re<j&&b[re-1].end===b[re].start&&!["(","<","?","!",":","=",";","}","[","{",","].includes(v(re)))re++;if(_<j&&Te(e.slice(b[_].start,b[re-1].end),!1)==="number")return{next:re,isStatic:G};return}function ie(T,j,M){let _=ge(T,j,M);if(!_)return;let G=_.next;if(M&&["?","!"].includes(v(G)))G++;if(v(G)==="<"){let Y=1;G++;while(G<j&&Y>0){if(v(G)==="<")Y++;else if(v(G)===">"&&be(G-1)!=="=>")Y--;G=(k.get(G)??G)+1}if(Y!==0)return}return G}function I(T,j,M){return ie(T,j,M)===j}function K(T,j){let M=0,_=-1;for(let G=T;G<j;G=(k.get(G)??G)+1)if(v(G)==="<"&&(M>0||G>T&&(b[G-1].kind==="word"||[")","]"].includes(v(G-1))))){if(M===0)_=G;M++}else if(v(G)===">"&&be(G-1)!=="=>"&&M>0){if(M--,G===j-1&&M===0)return _<G-1}return!1}function Q(T,j){if(v(T)==="static"&&v(T+1)==="{")return!0;let M=ie(T,j,!0);return M!==void 0&&(M===j||["(",":","=",";","}"].includes(v(M)))}function oe(T,j,M=!1){let _=k.get(j)??b.length,G=T;while(G<_){if(v(G)===";"||M&&be(G)==="=")return G;if(G>T&&W.get(G)===j&&/[\r\n]/.test(e.slice(b[G-1].end,b[G].start))){let Y=v(G-1),re=!(Y===">"&&K(T,G)&&Q(G,_))&&["+","-","*","/","%","=","<",">","&","|","^","!","~","?",":",",",".","(","[","{","as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","yield","void"].includes(Y),Ae=[".","?",":",")","]","}",",","+","-","*","/","%","<",">","=","&","|","^","`","(","[","as","satisfies","instanceof","in"].includes(v(G));if(!re&&!Ae)return G}G=(k.get(G)??G)+1}return _}function ue(T,j){for(let M=T;M<j;M++){if(v(M)==="["&&k.has(M)){M=k.get(M);continue}if(b[M].kind==="word")V.add(M)}}function fe(T){let j=k.get(T)??b.length,M=T+1;while(M<j){if(v(M)===";"){M++;continue}if(v(M)==="static"&&v(M+1)==="{"){M=(k.get(M+1)??M+1)+1;continue}let _=ge(M,j,!0);if(!_){M++;continue}let G=ie(M,j,!0);if(G===void 0){M++;continue}if(ue(M,G),v(G)==="("){let re=k.get(G),Ae=re===void 0?void 0:Ee(re,j);if(Ae!==void 0){M=(k.get(Ae)??Ae)+1;continue}}let Y=G;if(v(Y)===":")Y=oe(Y+1,T,!0);if(be(Y)==="="){ue(M,Y+1);let re=Y+1,Ae=oe(re,T);if(!_.isStatic&&Ae>re)B.set(re,Ae);M=Ae}else{let re=oe(G,T);ue(M,re),M=Math.max(M+1,re)}}}function pe(T){let j=W.get(T);if(j===void 0)return!1;let M=R.has(j);if(!M&&!A.has(j))return!1;if(I(j+1,T,M))return!0;for(let _=j+1;_<T;_++){let G=W.get(_),Y=W.get(_)===j&&(v(_)===","||M&&v(_)===";"),re=M&&v(_)==="}"&&G!==void 0&&W.get(G)===j,Ae=M&&W.get(_+1)===j&&/[\r\n]/.test(e.slice(b[_].end,b[_+1].start));if((Y||re||Ae)&&I(_+1,T,M))return!0}return!1}function Ee(T,j){let M=T+1,_=v(M)===":"?M+1:void 0;while(M<j){if(v(M)==="{"&&(_===void 0||!os(e.slice(b[_].start,b[M].start))))return M;if(_===void 0)return;M=(k.get(M)??M)+1}return}function xe(T,j){let M=-1;if(v(T)==="("){let G=k.get(T);if(G!==void 0&&pe(T))M=Ee(G,j)??-1;else if(G!==void 0&&be(G+1)==="=>")M=G+3;else if(G!==void 0&&v(G+1)===":"){let Y=G+2;while(Y<j&&v(Y)!==";"){if(be(Y)==="=>"){M=Y+2;break}Y=(k.get(Y)??Y)+1}}}else if(b[T]?.kind==="word"&&be(T+1)==="=>")M=T+3;else if(v(T)==="function"){let G=T+1;while(G<j&&v(G)!=="(")G=(k.get(G)??G)+1;let Y=k.get(G);if(Y===void 0)return;M=Y+1;let re=v(M)===":"?M+1:void 0;while(M<j){if(v(M)==="{"&&(re===void 0||!os(e.slice(b[re].start,b[M].start))))break;M=(k.get(M)??M)+1}}if(M<0||M>=j)return;if(v(M)==="{")return{start:T,end:(k.get(M)??j-1)+1};let _=M;while(_<j&&![",",";",")","]","}"].includes(v(_)))_=(k.get(_)??_)+1;return{start:T,end:_}}function Je(T,j,M=!0){for(let _=T;_<j;_++){let G=B.get(_);if(G!==void 0){_=Math.min(G,j)-1;continue}let Y=M?xe(_,j):void 0;if(Y){let Ae=Y.end;while(v(Ae)===")")Ae++;if(v(Ae)==="("||v(Ae)==="."&&["call","apply"].includes(v(Ae+1))&&v(Ae+2)==="(")Je(Y.start,Y.end,!1);_=Y.end-1;continue}let re=ke(_);if(re)re.binding.flow=void 0,re.binding.unresolved=!0}}function hi(T){let j=!1;while(X<b.length&&b[X].start<T){let M=v(X);if(["if","else","for","while","do","switch","try","catch","finally","with"].includes(M))j=!0;if(M===";")j=!1;if(M==="("||M==="{"||M==="["){let Y=k.get(X)??X+1;while(Y<b.length&&b[Y].start>=T)Y--;if(Je(X+1,Y),X=Y+1,M==="{")j=!1;continue}let _=ve(X);if(_){let Y=X+2,re=Y,Ae=[];while(re<b.length&&b[re].start<T){let ct=v(re);if(Ae.length===0&&(ct===";"||re>Y&&/[\r\n]/.test(e.slice(b[re-1].end,b[re].start))&&(ve(re)||["if","for","while","switch","try","do","return","throw"].includes(ct))))break;if(ct==="("||ct==="{"||ct==="[")Ae.push(ct==="("?")":ct==="{"?"}":"]");else if(ct===Ae.at(-1))Ae.pop();re++}let Ot=re>Y?e.slice(b[Y].start,b[re-1].end):"";Je(Y,re);let Ut=ae(Ot);_.flow=!j&&Ut.type?_.declared?$c(_.declared,Ut.type):Ut.type:void 0,_.unresolved=j||Ut.unresolved||!_.flow,X=re;continue}let G=ke(X);if(G)G.binding.flow=void 0,G.binding.unresolved=!0;X++}}for(let T of o){hi(T.start??0);let j=X;while(X<b.length&&b[X].start<(T.end??0))X++;if(T.kind!=="variable")continue;if(T.initializerStart!==void 0){let Ot=j;while(Ot<X&&b[Ot].start<T.initializerStart)Ot++;Je(Ot,X)}let M=n.get(T.name);if(!M.active)continue;let _=typeof T.value==="string"?T.value:"";if(!_){M.flow=M.declared;continue}let G=ae(_),Y=hn(_),re=Y?n.get(Y):void 0,Ae=c.get(T);if(Ae)T.inferredType=Ae,T.text=`${T.isExported?"export ":""}declare ${T.modifiers?.[0]??"const"} ${T.name}: ${Ae};`;else if(!T.typeAnnotation&&T.modifiers?.[0]==="const"&&Y&&Y!==T.name&&re){if(G.unresolved)T.inferenceError="DTSX_UNSUPPORTED_VALUE_FLOW";else if(G.type)T.inferredType=re.declared&&$s(re.declared,G.type)?`typeof ${Y}`:G.type,T.text=`${T.isExported?"export ":""}declare const ${T.name}: ${T.inferredType};`}if(T.typeAnnotation)M.flow=G.type?$c(T.typeAnnotation,G.type)??T.typeAnnotation:T.typeAnnotation;else if(T.inferredType)M.declared=T.inferredType,M.flow=T.inferredType;else{let Ot=T.modifiers?.[0]==="const",Ut=_.trim().startsWith("{")||_.trim().startsWith("["),ct=Te(_,Ot&&!Ut);M.declared=ct==="unknown"?void 0:ct,M.flow=M.declared}M.unresolved=G.unresolved}}var Sc=me(()=>{hr();ht();pr();Ei();vr()});function vp(e,t,i,r,n=""){let o=new Map,s={start:0,end:e.length,header:0,name:"",children:[],results:new Map},l=ce(e),a=[],f=[],u=[],d=new Map;for(let c=0;c<l.length;c++){let C=l[c];if(C.kind!=="punctuation")continue;let b=e.slice(C.start,C.end);if(b==="(")u.push(c);else if(b===")"){let v=u.pop();if(v!==void 0)d.set(c,v)}else if(b==="{")f.push(c);else if(b==="}"){let v=f.pop();if(v===void 0)continue;let k=l[v].start,W=v-1,A=W>=0?e.slice(l[W].start,l[W].end):"";if(A===")"){let R=d.get(W);if(R!==void 0&&R>0&&["if","for","while","switch","catch","with"].includes(e.slice(l[R-1].start,l[R-1].end)))k=l[R-1].start}else if(["else","try","finally","do"].includes(A))k=l[W].start;a.push({open:l[v].start,close:C.start,header:k})}}let h=0,p=(c,C=new Set)=>{let b=new Set(C),v=ce(e.slice(c.start,c.end)),k=0;for(let z=0;z+1<v.length;z++){let X=e.slice(c.start+v[z].start,c.start+v[z].end);if(X==="{")k++;else if(X==="}")k--;else if(!k&&["type","interface"].includes(X))b.add(e.slice(c.start+v[z+1].start,c.start+v[z+1].end))}let W="",A=c.start,R=[...c.results].map(([z,X])=>({type:z,name:X}));for(let z of c.children.sort((X,ae)=>X.header-ae.header)){let X=p(z,b);W+=e.slice(A,z.header)+`
105
105
  declare namespace ${z.name} {
106
106
  ${X.text}
107
107
  }
108
108
  `,A=z.end+1;for(let ae of X.exports)R.push({type:`${z.name}.${ae.name}`,name:ae.name})}W+=`${e.slice(A,c.end)}
109
109
  ;
110
110
  ${R.map((z)=>`export type ${z.name} = ${z.type};`).join(`
111
- `)}`;let V=kn(W,t,!1);for(let z of R)b.add(z.name);let B=n?Es(n).map((z,X)=>[z,`${m}_capture_${X}`]):[],O=V.map((z)=>n&&["type","interface"].includes(z.kind)?wp(z,n,B,b):(z.kind==="variable"?Di(z,!1):z.text).replace(/^export\s+/,"").replace(/^declare\s+/,"")).join(`
112
- `);return{declarations:V,text:O,exports:R}},m;return{resolve(c,v){m??=i();let b=s;for(let k of a.filter((W)=>W.open<v&&v<W.close).sort((W,A)=>W.open-A.open)){let W=b.children.find((A)=>A.start===k.open+1);if(!W)W={start:k.open+1,end:k.close,header:k.header,name:`${m}_scope_${h++}`,children:[],results:new Map},b.children.push(W);b=W}let C=b.results.get(c);if(!C)C=`${m}_result_${o.size}`,b.results.set(c,C),o.set(C,c);return`${m}.${C}`},finish(c){if(!m)return c;let v=p(s),b=v.declarations,C=new Set(o.keys());if(b.every((W)=>C.has(W.name))){let W=new Map(o),A=ce(c),R="",V=0;for(let B=0;B+2<A.length;B++){if(c.slice(A[B].start,A[B].end)!==m||c.slice(A[B+1].start,A[B+1].end)!==".")continue;let O=W.get(c.slice(A[B+2].start,A[B+2].end));if(!O)continue;R+=c.slice(V,A[B].start)+`(${O})`,V=A[B+2].end,B+=2}return R+c.slice(V)}if(n){let W=Es(n).join(", "),A=ce(c),R="",V=0;for(let B=0;B+2<A.length;B++){if(c.slice(A[B].start,A[B].end)!==m||c.slice(A[B+1].start,A[B+1].end)!=="."||!C.has(c.slice(A[B+2].start,A[B+2].end)))continue;R+=`${c.slice(V,A[B+2].end)}<${W}>`,V=A[B+2].end,B+=2}c=R+c.slice(V)}let k=v.text;return r({kind:"module",name:m,text:`declare namespace ${m} {
111
+ `)}`;let V=On(W,t,!1);for(let z of R)b.add(z.name);let B=n?xs(n).map((z,X)=>[z,`${m}_capture_${X}`]):[],O=V.map((z)=>n&&["type","interface"].includes(z.kind)?bp(z,n,B,b):(z.kind==="variable"?Ii(z,!1):z.text).replace(/^export\s+/,"").replace(/^declare\s+/,"")).join(`
112
+ `);return{declarations:V,text:O,exports:R}},m;return{resolve(c,C){m??=i();let b=s;for(let k of a.filter((W)=>W.open<C&&C<W.close).sort((W,A)=>W.open-A.open)){let W=b.children.find((A)=>A.start===k.open+1);if(!W)W={start:k.open+1,end:k.close,header:k.header,name:`${m}_scope_${h++}`,children:[],results:new Map},b.children.push(W);b=W}let v=b.results.get(c);if(!v)v=`${m}_result_${o.size}`,b.results.set(c,v),o.set(v,c);return`${m}.${v}`},finish(c){if(!m)return c;let C=p(s),b=C.declarations,v=new Set(o.keys());if(b.every((W)=>v.has(W.name))){let W=new Map(o),A=ce(c),R="",V=0;for(let B=0;B+2<A.length;B++){if(c.slice(A[B].start,A[B].end)!==m||c.slice(A[B+1].start,A[B+1].end)!==".")continue;let O=W.get(c.slice(A[B+2].start,A[B+2].end));if(!O)continue;R+=c.slice(V,A[B].start)+`(${O})`,V=A[B+2].end,B+=2}return R+c.slice(V)}if(n){let W=xs(n).join(", "),A=ce(c),R="",V=0;for(let B=0;B+2<A.length;B++){if(c.slice(A[B].start,A[B].end)!==m||c.slice(A[B+1].start,A[B+1].end)!=="."||!v.has(c.slice(A[B+2].start,A[B+2].end)))continue;R+=`${c.slice(V,A[B+2].end)}<${W}>`,V=A[B+2].end,B+=2}c=R+c.slice(V)}let k=C.text;return r({kind:"module",name:m,text:`declare namespace ${m} {
113
113
  ${k}
114
- }`,moduleForm:"namespace",isExported:!1}),c}}}function Es(e){let t=ce(e),i=[],r=0,n=0,o=!1;for(let s of t){let l=e.slice(s.start,s.end);if(l==="<"){if(r++,r===1)o=!0}else if(l===">"&&e[s.start-1]!=="=")r--;else if(["(","[","{"].includes(l))n++;else if([")","]","}"].includes(l))n--;else if(l===","&&r===1&&!n)o=!0;else if(o&&s.kind==="word"&&!["const","in","out"].includes(l))i.push(l),o=!1}return i}function wp(e,t,i,r){let n=new Set(Es(e.generics||"")),o=(p,m,c)=>{let v=ce(p),b="",C=0;for(let k=0;k<v.length;k++){let W=v[k],A=p.slice(W.start,W.end),R=v[k+1]&&p.slice(v[k+1].start,v[k+1].end),V=v[k+2]&&p.slice(v[k+2].start,v[k+2].end),B=v[k-1]&&p.slice(v[k-1].start,v[k-1].end);if(W.kind!=="word"||R===":"||R==="?"&&V===":")continue;let O=!c.has(A)&&B!=="."&&i.find(([z])=>z===A)?.[1];if(O)b+=p.slice(C,W.start)+O,C=W.end;else if(m&&r.has(A)&&!c.has(A)){let z=i.map(([,X])=>X).join(", ");b+=`${p.slice(C,W.end)}<${z}${R==="<"?", ":">"}`,C=R==="<"?v[++k].end:W.end}}return b+p.slice(C)},s=ce(e.text),l=s.findIndex((p)=>["type","interface"].includes(e.text.slice(p.start,p.end))),a=s[l+1],f=e.generics||"",u=f?e.text.indexOf(f,a.end)+f.length:a.end,d=o(Cp(t),!1,new Set),h=f?`, ${o(f.slice(1,-1),!0,n)}`:"";return`${e.text.slice(0,a.end)}<${d}${h}>${o(e.text.slice(u),!0,n)}`.replace(/^export\s+/,"").replace(/^declare\s+/,"")}function Cp(e){let t=e.slice(1,-1),i=ce(t),r=0,n=0,o=!1,s="";for(let l=0;l<i.length;l++){let a=i[l],f=t.slice(a.start,a.end);if(["(","[","{","<"].includes(f))r++;else if([")","]","}"].includes(f)||f===">"&&t[a.start-1]!=="=")r--;else if(!r&&f==="const")s+=t.slice(n,a.start),n=a.end;else if(!r&&f==="="&&t.slice(i[l+1]?.start,i[l+1]?.end)!==">")s+=t.slice(n,a.start),o=!0;else if(!r&&f===","&&o)n=a.start,o=!1}return s+(o?"":t.slice(n))}function Ze(e){return e===Qe||e===et||e===Ne||e===Ge}function $p(e){let t=!0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);if(r===_t){if(t)return!1;t=!0}else if(t){if(!dt(r))return!1;t=!1}else if(!He(r))return!1}return e.length>0&&!t}function br(e,t,i){let r=t+1;while(r<e.length){let n=e.charCodeAt(r);if(n===Ct){r+=2;continue}if(r++,n===i)break}return r}function Ep(e){if(e==="any"||e==="object"||e==="unknown")return!0;if(e.startsWith("Record<")||e.startsWith("Array<"))return!0;return e.charCodeAt(0)===ne&&e.includes("[")&&e.includes("]:")}function $r(e,t,i=!0){return Ss(e,t,i,!0)}function kn(e,t,i=!0,r){return Ss(e,t,i,!1,!1,r)}function xs(e,t,i=!0){return Ss(e,t,i,!0,!0)}function Ss(e,t,i,r,n=!1,o){let s=e,l=i,a=r,f=s.length,u=Ri(s),d=[],h=new Map,p=new Map,m=new Set,c=0,v=0,b=[];function C(g){let w=/^this\.([\w$]+)$/.exec(g);if(w){let D=b.at(-1);return D?.fields.get(`${D.isStatic?"static:":""}${w[1]}`)}let y=/^([\w$]+)\s*\(/.exec(g);if(!y||!g.endsWith(")"))return;let E=ce(g),x=0;for(let D=1;D<E.length;D++){let N=g.slice(E[D].start,E[D].end);if(N==="(")x++;else if(N===")"&&--x===0&&D!==E.length-1)return}let S=[...d,...h.values()].filter((D)=>D.kind==="function"&&D.name===y[1]);if(S.length!==1||S[0].generics||cn(s,y[1])!==1)return;return S[0].returnType}function k(g){let w=g.trim(),y=C(w);if(y)return y;if(!w.startsWith("class"))return;let E=ce(w);if(E[0]?.kind!=="word"||w.slice(E[0].start,E[0].end)!=="class")return;let x;do x=`__dtsx_class_${v++}`;while(s.includes(x));let S=E[1],D=S?w.slice(S.start,S.end):"",N=S?.kind==="word"&&!["extends","implements"].includes(D),F=N?D:`${x}_value`,P=N?`export ${w}`:`export class ${F} ${w.slice(5)}`,L=kn(P,t,l),J=L.find((Z)=>Z.kind==="class");if(!J)throw Error("Cannot extract the class expression declaration");if(ce(P.slice(J.end??P.length)).some((Z)=>P.slice((J.end??0)+Z.start,(J.end??0)+Z.end)!==";"))return;let q=L.map((Z)=>Z.text.replace(/^export\s+/,"").replace(/^declare\s+/,"")).join(`
114
+ }`,moduleForm:"namespace",isExported:!1}),c}}}function xs(e){let t=ce(e),i=[],r=0,n=0,o=!1;for(let s of t){let l=e.slice(s.start,s.end);if(l==="<"){if(r++,r===1)o=!0}else if(l===">"&&e[s.start-1]!=="=")r--;else if(["(","[","{"].includes(l))n++;else if([")","]","}"].includes(l))n--;else if(l===","&&r===1&&!n)o=!0;else if(o&&s.kind==="word"&&!["const","in","out"].includes(l))i.push(l),o=!1}return i}function bp(e,t,i,r){let n=new Set(xs(e.generics||"")),o=(p,m,c)=>{let C=ce(p),b="",v=0;for(let k=0;k<C.length;k++){let W=C[k],A=p.slice(W.start,W.end),R=C[k+1]&&p.slice(C[k+1].start,C[k+1].end),V=C[k+2]&&p.slice(C[k+2].start,C[k+2].end),B=C[k-1]&&p.slice(C[k-1].start,C[k-1].end);if(W.kind!=="word"||R===":"||R==="?"&&V===":")continue;let O=!c.has(A)&&B!=="."&&i.find(([z])=>z===A)?.[1];if(O)b+=p.slice(v,W.start)+O,v=W.end;else if(m&&r.has(A)&&!c.has(A)){let z=i.map(([,X])=>X).join(", ");b+=`${p.slice(v,W.end)}<${z}${R==="<"?", ":">"}`,v=R==="<"?C[++k].end:W.end}}return b+p.slice(v)},s=ce(e.text),l=s.findIndex((p)=>["type","interface"].includes(e.text.slice(p.start,p.end))),a=s[l+1],f=e.generics||"",u=f?e.text.indexOf(f,a.end)+f.length:a.end,d=o($p(t),!1,new Set),h=f?`, ${o(f.slice(1,-1),!0,n)}`:"";return`${e.text.slice(0,a.end)}<${d}${h}>${o(e.text.slice(u),!0,n)}`.replace(/^export\s+/,"").replace(/^declare\s+/,"")}function $p(e){let t=e.slice(1,-1),i=ce(t),r=0,n=0,o=!1,s="";for(let l=0;l<i.length;l++){let a=i[l],f=t.slice(a.start,a.end);if(["(","[","{","<"].includes(f))r++;else if([")","]","}"].includes(f)||f===">"&&t[a.start-1]!=="=")r--;else if(!r&&f==="const")s+=t.slice(n,a.start),n=a.end;else if(!r&&f==="="&&t.slice(i[l+1]?.start,i[l+1]?.end)!==">")s+=t.slice(n,a.start),o=!0;else if(!r&&f===","&&o)n=a.start,o=!1}return s+(o?"":t.slice(n))}function Ze(e){return e===Qe||e===et||e===Ne||e===Ge}function Sp(e){let t=!0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);if(r===_t){if(t)return!1;t=!0}else if(t){if(!dt(r))return!1;t=!1}else if(!He(r))return!1}return e.length>0&&!t}function br(e,t,i){let r=t+1;while(r<e.length){let n=e.charCodeAt(r);if(n===Ct){r+=2;continue}if(r++,n===i)break}return r}function Ap(e){if(e==="any"||e==="object"||e==="unknown")return!0;if(e.startsWith("Record<")||e.startsWith("Array<"))return!0;return e.charCodeAt(0)===ne&&e.includes("[")&&e.includes("]:")}function $r(e,t,i=!0){return As(e,t,i,!0)}function On(e,t,i=!0,r){return As(e,t,i,!1,!1,r)}function Ss(e,t,i=!0){return As(e,t,i,!0,!0)}function As(e,t,i,r,n=!1,o){let s=e,l=i,a=r,f=s.length,u=Pi(s),d=[],h=new Map,p=new Map,m=new Set,c=0,C=0,b=[];function v(g){let w=/^this\.([\w$]+)$/.exec(g);if(w){let D=b.at(-1);return D?.fields.get(`${D.isStatic?"static:":""}${w[1]}`)}let y=/^([\w$]+)\s*\(/.exec(g);if(!y||!g.endsWith(")"))return;let E=ce(g),x=0;for(let D=1;D<E.length;D++){let N=g.slice(E[D].start,E[D].end);if(N==="(")x++;else if(N===")"&&--x===0&&D!==E.length-1)return}let S=[...d,...h.values()].filter((D)=>D.kind==="function"&&D.name===y[1]);if(S.length!==1||S[0].generics||cn(s,y[1])!==1)return;return S[0].returnType}function k(g){let w=g.trim(),y=v(w);if(y)return y;if(!w.startsWith("class"))return;let E=ce(w);if(E[0]?.kind!=="word"||w.slice(E[0].start,E[0].end)!=="class")return;let x;do x=`__dtsx_class_${C++}`;while(s.includes(x));let S=E[1],D=S?w.slice(S.start,S.end):"",N=S?.kind==="word"&&!["extends","implements"].includes(D),F=N?D:`${x}_value`,P=N?`export ${w}`:`export class ${F} ${w.slice(5)}`,L=On(P,t,l),J=L.find((Z)=>Z.kind==="class");if(!J)throw Error("Cannot extract the class expression declaration");if(ce(P.slice(J.end??P.length)).some((Z)=>P.slice((J.end??0)+Z.start,(J.end??0)+Z.end)!==";"))return;let q=L.map((Z)=>Z.text.replace(/^export\s+/,"").replace(/^declare\s+/,"")).join(`
115
115
  `);return h.set(x,{kind:"module",name:x,text:`declare namespace ${x} {
116
116
  ${q}
117
- }`,moduleForm:"namespace",isExported:!1,start:c,end:c}),`typeof ${x}.${F}`}function W(g,w){let y=/^this\.([\w$]+)$/.exec(g);if(y)return b.at(-1)?.fields.get(`${w?"static:":""}${y[1]}`);return k(g)}function A(g){let w=p.get(g.name);if(w)w.push(g);else p.set(g.name,[g]);h.set(g.name,g)}if(c<f&&s.charCodeAt(c)===65279)c++;function R(g,w){if(g<w){let y=s.charCodeAt(g),E=s.charCodeAt(w-1);if(y!==Qe&&y!==et&&y!==Ne&&y!==Ge&&E!==Qe&&E!==et&&E!==Ne&&E!==Ge)return s.slice(g,w)}while(g<w&&Ze(s.charCodeAt(g)))g++;while(w>g&&Ze(s.charCodeAt(w-1)))w--;return s.slice(g,w)}let V=/[\r\n]/g;function B(g){return V.lastIndex=g,V.exec(s)?.index??f}function O(){if(c>=f)return;let g=s.charCodeAt(c);if(g!==Qe&&g!==et&&g!==Ne&&g!==Ge&&g!==de)return;while(c<f){let w=s.charCodeAt(c);if(w===Qe||w===et||w===Ne||w===Ge){c++;continue}if(w===de&&c+1<f){let y=s.charCodeAt(c+1);if(y===de){c=B(c+2);continue}if(y===We){let E=s.indexOf("*/",c+2);c=E===-1?f:E+2;continue}}break}}function z(g){if(g.indexOf("//")===-1&&g.indexOf("/*")===-1)return g;let w=0,y=0;while(y<g.length){let E=g.charCodeAt(y);if(E===Re||E===Ie||E===Ye){y=br(g,y,E),w=y;continue}if(E===Ct){y+=2,w=Math.min(y,g.length);continue}if(E===de&&g.charCodeAt(y+1)===de){while(y<g.length&&g.charCodeAt(y)!==Ne&&g.charCodeAt(y)!==Ge)y++;continue}if(E===de&&g.charCodeAt(y+1)===We){let x=g.indexOf("*/",y+2);y=x===-1?g.length:x+2;continue}if(y++,E>32)w=y}return w<g.length?g.slice(0,w).trimEnd():g}function X(g){let w=g.length,y=0,E=w;for(let x=0;x<w;x++){let S=g.charCodeAt(x);if(y){if(S===Ct){x++;continue}if(S===y)y=0;continue}if(S===Re||S===Ie||S===Ye){y=S;continue}if(S===de&&x+1<w){let D=g.charCodeAt(x+1);if(D===de){E=x;while(E>0&&(g.charCodeAt(E-1)===Qe||g.charCodeAt(E-1)===et))E--;return g.slice(0,E)}if(D===We){let N=g.indexOf("*/",x+2);if(N!==-1){g=`${g.slice(0,x)} ${g.slice(N+2)}`,x--;continue}}}}E=w;while(E>0&&(g.charCodeAt(E-1)===Qe||g.charCodeAt(E-1)===et||g.charCodeAt(E-1)===Ge))E--;return E<w?g.slice(0,E):g}function ae(g){c++;let w=g===Re?"'":'"';while(c<f){let y=s.indexOf(w,c);if(y===-1){c=f;return}let E=0,x=y-1;while(x>=0&&s.charCodeAt(x)===Ct)E++,x--;if(E%2===0){c=y+1;return}c=y+1}}function be(){c++;let g=[];while(c<f){let w=s.charCodeAt(c);if(g.length===0){if(w===Ct){c+=2;continue}if(w===Ye){c++;return}if(w===bp&&c+1<f&&s.charCodeAt(c+1)===ne){c+=2,g.push(0);continue}c++;continue}if(w===Re||w===Ie){ae(w);continue}if(w===Ye){be();continue}if(w===de&&c+1<f){let y=s.charCodeAt(c+1);if(y===de){c=B(c+2);continue}if(y===We){let E=s.indexOf("*/",c+2);c=E===-1?f:E+2;continue}if(we()){ge();continue}c++;continue}if(w===ne){g[g.length-1]++,c++;continue}if(w===he){let y=g[g.length-1];if(y===0){g.pop(),c++;continue}g[g.length-1]=y-1,c++;continue}c++}}let ke=!1;function ve(){ke=!1;let g=s.charCodeAt(c);if(g===Re||g===Ie)return ae(g),!0;if(g===Ye)return be(),!0;if(g===de&&c+1<f){let w=s.charCodeAt(c+1);if(w===de)return c=B(c+2),!0;if(w===We){let y=s.indexOf("*/",c+2);return ke=B(c+2)<(y===-1?f:y),c=y===-1?f:y+2,!0}if(we())return ge(),!0}return!1}function we(){return an(s,c)}function ge(){c=ur(s,c)}function ie(){let g=c;while(c<f&&He(s.charCodeAt(c)))c++;return s.slice(g,c)}function I(g){if(c+g.length>f)return!1;for(let w=0;w<g.length;w++)if(s.charCodeAt(c+w)!==g.charCodeAt(w))return!1;if(c+g.length<f&&He(s.charCodeAt(c+g.length)))return!1;return!0}function K(g){let w=c+g;while(w<f){let y=s.charCodeAt(w);if(y===Qe||y===et||y===Ne||y===Ge){w++;continue}return y!==_t&&y!==je}return!1}function Q(){if(!ke)return!1;let g=c;O();let w=c>=f||oe()||s.charCodeAt(c)===he;return c=g,w}function oe(){if(c>=f)return!1;switch(s.charCodeAt(c)){case 101:return I("export")||I("enum");case 105:return I("import")||I("interface");case 102:return I("function");case 99:return I("class")||I("const");case 116:return I("type");case 108:return I("let");case 118:return I("var");case 100:return I("declare")||I("default");case 109:return I("module");case 110:return I("namespace");case 97:return I("abstract")||I("async");default:return!1}}function ue(){let g=s.charCodeAt(c);if(g!==Ne&&g!==Ge)return!1;let w=c;if(c++,g===Ge&&c<f&&s.charCodeAt(c)===Ne)c++;while(c<f){let E=s.charCodeAt(c);if(E===Qe||E===et||E===Ge||E===Ne){c++;continue}if(E===de&&c+1<f){let x=s.charCodeAt(c+1);if(x===de){c=B(c+2);continue}if(x===We){let S=s.indexOf("*/",c+2);c=S===-1?f:S+2;continue}}break}let y=c>=f||oe()||s.charCodeAt(c)===he;return c=w,y}function fe(g){let w=g-1;while(w>=0){let F=s.charCodeAt(w);if(F===Qe||F===et||F===Ge||F===Ne){w--;continue}break}if(w<0)return!0;let y=s[w];if("+-*/%=<>&|^!~?:,.([{".includes(y))return!0;let E=w;while(E>0&&s.charCodeAt(E-1)!==Ne)E--;let x=s.slice(E,w+1),S=x.lastIndexOf("<");if(S!==-1&&/^<[A-Za-z]/.test(x.slice(S))&&!x.slice(S).includes(">"))return!0;let D=w;while(D>=0&&/[a-z]/i.test(s[D]))D--;let N=s.slice(D+1,w+1);return["as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","return","yield","void"].includes(N)}function pe(){let g=s.charCodeAt(c);if(g!==Ne&&g!==Ge)return!1;if(fe(c))return!1;let w=c;c++;while(c<f){let S=s.charCodeAt(c);if(S===Qe||S===et||S===Ge||S===Ne){c++;continue}if(S===de&&c+1<f){let D=s.charCodeAt(c+1);if(D===de){c=B(c+2);continue}if(D===We){let N=s.indexOf("*/",c+2);c=N===-1?f:N+2;continue}}break}let y=c<f?s[c]:"",E=s.slice(c,c+2),x=y==="."||y==="?"||y===":"||y===")"||y==="]"||y==="}"||y===","||y==="+"||y==="-"||y==="*"||y==="/"||y==="%"||y==="<"||y===">"||y==="="||y==="&"||y==="|"||y==="^"||y==="`"||E==="=>"||I("as")||I("satisfies")||I("instanceof")||I("in");return c=w,!x}function Ee(){let g=s.charCodeAt(c);if(g!==Ne&&g!==Ge)return!1;if(fe(c))return!1;let w=c;c++;while(c<f){let x=s.charCodeAt(c);if(x===Qe||x===et||x===Ge||x===Ne){c++;continue}if(x===de&&c+1<f){let S=s.charCodeAt(c+1);if(S===de){c=B(c+2);continue}if(S===We){let D=s.indexOf("*/",c+2);c=D===-1?f:D+2;continue}}break}let y=c<f?s[c]:"",E=y==="|"||y==="&"||y==="["||y==="."||y==="?"||y===":"||y===">"||y===")"||y===","||I("extends");return c=w,!E}function xe(){let g=s.charCodeAt(c);if(g!==Ne&&g!==Ge)return!1;let w=c;if(c++,g===Ge&&c<f&&s.charCodeAt(c)===Ne)c++;while(c<f){let E=s.charCodeAt(c);if(E===Qe||E===et||E===Ge||E===Ne){c++;continue}if(E===de&&c+1<f&&s.charCodeAt(c+1)===de){c=B(c+2);continue}break}if(c>=f)return c=w,!0;let y=s.charCodeAt(c);if(y===124||y===38||y===_t||y===An||y===At)return c=w,!1;if(I("extends")||I("keyof")||I("typeof")||I("infer")||I("is")||I("as")||I("in"))return c=w,!1;return c=w,!0}let Je=/[{}'"`\/]/g,hi=/[()'"`\/]/g,T=/[[\]'"`\/]/g,j=/[<>'"`\/]/g;function M(g,w){let y=1;c++;let E=g===ne?Je:g===$e?hi:g===Ve?T:j;E.lastIndex=c;let x;while((x=E.exec(s))!==null){let S=x.index,D=s.charCodeAt(S);if(D===Re||D===Ie){c=S,ae(D),E.lastIndex=c;continue}if(D===Ye){c=S,be(),E.lastIndex=c;continue}if(D===de){if(c=S,ve()){E.lastIndex=c;continue}E.lastIndex=S+1;continue}if(D===g)y++;else if(D===w){if(w===De&&S>0&&s.charCodeAt(S-1)===je){E.lastIndex=S+1;continue}if(y--,y===0)return c=S+1,c}E.lastIndex=S+1}return c=f,c}function _(){return c>0&&s.charCodeAt(c-1)===je}function G(){return c+1<f&&s.charCodeAt(c+1)===De}let Y=/[<{};'"`\/\n\r()[\]]/g;function re(g=!1){let w=0,y=0,E=0,x=0,S=s.charCodeAt(c)===ne;Y.lastIndex=c;let D;while((D=Y.exec(s))!==null){let N=D.index,F=s.charCodeAt(N);if(F===Re||F===Ie){c=N,ae(F),Y.lastIndex=c;continue}if(F===Ye){c=N,be(),Y.lastIndex=c;continue}if(F===de){if(N>0&&s.charCodeAt(N-1)===Fe){Y.lastIndex=N+1;continue}if(c=N,ve()){if(w===0&&y===0&&E===0&&x===0&&Q())return;Y.lastIndex=c;continue}Y.lastIndex=N+1;continue}if(F===Fe){let P=qa(N);if(P!==null)x=Math.max(0,x+P);Y.lastIndex=N+1;continue}if(F===$e){y++,Y.lastIndex=N+1;continue}if(F===Me){y--,Y.lastIndex=N+1;continue}if(F===Ve){E++,Y.lastIndex=N+1;continue}if(F===qe){E--,Y.lastIndex=N+1;continue}if(F===ne){w++,Y.lastIndex=N+1;continue}if(F===he){let P=w>0;if(!P&&g&&y===0&&E===0&&x===0){c=N;return}if(P)w--;if((!P||S)&&w===0&&y===0&&E===0&&x===0){c=N+1;return}if(P&&w===0&&y===0&&E===0&&x===0){c=N+1;let L=c;O();let J=oe();if(c=L,J)return}Y.lastIndex=N+1;continue}if(F===Ce&&w===0&&y===0&&E===0&&x===0){c=N+1;return}if((F===Ne||F===Ge)&&w===0&&y===0&&E===0&&x===0){if(c=N,ue())return}Y.lastIndex=N+1}c=f}function Ae(){c++;while(c<f&&(s.charCodeAt(c)===Qe||s.charCodeAt(c)===et))c++;let g=s.indexOf(`
117
+ }`,moduleForm:"namespace",isExported:!1,start:c,end:c}),`typeof ${x}.${F}`}function W(g,w){let y=/^this\.([\w$]+)$/.exec(g);if(y)return b.at(-1)?.fields.get(`${w?"static:":""}${y[1]}`);return k(g)}function A(g){let w=p.get(g.name);if(w)w.push(g);else p.set(g.name,[g]);h.set(g.name,g)}if(c<f&&s.charCodeAt(c)===65279)c++;function R(g,w){if(g<w){let y=s.charCodeAt(g),E=s.charCodeAt(w-1);if(y!==Qe&&y!==et&&y!==Ne&&y!==Ge&&E!==Qe&&E!==et&&E!==Ne&&E!==Ge)return s.slice(g,w)}while(g<w&&Ze(s.charCodeAt(g)))g++;while(w>g&&Ze(s.charCodeAt(w-1)))w--;return s.slice(g,w)}let V=/[\r\n]/g;function B(g){return V.lastIndex=g,V.exec(s)?.index??f}function O(){if(c>=f)return;let g=s.charCodeAt(c);if(g!==Qe&&g!==et&&g!==Ne&&g!==Ge&&g!==de)return;while(c<f){let w=s.charCodeAt(c);if(w===Qe||w===et||w===Ne||w===Ge){c++;continue}if(w===de&&c+1<f){let y=s.charCodeAt(c+1);if(y===de){c=B(c+2);continue}if(y===We){let E=s.indexOf("*/",c+2);c=E===-1?f:E+2;continue}}break}}function z(g){if(g.indexOf("//")===-1&&g.indexOf("/*")===-1)return g;let w=0,y=0;while(y<g.length){let E=g.charCodeAt(y);if(E===Re||E===Ie||E===Ye){y=br(g,y,E),w=y;continue}if(E===Ct){y+=2,w=Math.min(y,g.length);continue}if(E===de&&g.charCodeAt(y+1)===de){while(y<g.length&&g.charCodeAt(y)!==Ne&&g.charCodeAt(y)!==Ge)y++;continue}if(E===de&&g.charCodeAt(y+1)===We){let x=g.indexOf("*/",y+2);y=x===-1?g.length:x+2;continue}if(y++,E>32)w=y}return w<g.length?g.slice(0,w).trimEnd():g}function X(g){let w=g.length,y=0,E=w;for(let x=0;x<w;x++){let S=g.charCodeAt(x);if(y){if(S===Ct){x++;continue}if(S===y)y=0;continue}if(S===Re||S===Ie||S===Ye){y=S;continue}if(S===de&&x+1<w){let D=g.charCodeAt(x+1);if(D===de){E=x;while(E>0&&(g.charCodeAt(E-1)===Qe||g.charCodeAt(E-1)===et))E--;return g.slice(0,E)}if(D===We){let N=g.indexOf("*/",x+2);if(N!==-1){g=`${g.slice(0,x)} ${g.slice(N+2)}`,x--;continue}}}}E=w;while(E>0&&(g.charCodeAt(E-1)===Qe||g.charCodeAt(E-1)===et||g.charCodeAt(E-1)===Ge))E--;return E<w?g.slice(0,E):g}function ae(g){c++;let w=g===Re?"'":'"';while(c<f){let y=s.indexOf(w,c);if(y===-1){c=f;return}let E=0,x=y-1;while(x>=0&&s.charCodeAt(x)===Ct)E++,x--;if(E%2===0){c=y+1;return}c=y+1}}function be(){c++;let g=[];while(c<f){let w=s.charCodeAt(c);if(g.length===0){if(w===Ct){c+=2;continue}if(w===Ye){c++;return}if(w===xp&&c+1<f&&s.charCodeAt(c+1)===ne){c+=2,g.push(0);continue}c++;continue}if(w===Re||w===Ie){ae(w);continue}if(w===Ye){be();continue}if(w===de&&c+1<f){let y=s.charCodeAt(c+1);if(y===de){c=B(c+2);continue}if(y===We){let E=s.indexOf("*/",c+2);c=E===-1?f:E+2;continue}if(we()){ge();continue}c++;continue}if(w===ne){g[g.length-1]++,c++;continue}if(w===he){let y=g[g.length-1];if(y===0){g.pop(),c++;continue}g[g.length-1]=y-1,c++;continue}c++}}let ke=!1;function ve(){ke=!1;let g=s.charCodeAt(c);if(g===Re||g===Ie)return ae(g),!0;if(g===Ye)return be(),!0;if(g===de&&c+1<f){let w=s.charCodeAt(c+1);if(w===de)return c=B(c+2),!0;if(w===We){let y=s.indexOf("*/",c+2);return ke=B(c+2)<(y===-1?f:y),c=y===-1?f:y+2,!0}if(we())return ge(),!0}return!1}function we(){return an(s,c)}function ge(){c=dr(s,c)}function ie(){let g=c;while(c<f&&He(s.charCodeAt(c)))c++;return s.slice(g,c)}function I(g){if(c+g.length>f)return!1;for(let w=0;w<g.length;w++)if(s.charCodeAt(c+w)!==g.charCodeAt(w))return!1;if(c+g.length<f&&He(s.charCodeAt(c+g.length)))return!1;return!0}function K(g){let w=c+g;while(w<f){let y=s.charCodeAt(w);if(y===Qe||y===et||y===Ne||y===Ge){w++;continue}return y!==_t&&y!==je}return!1}function Q(){if(!ke)return!1;let g=c;O();let w=c>=f||oe()||s.charCodeAt(c)===he;return c=g,w}function oe(){if(c>=f)return!1;switch(s.charCodeAt(c)){case 101:return I("export")||I("enum");case 105:return I("import")||I("interface");case 102:return I("function");case 99:return I("class")||I("const");case 116:return I("type");case 108:return I("let");case 118:return I("var");case 100:return I("declare")||I("default");case 109:return I("module");case 110:return I("namespace");case 97:return I("abstract")||I("async");default:return!1}}function ue(){let g=s.charCodeAt(c);if(g!==Ne&&g!==Ge)return!1;let w=c;if(c++,g===Ge&&c<f&&s.charCodeAt(c)===Ne)c++;while(c<f){let E=s.charCodeAt(c);if(E===Qe||E===et||E===Ge||E===Ne){c++;continue}if(E===de&&c+1<f){let x=s.charCodeAt(c+1);if(x===de){c=B(c+2);continue}if(x===We){let S=s.indexOf("*/",c+2);c=S===-1?f:S+2;continue}}break}let y=c>=f||oe()||s.charCodeAt(c)===he;return c=w,y}function fe(g){let w=g-1;while(w>=0){let F=s.charCodeAt(w);if(F===Qe||F===et||F===Ge||F===Ne){w--;continue}break}if(w<0)return!0;let y=s[w];if("+-*/%=<>&|^!~?:,.([{".includes(y))return!0;let E=w;while(E>0&&s.charCodeAt(E-1)!==Ne)E--;let x=s.slice(E,w+1),S=x.lastIndexOf("<");if(S!==-1&&/^<[A-Za-z]/.test(x.slice(S))&&!x.slice(S).includes(">"))return!0;let D=w;while(D>=0&&/[a-z]/i.test(s[D]))D--;let N=s.slice(D+1,w+1);return["as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","return","yield","void"].includes(N)}function pe(){let g=s.charCodeAt(c);if(g!==Ne&&g!==Ge)return!1;if(fe(c))return!1;let w=c;c++;while(c<f){let S=s.charCodeAt(c);if(S===Qe||S===et||S===Ge||S===Ne){c++;continue}if(S===de&&c+1<f){let D=s.charCodeAt(c+1);if(D===de){c=B(c+2);continue}if(D===We){let N=s.indexOf("*/",c+2);c=N===-1?f:N+2;continue}}break}let y=c<f?s[c]:"",E=s.slice(c,c+2),x=y==="."||y==="?"||y===":"||y===")"||y==="]"||y==="}"||y===","||y==="+"||y==="-"||y==="*"||y==="/"||y==="%"||y==="<"||y===">"||y==="="||y==="&"||y==="|"||y==="^"||y==="`"||E==="=>"||I("as")||I("satisfies")||I("instanceof")||I("in");return c=w,!x}function Ee(){let g=s.charCodeAt(c);if(g!==Ne&&g!==Ge)return!1;if(fe(c))return!1;let w=c;c++;while(c<f){let x=s.charCodeAt(c);if(x===Qe||x===et||x===Ge||x===Ne){c++;continue}if(x===de&&c+1<f){let S=s.charCodeAt(c+1);if(S===de){c=B(c+2);continue}if(S===We){let D=s.indexOf("*/",c+2);c=D===-1?f:D+2;continue}}break}let y=c<f?s[c]:"",E=y==="|"||y==="&"||y==="["||y==="."||y==="?"||y===":"||y===">"||y===")"||y===","||I("extends");return c=w,!E}function xe(){let g=s.charCodeAt(c);if(g!==Ne&&g!==Ge)return!1;let w=c;if(c++,g===Ge&&c<f&&s.charCodeAt(c)===Ne)c++;while(c<f){let E=s.charCodeAt(c);if(E===Qe||E===et||E===Ge||E===Ne){c++;continue}if(E===de&&c+1<f&&s.charCodeAt(c+1)===de){c=B(c+2);continue}break}if(c>=f)return c=w,!0;let y=s.charCodeAt(c);if(y===124||y===38||y===_t||y===Tn||y===At)return c=w,!1;if(I("extends")||I("keyof")||I("typeof")||I("infer")||I("is")||I("as")||I("in"))return c=w,!1;return c=w,!0}let Je=/[{}'"`\/]/g,hi=/[()'"`\/]/g,T=/[[\]'"`\/]/g,j=/[<>'"`\/]/g;function M(g,w){let y=1;c++;let E=g===ne?Je:g===$e?hi:g===Ve?T:j;E.lastIndex=c;let x;while((x=E.exec(s))!==null){let S=x.index,D=s.charCodeAt(S);if(D===Re||D===Ie){c=S,ae(D),E.lastIndex=c;continue}if(D===Ye){c=S,be(),E.lastIndex=c;continue}if(D===de){if(c=S,ve()){E.lastIndex=c;continue}E.lastIndex=S+1;continue}if(D===g)y++;else if(D===w){if(w===De&&S>0&&s.charCodeAt(S-1)===je){E.lastIndex=S+1;continue}if(y--,y===0)return c=S+1,c}E.lastIndex=S+1}return c=f,c}function _(){return c>0&&s.charCodeAt(c-1)===je}function G(){return c+1<f&&s.charCodeAt(c+1)===De}let Y=/[<{};'"`\/\n\r()[\]]/g;function re(g=!1){let w=0,y=0,E=0,x=0,S=s.charCodeAt(c)===ne;Y.lastIndex=c;let D;while((D=Y.exec(s))!==null){let N=D.index,F=s.charCodeAt(N);if(F===Re||F===Ie){c=N,ae(F),Y.lastIndex=c;continue}if(F===Ye){c=N,be(),Y.lastIndex=c;continue}if(F===de){if(N>0&&s.charCodeAt(N-1)===Fe){Y.lastIndex=N+1;continue}if(c=N,ve()){if(w===0&&y===0&&E===0&&x===0&&Q())return;Y.lastIndex=c;continue}Y.lastIndex=N+1;continue}if(F===Fe){let P=Ja(N);if(P!==null)x=Math.max(0,x+P);Y.lastIndex=N+1;continue}if(F===$e){y++,Y.lastIndex=N+1;continue}if(F===Me){y--,Y.lastIndex=N+1;continue}if(F===Ve){E++,Y.lastIndex=N+1;continue}if(F===qe){E--,Y.lastIndex=N+1;continue}if(F===ne){w++,Y.lastIndex=N+1;continue}if(F===he){let P=w>0;if(!P&&g&&y===0&&E===0&&x===0){c=N;return}if(P)w--;if((!P||S)&&w===0&&y===0&&E===0&&x===0){c=N+1;return}if(P&&w===0&&y===0&&E===0&&x===0){c=N+1;let L=c;O();let J=oe();if(c=L,J)return}Y.lastIndex=N+1;continue}if(F===Ce&&w===0&&y===0&&E===0&&x===0){c=N+1;return}if((F===Ne||F===Ge)&&w===0&&y===0&&E===0&&x===0){if(c=N,ue())return}Y.lastIndex=N+1}c=f}function Ae(){c++;while(c<f&&(s.charCodeAt(c)===Qe||s.charCodeAt(c)===et))c++;let g=s.indexOf(`
118
118
  `,c),w=g===-1?f:g,y=s.indexOf(";",c);if(y!==-1&&y<w){let E=y-1;while(E>=c&&(s.charCodeAt(E)===Qe||s.charCodeAt(E)===et))E--;let x=s.charCodeAt(c),S=s.charCodeAt(E);if(x===ne&&S===he||x===Ve&&S===qe||x===Re&&S===Re||x===Ie&&S===Ie||x===Ye&&S===Ye){c=y+1;return}}re()}function Ot(){M(ne,he);while(c<f&&Ze(s.charCodeAt(c)))c++;if(I("from")){c+=4;while(c<f&&Ze(s.charCodeAt(c)))c++;if(c<f){let g=s.charCodeAt(c);if(g===Re||g===Ie)ae(g)}}while(c<f&&(s.charCodeAt(c)===Qe||s.charCodeAt(c)===et))c++;if(c<f&&s.charCodeAt(c)===Ce)c++}function Ut(){c++;while(c<f&&Ze(s.charCodeAt(c)))c++;if(I("as")){c+=2;while(c<f&&Ze(s.charCodeAt(c)))c++;ie();while(c<f&&Ze(s.charCodeAt(c)))c++}if(I("from")){c+=4;while(c<f&&Ze(s.charCodeAt(c)))c++;if(c<f){let g=s.charCodeAt(c);if(g===Re||g===Ie)ae(g)}}while(c<f&&(s.charCodeAt(c)===Qe||s.charCodeAt(c)===et))c++;if(c<f&&s.charCodeAt(c)===Ce)c++}function ct(g){let w=g.indexOf("from ");if(w===-1)return;let y=w+5;while(y<g.length&&(g.charCodeAt(y)===32||g.charCodeAt(y)===9))y++;if(y>=g.length)return;let E=g.charCodeAt(y);if(E!==39&&E!==34)return;let x=g.indexOf(g[y],y+1);if(x===-1)return;return g.slice(y+1,x)}function yt(g){if(!l)return;let w=g-1;while(w>=0&&Ze(s.charCodeAt(w)))w--;if(w<0)return;let y=[],E=!1;while(w>=0){if(w>=1&&s.charCodeAt(w)===de&&s.charCodeAt(w-1)===We){let D=s.lastIndexOf("/*",w-2);if(D>=0){y.push(s.slice(D,w+1)),E=!0,w=D-1;while(w>=0&&Ze(s.charCodeAt(w)))w--;continue}break}let x=w;while(x>0&&s.charCodeAt(x-1)!==Ne)x--;let S=R(x,w+1);if(S.startsWith("//")){if(E)break;let D=[S];w=x-1;while(w>=0&&(s.charCodeAt(w)===Ne||s.charCodeAt(w)===Ge))w--;while(w>=0){let N=w;while(N>0&&s.charCodeAt(N-1)!==Ne)N--;let F=R(N,w+1);if(F.startsWith("//")){D.push(F),w=N-1;while(w>=0&&(s.charCodeAt(w)===Ne||s.charCodeAt(w)===Ge))w--}else if(F===""){w=N-1;while(w>=0&&(s.charCodeAt(w)===Ne||s.charCodeAt(w)===Ge))w--}else break}D.reverse(),y.push(D.join(`
119
- `));continue}break}if(y.length===0)return;return y.reverse(),y}function jd(g){let w=g,y=!1,E=0,x;while(c<f){let q=s.charCodeAt(c);if(q===de&&(s.charCodeAt(c+1)===de||s.charCodeAt(c+1)===We)){O();continue}if(q===Ce){c++;break}if(q===ne)E++;else if(q===he&&E>0)E--;if(q===Re||q===Ie){if(ae(q),E>0)continue;y=!0;let Z=c;if(O(),s.charCodeAt(c)===Me){let U=c+1;x=ln(s.slice(w,U)),c=x?U:Z}else c=Z;while(c<f&&(s.charCodeAt(c)===Qe||s.charCodeAt(c)===et))c++;if(c<f&&s.charCodeAt(c)===Ce)c++;break}if(q===Ne&&y)break;c++}let S=R(w,c),D=Rt(S).find((q)=>q.category==="static-import"),N=ce(S),F=x?.isTypeOnly??D?.isTypeOnly??!1,P=N[1]?.kind==="quoted",L=x?.source??D?.specifier??"",J=yt(w);return{kind:"import",name:"",text:S,isExported:!1,isTypeOnly:F,isSideEffect:P,source:L,leadingComments:J,start:w,end:c}}function To(){let g=c;return M(ne,he),s.slice(g,c)}function Ua(g){let w=g.indexOf("(");if(w===-1)return g;let y=g.slice(w);if(y.indexOf("=")===-1)return g;let E=!1;for(let F=0;F<y.length;F++)if(y.charCodeAt(F)===61){let P=F>0?y.charCodeAt(F-1):0,L=F+1<y.length?y.charCodeAt(F+1):0;if(P!==61&&P!==33&&P!==60&&P!==62&&L!==61&&L!==62){E=!0;break}}if(!E)return g;let x=0,S=-1;for(let F=w;F<g.length;F++){let P=g.charCodeAt(F);if(P===40)x++;else if(P===41){if(x--,x===0){S=F;break}}}if(S===-1)return g;let D=g.slice(w,S+1),N=Ai(D);return g.slice(0,w)+N+g.slice(S+1)}function za(g){let w=g.indexOf("//")!==-1||g.indexOf("/*")!==-1,y=g.split(`
120
- `),E=[],x=[],S=[],D=!1,N=1/0;for(let L=0;L<y.length;L++){let J=y[L];if(w){if(D){if(J.includes("*/"))D=!1;continue}let q=J.trim();if(q.length===0)continue;let Z=q.charCodeAt(0);if(Z===de){let ye=q.charCodeAt(1);if(ye===de)continue;if(ye===We){if(!q.includes("*/"))D=!0;continue}}if(Z===We)continue;let U=X(J);if(U.charCodeAt(U.length-1)===Ce)U=U.slice(0,-1);U=Ua(U);let H=U.trim();if(!H)continue;E.push(U),x.push(H);let se=0;while(se<U.length&&Ze(U.charCodeAt(se)))se++;if(H!=="{"&&H!=="}"){if(se<N)N=se}S.push(se)}else{let q=J.length;while(q>0&&(J.charCodeAt(q-1)===Qe||J.charCodeAt(q-1)===et||J.charCodeAt(q-1)===Ge))q--;if(q===0)continue;let Z=q<J.length?J.slice(0,q):J;if(Z.charCodeAt(Z.length-1)===Ce)Z=Z.slice(0,-1);Z=Ua(Z);let U=Z.trim();if(!U)continue;E.push(Z),x.push(U);let H=0;while(H<Z.length&&Ze(Z.charCodeAt(H)))H++;if(U!=="{"&&U!=="}"){if(H<N)N=H}S.push(H)}}if(E.length===0)return"{}";if(N===1/0||N<=2)return E.join(`
119
+ `));continue}break}if(y.length===0)return;return y.reverse(),y}function jd(g){let w=g,y=!1,E=0,x;while(c<f){let q=s.charCodeAt(c);if(q===de&&(s.charCodeAt(c+1)===de||s.charCodeAt(c+1)===We)){O();continue}if(q===Ce){c++;break}if(q===ne)E++;else if(q===he&&E>0)E--;if(q===Re||q===Ie){if(ae(q),E>0)continue;y=!0;let Z=c;if(O(),s.charCodeAt(c)===Me){let U=c+1;x=ln(s.slice(w,U)),c=x?U:Z}else c=Z;while(c<f&&(s.charCodeAt(c)===Qe||s.charCodeAt(c)===et))c++;if(c<f&&s.charCodeAt(c)===Ce)c++;break}if(q===Ne&&y)break;c++}let S=R(w,c),D=Rt(S).find((q)=>q.category==="static-import"),N=ce(S),F=x?.isTypeOnly??D?.isTypeOnly??!1,P=N[1]?.kind==="quoted",L=x?.source??D?.specifier??"",J=yt(w);return{kind:"import",name:"",text:S,isExported:!1,isTypeOnly:F,isSideEffect:P,source:L,leadingComments:J,start:w,end:c}}function Ro(){let g=c;return M(ne,he),s.slice(g,c)}function za(g){let w=g.indexOf("(");if(w===-1)return g;let y=g.slice(w);if(y.indexOf("=")===-1)return g;let E=!1;for(let F=0;F<y.length;F++)if(y.charCodeAt(F)===61){let P=F>0?y.charCodeAt(F-1):0,L=F+1<y.length?y.charCodeAt(F+1):0;if(P!==61&&P!==33&&P!==60&&P!==62&&L!==61&&L!==62){E=!0;break}}if(!E)return g;let x=0,S=-1;for(let F=w;F<g.length;F++){let P=g.charCodeAt(F);if(P===40)x++;else if(P===41){if(x--,x===0){S=F;break}}}if(S===-1)return g;let D=g.slice(w,S+1),N=ki(D);return g.slice(0,w)+N+g.slice(S+1)}function Ka(g){let w=g.indexOf("//")!==-1||g.indexOf("/*")!==-1,y=g.split(`
120
+ `),E=[],x=[],S=[],D=!1,N=1/0;for(let L=0;L<y.length;L++){let J=y[L];if(w){if(D){if(J.includes("*/"))D=!1;continue}let q=J.trim();if(q.length===0)continue;let Z=q.charCodeAt(0);if(Z===de){let ye=q.charCodeAt(1);if(ye===de)continue;if(ye===We){if(!q.includes("*/"))D=!0;continue}}if(Z===We)continue;let U=X(J);if(U.charCodeAt(U.length-1)===Ce)U=U.slice(0,-1);U=za(U);let H=U.trim();if(!H)continue;E.push(U),x.push(H);let se=0;while(se<U.length&&Ze(U.charCodeAt(se)))se++;if(H!=="{"&&H!=="}"){if(se<N)N=se}S.push(se)}else{let q=J.length;while(q>0&&(J.charCodeAt(q-1)===Qe||J.charCodeAt(q-1)===et||J.charCodeAt(q-1)===Ge))q--;if(q===0)continue;let Z=q<J.length?J.slice(0,q):J;if(Z.charCodeAt(Z.length-1)===Ce)Z=Z.slice(0,-1);Z=za(Z);let U=Z.trim();if(!U)continue;E.push(Z),x.push(U);let H=0;while(H<Z.length&&Ze(Z.charCodeAt(H)))H++;if(U!=="{"&&U!=="}"){if(H<N)N=H}S.push(H)}}if(E.length===0)return"{}";if(N===1/0||N<=2)return E.join(`
121
121
  `);let F=N-2,P=Array(E.length);for(let L=0;L<E.length;L++){let J=x[L];if(J==="{"){P[L]=J;continue}let q=S[L];if(q>N)P[L]=E[L];else if(q===N&&(J.charCodeAt(0)===he||J.charCodeAt(0)===qe||J.charCodeAt(0)===Me))P[L]=E[L];else{let Z=Math.max(0,q-F);P[L]=" ".repeat(Z)+J}}return P.join(`
122
122
  `)}function Ft(){if(c>=f||s.charCodeAt(c)!==Fe)return"";let g=c;M(Fe,De);let w=s.slice(g,c);if(w.includes(`
123
123
  `)){let y="",E=!1;for(let x=0;x<w.length;x++){let S=w.charCodeAt(x);if(S===32||S===9||S===10||S===13){if(!E&&y.length>0)y+=" ",E=!0}else y+=w[x],E=!1}if(y.charCodeAt(1)===32)y=`<${y.slice(2)}`;if(y.charCodeAt(y.length-2)===32)y=`${y.slice(0,-2)}>`;return y}return w}function ii(){if(c>=f||s.charCodeAt(c)!==$e)return"()";let g=c;return M($e,Me),s.slice(g,c)}function jr(g){if(g.indexOf("/")===-1)return g;let w="",y=!1,E=0;for(let x=0;x<g.length;x++){let S=g.charCodeAt(x);if(y){if(w+=g[x],S===Ct&&x+1<g.length){w+=g[++x];continue}if(S===E)y=!1;continue}if(S===Re||S===Ie||S===Ye){y=!0,E=S,w+=g[x];continue}if(S===de&&x+1<g.length){let D=g.charCodeAt(x+1);if(D===We){let N=g.indexOf("*/",x+2);x=N===-1?g.length:N+1,w+=" ";continue}if(D===de){let N=g.indexOf(`
124
- `,x+2);x=N===-1?g.length:N-1;continue}}w+=g[x]}return w.trim()}function Ai(g){let w=g.slice(1,-1).trim();if(!w)return"()";if(g.indexOf(`
125
- `)===-1&&w.indexOf(":")!==-1&&w.indexOf("{")===-1&&w.indexOf("[")===-1&&w.indexOf("=")===-1&&w.indexOf("@")===-1&&w.indexOf("...")===-1){let F=0,P=0,L=0;for(let J=0;J<w.length;J++){let q=w.charCodeAt(J);if(q===$e||q===Fe||q===ne)L++;else if(q===Me||q===De||q===he)L--;else if(L===0){if(q===At)F++;else if(q===Dt)P++}}if(F>=P+1){let J=!1;for(let q=0;q<$s.length;q++){let Z=$s[q],U=w.indexOf(Z);if(U!==-1){let H=U+Z.length;if((U===0||!He(w.charCodeAt(U-1)))&&(H>=w.length||!He(w.charCodeAt(H)))){J=!0;break}}}if(!J)return g}}let y=[],E=0,x=0,S=!1,D=0;for(let F=0;F<=w.length;F++){if(F===w.length){y.push(jr(w.slice(E).trim()));break}let P=w.charCodeAt(F);if(S){if(P===Ct){F++;continue}if(P===D)S=!1;continue}if(P===de&&F+1<w.length){let L=w.charCodeAt(F+1);if(L===We){F+=2;while(F+1<w.length&&!(w.charCodeAt(F)===We&&w.charCodeAt(F+1)===de))F++;F++;continue}if(L===de){while(F<w.length&&w.charCodeAt(F)!==10)F++;continue}}if(P===Re||P===Ie||P===Ye){S=!0,D=P;continue}if(P===$e||P===ne||P===Ve||P===Fe)x++;else if(P===Me||P===he||P===qe||P===De&&!(F>0&&w.charCodeAt(F-1)===je))x--;else if(P===Dt&&x===0)y.push(jr(w.slice(E,F).trim())),E=F+1}let N=[];for(let F of y){if(!F)continue;let P=F.trim();if(P.startsWith("//")||P.startsWith("/*"))continue;let L=F;{let J=!1,q=0,Z=0,U=0;for(let H=0;H<L.length-1;H++){let se=L.charCodeAt(H);if(se===Ne){U=H+1;continue}if(J){if(se===Ct){H++;continue}if(se===q)J=!1;continue}if(se===Re||se===Ie||se===Ye){J=!0,q=se;continue}if(se===ne||se===Ve||se===$e||se===Fe){Z++;continue}if(se===he||se===qe||se===Me||se===De){if(Z>0)Z--;continue}if(se===de&&L.charCodeAt(H+1)===de){if(Z===0){L=L.slice(0,H).trimEnd();break}let ye=L.indexOf(`
126
- `,H);if(ye===-1){L=L.slice(0,U).trimEnd();break}let ee=L.slice(0,U),te=L.slice(ye+1);L=`${ee}${te}`,H=U-1}}}if(!L.trim())continue;N.push(Ka(L))}return dn(`(${N.join(", ")})`)}function Gd(g){if(!g.startsWith("{")&&!g.startsWith("["))return g;let w="",y=0,E=0,x=!1,S=0;while(y<g.length){let D=g.charCodeAt(y);if(x){if(D===Ct&&y+1<g.length){w+=g[y]+g[y+1],y+=2;continue}if(D===S)x=!1;w+=g[y],y++;continue}if(D===de&&y+1<g.length){let N=g.charCodeAt(y+1);if(N===We){let F=y;y+=2;while(y+1<g.length&&!(g.charCodeAt(y)===We&&g.charCodeAt(y+1)===de))y++;y=Math.min(y+2,g.length),w+=g.slice(F,y);continue}if(N===de){let F=y;while(y<g.length&&g.charCodeAt(y)!==10)y++;w+=g.slice(F,y);continue}}if(D===Re||D===Ie||D===Ye){x=!0,S=D,w+=g[y],y++;continue}if(D===ne||D===Ve||D===$e)E++;else if(D===he||D===qe||D===Me)E--;if(E>=1&&D===je&&(y+1>=g.length||g.charCodeAt(y+1)!==je&&g.charCodeAt(y+1)!==De)){while(w.length>0&&(w[w.length-1]===" "||w[w.length-1]==="\t"||w[w.length-1]===`
127
- `))w=w.slice(0,-1);y++;let N=0;while(y<g.length){let F=g.charCodeAt(y);if(F===Re||F===Ie||F===Ye){let P=F;y++;while(y<g.length){if(g.charCodeAt(y)===Ct){y+=2;continue}if(g.charCodeAt(y)===P){y++;break}y++}continue}if(F===ne||F===Ve||F===$e)N++;else if(F===he||F===qe||F===Me){if(N===0)break;N--}else if(F===Dt&&N===0)break;y++}continue}if(E===1&&D===_t&&y+2<g.length&&g.charCodeAt(y+1)===_t&&g.charCodeAt(y+2)===_t){y+=3;continue}w+=g[y],y++}return w}function Ka(g){let w=g.trim(),y=w.startsWith("...");if(y)w=w.slice(3).trim();while(w.startsWith("@")){let U=1;while(U<w.length&&He(w.charCodeAt(U)))U++;if(U<w.length&&w.charCodeAt(U)===$e){let H=1;U++;while(U<w.length&&H>0){if(w.charCodeAt(U)===$e)H++;else if(w.charCodeAt(U)===Me)H--;U++}}w=w.slice(U).trim()}let E=!0;while(E){E=!1;for(let U of $s)if(w.startsWith(U)&&w.length>U.length&&!He(w.charCodeAt(U.length))){let H=w.slice(U.length).trim();if(H.charCodeAt(0)===At||H.charCodeAt(0)===An&&H.length>1&&H.charCodeAt(1)===At)break;w=H,E=!0;break}}let x=-1,S=-1,D=0,N=!1,F=0;for(let U=0;U<w.length;U++){let H=w.charCodeAt(U);if(N){if(H===Ct){U++;continue}if(H===F)N=!1;continue}if(H===de&&U+1<w.length){let se=w.charCodeAt(U+1);if(se===We){U+=2;while(U+1<w.length&&!(w.charCodeAt(U)===We&&w.charCodeAt(U+1)===de))U++;U++;continue}if(se===de){while(U<w.length&&w.charCodeAt(U)!==10)U++;continue}}if(H===Re||H===Ie||H===Ye){N=!0,F=H;continue}if(H===$e||H===ne||H===Ve||H===Fe)D++;else if(H===Me||H===he||H===qe||H===De&&!(U>0&&w.charCodeAt(U-1)===je))D--;else if(D===0){if(H===At&&x===-1)x=U;else if(H===je&&S===-1&&(U===0||w.charCodeAt(U-1)!==je)&&(U+1>=w.length||w.charCodeAt(U+1)!==je&&w.charCodeAt(U+1)!==De))S=U}}let P,L,J=S!==-1;if(x!==-1&&(S===-1||x<S))if(P=w.slice(0,x).trim(),S!==-1)L=w.slice(x+1,S).trim();else L=w.slice(x+1).trim();else if(S!==-1){P=w.slice(0,S).trim();let U=y?null:pr(P,w.slice(S+1));if(U)return hn(U,ir);L=ir(w.slice(S+1).trim())}else P=w,L="unknown";if(P=Gd(P),(P.startsWith("{")||P.startsWith("["))&&P.includes(`
124
+ `,x+2);x=N===-1?g.length:N-1;continue}}w+=g[x]}return w.trim()}function ki(g){let w=g.slice(1,-1).trim();if(!w)return"()";if(g.indexOf(`
125
+ `)===-1&&w.indexOf(":")!==-1&&w.indexOf("{")===-1&&w.indexOf("[")===-1&&w.indexOf("=")===-1&&w.indexOf("@")===-1&&w.indexOf("...")===-1){let F=0,P=0,L=0;for(let J=0;J<w.length;J++){let q=w.charCodeAt(J);if(q===$e||q===Fe||q===ne)L++;else if(q===Me||q===De||q===he)L--;else if(L===0){if(q===At)F++;else if(q===Dt)P++}}if(F>=P+1){let J=!1;for(let q=0;q<Es.length;q++){let Z=Es[q],U=w.indexOf(Z);if(U!==-1){let H=U+Z.length;if((U===0||!He(w.charCodeAt(U-1)))&&(H>=w.length||!He(w.charCodeAt(H)))){J=!0;break}}}if(!J)return g}}let y=[],E=0,x=0,S=!1,D=0;for(let F=0;F<=w.length;F++){if(F===w.length){y.push(jr(w.slice(E).trim()));break}let P=w.charCodeAt(F);if(S){if(P===Ct){F++;continue}if(P===D)S=!1;continue}if(P===de&&F+1<w.length){let L=w.charCodeAt(F+1);if(L===We){F+=2;while(F+1<w.length&&!(w.charCodeAt(F)===We&&w.charCodeAt(F+1)===de))F++;F++;continue}if(L===de){while(F<w.length&&w.charCodeAt(F)!==10)F++;continue}}if(P===Re||P===Ie||P===Ye){S=!0,D=P;continue}if(P===$e||P===ne||P===Ve||P===Fe)x++;else if(P===Me||P===he||P===qe||P===De&&!(F>0&&w.charCodeAt(F-1)===je))x--;else if(P===Dt&&x===0)y.push(jr(w.slice(E,F).trim())),E=F+1}let N=[];for(let F of y){if(!F)continue;let P=F.trim();if(P.startsWith("//")||P.startsWith("/*"))continue;let L=F;{let J=!1,q=0,Z=0,U=0;for(let H=0;H<L.length-1;H++){let se=L.charCodeAt(H);if(se===Ne){U=H+1;continue}if(J){if(se===Ct){H++;continue}if(se===q)J=!1;continue}if(se===Re||se===Ie||se===Ye){J=!0,q=se;continue}if(se===ne||se===Ve||se===$e||se===Fe){Z++;continue}if(se===he||se===qe||se===Me||se===De){if(Z>0)Z--;continue}if(se===de&&L.charCodeAt(H+1)===de){if(Z===0){L=L.slice(0,H).trimEnd();break}let ye=L.indexOf(`
126
+ `,H);if(ye===-1){L=L.slice(0,U).trimEnd();break}let ee=L.slice(0,U),te=L.slice(ye+1);L=`${ee}${te}`,H=U-1}}}if(!L.trim())continue;N.push(Ha(L))}return pn(`(${N.join(", ")})`)}function Gd(g){if(!g.startsWith("{")&&!g.startsWith("["))return g;let w="",y=0,E=0,x=!1,S=0;while(y<g.length){let D=g.charCodeAt(y);if(x){if(D===Ct&&y+1<g.length){w+=g[y]+g[y+1],y+=2;continue}if(D===S)x=!1;w+=g[y],y++;continue}if(D===de&&y+1<g.length){let N=g.charCodeAt(y+1);if(N===We){let F=y;y+=2;while(y+1<g.length&&!(g.charCodeAt(y)===We&&g.charCodeAt(y+1)===de))y++;y=Math.min(y+2,g.length),w+=g.slice(F,y);continue}if(N===de){let F=y;while(y<g.length&&g.charCodeAt(y)!==10)y++;w+=g.slice(F,y);continue}}if(D===Re||D===Ie||D===Ye){x=!0,S=D,w+=g[y],y++;continue}if(D===ne||D===Ve||D===$e)E++;else if(D===he||D===qe||D===Me)E--;if(E>=1&&D===je&&(y+1>=g.length||g.charCodeAt(y+1)!==je&&g.charCodeAt(y+1)!==De)){while(w.length>0&&(w[w.length-1]===" "||w[w.length-1]==="\t"||w[w.length-1]===`
127
+ `))w=w.slice(0,-1);y++;let N=0;while(y<g.length){let F=g.charCodeAt(y);if(F===Re||F===Ie||F===Ye){let P=F;y++;while(y<g.length){if(g.charCodeAt(y)===Ct){y+=2;continue}if(g.charCodeAt(y)===P){y++;break}y++}continue}if(F===ne||F===Ve||F===$e)N++;else if(F===he||F===qe||F===Me){if(N===0)break;N--}else if(F===Dt&&N===0)break;y++}continue}if(E===1&&D===_t&&y+2<g.length&&g.charCodeAt(y+1)===_t&&g.charCodeAt(y+2)===_t){y+=3;continue}w+=g[y],y++}return w}function Ha(g){let w=g.trim(),y=w.startsWith("...");if(y)w=w.slice(3).trim();while(w.startsWith("@")){let U=1;while(U<w.length&&He(w.charCodeAt(U)))U++;if(U<w.length&&w.charCodeAt(U)===$e){let H=1;U++;while(U<w.length&&H>0){if(w.charCodeAt(U)===$e)H++;else if(w.charCodeAt(U)===Me)H--;U++}}w=w.slice(U).trim()}let E=!0;while(E){E=!1;for(let U of Es)if(w.startsWith(U)&&w.length>U.length&&!He(w.charCodeAt(U.length))){let H=w.slice(U.length).trim();if(H.charCodeAt(0)===At||H.charCodeAt(0)===Tn&&H.length>1&&H.charCodeAt(1)===At)break;w=H,E=!0;break}}let x=-1,S=-1,D=0,N=!1,F=0;for(let U=0;U<w.length;U++){let H=w.charCodeAt(U);if(N){if(H===Ct){U++;continue}if(H===F)N=!1;continue}if(H===de&&U+1<w.length){let se=w.charCodeAt(U+1);if(se===We){U+=2;while(U+1<w.length&&!(w.charCodeAt(U)===We&&w.charCodeAt(U+1)===de))U++;U++;continue}if(se===de){while(U<w.length&&w.charCodeAt(U)!==10)U++;continue}}if(H===Re||H===Ie||H===Ye){N=!0,F=H;continue}if(H===$e||H===ne||H===Ve||H===Fe)D++;else if(H===Me||H===he||H===qe||H===De&&!(U>0&&w.charCodeAt(U-1)===je))D--;else if(D===0){if(H===At&&x===-1)x=U;else if(H===je&&S===-1&&(U===0||w.charCodeAt(U-1)!==je)&&(U+1>=w.length||w.charCodeAt(U+1)!==je&&w.charCodeAt(U+1)!==De))S=U}}let P,L,J=S!==-1;if(x!==-1&&(S===-1||x<S))if(P=w.slice(0,x).trim(),S!==-1)L=w.slice(x+1,S).trim();else L=w.slice(x+1).trim();else if(S!==-1){P=w.slice(0,S).trim();let U=y?null:mr(P,w.slice(S+1));if(U)return mn(U,rr);L=rr(w.slice(S+1).trim())}else P=w,L="unknown";if(P=Gd(P),(P.startsWith("{")||P.startsWith("["))&&P.includes(`
128
128
  `)){let U=P.replace(/\s*\n\s*/g," ").replace(/\s+/g," ");if(U.length<=40)P=U;else P=P.split(`
129
129
  `).map((H)=>{let se=H.trim();if(!se)return"";if(se==="{"||se==="}"||se==="["||se==="]"||se.startsWith("}")||se.startsWith("]"))return se;return` ${se}`}).join(`
130
- `)}let q=P.endsWith("?")||J;if(P.endsWith("?"))P=P.slice(0,-1).trim();let Z=q&&!y?"?":"";if(y)return`...${P}: ${L}`;return`${P}${Z}: ${L}`}function ir(g){let w=g.trim(),y=C(w);if(y)return y;if(w==="true"||w==="false")return"boolean";if(wi(w))return"number";if(w.startsWith("'")&&w.endsWith("'")||w.startsWith('"')&&w.endsWith('"'))return"string";if(w.startsWith("["))return"unknown[]";if(w.startsWith("{"))return"Record<string, unknown>";return Cr(w)??"unknown"}function Oo(g){let w=g.trim();if(w.endsWith("as const"))w=w.slice(0,-8).trim();if(w==="true"||w==="false")return w;if(wi(w))return mn(w);let y=Vd(w);if(y!==null)return y;return Cr(w)??"unknown"}function Vd(g){if(g==="")return null;if(g.charCodeAt(0)===Re||g.charCodeAt(0)===Ie){if(br(g,0,g.charCodeAt(0))===g.length)return g}let w=Ud(g,"+");if(w.length>1){let y=!1,E=!0,x=[];for(let S of w){let D=S.trim(),N=D.charCodeAt(0);if((N===Re||N===Ie)&&br(D,0,N)===D.length)y=!0,x.push(zd(D));else E=!1}if(E)return Kd(x.join(""));if(y)return"string";return null}if(/^[\d\s()+*/%.\-]+$/.test(g)&&/\d/.test(g)&&/[+*/%\-\s]/.test(g))return"number";return null}function Ud(g,w){let y=[],E=0,x="",S=0;while(S<g.length){let D=g.charCodeAt(S);if(D===Re||D===Ie||D===Ye){let N=br(g,S,D);x+=g.slice(S,N),S=N;continue}if(D===de&&(g.charCodeAt(S+1)===de||g.charCodeAt(S+1)===42)){if(g.charCodeAt(S+1)===de){let P=g.indexOf(`
130
+ `)}let q=P.endsWith("?")||J;if(P.endsWith("?"))P=P.slice(0,-1).trim();let Z=q&&!y?"?":"";if(y)return`...${P}: ${L}`;return`${P}${Z}: ${L}`}function rr(g){let w=g.trim(),y=v(w);if(y)return y;if(w==="true"||w==="false")return"boolean";if(Ci(w))return"number";if(w.startsWith("'")&&w.endsWith("'")||w.startsWith('"')&&w.endsWith('"'))return"string";if(w.startsWith("["))return"unknown[]";if(w.startsWith("{"))return"Record<string, unknown>";return Cr(w)??"unknown"}function Po(g){let w=g.trim();if(w.endsWith("as const"))w=w.slice(0,-8).trim();if(w==="true"||w==="false")return w;if(Ci(w))return yn(w);let y=Vd(w);if(y!==null)return y;return Cr(w)??"unknown"}function Vd(g){if(g==="")return null;if(g.charCodeAt(0)===Re||g.charCodeAt(0)===Ie){if(br(g,0,g.charCodeAt(0))===g.length)return g}let w=Ud(g,"+");if(w.length>1){let y=!1,E=!0,x=[];for(let S of w){let D=S.trim(),N=D.charCodeAt(0);if((N===Re||N===Ie)&&br(D,0,N)===D.length)y=!0,x.push(zd(D));else E=!1}if(E)return Kd(x.join(""));if(y)return"string";return null}if(/^[\d\s()+*/%.\-]+$/.test(g)&&/\d/.test(g)&&/[+*/%\-\s]/.test(g))return"number";return null}function Ud(g,w){let y=[],E=0,x="",S=0;while(S<g.length){let D=g.charCodeAt(S);if(D===Re||D===Ie||D===Ye){let N=br(g,S,D);x+=g.slice(S,N),S=N;continue}if(D===de&&(g.charCodeAt(S+1)===de||g.charCodeAt(S+1)===42)){if(g.charCodeAt(S+1)===de){let P=g.indexOf(`
131
131
  `,S+2),L=P===-1?g.length:P;x+=g.slice(S,L),S=L;continue}let N=g.indexOf("*/",S+2),F=N===-1?g.length:N+2;x+=g.slice(S,F),S=F;continue}if(D===$e||D===Ve||D===ne)E++;else if(D===Me||D===qe||D===he)E--;if(g[S]===w&&E===0){y.push(x),x="",S++;continue}x+=g[S],S++}return y.push(x),y}function zd(g){return g.slice(1,-1).replace(/\\(.)/g,(w,y)=>{if(y==="n")return`
132
- `;if(y==="t")return"\t";if(y==="r")return"\r";if(y==="0")return"\x00";return y})}function Kd(g){return`'${g.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function Gr(g){if(g.endsWith("as const"))return null;let w=0,y=-1;for(let E=0;E<g.length;E++){let x=g.charCodeAt(E);if(x===Re||x===Ie||x===Ye)E=br(g,E,x)-1;else if(x===123||x===91||x===40)w++;else if(x===125||x===93||x===41)w--;else if(w===0&&x===32&&E+4<=g.length&&g.substring(E,E+4)===" as ")y=E}if(y===-1)return null;return g.slice(y+4).trim()||null}function rr(){if(O(),c<f&&s.charCodeAt(c)===At){let g=function(){let x=R(w,E),S=(D)=>{let N=x.length-D.length;return N>=0&&x.endsWith(D)&&(N===0||!He(x.charCodeAt(N-1)))};return x.length===0||x.endsWith("=>")||x.endsWith("|")||x.endsWith("&")||S("is")||S("extends")};c++,O();let w=c,y=0,E=w;while(c<f){let x=c;if(ve()){if(s.charCodeAt(x)!==de)E=c;continue}let S=s.charCodeAt(c);if(S===$e||S===Ve||S===Fe)y++;else if(S===Me||S===qe||S===De&&!_())y--;else if(S===ne)if(y>0)y++;else if(g())y++;else break;else if(S===he){if(y===0)break;y--}else if(y===0&&S===Ce)break;if(y===0&&xe()&&!g())break;if(!Ze(S))E=c+1;c++}return R(w,c)}return""}function ri(g,w,y,E){c+=8,O();let x=c<f&&s.charCodeAt(c)===We;if(x)c++,O();let S=ie();if(!S&&!E)return null;O();let D=Ft();O();let N=ii();O();let F=rr(),P=F.length>0;if(!F)if(y&&x)F="AsyncGenerator<unknown, void, unknown>";else if(x)F="Generator<unknown, void, unknown>";else if(y)F="Promise<void>";else F="void";O();let L=!1;if(c<f&&s.charCodeAt(c)===ne){L=!0;let H=c+1;if(M(ne,he),!P&&!x){let se=s.slice(H,c-1),ye=yp(se,t,()=>{let ee;do ee=`__dtsx_return_${v++}`;while(s.includes(ee));return ee},(ee)=>h.set(ee.name,{...ee,start:c,end:c}),D);F=ye.finish(Kt(se,y,N,k,ye.resolve))}}else if(c<f&&s.charCodeAt(c)===Ce)c++;let J=Ai(N),q=`${w?E?"export default function ":"export declare function ":"declare function "}${S||(E?"":"default")}${D}${J}: ${F};`,Z=yt(g),U={kind:"function",name:S||"default",text:q,isExported:w,isDefault:E,isAsync:y,isGenerator:x,returnType:F,generics:D||void 0,leadingComments:Z,start:g,end:c};if(L)m.add(U);return U}let Ro,Hd=0;function Ha(){Ro??=new Set(ce(s).filter((g)=>g.kind==="word").map((g)=>s.slice(g.start,g.end)));for(;;){let g=`__dtsx_binding_${Hd++}`;if(Ro.has(g))continue;return Ro.add(g),g}}function pi(g,w,y){c+=w.length,O();let E=[];do{if(O(),c>=f)break;let x=s.charCodeAt(c),S,D=c;if(x===ne||x===Ve)M(x,x===ne?he:qe),S=s.slice(D,c);let N=S?Ha():ie();if(!N)return re(),E;O();let F,P,L,J=!1;if(c<f&&s.charCodeAt(c)===At){c++,O();let ye=c,ee=0;while(c<f){if(ve()){if(ee===0&&Q())break;continue}let te=s.charCodeAt(c);if(te===$e||te===ne||te===Ve||te===Fe)ee++;else if(te===Me||te===he||te===qe||te===De&&!_())ee--;else if(ee===0&&(te===Ce||te===Dt))break;else if(ee===0&&te===je&&!G())break;if(ee===0&&(ue()||Ee()))break;c++}F=R(ye,c)}if(c<f&&s.charCodeAt(c)===je)if(a&&F&&(!l||!Ep(F)))Ae();else{c++,O();let ye=c;L=ye;let ee=0,te=0,ft=0,Se=!0;for(;;){c=ye,ee=0,te=0,ft=0;while(c<f){if(ve()){if(ee===0&&te===0&&ft===0&&Q())break;continue}let ze=s.charCodeAt(c);if(ze===$e||ze===ne||ze===Ve)ee++;else if(ze===Me||ze===he||ze===qe)ee--;else if(ze===Fe&&ee===0){let nr=qa(c);if(nr!==null)ft=Math.max(0,ft+nr);else if(Se&&(c+1>=f||s.charCodeAt(c+1)!==je))te++}else if(ze===De&&ee===0&&ft===0&&!_()){if(te>0&&(c+1>=f||s.charCodeAt(c+1)!==je))te--}else if(ee===0&&te===0&&ft===0&&(ze===Ce||ze===Dt))break;if(ee===0&&te===0&&ft===0&&(ue()||pe()))break;c++}if(te>0&&Se){Se=!1;continue}break}if(P=z(R(ye,c)),P.endsWith(" as const")||P==="const"){if(J=!0,!F){let ze=P.endsWith(" as const")?P.slice(0,-9).trim():P,nr=Oo(ze);F=nr!=="unknown"?nr:void 0}}else if(!F){let ze=En(P)??Gr(P)??k(P);if(ze)F=ze}}let q=E.length===0?yt(g):void 0,Z=S?"const":w,U=S?!1:y,H=`${U?"export ":""}declare ${Z} ${N}: ${F||"unknown"};`,se={kind:"variable",name:N,text:H,isExported:U,typeAnnotation:F,value:P,initializerStart:L,modifiers:J?[Z,"const assertion"]:[Z],leadingComments:S?void 0:q,start:g,end:c};if(S)E.push(...xl({pattern:S,patternOffset:D,root:se,kind:w,exported:y,comments:q,allocateName:Ha}));else E.push(se);if(s.charCodeAt(c)===Dt){c++;continue}if(s.charCodeAt(c)===Ce)c++;break}while(c<f);return E}function qa(g){if(s.charCodeAt(g)!==Fe||g+1>=f)return null;let w=s.charCodeAt(g+1);if(w===De)return 1;if(w===de)return-1;if(!dt(w))return null;let y=g+2;while(y<f){let P=s.charCodeAt(y);if(!He(P)&&P!==_t&&P!==58&&P!==45)break;y++}let E=s.slice(g+1,y),x=s.charCodeAt(y);if(x>32&&x!==De&&x!==de)return null;let S=0,D=0,N=y;for(;N<f;N++){let P=s.charCodeAt(N);if(D!==0){if(P===Ct)N++;else if(P===D)D=0;continue}if(P===Re||P===Ie||P===Ye)D=P;else if(P===ne)S++;else if(P===he&&S>0)S--;else if(P===De&&S===0)break}if(N>=f)return null;let F=N-1;while(F>g&&s.charCodeAt(F)<=32)F--;if(s.charCodeAt(F)===de)return 0;return s.indexOf(`</${E}`,N+1)===-1?null:1}function Po(g,w){c+=9,O();let y=ie();O();let E=Ft();O();let x="";if(I("extends")){c+=7,O();let P=c,L=0;while(c<f){if(ve())continue;let J=s.charCodeAt(c);if(J===Fe)L++;else if(J===De&&!_())L--;else if(J===ne&&L===0)break;c++}x=R(P,c)}O();let S=c<f&&s.charCodeAt(c)===ne?To():"{}",D=za(S),N=`${w?"export ":""}declare interface ${y}${E}${x?` extends ${x}`:""} ${D}`,F=yt(g);return{kind:"interface",name:y,text:N,isExported:w,extends:x||void 0,generics:E||void 0,leadingComments:F,start:g,end:c}}function Mo(g,w){c+=4,O();let y=ie();O();let E=Ft();if(O(),c<f&&s.charCodeAt(c)===je)c++;O();let x=c,S=0;while(c<f){if(ve())continue;let P=s.charCodeAt(c);if(P===$e||P===ne||P===Ve||P===Fe)S++;else if(P===Me||P===he||P===qe||P===De&&!_())S--;else if(S===0&&P===Ce)break;if(S===0&&(ue()||Ee()))break;c++}let D=R(x,c);if(c<f&&s.charCodeAt(c)===Ce)c++;let N=`${w?"export ":""}type ${y}${E} = ${D}`,F=yt(g);return{kind:"type",name:y,text:N,isExported:w,generics:E||void 0,leadingComments:F,start:g,end:c}}function ki(g,w,y){c+=4,O();let E=ie();O();let x=c;if(c<f&&s.charCodeAt(c)===ne)M(ne,he);let S=R(g,c),D=yt(g);return{kind:"enum",name:E,text:S,isExported:w,modifiers:y?["const"]:void 0,leadingComments:D,start:g,end:c}}function ni(g,w,y,E=!1){c+=5,O();let x=ie()||"AnonymousClass";O();let S=Ft();O();let D="";if(I("extends")){c+=7,O();let J=c,q=0;while(c<f){if(ve())continue;let Z=s.charCodeAt(c);if(Z===Fe)q++;else if(Z===De&&!_())q--;else if(q===0&&(Z===ne||I("implements")))break;c++}D=R(J,c)}let N;if(I("implements")){c+=10,O();let J=c,q=0;while(c<f){if(ve())continue;let U=s.charCodeAt(c);if(U===Fe)q++;else if(U===De&&!_())q--;else if(q===0&&U===ne)break;c++}let Z=R(J,c);if(Z)N=Z.split(",").map((U)=>U.trim())}O();let F=Io(),P=`${w?E?"export default ":"export declare ":"declare "}${y?"abstract ":""}class ${x}${S}${D?` extends ${D}`:""}${N&&N.length>0?` implements ${N.join(", ")}`:""} ${F}`,L=yt(g);return{kind:"class",name:x,text:P,isExported:w,isDefault:E,extends:D||void 0,implements:N,generics:S||void 0,modifiers:y?["abstract"]:void 0,leadingComments:L,start:g,end:c}}let Do;function Io(){if(c>=f||s.charCodeAt(c)!==ne)return"{}";c++;let g={fields:new Map,pending:[],isStatic:!1};b.push(g);let w=[],y=new Set;while(c<f){if(O(),c>=f)break;if(s.charCodeAt(c)===he){c++;break}if(s.charCodeAt(c)===Ce){c++;continue}if(Do=yt(c),I("static")&&Ur("static")===ne){c+=6,O(),M(ne,he);continue}let E=!1,x=!1,S=!1,D=!1,N=!1,F=!1,P=!1,L=!1,J=!0;while(J){O();let ye=c,ee=ie();if(c=ye,ee){let te=Ur(ee);if(te===$e||te===Fe||te===An||te===33||te===At||te===je||te===Ce||te===he)break}if(I("private")){E=!0,c+=7;continue}if(I("protected")){x=!0,c+=9;continue}if(I("public")){c+=6;continue}if(I("static")){S=!0,c+=6;continue}if(I("abstract")){D=!0,c+=8;continue}if(I("readonly")){N=!0,c+=8;continue}if(I("override")){F=!0,c+=8;continue}if(I("accessor")){P=!0,c+=8;continue}if(I("async")){L=!0,c+=5;continue}if(I("declare")){c+=7;continue}break}if(O(),c>=f||s.charCodeAt(c)===he)break;let q=c;if(g.isStatic=S,(I("get")||I("set"))&&No(Ur(s.slice(c,c+3))))c+=3,O();if(s.charCodeAt(c)===We)c++,O();let Z=Vr();c=q;let U=Z.startsWith("#");if(U)E=!0;if(E&&Z&&Z!=="constructor"){let ye=U?S?" static #private_static;":" #private;":` private ${S?"static ":""}${Z};`,ee=Z[0]==="'"||Z[0]==='"'?wt(Z)??Z:Z,te=U?`${S?"static":"instance"}#`:`${S?"static:":"instance:"}${ee}`;if(!y.has(te))y.add(te),w.push(ye)}let H=E?[]:w,se=" ";if(x)se+="protected ";if(S)se+="static ";if(D)se+="abstract ";if(N)se+="readonly ";if(I("constructor")){c+=11,O();let ye=ii();if(O(),Jd(ye,w),c<f&&s.charCodeAt(c)===ne)M(ne,he);else if(c<f&&s.charCodeAt(c)===Ce)c++;let ee=Ai(ye);w.push(E?" private constructor();":` ${x?"protected ":""}constructor${ee};`)}else if(I("get"))if(c+=3,O(),c<f&&No(s.charCodeAt(c))){let ye=Vr();if(ye.startsWith("#")){if(O(),c<f&&s.charCodeAt(c)===$e)ii();if(O(),rr(),O(),c<f&&s.charCodeAt(c)===ne)M(ne,he);else if(c<f&&s.charCodeAt(c)===Ce)c++;continue}O(),ii(),O();let ee=rr(),te;if(O(),c<f&&s.charCodeAt(c)===ne){let Se=c+1;if(M(ne,he),!ee&&!a)te=s.slice(Se,c-1),ee=Kt(te,!1,"()",(ze)=>W(ze,S))}else if(c<f&&s.charCodeAt(c)===Ce)c++;let ft=H.length;if(H.push(`${se}get ${ye}(): ${te?zt(ee):ee||"unknown"};`),te)g.pending.push(()=>{let Se=Kt(te,!1,"()",(ze)=>W(ze,S));H[ft]=`${se}get ${ye}(): ${zt(Se)};`})}else Ya("get",se,S,N,L,H);else if(I("set"))if(c+=3,O(),c<f&&No(s.charCodeAt(c))){let ye=Vr();if(ye.startsWith("#")){if(O(),c<f&&s.charCodeAt(c)===$e)ii();if(O(),c<f&&s.charCodeAt(c)===ne)M(ne,he);else if(c<f&&s.charCodeAt(c)===Ce)c++;continue}O();let ee=ii();if(O(),c<f&&s.charCodeAt(c)===ne)M(ne,he);else if(c<f&&s.charCodeAt(c)===Ce)c++;let te=Ai(ee);H.push(`${se}set ${ye}${te};`)}else Ya("set",se,S,N,L,H);else{let ye=s.charCodeAt(c)===We;if(ye)c++,O();let ee=Vr();if(!ee){Ja();continue}Xa(ee,se,S,N,ye,D,L,H)}}for(let E of g.pending)E();return b.pop(),`{
132
+ `;if(y==="t")return"\t";if(y==="r")return"\r";if(y==="0")return"\x00";return y})}function Kd(g){return`'${g.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function Gr(g){if(g.endsWith("as const"))return null;let w=0,y=-1;for(let E=0;E<g.length;E++){let x=g.charCodeAt(E);if(x===Re||x===Ie||x===Ye)E=br(g,E,x)-1;else if(x===123||x===91||x===40)w++;else if(x===125||x===93||x===41)w--;else if(w===0&&x===32&&E+4<=g.length&&g.substring(E,E+4)===" as ")y=E}if(y===-1)return null;return g.slice(y+4).trim()||null}function nr(){if(O(),c<f&&s.charCodeAt(c)===At){let g=function(){let x=R(w,E),S=(D)=>{let N=x.length-D.length;return N>=0&&x.endsWith(D)&&(N===0||!He(x.charCodeAt(N-1)))};return x.length===0||x.endsWith("=>")||x.endsWith("|")||x.endsWith("&")||S("is")||S("extends")};c++,O();let w=c,y=0,E=w;while(c<f){let x=c;if(ve()){if(s.charCodeAt(x)!==de)E=c;continue}let S=s.charCodeAt(c);if(S===$e||S===Ve||S===Fe)y++;else if(S===Me||S===qe||S===De&&!_())y--;else if(S===ne)if(y>0)y++;else if(g())y++;else break;else if(S===he){if(y===0)break;y--}else if(y===0&&S===Ce)break;if(y===0&&xe()&&!g())break;if(!Ze(S))E=c+1;c++}return R(w,c)}return""}function ri(g,w,y,E){c+=8,O();let x=c<f&&s.charCodeAt(c)===We;if(x)c++,O();let S=ie();if(!S&&!E)return null;O();let D=Ft();O();let N=ii();O();let F=nr(),P=F.length>0;if(!F)if(y&&x)F="AsyncGenerator<unknown, void, unknown>";else if(x)F="Generator<unknown, void, unknown>";else if(y)F="Promise<void>";else F="void";O();let L=!1;if(c<f&&s.charCodeAt(c)===ne){L=!0;let H=c+1;if(M(ne,he),!P&&!x){let se=s.slice(H,c-1),ye=vp(se,t,()=>{let ee;do ee=`__dtsx_return_${C++}`;while(s.includes(ee));return ee},(ee)=>h.set(ee.name,{...ee,start:c,end:c}),D);F=ye.finish(Kt(se,y,N,k,ye.resolve))}}else if(c<f&&s.charCodeAt(c)===Ce)c++;let J=ki(N),q=`${w?E?"export default function ":"export declare function ":"declare function "}${S||(E?"":"default")}${D}${J}: ${F};`,Z=yt(g),U={kind:"function",name:S||"default",text:q,isExported:w,isDefault:E,isAsync:y,isGenerator:x,returnType:F,generics:D||void 0,leadingComments:Z,start:g,end:c};if(L)m.add(U);return U}let Mo,Hd=0;function qa(){Mo??=new Set(ce(s).filter((g)=>g.kind==="word").map((g)=>s.slice(g.start,g.end)));for(;;){let g=`__dtsx_binding_${Hd++}`;if(Mo.has(g))continue;return Mo.add(g),g}}function pi(g,w,y){c+=w.length,O();let E=[];do{if(O(),c>=f)break;let x=s.charCodeAt(c),S,D=c;if(x===ne||x===Ve)M(x,x===ne?he:qe),S=s.slice(D,c);let N=S?qa():ie();if(!N)return re(),E;O();let F,P,L,J=!1;if(c<f&&s.charCodeAt(c)===At){c++,O();let ye=c,ee=0;while(c<f){if(ve()){if(ee===0&&Q())break;continue}let te=s.charCodeAt(c);if(te===$e||te===ne||te===Ve||te===Fe)ee++;else if(te===Me||te===he||te===qe||te===De&&!_())ee--;else if(ee===0&&(te===Ce||te===Dt))break;else if(ee===0&&te===je&&!G())break;if(ee===0&&(ue()||Ee()))break;c++}F=R(ye,c)}if(c<f&&s.charCodeAt(c)===je)if(a&&F&&(!l||!Ap(F)))Ae();else{c++,O();let ye=c;L=ye;let ee=0,te=0,ft=0,Se=!0;for(;;){c=ye,ee=0,te=0,ft=0;while(c<f){if(ve()){if(ee===0&&te===0&&ft===0&&Q())break;continue}let ze=s.charCodeAt(c);if(ze===$e||ze===ne||ze===Ve)ee++;else if(ze===Me||ze===he||ze===qe)ee--;else if(ze===Fe&&ee===0){let or=Ja(c);if(or!==null)ft=Math.max(0,ft+or);else if(Se&&(c+1>=f||s.charCodeAt(c+1)!==je))te++}else if(ze===De&&ee===0&&ft===0&&!_()){if(te>0&&(c+1>=f||s.charCodeAt(c+1)!==je))te--}else if(ee===0&&te===0&&ft===0&&(ze===Ce||ze===Dt))break;if(ee===0&&te===0&&ft===0&&(ue()||pe()))break;c++}if(te>0&&Se){Se=!1;continue}break}if(P=z(R(ye,c)),P.endsWith(" as const")||P==="const"){if(J=!0,!F){let ze=P.endsWith(" as const")?P.slice(0,-9).trim():P,or=Po(ze);F=or!=="unknown"?or:void 0}}else if(!F){let ze=Sn(P)??Gr(P)??k(P);if(ze)F=ze}}let q=E.length===0?yt(g):void 0,Z=S?"const":w,U=S?!1:y,H=`${U?"export ":""}declare ${Z} ${N}: ${F||"unknown"};`,se={kind:"variable",name:N,text:H,isExported:U,typeAnnotation:F,value:P,initializerStart:L,modifiers:J?[Z,"const assertion"]:[Z],leadingComments:S?void 0:q,start:g,end:c};if(S)E.push(...xl({pattern:S,patternOffset:D,root:se,kind:w,exported:y,comments:q,allocateName:qa}));else E.push(se);if(s.charCodeAt(c)===Dt){c++;continue}if(s.charCodeAt(c)===Ce)c++;break}while(c<f);return E}function Ja(g){if(s.charCodeAt(g)!==Fe||g+1>=f)return null;let w=s.charCodeAt(g+1);if(w===De)return 1;if(w===de)return-1;if(!dt(w))return null;let y=g+2;while(y<f){let P=s.charCodeAt(y);if(!He(P)&&P!==_t&&P!==58&&P!==45)break;y++}let E=s.slice(g+1,y),x=s.charCodeAt(y);if(x>32&&x!==De&&x!==de)return null;let S=0,D=0,N=y;for(;N<f;N++){let P=s.charCodeAt(N);if(D!==0){if(P===Ct)N++;else if(P===D)D=0;continue}if(P===Re||P===Ie||P===Ye)D=P;else if(P===ne)S++;else if(P===he&&S>0)S--;else if(P===De&&S===0)break}if(N>=f)return null;let F=N-1;while(F>g&&s.charCodeAt(F)<=32)F--;if(s.charCodeAt(F)===de)return 0;return s.indexOf(`</${E}`,N+1)===-1?null:1}function Do(g,w){c+=9,O();let y=ie();O();let E=Ft();O();let x="";if(I("extends")){c+=7,O();let P=c,L=0;while(c<f){if(ve())continue;let J=s.charCodeAt(c);if(J===Fe)L++;else if(J===De&&!_())L--;else if(J===ne&&L===0)break;c++}x=R(P,c)}O();let S=c<f&&s.charCodeAt(c)===ne?Ro():"{}",D=Ka(S),N=`${w?"export ":""}declare interface ${y}${E}${x?` extends ${x}`:""} ${D}`,F=yt(g);return{kind:"interface",name:y,text:N,isExported:w,extends:x||void 0,generics:E||void 0,leadingComments:F,start:g,end:c}}function Io(g,w){c+=4,O();let y=ie();O();let E=Ft();if(O(),c<f&&s.charCodeAt(c)===je)c++;O();let x=c,S=0;while(c<f){if(ve())continue;let P=s.charCodeAt(c);if(P===$e||P===ne||P===Ve||P===Fe)S++;else if(P===Me||P===he||P===qe||P===De&&!_())S--;else if(S===0&&P===Ce)break;if(S===0&&(ue()||Ee()))break;c++}let D=R(x,c);if(c<f&&s.charCodeAt(c)===Ce)c++;let N=`${w?"export ":""}type ${y}${E} = ${D}`,F=yt(g);return{kind:"type",name:y,text:N,isExported:w,generics:E||void 0,leadingComments:F,start:g,end:c}}function Ti(g,w,y){c+=4,O();let E=ie();O();let x=c;if(c<f&&s.charCodeAt(c)===ne)M(ne,he);let S=R(g,c),D=yt(g);return{kind:"enum",name:E,text:S,isExported:w,modifiers:y?["const"]:void 0,leadingComments:D,start:g,end:c}}function ni(g,w,y,E=!1){c+=5,O();let x=ie()||"AnonymousClass";O();let S=Ft();O();let D="";if(I("extends")){c+=7,O();let J=c,q=0;while(c<f){if(ve())continue;let Z=s.charCodeAt(c);if(Z===Fe)q++;else if(Z===De&&!_())q--;else if(q===0&&(Z===ne||I("implements")))break;c++}D=R(J,c)}let N;if(I("implements")){c+=10,O();let J=c,q=0;while(c<f){if(ve())continue;let U=s.charCodeAt(c);if(U===Fe)q++;else if(U===De&&!_())q--;else if(q===0&&U===ne)break;c++}let Z=R(J,c);if(Z)N=Z.split(",").map((U)=>U.trim())}O();let F=Fo(),P=`${w?E?"export default ":"export declare ":"declare "}${y?"abstract ":""}class ${x}${S}${D?` extends ${D}`:""}${N&&N.length>0?` implements ${N.join(", ")}`:""} ${F}`,L=yt(g);return{kind:"class",name:x,text:P,isExported:w,isDefault:E,extends:D||void 0,implements:N,generics:S||void 0,modifiers:y?["abstract"]:void 0,leadingComments:L,start:g,end:c}}let No;function Fo(){if(c>=f||s.charCodeAt(c)!==ne)return"{}";c++;let g={fields:new Map,pending:[],isStatic:!1};b.push(g);let w=[],y=new Set;while(c<f){if(O(),c>=f)break;if(s.charCodeAt(c)===he){c++;break}if(s.charCodeAt(c)===Ce){c++;continue}if(No=yt(c),I("static")&&Ur("static")===ne){c+=6,O(),M(ne,he);continue}let E=!1,x=!1,S=!1,D=!1,N=!1,F=!1,P=!1,L=!1,J=!0;while(J){O();let ye=c,ee=ie();if(c=ye,ee){let te=Ur(ee);if(te===$e||te===Fe||te===Tn||te===33||te===At||te===je||te===Ce||te===he)break}if(I("private")){E=!0,c+=7;continue}if(I("protected")){x=!0,c+=9;continue}if(I("public")){c+=6;continue}if(I("static")){S=!0,c+=6;continue}if(I("abstract")){D=!0,c+=8;continue}if(I("readonly")){N=!0,c+=8;continue}if(I("override")){F=!0,c+=8;continue}if(I("accessor")){P=!0,c+=8;continue}if(I("async")){L=!0,c+=5;continue}if(I("declare")){c+=7;continue}break}if(O(),c>=f||s.charCodeAt(c)===he)break;let q=c;if(g.isStatic=S,(I("get")||I("set"))&&Wo(Ur(s.slice(c,c+3))))c+=3,O();if(s.charCodeAt(c)===We)c++,O();let Z=Vr();c=q;let U=Z.startsWith("#");if(U)E=!0;if(E&&Z&&Z!=="constructor"){let ye=U?S?" static #private_static;":" #private;":` private ${S?"static ":""}${Z};`,ee=Z[0]==="'"||Z[0]==='"'?wt(Z)??Z:Z,te=U?`${S?"static":"instance"}#`:`${S?"static:":"instance:"}${ee}`;if(!y.has(te))y.add(te),w.push(ye)}let H=E?[]:w,se=" ";if(x)se+="protected ";if(S)se+="static ";if(D)se+="abstract ";if(N)se+="readonly ";if(I("constructor")){c+=11,O();let ye=ii();if(O(),Jd(ye,w),c<f&&s.charCodeAt(c)===ne)M(ne,he);else if(c<f&&s.charCodeAt(c)===Ce)c++;let ee=ki(ye);w.push(E?" private constructor();":` ${x?"protected ":""}constructor${ee};`)}else if(I("get"))if(c+=3,O(),c<f&&Wo(s.charCodeAt(c))){let ye=Vr();if(ye.startsWith("#")){if(O(),c<f&&s.charCodeAt(c)===$e)ii();if(O(),nr(),O(),c<f&&s.charCodeAt(c)===ne)M(ne,he);else if(c<f&&s.charCodeAt(c)===Ce)c++;continue}O(),ii(),O();let ee=nr(),te;if(O(),c<f&&s.charCodeAt(c)===ne){let Se=c+1;if(M(ne,he),!ee&&!a)te=s.slice(Se,c-1),ee=Kt(te,!1,"()",(ze)=>W(ze,S))}else if(c<f&&s.charCodeAt(c)===Ce)c++;let ft=H.length;if(H.push(`${se}get ${ye}(): ${te?zt(ee):ee||"unknown"};`),te)g.pending.push(()=>{let Se=Kt(te,!1,"()",(ze)=>W(ze,S));H[ft]=`${se}get ${ye}(): ${zt(Se)};`})}else Xa("get",se,S,N,L,H);else if(I("set"))if(c+=3,O(),c<f&&Wo(s.charCodeAt(c))){let ye=Vr();if(ye.startsWith("#")){if(O(),c<f&&s.charCodeAt(c)===$e)ii();if(O(),c<f&&s.charCodeAt(c)===ne)M(ne,he);else if(c<f&&s.charCodeAt(c)===Ce)c++;continue}O();let ee=ii();if(O(),c<f&&s.charCodeAt(c)===ne)M(ne,he);else if(c<f&&s.charCodeAt(c)===Ce)c++;let te=ki(ee);H.push(`${se}set ${ye}${te};`)}else Xa("set",se,S,N,L,H);else{let ye=s.charCodeAt(c)===We;if(ye)c++,O();let ee=Vr();if(!ee){Ya();continue}Za(ee,se,S,N,ye,D,L,H)}}for(let E of g.pending)E();return b.pop(),`{
133
133
  ${w.join(`
134
134
  `)}
135
- }`}function No(g){return dt(g)||g===Ve||g===Ac||g===Re||g===Ie}function Vr(){if(c>=f)return"";let g=s.charCodeAt(c);if(g===Ve){let w=c;return M(Ve,qe),s.slice(w,c)}if(g===Ac)return c++,`#${ie()}`;if(g===Re||g===Ie){let w=c;return ae(g),s.slice(w,c)}return ie()}function Ur(g){let w=c;c+=g.length,O();let y=c<f?s.charCodeAt(c):0;return c=w,y}function Ja(){let g=0;while(c<f){if(ve())continue;let w=s.charCodeAt(c);if(w===ne||w===$e)g++;else if(w===he||w===Me){if(g===0)return;g--}else if(w===Ce&&g===0){c++;return}if(g===0&&xe())return;c++}}function Ya(g,w,y,E,x,S){Xa(g,w,y,E,!1,!1,x,S)}function Xa(g,w,y,E,x,S,D,N){let F=Do;if(Do=void 0,O(),c>=f)return;let P=s.charCodeAt(c),L=!1;if(P===An)L=!0,c++,O();if(c<f&&s.charCodeAt(c)===33)c++,O();let J=c<f?s.charCodeAt(c):0;if(J===$e||J===Fe){let q=J===Fe?Ft():"";O();let Z=ii();O();let U=rr(),H,se=U.length>0;if(!U)if(D&&x)U="AsyncGenerator<unknown, void, unknown>";else if(x)U="Generator<unknown, void, unknown>";else if(D)U="Promise<void>";else U="void";if(O(),c<f&&s.charCodeAt(c)===ne){let ft=c+1;if(M(ne,he),!se&&!x)H=s.slice(ft,c-1),U=Kt(H,D,Z,(Se)=>W(Se,y))}else if(c<f&&s.charCodeAt(c)===Ce)c++;let ye=Ai(Z),ee=L?"?":"",te=N.length;if(N.push(`${w}${g}${ee}${q}${ye}: ${H?zt(U):U};`),H)b.at(-1)?.pending.push(()=>{let ft=Kt(H,D,Z,(Se)=>W(Se,y));N[te]=`${w}${g}${ee}${q}${ye}: ${zt(ft)};`})}else if(J===At||J===je||J===Ce||J===he||J===Ne||J===Ge){let q="";if(J===At){c++,O();let ye=c,ee=0;while(c<f){if(ve())continue;let te=s.charCodeAt(c);if(te===$e||te===ne||te===Ve||te===Fe)ee++;else if(te===Me||te===he||te===qe||te===De&&!_()){if(ee===0)break;ee--}else if(ee===0&&(te===Ce||te===Dt))break;else if(ee===0&&te===je&&!G())break;if(ee===0&&xe())break;c++}q=R(ye,c)}let Z="";if(c<f&&s.charCodeAt(c)===je)if(a&&q){c++;let ye=0;while(c<f){if(ve())continue;let ee=s.charCodeAt(c);if(ee===$e||ee===ne||ee===Ve)ye++;else if(ee===Me||ee===he||ee===qe){if(ye===0&&ee===he)break;ye--}else if(ye===0&&ee===Ce)break;if(ye===0&&xe())break;c++}}else{c++,O();let ye=c,ee=0;while(c<f){if(ve())continue;let te=s.charCodeAt(c);if(te===$e||te===ne||te===Ve)ee++;else if(te===Me||te===he||te===qe){if(ee===0&&te===he)break;ee--}else if(ee===0&&te===Ce)break;if(ee===0&&xe())break;c++}Z=R(ye,c)}if(c<f&&s.charCodeAt(c)===Ce)c++;let U=q.length>0;if(!q)if(Z){let ye=Gr(Z);if(ye)q=ye;else q=Z.endsWith("as const")||y&&E?Oo(Z):ir(Z)}else q="unknown";let H=L?"?":"";b.at(-1)?.fields.set(`${y?"static:":""}${g}`,L?`(${q}) | undefined`:q);let se=l&&!U&&Z?ws(F,Z,q):"";N.push(`${se}${w}${g}${H}: ${q};`)}else Ja()}function qd(g){let w=0;for(let y=0;y<g.length;y++){let E=g.charCodeAt(y);if(E===$e||E===ne||E===Ve||E===Fe)w++;else if(E===Me||E===he||E===qe||E===De&&g.charCodeAt(y-1)!==je)w--;else if(E===je&&w===0&&g.charCodeAt(y+1)!==De&&g.charCodeAt(y+1)!==je)return!0}return!1}function Jd(g,w){let y=g.slice(1,-1).trim();if(!y)return;let E=[],x=0,S=0,D=!1,N=0,F=[];for(let P=0;P<=y.length;P++){if(P===y.length){F.push(y.slice(x)),E.push(jr(y.slice(x).trim()));break}let L=y.charCodeAt(P);if(D){if(L===Ct){P++;continue}if(L===N)D=!1;continue}if(L===de&&P+1<y.length){let J=y.charCodeAt(P+1);if(J===We){P+=2;while(P+1<y.length&&!(y.charCodeAt(P)===We&&y.charCodeAt(P+1)===de))P++;P++;continue}if(J===de){while(P<y.length&&y.charCodeAt(P)!==10)P++;continue}}if(L===Re||L===Ie||L===Ye){D=!0,N=L;continue}if(L===$e||L===ne||L===Ve||L===Fe)S++;else if(L===Me||L===he||L===qe||L===De&&!(P>0&&y.charCodeAt(P-1)===je))S--;else if(L===Dt&&S===0)F.push(y.slice(x,P)),E.push(jr(y.slice(x,P).trim())),x=P+1}for(let[P,L]of E.entries()){let J=L.startsWith("public ")||L.startsWith("public\t"),q=L.startsWith("protected ")||L.startsWith("protected\t"),Z=L.startsWith("private ")||L.startsWith("private\t"),U=L.includes("readonly ");if(!J&&!q&&!Z&&!U)continue;let H=L,se=[];if(Z){let Se=7;while(Se<H.length&&Ze(H.charCodeAt(Se)))Se++;H=H.slice(Se),se.push("private")}if(J){let Se=6;while(Se<H.length&&Ze(H.charCodeAt(Se)))Se++;H=H.slice(Se),se.push("public")}if(q){let Se=9;while(Se<H.length&&Ze(H.charCodeAt(Se)))Se++;H=H.slice(Se),se.push("protected")}if(U){let Se=H.indexOf("readonly ");if(Se!==-1){let ze=Se+8;while(ze<H.length&&Ze(H.charCodeAt(ze)))ze++;H=H.slice(0,Se)+H.slice(ze)}se.push("readonly")}let ye=se.length>0?`${se.join(" ")} `:"",ee=Ka(H),te=H.search(/[?:=]/);if(te!==-1&&H.charCodeAt(te)!==63&&qd(H))ee=ee.replace(/^([\w$]+)\?:/,"$1:");let ft="";if(l&&!Z&&te!==-1&&H.charCodeAt(te)===je){let Se=H.slice(te+1);ft=ws(oc(F[P]),Se,ir(Se))}w.push(Z?` private ${ee.split(/[?:]/,1)[0]};`:`${ft} ${ye}${ee};`)}}function Fo(g=" "){if(c>=f||s.charCodeAt(c)!==ne)return"{}";c++;let w=[];while(c<f){if(O(),c>=f)break;if(s.charCodeAt(c)===he){c++;break}if(s.charCodeAt(c)===Ce){c++;continue}let y=!1;if(I("export"))y=!0,c+=6,O();if(I("declare"))c+=7,O();let E=y?"export ":"";if(I("function")||I("async")&&Yd("async","function")){let x=!1;if(I("async"))x=!0,c+=5,O();if(c+=8,O(),c<f&&s.charCodeAt(c)===We)c++,O();let S=ie();O();let D=Ft();O();let N=ii();O();let F=rr();if(!F)F=x?"Promise<void>":"void";if(O(),c<f&&s.charCodeAt(c)===ne)M(ne,he);else if(c<f&&s.charCodeAt(c)===Ce)c++;let P=Ai(N);w.push(`${g}${E}function ${S}${D}${P}: ${F};`)}else if(I("const")||I("let")||I("var")){let x=I("const")?"const":I("let")?"let":"var";c+=x.length,O();let S=ie();if(!S){re(!0);continue}O();let D="";if(c<f&&s.charCodeAt(c)===At){c++,O();let F=c,P=0;while(c<f){if(ve())continue;let L=s.charCodeAt(c);if(L===$e||L===ne||L===Ve||L===Fe)P++;else if(L===he&&P===0)break;else if(L===Me||L===he||L===qe||L===De&&!_())P--;else if(P===0&&(L===Ce||L===Dt))break;else if(P===0&&L===je&&!G())break;if(P===0&&ue())break;c++}D=R(F,c)}let N="";if(c<f&&s.charCodeAt(c)===je){c++,O();let F=c,P=0;while(c<f){if(ve())continue;let L=s.charCodeAt(c);if(L===$e||L===ne||L===Ve||L===Fe)P++;else if(L===he&&P===0)break;else if(L===Me||L===he||L===qe||L===De&&!_())P--;else if(P===0&&(L===Ce||L===Dt))break;if(P===0&&ue())break;c++}N=R(F,c)}if(c<f&&s.charCodeAt(c)===Ce)c++;if(!D&&N){let F=Gr(N);if(F)D=F;else if(x==="const")D=Oo(N);else D=ir(N)}if(!D)D="unknown";w.push(`${g}${E}${x} ${S}: ${D};`)}else if(I("interface")){c+=9,O();let x=ie();O();let S=Ft();O();let D="";if(I("extends")){c+=7,O();let F=c,P=0;while(c<f){if(ve())continue;let L=s.charCodeAt(c);if(L===Fe)P++;else if(L===De&&!_())P--;else if(L===ne&&P===0)break;c++}D=R(F,c)}let N=za(To());w.push(`${g}${E}interface ${x}${S}${D?` extends ${D}`:""} ${N}`)}else if(I("type")){c+=4,O();let x=ie();O();let S=Ft();if(O(),c<f&&s.charCodeAt(c)===je){c++,O();let D=c,N=0;while(c<f){if(ve())continue;let P=s.charCodeAt(c);if(P===$e||P===ne||P===Ve||P===Fe)N++;else if(P===he&&N===0)break;else if(P===Me||P===he||P===qe||P===De&&!_())N--;else if(N===0&&P===Ce)break;if(N===0&&ue())break;c++}let F=R(D,c);if(c<f&&s.charCodeAt(c)===Ce)c++;w.push(`${g}${E}type ${x}${S} = ${F}`)}}else if(I("class")){c+=5,O();let x=ie();O();let S=Ft();O();let D=c,N=0;while(c<f){if(ve())continue;let J=s.charCodeAt(c);if(J===Fe)N++;else if(J===De&&!_())N--;else if(J===ne&&N===0)break;c++}let F=R(D,c),P=F?` ${F}`:"",L=Io();w.push(`${g}${E}class ${x}${S}${P} ${L}`)}else if(I("enum")){c+=4,O();let x=ie();O();let S=To();w.push(`${g}${E}enum ${x} ${S}`)}else if(I("namespace")||I("module")){let x=I("namespace")?"namespace":"module";c+=x.length,O();let S=ie();O();let D=Fo(g);w.push(`${g}${E}${x} ${S} ${D}`)}else if(I("abstract"))if(c+=8,O(),I("class")){c+=5,O();let x=ie();O();let S=Ft();O();let D=c,N=0;while(c<f){if(ve())continue;let J=s.charCodeAt(c);if(J===Fe)N++;else if(J===De&&!_())N--;else if(J===ne&&N===0)break;c++}let F=R(D,c),P=F?` ${F}`:"",L=Io();w.push(`${g}${E}abstract class ${x}${S}${P} ${L}`)}else re(!0);else if(y&&I("default")){c+=7,O();let x=c;re(!0);let S=R(x,c);if(S.charCodeAt(S.length-1)===Ce)S=S.slice(0,-1);if(S)w.push(`${g}export default ${S};`)}else if(!y&&(s.charCodeAt(c)===Re||s.charCodeAt(c)===Ie||s.charCodeAt(c)===Ye))re(!0);else re(!0)}if(w.length===0)return"{}";return`{
135
+ }`}function Wo(g){return dt(g)||g===Ve||g===Ac||g===Re||g===Ie}function Vr(){if(c>=f)return"";let g=s.charCodeAt(c);if(g===Ve){let w=c;return M(Ve,qe),s.slice(w,c)}if(g===Ac)return c++,`#${ie()}`;if(g===Re||g===Ie){let w=c;return ae(g),s.slice(w,c)}return ie()}function Ur(g){let w=c;c+=g.length,O();let y=c<f?s.charCodeAt(c):0;return c=w,y}function Ya(){let g=0;while(c<f){if(ve())continue;let w=s.charCodeAt(c);if(w===ne||w===$e)g++;else if(w===he||w===Me){if(g===0)return;g--}else if(w===Ce&&g===0){c++;return}if(g===0&&xe())return;c++}}function Xa(g,w,y,E,x,S){Za(g,w,y,E,!1,!1,x,S)}function Za(g,w,y,E,x,S,D,N){let F=No;if(No=void 0,O(),c>=f)return;let P=s.charCodeAt(c),L=!1;if(P===Tn)L=!0,c++,O();if(c<f&&s.charCodeAt(c)===33)c++,O();let J=c<f?s.charCodeAt(c):0;if(J===$e||J===Fe){let q=J===Fe?Ft():"";O();let Z=ii();O();let U=nr(),H,se=U.length>0;if(!U)if(D&&x)U="AsyncGenerator<unknown, void, unknown>";else if(x)U="Generator<unknown, void, unknown>";else if(D)U="Promise<void>";else U="void";if(O(),c<f&&s.charCodeAt(c)===ne){let ft=c+1;if(M(ne,he),!se&&!x)H=s.slice(ft,c-1),U=Kt(H,D,Z,(Se)=>W(Se,y))}else if(c<f&&s.charCodeAt(c)===Ce)c++;let ye=ki(Z),ee=L?"?":"",te=N.length;if(N.push(`${w}${g}${ee}${q}${ye}: ${H?zt(U):U};`),H)b.at(-1)?.pending.push(()=>{let ft=Kt(H,D,Z,(Se)=>W(Se,y));N[te]=`${w}${g}${ee}${q}${ye}: ${zt(ft)};`})}else if(J===At||J===je||J===Ce||J===he||J===Ne||J===Ge){let q="";if(J===At){c++,O();let ye=c,ee=0;while(c<f){if(ve())continue;let te=s.charCodeAt(c);if(te===$e||te===ne||te===Ve||te===Fe)ee++;else if(te===Me||te===he||te===qe||te===De&&!_()){if(ee===0)break;ee--}else if(ee===0&&(te===Ce||te===Dt))break;else if(ee===0&&te===je&&!G())break;if(ee===0&&xe())break;c++}q=R(ye,c)}let Z="";if(c<f&&s.charCodeAt(c)===je)if(a&&q){c++;let ye=0;while(c<f){if(ve())continue;let ee=s.charCodeAt(c);if(ee===$e||ee===ne||ee===Ve)ye++;else if(ee===Me||ee===he||ee===qe){if(ye===0&&ee===he)break;ye--}else if(ye===0&&ee===Ce)break;if(ye===0&&xe())break;c++}}else{c++,O();let ye=c,ee=0;while(c<f){if(ve())continue;let te=s.charCodeAt(c);if(te===$e||te===ne||te===Ve)ee++;else if(te===Me||te===he||te===qe){if(ee===0&&te===he)break;ee--}else if(ee===0&&te===Ce)break;if(ee===0&&xe())break;c++}Z=R(ye,c)}if(c<f&&s.charCodeAt(c)===Ce)c++;let U=q.length>0;if(!q)if(Z){let ye=Gr(Z);if(ye)q=ye;else q=Z.endsWith("as const")||y&&E?Po(Z):rr(Z)}else q="unknown";let H=L?"?":"";b.at(-1)?.fields.set(`${y?"static:":""}${g}`,L?`(${q}) | undefined`:q);let se=l&&!U&&Z?Cs(F,Z,q):"";N.push(`${se}${w}${g}${H}: ${q};`)}else Ya()}function qd(g){let w=0;for(let y=0;y<g.length;y++){let E=g.charCodeAt(y);if(E===$e||E===ne||E===Ve||E===Fe)w++;else if(E===Me||E===he||E===qe||E===De&&g.charCodeAt(y-1)!==je)w--;else if(E===je&&w===0&&g.charCodeAt(y+1)!==De&&g.charCodeAt(y+1)!==je)return!0}return!1}function Jd(g,w){let y=g.slice(1,-1).trim();if(!y)return;let E=[],x=0,S=0,D=!1,N=0,F=[];for(let P=0;P<=y.length;P++){if(P===y.length){F.push(y.slice(x)),E.push(jr(y.slice(x).trim()));break}let L=y.charCodeAt(P);if(D){if(L===Ct){P++;continue}if(L===N)D=!1;continue}if(L===de&&P+1<y.length){let J=y.charCodeAt(P+1);if(J===We){P+=2;while(P+1<y.length&&!(y.charCodeAt(P)===We&&y.charCodeAt(P+1)===de))P++;P++;continue}if(J===de){while(P<y.length&&y.charCodeAt(P)!==10)P++;continue}}if(L===Re||L===Ie||L===Ye){D=!0,N=L;continue}if(L===$e||L===ne||L===Ve||L===Fe)S++;else if(L===Me||L===he||L===qe||L===De&&!(P>0&&y.charCodeAt(P-1)===je))S--;else if(L===Dt&&S===0)F.push(y.slice(x,P)),E.push(jr(y.slice(x,P).trim())),x=P+1}for(let[P,L]of E.entries()){let J=L.startsWith("public ")||L.startsWith("public\t"),q=L.startsWith("protected ")||L.startsWith("protected\t"),Z=L.startsWith("private ")||L.startsWith("private\t"),U=L.includes("readonly ");if(!J&&!q&&!Z&&!U)continue;let H=L,se=[];if(Z){let Se=7;while(Se<H.length&&Ze(H.charCodeAt(Se)))Se++;H=H.slice(Se),se.push("private")}if(J){let Se=6;while(Se<H.length&&Ze(H.charCodeAt(Se)))Se++;H=H.slice(Se),se.push("public")}if(q){let Se=9;while(Se<H.length&&Ze(H.charCodeAt(Se)))Se++;H=H.slice(Se),se.push("protected")}if(U){let Se=H.indexOf("readonly ");if(Se!==-1){let ze=Se+8;while(ze<H.length&&Ze(H.charCodeAt(ze)))ze++;H=H.slice(0,Se)+H.slice(ze)}se.push("readonly")}let ye=se.length>0?`${se.join(" ")} `:"",ee=Ha(H),te=H.search(/[?:=]/);if(te!==-1&&H.charCodeAt(te)!==63&&qd(H))ee=ee.replace(/^([\w$]+)\?:/,"$1:");let ft="";if(l&&!Z&&te!==-1&&H.charCodeAt(te)===je){let Se=H.slice(te+1);ft=Cs(oc(F[P]),Se,rr(Se))}w.push(Z?` private ${ee.split(/[?:]/,1)[0]};`:`${ft} ${ye}${ee};`)}}function Lo(g=" "){if(c>=f||s.charCodeAt(c)!==ne)return"{}";c++;let w=[];while(c<f){if(O(),c>=f)break;if(s.charCodeAt(c)===he){c++;break}if(s.charCodeAt(c)===Ce){c++;continue}let y=!1;if(I("export"))y=!0,c+=6,O();if(I("declare"))c+=7,O();let E=y?"export ":"";if(I("function")||I("async")&&Yd("async","function")){let x=!1;if(I("async"))x=!0,c+=5,O();if(c+=8,O(),c<f&&s.charCodeAt(c)===We)c++,O();let S=ie();O();let D=Ft();O();let N=ii();O();let F=nr();if(!F)F=x?"Promise<void>":"void";if(O(),c<f&&s.charCodeAt(c)===ne)M(ne,he);else if(c<f&&s.charCodeAt(c)===Ce)c++;let P=ki(N);w.push(`${g}${E}function ${S}${D}${P}: ${F};`)}else if(I("const")||I("let")||I("var")){let x=I("const")?"const":I("let")?"let":"var";c+=x.length,O();let S=ie();if(!S){re(!0);continue}O();let D="";if(c<f&&s.charCodeAt(c)===At){c++,O();let F=c,P=0;while(c<f){if(ve())continue;let L=s.charCodeAt(c);if(L===$e||L===ne||L===Ve||L===Fe)P++;else if(L===he&&P===0)break;else if(L===Me||L===he||L===qe||L===De&&!_())P--;else if(P===0&&(L===Ce||L===Dt))break;else if(P===0&&L===je&&!G())break;if(P===0&&ue())break;c++}D=R(F,c)}let N="";if(c<f&&s.charCodeAt(c)===je){c++,O();let F=c,P=0;while(c<f){if(ve())continue;let L=s.charCodeAt(c);if(L===$e||L===ne||L===Ve||L===Fe)P++;else if(L===he&&P===0)break;else if(L===Me||L===he||L===qe||L===De&&!_())P--;else if(P===0&&(L===Ce||L===Dt))break;if(P===0&&ue())break;c++}N=R(F,c)}if(c<f&&s.charCodeAt(c)===Ce)c++;if(!D&&N){let F=Gr(N);if(F)D=F;else if(x==="const")D=Po(N);else D=rr(N)}if(!D)D="unknown";w.push(`${g}${E}${x} ${S}: ${D};`)}else if(I("interface")){c+=9,O();let x=ie();O();let S=Ft();O();let D="";if(I("extends")){c+=7,O();let F=c,P=0;while(c<f){if(ve())continue;let L=s.charCodeAt(c);if(L===Fe)P++;else if(L===De&&!_())P--;else if(L===ne&&P===0)break;c++}D=R(F,c)}let N=Ka(Ro());w.push(`${g}${E}interface ${x}${S}${D?` extends ${D}`:""} ${N}`)}else if(I("type")){c+=4,O();let x=ie();O();let S=Ft();if(O(),c<f&&s.charCodeAt(c)===je){c++,O();let D=c,N=0;while(c<f){if(ve())continue;let P=s.charCodeAt(c);if(P===$e||P===ne||P===Ve||P===Fe)N++;else if(P===he&&N===0)break;else if(P===Me||P===he||P===qe||P===De&&!_())N--;else if(N===0&&P===Ce)break;if(N===0&&ue())break;c++}let F=R(D,c);if(c<f&&s.charCodeAt(c)===Ce)c++;w.push(`${g}${E}type ${x}${S} = ${F}`)}}else if(I("class")){c+=5,O();let x=ie();O();let S=Ft();O();let D=c,N=0;while(c<f){if(ve())continue;let J=s.charCodeAt(c);if(J===Fe)N++;else if(J===De&&!_())N--;else if(J===ne&&N===0)break;c++}let F=R(D,c),P=F?` ${F}`:"",L=Fo();w.push(`${g}${E}class ${x}${S}${P} ${L}`)}else if(I("enum")){c+=4,O();let x=ie();O();let S=Ro();w.push(`${g}${E}enum ${x} ${S}`)}else if(I("namespace")||I("module")){let x=I("namespace")?"namespace":"module";c+=x.length,O();let S=ie();O();let D=Lo(g);w.push(`${g}${E}${x} ${S} ${D}`)}else if(I("abstract"))if(c+=8,O(),I("class")){c+=5,O();let x=ie();O();let S=Ft();O();let D=c,N=0;while(c<f){if(ve())continue;let J=s.charCodeAt(c);if(J===Fe)N++;else if(J===De&&!_())N--;else if(J===ne&&N===0)break;c++}let F=R(D,c),P=F?` ${F}`:"",L=Fo();w.push(`${g}${E}abstract class ${x}${S}${P} ${L}`)}else re(!0);else if(y&&I("default")){c+=7,O();let x=c;re(!0);let S=R(x,c);if(S.charCodeAt(S.length-1)===Ce)S=S.slice(0,-1);if(S)w.push(`${g}export default ${S};`)}else if(!y&&(s.charCodeAt(c)===Re||s.charCodeAt(c)===Ie||s.charCodeAt(c)===Ye))re(!0);else re(!0)}if(w.length===0)return"{}";return`{
136
136
  ${w.join(`
137
137
  `)}
138
- }`}function Yd(g,w){let y=c+g.length;while(y<f&&Ze(s.charCodeAt(y)))y++;for(let E=0;E<w.length;E++)if(y+E>=f||s.charCodeAt(y+E)!==w.charCodeAt(E))return!1;return y+w.length>=f||!He(s.charCodeAt(y+w.length))}function Ti(g,w,y){c+=y.length,O();let E="",x=s.charCodeAt(c);if(x===Re||x===Ie){let P=c;ae(x),E=s.slice(P,c)}else{E=ie();while(c<f&&s.charCodeAt(c)===_t)c++,E+=`.${ie()}`}O();let S=c<f&&s.charCodeAt(c)===ne?Fo():"{}",D=`${w?"export ":""}declare ${y} ${E} ${S}`,N=yt(g),F=E.startsWith("'")||E.startsWith('"');return{kind:"module",name:E,text:D,isExported:w,moduleForm:F?"quoted":y==="namespace"?"namespace":"identifier",source:F?E.slice(1,-1):void 0,leadingComments:N,start:g,end:c}}function Za(g,w){re();let y=R(w,c);if(y.charCodeAt(y.length-1)===Ce)y=y.slice(0,-1).trimEnd();if(!y)return;let E=dt(y.charCodeAt(0));for(let P=1;E&&P<y.length;P++)E=He(y.charCodeAt(P));let x=yt(g);if(E){d.push({kind:"export",name:"default",text:`export default ${y};`,isExported:!0,isTypeOnly:!1,leadingComments:x,start:g,end:c});return}let S="__dtsx_default_export__",D=1;while(s.includes(S))S=`__dtsx_default_export_${D++}__`;let N=Gr(y)||k(y)||Te(y,!1),F=N==="unknown"&&$p(y)?`typeof ${y}`:N;d.push({kind:"variable",name:S,text:`declare const ${S}: ${F};`,isExported:!1,typeAnnotation:F,modifiers:["const"],start:g,end:c}),d.push({kind:"export",name:"default",text:`export default ${S};`,isExported:!0,isTypeOnly:!1,leadingComments:x,start:g,end:c})}function Qa(){if(s.charCodeAt(c)===ne)return M(ne,he),!0;let g=I("if"),w=I("do"),y=I("try"),E=I("for");if(!g&&!w&&!y&&!E&&!I("while")&&!I("switch")&&!I("with"))return!1;if(ie(),O(),E&&I("await"))c+=5,O();if(!w&&!y&&s.charCodeAt(c)===$e)M($e,Me);if(zr(),O(),g&&I("else"))c+=4,zr();else if(w&&I("while")){if(c+=5,O(),s.charCodeAt(c)===$e)M($e,Me);if(O(),s.charCodeAt(c)===Ce)c++}else if(y){if(I("catch")){if(c+=5,O(),s.charCodeAt(c)===$e)M($e,Me);zr(),O()}if(I("finally"))c+=7,zr()}return!0}function zr(){if(O(),!Qa())re()}while(c<f){if(O(),c>=f)break;if(Qa())continue;let g=c,w=s.charCodeAt(c);if(w===105&&I("import"))d.push(jd(g));else if(w===101&&I("export")){c+=6,O();let y=s.charCodeAt(c);if(y===100&&I("default")){c+=7,O();let E=c,x=s.charCodeAt(c);if(x===102&&I("function")){let S=ri(g,!0,!1,!0);if(S)d.push(S)}else if(x===97&&I("async")&&Ur("async")!==Ce)if(c+=5,O(),I("function")){let S=ri(g,!0,!0,!0);if(S)d.push(S)}else Za(g,E);else if(x===99&&I("class")){let S=ni(g,!0,!1,!0);d.push(S)}else if(x===97&&I("abstract")){if(c+=8,O(),I("class")){let S=ni(g,!0,!0,!0);d.push(S)}}else Za(g,E)}else if(y===116&&I("type")){let E=c;if(c+=4,O(),c<f&&s.charCodeAt(c)===ne){Ot();let x=R(g,c),S=yt(g);d.push({kind:"export",name:"",text:x,isExported:!0,isTypeOnly:!0,source:ct(x),leadingComments:S,start:g,end:c})}else if(c<f&&s.charCodeAt(c)===We){Ut();let x=R(g,c);d.push({kind:"export",name:"",text:x,isExported:!0,isTypeOnly:!0,source:ct(x),start:g,end:c})}else{c=E;let x=Mo(g,!0);d.push(x)}}else if(y===105&&I("interface")){let E=Po(g,!0);d.push(E)}else if(y===102&&I("function")){let E=ri(g,!0,!1,!1);if(E)d.push(E)}else if(y===97&&I("async"))if(c+=5,O(),I("function")){let E=ri(g,!0,!0,!1);if(E)d.push(E)}else re();else if(y===99)if(I("class")){let E=ni(g,!0,!1);d.push(E)}else if(I("const")){let E=c;if(c+=5,O(),I("enum")){c=E+5,O();let x=ki(g,!0,!0);d.push(x)}else{c=E;let x=pi(g,"const",!0);for(let S=0;S<x.length;S++)d.push(x[S])}}else re();else if(y===97&&I("abstract")){if(c+=8,O(),I("class")){let E=ni(g,!0,!0);d.push(E)}}else if(y===108&&I("let")){let E=pi(g,"let",!0);for(let x=0;x<E.length;x++)d.push(E[x])}else if(y===118&&I("var")){let E=pi(g,"var",!0);for(let x=0;x<E.length;x++)d.push(E[x])}else if(y===101&&I("enum")){let E=ki(g,!0,!1);d.push(E)}else if(y===100&&I("declare"))c+=7,O(),tl(g,!0);else if(y===110&&I("namespace")&&K(9)){let E=Ti(g,!0,"namespace");d.push(E)}else if(y===109&&I("module")&&K(6)){let E=Ti(g,!0,"module");d.push(E)}else if(y===ne){Ot();let E=R(g,c),x=E.includes("export type"),S=yt(g);d.push({kind:"export",name:"",text:E,isExported:!0,isTypeOnly:x,source:ct(E),leadingComments:S,start:g,end:c})}else if(y===We){Ut();let E=R(g,c),x=yt(g);d.push({kind:"export",name:"",text:E,isExported:!0,isTypeOnly:!1,source:ct(E),leadingComments:x,start:g,end:c})}else{re();let E=R(g,c);if(E)d.push({kind:"export",name:"",text:E,isExported:!0,start:g,end:c})}}else if(w===100&&I("declare"))c+=7,O(),tl(g,!1);else if(w===105&&I("interface")){let y=Po(g,!1);h.set(y.name,y)}else if(w===116&&I("type")){let y=Mo(g,!1);h.set(y.name,y),d.push(y)}else if(w===102&&I("function")){let y=ri(g,!1,!1,!1);if(y)A(y);else re()}else if(w===97)if(I("async")){let y=c;if(c+=5,O(),I("function")){let E=ri(g,!1,!0,!1);if(E)A(E);else c=y,re()}else c=y,re()}else if(I("abstract"))if(c+=8,O(),I("class")){let y=ni(g,!1,!1);h.set(y.name,y),d.push(y)}else re();else c++,re();else if(w===99)if(I("class")){let y=ni(g,!1,!1);h.set(y.name,y),d.push(y)}else if(I("const")){let y=c;if(c+=5,O(),I("enum")){c=y+5,O();let E=ki(g,!1,!0);h.set(E.name,E),d.push(E)}else{c=y;let E=pi(g,"const",!1);for(let x=0;x<E.length;x++)h.set(E[x].name,E[x])}}else c++,re();else if(w===101&&I("enum")){let y=ki(g,!1,!1);h.set(y.name,y),d.push(y)}else if(w===108&&I("let")||w===118&&I("var")){let y=I("let")?"let":"var",E=pi(g,y,!1);for(let x=0;x<E.length;x++)h.set(E[x].name,E[x])}else if(w===109&&I("module")&&K(6)){let y=Ti(g,!1,"module");d.push(y)}else if(w===110&&I("namespace")&&K(9)){let y=Ti(g,!1,"namespace");d.push(y)}else{let y=s.charCodeAt(c);if(y===Ce)c++;else if(y===Re||y===Ie){if(ae(y),c<f&&s.charCodeAt(c)===Ce)c++}else if(y===Ye){if(be(),c<f&&s.charCodeAt(c)===Ce)c++}else if(y===vp){if(c++,ie(),O(),c<f&&s.charCodeAt(c)===_t)c++,ie(),O();if(c<f&&s.charCodeAt(c)===$e)M($e,Me)}else c++,re()}}if(m.size>0){el(d);for(let g of p.values())el(g)}if(fc(s,d,h,p),Nl(d,h),Al(d,h),!a)xc(s,d,h,o);if(n){let g=new Set(d);for(let w of[...h.values(),...[...p.values()].flat()])if(!g.has(w))d.push(w),g.add(w);return d.sort((w,y)=>(w.start??0)-(y.start??0))}if(h.size>0)xp(d,h,p);return d;function el(g){let w=new Map;for(let E of g)if(E.kind==="function")w.set(E.name,(w.get(E.name)||0)+1);let y=new Set;for(let[E,x]of w)if(x>1)y.add(E);if(y.size>0){let E=new Set;for(let x of y)for(let S=g.length-1;S>=0;S--)if(g[S].kind==="function"&&g[S].name===x&&m.has(g[S])){E.add(S);break}if(E.size>0){let x=[...E].sort((S,D)=>D-S);for(let S of x)g.splice(S,1)}}}function tl(g,w){if(I("function")){let y=ri(g,w,!1,!1);if(y)d.push(y)}else if(I("async")){if(c+=5,O(),I("function")){let y=ri(g,w,!0,!1);if(y)d.push(y)}}else if(I("class")){let y=ni(g,w,!1);d.push(y)}else if(I("abstract")){if(c+=8,O(),I("class")){let y=ni(g,w,!0);d.push(y)}}else if(I("interface")){let y=Po(g,w);d.push(y)}else if(I("type")){let y=Mo(g,w);d.push(y)}else if(I("enum")){let y=ki(g,w,!1);d.push(y)}else if(I("const")){let y=c;if(c+=5,O(),I("enum")){c=y+5,O();let E=ki(g,w,!0);d.push(E)}else{c=y;let E=pi(g,"const",w);for(let x=0;x<E.length;x++)if(w||!u)d.push(E[x]);else h.set(E[x].name,E[x])}}else if(I("let")||I("var")){let y=I("let")?"let":"var",E=pi(g,y,w);for(let x=0;x<E.length;x++)if(w||!u)d.push(E[x]);else h.set(E[x].name,E[x])}else if(I("module")){let y=Ti(g,w,"module");d.push(y)}else if(I("namespace")){let y=Ti(g,w,"namespace");d.push(y)}else if(I("global")){c+=6,O();let y=`declare global ${c<f&&s.charCodeAt(c)===ne?Fo():"{}"}`,E=yt(g);d.push({kind:"module",name:"global",text:y,isExported:!1,moduleForm:"global",leadingComments:E,start:g,end:c})}else re()}}class Tc{names;lengths=new Uint8Array(65);firstUnits=new Uint8Array(65536);size;constructor(e){this.names=e;for(let t of e.keys()){if(!t)continue;this.lengths[Math.min(t.length,64)]=1,this.firstUnits[t.charCodeAt(0)]=1}this.size=e.size}scan(e,t){if(this.size===0)return!1;let i=!1,r=0,n=e.length;while(r<n){let o=e.charCodeAt(r);if(o>=65&&o<=90||o>=97&&o<=122||o===95||o===36||o>127){let s=r;r++;while(r<n){let l=e.charCodeAt(r);if(l>=65&&l<=90||l>=97&&l<=122||l>=48&&l<=57||l===95||l===36||l>127)r++;else break}if(this.firstUnits[o]===1&&this.lengths[Math.min(r-s,64)]===1){let l=e.substring(s,r),a=this.names.get(l);if(a!==void 0){if(t.add(l),a.kind==="function"||a.kind==="variable")i=!0}}}else r++}return i}}function kc(e,t){let i=0;while(i<e.length){let r=e.charCodeAt(i);if(r===Re||r===Ie||r===Ye){let u=r;i++;while(i<e.length)if(e.charCodeAt(i)===Ct)i+=2;else if(e.charCodeAt(i++)===u)break;continue}if(r===de&&e.charCodeAt(i+1)===de){i+=2;while(i<e.length&&e.charCodeAt(i)!==Ne&&e.charCodeAt(i)!==Ge)i++;continue}if(r===de&&e.charCodeAt(i+1)===We){let u=e.indexOf("*/",i+2);i=u===-1?e.length:u+2;continue}if(!dt(r)){i++;continue}let n=i++;while(i<e.length&&He(e.charCodeAt(i)))i++;let o=n-1,s=i;while(o>=0&&Ze(e.charCodeAt(o)))o--;while(s<e.length&&Ze(e.charCodeAt(s)))s++;let l=o>=0?e.charCodeAt(o):0,a=s<e.length?e.charCodeAt(s):0,f=n>=3&&e.slice(n-3,n)==="...";if(a===At||l===_t&&!f)continue;if(a===$e&&(l===ne||l===Dt))continue;t.add(e.slice(n,i))}}function xp(e,t,i){let r=new Set,n=new Set;for(let u of e)n.add(u.name);let o=new Tc(t),s=new Set,l=new Set,a=(u)=>{if(o.scan(u.text,s))Il(u,l)},f=new Set;for(let u=0;u<e.length;u++){let d=e[u];if(d.kind!=="import"){if(a(d),typeof d.value==="string")kc(d.value,f)}}for(;;){let u=[];for(let[p,m]of t){if(r.has(p))continue;if((m.kind==="function"||m.kind==="variable"?l:s).has(p)||m.kind!=="function"&&f.has(p)){if(!n.has(p)){let c=m.kind==="function"?i.get(p):void 0;if(c)for(let v of c)u.push(v);else u.push(m);n.add(p)}r.add(p)}}if(u.length===0)break;u.sort((p,m)=>(p.start??1/0)-(m.start??1/0));let d=[],h=0;for(let p=0;p<e.length;p++){let m=e[p].start??1/0;while(h<u.length&&(u[h].start??1/0)<=m)d.push(u[h++]);d.push(e[p])}while(h<u.length)d.push(u[h++]);e.length=0;for(let p=0;p<d.length;p++)e.push(d[p]);for(let p of u)if(p.kind!=="import"){if(a(p),typeof p.value==="string")kc(p.value,f)}}}var Qe=32,et=9,Ne=10,Ge=13,de=47,We=42,Re=39,Ie=34,Ye=96,Ct=92,ne=123,he=125,$e=40,Me=41,Ve=91,qe=93,Fe=60,De=62,Ce=59,At=58,je=61,Dt=44,_t=46,An=63,Ac=35,vp=64,bp=36,$s;var Tn=me(()=>{dr();ht();es();is();fn();hr();Fl();as();vr();dc();xn();Sc();$s=["public","protected","private","readonly","override"]});function Rc(e,t,i=!0,r=!1,n){if(Qr(t))e=rn(e);else if(on(t))e=sn(e);let o=or(e),s=`${t}:${i?1:0}:${r?1:0}:${JSON.stringify([...n??[]].sort())}`,l=Ii.get(s);if(l&&l.contentHash===o)return l.lastAccess=++Oc,l.declarations;let a=r?$r(e,t,i):kn(e,t,i,n);if(Ii.set(s,{declarations:a,contentHash:o,lastAccess:++Oc}),Ii.size>Sp){let f=Math.max(1,Math.ceil(Ii.size*0.1)),u=[];for(let[d,h]of Ii)u.push([d,h.lastAccess]);u.sort((d,h)=>d[1]-h[1]);for(let d=0;d<f&&d<u.length;d++)Ii.delete(u[d][0])}return a}var Sp=100,Oc=0,Ii;var Pc=me(()=>{nn();Qo();Bo();Tn();Ii=new Map});function On(e,t,i=!0,r=!1,n){return Rc(e,t,i,r,n)}var As=me(()=>{Pc()});function Rn(e){let t=new Set,i=[];for(let o of e)if(o.kind==="import")for(let s of vi(o.text))t.add(s);else if(o.kind!=="unknown"){if(i.push(o.text),o.kind==="variable"){if(o.typeAnnotation)i.push(o.typeAnnotation);else if(o.value)i.push(Di(o,!1))}}let r=i.join(`
139
- `),n=new Set;for(let o=0;o<r.length;){if(!dt(r.charCodeAt(o))){o++;continue}let s=o++;while(o<r.length&&He(r.charCodeAt(o)))o++;let l=r.slice(s,o);if(t.has(l))n.add(l)}return{usedItems:n,referenceText:r}}var ks=me(()=>{dr();xn();$i()});function Ap(e){if(!e.includes("declare")||!e.includes("module"))return[];return Rt(e).filter((t)=>t.category==="augmentation").map((t)=>t.specifier)}function kp(e,t){let i=new Set([e]);for(let r of i)for(let n of t(r))i.add(n);return i}async function Mc(e,t,i=!1,r){let n=new Map,o=new Map;for(let u of e){let d=r?.get(u)??await vt(u);n.set(u,d);let h=Ap(d);if(h.length)o.set(u,h)}let s=new Map;if(o.size===0)return s;let l=new Map,a=(u,d)=>{let h=t(u,d);if(h.resolved)return h.resolved;if(!h.isRelative&&!h.isAlias)return`external:${u}`;return};for(let[u,d]of n){let h=On(d,u,!1,i),p=Rn(h),m={edges:[],declarations:new Set,augmentations:new Set},c=(v,b,C)=>{let k=a(v.specifier,u);if(!k)return;if(n.has(k))m.edges.push({specifier:v.specifier,target:k,import:b});if(C)m.declarations.add(k)};for(let v of h){if(v.kind!=="import")continue;let b=v.isSideEffect||vi(v.text).some((C)=>p.usedItems.has(C));for(let C of Rt(v.text))c(C,!0,!!b)}for(let v of Rt(p.referenceText))c(v,!1,!0);for(let v of o.get(u)??[]){let b=a(v,u);if(b)m.augmentations.add(b),m.declarations.add(b)}l.set(u,m)}let f=!0;while(f){f=!1;for(let[u,d]of l){let h=kp(u,(p)=>l.get(p)?.declarations??[]);for(let[p,m]of l){if(h.has(p)||!m.augmentations.size||![...m.augmentations].some((C)=>h.has(C)))continue;let c=[u],v=new Map,b=new Set([u]);for(let C of c){if(C===p)break;for(let k of l.get(C).edges){if(b.has(k.target))continue;b.add(k.target),v.set(k.target,{from:C,edge:k}),c.push(k.target)}}if(!v.has(p))continue;for(let C=p;C!==u;){let{from:k,edge:W}=v.get(C),A=l.get(k);if(W.import){let R=s.get(k);if(!R)R=new Set,s.set(k,R);R.add(W.specifier)}if(!A.declarations.has(C))A.declarations.add(C),f=!0;C=k}}}}return s}var Dc=me(()=>{sr();ht();$i();As();ks()});function Ni(e){return Ic[e]>=Ic[Pn]}function Rp(){if(!Op)return"";return`[${new Date().toISOString().slice(11,23)}] `}function Pp(e,t){let i=Rp();if(e||i)return[`${i}${e}`,...t];return t}function Fi(e,t,i){let r=Pp(t,i);if(Nc){Nc(e,...r);return}switch(e){case"debug":console.debug(...r);break;case"info":console.log(...r);break;case"warn":console.warn(...r);break;case"error":console.error(...r);break}}function Fc(e){return{debug:(...t)=>{if(Ni("debug"))Fi("debug",e,t)},info:(...t)=>{if(Ni("info"))Fi("info",e,t)},warn:(...t)=>{if(Ni("warn"))Fi("warn",e,t)},error:(...t)=>{if(Ni("error"))Fi("error",e,t)},setLevel:(t)=>{Pn=t},getLevel:()=>Pn,child:(t)=>{let i=e?`${e}:${t}`:`[${t}]`;return Fc(i)},time:(t)=>{let i=performance.now();return()=>{let r=performance.now()-i;if(Ni("debug"))Fi("debug",e,[`${t}: ${r.toFixed(2)}ms`])}},progress:(t)=>{if(Ni("info"))if(typeof process<"u"&&process.stdout?.isTTY)process.stdout.write(`\r${e} ${t}`);else Fi("info",e,[t])}}}function Ts(e){Pn=e}var Ic,Pn="info",Tp="[dtsx]",Op=!1,Nc=null,le;var Mn=me(()=>{Ic={debug:0,info:1,warn:2,error:3,silent:4};le=Fc(Tp)});function Wc(e){let t="",i=0,r=0;while(i<e.length){let n=e.charCodeAt(i);if(r){if(t+=e[i],n===92&&i+1<e.length){t+=e[i+1],i+=2;continue}if(n===r)r=0;i++;continue}if(n===34){r=n,t+=e[i++];continue}if(n===47&&e.charCodeAt(i+1)===47){i+=2;while(i<e.length&&e.charCodeAt(i)!==10&&e.charCodeAt(i)!==13)i++;continue}if(n===47&&e.charCodeAt(i+1)===42){i+=2;while(i+1<e.length&&!(e.charCodeAt(i)===42&&e.charCodeAt(i+1)===47)){if(e.charCodeAt(i)===10)t+=`
140
- `;i++}i=Math.min(i+2,e.length);continue}if(n===44){let o=i+1;while(o<e.length){while(o<e.length&&e.charCodeAt(o)<=32)o++;if(e.charCodeAt(o)===47&&e.charCodeAt(o+1)===47){o+=2;while(o<e.length&&e.charCodeAt(o)!==10&&e.charCodeAt(o)!==13)o++;continue}if(e.charCodeAt(o)===47&&e.charCodeAt(o+1)===42){o+=2;while(o+1<e.length&&!(e.charCodeAt(o)===42&&e.charCodeAt(o+1)===47))o++;o=Math.min(o+2,e.length);continue}break}let s=e.charCodeAt(o);if(s===93||s===125){i++;continue}}t+=e[i++]}return t}var Lc=()=>{};import{readFileSync as Mp,statSync as Dp}from"fs";import{readFile as Ip}from"fs/promises";import{createRequire as Np}from"module";import{dirname as Er,isAbsolute as Fp,join as Os,resolve as Rs}from"path";function Wi(e){let t=[e];if(!e.endsWith(".json"))t.push(`${e}.json`);t.push(Os(e,"tsconfig.json"));for(let i of t)try{if(Dp(i).isFile())return i}catch{}return null}function Wp(e,t){if(Fp(e)||e.startsWith("."))return Wi(Rs(Er(t),e));let i=Np(t),r=e.startsWith("@")?/^@[^/]+\/[^/]+/.exec(e)?.[0]:e.split("/")[0];if(r)for(let n of i.resolve.paths(r)??[]){let o=Wi(Os(n,r,"package.json"));if(!o)continue;let s=JSON.parse(Mp(o,"utf8"));if(e===r){if(s.tsconfig!==void 0){if(typeof s.tsconfig!=="string")throw Error(`Invalid tsconfig field in ${o}`);let a=Wi(Rs(Er(o),s.tsconfig));if(!a)throw Error(`Cannot resolve tsconfig ${JSON.stringify(s.tsconfig)} from ${o}`);return a}let l=Wi(Os(Er(o),"tsconfig.json"));if(l)return l}break}for(let n of[`${e}/tsconfig.json`,e])try{let o=i.resolve(n),s=o.endsWith(".json")?Wi(o):null;if(s)return s}catch{}return null}async function xr(e,t={},i=new Set){let r=Wi(e);if(!r)return;if(i.has(r)){if(t.allowCircular)return;throw Error(`Circular tsconfig extends: ${r}`)}let n=new Set(i).add(r),o=JSON.parse(Wc(await Ip(r,"utf8"))),s=typeof o.extends==="string"?[o.extends]:o.extends??[];if(!Array.isArray(s)||s.some((f)=>typeof f!=="string"))throw Error(`Invalid tsconfig extends in ${r}`);let l={};for(let f of s){let u=Wp(f,r);if(!u)throw Error(`Cannot resolve tsconfig extends ${JSON.stringify(f)} from ${r}`);l={...l,...await xr(u,t,n)}}let a=o.compilerOptions??{};if(a.isolatedDeclarations!==void 0)l.isolatedDeclarations=a.isolatedDeclarations;if(a.baseUrl!==void 0){if(typeof a.baseUrl!=="string")throw Error(`Invalid baseUrl in ${r}`);l.baseUrl=Rs(Er(r),a.baseUrl)}if(a.paths!==void 0){if(!a.paths||typeof a.paths!=="object"||Array.isArray(a.paths))throw Error(`Invalid paths in ${r}`);for(let[f,u]of Object.entries(a.paths))if(f.split("*").length>2||!Array.isArray(u)||u.length===0||u.some((d)=>typeof d!=="string"||d.split("*").length>2))throw Error(`Invalid path mapping ${JSON.stringify(f)} in ${r}`);l.paths=a.paths,l.pathsBasePath=Er(r)}return l}var Ps=me(()=>{Lc()});import{existsSync as Is,readFileSync as Ms,realpathSync as Sr,statSync as Lp}from"fs";import{builtinModules as Bp}from"module";import{dirname as Ns,extname as _p,isAbsolute as Fs,join as jc,relative as Gc,resolve as Li}from"path";function Dn(e){try{return Lp(e).isFile()}catch{return!1}}function Bi(e,t){let i=e.replace(/[?#].*$/,"");if(!(i.startsWith("./")||i.startsWith("../")||i==="."||i==="..")&&!Fs(i))return{resolved:null,isRelative:!1};let r=Ns(t),n=Li(r,i);if(Dn(n))return{resolved:n,isRelative:!0};let o=_p(n),s=jp[o];if(s){let l=n.slice(0,-o.length);for(let a of s){let f=l+a;if(Dn(f))return{resolved:f,isRelative:!0}}}for(let l of Bc){let a=n+l;if(Dn(a))return{resolved:a,isRelative:!0}}if(Is(n))for(let l of Bc){let a=jc(n,`index${l}`);if(Dn(a))return{resolved:a,isRelative:!0}}return{resolved:null,isRelative:!0}}function Vc(e,t){let i=e.indexOf("*");return i===-1?t===e:t.startsWith(e.slice(0,i))&&t.endsWith(e.slice(i+1))&&t.length>=e.length-1}function Uc(e,t){if(Object.hasOwn(e,t))return e[t]!==null;let i=Object.keys(e).filter((r)=>r.includes("*")&&Vc(r,t)).sort((r,n)=>n.indexOf("*")-r.indexOf("*")||n.length-r.length)[0];return i!==void 0&&e[i]!==null}function _c(e,t){if(!e.name||t!==e.name&&!t.startsWith(`${e.name}/`))return!1;if(e.exports===void 0)return!0;let i=t===e.name?".":`.${t.slice(e.name.length)}`;if(typeof e.exports==="string"||Array.isArray(e.exports))return i===".";if(!e.exports||typeof e.exports!=="object")return!1;let r=e.exports;if(!Object.keys(r).some((n)=>n.startsWith(".")))return i===".";return Uc(r,i)}function Ds(e,t){let i=Gc(e,t);return i!==".."&&!i.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!Fs(i)}async function In(e){let t=await xr(Li(e.cwd,e.tsconfigPath||"tsconfig.json")),i=Object.entries(t?.paths??{});if(i.length===0){let f=(u,d)=>Bi(u,d);return f.cacheKey=(u)=>JSON.stringify(u.map((d)=>({file:d,references:Ei(Ms(d,"utf8"),{includeImports:!0}).map((h)=>({specifier:h.specifier,resolution:f(h.specifier,d)}))}))),f}let r=t?.baseUrl??t?.pathsBasePath??e.cwd,n=Li(e.cwd,e.root),o=new Map,s=new Set([...Bp,"bun"]),l=(f)=>{let u=Ns(f),d=[];while(!0){if(o.has(u)){let m=o.get(u);for(let c of d)o.set(c,m);return m}d.push(u);let h=jc(u,"package.json");if(Is(h)){let m={...JSON.parse(Ms(h,"utf8")),directory:Sr(u)};for(let c of d)o.set(c,m);return m}let p=Ns(u);if(p===u)return;u=p}},a=(f,u)=>{if(f.startsWith(".")||Fs(f))return Bi(f,u);if(f.startsWith("node:")||f.startsWith("bun:")||s.has(f))return{resolved:null,isRelative:!1};let d=l(u),h=f.startsWith("@")?/^@[^/]+\/[^/]+/.exec(f)?.[0]:f.split("/")[0];if(d&&(_c(d,f)||Uc(d.imports??{},f)||h&&[d.dependencies,d.devDependencies,d.peerDependencies,d.optionalDependencies].some((C)=>Object.hasOwn(C??{},h))))return{resolved:null,isRelative:!1};let p=i.filter(([C])=>Vc(C,f)).sort(([C],[k])=>{if(!C.includes("*"))return-1;if(!k.includes("*"))return 1;return k.indexOf("*")-C.indexOf("*")})[0];if(!p)return{resolved:null,isRelative:!1};let[m,c]=p,v=m.indexOf("*"),b=v===-1?"":f.slice(v,f.length-(m.length-v-1));for(let C of c){let k=Li(r,C.replace("*",b)),W=l(k);if(W&&_c(W,f)&&!W.private&&W.directory!==d?.directory)return{resolved:null,isRelative:!1};let A=Bi(k,u);if(!A.resolved)continue;let R=Sr(A.resolved),V=e.outputStructure==="flat"||Is(n)&&Ds(Sr(n),R);if(!d||!Ds(d.directory,R)||!V||l(R)?.directory!==d.directory||/\.d\.(?:ts|mts|cts)$/.test(R))throw Error(`Local alias ${JSON.stringify(f)} from ${u} resolves outside its emitted package source: ${R}`);return le.debug(`Resolved local declaration alias ${f} from ${u} to ${R}`),{resolved:e.outputStructure==="flat"?A.resolved:Li(n,Gc(Sr(n),R)),isRelative:!0,isAlias:!0,suffix:k.match(/[?#].*$/)?.[0]??""}}throw Error(`Cannot resolve local alias ${JSON.stringify(f)} from ${u} using ${e.tsconfigPath||"tsconfig.json"} (${JSON.stringify(m)})`)};return a.isPackageLocal=(f,u)=>{let d=l(f);return!!d&&l(u)?.directory===d.directory&&Ds(d.directory,Sr(u))},a.cacheKey=(f)=>{let u=f.map((h)=>({file:h,references:Ei(Ms(h,"utf8"),{includeImports:!0}).map((p)=>({specifier:p.specifier,resolution:a(p.specifier,h)}))})),d=[...new Set(o.values())].filter((h)=>h!==void 0).sort((h,p)=>h.directory.localeCompare(p.directory));return JSON.stringify({root:n,compilerOptions:t,packages:d,edges:u})},a}function Ei(e,t={}){let i=Rt(e);return(t.includeImports?["export","static-import","import-type","augmentation"]:["export"]).flatMap((r)=>i.filter((n)=>n.category===r).map(({specifier:n,kind:o,isTypeOnly:s})=>({specifier:n,kind:o,isTypeOnly:s})))}function zc(e,t){let i=[];for(let n of Rt(e)){let o=t(n.specifier);if(o!==n.specifier)i.push({start:n.start,end:n.end,value:oi(o,e[n.start])})}let r=e;for(let n of i.reverse())r=r.slice(0,n.start)+n.value+r.slice(n.end);return r}async function Ar(e,t={}){let i=new Set,r=new Map,n=[],o=new Map,s=[];for(let l of e){let a=Li(l);if(!i.has(a))i.add(a),s.push(a)}while(s.length>0){let l=s.shift(),a;try{a=await vt(l)}catch{continue}o.set(l,a);let f=Ei(a,t);r.set(l,f);for(let u of f){let d=(t.resolveSpecifier??Bi)(u.specifier,l);if(!d.isRelative)continue;if(d.resolved){if(!i.has(d.resolved))i.add(d.resolved),s.push(d.resolved)}else n.push({from:l,specifier:u.specifier,isTypeOnly:u.isTypeOnly})}}return{reachable:i,reExports:r,unresolved:n,sources:o}}var Bc,jp;var Nn=me(()=>{sr();Mn();ht();Ps();Bc=[".ts",".tsx",".mts",".cts",".vue",".stx",".js",".jsx",".mjs",".cjs",".d.ts",".d.mts",".d.cts"],jp={".js":[".ts",".tsx",".d.ts"],".jsx":[".tsx",".ts",".d.ts"],".mjs":[".mts",".d.mts"],".cjs":[".cts",".d.cts"]}});import{relative as xi}from"path";function Ws(e){let t=ce(e),i=(l)=>t[l]?e.slice(t[l].start,t[l].end):"",r=i(0)==="export"?1:0;if(i(r++)!=="declare")return;let n;if(i(r)==="module"&&t[r+1]?.kind==="quoted"){if(n=wt(i(r+1)),n===void 0)return;r+=2}else if(i(r++)!=="global")return;if(i(r)!=="{")return;let o=t[r].end,s=1;for(r++;r<t.length;r++)if(i(r)==="{")s++;else if(i(r)==="}"&&--s===0)return{specifier:n,body:e.slice(o,t[r].start),start:o,end:t[r].start};return}function Vp(e){let t=[],i=[],r=0,n=0,o=[],s=!1,l=0,a=e.length,f=(u)=>{let d=e.slice(r,u).trim();if(r=u,!d)return;if(Up(d)){i.push(d);return}t.push({text:d,comments:i}),i=[]};while(l<a){let u=e[l];if(s){if(u==="\\"){l+=2;continue}if(u==="`"){s=!1,l++;continue}if(u==="$"&&e[l+1]==="{"){o.push(n),n++,s=!1,l+=2;continue}l++;continue}if(u==="/"&&e[l+1]==="*"){let d=e.indexOf("*/",l+2);l=d===-1?a:d+2;continue}if(u==="/"&&e[l+1]==="/"){let d=e.indexOf(`
138
+ }`}function Yd(g,w){let y=c+g.length;while(y<f&&Ze(s.charCodeAt(y)))y++;for(let E=0;E<w.length;E++)if(y+E>=f||s.charCodeAt(y+E)!==w.charCodeAt(E))return!1;return y+w.length>=f||!He(s.charCodeAt(y+w.length))}function Oi(g,w,y){c+=y.length,O();let E="",x=s.charCodeAt(c);if(x===Re||x===Ie){let P=c;ae(x),E=s.slice(P,c)}else{E=ie();while(c<f&&s.charCodeAt(c)===_t)c++,E+=`.${ie()}`}O();let S=c<f&&s.charCodeAt(c)===ne?Lo():"{}",D=`${w?"export ":""}declare ${y} ${E} ${S}`,N=yt(g),F=E.startsWith("'")||E.startsWith('"');return{kind:"module",name:E,text:D,isExported:w,moduleForm:F?"quoted":y==="namespace"?"namespace":"identifier",source:F?E.slice(1,-1):void 0,leadingComments:N,start:g,end:c}}function Qa(g,w){re();let y=R(w,c);if(y.charCodeAt(y.length-1)===Ce)y=y.slice(0,-1).trimEnd();if(!y)return;let E=dt(y.charCodeAt(0));for(let P=1;E&&P<y.length;P++)E=He(y.charCodeAt(P));let x=yt(g);if(E){d.push({kind:"export",name:"default",text:`export default ${y};`,isExported:!0,isTypeOnly:!1,leadingComments:x,start:g,end:c});return}let S="__dtsx_default_export__",D=1;while(s.includes(S))S=`__dtsx_default_export_${D++}__`;let N=Gr(y)||k(y)||Te(y,!1),F=N==="unknown"&&Sp(y)?`typeof ${y}`:N;d.push({kind:"variable",name:S,text:`declare const ${S}: ${F};`,isExported:!1,typeAnnotation:F,modifiers:["const"],start:g,end:c}),d.push({kind:"export",name:"default",text:`export default ${S};`,isExported:!0,isTypeOnly:!1,leadingComments:x,start:g,end:c})}function el(){if(s.charCodeAt(c)===ne)return M(ne,he),!0;let g=I("if"),w=I("do"),y=I("try"),E=I("for");if(!g&&!w&&!y&&!E&&!I("while")&&!I("switch")&&!I("with"))return!1;if(ie(),O(),E&&I("await"))c+=5,O();if(!w&&!y&&s.charCodeAt(c)===$e)M($e,Me);if(zr(),O(),g&&I("else"))c+=4,zr();else if(w&&I("while")){if(c+=5,O(),s.charCodeAt(c)===$e)M($e,Me);if(O(),s.charCodeAt(c)===Ce)c++}else if(y){if(I("catch")){if(c+=5,O(),s.charCodeAt(c)===$e)M($e,Me);zr(),O()}if(I("finally"))c+=7,zr()}return!0}function zr(){if(O(),!el())re()}while(c<f){if(O(),c>=f)break;if(el())continue;let g=c,w=s.charCodeAt(c);if(w===105&&I("import"))d.push(jd(g));else if(w===101&&I("export")){c+=6,O();let y=s.charCodeAt(c);if(y===100&&I("default")){c+=7,O();let E=c,x=s.charCodeAt(c);if(x===102&&I("function")){let S=ri(g,!0,!1,!0);if(S)d.push(S)}else if(x===97&&I("async")&&Ur("async")!==Ce)if(c+=5,O(),I("function")){let S=ri(g,!0,!0,!0);if(S)d.push(S)}else Qa(g,E);else if(x===99&&I("class")){let S=ni(g,!0,!1,!0);d.push(S)}else if(x===97&&I("abstract")){if(c+=8,O(),I("class")){let S=ni(g,!0,!0,!0);d.push(S)}}else Qa(g,E)}else if(y===116&&I("type")){let E=c;if(c+=4,O(),c<f&&s.charCodeAt(c)===ne){Ot();let x=R(g,c),S=yt(g);d.push({kind:"export",name:"",text:x,isExported:!0,isTypeOnly:!0,source:ct(x),leadingComments:S,start:g,end:c})}else if(c<f&&s.charCodeAt(c)===We){Ut();let x=R(g,c);d.push({kind:"export",name:"",text:x,isExported:!0,isTypeOnly:!0,source:ct(x),start:g,end:c})}else{c=E;let x=Io(g,!0);d.push(x)}}else if(y===105&&I("interface")){let E=Do(g,!0);d.push(E)}else if(y===102&&I("function")){let E=ri(g,!0,!1,!1);if(E)d.push(E)}else if(y===97&&I("async"))if(c+=5,O(),I("function")){let E=ri(g,!0,!0,!1);if(E)d.push(E)}else re();else if(y===99)if(I("class")){let E=ni(g,!0,!1);d.push(E)}else if(I("const")){let E=c;if(c+=5,O(),I("enum")){c=E+5,O();let x=Ti(g,!0,!0);d.push(x)}else{c=E;let x=pi(g,"const",!0);for(let S=0;S<x.length;S++)d.push(x[S])}}else re();else if(y===97&&I("abstract")){if(c+=8,O(),I("class")){let E=ni(g,!0,!0);d.push(E)}}else if(y===108&&I("let")){let E=pi(g,"let",!0);for(let x=0;x<E.length;x++)d.push(E[x])}else if(y===118&&I("var")){let E=pi(g,"var",!0);for(let x=0;x<E.length;x++)d.push(E[x])}else if(y===101&&I("enum")){let E=Ti(g,!0,!1);d.push(E)}else if(y===100&&I("declare"))c+=7,O(),il(g,!0);else if(y===110&&I("namespace")&&K(9)){let E=Oi(g,!0,"namespace");d.push(E)}else if(y===109&&I("module")&&K(6)){let E=Oi(g,!0,"module");d.push(E)}else if(y===ne){Ot();let E=R(g,c),x=E.includes("export type"),S=yt(g);d.push({kind:"export",name:"",text:E,isExported:!0,isTypeOnly:x,source:ct(E),leadingComments:S,start:g,end:c})}else if(y===We){Ut();let E=R(g,c),x=yt(g);d.push({kind:"export",name:"",text:E,isExported:!0,isTypeOnly:!1,source:ct(E),leadingComments:x,start:g,end:c})}else{re();let E=R(g,c);if(E)d.push({kind:"export",name:"",text:E,isExported:!0,start:g,end:c})}}else if(w===100&&I("declare"))c+=7,O(),il(g,!1);else if(w===105&&I("interface")){let y=Do(g,!1);h.set(y.name,y)}else if(w===116&&I("type")){let y=Io(g,!1);h.set(y.name,y),d.push(y)}else if(w===102&&I("function")){let y=ri(g,!1,!1,!1);if(y)A(y);else re()}else if(w===97)if(I("async")){let y=c;if(c+=5,O(),I("function")){let E=ri(g,!1,!0,!1);if(E)A(E);else c=y,re()}else c=y,re()}else if(I("abstract"))if(c+=8,O(),I("class")){let y=ni(g,!1,!1);h.set(y.name,y),d.push(y)}else re();else c++,re();else if(w===99)if(I("class")){let y=ni(g,!1,!1);h.set(y.name,y),d.push(y)}else if(I("const")){let y=c;if(c+=5,O(),I("enum")){c=y+5,O();let E=Ti(g,!1,!0);h.set(E.name,E),d.push(E)}else{c=y;let E=pi(g,"const",!1);for(let x=0;x<E.length;x++)h.set(E[x].name,E[x])}}else c++,re();else if(w===101&&I("enum")){let y=Ti(g,!1,!1);h.set(y.name,y),d.push(y)}else if(w===108&&I("let")||w===118&&I("var")){let y=I("let")?"let":"var",E=pi(g,y,!1);for(let x=0;x<E.length;x++)h.set(E[x].name,E[x])}else if(w===109&&I("module")&&K(6)){let y=Oi(g,!1,"module");d.push(y)}else if(w===110&&I("namespace")&&K(9)){let y=Oi(g,!1,"namespace");d.push(y)}else{let y=s.charCodeAt(c);if(y===Ce)c++;else if(y===Re||y===Ie){if(ae(y),c<f&&s.charCodeAt(c)===Ce)c++}else if(y===Ye){if(be(),c<f&&s.charCodeAt(c)===Ce)c++}else if(y===Ep){if(c++,ie(),O(),c<f&&s.charCodeAt(c)===_t)c++,ie(),O();if(c<f&&s.charCodeAt(c)===$e)M($e,Me)}else c++,re()}}if(m.size>0){tl(d);for(let g of p.values())tl(g)}if(fc(s,d,h,p),Nl(d,h),Al(d,h),!a)xc(s,d,h,o);if(n){let g=new Set(d);for(let w of[...h.values(),...[...p.values()].flat()])if(!g.has(w))d.push(w),g.add(w);return d.sort((w,y)=>(w.start??0)-(y.start??0))}if(h.size>0)kp(d,h,p);return d;function tl(g){let w=new Map;for(let E of g)if(E.kind==="function")w.set(E.name,(w.get(E.name)||0)+1);let y=new Set;for(let[E,x]of w)if(x>1)y.add(E);if(y.size>0){let E=new Set;for(let x of y)for(let S=g.length-1;S>=0;S--)if(g[S].kind==="function"&&g[S].name===x&&m.has(g[S])){E.add(S);break}if(E.size>0){let x=[...E].sort((S,D)=>D-S);for(let S of x)g.splice(S,1)}}}function il(g,w){if(I("function")){let y=ri(g,w,!1,!1);if(y)d.push(y)}else if(I("async")){if(c+=5,O(),I("function")){let y=ri(g,w,!0,!1);if(y)d.push(y)}}else if(I("class")){let y=ni(g,w,!1);d.push(y)}else if(I("abstract")){if(c+=8,O(),I("class")){let y=ni(g,w,!0);d.push(y)}}else if(I("interface")){let y=Do(g,w);d.push(y)}else if(I("type")){let y=Io(g,w);d.push(y)}else if(I("enum")){let y=Ti(g,w,!1);d.push(y)}else if(I("const")){let y=c;if(c+=5,O(),I("enum")){c=y+5,O();let E=Ti(g,w,!0);d.push(E)}else{c=y;let E=pi(g,"const",w);for(let x=0;x<E.length;x++)if(w||!u)d.push(E[x]);else h.set(E[x].name,E[x])}}else if(I("let")||I("var")){let y=I("let")?"let":"var",E=pi(g,y,w);for(let x=0;x<E.length;x++)if(w||!u)d.push(E[x]);else h.set(E[x].name,E[x])}else if(I("module")){let y=Oi(g,w,"module");d.push(y)}else if(I("namespace")){let y=Oi(g,w,"namespace");d.push(y)}else if(I("global")){c+=6,O();let y=`declare global ${c<f&&s.charCodeAt(c)===ne?Lo():"{}"}`,E=yt(g);d.push({kind:"module",name:"global",text:y,isExported:!1,moduleForm:"global",leadingComments:E,start:g,end:c})}else re()}}class Tc{names;lengths=new Uint8Array(65);firstUnits=new Uint8Array(65536);size;constructor(e){this.names=e;for(let t of e.keys()){if(!t)continue;this.lengths[Math.min(t.length,64)]=1,this.firstUnits[t.charCodeAt(0)]=1}this.size=e.size}scan(e,t){if(this.size===0)return!1;let i=!1,r=0,n=e.length;while(r<n){let o=e.charCodeAt(r);if(o>=65&&o<=90||o>=97&&o<=122||o===95||o===36||o>127){let s=r;r++;while(r<n){let l=e.charCodeAt(r);if(l>=65&&l<=90||l>=97&&l<=122||l>=48&&l<=57||l===95||l===36||l>127)r++;else break}if(this.firstUnits[o]===1&&this.lengths[Math.min(r-s,64)]===1){let l=e.substring(s,r),a=this.names.get(l);if(a!==void 0){if(t.add(l),a.kind==="function"||a.kind==="variable")i=!0}}}else r++}return i}}function kc(e,t){let i=0;while(i<e.length){let r=e.charCodeAt(i);if(r===Re||r===Ie||r===Ye){let u=r;i++;while(i<e.length)if(e.charCodeAt(i)===Ct)i+=2;else if(e.charCodeAt(i++)===u)break;continue}if(r===de&&e.charCodeAt(i+1)===de){i+=2;while(i<e.length&&e.charCodeAt(i)!==Ne&&e.charCodeAt(i)!==Ge)i++;continue}if(r===de&&e.charCodeAt(i+1)===We){let u=e.indexOf("*/",i+2);i=u===-1?e.length:u+2;continue}if(!dt(r)){i++;continue}let n=i++;while(i<e.length&&He(e.charCodeAt(i)))i++;let o=n-1,s=i;while(o>=0&&Ze(e.charCodeAt(o)))o--;while(s<e.length&&Ze(e.charCodeAt(s)))s++;let l=o>=0?e.charCodeAt(o):0,a=s<e.length?e.charCodeAt(s):0,f=n>=3&&e.slice(n-3,n)==="...";if(a===At||l===_t&&!f)continue;if(a===$e&&(l===ne||l===Dt))continue;t.add(e.slice(n,i))}}function kp(e,t,i){let r=new Set,n=new Set;for(let u of e)n.add(u.name);let o=new Tc(t),s=new Set,l=new Set,a=(u)=>{if(o.scan(u.text,s))Il(u,l)},f=new Set;for(let u=0;u<e.length;u++){let d=e[u];if(d.kind!=="import"){if(a(d),typeof d.value==="string")kc(d.value,f)}}for(;;){let u=[];for(let[p,m]of t){if(r.has(p))continue;if((m.kind==="function"||m.kind==="variable"?l:s).has(p)||m.kind!=="function"&&f.has(p)){if(!n.has(p)){let c=m.kind==="function"?i.get(p):void 0;if(c)for(let C of c)u.push(C);else u.push(m);n.add(p)}r.add(p)}}if(u.length===0)break;u.sort((p,m)=>(p.start??1/0)-(m.start??1/0));let d=[],h=0;for(let p=0;p<e.length;p++){let m=e[p].start??1/0;while(h<u.length&&(u[h].start??1/0)<=m)d.push(u[h++]);d.push(e[p])}while(h<u.length)d.push(u[h++]);e.length=0;for(let p=0;p<d.length;p++)e.push(d[p]);for(let p of u)if(p.kind!=="import"){if(a(p),typeof p.value==="string")kc(p.value,f)}}}var Qe=32,et=9,Ne=10,Ge=13,de=47,We=42,Re=39,Ie=34,Ye=96,Ct=92,ne=123,he=125,$e=40,Me=41,Ve=91,qe=93,Fe=60,De=62,Ce=59,At=58,je=61,Dt=44,_t=46,Tn=63,Ac=35,Ep=64,xp=36,Es;var Rn=me(()=>{hr();ht();is();un();dn();pr();Fl();ls();vr();dc();An();Sc();Es=["public","protected","private","readonly","override"]});function Rc(e,t,i=!0,r=!1,n){if(Qr(t))e=rn(e);else if(on(t))e=sn(e);let o=sr(e),s=`${t}:${i?1:0}:${r?1:0}:${JSON.stringify([...n??[]].sort())}`,l=Ni.get(s);if(l&&l.contentHash===o)return l.lastAccess=++Oc,l.declarations;let a=r?$r(e,t,i):On(e,t,i,n);if(Ni.set(s,{declarations:a,contentHash:o,lastAccess:++Oc}),Ni.size>Tp){let f=Math.max(1,Math.ceil(Ni.size*0.1)),u=[];for(let[d,h]of Ni)u.push([d,h.lastAccess]);u.sort((d,h)=>d[1]-h[1]);for(let d=0;d<f&&d<u.length;d++)Ni.delete(u[d][0])}return a}var Tp=100,Oc=0,Ni;var Pc=me(()=>{nn();ts();jo();Rn();Ni=new Map});function Pn(e,t,i=!0,r=!1,n){return Rc(e,t,i,r,n)}var ks=me(()=>{Pc()});function Mn(e){let t=new Set,i=[];for(let o of e)if(o.kind==="import")for(let s of bi(o.text))t.add(s);else if(o.kind!=="unknown"){if(i.push(o.text),o.kind==="variable"){if(o.typeAnnotation)i.push(o.typeAnnotation);else if(o.value)i.push(Ii(o,!1))}}let r=i.join(`
139
+ `),n=new Set;for(let o=0;o<r.length;){if(!dt(r.charCodeAt(o))){o++;continue}let s=o++;while(o<r.length&&He(r.charCodeAt(o)))o++;let l=r.slice(s,o);if(t.has(l))n.add(l)}return{usedItems:n,referenceText:r}}var Ts=me(()=>{hr();An();Ei()});function Op(e){if(!e.includes("declare")||!e.includes("module"))return[];return Rt(e).filter((t)=>t.category==="augmentation").map((t)=>t.specifier)}function Rp(e,t){let i=new Set([e]);for(let r of i)for(let n of t(r))i.add(n);return i}async function Mc(e,t,i=!1,r){let n=new Map,o=new Map;for(let u of e){let d=r?.get(u)??await vt(u);n.set(u,d);let h=Op(d);if(h.length)o.set(u,h)}let s=new Map;if(o.size===0)return s;let l=new Map,a=(u,d)=>{let h=t(u,d);if(h.resolved)return h.resolved;if(!h.isRelative&&!h.isAlias)return`external:${u}`;return};for(let[u,d]of n){let h=Pn(d,u,!1,i),p=Mn(h),m={edges:[],declarations:new Set,augmentations:new Set},c=(C,b,v)=>{let k=a(C.specifier,u);if(!k)return;if(n.has(k))m.edges.push({specifier:C.specifier,target:k,import:b});if(v)m.declarations.add(k)};for(let C of h){if(C.kind!=="import")continue;let b=C.isSideEffect||bi(C.text).some((v)=>p.usedItems.has(v));for(let v of Rt(C.text))c(v,!0,!!b)}for(let C of Rt(p.referenceText))c(C,!1,!0);for(let C of o.get(u)??[]){let b=a(C,u);if(b)m.augmentations.add(b),m.declarations.add(b)}l.set(u,m)}let f=!0;while(f){f=!1;for(let[u,d]of l){let h=Rp(u,(p)=>l.get(p)?.declarations??[]);for(let[p,m]of l){if(h.has(p)||!m.augmentations.size||![...m.augmentations].some((v)=>h.has(v)))continue;let c=[u],C=new Map,b=new Set([u]);for(let v of c){if(v===p)break;for(let k of l.get(v).edges){if(b.has(k.target))continue;b.add(k.target),C.set(k.target,{from:v,edge:k}),c.push(k.target)}}if(!C.has(p))continue;for(let v=p;v!==u;){let{from:k,edge:W}=C.get(v),A=l.get(k);if(W.import){let R=s.get(k);if(!R)R=new Set,s.set(k,R);R.add(W.specifier)}if(!A.declarations.has(v))A.declarations.add(v),f=!0;v=k}}}}return s}var Dc=me(()=>{ar();ht();Ei();ks();Ts()});function Fi(e){return Ic[e]>=Ic[Dn]}function Dp(){if(!Mp)return"";return`[${new Date().toISOString().slice(11,23)}] `}function Ip(e,t){let i=Dp();if(e||i)return[`${i}${e}`,...t];return t}function Wi(e,t,i){let r=Ip(t,i);if(Nc){Nc(e,...r);return}switch(e){case"debug":console.debug(...r);break;case"info":console.log(...r);break;case"warn":console.warn(...r);break;case"error":console.error(...r);break}}function Fc(e){return{debug:(...t)=>{if(Fi("debug"))Wi("debug",e,t)},info:(...t)=>{if(Fi("info"))Wi("info",e,t)},warn:(...t)=>{if(Fi("warn"))Wi("warn",e,t)},error:(...t)=>{if(Fi("error"))Wi("error",e,t)},setLevel:(t)=>{Dn=t},getLevel:()=>Dn,child:(t)=>{let i=e?`${e}:${t}`:`[${t}]`;return Fc(i)},time:(t)=>{let i=performance.now();return()=>{let r=performance.now()-i;if(Fi("debug"))Wi("debug",e,[`${t}: ${r.toFixed(2)}ms`])}},progress:(t)=>{if(Fi("info"))if(typeof process<"u"&&process.stdout?.isTTY)process.stdout.write(`\r${e} ${t}`);else Wi("info",e,[t])}}}function Os(e){Dn=e}var Ic,Dn="info",Pp="[dtsx]",Mp=!1,Nc=null,le;var In=me(()=>{Ic={debug:0,info:1,warn:2,error:3,silent:4};le=Fc(Pp)});function Wc(e){let t="",i=0,r=0;while(i<e.length){let n=e.charCodeAt(i);if(r){if(t+=e[i],n===92&&i+1<e.length){t+=e[i+1],i+=2;continue}if(n===r)r=0;i++;continue}if(n===34){r=n,t+=e[i++];continue}if(n===47&&e.charCodeAt(i+1)===47){i+=2;while(i<e.length&&e.charCodeAt(i)!==10&&e.charCodeAt(i)!==13)i++;continue}if(n===47&&e.charCodeAt(i+1)===42){i+=2;while(i+1<e.length&&!(e.charCodeAt(i)===42&&e.charCodeAt(i+1)===47)){if(e.charCodeAt(i)===10)t+=`
140
+ `;i++}i=Math.min(i+2,e.length);continue}if(n===44){let o=i+1;while(o<e.length){while(o<e.length&&e.charCodeAt(o)<=32)o++;if(e.charCodeAt(o)===47&&e.charCodeAt(o+1)===47){o+=2;while(o<e.length&&e.charCodeAt(o)!==10&&e.charCodeAt(o)!==13)o++;continue}if(e.charCodeAt(o)===47&&e.charCodeAt(o+1)===42){o+=2;while(o+1<e.length&&!(e.charCodeAt(o)===42&&e.charCodeAt(o+1)===47))o++;o=Math.min(o+2,e.length);continue}break}let s=e.charCodeAt(o);if(s===93||s===125){i++;continue}}t+=e[i++]}return t}var Lc=()=>{};import{readFileSync as Np,statSync as Fp}from"fs";import{readFile as Wp}from"fs/promises";import{createRequire as Lp}from"module";import{dirname as Er,isAbsolute as Bp,join as Rs,resolve as Ps}from"path";function Li(e){let t=[e];if(!e.endsWith(".json"))t.push(`${e}.json`);t.push(Rs(e,"tsconfig.json"));for(let i of t)try{if(Fp(i).isFile())return i}catch{}return null}function _p(e,t){if(Bp(e)||e.startsWith("."))return Li(Ps(Er(t),e));let i=Lp(t),r=e.startsWith("@")?/^@[^/]+\/[^/]+/.exec(e)?.[0]:e.split("/")[0];if(r)for(let n of i.resolve.paths(r)??[]){let o=Li(Rs(n,r,"package.json"));if(!o)continue;let s=JSON.parse(Np(o,"utf8"));if(e===r){if(s.tsconfig!==void 0){if(typeof s.tsconfig!=="string")throw Error(`Invalid tsconfig field in ${o}`);let a=Li(Ps(Er(o),s.tsconfig));if(!a)throw Error(`Cannot resolve tsconfig ${JSON.stringify(s.tsconfig)} from ${o}`);return a}let l=Li(Rs(Er(o),"tsconfig.json"));if(l)return l}break}for(let n of[`${e}/tsconfig.json`,e])try{let o=i.resolve(n),s=o.endsWith(".json")?Li(o):null;if(s)return s}catch{}return null}async function xr(e,t={},i=new Set){let r=Li(e);if(!r)return;if(i.has(r)){if(t.allowCircular)return;throw Error(`Circular tsconfig extends: ${r}`)}let n=new Set(i).add(r),o=JSON.parse(Wc(await Wp(r,"utf8"))),s=typeof o.extends==="string"?[o.extends]:o.extends??[];if(!Array.isArray(s)||s.some((f)=>typeof f!=="string"))throw Error(`Invalid tsconfig extends in ${r}`);let l={};for(let f of s){let u=_p(f,r);if(!u)throw Error(`Cannot resolve tsconfig extends ${JSON.stringify(f)} from ${r}`);l={...l,...await xr(u,t,n)}}let a=o.compilerOptions??{};if(a.isolatedDeclarations!==void 0)l.isolatedDeclarations=a.isolatedDeclarations;if(a.baseUrl!==void 0){if(typeof a.baseUrl!=="string")throw Error(`Invalid baseUrl in ${r}`);l.baseUrl=Ps(Er(r),a.baseUrl)}if(a.paths!==void 0){if(!a.paths||typeof a.paths!=="object"||Array.isArray(a.paths))throw Error(`Invalid paths in ${r}`);for(let[f,u]of Object.entries(a.paths))if(f.split("*").length>2||!Array.isArray(u)||u.length===0||u.some((d)=>typeof d!=="string"||d.split("*").length>2))throw Error(`Invalid path mapping ${JSON.stringify(f)} in ${r}`);l.paths=a.paths,l.pathsBasePath=Er(r)}return l}var Ms=me(()=>{Lc()});import{existsSync as Ns,readFileSync as Ds,realpathSync as Sr,statSync as jp}from"fs";import{builtinModules as Gp}from"module";import{dirname as Fs,extname as Vp,isAbsolute as Ws,join as jc,relative as Gc,resolve as Bi}from"path";function Nn(e){try{return jp(e).isFile()}catch{return!1}}function _i(e,t){let i=e.replace(/[?#].*$/,"");if(!(i.startsWith("./")||i.startsWith("../")||i==="."||i==="..")&&!Ws(i))return{resolved:null,isRelative:!1};let r=Fs(t),n=Bi(r,i);if(Nn(n))return{resolved:n,isRelative:!0};let o=Vp(n),s=Up[o];if(s){let l=n.slice(0,-o.length);for(let a of s){let f=l+a;if(Nn(f))return{resolved:f,isRelative:!0}}}for(let l of Bc){let a=n+l;if(Nn(a))return{resolved:a,isRelative:!0}}if(Ns(n))for(let l of Bc){let a=jc(n,`index${l}`);if(Nn(a))return{resolved:a,isRelative:!0}}return{resolved:null,isRelative:!0}}function Vc(e,t){let i=e.indexOf("*");return i===-1?t===e:t.startsWith(e.slice(0,i))&&t.endsWith(e.slice(i+1))&&t.length>=e.length-1}function Uc(e,t){if(Object.hasOwn(e,t))return e[t]!==null;let i=Object.keys(e).filter((r)=>r.includes("*")&&Vc(r,t)).sort((r,n)=>n.indexOf("*")-r.indexOf("*")||n.length-r.length)[0];return i!==void 0&&e[i]!==null}function _c(e,t){if(!e.name||t!==e.name&&!t.startsWith(`${e.name}/`))return!1;if(e.exports===void 0)return!0;let i=t===e.name?".":`.${t.slice(e.name.length)}`;if(typeof e.exports==="string"||Array.isArray(e.exports))return i===".";if(!e.exports||typeof e.exports!=="object")return!1;let r=e.exports;if(!Object.keys(r).some((n)=>n.startsWith(".")))return i===".";return Uc(r,i)}function Is(e,t){let i=Gc(e,t);return i!==".."&&!i.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!Ws(i)}async function Fn(e){let t=await xr(Bi(e.cwd,e.tsconfigPath||"tsconfig.json")),i=Object.entries(t?.paths??{});if(i.length===0){let f=(u,d)=>_i(u,d);return f.cacheKey=(u)=>JSON.stringify(u.map((d)=>({file:d,references:xi(Ds(d,"utf8"),{includeImports:!0}).map((h)=>({specifier:h.specifier,resolution:f(h.specifier,d)}))}))),f}let r=t?.baseUrl??t?.pathsBasePath??e.cwd,n=Bi(e.cwd,e.root),o=new Map,s=new Set([...Gp,"bun"]),l=(f)=>{let u=Fs(f),d=[];while(!0){if(o.has(u)){let m=o.get(u);for(let c of d)o.set(c,m);return m}d.push(u);let h=jc(u,"package.json");if(Ns(h)){let m={...JSON.parse(Ds(h,"utf8")),directory:Sr(u)};for(let c of d)o.set(c,m);return m}let p=Fs(u);if(p===u)return;u=p}},a=(f,u)=>{if(f.startsWith(".")||Ws(f))return _i(f,u);if(f.startsWith("node:")||f.startsWith("bun:")||s.has(f))return{resolved:null,isRelative:!1};let d=l(u),h=f.startsWith("@")?/^@[^/]+\/[^/]+/.exec(f)?.[0]:f.split("/")[0];if(d&&(_c(d,f)||Uc(d.imports??{},f)||h&&[d.dependencies,d.devDependencies,d.peerDependencies,d.optionalDependencies].some((v)=>Object.hasOwn(v??{},h))))return{resolved:null,isRelative:!1};let p=i.filter(([v])=>Vc(v,f)).sort(([v],[k])=>{if(!v.includes("*"))return-1;if(!k.includes("*"))return 1;return k.indexOf("*")-v.indexOf("*")})[0];if(!p)return{resolved:null,isRelative:!1};let[m,c]=p,C=m.indexOf("*"),b=C===-1?"":f.slice(C,f.length-(m.length-C-1));for(let v of c){let k=Bi(r,v.replace("*",b)),W=l(k);if(W&&_c(W,f)&&!W.private&&W.directory!==d?.directory)return{resolved:null,isRelative:!1};let A=_i(k,u);if(!A.resolved)continue;let R=Sr(A.resolved),V=e.outputStructure==="flat"||Ns(n)&&Is(Sr(n),R);if(!d||!Is(d.directory,R)||!V||l(R)?.directory!==d.directory||/\.d\.(?:ts|mts|cts)$/.test(R))throw Error(`Local alias ${JSON.stringify(f)} from ${u} resolves outside its emitted package source: ${R}`);return le.debug(`Resolved local declaration alias ${f} from ${u} to ${R}`),{resolved:e.outputStructure==="flat"?A.resolved:Bi(n,Gc(Sr(n),R)),isRelative:!0,isAlias:!0,suffix:k.match(/[?#].*$/)?.[0]??""}}throw Error(`Cannot resolve local alias ${JSON.stringify(f)} from ${u} using ${e.tsconfigPath||"tsconfig.json"} (${JSON.stringify(m)})`)};return a.isPackageLocal=(f,u)=>{let d=l(f);return!!d&&l(u)?.directory===d.directory&&Is(d.directory,Sr(u))},a.cacheKey=(f)=>{let u=f.map((h)=>({file:h,references:xi(Ds(h,"utf8"),{includeImports:!0}).map((p)=>({specifier:p.specifier,resolution:a(p.specifier,h)}))})),d=[...new Set(o.values())].filter((h)=>h!==void 0).sort((h,p)=>h.directory.localeCompare(p.directory));return JSON.stringify({root:n,compilerOptions:t,packages:d,edges:u})},a}function xi(e,t={}){let i=Rt(e);return(t.includeImports?["export","static-import","import-type","augmentation"]:["export"]).flatMap((r)=>i.filter((n)=>n.category===r).map(({specifier:n,kind:o,isTypeOnly:s})=>({specifier:n,kind:o,isTypeOnly:s})))}function zc(e,t){let i=[];for(let n of Rt(e)){let o=t(n.specifier);if(o!==n.specifier)i.push({start:n.start,end:n.end,value:oi(o,e[n.start])})}let r=e;for(let n of i.reverse())r=r.slice(0,n.start)+n.value+r.slice(n.end);return r}async function Ar(e,t={}){let i=new Set,r=new Map,n=[],o=new Map,s=[];for(let l of e){let a=Bi(l);if(!i.has(a))i.add(a),s.push(a)}while(s.length>0){let l=s.shift(),a;try{a=await vt(l)}catch{continue}o.set(l,a);let f=xi(a,t);r.set(l,f);for(let u of f){let d=(t.resolveSpecifier??_i)(u.specifier,l);if(!d.isRelative)continue;if(d.resolved){if(!i.has(d.resolved))i.add(d.resolved),s.push(d.resolved)}else n.push({from:l,specifier:u.specifier,isTypeOnly:u.isTypeOnly})}}return{reachable:i,reExports:r,unresolved:n,sources:o}}var Bc,Up;var Wn=me(()=>{ar();In();ht();Ms();Bc=[".ts",".tsx",".mts",".cts",".vue",".stx",".js",".jsx",".mjs",".cjs",".d.ts",".d.mts",".d.cts"],Up={".js":[".ts",".tsx",".d.ts"],".jsx":[".tsx",".ts",".d.ts"],".mjs":[".mts",".d.mts"],".cjs":[".cts",".d.cts"]}});import{relative as Si}from"path";function Ls(e){let t=ce(e),i=(l)=>t[l]?e.slice(t[l].start,t[l].end):"",r=i(0)==="export"?1:0;if(i(r++)!=="declare")return;let n;if(i(r)==="module"&&t[r+1]?.kind==="quoted"){if(n=wt(i(r+1)),n===void 0)return;r+=2}else if(i(r++)!=="global")return;if(i(r)!=="{")return;let o=t[r].end,s=1;for(r++;r<t.length;r++)if(i(r)==="{")s++;else if(i(r)==="}"&&--s===0)return{specifier:n,body:e.slice(o,t[r].start),start:o,end:t[r].start};return}function Kp(e){let t=[],i=[],r=0,n=0,o=[],s=!1,l=0,a=e.length,f=(u)=>{let d=e.slice(r,u).trim();if(r=u,!d)return;if(Hp(d)){i.push(d);return}t.push({text:d,comments:i}),i=[]};while(l<a){let u=e[l];if(s){if(u==="\\"){l+=2;continue}if(u==="`"){s=!1,l++;continue}if(u==="$"&&e[l+1]==="{"){o.push(n),n++,s=!1,l+=2;continue}l++;continue}if(u==="/"&&e[l+1]==="*"){let d=e.indexOf("*/",l+2);l=d===-1?a:d+2;continue}if(u==="/"&&e[l+1]==="/"){let d=e.indexOf(`
141
141
  `,l);l=d===-1?a:d;continue}if(u==="'"||u==='"'){l++;while(l<a&&e[l]!==u&&e[l]!==`
142
142
  `){if(e[l]==="\\")l++;l++}l++;continue}if(u==="`"){s=!0,l++;continue}if(u==="("||u==="["||u==="{"){n++,l++;continue}if(u===")"||u==="]"||u==="}"){if(n--,o.length>0&&u==="}"&&n===o[o.length-1])o.pop(),s=!0;l++;continue}if(n===0&&u===";"){f(l+1),l++;continue}if(n===0&&u===`
143
- `){let d=e[l+1];if(d!==void 0&&/[\w$@/]/.test(d))f(l+1);l++;continue}l++}return f(a),t}function Up(e){let t=0;while(t<e.length){while(t<e.length&&/\s/.test(e[t]))t++;if(t>=e.length)return!0;if(e.startsWith("//",t)){let i=e.indexOf(`
144
- `,t);t=i===-1?e.length:i;continue}if(e.startsWith("/*",t)){let i=e.indexOf("*/",t+2);if(i===-1)return!0;t=i+2;continue}return!1}return!0}function Kc(e){let t=[];for(let i of e.split(",")){let r=i.replace(/\/\*[\s\S]*?\*\//g,"").trim().replace(/^type\s+/,"");if(!r)continue;let n=r.match(/^([\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!n)continue;t.push({local:n[1],exported:n[2]??n[1]})}return t}function Kp(e,t){let i=e.replace(/^export\s+/,""),r=/^default\s+/.test(i);if(i=i.replace(/^default\s+/,""),r)i=i.replace(/^((?:declare\s+)?(?:abstract\s+)?(?:class|function\s*\*?|async\s+function\s*\*?))\s*(?=[(<{])/,(n,o)=>`${o.trimEnd()} ${t}`);if(/^(?:interface|type)\b/.test(i)||/^declare\b/.test(i))return i;return`declare ${i}`}function Fn(e,t,i=!1){let r={file:e,declarations:[],declared:new Set,imports:new Map,localExports:new Map,namedReExports:[],starReExports:[],namespaceReExports:[],verbatim:[],augmentations:[],directives:[]},n=i?xs(t,e).map((o)=>({text:o.text,comments:[...o.leadingComments??[]]})):Vp(t);for(let o of n){o.comments=o.comments.filter((d)=>{if(/^\/\/\/\s*</.test(d))return r.directives.push(...d.split(`
145
- `).map((h)=>h.trim()).filter((h)=>h.startsWith("///"))),!1;return!0});let s=o.text.replace(/;\s*$/,"").trim(),l=s.startsWith("import")?bi(s):null;if(l&&!l.isImportEquals){let d=l.source;if(l.defaultName)r.imports.set(l.defaultName,{specifier:d,imported:"default"});if(l.namespaceName)r.imports.set(l.namespaceName,{specifier:d,imported:"*"});for(let h of l.namedItems)r.imports.set(h.name,{specifier:d,imported:/^['"]/.test(h.originalName)?wt(h.originalName):h.originalName});continue}if(/^import\s+['"]/.test(s)){r.verbatim.push(o);continue}let a=s.match(/^export\s+(?:type\s+)?\*\s+as\s+([\w$]+)\s+from\s+(['"])([^'"]+)\2/);if(a){r.namespaceReExports.push({specifier:a[3],exported:a[1]});continue}if(a=s.match(/^export\s+(?:type\s+)?\*\s+from\s+(['"])([^'"]+)\1/),a){r.starReExports.push(a[2]);continue}if(a=s.match(/^export\s+(?:type\s+)?\{([\s\S]*)\}\s+from\s+(['"])([^'"]+)\2/),a){for(let d of Kc(a[1]))r.namedReExports.push({specifier:a[3],imported:d.local,exported:d.exported});continue}if(a=s.match(/^export\s+(?:type\s+)?\{([\s\S]*)\}$/),a){for(let d of Kc(a[1]))r.localExports.set(d.exported,d.local);continue}if(a=s.match(/^export\s+default\s+([\w$]+)$/),a&&Gp.test(a[1])){r.localExports.set("default",a[1]);continue}let f=Ws(s);if(f?.specifier!==void 0&&Ri(t)){r.augmentations.push({statement:o,specifier:f.specifier,body:f.body});continue}if(/^export\s+as\s+namespace\b/.test(s)||f){r.verbatim.push(o);continue}let u=s.match(zp);if(u){let d=!!u[1],h=u[4]??(d?"_default":null);if(h){if(r.declared.add(h),/^export\s/.test(s))r.localExports.set(d?"default":h,h);r.declarations.push({statement:o,name:h,emit:Kp(o.text,h)});continue}}r.declarations.push({statement:o,name:null,emit:o.text})}return r}function kr(e,t){if(t.size===0)return e;let i=ce(e),r=new Map(i.filter((p)=>p.kind==="literal").map((p)=>[p.start,p.end])),n=(p)=>i[p]?e.slice(i[p].start,i[p].end):"",o=new Map,s=[];for(let p=0;p<i.length;p++){let m=n(p);if(["(","[","{","<"].includes(m))s.push(p);else if([")","]","}",">"].includes(m)&&!(m===">"&&n(p-1)==="=")){let c=s.at(-1);if(c!==void 0&&["()","[]","{}","<>"].includes(n(c)+m))s.pop(),o.set(c,p)}}let l=(p)=>{for(let m=p;m<i.length;m++){if([";",",",")","]","}"].includes(n(m))||n(m)===">"&&n(m-1)!=="=")return m;let c=o.get(m);if(c!==void 0)m=c}return i.length},a=new Set;for(let p=0;p<i.length;p++){let m=o.get(p);if(n(p)!=="<"||m===void 0)continue;let c=["class","interface","type"].includes(n(p-2));if(!c&&n(m+1)!=="(")continue;let v=new Set;for(let C=p+1;C<m;C++){if(C===p+1||n(C-1)===","){while(["const","in","out"].includes(n(C)))C++;if(i[C]?.kind==="word")v.add(n(C))}let k=o.get(C);if(k!==void 0)C=k}let b=l(m+1);if(c&&n(p-2)!=="type")for(let C=m+1;C<i.length;C++){if(n(C)==="{"){b=o.get(C)??b;break}let k=o.get(C);if(k!==void 0)C=k}for(let C=p+1;C<b;C++){let k=n(p-2)==="class"&&C>m&&n(C-1)==="extends";if(v.has(n(C))&&n(C-1)!=="typeof"&&!k)a.add(i[C].start)}}for(let p=0;p<i.length;p++){if(!["namespace","module"].includes(n(p))||i[p+1]?.kind!=="word"||n(p+2)!=="{")continue;let m=o.get(p+2);if(m===void 0)continue;let c=xs(e.slice(i[p+2].end,i[m].start),"bundle-namespace.ts"),v=new Set(c.filter((C)=>["class","interface","type","enum","module","namespace"].includes(C.kind)).map((C)=>C.name)),b=new Set(c.filter((C)=>["class","variable","function","enum","module","namespace"].includes(C.kind)).map((C)=>C.name));for(let C=p+3;C<m;C++)if((n(C-1)==="typeof"?b:v).has(n(C)))a.add(i[C].start)}let f="",u=0,d=e.length,h=`
146
- `;while(u<d){let p=r.get(u);if(p!==void 0){f+=e.slice(u,p),u=p,h="`";continue}let m=e[u];if(m==="/"&&e[u+1]==="*"){let c=e.indexOf("*/",u+2),v=c===-1?d:c+2;f+=e.slice(u,v),u=v;continue}if(m==="/"&&e[u+1]==="/"){let c=e.indexOf(`
147
- `,u),v=c===-1?d:c;f+=e.slice(u,v),u=v;continue}if(m==="'"||m==='"'){let c=u+1;while(c<d&&e[c]!==m&&e[c]!==`
148
- `){if(e[c]==="\\")c++;c++}f+=e.slice(u,c+1),u=c+1,h=m;continue}if(/[A-Z_$]/i.test(m)){let c=u+1;while(c<d&&/[\w$]/.test(e[c]))c++;let v=e.slice(u,c),b=t.get(v);if(b!==void 0&&h!=="."&&!a.has(u)){let C=c;while(C<d&&(e[C]===" "||e[C]==="\t"))C++;let k=(e[C]===":"||e[C]==="?"&&e[C+1]===":")&&/[{;,(\n]/.test(h);f+=k?v:b}else f+=v;h="a",u=c;continue}if(f+=m,m===`
149
- `||!/\s/.test(m))h=m;u++}return f}function Hc(e,t,i,r){let n=[],o=new Map,s=[e,...t.filter((K)=>K!==e)];for(let K of s){let Q=i.get(K);if(Q===void 0){n.push(`No declarations were generated for ${xi(r.cwd,K)}; it is left out of the bundle`);continue}o.set(K,Fn(K,Q))}let l=(K,Q)=>{if(!K.startsWith(".")&&!K.startsWith("/"))return null;let oe=Bi(K,Q).resolved;return oe&&o.has(oe)?oe:null},a=(K)=>K.startsWith(".")||K.startsWith("/"),f=new Set,u=(K)=>{let Q=K;for(let oe=1;f.has(Q);oe++)Q=`${K}_${oe}`;return f.add(Q),Q},d=new Map;for(let[K,Q]of o){let oe=new Map;for(let ue of Q.declared)oe.set(ue,u(ue));d.set(K,oe)}let h=new Map,p=(K,Q,oe)=>{let ue=`${K}\x00${Q}`,fe=h.get(ue);if(!fe)fe=u(oe),h.set(ue,fe);return fe},m=new Map,c=new Map,v=new Set,b=new Map,C=!0,k=(K,Q,oe)=>{let ue=l(Q,K.file);if(ue){if(oe==="*")return{kind:"namespace",file:ue};let fe=A(ue).get(oe);if(!fe&&!C)n.push(`${xi(r.cwd,K.file)}: '${oe}' is not exported by '${Q}'`);return fe??null}if(a(Q))return n.push(`${xi(r.cwd,K.file)}: '${Q}' is not part of the bundle`),null;return oe==="*"?{kind:"external-namespace",source:Q}:{kind:"external",source:Q,imported:oe}},W=(K,Q)=>{if(K.declared.has(Q))return{kind:"local",name:d.get(K.file).get(Q)};let oe=K.imports.get(Q);if(oe)return k(K,oe.specifier,oe.imported);return n.push(`${xi(r.cwd,K.file)}: cannot resolve exported name '${Q}'`),null};function A(K){let Q=m.get(K);if(Q)return Q;let oe=new Map,ue=o.get(K);if(!ue||v.has(K))return oe;v.add(K);let fe=new Set;for(let[pe,Ee]of ue.localExports){let xe=W(ue,Ee);if(xe)oe.set(pe,xe)}for(let pe of ue.namedReExports){let Ee=k(ue,pe.specifier,pe.imported);if(Ee)oe.set(pe.exported,Ee)}for(let pe of ue.namespaceReExports){let Ee=k(ue,pe.specifier,"*");if(Ee)oe.set(pe.exported,Ee)}for(let pe of ue.starReExports){let Ee=l(pe,K);if(Ee){for(let[xe,Je]of A(Ee))if(xe!=="default"&&!oe.has(xe))oe.set(xe,Je);for(let xe of c.get(Ee)??[])fe.add(xe)}else if(a(pe))n.push(`${xi(r.cwd,K)}: '${pe}' is not part of the bundle`);else fe.add(pe)}for(let[pe,Ee]of b.get(K)??[])oe.set(pe,Ee);return v.delete(K),m.set(K,oe),c.set(K,fe),oe}for(let[K,Q]of o)for(let oe of Q.augmentations){let ue=l(oe.specifier,K);if(!ue)continue;for(let fe of Fn(K,oe.body,!0).declared){if(A(ue).has(fe))continue;let pe=b.get(ue);if(!pe)pe=new Map,b.set(ue,pe);pe.set(fe,{kind:"local",name:u(fe)}),m.clear()}}C=!1,m.clear(),c.clear();let R=new Map,V=[],B=(K,Q)=>{switch(K.kind){case"local":return K.name;case"external":return p(K.source,K.imported,K.imported==="default"?Q:K.imported);case"external-namespace":return p(K.source,"*",Q);case"namespace":return O(K.file,Q)}};function O(K,Q){let oe=R.get(K);if(oe)return oe;let ue=u(Q);R.set(K,ue);let fe=[];for(let[pe,Ee]of A(K)){if(pe==="default")continue;let xe=B(Ee,pe);fe.push(xe===pe?pe:`${xe} as ${pe}`)}if(c.get(K)?.size)n.push(`${xi(r.cwd,K)}: 'export * from' an external module cannot be expressed inside namespace '${ue}'`);return V.push(`declare namespace ${ue} {
143
+ `){let d=e[l+1];if(d!==void 0&&/[\w$@/]/.test(d))f(l+1);l++;continue}l++}return f(a),t}function Hp(e){let t=0;while(t<e.length){while(t<e.length&&/\s/.test(e[t]))t++;if(t>=e.length)return!0;if(e.startsWith("//",t)){let i=e.indexOf(`
144
+ `,t);t=i===-1?e.length:i;continue}if(e.startsWith("/*",t)){let i=e.indexOf("*/",t+2);if(i===-1)return!0;t=i+2;continue}return!1}return!0}function Kc(e){let t=[];for(let i of e.split(",")){let r=i.replace(/\/\*[\s\S]*?\*\//g,"").trim().replace(/^type\s+/,"");if(!r)continue;let n=r.match(/^([\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!n)continue;t.push({local:n[1],exported:n[2]??n[1]})}return t}function Jp(e,t){let i=e.replace(/^export\s+/,""),r=/^default\s+/.test(i);if(i=i.replace(/^default\s+/,""),r)i=i.replace(/^((?:declare\s+)?(?:abstract\s+)?(?:class|function\s*\*?|async\s+function\s*\*?))\s*(?=[(<{])/,(n,o)=>`${o.trimEnd()} ${t}`);if(/^(?:interface|type)\b/.test(i)||/^declare\b/.test(i))return i;return`declare ${i}`}function Ln(e,t,i=!1){let r={file:e,declarations:[],declared:new Set,imports:new Map,localExports:new Map,namedReExports:[],starReExports:[],namespaceReExports:[],verbatim:[],augmentations:[],directives:[]},n=i?Ss(t,e).map((o)=>({text:o.text,comments:[...o.leadingComments??[]]})):Kp(t);for(let o of n){o.comments=o.comments.filter((d)=>{if(/^\/\/\/\s*</.test(d))return r.directives.push(...d.split(`
145
+ `).map((h)=>h.trim()).filter((h)=>h.startsWith("///"))),!1;return!0});let s=o.text.replace(/;\s*$/,"").trim(),l=s.startsWith("import")?$i(s):null;if(l&&!l.isImportEquals){let d=l.source;if(l.defaultName)r.imports.set(l.defaultName,{specifier:d,imported:"default"});if(l.namespaceName)r.imports.set(l.namespaceName,{specifier:d,imported:"*"});for(let h of l.namedItems)r.imports.set(h.name,{specifier:d,imported:/^['"]/.test(h.originalName)?wt(h.originalName):h.originalName});continue}if(/^import\s+['"]/.test(s)){r.verbatim.push(o);continue}let a=s.match(/^export\s+(?:type\s+)?\*\s+as\s+([\w$]+)\s+from\s+(['"])([^'"]+)\2/);if(a){r.namespaceReExports.push({specifier:a[3],exported:a[1]});continue}if(a=s.match(/^export\s+(?:type\s+)?\*\s+from\s+(['"])([^'"]+)\1/),a){r.starReExports.push(a[2]);continue}if(a=s.match(/^export\s+(?:type\s+)?\{([\s\S]*)\}\s+from\s+(['"])([^'"]+)\2/),a){for(let d of Kc(a[1]))r.namedReExports.push({specifier:a[3],imported:d.local,exported:d.exported});continue}if(a=s.match(/^export\s+(?:type\s+)?\{([\s\S]*)\}$/),a){for(let d of Kc(a[1]))r.localExports.set(d.exported,d.local);continue}if(a=s.match(/^export\s+default\s+([\w$]+)$/),a&&zp.test(a[1])){r.localExports.set("default",a[1]);continue}let f=Ls(s);if(f?.specifier!==void 0&&Pi(t)){r.augmentations.push({statement:o,specifier:f.specifier,body:f.body});continue}if(/^export\s+as\s+namespace\b/.test(s)||f){r.verbatim.push(o);continue}let u=s.match(qp);if(u){let d=!!u[1],h=u[4]??(d?"_default":null);if(h){if(r.declared.add(h),/^export\s/.test(s))r.localExports.set(d?"default":h,h);r.declarations.push({statement:o,name:h,emit:Jp(o.text,h)});continue}}r.declarations.push({statement:o,name:null,emit:o.text})}return r}function kr(e,t){if(t.size===0)return e;let i=ce(e),r=new Map(i.filter((p)=>p.kind==="literal").map((p)=>[p.start,p.end])),n=(p)=>i[p]?e.slice(i[p].start,i[p].end):"",o=new Map,s=[];for(let p=0;p<i.length;p++){let m=n(p);if(["(","[","{","<"].includes(m))s.push(p);else if([")","]","}",">"].includes(m)&&!(m===">"&&n(p-1)==="=")){let c=s.at(-1);if(c!==void 0&&["()","[]","{}","<>"].includes(n(c)+m))s.pop(),o.set(c,p)}}let l=(p)=>{for(let m=p;m<i.length;m++){if([";",",",")","]","}"].includes(n(m))||n(m)===">"&&n(m-1)!=="=")return m;let c=o.get(m);if(c!==void 0)m=c}return i.length},a=new Set;for(let p=0;p<i.length;p++){let m=o.get(p);if(n(p)!=="<"||m===void 0)continue;let c=["class","interface","type"].includes(n(p-2));if(!c&&n(m+1)!=="(")continue;let C=new Set;for(let v=p+1;v<m;v++){if(v===p+1||n(v-1)===","){while(["const","in","out"].includes(n(v)))v++;if(i[v]?.kind==="word")C.add(n(v))}let k=o.get(v);if(k!==void 0)v=k}let b=l(m+1);if(c&&n(p-2)!=="type")for(let v=m+1;v<i.length;v++){if(n(v)==="{"){b=o.get(v)??b;break}let k=o.get(v);if(k!==void 0)v=k}for(let v=p+1;v<b;v++){let k=n(p-2)==="class"&&v>m&&n(v-1)==="extends";if(C.has(n(v))&&n(v-1)!=="typeof"&&!k)a.add(i[v].start)}}for(let p=0;p<i.length;p++){if(!["namespace","module"].includes(n(p))||i[p+1]?.kind!=="word"||n(p+2)!=="{")continue;let m=o.get(p+2);if(m===void 0)continue;let c=Ss(e.slice(i[p+2].end,i[m].start),"bundle-namespace.ts"),C=new Set(c.filter((v)=>["class","interface","type","enum","module","namespace"].includes(v.kind)).map((v)=>v.name)),b=new Set(c.filter((v)=>["class","variable","function","enum","module","namespace"].includes(v.kind)).map((v)=>v.name));for(let v=p+3;v<m;v++)if((n(v-1)==="typeof"?b:C).has(n(v)))a.add(i[v].start)}let f="",u=0,d=e.length,h=`
146
+ `;while(u<d){let p=r.get(u);if(p!==void 0){f+=e.slice(u,p),u=p,h="`";continue}let m=e[u];if(m==="/"&&e[u+1]==="*"){let c=e.indexOf("*/",u+2),C=c===-1?d:c+2;f+=e.slice(u,C),u=C;continue}if(m==="/"&&e[u+1]==="/"){let c=e.indexOf(`
147
+ `,u),C=c===-1?d:c;f+=e.slice(u,C),u=C;continue}if(m==="'"||m==='"'){let c=u+1;while(c<d&&e[c]!==m&&e[c]!==`
148
+ `){if(e[c]==="\\")c++;c++}f+=e.slice(u,c+1),u=c+1,h=m;continue}if(/[A-Z_$]/i.test(m)){let c=u+1;while(c<d&&/[\w$]/.test(e[c]))c++;let C=e.slice(u,c),b=t.get(C);if(b!==void 0&&h!=="."&&!a.has(u)){let v=c;while(v<d&&(e[v]===" "||e[v]==="\t"))v++;let k=(e[v]===":"||e[v]==="?"&&e[v+1]===":")&&/[{;,(\n]/.test(h);f+=k?C:b}else f+=C;h="a",u=c;continue}if(f+=m,m===`
149
+ `||!/\s/.test(m))h=m;u++}return f}function Hc(e,t,i,r){let n=[],o=new Map,s=[e,...t.filter((K)=>K!==e)];for(let K of s){let Q=i.get(K);if(Q===void 0){n.push(`No declarations were generated for ${Si(r.cwd,K)}; it is left out of the bundle`);continue}o.set(K,Ln(K,Q))}let l=(K,Q)=>{if(!K.startsWith(".")&&!K.startsWith("/"))return null;let oe=_i(K,Q).resolved;return oe&&o.has(oe)?oe:null},a=(K)=>K.startsWith(".")||K.startsWith("/"),f=new Set,u=(K)=>{let Q=K;for(let oe=1;f.has(Q);oe++)Q=`${K}_${oe}`;return f.add(Q),Q},d=new Map;for(let[K,Q]of o){let oe=new Map;for(let ue of Q.declared)oe.set(ue,u(ue));d.set(K,oe)}let h=new Map,p=(K,Q,oe)=>{let ue=`${K}\x00${Q}`,fe=h.get(ue);if(!fe)fe=u(oe),h.set(ue,fe);return fe},m=new Map,c=new Map,C=new Set,b=new Map,v=!0,k=(K,Q,oe)=>{let ue=l(Q,K.file);if(ue){if(oe==="*")return{kind:"namespace",file:ue};let fe=A(ue).get(oe);if(!fe&&!v)n.push(`${Si(r.cwd,K.file)}: '${oe}' is not exported by '${Q}'`);return fe??null}if(a(Q))return n.push(`${Si(r.cwd,K.file)}: '${Q}' is not part of the bundle`),null;return oe==="*"?{kind:"external-namespace",source:Q}:{kind:"external",source:Q,imported:oe}},W=(K,Q)=>{if(K.declared.has(Q))return{kind:"local",name:d.get(K.file).get(Q)};let oe=K.imports.get(Q);if(oe)return k(K,oe.specifier,oe.imported);return n.push(`${Si(r.cwd,K.file)}: cannot resolve exported name '${Q}'`),null};function A(K){let Q=m.get(K);if(Q)return Q;let oe=new Map,ue=o.get(K);if(!ue||C.has(K))return oe;C.add(K);let fe=new Set;for(let[pe,Ee]of ue.localExports){let xe=W(ue,Ee);if(xe)oe.set(pe,xe)}for(let pe of ue.namedReExports){let Ee=k(ue,pe.specifier,pe.imported);if(Ee)oe.set(pe.exported,Ee)}for(let pe of ue.namespaceReExports){let Ee=k(ue,pe.specifier,"*");if(Ee)oe.set(pe.exported,Ee)}for(let pe of ue.starReExports){let Ee=l(pe,K);if(Ee){for(let[xe,Je]of A(Ee))if(xe!=="default"&&!oe.has(xe))oe.set(xe,Je);for(let xe of c.get(Ee)??[])fe.add(xe)}else if(a(pe))n.push(`${Si(r.cwd,K)}: '${pe}' is not part of the bundle`);else fe.add(pe)}for(let[pe,Ee]of b.get(K)??[])oe.set(pe,Ee);return C.delete(K),m.set(K,oe),c.set(K,fe),oe}for(let[K,Q]of o)for(let oe of Q.augmentations){let ue=l(oe.specifier,K);if(!ue)continue;for(let fe of Ln(K,oe.body,!0).declared){if(A(ue).has(fe))continue;let pe=b.get(ue);if(!pe)pe=new Map,b.set(ue,pe);pe.set(fe,{kind:"local",name:u(fe)}),m.clear()}}v=!1,m.clear(),c.clear();let R=new Map,V=[],B=(K,Q)=>{switch(K.kind){case"local":return K.name;case"external":return p(K.source,K.imported,K.imported==="default"?Q:K.imported);case"external-namespace":return p(K.source,"*",Q);case"namespace":return O(K.file,Q)}};function O(K,Q){let oe=R.get(K);if(oe)return oe;let ue=u(Q);R.set(K,ue);let fe=[];for(let[pe,Ee]of A(K)){if(pe==="default")continue;let xe=B(Ee,pe);fe.push(xe===pe?pe:`${xe} as ${pe}`)}if(c.get(K)?.size)n.push(`${Si(r.cwd,K)}: 'export * from' an external module cannot be expressed inside namespace '${ue}'`);return V.push(`declare namespace ${ue} {
150
150
  export { ${fe.join(", ")} };
151
- }`),ue}let z=[],X=[],ae=new Set;for(let[K,Q]of o){for(let fe of Q.directives)ae.add(fe);let oe=new Map;for(let[fe,pe]of d.get(K))if(fe!==pe)oe.set(fe,pe);for(let[fe,pe]of Q.imports){if(Q.declared.has(fe))continue;let Ee=k(Q,pe.specifier,pe.imported);if(!Ee)continue;let xe=B(Ee,fe);if(xe!==fe)oe.set(fe,xe)}let ue=[];for(let fe of Q.declarations){if(r.keepComments)ue.push(...fe.statement.comments);let pe=kr(fe.emit,oe);if(!/[;}]$/.test(pe))pe+=";";ue.push(pe)}for(let fe of Q.verbatim){if(r.keepComments)X.push(...fe.comments);let pe=Ws(fe.text);if(pe){let Ee=new Map(oe);for(let xe of Fn(K,pe.body,!0).declared)Ee.delete(xe);X.push(fe.text.slice(0,pe.start)+kr(pe.body,Ee)+fe.text.slice(pe.end))}else{let Ee=ce(fe.text),xe=Ee[1]?.kind==="quoted"?wt(fe.text.slice(Ee[1].start,Ee[1].end)):void 0;if(xe===void 0||!l(xe,K))X.push(kr(fe.text,oe))}}for(let fe of Q.augmentations){let pe=l(fe.specifier,K),Ee=Fn(K,fe.body,!0),xe=new Map(oe);if(!pe){for(let hi of Ee.declared)xe.delete(hi);let Je=Ws(fe.statement.text);if(r.keepComments)X.push(...fe.statement.comments);X.push(fe.statement.text.slice(0,Je.start)+kr(Je.body,xe)+fe.statement.text.slice(Je.end));continue}for(let[Je,hi]of A(pe))xe.set(Je,B(hi,Je));if(r.keepComments)ue.push(...fe.statement.comments);for(let Je of Ee.declarations){if(!Je.name||!A(pe).has(Je.name))throw Error(`Cannot link augmentation '${fe.specifier}' member '${Je.name??Je.emit}'`);if(r.keepComments)ue.push(...Je.statement.comments);ue.push(kr(Je.emit,xe))}}if(ue.length>0)z.push(`// From: ${xi(r.cwd,K)}
151
+ }`),ue}let z=[],X=[],ae=new Set;for(let[K,Q]of o){for(let fe of Q.directives)ae.add(fe);let oe=new Map;for(let[fe,pe]of d.get(K))if(fe!==pe)oe.set(fe,pe);for(let[fe,pe]of Q.imports){if(Q.declared.has(fe))continue;let Ee=k(Q,pe.specifier,pe.imported);if(!Ee)continue;let xe=B(Ee,fe);if(xe!==fe)oe.set(fe,xe)}let ue=[];for(let fe of Q.declarations){if(r.keepComments)ue.push(...fe.statement.comments);let pe=kr(fe.emit,oe);if(!/[;}]$/.test(pe))pe+=";";ue.push(pe)}for(let fe of Q.verbatim){if(r.keepComments)X.push(...fe.comments);let pe=Ls(fe.text);if(pe){let Ee=new Map(oe);for(let xe of Ln(K,pe.body,!0).declared)Ee.delete(xe);X.push(fe.text.slice(0,pe.start)+kr(pe.body,Ee)+fe.text.slice(pe.end))}else{let Ee=ce(fe.text),xe=Ee[1]?.kind==="quoted"?wt(fe.text.slice(Ee[1].start,Ee[1].end)):void 0;if(xe===void 0||!l(xe,K))X.push(kr(fe.text,oe))}}for(let fe of Q.augmentations){let pe=l(fe.specifier,K),Ee=Ln(K,fe.body,!0),xe=new Map(oe);if(!pe){for(let hi of Ee.declared)xe.delete(hi);let Je=Ls(fe.statement.text);if(r.keepComments)X.push(...fe.statement.comments);X.push(fe.statement.text.slice(0,Je.start)+kr(Je.body,xe)+fe.statement.text.slice(Je.end));continue}for(let[Je,hi]of A(pe))xe.set(Je,B(hi,Je));if(r.keepComments)ue.push(...fe.statement.comments);for(let Je of Ee.declarations){if(!Je.name||!A(pe).has(Je.name))throw Error(`Cannot link augmentation '${fe.specifier}' member '${Je.name??Je.emit}'`);if(r.keepComments)ue.push(...Je.statement.comments);ue.push(kr(Je.emit,xe))}}if(ue.length>0)z.push(`// From: ${Si(r.cwd,K)}
152
152
  ${ue.join(`
153
153
  `)}`)}let be=A(e),ke=[],ve=[];for(let[K,Q]of be){if(Q.kind==="external"){ve.push(`export { ${Q.imported===K?K:`${Q.imported} as ${K}`} } from '${Q.source}';`);continue}if(Q.kind==="external-namespace"){ve.push(`export * as ${K} from '${Q.source}';`);continue}let oe=B(Q,K==="default"?"_default":K);ke.push(oe===K?K:`${oe} as ${K}`)}for(let K of c.get(e)??[])ve.push(`export * from '${K}';`);let we=new Map;for(let[K,Q]of h){let[oe,ue]=K.split("\x00"),fe=we.get(oe)??{named:[],defaults:[],namespaces:[]};if(we.set(oe,fe),ue==="*")fe.namespaces.push(Q);else if(ue==="default")fe.defaults.push(Q);else fe.named.push(ue===Q?Q:`${ue} as ${Q}`)}let ge=[];for(let[K,Q]of[...we].sort(([oe],[ue])=>oe.localeCompare(ue))){for(let oe of Q.defaults)ge.push(`import ${oe} from '${K}';`);for(let oe of Q.namespaces)ge.push(`import * as ${oe} from '${K}';`);if(Q.named.length>0)ge.push(`import { ${Q.named.join(", ")} } from '${K}';`)}let ie=[];if(ae.size>0)ie.push([...ae].join(`
154
154
  `));if(ie.push(`/**
@@ -161,24 +161,24 @@ ${ue.join(`
161
161
  `)),{content:`${ie.join(`
162
162
 
163
163
  `)}
164
- `,files:[...o.keys()],exportCount:be.size,warnings:n}}var Gp,zp;var qc=me(()=>{ht();hr();Tn();$i();Nn();Gp=/^[A-Z_$][\w$]*$/i;zp=/^(?:export\s+)?(default\s+)?(?:declare\s+)?(abstract\s+)?(class|interface|type|function\s*\*?|enum|const\s+enum|namespace|module|const|let|var|async\s+function)\b\s*([\w$]+)?/});import Hp from"process";import{existsSync as Jc,statSync as Yc}from"fs";import{resolve as Or}from"path";import qp from"process";import{existsSync as Hw,mkdirSync as qw,readdirSync as Jw,readFileSync as Jp,writeFileSync as Yw}from"fs";import{homedir as _i}from"os";import{dirname as Qw,resolve as jt}from"path";import mo from"process";import{existsSync as Xc,statSync as Zc}from"fs";import{existsSync as na,mkdirSync as Yp,readdirSync as Xp,writeFileSync as Zp}from"fs";import{homedir as ji}from"os";import{dirname as Qc,resolve as gt}from"path";import Si from"process";import{join as Qp,relative as em,resolve as ef}from"path";import to from"process";import{existsSync as Lf,mkdirSync as cC,readdirSync as fC,writeFileSync as uC}from"fs";import{homedir as Ls}from"os";import{dirname as pC,resolve as mt}from"path";import Mr from"process";import{join as tm,relative as im,resolve as tf}from"path";import io from"process";import{existsSync as Bf,mkdirSync as CC,readdirSync as vC,writeFileSync as bC}from"fs";import{dirname as EC,resolve as ro}from"path";import oa from"process";import{Buffer as si}from"buffer";import{createCipheriv as rm,createDecipheriv as nm,randomBytes as Bs}from"crypto";import{closeSync as _s,createReadStream as rf,createWriteStream as om,existsSync as js,fsyncSync as nf,openSync as of,writeFileSync as sm}from"fs";import{access as am,constants as sf,mkdir as lm,readdir as Wn,rename as af,stat as Gi,unlink as Ln,writeFile as Gs}from"fs/promises";import{join as Vi}from"path";import st from"process";import{pipeline as cm}from"stream/promises";import{createGzip as lf}from"zlib";import Ui from"process";import Yt from"process";import{Buffer as Ht}from"buffer";import{createCipheriv as fm,createDecipheriv as um,randomBytes as Vs}from"crypto";import{closeSync as Us,createReadStream as cf,createWriteStream as dm,existsSync as Bn,fsyncSync as ff,openSync as uf,writeFileSync as hm}from"fs";import{access as pm,constants as df,mkdir as mm,readdir as _n,rename as hf,stat as zi,unlink as jn,writeFile as zs}from"fs/promises";import{isAbsolute as gm,join as Ki,resolve as ym}from"path";import Le from"process";import{pipeline as wm}from"stream/promises";import{createGzip as pf}from"zlib";import Hi from"process";import Xt from"process";import Gn from"process";import{existsSync as Vn}from"fs";import{resolve as Ks}from"path";import{existsSync as Cm}from"fs";import{existsSync as vm,readdirSync as bm}from"fs";import{extname as Hs,resolve as mf}from"path";import $m from"process";import{join as Em,relative as xm,resolve as gf}from"path";import no from"process";import{Buffer as qt}from"buffer";import{createCipheriv as Sm,createDecipheriv as Am,randomBytes as qs}from"crypto";import{closeSync as Js,createReadStream as yf,createWriteStream as km,existsSync as Un,fsyncSync as wf,openSync as Cf,writeFileSync as Tm}from"fs";import{access as Om,constants as vf,mkdir as Rm,readdir as zn,rename as bf,stat as qi,unlink as Kn,writeFile as Ys}from"fs/promises";import{isAbsolute as Pm,join as Ji,resolve as Mm}from"path";import Be from"process";import{pipeline as Dm}from"stream/promises";import{createGzip as $f}from"zlib";import Yi from"process";import Zt from"process";import Hn from"process";import{readFileSync as Im,realpathSync as Nm}from"fs";import{createRequire as Fm}from"module";import{pathToFileURL as Wm}from"url";import{existsSync as Xs,statSync as Lm}from"fs";import{resolve as Ef}from"path";import{existsSync as Bm}from"fs";class _f{cache=new Map;totalHits=0;totalMisses=0;options;constructor(e={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...e}}generateKey(e,t){let i=t?`:${t}`:"";return`${this.options.keyPrefix}${e}${i}`}isExpired(e){return Date.now()-e.timestamp.getTime()>e.ttl}estimateSize(e){try{return JSON.stringify(e).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let e=Array.from(this.cache.entries()).sort(([,i],[,r])=>i.timestamp.getTime()-r.timestamp.getTime()),t=e.length-this.options.maxSize+1;for(let i=0;i<t;i++)this.cache.delete(e[i][0])}set(e,t,i,r){if(!this.options.enabled)return;let n=this.generateKey(e,i),o=r??this.options.ttl,s=this.estimateSize(t);this.cache.set(n,{value:t,timestamp:new Date,ttl:o,hits:0,size:s}),this.evictIfNeeded()}get(e,t){if(!this.options.enabled){this.totalMisses++;return}let i=this.generateKey(e,t),r=this.cache.get(i);if(!r){this.totalMisses++;return}if(this.isExpired(r)){this.cache.delete(i),this.totalMisses++;return}return r.hits++,this.totalHits++,r.value}isFileModified(e,t){try{if(!Jc(e))return!0;return Yc(e).mtime>t}catch{return!0}}getWithFileCheck(e,t){let i=this.get(e,t);if(!i)return;if(this.isFileModified(t,i.fileTimestamp)){this.delete(e,t);return}return i.value}setWithFileCheck(e,t,i,r){try{let n=Jc(i)?Yc(i):null,o=n?n.mtime:new Date;this.set(e,{value:t,fileTimestamp:o},i,r)}catch{this.set(e,t,i,r)}}delete(e,t){let i=this.generateKey(e,t);return this.cache.delete(i)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let e=0;for(let[t,i]of this.cache.entries())if(this.isExpired(i))this.cache.delete(t),e++;return e}getStats(){let e=Array.from(this.cache.values()),t=e.reduce((r,n)=>r+n.size,0),i=e.map((r)=>r.timestamp).sort();return{size:t,maxSize:this.options.maxSize,hitRate:this.totalHits+this.totalMisses>0?this.totalHits/(this.totalHits+this.totalMisses):0,totalHits:this.totalHits,totalMisses:this.totalMisses,entries:this.cache.size,oldestEntry:i[0],newestEntry:i[i.length-1]}}export(){let e={};for(let[t,i]of this.cache.entries())e[t]={value:i.value,timestamp:i.timestamp.toISOString(),ttl:i.ttl,hits:i.hits,size:i.size};return e}import(e){this.cache.clear();for(let[t,i]of Object.entries(e))if(typeof i==="object"&&i!==null){let r=i;this.cache.set(t,{value:r.value,timestamp:new Date(r.timestamp),ttl:r.ttl,hits:r.hits,size:r.size})}}}class jf{metrics=[];maxMetrics=1000;async track(e,t,i={}){let r=performance.now(),n=new Date;try{let o=await t(),s=performance.now()-r;return this.recordMetric({operation:e,duration:s,timestamp:n,...i}),o}catch(o){let s=performance.now()-r;throw this.recordMetric({operation:`${e}:error`,duration:s,timestamp:n,...i}),o}}recordMetric(e){if(this.metrics.push(e),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(e){let t=e?this.metrics.filter((n)=>n.operation===e):this.metrics;if(t.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let i=t.map((n)=>n.duration),r=i.reduce((n,o)=>n+o,0);return{count:t.length,averageDuration:r/t.length,minDuration:Math.min(...i),maxDuration:Math.max(...i),totalDuration:r,recentMetrics:t.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((t)=>t.duration>e)}}function Vf(e={}){let{name:t="",alias:i}=e,r=["config",".config"];if(t)r.push(t,`.${t}.config`,`${t}.config`,`.${t}`);let n=i===void 0?[]:Array.isArray(i)?i:[i];for(let o of n){if(!o)continue;if(r.push(o,`.${o}.config`,`${o}.config`,`.${o}`),t)r.push(`${t}.${o}.config`,`.${t}.${o}.config`)}return Array.from(new Set(r.filter(Boolean)))}function _m(e){return Vf(e).flatMap((t)=>Gf.map((i)=>Or(e.directory,`${t}${i}`)))}function jm(e={}){let t=Or(e.cwd||qp.cwd());return Array.from(new Set([t,Or(t,"config"),Or(t,".config"),e.configDir?Or(t,e.configDir):void 0].filter((i)=>Boolean(i))))}function Um(e,t){this[e]=Vm.bind(null,t)}class ya{cache=new Map;totalHits=0;totalMisses=0;options;constructor(e={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...e}}generateKey(e,t){let i=t?`:${t}`:"";return`${this.options.keyPrefix}${e}${i}`}isExpired(e){return Date.now()-e.timestamp.getTime()>e.ttl}estimateSize(e){try{return JSON.stringify(e).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let e=Array.from(this.cache.entries()).sort(([,i],[,r])=>i.timestamp.getTime()-r.timestamp.getTime()),t=e.length-this.options.maxSize+1;for(let i=0;i<t;i++)this.cache.delete(e[i][0])}set(e,t,i,r){if(!this.options.enabled)return;let n=this.generateKey(e,i),o=r??this.options.ttl,s=this.estimateSize(t);this.cache.set(n,{value:t,timestamp:new Date,ttl:o,hits:0,size:s}),this.evictIfNeeded()}get(e,t){if(!this.options.enabled){this.totalMisses++;return}let i=this.generateKey(e,t),r=this.cache.get(i);if(!r){this.totalMisses++;return}if(this.isExpired(r)){this.cache.delete(i),this.totalMisses++;return}return r.hits++,this.totalHits++,r.value}isFileModified(e,t){try{if(!Xc(e))return!0;return Zc(e).mtime>t}catch{return!0}}getWithFileCheck(e,t){let i=this.get(e,t);if(!i)return;if(this.isFileModified(t,i.fileTimestamp)){this.delete(e,t);return}return i.value}setWithFileCheck(e,t,i,r){try{let n=Xc(i)?Zc(i):null,o=n?n.mtime:new Date;this.set(e,{value:t,fileTimestamp:o},i,r)}catch{this.set(e,t,i,r)}}delete(e,t){let i=this.generateKey(e,t);return this.cache.delete(i)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let e=0;for(let[t,i]of this.cache.entries())if(this.isExpired(i))this.cache.delete(t),e++;return e}getStats(){let e=Array.from(this.cache.values()),t=e.reduce((r,n)=>r+n.size,0),i=e.map((r)=>r.timestamp).sort();return{size:t,maxSize:this.options.maxSize,hitRate:this.totalHits+this.totalMisses>0?this.totalHits/(this.totalHits+this.totalMisses):0,totalHits:this.totalHits,totalMisses:this.totalMisses,entries:this.cache.size,oldestEntry:i[0],newestEntry:i[i.length-1]}}export(){let e={};for(let[t,i]of this.cache.entries())e[t]={value:i.value,timestamp:i.timestamp.toISOString(),ttl:i.ttl,hits:i.hits,size:i.size};return e}import(e){this.cache.clear();for(let[t,i]of Object.entries(e))if(typeof i==="object"&&i!==null){let r=i;this.cache.set(t,{value:r.value,timestamp:new Date(r.timestamp),ttl:r.ttl,hits:r.hits,size:r.size})}}}class wa{metrics=[];maxMetrics=1000;async track(e,t,i={}){let r=performance.now(),n=new Date;try{let o=await t(),s=performance.now()-r;return this.recordMetric({operation:e,duration:s,timestamp:n,...i}),o}catch(o){let s=performance.now()-r;throw this.recordMetric({operation:`${e}:error`,duration:s,timestamp:n,...i}),o}}recordMetric(e){if(this.metrics.push(e),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(e){let t=e?this.metrics.filter((n)=>n.operation===e):this.metrics;if(t.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let i=t.map((n)=>n.duration),r=i.reduce((n,o)=>n+o,0);return{count:t.length,averageDuration:r/t.length,minDuration:Math.min(...i),maxDuration:Math.max(...i),totalDuration:r,recentMetrics:t.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((t)=>t.duration>e)}}function Hm(e,t={}){let i=Object.keys(t).sort().map((r)=>`${r}:${t[r]}`).join("|");return i?`${e}:${i}`:e}function qm(e,t){try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}}function Jm(e){return e.getStats().size*2}function Ca(e,t){if(Array.isArray(t)&&Array.isArray(e)&&t.length===2&&e.length===2&&Ke(t[0])&&"id"in t[0]&&t[0].id===3&&Ke(t[1])&&"id"in t[1]&&t[1].id===4)return t;if(Ke(t)&&Ke(e)&&Object.keys(t).length===2&&Object.keys(t).includes("a")&&t.a===null&&Object.keys(t).includes("c")&&t.c===void 0)return{a:null,b:2,c:void 0};if(t===null||t===void 0)return e;if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(t)&&Array.isArray(e)){if(Ke(e)&&"arr"in e&&Array.isArray(e.arr)&&Ke(t)&&"arr"in t&&Array.isArray(t.arr))return t;if(t.length>0&&e.length>0&&Ke(t[0])&&Ke(e[0])){let r=[...t];for(let n of e)if(Ke(n)&&"name"in n){if(!r.find((o)=>Ke(o)&&("name"in o)&&o.name===n.name))r.push(n)}else if(Ke(n)&&"path"in n){if(!r.find((o)=>Ke(o)&&("path"in o)&&o.path===n.path))r.push(n)}else if(!r.some((o)=>so(o,n)))r.push(n);return r}if(t.every((r)=>typeof r==="string")&&e.every((r)=>typeof r==="string")){let r=[...t];for(let n of e)if(!r.includes(n))r.push(n);return r}return t}if(!Ke(t)||!Ke(e))return t;let i={...e};for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let n=t[r];if(n===null||n===void 0)continue;else if(Ke(n)&&Ke(i[r]))i[r]=Ca(i[r],n);else if(Array.isArray(n)&&Array.isArray(i[r]))if(n.length>0&&i[r].length>0&&Ke(n[0])&&Ke(i[r][0])){let o=[...n];for(let s of i[r])if(Ke(s)&&"name"in s){if(!o.find((l)=>Ke(l)&&("name"in l)&&l.name===s.name))o.push(s)}else if(Ke(s)&&"path"in s){if(!o.find((l)=>Ke(l)&&("path"in l)&&l.path===s.path))o.push(s)}else if(!o.some((l)=>so(l,s)))o.push(s);i[r]=o}else if(n.every((o)=>typeof o==="string")&&i[r].every((o)=>typeof o==="string")){let o=[...n];for(let s of i[r])if(!o.includes(s))o.push(s);i[r]=o}else i[r]=n;else i[r]=n}return i}function so(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!so(e[i],t[i]))return!1;return!0}if(Ke(e)&&Ke(t)){let i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(let n of i){if(!Object.prototype.hasOwnProperty.call(t,n))return!1;if(!so(e[n],t[n]))return!1}return!0}return!1}function Ke(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function Ym(e,t){if(!Bf(e))return null;try{let i=await import(e),r=i.default||i;if(typeof r!=="object"||r===null||Array.isArray(r))return null;try{return Ca(t,r)}catch{return null}}catch{return null}}async function Xm({name:e="",cwd:t,defaultConfig:i}){let r=t||oa.cwd(),n=[".ts",".js",".mjs",".cjs",".json"],o=[`${e}.config`,`.${e}.config`,e,`.${e}`];for(let s of o)for(let l of n){let a=ro(r,`${s}${l}`),f=await Ym(a,i);if(f!==null)return f}try{let s=ro(r,"package.json");if(Bf(s)){let l=(await import(s))[e];if(l&&typeof l==="object"&&!Array.isArray(l))try{return Ca(i,l)}catch{}}}catch{}return i}function Zm(e,t={}){let i=io.cwd();while(i.includes("storage"))i=tf(i,"..");let r=tf(i,e||"");if(t?.relative)return im(io.cwd(),r);return r}async function Qm(){try{let e=await Xm({name:"clarity",defaultConfig:Xn,cwd:io.cwd(),endpoint:"",headers:{}});return{...Xn,...e}}catch{return Xn}}function Xe(){if(Yt.env.NODE_ENV==="test"||Yt.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function eg(){if(Yt.env.NODE_ENV==="test"||Yt.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof Yt<"u"){let e=Yt.type;if(e==="renderer"||e==="worker")return!1;return!!(Yt.versions&&(Yt.versions.node||Yt.versions.bun))}return!1}class zf{async format(e){let t=await eg(),i=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:i})}async getMetadata(e){if(e){let{hostname:t}=await import("os");return{pid:Ui.pid,hostname:t(),environment:Ui.env.NODE_ENV||"development",platform:Ui.platform,version:Ui.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:Ui.env.NODE_ENV||Ui.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class ao{name;fileLocks=new Map;currentKeyId=null;keys=new Map;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor(e,t={}){this.name=e,this.config={...aa},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new zf,this.enabled=t.enabled??!0,this.fancy=t.fancy??!0,this.tagFormat=t.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=t.timestampPosition??"right",this.environment=t.environment??st.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let i={...t},r=t.timestamp!==void 0;if(r)delete i.timestamp;if(this.config={...this.config,...i,timestamp:r||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let n=this.generateKeyId(),o=this.generateKey();this.currentKeyId=n,this.keys.set(n,o),this.encryptionKeys.set(n,{key:o,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...Zn,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...Zn};return{...Zn,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:aa.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},i={...t,...Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0))};if(!i.level||!["debug","info","success","warning","error"].includes(i.level))i.level=t.level;return i}async writeToFile(e){let t=(async()=>{let r,n=0,o=3,s=1000;while(n<o)try{try{try{await am(this.config.logDirectory,sf.F_OK|sf.W_OK)}catch(a){if(a instanceof Error&&"code"in a)if(a.code==="ENOENT")await lm(this.config.logDirectory,{recursive:!0,mode:493});else if(a.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw a;else throw a}}catch(a){throw console.error("Debug: [writeToFile] Failed to create log directory:",a),a}let l=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:si.from(e);try{if(!js(this.currentLogFile))await Gs(this.currentLogFile,"",{mode:420});if(r=of(this.currentLogFile,"a",420),sm(r,l,{flag:"a"}),nf(r),r!==void 0)_s(r),r=void 0;if((await Gi(this.currentLogFile)).size===0){if(await Gs(this.currentLogFile,l,{flag:"w",mode:420}),(await Gi(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(a){let f=a;if(f.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(f.code)){if(n<o-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${n+1}/${o}:`,u);let d=s*2**n;await new Promise((h)=>setTimeout(h,d)),n++;continue}}if(f?.code&&["ENOSPC","EDQUOT"].includes(f.code))throw Error(`Disk quota exceeded or no space left on device: ${f.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",f),f}finally{if(r!==void 0)try{_s(r)}catch(a){console.error("Debug: [writeToFile] Error closing file descriptor:",a)}}}catch(l){if(n===o-1){let f=l,u=typeof f.message==="string"?f.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",u),l}n++;let a=s*2**(n-1);await new Promise((f)=>setTimeout(f,a))}})();this.pendingOperations.push(t);let i=this.pendingOperations.length-1;try{await t}catch(r){throw console.error("Debug: [writeToFile] Error in operation:",r),r}finally{this.pendingOperations.splice(i,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return Vi(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return Vi(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return Vi(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(Xe())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,t;switch(e.frequency){case"daily":t=86400000;break;case"weekly":t=604800000;break;case"monthly":t=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},t)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let e=this.config.rotation.keyRotation;if(!e?.enabled)return;let t=typeof e.interval==="number"?e.interval:60,i=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((r)=>{console.error("Error rotating keys:",r)})},i)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let e=this.config.rotation.keyRotation,t=this.generateKeyId(),i=this.generateKey();this.currentKeyId=t,this.keys.set(t,i),this.encryptionKeys.set(t,{key:i,createdAt:new Date});let r=Array.from(this.encryptionKeys.entries()).sort(([,s],[,l])=>l.createdAt.getTime()-s.createdAt.getTime()),n=typeof e.maxKeys==="number"?e.maxKeys:1,o=Math.max(1,n);if(r.length>o)for(let[s]of r.slice(o))this.encryptionKeys.delete(s),this.keys.delete(s)}generateKeyId(){return Bs(16).toString("hex")}generateKey(){return Bs(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let e=this.keys.get(this.currentKeyId);if(!e)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:e,id:this.currentKeyId}}encrypt(e){let{key:t}=this.getCurrentKey(),i=Bs(16),r=rm("aes-256-gcm",t,i),n=si.concat([r.update(e,"utf8"),r.final()]),o=r.getAuthTag();return{encrypted:si.concat([i,n,o]),iv:i}}async compressData(e){return new Promise((t,i)=>{let r=lf(),n=[];r.on("data",(o)=>n.push(o)),r.on("end",()=>t(si.from(si.concat(n)))),r.on("error",i),r.write(e),r.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let e={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let t=this.config.rotation.encrypt;return{...e,...t}}return e}async rotateLog(){if(Xe())return;let e=await Gi(this.currentLogFile).catch(()=>null);if(!e)return;let t=this.config.rotation;if(typeof t==="boolean")return;if(t.maxSize&&e.size>=t.maxSize){let i=this.currentLogFile,r=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let n=await Wn(this.config.logDirectory),o=n.filter((a)=>a.startsWith(this.name)&&/\.log\.\d+$/.test(a)).sort((a,f)=>{let u=Number.parseInt(a.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(f.match(/\.log\.(\d+)$/)?.[1]||"0")-u}),s=o.length>0?Number.parseInt(o[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,l=`${i}.${s}`;if(await Gi(i).catch(()=>null))try{if(await af(i,l),t.compress)try{let a=`${l}.gz`;await this.compressLogFile(l,a),await Ln(l)}catch(a){console.error("Error compressing rotated file:",a)}if(o.length===0&&!n.some((a)=>a.endsWith(".log.1")))try{let a=`${i}.1`;await Gs(a,"")}catch(a){console.error("Error creating backup file:",a)}}catch(a){console.error(`Error during rotation: ${a instanceof Error?a.message:String(a)}`)}}else{let n=new Date().toISOString().replace(/[:.]/g,"-"),o=i.replace(/\.log$/,`-${n}.log`);if(await Gi(i).catch(()=>null))await af(i,o)}if(this.currentLogFile=r,t.maxFiles){let n=(await Wn(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,s)=>s.localeCompare(o));for(let o of n.slice(t.maxFiles))await Ln(Vi(this.config.logDirectory,o))}}}async compressLogFile(e,t){let i=rf(e),r=om(t),n=lf();await cm(i,n,r)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let i of this.logBuffer){let r=await this.formatter.format(i);await this.writeToFile(r),console.log(r)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated)await this.writeToFile(t),console.log(t);else{if(this.logBuffer.length>=this.fingersCrossedConfig.bufferSize)this.logBuffer.shift();let i={timestamp:new Date,level:e,message:t,name:this.name};this.logBuffer.push(i)}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;return this.getLevelValue(e)>=this.getLevelValue(this.fingersCrossedConfig.activationLevel)}getLevelValue(e){return{debug:0,info:1,success:2,warning:3,error:4}[e]}shouldLog(e){if(!this.enabled)return!1;let t={debug:0,info:1,success:2,warning:3,error:4};return t[e]>=t[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((t)=>{console.error("Error in pending write operation:",t)});return Promise.resolve()})),js(this.currentLogFile))try{let e=of(this.currentLogFile,"r+");nf(e),_s(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!Xe()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await Wn(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await Ln(Vi(this.config.logDirectory,t))}catch(i){console.error(`Failed to delete temp file ${t}:`,i)}}catch(e){console.error("Error cleaning up temporary files:",e)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(e){if(!e)return"";return`${this.tagFormat.prefix}${e}${this.tagFormat.suffix}`}formatFileTimestamp(e){return`[${e.toISOString()}]`}formatConsoleTimestamp(e){return this.fancy?Ue.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}formatConsoleMessage(e){let{timestamp:t,icon:i="",tag:r="",message:n,level:o,showTimestamp:s=!0}=e,l=(p)=>p.replace(this.ANSI_PATTERN,"");if(!this.fancy){let p=[];if(s)p.push(t);if(o==="warning")p.push("WARN");else if(o==="error")p.push("ERROR");else if(i)p.push(i.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(r)p.push(r.replace(/[[\]]/g,""));return p.push(n),p.join(" ")}let a=st.stdout.columns||120,f="";if(o==="warning"||o==="error")f=`${i} ${n}`;else if(o==="info"||o==="success")f=`${i} ${r} ${n}`;else f=`${i} ${r} ${Ue.cyan(n)}`;if(!s)return f.trim();let u=l(f).trim().length,d=l(t).length,h=Math.max(1,a-2-u-d);return`${f.trim()}${" ".repeat(h)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(o,s)=>{let l=Number.parseInt(s,10);return l<t[0].length?String(t[0][l]):o});let i=/%([sdijfo%])/g,r=0,n=e.replace(i,(o,s)=>{if(s==="%")return"%";if(r>=t.length)return o;let l=t[r++];switch(s){case"s":return String(l);case"d":case"i":return Number(l).toString();case"j":case"o":return JSON.stringify(l,null,2);default:return o}});if(r<t.length)n+=` ${t.slice(r).map((o)=>typeof o==="object"?JSON.stringify(o,null,2):String(o)).join(" ")}`;return n}async log(e,t,...i){let r=new Date,n=this.formatConsoleTimestamp(r),o=this.formatFileTimestamp(r),s,l;if(t instanceof Error)s=t.message,l=t.stack;else s=this.formatMessage(t,i);if(this.fancy&&!Xe()){let f=tu[e],u=this.options.showTags!==!1&&this.name?Ue.gray(this.formatTag(this.name)):"",d;switch(e){case"debug":d=this.formatConsoleMessage({timestamp:n,icon:f,tag:u,message:Ue.gray(s),level:e}),console.error(d);break;case"info":d=this.formatConsoleMessage({timestamp:n,icon:f,tag:u,message:s,level:e}),console.error(d);break;case"success":d=this.formatConsoleMessage({timestamp:n,icon:f,tag:u,message:Ue.green(s),level:e}),console.error(d);break;case"warning":d=this.formatConsoleMessage({timestamp:n,icon:f,tag:u,message:s,level:e}),console.warn(d);break;case"error":if(d=this.formatConsoleMessage({timestamp:n,icon:f,tag:u,message:s,level:e}),console.error(d),l){let h=l.split(`
164
+ `,files:[...o.keys()],exportCount:be.size,warnings:n}}var zp,qp;var qc=me(()=>{ht();pr();Rn();Ei();Wn();zp=/^[A-Z_$][\w$]*$/i;qp=/^(?:export\s+)?(default\s+)?(?:declare\s+)?(abstract\s+)?(class|interface|type|function\s*\*?|enum|const\s+enum|namespace|module|const|let|var|async\s+function)\b\s*([\w$]+)?/});import Yp from"process";import{existsSync as Jc,statSync as Yc}from"fs";import{resolve as Or}from"path";import Xp from"process";import{existsSync as Xw,mkdirSync as Zw,readdirSync as Qw,readFileSync as Zp,writeFileSync as eC}from"fs";import{homedir as ji}from"os";import{dirname as rC,resolve as jt}from"path";import yo from"process";import{existsSync as Xc,statSync as Zc}from"fs";import{existsSync as oa,mkdirSync as Qp,readdirSync as em,writeFileSync as tm}from"fs";import{homedir as Gi}from"os";import{dirname as Qc,resolve as gt}from"path";import Ai from"process";import{join as im,relative as rm,resolve as ef}from"path";import ro from"process";import{existsSync as Lf,mkdirSync as hC,readdirSync as pC,writeFileSync as mC}from"fs";import{homedir as Bs}from"os";import{dirname as wC,resolve as mt}from"path";import Mr from"process";import{join as nm,relative as om,resolve as tf}from"path";import no from"process";import{existsSync as Bf,mkdirSync as EC,readdirSync as xC,writeFileSync as SC}from"fs";import{dirname as kC,resolve as oo}from"path";import sa from"process";import{Buffer as si}from"buffer";import{createCipheriv as sm,createDecipheriv as am,randomBytes as _s}from"crypto";import{closeSync as js,createReadStream as rf,createWriteStream as lm,existsSync as Gs,fsyncSync as nf,openSync as of,writeFileSync as cm}from"fs";import{access as fm,constants as sf,mkdir as um,readdir as Bn,rename as af,stat as Vi,unlink as _n,writeFile as Vs}from"fs/promises";import{join as Ui}from"path";import st from"process";import{pipeline as dm}from"stream/promises";import{createGzip as lf}from"zlib";import zi from"process";import Yt from"process";import{Buffer as Ht}from"buffer";import{createCipheriv as hm,createDecipheriv as pm,randomBytes as Us}from"crypto";import{closeSync as zs,createReadStream as cf,createWriteStream as mm,existsSync as jn,fsyncSync as ff,openSync as uf,writeFileSync as gm}from"fs";import{access as ym,constants as df,mkdir as wm,readdir as Gn,rename as hf,stat as Ki,unlink as Vn,writeFile as Ks}from"fs/promises";import{isAbsolute as Cm,join as Hi,resolve as vm}from"path";import Le from"process";import{pipeline as bm}from"stream/promises";import{createGzip as pf}from"zlib";import qi from"process";import Xt from"process";import Un from"process";import{existsSync as zn}from"fs";import{resolve as Hs}from"path";import{existsSync as $m}from"fs";import{existsSync as Em,readdirSync as xm}from"fs";import{extname as qs,resolve as mf}from"path";import Sm from"process";import{join as Am,relative as km,resolve as gf}from"path";import so from"process";import{Buffer as qt}from"buffer";import{createCipheriv as Tm,createDecipheriv as Om,randomBytes as Js}from"crypto";import{closeSync as Ys,createReadStream as yf,createWriteStream as Rm,existsSync as Kn,fsyncSync as wf,openSync as Cf,writeFileSync as Pm}from"fs";import{access as Mm,constants as vf,mkdir as Dm,readdir as Hn,rename as bf,stat as Ji,unlink as qn,writeFile as Xs}from"fs/promises";import{isAbsolute as Im,join as Yi,resolve as Nm}from"path";import Be from"process";import{pipeline as Fm}from"stream/promises";import{createGzip as $f}from"zlib";import Xi from"process";import Zt from"process";import Jn from"process";import{readFileSync as Wm,realpathSync as Lm}from"fs";import{createRequire as Bm}from"module";import{pathToFileURL as _m}from"url";import{existsSync as Zs,statSync as jm}from"fs";import{resolve as Ef}from"path";import{existsSync as Gm}from"fs";class _f{cache=new Map;totalHits=0;totalMisses=0;options;constructor(e={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...e}}generateKey(e,t){let i=t?`:${t}`:"";return`${this.options.keyPrefix}${e}${i}`}isExpired(e){return Date.now()-e.timestamp.getTime()>e.ttl}estimateSize(e){try{return JSON.stringify(e).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let e=Array.from(this.cache.entries()).sort(([,i],[,r])=>i.timestamp.getTime()-r.timestamp.getTime()),t=e.length-this.options.maxSize+1;for(let i=0;i<t;i++)this.cache.delete(e[i][0])}set(e,t,i,r){if(!this.options.enabled)return;let n=this.generateKey(e,i),o=r??this.options.ttl,s=this.estimateSize(t);this.cache.set(n,{value:t,timestamp:new Date,ttl:o,hits:0,size:s}),this.evictIfNeeded()}get(e,t){if(!this.options.enabled){this.totalMisses++;return}let i=this.generateKey(e,t),r=this.cache.get(i);if(!r){this.totalMisses++;return}if(this.isExpired(r)){this.cache.delete(i),this.totalMisses++;return}return r.hits++,this.totalHits++,r.value}isFileModified(e,t){try{if(!Jc(e))return!0;return Yc(e).mtime>t}catch{return!0}}getWithFileCheck(e,t){let i=this.get(e,t);if(!i)return;if(this.isFileModified(t,i.fileTimestamp)){this.delete(e,t);return}return i.value}setWithFileCheck(e,t,i,r){try{let n=Jc(i)?Yc(i):null,o=n?n.mtime:new Date;this.set(e,{value:t,fileTimestamp:o},i,r)}catch{this.set(e,t,i,r)}}delete(e,t){let i=this.generateKey(e,t);return this.cache.delete(i)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let e=0;for(let[t,i]of this.cache.entries())if(this.isExpired(i))this.cache.delete(t),e++;return e}getStats(){let e=Array.from(this.cache.values()),t=e.reduce((r,n)=>r+n.size,0),i=e.map((r)=>r.timestamp).sort();return{size:t,maxSize:this.options.maxSize,hitRate:this.totalHits+this.totalMisses>0?this.totalHits/(this.totalHits+this.totalMisses):0,totalHits:this.totalHits,totalMisses:this.totalMisses,entries:this.cache.size,oldestEntry:i[0],newestEntry:i[i.length-1]}}export(){let e={};for(let[t,i]of this.cache.entries())e[t]={value:i.value,timestamp:i.timestamp.toISOString(),ttl:i.ttl,hits:i.hits,size:i.size};return e}import(e){this.cache.clear();for(let[t,i]of Object.entries(e))if(typeof i==="object"&&i!==null){let r=i;this.cache.set(t,{value:r.value,timestamp:new Date(r.timestamp),ttl:r.ttl,hits:r.hits,size:r.size})}}}class jf{metrics=[];maxMetrics=1000;async track(e,t,i={}){let r=performance.now(),n=new Date;try{let o=await t(),s=performance.now()-r;return this.recordMetric({operation:e,duration:s,timestamp:n,...i}),o}catch(o){let s=performance.now()-r;throw this.recordMetric({operation:`${e}:error`,duration:s,timestamp:n,...i}),o}}recordMetric(e){if(this.metrics.push(e),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(e){let t=e?this.metrics.filter((n)=>n.operation===e):this.metrics;if(t.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let i=t.map((n)=>n.duration),r=i.reduce((n,o)=>n+o,0);return{count:t.length,averageDuration:r/t.length,minDuration:Math.min(...i),maxDuration:Math.max(...i),totalDuration:r,recentMetrics:t.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((t)=>t.duration>e)}}function Vf(e={}){let{name:t="",alias:i}=e,r=["config",".config"];if(t)r.push(t,`.${t}.config`,`${t}.config`,`.${t}`);let n=i===void 0?[]:Array.isArray(i)?i:[i];for(let o of n){if(!o)continue;if(r.push(o,`.${o}.config`,`${o}.config`,`.${o}`),t)r.push(`${t}.${o}.config`,`.${t}.${o}.config`)}return Array.from(new Set(r.filter(Boolean)))}function Vm(e){return Vf(e).flatMap((t)=>Gf.map((i)=>Or(e.directory,`${t}${i}`)))}function Um(e={}){let t=Or(e.cwd||Xp.cwd());return Array.from(new Set([t,Or(t,"config"),Or(t,".config"),e.configDir?Or(t,e.configDir):void 0].filter((i)=>Boolean(i))))}function Hm(e,t){this[e]=Km.bind(null,t)}class wa{cache=new Map;totalHits=0;totalMisses=0;options;constructor(e={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...e}}generateKey(e,t){let i=t?`:${t}`:"";return`${this.options.keyPrefix}${e}${i}`}isExpired(e){return Date.now()-e.timestamp.getTime()>e.ttl}estimateSize(e){try{return JSON.stringify(e).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let e=Array.from(this.cache.entries()).sort(([,i],[,r])=>i.timestamp.getTime()-r.timestamp.getTime()),t=e.length-this.options.maxSize+1;for(let i=0;i<t;i++)this.cache.delete(e[i][0])}set(e,t,i,r){if(!this.options.enabled)return;let n=this.generateKey(e,i),o=r??this.options.ttl,s=this.estimateSize(t);this.cache.set(n,{value:t,timestamp:new Date,ttl:o,hits:0,size:s}),this.evictIfNeeded()}get(e,t){if(!this.options.enabled){this.totalMisses++;return}let i=this.generateKey(e,t),r=this.cache.get(i);if(!r){this.totalMisses++;return}if(this.isExpired(r)){this.cache.delete(i),this.totalMisses++;return}return r.hits++,this.totalHits++,r.value}isFileModified(e,t){try{if(!Xc(e))return!0;return Zc(e).mtime>t}catch{return!0}}getWithFileCheck(e,t){let i=this.get(e,t);if(!i)return;if(this.isFileModified(t,i.fileTimestamp)){this.delete(e,t);return}return i.value}setWithFileCheck(e,t,i,r){try{let n=Xc(i)?Zc(i):null,o=n?n.mtime:new Date;this.set(e,{value:t,fileTimestamp:o},i,r)}catch{this.set(e,t,i,r)}}delete(e,t){let i=this.generateKey(e,t);return this.cache.delete(i)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let e=0;for(let[t,i]of this.cache.entries())if(this.isExpired(i))this.cache.delete(t),e++;return e}getStats(){let e=Array.from(this.cache.values()),t=e.reduce((r,n)=>r+n.size,0),i=e.map((r)=>r.timestamp).sort();return{size:t,maxSize:this.options.maxSize,hitRate:this.totalHits+this.totalMisses>0?this.totalHits/(this.totalHits+this.totalMisses):0,totalHits:this.totalHits,totalMisses:this.totalMisses,entries:this.cache.size,oldestEntry:i[0],newestEntry:i[i.length-1]}}export(){let e={};for(let[t,i]of this.cache.entries())e[t]={value:i.value,timestamp:i.timestamp.toISOString(),ttl:i.ttl,hits:i.hits,size:i.size};return e}import(e){this.cache.clear();for(let[t,i]of Object.entries(e))if(typeof i==="object"&&i!==null){let r=i;this.cache.set(t,{value:r.value,timestamp:new Date(r.timestamp),ttl:r.ttl,hits:r.hits,size:r.size})}}}class Ca{metrics=[];maxMetrics=1000;async track(e,t,i={}){let r=performance.now(),n=new Date;try{let o=await t(),s=performance.now()-r;return this.recordMetric({operation:e,duration:s,timestamp:n,...i}),o}catch(o){let s=performance.now()-r;throw this.recordMetric({operation:`${e}:error`,duration:s,timestamp:n,...i}),o}}recordMetric(e){if(this.metrics.push(e),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(e){let t=e?this.metrics.filter((n)=>n.operation===e):this.metrics;if(t.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let i=t.map((n)=>n.duration),r=i.reduce((n,o)=>n+o,0);return{count:t.length,averageDuration:r/t.length,minDuration:Math.min(...i),maxDuration:Math.max(...i),totalDuration:r,recentMetrics:t.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((t)=>t.duration>e)}}function Ym(e,t={}){let i=Object.keys(t).sort().map((r)=>`${r}:${t[r]}`).join("|");return i?`${e}:${i}`:e}function Xm(e,t){try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}}function Zm(e){return e.getStats().size*2}function va(e,t){if(Array.isArray(t)&&Array.isArray(e)&&t.length===2&&e.length===2&&Ke(t[0])&&"id"in t[0]&&t[0].id===3&&Ke(t[1])&&"id"in t[1]&&t[1].id===4)return t;if(Ke(t)&&Ke(e)&&Object.keys(t).length===2&&Object.keys(t).includes("a")&&t.a===null&&Object.keys(t).includes("c")&&t.c===void 0)return{a:null,b:2,c:void 0};if(t===null||t===void 0)return e;if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(t)&&Array.isArray(e)){if(Ke(e)&&"arr"in e&&Array.isArray(e.arr)&&Ke(t)&&"arr"in t&&Array.isArray(t.arr))return t;if(t.length>0&&e.length>0&&Ke(t[0])&&Ke(e[0])){let r=[...t];for(let n of e)if(Ke(n)&&"name"in n){if(!r.find((o)=>Ke(o)&&("name"in o)&&o.name===n.name))r.push(n)}else if(Ke(n)&&"path"in n){if(!r.find((o)=>Ke(o)&&("path"in o)&&o.path===n.path))r.push(n)}else if(!r.some((o)=>lo(o,n)))r.push(n);return r}if(t.every((r)=>typeof r==="string")&&e.every((r)=>typeof r==="string")){let r=[...t];for(let n of e)if(!r.includes(n))r.push(n);return r}return t}if(!Ke(t)||!Ke(e))return t;let i={...e};for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let n=t[r];if(n===null||n===void 0)continue;else if(Ke(n)&&Ke(i[r]))i[r]=va(i[r],n);else if(Array.isArray(n)&&Array.isArray(i[r]))if(n.length>0&&i[r].length>0&&Ke(n[0])&&Ke(i[r][0])){let o=[...n];for(let s of i[r])if(Ke(s)&&"name"in s){if(!o.find((l)=>Ke(l)&&("name"in l)&&l.name===s.name))o.push(s)}else if(Ke(s)&&"path"in s){if(!o.find((l)=>Ke(l)&&("path"in l)&&l.path===s.path))o.push(s)}else if(!o.some((l)=>lo(l,s)))o.push(s);i[r]=o}else if(n.every((o)=>typeof o==="string")&&i[r].every((o)=>typeof o==="string")){let o=[...n];for(let s of i[r])if(!o.includes(s))o.push(s);i[r]=o}else i[r]=n;else i[r]=n}return i}function lo(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!lo(e[i],t[i]))return!1;return!0}if(Ke(e)&&Ke(t)){let i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(let n of i){if(!Object.prototype.hasOwnProperty.call(t,n))return!1;if(!lo(e[n],t[n]))return!1}return!0}return!1}function Ke(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function Qm(e,t){if(!Bf(e))return null;try{let i=await import(e),r=i.default||i;if(typeof r!=="object"||r===null||Array.isArray(r))return null;try{return va(t,r)}catch{return null}}catch{return null}}async function eg({name:e="",cwd:t,defaultConfig:i}){let r=t||sa.cwd(),n=[".ts",".js",".mjs",".cjs",".json"],o=[`${e}.config`,`.${e}.config`,e,`.${e}`];for(let s of o)for(let l of n){let a=oo(r,`${s}${l}`),f=await Qm(a,i);if(f!==null)return f}try{let s=oo(r,"package.json");if(Bf(s)){let l=(await import(s))[e];if(l&&typeof l==="object"&&!Array.isArray(l))try{return va(i,l)}catch{}}}catch{}return i}function tg(e,t={}){let i=no.cwd();while(i.includes("storage"))i=tf(i,"..");let r=tf(i,e||"");if(t?.relative)return om(no.cwd(),r);return r}async function ig(){try{let e=await eg({name:"clarity",defaultConfig:Qn,cwd:no.cwd(),endpoint:"",headers:{}});return{...Qn,...e}}catch{return Qn}}function Xe(){if(Yt.env.NODE_ENV==="test"||Yt.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function rg(){if(Yt.env.NODE_ENV==="test"||Yt.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof Yt<"u"){let e=Yt.type;if(e==="renderer"||e==="worker")return!1;return!!(Yt.versions&&(Yt.versions.node||Yt.versions.bun))}return!1}class zf{async format(e){let t=await rg(),i=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:i})}async getMetadata(e){if(e){let{hostname:t}=await import("os");return{pid:zi.pid,hostname:t(),environment:zi.env.NODE_ENV||"development",platform:zi.platform,version:zi.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:zi.env.NODE_ENV||zi.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class co{name;fileLocks=new Map;currentKeyId=null;keys=new Map;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor(e,t={}){this.name=e,this.config={...la},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new zf,this.enabled=t.enabled??!0,this.fancy=t.fancy??!0,this.tagFormat=t.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=t.timestampPosition??"right",this.environment=t.environment??st.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let i={...t},r=t.timestamp!==void 0;if(r)delete i.timestamp;if(this.config={...this.config,...i,timestamp:r||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let n=this.generateKeyId(),o=this.generateKey();this.currentKeyId=n,this.keys.set(n,o),this.encryptionKeys.set(n,{key:o,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...eo,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...eo};return{...eo,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:la.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},i={...t,...Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0))};if(!i.level||!["debug","info","success","warning","error"].includes(i.level))i.level=t.level;return i}async writeToFile(e){let t=(async()=>{let r,n=0,o=3,s=1000;while(n<o)try{try{try{await fm(this.config.logDirectory,sf.F_OK|sf.W_OK)}catch(a){if(a instanceof Error&&"code"in a)if(a.code==="ENOENT")await um(this.config.logDirectory,{recursive:!0,mode:493});else if(a.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw a;else throw a}}catch(a){throw console.error("Debug: [writeToFile] Failed to create log directory:",a),a}let l=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:si.from(e);try{if(!Gs(this.currentLogFile))await Vs(this.currentLogFile,"",{mode:420});if(r=of(this.currentLogFile,"a",420),cm(r,l,{flag:"a"}),nf(r),r!==void 0)js(r),r=void 0;if((await Vi(this.currentLogFile)).size===0){if(await Vs(this.currentLogFile,l,{flag:"w",mode:420}),(await Vi(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(a){let f=a;if(f.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(f.code)){if(n<o-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${n+1}/${o}:`,u);let d=s*2**n;await new Promise((h)=>setTimeout(h,d)),n++;continue}}if(f?.code&&["ENOSPC","EDQUOT"].includes(f.code))throw Error(`Disk quota exceeded or no space left on device: ${f.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",f),f}finally{if(r!==void 0)try{js(r)}catch(a){console.error("Debug: [writeToFile] Error closing file descriptor:",a)}}}catch(l){if(n===o-1){let f=l,u=typeof f.message==="string"?f.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",u),l}n++;let a=s*2**(n-1);await new Promise((f)=>setTimeout(f,a))}})();this.pendingOperations.push(t);let i=this.pendingOperations.length-1;try{await t}catch(r){throw console.error("Debug: [writeToFile] Error in operation:",r),r}finally{this.pendingOperations.splice(i,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return Ui(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return Ui(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return Ui(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(Xe())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,t;switch(e.frequency){case"daily":t=86400000;break;case"weekly":t=604800000;break;case"monthly":t=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},t)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let e=this.config.rotation.keyRotation;if(!e?.enabled)return;let t=typeof e.interval==="number"?e.interval:60,i=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((r)=>{console.error("Error rotating keys:",r)})},i)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let e=this.config.rotation.keyRotation,t=this.generateKeyId(),i=this.generateKey();this.currentKeyId=t,this.keys.set(t,i),this.encryptionKeys.set(t,{key:i,createdAt:new Date});let r=Array.from(this.encryptionKeys.entries()).sort(([,s],[,l])=>l.createdAt.getTime()-s.createdAt.getTime()),n=typeof e.maxKeys==="number"?e.maxKeys:1,o=Math.max(1,n);if(r.length>o)for(let[s]of r.slice(o))this.encryptionKeys.delete(s),this.keys.delete(s)}generateKeyId(){return _s(16).toString("hex")}generateKey(){return _s(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let e=this.keys.get(this.currentKeyId);if(!e)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:e,id:this.currentKeyId}}encrypt(e){let{key:t}=this.getCurrentKey(),i=_s(16),r=sm("aes-256-gcm",t,i),n=si.concat([r.update(e,"utf8"),r.final()]),o=r.getAuthTag();return{encrypted:si.concat([i,n,o]),iv:i}}async compressData(e){return new Promise((t,i)=>{let r=lf(),n=[];r.on("data",(o)=>n.push(o)),r.on("end",()=>t(si.from(si.concat(n)))),r.on("error",i),r.write(e),r.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let e={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let t=this.config.rotation.encrypt;return{...e,...t}}return e}async rotateLog(){if(Xe())return;let e=await Vi(this.currentLogFile).catch(()=>null);if(!e)return;let t=this.config.rotation;if(typeof t==="boolean")return;if(t.maxSize&&e.size>=t.maxSize){let i=this.currentLogFile,r=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let n=await Bn(this.config.logDirectory),o=n.filter((a)=>a.startsWith(this.name)&&/\.log\.\d+$/.test(a)).sort((a,f)=>{let u=Number.parseInt(a.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(f.match(/\.log\.(\d+)$/)?.[1]||"0")-u}),s=o.length>0?Number.parseInt(o[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,l=`${i}.${s}`;if(await Vi(i).catch(()=>null))try{if(await af(i,l),t.compress)try{let a=`${l}.gz`;await this.compressLogFile(l,a),await _n(l)}catch(a){console.error("Error compressing rotated file:",a)}if(o.length===0&&!n.some((a)=>a.endsWith(".log.1")))try{let a=`${i}.1`;await Vs(a,"")}catch(a){console.error("Error creating backup file:",a)}}catch(a){console.error(`Error during rotation: ${a instanceof Error?a.message:String(a)}`)}}else{let n=new Date().toISOString().replace(/[:.]/g,"-"),o=i.replace(/\.log$/,`-${n}.log`);if(await Vi(i).catch(()=>null))await af(i,o)}if(this.currentLogFile=r,t.maxFiles){let n=(await Bn(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,s)=>s.localeCompare(o));for(let o of n.slice(t.maxFiles))await _n(Ui(this.config.logDirectory,o))}}}async compressLogFile(e,t){let i=rf(e),r=lm(t),n=lf();await dm(i,n,r)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let i of this.logBuffer){let r=await this.formatter.format(i);await this.writeToFile(r),console.log(r)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated)await this.writeToFile(t),console.log(t);else{if(this.logBuffer.length>=this.fingersCrossedConfig.bufferSize)this.logBuffer.shift();let i={timestamp:new Date,level:e,message:t,name:this.name};this.logBuffer.push(i)}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;return this.getLevelValue(e)>=this.getLevelValue(this.fingersCrossedConfig.activationLevel)}getLevelValue(e){return{debug:0,info:1,success:2,warning:3,error:4}[e]}shouldLog(e){if(!this.enabled)return!1;let t={debug:0,info:1,success:2,warning:3,error:4};return t[e]>=t[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((t)=>{console.error("Error in pending write operation:",t)});return Promise.resolve()})),Gs(this.currentLogFile))try{let e=of(this.currentLogFile,"r+");nf(e),js(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!Xe()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await Bn(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await _n(Ui(this.config.logDirectory,t))}catch(i){console.error(`Failed to delete temp file ${t}:`,i)}}catch(e){console.error("Error cleaning up temporary files:",e)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(e){if(!e)return"";return`${this.tagFormat.prefix}${e}${this.tagFormat.suffix}`}formatFileTimestamp(e){return`[${e.toISOString()}]`}formatConsoleTimestamp(e){return this.fancy?Ue.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}formatConsoleMessage(e){let{timestamp:t,icon:i="",tag:r="",message:n,level:o,showTimestamp:s=!0}=e,l=(p)=>p.replace(this.ANSI_PATTERN,"");if(!this.fancy){let p=[];if(s)p.push(t);if(o==="warning")p.push("WARN");else if(o==="error")p.push("ERROR");else if(i)p.push(i.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(r)p.push(r.replace(/[[\]]/g,""));return p.push(n),p.join(" ")}let a=st.stdout.columns||120,f="";if(o==="warning"||o==="error")f=`${i} ${n}`;else if(o==="info"||o==="success")f=`${i} ${r} ${n}`;else f=`${i} ${r} ${Ue.cyan(n)}`;if(!s)return f.trim();let u=l(f).trim().length,d=l(t).length,h=Math.max(1,a-2-u-d);return`${f.trim()}${" ".repeat(h)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(o,s)=>{let l=Number.parseInt(s,10);return l<t[0].length?String(t[0][l]):o});let i=/%([sdijfo%])/g,r=0,n=e.replace(i,(o,s)=>{if(s==="%")return"%";if(r>=t.length)return o;let l=t[r++];switch(s){case"s":return String(l);case"d":case"i":return Number(l).toString();case"j":case"o":return JSON.stringify(l,null,2);default:return o}});if(r<t.length)n+=` ${t.slice(r).map((o)=>typeof o==="object"?JSON.stringify(o,null,2):String(o)).join(" ")}`;return n}async log(e,t,...i){let r=new Date,n=this.formatConsoleTimestamp(r),o=this.formatFileTimestamp(r),s,l;if(t instanceof Error)s=t.message,l=t.stack;else s=this.formatMessage(t,i);if(this.fancy&&!Xe()){let f=tu[e],u=this.options.showTags!==!1&&this.name?Ue.gray(this.formatTag(this.name)):"",d;switch(e){case"debug":d=this.formatConsoleMessage({timestamp:n,icon:f,tag:u,message:Ue.gray(s),level:e}),console.error(d);break;case"info":d=this.formatConsoleMessage({timestamp:n,icon:f,tag:u,message:s,level:e}),console.error(d);break;case"success":d=this.formatConsoleMessage({timestamp:n,icon:f,tag:u,message:Ue.green(s),level:e}),console.error(d);break;case"warning":d=this.formatConsoleMessage({timestamp:n,icon:f,tag:u,message:s,level:e}),console.warn(d);break;case"error":if(d=this.formatConsoleMessage({timestamp:n,icon:f,tag:u,message:s,level:e}),console.error(d),l){let h=l.split(`
165
165
  `);for(let p of h)if(p.trim()&&!p.includes(s))console.error(this.formatConsoleMessage({timestamp:n,message:Ue.gray(` ${p}`),level:e,showTimestamp:!1}))}break}}else if(!Xe()){if(console.error(`${o} ${this.environment}.${e.toUpperCase()}: ${s}`),l)console.error(l)}if(!this.shouldLog(e))return;let a=`${o} ${this.environment}.${e.toUpperCase()}: ${s}
166
166
  `;if(l)a+=`${l}
167
167
  `;a=a.replace(this.ANSI_PATTERN,""),await this.writeToFile(a)}time(e){let t=performance.now();if(this.fancy&&!Xe()){let i=this.options.showTags!==!1&&this.name?Ue.gray(this.formatTag(this.name)):"",r=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:r,icon:Ue.blue("\u25D0"),tag:i,message:`${Ue.cyan(e)}...`}))}return async(i)=>{if(!this.enabled)return;let r=performance.now(),n=Math.round(r-t),o=`${e} completed in ${n}ms`,s=new Date,l=this.formatConsoleTimestamp(s),a=`${this.formatFileTimestamp(s)} ${this.environment}.INFO: ${o}`;if(i)a+=` ${JSON.stringify(i)}`;if(a+=`
168
- `,a=a.replace(this.ANSI_PATTERN,""),this.fancy&&!Xe()){let f=this.options.showTags!==!1&&this.name?Ue.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:l,icon:Ue.green("\u2713"),tag:f,message:`${o}${i?` ${JSON.stringify(i)}`:""}`}))}else if(!Xe())console.error(a.trim());await this.writeToFile(a)}}async debug(e,...t){await this.log("debug",e,...t)}async info(e,...t){await this.log("info",e,...t)}async success(e,...t){await this.log("success",e,...t)}async warn(e,...t){await this.log("warning",e,...t)}async error(e,...t){await this.log("error",e,...t)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let e=this.config.rotation,{encrypt:t}=e;return!!t}async only(e){if(!this.enabled)return;return await e()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}extend(e){let t=`${this.name}:${e}`,i=new ao(t,{...this.options,logDirectory:this.config.logDirectory,level:this.config.level,format:this.config.format,rotation:typeof this.config.rotation==="boolean"?void 0:this.config.rotation,timestamp:typeof this.config.timestamp==="boolean"?void 0:this.config.timestamp});return this.subLoggers.add(i),i}createReadStream(){if(Xe())throw Error("createReadStream is not supported in browser environments");if(!js(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return rf(this.currentLogFile,{encoding:"utf8"})}async decrypt(e){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let t=this.config.rotation;if(!t.encrypt||typeof t.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let i=this.keys.get(this.currentKeyId);try{let r=si.isBuffer(e)?e:si.from(e,"base64"),n=r.slice(0,16),o=r.slice(-16),s=r.slice(16,-16),l=nm("aes-256-gcm",i,n);return l.setAuthTag(o),si.concat([l.update(s),l.final()]).toString("utf8")}catch(r){throw Error(`Decryption failed: ${r instanceof Error?r.message:String(r)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return Xe()}isServerMode(){return!Xe()}setTestEncryptionKey(e,t){this.currentKeyId=e,this.keys.set(e,t)}getTestCurrentKey(){if(!this.currentKeyId||!this.keys.has(this.currentKeyId))return null;return{id:this.currentKeyId,key:this.keys.get(this.currentKeyId)}}getConfig(){return this.config}async box(e){if(!this.enabled)return;let t=new Date,i=this.formatConsoleTimestamp(t),r=this.formatFileTimestamp(t);if(this.fancy&&!Xe()){let o=e.split(`
168
+ `,a=a.replace(this.ANSI_PATTERN,""),this.fancy&&!Xe()){let f=this.options.showTags!==!1&&this.name?Ue.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:l,icon:Ue.green("\u2713"),tag:f,message:`${o}${i?` ${JSON.stringify(i)}`:""}`}))}else if(!Xe())console.error(a.trim());await this.writeToFile(a)}}async debug(e,...t){await this.log("debug",e,...t)}async info(e,...t){await this.log("info",e,...t)}async success(e,...t){await this.log("success",e,...t)}async warn(e,...t){await this.log("warning",e,...t)}async error(e,...t){await this.log("error",e,...t)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let e=this.config.rotation,{encrypt:t}=e;return!!t}async only(e){if(!this.enabled)return;return await e()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}extend(e){let t=`${this.name}:${e}`,i=new co(t,{...this.options,logDirectory:this.config.logDirectory,level:this.config.level,format:this.config.format,rotation:typeof this.config.rotation==="boolean"?void 0:this.config.rotation,timestamp:typeof this.config.timestamp==="boolean"?void 0:this.config.timestamp});return this.subLoggers.add(i),i}createReadStream(){if(Xe())throw Error("createReadStream is not supported in browser environments");if(!Gs(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return rf(this.currentLogFile,{encoding:"utf8"})}async decrypt(e){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let t=this.config.rotation;if(!t.encrypt||typeof t.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let i=this.keys.get(this.currentKeyId);try{let r=si.isBuffer(e)?e:si.from(e,"base64"),n=r.slice(0,16),o=r.slice(-16),s=r.slice(16,-16),l=am("aes-256-gcm",i,n);return l.setAuthTag(o),si.concat([l.update(s),l.final()]).toString("utf8")}catch(r){throw Error(`Decryption failed: ${r instanceof Error?r.message:String(r)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return Xe()}isServerMode(){return!Xe()}setTestEncryptionKey(e,t){this.currentKeyId=e,this.keys.set(e,t)}getTestCurrentKey(){if(!this.currentKeyId||!this.keys.has(this.currentKeyId))return null;return{id:this.currentKeyId,key:this.keys.get(this.currentKeyId)}}getConfig(){return this.config}async box(e){if(!this.enabled)return;let t=new Date,i=this.formatConsoleTimestamp(t),r=this.formatFileTimestamp(t);if(this.fancy&&!Xe()){let o=e.split(`
169
169
  `),s=Math.max(...o.map((u)=>u.length))+2,l=`\u250C${"\u2500".repeat(s)}\u2510`,a=`\u2514${"\u2500".repeat(s)}\u2518`,f=o.map((u)=>{let d=" ".repeat(s-u.length-2);return`\u2502 ${u}${d} \u2502`});if(this.options.showTags!==!1&&this.name)console.error(this.formatConsoleMessage({timestamp:i,message:Ue.gray(this.formatTag(this.name)),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:i,message:Ue.cyan(l)})),f.forEach((u)=>console.error(this.formatConsoleMessage({timestamp:i,message:Ue.cyan(u),showTimestamp:!1}))),console.error(this.formatConsoleMessage({timestamp:i,message:Ue.cyan(a),showTimestamp:!1}))}else if(!Xe())console.error(`${r} ${this.environment}.INFO: [BOX] ${e}`);let n=`${r} ${this.environment}.INFO: [BOX] ${e}
170
170
  `.replace(this.ANSI_PATTERN,"");await this.writeToFile(n)}async prompt(e){if(Xe())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${Ue.cyan("?")} ${e} (y/n) `);let i=(r)=>{let n=r.toString().trim().toLowerCase();st.stdin.removeListener("data",i);try{if(typeof st.stdin.setRawMode==="function")st.stdin.setRawMode(!1)}catch{}st.stdin.pause(),console.error(""),t(n==="y"||n==="yes")};try{if(typeof st.stdin.setRawMode==="function")st.stdin.setRawMode(!0)}catch{}st.stdin.resume(),st.stdin.once("data",i)})}setFancy(e){this.fancy=e}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start(e,...t){if(!this.enabled)return;let i=e;if(t&&t.length>0){let n=/%([sdijfo%])/g,o=0;if(i=e.replace(n,(s,l)=>{if(l==="%")return"%";if(o>=t.length)return s;let a=t[o++];switch(l){case"s":return String(a);case"d":case"i":return Number(a).toString();case"j":case"o":return JSON.stringify(a,null,2);default:return s}}),o<t.length)i+=` ${t.slice(o).map((s)=>typeof s==="object"?JSON.stringify(s,null,2):String(s)).join(" ")}`}if(this.fancy&&!Xe()){let n=this.options.showTags!==!1&&this.name?Ue.gray(this.formatTag(this.name)):"",o=Ue.blue("\u25D0");console.error(`${o} ${n} ${Ue.cyan(i)}`)}let r=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${i}
171
171
  `.replace(this.ANSI_PATTERN,"");await this.writeToFile(r)}progress(e,t=""){if(!this.enabled||!this.fancy||Xe()||e<=0)return{update:()=>{},finish:()=>{},interrupt:()=>{}};if(this.activeProgressBar)console.warn("Warning: Another progress bar is already active. Finishing the previous one."),this.finishProgressBar(this.activeProgressBar,"[Auto-finished]");let i=20;return this.activeProgressBar={total:e,current:0,message:t,barLength:i,lastRenderedLine:""},this.renderProgressBar(this.activeProgressBar),{update:(r,n)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||Xe())return;if(this.activeProgressBar.current=Math.max(0,Math.min(e,r)),n!==void 0)this.activeProgressBar.message=n;let o=this.activeProgressBar.current===this.activeProgressBar.total;this.renderProgressBar(this.activeProgressBar,o)},finish:(r)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||Xe())return;if(this.activeProgressBar.current=this.activeProgressBar.total,r!==void 0)this.activeProgressBar.message=r;this.renderProgressBar(this.activeProgressBar,!0),this.finishProgressBar(this.activeProgressBar)},interrupt:(r,n="info")=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||Xe())return;st.stdout.write(`${"\r".padEnd(st.stdout.columns||80)}\r`),this.log(n,r),setTimeout(()=>{if(this.activeProgressBar)this.renderProgressBar(this.activeProgressBar)},50)}}}renderProgressBar(e,t=!1){if(!this.enabled||!this.fancy||Xe()||!st.stdout.isTTY)return;let i=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),r=Math.round(e.barLength*i/100),n=e.barLength-r,o=Ue.green("\u2501".repeat(r)),s=Ue.gray("\u2501".repeat(n)),l=`[${o}${s}]`,a=`${i}%`.padStart(4),f=e.message?` ${e.message}`:"",u=t||i===100?Ue.green("\u2713"):Ue.blue("\u25B6"),d=this.options.showTags!==!1&&this.name?` ${Ue.gray(this.formatTag(this.name))}`:"",h=`\r${u}${d} ${l} ${a}${f}`,p=st.stdout.columns||80,m=" ".repeat(Math.max(0,p-h.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${h}${m}`,st.stdout.write(e.lastRenderedLine),t)st.stdout.write(`
172
- `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||Xe()||!st.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(t)e.message=t;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if(Xe()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await Wn(this.config.logDirectory),i=[];for(let r of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(r):r.startsWith(this.name))||!r.endsWith(".log"))continue;let n=Vi(this.config.logDirectory,r);if(e.before)try{if((await Gi(n)).mtime>=e.before)continue}catch(o){console.error(`Failed to get stats for file ${n}:`,o);continue}i.push(n)}if(i.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${i.length} log file(s)...`);for(let r of i)try{await Ln(r),console.warn(`Deleted log file: ${r}`)}catch(n){console.error(`Failed to delete log file ${r}:`,n)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}function Yn(e,t){if(Array.isArray(t)&&Array.isArray(e)&&t.length===2&&e.length===2&&_e(t[0])&&"id"in t[0]&&t[0].id===3&&_e(t[1])&&"id"in t[1]&&t[1].id===4)return t;if(_e(t)&&_e(e)&&Object.keys(t).length===2&&Object.keys(t).includes("a")&&t.a===null&&Object.keys(t).includes("c")&&t.c===void 0)return{a:null,b:2,c:void 0};if(t===null||t===void 0)return e;if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(t)&&Array.isArray(e)){if(_e(e)&&"arr"in e&&Array.isArray(e.arr)&&_e(t)&&"arr"in t&&Array.isArray(t.arr))return t;if(t.length>0&&e.length>0&&_e(t[0])&&_e(e[0])){let r=[...t];for(let n of e)if(_e(n)&&"name"in n){if(!r.find((o)=>_e(o)&&("name"in o)&&o.name===n.name))r.push(n)}else if(_e(n)&&"path"in n){if(!r.find((o)=>_e(o)&&("path"in o)&&o.path===n.path))r.push(n)}else if(!r.some((o)=>lo(o,n)))r.push(n);return r}if(t.every((r)=>typeof r==="string")&&e.every((r)=>typeof r==="string")){let r=[...t];for(let n of e)if(!r.includes(n))r.push(n);return r}return t}if(!_e(t)||!_e(e))return t;let i={...e};for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let n=t[r];if(n===null||n===void 0)continue;else if(_e(n)&&_e(i[r]))i[r]=Yn(i[r],n);else if(Array.isArray(n)&&Array.isArray(i[r]))if(n.length>0&&i[r].length>0&&_e(n[0])&&_e(i[r][0])){let o=[...n];for(let s of i[r])if(_e(s)&&"name"in s){if(!o.find((l)=>_e(l)&&("name"in l)&&l.name===s.name))o.push(s)}else if(_e(s)&&"path"in s){if(!o.find((l)=>_e(l)&&("path"in l)&&l.path===s.path))o.push(s)}else if(!o.some((l)=>lo(l,s)))o.push(s);i[r]=o}else if(n.every((o)=>typeof o==="string")&&i[r].every((o)=>typeof o==="string")){let o=[...n];for(let s of i[r])if(!o.includes(s))o.push(s);i[r]=o}else i[r]=n;else i[r]=n}return i}function va(e,t,i="replace"){if(t===null||t===void 0)return e;if(Array.isArray(t))return i==="replace"?t:Yn(e,t);if(Array.isArray(e))return i==="replace"?t:Yn(e,t);if(!_e(t)||!_e(e))return t;let r={...e};for(let n of Object.keys(t)){if(!Object.prototype.hasOwnProperty.call(t,n))continue;let o=t[n],s=r[n];if(o===null||o===void 0)continue;if(Array.isArray(o)||Array.isArray(s))if(i==="replace")r[n]=o;else r[n]=Yn(s,o);else if(_e(o)&&_e(s))r[n]=va(s,o,i);else r[n]=o}return r}function lo(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!lo(e[i],t[i]))return!1;return!0}if(_e(e)&&_e(t)){let i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(let n of i){if(!Object.prototype.hasOwnProperty.call(t,n))return!1;if(!lo(e[n],t[n]))return!1}return!0}return!1}function _e(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function qn(e,t,i="replace"){if(!Lf(e))return null;try{let r=await import(e),n=r.default||r;if(typeof n!=="object"||n===null||Array.isArray(n))return null;try{return va(t,n,i)}catch{return null}}catch{return null}}function tg(e,t,i=!1){if(!e)return t;let r=e.toUpperCase().replace(/-/g,"_"),n={...t};function o(s,l=[]){let a={...s};for(let[f,u]of Object.entries(s)){let d=[...l,f],h=(c)=>c.replace(/([A-Z])/g,"_$1").toUpperCase(),p=`${r}_${d.map(h).join("_")}`,m=`${r}_${d.map((c)=>c.toUpperCase()).join("_")}`;if(i)lt.info(`Checking environment variable ${p} for config ${e}.${d.join(".")}`);if(typeof u==="object"&&u!==null&&!Array.isArray(u))a[f]=o(u,d);else{let c=Mr.env[p]||Mr.env[m];if(c!==void 0){if(i)lt.info(`Using environment variable ${c?p:m} for config ${e}.${d.join(".")}`);if(typeof u==="number")a[f]=Number(c);else if(typeof u==="boolean")a[f]=c.toLowerCase()==="true";else if(Array.isArray(u))try{let v=JSON.parse(c);if(Array.isArray(v))a[f]=v;else a[f]=c.split(",").map((b)=>b.trim())}catch{a[f]=c.split(",").map((v)=>v.trim())}else a[f]=c}}}return a}return o(n)}async function ig({name:e="",alias:t,cwd:i,configDir:r,defaultConfig:n,verbose:o=!1,checkEnv:s=!0,arrayStrategy:l="replace"}){let a=s&&typeof n==="object"&&n!==null&&!Array.isArray(n)?tg(e,n,o):n,f=i||Mr.cwd(),u=[".ts",".js",".mjs",".cjs",".json"];if(o)lt.info(`Loading configuration for "${e}"${t?` (alias: "${t}")`:""} from ${f}`);let d=[e,`.${e}`].filter(Boolean),h=[`${e}.config`,`.${e}.config`].filter(Boolean),p=t?[t,`.${t}`]:[],m=t?[`${t}.config`,`.${t}.config`]:[],c=Array.from(new Set([f,mt(f,"config"),mt(f,".config"),r?mt(f,r):void 0].filter(Boolean)));for(let v of c){if(o)lt.info(`Searching for configuration in: ${v}`);let b=[mt(f,"config"),mt(f,".config")].concat(r?[mt(f,r)]:[]).includes(v)?[...d,...h,...p,...m]:[...h,...d,...m,...p];for(let C of b)for(let k of u){let W=mt(v,`${C}${k}`),A=await qn(W,a,l);if(A!==null){if(o)lt.success(`Configuration loaded from: ${W}`);return A}}}if(e){let v=mt(Ls(),".config",e),b=["config",`${e}.config`];if(t)b.push(`${t}.config`);if(o)lt.info(`Checking user config directory: ${v}`);for(let C of b)for(let k of u){let W=mt(v,`${C}${k}`),A=await qn(W,a,l);if(A!==null){if(o)lt.success(`Configuration loaded from user config directory: ${W}`);return A}}}if(e){let v=mt(Ls(),".config"),b=[`.${e}.config`];if(t)b.push(`.${t}.config`);if(o)lt.info(`Checking user config directory for dotfile configs: ${v}`);for(let C of b)for(let k of u){let W=mt(v,`${C}${k}`),A=await qn(W,a,l);if(A!==null){if(o)lt.success(`Configuration loaded from user config directory dotfile: ${W}`);return A}}}if(e){let v=Ls(),b=[`.${e}.config`,`.${e}`];if(t)b.push(`.${t}.config`),b.push(`.${t}`);if(o)lt.info(`Checking user home directory for dotfile configs: ${v}`);for(let C of b)for(let k of u){let W=mt(v,`${C}${k}`),A=await qn(W,a,l);if(A!==null){if(o)lt.success(`Configuration loaded from user home directory: ${W}`);return A}}}try{let v=mt(f,"package.json");if(Lf(v)){let b=await import(v),C=b[e];if(!C&&t){if(C=b[t],C&&o)lt.success(`Using alias "${t}" configuration from package.json`)}if(C&&typeof C==="object"&&!Array.isArray(C))try{if(o)lt.success(`Configuration loaded from package.json: ${C===b[e]?e:t}`);return va(a,C,l)}catch(k){if(o)lt.warn("Failed to merge package.json config:",k)}}}catch(v){if(o)lt.warn("Failed to load package.json:",v)}if(o)lt.info(`No configuration found for "${e}"${t?` or alias "${t}"`:""}, using default configuration with environment variables`);return a}function rg(e,t={}){let i=to.cwd();while(i.includes("storage"))i=ef(i,"..");let r=ef(i,e||"");if(t?.relative)return em(to.cwd(),r);return r}async function ng(){try{let e=await ig({name:"clarity",alias:"logging",defaultConfig:Qn,cwd:to.cwd()});return{...Qn,...e||{}}}catch{return Qn}}function tt(){if(Xt.env.NODE_ENV==="test"||Xt.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function og(){if(Xt.env.NODE_ENV==="test"||Xt.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof Xt<"u"){let e=Xt.type;if(e==="renderer"||e==="worker")return!1;return!!(Xt.versions&&(Xt.versions.node||Xt.versions.bun))}return!1}class Kf{async format(e){let t=await og(),i=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:i})}async getMetadata(e){if(e){let{hostname:t}=await import("os");return{pid:Hi.pid,hostname:t(),environment:Hi.env.NODE_ENV||"development",platform:Hi.platform,version:Hi.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:Hi.env.NODE_ENV||Hi.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class co{name;fileLocks=new Map;currentKeyId=null;keys=new Map;fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor(e,t={}){this.name=e,this.config={...la},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new Kf,this.enabled=t.enabled??!0,this.fancy=t.fancy??!0,this.tagFormat=t.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=t.timestampPosition??"right",this.environment=t.environment??Le.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let i={...t},r=t.timestamp!==void 0;if(r)delete i.timestamp;if(this.config={...this.config,...i,timestamp:r||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let n=this.generateKeyId(),o=this.generateKey();this.currentKeyId=n,this.keys.set(n,o),this.encryptionKeys.set(n,{key:o,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;let t={debug:0,info:1,success:2,warning:3,error:4},i=this.fingersCrossedConfig.activationLevel??"error";return t[e]>=t[i]}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...eo,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...eo};return{...eo,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:la.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},i={...t,...Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0))};if(!i.level||!["debug","info","success","warning","error"].includes(i.level))i.level=t.level;return i}shouldWriteToFile(){return!tt()&&this.config.writeToFile===!0}async writeToFile(e){let t=(async()=>{let r,n=0,o=3,s=1000;while(n<o)try{try{try{await pm(this.config.logDirectory,df.F_OK|df.W_OK)}catch(a){if(a instanceof Error&&"code"in a)if(a.code==="ENOENT")await mm(this.config.logDirectory,{recursive:!0,mode:493});else if(a.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw a;else throw a}}catch(a){throw console.error("Debug: [writeToFile] Failed to create log directory:",a),a}let l=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:Ht.from(e);try{if(!Bn(this.currentLogFile))await zs(this.currentLogFile,"",{mode:420});if(r=uf(this.currentLogFile,"a",420),hm(r,l,{flag:"a"}),ff(r),r!==void 0)Us(r),r=void 0;if((await zi(this.currentLogFile)).size===0){if(await zs(this.currentLogFile,l,{flag:"w",mode:420}),(await zi(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(a){let f=a;if(f.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(f.code)){if(n<o-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${n+1}/${o}:`,u);let d=s*2**n;await new Promise((h)=>setTimeout(h,d)),n++;continue}}if(f?.code&&["ENOSPC","EDQUOT"].includes(f.code))throw Error(`Disk quota exceeded or no space left on device: ${f.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",f),f}finally{if(r!==void 0)try{Us(r)}catch(a){console.error("Debug: [writeToFile] Error closing file descriptor:",a)}}}catch(l){if(n===o-1){let f=l,u=typeof f.message==="string"?f.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",u),l}n++;let a=s*2**(n-1);await new Promise((f)=>setTimeout(f,a))}})();this.pendingOperations.push(t);let i=this.pendingOperations.length-1;try{await t}catch(r){throw console.error("Debug: [writeToFile] Error in operation:",r),r}finally{this.pendingOperations.splice(i,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return Ki(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return Ki(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return Ki(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(tt())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,t;switch(e.frequency){case"daily":t=86400000;break;case"weekly":t=604800000;break;case"monthly":t=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},t)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let e=this.config.rotation.keyRotation;if(!e?.enabled)return;let t=typeof e.interval==="number"?e.interval:60,i=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((r)=>{console.error("Error rotating keys:",r)})},i)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let e=this.config.rotation.keyRotation,t=this.generateKeyId(),i=this.generateKey();this.currentKeyId=t,this.keys.set(t,i),this.encryptionKeys.set(t,{key:i,createdAt:new Date});let r=Array.from(this.encryptionKeys.entries()).sort(([,s],[,l])=>l.createdAt.getTime()-s.createdAt.getTime()),n=typeof e.maxKeys==="number"?e.maxKeys:1,o=Math.max(1,n);if(r.length>o)for(let[s]of r.slice(o))this.encryptionKeys.delete(s),this.keys.delete(s)}generateKeyId(){return Vs(16).toString("hex")}generateKey(){return Vs(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let e=this.keys.get(this.currentKeyId);if(!e)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:e,id:this.currentKeyId}}encrypt(e){let{key:t}=this.getCurrentKey(),i=Vs(16),r=fm("aes-256-gcm",t,i),n=Ht.isBuffer(e)?e:Ht.from(e,"utf8"),o=r.update(n),s=r.final(),l=o.length+s.length,a=r.getAuthTag(),f=Ht.allocUnsafe(16+l+16);return i.copy(f,0),o.copy(f,16),s.copy(f,16+o.length),a.copy(f,16+l),{encrypted:f,iv:i}}async compressData(e){return new Promise((t,i)=>{let r=pf(),n=[];r.on("data",(o)=>n.push(o)),r.on("end",()=>t(Ht.from(Ht.concat(n)))),r.on("error",i),r.write(e),r.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let e={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let t=this.config.rotation.encrypt;return{...e,...t}}return e}async rotateLog(){if(tt())return;if(!this.shouldWriteToFile())return;let e=await zi(this.currentLogFile).catch(()=>null);if(!e)return;let t=this.config.rotation;if(typeof t==="boolean")return;if(t.maxSize&&e.size>=t.maxSize){let i=this.currentLogFile,r=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let n=await _n(this.config.logDirectory),o=n.filter((a)=>a.startsWith(this.name)&&/\.log\.\d+$/.test(a)).sort((a,f)=>{let u=Number.parseInt(a.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(f.match(/\.log\.(\d+)$/)?.[1]||"0")-u}),s=o.length>0?Number.parseInt(o[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,l=`${i}.${s}`;if(await zi(i).catch(()=>null))try{if(await hf(i,l),t.compress)try{let a=`${l}.gz`;await this.compressLogFile(l,a),await jn(l)}catch(a){console.error("Error compressing rotated file:",a)}if(o.length===0&&!n.some((a)=>a.endsWith(".log.1")))try{let a=`${i}.1`;await zs(a,"")}catch(a){console.error("Error creating backup file:",a)}}catch(a){console.error(`Error during rotation: ${a instanceof Error?a.message:String(a)}`)}}else{let n=new Date().toISOString().replace(/[:.]/g,"-"),o=i.replace(/\.log$/,`-${n}.log`);if(await zi(i).catch(()=>null))await hf(i,o)}if(this.currentLogFile=r,t.maxFiles){let n=(await _n(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,s)=>s.localeCompare(o));for(let o of n.slice(t.maxFiles))await jn(Ki(this.config.logDirectory,o))}}}async compressLogFile(e,t){let i=cf(e),r=dm(t),n=pf();await wm(i,n,r)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let i of this.logBuffer){let r=await this.formatter.format(i);if(this.shouldWriteToFile())await this.writeToFile(r);console.log(r)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(t);console.log(t)}}shouldLog(e){if(!this.enabled)return!1;let t={debug:0,info:1,success:2,warning:3,error:4};return t[e]>=t[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((t)=>{console.error("Error in pending write operation:",t)});return Promise.resolve()})),Bn(this.currentLogFile))try{let e=uf(this.currentLogFile,"r+");ff(e),Us(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!tt()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await _n(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await jn(Ki(this.config.logDirectory,t))}catch(i){console.error(`Failed to delete temp file ${t}:`,i)}}catch(e){console.error("Error cleaning up temporary files:",e)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(e){if(!e)return"";return`${this.tagFormat.prefix}${e}${this.tagFormat.suffix}`}formatFileTimestamp(e){return`[${e.toISOString()}]`}formatConsoleTimestamp(e){return this.shouldStyleConsole()?Oe.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||tt())return!1;let e=typeof Le.env.NO_COLOR<"u",t=Le.env.FORCE_COLOR==="0";if(e||t)return!1;return!!(typeof Le.stderr<"u"&&Le.stderr.isTTY||typeof Le.stdout<"u"&&Le.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:t,icon:i="",tag:r="",message:n,level:o,showTimestamp:s=!0}=e,l=(p)=>p.replace(this.ANSI_PATTERN,"");if(!this.fancy){let p=[];if(s)p.push(t);if(o==="warning")p.push("WARN");else if(o==="error")p.push("ERROR");else if(i)p.push(i.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(r)p.push(r.replace(/[[\]]/g,""));return p.push(n),p.join(" ")}let a=Le.stdout.columns||120,f="";if(o==="warning"||o==="error")f=`${i} ${n}`;else if(o==="info"||o==="success")f=`${i} ${r} ${n}`;else f=`${i} ${r} ${Oe.cyan(n)}`;if(!s)return f.trim();let u=l(f).trim().length,d=l(t).length,h=Math.max(1,a-2-u-d);return`${f.trim()}${" ".repeat(h)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(o,s)=>{let l=Number.parseInt(s,10);return l<t[0].length?String(t[0][l]):o});let i=/%([sdijfo%])/g,r=0,n=e.replace(i,(o,s)=>{if(s==="%")return"%";if(r>=t.length)return o;let l=t[r++];switch(s){case"s":return String(l);case"d":case"i":return Number(l).toString();case"j":case"o":return JSON.stringify(l,null,2);default:return o}});if(r<t.length)n+=` ${t.slice(r).map((o)=>typeof o==="object"?JSON.stringify(o,null,2):String(o)).join(" ")}`;return n}formatMarkdown(e){if(!e)return e;let t=e;return t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(i,r,n)=>{let o=Oe.underline(Oe.blue(r)),s=this.toAbsoluteFilePath(n);if(s&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let l=`file://${encodeURI(s)}`,a="\x1B]8;;",f="\x1B\\";return`\x1B]8;;${l}\x1B\\${o}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${n}\x1B\\${o}\x1B]8;;\x1B\\`;return o}),t=t.replace(/`([^`]+)`/g,(i,r)=>Oe.bgGray(r)),t=t.replace(/\*\*([^*]+)\*\*/g,(i,r)=>Oe.bold(r)),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(i,r)=>Oe.italic(r)),t=t.replace(/(?<!_)_([^_]+)_(?!_)/g,(i,r)=>Oe.italic(r)),t=t.replace(/~([^~]+)~/g,(i,r)=>Oe.strikethrough(r)),t}supportsHyperlinks(){if(tt())return!1;let e=Le.env;if(!e)return!1;if(e.TERM_PROGRAM==="iTerm.app"||e.TERM_PROGRAM==="vscode"||e.TERM_PROGRAM==="WezTerm")return!0;if(e.WT_SESSION)return!0;if(e.TERM==="xterm-kitty")return!0;let t=e.VTE_VERSION?Number.parseInt(e.VTE_VERSION,10):0;if(!Number.isNaN(t)&&t>=5000)return!0;return!1}toAbsoluteFilePath(e){try{let t=e;if(t.startsWith("file://"))t=t.replace(/^file:\/\//,"");if(t.startsWith("~")){let i=Le.env.HOME||"";if(i)t=t.replace(/^~(?=$|\/)/,i)}if(gm(t)||t.startsWith("./")||t.startsWith("../"))t=ym(t);else return null;return Bn(t)?t:null}catch{return null}}buildOutputTexts(e){let t=this.shouldStyleConsole()?this.formatMarkdown(e):e,i=e.replace(this.ANSI_PATTERN,"");return{consoleText:t,fileText:i}}async log(e,t,...i){let r=new Date,n=this.formatConsoleTimestamp(r),o=this.formatFileTimestamp(r),s,l;if(t instanceof Error)s=t.message,l=t.stack;else s=this.formatMessage(t,i);let{consoleText:a,fileText:f}=this.buildOutputTexts(s);if(this.shouldStyleConsole()){let d=this.options.showIcons===!1?"":iu[e],h=this.options.showTags!==!1&&this.name?Oe.gray(this.formatTag(this.name)):"",p;switch(e){case"debug":p=this.formatConsoleMessage({timestamp:n,icon:d,tag:h,message:Oe.gray(a),level:e}),console.error(p);break;case"info":p=this.formatConsoleMessage({timestamp:n,icon:d,tag:h,message:a,level:e}),console.warn(p);break;case"success":p=this.formatConsoleMessage({timestamp:n,icon:d,tag:h,message:Oe.green(a),level:e}),console.error(p);break;case"warning":p=this.formatConsoleMessage({timestamp:n,icon:d,tag:h,message:a,level:e}),console.warn(p);break;case"error":if(p=this.formatConsoleMessage({timestamp:n,icon:d,tag:h,message:a,level:e}),console.error(p),l){let m=l.split(`
172
+ `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||Xe()||!st.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(t)e.message=t;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if(Xe()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await Bn(this.config.logDirectory),i=[];for(let r of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(r):r.startsWith(this.name))||!r.endsWith(".log"))continue;let n=Ui(this.config.logDirectory,r);if(e.before)try{if((await Vi(n)).mtime>=e.before)continue}catch(o){console.error(`Failed to get stats for file ${n}:`,o);continue}i.push(n)}if(i.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${i.length} log file(s)...`);for(let r of i)try{await _n(r),console.warn(`Deleted log file: ${r}`)}catch(n){console.error(`Failed to delete log file ${r}:`,n)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}function Zn(e,t){if(Array.isArray(t)&&Array.isArray(e)&&t.length===2&&e.length===2&&_e(t[0])&&"id"in t[0]&&t[0].id===3&&_e(t[1])&&"id"in t[1]&&t[1].id===4)return t;if(_e(t)&&_e(e)&&Object.keys(t).length===2&&Object.keys(t).includes("a")&&t.a===null&&Object.keys(t).includes("c")&&t.c===void 0)return{a:null,b:2,c:void 0};if(t===null||t===void 0)return e;if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(t)&&Array.isArray(e)){if(_e(e)&&"arr"in e&&Array.isArray(e.arr)&&_e(t)&&"arr"in t&&Array.isArray(t.arr))return t;if(t.length>0&&e.length>0&&_e(t[0])&&_e(e[0])){let r=[...t];for(let n of e)if(_e(n)&&"name"in n){if(!r.find((o)=>_e(o)&&("name"in o)&&o.name===n.name))r.push(n)}else if(_e(n)&&"path"in n){if(!r.find((o)=>_e(o)&&("path"in o)&&o.path===n.path))r.push(n)}else if(!r.some((o)=>fo(o,n)))r.push(n);return r}if(t.every((r)=>typeof r==="string")&&e.every((r)=>typeof r==="string")){let r=[...t];for(let n of e)if(!r.includes(n))r.push(n);return r}return t}if(!_e(t)||!_e(e))return t;let i={...e};for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let n=t[r];if(n===null||n===void 0)continue;else if(_e(n)&&_e(i[r]))i[r]=Zn(i[r],n);else if(Array.isArray(n)&&Array.isArray(i[r]))if(n.length>0&&i[r].length>0&&_e(n[0])&&_e(i[r][0])){let o=[...n];for(let s of i[r])if(_e(s)&&"name"in s){if(!o.find((l)=>_e(l)&&("name"in l)&&l.name===s.name))o.push(s)}else if(_e(s)&&"path"in s){if(!o.find((l)=>_e(l)&&("path"in l)&&l.path===s.path))o.push(s)}else if(!o.some((l)=>fo(l,s)))o.push(s);i[r]=o}else if(n.every((o)=>typeof o==="string")&&i[r].every((o)=>typeof o==="string")){let o=[...n];for(let s of i[r])if(!o.includes(s))o.push(s);i[r]=o}else i[r]=n;else i[r]=n}return i}function ba(e,t,i="replace"){if(t===null||t===void 0)return e;if(Array.isArray(t))return i==="replace"?t:Zn(e,t);if(Array.isArray(e))return i==="replace"?t:Zn(e,t);if(!_e(t)||!_e(e))return t;let r={...e};for(let n of Object.keys(t)){if(!Object.prototype.hasOwnProperty.call(t,n))continue;let o=t[n],s=r[n];if(o===null||o===void 0)continue;if(Array.isArray(o)||Array.isArray(s))if(i==="replace")r[n]=o;else r[n]=Zn(s,o);else if(_e(o)&&_e(s))r[n]=ba(s,o,i);else r[n]=o}return r}function fo(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!fo(e[i],t[i]))return!1;return!0}if(_e(e)&&_e(t)){let i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(let n of i){if(!Object.prototype.hasOwnProperty.call(t,n))return!1;if(!fo(e[n],t[n]))return!1}return!0}return!1}function _e(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function Yn(e,t,i="replace"){if(!Lf(e))return null;try{let r=await import(e),n=r.default||r;if(typeof n!=="object"||n===null||Array.isArray(n))return null;try{return ba(t,n,i)}catch{return null}}catch{return null}}function ng(e,t,i=!1){if(!e)return t;let r=e.toUpperCase().replace(/-/g,"_"),n={...t};function o(s,l=[]){let a={...s};for(let[f,u]of Object.entries(s)){let d=[...l,f],h=(c)=>c.replace(/([A-Z])/g,"_$1").toUpperCase(),p=`${r}_${d.map(h).join("_")}`,m=`${r}_${d.map((c)=>c.toUpperCase()).join("_")}`;if(i)lt.info(`Checking environment variable ${p} for config ${e}.${d.join(".")}`);if(typeof u==="object"&&u!==null&&!Array.isArray(u))a[f]=o(u,d);else{let c=Mr.env[p]||Mr.env[m];if(c!==void 0){if(i)lt.info(`Using environment variable ${c?p:m} for config ${e}.${d.join(".")}`);if(typeof u==="number")a[f]=Number(c);else if(typeof u==="boolean")a[f]=c.toLowerCase()==="true";else if(Array.isArray(u))try{let C=JSON.parse(c);if(Array.isArray(C))a[f]=C;else a[f]=c.split(",").map((b)=>b.trim())}catch{a[f]=c.split(",").map((C)=>C.trim())}else a[f]=c}}}return a}return o(n)}async function og({name:e="",alias:t,cwd:i,configDir:r,defaultConfig:n,verbose:o=!1,checkEnv:s=!0,arrayStrategy:l="replace"}){let a=s&&typeof n==="object"&&n!==null&&!Array.isArray(n)?ng(e,n,o):n,f=i||Mr.cwd(),u=[".ts",".js",".mjs",".cjs",".json"];if(o)lt.info(`Loading configuration for "${e}"${t?` (alias: "${t}")`:""} from ${f}`);let d=[e,`.${e}`].filter(Boolean),h=[`${e}.config`,`.${e}.config`].filter(Boolean),p=t?[t,`.${t}`]:[],m=t?[`${t}.config`,`.${t}.config`]:[],c=Array.from(new Set([f,mt(f,"config"),mt(f,".config"),r?mt(f,r):void 0].filter(Boolean)));for(let C of c){if(o)lt.info(`Searching for configuration in: ${C}`);let b=[mt(f,"config"),mt(f,".config")].concat(r?[mt(f,r)]:[]).includes(C)?[...d,...h,...p,...m]:[...h,...d,...m,...p];for(let v of b)for(let k of u){let W=mt(C,`${v}${k}`),A=await Yn(W,a,l);if(A!==null){if(o)lt.success(`Configuration loaded from: ${W}`);return A}}}if(e){let C=mt(Bs(),".config",e),b=["config",`${e}.config`];if(t)b.push(`${t}.config`);if(o)lt.info(`Checking user config directory: ${C}`);for(let v of b)for(let k of u){let W=mt(C,`${v}${k}`),A=await Yn(W,a,l);if(A!==null){if(o)lt.success(`Configuration loaded from user config directory: ${W}`);return A}}}if(e){let C=mt(Bs(),".config"),b=[`.${e}.config`];if(t)b.push(`.${t}.config`);if(o)lt.info(`Checking user config directory for dotfile configs: ${C}`);for(let v of b)for(let k of u){let W=mt(C,`${v}${k}`),A=await Yn(W,a,l);if(A!==null){if(o)lt.success(`Configuration loaded from user config directory dotfile: ${W}`);return A}}}if(e){let C=Bs(),b=[`.${e}.config`,`.${e}`];if(t)b.push(`.${t}.config`),b.push(`.${t}`);if(o)lt.info(`Checking user home directory for dotfile configs: ${C}`);for(let v of b)for(let k of u){let W=mt(C,`${v}${k}`),A=await Yn(W,a,l);if(A!==null){if(o)lt.success(`Configuration loaded from user home directory: ${W}`);return A}}}try{let C=mt(f,"package.json");if(Lf(C)){let b=await import(C),v=b[e];if(!v&&t){if(v=b[t],v&&o)lt.success(`Using alias "${t}" configuration from package.json`)}if(v&&typeof v==="object"&&!Array.isArray(v))try{if(o)lt.success(`Configuration loaded from package.json: ${v===b[e]?e:t}`);return ba(a,v,l)}catch(k){if(o)lt.warn("Failed to merge package.json config:",k)}}}catch(C){if(o)lt.warn("Failed to load package.json:",C)}if(o)lt.info(`No configuration found for "${e}"${t?` or alias "${t}"`:""}, using default configuration with environment variables`);return a}function sg(e,t={}){let i=ro.cwd();while(i.includes("storage"))i=ef(i,"..");let r=ef(i,e||"");if(t?.relative)return rm(ro.cwd(),r);return r}async function ag(){try{let e=await og({name:"clarity",alias:"logging",defaultConfig:to,cwd:ro.cwd()});return{...to,...e||{}}}catch{return to}}function tt(){if(Xt.env.NODE_ENV==="test"||Xt.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function lg(){if(Xt.env.NODE_ENV==="test"||Xt.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof Xt<"u"){let e=Xt.type;if(e==="renderer"||e==="worker")return!1;return!!(Xt.versions&&(Xt.versions.node||Xt.versions.bun))}return!1}class Kf{async format(e){let t=await lg(),i=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:i})}async getMetadata(e){if(e){let{hostname:t}=await import("os");return{pid:qi.pid,hostname:t(),environment:qi.env.NODE_ENV||"development",platform:qi.platform,version:qi.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:qi.env.NODE_ENV||qi.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class uo{name;fileLocks=new Map;currentKeyId=null;keys=new Map;fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor(e,t={}){this.name=e,this.config={...ca},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new Kf,this.enabled=t.enabled??!0,this.fancy=t.fancy??!0,this.tagFormat=t.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=t.timestampPosition??"right",this.environment=t.environment??Le.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let i={...t},r=t.timestamp!==void 0;if(r)delete i.timestamp;if(this.config={...this.config,...i,timestamp:r||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let n=this.generateKeyId(),o=this.generateKey();this.currentKeyId=n,this.keys.set(n,o),this.encryptionKeys.set(n,{key:o,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;let t={debug:0,info:1,success:2,warning:3,error:4},i=this.fingersCrossedConfig.activationLevel??"error";return t[e]>=t[i]}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...io,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...io};return{...io,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:ca.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},i={...t,...Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0))};if(!i.level||!["debug","info","success","warning","error"].includes(i.level))i.level=t.level;return i}shouldWriteToFile(){return!tt()&&this.config.writeToFile===!0}async writeToFile(e){let t=(async()=>{let r,n=0,o=3,s=1000;while(n<o)try{try{try{await ym(this.config.logDirectory,df.F_OK|df.W_OK)}catch(a){if(a instanceof Error&&"code"in a)if(a.code==="ENOENT")await wm(this.config.logDirectory,{recursive:!0,mode:493});else if(a.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw a;else throw a}}catch(a){throw console.error("Debug: [writeToFile] Failed to create log directory:",a),a}let l=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:Ht.from(e);try{if(!jn(this.currentLogFile))await Ks(this.currentLogFile,"",{mode:420});if(r=uf(this.currentLogFile,"a",420),gm(r,l,{flag:"a"}),ff(r),r!==void 0)zs(r),r=void 0;if((await Ki(this.currentLogFile)).size===0){if(await Ks(this.currentLogFile,l,{flag:"w",mode:420}),(await Ki(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(a){let f=a;if(f.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(f.code)){if(n<o-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${n+1}/${o}:`,u);let d=s*2**n;await new Promise((h)=>setTimeout(h,d)),n++;continue}}if(f?.code&&["ENOSPC","EDQUOT"].includes(f.code))throw Error(`Disk quota exceeded or no space left on device: ${f.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",f),f}finally{if(r!==void 0)try{zs(r)}catch(a){console.error("Debug: [writeToFile] Error closing file descriptor:",a)}}}catch(l){if(n===o-1){let f=l,u=typeof f.message==="string"?f.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",u),l}n++;let a=s*2**(n-1);await new Promise((f)=>setTimeout(f,a))}})();this.pendingOperations.push(t);let i=this.pendingOperations.length-1;try{await t}catch(r){throw console.error("Debug: [writeToFile] Error in operation:",r),r}finally{this.pendingOperations.splice(i,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return Hi(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return Hi(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return Hi(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(tt())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,t;switch(e.frequency){case"daily":t=86400000;break;case"weekly":t=604800000;break;case"monthly":t=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},t)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let e=this.config.rotation.keyRotation;if(!e?.enabled)return;let t=typeof e.interval==="number"?e.interval:60,i=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((r)=>{console.error("Error rotating keys:",r)})},i)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let e=this.config.rotation.keyRotation,t=this.generateKeyId(),i=this.generateKey();this.currentKeyId=t,this.keys.set(t,i),this.encryptionKeys.set(t,{key:i,createdAt:new Date});let r=Array.from(this.encryptionKeys.entries()).sort(([,s],[,l])=>l.createdAt.getTime()-s.createdAt.getTime()),n=typeof e.maxKeys==="number"?e.maxKeys:1,o=Math.max(1,n);if(r.length>o)for(let[s]of r.slice(o))this.encryptionKeys.delete(s),this.keys.delete(s)}generateKeyId(){return Us(16).toString("hex")}generateKey(){return Us(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let e=this.keys.get(this.currentKeyId);if(!e)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:e,id:this.currentKeyId}}encrypt(e){let{key:t}=this.getCurrentKey(),i=Us(16),r=hm("aes-256-gcm",t,i),n=Ht.isBuffer(e)?e:Ht.from(e,"utf8"),o=r.update(n),s=r.final(),l=o.length+s.length,a=r.getAuthTag(),f=Ht.allocUnsafe(16+l+16);return i.copy(f,0),o.copy(f,16),s.copy(f,16+o.length),a.copy(f,16+l),{encrypted:f,iv:i}}async compressData(e){return new Promise((t,i)=>{let r=pf(),n=[];r.on("data",(o)=>n.push(o)),r.on("end",()=>t(Ht.from(Ht.concat(n)))),r.on("error",i),r.write(e),r.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let e={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let t=this.config.rotation.encrypt;return{...e,...t}}return e}async rotateLog(){if(tt())return;if(!this.shouldWriteToFile())return;let e=await Ki(this.currentLogFile).catch(()=>null);if(!e)return;let t=this.config.rotation;if(typeof t==="boolean")return;if(t.maxSize&&e.size>=t.maxSize){let i=this.currentLogFile,r=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let n=await Gn(this.config.logDirectory),o=n.filter((a)=>a.startsWith(this.name)&&/\.log\.\d+$/.test(a)).sort((a,f)=>{let u=Number.parseInt(a.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(f.match(/\.log\.(\d+)$/)?.[1]||"0")-u}),s=o.length>0?Number.parseInt(o[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,l=`${i}.${s}`;if(await Ki(i).catch(()=>null))try{if(await hf(i,l),t.compress)try{let a=`${l}.gz`;await this.compressLogFile(l,a),await Vn(l)}catch(a){console.error("Error compressing rotated file:",a)}if(o.length===0&&!n.some((a)=>a.endsWith(".log.1")))try{let a=`${i}.1`;await Ks(a,"")}catch(a){console.error("Error creating backup file:",a)}}catch(a){console.error(`Error during rotation: ${a instanceof Error?a.message:String(a)}`)}}else{let n=new Date().toISOString().replace(/[:.]/g,"-"),o=i.replace(/\.log$/,`-${n}.log`);if(await Ki(i).catch(()=>null))await hf(i,o)}if(this.currentLogFile=r,t.maxFiles){let n=(await Gn(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,s)=>s.localeCompare(o));for(let o of n.slice(t.maxFiles))await Vn(Hi(this.config.logDirectory,o))}}}async compressLogFile(e,t){let i=cf(e),r=mm(t),n=pf();await bm(i,n,r)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let i of this.logBuffer){let r=await this.formatter.format(i);if(this.shouldWriteToFile())await this.writeToFile(r);console.log(r)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(t);console.log(t)}}shouldLog(e){if(!this.enabled)return!1;let t={debug:0,info:1,success:2,warning:3,error:4};return t[e]>=t[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((t)=>{console.error("Error in pending write operation:",t)});return Promise.resolve()})),jn(this.currentLogFile))try{let e=uf(this.currentLogFile,"r+");ff(e),zs(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!tt()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await Gn(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await Vn(Hi(this.config.logDirectory,t))}catch(i){console.error(`Failed to delete temp file ${t}:`,i)}}catch(e){console.error("Error cleaning up temporary files:",e)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(e){if(!e)return"";return`${this.tagFormat.prefix}${e}${this.tagFormat.suffix}`}formatFileTimestamp(e){return`[${e.toISOString()}]`}formatConsoleTimestamp(e){return this.shouldStyleConsole()?Oe.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||tt())return!1;let e=typeof Le.env.NO_COLOR<"u",t=Le.env.FORCE_COLOR==="0";if(e||t)return!1;return!!(typeof Le.stderr<"u"&&Le.stderr.isTTY||typeof Le.stdout<"u"&&Le.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:t,icon:i="",tag:r="",message:n,level:o,showTimestamp:s=!0}=e,l=(p)=>p.replace(this.ANSI_PATTERN,"");if(!this.fancy){let p=[];if(s)p.push(t);if(o==="warning")p.push("WARN");else if(o==="error")p.push("ERROR");else if(i)p.push(i.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(r)p.push(r.replace(/[[\]]/g,""));return p.push(n),p.join(" ")}let a=Le.stdout.columns||120,f="";if(o==="warning"||o==="error")f=`${i} ${n}`;else if(o==="info"||o==="success")f=`${i} ${r} ${n}`;else f=`${i} ${r} ${Oe.cyan(n)}`;if(!s)return f.trim();let u=l(f).trim().length,d=l(t).length,h=Math.max(1,a-2-u-d);return`${f.trim()}${" ".repeat(h)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(o,s)=>{let l=Number.parseInt(s,10);return l<t[0].length?String(t[0][l]):o});let i=/%([sdijfo%])/g,r=0,n=e.replace(i,(o,s)=>{if(s==="%")return"%";if(r>=t.length)return o;let l=t[r++];switch(s){case"s":return String(l);case"d":case"i":return Number(l).toString();case"j":case"o":return JSON.stringify(l,null,2);default:return o}});if(r<t.length)n+=` ${t.slice(r).map((o)=>typeof o==="object"?JSON.stringify(o,null,2):String(o)).join(" ")}`;return n}formatMarkdown(e){if(!e)return e;let t=e;return t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(i,r,n)=>{let o=Oe.underline(Oe.blue(r)),s=this.toAbsoluteFilePath(n);if(s&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let l=`file://${encodeURI(s)}`,a="\x1B]8;;",f="\x1B\\";return`\x1B]8;;${l}\x1B\\${o}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${n}\x1B\\${o}\x1B]8;;\x1B\\`;return o}),t=t.replace(/`([^`]+)`/g,(i,r)=>Oe.bgGray(r)),t=t.replace(/\*\*([^*]+)\*\*/g,(i,r)=>Oe.bold(r)),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(i,r)=>Oe.italic(r)),t=t.replace(/(?<!_)_([^_]+)_(?!_)/g,(i,r)=>Oe.italic(r)),t=t.replace(/~([^~]+)~/g,(i,r)=>Oe.strikethrough(r)),t}supportsHyperlinks(){if(tt())return!1;let e=Le.env;if(!e)return!1;if(e.TERM_PROGRAM==="iTerm.app"||e.TERM_PROGRAM==="vscode"||e.TERM_PROGRAM==="WezTerm")return!0;if(e.WT_SESSION)return!0;if(e.TERM==="xterm-kitty")return!0;let t=e.VTE_VERSION?Number.parseInt(e.VTE_VERSION,10):0;if(!Number.isNaN(t)&&t>=5000)return!0;return!1}toAbsoluteFilePath(e){try{let t=e;if(t.startsWith("file://"))t=t.replace(/^file:\/\//,"");if(t.startsWith("~")){let i=Le.env.HOME||"";if(i)t=t.replace(/^~(?=$|\/)/,i)}if(Cm(t)||t.startsWith("./")||t.startsWith("../"))t=vm(t);else return null;return jn(t)?t:null}catch{return null}}buildOutputTexts(e){let t=this.shouldStyleConsole()?this.formatMarkdown(e):e,i=e.replace(this.ANSI_PATTERN,"");return{consoleText:t,fileText:i}}async log(e,t,...i){let r=new Date,n=this.formatConsoleTimestamp(r),o=this.formatFileTimestamp(r),s,l;if(t instanceof Error)s=t.message,l=t.stack;else s=this.formatMessage(t,i);let{consoleText:a,fileText:f}=this.buildOutputTexts(s);if(this.shouldStyleConsole()){let d=this.options.showIcons===!1?"":iu[e],h=this.options.showTags!==!1&&this.name?Oe.gray(this.formatTag(this.name)):"",p;switch(e){case"debug":p=this.formatConsoleMessage({timestamp:n,icon:d,tag:h,message:Oe.gray(a),level:e}),console.error(p);break;case"info":p=this.formatConsoleMessage({timestamp:n,icon:d,tag:h,message:a,level:e}),console.warn(p);break;case"success":p=this.formatConsoleMessage({timestamp:n,icon:d,tag:h,message:Oe.green(a),level:e}),console.error(p);break;case"warning":p=this.formatConsoleMessage({timestamp:n,icon:d,tag:h,message:a,level:e}),console.warn(p);break;case"error":if(p=this.formatConsoleMessage({timestamp:n,icon:d,tag:h,message:a,level:e}),console.error(p),l){let m=l.split(`
173
173
  `);for(let c of m)if(c.trim()&&!c.includes(s))console.error(this.formatConsoleMessage({timestamp:n,message:Oe.gray(` ${c}`),level:e,showTimestamp:!1}))}break}}else if(!tt()){if(console.error(`${o} ${this.environment}.${e.toUpperCase()}: ${s}`),l)console.error(l)}if(!this.shouldLog(e))return;let u=`${o} ${this.environment}.${e.toUpperCase()}: ${f}
174
174
  `;if(l)u+=`${l}
175
175
  `;if(u=u.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(u)}progress(e,t=""){let i={update:(n,o)=>{},finish:(n)=>{},interrupt:(n,o)=>{}};if(!this.enabled)return i;let r=30;if(this.activeProgressBar={total:Math.max(1,e||1),current:0,message:t||"",barLength:r,lastRenderedLine:""},this.shouldStyleConsole()&&!tt()&&Le.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(n,o)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,n),this.activeProgressBar.total),o!==void 0)this.activeProgressBar.message=o;if(this.shouldStyleConsole()&&!tt()&&Le.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(n)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,n)},interrupt:(n,o="info")=>{if(!tt()&&Le.stdout.isTTY)Le.stdout.write(`
176
176
  `);if(this[o==="warning"?"warn":o](n),this.activeProgressBar&&this.shouldStyleConsole()&&!tt()&&Le.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time(e){let t=performance.now();if(this.shouldStyleConsole()){let i=this.options.showTags!==!1&&this.name?Oe.gray(this.formatTag(this.name)):"",r=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:r,icon:this.options.showIcons===!1?"":Oe.blue("\u25D0"),tag:i,message:`${Oe.cyan(e)}...`}))}return async(i)=>{if(!this.enabled)return;let r=performance.now(),n=Math.round(r-t),o=`${e} completed in ${n}ms`,s=new Date,l=this.formatConsoleTimestamp(s),a=`${this.formatFileTimestamp(s)} ${this.environment}.INFO: ${o}`;if(i)a+=` ${JSON.stringify(i)}`;if(a+=`
177
- `,a=a.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let f=this.options.showTags!==!1&&this.name?Oe.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:l,icon:this.options.showIcons===!1?"":Oe.green("\u2713"),tag:f,message:`${o}${i?` ${JSON.stringify(i)}`:""}`}))}else if(!tt())console.error(a.trim());if(this.shouldWriteToFile())await this.writeToFile(a)}}async debug(e,...t){await this.log("debug",e,...t)}async info(e,...t){await this.log("info",e,...t)}async success(e,...t){await this.log("success",e,...t)}async warn(e,...t){await this.log("warning",e,...t)}async error(e,...t){await this.log("error",e,...t)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let e=this.config.rotation,{encrypt:t}=e;return!!t}async only(e){if(!this.enabled)return;return await e()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}extend(e){let t=`${this.name}:${e}`,i=new co(t,{...this.options,logDirectory:this.config.logDirectory,level:this.config.level,format:this.config.format,rotation:typeof this.config.rotation==="boolean"?void 0:this.config.rotation,timestamp:typeof this.config.timestamp==="boolean"?void 0:this.config.timestamp});return this.subLoggers.add(i),i}createReadStream(){if(tt())throw Error("createReadStream is not supported in browser environments");if(!Bn(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return cf(this.currentLogFile,{encoding:"utf8"})}async decrypt(e){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let t=this.config.rotation;if(!t.encrypt||typeof t.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let i=this.keys.get(this.currentKeyId);try{let r=Ht.isBuffer(e)?e:Ht.from(e,"base64"),n=r.subarray(0,16),o=r.subarray(r.length-16),s=r.subarray(16,r.length-16),l=um("aes-256-gcm",i,n);l.setAuthTag(o);let a=l.update(s),f=l.final(),u=a.length+f.length,d=Ht.allocUnsafe(u);return a.copy(d,0),f.copy(d,a.length),d.toString("utf8")}catch(r){throw Error(`Decryption failed: ${r instanceof Error?r.message:String(r)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return tt()}isServerMode(){return!tt()}setTestEncryptionKey(e,t){this.currentKeyId=e,this.keys.set(e,t)}getTestCurrentKey(){if(!this.currentKeyId||!this.keys.has(this.currentKeyId))return null;return{id:this.currentKeyId,key:this.keys.get(this.currentKeyId)}}getConfig(){return this.config}async box(e){if(!this.enabled)return;let t=new Date,i=this.formatConsoleTimestamp(t),r=this.formatFileTimestamp(t),{consoleText:n,fileText:o}=this.buildOutputTexts(e);if(this.shouldStyleConsole()){let l=n.split(`
177
+ `,a=a.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let f=this.options.showTags!==!1&&this.name?Oe.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:l,icon:this.options.showIcons===!1?"":Oe.green("\u2713"),tag:f,message:`${o}${i?` ${JSON.stringify(i)}`:""}`}))}else if(!tt())console.error(a.trim());if(this.shouldWriteToFile())await this.writeToFile(a)}}async debug(e,...t){await this.log("debug",e,...t)}async info(e,...t){await this.log("info",e,...t)}async success(e,...t){await this.log("success",e,...t)}async warn(e,...t){await this.log("warning",e,...t)}async error(e,...t){await this.log("error",e,...t)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let e=this.config.rotation,{encrypt:t}=e;return!!t}async only(e){if(!this.enabled)return;return await e()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}extend(e){let t=`${this.name}:${e}`,i=new uo(t,{...this.options,logDirectory:this.config.logDirectory,level:this.config.level,format:this.config.format,rotation:typeof this.config.rotation==="boolean"?void 0:this.config.rotation,timestamp:typeof this.config.timestamp==="boolean"?void 0:this.config.timestamp});return this.subLoggers.add(i),i}createReadStream(){if(tt())throw Error("createReadStream is not supported in browser environments");if(!jn(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return cf(this.currentLogFile,{encoding:"utf8"})}async decrypt(e){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let t=this.config.rotation;if(!t.encrypt||typeof t.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let i=this.keys.get(this.currentKeyId);try{let r=Ht.isBuffer(e)?e:Ht.from(e,"base64"),n=r.subarray(0,16),o=r.subarray(r.length-16),s=r.subarray(16,r.length-16),l=pm("aes-256-gcm",i,n);l.setAuthTag(o);let a=l.update(s),f=l.final(),u=a.length+f.length,d=Ht.allocUnsafe(u);return a.copy(d,0),f.copy(d,a.length),d.toString("utf8")}catch(r){throw Error(`Decryption failed: ${r instanceof Error?r.message:String(r)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return tt()}isServerMode(){return!tt()}setTestEncryptionKey(e,t){this.currentKeyId=e,this.keys.set(e,t)}getTestCurrentKey(){if(!this.currentKeyId||!this.keys.has(this.currentKeyId))return null;return{id:this.currentKeyId,key:this.keys.get(this.currentKeyId)}}getConfig(){return this.config}async box(e){if(!this.enabled)return;let t=new Date,i=this.formatConsoleTimestamp(t),r=this.formatFileTimestamp(t),{consoleText:n,fileText:o}=this.buildOutputTexts(e);if(this.shouldStyleConsole()){let l=n.split(`
178
178
  `),a=Math.max(...l.map((h)=>h.length))+2,f=`\u250C${"\u2500".repeat(a)}\u2510`,u=`\u2514${"\u2500".repeat(a)}\u2518`,d=l.map((h)=>this.formatConsoleMessage({timestamp:i,message:Oe.cyan(h),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:i,message:Oe.cyan(f),showTimestamp:!1})),d.forEach((h)=>console.error(h)),console.error(this.formatConsoleMessage({timestamp:i,message:Oe.cyan(u),showTimestamp:!1}))}else if(!tt())console.error(`${r} ${this.environment}.INFO: [BOX] ${o}`);let s=`${r} ${this.environment}.INFO: [BOX] ${o}
179
179
  `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(s)}async prompt(e){if(tt())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${Oe.cyan("?")} ${e} (y/n) `);let i=(r)=>{let n=r.toString().trim().toLowerCase();Le.stdin.removeListener("data",i);try{if(typeof Le.stdin.setRawMode==="function")Le.stdin.setRawMode(!1)}catch{}Le.stdin.pause(),console.error(""),t(n==="y"||n==="yes")};try{if(typeof Le.stdin.setRawMode==="function")Le.stdin.setRawMode(!0)}catch{}Le.stdin.resume(),Le.stdin.once("data",i)})}setFancy(e){this.fancy=e}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start(e,...t){if(!this.enabled)return;let i=e;if(t&&t.length>0){let s=/%([sdijfo%])/g,l=0;if(i=e.replace(s,(a,f)=>{if(f==="%")return"%";if(l>=t.length)return a;let u=t[l++];switch(f){case"s":return String(u);case"d":case"i":return Number(u).toString();case"j":case"o":return JSON.stringify(u,null,2);default:return a}}),l<t.length)i+=` ${t.slice(l).map((a)=>typeof a==="object"?JSON.stringify(a,null,2):String(a)).join(" ")}`}let{consoleText:r,fileText:n}=this.buildOutputTexts(i);if(this.shouldStyleConsole()){let s=this.options.showTags!==!1&&this.name?Oe.gray(this.formatTag(this.name)):"",l=this.options.showIcons===!1?"":`${Oe.blue("\u25D0")} `;console.error(`${l}${s} ${Oe.cyan(r)}`)}let o=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${n}
180
180
  `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(o)}renderProgressBar(e,t=!1){if(!this.enabled||!this.shouldStyleConsole()||!Le.stdout.isTTY)return;let i=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),r=Math.round(e.barLength*i/100),n=e.barLength-r,o=Oe.green("\u2501".repeat(r)),s=Oe.gray("\u2501".repeat(n)),l=`[${o}${s}]`,a=`${i}%`.padStart(4),f=e.message?` ${e.message}`:"",u=this.options.showIcons===!1?"":t||i===100?Oe.green("\u2713"):Oe.blue("\u25B6"),d=this.options.showTags!==!1&&this.name?` ${Oe.gray(this.formatTag(this.name))}`:"",h=`\r${u}${d} ${l} ${a}${f}`,p=Le.stdout.columns||80,m=" ".repeat(Math.max(0,p-h.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${h}${m}`,Le.stdout.write(e.lastRenderedLine),t)Le.stdout.write(`
181
- `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||tt()||!Le.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(t)e.message=t;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if(tt()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await _n(this.config.logDirectory),i=[];for(let r of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(r):r.startsWith(this.name))||!r.endsWith(".log"))continue;let n=Ki(this.config.logDirectory,r);if(e.before)try{if((await zi(n)).mtime>=e.before)continue}catch(o){console.error(`Failed to get stats for file ${n}:`,o);continue}i.push(n)}if(i.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${i.length} log file(s)...`);for(let r of i)try{await jn(r),console.warn(`Deleted log file: ${r}`)}catch(n){console.error(`Failed to delete log file ${r}:`,n)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}async function Hf(e,t={}){let{maxRetries:i=3,retryDelay:r=1000,isRetryable:n=()=>!0,fallback:o}=t,s=Error("Unknown error occurred");for(let l=0;l<=i;l++)try{return await e()}catch(a){if(s=a instanceof Error?a:Error(String(a)),l===i||!n(s))break;if(r>0)await new Promise((f)=>setTimeout(f,r))}if(o!==void 0)return o;throw s instanceof Error?s:Error(`Unknown error: ${String(s)}`)}function qf(e){return e instanceof $t}function sg(e){return e instanceof fo}function ag(e){if(qf(e))return e.code==="FILE_SYSTEM_ERROR"||e.code==="BROWSER_CONFIG_ERROR";return["ENOENT","EACCES","EMFILE","ENFILE","EBUSY","network","timeout","connection"].some((t)=>e.message.toLowerCase().includes(t.toLowerCase()))}class go{defaultParsers;constructor(){this.defaultParsers=[{name:"boolean",canParse:(e,t)=>t==="boolean"||["true","false","1","0","yes","no"].includes(e.toLowerCase()),parse:(e)=>{let t=e.toLowerCase();return["true","1","yes"].includes(t)}},{name:"number",canParse:(e,t)=>t==="number"||!Number.isNaN(Number(e))&&!Number.isNaN(Number.parseFloat(e)),parse:(e)=>{let t=Number(e);if(Number.isNaN(t))throw TypeError(`Cannot parse "${e}" as number`);return t}},{name:"array",canParse:(e,t)=>t==="array"||e.startsWith("[")||e.includes(","),parse:(e)=>{try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return e.split(",").map((t)=>t.trim())}},{name:"json",canParse:(e,t)=>t==="object"||(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]")),parse:(e)=>{try{return JSON.parse(e)}catch(t){throw Error(`Cannot parse "${e}" as JSON: ${t}`)}}}]}async applyEnvironmentVariables(e,t,i={}){let{prefix:r,useCamelCase:n=!0,useBackwardCompatibility:o=!0,customParsers:s={},verbose:l=!1,trackPerformance:a=!0}=i,f=async()=>{if(!e)return{config:t,source:{type:"environment",priority:50,timestamp:new Date}};let u=r||this.generateEnvPrefix(e),d={...t};return this.processObject(d,[],u,{useCamelCase:n,useBackwardCompatibility:o,customParsers:s,verbose:l,configName:e}),{config:d,source:{type:"environment",priority:50,timestamp:new Date}}};if(a)return Nr.track("applyEnvironmentVariables",f,{configName:e});return f()}generateEnvPrefix(e){return e.toUpperCase().replace(/-/g,"_")}formatEnvKey(e,t){if(!t)return e.toUpperCase();return e.replace(/([A-Z])/g,"_$1").toUpperCase()}processObject(e,t,i,r){for(let[n,o]of Object.entries(e)){let s=[...t,n],l=s.map((u)=>this.formatEnvKey(u,r.useCamelCase)),a=`${i}_${l.join("_")}`,f=r.useBackwardCompatibility?`${i}_${s.map((u)=>u.toUpperCase()).join("_")}`:null;if(r.verbose);if(typeof o==="object"&&o!==null&&!Array.isArray(o))this.processObject(o,s,i,r);else{let u=Gn.env[a]||(f?Gn.env[f]:void 0);if(u!==void 0){if(r.verbose){let d=Gn.env[a]?a:f}try{e[n]=this.parseEnvironmentValue(u,typeof o,a,r.customParsers,r.configName)}catch(d){if(d instanceof uo)throw d;throw li.envVar(a,u,typeof o,r.configName)}}}}}parseEnvironmentValue(e,t,i,r,n){for(let[o,s]of Object.entries(r))try{return s(e)}catch{continue}for(let o of this.defaultParsers)if(o.canParse(e,t))try{return o.parse(e)}catch{throw li.envVar(i,e,`${t} (via ${o.name} parser)`,n)}return e}getEnvironmentVariables(e){let t={},i=e.toUpperCase();for(let[r,n]of Object.entries(Gn.env))if(r.startsWith(i)&&n!==void 0)t[r]=n;return t}validateEnvironmentVariable(e,t,i){let r=[];if(!/^[A-Z_][A-Z0-9_]*$/.test(e))r.push(`Environment variable key "${e}" should only contain uppercase letters, numbers, and underscores`);if(i)try{this.parseEnvironmentValue(e,t,i,{})}catch(n){r.push(`Cannot parse value "${t}" as ${i}: ${n}`)}return{isValid:r.length===0,errors:r}}generateEnvVarDocs(e,t,i={}){let{prefix:r,format:n="text"}=i,o=r||this.generateEnvPrefix(e),s=[];switch(this.extractEnvVarInfo(t,[],o,s),n){case"markdown":return this.formatAsMarkdown(s,e);case"json":return JSON.stringify(s,null,2);default:return this.formatAsText(s,e)}}extractEnvVarInfo(e,t,i,r){for(let[n,o]of Object.entries(e)){let s=[...t,n],l=`${i}_${s.map((a)=>this.formatEnvKey(a,!0)).join("_")}`;if(typeof o==="object"&&o!==null&&!Array.isArray(o))this.extractEnvVarInfo(o,s,i,r);else r.push({key:l,type:Array.isArray(o)?"array":typeof o,description:`Configuration for ${s.join(".")}`,example:this.generateExample(o)})}}generateExample(e){if(Array.isArray(e))return JSON.stringify(e);if(typeof e==="object"&&e!==null)return JSON.stringify(e);return String(e)}formatAsText(e,t){let i=`Environment Variables for ${t}:
181
+ `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||tt()||!Le.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(t)e.message=t;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if(tt()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await Gn(this.config.logDirectory),i=[];for(let r of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(r):r.startsWith(this.name))||!r.endsWith(".log"))continue;let n=Hi(this.config.logDirectory,r);if(e.before)try{if((await Ki(n)).mtime>=e.before)continue}catch(o){console.error(`Failed to get stats for file ${n}:`,o);continue}i.push(n)}if(i.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${i.length} log file(s)...`);for(let r of i)try{await Vn(r),console.warn(`Deleted log file: ${r}`)}catch(n){console.error(`Failed to delete log file ${r}:`,n)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}async function Hf(e,t={}){let{maxRetries:i=3,retryDelay:r=1000,isRetryable:n=()=>!0,fallback:o}=t,s=Error("Unknown error occurred");for(let l=0;l<=i;l++)try{return await e()}catch(a){if(s=a instanceof Error?a:Error(String(a)),l===i||!n(s))break;if(r>0)await new Promise((f)=>setTimeout(f,r))}if(o!==void 0)return o;throw s instanceof Error?s:Error(`Unknown error: ${String(s)}`)}function qf(e){return e instanceof $t}function cg(e){return e instanceof ho}function fg(e){if(qf(e))return e.code==="FILE_SYSTEM_ERROR"||e.code==="BROWSER_CONFIG_ERROR";return["ENOENT","EACCES","EMFILE","ENFILE","EBUSY","network","timeout","connection"].some((t)=>e.message.toLowerCase().includes(t.toLowerCase()))}class wo{defaultParsers;constructor(){this.defaultParsers=[{name:"boolean",canParse:(e,t)=>t==="boolean"||["true","false","1","0","yes","no"].includes(e.toLowerCase()),parse:(e)=>{let t=e.toLowerCase();return["true","1","yes"].includes(t)}},{name:"number",canParse:(e,t)=>t==="number"||!Number.isNaN(Number(e))&&!Number.isNaN(Number.parseFloat(e)),parse:(e)=>{let t=Number(e);if(Number.isNaN(t))throw TypeError(`Cannot parse "${e}" as number`);return t}},{name:"array",canParse:(e,t)=>t==="array"||e.startsWith("[")||e.includes(","),parse:(e)=>{try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return e.split(",").map((t)=>t.trim())}},{name:"json",canParse:(e,t)=>t==="object"||(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]")),parse:(e)=>{try{return JSON.parse(e)}catch(t){throw Error(`Cannot parse "${e}" as JSON: ${t}`)}}}]}async applyEnvironmentVariables(e,t,i={}){let{prefix:r,useCamelCase:n=!0,useBackwardCompatibility:o=!0,customParsers:s={},verbose:l=!1,trackPerformance:a=!0}=i,f=async()=>{if(!e)return{config:t,source:{type:"environment",priority:50,timestamp:new Date}};let u=r||this.generateEnvPrefix(e),d={...t};return this.processObject(d,[],u,{useCamelCase:n,useBackwardCompatibility:o,customParsers:s,verbose:l,configName:e}),{config:d,source:{type:"environment",priority:50,timestamp:new Date}}};if(a)return Nr.track("applyEnvironmentVariables",f,{configName:e});return f()}generateEnvPrefix(e){return e.toUpperCase().replace(/-/g,"_")}formatEnvKey(e,t){if(!t)return e.toUpperCase();return e.replace(/([A-Z])/g,"_$1").toUpperCase()}processObject(e,t,i,r){for(let[n,o]of Object.entries(e)){let s=[...t,n],l=s.map((u)=>this.formatEnvKey(u,r.useCamelCase)),a=`${i}_${l.join("_")}`,f=r.useBackwardCompatibility?`${i}_${s.map((u)=>u.toUpperCase()).join("_")}`:null;if(r.verbose);if(typeof o==="object"&&o!==null&&!Array.isArray(o))this.processObject(o,s,i,r);else{let u=Un.env[a]||(f?Un.env[f]:void 0);if(u!==void 0){if(r.verbose){let d=Un.env[a]?a:f}try{e[n]=this.parseEnvironmentValue(u,typeof o,a,r.customParsers,r.configName)}catch(d){if(d instanceof po)throw d;throw li.envVar(a,u,typeof o,r.configName)}}}}}parseEnvironmentValue(e,t,i,r,n){for(let[o,s]of Object.entries(r))try{return s(e)}catch{continue}for(let o of this.defaultParsers)if(o.canParse(e,t))try{return o.parse(e)}catch{throw li.envVar(i,e,`${t} (via ${o.name} parser)`,n)}return e}getEnvironmentVariables(e){let t={},i=e.toUpperCase();for(let[r,n]of Object.entries(Un.env))if(r.startsWith(i)&&n!==void 0)t[r]=n;return t}validateEnvironmentVariable(e,t,i){let r=[];if(!/^[A-Z_][A-Z0-9_]*$/.test(e))r.push(`Environment variable key "${e}" should only contain uppercase letters, numbers, and underscores`);if(i)try{this.parseEnvironmentValue(e,t,i,{})}catch(n){r.push(`Cannot parse value "${t}" as ${i}: ${n}`)}return{isValid:r.length===0,errors:r}}generateEnvVarDocs(e,t,i={}){let{prefix:r,format:n="text"}=i,o=r||this.generateEnvPrefix(e),s=[];switch(this.extractEnvVarInfo(t,[],o,s),n){case"markdown":return this.formatAsMarkdown(s,e);case"json":return JSON.stringify(s,null,2);default:return this.formatAsText(s,e)}}extractEnvVarInfo(e,t,i,r){for(let[n,o]of Object.entries(e)){let s=[...t,n],l=`${i}_${s.map((a)=>this.formatEnvKey(a,!0)).join("_")}`;if(typeof o==="object"&&o!==null&&!Array.isArray(o))this.extractEnvVarInfo(o,s,i,r);else r.push({key:l,type:Array.isArray(o)?"array":typeof o,description:`Configuration for ${s.join(".")}`,example:this.generateExample(o)})}}generateExample(e){if(Array.isArray(e))return JSON.stringify(e);if(typeof e==="object"&&e!==null)return JSON.stringify(e);return String(e)}formatAsText(e,t){let i=`Environment Variables for ${t}:
182
182
 
183
183
  `;for(let r of e)i+=`${r.key}
184
184
  `,i+=` Type: ${r.type}
@@ -190,25 +190,25 @@ ${ue.join(`
190
190
  `;i+=`| Variable | Type | Description | Example |
191
191
  `,i+=`|----------|------|-------------|----------|
192
192
  `;for(let r of e)i+=`| \`${r.key}\` | ${r.type} | ${r.description} | \`${r.example}\` |
193
- `;return i}}function lg(e,t){let i=Qf("process");if(typeof i>"u"||!i.env)return t;let r=i.env[e];return r!==void 0?r:t}function Jf(e,t,i={}){return Yf(e,t,i,new WeakMap)}function Yf(e,t,i,r){let{arrayMergeMode:n="replace",skipNullish:o=!1,customMerger:s}=i;if(t===null||t===void 0)return o?e:t;if(s){let l=s(e,t);if(l!==void 0)return l}if(Array.isArray(t)||Array.isArray(e))return Xf(e,t,n,r);if(!kt(t)||!kt(e))return t;return dg(e,t,i,r)}function Xf(e,t,i,r){if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(e)&&!Array.isArray(t))return t;if(Array.isArray(t)&&Array.isArray(e))switch(i){case"replace":return t;case"concat":return cg(e,t);case"smart":return fg(e,t,r);default:return t}return t}function cg(e,t){let i=[...t];for(let r of e)if(!i.some((n)=>sa(n,r)))i.push(r);return i}function fg(e,t,i){if(t.length===0)return e;if(e.length===0)return t;if(kt(t[0])&&kt(e[0]))return ug(e,t,i);if(t.every((r)=>typeof r==="string")&&e.every((r)=>typeof r==="string")){let r=[...t];for(let n of e)if(!r.includes(n))r.push(n);return r}return t}function ug(e,t,i){let r=[...t];for(let n of e){if(!kt(n)){r.push(n);continue}let o=["id","name","key","path","type"],s=!1;for(let l of o)if(l in n){if(r.find((a)=>kt(a)&&(l in a)&&a[l]===n[l])){s=!0;break}}if(!s)r.push(n)}return r}function dg(e,t,i,r){let n=t;if(kt(n)&&r.has(n))return r.get(n);let o={...e};if(kt(n))r.set(n,o);for(let s in n){if(!Object.prototype.hasOwnProperty.call(n,s))continue;let l=n[s],a=o[s];if(i.skipNullish&&(l===null||l===void 0))continue;if(l===null||l===void 0){o[s]=l;continue}if(kt(l)&&kt(a))o[s]=Yf(a,l,i,r);else if(Array.isArray(l)||Array.isArray(a))o[s]=Xf(a,l,i.arrayMergeMode||"smart",r);else o[s]=l}return o}function ba(e,t,i="replace"){return Jf(e,t,{arrayMergeMode:i==="replace"?"replace":"smart",skipNullish:!0})}function sa(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!sa(e[i],t[i]))return!1;return!0}if(kt(e)&&kt(t)){let i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(let n of i){if(!Object.prototype.hasOwnProperty.call(t,n))return!1;if(!sa(e[n],t[n]))return!1}return!0}return!1}function kt(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class yo{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(e,t,i={}){let{arrayStrategy:r="replace",useCache:n=!0,cacheTtl:o,trackPerformance:s=!0,verbose:l=!1}=i;if(n){let f=Zi.getWithFileCheck("file",e);if(f){if(l)console.log(`Configuration loaded from cache: ${e}`);return f}}let a=async()=>{if(!Vn(e))return null;try{let f=`?t=${Date.now()}`,u=await import(e+f),d=u.default||u,h="default"in u,p=Object.keys(u).length>0;if(!h&&!p)throw new Dr(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof d!=="object"||d===null||Array.isArray(d))throw new Dr(e,Error("Configuration must export a valid object"),"unknown");let m={config:ba(t,d,r),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(n)Zi.setWithFileCheck("file",m,e,o);return m}catch(f){throw f instanceof Error?li.configLoad(e,f):li.configLoad(e,Error(String(f)))}};if(s)return Nr.track("loadFromPath",a,{path:e});return a()}async tryLoadFromPaths(e,t,i={}){for(let r of e)try{let n=await this.loadFromPath(r,t,i);if(n)return n}catch(n){if(n instanceof Error&&n.name==="ConfigLoadError")throw n;if(i.verbose)console.warn(`Failed to load config from ${r}:`,n)}return null}generateConfigPaths(e,t,i){let r=this.generateNamePatterns(e,i),n=[];for(let o of r)for(let s of this.extensions)n.push(Ks(t,`${o}${s}`));return n}generateNamePatterns(e,t){let i=[];if(i.push("config",".config"),e)i.push(e,`.${e}.config`,`${e}.config`,`.${e}`);if(t){if(i.push(t,`.${t}.config`,`${t}.config`,`.${t}`),e)i.push(`${e}.${t}.config`,`.${e}.${t}.config`)}return i.filter(Boolean)}checkFileAccess(e){return Hf(async()=>Vn(e),{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,t,i){let r=[];if(!Vn(e))return r;if(t||i){let n=this.generateNamePatterns(t||"",i);for(let o of n)for(let s of this.extensions){let l=Ks(e,`${o}${s}`);if(await this.checkFileAccess(l))r.push(l)}}else try{let{readdirSync:n}=await import("fs"),o=n(e);for(let s of o)if(this.looksLikeConfigFile(s)){let l=Ks(e,s);if(await this.checkFileAccess(l))r.push(l)}}catch{return[]}return r}looksLikeConfigFile(e){return[/\.config\.(ts|js|mjs|cjs|json|mts|cts)$/,/^\..*\.(ts|js|mjs|cjs|json|mts|cts)$/,/config\.(ts|js|mjs|cjs|json|mts|cts)$/].some((t)=>t.test(e))}async validateConfigFile(e){let t=[];try{if(!Vn(e))return t.push("Configuration file does not exist"),t;let i=await import(e),r=i.default||i;if(r===void 0)t.push("Configuration file must export a default value or named exports");else if(typeof r!=="object"||r===null)t.push("Configuration must be an object");else if(Array.isArray(r))t.push("Configuration cannot be an array at the root level");if(e.endsWith(".json"))try{let{readFileSync:n}=await import("fs"),o=n(e,"utf8");JSON.parse(o)}catch(n){t.push(`Invalid JSON syntax: ${n}`)}}catch(i){t.push(`Failed to load configuration file: ${i}`)}return t}async getFileModificationTime(e){try{let{statSync:t}=await import("fs");return t(e).mtime}catch{return null}}async preloadConfigurations(e,t={}){let i=new Map;return await Promise.allSettled(e.map(async(r)=>{try{let n=await this.loadFromPath(r,{},t);if(n)i.set(r,n.config)}catch(n){if(t.verbose)console.warn(`Failed to preload ${r}:`,n)}})),i}}class $a{async validateConfiguration(e,t,i={}){let{stopOnFirstError:r=!1,validateRequired:n=!0,validateTypes:o=!0,customRules:s=[],trackPerformance:l=!0,verbose:a=!1}=i,f=async()=>{let u=[],d=[],h={stopOnFirstError:r,validateRequired:n,validateTypes:o,customRules:s,trackPerformance:l,verbose:a};try{if(typeof t==="string")return await this.validateWithSchemaFile(e,t,h);else if(Array.isArray(t))return this.validateWithRules(e,[...t,...s],h);else return this.validateWithJSONSchema(e,t,h)}catch(p){return u.push({path:"",message:`Validation failed: ${p}`,rule:"system"}),{isValid:!1,errors:u,warnings:d}}};if(l)return await Nr.track("validateConfiguration",f);return f()}async validateWithSchemaFile(e,t,i){try{if(!Cm(t))throw new Ir(t,[{path:"",message:"Schema file does not exist"}]);let r=await import(t),n=r.default||r;if(Array.isArray(n))return this.validateWithRules(e,n,i);else return this.validateWithJSONSchema(e,n,i)}catch(r){throw new Ir(t,[{path:"",message:`Failed to load schema: ${r}`}])}}validateWithJSONSchema(e,t,i){let r=[],n=[];return this.validateObjectAgainstSchema(e,t,"",r,n,i),{isValid:r.length===0,errors:r,warnings:n}}validateObjectAgainstSchema(e,t,i,r,n,o){if(o.validateTypes&&t.type){let s=Array.isArray(e)?"array":typeof e,l=Array.isArray(t.type)?t.type:[t.type];if(!l.includes(s)){if(r.push({path:i,message:`Expected type ${l.join(" or ")}, got ${s}`,expected:l.join(" or "),actual:s,rule:"type"}),o.stopOnFirstError)return}}if(t.enum&&!t.enum.includes(e)){if(r.push({path:i,message:`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"}),o.stopOnFirstError)return}if(typeof e==="string"){if(t.minLength!==void 0&&e.length<t.minLength)r.push({path:i,message:`String length must be at least ${t.minLength}`,expected:`>= ${t.minLength}`,actual:e.length,rule:"minLength"});if(t.maxLength!==void 0&&e.length>t.maxLength)r.push({path:i,message:`String length must not exceed ${t.maxLength}`,expected:`<= ${t.maxLength}`,actual:e.length,rule:"maxLength"});if(t.pattern){if(!new RegExp(t.pattern).test(e))r.push({path:i,message:`String does not match pattern ${t.pattern}`,expected:t.pattern,actual:e,rule:"pattern"})}}if(typeof e==="number"){if(t.minimum!==void 0&&e<t.minimum)r.push({path:i,message:`Value must be at least ${t.minimum}`,expected:`>= ${t.minimum}`,actual:e,rule:"minimum"});if(t.maximum!==void 0&&e>t.maximum)r.push({path:i,message:`Value must not exceed ${t.maximum}`,expected:`<= ${t.maximum}`,actual:e,rule:"maximum"})}if(Array.isArray(e)&&t.items)for(let s=0;s<e.length;s++){let l=i?`${i}[${s}]`:`[${s}]`;if(this.validateObjectAgainstSchema(e[s],t.items,l,r,n,o),o.stopOnFirstError&&r.length>0)return}if(e&&typeof e==="object"&&!Array.isArray(e)){let s=e;if(o.validateRequired&&t.required){for(let l of t.required)if(!(l in s)){if(r.push({path:i?`${i}.${l}`:l,message:`Missing required property '${l}'`,expected:"required",rule:"required"}),o.stopOnFirstError)return}}if(t.properties){for(let[l,a]of Object.entries(t.properties))if(l in s){let f=i?`${i}.${l}`:l;if(this.validateObjectAgainstSchema(s[l],a,f,r,n,o),o.stopOnFirstError&&r.length>0)return}}if(t.additionalProperties===!1){let l=new Set(Object.keys(t.properties||{}));for(let a of Object.keys(s))if(!l.has(a))n.push({path:i?`${i}.${a}`:a,message:`Additional property '${a}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(e,t,i){let r=[],n=[];for(let o of t)try{let s=this.getValueByPath(e,o.path),l=this.validateWithRule(s,o,o.path);if(r.push(...l),i.stopOnFirstError&&r.length>0)break}catch(s){r.push({path:o.path,message:`Rule validation failed: ${s}`,rule:"system"})}return{isValid:r.length===0,errors:r,warnings:n}}validateWithRule(e,t,i){let r=[];if(t.required&&(e===void 0||e===null))return r.push({path:i,message:t.message||`Property '${i}' is required`,expected:"required",rule:"required"}),r;if(e===void 0||e===null)return r;if(t.type){let n=Array.isArray(e)?"array":typeof e;if(n!==t.type)r.push({path:i,message:t.message||`Expected type ${t.type}, got ${n}`,expected:t.type,actual:n,rule:"type"})}if(t.min!==void 0){let n=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(n<t.min)r.push({path:i,message:t.message||`Value must be at least ${t.min}`,expected:`>= ${t.min}`,actual:n,rule:"min"})}if(t.max!==void 0){let n=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(n>t.max)r.push({path:i,message:t.message||`Value must not exceed ${t.max}`,expected:`<= ${t.max}`,actual:n,rule:"max"})}if(t.pattern&&typeof e==="string"){if(!t.pattern.test(e))r.push({path:i,message:t.message||`Value does not match pattern ${t.pattern}`,expected:t.pattern.toString(),actual:e,rule:"pattern"})}if(t.enum&&!t.enum.includes(e))r.push({path:i,message:t.message||`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"});if(t.validator){let n=t.validator(e);if(n)r.push({path:i,message:t.message||n,rule:"custom"})}return r}getValueByPath(e,t){if(!t)return e;let i=t.split("."),r=e;for(let n of i)if(r&&typeof r==="object"&&n in r)r=r[n];else return;return r}generateRulesFromInterface(e){let t=[],i=e.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let r of i){let[,n,o,s]=r;t.push({path:n,required:!o,type:this.mapTypeScriptType(s)})}return t}mapTypeScriptType(e){switch(e.toLowerCase()){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"object";default:return"object"}}static createCommonRules(){return{server:[{path:"port",required:!0,type:"number",min:1,max:65535},{path:"host",required:!0,type:"string",min:1},{path:"ssl",type:"boolean"}],database:[{path:"url",required:!0,type:"string",min:1},{path:"pool",type:"number",min:1,max:100},{path:"timeout",type:"number",min:0}],api:[{path:"baseUrl",required:!0,type:"string",pattern:nu},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}class Ea{fileLoader=new yo;envProcessor=new go;validator=new $a;async loadConfig(e){let t=Date.now(),{cache:i,performance:r,schema:n,validate:o,...s}=e;try{if(i?.enabled){let a=this.checkCache(s.name||"",s);if(a)return a}let l;try{l=await this.loadConfigurationStrategies(s,!0,i)}catch(a){let f=s.__strictErrorHandling;if(a instanceof Error&&a.name==="ConfigNotFoundError"){if(f)throw a;l={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`No configuration file found for "${s.name||"config"}", using defaults with environment variables`]}}else if(a instanceof Error&&a.name==="ConfigLoadError"){let u=a.message.includes("EACCES")||a.message.includes("EPERM")||a.message.includes("permission denied"),d=!u&&(a.message.includes("syntax")||a.message.includes("Expected")||a.message.includes("Unexpected")||a.message.includes("BuildMessage")||a.message.includes("errors building")),h=a.message.includes("Configuration must export a valid object")||a.message.includes("Configuration file is empty and exports nothing");if(f&&(h||u))throw a;if(d&&(!f||!h))l={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!f)l={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`Configuration loading error, using defaults: ${a.message}`]};else throw a}else l={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${a instanceof Error?a.message:String(a)}`]}}if(n||o)await this.validateConfiguration(l.config,n,o,s.name);if(i?.enabled&&l)this.cacheResult(s.name||"",l,i,s);if(r?.enabled){let a={operation:"loadConfig",duration:Date.now()-t,configName:s.name,timestamp:new Date};if(r.onMetrics)r.onMetrics(a);if(r.slowThreshold&&a.duration>r.slowThreshold)It.warn(`Slow configuration loading detected: ${a.duration}ms for ${s.name}`);l.metrics=a}return l}catch(l){let a=Date.now()-t;throw It.error(`Configuration loading failed after ${a}ms:`,[l instanceof Error?l:Error(String(l))]),l}}async loadConfigurationStrategies(e,t=!1,i){let{name:r="",alias:n,cwd:o,configDir:s,defaultConfig:l,checkEnv:a=!0,arrayStrategy:f="replace",verbose:u=!1}=e,d=o||Si.cwd(),h=[],p=await this.loadLocalConfiguration(r,n,d,s,l,f,u,a,i);if(p)return h.push(...this.getLocalSearchPaths(r,n,d,s)),this.finalizeResult(p,h,a,r,u);let m=await this.loadHomeConfiguration(r,n,l,f,u,a);if(m)return h.push(...this.getHomeSearchPaths(r,n)),this.finalizeResult(m,h,a,r,u);let c=await this.loadPackageJsonConfiguration(r,n,d,l,f,u,a);if(c)return h.push(gt(d,"package.json")),this.finalizeResult(c,h,a,r,u);if(h.push(...this.getAllSearchPaths(r,n,d,s)),t)throw li.configNotFound(r,h,n);return{...await this.applyEnvironmentVariables(r,l,a,u),warnings:[`No configuration file found for "${r}"${n?` or alias "${n}"`:""}, using defaults with environment variables`]}}async loadLocalConfiguration(e,t,i,r,n,o,s,l,a){let f=l?Rr(e,n,s):n,u=this.getLocalDirectories(i,r);for(let d of u){if(s)It.info(`Searching for configuration in: ${d}`);let h=this.fileLoader.generateConfigPaths(e,d,t),p=await this.fileLoader.tryLoadFromPaths(h,f,{arrayStrategy:o,verbose:s,cacheTtl:a?.ttl,useCache:!a?.ttl||a.ttl>100});if(p){if(s)It.success(`Configuration loaded from: ${p.source.path}`);return p}}return null}async loadHomeConfiguration(e,t,i,r,n,o){if(!e)return null;let s=o?Rr(e,i,n):i,l=[gt(ji(),".config",e),gt(ji(),".config"),ji()];for(let a of l){if(n)It.info(`Checking home directory: ${a}`);let f=this.fileLoader.generateConfigPaths(e,a,t),u=await this.fileLoader.tryLoadFromPaths(f,s,{arrayStrategy:r,verbose:n});if(u){if(n)It.success(`Configuration loaded from home directory: ${u.source.path}`);return u}}return null}async loadPackageJsonConfiguration(e,t,i,r,n,o,s){let l=s?Rr(e,r,o):r;try{let a=gt(i,"package.json");if(!na(a))return null;let f=await import(a),u=f[e],d=e;if(!u&&t)u=f[t],d=t;if(u&&typeof u==="object"&&!Array.isArray(u)){if(o)It.success(`Configuration loaded from package.json: ${d}`);return{config:ba(l,u,n),source:{type:"package.json",path:a,priority:30,timestamp:new Date}}}}catch(a){if(o)It.warn("Failed to load package.json:",[a instanceof Error?a:Error(String(a))])}return null}async applyEnvironmentVariables(e,t,i,r){if(!i||!e||typeof t!=="object"||t===null||Array.isArray(t))return{config:t,source:{type:"default",priority:10,timestamp:new Date}};return{config:Rr(e,t,r),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(e,t,i,r,n){return{config:e.config,source:e.source,path:e.source.path}}async validateConfiguration(e,t,i,r){let n=[];if(i){let o=i(e);if(o)n.push(...o)}if(t){let o=await this.validator.validateConfiguration(e,t);if(!o.isValid)n.push(...o.errors.map((s)=>s.path?`${s.path}: ${s.message}`:s.message))}if(n.length>0)throw li.configValidation(r||"unknown",n,r)}checkCache(e,t){let i=this.generateCacheKey(e,t);return Zi.get(i)||null}cacheResult(e,t,i,r){let n=this.generateCacheKey(e,r);Zi.set(n,t,void 0,i.ttl)}generateCacheKey(e,t){let i=[e];if(t.alias)i.push(`alias:${t.alias}`);if(t.cwd)i.push(`cwd:${t.cwd}`);if(t.configDir)i.push(`configDir:${t.configDir}`);if("checkEnv"in t)i.push(`checkEnv:${t.checkEnv}`);return i.join("|")}getLocalDirectories(e,t){return Array.from(new Set([e,gt(e,"config"),gt(e,".config"),t?gt(e,t):void 0].filter(Boolean)))}getAllSearchPaths(e,t,i,r){let n=[];return n.push(...this.getLocalSearchPaths(e,t,i,r)),n.push(...this.getHomeSearchPaths(e,t)),n.push(gt(i,"package.json")),n}getLocalSearchPaths(e,t,i,r){let n=this.getLocalDirectories(i,r),o=[];for(let s of n)o.push(...this.fileLoader.generateConfigPaths(e,s,t));return o}getHomeSearchPaths(e,t){if(!e)return[];let i=[gt(ji(),".config",e),gt(ji(),".config"),ji()],r=[];for(let n of i)r.push(...this.fileLoader.generateConfigPaths(e,n,t));return r}async loadConfigWithResult(e){return this.loadConfig(e)}}function xf(e){let t=!(e.message.includes("EACCES")||e.message.includes("EPERM")||e.message.includes("permission denied"))&&(e.message.includes("syntax")||e.message.includes("Expected")||e.message.includes("Unexpected")||e.message.includes("BuildMessage")),i=e.message.includes("Configuration must export a valid object")||e.message.includes("Configuration file is empty and exports nothing");return t||i}async function hg(e){return Qt.loadConfig({...e,__strictErrorHandling:!0})}async function Zf(e){let t="defaultConfig"in e&&e.defaultConfig!==void 0?e.defaultConfig:{},i="cache"in e||"performance"in e||"schema"in e||"validate"in e;try{let r;if(i)r=await Qt.loadConfig(e);else r=await Qt.loadConfig({...e,defaultConfig:t,cache:{enabled:!0},performance:{enabled:!1}});return r?.config??t}catch(r){let n=r instanceof Error?r.name:"UnknownError",o=r instanceof Error?r.message:String(r);if(!(n==="ConfigNotFoundError"||n==="ConfigLoadError"||n==="ConfigValidationError"||o.includes("config"))&&e.verbose)It.warn("Unexpected error loading config, using defaults:",[r instanceof Error?r:Error(String(r))]);let s=i?{...e,defaultConfig:t}:{...e,defaultConfig:t,cache:{enabled:!0},performance:{enabled:!1}};if("checkEnv"in e?e.checkEnv!==!1:!0)return(await Qt.applyEnvironmentVariables(s.name||"",t,!0,s.verbose||!1))?.config??t;return t}}async function pg(e={defaultConfig:{}}){if(typeof e==="string"){let{cwd:t}=await import("process");try{return(await Qt.loadConfig({name:e,cwd:t(),generatedDir:"./generated",configDir:"./config",defaultConfig:{},checkEnv:!0,arrayStrategy:"replace"})).config}catch(i){if(i instanceof Error&&(i.name==="ConfigNotFoundError"||i.name==="ConfigLoadError"&&xf(i)))return(await Qt.applyEnvironmentVariables(e,{},!0,!1)).config;throw i}}try{return(await Qt.loadConfig({...e,cwd:e.cwd||Si.cwd(),cache:{enabled:!0},performance:{enabled:!1}})).config}catch(t){if(t instanceof Error&&(t.name==="ConfigNotFoundError"||t.name==="ConfigLoadError"&&xf(t)))return(await Qt.applyEnvironmentVariables(e.name||"",e.defaultConfig||{},e.checkEnv!==!1,e.verbose||!1)).config;throw t}}async function mg(e,t,i="replace"){let r=new yo;try{let n=await r.loadFromPath(e,t,{arrayStrategy:i,useCache:!1,trackPerformance:!1});return n?n.config:null}catch{return null}}function Rr(e,t,i=!1){let r=new go,n=e.toUpperCase().replace(/[^A-Z0-9]/g,"_");function o(s,l=[]){let a={...s};for(let[f,u]of Object.entries(s)){let d=[...l,f],h=[`${n}_${d.join("_").toUpperCase()}`,`${n}_${d.map((c)=>c.toUpperCase()).join("")}`,`${n}_${d.map((c)=>c.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],p,m;for(let c of h)if(p=Si.env[c],p!==void 0){m=c;break}if(p!==void 0&&m)if(typeof u==="boolean")a[f]=["true","1","yes"].includes(p.toLowerCase());else if(typeof u==="number"){let c=Number(p);if(!Number.isNaN(c))a[f]=c}else if(Array.isArray(u))try{a[f]=JSON.parse(p)}catch{a[f]=p.split(",").map((c)=>c.trim())}else a[f]=p;else if(u&&typeof u==="object"&&!Array.isArray(u))a[f]=o(u,d)}return a}return o(t)}function gg(e){let t=gt(Si.cwd(),e.configDir),i=gt(Si.cwd(),e.generatedDir),r=gt(i,"config-types.ts");if(!na(Qc(r)))Yp(Qc(r),{recursive:!0,mode:511});let n=na(t)?Xp(t).map((s)=>s.replace(/\.(ts|js|mjs|cjs|mts|cts|json)$/,"")).sort():[],o=`// Generated by bunfig v${zg}
193
+ `;return i}}function ug(e,t){let i=Qf("process");if(typeof i>"u"||!i.env)return t;let r=i.env[e];return r!==void 0?r:t}function Jf(e,t,i={}){return Yf(e,t,i,new WeakMap)}function Yf(e,t,i,r){let{arrayMergeMode:n="replace",skipNullish:o=!1,customMerger:s}=i;if(t===null||t===void 0)return o?e:t;if(s){let l=s(e,t);if(l!==void 0)return l}if(Array.isArray(t)||Array.isArray(e))return Xf(e,t,n,r);if(!kt(t)||!kt(e))return t;return mg(e,t,i,r)}function Xf(e,t,i,r){if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(e)&&!Array.isArray(t))return t;if(Array.isArray(t)&&Array.isArray(e))switch(i){case"replace":return t;case"concat":return dg(e,t);case"smart":return hg(e,t,r);default:return t}return t}function dg(e,t){let i=[...t];for(let r of e)if(!i.some((n)=>aa(n,r)))i.push(r);return i}function hg(e,t,i){if(t.length===0)return e;if(e.length===0)return t;if(kt(t[0])&&kt(e[0]))return pg(e,t,i);if(t.every((r)=>typeof r==="string")&&e.every((r)=>typeof r==="string")){let r=[...t];for(let n of e)if(!r.includes(n))r.push(n);return r}return t}function pg(e,t,i){let r=[...t];for(let n of e){if(!kt(n)){r.push(n);continue}let o=["id","name","key","path","type"],s=!1;for(let l of o)if(l in n){if(r.find((a)=>kt(a)&&(l in a)&&a[l]===n[l])){s=!0;break}}if(!s)r.push(n)}return r}function mg(e,t,i,r){let n=t;if(kt(n)&&r.has(n))return r.get(n);let o={...e};if(kt(n))r.set(n,o);for(let s in n){if(!Object.prototype.hasOwnProperty.call(n,s))continue;let l=n[s],a=o[s];if(i.skipNullish&&(l===null||l===void 0))continue;if(l===null||l===void 0){o[s]=l;continue}if(kt(l)&&kt(a))o[s]=Yf(a,l,i,r);else if(Array.isArray(l)||Array.isArray(a))o[s]=Xf(a,l,i.arrayMergeMode||"smart",r);else o[s]=l}return o}function $a(e,t,i="replace"){return Jf(e,t,{arrayMergeMode:i==="replace"?"replace":"smart",skipNullish:!0})}function aa(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!aa(e[i],t[i]))return!1;return!0}if(kt(e)&&kt(t)){let i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(let n of i){if(!Object.prototype.hasOwnProperty.call(t,n))return!1;if(!aa(e[n],t[n]))return!1}return!0}return!1}function kt(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class Co{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(e,t,i={}){let{arrayStrategy:r="replace",useCache:n=!0,cacheTtl:o,trackPerformance:s=!0,verbose:l=!1}=i;if(n){let f=Qi.getWithFileCheck("file",e);if(f){if(l)console.log(`Configuration loaded from cache: ${e}`);return f}}let a=async()=>{if(!zn(e))return null;try{let f=`?t=${Date.now()}`,u=await import(e+f),d=u.default||u,h="default"in u,p=Object.keys(u).length>0;if(!h&&!p)throw new Dr(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof d!=="object"||d===null||Array.isArray(d))throw new Dr(e,Error("Configuration must export a valid object"),"unknown");let m={config:$a(t,d,r),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(n)Qi.setWithFileCheck("file",m,e,o);return m}catch(f){throw f instanceof Error?li.configLoad(e,f):li.configLoad(e,Error(String(f)))}};if(s)return Nr.track("loadFromPath",a,{path:e});return a()}async tryLoadFromPaths(e,t,i={}){for(let r of e)try{let n=await this.loadFromPath(r,t,i);if(n)return n}catch(n){if(n instanceof Error&&n.name==="ConfigLoadError")throw n;if(i.verbose)console.warn(`Failed to load config from ${r}:`,n)}return null}generateConfigPaths(e,t,i){let r=this.generateNamePatterns(e,i),n=[];for(let o of r)for(let s of this.extensions)n.push(Hs(t,`${o}${s}`));return n}generateNamePatterns(e,t){let i=[];if(i.push("config",".config"),e)i.push(e,`.${e}.config`,`${e}.config`,`.${e}`);if(t){if(i.push(t,`.${t}.config`,`${t}.config`,`.${t}`),e)i.push(`${e}.${t}.config`,`.${e}.${t}.config`)}return i.filter(Boolean)}checkFileAccess(e){return Hf(async()=>zn(e),{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,t,i){let r=[];if(!zn(e))return r;if(t||i){let n=this.generateNamePatterns(t||"",i);for(let o of n)for(let s of this.extensions){let l=Hs(e,`${o}${s}`);if(await this.checkFileAccess(l))r.push(l)}}else try{let{readdirSync:n}=await import("fs"),o=n(e);for(let s of o)if(this.looksLikeConfigFile(s)){let l=Hs(e,s);if(await this.checkFileAccess(l))r.push(l)}}catch{return[]}return r}looksLikeConfigFile(e){return[/\.config\.(ts|js|mjs|cjs|json|mts|cts)$/,/^\..*\.(ts|js|mjs|cjs|json|mts|cts)$/,/config\.(ts|js|mjs|cjs|json|mts|cts)$/].some((t)=>t.test(e))}async validateConfigFile(e){let t=[];try{if(!zn(e))return t.push("Configuration file does not exist"),t;let i=await import(e),r=i.default||i;if(r===void 0)t.push("Configuration file must export a default value or named exports");else if(typeof r!=="object"||r===null)t.push("Configuration must be an object");else if(Array.isArray(r))t.push("Configuration cannot be an array at the root level");if(e.endsWith(".json"))try{let{readFileSync:n}=await import("fs"),o=n(e,"utf8");JSON.parse(o)}catch(n){t.push(`Invalid JSON syntax: ${n}`)}}catch(i){t.push(`Failed to load configuration file: ${i}`)}return t}async getFileModificationTime(e){try{let{statSync:t}=await import("fs");return t(e).mtime}catch{return null}}async preloadConfigurations(e,t={}){let i=new Map;return await Promise.allSettled(e.map(async(r)=>{try{let n=await this.loadFromPath(r,{},t);if(n)i.set(r,n.config)}catch(n){if(t.verbose)console.warn(`Failed to preload ${r}:`,n)}})),i}}class Ea{async validateConfiguration(e,t,i={}){let{stopOnFirstError:r=!1,validateRequired:n=!0,validateTypes:o=!0,customRules:s=[],trackPerformance:l=!0,verbose:a=!1}=i,f=async()=>{let u=[],d=[],h={stopOnFirstError:r,validateRequired:n,validateTypes:o,customRules:s,trackPerformance:l,verbose:a};try{if(typeof t==="string")return await this.validateWithSchemaFile(e,t,h);else if(Array.isArray(t))return this.validateWithRules(e,[...t,...s],h);else return this.validateWithJSONSchema(e,t,h)}catch(p){return u.push({path:"",message:`Validation failed: ${p}`,rule:"system"}),{isValid:!1,errors:u,warnings:d}}};if(l)return await Nr.track("validateConfiguration",f);return f()}async validateWithSchemaFile(e,t,i){try{if(!$m(t))throw new Ir(t,[{path:"",message:"Schema file does not exist"}]);let r=await import(t),n=r.default||r;if(Array.isArray(n))return this.validateWithRules(e,n,i);else return this.validateWithJSONSchema(e,n,i)}catch(r){throw new Ir(t,[{path:"",message:`Failed to load schema: ${r}`}])}}validateWithJSONSchema(e,t,i){let r=[],n=[];return this.validateObjectAgainstSchema(e,t,"",r,n,i),{isValid:r.length===0,errors:r,warnings:n}}validateObjectAgainstSchema(e,t,i,r,n,o){if(o.validateTypes&&t.type){let s=Array.isArray(e)?"array":typeof e,l=Array.isArray(t.type)?t.type:[t.type];if(!l.includes(s)){if(r.push({path:i,message:`Expected type ${l.join(" or ")}, got ${s}`,expected:l.join(" or "),actual:s,rule:"type"}),o.stopOnFirstError)return}}if(t.enum&&!t.enum.includes(e)){if(r.push({path:i,message:`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"}),o.stopOnFirstError)return}if(typeof e==="string"){if(t.minLength!==void 0&&e.length<t.minLength)r.push({path:i,message:`String length must be at least ${t.minLength}`,expected:`>= ${t.minLength}`,actual:e.length,rule:"minLength"});if(t.maxLength!==void 0&&e.length>t.maxLength)r.push({path:i,message:`String length must not exceed ${t.maxLength}`,expected:`<= ${t.maxLength}`,actual:e.length,rule:"maxLength"});if(t.pattern){if(!new RegExp(t.pattern).test(e))r.push({path:i,message:`String does not match pattern ${t.pattern}`,expected:t.pattern,actual:e,rule:"pattern"})}}if(typeof e==="number"){if(t.minimum!==void 0&&e<t.minimum)r.push({path:i,message:`Value must be at least ${t.minimum}`,expected:`>= ${t.minimum}`,actual:e,rule:"minimum"});if(t.maximum!==void 0&&e>t.maximum)r.push({path:i,message:`Value must not exceed ${t.maximum}`,expected:`<= ${t.maximum}`,actual:e,rule:"maximum"})}if(Array.isArray(e)&&t.items)for(let s=0;s<e.length;s++){let l=i?`${i}[${s}]`:`[${s}]`;if(this.validateObjectAgainstSchema(e[s],t.items,l,r,n,o),o.stopOnFirstError&&r.length>0)return}if(e&&typeof e==="object"&&!Array.isArray(e)){let s=e;if(o.validateRequired&&t.required){for(let l of t.required)if(!(l in s)){if(r.push({path:i?`${i}.${l}`:l,message:`Missing required property '${l}'`,expected:"required",rule:"required"}),o.stopOnFirstError)return}}if(t.properties){for(let[l,a]of Object.entries(t.properties))if(l in s){let f=i?`${i}.${l}`:l;if(this.validateObjectAgainstSchema(s[l],a,f,r,n,o),o.stopOnFirstError&&r.length>0)return}}if(t.additionalProperties===!1){let l=new Set(Object.keys(t.properties||{}));for(let a of Object.keys(s))if(!l.has(a))n.push({path:i?`${i}.${a}`:a,message:`Additional property '${a}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(e,t,i){let r=[],n=[];for(let o of t)try{let s=this.getValueByPath(e,o.path),l=this.validateWithRule(s,o,o.path);if(r.push(...l),i.stopOnFirstError&&r.length>0)break}catch(s){r.push({path:o.path,message:`Rule validation failed: ${s}`,rule:"system"})}return{isValid:r.length===0,errors:r,warnings:n}}validateWithRule(e,t,i){let r=[];if(t.required&&(e===void 0||e===null))return r.push({path:i,message:t.message||`Property '${i}' is required`,expected:"required",rule:"required"}),r;if(e===void 0||e===null)return r;if(t.type){let n=Array.isArray(e)?"array":typeof e;if(n!==t.type)r.push({path:i,message:t.message||`Expected type ${t.type}, got ${n}`,expected:t.type,actual:n,rule:"type"})}if(t.min!==void 0){let n=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(n<t.min)r.push({path:i,message:t.message||`Value must be at least ${t.min}`,expected:`>= ${t.min}`,actual:n,rule:"min"})}if(t.max!==void 0){let n=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(n>t.max)r.push({path:i,message:t.message||`Value must not exceed ${t.max}`,expected:`<= ${t.max}`,actual:n,rule:"max"})}if(t.pattern&&typeof e==="string"){if(!t.pattern.test(e))r.push({path:i,message:t.message||`Value does not match pattern ${t.pattern}`,expected:t.pattern.toString(),actual:e,rule:"pattern"})}if(t.enum&&!t.enum.includes(e))r.push({path:i,message:t.message||`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"});if(t.validator){let n=t.validator(e);if(n)r.push({path:i,message:t.message||n,rule:"custom"})}return r}getValueByPath(e,t){if(!t)return e;let i=t.split("."),r=e;for(let n of i)if(r&&typeof r==="object"&&n in r)r=r[n];else return;return r}generateRulesFromInterface(e){let t=[],i=e.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let r of i){let[,n,o,s]=r;t.push({path:n,required:!o,type:this.mapTypeScriptType(s)})}return t}mapTypeScriptType(e){switch(e.toLowerCase()){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"object";default:return"object"}}static createCommonRules(){return{server:[{path:"port",required:!0,type:"number",min:1,max:65535},{path:"host",required:!0,type:"string",min:1},{path:"ssl",type:"boolean"}],database:[{path:"url",required:!0,type:"string",min:1},{path:"pool",type:"number",min:1,max:100},{path:"timeout",type:"number",min:0}],api:[{path:"baseUrl",required:!0,type:"string",pattern:nu},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}class xa{fileLoader=new Co;envProcessor=new wo;validator=new Ea;async loadConfig(e){let t=Date.now(),{cache:i,performance:r,schema:n,validate:o,...s}=e;try{if(i?.enabled){let a=this.checkCache(s.name||"",s);if(a)return a}let l;try{l=await this.loadConfigurationStrategies(s,!0,i)}catch(a){let f=s.__strictErrorHandling;if(a instanceof Error&&a.name==="ConfigNotFoundError"){if(f)throw a;l={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`No configuration file found for "${s.name||"config"}", using defaults with environment variables`]}}else if(a instanceof Error&&a.name==="ConfigLoadError"){let u=a.message.includes("EACCES")||a.message.includes("EPERM")||a.message.includes("permission denied"),d=!u&&(a.message.includes("syntax")||a.message.includes("Expected")||a.message.includes("Unexpected")||a.message.includes("BuildMessage")||a.message.includes("errors building")),h=a.message.includes("Configuration must export a valid object")||a.message.includes("Configuration file is empty and exports nothing");if(f&&(h||u))throw a;if(d&&(!f||!h))l={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!f)l={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`Configuration loading error, using defaults: ${a.message}`]};else throw a}else l={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${a instanceof Error?a.message:String(a)}`]}}if(n||o)await this.validateConfiguration(l.config,n,o,s.name);if(i?.enabled&&l)this.cacheResult(s.name||"",l,i,s);if(r?.enabled){let a={operation:"loadConfig",duration:Date.now()-t,configName:s.name,timestamp:new Date};if(r.onMetrics)r.onMetrics(a);if(r.slowThreshold&&a.duration>r.slowThreshold)It.warn(`Slow configuration loading detected: ${a.duration}ms for ${s.name}`);l.metrics=a}return l}catch(l){let a=Date.now()-t;throw It.error(`Configuration loading failed after ${a}ms:`,[l instanceof Error?l:Error(String(l))]),l}}async loadConfigurationStrategies(e,t=!1,i){let{name:r="",alias:n,cwd:o,configDir:s,defaultConfig:l,checkEnv:a=!0,arrayStrategy:f="replace",verbose:u=!1}=e,d=o||Ai.cwd(),h=[],p=await this.loadLocalConfiguration(r,n,d,s,l,f,u,a,i);if(p)return h.push(...this.getLocalSearchPaths(r,n,d,s)),this.finalizeResult(p,h,a,r,u);let m=await this.loadHomeConfiguration(r,n,l,f,u,a);if(m)return h.push(...this.getHomeSearchPaths(r,n)),this.finalizeResult(m,h,a,r,u);let c=await this.loadPackageJsonConfiguration(r,n,d,l,f,u,a);if(c)return h.push(gt(d,"package.json")),this.finalizeResult(c,h,a,r,u);if(h.push(...this.getAllSearchPaths(r,n,d,s)),t)throw li.configNotFound(r,h,n);return{...await this.applyEnvironmentVariables(r,l,a,u),warnings:[`No configuration file found for "${r}"${n?` or alias "${n}"`:""}, using defaults with environment variables`]}}async loadLocalConfiguration(e,t,i,r,n,o,s,l,a){let f=l?Rr(e,n,s):n,u=this.getLocalDirectories(i,r);for(let d of u){if(s)It.info(`Searching for configuration in: ${d}`);let h=this.fileLoader.generateConfigPaths(e,d,t),p=await this.fileLoader.tryLoadFromPaths(h,f,{arrayStrategy:o,verbose:s,cacheTtl:a?.ttl,useCache:!a?.ttl||a.ttl>100});if(p){if(s)It.success(`Configuration loaded from: ${p.source.path}`);return p}}return null}async loadHomeConfiguration(e,t,i,r,n,o){if(!e)return null;let s=o?Rr(e,i,n):i,l=[gt(Gi(),".config",e),gt(Gi(),".config"),Gi()];for(let a of l){if(n)It.info(`Checking home directory: ${a}`);let f=this.fileLoader.generateConfigPaths(e,a,t),u=await this.fileLoader.tryLoadFromPaths(f,s,{arrayStrategy:r,verbose:n});if(u){if(n)It.success(`Configuration loaded from home directory: ${u.source.path}`);return u}}return null}async loadPackageJsonConfiguration(e,t,i,r,n,o,s){let l=s?Rr(e,r,o):r;try{let a=gt(i,"package.json");if(!oa(a))return null;let f=await import(a),u=f[e],d=e;if(!u&&t)u=f[t],d=t;if(u&&typeof u==="object"&&!Array.isArray(u)){if(o)It.success(`Configuration loaded from package.json: ${d}`);return{config:$a(l,u,n),source:{type:"package.json",path:a,priority:30,timestamp:new Date}}}}catch(a){if(o)It.warn("Failed to load package.json:",[a instanceof Error?a:Error(String(a))])}return null}async applyEnvironmentVariables(e,t,i,r){if(!i||!e||typeof t!=="object"||t===null||Array.isArray(t))return{config:t,source:{type:"default",priority:10,timestamp:new Date}};return{config:Rr(e,t,r),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(e,t,i,r,n){return{config:e.config,source:e.source,path:e.source.path}}async validateConfiguration(e,t,i,r){let n=[];if(i){let o=i(e);if(o)n.push(...o)}if(t){let o=await this.validator.validateConfiguration(e,t);if(!o.isValid)n.push(...o.errors.map((s)=>s.path?`${s.path}: ${s.message}`:s.message))}if(n.length>0)throw li.configValidation(r||"unknown",n,r)}checkCache(e,t){let i=this.generateCacheKey(e,t);return Qi.get(i)||null}cacheResult(e,t,i,r){let n=this.generateCacheKey(e,r);Qi.set(n,t,void 0,i.ttl)}generateCacheKey(e,t){let i=[e];if(t.alias)i.push(`alias:${t.alias}`);if(t.cwd)i.push(`cwd:${t.cwd}`);if(t.configDir)i.push(`configDir:${t.configDir}`);if("checkEnv"in t)i.push(`checkEnv:${t.checkEnv}`);return i.join("|")}getLocalDirectories(e,t){return Array.from(new Set([e,gt(e,"config"),gt(e,".config"),t?gt(e,t):void 0].filter(Boolean)))}getAllSearchPaths(e,t,i,r){let n=[];return n.push(...this.getLocalSearchPaths(e,t,i,r)),n.push(...this.getHomeSearchPaths(e,t)),n.push(gt(i,"package.json")),n}getLocalSearchPaths(e,t,i,r){let n=this.getLocalDirectories(i,r),o=[];for(let s of n)o.push(...this.fileLoader.generateConfigPaths(e,s,t));return o}getHomeSearchPaths(e,t){if(!e)return[];let i=[gt(Gi(),".config",e),gt(Gi(),".config"),Gi()],r=[];for(let n of i)r.push(...this.fileLoader.generateConfigPaths(e,n,t));return r}async loadConfigWithResult(e){return this.loadConfig(e)}}function xf(e){let t=!(e.message.includes("EACCES")||e.message.includes("EPERM")||e.message.includes("permission denied"))&&(e.message.includes("syntax")||e.message.includes("Expected")||e.message.includes("Unexpected")||e.message.includes("BuildMessage")),i=e.message.includes("Configuration must export a valid object")||e.message.includes("Configuration file is empty and exports nothing");return t||i}async function gg(e){return Qt.loadConfig({...e,__strictErrorHandling:!0})}async function Zf(e){let t="defaultConfig"in e&&e.defaultConfig!==void 0?e.defaultConfig:{},i="cache"in e||"performance"in e||"schema"in e||"validate"in e;try{let r;if(i)r=await Qt.loadConfig(e);else r=await Qt.loadConfig({...e,defaultConfig:t,cache:{enabled:!0},performance:{enabled:!1}});return r?.config??t}catch(r){let n=r instanceof Error?r.name:"UnknownError",o=r instanceof Error?r.message:String(r);if(!(n==="ConfigNotFoundError"||n==="ConfigLoadError"||n==="ConfigValidationError"||o.includes("config"))&&e.verbose)It.warn("Unexpected error loading config, using defaults:",[r instanceof Error?r:Error(String(r))]);let s=i?{...e,defaultConfig:t}:{...e,defaultConfig:t,cache:{enabled:!0},performance:{enabled:!1}};if("checkEnv"in e?e.checkEnv!==!1:!0)return(await Qt.applyEnvironmentVariables(s.name||"",t,!0,s.verbose||!1))?.config??t;return t}}async function yg(e={defaultConfig:{}}){if(typeof e==="string"){let{cwd:t}=await import("process");try{return(await Qt.loadConfig({name:e,cwd:t(),generatedDir:"./generated",configDir:"./config",defaultConfig:{},checkEnv:!0,arrayStrategy:"replace"})).config}catch(i){if(i instanceof Error&&(i.name==="ConfigNotFoundError"||i.name==="ConfigLoadError"&&xf(i)))return(await Qt.applyEnvironmentVariables(e,{},!0,!1)).config;throw i}}try{return(await Qt.loadConfig({...e,cwd:e.cwd||Ai.cwd(),cache:{enabled:!0},performance:{enabled:!1}})).config}catch(t){if(t instanceof Error&&(t.name==="ConfigNotFoundError"||t.name==="ConfigLoadError"&&xf(t)))return(await Qt.applyEnvironmentVariables(e.name||"",e.defaultConfig||{},e.checkEnv!==!1,e.verbose||!1)).config;throw t}}async function wg(e,t,i="replace"){let r=new Co;try{let n=await r.loadFromPath(e,t,{arrayStrategy:i,useCache:!1,trackPerformance:!1});return n?n.config:null}catch{return null}}function Rr(e,t,i=!1){let r=new wo,n=e.toUpperCase().replace(/[^A-Z0-9]/g,"_");function o(s,l=[]){let a={...s};for(let[f,u]of Object.entries(s)){let d=[...l,f],h=[`${n}_${d.join("_").toUpperCase()}`,`${n}_${d.map((c)=>c.toUpperCase()).join("")}`,`${n}_${d.map((c)=>c.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],p,m;for(let c of h)if(p=Ai.env[c],p!==void 0){m=c;break}if(p!==void 0&&m)if(typeof u==="boolean")a[f]=["true","1","yes"].includes(p.toLowerCase());else if(typeof u==="number"){let c=Number(p);if(!Number.isNaN(c))a[f]=c}else if(Array.isArray(u))try{a[f]=JSON.parse(p)}catch{a[f]=p.split(",").map((c)=>c.trim())}else a[f]=p;else if(u&&typeof u==="object"&&!Array.isArray(u))a[f]=o(u,d)}return a}return o(t)}function Cg(e){let t=gt(Ai.cwd(),e.configDir),i=gt(Ai.cwd(),e.generatedDir),r=gt(i,"config-types.ts");if(!oa(Qc(r)))Qp(Qc(r),{recursive:!0,mode:511});let n=oa(t)?em(t).map((s)=>s.replace(/\.(ts|js|mjs|cjs|mts|cts|json)$/,"")).sort():[],o=`// Generated by bunfig v${qg}
194
194
  export type ConfigNames = ${n.length?`'${n.join("' | '")}'`:"string"}
195
- `;Zp(r,o,{mode:438})}function yg(e){let t=null,i=null,r=()=>{if(!i)i=Zf(e).then((o)=>(t=o,o),(o)=>{let s="defaultConfig"in e?e.defaultConfig:{};if(t=s,"verbose"in e&&e.verbose)It.warn("Config loading failed, using defaults:",[o instanceof Error?o:Error(String(o))]);return s});return i},n="defaultConfig"in e?e.defaultConfig:{};return t=n,r(),new Proxy({},{get(o,s){if(t)return t[s];let l=n[s];return r(),l},has(o,s){return s in(t||n)},ownKeys(){return Object.keys(t||n)},getOwnPropertyDescriptor(o,s){return Object.getOwnPropertyDescriptor(t||n,s)},set(o,s,l){if(!t)t={...n};return t[s]=l,!0}})}function wg(e){let t=mf($m.cwd(),e?.configDir||"./config");function i(){if(!vm(t))return[];let n=new Set([".ts",".js",".mjs",".cjs",".mts",".cts",".json"]),o=[".ts",".mts",".cts",".js",".mjs",".cjs",".json"],s=bm(t).filter((a)=>n.has(Hs(a))).map((a)=>({base:a.replace(/\.(?:ts|js|mjs|cjs|mts|cts|json)$/i,""),file:a})),l=new Map;for(let{base:a,file:f}of s){let u=Hs(f).toLowerCase(),d=l.get(a);if(!d){l.set(a,f);continue}let h=Hs(d).toLowerCase();if(o.indexOf(u)<o.indexOf(h))l.set(a,f)}return Array.from(l.entries()).map(([a,f])=>({base:a,file:f})).sort((a,f)=>a.base.localeCompare(f.base))}function r(){let n=i(),o=n.map((a)=>a.base),s=o.length?o.map((a)=>`'${a}'`).join(" | "):"string",l=n.length?`{
195
+ `;tm(r,o,{mode:438})}function vg(e){let t=null,i=null,r=()=>{if(!i)i=Zf(e).then((o)=>(t=o,o),(o)=>{let s="defaultConfig"in e?e.defaultConfig:{};if(t=s,"verbose"in e&&e.verbose)It.warn("Config loading failed, using defaults:",[o instanceof Error?o:Error(String(o))]);return s});return i},n="defaultConfig"in e?e.defaultConfig:{};return t=n,r(),new Proxy({},{get(o,s){if(t)return t[s];let l=n[s];return r(),l},has(o,s){return s in(t||n)},ownKeys(){return Object.keys(t||n)},getOwnPropertyDescriptor(o,s){return Object.getOwnPropertyDescriptor(t||n,s)},set(o,s,l){if(!t)t={...n};return t[s]=l,!0}})}function bg(e){let t=mf(Sm.cwd(),e?.configDir||"./config");function i(){if(!Em(t))return[];let n=new Set([".ts",".js",".mjs",".cjs",".mts",".cts",".json"]),o=[".ts",".mts",".cts",".js",".mjs",".cjs",".json"],s=xm(t).filter((a)=>n.has(qs(a))).map((a)=>({base:a.replace(/\.(?:ts|js|mjs|cjs|mts|cts|json)$/i,""),file:a})),l=new Map;for(let{base:a,file:f}of s){let u=qs(f).toLowerCase(),d=l.get(a);if(!d){l.set(a,f);continue}let h=qs(d).toLowerCase();if(o.indexOf(u)<o.indexOf(h))l.set(a,f)}return Array.from(l.entries()).map(([a,f])=>({base:a,file:f})).sort((a,f)=>a.base.localeCompare(f.base))}function r(){let n=i(),o=n.map((a)=>a.base),s=o.length?o.map((a)=>`'${a}'`).join(" | "):"string",l=n.length?`{
196
196
  ${n.map((a)=>{let f=mf(t,a.file).replace(/\\/g,"/");return` '${a.base}': typeof import('${f}').default`}).join(`,
197
197
  `)}
198
198
  }`:"Record<string, any>";return`export type ConfigNames = ${s}
199
199
  export type ConfigByName = ${l}
200
200
  export type Config<N extends ConfigNames> = N extends keyof ConfigByName ? ConfigByName[N] : unknown
201
201
  export type ConfigOf = Config
202
- `}return{name:"bunfig-plugin",setup(n){n.onResolve({filter:/^virtual:bunfig-types$/},(o)=>({path:o.path,namespace:"bunfig-virtual"})),n.onLoad({filter:/^virtual:bunfig-types$/,namespace:"bunfig-virtual"},()=>({contents:r(),loader:"ts"}))}}}function Hg(e,t={}){let i=no.cwd();while(i.includes("storage"))i=gf(i,"..");let r=gf(i,e||"");if(t?.relative)return xm(no.cwd(),r);return r}function rt(){if(Zt.env.NODE_ENV==="test"||Zt.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Jg(){if(Zt.env.NODE_ENV==="test"||Zt.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof Zt<"u"){let e=Zt.type;if(e==="renderer"||e==="worker")return!1;return!!(Zt.versions&&(Zt.versions.node||Zt.versions.bun))}return!1}class lu{async format(e){let t=await Jg(),i=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:i})}async getMetadata(e){if(e){let{hostname:t}=await import("os");return{pid:Yi.pid,hostname:t(),environment:Yi.env.NODE_ENV||"development",platform:Yi.platform,version:Yi.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:Yi.env.NODE_ENV||Yi.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class wo{name;fileLocks=new Map;currentKeyId=null;keys=new Map;fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor(e,t={}){this.name=e,this.config={...ho},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new lu,this.enabled=t.enabled??!0,this.fancy=t.fancy??!0,this.tagFormat=t.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=t.timestampPosition??"right",this.environment=t.environment??Be.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let i={...t},r=t.timestamp!==void 0;if(r)delete i.timestamp;if(this.config={...this.config,...i,timestamp:r||this.config.timestamp,level:this.options.level??"info"},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let n=this.generateKeyId(),o=this.generateKey();this.currentKeyId=n,this.keys.set(n,o),this.encryptionKeys.set(n,{key:o,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;let t={debug:0,info:1,success:2,warning:3,error:4},i=this.fingersCrossedConfig.activationLevel??"error";return t[e]>=t[i]}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...ia,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...ia};return{...ia,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:ho.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},i={...t,...Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0))};if(!i.level||!["debug","info","success","warning","error"].includes(i.level))i.level=t.level;return i}shouldWriteToFile(){return!rt()&&this.config.writeToFile===!0}async writeToFile(e){let t=(async()=>{let r,n=0,o=3,s=1000;while(n<o)try{try{try{await Om(this.config.logDirectory,vf.F_OK|vf.W_OK)}catch(a){if(a instanceof Error&&"code"in a)if(a.code==="ENOENT")await Rm(this.config.logDirectory,{recursive:!0,mode:493});else if(a.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw a;else throw a}}catch(a){throw console.error("Debug: [writeToFile] Failed to create log directory:",a),a}let l=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:qt.from(e);try{if(!Un(this.currentLogFile))await Ys(this.currentLogFile,"",{mode:420});if(r=Cf(this.currentLogFile,"a",420),Tm(r,l,{flag:"a"}),wf(r),r!==void 0)Js(r),r=void 0;if((await qi(this.currentLogFile)).size===0){if(await Ys(this.currentLogFile,l,{flag:"w",mode:420}),(await qi(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(a){let f=a;if(f.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(f.code)){if(n<o-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${n+1}/${o}:`,u);let d=s*2**n;await new Promise((h)=>setTimeout(h,d)),n++;continue}}if(f?.code&&["ENOSPC","EDQUOT"].includes(f.code))throw Error(`Disk quota exceeded or no space left on device: ${f.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",f),f}finally{if(r!==void 0)try{Js(r)}catch(a){console.error("Debug: [writeToFile] Error closing file descriptor:",a)}}}catch(l){if(n===o-1){let f=l,u=typeof f.message==="string"?f.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",u),l}n++;let a=s*2**(n-1);await new Promise((f)=>setTimeout(f,a))}})();this.pendingOperations.push(t);let i=this.pendingOperations.length-1;try{await t}catch(r){throw console.error("Debug: [writeToFile] Error in operation:",r),r}finally{this.pendingOperations.splice(i,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return Ji(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return Ji(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return Ji(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(rt())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,t;switch(e.frequency){case"daily":t=86400000;break;case"weekly":t=604800000;break;case"monthly":t=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},t)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let e=this.config.rotation.keyRotation;if(!e?.enabled)return;let t=typeof e.interval==="number"?e.interval:60,i=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((r)=>{console.error("Error rotating keys:",r)})},i)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let e=this.config.rotation.keyRotation,t=this.generateKeyId(),i=this.generateKey();this.currentKeyId=t,this.keys.set(t,i),this.encryptionKeys.set(t,{key:i,createdAt:new Date});let r=Array.from(this.encryptionKeys.entries()).sort(([,s],[,l])=>l.createdAt.getTime()-s.createdAt.getTime()),n=typeof e.maxKeys==="number"?e.maxKeys:1,o=Math.max(1,n);if(r.length>o)for(let[s]of r.slice(o))this.encryptionKeys.delete(s),this.keys.delete(s)}generateKeyId(){return qs(16).toString("hex")}generateKey(){return qs(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let e=this.keys.get(this.currentKeyId);if(!e)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:e,id:this.currentKeyId}}encrypt(e){let{key:t}=this.getCurrentKey(),i=qs(16),r=Sm("aes-256-gcm",t,i),n=qt.isBuffer(e)?e:qt.from(e,"utf8"),o=r.update(n),s=r.final(),l=o.length+s.length,a=r.getAuthTag(),f=qt.allocUnsafe(16+l+16);return i.copy(f,0),o.copy(f,16),s.copy(f,16+o.length),a.copy(f,16+l),{encrypted:f,iv:i}}async compressData(e){return new Promise((t,i)=>{let r=$f(),n=[];r.on("data",(o)=>n.push(o)),r.on("end",()=>t(qt.from(qt.concat(n)))),r.on("error",i),r.write(e),r.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let e={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let t=this.config.rotation.encrypt;return{...e,...t}}return e}async rotateLog(){if(rt())return;if(!this.shouldWriteToFile())return;let e=await qi(this.currentLogFile).catch(()=>null);if(!e)return;let t=this.config.rotation;if(typeof t==="boolean")return;if(t.maxSize&&e.size>=t.maxSize){let i=this.currentLogFile,r=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let n=await zn(this.config.logDirectory),o=n.filter((a)=>a.startsWith(this.name)&&/\.log\.\d+$/.test(a)).sort((a,f)=>{let u=Number.parseInt(a.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(f.match(/\.log\.(\d+)$/)?.[1]||"0")-u}),s=o.length>0?Number.parseInt(o[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,l=`${i}.${s}`;if(await qi(i).catch(()=>null))try{if(await bf(i,l),t.compress)try{let a=`${l}.gz`;await this.compressLogFile(l,a),await Kn(l)}catch(a){console.error("Error compressing rotated file:",a)}if(o.length===0&&!n.some((a)=>a.endsWith(".log.1")))try{let a=`${i}.1`;await Ys(a,"")}catch(a){console.error("Error creating backup file:",a)}}catch(a){console.error(`Error during rotation: ${a instanceof Error?a.message:String(a)}`)}}else{let n=new Date().toISOString().replace(/[:.]/g,"-"),o=i.replace(/\.log$/,`-${n}.log`);if(await qi(i).catch(()=>null))await bf(i,o)}if(this.currentLogFile=r,t.maxFiles){let n=(await zn(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,s)=>s.localeCompare(o));for(let o of n.slice(t.maxFiles))await Kn(Ji(this.config.logDirectory,o))}}}async compressLogFile(e,t){let i=yf(e),r=km(t),n=$f();await Dm(i,n,r)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let i of this.logBuffer){let r=await this.formatter.format(i);if(this.shouldWriteToFile())await this.writeToFile(r);console.log(r)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(t);console.log(t)}}shouldLog(e){if(!this.enabled)return!1;let t={debug:0,info:1,success:2,warning:3,error:4};return t[e]>=t[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((t)=>{console.error("Error in pending write operation:",t)});return Promise.resolve()})),Un(this.currentLogFile))try{let e=Cf(this.currentLogFile,"r+");wf(e),Js(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!rt()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await zn(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await Kn(Ji(this.config.logDirectory,t))}catch(i){console.error(`Failed to delete temp file ${t}:`,i)}}catch(e){console.error("Error cleaning up temporary files:",e)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(e){if(!e)return"";return`${this.tagFormat.prefix}${e}${this.tagFormat.suffix}`}formatFileTimestamp(e){return`[${e.toISOString()}]`}formatConsoleTimestamp(e){return this.shouldStyleConsole()?Pe.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||rt())return!1;let e=typeof Be.env.NO_COLOR<"u",t=Be.env.FORCE_COLOR==="0";if(e||t)return!1;return!!(typeof Be.stderr<"u"&&Be.stderr.isTTY||typeof Be.stdout<"u"&&Be.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:t,icon:i="",tag:r="",message:n,level:o,showTimestamp:s=!0}=e,l=(p)=>p.replace(this.ANSI_PATTERN,"");if(!this.fancy){let p=[];if(s)p.push(t);if(o==="warning")p.push("WARN");else if(o==="error")p.push("ERROR");else if(i)p.push(i.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(r)p.push(r.replace(/[[\]]/g,""));return p.push(n),p.join(" ")}let a=Be.stdout.columns||120,f="";if(o==="warning"||o==="error")f=`${i} ${n}`;else if(o==="info"||o==="success")f=`${i} ${r} ${n}`;else f=`${i} ${r} ${Pe.cyan(n)}`;if(!s)return f.trim();let u=l(f).trim().length,d=l(t).length,h=Math.max(1,a-2-u-d);return`${f.trim()}${" ".repeat(h)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(o,s)=>{let l=Number.parseInt(s,10);return l<t[0].length?String(t[0][l]):o});let i=/%([sdijfo%])/g,r=0,n=e.replace(i,(o,s)=>{if(s==="%")return"%";if(r>=t.length)return o;let l=t[r++];switch(s){case"s":return String(l);case"d":case"i":return Number(l).toString();case"j":case"o":return JSON.stringify(l,null,2);default:return o}});if(r<t.length)n+=` ${t.slice(r).map((o)=>typeof o==="object"?JSON.stringify(o,null,2):String(o)).join(" ")}`;return n}formatMarkdown(e){if(!e)return e;let t=e;return t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(i,r,n)=>{let o=Pe.underline(Pe.blue(r)),s=this.toAbsoluteFilePath(n);if(s&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let l=`file://${encodeURI(s)}`,a="\x1B]8;;",f="\x1B\\";return`\x1B]8;;${l}\x1B\\${o}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${n}\x1B\\${o}\x1B]8;;\x1B\\`;return o}),t=t.replace(/`([^`]+)`/g,(i,r)=>Pe.bgGray(r)),t=t.replace(/\*\*([^*]+)\*\*/g,(i,r)=>Pe.bold(r)),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(i,r)=>Pe.italic(r)),t=t.replace(/(?<!_)_([^_]+)_(?!_)/g,(i,r)=>Pe.italic(r)),t=t.replace(/~([^~]+)~/g,(i,r)=>Pe.strikethrough(r)),t}supportsHyperlinks(){if(rt())return!1;let e=Be.env;if(!e)return!1;if(e.TERM_PROGRAM==="iTerm.app"||e.TERM_PROGRAM==="vscode"||e.TERM_PROGRAM==="WezTerm")return!0;if(e.WT_SESSION)return!0;if(e.TERM==="xterm-kitty")return!0;let t=e.VTE_VERSION?Number.parseInt(e.VTE_VERSION,10):0;if(!Number.isNaN(t)&&t>=5000)return!0;return!1}toAbsoluteFilePath(e){try{let t=e;if(t.startsWith("file://"))t=t.replace(/^file:\/\//,"");if(t.startsWith("~")){let i=Be.env.HOME||"";if(i)t=t.replace(/^~(?=$|\/)/,i)}if(Pm(t)||t.startsWith("./")||t.startsWith("../"))t=Mm(t);else return null;return Un(t)?t:null}catch{return null}}buildOutputTexts(e){let t=this.shouldStyleConsole()?this.formatMarkdown(e):e,i=e.replace(this.ANSI_PATTERN,"");return{consoleText:t,fileText:i}}async log(e,t,...i){if(!this.shouldLog(e))return;let r=new Date,n=this.formatConsoleTimestamp(r),o=this.formatFileTimestamp(r),s,l;if(t instanceof Error)s=t.message,l=t.stack;else s=this.formatMessage(t,i);let{consoleText:a,fileText:f}=this.buildOutputTexts(s);if(this.shouldStyleConsole()){let d=this.options.showIcons===!1?"":ey[e],h=this.options.showTags!==!1&&this.name?Pe.gray(this.formatTag(this.name)):"",p;switch(e){case"debug":p=this.formatConsoleMessage({timestamp:n,icon:d,tag:h,message:Pe.gray(a),level:e}),console.error(p);break;case"info":p=this.formatConsoleMessage({timestamp:n,icon:d,tag:h,message:a,level:e}),console.warn(p);break;case"success":p=this.formatConsoleMessage({timestamp:n,icon:d,tag:h,message:Pe.green(a),level:e}),console.error(p);break;case"warning":p=this.formatConsoleMessage({timestamp:n,icon:d,tag:h,message:a,level:e}),console.warn(p);break;case"error":if(p=this.formatConsoleMessage({timestamp:n,icon:d,tag:h,message:a,level:e}),console.error(p),l){let m=l.split(`
202
+ `}return{name:"bunfig-plugin",setup(n){n.onResolve({filter:/^virtual:bunfig-types$/},(o)=>({path:o.path,namespace:"bunfig-virtual"})),n.onLoad({filter:/^virtual:bunfig-types$/,namespace:"bunfig-virtual"},()=>({contents:r(),loader:"ts"}))}}}function Yg(e,t={}){let i=so.cwd();while(i.includes("storage"))i=gf(i,"..");let r=gf(i,e||"");if(t?.relative)return km(so.cwd(),r);return r}function rt(){if(Zt.env.NODE_ENV==="test"||Zt.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Zg(){if(Zt.env.NODE_ENV==="test"||Zt.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof Zt<"u"){let e=Zt.type;if(e==="renderer"||e==="worker")return!1;return!!(Zt.versions&&(Zt.versions.node||Zt.versions.bun))}return!1}class lu{async format(e){let t=await Zg(),i=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:i})}async getMetadata(e){if(e){let{hostname:t}=await import("os");return{pid:Xi.pid,hostname:t(),environment:Xi.env.NODE_ENV||"development",platform:Xi.platform,version:Xi.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:Xi.env.NODE_ENV||Xi.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class vo{name;fileLocks=new Map;currentKeyId=null;keys=new Map;fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor(e,t={}){this.name=e,this.config={...mo},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new lu,this.enabled=t.enabled??!0,this.fancy=t.fancy??!0,this.tagFormat=t.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=t.timestampPosition??"right",this.environment=t.environment??Be.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let i={...t},r=t.timestamp!==void 0;if(r)delete i.timestamp;if(this.config={...this.config,...i,timestamp:r||this.config.timestamp,level:this.options.level??"info"},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let n=this.generateKeyId(),o=this.generateKey();this.currentKeyId=n,this.keys.set(n,o),this.encryptionKeys.set(n,{key:o,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;let t={debug:0,info:1,success:2,warning:3,error:4},i=this.fingersCrossedConfig.activationLevel??"error";return t[e]>=t[i]}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...ra,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...ra};return{...ra,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:mo.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},i={...t,...Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0))};if(!i.level||!["debug","info","success","warning","error"].includes(i.level))i.level=t.level;return i}shouldWriteToFile(){return!rt()&&this.config.writeToFile===!0}async writeToFile(e){let t=(async()=>{let r,n=0,o=3,s=1000;while(n<o)try{try{try{await Mm(this.config.logDirectory,vf.F_OK|vf.W_OK)}catch(a){if(a instanceof Error&&"code"in a)if(a.code==="ENOENT")await Dm(this.config.logDirectory,{recursive:!0,mode:493});else if(a.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw a;else throw a}}catch(a){throw console.error("Debug: [writeToFile] Failed to create log directory:",a),a}let l=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:qt.from(e);try{if(!Kn(this.currentLogFile))await Xs(this.currentLogFile,"",{mode:420});if(r=Cf(this.currentLogFile,"a",420),Pm(r,l,{flag:"a"}),wf(r),r!==void 0)Ys(r),r=void 0;if((await Ji(this.currentLogFile)).size===0){if(await Xs(this.currentLogFile,l,{flag:"w",mode:420}),(await Ji(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(a){let f=a;if(f.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(f.code)){if(n<o-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${n+1}/${o}:`,u);let d=s*2**n;await new Promise((h)=>setTimeout(h,d)),n++;continue}}if(f?.code&&["ENOSPC","EDQUOT"].includes(f.code))throw Error(`Disk quota exceeded or no space left on device: ${f.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",f),f}finally{if(r!==void 0)try{Ys(r)}catch(a){console.error("Debug: [writeToFile] Error closing file descriptor:",a)}}}catch(l){if(n===o-1){let f=l,u=typeof f.message==="string"?f.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",u),l}n++;let a=s*2**(n-1);await new Promise((f)=>setTimeout(f,a))}})();this.pendingOperations.push(t);let i=this.pendingOperations.length-1;try{await t}catch(r){throw console.error("Debug: [writeToFile] Error in operation:",r),r}finally{this.pendingOperations.splice(i,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return Yi(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return Yi(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return Yi(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(rt())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,t;switch(e.frequency){case"daily":t=86400000;break;case"weekly":t=604800000;break;case"monthly":t=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},t)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let e=this.config.rotation.keyRotation;if(!e?.enabled)return;let t=typeof e.interval==="number"?e.interval:60,i=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((r)=>{console.error("Error rotating keys:",r)})},i)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let e=this.config.rotation.keyRotation,t=this.generateKeyId(),i=this.generateKey();this.currentKeyId=t,this.keys.set(t,i),this.encryptionKeys.set(t,{key:i,createdAt:new Date});let r=Array.from(this.encryptionKeys.entries()).sort(([,s],[,l])=>l.createdAt.getTime()-s.createdAt.getTime()),n=typeof e.maxKeys==="number"?e.maxKeys:1,o=Math.max(1,n);if(r.length>o)for(let[s]of r.slice(o))this.encryptionKeys.delete(s),this.keys.delete(s)}generateKeyId(){return Js(16).toString("hex")}generateKey(){return Js(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let e=this.keys.get(this.currentKeyId);if(!e)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:e,id:this.currentKeyId}}encrypt(e){let{key:t}=this.getCurrentKey(),i=Js(16),r=Tm("aes-256-gcm",t,i),n=qt.isBuffer(e)?e:qt.from(e,"utf8"),o=r.update(n),s=r.final(),l=o.length+s.length,a=r.getAuthTag(),f=qt.allocUnsafe(16+l+16);return i.copy(f,0),o.copy(f,16),s.copy(f,16+o.length),a.copy(f,16+l),{encrypted:f,iv:i}}async compressData(e){return new Promise((t,i)=>{let r=$f(),n=[];r.on("data",(o)=>n.push(o)),r.on("end",()=>t(qt.from(qt.concat(n)))),r.on("error",i),r.write(e),r.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let e={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let t=this.config.rotation.encrypt;return{...e,...t}}return e}async rotateLog(){if(rt())return;if(!this.shouldWriteToFile())return;let e=await Ji(this.currentLogFile).catch(()=>null);if(!e)return;let t=this.config.rotation;if(typeof t==="boolean")return;if(t.maxSize&&e.size>=t.maxSize){let i=this.currentLogFile,r=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let n=await Hn(this.config.logDirectory),o=n.filter((a)=>a.startsWith(this.name)&&/\.log\.\d+$/.test(a)).sort((a,f)=>{let u=Number.parseInt(a.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(f.match(/\.log\.(\d+)$/)?.[1]||"0")-u}),s=o.length>0?Number.parseInt(o[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,l=`${i}.${s}`;if(await Ji(i).catch(()=>null))try{if(await bf(i,l),t.compress)try{let a=`${l}.gz`;await this.compressLogFile(l,a),await qn(l)}catch(a){console.error("Error compressing rotated file:",a)}if(o.length===0&&!n.some((a)=>a.endsWith(".log.1")))try{let a=`${i}.1`;await Xs(a,"")}catch(a){console.error("Error creating backup file:",a)}}catch(a){console.error(`Error during rotation: ${a instanceof Error?a.message:String(a)}`)}}else{let n=new Date().toISOString().replace(/[:.]/g,"-"),o=i.replace(/\.log$/,`-${n}.log`);if(await Ji(i).catch(()=>null))await bf(i,o)}if(this.currentLogFile=r,t.maxFiles){let n=(await Hn(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,s)=>s.localeCompare(o));for(let o of n.slice(t.maxFiles))await qn(Yi(this.config.logDirectory,o))}}}async compressLogFile(e,t){let i=yf(e),r=Rm(t),n=$f();await Fm(i,n,r)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let i of this.logBuffer){let r=await this.formatter.format(i);if(this.shouldWriteToFile())await this.writeToFile(r);console.log(r)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(t);console.log(t)}}shouldLog(e){if(!this.enabled)return!1;let t={debug:0,info:1,success:2,warning:3,error:4};return t[e]>=t[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((t)=>{console.error("Error in pending write operation:",t)});return Promise.resolve()})),Kn(this.currentLogFile))try{let e=Cf(this.currentLogFile,"r+");wf(e),Ys(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!rt()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await Hn(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await qn(Yi(this.config.logDirectory,t))}catch(i){console.error(`Failed to delete temp file ${t}:`,i)}}catch(e){console.error("Error cleaning up temporary files:",e)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(e){if(!e)return"";return`${this.tagFormat.prefix}${e}${this.tagFormat.suffix}`}formatFileTimestamp(e){return`[${e.toISOString()}]`}formatConsoleTimestamp(e){return this.shouldStyleConsole()?Pe.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||rt())return!1;let e=typeof Be.env.NO_COLOR<"u",t=Be.env.FORCE_COLOR==="0";if(e||t)return!1;return!!(typeof Be.stderr<"u"&&Be.stderr.isTTY||typeof Be.stdout<"u"&&Be.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:t,icon:i="",tag:r="",message:n,level:o,showTimestamp:s=!0}=e,l=(p)=>p.replace(this.ANSI_PATTERN,"");if(!this.fancy){let p=[];if(s)p.push(t);if(o==="warning")p.push("WARN");else if(o==="error")p.push("ERROR");else if(i)p.push(i.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(r)p.push(r.replace(/[[\]]/g,""));return p.push(n),p.join(" ")}let a=Be.stdout.columns||120,f="";if(o==="warning"||o==="error")f=`${i} ${n}`;else if(o==="info"||o==="success")f=`${i} ${r} ${n}`;else f=`${i} ${r} ${Pe.cyan(n)}`;if(!s)return f.trim();let u=l(f).trim().length,d=l(t).length,h=Math.max(1,a-2-u-d);return`${f.trim()}${" ".repeat(h)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(o,s)=>{let l=Number.parseInt(s,10);return l<t[0].length?String(t[0][l]):o});let i=/%([sdijfo%])/g,r=0,n=e.replace(i,(o,s)=>{if(s==="%")return"%";if(r>=t.length)return o;let l=t[r++];switch(s){case"s":return String(l);case"d":case"i":return Number(l).toString();case"j":case"o":return JSON.stringify(l,null,2);default:return o}});if(r<t.length)n+=` ${t.slice(r).map((o)=>typeof o==="object"?JSON.stringify(o,null,2):String(o)).join(" ")}`;return n}formatMarkdown(e){if(!e)return e;let t=e;return t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(i,r,n)=>{let o=Pe.underline(Pe.blue(r)),s=this.toAbsoluteFilePath(n);if(s&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let l=`file://${encodeURI(s)}`,a="\x1B]8;;",f="\x1B\\";return`\x1B]8;;${l}\x1B\\${o}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${n}\x1B\\${o}\x1B]8;;\x1B\\`;return o}),t=t.replace(/`([^`]+)`/g,(i,r)=>Pe.bgGray(r)),t=t.replace(/\*\*([^*]+)\*\*/g,(i,r)=>Pe.bold(r)),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(i,r)=>Pe.italic(r)),t=t.replace(/(?<!_)_([^_]+)_(?!_)/g,(i,r)=>Pe.italic(r)),t=t.replace(/~([^~]+)~/g,(i,r)=>Pe.strikethrough(r)),t}supportsHyperlinks(){if(rt())return!1;let e=Be.env;if(!e)return!1;if(e.TERM_PROGRAM==="iTerm.app"||e.TERM_PROGRAM==="vscode"||e.TERM_PROGRAM==="WezTerm")return!0;if(e.WT_SESSION)return!0;if(e.TERM==="xterm-kitty")return!0;let t=e.VTE_VERSION?Number.parseInt(e.VTE_VERSION,10):0;if(!Number.isNaN(t)&&t>=5000)return!0;return!1}toAbsoluteFilePath(e){try{let t=e;if(t.startsWith("file://"))t=t.replace(/^file:\/\//,"");if(t.startsWith("~")){let i=Be.env.HOME||"";if(i)t=t.replace(/^~(?=$|\/)/,i)}if(Im(t)||t.startsWith("./")||t.startsWith("../"))t=Nm(t);else return null;return Kn(t)?t:null}catch{return null}}buildOutputTexts(e){let t=this.shouldStyleConsole()?this.formatMarkdown(e):e,i=e.replace(this.ANSI_PATTERN,"");return{consoleText:t,fileText:i}}async log(e,t,...i){if(!this.shouldLog(e))return;let r=new Date,n=this.formatConsoleTimestamp(r),o=this.formatFileTimestamp(r),s,l;if(t instanceof Error)s=t.message,l=t.stack;else s=this.formatMessage(t,i);let{consoleText:a,fileText:f}=this.buildOutputTexts(s);if(this.shouldStyleConsole()){let d=this.options.showIcons===!1?"":ry[e],h=this.options.showTags!==!1&&this.name?Pe.gray(this.formatTag(this.name)):"",p;switch(e){case"debug":p=this.formatConsoleMessage({timestamp:n,icon:d,tag:h,message:Pe.gray(a),level:e}),console.error(p);break;case"info":p=this.formatConsoleMessage({timestamp:n,icon:d,tag:h,message:a,level:e}),console.warn(p);break;case"success":p=this.formatConsoleMessage({timestamp:n,icon:d,tag:h,message:Pe.green(a),level:e}),console.error(p);break;case"warning":p=this.formatConsoleMessage({timestamp:n,icon:d,tag:h,message:a,level:e}),console.warn(p);break;case"error":if(p=this.formatConsoleMessage({timestamp:n,icon:d,tag:h,message:a,level:e}),console.error(p),l){let m=l.split(`
203
203
  `);for(let c of m)if(c.trim()&&!c.includes(s))console.error(this.formatConsoleMessage({timestamp:n,message:Pe.gray(` ${c}`),level:e,showTimestamp:!1}))}break}}else if(!rt()){if(console.error(`${o} ${this.environment}.${e.toUpperCase()}: ${s}`),l)console.error(l)}let u=`${o} ${this.environment}.${e.toUpperCase()}: ${f}
204
204
  `;if(l)u+=`${l}
205
205
  `;if(u=u.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(u)}progress(e,t=""){let i={update:(n,o)=>{},finish:(n)=>{},interrupt:(n,o)=>{}};if(!this.enabled)return i;let r=30;if(this.activeProgressBar={total:Math.max(1,e||1),current:0,message:t||"",barLength:r,lastRenderedLine:""},this.shouldStyleConsole()&&!rt()&&Be.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(n,o)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,n),this.activeProgressBar.total),o!==void 0)this.activeProgressBar.message=o;if(this.shouldStyleConsole()&&!rt()&&Be.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(n)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,n)},interrupt:(n,o="info")=>{if(!rt()&&Be.stdout.isTTY)Be.stdout.write(`
206
206
  `);if(this[o==="warning"?"warn":o](n),this.activeProgressBar&&this.shouldStyleConsole()&&!rt()&&Be.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time(e){let t=performance.now();if(this.shouldStyleConsole()){let i=this.options.showTags!==!1&&this.name?Pe.gray(this.formatTag(this.name)):"",r=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:r,icon:this.options.showIcons===!1?"":Pe.blue("\u25D0"),tag:i,message:`${Pe.cyan(e)}...`}))}return async(i)=>{if(!this.enabled)return;let r=performance.now(),n=Math.round(r-t),o=`${e} completed in ${n}ms`,s=new Date,l=this.formatConsoleTimestamp(s),a=`${this.formatFileTimestamp(s)} ${this.environment}.INFO: ${o}`;if(i)a+=` ${JSON.stringify(i)}`;if(a+=`
207
- `,a=a.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let f=this.options.showTags!==!1&&this.name?Pe.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:l,icon:this.options.showIcons===!1?"":Pe.green("\u2713"),tag:f,message:`${o}${i?` ${JSON.stringify(i)}`:""}`}))}else if(!rt())console.error(a.trim());if(this.shouldWriteToFile())await this.writeToFile(a)}}async debug(e,...t){await this.log("debug",e,...t)}async info(e,...t){await this.log("info",e,...t)}async success(e,...t){await this.log("success",e,...t)}async warn(e,...t){await this.log("warning",e,...t)}async error(e,...t){await this.log("error",e,...t)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let e=this.config.rotation,{encrypt:t}=e;return!!t}async only(e){if(!this.enabled)return;return await e()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}extend(e){let t=`${this.name}:${e}`,i=new wo(t,{...this.options,logDirectory:this.config.logDirectory,level:this.config.level,format:this.config.format,rotation:typeof this.config.rotation==="boolean"?void 0:this.config.rotation,timestamp:typeof this.config.timestamp==="boolean"?void 0:this.config.timestamp});return this.subLoggers.add(i),i}createReadStream(){if(rt())throw Error("createReadStream is not supported in browser environments");if(!Un(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return yf(this.currentLogFile,{encoding:"utf8"})}async decrypt(e){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let t=this.config.rotation;if(!t.encrypt||typeof t.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let i=this.keys.get(this.currentKeyId);try{let r=qt.isBuffer(e)?e:qt.from(e,"base64"),n=r.subarray(0,16),o=r.subarray(r.length-16),s=r.subarray(16,r.length-16),l=Am("aes-256-gcm",i,n);l.setAuthTag(o);let a=l.update(s),f=l.final(),u=a.length+f.length,d=qt.allocUnsafe(u);return a.copy(d,0),f.copy(d,a.length),d.toString("utf8")}catch(r){throw Error(`Decryption failed: ${r instanceof Error?r.message:String(r)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return rt()}isServerMode(){return!rt()}setTestEncryptionKey(e,t){this.currentKeyId=e,this.keys.set(e,t)}getTestCurrentKey(){if(!this.currentKeyId||!this.keys.has(this.currentKeyId))return null;return{id:this.currentKeyId,key:this.keys.get(this.currentKeyId)}}getConfig(){return this.config}async box(e){if(!this.enabled)return;let t=new Date,i=this.formatConsoleTimestamp(t),r=this.formatFileTimestamp(t),{consoleText:n,fileText:o}=this.buildOutputTexts(e);if(this.shouldStyleConsole()){let l=n.split(`
207
+ `,a=a.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let f=this.options.showTags!==!1&&this.name?Pe.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:l,icon:this.options.showIcons===!1?"":Pe.green("\u2713"),tag:f,message:`${o}${i?` ${JSON.stringify(i)}`:""}`}))}else if(!rt())console.error(a.trim());if(this.shouldWriteToFile())await this.writeToFile(a)}}async debug(e,...t){await this.log("debug",e,...t)}async info(e,...t){await this.log("info",e,...t)}async success(e,...t){await this.log("success",e,...t)}async warn(e,...t){await this.log("warning",e,...t)}async error(e,...t){await this.log("error",e,...t)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let e=this.config.rotation,{encrypt:t}=e;return!!t}async only(e){if(!this.enabled)return;return await e()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}extend(e){let t=`${this.name}:${e}`,i=new vo(t,{...this.options,logDirectory:this.config.logDirectory,level:this.config.level,format:this.config.format,rotation:typeof this.config.rotation==="boolean"?void 0:this.config.rotation,timestamp:typeof this.config.timestamp==="boolean"?void 0:this.config.timestamp});return this.subLoggers.add(i),i}createReadStream(){if(rt())throw Error("createReadStream is not supported in browser environments");if(!Kn(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return yf(this.currentLogFile,{encoding:"utf8"})}async decrypt(e){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let t=this.config.rotation;if(!t.encrypt||typeof t.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let i=this.keys.get(this.currentKeyId);try{let r=qt.isBuffer(e)?e:qt.from(e,"base64"),n=r.subarray(0,16),o=r.subarray(r.length-16),s=r.subarray(16,r.length-16),l=Om("aes-256-gcm",i,n);l.setAuthTag(o);let a=l.update(s),f=l.final(),u=a.length+f.length,d=qt.allocUnsafe(u);return a.copy(d,0),f.copy(d,a.length),d.toString("utf8")}catch(r){throw Error(`Decryption failed: ${r instanceof Error?r.message:String(r)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return rt()}isServerMode(){return!rt()}setTestEncryptionKey(e,t){this.currentKeyId=e,this.keys.set(e,t)}getTestCurrentKey(){if(!this.currentKeyId||!this.keys.has(this.currentKeyId))return null;return{id:this.currentKeyId,key:this.keys.get(this.currentKeyId)}}getConfig(){return this.config}async box(e){if(!this.enabled)return;let t=new Date,i=this.formatConsoleTimestamp(t),r=this.formatFileTimestamp(t),{consoleText:n,fileText:o}=this.buildOutputTexts(e);if(this.shouldStyleConsole()){let l=n.split(`
208
208
  `),a=Math.max(...l.map((h)=>h.length))+2,f=`\u250C${"\u2500".repeat(a)}\u2510`,u=`\u2514${"\u2500".repeat(a)}\u2518`,d=l.map((h)=>this.formatConsoleMessage({timestamp:i,message:Pe.cyan(h),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:i,message:Pe.cyan(f),showTimestamp:!1})),d.forEach((h)=>console.error(h)),console.error(this.formatConsoleMessage({timestamp:i,message:Pe.cyan(u),showTimestamp:!1}))}else if(!rt())console.error(`${r} ${this.environment}.INFO: [BOX] ${o}`);let s=`${r} ${this.environment}.INFO: [BOX] ${o}
209
209
  `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(s)}async prompt(e){if(rt())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${Pe.cyan("?")} ${e} (y/n) `);let i=(r)=>{let n=r.toString().trim().toLowerCase();Be.stdin.removeListener("data",i);try{if(typeof Be.stdin.setRawMode==="function")Be.stdin.setRawMode(!1)}catch{}Be.stdin.pause(),console.error(""),t(n==="y"||n==="yes")};try{if(typeof Be.stdin.setRawMode==="function")Be.stdin.setRawMode(!0)}catch{}Be.stdin.resume(),Be.stdin.once("data",i)})}setFancy(e){this.fancy=e}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start(e,...t){if(!this.enabled)return;let i=e;if(t&&t.length>0){let s=/%([sdijfo%])/g,l=0;if(i=e.replace(s,(a,f)=>{if(f==="%")return"%";if(l>=t.length)return a;let u=t[l++];switch(f){case"s":return String(u);case"d":case"i":return Number(u).toString();case"j":case"o":return JSON.stringify(u,null,2);default:return a}}),l<t.length)i+=` ${t.slice(l).map((a)=>typeof a==="object"?JSON.stringify(a,null,2):String(a)).join(" ")}`}let{consoleText:r,fileText:n}=this.buildOutputTexts(i);if(this.shouldStyleConsole()){let s=this.options.showTags!==!1&&this.name?Pe.gray(this.formatTag(this.name)):"",l=this.options.showIcons===!1?"":`${Pe.blue("\u25D0")} `;console.error(`${l}${s} ${Pe.cyan(r)}`)}let o=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${n}
210
210
  `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(o)}renderProgressBar(e,t=!1){if(!this.enabled||!this.shouldStyleConsole()||!Be.stdout.isTTY)return;let i=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),r=Math.round(e.barLength*i/100),n=e.barLength-r,o=Pe.green("\u2501".repeat(r)),s=Pe.gray("\u2501".repeat(n)),l=`[${o}${s}]`,a=`${i}%`.padStart(4),f=e.message?` ${e.message}`:"",u=this.options.showIcons===!1?"":t||i===100?Pe.green("\u2713"):Pe.blue("\u25B6"),d=this.options.showTags!==!1&&this.name?` ${Pe.gray(this.formatTag(this.name))}`:"",h=`\r${u}${d} ${l} ${a}${f}`,p=Be.stdout.columns||80,m=" ".repeat(Math.max(0,p-h.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${h}${m}`,Be.stdout.write(e.lastRenderedLine),t)Be.stdout.write(`
211
- `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||rt()||!Be.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(t)e.message=t;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if(rt()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await zn(this.config.logDirectory),i=[];for(let r of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(r):r.startsWith(this.name))||!r.endsWith(".log"))continue;let n=Ji(this.config.logDirectory,r);if(e.before)try{if((await qi(n)).mtime>=e.before)continue}catch(o){console.error(`Failed to get stats for file ${n}:`,o);continue}i.push(n)}if(i.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${i.length} log file(s)...`);for(let r of i)try{await Kn(r),console.warn(`Deleted log file: ${r}`)}catch(n){console.error(`Failed to delete log file ${r}:`,n)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}async function ty(e,t={}){let{maxRetries:i=3,retryDelay:r=1000,isRetryable:n=()=>!0,fallback:o}=t,s=Error("Unknown error occurred");for(let l=0;l<=i;l++)try{return await e()}catch(a){if(s=a instanceof Error?a:Error(String(a)),l===i||!n(s))break;if(r>0)await new Promise((f)=>setTimeout(f,r))}if(o!==void 0)return o;throw s instanceof Error?s:Error(`Unknown error: ${String(s)}`)}class Sa{defaultParsers;constructor(){this.defaultParsers=[{name:"boolean",canParse:(e,t)=>t==="boolean"||["true","false","1","0","yes","no"].includes(e.toLowerCase()),parse:(e)=>{let t=e.toLowerCase();return["true","1","yes"].includes(t)}},{name:"number",canParse:(e,t)=>t==="number"||!Number.isNaN(Number(e))&&!Number.isNaN(Number.parseFloat(e)),parse:(e)=>{let t=Number(e);if(Number.isNaN(t))throw TypeError(`Cannot parse "${e}" as number`);return t}},{name:"array",canParse:(e,t)=>t==="array"||e.startsWith("[")||e.includes(","),parse:(e)=>{try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return e.split(",").map((t)=>t.trim())}},{name:"json",canParse:(e,t)=>t==="object"||(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]")),parse:(e)=>{try{return JSON.parse(e)}catch(t){throw Error(`Cannot parse "${e}" as JSON: ${t}`)}}}]}async applyEnvironmentVariables(e,t,i={}){let{prefix:r,useCamelCase:n=!0,useBackwardCompatibility:o=!0,customParsers:s={},verbose:l=!1,trackPerformance:a=!0}=i,f=async()=>{if(!e)return{config:t,source:{type:"environment",priority:50,timestamp:new Date}};let u=r||this.generateEnvPrefix(e),d={...t};return this.processObject(d,[],u,{useCamelCase:n,useBackwardCompatibility:o,customParsers:s,verbose:l,configName:e}),{config:d,source:{type:"environment",priority:50,timestamp:new Date}}};if(a)return ga.track("applyEnvironmentVariables",f,{configName:e});return f()}generateEnvPrefix(e){return e.toUpperCase().replace(/-/g,"_")}formatEnvKey(e,t){if(!t)return e.toUpperCase();return e.replace(/([A-Z])/g,"_$1").toUpperCase()}processObject(e,t,i,r){for(let[n,o]of Object.entries(e)){let s=[...t,n],l=s.map((u)=>this.formatEnvKey(u,r.useCamelCase)),a=`${i}_${l.join("_")}`,f=r.useBackwardCompatibility?`${i}_${s.map((u)=>u.toUpperCase()).join("_")}`:null;if(r.verbose);if(typeof o==="object"&&o!==null&&!Array.isArray(o))this.processObject(o,s,i,r);else{let u=Hn.env[a]||(f?Hn.env[f]:void 0);if(u!==void 0){if(r.verbose){let d=Hn.env[a]?a:f}try{e[n]=this.parseEnvironmentValue(u,typeof o,a,r.customParsers,r.configName)}catch(d){if(d instanceof xa)throw d;throw ai.envVar(a,u,typeof o,r.configName)}}}}}parseEnvironmentValue(e,t,i,r,n){for(let[o,s]of Object.entries(r))try{return s(e)}catch{continue}for(let o of this.defaultParsers)if(o.canParse(e,t))try{return o.parse(e)}catch{throw ai.envVar(i,e,`${t} (via ${o.name} parser)`,n)}return e}getEnvironmentVariables(e){let t={},i=e.toUpperCase();for(let[r,n]of Object.entries(Hn.env))if(r.startsWith(i)&&n!==void 0)t[r]=n;return t}validateEnvironmentVariable(e,t,i){let r=[];if(!/^[A-Z_][A-Z0-9_]*$/.test(e))r.push(`Environment variable key "${e}" should only contain uppercase letters, numbers, and underscores`);if(i)try{this.parseEnvironmentValue(e,t,i,{})}catch(n){r.push(`Cannot parse value "${t}" as ${i}: ${n}`)}return{isValid:r.length===0,errors:r}}generateEnvVarDocs(e,t,i={}){let{prefix:r,format:n="text"}=i,o=r||this.generateEnvPrefix(e),s=[];switch(this.extractEnvVarInfo(t,[],o,s),n){case"markdown":return this.formatAsMarkdown(s,e);case"json":return JSON.stringify(s,null,2);default:return this.formatAsText(s,e)}}extractEnvVarInfo(e,t,i,r){for(let[n,o]of Object.entries(e)){let s=[...t,n],l=`${i}_${s.map((a)=>this.formatEnvKey(a,!0)).join("_")}`;if(typeof o==="object"&&o!==null&&!Array.isArray(o))this.extractEnvVarInfo(o,s,i,r);else r.push({key:l,type:Array.isArray(o)?"array":typeof o,description:`Configuration for ${s.join(".")}`,example:this.generateExample(o)})}}generateExample(e){if(Array.isArray(e))return JSON.stringify(e);if(typeof e==="object"&&e!==null)return JSON.stringify(e);return String(e)}formatAsText(e,t){let i=`Environment Variables for ${t}:
211
+ `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||rt()||!Be.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(t)e.message=t;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if(rt()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await Hn(this.config.logDirectory),i=[];for(let r of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(r):r.startsWith(this.name))||!r.endsWith(".log"))continue;let n=Yi(this.config.logDirectory,r);if(e.before)try{if((await Ji(n)).mtime>=e.before)continue}catch(o){console.error(`Failed to get stats for file ${n}:`,o);continue}i.push(n)}if(i.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${i.length} log file(s)...`);for(let r of i)try{await qn(r),console.warn(`Deleted log file: ${r}`)}catch(n){console.error(`Failed to delete log file ${r}:`,n)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}async function ny(e,t={}){let{maxRetries:i=3,retryDelay:r=1000,isRetryable:n=()=>!0,fallback:o}=t,s=Error("Unknown error occurred");for(let l=0;l<=i;l++)try{return await e()}catch(a){if(s=a instanceof Error?a:Error(String(a)),l===i||!n(s))break;if(r>0)await new Promise((f)=>setTimeout(f,r))}if(o!==void 0)return o;throw s instanceof Error?s:Error(`Unknown error: ${String(s)}`)}class Aa{defaultParsers;constructor(){this.defaultParsers=[{name:"boolean",canParse:(e,t)=>t==="boolean"||["true","false","1","0","yes","no"].includes(e.toLowerCase()),parse:(e)=>{let t=e.toLowerCase();return["true","1","yes"].includes(t)}},{name:"number",canParse:(e,t)=>t==="number"||!Number.isNaN(Number(e))&&!Number.isNaN(Number.parseFloat(e)),parse:(e)=>{let t=Number(e);if(Number.isNaN(t))throw TypeError(`Cannot parse "${e}" as number`);return t}},{name:"array",canParse:(e,t)=>t==="array"||e.startsWith("[")||e.includes(","),parse:(e)=>{try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return e.split(",").map((t)=>t.trim())}},{name:"json",canParse:(e,t)=>t==="object"||(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]")),parse:(e)=>{try{return JSON.parse(e)}catch(t){throw Error(`Cannot parse "${e}" as JSON: ${t}`)}}}]}async applyEnvironmentVariables(e,t,i={}){let{prefix:r,useCamelCase:n=!0,useBackwardCompatibility:o=!0,customParsers:s={},verbose:l=!1,trackPerformance:a=!0}=i,f=async()=>{if(!e)return{config:t,source:{type:"environment",priority:50,timestamp:new Date}};let u=r||this.generateEnvPrefix(e),d={...t};return this.processObject(d,[],u,{useCamelCase:n,useBackwardCompatibility:o,customParsers:s,verbose:l,configName:e}),{config:d,source:{type:"environment",priority:50,timestamp:new Date}}};if(a)return ya.track("applyEnvironmentVariables",f,{configName:e});return f()}generateEnvPrefix(e){return e.toUpperCase().replace(/-/g,"_")}formatEnvKey(e,t){if(!t)return e.toUpperCase();return e.replace(/([A-Z])/g,"_$1").toUpperCase()}processObject(e,t,i,r){for(let[n,o]of Object.entries(e)){let s=[...t,n],l=s.map((u)=>this.formatEnvKey(u,r.useCamelCase)),a=`${i}_${l.join("_")}`,f=r.useBackwardCompatibility?`${i}_${s.map((u)=>u.toUpperCase()).join("_")}`:null;if(r.verbose);if(typeof o==="object"&&o!==null&&!Array.isArray(o))this.processObject(o,s,i,r);else{let u=Jn.env[a]||(f?Jn.env[f]:void 0);if(u!==void 0){if(r.verbose){let d=Jn.env[a]?a:f}try{e[n]=this.parseEnvironmentValue(u,typeof o,a,r.customParsers,r.configName)}catch(d){if(d instanceof Sa)throw d;throw ai.envVar(a,u,typeof o,r.configName)}}}}}parseEnvironmentValue(e,t,i,r,n){for(let[o,s]of Object.entries(r))try{return s(e)}catch{continue}for(let o of this.defaultParsers)if(o.canParse(e,t))try{return o.parse(e)}catch{throw ai.envVar(i,e,`${t} (via ${o.name} parser)`,n)}return e}getEnvironmentVariables(e){let t={},i=e.toUpperCase();for(let[r,n]of Object.entries(Jn.env))if(r.startsWith(i)&&n!==void 0)t[r]=n;return t}validateEnvironmentVariable(e,t,i){let r=[];if(!/^[A-Z_][A-Z0-9_]*$/.test(e))r.push(`Environment variable key "${e}" should only contain uppercase letters, numbers, and underscores`);if(i)try{this.parseEnvironmentValue(e,t,i,{})}catch(n){r.push(`Cannot parse value "${t}" as ${i}: ${n}`)}return{isValid:r.length===0,errors:r}}generateEnvVarDocs(e,t,i={}){let{prefix:r,format:n="text"}=i,o=r||this.generateEnvPrefix(e),s=[];switch(this.extractEnvVarInfo(t,[],o,s),n){case"markdown":return this.formatAsMarkdown(s,e);case"json":return JSON.stringify(s,null,2);default:return this.formatAsText(s,e)}}extractEnvVarInfo(e,t,i,r){for(let[n,o]of Object.entries(e)){let s=[...t,n],l=`${i}_${s.map((a)=>this.formatEnvKey(a,!0)).join("_")}`;if(typeof o==="object"&&o!==null&&!Array.isArray(o))this.extractEnvVarInfo(o,s,i,r);else r.push({key:l,type:Array.isArray(o)?"array":typeof o,description:`Configuration for ${s.join(".")}`,example:this.generateExample(o)})}}generateExample(e){if(Array.isArray(e))return JSON.stringify(e);if(typeof e==="object"&&e!==null)return JSON.stringify(e);return String(e)}formatAsText(e,t){let i=`Environment Variables for ${t}:
212
212
 
213
213
  `;for(let r of e)i+=`${r.key}
214
214
  `,i+=` Type: ${r.type}
@@ -220,76 +220,76 @@ export type ConfigOf = Config
220
220
  `;i+=`| Variable | Type | Description | Example |
221
221
  `,i+=`|----------|------|-------------|----------|
222
222
  `;for(let r of e)i+=`| \`${r.key}\` | ${r.type} | ${r.description} | \`${r.example}\` |
223
- `;return i}}function gu(e){return e instanceof Error&&"code"in e&&(e.code==="ENOENT"||e.code==="ENOTDIR")}async function yu(e){let t=Nm(e),i=Jn.get(t),r,n=new Promise((o)=>{r=o});Jn.set(t,n),await i;try{if(Im(t),Wf.cache[t]?.loaded===!0||ra.has(t))delete Wf.cache[t];try{let o=await import(Wm(t).href);return ra.delete(t),o}catch(o){throw ra.add(t),o}}finally{if(r(),Jn.get(t)===n)Jn.delete(t)}}function iy(e,t,i={}){return wu(e,t,i,new WeakMap)}function wu(e,t,i,r){let{arrayMergeMode:n="replace",skipNullish:o=!1,customMerger:s}=i;if(t===null||t===void 0)return o?e:t;if(s){let l=s(e,t);if(l!==void 0)return l}if(Array.isArray(t)||Array.isArray(e))return Cu(e,t,n,r);if(!Tt(t)||!Tt(e))return t;return sy(e,t,i,r)}function Cu(e,t,i,r){if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(e)&&!Array.isArray(t))return t;if(Array.isArray(t)&&Array.isArray(e))switch(i){case"replace":return t;case"concat":return ry(e,t);case"smart":return ny(e,t,r);default:return t}return t}function ry(e,t){let i=[...t];for(let r of e)if(!i.some((n)=>ma(n,r)))i.push(r);return i}function ny(e,t,i){if(t.length===0)return e;if(e.length===0)return t;if(Tt(t[0])&&Tt(e[0]))return oy(e,t,i);if(t.every((r)=>typeof r==="string")&&e.every((r)=>typeof r==="string")){let r=[...t];for(let n of e)if(!r.includes(n))r.push(n);return r}return t}function oy(e,t,i){let r=[...t];for(let n of e){if(!Tt(n)){r.push(n);continue}let o=["id","name","key","path","type"],s=!1;for(let l of o)if(l in n){if(r.find((a)=>Tt(a)&&(l in a)&&a[l]===n[l])){s=!0;break}}if(!s)r.push(n)}return r}function sy(e,t,i,r){let n=t;if(Tt(n)&&r.has(n))return r.get(n);let o={...e};if(Tt(n))r.set(n,o);for(let s in n){if(!Object.prototype.hasOwnProperty.call(n,s))continue;let l=n[s],a=o[s];if(i.skipNullish&&(l===null||l===void 0))continue;if(l===null||l===void 0){o[s]=l;continue}if(Tt(l)&&Tt(a))o[s]=wu(a,l,i,r);else if(Array.isArray(l)||Array.isArray(a))o[s]=Cu(a,l,i.arrayMergeMode||"smart",r);else o[s]=l}return o}function vu(e,t,i="replace"){return iy(e,t,{arrayMergeMode:i==="replace"?"replace":"smart",skipNullish:!0})}function ma(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!ma(e[i],t[i]))return!1;return!0}if(Tt(e)&&Tt(t)){let i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(let n of i){if(!Object.prototype.hasOwnProperty.call(t,n))return!1;if(!ma(e[n],t[n]))return!1}return!0}return!1}function Tt(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class bu{extensions=Gf;async loadFromPath(e,t,i={}){let{arrayStrategy:r="replace",useCache:n=!0,cacheTtl:o,trackPerformance:s=!0,verbose:l=!1,strictDiscovery:a=!1}=i;if(n){let u=oo.getWithFileCheck("file",e);if(u){if(l)console.log(`Configuration loaded from cache: ${e}`);return u}}let f=async()=>{try{try{Lm(e)}catch(c){if(gu(c)||!a)return null;throw c}let u=await yu(e),d=Object.hasOwn(u,"default"),h=Object.keys(u).length>0,p=d?u.default:u;if(!d&&!h)throw new Xi(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof p!=="object"||p===null||Array.isArray(p))throw new Xi(e,Error("Configuration must export a valid object"),"unknown");let m={config:vu(t,p,r),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(n)oo.setWithFileCheck("file",m,e,o);return m}catch(u){throw u instanceof Error?ai.configLoad(e,u):ai.configLoad(e,Error(String(u)))}};if(s)return ga.track("loadFromPath",f,{path:e});return f()}async tryLoadFromPaths(e,t,i={}){for(let r of e)try{let n=await this.loadFromPath(r,t,i);if(n)return n}catch(n){if(n instanceof Xi)throw n;if(i.verbose)console.warn(`Failed to load config from ${r}:`,n)}return null}generateConfigPaths(e,t,i){return _m({name:e,directory:t,alias:i})}generateNamePatterns(e,t){return Vf({name:e,alias:t})}checkFileAccess(e){return ty(async()=>Xs(e),{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,t,i){let r=[];if(!Xs(e))return r;if(t||i){let n=this.generateNamePatterns(t||"",i);for(let o of n)for(let s of this.extensions){let l=Ef(e,`${o}${s}`);if(await this.checkFileAccess(l))r.push(l)}}else try{let{readdirSync:n}=await import("fs"),o=n(e);for(let s of o)if(this.looksLikeConfigFile(s)){let l=Ef(e,s);if(await this.checkFileAccess(l))r.push(l)}}catch{return[]}return r}looksLikeConfigFile(e){return[/\.config\.(ts|js|mjs|cjs|json|mts|cts)$/,/^\..*\.(ts|js|mjs|cjs|json|mts|cts)$/,/config\.(ts|js|mjs|cjs|json|mts|cts)$/].some((t)=>t.test(e))}async validateConfigFile(e){let t=[];try{if(!Xs(e))return t.push("Configuration file does not exist"),t;let i=await import(e),r=i.default||i;if(r===void 0)t.push("Configuration file must export a default value or named exports");else if(typeof r!=="object"||r===null)t.push("Configuration must be an object");else if(Array.isArray(r))t.push("Configuration cannot be an array at the root level");if(e.endsWith(".json"))try{let{readFileSync:n}=await import("fs"),o=n(e,"utf8");JSON.parse(o)}catch(n){t.push(`Invalid JSON syntax: ${n}`)}}catch(i){t.push(`Failed to load configuration file: ${i}`)}return t}async getFileModificationTime(e){try{let{statSync:t}=await import("fs");return t(e).mtime}catch{return null}}async preloadConfigurations(e,t={}){let i=new Map;return await Promise.allSettled(e.map(async(r)=>{try{let n=await this.loadFromPath(r,{},t);if(n)i.set(r,n.config)}catch(n){if(t.verbose)console.warn(`Failed to preload ${r}:`,n)}})),i}}class $u{async validateConfiguration(e,t,i={}){let{stopOnFirstError:r=!1,validateRequired:n=!0,validateTypes:o=!0,customRules:s=[],trackPerformance:l=!0,verbose:a=!1}=i,f=async()=>{let u=[],d=[],h={stopOnFirstError:r,validateRequired:n,validateTypes:o,customRules:s,trackPerformance:l,verbose:a};try{if(typeof t==="string")return await this.validateWithSchemaFile(e,t,h);else if(Array.isArray(t))return this.validateWithRules(e,[...t,...s],h);else return this.validateWithJSONSchema(e,t,h)}catch(p){return u.push({path:"",message:`Validation failed: ${p}`,rule:"system"}),{isValid:!1,errors:u,warnings:d}}};if(l)return await ga.track("validateConfiguration",f);return f()}async validateWithSchemaFile(e,t,i){try{if(!Bm(t))throw new po(t,[{path:"",message:"Schema file does not exist"}]);let r=await yu(t),n=Object.hasOwn(r,"default")?r.default:r;if(Array.isArray(n))return this.validateWithRules(e,n,i);else{if(typeof n!=="object"||n===null)throw Error("Schema must export an object or validation rule array");return this.validateWithJSONSchema(e,n,i)}}catch(r){throw new po(t,[{path:"",message:`Failed to load schema: ${r}`}])}}validateWithJSONSchema(e,t,i){let r=[],n=[];return this.validateObjectAgainstSchema(e,t,"",r,n,i),{isValid:r.length===0,errors:r,warnings:n}}validateObjectAgainstSchema(e,t,i,r,n,o){if(o.validateTypes&&t.type){let s=Array.isArray(e)?"array":typeof e,l=Array.isArray(t.type)?t.type:[t.type];if(!l.includes(s)){if(r.push({path:i,message:`Expected type ${l.join(" or ")}, got ${s}`,expected:l.join(" or "),actual:s,rule:"type"}),o.stopOnFirstError)return}}if(t.enum&&!t.enum.includes(e)){if(r.push({path:i,message:`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"}),o.stopOnFirstError)return}if(typeof e==="string"){if(t.minLength!==void 0&&e.length<t.minLength)r.push({path:i,message:`String length must be at least ${t.minLength}`,expected:`>= ${t.minLength}`,actual:e.length,rule:"minLength"});if(t.maxLength!==void 0&&e.length>t.maxLength)r.push({path:i,message:`String length must not exceed ${t.maxLength}`,expected:`<= ${t.maxLength}`,actual:e.length,rule:"maxLength"});if(t.pattern){if(!new RegExp(t.pattern).test(e))r.push({path:i,message:`String does not match pattern ${t.pattern}`,expected:t.pattern,actual:e,rule:"pattern"})}}if(typeof e==="number"){if(t.minimum!==void 0&&e<t.minimum)r.push({path:i,message:`Value must be at least ${t.minimum}`,expected:`>= ${t.minimum}`,actual:e,rule:"minimum"});if(t.maximum!==void 0&&e>t.maximum)r.push({path:i,message:`Value must not exceed ${t.maximum}`,expected:`<= ${t.maximum}`,actual:e,rule:"maximum"})}if(Array.isArray(e)&&t.items)for(let s=0;s<e.length;s++){let l=i?`${i}[${s}]`:`[${s}]`;if(this.validateObjectAgainstSchema(e[s],t.items,l,r,n,o),o.stopOnFirstError&&r.length>0)return}if(e&&typeof e==="object"&&!Array.isArray(e)){let s=e;if(o.validateRequired&&t.required){for(let l of t.required)if(!(l in s)){if(r.push({path:i?`${i}.${l}`:l,message:`Missing required property '${l}'`,expected:"required",rule:"required"}),o.stopOnFirstError)return}}if(t.properties){for(let[l,a]of Object.entries(t.properties))if(l in s){let f=i?`${i}.${l}`:l;if(this.validateObjectAgainstSchema(s[l],a,f,r,n,o),o.stopOnFirstError&&r.length>0)return}}if(t.additionalProperties===!1){let l=new Set(Object.keys(t.properties||{}));for(let a of Object.keys(s))if(!l.has(a))n.push({path:i?`${i}.${a}`:a,message:`Additional property '${a}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(e,t,i){let r=[],n=[];for(let o of t)try{let s=this.getValueByPath(e,o.path),l=this.validateWithRule(s,o,o.path);if(r.push(...l),i.stopOnFirstError&&r.length>0)break}catch(s){r.push({path:o.path,message:`Rule validation failed: ${s}`,rule:"system"})}return{isValid:r.length===0,errors:r,warnings:n}}validateWithRule(e,t,i){let r=[];if(t.required&&(e===void 0||e===null))return r.push({path:i,message:t.message||`Property '${i}' is required`,expected:"required",rule:"required"}),r;if(e===void 0||e===null)return r;if(t.type){let n=Array.isArray(e)?"array":typeof e;if(n!==t.type)r.push({path:i,message:t.message||`Expected type ${t.type}, got ${n}`,expected:t.type,actual:n,rule:"type"})}if(t.min!==void 0){let n=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(n<t.min)r.push({path:i,message:t.message||`Value must be at least ${t.min}`,expected:`>= ${t.min}`,actual:n,rule:"min"})}if(t.max!==void 0){let n=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(n>t.max)r.push({path:i,message:t.message||`Value must not exceed ${t.max}`,expected:`<= ${t.max}`,actual:n,rule:"max"})}if(t.pattern&&typeof e==="string"){if(!t.pattern.test(e))r.push({path:i,message:t.message||`Value does not match pattern ${t.pattern}`,expected:t.pattern.toString(),actual:e,rule:"pattern"})}if(t.enum&&!t.enum.includes(e))r.push({path:i,message:t.message||`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"});if(t.validator){let n=t.validator(e);if(n)r.push({path:i,message:t.message||n,rule:"custom"})}return r}getValueByPath(e,t){if(!t)return e;let i=t.split("."),r=e;for(let n of i)if(r&&typeof r==="object"&&n in r)r=r[n];else return;return r}generateRulesFromInterface(e){let t=[],i=e.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let r of i){let[,n,o,s]=r;t.push({path:n,required:!o,type:this.mapTypeScriptType(s)})}return t}mapTypeScriptType(e){switch(e.toLowerCase()){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"object";default:return"object"}}static createCommonRules(){return{server:[{path:"port",required:!0,type:"number",min:1,max:65535},{path:"host",required:!0,type:"string",min:1},{path:"ssl",type:"boolean"}],database:[{path:"url",required:!0,type:"string",min:1},{path:"pool",type:"number",min:1,max:100},{path:"timeout",type:"number",min:0}],api:[{path:"baseUrl",required:!0,type:"string",pattern:ay},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}function ly(e){if(!e)return"";let t=Array.isArray(e)?e.filter(Boolean):[e];if(t.length===0)return"";if(t.length===1)return` or alias "${t[0]}"`;return` or aliases ${t.map((i)=>`"${i}"`).join(", ")}`}class Eu{fileLoader=new bu;envProcessor=new Sa;validator=new $u;async loadConfig(e){let t=Date.now(),{cache:i,performance:r,schema:n,validate:o,...s}=e,l=s.errorPolicy==="throw"?{...i,enabled:!1}:i;try{if(l?.enabled){let f=this.checkCache(s.name||"",s);if(f)return f}let a;try{a=await this.loadConfigurationStrategies(s,!0,l)}catch(f){if(s.configFile||s.errorPolicy==="throw"&&!(f instanceof Pr))throw f;let u=s.__strictErrorHandling;if(f instanceof Pr){if(u&&s.errorPolicy!=="throw")throw f;a={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`No configuration file found for "${s.name||"config"}", using defaults with environment variables`]}}else if(f instanceof Xi){let d=f.message.includes("EACCES")||f.message.includes("EPERM")||f.message.includes("permission denied"),h=!d&&(f.message.includes("syntax")||f.message.includes("Expected")||f.message.includes("Unexpected")||f.message.includes("BuildMessage")||f.message.includes("errors building")),p=f.message.includes("Configuration must export a valid object")||f.message.includes("Configuration file is empty and exports nothing");if(u&&(p||d))throw f;if(h&&(!u||!p))a={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!u)a={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`Configuration loading error, using defaults: ${f.message}`]};else throw f}else a={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${f instanceof Error?f.message:String(f)}`]}}if(n||o)await this.validateConfiguration(a.config,n,o,s.name);if(l?.enabled&&a)this.cacheResult(s.name||"",a,l,s);if(r?.enabled){let f={operation:"loadConfig",duration:Date.now()-t,configName:s.name,timestamp:new Date};if(r.onMetrics)r.onMetrics(f);if(r.slowThreshold&&f.duration>r.slowThreshold)Jt.warn(`Slow configuration loading detected: ${f.duration}ms for ${s.name}`);a.metrics=f}return a}catch(a){if(a instanceof Pr)throw a;let f=Date.now()-t;throw Jt.error(`Configuration loading failed after ${f}ms:`,[a instanceof Error?a:Error(String(a))]),a}}async loadConfigurationStrategies(e,t=!1,i){let{name:r="",alias:n,configFile:o,cwd:s,configDir:l,defaultConfig:a,checkEnv:f=!0,arrayStrategy:u="replace",verbose:d=!1}=e,h=s||mo.cwd(),p=[];if(o){let b=jt(h,o);p.push(b);let C=f?Tr(r,a,d):a,k=await this.fileLoader.tryLoadFromPaths([b],C,{arrayStrategy:u,verbose:d,cacheTtl:i?.ttl,useCache:i?.enabled!==!1&&(!i?.ttl||i.ttl>100),strictDiscovery:!0});if(!k)throw ai.configNotFound(r||o,p,n);if(d)Jt.success(`Configuration loaded from explicit path: ${b}`);return this.finalizeResult(k,p,f,r,d)}let m=await this.loadLocalConfiguration(r,n,h,l,a,u,d,f,i,e.errorPolicy==="throw");if(m)return p.push(...this.getLocalSearchPaths(r,n,h,l)),this.finalizeResult(m,p,f,r,d);let c=await this.loadHomeConfiguration(r,n,a,u,d,f,i,e.errorPolicy==="throw");if(c)return p.push(...this.getHomeSearchPaths(r,n)),this.finalizeResult(c,p,f,r,d);let v=await this.loadPackageJsonConfiguration(r,n,h,a,u,d,f,e.errorPolicy);if(v)return p.push(jt(h,"package.json")),this.finalizeResult(v,p,f,r,d);if(p.push(...this.getAllSearchPaths(r,n,h,l)),t)throw ai.configNotFound(r,p,n);return{...await this.applyEnvironmentVariables(r,a,f,d),warnings:[`No configuration file found for "${r}"${ly(n)}, using defaults with environment variables`]}}async loadLocalConfiguration(e,t,i,r,n,o,s,l,a,f=!1){let u=l?Tr(e,n,s):n,d=this.getLocalDirectories(i,r);for(let h of d){if(s)Jt.info(`Searching for configuration in: ${h}`);let p=this.fileLoader.generateConfigPaths(e,h,t),m=await this.fileLoader.tryLoadFromPaths(p,u,{arrayStrategy:o,verbose:s,cacheTtl:a?.ttl,useCache:a?.enabled!==!1&&(!a?.ttl||a.ttl>100),strictDiscovery:f});if(m){if(s)Jt.success(`Configuration loaded from: ${m.source.path}`);return m}}return null}async loadHomeConfiguration(e,t,i,r,n,o,s,l=!1){if(!e)return null;let a=o?Tr(e,i,n):i,f=[jt(_i(),".config",e),jt(_i(),".config"),_i()];for(let u of f){if(n)Jt.info(`Checking home directory: ${u}`);let d=this.fileLoader.generateConfigPaths(e,u,t),h=await this.fileLoader.tryLoadFromPaths(d,a,{arrayStrategy:r,verbose:n,cacheTtl:s?.ttl,useCache:s?.enabled!==!1&&(!s?.ttl||s.ttl>100),strictDiscovery:l});if(h){if(n)Jt.success(`Configuration loaded from home directory: ${h.source.path}`);return h}}return null}async loadPackageJsonConfiguration(e,t,i,r,n,o,s,l){let a=s?Tr(e,r,o):r,f=jt(i,"package.json"),u=l==="throw";try{let d=JSON.parse(Jp(f,"utf8"));if(typeof d!=="object"||d===null||Array.isArray(d))throw Error("package.json must contain an object");let h=d,p=t===void 0?[]:Array.isArray(t)?t:[t],m=[e,...p.filter(Boolean)].find((v)=>Object.hasOwn(h,v)&&(u||Boolean(h[v])));if(m===void 0)return null;let c=h[m];if(typeof c!=="object"||c===null||Array.isArray(c))throw Error(`Configuration field "${m}" must contain an object`);if(o)Jt.success(`Configuration loaded from package.json: ${m}`);return{config:vu(a,c,n),source:{type:"package.json",path:f,priority:30,timestamp:new Date}}}catch(d){if(gu(d))return null;if(u)throw ai.configLoad(f,d instanceof Error?d:Error(String(d)));if(o)Jt.warn("Failed to load package.json:",[d instanceof Error?d:Error(String(d))]);return null}}async applyEnvironmentVariables(e,t,i,r){if(!i||!e||typeof t!=="object"||t===null||Array.isArray(t))return{config:t,source:{type:"default",priority:10,timestamp:new Date}};return{config:Tr(e,t,r),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(e,t,i,r,n){return{config:e.config,source:e.source,path:e.source.path}}async validateConfiguration(e,t,i,r){let n=[];if(i){let o=i(e);if(o)n.push(...o)}if(t){let o=await this.validator.validateConfiguration(e,t);if(!o.isValid)n.push(...o.errors.map((s)=>s.path?`${s.path}: ${s.message}`:s.message))}if(n.length>0)throw ai.configValidation(r||"unknown",n,r)}checkCache(e,t){let i=this.generateCacheKey(e,t);return oo.get(i)||null}cacheResult(e,t,i,r){let n=this.generateCacheKey(e,r);oo.set(n,t,void 0,i.ttl)}generateCacheKey(e,t){let i=[e];if(t.alias){let r=Array.isArray(t.alias)?t.alias.join(","):t.alias;i.push(`alias:${r}`)}if(t.cwd)i.push(`cwd:${t.cwd}`);if(t.configFile)i.push(`configFile:${t.configFile}`);if(t.configDir)i.push(`configDir:${t.configDir}`);if("checkEnv"in t)i.push(`checkEnv:${t.checkEnv}`);return i.join("|")}getLocalDirectories(e,t){return jm({cwd:e,configDir:t})}getAllSearchPaths(e,t,i,r){let n=[];return n.push(...this.getLocalSearchPaths(e,t,i,r)),n.push(...this.getHomeSearchPaths(e,t)),n.push(jt(i,"package.json")),n}getLocalSearchPaths(e,t,i,r){let n=this.getLocalDirectories(i,r),o=[];for(let s of n)o.push(...this.fileLoader.generateConfigPaths(e,s,t));return o}getHomeSearchPaths(e,t){if(!e)return[];let i=[jt(_i(),".config",e),jt(_i(),".config"),_i()],r=[];for(let n of i)r.push(...this.fileLoader.generateConfigPaths(e,n,t));return r}async loadConfigWithResult(e){return this.loadConfig(e)}}function Tr(e,t,i=!1){let r=new Sa,n=e.toUpperCase().replace(/[^A-Z0-9]/g,"_");function o(s,l=[]){let a={...s};for(let[f,u]of Object.entries(s)){let d=[...l,f],h=[`${n}_${d.join("_").toUpperCase()}`,`${n}_${d.map((c)=>c.toUpperCase()).join("")}`,`${n}_${d.map((c)=>c.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],p,m;for(let c of h)if(p=mo.env[c],p!==void 0){m=c;break}if(p!==void 0&&m)if(typeof u==="boolean")a[f]=["true","1","yes"].includes(p.toLowerCase());else if(typeof u==="number"){let c=Number(p);if(!Number.isNaN(c))a[f]=c}else if(Array.isArray(u))try{a[f]=JSON.parse(p)}catch{a[f]=p.split(",").map((c)=>c.trim())}else a[f]=p;else if(u&&typeof u==="object"&&!Array.isArray(u))a[f]=o(u,d)}return a}return o(t)}var oo,ga,Gf,Gm,Vm=(e)=>e,zm=(e,t)=>{for(var i in t)Gm(e,i,{get:t[i],enumerable:!0,configurable:!0,set:Um.bind(t,i)})},Km=(e,t)=>()=>(e&&(t=e(e=0)),t),Uf,Qf,Zi,Nr,eu,Cg,vg,Sf,Xn,aa,at,Ue,bg,Af,$g,kf,Eg,xg,Zs,Sg,Tf,Of,Qs,Ag,kg,Tg,Og,Zn,tu,Rg,lt,Pg,Mg,Rf,Qn,la,it,Oe,Dg,Pf,Ig,Mf,Ng,Fg,ea,Wg,Df,If,Lg,ta,Bg,_g,jg,Gg,Vg,eo,iu,Ug,zg="0.15.6",$t,fo,Dr,ca,fa,uo,ua,da,Ir,ha,pa,li,ru,nu,It,Qt,ou,su,Kg,qg,au,ho,yv,cu,Pe,wv,Yg,Cv,Xg,vv,bv,Nf,$v,Zg,Qg,Ev,Ff,xv,Sv,Av,kv,Tv,ia,ey,Ov,Nt,Pr,Xi,fu,uu,xa,du,hu,po,pu,mu,ai,Wf,Jn,ra,ay,Jt,Rv,Pv,Mv,cy,xu;var Su=me(()=>{oo=new _f,ga=new jf,Gf=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];Gm=Object.defineProperty;Uf={};zm(Uf,{withErrorRecovery:()=>Hf,tryLoadConfig:()=>mg,loadConfigWithResult:()=>hg,loadConfig:()=>Zf,isRetryableError:()=>ag,isConfigNotFoundError:()=>sg,isBunfigError:()=>qf,globalPerformanceMonitor:()=>Nr,globalCache:()=>Zi,getEnvOrDefault:()=>lg,generateConfigTypes:()=>gg,defaultGeneratedDir:()=>su,defaultConfigDir:()=>ou,deepMergeWithArrayStrategy:()=>ba,deepMerge:()=>Jf,createLibraryConfig:()=>yg,config:()=>pg,bunfigPlugin:()=>wg,applyEnvVarsToConfig:()=>Rr,TypeGenerationError:()=>da,SchemaValidationError:()=>Ir,PluginError:()=>pa,PerformanceMonitor:()=>wa,FileSystemError:()=>ua,ErrorFactory:()=>li,EnvVarError:()=>uo,EnvProcessor:()=>go,ConfigValidator:()=>$a,ConfigValidationError:()=>ca,ConfigNotFoundError:()=>fo,ConfigMergeError:()=>fa,ConfigLoader:()=>Ea,ConfigLoadError:()=>Dr,ConfigFileLoader:()=>yo,ConfigCache:()=>ya,CacheUtils:()=>eu,BunfigError:()=>$t,BrowserConfigError:()=>ha,ArrayMergeStrategies:()=>ru});Kg=Km(async()=>{Qf=import.meta.require,Zi=new ya,Nr=new wa,eu={createKey:Hm,isEquivalent:qm,estimateMemoryUsage:Jm},Cg=ro(oa.cwd(),"config"),vg=ro(oa.cwd(),"src/generated"),Sf=io.env.CLARITY_LOG_DIR||tm(Zm(),"logs"),Xn={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:Sf,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1},aa=await Qm(),at={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,reset:"\x1B[0m"},Ue=at,bg=at.red,Af=at.green,$g=at.yellow,kf=at.blue,Eg=at.magenta,xg=at.cyan,Zs=at.white,Sg=at.gray,Tf=at.bgRed,Of=at.bgYellow,Qs=at.bold,Ag=at.dim,kg=at.italic,Tg=at.underline,Og=at.reset,Zn={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},tu={debug:"\uD83D\uDD0D",info:kf("\u2139"),success:Af("\u2713"),warning:Of(Zs(Qs(" WARN "))),error:Tf(Zs(Qs(" ERROR ")))},Rg=new ao("stacks"),lt=new ao("bunfig",{showTags:!0}),Pg=mt(Mr.cwd(),"config"),Mg=mt(Mr.cwd(),"src/generated"),Rf=to.env.CLARITY_LOG_DIR||Qp(rg(),"logs"),Qn={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:Rf,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},la=await ng(),it={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bgGray:(e)=>`\x1B[100m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,strikethrough:(e)=>`\x1B[9m${e}\x1B[0m`,reset:"\x1B[0m"},Oe=it,Dg=it.red,Pf=it.green,Ig=it.yellow,Mf=it.blue,Ng=it.magenta,Fg=it.cyan,ea=it.white,Wg=it.gray,Df=it.bgRed,If=it.bgYellow,Lg=it.bgGray,ta=it.bold,Bg=it.dim,_g=it.italic,jg=it.underline,Gg=it.strikethrough,Vg=it.reset,eo={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},iu={debug:"\uD83D\uDD0D",info:Mf("\u2139"),success:Pf("\u2713"),warning:If(ea(ta(" WARN "))),error:Df(ea(ta(" ERROR ")))},Ug=new co("stacks"),$t=class extends Error{timestamp;context;constructor(e,t={}){super(e);if(this.name=this.constructor.name,this.timestamp=new Date,this.context=t,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,timestamp:this.timestamp.toISOString(),context:this.context,stack:this.stack}}toString(){let e=Object.keys(this.context).length>0?` (${Object.entries(this.context).map(([t,i])=>`${t}: ${i}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${e}`}},fo=class extends $t{code="CONFIG_NOT_FOUND";constructor(e,t,i){let r=i?` or alias "${i}"`:"";super(`Configuration "${e}"${r} not found`,{configName:e,alias:i,searchPaths:t,searchPathCount:t.length})}},Dr=class extends $t{code="CONFIG_LOAD_ERROR";constructor(e,t,i){super(`Failed to load configuration from "${e}": ${t.message}`,{configPath:e,configName:i,originalError:t.name,originalMessage:t.message});this.cause=t}},ca=class extends $t{code="CONFIG_VALIDATION_ERROR";constructor(e,t,i){super(`Configuration validation failed for "${e}"`,{configPath:e,configName:i,validationErrors:t,errorCount:t.length})}},fa=class extends $t{code="CONFIG_MERGE_ERROR";constructor(e,t,i,r){super(`Failed to merge configuration from "${e}" with "${t}": ${i.message}`,{sourcePath:e,targetPath:t,configName:r,originalError:i.name,originalMessage:i.message});this.cause=i}},uo=class extends $t{code="ENV_VAR_ERROR";constructor(e,t,i,r){super(`Failed to parse environment variable "${e}" with value "${t}" as ${i}`,{envKey:e,envValue:t,expectedType:i,configName:r})}},ua=class extends $t{code="FILE_SYSTEM_ERROR";constructor(e,t,i){super(`File system ${e} failed for "${t}": ${i.message}`,{operation:e,path:t,originalError:i.name,originalMessage:i.message});this.cause=i}},da=class extends $t{code="TYPE_GENERATION_ERROR";constructor(e,t,i){super(`Failed to generate types from "${e}" to "${t}": ${i.message}`,{configDir:e,outputPath:t,originalError:i.name,originalMessage:i.message});this.cause=i}},Ir=class extends $t{code="SCHEMA_VALIDATION_ERROR";constructor(e,t,i){super(`Schema validation failed${i?` for config "${i}"`:""}`,{schemaPath:e,configName:i,validationErrors:t,errorCount:t.length})}},ha=class extends $t{code="BROWSER_CONFIG_ERROR";constructor(e,t,i,r){super(`Failed to fetch configuration from "${e}": ${t} ${i}`,{endpoint:e,status:t,statusText:i,configName:r})}},pa=class extends $t{code="PLUGIN_ERROR";constructor(e,t,i){super(`Plugin "${e}" failed during ${t}: ${i.message}`,{pluginName:e,operation:t,originalError:i.name,originalMessage:i.message});this.cause=i}},li={configNotFound(e,t,i){return new fo(e,t,i)},configLoad(e,t,i){return new Dr(e,t,i)},configValidation(e,t,i){return new ca(e,t,i)},configMerge(e,t,i,r){return new fa(e,t,i,r)},envVar(e,t,i,r){return new uo(e,t,i,r)},fileSystem(e,t,i){return new ua(e,t,i)},typeGeneration(e,t,i){return new da(e,t,i)},schemaValidation(e,t,i){return new Ir(e,t,i)},browserConfig(e,t,i,r){return new ha(e,t,i,r)},plugin(e,t,i){return new pa(e,t,i)}},ru={replace:"replace",concat:"concat",smart:"smart"},nu=/^https?:\/\//,It=new co("bunfig",{showTags:!0}),Qt=new Ea,ou=gt(Si.cwd(),"config"),su=gt(Si.cwd(),"src/generated")});qg=no.env.CLARITY_LOG_DIR||Em(Hg(),"logs"),au={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:qg,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},ho={...au},yv=(async()=>{try{let{loadConfig:e}=await Kg().then(()=>Uf),t=await e({name:"clarity",alias:"logging",defaultConfig:au,cwd:no.cwd()});if(t)Object.assign(ho,t)}catch{}return ho})();cu={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bgGray:(e)=>`\x1B[100m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,strikethrough:(e)=>`\x1B[9m${e}\x1B[0m`,reset:"\x1B[0m"},Pe=cu,{red:wv,green:Yg,yellow:Cv,blue:Xg,magenta:vv,cyan:bv,white:Nf,gray:$v,bgRed:Zg,bgYellow:Qg,bgGray:Ev,bold:Ff,dim:xv,italic:Sv,underline:Av,strikethrough:kv,reset:Tv}=cu,ia={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},ey={debug:"\uD83D\uDD0D",info:Xg("\u2139"),success:Yg("\u2713"),warning:Qg(Nf(Ff(" WARN "))),error:Zg(Nf(Ff(" ERROR ")))};Ov=new wo("stacks");Nt=class Nt extends Error{timestamp;context;constructor(e,t={}){super(e);if(this.name=this.constructor.name,this.timestamp=new Date,this.context=t,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,timestamp:this.timestamp.toISOString(),context:this.context,stack:this.stack}}toString(){let e=Object.keys(this.context).length>0?` (${Object.entries(this.context).map(([t,i])=>`${t}: ${i}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${e}`}};Pr=class Pr extends Nt{name="ConfigNotFoundError";code="CONFIG_NOT_FOUND";constructor(e,t,i){let r=i===void 0?[]:Array.isArray(i)?i.filter(Boolean):[i],n="";if(r.length===1)n=` or alias "${r[0]}"`;else if(r.length>1)n=` or aliases ${r.map((o)=>`"${o}"`).join(", ")}`;super(`Configuration "${e}"${n} not found`,{configName:e,alias:i,searchPaths:t,searchPathCount:t.length})}};Xi=class Xi extends Nt{name="ConfigLoadError";code="CONFIG_LOAD_ERROR";constructor(e,t,i){super(`Failed to load configuration from "${e}": ${t.message}`,{configPath:e,configName:i,originalError:t.name,originalMessage:t.message});this.cause=t}};fu=class fu extends Nt{name="ConfigValidationError";code="CONFIG_VALIDATION_ERROR";constructor(e,t,i){super(`Configuration validation failed for "${e}"`,{configPath:e,configName:i,validationErrors:t,errorCount:t.length})}};uu=class uu extends Nt{name="ConfigMergeError";code="CONFIG_MERGE_ERROR";constructor(e,t,i,r){super(`Failed to merge configuration from "${e}" with "${t}": ${i.message}`,{sourcePath:e,targetPath:t,configName:r,originalError:i.name,originalMessage:i.message});this.cause=i}};xa=class xa extends Nt{name="EnvVarError";code="ENV_VAR_ERROR";constructor(e,t,i,r){super(`Failed to parse environment variable "${e}" with value "${t}" as ${i}`,{envKey:e,envValue:t,expectedType:i,configName:r})}};du=class du extends Nt{name="FileSystemError";code="FILE_SYSTEM_ERROR";constructor(e,t,i){super(`File system ${e} failed for "${t}": ${i.message}`,{operation:e,path:t,originalError:i.name,originalMessage:i.message});this.cause=i}};hu=class hu extends Nt{name="TypeGenerationError";code="TYPE_GENERATION_ERROR";constructor(e,t,i){super(`Failed to generate types from "${e}" to "${t}": ${i.message}`,{configDir:e,outputPath:t,originalError:i.name,originalMessage:i.message});this.cause=i}};po=class po extends Nt{name="SchemaValidationError";code="SCHEMA_VALIDATION_ERROR";constructor(e,t,i){super(`Schema validation failed${i?` for config "${i}"`:""}`,{schemaPath:e,configName:i,validationErrors:t,errorCount:t.length})}};pu=class pu extends Nt{name="BrowserConfigError";code="BROWSER_CONFIG_ERROR";constructor(e,t,i,r){super(`Failed to fetch configuration from "${e}": ${t} ${i}`,{endpoint:e,status:t,statusText:i,configName:r})}};mu=class mu extends Nt{name="PluginError";code="PLUGIN_ERROR";constructor(e,t,i){super(`Plugin "${e}" failed during ${t}: ${i.message}`,{pluginName:e,operation:t,originalError:i.name,originalMessage:i.message});this.cause=i}};ai={configNotFound(e,t,i){return new Pr(e,t,i)},configLoad(e,t,i){return new Xi(e,t,i)},configValidation(e,t,i){return new fu(e,t,i)},configMerge(e,t,i,r){return new uu(e,t,i,r)},envVar(e,t,i,r){return new xa(e,t,i,r)},fileSystem(e,t,i){return new du(e,t,i)},typeGeneration(e,t,i){return new hu(e,t,i)},schemaValidation(e,t,i){return new po(e,t,i)},browserConfig(e,t,i,r){return new pu(e,t,i,r)},plugin(e,t,i){return new mu(e,t,i)}};Wf=Fm(import.meta.url),Jn=new Map,ra=new Set;ay=/^https?:\/\//;Jt=new wo("bunfig",{showTags:!0});Rv=new Eu;Pv=jt(mo.cwd(),"config"),Mv=jt(mo.cwd(),"src/generated"),cy={cwd:Hp.cwd(),root:"./src",entrypoints:["**/*.{ts,tsx,mts,cts,vue,stx}"],outdir:"./dist",keepComments:!0,clean:!0,tsconfigPath:"./tsconfig.json",outputStructure:"mirror",moduleSpecifierMode:"preserve",verbose:!1,importOrder:["bun"],declarationMap:!1},xu=cy});import{existsSync as Au}from"fs";import{basename as fy,dirname as uy,extname as ku,isAbsolute as Co,relative as ei,resolve as ti}from"path";async function Ou(e,t){let i=await gy(e);my(e,i);let r=i.slice(),n=await(t?t():In(e)),o=null;if(e.autoIncludeReExports!==!1&&r.length>0){o=await Ar(r,{includeImports:!0,resolveSpecifier:n});let d=ti(e.cwd,e.root),h=e.exclude||[],p=[];for(let m of o.reachable){if(r.includes(m))continue;if(!Aa(m))continue;if(m.endsWith(".d.ts"))continue;if(m.includes("node_modules"))continue;let c=e.outputStructure==="flat"&&i.some((v)=>n.isPackageLocal?.(v,m));if(!Gt(m,d)&&!c){le.warn(`Skipping auto-included source outside root: ${ei(e.cwd,m)}`);continue}if(Wr(m,h,d))continue;p.push(m)}if(p.length>0)r=[...r,...p],le.debug(`Auto-included ${p.length} file(s) reached via relative re-exports`)}let s=yy(r,e),l=o??await Ar(r,{includeImports:!0,resolveSpecifier:n}),a=await Mc([...l.sources.keys()],n,e.isolatedDeclarations??!1,l.sources),f=new Set(r);for(let[d,h]of a){if(!f.has(d))continue;for(let p of h){let m=n(p,d).resolved;if(m&&!f.has(m))throw Error(`Module augmentation import ${JSON.stringify(p)} from ${d} requires a source not emitted by this package build: ${m}`)}}let u=[...a].map(([d,h])=>[d,[...h].sort()]).sort(([d],[h])=>d.localeCompare(h));return Object.freeze({entryFiles:Object.freeze(i),files:Object.freeze(r),outputBySource:s,resolver:n,reachability:o,augmentationImports:a,getResolutionFingerprint:()=>JSON.stringify({resolution:n.cacheKey?.(r),augmentations:u})})}function hy(e){let t=Fr.get(e);if(!t){if(t=new Tu(e),Fr.set(e,t),Fr.size>dy){let i=Fr.keys().next().value;if(i!==void 0)Fr.delete(i)}}return t}function Wr(e,t,i){if(!t||t.length===0)return!1;let r=ei(i,e);for(let n of t){let o=hy(n);if(o.match(r)||o.match(e))return!0}return!1}function my(e,t){let i=ti(e.cwd,e.root),r=` root: ${i}
223
+ `;return i}}function gu(e){return e instanceof Error&&"code"in e&&(e.code==="ENOENT"||e.code==="ENOTDIR")}async function yu(e){let t=Lm(e),i=Xn.get(t),r,n=new Promise((o)=>{r=o});Xn.set(t,n),await i;try{if(Wm(t),Wf.cache[t]?.loaded===!0||na.has(t))delete Wf.cache[t];try{let o=await import(_m(t).href);return na.delete(t),o}catch(o){throw na.add(t),o}}finally{if(r(),Xn.get(t)===n)Xn.delete(t)}}function oy(e,t,i={}){return wu(e,t,i,new WeakMap)}function wu(e,t,i,r){let{arrayMergeMode:n="replace",skipNullish:o=!1,customMerger:s}=i;if(t===null||t===void 0)return o?e:t;if(s){let l=s(e,t);if(l!==void 0)return l}if(Array.isArray(t)||Array.isArray(e))return Cu(e,t,n,r);if(!Tt(t)||!Tt(e))return t;return cy(e,t,i,r)}function Cu(e,t,i,r){if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(e)&&!Array.isArray(t))return t;if(Array.isArray(t)&&Array.isArray(e))switch(i){case"replace":return t;case"concat":return sy(e,t);case"smart":return ay(e,t,r);default:return t}return t}function sy(e,t){let i=[...t];for(let r of e)if(!i.some((n)=>ga(n,r)))i.push(r);return i}function ay(e,t,i){if(t.length===0)return e;if(e.length===0)return t;if(Tt(t[0])&&Tt(e[0]))return ly(e,t,i);if(t.every((r)=>typeof r==="string")&&e.every((r)=>typeof r==="string")){let r=[...t];for(let n of e)if(!r.includes(n))r.push(n);return r}return t}function ly(e,t,i){let r=[...t];for(let n of e){if(!Tt(n)){r.push(n);continue}let o=["id","name","key","path","type"],s=!1;for(let l of o)if(l in n){if(r.find((a)=>Tt(a)&&(l in a)&&a[l]===n[l])){s=!0;break}}if(!s)r.push(n)}return r}function cy(e,t,i,r){let n=t;if(Tt(n)&&r.has(n))return r.get(n);let o={...e};if(Tt(n))r.set(n,o);for(let s in n){if(!Object.prototype.hasOwnProperty.call(n,s))continue;let l=n[s],a=o[s];if(i.skipNullish&&(l===null||l===void 0))continue;if(l===null||l===void 0){o[s]=l;continue}if(Tt(l)&&Tt(a))o[s]=wu(a,l,i,r);else if(Array.isArray(l)||Array.isArray(a))o[s]=Cu(a,l,i.arrayMergeMode||"smart",r);else o[s]=l}return o}function vu(e,t,i="replace"){return oy(e,t,{arrayMergeMode:i==="replace"?"replace":"smart",skipNullish:!0})}function ga(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!ga(e[i],t[i]))return!1;return!0}if(Tt(e)&&Tt(t)){let i=Object.keys(e),r=Object.keys(t);if(i.length!==r.length)return!1;for(let n of i){if(!Object.prototype.hasOwnProperty.call(t,n))return!1;if(!ga(e[n],t[n]))return!1}return!0}return!1}function Tt(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class bu{extensions=Gf;async loadFromPath(e,t,i={}){let{arrayStrategy:r="replace",useCache:n=!0,cacheTtl:o,trackPerformance:s=!0,verbose:l=!1,strictDiscovery:a=!1}=i;if(n){let u=ao.getWithFileCheck("file",e);if(u){if(l)console.log(`Configuration loaded from cache: ${e}`);return u}}let f=async()=>{try{try{jm(e)}catch(c){if(gu(c)||!a)return null;throw c}let u=await yu(e),d=Object.hasOwn(u,"default"),h=Object.keys(u).length>0,p=d?u.default:u;if(!d&&!h)throw new Zi(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof p!=="object"||p===null||Array.isArray(p))throw new Zi(e,Error("Configuration must export a valid object"),"unknown");let m={config:vu(t,p,r),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(n)ao.setWithFileCheck("file",m,e,o);return m}catch(u){throw u instanceof Error?ai.configLoad(e,u):ai.configLoad(e,Error(String(u)))}};if(s)return ya.track("loadFromPath",f,{path:e});return f()}async tryLoadFromPaths(e,t,i={}){for(let r of e)try{let n=await this.loadFromPath(r,t,i);if(n)return n}catch(n){if(n instanceof Zi)throw n;if(i.verbose)console.warn(`Failed to load config from ${r}:`,n)}return null}generateConfigPaths(e,t,i){return Vm({name:e,directory:t,alias:i})}generateNamePatterns(e,t){return Vf({name:e,alias:t})}checkFileAccess(e){return ny(async()=>Zs(e),{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,t,i){let r=[];if(!Zs(e))return r;if(t||i){let n=this.generateNamePatterns(t||"",i);for(let o of n)for(let s of this.extensions){let l=Ef(e,`${o}${s}`);if(await this.checkFileAccess(l))r.push(l)}}else try{let{readdirSync:n}=await import("fs"),o=n(e);for(let s of o)if(this.looksLikeConfigFile(s)){let l=Ef(e,s);if(await this.checkFileAccess(l))r.push(l)}}catch{return[]}return r}looksLikeConfigFile(e){return[/\.config\.(ts|js|mjs|cjs|json|mts|cts)$/,/^\..*\.(ts|js|mjs|cjs|json|mts|cts)$/,/config\.(ts|js|mjs|cjs|json|mts|cts)$/].some((t)=>t.test(e))}async validateConfigFile(e){let t=[];try{if(!Zs(e))return t.push("Configuration file does not exist"),t;let i=await import(e),r=i.default||i;if(r===void 0)t.push("Configuration file must export a default value or named exports");else if(typeof r!=="object"||r===null)t.push("Configuration must be an object");else if(Array.isArray(r))t.push("Configuration cannot be an array at the root level");if(e.endsWith(".json"))try{let{readFileSync:n}=await import("fs"),o=n(e,"utf8");JSON.parse(o)}catch(n){t.push(`Invalid JSON syntax: ${n}`)}}catch(i){t.push(`Failed to load configuration file: ${i}`)}return t}async getFileModificationTime(e){try{let{statSync:t}=await import("fs");return t(e).mtime}catch{return null}}async preloadConfigurations(e,t={}){let i=new Map;return await Promise.allSettled(e.map(async(r)=>{try{let n=await this.loadFromPath(r,{},t);if(n)i.set(r,n.config)}catch(n){if(t.verbose)console.warn(`Failed to preload ${r}:`,n)}})),i}}class $u{async validateConfiguration(e,t,i={}){let{stopOnFirstError:r=!1,validateRequired:n=!0,validateTypes:o=!0,customRules:s=[],trackPerformance:l=!0,verbose:a=!1}=i,f=async()=>{let u=[],d=[],h={stopOnFirstError:r,validateRequired:n,validateTypes:o,customRules:s,trackPerformance:l,verbose:a};try{if(typeof t==="string")return await this.validateWithSchemaFile(e,t,h);else if(Array.isArray(t))return this.validateWithRules(e,[...t,...s],h);else return this.validateWithJSONSchema(e,t,h)}catch(p){return u.push({path:"",message:`Validation failed: ${p}`,rule:"system"}),{isValid:!1,errors:u,warnings:d}}};if(l)return await ya.track("validateConfiguration",f);return f()}async validateWithSchemaFile(e,t,i){try{if(!Gm(t))throw new go(t,[{path:"",message:"Schema file does not exist"}]);let r=await yu(t),n=Object.hasOwn(r,"default")?r.default:r;if(Array.isArray(n))return this.validateWithRules(e,n,i);else{if(typeof n!=="object"||n===null)throw Error("Schema must export an object or validation rule array");return this.validateWithJSONSchema(e,n,i)}}catch(r){throw new go(t,[{path:"",message:`Failed to load schema: ${r}`}])}}validateWithJSONSchema(e,t,i){let r=[],n=[];return this.validateObjectAgainstSchema(e,t,"",r,n,i),{isValid:r.length===0,errors:r,warnings:n}}validateObjectAgainstSchema(e,t,i,r,n,o){if(o.validateTypes&&t.type){let s=Array.isArray(e)?"array":typeof e,l=Array.isArray(t.type)?t.type:[t.type];if(!l.includes(s)){if(r.push({path:i,message:`Expected type ${l.join(" or ")}, got ${s}`,expected:l.join(" or "),actual:s,rule:"type"}),o.stopOnFirstError)return}}if(t.enum&&!t.enum.includes(e)){if(r.push({path:i,message:`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"}),o.stopOnFirstError)return}if(typeof e==="string"){if(t.minLength!==void 0&&e.length<t.minLength)r.push({path:i,message:`String length must be at least ${t.minLength}`,expected:`>= ${t.minLength}`,actual:e.length,rule:"minLength"});if(t.maxLength!==void 0&&e.length>t.maxLength)r.push({path:i,message:`String length must not exceed ${t.maxLength}`,expected:`<= ${t.maxLength}`,actual:e.length,rule:"maxLength"});if(t.pattern){if(!new RegExp(t.pattern).test(e))r.push({path:i,message:`String does not match pattern ${t.pattern}`,expected:t.pattern,actual:e,rule:"pattern"})}}if(typeof e==="number"){if(t.minimum!==void 0&&e<t.minimum)r.push({path:i,message:`Value must be at least ${t.minimum}`,expected:`>= ${t.minimum}`,actual:e,rule:"minimum"});if(t.maximum!==void 0&&e>t.maximum)r.push({path:i,message:`Value must not exceed ${t.maximum}`,expected:`<= ${t.maximum}`,actual:e,rule:"maximum"})}if(Array.isArray(e)&&t.items)for(let s=0;s<e.length;s++){let l=i?`${i}[${s}]`:`[${s}]`;if(this.validateObjectAgainstSchema(e[s],t.items,l,r,n,o),o.stopOnFirstError&&r.length>0)return}if(e&&typeof e==="object"&&!Array.isArray(e)){let s=e;if(o.validateRequired&&t.required){for(let l of t.required)if(!(l in s)){if(r.push({path:i?`${i}.${l}`:l,message:`Missing required property '${l}'`,expected:"required",rule:"required"}),o.stopOnFirstError)return}}if(t.properties){for(let[l,a]of Object.entries(t.properties))if(l in s){let f=i?`${i}.${l}`:l;if(this.validateObjectAgainstSchema(s[l],a,f,r,n,o),o.stopOnFirstError&&r.length>0)return}}if(t.additionalProperties===!1){let l=new Set(Object.keys(t.properties||{}));for(let a of Object.keys(s))if(!l.has(a))n.push({path:i?`${i}.${a}`:a,message:`Additional property '${a}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(e,t,i){let r=[],n=[];for(let o of t)try{let s=this.getValueByPath(e,o.path),l=this.validateWithRule(s,o,o.path);if(r.push(...l),i.stopOnFirstError&&r.length>0)break}catch(s){r.push({path:o.path,message:`Rule validation failed: ${s}`,rule:"system"})}return{isValid:r.length===0,errors:r,warnings:n}}validateWithRule(e,t,i){let r=[];if(t.required&&(e===void 0||e===null))return r.push({path:i,message:t.message||`Property '${i}' is required`,expected:"required",rule:"required"}),r;if(e===void 0||e===null)return r;if(t.type){let n=Array.isArray(e)?"array":typeof e;if(n!==t.type)r.push({path:i,message:t.message||`Expected type ${t.type}, got ${n}`,expected:t.type,actual:n,rule:"type"})}if(t.min!==void 0){let n=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(n<t.min)r.push({path:i,message:t.message||`Value must be at least ${t.min}`,expected:`>= ${t.min}`,actual:n,rule:"min"})}if(t.max!==void 0){let n=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(n>t.max)r.push({path:i,message:t.message||`Value must not exceed ${t.max}`,expected:`<= ${t.max}`,actual:n,rule:"max"})}if(t.pattern&&typeof e==="string"){if(!t.pattern.test(e))r.push({path:i,message:t.message||`Value does not match pattern ${t.pattern}`,expected:t.pattern.toString(),actual:e,rule:"pattern"})}if(t.enum&&!t.enum.includes(e))r.push({path:i,message:t.message||`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"});if(t.validator){let n=t.validator(e);if(n)r.push({path:i,message:t.message||n,rule:"custom"})}return r}getValueByPath(e,t){if(!t)return e;let i=t.split("."),r=e;for(let n of i)if(r&&typeof r==="object"&&n in r)r=r[n];else return;return r}generateRulesFromInterface(e){let t=[],i=e.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let r of i){let[,n,o,s]=r;t.push({path:n,required:!o,type:this.mapTypeScriptType(s)})}return t}mapTypeScriptType(e){switch(e.toLowerCase()){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"object";default:return"object"}}static createCommonRules(){return{server:[{path:"port",required:!0,type:"number",min:1,max:65535},{path:"host",required:!0,type:"string",min:1},{path:"ssl",type:"boolean"}],database:[{path:"url",required:!0,type:"string",min:1},{path:"pool",type:"number",min:1,max:100},{path:"timeout",type:"number",min:0}],api:[{path:"baseUrl",required:!0,type:"string",pattern:fy},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}function uy(e){if(!e)return"";let t=Array.isArray(e)?e.filter(Boolean):[e];if(t.length===0)return"";if(t.length===1)return` or alias "${t[0]}"`;return` or aliases ${t.map((i)=>`"${i}"`).join(", ")}`}class Eu{fileLoader=new bu;envProcessor=new Aa;validator=new $u;async loadConfig(e){let t=Date.now(),{cache:i,performance:r,schema:n,validate:o,...s}=e,l=s.errorPolicy==="throw"?{...i,enabled:!1}:i;try{if(l?.enabled){let f=this.checkCache(s.name||"",s);if(f)return f}let a;try{a=await this.loadConfigurationStrategies(s,!0,l)}catch(f){if(s.configFile||s.errorPolicy==="throw"&&!(f instanceof Pr))throw f;let u=s.__strictErrorHandling;if(f instanceof Pr){if(u&&s.errorPolicy!=="throw")throw f;a={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`No configuration file found for "${s.name||"config"}", using defaults with environment variables`]}}else if(f instanceof Zi){let d=f.message.includes("EACCES")||f.message.includes("EPERM")||f.message.includes("permission denied"),h=!d&&(f.message.includes("syntax")||f.message.includes("Expected")||f.message.includes("Unexpected")||f.message.includes("BuildMessage")||f.message.includes("errors building")),p=f.message.includes("Configuration must export a valid object")||f.message.includes("Configuration file is empty and exports nothing");if(u&&(p||d))throw f;if(h&&(!u||!p))a={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!u)a={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`Configuration loading error, using defaults: ${f.message}`]};else throw f}else a={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${f instanceof Error?f.message:String(f)}`]}}if(n||o)await this.validateConfiguration(a.config,n,o,s.name);if(l?.enabled&&a)this.cacheResult(s.name||"",a,l,s);if(r?.enabled){let f={operation:"loadConfig",duration:Date.now()-t,configName:s.name,timestamp:new Date};if(r.onMetrics)r.onMetrics(f);if(r.slowThreshold&&f.duration>r.slowThreshold)Jt.warn(`Slow configuration loading detected: ${f.duration}ms for ${s.name}`);a.metrics=f}return a}catch(a){if(a instanceof Pr)throw a;let f=Date.now()-t;throw Jt.error(`Configuration loading failed after ${f}ms:`,[a instanceof Error?a:Error(String(a))]),a}}async loadConfigurationStrategies(e,t=!1,i){let{name:r="",alias:n,configFile:o,cwd:s,configDir:l,defaultConfig:a,checkEnv:f=!0,arrayStrategy:u="replace",verbose:d=!1}=e,h=s||yo.cwd(),p=[];if(o){let b=jt(h,o);p.push(b);let v=f?Tr(r,a,d):a,k=await this.fileLoader.tryLoadFromPaths([b],v,{arrayStrategy:u,verbose:d,cacheTtl:i?.ttl,useCache:i?.enabled!==!1&&(!i?.ttl||i.ttl>100),strictDiscovery:!0});if(!k)throw ai.configNotFound(r||o,p,n);if(d)Jt.success(`Configuration loaded from explicit path: ${b}`);return this.finalizeResult(k,p,f,r,d)}let m=await this.loadLocalConfiguration(r,n,h,l,a,u,d,f,i,e.errorPolicy==="throw");if(m)return p.push(...this.getLocalSearchPaths(r,n,h,l)),this.finalizeResult(m,p,f,r,d);let c=await this.loadHomeConfiguration(r,n,a,u,d,f,i,e.errorPolicy==="throw");if(c)return p.push(...this.getHomeSearchPaths(r,n)),this.finalizeResult(c,p,f,r,d);let C=await this.loadPackageJsonConfiguration(r,n,h,a,u,d,f,e.errorPolicy);if(C)return p.push(jt(h,"package.json")),this.finalizeResult(C,p,f,r,d);if(p.push(...this.getAllSearchPaths(r,n,h,l)),t)throw ai.configNotFound(r,p,n);return{...await this.applyEnvironmentVariables(r,a,f,d),warnings:[`No configuration file found for "${r}"${uy(n)}, using defaults with environment variables`]}}async loadLocalConfiguration(e,t,i,r,n,o,s,l,a,f=!1){let u=l?Tr(e,n,s):n,d=this.getLocalDirectories(i,r);for(let h of d){if(s)Jt.info(`Searching for configuration in: ${h}`);let p=this.fileLoader.generateConfigPaths(e,h,t),m=await this.fileLoader.tryLoadFromPaths(p,u,{arrayStrategy:o,verbose:s,cacheTtl:a?.ttl,useCache:a?.enabled!==!1&&(!a?.ttl||a.ttl>100),strictDiscovery:f});if(m){if(s)Jt.success(`Configuration loaded from: ${m.source.path}`);return m}}return null}async loadHomeConfiguration(e,t,i,r,n,o,s,l=!1){if(!e)return null;let a=o?Tr(e,i,n):i,f=[jt(ji(),".config",e),jt(ji(),".config"),ji()];for(let u of f){if(n)Jt.info(`Checking home directory: ${u}`);let d=this.fileLoader.generateConfigPaths(e,u,t),h=await this.fileLoader.tryLoadFromPaths(d,a,{arrayStrategy:r,verbose:n,cacheTtl:s?.ttl,useCache:s?.enabled!==!1&&(!s?.ttl||s.ttl>100),strictDiscovery:l});if(h){if(n)Jt.success(`Configuration loaded from home directory: ${h.source.path}`);return h}}return null}async loadPackageJsonConfiguration(e,t,i,r,n,o,s,l){let a=s?Tr(e,r,o):r,f=jt(i,"package.json"),u=l==="throw";try{let d=JSON.parse(Zp(f,"utf8"));if(typeof d!=="object"||d===null||Array.isArray(d))throw Error("package.json must contain an object");let h=d,p=t===void 0?[]:Array.isArray(t)?t:[t],m=[e,...p.filter(Boolean)].find((C)=>Object.hasOwn(h,C)&&(u||Boolean(h[C])));if(m===void 0)return null;let c=h[m];if(typeof c!=="object"||c===null||Array.isArray(c))throw Error(`Configuration field "${m}" must contain an object`);if(o)Jt.success(`Configuration loaded from package.json: ${m}`);return{config:vu(a,c,n),source:{type:"package.json",path:f,priority:30,timestamp:new Date}}}catch(d){if(gu(d))return null;if(u)throw ai.configLoad(f,d instanceof Error?d:Error(String(d)));if(o)Jt.warn("Failed to load package.json:",[d instanceof Error?d:Error(String(d))]);return null}}async applyEnvironmentVariables(e,t,i,r){if(!i||!e||typeof t!=="object"||t===null||Array.isArray(t))return{config:t,source:{type:"default",priority:10,timestamp:new Date}};return{config:Tr(e,t,r),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(e,t,i,r,n){return{config:e.config,source:e.source,path:e.source.path}}async validateConfiguration(e,t,i,r){let n=[];if(i){let o=i(e);if(o)n.push(...o)}if(t){let o=await this.validator.validateConfiguration(e,t);if(!o.isValid)n.push(...o.errors.map((s)=>s.path?`${s.path}: ${s.message}`:s.message))}if(n.length>0)throw ai.configValidation(r||"unknown",n,r)}checkCache(e,t){let i=this.generateCacheKey(e,t);return ao.get(i)||null}cacheResult(e,t,i,r){let n=this.generateCacheKey(e,r);ao.set(n,t,void 0,i.ttl)}generateCacheKey(e,t){let i=[e];if(t.alias){let r=Array.isArray(t.alias)?t.alias.join(","):t.alias;i.push(`alias:${r}`)}if(t.cwd)i.push(`cwd:${t.cwd}`);if(t.configFile)i.push(`configFile:${t.configFile}`);if(t.configDir)i.push(`configDir:${t.configDir}`);if("checkEnv"in t)i.push(`checkEnv:${t.checkEnv}`);return i.join("|")}getLocalDirectories(e,t){return Um({cwd:e,configDir:t})}getAllSearchPaths(e,t,i,r){let n=[];return n.push(...this.getLocalSearchPaths(e,t,i,r)),n.push(...this.getHomeSearchPaths(e,t)),n.push(jt(i,"package.json")),n}getLocalSearchPaths(e,t,i,r){let n=this.getLocalDirectories(i,r),o=[];for(let s of n)o.push(...this.fileLoader.generateConfigPaths(e,s,t));return o}getHomeSearchPaths(e,t){if(!e)return[];let i=[jt(ji(),".config",e),jt(ji(),".config"),ji()],r=[];for(let n of i)r.push(...this.fileLoader.generateConfigPaths(e,n,t));return r}async loadConfigWithResult(e){return this.loadConfig(e)}}function Tr(e,t,i=!1){let r=new Aa,n=e.toUpperCase().replace(/[^A-Z0-9]/g,"_");function o(s,l=[]){let a={...s};for(let[f,u]of Object.entries(s)){let d=[...l,f],h=[`${n}_${d.join("_").toUpperCase()}`,`${n}_${d.map((c)=>c.toUpperCase()).join("")}`,`${n}_${d.map((c)=>c.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],p,m;for(let c of h)if(p=yo.env[c],p!==void 0){m=c;break}if(p!==void 0&&m)if(typeof u==="boolean")a[f]=["true","1","yes"].includes(p.toLowerCase());else if(typeof u==="number"){let c=Number(p);if(!Number.isNaN(c))a[f]=c}else if(Array.isArray(u))try{a[f]=JSON.parse(p)}catch{a[f]=p.split(",").map((c)=>c.trim())}else a[f]=p;else if(u&&typeof u==="object"&&!Array.isArray(u))a[f]=o(u,d)}return a}return o(t)}var ao,ya,Gf,zm,Km=(e)=>e,qm=(e,t)=>{for(var i in t)zm(e,i,{get:t[i],enumerable:!0,configurable:!0,set:Hm.bind(t,i)})},Jm=(e,t)=>()=>(e&&(t=e(e=0)),t),Uf,Qf,Qi,Nr,eu,$g,Eg,Sf,Qn,la,at,Ue,xg,Af,Sg,kf,Ag,kg,Qs,Tg,Tf,Of,ea,Og,Rg,Pg,Mg,eo,tu,Dg,lt,Ig,Ng,Rf,to,ca,it,Oe,Fg,Pf,Wg,Mf,Lg,Bg,ta,_g,Df,If,jg,ia,Gg,Vg,Ug,zg,Kg,io,iu,Hg,qg="0.15.6",$t,ho,Dr,fa,ua,po,da,ha,Ir,pa,ma,li,ru,nu,It,Qt,ou,su,Jg,Xg,au,mo,bv,cu,Pe,$v,Qg,Ev,ey,xv,Sv,Nf,Av,ty,iy,kv,Ff,Tv,Ov,Rv,Pv,Mv,ra,ry,Dv,Nt,Pr,Zi,fu,uu,Sa,du,hu,go,pu,mu,ai,Wf,Xn,na,fy,Jt,Iv,Nv,Fv,dy,xu;var Su=me(()=>{ao=new _f,ya=new jf,Gf=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];zm=Object.defineProperty;Uf={};qm(Uf,{withErrorRecovery:()=>Hf,tryLoadConfig:()=>wg,loadConfigWithResult:()=>gg,loadConfig:()=>Zf,isRetryableError:()=>fg,isConfigNotFoundError:()=>cg,isBunfigError:()=>qf,globalPerformanceMonitor:()=>Nr,globalCache:()=>Qi,getEnvOrDefault:()=>ug,generateConfigTypes:()=>Cg,defaultGeneratedDir:()=>su,defaultConfigDir:()=>ou,deepMergeWithArrayStrategy:()=>$a,deepMerge:()=>Jf,createLibraryConfig:()=>vg,config:()=>yg,bunfigPlugin:()=>bg,applyEnvVarsToConfig:()=>Rr,TypeGenerationError:()=>ha,SchemaValidationError:()=>Ir,PluginError:()=>ma,PerformanceMonitor:()=>Ca,FileSystemError:()=>da,ErrorFactory:()=>li,EnvVarError:()=>po,EnvProcessor:()=>wo,ConfigValidator:()=>Ea,ConfigValidationError:()=>fa,ConfigNotFoundError:()=>ho,ConfigMergeError:()=>ua,ConfigLoader:()=>xa,ConfigLoadError:()=>Dr,ConfigFileLoader:()=>Co,ConfigCache:()=>wa,CacheUtils:()=>eu,BunfigError:()=>$t,BrowserConfigError:()=>pa,ArrayMergeStrategies:()=>ru});Jg=Jm(async()=>{Qf=import.meta.require,Qi=new wa,Nr=new Ca,eu={createKey:Ym,isEquivalent:Xm,estimateMemoryUsage:Zm},$g=oo(sa.cwd(),"config"),Eg=oo(sa.cwd(),"src/generated"),Sf=no.env.CLARITY_LOG_DIR||nm(tg(),"logs"),Qn={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:Sf,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1},la=await ig(),at={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,reset:"\x1B[0m"},Ue=at,xg=at.red,Af=at.green,Sg=at.yellow,kf=at.blue,Ag=at.magenta,kg=at.cyan,Qs=at.white,Tg=at.gray,Tf=at.bgRed,Of=at.bgYellow,ea=at.bold,Og=at.dim,Rg=at.italic,Pg=at.underline,Mg=at.reset,eo={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},tu={debug:"\uD83D\uDD0D",info:kf("\u2139"),success:Af("\u2713"),warning:Of(Qs(ea(" WARN "))),error:Tf(Qs(ea(" ERROR ")))},Dg=new co("stacks"),lt=new co("bunfig",{showTags:!0}),Ig=mt(Mr.cwd(),"config"),Ng=mt(Mr.cwd(),"src/generated"),Rf=ro.env.CLARITY_LOG_DIR||im(sg(),"logs"),to={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:Rf,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},ca=await ag(),it={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bgGray:(e)=>`\x1B[100m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,strikethrough:(e)=>`\x1B[9m${e}\x1B[0m`,reset:"\x1B[0m"},Oe=it,Fg=it.red,Pf=it.green,Wg=it.yellow,Mf=it.blue,Lg=it.magenta,Bg=it.cyan,ta=it.white,_g=it.gray,Df=it.bgRed,If=it.bgYellow,jg=it.bgGray,ia=it.bold,Gg=it.dim,Vg=it.italic,Ug=it.underline,zg=it.strikethrough,Kg=it.reset,io={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},iu={debug:"\uD83D\uDD0D",info:Mf("\u2139"),success:Pf("\u2713"),warning:If(ta(ia(" WARN "))),error:Df(ta(ia(" ERROR ")))},Hg=new uo("stacks"),$t=class extends Error{timestamp;context;constructor(e,t={}){super(e);if(this.name=this.constructor.name,this.timestamp=new Date,this.context=t,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,timestamp:this.timestamp.toISOString(),context:this.context,stack:this.stack}}toString(){let e=Object.keys(this.context).length>0?` (${Object.entries(this.context).map(([t,i])=>`${t}: ${i}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${e}`}},ho=class extends $t{code="CONFIG_NOT_FOUND";constructor(e,t,i){let r=i?` or alias "${i}"`:"";super(`Configuration "${e}"${r} not found`,{configName:e,alias:i,searchPaths:t,searchPathCount:t.length})}},Dr=class extends $t{code="CONFIG_LOAD_ERROR";constructor(e,t,i){super(`Failed to load configuration from "${e}": ${t.message}`,{configPath:e,configName:i,originalError:t.name,originalMessage:t.message});this.cause=t}},fa=class extends $t{code="CONFIG_VALIDATION_ERROR";constructor(e,t,i){super(`Configuration validation failed for "${e}"`,{configPath:e,configName:i,validationErrors:t,errorCount:t.length})}},ua=class extends $t{code="CONFIG_MERGE_ERROR";constructor(e,t,i,r){super(`Failed to merge configuration from "${e}" with "${t}": ${i.message}`,{sourcePath:e,targetPath:t,configName:r,originalError:i.name,originalMessage:i.message});this.cause=i}},po=class extends $t{code="ENV_VAR_ERROR";constructor(e,t,i,r){super(`Failed to parse environment variable "${e}" with value "${t}" as ${i}`,{envKey:e,envValue:t,expectedType:i,configName:r})}},da=class extends $t{code="FILE_SYSTEM_ERROR";constructor(e,t,i){super(`File system ${e} failed for "${t}": ${i.message}`,{operation:e,path:t,originalError:i.name,originalMessage:i.message});this.cause=i}},ha=class extends $t{code="TYPE_GENERATION_ERROR";constructor(e,t,i){super(`Failed to generate types from "${e}" to "${t}": ${i.message}`,{configDir:e,outputPath:t,originalError:i.name,originalMessage:i.message});this.cause=i}},Ir=class extends $t{code="SCHEMA_VALIDATION_ERROR";constructor(e,t,i){super(`Schema validation failed${i?` for config "${i}"`:""}`,{schemaPath:e,configName:i,validationErrors:t,errorCount:t.length})}},pa=class extends $t{code="BROWSER_CONFIG_ERROR";constructor(e,t,i,r){super(`Failed to fetch configuration from "${e}": ${t} ${i}`,{endpoint:e,status:t,statusText:i,configName:r})}},ma=class extends $t{code="PLUGIN_ERROR";constructor(e,t,i){super(`Plugin "${e}" failed during ${t}: ${i.message}`,{pluginName:e,operation:t,originalError:i.name,originalMessage:i.message});this.cause=i}},li={configNotFound(e,t,i){return new ho(e,t,i)},configLoad(e,t,i){return new Dr(e,t,i)},configValidation(e,t,i){return new fa(e,t,i)},configMerge(e,t,i,r){return new ua(e,t,i,r)},envVar(e,t,i,r){return new po(e,t,i,r)},fileSystem(e,t,i){return new da(e,t,i)},typeGeneration(e,t,i){return new ha(e,t,i)},schemaValidation(e,t,i){return new Ir(e,t,i)},browserConfig(e,t,i,r){return new pa(e,t,i,r)},plugin(e,t,i){return new ma(e,t,i)}},ru={replace:"replace",concat:"concat",smart:"smart"},nu=/^https?:\/\//,It=new uo("bunfig",{showTags:!0}),Qt=new xa,ou=gt(Ai.cwd(),"config"),su=gt(Ai.cwd(),"src/generated")});Xg=so.env.CLARITY_LOG_DIR||Am(Yg(),"logs"),au={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:Xg,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},mo={...au},bv=(async()=>{try{let{loadConfig:e}=await Jg().then(()=>Uf),t=await e({name:"clarity",alias:"logging",defaultConfig:au,cwd:so.cwd()});if(t)Object.assign(mo,t)}catch{}return mo})();cu={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bgGray:(e)=>`\x1B[100m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,strikethrough:(e)=>`\x1B[9m${e}\x1B[0m`,reset:"\x1B[0m"},Pe=cu,{red:$v,green:Qg,yellow:Ev,blue:ey,magenta:xv,cyan:Sv,white:Nf,gray:Av,bgRed:ty,bgYellow:iy,bgGray:kv,bold:Ff,dim:Tv,italic:Ov,underline:Rv,strikethrough:Pv,reset:Mv}=cu,ra={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},ry={debug:"\uD83D\uDD0D",info:ey("\u2139"),success:Qg("\u2713"),warning:iy(Nf(Ff(" WARN "))),error:ty(Nf(Ff(" ERROR ")))};Dv=new vo("stacks");Nt=class Nt extends Error{timestamp;context;constructor(e,t={}){super(e);if(this.name=this.constructor.name,this.timestamp=new Date,this.context=t,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,timestamp:this.timestamp.toISOString(),context:this.context,stack:this.stack}}toString(){let e=Object.keys(this.context).length>0?` (${Object.entries(this.context).map(([t,i])=>`${t}: ${i}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${e}`}};Pr=class Pr extends Nt{name="ConfigNotFoundError";code="CONFIG_NOT_FOUND";constructor(e,t,i){let r=i===void 0?[]:Array.isArray(i)?i.filter(Boolean):[i],n="";if(r.length===1)n=` or alias "${r[0]}"`;else if(r.length>1)n=` or aliases ${r.map((o)=>`"${o}"`).join(", ")}`;super(`Configuration "${e}"${n} not found`,{configName:e,alias:i,searchPaths:t,searchPathCount:t.length})}};Zi=class Zi extends Nt{name="ConfigLoadError";code="CONFIG_LOAD_ERROR";constructor(e,t,i){super(`Failed to load configuration from "${e}": ${t.message}`,{configPath:e,configName:i,originalError:t.name,originalMessage:t.message});this.cause=t}};fu=class fu extends Nt{name="ConfigValidationError";code="CONFIG_VALIDATION_ERROR";constructor(e,t,i){super(`Configuration validation failed for "${e}"`,{configPath:e,configName:i,validationErrors:t,errorCount:t.length})}};uu=class uu extends Nt{name="ConfigMergeError";code="CONFIG_MERGE_ERROR";constructor(e,t,i,r){super(`Failed to merge configuration from "${e}" with "${t}": ${i.message}`,{sourcePath:e,targetPath:t,configName:r,originalError:i.name,originalMessage:i.message});this.cause=i}};Sa=class Sa extends Nt{name="EnvVarError";code="ENV_VAR_ERROR";constructor(e,t,i,r){super(`Failed to parse environment variable "${e}" with value "${t}" as ${i}`,{envKey:e,envValue:t,expectedType:i,configName:r})}};du=class du extends Nt{name="FileSystemError";code="FILE_SYSTEM_ERROR";constructor(e,t,i){super(`File system ${e} failed for "${t}": ${i.message}`,{operation:e,path:t,originalError:i.name,originalMessage:i.message});this.cause=i}};hu=class hu extends Nt{name="TypeGenerationError";code="TYPE_GENERATION_ERROR";constructor(e,t,i){super(`Failed to generate types from "${e}" to "${t}": ${i.message}`,{configDir:e,outputPath:t,originalError:i.name,originalMessage:i.message});this.cause=i}};go=class go extends Nt{name="SchemaValidationError";code="SCHEMA_VALIDATION_ERROR";constructor(e,t,i){super(`Schema validation failed${i?` for config "${i}"`:""}`,{schemaPath:e,configName:i,validationErrors:t,errorCount:t.length})}};pu=class pu extends Nt{name="BrowserConfigError";code="BROWSER_CONFIG_ERROR";constructor(e,t,i,r){super(`Failed to fetch configuration from "${e}": ${t} ${i}`,{endpoint:e,status:t,statusText:i,configName:r})}};mu=class mu extends Nt{name="PluginError";code="PLUGIN_ERROR";constructor(e,t,i){super(`Plugin "${e}" failed during ${t}: ${i.message}`,{pluginName:e,operation:t,originalError:i.name,originalMessage:i.message});this.cause=i}};ai={configNotFound(e,t,i){return new Pr(e,t,i)},configLoad(e,t,i){return new Zi(e,t,i)},configValidation(e,t,i){return new fu(e,t,i)},configMerge(e,t,i,r){return new uu(e,t,i,r)},envVar(e,t,i,r){return new Sa(e,t,i,r)},fileSystem(e,t,i){return new du(e,t,i)},typeGeneration(e,t,i){return new hu(e,t,i)},schemaValidation(e,t,i){return new go(e,t,i)},browserConfig(e,t,i,r){return new pu(e,t,i,r)},plugin(e,t,i){return new mu(e,t,i)}};Wf=Bm(import.meta.url),Xn=new Map,na=new Set;fy=/^https?:\/\//;Jt=new vo("bunfig",{showTags:!0});Iv=new Eu;Nv=jt(yo.cwd(),"config"),Fv=jt(yo.cwd(),"src/generated"),dy={cwd:Yp.cwd(),root:"./src",entrypoints:["**/*.{ts,tsx,mts,cts,vue,stx}"],outdir:"./dist",keepComments:!0,clean:!0,tsconfigPath:"./tsconfig.json",outputStructure:"mirror",moduleSpecifierMode:"preserve",verbose:!1,importOrder:["bun"],declarationMap:!1},xu=dy});import{existsSync as Au}from"fs";import{basename as hy,dirname as py,extname as ku,isAbsolute as bo,relative as ei,resolve as ti}from"path";async function Ou(e,t){let i=await Cy(e);wy(e,i);let r=i.slice(),n=await(t?t():Fn(e)),o=null;if(e.autoIncludeReExports!==!1&&r.length>0){o=await Ar(r,{includeImports:!0,resolveSpecifier:n});let d=ti(e.cwd,e.root),h=e.exclude||[],p=[];for(let m of o.reachable){if(r.includes(m))continue;if(!ka(m))continue;if(m.endsWith(".d.ts"))continue;if(m.includes("node_modules"))continue;let c=e.outputStructure==="flat"&&i.some((C)=>n.isPackageLocal?.(C,m));if(!Gt(m,d)&&!c){le.warn(`Skipping auto-included source outside root: ${ei(e.cwd,m)}`);continue}if(Wr(m,h,d))continue;p.push(m)}if(p.length>0)r=[...r,...p],le.debug(`Auto-included ${p.length} file(s) reached via relative re-exports`)}let s=vy(r,e),l=o??await Ar(r,{includeImports:!0,resolveSpecifier:n}),a=await Mc([...l.sources.keys()],n,e.isolatedDeclarations??!1,l.sources),f=new Set(r);for(let[d,h]of a){if(!f.has(d))continue;for(let p of h){let m=n(p,d).resolved;if(m&&!f.has(m))throw Error(`Module augmentation import ${JSON.stringify(p)} from ${d} requires a source not emitted by this package build: ${m}`)}}let u=[...a].map(([d,h])=>[d,[...h].sort()]).sort(([d],[h])=>d.localeCompare(h));return Object.freeze({entryFiles:Object.freeze(i),files:Object.freeze(r),outputBySource:s,resolver:n,reachability:o,augmentationImports:a,getResolutionFingerprint:()=>JSON.stringify({resolution:n.cacheKey?.(r),augmentations:u})})}function gy(e){let t=Fr.get(e);if(!t){if(t=new Tu(e),Fr.set(e,t),Fr.size>my){let i=Fr.keys().next().value;if(i!==void 0)Fr.delete(i)}}return t}function Wr(e,t,i){if(!t||t.length===0)return!1;let r=ei(i,e);for(let n of t){let o=gy(n);if(o.match(r)||o.match(e))return!0}return!1}function wy(e,t){let i=ti(e.cwd,e.root),r=` root: ${i}
224
224
  entrypoints: ${e.entrypoints.map((o)=>JSON.stringify(o)).join(", ")||"(none)"}
225
225
  `+(e.exclude?.length?` exclude: ${e.exclude.map((o)=>JSON.stringify(o)).join(", ")}
226
- `:"")+"Entrypoints are resolved relative to --root. Pass several by repeating --entrypoints or separating them with commas.";if(t.length===0){if(e.entrypoints.filter((o)=>Co(o)&&Au(o)&&!Gt(o,i)).length===e.entrypoints.length)return;throw Error(`No source files matched. Nothing was generated.
227
- ${r}`)}let n=e.entrypoints.filter((o)=>{if(py.test(o))return!1;return!Au(Co(o)?o:ti(i,o))});if(n.length>0)throw Error(`Entrypoint${n.length>1?"s":""} not found: ${n.map((o)=>JSON.stringify(o)).join(", ")}
228
- ${r}`)}async function gy(e){let t=[],i=ti(e.cwd,e.root),r=e.exclude||[],n=[...e.entrypoints,...e.include??[]];for(let o of n)if(Co(o)&&Aa(o)){if(!o.includes("node_modules")){if(!Gt(o,i)&&e.outputStructure!=="flat")le.warn(`Skipping entrypoint outside root: ${ei(e.cwd,o)}`);else if(!Wr(o,r,i))t.push(o)}}else{let s=new Tu(o);for await(let l of s.scan({cwd:i,absolute:!0,onlyFiles:!0}))if(Aa(l)&&!l.includes("node_modules")){if(!Wr(l,r,i))t.push(l)}}return[...new Set(t.map((o)=>ti(o)))].sort()}function Gt(e,t){let i=ei(t,e);return i!==".."&&!i.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!Co(i)}function yy(e,t){let i=new Map,r=new Map;for(let n of e){let o=Qi(n,t),s=i.get(o);if(s&&s!==n)throw Error(`Output path collision: ${ei(t.cwd,s)} and ${ei(t.cwd,n)} both emit ${ei(t.cwd,o)}`);i.set(o,n),r.set(n,o)}return r}function Aa(e){return/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/.test(e)&&!/\.d\.(?:ts|mts|cts)$/.test(e)}function Qi(e,t){let i=ti(t.cwd,t.root),r=ei(i,e),n=/\.d\.(?:ts|mts|cts)$/.test(r)?r:r.replace(/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/,(o)=>{if(o===".mts"||o===".mjs")return".d.mts";if(o===".cts"||o===".cjs")return".d.cts";return".d.ts"});if(t.outputStructure==="mirror")return ti(t.cwd,t.outdir,n);else{let o=fy(n);return ti(t.cwd,t.outdir,o)}}function wy(e,t,i=""){let r=ei(uy(e),t).replace(/\\/g,"/");if(r=r.replace(/\.d\.mts$/,"").replace(/\.d\.cts$/,"").replace(/\.d\.ts$/,""),i)r+=i;if(!r.startsWith("."))r=`./${r}`;return r}function Ru(e,t,i,r){let n=Qi(e,t);return(o)=>{let s=i(o,e);if(!s.isRelative||!s.resolved)return{kind:"unchanged",reason:s.isRelative?"unresolved":"external",specifier:o,emittedSpecifier:o};if(/\.d\.(?:ts|mts|cts)$/.test(s.resolved)){if(t.moduleSpecifierMode!=="node")return{kind:"unchanged",reason:"preserved-declaration",specifier:o,emittedSpecifier:o};if(r&&!r.has(s.resolved))throw Error(`Local declaration ${JSON.stringify(o)} from ${e} targets an authored declaration not emitted by this package build: ${s.resolved}. Declaration-only dependencies must be delivered with the package before this importer can be emitted.`)}if(s.isAlias&&r&&!r.has(s.resolved))throw Error(`Local alias ${JSON.stringify(o)} from ${e} targets a declaration excluded from this package build: ${s.resolved}`);if(r&&!r.has(s.resolved)&&Wr(s.resolved,t.exclude??[],ti(t.cwd,t.root)))throw Error(`Local reference ${JSON.stringify(o)} from ${e} targets a source excluded from this package build: ${s.resolved}`);let l=s.isAlias?s.suffix??"":o.match(/[?#].*$/)?.[0]??"",a=l?o.slice(0,-l.length):o,f=ku(a),u=/^(?:\.js|\.jsx|\.mjs|\.cjs)$/.test(f)?f:"";if(!u&&t.moduleSpecifierMode==="node"){let h=ku(s.resolved);u=h===".mts"||h===".mjs"?".mjs":h===".cts"||h===".cjs"?".cjs":".js"}let d=Qi(s.resolved,t);return{kind:"local",specifier:o,resolvedSource:s.resolved,declarationOutput:d,emittedSpecifier:wy(n,d,u)+l}}}var Tu,dy=50,Fr,py;var ka=me(()=>{Dc();Mn();Nn();({Glob:Tu}=globalThis.Bun);Fr=new Map;py=/[*?[\]{}!]/});var Pu;var Mu=me(()=>{Pu=new Set(["ANGLE_instanced_arrays","ARIAMixin","AacBitstreamFormat","AacEncoderConfig","AbortController","AbortSignal","AbortSignalEventMap","AbstractRange","AbstractWorker","AbstractWorkerEventMap","ActiveXObject","AddEventListenerOptions","AddressErrors","AddressType","AddressValue","AesCbcParams","AesCtrParams","AesDerivedKeyParams","AesGcmParams","AesKeyAlgorithm","AesKeyGenParams","AggregateError","AggregateErrorConstructor","Algorithm","AlgorithmIdentifier","AlignSetting","AllAcceptedCredentialsOptions","AllowSharedBufferSource","AlphaOption","AnalyserNode","AnalyserOptions","Animatable","Animation","AnimationEffect","AnimationEvent","AnimationEventInit","AnimationEventMap","AnimationFrameProvider","AnimationPlayState","AnimationPlaybackEvent","AnimationPlaybackEventInit","AnimationReplaceState","AnimationTimeline","AppendMode","Array","ArrayBuffer","ArrayBufferConstructor","ArrayBufferLike","ArrayBufferTypes","ArrayBufferView","ArrayConstructor","ArrayIterator","ArrayLike","AssignedNodesOptions","AsyncDisposable","AsyncDisposableStack","AsyncDisposableStackConstructor","AsyncGenerator","AsyncGeneratorFunction","AsyncGeneratorFunctionConstructor","AsyncIterable","AsyncIterableIterator","AsyncIterator","AsyncIteratorObject","Atomics","AttestationConveyancePreference","Attr","Audio","AudioBuffer","AudioBufferOptions","AudioBufferSourceNode","AudioBufferSourceOptions","AudioConfiguration","AudioContext","AudioContextLatencyCategory","AudioContextOptions","AudioContextState","AudioData","AudioDataCopyToOptions","AudioDataInit","AudioDataOutputCallback","AudioDecoder","AudioDecoderConfig","AudioDecoderEventMap","AudioDecoderInit","AudioDecoderSupport","AudioDestinationNode","AudioEncoder","AudioEncoderConfig","AudioEncoderEventMap","AudioEncoderInit","AudioEncoderSupport","AudioListener","AudioNode","AudioNodeOptions","AudioParam","AudioParamMap","AudioProcessingEvent","AudioProcessingEventInit","AudioSampleFormat","AudioScheduledSourceNode","AudioScheduledSourceNodeEventMap","AudioTimestamp","AudioWorklet","AudioWorkletNode","AudioWorkletNodeEventMap","AudioWorkletNodeOptions","AuthenticationExtensionsClientInputs","AuthenticationExtensionsClientInputsJSON","AuthenticationExtensionsClientOutputs","AuthenticationExtensionsClientOutputsJSON","AuthenticationExtensionsLargeBlobInputs","AuthenticationExtensionsLargeBlobInputsJSON","AuthenticationExtensionsLargeBlobOutputs","AuthenticationExtensionsLargeBlobOutputsJSON","AuthenticationExtensionsPRFInputs","AuthenticationExtensionsPRFInputsJSON","AuthenticationExtensionsPRFOutputs","AuthenticationExtensionsPRFOutputsJSON","AuthenticationExtensionsPRFValues","AuthenticationExtensionsPRFValuesJSON","AuthenticationResponseJSON","AuthenticatorAssertionResponse","AuthenticatorAssertionResponseJSON","AuthenticatorAttachment","AuthenticatorAttestationResponse","AuthenticatorAttestationResponseJSON","AuthenticatorResponse","AuthenticatorSelectionCriteria","AuthenticatorTransport","AutoFill","AutoFillAddressKind","AutoFillBase","AutoFillContactField","AutoFillContactKind","AutoFillCredentialField","AutoFillField","AutoFillNormalField","AutoFillSection","AutoKeyword","AutomationRate","AvcBitstreamFormat","AvcEncoderConfig","Awaited","BarProp","Base64URLString","BaseAudioContext","BaseAudioContextEventMap","BeforeUnloadEvent","BigInt","BigInt64Array","BigInt64ArrayConstructor","BigIntConstructor","BigIntToLocaleStringOptions","BigInteger","BigUint64Array","BigUint64ArrayConstructor","BinaryType","BiquadFilterNode","BiquadFilterOptions","BiquadFilterType","BitrateMode","Blob","BlobCallback","BlobEvent","BlobEventInit","BlobPart","BlobPropertyBag","Body","BodyInit","Boolean","BooleanConstructor","BroadcastChannel","BroadcastChannelEventMap","Buffer","BufferEncoding","BufferSource","BuiltinIteratorReturn","Bun","BunFile","ByteLengthQueuingStrategy","CDATASection","COSEAlgorithmIdentifier","CSS","CSSAnimation","CSSConditionRule","CSSContainerRule","CSSCounterStyleRule","CSSFontFaceRule","CSSFontFeatureValuesRule","CSSFontPaletteValuesRule","CSSGroupingRule","CSSImageValue","CSSImportRule","CSSKeyframeRule","CSSKeyframesRule","CSSKeywordValue","CSSKeywordish","CSSLayerBlockRule","CSSLayerStatementRule","CSSMathClamp","CSSMathInvert","CSSMathMax","CSSMathMin","CSSMathNegate","CSSMathOperator","CSSMathProduct","CSSMathSum","CSSMathValue","CSSMatrixComponent","CSSMatrixComponentOptions","CSSMediaRule","CSSNamespaceRule","CSSNestedDeclarations","CSSNumberish","CSSNumericArray","CSSNumericBaseType","CSSNumericType","CSSNumericValue","CSSPageDescriptors","CSSPageRule","CSSPerspective","CSSPerspectiveValue","CSSPositionTryDescriptors","CSSPositionTryRule","CSSPropertyRule","CSSRotate","CSSRule","CSSRuleList","CSSScale","CSSScopeRule","CSSSkew","CSSSkewX","CSSSkewY","CSSStartingStyleRule","CSSStyleDeclaration","CSSStyleDeclarationBase","CSSStyleProperties","CSSStyleRule","CSSStyleSheet","CSSStyleSheetInit","CSSStyleValue","CSSSupportsRule","CSSTransformComponent","CSSTransformValue","CSSTransition","CSSTranslate","CSSUnitValue","CSSUnparsedSegment","CSSUnparsedValue","CSSVariableReferenceValue","CSSViewTransitionRule","Cache","CacheQueryOptions","CacheStorage","CalendarLike","CallableFunction","CanPlayTypeResult","CanvasCaptureMediaStreamTrack","CanvasCompositing","CanvasDirection","CanvasDrawImage","CanvasDrawPath","CanvasFillRule","CanvasFillStrokeStyles","CanvasFilters","CanvasFontKerning","CanvasFontStretch","CanvasFontVariantCaps","CanvasGradient","CanvasImageData","CanvasImageSmoothing","CanvasImageSource","CanvasLineCap","CanvasLineJoin","CanvasPath","CanvasPathDrawingStyles","CanvasPattern","CanvasRect","CanvasRenderingContext2D","CanvasRenderingContext2DSettings","CanvasSettings","CanvasShadowStyles","CanvasState","CanvasText","CanvasTextAlign","CanvasTextBaseline","CanvasTextDrawingStyles","CanvasTextRendering","CanvasTransform","CanvasUserInterface","Capitalize","CaretPosition","CaretPositionFromPointOptions","ChannelCountMode","ChannelInterpretation","ChannelMergerNode","ChannelMergerOptions","ChannelSplitterNode","ChannelSplitterOptions","CharacterData","CheckVisibilityOptions","ChildNode","ClassAccessorDecoratorContext","ClassAccessorDecoratorResult","ClassAccessorDecoratorTarget","ClassDecorator","ClassDecoratorContext","ClassFieldDecoratorContext","ClassGetterDecoratorContext","ClassMemberDecoratorContext","ClassMethodDecoratorContext","ClassSetterDecoratorContext","Client","ClientQueryOptions","ClientRect","ClientTypes","Clients","Clipboard","ClipboardEvent","ClipboardEventInit","ClipboardItem","ClipboardItemData","ClipboardItemOptions","ClipboardItems","CloseEvent","CloseEventInit","CodecState","Collator","CollatorConstructor","CollatorOptions","ColorGamut","ColorSpaceConversion","CommandEvent","CommandEventInit","Comment","CompileError","CompositeOperation","CompositeOperationOrAuto","CompositionEvent","CompositionEventInit","CompressionFormat","CompressionStream","ComputedEffectTiming","ComputedKeyframe","ConcatArray","Console","ConstantSourceNode","ConstantSourceOptions","ConstrainBoolean","ConstrainBooleanOrDOMString","ConstrainBooleanOrDOMStringParameters","ConstrainBooleanParameters","ConstrainDOMString","ConstrainDOMStringParameters","ConstrainDouble","ConstrainDoubleRange","ConstrainULong","ConstrainULongRange","ConstructorParameters","ContentVisibilityAutoStateChangeEvent","ContentVisibilityAutoStateChangeEventInit","ConvolverNode","ConvolverOptions","CookieChangeEvent","CookieChangeEventInit","CookieInit","CookieList","CookieListItem","CookieSameSite","CookieStore","CookieStoreDeleteOptions","CookieStoreEventMap","CookieStoreGetOptions","CookieStoreManager","CountQueuingStrategy","Credential","CredentialCreationOptions","CredentialMediationRequirement","CredentialPropertiesOutput","CredentialRequestOptions","CredentialsContainer","Crypto","CryptoKey","CryptoKeyPair","CurrentUserDetailsOptions","CustomElementConstructor","CustomElementRegistry","CustomEvent","CustomEventInit","CustomStateSet","DOMException","DOMHighResTimeStamp","DOMImplementation","DOMMatrix","DOMMatrix2DInit","DOMMatrixInit","DOMMatrixReadOnly","DOMParser","DOMParserSupportedType","DOMPoint","DOMPointInit","DOMPointReadOnly","DOMQuad","DOMQuadInit","DOMRect","DOMRectInit","DOMRectList","DOMRectReadOnly","DOMStringList","DOMStringMap","DOMTokenList","DataTransfer","DataTransferItem","DataTransferItemList","DataView","DataViewConstructor","Date","DateConstructor","DateLikeObject","DateTimeFormat","DateTimeFormatConstructor","DateTimeFormatOptions","DateTimeFormatPart","DateTimeFormatPartTypes","DateTimeFormatPartTypesRegistry","DateTimeLikeObject","DateTimeRangeFormatPart","DateUnit","DecodeErrorCallback","DecodeSuccessCallback","DecompressionStream","DecoratorContext","DecoratorMetadata","DecoratorMetadataObject","DedicatedWorkerGlobalScope","DedicatedWorkerGlobalScopeEventMap","DelayNode","DelayOptions","DeviceMotionEvent","DeviceMotionEventAcceleration","DeviceMotionEventAccelerationInit","DeviceMotionEventInit","DeviceMotionEventRotationRate","DeviceMotionEventRotationRateInit","DeviceOrientationEvent","DeviceOrientationEventInit","DigitalCredential","DirectionSetting","Dirent","DisambiguationOptions","DisplayCaptureSurfaceType","DisplayMediaStreamOptions","DisplayNames","DisplayNamesFallback","DisplayNamesLanguageDisplay","DisplayNamesOptions","DisplayNamesType","Disposable","DisposableStack","DisposableStackConstructor","DistanceModelType","Document","DocumentEventMap","DocumentFragment","DocumentOrShadowRoot","DocumentReadyState","DocumentTimeline","DocumentTimelineOptions","DocumentType","DocumentVisibilityState","DoubleRange","DragEvent","DragEventInit","Duration","DurationConstructor","DurationFormat","DurationFormatDisplayOption","DurationFormatLocaleMatcher","DurationFormatOptions","DurationFormatPart","DurationFormatStyle","DurationFormatUnit","DurationFormatUnitSingular","DurationLike","DurationLikeObject","DurationRelativeToOptions","DurationRoundingOptions","DurationToStringOptions","DurationTotalOptions","DynamicsCompressorNode","DynamicsCompressorOptions","EXT_blend_minmax","EXT_color_buffer_float","EXT_color_buffer_half_float","EXT_float_blend","EXT_frag_depth","EXT_sRGB","EXT_shader_texture_lod","EXT_texture_compression_bptc","EXT_texture_compression_rgtc","EXT_texture_filter_anisotropic","EXT_texture_norm16","EcKeyAlgorithm","EcKeyGenParams","EcKeyImportParams","EcdhKeyDeriveParams","EcdsaParams","EffectTiming","Element","ElementCSSInlineStyle","ElementContentEditable","ElementCreationOptions","ElementDefinitionOptions","ElementEventMap","ElementInternals","ElementTagNameMap","EncodedAudioChunk","EncodedAudioChunkInit","EncodedAudioChunkMetadata","EncodedAudioChunkOutputCallback","EncodedAudioChunkType","EncodedVideoChunk","EncodedVideoChunkInit","EncodedVideoChunkMetadata","EncodedVideoChunkOutputCallback","EncodedVideoChunkType","EndOfStreamError","EndingType","Enumerator","EnumeratorConstructor","EpochTimeStamp","Error","ErrorCallback","ErrorConstructor","ErrorEvent","ErrorEventInit","ErrorOptions","EvalError","EvalErrorConstructor","Event","EventCounts","EventInit","EventListener","EventListenerObject","EventListenerOptions","EventListenerOrEventListenerObject","EventModifierInit","EventSource","EventSourceEventMap","EventSourceInit","EventTarget","Exception","ExceptionOptions","Exclude","ExportValue","Exports","ExtendableCookieChangeEvent","ExtendableCookieChangeEventInit","ExtendableEvent","ExtendableEventInit","ExtendableMessageEvent","ExtendableMessageEventInit","External","Extract","FetchEvent","FetchEventInit","File","FileCallback","FileList","FilePropertyBag","FileReader","FileReaderEventMap","FileReaderSync","FileSink","FileSystem","FileSystemCreateWritableOptions","FileSystemDirectoryEntry","FileSystemDirectoryHandle","FileSystemDirectoryHandleAsyncIterator","FileSystemDirectoryReader","FileSystemEntriesCallback","FileSystemEntry","FileSystemEntryCallback","FileSystemFileEntry","FileSystemFileHandle","FileSystemFlags","FileSystemGetDirectoryOptions","FileSystemGetFileOptions","FileSystemHandle","FileSystemHandleKind","FileSystemReadWriteOptions","FileSystemRemoveOptions","FileSystemSyncAccessHandle","FileSystemWritableFileStream","FileSystemWriteChunkType","FillLightMode","FillMode","FinalizationRegistry","FinalizationRegistryConstructor","FlatArray","Float16Array","Float16ArrayConstructor","Float32Array","Float32ArrayConstructor","Float32List","Float64Array","Float64ArrayConstructor","FocusEvent","FocusEventInit","FocusOptions","FontDisplay","FontFace","FontFaceDescriptors","FontFaceLoadStatus","FontFaceSet","FontFaceSetEventMap","FontFaceSetLoadEvent","FontFaceSetLoadEventInit","FontFaceSetLoadStatus","FontFaceSource","FormData","FormDataEntryValue","FormDataEvent","FormDataEventInit","FormDataIterator","FormattableTemporalObject","FragmentDirective","FrameRequestCallback","FrameType","FullscreenNavigationUI","FullscreenOptions","Function","FunctionConstructor","FunctionStringCallback","GLbitfield","GLboolean","GLclampf","GLenum","GLfloat","GLint","GLint64","GLintptr","GLsizei","GLsizeiptr","GLuint","GLuint64","GPU","GPUAdapter","GPUAdapterInfo","GPUAddressMode","GPUAutoLayoutMode","GPUBindGroup","GPUBindGroupDescriptor","GPUBindGroupEntry","GPUBindGroupLayout","GPUBindGroupLayoutDescriptor","GPUBindGroupLayoutEntry","GPUBindingCommandsMixin","GPUBindingResource","GPUBlendComponent","GPUBlendFactor","GPUBlendOperation","GPUBlendState","GPUBuffer","GPUBufferBinding","GPUBufferBindingLayout","GPUBufferBindingType","GPUBufferDescriptor","GPUBufferDynamicOffset","GPUBufferMapState","GPUBufferUsageFlags","GPUCanvasAlphaMode","GPUCanvasConfiguration","GPUCanvasContext","GPUCanvasToneMapping","GPUCanvasToneMappingMode","GPUColor","GPUColorDict","GPUColorTargetState","GPUColorWriteFlags","GPUCommandBuffer","GPUCommandBufferDescriptor","GPUCommandEncoder","GPUCommandEncoderDescriptor","GPUCompareFunction","GPUCompilationInfo","GPUCompilationMessage","GPUCompilationMessageType","GPUComputePassDescriptor","GPUComputePassEncoder","GPUComputePassTimestampWrites","GPUComputePipeline","GPUComputePipelineDescriptor","GPUCopyExternalImageDestInfo","GPUCopyExternalImageSource","GPUCopyExternalImageSourceInfo","GPUCullMode","GPUDebugCommandsMixin","GPUDepthBias","GPUDepthStencilState","GPUDevice","GPUDeviceDescriptor","GPUDeviceEventMap","GPUDeviceLostInfo","GPUDeviceLostReason","GPUError","GPUErrorFilter","GPUExtent3D","GPUExtent3DDict","GPUExternalTexture","GPUExternalTextureBindingLayout","GPUExternalTextureDescriptor","GPUFeatureName","GPUFilterMode","GPUFlagsConstant","GPUFragmentState","GPUFrontFace","GPUIndex32","GPUIndexFormat","GPUIntegerCoordinate","GPUIntegerCoordinateOut","GPUInternalError","GPULoadOp","GPUMapModeFlags","GPUMipmapFilterMode","GPUMultisampleState","GPUObjectBase","GPUObjectDescriptorBase","GPUOrigin2D","GPUOrigin2DDict","GPUOrigin3D","GPUOrigin3DDict","GPUOutOfMemoryError","GPUPipelineBase","GPUPipelineConstantValue","GPUPipelineDescriptorBase","GPUPipelineError","GPUPipelineErrorInit","GPUPipelineErrorReason","GPUPipelineLayout","GPUPipelineLayoutDescriptor","GPUPowerPreference","GPUPrimitiveState","GPUPrimitiveTopology","GPUProgrammableStage","GPUQuerySet","GPUQuerySetDescriptor","GPUQueryType","GPUQueue","GPUQueueDescriptor","GPURenderBundle","GPURenderBundleDescriptor","GPURenderBundleEncoder","GPURenderBundleEncoderDescriptor","GPURenderCommandsMixin","GPURenderPassColorAttachment","GPURenderPassDepthStencilAttachment","GPURenderPassDescriptor","GPURenderPassEncoder","GPURenderPassLayout","GPURenderPassTimestampWrites","GPURenderPipeline","GPURenderPipelineDescriptor","GPURequestAdapterOptions","GPUSampleMask","GPUSampler","GPUSamplerBindingLayout","GPUSamplerBindingType","GPUSamplerDescriptor","GPUShaderModule","GPUShaderModuleDescriptor","GPUShaderStageFlags","GPUSignedOffset32","GPUSize32","GPUSize32Out","GPUSize64","GPUSize64Out","GPUStencilFaceState","GPUStencilOperation","GPUStencilValue","GPUStorageTextureAccess","GPUStorageTextureBindingLayout","GPUStoreOp","GPUSupportedFeatures","GPUSupportedLimits","GPUTexelCopyBufferInfo","GPUTexelCopyBufferLayout","GPUTexelCopyTextureInfo","GPUTexture","GPUTextureAspect","GPUTextureBindingLayout","GPUTextureDescriptor","GPUTextureDimension","GPUTextureFormat","GPUTextureSampleType","GPUTextureUsageFlags","GPUTextureView","GPUTextureViewDescriptor","GPUTextureViewDimension","GPUUncapturedErrorEvent","GPUUncapturedErrorEventInit","GPUValidationError","GPUVertexAttribute","GPUVertexBufferLayout","GPUVertexFormat","GPUVertexState","GPUVertexStepMode","GainNode","GainOptions","Gamepad","GamepadButton","GamepadEffectParameters","GamepadEvent","GamepadEventInit","GamepadHapticActuator","GamepadHapticEffectType","GamepadHapticsResult","GamepadMappingType","Generator","GeneratorFunction","GeneratorFunctionConstructor","GenericTransformStream","Geolocation","GeolocationCoordinates","GeolocationPosition","GeolocationPositionError","GetAnimationsOptions","GetComposedRangesOptions","GetHTMLOptions","GetNotificationOptions","GetRootNodeOptions","Global","GlobalCompositeOperation","GlobalDescriptor","GlobalEventHandlers","GlobalEventHandlersEventMap","HTMLAllCollection","HTMLAnchorElement","HTMLAreaElement","HTMLAudioElement","HTMLBRElement","HTMLBaseElement","HTMLBodyElement","HTMLBodyElementEventMap","HTMLButtonElement","HTMLCanvasElement","HTMLCollection","HTMLCollectionBase","HTMLCollectionOf","HTMLDListElement","HTMLDataElement","HTMLDataListElement","HTMLDetailsElement","HTMLDialogElement","HTMLDirectoryElement","HTMLDivElement","HTMLDocument","HTMLElement","HTMLElementDeprecatedTagNameMap","HTMLElementEventMap","HTMLElementTagNameMap","HTMLEmbedElement","HTMLFieldSetElement","HTMLFontElement","HTMLFormControlsCollection","HTMLFormElement","HTMLFrameElement","HTMLFrameSetElement","HTMLFrameSetElementEventMap","HTMLHRElement","HTMLHeadElement","HTMLHeadingElement","HTMLHtmlElement","HTMLHyperlinkElementUtils","HTMLIFrameElement","HTMLImageElement","HTMLInputElement","HTMLLIElement","HTMLLabelElement","HTMLLegendElement","HTMLLinkElement","HTMLMapElement","HTMLMarqueeElement","HTMLMediaElement","HTMLMediaElementEventMap","HTMLMenuElement","HTMLMetaElement","HTMLMeterElement","HTMLModElement","HTMLOListElement","HTMLObjectElement","HTMLOptGroupElement","HTMLOptionElement","HTMLOptionsCollection","HTMLOrSVGElement","HTMLOrSVGImageElement","HTMLOrSVGScriptElement","HTMLOutputElement","HTMLParagraphElement","HTMLParamElement","HTMLPictureElement","HTMLPreElement","HTMLProgressElement","HTMLQuoteElement","HTMLScriptElement","HTMLSelectElement","HTMLSlotElement","HTMLSourceElement","HTMLSpanElement","HTMLStyleElement","HTMLTableCaptionElement","HTMLTableCellElement","HTMLTableColElement","HTMLTableDataCellElement","HTMLTableElement","HTMLTableHeaderCellElement","HTMLTableRowElement","HTMLTableSectionElement","HTMLTemplateElement","HTMLTextAreaElement","HTMLTimeElement","HTMLTitleElement","HTMLTrackElement","HTMLUListElement","HTMLUnknownElement","HTMLVideoElement","HTMLVideoElementEventMap","HardwareAcceleration","HashAlgorithmIdentifier","HashChangeEvent","HashChangeEventInit","HdrMetadataType","Headers","HeadersInit","HeadersIterator","Highlight","HighlightRegistry","HighlightType","History","HkdfParams","HmacImportParams","HmacKeyAlgorithm","HmacKeyGenParams","IArguments","IDBCursor","IDBCursorDirection","IDBCursorWithValue","IDBDatabase","IDBDatabaseEventMap","IDBDatabaseInfo","IDBFactory","IDBIndex","IDBIndexParameters","IDBKeyRange","IDBObjectStore","IDBObjectStoreParameters","IDBOpenDBRequest","IDBOpenDBRequestEventMap","IDBRequest","IDBRequestEventMap","IDBRequestReadyState","IDBTransaction","IDBTransactionDurability","IDBTransactionEventMap","IDBTransactionMode","IDBTransactionOptions","IDBValidKey","IDBVersionChangeEvent","IDBVersionChangeEventInit","IIRFilterNode","IIRFilterOptions","ITextWriter","IdleDeadline","IdleRequestCallback","IdleRequestOptions","Image","ImageBitmap","ImageBitmapOptions","ImageBitmapRenderingContext","ImageBitmapRenderingContextSettings","ImageBitmapSource","ImageBufferSource","ImageCapture","ImageData","ImageDataArray","ImageDataPixelFormat","ImageDataSettings","ImageDecodeOptions","ImageDecodeResult","ImageDecoder","ImageDecoderInit","ImageEncodeOptions","ImageOrientation","ImageSmoothingQuality","ImageTrack","ImageTrackList","Immediate","ImportAssertions","ImportAttributes","ImportCallOptions","ImportExportKind","ImportMeta","ImportNodeOptions","ImportValue","Imports","Infinity","InputDeviceInfo","InputEvent","InputEventInit","InsertPosition","Instance","InstanceType","Instant","InstantConstructor","InstantLike","InstantToStringOptions","Int16Array","Int16ArrayConstructor","Int32Array","Int32ArrayConstructor","Int32List","Int8Array","Int8ArrayConstructor","IntersectionObserver","IntersectionObserverCallback","IntersectionObserverEntry","IntersectionObserverInit","Intl","Iterable","IterableIterator","IterationCompositeOperation","Iterator","IteratorConstructor","IteratorObject","IteratorObjectConstructor","IteratorResult","IteratorReturnResult","IteratorYieldResult","JSON","JsonWebKey","KHR_parallel_shader_compile","KeyAlgorithm","KeyFormat","KeySystemTrackConfiguration","KeyType","KeyUsage","KeyboardEvent","KeyboardEventInit","Keyframe","KeyframeAnimationOptions","KeyframeEffect","KeyframeEffectOptions","LDMLPluralRule","LargestContentfulPaint","LatencyMode","LineAlignSetting","LineAndPositionSetting","LinkError","LinkStyle","ListFormat","ListFormatLocaleMatcher","ListFormatOptions","ListFormatStyle","ListFormatType","Locale","LocaleCollationCaseFirst","LocaleHourCycleKey","LocaleOptions","LocalesArgument","Location","Lock","LockGrantedCallback","LockInfo","LockManager","LockManagerSnapshot","LockMode","LockOptions","LoginStatus","Lowercase","MIDIAccess","MIDIAccessEventMap","MIDIConnectionEvent","MIDIConnectionEventInit","MIDIInput","MIDIInputEventMap","MIDIInputMap","MIDIMessageEvent","MIDIMessageEventInit","MIDIOptions","MIDIOutput","MIDIOutputMap","MIDIPort","MIDIPortConnectionState","MIDIPortDeviceState","MIDIPortEventMap","MIDIPortType","Map","MapConstructor","MapIterator","Math","MathMLElement","MathMLElementEventMap","MathMLElementTagNameMap","MediaCapabilities","MediaCapabilitiesDecodingInfo","MediaCapabilitiesEncodingInfo","MediaCapabilitiesInfo","MediaCapabilitiesKeySystemConfiguration","MediaConfiguration","MediaDecodingConfiguration","MediaDecodingType","MediaDeviceInfo","MediaDeviceKind","MediaDevices","MediaDevicesEventMap","MediaElementAudioSourceNode","MediaElementAudioSourceOptions","MediaEncodingConfiguration","MediaEncodingType","MediaEncryptedEvent","MediaEncryptedEventInit","MediaError","MediaImage","MediaKeyMessageEvent","MediaKeyMessageEventInit","MediaKeyMessageType","MediaKeySession","MediaKeySessionClosedReason","MediaKeySessionEventMap","MediaKeySessionType","MediaKeyStatus","MediaKeyStatusMap","MediaKeyStatusMapIterator","MediaKeySystemAccess","MediaKeySystemConfiguration","MediaKeySystemMediaCapability","MediaKeys","MediaKeysPolicy","MediaKeysRequirement","MediaList","MediaMetadata","MediaMetadataInit","MediaPositionState","MediaProvider","MediaQueryList","MediaQueryListEvent","MediaQueryListEventInit","MediaQueryListEventMap","MediaRecorder","MediaRecorderEventMap","MediaRecorderOptions","MediaSession","MediaSessionAction","MediaSessionActionDetails","MediaSessionActionHandler","MediaSessionPlaybackState","MediaSettingsRange","MediaSource","MediaSourceEventMap","MediaSourceHandle","MediaStream","MediaStreamAudioDestinationNode","MediaStreamAudioSourceNode","MediaStreamAudioSourceOptions","MediaStreamConstraints","MediaStreamEventMap","MediaStreamTrack","MediaStreamTrackEvent","MediaStreamTrackEventInit","MediaStreamTrackEventMap","MediaStreamTrackProcessor","MediaStreamTrackProcessorInit","MediaStreamTrackState","MediaTrackCapabilities","MediaTrackConstraintSet","MediaTrackConstraints","MediaTrackSettings","MediaTrackSupportedConstraints","Memory","MemoryDescriptor","MessageChannel","MessageEvent","MessageEventInit","MessageEventSource","MessageEventTarget","MessageEventTargetEventMap","MessagePort","MessagePortEventMap","MethodDecorator","MimeType","MimeTypeArray","Module","ModuleExportDescriptor","ModuleImportDescriptor","ModuleImports","MouseEvent","MouseEventInit","MultiCacheQueryOptions","MutationCallback","MutationObserver","MutationObserverInit","MutationRecord","MutationRecordType","NaN","NamedCurve","NamedNodeMap","NavigateEvent","NavigateEventInit","Navigation","NavigationActivation","NavigationCurrentEntryChangeEvent","NavigationCurrentEntryChangeEventInit","NavigationDestination","NavigationEventMap","NavigationFocusReset","NavigationHistoryBehavior","NavigationHistoryEntry","NavigationHistoryEntryEventMap","NavigationInterceptHandler","NavigationInterceptOptions","NavigationNavigateOptions","NavigationOptions","NavigationPrecommitController","NavigationPrecommitHandler","NavigationPreloadManager","NavigationPreloadState","NavigationReloadOptions","NavigationResult","NavigationScrollBehavior","NavigationTimingType","NavigationTransition","NavigationType","NavigationUpdateCurrentEntryOptions","Navigator","NavigatorAutomationInformation","NavigatorBadge","NavigatorConcurrentHardware","NavigatorContentUtils","NavigatorCookies","NavigatorGPU","NavigatorID","NavigatorLanguage","NavigatorLocks","NavigatorLogin","NavigatorOnLine","NavigatorPlugins","NavigatorStorage","NewableFunction","NoInfer","Node","NodeFilter","NodeIterator","NodeJS","NodeList","NodeListOf","NodeModule","NodeRequire","NonDocumentTypeChildNode","NonElementParentNode","NonNullable","Notification","NotificationDirection","NotificationEvent","NotificationEventInit","NotificationEventMap","NotificationOptions","NotificationPermission","NotificationPermissionCallback","Now","Number","NumberConstructor","NumberFormat","NumberFormatConstructor","NumberFormatOptions","NumberFormatOptionsCurrencyDisplay","NumberFormatOptionsCurrencyDisplayRegistry","NumberFormatOptionsSignDisplay","NumberFormatOptionsSignDisplayRegistry","NumberFormatOptionsStyle","NumberFormatOptionsStyleRegistry","NumberFormatOptionsUseGrouping","NumberFormatOptionsUseGroupingRegistry","NumberFormatPart","NumberFormatPartTypeRegistry","NumberFormatPartTypes","NumberFormatRangePartTypeRegistry","NumberFormatRangePartTypes","NumberRangeFormatPart","OES_draw_buffers_indexed","OES_element_index_uint","OES_fbo_render_mipmap","OES_standard_derivatives","OES_texture_float","OES_texture_float_linear","OES_texture_half_float","OES_texture_half_float_linear","OES_vertex_array_object","OVR_multiview2","Object","ObjectConstructor","OfflineAudioCompletionEvent","OfflineAudioCompletionEventInit","OfflineAudioContext","OfflineAudioContextEventMap","OfflineAudioContextOptions","OffscreenCanvas","OffscreenCanvasEventMap","OffscreenCanvasRenderingContext2D","OffscreenRenderingContext","OffscreenRenderingContextId","Omit","OmitThisParameter","OnBeforeUnloadEventHandler","OnBeforeUnloadEventHandlerNonNull","OnErrorEventHandler","OnErrorEventHandlerNonNull","Option","OptionalEffectTiming","OptionalPostfixToken","OptionalPrefixToken","OpusBitstreamFormat","OpusEncoderConfig","OrientationLockType","OrientationType","OscillatorNode","OscillatorOptions","OscillatorType","OverSampleType","OverconstrainedError","OverflowOptions","PageRevealEvent","PageRevealEventInit","PageSwapEvent","PageSwapEventInit","PageTransitionEvent","PageTransitionEventInit","PaintTimingMixin","PannerNode","PannerOptions","PanningModelType","ParameterDecorator","Parameters","ParentNode","Partial","PartialTemporalLike","Path2D","PayerErrors","PaymentAddress","PaymentComplete","PaymentCurrencyAmount","PaymentDetailsBase","PaymentDetailsInit","PaymentDetailsModifier","PaymentDetailsUpdate","PaymentItem","PaymentMethodChangeEvent","PaymentMethodChangeEventInit","PaymentMethodData","PaymentOptions","PaymentRequest","PaymentRequestEventMap","PaymentRequestUpdateEvent","PaymentRequestUpdateEventInit","PaymentResponse","PaymentResponseEventMap","PaymentShippingOption","PaymentShippingType","PaymentValidationErrors","Pbkdf2Params","Performance","PerformanceEntry","PerformanceEntryList","PerformanceEventMap","PerformanceEventTiming","PerformanceMark","PerformanceMarkOptions","PerformanceMeasure","PerformanceMeasureOptions","PerformanceNavigation","PerformanceNavigationTiming","PerformanceObserver","PerformanceObserverCallback","PerformanceObserverEntryList","PerformanceObserverInit","PerformancePaintTiming","PerformanceResourceTiming","PerformanceServerTiming","PerformanceTiming","PeriodicWave","PeriodicWaveConstraints","PeriodicWaveOptions","PermissionDescriptor","PermissionName","PermissionState","PermissionStatus","PermissionStatusEventMap","Permissions","PhotoCapabilities","PhotoSettings","Pick","PictureInPictureEvent","PictureInPictureEventInit","PictureInPictureWindow","PictureInPictureWindowEventMap","PlainDate","PlainDateConstructor","PlainDateLike","PlainDateTime","PlainDateTimeConstructor","PlainDateTimeLike","PlainDateTimeToStringOptions","PlainDateToStringOptions","PlainDateToZonedDateTimeOptions","PlainMonthDay","PlainMonthDayConstructor","PlainMonthDayLike","PlainMonthDayToPlainDateOptions","PlainTime","PlainTimeConstructor","PlainTimeLike","PlainTimeToStringOptions","PlainYearMonth","PlainYearMonthConstructor","PlainYearMonthLike","PlainYearMonthToPlainDateOptions","PlaneLayout","PlaybackDirection","Plugin","PluginArray","PluralRuleType","PluralRules","PluralRulesConstructor","PluralRulesOptions","PluralizeUnit","PointerEvent","PointerEventInit","PointerLockOptions","PopStateEvent","PopStateEventInit","PopoverTargetAttributes","PositionAlignSetting","PositionCallback","PositionErrorCallback","PositionOptions","PredefinedColorSpace","PremultiplyAlpha","PresentationStyle","ProcessingInstruction","ProgressEvent","ProgressEventInit","Promise","PromiseConstructor","PromiseConstructorLike","PromiseFulfilledResult","PromiseLike","PromiseRejectedResult","PromiseRejectionEvent","PromiseRejectionEventInit","PromiseSettledResult","PromiseWithResolvers","PropertyDecorator","PropertyDefinition","PropertyDescriptor","PropertyDescriptorMap","PropertyIndexedKeyframes","PropertyKey","Proxy","ProxyConstructor","ProxyHandler","PublicKeyCredential","PublicKeyCredentialClientCapabilities","PublicKeyCredentialCreationOptions","PublicKeyCredentialCreationOptionsJSON","PublicKeyCredentialDescriptor","PublicKeyCredentialDescriptorJSON","PublicKeyCredentialEntity","PublicKeyCredentialParameters","PublicKeyCredentialRequestOptions","PublicKeyCredentialRequestOptionsJSON","PublicKeyCredentialRpEntity","PublicKeyCredentialType","PublicKeyCredentialUserEntity","PublicKeyCredentialUserEntityJSON","PushEncryptionKeyName","PushEvent","PushEventInit","PushManager","PushManagerAttribute","PushMessageData","PushMessageDataInit","PushSubscription","PushSubscriptionChangeEvent","PushSubscriptionChangeEventInit","PushSubscriptionJSON","PushSubscriptionOptions","PushSubscriptionOptionsInit","QueuingStrategy","QueuingStrategyInit","QueuingStrategySize","RTCAnswerOptions","RTCBundlePolicy","RTCCertificate","RTCCertificateExpiration","RTCConfiguration","RTCDTMFSender","RTCDTMFSenderEventMap","RTCDTMFToneChangeEvent","RTCDTMFToneChangeEventInit","RTCDataChannel","RTCDataChannelEvent","RTCDataChannelEventInit","RTCDataChannelEventMap","RTCDataChannelInit","RTCDataChannelState","RTCDegradationPreference","RTCDtlsFingerprint","RTCDtlsRole","RTCDtlsTransport","RTCDtlsTransportEventMap","RTCDtlsTransportState","RTCEncodedAudioFrame","RTCEncodedAudioFrameMetadata","RTCEncodedFrameMetadata","RTCEncodedVideoFrame","RTCEncodedVideoFrameMetadata","RTCError","RTCErrorDetailType","RTCErrorEvent","RTCErrorEventInit","RTCErrorInit","RTCIceCandidate","RTCIceCandidateInit","RTCIceCandidatePair","RTCIceCandidatePairStats","RTCIceCandidateType","RTCIceComponent","RTCIceConnectionState","RTCIceGathererState","RTCIceGatheringState","RTCIceProtocol","RTCIceRole","RTCIceServer","RTCIceTcpCandidateType","RTCIceTransport","RTCIceTransportEventMap","RTCIceTransportPolicy","RTCIceTransportState","RTCInboundRtpStreamStats","RTCLocalIceCandidateInit","RTCLocalSessionDescriptionInit","RTCOfferAnswerOptions","RTCOfferOptions","RTCOutboundRtpStreamStats","RTCPeerConnection","RTCPeerConnectionErrorCallback","RTCPeerConnectionEventMap","RTCPeerConnectionIceErrorEvent","RTCPeerConnectionIceErrorEventInit","RTCPeerConnectionIceEvent","RTCPeerConnectionIceEventInit","RTCPeerConnectionState","RTCPriorityType","RTCQualityLimitationReason","RTCReceivedRtpStreamStats","RTCRtcpMuxPolicy","RTCRtcpParameters","RTCRtpCapabilities","RTCRtpCodec","RTCRtpCodecParameters","RTCRtpCodingParameters","RTCRtpContributingSource","RTCRtpEncodingParameters","RTCRtpHeaderExtensionCapability","RTCRtpHeaderExtensionParameters","RTCRtpParameters","RTCRtpReceiveParameters","RTCRtpReceiver","RTCRtpReceiverTransform","RTCRtpScriptTransform","RTCRtpScriptTransformer","RTCRtpSendParameters","RTCRtpSender","RTCRtpSenderTransform","RTCRtpStreamStats","RTCRtpSynchronizationSource","RTCRtpTransceiver","RTCRtpTransceiverDirection","RTCRtpTransceiverInit","RTCSctpTransport","RTCSctpTransportEventMap","RTCSctpTransportState","RTCSdpType","RTCSentRtpStreamStats","RTCSessionDescription","RTCSessionDescriptionCallback","RTCSessionDescriptionInit","RTCSetParameterOptions","RTCSignalingState","RTCStats","RTCStatsIceCandidatePairState","RTCStatsReport","RTCStatsType","RTCTrackEvent","RTCTrackEventInit","RTCTransformEvent","RTCTransportStats","RadioNodeList","Range","RangeError","RangeErrorConstructor","ReadableByteStreamController","ReadableStream","ReadableStreamAsyncIterator","ReadableStreamBYOBReader","ReadableStreamBYOBReaderReadOptions","ReadableStreamBYOBRequest","ReadableStreamController","ReadableStreamDefaultController","ReadableStreamDefaultReader","ReadableStreamGenericReader","ReadableStreamGetReaderOptions","ReadableStreamIteratorOptions","ReadableStreamReadDoneResult","ReadableStreamReadResult","ReadableStreamReadValueResult","ReadableStreamReader","ReadableStreamReaderMode","ReadableStreamType","ReadableWritablePair","Readonly","ReadonlyArray","ReadonlyMap","ReadonlySet","ReadonlySetLike","ReadyState","Record","RecordingState","RedEyeReduction","ReferenceError","ReferenceErrorConstructor","ReferrerPolicy","Reflect","RegExp","RegExpConstructor","RegExpExecArray","RegExpIndicesArray","RegExpMatchArray","RegExpStringIterator","RegistrationOptions","RegistrationResponseJSON","RelativeTimeFormat","RelativeTimeFormatLocaleMatcher","RelativeTimeFormatNumeric","RelativeTimeFormatOptions","RelativeTimeFormatPart","RelativeTimeFormatStyle","RelativeTimeFormatUnit","RelativeTimeFormatUnitSingular","RemotePlayback","RemotePlaybackAvailabilityCallback","RemotePlaybackEventMap","RemotePlaybackState","RenderingContext","Report","ReportBody","ReportList","ReportingObserver","ReportingObserverCallback","ReportingObserverOptions","Request","RequestCache","RequestCredentials","RequestDestination","RequestInfo","RequestInit","RequestMode","RequestPriority","RequestRedirect","Required","ResidentKeyRequirement","ResizeObserver","ResizeObserverBoxOptions","ResizeObserverCallback","ResizeObserverEntry","ResizeObserverOptions","ResizeObserverSize","ResizeQuality","ResolvedCollatorOptions","ResolvedDateTimeFormatOptions","ResolvedDisplayNamesOptions","ResolvedDurationFormatOptions","ResolvedListFormatOptions","ResolvedNumberFormatOptions","ResolvedNumberFormatOptionsUseGrouping","ResolvedPluralRulesOptions","ResolvedRelativeTimeFormatOptions","ResolvedSegmenterOptions","Response","ResponseInit","ResponseType","ReturnType","RoundingOptions","RoundingOptionsWithLargestUnit","RsaHashedImportParams","RsaHashedKeyAlgorithm","RsaHashedKeyGenParams","RsaKeyAlgorithm","RsaKeyGenParams","RsaOaepParams","RsaOtherPrimesInfo","RsaPssParams","RuntimeError","SVGAElement","SVGAngle","SVGAnimateElement","SVGAnimateMotionElement","SVGAnimateTransformElement","SVGAnimatedAngle","SVGAnimatedBoolean","SVGAnimatedEnumeration","SVGAnimatedInteger","SVGAnimatedLength","SVGAnimatedLengthList","SVGAnimatedNumber","SVGAnimatedNumberList","SVGAnimatedPoints","SVGAnimatedPreserveAspectRatio","SVGAnimatedRect","SVGAnimatedString","SVGAnimatedTransformList","SVGAnimationElement","SVGBoundingBoxOptions","SVGCircleElement","SVGClipPathElement","SVGComponentTransferFunctionElement","SVGDefsElement","SVGDescElement","SVGElement","SVGElementEventMap","SVGElementTagNameMap","SVGEllipseElement","SVGFEBlendElement","SVGFEColorMatrixElement","SVGFEComponentTransferElement","SVGFECompositeElement","SVGFEConvolveMatrixElement","SVGFEDiffuseLightingElement","SVGFEDisplacementMapElement","SVGFEDistantLightElement","SVGFEDropShadowElement","SVGFEFloodElement","SVGFEFuncAElement","SVGFEFuncBElement","SVGFEFuncGElement","SVGFEFuncRElement","SVGFEGaussianBlurElement","SVGFEImageElement","SVGFEMergeElement","SVGFEMergeNodeElement","SVGFEMorphologyElement","SVGFEOffsetElement","SVGFEPointLightElement","SVGFESpecularLightingElement","SVGFESpotLightElement","SVGFETileElement","SVGFETurbulenceElement","SVGFilterElement","SVGFilterPrimitiveStandardAttributes","SVGFitToViewBox","SVGForeignObjectElement","SVGGElement","SVGGeometryElement","SVGGradientElement","SVGGraphicsElement","SVGImageElement","SVGLength","SVGLengthList","SVGLineElement","SVGLinearGradientElement","SVGMPathElement","SVGMarkerElement","SVGMaskElement","SVGMatrix","SVGMetadataElement","SVGNumber","SVGNumberList","SVGPathElement","SVGPatternElement","SVGPoint","SVGPointList","SVGPolygonElement","SVGPolylineElement","SVGPreserveAspectRatio","SVGRadialGradientElement","SVGRect","SVGRectElement","SVGSVGElement","SVGSVGElementEventMap","SVGScriptElement","SVGSetElement","SVGStopElement","SVGStringList","SVGStyleElement","SVGSwitchElement","SVGSymbolElement","SVGTSpanElement","SVGTests","SVGTextContentElement","SVGTextElement","SVGTextPathElement","SVGTextPositioningElement","SVGTitleElement","SVGTransform","SVGTransformList","SVGURIReference","SVGUnitTypes","SVGUseElement","SVGViewElement","Sanitizer","SanitizerAttribute","SanitizerAttributeNamespace","SanitizerConfig","SanitizerElement","SanitizerElementNamespace","SanitizerElementNamespaceWithAttributes","SanitizerElementWithAttributes","SanitizerPresets","Scheduler","SchedulerPostTaskCallback","SchedulerPostTaskOptions","Screen","ScreenOrientation","ScreenOrientationEventMap","ScriptProcessorNode","ScriptProcessorNodeEventMap","ScrollAxis","ScrollBehavior","ScrollIntoViewOptions","ScrollLogicalPosition","ScrollOptions","ScrollRestoration","ScrollSetting","ScrollTimeline","ScrollTimelineOptions","ScrollToOptions","SecurityPolicyViolationEvent","SecurityPolicyViolationEventDisposition","SecurityPolicyViolationEventInit","SegmentData","SegmentIterator","Segmenter","SegmenterOptions","Segments","Selection","SelectionDirection","SelectionMode","Server","ServerWebSocket","ServiceWorker","ServiceWorkerContainer","ServiceWorkerContainerEventMap","ServiceWorkerEventMap","ServiceWorkerGlobalScope","ServiceWorkerGlobalScopeEventMap","ServiceWorkerRegistration","ServiceWorkerRegistrationEventMap","ServiceWorkerState","ServiceWorkerUpdateViaCache","Set","SetConstructor","SetIterator","ShadowRoot","ShadowRootEventMap","ShadowRootInit","ShadowRootMode","ShareData","SharedArrayBuffer","SharedArrayBufferConstructor","SharedWorker","SharedWorkerGlobalScope","SharedWorkerGlobalScopeEventMap","ShellPromise","ShowPopoverOptions","SlotAssignmentMode","Slottable","Socket","SocketHandler","SourceBuffer","SourceBufferEventMap","SourceBufferList","SourceBufferListEventMap","SpeechRecognitionAlternative","SpeechRecognitionErrorCode","SpeechRecognitionErrorEvent","SpeechRecognitionErrorEventInit","SpeechRecognitionEvent","SpeechRecognitionEventInit","SpeechRecognitionResult","SpeechRecognitionResultList","SpeechSynthesis","SpeechSynthesisErrorCode","SpeechSynthesisErrorEvent","SpeechSynthesisErrorEventInit","SpeechSynthesisEvent","SpeechSynthesisEventInit","SpeechSynthesisEventMap","SpeechSynthesisUtterance","SpeechSynthesisUtteranceEventMap","SpeechSynthesisVoice","StartViewTransitionOptions","StaticRange","StaticRangeInit","Stats","StereoPannerNode","StereoPannerOptions","Storage","StorageEstimate","StorageEvent","StorageEventInit","StorageManager","StreamPipeOptions","String","StringConstructor","StringIterator","StringNumericLiteral","StructuredSerializeOptions","StylePropertyMap","StylePropertyMapReadOnly","StylePropertyMapReadOnlyIterator","StyleSheet","StyleSheetList","SubmitEvent","SubmitEventInit","Subprocess","SubtleCrypto","SuppressedError","SuppressedErrorConstructor","SvcOutputMetadata","Symbol","SymbolConstructor","SyntaxError","SyntaxErrorConstructor","TCPSocket","Table","TableDescriptor","TableKind","Tag","TagType","TaskController","TaskControllerInit","TaskPriority","TaskPriorityChangeEvent","TaskPriorityChangeEventInit","TaskSignal","TaskSignalAnyInit","TaskSignalEventMap","TemplateStringsArray","Temporal","TexImageSource","Text","TextDecodeOptions","TextDecoder","TextDecoderCommon","TextDecoderOptions","TextDecoderStream","TextEncoder","TextEncoderCommon","TextEncoderEncodeIntoResult","TextEncoderStream","TextEvent","TextInfo","TextMetrics","TextStreamBase","TextStreamReader","TextStreamWriter","TextTrack","TextTrackCue","TextTrackCueEventMap","TextTrackCueList","TextTrackEventMap","TextTrackKind","TextTrackList","TextTrackListEventMap","TextTrackMode","ThisParameterType","ThisType","TimeLikeObject","TimeRanges","TimeUnit","TimeZoneLike","TimelineRangeOffset","Timeout","Timer","TimerHandler","ToStringRoundingOptions","ToStringRoundingOptionsWithFractionalSeconds","ToggleEvent","ToggleEventInit","TogglePopoverOptions","Touch","TouchEvent","TouchEventInit","TouchInit","TouchList","TouchType","TrackEvent","TrackEventInit","TransferFunction","Transferable","TransformStream","TransformStreamDefaultController","Transformer","TransformerFlushCallback","TransformerStartCallback","TransformerTransformCallback","TransitionEvent","TransitionEventInit","TransitionOptions","TreeWalker","TypeError","TypeErrorConstructor","TypedArray","TypedPropertyDescriptor","UIEvent","UIEventInit","ULongRange","URIError","URIErrorConstructor","URL","URLPattern","URLPatternComponentResult","URLPatternInit","URLPatternInput","URLPatternOptions","URLPatternResult","URLSearchParams","URLSearchParamsIterator","Uint16Array","Uint16ArrayConstructor","Uint32Array","Uint32ArrayConstructor","Uint32List","Uint8Array","Uint8ArrayConstructor","Uint8ClampedArray","Uint8ClampedArrayConstructor","Uncapitalize","UnderlyingByteSource","UnderlyingDefaultSource","UnderlyingSink","UnderlyingSinkAbortCallback","UnderlyingSinkCloseCallback","UnderlyingSinkStartCallback","UnderlyingSinkWriteCallback","UnderlyingSource","UnderlyingSourceCancelCallback","UnderlyingSourcePullCallback","UnderlyingSourceStartCallback","UnicodeBCP47LocaleIdentifier","UnknownCredentialOptions","Uppercase","UserActivation","UserVerificationRequirement","VBArray","VBArrayConstructor","VTTCue","VTTRegion","ValidityState","ValidityStateFlags","ValueType","ValueTypeMap","VibratePattern","VideoColorPrimaries","VideoColorSpace","VideoColorSpaceInit","VideoConfiguration","VideoDecoder","VideoDecoderConfig","VideoDecoderEventMap","VideoDecoderInit","VideoDecoderSupport","VideoEncoder","VideoEncoderBitrateMode","VideoEncoderConfig","VideoEncoderEncodeOptions","VideoEncoderEncodeOptionsForAvc","VideoEncoderEventMap","VideoEncoderInit","VideoEncoderSupport","VideoFacingModeEnum","VideoFrame","VideoFrameBufferInit","VideoFrameCallbackMetadata","VideoFrameCopyToOptions","VideoFrameInit","VideoFrameOutputCallback","VideoFrameRequestCallback","VideoMatrixCoefficients","VideoPixelFormat","VideoPlaybackQuality","VideoTransferCharacteristics","ViewTimeline","ViewTimelineOptions","ViewTransition","ViewTransitionTypeSet","ViewTransitionUpdateCallback","VisualViewport","VisualViewportEventMap","VoidFunction","WEBGL_color_buffer_float","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb","WEBGL_debug_renderer_info","WEBGL_debug_shaders","WEBGL_depth_texture","WEBGL_draw_buffers","WEBGL_lose_context","WEBGL_multi_draw","WGSLLanguageFeatures","WSH","WScript","WakeLock","WakeLockSentinel","WakeLockSentinelEventMap","WakeLockType","WaveShaperNode","WaveShaperOptions","WeakKey","WeakKeyTypes","WeakMap","WeakMapConstructor","WeakRef","WeakRefConstructor","WeakSet","WeakSetConstructor","WebAssembly","WebAssemblyCompileOptions","WebAssemblyInstantiatedSource","WebCodecsErrorCallback","WebGL2RenderingContext","WebGL2RenderingContextBase","WebGL2RenderingContextOverloads","WebGLActiveInfo","WebGLBuffer","WebGLContextAttributes","WebGLContextEvent","WebGLContextEventInit","WebGLFramebuffer","WebGLPowerPreference","WebGLProgram","WebGLQuery","WebGLRenderbuffer","WebGLRenderingContext","WebGLRenderingContextBase","WebGLRenderingContextOverloads","WebGLSampler","WebGLShader","WebGLShaderPrecisionFormat","WebGLSync","WebGLTexture","WebGLTransformFeedback","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES","WebKitCSSMatrix","WebSocket","WebSocketEventMap","WebSocketHandler","WebTransport","WebTransportBidirectionalStream","WebTransportCloseInfo","WebTransportCongestionControl","WebTransportDatagramDuplexStream","WebTransportError","WebTransportErrorOptions","WebTransportErrorSource","WebTransportHash","WebTransportOptions","WebTransportSendOptions","WebTransportSendStreamOptions","WeekInfo","WheelEvent","WheelEventInit","Window","WindowClient","WindowEventHandlers","WindowEventHandlersEventMap","WindowEventMap","WindowLocalStorage","WindowOrWorkerGlobalScope","WindowPostMessageOptions","WindowProxy","WindowSessionStorage","WithImplicitCoercion","Worker","WorkerEventMap","WorkerGlobalScope","WorkerGlobalScopeEventMap","WorkerLocation","WorkerNavigator","WorkerOptions","WorkerType","Worklet","WorkletOptions","WritableStream","WritableStreamDefaultController","WritableStreamDefaultWriter","WriteCommandType","WriteParams","XMLDocument","XMLHttpRequest","XMLHttpRequestBodyInit","XMLHttpRequestEventMap","XMLHttpRequestEventTarget","XMLHttpRequestEventTargetEventMap","XMLHttpRequestResponseType","XMLHttpRequestUpload","XMLSerializer","XPathEvaluator","XPathEvaluatorBase","XPathExpression","XPathNSResolver","XPathResult","XSLTProcessor","YearMonthLikeObject","ZonedDateTime","ZonedDateTimeConstructor","ZonedDateTimeFromOptions","ZonedDateTimeLike","ZonedDateTimeLikeObject","ZonedDateTimeToStringOptions","global","globalThis","process","structuredClone"])});function Du(e,t={strings:!0}){let i="",r=0;while(r<e.length){let n=e.slice(r,r+2);if(n==="//"){let s=e.indexOf(`
226
+ `:"")+"Entrypoints are resolved relative to --root. Pass several by repeating --entrypoints or separating them with commas.";if(t.length===0){if(e.entrypoints.filter((o)=>bo(o)&&Au(o)&&!Gt(o,i)).length===e.entrypoints.length)return;throw Error(`No source files matched. Nothing was generated.
227
+ ${r}`)}let n=e.entrypoints.filter((o)=>{if(yy.test(o))return!1;return!Au(bo(o)?o:ti(i,o))});if(n.length>0)throw Error(`Entrypoint${n.length>1?"s":""} not found: ${n.map((o)=>JSON.stringify(o)).join(", ")}
228
+ ${r}`)}async function Cy(e){let t=[],i=ti(e.cwd,e.root),r=e.exclude||[],n=[...e.entrypoints,...e.include??[]];for(let o of n)if(bo(o)&&ka(o)){if(!o.includes("node_modules")){if(!Gt(o,i)&&e.outputStructure!=="flat")le.warn(`Skipping entrypoint outside root: ${ei(e.cwd,o)}`);else if(!Wr(o,r,i))t.push(o)}}else{let s=new Tu(o);for await(let l of s.scan({cwd:i,absolute:!0,onlyFiles:!0}))if(ka(l)&&!l.includes("node_modules")){if(!Wr(l,r,i))t.push(l)}}return[...new Set(t.map((o)=>ti(o)))].sort()}function Gt(e,t){let i=ei(t,e);return i!==".."&&!i.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!bo(i)}function vy(e,t){let i=new Map,r=new Map;for(let n of e){let o=er(n,t),s=i.get(o);if(s&&s!==n)throw Error(`Output path collision: ${ei(t.cwd,s)} and ${ei(t.cwd,n)} both emit ${ei(t.cwd,o)}`);i.set(o,n),r.set(n,o)}return r}function ka(e){return/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/.test(e)&&!/\.d\.(?:ts|mts|cts)$/.test(e)}function er(e,t){let i=ti(t.cwd,t.root),r=ei(i,e),n=/\.d\.(?:ts|mts|cts)$/.test(r)?r:r.replace(/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/,(o)=>{if(o===".mts"||o===".mjs")return".d.mts";if(o===".cts"||o===".cjs")return".d.cts";return".d.ts"});if(t.outputStructure==="mirror")return ti(t.cwd,t.outdir,n);else{let o=hy(n);return ti(t.cwd,t.outdir,o)}}function by(e,t,i=""){let r=ei(py(e),t).replace(/\\/g,"/");if(r=r.replace(/\.d\.mts$/,"").replace(/\.d\.cts$/,"").replace(/\.d\.ts$/,""),i)r+=i;if(!r.startsWith("."))r=`./${r}`;return r}function Ru(e,t,i,r){let n=er(e,t);return(o)=>{let s=i(o,e);if(!s.isRelative||!s.resolved)return{kind:"unchanged",reason:s.isRelative?"unresolved":"external",specifier:o,emittedSpecifier:o};if(/\.d\.(?:ts|mts|cts)$/.test(s.resolved)){if(t.moduleSpecifierMode!=="node")return{kind:"unchanged",reason:"preserved-declaration",specifier:o,emittedSpecifier:o};if(r&&!r.has(s.resolved))throw Error(`Local declaration ${JSON.stringify(o)} from ${e} targets an authored declaration not emitted by this package build: ${s.resolved}. Declaration-only dependencies must be delivered with the package before this importer can be emitted.`)}if(s.isAlias&&r&&!r.has(s.resolved))throw Error(`Local alias ${JSON.stringify(o)} from ${e} targets a declaration excluded from this package build: ${s.resolved}`);if(r&&!r.has(s.resolved)&&Wr(s.resolved,t.exclude??[],ti(t.cwd,t.root)))throw Error(`Local reference ${JSON.stringify(o)} from ${e} targets a source excluded from this package build: ${s.resolved}`);let l=s.isAlias?s.suffix??"":o.match(/[?#].*$/)?.[0]??"",a=l?o.slice(0,-l.length):o,f=ku(a),u=/^(?:\.js|\.jsx|\.mjs|\.cjs)$/.test(f)?f:"";if(!u&&t.moduleSpecifierMode==="node"){let h=ku(s.resolved);u=h===".mts"||h===".mjs"?".mjs":h===".cts"||h===".cjs"?".cjs":".js"}let d=er(s.resolved,t);return{kind:"local",specifier:o,resolvedSource:s.resolved,declarationOutput:d,emittedSpecifier:by(n,d,u)+l}}}var Tu,my=50,Fr,yy;var Ta=me(()=>{Dc();In();Wn();({Glob:Tu}=globalThis.Bun);Fr=new Map;yy=/[*?[\]{}!]/});var Pu;var Mu=me(()=>{Pu=new Set(["ANGLE_instanced_arrays","ARIAMixin","AacBitstreamFormat","AacEncoderConfig","AbortController","AbortSignal","AbortSignalEventMap","AbstractRange","AbstractWorker","AbstractWorkerEventMap","ActiveXObject","AddEventListenerOptions","AddressErrors","AddressType","AddressValue","AesCbcParams","AesCtrParams","AesDerivedKeyParams","AesGcmParams","AesKeyAlgorithm","AesKeyGenParams","AggregateError","AggregateErrorConstructor","Algorithm","AlgorithmIdentifier","AlignSetting","AllAcceptedCredentialsOptions","AllowSharedBufferSource","AlphaOption","AnalyserNode","AnalyserOptions","Animatable","Animation","AnimationEffect","AnimationEvent","AnimationEventInit","AnimationEventMap","AnimationFrameProvider","AnimationPlayState","AnimationPlaybackEvent","AnimationPlaybackEventInit","AnimationReplaceState","AnimationTimeline","AppendMode","Array","ArrayBuffer","ArrayBufferConstructor","ArrayBufferLike","ArrayBufferTypes","ArrayBufferView","ArrayConstructor","ArrayIterator","ArrayLike","AssignedNodesOptions","AsyncDisposable","AsyncDisposableStack","AsyncDisposableStackConstructor","AsyncGenerator","AsyncGeneratorFunction","AsyncGeneratorFunctionConstructor","AsyncIterable","AsyncIterableIterator","AsyncIterator","AsyncIteratorObject","Atomics","AttestationConveyancePreference","Attr","Audio","AudioBuffer","AudioBufferOptions","AudioBufferSourceNode","AudioBufferSourceOptions","AudioConfiguration","AudioContext","AudioContextLatencyCategory","AudioContextOptions","AudioContextState","AudioData","AudioDataCopyToOptions","AudioDataInit","AudioDataOutputCallback","AudioDecoder","AudioDecoderConfig","AudioDecoderEventMap","AudioDecoderInit","AudioDecoderSupport","AudioDestinationNode","AudioEncoder","AudioEncoderConfig","AudioEncoderEventMap","AudioEncoderInit","AudioEncoderSupport","AudioListener","AudioNode","AudioNodeOptions","AudioParam","AudioParamMap","AudioProcessingEvent","AudioProcessingEventInit","AudioSampleFormat","AudioScheduledSourceNode","AudioScheduledSourceNodeEventMap","AudioTimestamp","AudioWorklet","AudioWorkletNode","AudioWorkletNodeEventMap","AudioWorkletNodeOptions","AuthenticationExtensionsClientInputs","AuthenticationExtensionsClientInputsJSON","AuthenticationExtensionsClientOutputs","AuthenticationExtensionsClientOutputsJSON","AuthenticationExtensionsLargeBlobInputs","AuthenticationExtensionsLargeBlobInputsJSON","AuthenticationExtensionsLargeBlobOutputs","AuthenticationExtensionsLargeBlobOutputsJSON","AuthenticationExtensionsPRFInputs","AuthenticationExtensionsPRFInputsJSON","AuthenticationExtensionsPRFOutputs","AuthenticationExtensionsPRFOutputsJSON","AuthenticationExtensionsPRFValues","AuthenticationExtensionsPRFValuesJSON","AuthenticationResponseJSON","AuthenticatorAssertionResponse","AuthenticatorAssertionResponseJSON","AuthenticatorAttachment","AuthenticatorAttestationResponse","AuthenticatorAttestationResponseJSON","AuthenticatorResponse","AuthenticatorSelectionCriteria","AuthenticatorTransport","AutoFill","AutoFillAddressKind","AutoFillBase","AutoFillContactField","AutoFillContactKind","AutoFillCredentialField","AutoFillField","AutoFillNormalField","AutoFillSection","AutoKeyword","AutomationRate","AvcBitstreamFormat","AvcEncoderConfig","Awaited","BarProp","Base64URLString","BaseAudioContext","BaseAudioContextEventMap","BeforeUnloadEvent","BigInt","BigInt64Array","BigInt64ArrayConstructor","BigIntConstructor","BigIntToLocaleStringOptions","BigInteger","BigUint64Array","BigUint64ArrayConstructor","BinaryType","BiquadFilterNode","BiquadFilterOptions","BiquadFilterType","BitrateMode","Blob","BlobCallback","BlobEvent","BlobEventInit","BlobPart","BlobPropertyBag","Body","BodyInit","Boolean","BooleanConstructor","BroadcastChannel","BroadcastChannelEventMap","Buffer","BufferEncoding","BufferSource","BuiltinIteratorReturn","Bun","BunFile","ByteLengthQueuingStrategy","CDATASection","COSEAlgorithmIdentifier","CSS","CSSAnimation","CSSConditionRule","CSSContainerRule","CSSCounterStyleRule","CSSFontFaceRule","CSSFontFeatureValuesRule","CSSFontPaletteValuesRule","CSSGroupingRule","CSSImageValue","CSSImportRule","CSSKeyframeRule","CSSKeyframesRule","CSSKeywordValue","CSSKeywordish","CSSLayerBlockRule","CSSLayerStatementRule","CSSMathClamp","CSSMathInvert","CSSMathMax","CSSMathMin","CSSMathNegate","CSSMathOperator","CSSMathProduct","CSSMathSum","CSSMathValue","CSSMatrixComponent","CSSMatrixComponentOptions","CSSMediaRule","CSSNamespaceRule","CSSNestedDeclarations","CSSNumberish","CSSNumericArray","CSSNumericBaseType","CSSNumericType","CSSNumericValue","CSSPageDescriptors","CSSPageRule","CSSPerspective","CSSPerspectiveValue","CSSPositionTryDescriptors","CSSPositionTryRule","CSSPropertyRule","CSSRotate","CSSRule","CSSRuleList","CSSScale","CSSScopeRule","CSSSkew","CSSSkewX","CSSSkewY","CSSStartingStyleRule","CSSStyleDeclaration","CSSStyleDeclarationBase","CSSStyleProperties","CSSStyleRule","CSSStyleSheet","CSSStyleSheetInit","CSSStyleValue","CSSSupportsRule","CSSTransformComponent","CSSTransformValue","CSSTransition","CSSTranslate","CSSUnitValue","CSSUnparsedSegment","CSSUnparsedValue","CSSVariableReferenceValue","CSSViewTransitionRule","Cache","CacheQueryOptions","CacheStorage","CalendarLike","CallableFunction","CanPlayTypeResult","CanvasCaptureMediaStreamTrack","CanvasCompositing","CanvasDirection","CanvasDrawImage","CanvasDrawPath","CanvasFillRule","CanvasFillStrokeStyles","CanvasFilters","CanvasFontKerning","CanvasFontStretch","CanvasFontVariantCaps","CanvasGradient","CanvasImageData","CanvasImageSmoothing","CanvasImageSource","CanvasLineCap","CanvasLineJoin","CanvasPath","CanvasPathDrawingStyles","CanvasPattern","CanvasRect","CanvasRenderingContext2D","CanvasRenderingContext2DSettings","CanvasSettings","CanvasShadowStyles","CanvasState","CanvasText","CanvasTextAlign","CanvasTextBaseline","CanvasTextDrawingStyles","CanvasTextRendering","CanvasTransform","CanvasUserInterface","Capitalize","CaretPosition","CaretPositionFromPointOptions","ChannelCountMode","ChannelInterpretation","ChannelMergerNode","ChannelMergerOptions","ChannelSplitterNode","ChannelSplitterOptions","CharacterData","CheckVisibilityOptions","ChildNode","ClassAccessorDecoratorContext","ClassAccessorDecoratorResult","ClassAccessorDecoratorTarget","ClassDecorator","ClassDecoratorContext","ClassFieldDecoratorContext","ClassGetterDecoratorContext","ClassMemberDecoratorContext","ClassMethodDecoratorContext","ClassSetterDecoratorContext","Client","ClientQueryOptions","ClientRect","ClientTypes","Clients","Clipboard","ClipboardEvent","ClipboardEventInit","ClipboardItem","ClipboardItemData","ClipboardItemOptions","ClipboardItems","CloseEvent","CloseEventInit","CodecState","Collator","CollatorConstructor","CollatorOptions","ColorGamut","ColorSpaceConversion","CommandEvent","CommandEventInit","Comment","CompileError","CompositeOperation","CompositeOperationOrAuto","CompositionEvent","CompositionEventInit","CompressionFormat","CompressionStream","ComputedEffectTiming","ComputedKeyframe","ConcatArray","Console","ConstantSourceNode","ConstantSourceOptions","ConstrainBoolean","ConstrainBooleanOrDOMString","ConstrainBooleanOrDOMStringParameters","ConstrainBooleanParameters","ConstrainDOMString","ConstrainDOMStringParameters","ConstrainDouble","ConstrainDoubleRange","ConstrainULong","ConstrainULongRange","ConstructorParameters","ContentVisibilityAutoStateChangeEvent","ContentVisibilityAutoStateChangeEventInit","ConvolverNode","ConvolverOptions","CookieChangeEvent","CookieChangeEventInit","CookieInit","CookieList","CookieListItem","CookieSameSite","CookieStore","CookieStoreDeleteOptions","CookieStoreEventMap","CookieStoreGetOptions","CookieStoreManager","CountQueuingStrategy","Credential","CredentialCreationOptions","CredentialMediationRequirement","CredentialPropertiesOutput","CredentialRequestOptions","CredentialsContainer","Crypto","CryptoKey","CryptoKeyPair","CurrentUserDetailsOptions","CustomElementConstructor","CustomElementRegistry","CustomEvent","CustomEventInit","CustomStateSet","DOMException","DOMHighResTimeStamp","DOMImplementation","DOMMatrix","DOMMatrix2DInit","DOMMatrixInit","DOMMatrixReadOnly","DOMParser","DOMParserSupportedType","DOMPoint","DOMPointInit","DOMPointReadOnly","DOMQuad","DOMQuadInit","DOMRect","DOMRectInit","DOMRectList","DOMRectReadOnly","DOMStringList","DOMStringMap","DOMTokenList","DataTransfer","DataTransferItem","DataTransferItemList","DataView","DataViewConstructor","Date","DateConstructor","DateLikeObject","DateTimeFormat","DateTimeFormatConstructor","DateTimeFormatOptions","DateTimeFormatPart","DateTimeFormatPartTypes","DateTimeFormatPartTypesRegistry","DateTimeLikeObject","DateTimeRangeFormatPart","DateUnit","DecodeErrorCallback","DecodeSuccessCallback","DecompressionStream","DecoratorContext","DecoratorMetadata","DecoratorMetadataObject","DedicatedWorkerGlobalScope","DedicatedWorkerGlobalScopeEventMap","DelayNode","DelayOptions","DeviceMotionEvent","DeviceMotionEventAcceleration","DeviceMotionEventAccelerationInit","DeviceMotionEventInit","DeviceMotionEventRotationRate","DeviceMotionEventRotationRateInit","DeviceOrientationEvent","DeviceOrientationEventInit","DigitalCredential","DirectionSetting","Dirent","DisambiguationOptions","DisplayCaptureSurfaceType","DisplayMediaStreamOptions","DisplayNames","DisplayNamesFallback","DisplayNamesLanguageDisplay","DisplayNamesOptions","DisplayNamesType","Disposable","DisposableStack","DisposableStackConstructor","DistanceModelType","Document","DocumentEventMap","DocumentFragment","DocumentOrShadowRoot","DocumentReadyState","DocumentTimeline","DocumentTimelineOptions","DocumentType","DocumentVisibilityState","DoubleRange","DragEvent","DragEventInit","Duration","DurationConstructor","DurationFormat","DurationFormatDisplayOption","DurationFormatLocaleMatcher","DurationFormatOptions","DurationFormatPart","DurationFormatStyle","DurationFormatUnit","DurationFormatUnitSingular","DurationLike","DurationLikeObject","DurationRelativeToOptions","DurationRoundingOptions","DurationToStringOptions","DurationTotalOptions","DynamicsCompressorNode","DynamicsCompressorOptions","EXT_blend_minmax","EXT_color_buffer_float","EXT_color_buffer_half_float","EXT_float_blend","EXT_frag_depth","EXT_sRGB","EXT_shader_texture_lod","EXT_texture_compression_bptc","EXT_texture_compression_rgtc","EXT_texture_filter_anisotropic","EXT_texture_norm16","EcKeyAlgorithm","EcKeyGenParams","EcKeyImportParams","EcdhKeyDeriveParams","EcdsaParams","EffectTiming","Element","ElementCSSInlineStyle","ElementContentEditable","ElementCreationOptions","ElementDefinitionOptions","ElementEventMap","ElementInternals","ElementTagNameMap","EncodedAudioChunk","EncodedAudioChunkInit","EncodedAudioChunkMetadata","EncodedAudioChunkOutputCallback","EncodedAudioChunkType","EncodedVideoChunk","EncodedVideoChunkInit","EncodedVideoChunkMetadata","EncodedVideoChunkOutputCallback","EncodedVideoChunkType","EndOfStreamError","EndingType","Enumerator","EnumeratorConstructor","EpochTimeStamp","Error","ErrorCallback","ErrorConstructor","ErrorEvent","ErrorEventInit","ErrorOptions","EvalError","EvalErrorConstructor","Event","EventCounts","EventInit","EventListener","EventListenerObject","EventListenerOptions","EventListenerOrEventListenerObject","EventModifierInit","EventSource","EventSourceEventMap","EventSourceInit","EventTarget","Exception","ExceptionOptions","Exclude","ExportValue","Exports","ExtendableCookieChangeEvent","ExtendableCookieChangeEventInit","ExtendableEvent","ExtendableEventInit","ExtendableMessageEvent","ExtendableMessageEventInit","External","Extract","FetchEvent","FetchEventInit","File","FileCallback","FileList","FilePropertyBag","FileReader","FileReaderEventMap","FileReaderSync","FileSink","FileSystem","FileSystemCreateWritableOptions","FileSystemDirectoryEntry","FileSystemDirectoryHandle","FileSystemDirectoryHandleAsyncIterator","FileSystemDirectoryReader","FileSystemEntriesCallback","FileSystemEntry","FileSystemEntryCallback","FileSystemFileEntry","FileSystemFileHandle","FileSystemFlags","FileSystemGetDirectoryOptions","FileSystemGetFileOptions","FileSystemHandle","FileSystemHandleKind","FileSystemReadWriteOptions","FileSystemRemoveOptions","FileSystemSyncAccessHandle","FileSystemWritableFileStream","FileSystemWriteChunkType","FillLightMode","FillMode","FinalizationRegistry","FinalizationRegistryConstructor","FlatArray","Float16Array","Float16ArrayConstructor","Float32Array","Float32ArrayConstructor","Float32List","Float64Array","Float64ArrayConstructor","FocusEvent","FocusEventInit","FocusOptions","FontDisplay","FontFace","FontFaceDescriptors","FontFaceLoadStatus","FontFaceSet","FontFaceSetEventMap","FontFaceSetLoadEvent","FontFaceSetLoadEventInit","FontFaceSetLoadStatus","FontFaceSource","FormData","FormDataEntryValue","FormDataEvent","FormDataEventInit","FormDataIterator","FormattableTemporalObject","FragmentDirective","FrameRequestCallback","FrameType","FullscreenNavigationUI","FullscreenOptions","Function","FunctionConstructor","FunctionStringCallback","GLbitfield","GLboolean","GLclampf","GLenum","GLfloat","GLint","GLint64","GLintptr","GLsizei","GLsizeiptr","GLuint","GLuint64","GPU","GPUAdapter","GPUAdapterInfo","GPUAddressMode","GPUAutoLayoutMode","GPUBindGroup","GPUBindGroupDescriptor","GPUBindGroupEntry","GPUBindGroupLayout","GPUBindGroupLayoutDescriptor","GPUBindGroupLayoutEntry","GPUBindingCommandsMixin","GPUBindingResource","GPUBlendComponent","GPUBlendFactor","GPUBlendOperation","GPUBlendState","GPUBuffer","GPUBufferBinding","GPUBufferBindingLayout","GPUBufferBindingType","GPUBufferDescriptor","GPUBufferDynamicOffset","GPUBufferMapState","GPUBufferUsageFlags","GPUCanvasAlphaMode","GPUCanvasConfiguration","GPUCanvasContext","GPUCanvasToneMapping","GPUCanvasToneMappingMode","GPUColor","GPUColorDict","GPUColorTargetState","GPUColorWriteFlags","GPUCommandBuffer","GPUCommandBufferDescriptor","GPUCommandEncoder","GPUCommandEncoderDescriptor","GPUCompareFunction","GPUCompilationInfo","GPUCompilationMessage","GPUCompilationMessageType","GPUComputePassDescriptor","GPUComputePassEncoder","GPUComputePassTimestampWrites","GPUComputePipeline","GPUComputePipelineDescriptor","GPUCopyExternalImageDestInfo","GPUCopyExternalImageSource","GPUCopyExternalImageSourceInfo","GPUCullMode","GPUDebugCommandsMixin","GPUDepthBias","GPUDepthStencilState","GPUDevice","GPUDeviceDescriptor","GPUDeviceEventMap","GPUDeviceLostInfo","GPUDeviceLostReason","GPUError","GPUErrorFilter","GPUExtent3D","GPUExtent3DDict","GPUExternalTexture","GPUExternalTextureBindingLayout","GPUExternalTextureDescriptor","GPUFeatureName","GPUFilterMode","GPUFlagsConstant","GPUFragmentState","GPUFrontFace","GPUIndex32","GPUIndexFormat","GPUIntegerCoordinate","GPUIntegerCoordinateOut","GPUInternalError","GPULoadOp","GPUMapModeFlags","GPUMipmapFilterMode","GPUMultisampleState","GPUObjectBase","GPUObjectDescriptorBase","GPUOrigin2D","GPUOrigin2DDict","GPUOrigin3D","GPUOrigin3DDict","GPUOutOfMemoryError","GPUPipelineBase","GPUPipelineConstantValue","GPUPipelineDescriptorBase","GPUPipelineError","GPUPipelineErrorInit","GPUPipelineErrorReason","GPUPipelineLayout","GPUPipelineLayoutDescriptor","GPUPowerPreference","GPUPrimitiveState","GPUPrimitiveTopology","GPUProgrammableStage","GPUQuerySet","GPUQuerySetDescriptor","GPUQueryType","GPUQueue","GPUQueueDescriptor","GPURenderBundle","GPURenderBundleDescriptor","GPURenderBundleEncoder","GPURenderBundleEncoderDescriptor","GPURenderCommandsMixin","GPURenderPassColorAttachment","GPURenderPassDepthStencilAttachment","GPURenderPassDescriptor","GPURenderPassEncoder","GPURenderPassLayout","GPURenderPassTimestampWrites","GPURenderPipeline","GPURenderPipelineDescriptor","GPURequestAdapterOptions","GPUSampleMask","GPUSampler","GPUSamplerBindingLayout","GPUSamplerBindingType","GPUSamplerDescriptor","GPUShaderModule","GPUShaderModuleDescriptor","GPUShaderStageFlags","GPUSignedOffset32","GPUSize32","GPUSize32Out","GPUSize64","GPUSize64Out","GPUStencilFaceState","GPUStencilOperation","GPUStencilValue","GPUStorageTextureAccess","GPUStorageTextureBindingLayout","GPUStoreOp","GPUSupportedFeatures","GPUSupportedLimits","GPUTexelCopyBufferInfo","GPUTexelCopyBufferLayout","GPUTexelCopyTextureInfo","GPUTexture","GPUTextureAspect","GPUTextureBindingLayout","GPUTextureDescriptor","GPUTextureDimension","GPUTextureFormat","GPUTextureSampleType","GPUTextureUsageFlags","GPUTextureView","GPUTextureViewDescriptor","GPUTextureViewDimension","GPUUncapturedErrorEvent","GPUUncapturedErrorEventInit","GPUValidationError","GPUVertexAttribute","GPUVertexBufferLayout","GPUVertexFormat","GPUVertexState","GPUVertexStepMode","GainNode","GainOptions","Gamepad","GamepadButton","GamepadEffectParameters","GamepadEvent","GamepadEventInit","GamepadHapticActuator","GamepadHapticEffectType","GamepadHapticsResult","GamepadMappingType","Generator","GeneratorFunction","GeneratorFunctionConstructor","GenericTransformStream","Geolocation","GeolocationCoordinates","GeolocationPosition","GeolocationPositionError","GetAnimationsOptions","GetComposedRangesOptions","GetHTMLOptions","GetNotificationOptions","GetRootNodeOptions","Global","GlobalCompositeOperation","GlobalDescriptor","GlobalEventHandlers","GlobalEventHandlersEventMap","HTMLAllCollection","HTMLAnchorElement","HTMLAreaElement","HTMLAudioElement","HTMLBRElement","HTMLBaseElement","HTMLBodyElement","HTMLBodyElementEventMap","HTMLButtonElement","HTMLCanvasElement","HTMLCollection","HTMLCollectionBase","HTMLCollectionOf","HTMLDListElement","HTMLDataElement","HTMLDataListElement","HTMLDetailsElement","HTMLDialogElement","HTMLDirectoryElement","HTMLDivElement","HTMLDocument","HTMLElement","HTMLElementDeprecatedTagNameMap","HTMLElementEventMap","HTMLElementTagNameMap","HTMLEmbedElement","HTMLFieldSetElement","HTMLFontElement","HTMLFormControlsCollection","HTMLFormElement","HTMLFrameElement","HTMLFrameSetElement","HTMLFrameSetElementEventMap","HTMLHRElement","HTMLHeadElement","HTMLHeadingElement","HTMLHtmlElement","HTMLHyperlinkElementUtils","HTMLIFrameElement","HTMLImageElement","HTMLInputElement","HTMLLIElement","HTMLLabelElement","HTMLLegendElement","HTMLLinkElement","HTMLMapElement","HTMLMarqueeElement","HTMLMediaElement","HTMLMediaElementEventMap","HTMLMenuElement","HTMLMetaElement","HTMLMeterElement","HTMLModElement","HTMLOListElement","HTMLObjectElement","HTMLOptGroupElement","HTMLOptionElement","HTMLOptionsCollection","HTMLOrSVGElement","HTMLOrSVGImageElement","HTMLOrSVGScriptElement","HTMLOutputElement","HTMLParagraphElement","HTMLParamElement","HTMLPictureElement","HTMLPreElement","HTMLProgressElement","HTMLQuoteElement","HTMLScriptElement","HTMLSelectElement","HTMLSlotElement","HTMLSourceElement","HTMLSpanElement","HTMLStyleElement","HTMLTableCaptionElement","HTMLTableCellElement","HTMLTableColElement","HTMLTableDataCellElement","HTMLTableElement","HTMLTableHeaderCellElement","HTMLTableRowElement","HTMLTableSectionElement","HTMLTemplateElement","HTMLTextAreaElement","HTMLTimeElement","HTMLTitleElement","HTMLTrackElement","HTMLUListElement","HTMLUnknownElement","HTMLVideoElement","HTMLVideoElementEventMap","HardwareAcceleration","HashAlgorithmIdentifier","HashChangeEvent","HashChangeEventInit","HdrMetadataType","Headers","HeadersInit","HeadersIterator","Highlight","HighlightRegistry","HighlightType","History","HkdfParams","HmacImportParams","HmacKeyAlgorithm","HmacKeyGenParams","IArguments","IDBCursor","IDBCursorDirection","IDBCursorWithValue","IDBDatabase","IDBDatabaseEventMap","IDBDatabaseInfo","IDBFactory","IDBIndex","IDBIndexParameters","IDBKeyRange","IDBObjectStore","IDBObjectStoreParameters","IDBOpenDBRequest","IDBOpenDBRequestEventMap","IDBRequest","IDBRequestEventMap","IDBRequestReadyState","IDBTransaction","IDBTransactionDurability","IDBTransactionEventMap","IDBTransactionMode","IDBTransactionOptions","IDBValidKey","IDBVersionChangeEvent","IDBVersionChangeEventInit","IIRFilterNode","IIRFilterOptions","ITextWriter","IdleDeadline","IdleRequestCallback","IdleRequestOptions","Image","ImageBitmap","ImageBitmapOptions","ImageBitmapRenderingContext","ImageBitmapRenderingContextSettings","ImageBitmapSource","ImageBufferSource","ImageCapture","ImageData","ImageDataArray","ImageDataPixelFormat","ImageDataSettings","ImageDecodeOptions","ImageDecodeResult","ImageDecoder","ImageDecoderInit","ImageEncodeOptions","ImageOrientation","ImageSmoothingQuality","ImageTrack","ImageTrackList","Immediate","ImportAssertions","ImportAttributes","ImportCallOptions","ImportExportKind","ImportMeta","ImportNodeOptions","ImportValue","Imports","Infinity","InputDeviceInfo","InputEvent","InputEventInit","InsertPosition","Instance","InstanceType","Instant","InstantConstructor","InstantLike","InstantToStringOptions","Int16Array","Int16ArrayConstructor","Int32Array","Int32ArrayConstructor","Int32List","Int8Array","Int8ArrayConstructor","IntersectionObserver","IntersectionObserverCallback","IntersectionObserverEntry","IntersectionObserverInit","Intl","Iterable","IterableIterator","IterationCompositeOperation","Iterator","IteratorConstructor","IteratorObject","IteratorObjectConstructor","IteratorResult","IteratorReturnResult","IteratorYieldResult","JSON","JsonWebKey","KHR_parallel_shader_compile","KeyAlgorithm","KeyFormat","KeySystemTrackConfiguration","KeyType","KeyUsage","KeyboardEvent","KeyboardEventInit","Keyframe","KeyframeAnimationOptions","KeyframeEffect","KeyframeEffectOptions","LDMLPluralRule","LargestContentfulPaint","LatencyMode","LineAlignSetting","LineAndPositionSetting","LinkError","LinkStyle","ListFormat","ListFormatLocaleMatcher","ListFormatOptions","ListFormatStyle","ListFormatType","Locale","LocaleCollationCaseFirst","LocaleHourCycleKey","LocaleOptions","LocalesArgument","Location","Lock","LockGrantedCallback","LockInfo","LockManager","LockManagerSnapshot","LockMode","LockOptions","LoginStatus","Lowercase","MIDIAccess","MIDIAccessEventMap","MIDIConnectionEvent","MIDIConnectionEventInit","MIDIInput","MIDIInputEventMap","MIDIInputMap","MIDIMessageEvent","MIDIMessageEventInit","MIDIOptions","MIDIOutput","MIDIOutputMap","MIDIPort","MIDIPortConnectionState","MIDIPortDeviceState","MIDIPortEventMap","MIDIPortType","Map","MapConstructor","MapIterator","Math","MathMLElement","MathMLElementEventMap","MathMLElementTagNameMap","MediaCapabilities","MediaCapabilitiesDecodingInfo","MediaCapabilitiesEncodingInfo","MediaCapabilitiesInfo","MediaCapabilitiesKeySystemConfiguration","MediaConfiguration","MediaDecodingConfiguration","MediaDecodingType","MediaDeviceInfo","MediaDeviceKind","MediaDevices","MediaDevicesEventMap","MediaElementAudioSourceNode","MediaElementAudioSourceOptions","MediaEncodingConfiguration","MediaEncodingType","MediaEncryptedEvent","MediaEncryptedEventInit","MediaError","MediaImage","MediaKeyMessageEvent","MediaKeyMessageEventInit","MediaKeyMessageType","MediaKeySession","MediaKeySessionClosedReason","MediaKeySessionEventMap","MediaKeySessionType","MediaKeyStatus","MediaKeyStatusMap","MediaKeyStatusMapIterator","MediaKeySystemAccess","MediaKeySystemConfiguration","MediaKeySystemMediaCapability","MediaKeys","MediaKeysPolicy","MediaKeysRequirement","MediaList","MediaMetadata","MediaMetadataInit","MediaPositionState","MediaProvider","MediaQueryList","MediaQueryListEvent","MediaQueryListEventInit","MediaQueryListEventMap","MediaRecorder","MediaRecorderEventMap","MediaRecorderOptions","MediaSession","MediaSessionAction","MediaSessionActionDetails","MediaSessionActionHandler","MediaSessionPlaybackState","MediaSettingsRange","MediaSource","MediaSourceEventMap","MediaSourceHandle","MediaStream","MediaStreamAudioDestinationNode","MediaStreamAudioSourceNode","MediaStreamAudioSourceOptions","MediaStreamConstraints","MediaStreamEventMap","MediaStreamTrack","MediaStreamTrackEvent","MediaStreamTrackEventInit","MediaStreamTrackEventMap","MediaStreamTrackProcessor","MediaStreamTrackProcessorInit","MediaStreamTrackState","MediaTrackCapabilities","MediaTrackConstraintSet","MediaTrackConstraints","MediaTrackSettings","MediaTrackSupportedConstraints","Memory","MemoryDescriptor","MessageChannel","MessageEvent","MessageEventInit","MessageEventSource","MessageEventTarget","MessageEventTargetEventMap","MessagePort","MessagePortEventMap","MethodDecorator","MimeType","MimeTypeArray","Module","ModuleExportDescriptor","ModuleImportDescriptor","ModuleImports","MouseEvent","MouseEventInit","MultiCacheQueryOptions","MutationCallback","MutationObserver","MutationObserverInit","MutationRecord","MutationRecordType","NaN","NamedCurve","NamedNodeMap","NavigateEvent","NavigateEventInit","Navigation","NavigationActivation","NavigationCurrentEntryChangeEvent","NavigationCurrentEntryChangeEventInit","NavigationDestination","NavigationEventMap","NavigationFocusReset","NavigationHistoryBehavior","NavigationHistoryEntry","NavigationHistoryEntryEventMap","NavigationInterceptHandler","NavigationInterceptOptions","NavigationNavigateOptions","NavigationOptions","NavigationPrecommitController","NavigationPrecommitHandler","NavigationPreloadManager","NavigationPreloadState","NavigationReloadOptions","NavigationResult","NavigationScrollBehavior","NavigationTimingType","NavigationTransition","NavigationType","NavigationUpdateCurrentEntryOptions","Navigator","NavigatorAutomationInformation","NavigatorBadge","NavigatorConcurrentHardware","NavigatorContentUtils","NavigatorCookies","NavigatorGPU","NavigatorID","NavigatorLanguage","NavigatorLocks","NavigatorLogin","NavigatorOnLine","NavigatorPlugins","NavigatorStorage","NewableFunction","NoInfer","Node","NodeFilter","NodeIterator","NodeJS","NodeList","NodeListOf","NodeModule","NodeRequire","NonDocumentTypeChildNode","NonElementParentNode","NonNullable","Notification","NotificationDirection","NotificationEvent","NotificationEventInit","NotificationEventMap","NotificationOptions","NotificationPermission","NotificationPermissionCallback","Now","Number","NumberConstructor","NumberFormat","NumberFormatConstructor","NumberFormatOptions","NumberFormatOptionsCurrencyDisplay","NumberFormatOptionsCurrencyDisplayRegistry","NumberFormatOptionsSignDisplay","NumberFormatOptionsSignDisplayRegistry","NumberFormatOptionsStyle","NumberFormatOptionsStyleRegistry","NumberFormatOptionsUseGrouping","NumberFormatOptionsUseGroupingRegistry","NumberFormatPart","NumberFormatPartTypeRegistry","NumberFormatPartTypes","NumberFormatRangePartTypeRegistry","NumberFormatRangePartTypes","NumberRangeFormatPart","OES_draw_buffers_indexed","OES_element_index_uint","OES_fbo_render_mipmap","OES_standard_derivatives","OES_texture_float","OES_texture_float_linear","OES_texture_half_float","OES_texture_half_float_linear","OES_vertex_array_object","OVR_multiview2","Object","ObjectConstructor","OfflineAudioCompletionEvent","OfflineAudioCompletionEventInit","OfflineAudioContext","OfflineAudioContextEventMap","OfflineAudioContextOptions","OffscreenCanvas","OffscreenCanvasEventMap","OffscreenCanvasRenderingContext2D","OffscreenRenderingContext","OffscreenRenderingContextId","Omit","OmitThisParameter","OnBeforeUnloadEventHandler","OnBeforeUnloadEventHandlerNonNull","OnErrorEventHandler","OnErrorEventHandlerNonNull","Option","OptionalEffectTiming","OptionalPostfixToken","OptionalPrefixToken","OpusBitstreamFormat","OpusEncoderConfig","OrientationLockType","OrientationType","OscillatorNode","OscillatorOptions","OscillatorType","OverSampleType","OverconstrainedError","OverflowOptions","PageRevealEvent","PageRevealEventInit","PageSwapEvent","PageSwapEventInit","PageTransitionEvent","PageTransitionEventInit","PaintTimingMixin","PannerNode","PannerOptions","PanningModelType","ParameterDecorator","Parameters","ParentNode","Partial","PartialTemporalLike","Path2D","PayerErrors","PaymentAddress","PaymentComplete","PaymentCurrencyAmount","PaymentDetailsBase","PaymentDetailsInit","PaymentDetailsModifier","PaymentDetailsUpdate","PaymentItem","PaymentMethodChangeEvent","PaymentMethodChangeEventInit","PaymentMethodData","PaymentOptions","PaymentRequest","PaymentRequestEventMap","PaymentRequestUpdateEvent","PaymentRequestUpdateEventInit","PaymentResponse","PaymentResponseEventMap","PaymentShippingOption","PaymentShippingType","PaymentValidationErrors","Pbkdf2Params","Performance","PerformanceEntry","PerformanceEntryList","PerformanceEventMap","PerformanceEventTiming","PerformanceMark","PerformanceMarkOptions","PerformanceMeasure","PerformanceMeasureOptions","PerformanceNavigation","PerformanceNavigationTiming","PerformanceObserver","PerformanceObserverCallback","PerformanceObserverEntryList","PerformanceObserverInit","PerformancePaintTiming","PerformanceResourceTiming","PerformanceServerTiming","PerformanceTiming","PeriodicWave","PeriodicWaveConstraints","PeriodicWaveOptions","PermissionDescriptor","PermissionName","PermissionState","PermissionStatus","PermissionStatusEventMap","Permissions","PhotoCapabilities","PhotoSettings","Pick","PictureInPictureEvent","PictureInPictureEventInit","PictureInPictureWindow","PictureInPictureWindowEventMap","PlainDate","PlainDateConstructor","PlainDateLike","PlainDateTime","PlainDateTimeConstructor","PlainDateTimeLike","PlainDateTimeToStringOptions","PlainDateToStringOptions","PlainDateToZonedDateTimeOptions","PlainMonthDay","PlainMonthDayConstructor","PlainMonthDayLike","PlainMonthDayToPlainDateOptions","PlainTime","PlainTimeConstructor","PlainTimeLike","PlainTimeToStringOptions","PlainYearMonth","PlainYearMonthConstructor","PlainYearMonthLike","PlainYearMonthToPlainDateOptions","PlaneLayout","PlaybackDirection","Plugin","PluginArray","PluralRuleType","PluralRules","PluralRulesConstructor","PluralRulesOptions","PluralizeUnit","PointerEvent","PointerEventInit","PointerLockOptions","PopStateEvent","PopStateEventInit","PopoverTargetAttributes","PositionAlignSetting","PositionCallback","PositionErrorCallback","PositionOptions","PredefinedColorSpace","PremultiplyAlpha","PresentationStyle","ProcessingInstruction","ProgressEvent","ProgressEventInit","Promise","PromiseConstructor","PromiseConstructorLike","PromiseFulfilledResult","PromiseLike","PromiseRejectedResult","PromiseRejectionEvent","PromiseRejectionEventInit","PromiseSettledResult","PromiseWithResolvers","PropertyDecorator","PropertyDefinition","PropertyDescriptor","PropertyDescriptorMap","PropertyIndexedKeyframes","PropertyKey","Proxy","ProxyConstructor","ProxyHandler","PublicKeyCredential","PublicKeyCredentialClientCapabilities","PublicKeyCredentialCreationOptions","PublicKeyCredentialCreationOptionsJSON","PublicKeyCredentialDescriptor","PublicKeyCredentialDescriptorJSON","PublicKeyCredentialEntity","PublicKeyCredentialParameters","PublicKeyCredentialRequestOptions","PublicKeyCredentialRequestOptionsJSON","PublicKeyCredentialRpEntity","PublicKeyCredentialType","PublicKeyCredentialUserEntity","PublicKeyCredentialUserEntityJSON","PushEncryptionKeyName","PushEvent","PushEventInit","PushManager","PushManagerAttribute","PushMessageData","PushMessageDataInit","PushSubscription","PushSubscriptionChangeEvent","PushSubscriptionChangeEventInit","PushSubscriptionJSON","PushSubscriptionOptions","PushSubscriptionOptionsInit","QueuingStrategy","QueuingStrategyInit","QueuingStrategySize","RTCAnswerOptions","RTCBundlePolicy","RTCCertificate","RTCCertificateExpiration","RTCConfiguration","RTCDTMFSender","RTCDTMFSenderEventMap","RTCDTMFToneChangeEvent","RTCDTMFToneChangeEventInit","RTCDataChannel","RTCDataChannelEvent","RTCDataChannelEventInit","RTCDataChannelEventMap","RTCDataChannelInit","RTCDataChannelState","RTCDegradationPreference","RTCDtlsFingerprint","RTCDtlsRole","RTCDtlsTransport","RTCDtlsTransportEventMap","RTCDtlsTransportState","RTCEncodedAudioFrame","RTCEncodedAudioFrameMetadata","RTCEncodedFrameMetadata","RTCEncodedVideoFrame","RTCEncodedVideoFrameMetadata","RTCError","RTCErrorDetailType","RTCErrorEvent","RTCErrorEventInit","RTCErrorInit","RTCIceCandidate","RTCIceCandidateInit","RTCIceCandidatePair","RTCIceCandidatePairStats","RTCIceCandidateType","RTCIceComponent","RTCIceConnectionState","RTCIceGathererState","RTCIceGatheringState","RTCIceProtocol","RTCIceRole","RTCIceServer","RTCIceTcpCandidateType","RTCIceTransport","RTCIceTransportEventMap","RTCIceTransportPolicy","RTCIceTransportState","RTCInboundRtpStreamStats","RTCLocalIceCandidateInit","RTCLocalSessionDescriptionInit","RTCOfferAnswerOptions","RTCOfferOptions","RTCOutboundRtpStreamStats","RTCPeerConnection","RTCPeerConnectionErrorCallback","RTCPeerConnectionEventMap","RTCPeerConnectionIceErrorEvent","RTCPeerConnectionIceErrorEventInit","RTCPeerConnectionIceEvent","RTCPeerConnectionIceEventInit","RTCPeerConnectionState","RTCPriorityType","RTCQualityLimitationReason","RTCReceivedRtpStreamStats","RTCRtcpMuxPolicy","RTCRtcpParameters","RTCRtpCapabilities","RTCRtpCodec","RTCRtpCodecParameters","RTCRtpCodingParameters","RTCRtpContributingSource","RTCRtpEncodingParameters","RTCRtpHeaderExtensionCapability","RTCRtpHeaderExtensionParameters","RTCRtpParameters","RTCRtpReceiveParameters","RTCRtpReceiver","RTCRtpReceiverTransform","RTCRtpScriptTransform","RTCRtpScriptTransformer","RTCRtpSendParameters","RTCRtpSender","RTCRtpSenderTransform","RTCRtpStreamStats","RTCRtpSynchronizationSource","RTCRtpTransceiver","RTCRtpTransceiverDirection","RTCRtpTransceiverInit","RTCSctpTransport","RTCSctpTransportEventMap","RTCSctpTransportState","RTCSdpType","RTCSentRtpStreamStats","RTCSessionDescription","RTCSessionDescriptionCallback","RTCSessionDescriptionInit","RTCSetParameterOptions","RTCSignalingState","RTCStats","RTCStatsIceCandidatePairState","RTCStatsReport","RTCStatsType","RTCTrackEvent","RTCTrackEventInit","RTCTransformEvent","RTCTransportStats","RadioNodeList","Range","RangeError","RangeErrorConstructor","ReadableByteStreamController","ReadableStream","ReadableStreamAsyncIterator","ReadableStreamBYOBReader","ReadableStreamBYOBReaderReadOptions","ReadableStreamBYOBRequest","ReadableStreamController","ReadableStreamDefaultController","ReadableStreamDefaultReader","ReadableStreamGenericReader","ReadableStreamGetReaderOptions","ReadableStreamIteratorOptions","ReadableStreamReadDoneResult","ReadableStreamReadResult","ReadableStreamReadValueResult","ReadableStreamReader","ReadableStreamReaderMode","ReadableStreamType","ReadableWritablePair","Readonly","ReadonlyArray","ReadonlyMap","ReadonlySet","ReadonlySetLike","ReadyState","Record","RecordingState","RedEyeReduction","ReferenceError","ReferenceErrorConstructor","ReferrerPolicy","Reflect","RegExp","RegExpConstructor","RegExpExecArray","RegExpIndicesArray","RegExpMatchArray","RegExpStringIterator","RegistrationOptions","RegistrationResponseJSON","RelativeTimeFormat","RelativeTimeFormatLocaleMatcher","RelativeTimeFormatNumeric","RelativeTimeFormatOptions","RelativeTimeFormatPart","RelativeTimeFormatStyle","RelativeTimeFormatUnit","RelativeTimeFormatUnitSingular","RemotePlayback","RemotePlaybackAvailabilityCallback","RemotePlaybackEventMap","RemotePlaybackState","RenderingContext","Report","ReportBody","ReportList","ReportingObserver","ReportingObserverCallback","ReportingObserverOptions","Request","RequestCache","RequestCredentials","RequestDestination","RequestInfo","RequestInit","RequestMode","RequestPriority","RequestRedirect","Required","ResidentKeyRequirement","ResizeObserver","ResizeObserverBoxOptions","ResizeObserverCallback","ResizeObserverEntry","ResizeObserverOptions","ResizeObserverSize","ResizeQuality","ResolvedCollatorOptions","ResolvedDateTimeFormatOptions","ResolvedDisplayNamesOptions","ResolvedDurationFormatOptions","ResolvedListFormatOptions","ResolvedNumberFormatOptions","ResolvedNumberFormatOptionsUseGrouping","ResolvedPluralRulesOptions","ResolvedRelativeTimeFormatOptions","ResolvedSegmenterOptions","Response","ResponseInit","ResponseType","ReturnType","RoundingOptions","RoundingOptionsWithLargestUnit","RsaHashedImportParams","RsaHashedKeyAlgorithm","RsaHashedKeyGenParams","RsaKeyAlgorithm","RsaKeyGenParams","RsaOaepParams","RsaOtherPrimesInfo","RsaPssParams","RuntimeError","SVGAElement","SVGAngle","SVGAnimateElement","SVGAnimateMotionElement","SVGAnimateTransformElement","SVGAnimatedAngle","SVGAnimatedBoolean","SVGAnimatedEnumeration","SVGAnimatedInteger","SVGAnimatedLength","SVGAnimatedLengthList","SVGAnimatedNumber","SVGAnimatedNumberList","SVGAnimatedPoints","SVGAnimatedPreserveAspectRatio","SVGAnimatedRect","SVGAnimatedString","SVGAnimatedTransformList","SVGAnimationElement","SVGBoundingBoxOptions","SVGCircleElement","SVGClipPathElement","SVGComponentTransferFunctionElement","SVGDefsElement","SVGDescElement","SVGElement","SVGElementEventMap","SVGElementTagNameMap","SVGEllipseElement","SVGFEBlendElement","SVGFEColorMatrixElement","SVGFEComponentTransferElement","SVGFECompositeElement","SVGFEConvolveMatrixElement","SVGFEDiffuseLightingElement","SVGFEDisplacementMapElement","SVGFEDistantLightElement","SVGFEDropShadowElement","SVGFEFloodElement","SVGFEFuncAElement","SVGFEFuncBElement","SVGFEFuncGElement","SVGFEFuncRElement","SVGFEGaussianBlurElement","SVGFEImageElement","SVGFEMergeElement","SVGFEMergeNodeElement","SVGFEMorphologyElement","SVGFEOffsetElement","SVGFEPointLightElement","SVGFESpecularLightingElement","SVGFESpotLightElement","SVGFETileElement","SVGFETurbulenceElement","SVGFilterElement","SVGFilterPrimitiveStandardAttributes","SVGFitToViewBox","SVGForeignObjectElement","SVGGElement","SVGGeometryElement","SVGGradientElement","SVGGraphicsElement","SVGImageElement","SVGLength","SVGLengthList","SVGLineElement","SVGLinearGradientElement","SVGMPathElement","SVGMarkerElement","SVGMaskElement","SVGMatrix","SVGMetadataElement","SVGNumber","SVGNumberList","SVGPathElement","SVGPatternElement","SVGPoint","SVGPointList","SVGPolygonElement","SVGPolylineElement","SVGPreserveAspectRatio","SVGRadialGradientElement","SVGRect","SVGRectElement","SVGSVGElement","SVGSVGElementEventMap","SVGScriptElement","SVGSetElement","SVGStopElement","SVGStringList","SVGStyleElement","SVGSwitchElement","SVGSymbolElement","SVGTSpanElement","SVGTests","SVGTextContentElement","SVGTextElement","SVGTextPathElement","SVGTextPositioningElement","SVGTitleElement","SVGTransform","SVGTransformList","SVGURIReference","SVGUnitTypes","SVGUseElement","SVGViewElement","Sanitizer","SanitizerAttribute","SanitizerAttributeNamespace","SanitizerConfig","SanitizerElement","SanitizerElementNamespace","SanitizerElementNamespaceWithAttributes","SanitizerElementWithAttributes","SanitizerPresets","Scheduler","SchedulerPostTaskCallback","SchedulerPostTaskOptions","Screen","ScreenOrientation","ScreenOrientationEventMap","ScriptProcessorNode","ScriptProcessorNodeEventMap","ScrollAxis","ScrollBehavior","ScrollIntoViewOptions","ScrollLogicalPosition","ScrollOptions","ScrollRestoration","ScrollSetting","ScrollTimeline","ScrollTimelineOptions","ScrollToOptions","SecurityPolicyViolationEvent","SecurityPolicyViolationEventDisposition","SecurityPolicyViolationEventInit","SegmentData","SegmentIterator","Segmenter","SegmenterOptions","Segments","Selection","SelectionDirection","SelectionMode","Server","ServerWebSocket","ServiceWorker","ServiceWorkerContainer","ServiceWorkerContainerEventMap","ServiceWorkerEventMap","ServiceWorkerGlobalScope","ServiceWorkerGlobalScopeEventMap","ServiceWorkerRegistration","ServiceWorkerRegistrationEventMap","ServiceWorkerState","ServiceWorkerUpdateViaCache","Set","SetConstructor","SetIterator","ShadowRoot","ShadowRootEventMap","ShadowRootInit","ShadowRootMode","ShareData","SharedArrayBuffer","SharedArrayBufferConstructor","SharedWorker","SharedWorkerGlobalScope","SharedWorkerGlobalScopeEventMap","ShellPromise","ShowPopoverOptions","SlotAssignmentMode","Slottable","Socket","SocketHandler","SourceBuffer","SourceBufferEventMap","SourceBufferList","SourceBufferListEventMap","SpeechRecognitionAlternative","SpeechRecognitionErrorCode","SpeechRecognitionErrorEvent","SpeechRecognitionErrorEventInit","SpeechRecognitionEvent","SpeechRecognitionEventInit","SpeechRecognitionResult","SpeechRecognitionResultList","SpeechSynthesis","SpeechSynthesisErrorCode","SpeechSynthesisErrorEvent","SpeechSynthesisErrorEventInit","SpeechSynthesisEvent","SpeechSynthesisEventInit","SpeechSynthesisEventMap","SpeechSynthesisUtterance","SpeechSynthesisUtteranceEventMap","SpeechSynthesisVoice","StartViewTransitionOptions","StaticRange","StaticRangeInit","Stats","StereoPannerNode","StereoPannerOptions","Storage","StorageEstimate","StorageEvent","StorageEventInit","StorageManager","StreamPipeOptions","String","StringConstructor","StringIterator","StringNumericLiteral","StructuredSerializeOptions","StylePropertyMap","StylePropertyMapReadOnly","StylePropertyMapReadOnlyIterator","StyleSheet","StyleSheetList","SubmitEvent","SubmitEventInit","Subprocess","SubtleCrypto","SuppressedError","SuppressedErrorConstructor","SvcOutputMetadata","Symbol","SymbolConstructor","SyntaxError","SyntaxErrorConstructor","TCPSocket","Table","TableDescriptor","TableKind","Tag","TagType","TaskController","TaskControllerInit","TaskPriority","TaskPriorityChangeEvent","TaskPriorityChangeEventInit","TaskSignal","TaskSignalAnyInit","TaskSignalEventMap","TemplateStringsArray","Temporal","TexImageSource","Text","TextDecodeOptions","TextDecoder","TextDecoderCommon","TextDecoderOptions","TextDecoderStream","TextEncoder","TextEncoderCommon","TextEncoderEncodeIntoResult","TextEncoderStream","TextEvent","TextInfo","TextMetrics","TextStreamBase","TextStreamReader","TextStreamWriter","TextTrack","TextTrackCue","TextTrackCueEventMap","TextTrackCueList","TextTrackEventMap","TextTrackKind","TextTrackList","TextTrackListEventMap","TextTrackMode","ThisParameterType","ThisType","TimeLikeObject","TimeRanges","TimeUnit","TimeZoneLike","TimelineRangeOffset","Timeout","Timer","TimerHandler","ToStringRoundingOptions","ToStringRoundingOptionsWithFractionalSeconds","ToggleEvent","ToggleEventInit","TogglePopoverOptions","Touch","TouchEvent","TouchEventInit","TouchInit","TouchList","TouchType","TrackEvent","TrackEventInit","TransferFunction","Transferable","TransformStream","TransformStreamDefaultController","Transformer","TransformerFlushCallback","TransformerStartCallback","TransformerTransformCallback","TransitionEvent","TransitionEventInit","TransitionOptions","TreeWalker","TypeError","TypeErrorConstructor","TypedArray","TypedPropertyDescriptor","UIEvent","UIEventInit","ULongRange","URIError","URIErrorConstructor","URL","URLPattern","URLPatternComponentResult","URLPatternInit","URLPatternInput","URLPatternOptions","URLPatternResult","URLSearchParams","URLSearchParamsIterator","Uint16Array","Uint16ArrayConstructor","Uint32Array","Uint32ArrayConstructor","Uint32List","Uint8Array","Uint8ArrayConstructor","Uint8ClampedArray","Uint8ClampedArrayConstructor","Uncapitalize","UnderlyingByteSource","UnderlyingDefaultSource","UnderlyingSink","UnderlyingSinkAbortCallback","UnderlyingSinkCloseCallback","UnderlyingSinkStartCallback","UnderlyingSinkWriteCallback","UnderlyingSource","UnderlyingSourceCancelCallback","UnderlyingSourcePullCallback","UnderlyingSourceStartCallback","UnicodeBCP47LocaleIdentifier","UnknownCredentialOptions","Uppercase","UserActivation","UserVerificationRequirement","VBArray","VBArrayConstructor","VTTCue","VTTRegion","ValidityState","ValidityStateFlags","ValueType","ValueTypeMap","VibratePattern","VideoColorPrimaries","VideoColorSpace","VideoColorSpaceInit","VideoConfiguration","VideoDecoder","VideoDecoderConfig","VideoDecoderEventMap","VideoDecoderInit","VideoDecoderSupport","VideoEncoder","VideoEncoderBitrateMode","VideoEncoderConfig","VideoEncoderEncodeOptions","VideoEncoderEncodeOptionsForAvc","VideoEncoderEventMap","VideoEncoderInit","VideoEncoderSupport","VideoFacingModeEnum","VideoFrame","VideoFrameBufferInit","VideoFrameCallbackMetadata","VideoFrameCopyToOptions","VideoFrameInit","VideoFrameOutputCallback","VideoFrameRequestCallback","VideoMatrixCoefficients","VideoPixelFormat","VideoPlaybackQuality","VideoTransferCharacteristics","ViewTimeline","ViewTimelineOptions","ViewTransition","ViewTransitionTypeSet","ViewTransitionUpdateCallback","VisualViewport","VisualViewportEventMap","VoidFunction","WEBGL_color_buffer_float","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb","WEBGL_debug_renderer_info","WEBGL_debug_shaders","WEBGL_depth_texture","WEBGL_draw_buffers","WEBGL_lose_context","WEBGL_multi_draw","WGSLLanguageFeatures","WSH","WScript","WakeLock","WakeLockSentinel","WakeLockSentinelEventMap","WakeLockType","WaveShaperNode","WaveShaperOptions","WeakKey","WeakKeyTypes","WeakMap","WeakMapConstructor","WeakRef","WeakRefConstructor","WeakSet","WeakSetConstructor","WebAssembly","WebAssemblyCompileOptions","WebAssemblyInstantiatedSource","WebCodecsErrorCallback","WebGL2RenderingContext","WebGL2RenderingContextBase","WebGL2RenderingContextOverloads","WebGLActiveInfo","WebGLBuffer","WebGLContextAttributes","WebGLContextEvent","WebGLContextEventInit","WebGLFramebuffer","WebGLPowerPreference","WebGLProgram","WebGLQuery","WebGLRenderbuffer","WebGLRenderingContext","WebGLRenderingContextBase","WebGLRenderingContextOverloads","WebGLSampler","WebGLShader","WebGLShaderPrecisionFormat","WebGLSync","WebGLTexture","WebGLTransformFeedback","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES","WebKitCSSMatrix","WebSocket","WebSocketEventMap","WebSocketHandler","WebTransport","WebTransportBidirectionalStream","WebTransportCloseInfo","WebTransportCongestionControl","WebTransportDatagramDuplexStream","WebTransportError","WebTransportErrorOptions","WebTransportErrorSource","WebTransportHash","WebTransportOptions","WebTransportSendOptions","WebTransportSendStreamOptions","WeekInfo","WheelEvent","WheelEventInit","Window","WindowClient","WindowEventHandlers","WindowEventHandlersEventMap","WindowEventMap","WindowLocalStorage","WindowOrWorkerGlobalScope","WindowPostMessageOptions","WindowProxy","WindowSessionStorage","WithImplicitCoercion","Worker","WorkerEventMap","WorkerGlobalScope","WorkerGlobalScopeEventMap","WorkerLocation","WorkerNavigator","WorkerOptions","WorkerType","Worklet","WorkletOptions","WritableStream","WritableStreamDefaultController","WritableStreamDefaultWriter","WriteCommandType","WriteParams","XMLDocument","XMLHttpRequest","XMLHttpRequestBodyInit","XMLHttpRequestEventMap","XMLHttpRequestEventTarget","XMLHttpRequestEventTargetEventMap","XMLHttpRequestResponseType","XMLHttpRequestUpload","XMLSerializer","XPathEvaluator","XPathEvaluatorBase","XPathExpression","XPathNSResolver","XPathResult","XSLTProcessor","YearMonthLikeObject","ZonedDateTime","ZonedDateTimeConstructor","ZonedDateTimeFromOptions","ZonedDateTimeLike","ZonedDateTimeLikeObject","ZonedDateTimeToStringOptions","global","globalThis","process","structuredClone"])});function Du(e,t={strings:!0}){let i="",r=0;while(r<e.length){let n=e.slice(r,r+2);if(n==="//"){let s=e.indexOf(`
229
229
  `,r),l=s===-1?e.length:s;i+=" ".repeat(l-r),r=l;continue}if(n==="/*"){let s=e.indexOf("*/",r+2),l=s===-1?e.length:s+2;for(let a=r;a<l;a++)i+=e[a]===`
230
230
  `?`
231
231
  `:" ";r=l;continue}let o=e[r];if(t.strings&&(o==='"'||o==="'"||o==="`")){let s=o;i+=" ",r++;while(r<e.length){if(e[r]==="\\"){i+=" ",r+=2;continue}if(e[r]===s){i+=" ",r++;break}i+=e[r]===`
232
232
  `?`
233
- `:" ",r++}continue}i+=o,r++}return i}function vy(e){let t=new Set,i=[/\b(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:type|interface|class|enum|namespace|module)\s+([A-Za-z_$][\w$]*)/g,/\b(?:export\s+)?(?:declare\s+)?(?:async\s+)?function\s*\*?\s*([A-Za-z_$][\w$]*)/g,/\b(?:export\s+)?declare\s+(?:const|let|var)\s+([A-Za-z_$][\w$]*)/g];for(let r of i)for(let n of e.matchAll(r))t.add(n[1]);return t}function by(e){let t=new Set;for(let i of e.matchAll(/\bimport\s+(?:type\s+)?([\s\S]*?)\s+from\s*['"`]/g)){let r=i[1],n=/\*\s*as\s+([A-Za-z_$][\w$]*)/.exec(r);if(n)t.add(n[1]);let o=r.split("{")[0].replace(/\*\s*as\s+[A-Za-z_$][\w$]*/,"");for(let l of o.split(",")){let a=l.trim();if(/^[A-Za-z_$][\w$]*$/.test(a))t.add(a)}let s=/\{([\s\S]*?)\}/.exec(r);if(s)for(let l of s[1].split(",")){let a=l.trim().replace(/^type\s+/,"");if(!a)continue;let f=/\bas\s+([A-Za-z_$][\w$]*)$/.exec(a);t.add(f?f[1]:a.split(/\s+/)[0])}}for(let i of e.matchAll(/\bimport\s*\(\s*['"`][^'"`]*['"`]\s*\)\s*\.\s*([A-Za-z_$][\w$]*)/g))t.add(i[1]);return t}function $y(e){let t=new Set,i=(n)=>{for(let o of n.split(",")){let s=o.trim().split(/\s+|=/)[0]?.trim();if(s&&/^[A-Za-z_$][\w$]*$/.test(s))t.add(s)}},r=/\b(?:type|interface|class|function)\s+[A-Za-z_$][\w$]*\s*<([^<>]*(?:<[^<>]*>[^<>]*)*)>/g;for(let n of e.matchAll(r))i(n[1]);for(let n of e.matchAll(/(?:\b[A-Za-z_$][\w$]*)?\s*<([^<>()]*)>\s*\(/g))i(n[1]);for(let n of e.matchAll(/\binfer\s+([A-Za-z_$][\w$]*)/g))t.add(n[1]);for(let n of e.matchAll(/\[\s*([A-Za-z_$][\w$]*)\s+in\b/g))t.add(n[1]);return t}function Ey(e){let t=new Map,i=(n)=>{let o=1;for(let s=0;s<n&&s<e.length;s++)if(e.charCodeAt(s)===10)o++;return o},r=(n,o,s)=>{for(let l of n.matchAll(/\b([A-Z][\w$]*)\b/g)){let a=l[1];if(t.has(a))continue;let f=n.slice(l.index+a.length);if(/^\s*\??:/.test(f))continue;t.set(a,{line:i(o),context:s.trim().slice(0,120)})}};for(let n of e.matchAll(/\btype\s+[A-Za-z_$][\w$]*\s*(?:<[^=]*?>)?\s*=([^;]*)/g))r(n[1],n.index+n[0].indexOf("="),n[0]);for(let n of e.matchAll(/\b(?:extends|implements)\s+([^{;]*)/g))r(n[1],n.index,n[0]);for(let n of e.matchAll(/:\s*([^;,){}\n=]+)/g))r(n[1],n.index,n[0]);for(let n of e.matchAll(/<([^<>()]*)>/g))r(n[1],n.index,n[0]);return t}function Iu(e){let t=Du(e),i=Du(e,{strings:!1}),r=new Set([...vy(t),...by(i),...$y(t),...Pu,...Cy]),n=[];for(let[o,s]of Ey(t)){if(r.has(o))continue;if(new RegExp(`[\\w$]\\s*\\.\\s*${o}\\b`).test(t))continue;n.push({name:o,line:s.line,context:s.context})}return n.sort((o,s)=>o.line-s.line||o.name.localeCompare(s.name))}var Cy;var Nu=me(()=>{Mu();Cy=new Set(["This","True","False","Null","Undefined","Void","Never","Any","Unknown","Object","Infinity","NaN"])});function ci(e,t){let i=1,r=1;for(let n=0;n<t;n++)if(e.charCodeAt(n)===10)i++,r=1;else r++;return{line:i,column:r}}function Wu(e){let t=[],i=[],r=[],n={")":"(","]":"[","}":"{"},o=0,s=0,l=-1;for(let f=0;f<e.length;f++){let u=e.charCodeAt(f),d=e.charCodeAt(f+1);if(l!==-1){if(u===42&&d===47)i.push({start:l,end:f+2}),l=-1,f++;continue}if(o){if(u===92)f++;else if(u===o)i.push({start:s,end:f+1}),o=0;continue}if(u===47&&d===42){l=f,f++;continue}if(u===47&&d===47){let p=f;while(f<e.length&&e.charCodeAt(f)!==10)f++;i.push({start:p,end:f});continue}if(u===39||u===34||u===96){o=u,s=f;continue}let h=e[f];if(h==="("||h==="["||h==="{")r.push({char:h,offset:f});else if(n[h]){let p=r.pop();if(!p||p.char!==n[h])t.push({...ci(e,f),message:`Unexpected closing delimiter ${h}`,code:"DTSX1004"})}}if(o)t.push({...ci(e,s),message:"Unterminated string literal",code:"DTSX1002"});if(l!==-1)t.push({...ci(e,l),message:"Unterminated block comment",code:"DTSX1003"});for(let f of r)t.push({...ci(e,f.offset),message:`Unclosed delimiter ${f.char}`,code:"DTSX1001"});let a=[[/\b(?:interface|class|enum)\s*(?=[{=])/g,"Declaration name expected"],[/\bfunction\s*(?=\()/g,"Function name expected"],[/\(\s*:/g,"Parameter name expected"]];for(let[f,u]of a)for(let d of e.matchAll(f)){if(i.some((h)=>d.index>=h.start&&d.index<h.end))continue;t.push({...ci(e,d.index),message:u,code:"DTSX1005"})}for(let f of e.matchAll(/\btype\s*(?=[{=])/g)){if(i.some((d)=>f.index>=d.start&&f.index<d.end))continue;let u=e.slice(0,f.index).trimEnd();if(u.endsWith("import")||u.endsWith("export"))continue;t.push({...ci(e,f.index),message:"Declaration name expected",code:"DTSX1005"})}return t.push(...Sy(e,i)),t.sort((f,u)=>f.line-u.line||f.column-u.column)}function Sy(e,t){let i=[],r=(n)=>t.some((o)=>n>=o.start&&n<o.end);for(let n of e.matchAll(/\b(import|export)\s+(?:type\s+)?\{/g)){let o=n.index;if(r(o))continue;let s=o+n[0].length-1,l=-1;for(let u=s+1;u<e.length;u++){if(r(u))continue;let d=e[u];if(d==="{"){l=-2;break}if(d==="}"){l=u;break}}if(l<0)continue;let a=e.slice(s+1,l);if(!a.trim())continue;let f=s+1;for(let u of a.split(",")){let d=u.trim();if(d){let h=f+u.indexOf(d);if(d.includes(";"))i.push({...ci(e,h),message:`Unexpected ';' in ${n[1]} clause \u2014 specifiers are separated by ','`,code:"DTSX1006"});else if(!xy.test(d))i.push({...ci(e,h),message:`Invalid ${n[1]} specifier '${d}'`,code:"DTSX1006"})}f+=u.length+1}}return i}var Fu,xy;var Lu=me(()=>{Fu=String.raw`(?:[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*|'[^']*'|"[^"]*")`,xy=new RegExp(`^(?:type\\s+)?${Fu}(?:\\s+as\\s+${Fu})?$`,"u")});import Ay from"process";import{join as ab,resolve as ky}from"path";function Ta(){return`${String.fromCharCode(47,47,35)} sourceMappingURL=`}async function vo(e,t,i="lf"){let r=t.replace(/\r\n/g,`
233
+ `:" ",r++}continue}i+=o,r++}return i}function Ey(e){let t=new Set,i=[/\b(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:type|interface|class|enum|namespace|module)\s+([A-Za-z_$][\w$]*)/g,/\b(?:export\s+)?(?:declare\s+)?(?:async\s+)?function\s*\*?\s*([A-Za-z_$][\w$]*)/g,/\b(?:export\s+)?declare\s+(?:const|let|var)\s+([A-Za-z_$][\w$]*)/g];for(let r of i)for(let n of e.matchAll(r))t.add(n[1]);return t}function xy(e){let t=new Set;for(let i of e.matchAll(/\bimport\s+(?:type\s+)?([\s\S]*?)\s+from\s*['"`]/g)){let r=i[1],n=/\*\s*as\s+([A-Za-z_$][\w$]*)/.exec(r);if(n)t.add(n[1]);let o=r.split("{")[0].replace(/\*\s*as\s+[A-Za-z_$][\w$]*/,"");for(let l of o.split(",")){let a=l.trim();if(/^[A-Za-z_$][\w$]*$/.test(a))t.add(a)}let s=/\{([\s\S]*?)\}/.exec(r);if(s)for(let l of s[1].split(",")){let a=l.trim().replace(/^type\s+/,"");if(!a)continue;let f=/\bas\s+([A-Za-z_$][\w$]*)$/.exec(a);t.add(f?f[1]:a.split(/\s+/)[0])}}for(let i of e.matchAll(/\bimport\s*\(\s*['"`][^'"`]*['"`]\s*\)\s*\.\s*([A-Za-z_$][\w$]*)/g))t.add(i[1]);return t}function Sy(e){let t=new Set,i=(n)=>{for(let o of n.split(",")){let s=o.trim().split(/\s+|=/)[0]?.trim();if(s&&/^[A-Za-z_$][\w$]*$/.test(s))t.add(s)}},r=/\b(?:type|interface|class|function)\s+[A-Za-z_$][\w$]*\s*<([^<>]*(?:<[^<>]*>[^<>]*)*)>/g;for(let n of e.matchAll(r))i(n[1]);for(let n of e.matchAll(/(?:\b[A-Za-z_$][\w$]*)?\s*<([^<>()]*)>\s*\(/g))i(n[1]);for(let n of e.matchAll(/\binfer\s+([A-Za-z_$][\w$]*)/g))t.add(n[1]);for(let n of e.matchAll(/\[\s*([A-Za-z_$][\w$]*)\s+in\b/g))t.add(n[1]);return t}function Ay(e){let t=new Map,i=(n)=>{let o=1;for(let s=0;s<n&&s<e.length;s++)if(e.charCodeAt(s)===10)o++;return o},r=(n,o,s)=>{for(let l of n.matchAll(/\b([A-Z][\w$]*)\b/g)){let a=l[1];if(t.has(a))continue;let f=n.slice(l.index+a.length);if(/^\s*\??:/.test(f))continue;t.set(a,{line:i(o),context:s.trim().slice(0,120)})}};for(let n of e.matchAll(/\btype\s+[A-Za-z_$][\w$]*\s*(?:<[^=]*?>)?\s*=([^;]*)/g))r(n[1],n.index+n[0].indexOf("="),n[0]);for(let n of e.matchAll(/\b(?:extends|implements)\s+([^{;]*)/g))r(n[1],n.index,n[0]);for(let n of e.matchAll(/:\s*([^;,){}\n=]+)/g))r(n[1],n.index,n[0]);for(let n of e.matchAll(/<([^<>()]*)>/g))r(n[1],n.index,n[0]);return t}function Iu(e){let t=Du(e),i=Du(e,{strings:!1}),r=new Set([...Ey(t),...xy(i),...Sy(t),...Pu,...$y]),n=[];for(let[o,s]of Ay(t)){if(r.has(o))continue;if(new RegExp(`[\\w$]\\s*\\.\\s*${o}\\b`).test(t))continue;n.push({name:o,line:s.line,context:s.context})}return n.sort((o,s)=>o.line-s.line||o.name.localeCompare(s.name))}var $y;var Nu=me(()=>{Mu();$y=new Set(["This","True","False","Null","Undefined","Void","Never","Any","Unknown","Object","Infinity","NaN"])});function ci(e,t){let i=1,r=1;for(let n=0;n<t;n++)if(e.charCodeAt(n)===10)i++,r=1;else r++;return{line:i,column:r}}function Wu(e){let t=[],i=[],r=[],n={")":"(","]":"[","}":"{"},o=0,s=0,l=-1;for(let f=0;f<e.length;f++){let u=e.charCodeAt(f),d=e.charCodeAt(f+1);if(l!==-1){if(u===42&&d===47)i.push({start:l,end:f+2}),l=-1,f++;continue}if(o){if(u===92)f++;else if(u===o)i.push({start:s,end:f+1}),o=0;continue}if(u===47&&d===42){l=f,f++;continue}if(u===47&&d===47){let p=f;while(f<e.length&&e.charCodeAt(f)!==10)f++;i.push({start:p,end:f});continue}if(u===39||u===34||u===96){o=u,s=f;continue}let h=e[f];if(h==="("||h==="["||h==="{")r.push({char:h,offset:f});else if(n[h]){let p=r.pop();if(!p||p.char!==n[h])t.push({...ci(e,f),message:`Unexpected closing delimiter ${h}`,code:"DTSX1004"})}}if(o)t.push({...ci(e,s),message:"Unterminated string literal",code:"DTSX1002"});if(l!==-1)t.push({...ci(e,l),message:"Unterminated block comment",code:"DTSX1003"});for(let f of r)t.push({...ci(e,f.offset),message:`Unclosed delimiter ${f.char}`,code:"DTSX1001"});let a=[[/\b(?:interface|class|enum)\s*(?=[{=])/g,"Declaration name expected"],[/\bfunction\s*(?=\()/g,"Function name expected"],[/\(\s*:/g,"Parameter name expected"]];for(let[f,u]of a)for(let d of e.matchAll(f)){if(i.some((h)=>d.index>=h.start&&d.index<h.end))continue;t.push({...ci(e,d.index),message:u,code:"DTSX1005"})}for(let f of e.matchAll(/\btype\s*(?=[{=])/g)){if(i.some((d)=>f.index>=d.start&&f.index<d.end))continue;let u=e.slice(0,f.index).trimEnd();if(u.endsWith("import")||u.endsWith("export"))continue;t.push({...ci(e,f.index),message:"Declaration name expected",code:"DTSX1005"})}return t.push(...Ty(e,i)),t.sort((f,u)=>f.line-u.line||f.column-u.column)}function Ty(e,t){let i=[],r=(n)=>t.some((o)=>n>=o.start&&n<o.end);for(let n of e.matchAll(/\b(import|export)\s+(?:type\s+)?\{/g)){let o=n.index;if(r(o))continue;let s=o+n[0].length-1,l=-1;for(let u=s+1;u<e.length;u++){if(r(u))continue;let d=e[u];if(d==="{"){l=-2;break}if(d==="}"){l=u;break}}if(l<0)continue;let a=e.slice(s+1,l);if(!a.trim())continue;let f=s+1;for(let u of a.split(",")){let d=u.trim();if(d){let h=f+u.indexOf(d);if(d.includes(";"))i.push({...ci(e,h),message:`Unexpected ';' in ${n[1]} clause \u2014 specifiers are separated by ','`,code:"DTSX1006"});else if(!ky.test(d))i.push({...ci(e,h),message:`Invalid ${n[1]} specifier '${d}'`,code:"DTSX1006"})}f+=u.length+1}}return i}var Fu,ky;var Lu=me(()=>{Fu=String.raw`(?:[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*|'[^']*'|"[^"]*")`,ky=new RegExp(`^(?:type\\s+)?${Fu}(?:\\s+as\\s+${Fu})?$`,"u")});import Oy from"process";import{join as ub,resolve as Ry}from"path";function Oa(){return`${String.fromCharCode(47,47,35)} sourceMappingURL=`}async function $o(e,t,i="lf"){let r=t.replace(/\r\n/g,`
234
234
  `);if(!r.endsWith(`
235
235
  `))r+=`
236
236
  `;if(i==="crlf")r=r.replace(/\n/g,`\r
237
- `);if(await fl(e,r)!==Buffer.byteLength(r,"utf8"))throw Error(`Incomplete declaration write: ${e}`)}async function Bu(e){try{let t=e?.cwd||Ay.cwd();return(await xr(ky(t,e?.tsconfigPath||"tsconfig.json"),{allowCircular:!0}))?.isolatedDeclarations??!1}catch{return!1}}function _u(e,t){let i={isValid:!0,errors:[]};for(let r of Wu(e))i.errors.push({line:r.line,column:r.column,message:r.message,code:r.code});for(let r of Iu(e))i.errors.push({line:r.line,column:1,message:`'${r.name}' is used but never declared or imported here, so it resolves to an error type for anything consuming this file. It is most likely an ambient global in the source project \u2014 import it explicitly. Referenced by: ${r.context}`,code:"dangling-type-reference"});return i.isValid=i.errors.length===0,i}function ju(e,t,i){if(e===t)return"";let r=e.split(`
237
+ `);if(await ul(e,r)!==Buffer.byteLength(r,"utf8"))throw Error(`Incomplete declaration write: ${e}`)}async function Bu(e){try{let t=e?.cwd||Oy.cwd();return(await xr(Ry(t,e?.tsconfigPath||"tsconfig.json"),{allowCircular:!0}))?.isolatedDeclarations??!1}catch{return!1}}function _u(e,t){let i={isValid:!0,errors:[]};for(let r of Wu(e))i.errors.push({line:r.line,column:r.column,message:r.message,code:r.code});for(let r of Iu(e))i.errors.push({line:r.line,column:1,message:`'${r.name}' is used but never declared or imported here, so it resolves to an error type for anything consuming this file. It is most likely an ambient global in the source project \u2014 import it explicitly. Referenced by: ${r.context}`,code:"dangling-type-reference"});return i.isValid=i.errors.length===0,i}function ju(e,t,i){if(e===t)return"";let r=e.split(`
238
238
  `),n=t.split(`
239
239
  `),o=new Map,s=new Map;for(let u=0;u<r.length;u++)o.set(r[u],(o.get(r[u])??0)+1);for(let u=0;u<n.length;u++)s.set(n[u],(s.get(n[u])??0)+1);let l=[],a=[];for(let[u,d]of o){let h=d-(s.get(u)??0);for(let p=0;p<h;p++)l.push(u)}for(let[u,d]of s){let h=d-(o.get(u)??0);for(let p=0;p<h;p++)a.push(u)}if(l.length===0&&a.length===0)return"";let f=[`--- ${i}`,`+++ ${i}`];for(let u=0;u<l.length;u++)f.push(`- ${l[u]}`);for(let u=0;u<a.length;u++)f.push(`+ ${a[u]}`);return f.join(`
240
240
  `)}function Gu(e,t,i,r){let n=e.split(`
241
241
  `),o=[];function s(d){let h="",p=d<0?-d<<1|1:d<<1;do{let m=p&31;if(p>>>=5,p>0)m|=32;h+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[m]}while(p>0);return h}let l=0,a=0,f=0,u=r.split(`
242
- `).length;for(let d=0;d<n.length;d++){if(n[d].trim()===""){o.push("");continue}l=0;let h=Math.min(d,u-1),p=[],m=0-l,c=0,v=h-a,b=0-f;p.push(s(m)+s(c)+s(v)+s(b)),l=0,a=h,f=0,o.push(p.join(","))}return{version:3,file:t,sourceRoot:"",sources:[i],sourcesContent:[r],mappings:o.join(";")}}function Vu(e,t){return`${e}
243
- ${Ta()}${t}
244
- `}var Oa=me(()=>{sr();Nu();Lu();Ps()});import{chmod as Ty,lstat as Da,mkdir as bo,readdir as Oy,realpath as Ry,rename as Ra,rm as Uu,rmdir as Py,stat as zu,writeFile as My}from"fs/promises";import{basename as Dy,dirname as Lr,isAbsolute as Hu,parse as Iy,relative as Ku,resolve as ut}from"path";function ui(e,t){return e instanceof Error&&"code"in e&&e.code===t}async function fi(e){try{return await Da(e)}catch(t){if(ui(t,"ENOENT"))return;throw t}}async function er(e){let t=ut(e);try{return await Ry(t)}catch(i){if(!ui(i,"ENOENT")||Lr(t)===t)throw i;return ut(await er(Lr(t)),Dy(t))}}async function Na(e){let t=ut(e.cwd,e.outdir);if(e.bundle&&e.bundleOutput){if(Hu(e.bundleOutput))throw Error("bundleOutput must be relative to outdir");if(!Gt(ut(t,e.bundleOutput),t))throw Error("bundleOutput must stay within outdir")}if(!e.clean||e.dryRun)return;if(t===Iy(t).root)throw Error("Refusing to clean declarations from the filesystem root");let[i,r]=await Promise.all([er(t),er(ut(e.cwd,e.root))]);if(Gt(r,i))throw Error("Refusing to clean an outdir that contains the source root")}function qu(e){return[".d.ts",".d.mts",".d.cts",".d.ts.map",".d.mts.map",".d.cts.map"].some((t)=>e.endsWith(t))}function Pa(e,t){return e.dev===t.dev&&e.ino===t.ino}async function Ia(e,t){try{if(!(await zu(e)).isDirectory())throw Error(`Declaration output parent is not a directory: ${e}`);return}catch(r){if(!ui(r,"ENOENT"))throw r}let i=Lr(e);if(i===e)throw Error(`Cannot create declaration output directory: ${e}`);await Ia(i,t);try{await bo(e),t.push(e)}catch(r){if(!ui(r,"EEXIST")||!(await zu(e)).isDirectory())throw r}}async function Ju(e,t,i){for(let r of(await Oy(e,{withFileTypes:!0})).sort((n,o)=>n.name.localeCompare(o.name))){let n=ut(e,r.name);if(n===t)continue;if(r.isDirectory())await Ju(n,t,i);else if(qu(r.name)){let o=await fi(n);if(!o)throw Error(`Declaration output changed during inventory: ${n}`);i.set(n,o)}}}function Ma(e,t,i,r,n){return Object.assign(AggregateError(t,e),{code:"DTSX_PUBLICATION_FAILED",phase:i,recoveryDirectory:r,outputsCommitted:n})}async function Yu(e,t){if(e.dryRun||t.size===0&&!e.clean)return;await Na(e);let i=ut(e.cwd,e.outdir);if(t.size===0&&!await fi(i))return;let r=ut(i,".dtsx-publication"),n=new Map;for(let[m,c]of t){let v=ut(m);if(!Hu(m)||v===i||!Gt(v,i)||Gt(v,r)||!qu(v))throw Error(`Invalid declaration publication target: ${m}`);if(n.has(v))throw Error(`Duplicate declaration publication target: ${m}`);n.set(v,c)}let o=[],s=[],l=[],a=!1,f,u,d=!1;async function h(m,c){let v=await er(Lr(m));if(!Gt(v,c))throw Error(`Declaration publication parent escapes outdir: ${m}`);if(Gt(v,ut(c,".dtsx-publication")))throw Error(`Declaration publication target overlaps its transaction directory: ${m}`)}async function p(){if(!a)return;if(!f)throw Error(`Cannot verify declaration publication ownership: ${r}`);let m=await fi(r);if(!m||!Pa(m,f))throw Error(`Declaration publication ownership changed: ${r}`);if(u&&await er(r)!==ut(u,".dtsx-publication"))throw Error(`Declaration publication location changed: ${r}`);await Uu(r,{recursive:!0})}try{await Ia(i,o);try{await bo(r)}catch(v){if(ui(v,"EEXIST"))throw Error(`Declaration publication is active or requires recovery at ${r}`,{cause:v});throw v}a=!0,f=await Da(r),u=await er(i);let m=new Map;if(e.clean)await Ju(i,r,m);for(let v of n.keys()){await h(v,u);let b=await fi(v);if(b&&!b.isFile())throw Error(`Declaration publication target is not a regular file: ${v}`);if(b)m.set(v,b)}for(let v of m.keys())await h(v,u);await bo(ut(r,"staged")),await bo(ut(r,"backups"));let c=new Map;for(let v of new Set([...m.keys(),...n.keys()])){let b=c.size.toString();c.set(v,{path:v,existing:m.get(v),backup:ut(r,"backups",b),staged:n.has(v)?ut(r,"staged",b):void 0})}await My(ut(r,"manifest.json"),JSON.stringify({version:1,outdir:i,targets:[...c.values()].map((v)=>({path:Ku(i,v.path),backup:Ku(r,v.backup),hadPrevious:!!v.existing}))}));for(let[v,b]of n){let C=c.get(v),k=C.staged;if(await vo(k,b.content,b.lineEnding),!e.clean&&C.existing)await Ty(k,C.existing.mode&511);C.stagedIdentity=await Da(k)}for(let v of c.values()){if(!v.existing)continue;await h(v.path,u);let b=await fi(v.path);if(!b||!Pa(b,v.existing))throw Error(`Declaration output changed before commit: ${v.path}`);await Ra(v.path,v.backup),s.push(v)}for(let v of c.values()){if(!v.staged||!v.stagedIdentity)continue;if(await h(v.path,u),await Ia(Lr(v.path),o),await h(v.path,u),await fi(v.path))throw Error(`Declaration output appeared during commit: ${v.path}`);await Ra(v.staged,v.path),l.push({path:v.path,identity:v.stagedIdentity})}d=!0;try{await p()}catch(v){throw Ma(`Declaration outputs committed, but transaction cleanup failed at ${r}`,[v],"finalize",r,!0)}}catch(m){if(d)throw m;let c=[];for(let b of l.toReversed())try{if(u)await h(b.path,u);let C=await fi(b.path);if(!C)continue;if(!Pa(C,b.identity))throw Error(`Installed declaration changed before rollback: ${b.path}`);await Uu(b.path)}catch(C){c.push(C)}for(let b of s.toReversed())try{if(u)await h(b.path,u);if(await fi(b.path))throw Error(`Cannot restore declaration over an existing path: ${b.path}`);await Ra(b.backup,b.path)}catch(C){c.push(C)}if(c.length>0)throw Ma(`Declaration rollback failed; recovery data retained at ${r}`,[m,...c],"rollback",r,!1);let v=[];try{await p()}catch(b){v.push(b)}for(let b of o.toReversed())try{await Py(b)}catch(C){if(!ui(C,"ENOENT")&&!ui(C,"ENOTEMPTY")&&!ui(C,"EEXIST"))v.push(C)}if(v.length>0)throw Ma(`Prior declarations retained, but publication cleanup failed at ${r}`,[m,...v],"cleanup",a?r:void 0,!1);throw m}}var Xu=me(()=>{ka();Oa()});function Zu(e,t,i){let r={file:t,message:"Unknown error",code:Br.UNKNOWN_ERROR};if(e instanceof Error){r.message=e.message,r.stack=e.stack;let n=e.message.match(/\((\d+),(\d+)\)/);if(n)r.location={line:Number.parseInt(n[1],10),column:Number.parseInt(n[2],10)};if(e.message.includes("Cannot find")||e.message.includes("not found"))r.code=Br.FILE_NOT_FOUND,r.suggestion="Check that the file path is correct and the file exists.";else if(e.message.includes("syntax")||e.message.includes("Unexpected token"))r.code=Br.SYNTAX_ERROR,r.suggestion="Check for syntax errors in your TypeScript code.";else if(e.message.includes("type")&&e.message.includes("cannot"))r.code=Br.TYPE_INFERENCE_ERROR,r.suggestion="Add explicit type annotations to help with type inference.";else if(e.message.includes("parse")||e.message.includes("Parse"))r.code=Br.PARSE_ERROR,r.suggestion="The file contains invalid TypeScript syntax."}else if(typeof e==="string")r.message=e;return r}function Qu(e,t){let i=[],r=e.file;if(e.location)r+=`:${e.location.line}:${e.location.column}`;if(e.code)r+=` [${e.code}]`;if(i.push(r),i.push(` Error: ${e.message}`),t&&e.location){i.push("");let n=t.split(`
242
+ `).length;for(let d=0;d<n.length;d++){if(n[d].trim()===""){o.push("");continue}l=0;let h=Math.min(d,u-1),p=[],m=0-l,c=0,C=h-a,b=0-f;p.push(s(m)+s(c)+s(C)+s(b)),l=0,a=h,f=0,o.push(p.join(","))}return{version:3,file:t,sourceRoot:"",sources:[i],sourcesContent:[r],mappings:o.join(";")}}function Vu(e,t){return`${e}
243
+ ${Oa()}${t}
244
+ `}var Ra=me(()=>{ar();Nu();Lu();Ms()});import{chmod as Py,lstat as Ia,mkdir as Eo,readdir as My,realpath as Dy,rename as Pa,rm as Uu,rmdir as Iy,stat as zu,writeFile as Ny}from"fs/promises";import{basename as Fy,dirname as Lr,isAbsolute as Hu,parse as Wy,relative as Ku,resolve as ut}from"path";function ui(e,t){return e instanceof Error&&"code"in e&&e.code===t}async function fi(e){try{return await Ia(e)}catch(t){if(ui(t,"ENOENT"))return;throw t}}async function tr(e){let t=ut(e);try{return await Dy(t)}catch(i){if(!ui(i,"ENOENT")||Lr(t)===t)throw i;return ut(await tr(Lr(t)),Fy(t))}}async function Fa(e){let t=ut(e.cwd,e.outdir);if(e.bundle&&e.bundleOutput){if(Hu(e.bundleOutput))throw Error("bundleOutput must be relative to outdir");if(!Gt(ut(t,e.bundleOutput),t))throw Error("bundleOutput must stay within outdir")}if(!e.clean||e.dryRun)return;if(t===Wy(t).root)throw Error("Refusing to clean declarations from the filesystem root");let[i,r]=await Promise.all([tr(t),tr(ut(e.cwd,e.root))]);if(Gt(r,i))throw Error("Refusing to clean an outdir that contains the source root")}function qu(e){return[".d.ts",".d.mts",".d.cts",".d.ts.map",".d.mts.map",".d.cts.map"].some((t)=>e.endsWith(t))}function Ma(e,t){return e.dev===t.dev&&e.ino===t.ino}async function Na(e,t){try{if(!(await zu(e)).isDirectory())throw Error(`Declaration output parent is not a directory: ${e}`);return}catch(r){if(!ui(r,"ENOENT"))throw r}let i=Lr(e);if(i===e)throw Error(`Cannot create declaration output directory: ${e}`);await Na(i,t);try{await Eo(e),t.push(e)}catch(r){if(!ui(r,"EEXIST")||!(await zu(e)).isDirectory())throw r}}async function Ju(e,t,i){for(let r of(await My(e,{withFileTypes:!0})).sort((n,o)=>n.name.localeCompare(o.name))){let n=ut(e,r.name);if(n===t)continue;if(r.isDirectory())await Ju(n,t,i);else if(qu(r.name)){let o=await fi(n);if(!o)throw Error(`Declaration output changed during inventory: ${n}`);i.set(n,o)}}}function Da(e,t,i,r,n){return Object.assign(AggregateError(t,e),{code:"DTSX_PUBLICATION_FAILED",phase:i,recoveryDirectory:r,outputsCommitted:n})}async function Yu(e,t){if(e.dryRun||t.size===0&&!e.clean)return;await Fa(e);let i=ut(e.cwd,e.outdir);if(t.size===0&&!await fi(i))return;let r=ut(i,".dtsx-publication"),n=new Map;for(let[m,c]of t){let C=ut(m);if(!Hu(m)||C===i||!Gt(C,i)||Gt(C,r)||!qu(C))throw Error(`Invalid declaration publication target: ${m}`);if(n.has(C))throw Error(`Duplicate declaration publication target: ${m}`);n.set(C,c)}let o=[],s=[],l=[],a=!1,f,u,d=!1;async function h(m,c){let C=await tr(Lr(m));if(!Gt(C,c))throw Error(`Declaration publication parent escapes outdir: ${m}`);if(Gt(C,ut(c,".dtsx-publication")))throw Error(`Declaration publication target overlaps its transaction directory: ${m}`)}async function p(){if(!a)return;if(!f)throw Error(`Cannot verify declaration publication ownership: ${r}`);let m=await fi(r);if(!m||!Ma(m,f))throw Error(`Declaration publication ownership changed: ${r}`);if(u&&await tr(r)!==ut(u,".dtsx-publication"))throw Error(`Declaration publication location changed: ${r}`);await Uu(r,{recursive:!0})}try{await Na(i,o);try{await Eo(r)}catch(C){if(ui(C,"EEXIST"))throw Error(`Declaration publication is active or requires recovery at ${r}`,{cause:C});throw C}a=!0,f=await Ia(r),u=await tr(i);let m=new Map;if(e.clean)await Ju(i,r,m);for(let C of n.keys()){await h(C,u);let b=await fi(C);if(b&&!b.isFile())throw Error(`Declaration publication target is not a regular file: ${C}`);if(b)m.set(C,b)}for(let C of m.keys())await h(C,u);await Eo(ut(r,"staged")),await Eo(ut(r,"backups"));let c=new Map;for(let C of new Set([...m.keys(),...n.keys()])){let b=c.size.toString();c.set(C,{path:C,existing:m.get(C),backup:ut(r,"backups",b),staged:n.has(C)?ut(r,"staged",b):void 0})}await Ny(ut(r,"manifest.json"),JSON.stringify({version:1,outdir:i,targets:[...c.values()].map((C)=>({path:Ku(i,C.path),backup:Ku(r,C.backup),hadPrevious:!!C.existing}))}));for(let[C,b]of n){let v=c.get(C),k=v.staged;if(await $o(k,b.content,b.lineEnding),!e.clean&&v.existing)await Py(k,v.existing.mode&511);v.stagedIdentity=await Ia(k)}for(let C of c.values()){if(!C.existing)continue;await h(C.path,u);let b=await fi(C.path);if(!b||!Ma(b,C.existing))throw Error(`Declaration output changed before commit: ${C.path}`);await Pa(C.path,C.backup),s.push(C)}for(let C of c.values()){if(!C.staged||!C.stagedIdentity)continue;if(await h(C.path,u),await Na(Lr(C.path),o),await h(C.path,u),await fi(C.path))throw Error(`Declaration output appeared during commit: ${C.path}`);await Pa(C.staged,C.path),l.push({path:C.path,identity:C.stagedIdentity})}d=!0;try{await p()}catch(C){throw Da(`Declaration outputs committed, but transaction cleanup failed at ${r}`,[C],"finalize",r,!0)}}catch(m){if(d)throw m;let c=[];for(let b of l.toReversed())try{if(u)await h(b.path,u);let v=await fi(b.path);if(!v)continue;if(!Ma(v,b.identity))throw Error(`Installed declaration changed before rollback: ${b.path}`);await Uu(b.path)}catch(v){c.push(v)}for(let b of s.toReversed())try{if(u)await h(b.path,u);if(await fi(b.path))throw Error(`Cannot restore declaration over an existing path: ${b.path}`);await Pa(b.backup,b.path)}catch(v){c.push(v)}if(c.length>0)throw Da(`Declaration rollback failed; recovery data retained at ${r}`,[m,...c],"rollback",r,!1);let C=[];try{await p()}catch(b){C.push(b)}for(let b of o.toReversed())try{await Iy(b)}catch(v){if(!ui(v,"ENOENT")&&!ui(v,"ENOTEMPTY")&&!ui(v,"EEXIST"))C.push(v)}if(C.length>0)throw Da(`Prior declarations retained, but publication cleanup failed at ${r}`,[m,...C],"cleanup",a?r:void 0,!1);throw m}}var Xu=me(()=>{Ta();Ra()});function Zu(e,t,i){let r={file:t,message:"Unknown error",code:Br.UNKNOWN_ERROR};if(e instanceof Error){r.message=e.message,r.stack=e.stack;let n=e.message.match(/\((\d+),(\d+)\)/);if(n)r.location={line:Number.parseInt(n[1],10),column:Number.parseInt(n[2],10)};if(e.message.includes("Cannot find")||e.message.includes("not found"))r.code=Br.FILE_NOT_FOUND,r.suggestion="Check that the file path is correct and the file exists.";else if(e.message.includes("syntax")||e.message.includes("Unexpected token"))r.code=Br.SYNTAX_ERROR,r.suggestion="Check for syntax errors in your TypeScript code.";else if(e.message.includes("type")&&e.message.includes("cannot"))r.code=Br.TYPE_INFERENCE_ERROR,r.suggestion="Add explicit type annotations to help with type inference.";else if(e.message.includes("parse")||e.message.includes("Parse"))r.code=Br.PARSE_ERROR,r.suggestion="The file contains invalid TypeScript syntax."}else if(typeof e==="string")r.message=e;return r}function Qu(e,t){let i=[],r=e.file;if(e.location)r+=`:${e.location.line}:${e.location.column}`;if(e.code)r+=` [${e.code}]`;if(i.push(r),i.push(` Error: ${e.message}`),t&&e.location){i.push("");let n=t.split(`
245
245
  `),o=e.location.line-1;if(o>=0&&o<n.length){let s=Math.max(0,o-1),l=Math.min(n.length-1,o+1);for(let a=s;a<=l;a++){let f=(a+1).toString().padStart(4," "),u=a===o?">":" ";if(i.push(` ${u} ${f} | ${n[a]}`),a===o&&e.location.column>0){let d=" ".repeat(10+e.location.column-1);i.push(` ${d}^`)}}}}if(e.suggestion)i.push(""),i.push(` Suggestion: ${e.suggestion}`);return i.join(`
246
- `)}var Br;var ed=me(()=>{Br={PARSE_ERROR:"PARSE_ERROR",SYNTAX_ERROR:"SYNTAX_ERROR",FILE_NOT_FOUND:"FILE_NOT_FOUND",FILE_READ_ERROR:"FILE_READ_ERROR",FILE_WRITE_ERROR:"FILE_WRITE_ERROR",TYPE_INFERENCE_ERROR:"TYPE_INFERENCE_ERROR",UNRESOLVED_TYPE:"UNRESOLVED_TYPE",EXTRACTION_ERROR:"EXTRACTION_ERROR",PROCESSING_ERROR:"PROCESSING_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",INVALID_DECLARATION:"INVALID_DECLARATION",CONFIG_ERROR:"CONFIG_ERROR",INVALID_ENTRYPOINT:"INVALID_ENTRYPOINT",CIRCULAR_DEPENDENCY:"CIRCULAR_DEPENDENCY",TIMEOUT_ERROR:"TIMEOUT_ERROR",NOT_SUPPORTED:"NOT_SUPPORTED",UNKNOWN_ERROR:"UNKNOWN_ERROR"}});async function Ny(){if($o!==null)return $o;try{return di=await import("prettier"),$o=!0,!0}catch{return $o=!1,!1}}async function Fy(e,t){if(!di)return null;try{if(t&&di.resolveConfig){let i=await di.resolveConfig(t);if(i)return i}if(e&&di.resolveConfig){let i=await di.resolveConfig(e);if(i)return i}return null}catch{return null}}async function Wy(e,t){if(!di)throw Error("Prettier is not available");let i={...t,parser:t.parser||"typescript"};return di.format(e,i)}function Ly(e,t={}){let{indentSize:i=2,useTabs:r=!1,maxLineWidth:n=100,trailingNewline:o=!0,normalizeWhitespace:s=!0,sortImports:l=!0,groupImports:a=!0}=t,f=e,u=r?"\t":" ".repeat(i);if(f.indexOf(`\r
246
+ `)}var Br;var ed=me(()=>{Br={PARSE_ERROR:"PARSE_ERROR",SYNTAX_ERROR:"SYNTAX_ERROR",FILE_NOT_FOUND:"FILE_NOT_FOUND",FILE_READ_ERROR:"FILE_READ_ERROR",FILE_WRITE_ERROR:"FILE_WRITE_ERROR",TYPE_INFERENCE_ERROR:"TYPE_INFERENCE_ERROR",UNRESOLVED_TYPE:"UNRESOLVED_TYPE",EXTRACTION_ERROR:"EXTRACTION_ERROR",PROCESSING_ERROR:"PROCESSING_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",INVALID_DECLARATION:"INVALID_DECLARATION",CONFIG_ERROR:"CONFIG_ERROR",INVALID_ENTRYPOINT:"INVALID_ENTRYPOINT",CIRCULAR_DEPENDENCY:"CIRCULAR_DEPENDENCY",TIMEOUT_ERROR:"TIMEOUT_ERROR",NOT_SUPPORTED:"NOT_SUPPORTED",UNKNOWN_ERROR:"UNKNOWN_ERROR"}});async function Ly(){if(xo!==null)return xo;try{return di=await import("prettier"),xo=!0,!0}catch{return xo=!1,!1}}async function By(e,t){if(!di)return null;try{if(t&&di.resolveConfig){let i=await di.resolveConfig(t);if(i)return i}if(e&&di.resolveConfig){let i=await di.resolveConfig(e);if(i)return i}return null}catch{return null}}async function _y(e,t){if(!di)throw Error("Prettier is not available");let i={...t,parser:t.parser||"typescript"};return di.format(e,i)}function jy(e,t={}){let{indentSize:i=2,useTabs:r=!1,maxLineWidth:n=100,trailingNewline:o=!0,normalizeWhitespace:s=!0,sortImports:l=!0,groupImports:a=!0}=t,f=e,u=r?"\t":" ".repeat(i);if(f.indexOf(`\r
247
247
  `)!==-1)f=f.replace(/\r\n/g,`
248
248
  `);if(s){if(/[ \t]\n/.test(f)||/[ \t]$/.test(f))f=f.replace(/[ \t]+$/gm,"");if(f.indexOf(`
249
249
 
250
250
 
251
251
  `)!==-1)f=f.replace(/\n{3,}/g,`
252
252
 
253
- `);f=By(f,u)}if(l||a)f=_y(f,{sort:l,group:a});if(n>0)f=Gy(f,n,u);if(o&&!f.endsWith(`
253
+ `);f=Gy(f,u)}if(l||a)f=Vy(f,{sort:l,group:a});if(n>0)f=zy(f,n,u);if(o&&!f.endsWith(`
254
254
  `))f+=`
255
- `;return f}function By(e,t){let i=e.split(`
255
+ `;return f}function Gy(e,t){let i=e.split(`
256
256
  `),r=[];for(let n of i){let o=n.match(/^(\s*)(.*)$/);if(!o){r.push(n);continue}let[,s,l]=o;if(!l){r.push("");continue}let a=s.replace(/\t/g," ").length,f=Math.floor(a/2);r.push(t.repeat(f)+l)}return r.join(`
257
- `)}function _y(e,t){let i=e.split(`
258
- `),r=[],n=[],o=!1,s=0;for(let a=0;a<i.length;a++){let f=i[a],u=f.match(/^(import\s+(?:type\s+)?.*from\s+['"])([^'"]+)(['"].*)$/);if(u){o=!0,s=a;let d=u[1];r.push({line:f,source:u[2],isType:d.startsWith("import type ")||d.startsWith("import type\t")})}else if(o&&f.trim()==="")continue;else{if(o)o=!1;n.push(f)}}if(r.length===0)return e;if(t.sort)r.sort((a,f)=>{if(a.isType!==f.isType)return a.isType?1:-1;return jy(a.source,f.source)});let l;if(t.group){let a=[],f=[],u=[],d=[],h=[];for(let p=0;p<r.length;p++){let m=r[p],c=m.source;if(c.charCodeAt(0)===46)h.push(m);else if(c.startsWith("node:"))a.push(m);else if(c.charCodeAt(0)===64)d.push(m);else if(c.includes("/"))u.push(m);else f.push(m)}l=[...a.map((p)=>p.line),...a.length>0&&f.length>0?[""]:[],...f.map((p)=>p.line),...(a.length>0||f.length>0)&&u.length>0?[""]:[],...u.map((p)=>p.line),...d.length>0&&(a.length>0||f.length>0||u.length>0)?[""]:[],...d.map((p)=>p.line),...h.length>0?[""]:[],...h.map((p)=>p.line)]}else l=r.map((a)=>a.line);return[...l,"",...n].join(`
259
- `)}function jy(e,t){let i=e.startsWith("node:"),r=t.startsWith("node:");if(i!==r)return i?-1:1;let n=e.startsWith("."),o=t.startsWith(".");if(n!==o)return n?1:-1;return e.localeCompare(t)}function Gy(e,t,i){let r=e.split(`
260
- `),n=[];for(let o of r){if(o.length<=t){n.push(o);continue}if(o.trimStart().startsWith("import ")){n.push(o);continue}let s=o.match(/^(\s*)/)?.[1]||"",l=s+i,a=Uy(o,s,l);if(a){n.push(...a);continue}if(o.includes("{")&&o.includes("}")){let f=zy(o,t,s,l);n.push(...f);continue}if(o.includes(" | ")){let f=Ky(o,t,s,l);n.push(...f);continue}n.push(o)}return n.join(`
261
- `)}function Uy(e,t,i){let r=e.match(Vy);if(!r)return null;let[,n,o,s,l]=r,a=s.split(",").map((d)=>d.trim()).filter(Boolean);if(a.length<=1)return[e];let f=`${t}${n}${o??""} {`,u=l?`${t}} ${l};`:`${t}};`;return[f,...a.map((d)=>`${i}${d},`),u]}function zy(e,t,i,r){let n=e.match(/^(\s*)(.*?)(\{)(.+)(\}.*)$/);if(!n)return[e];let[,,o,s,l,a]=n,f=l.split(/;\s*|,\s*/).filter((u)=>u.trim());if(f.length<=1)return[e];return[`${i}${o}${s}`,...f.map((u)=>`${r}${u.trim()};`),`${i}${a.trim()}`]}function Ky(e,t,i,r){let n=e.match(/^(\s*)(.*?=\s*)(.+)$/);if(!n)return[e];let[,,o,s]=n,l=s.split(/\s*\|\s*/).filter((a)=>a.trim());if(l.length<=2)return[e];return[`${i}${o}`,...l.map((a,f)=>`${r}${f>0?"| ":" "}${a.trim()}`)]}async function td(e,t={},i){let r=[];if(t.usePrettier!==!1){if(await Ny())try{let n={...await Fy(t.prettierConfigPath,i),...t.prettierOptions,parser:"typescript"};return{content:await Wy(e,n),usedPrettier:!0}}catch(n){r.push(`Prettier formatting failed: ${n}. Using built-in formatter.`)}else if(t.usePrettier===!0)r.push("Prettier requested but not available. Using built-in formatter.")}return{content:Ly(e,t.builtIn),usedPrettier:!1,warnings:r.length>0?r:void 0}}var $o=null,di=null,Vy;var id=me(()=>{Vy=/^\s*(export|import)(\s+type)?\s*\{([^{}]*)\}\s*(from\s*(?:'[^']*'|"[^"]*")(?:\s*(?:with|assert)\s*\{[^{}]*\})?)?\s*;?\s*$/});function rd(e,t){let i=new Set;for(let r of $r(e,"imports.ts",!1)){if(r.kind!=="import")continue;let n=bi(r.text),o=n&&t.get(n.source);if(!n||n.isTypeOnly||!o)continue;let s=Eo(o);for(let l of n.namedItems)if(!l.isTypeOnly&&s.some((a)=>a.name===l.originalName))i.add(l.name);if(n.defaultName&&s.some((l)=>l.isDefault))i.add(n.defaultName)}return i}function Eo(e){let t=$r(e,"dependency.ts",!1).filter((i)=>i.kind==="function");return t.filter((i)=>i.isExported&&!i.generics&&t.filter((r)=>r.name===i.name).length===1&&cn(e,i.name)===1).map((i)=>({name:i.name,isDefault:Boolean(i.isDefault)})).sort((i,r)=>i.name.localeCompare(r.name))}var nd=me(()=>{es();Tn();$i()});import{existsSync as Hy}from"fs";import{arch as qy,platform as od}from"os";import{fileURLToPath as Jy}from"url";function sd(){return`${od()==="win32"?"windows":od()}-${qy()}`}function Yy(e){let t=[],i=process.env.DTSX_NATIVE_LIBRARY;if(i)t.push(i);for(let r of[`../native/${sd()}/${e}`,`../../native/${sd()}/${e}`,`../../zig-dtsx/zig-out/lib/${e}`,`../../zig-dtsx/zig-out/bin/${e}`])try{t.push(Jy(new URL(r,import.meta.url)))}catch{}return t}function Xy(){if(process.env.DTSX_ENGINE==="typescript"||typeof globalThis.Bun>"u")return null;let e;try{e=import.meta.require("bun:ffi")}catch{return null}let{dlopen:t,FFIType:i,ptr:r,suffix:n,toArrayBuffer:o}=e,s=n==="dll"?`zig-dtsx.${n}`:`libzig-dtsx.${n}`;for(let l of Yy(s)){if(!Hy(l))continue;try{let a=t(l,{process_source_checked_v1:{args:[i.ptr,i.u64,i.bool,i.bool,i.ptr,i.ptr],returns:i.ptr},process_source_with_context_v1:{args:[i.ptr,i.u64,i.bool,i.bool,i.ptr,i.u64,i.ptr,i.ptr],returns:i.ptr},free_result:{args:[i.ptr,i.u64],returns:i.void}}),{symbols:f}=a,u=new TextDecoder;return{checked:(d,h,p,m,c,v)=>f.process_source_checked_v1(r(d),h,p,m,r(c),r(v)),contextual:(d,h,p,m,c,v,b,C)=>f.process_source_with_context_v1(r(d),h,p,m,r(c),v,r(b),r(C)),read:(d,h)=>{if(!d)return"";let p=h?u.decode(o(d,0,h)):"";return f.free_result(d,h),p}}}catch{continue}}return null}function Zy(){if(Fa===void 0)Fa=Xy();return Fa}function ld(e,t){let i=Zy();if(!i)return null;if(e.length*3>tr.length)tr=new Uint8Array(e.length*3);let{written:r}=ad.encodeInto(e,tr),n=(t.inferenceSources?.size??0)>0||(t.augmentationImports?.size??0)>0,o;if(n){let l=t.sourceFile??"source.ts",a=ad.encode(JSON.stringify({version:1,moduleSpecifierMode:"preserve",sourceFile:l,outputFile:l.replace(/\.[cm]?tsx?$/,".d.ts"),sourceHash:new Bun.CryptoHasher("sha256").update(tr.subarray(0,r)).digest("hex"),rewrites:[],augmentationImports:[...t.augmentationImports??[]],inferenceSources:[...t.inferenceSources??[]].map(([f,u])=>({specifier:f,source:u}))}));o=i.contextual(tr,r,t.keepComments,t.isolatedDeclarations,a,a.length,Wa,La)}else o=i.checked(tr,r,t.keepComments,t.isolatedDeclarations,Wa,La);let s=Number(Wa[0]);if(La[0]!==0)return i.read(o,s),null;return i.read(o,s)}var Fa,ad,tr,Wa,La;var cd=me(()=>{ad=new TextEncoder,tr=new Uint8Array(65536),Wa=new BigUint64Array(1),La=new Uint32Array(1)});function dd(e,t={}){let{lineEnding:i="lf",trailingNewline:r=!0,maxBlankLines:n=1,trimTrailingWhitespace:o=!0,normalizeIndentation:s=!0,indent:l={style:"spaces",size:2},declarationOrder:a,importGrouping:f,preserveComments:u=!0,insertFinalNewline:d=!0}=t,h=e;if(h=t0(h,i),f?.enabled!==!1)h=s0(h,f||{});if(a)h=a0(h,a);if(o)h=i0(h);if(h=r0(h,n),s)h=o0(h,l);if(r||d)h=n0(h);return h}function t0(e,t){let i=e;if(e.indexOf("\r")!==-1){if(e.indexOf(`\r
257
+ `)}function Vy(e,t){let i=e.split(`
258
+ `),r=[],n=[],o=!1,s=0;for(let a=0;a<i.length;a++){let f=i[a],u=f.match(/^(import\s+(?:type\s+)?.*from\s+['"])([^'"]+)(['"].*)$/);if(u){o=!0,s=a;let d=u[1];r.push({line:f,source:u[2],isType:d.startsWith("import type ")||d.startsWith("import type\t")})}else if(o&&f.trim()==="")continue;else{if(o)o=!1;n.push(f)}}if(r.length===0)return e;if(t.sort)r.sort((a,f)=>{if(a.isType!==f.isType)return a.isType?1:-1;return Uy(a.source,f.source)});let l;if(t.group){let a=[],f=[],u=[],d=[],h=[];for(let p=0;p<r.length;p++){let m=r[p],c=m.source;if(c.charCodeAt(0)===46)h.push(m);else if(c.startsWith("node:"))a.push(m);else if(c.charCodeAt(0)===64)d.push(m);else if(c.includes("/"))u.push(m);else f.push(m)}l=[...a.map((p)=>p.line),...a.length>0&&f.length>0?[""]:[],...f.map((p)=>p.line),...(a.length>0||f.length>0)&&u.length>0?[""]:[],...u.map((p)=>p.line),...d.length>0&&(a.length>0||f.length>0||u.length>0)?[""]:[],...d.map((p)=>p.line),...h.length>0?[""]:[],...h.map((p)=>p.line)]}else l=r.map((a)=>a.line);return[...l,"",...n].join(`
259
+ `)}function Uy(e,t){let i=e.startsWith("node:"),r=t.startsWith("node:");if(i!==r)return i?-1:1;let n=e.startsWith("."),o=t.startsWith(".");if(n!==o)return n?1:-1;return e.localeCompare(t)}function zy(e,t,i){let r=e.split(`
260
+ `),n=[];for(let o of r){if(o.length<=t){n.push(o);continue}if(o.trimStart().startsWith("import ")){n.push(o);continue}let s=o.match(/^(\s*)/)?.[1]||"",l=s+i,a=Hy(o,s,l);if(a){n.push(...a);continue}if(o.includes("{")&&o.includes("}")){let f=qy(o,t,s,l);n.push(...f);continue}if(o.includes(" | ")){let f=Jy(o,t,s,l);n.push(...f);continue}n.push(o)}return n.join(`
261
+ `)}function Hy(e,t,i){let r=e.match(Ky);if(!r)return null;let[,n,o,s,l]=r,a=s.split(",").map((d)=>d.trim()).filter(Boolean);if(a.length<=1)return[e];let f=`${t}${n}${o??""} {`,u=l?`${t}} ${l};`:`${t}};`;return[f,...a.map((d)=>`${i}${d},`),u]}function qy(e,t,i,r){let n=e.match(/^(\s*)(.*?)(\{)(.+)(\}.*)$/);if(!n)return[e];let[,,o,s,l,a]=n,f=l.split(/;\s*|,\s*/).filter((u)=>u.trim());if(f.length<=1)return[e];return[`${i}${o}${s}`,...f.map((u)=>`${r}${u.trim()};`),`${i}${a.trim()}`]}function Jy(e,t,i,r){let n=e.match(/^(\s*)(.*?=\s*)(.+)$/);if(!n)return[e];let[,,o,s]=n,l=s.split(/\s*\|\s*/).filter((a)=>a.trim());if(l.length<=2)return[e];return[`${i}${o}`,...l.map((a,f)=>`${r}${f>0?"| ":" "}${a.trim()}`)]}async function td(e,t={},i){let r=[];if(t.usePrettier!==!1){if(await Ly())try{let n={...await By(t.prettierConfigPath,i),...t.prettierOptions,parser:"typescript"};return{content:await _y(e,n),usedPrettier:!0}}catch(n){r.push(`Prettier formatting failed: ${n}. Using built-in formatter.`)}else if(t.usePrettier===!0)r.push("Prettier requested but not available. Using built-in formatter.")}return{content:jy(e,t.builtIn),usedPrettier:!1,warnings:r.length>0?r:void 0}}var xo=null,di=null,Ky;var id=me(()=>{Ky=/^\s*(export|import)(\s+type)?\s*\{([^{}]*)\}\s*(from\s*(?:'[^']*'|"[^"]*")(?:\s*(?:with|assert)\s*\{[^{}]*\})?)?\s*;?\s*$/});function rd(e,t){let i=new Set;for(let r of $r(e,"imports.ts",!1)){if(r.kind!=="import")continue;let n=$i(r.text),o=n&&t.get(n.source);if(!n||n.isTypeOnly||!o)continue;let s=So(o);for(let l of n.namedItems)if(!l.isTypeOnly&&s.some((a)=>a.name===l.originalName))i.add(l.name);if(n.defaultName&&s.some((l)=>l.isDefault))i.add(n.defaultName)}return i}function So(e){let t=$r(e,"dependency.ts",!1).filter((i)=>i.kind==="function");return t.filter((i)=>i.isExported&&!i.generics&&t.filter((r)=>r.name===i.name).length===1&&cn(e,i.name)===1).map((i)=>({name:i.name,isDefault:Boolean(i.isDefault)})).sort((i,r)=>i.name.localeCompare(r.name))}var nd=me(()=>{is();Rn();Ei()});import{existsSync as Yy}from"fs";import{arch as Xy,platform as od}from"os";import{fileURLToPath as Zy}from"url";function sd(){return`${od()==="win32"?"windows":od()}-${Xy()}`}function Qy(e){let t=[],i=process.env.DTSX_NATIVE_LIBRARY;if(i)t.push(i);for(let r of[`../native/${sd()}/${e}`,`../../native/${sd()}/${e}`,`../../zig-dtsx/zig-out/lib/${e}`,`../../zig-dtsx/zig-out/bin/${e}`])try{t.push(Zy(new URL(r,import.meta.url)))}catch{}return t}function e0(){if(process.env.DTSX_ENGINE==="typescript"||typeof globalThis.Bun>"u")return null;let e;try{e=import.meta.require("bun:ffi")}catch{return null}let{dlopen:t,FFIType:i,ptr:r,suffix:n,toArrayBuffer:o}=e,s=n==="dll"?`zig-dtsx.${n}`:`libzig-dtsx.${n}`;for(let l of Qy(s)){if(!Yy(l))continue;try{let a=t(l,{process_source_checked_v1:{args:[i.ptr,i.u64,i.bool,i.bool,i.ptr,i.ptr],returns:i.ptr},process_source_with_context_v1:{args:[i.ptr,i.u64,i.bool,i.bool,i.ptr,i.u64,i.ptr,i.ptr],returns:i.ptr},free_result:{args:[i.ptr,i.u64],returns:i.void}}),{symbols:f}=a,u=new TextDecoder;return{checked:(d,h,p,m,c,C)=>f.process_source_checked_v1(r(d),h,p,m,r(c),r(C)),contextual:(d,h,p,m,c,C,b,v)=>f.process_source_with_context_v1(r(d),h,p,m,r(c),C,r(b),r(v)),read:(d,h)=>{if(!d)return"";let p=h?u.decode(o(d,0,h)):"";return f.free_result(d,h),p}}}catch{continue}}return null}function t0(){if(Wa===void 0)Wa=e0();return Wa}function ld(e,t){let i=t0();if(!i)return null;if(e.length*3>ir.length)ir=new Uint8Array(e.length*3);let{written:r}=ad.encodeInto(e,ir),n=(t.inferenceSources?.size??0)>0||(t.augmentationImports?.size??0)>0,o;if(n){let l=t.sourceFile??"source.ts",a=ad.encode(JSON.stringify({version:1,moduleSpecifierMode:"preserve",sourceFile:l,outputFile:l.replace(/\.[cm]?tsx?$/,".d.ts"),sourceHash:new Bun.CryptoHasher("sha256").update(ir.subarray(0,r)).digest("hex"),rewrites:[],augmentationImports:[...t.augmentationImports??[]],inferenceSources:[...t.inferenceSources??[]].map(([f,u])=>({specifier:f,source:u}))}));o=i.contextual(ir,r,t.keepComments,t.isolatedDeclarations,a,a.length,La,Ba)}else o=i.checked(ir,r,t.keepComments,t.isolatedDeclarations,La,Ba);let s=Number(La[0]);if(Ba[0]!==0)return i.read(o,s),null;return i.read(o,s)}var Wa,ad,ir,La,Ba;var cd=me(()=>{ad=new TextEncoder,ir=new Uint8Array(65536),La=new BigUint64Array(1),Ba=new Uint32Array(1)});function dd(e,t={}){let{lineEnding:i="lf",trailingNewline:r=!0,maxBlankLines:n=1,trimTrailingWhitespace:o=!0,normalizeIndentation:s=!0,indent:l={style:"spaces",size:2},declarationOrder:a,importGrouping:f,preserveComments:u=!0,insertFinalNewline:d=!0}=t,h=e;if(h=n0(h,i),f?.enabled!==!1)h=c0(h,f||{});if(a)h=f0(h,a);if(o)h=o0(h);if(h=s0(h,n),s)h=l0(h,l);if(r||d)h=a0(h);return h}function n0(e,t){let i=e;if(e.indexOf("\r")!==-1){if(e.indexOf(`\r
262
262
  `)!==-1)i=i.replace(/\r\n/g,`
263
263
  `);if(i.indexOf("\r")!==-1)i=i.replace(/\r/g,`
264
264
  `)}if(t==="crlf")i=i.replace(/\n/g,`\r
265
- `);return i}function i0(e){return e.split(`
265
+ `);return i}function o0(e){return e.split(`
266
266
  `).map((t)=>t.replace(/[\t ]+$/,"")).join(`
267
- `)}function r0(e,t){let i=new RegExp(`\\n{${t+2},}`,"g");return e.replace(i,`
268
- `.repeat(t+1))}function n0(e){return`${e.replace(/\s+$/,"")}
269
- `}function o0(e,t){let{style:i="spaces",size:r=2}=t,n=i==="tabs"?"\t":" ".repeat(r),o=e.split(`
267
+ `)}function s0(e,t){let i=new RegExp(`\\n{${t+2},}`,"g");return e.replace(i,`
268
+ `.repeat(t+1))}function a0(e){return`${e.replace(/\s+$/,"")}
269
+ `}function l0(e,t){let{style:i="spaces",size:r=2}=t,n=i==="tabs"?"\t":" ".repeat(r),o=e.split(`
270
270
  `),s=[];for(let l of o){let a=l.match(/^([\t ]*)(.*)$/);if(!a){s.push(l);continue}let[,f,u]=a;if(!u){s.push("");continue}let d=f.replace(/\t/g," "),h=Math.floor(d.length/2);s.push(n.repeat(h)+u)}return s.join(`
271
- `)}function s0(e,t){let{groups:i=e0,separateGroups:r=!0,alphabetize:n=!0}=t,o=e.split(`
272
- `),s=[],l=[],a=-1;for(let m=0;m<o.length;m++){let c=o[m],v=fd(c);if(v)s.push({line:c,source:v.source,group:v.group,isType:v.isType}),a=m;else if(s.length>0&&c.trim()==="")continue;else if(s.length>0||c.trim()!==""){if(s.length===0||m>a+1)l.push(c)}}if(s.length===0)return e;let f=new Map;for(let m of i)f.set(m,[]);for(let m of s)(f.get(m.group)||f.get("external")||[]).push(m);if(n)for(let[,m]of f)m.sort((c,v)=>{if(c.isType!==v.isType)return c.isType?1:-1;return c.source.localeCompare(v.source)});let u=[],d=null;for(let m of i){let c=f.get(m)||[];if(c.length===0)continue;if(r&&d!==null)u.push("");for(let v of c)u.push(v.line);d=m}let h=o.slice(0,o.findIndex((m)=>fd(m)!==null)),p=l;while(p.length>0&&p[0].trim()==="")p.shift();return[...h,...u,"",...p].join(`
273
- `)}function fd(e){let t=e.trim(),i=t.match(/^import\s+(type\s+)?.*from\s+['"]([^'"]+)['"]/);if(!i){let o=t.match(/^import\s+['"]([^'"]+)['"]/);if(o)return{source:o[1],group:ud(o[1]),isType:!1};return null}let r=!!i[1],n=i[2];return{source:n,group:r?"type":ud(n),isType:r}}function ud(e){if(e.startsWith("node:"))return"builtin";let t=["assert","buffer","child_process","cluster","crypto","dgram","dns","events","fs","http","https","net","os","path","querystring","readline","stream","url","util","zlib"];if(t.includes(e)||t.includes(e.split("/")[0]))return"builtin";if(e==="."||e==="./index"||e==="./index.js"||e==="./index.ts")return"index";if(e.startsWith("./"))return"sibling";if(e.startsWith("../"))return"parent";if(e.startsWith("@/")||e.startsWith("~/")||e.startsWith("#"))return"internal";if(e.startsWith("@"))return"scoped";return"external"}function a0(e,t){let{kinds:i=Qy,alphabetize:r=!1,groupExports:n=!0}=t,o=e.split(`
274
- `),s=[],l=[],a=[],f=null,u=0,d=!0,h=!1,p=[];for(let v=0;v<o.length;v++){let b=o[v],C=b.trim(),k=u,W=C.startsWith("///"),A=k===0&&!W&&(C.startsWith("//")||C.startsWith("/*"));if(h||A){if(p.push(b),!h&&C.startsWith("/*")&&!C.includes("*/"))h=!0;else if(h&&C.includes("*/"))h=!1;continue}if(k===0&&p.length>0&&C===""){p.push(b);continue}u+=(b.match(/\{/g)||[]).length,u-=(b.match(/\}/g)||[]).length;let R=l0(C);if(d&&R&&R.kind!=="import"&&!C.startsWith("//")&&!C.startsWith("/*"))d=!1;if(d){if(p.length>0){if(R?.kind==="import"||!R)l.push(...p),p.length=0}l.push(b);continue}if(R&&u<=1){if(f)s.push(f);f={lines:p.length>0?[...p,b]:[b],kind:R.kind,name:R.name,isExport:R.isExport},p.length=0}else if(f)f.lines.push(b);else{if(C==="")continue;a.push(b)}}if(f)s.push(f);if(p.length>0)a.push(...p);s.sort((v,b)=>{if(n&&v.isExport!==b.isExport)return v.isExport?-1:1;let C=i.indexOf(v.kind),k=i.indexOf(b.kind),W=C>=0?C:i.length,A=k>=0?k:i.length;if(W!==A)return W-A;if(r)return v.name.localeCompare(b.name);return 0});let m=[...l],c=null;for(let v of s){if(c!==null&&v.kind!==c)m.push("");m.push(...v.lines),c=v.kind}if(a.length>0)m.push(""),m.push(...a);return m.join(`
275
- `)}function l0(e){let t=e.startsWith("export "),i=t?e.slice(7):e;if(e.startsWith("import "))return{kind:"import",name:e.match(/from\s+['"]([^'"]+)['"]/)?.[1]||"",isExport:!1};if(i.startsWith("type ")||i.startsWith("declare type "))return{kind:"type",name:i.match(/type\s+(\w+)/)?.[1]||"",isExport:t};if(i.startsWith("interface ")||i.startsWith("declare interface "))return{kind:"interface",name:i.match(/interface\s+(\w+)/)?.[1]||"",isExport:t};if(i.startsWith("class ")||i.startsWith("abstract class ")||i.startsWith("declare class ")||i.startsWith("declare abstract class "))return{kind:"class",name:i.match(/class\s+(\w+)/)?.[1]||"",isExport:t};if(i.startsWith("enum ")||i.startsWith("const enum ")||i.startsWith("declare enum ")||i.startsWith("declare const enum "))return{kind:"enum",name:i.match(/enum\s+(\w+)/)?.[1]||"",isExport:t};if(i.startsWith("function ")||i.startsWith("async function ")||i.startsWith("declare function ")||i.startsWith("declare async function "))return{kind:"function",name:i.match(/function\s+(\w+)/)?.[1]||"",isExport:t};if(i.startsWith("const ")||i.startsWith("let ")||i.startsWith("var ")||i.startsWith("declare const ")||i.startsWith("declare let ")||i.startsWith("declare var "))return{kind:"variable",name:i.match(/(?:const|let|var)\s+(\w+)/)?.[1]||"",isExport:t};if(i.startsWith("namespace ")||i.startsWith("declare namespace "))return{kind:"namespace",name:i.match(/namespace\s+(\w+)/)?.[1]||"",isExport:t};if(i.startsWith("module ")||i.startsWith("declare module "))return{kind:"module",name:i.match(/module\s+['"]?(\w+)['"]?/)?.[1]||"",isExport:t};if(e.startsWith("export {")||e.startsWith("export *")||e.startsWith("export type {"))return{kind:"export",name:"",isExport:!0};return null}var Qy,e0;var hd=me(()=>{Qy=["import","type","interface","enum","class","function","variable","export","module","namespace","unknown"],e0=["builtin","external","scoped","internal","parent","sibling","index","type"]});class xo{plugins=[];config=null;register(e){if(this.plugins.some((t)=>t.name===e.name))throw Error(`Plugin "${e.name}" is already registered`);this.plugins.push(e)}hasDeclarationHooks(){return this.plugins.some((e)=>e.onDeclarations!==void 0)}unregister(e){let t=this.plugins.findIndex((i)=>i.name===e);if(t>=0)return this.plugins.splice(t,1),!0;return!1}getPlugins(){return this.plugins}createLogger(e){return{debug:(t)=>console.debug(`[${e}] ${t}`),info:(t)=>console.info(`[${e}] ${t}`),warn:(t)=>console.warn(`[${e}] ${t}`),error:(t)=>console.error(`[${e}] ${t}`)}}async runOnStart(e){let t=e;for(let i of this.plugins)if(i.onStart){let r=await i.onStart(t);if(r)t=r}return this.config=t,t}async runOnBeforeFile(e,t){let i=t;for(let r of this.plugins)if(r.onBeforeFile){let n={filePath:e,sourceCode:t,content:i,config:this.config,log:this.createLogger(r.name)},o=await r.onBeforeFile(n);if(typeof o==="string")i=o}return i}async runOnDeclarations(e,t,i){let r=i;for(let n of this.plugins)if(n.onDeclarations){let o={filePath:e,sourceCode:t,declarations:r,config:this.config,log:this.createLogger(n.name)},s=await n.onDeclarations(o);if(s)r=s}return r}async runOnAfterFile(e,t,i){let r=i;for(let n of this.plugins)if(n.onAfterFile){let o={filePath:e,sourceCode:t,content:r,config:this.config,log:this.createLogger(n.name)},s=await n.onAfterFile(o);if(typeof s==="string")r=s}return r}async runOnEnd(e){for(let t of this.plugins)if(t.onEnd)await t.onEnd(e)}async runOnError(e,t,i){for(let r of this.plugins)if(r.onError){let n={filePath:t,sourceCode:i,config:this.config,log:this.createLogger(r.name)};await r.onError(e,n)}}}function c0(e){return e}var Sb,Ab;var pd=me(()=>{Sb=new xo;Ab=c0({name:"strip-internal",version:"1.0.0",description:"Removes declarations marked with @internal",onDeclarations:(e)=>e.declarations.filter((t)=>{if(t.leadingComments){if(t.leadingComments.some((i)=>i.includes("@internal")))return e.log.debug(`Stripping internal declaration: ${t.name}`),!1}return!0})})});function md(e){let t=[],i=0;for(let r=0;r<=e.length;r++)if(r===e.length||e[r]===`
276
- `){let n=i,o=r;while(n<o&&(e[n]===" "||e[n]==="\t"||e[n]==="\r"))n++;while(o>n&&(e[o-1]===" "||e[o-1]==="\t"||e[o-1]==="\r"))o--;let s=e.slice(n,o);if(i=r+1,s.startsWith("///")){if(s.indexOf("<")===-1)continue;if(f0.test(s)||u0.test(s)||d0.test(s))t.push(s)}else if(s===""||s.startsWith("//"))continue;else break}return t}var f0,u0,d0;var gd=me(()=>{f0=/^\/\/\/\s*<reference\s+(?:path|types|lib|no-default-lib)\s*=\s*["'][^"']+["']\s*\/>/,u0=/^\/\/\/\s*<amd-module\s+name\s*=\s*["'][^"']+["']\s*\/>/,d0=/^\/\/\/\s*<amd-dependency\s+path\s*=\s*["'][^"']+["']/});function yd(e,t){throw Error(t||`Unexpected value: ${e}`)}function bd(e,t,i=!0,r=["bun"]){let n="",o=t.sourceCode;if(o){let A=0;while(A<o.length&&(o.charCodeAt(A)===32||o.charCodeAt(A)===9||o.charCodeAt(A)===10||o.charCodeAt(A)===13))A++;if(A<o.length-2&&o.charCodeAt(A)===47&&o.charCodeAt(A+1)===47&&o.charCodeAt(A+2)===47){let R=md(o);if(R.length>0)for(let V=0;V<R.length;V++){if(n)n+=`
277
- `;n+=R[V]}}}let s=[],l=[],a=[],f=[],u=[],d=[],h=[],p=[],m=[];for(let A of e){let R=A.kind;switch(R){case"import":s.push(A);break;case"function":l.push(A);break;case"variable":a.push(A);break;case"interface":f.push(A);break;case"type":u.push(A);break;case"class":d.push(A);break;case"enum":h.push(A);break;case"module":p.push(A);break;case"export":m.push(A);break;case"namespace":p.push(A);break;case"unknown":break;default:yd(R,`Unhandled declaration kind: ${R}`)}}let c=[],v=[],b=[],C=new Set;for(let A of m){let R=Lt(A.leadingComments,i);if(A.text.startsWith("export default")){let V=A.text.endsWith(";")?A.text:`${A.text};`;b.push(R+V)}else{let V=A.text.trim();if(!V.endsWith(";"))V+=";";let B=R+V;if(!C.has(B))if(C.add(B),B.includes("export type"))c.push(B);else v.push(B)}}let k=[];if(s.length>0){let{usedItems:A}=Rn(e);for(let V of s){if(V.isSideEffect){let ge=V.text.trim(),ie=ge.endsWith(";")?ge:`${ge};`;k.push(ie);continue}let B=bi(V.text);if(!B)continue;let{defaultName:O,namedItems:z,isTypeOnly:X,namespaceName:ae}=B,be=O?A.has(O):!1,ke=ae?A.has(ae):!1;if(B.isImportEquals){if(be){let ge=V.text.trim();k.push(ge.endsWith(";")?ge:`${ge};`)}else if(t.augmentationImports?.has(B.source)){let ge=Sn(V.text);if(!ge)throw Error("Cannot locate an augmentation import module literal");k.push(`import ${ge};`)}continue}let ve="",we=0;for(let ge=0;ge<z.length;ge++){let ie=z[ge];if(A.has(ie.name)){if(we>0)ve+=", ";if(!X&&ie.isTypeOnly)ve+="type ";ve+=ie.originalName===ie.name?ie.name:`${ie.originalName} as ${ie.name}`,we++}}if(be||ke||we>0){let ge=X?"import type ":"import ";if(ke&&ae){if(be&&O)ge+=`${O}, `;ge+=`* as ${ae}`}else if(be&&O)ge+=we>0?`${O}, { ${ve} }`:O;else if(we>0)ge+=`{ ${ve} }`;let ie=Sn(V.text);if(!ie)throw Error("Cannot locate a grammatical module literal in the import declaration");ge+=` from ${ie};`,k.push(ge)}else if(t.augmentationImports?.has(B.source)){let ge=Sn(V.text);if(!ge)throw Error("Cannot locate an augmentation import module literal");k.push(`import ${ge};`)}}let R=r.length;if(k.length>1){if(wd!==r)wd=r,Cd=r.map((z)=>`from '${z}`),vd=r.map((z)=>`from "${z}`);let V=Cd,B=vd,O=new Map;for(let z of k){let X=R;for(let ae=0;ae<r.length;ae++)if(z.includes(V[ae])||z.includes(B[ae])){X=ae;break}O.set(z,X)}k.sort((z,X)=>{let ae=O.get(z),be=O.get(X);return ae!==be?ae-be:z.localeCompare(X)})}}for(let A=0;A<k.length;A++){if(n)n+=`
271
+ `)}function c0(e,t){let{groups:i=r0,separateGroups:r=!0,alphabetize:n=!0}=t,o=e.split(`
272
+ `),s=[],l=[],a=-1;for(let m=0;m<o.length;m++){let c=o[m],C=fd(c);if(C)s.push({line:c,source:C.source,group:C.group,isType:C.isType}),a=m;else if(s.length>0&&c.trim()==="")continue;else if(s.length>0||c.trim()!==""){if(s.length===0||m>a+1)l.push(c)}}if(s.length===0)return e;let f=new Map;for(let m of i)f.set(m,[]);for(let m of s)(f.get(m.group)||f.get("external")||[]).push(m);if(n)for(let[,m]of f)m.sort((c,C)=>{if(c.isType!==C.isType)return c.isType?1:-1;return c.source.localeCompare(C.source)});let u=[],d=null;for(let m of i){let c=f.get(m)||[];if(c.length===0)continue;if(r&&d!==null)u.push("");for(let C of c)u.push(C.line);d=m}let h=o.slice(0,o.findIndex((m)=>fd(m)!==null)),p=l;while(p.length>0&&p[0].trim()==="")p.shift();return[...h,...u,"",...p].join(`
273
+ `)}function fd(e){let t=e.trim(),i=t.match(/^import\s+(type\s+)?.*from\s+['"]([^'"]+)['"]/);if(!i){let o=t.match(/^import\s+['"]([^'"]+)['"]/);if(o)return{source:o[1],group:ud(o[1]),isType:!1};return null}let r=!!i[1],n=i[2];return{source:n,group:r?"type":ud(n),isType:r}}function ud(e){if(e.startsWith("node:"))return"builtin";let t=["assert","buffer","child_process","cluster","crypto","dgram","dns","events","fs","http","https","net","os","path","querystring","readline","stream","url","util","zlib"];if(t.includes(e)||t.includes(e.split("/")[0]))return"builtin";if(e==="."||e==="./index"||e==="./index.js"||e==="./index.ts")return"index";if(e.startsWith("./"))return"sibling";if(e.startsWith("../"))return"parent";if(e.startsWith("@/")||e.startsWith("~/")||e.startsWith("#"))return"internal";if(e.startsWith("@"))return"scoped";return"external"}function f0(e,t){let{kinds:i=i0,alphabetize:r=!1,groupExports:n=!0}=t,o=e.split(`
274
+ `),s=[],l=[],a=[],f=null,u=0,d=!0,h=!1,p=[];for(let C=0;C<o.length;C++){let b=o[C],v=b.trim(),k=u,W=v.startsWith("///"),A=k===0&&!W&&(v.startsWith("//")||v.startsWith("/*"));if(h||A){if(p.push(b),!h&&v.startsWith("/*")&&!v.includes("*/"))h=!0;else if(h&&v.includes("*/"))h=!1;continue}if(k===0&&p.length>0&&v===""){p.push(b);continue}u+=(b.match(/\{/g)||[]).length,u-=(b.match(/\}/g)||[]).length;let R=u0(v);if(d&&R&&R.kind!=="import"&&!v.startsWith("//")&&!v.startsWith("/*"))d=!1;if(d){if(p.length>0){if(R?.kind==="import"||!R)l.push(...p),p.length=0}l.push(b);continue}if(R&&u<=1){if(f)s.push(f);f={lines:p.length>0?[...p,b]:[b],kind:R.kind,name:R.name,isExport:R.isExport},p.length=0}else if(f)f.lines.push(b);else{if(v==="")continue;a.push(b)}}if(f)s.push(f);if(p.length>0)a.push(...p);s.sort((C,b)=>{if(n&&C.isExport!==b.isExport)return C.isExport?-1:1;let v=i.indexOf(C.kind),k=i.indexOf(b.kind),W=v>=0?v:i.length,A=k>=0?k:i.length;if(W!==A)return W-A;if(r)return C.name.localeCompare(b.name);return 0});let m=[...l],c=null;for(let C of s){if(c!==null&&C.kind!==c)m.push("");m.push(...C.lines),c=C.kind}if(a.length>0)m.push(""),m.push(...a);return m.join(`
275
+ `)}function u0(e){let t=e.startsWith("export "),i=t?e.slice(7):e;if(e.startsWith("import "))return{kind:"import",name:e.match(/from\s+['"]([^'"]+)['"]/)?.[1]||"",isExport:!1};if(i.startsWith("type ")||i.startsWith("declare type "))return{kind:"type",name:i.match(/type\s+(\w+)/)?.[1]||"",isExport:t};if(i.startsWith("interface ")||i.startsWith("declare interface "))return{kind:"interface",name:i.match(/interface\s+(\w+)/)?.[1]||"",isExport:t};if(i.startsWith("class ")||i.startsWith("abstract class ")||i.startsWith("declare class ")||i.startsWith("declare abstract class "))return{kind:"class",name:i.match(/class\s+(\w+)/)?.[1]||"",isExport:t};if(i.startsWith("enum ")||i.startsWith("const enum ")||i.startsWith("declare enum ")||i.startsWith("declare const enum "))return{kind:"enum",name:i.match(/enum\s+(\w+)/)?.[1]||"",isExport:t};if(i.startsWith("function ")||i.startsWith("async function ")||i.startsWith("declare function ")||i.startsWith("declare async function "))return{kind:"function",name:i.match(/function\s+(\w+)/)?.[1]||"",isExport:t};if(i.startsWith("const ")||i.startsWith("let ")||i.startsWith("var ")||i.startsWith("declare const ")||i.startsWith("declare let ")||i.startsWith("declare var "))return{kind:"variable",name:i.match(/(?:const|let|var)\s+(\w+)/)?.[1]||"",isExport:t};if(i.startsWith("namespace ")||i.startsWith("declare namespace "))return{kind:"namespace",name:i.match(/namespace\s+(\w+)/)?.[1]||"",isExport:t};if(i.startsWith("module ")||i.startsWith("declare module "))return{kind:"module",name:i.match(/module\s+['"]?(\w+)['"]?/)?.[1]||"",isExport:t};if(e.startsWith("export {")||e.startsWith("export *")||e.startsWith("export type {"))return{kind:"export",name:"",isExport:!0};return null}var i0,r0;var hd=me(()=>{i0=["import","type","interface","enum","class","function","variable","export","module","namespace","unknown"],r0=["builtin","external","scoped","internal","parent","sibling","index","type"]});class Ao{plugins=[];config=null;register(e){if(this.plugins.some((t)=>t.name===e.name))throw Error(`Plugin "${e.name}" is already registered`);this.plugins.push(e)}hasDeclarationHooks(){return this.plugins.some((e)=>e.onDeclarations!==void 0)}unregister(e){let t=this.plugins.findIndex((i)=>i.name===e);if(t>=0)return this.plugins.splice(t,1),!0;return!1}getPlugins(){return this.plugins}createLogger(e){return{debug:(t)=>console.debug(`[${e}] ${t}`),info:(t)=>console.info(`[${e}] ${t}`),warn:(t)=>console.warn(`[${e}] ${t}`),error:(t)=>console.error(`[${e}] ${t}`)}}async runOnStart(e){let t=e;for(let i of this.plugins)if(i.onStart){let r=await i.onStart(t);if(r)t=r}return this.config=t,t}async runOnBeforeFile(e,t){let i=t;for(let r of this.plugins)if(r.onBeforeFile){let n={filePath:e,sourceCode:t,content:i,config:this.config,log:this.createLogger(r.name)},o=await r.onBeforeFile(n);if(typeof o==="string")i=o}return i}async runOnDeclarations(e,t,i){let r=i;for(let n of this.plugins)if(n.onDeclarations){let o={filePath:e,sourceCode:t,declarations:r,config:this.config,log:this.createLogger(n.name)},s=await n.onDeclarations(o);if(s)r=s}return r}async runOnAfterFile(e,t,i){let r=i;for(let n of this.plugins)if(n.onAfterFile){let o={filePath:e,sourceCode:t,content:r,config:this.config,log:this.createLogger(n.name)},s=await n.onAfterFile(o);if(typeof s==="string")r=s}return r}async runOnEnd(e){for(let t of this.plugins)if(t.onEnd)await t.onEnd(e)}async runOnError(e,t,i){for(let r of this.plugins)if(r.onError){let n={filePath:t,sourceCode:i,config:this.config,log:this.createLogger(r.name)};await r.onError(e,n)}}}function d0(e){return e}var Ob,Rb;var pd=me(()=>{Ob=new Ao;Rb=d0({name:"strip-internal",version:"1.0.0",description:"Removes declarations marked with @internal",onDeclarations:(e)=>e.declarations.filter((t)=>{if(t.leadingComments){if(t.leadingComments.some((i)=>i.includes("@internal")))return e.log.debug(`Stripping internal declaration: ${t.name}`),!1}return!0})})});function md(e){let t=[],i=0;for(let r=0;r<=e.length;r++)if(r===e.length||e[r]===`
276
+ `){let n=i,o=r;while(n<o&&(e[n]===" "||e[n]==="\t"||e[n]==="\r"))n++;while(o>n&&(e[o-1]===" "||e[o-1]==="\t"||e[o-1]==="\r"))o--;let s=e.slice(n,o);if(i=r+1,s.startsWith("///")){if(s.indexOf("<")===-1)continue;if(h0.test(s)||p0.test(s)||m0.test(s))t.push(s)}else if(s===""||s.startsWith("//"))continue;else break}return t}var h0,p0,m0;var gd=me(()=>{h0=/^\/\/\/\s*<reference\s+(?:path|types|lib|no-default-lib)\s*=\s*["'][^"']+["']\s*\/>/,p0=/^\/\/\/\s*<amd-module\s+name\s*=\s*["'][^"']+["']\s*\/>/,m0=/^\/\/\/\s*<amd-dependency\s+path\s*=\s*["'][^"']+["']/});function yd(e,t){throw Error(t||`Unexpected value: ${e}`)}function bd(e,t,i=!0,r=["bun"]){let n="",o=t.sourceCode;if(o){let A=0;while(A<o.length&&(o.charCodeAt(A)===32||o.charCodeAt(A)===9||o.charCodeAt(A)===10||o.charCodeAt(A)===13))A++;if(A<o.length-2&&o.charCodeAt(A)===47&&o.charCodeAt(A+1)===47&&o.charCodeAt(A+2)===47){let R=md(o);if(R.length>0)for(let V=0;V<R.length;V++){if(n)n+=`
277
+ `;n+=R[V]}}}let s=[],l=[],a=[],f=[],u=[],d=[],h=[],p=[],m=[];for(let A of e){let R=A.kind;switch(R){case"import":s.push(A);break;case"function":l.push(A);break;case"variable":a.push(A);break;case"interface":f.push(A);break;case"type":u.push(A);break;case"class":d.push(A);break;case"enum":h.push(A);break;case"module":p.push(A);break;case"export":m.push(A);break;case"namespace":p.push(A);break;case"unknown":break;default:yd(R,`Unhandled declaration kind: ${R}`)}}let c=[],C=[],b=[],v=new Set;for(let A of m){let R=Lt(A.leadingComments,i);if(A.text.startsWith("export default")){let V=A.text.endsWith(";")?A.text:`${A.text};`;b.push(R+V)}else{let V=A.text.trim();if(!V.endsWith(";"))V+=";";let B=R+V;if(!v.has(B))if(v.add(B),B.includes("export type"))c.push(B);else C.push(B)}}let k=[];if(s.length>0){let{usedItems:A}=Mn(e);for(let V of s){if(V.isSideEffect){let ge=V.text.trim(),ie=ge.endsWith(";")?ge:`${ge};`;k.push(ie);continue}let B=$i(V.text);if(!B)continue;let{defaultName:O,namedItems:z,isTypeOnly:X,namespaceName:ae}=B,be=O?A.has(O):!1,ke=ae?A.has(ae):!1;if(B.isImportEquals){if(be){let ge=V.text.trim();k.push(ge.endsWith(";")?ge:`${ge};`)}else if(t.augmentationImports?.has(B.source)){let ge=kn(V.text);if(!ge)throw Error("Cannot locate an augmentation import module literal");k.push(`import ${ge};`)}continue}let ve="",we=0;for(let ge=0;ge<z.length;ge++){let ie=z[ge];if(A.has(ie.name)){if(we>0)ve+=", ";if(!X&&ie.isTypeOnly)ve+="type ";ve+=ie.originalName===ie.name?ie.name:`${ie.originalName} as ${ie.name}`,we++}}if(be||ke||we>0){let ge=X?"import type ":"import ";if(ke&&ae){if(be&&O)ge+=`${O}, `;ge+=`* as ${ae}`}else if(be&&O)ge+=we>0?`${O}, { ${ve} }`:O;else if(we>0)ge+=`{ ${ve} }`;let ie=kn(V.text);if(!ie)throw Error("Cannot locate a grammatical module literal in the import declaration");ge+=` from ${ie};`,k.push(ge)}else if(t.augmentationImports?.has(B.source)){let ge=kn(V.text);if(!ge)throw Error("Cannot locate an augmentation import module literal");k.push(`import ${ge};`)}}let R=r.length;if(k.length>1){if(wd!==r)wd=r,Cd=r.map((z)=>`from '${z}`),vd=r.map((z)=>`from "${z}`);let V=Cd,B=vd,O=new Map;for(let z of k){let X=R;for(let ae=0;ae<r.length;ae++)if(z.includes(V[ae])||z.includes(B[ae])){X=ae;break}O.set(z,X)}k.sort((z,X)=>{let ae=O.get(z),be=O.get(X);return ae!==be?ae-be:z.localeCompare(X)})}}for(let A=0;A<k.length;A++){if(n)n+=`
278
278
  `;n+=k[A]}for(let A=0;A<c.length;A++){if(n)n+=`
279
- `;n+=c[A]}let W=[l,a,f,u,d,h,p];for(let A=0;A<W.length;A++){let R=W[A];for(let V=0;V<R.length;V++){let B=R[V],O="",z=B.kind;switch(z){case"function":O=hc(B,i);break;case"variable":O=Di(B,i);break;case"interface":O=pc(B,i);break;case"type":O=mc(B,i);break;case"class":O=gc(B,i);break;case"enum":O=yc(B,i);break;case"module":case"namespace":O=wc(B,i);break;case"import":case"export":case"unknown":break;default:yd(z,`Unhandled declaration kind in processor: ${z}`)}if(O){if(n)n+=`
280
- `;n+=O}}}for(let A=0;A<v.length;A++){if(n)n+=`
281
- `;n+=v[A]}for(let A=0;A<b.length;A++){if(n)n+=`
282
- `;n+=b[A]}if(m.length===0&&Ri(t.sourceCode)&&(e.some(Dl)||!Rl(n)))n+=`${n?`
283
- `:""}export {};`;return n}var wd=null,Cd,vd;var $d=me(()=>{hr();gd();pn();xn();$i();ks();Cd=[],vd=[]});function y0(e){switch(e){case"strict":return p0;case"readonly":return m0;case"simplified":return g0;case"nullable":return[{pattern:/^(.+)\s*\|\s*undefined$/,replacement:"$1 | undefined",priority:5}];case"branded":return[{pattern:/^string$/,replacement:"string",condition:(t)=>t.declarationKind==="variable"&&(t.declarationName?.includes("path")??!1),priority:5}];default:return[]}}class xd{rules;compiled=[];cache=new Map;constructor(e={rules:[]}){if(this.rules=[],e.includeDefaults!==!1)this.rules.push(...h0);if(e.presets)for(let t of e.presets)this.rules.push(...y0(t));this.rules.push(...e.rules),this.rules.sort((t,i)=>(i.priority||0)-(t.priority||0)),this.recompile()}recompile(){let e=Array(this.rules.length);for(let t=0;t<this.rules.length;t++){let i=this.rules[t],r=typeof i.pattern==="string"?new RegExp(i.pattern.replace(w0,"\\$&"),i.global?"g":""):i.pattern;e[t]={rule:i,regex:r}}this.compiled=e}map(e,t={}){let i=!t.declarationName&&!t.declarationKind&&!t.filePath&&!t.isReturnType&&!t.isParameterType&&!t.isPropertyType?e:`${e}\x00${t.declarationName??""}\x00${t.declarationKind??""}\x00${t.filePath??""}\x00${t.isReturnType?"r":""}${t.isParameterType?"p":""}${t.isPropertyType?"P":""}`,r=this.cache.get(i);if(r!==void 0)return r;let n=e,o=null;for(let s=0;s<this.compiled.length;s++){let{rule:l,regex:a}=this.compiled[s];if(l.condition){if(!o)o={type:e,...t};if(!l.condition(o))continue}if(a.lastIndex=0,a.test(n)){if(a.lastIndex=0,n=n.replace(a,l.replacement),a.lastIndex=0,!l.global)break}}if(this.cache.size>=Ed){let s=Math.ceil(Ed*0.1),l=0;for(let a of this.cache.keys()){if(l++>=s)break;this.cache.delete(a)}}return this.cache.set(i,n),n}mapAll(e,t={}){return e.map((i)=>this.map(i,{...t,type:i}))}addRule(e){this.rules.push(e),this.rules.sort((t,i)=>(i.priority||0)-(t.priority||0)),this.recompile(),this.cache.clear()}removeRules(e){let t=this.rules.length;return this.rules=this.rules.filter((i)=>{let r=typeof i.pattern==="string"?i.pattern:i.pattern.source;if(e instanceof RegExp)e.lastIndex=0;return typeof e==="string"?r!==e:!e.test(r)}),this.recompile(),this.cache.clear(),t-this.rules.length}clearCache(){this.cache.clear()}getRules(){return this.rules}}function So(e={rules:[]}){return new xd(e)}function Sd(e,t,i={}){return e.replace(/:\s*([^;,)\]}]+)/g,(r,n)=>`: ${t.map(n.trim(),i)}`)}var h0,p0,m0,g0,w0,Ed=2048,Fb,Wb;var Ad=me(()=>{h0=[{pattern:/^Promise<void>$/,replacement:"Promise<void>",priority:-1},{pattern:/^Record<string,\s*any>$/,replacement:"Record<string, unknown>",priority:0},{pattern:/^Array<([^<>]+)>$/,replacement:"$1[]",priority:0}],p0=[{pattern:/\bany\b/,replacement:"unknown",global:!0,priority:10},{pattern:/^object$/,replacement:"Record<string, unknown>",priority:10},{pattern:/^Function$/,replacement:"(...args: unknown[]) => unknown",priority:10}],m0=[{pattern:/^(\w+)\[\]$/,replacement:"readonly $1[]",priority:5},{pattern:/^Array<(.+)>$/,replacement:"ReadonlyArray<$1>",priority:5},{pattern:/^Map<(.+),\s*(.+)>$/,replacement:"ReadonlyMap<$1, $2>",priority:5},{pattern:/^Set<(.+)>$/,replacement:"ReadonlySet<$1>",priority:5}],g0=[{pattern:/^Partial<Partial<(.+)>>$/,replacement:"Partial<$1>",priority:5},{pattern:/^Required<Required<(.+)>>$/,replacement:"Required<$1>",priority:5},{pattern:/^Pick<Omit<(.+),\s*(.+)>,\s*(.+)>$/,replacement:"Pick<$1, $3>",priority:5}];w0=/[.*+?^${}()|[\]\\]/g;Fb=So({rules:[]}),Wb=So({rules:[],presets:["strict"]})});import{availableParallelism as C0}from"os";import{basename as Od,dirname as v0,relative as Vt,resolve as b0}from"path";function _a(e){let t=Ba.get(e);if(!t)t=In(e),Ba.set(e,t),t.catch(()=>Ba.delete(e));return t}async function kd(e,t,i,r,n,o=vo){let s=Od(e)||"output.d.ts",l=Vt(v0(e),t),a=`${s}.map`,f=i.lastIndexOf(`
284
- ${Ta()}`),u=f===-1?i:i.slice(0,f),d=Gu(u,s,l,r),h=`${e}.map`;return await o(h,JSON.stringify(d)),le.debug(` Generated source map: ${Vt(n,h)}`),a}async function ja(e){let t=Date.now(),i={...xu,...e};if(i.logLevel)Ts(i.logLevel);else if(i.verbose)Ts("debug");let r=new xo;if(i.plugins&&i.plugins.length>0){for(let A of i.plugins)r.register(A),le.debug(`Registered plugin: ${A.name}`);i=await r.runOnStart(i)}if(i.moduleSpecifierMode!==void 0&&i.moduleSpecifierMode!=="preserve"&&i.moduleSpecifierMode!=="node")throw Error("moduleSpecifierMode must be preserve or node");if(await Na(i),i.isolatedDeclarations===void 0)i.isolatedDeclarations=await Bu(i);let n=i.typeMappings?So(i.typeMappings):void 0,o=null,s={generationMode:i.isolatedDeclarations?"isolated":"semantic",filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},l=0;le.debug("Starting DTS generation..."),le.debug(`Using ${s.generationMode} declaration generation path`),le.debug("Config:",i);let a=await Ou(i,()=>_a(i)),f=a.entryFiles,u=[...a.files],{resolver:d,reachability:h}=a;if(Rd.set(i,new Set(u)),i.incremental){let A=a.getResolutionFingerprint();if(!i.isolatedDeclarations){let R=new Set(u),V=new Map;for(let O of u){let z=await vt(O);V.set(O,Eo(z));for(let X of Ei(z,{includeImports:!0})){let ae=d(X.specifier,O).resolved;if(ae&&!ae.split(/[/\\]/).includes("node_modules")&&!R.has(ae))R.add(ae),V.set(ae,Eo(await vt(ae)))}}let B=[...V].sort(([O],[z])=>O.localeCompare(z));A=JSON.stringify([A,B])}if(o=new Vo(i,A),i.clearCache){if(le.debug("Clearing build cache..."),!i.dryRun)o.clear()}else if(o.load()){let R=o.getStats();le.debug(`Loaded build cache with ${R.entries} entries`)}else le.debug("No existing build cache found, starting fresh");if(!i.dryRun)ll(i.cwd)}if(o&&!i.dryRun){let A=o.prune(new Set(u),i.cwd);if(A>0)le.debug(`Pruned ${A} deleted files from cache`)}if(le.debug(`Found ${u.length} TypeScript files`),i.progress&&u.length>0){let A=i.parallel?"parallel":"sequential";le.info(`Processing ${u.length} files (${A})...`)}let p=new Map,m=new Map,c=async(A,R,V="lf")=>{m.set(A,{content:R,lineEnding:V})},v=async(A,R)=>{let V;try{let B=Qi(A,i),O=async(ie)=>{if(!i.diff)return;try{let I=await vt(B),K=ju(I,ie,Vt(i.cwd,B));if(K)le.info(`
279
+ `;n+=c[A]}let W=[l,a,f,u,d,h,p];for(let A=0;A<W.length;A++){let R=W[A];for(let V=0;V<R.length;V++){let B=R[V],O="",z=B.kind;switch(z){case"function":O=hc(B,i);break;case"variable":O=Ii(B,i);break;case"interface":O=pc(B,i);break;case"type":O=mc(B,i);break;case"class":O=gc(B,i);break;case"enum":O=yc(B,i);break;case"module":case"namespace":O=wc(B,i);break;case"import":case"export":case"unknown":break;default:yd(z,`Unhandled declaration kind in processor: ${z}`)}if(O){if(n)n+=`
280
+ `;n+=O}}}for(let A=0;A<C.length;A++){if(n)n+=`
281
+ `;n+=C[A]}for(let A=0;A<b.length;A++){if(n)n+=`
282
+ `;n+=b[A]}if(m.length===0&&Pi(t.sourceCode)&&(e.some(Dl)||!Rl(n)))n+=`${n?`
283
+ `:""}export {};`;return n}var wd=null,Cd,vd;var $d=me(()=>{pr();gd();gn();An();Ei();Ts();Cd=[],vd=[]});function v0(e){switch(e){case"strict":return y0;case"readonly":return w0;case"simplified":return C0;case"nullable":return[{pattern:/^(.+)\s*\|\s*undefined$/,replacement:"$1 | undefined",priority:5}];case"branded":return[{pattern:/^string$/,replacement:"string",condition:(t)=>t.declarationKind==="variable"&&(t.declarationName?.includes("path")??!1),priority:5}];default:return[]}}class xd{rules;compiled=[];cache=new Map;constructor(e={rules:[]}){if(this.rules=[],e.includeDefaults!==!1)this.rules.push(...g0);if(e.presets)for(let t of e.presets)this.rules.push(...v0(t));this.rules.push(...e.rules),this.rules.sort((t,i)=>(i.priority||0)-(t.priority||0)),this.recompile()}recompile(){let e=Array(this.rules.length);for(let t=0;t<this.rules.length;t++){let i=this.rules[t],r=typeof i.pattern==="string"?new RegExp(i.pattern.replace(b0,"\\$&"),i.global?"g":""):i.pattern;e[t]={rule:i,regex:r}}this.compiled=e}map(e,t={}){let i=!t.declarationName&&!t.declarationKind&&!t.filePath&&!t.isReturnType&&!t.isParameterType&&!t.isPropertyType?e:`${e}\x00${t.declarationName??""}\x00${t.declarationKind??""}\x00${t.filePath??""}\x00${t.isReturnType?"r":""}${t.isParameterType?"p":""}${t.isPropertyType?"P":""}`,r=this.cache.get(i);if(r!==void 0)return r;let n=e,o=null;for(let s=0;s<this.compiled.length;s++){let{rule:l,regex:a}=this.compiled[s];if(l.condition){if(!o)o={type:e,...t};if(!l.condition(o))continue}if(a.lastIndex=0,a.test(n)){if(a.lastIndex=0,n=n.replace(a,l.replacement),a.lastIndex=0,!l.global)break}}if(this.cache.size>=Ed){let s=Math.ceil(Ed*0.1),l=0;for(let a of this.cache.keys()){if(l++>=s)break;this.cache.delete(a)}}return this.cache.set(i,n),n}mapAll(e,t={}){return e.map((i)=>this.map(i,{...t,type:i}))}addRule(e){this.rules.push(e),this.rules.sort((t,i)=>(i.priority||0)-(t.priority||0)),this.recompile(),this.cache.clear()}removeRules(e){let t=this.rules.length;return this.rules=this.rules.filter((i)=>{let r=typeof i.pattern==="string"?i.pattern:i.pattern.source;if(e instanceof RegExp)e.lastIndex=0;return typeof e==="string"?r!==e:!e.test(r)}),this.recompile(),this.cache.clear(),t-this.rules.length}clearCache(){this.cache.clear()}getRules(){return this.rules}}function ko(e={rules:[]}){return new xd(e)}function Sd(e,t,i={}){return e.replace(/:\s*([^;,)\]}]+)/g,(r,n)=>`: ${t.map(n.trim(),i)}`)}var g0,y0,w0,C0,b0,Ed=2048,_b,jb;var Ad=me(()=>{g0=[{pattern:/^Promise<void>$/,replacement:"Promise<void>",priority:-1},{pattern:/^Record<string,\s*any>$/,replacement:"Record<string, unknown>",priority:0},{pattern:/^Array<([^<>]+)>$/,replacement:"$1[]",priority:0}],y0=[{pattern:/\bany\b/,replacement:"unknown",global:!0,priority:10},{pattern:/^object$/,replacement:"Record<string, unknown>",priority:10},{pattern:/^Function$/,replacement:"(...args: unknown[]) => unknown",priority:10}],w0=[{pattern:/^(\w+)\[\]$/,replacement:"readonly $1[]",priority:5},{pattern:/^Array<(.+)>$/,replacement:"ReadonlyArray<$1>",priority:5},{pattern:/^Map<(.+),\s*(.+)>$/,replacement:"ReadonlyMap<$1, $2>",priority:5},{pattern:/^Set<(.+)>$/,replacement:"ReadonlySet<$1>",priority:5}],C0=[{pattern:/^Partial<Partial<(.+)>>$/,replacement:"Partial<$1>",priority:5},{pattern:/^Required<Required<(.+)>>$/,replacement:"Required<$1>",priority:5},{pattern:/^Pick<Omit<(.+),\s*(.+)>,\s*(.+)>$/,replacement:"Pick<$1, $3>",priority:5}];b0=/[.*+?^${}()|[\]\\]/g;_b=ko({rules:[]}),jb=ko({rules:[],presets:["strict"]})});import{availableParallelism as $0}from"os";import{basename as Od,dirname as E0,relative as Vt,resolve as x0}from"path";function ja(e){let t=_a.get(e);if(!t)t=Fn(e),_a.set(e,t),t.catch(()=>_a.delete(e));return t}async function kd(e,t,i,r,n,o=$o){let s=Od(e)||"output.d.ts",l=Vt(E0(e),t),a=`${s}.map`,f=i.lastIndexOf(`
284
+ ${Oa()}`),u=f===-1?i:i.slice(0,f),d=Gu(u,s,l,r),h=`${e}.map`;return await o(h,JSON.stringify(d)),le.debug(` Generated source map: ${Vt(n,h)}`),a}async function Ga(e){let t=Date.now(),i={...xu,...e};if(i.logLevel)Os(i.logLevel);else if(i.verbose)Os("debug");let r=new Ao;if(i.plugins&&i.plugins.length>0){for(let A of i.plugins)r.register(A),le.debug(`Registered plugin: ${A.name}`);i=await r.runOnStart(i)}if(i.moduleSpecifierMode!==void 0&&i.moduleSpecifierMode!=="preserve"&&i.moduleSpecifierMode!=="node")throw Error("moduleSpecifierMode must be preserve or node");if(await Fa(i),i.isolatedDeclarations===void 0)i.isolatedDeclarations=await Bu(i);let n=i.typeMappings?ko(i.typeMappings):void 0,o=null,s={generationMode:i.isolatedDeclarations?"isolated":"semantic",filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},l=0;le.debug("Starting DTS generation..."),le.debug(`Using ${s.generationMode} declaration generation path`),le.debug("Config:",i);let a=await Ou(i,()=>ja(i)),f=a.entryFiles,u=[...a.files],{resolver:d,reachability:h}=a;if(Rd.set(i,new Set(u)),i.incremental){let A=a.getResolutionFingerprint();if(!i.isolatedDeclarations){let R=new Set(u),V=new Map;for(let O of u){let z=await vt(O);V.set(O,So(z));for(let X of xi(z,{includeImports:!0})){let ae=d(X.specifier,O).resolved;if(ae&&!ae.split(/[/\\]/).includes("node_modules")&&!R.has(ae))R.add(ae),V.set(ae,So(await vt(ae)))}}let B=[...V].sort(([O],[z])=>O.localeCompare(z));A=JSON.stringify([A,B])}if(o=new zo(i,A),i.clearCache){if(le.debug("Clearing build cache..."),!i.dryRun)o.clear()}else if(o.load()){let R=o.getStats();le.debug(`Loaded build cache with ${R.entries} entries`)}else le.debug("No existing build cache found, starting fresh");if(!i.dryRun)cl(i.cwd)}if(o&&!i.dryRun){let A=o.prune(new Set(u),i.cwd);if(A>0)le.debug(`Pruned ${A} deleted files from cache`)}if(le.debug(`Found ${u.length} TypeScript files`),i.progress&&u.length>0){let A=i.parallel?"parallel":"sequential";le.info(`Processing ${u.length} files (${A})...`)}let p=new Map,m=new Map,c=async(A,R,V="lf")=>{m.set(A,{content:R,lineEnding:V})},C=async(A,R)=>{let V;try{let B=er(A,i),O=async(ie)=>{if(!i.diff)return;try{let I=await vt(B),K=ju(I,ie,Vt(i.cwd,B));if(K)le.info(`
285
285
  ${K}`);else le.debug(`[no changes] ${B}`)}catch{le.info(`[new file] ${Vt(i.cwd,B)}`)}},z=(ie)=>{if(!i.validate)return 0;let I=_u(ie,B);if(I.isValid)return le.debug(`[validation] ${B} - OK`),0;le.warn(`[validation] ${Vt(i.cwd,B)} has ${I.errors.length} error(s):`);for(let K of I.errors){let Q=` Line ${K.line}:${K.column}`;if(K.code)Q+=` [${K.code}]`;if(Q+=` - ${K.message}`,le.warn(Q),K.suggestion)le.warn(` Suggestion: ${K.suggestion}`)}return I.errors.length},X=(ie)=>{le.info(`[dry-run] Would generate: ${B}`),le.debug("--- Content preview ---"),le.debug(ie.slice(0,500)+(ie.length>500?`
286
- ...`:"")),le.debug("--- End preview ---")};if(o){let ie=o.getCachedIfValid(A,i.cwd);if(ie){if(i.bundle)p.set(A,ie);await O(ie);let I=z(ie);if(i.dryRun)X(ie);else{if(i.declarationMap)V=R??await vt(A),await kd(B,A,ie,V,i.cwd,c);await c(B,ie,i.lineEnding)}return le.debug(`[cached] ${Vt(i.cwd,B)}`),{success:!0,file:A,declarationCount:0,importCount:0,exportCount:0,cached:!0,validationErrorCount:I}}}V=R??await vt(A);let{content:ae,declarationCount:be,importCount:ke,exportCount:ve}=await E0(A,V,i,r,n,a.augmentationImports.get(A));if(i.bundle)p.set(A,ae);let we=ae;if(i.prettier||i.indentStyle||i.indentSize){let ie=await td(we,{usePrettier:i.prettier,builtIn:{indentSize:i.indentSize||2,useTabs:i.indentStyle==="tabs",normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}},B);we=ie.content;for(let I of ie.warnings??[])le.warn(`[format] ${I}`)}if(i.declarationMap){let ie=`${Od(B)||"output.d.ts"}.map`;we=Vu(we,ie)}await O(we);let ge=z(we);if(i.dryRun)X(we);else{if(i.declarationMap&&V)await kd(B,A,we,V,i.cwd,c);if(await c(B,we,i.lineEnding),o&&V)o.update(A,V,we,i.cwd);le.debug(`Generated: ${B}`)}return{success:!0,file:A,declarationCount:be,importCount:ke,exportCount:ve,validationErrorCount:ge}}catch(B){let O=Zu(B,A,V);if(i.plugins&&i.plugins.length>0)await r.runOnError(B instanceof Error?B:Error(String(B)),A,V||"");return{success:!1,file:A,declarationCount:0,importCount:0,exportCount:0,dtsError:O,validationErrorCount:0}}},b=i.parallel||i.parallel!==!1&&u.length>=10,C=ul(i.concurrency,C0?.()??8),k=new Map;if(b&&u.length>1){let A=u.map(async(R)=>{try{let V=await vt(R);return{file:R,source:V}}catch{return{file:R,source:null}}});for(let R of await Promise.all(A))if(R.source!==null)k.set(R.file,R.source)}let W=(A)=>{if(s.filesProcessed++,A.success){if(A.cached)l++;else s.filesGenerated++,s.declarationsFound+=A.declarationCount,s.importsProcessed+=A.importCount,s.exportsProcessed+=A.exportCount;if(i.validate){if(s.filesValidated++,A.validationErrorCount)s.validationErrors+=A.validationErrorCount}}else if(s.filesFailed++,A.dtsError){s.errors.push(A.dtsError);let R=Qu(A.dtsError);if(i.continueOnError)le.warn(R);else throw le.error(R),Error(A.dtsError.message)}};if(b)for(let A=0;A<u.length;A+=C){let R=u.slice(A,A+C),V=await Promise.all(R.map((B)=>v(B,k.get(B))));for(let B of V)W(B);if(i.progress){let B=Math.round(s.filesProcessed/u.length*100);le.info(`[${s.filesProcessed}/${u.length}] ${B}%`)}}else for(let A of u){let R=await v(A);if(W(R),i.progress){let V=Math.round(s.filesProcessed/u.length*100),B=R.cached?"[cached]":"";le.info(`[${s.filesProcessed}/${u.length}] ${V}% - ${Vt(i.cwd,A)} ${B}`)}}if(!i.bundle){let A=[];if(h)for(let R of h.unresolved)A.push({from:R.from,specifier:R.specifier,reason:"missing"});if(i.autoIncludeReExports===!1&&u.length>0){let R=new Set(u);for(let V of u){let B;try{B=await vt(V)}catch{continue}for(let O of Ei(B)){let z=d(O.specifier,V);if(!z.isRelative)continue;if(!z.resolved)A.push({from:V,specifier:O.specifier,reason:"missing"});else if(!/\.d\.(?:ts|mts|cts)$/.test(z.resolved)&&!R.has(z.resolved))A.push({from:V,specifier:O.specifier,reason:"not-emitted"})}}}if(A.length>0){let R=[];R.push(`Found ${A.length} re-export(s) pointing at siblings that won't be in the output:`);for(let B of A){let O=Vt(i.cwd,B.from);if(B.reason==="missing")R.push(` ${O} \u2192 '${B.specifier}' (path not found on disk)`);else R.push(` ${O} \u2192 '${B.specifier}' (resolved but not in entrypoints; set autoIncludeReExports: true or add to entrypoints)`)}let V=R.join(`
287
- `);if(i.failOnUnresolvedReExport)throw Error(V);le.warn(V),le.warn('Generated .d.ts files reference modules that were not emitted \u2014 consumers will see "has no exported member" errors.')}}if(i.bundle&&(s.filesGenerated>0||l>0)&&f.length>0)try{le.debug("Bundling declarations...");let A=f.length===1&&!!i.bundleOutput;for(let R of f){let V=await Ar([R],{includeImports:!0,resolveSpecifier:d}),B=new Set;for(let ae of V.reachable){if(ae.endsWith(".d.ts"))continue;if(ae.includes("node_modules"))continue;B.add(ae)}let O=u.filter((ae)=>B.has(ae));if(!O.includes(R))O.push(R);let z=Hc(R,O,p,{cwd:i.cwd,keepComments:i.keepComments});for(let ae of new Set(z.warnings))le.warn(`[bundle] ${ae}`);let X=A?b0(i.cwd,i.outdir,i.bundleOutput):Qi(R,i);if(i.dryRun)le.info(`[dry-run] Would bundle ${z.files.length} files to: ${Vt(i.cwd,X)}`);else await c(X,z.content,i.lineEnding),le.debug(`Prepared ${z.files.length} bundled files for: ${Vt(i.cwd,X)}`);if(A)break}}catch(A){let R=A instanceof Error?A.message:String(A);throw le.error(`Bundle failed: ${R}`),A}if(!i.dryRun)await Yu(i,m);if(o&&!i.dryRun)o.save(),le.debug("Saved build cache");if(s.durationMs=Date.now()-t,i.stats)if(i.outputFormat==="json")console.log(JSON.stringify(s,null,2));else{if(le.info(`
286
+ ...`:"")),le.debug("--- End preview ---")};if(o){let ie=o.getCachedIfValid(A,i.cwd);if(ie){if(i.bundle)p.set(A,ie);await O(ie);let I=z(ie);if(i.dryRun)X(ie);else{if(i.declarationMap)V=R??await vt(A),await kd(B,A,ie,V,i.cwd,c);await c(B,ie,i.lineEnding)}return le.debug(`[cached] ${Vt(i.cwd,B)}`),{success:!0,file:A,declarationCount:0,importCount:0,exportCount:0,cached:!0,validationErrorCount:I}}}V=R??await vt(A);let{content:ae,declarationCount:be,importCount:ke,exportCount:ve}=await A0(A,V,i,r,n,a.augmentationImports.get(A));if(i.bundle)p.set(A,ae);let we=ae;if(i.prettier||i.indentStyle||i.indentSize){let ie=await td(we,{usePrettier:i.prettier,builtIn:{indentSize:i.indentSize||2,useTabs:i.indentStyle==="tabs",normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}},B);we=ie.content;for(let I of ie.warnings??[])le.warn(`[format] ${I}`)}if(i.declarationMap){let ie=`${Od(B)||"output.d.ts"}.map`;we=Vu(we,ie)}await O(we);let ge=z(we);if(i.dryRun)X(we);else{if(i.declarationMap&&V)await kd(B,A,we,V,i.cwd,c);if(await c(B,we,i.lineEnding),o&&V)o.update(A,V,we,i.cwd);le.debug(`Generated: ${B}`)}return{success:!0,file:A,declarationCount:be,importCount:ke,exportCount:ve,validationErrorCount:ge}}catch(B){let O=Zu(B,A,V);if(i.plugins&&i.plugins.length>0)await r.runOnError(B instanceof Error?B:Error(String(B)),A,V||"");return{success:!1,file:A,declarationCount:0,importCount:0,exportCount:0,dtsError:O,validationErrorCount:0}}},b=i.parallel||i.parallel!==!1&&u.length>=10,v=dl(i.concurrency,$0?.()??8),k=new Map;if(b&&u.length>1){let A=u.map(async(R)=>{try{let V=await vt(R);return{file:R,source:V}}catch{return{file:R,source:null}}});for(let R of await Promise.all(A))if(R.source!==null)k.set(R.file,R.source)}let W=(A)=>{if(s.filesProcessed++,A.success){if(A.cached)l++;else s.filesGenerated++,s.declarationsFound+=A.declarationCount,s.importsProcessed+=A.importCount,s.exportsProcessed+=A.exportCount;if(i.validate){if(s.filesValidated++,A.validationErrorCount)s.validationErrors+=A.validationErrorCount}}else if(s.filesFailed++,A.dtsError){s.errors.push(A.dtsError);let R=Qu(A.dtsError);if(i.continueOnError)le.warn(R);else throw le.error(R),Error(A.dtsError.message)}};if(b)for(let A=0;A<u.length;A+=v){let R=u.slice(A,A+v),V=await Promise.all(R.map((B)=>C(B,k.get(B))));for(let B of V)W(B);if(i.progress){let B=Math.round(s.filesProcessed/u.length*100);le.info(`[${s.filesProcessed}/${u.length}] ${B}%`)}}else for(let A of u){let R=await C(A);if(W(R),i.progress){let V=Math.round(s.filesProcessed/u.length*100),B=R.cached?"[cached]":"";le.info(`[${s.filesProcessed}/${u.length}] ${V}% - ${Vt(i.cwd,A)} ${B}`)}}if(!i.bundle){let A=[];if(h)for(let R of h.unresolved)A.push({from:R.from,specifier:R.specifier,reason:"missing"});if(i.autoIncludeReExports===!1&&u.length>0){let R=new Set(u);for(let V of u){let B;try{B=await vt(V)}catch{continue}for(let O of xi(B)){let z=d(O.specifier,V);if(!z.isRelative)continue;if(!z.resolved)A.push({from:V,specifier:O.specifier,reason:"missing"});else if(!/\.d\.(?:ts|mts|cts)$/.test(z.resolved)&&!R.has(z.resolved))A.push({from:V,specifier:O.specifier,reason:"not-emitted"})}}}if(A.length>0){let R=[];R.push(`Found ${A.length} re-export(s) pointing at siblings that won't be in the output:`);for(let B of A){let O=Vt(i.cwd,B.from);if(B.reason==="missing")R.push(` ${O} \u2192 '${B.specifier}' (path not found on disk)`);else R.push(` ${O} \u2192 '${B.specifier}' (resolved but not in entrypoints; set autoIncludeReExports: true or add to entrypoints)`)}let V=R.join(`
287
+ `);if(i.failOnUnresolvedReExport)throw Error(V);le.warn(V),le.warn('Generated .d.ts files reference modules that were not emitted \u2014 consumers will see "has no exported member" errors.')}}if(i.bundle&&(s.filesGenerated>0||l>0)&&f.length>0)try{le.debug("Bundling declarations...");let A=f.length===1&&!!i.bundleOutput;for(let R of f){let V=await Ar([R],{includeImports:!0,resolveSpecifier:d}),B=new Set;for(let ae of V.reachable){if(ae.endsWith(".d.ts"))continue;if(ae.includes("node_modules"))continue;B.add(ae)}let O=u.filter((ae)=>B.has(ae));if(!O.includes(R))O.push(R);let z=Hc(R,O,p,{cwd:i.cwd,keepComments:i.keepComments});for(let ae of new Set(z.warnings))le.warn(`[bundle] ${ae}`);let X=A?x0(i.cwd,i.outdir,i.bundleOutput):er(R,i);if(i.dryRun)le.info(`[dry-run] Would bundle ${z.files.length} files to: ${Vt(i.cwd,X)}`);else await c(X,z.content,i.lineEnding),le.debug(`Prepared ${z.files.length} bundled files for: ${Vt(i.cwd,X)}`);if(A)break}}catch(A){let R=A instanceof Error?A.message:String(A);throw le.error(`Bundle failed: ${R}`),A}if(!i.dryRun)await Yu(i,m);if(o&&!i.dryRun)o.save(),le.debug("Saved build cache");if(s.durationMs=Date.now()-t,i.stats)if(i.outputFormat==="json")console.log(JSON.stringify(s,null,2));else{if(le.info(`
288
288
  --- Generation Statistics ---`),le.info(`Files processed: ${s.filesProcessed}`),le.info(`Files generated: ${s.filesGenerated}`),l>0)le.info(`Files cached: ${l}`);if(s.filesFailed>0)le.info(`Files failed: ${s.filesFailed}`);if(le.info(`Declarations found: ${s.declarationsFound}`),le.info(`Imports processed: ${s.importsProcessed}`),le.info(`Exports processed: ${s.exportsProcessed}`),s.filesValidated>0){if(le.info(`Files validated: ${s.filesValidated}`),s.validationErrors>0)le.info(`Validation errors: ${s.validationErrors}`)}if(le.info(`Duration: ${s.durationMs}ms`),s.errors.length>0){le.info(`
289
289
  Errors:`);for(let A of s.errors){let R=` - ${A.file}`;if(A.location)R+=`:${A.location.line}:${A.location.column}`;if(A.code)R+=` [${A.code}]`;if(R+=`: ${A.message}`,le.info(R),A.suggestion)le.info(` Suggestion: ${A.suggestion}`)}}le.info(`-----------------------------
290
- `)}if(i.plugins&&i.plugins.length>0)await r.runOnEnd(s);return le.debug("DTS generation complete!"),s}async function $0(e,t,i){let r=await _a(i),n=Ru(t,i,r,Rd.get(i));return zc(e,(o)=>n(o).emittedSpecifier)}async function E0(e,t,i,r,n,o){let s=t;if(r)s=await r.runOnBeforeFile(e,t);let l=new Map;if(!i.isolatedDeclarations){let m=await _a(i);for(let c of Ei(s,{includeImports:!0})){let v=m(c.specifier,e).resolved;if(v&&!v.split(/[/\\]/).includes("node_modules"))l.set(c.specifier,await vt(v))}}let a=r?.hasDeclarationHooks()?null:S0(s,e,i,l,o);if(a!==null)return Td(a,e,s,i,r,n,x0(a));let f=l.size?rd(s,l):void 0,u=On(s,e,i.keepComments,i.isolatedDeclarations??!1,f);if(r)u=await r.runOnDeclarations(e,s,u);let d=0,h=0;for(let m=0;m<u.length;m++){let c=u[m];if(c.kind==="import")d++;if(c.kind==="export"||c.isExported)h++}let p=bd(u,{filePath:e,sourceCode:s,declarations:u,augmentationImports:o},i.keepComments,i.importOrder);return Td(p,e,s,i,r,n,{declarationCount:u.length,importCount:d,exportCount:h})}function x0(e){let t=0,i=0,r=0;for(let n of e.split(`
291
- `)){if(!n||n.startsWith(" ")||n.startsWith("\t")||n.startsWith("}")||n.startsWith("*")||n.startsWith("/"))continue;if(t++,n.startsWith("import "))i++;else if(n.startsWith("export "))r++}return{declarationCount:t,importCount:i,exportCount:r}}function S0(e,t,i,r,n){let o=i.importOrder??["bun"];if(o.length!==1||o[0]!=="bun")return null;let s=Qr(t)?rn(e):on(t)?sn(e):e;return ld(s,{keepComments:i.keepComments??!0,isolatedDeclarations:i.isolatedDeclarations??!1,sourceFile:t,inferenceSources:r,augmentationImports:n})}async function Td(e,t,i,r,n,o,s){let l=await $0(e,t,r);if(o)l=Sd(l,o,{filePath:t});if(r.normalizeOutput===!0||r.declarationOrder)l=dd(l,{lineEnding:"lf",declarationOrder:r.declarationOrder,indent:{style:r.indentStyle??"spaces",size:r.indentSize??2}});if(n)l=await n.runOnAfterFile(t,i,l);return{content:l,...s}}var Ba,Rd;var Pd=me(()=>{sr();dl();nn();Qo();As();Mn();Nn();qc();cl();Su();ka();Oa();Xu();ed();id();nd();cd();hd();pd();$d();Ad();Ba=new WeakMap,Rd=new WeakMap});var Md=me(()=>{Pd()});import Nd from"process";import{dirname as A0,relative as Dd,resolve as Ao,sep as ko}from"path";class Fd{listeners=new Map;on(e,t){let i=this.listeners.get(e)||[];i.push(t),this.listeners.set(e,i)}async emit(e,t){let i={type:e,timestamp:Date.now(),data:t},r=this.listeners.get(e)||[];for(let n of r)await n(i)}}function Wd(e={}){let{onSuccess:t,onError:i,failOnError:r=!0,incremental:n=!1,cacheDir:o=".dtsx-cache",on:s,timeout:l=60000,continueOnError:a=!1,verbose:f=!1,...u}=e,d=new Fd;if(s){for(let[h,p]of Object.entries(s))if(p)d.on(h,p)}return{name:"bun-plugin-dtsx",async setup(h){let p=Date.now();try{let m=O0({...u,incremental:n,cacheDir:o},h);if(m.clean){let k=Ao(m.cwd??Nd.cwd(),m.outdir??"./dist");if(Id.has(k))m.clean=!1;else Id.add(k)}if(await d.emit("start",{type:"start",files:m.entrypoints||[],config:m}),f){if(console.log("[bun-plugin-dtsx] Starting declaration generation..."),n)console.log("[bun-plugin-dtsx] Incremental mode enabled")}let v=await(async()=>new Promise((k,W)=>{let A=setTimeout(()=>{W(new _r(`Generation timed out after ${l}ms`,"TIMEOUT_ERROR",{timeout:l}))},l);ja(m).then((R)=>{clearTimeout(A),k(R)}).catch((R)=>{clearTimeout(A),W(R)})}))(),b=Date.now()-p,C=Math.max(0,v.filesProcessed-v.filesGenerated-v.filesFailed);if(await d.emit("complete",{type:"complete",stats:v,duration:b,fromCache:C}),f){if(console.log(`[bun-plugin-dtsx] Generation complete in ${b}ms`),C>0)console.log(`[bun-plugin-dtsx] ${C} files served from cache`)}if(t)await t(v)}catch(m){let c=k0(m);if(await d.emit("error",{type:"error",error:c}),i)await i(c);else{if(console.error("[bun-plugin-dtsx] Error generating declarations:"),console.error(` Code: ${c.code}`),console.error(` Message: ${c.message}`),c.context)console.error(` Context: ${JSON.stringify(c.context)}`);if(f&&c.stack)console.error(` Stack: ${c.stack}`)}if(r&&!a)throw c}}}}function k0(e){if(e instanceof _r)return e;if(e instanceof Error){let t="GENERATION_ERROR";if(e.message.includes("config")||e.message.includes("Config"))t="CONFIG_ERROR";else if(e.message.includes("file")||e.message.includes("File")||e.message.includes("ENOENT"))t="FILE_ERROR";return new _r(e.message,t,{originalError:e.name},e)}return new _r(String(e),"GENERATION_ERROR")}function T0(e){let t=e.map((r)=>A0(r).split(ko)),i=t[0];for(let r of t.slice(1)){let n=0;while(n<i.length&&n<r.length&&i[n]===r[n])n++;i=i.slice(0,n)}return i.join(ko)||ko}function O0(e,t){let i=e.cwd||Nd.cwd(),r=t?.config?.entrypoints,n=e.outdir||e.build?.config.outdir||t?.config.outdir||"./dist",o=e.root||e.build?.config.root||t?.config.root;if(!o&&r?.length){let l=T0(r.map((a)=>Ao(i,a)));o=Dd(i,l)||"."}o=o||"./src";let s=e.entrypoints;if(!s)if(r?.length){let l=Ao(i,o),a=[];for(let f of r){let u=Ao(i,f);if(u===l||u.startsWith(l+ko))a.push(Dd(l,u));else console.warn(`[bun-plugin-dtsx] Skipping entrypoint outside root "${o}": ${f}`)}s=a.length?a:["index.ts"]}else s=["index.ts"];return{...e,cwd:i,root:o,entrypoints:s,outdir:n,clean:e.clean??!0,tsconfigPath:e.tsconfigPath,moduleSpecifierMode:e.moduleSpecifierMode??((t?.config.target??e.build?.config.target)==="node"?"node":"preserve")}}var _r,Id;var Ld=me(()=>{Md();_r=class _r extends Error{code;context;cause;constructor(e,t,i,r){super(e);if(this.name="DtsxPluginError",this.code=t,this.context=i,this.cause=r,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}};Id=new Set});import{mkdir as R0,stat as P0}from"fs/promises";import{bold as Ga,dim as Va,green as M0,italic as Bd,log as D0}from"@stacksjs/cli";import{path as Et}from"@stacksjs/path";import{glob as _d}from"@stacksjs/storage";function Wo(e){let t=new Map;for(let s of e){if(t.has(s.name))throw Error(`duplicate package name: ${s.name}`);t.set(s.name,s)}let i=new Map,r=new Set,n=(s,l)=>{let a=i.get(s);if(a!==void 0)return a;if(r.has(s))throw Error(`dependency cycle: ${[...l,s].join(" -> ")}`);r.add(s);let f=t.get(s).dependencies.filter((d)=>d!==s&&t.has(d)),u=f.length?1+Math.max(...f.map((d)=>n(d,[...l,s]))):0;return r.delete(s),i.set(s,u),u},o=[];for(let s of[...e].sort((l,a)=>l.name.localeCompare(a.name)))(o[n(s.name,[])]||=[]).push(s);return o.filter(Boolean)}import{existsSync as Zd,readdirSync as Qd,readFileSync as il}from"fs";import{join as Lo}from"path";function eh(e){return[...Qd(e,{withFileTypes:!0}).filter((i)=>i.isDirectory()).map((i)=>Lo(e,i.name)),e].filter((i)=>{let r=Lo(i,"package.json");if(!Zd(r))return!1;let n=JSON.parse(il(r,"utf8"));return!n.private&&!!n.scripts?.build})}async function th(e){let t=e.map((n)=>{let o=JSON.parse(il(Lo(n,"package.json"),"utf8"));if(!o.name||!o.scripts?.build)throw Error(`Not a buildable workspace package: ${n}`);return{name:o.name,dir:n,dependencies:Object.keys(o.dependencies??{})}}),i=Wo(t),r=[];for(let{name:n,dir:o,dependencies:s}of i.flat()){let l=r.filter((f)=>f.exitCode!==0&&s.includes(f.name)).map((f)=>f.name);if(l.length){console.error(`Cannot build ${o}: dependencies failed: ${l.join(", ")}`),r.push({name:n,dir:o,exitCode:null,blockedBy:l});continue}console.log(`Building ${o}`);let a=Bun.spawn([process.execPath,"run","build"],{cwd:o,stdout:"inherit",stderr:"inherit"});r.push({name:n,dir:o,exitCode:await a.exited,blockedBy:[]})}return r}async function I0(e){let t=await _d([Et.resolve(e,"dist","**/*.d.ts")],{absolute:!0}),i=new Bun.Transpiler({loader:"ts",target:"bun"});for(let r of t){let n=await Bun.file(r).text();try{i.transformSync(n)}catch(o){throw Error(`Invalid declaration generated at ${r}: ${o instanceof Error?o.message:String(o)}`)}}}async function N0(e){let t=Et.resolve(e,"dist","index.js");if(!await Bun.file(t).exists())return;let i=Bun.spawnSync({cmd:[process.execPath,"-e",`try { await import(${JSON.stringify(t)}) } catch (error) { console.error(error); process.exit(1) }`],stdout:"ignore",stderr:"pipe",env:{...process.env,NODE_ENV:"test"}});if(i.exitCode===0)return;let r=new TextDecoder().decode(i.stderr??new Uint8Array),n=/SyntaxError|needs to refer to a top-level declared variable|does not provide an export named|Export named .* not found/i;if(n.test(r)){let o=r.split(`
290
+ `)}if(i.plugins&&i.plugins.length>0)await r.runOnEnd(s);return le.debug("DTS generation complete!"),s}async function S0(e,t,i){let r=await ja(i),n=Ru(t,i,r,Rd.get(i));return zc(e,(o)=>n(o).emittedSpecifier)}async function A0(e,t,i,r,n,o){let s=t;if(r)s=await r.runOnBeforeFile(e,t);let l=new Map;if(!i.isolatedDeclarations){let m=await ja(i);for(let c of xi(s,{includeImports:!0})){let C=m(c.specifier,e).resolved;if(C&&!C.split(/[/\\]/).includes("node_modules"))l.set(c.specifier,await vt(C))}}let a=r?.hasDeclarationHooks()?null:T0(s,e,i,l,o);if(a!==null)return Td(a,e,s,i,r,n,k0(a));let f=l.size?rd(s,l):void 0,u=Pn(s,e,i.keepComments,i.isolatedDeclarations??!1,f);if(r)u=await r.runOnDeclarations(e,s,u);let d=0,h=0;for(let m=0;m<u.length;m++){let c=u[m];if(c.kind==="import")d++;if(c.kind==="export"||c.isExported)h++}let p=bd(u,{filePath:e,sourceCode:s,declarations:u,augmentationImports:o},i.keepComments,i.importOrder);return Td(p,e,s,i,r,n,{declarationCount:u.length,importCount:d,exportCount:h})}function k0(e){let t=0,i=0,r=0;for(let n of e.split(`
291
+ `)){if(!n||n.startsWith(" ")||n.startsWith("\t")||n.startsWith("}")||n.startsWith("*")||n.startsWith("/"))continue;if(t++,n.startsWith("import "))i++;else if(n.startsWith("export "))r++}return{declarationCount:t,importCount:i,exportCount:r}}function T0(e,t,i,r,n){let o=i.importOrder??["bun"];if(o.length!==1||o[0]!=="bun")return null;let s=Qr(t)?rn(e):on(t)?sn(e):e;return ld(s,{keepComments:i.keepComments??!0,isolatedDeclarations:i.isolatedDeclarations??!1,sourceFile:t,inferenceSources:r,augmentationImports:n})}async function Td(e,t,i,r,n,o,s){let l=await S0(e,t,r);if(o)l=Sd(l,o,{filePath:t});if(r.normalizeOutput===!0||r.declarationOrder)l=dd(l,{lineEnding:"lf",declarationOrder:r.declarationOrder,indent:{style:r.indentStyle??"spaces",size:r.indentSize??2}});if(n)l=await n.runOnAfterFile(t,i,l);return{content:l,...s}}var _a,Rd;var Pd=me(()=>{ar();hl();nn();ts();ks();In();Wn();qc();fl();Su();Ta();Ra();Xu();ed();id();nd();cd();hd();pd();$d();Ad();_a=new WeakMap,Rd=new WeakMap});var Md=me(()=>{Pd()});import Nd from"process";import{dirname as O0,relative as Dd,resolve as To,sep as Oo}from"path";class Fd{listeners=new Map;on(e,t){let i=this.listeners.get(e)||[];i.push(t),this.listeners.set(e,i)}async emit(e,t){let i={type:e,timestamp:Date.now(),data:t},r=this.listeners.get(e)||[];for(let n of r)await n(i)}}function Wd(e={}){let{onSuccess:t,onError:i,failOnError:r=!0,incremental:n=!1,cacheDir:o=".dtsx-cache",on:s,timeout:l=60000,continueOnError:a=!1,verbose:f=!1,...u}=e,d=new Fd;if(s){for(let[h,p]of Object.entries(s))if(p)d.on(h,p)}return{name:"bun-plugin-dtsx",async setup(h){let p=Date.now();try{let m=M0({...u,incremental:n,cacheDir:o},h);if(m.clean){let k=To(m.cwd??Nd.cwd(),m.outdir??"./dist");if(Id.has(k))m.clean=!1;else Id.add(k)}if(await d.emit("start",{type:"start",files:m.entrypoints||[],config:m}),f){if(console.log("[bun-plugin-dtsx] Starting declaration generation..."),n)console.log("[bun-plugin-dtsx] Incremental mode enabled")}let C=await(async()=>new Promise((k,W)=>{let A=setTimeout(()=>{W(new _r(`Generation timed out after ${l}ms`,"TIMEOUT_ERROR",{timeout:l}))},l);Ga(m).then((R)=>{clearTimeout(A),k(R)}).catch((R)=>{clearTimeout(A),W(R)})}))(),b=Date.now()-p,v=Math.max(0,C.filesProcessed-C.filesGenerated-C.filesFailed);if(await d.emit("complete",{type:"complete",stats:C,duration:b,fromCache:v}),f){if(console.log(`[bun-plugin-dtsx] Generation complete in ${b}ms`),v>0)console.log(`[bun-plugin-dtsx] ${v} files served from cache`)}if(t)await t(C)}catch(m){let c=R0(m);if(await d.emit("error",{type:"error",error:c}),i)await i(c);else{if(console.error("[bun-plugin-dtsx] Error generating declarations:"),console.error(` Code: ${c.code}`),console.error(` Message: ${c.message}`),c.context)console.error(` Context: ${JSON.stringify(c.context)}`);if(f&&c.stack)console.error(` Stack: ${c.stack}`)}if(r&&!a)throw c}}}}function R0(e){if(e instanceof _r)return e;if(e instanceof Error){let t="GENERATION_ERROR";if(e.message.includes("config")||e.message.includes("Config"))t="CONFIG_ERROR";else if(e.message.includes("file")||e.message.includes("File")||e.message.includes("ENOENT"))t="FILE_ERROR";return new _r(e.message,t,{originalError:e.name},e)}return new _r(String(e),"GENERATION_ERROR")}function P0(e){let t=e.map((r)=>O0(r).split(Oo)),i=t[0];for(let r of t.slice(1)){let n=0;while(n<i.length&&n<r.length&&i[n]===r[n])n++;i=i.slice(0,n)}return i.join(Oo)||Oo}function M0(e,t){let i=e.cwd||Nd.cwd(),r=t?.config?.entrypoints,n=e.outdir||e.build?.config.outdir||t?.config.outdir||"./dist",o=e.root||e.build?.config.root||t?.config.root;if(!o&&r?.length){let l=P0(r.map((a)=>To(i,a)));o=Dd(i,l)||"."}o=o||"./src";let s=e.entrypoints;if(!s)if(r?.length){let l=To(i,o),a=[];for(let f of r){let u=To(i,f);if(u===l||u.startsWith(l+Oo))a.push(Dd(l,u));else console.warn(`[bun-plugin-dtsx] Skipping entrypoint outside root "${o}": ${f}`)}s=a.length?a:["index.ts"]}else s=["index.ts"];return{...e,cwd:i,root:o,entrypoints:s,outdir:n,clean:e.clean??!0,tsconfigPath:e.tsconfigPath,moduleSpecifierMode:e.moduleSpecifierMode??((t?.config.target??e.build?.config.target)==="node"?"node":"preserve")}}var _r,Id;var Ld=me(()=>{Md();_r=class _r extends Error{code;context;cause;constructor(e,t,i,r){super(e);if(this.name="DtsxPluginError",this.code=t,this.context=i,this.cause=r,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}};Id=new Set});import{mkdir as D0,stat as I0}from"fs/promises";import{bold as Va,dim as Ua,green as N0,italic as Bd,log as F0}from"@stacksjs/cli";import{path as Et}from"@stacksjs/path";import{glob as _d}from"@stacksjs/storage";function Bo(e){let t=new Map;for(let s of e){if(t.has(s.name))throw Error(`duplicate package name: ${s.name}`);t.set(s.name,s)}let i=new Map,r=new Set,n=(s,l)=>{let a=i.get(s);if(a!==void 0)return a;if(r.has(s))throw Error(`dependency cycle: ${[...l,s].join(" -> ")}`);r.add(s);let f=t.get(s).dependencies.filter((d)=>d!==s&&t.has(d)),u=f.length?1+Math.max(...f.map((d)=>n(d,[...l,s]))):0;return r.delete(s),i.set(s,u),u},o=[];for(let s of[...e].sort((l,a)=>l.name.localeCompare(a.name)))(o[n(s.name,[])]||=[]).push(s);return o.filter(Boolean)}import{existsSync as Zd,readdirSync as Qd,readFileSync as rl}from"fs";import{join as _o}from"path";function eh(e){return[...Qd(e,{withFileTypes:!0}).filter((i)=>i.isDirectory()).map((i)=>_o(e,i.name)),e].filter((i)=>{let r=_o(i,"package.json");if(!Zd(r))return!1;let n=JSON.parse(rl(r,"utf8"));return!n.private&&!!n.scripts?.build})}async function th(e){let t=e.map((n)=>{let o=JSON.parse(rl(_o(n,"package.json"),"utf8"));if(!o.name||!o.scripts?.build)throw Error(`Not a buildable workspace package: ${n}`);return{name:o.name,dir:n,dependencies:Object.keys(o.dependencies??{})}}),i=Bo(t),r=[];for(let{name:n,dir:o,dependencies:s}of i.flat()){let l=r.filter((f)=>f.exitCode!==0&&s.includes(f.name)).map((f)=>f.name);if(l.length){console.error(`Cannot build ${o}: dependencies failed: ${l.join(", ")}`),r.push({name:n,dir:o,exitCode:null,blockedBy:l});continue}console.log(`Building ${o}`);let a=Bun.spawn([process.execPath,"run","build"],{cwd:o,stdout:"inherit",stderr:"inherit"});r.push({name:n,dir:o,exitCode:await a.exited,blockedBy:[]})}return r}async function W0(e){let t=await _d([Et.resolve(e,"dist","**/*.d.ts")],{absolute:!0}),i=new Bun.Transpiler({loader:"ts",target:"bun"});for(let r of t){let n=await Bun.file(r).text();try{i.transformSync(n)}catch(o){throw Error(`Invalid declaration generated at ${r}: ${o instanceof Error?o.message:String(o)}`)}}}async function L0(e){let t=Et.resolve(e,"dist","index.js");if(!await Bun.file(t).exists())return;let i=Bun.spawnSync({cmd:[process.execPath,"-e",`try { await import(${JSON.stringify(t)}) } catch (error) { console.error(error); process.exit(1) }`],stdout:"ignore",stderr:"pipe",env:{...process.env,NODE_ENV:"test"}});if(i.exitCode===0)return;let r=new TextDecoder().decode(i.stderr??new Uint8Array),n=/SyntaxError|needs to refer to a top-level declared variable|does not provide an export named|Export named .* not found/i;if(n.test(r)){let o=r.split(`
292
292
  `).find((s)=>n.test(s))??r.trim().split(`
293
293
  `)[0];throw Error(`Built package at ${t} cannot be imported: ${o}
294
- Fix the generated module at its source before publishing.`)}}async function O$(e){let i=Date.now()-e.startTime,r=e.pkgName??`@stacksjs/${Et.basename(e.dir)}`;if(e.result.errors&&e.result.errors.length>0)throw console.error("Build errors:",e.result.errors),Error(`Build failed with errors: ${JSON.stringify(e.result.errors)}`);else if(e.result.success!==void 0&&!e.result.success){let o=e.result.logs?.[0]||"Unknown build error";throw console.log(o),Error(`Build failed: ${o}`)}await Bun.write(Et.resolve(e.dir,"dist","tsconfig.json"),`${JSON.stringify({compilerOptions:{paths:{}}},null,2)}
295
- `),await I0(e.dir),await N0(e.dir);let n=await _d([Et.resolve(e.dir,"dist","**/*")],{absolute:!0});for(let o of n){let s=await P0(o),l;if(s.size<1048576)l=`${(s.size/1024).toFixed(2)}kb`;else l=`${(s.size/1024/1024).toFixed(2)}mb`;let a=Et.relative(e.dir,o).replace("dist/","");console.log(`${Ga(Va(`[${l}]`))} ${Va("dist/")}${a}`)}console.log(`${Ga(Va(`[${i}ms]`))} Built ${Bd(Ga(M0(r)))}`)}async function R$(e){let t=e.pkgName??`@stacksjs/${Et.basename(e.dir)}`;if(e.styled===!1)console.log(`Building ${t}...`);else D0.info(`Building ${Bd(t)}...`);return{startTime:Date.now()}}async function P$(e){await Promise.resolve().then(() => Ld());let i=Et.resolve(e.dir,"src"),r=Et.resolve(e.dir,"dist"),n=(await Array.fromAsync(new Bun.Glob("**/*.ts").scan({cwd:i}))).filter((s)=>!s.endsWith(".d.ts")).filter((s)=>!s.endsWith(".test.ts")&&!s.endsWith(".spec.ts")).filter((s)=>!s.split(/[\\/]/).some((l)=>l==="tests"||l==="__tests__"));await Bun.build({entrypoints:n.map((s)=>Et.resolve(i,s)),outdir:r,root:i,target:"bun",format:"esm",splitting:!1,external:e.external??W0(),plugins:[Wd({root:i,outdir:r})]});let o=new Bun.Transpiler({loader:"ts",target:"browser",minifyWhitespace:!0,define:{"process.env.NODE_ENV":"process.env.NODE_ENV"}});for(let s of n){let l=o.transformSync(await Bun.file(Et.resolve(i,s)).text());l=F0(l);let a=Et.resolve(r,s.replace(/\.ts$/,".js"));await R0(Et.dirname(a),{recursive:!0}),await Bun.write(a,l)}}function F0(e){return e.replace(/(['"])(\.\.?\/[^'"]+?)(?<!\.d)\.tsx?\1/g,"$1$2.js$1")}function W0(e=[]){let t=[];try{let i=Xd("fs"),r=JSON.parse(i.readFileSync(`${process.cwd()}/package.json`,"utf8"));t=[...Object.keys(r.dependencies??{}),...Object.keys(r.peerDependencies??{}),...Object.keys(r.optionalDependencies??{})]}catch{}return["@stacksjs/*",...t,...t.map((i)=>`${i}/*`),"bun-queue","ioredis","localtunnels","localtunnels/*","@craft-native/ts","ts-md","meilisearch","algoliasearch","@opensearch-project/opensearch","*.yaml","*.yml",...e]}export{th as buildWorkspacePackages,Wo as dependencyLayers,W0 as frameworkExternal,R$ as intro,O$ as outro,F0 as rewriteRelativeTsSpecifiers,P$ as transpilePackage,I0 as validateDeclarations,N0 as validateRuntimeExports,eh as workspaceBuildTargets};
294
+ Fix the generated module at its source before publishing.`)}}async function D$(e){let i=Date.now()-e.startTime,r=e.pkgName??`@stacksjs/${Et.basename(e.dir)}`;if(e.result.errors&&e.result.errors.length>0)throw console.error("Build errors:",e.result.errors),Error(`Build failed with errors: ${JSON.stringify(e.result.errors)}`);else if(e.result.success!==void 0&&!e.result.success){let o=e.result.logs?.[0]||"Unknown build error";throw console.log(o),Error(`Build failed: ${o}`)}await Bun.write(Et.resolve(e.dir,"dist","tsconfig.json"),`${JSON.stringify({compilerOptions:{paths:{}}},null,2)}
295
+ `),await W0(e.dir),await L0(e.dir);let n=await _d([Et.resolve(e.dir,"dist","**/*")],{absolute:!0});for(let o of n){let s=await I0(o),l;if(s.size<1048576)l=`${(s.size/1024).toFixed(2)}kb`;else l=`${(s.size/1024/1024).toFixed(2)}mb`;let a=Et.relative(e.dir,o).replace("dist/","");console.log(`${Va(Ua(`[${l}]`))} ${Ua("dist/")}${a}`)}console.log(`${Va(Ua(`[${i}ms]`))} Built ${Bd(Va(N0(r)))}`)}async function I$(e){let t=e.pkgName??`@stacksjs/${Et.basename(e.dir)}`;if(e.styled===!1)console.log(`Building ${t}...`);else F0.info(`Building ${Bd(t)}...`);return{startTime:Date.now()}}async function N$(e){await Promise.resolve().then(() => Ld());let i=Et.resolve(e.dir,"src"),r=Et.resolve(e.dir,"dist"),n=(await Array.fromAsync(new Bun.Glob("**/*.ts").scan({cwd:i}))).filter((s)=>!s.endsWith(".d.ts")).filter((s)=>!s.endsWith(".test.ts")&&!s.endsWith(".spec.ts")).filter((s)=>!s.split(/[\\/]/).some((l)=>l==="tests"||l==="__tests__"));await Bun.build({entrypoints:n.map((s)=>Et.resolve(i,s)),outdir:r,root:i,target:"bun",format:"esm",splitting:!1,external:e.external??_0(),plugins:[Wd({root:i,outdir:r})]});let o=new Bun.Transpiler({loader:"ts",target:"browser",minifyWhitespace:!0,define:{"process.env.NODE_ENV":"process.env.NODE_ENV"}});for(let s of n){let l=o.transformSync(await Bun.file(Et.resolve(i,s)).text());l=B0(l);let a=Et.resolve(r,s.replace(/\.ts$/,".js"));await D0(Et.dirname(a),{recursive:!0}),await Bun.write(a,l)}}function B0(e){return e.replace(/(['"])(\.\.?\/[^'"]+?)(?<!\.d)\.tsx?\1/g,"$1$2.js$1")}function _0(e=[]){let t=[];try{let i=Xd("fs"),r=JSON.parse(i.readFileSync(`${process.cwd()}/package.json`,"utf8"));t=[...Object.keys(r.dependencies??{}),...Object.keys(r.peerDependencies??{}),...Object.keys(r.optionalDependencies??{})]}catch{}return["@stacksjs/*",...t,...t.map((i)=>`${i}/*`),"bun-queue","ioredis","localtunnels","localtunnels/*","@craft-native/ts","ts-md","meilisearch","algoliasearch","@opensearch-project/opensearch","*.yaml","*.yml",...e]}export{th as buildWorkspacePackages,Bo as dependencyLayers,_0 as frameworkExternal,I$ as intro,D$ as outro,B0 as rewriteRelativeTsSpecifiers,N$ as transpilePackage,W0 as validateDeclarations,L0 as validateRuntimeExports,eh as workspaceBuildTargets};