@stacksjs/build 0.75.443 → 0.75.447

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 +161 -161
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1,55 +1,55 @@
1
1
  // @bun
2
- var ue=(e,t,i)=>()=>{if(e)try{t=e(e=0)}catch(n){i=[n]}if(i)throw i[0];return t};var nf=import.meta.require;import{readFile as cf,stat as Lm,writeFile as ff}from"fs/promises";async function as(e,t){if(Wi)return globalThis.Bun.write(e,t);let i=typeof t==="string"?t:t instanceof ArrayBuffer?Buffer.from(t):t;return await ff(e,i),typeof t==="string"?Buffer.byteLength(t):t.byteLength}async function Ot(e){if(Wi)return globalThis.Bun.file(e).text();return cf(e,"utf-8")}var Wi,Wm;var Bi=ue(()=>{Wi=typeof globalThis.Bun<"u",Wm=!Wi&&typeof process<"u"&&!!process.versions?.node});function Ut(e){return ls[e]>=ls[Gi]}function df(){if(!hf)return"";return`[${new Date().toISOString().slice(11,23)}] `}function pf(e,t){let i=df();if(e||i)return[`${i}${e}`,...t];return t}function Kt(e,t,i){let n=pf(t,i);if(cs){cs(e,...n);return}switch(e){case"debug":console.debug(...n);break;case"info":console.log(...n);break;case"warn":console.warn(...n);break;case"error":console.error(...n);break}}function fs(e){return{debug:(...t)=>{if(Ut("debug"))Kt("debug",e,t)},info:(...t)=>{if(Ut("info"))Kt("info",e,t)},warn:(...t)=>{if(Ut("warn"))Kt("warn",e,t)},error:(...t)=>{if(Ut("error"))Kt("error",e,t)},setLevel:(t)=>{Gi=t},getLevel:()=>Gi,child:(t)=>{let i=e?`${e}:${t}`:`[${t}]`;return fs(i)},time:(t)=>{let i=performance.now();return()=>{let n=performance.now()-i;if(Ut("debug"))Kt("debug",e,[`${t}: ${n.toFixed(2)}ms`])}},progress:(t)=>{if(Ut("info"))if(typeof process<"u"&&process.stdout?.isTTY)process.stdout.write(`\r${e} ${t}`);else Kt("info",e,[t])}}}function ln(e){Gi=e}var ls,Gi="info",uf="[dtsx]",hf=!1,cs=null,Y;var cn=ue(()=>{ls={debug:0,info:1,warn:2,error:3,silent:4};Y=fs(uf)});function dt(e){return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36||e>127}function _e(e){return dt(e)||e>=48&&e<=57}function us(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 n=e.lastIndexOf(`
3
- `,i)+1,r=mf(e,n,i);if(r!==-1){i=r-1;continue}return i}}function mf(e,t,i){let n=0;for(let r=t;r<=i;r++){let o=e.charCodeAt(r);if(n){if(o===92){r++;continue}if(o===n)n=0;continue}if(o===39||o===34||o===96){n=o;continue}if(o===47&&r+1<=i&&e.charCodeAt(r+1)===47)return r}return-1}function hs(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 ds(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 gf(e,t){let i=[],n=[],r=0,o=!1,s="",a="",c=!0,f=0,u=(l,m=!1)=>{a=s,s=l,c=m};while(f<=t){let l=e.charCodeAt(f);if(o){if(l===92){f+=2;continue}if(l===96)o=!1,u("literal");else if(l===36&&e.charCodeAt(f+1)===123)n.push(r++),o=!1,u("{",!0),f++;f++;continue}if(l===32||l===9||l===10||l===13){f++;continue}if(l===47&&e.charCodeAt(f+1)===47){let m=e.indexOf(`
4
- `,f+2);f=m===-1?e.length:m+1;continue}if(l===47&&e.charCodeAt(f+1)===42){let m=e.indexOf("*/",f+2);f=m===-1?e.length:m+2;continue}if(l===39||l===34){let m=l;f++;while(f<e.length){let y=e.charCodeAt(f++);if(y===92)f++;else if(y===m)break}u("literal");continue}if(l===96){o=!0,f++;continue}if(dt(l)||l===35&&dt(e.charCodeAt(f+1))){let m=f++;while(_e(e.charCodeAt(f)))f++;let y=e.slice(m,f);u(y,s!=="."&&ds(y));continue}if(l===40){let m=a!=="."&&(s==="if"||s==="while"||s==="for"||s==="with"||s==="switch"||s==="catch"||s==="await"&&a==="for");i.push(m),u("(",!0)}else if(l===41){let m=i.pop()??!1;if(f===t)return m;u(")",m)}else if(l===47&&c){f=di(e,f),u("literal");continue}else{if(l===123)r++;else if(l===125){if(r--,n.at(-1)===r)n.pop(),o=!0}u(e[f],l===47||hs(l))}f++}return!1}function ji(e,t){let i=us(e,t-1);if(i<0)return!0;let n=e.charCodeAt(i);if(n===41)return gf(e,i);if(hs(n))return!0;if(_e(n)){let r=i;while(r>=0&&_e(e.charCodeAt(r)))r--;let o=e.charCodeAt(us(e,r));if(o===46||o===35)return!1;return ds(e.slice(r+1,i+1))}return!1}function di(e,t){let i=t,n=e.length;i++;let r=!1;while(i<n){let o=e.charCodeAt(i);if(o===92){i+=2;continue}if(r){if(o===93)r=!1;i++;continue}if(o===91){r=!0,i++;continue}if(o===47){i++;break}if(o===10||o===13)break;i++}while(i<n&&_e(e.charCodeAt(i)))i++;return i}var fn=()=>{};function ps(e){let t="",i=0,n=0;while(i<e.length){let r=e.charCodeAt(i);if(n){if(t+=e[i],r===92&&i+1<e.length){t+=e[i+1],i+=2;continue}if(r===n)n=0;i++;continue}if(r===34){n=r,t+=e[i++];continue}if(r===47&&e.charCodeAt(i+1)===47){i+=2;while(i<e.length&&e.charCodeAt(i)!==10&&e.charCodeAt(i)!==13)i++;continue}if(r===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+=`
5
- `;i++}i=Math.min(i+2,e.length);continue}if(r===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 ms=()=>{};import{readFileSync as yf,statSync as Cf}from"fs";import{readFile as wf}from"fs/promises";import{createRequire as Ef}from"module";import{dirname as pi,isAbsolute as vf,join as un,resolve as hn}from"path";function Ht(e){let t=[e];if(!e.endsWith(".json"))t.push(`${e}.json`);t.push(un(e,"tsconfig.json"));for(let i of t)try{if(Cf(i).isFile())return i}catch{}return null}function bf(e,t){if(vf(e)||e.startsWith("."))return Ht(hn(pi(t),e));let i=Ef(t),n=e.startsWith("@")?/^@[^/]+\/[^/]+/.exec(e)?.[0]:e.split("/")[0];if(n)for(let r of i.resolve.paths(n)??[]){let o=Ht(un(r,n,"package.json"));if(!o)continue;let s=JSON.parse(yf(o,"utf8"));if(e===n){if(s.tsconfig!==void 0){if(typeof s.tsconfig!=="string")throw Error(`Invalid tsconfig field in ${o}`);let c=Ht(hn(pi(o),s.tsconfig));if(!c)throw Error(`Cannot resolve tsconfig ${JSON.stringify(s.tsconfig)} from ${o}`);return c}let a=Ht(un(pi(o),"tsconfig.json"));if(a)return a}break}for(let r of[`${e}/tsconfig.json`,e])try{let o=i.resolve(r),s=o.endsWith(".json")?Ht(o):null;if(s)return s}catch{}return null}async function mi(e,t={},i=new Set){let n=Ht(e);if(!n)return;if(i.has(n)){if(t.allowCircular)return;throw Error(`Circular tsconfig extends: ${n}`)}let r=new Set(i).add(n),o=JSON.parse(ps(await wf(n,"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 ${n}`);let a={};for(let f of s){let u=bf(f,n);if(!u)throw Error(`Cannot resolve tsconfig extends ${JSON.stringify(f)} from ${n}`);a={...a,...await mi(u,t,r)}}let c=o.compilerOptions??{};if(c.isolatedDeclarations!==void 0)a.isolatedDeclarations=c.isolatedDeclarations;if(c.baseUrl!==void 0){if(typeof c.baseUrl!=="string")throw Error(`Invalid baseUrl in ${n}`);a.baseUrl=hn(pi(n),c.baseUrl)}if(c.paths!==void 0){if(!c.paths||typeof c.paths!=="object"||Array.isArray(c.paths))throw Error(`Invalid paths in ${n}`);for(let[f,u]of Object.entries(c.paths))if(f.split("*").length>2||!Array.isArray(u)||u.length===0||u.some((l)=>typeof l!=="string"||l.split("*").length>2))throw Error(`Invalid path mapping ${JSON.stringify(f)} in ${n}`);a.paths=c.paths,a.pathsBasePath=pi(n)}return a}var dn=ue(()=>{ms()});import{existsSync as mn,readFileSync as gs,realpathSync as gi,statSync as Sf}from"fs";import{builtinModules as $f}from"module";import{dirname as gn,extname as Af,isAbsolute as yn,join as bs,relative as Ss,resolve as zt}from"path";function _i(e){try{return Sf(e).isFile()}catch{return!1}}function Jt(e,t){let i=e.replace(/[?#].*$/,"");if(!(i.startsWith("./")||i.startsWith("../")||i==="."||i==="..")&&!yn(i))return{resolved:null,isRelative:!1};let n=gn(t),r=zt(n,i);if(_i(r))return{resolved:r,isRelative:!0};let o=Af(r),s=xf[o];if(s){let a=r.slice(0,-o.length);for(let c of s){let f=a+c;if(_i(f))return{resolved:f,isRelative:!0}}}for(let a of ys){let c=r+a;if(_i(c))return{resolved:c,isRelative:!0}}if(mn(r))for(let a of ys){let c=bs(r,`index${a}`);if(_i(c))return{resolved:c,isRelative:!0}}return{resolved:null,isRelative:!0}}function $s(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 As(e,t){if(Object.hasOwn(e,t))return e[t]!==null;let i=Object.keys(e).filter((n)=>n.includes("*")&&$s(n,t)).sort((n,r)=>r.indexOf("*")-n.indexOf("*")||r.length-n.length)[0];return i!==void 0&&e[i]!==null}function Cs(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 n=e.exports;if(!Object.keys(n).some((r)=>r.startsWith(".")))return i===".";return As(n,i)}function pn(e,t){let i=Ss(e,t);return i!==".."&&!i.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!yn(i)}async function xs(e){let t=await mi(zt(e.cwd,e.tsconfigPath||"tsconfig.json")),i=Object.entries(t?.paths??{});if(i.length===0)return Jt;let n=t?.baseUrl??t?.pathsBasePath??e.cwd,r=zt(e.cwd,e.root),o=new Map,s=new Set([...$f,"bun"]),a=(f)=>{let u=gn(f),l=[];while(!0){if(o.has(u)){let w=o.get(u);for(let C of l)o.set(C,w);return w}l.push(u);let m=bs(u,"package.json");if(mn(m)){let w={...JSON.parse(gs(m,"utf8")),directory:gi(u)};for(let C of l)o.set(C,w);return w}let y=gn(u);if(y===u)return;u=y}},c=(f,u)=>{if(f.startsWith(".")||yn(f))return Jt(f,u);if(f.startsWith("node:")||f.startsWith("bun:")||s.has(f))return{resolved:null,isRelative:!1};let l=a(u),m=f.startsWith("@")?/^@[^/]+\/[^/]+/.exec(f)?.[0]:f.split("/")[0];if(l&&(Cs(l,f)||As(l.imports??{},f)||m&&[l.dependencies,l.devDependencies,l.peerDependencies,l.optionalDependencies].some((L)=>Object.hasOwn(L??{},m))))return{resolved:null,isRelative:!1};let y=i.filter(([L])=>$s(L,f)).sort(([L],[W])=>{if(!L.includes("*"))return-1;if(!W.includes("*"))return 1;return W.indexOf("*")-L.indexOf("*")})[0];if(!y)return{resolved:null,isRelative:!1};let[w,C]=y,x=w.indexOf("*"),k=x===-1?"":f.slice(x,f.length-(w.length-x-1));for(let L of C){let W=zt(n,L.replace("*",k)),T=a(W);if(T&&Cs(T,f)&&!T.private&&T.directory!==l?.directory)return{resolved:null,isRelative:!1};let D=Jt(W,u);if(!D.resolved)continue;let I=gi(D.resolved),N=e.outputStructure==="flat"||mn(r)&&pn(gi(r),I);if(!l||!pn(l.directory,I)||!N||a(I)?.directory!==l.directory||/\.d\.(?:ts|mts|cts)$/.test(I))throw Error(`Local alias ${JSON.stringify(f)} from ${u} resolves outside its emitted package source: ${I}`);return Y.debug(`Resolved local declaration alias ${f} from ${u} to ${I}`),{resolved:e.outputStructure==="flat"?D.resolved:zt(r,Ss(gi(r),I)),isRelative:!0,isAlias:!0,suffix:W.match(/[?#].*$/)?.[0]??""}}throw Error(`Cannot resolve local alias ${JSON.stringify(f)} from ${u} using ${e.tsconfigPath||"tsconfig.json"} (${JSON.stringify(w)})`)};return c.isPackageLocal=(f,u)=>{let l=a(f);return!!l&&a(u)?.directory===l.directory&&pn(l.directory,gi(u))},c.cacheKey=(f)=>{let u=f.map((m)=>({file:m,references:Vi(gs(m,"utf8"),{includeImports:!0}).map((y)=>({specifier:y.specifier,resolution:c(y.specifier,m)}))})),l=[...new Set(o.values())].filter((m)=>m!==void 0).sort((m,y)=>m.directory.localeCompare(y.directory));return JSON.stringify({root:r,compilerOptions:t,packages:l,edges:u})},c}function Ts(e,t=[]){let i=e.length,n="",r=0;while(r<i){let o=e.charCodeAt(r);if(o===34||o===39||o===96){let s=o,a=r;n+=e[r++];while(r<i){let c=e.charCodeAt(r),f=e[r++];if(n+=s===96&&c!==s?c===10||c===13?f:" ":f,c===92&&r<i){let u=e[r++];n+=s===96?u===`
6
- `||u==="\r"?u:" ":u;continue}if(c===s)break}t.push({start:a,end:r});continue}if(o===47&&r+1<i){let s=e.charCodeAt(r+1);if(s===47){n+=" ",r+=2;while(r<i&&e.charCodeAt(r)!==10)n+=" ",r++;continue}if(s===42){n+=" ",r+=2;while(r<i&&!(e.charCodeAt(r)===42&&e.charCodeAt(r+1)===47))n+=e[r]===`
7
- `||e[r]==="\r"?e[r]:" ",r++;if(r<i)n+=" ",r+=2;continue}if(ji(e,r)){let a=di(e,r);n+=e.slice(r,a).replace(/[^\r\n]/g," "),r=a;continue}}n+=e[r++]}return n}function Vi(e,t={}){let i=[],n=[],r=Ts(e,n),o=(a)=>n.some((c)=>a>c.start&&a<c.end);ws.lastIndex=0;let s;while((s=ws.exec(r))!==null){if(o(s.index))continue;let a=!!s[1],c=s[3],f=s[0],u;if(f.includes("* as "))u="export-star-as";else if(f.includes("*"))u="export-star";else u="export-named";i.push({specifier:c,kind:u,isTypeOnly:a})}if(t.includeImports){vs.lastIndex=0;while((s=vs.exec(r))!==null){if(o(s.index))continue;i.push({specifier:s[3],kind:"import",isTypeOnly:!!s[1]})}}if(t.includeImports){Es.lastIndex=0;while((s=Es.exec(r))!==null)if(!o(s.index))i.push({specifier:s[2],kind:"import",isTypeOnly:!1})}return i}function Os(e,t){let i=[],n=Ts(e,i),r=/\b(?:from\s*|import\s*(?:\(\s*)?)(['"])([^'"]+)\1/g,o=[],s;while((s=r.exec(n))!==null){if(i.some((u)=>s.index>u.start&&s.index<u.end))continue;let c=s.index+s[0].lastIndexOf(`${s[1]}${s[2]}${s[1]}`)+1,f=t(s[2]);if(f!==s[2])o.push({start:c,end:c+s[2].length,value:f})}let a=e;for(let c of o.reverse())a=a.slice(0,c.start)+c.value+a.slice(c.end);return a}async function Cn(e,t={}){let i=new Set,n=new Map,r=[],o=[];for(let s of e){let a=zt(s);if(!i.has(a))i.add(a),o.push(a)}while(o.length>0){let s=o.shift(),a;try{a=await Ot(s)}catch{continue}let c=Vi(a,t);n.set(s,c);for(let f of c){let u=(t.resolveSpecifier??Jt)(f.specifier,s);if(!u.isRelative)continue;if(u.resolved){if(!i.has(u.resolved))i.add(u.resolved),o.push(u.resolved)}else r.push({from:s,specifier:f.specifier,isTypeOnly:f.isTypeOnly})}}return{reachable:i,reExports:n,unresolved:r}}var ys,xf,ws,Es,vs;var wn=ue(()=>{Bi();cn();fn();dn();ys=[".ts",".tsx",".mts",".cts",".vue",".stx",".js",".jsx",".mjs",".cjs",".d.ts",".d.mts",".d.cts"],xf={".js":[".ts",".tsx",".d.ts"],".jsx":[".tsx",".ts",".d.ts"],".mjs":[".mts",".d.mts"],".cjs":[".cts",".d.cts"]};ws=/(?:^|[\n;{}])\s*export\s+(type\s+)?(?:\*(?:\s+as\s+\w+)?|\{[^}]*\})\s+from\s+(['"])([^'"]+)\2/g,Es=/\bimport\s*\(\s*(['"])([^'"]+)\1/g,vs=/(?:^|[\n;{}])\s*import\s+(type\s+)?(?:[^'";]+?\s+from\s+)?(['"])([^'"]+)\2/g});import{relative as Nt}from"path";function Tf(e){let t=[],i=[],n=0,r=0,o=[],s=!1,a=0,c=e.length,f=(u)=>{let l=e.slice(n,u).trim();if(n=u,!l)return;if(Of(l)){i.push(l);return}t.push({text:l,comments:i}),i=[]};while(a<c){let u=e[a];if(s){if(u==="\\"){a+=2;continue}if(u==="`"){s=!1,a++;continue}if(u==="$"&&e[a+1]==="{"){o.push(r),r++,s=!1,a+=2;continue}a++;continue}if(u==="/"&&e[a+1]==="*"){let l=e.indexOf("*/",a+2);a=l===-1?c:l+2;continue}if(u==="/"&&e[a+1]==="/"){let l=e.indexOf(`
8
- `,a);a=l===-1?c:l;continue}if(u==="'"||u==='"'){a++;while(a<c&&e[a]!==u&&e[a]!==`
9
- `){if(e[a]==="\\")a++;a++}a++;continue}if(u==="`"){s=!0,a++;continue}if(u==="("||u==="["||u==="{"){r++,a++;continue}if(u===")"||u==="]"||u==="}"){if(r--,o.length>0&&u==="}"&&r===o[o.length-1])o.pop(),s=!0;a++;continue}if(r===0&&u===";"){f(a+1),a++;continue}if(r===0&&u===`
10
- `){let l=e[a+1];if(l!==void 0&&/[\w$@/]/.test(l))f(a+1);a++;continue}a++}return f(c),t}function Of(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(`
11
- `,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 En(e){let t=[];for(let i of e.split(",")){let n=i.replace(/\/\*[\s\S]*?\*\//g,"").trim().replace(/^type\s+/,"");if(!n)continue;let r=n.match(/^([\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!r)continue;t.push({local:r[1],exported:r[2]??r[1]})}return t}function Rf(e){let t={named:[]},i=e.trim().replace(/^type\s+/,""),n=i.match(/\{([\s\S]*)\}/);if(n){for(let s of En(n[1]))t.named.push({imported:s.local,local:s.exported});i=i.replace(n[0],"")}let r=i.match(/\*\s*as\s+([\w$]+)/);if(r)t.namespaceName=r[1],i=i.replace(r[0],"");let o=i.replace(/,/g,"").trim();if(o&&Ps.test(o))t.defaultName=o;return t}function kf(e,t){let i=e.replace(/^export\s+/,""),n=/^default\s+/.test(i);if(i=i.replace(/^default\s+/,""),n)i=i.replace(/^((?:declare\s+)?(?:abstract\s+)?(?:class|function\s*\*?|async\s+function\s*\*?))\s*(?=[(<{])/,(r,o)=>`${o.trimEnd()} ${t}`);if(/^(?:interface|type)\b/.test(i)||/^declare\b/.test(i))return i;return`declare ${i}`}function Mf(e,t){let i={file:e,declarations:[],declared:new Set,imports:new Map,localExports:new Map,namedReExports:[],starReExports:[],namespaceReExports:[],verbatim:[],directives:[]},n=Tf(t);for(let r of n){r.comments=r.comments.filter((c)=>{if(/^\/\/\/\s*</.test(c))return i.directives.push(...c.split(`
12
- `).map((f)=>f.trim()).filter((f)=>f.startsWith("///"))),!1;return!0});let o=r.text.replace(/;\s*$/,"").trim(),s=o.match(/^import\s+(type\s+)?([\s\S]+?)\s+from\s+(['"])([^'"]+)\3/);if(s){let c=Rf(s[2]),f=s[4];if(c.defaultName)i.imports.set(c.defaultName,{specifier:f,imported:"default"});if(c.namespaceName)i.imports.set(c.namespaceName,{specifier:f,imported:"*"});for(let u of c.named)i.imports.set(u.local,{specifier:f,imported:u.imported});continue}if(/^import\s+['"]/.test(o)){i.verbatim.push(r);continue}if(s=o.match(/^export\s+(?:type\s+)?\*\s+as\s+([\w$]+)\s+from\s+(['"])([^'"]+)\2/),s){i.namespaceReExports.push({specifier:s[3],exported:s[1]});continue}if(s=o.match(/^export\s+(?:type\s+)?\*\s+from\s+(['"])([^'"]+)\1/),s){i.starReExports.push(s[2]);continue}if(s=o.match(/^export\s+(?:type\s+)?\{([\s\S]*)\}\s+from\s+(['"])([^'"]+)\2/),s){for(let c of En(s[1]))i.namedReExports.push({specifier:s[3],imported:c.local,exported:c.exported});continue}if(s=o.match(/^export\s+(?:type\s+)?\{([\s\S]*)\}$/),s){for(let c of En(s[1]))i.localExports.set(c.exported,c.local);continue}if(s=o.match(/^export\s+default\s+([\w$]+)$/),s&&Ps.test(s[1])){i.localExports.set("default",s[1]);continue}if(/^export\s+as\s+namespace\b/.test(o)||/^(?:export\s+)?declare\s+(?:global\b|module\s+['"])/.test(o)){i.verbatim.push(r);continue}let a=o.match(Pf);if(a){let c=!!a[1],f=a[4]??(c?"_default":null);if(f){if(i.declared.add(f),/^export\s/.test(o))i.localExports.set(c?"default":f,f);i.declarations.push({statement:r,name:f,emit:kf(r.text,f)});continue}}i.declarations.push({statement:r,name:null,emit:r.text})}return i}function Rs(e,t){if(t.size===0)return e;let i="",n=0,r=e.length,o=`
13
- `;while(n<r){let s=e[n];if(s==="/"&&e[n+1]==="*"){let a=e.indexOf("*/",n+2),c=a===-1?r:a+2;i+=e.slice(n,c),n=c;continue}if(s==="/"&&e[n+1]==="/"){let a=e.indexOf(`
14
- `,n),c=a===-1?r:a;i+=e.slice(n,c),n=c;continue}if(s==="'"||s==='"'){let a=n+1;while(a<r&&e[a]!==s&&e[a]!==`
15
- `){if(e[a]==="\\")a++;a++}i+=e.slice(n,a+1),n=a+1,o=s;continue}if(/[A-Z_$]/i.test(s)){let a=n+1;while(a<r&&/[\w$]/.test(e[a]))a++;let c=e.slice(n,a),f=t.get(c);if(f!==void 0&&o!=="."){let u=a;while(u<r&&(e[u]===" "||e[u]==="\t"))u++;let l=(e[u]===":"||e[u]==="?"&&e[u+1]===":")&&/[{;,(\n]/.test(o);i+=l?c:f}else i+=c;o="a",n=a;continue}if(i+=s,s===`
16
- `||!/\s/.test(s))o=s;n++}return i}function ks(e,t,i,n){let r=[],o=new Map,s=[e,...t.filter((F)=>F!==e)];for(let F of s){let U=i.get(F);if(U===void 0){r.push(`No declarations were generated for ${Nt(n.cwd,F)}; it is left out of the bundle`);continue}o.set(F,Mf(F,U))}let a=(F,U)=>{if(!F.startsWith(".")&&!F.startsWith("/"))return null;let q=Jt(F,U).resolved;return q&&o.has(q)?q:null},c=(F)=>F.startsWith(".")||F.startsWith("/"),f=new Set,u=(F)=>{let U=F;for(let q=1;f.has(U);q++)U=`${F}_${q}`;return f.add(U),U},l=new Map;for(let[F,U]of o){let q=new Map;for(let Z of U.declared)q.set(Z,u(Z));l.set(F,q)}let m=new Map,y=(F,U,q)=>{let Z=`${F}\x00${U}`,J=m.get(Z);if(!J)J=u(q),m.set(Z,J);return J},w=new Map,C=new Map,x=new Set,k=(F,U,q)=>{let Z=a(U,F.file);if(Z){if(q==="*")return{kind:"namespace",file:Z};let J=W(Z).get(q);if(!J)r.push(`${Nt(n.cwd,F.file)}: '${q}' is not exported by '${U}'`);return J??null}if(c(U))return r.push(`${Nt(n.cwd,F.file)}: '${U}' is not part of the bundle`),null;return q==="*"?{kind:"external-namespace",source:U}:{kind:"external",source:U,imported:q}},L=(F,U)=>{if(F.declared.has(U))return{kind:"local",name:l.get(F.file).get(U)};let q=F.imports.get(U);if(q)return k(F,q.specifier,q.imported);return r.push(`${Nt(n.cwd,F.file)}: cannot resolve exported name '${U}'`),null};function W(F){let U=w.get(F);if(U)return U;let q=new Map,Z=o.get(F);if(!Z||x.has(F))return q;x.add(F);let J=new Set;for(let[te,se]of Z.localExports){let re=L(Z,se);if(re)q.set(te,re)}for(let te of Z.namedReExports){let se=k(Z,te.specifier,te.imported);if(se)q.set(te.exported,se)}for(let te of Z.namespaceReExports){let se=k(Z,te.specifier,"*");if(se)q.set(te.exported,se)}for(let te of Z.starReExports){let se=a(te,F);if(se){for(let[re,qr]of W(se))if(re!=="default"&&!q.has(re))q.set(re,qr);for(let re of C.get(se)??[])J.add(re)}else if(c(te))r.push(`${Nt(n.cwd,F)}: '${te}' is not part of the bundle`);else J.add(te)}return x.delete(F),w.set(F,q),C.set(F,J),q}let T=new Map,D=[],I=(F,U)=>{switch(F.kind){case"local":return F.name;case"external":return y(F.source,F.imported,F.imported==="default"?U:F.imported);case"external-namespace":return y(F.source,"*",U);case"namespace":return N(F.file,U)}};function N(F,U){let q=T.get(F);if(q)return q;let Z=u(U);T.set(F,Z);let J=[];for(let[te,se]of W(F)){if(te==="default")continue;let re=I(se,te);J.push(re===te?te:`${re} as ${te}`)}if(C.get(F)?.size)r.push(`${Nt(n.cwd,F)}: 'export * from' an external module cannot be expressed inside namespace '${Z}'`);return D.push(`declare namespace ${Z} {
2
+ var de=(e,t,i)=>()=>{if(e)try{t=e(e=0)}catch(n){i=[n]}if(i)throw i[0];return t};var of=import.meta.require;import{readFile as ff,stat as Wm,writeFile as uf}from"fs/promises";async function ls(e,t){if(Wi)return globalThis.Bun.write(e,t);let i=typeof t==="string"?t:t instanceof ArrayBuffer?Buffer.from(t):t;return await uf(e,i),typeof t==="string"?Buffer.byteLength(t):t.byteLength}async function Ot(e){if(Wi)return globalThis.Bun.file(e).text();return ff(e,"utf-8")}var Wi,Bm;var Bi=de(()=>{Wi=typeof globalThis.Bun<"u",Bm=!Wi&&typeof process<"u"&&!!process.versions?.node});function Ut(e){return cs[e]>=cs[Gi]}function pf(){if(!df)return"";return`[${new Date().toISOString().slice(11,23)}] `}function mf(e,t){let i=pf();if(e||i)return[`${i}${e}`,...t];return t}function Kt(e,t,i){let n=mf(t,i);if(fs){fs(e,...n);return}switch(e){case"debug":console.debug(...n);break;case"info":console.log(...n);break;case"warn":console.warn(...n);break;case"error":console.error(...n);break}}function us(e){return{debug:(...t)=>{if(Ut("debug"))Kt("debug",e,t)},info:(...t)=>{if(Ut("info"))Kt("info",e,t)},warn:(...t)=>{if(Ut("warn"))Kt("warn",e,t)},error:(...t)=>{if(Ut("error"))Kt("error",e,t)},setLevel:(t)=>{Gi=t},getLevel:()=>Gi,child:(t)=>{let i=e?`${e}:${t}`:`[${t}]`;return us(i)},time:(t)=>{let i=performance.now();return()=>{let n=performance.now()-i;if(Ut("debug"))Kt("debug",e,[`${t}: ${n.toFixed(2)}ms`])}},progress:(t)=>{if(Ut("info"))if(typeof process<"u"&&process.stdout?.isTTY)process.stdout.write(`\r${e} ${t}`);else Kt("info",e,[t])}}}function ln(e){Gi=e}var cs,Gi="info",hf="[dtsx]",df=!1,fs=null,Y;var cn=de(()=>{cs={debug:0,info:1,warn:2,error:3,silent:4};Y=us(hf)});function mt(e){return e>=65&&e<=90||e>=97&&e<=122||e===95||e===36||e>127}function _e(e){return mt(e)||e>=48&&e<=57}function hs(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 n=e.lastIndexOf(`
3
+ `,i)+1,r=gf(e,n,i);if(r!==-1){i=r-1;continue}return i}}function gf(e,t,i){let n=0;for(let r=t;r<=i;r++){let o=e.charCodeAt(r);if(n){if(o===92){r++;continue}if(o===n)n=0;continue}if(o===39||o===34||o===96){n=o;continue}if(o===47&&r+1<=i&&e.charCodeAt(r+1)===47)return r}return-1}function ds(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 ps(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 yf(e,t){let i=[],n=[],r=0,o=!1,s="",l="",c=!0,f=0,u=(a,m=!1)=>{l=s,s=a,c=m};while(f<=t){let a=e.charCodeAt(f);if(o){if(a===92){f+=2;continue}if(a===96)o=!1,u("literal");else if(a===36&&e.charCodeAt(f+1)===123)n.push(r++),o=!1,u("{",!0),f++;f++;continue}if(a===32||a===9||a===10||a===13){f++;continue}if(a===47&&e.charCodeAt(f+1)===47){let m=e.indexOf(`
4
+ `,f+2);f=m===-1?e.length:m+1;continue}if(a===47&&e.charCodeAt(f+1)===42){let m=e.indexOf("*/",f+2);f=m===-1?e.length:m+2;continue}if(a===39||a===34){let m=a;f++;while(f<e.length){let y=e.charCodeAt(f++);if(y===92)f++;else if(y===m)break}u("literal");continue}if(a===96){o=!0,f++;continue}if(mt(a)||a===35&&mt(e.charCodeAt(f+1))){let m=f++;while(_e(e.charCodeAt(f)))f++;let y=e.slice(m,f);u(y,s!=="."&&ps(y));continue}if(a===40){let m=l!=="."&&(s==="if"||s==="while"||s==="for"||s==="with"||s==="switch"||s==="catch"||s==="await"&&l==="for");i.push(m),u("(",!0)}else if(a===41){let m=i.pop()??!1;if(f===t)return m;u(")",m)}else if(a===47&&c){f=di(e,f),u("literal");continue}else{if(a===123)r++;else if(a===125){if(r--,n.at(-1)===r)n.pop(),o=!0}u(e[f],a===47||ds(a))}f++}return!1}function ji(e,t){let i=hs(e,t-1);if(i<0)return!0;let n=e.charCodeAt(i);if(n===41)return yf(e,i);if(ds(n))return!0;if(_e(n)){let r=i;while(r>=0&&_e(e.charCodeAt(r)))r--;let o=e.charCodeAt(hs(e,r));if(o===46||o===35)return!1;return ps(e.slice(r+1,i+1))}return!1}function di(e,t){let i=t,n=e.length;i++;let r=!1;while(i<n){let o=e.charCodeAt(i);if(o===92){i+=2;continue}if(r){if(o===93)r=!1;i++;continue}if(o===91){r=!0,i++;continue}if(o===47){i++;break}if(o===10||o===13)break;i++}while(i<n&&_e(e.charCodeAt(i)))i++;return i}var fn=()=>{};function ms(e){let t="",i=0,n=0;while(i<e.length){let r=e.charCodeAt(i);if(n){if(t+=e[i],r===92&&i+1<e.length){t+=e[i+1],i+=2;continue}if(r===n)n=0;i++;continue}if(r===34){n=r,t+=e[i++];continue}if(r===47&&e.charCodeAt(i+1)===47){i+=2;while(i<e.length&&e.charCodeAt(i)!==10&&e.charCodeAt(i)!==13)i++;continue}if(r===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+=`
5
+ `;i++}i=Math.min(i+2,e.length);continue}if(r===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 gs=()=>{};import{readFileSync as Cf,statSync as wf}from"fs";import{readFile as bf}from"fs/promises";import{createRequire as Ef}from"module";import{dirname as pi,isAbsolute as vf,join as un,resolve as hn}from"path";function Ht(e){let t=[e];if(!e.endsWith(".json"))t.push(`${e}.json`);t.push(un(e,"tsconfig.json"));for(let i of t)try{if(wf(i).isFile())return i}catch{}return null}function Sf(e,t){if(vf(e)||e.startsWith("."))return Ht(hn(pi(t),e));let i=Ef(t),n=e.startsWith("@")?/^@[^/]+\/[^/]+/.exec(e)?.[0]:e.split("/")[0];if(n)for(let r of i.resolve.paths(n)??[]){let o=Ht(un(r,n,"package.json"));if(!o)continue;let s=JSON.parse(Cf(o,"utf8"));if(e===n){if(s.tsconfig!==void 0){if(typeof s.tsconfig!=="string")throw Error(`Invalid tsconfig field in ${o}`);let c=Ht(hn(pi(o),s.tsconfig));if(!c)throw Error(`Cannot resolve tsconfig ${JSON.stringify(s.tsconfig)} from ${o}`);return c}let l=Ht(un(pi(o),"tsconfig.json"));if(l)return l}break}for(let r of[`${e}/tsconfig.json`,e])try{let o=i.resolve(r),s=o.endsWith(".json")?Ht(o):null;if(s)return s}catch{}return null}async function mi(e,t={},i=new Set){let n=Ht(e);if(!n)return;if(i.has(n)){if(t.allowCircular)return;throw Error(`Circular tsconfig extends: ${n}`)}let r=new Set(i).add(n),o=JSON.parse(ms(await bf(n,"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 ${n}`);let l={};for(let f of s){let u=Sf(f,n);if(!u)throw Error(`Cannot resolve tsconfig extends ${JSON.stringify(f)} from ${n}`);l={...l,...await mi(u,t,r)}}let c=o.compilerOptions??{};if(c.isolatedDeclarations!==void 0)l.isolatedDeclarations=c.isolatedDeclarations;if(c.baseUrl!==void 0){if(typeof c.baseUrl!=="string")throw Error(`Invalid baseUrl in ${n}`);l.baseUrl=hn(pi(n),c.baseUrl)}if(c.paths!==void 0){if(!c.paths||typeof c.paths!=="object"||Array.isArray(c.paths))throw Error(`Invalid paths in ${n}`);for(let[f,u]of Object.entries(c.paths))if(f.split("*").length>2||!Array.isArray(u)||u.length===0||u.some((a)=>typeof a!=="string"||a.split("*").length>2))throw Error(`Invalid path mapping ${JSON.stringify(f)} in ${n}`);l.paths=c.paths,l.pathsBasePath=pi(n)}return l}var dn=de(()=>{gs()});import{existsSync as mn,readFileSync as ys,realpathSync as gi,statSync as $f}from"fs";import{builtinModules as xf}from"module";import{dirname as gn,extname as Af,isAbsolute as yn,join as Ss,relative as $s,resolve as zt}from"path";function _i(e){try{return $f(e).isFile()}catch{return!1}}function Jt(e,t){let i=e.replace(/[?#].*$/,"");if(!(i.startsWith("./")||i.startsWith("../")||i==="."||i==="..")&&!yn(i))return{resolved:null,isRelative:!1};let n=gn(t),r=zt(n,i);if(_i(r))return{resolved:r,isRelative:!0};let o=Af(r),s=Tf[o];if(s){let l=r.slice(0,-o.length);for(let c of s){let f=l+c;if(_i(f))return{resolved:f,isRelative:!0}}}for(let l of Cs){let c=r+l;if(_i(c))return{resolved:c,isRelative:!0}}if(mn(r))for(let l of Cs){let c=Ss(r,`index${l}`);if(_i(c))return{resolved:c,isRelative:!0}}return{resolved:null,isRelative:!0}}function xs(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 As(e,t){if(Object.hasOwn(e,t))return e[t]!==null;let i=Object.keys(e).filter((n)=>n.includes("*")&&xs(n,t)).sort((n,r)=>r.indexOf("*")-n.indexOf("*")||r.length-n.length)[0];return i!==void 0&&e[i]!==null}function ws(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 n=e.exports;if(!Object.keys(n).some((r)=>r.startsWith(".")))return i===".";return As(n,i)}function pn(e,t){let i=$s(e,t);return i!==".."&&!i.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!yn(i)}async function Ts(e){let t=await mi(zt(e.cwd,e.tsconfigPath||"tsconfig.json")),i=Object.entries(t?.paths??{});if(i.length===0)return Jt;let n=t?.baseUrl??t?.pathsBasePath??e.cwd,r=zt(e.cwd,e.root),o=new Map,s=new Set([...xf,"bun"]),l=(f)=>{let u=gn(f),a=[];while(!0){if(o.has(u)){let w=o.get(u);for(let C of a)o.set(C,w);return w}a.push(u);let m=Ss(u,"package.json");if(mn(m)){let w={...JSON.parse(ys(m,"utf8")),directory:gi(u)};for(let C of a)o.set(C,w);return w}let y=gn(u);if(y===u)return;u=y}},c=(f,u)=>{if(f.startsWith(".")||yn(f))return Jt(f,u);if(f.startsWith("node:")||f.startsWith("bun:")||s.has(f))return{resolved:null,isRelative:!1};let a=l(u),m=f.startsWith("@")?/^@[^/]+\/[^/]+/.exec(f)?.[0]:f.split("/")[0];if(a&&(ws(a,f)||As(a.imports??{},f)||m&&[a.dependencies,a.devDependencies,a.peerDependencies,a.optionalDependencies].some((W)=>Object.hasOwn(W??{},m))))return{resolved:null,isRelative:!1};let y=i.filter(([W])=>xs(W,f)).sort(([W],[B])=>{if(!W.includes("*"))return-1;if(!B.includes("*"))return 1;return B.indexOf("*")-W.indexOf("*")})[0];if(!y)return{resolved:null,isRelative:!1};let[w,C]=y,A=w.indexOf("*"),k=A===-1?"":f.slice(A,f.length-(w.length-A-1));for(let W of C){let B=zt(n,W.replace("*",k)),T=l(B);if(T&&ws(T,f)&&!T.private&&T.directory!==a?.directory)return{resolved:null,isRelative:!1};let D=Jt(B,u);if(!D.resolved)continue;let N=gi(D.resolved),F=e.outputStructure==="flat"||mn(r)&&pn(gi(r),N);if(!a||!pn(a.directory,N)||!F||l(N)?.directory!==a.directory||/\.d\.(?:ts|mts|cts)$/.test(N))throw Error(`Local alias ${JSON.stringify(f)} from ${u} resolves outside its emitted package source: ${N}`);return Y.debug(`Resolved local declaration alias ${f} from ${u} to ${N}`),{resolved:e.outputStructure==="flat"?D.resolved:zt(r,$s(gi(r),N)),isRelative:!0,isAlias:!0,suffix:B.match(/[?#].*$/)?.[0]??""}}throw Error(`Cannot resolve local alias ${JSON.stringify(f)} from ${u} using ${e.tsconfigPath||"tsconfig.json"} (${JSON.stringify(w)})`)};return c.isPackageLocal=(f,u)=>{let a=l(f);return!!a&&l(u)?.directory===a.directory&&pn(a.directory,gi(u))},c.cacheKey=(f)=>{let u=f.map((m)=>({file:m,references:Vi(ys(m,"utf8"),{includeImports:!0}).map((y)=>({specifier:y.specifier,resolution:c(y.specifier,m)}))})),a=[...new Set(o.values())].filter((m)=>m!==void 0).sort((m,y)=>m.directory.localeCompare(y.directory));return JSON.stringify({root:r,compilerOptions:t,packages:a,edges:u})},c}function Os(e,t=[]){let i=e.length,n="",r=0;while(r<i){let o=e.charCodeAt(r);if(o===34||o===39||o===96){let s=o,l=r;n+=e[r++];while(r<i){let c=e.charCodeAt(r),f=e[r++];if(n+=s===96&&c!==s?c===10||c===13?f:" ":f,c===92&&r<i){let u=e[r++];n+=s===96?u===`
6
+ `||u==="\r"?u:" ":u;continue}if(c===s)break}t.push({start:l,end:r});continue}if(o===47&&r+1<i){let s=e.charCodeAt(r+1);if(s===47){n+=" ",r+=2;while(r<i&&e.charCodeAt(r)!==10)n+=" ",r++;continue}if(s===42){n+=" ",r+=2;while(r<i&&!(e.charCodeAt(r)===42&&e.charCodeAt(r+1)===47))n+=e[r]===`
7
+ `||e[r]==="\r"?e[r]:" ",r++;if(r<i)n+=" ",r+=2;continue}if(ji(e,r)){let l=di(e,r);n+=e.slice(r,l).replace(/[^\r\n]/g," "),r=l;continue}}n+=e[r++]}return n}function Vi(e,t={}){let i=[],n=[],r=Os(e,n),o=(l)=>n.some((c)=>l>c.start&&l<c.end);bs.lastIndex=0;let s;while((s=bs.exec(r))!==null){if(o(s.index))continue;let l=!!s[1],c=s[3],f=s[0],u;if(f.includes("* as "))u="export-star-as";else if(f.includes("*"))u="export-star";else u="export-named";i.push({specifier:c,kind:u,isTypeOnly:l})}if(t.includeImports){vs.lastIndex=0;while((s=vs.exec(r))!==null){if(o(s.index))continue;i.push({specifier:s[3],kind:"import",isTypeOnly:!!s[1]})}}if(t.includeImports){Es.lastIndex=0;while((s=Es.exec(r))!==null)if(!o(s.index))i.push({specifier:s[2],kind:"import",isTypeOnly:!1})}return i}function Rs(e,t){let i=[],n=Os(e,i),r=/\b(?:from\s*|import\s*(?:\(\s*)?)(['"])([^'"]+)\1/g,o=[],s;while((s=r.exec(n))!==null){if(i.some((u)=>s.index>u.start&&s.index<u.end))continue;let c=s.index+s[0].lastIndexOf(`${s[1]}${s[2]}${s[1]}`)+1,f=t(s[2]);if(f!==s[2])o.push({start:c,end:c+s[2].length,value:f})}let l=e;for(let c of o.reverse())l=l.slice(0,c.start)+c.value+l.slice(c.end);return l}async function Cn(e,t={}){let i=new Set,n=new Map,r=[],o=[];for(let s of e){let l=zt(s);if(!i.has(l))i.add(l),o.push(l)}while(o.length>0){let s=o.shift(),l;try{l=await Ot(s)}catch{continue}let c=Vi(l,t);n.set(s,c);for(let f of c){let u=(t.resolveSpecifier??Jt)(f.specifier,s);if(!u.isRelative)continue;if(u.resolved){if(!i.has(u.resolved))i.add(u.resolved),o.push(u.resolved)}else r.push({from:s,specifier:f.specifier,isTypeOnly:f.isTypeOnly})}}return{reachable:i,reExports:n,unresolved:r}}var Cs,Tf,bs,Es,vs;var wn=de(()=>{Bi();cn();fn();dn();Cs=[".ts",".tsx",".mts",".cts",".vue",".stx",".js",".jsx",".mjs",".cjs",".d.ts",".d.mts",".d.cts"],Tf={".js":[".ts",".tsx",".d.ts"],".jsx":[".tsx",".ts",".d.ts"],".mjs":[".mts",".d.mts"],".cjs":[".cts",".d.cts"]};bs=/(?:^|[\n;{}])\s*export\s+(type\s+)?(?:\*(?:\s+as\s+\w+)?|\{[^}]*\})\s+from\s+(['"])([^'"]+)\2/g,Es=/\bimport\s*\(\s*(['"])([^'"]+)\1/g,vs=/(?:^|[\n;{}])\s*import\s+(type\s+)?(?:[^'";]+?\s+from\s+)?(['"])([^'"]+)\2/g});import{relative as Nt}from"path";function Of(e){let t=[],i=[],n=0,r=0,o=[],s=!1,l=0,c=e.length,f=(u)=>{let a=e.slice(n,u).trim();if(n=u,!a)return;if(Rf(a)){i.push(a);return}t.push({text:a,comments:i}),i=[]};while(l<c){let u=e[l];if(s){if(u==="\\"){l+=2;continue}if(u==="`"){s=!1,l++;continue}if(u==="$"&&e[l+1]==="{"){o.push(r),r++,s=!1,l+=2;continue}l++;continue}if(u==="/"&&e[l+1]==="*"){let a=e.indexOf("*/",l+2);l=a===-1?c:a+2;continue}if(u==="/"&&e[l+1]==="/"){let a=e.indexOf(`
8
+ `,l);l=a===-1?c:a;continue}if(u==="'"||u==='"'){l++;while(l<c&&e[l]!==u&&e[l]!==`
9
+ `){if(e[l]==="\\")l++;l++}l++;continue}if(u==="`"){s=!0,l++;continue}if(u==="("||u==="["||u==="{"){r++,l++;continue}if(u===")"||u==="]"||u==="}"){if(r--,o.length>0&&u==="}"&&r===o[o.length-1])o.pop(),s=!0;l++;continue}if(r===0&&u===";"){f(l+1),l++;continue}if(r===0&&u===`
10
+ `){let a=e[l+1];if(a!==void 0&&/[\w$@/]/.test(a))f(l+1);l++;continue}l++}return f(c),t}function Rf(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(`
11
+ `,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 bn(e){let t=[];for(let i of e.split(",")){let n=i.replace(/\/\*[\s\S]*?\*\//g,"").trim().replace(/^type\s+/,"");if(!n)continue;let r=n.match(/^([\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!r)continue;t.push({local:r[1],exported:r[2]??r[1]})}return t}function Pf(e){let t={named:[]},i=e.trim().replace(/^type\s+/,""),n=i.match(/\{([\s\S]*)\}/);if(n){for(let s of bn(n[1]))t.named.push({imported:s.local,local:s.exported});i=i.replace(n[0],"")}let r=i.match(/\*\s*as\s+([\w$]+)/);if(r)t.namespaceName=r[1],i=i.replace(r[0],"");let o=i.replace(/,/g,"").trim();if(o&&ks.test(o))t.defaultName=o;return t}function Mf(e,t){let i=e.replace(/^export\s+/,""),n=/^default\s+/.test(i);if(i=i.replace(/^default\s+/,""),n)i=i.replace(/^((?:declare\s+)?(?:abstract\s+)?(?:class|function\s*\*?|async\s+function\s*\*?))\s*(?=[(<{])/,(r,o)=>`${o.trimEnd()} ${t}`);if(/^(?:interface|type)\b/.test(i)||/^declare\b/.test(i))return i;return`declare ${i}`}function Df(e,t){let i={file:e,declarations:[],declared:new Set,imports:new Map,localExports:new Map,namedReExports:[],starReExports:[],namespaceReExports:[],verbatim:[],directives:[]},n=Of(t);for(let r of n){r.comments=r.comments.filter((c)=>{if(/^\/\/\/\s*</.test(c))return i.directives.push(...c.split(`
12
+ `).map((f)=>f.trim()).filter((f)=>f.startsWith("///"))),!1;return!0});let o=r.text.replace(/;\s*$/,"").trim(),s=o.match(/^import\s+(type\s+)?([\s\S]+?)\s+from\s+(['"])([^'"]+)\3/);if(s){let c=Pf(s[2]),f=s[4];if(c.defaultName)i.imports.set(c.defaultName,{specifier:f,imported:"default"});if(c.namespaceName)i.imports.set(c.namespaceName,{specifier:f,imported:"*"});for(let u of c.named)i.imports.set(u.local,{specifier:f,imported:u.imported});continue}if(/^import\s+['"]/.test(o)){i.verbatim.push(r);continue}if(s=o.match(/^export\s+(?:type\s+)?\*\s+as\s+([\w$]+)\s+from\s+(['"])([^'"]+)\2/),s){i.namespaceReExports.push({specifier:s[3],exported:s[1]});continue}if(s=o.match(/^export\s+(?:type\s+)?\*\s+from\s+(['"])([^'"]+)\1/),s){i.starReExports.push(s[2]);continue}if(s=o.match(/^export\s+(?:type\s+)?\{([\s\S]*)\}\s+from\s+(['"])([^'"]+)\2/),s){for(let c of bn(s[1]))i.namedReExports.push({specifier:s[3],imported:c.local,exported:c.exported});continue}if(s=o.match(/^export\s+(?:type\s+)?\{([\s\S]*)\}$/),s){for(let c of bn(s[1]))i.localExports.set(c.exported,c.local);continue}if(s=o.match(/^export\s+default\s+([\w$]+)$/),s&&ks.test(s[1])){i.localExports.set("default",s[1]);continue}if(/^export\s+as\s+namespace\b/.test(o)||/^(?:export\s+)?declare\s+(?:global\b|module\s+['"])/.test(o)){i.verbatim.push(r);continue}let l=o.match(kf);if(l){let c=!!l[1],f=l[4]??(c?"_default":null);if(f){if(i.declared.add(f),/^export\s/.test(o))i.localExports.set(c?"default":f,f);i.declarations.push({statement:r,name:f,emit:Mf(r.text,f)});continue}}i.declarations.push({statement:r,name:null,emit:r.text})}return i}function Ps(e,t){if(t.size===0)return e;let i="",n=0,r=e.length,o=`
13
+ `;while(n<r){let s=e[n];if(s==="/"&&e[n+1]==="*"){let l=e.indexOf("*/",n+2),c=l===-1?r:l+2;i+=e.slice(n,c),n=c;continue}if(s==="/"&&e[n+1]==="/"){let l=e.indexOf(`
14
+ `,n),c=l===-1?r:l;i+=e.slice(n,c),n=c;continue}if(s==="'"||s==='"'){let l=n+1;while(l<r&&e[l]!==s&&e[l]!==`
15
+ `){if(e[l]==="\\")l++;l++}i+=e.slice(n,l+1),n=l+1,o=s;continue}if(/[A-Z_$]/i.test(s)){let l=n+1;while(l<r&&/[\w$]/.test(e[l]))l++;let c=e.slice(n,l),f=t.get(c);if(f!==void 0&&o!=="."){let u=l;while(u<r&&(e[u]===" "||e[u]==="\t"))u++;let a=(e[u]===":"||e[u]==="?"&&e[u+1]===":")&&/[{;,(\n]/.test(o);i+=a?c:f}else i+=c;o="a",n=l;continue}if(i+=s,s===`
16
+ `||!/\s/.test(s))o=s;n++}return i}function Ms(e,t,i,n){let r=[],o=new Map,s=[e,...t.filter((L)=>L!==e)];for(let L of s){let U=i.get(L);if(U===void 0){r.push(`No declarations were generated for ${Nt(n.cwd,L)}; it is left out of the bundle`);continue}o.set(L,Df(L,U))}let l=(L,U)=>{if(!L.startsWith(".")&&!L.startsWith("/"))return null;let q=Jt(L,U).resolved;return q&&o.has(q)?q:null},c=(L)=>L.startsWith(".")||L.startsWith("/"),f=new Set,u=(L)=>{let U=L;for(let q=1;f.has(U);q++)U=`${L}_${q}`;return f.add(U),U},a=new Map;for(let[L,U]of o){let q=new Map;for(let Z of U.declared)q.set(Z,u(Z));a.set(L,q)}let m=new Map,y=(L,U,q)=>{let Z=`${L}\x00${U}`,J=m.get(Z);if(!J)J=u(q),m.set(Z,J);return J},w=new Map,C=new Map,A=new Set,k=(L,U,q)=>{let Z=l(U,L.file);if(Z){if(q==="*")return{kind:"namespace",file:Z};let J=B(Z).get(q);if(!J)r.push(`${Nt(n.cwd,L.file)}: '${q}' is not exported by '${U}'`);return J??null}if(c(U))return r.push(`${Nt(n.cwd,L.file)}: '${U}' is not part of the bundle`),null;return q==="*"?{kind:"external-namespace",source:U}:{kind:"external",source:U,imported:q}},W=(L,U)=>{if(L.declared.has(U))return{kind:"local",name:a.get(L.file).get(U)};let q=L.imports.get(U);if(q)return k(L,q.specifier,q.imported);return r.push(`${Nt(n.cwd,L.file)}: cannot resolve exported name '${U}'`),null};function B(L){let U=w.get(L);if(U)return U;let q=new Map,Z=o.get(L);if(!Z||A.has(L))return q;A.add(L);let J=new Set;for(let[te,se]of Z.localExports){let ne=W(Z,se);if(ne)q.set(te,ne)}for(let te of Z.namedReExports){let se=k(Z,te.specifier,te.imported);if(se)q.set(te.exported,se)}for(let te of Z.namespaceReExports){let se=k(Z,te.specifier,"*");if(se)q.set(te.exported,se)}for(let te of Z.starReExports){let se=l(te,L);if(se){for(let[ne,qr]of B(se))if(ne!=="default"&&!q.has(ne))q.set(ne,qr);for(let ne of C.get(se)??[])J.add(ne)}else if(c(te))r.push(`${Nt(n.cwd,L)}: '${te}' is not part of the bundle`);else J.add(te)}return A.delete(L),w.set(L,q),C.set(L,J),q}let T=new Map,D=[],N=(L,U)=>{switch(L.kind){case"local":return L.name;case"external":return y(L.source,L.imported,L.imported==="default"?U:L.imported);case"external-namespace":return y(L.source,"*",U);case"namespace":return F(L.file,U)}};function F(L,U){let q=T.get(L);if(q)return q;let Z=u(U);T.set(L,Z);let J=[];for(let[te,se]of B(L)){if(te==="default")continue;let ne=N(se,te);J.push(ne===te?te:`${ne} as ${te}`)}if(C.get(L)?.size)r.push(`${Nt(n.cwd,L)}: 'export * from' an external module cannot be expressed inside namespace '${Z}'`);return D.push(`declare namespace ${Z} {
17
17
  export { ${J.join(", ")} };
18
- }`),Z}let v=[],K=[],oe=new Set;for(let[F,U]of o){for(let J of U.directives)oe.add(J);let q=new Map;for(let[J,te]of l.get(F))if(J!==te)q.set(J,te);for(let[J,te]of U.imports){if(U.declared.has(J))continue;let se=k(U,te.specifier,te.imported);if(!se)continue;let re=I(se,J);if(re!==J)q.set(J,re)}let Z=[];for(let J of U.declarations){if(n.keepComments)Z.push(...J.statement.comments);let te=Rs(J.emit,q);if(!/[;}]$/.test(te))te+=";";Z.push(te)}for(let J of U.verbatim){if(n.keepComments)K.push(...J.comments);K.push(Rs(J.text,q))}if(Z.length>0)v.push(`// From: ${Nt(n.cwd,F)}
18
+ }`),Z}let E=[],K=[],oe=new Set;for(let[L,U]of o){for(let J of U.directives)oe.add(J);let q=new Map;for(let[J,te]of a.get(L))if(J!==te)q.set(J,te);for(let[J,te]of U.imports){if(U.declared.has(J))continue;let se=k(U,te.specifier,te.imported);if(!se)continue;let ne=N(se,J);if(ne!==J)q.set(J,ne)}let Z=[];for(let J of U.declarations){if(n.keepComments)Z.push(...J.statement.comments);let te=Ps(J.emit,q);if(!/[;}]$/.test(te))te+=";";Z.push(te)}for(let J of U.verbatim){if(n.keepComments)K.push(...J.comments);K.push(Ps(J.text,q))}if(Z.length>0)E.push(`// From: ${Nt(n.cwd,L)}
19
19
  ${Z.join(`
20
- `)}`)}let fe=W(e),z=[],ge=[];for(let[F,U]of fe){if(U.kind==="external"){ge.push(`export { ${U.imported===F?F:`${U.imported} as ${F}`} } from '${U.source}';`);continue}if(U.kind==="external-namespace"){ge.push(`export * as ${F} from '${U.source}';`);continue}let q=I(U,F==="default"?"_default":F);z.push(q===F?F:`${q} as ${F}`)}for(let F of C.get(e)??[])ge.push(`export * from '${F}';`);let De=new Map;for(let[F,U]of m){let[q,Z]=F.split("\x00"),J=De.get(q)??{named:[],defaults:[],namespaces:[]};if(De.set(q,J),Z==="*")J.namespaces.push(U);else if(Z==="default")J.defaults.push(U);else J.named.push(Z===U?U:`${Z} as ${U}`)}let ie=[];for(let[F,U]of[...De].sort(([q],[Z])=>q.localeCompare(Z))){for(let q of U.defaults)ie.push(`import ${q} from '${F}';`);for(let q of U.namespaces)ie.push(`import * as ${q} from '${F}';`);if(U.named.length>0)ie.push(`import { ${U.named.join(", ")} } from '${F}';`)}let le=[];if(oe.size>0)le.push([...oe].join(`
21
- `));if(le.push(`/**
20
+ `)}`)}let he=B(e),z=[],ge=[];for(let[L,U]of he){if(U.kind==="external"){ge.push(`export { ${U.imported===L?L:`${U.imported} as ${L}`} } from '${U.source}';`);continue}if(U.kind==="external-namespace"){ge.push(`export * as ${L} from '${U.source}';`);continue}let q=N(U,L==="default"?"_default":L);z.push(q===L?L:`${q} as ${L}`)}for(let L of C.get(e)??[])ge.push(`export * from '${L}';`);let De=new Map;for(let[L,U]of m){let[q,Z]=L.split("\x00"),J=De.get(q)??{named:[],defaults:[],namespaces:[]};if(De.set(q,J),Z==="*")J.namespaces.push(U);else if(Z==="default")J.defaults.push(U);else J.named.push(Z===U?U:`${Z} as ${U}`)}let re=[];for(let[L,U]of[...De].sort(([q],[Z])=>q.localeCompare(Z))){for(let q of U.defaults)re.push(`import ${q} from '${L}';`);for(let q of U.namespaces)re.push(`import * as ${q} from '${L}';`);if(U.named.length>0)re.push(`import { ${U.named.join(", ")} } from '${L}';`)}let ce=[];if(oe.size>0)ce.push([...oe].join(`
21
+ `));if(ce.push(`/**
22
22
  * Bundled TypeScript declarations
23
23
  * Generated from ${o.size} source files
24
- */`),ie.length>0)le.push(ie.join(`
25
- `));if(le.push(...v),D.length>0)le.push(D.join(`
26
- `));if(K.length>0)le.push(K.join(`
27
- `));let ee=[];if(z.length>0)ee.push(`export { ${z.join(", ")} };`);if(ee.push(...ge),ee.length===0)ee.push("export {};");return le.push(ee.join(`
28
- `)),{content:`${le.join(`
24
+ */`),re.length>0)ce.push(re.join(`
25
+ `));if(ce.push(...E),D.length>0)ce.push(D.join(`
26
+ `));if(K.length>0)ce.push(K.join(`
27
+ `));let ee=[];if(z.length>0)ee.push(`export { ${z.join(", ")} };`);if(ee.push(...ge),ee.length===0)ee.push("export {};");return ce.push(ee.join(`
28
+ `)),{content:`${ce.join(`
29
29
 
30
30
  `)}
31
- `,files:[...o.keys()],exportCount:fe.size,warnings:r}}var Ps,Pf;var Ms=ue(()=>{wn();Ps=/^[A-Z_$][\w$]*$/i;Pf=/^(?: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$]+)?/});function yi(e){if(Df)return Bun.hash(e);let t=0;for(let i=0;i<e.length;i++){let n=e.charCodeAt(i);t=(t<<5)-t+n,t=t&t}return t}var Df;var vn=ue(()=>{Df=typeof globalThis.Bun?.hash==="function"});import{existsSync as Ci,mkdirSync as If,readFileSync as Sn,renameSync as Nf,rmSync as Ds,statSync as Is,writeFileSync as Ns}from"fs";import{join as Fs,relative as Ui,resolve as Ff}from"path";class $n{cacheDir;manifestPath;manifest=null;configHash;constructor(e,t){this.cacheDir=Ff(e.cwd,Ki),this.manifestPath=Fs(this.cacheDir,Lf),this.configHash=this.hashConfig(e,t)}hashConfig(e,t){let i={resolutionContext:t,keepComments:e.keepComments,importOrder:e.importOrder,outputStructure:e.outputStructure,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((n)=>({pattern:typeof n.pattern==="string"?{kind:"string",value:n.pattern}:{kind:"regex",source:n.pattern.source,flags:n.pattern.flags},replacement:n.replacement,global:n.global,priority:n.priority,hasCondition:Boolean(n.condition)}))}:void 0,lineEnding:e.lineEnding,normalizeOutput:e.normalizeOutput,declarationOrder:e.declarationOrder,plugins:e.plugins?.map((n)=>({name:n.name,version:n.version,cacheKey:n.cacheKey}))};return String(yi(JSON.stringify(i)))}hashString(e){return String(yi(e))}load(){try{if(!Ci(this.manifestPath))return!1;let e=Sn(this.manifestPath,"utf-8"),t=JSON.parse(e);if(t.version!==bn)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:bn,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};if(this.manifest.updatedAt=Date.now(),!Ci(this.cacheDir))If(this.cacheDir,{recursive:!0});let e=`${this.manifestPath}.${process.pid}.tmp`;try{Ns(e,JSON.stringify(this.manifest,null,2)),Nf(e,this.manifestPath)}finally{if(Ci(e))Ds(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=Ui(t,e),n=this.manifest.entries[i];if(!n)return null;if(typeof n.dtsContent!=="string"||typeof n.dtsHash!=="string"||n.configHash!==this.configHash||this.hashString(n.dtsContent)!==n.dtsHash)return null;try{let r=Is(e),{mtimeMs:o,ctimeMs:s}=r;if(r.size!==n.sourceSize)return null;if(o!==n.sourceMtime||s!==n.sourceCtime){let a=Sn(e,"utf-8");if(this.hashString(a)!==n.sourceHash)return null;n.sourceMtime=o,n.sourceCtime=s}return n.dtsContent}catch{return null}}update(e,t,i,n){if(!this.manifest)this.manifest={version:bn,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};let r=Ui(n,e),o,s,a;try{let c=Is(e);o=c.mtimeMs,s=c.ctimeMs,a=c.size}catch{o=Date.now(),s=o,a=Buffer.byteLength(t)}this.manifest.entries[r]={sourcePath:r,sourceHash:this.hashString(t),sourceMtime:o,sourceCtime:s,sourceSize:a,dtsContent:i,dtsHash:this.hashString(i),generatedAt:Date.now(),configHash:this.configHash}}remove(e,t){if(!this.manifest)return;let i=Ui(t,e);delete this.manifest.entries[i]}clear(){this.manifest=null;try{if(Ci(this.manifestPath))Ds(this.cacheDir,{recursive:!0,force:!0})}catch{}}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,n=new Set(Array.from(e).map((r)=>Ui(t,r)));for(let r of Object.keys(this.manifest.entries))if(!n.has(r))delete this.manifest.entries[r],i++;return i}}function Ls(e){let t=Fs(e,".gitignore");try{let i="";if(Ci(t))i=Sn(t,"utf-8");if(!i.split(/\r?\n/).some((n)=>n.trim()===Ki||n.trim()===`${Ki}/`)){let n=i.trimEnd(),r=`${n}${n?`
31
+ `,files:[...o.keys()],exportCount:he.size,warnings:r}}var ks,kf;var Ds=de(()=>{wn();ks=/^[A-Z_$][\w$]*$/i;kf=/^(?: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$]+)?/});function yi(e){if(If)return Bun.hash(e);let t=0;for(let i=0;i<e.length;i++){let n=e.charCodeAt(i);t=(t<<5)-t+n,t=t&t}return t}var If;var En=de(()=>{If=typeof globalThis.Bun?.hash==="function"});import{existsSync as Ci,mkdirSync as Nf,readFileSync as Sn,renameSync as Ff,rmSync as Is,statSync as Ns,writeFileSync as Fs}from"fs";import{join as Ls,relative as Ui,resolve as Lf}from"path";class $n{cacheDir;manifestPath;manifest=null;configHash;constructor(e,t){this.cacheDir=Lf(e.cwd,Ki),this.manifestPath=Ls(this.cacheDir,Wf),this.configHash=this.hashConfig(e,t)}hashConfig(e,t){let i={resolutionContext:t,keepComments:e.keepComments,importOrder:e.importOrder,outputStructure:e.outputStructure,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((n)=>({pattern:typeof n.pattern==="string"?{kind:"string",value:n.pattern}:{kind:"regex",source:n.pattern.source,flags:n.pattern.flags},replacement:n.replacement,global:n.global,priority:n.priority,hasCondition:Boolean(n.condition)}))}:void 0,lineEnding:e.lineEnding,normalizeOutput:e.normalizeOutput,declarationOrder:e.declarationOrder,plugins:e.plugins?.map((n)=>({name:n.name,version:n.version,cacheKey:n.cacheKey}))};return String(yi(JSON.stringify(i)))}hashString(e){return String(yi(e))}load(){try{if(!Ci(this.manifestPath))return!1;let e=Sn(this.manifestPath,"utf-8"),t=JSON.parse(e);if(t.version!==vn)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:vn,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};if(this.manifest.updatedAt=Date.now(),!Ci(this.cacheDir))Nf(this.cacheDir,{recursive:!0});let e=`${this.manifestPath}.${process.pid}.tmp`;try{Fs(e,JSON.stringify(this.manifest,null,2)),Ff(e,this.manifestPath)}finally{if(Ci(e))Is(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=Ui(t,e),n=this.manifest.entries[i];if(!n)return null;if(typeof n.dtsContent!=="string"||typeof n.dtsHash!=="string"||n.configHash!==this.configHash||this.hashString(n.dtsContent)!==n.dtsHash)return null;try{let r=Ns(e),{mtimeMs:o,ctimeMs:s}=r;if(r.size!==n.sourceSize)return null;if(o!==n.sourceMtime||s!==n.sourceCtime){let l=Sn(e,"utf-8");if(this.hashString(l)!==n.sourceHash)return null;n.sourceMtime=o,n.sourceCtime=s}return n.dtsContent}catch{return null}}update(e,t,i,n){if(!this.manifest)this.manifest={version:vn,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};let r=Ui(n,e),o,s,l;try{let c=Ns(e);o=c.mtimeMs,s=c.ctimeMs,l=c.size}catch{o=Date.now(),s=o,l=Buffer.byteLength(t)}this.manifest.entries[r]={sourcePath:r,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=Ui(t,e);delete this.manifest.entries[i]}clear(){this.manifest=null;try{if(Ci(this.manifestPath))Is(this.cacheDir,{recursive:!0,force:!0})}catch{}}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,n=new Set(Array.from(e).map((r)=>Ui(t,r)));for(let r of Object.keys(this.manifest.entries))if(!n.has(r))delete this.manifest.entries[r],i++;return i}}function Ws(e){let t=Ls(e,".gitignore");try{let i="";if(Ci(t))i=Sn(t,"utf-8");if(!i.split(/\r?\n/).some((n)=>n.trim()===Ki||n.trim()===`${Ki}/`)){let n=i.trimEnd(),r=`${n}${n?`
32
32
 
33
33
  `:""}# dtsx cache
34
34
  ${Ki}/
35
- `;Ns(t,r)}}catch{}}var bn=3,Ki=".dtsx-cache",Lf="manifest.json";var Ws=ue(()=>{vn()});function Bs(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 Gs=()=>{};import Wf from"process";import{existsSync as js,statSync as _s}from"fs";import{existsSync as Bf,mkdirSync as mg,readdirSync as gg,readFileSync as Gf,writeFileSync as yg}from"fs";import{homedir as qt}from"os";import{dirname as Eg,resolve as nt}from"path";import Ar from"process";import{existsSync as Vs,statSync as Us}from"fs";import{existsSync as Un,mkdirSync as jf,readdirSync as _f,writeFileSync as Vf}from"fs";import{homedir as Yt}from"os";import{dirname as Ks,resolve as qe}from"path";import Ft from"process";import{join as Uf,relative as Kf,resolve as Hs}from"path";import ur from"process";import{existsSync as Ta,mkdirSync as Pg,readdirSync as kg,writeFileSync as Mg}from"fs";import{homedir as An}from"os";import{dirname as Ng,resolve as Je}from"path";import Ei from"process";import{join as Hf,relative as zf,resolve as zs}from"path";import hr from"process";import{existsSync as Oa,mkdirSync as Gg,readdirSync as jg,writeFileSync as _g}from"fs";import{dirname as Ug,resolve as dr}from"path";import Kn from"process";import{Buffer as Rt}from"buffer";import{createCipheriv as Jf,createDecipheriv as qf,randomBytes as xn}from"crypto";import{closeSync as Tn,createReadStream as Js,createWriteStream as Yf,existsSync as On,fsyncSync as qs,openSync as Ys,writeFileSync as Zf}from"fs";import{access as Xf,constants as Zs,mkdir as Qf,readdir as Hi,rename as Xs,stat as Zt,unlink as zi,writeFile as Rn}from"fs/promises";import{join as Xt}from"path";import Ve from"process";import{pipeline as eu}from"stream/promises";import{createGzip as Qs}from"zlib";import Qt from"process";import wt from"process";import{Buffer as gt}from"buffer";import{createCipheriv as tu,createDecipheriv as iu,randomBytes as Pn}from"crypto";import{closeSync as kn,createReadStream as ea,createWriteStream as ru,existsSync as Ji,fsyncSync as ta,openSync as ia,writeFileSync as nu}from"fs";import{access as ou,constants as ra,mkdir as su,readdir as qi,rename as na,stat as ei,unlink as Yi,writeFile as Mn}from"fs/promises";import{isAbsolute as au,join as ti,resolve as lu}from"path";import ye from"process";import{pipeline as cu}from"stream/promises";import{createGzip as oa}from"zlib";import ii from"process";import Et from"process";import Zi from"process";import{existsSync as Xi}from"fs";import{resolve as Dn}from"path";import{existsSync as fu}from"fs";import{existsSync as uu,readdirSync as hu}from"fs";import{extname as In,resolve as sa}from"path";import du from"process";import{join as pu,relative as mu,resolve as aa}from"path";import pr from"process";import{Buffer as yt}from"buffer";import{createCipheriv as gu,createDecipheriv as yu,randomBytes as Nn}from"crypto";import{closeSync as Fn,createReadStream as la,createWriteStream as Cu,existsSync as Qi,fsyncSync as ca,openSync as fa,writeFileSync as wu}from"fs";import{access as Eu,constants as ua,mkdir as vu,readdir as er,rename as ha,stat as ri,unlink as tr,writeFile as Ln}from"fs/promises";import{isAbsolute as bu,join as ni,resolve as Su}from"path";import Ce from"process";import{pipeline as $u}from"stream/promises";import{createGzip as da}from"zlib";import oi from"process";import vt from"process";import ir from"process";import{existsSync as rr}from"fs";import{resolve as Wn}from"path";import{existsSync as Au}from"fs";class Ra{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],[,n])=>i.timestamp.getTime()-n.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,n){if(!this.options.enabled)return;let r=this.generateKey(e,i),o=n??this.options.ttl,s=this.estimateSize(t);this.cache.set(r,{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),n=this.cache.get(i);if(!n){this.totalMisses++;return}if(this.isExpired(n)){this.cache.delete(i),this.totalMisses++;return}return n.hits++,this.totalHits++,n.value}isFileModified(e,t){try{if(!js(e))return!0;return _s(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,n){try{let r=js(i)?_s(i):null,o=r?r.mtime:new Date;this.set(e,{value:t,fileTimestamp:o},i,n)}catch{this.set(e,t,i,n)}}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((n,r)=>n+r.size,0),i=e.map((n)=>n.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 n=i;this.cache.set(t,{value:n.value,timestamp:new Date(n.timestamp),ttl:n.ttl,hits:n.hits,size:n.size})}}}class Pa{metrics=[];maxMetrics=1000;async track(e,t,i={}){let n=performance.now(),r=new Date;try{let o=await t(),s=performance.now()-n;return this.recordMetric({operation:e,duration:s,timestamp:r,...i}),o}catch(o){let s=performance.now()-n;throw this.recordMetric({operation:`${e}:error`,duration:s,timestamp:r,...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((r)=>r.operation===e):this.metrics;if(t.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let i=t.map((r)=>r.duration),n=i.reduce((r,o)=>r+o,0);return{count:t.length,averageDuration:n/t.length,minDuration:Math.min(...i),maxDuration:Math.max(...i),totalDuration:n,recentMetrics:t.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((t)=>t.duration>e)}}function Ou(e,t){this[e]=Tu.bind(null,t)}class ro{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],[,n])=>i.timestamp.getTime()-n.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,n){if(!this.options.enabled)return;let r=this.generateKey(e,i),o=n??this.options.ttl,s=this.estimateSize(t);this.cache.set(r,{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),n=this.cache.get(i);if(!n){this.totalMisses++;return}if(this.isExpired(n)){this.cache.delete(i),this.totalMisses++;return}return n.hits++,this.totalHits++,n.value}isFileModified(e,t){try{if(!Vs(e))return!0;return Us(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,n){try{let r=Vs(i)?Us(i):null,o=r?r.mtime:new Date;this.set(e,{value:t,fileTimestamp:o},i,n)}catch{this.set(e,t,i,n)}}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((n,r)=>n+r.size,0),i=e.map((n)=>n.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 n=i;this.cache.set(t,{value:n.value,timestamp:new Date(n.timestamp),ttl:n.ttl,hits:n.hits,size:n.size})}}}class no{metrics=[];maxMetrics=1000;async track(e,t,i={}){let n=performance.now(),r=new Date;try{let o=await t(),s=performance.now()-n;return this.recordMetric({operation:e,duration:s,timestamp:r,...i}),o}catch(o){let s=performance.now()-n;throw this.recordMetric({operation:`${e}:error`,duration:s,timestamp:r,...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((r)=>r.operation===e):this.metrics;if(t.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let i=t.map((r)=>r.duration),n=i.reduce((r,o)=>r+o,0);return{count:t.length,averageDuration:n/t.length,minDuration:Math.min(...i),maxDuration:Math.max(...i),totalDuration:n,recentMetrics:t.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((t)=>t.duration>e)}}function ku(e,t={}){let i=Object.keys(t).sort().map((n)=>`${n}:${t[n]}`).join("|");return i?`${e}:${i}`:e}function Mu(e,t){try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}}function Du(e){return e.getStats().size*2}function oo(e,t){if(Array.isArray(t)&&Array.isArray(e)&&t.length===2&&e.length===2&&Oe(t[0])&&"id"in t[0]&&t[0].id===3&&Oe(t[1])&&"id"in t[1]&&t[1].id===4)return t;if(Oe(t)&&Oe(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(Oe(e)&&"arr"in e&&Array.isArray(e.arr)&&Oe(t)&&"arr"in t&&Array.isArray(t.arr))return t;if(t.length>0&&e.length>0&&Oe(t[0])&&Oe(e[0])){let n=[...t];for(let r of e)if(Oe(r)&&"name"in r){if(!n.find((o)=>Oe(o)&&("name"in o)&&o.name===r.name))n.push(r)}else if(Oe(r)&&"path"in r){if(!n.find((o)=>Oe(o)&&("path"in o)&&o.path===r.path))n.push(r)}else if(!n.some((o)=>gr(o,r)))n.push(r);return n}if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let r of e)if(!n.includes(r))n.push(r);return n}return t}if(!Oe(t)||!Oe(e))return t;let i={...e};for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)){let r=t[n];if(r===null||r===void 0)continue;else if(Oe(r)&&Oe(i[n]))i[n]=oo(i[n],r);else if(Array.isArray(r)&&Array.isArray(i[n]))if(r.length>0&&i[n].length>0&&Oe(r[0])&&Oe(i[n][0])){let o=[...r];for(let s of i[n])if(Oe(s)&&"name"in s){if(!o.find((a)=>Oe(a)&&("name"in a)&&a.name===s.name))o.push(s)}else if(Oe(s)&&"path"in s){if(!o.find((a)=>Oe(a)&&("path"in a)&&a.path===s.path))o.push(s)}else if(!o.some((a)=>gr(a,s)))o.push(s);i[n]=o}else if(r.every((o)=>typeof o==="string")&&i[n].every((o)=>typeof o==="string")){let o=[...r];for(let s of i[n])if(!o.includes(s))o.push(s);i[n]=o}else i[n]=r;else i[n]=r}return i}function gr(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(!gr(e[i],t[i]))return!1;return!0}if(Oe(e)&&Oe(t)){let i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return!1;for(let r of i){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!gr(e[r],t[r]))return!1}return!0}return!1}function Oe(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function Iu(e,t){if(!Oa(e))return null;try{let i=await import(e),n=i.default||i;if(typeof n!=="object"||n===null||Array.isArray(n))return null;try{return oo(t,n)}catch{return null}}catch{return null}}async function Nu({name:e="",cwd:t,defaultConfig:i}){let n=t||Kn.cwd(),r=[".ts",".js",".mjs",".cjs",".json"],o=[`${e}.config`,`.${e}.config`,e,`.${e}`];for(let s of o)for(let a of r){let c=dr(n,`${s}${a}`),f=await Iu(c,i);if(f!==null)return f}try{let s=dr(n,"package.json");if(Oa(s)){let a=(await import(s))[e];if(a&&typeof a==="object"&&!Array.isArray(a))try{return oo(i,a)}catch{}}}catch{}return i}function Fu(e,t={}){let i=hr.cwd();while(i.includes("storage"))i=zs(i,"..");let n=zs(i,e||"");if(t?.relative)return zf(hr.cwd(),n);return n}async function Lu(){try{let e=await Nu({name:"clarity",defaultConfig:ar,cwd:hr.cwd(),endpoint:"",headers:{}});return{...ar,...e}}catch{return ar}}function Re(){if(wt.env.NODE_ENV==="test"||wt.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Wu(){if(wt.env.NODE_ENV==="test"||wt.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof wt<"u"){let e=wt.type;if(e==="renderer"||e==="worker")return!1;return!!(wt.versions&&(wt.versions.node||wt.versions.bun))}return!1}class Ma{async format(e){let t=await Wu(),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:Qt.pid,hostname:t(),environment:Qt.env.NODE_ENV||"development",platform:Qt.platform,version:Qt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:Qt.env.NODE_ENV||Qt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class yr{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={...zn},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new Ma,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??Ve.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let i={...t},n=t.timestamp!==void 0;if(n)delete i.timestamp;if(this.config={...this.config,...i,timestamp:n||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let r=this.generateKeyId(),o=this.generateKey();this.currentKeyId=r,this.keys.set(r,o),this.encryptionKeys.set(r,{key:o,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...lr,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...lr};return{...lr,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:zn.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},i={...t,...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==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 n,r=0,o=3,s=1000;while(r<o)try{try{try{await Xf(this.config.logDirectory,Zs.F_OK|Zs.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await Qf(this.config.logDirectory,{recursive:!0,mode:493});else if(c.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw c;else throw c}}catch(c){throw console.error("Debug: [writeToFile] Failed to create log directory:",c),c}let a=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:Rt.from(e);try{if(!On(this.currentLogFile))await Rn(this.currentLogFile,"",{mode:420});if(n=Ys(this.currentLogFile,"a",420),Zf(n,a,{flag:"a"}),qs(n),n!==void 0)Tn(n),n=void 0;if((await Zt(this.currentLogFile)).size===0){if(await Rn(this.currentLogFile,a,{flag:"w",mode:420}),(await Zt(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(c){let f=c;if(f.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(f.code)){if(r<o-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${r+1}/${o}:`,u);let l=s*2**r;await new Promise((m)=>setTimeout(m,l)),r++;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(n!==void 0)try{Tn(n)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(a){if(r===o-1){let f=a,u=typeof f.message==="string"?f.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",u),a}r++;let c=s*2**(r-1);await new Promise((f)=>setTimeout(f,c))}})();this.pendingOperations.push(t);let i=this.pendingOperations.length-1;try{await t}catch(n){throw console.error("Debug: [writeToFile] Error in operation:",n),n}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 Xt(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 Xt(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return Xt(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(Re())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((n)=>{console.error("Error rotating keys:",n)})},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 n=Array.from(this.encryptionKeys.entries()).sort(([,s],[,a])=>a.createdAt.getTime()-s.createdAt.getTime()),r=typeof e.maxKeys==="number"?e.maxKeys:1,o=Math.max(1,r);if(n.length>o)for(let[s]of n.slice(o))this.encryptionKeys.delete(s),this.keys.delete(s)}generateKeyId(){return xn(16).toString("hex")}generateKey(){return xn(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=xn(16),n=Jf("aes-256-gcm",t,i),r=Rt.concat([n.update(e,"utf8"),n.final()]),o=n.getAuthTag();return{encrypted:Rt.concat([i,r,o]),iv:i}}async compressData(e){return new Promise((t,i)=>{let n=Qs(),r=[];n.on("data",(o)=>r.push(o)),n.on("end",()=>t(Rt.from(Rt.concat(r)))),n.on("error",i),n.write(e),n.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(Re())return;let e=await Zt(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,n=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let r=await Hi(this.config.logDirectory),o=r.filter((c)=>c.startsWith(this.name)&&/\.log\.\d+$/.test(c)).sort((c,f)=>{let u=Number.parseInt(c.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,a=`${i}.${s}`;if(await Zt(i).catch(()=>null))try{if(await Xs(i,a),t.compress)try{let c=`${a}.gz`;await this.compressLogFile(a,c),await zi(a)}catch(c){console.error("Error compressing rotated file:",c)}if(o.length===0&&!r.some((c)=>c.endsWith(".log.1")))try{let c=`${i}.1`;await Rn(c,"")}catch(c){console.error("Error creating backup file:",c)}}catch(c){console.error(`Error during rotation: ${c instanceof Error?c.message:String(c)}`)}}else{let r=new Date().toISOString().replace(/[:.]/g,"-"),o=i.replace(/\.log$/,`-${r}.log`);if(await Zt(i).catch(()=>null))await Xs(i,o)}if(this.currentLogFile=n,t.maxFiles){let r=(await Hi(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,s)=>s.localeCompare(o));for(let o of r.slice(t.maxFiles))await zi(Xt(this.config.logDirectory,o))}}}async compressLogFile(e,t){let i=Js(e),n=Yf(t),r=Qs();await eu(i,r,n)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let i of this.logBuffer){let n=await this.formatter.format(i);await this.writeToFile(n),console.log(n)}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()})),On(this.currentLogFile))try{let e=Ys(this.currentLogFile,"r+");qs(e),Tn(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(!Re()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await Hi(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await zi(Xt(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?Se.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}formatConsoleMessage(e){let{timestamp:t,icon:i="",tag:n="",message:r,level:o,showTimestamp:s=!0}=e,a=(y)=>y.replace(this.ANSI_PATTERN,"");if(!this.fancy){let y=[];if(s)y.push(t);if(o==="warning")y.push("WARN");else if(o==="error")y.push("ERROR");else if(i)y.push(i.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(n)y.push(n.replace(/[[\]]/g,""));return y.push(r),y.join(" ")}let c=Ve.stdout.columns||120,f="";if(o==="warning"||o==="error")f=`${i} ${r}`;else if(o==="info"||o==="success")f=`${i} ${n} ${r}`;else f=`${i} ${n} ${Se.cyan(r)}`;if(!s)return f.trim();let u=a(f).trim().length,l=a(t).length,m=Math.max(1,c-2-u-l);return`${f.trim()}${" ".repeat(m)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(o,s)=>{let a=Number.parseInt(s,10);return a<t[0].length?String(t[0][a]):o});let i=/%([sdijfo%])/g,n=0,r=e.replace(i,(o,s)=>{if(s==="%")return"%";if(n>=t.length)return o;let a=t[n++];switch(s){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 o}});if(n<t.length)r+=` ${t.slice(n).map((o)=>typeof o==="object"?JSON.stringify(o,null,2):String(o)).join(" ")}`;return r}async log(e,t,...i){let n=new Date,r=this.formatConsoleTimestamp(n),o=this.formatFileTimestamp(n),s,a;if(t instanceof Error)s=t.message,a=t.stack;else s=this.formatMessage(t,i);if(this.fancy&&!Re()){let f=_a[e],u=this.options.showTags!==!1&&this.name?Se.gray(this.formatTag(this.name)):"",l;switch(e){case"debug":l=this.formatConsoleMessage({timestamp:r,icon:f,tag:u,message:Se.gray(s),level:e}),console.error(l);break;case"info":l=this.formatConsoleMessage({timestamp:r,icon:f,tag:u,message:s,level:e}),console.error(l);break;case"success":l=this.formatConsoleMessage({timestamp:r,icon:f,tag:u,message:Se.green(s),level:e}),console.error(l);break;case"warning":l=this.formatConsoleMessage({timestamp:r,icon:f,tag:u,message:s,level:e}),console.warn(l);break;case"error":if(l=this.formatConsoleMessage({timestamp:r,icon:f,tag:u,message:s,level:e}),console.error(l),a){let m=a.split(`
36
- `);for(let y of m)if(y.trim()&&!y.includes(s))console.error(this.formatConsoleMessage({timestamp:r,message:Se.gray(` ${y}`),level:e,showTimestamp:!1}))}break}}else if(!Re()){if(console.error(`${o} ${this.environment}.${e.toUpperCase()}: ${s}`),a)console.error(a)}if(!this.shouldLog(e))return;let c=`${o} ${this.environment}.${e.toUpperCase()}: ${s}
37
- `;if(a)c+=`${a}
38
- `;c=c.replace(this.ANSI_PATTERN,""),await this.writeToFile(c)}time(e){let t=performance.now();if(this.fancy&&!Re()){let i=this.options.showTags!==!1&&this.name?Se.gray(this.formatTag(this.name)):"",n=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:n,icon:Se.blue("\u25D0"),tag:i,message:`${Se.cyan(e)}...`}))}return async(i)=>{if(!this.enabled)return;let n=performance.now(),r=Math.round(n-t),o=`${e} completed in ${r}ms`,s=new Date,a=this.formatConsoleTimestamp(s),c=`${this.formatFileTimestamp(s)} ${this.environment}.INFO: ${o}`;if(i)c+=` ${JSON.stringify(i)}`;if(c+=`
39
- `,c=c.replace(this.ANSI_PATTERN,""),this.fancy&&!Re()){let f=this.options.showTags!==!1&&this.name?Se.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:a,icon:Se.green("\u2713"),tag:f,message:`${o}${i?` ${JSON.stringify(i)}`:""}`}))}else if(!Re())console.error(c.trim());await this.writeToFile(c)}}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 yr(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(Re())throw Error("createReadStream is not supported in browser environments");if(!On(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return Js(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 n=Rt.isBuffer(e)?e:Rt.from(e,"base64"),r=n.slice(0,16),o=n.slice(-16),s=n.slice(16,-16),a=qf("aes-256-gcm",i,r);return a.setAuthTag(o),Rt.concat([a.update(s),a.final()]).toString("utf8")}catch(n){throw Error(`Decryption failed: ${n instanceof Error?n.message:String(n)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return Re()}isServerMode(){return!Re()}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),n=this.formatFileTimestamp(t);if(this.fancy&&!Re()){let o=e.split(`
40
- `),s=Math.max(...o.map((u)=>u.length))+2,a=`\u250C${"\u2500".repeat(s)}\u2510`,c=`\u2514${"\u2500".repeat(s)}\u2518`,f=o.map((u)=>{let l=" ".repeat(s-u.length-2);return`\u2502 ${u}${l} \u2502`});if(this.options.showTags!==!1&&this.name)console.error(this.formatConsoleMessage({timestamp:i,message:Se.gray(this.formatTag(this.name)),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:i,message:Se.cyan(a)})),f.forEach((u)=>console.error(this.formatConsoleMessage({timestamp:i,message:Se.cyan(u),showTimestamp:!1}))),console.error(this.formatConsoleMessage({timestamp:i,message:Se.cyan(c),showTimestamp:!1}))}else if(!Re())console.error(`${n} ${this.environment}.INFO: [BOX] ${e}`);let r=`${n} ${this.environment}.INFO: [BOX] ${e}
41
- `.replace(this.ANSI_PATTERN,"");await this.writeToFile(r)}async prompt(e){if(Re())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${Se.cyan("?")} ${e} (y/n) `);let i=(n)=>{let r=n.toString().trim().toLowerCase();Ve.stdin.removeListener("data",i);try{if(typeof Ve.stdin.setRawMode==="function")Ve.stdin.setRawMode(!1)}catch{}Ve.stdin.pause(),console.error(""),t(r==="y"||r==="yes")};try{if(typeof Ve.stdin.setRawMode==="function")Ve.stdin.setRawMode(!0)}catch{}Ve.stdin.resume(),Ve.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 r=/%([sdijfo%])/g,o=0;if(i=e.replace(r,(s,a)=>{if(a==="%")return"%";if(o>=t.length)return s;let c=t[o++];switch(a){case"s":return String(c);case"d":case"i":return Number(c).toString();case"j":case"o":return JSON.stringify(c,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&&!Re()){let r=this.options.showTags!==!1&&this.name?Se.gray(this.formatTag(this.name)):"",o=Se.blue("\u25D0");console.error(`${o} ${r} ${Se.cyan(i)}`)}let n=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${i}
42
- `.replace(this.ANSI_PATTERN,"");await this.writeToFile(n)}progress(e,t=""){if(!this.enabled||!this.fancy||Re()||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:(n,r)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||Re())return;if(this.activeProgressBar.current=Math.max(0,Math.min(e,n)),r!==void 0)this.activeProgressBar.message=r;let o=this.activeProgressBar.current===this.activeProgressBar.total;this.renderProgressBar(this.activeProgressBar,o)},finish:(n)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||Re())return;if(this.activeProgressBar.current=this.activeProgressBar.total,n!==void 0)this.activeProgressBar.message=n;this.renderProgressBar(this.activeProgressBar,!0),this.finishProgressBar(this.activeProgressBar)},interrupt:(n,r="info")=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||Re())return;Ve.stdout.write(`${"\r".padEnd(Ve.stdout.columns||80)}\r`),this.log(r,n),setTimeout(()=>{if(this.activeProgressBar)this.renderProgressBar(this.activeProgressBar)},50)}}}renderProgressBar(e,t=!1){if(!this.enabled||!this.fancy||Re()||!Ve.stdout.isTTY)return;let i=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),n=Math.round(e.barLength*i/100),r=e.barLength-n,o=Se.green("\u2501".repeat(n)),s=Se.gray("\u2501".repeat(r)),a=`[${o}${s}]`,c=`${i}%`.padStart(4),f=e.message?` ${e.message}`:"",u=t||i===100?Se.green("\u2713"):Se.blue("\u25B6"),l=this.options.showTags!==!1&&this.name?` ${Se.gray(this.formatTag(this.name))}`:"",m=`\r${u}${l} ${a} ${c}${f}`,y=Ve.stdout.columns||80,w=" ".repeat(Math.max(0,y-m.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${m}${w}`,Ve.stdout.write(e.lastRenderedLine),t)Ve.stdout.write(`
43
- `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||Re()||!Ve.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(Re()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await Hi(this.config.logDirectory),i=[];for(let n of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(n):n.startsWith(this.name))||!n.endsWith(".log"))continue;let r=Xt(this.config.logDirectory,n);if(e.before)try{if((await Zt(r)).mtime>=e.before)continue}catch(o){console.error(`Failed to get stats for file ${r}:`,o);continue}i.push(r)}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 n of i)try{await zi(n),console.warn(`Deleted log file: ${n}`)}catch(r){console.error(`Failed to delete log file ${n}:`,r)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}function sr(e,t){if(Array.isArray(t)&&Array.isArray(e)&&t.length===2&&e.length===2&&we(t[0])&&"id"in t[0]&&t[0].id===3&&we(t[1])&&"id"in t[1]&&t[1].id===4)return t;if(we(t)&&we(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(we(e)&&"arr"in e&&Array.isArray(e.arr)&&we(t)&&"arr"in t&&Array.isArray(t.arr))return t;if(t.length>0&&e.length>0&&we(t[0])&&we(e[0])){let n=[...t];for(let r of e)if(we(r)&&"name"in r){if(!n.find((o)=>we(o)&&("name"in o)&&o.name===r.name))n.push(r)}else if(we(r)&&"path"in r){if(!n.find((o)=>we(o)&&("path"in o)&&o.path===r.path))n.push(r)}else if(!n.some((o)=>Cr(o,r)))n.push(r);return n}if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let r of e)if(!n.includes(r))n.push(r);return n}return t}if(!we(t)||!we(e))return t;let i={...e};for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)){let r=t[n];if(r===null||r===void 0)continue;else if(we(r)&&we(i[n]))i[n]=sr(i[n],r);else if(Array.isArray(r)&&Array.isArray(i[n]))if(r.length>0&&i[n].length>0&&we(r[0])&&we(i[n][0])){let o=[...r];for(let s of i[n])if(we(s)&&"name"in s){if(!o.find((a)=>we(a)&&("name"in a)&&a.name===s.name))o.push(s)}else if(we(s)&&"path"in s){if(!o.find((a)=>we(a)&&("path"in a)&&a.path===s.path))o.push(s)}else if(!o.some((a)=>Cr(a,s)))o.push(s);i[n]=o}else if(r.every((o)=>typeof o==="string")&&i[n].every((o)=>typeof o==="string")){let o=[...r];for(let s of i[n])if(!o.includes(s))o.push(s);i[n]=o}else i[n]=r;else i[n]=r}return i}function so(e,t,i="replace"){if(t===null||t===void 0)return e;if(Array.isArray(t))return i==="replace"?t:sr(e,t);if(Array.isArray(e))return i==="replace"?t:sr(e,t);if(!we(t)||!we(e))return t;let n={...e};for(let r of Object.keys(t)){if(!Object.prototype.hasOwnProperty.call(t,r))continue;let o=t[r],s=n[r];if(o===null||o===void 0)continue;if(Array.isArray(o)||Array.isArray(s))if(i==="replace")n[r]=o;else n[r]=sr(s,o);else if(we(o)&&we(s))n[r]=so(s,o,i);else n[r]=o}return n}function Cr(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(!Cr(e[i],t[i]))return!1;return!0}if(we(e)&&we(t)){let i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return!1;for(let r of i){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!Cr(e[r],t[r]))return!1}return!0}return!1}function we(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function nr(e,t,i="replace"){if(!Ta(e))return null;try{let n=await import(e),r=n.default||n;if(typeof r!=="object"||r===null||Array.isArray(r))return null;try{return so(t,r,i)}catch{return null}}catch{return null}}function Bu(e,t,i=!1){if(!e)return t;let n=e.toUpperCase().replace(/-/g,"_"),r={...t};function o(s,a=[]){let c={...s};for(let[f,u]of Object.entries(s)){let l=[...a,f],m=(C)=>C.replace(/([A-Z])/g,"_$1").toUpperCase(),y=`${n}_${l.map(m).join("_")}`,w=`${n}_${l.map((C)=>C.toUpperCase()).join("_")}`;if(i)Ke.info(`Checking environment variable ${y} for config ${e}.${l.join(".")}`);if(typeof u==="object"&&u!==null&&!Array.isArray(u))c[f]=o(u,l);else{let C=Ei.env[y]||Ei.env[w];if(C!==void 0){if(i)Ke.info(`Using environment variable ${C?y:w} for config ${e}.${l.join(".")}`);if(typeof u==="number")c[f]=Number(C);else if(typeof u==="boolean")c[f]=C.toLowerCase()==="true";else if(Array.isArray(u))try{let x=JSON.parse(C);if(Array.isArray(x))c[f]=x;else c[f]=C.split(",").map((k)=>k.trim())}catch{c[f]=C.split(",").map((x)=>x.trim())}else c[f]=C}}}return c}return o(r)}async function Gu({name:e="",alias:t,cwd:i,configDir:n,defaultConfig:r,verbose:o=!1,checkEnv:s=!0,arrayStrategy:a="replace"}){let c=s&&typeof r==="object"&&r!==null&&!Array.isArray(r)?Bu(e,r,o):r,f=i||Ei.cwd(),u=[".ts",".js",".mjs",".cjs",".json"];if(o)Ke.info(`Loading configuration for "${e}"${t?` (alias: "${t}")`:""} from ${f}`);let l=[e,`.${e}`].filter(Boolean),m=[`${e}.config`,`.${e}.config`].filter(Boolean),y=t?[t,`.${t}`]:[],w=t?[`${t}.config`,`.${t}.config`]:[],C=Array.from(new Set([f,Je(f,"config"),Je(f,".config"),n?Je(f,n):void 0].filter(Boolean)));for(let x of C){if(o)Ke.info(`Searching for configuration in: ${x}`);let k=[Je(f,"config"),Je(f,".config")].concat(n?[Je(f,n)]:[]).includes(x)?[...l,...m,...y,...w]:[...m,...l,...w,...y];for(let L of k)for(let W of u){let T=Je(x,`${L}${W}`),D=await nr(T,c,a);if(D!==null){if(o)Ke.success(`Configuration loaded from: ${T}`);return D}}}if(e){let x=Je(An(),".config",e),k=["config",`${e}.config`];if(t)k.push(`${t}.config`);if(o)Ke.info(`Checking user config directory: ${x}`);for(let L of k)for(let W of u){let T=Je(x,`${L}${W}`),D=await nr(T,c,a);if(D!==null){if(o)Ke.success(`Configuration loaded from user config directory: ${T}`);return D}}}if(e){let x=Je(An(),".config"),k=[`.${e}.config`];if(t)k.push(`.${t}.config`);if(o)Ke.info(`Checking user config directory for dotfile configs: ${x}`);for(let L of k)for(let W of u){let T=Je(x,`${L}${W}`),D=await nr(T,c,a);if(D!==null){if(o)Ke.success(`Configuration loaded from user config directory dotfile: ${T}`);return D}}}if(e){let x=An(),k=[`.${e}.config`,`.${e}`];if(t)k.push(`.${t}.config`),k.push(`.${t}`);if(o)Ke.info(`Checking user home directory for dotfile configs: ${x}`);for(let L of k)for(let W of u){let T=Je(x,`${L}${W}`),D=await nr(T,c,a);if(D!==null){if(o)Ke.success(`Configuration loaded from user home directory: ${T}`);return D}}}try{let x=Je(f,"package.json");if(Ta(x)){let k=await import(x),L=k[e];if(!L&&t){if(L=k[t],L&&o)Ke.success(`Using alias "${t}" configuration from package.json`)}if(L&&typeof L==="object"&&!Array.isArray(L))try{if(o)Ke.success(`Configuration loaded from package.json: ${L===k[e]?e:t}`);return so(c,L,a)}catch(W){if(o)Ke.warn("Failed to merge package.json config:",W)}}}catch(x){if(o)Ke.warn("Failed to load package.json:",x)}if(o)Ke.info(`No configuration found for "${e}"${t?` or alias "${t}"`:""}, using default configuration with environment variables`);return c}function ju(e,t={}){let i=ur.cwd();while(i.includes("storage"))i=Hs(i,"..");let n=Hs(i,e||"");if(t?.relative)return Kf(ur.cwd(),n);return n}async function _u(){try{let e=await Gu({name:"clarity",alias:"logging",defaultConfig:cr,cwd:ur.cwd()});return{...cr,...e||{}}}catch{return cr}}function Fe(){if(Et.env.NODE_ENV==="test"||Et.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Vu(){if(Et.env.NODE_ENV==="test"||Et.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof Et<"u"){let e=Et.type;if(e==="renderer"||e==="worker")return!1;return!!(Et.versions&&(Et.versions.node||Et.versions.bun))}return!1}class Da{async format(e){let t=await Vu(),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:ii.pid,hostname:t(),environment:ii.env.NODE_ENV||"development",platform:ii.platform,version:ii.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:ii.env.NODE_ENV||ii.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class wr{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={...Jn},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new Da,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??ye.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let i={...t},n=t.timestamp!==void 0;if(n)delete i.timestamp;if(this.config={...this.config,...i,timestamp:n||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let r=this.generateKeyId(),o=this.generateKey();this.currentKeyId=r,this.keys.set(r,o),this.encryptionKeys.set(r,{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{...fr,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...fr};return{...fr,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:Jn.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(([,n])=>n!==void 0))};if(!i.level||!["debug","info","success","warning","error"].includes(i.level))i.level=t.level;return i}shouldWriteToFile(){return!Fe()&&this.config.writeToFile===!0}async writeToFile(e){let t=(async()=>{let n,r=0,o=3,s=1000;while(r<o)try{try{try{await ou(this.config.logDirectory,ra.F_OK|ra.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await su(this.config.logDirectory,{recursive:!0,mode:493});else if(c.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw c;else throw c}}catch(c){throw console.error("Debug: [writeToFile] Failed to create log directory:",c),c}let a=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:gt.from(e);try{if(!Ji(this.currentLogFile))await Mn(this.currentLogFile,"",{mode:420});if(n=ia(this.currentLogFile,"a",420),nu(n,a,{flag:"a"}),ta(n),n!==void 0)kn(n),n=void 0;if((await ei(this.currentLogFile)).size===0){if(await Mn(this.currentLogFile,a,{flag:"w",mode:420}),(await ei(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(c){let f=c;if(f.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(f.code)){if(r<o-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${r+1}/${o}:`,u);let l=s*2**r;await new Promise((m)=>setTimeout(m,l)),r++;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(n!==void 0)try{kn(n)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(a){if(r===o-1){let f=a,u=typeof f.message==="string"?f.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",u),a}r++;let c=s*2**(r-1);await new Promise((f)=>setTimeout(f,c))}})();this.pendingOperations.push(t);let i=this.pendingOperations.length-1;try{await t}catch(n){throw console.error("Debug: [writeToFile] Error in operation:",n),n}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 ti(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 ti(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return ti(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(Fe())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((n)=>{console.error("Error rotating keys:",n)})},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 n=Array.from(this.encryptionKeys.entries()).sort(([,s],[,a])=>a.createdAt.getTime()-s.createdAt.getTime()),r=typeof e.maxKeys==="number"?e.maxKeys:1,o=Math.max(1,r);if(n.length>o)for(let[s]of n.slice(o))this.encryptionKeys.delete(s),this.keys.delete(s)}generateKeyId(){return Pn(16).toString("hex")}generateKey(){return Pn(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=Pn(16),n=tu("aes-256-gcm",t,i),r=gt.isBuffer(e)?e:gt.from(e,"utf8"),o=n.update(r),s=n.final(),a=o.length+s.length,c=n.getAuthTag(),f=gt.allocUnsafe(16+a+16);return i.copy(f,0),o.copy(f,16),s.copy(f,16+o.length),c.copy(f,16+a),{encrypted:f,iv:i}}async compressData(e){return new Promise((t,i)=>{let n=oa(),r=[];n.on("data",(o)=>r.push(o)),n.on("end",()=>t(gt.from(gt.concat(r)))),n.on("error",i),n.write(e),n.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(Fe())return;if(!this.shouldWriteToFile())return;let e=await ei(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,n=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let r=await qi(this.config.logDirectory),o=r.filter((c)=>c.startsWith(this.name)&&/\.log\.\d+$/.test(c)).sort((c,f)=>{let u=Number.parseInt(c.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,a=`${i}.${s}`;if(await ei(i).catch(()=>null))try{if(await na(i,a),t.compress)try{let c=`${a}.gz`;await this.compressLogFile(a,c),await Yi(a)}catch(c){console.error("Error compressing rotated file:",c)}if(o.length===0&&!r.some((c)=>c.endsWith(".log.1")))try{let c=`${i}.1`;await Mn(c,"")}catch(c){console.error("Error creating backup file:",c)}}catch(c){console.error(`Error during rotation: ${c instanceof Error?c.message:String(c)}`)}}else{let r=new Date().toISOString().replace(/[:.]/g,"-"),o=i.replace(/\.log$/,`-${r}.log`);if(await ei(i).catch(()=>null))await na(i,o)}if(this.currentLogFile=n,t.maxFiles){let r=(await qi(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,s)=>s.localeCompare(o));for(let o of r.slice(t.maxFiles))await Yi(ti(this.config.logDirectory,o))}}}async compressLogFile(e,t){let i=ea(e),n=ru(t),r=oa();await cu(i,r,n)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let i of this.logBuffer){let n=await this.formatter.format(i);if(this.shouldWriteToFile())await this.writeToFile(n);console.log(n)}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()})),Ji(this.currentLogFile))try{let e=ia(this.currentLogFile,"r+");ta(e),kn(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(!Fe()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await qi(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await Yi(ti(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()?ce.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||Fe())return!1;let e=typeof ye.env.NO_COLOR<"u",t=ye.env.FORCE_COLOR==="0";if(e||t)return!1;return!!(typeof ye.stderr<"u"&&ye.stderr.isTTY||typeof ye.stdout<"u"&&ye.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:t,icon:i="",tag:n="",message:r,level:o,showTimestamp:s=!0}=e,a=(y)=>y.replace(this.ANSI_PATTERN,"");if(!this.fancy){let y=[];if(s)y.push(t);if(o==="warning")y.push("WARN");else if(o==="error")y.push("ERROR");else if(i)y.push(i.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(n)y.push(n.replace(/[[\]]/g,""));return y.push(r),y.join(" ")}let c=ye.stdout.columns||120,f="";if(o==="warning"||o==="error")f=`${i} ${r}`;else if(o==="info"||o==="success")f=`${i} ${n} ${r}`;else f=`${i} ${n} ${ce.cyan(r)}`;if(!s)return f.trim();let u=a(f).trim().length,l=a(t).length,m=Math.max(1,c-2-u-l);return`${f.trim()}${" ".repeat(m)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(o,s)=>{let a=Number.parseInt(s,10);return a<t[0].length?String(t[0][a]):o});let i=/%([sdijfo%])/g,n=0,r=e.replace(i,(o,s)=>{if(s==="%")return"%";if(n>=t.length)return o;let a=t[n++];switch(s){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 o}});if(n<t.length)r+=` ${t.slice(n).map((o)=>typeof o==="object"?JSON.stringify(o,null,2):String(o)).join(" ")}`;return r}formatMarkdown(e){if(!e)return e;let t=e;return t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(i,n,r)=>{let o=ce.underline(ce.blue(n)),s=this.toAbsoluteFilePath(r);if(s&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let a=`file://${encodeURI(s)}`,c="\x1B]8;;",f="\x1B\\";return`\x1B]8;;${a}\x1B\\${o}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${r}\x1B\\${o}\x1B]8;;\x1B\\`;return o}),t=t.replace(/`([^`]+)`/g,(i,n)=>ce.bgGray(n)),t=t.replace(/\*\*([^*]+)\*\*/g,(i,n)=>ce.bold(n)),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(i,n)=>ce.italic(n)),t=t.replace(/(?<!_)_([^_]+)_(?!_)/g,(i,n)=>ce.italic(n)),t=t.replace(/~([^~]+)~/g,(i,n)=>ce.strikethrough(n)),t}supportsHyperlinks(){if(Fe())return!1;let e=ye.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=ye.env.HOME||"";if(i)t=t.replace(/^~(?=$|\/)/,i)}if(au(t)||t.startsWith("./")||t.startsWith("../"))t=lu(t);else return null;return Ji(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 n=new Date,r=this.formatConsoleTimestamp(n),o=this.formatFileTimestamp(n),s,a;if(t instanceof Error)s=t.message,a=t.stack;else s=this.formatMessage(t,i);let{consoleText:c,fileText:f}=this.buildOutputTexts(s);if(this.shouldStyleConsole()){let l=this.options.showIcons===!1?"":Va[e],m=this.options.showTags!==!1&&this.name?ce.gray(this.formatTag(this.name)):"",y;switch(e){case"debug":y=this.formatConsoleMessage({timestamp:r,icon:l,tag:m,message:ce.gray(c),level:e}),console.error(y);break;case"info":y=this.formatConsoleMessage({timestamp:r,icon:l,tag:m,message:c,level:e}),console.warn(y);break;case"success":y=this.formatConsoleMessage({timestamp:r,icon:l,tag:m,message:ce.green(c),level:e}),console.error(y);break;case"warning":y=this.formatConsoleMessage({timestamp:r,icon:l,tag:m,message:c,level:e}),console.warn(y);break;case"error":if(y=this.formatConsoleMessage({timestamp:r,icon:l,tag:m,message:c,level:e}),console.error(y),a){let w=a.split(`
44
- `);for(let C of w)if(C.trim()&&!C.includes(s))console.error(this.formatConsoleMessage({timestamp:r,message:ce.gray(` ${C}`),level:e,showTimestamp:!1}))}break}}else if(!Fe()){if(console.error(`${o} ${this.environment}.${e.toUpperCase()}: ${s}`),a)console.error(a)}if(!this.shouldLog(e))return;let u=`${o} ${this.environment}.${e.toUpperCase()}: ${f}
45
- `;if(a)u+=`${a}
35
+ `;Fs(t,r)}}catch{}}var vn=3,Ki=".dtsx-cache",Wf="manifest.json";var Bs=de(()=>{En()});function Gs(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 js=()=>{};import Bf from"process";import{existsSync as _s,statSync as Vs}from"fs";import{existsSync as Gf,mkdirSync as gg,readdirSync as yg,readFileSync as jf,writeFileSync as Cg}from"fs";import{homedir as qt}from"os";import{dirname as Eg,resolve as nt}from"path";import xr from"process";import{existsSync as Us,statSync as Ks}from"fs";import{existsSync as Un,mkdirSync as _f,readdirSync as Vf,writeFileSync as Uf}from"fs";import{homedir as Yt}from"os";import{dirname as Hs,resolve as qe}from"path";import Ft from"process";import{join as Kf,relative as Hf,resolve as zs}from"path";import ur from"process";import{existsSync as Oa,mkdirSync as kg,readdirSync as Mg,writeFileSync as Dg}from"fs";import{homedir as xn}from"os";import{dirname as Fg,resolve as Je}from"path";import bi from"process";import{join as zf,relative as Jf,resolve as Js}from"path";import hr from"process";import{existsSync as Ra,mkdirSync as jg,readdirSync as _g,writeFileSync as Vg}from"fs";import{dirname as Kg,resolve as dr}from"path";import Kn from"process";import{Buffer as Rt}from"buffer";import{createCipheriv as qf,createDecipheriv as Yf,randomBytes as An}from"crypto";import{closeSync as Tn,createReadStream as qs,createWriteStream as Zf,existsSync as On,fsyncSync as Ys,openSync as Zs,writeFileSync as Xf}from"fs";import{access as Qf,constants as Xs,mkdir as eu,readdir as Hi,rename as Qs,stat as Zt,unlink as zi,writeFile as Rn}from"fs/promises";import{join as Xt}from"path";import Ve from"process";import{pipeline as tu}from"stream/promises";import{createGzip as ea}from"zlib";import Qt from"process";import wt from"process";import{Buffer as gt}from"buffer";import{createCipheriv as iu,createDecipheriv as ru,randomBytes as Pn}from"crypto";import{closeSync as kn,createReadStream as ta,createWriteStream as nu,existsSync as Ji,fsyncSync as ia,openSync as ra,writeFileSync as ou}from"fs";import{access as su,constants as na,mkdir as au,readdir as qi,rename as oa,stat as ei,unlink as Yi,writeFile as Mn}from"fs/promises";import{isAbsolute as lu,join as ti,resolve as cu}from"path";import ye from"process";import{pipeline as fu}from"stream/promises";import{createGzip as sa}from"zlib";import ii from"process";import bt from"process";import Zi from"process";import{existsSync as Xi}from"fs";import{resolve as Dn}from"path";import{existsSync as uu}from"fs";import{existsSync as hu,readdirSync as du}from"fs";import{extname as In,resolve as aa}from"path";import pu from"process";import{join as mu,relative as gu,resolve as la}from"path";import pr from"process";import{Buffer as yt}from"buffer";import{createCipheriv as yu,createDecipheriv as Cu,randomBytes as Nn}from"crypto";import{closeSync as Fn,createReadStream as ca,createWriteStream as wu,existsSync as Qi,fsyncSync as fa,openSync as ua,writeFileSync as bu}from"fs";import{access as Eu,constants as ha,mkdir as vu,readdir as er,rename as da,stat as ri,unlink as tr,writeFile as Ln}from"fs/promises";import{isAbsolute as Su,join as ni,resolve as $u}from"path";import Ce from"process";import{pipeline as xu}from"stream/promises";import{createGzip as pa}from"zlib";import oi from"process";import Et from"process";import ir from"process";import{existsSync as rr}from"fs";import{resolve as Wn}from"path";import{existsSync as Au}from"fs";class Pa{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],[,n])=>i.timestamp.getTime()-n.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,n){if(!this.options.enabled)return;let r=this.generateKey(e,i),o=n??this.options.ttl,s=this.estimateSize(t);this.cache.set(r,{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),n=this.cache.get(i);if(!n){this.totalMisses++;return}if(this.isExpired(n)){this.cache.delete(i),this.totalMisses++;return}return n.hits++,this.totalHits++,n.value}isFileModified(e,t){try{if(!_s(e))return!0;return Vs(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,n){try{let r=_s(i)?Vs(i):null,o=r?r.mtime:new Date;this.set(e,{value:t,fileTimestamp:o},i,n)}catch{this.set(e,t,i,n)}}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((n,r)=>n+r.size,0),i=e.map((n)=>n.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 n=i;this.cache.set(t,{value:n.value,timestamp:new Date(n.timestamp),ttl:n.ttl,hits:n.hits,size:n.size})}}}class ka{metrics=[];maxMetrics=1000;async track(e,t,i={}){let n=performance.now(),r=new Date;try{let o=await t(),s=performance.now()-n;return this.recordMetric({operation:e,duration:s,timestamp:r,...i}),o}catch(o){let s=performance.now()-n;throw this.recordMetric({operation:`${e}:error`,duration:s,timestamp:r,...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((r)=>r.operation===e):this.metrics;if(t.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let i=t.map((r)=>r.duration),n=i.reduce((r,o)=>r+o,0);return{count:t.length,averageDuration:n/t.length,minDuration:Math.min(...i),maxDuration:Math.max(...i),totalDuration:n,recentMetrics:t.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((t)=>t.duration>e)}}function Ru(e,t){this[e]=Ou.bind(null,t)}class ro{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],[,n])=>i.timestamp.getTime()-n.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,n){if(!this.options.enabled)return;let r=this.generateKey(e,i),o=n??this.options.ttl,s=this.estimateSize(t);this.cache.set(r,{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),n=this.cache.get(i);if(!n){this.totalMisses++;return}if(this.isExpired(n)){this.cache.delete(i),this.totalMisses++;return}return n.hits++,this.totalHits++,n.value}isFileModified(e,t){try{if(!Us(e))return!0;return Ks(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,n){try{let r=Us(i)?Ks(i):null,o=r?r.mtime:new Date;this.set(e,{value:t,fileTimestamp:o},i,n)}catch{this.set(e,t,i,n)}}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((n,r)=>n+r.size,0),i=e.map((n)=>n.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 n=i;this.cache.set(t,{value:n.value,timestamp:new Date(n.timestamp),ttl:n.ttl,hits:n.hits,size:n.size})}}}class no{metrics=[];maxMetrics=1000;async track(e,t,i={}){let n=performance.now(),r=new Date;try{let o=await t(),s=performance.now()-n;return this.recordMetric({operation:e,duration:s,timestamp:r,...i}),o}catch(o){let s=performance.now()-n;throw this.recordMetric({operation:`${e}:error`,duration:s,timestamp:r,...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((r)=>r.operation===e):this.metrics;if(t.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let i=t.map((r)=>r.duration),n=i.reduce((r,o)=>r+o,0);return{count:t.length,averageDuration:n/t.length,minDuration:Math.min(...i),maxDuration:Math.max(...i),totalDuration:n,recentMetrics:t.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((t)=>t.duration>e)}}function Mu(e,t={}){let i=Object.keys(t).sort().map((n)=>`${n}:${t[n]}`).join("|");return i?`${e}:${i}`:e}function Du(e,t){try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}}function Iu(e){return e.getStats().size*2}function oo(e,t){if(Array.isArray(t)&&Array.isArray(e)&&t.length===2&&e.length===2&&Oe(t[0])&&"id"in t[0]&&t[0].id===3&&Oe(t[1])&&"id"in t[1]&&t[1].id===4)return t;if(Oe(t)&&Oe(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(Oe(e)&&"arr"in e&&Array.isArray(e.arr)&&Oe(t)&&"arr"in t&&Array.isArray(t.arr))return t;if(t.length>0&&e.length>0&&Oe(t[0])&&Oe(e[0])){let n=[...t];for(let r of e)if(Oe(r)&&"name"in r){if(!n.find((o)=>Oe(o)&&("name"in o)&&o.name===r.name))n.push(r)}else if(Oe(r)&&"path"in r){if(!n.find((o)=>Oe(o)&&("path"in o)&&o.path===r.path))n.push(r)}else if(!n.some((o)=>gr(o,r)))n.push(r);return n}if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let r of e)if(!n.includes(r))n.push(r);return n}return t}if(!Oe(t)||!Oe(e))return t;let i={...e};for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)){let r=t[n];if(r===null||r===void 0)continue;else if(Oe(r)&&Oe(i[n]))i[n]=oo(i[n],r);else if(Array.isArray(r)&&Array.isArray(i[n]))if(r.length>0&&i[n].length>0&&Oe(r[0])&&Oe(i[n][0])){let o=[...r];for(let s of i[n])if(Oe(s)&&"name"in s){if(!o.find((l)=>Oe(l)&&("name"in l)&&l.name===s.name))o.push(s)}else if(Oe(s)&&"path"in s){if(!o.find((l)=>Oe(l)&&("path"in l)&&l.path===s.path))o.push(s)}else if(!o.some((l)=>gr(l,s)))o.push(s);i[n]=o}else if(r.every((o)=>typeof o==="string")&&i[n].every((o)=>typeof o==="string")){let o=[...r];for(let s of i[n])if(!o.includes(s))o.push(s);i[n]=o}else i[n]=r;else i[n]=r}return i}function gr(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(!gr(e[i],t[i]))return!1;return!0}if(Oe(e)&&Oe(t)){let i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return!1;for(let r of i){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!gr(e[r],t[r]))return!1}return!0}return!1}function Oe(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function Nu(e,t){if(!Ra(e))return null;try{let i=await import(e),n=i.default||i;if(typeof n!=="object"||n===null||Array.isArray(n))return null;try{return oo(t,n)}catch{return null}}catch{return null}}async function Fu({name:e="",cwd:t,defaultConfig:i}){let n=t||Kn.cwd(),r=[".ts",".js",".mjs",".cjs",".json"],o=[`${e}.config`,`.${e}.config`,e,`.${e}`];for(let s of o)for(let l of r){let c=dr(n,`${s}${l}`),f=await Nu(c,i);if(f!==null)return f}try{let s=dr(n,"package.json");if(Ra(s)){let l=(await import(s))[e];if(l&&typeof l==="object"&&!Array.isArray(l))try{return oo(i,l)}catch{}}}catch{}return i}function Lu(e,t={}){let i=hr.cwd();while(i.includes("storage"))i=Js(i,"..");let n=Js(i,e||"");if(t?.relative)return Jf(hr.cwd(),n);return n}async function Wu(){try{let e=await Fu({name:"clarity",defaultConfig:ar,cwd:hr.cwd(),endpoint:"",headers:{}});return{...ar,...e}}catch{return ar}}function Re(){if(wt.env.NODE_ENV==="test"||wt.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Bu(){if(wt.env.NODE_ENV==="test"||wt.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof wt<"u"){let e=wt.type;if(e==="renderer"||e==="worker")return!1;return!!(wt.versions&&(wt.versions.node||wt.versions.bun))}return!1}class Da{async format(e){let t=await Bu(),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:Qt.pid,hostname:t(),environment:Qt.env.NODE_ENV||"development",platform:Qt.platform,version:Qt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:Qt.env.NODE_ENV||Qt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class yr{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={...zn},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new Da,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??Ve.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let i={...t},n=t.timestamp!==void 0;if(n)delete i.timestamp;if(this.config={...this.config,...i,timestamp:n||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let r=this.generateKeyId(),o=this.generateKey();this.currentKeyId=r,this.keys.set(r,o),this.encryptionKeys.set(r,{key:o,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...lr,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...lr};return{...lr,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:zn.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},i={...t,...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==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 n,r=0,o=3,s=1000;while(r<o)try{try{try{await Qf(this.config.logDirectory,Xs.F_OK|Xs.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await eu(this.config.logDirectory,{recursive:!0,mode:493});else if(c.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw c;else throw c}}catch(c){throw console.error("Debug: [writeToFile] Failed to create log directory:",c),c}let l=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:Rt.from(e);try{if(!On(this.currentLogFile))await Rn(this.currentLogFile,"",{mode:420});if(n=Zs(this.currentLogFile,"a",420),Xf(n,l,{flag:"a"}),Ys(n),n!==void 0)Tn(n),n=void 0;if((await Zt(this.currentLogFile)).size===0){if(await Rn(this.currentLogFile,l,{flag:"w",mode:420}),(await Zt(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(c){let f=c;if(f.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(f.code)){if(r<o-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${r+1}/${o}:`,u);let a=s*2**r;await new Promise((m)=>setTimeout(m,a)),r++;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(n!==void 0)try{Tn(n)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(l){if(r===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}r++;let c=s*2**(r-1);await new Promise((f)=>setTimeout(f,c))}})();this.pendingOperations.push(t);let i=this.pendingOperations.length-1;try{await t}catch(n){throw console.error("Debug: [writeToFile] Error in operation:",n),n}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 Xt(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 Xt(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return Xt(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(Re())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((n)=>{console.error("Error rotating keys:",n)})},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 n=Array.from(this.encryptionKeys.entries()).sort(([,s],[,l])=>l.createdAt.getTime()-s.createdAt.getTime()),r=typeof e.maxKeys==="number"?e.maxKeys:1,o=Math.max(1,r);if(n.length>o)for(let[s]of n.slice(o))this.encryptionKeys.delete(s),this.keys.delete(s)}generateKeyId(){return An(16).toString("hex")}generateKey(){return An(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=An(16),n=qf("aes-256-gcm",t,i),r=Rt.concat([n.update(e,"utf8"),n.final()]),o=n.getAuthTag();return{encrypted:Rt.concat([i,r,o]),iv:i}}async compressData(e){return new Promise((t,i)=>{let n=ea(),r=[];n.on("data",(o)=>r.push(o)),n.on("end",()=>t(Rt.from(Rt.concat(r)))),n.on("error",i),n.write(e),n.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(Re())return;let e=await Zt(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,n=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let r=await Hi(this.config.logDirectory),o=r.filter((c)=>c.startsWith(this.name)&&/\.log\.\d+$/.test(c)).sort((c,f)=>{let u=Number.parseInt(c.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 Zt(i).catch(()=>null))try{if(await Qs(i,l),t.compress)try{let c=`${l}.gz`;await this.compressLogFile(l,c),await zi(l)}catch(c){console.error("Error compressing rotated file:",c)}if(o.length===0&&!r.some((c)=>c.endsWith(".log.1")))try{let c=`${i}.1`;await Rn(c,"")}catch(c){console.error("Error creating backup file:",c)}}catch(c){console.error(`Error during rotation: ${c instanceof Error?c.message:String(c)}`)}}else{let r=new Date().toISOString().replace(/[:.]/g,"-"),o=i.replace(/\.log$/,`-${r}.log`);if(await Zt(i).catch(()=>null))await Qs(i,o)}if(this.currentLogFile=n,t.maxFiles){let r=(await Hi(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,s)=>s.localeCompare(o));for(let o of r.slice(t.maxFiles))await zi(Xt(this.config.logDirectory,o))}}}async compressLogFile(e,t){let i=qs(e),n=Zf(t),r=ea();await tu(i,r,n)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let i of this.logBuffer){let n=await this.formatter.format(i);await this.writeToFile(n),console.log(n)}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()})),On(this.currentLogFile))try{let e=Zs(this.currentLogFile,"r+");Ys(e),Tn(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(!Re()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await Hi(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await zi(Xt(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?Se.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}formatConsoleMessage(e){let{timestamp:t,icon:i="",tag:n="",message:r,level:o,showTimestamp:s=!0}=e,l=(y)=>y.replace(this.ANSI_PATTERN,"");if(!this.fancy){let y=[];if(s)y.push(t);if(o==="warning")y.push("WARN");else if(o==="error")y.push("ERROR");else if(i)y.push(i.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(n)y.push(n.replace(/[[\]]/g,""));return y.push(r),y.join(" ")}let c=Ve.stdout.columns||120,f="";if(o==="warning"||o==="error")f=`${i} ${r}`;else if(o==="info"||o==="success")f=`${i} ${n} ${r}`;else f=`${i} ${n} ${Se.cyan(r)}`;if(!s)return f.trim();let u=l(f).trim().length,a=l(t).length,m=Math.max(1,c-2-u-a);return`${f.trim()}${" ".repeat(m)}${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,n=0,r=e.replace(i,(o,s)=>{if(s==="%")return"%";if(n>=t.length)return o;let l=t[n++];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(n<t.length)r+=` ${t.slice(n).map((o)=>typeof o==="object"?JSON.stringify(o,null,2):String(o)).join(" ")}`;return r}async log(e,t,...i){let n=new Date,r=this.formatConsoleTimestamp(n),o=this.formatFileTimestamp(n),s,l;if(t instanceof Error)s=t.message,l=t.stack;else s=this.formatMessage(t,i);if(this.fancy&&!Re()){let f=Va[e],u=this.options.showTags!==!1&&this.name?Se.gray(this.formatTag(this.name)):"",a;switch(e){case"debug":a=this.formatConsoleMessage({timestamp:r,icon:f,tag:u,message:Se.gray(s),level:e}),console.error(a);break;case"info":a=this.formatConsoleMessage({timestamp:r,icon:f,tag:u,message:s,level:e}),console.error(a);break;case"success":a=this.formatConsoleMessage({timestamp:r,icon:f,tag:u,message:Se.green(s),level:e}),console.error(a);break;case"warning":a=this.formatConsoleMessage({timestamp:r,icon:f,tag:u,message:s,level:e}),console.warn(a);break;case"error":if(a=this.formatConsoleMessage({timestamp:r,icon:f,tag:u,message:s,level:e}),console.error(a),l){let m=l.split(`
36
+ `);for(let y of m)if(y.trim()&&!y.includes(s))console.error(this.formatConsoleMessage({timestamp:r,message:Se.gray(` ${y}`),level:e,showTimestamp:!1}))}break}}else if(!Re()){if(console.error(`${o} ${this.environment}.${e.toUpperCase()}: ${s}`),l)console.error(l)}if(!this.shouldLog(e))return;let c=`${o} ${this.environment}.${e.toUpperCase()}: ${s}
37
+ `;if(l)c+=`${l}
38
+ `;c=c.replace(this.ANSI_PATTERN,""),await this.writeToFile(c)}time(e){let t=performance.now();if(this.fancy&&!Re()){let i=this.options.showTags!==!1&&this.name?Se.gray(this.formatTag(this.name)):"",n=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:n,icon:Se.blue("\u25D0"),tag:i,message:`${Se.cyan(e)}...`}))}return async(i)=>{if(!this.enabled)return;let n=performance.now(),r=Math.round(n-t),o=`${e} completed in ${r}ms`,s=new Date,l=this.formatConsoleTimestamp(s),c=`${this.formatFileTimestamp(s)} ${this.environment}.INFO: ${o}`;if(i)c+=` ${JSON.stringify(i)}`;if(c+=`
39
+ `,c=c.replace(this.ANSI_PATTERN,""),this.fancy&&!Re()){let f=this.options.showTags!==!1&&this.name?Se.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:l,icon:Se.green("\u2713"),tag:f,message:`${o}${i?` ${JSON.stringify(i)}`:""}`}))}else if(!Re())console.error(c.trim());await this.writeToFile(c)}}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 yr(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(Re())throw Error("createReadStream is not supported in browser environments");if(!On(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return qs(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 n=Rt.isBuffer(e)?e:Rt.from(e,"base64"),r=n.slice(0,16),o=n.slice(-16),s=n.slice(16,-16),l=Yf("aes-256-gcm",i,r);return l.setAuthTag(o),Rt.concat([l.update(s),l.final()]).toString("utf8")}catch(n){throw Error(`Decryption failed: ${n instanceof Error?n.message:String(n)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return Re()}isServerMode(){return!Re()}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),n=this.formatFileTimestamp(t);if(this.fancy&&!Re()){let o=e.split(`
40
+ `),s=Math.max(...o.map((u)=>u.length))+2,l=`\u250C${"\u2500".repeat(s)}\u2510`,c=`\u2514${"\u2500".repeat(s)}\u2518`,f=o.map((u)=>{let a=" ".repeat(s-u.length-2);return`\u2502 ${u}${a} \u2502`});if(this.options.showTags!==!1&&this.name)console.error(this.formatConsoleMessage({timestamp:i,message:Se.gray(this.formatTag(this.name)),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:i,message:Se.cyan(l)})),f.forEach((u)=>console.error(this.formatConsoleMessage({timestamp:i,message:Se.cyan(u),showTimestamp:!1}))),console.error(this.formatConsoleMessage({timestamp:i,message:Se.cyan(c),showTimestamp:!1}))}else if(!Re())console.error(`${n} ${this.environment}.INFO: [BOX] ${e}`);let r=`${n} ${this.environment}.INFO: [BOX] ${e}
41
+ `.replace(this.ANSI_PATTERN,"");await this.writeToFile(r)}async prompt(e){if(Re())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${Se.cyan("?")} ${e} (y/n) `);let i=(n)=>{let r=n.toString().trim().toLowerCase();Ve.stdin.removeListener("data",i);try{if(typeof Ve.stdin.setRawMode==="function")Ve.stdin.setRawMode(!1)}catch{}Ve.stdin.pause(),console.error(""),t(r==="y"||r==="yes")};try{if(typeof Ve.stdin.setRawMode==="function")Ve.stdin.setRawMode(!0)}catch{}Ve.stdin.resume(),Ve.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 r=/%([sdijfo%])/g,o=0;if(i=e.replace(r,(s,l)=>{if(l==="%")return"%";if(o>=t.length)return s;let c=t[o++];switch(l){case"s":return String(c);case"d":case"i":return Number(c).toString();case"j":case"o":return JSON.stringify(c,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&&!Re()){let r=this.options.showTags!==!1&&this.name?Se.gray(this.formatTag(this.name)):"",o=Se.blue("\u25D0");console.error(`${o} ${r} ${Se.cyan(i)}`)}let n=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${i}
42
+ `.replace(this.ANSI_PATTERN,"");await this.writeToFile(n)}progress(e,t=""){if(!this.enabled||!this.fancy||Re()||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:(n,r)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||Re())return;if(this.activeProgressBar.current=Math.max(0,Math.min(e,n)),r!==void 0)this.activeProgressBar.message=r;let o=this.activeProgressBar.current===this.activeProgressBar.total;this.renderProgressBar(this.activeProgressBar,o)},finish:(n)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||Re())return;if(this.activeProgressBar.current=this.activeProgressBar.total,n!==void 0)this.activeProgressBar.message=n;this.renderProgressBar(this.activeProgressBar,!0),this.finishProgressBar(this.activeProgressBar)},interrupt:(n,r="info")=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||Re())return;Ve.stdout.write(`${"\r".padEnd(Ve.stdout.columns||80)}\r`),this.log(r,n),setTimeout(()=>{if(this.activeProgressBar)this.renderProgressBar(this.activeProgressBar)},50)}}}renderProgressBar(e,t=!1){if(!this.enabled||!this.fancy||Re()||!Ve.stdout.isTTY)return;let i=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),n=Math.round(e.barLength*i/100),r=e.barLength-n,o=Se.green("\u2501".repeat(n)),s=Se.gray("\u2501".repeat(r)),l=`[${o}${s}]`,c=`${i}%`.padStart(4),f=e.message?` ${e.message}`:"",u=t||i===100?Se.green("\u2713"):Se.blue("\u25B6"),a=this.options.showTags!==!1&&this.name?` ${Se.gray(this.formatTag(this.name))}`:"",m=`\r${u}${a} ${l} ${c}${f}`,y=Ve.stdout.columns||80,w=" ".repeat(Math.max(0,y-m.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${m}${w}`,Ve.stdout.write(e.lastRenderedLine),t)Ve.stdout.write(`
43
+ `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||Re()||!Ve.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(Re()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await Hi(this.config.logDirectory),i=[];for(let n of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(n):n.startsWith(this.name))||!n.endsWith(".log"))continue;let r=Xt(this.config.logDirectory,n);if(e.before)try{if((await Zt(r)).mtime>=e.before)continue}catch(o){console.error(`Failed to get stats for file ${r}:`,o);continue}i.push(r)}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 n of i)try{await zi(n),console.warn(`Deleted log file: ${n}`)}catch(r){console.error(`Failed to delete log file ${n}:`,r)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}function sr(e,t){if(Array.isArray(t)&&Array.isArray(e)&&t.length===2&&e.length===2&&we(t[0])&&"id"in t[0]&&t[0].id===3&&we(t[1])&&"id"in t[1]&&t[1].id===4)return t;if(we(t)&&we(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(we(e)&&"arr"in e&&Array.isArray(e.arr)&&we(t)&&"arr"in t&&Array.isArray(t.arr))return t;if(t.length>0&&e.length>0&&we(t[0])&&we(e[0])){let n=[...t];for(let r of e)if(we(r)&&"name"in r){if(!n.find((o)=>we(o)&&("name"in o)&&o.name===r.name))n.push(r)}else if(we(r)&&"path"in r){if(!n.find((o)=>we(o)&&("path"in o)&&o.path===r.path))n.push(r)}else if(!n.some((o)=>Cr(o,r)))n.push(r);return n}if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let r of e)if(!n.includes(r))n.push(r);return n}return t}if(!we(t)||!we(e))return t;let i={...e};for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)){let r=t[n];if(r===null||r===void 0)continue;else if(we(r)&&we(i[n]))i[n]=sr(i[n],r);else if(Array.isArray(r)&&Array.isArray(i[n]))if(r.length>0&&i[n].length>0&&we(r[0])&&we(i[n][0])){let o=[...r];for(let s of i[n])if(we(s)&&"name"in s){if(!o.find((l)=>we(l)&&("name"in l)&&l.name===s.name))o.push(s)}else if(we(s)&&"path"in s){if(!o.find((l)=>we(l)&&("path"in l)&&l.path===s.path))o.push(s)}else if(!o.some((l)=>Cr(l,s)))o.push(s);i[n]=o}else if(r.every((o)=>typeof o==="string")&&i[n].every((o)=>typeof o==="string")){let o=[...r];for(let s of i[n])if(!o.includes(s))o.push(s);i[n]=o}else i[n]=r;else i[n]=r}return i}function so(e,t,i="replace"){if(t===null||t===void 0)return e;if(Array.isArray(t))return i==="replace"?t:sr(e,t);if(Array.isArray(e))return i==="replace"?t:sr(e,t);if(!we(t)||!we(e))return t;let n={...e};for(let r of Object.keys(t)){if(!Object.prototype.hasOwnProperty.call(t,r))continue;let o=t[r],s=n[r];if(o===null||o===void 0)continue;if(Array.isArray(o)||Array.isArray(s))if(i==="replace")n[r]=o;else n[r]=sr(s,o);else if(we(o)&&we(s))n[r]=so(s,o,i);else n[r]=o}return n}function Cr(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(!Cr(e[i],t[i]))return!1;return!0}if(we(e)&&we(t)){let i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return!1;for(let r of i){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!Cr(e[r],t[r]))return!1}return!0}return!1}function we(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function nr(e,t,i="replace"){if(!Oa(e))return null;try{let n=await import(e),r=n.default||n;if(typeof r!=="object"||r===null||Array.isArray(r))return null;try{return so(t,r,i)}catch{return null}}catch{return null}}function Gu(e,t,i=!1){if(!e)return t;let n=e.toUpperCase().replace(/-/g,"_"),r={...t};function o(s,l=[]){let c={...s};for(let[f,u]of Object.entries(s)){let a=[...l,f],m=(C)=>C.replace(/([A-Z])/g,"_$1").toUpperCase(),y=`${n}_${a.map(m).join("_")}`,w=`${n}_${a.map((C)=>C.toUpperCase()).join("_")}`;if(i)Ke.info(`Checking environment variable ${y} for config ${e}.${a.join(".")}`);if(typeof u==="object"&&u!==null&&!Array.isArray(u))c[f]=o(u,a);else{let C=bi.env[y]||bi.env[w];if(C!==void 0){if(i)Ke.info(`Using environment variable ${C?y:w} for config ${e}.${a.join(".")}`);if(typeof u==="number")c[f]=Number(C);else if(typeof u==="boolean")c[f]=C.toLowerCase()==="true";else if(Array.isArray(u))try{let A=JSON.parse(C);if(Array.isArray(A))c[f]=A;else c[f]=C.split(",").map((k)=>k.trim())}catch{c[f]=C.split(",").map((A)=>A.trim())}else c[f]=C}}}return c}return o(r)}async function ju({name:e="",alias:t,cwd:i,configDir:n,defaultConfig:r,verbose:o=!1,checkEnv:s=!0,arrayStrategy:l="replace"}){let c=s&&typeof r==="object"&&r!==null&&!Array.isArray(r)?Gu(e,r,o):r,f=i||bi.cwd(),u=[".ts",".js",".mjs",".cjs",".json"];if(o)Ke.info(`Loading configuration for "${e}"${t?` (alias: "${t}")`:""} from ${f}`);let a=[e,`.${e}`].filter(Boolean),m=[`${e}.config`,`.${e}.config`].filter(Boolean),y=t?[t,`.${t}`]:[],w=t?[`${t}.config`,`.${t}.config`]:[],C=Array.from(new Set([f,Je(f,"config"),Je(f,".config"),n?Je(f,n):void 0].filter(Boolean)));for(let A of C){if(o)Ke.info(`Searching for configuration in: ${A}`);let k=[Je(f,"config"),Je(f,".config")].concat(n?[Je(f,n)]:[]).includes(A)?[...a,...m,...y,...w]:[...m,...a,...w,...y];for(let W of k)for(let B of u){let T=Je(A,`${W}${B}`),D=await nr(T,c,l);if(D!==null){if(o)Ke.success(`Configuration loaded from: ${T}`);return D}}}if(e){let A=Je(xn(),".config",e),k=["config",`${e}.config`];if(t)k.push(`${t}.config`);if(o)Ke.info(`Checking user config directory: ${A}`);for(let W of k)for(let B of u){let T=Je(A,`${W}${B}`),D=await nr(T,c,l);if(D!==null){if(o)Ke.success(`Configuration loaded from user config directory: ${T}`);return D}}}if(e){let A=Je(xn(),".config"),k=[`.${e}.config`];if(t)k.push(`.${t}.config`);if(o)Ke.info(`Checking user config directory for dotfile configs: ${A}`);for(let W of k)for(let B of u){let T=Je(A,`${W}${B}`),D=await nr(T,c,l);if(D!==null){if(o)Ke.success(`Configuration loaded from user config directory dotfile: ${T}`);return D}}}if(e){let A=xn(),k=[`.${e}.config`,`.${e}`];if(t)k.push(`.${t}.config`),k.push(`.${t}`);if(o)Ke.info(`Checking user home directory for dotfile configs: ${A}`);for(let W of k)for(let B of u){let T=Je(A,`${W}${B}`),D=await nr(T,c,l);if(D!==null){if(o)Ke.success(`Configuration loaded from user home directory: ${T}`);return D}}}try{let A=Je(f,"package.json");if(Oa(A)){let k=await import(A),W=k[e];if(!W&&t){if(W=k[t],W&&o)Ke.success(`Using alias "${t}" configuration from package.json`)}if(W&&typeof W==="object"&&!Array.isArray(W))try{if(o)Ke.success(`Configuration loaded from package.json: ${W===k[e]?e:t}`);return so(c,W,l)}catch(B){if(o)Ke.warn("Failed to merge package.json config:",B)}}}catch(A){if(o)Ke.warn("Failed to load package.json:",A)}if(o)Ke.info(`No configuration found for "${e}"${t?` or alias "${t}"`:""}, using default configuration with environment variables`);return c}function _u(e,t={}){let i=ur.cwd();while(i.includes("storage"))i=zs(i,"..");let n=zs(i,e||"");if(t?.relative)return Hf(ur.cwd(),n);return n}async function Vu(){try{let e=await ju({name:"clarity",alias:"logging",defaultConfig:cr,cwd:ur.cwd()});return{...cr,...e||{}}}catch{return cr}}function Fe(){if(bt.env.NODE_ENV==="test"||bt.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Uu(){if(bt.env.NODE_ENV==="test"||bt.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof bt<"u"){let e=bt.type;if(e==="renderer"||e==="worker")return!1;return!!(bt.versions&&(bt.versions.node||bt.versions.bun))}return!1}class Ia{async format(e){let t=await Uu(),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:ii.pid,hostname:t(),environment:ii.env.NODE_ENV||"development",platform:ii.platform,version:ii.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:ii.env.NODE_ENV||ii.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class wr{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={...Jn},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new Ia,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??ye.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let i={...t},n=t.timestamp!==void 0;if(n)delete i.timestamp;if(this.config={...this.config,...i,timestamp:n||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let r=this.generateKeyId(),o=this.generateKey();this.currentKeyId=r,this.keys.set(r,o),this.encryptionKeys.set(r,{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{...fr,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...fr};return{...fr,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:Jn.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(([,n])=>n!==void 0))};if(!i.level||!["debug","info","success","warning","error"].includes(i.level))i.level=t.level;return i}shouldWriteToFile(){return!Fe()&&this.config.writeToFile===!0}async writeToFile(e){let t=(async()=>{let n,r=0,o=3,s=1000;while(r<o)try{try{try{await su(this.config.logDirectory,na.F_OK|na.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await au(this.config.logDirectory,{recursive:!0,mode:493});else if(c.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw c;else throw c}}catch(c){throw console.error("Debug: [writeToFile] Failed to create log directory:",c),c}let l=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:gt.from(e);try{if(!Ji(this.currentLogFile))await Mn(this.currentLogFile,"",{mode:420});if(n=ra(this.currentLogFile,"a",420),ou(n,l,{flag:"a"}),ia(n),n!==void 0)kn(n),n=void 0;if((await ei(this.currentLogFile)).size===0){if(await Mn(this.currentLogFile,l,{flag:"w",mode:420}),(await ei(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(c){let f=c;if(f.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(f.code)){if(r<o-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${r+1}/${o}:`,u);let a=s*2**r;await new Promise((m)=>setTimeout(m,a)),r++;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(n!==void 0)try{kn(n)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(l){if(r===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}r++;let c=s*2**(r-1);await new Promise((f)=>setTimeout(f,c))}})();this.pendingOperations.push(t);let i=this.pendingOperations.length-1;try{await t}catch(n){throw console.error("Debug: [writeToFile] Error in operation:",n),n}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 ti(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 ti(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return ti(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(Fe())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((n)=>{console.error("Error rotating keys:",n)})},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 n=Array.from(this.encryptionKeys.entries()).sort(([,s],[,l])=>l.createdAt.getTime()-s.createdAt.getTime()),r=typeof e.maxKeys==="number"?e.maxKeys:1,o=Math.max(1,r);if(n.length>o)for(let[s]of n.slice(o))this.encryptionKeys.delete(s),this.keys.delete(s)}generateKeyId(){return Pn(16).toString("hex")}generateKey(){return Pn(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=Pn(16),n=iu("aes-256-gcm",t,i),r=gt.isBuffer(e)?e:gt.from(e,"utf8"),o=n.update(r),s=n.final(),l=o.length+s.length,c=n.getAuthTag(),f=gt.allocUnsafe(16+l+16);return i.copy(f,0),o.copy(f,16),s.copy(f,16+o.length),c.copy(f,16+l),{encrypted:f,iv:i}}async compressData(e){return new Promise((t,i)=>{let n=sa(),r=[];n.on("data",(o)=>r.push(o)),n.on("end",()=>t(gt.from(gt.concat(r)))),n.on("error",i),n.write(e),n.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(Fe())return;if(!this.shouldWriteToFile())return;let e=await ei(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,n=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let r=await qi(this.config.logDirectory),o=r.filter((c)=>c.startsWith(this.name)&&/\.log\.\d+$/.test(c)).sort((c,f)=>{let u=Number.parseInt(c.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 ei(i).catch(()=>null))try{if(await oa(i,l),t.compress)try{let c=`${l}.gz`;await this.compressLogFile(l,c),await Yi(l)}catch(c){console.error("Error compressing rotated file:",c)}if(o.length===0&&!r.some((c)=>c.endsWith(".log.1")))try{let c=`${i}.1`;await Mn(c,"")}catch(c){console.error("Error creating backup file:",c)}}catch(c){console.error(`Error during rotation: ${c instanceof Error?c.message:String(c)}`)}}else{let r=new Date().toISOString().replace(/[:.]/g,"-"),o=i.replace(/\.log$/,`-${r}.log`);if(await ei(i).catch(()=>null))await oa(i,o)}if(this.currentLogFile=n,t.maxFiles){let r=(await qi(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,s)=>s.localeCompare(o));for(let o of r.slice(t.maxFiles))await Yi(ti(this.config.logDirectory,o))}}}async compressLogFile(e,t){let i=ta(e),n=nu(t),r=sa();await fu(i,r,n)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let i of this.logBuffer){let n=await this.formatter.format(i);if(this.shouldWriteToFile())await this.writeToFile(n);console.log(n)}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()})),Ji(this.currentLogFile))try{let e=ra(this.currentLogFile,"r+");ia(e),kn(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(!Fe()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await qi(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await Yi(ti(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()?fe.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||Fe())return!1;let e=typeof ye.env.NO_COLOR<"u",t=ye.env.FORCE_COLOR==="0";if(e||t)return!1;return!!(typeof ye.stderr<"u"&&ye.stderr.isTTY||typeof ye.stdout<"u"&&ye.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:t,icon:i="",tag:n="",message:r,level:o,showTimestamp:s=!0}=e,l=(y)=>y.replace(this.ANSI_PATTERN,"");if(!this.fancy){let y=[];if(s)y.push(t);if(o==="warning")y.push("WARN");else if(o==="error")y.push("ERROR");else if(i)y.push(i.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(n)y.push(n.replace(/[[\]]/g,""));return y.push(r),y.join(" ")}let c=ye.stdout.columns||120,f="";if(o==="warning"||o==="error")f=`${i} ${r}`;else if(o==="info"||o==="success")f=`${i} ${n} ${r}`;else f=`${i} ${n} ${fe.cyan(r)}`;if(!s)return f.trim();let u=l(f).trim().length,a=l(t).length,m=Math.max(1,c-2-u-a);return`${f.trim()}${" ".repeat(m)}${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,n=0,r=e.replace(i,(o,s)=>{if(s==="%")return"%";if(n>=t.length)return o;let l=t[n++];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(n<t.length)r+=` ${t.slice(n).map((o)=>typeof o==="object"?JSON.stringify(o,null,2):String(o)).join(" ")}`;return r}formatMarkdown(e){if(!e)return e;let t=e;return t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(i,n,r)=>{let o=fe.underline(fe.blue(n)),s=this.toAbsoluteFilePath(r);if(s&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let l=`file://${encodeURI(s)}`,c="\x1B]8;;",f="\x1B\\";return`\x1B]8;;${l}\x1B\\${o}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${r}\x1B\\${o}\x1B]8;;\x1B\\`;return o}),t=t.replace(/`([^`]+)`/g,(i,n)=>fe.bgGray(n)),t=t.replace(/\*\*([^*]+)\*\*/g,(i,n)=>fe.bold(n)),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(i,n)=>fe.italic(n)),t=t.replace(/(?<!_)_([^_]+)_(?!_)/g,(i,n)=>fe.italic(n)),t=t.replace(/~([^~]+)~/g,(i,n)=>fe.strikethrough(n)),t}supportsHyperlinks(){if(Fe())return!1;let e=ye.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=ye.env.HOME||"";if(i)t=t.replace(/^~(?=$|\/)/,i)}if(lu(t)||t.startsWith("./")||t.startsWith("../"))t=cu(t);else return null;return Ji(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 n=new Date,r=this.formatConsoleTimestamp(n),o=this.formatFileTimestamp(n),s,l;if(t instanceof Error)s=t.message,l=t.stack;else s=this.formatMessage(t,i);let{consoleText:c,fileText:f}=this.buildOutputTexts(s);if(this.shouldStyleConsole()){let a=this.options.showIcons===!1?"":Ua[e],m=this.options.showTags!==!1&&this.name?fe.gray(this.formatTag(this.name)):"",y;switch(e){case"debug":y=this.formatConsoleMessage({timestamp:r,icon:a,tag:m,message:fe.gray(c),level:e}),console.error(y);break;case"info":y=this.formatConsoleMessage({timestamp:r,icon:a,tag:m,message:c,level:e}),console.warn(y);break;case"success":y=this.formatConsoleMessage({timestamp:r,icon:a,tag:m,message:fe.green(c),level:e}),console.error(y);break;case"warning":y=this.formatConsoleMessage({timestamp:r,icon:a,tag:m,message:c,level:e}),console.warn(y);break;case"error":if(y=this.formatConsoleMessage({timestamp:r,icon:a,tag:m,message:c,level:e}),console.error(y),l){let w=l.split(`
44
+ `);for(let C of w)if(C.trim()&&!C.includes(s))console.error(this.formatConsoleMessage({timestamp:r,message:fe.gray(` ${C}`),level:e,showTimestamp:!1}))}break}}else if(!Fe()){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}
45
+ `;if(l)u+=`${l}
46
46
  `;if(u=u.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(u)}progress(e,t=""){let i={update:(r,o)=>{},finish:(r)=>{},interrupt:(r,o)=>{}};if(!this.enabled)return i;let n=30;if(this.activeProgressBar={total:Math.max(1,e||1),current:0,message:t||"",barLength:n,lastRenderedLine:""},this.shouldStyleConsole()&&!Fe()&&ye.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(r,o)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,r),this.activeProgressBar.total),o!==void 0)this.activeProgressBar.message=o;if(this.shouldStyleConsole()&&!Fe()&&ye.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(r)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,r)},interrupt:(r,o="info")=>{if(!Fe()&&ye.stdout.isTTY)ye.stdout.write(`
47
- `);if(this[o==="warning"?"warn":o](r),this.activeProgressBar&&this.shouldStyleConsole()&&!Fe()&&ye.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time(e){let t=performance.now();if(this.shouldStyleConsole()){let i=this.options.showTags!==!1&&this.name?ce.gray(this.formatTag(this.name)):"",n=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:n,icon:this.options.showIcons===!1?"":ce.blue("\u25D0"),tag:i,message:`${ce.cyan(e)}...`}))}return async(i)=>{if(!this.enabled)return;let n=performance.now(),r=Math.round(n-t),o=`${e} completed in ${r}ms`,s=new Date,a=this.formatConsoleTimestamp(s),c=`${this.formatFileTimestamp(s)} ${this.environment}.INFO: ${o}`;if(i)c+=` ${JSON.stringify(i)}`;if(c+=`
48
- `,c=c.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let f=this.options.showTags!==!1&&this.name?ce.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:a,icon:this.options.showIcons===!1?"":ce.green("\u2713"),tag:f,message:`${o}${i?` ${JSON.stringify(i)}`:""}`}))}else if(!Fe())console.error(c.trim());if(this.shouldWriteToFile())await this.writeToFile(c)}}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 wr(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(Fe())throw Error("createReadStream is not supported in browser environments");if(!Ji(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return ea(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 n=gt.isBuffer(e)?e:gt.from(e,"base64"),r=n.subarray(0,16),o=n.subarray(n.length-16),s=n.subarray(16,n.length-16),a=iu("aes-256-gcm",i,r);a.setAuthTag(o);let c=a.update(s),f=a.final(),u=c.length+f.length,l=gt.allocUnsafe(u);return c.copy(l,0),f.copy(l,c.length),l.toString("utf8")}catch(n){throw Error(`Decryption failed: ${n instanceof Error?n.message:String(n)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return Fe()}isServerMode(){return!Fe()}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),n=this.formatFileTimestamp(t),{consoleText:r,fileText:o}=this.buildOutputTexts(e);if(this.shouldStyleConsole()){let a=r.split(`
49
- `),c=Math.max(...a.map((m)=>m.length))+2,f=`\u250C${"\u2500".repeat(c)}\u2510`,u=`\u2514${"\u2500".repeat(c)}\u2518`,l=a.map((m)=>this.formatConsoleMessage({timestamp:i,message:ce.cyan(m),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:i,message:ce.cyan(f),showTimestamp:!1})),l.forEach((m)=>console.error(m)),console.error(this.formatConsoleMessage({timestamp:i,message:ce.cyan(u),showTimestamp:!1}))}else if(!Fe())console.error(`${n} ${this.environment}.INFO: [BOX] ${o}`);let s=`${n} ${this.environment}.INFO: [BOX] ${o}
50
- `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(s)}async prompt(e){if(Fe())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${ce.cyan("?")} ${e} (y/n) `);let i=(n)=>{let r=n.toString().trim().toLowerCase();ye.stdin.removeListener("data",i);try{if(typeof ye.stdin.setRawMode==="function")ye.stdin.setRawMode(!1)}catch{}ye.stdin.pause(),console.error(""),t(r==="y"||r==="yes")};try{if(typeof ye.stdin.setRawMode==="function")ye.stdin.setRawMode(!0)}catch{}ye.stdin.resume(),ye.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,a=0;if(i=e.replace(s,(c,f)=>{if(f==="%")return"%";if(a>=t.length)return c;let u=t[a++];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 c}}),a<t.length)i+=` ${t.slice(a).map((c)=>typeof c==="object"?JSON.stringify(c,null,2):String(c)).join(" ")}`}let{consoleText:n,fileText:r}=this.buildOutputTexts(i);if(this.shouldStyleConsole()){let s=this.options.showTags!==!1&&this.name?ce.gray(this.formatTag(this.name)):"",a=this.options.showIcons===!1?"":`${ce.blue("\u25D0")} `;console.error(`${a}${s} ${ce.cyan(n)}`)}let o=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${r}
51
- `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(o)}renderProgressBar(e,t=!1){if(!this.enabled||!this.shouldStyleConsole()||!ye.stdout.isTTY)return;let i=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),n=Math.round(e.barLength*i/100),r=e.barLength-n,o=ce.green("\u2501".repeat(n)),s=ce.gray("\u2501".repeat(r)),a=`[${o}${s}]`,c=`${i}%`.padStart(4),f=e.message?` ${e.message}`:"",u=this.options.showIcons===!1?"":t||i===100?ce.green("\u2713"):ce.blue("\u25B6"),l=this.options.showTags!==!1&&this.name?` ${ce.gray(this.formatTag(this.name))}`:"",m=`\r${u}${l} ${a} ${c}${f}`,y=ye.stdout.columns||80,w=" ".repeat(Math.max(0,y-m.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${m}${w}`,ye.stdout.write(e.lastRenderedLine),t)ye.stdout.write(`
52
- `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||Fe()||!ye.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(Fe()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await qi(this.config.logDirectory),i=[];for(let n of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(n):n.startsWith(this.name))||!n.endsWith(".log"))continue;let r=ti(this.config.logDirectory,n);if(e.before)try{if((await ei(r)).mtime>=e.before)continue}catch(o){console.error(`Failed to get stats for file ${r}:`,o);continue}i.push(r)}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 n of i)try{await Yi(n),console.warn(`Deleted log file: ${n}`)}catch(r){console.error(`Failed to delete log file ${n}:`,r)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}async function Ia(e,t={}){let{maxRetries:i=3,retryDelay:n=1000,isRetryable:r=()=>!0,fallback:o}=t,s=Error("Unknown error occurred");for(let a=0;a<=i;a++)try{return await e()}catch(c){if(s=c instanceof Error?c:Error(String(c)),a===i||!r(s))break;if(n>0)await new Promise((f)=>setTimeout(f,n))}if(o!==void 0)return o;throw s instanceof Error?s:Error(`Unknown error: ${String(s)}`)}function Na(e){return e instanceof Qe}function Uu(e){return e instanceof Er}function Ku(e){if(Na(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 xr{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:n,useCamelCase:r=!0,useBackwardCompatibility:o=!0,customParsers:s={},verbose:a=!1,trackPerformance:c=!0}=i,f=async()=>{if(!e)return{config:t,source:{type:"environment",priority:50,timestamp:new Date}};let u=n||this.generateEnvPrefix(e),l={...t};return this.processObject(l,[],u,{useCamelCase:r,useBackwardCompatibility:o,customParsers:s,verbose:a,configName:e}),{config:l,source:{type:"environment",priority:50,timestamp:new Date}}};if(c)return Si.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,n){for(let[r,o]of Object.entries(e)){let s=[...t,r],a=s.map((u)=>this.formatEnvKey(u,n.useCamelCase)),c=`${i}_${a.join("_")}`,f=n.useBackwardCompatibility?`${i}_${s.map((u)=>u.toUpperCase()).join("_")}`:null;if(n.verbose);if(typeof o==="object"&&o!==null&&!Array.isArray(o))this.processObject(o,s,i,n);else{let u=Zi.env[c]||(f?Zi.env[f]:void 0);if(u!==void 0){if(n.verbose){let l=Zi.env[c]?c:f}try{e[r]=this.parseEnvironmentValue(u,typeof o,c,n.customParsers,n.configName)}catch(l){if(l instanceof vr)throw l;throw Pt.envVar(c,u,typeof o,n.configName)}}}}}parseEnvironmentValue(e,t,i,n,r){for(let[o,s]of Object.entries(n))try{return s(e)}catch{continue}for(let o of this.defaultParsers)if(o.canParse(e,t))try{return o.parse(e)}catch{throw Pt.envVar(i,e,`${t} (via ${o.name} parser)`,r)}return e}getEnvironmentVariables(e){let t={},i=e.toUpperCase();for(let[n,r]of Object.entries(Zi.env))if(n.startsWith(i)&&r!==void 0)t[n]=r;return t}validateEnvironmentVariable(e,t,i){let n=[];if(!/^[A-Z_][A-Z0-9_]*$/.test(e))n.push(`Environment variable key "${e}" should only contain uppercase letters, numbers, and underscores`);if(i)try{this.parseEnvironmentValue(e,t,i,{})}catch(r){n.push(`Cannot parse value "${t}" as ${i}: ${r}`)}return{isValid:n.length===0,errors:n}}generateEnvVarDocs(e,t,i={}){let{prefix:n,format:r="text"}=i,o=n||this.generateEnvPrefix(e),s=[];switch(this.extractEnvVarInfo(t,[],o,s),r){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,n){for(let[r,o]of Object.entries(e)){let s=[...t,r],a=`${i}_${s.map((c)=>this.formatEnvKey(c,!0)).join("_")}`;if(typeof o==="object"&&o!==null&&!Array.isArray(o))this.extractEnvVarInfo(o,s,i,n);else n.push({key:a,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}:
47
+ `);if(this[o==="warning"?"warn":o](r),this.activeProgressBar&&this.shouldStyleConsole()&&!Fe()&&ye.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time(e){let t=performance.now();if(this.shouldStyleConsole()){let i=this.options.showTags!==!1&&this.name?fe.gray(this.formatTag(this.name)):"",n=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:n,icon:this.options.showIcons===!1?"":fe.blue("\u25D0"),tag:i,message:`${fe.cyan(e)}...`}))}return async(i)=>{if(!this.enabled)return;let n=performance.now(),r=Math.round(n-t),o=`${e} completed in ${r}ms`,s=new Date,l=this.formatConsoleTimestamp(s),c=`${this.formatFileTimestamp(s)} ${this.environment}.INFO: ${o}`;if(i)c+=` ${JSON.stringify(i)}`;if(c+=`
48
+ `,c=c.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let f=this.options.showTags!==!1&&this.name?fe.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:l,icon:this.options.showIcons===!1?"":fe.green("\u2713"),tag:f,message:`${o}${i?` ${JSON.stringify(i)}`:""}`}))}else if(!Fe())console.error(c.trim());if(this.shouldWriteToFile())await this.writeToFile(c)}}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 wr(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(Fe())throw Error("createReadStream is not supported in browser environments");if(!Ji(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return ta(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 n=gt.isBuffer(e)?e:gt.from(e,"base64"),r=n.subarray(0,16),o=n.subarray(n.length-16),s=n.subarray(16,n.length-16),l=ru("aes-256-gcm",i,r);l.setAuthTag(o);let c=l.update(s),f=l.final(),u=c.length+f.length,a=gt.allocUnsafe(u);return c.copy(a,0),f.copy(a,c.length),a.toString("utf8")}catch(n){throw Error(`Decryption failed: ${n instanceof Error?n.message:String(n)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return Fe()}isServerMode(){return!Fe()}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),n=this.formatFileTimestamp(t),{consoleText:r,fileText:o}=this.buildOutputTexts(e);if(this.shouldStyleConsole()){let l=r.split(`
49
+ `),c=Math.max(...l.map((m)=>m.length))+2,f=`\u250C${"\u2500".repeat(c)}\u2510`,u=`\u2514${"\u2500".repeat(c)}\u2518`,a=l.map((m)=>this.formatConsoleMessage({timestamp:i,message:fe.cyan(m),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:i,message:fe.cyan(f),showTimestamp:!1})),a.forEach((m)=>console.error(m)),console.error(this.formatConsoleMessage({timestamp:i,message:fe.cyan(u),showTimestamp:!1}))}else if(!Fe())console.error(`${n} ${this.environment}.INFO: [BOX] ${o}`);let s=`${n} ${this.environment}.INFO: [BOX] ${o}
50
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(s)}async prompt(e){if(Fe())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${fe.cyan("?")} ${e} (y/n) `);let i=(n)=>{let r=n.toString().trim().toLowerCase();ye.stdin.removeListener("data",i);try{if(typeof ye.stdin.setRawMode==="function")ye.stdin.setRawMode(!1)}catch{}ye.stdin.pause(),console.error(""),t(r==="y"||r==="yes")};try{if(typeof ye.stdin.setRawMode==="function")ye.stdin.setRawMode(!0)}catch{}ye.stdin.resume(),ye.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,(c,f)=>{if(f==="%")return"%";if(l>=t.length)return c;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 c}}),l<t.length)i+=` ${t.slice(l).map((c)=>typeof c==="object"?JSON.stringify(c,null,2):String(c)).join(" ")}`}let{consoleText:n,fileText:r}=this.buildOutputTexts(i);if(this.shouldStyleConsole()){let s=this.options.showTags!==!1&&this.name?fe.gray(this.formatTag(this.name)):"",l=this.options.showIcons===!1?"":`${fe.blue("\u25D0")} `;console.error(`${l}${s} ${fe.cyan(n)}`)}let o=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${r}
51
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(o)}renderProgressBar(e,t=!1){if(!this.enabled||!this.shouldStyleConsole()||!ye.stdout.isTTY)return;let i=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),n=Math.round(e.barLength*i/100),r=e.barLength-n,o=fe.green("\u2501".repeat(n)),s=fe.gray("\u2501".repeat(r)),l=`[${o}${s}]`,c=`${i}%`.padStart(4),f=e.message?` ${e.message}`:"",u=this.options.showIcons===!1?"":t||i===100?fe.green("\u2713"):fe.blue("\u25B6"),a=this.options.showTags!==!1&&this.name?` ${fe.gray(this.formatTag(this.name))}`:"",m=`\r${u}${a} ${l} ${c}${f}`,y=ye.stdout.columns||80,w=" ".repeat(Math.max(0,y-m.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${m}${w}`,ye.stdout.write(e.lastRenderedLine),t)ye.stdout.write(`
52
+ `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||Fe()||!ye.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(Fe()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await qi(this.config.logDirectory),i=[];for(let n of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(n):n.startsWith(this.name))||!n.endsWith(".log"))continue;let r=ti(this.config.logDirectory,n);if(e.before)try{if((await ei(r)).mtime>=e.before)continue}catch(o){console.error(`Failed to get stats for file ${r}:`,o);continue}i.push(r)}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 n of i)try{await Yi(n),console.warn(`Deleted log file: ${n}`)}catch(r){console.error(`Failed to delete log file ${n}:`,r)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}async function Na(e,t={}){let{maxRetries:i=3,retryDelay:n=1000,isRetryable:r=()=>!0,fallback:o}=t,s=Error("Unknown error occurred");for(let l=0;l<=i;l++)try{return await e()}catch(c){if(s=c instanceof Error?c:Error(String(c)),l===i||!r(s))break;if(n>0)await new Promise((f)=>setTimeout(f,n))}if(o!==void 0)return o;throw s instanceof Error?s:Error(`Unknown error: ${String(s)}`)}function Fa(e){return e instanceof Qe}function Ku(e){return e instanceof br}function Hu(e){if(Fa(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 Ar{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:n,useCamelCase:r=!0,useBackwardCompatibility:o=!0,customParsers:s={},verbose:l=!1,trackPerformance:c=!0}=i,f=async()=>{if(!e)return{config:t,source:{type:"environment",priority:50,timestamp:new Date}};let u=n||this.generateEnvPrefix(e),a={...t};return this.processObject(a,[],u,{useCamelCase:r,useBackwardCompatibility:o,customParsers:s,verbose:l,configName:e}),{config:a,source:{type:"environment",priority:50,timestamp:new Date}}};if(c)return Si.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,n){for(let[r,o]of Object.entries(e)){let s=[...t,r],l=s.map((u)=>this.formatEnvKey(u,n.useCamelCase)),c=`${i}_${l.join("_")}`,f=n.useBackwardCompatibility?`${i}_${s.map((u)=>u.toUpperCase()).join("_")}`:null;if(n.verbose);if(typeof o==="object"&&o!==null&&!Array.isArray(o))this.processObject(o,s,i,n);else{let u=Zi.env[c]||(f?Zi.env[f]:void 0);if(u!==void 0){if(n.verbose){let a=Zi.env[c]?c:f}try{e[r]=this.parseEnvironmentValue(u,typeof o,c,n.customParsers,n.configName)}catch(a){if(a instanceof Er)throw a;throw Pt.envVar(c,u,typeof o,n.configName)}}}}}parseEnvironmentValue(e,t,i,n,r){for(let[o,s]of Object.entries(n))try{return s(e)}catch{continue}for(let o of this.defaultParsers)if(o.canParse(e,t))try{return o.parse(e)}catch{throw Pt.envVar(i,e,`${t} (via ${o.name} parser)`,r)}return e}getEnvironmentVariables(e){let t={},i=e.toUpperCase();for(let[n,r]of Object.entries(Zi.env))if(n.startsWith(i)&&r!==void 0)t[n]=r;return t}validateEnvironmentVariable(e,t,i){let n=[];if(!/^[A-Z_][A-Z0-9_]*$/.test(e))n.push(`Environment variable key "${e}" should only contain uppercase letters, numbers, and underscores`);if(i)try{this.parseEnvironmentValue(e,t,i,{})}catch(r){n.push(`Cannot parse value "${t}" as ${i}: ${r}`)}return{isValid:n.length===0,errors:n}}generateEnvVarDocs(e,t,i={}){let{prefix:n,format:r="text"}=i,o=n||this.generateEnvPrefix(e),s=[];switch(this.extractEnvVarInfo(t,[],o,s),r){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,n){for(let[r,o]of Object.entries(e)){let s=[...t,r],l=`${i}_${s.map((c)=>this.formatEnvKey(c,!0)).join("_")}`;if(typeof o==="object"&&o!==null&&!Array.isArray(o))this.extractEnvVarInfo(o,s,i,n);else n.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}:
53
53
 
54
54
  `;for(let n of e)i+=`${n.key}
55
55
  `,i+=` Type: ${n.type}
@@ -61,25 +61,25 @@ ${Ki}/
61
61
  `;i+=`| Variable | Type | Description | Example |
62
62
  `,i+=`|----------|------|-------------|----------|
63
63
  `;for(let n of e)i+=`| \`${n.key}\` | ${n.type} | ${n.description} | \`${n.example}\` |
64
- `;return i}}function Hu(e,t){let i=Ga("process");if(typeof i>"u"||!i.env)return t;let n=i.env[e];return n!==void 0?n:t}function Fa(e,t,i={}){return La(e,t,i,new WeakMap)}function La(e,t,i,n){let{arrayMergeMode:r="replace",skipNullish:o=!1,customMerger:s}=i;if(t===null||t===void 0)return o?e:t;if(s){let a=s(e,t);if(a!==void 0)return a}if(Array.isArray(t)||Array.isArray(e))return Wa(e,t,r,n);if(!ot(t)||!ot(e))return t;return Yu(e,t,i,n)}function Wa(e,t,i,n){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 zu(e,t);case"smart":return Ju(e,t,n);default:return t}return t}function zu(e,t){let i=[...t];for(let n of e)if(!i.some((r)=>Hn(r,n)))i.push(n);return i}function Ju(e,t,i){if(t.length===0)return e;if(e.length===0)return t;if(ot(t[0])&&ot(e[0]))return qu(e,t,i);if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let r of e)if(!n.includes(r))n.push(r);return n}return t}function qu(e,t,i){let n=[...t];for(let r of e){if(!ot(r)){n.push(r);continue}let o=["id","name","key","path","type"],s=!1;for(let a of o)if(a in r){if(n.find((c)=>ot(c)&&(a in c)&&c[a]===r[a])){s=!0;break}}if(!s)n.push(r)}return n}function Yu(e,t,i,n){let r=t;if(ot(r)&&n.has(r))return n.get(r);let o={...e};if(ot(r))n.set(r,o);for(let s in r){if(!Object.prototype.hasOwnProperty.call(r,s))continue;let a=r[s],c=o[s];if(i.skipNullish&&(a===null||a===void 0))continue;if(a===null||a===void 0){o[s]=a;continue}if(ot(a)&&ot(c))o[s]=La(c,a,i,n);else if(Array.isArray(a)||Array.isArray(c))o[s]=Wa(c,a,i.arrayMergeMode||"smart",n);else o[s]=a}return o}function ao(e,t,i="replace"){return Fa(e,t,{arrayMergeMode:i==="replace"?"replace":"smart",skipNullish:!0})}function Hn(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(!Hn(e[i],t[i]))return!1;return!0}if(ot(e)&&ot(t)){let i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return!1;for(let r of i){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!Hn(e[r],t[r]))return!1}return!0}return!1}function ot(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class Tr{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(e,t,i={}){let{arrayStrategy:n="replace",useCache:r=!0,cacheTtl:o,trackPerformance:s=!0,verbose:a=!1}=i;if(r){let f=si.getWithFileCheck("file",e);if(f){if(a)console.log(`Configuration loaded from cache: ${e}`);return f}}let c=async()=>{if(!Xi(e))return null;try{let f=`?t=${Date.now()}`,u=await import(e+f),l=u.default||u,m="default"in u,y=Object.keys(u).length>0;if(!m&&!y)throw new vi(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof l!=="object"||l===null||Array.isArray(l))throw new vi(e,Error("Configuration must export a valid object"),"unknown");let w={config:ao(t,l,n),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(r)si.setWithFileCheck("file",w,e,o);return w}catch(f){throw f instanceof Error?Pt.configLoad(e,f):Pt.configLoad(e,Error(String(f)))}};if(s)return Si.track("loadFromPath",c,{path:e});return c()}async tryLoadFromPaths(e,t,i={}){for(let n of e)try{let r=await this.loadFromPath(n,t,i);if(r)return r}catch(r){if(r instanceof Error&&r.name==="ConfigLoadError")throw r;if(i.verbose)console.warn(`Failed to load config from ${n}:`,r)}return null}generateConfigPaths(e,t,i){let n=this.generateNamePatterns(e,i),r=[];for(let o of n)for(let s of this.extensions)r.push(Dn(t,`${o}${s}`));return r}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 Ia(async()=>Xi(e),{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,t,i){let n=[];if(!Xi(e))return n;if(t||i){let r=this.generateNamePatterns(t||"",i);for(let o of r)for(let s of this.extensions){let a=Dn(e,`${o}${s}`);if(await this.checkFileAccess(a))n.push(a)}}else try{let{readdirSync:r}=await import("fs"),o=r(e);for(let s of o)if(this.looksLikeConfigFile(s)){let a=Dn(e,s);if(await this.checkFileAccess(a))n.push(a)}}catch{return[]}return n}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(!Xi(e))return t.push("Configuration file does not exist"),t;let i=await import(e),n=i.default||i;if(n===void 0)t.push("Configuration file must export a default value or named exports");else if(typeof n!=="object"||n===null)t.push("Configuration must be an object");else if(Array.isArray(n))t.push("Configuration cannot be an array at the root level");if(e.endsWith(".json"))try{let{readFileSync:r}=await import("fs"),o=r(e,"utf8");JSON.parse(o)}catch(r){t.push(`Invalid JSON syntax: ${r}`)}}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(n)=>{try{let r=await this.loadFromPath(n,{},t);if(r)i.set(n,r.config)}catch(r){if(t.verbose)console.warn(`Failed to preload ${n}:`,r)}})),i}}class lo{async validateConfiguration(e,t,i={}){let{stopOnFirstError:n=!1,validateRequired:r=!0,validateTypes:o=!0,customRules:s=[],trackPerformance:a=!0,verbose:c=!1}=i,f=async()=>{let u=[],l=[],m={stopOnFirstError:n,validateRequired:r,validateTypes:o,customRules:s,trackPerformance:a,verbose:c};try{if(typeof t==="string")return await this.validateWithSchemaFile(e,t,m);else if(Array.isArray(t))return this.validateWithRules(e,[...t,...s],m);else return this.validateWithJSONSchema(e,t,m)}catch(y){return u.push({path:"",message:`Validation failed: ${y}`,rule:"system"}),{isValid:!1,errors:u,warnings:l}}};if(a)return await Si.track("validateConfiguration",f);return f()}async validateWithSchemaFile(e,t,i){try{if(!fu(t))throw new bi(t,[{path:"",message:"Schema file does not exist"}]);let n=await import(t),r=n.default||n;if(Array.isArray(r))return this.validateWithRules(e,r,i);else return this.validateWithJSONSchema(e,r,i)}catch(n){throw new bi(t,[{path:"",message:`Failed to load schema: ${n}`}])}}validateWithJSONSchema(e,t,i){let n=[],r=[];return this.validateObjectAgainstSchema(e,t,"",n,r,i),{isValid:n.length===0,errors:n,warnings:r}}validateObjectAgainstSchema(e,t,i,n,r,o){if(o.validateTypes&&t.type){let s=Array.isArray(e)?"array":typeof e,a=Array.isArray(t.type)?t.type:[t.type];if(!a.includes(s)){if(n.push({path:i,message:`Expected type ${a.join(" or ")}, got ${s}`,expected:a.join(" or "),actual:s,rule:"type"}),o.stopOnFirstError)return}}if(t.enum&&!t.enum.includes(e)){if(n.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)n.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)n.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))n.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)n.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)n.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 a=i?`${i}[${s}]`:`[${s}]`;if(this.validateObjectAgainstSchema(e[s],t.items,a,n,r,o),o.stopOnFirstError&&n.length>0)return}if(e&&typeof e==="object"&&!Array.isArray(e)){let s=e;if(o.validateRequired&&t.required){for(let a of t.required)if(!(a in s)){if(n.push({path:i?`${i}.${a}`:a,message:`Missing required property '${a}'`,expected:"required",rule:"required"}),o.stopOnFirstError)return}}if(t.properties){for(let[a,c]of Object.entries(t.properties))if(a in s){let f=i?`${i}.${a}`:a;if(this.validateObjectAgainstSchema(s[a],c,f,n,r,o),o.stopOnFirstError&&n.length>0)return}}if(t.additionalProperties===!1){let a=new Set(Object.keys(t.properties||{}));for(let c of Object.keys(s))if(!a.has(c))r.push({path:i?`${i}.${c}`:c,message:`Additional property '${c}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(e,t,i){let n=[],r=[];for(let o of t)try{let s=this.getValueByPath(e,o.path),a=this.validateWithRule(s,o,o.path);if(n.push(...a),i.stopOnFirstError&&n.length>0)break}catch(s){n.push({path:o.path,message:`Rule validation failed: ${s}`,rule:"system"})}return{isValid:n.length===0,errors:n,warnings:r}}validateWithRule(e,t,i){let n=[];if(t.required&&(e===void 0||e===null))return n.push({path:i,message:t.message||`Property '${i}' is required`,expected:"required",rule:"required"}),n;if(e===void 0||e===null)return n;if(t.type){let r=Array.isArray(e)?"array":typeof e;if(r!==t.type)n.push({path:i,message:t.message||`Expected type ${t.type}, got ${r}`,expected:t.type,actual:r,rule:"type"})}if(t.min!==void 0){let r=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(r<t.min)n.push({path:i,message:t.message||`Value must be at least ${t.min}`,expected:`>= ${t.min}`,actual:r,rule:"min"})}if(t.max!==void 0){let r=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(r>t.max)n.push({path:i,message:t.message||`Value must not exceed ${t.max}`,expected:`<= ${t.max}`,actual:r,rule:"max"})}if(t.pattern&&typeof e==="string"){if(!t.pattern.test(e))n.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))n.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 r=t.validator(e);if(r)n.push({path:i,message:t.message||r,rule:"custom"})}return n}getValueByPath(e,t){if(!t)return e;let i=t.split("."),n=e;for(let r of i)if(n&&typeof n==="object"&&r in n)n=n[r];else return;return n}generateRulesFromInterface(e){let t=[],i=e.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let n of i){let[,r,o,s]=n;t.push({path:r,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:Ka},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}class co{fileLoader=new Tr;envProcessor=new xr;validator=new lo;async loadConfig(e){let t=Date.now(),{cache:i,performance:n,schema:r,validate:o,...s}=e;try{if(i?.enabled){let c=this.checkCache(s.name||"",s);if(c)return c}let a;try{a=await this.loadConfigurationStrategies(s,!0,i)}catch(c){let f=s.__strictErrorHandling;if(c instanceof Error&&c.name==="ConfigNotFoundError"){if(f)throw c;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(c instanceof Error&&c.name==="ConfigLoadError"){let u=c.message.includes("EACCES")||c.message.includes("EPERM")||c.message.includes("permission denied"),l=!u&&(c.message.includes("syntax")||c.message.includes("Expected")||c.message.includes("Unexpected")||c.message.includes("BuildMessage")||c.message.includes("errors building")),m=c.message.includes("Configuration must export a valid object")||c.message.includes("Configuration file is empty and exports nothing");if(f&&(m||u))throw c;if(l&&(!f||!m))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(!f)a={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`Configuration loading error, using defaults: ${c.message}`]};else throw c}else a={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${c instanceof Error?c.message:String(c)}`]}}if(r||o)await this.validateConfiguration(a.config,r,o,s.name);if(i?.enabled&&a)this.cacheResult(s.name||"",a,i,s);if(n?.enabled){let c={operation:"loadConfig",duration:Date.now()-t,configName:s.name,timestamp:new Date};if(n.onMetrics)n.onMetrics(c);if(n.slowThreshold&&c.duration>n.slowThreshold)lt.warn(`Slow configuration loading detected: ${c.duration}ms for ${s.name}`);a.metrics=c}return a}catch(a){let c=Date.now()-t;throw lt.error(`Configuration loading failed after ${c}ms:`,[a instanceof Error?a:Error(String(a))]),a}}async loadConfigurationStrategies(e,t=!1,i){let{name:n="",alias:r,cwd:o,configDir:s,defaultConfig:a,checkEnv:c=!0,arrayStrategy:f="replace",verbose:u=!1}=e,l=o||Ft.cwd(),m=[],y=await this.loadLocalConfiguration(n,r,l,s,a,f,u,c,i);if(y)return m.push(...this.getLocalSearchPaths(n,r,l,s)),this.finalizeResult(y,m,c,n,u);let w=await this.loadHomeConfiguration(n,r,a,f,u,c);if(w)return m.push(...this.getHomeSearchPaths(n,r)),this.finalizeResult(w,m,c,n,u);let C=await this.loadPackageJsonConfiguration(n,r,l,a,f,u,c);if(C)return m.push(qe(l,"package.json")),this.finalizeResult(C,m,c,n,u);if(m.push(...this.getAllSearchPaths(n,r,l,s)),t)throw Pt.configNotFound(n,m,r);return{...await this.applyEnvironmentVariables(n,a,c,u),warnings:[`No configuration file found for "${n}"${r?` or alias "${r}"`:""}, using defaults with environment variables`]}}async loadLocalConfiguration(e,t,i,n,r,o,s,a,c){let f=a?wi(e,r,s):r,u=this.getLocalDirectories(i,n);for(let l of u){if(s)lt.info(`Searching for configuration in: ${l}`);let m=this.fileLoader.generateConfigPaths(e,l,t),y=await this.fileLoader.tryLoadFromPaths(m,f,{arrayStrategy:o,verbose:s,cacheTtl:c?.ttl,useCache:!c?.ttl||c.ttl>100});if(y){if(s)lt.success(`Configuration loaded from: ${y.source.path}`);return y}}return null}async loadHomeConfiguration(e,t,i,n,r,o){if(!e)return null;let s=o?wi(e,i,r):i,a=[qe(Yt(),".config",e),qe(Yt(),".config"),Yt()];for(let c of a){if(r)lt.info(`Checking home directory: ${c}`);let f=this.fileLoader.generateConfigPaths(e,c,t),u=await this.fileLoader.tryLoadFromPaths(f,s,{arrayStrategy:n,verbose:r});if(u){if(r)lt.success(`Configuration loaded from home directory: ${u.source.path}`);return u}}return null}async loadPackageJsonConfiguration(e,t,i,n,r,o,s){let a=s?wi(e,n,o):n;try{let c=qe(i,"package.json");if(!Un(c))return null;let f=await import(c),u=f[e],l=e;if(!u&&t)u=f[t],l=t;if(u&&typeof u==="object"&&!Array.isArray(u)){if(o)lt.success(`Configuration loaded from package.json: ${l}`);return{config:ao(a,u,r),source:{type:"package.json",path:c,priority:30,timestamp:new Date}}}}catch(c){if(o)lt.warn("Failed to load package.json:",[c instanceof Error?c:Error(String(c))])}return null}async applyEnvironmentVariables(e,t,i,n){if(!i||!e||typeof t!=="object"||t===null||Array.isArray(t))return{config:t,source:{type:"default",priority:10,timestamp:new Date}};return{config:wi(e,t,n),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(e,t,i,n,r){return{config:e.config,source:e.source,path:e.source.path}}async validateConfiguration(e,t,i,n){let r=[];if(i){let o=i(e);if(o)r.push(...o)}if(t){let o=await this.validator.validateConfiguration(e,t);if(!o.isValid)r.push(...o.errors.map((s)=>s.path?`${s.path}: ${s.message}`:s.message))}if(r.length>0)throw Pt.configValidation(n||"unknown",r,n)}checkCache(e,t){let i=this.generateCacheKey(e,t);return si.get(i)||null}cacheResult(e,t,i,n){let r=this.generateCacheKey(e,n);si.set(r,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,qe(e,"config"),qe(e,".config"),t?qe(e,t):void 0].filter(Boolean)))}getAllSearchPaths(e,t,i,n){let r=[];return r.push(...this.getLocalSearchPaths(e,t,i,n)),r.push(...this.getHomeSearchPaths(e,t)),r.push(qe(i,"package.json")),r}getLocalSearchPaths(e,t,i,n){let r=this.getLocalDirectories(i,n),o=[];for(let s of r)o.push(...this.fileLoader.generateConfigPaths(e,s,t));return o}getHomeSearchPaths(e,t){if(!e)return[];let i=[qe(Yt(),".config",e),qe(Yt(),".config"),Yt()],n=[];for(let r of i)n.push(...this.fileLoader.generateConfigPaths(e,r,t));return n}async loadConfigWithResult(e){return this.loadConfig(e)}}function pa(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 Zu(e){return bt.loadConfig({...e,__strictErrorHandling:!0})}async function Ba(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 n;if(i)n=await bt.loadConfig(e);else n=await bt.loadConfig({...e,defaultConfig:t,cache:{enabled:!0},performance:{enabled:!1}});return n?.config??t}catch(n){let r=n instanceof Error?n.name:"UnknownError",o=n instanceof Error?n.message:String(n);if(!(r==="ConfigNotFoundError"||r==="ConfigLoadError"||r==="ConfigValidationError"||o.includes("config"))&&e.verbose)lt.warn("Unexpected error loading config, using defaults:",[n instanceof Error?n:Error(String(n))]);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 bt.applyEnvironmentVariables(s.name||"",t,!0,s.verbose||!1))?.config??t;return t}}async function Xu(e={defaultConfig:{}}){if(typeof e==="string"){let{cwd:t}=await import("process");try{return(await bt.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"&&pa(i)))return(await bt.applyEnvironmentVariables(e,{},!0,!1)).config;throw i}}try{return(await bt.loadConfig({...e,cwd:e.cwd||Ft.cwd(),cache:{enabled:!0},performance:{enabled:!1}})).config}catch(t){if(t instanceof Error&&(t.name==="ConfigNotFoundError"||t.name==="ConfigLoadError"&&pa(t)))return(await bt.applyEnvironmentVariables(e.name||"",e.defaultConfig||{},e.checkEnv!==!1,e.verbose||!1)).config;throw t}}async function Qu(e,t,i="replace"){let n=new Tr;try{let r=await n.loadFromPath(e,t,{arrayStrategy:i,useCache:!1,trackPerformance:!1});return r?r.config:null}catch{return null}}function wi(e,t,i=!1){let n=new xr,r=e.toUpperCase().replace(/[^A-Z0-9]/g,"_");function o(s,a=[]){let c={...s};for(let[f,u]of Object.entries(s)){let l=[...a,f],m=[`${r}_${l.join("_").toUpperCase()}`,`${r}_${l.map((C)=>C.toUpperCase()).join("")}`,`${r}_${l.map((C)=>C.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],y,w;for(let C of m)if(y=Ft.env[C],y!==void 0){w=C;break}if(y!==void 0&&w)if(typeof u==="boolean")c[f]=["true","1","yes"].includes(y.toLowerCase());else if(typeof u==="number"){let C=Number(y);if(!Number.isNaN(C))c[f]=C}else if(Array.isArray(u))try{c[f]=JSON.parse(y)}catch{c[f]=y.split(",").map((C)=>C.trim())}else c[f]=y;else if(u&&typeof u==="object"&&!Array.isArray(u))c[f]=o(u,l)}return c}return o(t)}function eh(e){let t=qe(Ft.cwd(),e.configDir),i=qe(Ft.cwd(),e.generatedDir),n=qe(i,"config-types.ts");if(!Un(Ks(n)))jf(Ks(n),{recursive:!0,mode:511});let r=Un(t)?_f(t).map((s)=>s.replace(/\.(ts|js|mjs|cjs|mts|cts|json)$/,"")).sort():[],o=`// Generated by bunfig v${Rh}
64
+ `;return i}}function zu(e,t){let i=ja("process");if(typeof i>"u"||!i.env)return t;let n=i.env[e];return n!==void 0?n:t}function La(e,t,i={}){return Wa(e,t,i,new WeakMap)}function Wa(e,t,i,n){let{arrayMergeMode:r="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 Ba(e,t,r,n);if(!ot(t)||!ot(e))return t;return Zu(e,t,i,n)}function Ba(e,t,i,n){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 Ju(e,t);case"smart":return qu(e,t,n);default:return t}return t}function Ju(e,t){let i=[...t];for(let n of e)if(!i.some((r)=>Hn(r,n)))i.push(n);return i}function qu(e,t,i){if(t.length===0)return e;if(e.length===0)return t;if(ot(t[0])&&ot(e[0]))return Yu(e,t,i);if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let r of e)if(!n.includes(r))n.push(r);return n}return t}function Yu(e,t,i){let n=[...t];for(let r of e){if(!ot(r)){n.push(r);continue}let o=["id","name","key","path","type"],s=!1;for(let l of o)if(l in r){if(n.find((c)=>ot(c)&&(l in c)&&c[l]===r[l])){s=!0;break}}if(!s)n.push(r)}return n}function Zu(e,t,i,n){let r=t;if(ot(r)&&n.has(r))return n.get(r);let o={...e};if(ot(r))n.set(r,o);for(let s in r){if(!Object.prototype.hasOwnProperty.call(r,s))continue;let l=r[s],c=o[s];if(i.skipNullish&&(l===null||l===void 0))continue;if(l===null||l===void 0){o[s]=l;continue}if(ot(l)&&ot(c))o[s]=Wa(c,l,i,n);else if(Array.isArray(l)||Array.isArray(c))o[s]=Ba(c,l,i.arrayMergeMode||"smart",n);else o[s]=l}return o}function ao(e,t,i="replace"){return La(e,t,{arrayMergeMode:i==="replace"?"replace":"smart",skipNullish:!0})}function Hn(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(!Hn(e[i],t[i]))return!1;return!0}if(ot(e)&&ot(t)){let i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return!1;for(let r of i){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!Hn(e[r],t[r]))return!1}return!0}return!1}function ot(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class Tr{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(e,t,i={}){let{arrayStrategy:n="replace",useCache:r=!0,cacheTtl:o,trackPerformance:s=!0,verbose:l=!1}=i;if(r){let f=si.getWithFileCheck("file",e);if(f){if(l)console.log(`Configuration loaded from cache: ${e}`);return f}}let c=async()=>{if(!Xi(e))return null;try{let f=`?t=${Date.now()}`,u=await import(e+f),a=u.default||u,m="default"in u,y=Object.keys(u).length>0;if(!m&&!y)throw new Ei(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof a!=="object"||a===null||Array.isArray(a))throw new Ei(e,Error("Configuration must export a valid object"),"unknown");let w={config:ao(t,a,n),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(r)si.setWithFileCheck("file",w,e,o);return w}catch(f){throw f instanceof Error?Pt.configLoad(e,f):Pt.configLoad(e,Error(String(f)))}};if(s)return Si.track("loadFromPath",c,{path:e});return c()}async tryLoadFromPaths(e,t,i={}){for(let n of e)try{let r=await this.loadFromPath(n,t,i);if(r)return r}catch(r){if(r instanceof Error&&r.name==="ConfigLoadError")throw r;if(i.verbose)console.warn(`Failed to load config from ${n}:`,r)}return null}generateConfigPaths(e,t,i){let n=this.generateNamePatterns(e,i),r=[];for(let o of n)for(let s of this.extensions)r.push(Dn(t,`${o}${s}`));return r}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 Na(async()=>Xi(e),{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,t,i){let n=[];if(!Xi(e))return n;if(t||i){let r=this.generateNamePatterns(t||"",i);for(let o of r)for(let s of this.extensions){let l=Dn(e,`${o}${s}`);if(await this.checkFileAccess(l))n.push(l)}}else try{let{readdirSync:r}=await import("fs"),o=r(e);for(let s of o)if(this.looksLikeConfigFile(s)){let l=Dn(e,s);if(await this.checkFileAccess(l))n.push(l)}}catch{return[]}return n}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(!Xi(e))return t.push("Configuration file does not exist"),t;let i=await import(e),n=i.default||i;if(n===void 0)t.push("Configuration file must export a default value or named exports");else if(typeof n!=="object"||n===null)t.push("Configuration must be an object");else if(Array.isArray(n))t.push("Configuration cannot be an array at the root level");if(e.endsWith(".json"))try{let{readFileSync:r}=await import("fs"),o=r(e,"utf8");JSON.parse(o)}catch(r){t.push(`Invalid JSON syntax: ${r}`)}}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(n)=>{try{let r=await this.loadFromPath(n,{},t);if(r)i.set(n,r.config)}catch(r){if(t.verbose)console.warn(`Failed to preload ${n}:`,r)}})),i}}class lo{async validateConfiguration(e,t,i={}){let{stopOnFirstError:n=!1,validateRequired:r=!0,validateTypes:o=!0,customRules:s=[],trackPerformance:l=!0,verbose:c=!1}=i,f=async()=>{let u=[],a=[],m={stopOnFirstError:n,validateRequired:r,validateTypes:o,customRules:s,trackPerformance:l,verbose:c};try{if(typeof t==="string")return await this.validateWithSchemaFile(e,t,m);else if(Array.isArray(t))return this.validateWithRules(e,[...t,...s],m);else return this.validateWithJSONSchema(e,t,m)}catch(y){return u.push({path:"",message:`Validation failed: ${y}`,rule:"system"}),{isValid:!1,errors:u,warnings:a}}};if(l)return await Si.track("validateConfiguration",f);return f()}async validateWithSchemaFile(e,t,i){try{if(!uu(t))throw new vi(t,[{path:"",message:"Schema file does not exist"}]);let n=await import(t),r=n.default||n;if(Array.isArray(r))return this.validateWithRules(e,r,i);else return this.validateWithJSONSchema(e,r,i)}catch(n){throw new vi(t,[{path:"",message:`Failed to load schema: ${n}`}])}}validateWithJSONSchema(e,t,i){let n=[],r=[];return this.validateObjectAgainstSchema(e,t,"",n,r,i),{isValid:n.length===0,errors:n,warnings:r}}validateObjectAgainstSchema(e,t,i,n,r,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(n.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(n.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)n.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)n.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))n.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)n.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)n.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,n,r,o),o.stopOnFirstError&&n.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(n.push({path:i?`${i}.${l}`:l,message:`Missing required property '${l}'`,expected:"required",rule:"required"}),o.stopOnFirstError)return}}if(t.properties){for(let[l,c]of Object.entries(t.properties))if(l in s){let f=i?`${i}.${l}`:l;if(this.validateObjectAgainstSchema(s[l],c,f,n,r,o),o.stopOnFirstError&&n.length>0)return}}if(t.additionalProperties===!1){let l=new Set(Object.keys(t.properties||{}));for(let c of Object.keys(s))if(!l.has(c))r.push({path:i?`${i}.${c}`:c,message:`Additional property '${c}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(e,t,i){let n=[],r=[];for(let o of t)try{let s=this.getValueByPath(e,o.path),l=this.validateWithRule(s,o,o.path);if(n.push(...l),i.stopOnFirstError&&n.length>0)break}catch(s){n.push({path:o.path,message:`Rule validation failed: ${s}`,rule:"system"})}return{isValid:n.length===0,errors:n,warnings:r}}validateWithRule(e,t,i){let n=[];if(t.required&&(e===void 0||e===null))return n.push({path:i,message:t.message||`Property '${i}' is required`,expected:"required",rule:"required"}),n;if(e===void 0||e===null)return n;if(t.type){let r=Array.isArray(e)?"array":typeof e;if(r!==t.type)n.push({path:i,message:t.message||`Expected type ${t.type}, got ${r}`,expected:t.type,actual:r,rule:"type"})}if(t.min!==void 0){let r=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(r<t.min)n.push({path:i,message:t.message||`Value must be at least ${t.min}`,expected:`>= ${t.min}`,actual:r,rule:"min"})}if(t.max!==void 0){let r=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(r>t.max)n.push({path:i,message:t.message||`Value must not exceed ${t.max}`,expected:`<= ${t.max}`,actual:r,rule:"max"})}if(t.pattern&&typeof e==="string"){if(!t.pattern.test(e))n.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))n.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 r=t.validator(e);if(r)n.push({path:i,message:t.message||r,rule:"custom"})}return n}getValueByPath(e,t){if(!t)return e;let i=t.split("."),n=e;for(let r of i)if(n&&typeof n==="object"&&r in n)n=n[r];else return;return n}generateRulesFromInterface(e){let t=[],i=e.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let n of i){let[,r,o,s]=n;t.push({path:r,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:Ha},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}class co{fileLoader=new Tr;envProcessor=new Ar;validator=new lo;async loadConfig(e){let t=Date.now(),{cache:i,performance:n,schema:r,validate:o,...s}=e;try{if(i?.enabled){let c=this.checkCache(s.name||"",s);if(c)return c}let l;try{l=await this.loadConfigurationStrategies(s,!0,i)}catch(c){let f=s.__strictErrorHandling;if(c instanceof Error&&c.name==="ConfigNotFoundError"){if(f)throw c;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(c instanceof Error&&c.name==="ConfigLoadError"){let u=c.message.includes("EACCES")||c.message.includes("EPERM")||c.message.includes("permission denied"),a=!u&&(c.message.includes("syntax")||c.message.includes("Expected")||c.message.includes("Unexpected")||c.message.includes("BuildMessage")||c.message.includes("errors building")),m=c.message.includes("Configuration must export a valid object")||c.message.includes("Configuration file is empty and exports nothing");if(f&&(m||u))throw c;if(a&&(!f||!m))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: ${c.message}`]};else throw c}else l={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${c instanceof Error?c.message:String(c)}`]}}if(r||o)await this.validateConfiguration(l.config,r,o,s.name);if(i?.enabled&&l)this.cacheResult(s.name||"",l,i,s);if(n?.enabled){let c={operation:"loadConfig",duration:Date.now()-t,configName:s.name,timestamp:new Date};if(n.onMetrics)n.onMetrics(c);if(n.slowThreshold&&c.duration>n.slowThreshold)ct.warn(`Slow configuration loading detected: ${c.duration}ms for ${s.name}`);l.metrics=c}return l}catch(l){let c=Date.now()-t;throw ct.error(`Configuration loading failed after ${c}ms:`,[l instanceof Error?l:Error(String(l))]),l}}async loadConfigurationStrategies(e,t=!1,i){let{name:n="",alias:r,cwd:o,configDir:s,defaultConfig:l,checkEnv:c=!0,arrayStrategy:f="replace",verbose:u=!1}=e,a=o||Ft.cwd(),m=[],y=await this.loadLocalConfiguration(n,r,a,s,l,f,u,c,i);if(y)return m.push(...this.getLocalSearchPaths(n,r,a,s)),this.finalizeResult(y,m,c,n,u);let w=await this.loadHomeConfiguration(n,r,l,f,u,c);if(w)return m.push(...this.getHomeSearchPaths(n,r)),this.finalizeResult(w,m,c,n,u);let C=await this.loadPackageJsonConfiguration(n,r,a,l,f,u,c);if(C)return m.push(qe(a,"package.json")),this.finalizeResult(C,m,c,n,u);if(m.push(...this.getAllSearchPaths(n,r,a,s)),t)throw Pt.configNotFound(n,m,r);return{...await this.applyEnvironmentVariables(n,l,c,u),warnings:[`No configuration file found for "${n}"${r?` or alias "${r}"`:""}, using defaults with environment variables`]}}async loadLocalConfiguration(e,t,i,n,r,o,s,l,c){let f=l?wi(e,r,s):r,u=this.getLocalDirectories(i,n);for(let a of u){if(s)ct.info(`Searching for configuration in: ${a}`);let m=this.fileLoader.generateConfigPaths(e,a,t),y=await this.fileLoader.tryLoadFromPaths(m,f,{arrayStrategy:o,verbose:s,cacheTtl:c?.ttl,useCache:!c?.ttl||c.ttl>100});if(y){if(s)ct.success(`Configuration loaded from: ${y.source.path}`);return y}}return null}async loadHomeConfiguration(e,t,i,n,r,o){if(!e)return null;let s=o?wi(e,i,r):i,l=[qe(Yt(),".config",e),qe(Yt(),".config"),Yt()];for(let c of l){if(r)ct.info(`Checking home directory: ${c}`);let f=this.fileLoader.generateConfigPaths(e,c,t),u=await this.fileLoader.tryLoadFromPaths(f,s,{arrayStrategy:n,verbose:r});if(u){if(r)ct.success(`Configuration loaded from home directory: ${u.source.path}`);return u}}return null}async loadPackageJsonConfiguration(e,t,i,n,r,o,s){let l=s?wi(e,n,o):n;try{let c=qe(i,"package.json");if(!Un(c))return null;let f=await import(c),u=f[e],a=e;if(!u&&t)u=f[t],a=t;if(u&&typeof u==="object"&&!Array.isArray(u)){if(o)ct.success(`Configuration loaded from package.json: ${a}`);return{config:ao(l,u,r),source:{type:"package.json",path:c,priority:30,timestamp:new Date}}}}catch(c){if(o)ct.warn("Failed to load package.json:",[c instanceof Error?c:Error(String(c))])}return null}async applyEnvironmentVariables(e,t,i,n){if(!i||!e||typeof t!=="object"||t===null||Array.isArray(t))return{config:t,source:{type:"default",priority:10,timestamp:new Date}};return{config:wi(e,t,n),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(e,t,i,n,r){return{config:e.config,source:e.source,path:e.source.path}}async validateConfiguration(e,t,i,n){let r=[];if(i){let o=i(e);if(o)r.push(...o)}if(t){let o=await this.validator.validateConfiguration(e,t);if(!o.isValid)r.push(...o.errors.map((s)=>s.path?`${s.path}: ${s.message}`:s.message))}if(r.length>0)throw Pt.configValidation(n||"unknown",r,n)}checkCache(e,t){let i=this.generateCacheKey(e,t);return si.get(i)||null}cacheResult(e,t,i,n){let r=this.generateCacheKey(e,n);si.set(r,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,qe(e,"config"),qe(e,".config"),t?qe(e,t):void 0].filter(Boolean)))}getAllSearchPaths(e,t,i,n){let r=[];return r.push(...this.getLocalSearchPaths(e,t,i,n)),r.push(...this.getHomeSearchPaths(e,t)),r.push(qe(i,"package.json")),r}getLocalSearchPaths(e,t,i,n){let r=this.getLocalDirectories(i,n),o=[];for(let s of r)o.push(...this.fileLoader.generateConfigPaths(e,s,t));return o}getHomeSearchPaths(e,t){if(!e)return[];let i=[qe(Yt(),".config",e),qe(Yt(),".config"),Yt()],n=[];for(let r of i)n.push(...this.fileLoader.generateConfigPaths(e,r,t));return n}async loadConfigWithResult(e){return this.loadConfig(e)}}function ma(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 Xu(e){return vt.loadConfig({...e,__strictErrorHandling:!0})}async function Ga(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 n;if(i)n=await vt.loadConfig(e);else n=await vt.loadConfig({...e,defaultConfig:t,cache:{enabled:!0},performance:{enabled:!1}});return n?.config??t}catch(n){let r=n instanceof Error?n.name:"UnknownError",o=n instanceof Error?n.message:String(n);if(!(r==="ConfigNotFoundError"||r==="ConfigLoadError"||r==="ConfigValidationError"||o.includes("config"))&&e.verbose)ct.warn("Unexpected error loading config, using defaults:",[n instanceof Error?n:Error(String(n))]);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 vt.applyEnvironmentVariables(s.name||"",t,!0,s.verbose||!1))?.config??t;return t}}async function Qu(e={defaultConfig:{}}){if(typeof e==="string"){let{cwd:t}=await import("process");try{return(await vt.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"&&ma(i)))return(await vt.applyEnvironmentVariables(e,{},!0,!1)).config;throw i}}try{return(await vt.loadConfig({...e,cwd:e.cwd||Ft.cwd(),cache:{enabled:!0},performance:{enabled:!1}})).config}catch(t){if(t instanceof Error&&(t.name==="ConfigNotFoundError"||t.name==="ConfigLoadError"&&ma(t)))return(await vt.applyEnvironmentVariables(e.name||"",e.defaultConfig||{},e.checkEnv!==!1,e.verbose||!1)).config;throw t}}async function eh(e,t,i="replace"){let n=new Tr;try{let r=await n.loadFromPath(e,t,{arrayStrategy:i,useCache:!1,trackPerformance:!1});return r?r.config:null}catch{return null}}function wi(e,t,i=!1){let n=new Ar,r=e.toUpperCase().replace(/[^A-Z0-9]/g,"_");function o(s,l=[]){let c={...s};for(let[f,u]of Object.entries(s)){let a=[...l,f],m=[`${r}_${a.join("_").toUpperCase()}`,`${r}_${a.map((C)=>C.toUpperCase()).join("")}`,`${r}_${a.map((C)=>C.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],y,w;for(let C of m)if(y=Ft.env[C],y!==void 0){w=C;break}if(y!==void 0&&w)if(typeof u==="boolean")c[f]=["true","1","yes"].includes(y.toLowerCase());else if(typeof u==="number"){let C=Number(y);if(!Number.isNaN(C))c[f]=C}else if(Array.isArray(u))try{c[f]=JSON.parse(y)}catch{c[f]=y.split(",").map((C)=>C.trim())}else c[f]=y;else if(u&&typeof u==="object"&&!Array.isArray(u))c[f]=o(u,a)}return c}return o(t)}function th(e){let t=qe(Ft.cwd(),e.configDir),i=qe(Ft.cwd(),e.generatedDir),n=qe(i,"config-types.ts");if(!Un(Hs(n)))_f(Hs(n),{recursive:!0,mode:511});let r=Un(t)?Vf(t).map((s)=>s.replace(/\.(ts|js|mjs|cjs|mts|cts|json)$/,"")).sort():[],o=`// Generated by bunfig v${Ph}
65
65
  export type ConfigNames = ${r.length?`'${r.join("' | '")}'`:"string"}
66
- `;Vf(n,o,{mode:438})}function th(e){let t=null,i=null,n=()=>{if(!i)i=Ba(e).then((o)=>(t=o,o),(o)=>{let s="defaultConfig"in e?e.defaultConfig:{};if(t=s,"verbose"in e&&e.verbose)lt.warn("Config loading failed, using defaults:",[o instanceof Error?o:Error(String(o))]);return s});return i},r="defaultConfig"in e?e.defaultConfig:{};return t=r,n(),new Proxy({},{get(o,s){if(t)return t[s];let a=r[s];return n(),a},has(o,s){return s in(t||r)},ownKeys(){return Object.keys(t||r)},getOwnPropertyDescriptor(o,s){return Object.getOwnPropertyDescriptor(t||r,s)},set(o,s,a){if(!t)t={...r};return t[s]=a,!0}})}function ih(e){let t=sa(du.cwd(),e?.configDir||"./config");function i(){if(!uu(t))return[];let r=new Set([".ts",".js",".mjs",".cjs",".mts",".cts",".json"]),o=[".ts",".mts",".cts",".js",".mjs",".cjs",".json"],s=hu(t).filter((c)=>r.has(In(c))).map((c)=>({base:c.replace(/\.(?:ts|js|mjs|cjs|mts|cts|json)$/i,""),file:c})),a=new Map;for(let{base:c,file:f}of s){let u=In(f).toLowerCase(),l=a.get(c);if(!l){a.set(c,f);continue}let m=In(l).toLowerCase();if(o.indexOf(u)<o.indexOf(m))a.set(c,f)}return Array.from(a.entries()).map(([c,f])=>({base:c,file:f})).sort((c,f)=>c.base.localeCompare(f.base))}function n(){let r=i(),o=r.map((c)=>c.base),s=o.length?o.map((c)=>`'${c}'`).join(" | "):"string",a=r.length?`{
67
- ${r.map((c)=>{let f=sa(t,c.file).replace(/\\/g,"/");return` '${c.base}': typeof import('${f}').default`}).join(`,
66
+ `;Uf(n,o,{mode:438})}function ih(e){let t=null,i=null,n=()=>{if(!i)i=Ga(e).then((o)=>(t=o,o),(o)=>{let s="defaultConfig"in e?e.defaultConfig:{};if(t=s,"verbose"in e&&e.verbose)ct.warn("Config loading failed, using defaults:",[o instanceof Error?o:Error(String(o))]);return s});return i},r="defaultConfig"in e?e.defaultConfig:{};return t=r,n(),new Proxy({},{get(o,s){if(t)return t[s];let l=r[s];return n(),l},has(o,s){return s in(t||r)},ownKeys(){return Object.keys(t||r)},getOwnPropertyDescriptor(o,s){return Object.getOwnPropertyDescriptor(t||r,s)},set(o,s,l){if(!t)t={...r};return t[s]=l,!0}})}function rh(e){let t=aa(pu.cwd(),e?.configDir||"./config");function i(){if(!hu(t))return[];let r=new Set([".ts",".js",".mjs",".cjs",".mts",".cts",".json"]),o=[".ts",".mts",".cts",".js",".mjs",".cjs",".json"],s=du(t).filter((c)=>r.has(In(c))).map((c)=>({base:c.replace(/\.(?:ts|js|mjs|cjs|mts|cts|json)$/i,""),file:c})),l=new Map;for(let{base:c,file:f}of s){let u=In(f).toLowerCase(),a=l.get(c);if(!a){l.set(c,f);continue}let m=In(a).toLowerCase();if(o.indexOf(u)<o.indexOf(m))l.set(c,f)}return Array.from(l.entries()).map(([c,f])=>({base:c,file:f})).sort((c,f)=>c.base.localeCompare(f.base))}function n(){let r=i(),o=r.map((c)=>c.base),s=o.length?o.map((c)=>`'${c}'`).join(" | "):"string",l=r.length?`{
67
+ ${r.map((c)=>{let f=aa(t,c.file).replace(/\\/g,"/");return` '${c.base}': typeof import('${f}').default`}).join(`,
68
68
  `)}
69
69
  }`:"Record<string, any>";return`export type ConfigNames = ${s}
70
- export type ConfigByName = ${a}
70
+ export type ConfigByName = ${l}
71
71
  export type Config<N extends ConfigNames> = N extends keyof ConfigByName ? ConfigByName[N] : unknown
72
72
  export type ConfigOf = Config
73
- `}return{name:"bunfig-plugin",setup(r){r.onResolve({filter:/^virtual:bunfig-types$/},(o)=>({path:o.path,namespace:"bunfig-virtual"})),r.onLoad({filter:/^virtual:bunfig-types$/,namespace:"bunfig-virtual"},()=>({contents:n(),loader:"ts"}))}}}function kh(e,t={}){let i=pr.cwd();while(i.includes("storage"))i=aa(i,"..");let n=aa(i,e||"");if(t?.relative)return mu(pr.cwd(),n);return n}function We(){if(vt.env.NODE_ENV==="test"||vt.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Dh(){if(vt.env.NODE_ENV==="test"||vt.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof vt<"u"){let e=vt.type;if(e==="renderer"||e==="worker")return!1;return!!(vt.versions&&(vt.versions.node||vt.versions.bun))}return!1}class qa{async format(e){let t=await Dh(),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:oi.pid,hostname:t(),environment:oi.env.NODE_ENV||"development",platform:oi.platform,version:oi.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:oi.env.NODE_ENV||oi.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class Or{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={...br},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new qa,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??Ce.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let i={...t},n=t.timestamp!==void 0;if(n)delete i.timestamp;if(this.config={...this.config,...i,timestamp:n||this.config.timestamp,level:this.options.level??"info"},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let r=this.generateKeyId(),o=this.generateKey();this.currentKeyId=r,this.keys.set(r,o),this.encryptionKeys.set(r,{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{...Vn,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...Vn};return{...Vn,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:br.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(([,n])=>n!==void 0))};if(!i.level||!["debug","info","success","warning","error"].includes(i.level))i.level=t.level;return i}shouldWriteToFile(){return!We()&&this.config.writeToFile===!0}async writeToFile(e){let t=(async()=>{let n,r=0,o=3,s=1000;while(r<o)try{try{try{await Eu(this.config.logDirectory,ua.F_OK|ua.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await vu(this.config.logDirectory,{recursive:!0,mode:493});else if(c.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw c;else throw c}}catch(c){throw console.error("Debug: [writeToFile] Failed to create log directory:",c),c}let a=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:yt.from(e);try{if(!Qi(this.currentLogFile))await Ln(this.currentLogFile,"",{mode:420});if(n=fa(this.currentLogFile,"a",420),wu(n,a,{flag:"a"}),ca(n),n!==void 0)Fn(n),n=void 0;if((await ri(this.currentLogFile)).size===0){if(await Ln(this.currentLogFile,a,{flag:"w",mode:420}),(await ri(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(c){let f=c;if(f.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(f.code)){if(r<o-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${r+1}/${o}:`,u);let l=s*2**r;await new Promise((m)=>setTimeout(m,l)),r++;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(n!==void 0)try{Fn(n)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(a){if(r===o-1){let f=a,u=typeof f.message==="string"?f.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",u),a}r++;let c=s*2**(r-1);await new Promise((f)=>setTimeout(f,c))}})();this.pendingOperations.push(t);let i=this.pendingOperations.length-1;try{await t}catch(n){throw console.error("Debug: [writeToFile] Error in operation:",n),n}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 ni(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 ni(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return ni(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(We())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((n)=>{console.error("Error rotating keys:",n)})},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 n=Array.from(this.encryptionKeys.entries()).sort(([,s],[,a])=>a.createdAt.getTime()-s.createdAt.getTime()),r=typeof e.maxKeys==="number"?e.maxKeys:1,o=Math.max(1,r);if(n.length>o)for(let[s]of n.slice(o))this.encryptionKeys.delete(s),this.keys.delete(s)}generateKeyId(){return Nn(16).toString("hex")}generateKey(){return Nn(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=Nn(16),n=gu("aes-256-gcm",t,i),r=yt.isBuffer(e)?e:yt.from(e,"utf8"),o=n.update(r),s=n.final(),a=o.length+s.length,c=n.getAuthTag(),f=yt.allocUnsafe(16+a+16);return i.copy(f,0),o.copy(f,16),s.copy(f,16+o.length),c.copy(f,16+a),{encrypted:f,iv:i}}async compressData(e){return new Promise((t,i)=>{let n=da(),r=[];n.on("data",(o)=>r.push(o)),n.on("end",()=>t(yt.from(yt.concat(r)))),n.on("error",i),n.write(e),n.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(We())return;if(!this.shouldWriteToFile())return;let e=await ri(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,n=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let r=await er(this.config.logDirectory),o=r.filter((c)=>c.startsWith(this.name)&&/\.log\.\d+$/.test(c)).sort((c,f)=>{let u=Number.parseInt(c.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,a=`${i}.${s}`;if(await ri(i).catch(()=>null))try{if(await ha(i,a),t.compress)try{let c=`${a}.gz`;await this.compressLogFile(a,c),await tr(a)}catch(c){console.error("Error compressing rotated file:",c)}if(o.length===0&&!r.some((c)=>c.endsWith(".log.1")))try{let c=`${i}.1`;await Ln(c,"")}catch(c){console.error("Error creating backup file:",c)}}catch(c){console.error(`Error during rotation: ${c instanceof Error?c.message:String(c)}`)}}else{let r=new Date().toISOString().replace(/[:.]/g,"-"),o=i.replace(/\.log$/,`-${r}.log`);if(await ri(i).catch(()=>null))await ha(i,o)}if(this.currentLogFile=n,t.maxFiles){let r=(await er(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,s)=>s.localeCompare(o));for(let o of r.slice(t.maxFiles))await tr(ni(this.config.logDirectory,o))}}}async compressLogFile(e,t){let i=la(e),n=Cu(t),r=da();await $u(i,r,n)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let i of this.logBuffer){let n=await this.formatter.format(i);if(this.shouldWriteToFile())await this.writeToFile(n);console.log(n)}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()})),Qi(this.currentLogFile))try{let e=fa(this.currentLogFile,"r+");ca(e),Fn(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(!We()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await er(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await tr(ni(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()?he.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||We())return!1;let e=typeof Ce.env.NO_COLOR<"u",t=Ce.env.FORCE_COLOR==="0";if(e||t)return!1;return!!(typeof Ce.stderr<"u"&&Ce.stderr.isTTY||typeof Ce.stdout<"u"&&Ce.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:t,icon:i="",tag:n="",message:r,level:o,showTimestamp:s=!0}=e,a=(y)=>y.replace(this.ANSI_PATTERN,"");if(!this.fancy){let y=[];if(s)y.push(t);if(o==="warning")y.push("WARN");else if(o==="error")y.push("ERROR");else if(i)y.push(i.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(n)y.push(n.replace(/[[\]]/g,""));return y.push(r),y.join(" ")}let c=Ce.stdout.columns||120,f="";if(o==="warning"||o==="error")f=`${i} ${r}`;else if(o==="info"||o==="success")f=`${i} ${n} ${r}`;else f=`${i} ${n} ${he.cyan(r)}`;if(!s)return f.trim();let u=a(f).trim().length,l=a(t).length,m=Math.max(1,c-2-u-l);return`${f.trim()}${" ".repeat(m)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(o,s)=>{let a=Number.parseInt(s,10);return a<t[0].length?String(t[0][a]):o});let i=/%([sdijfo%])/g,n=0,r=e.replace(i,(o,s)=>{if(s==="%")return"%";if(n>=t.length)return o;let a=t[n++];switch(s){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 o}});if(n<t.length)r+=` ${t.slice(n).map((o)=>typeof o==="object"?JSON.stringify(o,null,2):String(o)).join(" ")}`;return r}formatMarkdown(e){if(!e)return e;let t=e;return t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(i,n,r)=>{let o=he.underline(he.blue(n)),s=this.toAbsoluteFilePath(r);if(s&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let a=`file://${encodeURI(s)}`,c="\x1B]8;;",f="\x1B\\";return`\x1B]8;;${a}\x1B\\${o}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${r}\x1B\\${o}\x1B]8;;\x1B\\`;return o}),t=t.replace(/`([^`]+)`/g,(i,n)=>he.bgGray(n)),t=t.replace(/\*\*([^*]+)\*\*/g,(i,n)=>he.bold(n)),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(i,n)=>he.italic(n)),t=t.replace(/(?<!_)_([^_]+)_(?!_)/g,(i,n)=>he.italic(n)),t=t.replace(/~([^~]+)~/g,(i,n)=>he.strikethrough(n)),t}supportsHyperlinks(){if(We())return!1;let e=Ce.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=Ce.env.HOME||"";if(i)t=t.replace(/^~(?=$|\/)/,i)}if(bu(t)||t.startsWith("./")||t.startsWith("../"))t=Su(t);else return null;return Qi(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 n=new Date,r=this.formatConsoleTimestamp(n),o=this.formatFileTimestamp(n),s,a;if(t instanceof Error)s=t.message,a=t.stack;else s=this.formatMessage(t,i);let{consoleText:c,fileText:f}=this.buildOutputTexts(s);if(this.shouldStyleConsole()){let l=this.options.showIcons===!1?"":Wh[e],m=this.options.showTags!==!1&&this.name?he.gray(this.formatTag(this.name)):"",y;switch(e){case"debug":y=this.formatConsoleMessage({timestamp:r,icon:l,tag:m,message:he.gray(c),level:e}),console.error(y);break;case"info":y=this.formatConsoleMessage({timestamp:r,icon:l,tag:m,message:c,level:e}),console.warn(y);break;case"success":y=this.formatConsoleMessage({timestamp:r,icon:l,tag:m,message:he.green(c),level:e}),console.error(y);break;case"warning":y=this.formatConsoleMessage({timestamp:r,icon:l,tag:m,message:c,level:e}),console.warn(y);break;case"error":if(y=this.formatConsoleMessage({timestamp:r,icon:l,tag:m,message:c,level:e}),console.error(y),a){let w=a.split(`
74
- `);for(let C of w)if(C.trim()&&!C.includes(s))console.error(this.formatConsoleMessage({timestamp:r,message:he.gray(` ${C}`),level:e,showTimestamp:!1}))}break}}else if(!We()){if(console.error(`${o} ${this.environment}.${e.toUpperCase()}: ${s}`),a)console.error(a)}let u=`${o} ${this.environment}.${e.toUpperCase()}: ${f}
75
- `;if(a)u+=`${a}
73
+ `}return{name:"bunfig-plugin",setup(r){r.onResolve({filter:/^virtual:bunfig-types$/},(o)=>({path:o.path,namespace:"bunfig-virtual"})),r.onLoad({filter:/^virtual:bunfig-types$/,namespace:"bunfig-virtual"},()=>({contents:n(),loader:"ts"}))}}}function Mh(e,t={}){let i=pr.cwd();while(i.includes("storage"))i=la(i,"..");let n=la(i,e||"");if(t?.relative)return gu(pr.cwd(),n);return n}function We(){if(Et.env.NODE_ENV==="test"||Et.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Ih(){if(Et.env.NODE_ENV==="test"||Et.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof Et<"u"){let e=Et.type;if(e==="renderer"||e==="worker")return!1;return!!(Et.versions&&(Et.versions.node||Et.versions.bun))}return!1}class Ya{async format(e){let t=await Ih(),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:oi.pid,hostname:t(),environment:oi.env.NODE_ENV||"development",platform:oi.platform,version:oi.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:oi.env.NODE_ENV||oi.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class Or{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={...vr},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new Ya,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??Ce.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let i={...t},n=t.timestamp!==void 0;if(n)delete i.timestamp;if(this.config={...this.config,...i,timestamp:n||this.config.timestamp,level:this.options.level??"info"},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let r=this.generateKeyId(),o=this.generateKey();this.currentKeyId=r,this.keys.set(r,o),this.encryptionKeys.set(r,{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{...Vn,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...Vn};return{...Vn,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:vr.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(([,n])=>n!==void 0))};if(!i.level||!["debug","info","success","warning","error"].includes(i.level))i.level=t.level;return i}shouldWriteToFile(){return!We()&&this.config.writeToFile===!0}async writeToFile(e){let t=(async()=>{let n,r=0,o=3,s=1000;while(r<o)try{try{try{await Eu(this.config.logDirectory,ha.F_OK|ha.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await vu(this.config.logDirectory,{recursive:!0,mode:493});else if(c.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw c;else throw c}}catch(c){throw console.error("Debug: [writeToFile] Failed to create log directory:",c),c}let l=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:yt.from(e);try{if(!Qi(this.currentLogFile))await Ln(this.currentLogFile,"",{mode:420});if(n=ua(this.currentLogFile,"a",420),bu(n,l,{flag:"a"}),fa(n),n!==void 0)Fn(n),n=void 0;if((await ri(this.currentLogFile)).size===0){if(await Ln(this.currentLogFile,l,{flag:"w",mode:420}),(await ri(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(c){let f=c;if(f.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(f.code)){if(r<o-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${r+1}/${o}:`,u);let a=s*2**r;await new Promise((m)=>setTimeout(m,a)),r++;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(n!==void 0)try{Fn(n)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(l){if(r===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}r++;let c=s*2**(r-1);await new Promise((f)=>setTimeout(f,c))}})();this.pendingOperations.push(t);let i=this.pendingOperations.length-1;try{await t}catch(n){throw console.error("Debug: [writeToFile] Error in operation:",n),n}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 ni(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 ni(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return ni(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(We())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((n)=>{console.error("Error rotating keys:",n)})},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 n=Array.from(this.encryptionKeys.entries()).sort(([,s],[,l])=>l.createdAt.getTime()-s.createdAt.getTime()),r=typeof e.maxKeys==="number"?e.maxKeys:1,o=Math.max(1,r);if(n.length>o)for(let[s]of n.slice(o))this.encryptionKeys.delete(s),this.keys.delete(s)}generateKeyId(){return Nn(16).toString("hex")}generateKey(){return Nn(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=Nn(16),n=yu("aes-256-gcm",t,i),r=yt.isBuffer(e)?e:yt.from(e,"utf8"),o=n.update(r),s=n.final(),l=o.length+s.length,c=n.getAuthTag(),f=yt.allocUnsafe(16+l+16);return i.copy(f,0),o.copy(f,16),s.copy(f,16+o.length),c.copy(f,16+l),{encrypted:f,iv:i}}async compressData(e){return new Promise((t,i)=>{let n=pa(),r=[];n.on("data",(o)=>r.push(o)),n.on("end",()=>t(yt.from(yt.concat(r)))),n.on("error",i),n.write(e),n.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(We())return;if(!this.shouldWriteToFile())return;let e=await ri(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,n=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let r=await er(this.config.logDirectory),o=r.filter((c)=>c.startsWith(this.name)&&/\.log\.\d+$/.test(c)).sort((c,f)=>{let u=Number.parseInt(c.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 ri(i).catch(()=>null))try{if(await da(i,l),t.compress)try{let c=`${l}.gz`;await this.compressLogFile(l,c),await tr(l)}catch(c){console.error("Error compressing rotated file:",c)}if(o.length===0&&!r.some((c)=>c.endsWith(".log.1")))try{let c=`${i}.1`;await Ln(c,"")}catch(c){console.error("Error creating backup file:",c)}}catch(c){console.error(`Error during rotation: ${c instanceof Error?c.message:String(c)}`)}}else{let r=new Date().toISOString().replace(/[:.]/g,"-"),o=i.replace(/\.log$/,`-${r}.log`);if(await ri(i).catch(()=>null))await da(i,o)}if(this.currentLogFile=n,t.maxFiles){let r=(await er(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,s)=>s.localeCompare(o));for(let o of r.slice(t.maxFiles))await tr(ni(this.config.logDirectory,o))}}}async compressLogFile(e,t){let i=ca(e),n=wu(t),r=pa();await xu(i,r,n)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let i of this.logBuffer){let n=await this.formatter.format(i);if(this.shouldWriteToFile())await this.writeToFile(n);console.log(n)}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()})),Qi(this.currentLogFile))try{let e=ua(this.currentLogFile,"r+");fa(e),Fn(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(!We()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await er(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await tr(ni(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||We())return!1;let e=typeof Ce.env.NO_COLOR<"u",t=Ce.env.FORCE_COLOR==="0";if(e||t)return!1;return!!(typeof Ce.stderr<"u"&&Ce.stderr.isTTY||typeof Ce.stdout<"u"&&Ce.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:t,icon:i="",tag:n="",message:r,level:o,showTimestamp:s=!0}=e,l=(y)=>y.replace(this.ANSI_PATTERN,"");if(!this.fancy){let y=[];if(s)y.push(t);if(o==="warning")y.push("WARN");else if(o==="error")y.push("ERROR");else if(i)y.push(i.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(n)y.push(n.replace(/[[\]]/g,""));return y.push(r),y.join(" ")}let c=Ce.stdout.columns||120,f="";if(o==="warning"||o==="error")f=`${i} ${r}`;else if(o==="info"||o==="success")f=`${i} ${n} ${r}`;else f=`${i} ${n} ${pe.cyan(r)}`;if(!s)return f.trim();let u=l(f).trim().length,a=l(t).length,m=Math.max(1,c-2-u-a);return`${f.trim()}${" ".repeat(m)}${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,n=0,r=e.replace(i,(o,s)=>{if(s==="%")return"%";if(n>=t.length)return o;let l=t[n++];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(n<t.length)r+=` ${t.slice(n).map((o)=>typeof o==="object"?JSON.stringify(o,null,2):String(o)).join(" ")}`;return r}formatMarkdown(e){if(!e)return e;let t=e;return t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(i,n,r)=>{let o=pe.underline(pe.blue(n)),s=this.toAbsoluteFilePath(r);if(s&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let l=`file://${encodeURI(s)}`,c="\x1B]8;;",f="\x1B\\";return`\x1B]8;;${l}\x1B\\${o}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${r}\x1B\\${o}\x1B]8;;\x1B\\`;return o}),t=t.replace(/`([^`]+)`/g,(i,n)=>pe.bgGray(n)),t=t.replace(/\*\*([^*]+)\*\*/g,(i,n)=>pe.bold(n)),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(i,n)=>pe.italic(n)),t=t.replace(/(?<!_)_([^_]+)_(?!_)/g,(i,n)=>pe.italic(n)),t=t.replace(/~([^~]+)~/g,(i,n)=>pe.strikethrough(n)),t}supportsHyperlinks(){if(We())return!1;let e=Ce.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=Ce.env.HOME||"";if(i)t=t.replace(/^~(?=$|\/)/,i)}if(Su(t)||t.startsWith("./")||t.startsWith("../"))t=$u(t);else return null;return Qi(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 n=new Date,r=this.formatConsoleTimestamp(n),o=this.formatFileTimestamp(n),s,l;if(t instanceof Error)s=t.message,l=t.stack;else s=this.formatMessage(t,i);let{consoleText:c,fileText:f}=this.buildOutputTexts(s);if(this.shouldStyleConsole()){let a=this.options.showIcons===!1?"":Bh[e],m=this.options.showTags!==!1&&this.name?pe.gray(this.formatTag(this.name)):"",y;switch(e){case"debug":y=this.formatConsoleMessage({timestamp:r,icon:a,tag:m,message:pe.gray(c),level:e}),console.error(y);break;case"info":y=this.formatConsoleMessage({timestamp:r,icon:a,tag:m,message:c,level:e}),console.warn(y);break;case"success":y=this.formatConsoleMessage({timestamp:r,icon:a,tag:m,message:pe.green(c),level:e}),console.error(y);break;case"warning":y=this.formatConsoleMessage({timestamp:r,icon:a,tag:m,message:c,level:e}),console.warn(y);break;case"error":if(y=this.formatConsoleMessage({timestamp:r,icon:a,tag:m,message:c,level:e}),console.error(y),l){let w=l.split(`
74
+ `);for(let C of w)if(C.trim()&&!C.includes(s))console.error(this.formatConsoleMessage({timestamp:r,message:pe.gray(` ${C}`),level:e,showTimestamp:!1}))}break}}else if(!We()){if(console.error(`${o} ${this.environment}.${e.toUpperCase()}: ${s}`),l)console.error(l)}let u=`${o} ${this.environment}.${e.toUpperCase()}: ${f}
75
+ `;if(l)u+=`${l}
76
76
  `;if(u=u.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(u)}progress(e,t=""){let i={update:(r,o)=>{},finish:(r)=>{},interrupt:(r,o)=>{}};if(!this.enabled)return i;let n=30;if(this.activeProgressBar={total:Math.max(1,e||1),current:0,message:t||"",barLength:n,lastRenderedLine:""},this.shouldStyleConsole()&&!We()&&Ce.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(r,o)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,r),this.activeProgressBar.total),o!==void 0)this.activeProgressBar.message=o;if(this.shouldStyleConsole()&&!We()&&Ce.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(r)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,r)},interrupt:(r,o="info")=>{if(!We()&&Ce.stdout.isTTY)Ce.stdout.write(`
77
- `);if(this[o==="warning"?"warn":o](r),this.activeProgressBar&&this.shouldStyleConsole()&&!We()&&Ce.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time(e){let t=performance.now();if(this.shouldStyleConsole()){let i=this.options.showTags!==!1&&this.name?he.gray(this.formatTag(this.name)):"",n=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:n,icon:this.options.showIcons===!1?"":he.blue("\u25D0"),tag:i,message:`${he.cyan(e)}...`}))}return async(i)=>{if(!this.enabled)return;let n=performance.now(),r=Math.round(n-t),o=`${e} completed in ${r}ms`,s=new Date,a=this.formatConsoleTimestamp(s),c=`${this.formatFileTimestamp(s)} ${this.environment}.INFO: ${o}`;if(i)c+=` ${JSON.stringify(i)}`;if(c+=`
78
- `,c=c.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let f=this.options.showTags!==!1&&this.name?he.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:a,icon:this.options.showIcons===!1?"":he.green("\u2713"),tag:f,message:`${o}${i?` ${JSON.stringify(i)}`:""}`}))}else if(!We())console.error(c.trim());if(this.shouldWriteToFile())await this.writeToFile(c)}}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 Or(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(We())throw Error("createReadStream is not supported in browser environments");if(!Qi(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return la(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 n=yt.isBuffer(e)?e:yt.from(e,"base64"),r=n.subarray(0,16),o=n.subarray(n.length-16),s=n.subarray(16,n.length-16),a=yu("aes-256-gcm",i,r);a.setAuthTag(o);let c=a.update(s),f=a.final(),u=c.length+f.length,l=yt.allocUnsafe(u);return c.copy(l,0),f.copy(l,c.length),l.toString("utf8")}catch(n){throw Error(`Decryption failed: ${n instanceof Error?n.message:String(n)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return We()}isServerMode(){return!We()}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),n=this.formatFileTimestamp(t),{consoleText:r,fileText:o}=this.buildOutputTexts(e);if(this.shouldStyleConsole()){let a=r.split(`
79
- `),c=Math.max(...a.map((m)=>m.length))+2,f=`\u250C${"\u2500".repeat(c)}\u2510`,u=`\u2514${"\u2500".repeat(c)}\u2518`,l=a.map((m)=>this.formatConsoleMessage({timestamp:i,message:he.cyan(m),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:i,message:he.cyan(f),showTimestamp:!1})),l.forEach((m)=>console.error(m)),console.error(this.formatConsoleMessage({timestamp:i,message:he.cyan(u),showTimestamp:!1}))}else if(!We())console.error(`${n} ${this.environment}.INFO: [BOX] ${o}`);let s=`${n} ${this.environment}.INFO: [BOX] ${o}
80
- `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(s)}async prompt(e){if(We())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${he.cyan("?")} ${e} (y/n) `);let i=(n)=>{let r=n.toString().trim().toLowerCase();Ce.stdin.removeListener("data",i);try{if(typeof Ce.stdin.setRawMode==="function")Ce.stdin.setRawMode(!1)}catch{}Ce.stdin.pause(),console.error(""),t(r==="y"||r==="yes")};try{if(typeof Ce.stdin.setRawMode==="function")Ce.stdin.setRawMode(!0)}catch{}Ce.stdin.resume(),Ce.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,a=0;if(i=e.replace(s,(c,f)=>{if(f==="%")return"%";if(a>=t.length)return c;let u=t[a++];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 c}}),a<t.length)i+=` ${t.slice(a).map((c)=>typeof c==="object"?JSON.stringify(c,null,2):String(c)).join(" ")}`}let{consoleText:n,fileText:r}=this.buildOutputTexts(i);if(this.shouldStyleConsole()){let s=this.options.showTags!==!1&&this.name?he.gray(this.formatTag(this.name)):"",a=this.options.showIcons===!1?"":`${he.blue("\u25D0")} `;console.error(`${a}${s} ${he.cyan(n)}`)}let o=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${r}
81
- `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(o)}renderProgressBar(e,t=!1){if(!this.enabled||!this.shouldStyleConsole()||!Ce.stdout.isTTY)return;let i=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),n=Math.round(e.barLength*i/100),r=e.barLength-n,o=he.green("\u2501".repeat(n)),s=he.gray("\u2501".repeat(r)),a=`[${o}${s}]`,c=`${i}%`.padStart(4),f=e.message?` ${e.message}`:"",u=this.options.showIcons===!1?"":t||i===100?he.green("\u2713"):he.blue("\u25B6"),l=this.options.showTags!==!1&&this.name?` ${he.gray(this.formatTag(this.name))}`:"",m=`\r${u}${l} ${a} ${c}${f}`,y=Ce.stdout.columns||80,w=" ".repeat(Math.max(0,y-m.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${m}${w}`,Ce.stdout.write(e.lastRenderedLine),t)Ce.stdout.write(`
82
- `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||We()||!Ce.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(We()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await er(this.config.logDirectory),i=[];for(let n of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(n):n.startsWith(this.name))||!n.endsWith(".log"))continue;let r=ni(this.config.logDirectory,n);if(e.before)try{if((await ri(r)).mtime>=e.before)continue}catch(o){console.error(`Failed to get stats for file ${r}:`,o);continue}i.push(r)}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 n of i)try{await tr(n),console.warn(`Deleted log file: ${n}`)}catch(r){console.error(`Failed to delete log file ${n}:`,r)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}async function Bh(e,t={}){let{maxRetries:i=3,retryDelay:n=1000,isRetryable:r=()=>!0,fallback:o}=t,s=Error("Unknown error occurred");for(let a=0;a<=i;a++)try{return await e()}catch(c){if(s=c instanceof Error?c:Error(String(c)),a===i||!r(s))break;if(n>0)await new Promise((f)=>setTimeout(f,n))}if(o!==void 0)return o;throw s instanceof Error?s:Error(`Unknown error: ${String(s)}`)}class uo{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:n,useCamelCase:r=!0,useBackwardCompatibility:o=!0,customParsers:s={},verbose:a=!1,trackPerformance:c=!0}=i,f=async()=>{if(!e)return{config:t,source:{type:"environment",priority:50,timestamp:new Date}};let u=n||this.generateEnvPrefix(e),l={...t};return this.processObject(l,[],u,{useCamelCase:r,useBackwardCompatibility:o,customParsers:s,verbose:a,configName:e}),{config:l,source:{type:"environment",priority:50,timestamp:new Date}}};if(c)return io.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,n){for(let[r,o]of Object.entries(e)){let s=[...t,r],a=s.map((u)=>this.formatEnvKey(u,n.useCamelCase)),c=`${i}_${a.join("_")}`,f=n.useBackwardCompatibility?`${i}_${s.map((u)=>u.toUpperCase()).join("_")}`:null;if(n.verbose);if(typeof o==="object"&&o!==null&&!Array.isArray(o))this.processObject(o,s,i,n);else{let u=ir.env[c]||(f?ir.env[f]:void 0);if(u!==void 0){if(n.verbose){let l=ir.env[c]?c:f}try{e[r]=this.parseEnvironmentValue(u,typeof o,c,n.customParsers,n.configName)}catch(l){if(l instanceof fo)throw l;throw ai.envVar(c,u,typeof o,n.configName)}}}}}parseEnvironmentValue(e,t,i,n,r){for(let[o,s]of Object.entries(n))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)`,r)}return e}getEnvironmentVariables(e){let t={},i=e.toUpperCase();for(let[n,r]of Object.entries(ir.env))if(n.startsWith(i)&&r!==void 0)t[n]=r;return t}validateEnvironmentVariable(e,t,i){let n=[];if(!/^[A-Z_][A-Z0-9_]*$/.test(e))n.push(`Environment variable key "${e}" should only contain uppercase letters, numbers, and underscores`);if(i)try{this.parseEnvironmentValue(e,t,i,{})}catch(r){n.push(`Cannot parse value "${t}" as ${i}: ${r}`)}return{isValid:n.length===0,errors:n}}generateEnvVarDocs(e,t,i={}){let{prefix:n,format:r="text"}=i,o=n||this.generateEnvPrefix(e),s=[];switch(this.extractEnvVarInfo(t,[],o,s),r){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,n){for(let[r,o]of Object.entries(e)){let s=[...t,r],a=`${i}_${s.map((c)=>this.formatEnvKey(c,!0)).join("_")}`;if(typeof o==="object"&&o!==null&&!Array.isArray(o))this.extractEnvVarInfo(o,s,i,n);else n.push({key:a,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}:
77
+ `);if(this[o==="warning"?"warn":o](r),this.activeProgressBar&&this.shouldStyleConsole()&&!We()&&Ce.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)):"",n=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:n,icon:this.options.showIcons===!1?"":pe.blue("\u25D0"),tag:i,message:`${pe.cyan(e)}...`}))}return async(i)=>{if(!this.enabled)return;let n=performance.now(),r=Math.round(n-t),o=`${e} completed in ${r}ms`,s=new Date,l=this.formatConsoleTimestamp(s),c=`${this.formatFileTimestamp(s)} ${this.environment}.INFO: ${o}`;if(i)c+=` ${JSON.stringify(i)}`;if(c+=`
78
+ `,c=c.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(!We())console.error(c.trim());if(this.shouldWriteToFile())await this.writeToFile(c)}}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 Or(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(We())throw Error("createReadStream is not supported in browser environments");if(!Qi(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return ca(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 n=yt.isBuffer(e)?e:yt.from(e,"base64"),r=n.subarray(0,16),o=n.subarray(n.length-16),s=n.subarray(16,n.length-16),l=Cu("aes-256-gcm",i,r);l.setAuthTag(o);let c=l.update(s),f=l.final(),u=c.length+f.length,a=yt.allocUnsafe(u);return c.copy(a,0),f.copy(a,c.length),a.toString("utf8")}catch(n){throw Error(`Decryption failed: ${n instanceof Error?n.message:String(n)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return We()}isServerMode(){return!We()}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),n=this.formatFileTimestamp(t),{consoleText:r,fileText:o}=this.buildOutputTexts(e);if(this.shouldStyleConsole()){let l=r.split(`
79
+ `),c=Math.max(...l.map((m)=>m.length))+2,f=`\u250C${"\u2500".repeat(c)}\u2510`,u=`\u2514${"\u2500".repeat(c)}\u2518`,a=l.map((m)=>this.formatConsoleMessage({timestamp:i,message:pe.cyan(m),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:i,message:pe.cyan(f),showTimestamp:!1})),a.forEach((m)=>console.error(m)),console.error(this.formatConsoleMessage({timestamp:i,message:pe.cyan(u),showTimestamp:!1}))}else if(!We())console.error(`${n} ${this.environment}.INFO: [BOX] ${o}`);let s=`${n} ${this.environment}.INFO: [BOX] ${o}
80
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(s)}async prompt(e){if(We())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${pe.cyan("?")} ${e} (y/n) `);let i=(n)=>{let r=n.toString().trim().toLowerCase();Ce.stdin.removeListener("data",i);try{if(typeof Ce.stdin.setRawMode==="function")Ce.stdin.setRawMode(!1)}catch{}Ce.stdin.pause(),console.error(""),t(r==="y"||r==="yes")};try{if(typeof Ce.stdin.setRawMode==="function")Ce.stdin.setRawMode(!0)}catch{}Ce.stdin.resume(),Ce.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,(c,f)=>{if(f==="%")return"%";if(l>=t.length)return c;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 c}}),l<t.length)i+=` ${t.slice(l).map((c)=>typeof c==="object"?JSON.stringify(c,null,2):String(c)).join(" ")}`}let{consoleText:n,fileText:r}=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(n)}`)}let o=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${r}
81
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(o)}renderProgressBar(e,t=!1){if(!this.enabled||!this.shouldStyleConsole()||!Ce.stdout.isTTY)return;let i=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),n=Math.round(e.barLength*i/100),r=e.barLength-n,o=pe.green("\u2501".repeat(n)),s=pe.gray("\u2501".repeat(r)),l=`[${o}${s}]`,c=`${i}%`.padStart(4),f=e.message?` ${e.message}`:"",u=this.options.showIcons===!1?"":t||i===100?pe.green("\u2713"):pe.blue("\u25B6"),a=this.options.showTags!==!1&&this.name?` ${pe.gray(this.formatTag(this.name))}`:"",m=`\r${u}${a} ${l} ${c}${f}`,y=Ce.stdout.columns||80,w=" ".repeat(Math.max(0,y-m.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${m}${w}`,Ce.stdout.write(e.lastRenderedLine),t)Ce.stdout.write(`
82
+ `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||We()||!Ce.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(We()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await er(this.config.logDirectory),i=[];for(let n of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(n):n.startsWith(this.name))||!n.endsWith(".log"))continue;let r=ni(this.config.logDirectory,n);if(e.before)try{if((await ri(r)).mtime>=e.before)continue}catch(o){console.error(`Failed to get stats for file ${r}:`,o);continue}i.push(r)}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 n of i)try{await tr(n),console.warn(`Deleted log file: ${n}`)}catch(r){console.error(`Failed to delete log file ${n}:`,r)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}async function Gh(e,t={}){let{maxRetries:i=3,retryDelay:n=1000,isRetryable:r=()=>!0,fallback:o}=t,s=Error("Unknown error occurred");for(let l=0;l<=i;l++)try{return await e()}catch(c){if(s=c instanceof Error?c:Error(String(c)),l===i||!r(s))break;if(n>0)await new Promise((f)=>setTimeout(f,n))}if(o!==void 0)return o;throw s instanceof Error?s:Error(`Unknown error: ${String(s)}`)}class uo{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:n,useCamelCase:r=!0,useBackwardCompatibility:o=!0,customParsers:s={},verbose:l=!1,trackPerformance:c=!0}=i,f=async()=>{if(!e)return{config:t,source:{type:"environment",priority:50,timestamp:new Date}};let u=n||this.generateEnvPrefix(e),a={...t};return this.processObject(a,[],u,{useCamelCase:r,useBackwardCompatibility:o,customParsers:s,verbose:l,configName:e}),{config:a,source:{type:"environment",priority:50,timestamp:new Date}}};if(c)return io.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,n){for(let[r,o]of Object.entries(e)){let s=[...t,r],l=s.map((u)=>this.formatEnvKey(u,n.useCamelCase)),c=`${i}_${l.join("_")}`,f=n.useBackwardCompatibility?`${i}_${s.map((u)=>u.toUpperCase()).join("_")}`:null;if(n.verbose);if(typeof o==="object"&&o!==null&&!Array.isArray(o))this.processObject(o,s,i,n);else{let u=ir.env[c]||(f?ir.env[f]:void 0);if(u!==void 0){if(n.verbose){let a=ir.env[c]?c:f}try{e[r]=this.parseEnvironmentValue(u,typeof o,c,n.customParsers,n.configName)}catch(a){if(a instanceof fo)throw a;throw ai.envVar(c,u,typeof o,n.configName)}}}}}parseEnvironmentValue(e,t,i,n,r){for(let[o,s]of Object.entries(n))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)`,r)}return e}getEnvironmentVariables(e){let t={},i=e.toUpperCase();for(let[n,r]of Object.entries(ir.env))if(n.startsWith(i)&&r!==void 0)t[n]=r;return t}validateEnvironmentVariable(e,t,i){let n=[];if(!/^[A-Z_][A-Z0-9_]*$/.test(e))n.push(`Environment variable key "${e}" should only contain uppercase letters, numbers, and underscores`);if(i)try{this.parseEnvironmentValue(e,t,i,{})}catch(r){n.push(`Cannot parse value "${t}" as ${i}: ${r}`)}return{isValid:n.length===0,errors:n}}generateEnvVarDocs(e,t,i={}){let{prefix:n,format:r="text"}=i,o=n||this.generateEnvPrefix(e),s=[];switch(this.extractEnvVarInfo(t,[],o,s),r){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,n){for(let[r,o]of Object.entries(e)){let s=[...t,r],l=`${i}_${s.map((c)=>this.formatEnvKey(c,!0)).join("_")}`;if(typeof o==="object"&&o!==null&&!Array.isArray(o))this.extractEnvVarInfo(o,s,i,n);else n.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}:
83
83
 
84
84
  `;for(let n of e)i+=`${n.key}
85
85
  `,i+=` Type: ${n.type}
@@ -91,168 +91,168 @@ export type ConfigOf = Config
91
91
  `;i+=`| Variable | Type | Description | Example |
92
92
  `,i+=`|----------|------|-------------|----------|
93
93
  `;for(let n of e)i+=`| \`${n.key}\` | ${n.type} | ${n.description} | \`${n.example}\` |
94
- `;return i}}function Gh(e,t,i={}){return nl(e,t,i,new WeakMap)}function nl(e,t,i,n){let{arrayMergeMode:r="replace",skipNullish:o=!1,customMerger:s}=i;if(t===null||t===void 0)return o?e:t;if(s){let a=s(e,t);if(a!==void 0)return a}if(Array.isArray(t)||Array.isArray(e))return ol(e,t,r,n);if(!st(t)||!st(e))return t;return Uh(e,t,i,n)}function ol(e,t,i,n){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 jh(e,t);case"smart":return _h(e,t,n);default:return t}return t}function jh(e,t){let i=[...t];for(let n of e)if(!i.some((r)=>to(r,n)))i.push(n);return i}function _h(e,t,i){if(t.length===0)return e;if(e.length===0)return t;if(st(t[0])&&st(e[0]))return Vh(e,t,i);if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let r of e)if(!n.includes(r))n.push(r);return n}return t}function Vh(e,t,i){let n=[...t];for(let r of e){if(!st(r)){n.push(r);continue}let o=["id","name","key","path","type"],s=!1;for(let a of o)if(a in r){if(n.find((c)=>st(c)&&(a in c)&&c[a]===r[a])){s=!0;break}}if(!s)n.push(r)}return n}function Uh(e,t,i,n){let r=t;if(st(r)&&n.has(r))return n.get(r);let o={...e};if(st(r))n.set(r,o);for(let s in r){if(!Object.prototype.hasOwnProperty.call(r,s))continue;let a=r[s],c=o[s];if(i.skipNullish&&(a===null||a===void 0))continue;if(a===null||a===void 0){o[s]=a;continue}if(st(a)&&st(c))o[s]=nl(c,a,i,n);else if(Array.isArray(a)||Array.isArray(c))o[s]=ol(c,a,i.arrayMergeMode||"smart",n);else o[s]=a}return o}function sl(e,t,i="replace"){return Gh(e,t,{arrayMergeMode:i==="replace"?"replace":"smart",skipNullish:!0})}function to(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(!to(e[i],t[i]))return!1;return!0}if(st(e)&&st(t)){let i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return!1;for(let r of i){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!to(e[r],t[r]))return!1}return!0}return!1}function st(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class al{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(e,t,i={}){let{arrayStrategy:n="replace",useCache:r=!0,cacheTtl:o,trackPerformance:s=!0,verbose:a=!1}=i;if(r){let f=mr.getWithFileCheck("file",e);if(f){if(a)console.log(`Configuration loaded from cache: ${e}`);return f}}let c=async()=>{if(!rr(e))return null;try{let f=`?t=${Date.now()}`,u=await import(e+f),l=u.default||u,m="default"in u,y=Object.keys(u).length>0;if(!m&&!y)throw new Sr(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof l!=="object"||l===null||Array.isArray(l))throw new Sr(e,Error("Configuration must export a valid object"),"unknown");let w={config:sl(t,l,n),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(r)mr.setWithFileCheck("file",w,e,o);return w}catch(f){throw f instanceof Error?ai.configLoad(e,f):ai.configLoad(e,Error(String(f)))}};if(s)return io.track("loadFromPath",c,{path:e});return c()}async tryLoadFromPaths(e,t,i={}){for(let n of e)try{let r=await this.loadFromPath(n,t,i);if(r)return r}catch(r){if(r instanceof Error&&r.name==="ConfigLoadError")throw r;if(i.verbose)console.warn(`Failed to load config from ${n}:`,r)}return null}generateConfigPaths(e,t,i){let n=this.generateNamePatterns(e,i),r=[];for(let o of n)for(let s of this.extensions)r.push(Wn(t,`${o}${s}`));return r}generateNamePatterns(e,t){let i=[];if(i.push("config",".config"),e)i.push(e,`.${e}.config`,`${e}.config`,`.${e}`);let n=t===void 0?[]:Array.isArray(t)?t:[t];for(let o of n){if(!o)continue;if(i.push(o,`.${o}.config`,`${o}.config`,`.${o}`),e)i.push(`${e}.${o}.config`,`.${e}.${o}.config`)}let r=new Set;return i.filter((o)=>{if(!o||r.has(o))return!1;return r.add(o),!0})}checkFileAccess(e){return Bh(async()=>rr(e),{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,t,i){let n=[];if(!rr(e))return n;if(t||i){let r=this.generateNamePatterns(t||"",i);for(let o of r)for(let s of this.extensions){let a=Wn(e,`${o}${s}`);if(await this.checkFileAccess(a))n.push(a)}}else try{let{readdirSync:r}=await import("fs"),o=r(e);for(let s of o)if(this.looksLikeConfigFile(s)){let a=Wn(e,s);if(await this.checkFileAccess(a))n.push(a)}}catch{return[]}return n}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(!rr(e))return t.push("Configuration file does not exist"),t;let i=await import(e),n=i.default||i;if(n===void 0)t.push("Configuration file must export a default value or named exports");else if(typeof n!=="object"||n===null)t.push("Configuration must be an object");else if(Array.isArray(n))t.push("Configuration cannot be an array at the root level");if(e.endsWith(".json"))try{let{readFileSync:r}=await import("fs"),o=r(e,"utf8");JSON.parse(o)}catch(r){t.push(`Invalid JSON syntax: ${r}`)}}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(n)=>{try{let r=await this.loadFromPath(n,{},t);if(r)i.set(n,r.config)}catch(r){if(t.verbose)console.warn(`Failed to preload ${n}:`,r)}})),i}}class ll{async validateConfiguration(e,t,i={}){let{stopOnFirstError:n=!1,validateRequired:r=!0,validateTypes:o=!0,customRules:s=[],trackPerformance:a=!0,verbose:c=!1}=i,f=async()=>{let u=[],l=[],m={stopOnFirstError:n,validateRequired:r,validateTypes:o,customRules:s,trackPerformance:a,verbose:c};try{if(typeof t==="string")return await this.validateWithSchemaFile(e,t,m);else if(Array.isArray(t))return this.validateWithRules(e,[...t,...s],m);else return this.validateWithJSONSchema(e,t,m)}catch(y){return u.push({path:"",message:`Validation failed: ${y}`,rule:"system"}),{isValid:!1,errors:u,warnings:l}}};if(a)return await io.track("validateConfiguration",f);return f()}async validateWithSchemaFile(e,t,i){try{if(!Au(t))throw new $r(t,[{path:"",message:"Schema file does not exist"}]);let n=await import(t),r=n.default||n;if(Array.isArray(r))return this.validateWithRules(e,r,i);else return this.validateWithJSONSchema(e,r,i)}catch(n){throw new $r(t,[{path:"",message:`Failed to load schema: ${n}`}])}}validateWithJSONSchema(e,t,i){let n=[],r=[];return this.validateObjectAgainstSchema(e,t,"",n,r,i),{isValid:n.length===0,errors:n,warnings:r}}validateObjectAgainstSchema(e,t,i,n,r,o){if(o.validateTypes&&t.type){let s=Array.isArray(e)?"array":typeof e,a=Array.isArray(t.type)?t.type:[t.type];if(!a.includes(s)){if(n.push({path:i,message:`Expected type ${a.join(" or ")}, got ${s}`,expected:a.join(" or "),actual:s,rule:"type"}),o.stopOnFirstError)return}}if(t.enum&&!t.enum.includes(e)){if(n.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)n.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)n.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))n.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)n.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)n.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 a=i?`${i}[${s}]`:`[${s}]`;if(this.validateObjectAgainstSchema(e[s],t.items,a,n,r,o),o.stopOnFirstError&&n.length>0)return}if(e&&typeof e==="object"&&!Array.isArray(e)){let s=e;if(o.validateRequired&&t.required){for(let a of t.required)if(!(a in s)){if(n.push({path:i?`${i}.${a}`:a,message:`Missing required property '${a}'`,expected:"required",rule:"required"}),o.stopOnFirstError)return}}if(t.properties){for(let[a,c]of Object.entries(t.properties))if(a in s){let f=i?`${i}.${a}`:a;if(this.validateObjectAgainstSchema(s[a],c,f,n,r,o),o.stopOnFirstError&&n.length>0)return}}if(t.additionalProperties===!1){let a=new Set(Object.keys(t.properties||{}));for(let c of Object.keys(s))if(!a.has(c))r.push({path:i?`${i}.${c}`:c,message:`Additional property '${c}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(e,t,i){let n=[],r=[];for(let o of t)try{let s=this.getValueByPath(e,o.path),a=this.validateWithRule(s,o,o.path);if(n.push(...a),i.stopOnFirstError&&n.length>0)break}catch(s){n.push({path:o.path,message:`Rule validation failed: ${s}`,rule:"system"})}return{isValid:n.length===0,errors:n,warnings:r}}validateWithRule(e,t,i){let n=[];if(t.required&&(e===void 0||e===null))return n.push({path:i,message:t.message||`Property '${i}' is required`,expected:"required",rule:"required"}),n;if(e===void 0||e===null)return n;if(t.type){let r=Array.isArray(e)?"array":typeof e;if(r!==t.type)n.push({path:i,message:t.message||`Expected type ${t.type}, got ${r}`,expected:t.type,actual:r,rule:"type"})}if(t.min!==void 0){let r=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(r<t.min)n.push({path:i,message:t.message||`Value must be at least ${t.min}`,expected:`>= ${t.min}`,actual:r,rule:"min"})}if(t.max!==void 0){let r=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(r>t.max)n.push({path:i,message:t.message||`Value must not exceed ${t.max}`,expected:`<= ${t.max}`,actual:r,rule:"max"})}if(t.pattern&&typeof e==="string"){if(!t.pattern.test(e))n.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))n.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 r=t.validator(e);if(r)n.push({path:i,message:t.message||r,rule:"custom"})}return n}getValueByPath(e,t){if(!t)return e;let i=t.split("."),n=e;for(let r of i)if(n&&typeof n==="object"&&r in n)n=n[r];else return;return n}generateRulesFromInterface(e){let t=[],i=e.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let n of i){let[,r,o,s]=n;t.push({path:r,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:Kh},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}function Hh(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 cl{fileLoader=new al;envProcessor=new uo;validator=new ll;async loadConfig(e){let t=Date.now(),{cache:i,performance:n,schema:r,validate:o,...s}=e;try{if(i?.enabled){let c=this.checkCache(s.name||"",s);if(c)return c}let a;try{a=await this.loadConfigurationStrategies(s,!0,i)}catch(c){let f=s.__strictErrorHandling;if(c instanceof Error&&c.name==="ConfigNotFoundError"){if(f)throw c;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(c instanceof Error&&c.name==="ConfigLoadError"){let u=c.message.includes("EACCES")||c.message.includes("EPERM")||c.message.includes("permission denied"),l=!u&&(c.message.includes("syntax")||c.message.includes("Expected")||c.message.includes("Unexpected")||c.message.includes("BuildMessage")||c.message.includes("errors building")),m=c.message.includes("Configuration must export a valid object")||c.message.includes("Configuration file is empty and exports nothing");if(f&&(m||u))throw c;if(l&&(!f||!m))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(!f)a={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`Configuration loading error, using defaults: ${c.message}`]};else throw c}else a={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${c instanceof Error?c.message:String(c)}`]}}if(r||o)await this.validateConfiguration(a.config,r,o,s.name);if(i?.enabled&&a)this.cacheResult(s.name||"",a,i,s);if(n?.enabled){let c={operation:"loadConfig",duration:Date.now()-t,configName:s.name,timestamp:new Date};if(n.onMetrics)n.onMetrics(c);if(n.slowThreshold&&c.duration>n.slowThreshold)Ct.warn(`Slow configuration loading detected: ${c.duration}ms for ${s.name}`);a.metrics=c}return a}catch(a){if(a instanceof Error&&a.name==="ConfigNotFoundError")throw a;let c=Date.now()-t;throw Ct.error(`Configuration loading failed after ${c}ms:`,[a instanceof Error?a:Error(String(a))]),a}}async loadConfigurationStrategies(e,t=!1,i){let{name:n="",alias:r,cwd:o,configDir:s,defaultConfig:a,checkEnv:c=!0,arrayStrategy:f="replace",verbose:u=!1}=e,l=o||Ar.cwd(),m=[],y=await this.loadLocalConfiguration(n,r,l,s,a,f,u,c,i);if(y)return m.push(...this.getLocalSearchPaths(n,r,l,s)),this.finalizeResult(y,m,c,n,u);let w=await this.loadHomeConfiguration(n,r,a,f,u,c);if(w)return m.push(...this.getHomeSearchPaths(n,r)),this.finalizeResult(w,m,c,n,u);let C=await this.loadPackageJsonConfiguration(n,r,l,a,f,u,c);if(C)return m.push(nt(l,"package.json")),this.finalizeResult(C,m,c,n,u);if(m.push(...this.getAllSearchPaths(n,r,l,s)),t)throw ai.configNotFound(n,m,r);return{...await this.applyEnvironmentVariables(n,a,c,u),warnings:[`No configuration file found for "${n}"${Hh(r)}, using defaults with environment variables`]}}async loadLocalConfiguration(e,t,i,n,r,o,s,a,c){let f=a?or(e,r,s):r,u=this.getLocalDirectories(i,n);for(let l of u){if(s)Ct.info(`Searching for configuration in: ${l}`);let m=this.fileLoader.generateConfigPaths(e,l,t),y=await this.fileLoader.tryLoadFromPaths(m,f,{arrayStrategy:o,verbose:s,cacheTtl:c?.ttl,useCache:!c?.ttl||c.ttl>100});if(y){if(s)Ct.success(`Configuration loaded from: ${y.source.path}`);return y}}return null}async loadHomeConfiguration(e,t,i,n,r,o){if(!e)return null;let s=o?or(e,i,r):i,a=[nt(qt(),".config",e),nt(qt(),".config"),qt()];for(let c of a){if(r)Ct.info(`Checking home directory: ${c}`);let f=this.fileLoader.generateConfigPaths(e,c,t),u=await this.fileLoader.tryLoadFromPaths(f,s,{arrayStrategy:n,verbose:r});if(u){if(r)Ct.success(`Configuration loaded from home directory: ${u.source.path}`);return u}}return null}async loadPackageJsonConfiguration(e,t,i,n,r,o,s){let a=s?or(e,n,o):n;try{let c=nt(i,"package.json");if(!Bf(c))return null;let f={};try{f=JSON.parse(Gf(c,"utf8"))}catch(m){if(o)Ct.warn("Failed to parse package.json:",[m instanceof Error?m:Error(String(m))]);return null}let u=f[e],l=e;if(!u&&t){let m=Array.isArray(t)?t:[t];for(let y of m){if(!y)continue;if(f[y]){u=f[y],l=y;break}}}if(u&&typeof u==="object"&&!Array.isArray(u)){if(o)Ct.success(`Configuration loaded from package.json: ${l}`);return{config:sl(a,u,r),source:{type:"package.json",path:c,priority:30,timestamp:new Date}}}}catch(c){if(o)Ct.warn("Failed to load package.json:",[c instanceof Error?c:Error(String(c))])}return null}async applyEnvironmentVariables(e,t,i,n){if(!i||!e||typeof t!=="object"||t===null||Array.isArray(t))return{config:t,source:{type:"default",priority:10,timestamp:new Date}};return{config:or(e,t,n),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(e,t,i,n,r){return{config:e.config,source:e.source,path:e.source.path}}async validateConfiguration(e,t,i,n){let r=[];if(i){let o=i(e);if(o)r.push(...o)}if(t){let o=await this.validator.validateConfiguration(e,t);if(!o.isValid)r.push(...o.errors.map((s)=>s.path?`${s.path}: ${s.message}`:s.message))}if(r.length>0)throw ai.configValidation(n||"unknown",r,n)}checkCache(e,t){let i=this.generateCacheKey(e,t);return mr.get(i)||null}cacheResult(e,t,i,n){let r=this.generateCacheKey(e,n);mr.set(r,t,void 0,i.ttl)}generateCacheKey(e,t){let i=[e];if(t.alias){let n=Array.isArray(t.alias)?t.alias.join(","):t.alias;i.push(`alias:${n}`)}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,nt(e,"config"),nt(e,".config"),t?nt(e,t):void 0].filter(Boolean)))}getAllSearchPaths(e,t,i,n){let r=[];return r.push(...this.getLocalSearchPaths(e,t,i,n)),r.push(...this.getHomeSearchPaths(e,t)),r.push(nt(i,"package.json")),r}getLocalSearchPaths(e,t,i,n){let r=this.getLocalDirectories(i,n),o=[];for(let s of r)o.push(...this.fileLoader.generateConfigPaths(e,s,t));return o}getHomeSearchPaths(e,t){if(!e)return[];let i=[nt(qt(),".config",e),nt(qt(),".config"),qt()],n=[];for(let r of i)n.push(...this.fileLoader.generateConfigPaths(e,r,t));return n}async loadConfigWithResult(e){return this.loadConfig(e)}}function or(e,t,i=!1){let n=new uo,r=e.toUpperCase().replace(/[^A-Z0-9]/g,"_");function o(s,a=[]){let c={...s};for(let[f,u]of Object.entries(s)){let l=[...a,f],m=[`${r}_${l.join("_").toUpperCase()}`,`${r}_${l.map((C)=>C.toUpperCase()).join("")}`,`${r}_${l.map((C)=>C.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],y,w;for(let C of m)if(y=Ar.env[C],y!==void 0){w=C;break}if(y!==void 0&&w)if(typeof u==="boolean")c[f]=["true","1","yes"].includes(y.toLowerCase());else if(typeof u==="number"){let C=Number(y);if(!Number.isNaN(C))c[f]=C}else if(Array.isArray(u))try{c[f]=JSON.parse(y)}catch{c[f]=y.split(",").map((C)=>C.trim())}else c[f]=y;else if(u&&typeof u==="object"&&!Array.isArray(u))c[f]=o(u,l)}return c}return o(t)}var mr,io,xu,Tu=(e)=>e,Ru=(e,t)=>{for(var i in t)xu(e,i,{get:t[i],enumerable:!0,configurable:!0,set:Ou.bind(t,i)})},Pu=(e,t)=>()=>(e&&(t=e(e=0)),t),ka,Ga,si,Si,ja,rh,nh,ma,ar,zn,Ue,Se,oh,ga,sh,ya,ah,lh,Bn,ch,Ca,wa,Gn,fh,uh,hh,dh,lr,_a,ph,Ke,mh,gh,Ea,cr,Jn,Le,ce,yh,va,Ch,ba,wh,Eh,jn,vh,Sa,$a,bh,_n,Sh,$h,Ah,xh,Th,fr,Va,Oh,Rh="0.15.6",Qe,Er,vi,qn,Yn,vr,Zn,Xn,bi,Qn,eo,Pt,Ua,Ka,lt,bt,Ha,za,Ph,Mh,Ja,br,Ny,Ya,he,Fy,Ih,Ly,Nh,Wy,By,Aa,Gy,Fh,Lh,jy,xa,_y,Vy,Uy,Ky,Hy,Vn,Wh,zy,ct,Za,Sr,Xa,Qa,fo,el,tl,$r,il,rl,ai,Kh,Ct,Jy,qy,Yy,zh,fl;var ul=ue(()=>{mr=new Ra,io=new Pa,xu=Object.defineProperty;ka={};Ru(ka,{withErrorRecovery:()=>Ia,tryLoadConfig:()=>Qu,loadConfigWithResult:()=>Zu,loadConfig:()=>Ba,isRetryableError:()=>Ku,isConfigNotFoundError:()=>Uu,isBunfigError:()=>Na,globalPerformanceMonitor:()=>Si,globalCache:()=>si,getEnvOrDefault:()=>Hu,generateConfigTypes:()=>eh,defaultGeneratedDir:()=>za,defaultConfigDir:()=>Ha,deepMergeWithArrayStrategy:()=>ao,deepMerge:()=>Fa,createLibraryConfig:()=>th,config:()=>Xu,bunfigPlugin:()=>ih,applyEnvVarsToConfig:()=>wi,TypeGenerationError:()=>Xn,SchemaValidationError:()=>bi,PluginError:()=>eo,PerformanceMonitor:()=>no,FileSystemError:()=>Zn,ErrorFactory:()=>Pt,EnvVarError:()=>vr,EnvProcessor:()=>xr,ConfigValidator:()=>lo,ConfigValidationError:()=>qn,ConfigNotFoundError:()=>Er,ConfigMergeError:()=>Yn,ConfigLoader:()=>co,ConfigLoadError:()=>vi,ConfigFileLoader:()=>Tr,ConfigCache:()=>ro,CacheUtils:()=>ja,BunfigError:()=>Qe,BrowserConfigError:()=>Qn,ArrayMergeStrategies:()=>Ua});Ph=Pu(async()=>{Ga=import.meta.require,si=new ro,Si=new no,ja={createKey:ku,isEquivalent:Mu,estimateMemoryUsage:Du},rh=dr(Kn.cwd(),"config"),nh=dr(Kn.cwd(),"src/generated"),ma=hr.env.CLARITY_LOG_DIR||Hf(Fu(),"logs"),ar={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:ma,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1},zn=await Lu(),Ue={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"},Se=Ue,oh=Ue.red,ga=Ue.green,sh=Ue.yellow,ya=Ue.blue,ah=Ue.magenta,lh=Ue.cyan,Bn=Ue.white,ch=Ue.gray,Ca=Ue.bgRed,wa=Ue.bgYellow,Gn=Ue.bold,fh=Ue.dim,uh=Ue.italic,hh=Ue.underline,dh=Ue.reset,lr={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},_a={debug:"\uD83D\uDD0D",info:ya("\u2139"),success:ga("\u2713"),warning:wa(Bn(Gn(" WARN "))),error:Ca(Bn(Gn(" ERROR ")))},ph=new yr("stacks"),Ke=new yr("bunfig",{showTags:!0}),mh=Je(Ei.cwd(),"config"),gh=Je(Ei.cwd(),"src/generated"),Ea=ur.env.CLARITY_LOG_DIR||Uf(ju(),"logs"),cr={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:Ea,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},Jn=await _u(),Le={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"},ce=Le,yh=Le.red,va=Le.green,Ch=Le.yellow,ba=Le.blue,wh=Le.magenta,Eh=Le.cyan,jn=Le.white,vh=Le.gray,Sa=Le.bgRed,$a=Le.bgYellow,bh=Le.bgGray,_n=Le.bold,Sh=Le.dim,$h=Le.italic,Ah=Le.underline,xh=Le.strikethrough,Th=Le.reset,fr={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},Va={debug:"\uD83D\uDD0D",info:ba("\u2139"),success:va("\u2713"),warning:$a(jn(_n(" WARN "))),error:Sa(jn(_n(" ERROR ")))},Oh=new wr("stacks"),Qe=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}`}},Er=class extends Qe{code="CONFIG_NOT_FOUND";constructor(e,t,i){let n=i?` or alias "${i}"`:"";super(`Configuration "${e}"${n} not found`,{configName:e,alias:i,searchPaths:t,searchPathCount:t.length})}},vi=class extends Qe{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}},qn=class extends Qe{code="CONFIG_VALIDATION_ERROR";constructor(e,t,i){super(`Configuration validation failed for "${e}"`,{configPath:e,configName:i,validationErrors:t,errorCount:t.length})}},Yn=class extends Qe{code="CONFIG_MERGE_ERROR";constructor(e,t,i,n){super(`Failed to merge configuration from "${e}" with "${t}": ${i.message}`,{sourcePath:e,targetPath:t,configName:n,originalError:i.name,originalMessage:i.message});this.cause=i}},vr=class extends Qe{code="ENV_VAR_ERROR";constructor(e,t,i,n){super(`Failed to parse environment variable "${e}" with value "${t}" as ${i}`,{envKey:e,envValue:t,expectedType:i,configName:n})}},Zn=class extends Qe{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}},Xn=class extends Qe{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}},bi=class extends Qe{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})}},Qn=class extends Qe{code="BROWSER_CONFIG_ERROR";constructor(e,t,i,n){super(`Failed to fetch configuration from "${e}": ${t} ${i}`,{endpoint:e,status:t,statusText:i,configName:n})}},eo=class extends Qe{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}},Pt={configNotFound(e,t,i){return new Er(e,t,i)},configLoad(e,t,i){return new vi(e,t,i)},configValidation(e,t,i){return new qn(e,t,i)},configMerge(e,t,i,n){return new Yn(e,t,i,n)},envVar(e,t,i,n){return new vr(e,t,i,n)},fileSystem(e,t,i){return new Zn(e,t,i)},typeGeneration(e,t,i){return new Xn(e,t,i)},schemaValidation(e,t,i){return new bi(e,t,i)},browserConfig(e,t,i,n){return new Qn(e,t,i,n)},plugin(e,t,i){return new eo(e,t,i)}},Ua={replace:"replace",concat:"concat",smart:"smart"},Ka=/^https?:\/\//,lt=new wr("bunfig",{showTags:!0}),bt=new co,Ha=qe(Ft.cwd(),"config"),za=qe(Ft.cwd(),"src/generated")});Mh=pr.env.CLARITY_LOG_DIR||pu(kh(),"logs"),Ja={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:Mh,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},br={...Ja},Ny=(async()=>{try{let{loadConfig:e}=await Ph().then(()=>ka),t=await e({name:"clarity",alias:"logging",defaultConfig:Ja,cwd:pr.cwd()});if(t)Object.assign(br,t)}catch{}return br})();Ya={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"},he=Ya,{red:Fy,green:Ih,yellow:Ly,blue:Nh,magenta:Wy,cyan:By,white:Aa,gray:Gy,bgRed:Fh,bgYellow:Lh,bgGray:jy,bold:xa,dim:_y,italic:Vy,underline:Uy,strikethrough:Ky,reset:Hy}=Ya,Vn={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},Wh={debug:"\uD83D\uDD0D",info:Nh("\u2139"),success:Ih("\u2713"),warning:Lh(Aa(xa(" WARN "))),error:Fh(Aa(xa(" ERROR ")))};zy=new Or("stacks");ct=class ct 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}`}};Za=class Za extends ct{code="CONFIG_NOT_FOUND";constructor(e,t,i){let n=i===void 0?[]:Array.isArray(i)?i.filter(Boolean):[i],r="";if(n.length===1)r=` or alias "${n[0]}"`;else if(n.length>1)r=` or aliases ${n.map((o)=>`"${o}"`).join(", ")}`;super(`Configuration "${e}"${r} not found`,{configName:e,alias:i,searchPaths:t,searchPathCount:t.length})}};Sr=class Sr extends ct{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}};Xa=class Xa extends ct{code="CONFIG_VALIDATION_ERROR";constructor(e,t,i){super(`Configuration validation failed for "${e}"`,{configPath:e,configName:i,validationErrors:t,errorCount:t.length})}};Qa=class Qa extends ct{code="CONFIG_MERGE_ERROR";constructor(e,t,i,n){super(`Failed to merge configuration from "${e}" with "${t}": ${i.message}`,{sourcePath:e,targetPath:t,configName:n,originalError:i.name,originalMessage:i.message});this.cause=i}};fo=class fo extends ct{code="ENV_VAR_ERROR";constructor(e,t,i,n){super(`Failed to parse environment variable "${e}" with value "${t}" as ${i}`,{envKey:e,envValue:t,expectedType:i,configName:n})}};el=class el extends ct{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}};tl=class tl extends ct{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}};$r=class $r extends ct{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})}};il=class il extends ct{code="BROWSER_CONFIG_ERROR";constructor(e,t,i,n){super(`Failed to fetch configuration from "${e}": ${t} ${i}`,{endpoint:e,status:t,statusText:i,configName:n})}};rl=class rl extends ct{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 Za(e,t,i)},configLoad(e,t,i){return new Sr(e,t,i)},configValidation(e,t,i){return new Xa(e,t,i)},configMerge(e,t,i,n){return new Qa(e,t,i,n)},envVar(e,t,i,n){return new fo(e,t,i,n)},fileSystem(e,t,i){return new el(e,t,i)},typeGeneration(e,t,i){return new tl(e,t,i)},schemaValidation(e,t,i){return new $r(e,t,i)},browserConfig(e,t,i,n){return new il(e,t,i,n)},plugin(e,t,i){return new rl(e,t,i)}};Kh=/^https?:\/\//;Ct=new Or("bunfig",{showTags:!0});Jy=new cl;qy=nt(Ar.cwd(),"config"),Yy=nt(Ar.cwd(),"src/generated"),zh={cwd:Wf.cwd(),root:"./src",entrypoints:["**/*.{ts,tsx,mts,cts,vue,stx}"],outdir:"./dist",keepComments:!0,clean:!0,tsconfigPath:"./tsconfig.json",outputStructure:"mirror",verbose:!1,importOrder:["bun"],declarationMap:!1},fl=zh});function hl(e,t,i){let n={file:t,message:"Unknown error",code:$i.UNKNOWN_ERROR};if(e instanceof Error){n.message=e.message,n.stack=e.stack;let r=e.message.match(/\((\d+),(\d+)\)/);if(r)n.location={line:Number.parseInt(r[1],10),column:Number.parseInt(r[2],10)};if(e.message.includes("Cannot find")||e.message.includes("not found"))n.code=$i.FILE_NOT_FOUND,n.suggestion="Check that the file path is correct and the file exists.";else if(e.message.includes("syntax")||e.message.includes("Unexpected token"))n.code=$i.SYNTAX_ERROR,n.suggestion="Check for syntax errors in your TypeScript code.";else if(e.message.includes("type")&&e.message.includes("cannot"))n.code=$i.TYPE_INFERENCE_ERROR,n.suggestion="Add explicit type annotations to help with type inference.";else if(e.message.includes("parse")||e.message.includes("Parse"))n.code=$i.PARSE_ERROR,n.suggestion="The file contains invalid TypeScript syntax."}else if(typeof e==="string")n.message=e;return n}function dl(e,t){let i=[],n=e.file;if(e.location)n+=`:${e.location.line}:${e.location.column}`;if(e.code)n+=` [${e.code}]`;if(i.push(n),i.push(` Error: ${e.message}`),t&&e.location){i.push("");let r=t.split(`
95
- `),o=e.location.line-1;if(o>=0&&o<r.length){let s=Math.max(0,o-1),a=Math.min(r.length-1,o+1);for(let c=s;c<=a;c++){let f=(c+1).toString().padStart(4," "),u=c===o?">":" ";if(i.push(` ${u} ${f} | ${r[c]}`),c===o&&e.location.column>0){let l=" ".repeat(10+e.location.column-1);i.push(` ${l}^`)}}}}if(e.suggestion)i.push(""),i.push(` Suggestion: ${e.suggestion}`);return i.join(`
96
- `)}var $i;var pl=ue(()=>{$i={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"}});function gl(e){return e.endsWith(".vue")}function Jh(e){let t={script:null,scriptSetup:null},i=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,n;while((n=i.exec(e))!==null){let r=n[1]||"",o=/lang\s*=\s*["']([^"']+)["']/i.exec(r)?.[1]?.toLowerCase()??"js",s={content:n[2]??"",attrs:r,setup:/\bsetup\b/.test(r),lang:o};if(s.setup)t.scriptSetup=s;else t.script=s}return t}function et(e,t){let i=e[t];t++;while(t<e.length){let n=e[t];if(n==="\\"){t+=2;continue}if(n===i)return t+1;t++}return t}function at(e,t){t++;let i=0;while(t<e.length){let n=e[t];if(n==="\\"){t+=2;continue}if(n==="`"&&i===0)return t+1;if(n==="$"&&e[t+1]==="{"){i++,t+=2;continue}if(n==="}"){if(i>0)i--;t++;continue}t++}return t}function pt(e,t){if(e[t+1]==="/"){let i=e.indexOf(`
97
- `,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 po(e,t){let i=e[t];if(i==='"'||i==="'")return et(e,t);if(i==="`")return at(e,t);if(i==="/"&&(e[t+1]==="/"||e[t+1]==="*"))return pt(e,t);return t}function mo(e){let t=e.split(""),i=0;while(i<e.length){let n=po(e,i);if(n>i){for(let r=i;r<n;r++)if(t[r]!==`
98
- `&&t[r]!=="\r")t[r]=" ";i=n;continue}i++}return t.join("")}function je(e,t,i,n){let r=0,o=t;while(o<e.length){let s=e[o];if(s==='"'||s==="'"){o=et(e,o);continue}if(s==="`"){o=at(e,o);continue}if(s==="/"&&(e[o+1]==="/"||e[o+1]==="*")){o=pt(e,o);continue}if(s===i)r++;else if(s===n){if(r--,r===0)return o}o++}return-1}function go(e,t){let i=0,n=t;while(n<e.length){let r=e[n];if(r==='"'||r==="'"){n=et(e,n);continue}if(r==="`"){n=at(e,n);continue}if(r==="/"&&(e[n+1]==="/"||e[n+1]==="*")){n=pt(e,n);continue}if(r==="="&&e[n+1]===">"){n+=2;continue}if(r==="<")i++;else if(r===">"){if(i--,i===0)return n}n++}return-1}function li(e,t=","){let i=[],n=0,r="",o=0;while(o<e.length){let s=e[o];if(s==='"'||s==="'"){let a=et(e,o);r+=e.slice(o,a),o=a;continue}if(s==="`"){let a=at(e,o);r+=e.slice(o,a),o=a;continue}if(s==="/"&&(e[o+1]==="/"||e[o+1]==="*")){o=pt(e,o);continue}if(s==="{"||s==="["||s==="("||s==="<")n++;else if(s==="}"||s==="]"||s===")"||s===">")n--;if(s===t&&n===0){i.push(r),r="",o++;continue}r+=s,o++}if(r.trim()!=="")i.push(r);return i}function Ti(e){let t=e.trim();if(!t.startsWith("{"))return[];let i=je(t,0,"{","}");if(i===-1)return[];let n=t.slice(1,i),r=[];for(let o of li(n)){let s=-1,a=0;for(let u=0;u<o.length;u++){let l=o[u];if(l==='"'||l==="'"){u=et(o,u)-1;continue}if(l==="`"){u=at(o,u)-1;continue}if(l==="{"||l==="["||l==="("||l==="<")a++;else if(l==="}"||l==="]"||l===")"||l===">")a--;else if(l===":"&&a===0){s=u;break}}if(s!==-1){r.push({key:Ai(o.slice(0,s).trim()),value:o.slice(s+1).trim(),isMethod:!1});continue}let c=/^([A-Za-z_$][\w$]*|['"][^'"]+['"])\s*\(/.exec(o.trim());if(c){r.push({key:Ai(c[1]),value:o.trim(),isMethod:!0});continue}let f=o.trim();if(f)r.push({key:Ai(f),value:"",isMethod:!1})}return r}function Ai(e){if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);return e}function xi(e){return/^[A-Za-z_$][\w$]*$/.test(e)?e:JSON.stringify(e)}function Oi(e,t){let i=new RegExp(`\\b${t}\\b`,"g"),n;while((n=i.exec(e))!==null){let r=n.index+n[0].length;while(r<e.length&&/\s/.test(e[r]))r++;let o=null;if(e[r]==="<"){let c=go(e,r);if(c===-1)return null;o=e.slice(r+1,c).trim(),r=c+1;while(r<e.length&&/\s/.test(e[r]))r++}if(e[r]!=="(")continue;let s=je(e,r,"(",")");if(s===-1)return null;let a=li(e.slice(r+1,s));return{generic:o,arg:a.length>0?a[0].trim():null}}return null}function qh(e,t){let i=yl(e,t);if(!i)return null;return i.kind==="interface"?e.slice(i.bodyStart,i.end):e.slice(i.bodyStart,i.end).trim()}function yl(e,t){let i=new RegExp(`\\binterface\\s+${t}\\b[^{]*\\{`,"m").exec(e);if(i){let r=i.index+i[0].length-1,o=je(e,r,"{","}");if(o!==-1)return{kind:"interface",start:i.index,end:o+1,bodyStart:r}}let n=new RegExp(`\\btype\\s+${t}\\b[^=]*=`,"m").exec(e);if(n){let r=n.index+n[0].length,o=0,s=r;while(r<e.length){let a=e[r];if(a==='"'||a==="'"){r=et(e,r);continue}if(a==="`"){r=at(e,r);continue}if(a==="{"||a==="["||a==="("||a==="<")o++;else if(a==="}"||a==="]"||a===")"||a===">")o--;else if((a===";"||a===`
99
- `)&&o===0)break;r++}return{kind:"type",start:n.index,end:r,bodyStart:s}}return null}function Yh(e){let t=e.search(/\bas\s+PropType\s*</);if(t===-1)return null;let i=e.indexOf("<",t),n=go(e,i);if(n===-1)return null;if(e.slice(n+1).trim()!=="")return null;return e.slice(i+1,n).trim()}function ho(e){let t=e.trim(),i=Yh(t);if(i!==null)return{type:i,optional:!0};if(t==="null")return{type:"unknown",optional:!0};if(t.startsWith("[")){let n=je(t,0,"[","]");if(n!==-1){let r=li(t.slice(1,n)).map((o)=>ho(o).type).filter((o)=>o!=="unknown");return{type:r.length>0?[...new Set(r)].join(" | "):"unknown",optional:!0}}}if(t.startsWith("{")){let n=Ti(t),r=n.find((c)=>c.key==="type"),o=n.find((c)=>c.key==="required"),s=r?ho(r.value).type:"unknown",a=!(o&&o.value.trim()==="true");return{type:s,optional:a}}if(ml[t])return{type:ml[t],optional:!0};if(/^[A-Za-z_$][\w$.]*$/.test(t))return{type:t,optional:!0};return{type:"unknown",optional:!0}}function Mr(e){let t=e.trim();if(t.startsWith("{")){let i=Ti(t);if(i.length===0)return"{}";return`{ ${i.map((n)=>{if(n.isMethod||n.value==="")return`${xi(n.key)}?: unknown`;let r=ho(n.value);return`${xi(n.key)}${r.optional?"?":""}: ${r.type}`}).join(", ")} }`}if(t.startsWith("[")){let i=je(t,0,"[","]");if(i===-1)return null;let n=li(t.slice(1,i)).map((r)=>Ai(r.trim())).filter((r)=>r!=="");if(n.length===0)return"{}";return`{ ${n.map((r)=>`${xi(r)}?: unknown`).join(", ")} }`}return null}function Zh(e){let t=e.trim();if(!t.startsWith("["))return null;let i=je(t,0,"[","]");if(i===-1)return null;let n=li(t.slice(1,i)).map((r)=>r.trim());if(n.length===0)return"{}";if(!n.every((r)=>r.startsWith("'")&&r.endsWith("'")||r.startsWith('"')&&r.endsWith('"')))return"string[]";return`[${n.map((r)=>JSON.stringify(Ai(r))).join(", ")}]`}function Xh(e){let t=e.trim();if(!t.startsWith("{"))return null;let i=Ti(t);if(i.length===0)return"{}";return`{ ${i.map((n)=>`${JSON.stringify(n.key)}: (...args: any[]) => void`).join(", ")} }`}function Cl(e){return Zh(e)??Xh(e)}function Qh(e){let t=[],i=0,n="",r=0;while(r<e.length){let o=e[r];if(o==='"'||o==="'"){let s=et(e,r);n+=e.slice(r,s),r=s;continue}if(o==="`"){let s=at(e,r);n+=e.slice(r,s),r=s;continue}if(o==="/"&&(e[r+1]==="/"||e[r+1]==="*")){let s=pt(e,r);n+=e.slice(r,s),r=s;continue}if(o==="="&&e[r+1]===">"){n+="=>",r+=2;continue}if(o==="{"||o==="["||o==="("||o==="<")i++;else if(o==="}"||o==="]"||o===")"||o===">")i--;if((o===";"||o===","||o===`
100
- `)&&i===0){if(n.trim()!=="")t.push(n.trim());n="",r++;continue}n+=o,r++}if(n.trim()!=="")t.push(n.trim());return t}function ed(e){let t=e.trim();if(!t.startsWith("{"))return null;let i=je(t,0,"{","}");if(i===-1||t.slice(i+1).trim()!=="")return null;let n=Qh(t.slice(1,i));if(n.length===0)return"{}";let r=[];for(let o of n){let s=/^\(\s*\w+\s*:\s*/.exec(o);if(!s)return null;let a=s[0].length,c=o[a];if(c!=="'"&&c!=='"'&&c!=="`")return null;let f=et(o,a),u=o.slice(a+1,f-1),l=je(o,o.indexOf("(",0),"(",")");if(l===-1)return null;let m=o.slice(a,l),y=li(m).slice(1),w=o.slice(l+1).trim();if(w.startsWith(":"))w=w.slice(1).trim();if(w==="")w="void";r.push(`${JSON.stringify(u)}: (${y.map((C)=>C.trim()).join(", ")}) => ${w}`)}return`{ ${r.join(", ")} }`}function yo(e){let t=e;for(let i of["defineProps","defineEmits","defineExpose","defineSlots","defineOptions"])t=td(t,i);return t}function td(e,t){let i=new RegExp(`\\b${t}\\b`,"g"),n=[],r=e,o;while((o=i.exec(e))!==null){let s=e.lastIndexOf(`
101
- `,o.index)+1,a=e.slice(s,o.index),c=/^\s*(?:(?:const|let|var)\s+[A-Za-z_$][\w$]*\s*(?::[^=]+)?=\s*)?(withDefaults\s*\(\s*)?$/.exec(a);if(!c)continue;let f=o.index+o[0].length;while(f<e.length&&/\s/.test(e[f]))f++;if(e[f]==="<"){let m=go(e,f);if(m===-1)continue;f=m+1;while(f<e.length&&/\s/.test(e[f]))f++}if(e[f]!=="(")continue;let u=je(e,f,"(",")");if(u===-1)continue;if(c[1]){let m=s+a.length-c[1].length,y=e.indexOf("(",m);if(y!==-1){let w=je(e,y,"(",")");if(w!==-1)u=w}}let l=u+1;while(l<e.length&&e[l]!==`
102
- `&&/\s|;/.test(e[l]))l++;if(e[l]===`
103
- `)l++;n.push([s,l])}for(let s=n.length-1;s>=0;s--)r=r.slice(0,n[s][0])+r.slice(n[s][1]);return r}function Co(e){let t=id(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 n=t+i.length;while(n<e.length&&/\s/.test(e[n]))n++;let r=-1,o=-1,s=-1;if(e[n]==="{")r=n,o=je(e,n,"{","}"),s=o;else if(e.startsWith("defineComponent",n)){let f=e.indexOf("(",n);if(f!==-1){let u=f+1;while(u<e.length&&/\s/.test(e[u]))u++;if(e[u]==="{")r=u,o=je(e,u,"{","}"),s=je(e,f,"(",")")}}if(r===-1||o===-1||s===-1)return{options:null,script:e,passthrough:!0};let a=s+1;if(e[a]===";")a++;let c=(e.slice(0,t)+e.slice(a)).trim();return{options:e.slice(r,o+1),script:c,passthrough:!1}}return{options:null,script:e,passthrough:!1}}function id(e){let t=0,i=0;while(i<e.length){let n=e[i];if(n==='"'||n==="'"){i=et(e,i);continue}if(n==="`"){i=at(e,i);continue}if(n==="/"&&(e[i+1]==="/"||e[i+1]==="*")){i=pt(e,i);continue}if(n==="{"||n==="["||n==="(")t++;else if(n==="}"||n==="]"||n===")")t=Math.max(0,t-1);else if(t===0&&e.startsWith("export",i)){let r=i===0?"":e[i-1],o=e[i+6]??"";if(!/[\w$]/.test(r)&&!/[\w$]/.test(o)){if(/^export\s+default\b/.exec(e.slice(i)))return i}}i++}return-1}function Rr(e,t){let i=Ti(e).find((n)=>n.key===t);return i&&i.value!==""?i.value:null}function Pr(e,t){let i=nd(e),n=e;for(let r=i.length-1;r>=0;r--){let o=i[r],s=n.slice(0,o.start)+n.slice(o.end);if(rd(s,o.name))continue;if(new RegExp(`\\btypeof\\s+${o.name}\\b`).test(t))continue;n=s}return n}function rd(e,t){let i=0;while(i<e.length){let n=e[i];if(n==='"'||n==="'"){i=et(e,i);continue}if(n==="`"){i=at(e,i);continue}if(n==="/"&&(e[i+1]==="/"||e[i+1]==="*")){i=pt(e,i);continue}if(/[A-Za-z_$]/.test(n)){let r=i+1;while(r<e.length&&/[\w$]/.test(e[r]))r++;if(e.slice(i,r)===t)return!0;i=r;continue}i++}return!1}function nd(e){let t=[],i=od(e),n=/^[ \t]*(const|let|var|(?:async[ \t]+)?function)[ \t]+([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=?/gm,r;while((r=n.exec(e))!==null){let o=e.lastIndexOf(`
104
- `,r.index)+1;if(!i.has(o))continue;if(/\bexport\b/.test(e.slice(o,r.index)))continue;let s=r[1],a=r[2],c=r.index+r[0].length,f=-1;if(s.endsWith("function")){let u=e.indexOf("(",c);if(u===-1)continue;let l=je(e,u,"(",")");if(l===-1)continue;c=l+1;while(c<e.length&&/\s/.test(e[c]))c++;if(e[c]===":")while(c<e.length&&e[c]!=="{"&&e[c]!==`
94
+ `;return i}}function jh(e,t,i={}){return ol(e,t,i,new WeakMap)}function ol(e,t,i,n){let{arrayMergeMode:r="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 sl(e,t,r,n);if(!st(t)||!st(e))return t;return Kh(e,t,i,n)}function sl(e,t,i,n){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 _h(e,t);case"smart":return Vh(e,t,n);default:return t}return t}function _h(e,t){let i=[...t];for(let n of e)if(!i.some((r)=>to(r,n)))i.push(n);return i}function Vh(e,t,i){if(t.length===0)return e;if(e.length===0)return t;if(st(t[0])&&st(e[0]))return Uh(e,t,i);if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let r of e)if(!n.includes(r))n.push(r);return n}return t}function Uh(e,t,i){let n=[...t];for(let r of e){if(!st(r)){n.push(r);continue}let o=["id","name","key","path","type"],s=!1;for(let l of o)if(l in r){if(n.find((c)=>st(c)&&(l in c)&&c[l]===r[l])){s=!0;break}}if(!s)n.push(r)}return n}function Kh(e,t,i,n){let r=t;if(st(r)&&n.has(r))return n.get(r);let o={...e};if(st(r))n.set(r,o);for(let s in r){if(!Object.prototype.hasOwnProperty.call(r,s))continue;let l=r[s],c=o[s];if(i.skipNullish&&(l===null||l===void 0))continue;if(l===null||l===void 0){o[s]=l;continue}if(st(l)&&st(c))o[s]=ol(c,l,i,n);else if(Array.isArray(l)||Array.isArray(c))o[s]=sl(c,l,i.arrayMergeMode||"smart",n);else o[s]=l}return o}function al(e,t,i="replace"){return jh(e,t,{arrayMergeMode:i==="replace"?"replace":"smart",skipNullish:!0})}function to(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(!to(e[i],t[i]))return!1;return!0}if(st(e)&&st(t)){let i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return!1;for(let r of i){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!to(e[r],t[r]))return!1}return!0}return!1}function st(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class ll{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(e,t,i={}){let{arrayStrategy:n="replace",useCache:r=!0,cacheTtl:o,trackPerformance:s=!0,verbose:l=!1}=i;if(r){let f=mr.getWithFileCheck("file",e);if(f){if(l)console.log(`Configuration loaded from cache: ${e}`);return f}}let c=async()=>{if(!rr(e))return null;try{let f=`?t=${Date.now()}`,u=await import(e+f),a=u.default||u,m="default"in u,y=Object.keys(u).length>0;if(!m&&!y)throw new Sr(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof a!=="object"||a===null||Array.isArray(a))throw new Sr(e,Error("Configuration must export a valid object"),"unknown");let w={config:al(t,a,n),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(r)mr.setWithFileCheck("file",w,e,o);return w}catch(f){throw f instanceof Error?ai.configLoad(e,f):ai.configLoad(e,Error(String(f)))}};if(s)return io.track("loadFromPath",c,{path:e});return c()}async tryLoadFromPaths(e,t,i={}){for(let n of e)try{let r=await this.loadFromPath(n,t,i);if(r)return r}catch(r){if(r instanceof Error&&r.name==="ConfigLoadError")throw r;if(i.verbose)console.warn(`Failed to load config from ${n}:`,r)}return null}generateConfigPaths(e,t,i){let n=this.generateNamePatterns(e,i),r=[];for(let o of n)for(let s of this.extensions)r.push(Wn(t,`${o}${s}`));return r}generateNamePatterns(e,t){let i=[];if(i.push("config",".config"),e)i.push(e,`.${e}.config`,`${e}.config`,`.${e}`);let n=t===void 0?[]:Array.isArray(t)?t:[t];for(let o of n){if(!o)continue;if(i.push(o,`.${o}.config`,`${o}.config`,`.${o}`),e)i.push(`${e}.${o}.config`,`.${e}.${o}.config`)}let r=new Set;return i.filter((o)=>{if(!o||r.has(o))return!1;return r.add(o),!0})}checkFileAccess(e){return Gh(async()=>rr(e),{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,t,i){let n=[];if(!rr(e))return n;if(t||i){let r=this.generateNamePatterns(t||"",i);for(let o of r)for(let s of this.extensions){let l=Wn(e,`${o}${s}`);if(await this.checkFileAccess(l))n.push(l)}}else try{let{readdirSync:r}=await import("fs"),o=r(e);for(let s of o)if(this.looksLikeConfigFile(s)){let l=Wn(e,s);if(await this.checkFileAccess(l))n.push(l)}}catch{return[]}return n}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(!rr(e))return t.push("Configuration file does not exist"),t;let i=await import(e),n=i.default||i;if(n===void 0)t.push("Configuration file must export a default value or named exports");else if(typeof n!=="object"||n===null)t.push("Configuration must be an object");else if(Array.isArray(n))t.push("Configuration cannot be an array at the root level");if(e.endsWith(".json"))try{let{readFileSync:r}=await import("fs"),o=r(e,"utf8");JSON.parse(o)}catch(r){t.push(`Invalid JSON syntax: ${r}`)}}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(n)=>{try{let r=await this.loadFromPath(n,{},t);if(r)i.set(n,r.config)}catch(r){if(t.verbose)console.warn(`Failed to preload ${n}:`,r)}})),i}}class cl{async validateConfiguration(e,t,i={}){let{stopOnFirstError:n=!1,validateRequired:r=!0,validateTypes:o=!0,customRules:s=[],trackPerformance:l=!0,verbose:c=!1}=i,f=async()=>{let u=[],a=[],m={stopOnFirstError:n,validateRequired:r,validateTypes:o,customRules:s,trackPerformance:l,verbose:c};try{if(typeof t==="string")return await this.validateWithSchemaFile(e,t,m);else if(Array.isArray(t))return this.validateWithRules(e,[...t,...s],m);else return this.validateWithJSONSchema(e,t,m)}catch(y){return u.push({path:"",message:`Validation failed: ${y}`,rule:"system"}),{isValid:!1,errors:u,warnings:a}}};if(l)return await io.track("validateConfiguration",f);return f()}async validateWithSchemaFile(e,t,i){try{if(!Au(t))throw new $r(t,[{path:"",message:"Schema file does not exist"}]);let n=await import(t),r=n.default||n;if(Array.isArray(r))return this.validateWithRules(e,r,i);else return this.validateWithJSONSchema(e,r,i)}catch(n){throw new $r(t,[{path:"",message:`Failed to load schema: ${n}`}])}}validateWithJSONSchema(e,t,i){let n=[],r=[];return this.validateObjectAgainstSchema(e,t,"",n,r,i),{isValid:n.length===0,errors:n,warnings:r}}validateObjectAgainstSchema(e,t,i,n,r,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(n.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(n.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)n.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)n.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))n.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)n.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)n.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,n,r,o),o.stopOnFirstError&&n.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(n.push({path:i?`${i}.${l}`:l,message:`Missing required property '${l}'`,expected:"required",rule:"required"}),o.stopOnFirstError)return}}if(t.properties){for(let[l,c]of Object.entries(t.properties))if(l in s){let f=i?`${i}.${l}`:l;if(this.validateObjectAgainstSchema(s[l],c,f,n,r,o),o.stopOnFirstError&&n.length>0)return}}if(t.additionalProperties===!1){let l=new Set(Object.keys(t.properties||{}));for(let c of Object.keys(s))if(!l.has(c))r.push({path:i?`${i}.${c}`:c,message:`Additional property '${c}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(e,t,i){let n=[],r=[];for(let o of t)try{let s=this.getValueByPath(e,o.path),l=this.validateWithRule(s,o,o.path);if(n.push(...l),i.stopOnFirstError&&n.length>0)break}catch(s){n.push({path:o.path,message:`Rule validation failed: ${s}`,rule:"system"})}return{isValid:n.length===0,errors:n,warnings:r}}validateWithRule(e,t,i){let n=[];if(t.required&&(e===void 0||e===null))return n.push({path:i,message:t.message||`Property '${i}' is required`,expected:"required",rule:"required"}),n;if(e===void 0||e===null)return n;if(t.type){let r=Array.isArray(e)?"array":typeof e;if(r!==t.type)n.push({path:i,message:t.message||`Expected type ${t.type}, got ${r}`,expected:t.type,actual:r,rule:"type"})}if(t.min!==void 0){let r=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(r<t.min)n.push({path:i,message:t.message||`Value must be at least ${t.min}`,expected:`>= ${t.min}`,actual:r,rule:"min"})}if(t.max!==void 0){let r=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(r>t.max)n.push({path:i,message:t.message||`Value must not exceed ${t.max}`,expected:`<= ${t.max}`,actual:r,rule:"max"})}if(t.pattern&&typeof e==="string"){if(!t.pattern.test(e))n.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))n.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 r=t.validator(e);if(r)n.push({path:i,message:t.message||r,rule:"custom"})}return n}getValueByPath(e,t){if(!t)return e;let i=t.split("."),n=e;for(let r of i)if(n&&typeof n==="object"&&r in n)n=n[r];else return;return n}generateRulesFromInterface(e){let t=[],i=e.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let n of i){let[,r,o,s]=n;t.push({path:r,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:Hh},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}function zh(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 fl{fileLoader=new ll;envProcessor=new uo;validator=new cl;async loadConfig(e){let t=Date.now(),{cache:i,performance:n,schema:r,validate:o,...s}=e;try{if(i?.enabled){let c=this.checkCache(s.name||"",s);if(c)return c}let l;try{l=await this.loadConfigurationStrategies(s,!0,i)}catch(c){let f=s.__strictErrorHandling;if(c instanceof Error&&c.name==="ConfigNotFoundError"){if(f)throw c;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(c instanceof Error&&c.name==="ConfigLoadError"){let u=c.message.includes("EACCES")||c.message.includes("EPERM")||c.message.includes("permission denied"),a=!u&&(c.message.includes("syntax")||c.message.includes("Expected")||c.message.includes("Unexpected")||c.message.includes("BuildMessage")||c.message.includes("errors building")),m=c.message.includes("Configuration must export a valid object")||c.message.includes("Configuration file is empty and exports nothing");if(f&&(m||u))throw c;if(a&&(!f||!m))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: ${c.message}`]};else throw c}else l={...await this.applyEnvironmentVariables(s.name||"",s.defaultConfig,s.checkEnv!==!1,s.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${c instanceof Error?c.message:String(c)}`]}}if(r||o)await this.validateConfiguration(l.config,r,o,s.name);if(i?.enabled&&l)this.cacheResult(s.name||"",l,i,s);if(n?.enabled){let c={operation:"loadConfig",duration:Date.now()-t,configName:s.name,timestamp:new Date};if(n.onMetrics)n.onMetrics(c);if(n.slowThreshold&&c.duration>n.slowThreshold)Ct.warn(`Slow configuration loading detected: ${c.duration}ms for ${s.name}`);l.metrics=c}return l}catch(l){if(l instanceof Error&&l.name==="ConfigNotFoundError")throw l;let c=Date.now()-t;throw Ct.error(`Configuration loading failed after ${c}ms:`,[l instanceof Error?l:Error(String(l))]),l}}async loadConfigurationStrategies(e,t=!1,i){let{name:n="",alias:r,cwd:o,configDir:s,defaultConfig:l,checkEnv:c=!0,arrayStrategy:f="replace",verbose:u=!1}=e,a=o||xr.cwd(),m=[],y=await this.loadLocalConfiguration(n,r,a,s,l,f,u,c,i);if(y)return m.push(...this.getLocalSearchPaths(n,r,a,s)),this.finalizeResult(y,m,c,n,u);let w=await this.loadHomeConfiguration(n,r,l,f,u,c);if(w)return m.push(...this.getHomeSearchPaths(n,r)),this.finalizeResult(w,m,c,n,u);let C=await this.loadPackageJsonConfiguration(n,r,a,l,f,u,c);if(C)return m.push(nt(a,"package.json")),this.finalizeResult(C,m,c,n,u);if(m.push(...this.getAllSearchPaths(n,r,a,s)),t)throw ai.configNotFound(n,m,r);return{...await this.applyEnvironmentVariables(n,l,c,u),warnings:[`No configuration file found for "${n}"${zh(r)}, using defaults with environment variables`]}}async loadLocalConfiguration(e,t,i,n,r,o,s,l,c){let f=l?or(e,r,s):r,u=this.getLocalDirectories(i,n);for(let a of u){if(s)Ct.info(`Searching for configuration in: ${a}`);let m=this.fileLoader.generateConfigPaths(e,a,t),y=await this.fileLoader.tryLoadFromPaths(m,f,{arrayStrategy:o,verbose:s,cacheTtl:c?.ttl,useCache:!c?.ttl||c.ttl>100});if(y){if(s)Ct.success(`Configuration loaded from: ${y.source.path}`);return y}}return null}async loadHomeConfiguration(e,t,i,n,r,o){if(!e)return null;let s=o?or(e,i,r):i,l=[nt(qt(),".config",e),nt(qt(),".config"),qt()];for(let c of l){if(r)Ct.info(`Checking home directory: ${c}`);let f=this.fileLoader.generateConfigPaths(e,c,t),u=await this.fileLoader.tryLoadFromPaths(f,s,{arrayStrategy:n,verbose:r});if(u){if(r)Ct.success(`Configuration loaded from home directory: ${u.source.path}`);return u}}return null}async loadPackageJsonConfiguration(e,t,i,n,r,o,s){let l=s?or(e,n,o):n;try{let c=nt(i,"package.json");if(!Gf(c))return null;let f={};try{f=JSON.parse(jf(c,"utf8"))}catch(m){if(o)Ct.warn("Failed to parse package.json:",[m instanceof Error?m:Error(String(m))]);return null}let u=f[e],a=e;if(!u&&t){let m=Array.isArray(t)?t:[t];for(let y of m){if(!y)continue;if(f[y]){u=f[y],a=y;break}}}if(u&&typeof u==="object"&&!Array.isArray(u)){if(o)Ct.success(`Configuration loaded from package.json: ${a}`);return{config:al(l,u,r),source:{type:"package.json",path:c,priority:30,timestamp:new Date}}}}catch(c){if(o)Ct.warn("Failed to load package.json:",[c instanceof Error?c:Error(String(c))])}return null}async applyEnvironmentVariables(e,t,i,n){if(!i||!e||typeof t!=="object"||t===null||Array.isArray(t))return{config:t,source:{type:"default",priority:10,timestamp:new Date}};return{config:or(e,t,n),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(e,t,i,n,r){return{config:e.config,source:e.source,path:e.source.path}}async validateConfiguration(e,t,i,n){let r=[];if(i){let o=i(e);if(o)r.push(...o)}if(t){let o=await this.validator.validateConfiguration(e,t);if(!o.isValid)r.push(...o.errors.map((s)=>s.path?`${s.path}: ${s.message}`:s.message))}if(r.length>0)throw ai.configValidation(n||"unknown",r,n)}checkCache(e,t){let i=this.generateCacheKey(e,t);return mr.get(i)||null}cacheResult(e,t,i,n){let r=this.generateCacheKey(e,n);mr.set(r,t,void 0,i.ttl)}generateCacheKey(e,t){let i=[e];if(t.alias){let n=Array.isArray(t.alias)?t.alias.join(","):t.alias;i.push(`alias:${n}`)}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,nt(e,"config"),nt(e,".config"),t?nt(e,t):void 0].filter(Boolean)))}getAllSearchPaths(e,t,i,n){let r=[];return r.push(...this.getLocalSearchPaths(e,t,i,n)),r.push(...this.getHomeSearchPaths(e,t)),r.push(nt(i,"package.json")),r}getLocalSearchPaths(e,t,i,n){let r=this.getLocalDirectories(i,n),o=[];for(let s of r)o.push(...this.fileLoader.generateConfigPaths(e,s,t));return o}getHomeSearchPaths(e,t){if(!e)return[];let i=[nt(qt(),".config",e),nt(qt(),".config"),qt()],n=[];for(let r of i)n.push(...this.fileLoader.generateConfigPaths(e,r,t));return n}async loadConfigWithResult(e){return this.loadConfig(e)}}function or(e,t,i=!1){let n=new uo,r=e.toUpperCase().replace(/[^A-Z0-9]/g,"_");function o(s,l=[]){let c={...s};for(let[f,u]of Object.entries(s)){let a=[...l,f],m=[`${r}_${a.join("_").toUpperCase()}`,`${r}_${a.map((C)=>C.toUpperCase()).join("")}`,`${r}_${a.map((C)=>C.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],y,w;for(let C of m)if(y=xr.env[C],y!==void 0){w=C;break}if(y!==void 0&&w)if(typeof u==="boolean")c[f]=["true","1","yes"].includes(y.toLowerCase());else if(typeof u==="number"){let C=Number(y);if(!Number.isNaN(C))c[f]=C}else if(Array.isArray(u))try{c[f]=JSON.parse(y)}catch{c[f]=y.split(",").map((C)=>C.trim())}else c[f]=y;else if(u&&typeof u==="object"&&!Array.isArray(u))c[f]=o(u,a)}return c}return o(t)}var mr,io,Tu,Ou=(e)=>e,Pu=(e,t)=>{for(var i in t)Tu(e,i,{get:t[i],enumerable:!0,configurable:!0,set:Ru.bind(t,i)})},ku=(e,t)=>()=>(e&&(t=e(e=0)),t),Ma,ja,si,Si,_a,nh,oh,ga,ar,zn,Ue,Se,sh,ya,ah,Ca,lh,ch,Bn,fh,wa,ba,Gn,uh,hh,dh,ph,lr,Va,mh,Ke,gh,yh,Ea,cr,Jn,Le,fe,Ch,va,wh,Sa,bh,Eh,jn,vh,$a,xa,Sh,_n,$h,xh,Ah,Th,Oh,fr,Ua,Rh,Ph="0.15.6",Qe,br,Ei,qn,Yn,Er,Zn,Xn,vi,Qn,eo,Pt,Ka,Ha,ct,vt,za,Ja,kh,Dh,qa,vr,Fy,Za,pe,Ly,Nh,Wy,Fh,By,Gy,Aa,jy,Lh,Wh,_y,Ta,Vy,Uy,Ky,Hy,zy,Vn,Bh,Jy,ft,Xa,Sr,Qa,el,fo,tl,il,$r,rl,nl,ai,Hh,Ct,qy,Yy,Zy,Jh,ul;var hl=de(()=>{mr=new Pa,io=new ka,Tu=Object.defineProperty;Ma={};Pu(Ma,{withErrorRecovery:()=>Na,tryLoadConfig:()=>eh,loadConfigWithResult:()=>Xu,loadConfig:()=>Ga,isRetryableError:()=>Hu,isConfigNotFoundError:()=>Ku,isBunfigError:()=>Fa,globalPerformanceMonitor:()=>Si,globalCache:()=>si,getEnvOrDefault:()=>zu,generateConfigTypes:()=>th,defaultGeneratedDir:()=>Ja,defaultConfigDir:()=>za,deepMergeWithArrayStrategy:()=>ao,deepMerge:()=>La,createLibraryConfig:()=>ih,config:()=>Qu,bunfigPlugin:()=>rh,applyEnvVarsToConfig:()=>wi,TypeGenerationError:()=>Xn,SchemaValidationError:()=>vi,PluginError:()=>eo,PerformanceMonitor:()=>no,FileSystemError:()=>Zn,ErrorFactory:()=>Pt,EnvVarError:()=>Er,EnvProcessor:()=>Ar,ConfigValidator:()=>lo,ConfigValidationError:()=>qn,ConfigNotFoundError:()=>br,ConfigMergeError:()=>Yn,ConfigLoader:()=>co,ConfigLoadError:()=>Ei,ConfigFileLoader:()=>Tr,ConfigCache:()=>ro,CacheUtils:()=>_a,BunfigError:()=>Qe,BrowserConfigError:()=>Qn,ArrayMergeStrategies:()=>Ka});kh=ku(async()=>{ja=import.meta.require,si=new ro,Si=new no,_a={createKey:Mu,isEquivalent:Du,estimateMemoryUsage:Iu},nh=dr(Kn.cwd(),"config"),oh=dr(Kn.cwd(),"src/generated"),ga=hr.env.CLARITY_LOG_DIR||zf(Lu(),"logs"),ar={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:ga,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1},zn=await Wu(),Ue={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"},Se=Ue,sh=Ue.red,ya=Ue.green,ah=Ue.yellow,Ca=Ue.blue,lh=Ue.magenta,ch=Ue.cyan,Bn=Ue.white,fh=Ue.gray,wa=Ue.bgRed,ba=Ue.bgYellow,Gn=Ue.bold,uh=Ue.dim,hh=Ue.italic,dh=Ue.underline,ph=Ue.reset,lr={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},Va={debug:"\uD83D\uDD0D",info:Ca("\u2139"),success:ya("\u2713"),warning:ba(Bn(Gn(" WARN "))),error:wa(Bn(Gn(" ERROR ")))},mh=new yr("stacks"),Ke=new yr("bunfig",{showTags:!0}),gh=Je(bi.cwd(),"config"),yh=Je(bi.cwd(),"src/generated"),Ea=ur.env.CLARITY_LOG_DIR||Kf(_u(),"logs"),cr={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:Ea,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},Jn=await Vu(),Le={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"},fe=Le,Ch=Le.red,va=Le.green,wh=Le.yellow,Sa=Le.blue,bh=Le.magenta,Eh=Le.cyan,jn=Le.white,vh=Le.gray,$a=Le.bgRed,xa=Le.bgYellow,Sh=Le.bgGray,_n=Le.bold,$h=Le.dim,xh=Le.italic,Ah=Le.underline,Th=Le.strikethrough,Oh=Le.reset,fr={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},Ua={debug:"\uD83D\uDD0D",info:Sa("\u2139"),success:va("\u2713"),warning:xa(jn(_n(" WARN "))),error:$a(jn(_n(" ERROR ")))},Rh=new wr("stacks"),Qe=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}`}},br=class extends Qe{code="CONFIG_NOT_FOUND";constructor(e,t,i){let n=i?` or alias "${i}"`:"";super(`Configuration "${e}"${n} not found`,{configName:e,alias:i,searchPaths:t,searchPathCount:t.length})}},Ei=class extends Qe{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}},qn=class extends Qe{code="CONFIG_VALIDATION_ERROR";constructor(e,t,i){super(`Configuration validation failed for "${e}"`,{configPath:e,configName:i,validationErrors:t,errorCount:t.length})}},Yn=class extends Qe{code="CONFIG_MERGE_ERROR";constructor(e,t,i,n){super(`Failed to merge configuration from "${e}" with "${t}": ${i.message}`,{sourcePath:e,targetPath:t,configName:n,originalError:i.name,originalMessage:i.message});this.cause=i}},Er=class extends Qe{code="ENV_VAR_ERROR";constructor(e,t,i,n){super(`Failed to parse environment variable "${e}" with value "${t}" as ${i}`,{envKey:e,envValue:t,expectedType:i,configName:n})}},Zn=class extends Qe{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}},Xn=class extends Qe{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}},vi=class extends Qe{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})}},Qn=class extends Qe{code="BROWSER_CONFIG_ERROR";constructor(e,t,i,n){super(`Failed to fetch configuration from "${e}": ${t} ${i}`,{endpoint:e,status:t,statusText:i,configName:n})}},eo=class extends Qe{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}},Pt={configNotFound(e,t,i){return new br(e,t,i)},configLoad(e,t,i){return new Ei(e,t,i)},configValidation(e,t,i){return new qn(e,t,i)},configMerge(e,t,i,n){return new Yn(e,t,i,n)},envVar(e,t,i,n){return new Er(e,t,i,n)},fileSystem(e,t,i){return new Zn(e,t,i)},typeGeneration(e,t,i){return new Xn(e,t,i)},schemaValidation(e,t,i){return new vi(e,t,i)},browserConfig(e,t,i,n){return new Qn(e,t,i,n)},plugin(e,t,i){return new eo(e,t,i)}},Ka={replace:"replace",concat:"concat",smart:"smart"},Ha=/^https?:\/\//,ct=new wr("bunfig",{showTags:!0}),vt=new co,za=qe(Ft.cwd(),"config"),Ja=qe(Ft.cwd(),"src/generated")});Dh=pr.env.CLARITY_LOG_DIR||mu(Mh(),"logs"),qa={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:Dh,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},vr={...qa},Fy=(async()=>{try{let{loadConfig:e}=await kh().then(()=>Ma),t=await e({name:"clarity",alias:"logging",defaultConfig:qa,cwd:pr.cwd()});if(t)Object.assign(vr,t)}catch{}return vr})();Za={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=Za,{red:Ly,green:Nh,yellow:Wy,blue:Fh,magenta:By,cyan:Gy,white:Aa,gray:jy,bgRed:Lh,bgYellow:Wh,bgGray:_y,bold:Ta,dim:Vy,italic:Uy,underline:Ky,strikethrough:Hy,reset:zy}=Za,Vn={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},Bh={debug:"\uD83D\uDD0D",info:Fh("\u2139"),success:Nh("\u2713"),warning:Wh(Aa(Ta(" WARN "))),error:Lh(Aa(Ta(" ERROR ")))};Jy=new Or("stacks");ft=class ft 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}`}};Xa=class Xa extends ft{code="CONFIG_NOT_FOUND";constructor(e,t,i){let n=i===void 0?[]:Array.isArray(i)?i.filter(Boolean):[i],r="";if(n.length===1)r=` or alias "${n[0]}"`;else if(n.length>1)r=` or aliases ${n.map((o)=>`"${o}"`).join(", ")}`;super(`Configuration "${e}"${r} not found`,{configName:e,alias:i,searchPaths:t,searchPathCount:t.length})}};Sr=class Sr extends ft{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}};Qa=class Qa extends ft{code="CONFIG_VALIDATION_ERROR";constructor(e,t,i){super(`Configuration validation failed for "${e}"`,{configPath:e,configName:i,validationErrors:t,errorCount:t.length})}};el=class el extends ft{code="CONFIG_MERGE_ERROR";constructor(e,t,i,n){super(`Failed to merge configuration from "${e}" with "${t}": ${i.message}`,{sourcePath:e,targetPath:t,configName:n,originalError:i.name,originalMessage:i.message});this.cause=i}};fo=class fo extends ft{code="ENV_VAR_ERROR";constructor(e,t,i,n){super(`Failed to parse environment variable "${e}" with value "${t}" as ${i}`,{envKey:e,envValue:t,expectedType:i,configName:n})}};tl=class tl extends ft{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}};il=class il extends ft{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}};$r=class $r extends ft{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})}};rl=class rl extends ft{code="BROWSER_CONFIG_ERROR";constructor(e,t,i,n){super(`Failed to fetch configuration from "${e}": ${t} ${i}`,{endpoint:e,status:t,statusText:i,configName:n})}};nl=class nl extends ft{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 Xa(e,t,i)},configLoad(e,t,i){return new Sr(e,t,i)},configValidation(e,t,i){return new Qa(e,t,i)},configMerge(e,t,i,n){return new el(e,t,i,n)},envVar(e,t,i,n){return new fo(e,t,i,n)},fileSystem(e,t,i){return new tl(e,t,i)},typeGeneration(e,t,i){return new il(e,t,i)},schemaValidation(e,t,i){return new $r(e,t,i)},browserConfig(e,t,i,n){return new rl(e,t,i,n)},plugin(e,t,i){return new nl(e,t,i)}};Hh=/^https?:\/\//;Ct=new Or("bunfig",{showTags:!0});qy=new fl;Yy=nt(xr.cwd(),"config"),Zy=nt(xr.cwd(),"src/generated"),Jh={cwd:Bf.cwd(),root:"./src",entrypoints:["**/*.{ts,tsx,mts,cts,vue,stx}"],outdir:"./dist",keepComments:!0,clean:!0,tsconfigPath:"./tsconfig.json",outputStructure:"mirror",verbose:!1,importOrder:["bun"],declarationMap:!1},ul=Jh});function dl(e,t,i){let n={file:t,message:"Unknown error",code:$i.UNKNOWN_ERROR};if(e instanceof Error){n.message=e.message,n.stack=e.stack;let r=e.message.match(/\((\d+),(\d+)\)/);if(r)n.location={line:Number.parseInt(r[1],10),column:Number.parseInt(r[2],10)};if(e.message.includes("Cannot find")||e.message.includes("not found"))n.code=$i.FILE_NOT_FOUND,n.suggestion="Check that the file path is correct and the file exists.";else if(e.message.includes("syntax")||e.message.includes("Unexpected token"))n.code=$i.SYNTAX_ERROR,n.suggestion="Check for syntax errors in your TypeScript code.";else if(e.message.includes("type")&&e.message.includes("cannot"))n.code=$i.TYPE_INFERENCE_ERROR,n.suggestion="Add explicit type annotations to help with type inference.";else if(e.message.includes("parse")||e.message.includes("Parse"))n.code=$i.PARSE_ERROR,n.suggestion="The file contains invalid TypeScript syntax."}else if(typeof e==="string")n.message=e;return n}function pl(e,t){let i=[],n=e.file;if(e.location)n+=`:${e.location.line}:${e.location.column}`;if(e.code)n+=` [${e.code}]`;if(i.push(n),i.push(` Error: ${e.message}`),t&&e.location){i.push("");let r=t.split(`
95
+ `),o=e.location.line-1;if(o>=0&&o<r.length){let s=Math.max(0,o-1),l=Math.min(r.length-1,o+1);for(let c=s;c<=l;c++){let f=(c+1).toString().padStart(4," "),u=c===o?">":" ";if(i.push(` ${u} ${f} | ${r[c]}`),c===o&&e.location.column>0){let a=" ".repeat(10+e.location.column-1);i.push(` ${a}^`)}}}}if(e.suggestion)i.push(""),i.push(` Suggestion: ${e.suggestion}`);return i.join(`
96
+ `)}var $i;var ml=de(()=>{$i={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"}});function yl(e){return e.endsWith(".vue")}function qh(e){let t={script:null,scriptSetup:null},i=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,n;while((n=i.exec(e))!==null){let r=n[1]||"",o=/lang\s*=\s*["']([^"']+)["']/i.exec(r)?.[1]?.toLowerCase()??"js",s={content:n[2]??"",attrs:r,setup:/\bsetup\b/.test(r),lang:o};if(s.setup)t.scriptSetup=s;else t.script=s}return t}function et(e,t){let i=e[t];t++;while(t<e.length){let n=e[t];if(n==="\\"){t+=2;continue}if(n===i)return t+1;t++}return t}function at(e,t){t++;let i=0;while(t<e.length){let n=e[t];if(n==="\\"){t+=2;continue}if(n==="`"&&i===0)return t+1;if(n==="$"&&e[t+1]==="{"){i++,t+=2;continue}if(n==="}"){if(i>0)i--;t++;continue}t++}return t}function dt(e,t){if(e[t+1]==="/"){let i=e.indexOf(`
97
+ `,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 po(e,t){let i=e[t];if(i==='"'||i==="'")return et(e,t);if(i==="`")return at(e,t);if(i==="/"&&(e[t+1]==="/"||e[t+1]==="*"))return dt(e,t);return t}function mo(e){let t=e.split(""),i=0;while(i<e.length){let n=po(e,i);if(n>i){for(let r=i;r<n;r++)if(t[r]!==`
98
+ `&&t[r]!=="\r")t[r]=" ";i=n;continue}i++}return t.join("")}function Ge(e,t,i,n){let r=0,o=t;while(o<e.length){let s=e[o];if(s==='"'||s==="'"){o=et(e,o);continue}if(s==="`"){o=at(e,o);continue}if(s==="/"&&(e[o+1]==="/"||e[o+1]==="*")){o=dt(e,o);continue}if(s===i)r++;else if(s===n){if(r--,r===0)return o}o++}return-1}function go(e,t){let i=0,n=t;while(n<e.length){let r=e[n];if(r==='"'||r==="'"){n=et(e,n);continue}if(r==="`"){n=at(e,n);continue}if(r==="/"&&(e[n+1]==="/"||e[n+1]==="*")){n=dt(e,n);continue}if(r==="="&&e[n+1]===">"){n+=2;continue}if(r==="<")i++;else if(r===">"){if(i--,i===0)return n}n++}return-1}function li(e,t=","){let i=[],n=0,r="",o=0;while(o<e.length){let s=e[o];if(s==='"'||s==="'"){let l=et(e,o);r+=e.slice(o,l),o=l;continue}if(s==="`"){let l=at(e,o);r+=e.slice(o,l),o=l;continue}if(s==="/"&&(e[o+1]==="/"||e[o+1]==="*")){o=dt(e,o);continue}if(s==="{"||s==="["||s==="("||s==="<")n++;else if(s==="}"||s==="]"||s===")"||s===">")n--;if(s===t&&n===0){i.push(r),r="",o++;continue}r+=s,o++}if(r.trim()!=="")i.push(r);return i}function Ti(e){let t=e.trim();if(!t.startsWith("{"))return[];let i=Ge(t,0,"{","}");if(i===-1)return[];let n=t.slice(1,i),r=[];for(let o of li(n)){let s=-1,l=0;for(let u=0;u<o.length;u++){let a=o[u];if(a==='"'||a==="'"){u=et(o,u)-1;continue}if(a==="`"){u=at(o,u)-1;continue}if(a==="{"||a==="["||a==="("||a==="<")l++;else if(a==="}"||a==="]"||a===")"||a===">")l--;else if(a===":"&&l===0){s=u;break}}if(s!==-1){r.push({key:xi(o.slice(0,s).trim()),value:o.slice(s+1).trim(),isMethod:!1});continue}let c=/^([A-Za-z_$][\w$]*|['"][^'"]+['"])\s*\(/.exec(o.trim());if(c){r.push({key:xi(c[1]),value:o.trim(),isMethod:!0});continue}let f=o.trim();if(f)r.push({key:xi(f),value:"",isMethod:!1})}return r}function xi(e){if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);return e}function Ai(e){return/^[A-Za-z_$][\w$]*$/.test(e)?e:JSON.stringify(e)}function Oi(e,t){let i=new RegExp(`\\b${t}\\b`,"g"),n;while((n=i.exec(e))!==null){let r=n.index+n[0].length;while(r<e.length&&/\s/.test(e[r]))r++;let o=null;if(e[r]==="<"){let c=go(e,r);if(c===-1)return null;o=e.slice(r+1,c).trim(),r=c+1;while(r<e.length&&/\s/.test(e[r]))r++}if(e[r]!=="(")continue;let s=Ge(e,r,"(",")");if(s===-1)return null;let l=li(e.slice(r+1,s));return{generic:o,arg:l.length>0?l[0].trim():null}}return null}function Yh(e,t){let i=Cl(e,t);if(!i)return null;return i.kind==="interface"?e.slice(i.bodyStart,i.end):e.slice(i.bodyStart,i.end).trim()}function Cl(e,t){let i=new RegExp(`\\binterface\\s+${t}\\b[^{]*\\{`,"m").exec(e);if(i){let r=i.index+i[0].length-1,o=Ge(e,r,"{","}");if(o!==-1)return{kind:"interface",start:i.index,end:o+1,bodyStart:r}}let n=new RegExp(`\\btype\\s+${t}\\b[^=]*=`,"m").exec(e);if(n){let r=n.index+n[0].length,o=0,s=r;while(r<e.length){let l=e[r];if(l==='"'||l==="'"){r=et(e,r);continue}if(l==="`"){r=at(e,r);continue}if(l==="{"||l==="["||l==="("||l==="<")o++;else if(l==="}"||l==="]"||l===")"||l===">")o--;else if((l===";"||l===`
99
+ `)&&o===0)break;r++}return{kind:"type",start:n.index,end:r,bodyStart:s}}return null}function Zh(e){let t=e.search(/\bas\s+PropType\s*</);if(t===-1)return null;let i=e.indexOf("<",t),n=go(e,i);if(n===-1)return null;if(e.slice(n+1).trim()!=="")return null;return e.slice(i+1,n).trim()}function ho(e){let t=e.trim(),i=Zh(t);if(i!==null)return{type:i,optional:!0};if(t==="null")return{type:"unknown",optional:!0};if(t.startsWith("[")){let n=Ge(t,0,"[","]");if(n!==-1){let r=li(t.slice(1,n)).map((o)=>ho(o).type).filter((o)=>o!=="unknown");return{type:r.length>0?[...new Set(r)].join(" | "):"unknown",optional:!0}}}if(t.startsWith("{")){let n=Ti(t),r=n.find((c)=>c.key==="type"),o=n.find((c)=>c.key==="required"),s=r?ho(r.value).type:"unknown",l=!(o&&o.value.trim()==="true");return{type:s,optional:l}}if(gl[t])return{type:gl[t],optional:!0};if(/^[A-Za-z_$][\w$.]*$/.test(t))return{type:t,optional:!0};return{type:"unknown",optional:!0}}function Mr(e){let t=e.trim();if(t.startsWith("{")){let i=Ti(t);if(i.length===0)return"{}";return`{ ${i.map((n)=>{if(n.isMethod||n.value==="")return`${Ai(n.key)}?: unknown`;let r=ho(n.value);return`${Ai(n.key)}${r.optional?"?":""}: ${r.type}`}).join(", ")} }`}if(t.startsWith("[")){let i=Ge(t,0,"[","]");if(i===-1)return null;let n=li(t.slice(1,i)).map((r)=>xi(r.trim())).filter((r)=>r!=="");if(n.length===0)return"{}";return`{ ${n.map((r)=>`${Ai(r)}?: unknown`).join(", ")} }`}return null}function Xh(e){let t=e.trim();if(!t.startsWith("["))return null;let i=Ge(t,0,"[","]");if(i===-1)return null;let n=li(t.slice(1,i)).map((r)=>r.trim());if(n.length===0)return"{}";if(!n.every((r)=>r.startsWith("'")&&r.endsWith("'")||r.startsWith('"')&&r.endsWith('"')))return"string[]";return`[${n.map((r)=>JSON.stringify(xi(r))).join(", ")}]`}function Qh(e){let t=e.trim();if(!t.startsWith("{"))return null;let i=Ti(t);if(i.length===0)return"{}";return`{ ${i.map((n)=>`${JSON.stringify(n.key)}: (...args: any[]) => void`).join(", ")} }`}function wl(e){return Xh(e)??Qh(e)}function ed(e){let t=[],i=0,n="",r=0;while(r<e.length){let o=e[r];if(o==='"'||o==="'"){let s=et(e,r);n+=e.slice(r,s),r=s;continue}if(o==="`"){let s=at(e,r);n+=e.slice(r,s),r=s;continue}if(o==="/"&&(e[r+1]==="/"||e[r+1]==="*")){let s=dt(e,r);n+=e.slice(r,s),r=s;continue}if(o==="="&&e[r+1]===">"){n+="=>",r+=2;continue}if(o==="{"||o==="["||o==="("||o==="<")i++;else if(o==="}"||o==="]"||o===")"||o===">")i--;if((o===";"||o===","||o===`
100
+ `)&&i===0){if(n.trim()!=="")t.push(n.trim());n="",r++;continue}n+=o,r++}if(n.trim()!=="")t.push(n.trim());return t}function td(e){let t=e.trim();if(!t.startsWith("{"))return null;let i=Ge(t,0,"{","}");if(i===-1||t.slice(i+1).trim()!=="")return null;let n=ed(t.slice(1,i));if(n.length===0)return"{}";let r=[];for(let o of n){let s=/^\(\s*\w+\s*:\s*/.exec(o);if(!s)return null;let l=s[0].length,c=o[l];if(c!=="'"&&c!=='"'&&c!=="`")return null;let f=et(o,l),u=o.slice(l+1,f-1),a=Ge(o,o.indexOf("(",0),"(",")");if(a===-1)return null;let m=o.slice(l,a),y=li(m).slice(1),w=o.slice(a+1).trim();if(w.startsWith(":"))w=w.slice(1).trim();if(w==="")w="void";r.push(`${JSON.stringify(u)}: (${y.map((C)=>C.trim()).join(", ")}) => ${w}`)}return`{ ${r.join(", ")} }`}function yo(e){let t=e;for(let i of["defineProps","defineEmits","defineExpose","defineSlots","defineOptions"])t=id(t,i);return t}function id(e,t){let i=new RegExp(`\\b${t}\\b`,"g"),n=[],r=e,o;while((o=i.exec(e))!==null){let s=e.lastIndexOf(`
101
+ `,o.index)+1,l=e.slice(s,o.index),c=/^\s*(?:(?:const|let|var)\s+[A-Za-z_$][\w$]*\s*(?::[^=]+)?=\s*)?(withDefaults\s*\(\s*)?$/.exec(l);if(!c)continue;let f=o.index+o[0].length;while(f<e.length&&/\s/.test(e[f]))f++;if(e[f]==="<"){let m=go(e,f);if(m===-1)continue;f=m+1;while(f<e.length&&/\s/.test(e[f]))f++}if(e[f]!=="(")continue;let u=Ge(e,f,"(",")");if(u===-1)continue;if(c[1]){let m=s+l.length-c[1].length,y=e.indexOf("(",m);if(y!==-1){let w=Ge(e,y,"(",")");if(w!==-1)u=w}}let a=u+1;while(a<e.length&&e[a]!==`
102
+ `&&/\s|;/.test(e[a]))a++;if(e[a]===`
103
+ `)a++;n.push([s,a])}for(let s=n.length-1;s>=0;s--)r=r.slice(0,n[s][0])+r.slice(n[s][1]);return r}function Co(e){let t=rd(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 n=t+i.length;while(n<e.length&&/\s/.test(e[n]))n++;let r=-1,o=-1,s=-1;if(e[n]==="{")r=n,o=Ge(e,n,"{","}"),s=o;else if(e.startsWith("defineComponent",n)){let f=e.indexOf("(",n);if(f!==-1){let u=f+1;while(u<e.length&&/\s/.test(e[u]))u++;if(e[u]==="{")r=u,o=Ge(e,u,"{","}"),s=Ge(e,f,"(",")")}}if(r===-1||o===-1||s===-1)return{options:null,script:e,passthrough:!0};let l=s+1;if(e[l]===";")l++;let c=(e.slice(0,t)+e.slice(l)).trim();return{options:e.slice(r,o+1),script:c,passthrough:!1}}return{options:null,script:e,passthrough:!1}}function rd(e){let t=0,i=0;while(i<e.length){let n=e[i];if(n==='"'||n==="'"){i=et(e,i);continue}if(n==="`"){i=at(e,i);continue}if(n==="/"&&(e[i+1]==="/"||e[i+1]==="*")){i=dt(e,i);continue}if(n==="{"||n==="["||n==="(")t++;else if(n==="}"||n==="]"||n===")")t=Math.max(0,t-1);else if(t===0&&e.startsWith("export",i)){let r=i===0?"":e[i-1],o=e[i+6]??"";if(!/[\w$]/.test(r)&&!/[\w$]/.test(o)){if(/^export\s+default\b/.exec(e.slice(i)))return i}}i++}return-1}function Rr(e,t){let i=Ti(e).find((n)=>n.key===t);return i&&i.value!==""?i.value:null}function Pr(e,t){let i=od(e),n=e;for(let r=i.length-1;r>=0;r--){let o=i[r],s=n.slice(0,o.start)+n.slice(o.end);if(nd(s,o.name))continue;if(new RegExp(`\\btypeof\\s+${o.name}\\b`).test(t))continue;n=s}return n}function nd(e,t){let i=0;while(i<e.length){let n=e[i];if(n==='"'||n==="'"){i=et(e,i);continue}if(n==="`"){i=at(e,i);continue}if(n==="/"&&(e[i+1]==="/"||e[i+1]==="*")){i=dt(e,i);continue}if(/[A-Za-z_$]/.test(n)){let r=i+1;while(r<e.length&&/[\w$]/.test(e[r]))r++;if(e.slice(i,r)===t)return!0;i=r;continue}i++}return!1}function od(e){let t=[],i=sd(e),n=/^[ \t]*(const|let|var|(?:async[ \t]+)?function)[ \t]+([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=?/gm,r;while((r=n.exec(e))!==null){let o=e.lastIndexOf(`
104
+ `,r.index)+1;if(!i.has(o))continue;if(/\bexport\b/.test(e.slice(o,r.index)))continue;let s=r[1],l=r[2],c=r.index+r[0].length,f=-1;if(s.endsWith("function")){let u=e.indexOf("(",c);if(u===-1)continue;let a=Ge(e,u,"(",")");if(a===-1)continue;c=a+1;while(c<e.length&&/\s/.test(e[c]))c++;if(e[c]===":")while(c<e.length&&e[c]!=="{"&&e[c]!==`
105
105
  `)c++;while(c<e.length&&/\s/.test(e[c])&&e[c]!==`
106
- `)c++;if(e[c]!=="{")continue;let m=je(e,c,"{","}");if(m===-1)continue;f=m+1}else{let u=0;while(c<e.length){let l=e[c];if(l==='"'||l==="'"){c=et(e,c);continue}if(l==="`"){c=at(e,c);continue}if(l==="/"&&(e[c+1]==="/"||e[c+1]==="*")){c=pt(e,c);continue}if(l==="{"||l==="["||l==="(")u++;else if(l==="}"||l==="]"||l===")")u--;else if(l===";"&&u===0){f=c+1;break}else if(l===`
106
+ `)c++;if(e[c]!=="{")continue;let m=Ge(e,c,"{","}");if(m===-1)continue;f=m+1}else{let u=0;while(c<e.length){let a=e[c];if(a==='"'||a==="'"){c=et(e,c);continue}if(a==="`"){c=at(e,c);continue}if(a==="/"&&(e[c+1]==="/"||e[c+1]==="*")){c=dt(e,c);continue}if(a==="{"||a==="["||a==="(")u++;else if(a==="}"||a==="]"||a===")")u--;else if(a===";"&&u===0){f=c+1;break}else if(a===`
107
107
  `&&u===0){f=c;break}c++}if(f===-1)f=e.length}if(e[f]===`
108
- `)f++;t.push({name:a,start:r.index,end:f})}return t}function od(e){let t=new Set([0]),i=0,n=0;while(n<e.length){let r=e[n];if(r==='"'||r==="'"){n=et(e,n);continue}if(r==="`"){n=at(e,n);continue}if(r==="/"&&(e[n+1]==="/"||e[n+1]==="*")){n=pt(e,n);continue}if(r==="{"||r==="["||r==="(")i++;else if(r==="}"||r==="]"||r===")")i=Math.max(0,i-1);if(r===`
108
+ `)f++;t.push({name:l,start:r.index,end:f})}return t}function sd(e){let t=new Set([0]),i=0,n=0;while(n<e.length){let r=e[n];if(r==='"'||r==="'"){n=et(e,n);continue}if(r==="`"){n=at(e,n);continue}if(r==="/"&&(e[n+1]==="/"||e[n+1]==="*")){n=dt(e,n);continue}if(r==="{"||r==="["||r==="(")i++;else if(r==="}"||r==="]"||r===")")i=Math.max(0,i-1);if(r===`
109
109
  `&&i===0)t.add(n+1);n++}return t}function kr(e,t,i){let n=e.indexOf(i);if(n===-1)return e;let r=e.lastIndexOf(`
110
- `,n)+1;if(/\bexport\b/.test(e.slice(r,n)))return e;let o=e.slice(0,n)+e.slice(n+i.length);if(new RegExp(`\\b${t}\\b`).test(o))return e;return o}function wo(e){let t="",i=0,n=()=>{for(let o=t.length-1;o>=0;o--)if(!/\s/.test(t[o]))return t[o];return""},r=(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=et(e,i);t+=e.slice(i,s),i=s;continue}if(o==="`"){let s=at(e,i);t+=e.slice(i,s),i=s;continue}if(o==="/"&&e[i+1]==="*"){let s=pt(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]!==`
111
- `)s++;let a=e.slice(i+2,s).trim();if(a!==""&&!a.includes("*/"))t+=`/* ${a} */`;i=s;continue}if(o===`
112
- `){let s=n(),a=r(i+1);if(s===""||a===""){i++;continue}let c=sd(t);if(!c&&("{;,(<:=[".includes(s)||"}),]>;|&".includes(a))){if(!t.endsWith(" ")&&!t.endsWith(";"))t+=" "}else if(c){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 sd(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 n=i-1;n>=0;n--){let r=e[n];if(/\s/.test(r))continue;return"{;,(<:".includes(r)}return!0}function Dr(e,t){let i=[e,t].filter((n)=>n!==null);for(let n of i){let r=Oi(n,"defineProps");if(!r)continue;if(r.generic){let o=r.generic;if(o.startsWith("{"))return{type:o};if(/^[A-Za-z_$][\w$]*$/.test(o)){for(let s of i){let a=yl(s,o);if(!a)continue;let c=qh(s,o);if(c===null)continue;return{type:c,inlinedLocal:{name:o,declText:s.slice(a.start,a.end)}}}return{type:o}}return{type:o}}if(r.arg){let o=Mr(r.arg);if(o!==null)return{type:o}}}return null}function Eo(e,t){let i=[e,t].filter((n)=>n!==null);for(let n of i){let r=Oi(n,"defineEmits");if(!r)continue;if(r.generic)return ed(r.generic)??r.generic;if(r.arg){let o=Cl(r.arg);if(o!==null)return o}}return null}function vo(e,t){let i=[e,t].filter((n)=>n!==null);for(let n of i){let r=Oi(n,"defineExpose");if(!r||!r.arg||!r.arg.startsWith("{"))continue;let o=Ti(r.arg);if(o.length===0)return null;return`{ ${o.map((s)=>{if(s.value===""&&/^[A-Za-z_$][\w$]*$/.test(s.key))return`${xi(s.key)}: typeof ${s.key}`;let a=s.isMethod||/=>|^\s*function\b/.test(s.value);return`${xi(s.key)}: ${a?"(...args: any[]) => any":"unknown"}`}).join(", ")} }`}return null}function wl(e){let t=Jh(e),i="",n=null,r=null;if(t.script){let x=Co(t.script.content);if(x.passthrough)return t.scriptSetup?`${t.script.content}
113
- ${t.scriptSetup.content}`:t.script.content;if(i=x.script,x.options){let k=Rr(x.options,"props");if(k)n=Mr(k);let L=Rr(x.options,"emits");if(L)r=Cl(L)}}let o=t.scriptSetup?.content??null,s=o!==null?yo(o):null,a=Dr(o,o!==null?null:i),c=a?.type??n??"{}",f=Eo(o,null)??r,u=vo(o,null),l=a?.inlinedLocal;if(l){if(i=kr(i,l.name,l.declText),s!==null)s=kr(s,l.name,l.declText)}let m=[c,u??"{}"];if(f)m.push("{}","{}","{}","{}","{}",f);let y=wo(`DefineComponent<${m.join(", ")}>`),w=[],C=Pr(i,y);if(C.trim()!=="")w.push(C);if(s&&s.trim()!==""){let x=Pr(s,y);if(x.trim()!=="")w.push(x)}return w.push("import type { DefineComponent } from 'vue'"),w.push(`type __DtsxComponentType = ${y}`),w.push("const __dtsx_component__: __DtsxComponentType = null as unknown as __DtsxComponentType"),w.push("export default __dtsx_component__"),w.join(`
114
- `)}var ml;var bo=ue(()=>{ml={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 vl(e){return e.endsWith(".stx")}function ad(e){let t=[],i=/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi,n;while((n=i.exec(e))!==null){let r=n[1]??"",o=/\blang\s*=\s*["']([^"']+)["']/i.exec(r)?.[1]?.toLowerCase()??(/\b(?:type\s*=\s*["'](?:text\/)?typescript["']|typescript)\b/i.test(r)?"ts":"js"),s=/\bserver\b/i.test(r)?"server":/\bclient\b/i.test(r)?"client":"universal";t.push({content:n[2]??"",kind:"script",attrs:r,context:s,lang:o,start:n.index})}return t}function ld(e){let t=[],i=/^[ \t]*@ts[ \t]*(?:\r?\n|$)/gm,n;while((n=i.exec(e))!==null){let r=i.lastIndex,o=/^[ \t]*@endts[ \t]*(?:\r?\n|$)/gm;o.lastIndex=r;let s=o.exec(e),a=s?.index??e.length;if(t.push({content:e.slice(r,a),kind:"ts",attrs:"",context:"universal",lang:"ts",start:n.index}),!s)break;i.lastIndex=o.lastIndex}return t}function cd(e){return[...ad(e),...ld(e)].sort((t,i)=>t.start-i.start)}function fd(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 ud(e){let t=/(?:\$?props)\s+as\s+/g,i;while((i=t.exec(e))!==null){let n=t.lastIndex;while(n<e.length&&/\s/.test(e[n]))n++;if(e[n]==="{"){let s=je(e,n,"{","}");if(s!==-1)return e.slice(n,s+1).trim();continue}let r=/^[A-Za-z_$][\w$]*/.exec(e.slice(n))?.[0];if(!r)continue;let o=n+r.length;while(o<e.length&&/\s/.test(e[o]))o++;if(e[o]==="<"){let s=je(e,o,"<",">");if(s!==-1)o=s+1}return e.slice(n,o).trim()}return null}function hd(e){return/\b(?:const|let|var)\s+\$?props\s*:\s*([^=;\n]+)/.exec(e)?.[1]?.trim()??null}function dd(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 pd(e,t){if(!e||e==="unknown")return t;if(t==="unknown"||e===t)return e;return[...new Set([...e.split(" | "),...t.split(" | ")])].join(" | ")}function md(e){let t=mo(e),i=new Map,n=/\$props(?:\.([A-Za-z_$][\w$]*)|\[\s*(['"])([^'"\n]+)\2\s*\])/g,r;while((r=n.exec(e))!==null){if(t.slice(r.index,r.index+6)!=="$props")continue;let o=r[1]??r[3],s=dd(e.slice(n.lastIndex));i.set(o,pd(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 gd(e){let t=Dr(e,null);if(t)return t;let i=ud(e)??hd(e);if(!i)return md(e);if(/^[A-Za-z_$][\w$]*$/.test(i)){let n=i.replace(/[$]/g,"\\$&");if(new RegExp(`\\bexport\\s+(?:declare\\s+)?(?:interface|type)\\s+${n}\\b`).test(e))return{type:i}}return Dr(`${e}
115
- defineProps<${i}>()`,null)}function yd(e){return yo(e)}function El(e){let t=mo(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 Cd(e){let t=[],i=0,n=0,r=0;while(r<e.length){let s=e[r],a=po(e,r);if(a>r){r=a;continue}if(s==="{"||s==="["||s==="(")n++;else if(s==="}"||s==="]"||s===")")n=Math.max(0,n-1);if((s===";"||s===`
116
- `)&&n===0){let c=r+1;if(!El(e.slice(i,c)))t.push([i,c]);i=c}r++}if(i<e.length&&!El(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 bl(e){let t=cd(e).filter(fd).map((C)=>C.content).join(`
117
- `),i=null,n=Co(t);if(n.passthrough)return t;if(t=n.script,n.options){let C=Rr(n.options,"props");if(C)i=Mr(C)}let r=t,o=yd(t),s=gd(r),a=s?.type??i??"{}",c=Eo(r,null),f=vo(r,null),u=Oi(r,"defineSlots")?.generic??null,l=s?.inlinedLocal;if(l)o=kr(o,l.name,l.declText);let m=`DefineComponent<${a}>`,y=[];if(c)y.push(`readonly __stxEmits?: ${c}`);if(u)y.push(`readonly __stxSlots?: ${u}`);if(f)y.push(`readonly __stxExposed?: ${f}`);if(y.length>0)m+=` & { ${y.join(", ")} }`;m=wo(m),o=Cd(Pr(o,m));let w=["import type { DefineComponent } from '@stacksjs/stx'",`type __DtsxStxComponentType = ${m}`,"const __dtsx_component__: __DtsxStxComponentType = null as unknown as __DtsxStxComponentType","export default __dtsx_component__"];if(o.trim()!=="")w.push(o);return w.join(`
118
- `)}var Sl=ue(()=>{bo()});function $t(e,t=!0){if(!t||!e||e.length===0)return"";if(e.length===1){let n=e[0];if(n.length>0&&n.charCodeAt(0)>32&&n.charCodeAt(n.length-1)>32)return`${n}
110
+ `,n)+1;if(/\bexport\b/.test(e.slice(r,n)))return e;let o=e.slice(0,n)+e.slice(n+i.length);if(new RegExp(`\\b${t}\\b`).test(o))return e;return o}function wo(e){let t="",i=0,n=()=>{for(let o=t.length-1;o>=0;o--)if(!/\s/.test(t[o]))return t[o];return""},r=(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=et(e,i);t+=e.slice(i,s),i=s;continue}if(o==="`"){let s=at(e,i);t+=e.slice(i,s),i=s;continue}if(o==="/"&&e[i+1]==="*"){let s=dt(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]!==`
111
+ `)s++;let l=e.slice(i+2,s).trim();if(l!==""&&!l.includes("*/"))t+=`/* ${l} */`;i=s;continue}if(o===`
112
+ `){let s=n(),l=r(i+1);if(s===""||l===""){i++;continue}let c=ad(t);if(!c&&("{;,(<:=[".includes(s)||"}),]>;|&".includes(l))){if(!t.endsWith(" ")&&!t.endsWith(";"))t+=" "}else if(c){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 ad(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 n=i-1;n>=0;n--){let r=e[n];if(/\s/.test(r))continue;return"{;,(<:".includes(r)}return!0}function Dr(e,t){let i=[e,t].filter((n)=>n!==null);for(let n of i){let r=Oi(n,"defineProps");if(!r)continue;if(r.generic){let o=r.generic;if(o.startsWith("{"))return{type:o};if(/^[A-Za-z_$][\w$]*$/.test(o)){for(let s of i){let l=Cl(s,o);if(!l)continue;let c=Yh(s,o);if(c===null)continue;return{type:c,inlinedLocal:{name:o,declText:s.slice(l.start,l.end)}}}return{type:o}}return{type:o}}if(r.arg){let o=Mr(r.arg);if(o!==null)return{type:o}}}return null}function bo(e,t){let i=[e,t].filter((n)=>n!==null);for(let n of i){let r=Oi(n,"defineEmits");if(!r)continue;if(r.generic)return td(r.generic)??r.generic;if(r.arg){let o=wl(r.arg);if(o!==null)return o}}return null}function Eo(e,t){let i=[e,t].filter((n)=>n!==null);for(let n of i){let r=Oi(n,"defineExpose");if(!r||!r.arg||!r.arg.startsWith("{"))continue;let o=Ti(r.arg);if(o.length===0)return null;return`{ ${o.map((s)=>{if(s.value===""&&/^[A-Za-z_$][\w$]*$/.test(s.key))return`${Ai(s.key)}: typeof ${s.key}`;let l=s.isMethod||/=>|^\s*function\b/.test(s.value);return`${Ai(s.key)}: ${l?"(...args: any[]) => any":"unknown"}`}).join(", ")} }`}return null}function bl(e){let t=qh(e),i="",n=null,r=null;if(t.script){let A=Co(t.script.content);if(A.passthrough)return t.scriptSetup?`${t.script.content}
113
+ ${t.scriptSetup.content}`:t.script.content;if(i=A.script,A.options){let k=Rr(A.options,"props");if(k)n=Mr(k);let W=Rr(A.options,"emits");if(W)r=wl(W)}}let o=t.scriptSetup?.content??null,s=o!==null?yo(o):null,l=Dr(o,o!==null?null:i),c=l?.type??n??"{}",f=bo(o,null)??r,u=Eo(o,null),a=l?.inlinedLocal;if(a){if(i=kr(i,a.name,a.declText),s!==null)s=kr(s,a.name,a.declText)}let m=[c,u??"{}"];if(f)m.push("{}","{}","{}","{}","{}",f);let y=wo(`DefineComponent<${m.join(", ")}>`),w=[],C=Pr(i,y);if(C.trim()!=="")w.push(C);if(s&&s.trim()!==""){let A=Pr(s,y);if(A.trim()!=="")w.push(A)}return w.push("import type { DefineComponent } from 'vue'"),w.push(`type __DtsxComponentType = ${y}`),w.push("const __dtsx_component__: __DtsxComponentType = null as unknown as __DtsxComponentType"),w.push("export default __dtsx_component__"),w.join(`
114
+ `)}var gl;var vo=de(()=>{gl={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 vl(e){return e.endsWith(".stx")}function ld(e){let t=[],i=/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi,n;while((n=i.exec(e))!==null){let r=n[1]??"",o=/\blang\s*=\s*["']([^"']+)["']/i.exec(r)?.[1]?.toLowerCase()??(/\b(?:type\s*=\s*["'](?:text\/)?typescript["']|typescript)\b/i.test(r)?"ts":"js"),s=/\bserver\b/i.test(r)?"server":/\bclient\b/i.test(r)?"client":"universal";t.push({content:n[2]??"",kind:"script",attrs:r,context:s,lang:o,start:n.index})}return t}function cd(e){let t=[],i=/^[ \t]*@ts[ \t]*(?:\r?\n|$)/gm,n;while((n=i.exec(e))!==null){let r=i.lastIndex,o=/^[ \t]*@endts[ \t]*(?:\r?\n|$)/gm;o.lastIndex=r;let s=o.exec(e),l=s?.index??e.length;if(t.push({content:e.slice(r,l),kind:"ts",attrs:"",context:"universal",lang:"ts",start:n.index}),!s)break;i.lastIndex=o.lastIndex}return t}function fd(e){return[...ld(e),...cd(e)].sort((t,i)=>t.start-i.start)}function ud(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 hd(e){let t=/(?:\$?props)\s+as\s+/g,i;while((i=t.exec(e))!==null){let n=t.lastIndex;while(n<e.length&&/\s/.test(e[n]))n++;if(e[n]==="{"){let s=Ge(e,n,"{","}");if(s!==-1)return e.slice(n,s+1).trim();continue}let r=/^[A-Za-z_$][\w$]*/.exec(e.slice(n))?.[0];if(!r)continue;let o=n+r.length;while(o<e.length&&/\s/.test(e[o]))o++;if(e[o]==="<"){let s=Ge(e,o,"<",">");if(s!==-1)o=s+1}return e.slice(n,o).trim()}return null}function dd(e){return/\b(?:const|let|var)\s+\$?props\s*:\s*([^=;\n]+)/.exec(e)?.[1]?.trim()??null}function pd(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 md(e,t){if(!e||e==="unknown")return t;if(t==="unknown"||e===t)return e;return[...new Set([...e.split(" | "),...t.split(" | ")])].join(" | ")}function gd(e){let t=mo(e),i=new Map,n=/\$props(?:\.([A-Za-z_$][\w$]*)|\[\s*(['"])([^'"\n]+)\2\s*\])/g,r;while((r=n.exec(e))!==null){if(t.slice(r.index,r.index+6)!=="$props")continue;let o=r[1]??r[3],s=pd(e.slice(n.lastIndex));i.set(o,md(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 yd(e){let t=Dr(e,null);if(t)return t;let i=hd(e)??dd(e);if(!i)return gd(e);if(/^[A-Za-z_$][\w$]*$/.test(i)){let n=i.replace(/[$]/g,"\\$&");if(new RegExp(`\\bexport\\s+(?:declare\\s+)?(?:interface|type)\\s+${n}\\b`).test(e))return{type:i}}return Dr(`${e}
115
+ defineProps<${i}>()`,null)}function Cd(e){return yo(e)}function El(e){let t=mo(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 wd(e){let t=[],i=0,n=0,r=0;while(r<e.length){let s=e[r],l=po(e,r);if(l>r){r=l;continue}if(s==="{"||s==="["||s==="(")n++;else if(s==="}"||s==="]"||s===")")n=Math.max(0,n-1);if((s===";"||s===`
116
+ `)&&n===0){let c=r+1;if(!El(e.slice(i,c)))t.push([i,c]);i=c}r++}if(i<e.length&&!El(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 Sl(e){let t=fd(e).filter(ud).map((C)=>C.content).join(`
117
+ `),i=null,n=Co(t);if(n.passthrough)return t;if(t=n.script,n.options){let C=Rr(n.options,"props");if(C)i=Mr(C)}let r=t,o=Cd(t),s=yd(r),l=s?.type??i??"{}",c=bo(r,null),f=Eo(r,null),u=Oi(r,"defineSlots")?.generic??null,a=s?.inlinedLocal;if(a)o=kr(o,a.name,a.declText);let m=`DefineComponent<${l}>`,y=[];if(c)y.push(`readonly __stxEmits?: ${c}`);if(u)y.push(`readonly __stxSlots?: ${u}`);if(f)y.push(`readonly __stxExposed?: ${f}`);if(y.length>0)m+=` & { ${y.join(", ")} }`;m=wo(m),o=wd(Pr(o,m));let w=["import type { DefineComponent } from '@stacksjs/stx'",`type __DtsxStxComponentType = ${m}`,"const __dtsx_component__: __DtsxStxComponentType = null as unknown as __DtsxStxComponentType","export default __dtsx_component__"];if(o.trim()!=="")w.push(o);return w.join(`
118
+ `)}var $l=de(()=>{vo()});function $t(e,t=!0){if(!t||!e||e.length===0)return"";if(e.length===1){let n=e[0];if(n.length>0&&n.charCodeAt(0)>32&&n.charCodeAt(n.length-1)>32)return`${n}
119
119
  `;return`${n.trim()}
120
120
  `}let i="";for(let n=0;n<e.length;n++){if(n>0)i+=`
121
121
  `;i+=e[n].trim()}return`${i}
122
- `}function Po(e){return e.replaceAll("*/","*\\/")}function $o(e){return Pl(e).replace(/\n[ \t]*(?=\n)/g,"")}function Pl(e){if(e.indexOf("/*")===-1)return e.trim();let t=[],i=0,n=0,r=e.length;while(n<r)if(e.charCodeAt(n)===47&&n+1<r&&e.charCodeAt(n+1)===42){if(n>i)t.push(e.substring(i,n));n+=2;while(n<r-1){if(e.charCodeAt(n)===42&&e.charCodeAt(n+1)===47){n+=2;break}n++}i=n}else n++;if(i<r)t.push(e.substring(i));return t.join("").trim()}function Mo(){Wr=!0,Ye=null}function Do(){Wr=!1;let e=Ye;return Ye=null,e}function Io(e){let t=e.length;if(t===0)return!1;let i=0;if(e.charCodeAt(i)===45)i++;if(i>=t)return!1;let n=i;while(i<t&&e.charCodeAt(i)>=48&&e.charCodeAt(i)<=57)i++;if(i===n)return!1;if(i<t&&e.charCodeAt(i)===46){i++;let r=i;while(i<t&&e.charCodeAt(i)>=48&&e.charCodeAt(i)<=57)i++;if(i===r)return!1}return i===t}function wd(e){for(let t=0,i=e.length-1;t<i;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return!0}function So(e,t){let i=0,n=0;while((n=e.indexOf(t,n))!==-1)i++,n+=t.length;return i}function $l(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 Ir(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 n=2;while(n<t.length&&$l(t.charCodeAt(n)))n++;let r=t.slice(1,n),o=t.charCodeAt(n);if(o>32&&o!==62&&o!==47)return!1;if(t.endsWith("/>"))return!0;let s=t.lastIndexOf("</");if(s===-1)return!1;let a=s+2;while(a<t.length&&$l(t.charCodeAt(a)))a++;return t.slice(s+2,a)===r&&t.charCodeAt(a)===62&&a===t.length-1}function Nr(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 a=e.charCodeAt(s);if(a===10||a===13||a===9){i=!0;break}}if(!i)return e;let n=[],r=-1,o=!1;for(let s=0;s<t;s++)if(e.charCodeAt(s)<=32){if(!o){if(r>=0)n.push(e.substring(r,s));n.push(" "),o=!0,r=-1}}else{if(o||r<0)r=s;o=!1}if(r>=0)n.push(e.substring(r));return n.join("")}function Ie(e,t=!1,i=!1,n=0){if(!e||typeof e!=="string")return"unknown";if(n>=ko)return"unknown";let r=e.trim();if(Ir(r))return"JSX.Element";if(r.startsWith("BigInt("))return"bigint";if(r.startsWith("Symbol.for("))return"symbol";if(r.includes(".raw`")||r.includes("String.raw`"))return"string";if(r.startsWith("`")&&r.endsWith("`")){if(!t||r.includes("${")||r.includes(`
123
- `)||r.includes("\r"))return"string";return r}if(r.charCodeAt(0)===39||r.charCodeAt(0)===34){let s=Ed(r);if(s!==null){if(s==="string"||!t)return"string";return s}}if(Io(r)){if(!t)return"number";return r}if(r==="true"||r==="false"){if(!t)return"boolean";return r}if(r==="null")return"null";if(r==="undefined")return"undefined";if(r.startsWith("[")&&r.endsWith("]"))return To(r,t,n+1);if(r.startsWith("{")&&r.endsWith("}"))return Md(r,t,n+1);if(r.startsWith("class ")||r.startsWith("class{"))return Pd(r);if(r.startsWith("new "))return Rd(r);if(r.endsWith("as const")){let s=r.slice(0,-8).trim();if(s.startsWith("[")&&s.endsWith("]")){let a=s.slice(1,-1).trim();if(!a)return"readonly []";let c=Fr(a),f=[];for(let u=0;u<c.length;u++)f.push(Ie(c[u].trim(),!0,!1,n+1));return`readonly [${f.join(", ")}]`}return Ie(s,!0,i,n+1)}if(Lr(r)!==-1||r.startsWith("function")||r.startsWith("async"))return Wl(r,i,n,t);if(r.startsWith("`")&&r.endsWith("`"))return Od(r,t);if(r.startsWith("Promise."))return Il(r,t,n);if(r.startsWith("await "))return"unknown";if(r.charCodeAt(r.length-1)===110&&r.length>1&&wd(r)){if(t)return r;return"bigint"}if(r.startsWith("Symbol(")||r==="Symbol.for")return"symbol";let o=Nl(r);if(o!==null)return o;if(kl(r))return"boolean";if($d(r))return"number";return"unknown"}function Al(e){let t=e.charCodeAt(0);if(t!==39&&t!==34)return!1;return kt(e,0,t)===e.length}function Ed(e){if(Al(e))return e;let t=vd(e);if(t.length<2)return null;let i=!1,n=!0,r="";for(let o of t){let s=o.trim();if(Al(s))i=!0,r+=bd(s);else n=!1}if(n)return Sd(r);if(i)return"string";return null}function vd(e){let t=[],i=0,n=0,r=0;while(r<e.length){let o=e.charCodeAt(r);if(o===39||o===34||o===96){r=kt(e,r,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(n,r)),n=r+1;r++}return t.push(e.slice(n)),t}function bd(e){return e.slice(1,-1).replace(/\\(.)/g,(t,i)=>{if(i==="n")return`
124
- `;if(i==="t")return"\t";if(i==="r")return"\r";if(i==="0")return"\x00";return i})}function Sd(e){return`'${e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function $d(e){if(e==="")return!1;let t=!1,i=!1;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r>=48&&r<=57){t=!0;continue}if(r===43||r===45||r===42||r===47||r===37){i=!0;continue}if(r===46||r===40||r===41||r<=32)continue;return!1}return t&&i}function kl(e){let t=0;for(let i=0;i<e.length;i++){let n=e.charCodeAt(i);if(n===34||n===39||n===96){i=kt(e,i,n)-1;continue}if(n===40||n===91||n===123){t++;continue}if(n===41||n===93||n===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((n===62||n===60)&&e.charCodeAt(i-1)!==61&&e.charCodeAt(i+1)!==61)return!0}return!1}function Ad(e,t=!1,i=0){return Ie(e,t,!0,i)}function fi(e,t=!1,i=""){let n=Ml(i),r=[],o=!1,s=0;while(s<e.length){let c=e.charCodeAt(s);if(c===34||c===39||c===96){s=kt(e,s,c);continue}if(c===47&&e.charCodeAt(s+1)===47){s+=2;while(s<e.length&&e.charCodeAt(s)!==10&&e.charCodeAt(s)!==13)s++;continue}if(c===47&&e.charCodeAt(s+1)===42){let f=e.indexOf("*/",s+2);s=f===-1?e.length:f+2;continue}if(e.startsWith("function",s)&&Ao(e,s,8)||e.startsWith("class",s)&&Ao(e,s,5)){let f=Td(e,s);if(f!==-1){s=xo(e,f);continue}}if(c===61&&e.charCodeAt(s+1)===62){let f=s+2;while(f<e.length&&e.charCodeAt(f)<=32)f++;if(e.charCodeAt(f)===123){s=xo(e,f);continue}}if(e.startsWith("return",s)&&(s===0||!St(e.charCodeAt(s-1)))&&!St(e.charCodeAt(s+6))){s+=6;let f=!1;while(s<e.length&&e.charCodeAt(s)<=32){let x=e.charCodeAt(s);if(x===10||x===13)f=!0;s++}if(f||s>=e.length||e.charCodeAt(s)===59||e.charCodeAt(s)===125){o=!0;continue}let u=s,l=0,m=0,y=0;while(s<e.length){let x=e.charCodeAt(s);if(x===34||x===39||x===96){s=kt(e,s,x);continue}if(x===47&&e.charCodeAt(s+1)===47){if(l===0&&m===0&&y===0)break;while(s<e.length&&e.charCodeAt(s)!==10&&e.charCodeAt(s)!==13)s++;continue}if(x===47&&e.charCodeAt(s+1)===42){let k=e.indexOf("*/",s+2);s=k===-1?e.length:k+2;continue}if(x===40)l++;else if(x===41)l--;else if(x===91)m++;else if(x===93)m--;else if(x===123)y++;else if(x===125){if(y===0&&l===0&&m===0)break;y--}else if(x===59&&l===0&&m===0&&y===0)break;else if((x===10||x===13)&&l===0&&m===0&&y===0){let k=s+1;while(k<e.length&&e.charCodeAt(k)<=32)k++;if(e.startsWith("return",k)&&!St(e.charCodeAt(k+6)))break}s++}let w=e.slice(u,s).trim(),C=$o(Lt(w,n));if(!r.includes(C))r.push(C);continue}s++}if(o&&!r.includes("undefined"))r.push("undefined");let a=r.includes("unknown")?"unknown":r.length===0?"void":r.join(" | ");return t&&!a.startsWith("Promise<")?`Promise<${a}>`:a}function Ml(e){let t=new Map,i=e.startsWith("(")&&e.endsWith(")")?e.slice(1,-1):e,n=0,r=0,o=0;for(let s=0;s<=i.length;s++){let a=i.charCodeAt(s);if(a===40||a===91||a===123)r++;else if(a===41||a===93||a===125)r--;else if(a===60)o++;else if(a===62&&i.charCodeAt(s-1)!==61&&o>0)o--;if(s!==i.length&&(a!==44||r!==0||o!==0))continue;let c=i.slice(n,s).trim(),f=c.indexOf(":");if(f!==-1){let u=c.slice(0,f).trim().replace(/^\.\.\./,"").replace(/\?$/,""),l=c.slice(f+1).trim(),m=l.indexOf("=");if(m!==-1)l=l.slice(0,m).trim();if(Br(u)&&l)t.set(u,l)}n=s+1}return t}function Lt(e,t){let i=e.trim();while(Dl(i))i=i.slice(1,-1).trim();if(Ir(i))return"JSX.Element";if(i.startsWith("await ")){let o=Lt(i.slice(6),t);return o.startsWith("Promise<")&&o.endsWith(">")?o.slice(8,-1):o}if(t.has(i))return t.get(i);if(i.startsWith("!"))return"boolean";if(i.startsWith("fetch("))return"Promise<Response>";let n=xd(i);if(n){let o=Lt(n.whenTrue,t),s=Lt(n.whenFalse,t);return o===s?o:`${o} | ${s}`}if(kl(i))return"boolean";let r=0;for(let o=i.length-1;o>=0;o--){let s=i.charCodeAt(o);if(s===41||s===93||s===125)r++;else if(s===40||s===91||s===123)r--;else if(r===0&&(s===43||s===45||s===42||s===47||s===37)){let a=Lt(i.slice(0,o),t),c=Lt(i.slice(o+1),t);if(s===43&&(a==="string"||c==="string"))return"string";if(a==="number"&&c==="number")return"number";break}}return Ie(i,!1).replace(/\btypeof\s+[$A-Z_a-z][$\w]*/g,(o)=>{let s=o.slice(7);return t.get(s)??"unknown"})}function Dl(e){if(!e.startsWith("(")||!e.endsWith(")"))return!1;let t=0;for(let i=0;i<e.length;i++){let n=e.charCodeAt(i);if(n===40)t++;else if(n===41&&--t===0)return i===e.length-1}return!1}function xd(e){let t=0,i=-1;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===40||r===91||r===123)t++;else if(r===41||r===93||r===125)t--;else if(r===63&&t===0&&e.charCodeAt(n+1)!==63)i=n;else if(r===58&&t===0&&i!==-1)return{whenTrue:e.slice(i+1,n),whenFalse:e.slice(n+1)}}return null}function Ao(e,t,i){return(t===0||!St(e.charCodeAt(t-1)))&&!St(e.charCodeAt(t+i))}function Td(e,t){for(let i=t;i<e.length;i++){let n=e.charCodeAt(i);if(n===34||n===39||n===96){i=kt(e,i,n)-1;continue}if(n===123)return i;if(n===59)return-1}return-1}function xo(e,t){let i=1,n=t+1;while(n<e.length&&i>0){let r=e.charCodeAt(n);if(r===34||r===39||r===96){n=kt(e,n,r);continue}if(r===47&&e.charCodeAt(n+1)===47){n+=2;while(n<e.length&&e.charCodeAt(n)!==10&&e.charCodeAt(n)!==13)n++;continue}if(r===47&&e.charCodeAt(n+1)===42){let o=e.indexOf("*/",n+2);n=o===-1?e.length:o+2;continue}if(r===123)i++;else if(r===125)i--;n++}return n}function kt(e,t,i){let n=t+1;while(n<e.length){let r=e.charCodeAt(n);if(r===92){n+=2;continue}if(i===96&&r===36&&e.charCodeAt(n+1)===123){n=xo(e,n+1);continue}if(n++,r===i)break}return n}function Od(e,t){if(e.includes(".raw`")||e.includes("String.raw`"))return"string";if(!t||e.includes("${")||e.includes(`
125
- `)||e.includes("\r"))return"string";return e}function Rd(e){let t=4;while(t<e.length&&e.charCodeAt(t)<=32)t++;let i=t,n=e.charCodeAt(t);if(n<65||n>90)return"unknown";while(t<e.length&&(St(e.charCodeAt(t))||e.charCodeAt(t)===46))t++;if(t===i)return"unknown";let r=e.slice(i,t);{let o=e.slice(t),s=o;if(o.startsWith("<")){let c=0,f=-1;for(let u=0;u<o.length;u++)if(o[u]==="<")c++;else if(o[u]===">"){if(c--,c===0){f=u;break}}if(f!==-1){let u=o.slice(0,f+1);s=o.slice(f+1);let l=s.indexOf("(");if(l!==-1){let m=0,y=-1;for(let w=l;w<s.length;w++)if(s[w]==="(")m++;else if(s[w]===")"){if(m--,m===0){y=w;break}}if(y!==-1){if(s.slice(y+1).trimStart().startsWith("."))return"unknown"}}return`${r}${u}`}}let a=s.indexOf("(");if(a!==-1){let c=0,f=-1;for(let u=a;u<s.length;u++)if(s[u]==="(")c++;else if(s[u]===")"){if(c--,c===0){f=u;break}}if(f!==-1){if(s.slice(f+1).trimStart().startsWith("."))return"unknown"}}switch(r){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 r}}return"unknown"}function Pd(e){return"{ new (...args: any[]): any }"}function Il(e,t,i=0){if(e.startsWith("Promise.resolve(")){let n=e.indexOf(")",16);if(n!==-1){let r=e.slice(16,n).trim();if(r)return`Promise<${Ie(r,t,!1,i+1)}>`}return"Promise<unknown>"}if(e.startsWith("Promise.reject("))return"Promise<never>";if(e.startsWith("Promise.all(")){let n=e.indexOf("[",12),r=e.lastIndexOf("]");if(n!==-1&&r>n){let o=e.slice(n+1,r).trim(),s=Fr(o),a=[];for(let c=0;c<s.length;c++){let f=s[c].trim();if(f.startsWith("Promise.resolve(")){let u=Il(f,t,i+1),l=u.indexOf("<"),m=u.lastIndexOf(">");a.push(l!==-1&&m>l?u.slice(l+1,m):"unknown")}else a.push(Ie(f,t,!1,i+1))}return`Promise<[${a.join(", ")}]>`}return"Promise<unknown[]>"}return"Promise<unknown>"}function To(e,t,i=0){let n=e.slice(1,-1).trim();if(!n)return"never[]";if(i>=ko)return"unknown[]";let r=Fr(n),o=!1;for(let m=0;m<r.length;m++){let y=r[m],w=y.length;while(w>0&&y.charCodeAt(w-1)<=32)w--;if(w>=8&&y.slice(w-8,w)==="as const"){o=!0;break}}if(o){let m=[];for(let y=0;y<r.length;y++){let w=r[y].trim();if(w.endsWith("as const")){let C=w.slice(0,-8).trim();if(C.startsWith("[")&&C.endsWith("]")){let x=C.slice(1,-1).trim(),k=Fr(x),L=[];for(let W=0;W<k.length;W++)L.push(Ie(k[W].trim(),!0,!1,i+1));m.push(`readonly [${L.join(", ")}]`)}else m.push(Ie(C,!0,!1,i+1))}else if(w.startsWith("[")&&w.endsWith("]"))m.push(To(w,!0,i+1));else m.push(Ie(w,!0,!1,i+1))}return`readonly [
122
+ `}function Po(e){return e.replaceAll("*/","*\\/")}function $o(e){return kl(e).replace(/\n[ \t]*(?=\n)/g,"")}function kl(e){if(e.indexOf("/*")===-1)return e.trim();let t=[],i=0,n=0,r=e.length;while(n<r)if(e.charCodeAt(n)===47&&n+1<r&&e.charCodeAt(n+1)===42){if(n>i)t.push(e.substring(i,n));n+=2;while(n<r-1){if(e.charCodeAt(n)===42&&e.charCodeAt(n+1)===47){n+=2;break}n++}i=n}else n++;if(i<r)t.push(e.substring(i));return t.join("").trim()}function Mo(){Wr=!0,Ye=null}function Do(){Wr=!1;let e=Ye;return Ye=null,e}function Io(e){let t=e.length;if(t===0)return!1;let i=0;if(e.charCodeAt(i)===45)i++;if(i>=t)return!1;let n=i;while(i<t&&e.charCodeAt(i)>=48&&e.charCodeAt(i)<=57)i++;if(i===n)return!1;if(i<t&&e.charCodeAt(i)===46){i++;let r=i;while(i<t&&e.charCodeAt(i)>=48&&e.charCodeAt(i)<=57)i++;if(i===r)return!1}return i===t}function bd(e){for(let t=0,i=e.length-1;t<i;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return!0}function So(e,t){let i=0,n=0;while((n=e.indexOf(t,n))!==-1)i++,n+=t.length;return i}function xl(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 Ir(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 n=2;while(n<t.length&&xl(t.charCodeAt(n)))n++;let r=t.slice(1,n),o=t.charCodeAt(n);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&&xl(t.charCodeAt(l)))l++;return t.slice(s+2,l)===r&&t.charCodeAt(l)===62&&l===t.length-1}function Nr(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 n=[],r=-1,o=!1;for(let s=0;s<t;s++)if(e.charCodeAt(s)<=32){if(!o){if(r>=0)n.push(e.substring(r,s));n.push(" "),o=!0,r=-1}}else{if(o||r<0)r=s;o=!1}if(r>=0)n.push(e.substring(r));return n.join("")}function Ie(e,t=!1,i=!1,n=0){if(!e||typeof e!=="string")return"unknown";if(n>=ko)return"unknown";let r=e.trim();if(Ir(r))return"JSX.Element";if(r.startsWith("BigInt("))return"bigint";if(r.startsWith("Symbol.for("))return"symbol";if(r.includes(".raw`")||r.includes("String.raw`"))return"string";if(r.startsWith("`")&&r.endsWith("`")){if(!t||r.includes("${")||r.includes(`
123
+ `)||r.includes("\r"))return"string";return r}if(r.charCodeAt(0)===39||r.charCodeAt(0)===34){let s=Ed(r);if(s!==null){if(s==="string"||!t)return"string";return s}}if(Io(r)){if(!t)return"number";return r}if(r==="true"||r==="false"){if(!t)return"boolean";return r}if(r==="null")return"null";if(r==="undefined")return"undefined";if(r.startsWith("[")&&r.endsWith("]"))return To(r,t,n+1);if(r.startsWith("{")&&r.endsWith("}"))return Dd(r,t,n+1);if(r.startsWith("class ")||r.startsWith("class{"))return kd(r);if(r.startsWith("new "))return Pd(r);if(r.endsWith("as const")){let s=r.slice(0,-8).trim();if(s.startsWith("[")&&s.endsWith("]")){let l=s.slice(1,-1).trim();if(!l)return"readonly []";let c=Fr(l),f=[];for(let u=0;u<c.length;u++)f.push(Ie(c[u].trim(),!0,!1,n+1));return`readonly [${f.join(", ")}]`}return Ie(s,!0,i,n+1)}if(Lr(r)!==-1||r.startsWith("function")||r.startsWith("async"))return Bl(r,i,n,t);if(r.startsWith("`")&&r.endsWith("`"))return Rd(r,t);if(r.startsWith("Promise."))return Nl(r,t,n);if(r.startsWith("await "))return"unknown";if(r.charCodeAt(r.length-1)===110&&r.length>1&&bd(r)){if(t)return r;return"bigint"}if(r.startsWith("Symbol(")||r==="Symbol.for")return"symbol";let o=Fl(r);if(o!==null)return o;if(Ml(r))return"boolean";if(xd(r))return"number";return"unknown"}function Al(e){let t=e.charCodeAt(0);if(t!==39&&t!==34)return!1;return kt(e,0,t)===e.length}function Ed(e){if(Al(e))return e;let t=vd(e);if(t.length<2)return null;let i=!1,n=!0,r="";for(let o of t){let s=o.trim();if(Al(s))i=!0,r+=Sd(s);else n=!1}if(n)return $d(r);if(i)return"string";return null}function vd(e){let t=[],i=0,n=0,r=0;while(r<e.length){let o=e.charCodeAt(r);if(o===39||o===34||o===96){r=kt(e,r,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(n,r)),n=r+1;r++}return t.push(e.slice(n)),t}function Sd(e){return e.slice(1,-1).replace(/\\(.)/g,(t,i)=>{if(i==="n")return`
124
+ `;if(i==="t")return"\t";if(i==="r")return"\r";if(i==="0")return"\x00";return i})}function $d(e){return`'${e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function xd(e){if(e==="")return!1;let t=!1,i=!1;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r>=48&&r<=57){t=!0;continue}if(r===43||r===45||r===42||r===47||r===37){i=!0;continue}if(r===46||r===40||r===41||r<=32)continue;return!1}return t&&i}function Ml(e){let t=0;for(let i=0;i<e.length;i++){let n=e.charCodeAt(i);if(n===34||n===39||n===96){i=kt(e,i,n)-1;continue}if(n===40||n===91||n===123){t++;continue}if(n===41||n===93||n===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((n===62||n===60)&&e.charCodeAt(i-1)!==61&&e.charCodeAt(i+1)!==61)return!0}return!1}function Ad(e,t=!1,i=0){return Ie(e,t,!0,i)}function fi(e,t=!1,i=""){let n=Dl(i),r=[],o=!1,s=0;while(s<e.length){let c=e.charCodeAt(s);if(c===34||c===39||c===96){s=kt(e,s,c);continue}if(c===47&&e.charCodeAt(s+1)===47){s+=2;while(s<e.length&&e.charCodeAt(s)!==10&&e.charCodeAt(s)!==13)s++;continue}if(c===47&&e.charCodeAt(s+1)===42){let f=e.indexOf("*/",s+2);s=f===-1?e.length:f+2;continue}if(e.startsWith("function",s)&&xo(e,s,8)||e.startsWith("class",s)&&xo(e,s,5)){let f=Od(e,s);if(f!==-1){s=Ao(e,f);continue}}if(c===61&&e.charCodeAt(s+1)===62){let f=s+2;while(f<e.length&&e.charCodeAt(f)<=32)f++;if(e.charCodeAt(f)===123){s=Ao(e,f);continue}}if(e.startsWith("return",s)&&(s===0||!St(e.charCodeAt(s-1)))&&!St(e.charCodeAt(s+6))){s+=6;let f=!1;while(s<e.length&&e.charCodeAt(s)<=32){let A=e.charCodeAt(s);if(A===10||A===13)f=!0;s++}if(f||s>=e.length||e.charCodeAt(s)===59||e.charCodeAt(s)===125){o=!0;continue}let u=s,a=0,m=0,y=0;while(s<e.length){let A=e.charCodeAt(s);if(A===34||A===39||A===96){s=kt(e,s,A);continue}if(A===47&&e.charCodeAt(s+1)===47){if(a===0&&m===0&&y===0)break;while(s<e.length&&e.charCodeAt(s)!==10&&e.charCodeAt(s)!==13)s++;continue}if(A===47&&e.charCodeAt(s+1)===42){let k=e.indexOf("*/",s+2);s=k===-1?e.length:k+2;continue}if(A===40)a++;else if(A===41)a--;else if(A===91)m++;else if(A===93)m--;else if(A===123)y++;else if(A===125){if(y===0&&a===0&&m===0)break;y--}else if(A===59&&a===0&&m===0&&y===0)break;else if((A===10||A===13)&&a===0&&m===0&&y===0){let k=s+1;while(k<e.length&&e.charCodeAt(k)<=32)k++;if(e.startsWith("return",k)&&!St(e.charCodeAt(k+6)))break}s++}let w=e.slice(u,s).trim(),C=$o(Lt(w,n));if(!r.includes(C))r.push(C);continue}s++}if(o&&!r.includes("undefined"))r.push("undefined");let l=r.includes("unknown")?"unknown":r.length===0?"void":r.join(" | ");return t&&!l.startsWith("Promise<")?`Promise<${l}>`:l}function Dl(e){let t=new Map,i=e.startsWith("(")&&e.endsWith(")")?e.slice(1,-1):e,n=0,r=0,o=0;for(let s=0;s<=i.length;s++){let l=i.charCodeAt(s);if(l===40||l===91||l===123)r++;else if(l===41||l===93||l===125)r--;else if(l===60)o++;else if(l===62&&i.charCodeAt(s-1)!==61&&o>0)o--;if(s!==i.length&&(l!==44||r!==0||o!==0))continue;let c=i.slice(n,s).trim(),f=c.indexOf(":");if(f!==-1){let u=c.slice(0,f).trim().replace(/^\.\.\./,"").replace(/\?$/,""),a=c.slice(f+1).trim(),m=a.indexOf("=");if(m!==-1)a=a.slice(0,m).trim();if(Br(u)&&a)t.set(u,a)}n=s+1}return t}function Lt(e,t){let i=e.trim();while(Il(i))i=i.slice(1,-1).trim();if(Ir(i))return"JSX.Element";if(i.startsWith("await ")){let o=Lt(i.slice(6),t);return o.startsWith("Promise<")&&o.endsWith(">")?o.slice(8,-1):o}if(t.has(i))return t.get(i);if(i.startsWith("!"))return"boolean";if(i.startsWith("fetch("))return"Promise<Response>";let n=Td(i);if(n){let o=Lt(n.whenTrue,t),s=Lt(n.whenFalse,t);return o===s?o:`${o} | ${s}`}if(Ml(i))return"boolean";let r=0;for(let o=i.length-1;o>=0;o--){let s=i.charCodeAt(o);if(s===41||s===93||s===125)r++;else if(s===40||s===91||s===123)r--;else if(r===0&&(s===43||s===45||s===42||s===47||s===37)){let l=Lt(i.slice(0,o),t),c=Lt(i.slice(o+1),t);if(s===43&&(l==="string"||c==="string"))return"string";if(l==="number"&&c==="number")return"number";break}}return Ie(i,!1).replace(/\btypeof\s+[$A-Z_a-z][$\w]*/g,(o)=>{let s=o.slice(7);return t.get(s)??"unknown"})}function Il(e){if(!e.startsWith("(")||!e.endsWith(")"))return!1;let t=0;for(let i=0;i<e.length;i++){let n=e.charCodeAt(i);if(n===40)t++;else if(n===41&&--t===0)return i===e.length-1}return!1}function Td(e){let t=0,i=-1;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===40||r===91||r===123)t++;else if(r===41||r===93||r===125)t--;else if(r===63&&t===0&&e.charCodeAt(n+1)!==63)i=n;else if(r===58&&t===0&&i!==-1)return{whenTrue:e.slice(i+1,n),whenFalse:e.slice(n+1)}}return null}function xo(e,t,i){return(t===0||!St(e.charCodeAt(t-1)))&&!St(e.charCodeAt(t+i))}function Od(e,t){for(let i=t;i<e.length;i++){let n=e.charCodeAt(i);if(n===34||n===39||n===96){i=kt(e,i,n)-1;continue}if(n===123)return i;if(n===59)return-1}return-1}function Ao(e,t){let i=1,n=t+1;while(n<e.length&&i>0){let r=e.charCodeAt(n);if(r===34||r===39||r===96){n=kt(e,n,r);continue}if(r===47&&e.charCodeAt(n+1)===47){n+=2;while(n<e.length&&e.charCodeAt(n)!==10&&e.charCodeAt(n)!==13)n++;continue}if(r===47&&e.charCodeAt(n+1)===42){let o=e.indexOf("*/",n+2);n=o===-1?e.length:o+2;continue}if(r===123)i++;else if(r===125)i--;n++}return n}function kt(e,t,i){let n=t+1;while(n<e.length){let r=e.charCodeAt(n);if(r===92){n+=2;continue}if(i===96&&r===36&&e.charCodeAt(n+1)===123){n=Ao(e,n+1);continue}if(n++,r===i)break}return n}function Rd(e,t){if(e.includes(".raw`")||e.includes("String.raw`"))return"string";if(!t||e.includes("${")||e.includes(`
125
+ `)||e.includes("\r"))return"string";return e}function Pd(e){let t=4;while(t<e.length&&e.charCodeAt(t)<=32)t++;let i=t,n=e.charCodeAt(t);if(n<65||n>90)return"unknown";while(t<e.length&&(St(e.charCodeAt(t))||e.charCodeAt(t)===46))t++;if(t===i)return"unknown";let r=e.slice(i,t);{let o=e.slice(t),s=o;if(o.startsWith("<")){let c=0,f=-1;for(let u=0;u<o.length;u++)if(o[u]==="<")c++;else if(o[u]===">"){if(c--,c===0){f=u;break}}if(f!==-1){let u=o.slice(0,f+1);s=o.slice(f+1);let a=s.indexOf("(");if(a!==-1){let m=0,y=-1;for(let w=a;w<s.length;w++)if(s[w]==="(")m++;else if(s[w]===")"){if(m--,m===0){y=w;break}}if(y!==-1){if(s.slice(y+1).trimStart().startsWith("."))return"unknown"}}return`${r}${u}`}}let l=s.indexOf("(");if(l!==-1){let c=0,f=-1;for(let u=l;u<s.length;u++)if(s[u]==="(")c++;else if(s[u]===")"){if(c--,c===0){f=u;break}}if(f!==-1){if(s.slice(f+1).trimStart().startsWith("."))return"unknown"}}switch(r){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 r}}return"unknown"}function kd(e){return"{ new (...args: any[]): any }"}function Nl(e,t,i=0){if(e.startsWith("Promise.resolve(")){let n=e.indexOf(")",16);if(n!==-1){let r=e.slice(16,n).trim();if(r)return`Promise<${Ie(r,t,!1,i+1)}>`}return"Promise<unknown>"}if(e.startsWith("Promise.reject("))return"Promise<never>";if(e.startsWith("Promise.all(")){let n=e.indexOf("[",12),r=e.lastIndexOf("]");if(n!==-1&&r>n){let o=e.slice(n+1,r).trim(),s=Fr(o),l=[];for(let c=0;c<s.length;c++){let f=s[c].trim();if(f.startsWith("Promise.resolve(")){let u=Nl(f,t,i+1),a=u.indexOf("<"),m=u.lastIndexOf(">");l.push(a!==-1&&m>a?u.slice(a+1,m):"unknown")}else l.push(Ie(f,t,!1,i+1))}return`Promise<[${l.join(", ")}]>`}return"Promise<unknown[]>"}return"Promise<unknown>"}function To(e,t,i=0){let n=e.slice(1,-1).trim();if(!n)return"never[]";if(i>=ko)return"unknown[]";let r=Fr(n),o=!1;for(let m=0;m<r.length;m++){let y=r[m],w=y.length;while(w>0&&y.charCodeAt(w-1)<=32)w--;if(w>=8&&y.slice(w-8,w)==="as const"){o=!0;break}}if(o){let m=[];for(let y=0;y<r.length;y++){let w=r[y].trim();if(w.endsWith("as const")){let C=w.slice(0,-8).trim();if(C.startsWith("[")&&C.endsWith("]")){let A=C.slice(1,-1).trim(),k=Fr(A),W=[];for(let B=0;B<k.length;B++)W.push(Ie(k[B].trim(),!0,!1,i+1));m.push(`readonly [${W.join(", ")}]`)}else m.push(Ie(C,!0,!1,i+1))}else if(w.startsWith("[")&&w.endsWith("]"))m.push(To(w,!0,i+1));else m.push(Ie(w,!0,!1,i+1))}return`readonly [
126
126
  ${m.join(` |
127
127
  `)}
128
- ]`}let s=Wr&&!t,a=[],c=[];for(let m of r){let y=m.trim(),w=Ye;if(Ye=null,y.startsWith("...")){let C=y.slice(3).trim(),x=Ie(C,!1,!1,i+1);if(x.endsWith("[]"))a.push(x.slice(0,-2));else if(x.startsWith("readonly [")&&x.endsWith("]"))a.push(x.slice(10,-1));else if(ci(C))a.push(`(typeof ${C})[number]`);else a.push("unknown")}else if(y.startsWith("[")&&y.endsWith("]"))a.push(To(y,t,i+1));else a.push(Ad(y,t,i+1));if(s)c.push(Ye);Ye=w}if(s)if(Ro(e))Ye=Nr(e);else{let m=[];for(let y=0;y<r.length;y++){let w=r[y].trim();if(w.endsWith("as const"))continue;if(Oo(w)||w==="null"||w==="undefined")m.push(w);else if(w.startsWith("[")&&Ro(w))m.push(Nr(w));else if(w.startsWith("{")){if(c[y])m.push(c[y])}else{let C=Ie(w,!1,!1,0);if(C!=="unknown")m.push(C)}}if(m.length>0)Ye=`[${m.join(", ")}]`}if(t)return`readonly [${a.join(", ")}]`;let f=new Set,u=[],l=!0;for(let m of a){if(!f.has(m))f.add(m),u.push(m);if(l){if(!(Io(m)||m==="true"||m==="false"||m.charCodeAt(0)===34&&m.charCodeAt(m.length-1)===34||m.charCodeAt(0)===39&&m.charCodeAt(m.length-1)===39))l=!1}}if(l&&a.length<=10)return`readonly [${a.join(", ")}]`;if(u.length===1)return`${u[0]}[]`;return`(${u.join(" | ")})[]`}function Fr(e){let t=[],i=0,n=0,r=!1,o=0;for(let a=0;a<e.length;a++){let c=e.charCodeAt(a);if(!r&&(c===34||c===39||c===96))r=!0,o=c;else if(r&&c===o&&(a===0||e.charCodeAt(a-1)!==92))r=!1;if(!r){if(c===91||c===123||c===40)n++;else if(c===93||c===125||c===41)n--;else if(c===44&&n===0){let f=e.substring(i,a).trim();if(f)t.push(f);i=a+1;continue}}}let s=e.substring(i).trim();if(s)t.push(s);return t}function Oo(e){if(Io(e))return!0;if(e==="true"||e==="false")return!0;if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return!0;return!1}function kd(e){return e==="number"||e==="string"||e==="boolean"}function Ro(e){let t=!1,i=0,n=e.length;for(let r=0;r<n;r++){let o=e.charCodeAt(r);if(t){if(o===92){r++;continue}if(o===i)t=!1;continue}if(o===34||o===39||o===96){t=!0,i=o;continue}if(o===61&&r+1<n&&e.charCodeAt(r+1)===62)return!1;if(o>=97&&o<=122){let s=r;while(r<n&&(e.charCodeAt(r)>=97&&e.charCodeAt(r)<=122||e.charCodeAt(r)>=65&&e.charCodeAt(r)<=90||e.charCodeAt(r)>=48&&e.charCodeAt(r)<=57||e.charCodeAt(r)===95||e.charCodeAt(r)===36))r++;let a=e.slice(s,r);if(a==="new"||a==="async"||a==="await"||a==="function"||a==="yield"||a==="console"||a==="process")return!1;let c=r;while(c<n&&e.charCodeAt(c)<=32)c++;if(c<n&&e.charCodeAt(c)===40)return!1;r--}}return!0}function Md(e,t,i=0){let n=e.slice(1,-1).trim();if(!n)return"{}";if(i>=ko)return"Record<string, unknown>";let r=Fd(n),o=[],s=[],a=Wr&&!t,c=[];for(let[l,m]of r){let{comments:y,key:w}=Ll(l),C=y?`${y}
129
- `:"",x=w,k=!1;if(w==="..."){let v=m.trim(),K=ci(v)?`typeof ${v}`:Ie(v,t,!1,i+1);if(K!=="unknown")s.push(K);if(a&&(ci(v)||v.startsWith("{")))c.push(`...${Nr(v)}`);continue}let L=Ye;Ye=null;let W,T=m.trim();if(T===w&&Br(T))W=`typeof ${T}`;else if(Bd(T)){k=!0;let v=Gd(w);if(v){x=v.name;let K="";if(T.startsWith("async "))K="async ";if(T.charCodeAt(K.length)===42)K+="*";W=Ol(v.name,K+v.typeParams+T.slice(K.length))}else W=Ol(w,T)}else{if(W=Ie(m,t,!1,i+1),W==="unknown"&&ci(T))W=`typeof ${T}`;if(W.includes("=>")||W.includes("function")||W.includes("async"))W=xl(W)}let D=Ye;Ye=L;let I=m.trim(),N=Ld(w);if(N){let v=Wd(N.kind,N.name,W);if(v){o.push(`${C}${v}`);continue}}if(!t&&kd(W)&&Oo(I))o.push(`${C}/** @defaultValue ${Po(I)} */
130
- ${x}: ${W}`);else o.push(`${C}${x}: ${W}`);if(a){let v=Pl(x);if(I.endsWith("as const"));else if(Oo(I))c.push(`${v}: ${I}`);else if(I.startsWith("[")&&Ro(I))c.push(`${v}: ${Nr(I)}`);else if(I.startsWith("{")){if(D)c.push(`${v}: ${D}`)}else if(k)c.push(`${v}: ${$o(xl(W))}`);else if(!I.startsWith("[")&&(I.includes("=>")||I.startsWith("function")||I.startsWith("async"))){let K=Wl(I,!1,0,!0);c.push(`${v}: ${$o(K)}`)}}}if(a&&c.length>0){let l=i>0?(i-1)/2:0,m=`{ ${c.join(", ")} }`;if(m.length<=80)Ye=m;else{let y=" ".repeat((l+1)*2),w=" ".repeat(l*2);Ye=`{
128
+ ]`}let s=Wr&&!t,l=[],c=[];for(let m of r){let y=m.trim(),w=Ye;if(Ye=null,y.startsWith("...")){let C=y.slice(3).trim(),A=Ie(C,!1,!1,i+1);if(A.endsWith("[]"))l.push(A.slice(0,-2));else if(A.startsWith("readonly [")&&A.endsWith("]"))l.push(A.slice(10,-1));else if(ci(C))l.push(`(typeof ${C})[number]`);else l.push("unknown")}else if(y.startsWith("[")&&y.endsWith("]"))l.push(To(y,t,i+1));else l.push(Ad(y,t,i+1));if(s)c.push(Ye);Ye=w}if(s)if(Ro(e))Ye=Nr(e);else{let m=[];for(let y=0;y<r.length;y++){let w=r[y].trim();if(w.endsWith("as const"))continue;if(Oo(w)||w==="null"||w==="undefined")m.push(w);else if(w.startsWith("[")&&Ro(w))m.push(Nr(w));else if(w.startsWith("{")){if(c[y])m.push(c[y])}else{let C=Ie(w,!1,!1,0);if(C!=="unknown")m.push(C)}}if(m.length>0)Ye=`[${m.join(", ")}]`}if(t)return`readonly [${l.join(", ")}]`;let f=new Set,u=[],a=!0;for(let m of l){if(!f.has(m))f.add(m),u.push(m);if(a){if(!(Io(m)||m==="true"||m==="false"||m.charCodeAt(0)===34&&m.charCodeAt(m.length-1)===34||m.charCodeAt(0)===39&&m.charCodeAt(m.length-1)===39))a=!1}}if(a&&l.length<=10)return`readonly [${l.join(", ")}]`;if(u.length===1)return`${u[0]}[]`;return`(${u.join(" | ")})[]`}function Fr(e){let t=[],i=0,n=0,r=!1,o=0;for(let l=0;l<e.length;l++){let c=e.charCodeAt(l);if(!r&&(c===34||c===39||c===96))r=!0,o=c;else if(r&&c===o&&(l===0||e.charCodeAt(l-1)!==92))r=!1;if(!r){if(c===91||c===123||c===40)n++;else if(c===93||c===125||c===41)n--;else if(c===44&&n===0){let f=e.substring(i,l).trim();if(f)t.push(f);i=l+1;continue}}}let s=e.substring(i).trim();if(s)t.push(s);return t}function Oo(e){if(Io(e))return!0;if(e==="true"||e==="false")return!0;if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return!0;return!1}function Md(e){return e==="number"||e==="string"||e==="boolean"}function Ro(e){let t=!1,i=0,n=e.length;for(let r=0;r<n;r++){let o=e.charCodeAt(r);if(t){if(o===92){r++;continue}if(o===i)t=!1;continue}if(o===34||o===39||o===96){t=!0,i=o;continue}if(o===61&&r+1<n&&e.charCodeAt(r+1)===62)return!1;if(o>=97&&o<=122){let s=r;while(r<n&&(e.charCodeAt(r)>=97&&e.charCodeAt(r)<=122||e.charCodeAt(r)>=65&&e.charCodeAt(r)<=90||e.charCodeAt(r)>=48&&e.charCodeAt(r)<=57||e.charCodeAt(r)===95||e.charCodeAt(r)===36))r++;let l=e.slice(s,r);if(l==="new"||l==="async"||l==="await"||l==="function"||l==="yield"||l==="console"||l==="process")return!1;let c=r;while(c<n&&e.charCodeAt(c)<=32)c++;if(c<n&&e.charCodeAt(c)===40)return!1;r--}}return!0}function Dd(e,t,i=0){let n=e.slice(1,-1).trim();if(!n)return"{}";if(i>=ko)return"Record<string, unknown>";let r=Ld(n),o=[],s=[],l=Wr&&!t,c=[];for(let[a,m]of r){let{comments:y,key:w}=Wl(a),C=y?`${y}
129
+ `:"",A=w,k=!1;if(w==="..."){let E=m.trim(),K=ci(E)?`typeof ${E}`:Ie(E,t,!1,i+1);if(K!=="unknown")s.push(K);if(l&&(ci(E)||E.startsWith("{")))c.push(`...${Nr(E)}`);continue}let W=Ye;Ye=null;let B,T=m.trim();if(T===w&&Br(T))B=`typeof ${T}`;else if(Gd(T)){k=!0;let E=jd(w);if(E){A=E.name;let K="";if(T.startsWith("async "))K="async ";if(T.charCodeAt(K.length)===42)K+="*";B=Rl(E.name,K+E.typeParams+T.slice(K.length))}else B=Rl(w,T)}else{if(B=Ie(m,t,!1,i+1),B==="unknown"&&ci(T))B=`typeof ${T}`;if(B.includes("=>")||B.includes("function")||B.includes("async"))B=Tl(B)}let D=Ye;Ye=W;let N=m.trim(),F=Wd(w);if(F){let E=Bd(F.kind,F.name,B);if(E){o.push(`${C}${E}`);continue}}if(!t&&Md(B)&&Oo(N))o.push(`${C}/** @defaultValue ${Po(N)} */
130
+ ${A}: ${B}`);else o.push(`${C}${A}: ${B}`);if(l){let E=kl(A);if(N.endsWith("as const"));else if(Oo(N))c.push(`${E}: ${N}`);else if(N.startsWith("[")&&Ro(N))c.push(`${E}: ${Nr(N)}`);else if(N.startsWith("{")){if(D)c.push(`${E}: ${D}`)}else if(k)c.push(`${E}: ${$o(Tl(B))}`);else if(!N.startsWith("[")&&(N.includes("=>")||N.startsWith("function")||N.startsWith("async"))){let K=Bl(N,!1,0,!0);c.push(`${E}: ${$o(K)}`)}}}if(l&&c.length>0){let a=i>0?(i-1)/2:0,m=`{ ${c.join(", ")} }`;if(m.length<=80)Ye=m;else{let y=" ".repeat((a+1)*2),w=" ".repeat(a*2);Ye=`{
131
131
  ${y}${c.join(`,
132
132
  ${y}`)}
133
133
  ${w}}`}}let f=o.length>0?`{
134
134
  ${o.join(`;
135
135
  `)}
136
- }`:"{}";if(s.length===0)return f;let u=s[0];for(let l=1;l<s.length;l++)u=`Omit<${u}, keyof ${s[l]}> & ${s[l]}`;return o.length>0?`Omit<${u}, keyof ${f}> & ${f}`:u}function Br(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(!St(e.charCodeAt(i)))return!1;return!0}function ci(e){let t=e.split(".");return t.length>0&&t.every(Br)}function Dd(e){let t=!1,i="";for(let n=0;n<e.length;n++){let r=e[n];if(t){if(r==="\\")n++;else if(r===i)t=!1;continue}if(r==='"'||r==="'"||r==="`"){t=!0,i=r;continue}if(r==="(")return n;if(r==="<"){let o=tt(e,n,"<",">");if(o!==-1)n=o}}return-1}function Nl(e){if(e.length<3||!e.endsWith(")"))return null;let t=Dd(e);if(t===-1||tt(e,t,"(",")")!==e.length-1)return null;let i=e.slice(0,t).trim(),n=!1;if(i.endsWith("?."))n=!0,i=i.slice(0,-2).trim();let r=i,o=!1,s=i.indexOf("<");if(s!==-1){if(tt(i,s,"<",">")!==i.length-1)return null;r=i.slice(0,s).trim(),o=!0}if(!ci(r))return null;let a=e.slice(t+1,-1).trim(),c=Lr(a)!==-1||a.startsWith("function")||a.startsWith("async function"),f=ci(a),u=!c&&a.endsWith(")")&&Nl(a)!==null;if(!o&&!n&&!c&&!f&&!u)return null;let l=`ReturnType<typeof ${i}>`;return n?`${l} | undefined`:l}function xl(e){let t=e.split(`
137
- `).map((f)=>Fl(f)).join(`
138
- `),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(!St(f)&&!St(u))t=(t.slice(0,i)+t.slice(i+5)).trim()}let n=t.indexOf("(");if(n!==-1){let f=tt(t,n,"(",")");if(f!==-1){let u=t.slice(n,f+1),l=Wt(u);t=t.slice(0,n)+l+t.slice(f+1)}}let r=t.length,o="",s=[],a=!1,c=!1;for(let f=0;f<r;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(a=!0,u===10||u===13)c=!0;continue}if(a&&o.length>0){let l=(s.length>0?s[s.length-1]:0)===123;if(c&&l){let m=o.charCodeAt(o.length-1),y=m===59||m===44||m===123||u===125,w=o.length>=2&&o.charCodeAt(o.length-1)===47&&o.charCodeAt(o.length-2)===42;if(!y&&!w)o+="; ";else o+=" "}else o+=" "}a=!1,c=!1,o+=t[f]}return o.trim()}function St(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===95||e===36}function Wt(e){let t=e.trim(),i,n=!1;if(t.startsWith("(")&&t.endsWith(")"))i=t.slice(1,-1),n=!0;else i=t;let r=i.trim();if(!r)return n?"()":"";let o=!1;{let w=0;for(let C=0;C<r.length;C++){let x=r.charCodeAt(C);if(x===40||x===60||x===91||x===123)w++;else if(x===41||x===93||x===125||x===62&&r.charCodeAt(C-1)!==61)w--;else if(w===0&&x===61){let k=C>0?r.charCodeAt(C-1):0,L=C+1<r.length?r.charCodeAt(C+1):0;if(k!==61&&k!==33&&k!==60&&k!==62&&L!==61&&L!==62){o=!0;break}}}}if(!o)return t;let s=[],a=[],c=0,f=0,u=!1,l=0;for(let w=0;w<=r.length;w++){if(w===r.length){s.push(r.slice(c));break}let C=r.charCodeAt(w);if(u){if(C===92){w++;continue}if(C===l)u=!1;continue}if(C===47&&w+1<r.length){let x=r.charCodeAt(w+1);if(x===42){w+=2;while(w+1<r.length&&!(r.charCodeAt(w)===42&&r.charCodeAt(w+1)===47))w++;w++;continue}if(x===47){while(w<r.length&&r.charCodeAt(w)!==10)w++;continue}}if(C===39||C===34||C===96){u=!0,l=C;continue}if(C===40||C===60||C===91||C===123)f++;else if(C===41||C===93||C===125||C===62&&r.charCodeAt(w-1)!==61)f--;else if(C===44&&f===0){s.push(r.slice(c,w));let x=",",k=w+1;while(k<r.length&&r.charCodeAt(k)<=32)x+=r[k],k++;a.push(x),c=k}}let m=[];for(let w of s){let C=w.trim();if(!C){m.push(w);continue}if(C.startsWith("//"))continue;let x=Fl(C),k=w.slice(0,w.length-w.trimStart().length);m.push(k+Id(x))}let y=m[0]||"";for(let w=1;w<m.length;w++)y+=(a[w-1]||", ")+m[w];return n?`(${y})`:y}function Fl(e){let t=!1,i=0;for(let n=0;n<e.length-1;n++){let r=e.charCodeAt(n);if(t){if(r===92){n++;continue}if(r===i)t=!1;continue}if(r===39||r===34||r===96){t=!0,i=r;continue}if(r===47&&e.charCodeAt(n+1)===47)return e.slice(0,n).trimEnd()}return e}function Id(e){if(e.startsWith("..."))return e;let t=-1,i=-1,n=0,r=!1,o=0;for(let a=0;a<e.length;a++){let c=e.charCodeAt(a);if(r){if(c===92){a++;continue}if(c===o)r=!1;continue}if(c===47&&a+1<e.length){let f=e.charCodeAt(a+1);if(f===42){a+=2;while(a+1<e.length&&!(e.charCodeAt(a)===42&&e.charCodeAt(a+1)===47))a++;a++;continue}if(f===47){while(a<e.length&&e.charCodeAt(a)!==10)a++;continue}}if(c===39||c===34||c===96){r=!0,o=c;continue}if(c===40||c===60||c===91||c===123)n++;else if(c===41||c===93||c===125||c===62&&e.charCodeAt(a-1)!==61)n--;else if(n===0){if(c===58&&t===-1)t=a;else if(c===61&&i===-1&&(a===0||e.charCodeAt(a-1)!==61)&&(a+1>=e.length||e.charCodeAt(a+1)!==61&&e.charCodeAt(a+1)!==62))i=a}}let s=i!==-1;if(t!==-1&&(i===-1||t<i)){let a=e.slice(0,t).trim(),c=i!==-1?e.slice(t+1,i).trim():e.slice(t+1).trim(),f=s&&!a.endsWith("?")?"?":"";return`${a}${f}: ${c}`}else if(i!==-1){let a=e.slice(0,i).trim(),c=!a.endsWith("?")?"?":"",f=e.slice(i+1).trim(),u="unknown";if(f==="true"||f==="false")u="boolean";else if(/^-?\d+(\.\d+)?$/.test(f))u="number";else if(f.startsWith("'")&&f.endsWith("'")||f.startsWith('"')&&f.endsWith('"'))u="string";else if(f.startsWith("["))u="unknown[]";else if(f.startsWith("{"))u="Record<string, unknown>";return`${a}${c}: ${u}`}return e}function Nd(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 Ll(e){let t=[],i=0,n=e.length;while(i<n){while(i<n&&e.charCodeAt(i)<=32)i++;if(i+1>=n||e.charCodeAt(i)!==47||e.charCodeAt(i+1)!==42)break;let r=i;i+=2;while(i+1<n&&!(e.charCodeAt(i)===42&&e.charCodeAt(i+1)===47))i++;i=Math.min(i+2,n),t.push(e.slice(r,i).trim())}return{comments:t.join(`
139
- `),key:e.slice(i).trim()}}function Fd(e){let t=[],i="",n="",r=0,o=!1,s="",a=!0,c=!1,f=0,u=!1,l=!1,m=0,y=!1,w=!1;for(let C=0;C<e.length;C++){let x=e.charCodeAt(C),k=C>0?e.charCodeAt(C-1):0,L=C<e.length-1?e.charCodeAt(C+1):0;if(!o&&!c&&x===47&&L===47){i=i.replace(/[ \t]+$/,""),C+=2;while(C<e.length&&e.charCodeAt(C)!==10)C++;C--;continue}if(!o&&!c&&x===47&&L===42){c=!0,f=1,i+="/*",C++;continue}else if(c&&x===42&&L===47){if(f--,i+="*/",C++,f===0)c=!1;continue}else if(c&&x===47&&L===42){f++,i+="/*",C++;continue}let W=e[C];if(!o&&!c&&(x===34||x===39||x===96))o=!0,s=W,i+=W;else if(o&&W===s&&k!==92)o=!1,i+=W;else if(!o&&!c)if(x===40&&r===0&&a&&m===0){n=i.trim();let T=Nd(n),D=T>0?n.slice(0,T):"",I=n.slice(T),N="";if(I.startsWith("async ")||I.startsWith("async\t")||I.startsWith(`async
140
- `))I=I.slice(6).trimStart(),N="async ";if(I.startsWith("*"))I=I.slice(1).trimStart(),N+="*";n=D+I,i=N+W,a=!1,y=!0,w=!1,r=1}else if(x===123||x===91||x===40){if(r++,i+=W,w&&x===123)w=!1}else if(x===125||x===93||x===41){if(r--,i+=W,x===41&&r===0&&!a&&!y)u=!0;if(y){if(x===41&&r===0&&!w)w=!0;else if(x===125&&r===0)y=!1,w=!1}}else if(x===58&&r===0&&a&&m===0)n=i.trim(),i="",a=!1;else if(x===58&&r===0&&u)l=!0,i+=W;else if(x===60&&l)m++,i+=W;else if(x===60&&a&&r===0)m++,i+=W;else if(x===62&&m>0&&k!==61)m--,i+=W;else if(x===61&&L===62&&l&&m===0)l=!1,u=!1,i+=W;else if(x===44&&r===0&&m===0&&!w){if(n&&i.trim()){let T=i.trim();t.push([n,T])}else if(a&&i.trim())Tl(t,i.trim());i="",n="",a=!0,u=!1,l=!1,m=0}else i+=W;else i+=W}if(n&&i.trim()){let C=i.trim();t.push([n,C])}else if(a&&i.trim())Tl(t,i.trim());return t}function Tl(e,t){let{comments:i,key:n}=Ll(t);if(Br(n))e.push([i?`${i}
141
- ${n}`:n,n]);else if(n.startsWith("...")&&n.length>3)e.push(["...",n.slice(3).trim()])}function Ld(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 Wd(e,t,i){let n=i.trim();if(n.charCodeAt(0)!==40)return null;let r=tt(n,0,"(",")");if(r===-1)return null;let o=n.slice(1,r).trim(),s=n.slice(r+1).trimStart();if(!s.startsWith("=>"))return null;let a=s.slice(2).trim();if(e==="get")return`get ${t}(): ${a||"unknown"}`;return`set ${t}(${o})`}function Bd(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 n=0;n<t.length;n++){let r=t.charCodeAt(n);if(r===40)i++;else if(r===41){if(i--,i===0){let o=t.slice(n+1).trimStart();if(o.startsWith("{"))return!0;if(o.startsWith(":")){let s=No(o,1);if(s?.kind==="arrow")return!1;if(s?.kind==="body")return!0}return!1}}}return!1}function Gd(e){let t=e.trimEnd();if(!t.endsWith(">"))return null;let i=0,n=-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){n=o;break}}}if(n===-1)return null;let r=t.slice(0,n).trimEnd();if(!r)return null;return{name:r,typeParams:t.slice(n)}}function Ol(e,t){let i=t.trimStart(),n=!1,r=!1;if(i.startsWith("async ")||i.startsWith("async\t"))n=!0,i=i.slice(5).trimStart();if(i.startsWith("*"))r=!0,i=i.slice(1).trimStart();let o="";if(i.charCodeAt(0)===60){let m=0,y=-1;for(let w=0;w<i.length;w++)if(i.charCodeAt(w)===60)m++;else if(i.charCodeAt(w)===62&&!(w>0&&i.charCodeAt(w-1)===61)){if(m--,m===0){y=w;break}}if(y!==-1)o=i.slice(0,y+1),i=i.slice(y+1).trimStart()}let s=i.indexOf("("),a=tt(i,s,"(",")");if(s===-1||a===-1)return"() => unknown";let c=i.slice(s,a+1),f="unknown",u=i.slice(a+1).trimStart();if(u.charCodeAt(0)===58){let m=u.slice(1),y=No(m,0);if(y)f=m.slice(0,y.index).trim();else f=m.trim()}if(f==="unknown"&&!r&&u.charCodeAt(0)===123){let m=tt(u,0,"{","}");if(m!==-1){let y=fi(u.slice(1,m),n,c);if(y!=="unknown"&&y!=="Promise<unknown>")f=n&&y.startsWith("Promise<")?y.slice(8,-1):y;else if(n)f="Promise<unknown>"}}if(f==="unknown"){if(n&&r)f="AsyncGenerator<unknown, void, unknown>";else if(r)f="Generator<unknown, void, unknown>";else if(n)f="Promise<void>"}else if(n&&!f.startsWith("Promise<")&&!f.startsWith("AsyncGenerator<"))f=`Promise<${f}>`;let l=Wt(c);return`${o}${l} => ${f}`}function No(e,t){let i=0,n=0,r=0,o=0,s=!1,a=0;for(let c=t;c<e.length;c++){let f=e.charCodeAt(c);if(s){if(f===92)c++;else if(f===a)s=!1;continue}if(f===34||f===39||f===96){s=!0,a=f;continue}if(f===40)i++;else if(f===41&&i>0)i--;else if(f===91)n++;else if(f===93&&n>0)n--;else if(f===60)r++;else if(f===62&&r>0&&e.charCodeAt(c-1)!==61)r--;else if(f===125&&o>0)o--;else if(f===123){let u=i>0||n>0||r>0||o>0,l=e.slice(t,c).trimEnd(),m=l.charCodeAt(l.length-1),y=l.length===0||m===38||m===124||m===40||m===44||m===58||m===61||m===91;if(u||y)o++;else return{index:c,kind:"body"}}else if(f===61&&c+1<e.length&&e.charCodeAt(c+1)===62&&i===0&&n===0&&r===0&&o===0)return{index:c,kind:"arrow"}}return null}function tt(e,t,i,n){let r=0;for(let o=t;o<e.length;o++)if(e[o]===i)r++;else if(e[o]===n){if(n===">"&&o>0&&e[o-1]==="=")continue;if(r--,r===0)return o}return-1}function Lr(e){let t=0,i=0,n=!1,r="";for(let o=0;o<e.length-1;o++){let s=e[o],a=e[o+1],c=o>0?e[o-1]:"";if(!n&&(s==='"'||s==="'"||s==="`"))n=!0,r=s;else if(n&&s===r&&c!=="\\")n=!1;if(!n){if(s==="<"){let f=tt(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==="="&&a===">"&&t===0&&i===0)return o}}return-1}function Wl(e,t=!1,i=0,n=!0){let r=e.trim();if(r.length>200&&So(r,"=>")>2&&So(r,"<")>5&&!r.startsWith("function"))return t?"((...args: any[]) => any)":"(...args: any[]) => any";if(r.startsWith("async ")&&r.includes("=>")){let s=r.slice(5).trim(),a=Lr(s);if(a===-1)return t?"(() => Promise<unknown>)":"() => Promise<unknown>";let c=s.substring(0,a).trim(),f=s.substring(a+2).trim(),u=Rl(c),{params:l,returnType:m}=u;if(l=Wt(l),l==="()"||l==="")l="()";else if(!l.startsWith("("))l=`(${l})`;let y=m;if(y);else if(f.startsWith("{"))y=fi(f.slice(1,f.endsWith("}")?-1:void 0),!0,l);else y=Ie(f,n,!1,i+1);let w=`${l} => ${m||y.startsWith("Promise<")?y:`Promise<${y}>`}`;return t?`(${w})`:w}if(r.includes("=>")){let s="",a=r;if(r.startsWith("<")){let x=tt(r,0,"<",">");if(x!==-1)s=r.substring(0,x+1),a=r.substring(x+1).trim()}let c=Lr(a);if(c===-1)return t?"(() => unknown)":"() => unknown";let f=a.substring(0,c).trim(),u=a.substring(c+2).trim(),l=Rl(f),{params:m,returnType:y}=l;if(m=Wt(m),m==="()"||m==="")m="()";else if(!m.startsWith("("))m=`(${m})`;let w="unknown";if(y)w=y;else if(u.startsWith("{"))w=fi(u.slice(1,u.endsWith("}")?-1:void 0),!1,m);else if(Ir(u)||Dl(u)&&Ir(u.slice(1,-1).trim()))w="JSX.Element";else if(u.includes("=>")){let x=u.trimStart(),k=x.indexOf("("),L=k!==-1?tt(x,k,"(",")"):-1,W=L!==-1?x.indexOf("=>",L):-1;if(k===0&&L!==-1&&W!==-1){let T=x.substring(k+1,L).trim(),D=Wt(T);if(s.includes("T")&&D.includes("T"))w=`(${D}) => T`;else w=`(${D}) => any`}else w="any"}else if(t)w="unknown";else w=Lt(u,Ml(m));let C=`${s}${m} => ${w}`;return t?`(${C})`:C}if(r.startsWith("function")){let s=8,a=r.length;while(s<a&&r.charCodeAt(s)<=32)s++;let c=!1;if(s<a&&r.charCodeAt(s)===42){c=!0,s++;while(s<a&&r.charCodeAt(s)<=32)s++}let f="";if(s<a&&r.charCodeAt(s)===60){let m=s,y=1;s++;while(s<a&&y>0){let w=r.charCodeAt(s);if(w===60)y++;else if(w===62&&r.charCodeAt(s-1)!==61)y--;s++}f=r.substring(m,s);while(s<a&&r.charCodeAt(s)<=32)s++}let u=r.indexOf("(",s);if(u!==-1){let m=1,y=u+1;while(y<a&&m>0){let W=r.charCodeAt(y);if(W===40)m++;else if(W===41)m--;y++}let w=r.substring(u+1,y-1).trim(),C=w?Wt(`(${w})`):"()";if(c){let W=r.substring(y).trim(),T=W.indexOf("Generator<");if(T!==-1){let I=T+10,N=W.indexOf(">",I);if(N!==-1){let v=W.substring(I,N),K=`${f}${C} => Generator<${v}>`;return t?`(${K})`:K}}let D=`${f}${C} => Generator<any, any, any>`;return t?`(${D})`:D}let x="unknown",k=r.substring(y).trimStart();if(k.charCodeAt(0)===58){let W=k.slice(1),T=No(W,0),D=(T?W.slice(0,T.index):W).trim();if(D)x=D}let L=`${f}${C} => ${x}`;return t?`(${L})`:L}let l="(...args: any[]) => unknown";return t?`(${l})`:l}if(r.includes("=>")&&r.includes("(")&&r.includes(")")){if(r.length>100||So(r,"=>")>2){let s="";if(r.charCodeAt(0)===60){let l=tt(r,0,"<",">");if(l!==-1)s=r.substring(0,l+1)}let a=r.indexOf("("),c=a!==-1?tt(r,a,"(",")"):-1,f=a!==-1&&c!==-1?r.substring(a,c+1):"(...args: any[])";f=Wt(f);let u=`${s}${f} => any`;return t?`(${u})`:u}return t?`(${r})`:r}let o="() => unknown";return t?`(${o})`:o}function Rl(e){let t=e.trim();if(!t.startsWith("("))return{params:t,returnType:""};let i=tt(t,0,"(",")");if(i===-1)return{params:t,returnType:""};let n=t.slice(i+1).trim();return{params:t.slice(0,i+1),returnType:n.startsWith(":")?n.slice(1).trim():""}}function Bl(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 Gr(e){let t=-1,i=0;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);if(o===34||o===39||o===96){r=kt(e,r,o)-1;continue}if(o===47&&e.charCodeAt(r+1)===47){while(r<e.length&&e.charCodeAt(r)!==10)r++;continue}if(o===47&&e.charCodeAt(r+1)===42){let s=e.indexOf("*/",r+2);r=s===-1?e.length:s+1;continue}if(o===47){let s=r-1;while(s>=0&&e.charCodeAt(s)<=32)s--;if(s<0||"([{:;,=!?&|+*-~>".includes(e[s])){let a=!1;for(r++;r<e.length;r++){let c=e.charCodeAt(r);if(c===92)r++;else if(c===91)a=!0;else if(c===93)a=!1;else if(c===47&&!a)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",r)&&Ao(e,r,9)&&e[r-1]!==".")t=r}if(t===-1)return null;let n=e.slice(t+9).trim();if(n.endsWith(";"))n=n.slice(0,-1).trim();return n||null}var ko=20,Wr=!1,Ye=null;var Fo=()=>{};function Be(e){return e===ke||e===Me||e===Ee||e===Te}function Vd(e){let t=!0;for(let i=0;i<e.length;i++){let n=e.charCodeAt(i);if(n===mt){if(t)return!1;t=!0}else if(t){if(!dt(n))return!1;t=!1}else if(!_e(n))return!1}return e.length>0&&!t}function _r(e,t,i){let n=t+1;while(n<e.length){let r=e.charCodeAt(n);if(r===it){n+=2;continue}if(n++,r===i)break}return n}function Ud(e){if(e==="any"||e==="object"||e==="unknown")return!0;if(e.startsWith("Record<")||e.startsWith("Array<"))return!0;return e.charCodeAt(0)===H&&e.includes("[")&&e.includes("]:")}function _l(e,t,i=!0){return Ul(e,t,i,!0)}function Vl(e,t,i=!0){return Ul(e,t,i,!1)}function Ul(e,t,i,n){let r=e,o=i,s=n,a=r.length,c=[],f=new Map,u=new Set,l=0;if(l<a&&r.charCodeAt(l)===65279)l++;function m(d,p){if(d<p){let h=r.charCodeAt(d),g=r.charCodeAt(p-1);if(h!==ke&&h!==Me&&h!==Ee&&h!==Te&&g!==ke&&g!==Me&&g!==Ee&&g!==Te)return r.slice(d,p)}while(d<p&&Be(r.charCodeAt(d)))d++;while(p>d&&Be(r.charCodeAt(p-1)))p--;return r.slice(d,p)}let y=/[\r\n]/g;function w(d){return y.lastIndex=d,y.exec(r)?.index??a}function C(){if(l>=a)return;let d=r.charCodeAt(l);if(d!==ke&&d!==Me&&d!==Ee&&d!==Te&&d!==Q)return;while(l<a){let p=r.charCodeAt(l);if(p===ke||p===Me||p===Ee||p===Te){l++;continue}if(p===Q&&l+1<a){let h=r.charCodeAt(l+1);if(h===Q){l=w(l+2);continue}if(h===xe){let g=r.indexOf("*/",l+2);l=g===-1?a:g+2;continue}}break}}function x(d){let p=d.length,h=0,g=p;for(let E=0;E<p;E++){let b=d.charCodeAt(E);if(h){if(b===it){E++;continue}if(b===h)h=0;continue}if(b===de||b===me||b===Ne){h=b;continue}if(b===Q&&E+1<p){let O=d.charCodeAt(E+1);if(O===Q){g=E;while(g>0&&(d.charCodeAt(g-1)===ke||d.charCodeAt(g-1)===Me))g--;return d.slice(0,g)}if(O===xe){let R=d.indexOf("*/",E+2);if(R!==-1){d=`${d.slice(0,E)} ${d.slice(R+2)}`,E--;continue}}}}g=p;while(g>0&&(d.charCodeAt(g-1)===ke||d.charCodeAt(g-1)===Me||d.charCodeAt(g-1)===Te))g--;return g<p?d.slice(0,g):d}function k(d){l++;let p=d===de?"'":'"';while(l<a){let h=r.indexOf(p,l);if(h===-1){l=a;return}let g=0,E=h-1;while(E>=0&&r.charCodeAt(E)===it)g++,E--;if(g%2===0){l=h+1;return}l=h+1}}function L(){l++;let d=[];while(l<a){let p=r.charCodeAt(l);if(d.length===0){if(p===it){l+=2;continue}if(p===Ne){l++;return}if(p===_d&&l+1<a&&r.charCodeAt(l+1)===H){l+=2,d.push(0);continue}l++;continue}if(p===de||p===me){k(p);continue}if(p===Ne){L();continue}if(p===Q&&l+1<a){let h=r.charCodeAt(l+1);if(h===Q){l=w(l+2);continue}if(h===xe){let g=r.indexOf("*/",l+2);l=g===-1?a:g+2;continue}if(D()){I();continue}l++;continue}if(p===H){d[d.length-1]++,l++;continue}if(p===X){let h=d[d.length-1];if(h===0){d.pop(),l++;continue}d[d.length-1]=h-1,l++;continue}l++}}let W=!1;function T(){W=!1;let d=r.charCodeAt(l);if(d===de||d===me)return k(d),!0;if(d===Ne)return L(),!0;if(d===Q&&l+1<a){let p=r.charCodeAt(l+1);if(p===Q)return l=w(l+2),!0;if(p===xe){let h=r.indexOf("*/",l+2);return W=w(l+2)<(h===-1?a:h),l=h===-1?a:h+2,!0}if(D())return I(),!0}return!1}function D(){return ji(r,l)}function I(){l=di(r,l)}function N(){let d=l;while(l<a&&_e(r.charCodeAt(l)))l++;return r.slice(d,l)}function v(d){if(l+d.length>a)return!1;for(let p=0;p<d.length;p++)if(r.charCodeAt(l+p)!==d.charCodeAt(p))return!1;if(l+d.length<a&&_e(r.charCodeAt(l+d.length)))return!1;return!0}function K(d){let p=l+d;while(p<a){let h=r.charCodeAt(p);if(h===ke||h===Me||h===Ee||h===Te){p++;continue}return h!==mt&&h!==Ae}return!1}function oe(){if(!W)return!1;let d=l;C();let p=l>=a||fe()||r.charCodeAt(l)===X;return l=d,p}function fe(){if(l>=a)return!1;switch(r.charCodeAt(l)){case 101:return v("export")||v("enum");case 105:return v("import")||v("interface");case 102:return v("function");case 99:return v("class")||v("const");case 116:return v("type");case 108:return v("let");case 118:return v("var");case 100:return v("declare")||v("default");case 109:return v("module");case 110:return v("namespace");case 97:return v("abstract")||v("async");default:return!1}}function z(){let d=r.charCodeAt(l);if(d!==Ee&&d!==Te)return!1;let p=l;if(l++,d===Te&&l<a&&r.charCodeAt(l)===Ee)l++;while(l<a){let g=r.charCodeAt(l);if(g===ke||g===Me||g===Te||g===Ee){l++;continue}if(g===Q&&l+1<a){let E=r.charCodeAt(l+1);if(E===Q){l=w(l+2);continue}if(E===xe){let b=r.indexOf("*/",l+2);l=b===-1?a:b+2;continue}}break}let h=l>=a||fe()||r.charCodeAt(l)===X;return l=p,h}function ge(d){let p=d-1;while(p>=0){let S=r.charCodeAt(p);if(S===ke||S===Me||S===Te||S===Ee){p--;continue}break}if(p<0)return!0;let h=r[p];if("+-*/%=<>&|^!~?:,.([{".includes(h))return!0;let g=p;while(g>0&&r.charCodeAt(g-1)!==Ee)g--;let E=r.slice(g,p+1),b=E.lastIndexOf("<");if(b!==-1&&/^<[A-Za-z]/.test(E.slice(b))&&!E.slice(b).includes(">"))return!0;let O=p;while(O>=0&&/[a-z]/i.test(r[O]))O--;let R=r.slice(O+1,p+1);return["as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","return","yield","void"].includes(R)}function De(){let d=r.charCodeAt(l);if(d!==Ee&&d!==Te)return!1;if(ge(l))return!1;let p=l;l++;while(l<a){let b=r.charCodeAt(l);if(b===ke||b===Me||b===Te||b===Ee){l++;continue}if(b===Q&&l+1<a){let O=r.charCodeAt(l+1);if(O===Q){l=w(l+2);continue}if(O===xe){let R=r.indexOf("*/",l+2);l=R===-1?a:R+2;continue}}break}let h=l<a?r[l]:"",g=r.slice(l,l+2),E=h==="."||h==="?"||h===":"||h===")"||h==="]"||h==="}"||h===","||h==="+"||h==="-"||h==="*"||h==="/"||h==="%"||h==="<"||h===">"||h==="="||h==="&"||h==="|"||h==="^"||h==="`"||g==="=>"||v("as")||v("satisfies")||v("instanceof")||v("in");return l=p,!E}function ie(){let d=r.charCodeAt(l);if(d!==Ee&&d!==Te)return!1;if(ge(l))return!1;let p=l;l++;while(l<a){let E=r.charCodeAt(l);if(E===ke||E===Me||E===Te||E===Ee){l++;continue}if(E===Q&&l+1<a){let b=r.charCodeAt(l+1);if(b===Q){l=w(l+2);continue}if(b===xe){let O=r.indexOf("*/",l+2);l=O===-1?a:O+2;continue}}break}let h=l<a?r[l]:"",g=h==="|"||h==="&"||h==="["||h==="."||h==="?"||h===":"||h===">"||h===")"||h===","||v("extends");return l=p,!g}function le(){let d=r.charCodeAt(l);if(d!==Ee&&d!==Te)return!1;let p=l;if(l++,d===Te&&l<a&&r.charCodeAt(l)===Ee)l++;while(l<a){let g=r.charCodeAt(l);if(g===ke||g===Me||g===Te||g===Ee){l++;continue}if(g===Q&&l+1<a&&r.charCodeAt(l+1)===Q){l=w(l+2);continue}break}if(l>=a)return l=p,!0;let h=r.charCodeAt(l);if(h===124||h===38||h===mt||h===Lo||h===ft)return l=p,!1;if(v("extends")||v("keyof")||v("typeof")||v("infer")||v("is")||v("as")||v("in"))return l=p,!1;return l=p,!0}let ee=/[{}'"`\/]/g,F=/[()'"`\/]/g,U=/[[\]'"`\/]/g,q=/[<>'"`\/]/g;function Z(d,p){let h=1;l++;let g=d===H?ee:d===ae?F:d===be?U:q;g.lastIndex=l;let E;while((E=g.exec(r))!==null){let b=E.index,O=r.charCodeAt(b);if(O===de||O===me){l=b,k(O),g.lastIndex=l;continue}if(O===Ne){l=b,L(),g.lastIndex=l;continue}if(O===Q){if(l=b,T()){g.lastIndex=l;continue}g.lastIndex=b+1;continue}if(O===d)h++;else if(O===p){if(p===pe&&b>0&&r.charCodeAt(b-1)===Ae){g.lastIndex=b+1;continue}if(h--,h===0)return l=b+1,l}g.lastIndex=b+1}return l=a,l}function J(){return l>0&&r.charCodeAt(l-1)===Ae}function te(){return l+1<a&&r.charCodeAt(l+1)===pe}let se=/[<{};'"`\/\n\r()[\]]/g;function re(d=!1){let p=0,h=0,g=0,E=0,b=r.charCodeAt(l)===H;se.lastIndex=l;let O;while((O=se.exec(r))!==null){let R=O.index,S=r.charCodeAt(R);if(S===de||S===me){l=R,k(S),se.lastIndex=l;continue}if(S===Ne){l=R,L(),se.lastIndex=l;continue}if(S===Q){if(R>0&&r.charCodeAt(R-1)===ve){se.lastIndex=R+1;continue}if(l=R,T()){if(p===0&&h===0&&g===0&&E===0&&oe())return;se.lastIndex=l;continue}se.lastIndex=R+1;continue}if(S===ve){let A=es(R);if(A!==null)E=Math.max(0,E+A);se.lastIndex=R+1;continue}if(S===ae){h++,se.lastIndex=R+1;continue}if(S===$e){h--,se.lastIndex=R+1;continue}if(S===be){g++,se.lastIndex=R+1;continue}if(S===Pe){g--,se.lastIndex=R+1;continue}if(S===H){p++,se.lastIndex=R+1;continue}if(S===X){let A=p>0;if(!A&&d&&h===0&&g===0&&E===0){l=R;return}if(A)p--;if((!A||b)&&p===0&&h===0&&g===0&&E===0){l=R+1;return}se.lastIndex=R+1;continue}if(S===ne&&p===0&&h===0&&g===0&&E===0){l=R+1;return}if((S===Ee||S===Te)&&p===0&&h===0&&g===0&&E===0){if(l=R,z())return}se.lastIndex=R+1}l=a}function qr(){l++;while(l<a&&(r.charCodeAt(l)===ke||r.charCodeAt(l)===Me))l++;let d=r.indexOf(`
142
- `,l),p=d===-1?a:d,h=r.indexOf(";",l);if(h!==-1&&h<p){let g=h-1;while(g>=l&&(r.charCodeAt(g)===ke||r.charCodeAt(g)===Me))g--;let E=r.charCodeAt(l),b=r.charCodeAt(g);if(E===H&&b===X||E===be&&b===Pe||E===de&&b===de||E===me&&b===me||E===Ne&&b===Ne){l=h+1;return}}re()}function Jo(){Z(H,X);while(l<a&&Be(r.charCodeAt(l)))l++;if(v("from")){l+=4;while(l<a&&Be(r.charCodeAt(l)))l++;if(l<a){let d=r.charCodeAt(l);if(d===de||d===me)k(d)}}while(l<a&&(r.charCodeAt(l)===ke||r.charCodeAt(l)===Me))l++;if(l<a&&r.charCodeAt(l)===ne)l++}function qo(){l++;while(l<a&&Be(r.charCodeAt(l)))l++;if(v("as")){l+=2;while(l<a&&Be(r.charCodeAt(l)))l++;N();while(l<a&&Be(r.charCodeAt(l)))l++}if(v("from")){l+=4;while(l<a&&Be(r.charCodeAt(l)))l++;if(l<a){let d=r.charCodeAt(l);if(d===de||d===me)k(d)}}while(l<a&&(r.charCodeAt(l)===ke||r.charCodeAt(l)===Me))l++;if(l<a&&r.charCodeAt(l)===ne)l++}function Ni(d){let p=d.indexOf("from ");if(p===-1)return;let h=p+5;while(h<d.length&&(d.charCodeAt(h)===32||d.charCodeAt(h)===9))h++;if(h>=d.length)return;let g=d.charCodeAt(h);if(g!==39&&g!==34)return;let E=d.indexOf(d[h],h+1);if(E===-1)return;return d.slice(h+1,E)}function Xe(d){if(!o)return;let p=d-1;while(p>=0&&Be(r.charCodeAt(p)))p--;if(p<0)return;let h=[],g=!1;while(p>=0){if(p>=1&&r.charCodeAt(p)===Q&&r.charCodeAt(p-1)===xe){let O=r.lastIndexOf("/*",p-2);if(O>=0){h.push(r.slice(O,p+1)),g=!0,p=O-1;while(p>=0&&Be(r.charCodeAt(p)))p--;continue}break}let E=p;while(E>0&&r.charCodeAt(E-1)!==Ee)E--;let b=m(E,p+1);if(b.startsWith("//")){if(g)break;let O=[b];p=E-1;while(p>=0&&(r.charCodeAt(p)===Ee||r.charCodeAt(p)===Te))p--;while(p>=0){let R=p;while(R>0&&r.charCodeAt(R-1)!==Ee)R--;let S=m(R,p+1);if(S.startsWith("//")){O.push(S),p=R-1;while(p>=0&&(r.charCodeAt(p)===Ee||r.charCodeAt(p)===Te))p--}else if(S===""){p=R-1;while(p>=0&&(r.charCodeAt(p)===Ee||r.charCodeAt(p)===Te))p--}else break}O.reverse(),h.push(O.join(`
143
- `));continue}break}if(h.length===0)return;return h.reverse(),h}function Jc(d){let p=d,h=!1;while(l<a){let S=r.charCodeAt(l);if(S===ne){l++;break}if(S===de||S===me){k(S),h=!0;while(l<a&&(r.charCodeAt(l)===ke||r.charCodeAt(l)===Me))l++;if(l<a&&r.charCodeAt(l)===ne)l++;break}if(S===Ee&&h)break;l++}let g=m(p,l),E=g.charCodeAt(7)===116&&(g.startsWith("import type ")||g.startsWith("import type{")),b=!1;{let S=6;while(S<g.length&&(g.charCodeAt(S)===ke||g.charCodeAt(S)===Me))S++;if(S<g.length&&g.charCodeAt(S)===116&&g.startsWith("type",S)){S+=4;while(S<g.length&&(g.charCodeAt(S)===ke||g.charCodeAt(S)===Me))S++}if(S<g.length){let A=g.charCodeAt(S);b=A===de||A===me}}let O="";{let S=g.indexOf("from ");if(S!==-1){let A=S+5;while(A<g.length&&(g.charCodeAt(A)===ke||g.charCodeAt(A)===Me))A++;if(A<g.length){let P=g.charCodeAt(A);if(P===de||P===me){let B=g.indexOf(String.fromCharCode(P),A+1);if(B!==-1)O=g.slice(A+1,B)}}}else if(b){let A=6;while(A<g.length&&g.charCodeAt(A)!==de&&g.charCodeAt(A)!==me)A++;if(A<g.length){let P=g.charCodeAt(A),B=g.indexOf(String.fromCharCode(P),A+1);if(B!==-1)O=g.slice(A+1,B)}}}let R=Xe(p);return{kind:"import",name:"",text:g,isExported:!1,isTypeOnly:E,isSideEffect:b,source:O,leadingComments:R,start:p,end:l}}function Yr(){let d=l;return Z(H,X),r.slice(d,l)}function Yo(d){let p=d.indexOf("(");if(p===-1)return d;let h=d.slice(p);if(h.indexOf("=")===-1)return d;let g=!1;for(let S=0;S<h.length;S++)if(h.charCodeAt(S)===61){let A=S>0?h.charCodeAt(S-1):0,P=S+1<h.length?h.charCodeAt(S+1):0;if(A!==61&&A!==33&&A!==60&&A!==62&&P!==61&&P!==62){g=!0;break}}if(!g)return d;let E=0,b=-1;for(let S=p;S<d.length;S++){let A=d.charCodeAt(S);if(A===40)E++;else if(A===41){if(E--,E===0){b=S;break}}}if(b===-1)return d;let O=d.slice(p,b+1),R=Gt(O);return d.slice(0,p)+R+d.slice(b+1)}function Zo(d){let p=d.indexOf("//")!==-1||d.indexOf("/*")!==-1,h=d.split(`
144
- `),g=[],E=[],b=[],O=!1,R=1/0;for(let P=0;P<h.length;P++){let B=h[P];if(p){if(O){if(B.includes("*/"))O=!1;continue}let _=B.trim();if(_.length===0)continue;let G=_.charCodeAt(0);if(G===Q){let He=_.charCodeAt(1);if(He===Q)continue;if(He===xe){if(!_.includes("*/"))O=!0;continue}}if(G===xe)continue;let M=x(B);if(M.charCodeAt(M.length-1)===ne)M=M.slice(0,-1);M=Yo(M);let j=M.trim();if(!j)continue;g.push(M),E.push(j);let V=0;while(V<M.length&&Be(M.charCodeAt(V)))V++;if(j!=="{"&&j!=="}"){if(V<R)R=V}b.push(V)}else{let _=B.length;while(_>0&&(B.charCodeAt(_-1)===ke||B.charCodeAt(_-1)===Me||B.charCodeAt(_-1)===Te))_--;if(_===0)continue;let G=_<B.length?B.slice(0,_):B;if(G.charCodeAt(G.length-1)===ne)G=G.slice(0,-1);G=Yo(G);let M=G.trim();if(!M)continue;g.push(G),E.push(M);let j=0;while(j<G.length&&Be(G.charCodeAt(j)))j++;if(M!=="{"&&M!=="}"){if(j<R)R=j}b.push(j)}}if(g.length===0)return"{}";if(R===1/0||R<=2)return g.join(`
145
- `);let S=R-2,A=Array(g.length);for(let P=0;P<g.length;P++){let B=E[P];if(B==="{"){A[P]=B;continue}let _=b[P];if(_>R)A[P]=g[P];else if(_===R&&(B.charCodeAt(0)===X||B.charCodeAt(0)===Pe||B.charCodeAt(0)===$e))A[P]=g[P];else{let G=Math.max(0,_-S);A[P]=" ".repeat(G)+B}}return A.join(`
146
- `)}function ht(){if(l>=a||r.charCodeAt(l)!==ve)return"";let d=l;Z(ve,pe);let p=r.slice(d,l);if(p.includes(`
147
- `)){let h="",g=!1;for(let E=0;E<p.length;E++){let b=p.charCodeAt(E);if(b===32||b===9||b===10||b===13){if(!g&&h.length>0)h+=" ",g=!0}else h+=p[E],g=!1}if(h.charCodeAt(1)===32)h=`<${h.slice(2)}`;if(h.charCodeAt(h.length-2)===32)h=`${h.slice(0,-2)}>`;return h}return p}function At(){if(l>=a||r.charCodeAt(l)!==ae)return"()";let d=l;return Z(ae,$e),r.slice(d,l)}function Fi(d){if(d.indexOf("/")===-1)return d;let p="",h=!1,g=0;for(let E=0;E<d.length;E++){let b=d.charCodeAt(E);if(h){if(p+=d[E],b===it&&E+1<d.length){p+=d[++E];continue}if(b===g)h=!1;continue}if(b===de||b===me||b===Ne){h=!0,g=b,p+=d[E];continue}if(b===Q&&E+1<d.length){let O=d.charCodeAt(E+1);if(O===xe){let R=d.indexOf("*/",E+2);E=R===-1?d.length:R+1,p+=" ";continue}if(O===Q){let R=d.indexOf(`
148
- `,E+2);E=R===-1?d.length:R-1;continue}}p+=d[E]}return p.trim()}function Gt(d){let p=d.slice(1,-1).trim();if(!p)return"()";if(d.indexOf(`
149
- `)===-1&&p.indexOf(":")!==-1&&p.indexOf("{")===-1&&p.indexOf("[")===-1&&p.indexOf("=")===-1&&p.indexOf("@")===-1&&p.indexOf("...")===-1){let S=0,A=0,P=0;for(let B=0;B<p.length;B++){let _=p.charCodeAt(B);if(_===ae||_===ve||_===H)P++;else if(_===$e||_===pe||_===X)P--;else if(P===0){if(_===ft)S++;else if(_===ut)A++}}if(S>=A+1){let B=!1;for(let _=0;_<Wo.length;_++){let G=Wo[_],M=p.indexOf(G);if(M!==-1){let j=M+G.length;if((M===0||!_e(p.charCodeAt(M-1)))&&(j>=p.length||!_e(p.charCodeAt(j)))){B=!0;break}}}if(!B)return d}}let h=[],g=0,E=0,b=!1,O=0;for(let S=0;S<=p.length;S++){if(S===p.length){h.push(Fi(p.slice(g).trim()));break}let A=p.charCodeAt(S);if(b){if(A===it){S++;continue}if(A===O)b=!1;continue}if(A===Q&&S+1<p.length){let P=p.charCodeAt(S+1);if(P===xe){S+=2;while(S+1<p.length&&!(p.charCodeAt(S)===xe&&p.charCodeAt(S+1)===Q))S++;S++;continue}if(P===Q){while(S<p.length&&p.charCodeAt(S)!==10)S++;continue}}if(A===de||A===me||A===Ne){b=!0,O=A;continue}if(A===ae||A===H||A===be||A===ve)E++;else if(A===$e||A===X||A===Pe||A===pe&&!(S>0&&p.charCodeAt(S-1)===Ae))E--;else if(A===ut&&E===0)h.push(Fi(p.slice(g,S).trim())),g=S+1}let R=[];for(let S of h){if(!S)continue;let A=S.trim();if(A.startsWith("//")||A.startsWith("/*"))continue;let P=S;{let B=!1,_=0,G=0,M=0;for(let j=0;j<P.length-1;j++){let V=P.charCodeAt(j);if(V===Ee){M=j+1;continue}if(B){if(V===it){j++;continue}if(V===_)B=!1;continue}if(V===de||V===me||V===Ne){B=!0,_=V;continue}if(V===H||V===be||V===ae||V===ve){G++;continue}if(V===X||V===Pe||V===$e||V===pe){if(G>0)G--;continue}if(V===Q&&P.charCodeAt(j+1)===Q){if(G===0){P=P.slice(0,j).trimEnd();break}let He=P.indexOf(`
150
- `,j);if(He===-1){P=P.slice(0,M).trimEnd();break}let ze=P.slice(0,M),Vt=P.slice(He+1);P=`${ze}${Vt}`,j=M-1}}}if(!P.trim())continue;R.push(Xo(P))}return`(${R.join(", ")})`}function qc(d){if(!d.startsWith("{")&&!d.startsWith("["))return d;let p="",h=0,g=0,E=!1,b=0;while(h<d.length){let O=d.charCodeAt(h);if(E){if(O===it&&h+1<d.length){p+=d[h]+d[h+1],h+=2;continue}if(O===b)E=!1;p+=d[h],h++;continue}if(O===Q&&h+1<d.length){let R=d.charCodeAt(h+1);if(R===xe){let S=h;h+=2;while(h+1<d.length&&!(d.charCodeAt(h)===xe&&d.charCodeAt(h+1)===Q))h++;h=Math.min(h+2,d.length),p+=d.slice(S,h);continue}if(R===Q){let S=h;while(h<d.length&&d.charCodeAt(h)!==10)h++;p+=d.slice(S,h);continue}}if(O===de||O===me||O===Ne){E=!0,b=O,p+=d[h],h++;continue}if(O===H||O===be||O===ae)g++;else if(O===X||O===Pe||O===$e)g--;if(g>=1&&O===Ae&&(h+1>=d.length||d.charCodeAt(h+1)!==Ae&&d.charCodeAt(h+1)!==pe)){while(p.length>0&&(p[p.length-1]===" "||p[p.length-1]==="\t"||p[p.length-1]===`
151
- `))p=p.slice(0,-1);h++;let R=0;while(h<d.length){let S=d.charCodeAt(h);if(S===de||S===me||S===Ne){let A=S;h++;while(h<d.length){if(d.charCodeAt(h)===it){h+=2;continue}if(d.charCodeAt(h)===A){h++;break}h++}continue}if(S===H||S===be||S===ae)R++;else if(S===X||S===Pe||S===$e){if(R===0)break;R--}else if(S===ut&&R===0)break;h++}continue}if(g===1&&O===mt&&h+2<d.length&&d.charCodeAt(h+1)===mt&&d.charCodeAt(h+2)===mt){h+=3;continue}p+=d[h],h++}return p}function Xo(d){let p=d.trim(),h=p.startsWith("...");if(h)p=p.slice(3).trim();while(p.startsWith("@")){let M=1;while(M<p.length&&_e(p.charCodeAt(M)))M++;if(M<p.length&&p.charCodeAt(M)===ae){let j=1;M++;while(M<p.length&&j>0){if(p.charCodeAt(M)===ae)j++;else if(p.charCodeAt(M)===$e)j--;M++}}p=p.slice(M).trim()}let g=!0;while(g){g=!1;for(let M of Wo)if(p.startsWith(M)&&p.length>M.length&&!_e(p.charCodeAt(M.length))){let j=p.slice(M.length).trim();if(j.charCodeAt(0)===ft||j.charCodeAt(0)===Lo&&j.length>1&&j.charCodeAt(1)===ft)break;p=j,g=!0;break}}let E=-1,b=-1,O=0,R=!1,S=0;for(let M=0;M<p.length;M++){let j=p.charCodeAt(M);if(R){if(j===it){M++;continue}if(j===S)R=!1;continue}if(j===Q&&M+1<p.length){let V=p.charCodeAt(M+1);if(V===xe){M+=2;while(M+1<p.length&&!(p.charCodeAt(M)===xe&&p.charCodeAt(M+1)===Q))M++;M++;continue}if(V===Q){while(M<p.length&&p.charCodeAt(M)!==10)M++;continue}}if(j===de||j===me||j===Ne){R=!0,S=j;continue}if(j===ae||j===H||j===be||j===ve)O++;else if(j===$e||j===X||j===Pe||j===pe&&!(M>0&&p.charCodeAt(M-1)===Ae))O--;else if(O===0){if(j===ft&&E===-1)E=M;else if(j===Ae&&b===-1&&(M===0||p.charCodeAt(M-1)!==Ae)&&(M+1>=p.length||p.charCodeAt(M+1)!==Ae&&p.charCodeAt(M+1)!==pe))b=M}}let A,P,B=b!==-1;if(E!==-1&&(b===-1||E<b))if(A=p.slice(0,E).trim(),b!==-1)P=p.slice(E+1,b).trim();else P=p.slice(E+1).trim();else if(b!==-1)A=p.slice(0,b).trim(),P=Zr(p.slice(b+1).trim());else A=p,P="unknown";if(A=qc(A),(A.startsWith("{")||A.startsWith("["))&&A.includes(`
152
- `)){let M=A.replace(/\s*\n\s*/g," ").replace(/\s+/g," ");if(M.length<=40)A=M;else A=A.split(`
153
- `).map((j)=>{let V=j.trim();if(!V)return"";if(V==="{"||V==="}"||V==="["||V==="]"||V.startsWith("}")||V.startsWith("]"))return V;return` ${V}`}).join(`
154
- `)}let _=A.endsWith("?")||B;if(A.endsWith("?"))A=A.slice(0,-1).trim();let G=_&&!h?"?":"";if(h)return`...${A}: ${P}`;return`${A}${G}: ${P}`}function Qo(d){let p=0;if(p<d.length&&d.charCodeAt(p)===45)p++;if(p>=d.length)return!1;let h=d.charCodeAt(p);if(h<48||h>57)return!1;while(p<d.length&&d.charCodeAt(p)>=48&&d.charCodeAt(p)<=57)p++;if(p<d.length&&d.charCodeAt(p)===46){if(p++,p>=d.length||d.charCodeAt(p)<48||d.charCodeAt(p)>57)return!1;while(p<d.length&&d.charCodeAt(p)>=48&&d.charCodeAt(p)<=57)p++}return p===d.length}function Zr(d){let p=d.trim();if(p==="true"||p==="false")return"boolean";if(Qo(p))return"number";if(p.startsWith("'")&&p.endsWith("'")||p.startsWith('"')&&p.endsWith('"'))return"string";if(p.startsWith("["))return"unknown[]";if(p.startsWith("{"))return"Record<string, unknown>";return"unknown"}function Xr(d){let p=d.trim();if(p.endsWith("as const"))p=p.slice(0,-8).trim();if(p==="true"||p==="false")return p;if(Qo(p))return p;let h=Yc(p);if(h!==null)return h;return"unknown"}function Yc(d){if(d==="")return null;if(d.charCodeAt(0)===de||d.charCodeAt(0)===me){if(_r(d,0,d.charCodeAt(0))===d.length)return d}let p=Zc(d,"+");if(p.length>1){let h=!1,g=!0,E=[];for(let b of p){let O=b.trim(),R=O.charCodeAt(0);if((R===de||R===me)&&_r(O,0,R)===O.length)h=!0,E.push(Xc(O));else g=!1}if(g)return Qc(E.join(""));if(h)return"string";return null}if(/^[\d\s()+*/%.\-]+$/.test(d)&&/\d/.test(d)&&/[+*/%\-\s]/.test(d))return"number";return null}function Zc(d,p){let h=[],g=0,E="",b=0;while(b<d.length){let O=d.charCodeAt(b);if(O===de||O===me||O===Ne){let R=_r(d,b,O);E+=d.slice(b,R),b=R;continue}if(O===Q&&(d.charCodeAt(b+1)===Q||d.charCodeAt(b+1)===42)){if(d.charCodeAt(b+1)===Q){let A=d.indexOf(`
155
- `,b+2),P=A===-1?d.length:A;E+=d.slice(b,P),b=P;continue}let R=d.indexOf("*/",b+2),S=R===-1?d.length:R+2;E+=d.slice(b,S),b=S;continue}if(O===ae||O===be||O===H)g++;else if(O===$e||O===Pe||O===X)g--;if(d[b]===p&&g===0){h.push(E),E="",b++;continue}E+=d[b],b++}return h.push(E),h}function Xc(d){return d.slice(1,-1).replace(/\\(.)/g,(p,h)=>{if(h==="n")return`
156
- `;if(h==="t")return"\t";if(h==="r")return"\r";if(h==="0")return"\x00";return h})}function Qc(d){return`'${d.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function Li(d){if(d.endsWith("as const"))return null;let p=0,h=-1;for(let g=0;g<d.length;g++){let E=d.charCodeAt(g);if(E===de||E===me||E===Ne)g=_r(d,g,E)-1;else if(E===123||E===91||E===40)p++;else if(E===125||E===93||E===41)p--;else if(p===0&&E===32&&g+4<=d.length&&d.substring(g,g+4)===" as ")h=g}if(h===-1)return null;return d.slice(h+4).trim()||null}function hi(){if(C(),l<a&&r.charCodeAt(l)===ft){l++,C();let d=l,p=0;while(l<a){if(T())continue;let h=r.charCodeAt(l);if(h===ae||h===be||h===ve)p++;else if(h===$e||h===Pe||h===pe&&!J())p--;else if(h===H)if(p>0)p++;else{let g=m(d,l),E=(b)=>{let O=g.length-b.length;return O>=0&&g.endsWith(b)&&(O===0||!_e(g.charCodeAt(O-1)))};if(g.length===0||g.endsWith("|")||g.endsWith("&")||E("is")||E("extends"))p++;else break}else if(h===X){if(p===0)break;p--}else if(p===0&&h===ne)break;if(p===0&&le())break;l++}return m(d,l)}return""}function xt(d,p,h,g){l+=8,C();let E=l<a&&r.charCodeAt(l)===xe;if(E)l++,C();let b=N();if(!b&&!g)return null;C();let O=ht();C();let R=At();C();let S=hi(),A=S.length>0;if(!S)if(h&&E)S="AsyncGenerator<unknown, void, unknown>";else if(E)S="Generator<unknown, void, unknown>";else if(h)S="Promise<void>";else S="void";C();let P=!1;if(l<a&&r.charCodeAt(l)===H){P=!0;let M=l+1;if(Z(H,X),!A&&!E)S=fi(r.slice(M,l-1),h,R)}else if(l<a&&r.charCodeAt(l)===ne)l++;let B=Gt(R),_=`${p?g?"export default function ":"export declare function ":"declare function "}${b||(g?"":"default")}${O}${B}: ${S};`,G=Xe(d);if(P)u.add(c.length);return{kind:"function",name:b||"default",text:_,isExported:p,isDefault:g,isAsync:h,isGenerator:E,returnType:S,generics:O||void 0,leadingComments:G,start:d,end:l}}function It(d,p,h){l+=p.length,C();let g=[];do{if(C(),l>=a)break;let E=r.charCodeAt(l);if(E===H||E===be)return re(),g;let b=N();if(!b)return re(),g;C();let O,R,S=!1;if(l<a&&r.charCodeAt(l)===ft){l++,C();let B=l,_=0;while(l<a){if(T()){if(_===0&&oe())break;continue}let G=r.charCodeAt(l);if(G===ae||G===H||G===be||G===ve)_++;else if(G===$e||G===X||G===Pe||G===pe&&!J())_--;else if(_===0&&(G===ne||G===ut))break;else if(_===0&&G===Ae&&!te())break;if(_===0&&(z()||ie()))break;l++}O=m(B,l)}if(l<a&&r.charCodeAt(l)===Ae)if(s&&O&&(!o||!Ud(O)))qr();else{l++,C();let B=l,_=0,G=0,M=0,j=!0;for(;;){l=B,_=0,G=0,M=0;while(l<a){if(T()){if(_===0&&G===0&&M===0&&oe())break;continue}let V=r.charCodeAt(l);if(V===ae||V===H||V===be)_++;else if(V===$e||V===X||V===Pe)_--;else if(V===ve&&_===0){let He=es(l);if(He!==null)M=Math.max(0,M+He);else if(j&&(l+1>=a||r.charCodeAt(l+1)!==Ae))G++}else if(V===pe&&_===0&&M===0&&!J()){if(G>0&&(l+1>=a||r.charCodeAt(l+1)!==Ae))G--}else if(_===0&&G===0&&M===0&&(V===ne||V===ut))break;if(_===0&&G===0&&M===0&&(z()||De()))break;l++}if(G>0&&j){j=!1;continue}break}if(R=m(B,l),R.endsWith(" as const")||R==="const"){if(S=!0,!O){let V=R.endsWith(" as const")?R.slice(0,-9).trim():R,He=Xr(V);O=He!=="unknown"?He:void 0}}else if(!O){let V=Gr(R)??Li(R);if(V)O=V}}if(l<a){let B=r.charCodeAt(l);if(B===ut){l++;continue}if(B===ne)l++}let A=Xe(d),P=`${h?"export ":""}declare ${p} ${b}: ${O||"unknown"};`;g.push({kind:"variable",name:b,text:P,isExported:h,typeAnnotation:O,value:R,modifiers:S?[p,"const assertion"]:[p],leadingComments:A,start:d,end:l});break}while(l<a);return g}function es(d){if(r.charCodeAt(d)!==ve||d+1>=a)return null;let p=r.charCodeAt(d+1);if(p===pe)return 1;if(p===Q)return-1;if(!dt(p))return null;let h=d+2;while(h<a){let A=r.charCodeAt(h);if(!_e(A)&&A!==mt&&A!==58&&A!==45)break;h++}let g=r.slice(d+1,h),E=r.charCodeAt(h);if(E>32&&E!==pe&&E!==Q)return null;let b=0,O=0,R=h;for(;R<a;R++){let A=r.charCodeAt(R);if(O!==0){if(A===it)R++;else if(A===O)O=0;continue}if(A===de||A===me||A===Ne)O=A;else if(A===H)b++;else if(A===X&&b>0)b--;else if(A===pe&&b===0)break}if(R>=a)return null;let S=R-1;while(S>d&&r.charCodeAt(S)<=32)S--;if(r.charCodeAt(S)===Q)return 0;return r.indexOf(`</${g}`,R+1)===-1?null:1}function Qr(d,p){l+=9,C();let h=N();C();let g=ht();C();let E="";if(v("extends")){l+=7,C();let A=l,P=0;while(l<a){if(T())continue;let B=r.charCodeAt(l);if(B===ve)P++;else if(B===pe&&!J())P--;else if(B===H&&P===0)break;l++}E=m(A,l)}C();let b=l<a&&r.charCodeAt(l)===H?Yr():"{}",O=Zo(b),R=`${p?"export ":""}declare interface ${h}${g}${E?` extends ${E}`:""} ${O}`,S=Xe(d);return{kind:"interface",name:h,text:R,isExported:p,extends:E||void 0,generics:g||void 0,leadingComments:S,start:d,end:l}}function en(d,p){l+=4,C();let h=N();C();let g=ht();if(C(),l<a&&r.charCodeAt(l)===Ae)l++;C();let E=l,b=0;while(l<a){if(T())continue;let A=r.charCodeAt(l);if(A===ae||A===H||A===be||A===ve)b++;else if(A===$e||A===X||A===Pe||A===pe&&!J())b--;else if(b===0&&A===ne)break;if(b===0&&(z()||ie()))break;l++}let O=m(E,l);if(l<a&&r.charCodeAt(l)===ne)l++;let R=`${p?"export ":""}type ${h}${g} = ${O}`,S=Xe(d);return{kind:"type",name:h,text:R,isExported:p,generics:g||void 0,leadingComments:S,start:d,end:l}}function jt(d,p,h){l+=4,C();let g=N();C();let E=l;if(l<a&&r.charCodeAt(l)===H)Z(H,X);let b=m(d,l),O=Xe(d);return{kind:"enum",name:g,text:b,isExported:p,modifiers:h?["const"]:void 0,leadingComments:O,start:d,end:l}}function Tt(d,p,h,g=!1){l+=5,C();let E=N()||"AnonymousClass";C();let b=ht();C();let O="";if(v("extends")){l+=7,C();let B=l,_=0;while(l<a){if(T())continue;let G=r.charCodeAt(l);if(G===ve)_++;else if(G===pe&&!J())_--;else if(_===0&&(G===H||v("implements")))break;l++}O=m(B,l)}let R;if(v("implements")){l+=10,C();let B=l,_=0;while(l<a){if(T())continue;let M=r.charCodeAt(l);if(M===ve)_++;else if(M===pe&&!J())_--;else if(_===0&&M===H)break;l++}let G=m(B,l);if(G)R=G.split(",").map((M)=>M.trim())}C();let S=tn(),A=`${p?g?"export default ":"export declare ":"declare "}${h?"abstract ":""}class ${E}${b}${O?` extends ${O}`:""}${R&&R.length>0?` implements ${R.join(", ")}`:""} ${S}`,P=Xe(d);return{kind:"class",name:E,text:A,isExported:p,isDefault:g,extends:O||void 0,implements:R,generics:b||void 0,modifiers:h?["abstract"]:void 0,leadingComments:P,start:d,end:l}}function tn(){if(l>=a||r.charCodeAt(l)!==H)return"{}";l++;let d=[];while(l<a){if(C(),l>=a)break;if(r.charCodeAt(l)===X){l++;break}if(r.charCodeAt(l)===ne){l++;continue}if(v("static")&&ts("static")===H){l+=6,C(),Z(H,X);continue}let p=!1,h=!1,g=!1,E=!1,b=!1,O=!1,R=!1,S=!1,A=!0;while(A){if(C(),v("private")){p=!0,l+=7;continue}if(v("protected")){h=!0,l+=9;continue}if(v("public")){l+=6;continue}if(v("static")){g=!0,l+=6;continue}if(v("abstract")){E=!0,l+=8;continue}if(v("readonly")){b=!0,l+=8;continue}if(v("override")){O=!0,l+=8;continue}if(v("accessor")){R=!0,l+=8;continue}if(v("async")){S=!0,l+=5;continue}if(v("declare")){l+=7;continue}break}if(C(),l>=a||r.charCodeAt(l)===X)break;if(r.charCodeAt(l)===jr)p=!0;if(p){nn();continue}let P=" ";if(h)P+="protected ";if(g)P+="static ";if(E)P+="abstract ";if(b)P+="readonly ";if(v("constructor")){l+=11,C();let B=At();if(C(),tf(B,d),l<a&&r.charCodeAt(l)===H)Z(H,X);else if(l<a&&r.charCodeAt(l)===ne)l++;let _=Gt(B);d.push(` constructor${_};`)}else if(v("get"))if(l+=3,C(),l<a&&(dt(r.charCodeAt(l))||r.charCodeAt(l)===be||r.charCodeAt(l)===jr)){let B=rn();if(B.startsWith("#")){if(C(),l<a&&r.charCodeAt(l)===ae)At();if(C(),hi(),C(),l<a&&r.charCodeAt(l)===H)Z(H,X);else if(l<a&&r.charCodeAt(l)===ne)l++;continue}C(),At(),C();let _=hi()||"unknown";if(C(),l<a&&r.charCodeAt(l)===H)Z(H,X);else if(l<a&&r.charCodeAt(l)===ne)l++;d.push(`${P}get ${B}(): ${_};`)}else is("get",P,g,b,S,d);else if(v("set"))if(l+=3,C(),l<a&&(dt(r.charCodeAt(l))||r.charCodeAt(l)===be||r.charCodeAt(l)===jr)){let B=rn();if(B.startsWith("#")){if(C(),l<a&&r.charCodeAt(l)===ae)At();if(C(),l<a&&r.charCodeAt(l)===H)Z(H,X);else if(l<a&&r.charCodeAt(l)===ne)l++;continue}C();let _=At();if(C(),l<a&&r.charCodeAt(l)===H)Z(H,X);else if(l<a&&r.charCodeAt(l)===ne)l++;let G=Gt(_);d.push(`${P}set ${B}${G};`)}else is("set",P,g,b,S,d);else{let B=r.charCodeAt(l)===xe;if(B)l++,C();let _=rn();if(!_){nn();continue}rs(_,P,g,b,B,E,S,d)}}return`{
136
+ }`:"{}";if(s.length===0)return f;let u=s[0];for(let a=1;a<s.length;a++)u=`Omit<${u}, keyof ${s[a]}> & ${s[a]}`;return o.length>0?`Omit<${u}, keyof ${f}> & ${f}`:u}function Br(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(!St(e.charCodeAt(i)))return!1;return!0}function ci(e){let t=e.split(".");return t.length>0&&t.every(Br)}function Id(e){let t=!1,i="";for(let n=0;n<e.length;n++){let r=e[n];if(t){if(r==="\\")n++;else if(r===i)t=!1;continue}if(r==='"'||r==="'"||r==="`"){t=!0,i=r;continue}if(r==="(")return n;if(r==="<"){let o=tt(e,n,"<",">");if(o!==-1)n=o}}return-1}function Fl(e){if(e.length<3||!e.endsWith(")"))return null;let t=Id(e);if(t===-1||tt(e,t,"(",")")!==e.length-1)return null;let i=e.slice(0,t).trim(),n=!1;if(i.endsWith("?."))n=!0,i=i.slice(0,-2).trim();let r=i,o=!1,s=i.indexOf("<");if(s!==-1){if(tt(i,s,"<",">")!==i.length-1)return null;r=i.slice(0,s).trim(),o=!0}if(!ci(r))return null;let l=e.slice(t+1,-1).trim(),c=Lr(l)!==-1||l.startsWith("function")||l.startsWith("async function"),f=ci(l),u=!c&&l.endsWith(")")&&Fl(l)!==null;if(!o&&!n&&!c&&!f&&!u)return null;let a=`ReturnType<typeof ${i}>`;return n?`${a} | undefined`:a}function Tl(e){let t=e.split(`
137
+ `).map((f)=>Ll(f)).join(`
138
+ `),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(!St(f)&&!St(u))t=(t.slice(0,i)+t.slice(i+5)).trim()}let n=t.indexOf("(");if(n!==-1){let f=tt(t,n,"(",")");if(f!==-1){let u=t.slice(n,f+1),a=Wt(u);t=t.slice(0,n)+a+t.slice(f+1)}}let r=t.length,o="",s=[],l=!1,c=!1;for(let f=0;f<r;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)c=!0;continue}if(l&&o.length>0){let a=(s.length>0?s[s.length-1]:0)===123;if(c&&a){let m=o.charCodeAt(o.length-1),y=m===59||m===44||m===123||u===125,w=o.length>=2&&o.charCodeAt(o.length-1)===47&&o.charCodeAt(o.length-2)===42;if(!y&&!w)o+="; ";else o+=" "}else o+=" "}l=!1,c=!1,o+=t[f]}return o.trim()}function St(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===95||e===36}function Wt(e){let t=e.trim(),i,n=!1;if(t.startsWith("(")&&t.endsWith(")"))i=t.slice(1,-1),n=!0;else i=t;let r=i.trim();if(!r)return n?"()":"";let o=!1;{let w=0;for(let C=0;C<r.length;C++){let A=r.charCodeAt(C);if(A===40||A===60||A===91||A===123)w++;else if(A===41||A===93||A===125||A===62&&r.charCodeAt(C-1)!==61)w--;else if(w===0&&A===61){let k=C>0?r.charCodeAt(C-1):0,W=C+1<r.length?r.charCodeAt(C+1):0;if(k!==61&&k!==33&&k!==60&&k!==62&&W!==61&&W!==62){o=!0;break}}}}if(!o)return t;let s=[],l=[],c=0,f=0,u=!1,a=0;for(let w=0;w<=r.length;w++){if(w===r.length){s.push(r.slice(c));break}let C=r.charCodeAt(w);if(u){if(C===92){w++;continue}if(C===a)u=!1;continue}if(C===47&&w+1<r.length){let A=r.charCodeAt(w+1);if(A===42){w+=2;while(w+1<r.length&&!(r.charCodeAt(w)===42&&r.charCodeAt(w+1)===47))w++;w++;continue}if(A===47){while(w<r.length&&r.charCodeAt(w)!==10)w++;continue}}if(C===39||C===34||C===96){u=!0,a=C;continue}if(C===40||C===60||C===91||C===123)f++;else if(C===41||C===93||C===125||C===62&&r.charCodeAt(w-1)!==61)f--;else if(C===44&&f===0){s.push(r.slice(c,w));let A=",",k=w+1;while(k<r.length&&r.charCodeAt(k)<=32)A+=r[k],k++;l.push(A),c=k}}let m=[];for(let w of s){let C=w.trim();if(!C){m.push(w);continue}if(C.startsWith("//"))continue;let A=Ll(C),k=w.slice(0,w.length-w.trimStart().length);m.push(k+Nd(A))}let y=m[0]||"";for(let w=1;w<m.length;w++)y+=(l[w-1]||", ")+m[w];return n?`(${y})`:y}function Ll(e){let t=!1,i=0;for(let n=0;n<e.length-1;n++){let r=e.charCodeAt(n);if(t){if(r===92){n++;continue}if(r===i)t=!1;continue}if(r===39||r===34||r===96){t=!0,i=r;continue}if(r===47&&e.charCodeAt(n+1)===47)return e.slice(0,n).trimEnd()}return e}function Nd(e){if(e.startsWith("..."))return e;let t=-1,i=-1,n=0,r=!1,o=0;for(let l=0;l<e.length;l++){let c=e.charCodeAt(l);if(r){if(c===92){l++;continue}if(c===o)r=!1;continue}if(c===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(c===39||c===34||c===96){r=!0,o=c;continue}if(c===40||c===60||c===91||c===123)n++;else if(c===41||c===93||c===125||c===62&&e.charCodeAt(l-1)!==61)n--;else if(n===0){if(c===58&&t===-1)t=l;else if(c===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(),c=i!==-1?e.slice(t+1,i).trim():e.slice(t+1).trim(),f=s&&!l.endsWith("?")?"?":"";return`${l}${f}: ${c}`}else if(i!==-1){let l=e.slice(0,i).trim(),c=!l.endsWith("?")?"?":"",f=e.slice(i+1).trim(),u="unknown";if(f==="true"||f==="false")u="boolean";else if(/^-?\d+(\.\d+)?$/.test(f))u="number";else if(f.startsWith("'")&&f.endsWith("'")||f.startsWith('"')&&f.endsWith('"'))u="string";else if(f.startsWith("["))u="unknown[]";else if(f.startsWith("{"))u="Record<string, unknown>";return`${l}${c}: ${u}`}return e}function Fd(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 Wl(e){let t=[],i=0,n=e.length;while(i<n){while(i<n&&e.charCodeAt(i)<=32)i++;if(i+1>=n||e.charCodeAt(i)!==47||e.charCodeAt(i+1)!==42)break;let r=i;i+=2;while(i+1<n&&!(e.charCodeAt(i)===42&&e.charCodeAt(i+1)===47))i++;i=Math.min(i+2,n),t.push(e.slice(r,i).trim())}return{comments:t.join(`
139
+ `),key:e.slice(i).trim()}}function Ld(e){let t=[],i="",n="",r=0,o=!1,s="",l=!0,c=!1,f=0,u=!1,a=!1,m=0,y=!1,w=!1;for(let C=0;C<e.length;C++){let A=e.charCodeAt(C),k=C>0?e.charCodeAt(C-1):0,W=C<e.length-1?e.charCodeAt(C+1):0;if(!o&&!c&&A===47&&W===47){i=i.replace(/[ \t]+$/,""),C+=2;while(C<e.length&&e.charCodeAt(C)!==10)C++;C--;continue}if(!o&&!c&&A===47&&W===42){c=!0,f=1,i+="/*",C++;continue}else if(c&&A===42&&W===47){if(f--,i+="*/",C++,f===0)c=!1;continue}else if(c&&A===47&&W===42){f++,i+="/*",C++;continue}let B=e[C];if(!o&&!c&&(A===34||A===39||A===96))o=!0,s=B,i+=B;else if(o&&B===s&&k!==92)o=!1,i+=B;else if(!o&&!c)if(A===40&&r===0&&l&&m===0){n=i.trim();let T=Fd(n),D=T>0?n.slice(0,T):"",N=n.slice(T),F="";if(N.startsWith("async ")||N.startsWith("async\t")||N.startsWith(`async
140
+ `))N=N.slice(6).trimStart(),F="async ";if(N.startsWith("*"))N=N.slice(1).trimStart(),F+="*";n=D+N,i=F+B,l=!1,y=!0,w=!1,r=1}else if(A===123||A===91||A===40){if(r++,i+=B,w&&A===123)w=!1}else if(A===125||A===93||A===41){if(r--,i+=B,A===41&&r===0&&!l&&!y)u=!0;if(y){if(A===41&&r===0&&!w)w=!0;else if(A===125&&r===0)y=!1,w=!1}}else if(A===58&&r===0&&l&&m===0)n=i.trim(),i="",l=!1;else if(A===58&&r===0&&u)a=!0,i+=B;else if(A===60&&a)m++,i+=B;else if(A===60&&l&&r===0)m++,i+=B;else if(A===62&&m>0&&k!==61)m--,i+=B;else if(A===61&&W===62&&a&&m===0)a=!1,u=!1,i+=B;else if(A===44&&r===0&&m===0&&!w){if(n&&i.trim()){let T=i.trim();t.push([n,T])}else if(l&&i.trim())Ol(t,i.trim());i="",n="",l=!0,u=!1,a=!1,m=0}else i+=B;else i+=B}if(n&&i.trim()){let C=i.trim();t.push([n,C])}else if(l&&i.trim())Ol(t,i.trim());return t}function Ol(e,t){let{comments:i,key:n}=Wl(t);if(Br(n))e.push([i?`${i}
141
+ ${n}`:n,n]);else if(n.startsWith("...")&&n.length>3)e.push(["...",n.slice(3).trim()])}function Wd(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 Bd(e,t,i){let n=i.trim();if(n.charCodeAt(0)!==40)return null;let r=tt(n,0,"(",")");if(r===-1)return null;let o=n.slice(1,r).trim(),s=n.slice(r+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 Gd(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 n=0;n<t.length;n++){let r=t.charCodeAt(n);if(r===40)i++;else if(r===41){if(i--,i===0){let o=t.slice(n+1).trimStart();if(o.startsWith("{"))return!0;if(o.startsWith(":")){let s=No(o,1);if(s?.kind==="arrow")return!1;if(s?.kind==="body")return!0}return!1}}}return!1}function jd(e){let t=e.trimEnd();if(!t.endsWith(">"))return null;let i=0,n=-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){n=o;break}}}if(n===-1)return null;let r=t.slice(0,n).trimEnd();if(!r)return null;return{name:r,typeParams:t.slice(n)}}function Rl(e,t){let i=t.trimStart(),n=!1,r=!1;if(i.startsWith("async ")||i.startsWith("async\t"))n=!0,i=i.slice(5).trimStart();if(i.startsWith("*"))r=!0,i=i.slice(1).trimStart();let o="";if(i.charCodeAt(0)===60){let m=0,y=-1;for(let w=0;w<i.length;w++)if(i.charCodeAt(w)===60)m++;else if(i.charCodeAt(w)===62&&!(w>0&&i.charCodeAt(w-1)===61)){if(m--,m===0){y=w;break}}if(y!==-1)o=i.slice(0,y+1),i=i.slice(y+1).trimStart()}let s=i.indexOf("("),l=tt(i,s,"(",")");if(s===-1||l===-1)return"() => unknown";let c=i.slice(s,l+1),f="unknown",u=i.slice(l+1).trimStart();if(u.charCodeAt(0)===58){let m=u.slice(1),y=No(m,0);if(y)f=m.slice(0,y.index).trim();else f=m.trim()}if(f==="unknown"&&!r&&u.charCodeAt(0)===123){let m=tt(u,0,"{","}");if(m!==-1){let y=fi(u.slice(1,m),n,c);if(y!=="unknown"&&y!=="Promise<unknown>")f=n&&y.startsWith("Promise<")?y.slice(8,-1):y;else if(n)f="Promise<unknown>"}}if(f==="unknown"){if(n&&r)f="AsyncGenerator<unknown, void, unknown>";else if(r)f="Generator<unknown, void, unknown>";else if(n)f="Promise<void>"}else if(n&&!f.startsWith("Promise<")&&!f.startsWith("AsyncGenerator<"))f=`Promise<${f}>`;let a=Wt(c);return`${o}${a} => ${f}`}function No(e,t){let i=0,n=0,r=0,o=0,s=!1,l=0;for(let c=t;c<e.length;c++){let f=e.charCodeAt(c);if(s){if(f===92)c++;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)n++;else if(f===93&&n>0)n--;else if(f===60)r++;else if(f===62&&r>0&&e.charCodeAt(c-1)!==61)r--;else if(f===125&&o>0)o--;else if(f===123){let u=i>0||n>0||r>0||o>0,a=e.slice(t,c).trimEnd(),m=a.charCodeAt(a.length-1),y=a.length===0||m===38||m===124||m===40||m===44||m===58||m===61||m===91;if(u||y)o++;else return{index:c,kind:"body"}}else if(f===61&&c+1<e.length&&e.charCodeAt(c+1)===62&&i===0&&n===0&&r===0&&o===0)return{index:c,kind:"arrow"}}return null}function tt(e,t,i,n){let r=0;for(let o=t;o<e.length;o++)if(e[o]===i)r++;else if(e[o]===n){if(n===">"&&o>0&&e[o-1]==="=")continue;if(r--,r===0)return o}return-1}function Lr(e){let t=0,i=0,n=!1,r="";for(let o=0;o<e.length-1;o++){let s=e[o],l=e[o+1],c=o>0?e[o-1]:"";if(!n&&(s==='"'||s==="'"||s==="`"))n=!0,r=s;else if(n&&s===r&&c!=="\\")n=!1;if(!n){if(s==="<"){let f=tt(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 Bl(e,t=!1,i=0,n=!0){let r=e.trim();if(r.length>200&&So(r,"=>")>2&&So(r,"<")>5&&!r.startsWith("function"))return t?"((...args: any[]) => any)":"(...args: any[]) => any";if(r.startsWith("async ")&&r.includes("=>")){let s=r.slice(5).trim(),l=Lr(s);if(l===-1)return t?"(() => Promise<unknown>)":"() => Promise<unknown>";let c=s.substring(0,l).trim(),f=s.substring(l+2).trim(),u=Pl(c),{params:a,returnType:m}=u;if(a=Wt(a),a==="()"||a==="")a="()";else if(!a.startsWith("("))a=`(${a})`;let y=m;if(y);else if(f.startsWith("{"))y=fi(f.slice(1,f.endsWith("}")?-1:void 0),!0,a);else y=Ie(f,n,!1,i+1);let w=`${a} => ${m||y.startsWith("Promise<")?y:`Promise<${y}>`}`;return t?`(${w})`:w}if(r.includes("=>")){let s="",l=r;if(r.startsWith("<")){let A=tt(r,0,"<",">");if(A!==-1)s=r.substring(0,A+1),l=r.substring(A+1).trim()}let c=Lr(l);if(c===-1)return t?"(() => unknown)":"() => unknown";let f=l.substring(0,c).trim(),u=l.substring(c+2).trim(),a=Pl(f),{params:m,returnType:y}=a;if(m=Wt(m),m==="()"||m==="")m="()";else if(!m.startsWith("("))m=`(${m})`;let w="unknown";if(y)w=y;else if(u.startsWith("{"))w=fi(u.slice(1,u.endsWith("}")?-1:void 0),!1,m);else if(Ir(u)||Il(u)&&Ir(u.slice(1,-1).trim()))w="JSX.Element";else if(u.includes("=>")){let A=u.trimStart(),k=A.indexOf("("),W=k!==-1?tt(A,k,"(",")"):-1,B=W!==-1?A.indexOf("=>",W):-1;if(k===0&&W!==-1&&B!==-1){let T=A.substring(k+1,W).trim(),D=Wt(T);if(s.includes("T")&&D.includes("T"))w=`(${D}) => T`;else w=`(${D}) => any`}else w="any"}else if(t)w="unknown";else w=Lt(u,Dl(m));let C=`${s}${m} => ${w}`;return t?`(${C})`:C}if(r.startsWith("function")){let s=8,l=r.length;while(s<l&&r.charCodeAt(s)<=32)s++;let c=!1;if(s<l&&r.charCodeAt(s)===42){c=!0,s++;while(s<l&&r.charCodeAt(s)<=32)s++}let f="";if(s<l&&r.charCodeAt(s)===60){let m=s,y=1;s++;while(s<l&&y>0){let w=r.charCodeAt(s);if(w===60)y++;else if(w===62&&r.charCodeAt(s-1)!==61)y--;s++}f=r.substring(m,s);while(s<l&&r.charCodeAt(s)<=32)s++}let u=r.indexOf("(",s);if(u!==-1){let m=1,y=u+1;while(y<l&&m>0){let B=r.charCodeAt(y);if(B===40)m++;else if(B===41)m--;y++}let w=r.substring(u+1,y-1).trim(),C=w?Wt(`(${w})`):"()";if(c){let B=r.substring(y).trim(),T=B.indexOf("Generator<");if(T!==-1){let N=T+10,F=B.indexOf(">",N);if(F!==-1){let E=B.substring(N,F),K=`${f}${C} => Generator<${E}>`;return t?`(${K})`:K}}let D=`${f}${C} => Generator<any, any, any>`;return t?`(${D})`:D}let A="unknown",k=r.substring(y).trimStart();if(k.charCodeAt(0)===58){let B=k.slice(1),T=No(B,0),D=(T?B.slice(0,T.index):B).trim();if(D)A=D}let W=`${f}${C} => ${A}`;return t?`(${W})`:W}let a="(...args: any[]) => unknown";return t?`(${a})`:a}if(r.includes("=>")&&r.includes("(")&&r.includes(")")){if(r.length>100||So(r,"=>")>2){let s="";if(r.charCodeAt(0)===60){let a=tt(r,0,"<",">");if(a!==-1)s=r.substring(0,a+1)}let l=r.indexOf("("),c=l!==-1?tt(r,l,"(",")"):-1,f=l!==-1&&c!==-1?r.substring(l,c+1):"(...args: any[])";f=Wt(f);let u=`${s}${f} => any`;return t?`(${u})`:u}return t?`(${r})`:r}let o="() => unknown";return t?`(${o})`:o}function Pl(e){let t=e.trim();if(!t.startsWith("("))return{params:t,returnType:""};let i=tt(t,0,"(",")");if(i===-1)return{params:t,returnType:""};let n=t.slice(i+1).trim();return{params:t.slice(0,i+1),returnType:n.startsWith(":")?n.slice(1).trim():""}}function Gl(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 Gr(e){let t=-1,i=0;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);if(o===34||o===39||o===96){r=kt(e,r,o)-1;continue}if(o===47&&e.charCodeAt(r+1)===47){while(r<e.length&&e.charCodeAt(r)!==10)r++;continue}if(o===47&&e.charCodeAt(r+1)===42){let s=e.indexOf("*/",r+2);r=s===-1?e.length:s+1;continue}if(o===47){let s=r-1;while(s>=0&&e.charCodeAt(s)<=32)s--;if(s<0||"([{:;,=!?&|+*-~>".includes(e[s])){let l=!1;for(r++;r<e.length;r++){let c=e.charCodeAt(r);if(c===92)r++;else if(c===91)l=!0;else if(c===93)l=!1;else if(c===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",r)&&xo(e,r,9)&&e[r-1]!==".")t=r}if(t===-1)return null;let n=e.slice(t+9).trim();if(n.endsWith(";"))n=n.slice(0,-1).trim();return n||null}var ko=20,Wr=!1,Ye=null;var Fo=()=>{};function je(e){return e===ke||e===Me||e===Ee||e===Te}function Ud(e){let t=!0;for(let i=0;i<e.length;i++){let n=e.charCodeAt(i);if(n===pt){if(t)return!1;t=!0}else if(t){if(!mt(n))return!1;t=!1}else if(!_e(n))return!1}return e.length>0&&!t}function _r(e,t,i){let n=t+1;while(n<e.length){let r=e.charCodeAt(n);if(r===it){n+=2;continue}if(n++,r===i)break}return n}function Kd(e){if(e==="any"||e==="object"||e==="unknown")return!0;if(e.startsWith("Record<")||e.startsWith("Array<"))return!0;return e.charCodeAt(0)===H&&e.includes("[")&&e.includes("]:")}function Vl(e,t,i=!0){return Kl(e,t,i,!0)}function Ul(e,t,i=!0){return Kl(e,t,i,!1)}function Kl(e,t,i,n){let r=e,o=i,s=n,l=r.length,c=[],f=new Map,u=new Set,a=0;if(a<l&&r.charCodeAt(a)===65279)a++;function m(d,p){if(d<p){let h=r.charCodeAt(d),g=r.charCodeAt(p-1);if(h!==ke&&h!==Me&&h!==Ee&&h!==Te&&g!==ke&&g!==Me&&g!==Ee&&g!==Te)return r.slice(d,p)}while(d<p&&je(r.charCodeAt(d)))d++;while(p>d&&je(r.charCodeAt(p-1)))p--;return r.slice(d,p)}let y=/[\r\n]/g;function w(d){return y.lastIndex=d,y.exec(r)?.index??l}function C(){if(a>=l)return;let d=r.charCodeAt(a);if(d!==ke&&d!==Me&&d!==Ee&&d!==Te&&d!==Q)return;while(a<l){let p=r.charCodeAt(a);if(p===ke||p===Me||p===Ee||p===Te){a++;continue}if(p===Q&&a+1<l){let h=r.charCodeAt(a+1);if(h===Q){a=w(a+2);continue}if(h===Ae){let g=r.indexOf("*/",a+2);a=g===-1?l:g+2;continue}}break}}function A(d){let p=d.length,h=0,g=p;for(let b=0;b<p;b++){let v=d.charCodeAt(b);if(h){if(v===it){b++;continue}if(v===h)h=0;continue}if(v===le||v===ue||v===Ne){h=v;continue}if(v===Q&&b+1<p){let O=d.charCodeAt(b+1);if(O===Q){g=b;while(g>0&&(d.charCodeAt(g-1)===ke||d.charCodeAt(g-1)===Me))g--;return d.slice(0,g)}if(O===Ae){let R=d.indexOf("*/",b+2);if(R!==-1){d=`${d.slice(0,b)} ${d.slice(R+2)}`,b--;continue}}}}g=p;while(g>0&&(d.charCodeAt(g-1)===ke||d.charCodeAt(g-1)===Me||d.charCodeAt(g-1)===Te))g--;return g<p?d.slice(0,g):d}function k(d){a++;let p=d===le?"'":'"';while(a<l){let h=r.indexOf(p,a);if(h===-1){a=l;return}let g=0,b=h-1;while(b>=0&&r.charCodeAt(b)===it)g++,b--;if(g%2===0){a=h+1;return}a=h+1}}function W(){a++;let d=[];while(a<l){let p=r.charCodeAt(a);if(d.length===0){if(p===it){a+=2;continue}if(p===Ne){a++;return}if(p===Vd&&a+1<l&&r.charCodeAt(a+1)===H){a+=2,d.push(0);continue}a++;continue}if(p===le||p===ue){k(p);continue}if(p===Ne){W();continue}if(p===Q&&a+1<l){let h=r.charCodeAt(a+1);if(h===Q){a=w(a+2);continue}if(h===Ae){let g=r.indexOf("*/",a+2);a=g===-1?l:g+2;continue}if(D()){N();continue}a++;continue}if(p===H){d[d.length-1]++,a++;continue}if(p===X){let h=d[d.length-1];if(h===0){d.pop(),a++;continue}d[d.length-1]=h-1,a++;continue}a++}}let B=!1;function T(){B=!1;let d=r.charCodeAt(a);if(d===le||d===ue)return k(d),!0;if(d===Ne)return W(),!0;if(d===Q&&a+1<l){let p=r.charCodeAt(a+1);if(p===Q)return a=w(a+2),!0;if(p===Ae){let h=r.indexOf("*/",a+2);return B=w(a+2)<(h===-1?l:h),a=h===-1?l:h+2,!0}if(D())return N(),!0}return!1}function D(){return ji(r,a)}function N(){a=di(r,a)}function F(){let d=a;while(a<l&&_e(r.charCodeAt(a)))a++;return r.slice(d,a)}function E(d){if(a+d.length>l)return!1;for(let p=0;p<d.length;p++)if(r.charCodeAt(a+p)!==d.charCodeAt(p))return!1;if(a+d.length<l&&_e(r.charCodeAt(a+d.length)))return!1;return!0}function K(d){let p=a+d;while(p<l){let h=r.charCodeAt(p);if(h===ke||h===Me||h===Ee||h===Te){p++;continue}return h!==pt&&h!==ve}return!1}function oe(){if(!B)return!1;let d=a;C();let p=a>=l||he()||r.charCodeAt(a)===X;return a=d,p}function he(){if(a>=l)return!1;switch(r.charCodeAt(a)){case 101:return E("export")||E("enum");case 105:return E("import")||E("interface");case 102:return E("function");case 99:return E("class")||E("const");case 116:return E("type");case 108:return E("let");case 118:return E("var");case 100:return E("declare")||E("default");case 109:return E("module");case 110:return E("namespace");case 97:return E("abstract")||E("async");default:return!1}}function z(){let d=r.charCodeAt(a);if(d!==Ee&&d!==Te)return!1;let p=a;if(a++,d===Te&&a<l&&r.charCodeAt(a)===Ee)a++;while(a<l){let g=r.charCodeAt(a);if(g===ke||g===Me||g===Te||g===Ee){a++;continue}if(g===Q&&a+1<l){let b=r.charCodeAt(a+1);if(b===Q){a=w(a+2);continue}if(b===Ae){let v=r.indexOf("*/",a+2);a=v===-1?l:v+2;continue}}break}let h=a>=l||he()||r.charCodeAt(a)===X;return a=p,h}function ge(d){let p=d-1;while(p>=0){let S=r.charCodeAt(p);if(S===ke||S===Me||S===Te||S===Ee){p--;continue}break}if(p<0)return!0;let h=r[p];if("+-*/%=<>&|^!~?:,.([{".includes(h))return!0;let g=p;while(g>0&&r.charCodeAt(g-1)!==Ee)g--;let b=r.slice(g,p+1),v=b.lastIndexOf("<");if(v!==-1&&/^<[A-Za-z]/.test(b.slice(v))&&!b.slice(v).includes(">"))return!0;let O=p;while(O>=0&&/[a-z]/i.test(r[O]))O--;let R=r.slice(O+1,p+1);return["as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","return","yield","void"].includes(R)}function De(){let d=r.charCodeAt(a);if(d!==Ee&&d!==Te)return!1;if(ge(a))return!1;let p=a;a++;while(a<l){let v=r.charCodeAt(a);if(v===ke||v===Me||v===Te||v===Ee){a++;continue}if(v===Q&&a+1<l){let O=r.charCodeAt(a+1);if(O===Q){a=w(a+2);continue}if(O===Ae){let R=r.indexOf("*/",a+2);a=R===-1?l:R+2;continue}}break}let h=a<l?r[a]:"",g=r.slice(a,a+2),b=h==="."||h==="?"||h===":"||h===")"||h==="]"||h==="}"||h===","||h==="+"||h==="-"||h==="*"||h==="/"||h==="%"||h==="<"||h===">"||h==="="||h==="&"||h==="|"||h==="^"||h==="`"||g==="=>"||E("as")||E("satisfies")||E("instanceof")||E("in");return a=p,!b}function re(){let d=r.charCodeAt(a);if(d!==Ee&&d!==Te)return!1;if(ge(a))return!1;let p=a;a++;while(a<l){let b=r.charCodeAt(a);if(b===ke||b===Me||b===Te||b===Ee){a++;continue}if(b===Q&&a+1<l){let v=r.charCodeAt(a+1);if(v===Q){a=w(a+2);continue}if(v===Ae){let O=r.indexOf("*/",a+2);a=O===-1?l:O+2;continue}}break}let h=a<l?r[a]:"",g=h==="|"||h==="&"||h==="["||h==="."||h==="?"||h===":"||h===">"||h===")"||h===","||E("extends");return a=p,!g}function ce(){let d=r.charCodeAt(a);if(d!==Ee&&d!==Te)return!1;let p=a;if(a++,d===Te&&a<l&&r.charCodeAt(a)===Ee)a++;while(a<l){let g=r.charCodeAt(a);if(g===ke||g===Me||g===Te||g===Ee){a++;continue}if(g===Q&&a+1<l&&r.charCodeAt(a+1)===Q){a=w(a+2);continue}break}if(a>=l)return a=p,!0;let h=r.charCodeAt(a);if(h===124||h===38||h===pt||h===jr||h===lt)return a=p,!1;if(E("extends")||E("keyof")||E("typeof")||E("infer")||E("is")||E("as")||E("in"))return a=p,!1;return a=p,!0}let ee=/[{}'"`\/]/g,L=/[()'"`\/]/g,U=/[[\]'"`\/]/g,q=/[<>'"`\/]/g;function Z(d,p){let h=1;a++;let g=d===H?ee:d===ae?L:d===xe?U:q;g.lastIndex=a;let b;while((b=g.exec(r))!==null){let v=b.index,O=r.charCodeAt(v);if(O===le||O===ue){a=v,k(O),g.lastIndex=a;continue}if(O===Ne){a=v,W(),g.lastIndex=a;continue}if(O===Q){if(a=v,T()){g.lastIndex=a;continue}g.lastIndex=v+1;continue}if(O===d)h++;else if(O===p){if(p===me&&v>0&&r.charCodeAt(v-1)===ve){g.lastIndex=v+1;continue}if(h--,h===0)return a=v+1,a}g.lastIndex=v+1}return a=l,a}function J(){return a>0&&r.charCodeAt(a-1)===ve}function te(){return a+1<l&&r.charCodeAt(a+1)===me}let se=/[<{};'"`\/\n\r()[\]]/g;function ne(d=!1){let p=0,h=0,g=0,b=0,v=r.charCodeAt(a)===H;se.lastIndex=a;let O;while((O=se.exec(r))!==null){let R=O.index,S=r.charCodeAt(R);if(S===le||S===ue){a=R,k(S),se.lastIndex=a;continue}if(S===Ne){a=R,W(),se.lastIndex=a;continue}if(S===Q){if(R>0&&r.charCodeAt(R-1)===be){se.lastIndex=R+1;continue}if(a=R,T()){if(p===0&&h===0&&g===0&&b===0&&oe())return;se.lastIndex=a;continue}se.lastIndex=R+1;continue}if(S===be){let x=es(R);if(x!==null)b=Math.max(0,b+x);se.lastIndex=R+1;continue}if(S===ae){h++,se.lastIndex=R+1;continue}if(S===$e){h--,se.lastIndex=R+1;continue}if(S===xe){g++,se.lastIndex=R+1;continue}if(S===Pe){g--,se.lastIndex=R+1;continue}if(S===H){p++,se.lastIndex=R+1;continue}if(S===X){let x=p>0;if(!x&&d&&h===0&&g===0&&b===0){a=R;return}if(x)p--;if((!x||v)&&p===0&&h===0&&g===0&&b===0){a=R+1;return}se.lastIndex=R+1;continue}if(S===ie&&p===0&&h===0&&g===0&&b===0){a=R+1;return}if((S===Ee||S===Te)&&p===0&&h===0&&g===0&&b===0){if(a=R,z())return}se.lastIndex=R+1}a=l}function qr(){a++;while(a<l&&(r.charCodeAt(a)===ke||r.charCodeAt(a)===Me))a++;let d=r.indexOf(`
142
+ `,a),p=d===-1?l:d,h=r.indexOf(";",a);if(h!==-1&&h<p){let g=h-1;while(g>=a&&(r.charCodeAt(g)===ke||r.charCodeAt(g)===Me))g--;let b=r.charCodeAt(a),v=r.charCodeAt(g);if(b===H&&v===X||b===xe&&v===Pe||b===le&&v===le||b===ue&&v===ue||b===Ne&&v===Ne){a=h+1;return}}ne()}function Jo(){Z(H,X);while(a<l&&je(r.charCodeAt(a)))a++;if(E("from")){a+=4;while(a<l&&je(r.charCodeAt(a)))a++;if(a<l){let d=r.charCodeAt(a);if(d===le||d===ue)k(d)}}while(a<l&&(r.charCodeAt(a)===ke||r.charCodeAt(a)===Me))a++;if(a<l&&r.charCodeAt(a)===ie)a++}function qo(){a++;while(a<l&&je(r.charCodeAt(a)))a++;if(E("as")){a+=2;while(a<l&&je(r.charCodeAt(a)))a++;F();while(a<l&&je(r.charCodeAt(a)))a++}if(E("from")){a+=4;while(a<l&&je(r.charCodeAt(a)))a++;if(a<l){let d=r.charCodeAt(a);if(d===le||d===ue)k(d)}}while(a<l&&(r.charCodeAt(a)===ke||r.charCodeAt(a)===Me))a++;if(a<l&&r.charCodeAt(a)===ie)a++}function Ni(d){let p=d.indexOf("from ");if(p===-1)return;let h=p+5;while(h<d.length&&(d.charCodeAt(h)===32||d.charCodeAt(h)===9))h++;if(h>=d.length)return;let g=d.charCodeAt(h);if(g!==39&&g!==34)return;let b=d.indexOf(d[h],h+1);if(b===-1)return;return d.slice(h+1,b)}function Xe(d){if(!o)return;let p=d-1;while(p>=0&&je(r.charCodeAt(p)))p--;if(p<0)return;let h=[],g=!1;while(p>=0){if(p>=1&&r.charCodeAt(p)===Q&&r.charCodeAt(p-1)===Ae){let O=r.lastIndexOf("/*",p-2);if(O>=0){h.push(r.slice(O,p+1)),g=!0,p=O-1;while(p>=0&&je(r.charCodeAt(p)))p--;continue}break}let b=p;while(b>0&&r.charCodeAt(b-1)!==Ee)b--;let v=m(b,p+1);if(v.startsWith("//")){if(g)break;let O=[v];p=b-1;while(p>=0&&(r.charCodeAt(p)===Ee||r.charCodeAt(p)===Te))p--;while(p>=0){let R=p;while(R>0&&r.charCodeAt(R-1)!==Ee)R--;let S=m(R,p+1);if(S.startsWith("//")){O.push(S),p=R-1;while(p>=0&&(r.charCodeAt(p)===Ee||r.charCodeAt(p)===Te))p--}else if(S===""){p=R-1;while(p>=0&&(r.charCodeAt(p)===Ee||r.charCodeAt(p)===Te))p--}else break}O.reverse(),h.push(O.join(`
143
+ `));continue}break}if(h.length===0)return;return h.reverse(),h}function qc(d){let p=d,h=!1;while(a<l){let S=r.charCodeAt(a);if(S===ie){a++;break}if(S===le||S===ue){k(S),h=!0;while(a<l&&(r.charCodeAt(a)===ke||r.charCodeAt(a)===Me))a++;if(a<l&&r.charCodeAt(a)===ie)a++;break}if(S===Ee&&h)break;a++}let g=m(p,a),b=g.charCodeAt(7)===116&&(g.startsWith("import type ")||g.startsWith("import type{")),v=!1;{let S=6;while(S<g.length&&(g.charCodeAt(S)===ke||g.charCodeAt(S)===Me))S++;if(S<g.length&&g.charCodeAt(S)===116&&g.startsWith("type",S)){S+=4;while(S<g.length&&(g.charCodeAt(S)===ke||g.charCodeAt(S)===Me))S++}if(S<g.length){let x=g.charCodeAt(S);v=x===le||x===ue}}let O="";{let S=g.indexOf("from ");if(S!==-1){let x=S+5;while(x<g.length&&(g.charCodeAt(x)===ke||g.charCodeAt(x)===Me))x++;if(x<g.length){let P=g.charCodeAt(x);if(P===le||P===ue){let j=g.indexOf(String.fromCharCode(P),x+1);if(j!==-1)O=g.slice(x+1,j)}}}else if(v){let x=6;while(x<g.length&&g.charCodeAt(x)!==le&&g.charCodeAt(x)!==ue)x++;if(x<g.length){let P=g.charCodeAt(x),j=g.indexOf(String.fromCharCode(P),x+1);if(j!==-1)O=g.slice(x+1,j)}}}let R=Xe(p);return{kind:"import",name:"",text:g,isExported:!1,isTypeOnly:b,isSideEffect:v,source:O,leadingComments:R,start:p,end:a}}function Yr(){let d=a;return Z(H,X),r.slice(d,a)}function Yo(d){let p=d.indexOf("(");if(p===-1)return d;let h=d.slice(p);if(h.indexOf("=")===-1)return d;let g=!1;for(let S=0;S<h.length;S++)if(h.charCodeAt(S)===61){let x=S>0?h.charCodeAt(S-1):0,P=S+1<h.length?h.charCodeAt(S+1):0;if(x!==61&&x!==33&&x!==60&&x!==62&&P!==61&&P!==62){g=!0;break}}if(!g)return d;let b=0,v=-1;for(let S=p;S<d.length;S++){let x=d.charCodeAt(S);if(x===40)b++;else if(x===41){if(b--,b===0){v=S;break}}}if(v===-1)return d;let O=d.slice(p,v+1),R=Gt(O);return d.slice(0,p)+R+d.slice(v+1)}function Zo(d){let p=d.indexOf("//")!==-1||d.indexOf("/*")!==-1,h=d.split(`
144
+ `),g=[],b=[],v=[],O=!1,R=1/0;for(let P=0;P<h.length;P++){let j=h[P];if(p){if(O){if(j.includes("*/"))O=!1;continue}let G=j.trim();if(G.length===0)continue;let I=G.charCodeAt(0);if(I===Q){let He=G.charCodeAt(1);if(He===Q)continue;if(He===Ae){if(!G.includes("*/"))O=!0;continue}}if(I===Ae)continue;let M=A(j);if(M.charCodeAt(M.length-1)===ie)M=M.slice(0,-1);M=Yo(M);let _=M.trim();if(!_)continue;g.push(M),b.push(_);let V=0;while(V<M.length&&je(M.charCodeAt(V)))V++;if(_!=="{"&&_!=="}"){if(V<R)R=V}v.push(V)}else{let G=j.length;while(G>0&&(j.charCodeAt(G-1)===ke||j.charCodeAt(G-1)===Me||j.charCodeAt(G-1)===Te))G--;if(G===0)continue;let I=G<j.length?j.slice(0,G):j;if(I.charCodeAt(I.length-1)===ie)I=I.slice(0,-1);I=Yo(I);let M=I.trim();if(!M)continue;g.push(I),b.push(M);let _=0;while(_<I.length&&je(I.charCodeAt(_)))_++;if(M!=="{"&&M!=="}"){if(_<R)R=_}v.push(_)}}if(g.length===0)return"{}";if(R===1/0||R<=2)return g.join(`
145
+ `);let S=R-2,x=Array(g.length);for(let P=0;P<g.length;P++){let j=b[P];if(j==="{"){x[P]=j;continue}let G=v[P];if(G>R)x[P]=g[P];else if(G===R&&(j.charCodeAt(0)===X||j.charCodeAt(0)===Pe||j.charCodeAt(0)===$e))x[P]=g[P];else{let I=Math.max(0,G-S);x[P]=" ".repeat(I)+j}}return x.join(`
146
+ `)}function ht(){if(a>=l||r.charCodeAt(a)!==be)return"";let d=a;Z(be,me);let p=r.slice(d,a);if(p.includes(`
147
+ `)){let h="",g=!1;for(let b=0;b<p.length;b++){let v=p.charCodeAt(b);if(v===32||v===9||v===10||v===13){if(!g&&h.length>0)h+=" ",g=!0}else h+=p[b],g=!1}if(h.charCodeAt(1)===32)h=`<${h.slice(2)}`;if(h.charCodeAt(h.length-2)===32)h=`${h.slice(0,-2)}>`;return h}return p}function xt(){if(a>=l||r.charCodeAt(a)!==ae)return"()";let d=a;return Z(ae,$e),r.slice(d,a)}function Fi(d){if(d.indexOf("/")===-1)return d;let p="",h=!1,g=0;for(let b=0;b<d.length;b++){let v=d.charCodeAt(b);if(h){if(p+=d[b],v===it&&b+1<d.length){p+=d[++b];continue}if(v===g)h=!1;continue}if(v===le||v===ue||v===Ne){h=!0,g=v,p+=d[b];continue}if(v===Q&&b+1<d.length){let O=d.charCodeAt(b+1);if(O===Ae){let R=d.indexOf("*/",b+2);b=R===-1?d.length:R+1,p+=" ";continue}if(O===Q){let R=d.indexOf(`
148
+ `,b+2);b=R===-1?d.length:R-1;continue}}p+=d[b]}return p.trim()}function Gt(d){let p=d.slice(1,-1).trim();if(!p)return"()";if(d.indexOf(`
149
+ `)===-1&&p.indexOf(":")!==-1&&p.indexOf("{")===-1&&p.indexOf("[")===-1&&p.indexOf("=")===-1&&p.indexOf("@")===-1&&p.indexOf("...")===-1){let S=0,x=0,P=0;for(let j=0;j<p.length;j++){let G=p.charCodeAt(j);if(G===ae||G===be||G===H)P++;else if(G===$e||G===me||G===X)P--;else if(P===0){if(G===lt)S++;else if(G===ut)x++}}if(S>=x+1){let j=!1;for(let G=0;G<Wo.length;G++){let I=Wo[G],M=p.indexOf(I);if(M!==-1){let _=M+I.length;if((M===0||!_e(p.charCodeAt(M-1)))&&(_>=p.length||!_e(p.charCodeAt(_)))){j=!0;break}}}if(!j)return d}}let h=[],g=0,b=0,v=!1,O=0;for(let S=0;S<=p.length;S++){if(S===p.length){h.push(Fi(p.slice(g).trim()));break}let x=p.charCodeAt(S);if(v){if(x===it){S++;continue}if(x===O)v=!1;continue}if(x===Q&&S+1<p.length){let P=p.charCodeAt(S+1);if(P===Ae){S+=2;while(S+1<p.length&&!(p.charCodeAt(S)===Ae&&p.charCodeAt(S+1)===Q))S++;S++;continue}if(P===Q){while(S<p.length&&p.charCodeAt(S)!==10)S++;continue}}if(x===le||x===ue||x===Ne){v=!0,O=x;continue}if(x===ae||x===H||x===xe||x===be)b++;else if(x===$e||x===X||x===Pe||x===me&&!(S>0&&p.charCodeAt(S-1)===ve))b--;else if(x===ut&&b===0)h.push(Fi(p.slice(g,S).trim())),g=S+1}let R=[];for(let S of h){if(!S)continue;let x=S.trim();if(x.startsWith("//")||x.startsWith("/*"))continue;let P=S;{let j=!1,G=0,I=0,M=0;for(let _=0;_<P.length-1;_++){let V=P.charCodeAt(_);if(V===Ee){M=_+1;continue}if(j){if(V===it){_++;continue}if(V===G)j=!1;continue}if(V===le||V===ue||V===Ne){j=!0,G=V;continue}if(V===H||V===xe||V===ae||V===be){I++;continue}if(V===X||V===Pe||V===$e||V===me){if(I>0)I--;continue}if(V===Q&&P.charCodeAt(_+1)===Q){if(I===0){P=P.slice(0,_).trimEnd();break}let He=P.indexOf(`
150
+ `,_);if(He===-1){P=P.slice(0,M).trimEnd();break}let ze=P.slice(0,M),Vt=P.slice(He+1);P=`${ze}${Vt}`,_=M-1}}}if(!P.trim())continue;R.push(Xo(P))}return`(${R.join(", ")})`}function Yc(d){if(!d.startsWith("{")&&!d.startsWith("["))return d;let p="",h=0,g=0,b=!1,v=0;while(h<d.length){let O=d.charCodeAt(h);if(b){if(O===it&&h+1<d.length){p+=d[h]+d[h+1],h+=2;continue}if(O===v)b=!1;p+=d[h],h++;continue}if(O===Q&&h+1<d.length){let R=d.charCodeAt(h+1);if(R===Ae){let S=h;h+=2;while(h+1<d.length&&!(d.charCodeAt(h)===Ae&&d.charCodeAt(h+1)===Q))h++;h=Math.min(h+2,d.length),p+=d.slice(S,h);continue}if(R===Q){let S=h;while(h<d.length&&d.charCodeAt(h)!==10)h++;p+=d.slice(S,h);continue}}if(O===le||O===ue||O===Ne){b=!0,v=O,p+=d[h],h++;continue}if(O===H||O===xe||O===ae)g++;else if(O===X||O===Pe||O===$e)g--;if(g>=1&&O===ve&&(h+1>=d.length||d.charCodeAt(h+1)!==ve&&d.charCodeAt(h+1)!==me)){while(p.length>0&&(p[p.length-1]===" "||p[p.length-1]==="\t"||p[p.length-1]===`
151
+ `))p=p.slice(0,-1);h++;let R=0;while(h<d.length){let S=d.charCodeAt(h);if(S===le||S===ue||S===Ne){let x=S;h++;while(h<d.length){if(d.charCodeAt(h)===it){h+=2;continue}if(d.charCodeAt(h)===x){h++;break}h++}continue}if(S===H||S===xe||S===ae)R++;else if(S===X||S===Pe||S===$e){if(R===0)break;R--}else if(S===ut&&R===0)break;h++}continue}if(g===1&&O===pt&&h+2<d.length&&d.charCodeAt(h+1)===pt&&d.charCodeAt(h+2)===pt){h+=3;continue}p+=d[h],h++}return p}function Xo(d){let p=d.trim(),h=p.startsWith("...");if(h)p=p.slice(3).trim();while(p.startsWith("@")){let M=1;while(M<p.length&&_e(p.charCodeAt(M)))M++;if(M<p.length&&p.charCodeAt(M)===ae){let _=1;M++;while(M<p.length&&_>0){if(p.charCodeAt(M)===ae)_++;else if(p.charCodeAt(M)===$e)_--;M++}}p=p.slice(M).trim()}let g=!0;while(g){g=!1;for(let M of Wo)if(p.startsWith(M)&&p.length>M.length&&!_e(p.charCodeAt(M.length))){let _=p.slice(M.length).trim();if(_.charCodeAt(0)===lt||_.charCodeAt(0)===jr&&_.length>1&&_.charCodeAt(1)===lt)break;p=_,g=!0;break}}let b=-1,v=-1,O=0,R=!1,S=0;for(let M=0;M<p.length;M++){let _=p.charCodeAt(M);if(R){if(_===it){M++;continue}if(_===S)R=!1;continue}if(_===Q&&M+1<p.length){let V=p.charCodeAt(M+1);if(V===Ae){M+=2;while(M+1<p.length&&!(p.charCodeAt(M)===Ae&&p.charCodeAt(M+1)===Q))M++;M++;continue}if(V===Q){while(M<p.length&&p.charCodeAt(M)!==10)M++;continue}}if(_===le||_===ue||_===Ne){R=!0,S=_;continue}if(_===ae||_===H||_===xe||_===be)O++;else if(_===$e||_===X||_===Pe||_===me&&!(M>0&&p.charCodeAt(M-1)===ve))O--;else if(O===0){if(_===lt&&b===-1)b=M;else if(_===ve&&v===-1&&(M===0||p.charCodeAt(M-1)!==ve)&&(M+1>=p.length||p.charCodeAt(M+1)!==ve&&p.charCodeAt(M+1)!==me))v=M}}let x,P,j=v!==-1;if(b!==-1&&(v===-1||b<v))if(x=p.slice(0,b).trim(),v!==-1)P=p.slice(b+1,v).trim();else P=p.slice(b+1).trim();else if(v!==-1)x=p.slice(0,v).trim(),P=Zr(p.slice(v+1).trim());else x=p,P="unknown";if(x=Yc(x),(x.startsWith("{")||x.startsWith("["))&&x.includes(`
152
+ `)){let M=x.replace(/\s*\n\s*/g," ").replace(/\s+/g," ");if(M.length<=40)x=M;else x=x.split(`
153
+ `).map((_)=>{let V=_.trim();if(!V)return"";if(V==="{"||V==="}"||V==="["||V==="]"||V.startsWith("}")||V.startsWith("]"))return V;return` ${V}`}).join(`
154
+ `)}let G=x.endsWith("?")||j;if(x.endsWith("?"))x=x.slice(0,-1).trim();let I=G&&!h?"?":"";if(h)return`...${x}: ${P}`;return`${x}${I}: ${P}`}function Qo(d){let p=0;if(p<d.length&&d.charCodeAt(p)===45)p++;if(p>=d.length)return!1;let h=d.charCodeAt(p);if(h<48||h>57)return!1;while(p<d.length&&d.charCodeAt(p)>=48&&d.charCodeAt(p)<=57)p++;if(p<d.length&&d.charCodeAt(p)===46){if(p++,p>=d.length||d.charCodeAt(p)<48||d.charCodeAt(p)>57)return!1;while(p<d.length&&d.charCodeAt(p)>=48&&d.charCodeAt(p)<=57)p++}return p===d.length}function Zr(d){let p=d.trim();if(p==="true"||p==="false")return"boolean";if(Qo(p))return"number";if(p.startsWith("'")&&p.endsWith("'")||p.startsWith('"')&&p.endsWith('"'))return"string";if(p.startsWith("["))return"unknown[]";if(p.startsWith("{"))return"Record<string, unknown>";return"unknown"}function Xr(d){let p=d.trim();if(p.endsWith("as const"))p=p.slice(0,-8).trim();if(p==="true"||p==="false")return p;if(Qo(p))return p;let h=Zc(p);if(h!==null)return h;return"unknown"}function Zc(d){if(d==="")return null;if(d.charCodeAt(0)===le||d.charCodeAt(0)===ue){if(_r(d,0,d.charCodeAt(0))===d.length)return d}let p=Xc(d,"+");if(p.length>1){let h=!1,g=!0,b=[];for(let v of p){let O=v.trim(),R=O.charCodeAt(0);if((R===le||R===ue)&&_r(O,0,R)===O.length)h=!0,b.push(Qc(O));else g=!1}if(g)return ef(b.join(""));if(h)return"string";return null}if(/^[\d\s()+*/%.\-]+$/.test(d)&&/\d/.test(d)&&/[+*/%\-\s]/.test(d))return"number";return null}function Xc(d,p){let h=[],g=0,b="",v=0;while(v<d.length){let O=d.charCodeAt(v);if(O===le||O===ue||O===Ne){let R=_r(d,v,O);b+=d.slice(v,R),v=R;continue}if(O===Q&&(d.charCodeAt(v+1)===Q||d.charCodeAt(v+1)===42)){if(d.charCodeAt(v+1)===Q){let x=d.indexOf(`
155
+ `,v+2),P=x===-1?d.length:x;b+=d.slice(v,P),v=P;continue}let R=d.indexOf("*/",v+2),S=R===-1?d.length:R+2;b+=d.slice(v,S),v=S;continue}if(O===ae||O===xe||O===H)g++;else if(O===$e||O===Pe||O===X)g--;if(d[v]===p&&g===0){h.push(b),b="",v++;continue}b+=d[v],v++}return h.push(b),h}function Qc(d){return d.slice(1,-1).replace(/\\(.)/g,(p,h)=>{if(h==="n")return`
156
+ `;if(h==="t")return"\t";if(h==="r")return"\r";if(h==="0")return"\x00";return h})}function ef(d){return`'${d.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function Li(d){if(d.endsWith("as const"))return null;let p=0,h=-1;for(let g=0;g<d.length;g++){let b=d.charCodeAt(g);if(b===le||b===ue||b===Ne)g=_r(d,g,b)-1;else if(b===123||b===91||b===40)p++;else if(b===125||b===93||b===41)p--;else if(p===0&&b===32&&g+4<=d.length&&d.substring(g,g+4)===" as ")h=g}if(h===-1)return null;return d.slice(h+4).trim()||null}function hi(){if(C(),a<l&&r.charCodeAt(a)===lt){a++,C();let d=a,p=0;while(a<l){if(T())continue;let h=r.charCodeAt(a);if(h===ae||h===xe||h===be)p++;else if(h===$e||h===Pe||h===me&&!J())p--;else if(h===H)if(p>0)p++;else{let g=m(d,a),b=(v)=>{let O=g.length-v.length;return O>=0&&g.endsWith(v)&&(O===0||!_e(g.charCodeAt(O-1)))};if(g.length===0||g.endsWith("|")||g.endsWith("&")||b("is")||b("extends"))p++;else break}else if(h===X){if(p===0)break;p--}else if(p===0&&h===ie)break;if(p===0&&ce())break;a++}return m(d,a)}return""}function At(d,p,h,g){a+=8,C();let b=a<l&&r.charCodeAt(a)===Ae;if(b)a++,C();let v=F();if(!v&&!g)return null;C();let O=ht();C();let R=xt();C();let S=hi(),x=S.length>0;if(!S)if(h&&b)S="AsyncGenerator<unknown, void, unknown>";else if(b)S="Generator<unknown, void, unknown>";else if(h)S="Promise<void>";else S="void";C();let P=!1;if(a<l&&r.charCodeAt(a)===H){P=!0;let M=a+1;if(Z(H,X),!x&&!b)S=fi(r.slice(M,a-1),h,R)}else if(a<l&&r.charCodeAt(a)===ie)a++;let j=Gt(R),G=`${p?g?"export default function ":"export declare function ":"declare function "}${v||(g?"":"default")}${O}${j}: ${S};`,I=Xe(d);if(P)u.add(c.length);return{kind:"function",name:v||"default",text:G,isExported:p,isDefault:g,isAsync:h,isGenerator:b,returnType:S,generics:O||void 0,leadingComments:I,start:d,end:a}}function It(d,p,h){a+=p.length,C();let g=[];do{if(C(),a>=l)break;let b=r.charCodeAt(a);if(b===H||b===xe)return ne(),g;let v=F();if(!v)return ne(),g;C();let O,R,S=!1;if(a<l&&r.charCodeAt(a)===lt){a++,C();let j=a,G=0;while(a<l){if(T()){if(G===0&&oe())break;continue}let I=r.charCodeAt(a);if(I===ae||I===H||I===xe||I===be)G++;else if(I===$e||I===X||I===Pe||I===me&&!J())G--;else if(G===0&&(I===ie||I===ut))break;else if(G===0&&I===ve&&!te())break;if(G===0&&(z()||re()))break;a++}O=m(j,a)}if(a<l&&r.charCodeAt(a)===ve)if(s&&O&&(!o||!Kd(O)))qr();else{a++,C();let j=a,G=0,I=0,M=0,_=!0;for(;;){a=j,G=0,I=0,M=0;while(a<l){if(T()){if(G===0&&I===0&&M===0&&oe())break;continue}let V=r.charCodeAt(a);if(V===ae||V===H||V===xe)G++;else if(V===$e||V===X||V===Pe)G--;else if(V===be&&G===0){let He=es(a);if(He!==null)M=Math.max(0,M+He);else if(_&&(a+1>=l||r.charCodeAt(a+1)!==ve))I++}else if(V===me&&G===0&&M===0&&!J()){if(I>0&&(a+1>=l||r.charCodeAt(a+1)!==ve))I--}else if(G===0&&I===0&&M===0&&(V===ie||V===ut))break;if(G===0&&I===0&&M===0&&(z()||De()))break;a++}if(I>0&&_){_=!1;continue}break}if(R=m(j,a),R.endsWith(" as const")||R==="const"){if(S=!0,!O){let V=R.endsWith(" as const")?R.slice(0,-9).trim():R,He=Xr(V);O=He!=="unknown"?He:void 0}}else if(!O){let V=Gr(R)??Li(R);if(V)O=V}}if(a<l){let j=r.charCodeAt(a);if(j===ut){a++;continue}if(j===ie)a++}let x=Xe(d),P=`${h?"export ":""}declare ${p} ${v}: ${O||"unknown"};`;g.push({kind:"variable",name:v,text:P,isExported:h,typeAnnotation:O,value:R,modifiers:S?[p,"const assertion"]:[p],leadingComments:x,start:d,end:a});break}while(a<l);return g}function es(d){if(r.charCodeAt(d)!==be||d+1>=l)return null;let p=r.charCodeAt(d+1);if(p===me)return 1;if(p===Q)return-1;if(!mt(p))return null;let h=d+2;while(h<l){let x=r.charCodeAt(h);if(!_e(x)&&x!==pt&&x!==58&&x!==45)break;h++}let g=r.slice(d+1,h),b=r.charCodeAt(h);if(b>32&&b!==me&&b!==Q)return null;let v=0,O=0,R=h;for(;R<l;R++){let x=r.charCodeAt(R);if(O!==0){if(x===it)R++;else if(x===O)O=0;continue}if(x===le||x===ue||x===Ne)O=x;else if(x===H)v++;else if(x===X&&v>0)v--;else if(x===me&&v===0)break}if(R>=l)return null;let S=R-1;while(S>d&&r.charCodeAt(S)<=32)S--;if(r.charCodeAt(S)===Q)return 0;return r.indexOf(`</${g}`,R+1)===-1?null:1}function Qr(d,p){a+=9,C();let h=F();C();let g=ht();C();let b="";if(E("extends")){a+=7,C();let x=a,P=0;while(a<l){if(T())continue;let j=r.charCodeAt(a);if(j===be)P++;else if(j===me&&!J())P--;else if(j===H&&P===0)break;a++}b=m(x,a)}C();let v=a<l&&r.charCodeAt(a)===H?Yr():"{}",O=Zo(v),R=`${p?"export ":""}declare interface ${h}${g}${b?` extends ${b}`:""} ${O}`,S=Xe(d);return{kind:"interface",name:h,text:R,isExported:p,extends:b||void 0,generics:g||void 0,leadingComments:S,start:d,end:a}}function en(d,p){a+=4,C();let h=F();C();let g=ht();if(C(),a<l&&r.charCodeAt(a)===ve)a++;C();let b=a,v=0;while(a<l){if(T())continue;let x=r.charCodeAt(a);if(x===ae||x===H||x===xe||x===be)v++;else if(x===$e||x===X||x===Pe||x===me&&!J())v--;else if(v===0&&x===ie)break;if(v===0&&(z()||re()))break;a++}let O=m(b,a);if(a<l&&r.charCodeAt(a)===ie)a++;let R=`${p?"export ":""}type ${h}${g} = ${O}`,S=Xe(d);return{kind:"type",name:h,text:R,isExported:p,generics:g||void 0,leadingComments:S,start:d,end:a}}function jt(d,p,h){a+=4,C();let g=F();C();let b=a;if(a<l&&r.charCodeAt(a)===H)Z(H,X);let v=m(d,a),O=Xe(d);return{kind:"enum",name:g,text:v,isExported:p,modifiers:h?["const"]:void 0,leadingComments:O,start:d,end:a}}function Tt(d,p,h,g=!1){a+=5,C();let b=F()||"AnonymousClass";C();let v=ht();C();let O="";if(E("extends")){a+=7,C();let j=a,G=0;while(a<l){if(T())continue;let I=r.charCodeAt(a);if(I===be)G++;else if(I===me&&!J())G--;else if(G===0&&(I===H||E("implements")))break;a++}O=m(j,a)}let R;if(E("implements")){a+=10,C();let j=a,G=0;while(a<l){if(T())continue;let M=r.charCodeAt(a);if(M===be)G++;else if(M===me&&!J())G--;else if(G===0&&M===H)break;a++}let I=m(j,a);if(I)R=I.split(",").map((M)=>M.trim())}C();let S=tn(),x=`${p?g?"export default ":"export declare ":"declare "}${h?"abstract ":""}class ${b}${v}${O?` extends ${O}`:""}${R&&R.length>0?` implements ${R.join(", ")}`:""} ${S}`,P=Xe(d);return{kind:"class",name:b,text:x,isExported:p,isDefault:g,extends:O||void 0,implements:R,generics:v||void 0,modifiers:h?["abstract"]:void 0,leadingComments:P,start:d,end:a}}function tn(){if(a>=l||r.charCodeAt(a)!==H)return"{}";a++;let d=[];while(a<l){if(C(),a>=l)break;if(r.charCodeAt(a)===X){a++;break}if(r.charCodeAt(a)===ie){a++;continue}if(E("static")&&nn("static")===H){a+=6,C(),Z(H,X);continue}let p=!1,h=!1,g=!1,b=!1,v=!1,O=!1,R=!1,S=!1,x=!0;while(x){C();let G=a,I=F();if(a=G,I){let M=nn(I);if(M===ae||M===be||M===jr||M===33||M===lt||M===ve||M===ie||M===X)break}if(E("private")){p=!0,a+=7;continue}if(E("protected")){h=!0,a+=9;continue}if(E("public")){a+=6;continue}if(E("static")){g=!0,a+=6;continue}if(E("abstract")){b=!0,a+=8;continue}if(E("readonly")){v=!0,a+=8;continue}if(E("override")){O=!0,a+=8;continue}if(E("accessor")){R=!0,a+=8;continue}if(E("async")){S=!0,a+=5;continue}if(E("declare")){a+=7;continue}break}if(C(),a>=l||r.charCodeAt(a)===X)break;if(r.charCodeAt(a)===Lo)p=!0;let P=p?[]:d,j=" ";if(h)j+="protected ";if(g)j+="static ";if(b)j+="abstract ";if(v)j+="readonly ";if(E("constructor")){a+=11,C();let G=xt();if(C(),rf(G,P),a<l&&r.charCodeAt(a)===H)Z(H,X);else if(a<l&&r.charCodeAt(a)===ie)a++;let I=Gt(G);P.push(` constructor${I};`)}else if(E("get"))if(a+=3,C(),a<l&&ts(r.charCodeAt(a))){let G=rn();if(G.startsWith("#")){if(C(),a<l&&r.charCodeAt(a)===ae)xt();if(C(),hi(),C(),a<l&&r.charCodeAt(a)===H)Z(H,X);else if(a<l&&r.charCodeAt(a)===ie)a++;continue}C(),xt(),C();let I=hi()||"unknown";if(C(),a<l&&r.charCodeAt(a)===H)Z(H,X);else if(a<l&&r.charCodeAt(a)===ie)a++;P.push(`${j}get ${G}(): ${I};`)}else rs("get",j,g,v,S,P);else if(E("set"))if(a+=3,C(),a<l&&ts(r.charCodeAt(a))){let G=rn();if(G.startsWith("#")){if(C(),a<l&&r.charCodeAt(a)===ae)xt();if(C(),a<l&&r.charCodeAt(a)===H)Z(H,X);else if(a<l&&r.charCodeAt(a)===ie)a++;continue}C();let I=xt();if(C(),a<l&&r.charCodeAt(a)===H)Z(H,X);else if(a<l&&r.charCodeAt(a)===ie)a++;let M=Gt(I);P.push(`${j}set ${G}${M};`)}else rs("set",j,g,v,S,P);else{let G=r.charCodeAt(a)===Ae;if(G)a++,C();let I=rn();if(!I){is();continue}ns(I,j,g,v,G,b,S,P)}}return`{
157
157
  ${d.join(`
158
158
  `)}
159
- }`}function rn(){if(l>=a)return"";let d=r.charCodeAt(l);if(d===be){let p=l;return Z(be,Pe),r.slice(p,l)}if(d===jr)return l++,`#${N()}`;return N()}function ts(d){let p=l+d.length;while(p<a&&Be(r.charCodeAt(p)))p++;return p<a?r.charCodeAt(p):0}function nn(){let d=0;while(l<a){if(T())continue;let p=r.charCodeAt(l);if(p===H||p===ae)d++;else if(p===X||p===$e){if(d===0)return;d--}else if(p===ne&&d===0){l++;return}if(d===0&&le())return;l++}}function is(d,p,h,g,E,b){rs(d,p,h,g,!1,!1,E,b)}function rs(d,p,h,g,E,b,O,R){if(C(),l>=a)return;let S=r.charCodeAt(l),A=!1;if(S===Lo)A=!0,l++,C();if(l<a&&r.charCodeAt(l)===33)l++,C();let P=l<a?r.charCodeAt(l):0;if(P===ae||P===ve){let B=P===ve?ht():"";C();let _=At();C();let G=hi(),M=G.length>0;if(!G)if(O&&E)G="AsyncGenerator<unknown, void, unknown>";else if(E)G="Generator<unknown, void, unknown>";else if(O)G="Promise<void>";else G="void";if(C(),l<a&&r.charCodeAt(l)===H){let He=l+1;if(Z(H,X),!M&&!E)G=fi(r.slice(He,l-1),O,_)}else if(l<a&&r.charCodeAt(l)===ne)l++;let j=Gt(_),V=A?"?":"";R.push(`${p}${d}${V}${B}${j}: ${G};`)}else if(P===ft||P===Ae||P===ne||P===X||P===Ee||P===Te){let B="";if(P===ft){l++,C();let M=l,j=0;while(l<a){if(T())continue;let V=r.charCodeAt(l);if(V===ae||V===H||V===be||V===ve)j++;else if(V===$e||V===X||V===Pe||V===pe&&!J()){if(j===0)break;j--}else if(j===0&&(V===ne||V===ut))break;else if(j===0&&V===Ae&&!te())break;if(j===0&&le())break;l++}B=m(M,l)}let _="";if(l<a&&r.charCodeAt(l)===Ae)if(s&&B){l++;let M=0;while(l<a){if(T())continue;let j=r.charCodeAt(l);if(j===ae||j===H||j===be)M++;else if(j===$e||j===X||j===Pe){if(M===0&&j===X)break;M--}else if(M===0&&j===ne)break;if(M===0&&le())break;l++}}else{l++,C();let M=l,j=0;while(l<a){if(T())continue;let V=r.charCodeAt(l);if(V===ae||V===H||V===be)j++;else if(V===$e||V===X||V===Pe){if(j===0&&V===X)break;j--}else if(j===0&&V===ne)break;if(j===0&&le())break;l++}_=m(M,l)}if(l<a&&r.charCodeAt(l)===ne)l++;if(!B)if(_){let M=Li(_);if(M)B=M;else B=_.endsWith("as const")||h&&g?Xr(_):Zr(_)}else B="unknown";let G=A?"?":"";R.push(`${p}${d}${G}: ${B};`)}else nn()}function ef(d){let p=0;for(let h=0;h<d.length;h++){let g=d.charCodeAt(h);if(g===ae||g===H||g===be||g===ve)p++;else if(g===$e||g===X||g===Pe||g===pe&&d.charCodeAt(h-1)!==Ae)p--;else if(g===Ae&&p===0&&d.charCodeAt(h+1)!==pe&&d.charCodeAt(h+1)!==Ae)return!0}return!1}function tf(d,p){let h=d.slice(1,-1).trim();if(!h)return;let g=[],E=0,b=0,O=!1,R=0;for(let S=0;S<=h.length;S++){if(S===h.length){g.push(Fi(h.slice(E).trim()));break}let A=h.charCodeAt(S);if(O){if(A===it){S++;continue}if(A===R)O=!1;continue}if(A===Q&&S+1<h.length){let P=h.charCodeAt(S+1);if(P===xe){S+=2;while(S+1<h.length&&!(h.charCodeAt(S)===xe&&h.charCodeAt(S+1)===Q))S++;S++;continue}if(P===Q){while(S<h.length&&h.charCodeAt(S)!==10)S++;continue}}if(A===de||A===me||A===Ne){O=!0,R=A;continue}if(A===ae||A===H||A===be||A===ve)b++;else if(A===$e||A===X||A===Pe||A===pe&&!(S>0&&h.charCodeAt(S-1)===Ae))b--;else if(A===ut&&b===0)g.push(Fi(h.slice(E,S).trim())),E=S+1}for(let S of g){let A=S.startsWith("public ")||S.startsWith("public\t"),P=S.startsWith("protected ")||S.startsWith("protected\t"),B=S.startsWith("private ")||S.startsWith("private\t"),_=S.includes("readonly ");if(!A&&!P&&!B&&!_)continue;if(B)continue;let G=S,M=[];if(A){let ze=6;while(ze<G.length&&Be(G.charCodeAt(ze)))ze++;G=G.slice(ze),M.push("public")}if(P){let ze=9;while(ze<G.length&&Be(G.charCodeAt(ze)))ze++;G=G.slice(ze),M.push("protected")}if(_){let ze=G.indexOf("readonly ");if(ze!==-1){let Vt=ze+8;while(Vt<G.length&&Be(G.charCodeAt(Vt)))Vt++;G=G.slice(0,ze)+G.slice(Vt)}M.push("readonly")}let j=M.length>0?`${M.join(" ")} `:"",V=Xo(G),He=G.search(/[?:=]/);if(He!==-1&&G.charCodeAt(He)!==63&&ef(G))V=V.replace(/^([\w$]+)\?:/,"$1:");p.push(` ${j}${V};`)}}function on(d=" "){if(l>=a||r.charCodeAt(l)!==H)return"{}";l++;let p=[];while(l<a){if(C(),l>=a)break;if(r.charCodeAt(l)===X){l++;break}if(r.charCodeAt(l)===ne){l++;continue}let h=!1;if(v("export"))h=!0,l+=6,C();if(v("declare"))l+=7,C();let g=h?"export ":"";if(v("function")||v("async")&&rf("async","function")){let E=!1;if(v("async"))E=!0,l+=5,C();if(l+=8,C(),l<a&&r.charCodeAt(l)===xe)l++,C();let b=N();C();let O=ht();C();let R=At();C();let S=hi();if(!S)S=E?"Promise<void>":"void";if(C(),l<a&&r.charCodeAt(l)===H)Z(H,X);else if(l<a&&r.charCodeAt(l)===ne)l++;let A=Gt(R);p.push(`${d}${g}function ${b}${O}${A}: ${S};`)}else if(v("const")||v("let")||v("var")){let E=v("const")?"const":v("let")?"let":"var";l+=E.length,C();let b=N();if(!b){re(!0);continue}C();let O="";if(l<a&&r.charCodeAt(l)===ft){l++,C();let S=l,A=0;while(l<a){if(T())continue;let P=r.charCodeAt(l);if(P===ae||P===H||P===be||P===ve)A++;else if(P===X&&A===0)break;else if(P===$e||P===X||P===Pe||P===pe&&!J())A--;else if(A===0&&(P===ne||P===ut))break;else if(A===0&&P===Ae&&!te())break;if(A===0&&z())break;l++}O=m(S,l)}let R="";if(l<a&&r.charCodeAt(l)===Ae){l++,C();let S=l,A=0;while(l<a){if(T())continue;let P=r.charCodeAt(l);if(P===ae||P===H||P===be||P===ve)A++;else if(P===X&&A===0)break;else if(P===$e||P===X||P===Pe||P===pe&&!J())A--;else if(A===0&&(P===ne||P===ut))break;if(A===0&&z())break;l++}R=m(S,l)}if(l<a&&r.charCodeAt(l)===ne)l++;if(!O&&R){let S=Li(R);if(S)O=S;else if(E==="const")O=Xr(R);else O=Zr(R)}if(!O)O="unknown";p.push(`${d}${g}${E} ${b}: ${O};`)}else if(v("interface")){l+=9,C();let E=N();C();let b=ht();C();let O="";if(v("extends")){l+=7,C();let S=l,A=0;while(l<a){if(T())continue;let P=r.charCodeAt(l);if(P===ve)A++;else if(P===pe&&!J())A--;else if(P===H&&A===0)break;l++}O=m(S,l)}let R=Zo(Yr());p.push(`${d}${g}interface ${E}${b}${O?` extends ${O}`:""} ${R}`)}else if(v("type")){l+=4,C();let E=N();C();let b=ht();if(C(),l<a&&r.charCodeAt(l)===Ae){l++,C();let O=l,R=0;while(l<a){if(T())continue;let A=r.charCodeAt(l);if(A===ae||A===H||A===be||A===ve)R++;else if(A===X&&R===0)break;else if(A===$e||A===X||A===Pe||A===pe&&!J())R--;else if(R===0&&A===ne)break;if(R===0&&z())break;l++}let S=m(O,l);if(l<a&&r.charCodeAt(l)===ne)l++;p.push(`${d}${g}type ${E}${b} = ${S}`)}}else if(v("class")){l+=5,C();let E=N();C();let b=ht();C();let O=l,R=0;while(l<a){if(T())continue;let B=r.charCodeAt(l);if(B===ve)R++;else if(B===pe&&!J())R--;else if(B===H&&R===0)break;l++}let S=m(O,l),A=S?` ${S}`:"",P=tn();p.push(`${d}${g}class ${E}${b}${A} ${P}`)}else if(v("enum")){l+=4,C();let E=N();C();let b=Yr();p.push(`${d}${g}enum ${E} ${b}`)}else if(v("namespace")||v("module")){let E=v("namespace")?"namespace":"module";l+=E.length,C();let b=N();C();let O=on(d);p.push(`${d}${g}${E} ${b} ${O}`)}else if(v("abstract"))if(l+=8,C(),v("class")){l+=5,C();let E=N();C();let b=ht();C();let O=l,R=0;while(l<a){if(T())continue;let B=r.charCodeAt(l);if(B===ve)R++;else if(B===pe&&!J())R--;else if(B===H&&R===0)break;l++}let S=m(O,l),A=S?` ${S}`:"",P=tn();p.push(`${d}${g}abstract class ${E}${b}${A} ${P}`)}else re(!0);else if(h&&v("default")){l+=7,C();let E=l;re(!0);let b=m(E,l);if(b.charCodeAt(b.length-1)===ne)b=b.slice(0,-1);if(b)p.push(`${d}export default ${b};`)}else if(!h&&(r.charCodeAt(l)===de||r.charCodeAt(l)===me||r.charCodeAt(l)===Ne))re(!0);else re(!0)}if(p.length===0)return"{}";return`{
159
+ }`}function ts(d){return mt(d)||d===xe||d===Lo||d===le||d===ue}function rn(){if(a>=l)return"";let d=r.charCodeAt(a);if(d===xe){let p=a;return Z(xe,Pe),r.slice(p,a)}if(d===Lo)return a++,`#${F()}`;if(d===le||d===ue){let p=a;return k(d),r.slice(p,a)}return F()}function nn(d){let p=a;a+=d.length,C();let h=a<l?r.charCodeAt(a):0;return a=p,h}function is(){let d=0;while(a<l){if(T())continue;let p=r.charCodeAt(a);if(p===H||p===ae)d++;else if(p===X||p===$e){if(d===0)return;d--}else if(p===ie&&d===0){a++;return}if(d===0&&ce())return;a++}}function rs(d,p,h,g,b,v){ns(d,p,h,g,!1,!1,b,v)}function ns(d,p,h,g,b,v,O,R){if(C(),a>=l)return;let S=r.charCodeAt(a),x=!1;if(S===jr)x=!0,a++,C();if(a<l&&r.charCodeAt(a)===33)a++,C();let P=a<l?r.charCodeAt(a):0;if(P===ae||P===be){let j=P===be?ht():"";C();let G=xt();C();let I=hi(),M=I.length>0;if(!I)if(O&&b)I="AsyncGenerator<unknown, void, unknown>";else if(b)I="Generator<unknown, void, unknown>";else if(O)I="Promise<void>";else I="void";if(C(),a<l&&r.charCodeAt(a)===H){let He=a+1;if(Z(H,X),!M&&!b)I=fi(r.slice(He,a-1),O,G)}else if(a<l&&r.charCodeAt(a)===ie)a++;let _=Gt(G),V=x?"?":"";R.push(`${p}${d}${V}${j}${_}: ${I};`)}else if(P===lt||P===ve||P===ie||P===X||P===Ee||P===Te){let j="";if(P===lt){a++,C();let M=a,_=0;while(a<l){if(T())continue;let V=r.charCodeAt(a);if(V===ae||V===H||V===xe||V===be)_++;else if(V===$e||V===X||V===Pe||V===me&&!J()){if(_===0)break;_--}else if(_===0&&(V===ie||V===ut))break;else if(_===0&&V===ve&&!te())break;if(_===0&&ce())break;a++}j=m(M,a)}let G="";if(a<l&&r.charCodeAt(a)===ve)if(s&&j){a++;let M=0;while(a<l){if(T())continue;let _=r.charCodeAt(a);if(_===ae||_===H||_===xe)M++;else if(_===$e||_===X||_===Pe){if(M===0&&_===X)break;M--}else if(M===0&&_===ie)break;if(M===0&&ce())break;a++}}else{a++,C();let M=a,_=0;while(a<l){if(T())continue;let V=r.charCodeAt(a);if(V===ae||V===H||V===xe)_++;else if(V===$e||V===X||V===Pe){if(_===0&&V===X)break;_--}else if(_===0&&V===ie)break;if(_===0&&ce())break;a++}G=m(M,a)}if(a<l&&r.charCodeAt(a)===ie)a++;if(!j)if(G){let M=Li(G);if(M)j=M;else j=G.endsWith("as const")||h&&g?Xr(G):Zr(G)}else j="unknown";let I=x?"?":"";R.push(`${p}${d}${I}: ${j};`)}else is()}function tf(d){let p=0;for(let h=0;h<d.length;h++){let g=d.charCodeAt(h);if(g===ae||g===H||g===xe||g===be)p++;else if(g===$e||g===X||g===Pe||g===me&&d.charCodeAt(h-1)!==ve)p--;else if(g===ve&&p===0&&d.charCodeAt(h+1)!==me&&d.charCodeAt(h+1)!==ve)return!0}return!1}function rf(d,p){let h=d.slice(1,-1).trim();if(!h)return;let g=[],b=0,v=0,O=!1,R=0;for(let S=0;S<=h.length;S++){if(S===h.length){g.push(Fi(h.slice(b).trim()));break}let x=h.charCodeAt(S);if(O){if(x===it){S++;continue}if(x===R)O=!1;continue}if(x===Q&&S+1<h.length){let P=h.charCodeAt(S+1);if(P===Ae){S+=2;while(S+1<h.length&&!(h.charCodeAt(S)===Ae&&h.charCodeAt(S+1)===Q))S++;S++;continue}if(P===Q){while(S<h.length&&h.charCodeAt(S)!==10)S++;continue}}if(x===le||x===ue||x===Ne){O=!0,R=x;continue}if(x===ae||x===H||x===xe||x===be)v++;else if(x===$e||x===X||x===Pe||x===me&&!(S>0&&h.charCodeAt(S-1)===ve))v--;else if(x===ut&&v===0)g.push(Fi(h.slice(b,S).trim())),b=S+1}for(let S of g){let x=S.startsWith("public ")||S.startsWith("public\t"),P=S.startsWith("protected ")||S.startsWith("protected\t"),j=S.startsWith("private ")||S.startsWith("private\t"),G=S.includes("readonly ");if(!x&&!P&&!j&&!G)continue;if(j)continue;let I=S,M=[];if(x){let ze=6;while(ze<I.length&&je(I.charCodeAt(ze)))ze++;I=I.slice(ze),M.push("public")}if(P){let ze=9;while(ze<I.length&&je(I.charCodeAt(ze)))ze++;I=I.slice(ze),M.push("protected")}if(G){let ze=I.indexOf("readonly ");if(ze!==-1){let Vt=ze+8;while(Vt<I.length&&je(I.charCodeAt(Vt)))Vt++;I=I.slice(0,ze)+I.slice(Vt)}M.push("readonly")}let _=M.length>0?`${M.join(" ")} `:"",V=Xo(I),He=I.search(/[?:=]/);if(He!==-1&&I.charCodeAt(He)!==63&&tf(I))V=V.replace(/^([\w$]+)\?:/,"$1:");p.push(` ${_}${V};`)}}function on(d=" "){if(a>=l||r.charCodeAt(a)!==H)return"{}";a++;let p=[];while(a<l){if(C(),a>=l)break;if(r.charCodeAt(a)===X){a++;break}if(r.charCodeAt(a)===ie){a++;continue}let h=!1;if(E("export"))h=!0,a+=6,C();if(E("declare"))a+=7,C();let g=h?"export ":"";if(E("function")||E("async")&&nf("async","function")){let b=!1;if(E("async"))b=!0,a+=5,C();if(a+=8,C(),a<l&&r.charCodeAt(a)===Ae)a++,C();let v=F();C();let O=ht();C();let R=xt();C();let S=hi();if(!S)S=b?"Promise<void>":"void";if(C(),a<l&&r.charCodeAt(a)===H)Z(H,X);else if(a<l&&r.charCodeAt(a)===ie)a++;let x=Gt(R);p.push(`${d}${g}function ${v}${O}${x}: ${S};`)}else if(E("const")||E("let")||E("var")){let b=E("const")?"const":E("let")?"let":"var";a+=b.length,C();let v=F();if(!v){ne(!0);continue}C();let O="";if(a<l&&r.charCodeAt(a)===lt){a++,C();let S=a,x=0;while(a<l){if(T())continue;let P=r.charCodeAt(a);if(P===ae||P===H||P===xe||P===be)x++;else if(P===X&&x===0)break;else if(P===$e||P===X||P===Pe||P===me&&!J())x--;else if(x===0&&(P===ie||P===ut))break;else if(x===0&&P===ve&&!te())break;if(x===0&&z())break;a++}O=m(S,a)}let R="";if(a<l&&r.charCodeAt(a)===ve){a++,C();let S=a,x=0;while(a<l){if(T())continue;let P=r.charCodeAt(a);if(P===ae||P===H||P===xe||P===be)x++;else if(P===X&&x===0)break;else if(P===$e||P===X||P===Pe||P===me&&!J())x--;else if(x===0&&(P===ie||P===ut))break;if(x===0&&z())break;a++}R=m(S,a)}if(a<l&&r.charCodeAt(a)===ie)a++;if(!O&&R){let S=Li(R);if(S)O=S;else if(b==="const")O=Xr(R);else O=Zr(R)}if(!O)O="unknown";p.push(`${d}${g}${b} ${v}: ${O};`)}else if(E("interface")){a+=9,C();let b=F();C();let v=ht();C();let O="";if(E("extends")){a+=7,C();let S=a,x=0;while(a<l){if(T())continue;let P=r.charCodeAt(a);if(P===be)x++;else if(P===me&&!J())x--;else if(P===H&&x===0)break;a++}O=m(S,a)}let R=Zo(Yr());p.push(`${d}${g}interface ${b}${v}${O?` extends ${O}`:""} ${R}`)}else if(E("type")){a+=4,C();let b=F();C();let v=ht();if(C(),a<l&&r.charCodeAt(a)===ve){a++,C();let O=a,R=0;while(a<l){if(T())continue;let x=r.charCodeAt(a);if(x===ae||x===H||x===xe||x===be)R++;else if(x===X&&R===0)break;else if(x===$e||x===X||x===Pe||x===me&&!J())R--;else if(R===0&&x===ie)break;if(R===0&&z())break;a++}let S=m(O,a);if(a<l&&r.charCodeAt(a)===ie)a++;p.push(`${d}${g}type ${b}${v} = ${S}`)}}else if(E("class")){a+=5,C();let b=F();C();let v=ht();C();let O=a,R=0;while(a<l){if(T())continue;let j=r.charCodeAt(a);if(j===be)R++;else if(j===me&&!J())R--;else if(j===H&&R===0)break;a++}let S=m(O,a),x=S?` ${S}`:"",P=tn();p.push(`${d}${g}class ${b}${v}${x} ${P}`)}else if(E("enum")){a+=4,C();let b=F();C();let v=Yr();p.push(`${d}${g}enum ${b} ${v}`)}else if(E("namespace")||E("module")){let b=E("namespace")?"namespace":"module";a+=b.length,C();let v=F();C();let O=on(d);p.push(`${d}${g}${b} ${v} ${O}`)}else if(E("abstract"))if(a+=8,C(),E("class")){a+=5,C();let b=F();C();let v=ht();C();let O=a,R=0;while(a<l){if(T())continue;let j=r.charCodeAt(a);if(j===be)R++;else if(j===me&&!J())R--;else if(j===H&&R===0)break;a++}let S=m(O,a),x=S?` ${S}`:"",P=tn();p.push(`${d}${g}abstract class ${b}${v}${x} ${P}`)}else ne(!0);else if(h&&E("default")){a+=7,C();let b=a;ne(!0);let v=m(b,a);if(v.charCodeAt(v.length-1)===ie)v=v.slice(0,-1);if(v)p.push(`${d}export default ${v};`)}else if(!h&&(r.charCodeAt(a)===le||r.charCodeAt(a)===ue||r.charCodeAt(a)===Ne))ne(!0);else ne(!0)}if(p.length===0)return"{}";return`{
160
160
  ${p.join(`
161
161
  `)}
162
- }`}function rf(d,p){let h=l+d.length;while(h<a&&Be(r.charCodeAt(h)))h++;for(let g=0;g<p.length;g++)if(h+g>=a||r.charCodeAt(h+g)!==p.charCodeAt(g))return!1;return h+p.length>=a||!_e(r.charCodeAt(h+p.length))}function _t(d,p,h){l+=h.length,C();let g="",E=r.charCodeAt(l);if(E===de||E===me){let A=l;k(E),g=r.slice(A,l)}else{g=N();while(l<a&&r.charCodeAt(l)===mt)l++,g+=`.${N()}`}C();let b=l<a&&r.charCodeAt(l)===H?on():"{}",O=`${p?"export ":""}declare ${h} ${g} ${b}`,R=Xe(d),S=g.startsWith("'")||g.startsWith('"');return{kind:"module",name:g,text:O,isExported:p,source:S?g.slice(1,-1):void 0,leadingComments:R,start:d,end:l}}function ns(d,p){re();let h=m(p,l);if(h.charCodeAt(h.length-1)===ne)h=h.slice(0,-1).trimEnd();if(!h)return;let g=dt(h.charCodeAt(0));for(let A=1;g&&A<h.length;A++)g=_e(h.charCodeAt(A));let E=Xe(d);if(g){c.push({kind:"export",name:"default",text:`export default ${h};`,isExported:!0,isTypeOnly:!1,leadingComments:E,start:d,end:l});return}let b="__dtsx_default_export__",O=1;while(r.includes(b))b=`__dtsx_default_export_${O++}__`;let R=Li(h)||Ie(h,!1),S=R==="unknown"&&Vd(h)?`typeof ${h}`:R;c.push({kind:"variable",name:b,text:`declare const ${b}: ${S};`,isExported:!1,typeAnnotation:S,modifiers:["const"],start:d,end:l}),c.push({kind:"export",name:"default",text:`export default ${b};`,isExported:!0,isTypeOnly:!1,leadingComments:E,start:d,end:l})}while(l<a){if(C(),l>=a)break;let d=l,p=r.charCodeAt(l);if(p===105&&v("import"))c.push(Jc(d));else if(p===101&&v("export")){l+=6,C();let h=r.charCodeAt(l);if(h===100&&v("default")){l+=7,C();let g=l,E=r.charCodeAt(l);if(E===102&&v("function")){let b=xt(d,!0,!1,!0);if(b)c.push(b)}else if(E===97&&v("async")&&ts("async")!==ne)if(l+=5,C(),v("function")){let b=xt(d,!0,!0,!0);if(b)c.push(b)}else ns(d,g);else if(E===99&&v("class")){let b=Tt(d,!0,!1,!0);c.push(b)}else if(E===97&&v("abstract")){if(l+=8,C(),v("class")){let b=Tt(d,!0,!0,!0);c.push(b)}}else ns(d,g)}else if(h===116&&v("type")){let g=l;if(l+=4,C(),l<a&&r.charCodeAt(l)===H){Jo();let E=m(d,l),b=Xe(d);c.push({kind:"export",name:"",text:E,isExported:!0,isTypeOnly:!0,source:Ni(E),leadingComments:b,start:d,end:l})}else if(l<a&&r.charCodeAt(l)===xe){qo();let E=m(d,l);c.push({kind:"export",name:"",text:E,isExported:!0,isTypeOnly:!0,source:Ni(E),start:d,end:l})}else{l=g;let E=en(d,!0);c.push(E)}}else if(h===105&&v("interface")){let g=Qr(d,!0);c.push(g)}else if(h===102&&v("function")){let g=xt(d,!0,!1,!1);if(g)c.push(g)}else if(h===97&&v("async"))if(l+=5,C(),v("function")){let g=xt(d,!0,!0,!1);if(g)c.push(g)}else re();else if(h===99)if(v("class")){let g=Tt(d,!0,!1);c.push(g)}else if(v("const")){let g=l;if(l+=5,C(),v("enum")){l=g+5,C();let E=jt(d,!0,!0);c.push(E)}else{l=g;let E=It(d,"const",!0);for(let b=0;b<E.length;b++)c.push(E[b])}}else re();else if(h===97&&v("abstract")){if(l+=8,C(),v("class")){let g=Tt(d,!0,!0);c.push(g)}}else if(h===108&&v("let")){let g=It(d,"let",!0);for(let E=0;E<g.length;E++)c.push(g[E])}else if(h===118&&v("var")){let g=It(d,"var",!0);for(let E=0;E<g.length;E++)c.push(g[E])}else if(h===101&&v("enum")){let g=jt(d,!0,!1);c.push(g)}else if(h===100&&v("declare"))l+=7,C(),os(d,!0);else if(h===110&&v("namespace")&&K(9)){let g=_t(d,!0,"namespace");c.push(g)}else if(h===109&&v("module")&&K(6)){let g=_t(d,!0,"module");c.push(g)}else if(h===H){Jo();let g=m(d,l),E=g.includes("export type"),b=Xe(d);c.push({kind:"export",name:"",text:g,isExported:!0,isTypeOnly:E,source:Ni(g),leadingComments:b,start:d,end:l})}else if(h===xe){qo();let g=m(d,l),E=Xe(d);c.push({kind:"export",name:"",text:g,isExported:!0,isTypeOnly:!1,source:Ni(g),leadingComments:E,start:d,end:l})}else{re();let g=m(d,l);if(g)c.push({kind:"export",name:"",text:g,isExported:!0,start:d,end:l})}}else if(p===100&&v("declare"))l+=7,C(),os(d,!1);else if(p===105&&v("interface")){let h=Qr(d,!1);f.set(h.name,h)}else if(p===116&&v("type")){let h=en(d,!1);f.set(h.name,h),c.push(h)}else if(p===102&&v("function")){let h=xt(d,!1,!1,!1);if(h)f.set(h.name,h);else re()}else if(p===97)if(v("async")){let h=l;if(l+=5,C(),v("function")){let g=xt(d,!1,!0,!1);if(g)f.set(g.name,g);else l=h,re()}else l=h,re()}else if(v("abstract"))if(l+=8,C(),v("class")){let h=Tt(d,!1,!1);f.set(h.name,h),c.push(h)}else re();else l++,re();else if(p===99)if(v("class")){let h=Tt(d,!1,!1);f.set(h.name,h),c.push(h)}else if(v("const")){let h=l;if(l+=5,C(),v("enum")){l=h+5,C();let g=jt(d,!1,!0);f.set(g.name,g),c.push(g)}else{l=h;let g=It(d,"const",!1);for(let E=0;E<g.length;E++)f.set(g[E].name,g[E])}}else l++,re();else if(p===101&&v("enum")){let h=jt(d,!1,!1);f.set(h.name,h),c.push(h)}else if(p===108&&v("let")||p===118&&v("var")){let h=v("let")?"let":"var",g=It(d,h,!1);for(let E=0;E<g.length;E++)f.set(g[E].name,g[E])}else if(p===109&&v("module")&&K(6)){let h=_t(d,!1,"module");c.push(h)}else if(p===110&&v("namespace")&&K(9)){let h=_t(d,!1,"namespace");c.push(h)}else{let h=r.charCodeAt(l);if(h===ne)l++;else if(h===de||h===me){if(k(h),l<a&&r.charCodeAt(l)===ne)l++}else if(h===Ne){if(L(),l<a&&r.charCodeAt(l)===ne)l++}else if(h===jd){if(l++,N(),C(),l<a&&r.charCodeAt(l)===mt)l++,N(),C();if(l<a&&r.charCodeAt(l)===ae)Z(ae,$e)}else l++,re()}}if(f.size>0)Kd(c,f);if(u.size>0){let d=new Map;for(let h of c)if(h.kind==="function")d.set(h.name,(d.get(h.name)||0)+1);let p=new Set;for(let[h,g]of d)if(g>1)p.add(h);if(p.size>0){let h=new Set;for(let g of p)for(let E=c.length-1;E>=0;E--)if(c[E].kind==="function"&&c[E].name===g&&u.has(E)){h.add(E);break}if(h.size>0){let g=[...h].sort((E,b)=>b-E);for(let E of g)c.splice(E,1)}}}return c;function os(d,p){if(v("function")){let h=xt(d,p,!1,!1);if(h)c.push(h)}else if(v("async")){if(l+=5,C(),v("function")){let h=xt(d,p,!0,!1);if(h)c.push(h)}}else if(v("class")){let h=Tt(d,p,!1);c.push(h)}else if(v("abstract")){if(l+=8,C(),v("class")){let h=Tt(d,p,!0);c.push(h)}}else if(v("interface")){let h=Qr(d,p);c.push(h)}else if(v("type")){let h=en(d,p);c.push(h)}else if(v("enum")){let h=jt(d,p,!1);c.push(h)}else if(v("const")){let h=l;if(l+=5,C(),v("enum")){l=h+5,C();let g=jt(d,p,!0);c.push(g)}else if(p){l=h;let g=It(d,"const",!0);for(let E=0;E<g.length;E++)c.push(g[E])}else re()}else if(v("let")||v("var"))if(p){let h=v("let")?"let":"var",g=It(d,h,!0);for(let E=0;E<g.length;E++)c.push(g[E])}else re();else if(v("module")){let h=_t(d,p,"module");c.push(h)}else if(v("namespace")){let h=_t(d,p,"namespace");c.push(h)}else if(v("global")){l+=6,C();let h=`declare global ${l<a&&r.charCodeAt(l)===H?on():"{}"}`,g=Xe(d);c.push({kind:"module",name:"global",text:h,isExported:!1,leadingComments:g,start:d,end:l})}else re()}}function Gl(e,t){let i=0,n=e.length;while(i<n){let r=e.charCodeAt(i);if(r>=65&&r<=90||r>=97&&r<=122||r===95||r===36||r>127){let o=i;i++;while(i<n){let s=e.charCodeAt(i);if(s>=65&&s<=90||s>=97&&s<=122||s>=48&&s<=57||s===95||s===36||s>127)i++;else break}t.add(e.substring(o,i))}else i++}}function jl(e,t){let i=0;while(i<e.length){let n=e.charCodeAt(i);if(n===de||n===me||n===Ne){let u=n;i++;while(i<e.length)if(e.charCodeAt(i)===it)i+=2;else if(e.charCodeAt(i++)===u)break;continue}if(n===Q&&e.charCodeAt(i+1)===Q){i+=2;while(i<e.length&&e.charCodeAt(i)!==Ee&&e.charCodeAt(i)!==Te)i++;continue}if(n===Q&&e.charCodeAt(i+1)===xe){let u=e.indexOf("*/",i+2);i=u===-1?e.length:u+2;continue}if(!dt(n)){i++;continue}let r=i++;while(i<e.length&&_e(e.charCodeAt(i)))i++;let o=r-1,s=i;while(o>=0&&Be(e.charCodeAt(o)))o--;while(s<e.length&&Be(e.charCodeAt(s)))s++;let a=o>=0?e.charCodeAt(o):0,c=s<e.length?e.charCodeAt(s):0,f=r>=3&&e.slice(r-3,r)==="...";if(c===ft||a===mt&&!f)continue;if(c===ae&&(a===H||a===ut))continue;t.add(e.slice(r,i))}}function Kd(e,t){let i=new Set,n=new Set;for(let s of e)n.add(s.name);let r=new Set,o=[];for(let s=0;s<e.length;s++){let a=e[s];if(a.kind!=="import"){if(o.push(a.text),Gl(a.text,r),typeof a.value==="string")jl(a.value,r)}}for(;;){let s=[];for(let[f,u]of t){if(i.has(f))continue;if(r.has(f)){if(!n.has(f))s.push(u),n.add(f);i.add(f)}}if(s.length===0)break;s.sort((f,u)=>(f.start??1/0)-(u.start??1/0));let a=[],c=0;for(let f=0;f<e.length;f++){let u=e[f].start??1/0;while(c<s.length&&(s[c].start??1/0)<=u)a.push(s[c++]);a.push(e[f])}while(c<s.length)a.push(s[c++]);e.length=0;for(let f=0;f<a.length;f++)e.push(a[f]);for(let f of s)if(f.kind!=="import"){if(o.push(f.text),Gl(f.text,r),typeof f.value==="string")jl(f.value,r)}}}var ke=32,Me=9,Ee=10,Te=13,Q=47,xe=42,de=39,me=34,Ne=96,it=92,H=123,X=125,ae=40,$e=41,be=91,Pe=93,ve=60,pe=62,ne=59,ft=58,Ae=61,ut=44,mt=46,Lo=63,jr=35,jd=64,_d=36,Wo;var Kl=ue(()=>{fn();Fo();Wo=["public","protected","private","readonly","override"]});function zl(e,t,i=!0,n=!1){if(gl(t))e=wl(e);else if(vl(t))e=bl(e);let r=yi(e),o=`${t}:${i?1:0}:${n?1:0}`,s=ui.get(o);if(s&&s.contentHash===r)return s.lastAccess=++Hl,s.declarations;let a=n?_l(e,t,i):Vl(e,t,i);if(ui.set(o,{declarations:a,contentHash:r,lastAccess:++Hl}),ui.size>Hd){let c=Math.max(1,Math.ceil(ui.size*0.1)),f=[];for(let[u,l]of ui)f.push([u,l.lastAccess]);f.sort((u,l)=>u[1]-l[1]);for(let u=0;u<c&&u<f.length;u++)ui.delete(f[u][0])}return a}var Hd=100,Hl=0,ui;var Jl=ue(()=>{bo();Sl();Kl();vn();ui=new Map});function ql(e,t,i=!0,n=!1){return zl(e,t,i,n)}var Yl=ue(()=>{Jl()});async function zd(){if(Vr!==null)return Vr;try{return Mt=await import("prettier"),Vr=!0,!0}catch{return Vr=!1,!1}}async function Jd(e,t){if(!Mt)return null;try{if(t&&Mt.resolveConfig){let i=await Mt.resolveConfig(t);if(i)return i}if(e&&Mt.resolveConfig){let i=await Mt.resolveConfig(e);if(i)return i}return null}catch{return null}}async function qd(e,t){if(!Mt)throw Error("Prettier is not available");let i={...t,parser:t.parser||"typescript"};return Mt.format(e,i)}function Yd(e,t={}){let{indentSize:i=2,useTabs:n=!1,maxLineWidth:r=100,trailingNewline:o=!0,normalizeWhitespace:s=!0,sortImports:a=!0,groupImports:c=!0}=t,f=e,u=n?"\t":" ".repeat(i);if(f.indexOf(`\r
162
+ }`}function nf(d,p){let h=a+d.length;while(h<l&&je(r.charCodeAt(h)))h++;for(let g=0;g<p.length;g++)if(h+g>=l||r.charCodeAt(h+g)!==p.charCodeAt(g))return!1;return h+p.length>=l||!_e(r.charCodeAt(h+p.length))}function _t(d,p,h){a+=h.length,C();let g="",b=r.charCodeAt(a);if(b===le||b===ue){let x=a;k(b),g=r.slice(x,a)}else{g=F();while(a<l&&r.charCodeAt(a)===pt)a++,g+=`.${F()}`}C();let v=a<l&&r.charCodeAt(a)===H?on():"{}",O=`${p?"export ":""}declare ${h} ${g} ${v}`,R=Xe(d),S=g.startsWith("'")||g.startsWith('"');return{kind:"module",name:g,text:O,isExported:p,source:S?g.slice(1,-1):void 0,leadingComments:R,start:d,end:a}}function os(d,p){ne();let h=m(p,a);if(h.charCodeAt(h.length-1)===ie)h=h.slice(0,-1).trimEnd();if(!h)return;let g=mt(h.charCodeAt(0));for(let x=1;g&&x<h.length;x++)g=_e(h.charCodeAt(x));let b=Xe(d);if(g){c.push({kind:"export",name:"default",text:`export default ${h};`,isExported:!0,isTypeOnly:!1,leadingComments:b,start:d,end:a});return}let v="__dtsx_default_export__",O=1;while(r.includes(v))v=`__dtsx_default_export_${O++}__`;let R=Li(h)||Ie(h,!1),S=R==="unknown"&&Ud(h)?`typeof ${h}`:R;c.push({kind:"variable",name:v,text:`declare const ${v}: ${S};`,isExported:!1,typeAnnotation:S,modifiers:["const"],start:d,end:a}),c.push({kind:"export",name:"default",text:`export default ${v};`,isExported:!0,isTypeOnly:!1,leadingComments:b,start:d,end:a})}while(a<l){if(C(),a>=l)break;let d=a,p=r.charCodeAt(a);if(p===105&&E("import"))c.push(qc(d));else if(p===101&&E("export")){a+=6,C();let h=r.charCodeAt(a);if(h===100&&E("default")){a+=7,C();let g=a,b=r.charCodeAt(a);if(b===102&&E("function")){let v=At(d,!0,!1,!0);if(v)c.push(v)}else if(b===97&&E("async")&&nn("async")!==ie)if(a+=5,C(),E("function")){let v=At(d,!0,!0,!0);if(v)c.push(v)}else os(d,g);else if(b===99&&E("class")){let v=Tt(d,!0,!1,!0);c.push(v)}else if(b===97&&E("abstract")){if(a+=8,C(),E("class")){let v=Tt(d,!0,!0,!0);c.push(v)}}else os(d,g)}else if(h===116&&E("type")){let g=a;if(a+=4,C(),a<l&&r.charCodeAt(a)===H){Jo();let b=m(d,a),v=Xe(d);c.push({kind:"export",name:"",text:b,isExported:!0,isTypeOnly:!0,source:Ni(b),leadingComments:v,start:d,end:a})}else if(a<l&&r.charCodeAt(a)===Ae){qo();let b=m(d,a);c.push({kind:"export",name:"",text:b,isExported:!0,isTypeOnly:!0,source:Ni(b),start:d,end:a})}else{a=g;let b=en(d,!0);c.push(b)}}else if(h===105&&E("interface")){let g=Qr(d,!0);c.push(g)}else if(h===102&&E("function")){let g=At(d,!0,!1,!1);if(g)c.push(g)}else if(h===97&&E("async"))if(a+=5,C(),E("function")){let g=At(d,!0,!0,!1);if(g)c.push(g)}else ne();else if(h===99)if(E("class")){let g=Tt(d,!0,!1);c.push(g)}else if(E("const")){let g=a;if(a+=5,C(),E("enum")){a=g+5,C();let b=jt(d,!0,!0);c.push(b)}else{a=g;let b=It(d,"const",!0);for(let v=0;v<b.length;v++)c.push(b[v])}}else ne();else if(h===97&&E("abstract")){if(a+=8,C(),E("class")){let g=Tt(d,!0,!0);c.push(g)}}else if(h===108&&E("let")){let g=It(d,"let",!0);for(let b=0;b<g.length;b++)c.push(g[b])}else if(h===118&&E("var")){let g=It(d,"var",!0);for(let b=0;b<g.length;b++)c.push(g[b])}else if(h===101&&E("enum")){let g=jt(d,!0,!1);c.push(g)}else if(h===100&&E("declare"))a+=7,C(),ss(d,!0);else if(h===110&&E("namespace")&&K(9)){let g=_t(d,!0,"namespace");c.push(g)}else if(h===109&&E("module")&&K(6)){let g=_t(d,!0,"module");c.push(g)}else if(h===H){Jo();let g=m(d,a),b=g.includes("export type"),v=Xe(d);c.push({kind:"export",name:"",text:g,isExported:!0,isTypeOnly:b,source:Ni(g),leadingComments:v,start:d,end:a})}else if(h===Ae){qo();let g=m(d,a),b=Xe(d);c.push({kind:"export",name:"",text:g,isExported:!0,isTypeOnly:!1,source:Ni(g),leadingComments:b,start:d,end:a})}else{ne();let g=m(d,a);if(g)c.push({kind:"export",name:"",text:g,isExported:!0,start:d,end:a})}}else if(p===100&&E("declare"))a+=7,C(),ss(d,!1);else if(p===105&&E("interface")){let h=Qr(d,!1);f.set(h.name,h)}else if(p===116&&E("type")){let h=en(d,!1);f.set(h.name,h),c.push(h)}else if(p===102&&E("function")){let h=At(d,!1,!1,!1);if(h)f.set(h.name,h);else ne()}else if(p===97)if(E("async")){let h=a;if(a+=5,C(),E("function")){let g=At(d,!1,!0,!1);if(g)f.set(g.name,g);else a=h,ne()}else a=h,ne()}else if(E("abstract"))if(a+=8,C(),E("class")){let h=Tt(d,!1,!1);f.set(h.name,h),c.push(h)}else ne();else a++,ne();else if(p===99)if(E("class")){let h=Tt(d,!1,!1);f.set(h.name,h),c.push(h)}else if(E("const")){let h=a;if(a+=5,C(),E("enum")){a=h+5,C();let g=jt(d,!1,!0);f.set(g.name,g),c.push(g)}else{a=h;let g=It(d,"const",!1);for(let b=0;b<g.length;b++)f.set(g[b].name,g[b])}}else a++,ne();else if(p===101&&E("enum")){let h=jt(d,!1,!1);f.set(h.name,h),c.push(h)}else if(p===108&&E("let")||p===118&&E("var")){let h=E("let")?"let":"var",g=It(d,h,!1);for(let b=0;b<g.length;b++)f.set(g[b].name,g[b])}else if(p===109&&E("module")&&K(6)){let h=_t(d,!1,"module");c.push(h)}else if(p===110&&E("namespace")&&K(9)){let h=_t(d,!1,"namespace");c.push(h)}else{let h=r.charCodeAt(a);if(h===ie)a++;else if(h===le||h===ue){if(k(h),a<l&&r.charCodeAt(a)===ie)a++}else if(h===Ne){if(W(),a<l&&r.charCodeAt(a)===ie)a++}else if(h===_d){if(a++,F(),C(),a<l&&r.charCodeAt(a)===pt)a++,F(),C();if(a<l&&r.charCodeAt(a)===ae)Z(ae,$e)}else a++,ne()}}if(f.size>0)Hd(c,f);if(u.size>0){let d=new Map;for(let h of c)if(h.kind==="function")d.set(h.name,(d.get(h.name)||0)+1);let p=new Set;for(let[h,g]of d)if(g>1)p.add(h);if(p.size>0){let h=new Set;for(let g of p)for(let b=c.length-1;b>=0;b--)if(c[b].kind==="function"&&c[b].name===g&&u.has(b)){h.add(b);break}if(h.size>0){let g=[...h].sort((b,v)=>v-b);for(let b of g)c.splice(b,1)}}}return c;function ss(d,p){if(E("function")){let h=At(d,p,!1,!1);if(h)c.push(h)}else if(E("async")){if(a+=5,C(),E("function")){let h=At(d,p,!0,!1);if(h)c.push(h)}}else if(E("class")){let h=Tt(d,p,!1);c.push(h)}else if(E("abstract")){if(a+=8,C(),E("class")){let h=Tt(d,p,!0);c.push(h)}}else if(E("interface")){let h=Qr(d,p);c.push(h)}else if(E("type")){let h=en(d,p);c.push(h)}else if(E("enum")){let h=jt(d,p,!1);c.push(h)}else if(E("const")){let h=a;if(a+=5,C(),E("enum")){a=h+5,C();let g=jt(d,p,!0);c.push(g)}else if(p){a=h;let g=It(d,"const",!0);for(let b=0;b<g.length;b++)c.push(g[b])}else ne()}else if(E("let")||E("var"))if(p){let h=E("let")?"let":"var",g=It(d,h,!0);for(let b=0;b<g.length;b++)c.push(g[b])}else ne();else if(E("module")){let h=_t(d,p,"module");c.push(h)}else if(E("namespace")){let h=_t(d,p,"namespace");c.push(h)}else if(E("global")){a+=6,C();let h=`declare global ${a<l&&r.charCodeAt(a)===H?on():"{}"}`,g=Xe(d);c.push({kind:"module",name:"global",text:h,isExported:!1,leadingComments:g,start:d,end:a})}else ne()}}function jl(e,t){let i=0,n=e.length;while(i<n){let r=e.charCodeAt(i);if(r>=65&&r<=90||r>=97&&r<=122||r===95||r===36||r>127){let o=i;i++;while(i<n){let s=e.charCodeAt(i);if(s>=65&&s<=90||s>=97&&s<=122||s>=48&&s<=57||s===95||s===36||s>127)i++;else break}t.add(e.substring(o,i))}else i++}}function _l(e,t){let i=0;while(i<e.length){let n=e.charCodeAt(i);if(n===le||n===ue||n===Ne){let u=n;i++;while(i<e.length)if(e.charCodeAt(i)===it)i+=2;else if(e.charCodeAt(i++)===u)break;continue}if(n===Q&&e.charCodeAt(i+1)===Q){i+=2;while(i<e.length&&e.charCodeAt(i)!==Ee&&e.charCodeAt(i)!==Te)i++;continue}if(n===Q&&e.charCodeAt(i+1)===Ae){let u=e.indexOf("*/",i+2);i=u===-1?e.length:u+2;continue}if(!mt(n)){i++;continue}let r=i++;while(i<e.length&&_e(e.charCodeAt(i)))i++;let o=r-1,s=i;while(o>=0&&je(e.charCodeAt(o)))o--;while(s<e.length&&je(e.charCodeAt(s)))s++;let l=o>=0?e.charCodeAt(o):0,c=s<e.length?e.charCodeAt(s):0,f=r>=3&&e.slice(r-3,r)==="...";if(c===lt||l===pt&&!f)continue;if(c===ae&&(l===H||l===ut))continue;t.add(e.slice(r,i))}}function Hd(e,t){let i=new Set,n=new Set;for(let s of e)n.add(s.name);let r=new Set,o=[];for(let s=0;s<e.length;s++){let l=e[s];if(l.kind!=="import"){if(o.push(l.text),jl(l.text,r),typeof l.value==="string")_l(l.value,r)}}for(;;){let s=[];for(let[f,u]of t){if(i.has(f))continue;if(r.has(f)){if(!n.has(f))s.push(u),n.add(f);i.add(f)}}if(s.length===0)break;s.sort((f,u)=>(f.start??1/0)-(u.start??1/0));let l=[],c=0;for(let f=0;f<e.length;f++){let u=e[f].start??1/0;while(c<s.length&&(s[c].start??1/0)<=u)l.push(s[c++]);l.push(e[f])}while(c<s.length)l.push(s[c++]);e.length=0;for(let f=0;f<l.length;f++)e.push(l[f]);for(let f of s)if(f.kind!=="import"){if(o.push(f.text),jl(f.text,r),typeof f.value==="string")_l(f.value,r)}}}var ke=32,Me=9,Ee=10,Te=13,Q=47,Ae=42,le=39,ue=34,Ne=96,it=92,H=123,X=125,ae=40,$e=41,xe=91,Pe=93,be=60,me=62,ie=59,lt=58,ve=61,ut=44,pt=46,jr=63,Lo=35,_d=64,Vd=36,Wo;var Hl=de(()=>{fn();Fo();Wo=["public","protected","private","readonly","override"]});function Jl(e,t,i=!0,n=!1){if(yl(t))e=bl(e);else if(vl(t))e=Sl(e);let r=yi(e),o=`${t}:${i?1:0}:${n?1:0}`,s=ui.get(o);if(s&&s.contentHash===r)return s.lastAccess=++zl,s.declarations;let l=n?Vl(e,t,i):Ul(e,t,i);if(ui.set(o,{declarations:l,contentHash:r,lastAccess:++zl}),ui.size>zd){let c=Math.max(1,Math.ceil(ui.size*0.1)),f=[];for(let[u,a]of ui)f.push([u,a.lastAccess]);f.sort((u,a)=>u[1]-a[1]);for(let u=0;u<c&&u<f.length;u++)ui.delete(f[u][0])}return l}var zd=100,zl=0,ui;var ql=de(()=>{vo();$l();Hl();En();ui=new Map});function Yl(e,t,i=!0,n=!1){return Jl(e,t,i,n)}var Zl=de(()=>{ql()});async function Jd(){if(Vr!==null)return Vr;try{return Mt=await import("prettier"),Vr=!0,!0}catch{return Vr=!1,!1}}async function qd(e,t){if(!Mt)return null;try{if(t&&Mt.resolveConfig){let i=await Mt.resolveConfig(t);if(i)return i}if(e&&Mt.resolveConfig){let i=await Mt.resolveConfig(e);if(i)return i}return null}catch{return null}}async function Yd(e,t){if(!Mt)throw Error("Prettier is not available");let i={...t,parser:t.parser||"typescript"};return Mt.format(e,i)}function Zd(e,t={}){let{indentSize:i=2,useTabs:n=!1,maxLineWidth:r=100,trailingNewline:o=!0,normalizeWhitespace:s=!0,sortImports:l=!0,groupImports:c=!0}=t,f=e,u=n?"\t":" ".repeat(i);if(f.indexOf(`\r
163
163
  `)!==-1)f=f.replace(/\r\n/g,`
164
164
  `);if(s){if(/[ \t]\n/.test(f)||/[ \t]$/.test(f))f=f.replace(/[ \t]+$/gm,"");if(f.indexOf(`
165
165
 
166
166
 
167
167
  `)!==-1)f=f.replace(/\n{3,}/g,`
168
168
 
169
- `);f=Zd(f,u)}if(a||c)f=Xd(f,{sort:a,group:c});if(r>0)f=ep(f,r,u);if(o&&!f.endsWith(`
169
+ `);f=Xd(f,u)}if(l||c)f=Qd(f,{sort:l,group:c});if(r>0)f=tp(f,r,u);if(o&&!f.endsWith(`
170
170
  `))f+=`
171
- `;return f}function Zd(e,t){let i=e.split(`
172
- `),n=[];for(let r of i){let o=r.match(/^(\s*)(.*)$/);if(!o){n.push(r);continue}let[,s,a]=o;if(!a){n.push("");continue}let c=s.replace(/\t/g," ").length,f=Math.floor(c/2);n.push(t.repeat(f)+a)}return n.join(`
173
- `)}function Xd(e,t){let i=e.split(`
174
- `),n=[],r=[],o=!1,s=0;for(let c=0;c<i.length;c++){let f=i[c],u=f.match(/^(import\s+(?:type\s+)?.*from\s+['"])([^'"]+)(['"].*)$/);if(u){o=!0,s=c;let l=u[1];n.push({line:f,source:u[2],isType:l.startsWith("import type ")||l.startsWith("import type\t")})}else if(o&&f.trim()==="")continue;else{if(o)o=!1;r.push(f)}}if(n.length===0)return e;if(t.sort)n.sort((c,f)=>{if(c.isType!==f.isType)return c.isType?1:-1;return Qd(c.source,f.source)});let a;if(t.group){let c=[],f=[],u=[],l=[],m=[];for(let y=0;y<n.length;y++){let w=n[y],C=w.source;if(C.charCodeAt(0)===46)m.push(w);else if(C.startsWith("node:"))c.push(w);else if(C.charCodeAt(0)===64)l.push(w);else if(C.includes("/"))u.push(w);else f.push(w)}a=[...c.map((y)=>y.line),...c.length>0&&f.length>0?[""]:[],...f.map((y)=>y.line),...(c.length>0||f.length>0)&&u.length>0?[""]:[],...u.map((y)=>y.line),...l.length>0&&(c.length>0||f.length>0||u.length>0)?[""]:[],...l.map((y)=>y.line),...m.length>0?[""]:[],...m.map((y)=>y.line)]}else a=n.map((c)=>c.line);return[...a,"",...r].join(`
175
- `)}function Qd(e,t){let i=e.startsWith("node:"),n=t.startsWith("node:");if(i!==n)return i?-1:1;let r=e.startsWith("."),o=t.startsWith(".");if(r!==o)return r?1:-1;return e.localeCompare(t)}function ep(e,t,i){let n=e.split(`
176
- `),r=[];for(let o of n){if(o.length<=t){r.push(o);continue}if(o.trimStart().startsWith("import ")){r.push(o);continue}let s=o.match(/^(\s*)/)?.[1]||"",a=s+i,c=ip(o,s,a);if(c){r.push(...c);continue}if(o.includes("{")&&o.includes("}")){let f=rp(o,t,s,a);r.push(...f);continue}if(o.includes(" | ")){let f=np(o,t,s,a);r.push(...f);continue}r.push(o)}return r.join(`
177
- `)}function ip(e,t,i){let n=e.match(tp);if(!n)return null;let[,r,o,s,a]=n,c=s.split(",").map((l)=>l.trim()).filter(Boolean);if(c.length<=1)return[e];let f=`${t}${r}${o??""} {`,u=a?`${t}} ${a};`:`${t}};`;return[f,...c.map((l)=>`${i}${l},`),u]}function rp(e,t,i,n){let r=e.match(/^(\s*)(.*?)(\{)(.+)(\}.*)$/);if(!r)return[e];let[,,o,s,a,c]=r,f=a.split(/;\s*|,\s*/).filter((u)=>u.trim());if(f.length<=1)return[e];return[`${i}${o}${s}`,...f.map((u)=>`${n}${u.trim()};`),`${i}${c.trim()}`]}function np(e,t,i,n){let r=e.match(/^(\s*)(.*?=\s*)(.+)$/);if(!r)return[e];let[,,o,s]=r,a=s.split(/\s*\|\s*/).filter((c)=>c.trim());if(a.length<=2)return[e];return[`${i}${o}`,...a.map((c,f)=>`${n}${f>0?"| ":" "}${c.trim()}`)]}async function Zl(e,t={},i){let n=[];if(t.usePrettier!==!1){if(await zd())try{let r={...await Jd(t.prettierConfigPath,i),...t.prettierOptions,parser:"typescript"};return{content:await qd(e,r),usedPrettier:!0}}catch(r){n.push(`Prettier formatting failed: ${r}. Using built-in formatter.`)}else if(t.usePrettier===!0)n.push("Prettier requested but not available. Using built-in formatter.")}return{content:Yd(e,t.builtIn),usedPrettier:!1,warnings:n.length>0?n:void 0}}var Vr=null,Mt=null,tp;var Xl=ue(()=>{tp=/^\s*(export|import)(\s+type)?\s*\{([^{}]*)\}\s*(from\s*(?:'[^']*'|"[^"]*")(?:\s*(?:with|assert)\s*\{[^{}]*\})?)?\s*;?\s*$/});class Ur{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)}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 n=await i.onStart(t);if(n)t=n}return this.config=t,t}async runOnBeforeFile(e,t){let i=t;for(let n of this.plugins)if(n.onBeforeFile){let r={filePath:e,sourceCode:t,content:i,config:this.config,log:this.createLogger(n.name)},o=await n.onBeforeFile(r);if(typeof o==="string")i=o}return i}async runOnDeclarations(e,t,i){let n=i;for(let r of this.plugins)if(r.onDeclarations){let o={filePath:e,sourceCode:t,declarations:n,config:this.config,log:this.createLogger(r.name)},s=await r.onDeclarations(o);if(s)n=s}return n}async runOnAfterFile(e,t,i){let n=i;for(let r of this.plugins)if(r.onAfterFile){let o={filePath:e,sourceCode:t,content:n,config:this.config,log:this.createLogger(r.name)},s=await r.onAfterFile(o);if(typeof s==="string")n=s}return n}async runOnEnd(e){for(let t of this.plugins)if(t.onEnd)await t.onEnd(e)}async runOnError(e,t,i){for(let n of this.plugins)if(n.onError){let r={filePath:t,sourceCode:i,config:this.config,log:this.createLogger(n.name)};await n.onError(e,r)}}}function op(e){return e}var x0,T0;var Ql=ue(()=>{x0=new Ur;T0=op({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 ic(e,t={}){let{lineEnding:i="lf",trailingNewline:n=!0,maxBlankLines:r=1,trimTrailingWhitespace:o=!0,normalizeIndentation:s=!0,indent:a={style:"spaces",size:2},declarationOrder:c,importGrouping:f,preserveComments:u=!0,insertFinalNewline:l=!0}=t,m=e;if(m=lp(m,i),f?.enabled!==!1)m=dp(m,f||{});if(c)m=pp(m,c);if(o)m=cp(m);if(m=fp(m,r),s)m=hp(m,a);if(n||l)m=up(m);return m}function lp(e,t){let i=e;if(e.indexOf("\r")!==-1){if(e.indexOf(`\r
171
+ `;return f}function Xd(e,t){let i=e.split(`
172
+ `),n=[];for(let r of i){let o=r.match(/^(\s*)(.*)$/);if(!o){n.push(r);continue}let[,s,l]=o;if(!l){n.push("");continue}let c=s.replace(/\t/g," ").length,f=Math.floor(c/2);n.push(t.repeat(f)+l)}return n.join(`
173
+ `)}function Qd(e,t){let i=e.split(`
174
+ `),n=[],r=[],o=!1,s=0;for(let c=0;c<i.length;c++){let f=i[c],u=f.match(/^(import\s+(?:type\s+)?.*from\s+['"])([^'"]+)(['"].*)$/);if(u){o=!0,s=c;let a=u[1];n.push({line:f,source:u[2],isType:a.startsWith("import type ")||a.startsWith("import type\t")})}else if(o&&f.trim()==="")continue;else{if(o)o=!1;r.push(f)}}if(n.length===0)return e;if(t.sort)n.sort((c,f)=>{if(c.isType!==f.isType)return c.isType?1:-1;return ep(c.source,f.source)});let l;if(t.group){let c=[],f=[],u=[],a=[],m=[];for(let y=0;y<n.length;y++){let w=n[y],C=w.source;if(C.charCodeAt(0)===46)m.push(w);else if(C.startsWith("node:"))c.push(w);else if(C.charCodeAt(0)===64)a.push(w);else if(C.includes("/"))u.push(w);else f.push(w)}l=[...c.map((y)=>y.line),...c.length>0&&f.length>0?[""]:[],...f.map((y)=>y.line),...(c.length>0||f.length>0)&&u.length>0?[""]:[],...u.map((y)=>y.line),...a.length>0&&(c.length>0||f.length>0||u.length>0)?[""]:[],...a.map((y)=>y.line),...m.length>0?[""]:[],...m.map((y)=>y.line)]}else l=n.map((c)=>c.line);return[...l,"",...r].join(`
175
+ `)}function ep(e,t){let i=e.startsWith("node:"),n=t.startsWith("node:");if(i!==n)return i?-1:1;let r=e.startsWith("."),o=t.startsWith(".");if(r!==o)return r?1:-1;return e.localeCompare(t)}function tp(e,t,i){let n=e.split(`
176
+ `),r=[];for(let o of n){if(o.length<=t){r.push(o);continue}if(o.trimStart().startsWith("import ")){r.push(o);continue}let s=o.match(/^(\s*)/)?.[1]||"",l=s+i,c=rp(o,s,l);if(c){r.push(...c);continue}if(o.includes("{")&&o.includes("}")){let f=np(o,t,s,l);r.push(...f);continue}if(o.includes(" | ")){let f=op(o,t,s,l);r.push(...f);continue}r.push(o)}return r.join(`
177
+ `)}function rp(e,t,i){let n=e.match(ip);if(!n)return null;let[,r,o,s,l]=n,c=s.split(",").map((a)=>a.trim()).filter(Boolean);if(c.length<=1)return[e];let f=`${t}${r}${o??""} {`,u=l?`${t}} ${l};`:`${t}};`;return[f,...c.map((a)=>`${i}${a},`),u]}function np(e,t,i,n){let r=e.match(/^(\s*)(.*?)(\{)(.+)(\}.*)$/);if(!r)return[e];let[,,o,s,l,c]=r,f=l.split(/;\s*|,\s*/).filter((u)=>u.trim());if(f.length<=1)return[e];return[`${i}${o}${s}`,...f.map((u)=>`${n}${u.trim()};`),`${i}${c.trim()}`]}function op(e,t,i,n){let r=e.match(/^(\s*)(.*?=\s*)(.+)$/);if(!r)return[e];let[,,o,s]=r,l=s.split(/\s*\|\s*/).filter((c)=>c.trim());if(l.length<=2)return[e];return[`${i}${o}`,...l.map((c,f)=>`${n}${f>0?"| ":" "}${c.trim()}`)]}async function Xl(e,t={},i){let n=[];if(t.usePrettier!==!1){if(await Jd())try{let r={...await qd(t.prettierConfigPath,i),...t.prettierOptions,parser:"typescript"};return{content:await Yd(e,r),usedPrettier:!0}}catch(r){n.push(`Prettier formatting failed: ${r}. Using built-in formatter.`)}else if(t.usePrettier===!0)n.push("Prettier requested but not available. Using built-in formatter.")}return{content:Zd(e,t.builtIn),usedPrettier:!1,warnings:n.length>0?n:void 0}}var Vr=null,Mt=null,ip;var Ql=de(()=>{ip=/^\s*(export|import)(\s+type)?\s*\{([^{}]*)\}\s*(from\s*(?:'[^']*'|"[^"]*")(?:\s*(?:with|assert)\s*\{[^{}]*\})?)?\s*;?\s*$/});class Ur{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)}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 n=await i.onStart(t);if(n)t=n}return this.config=t,t}async runOnBeforeFile(e,t){let i=t;for(let n of this.plugins)if(n.onBeforeFile){let r={filePath:e,sourceCode:t,content:i,config:this.config,log:this.createLogger(n.name)},o=await n.onBeforeFile(r);if(typeof o==="string")i=o}return i}async runOnDeclarations(e,t,i){let n=i;for(let r of this.plugins)if(r.onDeclarations){let o={filePath:e,sourceCode:t,declarations:n,config:this.config,log:this.createLogger(r.name)},s=await r.onDeclarations(o);if(s)n=s}return n}async runOnAfterFile(e,t,i){let n=i;for(let r of this.plugins)if(r.onAfterFile){let o={filePath:e,sourceCode:t,content:n,config:this.config,log:this.createLogger(r.name)},s=await r.onAfterFile(o);if(typeof s==="string")n=s}return n}async runOnEnd(e){for(let t of this.plugins)if(t.onEnd)await t.onEnd(e)}async runOnError(e,t,i){for(let n of this.plugins)if(n.onError){let r={filePath:t,sourceCode:i,config:this.config,log:this.createLogger(n.name)};await n.onError(e,r)}}}function sp(e){return e}var T0,O0;var ec=de(()=>{T0=new Ur;O0=sp({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 rc(e,t={}){let{lineEnding:i="lf",trailingNewline:n=!0,maxBlankLines:r=1,trimTrailingWhitespace:o=!0,normalizeIndentation:s=!0,indent:l={style:"spaces",size:2},declarationOrder:c,importGrouping:f,preserveComments:u=!0,insertFinalNewline:a=!0}=t,m=e;if(m=cp(m,i),f?.enabled!==!1)m=pp(m,f||{});if(c)m=mp(m,c);if(o)m=fp(m);if(m=up(m,r),s)m=dp(m,l);if(n||a)m=hp(m);return m}function cp(e,t){let i=e;if(e.indexOf("\r")!==-1){if(e.indexOf(`\r
178
178
  `)!==-1)i=i.replace(/\r\n/g,`
179
179
  `);if(i.indexOf("\r")!==-1)i=i.replace(/\r/g,`
180
180
  `)}if(t==="crlf")i=i.replace(/\n/g,`\r
181
- `);return i}function cp(e){return e.split(`
181
+ `);return i}function fp(e){return e.split(`
182
182
  `).map((t)=>t.replace(/[\t ]+$/,"")).join(`
183
- `)}function fp(e,t){let i=new RegExp(`\\n{${t+2},}`,"g");return e.replace(i,`
184
- `.repeat(t+1))}function up(e){return`${e.replace(/\s+$/,"")}
185
- `}function hp(e,t){let{style:i="spaces",size:n=2}=t,r=i==="tabs"?"\t":" ".repeat(n),o=e.split(`
186
- `),s=[];for(let a of o){let c=a.match(/^([\t ]*)(.*)$/);if(!c){s.push(a);continue}let[,f,u]=c;if(!u){s.push("");continue}let l=f.replace(/\t/g," "),m=Math.floor(l.length/2);s.push(r.repeat(m)+u)}return s.join(`
187
- `)}function dp(e,t){let{groups:i=ap,separateGroups:n=!0,alphabetize:r=!0}=t,o=e.split(`
188
- `),s=[],a=[],c=-1;for(let w=0;w<o.length;w++){let C=o[w],x=ec(C);if(x)s.push({line:C,source:x.source,group:x.group,isType:x.isType}),c=w;else if(s.length>0&&C.trim()==="")continue;else if(s.length>0||C.trim()!==""){if(s.length===0||w>c+1)a.push(C)}}if(s.length===0)return e;let f=new Map;for(let w of i)f.set(w,[]);for(let w of s)(f.get(w.group)||f.get("external")||[]).push(w);if(r)for(let[,w]of f)w.sort((C,x)=>{if(C.isType!==x.isType)return C.isType?1:-1;return C.source.localeCompare(x.source)});let u=[],l=null;for(let w of i){let C=f.get(w)||[];if(C.length===0)continue;if(n&&l!==null)u.push("");for(let x of C)u.push(x.line);l=w}let m=o.slice(0,o.findIndex((w)=>ec(w)!==null)),y=a;while(y.length>0&&y[0].trim()==="")y.shift();return[...m,...u,"",...y].join(`
189
- `)}function ec(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:tc(o[1]),isType:!1};return null}let n=!!i[1],r=i[2];return{source:r,group:n?"type":tc(r),isType:n}}function tc(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 pp(e,t){let{kinds:i=sp,alphabetize:n=!1,groupExports:r=!0}=t,o=e.split(`
190
- `),s=[],a=[],c=[],f=null,u=0,l=!0,m=!1,y=[];for(let x=0;x<o.length;x++){let k=o[x],L=k.trim(),W=u,T=L.startsWith("///"),D=W===0&&!T&&(L.startsWith("//")||L.startsWith("/*"));if(m||D){if(y.push(k),!m&&L.startsWith("/*")&&!L.includes("*/"))m=!0;else if(m&&L.includes("*/"))m=!1;continue}if(W===0&&y.length>0&&L===""){y.push(k);continue}u+=(k.match(/\{/g)||[]).length,u-=(k.match(/\}/g)||[]).length;let I=mp(L);if(l&&I&&I.kind!=="import"&&!L.startsWith("//")&&!L.startsWith("/*"))l=!1;if(l){if(y.length>0){if(I?.kind==="import"||!I)a.push(...y),y.length=0}a.push(k);continue}if(I&&u<=1){if(f)s.push(f);f={lines:y.length>0?[...y,k]:[k],kind:I.kind,name:I.name,isExport:I.isExport},y.length=0}else if(f)f.lines.push(k);else{if(L==="")continue;c.push(k)}}if(f)s.push(f);if(y.length>0)c.push(...y);s.sort((x,k)=>{if(r&&x.isExport!==k.isExport)return x.isExport?-1:1;let L=i.indexOf(x.kind),W=i.indexOf(k.kind),T=L>=0?L:i.length,D=W>=0?W:i.length;if(T!==D)return T-D;if(n)return x.name.localeCompare(k.name);return 0});let w=[...a],C=null;for(let x of s){if(C!==null&&x.kind!==C)w.push("");w.push(...x.lines),C=x.kind}if(c.length>0)w.push(""),w.push(...c);return w.join(`
191
- `)}function mp(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 sp,ap;var rc=ue(()=>{sp=["import","type","interface","enum","class","function","variable","export","module","namespace","unknown"],ap=["builtin","external","scoped","internal","parent","sibling","index","type"]});function Ep(e){switch(e){case"strict":return yp;case"readonly":return Cp;case"simplified":return wp;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 oc{rules;compiled=[];cache=new Map;constructor(e={rules:[]}){if(this.rules=[],e.includeDefaults!==!1)this.rules.push(...gp);if(e.presets)for(let t of e.presets)this.rules.push(...Ep(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],n=typeof i.pattern==="string"?new RegExp(i.pattern.replace(vp,"\\$&"),i.global?"g":""):i.pattern;e[t]={rule:i,regex:n}}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":""}`,n=this.cache.get(i);if(n!==void 0)return n;let r=e,o=null;for(let s=0;s<this.compiled.length;s++){let{rule:a,regex:c}=this.compiled[s];if(a.condition){if(!o)o={type:e,...t};if(!a.condition(o))continue}if(c.lastIndex=0,c.test(r)){if(c.lastIndex=0,r=r.replace(c,a.replacement),c.lastIndex=0,!a.global)break}}if(this.cache.size>=nc){let s=Math.ceil(nc*0.1),a=0;for(let c of this.cache.keys()){if(a++>=s)break;this.cache.delete(c)}}return this.cache.set(i,r),r}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 n=typeof i.pattern==="string"?i.pattern:i.pattern.source;if(e instanceof RegExp)e.lastIndex=0;return typeof e==="string"?n!==e:!e.test(n)}),this.recompile(),this.cache.clear(),t-this.rules.length}clearCache(){this.cache.clear()}getRules(){return this.rules}}function Kr(e={rules:[]}){return new oc(e)}function sc(e,t,i={}){return e.replace(/:\s*([^;,)\]}]+)/g,(n,r)=>`: ${t.map(r.trim(),i)}`)}var gp,yp,Cp,wp,vp,nc=2048,P0,k0;var ac=ue(()=>{gp=[{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}],yp=[{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}],Cp=[{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}],wp=[{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}];vp=/[.*+?^${}()|[\]\\]/g;P0=Kr({rules:[]}),k0=Kr({rules:[],presets:["strict"]})});var lc;var cc=ue(()=>{lc=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 fc(e,t={strings:!0}){let i="",n=0;while(n<e.length){let r=e.slice(n,n+2);if(r==="//"){let s=e.indexOf(`
192
- `,n),a=s===-1?e.length:s;i+=" ".repeat(a-n),n=a;continue}if(r==="/*"){let s=e.indexOf("*/",n+2),a=s===-1?e.length:s+2;for(let c=n;c<a;c++)i+=e[c]===`
183
+ `)}function up(e,t){let i=new RegExp(`\\n{${t+2},}`,"g");return e.replace(i,`
184
+ `.repeat(t+1))}function hp(e){return`${e.replace(/\s+$/,"")}
185
+ `}function dp(e,t){let{style:i="spaces",size:n=2}=t,r=i==="tabs"?"\t":" ".repeat(n),o=e.split(`
186
+ `),s=[];for(let l of o){let c=l.match(/^([\t ]*)(.*)$/);if(!c){s.push(l);continue}let[,f,u]=c;if(!u){s.push("");continue}let a=f.replace(/\t/g," "),m=Math.floor(a.length/2);s.push(r.repeat(m)+u)}return s.join(`
187
+ `)}function pp(e,t){let{groups:i=lp,separateGroups:n=!0,alphabetize:r=!0}=t,o=e.split(`
188
+ `),s=[],l=[],c=-1;for(let w=0;w<o.length;w++){let C=o[w],A=tc(C);if(A)s.push({line:C,source:A.source,group:A.group,isType:A.isType}),c=w;else if(s.length>0&&C.trim()==="")continue;else if(s.length>0||C.trim()!==""){if(s.length===0||w>c+1)l.push(C)}}if(s.length===0)return e;let f=new Map;for(let w of i)f.set(w,[]);for(let w of s)(f.get(w.group)||f.get("external")||[]).push(w);if(r)for(let[,w]of f)w.sort((C,A)=>{if(C.isType!==A.isType)return C.isType?1:-1;return C.source.localeCompare(A.source)});let u=[],a=null;for(let w of i){let C=f.get(w)||[];if(C.length===0)continue;if(n&&a!==null)u.push("");for(let A of C)u.push(A.line);a=w}let m=o.slice(0,o.findIndex((w)=>tc(w)!==null)),y=l;while(y.length>0&&y[0].trim()==="")y.shift();return[...m,...u,"",...y].join(`
189
+ `)}function tc(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:ic(o[1]),isType:!1};return null}let n=!!i[1],r=i[2];return{source:r,group:n?"type":ic(r),isType:n}}function ic(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 mp(e,t){let{kinds:i=ap,alphabetize:n=!1,groupExports:r=!0}=t,o=e.split(`
190
+ `),s=[],l=[],c=[],f=null,u=0,a=!0,m=!1,y=[];for(let A=0;A<o.length;A++){let k=o[A],W=k.trim(),B=u,T=W.startsWith("///"),D=B===0&&!T&&(W.startsWith("//")||W.startsWith("/*"));if(m||D){if(y.push(k),!m&&W.startsWith("/*")&&!W.includes("*/"))m=!0;else if(m&&W.includes("*/"))m=!1;continue}if(B===0&&y.length>0&&W===""){y.push(k);continue}u+=(k.match(/\{/g)||[]).length,u-=(k.match(/\}/g)||[]).length;let N=gp(W);if(a&&N&&N.kind!=="import"&&!W.startsWith("//")&&!W.startsWith("/*"))a=!1;if(a){if(y.length>0){if(N?.kind==="import"||!N)l.push(...y),y.length=0}l.push(k);continue}if(N&&u<=1){if(f)s.push(f);f={lines:y.length>0?[...y,k]:[k],kind:N.kind,name:N.name,isExport:N.isExport},y.length=0}else if(f)f.lines.push(k);else{if(W==="")continue;c.push(k)}}if(f)s.push(f);if(y.length>0)c.push(...y);s.sort((A,k)=>{if(r&&A.isExport!==k.isExport)return A.isExport?-1:1;let W=i.indexOf(A.kind),B=i.indexOf(k.kind),T=W>=0?W:i.length,D=B>=0?B:i.length;if(T!==D)return T-D;if(n)return A.name.localeCompare(k.name);return 0});let w=[...l],C=null;for(let A of s){if(C!==null&&A.kind!==C)w.push("");w.push(...A.lines),C=A.kind}if(c.length>0)w.push(""),w.push(...c);return w.join(`
191
+ `)}function gp(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 ap,lp;var nc=de(()=>{ap=["import","type","interface","enum","class","function","variable","export","module","namespace","unknown"],lp=["builtin","external","scoped","internal","parent","sibling","index","type"]});function Ep(e){switch(e){case"strict":return Cp;case"readonly":return wp;case"simplified":return bp;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 sc{rules;compiled=[];cache=new Map;constructor(e={rules:[]}){if(this.rules=[],e.includeDefaults!==!1)this.rules.push(...yp);if(e.presets)for(let t of e.presets)this.rules.push(...Ep(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],n=typeof i.pattern==="string"?new RegExp(i.pattern.replace(vp,"\\$&"),i.global?"g":""):i.pattern;e[t]={rule:i,regex:n}}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":""}`,n=this.cache.get(i);if(n!==void 0)return n;let r=e,o=null;for(let s=0;s<this.compiled.length;s++){let{rule:l,regex:c}=this.compiled[s];if(l.condition){if(!o)o={type:e,...t};if(!l.condition(o))continue}if(c.lastIndex=0,c.test(r)){if(c.lastIndex=0,r=r.replace(c,l.replacement),c.lastIndex=0,!l.global)break}}if(this.cache.size>=oc){let s=Math.ceil(oc*0.1),l=0;for(let c of this.cache.keys()){if(l++>=s)break;this.cache.delete(c)}}return this.cache.set(i,r),r}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 n=typeof i.pattern==="string"?i.pattern:i.pattern.source;if(e instanceof RegExp)e.lastIndex=0;return typeof e==="string"?n!==e:!e.test(n)}),this.recompile(),this.cache.clear(),t-this.rules.length}clearCache(){this.cache.clear()}getRules(){return this.rules}}function Kr(e={rules:[]}){return new sc(e)}function ac(e,t,i={}){return e.replace(/:\s*([^;,)\]}]+)/g,(n,r)=>`: ${t.map(r.trim(),i)}`)}var yp,Cp,wp,bp,vp,oc=2048,k0,M0;var lc=de(()=>{yp=[{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}],Cp=[{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}],wp=[{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}],bp=[{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}];vp=/[.*+?^${}()|[\]\\]/g;k0=Kr({rules:[]}),M0=Kr({rules:[],presets:["strict"]})});var cc;var fc=de(()=>{cc=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 uc(e,t={strings:!0}){let i="",n=0;while(n<e.length){let r=e.slice(n,n+2);if(r==="//"){let s=e.indexOf(`
192
+ `,n),l=s===-1?e.length:s;i+=" ".repeat(l-n),n=l;continue}if(r==="/*"){let s=e.indexOf("*/",n+2),l=s===-1?e.length:s+2;for(let c=n;c<l;c++)i+=e[c]===`
193
193
  `?`
194
- `:" ";n=a;continue}let o=e[n];if(t.strings&&(o==='"'||o==="'"||o==="`")){let s=o;i+=" ",n++;while(n<e.length){if(e[n]==="\\"){i+=" ",n+=2;continue}if(e[n]===s){i+=" ",n++;break}i+=e[n]===`
194
+ `:" ";n=l;continue}let o=e[n];if(t.strings&&(o==='"'||o==="'"||o==="`")){let s=o;i+=" ",n++;while(n<e.length){if(e[n]==="\\"){i+=" ",n+=2;continue}if(e[n]===s){i+=" ",n++;break}i+=e[n]===`
195
195
  `?`
196
- `:" ",n++}continue}i+=o,n++}return i}function Sp(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 n of i)for(let r of e.matchAll(n))t.add(r[1]);return t}function $p(e){let t=new Set;for(let i of e.matchAll(/\bimport\s+(?:type\s+)?([\s\S]*?)\s+from\s*['"`]/g)){let n=i[1],r=/\*\s*as\s+([A-Za-z_$][\w$]*)/.exec(n);if(r)t.add(r[1]);let o=n.split("{")[0].replace(/\*\s*as\s+[A-Za-z_$][\w$]*/,"");for(let a of o.split(",")){let c=a.trim();if(/^[A-Za-z_$][\w$]*$/.test(c))t.add(c)}let s=/\{([\s\S]*?)\}/.exec(n);if(s)for(let a of s[1].split(",")){let c=a.trim().replace(/^type\s+/,"");if(!c)continue;let f=/\bas\s+([A-Za-z_$][\w$]*)$/.exec(c);t.add(f?f[1]:c.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 Ap(e){let t=new Set,i=(r)=>{for(let o of r.split(",")){let s=o.trim().split(/\s+|=/)[0]?.trim();if(s&&/^[A-Za-z_$][\w$]*$/.test(s))t.add(s)}},n=/\b(?:type|interface|class|function)\s+[A-Za-z_$][\w$]*\s*<([^<>]*(?:<[^<>]*>[^<>]*)*)>/g;for(let r of e.matchAll(n))i(r[1]);for(let r of e.matchAll(/(?:\b[A-Za-z_$][\w$]*)?\s*<([^<>()]*)>\s*\(/g))i(r[1]);for(let r of e.matchAll(/\binfer\s+([A-Za-z_$][\w$]*)/g))t.add(r[1]);for(let r of e.matchAll(/\[\s*([A-Za-z_$][\w$]*)\s+in\b/g))t.add(r[1]);return t}function xp(e){let t=new Map,i=(r)=>{let o=1;for(let s=0;s<r&&s<e.length;s++)if(e.charCodeAt(s)===10)o++;return o},n=(r,o,s)=>{for(let a of r.matchAll(/\b([A-Z][\w$]*)\b/g)){let c=a[1];if(t.has(c))continue;let f=r.slice(a.index+c.length);if(/^\s*\??:/.test(f))continue;t.set(c,{line:i(o),context:s.trim().slice(0,120)})}};for(let r of e.matchAll(/\btype\s+[A-Za-z_$][\w$]*\s*(?:<[^=]*?>)?\s*=([^;]*)/g))n(r[1],r.index+r[0].indexOf("="),r[0]);for(let r of e.matchAll(/\b(?:extends|implements)\s+([^{;]*)/g))n(r[1],r.index,r[0]);for(let r of e.matchAll(/:\s*([^;,){}\n=]+)/g))n(r[1],r.index,r[0]);for(let r of e.matchAll(/<([^<>()]*)>/g))n(r[1],r.index,r[0]);return t}function uc(e){let t=fc(e),i=fc(e,{strings:!1}),n=new Set([...Sp(t),...$p(i),...Ap(t),...lc,...bp]),r=[];for(let[o,s]of xp(t)){if(n.has(o))continue;if(new RegExp(`[\\w$]\\s*\\.\\s*${o}\\b`).test(t))continue;r.push({name:o,line:s.line,context:s.context})}return r.sort((o,s)=>o.line-s.line||o.name.localeCompare(s.name))}var bp;var hc=ue(()=>{cc();bp=new Set(["This","True","False","Null","Undefined","Void","Never","Any","Unknown","Object","Infinity","NaN"])});function Dt(e,t){let i=1,n=1;for(let r=0;r<t;r++)if(e.charCodeAt(r)===10)i++,n=1;else n++;return{line:i,column:n}}function pc(e){let t=[],i=[],n=[],r={")":"(","]":"[","}":"{"},o=0,s=0,a=-1;for(let f=0;f<e.length;f++){let u=e.charCodeAt(f),l=e.charCodeAt(f+1);if(a!==-1){if(u===42&&l===47)i.push({start:a,end:f+2}),a=-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&&l===42){a=f,f++;continue}if(u===47&&l===47){let y=f;while(f<e.length&&e.charCodeAt(f)!==10)f++;i.push({start:y,end:f});continue}if(u===39||u===34||u===96){o=u,s=f;continue}let m=e[f];if(m==="("||m==="["||m==="{")n.push({char:m,offset:f});else if(r[m]){let y=n.pop();if(!y||y.char!==r[m])t.push({...Dt(e,f),message:`Unexpected closing delimiter ${m}`,code:"DTSX1004"})}}if(o)t.push({...Dt(e,s),message:"Unterminated string literal",code:"DTSX1002"});if(a!==-1)t.push({...Dt(e,a),message:"Unterminated block comment",code:"DTSX1003"});for(let f of n)t.push({...Dt(e,f.offset),message:`Unclosed delimiter ${f.char}`,code:"DTSX1001"});let c=[[/\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 c)for(let l of e.matchAll(f)){if(i.some((m)=>l.index>=m.start&&l.index<m.end))continue;t.push({...Dt(e,l.index),message:u,code:"DTSX1005"})}for(let f of e.matchAll(/\btype\s*(?=[{=])/g)){if(i.some((l)=>f.index>=l.start&&f.index<l.end))continue;let u=e.slice(0,f.index).trimEnd();if(u.endsWith("import")||u.endsWith("export"))continue;t.push({...Dt(e,f.index),message:"Declaration name expected",code:"DTSX1005"})}return t.push(...Op(e,i)),t.sort((f,u)=>f.line-u.line||f.column-u.column)}function Op(e,t){let i=[],n=(r)=>t.some((o)=>r>=o.start&&r<o.end);for(let r of e.matchAll(/\b(import|export)\s+(?:type\s+)?\{/g)){let o=r.index;if(n(o))continue;let s=o+r[0].length-1,a=-1;for(let u=s+1;u<e.length;u++){if(n(u))continue;let l=e[u];if(l==="{"){a=-2;break}if(l==="}"){a=u;break}}if(a<0)continue;let c=e.slice(s+1,a);if(!c.trim())continue;let f=s+1;for(let u of c.split(",")){let l=u.trim();if(l){let m=f+u.indexOf(l);if(l.includes(";"))i.push({...Dt(e,m),message:`Unexpected ';' in ${r[1]} clause \u2014 specifiers are separated by ','`,code:"DTSX1006"});else if(!Tp.test(l))i.push({...Dt(e,m),message:`Invalid ${r[1]} specifier '${l}'`,code:"DTSX1006"})}f+=u.length+1}}return i}var dc,Tp;var mc=ue(()=>{dc=String.raw`(?:[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*|'[^']*'|"[^"]*")`,Tp=new RegExp(`^(?:type\\s+)?${dc}(?:\\s+as\\s+${dc})?$`,"u")});import{join as _0,resolve as Rp}from"path";import Pp from"process";function Bo(){return`${String.fromCharCode(47,47,35)} sourceMappingURL=`}async function Hr(e,t,i="lf"){let n=t.replace(/\r\n/g,`
196
+ `:" ",n++}continue}i+=o,n++}return i}function $p(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 n of i)for(let r of e.matchAll(n))t.add(r[1]);return t}function xp(e){let t=new Set;for(let i of e.matchAll(/\bimport\s+(?:type\s+)?([\s\S]*?)\s+from\s*['"`]/g)){let n=i[1],r=/\*\s*as\s+([A-Za-z_$][\w$]*)/.exec(n);if(r)t.add(r[1]);let o=n.split("{")[0].replace(/\*\s*as\s+[A-Za-z_$][\w$]*/,"");for(let l of o.split(",")){let c=l.trim();if(/^[A-Za-z_$][\w$]*$/.test(c))t.add(c)}let s=/\{([\s\S]*?)\}/.exec(n);if(s)for(let l of s[1].split(",")){let c=l.trim().replace(/^type\s+/,"");if(!c)continue;let f=/\bas\s+([A-Za-z_$][\w$]*)$/.exec(c);t.add(f?f[1]:c.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 Ap(e){let t=new Set,i=(r)=>{for(let o of r.split(",")){let s=o.trim().split(/\s+|=/)[0]?.trim();if(s&&/^[A-Za-z_$][\w$]*$/.test(s))t.add(s)}},n=/\b(?:type|interface|class|function)\s+[A-Za-z_$][\w$]*\s*<([^<>]*(?:<[^<>]*>[^<>]*)*)>/g;for(let r of e.matchAll(n))i(r[1]);for(let r of e.matchAll(/(?:\b[A-Za-z_$][\w$]*)?\s*<([^<>()]*)>\s*\(/g))i(r[1]);for(let r of e.matchAll(/\binfer\s+([A-Za-z_$][\w$]*)/g))t.add(r[1]);for(let r of e.matchAll(/\[\s*([A-Za-z_$][\w$]*)\s+in\b/g))t.add(r[1]);return t}function Tp(e){let t=new Map,i=(r)=>{let o=1;for(let s=0;s<r&&s<e.length;s++)if(e.charCodeAt(s)===10)o++;return o},n=(r,o,s)=>{for(let l of r.matchAll(/\b([A-Z][\w$]*)\b/g)){let c=l[1];if(t.has(c))continue;let f=r.slice(l.index+c.length);if(/^\s*\??:/.test(f))continue;t.set(c,{line:i(o),context:s.trim().slice(0,120)})}};for(let r of e.matchAll(/\btype\s+[A-Za-z_$][\w$]*\s*(?:<[^=]*?>)?\s*=([^;]*)/g))n(r[1],r.index+r[0].indexOf("="),r[0]);for(let r of e.matchAll(/\b(?:extends|implements)\s+([^{;]*)/g))n(r[1],r.index,r[0]);for(let r of e.matchAll(/:\s*([^;,){}\n=]+)/g))n(r[1],r.index,r[0]);for(let r of e.matchAll(/<([^<>()]*)>/g))n(r[1],r.index,r[0]);return t}function hc(e){let t=uc(e),i=uc(e,{strings:!1}),n=new Set([...$p(t),...xp(i),...Ap(t),...cc,...Sp]),r=[];for(let[o,s]of Tp(t)){if(n.has(o))continue;if(new RegExp(`[\\w$]\\s*\\.\\s*${o}\\b`).test(t))continue;r.push({name:o,line:s.line,context:s.context})}return r.sort((o,s)=>o.line-s.line||o.name.localeCompare(s.name))}var Sp;var dc=de(()=>{fc();Sp=new Set(["This","True","False","Null","Undefined","Void","Never","Any","Unknown","Object","Infinity","NaN"])});function Dt(e,t){let i=1,n=1;for(let r=0;r<t;r++)if(e.charCodeAt(r)===10)i++,n=1;else n++;return{line:i,column:n}}function mc(e){let t=[],i=[],n=[],r={")":"(","]":"[","}":"{"},o=0,s=0,l=-1;for(let f=0;f<e.length;f++){let u=e.charCodeAt(f),a=e.charCodeAt(f+1);if(l!==-1){if(u===42&&a===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&&a===42){l=f,f++;continue}if(u===47&&a===47){let y=f;while(f<e.length&&e.charCodeAt(f)!==10)f++;i.push({start:y,end:f});continue}if(u===39||u===34||u===96){o=u,s=f;continue}let m=e[f];if(m==="("||m==="["||m==="{")n.push({char:m,offset:f});else if(r[m]){let y=n.pop();if(!y||y.char!==r[m])t.push({...Dt(e,f),message:`Unexpected closing delimiter ${m}`,code:"DTSX1004"})}}if(o)t.push({...Dt(e,s),message:"Unterminated string literal",code:"DTSX1002"});if(l!==-1)t.push({...Dt(e,l),message:"Unterminated block comment",code:"DTSX1003"});for(let f of n)t.push({...Dt(e,f.offset),message:`Unclosed delimiter ${f.char}`,code:"DTSX1001"});let c=[[/\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 c)for(let a of e.matchAll(f)){if(i.some((m)=>a.index>=m.start&&a.index<m.end))continue;t.push({...Dt(e,a.index),message:u,code:"DTSX1005"})}for(let f of e.matchAll(/\btype\s*(?=[{=])/g)){if(i.some((a)=>f.index>=a.start&&f.index<a.end))continue;let u=e.slice(0,f.index).trimEnd();if(u.endsWith("import")||u.endsWith("export"))continue;t.push({...Dt(e,f.index),message:"Declaration name expected",code:"DTSX1005"})}return t.push(...Rp(e,i)),t.sort((f,u)=>f.line-u.line||f.column-u.column)}function Rp(e,t){let i=[],n=(r)=>t.some((o)=>r>=o.start&&r<o.end);for(let r of e.matchAll(/\b(import|export)\s+(?:type\s+)?\{/g)){let o=r.index;if(n(o))continue;let s=o+r[0].length-1,l=-1;for(let u=s+1;u<e.length;u++){if(n(u))continue;let a=e[u];if(a==="{"){l=-2;break}if(a==="}"){l=u;break}}if(l<0)continue;let c=e.slice(s+1,l);if(!c.trim())continue;let f=s+1;for(let u of c.split(",")){let a=u.trim();if(a){let m=f+u.indexOf(a);if(a.includes(";"))i.push({...Dt(e,m),message:`Unexpected ';' in ${r[1]} clause \u2014 specifiers are separated by ','`,code:"DTSX1006"});else if(!Op.test(a))i.push({...Dt(e,m),message:`Invalid ${r[1]} specifier '${a}'`,code:"DTSX1006"})}f+=u.length+1}}return i}var pc,Op;var gc=de(()=>{pc=String.raw`(?:[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*|'[^']*'|"[^"]*")`,Op=new RegExp(`^(?:type\\s+)?${pc}(?:\\s+as\\s+${pc})?$`,"u")});import{join as V0,resolve as Pp}from"path";import kp from"process";function Bo(){return`${String.fromCharCode(47,47,35)} sourceMappingURL=`}async function Hr(e,t,i="lf"){let n=t.replace(/\r\n/g,`
197
197
  `);if(!n.endsWith(`
198
198
  `))n+=`
199
199
  `;if(i==="crlf")n=n.replace(/\n/g,`\r
200
- `);await as(e,n)}async function gc(e){try{let t=e?.cwd||Pp.cwd();return(await mi(Rp(t,e?.tsconfigPath||"tsconfig.json"),{allowCircular:!0}))?.isolatedDeclarations??!1}catch{return!1}}function yc(e,t){let i={isValid:!0,errors:[]};for(let n of pc(e))i.errors.push({line:n.line,column:n.column,message:n.message,code:n.code});for(let n of uc(e))i.errors.push({line:n.line,column:1,message:`'${n.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: ${n.context}`,code:"dangling-type-reference"});return i.isValid=i.errors.length===0,i}function Cc(e,t,i){if(e===t)return"";let n=e.split(`
200
+ `);await ls(e,n)}async function yc(e){try{let t=e?.cwd||kp.cwd();return(await mi(Pp(t,e?.tsconfigPath||"tsconfig.json"),{allowCircular:!0}))?.isolatedDeclarations??!1}catch{return!1}}function Cc(e,t){let i={isValid:!0,errors:[]};for(let n of mc(e))i.errors.push({line:n.line,column:n.column,message:n.message,code:n.code});for(let n of hc(e))i.errors.push({line:n.line,column:1,message:`'${n.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: ${n.context}`,code:"dangling-type-reference"});return i.isValid=i.errors.length===0,i}function wc(e,t,i){if(e===t)return"";let n=e.split(`
201
201
  `),r=t.split(`
202
- `),o=new Map,s=new Map;for(let u=0;u<n.length;u++)o.set(n[u],(o.get(n[u])??0)+1);for(let u=0;u<r.length;u++)s.set(r[u],(s.get(r[u])??0)+1);let a=[],c=[];for(let[u,l]of o){let m=l-(s.get(u)??0);for(let y=0;y<m;y++)a.push(u)}for(let[u,l]of s){let m=l-(o.get(u)??0);for(let y=0;y<m;y++)c.push(u)}if(a.length===0&&c.length===0)return"";let f=[`--- ${i}`,`+++ ${i}`];for(let u=0;u<a.length;u++)f.push(`- ${a[u]}`);for(let u=0;u<c.length;u++)f.push(`+ ${c[u]}`);return f.join(`
203
- `)}function wc(e,t,i,n){let r=e.split(`
204
- `),o=[];function s(l){let m="",y=l<0?-l<<1|1:l<<1;do{let w=y&31;if(y>>>=5,y>0)w|=32;m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[w]}while(y>0);return m}let a=0,c=0,f=0,u=n.split(`
205
- `).length;for(let l=0;l<r.length;l++){if(r[l].trim()===""){o.push("");continue}a=0;let m=Math.min(l,u-1),y=[],w=0-a,C=0,x=m-c,k=0-f;y.push(s(w)+s(C)+s(x)+s(k)),a=0,c=m,f=0,o.push(y.join(","))}return{version:3,file:t,sourceRoot:"",sources:[i],sourcesContent:[n],mappings:o.join(";")}}function Ec(e,t){return`${e}
202
+ `),o=new Map,s=new Map;for(let u=0;u<n.length;u++)o.set(n[u],(o.get(n[u])??0)+1);for(let u=0;u<r.length;u++)s.set(r[u],(s.get(r[u])??0)+1);let l=[],c=[];for(let[u,a]of o){let m=a-(s.get(u)??0);for(let y=0;y<m;y++)l.push(u)}for(let[u,a]of s){let m=a-(o.get(u)??0);for(let y=0;y<m;y++)c.push(u)}if(l.length===0&&c.length===0)return"";let f=[`--- ${i}`,`+++ ${i}`];for(let u=0;u<l.length;u++)f.push(`- ${l[u]}`);for(let u=0;u<c.length;u++)f.push(`+ ${c[u]}`);return f.join(`
203
+ `)}function bc(e,t,i,n){let r=e.split(`
204
+ `),o=[];function s(a){let m="",y=a<0?-a<<1|1:a<<1;do{let w=y&31;if(y>>>=5,y>0)w|=32;m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[w]}while(y>0);return m}let l=0,c=0,f=0,u=n.split(`
205
+ `).length;for(let a=0;a<r.length;a++){if(r[a].trim()===""){o.push("");continue}l=0;let m=Math.min(a,u-1),y=[],w=0-l,C=0,A=m-c,k=0-f;y.push(s(w)+s(C)+s(A)+s(k)),l=0,c=m,f=0,o.push(y.join(","))}return{version:3,file:t,sourceRoot:"",sources:[i],sourcesContent:[n],mappings:o.join(";")}}function Ec(e,t){return`${e}
206
206
  ${Bo()}${t}
207
- `}var vc=ue(()=>{Bi();dn();hc();mc()});function Ip(e){let t=[],i=0;for(let n=0;n<=e.length;n++)if(n===e.length||e[n]===`
208
- `){let r=i,o=n;while(r<o&&(e[r]===" "||e[r]==="\t"||e[r]==="\r"))r++;while(o>r&&(e[o-1]===" "||e[o-1]==="\t"||e[o-1]==="\r"))o--;let s=e.slice(r,o);if(i=n+1,s.startsWith("///")){if(s.indexOf("<")===-1)continue;if(kp.test(s)||Mp.test(s)||Dp.test(s))t.push(s)}else if(s===""||s.startsWith("//"))continue;else break}return t}function Np(e){if(e.includes(`
207
+ `}var vc=de(()=>{Bi();dn();dc();gc()});function Np(e){let t=[],i=0;for(let n=0;n<=e.length;n++)if(n===e.length||e[n]===`
208
+ `){let r=i,o=n;while(r<o&&(e[r]===" "||e[r]==="\t"||e[r]==="\r"))r++;while(o>r&&(e[o-1]===" "||e[o-1]==="\t"||e[o-1]==="\r"))o--;let s=e.slice(r,o);if(i=n+1,s.startsWith("///")){if(s.indexOf("<")===-1)continue;if(Mp.test(s)||Dp.test(s)||Ip.test(s))t.push(s)}else if(s===""||s.startsWith("//"))continue;else break}return t}function Fp(e){if(e.includes(`
209
209
  `))return`/**
210
210
  * ${e}
211
211
  */
212
212
  `;return`/** ${e} */
213
- `}function Fp(e){let t=e.indexOf("{");if(t===-1)return-1;let i=e.indexOf("<");if(i===-1||i>t)return t;let n=0,r=!1,o="";for(let s=0;s<e.length;s++){let a=e[s],c=s>0?e[s-1]:"";if(!r&&(a==='"'||a==="'"||a==="`"))r=!0,o=a;else if(r&&a===o&&c!=="\\")r=!1;if(!r){if(a==="<")n++;else if(a===">")n--;else if(a==="{"&&n===0)return s}}return-1}function Lp(e,t=!0){return $t(e.leadingComments,t)+e.text}function bc(e,t=!0){let i=$t(e.leadingComments,t);if(e.typeAnnotation&&!e.value)return i+e.text;let n="";if(e.isExported)n+="export ";n+="declare ";let r=e.modifiers?.[0]||"const";n+=`${r} `,n+=e.name;let{typeAnnotation:o,value:s}=e,a=!o&&s?Gr(s):null;if(a)o=a;else if(!o&&s&&s.trim().endsWith("as const"))o=Ie(s,!0);else if(!o&&s&&r==="const"){let f=s.trim(),u=f.startsWith("{")||f.startsWith("[");if(u)Mo();o=Ie(s,!u)}else if(!o&&s)o=Ie(s,r==="const");if(!o)o="unknown";let c="";if(t&&s&&!e.typeAnnotation&&!s.trim().endsWith("as const")){let f=s.trim();if(r!=="const"){if((o==="string"||o==="number"||o==="boolean")&&f.length>0)c=`@defaultValue ${f}`}else if(f.startsWith("{")||f.startsWith("[")){let u=Do();if(u)if(u.includes(`
213
+ `}function Lp(e){let t=e.indexOf("{");if(t===-1)return-1;let i=e.indexOf("<");if(i===-1||i>t)return t;let n=0,r=!1,o="";for(let s=0;s<e.length;s++){let l=e[s],c=s>0?e[s-1]:"";if(!r&&(l==='"'||l==="'"||l==="`"))r=!0,o=l;else if(r&&l===o&&c!=="\\")r=!1;if(!r){if(l==="<")n++;else if(l===">")n--;else if(l==="{"&&n===0)return s}}return-1}function Wp(e,t=!0){return $t(e.leadingComments,t)+e.text}function Sc(e,t=!0){let i=$t(e.leadingComments,t);if(e.typeAnnotation&&!e.value)return i+e.text;let n="";if(e.isExported)n+="export ";n+="declare ";let r=e.modifiers?.[0]||"const";n+=`${r} `,n+=e.name;let{typeAnnotation:o,value:s}=e,l=!o&&s?Gr(s):null;if(l)o=l;else if(!o&&s&&s.trim().endsWith("as const"))o=Ie(s,!0);else if(!o&&s&&r==="const"){let f=s.trim(),u=f.startsWith("{")||f.startsWith("[");if(u)Mo();o=Ie(s,!u)}else if(!o&&s)o=Ie(s,r==="const");if(!o)o="unknown";let c="";if(t&&s&&!e.typeAnnotation&&!s.trim().endsWith("as const")){let f=s.trim();if(r!=="const"){if((o==="string"||o==="number"||o==="boolean")&&f.length>0)c=`@defaultValue ${f}`}else if(f.startsWith("{")||f.startsWith("[")){let u=Do();if(u)if(u.includes(`
214
214
  `))c=`@defaultValue
215
215
  * \`\`\`ts
216
216
  ${u.split(`
217
- `).map((l)=>` * ${l}`).join(`
217
+ `).map((a)=>` * ${a}`).join(`
218
218
  `)}
219
- * \`\`\``;else c=`@defaultValue \`${u}\``}}else if(t&&s&&e.typeAnnotation&&Bl(e.typeAnnotation)){Mo();let f=s.trim(),u=f.endsWith("as const")?f.slice(0,-8).trim():f;Ie(u,!1);let l=Do();if(l)if(l.includes(`
219
+ * \`\`\``;else c=`@defaultValue \`${u}\``}}else if(t&&s&&e.typeAnnotation&&Gl(e.typeAnnotation)){Mo();let f=s.trim(),u=f.endsWith("as const")?f.slice(0,-8).trim():f;Ie(u,!1);let a=Do();if(a)if(a.includes(`
220
220
  `))c=`@defaultValue
221
221
  * \`\`\`ts
222
- ${l.split(`
222
+ ${a.split(`
223
223
  `).map((m)=>` * ${m}`).join(`
224
224
  `)}
225
- * \`\`\``;else c=`@defaultValue \`${l}\``}if(c=Po(c),n+=`: ${o};`,c&&i&&i.includes("@defaultValue"))c="";if(c&&i){let f=i.trimEnd(),u=f.lastIndexOf("*/");if(u!==-1){let l=f.slice(0,u).trimEnd();if(l.startsWith("/** ")&&!l.includes(`
226
- `))l=`/**
227
- * ${l.slice(4)}`;return`${l}
225
+ * \`\`\``;else c=`@defaultValue \`${a}\``}if(c=Po(c),n+=`: ${o};`,c&&i&&i.includes("@defaultValue"))c="";if(c&&i){let f=i.trimEnd(),u=f.lastIndexOf("*/");if(u!==-1){let a=f.slice(0,u).trimEnd();if(a.startsWith("/** ")&&!a.includes(`
226
+ `))a=`/**
227
+ * ${a.slice(4)}`;return`${a}
228
228
  * ${c}
229
229
  */
230
230
  `+n}return`/**
231
231
  * ${f.replace(/^\/\/\s*/,"")}
232
232
  * ${c}
233
233
  */
234
- ${n}`}if(c)return`${Np(c)}${n}`;return i+n}function Wp(e,t=!0){let i=$t(e.leadingComments,t),n=e.text;if(n.startsWith("export declare interface")||n.startsWith("declare interface"))return i+n;let r="";if(e.isExported)r+="export ";if(r+="declare interface ",r+=e.name,e.generics)r+=e.generics;if(e.extends)r+=` extends ${e.extends}`;let o=Fp(e.text);if(o!==-1)r+=` ${e.text.slice(o)}`;else r+=" {}";return i+r}function Bp(e,t=!0){let i=$t(e.leadingComments,t);if(e.text.includes("{")&&e.text.includes("}")&&e.text.includes("from"))return i+e.text;let n="";if(e.isExported)n+="export ";if(!e.isExported&&!e.text.includes(" from "))n+="declare ";let r=e.text.indexOf("type ");if(r!==-1){let s=e.text.slice(r),a=s.length;while(a>0&&(s.charCodeAt(a-1)===59||s.charCodeAt(a-1)===32||s.charCodeAt(a-1)===10||s.charCodeAt(a-1)===13))a--;if(a<s.length)s=s.slice(0,a);n+=s}else{if(n+=`type ${e.name}`,e.generics)n+=e.generics;n+=" = any"}let o=n.trimEnd();if(!o.endsWith(";")&&!o.endsWith("}"))n+=";";return i+n}function Gp(e,t=!0){return $t(e.leadingComments,t)+e.text}function jp(e,t=!0){let i=$t(e.leadingComments,t),n="";if(e.isExported)n+="export ";if(n+="declare ",e.modifiers?.includes("const"))n+="const ";n+="enum ",n+=e.name;let r=e.text.indexOf("{");if(r!==-1)n+=` ${e.text.slice(r)}`;else n+=" {}";return i+n}function _p(e,t=!0){let i=$t(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 n="";if(e.isExported)n+="export ";if(!e.modifiers?.includes("declare"))n+="declare ";n+="namespace ",n+=e.name;let r=e.text.indexOf("{");if(r!==-1)n+=` ${e.text.slice(r)}`;else n+=" {}";return i+n}function Vp(e){let t=Bt.get(e);if(t)return Bt.delete(e),Bt.set(e,t),t;return null}function Sc(e,t){if(Bt.set(e,t),Bt.size>200){let i=0;for(let n of Bt.keys()){if(i++>=20)break;Bt.delete(n)}}}function Up(e){let t=e.indexOf(" from ");if(t===-1)return null;let i=e.slice(t+6).trim(),n=i[0];if(n!=='"'&&n!=="'")return null;let r=i.indexOf(n,1);if(r===-1)return null;let o=i.slice(1,r),s=e.slice(0,t).trim(),a=s.startsWith("import type ");if(s.startsWith("import "))s=s.slice(7).trim();if(s.startsWith("type "))s=s.slice(5).trim();let c=null,f=[],u=!1,l=s.indexOf("{"),m=s.lastIndexOf("}");if(l!==-1&&m!==-1){let y=s.slice(0,l).trim();if(y.endsWith(","))c=y.slice(0,-1).trim()||null;let w=s.slice(l+1,m),C=0;for(let x=0;x<=w.length;x++)if(x===w.length||w.charCodeAt(x)===44){let k=C,L=x;while(k<L&&(w.charCodeAt(k)===32||w.charCodeAt(k)===9||w.charCodeAt(k)===10))k++;while(L>k&&(w.charCodeAt(L-1)===32||w.charCodeAt(L-1)===9||w.charCodeAt(L-1)===10))L--;if(k<L)f.push(w.slice(k,L));C=x+1}}else{let y=s.trim();if(y.startsWith("* as "))c=y.slice(5).trim()||null,u=!0;else c=y||null}return{defaultName:c,namedItems:f,source:o,isTypeOnly:a,isNamespace:u}}function Kp(e){let t=Vp(e);if(t)return t;let i=[],n=e.indexOf(" from ");if(n===-1)return Sc(e,i),i;let r=e.slice(0,n).trim();if(r.startsWith("import "))r=r.slice(7).trim();if(r.startsWith("type "))r=r.slice(5).trim();let o=r.indexOf("{"),s=r.lastIndexOf("}");if(o!==-1&&s!==-1){let a=r.slice(0,o).trim();if(a.endsWith(",")){let f=a.slice(0,-1).trim();if(f)i.push(f)}else if(a&&!a.includes(","))i.push(a);let c=r.slice(o+1,s).split(",");for(let f=0;f<c.length;f++){let u=c[f].trim();if(!u)continue;if(u.startsWith("type "))u=u.slice(5).trim();let l=u.indexOf(" as ");if(l!==-1)u=u.slice(l+4).trim();if(u)i.push(u)}}else{let a=r.trim();if(a.startsWith("* as ")){let c=a.slice(5).trim();if(c)i.push(c)}else if(a)i.push(a)}return Sc(e,i),i}function $c(e,t){throw Error(t||`Unexpected value: ${e}`)}function Hp(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===95||e===36||e>127}function Ac(e){let t=new Set,i=0,n=e.length;while(i<n){let r=e.charCodeAt(i);if(r>=65&&r<=90||r>=97&&r<=122||r===95||r===36||r>127){let o=i;i++;while(i<n&&Hp(e.charCodeAt(i)))i++;t.add(e.substring(o,i))}else i++}return t}function Rc(e,t,i=!0,n=["bun"]){let r="",o=t.sourceCode;if(o){let v=0;while(v<o.length&&(o.charCodeAt(v)===32||o.charCodeAt(v)===9||o.charCodeAt(v)===10||o.charCodeAt(v)===13))v++;if(v<o.length-2&&o.charCodeAt(v)===47&&o.charCodeAt(v+1)===47&&o.charCodeAt(v+2)===47){let K=Ip(o);if(K.length>0)for(let oe=0;oe<K.length;oe++){if(r)r+=`
235
- `;r+=K[oe]}}}let s=[],a=[],c=[],f=[],u=[],l=[],m=[],y=[],w=[];for(let v of e){let K=v.kind;switch(K){case"import":s.push(v);break;case"function":a.push(v);break;case"variable":c.push(v);break;case"interface":f.push(v);break;case"type":u.push(v);break;case"class":l.push(v);break;case"enum":m.push(v);break;case"module":y.push(v);break;case"export":w.push(v);break;case"namespace":y.push(v);break;case"unknown":break;default:$c(K,`Unhandled declaration kind: ${K}`)}}let C=new Set,x=[],k=[],L=[],W=new Set;for(let v of w){let K=$t(v.leadingComments,i);if(v.text.startsWith("export default")){let oe=v.text.endsWith(";")?v.text:`${v.text};`;L.push(K+oe)}else{let oe=v.text.trim();if(!oe.endsWith(";"))oe+=";";let fe=oe.match(zp);if(fe){let ge=fe[1],De=0;for(let ie=0;ie<=ge.length;ie++)if(ie===ge.length||ge.charCodeAt(ie)===44){let le=De,ee=ie;while(le<ee&&ge.charCodeAt(le)<=32)le++;while(ee>le&&ge.charCodeAt(ee-1)<=32)ee--;if(le<ee)C.add(ge.slice(le,ee));De=ie+1}}let z=K+oe;if(!W.has(z))if(W.add(z),z.includes("export type"))x.push(z);else k.push(z)}}let T=new Map;if(s.length>0)for(let v of s){let K=Kp(v.text);for(let oe of K)T.set(oe,v)}let D=new Set;if(f.length>0){let v=[];for(let K of a)if(K.isExported)v.push(K.text);for(let K of l)v.push(K.text);for(let K of u)v.push(K.text);if(v.length>0){let K=Ac(v.join(`
236
- `));for(let oe of f)if(K.has(oe.name))D.add(oe.name)}}let I=[];if(s.length>0){let v=new Set,K=[];for(let z of a)if(z.isExported)K.push(z.text);for(let z of c)if(K.push(z.text),z.typeAnnotation)K.push(z.typeAnnotation);else if(z.isExported&&z.value)K.push(bc(z,!1));for(let z of f)if(z.isExported||D.has(z.name))K.push(z.text);for(let z of u)K.push(z.text);for(let z of l)K.push(z.text);for(let z of m)K.push(z.text);for(let z of y)K.push(z.text);for(let z of w)K.push(z.text);let oe=K.join(`
237
- `);if(oe&&T.size>0){let z=Ac(oe);for(let ge of T.keys())if(z.has(ge))v.add(ge)}for(let z of C)if(T.has(z))v.add(z);for(let z of s){if(z.isSideEffect){let J=z.text.trim(),te=J.endsWith(";")?J:`${J};`;I.push(te);continue}let ge=Up(z.text);if(!ge)continue;let{defaultName:De,namedItems:ie,source:le,isTypeOnly:ee,isNamespace:F}=ge,U=De?v.has(De):!1,q="",Z=0;for(let J=0;J<ie.length;J++){let te=ie[J],se=te.charCodeAt(0)===116&&te.startsWith("type ")?te.slice(5).trim():te.trim(),re=se.indexOf(" as ");if(re!==-1)se=se.slice(re+4).trim();if(v.has(se)){if(Z>0)q+=", ";q+=te,Z++}}if(U||Z>0){let J=ee?"import type ":"import ";if(U&&De)if(F)J+=`* as ${De}`;else J+=Z>0?`${De}, { ${q} }`:De;else if(Z>0)J+=`{ ${q} }`;J+=` from '${le}';`,I.push(J)}}let fe=n.length;if(I.length>1){if(xc!==n)xc=n,Tc=n.map((ie)=>`from '${ie}`),Oc=n.map((ie)=>`from "${ie}`);let z=Tc,ge=Oc,De=new Map;for(let ie of I){let le=fe;for(let ee=0;ee<n.length;ee++)if(ie.includes(z[ee])||ie.includes(ge[ee])){le=ee;break}De.set(ie,le)}I.sort((ie,le)=>{let ee=De.get(ie),F=De.get(le);return ee!==F?ee-F:ie.localeCompare(le)})}}for(let v=0;v<I.length;v++){if(r)r+=`
238
- `;r+=I[v]}for(let v=0;v<x.length;v++){if(r)r+=`
239
- `;r+=x[v]}let N=[a,c,f,u,l,m,y];for(let v=0;v<N.length;v++){let K=N[v];for(let oe=0;oe<K.length;oe++){let fe=K[oe],z="",ge=fe.kind;switch(ge){case"function":z=Lp(fe,i);break;case"variable":z=bc(fe,i);break;case"interface":z=Wp(fe,i);break;case"type":z=Bp(fe,i);break;case"class":z=Gp(fe,i);break;case"enum":z=jp(fe,i);break;case"module":case"namespace":z=_p(fe,i);break;case"import":case"export":case"unknown":break;default:$c(ge,`Unhandled declaration kind in processor: ${ge}`)}if(z){if(r)r+=`
240
- `;r+=z}}}for(let v=0;v<k.length;v++){if(r)r+=`
241
- `;r+=k[v]}for(let v=0;v<L.length;v++){if(r)r+=`
242
- `;r+=L[v]}if(!r&&(s.length>0||w.length>0))return"export {};";return r}var kp,Mp,Dp,Bt,zp,xc=null,Tc,Oc;var Pc=ue(()=>{Fo();kp=/^\/\/\/\s*<reference\s+(?:path|types|lib|no-default-lib)\s*=\s*["'][^"']+["']\s*\/>/,Mp=/^\/\/\/\s*<amd-module\s+name\s*=\s*["'][^"']+["']\s*\/>/,Dp=/^\/\/\/\s*<amd-dependency\s+path\s*=\s*["'][^"']+["']/;Bt=new Map;zp=/export\s+(?:type\s+)?\{\s*([^}]+)\s*\}/,Tc=[],Oc=[]});import{existsSync as kc}from"fs";import{mkdir as Mc,readdir as Jp,realpath as qp,rm as Yp}from"fs/promises";import{availableParallelism as Zp}from"os";import{basename as Uo,dirname as zr,extname as Xp,isAbsolute as Pi,parse as Qp,relative as Ge,resolve as Ze}from"path";function Fc(e){let t=Go.get(e);if(!t)t=xs(e),Go.set(e,t),t.catch(()=>Go.delete(e));return t}async function Dc(e,t,i,n,r,o=Hr){let s=Uo(e)||"output.d.ts",a=Ge(zr(e),t),c=`${s}.map`,f=i.lastIndexOf(`
243
- ${Bo()}`),u=f===-1?i:i.slice(0,f),l=wc(u,s,a,n),m=`${e}.map`;return await o(m,JSON.stringify(l)),Y.debug(` Generated source map: ${Ge(r,m)}`),c}async function Ko(e){let t=Date.now(),i={...fl,...e};if(i.logLevel)ln(i.logLevel);else if(i.verbose)ln("debug");let n=new Ur;if(i.plugins&&i.plugins.length>0){for(let T of i.plugins)n.register(T),Y.debug(`Registered plugin: ${T.name}`);i=await n.runOnStart(i)}if(await tm(i),i.isolatedDeclarations===void 0)i.isolatedDeclarations=await gc(i);let r=i.typeMappings?Kr(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:[]},a=0;Y.debug("Starting DTS generation..."),Y.debug(`Using ${s.generationMode} declaration generation path`),Y.debug("Config:",i);let c=await sm(i);om(i,c);let f=c.slice(),u=await Fc(i),l=null;if(i.autoIncludeReExports!==!1&&f.length>0){l=await Cn(f,{includeImports:!0,resolveSpecifier:u});let T=Ze(i.cwd,i.root),D=i.exclude||[],I=[];for(let N of l.reachable){if(f.includes(N))continue;if(!Vo(N))continue;if(N.endsWith(".d.ts"))continue;if(N.includes("node_modules"))continue;let v=i.outputStructure==="flat"&&c.some((K)=>u.isPackageLocal?.(K,N));if(!ki(N,T)&&!v){Y.warn(`Skipping auto-included source outside root: ${Ge(i.cwd,N)}`);continue}if(_o(N,D,T))continue;I.push(N)}if(I.length>0)f=[...f,...I],Y.debug(`Auto-included ${I.length} file(s) reached via relative re-exports`)}if(am(f,i),jo.set(i,new Set(f)),i.incremental){if(o=new $n(i,u.cacheKey?.(f)),i.clearCache){if(Y.debug("Clearing build cache..."),!i.dryRun)o.clear()}else if(o.load()){let T=o.getStats();Y.debug(`Loaded build cache with ${T.entries} entries`)}else Y.debug("No existing build cache found, starting fresh");if(!i.dryRun)Ls(i.cwd)}if(o&&!i.dryRun){let T=o.prune(new Set(f),i.cwd);if(T>0)Y.debug(`Pruned ${T} deleted files from cache`)}if(Y.debug(`Found ${f.length} TypeScript files`),i.progress&&f.length>0){let T=i.parallel?"parallel":"sequential";Y.info(`Processing ${f.length} files (${T})...`)}let m=new Map,y=new Map,w=async(T,D,I="lf")=>{y.set(T,{content:D,lineEnding:I})},C=async(T,D)=>{let I;try{let N=Mi(T,i),v=async(ee)=>{if(!i.diff)return;try{let F=await Ot(N),U=Cc(F,ee,Ge(i.cwd,N));if(U)Y.info(`
244
- ${U}`);else Y.debug(`[no changes] ${N}`)}catch{Y.info(`[new file] ${Ge(i.cwd,N)}`)}},K=(ee)=>{if(!i.validate)return 0;let F=yc(ee,N);if(F.isValid)return Y.debug(`[validation] ${N} - OK`),0;Y.warn(`[validation] ${Ge(i.cwd,N)} has ${F.errors.length} error(s):`);for(let U of F.errors){let q=` Line ${U.line}:${U.column}`;if(U.code)q+=` [${U.code}]`;if(q+=` - ${U.message}`,Y.warn(q),U.suggestion)Y.warn(` Suggestion: ${U.suggestion}`)}return F.errors.length},oe=(ee)=>{Y.info(`[dry-run] Would generate: ${N}`),Y.debug("--- Content preview ---"),Y.debug(ee.slice(0,500)+(ee.length>500?`
245
- ...`:"")),Y.debug("--- End preview ---")};if(o){let ee=o.getCachedIfValid(T,i.cwd);if(ee){if(i.bundle)m.set(T,ee);await v(ee);let F=K(ee);if(i.dryRun)oe(ee);else{if(i.declarationMap)I=D??await Ot(T),await Dc(N,T,ee,I,i.cwd,w);await w(N,ee,i.lineEnding)}return Y.debug(`[cached] ${Ge(i.cwd,N)}`),{success:!0,file:T,declarationCount:0,importCount:0,exportCount:0,cached:!0,validationErrorCount:F}}}I=D??await Ot(T);let{content:fe,declarationCount:z,importCount:ge,exportCount:De}=await fm(T,I,i,n,r);if(i.bundle)m.set(T,fe);let ie=fe;if(i.prettier||i.indentStyle||i.indentSize){let ee=await Zl(ie,{usePrettier:i.prettier,builtIn:{indentSize:i.indentSize||2,useTabs:i.indentStyle==="tabs",normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}},N);ie=ee.content;for(let F of ee.warnings??[])Y.warn(`[format] ${F}`)}if(i.declarationMap){let ee=`${Uo(N)||"output.d.ts"}.map`;ie=Ec(ie,ee)}await v(ie);let le=K(ie);if(i.dryRun)oe(ie);else{if(i.declarationMap&&I)await Dc(N,T,ie,I,i.cwd,w);if(await w(N,ie,i.lineEnding),o&&I)o.update(T,I,ie,i.cwd);Y.debug(`Generated: ${N}`)}return{success:!0,file:T,declarationCount:z,importCount:ge,exportCount:De,validationErrorCount:le}}catch(N){let v=hl(N,T,I);if(i.plugins&&i.plugins.length>0)await n.runOnError(N instanceof Error?N:Error(String(N)),T,I||"");return{success:!1,file:T,declarationCount:0,importCount:0,exportCount:0,dtsError:v,validationErrorCount:0}}},x=i.parallel||i.parallel!==!1&&f.length>=10,k=Bs(i.concurrency,Zp?.()??8),L=new Map;if(x&&f.length>1){let T=f.map(async(D)=>{try{let I=await Ot(D);return{file:D,source:I}}catch{return{file:D,source:null}}});for(let D of await Promise.all(T))if(D.source!==null)L.set(D.file,D.source)}let W=(T)=>{if(s.filesProcessed++,T.success){if(T.cached)a++;else s.filesGenerated++,s.declarationsFound+=T.declarationCount,s.importsProcessed+=T.importCount,s.exportsProcessed+=T.exportCount;if(i.validate){if(s.filesValidated++,T.validationErrorCount)s.validationErrors+=T.validationErrorCount}}else if(s.filesFailed++,T.dtsError){s.errors.push(T.dtsError);let D=dl(T.dtsError);if(i.continueOnError)Y.warn(D);else throw Y.error(D),Error(T.dtsError.message)}};if(x)for(let T=0;T<f.length;T+=k){let D=f.slice(T,T+k),I=await Promise.all(D.map((N)=>C(N,L.get(N))));for(let N of I)W(N);if(i.progress){let N=Math.round(s.filesProcessed/f.length*100);Y.info(`[${s.filesProcessed}/${f.length}] ${N}%`)}}else for(let T of f){let D=await C(T);if(W(D),i.progress){let I=Math.round(s.filesProcessed/f.length*100),N=D.cached?"[cached]":"";Y.info(`[${s.filesProcessed}/${f.length}] ${I}% - ${Ge(i.cwd,T)} ${N}`)}}if(!i.dryRun){if(i.clean)await rm(i);for(let[T,D]of y)await Mc(zr(T),{recursive:!0}),await Hr(T,D.content,D.lineEnding)}if(o&&!i.dryRun)o.save(),Y.debug("Saved build cache");if(!i.bundle){let T=[];if(l)for(let D of l.unresolved)T.push({from:D.from,specifier:D.specifier,reason:"missing"});if(i.autoIncludeReExports===!1&&f.length>0){let D=new Set(f);for(let I of f){let N;try{N=await Ot(I)}catch{continue}for(let v of Vi(N)){let K=u(v.specifier,I);if(!K.isRelative)continue;if(!K.resolved)T.push({from:I,specifier:v.specifier,reason:"missing"});else if(!/\.d\.(?:ts|mts|cts)$/.test(K.resolved)&&!D.has(K.resolved))T.push({from:I,specifier:v.specifier,reason:"not-emitted"})}}}if(T.length>0){let D=[];D.push(`Found ${T.length} re-export(s) pointing at siblings that won't be in the output:`);for(let N of T){let v=Ge(i.cwd,N.from);if(N.reason==="missing")D.push(` ${v} \u2192 '${N.specifier}' (path not found on disk)`);else D.push(` ${v} \u2192 '${N.specifier}' (resolved but not in entrypoints; set autoIncludeReExports: true or add to entrypoints)`)}let I=D.join(`
246
- `);if(i.failOnUnresolvedReExport)throw Error(I);Y.warn(I),Y.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||a>0)&&c.length>0)try{Y.debug("Bundling declarations...");let T=c.length===1&&!!i.bundleOutput;for(let D of c){let I=await Cn([D],{includeImports:!0,resolveSpecifier:u}),N=new Set;for(let fe of I.reachable){if(fe.endsWith(".d.ts"))continue;if(fe.includes("node_modules"))continue;N.add(fe)}let v=f.filter((fe)=>N.has(fe));if(!v.includes(D))v.push(D);let K=ks(D,v,m,{cwd:i.cwd,keepComments:i.keepComments});for(let fe of new Set(K.warnings))Y.warn(`[bundle] ${fe}`);let oe=T?Ze(i.cwd,i.outdir,i.bundleOutput):Mi(D,i);if(i.dryRun)Y.info(`[dry-run] Would bundle ${K.files.length} files to: ${Ge(i.cwd,oe)}`);else await Mc(zr(oe),{recursive:!0}),await Hr(oe,K.content,i.lineEnding),Y.info(`Bundled ${K.files.length} files to: ${Ge(i.cwd,oe)}`);if(T)break}}catch(T){let D=T instanceof Error?T.message:String(T);Y.error(`Bundle failed: ${D}`)}if(s.durationMs=Date.now()-t,i.stats)if(i.outputFormat==="json")console.log(JSON.stringify(s,null,2));else{if(Y.info(`
247
- --- Generation Statistics ---`),Y.info(`Files processed: ${s.filesProcessed}`),Y.info(`Files generated: ${s.filesGenerated}`),a>0)Y.info(`Files cached: ${a}`);if(s.filesFailed>0)Y.info(`Files failed: ${s.filesFailed}`);if(Y.info(`Declarations found: ${s.declarationsFound}`),Y.info(`Imports processed: ${s.importsProcessed}`),Y.info(`Exports processed: ${s.exportsProcessed}`),s.filesValidated>0){if(Y.info(`Files validated: ${s.filesValidated}`),s.validationErrors>0)Y.info(`Validation errors: ${s.validationErrors}`)}if(Y.info(`Duration: ${s.durationMs}ms`),s.errors.length>0){Y.info(`
234
+ ${n}`}if(c)return`${Fp(c)}${n}`;return i+n}function Bp(e,t=!0){let i=$t(e.leadingComments,t),n=e.text;if(n.startsWith("export declare interface")||n.startsWith("declare interface"))return i+n;let r="";if(e.isExported)r+="export ";if(r+="declare interface ",r+=e.name,e.generics)r+=e.generics;if(e.extends)r+=` extends ${e.extends}`;let o=Lp(e.text);if(o!==-1)r+=` ${e.text.slice(o)}`;else r+=" {}";return i+r}function Gp(e,t=!0){let i=$t(e.leadingComments,t);if(e.text.includes("{")&&e.text.includes("}")&&e.text.includes("from"))return i+e.text;let n="";if(e.isExported)n+="export ";if(!e.isExported&&!e.text.includes(" from "))n+="declare ";let r=e.text.indexOf("type ");if(r!==-1){let s=e.text.slice(r),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);n+=s}else{if(n+=`type ${e.name}`,e.generics)n+=e.generics;n+=" = any"}let o=n.trimEnd();if(!o.endsWith(";")&&!o.endsWith("}"))n+=";";return i+n}function jp(e,t=!0){return $t(e.leadingComments,t)+e.text}function _p(e,t=!0){let i=$t(e.leadingComments,t),n="";if(e.isExported)n+="export ";if(n+="declare ",e.modifiers?.includes("const"))n+="const ";n+="enum ",n+=e.name;let r=e.text.indexOf("{");if(r!==-1)n+=` ${e.text.slice(r)}`;else n+=" {}";return i+n}function Vp(e,t=!0){let i=$t(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 n="";if(e.isExported)n+="export ";if(!e.modifiers?.includes("declare"))n+="declare ";n+="namespace ",n+=e.name;let r=e.text.indexOf("{");if(r!==-1)n+=` ${e.text.slice(r)}`;else n+=" {}";return i+n}function Up(e){let t=Bt.get(e);if(t)return Bt.delete(e),Bt.set(e,t),t;return null}function $c(e,t){if(Bt.set(e,t),Bt.size>200){let i=0;for(let n of Bt.keys()){if(i++>=20)break;Bt.delete(n)}}}function Kp(e){let t=e.indexOf(" from ");if(t===-1)return null;let i=e.slice(t+6).trim(),n=i[0];if(n!=='"'&&n!=="'")return null;let r=i.indexOf(n,1);if(r===-1)return null;let o=i.slice(1,r),s=e.slice(0,t).trim(),l=s.startsWith("import type ");if(s.startsWith("import "))s=s.slice(7).trim();if(s.startsWith("type "))s=s.slice(5).trim();let c=null,f=[],u=!1,a=s.indexOf("{"),m=s.lastIndexOf("}");if(a!==-1&&m!==-1){let y=s.slice(0,a).trim();if(y.endsWith(","))c=y.slice(0,-1).trim()||null;let w=s.slice(a+1,m),C=0;for(let A=0;A<=w.length;A++)if(A===w.length||w.charCodeAt(A)===44){let k=C,W=A;while(k<W&&(w.charCodeAt(k)===32||w.charCodeAt(k)===9||w.charCodeAt(k)===10))k++;while(W>k&&(w.charCodeAt(W-1)===32||w.charCodeAt(W-1)===9||w.charCodeAt(W-1)===10))W--;if(k<W)f.push(w.slice(k,W));C=A+1}}else{let y=s.trim();if(y.startsWith("* as "))c=y.slice(5).trim()||null,u=!0;else c=y||null}return{defaultName:c,namedItems:f,source:o,isTypeOnly:l,isNamespace:u}}function Hp(e){let t=Up(e);if(t)return t;let i=[],n=e.indexOf(" from ");if(n===-1)return $c(e,i),i;let r=e.slice(0,n).trim();if(r.startsWith("import "))r=r.slice(7).trim();if(r.startsWith("type "))r=r.slice(5).trim();let o=r.indexOf("{"),s=r.lastIndexOf("}");if(o!==-1&&s!==-1){let l=r.slice(0,o).trim();if(l.endsWith(",")){let f=l.slice(0,-1).trim();if(f)i.push(f)}else if(l&&!l.includes(","))i.push(l);let c=r.slice(o+1,s).split(",");for(let f=0;f<c.length;f++){let u=c[f].trim();if(!u)continue;if(u.startsWith("type "))u=u.slice(5).trim();let a=u.indexOf(" as ");if(a!==-1)u=u.slice(a+4).trim();if(u)i.push(u)}}else{let l=r.trim();if(l.startsWith("* as ")){let c=l.slice(5).trim();if(c)i.push(c)}else if(l)i.push(l)}return $c(e,i),i}function xc(e,t){throw Error(t||`Unexpected value: ${e}`)}function zp(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===95||e===36||e>127}function Ac(e){let t=new Set,i=0,n=e.length;while(i<n){let r=e.charCodeAt(i);if(r>=65&&r<=90||r>=97&&r<=122||r===95||r===36||r>127){let o=i;i++;while(i<n&&zp(e.charCodeAt(i)))i++;t.add(e.substring(o,i))}else i++}return t}function Pc(e,t,i=!0,n=["bun"]){let r="",o=t.sourceCode;if(o){let E=0;while(E<o.length&&(o.charCodeAt(E)===32||o.charCodeAt(E)===9||o.charCodeAt(E)===10||o.charCodeAt(E)===13))E++;if(E<o.length-2&&o.charCodeAt(E)===47&&o.charCodeAt(E+1)===47&&o.charCodeAt(E+2)===47){let K=Np(o);if(K.length>0)for(let oe=0;oe<K.length;oe++){if(r)r+=`
235
+ `;r+=K[oe]}}}let s=[],l=[],c=[],f=[],u=[],a=[],m=[],y=[],w=[];for(let E of e){let K=E.kind;switch(K){case"import":s.push(E);break;case"function":l.push(E);break;case"variable":c.push(E);break;case"interface":f.push(E);break;case"type":u.push(E);break;case"class":a.push(E);break;case"enum":m.push(E);break;case"module":y.push(E);break;case"export":w.push(E);break;case"namespace":y.push(E);break;case"unknown":break;default:xc(K,`Unhandled declaration kind: ${K}`)}}let C=new Set,A=[],k=[],W=[],B=new Set;for(let E of w){let K=$t(E.leadingComments,i);if(E.text.startsWith("export default")){let oe=E.text.endsWith(";")?E.text:`${E.text};`;W.push(K+oe)}else{let oe=E.text.trim();if(!oe.endsWith(";"))oe+=";";let he=oe.match(Jp);if(he){let ge=he[1],De=0;for(let re=0;re<=ge.length;re++)if(re===ge.length||ge.charCodeAt(re)===44){let ce=De,ee=re;while(ce<ee&&ge.charCodeAt(ce)<=32)ce++;while(ee>ce&&ge.charCodeAt(ee-1)<=32)ee--;if(ce<ee)C.add(ge.slice(ce,ee));De=re+1}}let z=K+oe;if(!B.has(z))if(B.add(z),z.includes("export type"))A.push(z);else k.push(z)}}let T=new Map;if(s.length>0)for(let E of s){let K=Hp(E.text);for(let oe of K)T.set(oe,E)}let D=new Set;if(f.length>0){let E=[];for(let K of l)if(K.isExported)E.push(K.text);for(let K of a)E.push(K.text);for(let K of u)E.push(K.text);if(E.length>0){let K=Ac(E.join(`
236
+ `));for(let oe of f)if(K.has(oe.name))D.add(oe.name)}}let N=[];if(s.length>0){let E=new Set,K=[];for(let z of l)if(z.isExported)K.push(z.text);for(let z of c)if(K.push(z.text),z.typeAnnotation)K.push(z.typeAnnotation);else if(z.isExported&&z.value)K.push(Sc(z,!1));for(let z of f)if(z.isExported||D.has(z.name))K.push(z.text);for(let z of u)K.push(z.text);for(let z of a)K.push(z.text);for(let z of m)K.push(z.text);for(let z of y)K.push(z.text);for(let z of w)K.push(z.text);let oe=K.join(`
237
+ `);if(oe&&T.size>0){let z=Ac(oe);for(let ge of T.keys())if(z.has(ge))E.add(ge)}for(let z of C)if(T.has(z))E.add(z);for(let z of s){if(z.isSideEffect){let J=z.text.trim(),te=J.endsWith(";")?J:`${J};`;N.push(te);continue}let ge=Kp(z.text);if(!ge)continue;let{defaultName:De,namedItems:re,source:ce,isTypeOnly:ee,isNamespace:L}=ge,U=De?E.has(De):!1,q="",Z=0;for(let J=0;J<re.length;J++){let te=re[J],se=te.charCodeAt(0)===116&&te.startsWith("type ")?te.slice(5).trim():te.trim(),ne=se.indexOf(" as ");if(ne!==-1)se=se.slice(ne+4).trim();if(E.has(se)){if(Z>0)q+=", ";q+=te,Z++}}if(U||Z>0){let J=ee?"import type ":"import ";if(U&&De)if(L)J+=`* as ${De}`;else J+=Z>0?`${De}, { ${q} }`:De;else if(Z>0)J+=`{ ${q} }`;J+=` from '${ce}';`,N.push(J)}}let he=n.length;if(N.length>1){if(Tc!==n)Tc=n,Oc=n.map((re)=>`from '${re}`),Rc=n.map((re)=>`from "${re}`);let z=Oc,ge=Rc,De=new Map;for(let re of N){let ce=he;for(let ee=0;ee<n.length;ee++)if(re.includes(z[ee])||re.includes(ge[ee])){ce=ee;break}De.set(re,ce)}N.sort((re,ce)=>{let ee=De.get(re),L=De.get(ce);return ee!==L?ee-L:re.localeCompare(ce)})}}for(let E=0;E<N.length;E++){if(r)r+=`
238
+ `;r+=N[E]}for(let E=0;E<A.length;E++){if(r)r+=`
239
+ `;r+=A[E]}let F=[l,c,f,u,a,m,y];for(let E=0;E<F.length;E++){let K=F[E];for(let oe=0;oe<K.length;oe++){let he=K[oe],z="",ge=he.kind;switch(ge){case"function":z=Wp(he,i);break;case"variable":z=Sc(he,i);break;case"interface":z=Bp(he,i);break;case"type":z=Gp(he,i);break;case"class":z=jp(he,i);break;case"enum":z=_p(he,i);break;case"module":case"namespace":z=Vp(he,i);break;case"import":case"export":case"unknown":break;default:xc(ge,`Unhandled declaration kind in processor: ${ge}`)}if(z){if(r)r+=`
240
+ `;r+=z}}}for(let E=0;E<k.length;E++){if(r)r+=`
241
+ `;r+=k[E]}for(let E=0;E<W.length;E++){if(r)r+=`
242
+ `;r+=W[E]}if(!r&&(s.length>0||w.length>0))return"export {};";return r}var Mp,Dp,Ip,Bt,Jp,Tc=null,Oc,Rc;var kc=de(()=>{Fo();Mp=/^\/\/\/\s*<reference\s+(?:path|types|lib|no-default-lib)\s*=\s*["'][^"']+["']\s*\/>/,Dp=/^\/\/\/\s*<amd-module\s+name\s*=\s*["'][^"']+["']\s*\/>/,Ip=/^\/\/\/\s*<amd-dependency\s+path\s*=\s*["'][^"']+["']/;Bt=new Map;Jp=/export\s+(?:type\s+)?\{\s*([^}]+)\s*\}/,Oc=[],Rc=[]});import{existsSync as Mc}from"fs";import{mkdir as Dc,readdir as qp,realpath as Yp,rm as Zp}from"fs/promises";import{availableParallelism as Xp}from"os";import{basename as Uo,dirname as zr,extname as Qp,isAbsolute as Pi,parse as em,relative as Be,resolve as Ze}from"path";function Lc(e){let t=Go.get(e);if(!t)t=Ts(e),Go.set(e,t),t.catch(()=>Go.delete(e));return t}async function Ic(e,t,i,n,r,o=Hr){let s=Uo(e)||"output.d.ts",l=Be(zr(e),t),c=`${s}.map`,f=i.lastIndexOf(`
243
+ ${Bo()}`),u=f===-1?i:i.slice(0,f),a=bc(u,s,l,n),m=`${e}.map`;return await o(m,JSON.stringify(a)),Y.debug(` Generated source map: ${Be(r,m)}`),c}async function Ko(e){let t=Date.now(),i={...ul,...e};if(i.logLevel)ln(i.logLevel);else if(i.verbose)ln("debug");let n=new Ur;if(i.plugins&&i.plugins.length>0){for(let T of i.plugins)n.register(T),Y.debug(`Registered plugin: ${T.name}`);i=await n.runOnStart(i)}if(await im(i),i.isolatedDeclarations===void 0)i.isolatedDeclarations=await yc(i);let r=i.typeMappings?Kr(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;Y.debug("Starting DTS generation..."),Y.debug(`Using ${s.generationMode} declaration generation path`),Y.debug("Config:",i);let c=await am(i);sm(i,c);let f=c.slice(),u=await Lc(i),a=null;if(i.autoIncludeReExports!==!1&&f.length>0){a=await Cn(f,{includeImports:!0,resolveSpecifier:u});let T=Ze(i.cwd,i.root),D=i.exclude||[],N=[];for(let F of a.reachable){if(f.includes(F))continue;if(!Vo(F))continue;if(F.endsWith(".d.ts"))continue;if(F.includes("node_modules"))continue;let E=i.outputStructure==="flat"&&c.some((K)=>u.isPackageLocal?.(K,F));if(!ki(F,T)&&!E){Y.warn(`Skipping auto-included source outside root: ${Be(i.cwd,F)}`);continue}if(_o(F,D,T))continue;N.push(F)}if(N.length>0)f=[...f,...N],Y.debug(`Auto-included ${N.length} file(s) reached via relative re-exports`)}if(lm(f,i),jo.set(i,new Set(f)),i.incremental){if(o=new $n(i,u.cacheKey?.(f)),i.clearCache){if(Y.debug("Clearing build cache..."),!i.dryRun)o.clear()}else if(o.load()){let T=o.getStats();Y.debug(`Loaded build cache with ${T.entries} entries`)}else Y.debug("No existing build cache found, starting fresh");if(!i.dryRun)Ws(i.cwd)}if(o&&!i.dryRun){let T=o.prune(new Set(f),i.cwd);if(T>0)Y.debug(`Pruned ${T} deleted files from cache`)}if(Y.debug(`Found ${f.length} TypeScript files`),i.progress&&f.length>0){let T=i.parallel?"parallel":"sequential";Y.info(`Processing ${f.length} files (${T})...`)}let m=new Map,y=new Map,w=async(T,D,N="lf")=>{y.set(T,{content:D,lineEnding:N})},C=async(T,D)=>{let N;try{let F=Mi(T,i),E=async(ee)=>{if(!i.diff)return;try{let L=await Ot(F),U=wc(L,ee,Be(i.cwd,F));if(U)Y.info(`
244
+ ${U}`);else Y.debug(`[no changes] ${F}`)}catch{Y.info(`[new file] ${Be(i.cwd,F)}`)}},K=(ee)=>{if(!i.validate)return 0;let L=Cc(ee,F);if(L.isValid)return Y.debug(`[validation] ${F} - OK`),0;Y.warn(`[validation] ${Be(i.cwd,F)} has ${L.errors.length} error(s):`);for(let U of L.errors){let q=` Line ${U.line}:${U.column}`;if(U.code)q+=` [${U.code}]`;if(q+=` - ${U.message}`,Y.warn(q),U.suggestion)Y.warn(` Suggestion: ${U.suggestion}`)}return L.errors.length},oe=(ee)=>{Y.info(`[dry-run] Would generate: ${F}`),Y.debug("--- Content preview ---"),Y.debug(ee.slice(0,500)+(ee.length>500?`
245
+ ...`:"")),Y.debug("--- End preview ---")};if(o){let ee=o.getCachedIfValid(T,i.cwd);if(ee){if(i.bundle)m.set(T,ee);await E(ee);let L=K(ee);if(i.dryRun)oe(ee);else{if(i.declarationMap)N=D??await Ot(T),await Ic(F,T,ee,N,i.cwd,w);await w(F,ee,i.lineEnding)}return Y.debug(`[cached] ${Be(i.cwd,F)}`),{success:!0,file:T,declarationCount:0,importCount:0,exportCount:0,cached:!0,validationErrorCount:L}}}N=D??await Ot(T);let{content:he,declarationCount:z,importCount:ge,exportCount:De}=await um(T,N,i,n,r);if(i.bundle)m.set(T,he);let re=he;if(i.prettier||i.indentStyle||i.indentSize){let ee=await Xl(re,{usePrettier:i.prettier,builtIn:{indentSize:i.indentSize||2,useTabs:i.indentStyle==="tabs",normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}},F);re=ee.content;for(let L of ee.warnings??[])Y.warn(`[format] ${L}`)}if(i.declarationMap){let ee=`${Uo(F)||"output.d.ts"}.map`;re=Ec(re,ee)}await E(re);let ce=K(re);if(i.dryRun)oe(re);else{if(i.declarationMap&&N)await Ic(F,T,re,N,i.cwd,w);if(await w(F,re,i.lineEnding),o&&N)o.update(T,N,re,i.cwd);Y.debug(`Generated: ${F}`)}return{success:!0,file:T,declarationCount:z,importCount:ge,exportCount:De,validationErrorCount:ce}}catch(F){let E=dl(F,T,N);if(i.plugins&&i.plugins.length>0)await n.runOnError(F instanceof Error?F:Error(String(F)),T,N||"");return{success:!1,file:T,declarationCount:0,importCount:0,exportCount:0,dtsError:E,validationErrorCount:0}}},A=i.parallel||i.parallel!==!1&&f.length>=10,k=Gs(i.concurrency,Xp?.()??8),W=new Map;if(A&&f.length>1){let T=f.map(async(D)=>{try{let N=await Ot(D);return{file:D,source:N}}catch{return{file:D,source:null}}});for(let D of await Promise.all(T))if(D.source!==null)W.set(D.file,D.source)}let B=(T)=>{if(s.filesProcessed++,T.success){if(T.cached)l++;else s.filesGenerated++,s.declarationsFound+=T.declarationCount,s.importsProcessed+=T.importCount,s.exportsProcessed+=T.exportCount;if(i.validate){if(s.filesValidated++,T.validationErrorCount)s.validationErrors+=T.validationErrorCount}}else if(s.filesFailed++,T.dtsError){s.errors.push(T.dtsError);let D=pl(T.dtsError);if(i.continueOnError)Y.warn(D);else throw Y.error(D),Error(T.dtsError.message)}};if(A)for(let T=0;T<f.length;T+=k){let D=f.slice(T,T+k),N=await Promise.all(D.map((F)=>C(F,W.get(F))));for(let F of N)B(F);if(i.progress){let F=Math.round(s.filesProcessed/f.length*100);Y.info(`[${s.filesProcessed}/${f.length}] ${F}%`)}}else for(let T of f){let D=await C(T);if(B(D),i.progress){let N=Math.round(s.filesProcessed/f.length*100),F=D.cached?"[cached]":"";Y.info(`[${s.filesProcessed}/${f.length}] ${N}% - ${Be(i.cwd,T)} ${F}`)}}if(!i.dryRun){if(i.clean)await nm(i);for(let[T,D]of y)await Dc(zr(T),{recursive:!0}),await Hr(T,D.content,D.lineEnding)}if(o&&!i.dryRun)o.save(),Y.debug("Saved build cache");if(!i.bundle){let T=[];if(a)for(let D of a.unresolved)T.push({from:D.from,specifier:D.specifier,reason:"missing"});if(i.autoIncludeReExports===!1&&f.length>0){let D=new Set(f);for(let N of f){let F;try{F=await Ot(N)}catch{continue}for(let E of Vi(F)){let K=u(E.specifier,N);if(!K.isRelative)continue;if(!K.resolved)T.push({from:N,specifier:E.specifier,reason:"missing"});else if(!/\.d\.(?:ts|mts|cts)$/.test(K.resolved)&&!D.has(K.resolved))T.push({from:N,specifier:E.specifier,reason:"not-emitted"})}}}if(T.length>0){let D=[];D.push(`Found ${T.length} re-export(s) pointing at siblings that won't be in the output:`);for(let F of T){let E=Be(i.cwd,F.from);if(F.reason==="missing")D.push(` ${E} \u2192 '${F.specifier}' (path not found on disk)`);else D.push(` ${E} \u2192 '${F.specifier}' (resolved but not in entrypoints; set autoIncludeReExports: true or add to entrypoints)`)}let N=D.join(`
246
+ `);if(i.failOnUnresolvedReExport)throw Error(N);Y.warn(N),Y.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)&&c.length>0)try{Y.debug("Bundling declarations...");let T=c.length===1&&!!i.bundleOutput;for(let D of c){let N=await Cn([D],{includeImports:!0,resolveSpecifier:u}),F=new Set;for(let he of N.reachable){if(he.endsWith(".d.ts"))continue;if(he.includes("node_modules"))continue;F.add(he)}let E=f.filter((he)=>F.has(he));if(!E.includes(D))E.push(D);let K=Ms(D,E,m,{cwd:i.cwd,keepComments:i.keepComments});for(let he of new Set(K.warnings))Y.warn(`[bundle] ${he}`);let oe=T?Ze(i.cwd,i.outdir,i.bundleOutput):Mi(D,i);if(i.dryRun)Y.info(`[dry-run] Would bundle ${K.files.length} files to: ${Be(i.cwd,oe)}`);else await Dc(zr(oe),{recursive:!0}),await Hr(oe,K.content,i.lineEnding),Y.info(`Bundled ${K.files.length} files to: ${Be(i.cwd,oe)}`);if(T)break}}catch(T){let D=T instanceof Error?T.message:String(T);Y.error(`Bundle failed: ${D}`)}if(s.durationMs=Date.now()-t,i.stats)if(i.outputFormat==="json")console.log(JSON.stringify(s,null,2));else{if(Y.info(`
247
+ --- Generation Statistics ---`),Y.info(`Files processed: ${s.filesProcessed}`),Y.info(`Files generated: ${s.filesGenerated}`),l>0)Y.info(`Files cached: ${l}`);if(s.filesFailed>0)Y.info(`Files failed: ${s.filesFailed}`);if(Y.info(`Declarations found: ${s.declarationsFound}`),Y.info(`Imports processed: ${s.importsProcessed}`),Y.info(`Exports processed: ${s.exportsProcessed}`),s.filesValidated>0){if(Y.info(`Files validated: ${s.filesValidated}`),s.validationErrors>0)Y.info(`Validation errors: ${s.validationErrors}`)}if(Y.info(`Duration: ${s.durationMs}ms`),s.errors.length>0){Y.info(`
248
248
  Errors:`);for(let T of s.errors){let D=` - ${T.file}`;if(T.location)D+=`:${T.location.line}:${T.location.column}`;if(T.code)D+=` [${T.code}]`;if(D+=`: ${T.message}`,Y.info(D),T.suggestion)Y.info(` Suggestion: ${T.suggestion}`)}}Y.info(`-----------------------------
249
- `)}if(i.plugins&&i.plugins.length>0)await n.runOnEnd(s);return Y.debug("DTS generation complete!"),s}async function Ic(e){try{return await qp(e)}catch{return Ze(e)}}async function tm(e){let t=Ze(e.cwd,e.outdir);if(e.bundle&&e.bundleOutput){if(Pi(e.bundleOutput))throw Error("bundleOutput must be relative to outdir");let r=Ze(t,e.bundleOutput);if(!ki(r,t))throw Error("bundleOutput must stay within outdir")}if(!e.clean||e.dryRun)return;if(t===Qp(t).root)throw Error("Refusing to clean declarations from the filesystem root");let[i,n]=await Promise.all([Ic(t),Ic(Ze(e.cwd,e.root))]);if(ki(n,i))throw Error("Refusing to clean an outdir that contains the source root")}function im(e){let t=Ri.get(e);if(!t){if(t=new Nc(e),Ri.set(e,t),Ri.size>em){let i=Ri.keys().next().value;if(i!==void 0)Ri.delete(i)}}return t}async function rm(e){let t=Ze(e.cwd,e.outdir);async function i(n){let r;try{r=await Jp(n,{withFileTypes:!0})}catch{return}await Promise.all(r.map(async(o)=>{let s=Ze(n,o.name);if(o.isDirectory()){await i(s);return}if(o.name.endsWith(".d.ts")||o.name.endsWith(".d.mts")||o.name.endsWith(".d.cts")||o.name.endsWith(".d.ts.map")||o.name.endsWith(".d.mts.map")||o.name.endsWith(".d.cts.map"))await Yp(s,{force:!0})}))}await i(t)}function _o(e,t,i){if(!t||t.length===0)return!1;let n=Ge(i,e);for(let r of t){let o=im(r);if(o.match(n)||o.match(e))return!0}return!1}function om(e,t){let i=Ze(e.cwd,e.root),n=` root: ${i}
249
+ `)}if(i.plugins&&i.plugins.length>0)await n.runOnEnd(s);return Y.debug("DTS generation complete!"),s}async function Nc(e){try{return await Yp(e)}catch{return Ze(e)}}async function im(e){let t=Ze(e.cwd,e.outdir);if(e.bundle&&e.bundleOutput){if(Pi(e.bundleOutput))throw Error("bundleOutput must be relative to outdir");let r=Ze(t,e.bundleOutput);if(!ki(r,t))throw Error("bundleOutput must stay within outdir")}if(!e.clean||e.dryRun)return;if(t===em(t).root)throw Error("Refusing to clean declarations from the filesystem root");let[i,n]=await Promise.all([Nc(t),Nc(Ze(e.cwd,e.root))]);if(ki(n,i))throw Error("Refusing to clean an outdir that contains the source root")}function rm(e){let t=Ri.get(e);if(!t){if(t=new Fc(e),Ri.set(e,t),Ri.size>tm){let i=Ri.keys().next().value;if(i!==void 0)Ri.delete(i)}}return t}async function nm(e){let t=Ze(e.cwd,e.outdir);async function i(n){let r;try{r=await qp(n,{withFileTypes:!0})}catch{return}await Promise.all(r.map(async(o)=>{let s=Ze(n,o.name);if(o.isDirectory()){await i(s);return}if(o.name.endsWith(".d.ts")||o.name.endsWith(".d.mts")||o.name.endsWith(".d.cts")||o.name.endsWith(".d.ts.map")||o.name.endsWith(".d.mts.map")||o.name.endsWith(".d.cts.map"))await Zp(s,{force:!0})}))}await i(t)}function _o(e,t,i){if(!t||t.length===0)return!1;let n=Be(i,e);for(let r of t){let o=rm(r);if(o.match(n)||o.match(e))return!0}return!1}function sm(e,t){let i=Ze(e.cwd,e.root),n=` root: ${i}
250
250
  entrypoints: ${e.entrypoints.map((o)=>JSON.stringify(o)).join(", ")||"(none)"}
251
251
  `+(e.exclude?.length?` exclude: ${e.exclude.map((o)=>JSON.stringify(o)).join(", ")}
252
- `:"")+"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)=>Pi(o)&&kc(o)&&!ki(o,i)).length===e.entrypoints.length)return;throw Error(`No source files matched. Nothing was generated.
253
- ${n}`)}let r=e.entrypoints.filter((o)=>{if(nm.test(o))return!1;return!kc(Pi(o)?o:Ze(i,o))});if(r.length>0)throw Error(`Entrypoint${r.length>1?"s":""} not found: ${r.map((o)=>JSON.stringify(o)).join(", ")}
254
- ${n}`)}async function sm(e){let t=[],i=Ze(e.cwd,e.root),n=e.exclude||[],r=[...e.entrypoints,...e.include??[]];for(let o of r)if(Pi(o)&&Vo(o)){if(!o.includes("node_modules")){if(!ki(o,i)&&e.outputStructure!=="flat")Y.warn(`Skipping entrypoint outside root: ${Ge(e.cwd,o)}`);else if(!_o(o,n,i))t.push(o)}}else{let s=new Nc(o);for await(let a of s.scan({cwd:i,absolute:!0,onlyFiles:!0}))if(Vo(a)&&!a.includes("node_modules")){if(!_o(a,n,i))t.push(a)}}return[...new Set(t.map((o)=>Ze(o)))].sort()}function ki(e,t){let i=Ge(t,e);return i!==".."&&!i.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!Pi(i)}function am(e,t){let i=new Map;for(let n of e){let r=Mi(n,t),o=i.get(r);if(o&&o!==n)throw Error(`Output path collision: ${Ge(t.cwd,o)} and ${Ge(t.cwd,n)} both emit ${Ge(t.cwd,r)}`);i.set(r,n)}}function Vo(e){return/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/.test(e)&&!/\.d\.(?:ts|mts|cts)$/.test(e)}function Mi(e,t){let i=Ze(t.cwd,t.root),n=Ge(i,e).replace(/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/,(r)=>{if(r===".mts"||r===".mjs")return".d.mts";if(r===".cts"||r===".cjs")return".d.cts";return".d.ts"});if(t.outputStructure==="mirror")return Ze(t.cwd,t.outdir,n);else{let r=Uo(n);return Ze(t.cwd,t.outdir,r)}}function lm(e,t,i=""){let n=Ge(zr(e),t).replace(/\\/g,"/");if(n=n.replace(/\.d\.mts$/,"").replace(/\.d\.cts$/,"").replace(/\.d\.ts$/,""),i)n+=i;if(!n.startsWith("."))n=`./${n}`;return n}async function cm(e,t,i){let n=await Fc(i),r=Mi(t,i);return Os(e,(o)=>{let s=n(o,t);if(!s.isRelative||!s.resolved)return o;if(/\.d\.(?:ts|mts|cts)$/.test(s.resolved))return o;if(s.isAlias&&jo.has(i)&&!jo.get(i).has(s.resolved))throw Error(`Local alias ${JSON.stringify(o)} from ${t} targets a declaration excluded from this package build: ${s.resolved}`);let a=s.isAlias?s.suffix??"":o.match(/[?#].*$/)?.[0]??"",c=a?o.slice(0,-a.length):o,f=Xp(c),u=/^(?:\.js|\.jsx|\.mjs|\.cjs)$/.test(f)?f:"";return lm(r,Mi(s.resolved,i),u)+a})}async function fm(e,t,i,n,r){let o=t;if(n)o=await n.runOnBeforeFile(e,t);let s=ql(o,e,i.keepComments,i.isolatedDeclarations??!1);if(n)s=await n.runOnDeclarations(e,o,s);let a=0,c=0;for(let u=0;u<s.length;u++){let l=s[u];if(l.kind==="import")a++;if(l.kind==="export"||l.isExported)c++}let f=Rc(s,{filePath:e,sourceCode:o,declarations:s},i.keepComments,i.importOrder);if(f=await cm(f,e,i),r)f=sc(f,r,{filePath:e});if(i.normalizeOutput===!0||i.declarationOrder)f=ic(f,{lineEnding:"lf",declarationOrder:i.declarationOrder,indent:{style:i.indentStyle??"spaces",size:i.indentSize??2}});if(n)f=await n.runOnAfterFile(e,o,f);return{content:f,declarationCount:s.length,importCount:a,exportCount:c}}var Nc,Go,jo,em=50,Ri,nm;var Lc=ue(()=>{Bi();cn();wn();Ms();Ws();Gs();ul();pl();Yl();Xl();Ql();rc();ac();vc();Pc();({Glob:Nc}=globalThis.Bun),Go=new WeakMap,jo=new WeakMap;Ri=new Map;nm=/[*?[\]{}!]/});var Wc=ue(()=>{Lc()});import{createHash as hm}from"crypto";import{existsSync as dm,readFileSync as pm,writeFileSync as mm}from"fs";import{dirname as gm,join as ym,relative as Bc,resolve as Di,sep as Jr}from"path";import jc from"process";class _c{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},n=this.listeners.get(e)||[];for(let r of n)await r(i)}}class Vc{manifest;cacheDir;manifestPath;constructor(e,t){this.cacheDir=e,this.manifestPath=ym(e,"manifest.json"),this.manifest=this.loadManifest(t)}loadManifest(e){try{if(dm(this.manifestPath)){let t=JSON.parse(pm(this.manifestPath,"utf-8"));if(t.configHash===e&&t.version==="1.0")return t}}catch{}return{version:"1.0",configHash:e,entries:{}}}save(){try{let{mkdirSync:e}=um("fs");e(this.cacheDir,{recursive:!0}),mm(this.manifestPath,JSON.stringify(this.manifest,null,2))}catch{}}getEntry(e){return this.manifest.entries[e]}setEntry(e,t){this.manifest.entries[e]=t}isValid(e,t){return this.getEntry(e)?.hash===t}clear(){this.manifest.entries={},this.save()}}function Cm(e){let t={root:e.root,outdir:e.outdir,entrypoints:e.entrypoints,clean:e.clean,tsconfigPath:e.tsconfigPath};return hm("md5").update(JSON.stringify(t)).digest("hex")}function Uc(e={}){let{onSuccess:t,onError:i,failOnError:n=!0,incremental:r=!1,cacheDir:o=".dtsx-cache",on:s,timeout:a=60000,continueOnError:c=!1,verbose:f=!1,...u}=e,l=new _c;if(s){for(let[m,y]of Object.entries(s))if(y)l.on(m,y)}return{name:"bun-plugin-dtsx",async setup(m){let y=Date.now(),w=null,C=0;try{let x=vm(u,m),k=Cm(x);if(x.clean){let D=Di(x.cwd??jc.cwd(),x.outdir??"./dist");if(Gc.has(D))x.clean=!1;else Gc.add(D)}if(r)w=new Vc(Di(o),k);if(await l.emit("start",{type:"start",files:x.entrypoints||[],config:x}),f){if(console.log("[bun-plugin-dtsx] Starting declaration generation..."),r)console.log("[bun-plugin-dtsx] Incremental mode enabled")}let W=await(async()=>new Promise((D,I)=>{let N=setTimeout(()=>{I(new Ii(`Generation timed out after ${a}ms`,"TIMEOUT_ERROR",{timeout:a}))},a);Ko(x).then((v)=>{clearTimeout(N),D(v)}).catch((v)=>{clearTimeout(N),I(v)})}))(),T=Date.now()-y;if(w)w.save();if(await l.emit("complete",{type:"complete",stats:W,duration:T,fromCache:C}),f){if(console.log(`[bun-plugin-dtsx] Generation complete in ${T}ms`),C>0)console.log(`[bun-plugin-dtsx] ${C} files served from cache`)}if(t)await t(W)}catch(x){let k=wm(x);if(await l.emit("error",{type:"error",error:k}),i)await i(k);else{if(console.error("[bun-plugin-dtsx] Error generating declarations:"),console.error(` Code: ${k.code}`),console.error(` Message: ${k.message}`),k.context)console.error(` Context: ${JSON.stringify(k.context)}`);if(f&&k.stack)console.error(` Stack: ${k.stack}`)}if(n&&!c)throw k}}}}function wm(e){if(e instanceof Ii)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 Ii(e.message,t,{originalError:e.name},e)}return new Ii(String(e),"GENERATION_ERROR")}function Em(e){let t=e.map((n)=>gm(n).split(Jr)),i=t[0];for(let n of t.slice(1)){let r=0;while(r<i.length&&r<n.length&&i[r]===n[r])r++;i=i.slice(0,r)}return i.join(Jr)||Jr}function vm(e,t){let i=e.cwd||jc.cwd(),n=t?.config?.entrypoints,r=e.outdir||e.build?.config.outdir||t?.config.outdir||"./dist",o=e.root||e.build?.config.root||t?.config.root;if(!o&&n?.length){let a=Em(n.map((c)=>Di(i,c)));o=Bc(i,a)||"."}o=o||"./src";let s=e.entrypoints;if(!s)if(n?.length){let a=Di(i,o),c=[];for(let f of n){let u=Di(i,f);if(u===a||u.startsWith(a+Jr))c.push(Bc(a,u));else console.warn(`[bun-plugin-dtsx] Skipping entrypoint outside root "${o}": ${f}`)}s=c.length?c:["index.ts"]}else s=["index.ts"];return{...e,cwd:i,root:o,entrypoints:s,outdir:r,clean:e.clean??!0,tsconfigPath:e.tsconfigPath}}var um,Ii,Gc;var Kc=ue(()=>{Wc();um=import.meta.require;Ii=class Ii extends Error{code;context;cause;constructor(e,t,i,n){super(e);if(this.name="DtsxPluginError",this.code=t,this.context=i,this.cause=n,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}};Gc=new Set});import{mkdir as bm,stat as Sm}from"fs/promises";import{bold as Ho,dim as zo,green as $m,italic as Hc,log as Am}from"@stacksjs/cli";import{path as rt}from"@stacksjs/path";import{glob as zc}from"@stacksjs/storage";function sn(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,n=new Set,r=(s,a)=>{let c=i.get(s);if(c!==void 0)return c;if(n.has(s))throw Error(`dependency cycle: ${[...a,s].join(" -> ")}`);n.add(s);let f=t.get(s).dependencies.filter((l)=>l!==s&&t.has(l)),u=f.length?1+Math.max(...f.map((l)=>r(l,[...a,s]))):0;return n.delete(s),i.set(s,u),u},o=[];for(let s of[...e].sort((a,c)=>a.name.localeCompare(c.name)))(o[r(s.name,[])]||=[]).push(s);return o.filter(Boolean)}import{existsSync as of,readdirSync as sf,readFileSync as ss}from"fs";import{join as an}from"path";function af(e){return[...sf(e,{withFileTypes:!0}).filter((i)=>i.isDirectory()).map((i)=>an(e,i.name)),e].filter((i)=>{let n=an(i,"package.json");if(!of(n))return!1;let r=JSON.parse(ss(n,"utf8"));return!r.private&&!!r.scripts?.build})}async function lf(e){let t=e.map((r)=>{let o=JSON.parse(ss(an(r,"package.json"),"utf8"));if(!o.name||!o.scripts?.build)throw Error(`Not a buildable workspace package: ${r}`);return{name:o.name,dir:r,dependencies:Object.keys(o.dependencies??{})}}),i=sn(t),n=[];for(let{name:r,dir:o,dependencies:s}of i.flat()){let a=n.filter((f)=>f.exitCode!==0&&s.includes(f.name)).map((f)=>f.name);if(a.length){console.error(`Cannot build ${o}: dependencies failed: ${a.join(", ")}`),n.push({name:r,dir:o,exitCode:null,blockedBy:a});continue}console.log(`Building ${o}`);let c=Bun.spawn([process.execPath,"run","build"],{cwd:o,stdout:"inherit",stderr:"inherit"});n.push({name:r,dir:o,exitCode:await c.exited,blockedBy:[]})}return n}async function xm(e){let t=await zc([rt.resolve(e,"dist","**/*.d.ts")],{absolute:!0}),i=new Bun.Transpiler({loader:"ts",target:"bun"});for(let n of t){let r=await Bun.file(n).text();try{i.transformSync(r)}catch(o){throw Error(`Invalid declaration generated at ${n}: ${o instanceof Error?o.message:String(o)}`)}}}async function Tm(e){let t=rt.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 n=new TextDecoder().decode(i.stderr??new Uint8Array),r=/SyntaxError|needs to refer to a top-level declared variable|does not provide an export named|Export named .* not found/i;if(r.test(n)){let o=n.split(`
252
+ `:"")+"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)=>Pi(o)&&Mc(o)&&!ki(o,i)).length===e.entrypoints.length)return;throw Error(`No source files matched. Nothing was generated.
253
+ ${n}`)}let r=e.entrypoints.filter((o)=>{if(om.test(o))return!1;return!Mc(Pi(o)?o:Ze(i,o))});if(r.length>0)throw Error(`Entrypoint${r.length>1?"s":""} not found: ${r.map((o)=>JSON.stringify(o)).join(", ")}
254
+ ${n}`)}async function am(e){let t=[],i=Ze(e.cwd,e.root),n=e.exclude||[],r=[...e.entrypoints,...e.include??[]];for(let o of r)if(Pi(o)&&Vo(o)){if(!o.includes("node_modules")){if(!ki(o,i)&&e.outputStructure!=="flat")Y.warn(`Skipping entrypoint outside root: ${Be(e.cwd,o)}`);else if(!_o(o,n,i))t.push(o)}}else{let s=new Fc(o);for await(let l of s.scan({cwd:i,absolute:!0,onlyFiles:!0}))if(Vo(l)&&!l.includes("node_modules")){if(!_o(l,n,i))t.push(l)}}return[...new Set(t.map((o)=>Ze(o)))].sort()}function ki(e,t){let i=Be(t,e);return i!==".."&&!i.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!Pi(i)}function lm(e,t){let i=new Map;for(let n of e){let r=Mi(n,t),o=i.get(r);if(o&&o!==n)throw Error(`Output path collision: ${Be(t.cwd,o)} and ${Be(t.cwd,n)} both emit ${Be(t.cwd,r)}`);i.set(r,n)}}function Vo(e){return/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/.test(e)&&!/\.d\.(?:ts|mts|cts)$/.test(e)}function Mi(e,t){let i=Ze(t.cwd,t.root),n=Be(i,e).replace(/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/,(r)=>{if(r===".mts"||r===".mjs")return".d.mts";if(r===".cts"||r===".cjs")return".d.cts";return".d.ts"});if(t.outputStructure==="mirror")return Ze(t.cwd,t.outdir,n);else{let r=Uo(n);return Ze(t.cwd,t.outdir,r)}}function cm(e,t,i=""){let n=Be(zr(e),t).replace(/\\/g,"/");if(n=n.replace(/\.d\.mts$/,"").replace(/\.d\.cts$/,"").replace(/\.d\.ts$/,""),i)n+=i;if(!n.startsWith("."))n=`./${n}`;return n}async function fm(e,t,i){let n=await Lc(i),r=Mi(t,i);return Rs(e,(o)=>{let s=n(o,t);if(!s.isRelative||!s.resolved)return o;if(/\.d\.(?:ts|mts|cts)$/.test(s.resolved))return o;if(s.isAlias&&jo.has(i)&&!jo.get(i).has(s.resolved))throw Error(`Local alias ${JSON.stringify(o)} from ${t} targets a declaration excluded from this package build: ${s.resolved}`);let l=s.isAlias?s.suffix??"":o.match(/[?#].*$/)?.[0]??"",c=l?o.slice(0,-l.length):o,f=Qp(c),u=/^(?:\.js|\.jsx|\.mjs|\.cjs)$/.test(f)?f:"";return cm(r,Mi(s.resolved,i),u)+l})}async function um(e,t,i,n,r){let o=t;if(n)o=await n.runOnBeforeFile(e,t);let s=Yl(o,e,i.keepComments,i.isolatedDeclarations??!1);if(n)s=await n.runOnDeclarations(e,o,s);let l=0,c=0;for(let u=0;u<s.length;u++){let a=s[u];if(a.kind==="import")l++;if(a.kind==="export"||a.isExported)c++}let f=Pc(s,{filePath:e,sourceCode:o,declarations:s},i.keepComments,i.importOrder);if(f=await fm(f,e,i),r)f=ac(f,r,{filePath:e});if(i.normalizeOutput===!0||i.declarationOrder)f=rc(f,{lineEnding:"lf",declarationOrder:i.declarationOrder,indent:{style:i.indentStyle??"spaces",size:i.indentSize??2}});if(n)f=await n.runOnAfterFile(e,o,f);return{content:f,declarationCount:s.length,importCount:l,exportCount:c}}var Fc,Go,jo,tm=50,Ri,om;var Wc=de(()=>{Bi();cn();wn();Ds();Bs();js();hl();ml();Zl();Ql();ec();nc();lc();vc();kc();({Glob:Fc}=globalThis.Bun),Go=new WeakMap,jo=new WeakMap;Ri=new Map;om=/[*?[\]{}!]/});var Bc=de(()=>{Wc()});import{createHash as dm}from"crypto";import{existsSync as pm,readFileSync as mm,writeFileSync as gm}from"fs";import{dirname as ym,join as Cm,relative as Gc,resolve as Di,sep as Jr}from"path";import _c from"process";class Vc{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},n=this.listeners.get(e)||[];for(let r of n)await r(i)}}class Uc{manifest;cacheDir;manifestPath;constructor(e,t){this.cacheDir=e,this.manifestPath=Cm(e,"manifest.json"),this.manifest=this.loadManifest(t)}loadManifest(e){try{if(pm(this.manifestPath)){let t=JSON.parse(mm(this.manifestPath,"utf-8"));if(t.configHash===e&&t.version==="1.0")return t}}catch{}return{version:"1.0",configHash:e,entries:{}}}save(){try{let{mkdirSync:e}=hm("fs");e(this.cacheDir,{recursive:!0}),gm(this.manifestPath,JSON.stringify(this.manifest,null,2))}catch{}}getEntry(e){return this.manifest.entries[e]}setEntry(e,t){this.manifest.entries[e]=t}isValid(e,t){return this.getEntry(e)?.hash===t}clear(){this.manifest.entries={},this.save()}}function wm(e){let t={root:e.root,outdir:e.outdir,entrypoints:e.entrypoints,clean:e.clean,tsconfigPath:e.tsconfigPath};return dm("md5").update(JSON.stringify(t)).digest("hex")}function Kc(e={}){let{onSuccess:t,onError:i,failOnError:n=!0,incremental:r=!1,cacheDir:o=".dtsx-cache",on:s,timeout:l=60000,continueOnError:c=!1,verbose:f=!1,...u}=e,a=new Vc;if(s){for(let[m,y]of Object.entries(s))if(y)a.on(m,y)}return{name:"bun-plugin-dtsx",async setup(m){let y=Date.now(),w=null,C=0;try{let A=vm(u,m),k=wm(A);if(A.clean){let D=Di(A.cwd??_c.cwd(),A.outdir??"./dist");if(jc.has(D))A.clean=!1;else jc.add(D)}if(r)w=new Uc(Di(o),k);if(await a.emit("start",{type:"start",files:A.entrypoints||[],config:A}),f){if(console.log("[bun-plugin-dtsx] Starting declaration generation..."),r)console.log("[bun-plugin-dtsx] Incremental mode enabled")}let B=await(async()=>new Promise((D,N)=>{let F=setTimeout(()=>{N(new Ii(`Generation timed out after ${l}ms`,"TIMEOUT_ERROR",{timeout:l}))},l);Ko(A).then((E)=>{clearTimeout(F),D(E)}).catch((E)=>{clearTimeout(F),N(E)})}))(),T=Date.now()-y;if(w)w.save();if(await a.emit("complete",{type:"complete",stats:B,duration:T,fromCache:C}),f){if(console.log(`[bun-plugin-dtsx] Generation complete in ${T}ms`),C>0)console.log(`[bun-plugin-dtsx] ${C} files served from cache`)}if(t)await t(B)}catch(A){let k=bm(A);if(await a.emit("error",{type:"error",error:k}),i)await i(k);else{if(console.error("[bun-plugin-dtsx] Error generating declarations:"),console.error(` Code: ${k.code}`),console.error(` Message: ${k.message}`),k.context)console.error(` Context: ${JSON.stringify(k.context)}`);if(f&&k.stack)console.error(` Stack: ${k.stack}`)}if(n&&!c)throw k}}}}function bm(e){if(e instanceof Ii)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 Ii(e.message,t,{originalError:e.name},e)}return new Ii(String(e),"GENERATION_ERROR")}function Em(e){let t=e.map((n)=>ym(n).split(Jr)),i=t[0];for(let n of t.slice(1)){let r=0;while(r<i.length&&r<n.length&&i[r]===n[r])r++;i=i.slice(0,r)}return i.join(Jr)||Jr}function vm(e,t){let i=e.cwd||_c.cwd(),n=t?.config?.entrypoints,r=e.outdir||e.build?.config.outdir||t?.config.outdir||"./dist",o=e.root||e.build?.config.root||t?.config.root;if(!o&&n?.length){let l=Em(n.map((c)=>Di(i,c)));o=Gc(i,l)||"."}o=o||"./src";let s=e.entrypoints;if(!s)if(n?.length){let l=Di(i,o),c=[];for(let f of n){let u=Di(i,f);if(u===l||u.startsWith(l+Jr))c.push(Gc(l,u));else console.warn(`[bun-plugin-dtsx] Skipping entrypoint outside root "${o}": ${f}`)}s=c.length?c:["index.ts"]}else s=["index.ts"];return{...e,cwd:i,root:o,entrypoints:s,outdir:r,clean:e.clean??!0,tsconfigPath:e.tsconfigPath}}var hm,Ii,jc;var Hc=de(()=>{Bc();hm=import.meta.require;Ii=class Ii extends Error{code;context;cause;constructor(e,t,i,n){super(e);if(this.name="DtsxPluginError",this.code=t,this.context=i,this.cause=n,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}};jc=new Set});import{mkdir as Sm,stat as $m}from"fs/promises";import{bold as Ho,dim as zo,green as xm,italic as zc,log as Am}from"@stacksjs/cli";import{path as rt}from"@stacksjs/path";import{glob as Jc}from"@stacksjs/storage";function sn(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,n=new Set,r=(s,l)=>{let c=i.get(s);if(c!==void 0)return c;if(n.has(s))throw Error(`dependency cycle: ${[...l,s].join(" -> ")}`);n.add(s);let f=t.get(s).dependencies.filter((a)=>a!==s&&t.has(a)),u=f.length?1+Math.max(...f.map((a)=>r(a,[...l,s]))):0;return n.delete(s),i.set(s,u),u},o=[];for(let s of[...e].sort((l,c)=>l.name.localeCompare(c.name)))(o[r(s.name,[])]||=[]).push(s);return o.filter(Boolean)}import{existsSync as sf,readdirSync as af,readFileSync as as}from"fs";import{join as an}from"path";function lf(e){return[...af(e,{withFileTypes:!0}).filter((i)=>i.isDirectory()).map((i)=>an(e,i.name)),e].filter((i)=>{let n=an(i,"package.json");if(!sf(n))return!1;let r=JSON.parse(as(n,"utf8"));return!r.private&&!!r.scripts?.build})}async function cf(e){let t=e.map((r)=>{let o=JSON.parse(as(an(r,"package.json"),"utf8"));if(!o.name||!o.scripts?.build)throw Error(`Not a buildable workspace package: ${r}`);return{name:o.name,dir:r,dependencies:Object.keys(o.dependencies??{})}}),i=sn(t),n=[];for(let{name:r,dir:o,dependencies:s}of i.flat()){let l=n.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(", ")}`),n.push({name:r,dir:o,exitCode:null,blockedBy:l});continue}console.log(`Building ${o}`);let c=Bun.spawn([process.execPath,"run","build"],{cwd:o,stdout:"inherit",stderr:"inherit"});n.push({name:r,dir:o,exitCode:await c.exited,blockedBy:[]})}return n}async function Tm(e){let t=await Jc([rt.resolve(e,"dist","**/*.d.ts")],{absolute:!0}),i=new Bun.Transpiler({loader:"ts",target:"bun"});for(let n of t){let r=await Bun.file(n).text();try{i.transformSync(r)}catch(o){throw Error(`Invalid declaration generated at ${n}: ${o instanceof Error?o.message:String(o)}`)}}}async function Om(e){let t=rt.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 n=new TextDecoder().decode(i.stderr??new Uint8Array),r=/SyntaxError|needs to refer to a top-level declared variable|does not provide an export named|Export named .* not found/i;if(r.test(n)){let o=n.split(`
255
255
  `).find((s)=>r.test(s))??n.trim().split(`
256
256
  `)[0];throw Error(`Built package at ${t} cannot be imported: ${o}
257
- Fix the generated module at its source before publishing.`)}}async function IC(e){let i=Date.now()-e.startTime,n=e.pkgName??`@stacksjs/${rt.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(rt.resolve(e.dir,"dist","tsconfig.json"),`${JSON.stringify({compilerOptions:{paths:{}}},null,2)}
258
- `),await xm(e.dir),await Tm(e.dir);let r=await zc([rt.resolve(e.dir,"dist","**/*")],{absolute:!0});for(let o of r){let s=await Sm(o),a;if(s.size<1048576)a=`${(s.size/1024).toFixed(2)}kb`;else a=`${(s.size/1024/1024).toFixed(2)}mb`;let c=rt.relative(e.dir,o).replace("dist/","");console.log(`${Ho(zo(`[${a}]`))} ${zo("dist/")}${c}`)}console.log(`${Ho(zo(`[${i}ms]`))} Built ${Hc(Ho($m(n)))}`)}async function NC(e){let t=e.pkgName??`@stacksjs/${rt.basename(e.dir)}`;if(e.styled===!1)console.log(`Building ${t}...`);else Am.info(`Building ${Hc(t)}...`);return{startTime:Date.now()}}async function FC(e){await Promise.resolve().then(() => Kc());let i=rt.resolve(e.dir,"src"),n=rt.resolve(e.dir,"dist"),r=(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((a)=>a==="tests"||a==="__tests__"));await Bun.build({entrypoints:r.map((s)=>rt.resolve(i,s)),outdir:n,root:i,target:"bun",format:"esm",splitting:!1,external:e.external??Rm(),plugins:[Uc({root:i,outdir:n})]});let o=new Bun.Transpiler({loader:"ts",target:"bun",minifyWhitespace:!0,define:{"process.env.NODE_ENV":"process.env.NODE_ENV"}});for(let s of r){let a=o.transformSync(await Bun.file(rt.resolve(i,s)).text());a=Om(a);let c=rt.resolve(n,s.replace(/\.ts$/,".js"));await bm(rt.dirname(c),{recursive:!0}),await Bun.write(c,a)}}function Om(e){return e.replace(/(['"])(\.\.?\/[^'"]+?)(?<!\.d)\.tsx?\1/g,"$1$2.js$1")}function Rm(e=[]){let t=[];try{let i=nf("fs"),n=JSON.parse(i.readFileSync(`${process.cwd()}/package.json`,"utf8"));t=[...Object.keys(n.dependencies??{}),...Object.keys(n.peerDependencies??{}),...Object.keys(n.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{lf as buildWorkspacePackages,sn as dependencyLayers,Rm as frameworkExternal,NC as intro,IC as outro,Om as rewriteRelativeTsSpecifiers,FC as transpilePackage,xm as validateDeclarations,Tm as validateRuntimeExports,af as workspaceBuildTargets};
257
+ Fix the generated module at its source before publishing.`)}}async function NC(e){let i=Date.now()-e.startTime,n=e.pkgName??`@stacksjs/${rt.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(rt.resolve(e.dir,"dist","tsconfig.json"),`${JSON.stringify({compilerOptions:{paths:{}}},null,2)}
258
+ `),await Tm(e.dir),await Om(e.dir);let r=await Jc([rt.resolve(e.dir,"dist","**/*")],{absolute:!0});for(let o of r){let s=await $m(o),l;if(s.size<1048576)l=`${(s.size/1024).toFixed(2)}kb`;else l=`${(s.size/1024/1024).toFixed(2)}mb`;let c=rt.relative(e.dir,o).replace("dist/","");console.log(`${Ho(zo(`[${l}]`))} ${zo("dist/")}${c}`)}console.log(`${Ho(zo(`[${i}ms]`))} Built ${zc(Ho(xm(n)))}`)}async function FC(e){let t=e.pkgName??`@stacksjs/${rt.basename(e.dir)}`;if(e.styled===!1)console.log(`Building ${t}...`);else Am.info(`Building ${zc(t)}...`);return{startTime:Date.now()}}async function LC(e){await Promise.resolve().then(() => Hc());let i=rt.resolve(e.dir,"src"),n=rt.resolve(e.dir,"dist"),r=(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:r.map((s)=>rt.resolve(i,s)),outdir:n,root:i,target:"bun",format:"esm",splitting:!1,external:e.external??Pm(),plugins:[Kc({root:i,outdir:n})]});let o=new Bun.Transpiler({loader:"ts",target:"bun",minifyWhitespace:!0,define:{"process.env.NODE_ENV":"process.env.NODE_ENV"}});for(let s of r){let l=o.transformSync(await Bun.file(rt.resolve(i,s)).text());l=Rm(l);let c=rt.resolve(n,s.replace(/\.ts$/,".js"));await Sm(rt.dirname(c),{recursive:!0}),await Bun.write(c,l)}}function Rm(e){return e.replace(/(['"])(\.\.?\/[^'"]+?)(?<!\.d)\.tsx?\1/g,"$1$2.js$1")}function Pm(e=[]){let t=[];try{let i=of("fs"),n=JSON.parse(i.readFileSync(`${process.cwd()}/package.json`,"utf8"));t=[...Object.keys(n.dependencies??{}),...Object.keys(n.peerDependencies??{}),...Object.keys(n.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{cf as buildWorkspacePackages,sn as dependencyLayers,Pm as frameworkExternal,FC as intro,NC as outro,Rm as rewriteRelativeTsSpecifiers,LC as transpilePackage,Tm as validateDeclarations,Om as validateRuntimeExports,lf as workspaceBuildTargets};