@stacksjs/build 0.75.37 → 0.75.40

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 +138 -137
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -1,96 +1,97 @@
1
1
  // @bun
2
- var ce=(e,t,r)=>()=>{if(e)try{t=e(e=0)}catch(n){r=[n]}if(r)throw r[0];return t};var dc=import.meta.require;function Rs(e,t){let r=Number.isFinite(t)?Math.max(1,Math.floor(t)):1;if(e===void 0||!Number.isFinite(e))return r;return Math.max(1,Math.floor(e))}var Os=()=>{};function or(e){if(mc)return Bun.hash(e);let t=0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);t=(t<<5)-t+n,t=t&t}return t}var mc;var Ji=ce(()=>{mc=typeof globalThis.Bun?.hash==="function"});function Ms(e){return e.endsWith(".vue")}function pc(e){let t={script:null,scriptSetup:null},r=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,n;while((n=r.exec(e))!==null){let i=n[1]||"",s=/lang\s*=\s*["']([^"']+)["']/i.exec(i)?.[1]?.toLowerCase()??"js",o={content:n[2]??"",attrs:i,setup:/\bsetup\b/.test(i),lang:s};if(o.setup)t.scriptSetup=o;else t.script=o}return t}function qe(e,t){let r=e[t];t++;while(t<e.length){let n=e[t];if(n==="\\"){t+=2;continue}if(n===r)return t+1;t++}return t}function Ze(e,t){t++;let r=0;while(t<e.length){let n=e[t];if(n==="\\"){t+=2;continue}if(n==="`"&&r===0)return t+1;if(n==="$"&&e[t+1]==="{"){r++,t+=2;continue}if(n==="}"){if(r>0)r--;t++;continue}t++}return t}function lt(e,t){if(e[t+1]==="/"){let r=e.indexOf(`
3
- `,t+2);return r===-1?e.length:r+1}if(e[t+1]==="*"){let r=e.indexOf("*/",t+2);return r===-1?e.length:r+2}return t+1}function Yi(e,t){let r=e[t];if(r==='"'||r==="'")return qe(e,t);if(r==="`")return Ze(e,t);if(r==="/"&&(e[t+1]==="/"||e[t+1]==="*"))return lt(e,t);return t}function Zi(e){let t=e.split(""),r=0;while(r<e.length){let n=Yi(e,r);if(n>r){for(let i=r;i<n;i++)if(t[i]!==`
4
- `&&t[i]!=="\r")t[i]=" ";r=n;continue}r++}return t.join("")}function We(e,t,r,n){let i=0,s=t;while(s<e.length){let o=e[s];if(o==='"'||o==="'"){s=qe(e,s);continue}if(o==="`"){s=Ze(e,s);continue}if(o==="/"&&(e[s+1]==="/"||e[s+1]==="*")){s=lt(e,s);continue}if(o===r)i++;else if(o===n){if(i--,i===0)return s}s++}return-1}function Xi(e,t){let r=0,n=t;while(n<e.length){let i=e[n];if(i==='"'||i==="'"){n=qe(e,n);continue}if(i==="`"){n=Ze(e,n);continue}if(i==="/"&&(e[n+1]==="/"||e[n+1]==="*")){n=lt(e,n);continue}if(i==="="&&e[n+1]===">"){n+=2;continue}if(i==="<")r++;else if(i===">"){if(r--,r===0)return n}n++}return-1}function Gt(e,t=","){let r=[],n=0,i="",s=0;while(s<e.length){let o=e[s];if(o==='"'||o==="'"){let a=qe(e,s);i+=e.slice(s,a),s=a;continue}if(o==="`"){let a=Ze(e,s);i+=e.slice(s,a),s=a;continue}if(o==="/"&&(e[s+1]==="/"||e[s+1]==="*")){s=lt(e,s);continue}if(o==="{"||o==="["||o==="("||o==="<")n++;else if(o==="}"||o==="]"||o===")"||o===">")n--;if(o===t&&n===0){r.push(i),i="",s++;continue}i+=o,s++}if(i.trim()!=="")r.push(i);return r}function cr(e){let t=e.trim();if(!t.startsWith("{"))return[];let r=We(t,0,"{","}");if(r===-1)return[];let n=t.slice(1,r),i=[];for(let s of Gt(n)){let o=-1,a=0;for(let u=0;u<s.length;u++){let l=s[u];if(l==='"'||l==="'"){u=qe(s,u)-1;continue}if(l==="`"){u=Ze(s,u)-1;continue}if(l==="{"||l==="["||l==="("||l==="<")a++;else if(l==="}"||l==="]"||l===")"||l===">")a--;else if(l===":"&&a===0){o=u;break}}if(o!==-1){i.push({key:ar(s.slice(0,o).trim()),value:s.slice(o+1).trim(),isMethod:!1});continue}let c=/^([A-Za-z_$][\w$]*|['"][^'"]+['"])\s*\(/.exec(s.trim());if(c){i.push({key:ar(c[1]),value:s.trim(),isMethod:!0});continue}let f=s.trim();if(f)i.push({key:ar(f),value:"",isMethod:!1})}return i}function ar(e){if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);return e}function lr(e){return/^[A-Za-z_$][\w$]*$/.test(e)?e:JSON.stringify(e)}function fr(e,t){let r=new RegExp(`\\b${t}\\b`,"g"),n;while((n=r.exec(e))!==null){let i=n.index+n[0].length;while(i<e.length&&/\s/.test(e[i]))i++;let s=null;if(e[i]==="<"){let c=Xi(e,i);if(c===-1)return null;s=e.slice(i+1,c).trim(),i=c+1;while(i<e.length&&/\s/.test(e[i]))i++}if(e[i]!=="(")continue;let o=We(e,i,"(",")");if(o===-1)return null;let a=Gt(e.slice(i+1,o));return{generic:s,arg:a.length>0?a[0].trim():null}}return null}function gc(e,t){let r=Ds(e,t);if(!r)return null;return r.kind==="interface"?e.slice(r.bodyStart,r.end):e.slice(r.bodyStart,r.end).trim()}function Ds(e,t){let r=new RegExp(`\\binterface\\s+${t}\\b[^{]*\\{`,"m").exec(e);if(r){let i=r.index+r[0].length-1,s=We(e,i,"{","}");if(s!==-1)return{kind:"interface",start:r.index,end:s+1,bodyStart:i}}let n=new RegExp(`\\btype\\s+${t}\\b[^=]*=`,"m").exec(e);if(n){let i=n.index+n[0].length,s=0,o=i;while(i<e.length){let a=e[i];if(a==='"'||a==="'"){i=qe(e,i);continue}if(a==="`"){i=Ze(e,i);continue}if(a==="{"||a==="["||a==="("||a==="<")s++;else if(a==="}"||a==="]"||a===")"||a===">")s--;else if((a===";"||a===`
5
- `)&&s===0)break;i++}return{kind:"type",start:n.index,end:i,bodyStart:o}}return null}function yc(e){let t=e.search(/\bas\s+PropType\s*</);if(t===-1)return null;let r=e.indexOf("<",t),n=Xi(e,r);if(n===-1)return null;if(e.slice(n+1).trim()!=="")return null;return e.slice(r+1,n).trim()}function qi(e){let t=e.trim(),r=yc(t);if(r!==null)return{type:r,optional:!0};if(t==="null")return{type:"unknown",optional:!0};if(t.startsWith("[")){let n=We(t,0,"[","]");if(n!==-1){let i=Gt(t.slice(1,n)).map((s)=>qi(s).type).filter((s)=>s!=="unknown");return{type:i.length>0?[...new Set(i)].join(" | "):"unknown",optional:!0}}}if(t.startsWith("{")){let n=cr(t),i=n.find((c)=>c.key==="type"),s=n.find((c)=>c.key==="required"),o=i?qi(i.value).type:"unknown",a=!(s&&s.value.trim()==="true");return{type:o,optional:a}}if(ks[t])return{type:ks[t],optional:!0};if(/^[A-Za-z_$][\w$.]*$/.test(t))return{type:t,optional:!0};return{type:"unknown",optional:!0}}function Fr(e){let t=e.trim();if(t.startsWith("{")){let r=cr(t);if(r.length===0)return"{}";return`{ ${r.map((n)=>{if(n.isMethod||n.value==="")return`${lr(n.key)}?: unknown`;let i=qi(n.value);return`${lr(n.key)}${i.optional?"?":""}: ${i.type}`}).join(", ")} }`}if(t.startsWith("[")){let r=We(t,0,"[","]");if(r===-1)return null;let n=Gt(t.slice(1,r)).map((i)=>ar(i.trim())).filter((i)=>i!=="");if(n.length===0)return"{}";return`{ ${n.map((i)=>`${lr(i)}?: unknown`).join(", ")} }`}return null}function Cc(e){let t=e.trim();if(!t.startsWith("["))return null;let r=We(t,0,"[","]");if(r===-1)return null;let n=Gt(t.slice(1,r)).map((i)=>i.trim());if(n.length===0)return"{}";if(!n.every((i)=>i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"')))return"string[]";return`[${n.map((i)=>JSON.stringify(ar(i))).join(", ")}]`}function wc(e){let t=e.trim();if(!t.startsWith("{"))return null;let r=cr(t);if(r.length===0)return"{}";return`{ ${r.map((n)=>`${JSON.stringify(n.key)}: (...args: any[]) => void`).join(", ")} }`}function Is(e){return Cc(e)??wc(e)}function vc(e){let t=[],r=0,n="",i=0;while(i<e.length){let s=e[i];if(s==='"'||s==="'"){let o=qe(e,i);n+=e.slice(i,o),i=o;continue}if(s==="`"){let o=Ze(e,i);n+=e.slice(i,o),i=o;continue}if(s==="/"&&(e[i+1]==="/"||e[i+1]==="*")){let o=lt(e,i);n+=e.slice(i,o),i=o;continue}if(s==="="&&e[i+1]===">"){n+="=>",i+=2;continue}if(s==="{"||s==="["||s==="("||s==="<")r++;else if(s==="}"||s==="]"||s===")"||s===">")r--;if((s===";"||s===","||s===`
6
- `)&&r===0){if(n.trim()!=="")t.push(n.trim());n="",i++;continue}n+=s,i++}if(n.trim()!=="")t.push(n.trim());return t}function Ec(e){let t=e.trim();if(!t.startsWith("{"))return null;let r=We(t,0,"{","}");if(r===-1||t.slice(r+1).trim()!=="")return null;let n=vc(t.slice(1,r));if(n.length===0)return"{}";let i=[];for(let s of n){let o=/^\(\s*\w+\s*:\s*/.exec(s);if(!o)return null;let a=o[0].length,c=s[a];if(c!=="'"&&c!=='"'&&c!=="`")return null;let f=qe(s,a),u=s.slice(a+1,f-1),l=We(s,s.indexOf("(",0),"(",")");if(l===-1)return null;let g=s.slice(a,l),d=Gt(g).slice(1),v=s.slice(l+1).trim();if(v.startsWith(":"))v=v.slice(1).trim();if(v==="")v="void";i.push(`${JSON.stringify(u)}: (${d.map((b)=>b.trim()).join(", ")}) => ${v}`)}return`{ ${i.join(", ")} }`}function Qi(e){let t=e;for(let r of["defineProps","defineEmits","defineExpose","defineSlots","defineOptions"])t=bc(t,r);return t}function bc(e,t){let r=new RegExp(`\\b${t}\\b`,"g"),n=[],i=e,s;while((s=r.exec(e))!==null){let o=e.lastIndexOf(`
7
- `,s.index)+1,a=e.slice(o,s.index),c=/^\s*(?:(?:const|let|var)\s+[A-Za-z_$][\w$]*\s*(?::[^=]+)?=\s*)?(withDefaults\s*\(\s*)?$/.exec(a);if(!c)continue;let f=s.index+s[0].length;while(f<e.length&&/\s/.test(e[f]))f++;if(e[f]==="<"){let g=Xi(e,f);if(g===-1)continue;f=g+1;while(f<e.length&&/\s/.test(e[f]))f++}if(e[f]!=="(")continue;let u=We(e,f,"(",")");if(u===-1)continue;if(c[1]){let g=o+a.length-c[1].length,d=e.indexOf("(",g);if(d!==-1){let v=We(e,d,"(",")");if(v!==-1)u=v}}let l=u+1;while(l<e.length&&e[l]!==`
2
+ var fe=(e,t,r)=>()=>{if(e)try{t=e(e=0)}catch(n){r=[n]}if(r)throw r[0];return t};var pc=import.meta.require;function ks(e,t){let r=Number.isFinite(t)?Math.max(1,Math.floor(t)):1;if(e===void 0||!Number.isFinite(e))return r;return Math.max(1,Math.floor(e))}var Ms=()=>{};function ar(e){if(gc)return Bun.hash(e);let t=0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);t=(t<<5)-t+n,t=t&t}return t}var gc;var Yi=fe(()=>{gc=typeof globalThis.Bun?.hash==="function"});function Is(e){return e.endsWith(".vue")}function yc(e){let t={script:null,scriptSetup:null},r=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,n;while((n=r.exec(e))!==null){let i=n[1]||"",s=/lang\s*=\s*["']([^"']+)["']/i.exec(i)?.[1]?.toLowerCase()??"js",o={content:n[2]??"",attrs:i,setup:/\bsetup\b/.test(i),lang:s};if(o.setup)t.scriptSetup=o;else t.script=o}return t}function Ye(e,t){let r=e[t];t++;while(t<e.length){let n=e[t];if(n==="\\"){t+=2;continue}if(n===r)return t+1;t++}return t}function Xe(e,t){t++;let r=0;while(t<e.length){let n=e[t];if(n==="\\"){t+=2;continue}if(n==="`"&&r===0)return t+1;if(n==="$"&&e[t+1]==="{"){r++,t+=2;continue}if(n==="}"){if(r>0)r--;t++;continue}t++}return t}function ct(e,t){if(e[t+1]==="/"){let r=e.indexOf(`
3
+ `,t+2);return r===-1?e.length:r+1}if(e[t+1]==="*"){let r=e.indexOf("*/",t+2);return r===-1?e.length:r+2}return t+1}function Xi(e,t){let r=e[t];if(r==='"'||r==="'")return Ye(e,t);if(r==="`")return Xe(e,t);if(r==="/"&&(e[t+1]==="/"||e[t+1]==="*"))return ct(e,t);return t}function Qi(e){let t=e.split(""),r=0;while(r<e.length){let n=Xi(e,r);if(n>r){for(let i=r;i<n;i++)if(t[i]!==`
4
+ `&&t[i]!=="\r")t[i]=" ";r=n;continue}r++}return t.join("")}function Le(e,t,r,n){let i=0,s=t;while(s<e.length){let o=e[s];if(o==='"'||o==="'"){s=Ye(e,s);continue}if(o==="`"){s=Xe(e,s);continue}if(o==="/"&&(e[s+1]==="/"||e[s+1]==="*")){s=ct(e,s);continue}if(o===r)i++;else if(o===n){if(i--,i===0)return s}s++}return-1}function en(e,t){let r=0,n=t;while(n<e.length){let i=e[n];if(i==='"'||i==="'"){n=Ye(e,n);continue}if(i==="`"){n=Xe(e,n);continue}if(i==="/"&&(e[n+1]==="/"||e[n+1]==="*")){n=ct(e,n);continue}if(i==="="&&e[n+1]===">"){n+=2;continue}if(i==="<")r++;else if(i===">"){if(r--,r===0)return n}n++}return-1}function jt(e,t=","){let r=[],n=0,i="",s=0;while(s<e.length){let o=e[s];if(o==='"'||o==="'"){let a=Ye(e,s);i+=e.slice(s,a),s=a;continue}if(o==="`"){let a=Xe(e,s);i+=e.slice(s,a),s=a;continue}if(o==="/"&&(e[s+1]==="/"||e[s+1]==="*")){s=ct(e,s);continue}if(o==="{"||o==="["||o==="("||o==="<")n++;else if(o==="}"||o==="]"||o===")"||o===">")n--;if(o===t&&n===0){r.push(i),i="",s++;continue}i+=o,s++}if(i.trim()!=="")r.push(i);return r}function fr(e){let t=e.trim();if(!t.startsWith("{"))return[];let r=Le(t,0,"{","}");if(r===-1)return[];let n=t.slice(1,r),i=[];for(let s of jt(n)){let o=-1,a=0;for(let u=0;u<s.length;u++){let l=s[u];if(l==='"'||l==="'"){u=Ye(s,u)-1;continue}if(l==="`"){u=Xe(s,u)-1;continue}if(l==="{"||l==="["||l==="("||l==="<")a++;else if(l==="}"||l==="]"||l===")"||l===">")a--;else if(l===":"&&a===0){o=u;break}}if(o!==-1){i.push({key:lr(s.slice(0,o).trim()),value:s.slice(o+1).trim(),isMethod:!1});continue}let c=/^([A-Za-z_$][\w$]*|['"][^'"]+['"])\s*\(/.exec(s.trim());if(c){i.push({key:lr(c[1]),value:s.trim(),isMethod:!0});continue}let f=s.trim();if(f)i.push({key:lr(f),value:"",isMethod:!1})}return i}function lr(e){if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);return e}function cr(e){return/^[A-Za-z_$][\w$]*$/.test(e)?e:JSON.stringify(e)}function ur(e,t){let r=new RegExp(`\\b${t}\\b`,"g"),n;while((n=r.exec(e))!==null){let i=n.index+n[0].length;while(i<e.length&&/\s/.test(e[i]))i++;let s=null;if(e[i]==="<"){let c=en(e,i);if(c===-1)return null;s=e.slice(i+1,c).trim(),i=c+1;while(i<e.length&&/\s/.test(e[i]))i++}if(e[i]!=="(")continue;let o=Le(e,i,"(",")");if(o===-1)return null;let a=jt(e.slice(i+1,o));return{generic:s,arg:a.length>0?a[0].trim():null}}return null}function Cc(e,t){let r=Fs(e,t);if(!r)return null;return r.kind==="interface"?e.slice(r.bodyStart,r.end):e.slice(r.bodyStart,r.end).trim()}function Fs(e,t){let r=new RegExp(`\\binterface\\s+${t}\\b[^{]*\\{`,"m").exec(e);if(r){let i=r.index+r[0].length-1,s=Le(e,i,"{","}");if(s!==-1)return{kind:"interface",start:r.index,end:s+1,bodyStart:i}}let n=new RegExp(`\\btype\\s+${t}\\b[^=]*=`,"m").exec(e);if(n){let i=n.index+n[0].length,s=0,o=i;while(i<e.length){let a=e[i];if(a==='"'||a==="'"){i=Ye(e,i);continue}if(a==="`"){i=Xe(e,i);continue}if(a==="{"||a==="["||a==="("||a==="<")s++;else if(a==="}"||a==="]"||a===")"||a===">")s--;else if((a===";"||a===`
5
+ `)&&s===0)break;i++}return{kind:"type",start:n.index,end:i,bodyStart:o}}return null}function wc(e){let t=e.search(/\bas\s+PropType\s*</);if(t===-1)return null;let r=e.indexOf("<",t),n=en(e,r);if(n===-1)return null;if(e.slice(n+1).trim()!=="")return null;return e.slice(r+1,n).trim()}function Zi(e){let t=e.trim(),r=wc(t);if(r!==null)return{type:r,optional:!0};if(t==="null")return{type:"unknown",optional:!0};if(t.startsWith("[")){let n=Le(t,0,"[","]");if(n!==-1){let i=jt(t.slice(1,n)).map((s)=>Zi(s).type).filter((s)=>s!=="unknown");return{type:i.length>0?[...new Set(i)].join(" | "):"unknown",optional:!0}}}if(t.startsWith("{")){let n=fr(t),i=n.find((c)=>c.key==="type"),s=n.find((c)=>c.key==="required"),o=i?Zi(i.value).type:"unknown",a=!(s&&s.value.trim()==="true");return{type:o,optional:a}}if(Ds[t])return{type:Ds[t],optional:!0};if(/^[A-Za-z_$][\w$.]*$/.test(t))return{type:t,optional:!0};return{type:"unknown",optional:!0}}function Lr(e){let t=e.trim();if(t.startsWith("{")){let r=fr(t);if(r.length===0)return"{}";return`{ ${r.map((n)=>{if(n.isMethod||n.value==="")return`${cr(n.key)}?: unknown`;let i=Zi(n.value);return`${cr(n.key)}${i.optional?"?":""}: ${i.type}`}).join(", ")} }`}if(t.startsWith("[")){let r=Le(t,0,"[","]");if(r===-1)return null;let n=jt(t.slice(1,r)).map((i)=>lr(i.trim())).filter((i)=>i!=="");if(n.length===0)return"{}";return`{ ${n.map((i)=>`${cr(i)}?: unknown`).join(", ")} }`}return null}function vc(e){let t=e.trim();if(!t.startsWith("["))return null;let r=Le(t,0,"[","]");if(r===-1)return null;let n=jt(t.slice(1,r)).map((i)=>i.trim());if(n.length===0)return"{}";if(!n.every((i)=>i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"')))return"string[]";return`[${n.map((i)=>JSON.stringify(lr(i))).join(", ")}]`}function Ec(e){let t=e.trim();if(!t.startsWith("{"))return null;let r=fr(t);if(r.length===0)return"{}";return`{ ${r.map((n)=>`${JSON.stringify(n.key)}: (...args: any[]) => void`).join(", ")} }`}function Ns(e){return vc(e)??Ec(e)}function bc(e){let t=[],r=0,n="",i=0;while(i<e.length){let s=e[i];if(s==='"'||s==="'"){let o=Ye(e,i);n+=e.slice(i,o),i=o;continue}if(s==="`"){let o=Xe(e,i);n+=e.slice(i,o),i=o;continue}if(s==="/"&&(e[i+1]==="/"||e[i+1]==="*")){let o=ct(e,i);n+=e.slice(i,o),i=o;continue}if(s==="="&&e[i+1]===">"){n+="=>",i+=2;continue}if(s==="{"||s==="["||s==="("||s==="<")r++;else if(s==="}"||s==="]"||s===")"||s===">")r--;if((s===";"||s===","||s===`
6
+ `)&&r===0){if(n.trim()!=="")t.push(n.trim());n="",i++;continue}n+=s,i++}if(n.trim()!=="")t.push(n.trim());return t}function Sc(e){let t=e.trim();if(!t.startsWith("{"))return null;let r=Le(t,0,"{","}");if(r===-1||t.slice(r+1).trim()!=="")return null;let n=bc(t.slice(1,r));if(n.length===0)return"{}";let i=[];for(let s of n){let o=/^\(\s*\w+\s*:\s*/.exec(s);if(!o)return null;let a=o[0].length,c=s[a];if(c!=="'"&&c!=='"'&&c!=="`")return null;let f=Ye(s,a),u=s.slice(a+1,f-1),l=Le(s,s.indexOf("(",0),"(",")");if(l===-1)return null;let g=s.slice(a,l),p=jt(g).slice(1),v=s.slice(l+1).trim();if(v.startsWith(":"))v=v.slice(1).trim();if(v==="")v="void";i.push(`${JSON.stringify(u)}: (${p.map((b)=>b.trim()).join(", ")}) => ${v}`)}return`{ ${i.join(", ")} }`}function tn(e){let t=e;for(let r of["defineProps","defineEmits","defineExpose","defineSlots","defineOptions"])t=$c(t,r);return t}function $c(e,t){let r=new RegExp(`\\b${t}\\b`,"g"),n=[],i=e,s;while((s=r.exec(e))!==null){let o=e.lastIndexOf(`
7
+ `,s.index)+1,a=e.slice(o,s.index),c=/^\s*(?:(?:const|let|var)\s+[A-Za-z_$][\w$]*\s*(?::[^=]+)?=\s*)?(withDefaults\s*\(\s*)?$/.exec(a);if(!c)continue;let f=s.index+s[0].length;while(f<e.length&&/\s/.test(e[f]))f++;if(e[f]==="<"){let g=en(e,f);if(g===-1)continue;f=g+1;while(f<e.length&&/\s/.test(e[f]))f++}if(e[f]!=="(")continue;let u=Le(e,f,"(",")");if(u===-1)continue;if(c[1]){let g=o+a.length-c[1].length,p=e.indexOf("(",g);if(p!==-1){let v=Le(e,p,"(",")");if(v!==-1)u=v}}let l=u+1;while(l<e.length&&e[l]!==`
8
8
  `&&/\s|;/.test(e[l]))l++;if(e[l]===`
9
- `)l++;n.push([o,l])}for(let o=n.length-1;o>=0;o--)i=i.slice(0,n[o][0])+i.slice(n[o][1]);return i}function en(e){let t=Sc(e);if(t!==-1){let r=/^export\s+default\b/.exec(e.slice(t))?.[0];if(!r)return{options:null,script:e,passthrough:!1};let n=t+r.length;while(n<e.length&&/\s/.test(e[n]))n++;let i=-1,s=-1,o=-1;if(e[n]==="{")i=n,s=We(e,n,"{","}"),o=s;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]==="{")i=u,s=We(e,u,"{","}"),o=We(e,f,"(",")")}}if(i===-1||s===-1||o===-1)return{options:null,script:e,passthrough:!0};let a=o+1;if(e[a]===";")a++;let c=(e.slice(0,t)+e.slice(a)).trim();return{options:e.slice(i,s+1),script:c,passthrough:!1}}return{options:null,script:e,passthrough:!1}}function Sc(e){let t=0,r=0;while(r<e.length){let n=e[r];if(n==='"'||n==="'"){r=qe(e,r);continue}if(n==="`"){r=Ze(e,r);continue}if(n==="/"&&(e[r+1]==="/"||e[r+1]==="*")){r=lt(e,r);continue}if(n==="{"||n==="["||n==="(")t++;else if(n==="}"||n==="]"||n===")")t=Math.max(0,t-1);else if(t===0&&e.startsWith("export",r)){let i=r===0?"":e[r-1],s=e[r+6]??"";if(!/[\w$]/.test(i)&&!/[\w$]/.test(s)){if(/^export\s+default\b/.exec(e.slice(r)))return r}}r++}return-1}function Mr(e,t){let r=cr(e).find((n)=>n.key===t);return r&&r.value!==""?r.value:null}function Dr(e,t){let r=$c(e),n=e;for(let i=r.length-1;i>=0;i--){let s=r[i],o=n.slice(0,s.start)+n.slice(s.end);if(Ac(o,s.name))continue;if(new RegExp(`\\btypeof\\s+${s.name}\\b`).test(t))continue;n=o}return n}function Ac(e,t){let r=0;while(r<e.length){let n=e[r];if(n==='"'||n==="'"){r=qe(e,r);continue}if(n==="`"){r=Ze(e,r);continue}if(n==="/"&&(e[r+1]==="/"||e[r+1]==="*")){r=lt(e,r);continue}if(/[A-Za-z_$]/.test(n)){let i=r+1;while(i<e.length&&/[\w$]/.test(e[i]))i++;if(e.slice(r,i)===t)return!0;r=i;continue}r++}return!1}function $c(e){let t=[],r=xc(e),n=/^[ \t]*(const|let|var|(?:async[ \t]+)?function)[ \t]+([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=?/gm,i;while((i=n.exec(e))!==null){let s=e.lastIndexOf(`
10
- `,i.index)+1;if(!r.has(s))continue;if(/\bexport\b/.test(e.slice(s,i.index)))continue;let o=i[1],a=i[2],c=i.index+i[0].length,f=-1;if(o.endsWith("function")){let u=e.indexOf("(",c);if(u===-1)continue;let l=We(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]!==`
9
+ `)l++;n.push([o,l])}for(let o=n.length-1;o>=0;o--)i=i.slice(0,n[o][0])+i.slice(n[o][1]);return i}function rn(e){let t=Ac(e);if(t!==-1){let r=/^export\s+default\b/.exec(e.slice(t))?.[0];if(!r)return{options:null,script:e,passthrough:!1};let n=t+r.length;while(n<e.length&&/\s/.test(e[n]))n++;let i=-1,s=-1,o=-1;if(e[n]==="{")i=n,s=Le(e,n,"{","}"),o=s;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]==="{")i=u,s=Le(e,u,"{","}"),o=Le(e,f,"(",")")}}if(i===-1||s===-1||o===-1)return{options:null,script:e,passthrough:!0};let a=o+1;if(e[a]===";")a++;let c=(e.slice(0,t)+e.slice(a)).trim();return{options:e.slice(i,s+1),script:c,passthrough:!1}}return{options:null,script:e,passthrough:!1}}function Ac(e){let t=0,r=0;while(r<e.length){let n=e[r];if(n==='"'||n==="'"){r=Ye(e,r);continue}if(n==="`"){r=Xe(e,r);continue}if(n==="/"&&(e[r+1]==="/"||e[r+1]==="*")){r=ct(e,r);continue}if(n==="{"||n==="["||n==="(")t++;else if(n==="}"||n==="]"||n===")")t=Math.max(0,t-1);else if(t===0&&e.startsWith("export",r)){let i=r===0?"":e[r-1],s=e[r+6]??"";if(!/[\w$]/.test(i)&&!/[\w$]/.test(s)){if(/^export\s+default\b/.exec(e.slice(r)))return r}}r++}return-1}function Ir(e,t){let r=fr(e).find((n)=>n.key===t);return r&&r.value!==""?r.value:null}function Fr(e,t){let r=Tc(e),n=e;for(let i=r.length-1;i>=0;i--){let s=r[i],o=n.slice(0,s.start)+n.slice(s.end);if(xc(o,s.name))continue;if(new RegExp(`\\btypeof\\s+${s.name}\\b`).test(t))continue;n=o}return n}function xc(e,t){let r=0;while(r<e.length){let n=e[r];if(n==='"'||n==="'"){r=Ye(e,r);continue}if(n==="`"){r=Xe(e,r);continue}if(n==="/"&&(e[r+1]==="/"||e[r+1]==="*")){r=ct(e,r);continue}if(/[A-Za-z_$]/.test(n)){let i=r+1;while(i<e.length&&/[\w$]/.test(e[i]))i++;if(e.slice(r,i)===t)return!0;r=i;continue}r++}return!1}function Tc(e){let t=[],r=Pc(e),n=/^[ \t]*(const|let|var|(?:async[ \t]+)?function)[ \t]+([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=?/gm,i;while((i=n.exec(e))!==null){let s=e.lastIndexOf(`
10
+ `,i.index)+1;if(!r.has(s))continue;if(/\bexport\b/.test(e.slice(s,i.index)))continue;let o=i[1],a=i[2],c=i.index+i[0].length,f=-1;if(o.endsWith("function")){let u=e.indexOf("(",c);if(u===-1)continue;let l=Le(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]!==`
11
11
  `)c++;while(c<e.length&&/\s/.test(e[c])&&e[c]!==`
12
- `)c++;if(e[c]!=="{")continue;let g=We(e,c,"{","}");if(g===-1)continue;f=g+1}else{let u=0;while(c<e.length){let l=e[c];if(l==='"'||l==="'"){c=qe(e,c);continue}if(l==="`"){c=Ze(e,c);continue}if(l==="/"&&(e[c+1]==="/"||e[c+1]==="*")){c=lt(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===`
12
+ `)c++;if(e[c]!=="{")continue;let g=Le(e,c,"{","}");if(g===-1)continue;f=g+1}else{let u=0;while(c<e.length){let l=e[c];if(l==='"'||l==="'"){c=Ye(e,c);continue}if(l==="`"){c=Xe(e,c);continue}if(l==="/"&&(e[c+1]==="/"||e[c+1]==="*")){c=ct(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===`
13
13
  `&&u===0){f=c;break}c++}if(f===-1)f=e.length}if(e[f]===`
14
- `)f++;t.push({name:a,start:i.index,end:f})}return t}function xc(e){let t=new Set([0]),r=0,n=0;while(n<e.length){let i=e[n];if(i==='"'||i==="'"){n=qe(e,n);continue}if(i==="`"){n=Ze(e,n);continue}if(i==="/"&&(e[n+1]==="/"||e[n+1]==="*")){n=lt(e,n);continue}if(i==="{"||i==="["||i==="(")r++;else if(i==="}"||i==="]"||i===")")r=Math.max(0,r-1);if(i===`
15
- `&&r===0)t.add(n+1);n++}return t}function Ir(e,t,r){let n=e.indexOf(r);if(n===-1)return e;let i=e.lastIndexOf(`
16
- `,n)+1;if(/\bexport\b/.test(e.slice(i,n)))return e;let s=e.slice(0,n)+e.slice(n+r.length);if(new RegExp(`\\b${t}\\b`).test(s))return e;return s}function tn(e){let t="",r=0,n=()=>{for(let s=t.length-1;s>=0;s--)if(!/\s/.test(t[s]))return t[s];return""},i=(s)=>{for(let o=s;o<e.length;o++)if(!/\s/.test(e[o]))return e[o];return""};while(r<e.length){let s=e[r];if(s==='"'||s==="'"){let o=qe(e,r);t+=e.slice(r,o),r=o;continue}if(s==="`"){let o=Ze(e,r);t+=e.slice(r,o),r=o;continue}if(s==="/"&&e[r+1]==="*"){let o=lt(e,r);t+=e.slice(r,o).replace(/\s*\n\s*/g," "),r=o;continue}if(s==="/"&&e[r+1]==="/"){let o=r+2;while(o<e.length&&e[o]!==`
14
+ `)f++;t.push({name:a,start:i.index,end:f})}return t}function Pc(e){let t=new Set([0]),r=0,n=0;while(n<e.length){let i=e[n];if(i==='"'||i==="'"){n=Ye(e,n);continue}if(i==="`"){n=Xe(e,n);continue}if(i==="/"&&(e[n+1]==="/"||e[n+1]==="*")){n=ct(e,n);continue}if(i==="{"||i==="["||i==="(")r++;else if(i==="}"||i==="]"||i===")")r=Math.max(0,r-1);if(i===`
15
+ `&&r===0)t.add(n+1);n++}return t}function Nr(e,t,r){let n=e.indexOf(r);if(n===-1)return e;let i=e.lastIndexOf(`
16
+ `,n)+1;if(/\bexport\b/.test(e.slice(i,n)))return e;let s=e.slice(0,n)+e.slice(n+r.length);if(new RegExp(`\\b${t}\\b`).test(s))return e;return s}function nn(e){let t="",r=0,n=()=>{for(let s=t.length-1;s>=0;s--)if(!/\s/.test(t[s]))return t[s];return""},i=(s)=>{for(let o=s;o<e.length;o++)if(!/\s/.test(e[o]))return e[o];return""};while(r<e.length){let s=e[r];if(s==='"'||s==="'"){let o=Ye(e,r);t+=e.slice(r,o),r=o;continue}if(s==="`"){let o=Xe(e,r);t+=e.slice(r,o),r=o;continue}if(s==="/"&&e[r+1]==="*"){let o=ct(e,r);t+=e.slice(r,o).replace(/\s*\n\s*/g," "),r=o;continue}if(s==="/"&&e[r+1]==="/"){let o=r+2;while(o<e.length&&e[o]!==`
17
17
  `)o++;let a=e.slice(r+2,o).trim();if(a!==""&&!a.includes("*/"))t+=`/* ${a} */`;r=o;continue}if(s===`
18
- `){let o=n(),a=i(r+1);if(o===""||a===""){r++;continue}let c=Tc(t);if(!c&&("{;,(<:=[".includes(o)||"}),]>;|&".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+="; "}r++;while(r<e.length&&(e[r]===" "||e[r]==="\t"))r++;continue}t+=s,r++}return t}function Tc(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 r=e.lastIndexOf("/*",t);if(r===-1)return!1;for(let n=r-1;n>=0;n--){let i=e[n];if(/\s/.test(i))continue;return"{;,(<:".includes(i)}return!0}function Nr(e,t){let r=[e,t].filter((n)=>n!==null);for(let n of r){let i=fr(n,"defineProps");if(!i)continue;if(i.generic){let s=i.generic;if(s.startsWith("{"))return{type:s};if(/^[A-Za-z_$][\w$]*$/.test(s)){for(let o of r){let a=Ds(o,s);if(!a)continue;let c=gc(o,s);if(c===null)continue;return{type:c,inlinedLocal:{name:s,declText:o.slice(a.start,a.end)}}}return{type:s}}return{type:s}}if(i.arg){let s=Fr(i.arg);if(s!==null)return{type:s}}}return null}function rn(e,t){let r=[e,t].filter((n)=>n!==null);for(let n of r){let i=fr(n,"defineEmits");if(!i)continue;if(i.generic)return Ec(i.generic)??i.generic;if(i.arg){let s=Is(i.arg);if(s!==null)return s}}return null}function nn(e,t){let r=[e,t].filter((n)=>n!==null);for(let n of r){let i=fr(n,"defineExpose");if(!i||!i.arg||!i.arg.startsWith("{"))continue;let s=cr(i.arg);if(s.length===0)return null;return`{ ${s.map((o)=>{if(o.value===""&&/^[A-Za-z_$][\w$]*$/.test(o.key))return`${lr(o.key)}: typeof ${o.key}`;let a=o.isMethod||/=>|^\s*function\b/.test(o.value);return`${lr(o.key)}: ${a?"(...args: any[]) => any":"unknown"}`}).join(", ")} }`}return null}function Fs(e){let t=pc(e),r="",n=null,i=null;if(t.script){let C=en(t.script.content);if(C.passthrough)return t.scriptSetup?`${t.script.content}
19
- ${t.scriptSetup.content}`:t.script.content;if(r=C.script,C.options){let T=Mr(C.options,"props");if(T)n=Fr(T);let k=Mr(C.options,"emits");if(k)i=Is(k)}}let s=t.scriptSetup?.content??null,o=s!==null?Qi(s):null,a=Nr(s,s!==null?null:r),c=a?.type??n??"{}",f=rn(s,null)??i,u=nn(s,null),l=a?.inlinedLocal;if(l){if(r=Ir(r,l.name,l.declText),o!==null)o=Ir(o,l.name,l.declText)}let g=[c,u??"{}"];if(f)g.push("{}","{}","{}","{}","{}",f);let d=tn(`DefineComponent<${g.join(", ")}>`),v=[],b=Dr(r,d);if(b.trim()!=="")v.push(b);if(o&&o.trim()!==""){let C=Dr(o,d);if(C.trim()!=="")v.push(C)}return v.push("import type { DefineComponent } from 'vue'"),v.push(`type __DtsxComponentType = ${d}`),v.push("const __dtsx_component__: __DtsxComponentType = null as unknown as __DtsxComponentType"),v.push("export default __dtsx_component__"),v.join(`
20
- `)}var ks;var sn=ce(()=>{ks={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 Ls(e){return e.endsWith(".stx")}function Pc(e){let t=[],r=/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi,n;while((n=r.exec(e))!==null){let i=n[1]??"",s=/\blang\s*=\s*["']([^"']+)["']/i.exec(i)?.[1]?.toLowerCase()??(/\b(?:type\s*=\s*["'](?:text\/)?typescript["']|typescript)\b/i.test(i)?"ts":"js"),o=/\bserver\b/i.test(i)?"server":/\bclient\b/i.test(i)?"client":"universal";t.push({content:n[2]??"",kind:"script",attrs:i,context:o,lang:s,start:n.index})}return t}function Rc(e){let t=[],r=/^[ \t]*@ts[ \t]*(?:\r?\n|$)/gm,n;while((n=r.exec(e))!==null){let i=r.lastIndex,s=/^[ \t]*@endts[ \t]*(?:\r?\n|$)/gm;s.lastIndex=i;let o=s.exec(e),a=o?.index??e.length;if(t.push({content:e.slice(i,a),kind:"ts",attrs:"",context:"universal",lang:"ts",start:n.index}),!o)break;r.lastIndex=s.lastIndex}return t}function Oc(e){return[...Pc(e),...Rc(e)].sort((t,r)=>t.start-r.start)}function kc(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 Mc(e){let t=/(?:\$?props)\s+as\s+/g,r;while((r=t.exec(e))!==null){let n=t.lastIndex;while(n<e.length&&/\s/.test(e[n]))n++;if(e[n]==="{"){let o=We(e,n,"{","}");if(o!==-1)return e.slice(n,o+1).trim();continue}let i=/^[A-Za-z_$][\w$]*/.exec(e.slice(n))?.[0];if(!i)continue;let s=n+i.length;while(s<e.length&&/\s/.test(e[s]))s++;if(e[s]==="<"){let o=We(e,s,"<",">");if(o!==-1)s=o+1}return e.slice(n,s).trim()}return null}function Dc(e){return/\b(?:const|let|var)\s+\$?props\s*:\s*([^=;\n]+)/.exec(e)?.[1]?.trim()??null}function Ic(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 Fc(e,t){if(!e||e==="unknown")return t;if(t==="unknown"||e===t)return e;return[...new Set([...e.split(" | "),...t.split(" | ")])].join(" | ")}function Nc(e){let t=Zi(e),r=new Map,n=/\$props(?:\.([A-Za-z_$][\w$]*)|\[\s*(['"])([^'"\n]+)\2\s*\])/g,i;while((i=n.exec(e))!==null){if(t.slice(i.index,i.index+6)!=="$props")continue;let s=i[1]??i[3],o=Ic(e.slice(n.lastIndex));r.set(s,Fc(r.get(s),o))}if(r.size===0)return null;return{type:`{ ${[...r].map(([s,o])=>`${/^[A-Za-z_$][\w$]*$/.test(s)?s:JSON.stringify(s)}?: ${o}`).join(", ")} }`}}function Lc(e){let t=Nr(e,null);if(t)return t;let r=Mc(e)??Dc(e);if(!r)return Nc(e);if(/^[A-Za-z_$][\w$]*$/.test(r)){let n=r.replace(/[$]/g,"\\$&");if(new RegExp(`\\bexport\\s+(?:declare\\s+)?(?:interface|type)\\s+${n}\\b`).test(e))return{type:r}}return Nr(`${e}
21
- defineProps<${r}>()`,null)}function Wc(e){return Qi(e)}function Ns(e){let t=Zi(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 Bc(e){let t=[],r=0,n=0,i=0;while(i<e.length){let o=e[i],a=Yi(e,i);if(a>i){i=a;continue}if(o==="{"||o==="["||o==="(")n++;else if(o==="}"||o==="]"||o===")")n=Math.max(0,n-1);if((o===";"||o===`
22
- `)&&n===0){let c=i+1;if(!Ns(e.slice(r,c)))t.push([r,c]);r=c}i++}if(r<e.length&&!Ns(e.slice(r)))t.push([r,e.length]);let s=e;for(let o=t.length-1;o>=0;o--)s=s.slice(0,t[o][0])+s.slice(t[o][1]);return s}function Ws(e){let t=Oc(e).filter(kc).map((b)=>b.content).join(`
23
- `),r=null,n=en(t);if(n.passthrough)return t;if(t=n.script,n.options){let b=Mr(n.options,"props");if(b)r=Fr(b)}let i=t,s=Wc(t),o=Lc(i),a=o?.type??r??"{}",c=rn(i,null),f=nn(i,null),u=fr(i,"defineSlots")?.generic??null,l=o?.inlinedLocal;if(l)s=Ir(s,l.name,l.declText);let g=`DefineComponent<${a}>`,d=[];if(c)d.push(`readonly __stxEmits?: ${c}`);if(u)d.push(`readonly __stxSlots?: ${u}`);if(f)d.push(`readonly __stxExposed?: ${f}`);if(d.length>0)g+=` & { ${d.join(", ")} }`;g=tn(g),s=Bc(Dr(s,g));let v=["import type { DefineComponent } from '@stacksjs/stx'",`type __DtsxStxComponentType = ${g}`,"const __dtsx_component__: __DtsxStxComponentType = null as unknown as __DtsxStxComponentType","export default __dtsx_component__"];if(s.trim()!=="")v.push(s);return v.join(`
24
- `)}var Bs=ce(()=>{sn()});function Gc(e){if(e.indexOf("/*")===-1)return e.trim();let t=[],r=0,n=0,i=e.length;while(n<i)if(e.charCodeAt(n)===47&&n+1<i&&e.charCodeAt(n+1)===42){if(n>r)t.push(e.substring(r,n));n+=2;while(n<i-1){if(e.charCodeAt(n)===42&&e.charCodeAt(n+1)===47){n+=2;break}n++}r=n}else n++;if(r<i)t.push(e.substring(r));return t.join("").trim()}function fn(){Gr=!0,_e=null}function un(){Gr=!1;let e=_e;return _e=null,e}function hn(e){let t=e.length;if(t===0)return!1;let r=0;if(e.charCodeAt(r)===45)r++;if(r>=t)return!1;let n=r;while(r<t&&e.charCodeAt(r)>=48&&e.charCodeAt(r)<=57)r++;if(r===n)return!1;if(r<t&&e.charCodeAt(r)===46){r++;let i=r;while(r<t&&e.charCodeAt(r)>=48&&e.charCodeAt(r)<=57)r++;if(r===i)return!1}return r===t}function jc(e){for(let t=0,r=e.length-1;t<r;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return!0}function on(e,t){let r=0,n=0;while((n=e.indexOf(t,n))!==-1)r++,n+=t.length;return r}function Gs(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 Lr(e){let t=e.trim();if(t.length<3||t.charCodeAt(0)!==60)return!1;if(t.startsWith("<>"))return t.endsWith("</>");let r=t.charCodeAt(1);if(!(r>=65&&r<=90||r>=97&&r<=122||r===36||r===95))return!1;let n=2;while(n<t.length&&Gs(t.charCodeAt(n)))n++;let i=t.slice(1,n),s=t.charCodeAt(n);if(s>32&&s!==62&&s!==47)return!1;if(t.endsWith("/>"))return!0;let o=t.lastIndexOf("</");if(o===-1)return!1;let a=o+2;while(a<t.length&&Gs(t.charCodeAt(a)))a++;return t.slice(o+2,a)===i&&t.charCodeAt(a)===62&&a===t.length-1}function ur(e){let t=e.length,r=!1;for(let o=1;o<t;o++)if(e.charCodeAt(o)<=32&&e.charCodeAt(o-1)<=32){r=!0;break}if(!r)for(let o=0;o<t;o++){let a=e.charCodeAt(o);if(a===10||a===13||a===9){r=!0;break}}if(!r)return e;let n=[],i=-1,s=!1;for(let o=0;o<t;o++)if(e.charCodeAt(o)<=32){if(!s){if(i>=0)n.push(e.substring(i,o));n.push(" "),s=!0,i=-1}}else{if(s||i<0)i=o;s=!1}if(i>=0)n.push(e.substring(i));return n.join("")}function Te(e,t=!1,r=!1,n=0){if(!e||typeof e!=="string")return"unknown";if(n>=20)return"unknown";let i=e.trim();if(Lr(i))return"JSX.Element";if(i.startsWith("BigInt("))return"bigint";if(i.startsWith("Symbol.for("))return"symbol";if(i.includes(".raw`")||i.includes("String.raw`"))return"string";if(i.startsWith("`")&&i.endsWith("`")){if(!t||i.includes("${")||i.includes(`
25
- `)||i.includes("\r"))return"string";return i}if(i.charCodeAt(0)===39||i.charCodeAt(0)===34){let o=_c(i);if(o!==null){if(o==="string"||!t)return"string";return o}}if(hn(i)){if(!t)return"number";return i}if(i==="true"||i==="false"){if(!t)return"boolean";return i}if(i==="null")return"null";if(i==="undefined")return"undefined";if(i.startsWith("[")&&i.endsWith("]"))return an(i,t,n+1);if(i.startsWith("{")&&i.endsWith("}"))return tf(i,t,n+1);if(i.startsWith("class ")||i.startsWith("class{"))return Qc(i);if(i.startsWith("new "))return Xc(i);if(i.endsWith("as const")){let o=i.slice(0,-8).trim();if(o.startsWith("[")&&o.endsWith("]")){let a=o.slice(1,-1).trim();if(!a)return"readonly []";let c=Wr(a),f=[];for(let u=0;u<c.length;u++)f.push(Te(c[u].trim(),!0,!1,n+1));return`readonly [${f.join(", ")}]`}return Te(o,!0,r,n+1)}if(Br(i)!==-1||i.startsWith("function")||i.startsWith("async"))return Xs(i,r,n,t);if(i.startsWith("`")&&i.endsWith("`"))return Zc(i,t);if(i.startsWith("Promise."))return Js(i,t,n);if(i.startsWith("await "))return"unknown";if(i.charCodeAt(i.length-1)===110&&i.length>1&&jc(i)){if(t)return i;return"bigint"}if(i.startsWith("Symbol(")||i==="Symbol.for")return"symbol";let s=qs(i);if(s!==null)return s;if(zc(i))return"boolean";if(Hc(i))return"number";return"unknown"}function js(e){let t=e.charCodeAt(0);if(t!==39&&t!==34)return!1;return Rt(e,0,t)===e.length}function _c(e){if(js(e))return e;let t=Vc(e);if(t.length<2)return null;let r=!1,n=!0,i="";for(let s of t){let o=s.trim();if(js(o))r=!0,i+=Uc(o);else n=!1}if(n)return Kc(i);if(r)return"string";return null}function Vc(e){let t=[],r=0,n=0,i=0;while(i<e.length){let s=e.charCodeAt(i);if(s===39||s===34||s===96){i=Rt(e,i,s);continue}if(s===40||s===91||s===123)r++;else if(s===41||s===93||s===125)r--;else if(s===43&&r===0)t.push(e.slice(n,i)),n=i+1;i++}return t.push(e.slice(n)),t}function Uc(e){return e.slice(1,-1).replace(/\\(.)/g,(t,r)=>{if(r==="n")return`
26
- `;if(r==="t")return"\t";if(r==="r")return"\r";if(r==="0")return"\x00";return r})}function Kc(e){return`'${e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function Hc(e){if(e==="")return!1;let t=!1,r=!1;for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);if(i>=48&&i<=57){t=!0;continue}if(i===43||i===45||i===42||i===47||i===37){r=!0;continue}if(i===46||i===40||i===41||i<=32)continue;return!1}return t&&r}function zc(e){let t=0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n===34||n===39||n===96){r=Rt(e,r,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("===",r)||e.startsWith("!==",r)||e.startsWith("==",r)||e.startsWith("!=",r)||e.startsWith(">=",r)||e.startsWith("<=",r))return!0;if((n===62||n===60)&&e.charCodeAt(r-1)!==61&&e.charCodeAt(r+1)!==61)return!0}return!1}function Jc(e,t=!1,r=0){return Te(e,t,!0,r)}function hr(e,t=!1,r=""){let n=Hs(r),i=[],s=!1,o=0;while(o<e.length){let c=e.charCodeAt(o);if(c===34||c===39||c===96){o=Rt(e,o,c);continue}if(c===47&&e.charCodeAt(o+1)===47){o+=2;while(o<e.length&&e.charCodeAt(o)!==10&&e.charCodeAt(o)!==13)o++;continue}if(c===47&&e.charCodeAt(o+1)===42){let f=e.indexOf("*/",o+2);o=f===-1?e.length:f+2;continue}if(e.startsWith("function",o)&&_s(e,o,8)||e.startsWith("class",o)&&_s(e,o,5)){let f=Yc(e,o);if(f!==-1){o=Vs(e,f);continue}}if(c===61&&e.charCodeAt(o+1)===62){let f=o+2;while(f<e.length&&e.charCodeAt(f)<=32)f++;if(e.charCodeAt(f)===123){o=Vs(e,f);continue}}if(e.startsWith("return",o)&&(o===0||!ut(e.charCodeAt(o-1)))&&!ut(e.charCodeAt(o+6))){o+=6;let f=!1;while(o<e.length&&e.charCodeAt(o)<=32){let C=e.charCodeAt(o);if(C===10||C===13)f=!0;o++}if(f||o>=e.length||e.charCodeAt(o)===59||e.charCodeAt(o)===125){s=!0;continue}let u=o,l=0,g=0,d=0;while(o<e.length){let C=e.charCodeAt(o);if(C===34||C===39||C===96){o=Rt(e,o,C);continue}if(C===47&&e.charCodeAt(o+1)===47)break;if(C===47&&e.charCodeAt(o+1)===42){let T=e.indexOf("*/",o+2);o=T===-1?e.length:T+2;continue}if(C===40)l++;else if(C===41)l--;else if(C===91)g++;else if(C===93)g--;else if(C===123)d++;else if(C===125){if(d===0&&l===0&&g===0)break;d--}else if(C===59&&l===0&&g===0&&d===0)break;else if((C===10||C===13)&&l===0&&g===0&&d===0){let T=o+1;while(T<e.length&&e.charCodeAt(T)<=32)T++;if(e.startsWith("return",T)&&!ut(e.charCodeAt(T+6)))break}o++}let v=e.slice(u,o).trim(),b=Pt(v,n);if(!i.includes(b))i.push(b);continue}o++}if(s&&!i.includes("undefined"))i.push("undefined");let a=i.includes("unknown")?"unknown":i.length===0?"void":i.join(" | ");return t&&!a.startsWith("Promise<")?`Promise<${a}>`:a}function Hs(e){let t=new Map,r=e.startsWith("(")&&e.endsWith(")")?e.slice(1,-1):e,n=0,i=0,s=0;for(let o=0;o<=r.length;o++){let a=r.charCodeAt(o);if(a===40||a===91||a===123)i++;else if(a===41||a===93||a===125)i--;else if(a===60)s++;else if(a===62&&r.charCodeAt(o-1)!==61&&s>0)s--;if(o!==r.length&&(a!==44||i!==0||s!==0))continue;let c=r.slice(n,o).trim(),f=c.indexOf(":");if(f!==-1){let u=c.slice(0,f).trim().replace(/^\.\.\./,"").replace(/\?$/,""),l=c.slice(f+1).trim(),g=l.indexOf("=");if(g!==-1)l=l.slice(0,g).trim();if(dr(u)&&l)t.set(u,l)}n=o+1}return t}function Pt(e,t){let r=e.trim();while(zs(r))r=r.slice(1,-1).trim();if(Lr(r))return"JSX.Element";if(r.startsWith("await ")){let s=Pt(r.slice(6),t);return s.startsWith("Promise<")&&s.endsWith(">")?s.slice(8,-1):s}if(t.has(r))return t.get(r);if(r.startsWith("!"))return"boolean";if(r.startsWith("fetch("))return"Promise<Response>";let n=qc(r);if(n){let s=Pt(n.whenTrue,t),o=Pt(n.whenFalse,t);return s===o?s:`${s} | ${o}`}if(["===","!==","==","!=",">=","<="].some((s)=>r.includes(s))||r.includes(" > ")||r.includes(" < "))return"boolean";let i=0;for(let s=r.length-1;s>=0;s--){let o=r.charCodeAt(s);if(o===41||o===93||o===125)i++;else if(o===40||o===91||o===123)i--;else if(i===0&&(o===43||o===45||o===42||o===47||o===37)){let a=Pt(r.slice(0,s),t),c=Pt(r.slice(s+1),t);if(o===43&&(a==="string"||c==="string"))return"string";if(a==="number"&&c==="number")return"number";break}}return Te(r,!1).replace(/\btypeof\s+[$A-Z_a-z][$\w]*/g,(s)=>{let o=s.slice(7);return t.get(o)??"unknown"})}function zs(e){if(!e.startsWith("(")||!e.endsWith(")"))return!1;let t=0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n===40)t++;else if(n===41&&--t===0)return r===e.length-1}return!1}function qc(e){let t=0,r=-1;for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);if(i===40||i===91||i===123)t++;else if(i===41||i===93||i===125)t--;else if(i===63&&t===0&&e.charCodeAt(n+1)!==63)r=n;else if(i===58&&t===0&&r!==-1)return{whenTrue:e.slice(r+1,n),whenFalse:e.slice(n+1)}}return null}function _s(e,t,r){return(t===0||!ut(e.charCodeAt(t-1)))&&!ut(e.charCodeAt(t+r))}function Yc(e,t){for(let r=t;r<e.length;r++){let n=e.charCodeAt(r);if(n===34||n===39||n===96){r=Rt(e,r,n)-1;continue}if(n===123)return r;if(n===59)return-1}return-1}function Vs(e,t){let r=1,n=t+1;while(n<e.length&&r>0){let i=e.charCodeAt(n);if(i===34||i===39||i===96){n=Rt(e,n,i);continue}if(i===47&&e.charCodeAt(n+1)===47){n+=2;while(n<e.length&&e.charCodeAt(n)!==10&&e.charCodeAt(n)!==13)n++;continue}if(i===47&&e.charCodeAt(n+1)===42){let s=e.indexOf("*/",n+2);n=s===-1?e.length:s+2;continue}if(i===123)r++;else if(i===125)r--;n++}return n}function Rt(e,t,r){let n=t+1;while(n<e.length){let i=e.charCodeAt(n);if(i===92){n+=2;continue}if(n++,i===r)break}return n}function Zc(e,t){if(e.includes(".raw`")||e.includes("String.raw`"))return"string";if(!t||e.includes("${")||e.includes(`
27
- `)||e.includes("\r"))return"string";return e}function Xc(e){let t=4;while(t<e.length&&e.charCodeAt(t)<=32)t++;let r=t,n=e.charCodeAt(t);if(n<65||n>90)return"unknown";while(t<e.length&&(ut(e.charCodeAt(t))||e.charCodeAt(t)===46))t++;if(t===r)return"unknown";let i=e.slice(r,t);{let s=e.slice(t),o=s;if(s.startsWith("<")){let c=0,f=-1;for(let u=0;u<s.length;u++)if(s[u]==="<")c++;else if(s[u]===">"){if(c--,c===0){f=u;break}}if(f!==-1){let u=s.slice(0,f+1);o=s.slice(f+1);let l=o.indexOf("(");if(l!==-1){let g=0,d=-1;for(let v=l;v<o.length;v++)if(o[v]==="(")g++;else if(o[v]===")"){if(g--,g===0){d=v;break}}if(d!==-1){if(o.slice(d+1).trimStart().startsWith("."))return"unknown"}}return`${i}${u}`}}let a=o.indexOf("(");if(a!==-1){let c=0,f=-1;for(let u=a;u<o.length;u++)if(o[u]==="(")c++;else if(o[u]===")"){if(c--,c===0){f=u;break}}if(f!==-1){if(o.slice(f+1).trimStart().startsWith("."))return"unknown"}}switch(i){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 i}}return"unknown"}function Qc(e){return"{ new (...args: any[]): any }"}function Js(e,t,r=0){if(e.startsWith("Promise.resolve(")){let n=e.indexOf(")",16);if(n!==-1){let i=e.slice(16,n).trim();if(i)return`Promise<${Te(i,t,!1,r+1)}>`}return"Promise<unknown>"}if(e.startsWith("Promise.reject("))return"Promise<never>";if(e.startsWith("Promise.all(")){let n=e.indexOf("[",12),i=e.lastIndexOf("]");if(n!==-1&&i>n){let s=e.slice(n+1,i).trim(),o=Wr(s),a=[];for(let c=0;c<o.length;c++){let f=o[c].trim();if(f.startsWith("Promise.resolve(")){let u=Js(f,t,r+1),l=u.indexOf("<"),g=u.lastIndexOf(">");a.push(l!==-1&&g>l?u.slice(l+1,g):"unknown")}else a.push(Te(f,t,!1,r+1))}return`Promise<[${a.join(", ")}]>`}return"Promise<unknown[]>"}return"Promise<unknown>"}function an(e,t,r=0){let n=e.slice(1,-1).trim();if(!n)return"never[]";if(r>=20)return"unknown[]";let i=Wr(n),s=!1;for(let g=0;g<i.length;g++){let d=i[g],v=d.length;while(v>0&&d.charCodeAt(v-1)<=32)v--;if(v>=8&&d.slice(v-8,v)==="as const"){s=!0;break}}if(s){let g=[];for(let d=0;d<i.length;d++){let v=i[d].trim();if(v.endsWith("as const")){let b=v.slice(0,-8).trim();if(b.startsWith("[")&&b.endsWith("]")){let C=b.slice(1,-1).trim(),T=Wr(C),k=[];for(let R=0;R<T.length;R++)k.push(Te(T[R].trim(),!0,!1,r+1));g.push(`readonly [${k.join(", ")}]`)}else g.push(Te(b,!0,!1,r+1))}else if(v.startsWith("[")&&v.endsWith("]"))g.push(an(v,!0,r+1));else g.push(Te(v,!0,!1,r+1))}return`readonly [
18
+ `){let o=n(),a=i(r+1);if(o===""||a===""){r++;continue}let c=Rc(t);if(!c&&("{;,(<:=[".includes(o)||"}),]>;|&".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+="; "}r++;while(r<e.length&&(e[r]===" "||e[r]==="\t"))r++;continue}t+=s,r++}return t}function Rc(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 r=e.lastIndexOf("/*",t);if(r===-1)return!1;for(let n=r-1;n>=0;n--){let i=e[n];if(/\s/.test(i))continue;return"{;,(<:".includes(i)}return!0}function Wr(e,t){let r=[e,t].filter((n)=>n!==null);for(let n of r){let i=ur(n,"defineProps");if(!i)continue;if(i.generic){let s=i.generic;if(s.startsWith("{"))return{type:s};if(/^[A-Za-z_$][\w$]*$/.test(s)){for(let o of r){let a=Fs(o,s);if(!a)continue;let c=Cc(o,s);if(c===null)continue;return{type:c,inlinedLocal:{name:s,declText:o.slice(a.start,a.end)}}}return{type:s}}return{type:s}}if(i.arg){let s=Lr(i.arg);if(s!==null)return{type:s}}}return null}function sn(e,t){let r=[e,t].filter((n)=>n!==null);for(let n of r){let i=ur(n,"defineEmits");if(!i)continue;if(i.generic)return Sc(i.generic)??i.generic;if(i.arg){let s=Ns(i.arg);if(s!==null)return s}}return null}function on(e,t){let r=[e,t].filter((n)=>n!==null);for(let n of r){let i=ur(n,"defineExpose");if(!i||!i.arg||!i.arg.startsWith("{"))continue;let s=fr(i.arg);if(s.length===0)return null;return`{ ${s.map((o)=>{if(o.value===""&&/^[A-Za-z_$][\w$]*$/.test(o.key))return`${cr(o.key)}: typeof ${o.key}`;let a=o.isMethod||/=>|^\s*function\b/.test(o.value);return`${cr(o.key)}: ${a?"(...args: any[]) => any":"unknown"}`}).join(", ")} }`}return null}function Ls(e){let t=yc(e),r="",n=null,i=null;if(t.script){let w=rn(t.script.content);if(w.passthrough)return t.scriptSetup?`${t.script.content}
19
+ ${t.scriptSetup.content}`:t.script.content;if(r=w.script,w.options){let T=Ir(w.options,"props");if(T)n=Lr(T);let k=Ir(w.options,"emits");if(k)i=Ns(k)}}let s=t.scriptSetup?.content??null,o=s!==null?tn(s):null,a=Wr(s,s!==null?null:r),c=a?.type??n??"{}",f=sn(s,null)??i,u=on(s,null),l=a?.inlinedLocal;if(l){if(r=Nr(r,l.name,l.declText),o!==null)o=Nr(o,l.name,l.declText)}let g=[c,u??"{}"];if(f)g.push("{}","{}","{}","{}","{}",f);let p=nn(`DefineComponent<${g.join(", ")}>`),v=[],b=Fr(r,p);if(b.trim()!=="")v.push(b);if(o&&o.trim()!==""){let w=Fr(o,p);if(w.trim()!=="")v.push(w)}return v.push("import type { DefineComponent } from 'vue'"),v.push(`type __DtsxComponentType = ${p}`),v.push("const __dtsx_component__: __DtsxComponentType = null as unknown as __DtsxComponentType"),v.push("export default __dtsx_component__"),v.join(`
20
+ `)}var Ds;var an=fe(()=>{Ds={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 Bs(e){return e.endsWith(".stx")}function Oc(e){let t=[],r=/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi,n;while((n=r.exec(e))!==null){let i=n[1]??"",s=/\blang\s*=\s*["']([^"']+)["']/i.exec(i)?.[1]?.toLowerCase()??(/\b(?:type\s*=\s*["'](?:text\/)?typescript["']|typescript)\b/i.test(i)?"ts":"js"),o=/\bserver\b/i.test(i)?"server":/\bclient\b/i.test(i)?"client":"universal";t.push({content:n[2]??"",kind:"script",attrs:i,context:o,lang:s,start:n.index})}return t}function kc(e){let t=[],r=/^[ \t]*@ts[ \t]*(?:\r?\n|$)/gm,n;while((n=r.exec(e))!==null){let i=r.lastIndex,s=/^[ \t]*@endts[ \t]*(?:\r?\n|$)/gm;s.lastIndex=i;let o=s.exec(e),a=o?.index??e.length;if(t.push({content:e.slice(i,a),kind:"ts",attrs:"",context:"universal",lang:"ts",start:n.index}),!o)break;r.lastIndex=s.lastIndex}return t}function Mc(e){return[...Oc(e),...kc(e)].sort((t,r)=>t.start-r.start)}function Dc(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 Ic(e){let t=/(?:\$?props)\s+as\s+/g,r;while((r=t.exec(e))!==null){let n=t.lastIndex;while(n<e.length&&/\s/.test(e[n]))n++;if(e[n]==="{"){let o=Le(e,n,"{","}");if(o!==-1)return e.slice(n,o+1).trim();continue}let i=/^[A-Za-z_$][\w$]*/.exec(e.slice(n))?.[0];if(!i)continue;let s=n+i.length;while(s<e.length&&/\s/.test(e[s]))s++;if(e[s]==="<"){let o=Le(e,s,"<",">");if(o!==-1)s=o+1}return e.slice(n,s).trim()}return null}function Fc(e){return/\b(?:const|let|var)\s+\$?props\s*:\s*([^=;\n]+)/.exec(e)?.[1]?.trim()??null}function Nc(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 Lc(e,t){if(!e||e==="unknown")return t;if(t==="unknown"||e===t)return e;return[...new Set([...e.split(" | "),...t.split(" | ")])].join(" | ")}function Wc(e){let t=Qi(e),r=new Map,n=/\$props(?:\.([A-Za-z_$][\w$]*)|\[\s*(['"])([^'"\n]+)\2\s*\])/g,i;while((i=n.exec(e))!==null){if(t.slice(i.index,i.index+6)!=="$props")continue;let s=i[1]??i[3],o=Nc(e.slice(n.lastIndex));r.set(s,Lc(r.get(s),o))}if(r.size===0)return null;return{type:`{ ${[...r].map(([s,o])=>`${/^[A-Za-z_$][\w$]*$/.test(s)?s:JSON.stringify(s)}?: ${o}`).join(", ")} }`}}function Bc(e){let t=Wr(e,null);if(t)return t;let r=Ic(e)??Fc(e);if(!r)return Wc(e);if(/^[A-Za-z_$][\w$]*$/.test(r)){let n=r.replace(/[$]/g,"\\$&");if(new RegExp(`\\bexport\\s+(?:declare\\s+)?(?:interface|type)\\s+${n}\\b`).test(e))return{type:r}}return Wr(`${e}
21
+ defineProps<${r}>()`,null)}function Gc(e){return tn(e)}function Ws(e){let t=Qi(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 jc(e){let t=[],r=0,n=0,i=0;while(i<e.length){let o=e[i],a=Xi(e,i);if(a>i){i=a;continue}if(o==="{"||o==="["||o==="(")n++;else if(o==="}"||o==="]"||o===")")n=Math.max(0,n-1);if((o===";"||o===`
22
+ `)&&n===0){let c=i+1;if(!Ws(e.slice(r,c)))t.push([r,c]);r=c}i++}if(r<e.length&&!Ws(e.slice(r)))t.push([r,e.length]);let s=e;for(let o=t.length-1;o>=0;o--)s=s.slice(0,t[o][0])+s.slice(t[o][1]);return s}function Gs(e){let t=Mc(e).filter(Dc).map((b)=>b.content).join(`
23
+ `),r=null,n=rn(t);if(n.passthrough)return t;if(t=n.script,n.options){let b=Ir(n.options,"props");if(b)r=Lr(b)}let i=t,s=Gc(t),o=Bc(i),a=o?.type??r??"{}",c=sn(i,null),f=on(i,null),u=ur(i,"defineSlots")?.generic??null,l=o?.inlinedLocal;if(l)s=Nr(s,l.name,l.declText);let g=`DefineComponent<${a}>`,p=[];if(c)p.push(`readonly __stxEmits?: ${c}`);if(u)p.push(`readonly __stxSlots?: ${u}`);if(f)p.push(`readonly __stxExposed?: ${f}`);if(p.length>0)g+=` & { ${p.join(", ")} }`;g=nn(g),s=jc(Fr(s,g));let v=["import type { DefineComponent } from '@stacksjs/stx'",`type __DtsxStxComponentType = ${g}`,"const __dtsx_component__: __DtsxStxComponentType = null as unknown as __DtsxStxComponentType","export default __dtsx_component__"];if(s.trim()!=="")v.push(s);return v.join(`
24
+ `)}var js=fe(()=>{an()});function _c(e){if(e.indexOf("/*")===-1)return e.trim();let t=[],r=0,n=0,i=e.length;while(n<i)if(e.charCodeAt(n)===47&&n+1<i&&e.charCodeAt(n+1)===42){if(n>r)t.push(e.substring(r,n));n+=2;while(n<i-1){if(e.charCodeAt(n)===42&&e.charCodeAt(n+1)===47){n+=2;break}n++}r=n}else n++;if(r<i)t.push(e.substring(r));return t.join("").trim()}function hn(){_r=!0,Ve=null}function dn(){_r=!1;let e=Ve;return Ve=null,e}function mn(e){let t=e.length;if(t===0)return!1;let r=0;if(e.charCodeAt(r)===45)r++;if(r>=t)return!1;let n=r;while(r<t&&e.charCodeAt(r)>=48&&e.charCodeAt(r)<=57)r++;if(r===n)return!1;if(r<t&&e.charCodeAt(r)===46){r++;let i=r;while(r<t&&e.charCodeAt(r)>=48&&e.charCodeAt(r)<=57)r++;if(r===i)return!1}return r===t}function Vc(e){for(let t=0,r=e.length-1;t<r;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return!0}function ln(e,t){let r=0,n=0;while((n=e.indexOf(t,n))!==-1)r++,n+=t.length;return r}function _s(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 Br(e){let t=e.trim();if(t.length<3||t.charCodeAt(0)!==60)return!1;if(t.startsWith("<>"))return t.endsWith("</>");let r=t.charCodeAt(1);if(!(r>=65&&r<=90||r>=97&&r<=122||r===36||r===95))return!1;let n=2;while(n<t.length&&_s(t.charCodeAt(n)))n++;let i=t.slice(1,n),s=t.charCodeAt(n);if(s>32&&s!==62&&s!==47)return!1;if(t.endsWith("/>"))return!0;let o=t.lastIndexOf("</");if(o===-1)return!1;let a=o+2;while(a<t.length&&_s(t.charCodeAt(a)))a++;return t.slice(o+2,a)===i&&t.charCodeAt(a)===62&&a===t.length-1}function hr(e){let t=e.length,r=!1;for(let o=1;o<t;o++)if(e.charCodeAt(o)<=32&&e.charCodeAt(o-1)<=32){r=!0;break}if(!r)for(let o=0;o<t;o++){let a=e.charCodeAt(o);if(a===10||a===13||a===9){r=!0;break}}if(!r)return e;let n=[],i=-1,s=!1;for(let o=0;o<t;o++)if(e.charCodeAt(o)<=32){if(!s){if(i>=0)n.push(e.substring(i,o));n.push(" "),s=!0,i=-1}}else{if(s||i<0)i=o;s=!1}if(i>=0)n.push(e.substring(i));return n.join("")}function Te(e,t=!1,r=!1,n=0){if(!e||typeof e!=="string")return"unknown";if(n>=20)return"unknown";let i=e.trim();if(Br(i))return"JSX.Element";if(i.startsWith("BigInt("))return"bigint";if(i.startsWith("Symbol.for("))return"symbol";if(i.includes(".raw`")||i.includes("String.raw`"))return"string";if(i.startsWith("`")&&i.endsWith("`")){if(!t||i.includes("${")||i.includes(`
25
+ `)||i.includes("\r"))return"string";return i}if(i.charCodeAt(0)===39||i.charCodeAt(0)===34){let o=Uc(i);if(o!==null){if(o==="string"||!t)return"string";return o}}if(mn(i)){if(!t)return"number";return i}if(i==="true"||i==="false"){if(!t)return"boolean";return i}if(i==="null")return"null";if(i==="undefined")return"undefined";if(i.startsWith("[")&&i.endsWith("]"))return cn(i,t,n+1);if(i.startsWith("{")&&i.endsWith("}"))return nf(i,t,n+1);if(i.startsWith("class ")||i.startsWith("class{"))return tf(i);if(i.startsWith("new "))return ef(i);if(i.endsWith("as const")){let o=i.slice(0,-8).trim();if(o.startsWith("[")&&o.endsWith("]")){let a=o.slice(1,-1).trim();if(!a)return"readonly []";let c=Gr(a),f=[];for(let u=0;u<c.length;u++)f.push(Te(c[u].trim(),!0,!1,n+1));return`readonly [${f.join(", ")}]`}return Te(o,!0,r,n+1)}if(jr(i)!==-1||i.startsWith("function")||i.startsWith("async"))return eo(i,r,n,t);if(i.startsWith("`")&&i.endsWith("`"))return Qc(i,t);if(i.startsWith("Promise."))return Ys(i,t,n);if(i.startsWith("await "))return"unknown";if(i.charCodeAt(i.length-1)===110&&i.length>1&&Vc(i)){if(t)return i;return"bigint"}if(i.startsWith("Symbol(")||i==="Symbol.for")return"symbol";let s=Zs(i);if(s!==null)return s;if(qc(i))return"boolean";if(Jc(i))return"number";return"unknown"}function Vs(e){let t=e.charCodeAt(0);if(t!==39&&t!==34)return!1;return Ot(e,0,t)===e.length}function Uc(e){if(Vs(e))return e;let t=Kc(e);if(t.length<2)return null;let r=!1,n=!0,i="";for(let s of t){let o=s.trim();if(Vs(o))r=!0,i+=zc(o);else n=!1}if(n)return Hc(i);if(r)return"string";return null}function Kc(e){let t=[],r=0,n=0,i=0;while(i<e.length){let s=e.charCodeAt(i);if(s===39||s===34||s===96){i=Ot(e,i,s);continue}if(s===40||s===91||s===123)r++;else if(s===41||s===93||s===125)r--;else if(s===43&&r===0)t.push(e.slice(n,i)),n=i+1;i++}return t.push(e.slice(n)),t}function zc(e){return e.slice(1,-1).replace(/\\(.)/g,(t,r)=>{if(r==="n")return`
26
+ `;if(r==="t")return"\t";if(r==="r")return"\r";if(r==="0")return"\x00";return r})}function Hc(e){return`'${e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function Jc(e){if(e==="")return!1;let t=!1,r=!1;for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);if(i>=48&&i<=57){t=!0;continue}if(i===43||i===45||i===42||i===47||i===37){r=!0;continue}if(i===46||i===40||i===41||i<=32)continue;return!1}return t&&r}function qc(e){let t=0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n===34||n===39||n===96){r=Ot(e,r,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("===",r)||e.startsWith("!==",r)||e.startsWith("==",r)||e.startsWith("!=",r)||e.startsWith(">=",r)||e.startsWith("<=",r))return!0;if((n===62||n===60)&&e.charCodeAt(r-1)!==61&&e.charCodeAt(r+1)!==61)return!0}return!1}function Yc(e,t=!1,r=0){return Te(e,t,!0,r)}function dr(e,t=!1,r=""){let n=Js(r),i=[],s=!1,o=0;while(o<e.length){let c=e.charCodeAt(o);if(c===34||c===39||c===96){o=Ot(e,o,c);continue}if(c===47&&e.charCodeAt(o+1)===47){o+=2;while(o<e.length&&e.charCodeAt(o)!==10&&e.charCodeAt(o)!==13)o++;continue}if(c===47&&e.charCodeAt(o+1)===42){let f=e.indexOf("*/",o+2);o=f===-1?e.length:f+2;continue}if(e.startsWith("function",o)&&Us(e,o,8)||e.startsWith("class",o)&&Us(e,o,5)){let f=Xc(e,o);if(f!==-1){o=Ks(e,f);continue}}if(c===61&&e.charCodeAt(o+1)===62){let f=o+2;while(f<e.length&&e.charCodeAt(f)<=32)f++;if(e.charCodeAt(f)===123){o=Ks(e,f);continue}}if(e.startsWith("return",o)&&(o===0||!ht(e.charCodeAt(o-1)))&&!ht(e.charCodeAt(o+6))){o+=6;let f=!1;while(o<e.length&&e.charCodeAt(o)<=32){let w=e.charCodeAt(o);if(w===10||w===13)f=!0;o++}if(f||o>=e.length||e.charCodeAt(o)===59||e.charCodeAt(o)===125){s=!0;continue}let u=o,l=0,g=0,p=0;while(o<e.length){let w=e.charCodeAt(o);if(w===34||w===39||w===96){o=Ot(e,o,w);continue}if(w===47&&e.charCodeAt(o+1)===47)break;if(w===47&&e.charCodeAt(o+1)===42){let T=e.indexOf("*/",o+2);o=T===-1?e.length:T+2;continue}if(w===40)l++;else if(w===41)l--;else if(w===91)g++;else if(w===93)g--;else if(w===123)p++;else if(w===125){if(p===0&&l===0&&g===0)break;p--}else if(w===59&&l===0&&g===0&&p===0)break;else if((w===10||w===13)&&l===0&&g===0&&p===0){let T=o+1;while(T<e.length&&e.charCodeAt(T)<=32)T++;if(e.startsWith("return",T)&&!ht(e.charCodeAt(T+6)))break}o++}let v=e.slice(u,o).trim(),b=Rt(v,n);if(!i.includes(b))i.push(b);continue}o++}if(s&&!i.includes("undefined"))i.push("undefined");let a=i.includes("unknown")?"unknown":i.length===0?"void":i.join(" | ");return t&&!a.startsWith("Promise<")?`Promise<${a}>`:a}function Js(e){let t=new Map,r=e.startsWith("(")&&e.endsWith(")")?e.slice(1,-1):e,n=0,i=0,s=0;for(let o=0;o<=r.length;o++){let a=r.charCodeAt(o);if(a===40||a===91||a===123)i++;else if(a===41||a===93||a===125)i--;else if(a===60)s++;else if(a===62&&r.charCodeAt(o-1)!==61&&s>0)s--;if(o!==r.length&&(a!==44||i!==0||s!==0))continue;let c=r.slice(n,o).trim(),f=c.indexOf(":");if(f!==-1){let u=c.slice(0,f).trim().replace(/^\.\.\./,"").replace(/\?$/,""),l=c.slice(f+1).trim(),g=l.indexOf("=");if(g!==-1)l=l.slice(0,g).trim();if(mr(u)&&l)t.set(u,l)}n=o+1}return t}function Rt(e,t){let r=e.trim();while(qs(r))r=r.slice(1,-1).trim();if(Br(r))return"JSX.Element";if(r.startsWith("await ")){let s=Rt(r.slice(6),t);return s.startsWith("Promise<")&&s.endsWith(">")?s.slice(8,-1):s}if(t.has(r))return t.get(r);if(r.startsWith("!"))return"boolean";if(r.startsWith("fetch("))return"Promise<Response>";let n=Zc(r);if(n){let s=Rt(n.whenTrue,t),o=Rt(n.whenFalse,t);return s===o?s:`${s} | ${o}`}if(["===","!==","==","!=",">=","<="].some((s)=>r.includes(s))||r.includes(" > ")||r.includes(" < "))return"boolean";let i=0;for(let s=r.length-1;s>=0;s--){let o=r.charCodeAt(s);if(o===41||o===93||o===125)i++;else if(o===40||o===91||o===123)i--;else if(i===0&&(o===43||o===45||o===42||o===47||o===37)){let a=Rt(r.slice(0,s),t),c=Rt(r.slice(s+1),t);if(o===43&&(a==="string"||c==="string"))return"string";if(a==="number"&&c==="number")return"number";break}}return Te(r,!1).replace(/\btypeof\s+[$A-Z_a-z][$\w]*/g,(s)=>{let o=s.slice(7);return t.get(o)??"unknown"})}function qs(e){if(!e.startsWith("(")||!e.endsWith(")"))return!1;let t=0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n===40)t++;else if(n===41&&--t===0)return r===e.length-1}return!1}function Zc(e){let t=0,r=-1;for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);if(i===40||i===91||i===123)t++;else if(i===41||i===93||i===125)t--;else if(i===63&&t===0&&e.charCodeAt(n+1)!==63)r=n;else if(i===58&&t===0&&r!==-1)return{whenTrue:e.slice(r+1,n),whenFalse:e.slice(n+1)}}return null}function Us(e,t,r){return(t===0||!ht(e.charCodeAt(t-1)))&&!ht(e.charCodeAt(t+r))}function Xc(e,t){for(let r=t;r<e.length;r++){let n=e.charCodeAt(r);if(n===34||n===39||n===96){r=Ot(e,r,n)-1;continue}if(n===123)return r;if(n===59)return-1}return-1}function Ks(e,t){let r=1,n=t+1;while(n<e.length&&r>0){let i=e.charCodeAt(n);if(i===34||i===39||i===96){n=Ot(e,n,i);continue}if(i===47&&e.charCodeAt(n+1)===47){n+=2;while(n<e.length&&e.charCodeAt(n)!==10&&e.charCodeAt(n)!==13)n++;continue}if(i===47&&e.charCodeAt(n+1)===42){let s=e.indexOf("*/",n+2);n=s===-1?e.length:s+2;continue}if(i===123)r++;else if(i===125)r--;n++}return n}function Ot(e,t,r){let n=t+1;while(n<e.length){let i=e.charCodeAt(n);if(i===92){n+=2;continue}if(n++,i===r)break}return n}function Qc(e,t){if(e.includes(".raw`")||e.includes("String.raw`"))return"string";if(!t||e.includes("${")||e.includes(`
27
+ `)||e.includes("\r"))return"string";return e}function ef(e){let t=4;while(t<e.length&&e.charCodeAt(t)<=32)t++;let r=t,n=e.charCodeAt(t);if(n<65||n>90)return"unknown";while(t<e.length&&(ht(e.charCodeAt(t))||e.charCodeAt(t)===46))t++;if(t===r)return"unknown";let i=e.slice(r,t);{let s=e.slice(t),o=s;if(s.startsWith("<")){let c=0,f=-1;for(let u=0;u<s.length;u++)if(s[u]==="<")c++;else if(s[u]===">"){if(c--,c===0){f=u;break}}if(f!==-1){let u=s.slice(0,f+1);o=s.slice(f+1);let l=o.indexOf("(");if(l!==-1){let g=0,p=-1;for(let v=l;v<o.length;v++)if(o[v]==="(")g++;else if(o[v]===")"){if(g--,g===0){p=v;break}}if(p!==-1){if(o.slice(p+1).trimStart().startsWith("."))return"unknown"}}return`${i}${u}`}}let a=o.indexOf("(");if(a!==-1){let c=0,f=-1;for(let u=a;u<o.length;u++)if(o[u]==="(")c++;else if(o[u]===")"){if(c--,c===0){f=u;break}}if(f!==-1){if(o.slice(f+1).trimStart().startsWith("."))return"unknown"}}switch(i){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 i}}return"unknown"}function tf(e){return"{ new (...args: any[]): any }"}function Ys(e,t,r=0){if(e.startsWith("Promise.resolve(")){let n=e.indexOf(")",16);if(n!==-1){let i=e.slice(16,n).trim();if(i)return`Promise<${Te(i,t,!1,r+1)}>`}return"Promise<unknown>"}if(e.startsWith("Promise.reject("))return"Promise<never>";if(e.startsWith("Promise.all(")){let n=e.indexOf("[",12),i=e.lastIndexOf("]");if(n!==-1&&i>n){let s=e.slice(n+1,i).trim(),o=Gr(s),a=[];for(let c=0;c<o.length;c++){let f=o[c].trim();if(f.startsWith("Promise.resolve(")){let u=Ys(f,t,r+1),l=u.indexOf("<"),g=u.lastIndexOf(">");a.push(l!==-1&&g>l?u.slice(l+1,g):"unknown")}else a.push(Te(f,t,!1,r+1))}return`Promise<[${a.join(", ")}]>`}return"Promise<unknown[]>"}return"Promise<unknown>"}function cn(e,t,r=0){let n=e.slice(1,-1).trim();if(!n)return"never[]";if(r>=20)return"unknown[]";let i=Gr(n),s=!1;for(let g=0;g<i.length;g++){let p=i[g],v=p.length;while(v>0&&p.charCodeAt(v-1)<=32)v--;if(v>=8&&p.slice(v-8,v)==="as const"){s=!0;break}}if(s){let g=[];for(let p=0;p<i.length;p++){let v=i[p].trim();if(v.endsWith("as const")){let b=v.slice(0,-8).trim();if(b.startsWith("[")&&b.endsWith("]")){let w=b.slice(1,-1).trim(),T=Gr(w),k=[];for(let R=0;R<T.length;R++)k.push(Te(T[R].trim(),!0,!1,r+1));g.push(`readonly [${k.join(", ")}]`)}else g.push(Te(b,!0,!1,r+1))}else if(v.startsWith("[")&&v.endsWith("]"))g.push(cn(v,!0,r+1));else g.push(Te(v,!0,!1,r+1))}return`readonly [
28
28
  ${g.join(` |
29
29
  `)}
30
- ]`}let o=Gr&&!t,a=[],c=[];for(let g of i){let d=g.trim(),v=_e;if(_e=null,d.startsWith("...")){let b=d.slice(3).trim(),C=Te(b,!1,!1,r+1);if(C.endsWith("[]"))a.push(C.slice(0,-2));else if(C.startsWith("readonly [")&&C.endsWith("]"))a.push(C.slice(10,-1));else if(mr(b))a.push(`(typeof ${b})[number]`);else a.push("unknown")}else if(d.startsWith("[")&&d.endsWith("]"))a.push(an(d,t,r+1));else a.push(Jc(d,t,r+1));if(o)c.push(_e);_e=v}if(o)if(cn(e))_e=ur(e);else{let g=[];for(let d=0;d<i.length;d++){let v=i[d].trim();if(v.endsWith("as const"))continue;if(ln(v)||v==="null"||v==="undefined")g.push(v);else if(v.startsWith("[")&&cn(v))g.push(ur(v));else if(v.startsWith("{")){if(c[d])g.push(c[d])}else{let b=Te(v,!1,!1,0);if(b!=="unknown")g.push(b)}}if(g.length>0)_e=`[${g.join(", ")}]`}if(t)return`readonly [${a.join(", ")}]`;let f=new Set,u=[],l=!0;for(let g of a){if(!f.has(g))f.add(g),u.push(g);if(l){if(!(hn(g)||g==="true"||g==="false"||g.charCodeAt(0)===34&&g.charCodeAt(g.length-1)===34||g.charCodeAt(0)===39&&g.charCodeAt(g.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 Wr(e){let t=[],r=0,n=0,i=!1,s=0;for(let a=0;a<e.length;a++){let c=e.charCodeAt(a);if(!i&&(c===34||c===39||c===96))i=!0,s=c;else if(i&&c===s&&(a===0||e.charCodeAt(a-1)!==92))i=!1;if(!i){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(r,a).trim();if(f)t.push(f);r=a+1;continue}}}let o=e.substring(r).trim();if(o)t.push(o);return t}function ln(e){if(hn(e))return!0;if(e==="true"||e==="false")return!0;if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return!0;return!1}function ef(e){return e==="number"||e==="string"||e==="boolean"}function cn(e){let t=!1,r=0,n=e.length;for(let i=0;i<n;i++){let s=e.charCodeAt(i);if(t){if(s===92){i++;continue}if(s===r)t=!1;continue}if(s===34||s===39||s===96){t=!0,r=s;continue}if(s===61&&i+1<n&&e.charCodeAt(i+1)===62)return!1;if(s>=97&&s<=122){let o=i;while(i<n&&(e.charCodeAt(i)>=97&&e.charCodeAt(i)<=122||e.charCodeAt(i)>=65&&e.charCodeAt(i)<=90||e.charCodeAt(i)>=48&&e.charCodeAt(i)<=57||e.charCodeAt(i)===95||e.charCodeAt(i)===36))i++;let a=e.slice(o,i);if(a==="new"||a==="async"||a==="await"||a==="function"||a==="yield"||a==="console"||a==="process")return!1;let c=i;while(c<n&&e.charCodeAt(c)<=32)c++;if(c<n&&e.charCodeAt(c)===40)return!1;i--}}return!0}function tf(e,t,r=0){let n=e.slice(1,-1).trim();if(!n)return"{}";if(r>=20)return"Record<string, unknown>";let i=lf(n),s=[],o=[],a=Gr&&!t,c=[];for(let[l,g]of i){let{comments:d,key:v}=af(l),b=d?`${d}
31
- `:"",C=v,T=!1;if(v==="..."){let F=g.trim(),U=mr(F)?`typeof ${F}`:Te(F,t,!1,r+1);if(U!=="unknown")o.push(U);if(a&&(mr(F)||F.startsWith("{")))c.push(`...${ur(F)}`);continue}let k=_e;_e=null;let R,I=g.trim();if(I===v&&dr(I))R=`typeof ${I}`;else if(uf(I)){T=!0;let F=hf(v);if(F){C=F.name;let U="";if(I.startsWith("async "))U="async ";if(I.charCodeAt(U.length)===42)U+="*";R=Us(F.name,U+F.typeParams+I.slice(U.length))}else R=Us(v,I)}else if(R=Te(g,t,!1,r+1),R.includes("=>")||R.includes("function")||R.includes("async"))R=nf(R);let _=_e;_e=k;let L=g.trim(),P=cf(v);if(P){let F=ff(P.kind,P.name,R);if(F){s.push(`${b}${F}`);continue}}if(!t&&ef(R)&&ln(L))s.push(`${b}/** @defaultValue ${L} */
32
- ${C}: ${R}`);else s.push(`${b}${C}: ${R}`);if(a){let F=Gc(C);if(L.endsWith("as const"));else if(ln(L))c.push(`${F}: ${L}`);else if(L.startsWith("[")&&cn(L))c.push(`${F}: ${ur(L)}`);else if(L.startsWith("{")){if(_)c.push(`${F}: ${_}`)}else if(T)c.push(`${F}: ${ur(R)}`);else if(!L.startsWith("[")&&(L.includes("=>")||L.startsWith("function")||L.startsWith("async"))){let U=Xs(L,!1,0,!0);c.push(`${F}: ${U}`)}}}if(a&&c.length>0){let l=r>0?(r-1)/2:0,g=`{ ${c.join(", ")} }`;if(g.length<=80)_e=g;else{let d=" ".repeat((l+1)*2),v=" ".repeat(l*2);_e=`{
33
- ${d}${c.join(`,
34
- ${d}`)}
30
+ ]`}let o=_r&&!t,a=[],c=[];for(let g of i){let p=g.trim(),v=Ve;if(Ve=null,p.startsWith("...")){let b=p.slice(3).trim(),w=Te(b,!1,!1,r+1);if(w.endsWith("[]"))a.push(w.slice(0,-2));else if(w.startsWith("readonly [")&&w.endsWith("]"))a.push(w.slice(10,-1));else if(pr(b))a.push(`(typeof ${b})[number]`);else a.push("unknown")}else if(p.startsWith("[")&&p.endsWith("]"))a.push(cn(p,t,r+1));else a.push(Yc(p,t,r+1));if(o)c.push(Ve);Ve=v}if(o)if(un(e))Ve=hr(e);else{let g=[];for(let p=0;p<i.length;p++){let v=i[p].trim();if(v.endsWith("as const"))continue;if(fn(v)||v==="null"||v==="undefined")g.push(v);else if(v.startsWith("[")&&un(v))g.push(hr(v));else if(v.startsWith("{")){if(c[p])g.push(c[p])}else{let b=Te(v,!1,!1,0);if(b!=="unknown")g.push(b)}}if(g.length>0)Ve=`[${g.join(", ")}]`}if(t)return`readonly [${a.join(", ")}]`;let f=new Set,u=[],l=!0;for(let g of a){if(!f.has(g))f.add(g),u.push(g);if(l){if(!(mn(g)||g==="true"||g==="false"||g.charCodeAt(0)===34&&g.charCodeAt(g.length-1)===34||g.charCodeAt(0)===39&&g.charCodeAt(g.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 Gr(e){let t=[],r=0,n=0,i=!1,s=0;for(let a=0;a<e.length;a++){let c=e.charCodeAt(a);if(!i&&(c===34||c===39||c===96))i=!0,s=c;else if(i&&c===s&&(a===0||e.charCodeAt(a-1)!==92))i=!1;if(!i){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(r,a).trim();if(f)t.push(f);r=a+1;continue}}}let o=e.substring(r).trim();if(o)t.push(o);return t}function fn(e){if(mn(e))return!0;if(e==="true"||e==="false")return!0;if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return!0;return!1}function rf(e){return e==="number"||e==="string"||e==="boolean"}function un(e){let t=!1,r=0,n=e.length;for(let i=0;i<n;i++){let s=e.charCodeAt(i);if(t){if(s===92){i++;continue}if(s===r)t=!1;continue}if(s===34||s===39||s===96){t=!0,r=s;continue}if(s===61&&i+1<n&&e.charCodeAt(i+1)===62)return!1;if(s>=97&&s<=122){let o=i;while(i<n&&(e.charCodeAt(i)>=97&&e.charCodeAt(i)<=122||e.charCodeAt(i)>=65&&e.charCodeAt(i)<=90||e.charCodeAt(i)>=48&&e.charCodeAt(i)<=57||e.charCodeAt(i)===95||e.charCodeAt(i)===36))i++;let a=e.slice(o,i);if(a==="new"||a==="async"||a==="await"||a==="function"||a==="yield"||a==="console"||a==="process")return!1;let c=i;while(c<n&&e.charCodeAt(c)<=32)c++;if(c<n&&e.charCodeAt(c)===40)return!1;i--}}return!0}function nf(e,t,r=0){let n=e.slice(1,-1).trim();if(!n)return"{}";if(r>=20)return"Record<string, unknown>";let i=ff(n),s=[],o=[],a=_r&&!t,c=[];for(let[l,g]of i){let{comments:p,key:v}=cf(l),b=p?`${p}
31
+ `:"",w=v,T=!1;if(v==="..."){let F=g.trim(),U=pr(F)?`typeof ${F}`:Te(F,t,!1,r+1);if(U!=="unknown")o.push(U);if(a&&(pr(F)||F.startsWith("{")))c.push(`...${hr(F)}`);continue}let k=Ve;Ve=null;let R,I=g.trim();if(I===v&&mr(I))R=`typeof ${I}`;else if(df(I)){T=!0;let F=mf(v);if(F){w=F.name;let U="";if(I.startsWith("async "))U="async ";if(I.charCodeAt(U.length)===42)U+="*";R=zs(F.name,U+F.typeParams+I.slice(U.length))}else R=zs(v,I)}else if(R=Te(g,t,!1,r+1),R.includes("=>")||R.includes("function")||R.includes("async"))R=of(R);let _=Ve;Ve=k;let W=g.trim(),P=uf(v);if(P){let F=hf(P.kind,P.name,R);if(F){s.push(`${b}${F}`);continue}}if(!t&&rf(R)&&fn(W))s.push(`${b}/** @defaultValue ${W} */
32
+ ${w}: ${R}`);else s.push(`${b}${w}: ${R}`);if(a){let F=_c(w);if(W.endsWith("as const"));else if(fn(W))c.push(`${F}: ${W}`);else if(W.startsWith("[")&&un(W))c.push(`${F}: ${hr(W)}`);else if(W.startsWith("{")){if(_)c.push(`${F}: ${_}`)}else if(T)c.push(`${F}: ${hr(R)}`);else if(!W.startsWith("[")&&(W.includes("=>")||W.startsWith("function")||W.startsWith("async"))){let U=eo(W,!1,0,!0);c.push(`${F}: ${U}`)}}}if(a&&c.length>0){let l=r>0?(r-1)/2:0,g=`{ ${c.join(", ")} }`;if(g.length<=80)Ve=g;else{let p=" ".repeat((l+1)*2),v=" ".repeat(l*2);Ve=`{
33
+ ${p}${c.join(`,
34
+ ${p}`)}
35
35
  ${v}}`}}let f=s.length>0?`{
36
36
  ${s.join(`;
37
37
  `)}
38
- }`:"{}";if(o.length===0)return f;let u=o[0];for(let l=1;l<o.length;l++)u=`Omit<${u}, keyof ${o[l]}> & ${o[l]}`;return s.length>0?`Omit<${u}, keyof ${f}> & ${f}`:u}function dr(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 r=1;r<e.length;r++)if(!ut(e.charCodeAt(r)))return!1;return!0}function mr(e){let t=e.split(".");return t.length>0&&t.every(dr)}function rf(e){let t=!1,r="";for(let n=0;n<e.length;n++){let i=e[n];if(t){if(i==="\\")n++;else if(i===r)t=!1;continue}if(i==='"'||i==="'"||i==="`"){t=!0,r=i;continue}if(i==="(")return n;if(i==="<"){let s=Xe(e,n,"<",">");if(s!==-1)n=s}}return-1}function qs(e){if(e.length<3||!e.endsWith(")"))return null;let t=rf(e);if(t===-1||Xe(e,t,"(",")")!==e.length-1)return null;let r=e.slice(0,t).trim(),n=!1;if(r.endsWith("?."))n=!0,r=r.slice(0,-2).trim();let i=r,s=!1,o=r.indexOf("<");if(o!==-1){if(Xe(r,o,"<",">")!==r.length-1)return null;i=r.slice(0,o).trim(),s=!0}if(!mr(i))return null;let a=e.slice(t+1,-1).trim(),c=Br(a)!==-1||a.startsWith("function")||a.startsWith("async function"),f=mr(a),u=!c&&a.endsWith(")")&&qs(a)!==null;if(!s&&!n&&!c&&!f&&!u)return null;let l=`ReturnType<typeof ${r}>`;return n?`${l} | undefined`:l}function nf(e){let t=e.split(`
39
- `).map((f)=>Ys(f)).join(`
40
- `),r=t.indexOf("async");if(r!==-1){let f=r>0?t.charCodeAt(r-1):32,u=r+5<t.length?t.charCodeAt(r+5):32;if(!ut(f)&&!ut(u))t=(t.slice(0,r)+t.slice(r+5)).trim()}let n=t.indexOf("(");if(n!==-1){let f=Xe(t,n,"(",")");if(f!==-1){let u=t.slice(n,f+1),l=jt(u);t=t.slice(0,n)+l+t.slice(f+1)}}let i=t.length,s="",o=[],a=!1,c=!1;for(let f=0;f<i;f++){let u=t.charCodeAt(f);if(u===123||u===40)o.push(u);else if(u===125||u===41)o.pop();if(u<=32){if(a=!0,u===10||u===13)c=!0;continue}if(a&&s.length>0){let l=(o.length>0?o[o.length-1]:0)===123;if(c&&l){let g=s.charCodeAt(s.length-1),d=g===59||g===44||g===123||u===125,v=s.length>=2&&s.charCodeAt(s.length-1)===47&&s.charCodeAt(s.length-2)===42;if(!d&&!v)s+="; ";else s+=" "}else s+=" "}a=!1,c=!1,s+=t[f]}return s.trim()}function ut(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===95||e===36}function jt(e){let t=e.trim(),r,n=!1;if(t.startsWith("(")&&t.endsWith(")"))r=t.slice(1,-1),n=!0;else r=t;let i=r.trim();if(!i)return n?"()":"";let s=!1;{let v=0;for(let b=0;b<i.length;b++){let C=i.charCodeAt(b);if(C===40||C===60||C===91||C===123)v++;else if(C===41||C===62||C===93||C===125)v--;else if(v===0&&C===61){let T=b>0?i.charCodeAt(b-1):0,k=b+1<i.length?i.charCodeAt(b+1):0;if(T!==61&&T!==33&&T!==60&&T!==62&&k!==61&&k!==62){s=!0;break}}}}if(!s)return t;let o=[],a=[],c=0,f=0,u=!1,l=0;for(let v=0;v<=i.length;v++){if(v===i.length){o.push(i.slice(c));break}let b=i.charCodeAt(v);if(u){if(b===92){v++;continue}if(b===l)u=!1;continue}if(b===47&&v+1<i.length){let C=i.charCodeAt(v+1);if(C===42){v+=2;while(v+1<i.length&&!(i.charCodeAt(v)===42&&i.charCodeAt(v+1)===47))v++;v++;continue}if(C===47){while(v<i.length&&i.charCodeAt(v)!==10)v++;continue}}if(b===39||b===34||b===96){u=!0,l=b;continue}if(b===40||b===60||b===91||b===123)f++;else if(b===41||b===62||b===93||b===125)f--;else if(b===44&&f===0){o.push(i.slice(c,v));let C=",",T=v+1;while(T<i.length&&i.charCodeAt(T)<=32)C+=i[T],T++;a.push(C),c=T}}let g=[];for(let v of o){let b=v.trim();if(!b){g.push(v);continue}if(b.startsWith("//"))continue;let C=Ys(b),T=v.slice(0,v.length-v.trimStart().length);g.push(T+sf(C))}let d=g[0]||"";for(let v=1;v<g.length;v++)d+=(a[v-1]||", ")+g[v];return n?`(${d})`:d}function Ys(e){let t=!1,r=0;for(let n=0;n<e.length-1;n++){let i=e.charCodeAt(n);if(t){if(i===92){n++;continue}if(i===r)t=!1;continue}if(i===39||i===34||i===96){t=!0,r=i;continue}if(i===47&&e.charCodeAt(n+1)===47)return e.slice(0,n).trimEnd()}return e}function sf(e){if(e.startsWith("..."))return e;let t=-1,r=-1,n=0,i=!1,s=0;for(let a=0;a<e.length;a++){let c=e.charCodeAt(a);if(i){if(c===92){a++;continue}if(c===s)i=!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){i=!0,s=c;continue}if(c===40||c===60||c===91||c===123)n++;else if(c===41||c===62||c===93||c===125)n--;else if(n===0){if(c===58&&t===-1)t=a;else if(c===61&&r===-1&&(a===0||e.charCodeAt(a-1)!==61)&&(a+1>=e.length||e.charCodeAt(a+1)!==61&&e.charCodeAt(a+1)!==62))r=a}}let o=r!==-1;if(t!==-1&&(r===-1||t<r)){let a=e.slice(0,t).trim(),c=r!==-1?e.slice(t+1,r).trim():e.slice(t+1).trim(),f=o&&!a.endsWith("?")?"?":"";return`${a}${f}: ${c}`}else if(r!==-1){let a=e.slice(0,r).trim(),c=!a.endsWith("?")?"?":"",f=e.slice(r+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 of(e){let t=0,r=e.length;while(t<r){while(t<r&&(e.charCodeAt(t)===32||e.charCodeAt(t)===9||e.charCodeAt(t)===10||e.charCodeAt(t)===13))t++;if(t+1<r&&e.charCodeAt(t)===47&&e.charCodeAt(t+1)===42){t+=2;while(t+1<r&&!(e.charCodeAt(t)===42&&e.charCodeAt(t+1)===47))t++;t+=2;continue}break}return t}function af(e){let t=[],r=0,n=e.length;while(r<n){while(r<n&&e.charCodeAt(r)<=32)r++;if(r+1>=n||e.charCodeAt(r)!==47||e.charCodeAt(r+1)!==42)break;let i=r;r+=2;while(r+1<n&&!(e.charCodeAt(r)===42&&e.charCodeAt(r+1)===47))r++;r=Math.min(r+2,n),t.push(e.slice(i,r).trim())}return{comments:t.join(`
41
- `),key:e.slice(r).trim()}}function lf(e){let t=[],r="",n="",i=0,s=!1,o="",a=!0,c=!1,f=0,u=!1,l=!1,g=0,d=!1,v=!1;for(let b=0;b<e.length;b++){let C=e.charCodeAt(b),T=b>0?e.charCodeAt(b-1):0,k=b<e.length-1?e.charCodeAt(b+1):0;if(!s&&!c&&C===47&&k===47){b+=2;while(b<e.length&&e.charCodeAt(b)!==10)b++;continue}if(!s&&!c&&C===47&&k===42){c=!0,f=1,r+="/*",b++;continue}else if(c&&C===42&&k===47){if(f--,r+="*/",b++,f===0)c=!1;continue}else if(c&&C===47&&k===42){f++,r+="/*",b++;continue}let R=e[b];if(!s&&(C===34||C===39||C===96))s=!0,o=R,r+=R;else if(s&&R===o&&T!==92)s=!1,r+=R;else if(!s&&!c)if(C===40&&i===0&&a&&g===0){n=r.trim();let I=of(n),_=I>0?n.slice(0,I):"",L=n.slice(I),P="";if(L.startsWith("async ")||L.startsWith("async\t")||L.startsWith(`async
42
- `))L=L.slice(6).trimStart(),P="async ";if(L.startsWith("*"))L=L.slice(1).trimStart(),P+="*";n=_+L,r=P+R,a=!1,d=!0,v=!1,i=1}else if(C===123||C===91||C===40){if(i++,r+=R,v&&C===123)v=!1}else if(C===125||C===93||C===41){if(i--,r+=R,C===41&&i===0&&!a&&!d)u=!0;if(d){if(C===41&&i===0&&!v)v=!0;else if(C===125&&i===0)d=!1,v=!1}}else if(C===58&&i===0&&a&&g===0)n=r.trim(),r="",a=!1;else if(C===58&&i===0&&u)l=!0,r+=R;else if(C===60&&l)g++,r+=R;else if(C===60&&a&&i===0)g++,r+=R;else if(C===62&&g>0&&T!==61)g--,r+=R;else if(C===61&&k===62&&l&&g===0)l=!1,u=!1,r+=R;else if(C===44&&i===0&&g===0&&!v){if(n&&r.trim()){let I=r.trim();t.push([n,I])}else if(a&&r.trim()){let I=r.trim();if(dr(I))t.push([I,I]);else if(I.startsWith("...")&&I.length>3)t.push(["...",I.slice(3).trim()])}r="",n="",a=!0,u=!1,l=!1,g=0}else r+=R;else r+=R}if(n&&r.trim()){let b=r.trim();t.push([n,b])}else if(a&&r.trim()){let b=r.trim();if(dr(b))t.push([b,b]);else if(b.startsWith("...")&&b.length>3)t.push(["...",b.slice(3).trim()])}return t}function cf(e){let t=e.trim();if(t.startsWith("get ")&&t.length>4){let r=t.slice(4).trim();if(r)return{kind:"get",name:r}}if(t.startsWith("set ")&&t.length>4){let r=t.slice(4).trim();if(r)return{kind:"set",name:r}}return null}function ff(e,t,r){let n=r.trim();if(n.charCodeAt(0)!==40)return null;let i=Xe(n,0,"(",")");if(i===-1)return null;let s=n.slice(1,i).trim(),o=n.slice(i+1).trimStart();if(!o.startsWith("=>"))return null;let a=o.slice(2).trim();if(e==="get")return`get ${t}(): ${a||"unknown"}`;return`set ${t}(${s})`}function uf(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 r=0;for(let n=0;n<t.length;n++){let i=t.charCodeAt(n);if(i===40)r++;else if(i===41){if(r--,r===0){let s=t.slice(n+1).trimStart();if(s.startsWith("{"))return!0;if(s.startsWith(":")){let o=Zs(s,1);if(o?.kind==="arrow")return!1;if(o?.kind==="body")return!0}return!1}}}return!1}function hf(e){let t=e.trimEnd();if(!t.endsWith(">"))return null;let r=0,n=-1;for(let s=t.length-1;s>=0;s--){let o=t.charCodeAt(s);if(o===62){if(s>0&&t.charCodeAt(s-1)===61)continue;r++}else if(o===60){if(r--,r===0){n=s;break}}}if(n===-1)return null;let i=t.slice(0,n).trimEnd();if(!i)return null;return{name:i,typeParams:t.slice(n)}}function Us(e,t){let r=t.trimStart(),n=!1,i=!1;if(r.startsWith("async ")||r.startsWith("async\t"))n=!0,r=r.slice(5).trimStart();if(r.startsWith("*"))i=!0,r=r.slice(1).trimStart();let s="";if(r.charCodeAt(0)===60){let g=0,d=-1;for(let v=0;v<r.length;v++)if(r.charCodeAt(v)===60)g++;else if(r.charCodeAt(v)===62&&!(v>0&&r.charCodeAt(v-1)===61)){if(g--,g===0){d=v;break}}if(d!==-1)s=r.slice(0,d+1),r=r.slice(d+1).trimStart()}let o=r.indexOf("("),a=Xe(r,o,"(",")");if(o===-1||a===-1)return"() => unknown";let c=r.slice(o,a+1),f="unknown",u=r.slice(a+1).trimStart();if(u.charCodeAt(0)===58){let g=u.slice(1),d=Zs(g,0);if(d)f=g.slice(0,d.index).trim();else f=g.trim()}if(f==="unknown"){if(n&&i)f="AsyncGenerator<unknown, void, unknown>";else if(i)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=jt(c);return`${s}${l} => ${f}`}function Zs(e,t){let r=0,n=0,i=0,s=0,o=!1,a=0;for(let c=t;c<e.length;c++){let f=e.charCodeAt(c);if(o){if(f===92)c++;else if(f===a)o=!1;continue}if(f===34||f===39||f===96){o=!0,a=f;continue}if(f===40)r++;else if(f===41&&r>0)r--;else if(f===91)n++;else if(f===93&&n>0)n--;else if(f===60)i++;else if(f===62&&i>0&&e.charCodeAt(c-1)!==61)i--;else if(f===125&&s>0)s--;else if(f===123){let u=r>0||n>0||i>0||s>0,l=e.slice(t,c).trimEnd(),g=l.charCodeAt(l.length-1),d=l.length===0||g===38||g===124||g===40||g===44||g===58||g===61||g===91;if(u||d)s++;else return{index:c,kind:"body"}}else if(f===61&&c+1<e.length&&e.charCodeAt(c+1)===62&&r===0&&n===0&&i===0&&s===0)return{index:c,kind:"arrow"}}return null}function Xe(e,t,r,n){let i=0;for(let s=t;s<e.length;s++)if(e[s]===r)i++;else if(e[s]===n){if(n===">"&&s>0&&e[s-1]==="=")continue;if(i--,i===0)return s}return-1}function Br(e){let t=0,r=0,n=!1,i="";for(let s=0;s<e.length-1;s++){let o=e[s],a=e[s+1],c=s>0?e[s-1]:"";if(!n&&(o==='"'||o==="'"||o==="`"))n=!0,i=o;else if(n&&o===i&&c!=="\\")n=!1;if(!n){if(o==="<"){let f=Xe(e,s,"<",">");if(f!==-1){s=f;continue}}if(o==="(")t++;else if(o===")")t--;else if(o==="[")r++;else if(o==="]")r--;if(o==="="&&a===">"&&t===0&&r===0)return s}}return-1}function Xs(e,t=!1,r=0,n=!0){let i=e.trim();if(i.length>200&&on(i,"=>")>2&&on(i,"<")>5&&!i.startsWith("function"))return t?"((...args: any[]) => any)":"(...args: any[]) => any";if(i.startsWith("async ")&&i.includes("=>")){let o=i.slice(5).trim(),a=Br(o);if(a===-1)return t?"(() => Promise<unknown>)":"() => Promise<unknown>";let c=o.substring(0,a).trim(),f=o.substring(a+2).trim(),u=Ks(c),{params:l,returnType:g}=u;if(l=jt(l),l==="()"||l==="")l="()";else if(!l.startsWith("("))l=`(${l})`;let d=g;if(d);else if(f.startsWith("{"))d=hr(f.slice(1,f.endsWith("}")?-1:void 0),!0,l);else d=Te(f,n,!1,r+1);let v=`${l} => ${g||d.startsWith("Promise<")?d:`Promise<${d}>`}`;return t?`(${v})`:v}if(i.includes("=>")){let o="",a=i;if(i.startsWith("<")){let C=Xe(i,0,"<",">");if(C!==-1)o=i.substring(0,C+1),a=i.substring(C+1).trim()}let c=Br(a);if(c===-1)return t?"(() => unknown)":"() => unknown";let f=a.substring(0,c).trim(),u=a.substring(c+2).trim(),l=Ks(f),{params:g,returnType:d}=l;if(g=jt(g),g==="()"||g==="")g="()";else if(!g.startsWith("("))g=`(${g})`;let v="unknown";if(d)v=d;else if(u.startsWith("{"))v=hr(u.slice(1,u.endsWith("}")?-1:void 0),!1,g);else if(Lr(u)||zs(u)&&Lr(u.slice(1,-1).trim()))v="JSX.Element";else if(u.includes("=>")){let C=u.trimStart(),T=C.indexOf("("),k=T!==-1?Xe(C,T,"(",")"):-1,R=k!==-1?C.indexOf("=>",k):-1;if(T===0&&k!==-1&&R!==-1){let I=C.substring(T+1,k).trim(),_=jt(I);if(o.includes("T")&&_.includes("T"))v=`(${_}) => T`;else v=`(${_}) => any`}else v="any"}else if(t)v="unknown";else v=Pt(u,Hs(g));let b=`${o}${g} => ${v}`;return t?`(${b})`:b}if(i.startsWith("function")){let o=8,a=i.length;while(o<a&&i.charCodeAt(o)<=32)o++;let c=!1;if(o<a&&i.charCodeAt(o)===42){c=!0,o++;while(o<a&&i.charCodeAt(o)<=32)o++}let f="";if(o<a&&i.charCodeAt(o)===60){let g=o,d=1;o++;while(o<a&&d>0){let v=i.charCodeAt(o);if(v===60)d++;else if(v===62&&i.charCodeAt(o-1)!==61)d--;o++}f=i.substring(g,o);while(o<a&&i.charCodeAt(o)<=32)o++}let u=i.indexOf("(",o);if(u!==-1){let g=1,d=u+1;while(d<a&&g>0){let T=i.charCodeAt(d);if(T===40)g++;else if(T===41)g--;d++}let v=i.substring(u+1,d-1).trim(),b=v?`(${v})`:"()";if(c){let T=i.substring(d).trim(),k=T.indexOf("Generator<");if(k!==-1){let I=k+10,_=T.indexOf(">",I);if(_!==-1){let L=T.substring(I,_),P=`${f}${b} => Generator<${L}>`;return t?`(${P})`:P}}let R=`${f}${b} => Generator<any, any, any>`;return t?`(${R})`:R}let C=`${f}${b} => unknown`;return t?`(${C})`:C}let l="(...args: any[]) => unknown";return t?`(${l})`:l}if(i.includes("=>")&&i.includes("(")&&i.includes(")")){if(i.length>100||on(i,"=>")>2){let o="";if(i.charCodeAt(0)===60){let l=Xe(i,0,"<",">");if(l!==-1)o=i.substring(0,l+1)}let a=i.indexOf("("),c=a!==-1?Xe(i,a,"(",")"):-1,f=a!==-1&&c!==-1?i.substring(a,c+1):"(...args: any[])";f=jt(f);let u=`${o}${f} => any`;return t?`(${u})`:u}return t?`(${i})`:i}let s="() => unknown";return t?`(${s})`:s}function Ks(e){let t=e.trim();if(!t.startsWith("("))return{params:t,returnType:""};let r=Xe(t,0,"(",")");if(r===-1)return{params:t,returnType:""};let n=t.slice(r+1).trim();return{params:t.slice(0,r+1),returnType:n.startsWith(":")?n.slice(1).trim():""}}function Qs(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 eo(e){let t=e.lastIndexOf(" satisfies ");if(t===-1)return null;let r=e.slice(t+11).trim();if(r.endsWith(";"))r=r.slice(0,-1).trim();return r||null}var Gr=!1,_e=null;var dn=()=>{};function De(e){return e===Se||e===Ae||e===ne||e===ye}function Ot(e){return e>=65&&e<=90||e>=97&&e<=122||e===mf||e===io||e>127}function Ve(e){return Ot(e)||e>=48&&e<=57}function pf(e){let t=!0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n===ct){if(t)return!1;t=!0}else if(t){if(!Ot(n))return!1;t=!1}else if(!Ve(n))return!1}return e.length>0&&!t}function Vr(e,t,r){let n=t+1;while(n<e.length){let i=e.charCodeAt(n);if(i===He){n+=2;continue}if(n++,i===r)break}return n}function gf(e){if(e==="any"||e==="object"||e==="unknown")return!0;if(e.startsWith("Record<")||e.startsWith("Array<"))return!0;return e.charCodeAt(0)===V&&e.includes("[")&&e.includes("]:")}function no(e,t,r=!0){return oo(e,t,r,!0)}function so(e,t,r=!0){return oo(e,t,r,!1)}function oo(e,t,r,n){let i=e,s=r,o=n,a=i.length,c=[],f=new Map,u=new Set,l=0;if(l<a&&i.charCodeAt(l)===65279)l++;function g(p,h){if(p<h){let m=i.charCodeAt(p),y=i.charCodeAt(h-1);if(m!==Se&&m!==Ae&&m!==ne&&m!==ye&&y!==Se&&y!==Ae&&y!==ne&&y!==ye)return i.slice(p,h)}while(p<h&&De(i.charCodeAt(p)))p++;while(h>p&&De(i.charCodeAt(h-1)))h--;return i.slice(p,h)}function d(){if(l>=a)return;let p=i.charCodeAt(l);if(p!==Se&&p!==Ae&&p!==ne&&p!==ye&&p!==z)return;while(l<a){let h=i.charCodeAt(l);if(h===Se||h===Ae||h===ne||h===ye){l++;continue}if(h===z&&l+1<a){let m=i.charCodeAt(l+1);if(m===z){let y=i.indexOf(`
43
- `,l+2);l=y===-1?a:y+1;continue}if(m===ve){let y=i.indexOf("*/",l+2);l=y===-1?a:y+2;continue}}break}}function v(p){let h=p.length,m=0,y=h;for(let w=0;w<h;w++){let E=p.charCodeAt(w);if(m){if(E===He){w++;continue}if(E===m)m=0;continue}if(E===ie||E===le||E===Pe){m=E;continue}if(E===z&&w+1<h){let x=p.charCodeAt(w+1);if(x===z){y=w;while(y>0&&(p.charCodeAt(y-1)===Se||p.charCodeAt(y-1)===Ae))y--;return p.slice(0,y)}if(x===ve){let O=p.indexOf("*/",w+2);if(O!==-1){p=`${p.slice(0,w)} ${p.slice(O+2)}`,w--;continue}}}}y=h;while(y>0&&(p.charCodeAt(y-1)===Se||p.charCodeAt(y-1)===Ae||p.charCodeAt(y-1)===ye))y--;return y<h?p.slice(0,y):p}function b(p){l++;let h=p===ie?"'":'"';while(l<a){let m=i.indexOf(h,l);if(m===-1){l=a;return}let y=0,w=m-1;while(w>=0&&i.charCodeAt(w)===He)y++,w--;if(y%2===0){l=m+1;return}l=m+1}}function C(){l++;let p=[];while(l<a){let h=i.charCodeAt(l);if(p.length===0){if(h===He){l+=2;continue}if(h===Pe){l++;return}if(h===io&&l+1<a&&i.charCodeAt(l+1)===V){l+=2,p.push(0);continue}l++;continue}if(h===ie||h===le){b(h);continue}if(h===Pe){C();continue}if(h===z&&l+1<a){let m=i.charCodeAt(l+1);if(m===z){let y=i.indexOf(`
44
- `,l+2);l=y===-1?a:y+1;continue}if(m===ve){let y=i.indexOf("*/",l+2);l=y===-1?a:y+2;continue}if(I()){_();continue}l++;continue}if(h===V){p[p.length-1]++,l++;continue}if(h===J){let m=p[p.length-1];if(m===0){p.pop(),l++;continue}p[p.length-1]=m-1,l++;continue}l++}}function T(){let p=i.charCodeAt(l);if(p===ie||p===le)return b(p),!0;if(p===Pe)return C(),!0;if(p===z&&l+1<a){let h=i.charCodeAt(l+1);if(h===z){let m=i.indexOf(`
45
- `,l+2);return l=m===-1?a:m+1,!0}if(h===ve){let m=i.indexOf("*/",l+2);return l=m===-1?a:m+2,!0}if(I())return _(),!0}return!1}function k(p){let h=p;for(;;){while(h>=0&&(i.charCodeAt(h)===Se||i.charCodeAt(h)===Ae||i.charCodeAt(h)===ne||i.charCodeAt(h)===ye))h--;if(h<0)return-1;if(i.charCodeAt(h)===z&&h>0&&i.charCodeAt(h-1)===ve){let w=i.lastIndexOf("/*",h-2);if(w===-1)return-1;h=w-1;continue}let m=i.lastIndexOf(`
46
- `,h)+1,y=R(m,h);if(y!==-1){h=y-1;continue}return h}}function R(p,h){let m=0;for(let y=p;y<=h;y++){let w=i.charCodeAt(y);if(m){if(w===He){y++;continue}if(w===m)m=0;continue}if(w===ie||w===le||w===Pe){m=w;continue}if(w===z&&y+1<=h&&i.charCodeAt(y+1)===z)return y}return-1}function I(){let p=k(l-1);if(p<0)return!0;let h=i.charCodeAt(p);if(h===be||h===ee||h===pe||h===33||h===38||h===124||h===jr||h===Qe||h===et||h===Y||h===V||h===J||h===94||h===126||h===43||h===45||h===ve||h===37||h===ge||h===fe)return!0;if(Ve(h)){let m=p;while(m>=0&&Ve(i.charCodeAt(m)))m--;let y=i.slice(m+1,p+1);if(y==="return"||y==="typeof"||y==="void"||y==="delete"||y==="throw"||y==="new"||y==="in"||y==="of"||y==="case"||y==="instanceof"||y==="yield"||y==="await")return!0}return!1}function _(){l++;let p=!1;while(l<a){let h=i.charCodeAt(l);if(h===He){l+=2;continue}if(p){if(h===$e)p=!1;l++;continue}if(h===pe){p=!0,l++;continue}if(h===z){l++;break}if(h===ne||h===ye)break;l++}while(l<a&&Ve(i.charCodeAt(l)))l++}function L(){let p=l;while(l<a&&Ve(i.charCodeAt(l)))l++;return i.slice(p,l)}function P(p){if(l+p.length>a)return!1;for(let h=0;h<p.length;h++)if(i.charCodeAt(l+h)!==p.charCodeAt(h))return!1;if(l+p.length<a&&Ve(i.charCodeAt(l+p.length)))return!1;return!0}function F(p){let h=l+p;while(h<a){let m=i.charCodeAt(h);if(m===Se||m===Ae||m===ne||m===ye){h++;continue}return m!==ct&&m!==be}return!1}function U(){if(l>=a)return!1;switch(i.charCodeAt(l)){case 101:return P("export")||P("enum");case 105:return P("import")||P("interface");case 102:return P("function");case 99:return P("class")||P("const");case 116:return P("type");case 108:return P("let");case 118:return P("var");case 100:return P("declare")||P("default");case 109:return P("module");case 110:return P("namespace");case 97:return P("abstract")||P("async");default:return!1}}function q(){let p=i.charCodeAt(l);if(p!==ne&&p!==ye)return!1;let h=l;if(l++,p===ye&&l<a&&i.charCodeAt(l)===ne)l++;while(l<a){let y=i.charCodeAt(l);if(y===Se||y===Ae||y===ye||y===ne){l++;continue}if(y===z&&l+1<a){let w=i.charCodeAt(l+1);if(w===z){let E=i.indexOf(`
47
- `,l+2);l=E===-1?a:E+1;continue}if(w===ve){let E=i.indexOf("*/",l+2);l=E===-1?a:E+2;continue}}break}let m=l>=a||U()||i.charCodeAt(l)===J;return l=h,m}function oe(p){let h=p-1;while(h>=0){let S=i.charCodeAt(h);if(S===Se||S===Ae||S===ye||S===ne){h--;continue}break}if(h<0)return!0;let m=i[h];if("+-*/%=<>&|^!~?:,.([{".includes(m))return!0;let y=h;while(y>0&&i.charCodeAt(y-1)!==ne)y--;let w=i.slice(y,h+1),E=w.lastIndexOf("<");if(E!==-1&&/^<[A-Za-z]/.test(w.slice(E))&&!w.slice(E).includes(">"))return!0;let x=h;while(x>=0&&/[a-z]/i.test(i[x]))x--;let O=i.slice(x+1,h+1);return["as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","return","yield","void"].includes(O)}function H(){let p=i.charCodeAt(l);if(p!==ne&&p!==ye)return!1;if(oe(l))return!1;let h=l;l++;while(l<a){let E=i.charCodeAt(l);if(E===Se||E===Ae||E===ye||E===ne){l++;continue}if(E===z&&l+1<a){let x=i.charCodeAt(l+1);if(x===z){let O=i.indexOf(`
48
- `,l+2);l=O===-1?a:O+1;continue}if(x===ve){let O=i.indexOf("*/",l+2);l=O===-1?a:O+2;continue}}break}let m=l<a?i[l]:"",y=i.slice(l,l+2),w=m==="."||m==="?"||m===":"||m===")"||m==="]"||m==="}"||m===","||m==="+"||m==="-"||m==="*"||m==="/"||m==="%"||m==="<"||m===">"||m==="="||m==="&"||m==="|"||m==="^"||m==="`"||y==="=>"||P("as")||P("satisfies")||P("instanceof")||P("in");return l=h,!w}function Z(){let p=i.charCodeAt(l);if(p!==ne&&p!==ye)return!1;if(oe(l))return!1;let h=l;l++;while(l<a){let w=i.charCodeAt(l);if(w===Se||w===Ae||w===ye||w===ne){l++;continue}if(w===z&&l+1<a){let E=i.charCodeAt(l+1);if(E===z){let x=i.indexOf(`
49
- `,l+2);l=x===-1?a:x+1;continue}if(E===ve){let x=i.indexOf("*/",l+2);l=x===-1?a:x+2;continue}}break}let m=l<a?i[l]:"",y=m==="|"||m==="&"||m==="["||m==="."||m==="?"||m===":"||m===">"||m===")"||m===","||P("extends");return l=h,!y}function re(){let p=i.charCodeAt(l);if(p!==ne&&p!==ye)return!1;let h=l;if(l++,p===ye&&l<a&&i.charCodeAt(l)===ne)l++;while(l<a){let y=i.charCodeAt(l);if(y===Se||y===Ae||y===ye||y===ne){l++;continue}if(y===z&&l+1<a&&i.charCodeAt(l+1)===z){let w=i.indexOf(`
50
- `,l+2);l=w===-1?a:w+1;continue}break}if(l>=a)return l=h,!0;let m=i.charCodeAt(l);if(m===124||m===38||m===ct||m===jr||m===Qe)return l=h,!1;if(P("extends")||P("keyof")||P("typeof")||P("infer")||P("is")||P("as")||P("in"))return l=h,!1;return l=h,!0}let X=/[{}'"`\/]/g,Re=/[()'"`\/]/g,Oe=/[[\]'"`\/]/g,Dt=/[<>'"`\/]/g;function ke(p,h){let m=1;l++;let y=p===V?X:p===ee?Re:p===pe?Oe:Dt;y.lastIndex=l;let w;while((w=y.exec(i))!==null){let E=w.index,x=i.charCodeAt(E);if(x===ie||x===le){l=E,b(x),y.lastIndex=l;continue}if(x===Pe){l=E,C(),y.lastIndex=l;continue}if(x===z){if(l=E,T()){y.lastIndex=l;continue}y.lastIndex=E+1;continue}if(x===p)m++;else if(x===h){if(h===fe&&E>0&&i.charCodeAt(E-1)===be){y.lastIndex=E+1;continue}if(m--,m===0)return l=E+1,l}y.lastIndex=E+1}return l=a,l}function Me(){return l>0&&i.charCodeAt(l-1)===be}function ft(){return l+1<a&&i.charCodeAt(l+1)===fe}let ae=/[<{};'"`\/\n\r()[\]]/g;function Q(){let p=0,h=0,m=0,y=0,w=i.charCodeAt(l)===V;ae.lastIndex=l;let E;while((E=ae.exec(i))!==null){let x=E.index,O=i.charCodeAt(x);if(O===ie||O===le){l=x,b(O),ae.lastIndex=l;continue}if(O===Pe){l=x,C(),ae.lastIndex=l;continue}if(O===z){if(x>0&&i.charCodeAt(x-1)===ge){ae.lastIndex=x+1;continue}if(l=x,T()){ae.lastIndex=l;continue}ae.lastIndex=x+1;continue}if(O===ge){let S=Ss(x);if(S!==null)y=Math.max(0,y+S);ae.lastIndex=x+1;continue}if(O===ee){h++,ae.lastIndex=x+1;continue}if(O===we){h--,ae.lastIndex=x+1;continue}if(O===pe){m++,ae.lastIndex=x+1;continue}if(O===$e){m--,ae.lastIndex=x+1;continue}if(O===V){p++,ae.lastIndex=x+1;continue}if(O===J){let S=p>0;if(S)p--;if((!S||w)&&p===0&&h===0&&m===0&&y===0){l=x+1;return}ae.lastIndex=x+1;continue}if(O===Y&&p===0&&h===0&&m===0&&y===0){l=x+1;return}if((O===ne||O===ye)&&p===0&&h===0&&m===0&&y===0){if(l=x,q())return}ae.lastIndex=x+1}l=a}function It(){l++;while(l<a&&(i.charCodeAt(l)===Se||i.charCodeAt(l)===Ae))l++;let p=i.indexOf(`
51
- `,l),h=p===-1?a:p,m=i.indexOf(";",l);if(m!==-1&&m<h){let y=m-1;while(y>=l&&(i.charCodeAt(y)===Se||i.charCodeAt(y)===Ae))y--;let w=i.charCodeAt(l),E=i.charCodeAt(y);if(w===V&&E===J||w===pe&&E===$e||w===ie&&E===ie||w===le&&E===le||w===Pe&&E===Pe){l=m+1;return}}Q()}function nr(){ke(V,J);while(l<a&&De(i.charCodeAt(l)))l++;if(P("from")){l+=4;while(l<a&&De(i.charCodeAt(l)))l++;if(l<a){let p=i.charCodeAt(l);if(p===ie||p===le)b(p)}}while(l<a&&(i.charCodeAt(l)===Se||i.charCodeAt(l)===Ae))l++;if(l<a&&i.charCodeAt(l)===Y)l++}function Cs(){l++;while(l<a&&De(i.charCodeAt(l)))l++;if(P("as")){l+=2;while(l<a&&De(i.charCodeAt(l)))l++;L();while(l<a&&De(i.charCodeAt(l)))l++}if(P("from")){l+=4;while(l<a&&De(i.charCodeAt(l)))l++;if(l<a){let p=i.charCodeAt(l);if(p===ie||p===le)b(p)}}while(l<a&&(i.charCodeAt(l)===Se||i.charCodeAt(l)===Ae))l++;if(l<a&&i.charCodeAt(l)===Y)l++}function Or(p){let h=p.indexOf("from ");if(h===-1)return;let m=h+5;while(m<p.length&&(p.charCodeAt(m)===32||p.charCodeAt(m)===9))m++;if(m>=p.length)return;let y=p.charCodeAt(m);if(y!==39&&y!==34)return;let w=p.indexOf(p[m],m+1);if(w===-1)return;return p.slice(m+1,w)}function Je(p){if(!s)return;let h=p-1;while(h>=0&&De(i.charCodeAt(h)))h--;if(h<0)return;let m=[],y=!1;while(h>=0){if(h>=1&&i.charCodeAt(h)===z&&i.charCodeAt(h-1)===ve){let x=i.lastIndexOf("/*",h-2);if(x>=0){m.push(i.slice(x,h+1)),y=!0,h=x-1;while(h>=0&&De(i.charCodeAt(h)))h--;continue}break}let w=h;while(w>0&&i.charCodeAt(w-1)!==ne)w--;let E=g(w,h+1);if(E.startsWith("//")){if(y)break;let x=[E];h=w-1;while(h>=0&&(i.charCodeAt(h)===ne||i.charCodeAt(h)===ye))h--;while(h>=0){let O=h;while(O>0&&i.charCodeAt(O-1)!==ne)O--;let S=g(O,h+1);if(S.startsWith("//")){x.push(S),h=O-1;while(h>=0&&(i.charCodeAt(h)===ne||i.charCodeAt(h)===ye))h--}else if(S===""){h=O-1;while(h>=0&&(i.charCodeAt(h)===ne||i.charCodeAt(h)===ye))h--}else break}x.reverse(),m.push(x.join(`
52
- `));continue}break}if(m.length===0)return;return m.reverse(),m}function nc(p){let h=p,m=!1;while(l<a){let S=i.charCodeAt(l);if(S===Y){l++;break}if(S===ie||S===le){b(S),m=!0;while(l<a&&(i.charCodeAt(l)===Se||i.charCodeAt(l)===Ae))l++;if(l<a&&i.charCodeAt(l)===Y)l++;break}if(S===ne&&m)break;l++}let y=g(h,l),w=y.charCodeAt(7)===116&&(y.startsWith("import type ")||y.startsWith("import type{")),E=!1;{let S=6;while(S<y.length&&(y.charCodeAt(S)===Se||y.charCodeAt(S)===Ae))S++;if(S<y.length&&y.charCodeAt(S)===116&&y.startsWith("type",S)){S+=4;while(S<y.length&&(y.charCodeAt(S)===Se||y.charCodeAt(S)===Ae))S++}if(S<y.length){let A=y.charCodeAt(S);E=A===ie||A===le}}let x="";{let S=y.indexOf("from ");if(S!==-1){let A=S+5;while(A<y.length&&(y.charCodeAt(A)===Se||y.charCodeAt(A)===Ae))A++;if(A<y.length){let M=y.charCodeAt(A);if(M===ie||M===le){let N=y.indexOf(String.fromCharCode(M),A+1);if(N!==-1)x=y.slice(A+1,N)}}}else if(E){let A=6;while(A<y.length&&y.charCodeAt(A)!==ie&&y.charCodeAt(A)!==le)A++;if(A<y.length){let M=y.charCodeAt(A),N=y.indexOf(String.fromCharCode(M),A+1);if(N!==-1)x=y.slice(A+1,N)}}}let O=Je(h);return{kind:"import",name:"",text:y,isExported:!1,isTypeOnly:w,isSideEffect:E,source:x,leadingComments:O,start:h,end:l}}function Bi(){let p=l;return ke(V,J),i.slice(p,l)}function ws(p){let h=p.indexOf("(");if(h===-1)return p;let m=p.slice(h);if(m.indexOf("=")===-1)return p;let y=!1;for(let S=0;S<m.length;S++)if(m.charCodeAt(S)===61){let A=S>0?m.charCodeAt(S-1):0,M=S+1<m.length?m.charCodeAt(S+1):0;if(A!==61&&A!==33&&A!==60&&A!==62&&M!==61&&M!==62){y=!0;break}}if(!y)return p;let w=0,E=-1;for(let S=h;S<p.length;S++){let A=p.charCodeAt(S);if(A===40)w++;else if(A===41){if(w--,w===0){E=S;break}}}if(E===-1)return p;let x=p.slice(h,E+1),O=Ft(x);return p.slice(0,h)+O+p.slice(E+1)}function vs(p){let h=p.indexOf("//")!==-1||p.indexOf("/*")!==-1,m=p.split(`
53
- `),y=[],w=[],E=[],x=!1,O=1/0;for(let M=0;M<m.length;M++){let N=m[M];if(h){if(x){if(N.includes("*/"))x=!1;continue}let G=N.trim();if(G.length===0)continue;let B=G.charCodeAt(0);if(B===z){let me=G.charCodeAt(1);if(me===z)continue;if(me===ve){if(!G.includes("*/"))x=!0;continue}}if(B===ve)continue;let D=v(N);if(D.charCodeAt(D.length-1)===Y)D=D.slice(0,-1);D=ws(D);let W=D.trim();if(!W)continue;y.push(D),w.push(W);let j=0;while(j<D.length&&De(D.charCodeAt(j)))j++;if(W!=="{"&&W!=="}"){if(j<O)O=j}E.push(j)}else{let G=N.length;while(G>0&&(N.charCodeAt(G-1)===Se||N.charCodeAt(G-1)===Ae||N.charCodeAt(G-1)===ye))G--;if(G===0)continue;let B=G<N.length?N.slice(0,G):N;if(B.charCodeAt(B.length-1)===Y)B=B.slice(0,-1);B=ws(B);let D=B.trim();if(!D)continue;y.push(B),w.push(D);let W=0;while(W<B.length&&De(B.charCodeAt(W)))W++;if(D!=="{"&&D!=="}"){if(W<O)O=W}E.push(W)}}if(y.length===0)return"{}";if(O===1/0||O<=2)return y.join(`
54
- `);let S=O-2,A=Array(y.length);for(let M=0;M<y.length;M++){let N=w[M];if(N==="{"){A[M]=N;continue}let G=E[M];if(G>O)A[M]=y[M];else if(G===O&&(N.charCodeAt(0)===J||N.charCodeAt(0)===$e||N.charCodeAt(0)===we))A[M]=y[M];else{let B=Math.max(0,G-S);A[M]=" ".repeat(B)+N}}return A.join(`
55
- `)}function at(){if(l>=a||i.charCodeAt(l)!==ge)return"";let p=l;ke(ge,fe);let h=i.slice(p,l);if(h.includes(`
56
- `)){let m="",y=!1;for(let w=0;w<h.length;w++){let E=h.charCodeAt(w);if(E===32||E===9||E===10||E===13){if(!y&&m.length>0)m+=" ",y=!0}else m+=h[w],y=!1}if(m.charCodeAt(1)===32)m=`<${m.slice(2)}`;if(m.charCodeAt(m.length-2)===32)m=`${m.slice(0,-2)}>`;return m}return h}function Et(){if(l>=a||i.charCodeAt(l)!==ee)return"()";let p=l;return ke(ee,we),i.slice(p,l)}function Ft(p){let h=p.slice(1,-1).trim();if(!h)return"()";if(p.indexOf(`
57
- `)===-1&&h.indexOf(":")!==-1&&h.indexOf("{")===-1&&h.indexOf("[")===-1&&h.indexOf("=")===-1&&h.indexOf("@")===-1&&h.indexOf("...")===-1){let S=0,A=0,M=0;for(let N=0;N<h.length;N++){let G=h.charCodeAt(N);if(G===ee||G===ge||G===V)M++;else if(G===we||G===fe||G===J)M--;else if(M===0){if(G===Qe)S++;else if(G===et)A++}}if(S>=A+1){let N=!1;for(let G=0;G<mn.length;G++){let B=mn[G],D=h.indexOf(B);if(D!==-1){let W=D+B.length;if((D===0||!Ve(h.charCodeAt(D-1)))&&(W>=h.length||!Ve(h.charCodeAt(W)))){N=!0;break}}}if(!N)return p}}let m=[],y=0,w=0,E=!1,x=0;for(let S=0;S<=h.length;S++){if(S===h.length){m.push(h.slice(y).trim());break}let A=h.charCodeAt(S);if(E){if(A===He){S++;continue}if(A===x)E=!1;continue}if(A===z&&S+1<h.length){let M=h.charCodeAt(S+1);if(M===ve){S+=2;while(S+1<h.length&&!(h.charCodeAt(S)===ve&&h.charCodeAt(S+1)===z))S++;S++;continue}if(M===z){while(S<h.length&&h.charCodeAt(S)!==10)S++;continue}}if(A===ie||A===le||A===Pe){E=!0,x=A;continue}if(A===ee||A===V||A===pe||A===ge)w++;else if(A===we||A===J||A===$e||A===fe&&!(S>0&&h.charCodeAt(S-1)===be))w--;else if(A===et&&w===0)m.push(h.slice(y,S).trim()),y=S+1}let O=[];for(let S of m){if(!S)continue;let A=S.trim();if(A.startsWith("//")||A.startsWith("/*"))continue;let M=S;{let N=!1,G=0,B=0,D=0;for(let W=0;W<M.length-1;W++){let j=M.charCodeAt(W);if(j===ne){D=W+1;continue}if(N){if(j===He){W++;continue}if(j===G)N=!1;continue}if(j===ie||j===le||j===Pe){N=!0,G=j;continue}if(j===V||j===pe||j===ee||j===ge){B++;continue}if(j===J||j===$e||j===we||j===fe){if(B>0)B--;continue}if(j===z&&M.charCodeAt(W+1)===z){if(B===0){M=M.slice(0,W).trimEnd();break}let me=M.indexOf(`
58
- `,W);if(me===-1){M=M.slice(0,D).trimEnd();break}let Bt=M.slice(0,D),hc=M.slice(me+1);M=`${Bt}${hc}`,W=D-1}}}if(!M.trim())continue;O.push(Es(M))}return`(${O.join(", ")})`}function sc(p){if(!p.startsWith("{")&&!p.startsWith("["))return p;let h="",m=0,y=0,w=!1,E=0;while(m<p.length){let x=p.charCodeAt(m);if(w){if(x===He&&m+1<p.length){h+=p[m]+p[m+1],m+=2;continue}if(x===E)w=!1;h+=p[m],m++;continue}if(x===z&&m+1<p.length){let O=p.charCodeAt(m+1);if(O===ve){let S=m;m+=2;while(m+1<p.length&&!(p.charCodeAt(m)===ve&&p.charCodeAt(m+1)===z))m++;m=Math.min(m+2,p.length),h+=p.slice(S,m);continue}if(O===z){let S=m;while(m<p.length&&p.charCodeAt(m)!==10)m++;h+=p.slice(S,m);continue}}if(x===ie||x===le||x===Pe){w=!0,E=x,h+=p[m],m++;continue}if(x===V||x===pe||x===ee)y++;else if(x===J||x===$e||x===we)y--;if(y>=1&&x===be&&(m+1>=p.length||p.charCodeAt(m+1)!==be&&p.charCodeAt(m+1)!==fe)){while(h.length>0&&(h[h.length-1]===" "||h[h.length-1]==="\t"||h[h.length-1]===`
59
- `))h=h.slice(0,-1);m++;let O=0;while(m<p.length){let S=p.charCodeAt(m);if(S===ie||S===le||S===Pe){let A=S;m++;while(m<p.length){if(p.charCodeAt(m)===He){m+=2;continue}if(p.charCodeAt(m)===A){m++;break}m++}continue}if(S===V||S===pe||S===ee)O++;else if(S===J||S===$e||S===we){if(O===0)break;O--}else if(S===et&&O===0)break;m++}continue}if(y===1&&x===ct&&m+2<p.length&&p.charCodeAt(m+1)===ct&&p.charCodeAt(m+2)===ct){m+=3;continue}h+=p[m],m++}return h}function Es(p){let h=p.trim(),m=h.startsWith("...");if(m)h=h.slice(3).trim();while(h.startsWith("@")){let D=1;while(D<h.length&&Ve(h.charCodeAt(D)))D++;if(D<h.length&&h.charCodeAt(D)===ee){let W=1;D++;while(D<h.length&&W>0){if(h.charCodeAt(D)===ee)W++;else if(h.charCodeAt(D)===we)W--;D++}}h=h.slice(D).trim()}let y=!0;while(y){y=!1;for(let D of mn)if(h.startsWith(D)&&h.length>D.length&&!Ve(h.charCodeAt(D.length))){let W=h.slice(D.length).trim();if(W.charCodeAt(0)===Qe||W.charCodeAt(0)===jr&&W.length>1&&W.charCodeAt(1)===Qe)break;h=W,y=!0;break}}let w=-1,E=-1,x=0,O=!1,S=0;for(let D=0;D<h.length;D++){let W=h.charCodeAt(D);if(O){if(W===He){D++;continue}if(W===S)O=!1;continue}if(W===z&&D+1<h.length){let j=h.charCodeAt(D+1);if(j===ve){D+=2;while(D+1<h.length&&!(h.charCodeAt(D)===ve&&h.charCodeAt(D+1)===z))D++;D++;continue}if(j===z){while(D<h.length&&h.charCodeAt(D)!==10)D++;continue}}if(W===ie||W===le||W===Pe){O=!0,S=W;continue}if(W===ee||W===V||W===pe||W===ge)x++;else if(W===we||W===J||W===$e||W===fe&&!(D>0&&h.charCodeAt(D-1)===be))x--;else if(x===0){if(W===Qe&&w===-1)w=D;else if(W===be&&E===-1&&(D===0||h.charCodeAt(D-1)!==be)&&(D+1>=h.length||h.charCodeAt(D+1)!==be&&h.charCodeAt(D+1)!==fe))E=D}}let A,M,N=E!==-1;if(w!==-1&&(E===-1||w<E))if(A=h.slice(0,w).trim(),E!==-1)M=h.slice(w+1,E).trim();else M=h.slice(w+1).trim();else if(E!==-1)A=h.slice(0,E).trim(),M=Gi(h.slice(E+1).trim());else A=h,M="unknown";if(A=sc(A),(A.startsWith("{")||A.startsWith("["))&&A.includes(`
38
+ }`:"{}";if(o.length===0)return f;let u=o[0];for(let l=1;l<o.length;l++)u=`Omit<${u}, keyof ${o[l]}> & ${o[l]}`;return s.length>0?`Omit<${u}, keyof ${f}> & ${f}`:u}function mr(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 r=1;r<e.length;r++)if(!ht(e.charCodeAt(r)))return!1;return!0}function pr(e){let t=e.split(".");return t.length>0&&t.every(mr)}function sf(e){let t=!1,r="";for(let n=0;n<e.length;n++){let i=e[n];if(t){if(i==="\\")n++;else if(i===r)t=!1;continue}if(i==='"'||i==="'"||i==="`"){t=!0,r=i;continue}if(i==="(")return n;if(i==="<"){let s=Qe(e,n,"<",">");if(s!==-1)n=s}}return-1}function Zs(e){if(e.length<3||!e.endsWith(")"))return null;let t=sf(e);if(t===-1||Qe(e,t,"(",")")!==e.length-1)return null;let r=e.slice(0,t).trim(),n=!1;if(r.endsWith("?."))n=!0,r=r.slice(0,-2).trim();let i=r,s=!1,o=r.indexOf("<");if(o!==-1){if(Qe(r,o,"<",">")!==r.length-1)return null;i=r.slice(0,o).trim(),s=!0}if(!pr(i))return null;let a=e.slice(t+1,-1).trim(),c=jr(a)!==-1||a.startsWith("function")||a.startsWith("async function"),f=pr(a),u=!c&&a.endsWith(")")&&Zs(a)!==null;if(!s&&!n&&!c&&!f&&!u)return null;let l=`ReturnType<typeof ${r}>`;return n?`${l} | undefined`:l}function of(e){let t=e.split(`
39
+ `).map((f)=>Xs(f)).join(`
40
+ `),r=t.indexOf("async");if(r!==-1){let f=r>0?t.charCodeAt(r-1):32,u=r+5<t.length?t.charCodeAt(r+5):32;if(!ht(f)&&!ht(u))t=(t.slice(0,r)+t.slice(r+5)).trim()}let n=t.indexOf("(");if(n!==-1){let f=Qe(t,n,"(",")");if(f!==-1){let u=t.slice(n,f+1),l=_t(u);t=t.slice(0,n)+l+t.slice(f+1)}}let i=t.length,s="",o=[],a=!1,c=!1;for(let f=0;f<i;f++){let u=t.charCodeAt(f);if(u===123||u===40)o.push(u);else if(u===125||u===41)o.pop();if(u<=32){if(a=!0,u===10||u===13)c=!0;continue}if(a&&s.length>0){let l=(o.length>0?o[o.length-1]:0)===123;if(c&&l){let g=s.charCodeAt(s.length-1),p=g===59||g===44||g===123||u===125,v=s.length>=2&&s.charCodeAt(s.length-1)===47&&s.charCodeAt(s.length-2)===42;if(!p&&!v)s+="; ";else s+=" "}else s+=" "}a=!1,c=!1,s+=t[f]}return s.trim()}function ht(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===95||e===36}function _t(e){let t=e.trim(),r,n=!1;if(t.startsWith("(")&&t.endsWith(")"))r=t.slice(1,-1),n=!0;else r=t;let i=r.trim();if(!i)return n?"()":"";let s=!1;{let v=0;for(let b=0;b<i.length;b++){let w=i.charCodeAt(b);if(w===40||w===60||w===91||w===123)v++;else if(w===41||w===62||w===93||w===125)v--;else if(v===0&&w===61){let T=b>0?i.charCodeAt(b-1):0,k=b+1<i.length?i.charCodeAt(b+1):0;if(T!==61&&T!==33&&T!==60&&T!==62&&k!==61&&k!==62){s=!0;break}}}}if(!s)return t;let o=[],a=[],c=0,f=0,u=!1,l=0;for(let v=0;v<=i.length;v++){if(v===i.length){o.push(i.slice(c));break}let b=i.charCodeAt(v);if(u){if(b===92){v++;continue}if(b===l)u=!1;continue}if(b===47&&v+1<i.length){let w=i.charCodeAt(v+1);if(w===42){v+=2;while(v+1<i.length&&!(i.charCodeAt(v)===42&&i.charCodeAt(v+1)===47))v++;v++;continue}if(w===47){while(v<i.length&&i.charCodeAt(v)!==10)v++;continue}}if(b===39||b===34||b===96){u=!0,l=b;continue}if(b===40||b===60||b===91||b===123)f++;else if(b===41||b===62||b===93||b===125)f--;else if(b===44&&f===0){o.push(i.slice(c,v));let w=",",T=v+1;while(T<i.length&&i.charCodeAt(T)<=32)w+=i[T],T++;a.push(w),c=T}}let g=[];for(let v of o){let b=v.trim();if(!b){g.push(v);continue}if(b.startsWith("//"))continue;let w=Xs(b),T=v.slice(0,v.length-v.trimStart().length);g.push(T+af(w))}let p=g[0]||"";for(let v=1;v<g.length;v++)p+=(a[v-1]||", ")+g[v];return n?`(${p})`:p}function Xs(e){let t=!1,r=0;for(let n=0;n<e.length-1;n++){let i=e.charCodeAt(n);if(t){if(i===92){n++;continue}if(i===r)t=!1;continue}if(i===39||i===34||i===96){t=!0,r=i;continue}if(i===47&&e.charCodeAt(n+1)===47)return e.slice(0,n).trimEnd()}return e}function af(e){if(e.startsWith("..."))return e;let t=-1,r=-1,n=0,i=!1,s=0;for(let a=0;a<e.length;a++){let c=e.charCodeAt(a);if(i){if(c===92){a++;continue}if(c===s)i=!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){i=!0,s=c;continue}if(c===40||c===60||c===91||c===123)n++;else if(c===41||c===62||c===93||c===125)n--;else if(n===0){if(c===58&&t===-1)t=a;else if(c===61&&r===-1&&(a===0||e.charCodeAt(a-1)!==61)&&(a+1>=e.length||e.charCodeAt(a+1)!==61&&e.charCodeAt(a+1)!==62))r=a}}let o=r!==-1;if(t!==-1&&(r===-1||t<r)){let a=e.slice(0,t).trim(),c=r!==-1?e.slice(t+1,r).trim():e.slice(t+1).trim(),f=o&&!a.endsWith("?")?"?":"";return`${a}${f}: ${c}`}else if(r!==-1){let a=e.slice(0,r).trim(),c=!a.endsWith("?")?"?":"",f=e.slice(r+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 lf(e){let t=0,r=e.length;while(t<r){while(t<r&&(e.charCodeAt(t)===32||e.charCodeAt(t)===9||e.charCodeAt(t)===10||e.charCodeAt(t)===13))t++;if(t+1<r&&e.charCodeAt(t)===47&&e.charCodeAt(t+1)===42){t+=2;while(t+1<r&&!(e.charCodeAt(t)===42&&e.charCodeAt(t+1)===47))t++;t+=2;continue}break}return t}function cf(e){let t=[],r=0,n=e.length;while(r<n){while(r<n&&e.charCodeAt(r)<=32)r++;if(r+1>=n||e.charCodeAt(r)!==47||e.charCodeAt(r+1)!==42)break;let i=r;r+=2;while(r+1<n&&!(e.charCodeAt(r)===42&&e.charCodeAt(r+1)===47))r++;r=Math.min(r+2,n),t.push(e.slice(i,r).trim())}return{comments:t.join(`
41
+ `),key:e.slice(r).trim()}}function ff(e){let t=[],r="",n="",i=0,s=!1,o="",a=!0,c=!1,f=0,u=!1,l=!1,g=0,p=!1,v=!1;for(let b=0;b<e.length;b++){let w=e.charCodeAt(b),T=b>0?e.charCodeAt(b-1):0,k=b<e.length-1?e.charCodeAt(b+1):0;if(!s&&!c&&w===47&&k===47){b+=2;while(b<e.length&&e.charCodeAt(b)!==10)b++;continue}if(!s&&!c&&w===47&&k===42){c=!0,f=1,r+="/*",b++;continue}else if(c&&w===42&&k===47){if(f--,r+="*/",b++,f===0)c=!1;continue}else if(c&&w===47&&k===42){f++,r+="/*",b++;continue}let R=e[b];if(!s&&(w===34||w===39||w===96))s=!0,o=R,r+=R;else if(s&&R===o&&T!==92)s=!1,r+=R;else if(!s&&!c)if(w===40&&i===0&&a&&g===0){n=r.trim();let I=lf(n),_=I>0?n.slice(0,I):"",W=n.slice(I),P="";if(W.startsWith("async ")||W.startsWith("async\t")||W.startsWith(`async
42
+ `))W=W.slice(6).trimStart(),P="async ";if(W.startsWith("*"))W=W.slice(1).trimStart(),P+="*";n=_+W,r=P+R,a=!1,p=!0,v=!1,i=1}else if(w===123||w===91||w===40){if(i++,r+=R,v&&w===123)v=!1}else if(w===125||w===93||w===41){if(i--,r+=R,w===41&&i===0&&!a&&!p)u=!0;if(p){if(w===41&&i===0&&!v)v=!0;else if(w===125&&i===0)p=!1,v=!1}}else if(w===58&&i===0&&a&&g===0)n=r.trim(),r="",a=!1;else if(w===58&&i===0&&u)l=!0,r+=R;else if(w===60&&l)g++,r+=R;else if(w===60&&a&&i===0)g++,r+=R;else if(w===62&&g>0&&T!==61)g--,r+=R;else if(w===61&&k===62&&l&&g===0)l=!1,u=!1,r+=R;else if(w===44&&i===0&&g===0&&!v){if(n&&r.trim()){let I=r.trim();t.push([n,I])}else if(a&&r.trim()){let I=r.trim();if(mr(I))t.push([I,I]);else if(I.startsWith("...")&&I.length>3)t.push(["...",I.slice(3).trim()])}r="",n="",a=!0,u=!1,l=!1,g=0}else r+=R;else r+=R}if(n&&r.trim()){let b=r.trim();t.push([n,b])}else if(a&&r.trim()){let b=r.trim();if(mr(b))t.push([b,b]);else if(b.startsWith("...")&&b.length>3)t.push(["...",b.slice(3).trim()])}return t}function uf(e){let t=e.trim();if(t.startsWith("get ")&&t.length>4){let r=t.slice(4).trim();if(r)return{kind:"get",name:r}}if(t.startsWith("set ")&&t.length>4){let r=t.slice(4).trim();if(r)return{kind:"set",name:r}}return null}function hf(e,t,r){let n=r.trim();if(n.charCodeAt(0)!==40)return null;let i=Qe(n,0,"(",")");if(i===-1)return null;let s=n.slice(1,i).trim(),o=n.slice(i+1).trimStart();if(!o.startsWith("=>"))return null;let a=o.slice(2).trim();if(e==="get")return`get ${t}(): ${a||"unknown"}`;return`set ${t}(${s})`}function df(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 r=0;for(let n=0;n<t.length;n++){let i=t.charCodeAt(n);if(i===40)r++;else if(i===41){if(r--,r===0){let s=t.slice(n+1).trimStart();if(s.startsWith("{"))return!0;if(s.startsWith(":")){let o=Qs(s,1);if(o?.kind==="arrow")return!1;if(o?.kind==="body")return!0}return!1}}}return!1}function mf(e){let t=e.trimEnd();if(!t.endsWith(">"))return null;let r=0,n=-1;for(let s=t.length-1;s>=0;s--){let o=t.charCodeAt(s);if(o===62){if(s>0&&t.charCodeAt(s-1)===61)continue;r++}else if(o===60){if(r--,r===0){n=s;break}}}if(n===-1)return null;let i=t.slice(0,n).trimEnd();if(!i)return null;return{name:i,typeParams:t.slice(n)}}function zs(e,t){let r=t.trimStart(),n=!1,i=!1;if(r.startsWith("async ")||r.startsWith("async\t"))n=!0,r=r.slice(5).trimStart();if(r.startsWith("*"))i=!0,r=r.slice(1).trimStart();let s="";if(r.charCodeAt(0)===60){let g=0,p=-1;for(let v=0;v<r.length;v++)if(r.charCodeAt(v)===60)g++;else if(r.charCodeAt(v)===62&&!(v>0&&r.charCodeAt(v-1)===61)){if(g--,g===0){p=v;break}}if(p!==-1)s=r.slice(0,p+1),r=r.slice(p+1).trimStart()}let o=r.indexOf("("),a=Qe(r,o,"(",")");if(o===-1||a===-1)return"() => unknown";let c=r.slice(o,a+1),f="unknown",u=r.slice(a+1).trimStart();if(u.charCodeAt(0)===58){let g=u.slice(1),p=Qs(g,0);if(p)f=g.slice(0,p.index).trim();else f=g.trim()}if(f==="unknown"){if(n&&i)f="AsyncGenerator<unknown, void, unknown>";else if(i)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=_t(c);return`${s}${l} => ${f}`}function Qs(e,t){let r=0,n=0,i=0,s=0,o=!1,a=0;for(let c=t;c<e.length;c++){let f=e.charCodeAt(c);if(o){if(f===92)c++;else if(f===a)o=!1;continue}if(f===34||f===39||f===96){o=!0,a=f;continue}if(f===40)r++;else if(f===41&&r>0)r--;else if(f===91)n++;else if(f===93&&n>0)n--;else if(f===60)i++;else if(f===62&&i>0&&e.charCodeAt(c-1)!==61)i--;else if(f===125&&s>0)s--;else if(f===123){let u=r>0||n>0||i>0||s>0,l=e.slice(t,c).trimEnd(),g=l.charCodeAt(l.length-1),p=l.length===0||g===38||g===124||g===40||g===44||g===58||g===61||g===91;if(u||p)s++;else return{index:c,kind:"body"}}else if(f===61&&c+1<e.length&&e.charCodeAt(c+1)===62&&r===0&&n===0&&i===0&&s===0)return{index:c,kind:"arrow"}}return null}function Qe(e,t,r,n){let i=0;for(let s=t;s<e.length;s++)if(e[s]===r)i++;else if(e[s]===n){if(n===">"&&s>0&&e[s-1]==="=")continue;if(i--,i===0)return s}return-1}function jr(e){let t=0,r=0,n=!1,i="";for(let s=0;s<e.length-1;s++){let o=e[s],a=e[s+1],c=s>0?e[s-1]:"";if(!n&&(o==='"'||o==="'"||o==="`"))n=!0,i=o;else if(n&&o===i&&c!=="\\")n=!1;if(!n){if(o==="<"){let f=Qe(e,s,"<",">");if(f!==-1){s=f;continue}}if(o==="(")t++;else if(o===")")t--;else if(o==="[")r++;else if(o==="]")r--;if(o==="="&&a===">"&&t===0&&r===0)return s}}return-1}function eo(e,t=!1,r=0,n=!0){let i=e.trim();if(i.length>200&&ln(i,"=>")>2&&ln(i,"<")>5&&!i.startsWith("function"))return t?"((...args: any[]) => any)":"(...args: any[]) => any";if(i.startsWith("async ")&&i.includes("=>")){let o=i.slice(5).trim(),a=jr(o);if(a===-1)return t?"(() => Promise<unknown>)":"() => Promise<unknown>";let c=o.substring(0,a).trim(),f=o.substring(a+2).trim(),u=Hs(c),{params:l,returnType:g}=u;if(l=_t(l),l==="()"||l==="")l="()";else if(!l.startsWith("("))l=`(${l})`;let p=g;if(p);else if(f.startsWith("{"))p=dr(f.slice(1,f.endsWith("}")?-1:void 0),!0,l);else p=Te(f,n,!1,r+1);let v=`${l} => ${g||p.startsWith("Promise<")?p:`Promise<${p}>`}`;return t?`(${v})`:v}if(i.includes("=>")){let o="",a=i;if(i.startsWith("<")){let w=Qe(i,0,"<",">");if(w!==-1)o=i.substring(0,w+1),a=i.substring(w+1).trim()}let c=jr(a);if(c===-1)return t?"(() => unknown)":"() => unknown";let f=a.substring(0,c).trim(),u=a.substring(c+2).trim(),l=Hs(f),{params:g,returnType:p}=l;if(g=_t(g),g==="()"||g==="")g="()";else if(!g.startsWith("("))g=`(${g})`;let v="unknown";if(p)v=p;else if(u.startsWith("{"))v=dr(u.slice(1,u.endsWith("}")?-1:void 0),!1,g);else if(Br(u)||qs(u)&&Br(u.slice(1,-1).trim()))v="JSX.Element";else if(u.includes("=>")){let w=u.trimStart(),T=w.indexOf("("),k=T!==-1?Qe(w,T,"(",")"):-1,R=k!==-1?w.indexOf("=>",k):-1;if(T===0&&k!==-1&&R!==-1){let I=w.substring(T+1,k).trim(),_=_t(I);if(o.includes("T")&&_.includes("T"))v=`(${_}) => T`;else v=`(${_}) => any`}else v="any"}else if(t)v="unknown";else v=Rt(u,Js(g));let b=`${o}${g} => ${v}`;return t?`(${b})`:b}if(i.startsWith("function")){let o=8,a=i.length;while(o<a&&i.charCodeAt(o)<=32)o++;let c=!1;if(o<a&&i.charCodeAt(o)===42){c=!0,o++;while(o<a&&i.charCodeAt(o)<=32)o++}let f="";if(o<a&&i.charCodeAt(o)===60){let g=o,p=1;o++;while(o<a&&p>0){let v=i.charCodeAt(o);if(v===60)p++;else if(v===62&&i.charCodeAt(o-1)!==61)p--;o++}f=i.substring(g,o);while(o<a&&i.charCodeAt(o)<=32)o++}let u=i.indexOf("(",o);if(u!==-1){let g=1,p=u+1;while(p<a&&g>0){let T=i.charCodeAt(p);if(T===40)g++;else if(T===41)g--;p++}let v=i.substring(u+1,p-1).trim(),b=v?`(${v})`:"()";if(c){let T=i.substring(p).trim(),k=T.indexOf("Generator<");if(k!==-1){let I=k+10,_=T.indexOf(">",I);if(_!==-1){let W=T.substring(I,_),P=`${f}${b} => Generator<${W}>`;return t?`(${P})`:P}}let R=`${f}${b} => Generator<any, any, any>`;return t?`(${R})`:R}let w=`${f}${b} => unknown`;return t?`(${w})`:w}let l="(...args: any[]) => unknown";return t?`(${l})`:l}if(i.includes("=>")&&i.includes("(")&&i.includes(")")){if(i.length>100||ln(i,"=>")>2){let o="";if(i.charCodeAt(0)===60){let l=Qe(i,0,"<",">");if(l!==-1)o=i.substring(0,l+1)}let a=i.indexOf("("),c=a!==-1?Qe(i,a,"(",")"):-1,f=a!==-1&&c!==-1?i.substring(a,c+1):"(...args: any[])";f=_t(f);let u=`${o}${f} => any`;return t?`(${u})`:u}return t?`(${i})`:i}let s="() => unknown";return t?`(${s})`:s}function Hs(e){let t=e.trim();if(!t.startsWith("("))return{params:t,returnType:""};let r=Qe(t,0,"(",")");if(r===-1)return{params:t,returnType:""};let n=t.slice(r+1).trim();return{params:t.slice(0,r+1),returnType:n.startsWith(":")?n.slice(1).trim():""}}function to(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 ro(e){let t=e.lastIndexOf(" satisfies ");if(t===-1)return null;let r=e.slice(t+11).trim();if(r.endsWith(";"))r=r.slice(0,-1).trim();return r||null}var _r=!1,Ve=null;var pn=()=>{};function Me(e){return e===Se||e===$e||e===oe||e===ye}function kt(e){return e>=65&&e<=90||e>=97&&e<=122||e===gf||e===so||e>127}function Ke(e){return kt(e)||e>=48&&e<=57}function yf(e){let t=!0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n===ft){if(t)return!1;t=!0}else if(t){if(!kt(n))return!1;t=!1}else if(!Ke(n))return!1}return e.length>0&&!t}function Kr(e,t,r){let n=t+1;while(n<e.length){let i=e.charCodeAt(n);if(i===Ue){n+=2;continue}if(n++,i===r)break}return n}function Cf(e){if(e==="any"||e==="object"||e==="unknown")return!0;if(e.startsWith("Record<")||e.startsWith("Array<"))return!0;return e.charCodeAt(0)===V&&e.includes("[")&&e.includes("]:")}function oo(e,t,r=!0){return lo(e,t,r,!0)}function ao(e,t,r=!0){return lo(e,t,r,!1)}function lo(e,t,r,n){let i=e,s=r,o=n,a=i.length,c=[],f=new Map,u=new Set,l=0;if(l<a&&i.charCodeAt(l)===65279)l++;function g(m,h){if(m<h){let d=i.charCodeAt(m),y=i.charCodeAt(h-1);if(d!==Se&&d!==$e&&d!==oe&&d!==ye&&y!==Se&&y!==$e&&y!==oe&&y!==ye)return i.slice(m,h)}while(m<h&&Me(i.charCodeAt(m)))m++;while(h>m&&Me(i.charCodeAt(h-1)))h--;return i.slice(m,h)}function p(){if(l>=a)return;let m=i.charCodeAt(l);if(m!==Se&&m!==$e&&m!==oe&&m!==ye&&m!==H)return;while(l<a){let h=i.charCodeAt(l);if(h===Se||h===$e||h===oe||h===ye){l++;continue}if(h===H&&l+1<a){let d=i.charCodeAt(l+1);if(d===H){let y=i.indexOf(`
43
+ `,l+2);l=y===-1?a:y+1;continue}if(d===ge){let y=i.indexOf("*/",l+2);l=y===-1?a:y+2;continue}}break}}function v(m){let h=m.length,d=0,y=h;for(let C=0;C<h;C++){let E=m.charCodeAt(C);if(d){if(E===Ue){C++;continue}if(E===d)d=0;continue}if(E===te||E===se||E===Ae){d=E;continue}if(E===H&&C+1<h){let x=m.charCodeAt(C+1);if(x===H){y=C;while(y>0&&(m.charCodeAt(y-1)===Se||m.charCodeAt(y-1)===$e))y--;return m.slice(0,y)}if(x===ge){let O=m.indexOf("*/",C+2);if(O!==-1){m=`${m.slice(0,C)} ${m.slice(O+2)}`,C--;continue}}}}y=h;while(y>0&&(m.charCodeAt(y-1)===Se||m.charCodeAt(y-1)===$e||m.charCodeAt(y-1)===ye))y--;return y<h?m.slice(0,y):m}function b(m){l++;let h=m===te?"'":'"';while(l<a){let d=i.indexOf(h,l);if(d===-1){l=a;return}let y=0,C=d-1;while(C>=0&&i.charCodeAt(C)===Ue)y++,C--;if(y%2===0){l=d+1;return}l=d+1}}function w(){l++;let m=[];while(l<a){let h=i.charCodeAt(l);if(m.length===0){if(h===Ue){l+=2;continue}if(h===Ae){l++;return}if(h===so&&l+1<a&&i.charCodeAt(l+1)===V){l+=2,m.push(0);continue}l++;continue}if(h===te||h===se){b(h);continue}if(h===Ae){w();continue}if(h===H&&l+1<a){let d=i.charCodeAt(l+1);if(d===H){let y=i.indexOf(`
44
+ `,l+2);l=y===-1?a:y+1;continue}if(d===ge){let y=i.indexOf("*/",l+2);l=y===-1?a:y+2;continue}if(I()){_();continue}l++;continue}if(h===V){m[m.length-1]++,l++;continue}if(h===J){let d=m[m.length-1];if(d===0){m.pop(),l++;continue}m[m.length-1]=d-1,l++;continue}l++}}function T(){let m=i.charCodeAt(l);if(m===te||m===se)return b(m),!0;if(m===Ae)return w(),!0;if(m===H&&l+1<a){let h=i.charCodeAt(l+1);if(h===H){let d=i.indexOf(`
45
+ `,l+2);return l=d===-1?a:d+1,!0}if(h===ge){let d=i.indexOf("*/",l+2);return l=d===-1?a:d+2,!0}if(I())return _(),!0}return!1}function k(m){let h=m;for(;;){while(h>=0&&(i.charCodeAt(h)===Se||i.charCodeAt(h)===$e||i.charCodeAt(h)===oe||i.charCodeAt(h)===ye))h--;if(h<0)return-1;if(i.charCodeAt(h)===H&&h>0&&i.charCodeAt(h-1)===ge){let C=i.lastIndexOf("/*",h-2);if(C===-1)return-1;h=C-1;continue}let d=i.lastIndexOf(`
46
+ `,h)+1,y=R(d,h);if(y!==-1){h=y-1;continue}return h}}function R(m,h){let d=0;for(let y=m;y<=h;y++){let C=i.charCodeAt(y);if(d){if(C===Ue){y++;continue}if(C===d)d=0;continue}if(C===te||C===se||C===Ae){d=C;continue}if(C===H&&y+1<=h&&i.charCodeAt(y+1)===H)return y}return-1}function I(){let m=k(l-1);if(m<0)return!0;let h=i.charCodeAt(m);if(h===Ce||h===Q||h===ue||h===33||h===38||h===124||h===Vr||h===et||h===tt||h===Y||h===V||h===J||h===94||h===126||h===43||h===45||h===ge||h===37||h===he||h===ne)return!0;if(Ke(h)){let d=m;while(d>=0&&Ke(i.charCodeAt(d)))d--;let y=i.slice(d+1,m+1);if(y==="return"||y==="typeof"||y==="void"||y==="delete"||y==="throw"||y==="new"||y==="in"||y==="of"||y==="case"||y==="instanceof"||y==="yield"||y==="await")return!0}return!1}function _(){l++;let m=!1;while(l<a){let h=i.charCodeAt(l);if(h===Ue){l+=2;continue}if(m){if(h===be)m=!1;l++;continue}if(h===ue){m=!0,l++;continue}if(h===H){l++;break}if(h===oe||h===ye)break;l++}while(l<a&&Ke(i.charCodeAt(l)))l++}function W(){let m=l;while(l<a&&Ke(i.charCodeAt(l)))l++;return i.slice(m,l)}function P(m){if(l+m.length>a)return!1;for(let h=0;h<m.length;h++)if(i.charCodeAt(l+h)!==m.charCodeAt(h))return!1;if(l+m.length<a&&Ke(i.charCodeAt(l+m.length)))return!1;return!0}function F(m){let h=l+m;while(h<a){let d=i.charCodeAt(h);if(d===Se||d===$e||d===oe||d===ye){h++;continue}return d!==ft&&d!==Ce}return!1}function U(){if(l>=a)return!1;switch(i.charCodeAt(l)){case 101:return P("export")||P("enum");case 105:return P("import")||P("interface");case 102:return P("function");case 99:return P("class")||P("const");case 116:return P("type");case 108:return P("let");case 118:return P("var");case 100:return P("declare")||P("default");case 109:return P("module");case 110:return P("namespace");case 97:return P("abstract")||P("async");default:return!1}}function q(){let m=i.charCodeAt(l);if(m!==oe&&m!==ye)return!1;let h=l;if(l++,m===ye&&l<a&&i.charCodeAt(l)===oe)l++;while(l<a){let y=i.charCodeAt(l);if(y===Se||y===$e||y===ye||y===oe){l++;continue}if(y===H&&l+1<a){let C=i.charCodeAt(l+1);if(C===H){let E=i.indexOf(`
47
+ `,l+2);l=E===-1?a:E+1;continue}if(C===ge){let E=i.indexOf("*/",l+2);l=E===-1?a:E+2;continue}}break}let d=l>=a||U()||i.charCodeAt(l)===J;return l=h,d}function le(m){let h=m-1;while(h>=0){let S=i.charCodeAt(h);if(S===Se||S===$e||S===ye||S===oe){h--;continue}break}if(h<0)return!0;let d=i[h];if("+-*/%=<>&|^!~?:,.([{".includes(d))return!0;let y=h;while(y>0&&i.charCodeAt(y-1)!==oe)y--;let C=i.slice(y,h+1),E=C.lastIndexOf("<");if(E!==-1&&/^<[A-Za-z]/.test(C.slice(E))&&!C.slice(E).includes(">"))return!0;let x=h;while(x>=0&&/[a-z]/i.test(i[x]))x--;let O=i.slice(x+1,h+1);return["as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","return","yield","void"].includes(O)}function z(){let m=i.charCodeAt(l);if(m!==oe&&m!==ye)return!1;if(le(l))return!1;let h=l;l++;while(l<a){let E=i.charCodeAt(l);if(E===Se||E===$e||E===ye||E===oe){l++;continue}if(E===H&&l+1<a){let x=i.charCodeAt(l+1);if(x===H){let O=i.indexOf(`
48
+ `,l+2);l=O===-1?a:O+1;continue}if(x===ge){let O=i.indexOf("*/",l+2);l=O===-1?a:O+2;continue}}break}let d=l<a?i[l]:"",y=i.slice(l,l+2),C=d==="."||d==="?"||d===":"||d===")"||d==="]"||d==="}"||d===","||d==="+"||d==="-"||d==="*"||d==="/"||d==="%"||d==="<"||d===">"||d==="="||d==="&"||d==="|"||d==="^"||d==="`"||y==="=>"||P("as")||P("satisfies")||P("instanceof")||P("in");return l=h,!C}function Z(){let m=i.charCodeAt(l);if(m!==oe&&m!==ye)return!1;if(le(l))return!1;let h=l;l++;while(l<a){let C=i.charCodeAt(l);if(C===Se||C===$e||C===ye||C===oe){l++;continue}if(C===H&&l+1<a){let E=i.charCodeAt(l+1);if(E===H){let x=i.indexOf(`
49
+ `,l+2);l=x===-1?a:x+1;continue}if(E===ge){let x=i.indexOf("*/",l+2);l=x===-1?a:x+2;continue}}break}let d=l<a?i[l]:"",y=d==="|"||d==="&"||d==="["||d==="."||d==="?"||d===":"||d===">"||d===")"||d===","||P("extends");return l=h,!y}function ie(){let m=i.charCodeAt(l);if(m!==oe&&m!==ye)return!1;let h=l;if(l++,m===ye&&l<a&&i.charCodeAt(l)===oe)l++;while(l<a){let y=i.charCodeAt(l);if(y===Se||y===$e||y===ye||y===oe){l++;continue}if(y===H&&l+1<a&&i.charCodeAt(l+1)===H){let C=i.indexOf(`
50
+ `,l+2);l=C===-1?a:C+1;continue}break}if(l>=a)return l=h,!0;let d=i.charCodeAt(l);if(d===124||d===38||d===ft||d===Vr||d===et)return l=h,!1;if(P("extends")||P("keyof")||P("typeof")||P("infer")||P("is")||P("as")||P("in"))return l=h,!1;return l=h,!0}let X=/[{}'"`\/]/g,Pe=/[()'"`\/]/g,Re=/[[\]'"`\/]/g,It=/[<>'"`\/]/g;function Oe(m,h){let d=1;l++;let y=m===V?X:m===Q?Pe:m===ue?Re:It;y.lastIndex=l;let C;while((C=y.exec(i))!==null){let E=C.index,x=i.charCodeAt(E);if(x===te||x===se){l=E,b(x),y.lastIndex=l;continue}if(x===Ae){l=E,w(),y.lastIndex=l;continue}if(x===H){if(l=E,T()){y.lastIndex=l;continue}y.lastIndex=E+1;continue}if(x===m)d++;else if(x===h){if(h===ne&&E>0&&i.charCodeAt(E-1)===Ce){y.lastIndex=E+1;continue}if(d--,d===0)return l=E+1,l}y.lastIndex=E+1}return l=a,l}function ke(){return l>0&&i.charCodeAt(l-1)===Ce}function ut(){return l+1<a&&i.charCodeAt(l+1)===ne}let ce=/[<{};'"`\/\n\r()[\]]/g;function ee(){let m=0,h=0,d=0,y=0,C=i.charCodeAt(l)===V;ce.lastIndex=l;let E;while((E=ce.exec(i))!==null){let x=E.index,O=i.charCodeAt(x);if(O===te||O===se){l=x,b(O),ce.lastIndex=l;continue}if(O===Ae){l=x,w(),ce.lastIndex=l;continue}if(O===H){if(x>0&&i.charCodeAt(x-1)===he){ce.lastIndex=x+1;continue}if(l=x,T()){ce.lastIndex=l;continue}ce.lastIndex=x+1;continue}if(O===he){let S=As(x);if(S!==null)y=Math.max(0,y+S);ce.lastIndex=x+1;continue}if(O===Q){h++,ce.lastIndex=x+1;continue}if(O===we){h--,ce.lastIndex=x+1;continue}if(O===ue){d++,ce.lastIndex=x+1;continue}if(O===be){d--,ce.lastIndex=x+1;continue}if(O===V){m++,ce.lastIndex=x+1;continue}if(O===J){let S=m>0;if(S)m--;if((!S||C)&&m===0&&h===0&&d===0&&y===0){l=x+1;return}ce.lastIndex=x+1;continue}if(O===Y&&m===0&&h===0&&d===0&&y===0){l=x+1;return}if((O===oe||O===ye)&&m===0&&h===0&&d===0&&y===0){if(l=x,q())return}ce.lastIndex=x+1}l=a}function Ft(){l++;while(l<a&&(i.charCodeAt(l)===Se||i.charCodeAt(l)===$e))l++;let m=i.indexOf(`
51
+ `,l),h=m===-1?a:m,d=i.indexOf(";",l);if(d!==-1&&d<h){let y=d-1;while(y>=l&&(i.charCodeAt(y)===Se||i.charCodeAt(y)===$e))y--;let C=i.charCodeAt(l),E=i.charCodeAt(y);if(C===V&&E===J||C===ue&&E===be||C===te&&E===te||C===se&&E===se||C===Ae&&E===Ae){l=d+1;return}}ee()}function sr(){Oe(V,J);while(l<a&&Me(i.charCodeAt(l)))l++;if(P("from")){l+=4;while(l<a&&Me(i.charCodeAt(l)))l++;if(l<a){let m=i.charCodeAt(l);if(m===te||m===se)b(m)}}while(l<a&&(i.charCodeAt(l)===Se||i.charCodeAt(l)===$e))l++;if(l<a&&i.charCodeAt(l)===Y)l++}function vs(){l++;while(l<a&&Me(i.charCodeAt(l)))l++;if(P("as")){l+=2;while(l<a&&Me(i.charCodeAt(l)))l++;W();while(l<a&&Me(i.charCodeAt(l)))l++}if(P("from")){l+=4;while(l<a&&Me(i.charCodeAt(l)))l++;if(l<a){let m=i.charCodeAt(l);if(m===te||m===se)b(m)}}while(l<a&&(i.charCodeAt(l)===Se||i.charCodeAt(l)===$e))l++;if(l<a&&i.charCodeAt(l)===Y)l++}function kr(m){let h=m.indexOf("from ");if(h===-1)return;let d=h+5;while(d<m.length&&(m.charCodeAt(d)===32||m.charCodeAt(d)===9))d++;if(d>=m.length)return;let y=m.charCodeAt(d);if(y!==39&&y!==34)return;let C=m.indexOf(m[d],d+1);if(C===-1)return;return m.slice(d+1,C)}function qe(m){if(!s)return;let h=m-1;while(h>=0&&Me(i.charCodeAt(h)))h--;if(h<0)return;let d=[],y=!1;while(h>=0){if(h>=1&&i.charCodeAt(h)===H&&i.charCodeAt(h-1)===ge){let x=i.lastIndexOf("/*",h-2);if(x>=0){d.push(i.slice(x,h+1)),y=!0,h=x-1;while(h>=0&&Me(i.charCodeAt(h)))h--;continue}break}let C=h;while(C>0&&i.charCodeAt(C-1)!==oe)C--;let E=g(C,h+1);if(E.startsWith("//")){if(y)break;let x=[E];h=C-1;while(h>=0&&(i.charCodeAt(h)===oe||i.charCodeAt(h)===ye))h--;while(h>=0){let O=h;while(O>0&&i.charCodeAt(O-1)!==oe)O--;let S=g(O,h+1);if(S.startsWith("//")){x.push(S),h=O-1;while(h>=0&&(i.charCodeAt(h)===oe||i.charCodeAt(h)===ye))h--}else if(S===""){h=O-1;while(h>=0&&(i.charCodeAt(h)===oe||i.charCodeAt(h)===ye))h--}else break}x.reverse(),d.push(x.join(`
52
+ `));continue}break}if(d.length===0)return;return d.reverse(),d}function oc(m){let h=m,d=!1;while(l<a){let S=i.charCodeAt(l);if(S===Y){l++;break}if(S===te||S===se){b(S),d=!0;while(l<a&&(i.charCodeAt(l)===Se||i.charCodeAt(l)===$e))l++;if(l<a&&i.charCodeAt(l)===Y)l++;break}if(S===oe&&d)break;l++}let y=g(h,l),C=y.charCodeAt(7)===116&&(y.startsWith("import type ")||y.startsWith("import type{")),E=!1;{let S=6;while(S<y.length&&(y.charCodeAt(S)===Se||y.charCodeAt(S)===$e))S++;if(S<y.length&&y.charCodeAt(S)===116&&y.startsWith("type",S)){S+=4;while(S<y.length&&(y.charCodeAt(S)===Se||y.charCodeAt(S)===$e))S++}if(S<y.length){let A=y.charCodeAt(S);E=A===te||A===se}}let x="";{let S=y.indexOf("from ");if(S!==-1){let A=S+5;while(A<y.length&&(y.charCodeAt(A)===Se||y.charCodeAt(A)===$e))A++;if(A<y.length){let M=y.charCodeAt(A);if(M===te||M===se){let N=y.indexOf(String.fromCharCode(M),A+1);if(N!==-1)x=y.slice(A+1,N)}}}else if(E){let A=6;while(A<y.length&&y.charCodeAt(A)!==te&&y.charCodeAt(A)!==se)A++;if(A<y.length){let M=y.charCodeAt(A),N=y.indexOf(String.fromCharCode(M),A+1);if(N!==-1)x=y.slice(A+1,N)}}}let O=qe(h);return{kind:"import",name:"",text:y,isExported:!1,isTypeOnly:C,isSideEffect:E,source:x,leadingComments:O,start:h,end:l}}function ji(){let m=l;return Oe(V,J),i.slice(m,l)}function Es(m){let h=m.indexOf("(");if(h===-1)return m;let d=m.slice(h);if(d.indexOf("=")===-1)return m;let y=!1;for(let S=0;S<d.length;S++)if(d.charCodeAt(S)===61){let A=S>0?d.charCodeAt(S-1):0,M=S+1<d.length?d.charCodeAt(S+1):0;if(A!==61&&A!==33&&A!==60&&A!==62&&M!==61&&M!==62){y=!0;break}}if(!y)return m;let C=0,E=-1;for(let S=h;S<m.length;S++){let A=m.charCodeAt(S);if(A===40)C++;else if(A===41){if(C--,C===0){E=S;break}}}if(E===-1)return m;let x=m.slice(h,E+1),O=Nt(x);return m.slice(0,h)+O+m.slice(E+1)}function bs(m){let h=m.indexOf("//")!==-1||m.indexOf("/*")!==-1,d=m.split(`
53
+ `),y=[],C=[],E=[],x=!1,O=1/0;for(let M=0;M<d.length;M++){let N=d[M];if(h){if(x){if(N.includes("*/"))x=!1;continue}let G=N.trim();if(G.length===0)continue;let L=G.charCodeAt(0);if(L===H){let je=G.charCodeAt(1);if(je===H)continue;if(je===ge){if(!G.includes("*/"))x=!0;continue}}if(L===ge)continue;let D=v(N);if(D.charCodeAt(D.length-1)===Y)D=D.slice(0,-1);D=Es(D);let B=D.trim();if(!B)continue;y.push(D),C.push(B);let j=0;while(j<D.length&&Me(D.charCodeAt(j)))j++;if(B!=="{"&&B!=="}"){if(j<O)O=j}E.push(j)}else{let G=N.length;while(G>0&&(N.charCodeAt(G-1)===Se||N.charCodeAt(G-1)===$e||N.charCodeAt(G-1)===ye))G--;if(G===0)continue;let L=G<N.length?N.slice(0,G):N;if(L.charCodeAt(L.length-1)===Y)L=L.slice(0,-1);L=Es(L);let D=L.trim();if(!D)continue;y.push(L),C.push(D);let B=0;while(B<L.length&&Me(L.charCodeAt(B)))B++;if(D!=="{"&&D!=="}"){if(B<O)O=B}E.push(B)}}if(y.length===0)return"{}";if(O===1/0||O<=2)return y.join(`
54
+ `);let S=O-2,A=Array(y.length);for(let M=0;M<y.length;M++){let N=C[M];if(N==="{"){A[M]=N;continue}let G=E[M];if(G>O)A[M]=y[M];else if(G===O&&(N.charCodeAt(0)===J||N.charCodeAt(0)===be||N.charCodeAt(0)===we))A[M]=y[M];else{let L=Math.max(0,G-S);A[M]=" ".repeat(L)+N}}return A.join(`
55
+ `)}function lt(){if(l>=a||i.charCodeAt(l)!==he)return"";let m=l;Oe(he,ne);let h=i.slice(m,l);if(h.includes(`
56
+ `)){let d="",y=!1;for(let C=0;C<h.length;C++){let E=h.charCodeAt(C);if(E===32||E===9||E===10||E===13){if(!y&&d.length>0)d+=" ",y=!0}else d+=h[C],y=!1}if(d.charCodeAt(1)===32)d=`<${d.slice(2)}`;if(d.charCodeAt(d.length-2)===32)d=`${d.slice(0,-2)}>`;return d}return h}function bt(){if(l>=a||i.charCodeAt(l)!==Q)return"()";let m=l;return Oe(Q,we),i.slice(m,l)}function Mr(m){if(m.indexOf("/")===-1)return m;let h="",d=!1,y=0;for(let C=0;C<m.length;C++){let E=m.charCodeAt(C);if(d){if(h+=m[C],E===Ue&&C+1<m.length){h+=m[++C];continue}if(E===y)d=!1;continue}if(E===te||E===se||E===Ae){d=!0,y=E,h+=m[C];continue}if(E===H&&C+1<m.length){let x=m.charCodeAt(C+1);if(x===ge){let O=m.indexOf("*/",C+2);C=O===-1?m.length:O+1,h+=" ";continue}if(x===H){let O=m.indexOf(`
57
+ `,C+2);C=O===-1?m.length:O-1;continue}}h+=m[C]}return h.trim()}function Nt(m){let h=m.slice(1,-1).trim();if(!h)return"()";if(m.indexOf(`
58
+ `)===-1&&h.indexOf(":")!==-1&&h.indexOf("{")===-1&&h.indexOf("[")===-1&&h.indexOf("=")===-1&&h.indexOf("@")===-1&&h.indexOf("...")===-1){let S=0,A=0,M=0;for(let N=0;N<h.length;N++){let G=h.charCodeAt(N);if(G===Q||G===he||G===V)M++;else if(G===we||G===ne||G===J)M--;else if(M===0){if(G===et)S++;else if(G===tt)A++}}if(S>=A+1){let N=!1;for(let G=0;G<gn.length;G++){let L=gn[G],D=h.indexOf(L);if(D!==-1){let B=D+L.length;if((D===0||!Ke(h.charCodeAt(D-1)))&&(B>=h.length||!Ke(h.charCodeAt(B)))){N=!0;break}}}if(!N)return m}}let d=[],y=0,C=0,E=!1,x=0;for(let S=0;S<=h.length;S++){if(S===h.length){d.push(Mr(h.slice(y).trim()));break}let A=h.charCodeAt(S);if(E){if(A===Ue){S++;continue}if(A===x)E=!1;continue}if(A===H&&S+1<h.length){let M=h.charCodeAt(S+1);if(M===ge){S+=2;while(S+1<h.length&&!(h.charCodeAt(S)===ge&&h.charCodeAt(S+1)===H))S++;S++;continue}if(M===H){while(S<h.length&&h.charCodeAt(S)!==10)S++;continue}}if(A===te||A===se||A===Ae){E=!0,x=A;continue}if(A===Q||A===V||A===ue||A===he)C++;else if(A===we||A===J||A===be||A===ne&&!(S>0&&h.charCodeAt(S-1)===Ce))C--;else if(A===tt&&C===0)d.push(Mr(h.slice(y,S).trim())),y=S+1}let O=[];for(let S of d){if(!S)continue;let A=S.trim();if(A.startsWith("//")||A.startsWith("/*"))continue;let M=S;{let N=!1,G=0,L=0,D=0;for(let B=0;B<M.length-1;B++){let j=M.charCodeAt(B);if(j===oe){D=B+1;continue}if(N){if(j===Ue){B++;continue}if(j===G)N=!1;continue}if(j===te||j===se||j===Ae){N=!0,G=j;continue}if(j===V||j===ue||j===Q||j===he){L++;continue}if(j===J||j===be||j===we||j===ne){if(L>0)L--;continue}if(j===H&&M.charCodeAt(B+1)===H){if(L===0){M=M.slice(0,B).trimEnd();break}let je=M.indexOf(`
59
+ `,B);if(je===-1){M=M.slice(0,D).trimEnd();break}let _e=M.slice(0,D),Gt=M.slice(je+1);M=`${_e}${Gt}`,B=D-1}}}if(!M.trim())continue;O.push(Ss(M))}return`(${O.join(", ")})`}function ac(m){if(!m.startsWith("{")&&!m.startsWith("["))return m;let h="",d=0,y=0,C=!1,E=0;while(d<m.length){let x=m.charCodeAt(d);if(C){if(x===Ue&&d+1<m.length){h+=m[d]+m[d+1],d+=2;continue}if(x===E)C=!1;h+=m[d],d++;continue}if(x===H&&d+1<m.length){let O=m.charCodeAt(d+1);if(O===ge){let S=d;d+=2;while(d+1<m.length&&!(m.charCodeAt(d)===ge&&m.charCodeAt(d+1)===H))d++;d=Math.min(d+2,m.length),h+=m.slice(S,d);continue}if(O===H){let S=d;while(d<m.length&&m.charCodeAt(d)!==10)d++;h+=m.slice(S,d);continue}}if(x===te||x===se||x===Ae){C=!0,E=x,h+=m[d],d++;continue}if(x===V||x===ue||x===Q)y++;else if(x===J||x===be||x===we)y--;if(y>=1&&x===Ce&&(d+1>=m.length||m.charCodeAt(d+1)!==Ce&&m.charCodeAt(d+1)!==ne)){while(h.length>0&&(h[h.length-1]===" "||h[h.length-1]==="\t"||h[h.length-1]===`
60
+ `))h=h.slice(0,-1);d++;let O=0;while(d<m.length){let S=m.charCodeAt(d);if(S===te||S===se||S===Ae){let A=S;d++;while(d<m.length){if(m.charCodeAt(d)===Ue){d+=2;continue}if(m.charCodeAt(d)===A){d++;break}d++}continue}if(S===V||S===ue||S===Q)O++;else if(S===J||S===be||S===we){if(O===0)break;O--}else if(S===tt&&O===0)break;d++}continue}if(y===1&&x===ft&&d+2<m.length&&m.charCodeAt(d+1)===ft&&m.charCodeAt(d+2)===ft){d+=3;continue}h+=m[d],d++}return h}function Ss(m){let h=m.trim(),d=h.startsWith("...");if(d)h=h.slice(3).trim();while(h.startsWith("@")){let D=1;while(D<h.length&&Ke(h.charCodeAt(D)))D++;if(D<h.length&&h.charCodeAt(D)===Q){let B=1;D++;while(D<h.length&&B>0){if(h.charCodeAt(D)===Q)B++;else if(h.charCodeAt(D)===we)B--;D++}}h=h.slice(D).trim()}let y=!0;while(y){y=!1;for(let D of gn)if(h.startsWith(D)&&h.length>D.length&&!Ke(h.charCodeAt(D.length))){let B=h.slice(D.length).trim();if(B.charCodeAt(0)===et||B.charCodeAt(0)===Vr&&B.length>1&&B.charCodeAt(1)===et)break;h=B,y=!0;break}}let C=-1,E=-1,x=0,O=!1,S=0;for(let D=0;D<h.length;D++){let B=h.charCodeAt(D);if(O){if(B===Ue){D++;continue}if(B===S)O=!1;continue}if(B===H&&D+1<h.length){let j=h.charCodeAt(D+1);if(j===ge){D+=2;while(D+1<h.length&&!(h.charCodeAt(D)===ge&&h.charCodeAt(D+1)===H))D++;D++;continue}if(j===H){while(D<h.length&&h.charCodeAt(D)!==10)D++;continue}}if(B===te||B===se||B===Ae){O=!0,S=B;continue}if(B===Q||B===V||B===ue||B===he)x++;else if(B===we||B===J||B===be||B===ne&&!(D>0&&h.charCodeAt(D-1)===Ce))x--;else if(x===0){if(B===et&&C===-1)C=D;else if(B===Ce&&E===-1&&(D===0||h.charCodeAt(D-1)!==Ce)&&(D+1>=h.length||h.charCodeAt(D+1)!==Ce&&h.charCodeAt(D+1)!==ne))E=D}}let A,M,N=E!==-1;if(C!==-1&&(E===-1||C<E))if(A=h.slice(0,C).trim(),E!==-1)M=h.slice(C+1,E).trim();else M=h.slice(C+1).trim();else if(E!==-1)A=h.slice(0,E).trim(),M=_i(h.slice(E+1).trim());else A=h,M="unknown";if(A=ac(A),(A.startsWith("{")||A.startsWith("["))&&A.includes(`
60
61
  `)){let D=A.replace(/\s*\n\s*/g," ").replace(/\s+/g," ");if(D.length<=40)A=D;else A=A.split(`
61
- `).map((W)=>{let j=W.trim();if(!j)return"";if(j==="{"||j==="}"||j==="["||j==="]"||j.startsWith("}")||j.startsWith("]"))return j;return` ${j}`}).join(`
62
- `)}let G=A.endsWith("?")||N;if(A.endsWith("?"))A=A.slice(0,-1).trim();let B=G&&!m?"?":"";if(m)return`...${A}: ${M}`;return`${A}${B}: ${M}`}function bs(p){let h=0;if(h<p.length&&p.charCodeAt(h)===45)h++;if(h>=p.length)return!1;let m=p.charCodeAt(h);if(m<48||m>57)return!1;while(h<p.length&&p.charCodeAt(h)>=48&&p.charCodeAt(h)<=57)h++;if(h<p.length&&p.charCodeAt(h)===46){if(h++,h>=p.length||p.charCodeAt(h)<48||p.charCodeAt(h)>57)return!1;while(h<p.length&&p.charCodeAt(h)>=48&&p.charCodeAt(h)<=57)h++}return h===p.length}function Gi(p){let h=p.trim();if(h==="true"||h==="false")return"boolean";if(bs(h))return"number";if(h.startsWith("'")&&h.endsWith("'")||h.startsWith('"')&&h.endsWith('"'))return"string";if(h.startsWith("["))return"unknown[]";if(h.startsWith("{"))return"Record<string, unknown>";return"unknown"}function ji(p){let h=p.trim();if(h.endsWith("as const"))h=h.slice(0,-8).trim();if(h==="true"||h==="false")return h;if(bs(h))return h;let m=oc(h);if(m!==null)return m;return"unknown"}function oc(p){if(p==="")return null;if(p.charCodeAt(0)===ie||p.charCodeAt(0)===le){if(Vr(p,0,p.charCodeAt(0))===p.length)return p}let h=ac(p,"+");if(h.length>1){let m=!1,y=!0,w=[];for(let E of h){let x=E.trim(),O=x.charCodeAt(0);if((O===ie||O===le)&&Vr(x,0,O)===x.length)m=!0,w.push(lc(x));else y=!1}if(y)return cc(w.join(""));if(m)return"string";return null}if(/^[\d\s()+*/%.\-]+$/.test(p)&&/\d/.test(p)&&/[+*/%\-\s]/.test(p))return"number";return null}function ac(p,h){let m=[],y=0,w="",E=0;while(E<p.length){let x=p.charCodeAt(E);if(x===ie||x===le||x===Pe){let O=Vr(p,E,x);w+=p.slice(E,O),E=O;continue}if(x===z&&(p.charCodeAt(E+1)===z||p.charCodeAt(E+1)===42)){if(p.charCodeAt(E+1)===z){let A=p.indexOf(`
63
- `,E+2),M=A===-1?p.length:A;w+=p.slice(E,M),E=M;continue}let O=p.indexOf("*/",E+2),S=O===-1?p.length:O+2;w+=p.slice(E,S),E=S;continue}if(x===ee||x===pe||x===V)y++;else if(x===we||x===$e||x===J)y--;if(p[E]===h&&y===0){m.push(w),w="",E++;continue}w+=p[E],E++}return m.push(w),m}function lc(p){return p.slice(1,-1).replace(/\\(.)/g,(h,m)=>{if(m==="n")return`
64
- `;if(m==="t")return"\t";if(m==="r")return"\r";if(m==="0")return"\x00";return m})}function cc(p){return`'${p.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function kr(p){if(p.endsWith("as const"))return null;let h=0,m=-1;for(let y=0;y<p.length;y++){let w=p.charCodeAt(y);if(w===ie||w===le||w===Pe)y=Vr(p,y,w)-1;else if(w===123||w===91||w===40)h++;else if(w===125||w===93||w===41)h--;else if(h===0&&w===32&&y+4<=p.length&&p.substring(y,y+4)===" as ")m=y}if(m===-1)return null;return p.slice(m+4).trim()||null}function sr(){if(d(),l<a&&i.charCodeAt(l)===Qe){l++,d();let p=l,h=0;while(l<a){if(T())continue;let m=i.charCodeAt(l);if(m===ee||m===pe||m===ge)h++;else if(m===we||m===$e||m===fe&&!Me())h--;else if(m===V)if(h>0)h++;else{let y=g(p,l),w=(E)=>{let x=y.length-E.length;return x>=0&&y.endsWith(E)&&(x===0||!Ve(y.charCodeAt(x-1)))};if(y.length===0||y.endsWith("|")||y.endsWith("&")||w("is")||w("extends"))h++;else break}else if(m===J){if(h===0)break;h--}else if(h===0&&m===Y)break;if(h===0&&re())break;l++}return g(p,l)}return""}function bt(p,h,m,y){l+=8,d();let w=l<a&&i.charCodeAt(l)===ve;if(w)l++,d();let E=L();if(!E&&!y)return null;d();let x=at();d();let O=Et();d();let S=sr(),A=S.length>0;if(!S)if(m&&w)S="AsyncGenerator<unknown, void, unknown>";else if(w)S="Generator<unknown, void, unknown>";else if(m)S="Promise<void>";else S="void";d();let M=!1;if(l<a&&i.charCodeAt(l)===V){M=!0;let D=l+1;if(ke(V,J),!o&&!A&&!w)S=hr(i.slice(D,l-1),m,O)}else if(l<a&&i.charCodeAt(l)===Y)l++;let N=Ft(O),G=`${h?y?"export default function ":"export declare function ":"declare function "}${E||(y?"":"default")}${x}${N}: ${S};`,B=Je(p);if(M)u.add(c.length);return{kind:"function",name:E||"default",text:G,isExported:h,isDefault:y,isAsync:m,isGenerator:w,returnType:S,generics:x||void 0,leadingComments:B,start:p,end:l}}function Nt(p,h,m){l+=h.length,d();let y=[];do{if(d(),l>=a)break;let w=i.charCodeAt(l);if(w===V||w===pe)return Q(),y;let E=L();if(!E)return Q(),y;d();let x,O,S=!1;if(l<a&&i.charCodeAt(l)===Qe){l++,d();let N=l,G=0;while(l<a){if(T())continue;let B=i.charCodeAt(l);if(B===ee||B===V||B===pe||B===ge)G++;else if(B===we||B===J||B===$e||B===fe&&!Me())G--;else if(G===0&&(B===Y||B===et))break;else if(G===0&&B===be&&!ft())break;if(G===0&&(q()||Z()))break;l++}x=g(N,l)}if(l<a&&i.charCodeAt(l)===be)if(o&&x&&(!s||!gf(x)))It();else{l++,d();let N=l,G=0,B=0,D=0,W=!0;for(;;){l=N,G=0,B=0,D=0;while(l<a){if(T())continue;let j=i.charCodeAt(l);if(j===ee||j===V||j===pe)G++;else if(j===we||j===J||j===$e)G--;else if(j===ge&&G===0){let me=Ss(l);if(me!==null)D=Math.max(0,D+me);else if(W&&(l+1>=a||i.charCodeAt(l+1)!==be))B++}else if(j===fe&&G===0&&D===0&&!Me()){if(B>0&&(l+1>=a||i.charCodeAt(l+1)!==be))B--}else if(G===0&&B===0&&D===0&&(j===Y||j===et))break;if(G===0&&B===0&&D===0&&(q()||H()))break;l++}if(B>0&&W){W=!1;continue}break}if(O=g(N,l),O.endsWith(" as const")||O==="const"){if(S=!0,!x){let j=O.endsWith(" as const")?O.slice(0,-9).trim():O,me=ji(j);x=me!=="unknown"?me:void 0}}else if(!x){let j=kr(O);if(j)x=j}}if(l<a){let N=i.charCodeAt(l);if(N===et){l++;continue}if(N===Y)l++}let A=Je(p),M=`${m?"export ":""}declare ${h} ${E}: ${x||"unknown"};`;y.push({kind:"variable",name:E,text:M,isExported:m,typeAnnotation:x,value:O,modifiers:S?[h,"const assertion"]:[h],leadingComments:A,start:p,end:l});break}while(l<a);return y}function Ss(p){if(i.charCodeAt(p)!==ge||p+1>=a)return null;let h=i.charCodeAt(p+1);if(h===fe)return 1;if(h===z)return-1;if(!Ot(h))return null;let m=p+2;while(m<a){let A=i.charCodeAt(m);if(!Ve(A)&&A!==ct&&A!==58&&A!==45)break;m++}let y=i.slice(p+1,m),w=i.charCodeAt(m);if(w>32&&w!==fe&&w!==z)return null;let E=0,x=0,O=m;for(;O<a;O++){let A=i.charCodeAt(O);if(x!==0){if(A===He)O++;else if(A===x)x=0;continue}if(A===ie||A===le||A===Pe)x=A;else if(A===V)E++;else if(A===J&&E>0)E--;else if(A===fe&&E===0)break}if(O>=a)return null;let S=O-1;while(S>p&&i.charCodeAt(S)<=32)S--;if(i.charCodeAt(S)===z)return 0;return i.indexOf(`</${y}`,O+1)===-1?null:1}function _i(p,h){l+=9,d();let m=L();d();let y=at();d();let w="";if(P("extends")){l+=7,d();let A=l,M=0;while(l<a){if(T())continue;let N=i.charCodeAt(l);if(N===ge)M++;else if(N===fe&&!Me())M--;else if(N===V&&M===0)break;l++}w=g(A,l)}d();let E=l<a&&i.charCodeAt(l)===V?Bi():"{}",x=vs(E),O=`${h?"export ":""}declare interface ${m}${y}${w?` extends ${w}`:""} ${x}`,S=Je(p);return{kind:"interface",name:m,text:O,isExported:h,extends:w||void 0,generics:y||void 0,leadingComments:S,start:p,end:l}}function Vi(p,h){l+=4,d();let m=L();d();let y=at();if(d(),l<a&&i.charCodeAt(l)===be)l++;d();let w=l,E=0;while(l<a){if(T())continue;let A=i.charCodeAt(l);if(A===ee||A===V||A===pe||A===ge)E++;else if(A===we||A===J||A===$e||A===fe&&!Me())E--;else if(E===0&&A===Y)break;if(E===0&&(q()||Z()))break;l++}let x=g(w,l);if(l<a&&i.charCodeAt(l)===Y)l++;let O=`${h?"export ":""}type ${m}${y} = ${x}`,S=Je(p);return{kind:"type",name:m,text:O,isExported:h,generics:y||void 0,leadingComments:S,start:p,end:l}}function Lt(p,h,m){l+=4,d();let y=L();d();let w=l;if(l<a&&i.charCodeAt(l)===V)ke(V,J);let E=g(p,l),x=Je(p);return{kind:"enum",name:y,text:E,isExported:h,modifiers:m?["const"]:void 0,leadingComments:x,start:p,end:l}}function St(p,h,m,y=!1){l+=5,d();let w=L()||"AnonymousClass";d();let E=at();d();let x="";if(P("extends")){l+=7,d();let N=l,G=0;while(l<a){if(T())continue;let B=i.charCodeAt(l);if(B===ge)G++;else if(B===fe&&!Me())G--;else if(G===0&&(B===V||P("implements")))break;l++}x=g(N,l)}let O;if(P("implements")){l+=10,d();let N=l,G=0;while(l<a){if(T())continue;let D=i.charCodeAt(l);if(D===ge)G++;else if(D===fe&&!Me())G--;else if(G===0&&D===V)break;l++}let B=g(N,l);if(B)O=B.split(",").map((D)=>D.trim())}d();let S=Ui(),A=`${h?y?"export default ":"export declare ":"declare "}${m?"abstract ":""}class ${w}${E}${x?` extends ${x}`:""}${O&&O.length>0?` implements ${O.join(", ")}`:""} ${S}`,M=Je(p);return{kind:"class",name:w,text:A,isExported:h,isDefault:y,extends:x||void 0,implements:O,generics:E||void 0,modifiers:m?["abstract"]:void 0,leadingComments:M,start:p,end:l}}function Ui(){if(l>=a||i.charCodeAt(l)!==V)return"{}";l++;let p=[];while(l<a){if(d(),l>=a)break;if(i.charCodeAt(l)===J){l++;break}if(i.charCodeAt(l)===Y){l++;continue}if(P("static")&&As("static")===V){l+=6,d(),ke(V,J);continue}let h=!1,m=!1,y=!1,w=!1,E=!1,x=!1,O=!1,S=!1,A=!0;while(A){if(d(),P("private")){h=!0,l+=7;continue}if(P("protected")){m=!0,l+=9;continue}if(P("public")){l+=6;continue}if(P("static")){y=!0,l+=6;continue}if(P("abstract")){w=!0,l+=8;continue}if(P("readonly")){E=!0,l+=8;continue}if(P("override")){x=!0,l+=8;continue}if(P("accessor")){O=!0,l+=8;continue}if(P("async")){S=!0,l+=5;continue}if(P("declare")){l+=7;continue}break}if(d(),l>=a||i.charCodeAt(l)===J)break;if(i.charCodeAt(l)===_r)h=!0;if(h){Hi();continue}let M=" ";if(m)M+="protected ";if(y)M+="static ";if(w)M+="abstract ";if(E)M+="readonly ";if(P("constructor")){l+=11,d();let N=Et();if(d(),fc(N,p),l<a&&i.charCodeAt(l)===V)ke(V,J);else if(l<a&&i.charCodeAt(l)===Y)l++;let G=Ft(N);p.push(` constructor${G};`)}else if(P("get"))if(l+=3,d(),l<a&&(Ot(i.charCodeAt(l))||i.charCodeAt(l)===pe||i.charCodeAt(l)===_r)){let N=Ki();if(N.startsWith("#")){if(d(),l<a&&i.charCodeAt(l)===ee)Et();if(d(),sr(),d(),l<a&&i.charCodeAt(l)===V)ke(V,J);else if(l<a&&i.charCodeAt(l)===Y)l++;continue}d(),Et(),d();let G=sr()||"unknown";if(d(),l<a&&i.charCodeAt(l)===V)ke(V,J);else if(l<a&&i.charCodeAt(l)===Y)l++;p.push(`${M}get ${N}(): ${G};`)}else $s("get",M,y,E,S,p);else if(P("set"))if(l+=3,d(),l<a&&(Ot(i.charCodeAt(l))||i.charCodeAt(l)===pe||i.charCodeAt(l)===_r)){let N=Ki();if(N.startsWith("#")){if(d(),l<a&&i.charCodeAt(l)===ee)Et();if(d(),l<a&&i.charCodeAt(l)===V)ke(V,J);else if(l<a&&i.charCodeAt(l)===Y)l++;continue}d();let G=Et();if(d(),l<a&&i.charCodeAt(l)===V)ke(V,J);else if(l<a&&i.charCodeAt(l)===Y)l++;let B=Ft(G);p.push(`${M}set ${N}${B};`)}else $s("set",M,y,E,S,p);else{let N=i.charCodeAt(l)===ve;if(N)l++,d();let G=Ki();if(!G){Hi();continue}xs(G,M,y,E,N,w,S,p)}}return`{
65
- ${p.join(`
62
+ `).map((B)=>{let j=B.trim();if(!j)return"";if(j==="{"||j==="}"||j==="["||j==="]"||j.startsWith("}")||j.startsWith("]"))return j;return` ${j}`}).join(`
63
+ `)}let G=A.endsWith("?")||N;if(A.endsWith("?"))A=A.slice(0,-1).trim();let L=G&&!d?"?":"";if(d)return`...${A}: ${M}`;return`${A}${L}: ${M}`}function $s(m){let h=0;if(h<m.length&&m.charCodeAt(h)===45)h++;if(h>=m.length)return!1;let d=m.charCodeAt(h);if(d<48||d>57)return!1;while(h<m.length&&m.charCodeAt(h)>=48&&m.charCodeAt(h)<=57)h++;if(h<m.length&&m.charCodeAt(h)===46){if(h++,h>=m.length||m.charCodeAt(h)<48||m.charCodeAt(h)>57)return!1;while(h<m.length&&m.charCodeAt(h)>=48&&m.charCodeAt(h)<=57)h++}return h===m.length}function _i(m){let h=m.trim();if(h==="true"||h==="false")return"boolean";if($s(h))return"number";if(h.startsWith("'")&&h.endsWith("'")||h.startsWith('"')&&h.endsWith('"'))return"string";if(h.startsWith("["))return"unknown[]";if(h.startsWith("{"))return"Record<string, unknown>";return"unknown"}function Vi(m){let h=m.trim();if(h.endsWith("as const"))h=h.slice(0,-8).trim();if(h==="true"||h==="false")return h;if($s(h))return h;let d=lc(h);if(d!==null)return d;return"unknown"}function lc(m){if(m==="")return null;if(m.charCodeAt(0)===te||m.charCodeAt(0)===se){if(Kr(m,0,m.charCodeAt(0))===m.length)return m}let h=cc(m,"+");if(h.length>1){let d=!1,y=!0,C=[];for(let E of h){let x=E.trim(),O=x.charCodeAt(0);if((O===te||O===se)&&Kr(x,0,O)===x.length)d=!0,C.push(fc(x));else y=!1}if(y)return uc(C.join(""));if(d)return"string";return null}if(/^[\d\s()+*/%.\-]+$/.test(m)&&/\d/.test(m)&&/[+*/%\-\s]/.test(m))return"number";return null}function cc(m,h){let d=[],y=0,C="",E=0;while(E<m.length){let x=m.charCodeAt(E);if(x===te||x===se||x===Ae){let O=Kr(m,E,x);C+=m.slice(E,O),E=O;continue}if(x===H&&(m.charCodeAt(E+1)===H||m.charCodeAt(E+1)===42)){if(m.charCodeAt(E+1)===H){let A=m.indexOf(`
64
+ `,E+2),M=A===-1?m.length:A;C+=m.slice(E,M),E=M;continue}let O=m.indexOf("*/",E+2),S=O===-1?m.length:O+2;C+=m.slice(E,S),E=S;continue}if(x===Q||x===ue||x===V)y++;else if(x===we||x===be||x===J)y--;if(m[E]===h&&y===0){d.push(C),C="",E++;continue}C+=m[E],E++}return d.push(C),d}function fc(m){return m.slice(1,-1).replace(/\\(.)/g,(h,d)=>{if(d==="n")return`
65
+ `;if(d==="t")return"\t";if(d==="r")return"\r";if(d==="0")return"\x00";return d})}function uc(m){return`'${m.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function Dr(m){if(m.endsWith("as const"))return null;let h=0,d=-1;for(let y=0;y<m.length;y++){let C=m.charCodeAt(y);if(C===te||C===se||C===Ae)y=Kr(m,y,C)-1;else if(C===123||C===91||C===40)h++;else if(C===125||C===93||C===41)h--;else if(h===0&&C===32&&y+4<=m.length&&m.substring(y,y+4)===" as ")d=y}if(d===-1)return null;return m.slice(d+4).trim()||null}function or(){if(p(),l<a&&i.charCodeAt(l)===et){l++,p();let m=l,h=0;while(l<a){if(T())continue;let d=i.charCodeAt(l);if(d===Q||d===ue||d===he)h++;else if(d===we||d===be||d===ne&&!ke())h--;else if(d===V)if(h>0)h++;else{let y=g(m,l),C=(E)=>{let x=y.length-E.length;return x>=0&&y.endsWith(E)&&(x===0||!Ke(y.charCodeAt(x-1)))};if(y.length===0||y.endsWith("|")||y.endsWith("&")||C("is")||C("extends"))h++;else break}else if(d===J){if(h===0)break;h--}else if(h===0&&d===Y)break;if(h===0&&ie())break;l++}return g(m,l)}return""}function St(m,h,d,y){l+=8,p();let C=l<a&&i.charCodeAt(l)===ge;if(C)l++,p();let E=W();if(!E&&!y)return null;p();let x=lt();p();let O=bt();p();let S=or(),A=S.length>0;if(!S)if(d&&C)S="AsyncGenerator<unknown, void, unknown>";else if(C)S="Generator<unknown, void, unknown>";else if(d)S="Promise<void>";else S="void";p();let M=!1;if(l<a&&i.charCodeAt(l)===V){M=!0;let D=l+1;if(Oe(V,J),!o&&!A&&!C)S=dr(i.slice(D,l-1),d,O)}else if(l<a&&i.charCodeAt(l)===Y)l++;let N=Nt(O),G=`${h?y?"export default function ":"export declare function ":"declare function "}${E||(y?"":"default")}${x}${N}: ${S};`,L=qe(m);if(M)u.add(c.length);return{kind:"function",name:E||"default",text:G,isExported:h,isDefault:y,isAsync:d,isGenerator:C,returnType:S,generics:x||void 0,leadingComments:L,start:m,end:l}}function Lt(m,h,d){l+=h.length,p();let y=[];do{if(p(),l>=a)break;let C=i.charCodeAt(l);if(C===V||C===ue)return ee(),y;let E=W();if(!E)return ee(),y;p();let x,O,S=!1;if(l<a&&i.charCodeAt(l)===et){l++,p();let N=l,G=0;while(l<a){if(T())continue;let L=i.charCodeAt(l);if(L===Q||L===V||L===ue||L===he)G++;else if(L===we||L===J||L===be||L===ne&&!ke())G--;else if(G===0&&(L===Y||L===tt))break;else if(G===0&&L===Ce&&!ut())break;if(G===0&&(q()||Z()))break;l++}x=g(N,l)}if(l<a&&i.charCodeAt(l)===Ce)if(o&&x&&(!s||!Cf(x)))Ft();else{l++,p();let N=l,G=0,L=0,D=0,B=!0;for(;;){l=N,G=0,L=0,D=0;while(l<a){if(T())continue;let j=i.charCodeAt(l);if(j===Q||j===V||j===ue)G++;else if(j===we||j===J||j===be)G--;else if(j===he&&G===0){let je=As(l);if(je!==null)D=Math.max(0,D+je);else if(B&&(l+1>=a||i.charCodeAt(l+1)!==Ce))L++}else if(j===ne&&G===0&&D===0&&!ke()){if(L>0&&(l+1>=a||i.charCodeAt(l+1)!==Ce))L--}else if(G===0&&L===0&&D===0&&(j===Y||j===tt))break;if(G===0&&L===0&&D===0&&(q()||z()))break;l++}if(L>0&&B){B=!1;continue}break}if(O=g(N,l),O.endsWith(" as const")||O==="const"){if(S=!0,!x){let j=O.endsWith(" as const")?O.slice(0,-9).trim():O,je=Vi(j);x=je!=="unknown"?je:void 0}}else if(!x){let j=Dr(O);if(j)x=j}}if(l<a){let N=i.charCodeAt(l);if(N===tt){l++;continue}if(N===Y)l++}let A=qe(m),M=`${d?"export ":""}declare ${h} ${E}: ${x||"unknown"};`;y.push({kind:"variable",name:E,text:M,isExported:d,typeAnnotation:x,value:O,modifiers:S?[h,"const assertion"]:[h],leadingComments:A,start:m,end:l});break}while(l<a);return y}function As(m){if(i.charCodeAt(m)!==he||m+1>=a)return null;let h=i.charCodeAt(m+1);if(h===ne)return 1;if(h===H)return-1;if(!kt(h))return null;let d=m+2;while(d<a){let A=i.charCodeAt(d);if(!Ke(A)&&A!==ft&&A!==58&&A!==45)break;d++}let y=i.slice(m+1,d),C=i.charCodeAt(d);if(C>32&&C!==ne&&C!==H)return null;let E=0,x=0,O=d;for(;O<a;O++){let A=i.charCodeAt(O);if(x!==0){if(A===Ue)O++;else if(A===x)x=0;continue}if(A===te||A===se||A===Ae)x=A;else if(A===V)E++;else if(A===J&&E>0)E--;else if(A===ne&&E===0)break}if(O>=a)return null;let S=O-1;while(S>m&&i.charCodeAt(S)<=32)S--;if(i.charCodeAt(S)===H)return 0;return i.indexOf(`</${y}`,O+1)===-1?null:1}function Ui(m,h){l+=9,p();let d=W();p();let y=lt();p();let C="";if(P("extends")){l+=7,p();let A=l,M=0;while(l<a){if(T())continue;let N=i.charCodeAt(l);if(N===he)M++;else if(N===ne&&!ke())M--;else if(N===V&&M===0)break;l++}C=g(A,l)}p();let E=l<a&&i.charCodeAt(l)===V?ji():"{}",x=bs(E),O=`${h?"export ":""}declare interface ${d}${y}${C?` extends ${C}`:""} ${x}`,S=qe(m);return{kind:"interface",name:d,text:O,isExported:h,extends:C||void 0,generics:y||void 0,leadingComments:S,start:m,end:l}}function Ki(m,h){l+=4,p();let d=W();p();let y=lt();if(p(),l<a&&i.charCodeAt(l)===Ce)l++;p();let C=l,E=0;while(l<a){if(T())continue;let A=i.charCodeAt(l);if(A===Q||A===V||A===ue||A===he)E++;else if(A===we||A===J||A===be||A===ne&&!ke())E--;else if(E===0&&A===Y)break;if(E===0&&(q()||Z()))break;l++}let x=g(C,l);if(l<a&&i.charCodeAt(l)===Y)l++;let O=`${h?"export ":""}type ${d}${y} = ${x}`,S=qe(m);return{kind:"type",name:d,text:O,isExported:h,generics:y||void 0,leadingComments:S,start:m,end:l}}function Wt(m,h,d){l+=4,p();let y=W();p();let C=l;if(l<a&&i.charCodeAt(l)===V)Oe(V,J);let E=g(m,l),x=qe(m);return{kind:"enum",name:y,text:E,isExported:h,modifiers:d?["const"]:void 0,leadingComments:x,start:m,end:l}}function $t(m,h,d,y=!1){l+=5,p();let C=W()||"AnonymousClass";p();let E=lt();p();let x="";if(P("extends")){l+=7,p();let N=l,G=0;while(l<a){if(T())continue;let L=i.charCodeAt(l);if(L===he)G++;else if(L===ne&&!ke())G--;else if(G===0&&(L===V||P("implements")))break;l++}x=g(N,l)}let O;if(P("implements")){l+=10,p();let N=l,G=0;while(l<a){if(T())continue;let D=i.charCodeAt(l);if(D===he)G++;else if(D===ne&&!ke())G--;else if(G===0&&D===V)break;l++}let L=g(N,l);if(L)O=L.split(",").map((D)=>D.trim())}p();let S=zi(),A=`${h?y?"export default ":"export declare ":"declare "}${d?"abstract ":""}class ${C}${E}${x?` extends ${x}`:""}${O&&O.length>0?` implements ${O.join(", ")}`:""} ${S}`,M=qe(m);return{kind:"class",name:C,text:A,isExported:h,isDefault:y,extends:x||void 0,implements:O,generics:E||void 0,modifiers:d?["abstract"]:void 0,leadingComments:M,start:m,end:l}}function zi(){if(l>=a||i.charCodeAt(l)!==V)return"{}";l++;let m=[];while(l<a){if(p(),l>=a)break;if(i.charCodeAt(l)===J){l++;break}if(i.charCodeAt(l)===Y){l++;continue}if(P("static")&&xs("static")===V){l+=6,p(),Oe(V,J);continue}let h=!1,d=!1,y=!1,C=!1,E=!1,x=!1,O=!1,S=!1,A=!0;while(A){if(p(),P("private")){h=!0,l+=7;continue}if(P("protected")){d=!0,l+=9;continue}if(P("public")){l+=6;continue}if(P("static")){y=!0,l+=6;continue}if(P("abstract")){C=!0,l+=8;continue}if(P("readonly")){E=!0,l+=8;continue}if(P("override")){x=!0,l+=8;continue}if(P("accessor")){O=!0,l+=8;continue}if(P("async")){S=!0,l+=5;continue}if(P("declare")){l+=7;continue}break}if(p(),l>=a||i.charCodeAt(l)===J)break;if(i.charCodeAt(l)===Ur)h=!0;if(h){Ji();continue}let M=" ";if(d)M+="protected ";if(y)M+="static ";if(C)M+="abstract ";if(E)M+="readonly ";if(P("constructor")){l+=11,p();let N=bt();if(p(),dc(N,m),l<a&&i.charCodeAt(l)===V)Oe(V,J);else if(l<a&&i.charCodeAt(l)===Y)l++;let G=Nt(N);m.push(` constructor${G};`)}else if(P("get"))if(l+=3,p(),l<a&&(kt(i.charCodeAt(l))||i.charCodeAt(l)===ue||i.charCodeAt(l)===Ur)){let N=Hi();if(N.startsWith("#")){if(p(),l<a&&i.charCodeAt(l)===Q)bt();if(p(),or(),p(),l<a&&i.charCodeAt(l)===V)Oe(V,J);else if(l<a&&i.charCodeAt(l)===Y)l++;continue}p(),bt(),p();let G=or()||"unknown";if(p(),l<a&&i.charCodeAt(l)===V)Oe(V,J);else if(l<a&&i.charCodeAt(l)===Y)l++;m.push(`${M}get ${N}(): ${G};`)}else Ts("get",M,y,E,S,m);else if(P("set"))if(l+=3,p(),l<a&&(kt(i.charCodeAt(l))||i.charCodeAt(l)===ue||i.charCodeAt(l)===Ur)){let N=Hi();if(N.startsWith("#")){if(p(),l<a&&i.charCodeAt(l)===Q)bt();if(p(),l<a&&i.charCodeAt(l)===V)Oe(V,J);else if(l<a&&i.charCodeAt(l)===Y)l++;continue}p();let G=bt();if(p(),l<a&&i.charCodeAt(l)===V)Oe(V,J);else if(l<a&&i.charCodeAt(l)===Y)l++;let L=Nt(G);m.push(`${M}set ${N}${L};`)}else Ts("set",M,y,E,S,m);else{let N=i.charCodeAt(l)===ge;if(N)l++,p();let G=Hi();if(!G){Ji();continue}Ps(G,M,y,E,N,C,S,m)}}return`{
66
+ ${m.join(`
66
67
  `)}
67
- }`}function Ki(){if(l>=a)return"";let p=i.charCodeAt(l);if(p===pe){let h=l;return ke(pe,$e),i.slice(h,l)}if(p===_r)return l++,`#${L()}`;return L()}function As(p){let h=l+p.length;while(h<a&&De(i.charCodeAt(h)))h++;return h<a?i.charCodeAt(h):0}function Hi(){let p=0;while(l<a){if(T())continue;let h=i.charCodeAt(l);if(h===V||h===ee)p++;else if(h===J||h===we){if(p===0)return;p--}else if(h===Y&&p===0){l++;return}if(p===0&&re())return;l++}}function $s(p,h,m,y,w,E){xs(p,h,m,y,!1,!1,w,E)}function xs(p,h,m,y,w,E,x,O){if(d(),l>=a)return;let S=i.charCodeAt(l),A=!1;if(S===jr)A=!0,l++,d();if(l<a&&i.charCodeAt(l)===33)l++,d();let M=l<a?i.charCodeAt(l):0;if(M===ee||M===ge){let N=M===ge?at():"";d();let G=Et();d();let B=sr(),D=B.length>0;if(!B)if(x&&w)B="AsyncGenerator<unknown, void, unknown>";else if(w)B="Generator<unknown, void, unknown>";else if(x)B="Promise<void>";else B="void";if(d(),l<a&&i.charCodeAt(l)===V){let me=l+1;if(ke(V,J),!o&&!D&&!w)B=hr(i.slice(me,l-1),x,G)}else if(l<a&&i.charCodeAt(l)===Y)l++;let W=Ft(G),j=A?"?":"";O.push(`${h}${p}${j}${N}${W}: ${B};`)}else if(M===Qe||M===be||M===Y||M===J||M===ne||M===ye){let N="";if(M===Qe){l++,d();let D=l,W=0;while(l<a){if(T())continue;let j=i.charCodeAt(l);if(j===ee||j===V||j===pe||j===ge)W++;else if(j===we||j===J||j===$e||j===fe&&!Me()){if(W===0)break;W--}else if(W===0&&(j===Y||j===et))break;else if(W===0&&j===be&&!ft())break;if(W===0&&re())break;l++}N=g(D,l)}let G="";if(l<a&&i.charCodeAt(l)===be)if(o&&N){l++;let D=0;while(l<a){if(T())continue;let W=i.charCodeAt(l);if(W===ee||W===V||W===pe)D++;else if(W===we||W===J||W===$e){if(D===0&&W===J)break;D--}else if(D===0&&W===Y)break;if(D===0&&re())break;l++}}else{l++,d();let D=l,W=0;while(l<a){if(T())continue;let j=i.charCodeAt(l);if(j===ee||j===V||j===pe)W++;else if(j===we||j===J||j===$e){if(W===0&&j===J)break;W--}else if(W===0&&j===Y)break;if(W===0&&re())break;l++}G=g(D,l)}if(l<a&&i.charCodeAt(l)===Y)l++;if(!N)if(G){let D=kr(G);if(D)N=D;else N=G.endsWith("as const")||m&&y?ji(G):Gi(G)}else N="unknown";let B=A?"?":"";O.push(`${h}${p}${B}: ${N};`)}else Hi()}function fc(p,h){let m=p.slice(1,-1).trim();if(!m)return;let y=[],w=0,E=0,x=!1,O=0;for(let S=0;S<=m.length;S++){if(S===m.length){y.push(m.slice(w).trim());break}let A=m.charCodeAt(S);if(x){if(A===He){S++;continue}if(A===O)x=!1;continue}if(A===ie||A===le||A===Pe){x=!0,O=A;continue}if(A===ee||A===V||A===pe||A===ge)E++;else if(A===we||A===J||A===$e||A===fe&&!(S>0&&m.charCodeAt(S-1)===be))E--;else if(A===et&&E===0)y.push(m.slice(w,S).trim()),w=S+1}for(let S of y){let A=S.startsWith("public ")||S.startsWith("public\t"),M=S.startsWith("protected ")||S.startsWith("protected\t"),N=S.startsWith("private ")||S.startsWith("private\t"),G=S.includes("readonly ");if(!A&&!M&&!N&&!G)continue;if(N)continue;let B=S,D=[];if(A){let me=6;while(me<B.length&&De(B.charCodeAt(me)))me++;B=B.slice(me),D.push("public")}if(M){let me=9;while(me<B.length&&De(B.charCodeAt(me)))me++;B=B.slice(me),D.push("protected")}if(G){let me=B.indexOf("readonly ");if(me!==-1){let Bt=me+8;while(Bt<B.length&&De(B.charCodeAt(Bt)))Bt++;B=B.slice(0,me)+B.slice(Bt)}D.push("readonly")}let W=D.length>0?`${D.join(" ")} `:"",j=Es(B);h.push(` ${W}${j};`)}}function zi(p=" "){if(l>=a||i.charCodeAt(l)!==V)return"{}";l++;let h=[];while(l<a){if(d(),l>=a)break;if(i.charCodeAt(l)===J){l++;break}if(i.charCodeAt(l)===Y){l++;continue}let m=!1;if(P("export"))m=!0,l+=6,d();if(P("declare"))l+=7,d();let y=m?"export ":"";if(P("function")||P("async")&&uc("async","function")){let w=!1;if(P("async"))w=!0,l+=5,d();if(l+=8,d(),l<a&&i.charCodeAt(l)===ve)l++,d();let E=L();d();let x=at();d();let O=Et();d();let S=sr();if(!S)S=w?"Promise<void>":"void";if(d(),l<a&&i.charCodeAt(l)===V)ke(V,J);else if(l<a&&i.charCodeAt(l)===Y)l++;let A=Ft(O);h.push(`${p}${y}function ${E}${x}${A}: ${S};`)}else if(P("const")||P("let")||P("var")){let w=P("const")?"const":P("let")?"let":"var";l+=w.length,d();let E=L();if(!E){Q();continue}d();let x="";if(l<a&&i.charCodeAt(l)===Qe){l++,d();let S=l,A=0;while(l<a){if(T())continue;let M=i.charCodeAt(l);if(M===ee||M===V||M===pe||M===ge)A++;else if(M===we||M===J||M===$e||M===fe&&!Me())A--;else if(A===0&&(M===Y||M===et))break;else if(A===0&&M===be&&!ft())break;if(A===0&&q())break;l++}x=g(S,l)}let O="";if(l<a&&i.charCodeAt(l)===be){l++,d();let S=l,A=0;while(l<a){if(T())continue;let M=i.charCodeAt(l);if(M===ee||M===V||M===pe||M===ge)A++;else if(M===we||M===J||M===$e||M===fe&&!Me())A--;else if(A===0&&(M===Y||M===et))break;if(A===0&&q())break;l++}O=g(S,l)}if(l<a&&i.charCodeAt(l)===Y)l++;if(!x&&O){let S=kr(O);if(S)x=S;else if(w==="const")x=ji(O);else x=Gi(O)}if(!x)x="unknown";h.push(`${p}${y}${w} ${E}: ${x};`)}else if(P("interface")){l+=9,d();let w=L();d();let E=at();d();let x="";if(P("extends")){l+=7,d();let S=l,A=0;while(l<a){if(T())continue;let M=i.charCodeAt(l);if(M===ge)A++;else if(M===fe&&!Me())A--;else if(M===V&&A===0)break;l++}x=g(S,l)}let O=vs(Bi());h.push(`${p}${y}interface ${w}${E}${x?` extends ${x}`:""} ${O}`)}else if(P("type")){l+=4,d();let w=L();d();let E=at();if(d(),l<a&&i.charCodeAt(l)===be){l++,d();let x=l,O=0;while(l<a){if(T())continue;let A=i.charCodeAt(l);if(A===ee||A===V||A===pe||A===ge)O++;else if(A===we||A===J||A===$e||A===fe&&!Me())O--;else if(O===0&&A===Y)break;if(O===0&&q())break;l++}let S=g(x,l);if(l<a&&i.charCodeAt(l)===Y)l++;h.push(`${p}${y}type ${w}${E} = ${S}`)}}else if(P("class")){l+=5,d();let w=L();d();let E=at();d();let x=l,O=0;while(l<a){if(T())continue;let N=i.charCodeAt(l);if(N===ge)O++;else if(N===fe&&!Me())O--;else if(N===V&&O===0)break;l++}let S=g(x,l),A=S?` ${S}`:"",M=Ui();h.push(`${p}${y}class ${w}${E}${A} ${M}`)}else if(P("enum")){l+=4,d();let w=L();d();let E=Bi();h.push(`${p}${y}enum ${w} ${E}`)}else if(P("namespace")||P("module")){let w=P("namespace")?"namespace":"module";l+=w.length,d();let E=L();d();let x=zi(p);h.push(`${p}${y}${w} ${E} ${x}`)}else if(P("abstract"))if(l+=8,d(),P("class")){l+=5,d();let w=L();d();let E=at();d();let x=l,O=0;while(l<a){if(T())continue;let N=i.charCodeAt(l);if(N===ge)O++;else if(N===fe&&!Me())O--;else if(N===V&&O===0)break;l++}let S=g(x,l),A=S?` ${S}`:"",M=Ui();h.push(`${p}${y}abstract class ${w}${E}${A} ${M}`)}else Q();else if(m&&P("default")){l+=7,d();let w=l;Q();let E=g(w,l);if(E.charCodeAt(E.length-1)===Y)E=E.slice(0,-1);if(E)h.push(`${p}export default ${E};`)}else if(!m&&(i.charCodeAt(l)===ie||i.charCodeAt(l)===le||i.charCodeAt(l)===Pe))Q();else Q()}if(h.length===0)return"{}";return`{
68
+ }`}function Hi(){if(l>=a)return"";let m=i.charCodeAt(l);if(m===ue){let h=l;return Oe(ue,be),i.slice(h,l)}if(m===Ur)return l++,`#${W()}`;return W()}function xs(m){let h=l+m.length;while(h<a&&Me(i.charCodeAt(h)))h++;return h<a?i.charCodeAt(h):0}function Ji(){let m=0;while(l<a){if(T())continue;let h=i.charCodeAt(l);if(h===V||h===Q)m++;else if(h===J||h===we){if(m===0)return;m--}else if(h===Y&&m===0){l++;return}if(m===0&&ie())return;l++}}function Ts(m,h,d,y,C,E){Ps(m,h,d,y,!1,!1,C,E)}function Ps(m,h,d,y,C,E,x,O){if(p(),l>=a)return;let S=i.charCodeAt(l),A=!1;if(S===Vr)A=!0,l++,p();if(l<a&&i.charCodeAt(l)===33)l++,p();let M=l<a?i.charCodeAt(l):0;if(M===Q||M===he){let N=M===he?lt():"";p();let G=bt();p();let L=or(),D=L.length>0;if(!L)if(x&&C)L="AsyncGenerator<unknown, void, unknown>";else if(C)L="Generator<unknown, void, unknown>";else if(x)L="Promise<void>";else L="void";if(p(),l<a&&i.charCodeAt(l)===V){let je=l+1;if(Oe(V,J),!o&&!D&&!C)L=dr(i.slice(je,l-1),x,G)}else if(l<a&&i.charCodeAt(l)===Y)l++;let B=Nt(G),j=A?"?":"";O.push(`${h}${m}${j}${N}${B}: ${L};`)}else if(M===et||M===Ce||M===Y||M===J||M===oe||M===ye){let N="";if(M===et){l++,p();let D=l,B=0;while(l<a){if(T())continue;let j=i.charCodeAt(l);if(j===Q||j===V||j===ue||j===he)B++;else if(j===we||j===J||j===be||j===ne&&!ke()){if(B===0)break;B--}else if(B===0&&(j===Y||j===tt))break;else if(B===0&&j===Ce&&!ut())break;if(B===0&&ie())break;l++}N=g(D,l)}let G="";if(l<a&&i.charCodeAt(l)===Ce)if(o&&N){l++;let D=0;while(l<a){if(T())continue;let B=i.charCodeAt(l);if(B===Q||B===V||B===ue)D++;else if(B===we||B===J||B===be){if(D===0&&B===J)break;D--}else if(D===0&&B===Y)break;if(D===0&&ie())break;l++}}else{l++,p();let D=l,B=0;while(l<a){if(T())continue;let j=i.charCodeAt(l);if(j===Q||j===V||j===ue)B++;else if(j===we||j===J||j===be){if(B===0&&j===J)break;B--}else if(B===0&&j===Y)break;if(B===0&&ie())break;l++}G=g(D,l)}if(l<a&&i.charCodeAt(l)===Y)l++;if(!N)if(G){let D=Dr(G);if(D)N=D;else N=G.endsWith("as const")||d&&y?Vi(G):_i(G)}else N="unknown";let L=A?"?":"";O.push(`${h}${m}${L}: ${N};`)}else Ji()}function hc(m){let h=0;for(let d=0;d<m.length;d++){let y=m.charCodeAt(d);if(y===Q||y===V||y===ue||y===he)h++;else if(y===we||y===J||y===be||y===ne&&m.charCodeAt(d-1)!==Ce)h--;else if(y===Ce&&h===0&&m.charCodeAt(d+1)!==ne&&m.charCodeAt(d+1)!==Ce)return!0}return!1}function dc(m,h){let d=m.slice(1,-1).trim();if(!d)return;let y=[],C=0,E=0,x=!1,O=0;for(let S=0;S<=d.length;S++){if(S===d.length){y.push(Mr(d.slice(C).trim()));break}let A=d.charCodeAt(S);if(x){if(A===Ue){S++;continue}if(A===O)x=!1;continue}if(A===H&&S+1<d.length){let M=d.charCodeAt(S+1);if(M===ge){S+=2;while(S+1<d.length&&!(d.charCodeAt(S)===ge&&d.charCodeAt(S+1)===H))S++;S++;continue}if(M===H){while(S<d.length&&d.charCodeAt(S)!==10)S++;continue}}if(A===te||A===se||A===Ae){x=!0,O=A;continue}if(A===Q||A===V||A===ue||A===he)E++;else if(A===we||A===J||A===be||A===ne&&!(S>0&&d.charCodeAt(S-1)===Ce))E--;else if(A===tt&&E===0)y.push(Mr(d.slice(C,S).trim())),C=S+1}for(let S of y){let A=S.startsWith("public ")||S.startsWith("public\t"),M=S.startsWith("protected ")||S.startsWith("protected\t"),N=S.startsWith("private ")||S.startsWith("private\t"),G=S.includes("readonly ");if(!A&&!M&&!N&&!G)continue;if(N)continue;let L=S,D=[];if(A){let _e=6;while(_e<L.length&&Me(L.charCodeAt(_e)))_e++;L=L.slice(_e),D.push("public")}if(M){let _e=9;while(_e<L.length&&Me(L.charCodeAt(_e)))_e++;L=L.slice(_e),D.push("protected")}if(G){let _e=L.indexOf("readonly ");if(_e!==-1){let Gt=_e+8;while(Gt<L.length&&Me(L.charCodeAt(Gt)))Gt++;L=L.slice(0,_e)+L.slice(Gt)}D.push("readonly")}let B=D.length>0?`${D.join(" ")} `:"",j=Ss(L),je=L.search(/[?:=]/);if(je!==-1&&L.charCodeAt(je)!==63&&hc(L))j=j.replace(/^([\w$]+)\?:/,"$1:");h.push(` ${B}${j};`)}}function qi(m=" "){if(l>=a||i.charCodeAt(l)!==V)return"{}";l++;let h=[];while(l<a){if(p(),l>=a)break;if(i.charCodeAt(l)===J){l++;break}if(i.charCodeAt(l)===Y){l++;continue}let d=!1;if(P("export"))d=!0,l+=6,p();if(P("declare"))l+=7,p();let y=d?"export ":"";if(P("function")||P("async")&&mc("async","function")){let C=!1;if(P("async"))C=!0,l+=5,p();if(l+=8,p(),l<a&&i.charCodeAt(l)===ge)l++,p();let E=W();p();let x=lt();p();let O=bt();p();let S=or();if(!S)S=C?"Promise<void>":"void";if(p(),l<a&&i.charCodeAt(l)===V)Oe(V,J);else if(l<a&&i.charCodeAt(l)===Y)l++;let A=Nt(O);h.push(`${m}${y}function ${E}${x}${A}: ${S};`)}else if(P("const")||P("let")||P("var")){let C=P("const")?"const":P("let")?"let":"var";l+=C.length,p();let E=W();if(!E){ee();continue}p();let x="";if(l<a&&i.charCodeAt(l)===et){l++,p();let S=l,A=0;while(l<a){if(T())continue;let M=i.charCodeAt(l);if(M===Q||M===V||M===ue||M===he)A++;else if(M===we||M===J||M===be||M===ne&&!ke())A--;else if(A===0&&(M===Y||M===tt))break;else if(A===0&&M===Ce&&!ut())break;if(A===0&&q())break;l++}x=g(S,l)}let O="";if(l<a&&i.charCodeAt(l)===Ce){l++,p();let S=l,A=0;while(l<a){if(T())continue;let M=i.charCodeAt(l);if(M===Q||M===V||M===ue||M===he)A++;else if(M===we||M===J||M===be||M===ne&&!ke())A--;else if(A===0&&(M===Y||M===tt))break;if(A===0&&q())break;l++}O=g(S,l)}if(l<a&&i.charCodeAt(l)===Y)l++;if(!x&&O){let S=Dr(O);if(S)x=S;else if(C==="const")x=Vi(O);else x=_i(O)}if(!x)x="unknown";h.push(`${m}${y}${C} ${E}: ${x};`)}else if(P("interface")){l+=9,p();let C=W();p();let E=lt();p();let x="";if(P("extends")){l+=7,p();let S=l,A=0;while(l<a){if(T())continue;let M=i.charCodeAt(l);if(M===he)A++;else if(M===ne&&!ke())A--;else if(M===V&&A===0)break;l++}x=g(S,l)}let O=bs(ji());h.push(`${m}${y}interface ${C}${E}${x?` extends ${x}`:""} ${O}`)}else if(P("type")){l+=4,p();let C=W();p();let E=lt();if(p(),l<a&&i.charCodeAt(l)===Ce){l++,p();let x=l,O=0;while(l<a){if(T())continue;let A=i.charCodeAt(l);if(A===Q||A===V||A===ue||A===he)O++;else if(A===we||A===J||A===be||A===ne&&!ke())O--;else if(O===0&&A===Y)break;if(O===0&&q())break;l++}let S=g(x,l);if(l<a&&i.charCodeAt(l)===Y)l++;h.push(`${m}${y}type ${C}${E} = ${S}`)}}else if(P("class")){l+=5,p();let C=W();p();let E=lt();p();let x=l,O=0;while(l<a){if(T())continue;let N=i.charCodeAt(l);if(N===he)O++;else if(N===ne&&!ke())O--;else if(N===V&&O===0)break;l++}let S=g(x,l),A=S?` ${S}`:"",M=zi();h.push(`${m}${y}class ${C}${E}${A} ${M}`)}else if(P("enum")){l+=4,p();let C=W();p();let E=ji();h.push(`${m}${y}enum ${C} ${E}`)}else if(P("namespace")||P("module")){let C=P("namespace")?"namespace":"module";l+=C.length,p();let E=W();p();let x=qi(m);h.push(`${m}${y}${C} ${E} ${x}`)}else if(P("abstract"))if(l+=8,p(),P("class")){l+=5,p();let C=W();p();let E=lt();p();let x=l,O=0;while(l<a){if(T())continue;let N=i.charCodeAt(l);if(N===he)O++;else if(N===ne&&!ke())O--;else if(N===V&&O===0)break;l++}let S=g(x,l),A=S?` ${S}`:"",M=zi();h.push(`${m}${y}abstract class ${C}${E}${A} ${M}`)}else ee();else if(d&&P("default")){l+=7,p();let C=l;ee();let E=g(C,l);if(E.charCodeAt(E.length-1)===Y)E=E.slice(0,-1);if(E)h.push(`${m}export default ${E};`)}else if(!d&&(i.charCodeAt(l)===te||i.charCodeAt(l)===se||i.charCodeAt(l)===Ae))ee();else ee()}if(h.length===0)return"{}";return`{
68
69
  ${h.join(`
69
70
  `)}
70
- }`}function uc(p,h){let m=l+p.length;while(m<a&&De(i.charCodeAt(m)))m++;for(let y=0;y<h.length;y++)if(m+y>=a||i.charCodeAt(m+y)!==h.charCodeAt(y))return!1;return m+h.length>=a||!Ve(i.charCodeAt(m+h.length))}function Wt(p,h,m){l+=m.length,d();let y="",w=i.charCodeAt(l);if(w===ie||w===le){let A=l;b(w),y=i.slice(A,l)}else{y=L();while(l<a&&i.charCodeAt(l)===ct)l++,y+=`.${L()}`}d();let E=l<a&&i.charCodeAt(l)===V?zi():"{}",x=`${h?"export ":""}declare ${m} ${y} ${E}`,O=Je(p),S=y.startsWith("'")||y.startsWith('"');return{kind:"module",name:y,text:x,isExported:h,source:S?y.slice(1,-1):void 0,leadingComments:O,start:p,end:l}}function Ts(p,h){Q();let m=g(h,l);if(m.charCodeAt(m.length-1)===Y)m=m.slice(0,-1).trimEnd();if(!m)return;let y=Ot(m.charCodeAt(0));for(let A=1;y&&A<m.length;A++)y=Ve(m.charCodeAt(A));let w=Je(p);if(y){c.push({kind:"export",name:"default",text:`export default ${m};`,isExported:!0,isTypeOnly:!1,leadingComments:w,start:p,end:l});return}let E="__dtsx_default_export__",x=1;while(i.includes(E))E=`__dtsx_default_export_${x++}__`;let O=kr(m)||Te(m,!1),S=O==="unknown"&&pf(m)?`typeof ${m}`:O;c.push({kind:"variable",name:E,text:`declare const ${E}: ${S};`,isExported:!1,typeAnnotation:S,modifiers:["const"],start:p,end:l}),c.push({kind:"export",name:"default",text:`export default ${E};`,isExported:!0,isTypeOnly:!1,leadingComments:w,start:p,end:l})}while(l<a){if(d(),l>=a)break;let p=l,h=i.charCodeAt(l);if(h===105&&P("import"))c.push(nc(p));else if(h===101&&P("export")){l+=6,d();let m=i.charCodeAt(l);if(m===100&&P("default")){l+=7,d();let y=l,w=i.charCodeAt(l);if(w===102&&P("function")){let E=bt(p,!0,!1,!0);if(E)c.push(E)}else if(w===97&&P("async")&&As("async")!==Y)if(l+=5,d(),P("function")){let E=bt(p,!0,!0,!0);if(E)c.push(E)}else Ts(p,y);else if(w===99&&P("class")){let E=St(p,!0,!1,!0);c.push(E)}else if(w===97&&P("abstract")){if(l+=8,d(),P("class")){let E=St(p,!0,!0,!0);c.push(E)}}else Ts(p,y)}else if(m===116&&P("type")){let y=l;if(l+=4,d(),l<a&&i.charCodeAt(l)===V){nr();let w=g(p,l),E=Je(p);c.push({kind:"export",name:"",text:w,isExported:!0,isTypeOnly:!0,source:Or(w),leadingComments:E,start:p,end:l})}else if(l<a&&i.charCodeAt(l)===ve){Cs();let w=g(p,l);c.push({kind:"export",name:"",text:w,isExported:!0,isTypeOnly:!0,source:Or(w),start:p,end:l})}else{l=y;let w=Vi(p,!0);c.push(w)}}else if(m===105&&P("interface")){let y=_i(p,!0);c.push(y)}else if(m===102&&P("function")){let y=bt(p,!0,!1,!1);if(y)c.push(y)}else if(m===97&&P("async"))if(l+=5,d(),P("function")){let y=bt(p,!0,!0,!1);if(y)c.push(y)}else Q();else if(m===99)if(P("class")){let y=St(p,!0,!1);c.push(y)}else if(P("const")){let y=l;if(l+=5,d(),P("enum")){l=y+5,d();let w=Lt(p,!0,!0);c.push(w)}else{l=y;let w=Nt(p,"const",!0);for(let E=0;E<w.length;E++)c.push(w[E])}}else Q();else if(m===97&&P("abstract")){if(l+=8,d(),P("class")){let y=St(p,!0,!0);c.push(y)}}else if(m===108&&P("let")){let y=Nt(p,"let",!0);for(let w=0;w<y.length;w++)c.push(y[w])}else if(m===118&&P("var")){let y=Nt(p,"var",!0);for(let w=0;w<y.length;w++)c.push(y[w])}else if(m===101&&P("enum")){let y=Lt(p,!0,!1);c.push(y)}else if(m===100&&P("declare"))l+=7,d(),Ps(p,!0);else if(m===110&&P("namespace")&&F(9)){let y=Wt(p,!0,"namespace");c.push(y)}else if(m===109&&P("module")&&F(6)){let y=Wt(p,!0,"module");c.push(y)}else if(m===V){nr();let y=g(p,l),w=y.includes("export type"),E=Je(p);c.push({kind:"export",name:"",text:y,isExported:!0,isTypeOnly:w,source:Or(y),leadingComments:E,start:p,end:l})}else if(m===ve){Cs();let y=g(p,l),w=Je(p);c.push({kind:"export",name:"",text:y,isExported:!0,isTypeOnly:!1,source:Or(y),leadingComments:w,start:p,end:l})}else{Q();let y=g(p,l);if(y)c.push({kind:"export",name:"",text:y,isExported:!0,start:p,end:l})}}else if(h===100&&P("declare"))l+=7,d(),Ps(p,!1);else if(h===105&&P("interface")){let m=_i(p,!1);f.set(m.name,m)}else if(h===116&&P("type")){let m=Vi(p,!1);f.set(m.name,m),c.push(m)}else if(h===102&&P("function")){let m=bt(p,!1,!1,!1);if(m)f.set(m.name,m);else Q()}else if(h===97)if(P("async")){let m=l;if(l+=5,d(),P("function")){let y=bt(p,!1,!0,!1);if(y)f.set(y.name,y);else l=m,Q()}else l=m,Q()}else if(P("abstract"))if(l+=8,d(),P("class")){let m=St(p,!1,!1);f.set(m.name,m),c.push(m)}else Q();else l++,Q();else if(h===99)if(P("class")){let m=St(p,!1,!1);f.set(m.name,m),c.push(m)}else if(P("const")){let m=l;if(l+=5,d(),P("enum")){l=m+5,d();let y=Lt(p,!1,!0);f.set(y.name,y),c.push(y)}else{l=m;let y=Nt(p,"const",!1);for(let w=0;w<y.length;w++)f.set(y[w].name,y[w])}}else l++,Q();else if(h===101&&P("enum")){let m=Lt(p,!1,!1);f.set(m.name,m),c.push(m)}else if(h===108&&P("let"))Q();else if(h===118&&P("var"))Q();else if(h===109&&P("module")&&F(6)){let m=Wt(p,!1,"module");c.push(m)}else if(h===110&&P("namespace")&&F(9)){let m=Wt(p,!1,"namespace");c.push(m)}else{let m=i.charCodeAt(l);if(m===Y)l++;else if(m===ie||m===le){if(b(m),l<a&&i.charCodeAt(l)===Y)l++}else if(m===Pe){if(C(),l<a&&i.charCodeAt(l)===Y)l++}else if(m===df){if(l++,L(),d(),l<a&&i.charCodeAt(l)===ct)l++,L(),d();if(l<a&&i.charCodeAt(l)===ee)ke(ee,we)}else l++,Q()}}if(f.size>0)yf(c,f);if(u.size>0){let p=new Map;for(let m of c)if(m.kind==="function")p.set(m.name,(p.get(m.name)||0)+1);let h=new Set;for(let[m,y]of p)if(y>1)h.add(m);if(h.size>0){let m=new Set;for(let y of h)for(let w=c.length-1;w>=0;w--)if(c[w].kind==="function"&&c[w].name===y&&u.has(w)){m.add(w);break}if(m.size>0){let y=[...m].sort((w,E)=>E-w);for(let w of y)c.splice(w,1)}}}return c;function Ps(p,h){if(P("function")){let m=bt(p,h,!1,!1);if(m)c.push(m)}else if(P("async")){if(l+=5,d(),P("function")){let m=bt(p,h,!0,!1);if(m)c.push(m)}}else if(P("class")){let m=St(p,h,!1);c.push(m)}else if(P("abstract")){if(l+=8,d(),P("class")){let m=St(p,h,!0);c.push(m)}}else if(P("interface")){let m=_i(p,h);c.push(m)}else if(P("type")){let m=Vi(p,h);c.push(m)}else if(P("enum")){let m=Lt(p,h,!1);c.push(m)}else if(P("const")){let m=l;if(l+=5,d(),P("enum")){l=m+5,d();let y=Lt(p,h,!0);c.push(y)}else if(h){l=m;let y=Nt(p,"const",!0);for(let w=0;w<y.length;w++)c.push(y[w])}else Q()}else if(P("let")||P("var"))if(h){let m=P("let")?"let":"var",y=Nt(p,m,!0);for(let w=0;w<y.length;w++)c.push(y[w])}else Q();else if(P("module")){let m=Wt(p,h,"module");c.push(m)}else if(P("namespace")){let m=Wt(p,h,"namespace");c.push(m)}else if(P("global")){l+=6,d();let m=`declare global ${l<a&&i.charCodeAt(l)===V?zi():"{}"}`,y=Je(p);c.push({kind:"module",name:"global",text:m,isExported:!1,leadingComments:y,start:p,end:l})}else Q()}}function to(e,t){let r=0,n=e.length;while(r<n){let i=e.charCodeAt(r);if(i>=65&&i<=90||i>=97&&i<=122||i===95||i===36||i>127){let s=r;r++;while(r<n){let o=e.charCodeAt(r);if(o>=65&&o<=90||o>=97&&o<=122||o>=48&&o<=57||o===95||o===36||o>127)r++;else break}t.add(e.substring(s,r))}else r++}}function ro(e,t){let r=0;while(r<e.length){let n=e.charCodeAt(r);if(n===ie||n===le||n===Pe){let u=n;r++;while(r<e.length)if(e.charCodeAt(r)===He)r+=2;else if(e.charCodeAt(r++)===u)break;continue}if(n===z&&e.charCodeAt(r+1)===z){r+=2;while(r<e.length&&e.charCodeAt(r)!==ne&&e.charCodeAt(r)!==ye)r++;continue}if(n===z&&e.charCodeAt(r+1)===ve){let u=e.indexOf("*/",r+2);r=u===-1?e.length:u+2;continue}if(!Ot(n)){r++;continue}let i=r++;while(r<e.length&&Ve(e.charCodeAt(r)))r++;let s=i-1,o=r;while(s>=0&&De(e.charCodeAt(s)))s--;while(o<e.length&&De(e.charCodeAt(o)))o++;let a=s>=0?e.charCodeAt(s):0,c=o<e.length?e.charCodeAt(o):0,f=i>=3&&e.slice(i-3,i)==="...";if(c===Qe||a===ct&&!f)continue;if(c===ee&&(a===V||a===et))continue;t.add(e.slice(i,r))}}function yf(e,t){let r=new Set,n=new Set;for(let o of e)n.add(o.name);let i=new Set,s=[];for(let o=0;o<e.length;o++){let a=e[o];if(a.kind!=="import"){if(s.push(a.text),to(a.text,i),typeof a.value==="string")ro(a.value,i)}}for(;;){let o=[];for(let[f,u]of t){if(r.has(f))continue;if(i.has(f)){if(!n.has(f))o.push(u),n.add(f);r.add(f)}}if(o.length===0)break;o.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<o.length&&(o[c].start??1/0)<=u)a.push(o[c++]);a.push(e[f])}while(c<o.length)a.push(o[c++]);e.length=0;for(let f=0;f<a.length;f++)e.push(a[f]);for(let f of o)if(f.kind!=="import"){if(s.push(f.text),to(f.text,i),typeof f.value==="string")ro(f.value,i)}}}var Se=32,Ae=9,ne=10,ye=13,z=47,ve=42,ie=39,le=34,Pe=96,He=92,V=123,J=125,ee=40,we=41,pe=91,$e=93,ge=60,fe=62,Y=59,Qe=58,be=61,et=44,ct=46,jr=63,_r=35,df=64,io=36,mf=95,mn;var ao=ce(()=>{dn();mn=["public","protected","private","readonly","override"]});function co(e,t,r=!0,n=!1){if(Ms(t))e=Fs(e);else if(Ls(t))e=Ws(e);let i=or(e),s=`${t}:${r?1:0}:${n?1:0}`,o=_t.get(s);if(o&&o.contentHash===i)return o.lastAccess=++lo,o.declarations;let a=n?no(e,t,r):so(e,t,r);if(_t.set(s,{declarations:a,contentHash:i,lastAccess:++lo}),_t.size>Cf){let c=Math.max(1,Math.ceil(_t.size*0.1)),f=[];for(let[u,l]of _t)f.push([u,l.lastAccess]);f.sort((u,l)=>u[1]-l[1]);for(let u=0;u<c&&u<f.length;u++)_t.delete(f[u][0])}return a}var Cf=100,lo=0,_t;var fo=ce(()=>{sn();Bs();ao();Ji();_t=new Map});function Ur(e,t,r=!0,n=!1){return co(e,t,r,n)}var pn=ce(()=>{fo()});import{dirname as tp,relative as wf,resolve as rp}from"path";async function uo(e,t,r){let n=new Map,i=[],s=new Set,o=0,a=0,c=0,f=[];for(let k of e){let R=t.get(k);if(!R)continue;f.push({file:k,decls:Ur(R,k,r.keepComments)})}for(let{file:k,decls:R}of f){o+=R.length;for(let I of R)if(I.kind==="import"){a++;let _=I.source||"";if(_.startsWith("."))continue;if(!n.has(_))n.set(_,{source:_,specifiers:new Map,isTypeOnly:I.isTypeOnly||!1,isSideEffect:I.isSideEffect||!1});let L=n.get(_);if(I.specifiers)for(let P of I.specifiers){let F=P.alias||P.name;if(!L.specifiers.has(F))L.specifiers.set(F,{name:P.name,alias:P.alias,isType:P.isType||!1})}if(!I.isTypeOnly)L.isTypeOnly=!1}else if(I.isExported||I.kind==="export"){if(c++,I.kind==="export"&&I.source&&(I.source.startsWith(".")||I.source.startsWith("/")))continue;if(I.name&&s.has(I.name))continue;if(I.name)s.add(I.name);i.push({declaration:I,file:k})}}let u=[];u.push("/**"),u.push(" * Bundled TypeScript declarations"),u.push(` * Generated from ${e.length} source files`),u.push(" */"),u.push("");let l=r.importOrder||["bun"],g=Array.from(n.values()),d=Array(g.length);for(let k=0;k<g.length;k++){let R=g[k].source,I=l.length;for(let _=0;_<l.length;_++)if(R.startsWith(l[_])){I=_;break}d[k]=I}let v=g.map((k,R)=>R);v.sort((k,R)=>{let I=d[k],_=d[R];if(I!==_)return I-_;return g[k].source.localeCompare(g[R].source)});let b=v.map((k)=>g[k]);for(let k of b)if(k.isSideEffect)u.push(`import '${k.source}';`);else if(k.specifiers.size>0){let R=Array.from(k.specifiers.values()).map((_)=>{let L=_.isType?"type ":"";return _.alias?`${L}${_.name} as ${_.alias}`:`${L}${_.name}`}),I=k.isTypeOnly?"type ":"";u.push(`import ${I}{ ${R.join(", ")} } from '${k.source}';`)}if(b.length>0)u.push("");let C=new Map;for(let{declaration:k,file:R}of i){if(!C.has(R))C.set(R,[]);C.get(R).push(k)}for(let[k,R]of C){let I=wf(r.cwd,k);u.push(`// From: ${I}`);for(let _ of R){if(r.keepComments&&_.leadingComments)for(let L of _.leadingComments)u.push(L);u.push(ho(_))}u.push("")}let T=u.join(`
71
- `);return{content:T,files:e,declarationCount:o,importCount:a,exportCount:c,size:Buffer.byteLength(T,"utf8"),warnings:[]}}function ho(e){if(e.text){let r=e.text.trim();if(e.isExported&&!r.startsWith("export"))r=`export ${r}`;if(!r.endsWith(";")&&!r.endsWith("}"))r+=";";return r}let t=[];if(e.isExported)t.push("export");if(e.isDefault)t.push("default");switch(e.kind){case"function":if(t.push("declare function"),t.push(e.name),e.generics)t.push(e.generics);if(t.push(`(${vf(e.parameters)})`),e.returnType)t.push(`: ${e.returnType}`);break;case"variable":if(t.push("declare const"),t.push(e.name),e.typeAnnotation)t.push(`: ${e.typeAnnotation}`);break;case"interface":if(t.push("interface"),t.push(e.name),e.generics)t.push(e.generics);if(e.extends)t.push(`extends ${e.extends}`);if(t.push("{"),e.members)for(let r of e.members)t.push(` ${r.name}${r.typeAnnotation?`: ${r.typeAnnotation}`:""};`);t.push("}");break;case"type":if(t.push("type"),t.push(e.name),e.generics)t.push(e.generics);t.push("="),t.push(e.typeAnnotation||"unknown");break;case"class":if(t.push("declare class"),t.push(e.name),e.generics)t.push(e.generics);if(e.extends)t.push(`extends ${e.extends}`);if(e.implements&&e.implements.length>0)t.push(`implements ${e.implements.join(", ")}`);if(t.push("{"),e.members)for(let r of e.members)t.push(` ${ho(r)}`);t.push("}");break;case"enum":if(t.push("declare enum"),t.push(e.name),t.push("{"),e.members){let r=e.members.map((n)=>n.value!==void 0?`${n.name} = ${n.value}`:n.name);t.push(` ${r.join(`,
72
- `)}`)}t.push("}");break;default:return e.text||""}return t.join(" ")}function vf(e){if(!e||e.length===0)return"";return e.map((t)=>{let r="";if(t.rest)r+="...";if(r+=t.name,t.optional)r+="?";if(t.type)r+=`: ${t.type}`;if(t.defaultValue)r+=` = ${t.defaultValue}`;return r}).join(", ")}var mo=ce(()=>{pn()});import{existsSync as pr,mkdirSync as Ef,readFileSync as yn,renameSync as bf,rmSync as po,statSync as go,writeFileSync as yo}from"fs";import{join as Co,relative as Kr,resolve as Sf}from"path";class Cn{cacheDir;manifestPath;manifest=null;configHash;constructor(e){this.cacheDir=Sf(e.cwd,Hr),this.manifestPath=Co(this.cacheDir,Af),this.configHash=this.hashConfig(e)}hashConfig(e){let 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((r)=>({pattern:typeof r.pattern==="string"?{kind:"string",value:r.pattern}:{kind:"regex",source:r.pattern.source,flags:r.pattern.flags},replacement:r.replacement,global:r.global,priority:r.priority,hasCondition:Boolean(r.condition)}))}:void 0,lineEnding:e.lineEnding,normalizeOutput:e.normalizeOutput,declarationOrder:e.declarationOrder,plugins:e.plugins?.map((r)=>({name:r.name,version:r.version,cacheKey:r.cacheKey}))};return String(or(JSON.stringify(t)))}hashString(e){return String(or(e))}load(){try{if(!pr(this.manifestPath))return!1;let e=yn(this.manifestPath,"utf-8"),t=JSON.parse(e);if(t.version!==gn)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:gn,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};if(this.manifest.updatedAt=Date.now(),!pr(this.cacheDir))Ef(this.cacheDir,{recursive:!0});let e=`${this.manifestPath}.${process.pid}.tmp`;try{yo(e,JSON.stringify(this.manifest,null,2)),bf(e,this.manifestPath)}finally{if(pr(e))po(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 r=Kr(t,e),n=this.manifest.entries[r];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 i=go(e),{mtimeMs:s,ctimeMs:o}=i;if(i.size!==n.sourceSize)return null;if(s!==n.sourceMtime||o!==n.sourceCtime){let a=yn(e,"utf-8");if(this.hashString(a)!==n.sourceHash)return null;n.sourceMtime=s,n.sourceCtime=o}return n.dtsContent}catch{return null}}update(e,t,r,n){if(!this.manifest)this.manifest={version:gn,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};let i=Kr(n,e),s,o,a;try{let c=go(e);s=c.mtimeMs,o=c.ctimeMs,a=c.size}catch{s=Date.now(),o=s,a=Buffer.byteLength(t)}this.manifest.entries[i]={sourcePath:i,sourceHash:this.hashString(t),sourceMtime:s,sourceCtime:o,sourceSize:a,dtsContent:r,dtsHash:this.hashString(r),generatedAt:Date.now(),configHash:this.configHash}}remove(e,t){if(!this.manifest)return;let r=Kr(t,e);delete this.manifest.entries[r]}clear(){this.manifest=null;try{if(pr(this.manifestPath))po(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 r of Object.values(this.manifest.entries))t+=r.dtsContent.length;return{entries:e,size:t}}prune(e,t){if(!this.manifest)return 0;let r=0,n=new Set(Array.from(e).map((i)=>Kr(t,i)));for(let i of Object.keys(this.manifest.entries))if(!n.has(i))delete this.manifest.entries[i],r++;return r}}function wo(e){let t=Co(e,".gitignore");try{let r="";if(pr(t))r=yn(t,"utf-8");if(!r.split(/\r?\n/).some((n)=>n.trim()===Hr||n.trim()===`${Hr}/`)){let n=r.trimEnd(),i=`${n}${n?`
71
+ }`}function mc(m,h){let d=l+m.length;while(d<a&&Me(i.charCodeAt(d)))d++;for(let y=0;y<h.length;y++)if(d+y>=a||i.charCodeAt(d+y)!==h.charCodeAt(y))return!1;return d+h.length>=a||!Ke(i.charCodeAt(d+h.length))}function Bt(m,h,d){l+=d.length,p();let y="",C=i.charCodeAt(l);if(C===te||C===se){let A=l;b(C),y=i.slice(A,l)}else{y=W();while(l<a&&i.charCodeAt(l)===ft)l++,y+=`.${W()}`}p();let E=l<a&&i.charCodeAt(l)===V?qi():"{}",x=`${h?"export ":""}declare ${d} ${y} ${E}`,O=qe(m),S=y.startsWith("'")||y.startsWith('"');return{kind:"module",name:y,text:x,isExported:h,source:S?y.slice(1,-1):void 0,leadingComments:O,start:m,end:l}}function Rs(m,h){ee();let d=g(h,l);if(d.charCodeAt(d.length-1)===Y)d=d.slice(0,-1).trimEnd();if(!d)return;let y=kt(d.charCodeAt(0));for(let A=1;y&&A<d.length;A++)y=Ke(d.charCodeAt(A));let C=qe(m);if(y){c.push({kind:"export",name:"default",text:`export default ${d};`,isExported:!0,isTypeOnly:!1,leadingComments:C,start:m,end:l});return}let E="__dtsx_default_export__",x=1;while(i.includes(E))E=`__dtsx_default_export_${x++}__`;let O=Dr(d)||Te(d,!1),S=O==="unknown"&&yf(d)?`typeof ${d}`:O;c.push({kind:"variable",name:E,text:`declare const ${E}: ${S};`,isExported:!1,typeAnnotation:S,modifiers:["const"],start:m,end:l}),c.push({kind:"export",name:"default",text:`export default ${E};`,isExported:!0,isTypeOnly:!1,leadingComments:C,start:m,end:l})}while(l<a){if(p(),l>=a)break;let m=l,h=i.charCodeAt(l);if(h===105&&P("import"))c.push(oc(m));else if(h===101&&P("export")){l+=6,p();let d=i.charCodeAt(l);if(d===100&&P("default")){l+=7,p();let y=l,C=i.charCodeAt(l);if(C===102&&P("function")){let E=St(m,!0,!1,!0);if(E)c.push(E)}else if(C===97&&P("async")&&xs("async")!==Y)if(l+=5,p(),P("function")){let E=St(m,!0,!0,!0);if(E)c.push(E)}else Rs(m,y);else if(C===99&&P("class")){let E=$t(m,!0,!1,!0);c.push(E)}else if(C===97&&P("abstract")){if(l+=8,p(),P("class")){let E=$t(m,!0,!0,!0);c.push(E)}}else Rs(m,y)}else if(d===116&&P("type")){let y=l;if(l+=4,p(),l<a&&i.charCodeAt(l)===V){sr();let C=g(m,l),E=qe(m);c.push({kind:"export",name:"",text:C,isExported:!0,isTypeOnly:!0,source:kr(C),leadingComments:E,start:m,end:l})}else if(l<a&&i.charCodeAt(l)===ge){vs();let C=g(m,l);c.push({kind:"export",name:"",text:C,isExported:!0,isTypeOnly:!0,source:kr(C),start:m,end:l})}else{l=y;let C=Ki(m,!0);c.push(C)}}else if(d===105&&P("interface")){let y=Ui(m,!0);c.push(y)}else if(d===102&&P("function")){let y=St(m,!0,!1,!1);if(y)c.push(y)}else if(d===97&&P("async"))if(l+=5,p(),P("function")){let y=St(m,!0,!0,!1);if(y)c.push(y)}else ee();else if(d===99)if(P("class")){let y=$t(m,!0,!1);c.push(y)}else if(P("const")){let y=l;if(l+=5,p(),P("enum")){l=y+5,p();let C=Wt(m,!0,!0);c.push(C)}else{l=y;let C=Lt(m,"const",!0);for(let E=0;E<C.length;E++)c.push(C[E])}}else ee();else if(d===97&&P("abstract")){if(l+=8,p(),P("class")){let y=$t(m,!0,!0);c.push(y)}}else if(d===108&&P("let")){let y=Lt(m,"let",!0);for(let C=0;C<y.length;C++)c.push(y[C])}else if(d===118&&P("var")){let y=Lt(m,"var",!0);for(let C=0;C<y.length;C++)c.push(y[C])}else if(d===101&&P("enum")){let y=Wt(m,!0,!1);c.push(y)}else if(d===100&&P("declare"))l+=7,p(),Os(m,!0);else if(d===110&&P("namespace")&&F(9)){let y=Bt(m,!0,"namespace");c.push(y)}else if(d===109&&P("module")&&F(6)){let y=Bt(m,!0,"module");c.push(y)}else if(d===V){sr();let y=g(m,l),C=y.includes("export type"),E=qe(m);c.push({kind:"export",name:"",text:y,isExported:!0,isTypeOnly:C,source:kr(y),leadingComments:E,start:m,end:l})}else if(d===ge){vs();let y=g(m,l),C=qe(m);c.push({kind:"export",name:"",text:y,isExported:!0,isTypeOnly:!1,source:kr(y),leadingComments:C,start:m,end:l})}else{ee();let y=g(m,l);if(y)c.push({kind:"export",name:"",text:y,isExported:!0,start:m,end:l})}}else if(h===100&&P("declare"))l+=7,p(),Os(m,!1);else if(h===105&&P("interface")){let d=Ui(m,!1);f.set(d.name,d)}else if(h===116&&P("type")){let d=Ki(m,!1);f.set(d.name,d),c.push(d)}else if(h===102&&P("function")){let d=St(m,!1,!1,!1);if(d)f.set(d.name,d);else ee()}else if(h===97)if(P("async")){let d=l;if(l+=5,p(),P("function")){let y=St(m,!1,!0,!1);if(y)f.set(y.name,y);else l=d,ee()}else l=d,ee()}else if(P("abstract"))if(l+=8,p(),P("class")){let d=$t(m,!1,!1);f.set(d.name,d),c.push(d)}else ee();else l++,ee();else if(h===99)if(P("class")){let d=$t(m,!1,!1);f.set(d.name,d),c.push(d)}else if(P("const")){let d=l;if(l+=5,p(),P("enum")){l=d+5,p();let y=Wt(m,!1,!0);f.set(y.name,y),c.push(y)}else{l=d;let y=Lt(m,"const",!1);for(let C=0;C<y.length;C++)f.set(y[C].name,y[C])}}else l++,ee();else if(h===101&&P("enum")){let d=Wt(m,!1,!1);f.set(d.name,d),c.push(d)}else if(h===108&&P("let"))ee();else if(h===118&&P("var"))ee();else if(h===109&&P("module")&&F(6)){let d=Bt(m,!1,"module");c.push(d)}else if(h===110&&P("namespace")&&F(9)){let d=Bt(m,!1,"namespace");c.push(d)}else{let d=i.charCodeAt(l);if(d===Y)l++;else if(d===te||d===se){if(b(d),l<a&&i.charCodeAt(l)===Y)l++}else if(d===Ae){if(w(),l<a&&i.charCodeAt(l)===Y)l++}else if(d===pf){if(l++,W(),p(),l<a&&i.charCodeAt(l)===ft)l++,W(),p();if(l<a&&i.charCodeAt(l)===Q)Oe(Q,we)}else l++,ee()}}if(f.size>0)wf(c,f);if(u.size>0){let m=new Map;for(let d of c)if(d.kind==="function")m.set(d.name,(m.get(d.name)||0)+1);let h=new Set;for(let[d,y]of m)if(y>1)h.add(d);if(h.size>0){let d=new Set;for(let y of h)for(let C=c.length-1;C>=0;C--)if(c[C].kind==="function"&&c[C].name===y&&u.has(C)){d.add(C);break}if(d.size>0){let y=[...d].sort((C,E)=>E-C);for(let C of y)c.splice(C,1)}}}return c;function Os(m,h){if(P("function")){let d=St(m,h,!1,!1);if(d)c.push(d)}else if(P("async")){if(l+=5,p(),P("function")){let d=St(m,h,!0,!1);if(d)c.push(d)}}else if(P("class")){let d=$t(m,h,!1);c.push(d)}else if(P("abstract")){if(l+=8,p(),P("class")){let d=$t(m,h,!0);c.push(d)}}else if(P("interface")){let d=Ui(m,h);c.push(d)}else if(P("type")){let d=Ki(m,h);c.push(d)}else if(P("enum")){let d=Wt(m,h,!1);c.push(d)}else if(P("const")){let d=l;if(l+=5,p(),P("enum")){l=d+5,p();let y=Wt(m,h,!0);c.push(y)}else if(h){l=d;let y=Lt(m,"const",!0);for(let C=0;C<y.length;C++)c.push(y[C])}else ee()}else if(P("let")||P("var"))if(h){let d=P("let")?"let":"var",y=Lt(m,d,!0);for(let C=0;C<y.length;C++)c.push(y[C])}else ee();else if(P("module")){let d=Bt(m,h,"module");c.push(d)}else if(P("namespace")){let d=Bt(m,h,"namespace");c.push(d)}else if(P("global")){l+=6,p();let d=`declare global ${l<a&&i.charCodeAt(l)===V?qi():"{}"}`,y=qe(m);c.push({kind:"module",name:"global",text:d,isExported:!1,leadingComments:y,start:m,end:l})}else ee()}}function io(e,t){let r=0,n=e.length;while(r<n){let i=e.charCodeAt(r);if(i>=65&&i<=90||i>=97&&i<=122||i===95||i===36||i>127){let s=r;r++;while(r<n){let o=e.charCodeAt(r);if(o>=65&&o<=90||o>=97&&o<=122||o>=48&&o<=57||o===95||o===36||o>127)r++;else break}t.add(e.substring(s,r))}else r++}}function no(e,t){let r=0;while(r<e.length){let n=e.charCodeAt(r);if(n===te||n===se||n===Ae){let u=n;r++;while(r<e.length)if(e.charCodeAt(r)===Ue)r+=2;else if(e.charCodeAt(r++)===u)break;continue}if(n===H&&e.charCodeAt(r+1)===H){r+=2;while(r<e.length&&e.charCodeAt(r)!==oe&&e.charCodeAt(r)!==ye)r++;continue}if(n===H&&e.charCodeAt(r+1)===ge){let u=e.indexOf("*/",r+2);r=u===-1?e.length:u+2;continue}if(!kt(n)){r++;continue}let i=r++;while(r<e.length&&Ke(e.charCodeAt(r)))r++;let s=i-1,o=r;while(s>=0&&Me(e.charCodeAt(s)))s--;while(o<e.length&&Me(e.charCodeAt(o)))o++;let a=s>=0?e.charCodeAt(s):0,c=o<e.length?e.charCodeAt(o):0,f=i>=3&&e.slice(i-3,i)==="...";if(c===et||a===ft&&!f)continue;if(c===Q&&(a===V||a===tt))continue;t.add(e.slice(i,r))}}function wf(e,t){let r=new Set,n=new Set;for(let o of e)n.add(o.name);let i=new Set,s=[];for(let o=0;o<e.length;o++){let a=e[o];if(a.kind!=="import"){if(s.push(a.text),io(a.text,i),typeof a.value==="string")no(a.value,i)}}for(;;){let o=[];for(let[f,u]of t){if(r.has(f))continue;if(i.has(f)){if(!n.has(f))o.push(u),n.add(f);r.add(f)}}if(o.length===0)break;o.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<o.length&&(o[c].start??1/0)<=u)a.push(o[c++]);a.push(e[f])}while(c<o.length)a.push(o[c++]);e.length=0;for(let f=0;f<a.length;f++)e.push(a[f]);for(let f of o)if(f.kind!=="import"){if(s.push(f.text),io(f.text,i),typeof f.value==="string")no(f.value,i)}}}var Se=32,$e=9,oe=10,ye=13,H=47,ge=42,te=39,se=34,Ae=96,Ue=92,V=123,J=125,Q=40,we=41,ue=91,be=93,he=60,ne=62,Y=59,et=58,Ce=61,tt=44,ft=46,Vr=63,Ur=35,pf=64,so=36,gf=95,gn;var co=fe(()=>{pn();gn=["public","protected","private","readonly","override"]});function uo(e,t,r=!0,n=!1){if(Is(t))e=Ls(e);else if(Bs(t))e=Gs(e);let i=ar(e),s=`${t}:${r?1:0}:${n?1:0}`,o=Vt.get(s);if(o&&o.contentHash===i)return o.lastAccess=++fo,o.declarations;let a=n?oo(e,t,r):ao(e,t,r);if(Vt.set(s,{declarations:a,contentHash:i,lastAccess:++fo}),Vt.size>vf){let c=Math.max(1,Math.ceil(Vt.size*0.1)),f=[];for(let[u,l]of Vt)f.push([u,l.lastAccess]);f.sort((u,l)=>u[1]-l[1]);for(let u=0;u<c&&u<f.length;u++)Vt.delete(f[u][0])}return a}var vf=100,fo=0,Vt;var ho=fe(()=>{an();js();co();Yi();Vt=new Map});function zr(e,t,r=!0,n=!1){return uo(e,t,r,n)}var yn=fe(()=>{ho()});import{dirname as ip,relative as Ef,resolve as np}from"path";async function mo(e,t,r){let n=new Map,i=[],s=new Set,o=0,a=0,c=0,f=[];for(let k of e){let R=t.get(k);if(!R)continue;f.push({file:k,decls:zr(R,k,r.keepComments)})}for(let{file:k,decls:R}of f){o+=R.length;for(let I of R)if(I.kind==="import"){a++;let _=I.source||"";if(_.startsWith("."))continue;if(!n.has(_))n.set(_,{source:_,specifiers:new Map,isTypeOnly:I.isTypeOnly||!1,isSideEffect:I.isSideEffect||!1});let W=n.get(_);if(I.specifiers)for(let P of I.specifiers){let F=P.alias||P.name;if(!W.specifiers.has(F))W.specifiers.set(F,{name:P.name,alias:P.alias,isType:P.isType||!1})}if(!I.isTypeOnly)W.isTypeOnly=!1}else if(I.isExported||I.kind==="export"){if(c++,I.kind==="export"&&I.source&&(I.source.startsWith(".")||I.source.startsWith("/")))continue;if(I.name&&s.has(I.name))continue;if(I.name)s.add(I.name);i.push({declaration:I,file:k})}}let u=[];u.push("/**"),u.push(" * Bundled TypeScript declarations"),u.push(` * Generated from ${e.length} source files`),u.push(" */"),u.push("");let l=r.importOrder||["bun"],g=Array.from(n.values()),p=Array(g.length);for(let k=0;k<g.length;k++){let R=g[k].source,I=l.length;for(let _=0;_<l.length;_++)if(R.startsWith(l[_])){I=_;break}p[k]=I}let v=g.map((k,R)=>R);v.sort((k,R)=>{let I=p[k],_=p[R];if(I!==_)return I-_;return g[k].source.localeCompare(g[R].source)});let b=v.map((k)=>g[k]);for(let k of b)if(k.isSideEffect)u.push(`import '${k.source}';`);else if(k.specifiers.size>0){let R=Array.from(k.specifiers.values()).map((_)=>{let W=_.isType?"type ":"";return _.alias?`${W}${_.name} as ${_.alias}`:`${W}${_.name}`}),I=k.isTypeOnly?"type ":"";u.push(`import ${I}{ ${R.join(", ")} } from '${k.source}';`)}if(b.length>0)u.push("");let w=new Map;for(let{declaration:k,file:R}of i){if(!w.has(R))w.set(R,[]);w.get(R).push(k)}for(let[k,R]of w){let I=Ef(r.cwd,k);u.push(`// From: ${I}`);for(let _ of R){if(r.keepComments&&_.leadingComments)for(let W of _.leadingComments)u.push(W);u.push(po(_))}u.push("")}let T=u.join(`
72
+ `);return{content:T,files:e,declarationCount:o,importCount:a,exportCount:c,size:Buffer.byteLength(T,"utf8"),warnings:[]}}function po(e){if(e.text){let r=e.text.trim();if(e.isExported&&!r.startsWith("export"))r=`export ${r}`;if(!r.endsWith(";")&&!r.endsWith("}"))r+=";";return r}let t=[];if(e.isExported)t.push("export");if(e.isDefault)t.push("default");switch(e.kind){case"function":if(t.push("declare function"),t.push(e.name),e.generics)t.push(e.generics);if(t.push(`(${bf(e.parameters)})`),e.returnType)t.push(`: ${e.returnType}`);break;case"variable":if(t.push("declare const"),t.push(e.name),e.typeAnnotation)t.push(`: ${e.typeAnnotation}`);break;case"interface":if(t.push("interface"),t.push(e.name),e.generics)t.push(e.generics);if(e.extends)t.push(`extends ${e.extends}`);if(t.push("{"),e.members)for(let r of e.members)t.push(` ${r.name}${r.typeAnnotation?`: ${r.typeAnnotation}`:""};`);t.push("}");break;case"type":if(t.push("type"),t.push(e.name),e.generics)t.push(e.generics);t.push("="),t.push(e.typeAnnotation||"unknown");break;case"class":if(t.push("declare class"),t.push(e.name),e.generics)t.push(e.generics);if(e.extends)t.push(`extends ${e.extends}`);if(e.implements&&e.implements.length>0)t.push(`implements ${e.implements.join(", ")}`);if(t.push("{"),e.members)for(let r of e.members)t.push(` ${po(r)}`);t.push("}");break;case"enum":if(t.push("declare enum"),t.push(e.name),t.push("{"),e.members){let r=e.members.map((n)=>n.value!==void 0?`${n.name} = ${n.value}`:n.name);t.push(` ${r.join(`,
73
+ `)}`)}t.push("}");break;default:return e.text||""}return t.join(" ")}function bf(e){if(!e||e.length===0)return"";return e.map((t)=>{let r="";if(t.rest)r+="...";if(r+=t.name,t.optional)r+="?";if(t.type)r+=`: ${t.type}`;if(t.defaultValue)r+=` = ${t.defaultValue}`;return r}).join(", ")}var go=fe(()=>{yn()});import{existsSync as gr,mkdirSync as Sf,readFileSync as wn,renameSync as $f,rmSync as yo,statSync as Co,writeFileSync as wo}from"fs";import{join as vo,relative as Hr,resolve as Af}from"path";class vn{cacheDir;manifestPath;manifest=null;configHash;constructor(e){this.cacheDir=Af(e.cwd,Jr),this.manifestPath=vo(this.cacheDir,xf),this.configHash=this.hashConfig(e)}hashConfig(e){let 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((r)=>({pattern:typeof r.pattern==="string"?{kind:"string",value:r.pattern}:{kind:"regex",source:r.pattern.source,flags:r.pattern.flags},replacement:r.replacement,global:r.global,priority:r.priority,hasCondition:Boolean(r.condition)}))}:void 0,lineEnding:e.lineEnding,normalizeOutput:e.normalizeOutput,declarationOrder:e.declarationOrder,plugins:e.plugins?.map((r)=>({name:r.name,version:r.version,cacheKey:r.cacheKey}))};return String(ar(JSON.stringify(t)))}hashString(e){return String(ar(e))}load(){try{if(!gr(this.manifestPath))return!1;let e=wn(this.manifestPath,"utf-8"),t=JSON.parse(e);if(t.version!==Cn)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:Cn,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};if(this.manifest.updatedAt=Date.now(),!gr(this.cacheDir))Sf(this.cacheDir,{recursive:!0});let e=`${this.manifestPath}.${process.pid}.tmp`;try{wo(e,JSON.stringify(this.manifest,null,2)),$f(e,this.manifestPath)}finally{if(gr(e))yo(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 r=Hr(t,e),n=this.manifest.entries[r];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 i=Co(e),{mtimeMs:s,ctimeMs:o}=i;if(i.size!==n.sourceSize)return null;if(s!==n.sourceMtime||o!==n.sourceCtime){let a=wn(e,"utf-8");if(this.hashString(a)!==n.sourceHash)return null;n.sourceMtime=s,n.sourceCtime=o}return n.dtsContent}catch{return null}}update(e,t,r,n){if(!this.manifest)this.manifest={version:Cn,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};let i=Hr(n,e),s,o,a;try{let c=Co(e);s=c.mtimeMs,o=c.ctimeMs,a=c.size}catch{s=Date.now(),o=s,a=Buffer.byteLength(t)}this.manifest.entries[i]={sourcePath:i,sourceHash:this.hashString(t),sourceMtime:s,sourceCtime:o,sourceSize:a,dtsContent:r,dtsHash:this.hashString(r),generatedAt:Date.now(),configHash:this.configHash}}remove(e,t){if(!this.manifest)return;let r=Hr(t,e);delete this.manifest.entries[r]}clear(){this.manifest=null;try{if(gr(this.manifestPath))yo(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 r of Object.values(this.manifest.entries))t+=r.dtsContent.length;return{entries:e,size:t}}prune(e,t){if(!this.manifest)return 0;let r=0,n=new Set(Array.from(e).map((i)=>Hr(t,i)));for(let i of Object.keys(this.manifest.entries))if(!n.has(i))delete this.manifest.entries[i],r++;return r}}function Eo(e){let t=vo(e,".gitignore");try{let r="";if(gr(t))r=wn(t,"utf-8");if(!r.split(/\r?\n/).some((n)=>n.trim()===Jr||n.trim()===`${Jr}/`)){let n=r.trimEnd(),i=`${n}${n?`
73
74
 
74
75
  `:""}# dtsx cache
75
- ${Hr}/
76
- `;yo(t,i)}}catch{}}var gn=3,Hr=".dtsx-cache",Af="manifest.json";var vo=ce(()=>{Ji()});import{readFile as $f,stat as cp,writeFile as xf}from"fs/promises";async function Eo(e,t){if(zr)return globalThis.Bun.write(e,t);let r=typeof t==="string"?t:t instanceof ArrayBuffer?Buffer.from(t):t;return await xf(e,r),typeof t==="string"?Buffer.byteLength(t):t.byteLength}async function ht(e){if(zr)return globalThis.Bun.file(e).text();return $f(e,"utf-8")}var zr,fp;var Jr=ce(()=>{zr=typeof globalThis.Bun<"u",fp=!zr&&typeof process<"u"&&!!process.versions?.node});function Vt(e){return bo[e]>=bo[qr]}function Rf(){if(!Pf)return"";return`[${new Date().toISOString().slice(11,23)}] `}function Of(e,t){let r=Rf();if(e||r)return[`${r}${e}`,...t];return t}function Ut(e,t,r){let n=Of(t,r);if(So){So(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 Ao(e){return{debug:(...t)=>{if(Vt("debug"))Ut("debug",e,t)},info:(...t)=>{if(Vt("info"))Ut("info",e,t)},warn:(...t)=>{if(Vt("warn"))Ut("warn",e,t)},error:(...t)=>{if(Vt("error"))Ut("error",e,t)},setLevel:(t)=>{qr=t},getLevel:()=>qr,child:(t)=>{let r=e?`${e}:${t}`:`[${t}]`;return Ao(r)},time:(t)=>{let r=performance.now();return()=>{let n=performance.now()-r;if(Vt("debug"))Ut("debug",e,[`${t}: ${n.toFixed(2)}ms`])}},progress:(t)=>{if(Vt("info"))if(typeof process<"u"&&process.stdout?.isTTY)process.stdout.write(`\r${e} ${t}`);else Ut("info",e,[t])}}}function wn(e){qr=e}var bo,qr="info",Tf="[dtsx]",Pf=!1,So=null,K;var $o=ce(()=>{bo={debug:0,info:1,warn:2,error:3,silent:4};K=Ao(Tf)});import kf from"process";import{existsSync as xo,statSync as To}from"fs";import{existsSync as Mf,mkdirSync as gp,readdirSync as yp,readFileSync as Df,writeFileSync as Cp}from"fs";import{homedir as Kt}from"os";import{dirname as Ep,resolve as tt}from"path";import Ri from"process";import{existsSync as Po,statSync as Ro}from"fs";import{existsSync as Bn,mkdirSync as If,readdirSync as Ff,writeFileSync as Nf}from"fs";import{homedir as Ht}from"os";import{dirname as Oo,resolve as Ke}from"path";import kt from"process";import{join as Lf,relative as Wf,resolve as ko}from"path";import pi from"process";import{existsSync as ha,mkdirSync as kp,readdirSync as Mp,writeFileSync as Dp}from"fs";import{homedir as vn}from"os";import{dirname as Np,resolve as Ue}from"path";import yr from"process";import{join as Bf,relative as Gf,resolve as Mo}from"path";import gi from"process";import{existsSync as da,mkdirSync as jp,readdirSync as _p,writeFileSync as Vp}from"fs";import{dirname as Kp,resolve as yi}from"path";import Gn from"process";import{Buffer as At}from"buffer";import{createCipheriv as jf,createDecipheriv as _f,randomBytes as En}from"crypto";import{closeSync as bn,createReadStream as Do,createWriteStream as Vf,existsSync as Sn,fsyncSync as Io,openSync as Fo,writeFileSync as Uf}from"fs";import{access as Kf,constants as No,mkdir as Hf,readdir as Yr,rename as Lo,stat as zt,unlink as Zr,writeFile as An}from"fs/promises";import{join as Jt}from"path";import Be from"process";import{pipeline as zf}from"stream/promises";import{createGzip as Wo}from"zlib";import qt from"process";import gt from"process";import{Buffer as dt}from"buffer";import{createCipheriv as Jf,createDecipheriv as qf,randomBytes as $n}from"crypto";import{closeSync as xn,createReadStream as Bo,createWriteStream as Yf,existsSync as Xr,fsyncSync as Go,openSync as jo,writeFileSync as Zf}from"fs";import{access as Xf,constants as _o,mkdir as Qf,readdir as Qr,rename as Vo,stat as Yt,unlink as ei,writeFile as Tn}from"fs/promises";import{isAbsolute as eu,join as Zt,resolve as tu}from"path";import ue from"process";import{pipeline as ru}from"stream/promises";import{createGzip as Uo}from"zlib";import Xt from"process";import yt from"process";import ti from"process";import{existsSync as ri}from"fs";import{resolve as Pn}from"path";import{existsSync as iu}from"fs";import{existsSync as nu,readdirSync as su}from"fs";import{extname as Rn,resolve as Ko}from"path";import ou from"process";import{join as au,relative as lu,resolve as Ho}from"path";import Ci from"process";import{Buffer as mt}from"buffer";import{createCipheriv as cu,createDecipheriv as fu,randomBytes as On}from"crypto";import{closeSync as kn,createReadStream as zo,createWriteStream as uu,existsSync as ii,fsyncSync as Jo,openSync as qo,writeFileSync as hu}from"fs";import{access as du,constants as Yo,mkdir as mu,readdir as ni,rename as Zo,stat as Qt,unlink as si,writeFile as Mn}from"fs/promises";import{isAbsolute as pu,join as er,resolve as gu}from"path";import he from"process";import{pipeline as yu}from"stream/promises";import{createGzip as Xo}from"zlib";import tr from"process";import Ct from"process";import oi from"process";import{existsSync as ai}from"fs";import{resolve as Dn}from"path";import{existsSync as Cu}from"fs";class ma{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 r=t?`:${t}`:"";return`${this.options.keyPrefix}${e}${r}`}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(([,r],[,n])=>r.timestamp.getTime()-n.timestamp.getTime()),t=e.length-this.options.maxSize+1;for(let r=0;r<t;r++)this.cache.delete(e[r][0])}set(e,t,r,n){if(!this.options.enabled)return;let i=this.generateKey(e,r),s=n??this.options.ttl,o=this.estimateSize(t);this.cache.set(i,{value:t,timestamp:new Date,ttl:s,hits:0,size:o}),this.evictIfNeeded()}get(e,t){if(!this.options.enabled){this.totalMisses++;return}let r=this.generateKey(e,t),n=this.cache.get(r);if(!n){this.totalMisses++;return}if(this.isExpired(n)){this.cache.delete(r),this.totalMisses++;return}return n.hits++,this.totalHits++,n.value}isFileModified(e,t){try{if(!xo(e))return!0;return To(e).mtime>t}catch{return!0}}getWithFileCheck(e,t){let r=this.get(e,t);if(!r)return;if(this.isFileModified(t,r.fileTimestamp)){this.delete(e,t);return}return r.value}setWithFileCheck(e,t,r,n){try{let i=xo(r)?To(r):null,s=i?i.mtime:new Date;this.set(e,{value:t,fileTimestamp:s},r,n)}catch{this.set(e,t,r,n)}}delete(e,t){let r=this.generateKey(e,t);return this.cache.delete(r)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let e=0;for(let[t,r]of this.cache.entries())if(this.isExpired(r))this.cache.delete(t),e++;return e}getStats(){let e=Array.from(this.cache.values()),t=e.reduce((n,i)=>n+i.size,0),r=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:r[0],newestEntry:r[r.length-1]}}export(){let e={};for(let[t,r]of this.cache.entries())e[t]={value:r.value,timestamp:r.timestamp.toISOString(),ttl:r.ttl,hits:r.hits,size:r.size};return e}import(e){this.cache.clear();for(let[t,r]of Object.entries(e))if(typeof r==="object"&&r!==null){let n=r;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,r={}){let n=performance.now(),i=new Date;try{let s=await t(),o=performance.now()-n;return this.recordMetric({operation:e,duration:o,timestamp:i,...r}),s}catch(s){let o=performance.now()-n;throw this.recordMetric({operation:`${e}:error`,duration:o,timestamp:i,...r}),s}}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((i)=>i.operation===e):this.metrics;if(t.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let r=t.map((i)=>i.duration),n=r.reduce((i,s)=>i+s,0);return{count:t.length,averageDuration:n/t.length,minDuration:Math.min(...r),maxDuration:Math.max(...r),totalDuration:n,recentMetrics:t.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((t)=>t.duration>e)}}function Eu(e,t){this[e]=vu.bind(null,t)}class Xn{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 r=t?`:${t}`:"";return`${this.options.keyPrefix}${e}${r}`}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(([,r],[,n])=>r.timestamp.getTime()-n.timestamp.getTime()),t=e.length-this.options.maxSize+1;for(let r=0;r<t;r++)this.cache.delete(e[r][0])}set(e,t,r,n){if(!this.options.enabled)return;let i=this.generateKey(e,r),s=n??this.options.ttl,o=this.estimateSize(t);this.cache.set(i,{value:t,timestamp:new Date,ttl:s,hits:0,size:o}),this.evictIfNeeded()}get(e,t){if(!this.options.enabled){this.totalMisses++;return}let r=this.generateKey(e,t),n=this.cache.get(r);if(!n){this.totalMisses++;return}if(this.isExpired(n)){this.cache.delete(r),this.totalMisses++;return}return n.hits++,this.totalHits++,n.value}isFileModified(e,t){try{if(!Po(e))return!0;return Ro(e).mtime>t}catch{return!0}}getWithFileCheck(e,t){let r=this.get(e,t);if(!r)return;if(this.isFileModified(t,r.fileTimestamp)){this.delete(e,t);return}return r.value}setWithFileCheck(e,t,r,n){try{let i=Po(r)?Ro(r):null,s=i?i.mtime:new Date;this.set(e,{value:t,fileTimestamp:s},r,n)}catch{this.set(e,t,r,n)}}delete(e,t){let r=this.generateKey(e,t);return this.cache.delete(r)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let e=0;for(let[t,r]of this.cache.entries())if(this.isExpired(r))this.cache.delete(t),e++;return e}getStats(){let e=Array.from(this.cache.values()),t=e.reduce((n,i)=>n+i.size,0),r=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:r[0],newestEntry:r[r.length-1]}}export(){let e={};for(let[t,r]of this.cache.entries())e[t]={value:r.value,timestamp:r.timestamp.toISOString(),ttl:r.ttl,hits:r.hits,size:r.size};return e}import(e){this.cache.clear();for(let[t,r]of Object.entries(e))if(typeof r==="object"&&r!==null){let n=r;this.cache.set(t,{value:n.value,timestamp:new Date(n.timestamp),ttl:n.ttl,hits:n.hits,size:n.size})}}}class Qn{metrics=[];maxMetrics=1000;async track(e,t,r={}){let n=performance.now(),i=new Date;try{let s=await t(),o=performance.now()-n;return this.recordMetric({operation:e,duration:o,timestamp:i,...r}),s}catch(s){let o=performance.now()-n;throw this.recordMetric({operation:`${e}:error`,duration:o,timestamp:i,...r}),s}}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((i)=>i.operation===e):this.metrics;if(t.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let r=t.map((i)=>i.duration),n=r.reduce((i,s)=>i+s,0);return{count:t.length,averageDuration:n/t.length,minDuration:Math.min(...r),maxDuration:Math.max(...r),totalDuration:n,recentMetrics:t.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((t)=>t.duration>e)}}function Au(e,t={}){let r=Object.keys(t).sort().map((n)=>`${n}:${t[n]}`).join("|");return r?`${e}:${r}`:e}function $u(e,t){try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}}function xu(e){return e.getStats().size*2}function es(e,t){if(Array.isArray(t)&&Array.isArray(e)&&t.length===2&&e.length===2&&Ee(t[0])&&"id"in t[0]&&t[0].id===3&&Ee(t[1])&&"id"in t[1]&&t[1].id===4)return t;if(Ee(t)&&Ee(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(Ee(e)&&"arr"in e&&Array.isArray(e.arr)&&Ee(t)&&"arr"in t&&Array.isArray(t.arr))return t;if(t.length>0&&e.length>0&&Ee(t[0])&&Ee(e[0])){let n=[...t];for(let i of e)if(Ee(i)&&"name"in i){if(!n.find((s)=>Ee(s)&&("name"in s)&&s.name===i.name))n.push(i)}else if(Ee(i)&&"path"in i){if(!n.find((s)=>Ee(s)&&("path"in s)&&s.path===i.path))n.push(i)}else if(!n.some((s)=>vi(s,i)))n.push(i);return n}if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let i of e)if(!n.includes(i))n.push(i);return n}return t}if(!Ee(t)||!Ee(e))return t;let r={...e};for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)){let i=t[n];if(i===null||i===void 0)continue;else if(Ee(i)&&Ee(r[n]))r[n]=es(r[n],i);else if(Array.isArray(i)&&Array.isArray(r[n]))if(i.length>0&&r[n].length>0&&Ee(i[0])&&Ee(r[n][0])){let s=[...i];for(let o of r[n])if(Ee(o)&&"name"in o){if(!s.find((a)=>Ee(a)&&("name"in a)&&a.name===o.name))s.push(o)}else if(Ee(o)&&"path"in o){if(!s.find((a)=>Ee(a)&&("path"in a)&&a.path===o.path))s.push(o)}else if(!s.some((a)=>vi(a,o)))s.push(o);r[n]=s}else if(i.every((s)=>typeof s==="string")&&r[n].every((s)=>typeof s==="string")){let s=[...i];for(let o of r[n])if(!s.includes(o))s.push(o);r[n]=s}else r[n]=i;else r[n]=i}return r}function vi(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!vi(e[r],t[r]))return!1;return!0}if(Ee(e)&&Ee(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!vi(e[i],t[i]))return!1}return!0}return!1}function Ee(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function Tu(e,t){if(!da(e))return null;try{let r=await import(e),n=r.default||r;if(typeof n!=="object"||n===null||Array.isArray(n))return null;try{return es(t,n)}catch{return null}}catch{return null}}async function Pu({name:e="",cwd:t,defaultConfig:r}){let n=t||Gn.cwd(),i=[".ts",".js",".mjs",".cjs",".json"],s=[`${e}.config`,`.${e}.config`,e,`.${e}`];for(let o of s)for(let a of i){let c=yi(n,`${o}${a}`),f=await Tu(c,r);if(f!==null)return f}try{let o=yi(n,"package.json");if(da(o)){let a=(await import(o))[e];if(a&&typeof a==="object"&&!Array.isArray(a))try{return es(r,a)}catch{}}}catch{}return r}function Ru(e,t={}){let r=gi.cwd();while(r.includes("storage"))r=Mo(r,"..");let n=Mo(r,e||"");if(t?.relative)return Gf(gi.cwd(),n);return n}async function Ou(){try{let e=await Pu({name:"clarity",defaultConfig:ui,cwd:gi.cwd(),endpoint:"",headers:{}});return{...ui,...e}}catch{return ui}}function xe(){if(gt.env.NODE_ENV==="test"||gt.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function ku(){if(gt.env.NODE_ENV==="test"||gt.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof gt<"u"){let e=gt.type;if(e==="renderer"||e==="worker")return!1;return!!(gt.versions&&(gt.versions.node||gt.versions.bun))}return!1}class ya{async format(e){let t=await ku(),r=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:r})}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 Ei{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={..._n},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??Be.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let r={...t},n=t.timestamp!==void 0;if(n)delete r.timestamp;if(this.config={...this.config,...r,timestamp:n||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let i=this.generateKeyId(),s=this.generateKey();this.currentKeyId=i,this.keys.set(i,s),this.encryptionKeys.set(i,{key:s,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...hi,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...hi};return{...hi,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:_n.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},r={...t,...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))};if(!r.level||!["debug","info","success","warning","error"].includes(r.level))r.level=t.level;return r}async writeToFile(e){let t=(async()=>{let n,i=0,s=3,o=1000;while(i<s)try{try{try{await Kf(this.config.logDirectory,No.F_OK|No.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await Hf(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:At.from(e);try{if(!Sn(this.currentLogFile))await An(this.currentLogFile,"",{mode:420});if(n=Fo(this.currentLogFile,"a",420),Uf(n,a,{flag:"a"}),Io(n),n!==void 0)bn(n),n=void 0;if((await zt(this.currentLogFile)).size===0){if(await An(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(i<s-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${i+1}/${s}:`,u);let l=o*2**i;await new Promise((g)=>setTimeout(g,l)),i++;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{bn(n)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(a){if(i===s-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}i++;let c=o*2**(i-1);await new Promise((f)=>setTimeout(f,c))}})();this.pendingOperations.push(t);let r=this.pendingOperations.length-1;try{await t}catch(n){throw console.error("Debug: [writeToFile] Error in operation:",n),n}finally{this.pendingOperations.splice(r,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 Jt(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 Jt(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return Jt(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(xe())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,t;switch(e.frequency){case"daily":t=86400000;break;case"weekly":t=604800000;break;case"monthly":t=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},t)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let e=this.config.rotation.keyRotation;if(!e?.enabled)return;let t=typeof e.interval==="number"?e.interval:60,r=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((n)=>{console.error("Error rotating keys:",n)})},r)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let e=this.config.rotation.keyRotation,t=this.generateKeyId(),r=this.generateKey();this.currentKeyId=t,this.keys.set(t,r),this.encryptionKeys.set(t,{key:r,createdAt:new Date});let n=Array.from(this.encryptionKeys.entries()).sort(([,o],[,a])=>a.createdAt.getTime()-o.createdAt.getTime()),i=typeof e.maxKeys==="number"?e.maxKeys:1,s=Math.max(1,i);if(n.length>s)for(let[o]of n.slice(s))this.encryptionKeys.delete(o),this.keys.delete(o)}generateKeyId(){return En(16).toString("hex")}generateKey(){return En(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(),r=En(16),n=jf("aes-256-gcm",t,r),i=At.concat([n.update(e,"utf8"),n.final()]),s=n.getAuthTag();return{encrypted:At.concat([r,i,s]),iv:r}}async compressData(e){return new Promise((t,r)=>{let n=Wo(),i=[];n.on("data",(s)=>i.push(s)),n.on("end",()=>t(At.from(At.concat(i)))),n.on("error",r),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(xe())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 r=this.currentLogFile,n=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let i=await Yr(this.config.logDirectory),s=i.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}),o=s.length>0?Number.parseInt(s[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,a=`${r}.${o}`;if(await zt(r).catch(()=>null))try{if(await Lo(r,a),t.compress)try{let c=`${a}.gz`;await this.compressLogFile(a,c),await Zr(a)}catch(c){console.error("Error compressing rotated file:",c)}if(s.length===0&&!i.some((c)=>c.endsWith(".log.1")))try{let c=`${r}.1`;await An(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 i=new Date().toISOString().replace(/[:.]/g,"-"),s=r.replace(/\.log$/,`-${i}.log`);if(await zt(r).catch(()=>null))await Lo(r,s)}if(this.currentLogFile=n,t.maxFiles){let i=(await Yr(this.config.logDirectory)).filter((s)=>s.startsWith(this.name)).sort((s,o)=>o.localeCompare(s));for(let s of i.slice(t.maxFiles))await Zr(Jt(this.config.logDirectory,s))}}}async compressLogFile(e,t){let r=Do(e),n=Vf(t),i=Wo();await zf(r,i,n)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let r of this.logBuffer){let n=await this.formatter.format(r);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 r={timestamp:new Date,level:e,message:t,name:this.name};this.logBuffer.push(r)}}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()})),Sn(this.currentLogFile))try{let e=Fo(this.currentLogFile,"r+");Io(e),bn(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!xe()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await Yr(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await Zr(Jt(this.config.logDirectory,t))}catch(r){console.error(`Failed to delete temp file ${t}:`,r)}}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?Ce.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}formatConsoleMessage(e){let{timestamp:t,icon:r="",tag:n="",message:i,level:s,showTimestamp:o=!0}=e,a=(d)=>d.replace(this.ANSI_PATTERN,"");if(!this.fancy){let d=[];if(o)d.push(t);if(s==="warning")d.push("WARN");else if(s==="error")d.push("ERROR");else if(r)d.push(r.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(n)d.push(n.replace(/[[\]]/g,""));return d.push(i),d.join(" ")}let c=Be.stdout.columns||120,f="";if(s==="warning"||s==="error")f=`${r} ${i}`;else if(s==="info"||s==="success")f=`${r} ${n} ${i}`;else f=`${r} ${n} ${Ce.cyan(i)}`;if(!o)return f.trim();let u=a(f).trim().length,l=a(t).length,g=Math.max(1,c-2-u-l);return`${f.trim()}${" ".repeat(g)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(s,o)=>{let a=Number.parseInt(o,10);return a<t[0].length?String(t[0][a]):s});let r=/%([sdijfo%])/g,n=0,i=e.replace(r,(s,o)=>{if(o==="%")return"%";if(n>=t.length)return s;let a=t[n++];switch(o){case"s":return String(a);case"d":case"i":return Number(a).toString();case"j":case"o":return JSON.stringify(a,null,2);default:return s}});if(n<t.length)i+=` ${t.slice(n).map((s)=>typeof s==="object"?JSON.stringify(s,null,2):String(s)).join(" ")}`;return i}async log(e,t,...r){let n=new Date,i=this.formatConsoleTimestamp(n),s=this.formatFileTimestamp(n),o,a;if(t instanceof Error)o=t.message,a=t.stack;else o=this.formatMessage(t,r);if(this.fancy&&!xe()){let f=Ta[e],u=this.options.showTags!==!1&&this.name?Ce.gray(this.formatTag(this.name)):"",l;switch(e){case"debug":l=this.formatConsoleMessage({timestamp:i,icon:f,tag:u,message:Ce.gray(o),level:e}),console.error(l);break;case"info":l=this.formatConsoleMessage({timestamp:i,icon:f,tag:u,message:o,level:e}),console.error(l);break;case"success":l=this.formatConsoleMessage({timestamp:i,icon:f,tag:u,message:Ce.green(o),level:e}),console.error(l);break;case"warning":l=this.formatConsoleMessage({timestamp:i,icon:f,tag:u,message:o,level:e}),console.warn(l);break;case"error":if(l=this.formatConsoleMessage({timestamp:i,icon:f,tag:u,message:o,level:e}),console.error(l),a){let g=a.split(`
77
- `);for(let d of g)if(d.trim()&&!d.includes(o))console.error(this.formatConsoleMessage({timestamp:i,message:Ce.gray(` ${d}`),level:e,showTimestamp:!1}))}break}}else if(!xe()){if(console.error(`${s} ${this.environment}.${e.toUpperCase()}: ${o}`),a)console.error(a)}if(!this.shouldLog(e))return;let c=`${s} ${this.environment}.${e.toUpperCase()}: ${o}
76
+ ${Jr}/
77
+ `;wo(t,i)}}catch{}}var Cn=3,Jr=".dtsx-cache",xf="manifest.json";var bo=fe(()=>{Yi()});import{readFile as Tf,stat as up,writeFile as Pf}from"fs/promises";async function So(e,t){if(qr)return globalThis.Bun.write(e,t);let r=typeof t==="string"?t:t instanceof ArrayBuffer?Buffer.from(t):t;return await Pf(e,r),typeof t==="string"?Buffer.byteLength(t):t.byteLength}async function dt(e){if(qr)return globalThis.Bun.file(e).text();return Tf(e,"utf-8")}var qr,hp;var Yr=fe(()=>{qr=typeof globalThis.Bun<"u",hp=!qr&&typeof process<"u"&&!!process.versions?.node});function Ut(e){return $o[e]>=$o[Zr]}function kf(){if(!Of)return"";return`[${new Date().toISOString().slice(11,23)}] `}function Mf(e,t){let r=kf();if(e||r)return[`${r}${e}`,...t];return t}function Kt(e,t,r){let n=Mf(t,r);if(Ao){Ao(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 xo(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)=>{Zr=t},getLevel:()=>Zr,child:(t)=>{let r=e?`${e}:${t}`:`[${t}]`;return xo(r)},time:(t)=>{let r=performance.now();return()=>{let n=performance.now()-r;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 En(e){Zr=e}var $o,Zr="info",Rf="[dtsx]",Of=!1,Ao=null,K;var To=fe(()=>{$o={debug:0,info:1,warn:2,error:3,silent:4};K=xo(Rf)});import Df from"process";import{existsSync as Po,statSync as Ro}from"fs";import{existsSync as If,mkdirSync as Cp,readdirSync as wp,readFileSync as Ff,writeFileSync as vp}from"fs";import{homedir as zt}from"os";import{dirname as Sp,resolve as rt}from"path";import ki from"process";import{existsSync as Oo,statSync as ko}from"fs";import{existsSync as jn,mkdirSync as Nf,readdirSync as Lf,writeFileSync as Wf}from"fs";import{homedir as Ht}from"os";import{dirname as Mo,resolve as He}from"path";import Mt from"process";import{join as Bf,relative as Gf,resolve as Do}from"path";import yi from"process";import{existsSync as ma,mkdirSync as Dp,readdirSync as Ip,writeFileSync as Fp}from"fs";import{homedir as bn}from"os";import{dirname as Wp,resolve as ze}from"path";import Cr from"process";import{join as jf,relative as _f,resolve as Io}from"path";import Ci from"process";import{existsSync as pa,mkdirSync as Vp,readdirSync as Up,writeFileSync as Kp}from"fs";import{dirname as Hp,resolve as wi}from"path";import _n from"process";import{Buffer as At}from"buffer";import{createCipheriv as Vf,createDecipheriv as Uf,randomBytes as Sn}from"crypto";import{closeSync as $n,createReadStream as Fo,createWriteStream as Kf,existsSync as An,fsyncSync as No,openSync as Lo,writeFileSync as zf}from"fs";import{access as Hf,constants as Wo,mkdir as Jf,readdir as Xr,rename as Bo,stat as Jt,unlink as Qr,writeFile as xn}from"fs/promises";import{join as qt}from"path";import We from"process";import{pipeline as qf}from"stream/promises";import{createGzip as Go}from"zlib";import Yt from"process";import yt from"process";import{Buffer as mt}from"buffer";import{createCipheriv as Yf,createDecipheriv as Zf,randomBytes as Tn}from"crypto";import{closeSync as Pn,createReadStream as jo,createWriteStream as Xf,existsSync as ei,fsyncSync as _o,openSync as Vo,writeFileSync as Qf}from"fs";import{access as eu,constants as Uo,mkdir as tu,readdir as ti,rename as Ko,stat as Zt,unlink as ri,writeFile as Rn}from"fs/promises";import{isAbsolute as ru,join as Xt,resolve as iu}from"path";import de from"process";import{pipeline as nu}from"stream/promises";import{createGzip as zo}from"zlib";import Qt from"process";import Ct from"process";import ii from"process";import{existsSync as ni}from"fs";import{resolve as On}from"path";import{existsSync as su}from"fs";import{existsSync as ou,readdirSync as au}from"fs";import{extname as kn,resolve as Ho}from"path";import lu from"process";import{join as cu,relative as fu,resolve as Jo}from"path";import vi from"process";import{Buffer as pt}from"buffer";import{createCipheriv as uu,createDecipheriv as hu,randomBytes as Mn}from"crypto";import{closeSync as Dn,createReadStream as qo,createWriteStream as du,existsSync as si,fsyncSync as Yo,openSync as Zo,writeFileSync as mu}from"fs";import{access as pu,constants as Xo,mkdir as gu,readdir as oi,rename as Qo,stat as er,unlink as ai,writeFile as In}from"fs/promises";import{isAbsolute as yu,join as tr,resolve as Cu}from"path";import me from"process";import{pipeline as wu}from"stream/promises";import{createGzip as ea}from"zlib";import rr from"process";import wt from"process";import li from"process";import{existsSync as ci}from"fs";import{resolve as Fn}from"path";import{existsSync as vu}from"fs";class ga{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 r=t?`:${t}`:"";return`${this.options.keyPrefix}${e}${r}`}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(([,r],[,n])=>r.timestamp.getTime()-n.timestamp.getTime()),t=e.length-this.options.maxSize+1;for(let r=0;r<t;r++)this.cache.delete(e[r][0])}set(e,t,r,n){if(!this.options.enabled)return;let i=this.generateKey(e,r),s=n??this.options.ttl,o=this.estimateSize(t);this.cache.set(i,{value:t,timestamp:new Date,ttl:s,hits:0,size:o}),this.evictIfNeeded()}get(e,t){if(!this.options.enabled){this.totalMisses++;return}let r=this.generateKey(e,t),n=this.cache.get(r);if(!n){this.totalMisses++;return}if(this.isExpired(n)){this.cache.delete(r),this.totalMisses++;return}return n.hits++,this.totalHits++,n.value}isFileModified(e,t){try{if(!Po(e))return!0;return Ro(e).mtime>t}catch{return!0}}getWithFileCheck(e,t){let r=this.get(e,t);if(!r)return;if(this.isFileModified(t,r.fileTimestamp)){this.delete(e,t);return}return r.value}setWithFileCheck(e,t,r,n){try{let i=Po(r)?Ro(r):null,s=i?i.mtime:new Date;this.set(e,{value:t,fileTimestamp:s},r,n)}catch{this.set(e,t,r,n)}}delete(e,t){let r=this.generateKey(e,t);return this.cache.delete(r)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let e=0;for(let[t,r]of this.cache.entries())if(this.isExpired(r))this.cache.delete(t),e++;return e}getStats(){let e=Array.from(this.cache.values()),t=e.reduce((n,i)=>n+i.size,0),r=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:r[0],newestEntry:r[r.length-1]}}export(){let e={};for(let[t,r]of this.cache.entries())e[t]={value:r.value,timestamp:r.timestamp.toISOString(),ttl:r.ttl,hits:r.hits,size:r.size};return e}import(e){this.cache.clear();for(let[t,r]of Object.entries(e))if(typeof r==="object"&&r!==null){let n=r;this.cache.set(t,{value:n.value,timestamp:new Date(n.timestamp),ttl:n.ttl,hits:n.hits,size:n.size})}}}class ya{metrics=[];maxMetrics=1000;async track(e,t,r={}){let n=performance.now(),i=new Date;try{let s=await t(),o=performance.now()-n;return this.recordMetric({operation:e,duration:o,timestamp:i,...r}),s}catch(s){let o=performance.now()-n;throw this.recordMetric({operation:`${e}:error`,duration:o,timestamp:i,...r}),s}}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((i)=>i.operation===e):this.metrics;if(t.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let r=t.map((i)=>i.duration),n=r.reduce((i,s)=>i+s,0);return{count:t.length,averageDuration:n/t.length,minDuration:Math.min(...r),maxDuration:Math.max(...r),totalDuration:n,recentMetrics:t.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((t)=>t.duration>e)}}function Su(e,t){this[e]=bu.bind(null,t)}class es{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 r=t?`:${t}`:"";return`${this.options.keyPrefix}${e}${r}`}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(([,r],[,n])=>r.timestamp.getTime()-n.timestamp.getTime()),t=e.length-this.options.maxSize+1;for(let r=0;r<t;r++)this.cache.delete(e[r][0])}set(e,t,r,n){if(!this.options.enabled)return;let i=this.generateKey(e,r),s=n??this.options.ttl,o=this.estimateSize(t);this.cache.set(i,{value:t,timestamp:new Date,ttl:s,hits:0,size:o}),this.evictIfNeeded()}get(e,t){if(!this.options.enabled){this.totalMisses++;return}let r=this.generateKey(e,t),n=this.cache.get(r);if(!n){this.totalMisses++;return}if(this.isExpired(n)){this.cache.delete(r),this.totalMisses++;return}return n.hits++,this.totalHits++,n.value}isFileModified(e,t){try{if(!Oo(e))return!0;return ko(e).mtime>t}catch{return!0}}getWithFileCheck(e,t){let r=this.get(e,t);if(!r)return;if(this.isFileModified(t,r.fileTimestamp)){this.delete(e,t);return}return r.value}setWithFileCheck(e,t,r,n){try{let i=Oo(r)?ko(r):null,s=i?i.mtime:new Date;this.set(e,{value:t,fileTimestamp:s},r,n)}catch{this.set(e,t,r,n)}}delete(e,t){let r=this.generateKey(e,t);return this.cache.delete(r)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let e=0;for(let[t,r]of this.cache.entries())if(this.isExpired(r))this.cache.delete(t),e++;return e}getStats(){let e=Array.from(this.cache.values()),t=e.reduce((n,i)=>n+i.size,0),r=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:r[0],newestEntry:r[r.length-1]}}export(){let e={};for(let[t,r]of this.cache.entries())e[t]={value:r.value,timestamp:r.timestamp.toISOString(),ttl:r.ttl,hits:r.hits,size:r.size};return e}import(e){this.cache.clear();for(let[t,r]of Object.entries(e))if(typeof r==="object"&&r!==null){let n=r;this.cache.set(t,{value:n.value,timestamp:new Date(n.timestamp),ttl:n.ttl,hits:n.hits,size:n.size})}}}class ts{metrics=[];maxMetrics=1000;async track(e,t,r={}){let n=performance.now(),i=new Date;try{let s=await t(),o=performance.now()-n;return this.recordMetric({operation:e,duration:o,timestamp:i,...r}),s}catch(s){let o=performance.now()-n;throw this.recordMetric({operation:`${e}:error`,duration:o,timestamp:i,...r}),s}}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((i)=>i.operation===e):this.metrics;if(t.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let r=t.map((i)=>i.duration),n=r.reduce((i,s)=>i+s,0);return{count:t.length,averageDuration:n/t.length,minDuration:Math.min(...r),maxDuration:Math.max(...r),totalDuration:n,recentMetrics:t.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((t)=>t.duration>e)}}function xu(e,t={}){let r=Object.keys(t).sort().map((n)=>`${n}:${t[n]}`).join("|");return r?`${e}:${r}`:e}function Tu(e,t){try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}}function Pu(e){return e.getStats().size*2}function rs(e,t){if(Array.isArray(t)&&Array.isArray(e)&&t.length===2&&e.length===2&&Ee(t[0])&&"id"in t[0]&&t[0].id===3&&Ee(t[1])&&"id"in t[1]&&t[1].id===4)return t;if(Ee(t)&&Ee(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(Ee(e)&&"arr"in e&&Array.isArray(e.arr)&&Ee(t)&&"arr"in t&&Array.isArray(t.arr))return t;if(t.length>0&&e.length>0&&Ee(t[0])&&Ee(e[0])){let n=[...t];for(let i of e)if(Ee(i)&&"name"in i){if(!n.find((s)=>Ee(s)&&("name"in s)&&s.name===i.name))n.push(i)}else if(Ee(i)&&"path"in i){if(!n.find((s)=>Ee(s)&&("path"in s)&&s.path===i.path))n.push(i)}else if(!n.some((s)=>bi(s,i)))n.push(i);return n}if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let i of e)if(!n.includes(i))n.push(i);return n}return t}if(!Ee(t)||!Ee(e))return t;let r={...e};for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)){let i=t[n];if(i===null||i===void 0)continue;else if(Ee(i)&&Ee(r[n]))r[n]=rs(r[n],i);else if(Array.isArray(i)&&Array.isArray(r[n]))if(i.length>0&&r[n].length>0&&Ee(i[0])&&Ee(r[n][0])){let s=[...i];for(let o of r[n])if(Ee(o)&&"name"in o){if(!s.find((a)=>Ee(a)&&("name"in a)&&a.name===o.name))s.push(o)}else if(Ee(o)&&"path"in o){if(!s.find((a)=>Ee(a)&&("path"in a)&&a.path===o.path))s.push(o)}else if(!s.some((a)=>bi(a,o)))s.push(o);r[n]=s}else if(i.every((s)=>typeof s==="string")&&r[n].every((s)=>typeof s==="string")){let s=[...i];for(let o of r[n])if(!s.includes(o))s.push(o);r[n]=s}else r[n]=i;else r[n]=i}return r}function bi(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!bi(e[r],t[r]))return!1;return!0}if(Ee(e)&&Ee(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!bi(e[i],t[i]))return!1}return!0}return!1}function Ee(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function Ru(e,t){if(!pa(e))return null;try{let r=await import(e),n=r.default||r;if(typeof n!=="object"||n===null||Array.isArray(n))return null;try{return rs(t,n)}catch{return null}}catch{return null}}async function Ou({name:e="",cwd:t,defaultConfig:r}){let n=t||_n.cwd(),i=[".ts",".js",".mjs",".cjs",".json"],s=[`${e}.config`,`.${e}.config`,e,`.${e}`];for(let o of s)for(let a of i){let c=wi(n,`${o}${a}`),f=await Ru(c,r);if(f!==null)return f}try{let o=wi(n,"package.json");if(pa(o)){let a=(await import(o))[e];if(a&&typeof a==="object"&&!Array.isArray(a))try{return rs(r,a)}catch{}}}catch{}return r}function ku(e,t={}){let r=Ci.cwd();while(r.includes("storage"))r=Io(r,"..");let n=Io(r,e||"");if(t?.relative)return _f(Ci.cwd(),n);return n}async function Mu(){try{let e=await Ou({name:"clarity",defaultConfig:di,cwd:Ci.cwd(),endpoint:"",headers:{}});return{...di,...e}}catch{return di}}function xe(){if(yt.env.NODE_ENV==="test"||yt.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Du(){if(yt.env.NODE_ENV==="test"||yt.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof yt<"u"){let e=yt.type;if(e==="renderer"||e==="worker")return!1;return!!(yt.versions&&(yt.versions.node||yt.versions.bun))}return!1}class wa{async format(e){let t=await Du(),r=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:r})}async getMetadata(e){if(e){let{hostname:t}=await import("os");return{pid:Yt.pid,hostname:t(),environment:Yt.env.NODE_ENV||"development",platform:Yt.platform,version:Yt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:Yt.env.NODE_ENV||Yt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class Si{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={...Un},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new wa,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??We.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let r={...t},n=t.timestamp!==void 0;if(n)delete r.timestamp;if(this.config={...this.config,...r,timestamp:n||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let i=this.generateKeyId(),s=this.generateKey();this.currentKeyId=i,this.keys.set(i,s),this.encryptionKeys.set(i,{key:s,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...mi,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...mi};return{...mi,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:Un.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},r={...t,...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))};if(!r.level||!["debug","info","success","warning","error"].includes(r.level))r.level=t.level;return r}async writeToFile(e){let t=(async()=>{let n,i=0,s=3,o=1000;while(i<s)try{try{try{await Hf(this.config.logDirectory,Wo.F_OK|Wo.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await Jf(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:At.from(e);try{if(!An(this.currentLogFile))await xn(this.currentLogFile,"",{mode:420});if(n=Lo(this.currentLogFile,"a",420),zf(n,a,{flag:"a"}),No(n),n!==void 0)$n(n),n=void 0;if((await Jt(this.currentLogFile)).size===0){if(await xn(this.currentLogFile,a,{flag:"w",mode:420}),(await Jt(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(i<s-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${i+1}/${s}:`,u);let l=o*2**i;await new Promise((g)=>setTimeout(g,l)),i++;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{$n(n)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(a){if(i===s-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}i++;let c=o*2**(i-1);await new Promise((f)=>setTimeout(f,c))}})();this.pendingOperations.push(t);let r=this.pendingOperations.length-1;try{await t}catch(n){throw console.error("Debug: [writeToFile] Error in operation:",n),n}finally{this.pendingOperations.splice(r,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 qt(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 qt(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return qt(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(xe())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,t;switch(e.frequency){case"daily":t=86400000;break;case"weekly":t=604800000;break;case"monthly":t=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},t)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let e=this.config.rotation.keyRotation;if(!e?.enabled)return;let t=typeof e.interval==="number"?e.interval:60,r=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((n)=>{console.error("Error rotating keys:",n)})},r)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let e=this.config.rotation.keyRotation,t=this.generateKeyId(),r=this.generateKey();this.currentKeyId=t,this.keys.set(t,r),this.encryptionKeys.set(t,{key:r,createdAt:new Date});let n=Array.from(this.encryptionKeys.entries()).sort(([,o],[,a])=>a.createdAt.getTime()-o.createdAt.getTime()),i=typeof e.maxKeys==="number"?e.maxKeys:1,s=Math.max(1,i);if(n.length>s)for(let[o]of n.slice(s))this.encryptionKeys.delete(o),this.keys.delete(o)}generateKeyId(){return Sn(16).toString("hex")}generateKey(){return Sn(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(),r=Sn(16),n=Vf("aes-256-gcm",t,r),i=At.concat([n.update(e,"utf8"),n.final()]),s=n.getAuthTag();return{encrypted:At.concat([r,i,s]),iv:r}}async compressData(e){return new Promise((t,r)=>{let n=Go(),i=[];n.on("data",(s)=>i.push(s)),n.on("end",()=>t(At.from(At.concat(i)))),n.on("error",r),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(xe())return;let e=await Jt(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 r=this.currentLogFile,n=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let i=await Xr(this.config.logDirectory),s=i.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}),o=s.length>0?Number.parseInt(s[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,a=`${r}.${o}`;if(await Jt(r).catch(()=>null))try{if(await Bo(r,a),t.compress)try{let c=`${a}.gz`;await this.compressLogFile(a,c),await Qr(a)}catch(c){console.error("Error compressing rotated file:",c)}if(s.length===0&&!i.some((c)=>c.endsWith(".log.1")))try{let c=`${r}.1`;await xn(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 i=new Date().toISOString().replace(/[:.]/g,"-"),s=r.replace(/\.log$/,`-${i}.log`);if(await Jt(r).catch(()=>null))await Bo(r,s)}if(this.currentLogFile=n,t.maxFiles){let i=(await Xr(this.config.logDirectory)).filter((s)=>s.startsWith(this.name)).sort((s,o)=>o.localeCompare(s));for(let s of i.slice(t.maxFiles))await Qr(qt(this.config.logDirectory,s))}}}async compressLogFile(e,t){let r=Fo(e),n=Kf(t),i=Go();await qf(r,i,n)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let r of this.logBuffer){let n=await this.formatter.format(r);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 r={timestamp:new Date,level:e,message:t,name:this.name};this.logBuffer.push(r)}}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()})),An(this.currentLogFile))try{let e=Lo(this.currentLogFile,"r+");No(e),$n(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!xe()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await Xr(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await Qr(qt(this.config.logDirectory,t))}catch(r){console.error(`Failed to delete temp file ${t}:`,r)}}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?ve.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}formatConsoleMessage(e){let{timestamp:t,icon:r="",tag:n="",message:i,level:s,showTimestamp:o=!0}=e,a=(p)=>p.replace(this.ANSI_PATTERN,"");if(!this.fancy){let p=[];if(o)p.push(t);if(s==="warning")p.push("WARN");else if(s==="error")p.push("ERROR");else if(r)p.push(r.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(n)p.push(n.replace(/[[\]]/g,""));return p.push(i),p.join(" ")}let c=We.stdout.columns||120,f="";if(s==="warning"||s==="error")f=`${r} ${i}`;else if(s==="info"||s==="success")f=`${r} ${n} ${i}`;else f=`${r} ${n} ${ve.cyan(i)}`;if(!o)return f.trim();let u=a(f).trim().length,l=a(t).length,g=Math.max(1,c-2-u-l);return`${f.trim()}${" ".repeat(g)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(s,o)=>{let a=Number.parseInt(o,10);return a<t[0].length?String(t[0][a]):s});let r=/%([sdijfo%])/g,n=0,i=e.replace(r,(s,o)=>{if(o==="%")return"%";if(n>=t.length)return s;let a=t[n++];switch(o){case"s":return String(a);case"d":case"i":return Number(a).toString();case"j":case"o":return JSON.stringify(a,null,2);default:return s}});if(n<t.length)i+=` ${t.slice(n).map((s)=>typeof s==="object"?JSON.stringify(s,null,2):String(s)).join(" ")}`;return i}async log(e,t,...r){let n=new Date,i=this.formatConsoleTimestamp(n),s=this.formatFileTimestamp(n),o,a;if(t instanceof Error)o=t.message,a=t.stack;else o=this.formatMessage(t,r);if(this.fancy&&!xe()){let f=Ra[e],u=this.options.showTags!==!1&&this.name?ve.gray(this.formatTag(this.name)):"",l;switch(e){case"debug":l=this.formatConsoleMessage({timestamp:i,icon:f,tag:u,message:ve.gray(o),level:e}),console.error(l);break;case"info":l=this.formatConsoleMessage({timestamp:i,icon:f,tag:u,message:o,level:e}),console.error(l);break;case"success":l=this.formatConsoleMessage({timestamp:i,icon:f,tag:u,message:ve.green(o),level:e}),console.error(l);break;case"warning":l=this.formatConsoleMessage({timestamp:i,icon:f,tag:u,message:o,level:e}),console.warn(l);break;case"error":if(l=this.formatConsoleMessage({timestamp:i,icon:f,tag:u,message:o,level:e}),console.error(l),a){let g=a.split(`
78
+ `);for(let p of g)if(p.trim()&&!p.includes(o))console.error(this.formatConsoleMessage({timestamp:i,message:ve.gray(` ${p}`),level:e,showTimestamp:!1}))}break}}else if(!xe()){if(console.error(`${s} ${this.environment}.${e.toUpperCase()}: ${o}`),a)console.error(a)}if(!this.shouldLog(e))return;let c=`${s} ${this.environment}.${e.toUpperCase()}: ${o}
78
79
  `;if(a)c+=`${a}
79
- `;c=c.replace(this.ANSI_PATTERN,""),await this.writeToFile(c)}time(e){let t=performance.now();if(this.fancy&&!xe()){let r=this.options.showTags!==!1&&this.name?Ce.gray(this.formatTag(this.name)):"",n=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:n,icon:Ce.blue("\u25D0"),tag:r,message:`${Ce.cyan(e)}...`}))}return async(r)=>{if(!this.enabled)return;let n=performance.now(),i=Math.round(n-t),s=`${e} completed in ${i}ms`,o=new Date,a=this.formatConsoleTimestamp(o),c=`${this.formatFileTimestamp(o)} ${this.environment}.INFO: ${s}`;if(r)c+=` ${JSON.stringify(r)}`;if(c+=`
80
- `,c=c.replace(this.ANSI_PATTERN,""),this.fancy&&!xe()){let f=this.options.showTags!==!1&&this.name?Ce.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:a,icon:Ce.green("\u2713"),tag:f,message:`${s}${r?` ${JSON.stringify(r)}`:""}`}))}else if(!xe())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}`,r=new Ei(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(r),r}createReadStream(){if(xe())throw Error("createReadStream is not supported in browser environments");if(!Sn(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return Do(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 r=this.keys.get(this.currentKeyId);try{let n=At.isBuffer(e)?e:At.from(e,"base64"),i=n.slice(0,16),s=n.slice(-16),o=n.slice(16,-16),a=_f("aes-256-gcm",r,i);return a.setAuthTag(s),At.concat([a.update(o),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 xe()}isServerMode(){return!xe()}setTestEncryptionKey(e,t){this.currentKeyId=e,this.keys.set(e,t)}getTestCurrentKey(){if(!this.currentKeyId||!this.keys.has(this.currentKeyId))return null;return{id:this.currentKeyId,key:this.keys.get(this.currentKeyId)}}getConfig(){return this.config}async box(e){if(!this.enabled)return;let t=new Date,r=this.formatConsoleTimestamp(t),n=this.formatFileTimestamp(t);if(this.fancy&&!xe()){let s=e.split(`
81
- `),o=Math.max(...s.map((u)=>u.length))+2,a=`\u250C${"\u2500".repeat(o)}\u2510`,c=`\u2514${"\u2500".repeat(o)}\u2518`,f=s.map((u)=>{let l=" ".repeat(o-u.length-2);return`\u2502 ${u}${l} \u2502`});if(this.options.showTags!==!1&&this.name)console.error(this.formatConsoleMessage({timestamp:r,message:Ce.gray(this.formatTag(this.name)),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:r,message:Ce.cyan(a)})),f.forEach((u)=>console.error(this.formatConsoleMessage({timestamp:r,message:Ce.cyan(u),showTimestamp:!1}))),console.error(this.formatConsoleMessage({timestamp:r,message:Ce.cyan(c),showTimestamp:!1}))}else if(!xe())console.error(`${n} ${this.environment}.INFO: [BOX] ${e}`);let i=`${n} ${this.environment}.INFO: [BOX] ${e}
82
- `.replace(this.ANSI_PATTERN,"");await this.writeToFile(i)}async prompt(e){if(xe())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${Ce.cyan("?")} ${e} (y/n) `);let r=(n)=>{let i=n.toString().trim().toLowerCase();Be.stdin.removeListener("data",r);try{if(typeof Be.stdin.setRawMode==="function")Be.stdin.setRawMode(!1)}catch{}Be.stdin.pause(),console.error(""),t(i==="y"||i==="yes")};try{if(typeof Be.stdin.setRawMode==="function")Be.stdin.setRawMode(!0)}catch{}Be.stdin.resume(),Be.stdin.once("data",r)})}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 r=e;if(t&&t.length>0){let i=/%([sdijfo%])/g,s=0;if(r=e.replace(i,(o,a)=>{if(a==="%")return"%";if(s>=t.length)return o;let c=t[s++];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 o}}),s<t.length)r+=` ${t.slice(s).map((o)=>typeof o==="object"?JSON.stringify(o,null,2):String(o)).join(" ")}`}if(this.fancy&&!xe()){let i=this.options.showTags!==!1&&this.name?Ce.gray(this.formatTag(this.name)):"",s=Ce.blue("\u25D0");console.error(`${s} ${i} ${Ce.cyan(r)}`)}let n=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${r}
83
- `.replace(this.ANSI_PATTERN,"");await this.writeToFile(n)}progress(e,t=""){if(!this.enabled||!this.fancy||xe()||e<=0)return{update:()=>{},finish:()=>{},interrupt:()=>{}};if(this.activeProgressBar)console.warn("Warning: Another progress bar is already active. Finishing the previous one."),this.finishProgressBar(this.activeProgressBar,"[Auto-finished]");let r=20;return this.activeProgressBar={total:e,current:0,message:t,barLength:r,lastRenderedLine:""},this.renderProgressBar(this.activeProgressBar),{update:(n,i)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||xe())return;if(this.activeProgressBar.current=Math.max(0,Math.min(e,n)),i!==void 0)this.activeProgressBar.message=i;let s=this.activeProgressBar.current===this.activeProgressBar.total;this.renderProgressBar(this.activeProgressBar,s)},finish:(n)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||xe())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,i="info")=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||xe())return;Be.stdout.write(`${"\r".padEnd(Be.stdout.columns||80)}\r`),this.log(i,n),setTimeout(()=>{if(this.activeProgressBar)this.renderProgressBar(this.activeProgressBar)},50)}}}renderProgressBar(e,t=!1){if(!this.enabled||!this.fancy||xe()||!Be.stdout.isTTY)return;let r=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),n=Math.round(e.barLength*r/100),i=e.barLength-n,s=Ce.green("\u2501".repeat(n)),o=Ce.gray("\u2501".repeat(i)),a=`[${s}${o}]`,c=`${r}%`.padStart(4),f=e.message?` ${e.message}`:"",u=t||r===100?Ce.green("\u2713"):Ce.blue("\u25B6"),l=this.options.showTags!==!1&&this.name?` ${Ce.gray(this.formatTag(this.name))}`:"",g=`\r${u}${l} ${a} ${c}${f}`,d=Be.stdout.columns||80,v=" ".repeat(Math.max(0,d-g.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${g}${v}`,Be.stdout.write(e.lastRenderedLine),t)Be.stdout.write(`
84
- `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||xe()||!Be.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(t)e.message=t;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if(xe()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await Yr(this.config.logDirectory),r=[];for(let n of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(n):n.startsWith(this.name))||!n.endsWith(".log"))continue;let i=Jt(this.config.logDirectory,n);if(e.before)try{if((await zt(i)).mtime>=e.before)continue}catch(s){console.error(`Failed to get stats for file ${i}:`,s);continue}r.push(i)}if(r.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${r.length} log file(s)...`);for(let n of r)try{await Zr(n),console.warn(`Deleted log file: ${n}`)}catch(i){console.error(`Failed to delete log file ${n}:`,i)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}function fi(e,t){if(Array.isArray(t)&&Array.isArray(e)&&t.length===2&&e.length===2&&de(t[0])&&"id"in t[0]&&t[0].id===3&&de(t[1])&&"id"in t[1]&&t[1].id===4)return t;if(de(t)&&de(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(de(e)&&"arr"in e&&Array.isArray(e.arr)&&de(t)&&"arr"in t&&Array.isArray(t.arr))return t;if(t.length>0&&e.length>0&&de(t[0])&&de(e[0])){let n=[...t];for(let i of e)if(de(i)&&"name"in i){if(!n.find((s)=>de(s)&&("name"in s)&&s.name===i.name))n.push(i)}else if(de(i)&&"path"in i){if(!n.find((s)=>de(s)&&("path"in s)&&s.path===i.path))n.push(i)}else if(!n.some((s)=>bi(s,i)))n.push(i);return n}if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let i of e)if(!n.includes(i))n.push(i);return n}return t}if(!de(t)||!de(e))return t;let r={...e};for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)){let i=t[n];if(i===null||i===void 0)continue;else if(de(i)&&de(r[n]))r[n]=fi(r[n],i);else if(Array.isArray(i)&&Array.isArray(r[n]))if(i.length>0&&r[n].length>0&&de(i[0])&&de(r[n][0])){let s=[...i];for(let o of r[n])if(de(o)&&"name"in o){if(!s.find((a)=>de(a)&&("name"in a)&&a.name===o.name))s.push(o)}else if(de(o)&&"path"in o){if(!s.find((a)=>de(a)&&("path"in a)&&a.path===o.path))s.push(o)}else if(!s.some((a)=>bi(a,o)))s.push(o);r[n]=s}else if(i.every((s)=>typeof s==="string")&&r[n].every((s)=>typeof s==="string")){let s=[...i];for(let o of r[n])if(!s.includes(o))s.push(o);r[n]=s}else r[n]=i;else r[n]=i}return r}function ts(e,t,r="replace"){if(t===null||t===void 0)return e;if(Array.isArray(t))return r==="replace"?t:fi(e,t);if(Array.isArray(e))return r==="replace"?t:fi(e,t);if(!de(t)||!de(e))return t;let n={...e};for(let i of Object.keys(t)){if(!Object.prototype.hasOwnProperty.call(t,i))continue;let s=t[i],o=n[i];if(s===null||s===void 0)continue;if(Array.isArray(s)||Array.isArray(o))if(r==="replace")n[i]=s;else n[i]=fi(o,s);else if(de(s)&&de(o))n[i]=ts(o,s,r);else n[i]=s}return n}function bi(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!bi(e[r],t[r]))return!1;return!0}if(de(e)&&de(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!bi(e[i],t[i]))return!1}return!0}return!1}function de(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function li(e,t,r="replace"){if(!ha(e))return null;try{let n=await import(e),i=n.default||n;if(typeof i!=="object"||i===null||Array.isArray(i))return null;try{return ts(t,i,r)}catch{return null}}catch{return null}}function Mu(e,t,r=!1){if(!e)return t;let n=e.toUpperCase().replace(/-/g,"_"),i={...t};function s(o,a=[]){let c={...o};for(let[f,u]of Object.entries(o)){let l=[...a,f],g=(b)=>b.replace(/([A-Z])/g,"_$1").toUpperCase(),d=`${n}_${l.map(g).join("_")}`,v=`${n}_${l.map((b)=>b.toUpperCase()).join("_")}`;if(r)je.info(`Checking environment variable ${d} for config ${e}.${l.join(".")}`);if(typeof u==="object"&&u!==null&&!Array.isArray(u))c[f]=s(u,l);else{let b=yr.env[d]||yr.env[v];if(b!==void 0){if(r)je.info(`Using environment variable ${b?d:v} for config ${e}.${l.join(".")}`);if(typeof u==="number")c[f]=Number(b);else if(typeof u==="boolean")c[f]=b.toLowerCase()==="true";else if(Array.isArray(u))try{let C=JSON.parse(b);if(Array.isArray(C))c[f]=C;else c[f]=b.split(",").map((T)=>T.trim())}catch{c[f]=b.split(",").map((C)=>C.trim())}else c[f]=b}}}return c}return s(i)}async function Du({name:e="",alias:t,cwd:r,configDir:n,defaultConfig:i,verbose:s=!1,checkEnv:o=!0,arrayStrategy:a="replace"}){let c=o&&typeof i==="object"&&i!==null&&!Array.isArray(i)?Mu(e,i,s):i,f=r||yr.cwd(),u=[".ts",".js",".mjs",".cjs",".json"];if(s)je.info(`Loading configuration for "${e}"${t?` (alias: "${t}")`:""} from ${f}`);let l=[e,`.${e}`].filter(Boolean),g=[`${e}.config`,`.${e}.config`].filter(Boolean),d=t?[t,`.${t}`]:[],v=t?[`${t}.config`,`.${t}.config`]:[],b=Array.from(new Set([f,Ue(f,"config"),Ue(f,".config"),n?Ue(f,n):void 0].filter(Boolean)));for(let C of b){if(s)je.info(`Searching for configuration in: ${C}`);let T=[Ue(f,"config"),Ue(f,".config")].concat(n?[Ue(f,n)]:[]).includes(C)?[...l,...g,...d,...v]:[...g,...l,...v,...d];for(let k of T)for(let R of u){let I=Ue(C,`${k}${R}`),_=await li(I,c,a);if(_!==null){if(s)je.success(`Configuration loaded from: ${I}`);return _}}}if(e){let C=Ue(vn(),".config",e),T=["config",`${e}.config`];if(t)T.push(`${t}.config`);if(s)je.info(`Checking user config directory: ${C}`);for(let k of T)for(let R of u){let I=Ue(C,`${k}${R}`),_=await li(I,c,a);if(_!==null){if(s)je.success(`Configuration loaded from user config directory: ${I}`);return _}}}if(e){let C=Ue(vn(),".config"),T=[`.${e}.config`];if(t)T.push(`.${t}.config`);if(s)je.info(`Checking user config directory for dotfile configs: ${C}`);for(let k of T)for(let R of u){let I=Ue(C,`${k}${R}`),_=await li(I,c,a);if(_!==null){if(s)je.success(`Configuration loaded from user config directory dotfile: ${I}`);return _}}}if(e){let C=vn(),T=[`.${e}.config`,`.${e}`];if(t)T.push(`.${t}.config`),T.push(`.${t}`);if(s)je.info(`Checking user home directory for dotfile configs: ${C}`);for(let k of T)for(let R of u){let I=Ue(C,`${k}${R}`),_=await li(I,c,a);if(_!==null){if(s)je.success(`Configuration loaded from user home directory: ${I}`);return _}}}try{let C=Ue(f,"package.json");if(ha(C)){let T=await import(C),k=T[e];if(!k&&t){if(k=T[t],k&&s)je.success(`Using alias "${t}" configuration from package.json`)}if(k&&typeof k==="object"&&!Array.isArray(k))try{if(s)je.success(`Configuration loaded from package.json: ${k===T[e]?e:t}`);return ts(c,k,a)}catch(R){if(s)je.warn("Failed to merge package.json config:",R)}}}catch(C){if(s)je.warn("Failed to load package.json:",C)}if(s)je.info(`No configuration found for "${e}"${t?` or alias "${t}"`:""}, using default configuration with environment variables`);return c}function Iu(e,t={}){let r=pi.cwd();while(r.includes("storage"))r=ko(r,"..");let n=ko(r,e||"");if(t?.relative)return Wf(pi.cwd(),n);return n}async function Fu(){try{let e=await Du({name:"clarity",alias:"logging",defaultConfig:di,cwd:pi.cwd()});return{...di,...e||{}}}catch{return di}}function Ie(){if(yt.env.NODE_ENV==="test"||yt.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Nu(){if(yt.env.NODE_ENV==="test"||yt.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof yt<"u"){let e=yt.type;if(e==="renderer"||e==="worker")return!1;return!!(yt.versions&&(yt.versions.node||yt.versions.bun))}return!1}class Ca{async format(e){let t=await Nu(),r=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:r})}async getMetadata(e){if(e){let{hostname:t}=await import("os");return{pid:Xt.pid,hostname:t(),environment:Xt.env.NODE_ENV||"development",platform:Xt.platform,version:Xt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:Xt.env.NODE_ENV||Xt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class Si{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={...Vn},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new Ca,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??ue.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let r={...t},n=t.timestamp!==void 0;if(n)delete r.timestamp;if(this.config={...this.config,...r,timestamp:n||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let i=this.generateKeyId(),s=this.generateKey();this.currentKeyId=i,this.keys.set(i,s),this.encryptionKeys.set(i,{key:s,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;let t={debug:0,info:1,success:2,warning:3,error:4},r=this.fingersCrossedConfig.activationLevel??"error";return t[e]>=t[r]}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...mi,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...mi};return{...mi,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:Vn.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},r={...t,...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))};if(!r.level||!["debug","info","success","warning","error"].includes(r.level))r.level=t.level;return r}shouldWriteToFile(){return!Ie()&&this.config.writeToFile===!0}async writeToFile(e){let t=(async()=>{let n,i=0,s=3,o=1000;while(i<s)try{try{try{await Xf(this.config.logDirectory,_o.F_OK|_o.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:dt.from(e);try{if(!Xr(this.currentLogFile))await Tn(this.currentLogFile,"",{mode:420});if(n=jo(this.currentLogFile,"a",420),Zf(n,a,{flag:"a"}),Go(n),n!==void 0)xn(n),n=void 0;if((await Yt(this.currentLogFile)).size===0){if(await Tn(this.currentLogFile,a,{flag:"w",mode:420}),(await Yt(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(i<s-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${i+1}/${s}:`,u);let l=o*2**i;await new Promise((g)=>setTimeout(g,l)),i++;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{xn(n)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(a){if(i===s-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}i++;let c=o*2**(i-1);await new Promise((f)=>setTimeout(f,c))}})();this.pendingOperations.push(t);let r=this.pendingOperations.length-1;try{await t}catch(n){throw console.error("Debug: [writeToFile] Error in operation:",n),n}finally{this.pendingOperations.splice(r,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 Zt(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 Zt(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return Zt(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(Ie())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,r=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((n)=>{console.error("Error rotating keys:",n)})},r)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let e=this.config.rotation.keyRotation,t=this.generateKeyId(),r=this.generateKey();this.currentKeyId=t,this.keys.set(t,r),this.encryptionKeys.set(t,{key:r,createdAt:new Date});let n=Array.from(this.encryptionKeys.entries()).sort(([,o],[,a])=>a.createdAt.getTime()-o.createdAt.getTime()),i=typeof e.maxKeys==="number"?e.maxKeys:1,s=Math.max(1,i);if(n.length>s)for(let[o]of n.slice(s))this.encryptionKeys.delete(o),this.keys.delete(o)}generateKeyId(){return $n(16).toString("hex")}generateKey(){return $n(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(),r=$n(16),n=Jf("aes-256-gcm",t,r),i=dt.isBuffer(e)?e:dt.from(e,"utf8"),s=n.update(i),o=n.final(),a=s.length+o.length,c=n.getAuthTag(),f=dt.allocUnsafe(16+a+16);return r.copy(f,0),s.copy(f,16),o.copy(f,16+s.length),c.copy(f,16+a),{encrypted:f,iv:r}}async compressData(e){return new Promise((t,r)=>{let n=Uo(),i=[];n.on("data",(s)=>i.push(s)),n.on("end",()=>t(dt.from(dt.concat(i)))),n.on("error",r),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(Ie())return;if(!this.shouldWriteToFile())return;let e=await Yt(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 r=this.currentLogFile,n=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let i=await Qr(this.config.logDirectory),s=i.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}),o=s.length>0?Number.parseInt(s[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,a=`${r}.${o}`;if(await Yt(r).catch(()=>null))try{if(await Vo(r,a),t.compress)try{let c=`${a}.gz`;await this.compressLogFile(a,c),await ei(a)}catch(c){console.error("Error compressing rotated file:",c)}if(s.length===0&&!i.some((c)=>c.endsWith(".log.1")))try{let c=`${r}.1`;await Tn(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 i=new Date().toISOString().replace(/[:.]/g,"-"),s=r.replace(/\.log$/,`-${i}.log`);if(await Yt(r).catch(()=>null))await Vo(r,s)}if(this.currentLogFile=n,t.maxFiles){let i=(await Qr(this.config.logDirectory)).filter((s)=>s.startsWith(this.name)).sort((s,o)=>o.localeCompare(s));for(let s of i.slice(t.maxFiles))await ei(Zt(this.config.logDirectory,s))}}}async compressLogFile(e,t){let r=Bo(e),n=Yf(t),i=Uo();await ru(r,i,n)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let r of this.logBuffer){let n=await this.formatter.format(r);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()})),Xr(this.currentLogFile))try{let e=jo(this.currentLogFile,"r+");Go(e),xn(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(!Ie()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await Qr(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await ei(Zt(this.config.logDirectory,t))}catch(r){console.error(`Failed to delete temp file ${t}:`,r)}}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()?te.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||Ie())return!1;let e=typeof ue.env.NO_COLOR<"u",t=ue.env.FORCE_COLOR==="0";if(e||t)return!1;return!!(typeof ue.stderr<"u"&&ue.stderr.isTTY||typeof ue.stdout<"u"&&ue.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:t,icon:r="",tag:n="",message:i,level:s,showTimestamp:o=!0}=e,a=(d)=>d.replace(this.ANSI_PATTERN,"");if(!this.fancy){let d=[];if(o)d.push(t);if(s==="warning")d.push("WARN");else if(s==="error")d.push("ERROR");else if(r)d.push(r.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(n)d.push(n.replace(/[[\]]/g,""));return d.push(i),d.join(" ")}let c=ue.stdout.columns||120,f="";if(s==="warning"||s==="error")f=`${r} ${i}`;else if(s==="info"||s==="success")f=`${r} ${n} ${i}`;else f=`${r} ${n} ${te.cyan(i)}`;if(!o)return f.trim();let u=a(f).trim().length,l=a(t).length,g=Math.max(1,c-2-u-l);return`${f.trim()}${" ".repeat(g)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(s,o)=>{let a=Number.parseInt(o,10);return a<t[0].length?String(t[0][a]):s});let r=/%([sdijfo%])/g,n=0,i=e.replace(r,(s,o)=>{if(o==="%")return"%";if(n>=t.length)return s;let a=t[n++];switch(o){case"s":return String(a);case"d":case"i":return Number(a).toString();case"j":case"o":return JSON.stringify(a,null,2);default:return s}});if(n<t.length)i+=` ${t.slice(n).map((s)=>typeof s==="object"?JSON.stringify(s,null,2):String(s)).join(" ")}`;return i}formatMarkdown(e){if(!e)return e;let t=e;return t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,n,i)=>{let s=te.underline(te.blue(n)),o=this.toAbsoluteFilePath(i);if(o&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let a=`file://${encodeURI(o)}`,c="\x1B]8;;",f="\x1B\\";return`\x1B]8;;${a}\x1B\\${s}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${i}\x1B\\${s}\x1B]8;;\x1B\\`;return s}),t=t.replace(/`([^`]+)`/g,(r,n)=>te.bgGray(n)),t=t.replace(/\*\*([^*]+)\*\*/g,(r,n)=>te.bold(n)),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(r,n)=>te.italic(n)),t=t.replace(/(?<!_)_([^_]+)_(?!_)/g,(r,n)=>te.italic(n)),t=t.replace(/~([^~]+)~/g,(r,n)=>te.strikethrough(n)),t}supportsHyperlinks(){if(Ie())return!1;let e=ue.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 r=ue.env.HOME||"";if(r)t=t.replace(/^~(?=$|\/)/,r)}if(eu(t)||t.startsWith("./")||t.startsWith("../"))t=tu(t);else return null;return Xr(t)?t:null}catch{return null}}buildOutputTexts(e){let t=this.shouldStyleConsole()?this.formatMarkdown(e):e,r=e.replace(this.ANSI_PATTERN,"");return{consoleText:t,fileText:r}}async log(e,t,...r){let n=new Date,i=this.formatConsoleTimestamp(n),s=this.formatFileTimestamp(n),o,a;if(t instanceof Error)o=t.message,a=t.stack;else o=this.formatMessage(t,r);let{consoleText:c,fileText:f}=this.buildOutputTexts(o);if(this.shouldStyleConsole()){let l=this.options.showIcons===!1?"":Pa[e],g=this.options.showTags!==!1&&this.name?te.gray(this.formatTag(this.name)):"",d;switch(e){case"debug":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:te.gray(c),level:e}),console.error(d);break;case"info":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.warn(d);break;case"success":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:te.green(c),level:e}),console.error(d);break;case"warning":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.warn(d);break;case"error":if(d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.error(d),a){let v=a.split(`
85
- `);for(let b of v)if(b.trim()&&!b.includes(o))console.error(this.formatConsoleMessage({timestamp:i,message:te.gray(` ${b}`),level:e,showTimestamp:!1}))}break}}else if(!Ie()){if(console.error(`${s} ${this.environment}.${e.toUpperCase()}: ${o}`),a)console.error(a)}if(!this.shouldLog(e))return;let u=`${s} ${this.environment}.${e.toUpperCase()}: ${f}
80
+ `;c=c.replace(this.ANSI_PATTERN,""),await this.writeToFile(c)}time(e){let t=performance.now();if(this.fancy&&!xe()){let r=this.options.showTags!==!1&&this.name?ve.gray(this.formatTag(this.name)):"",n=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:n,icon:ve.blue("\u25D0"),tag:r,message:`${ve.cyan(e)}...`}))}return async(r)=>{if(!this.enabled)return;let n=performance.now(),i=Math.round(n-t),s=`${e} completed in ${i}ms`,o=new Date,a=this.formatConsoleTimestamp(o),c=`${this.formatFileTimestamp(o)} ${this.environment}.INFO: ${s}`;if(r)c+=` ${JSON.stringify(r)}`;if(c+=`
81
+ `,c=c.replace(this.ANSI_PATTERN,""),this.fancy&&!xe()){let f=this.options.showTags!==!1&&this.name?ve.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:a,icon:ve.green("\u2713"),tag:f,message:`${s}${r?` ${JSON.stringify(r)}`:""}`}))}else if(!xe())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}`,r=new Si(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(r),r}createReadStream(){if(xe())throw Error("createReadStream is not supported in browser environments");if(!An(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return Fo(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 r=this.keys.get(this.currentKeyId);try{let n=At.isBuffer(e)?e:At.from(e,"base64"),i=n.slice(0,16),s=n.slice(-16),o=n.slice(16,-16),a=Uf("aes-256-gcm",r,i);return a.setAuthTag(s),At.concat([a.update(o),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 xe()}isServerMode(){return!xe()}setTestEncryptionKey(e,t){this.currentKeyId=e,this.keys.set(e,t)}getTestCurrentKey(){if(!this.currentKeyId||!this.keys.has(this.currentKeyId))return null;return{id:this.currentKeyId,key:this.keys.get(this.currentKeyId)}}getConfig(){return this.config}async box(e){if(!this.enabled)return;let t=new Date,r=this.formatConsoleTimestamp(t),n=this.formatFileTimestamp(t);if(this.fancy&&!xe()){let s=e.split(`
82
+ `),o=Math.max(...s.map((u)=>u.length))+2,a=`\u250C${"\u2500".repeat(o)}\u2510`,c=`\u2514${"\u2500".repeat(o)}\u2518`,f=s.map((u)=>{let l=" ".repeat(o-u.length-2);return`\u2502 ${u}${l} \u2502`});if(this.options.showTags!==!1&&this.name)console.error(this.formatConsoleMessage({timestamp:r,message:ve.gray(this.formatTag(this.name)),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:r,message:ve.cyan(a)})),f.forEach((u)=>console.error(this.formatConsoleMessage({timestamp:r,message:ve.cyan(u),showTimestamp:!1}))),console.error(this.formatConsoleMessage({timestamp:r,message:ve.cyan(c),showTimestamp:!1}))}else if(!xe())console.error(`${n} ${this.environment}.INFO: [BOX] ${e}`);let i=`${n} ${this.environment}.INFO: [BOX] ${e}
83
+ `.replace(this.ANSI_PATTERN,"");await this.writeToFile(i)}async prompt(e){if(xe())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${ve.cyan("?")} ${e} (y/n) `);let r=(n)=>{let i=n.toString().trim().toLowerCase();We.stdin.removeListener("data",r);try{if(typeof We.stdin.setRawMode==="function")We.stdin.setRawMode(!1)}catch{}We.stdin.pause(),console.error(""),t(i==="y"||i==="yes")};try{if(typeof We.stdin.setRawMode==="function")We.stdin.setRawMode(!0)}catch{}We.stdin.resume(),We.stdin.once("data",r)})}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 r=e;if(t&&t.length>0){let i=/%([sdijfo%])/g,s=0;if(r=e.replace(i,(o,a)=>{if(a==="%")return"%";if(s>=t.length)return o;let c=t[s++];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 o}}),s<t.length)r+=` ${t.slice(s).map((o)=>typeof o==="object"?JSON.stringify(o,null,2):String(o)).join(" ")}`}if(this.fancy&&!xe()){let i=this.options.showTags!==!1&&this.name?ve.gray(this.formatTag(this.name)):"",s=ve.blue("\u25D0");console.error(`${s} ${i} ${ve.cyan(r)}`)}let n=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${r}
84
+ `.replace(this.ANSI_PATTERN,"");await this.writeToFile(n)}progress(e,t=""){if(!this.enabled||!this.fancy||xe()||e<=0)return{update:()=>{},finish:()=>{},interrupt:()=>{}};if(this.activeProgressBar)console.warn("Warning: Another progress bar is already active. Finishing the previous one."),this.finishProgressBar(this.activeProgressBar,"[Auto-finished]");let r=20;return this.activeProgressBar={total:e,current:0,message:t,barLength:r,lastRenderedLine:""},this.renderProgressBar(this.activeProgressBar),{update:(n,i)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||xe())return;if(this.activeProgressBar.current=Math.max(0,Math.min(e,n)),i!==void 0)this.activeProgressBar.message=i;let s=this.activeProgressBar.current===this.activeProgressBar.total;this.renderProgressBar(this.activeProgressBar,s)},finish:(n)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||xe())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,i="info")=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||xe())return;We.stdout.write(`${"\r".padEnd(We.stdout.columns||80)}\r`),this.log(i,n),setTimeout(()=>{if(this.activeProgressBar)this.renderProgressBar(this.activeProgressBar)},50)}}}renderProgressBar(e,t=!1){if(!this.enabled||!this.fancy||xe()||!We.stdout.isTTY)return;let r=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),n=Math.round(e.barLength*r/100),i=e.barLength-n,s=ve.green("\u2501".repeat(n)),o=ve.gray("\u2501".repeat(i)),a=`[${s}${o}]`,c=`${r}%`.padStart(4),f=e.message?` ${e.message}`:"",u=t||r===100?ve.green("\u2713"):ve.blue("\u25B6"),l=this.options.showTags!==!1&&this.name?` ${ve.gray(this.formatTag(this.name))}`:"",g=`\r${u}${l} ${a} ${c}${f}`,p=We.stdout.columns||80,v=" ".repeat(Math.max(0,p-g.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${g}${v}`,We.stdout.write(e.lastRenderedLine),t)We.stdout.write(`
85
+ `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||xe()||!We.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(t)e.message=t;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if(xe()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await Xr(this.config.logDirectory),r=[];for(let n of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(n):n.startsWith(this.name))||!n.endsWith(".log"))continue;let i=qt(this.config.logDirectory,n);if(e.before)try{if((await Jt(i)).mtime>=e.before)continue}catch(s){console.error(`Failed to get stats for file ${i}:`,s);continue}r.push(i)}if(r.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${r.length} log file(s)...`);for(let n of r)try{await Qr(n),console.warn(`Deleted log file: ${n}`)}catch(i){console.error(`Failed to delete log file ${n}:`,i)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}function hi(e,t){if(Array.isArray(t)&&Array.isArray(e)&&t.length===2&&e.length===2&&pe(t[0])&&"id"in t[0]&&t[0].id===3&&pe(t[1])&&"id"in t[1]&&t[1].id===4)return t;if(pe(t)&&pe(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(pe(e)&&"arr"in e&&Array.isArray(e.arr)&&pe(t)&&"arr"in t&&Array.isArray(t.arr))return t;if(t.length>0&&e.length>0&&pe(t[0])&&pe(e[0])){let n=[...t];for(let i of e)if(pe(i)&&"name"in i){if(!n.find((s)=>pe(s)&&("name"in s)&&s.name===i.name))n.push(i)}else if(pe(i)&&"path"in i){if(!n.find((s)=>pe(s)&&("path"in s)&&s.path===i.path))n.push(i)}else if(!n.some((s)=>$i(s,i)))n.push(i);return n}if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let i of e)if(!n.includes(i))n.push(i);return n}return t}if(!pe(t)||!pe(e))return t;let r={...e};for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)){let i=t[n];if(i===null||i===void 0)continue;else if(pe(i)&&pe(r[n]))r[n]=hi(r[n],i);else if(Array.isArray(i)&&Array.isArray(r[n]))if(i.length>0&&r[n].length>0&&pe(i[0])&&pe(r[n][0])){let s=[...i];for(let o of r[n])if(pe(o)&&"name"in o){if(!s.find((a)=>pe(a)&&("name"in a)&&a.name===o.name))s.push(o)}else if(pe(o)&&"path"in o){if(!s.find((a)=>pe(a)&&("path"in a)&&a.path===o.path))s.push(o)}else if(!s.some((a)=>$i(a,o)))s.push(o);r[n]=s}else if(i.every((s)=>typeof s==="string")&&r[n].every((s)=>typeof s==="string")){let s=[...i];for(let o of r[n])if(!s.includes(o))s.push(o);r[n]=s}else r[n]=i;else r[n]=i}return r}function is(e,t,r="replace"){if(t===null||t===void 0)return e;if(Array.isArray(t))return r==="replace"?t:hi(e,t);if(Array.isArray(e))return r==="replace"?t:hi(e,t);if(!pe(t)||!pe(e))return t;let n={...e};for(let i of Object.keys(t)){if(!Object.prototype.hasOwnProperty.call(t,i))continue;let s=t[i],o=n[i];if(s===null||s===void 0)continue;if(Array.isArray(s)||Array.isArray(o))if(r==="replace")n[i]=s;else n[i]=hi(o,s);else if(pe(s)&&pe(o))n[i]=is(o,s,r);else n[i]=s}return n}function $i(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!$i(e[r],t[r]))return!1;return!0}if(pe(e)&&pe(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!$i(e[i],t[i]))return!1}return!0}return!1}function pe(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function fi(e,t,r="replace"){if(!ma(e))return null;try{let n=await import(e),i=n.default||n;if(typeof i!=="object"||i===null||Array.isArray(i))return null;try{return is(t,i,r)}catch{return null}}catch{return null}}function Iu(e,t,r=!1){if(!e)return t;let n=e.toUpperCase().replace(/-/g,"_"),i={...t};function s(o,a=[]){let c={...o};for(let[f,u]of Object.entries(o)){let l=[...a,f],g=(b)=>b.replace(/([A-Z])/g,"_$1").toUpperCase(),p=`${n}_${l.map(g).join("_")}`,v=`${n}_${l.map((b)=>b.toUpperCase()).join("_")}`;if(r)Ge.info(`Checking environment variable ${p} for config ${e}.${l.join(".")}`);if(typeof u==="object"&&u!==null&&!Array.isArray(u))c[f]=s(u,l);else{let b=Cr.env[p]||Cr.env[v];if(b!==void 0){if(r)Ge.info(`Using environment variable ${b?p:v} for config ${e}.${l.join(".")}`);if(typeof u==="number")c[f]=Number(b);else if(typeof u==="boolean")c[f]=b.toLowerCase()==="true";else if(Array.isArray(u))try{let w=JSON.parse(b);if(Array.isArray(w))c[f]=w;else c[f]=b.split(",").map((T)=>T.trim())}catch{c[f]=b.split(",").map((w)=>w.trim())}else c[f]=b}}}return c}return s(i)}async function Fu({name:e="",alias:t,cwd:r,configDir:n,defaultConfig:i,verbose:s=!1,checkEnv:o=!0,arrayStrategy:a="replace"}){let c=o&&typeof i==="object"&&i!==null&&!Array.isArray(i)?Iu(e,i,s):i,f=r||Cr.cwd(),u=[".ts",".js",".mjs",".cjs",".json"];if(s)Ge.info(`Loading configuration for "${e}"${t?` (alias: "${t}")`:""} from ${f}`);let l=[e,`.${e}`].filter(Boolean),g=[`${e}.config`,`.${e}.config`].filter(Boolean),p=t?[t,`.${t}`]:[],v=t?[`${t}.config`,`.${t}.config`]:[],b=Array.from(new Set([f,ze(f,"config"),ze(f,".config"),n?ze(f,n):void 0].filter(Boolean)));for(let w of b){if(s)Ge.info(`Searching for configuration in: ${w}`);let T=[ze(f,"config"),ze(f,".config")].concat(n?[ze(f,n)]:[]).includes(w)?[...l,...g,...p,...v]:[...g,...l,...v,...p];for(let k of T)for(let R of u){let I=ze(w,`${k}${R}`),_=await fi(I,c,a);if(_!==null){if(s)Ge.success(`Configuration loaded from: ${I}`);return _}}}if(e){let w=ze(bn(),".config",e),T=["config",`${e}.config`];if(t)T.push(`${t}.config`);if(s)Ge.info(`Checking user config directory: ${w}`);for(let k of T)for(let R of u){let I=ze(w,`${k}${R}`),_=await fi(I,c,a);if(_!==null){if(s)Ge.success(`Configuration loaded from user config directory: ${I}`);return _}}}if(e){let w=ze(bn(),".config"),T=[`.${e}.config`];if(t)T.push(`.${t}.config`);if(s)Ge.info(`Checking user config directory for dotfile configs: ${w}`);for(let k of T)for(let R of u){let I=ze(w,`${k}${R}`),_=await fi(I,c,a);if(_!==null){if(s)Ge.success(`Configuration loaded from user config directory dotfile: ${I}`);return _}}}if(e){let w=bn(),T=[`.${e}.config`,`.${e}`];if(t)T.push(`.${t}.config`),T.push(`.${t}`);if(s)Ge.info(`Checking user home directory for dotfile configs: ${w}`);for(let k of T)for(let R of u){let I=ze(w,`${k}${R}`),_=await fi(I,c,a);if(_!==null){if(s)Ge.success(`Configuration loaded from user home directory: ${I}`);return _}}}try{let w=ze(f,"package.json");if(ma(w)){let T=await import(w),k=T[e];if(!k&&t){if(k=T[t],k&&s)Ge.success(`Using alias "${t}" configuration from package.json`)}if(k&&typeof k==="object"&&!Array.isArray(k))try{if(s)Ge.success(`Configuration loaded from package.json: ${k===T[e]?e:t}`);return is(c,k,a)}catch(R){if(s)Ge.warn("Failed to merge package.json config:",R)}}}catch(w){if(s)Ge.warn("Failed to load package.json:",w)}if(s)Ge.info(`No configuration found for "${e}"${t?` or alias "${t}"`:""}, using default configuration with environment variables`);return c}function Nu(e,t={}){let r=yi.cwd();while(r.includes("storage"))r=Do(r,"..");let n=Do(r,e||"");if(t?.relative)return Gf(yi.cwd(),n);return n}async function Lu(){try{let e=await Fu({name:"clarity",alias:"logging",defaultConfig:pi,cwd:yi.cwd()});return{...pi,...e||{}}}catch{return pi}}function De(){if(Ct.env.NODE_ENV==="test"||Ct.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Wu(){if(Ct.env.NODE_ENV==="test"||Ct.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof Ct<"u"){let e=Ct.type;if(e==="renderer"||e==="worker")return!1;return!!(Ct.versions&&(Ct.versions.node||Ct.versions.bun))}return!1}class va{async format(e){let t=await Wu(),r=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:r})}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 Ai{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={...Kn},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new va,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??de.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let r={...t},n=t.timestamp!==void 0;if(n)delete r.timestamp;if(this.config={...this.config,...r,timestamp:n||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let i=this.generateKeyId(),s=this.generateKey();this.currentKeyId=i,this.keys.set(i,s),this.encryptionKeys.set(i,{key:s,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;let t={debug:0,info:1,success:2,warning:3,error:4},r=this.fingersCrossedConfig.activationLevel??"error";return t[e]>=t[r]}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...gi,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...gi};return{...gi,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:Kn.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},r={...t,...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))};if(!r.level||!["debug","info","success","warning","error"].includes(r.level))r.level=t.level;return r}shouldWriteToFile(){return!De()&&this.config.writeToFile===!0}async writeToFile(e){let t=(async()=>{let n,i=0,s=3,o=1000;while(i<s)try{try{try{await eu(this.config.logDirectory,Uo.F_OK|Uo.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await tu(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:mt.from(e);try{if(!ei(this.currentLogFile))await Rn(this.currentLogFile,"",{mode:420});if(n=Vo(this.currentLogFile,"a",420),Qf(n,a,{flag:"a"}),_o(n),n!==void 0)Pn(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(i<s-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${i+1}/${s}:`,u);let l=o*2**i;await new Promise((g)=>setTimeout(g,l)),i++;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{Pn(n)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(a){if(i===s-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}i++;let c=o*2**(i-1);await new Promise((f)=>setTimeout(f,c))}})();this.pendingOperations.push(t);let r=this.pendingOperations.length-1;try{await t}catch(n){throw console.error("Debug: [writeToFile] Error in operation:",n),n}finally{this.pendingOperations.splice(r,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(De())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,r=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((n)=>{console.error("Error rotating keys:",n)})},r)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let e=this.config.rotation.keyRotation,t=this.generateKeyId(),r=this.generateKey();this.currentKeyId=t,this.keys.set(t,r),this.encryptionKeys.set(t,{key:r,createdAt:new Date});let n=Array.from(this.encryptionKeys.entries()).sort(([,o],[,a])=>a.createdAt.getTime()-o.createdAt.getTime()),i=typeof e.maxKeys==="number"?e.maxKeys:1,s=Math.max(1,i);if(n.length>s)for(let[o]of n.slice(s))this.encryptionKeys.delete(o),this.keys.delete(o)}generateKeyId(){return Tn(16).toString("hex")}generateKey(){return Tn(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(),r=Tn(16),n=Yf("aes-256-gcm",t,r),i=mt.isBuffer(e)?e:mt.from(e,"utf8"),s=n.update(i),o=n.final(),a=s.length+o.length,c=n.getAuthTag(),f=mt.allocUnsafe(16+a+16);return r.copy(f,0),s.copy(f,16),o.copy(f,16+s.length),c.copy(f,16+a),{encrypted:f,iv:r}}async compressData(e){return new Promise((t,r)=>{let n=zo(),i=[];n.on("data",(s)=>i.push(s)),n.on("end",()=>t(mt.from(mt.concat(i)))),n.on("error",r),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(De())return;if(!this.shouldWriteToFile())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 r=this.currentLogFile,n=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let i=await ti(this.config.logDirectory),s=i.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}),o=s.length>0?Number.parseInt(s[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,a=`${r}.${o}`;if(await Zt(r).catch(()=>null))try{if(await Ko(r,a),t.compress)try{let c=`${a}.gz`;await this.compressLogFile(a,c),await ri(a)}catch(c){console.error("Error compressing rotated file:",c)}if(s.length===0&&!i.some((c)=>c.endsWith(".log.1")))try{let c=`${r}.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 i=new Date().toISOString().replace(/[:.]/g,"-"),s=r.replace(/\.log$/,`-${i}.log`);if(await Zt(r).catch(()=>null))await Ko(r,s)}if(this.currentLogFile=n,t.maxFiles){let i=(await ti(this.config.logDirectory)).filter((s)=>s.startsWith(this.name)).sort((s,o)=>o.localeCompare(s));for(let s of i.slice(t.maxFiles))await ri(Xt(this.config.logDirectory,s))}}}async compressLogFile(e,t){let r=jo(e),n=Xf(t),i=zo();await nu(r,i,n)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let r of this.logBuffer){let n=await this.formatter.format(r);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()})),ei(this.currentLogFile))try{let e=Vo(this.currentLogFile,"r+");_o(e),Pn(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(!De()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await ti(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await ri(Xt(this.config.logDirectory,t))}catch(r){console.error(`Failed to delete temp file ${t}:`,r)}}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()?re.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||De())return!1;let e=typeof de.env.NO_COLOR<"u",t=de.env.FORCE_COLOR==="0";if(e||t)return!1;return!!(typeof de.stderr<"u"&&de.stderr.isTTY||typeof de.stdout<"u"&&de.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:t,icon:r="",tag:n="",message:i,level:s,showTimestamp:o=!0}=e,a=(p)=>p.replace(this.ANSI_PATTERN,"");if(!this.fancy){let p=[];if(o)p.push(t);if(s==="warning")p.push("WARN");else if(s==="error")p.push("ERROR");else if(r)p.push(r.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(n)p.push(n.replace(/[[\]]/g,""));return p.push(i),p.join(" ")}let c=de.stdout.columns||120,f="";if(s==="warning"||s==="error")f=`${r} ${i}`;else if(s==="info"||s==="success")f=`${r} ${n} ${i}`;else f=`${r} ${n} ${re.cyan(i)}`;if(!o)return f.trim();let u=a(f).trim().length,l=a(t).length,g=Math.max(1,c-2-u-l);return`${f.trim()}${" ".repeat(g)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(s,o)=>{let a=Number.parseInt(o,10);return a<t[0].length?String(t[0][a]):s});let r=/%([sdijfo%])/g,n=0,i=e.replace(r,(s,o)=>{if(o==="%")return"%";if(n>=t.length)return s;let a=t[n++];switch(o){case"s":return String(a);case"d":case"i":return Number(a).toString();case"j":case"o":return JSON.stringify(a,null,2);default:return s}});if(n<t.length)i+=` ${t.slice(n).map((s)=>typeof s==="object"?JSON.stringify(s,null,2):String(s)).join(" ")}`;return i}formatMarkdown(e){if(!e)return e;let t=e;return t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,n,i)=>{let s=re.underline(re.blue(n)),o=this.toAbsoluteFilePath(i);if(o&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let a=`file://${encodeURI(o)}`,c="\x1B]8;;",f="\x1B\\";return`\x1B]8;;${a}\x1B\\${s}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${i}\x1B\\${s}\x1B]8;;\x1B\\`;return s}),t=t.replace(/`([^`]+)`/g,(r,n)=>re.bgGray(n)),t=t.replace(/\*\*([^*]+)\*\*/g,(r,n)=>re.bold(n)),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(r,n)=>re.italic(n)),t=t.replace(/(?<!_)_([^_]+)_(?!_)/g,(r,n)=>re.italic(n)),t=t.replace(/~([^~]+)~/g,(r,n)=>re.strikethrough(n)),t}supportsHyperlinks(){if(De())return!1;let e=de.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 r=de.env.HOME||"";if(r)t=t.replace(/^~(?=$|\/)/,r)}if(ru(t)||t.startsWith("./")||t.startsWith("../"))t=iu(t);else return null;return ei(t)?t:null}catch{return null}}buildOutputTexts(e){let t=this.shouldStyleConsole()?this.formatMarkdown(e):e,r=e.replace(this.ANSI_PATTERN,"");return{consoleText:t,fileText:r}}async log(e,t,...r){let n=new Date,i=this.formatConsoleTimestamp(n),s=this.formatFileTimestamp(n),o,a;if(t instanceof Error)o=t.message,a=t.stack;else o=this.formatMessage(t,r);let{consoleText:c,fileText:f}=this.buildOutputTexts(o);if(this.shouldStyleConsole()){let l=this.options.showIcons===!1?"":Oa[e],g=this.options.showTags!==!1&&this.name?re.gray(this.formatTag(this.name)):"",p;switch(e){case"debug":p=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:re.gray(c),level:e}),console.error(p);break;case"info":p=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.warn(p);break;case"success":p=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:re.green(c),level:e}),console.error(p);break;case"warning":p=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.warn(p);break;case"error":if(p=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.error(p),a){let v=a.split(`
86
+ `);for(let b of v)if(b.trim()&&!b.includes(o))console.error(this.formatConsoleMessage({timestamp:i,message:re.gray(` ${b}`),level:e,showTimestamp:!1}))}break}}else if(!De()){if(console.error(`${s} ${this.environment}.${e.toUpperCase()}: ${o}`),a)console.error(a)}if(!this.shouldLog(e))return;let u=`${s} ${this.environment}.${e.toUpperCase()}: ${f}
86
87
  `;if(a)u+=`${a}
87
- `;if(u=u.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(u)}progress(e,t=""){let r={update:(i,s)=>{},finish:(i)=>{},interrupt:(i,s)=>{}};if(!this.enabled)return r;let n=30;if(this.activeProgressBar={total:Math.max(1,e||1),current:0,message:t||"",barLength:n,lastRenderedLine:""},this.shouldStyleConsole()&&!Ie()&&ue.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(i,s)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,i),this.activeProgressBar.total),s!==void 0)this.activeProgressBar.message=s;if(this.shouldStyleConsole()&&!Ie()&&ue.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(i)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,i)},interrupt:(i,s="info")=>{if(!Ie()&&ue.stdout.isTTY)ue.stdout.write(`
88
- `);if(this[s==="warning"?"warn":s](i),this.activeProgressBar&&this.shouldStyleConsole()&&!Ie()&&ue.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time(e){let t=performance.now();if(this.shouldStyleConsole()){let r=this.options.showTags!==!1&&this.name?te.gray(this.formatTag(this.name)):"",n=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:n,icon:this.options.showIcons===!1?"":te.blue("\u25D0"),tag:r,message:`${te.cyan(e)}...`}))}return async(r)=>{if(!this.enabled)return;let n=performance.now(),i=Math.round(n-t),s=`${e} completed in ${i}ms`,o=new Date,a=this.formatConsoleTimestamp(o),c=`${this.formatFileTimestamp(o)} ${this.environment}.INFO: ${s}`;if(r)c+=` ${JSON.stringify(r)}`;if(c+=`
89
- `,c=c.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let f=this.options.showTags!==!1&&this.name?te.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:a,icon:this.options.showIcons===!1?"":te.green("\u2713"),tag:f,message:`${s}${r?` ${JSON.stringify(r)}`:""}`}))}else if(!Ie())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}`,r=new Si(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(r),r}createReadStream(){if(Ie())throw Error("createReadStream is not supported in browser environments");if(!Xr(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return Bo(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 r=this.keys.get(this.currentKeyId);try{let n=dt.isBuffer(e)?e:dt.from(e,"base64"),i=n.subarray(0,16),s=n.subarray(n.length-16),o=n.subarray(16,n.length-16),a=qf("aes-256-gcm",r,i);a.setAuthTag(s);let c=a.update(o),f=a.final(),u=c.length+f.length,l=dt.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 Ie()}isServerMode(){return!Ie()}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,r=this.formatConsoleTimestamp(t),n=this.formatFileTimestamp(t),{consoleText:i,fileText:s}=this.buildOutputTexts(e);if(this.shouldStyleConsole()){let a=i.split(`
90
- `),c=Math.max(...a.map((g)=>g.length))+2,f=`\u250C${"\u2500".repeat(c)}\u2510`,u=`\u2514${"\u2500".repeat(c)}\u2518`,l=a.map((g)=>this.formatConsoleMessage({timestamp:r,message:te.cyan(g),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:r,message:te.cyan(f),showTimestamp:!1})),l.forEach((g)=>console.error(g)),console.error(this.formatConsoleMessage({timestamp:r,message:te.cyan(u),showTimestamp:!1}))}else if(!Ie())console.error(`${n} ${this.environment}.INFO: [BOX] ${s}`);let o=`${n} ${this.environment}.INFO: [BOX] ${s}
91
- `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(o)}async prompt(e){if(Ie())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${te.cyan("?")} ${e} (y/n) `);let r=(n)=>{let i=n.toString().trim().toLowerCase();ue.stdin.removeListener("data",r);try{if(typeof ue.stdin.setRawMode==="function")ue.stdin.setRawMode(!1)}catch{}ue.stdin.pause(),console.error(""),t(i==="y"||i==="yes")};try{if(typeof ue.stdin.setRawMode==="function")ue.stdin.setRawMode(!0)}catch{}ue.stdin.resume(),ue.stdin.once("data",r)})}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 r=e;if(t&&t.length>0){let o=/%([sdijfo%])/g,a=0;if(r=e.replace(o,(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)r+=` ${t.slice(a).map((c)=>typeof c==="object"?JSON.stringify(c,null,2):String(c)).join(" ")}`}let{consoleText:n,fileText:i}=this.buildOutputTexts(r);if(this.shouldStyleConsole()){let o=this.options.showTags!==!1&&this.name?te.gray(this.formatTag(this.name)):"",a=this.options.showIcons===!1?"":`${te.blue("\u25D0")} `;console.error(`${a}${o} ${te.cyan(n)}`)}let s=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${i}
92
- `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(s)}renderProgressBar(e,t=!1){if(!this.enabled||!this.shouldStyleConsole()||!ue.stdout.isTTY)return;let r=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),n=Math.round(e.barLength*r/100),i=e.barLength-n,s=te.green("\u2501".repeat(n)),o=te.gray("\u2501".repeat(i)),a=`[${s}${o}]`,c=`${r}%`.padStart(4),f=e.message?` ${e.message}`:"",u=this.options.showIcons===!1?"":t||r===100?te.green("\u2713"):te.blue("\u25B6"),l=this.options.showTags!==!1&&this.name?` ${te.gray(this.formatTag(this.name))}`:"",g=`\r${u}${l} ${a} ${c}${f}`,d=ue.stdout.columns||80,v=" ".repeat(Math.max(0,d-g.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${g}${v}`,ue.stdout.write(e.lastRenderedLine),t)ue.stdout.write(`
93
- `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||Ie()||!ue.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(Ie()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await Qr(this.config.logDirectory),r=[];for(let n of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(n):n.startsWith(this.name))||!n.endsWith(".log"))continue;let i=Zt(this.config.logDirectory,n);if(e.before)try{if((await Yt(i)).mtime>=e.before)continue}catch(s){console.error(`Failed to get stats for file ${i}:`,s);continue}r.push(i)}if(r.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${r.length} log file(s)...`);for(let n of r)try{await ei(n),console.warn(`Deleted log file: ${n}`)}catch(i){console.error(`Failed to delete log file ${n}:`,i)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}async function wa(e,t={}){let{maxRetries:r=3,retryDelay:n=1000,isRetryable:i=()=>!0,fallback:s}=t,o=Error("Unknown error occurred");for(let a=0;a<=r;a++)try{return await e()}catch(c){if(o=c instanceof Error?c:Error(String(c)),a===r||!i(o))break;if(n>0)await new Promise((f)=>setTimeout(f,n))}if(s!==void 0)return s;throw o instanceof Error?o:Error(`Unknown error: ${String(o)}`)}function va(e){return e instanceof Ye}function Lu(e){return e instanceof Ai}function Wu(e){if(va(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 Oi{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,r={}){let{prefix:n,useCamelCase:i=!0,useBackwardCompatibility:s=!0,customParsers:o={},verbose:a=!1,trackPerformance:c=!0}=r,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:i,useBackwardCompatibility:s,customParsers:o,verbose:a,configName:e}),{config:l,source:{type:"environment",priority:50,timestamp:new Date}}};if(c)return vr.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,r,n){for(let[i,s]of Object.entries(e)){let o=[...t,i],a=o.map((u)=>this.formatEnvKey(u,n.useCamelCase)),c=`${r}_${a.join("_")}`,f=n.useBackwardCompatibility?`${r}_${o.map((u)=>u.toUpperCase()).join("_")}`:null;if(n.verbose);if(typeof s==="object"&&s!==null&&!Array.isArray(s))this.processObject(s,o,r,n);else{let u=ti.env[c]||(f?ti.env[f]:void 0);if(u!==void 0){if(n.verbose){let l=ti.env[c]?c:f}try{e[i]=this.parseEnvironmentValue(u,typeof s,c,n.customParsers,n.configName)}catch(l){if(l instanceof $i)throw l;throw $t.envVar(c,u,typeof s,n.configName)}}}}}parseEnvironmentValue(e,t,r,n,i){for(let[s,o]of Object.entries(n))try{return o(e)}catch{continue}for(let s of this.defaultParsers)if(s.canParse(e,t))try{return s.parse(e)}catch{throw $t.envVar(r,e,`${t} (via ${s.name} parser)`,i)}return e}getEnvironmentVariables(e){let t={},r=e.toUpperCase();for(let[n,i]of Object.entries(ti.env))if(n.startsWith(r)&&i!==void 0)t[n]=i;return t}validateEnvironmentVariable(e,t,r){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(r)try{this.parseEnvironmentValue(e,t,r,{})}catch(i){n.push(`Cannot parse value "${t}" as ${r}: ${i}`)}return{isValid:n.length===0,errors:n}}generateEnvVarDocs(e,t,r={}){let{prefix:n,format:i="text"}=r,s=n||this.generateEnvPrefix(e),o=[];switch(this.extractEnvVarInfo(t,[],s,o),i){case"markdown":return this.formatAsMarkdown(o,e);case"json":return JSON.stringify(o,null,2);default:return this.formatAsText(o,e)}}extractEnvVarInfo(e,t,r,n){for(let[i,s]of Object.entries(e)){let o=[...t,i],a=`${r}_${o.map((c)=>this.formatEnvKey(c,!0)).join("_")}`;if(typeof s==="object"&&s!==null&&!Array.isArray(s))this.extractEnvVarInfo(s,o,r,n);else n.push({key:a,type:Array.isArray(s)?"array":typeof s,description:`Configuration for ${o.join(".")}`,example:this.generateExample(s)})}}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 r=`Environment Variables for ${t}:
88
+ `;if(u=u.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(u)}progress(e,t=""){let r={update:(i,s)=>{},finish:(i)=>{},interrupt:(i,s)=>{}};if(!this.enabled)return r;let n=30;if(this.activeProgressBar={total:Math.max(1,e||1),current:0,message:t||"",barLength:n,lastRenderedLine:""},this.shouldStyleConsole()&&!De()&&de.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(i,s)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,i),this.activeProgressBar.total),s!==void 0)this.activeProgressBar.message=s;if(this.shouldStyleConsole()&&!De()&&de.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(i)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,i)},interrupt:(i,s="info")=>{if(!De()&&de.stdout.isTTY)de.stdout.write(`
89
+ `);if(this[s==="warning"?"warn":s](i),this.activeProgressBar&&this.shouldStyleConsole()&&!De()&&de.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time(e){let t=performance.now();if(this.shouldStyleConsole()){let r=this.options.showTags!==!1&&this.name?re.gray(this.formatTag(this.name)):"",n=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:n,icon:this.options.showIcons===!1?"":re.blue("\u25D0"),tag:r,message:`${re.cyan(e)}...`}))}return async(r)=>{if(!this.enabled)return;let n=performance.now(),i=Math.round(n-t),s=`${e} completed in ${i}ms`,o=new Date,a=this.formatConsoleTimestamp(o),c=`${this.formatFileTimestamp(o)} ${this.environment}.INFO: ${s}`;if(r)c+=` ${JSON.stringify(r)}`;if(c+=`
90
+ `,c=c.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let f=this.options.showTags!==!1&&this.name?re.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:a,icon:this.options.showIcons===!1?"":re.green("\u2713"),tag:f,message:`${s}${r?` ${JSON.stringify(r)}`:""}`}))}else if(!De())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}`,r=new Ai(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(r),r}createReadStream(){if(De())throw Error("createReadStream is not supported in browser environments");if(!ei(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return jo(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 r=this.keys.get(this.currentKeyId);try{let n=mt.isBuffer(e)?e:mt.from(e,"base64"),i=n.subarray(0,16),s=n.subarray(n.length-16),o=n.subarray(16,n.length-16),a=Zf("aes-256-gcm",r,i);a.setAuthTag(s);let c=a.update(o),f=a.final(),u=c.length+f.length,l=mt.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 De()}isServerMode(){return!De()}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,r=this.formatConsoleTimestamp(t),n=this.formatFileTimestamp(t),{consoleText:i,fileText:s}=this.buildOutputTexts(e);if(this.shouldStyleConsole()){let a=i.split(`
91
+ `),c=Math.max(...a.map((g)=>g.length))+2,f=`\u250C${"\u2500".repeat(c)}\u2510`,u=`\u2514${"\u2500".repeat(c)}\u2518`,l=a.map((g)=>this.formatConsoleMessage({timestamp:r,message:re.cyan(g),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:r,message:re.cyan(f),showTimestamp:!1})),l.forEach((g)=>console.error(g)),console.error(this.formatConsoleMessage({timestamp:r,message:re.cyan(u),showTimestamp:!1}))}else if(!De())console.error(`${n} ${this.environment}.INFO: [BOX] ${s}`);let o=`${n} ${this.environment}.INFO: [BOX] ${s}
92
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(o)}async prompt(e){if(De())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${re.cyan("?")} ${e} (y/n) `);let r=(n)=>{let i=n.toString().trim().toLowerCase();de.stdin.removeListener("data",r);try{if(typeof de.stdin.setRawMode==="function")de.stdin.setRawMode(!1)}catch{}de.stdin.pause(),console.error(""),t(i==="y"||i==="yes")};try{if(typeof de.stdin.setRawMode==="function")de.stdin.setRawMode(!0)}catch{}de.stdin.resume(),de.stdin.once("data",r)})}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 r=e;if(t&&t.length>0){let o=/%([sdijfo%])/g,a=0;if(r=e.replace(o,(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)r+=` ${t.slice(a).map((c)=>typeof c==="object"?JSON.stringify(c,null,2):String(c)).join(" ")}`}let{consoleText:n,fileText:i}=this.buildOutputTexts(r);if(this.shouldStyleConsole()){let o=this.options.showTags!==!1&&this.name?re.gray(this.formatTag(this.name)):"",a=this.options.showIcons===!1?"":`${re.blue("\u25D0")} `;console.error(`${a}${o} ${re.cyan(n)}`)}let s=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${i}
93
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(s)}renderProgressBar(e,t=!1){if(!this.enabled||!this.shouldStyleConsole()||!de.stdout.isTTY)return;let r=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),n=Math.round(e.barLength*r/100),i=e.barLength-n,s=re.green("\u2501".repeat(n)),o=re.gray("\u2501".repeat(i)),a=`[${s}${o}]`,c=`${r}%`.padStart(4),f=e.message?` ${e.message}`:"",u=this.options.showIcons===!1?"":t||r===100?re.green("\u2713"):re.blue("\u25B6"),l=this.options.showTags!==!1&&this.name?` ${re.gray(this.formatTag(this.name))}`:"",g=`\r${u}${l} ${a} ${c}${f}`,p=de.stdout.columns||80,v=" ".repeat(Math.max(0,p-g.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${g}${v}`,de.stdout.write(e.lastRenderedLine),t)de.stdout.write(`
94
+ `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||De()||!de.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(De()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await ti(this.config.logDirectory),r=[];for(let n of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(n):n.startsWith(this.name))||!n.endsWith(".log"))continue;let i=Xt(this.config.logDirectory,n);if(e.before)try{if((await Zt(i)).mtime>=e.before)continue}catch(s){console.error(`Failed to get stats for file ${i}:`,s);continue}r.push(i)}if(r.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${r.length} log file(s)...`);for(let n of r)try{await ri(n),console.warn(`Deleted log file: ${n}`)}catch(i){console.error(`Failed to delete log file ${n}:`,i)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}async function Ea(e,t={}){let{maxRetries:r=3,retryDelay:n=1000,isRetryable:i=()=>!0,fallback:s}=t,o=Error("Unknown error occurred");for(let a=0;a<=r;a++)try{return await e()}catch(c){if(o=c instanceof Error?c:Error(String(c)),a===r||!i(o))break;if(n>0)await new Promise((f)=>setTimeout(f,n))}if(s!==void 0)return s;throw o instanceof Error?o:Error(`Unknown error: ${String(o)}`)}function ba(e){return e instanceof Ze}function Bu(e){return e instanceof xi}function Gu(e){if(ba(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 Mi{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,r={}){let{prefix:n,useCamelCase:i=!0,useBackwardCompatibility:s=!0,customParsers:o={},verbose:a=!1,trackPerformance:c=!0}=r,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:i,useBackwardCompatibility:s,customParsers:o,verbose:a,configName:e}),{config:l,source:{type:"environment",priority:50,timestamp:new Date}}};if(c)return Er.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,r,n){for(let[i,s]of Object.entries(e)){let o=[...t,i],a=o.map((u)=>this.formatEnvKey(u,n.useCamelCase)),c=`${r}_${a.join("_")}`,f=n.useBackwardCompatibility?`${r}_${o.map((u)=>u.toUpperCase()).join("_")}`:null;if(n.verbose);if(typeof s==="object"&&s!==null&&!Array.isArray(s))this.processObject(s,o,r,n);else{let u=ii.env[c]||(f?ii.env[f]:void 0);if(u!==void 0){if(n.verbose){let l=ii.env[c]?c:f}try{e[i]=this.parseEnvironmentValue(u,typeof s,c,n.customParsers,n.configName)}catch(l){if(l instanceof Ti)throw l;throw xt.envVar(c,u,typeof s,n.configName)}}}}}parseEnvironmentValue(e,t,r,n,i){for(let[s,o]of Object.entries(n))try{return o(e)}catch{continue}for(let s of this.defaultParsers)if(s.canParse(e,t))try{return s.parse(e)}catch{throw xt.envVar(r,e,`${t} (via ${s.name} parser)`,i)}return e}getEnvironmentVariables(e){let t={},r=e.toUpperCase();for(let[n,i]of Object.entries(ii.env))if(n.startsWith(r)&&i!==void 0)t[n]=i;return t}validateEnvironmentVariable(e,t,r){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(r)try{this.parseEnvironmentValue(e,t,r,{})}catch(i){n.push(`Cannot parse value "${t}" as ${r}: ${i}`)}return{isValid:n.length===0,errors:n}}generateEnvVarDocs(e,t,r={}){let{prefix:n,format:i="text"}=r,s=n||this.generateEnvPrefix(e),o=[];switch(this.extractEnvVarInfo(t,[],s,o),i){case"markdown":return this.formatAsMarkdown(o,e);case"json":return JSON.stringify(o,null,2);default:return this.formatAsText(o,e)}}extractEnvVarInfo(e,t,r,n){for(let[i,s]of Object.entries(e)){let o=[...t,i],a=`${r}_${o.map((c)=>this.formatEnvKey(c,!0)).join("_")}`;if(typeof s==="object"&&s!==null&&!Array.isArray(s))this.extractEnvVarInfo(s,o,r,n);else n.push({key:a,type:Array.isArray(s)?"array":typeof s,description:`Configuration for ${o.join(".")}`,example:this.generateExample(s)})}}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 r=`Environment Variables for ${t}:
94
95
 
95
96
  `;for(let n of e)r+=`${n.key}
96
97
  `,r+=` Type: ${n.type}
@@ -102,25 +103,25 @@ ${Hr}/
102
103
  `;r+=`| Variable | Type | Description | Example |
103
104
  `,r+=`|----------|------|-------------|----------|
104
105
  `;for(let n of e)r+=`| \`${n.key}\` | ${n.type} | ${n.description} | \`${n.example}\` |
105
- `;return r}}function Bu(e,t){let r=$a("process");if(typeof r>"u"||!r.env)return t;let n=r.env[e];return n!==void 0?n:t}function Ea(e,t,r={}){return ba(e,t,r,new WeakMap)}function ba(e,t,r,n){let{arrayMergeMode:i="replace",skipNullish:s=!1,customMerger:o}=r;if(t===null||t===void 0)return s?e:t;if(o){let a=o(e,t);if(a!==void 0)return a}if(Array.isArray(t)||Array.isArray(e))return Sa(e,t,i,n);if(!rt(t)||!rt(e))return t;return Vu(e,t,r,n)}function Sa(e,t,r,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(r){case"replace":return t;case"concat":return Gu(e,t);case"smart":return ju(e,t,n);default:return t}return t}function Gu(e,t){let r=[...t];for(let n of e)if(!r.some((i)=>jn(i,n)))r.push(n);return r}function ju(e,t,r){if(t.length===0)return e;if(e.length===0)return t;if(rt(t[0])&&rt(e[0]))return _u(e,t,r);if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let i of e)if(!n.includes(i))n.push(i);return n}return t}function _u(e,t,r){let n=[...t];for(let i of e){if(!rt(i)){n.push(i);continue}let s=["id","name","key","path","type"],o=!1;for(let a of s)if(a in i){if(n.find((c)=>rt(c)&&(a in c)&&c[a]===i[a])){o=!0;break}}if(!o)n.push(i)}return n}function Vu(e,t,r,n){let i=t;if(rt(i)&&n.has(i))return n.get(i);let s={...e};if(rt(i))n.set(i,s);for(let o in i){if(!Object.prototype.hasOwnProperty.call(i,o))continue;let a=i[o],c=s[o];if(r.skipNullish&&(a===null||a===void 0))continue;if(a===null||a===void 0){s[o]=a;continue}if(rt(a)&&rt(c))s[o]=ba(c,a,r,n);else if(Array.isArray(a)||Array.isArray(c))s[o]=Sa(c,a,r.arrayMergeMode||"smart",n);else s[o]=a}return s}function rs(e,t,r="replace"){return Ea(e,t,{arrayMergeMode:r==="replace"?"replace":"smart",skipNullish:!0})}function jn(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!jn(e[r],t[r]))return!1;return!0}if(rt(e)&&rt(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!jn(e[i],t[i]))return!1}return!0}return!1}function rt(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class ki{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(e,t,r={}){let{arrayStrategy:n="replace",useCache:i=!0,cacheTtl:s,trackPerformance:o=!0,verbose:a=!1}=r;if(i){let f=rr.getWithFileCheck("file",e);if(f){if(a)console.log(`Configuration loaded from cache: ${e}`);return f}}let c=async()=>{if(!ri(e))return null;try{let f=`?t=${Date.now()}`,u=await import(e+f),l=u.default||u,g="default"in u,d=Object.keys(u).length>0;if(!g&&!d)throw new Cr(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof l!=="object"||l===null||Array.isArray(l))throw new Cr(e,Error("Configuration must export a valid object"),"unknown");let v={config:rs(t,l,n),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(i)rr.setWithFileCheck("file",v,e,s);return v}catch(f){throw f instanceof Error?$t.configLoad(e,f):$t.configLoad(e,Error(String(f)))}};if(o)return vr.track("loadFromPath",c,{path:e});return c()}async tryLoadFromPaths(e,t,r={}){for(let n of e)try{let i=await this.loadFromPath(n,t,r);if(i)return i}catch(i){if(i instanceof Error&&i.name==="ConfigLoadError")throw i;if(r.verbose)console.warn(`Failed to load config from ${n}:`,i)}return null}generateConfigPaths(e,t,r){let n=this.generateNamePatterns(e,r),i=[];for(let s of n)for(let o of this.extensions)i.push(Pn(t,`${s}${o}`));return i}generateNamePatterns(e,t){let r=[];if(r.push("config",".config"),e)r.push(e,`.${e}.config`,`${e}.config`,`.${e}`);if(t){if(r.push(t,`.${t}.config`,`${t}.config`,`.${t}`),e)r.push(`${e}.${t}.config`,`.${e}.${t}.config`)}return r.filter(Boolean)}checkFileAccess(e){return wa(async()=>ri(e),{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,t,r){let n=[];if(!ri(e))return n;if(t||r){let i=this.generateNamePatterns(t||"",r);for(let s of i)for(let o of this.extensions){let a=Pn(e,`${s}${o}`);if(await this.checkFileAccess(a))n.push(a)}}else try{let{readdirSync:i}=await import("fs"),s=i(e);for(let o of s)if(this.looksLikeConfigFile(o)){let a=Pn(e,o);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(!ri(e))return t.push("Configuration file does not exist"),t;let r=await import(e),n=r.default||r;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:i}=await import("fs"),s=i(e,"utf8");JSON.parse(s)}catch(i){t.push(`Invalid JSON syntax: ${i}`)}}catch(r){t.push(`Failed to load configuration file: ${r}`)}return t}async getFileModificationTime(e){try{let{statSync:t}=await import("fs");return t(e).mtime}catch{return null}}async preloadConfigurations(e,t={}){let r=new Map;return await Promise.allSettled(e.map(async(n)=>{try{let i=await this.loadFromPath(n,{},t);if(i)r.set(n,i.config)}catch(i){if(t.verbose)console.warn(`Failed to preload ${n}:`,i)}})),r}}class is{async validateConfiguration(e,t,r={}){let{stopOnFirstError:n=!1,validateRequired:i=!0,validateTypes:s=!0,customRules:o=[],trackPerformance:a=!0,verbose:c=!1}=r,f=async()=>{let u=[],l=[],g={stopOnFirstError:n,validateRequired:i,validateTypes:s,customRules:o,trackPerformance:a,verbose:c};try{if(typeof t==="string")return await this.validateWithSchemaFile(e,t,g);else if(Array.isArray(t))return this.validateWithRules(e,[...t,...o],g);else return this.validateWithJSONSchema(e,t,g)}catch(d){return u.push({path:"",message:`Validation failed: ${d}`,rule:"system"}),{isValid:!1,errors:u,warnings:l}}};if(a)return await vr.track("validateConfiguration",f);return f()}async validateWithSchemaFile(e,t,r){try{if(!iu(t))throw new wr(t,[{path:"",message:"Schema file does not exist"}]);let n=await import(t),i=n.default||n;if(Array.isArray(i))return this.validateWithRules(e,i,r);else return this.validateWithJSONSchema(e,i,r)}catch(n){throw new wr(t,[{path:"",message:`Failed to load schema: ${n}`}])}}validateWithJSONSchema(e,t,r){let n=[],i=[];return this.validateObjectAgainstSchema(e,t,"",n,i,r),{isValid:n.length===0,errors:n,warnings:i}}validateObjectAgainstSchema(e,t,r,n,i,s){if(s.validateTypes&&t.type){let o=Array.isArray(e)?"array":typeof e,a=Array.isArray(t.type)?t.type:[t.type];if(!a.includes(o)){if(n.push({path:r,message:`Expected type ${a.join(" or ")}, got ${o}`,expected:a.join(" or "),actual:o,rule:"type"}),s.stopOnFirstError)return}}if(t.enum&&!t.enum.includes(e)){if(n.push({path:r,message:`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"}),s.stopOnFirstError)return}if(typeof e==="string"){if(t.minLength!==void 0&&e.length<t.minLength)n.push({path:r,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:r,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:r,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:r,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:r,message:`Value must not exceed ${t.maximum}`,expected:`<= ${t.maximum}`,actual:e,rule:"maximum"})}if(Array.isArray(e)&&t.items)for(let o=0;o<e.length;o++){let a=r?`${r}[${o}]`:`[${o}]`;if(this.validateObjectAgainstSchema(e[o],t.items,a,n,i,s),s.stopOnFirstError&&n.length>0)return}if(e&&typeof e==="object"&&!Array.isArray(e)){let o=e;if(s.validateRequired&&t.required){for(let a of t.required)if(!(a in o)){if(n.push({path:r?`${r}.${a}`:a,message:`Missing required property '${a}'`,expected:"required",rule:"required"}),s.stopOnFirstError)return}}if(t.properties){for(let[a,c]of Object.entries(t.properties))if(a in o){let f=r?`${r}.${a}`:a;if(this.validateObjectAgainstSchema(o[a],c,f,n,i,s),s.stopOnFirstError&&n.length>0)return}}if(t.additionalProperties===!1){let a=new Set(Object.keys(t.properties||{}));for(let c of Object.keys(o))if(!a.has(c))i.push({path:r?`${r}.${c}`:c,message:`Additional property '${c}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(e,t,r){let n=[],i=[];for(let s of t)try{let o=this.getValueByPath(e,s.path),a=this.validateWithRule(o,s,s.path);if(n.push(...a),r.stopOnFirstError&&n.length>0)break}catch(o){n.push({path:s.path,message:`Rule validation failed: ${o}`,rule:"system"})}return{isValid:n.length===0,errors:n,warnings:i}}validateWithRule(e,t,r){let n=[];if(t.required&&(e===void 0||e===null))return n.push({path:r,message:t.message||`Property '${r}' is required`,expected:"required",rule:"required"}),n;if(e===void 0||e===null)return n;if(t.type){let i=Array.isArray(e)?"array":typeof e;if(i!==t.type)n.push({path:r,message:t.message||`Expected type ${t.type}, got ${i}`,expected:t.type,actual:i,rule:"type"})}if(t.min!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i<t.min)n.push({path:r,message:t.message||`Value must be at least ${t.min}`,expected:`>= ${t.min}`,actual:i,rule:"min"})}if(t.max!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i>t.max)n.push({path:r,message:t.message||`Value must not exceed ${t.max}`,expected:`<= ${t.max}`,actual:i,rule:"max"})}if(t.pattern&&typeof e==="string"){if(!t.pattern.test(e))n.push({path:r,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:r,message:t.message||`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"});if(t.validator){let i=t.validator(e);if(i)n.push({path:r,message:t.message||i,rule:"custom"})}return n}getValueByPath(e,t){if(!t)return e;let r=t.split("."),n=e;for(let i of r)if(n&&typeof n==="object"&&i in n)n=n[i];else return;return n}generateRulesFromInterface(e){let t=[],r=e.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let n of r){let[,i,s,o]=n;t.push({path:i,required:!s,type:this.mapTypeScriptType(o)})}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:Oa},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}class ns{fileLoader=new ki;envProcessor=new Oi;validator=new is;async loadConfig(e){let t=Date.now(),{cache:r,performance:n,schema:i,validate:s,...o}=e;try{if(r?.enabled){let c=this.checkCache(o.name||"",o);if(c)return c}let a;try{a=await this.loadConfigurationStrategies(o,!0,r)}catch(c){let f=o.__strictErrorHandling;if(c instanceof Error&&c.name==="ConfigNotFoundError"){if(f)throw c;a={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:[`No configuration file found for "${o.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")),g=c.message.includes("Configuration must export a valid object")||c.message.includes("Configuration file is empty and exports nothing");if(f&&(g||u))throw c;if(l&&(!f||!g))a={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!f)a={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:[`Configuration loading error, using defaults: ${c.message}`]};else throw c}else a={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${c instanceof Error?c.message:String(c)}`]}}if(i||s)await this.validateConfiguration(a.config,i,s,o.name);if(r?.enabled&&a)this.cacheResult(o.name||"",a,r,o);if(n?.enabled){let c={operation:"loadConfig",duration:Date.now()-t,configName:o.name,timestamp:new Date};if(n.onMetrics)n.onMetrics(c);if(n.slowThreshold&&c.duration>n.slowThreshold)st.warn(`Slow configuration loading detected: ${c.duration}ms for ${o.name}`);a.metrics=c}return a}catch(a){let c=Date.now()-t;throw st.error(`Configuration loading failed after ${c}ms:`,[a instanceof Error?a:Error(String(a))]),a}}async loadConfigurationStrategies(e,t=!1,r){let{name:n="",alias:i,cwd:s,configDir:o,defaultConfig:a,checkEnv:c=!0,arrayStrategy:f="replace",verbose:u=!1}=e,l=s||kt.cwd(),g=[],d=await this.loadLocalConfiguration(n,i,l,o,a,f,u,c,r);if(d)return g.push(...this.getLocalSearchPaths(n,i,l,o)),this.finalizeResult(d,g,c,n,u);let v=await this.loadHomeConfiguration(n,i,a,f,u,c);if(v)return g.push(...this.getHomeSearchPaths(n,i)),this.finalizeResult(v,g,c,n,u);let b=await this.loadPackageJsonConfiguration(n,i,l,a,f,u,c);if(b)return g.push(Ke(l,"package.json")),this.finalizeResult(b,g,c,n,u);if(g.push(...this.getAllSearchPaths(n,i,l,o)),t)throw $t.configNotFound(n,g,i);return{...await this.applyEnvironmentVariables(n,a,c,u),warnings:[`No configuration file found for "${n}"${i?` or alias "${i}"`:""}, using defaults with environment variables`]}}async loadLocalConfiguration(e,t,r,n,i,s,o,a,c){let f=a?gr(e,i,o):i,u=this.getLocalDirectories(r,n);for(let l of u){if(o)st.info(`Searching for configuration in: ${l}`);let g=this.fileLoader.generateConfigPaths(e,l,t),d=await this.fileLoader.tryLoadFromPaths(g,f,{arrayStrategy:s,verbose:o,cacheTtl:c?.ttl,useCache:!c?.ttl||c.ttl>100});if(d){if(o)st.success(`Configuration loaded from: ${d.source.path}`);return d}}return null}async loadHomeConfiguration(e,t,r,n,i,s){if(!e)return null;let o=s?gr(e,r,i):r,a=[Ke(Ht(),".config",e),Ke(Ht(),".config"),Ht()];for(let c of a){if(i)st.info(`Checking home directory: ${c}`);let f=this.fileLoader.generateConfigPaths(e,c,t),u=await this.fileLoader.tryLoadFromPaths(f,o,{arrayStrategy:n,verbose:i});if(u){if(i)st.success(`Configuration loaded from home directory: ${u.source.path}`);return u}}return null}async loadPackageJsonConfiguration(e,t,r,n,i,s,o){let a=o?gr(e,n,s):n;try{let c=Ke(r,"package.json");if(!Bn(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(s)st.success(`Configuration loaded from package.json: ${l}`);return{config:rs(a,u,i),source:{type:"package.json",path:c,priority:30,timestamp:new Date}}}}catch(c){if(s)st.warn("Failed to load package.json:",[c instanceof Error?c:Error(String(c))])}return null}async applyEnvironmentVariables(e,t,r,n){if(!r||!e||typeof t!=="object"||t===null||Array.isArray(t))return{config:t,source:{type:"default",priority:10,timestamp:new Date}};return{config:gr(e,t,n),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(e,t,r,n,i){return{config:e.config,source:e.source,path:e.source.path}}async validateConfiguration(e,t,r,n){let i=[];if(r){let s=r(e);if(s)i.push(...s)}if(t){let s=await this.validator.validateConfiguration(e,t);if(!s.isValid)i.push(...s.errors.map((o)=>o.path?`${o.path}: ${o.message}`:o.message))}if(i.length>0)throw $t.configValidation(n||"unknown",i,n)}checkCache(e,t){let r=this.generateCacheKey(e,t);return rr.get(r)||null}cacheResult(e,t,r,n){let i=this.generateCacheKey(e,n);rr.set(i,t,void 0,r.ttl)}generateCacheKey(e,t){let r=[e];if(t.alias)r.push(`alias:${t.alias}`);if(t.cwd)r.push(`cwd:${t.cwd}`);if(t.configDir)r.push(`configDir:${t.configDir}`);if("checkEnv"in t)r.push(`checkEnv:${t.checkEnv}`);return r.join("|")}getLocalDirectories(e,t){return Array.from(new Set([e,Ke(e,"config"),Ke(e,".config"),t?Ke(e,t):void 0].filter(Boolean)))}getAllSearchPaths(e,t,r,n){let i=[];return i.push(...this.getLocalSearchPaths(e,t,r,n)),i.push(...this.getHomeSearchPaths(e,t)),i.push(Ke(r,"package.json")),i}getLocalSearchPaths(e,t,r,n){let i=this.getLocalDirectories(r,n),s=[];for(let o of i)s.push(...this.fileLoader.generateConfigPaths(e,o,t));return s}getHomeSearchPaths(e,t){if(!e)return[];let r=[Ke(Ht(),".config",e),Ke(Ht(),".config"),Ht()],n=[];for(let i of r)n.push(...this.fileLoader.generateConfigPaths(e,i,t));return n}async loadConfigWithResult(e){return this.loadConfig(e)}}function Qo(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")),r=e.message.includes("Configuration must export a valid object")||e.message.includes("Configuration file is empty and exports nothing");return t||r}async function Uu(e){return wt.loadConfig({...e,__strictErrorHandling:!0})}async function Aa(e){let t="defaultConfig"in e&&e.defaultConfig!==void 0?e.defaultConfig:{},r="cache"in e||"performance"in e||"schema"in e||"validate"in e;try{let n;if(r)n=await wt.loadConfig(e);else n=await wt.loadConfig({...e,defaultConfig:t,cache:{enabled:!0},performance:{enabled:!1}});return n?.config??t}catch(n){let i=n instanceof Error?n.name:"UnknownError",s=n instanceof Error?n.message:String(n);if(!(i==="ConfigNotFoundError"||i==="ConfigLoadError"||i==="ConfigValidationError"||s.includes("config"))&&e.verbose)st.warn("Unexpected error loading config, using defaults:",[n instanceof Error?n:Error(String(n))]);let o=r?{...e,defaultConfig:t}:{...e,defaultConfig:t,cache:{enabled:!0},performance:{enabled:!1}};if("checkEnv"in e?e.checkEnv!==!1:!0)return(await wt.applyEnvironmentVariables(o.name||"",t,!0,o.verbose||!1))?.config??t;return t}}async function Ku(e={defaultConfig:{}}){if(typeof e==="string"){let{cwd:t}=await import("process");try{return(await wt.loadConfig({name:e,cwd:t(),generatedDir:"./generated",configDir:"./config",defaultConfig:{},checkEnv:!0,arrayStrategy:"replace"})).config}catch(r){if(r instanceof Error&&(r.name==="ConfigNotFoundError"||r.name==="ConfigLoadError"&&Qo(r)))return(await wt.applyEnvironmentVariables(e,{},!0,!1)).config;throw r}}try{return(await wt.loadConfig({...e,cwd:e.cwd||kt.cwd(),cache:{enabled:!0},performance:{enabled:!1}})).config}catch(t){if(t instanceof Error&&(t.name==="ConfigNotFoundError"||t.name==="ConfigLoadError"&&Qo(t)))return(await wt.applyEnvironmentVariables(e.name||"",e.defaultConfig||{},e.checkEnv!==!1,e.verbose||!1)).config;throw t}}async function Hu(e,t,r="replace"){let n=new ki;try{let i=await n.loadFromPath(e,t,{arrayStrategy:r,useCache:!1,trackPerformance:!1});return i?i.config:null}catch{return null}}function gr(e,t,r=!1){let n=new Oi,i=e.toUpperCase().replace(/[^A-Z0-9]/g,"_");function s(o,a=[]){let c={...o};for(let[f,u]of Object.entries(o)){let l=[...a,f],g=[`${i}_${l.join("_").toUpperCase()}`,`${i}_${l.map((b)=>b.toUpperCase()).join("")}`,`${i}_${l.map((b)=>b.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],d,v;for(let b of g)if(d=kt.env[b],d!==void 0){v=b;break}if(d!==void 0&&v)if(typeof u==="boolean")c[f]=["true","1","yes"].includes(d.toLowerCase());else if(typeof u==="number"){let b=Number(d);if(!Number.isNaN(b))c[f]=b}else if(Array.isArray(u))try{c[f]=JSON.parse(d)}catch{c[f]=d.split(",").map((b)=>b.trim())}else c[f]=d;else if(u&&typeof u==="object"&&!Array.isArray(u))c[f]=s(u,l)}return c}return s(t)}function zu(e){let t=Ke(kt.cwd(),e.configDir),r=Ke(kt.cwd(),e.generatedDir),n=Ke(r,"config-types.ts");if(!Bn(Oo(n)))If(Oo(n),{recursive:!0,mode:511});let i=Bn(t)?Ff(t).map((o)=>o.replace(/\.(ts|js|mjs|cjs|mts|cts|json)$/,"")).sort():[],s=`// Generated by bunfig v${bh}
106
+ `;return r}}function ju(e,t){let r=Ta("process");if(typeof r>"u"||!r.env)return t;let n=r.env[e];return n!==void 0?n:t}function Sa(e,t,r={}){return $a(e,t,r,new WeakMap)}function $a(e,t,r,n){let{arrayMergeMode:i="replace",skipNullish:s=!1,customMerger:o}=r;if(t===null||t===void 0)return s?e:t;if(o){let a=o(e,t);if(a!==void 0)return a}if(Array.isArray(t)||Array.isArray(e))return Aa(e,t,i,n);if(!it(t)||!it(e))return t;return Ku(e,t,r,n)}function Aa(e,t,r,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(r){case"replace":return t;case"concat":return _u(e,t);case"smart":return Vu(e,t,n);default:return t}return t}function _u(e,t){let r=[...t];for(let n of e)if(!r.some((i)=>Vn(i,n)))r.push(n);return r}function Vu(e,t,r){if(t.length===0)return e;if(e.length===0)return t;if(it(t[0])&&it(e[0]))return Uu(e,t,r);if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let i of e)if(!n.includes(i))n.push(i);return n}return t}function Uu(e,t,r){let n=[...t];for(let i of e){if(!it(i)){n.push(i);continue}let s=["id","name","key","path","type"],o=!1;for(let a of s)if(a in i){if(n.find((c)=>it(c)&&(a in c)&&c[a]===i[a])){o=!0;break}}if(!o)n.push(i)}return n}function Ku(e,t,r,n){let i=t;if(it(i)&&n.has(i))return n.get(i);let s={...e};if(it(i))n.set(i,s);for(let o in i){if(!Object.prototype.hasOwnProperty.call(i,o))continue;let a=i[o],c=s[o];if(r.skipNullish&&(a===null||a===void 0))continue;if(a===null||a===void 0){s[o]=a;continue}if(it(a)&&it(c))s[o]=$a(c,a,r,n);else if(Array.isArray(a)||Array.isArray(c))s[o]=Aa(c,a,r.arrayMergeMode||"smart",n);else s[o]=a}return s}function ns(e,t,r="replace"){return Sa(e,t,{arrayMergeMode:r==="replace"?"replace":"smart",skipNullish:!0})}function Vn(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Vn(e[r],t[r]))return!1;return!0}if(it(e)&&it(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!Vn(e[i],t[i]))return!1}return!0}return!1}function it(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class Di{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(e,t,r={}){let{arrayStrategy:n="replace",useCache:i=!0,cacheTtl:s,trackPerformance:o=!0,verbose:a=!1}=r;if(i){let f=ir.getWithFileCheck("file",e);if(f){if(a)console.log(`Configuration loaded from cache: ${e}`);return f}}let c=async()=>{if(!ni(e))return null;try{let f=`?t=${Date.now()}`,u=await import(e+f),l=u.default||u,g="default"in u,p=Object.keys(u).length>0;if(!g&&!p)throw new wr(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof l!=="object"||l===null||Array.isArray(l))throw new wr(e,Error("Configuration must export a valid object"),"unknown");let v={config:ns(t,l,n),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(i)ir.setWithFileCheck("file",v,e,s);return v}catch(f){throw f instanceof Error?xt.configLoad(e,f):xt.configLoad(e,Error(String(f)))}};if(o)return Er.track("loadFromPath",c,{path:e});return c()}async tryLoadFromPaths(e,t,r={}){for(let n of e)try{let i=await this.loadFromPath(n,t,r);if(i)return i}catch(i){if(i instanceof Error&&i.name==="ConfigLoadError")throw i;if(r.verbose)console.warn(`Failed to load config from ${n}:`,i)}return null}generateConfigPaths(e,t,r){let n=this.generateNamePatterns(e,r),i=[];for(let s of n)for(let o of this.extensions)i.push(On(t,`${s}${o}`));return i}generateNamePatterns(e,t){let r=[];if(r.push("config",".config"),e)r.push(e,`.${e}.config`,`${e}.config`,`.${e}`);if(t){if(r.push(t,`.${t}.config`,`${t}.config`,`.${t}`),e)r.push(`${e}.${t}.config`,`.${e}.${t}.config`)}return r.filter(Boolean)}checkFileAccess(e){return Ea(async()=>ni(e),{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,t,r){let n=[];if(!ni(e))return n;if(t||r){let i=this.generateNamePatterns(t||"",r);for(let s of i)for(let o of this.extensions){let a=On(e,`${s}${o}`);if(await this.checkFileAccess(a))n.push(a)}}else try{let{readdirSync:i}=await import("fs"),s=i(e);for(let o of s)if(this.looksLikeConfigFile(o)){let a=On(e,o);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(!ni(e))return t.push("Configuration file does not exist"),t;let r=await import(e),n=r.default||r;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:i}=await import("fs"),s=i(e,"utf8");JSON.parse(s)}catch(i){t.push(`Invalid JSON syntax: ${i}`)}}catch(r){t.push(`Failed to load configuration file: ${r}`)}return t}async getFileModificationTime(e){try{let{statSync:t}=await import("fs");return t(e).mtime}catch{return null}}async preloadConfigurations(e,t={}){let r=new Map;return await Promise.allSettled(e.map(async(n)=>{try{let i=await this.loadFromPath(n,{},t);if(i)r.set(n,i.config)}catch(i){if(t.verbose)console.warn(`Failed to preload ${n}:`,i)}})),r}}class ss{async validateConfiguration(e,t,r={}){let{stopOnFirstError:n=!1,validateRequired:i=!0,validateTypes:s=!0,customRules:o=[],trackPerformance:a=!0,verbose:c=!1}=r,f=async()=>{let u=[],l=[],g={stopOnFirstError:n,validateRequired:i,validateTypes:s,customRules:o,trackPerformance:a,verbose:c};try{if(typeof t==="string")return await this.validateWithSchemaFile(e,t,g);else if(Array.isArray(t))return this.validateWithRules(e,[...t,...o],g);else return this.validateWithJSONSchema(e,t,g)}catch(p){return u.push({path:"",message:`Validation failed: ${p}`,rule:"system"}),{isValid:!1,errors:u,warnings:l}}};if(a)return await Er.track("validateConfiguration",f);return f()}async validateWithSchemaFile(e,t,r){try{if(!su(t))throw new vr(t,[{path:"",message:"Schema file does not exist"}]);let n=await import(t),i=n.default||n;if(Array.isArray(i))return this.validateWithRules(e,i,r);else return this.validateWithJSONSchema(e,i,r)}catch(n){throw new vr(t,[{path:"",message:`Failed to load schema: ${n}`}])}}validateWithJSONSchema(e,t,r){let n=[],i=[];return this.validateObjectAgainstSchema(e,t,"",n,i,r),{isValid:n.length===0,errors:n,warnings:i}}validateObjectAgainstSchema(e,t,r,n,i,s){if(s.validateTypes&&t.type){let o=Array.isArray(e)?"array":typeof e,a=Array.isArray(t.type)?t.type:[t.type];if(!a.includes(o)){if(n.push({path:r,message:`Expected type ${a.join(" or ")}, got ${o}`,expected:a.join(" or "),actual:o,rule:"type"}),s.stopOnFirstError)return}}if(t.enum&&!t.enum.includes(e)){if(n.push({path:r,message:`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"}),s.stopOnFirstError)return}if(typeof e==="string"){if(t.minLength!==void 0&&e.length<t.minLength)n.push({path:r,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:r,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:r,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:r,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:r,message:`Value must not exceed ${t.maximum}`,expected:`<= ${t.maximum}`,actual:e,rule:"maximum"})}if(Array.isArray(e)&&t.items)for(let o=0;o<e.length;o++){let a=r?`${r}[${o}]`:`[${o}]`;if(this.validateObjectAgainstSchema(e[o],t.items,a,n,i,s),s.stopOnFirstError&&n.length>0)return}if(e&&typeof e==="object"&&!Array.isArray(e)){let o=e;if(s.validateRequired&&t.required){for(let a of t.required)if(!(a in o)){if(n.push({path:r?`${r}.${a}`:a,message:`Missing required property '${a}'`,expected:"required",rule:"required"}),s.stopOnFirstError)return}}if(t.properties){for(let[a,c]of Object.entries(t.properties))if(a in o){let f=r?`${r}.${a}`:a;if(this.validateObjectAgainstSchema(o[a],c,f,n,i,s),s.stopOnFirstError&&n.length>0)return}}if(t.additionalProperties===!1){let a=new Set(Object.keys(t.properties||{}));for(let c of Object.keys(o))if(!a.has(c))i.push({path:r?`${r}.${c}`:c,message:`Additional property '${c}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(e,t,r){let n=[],i=[];for(let s of t)try{let o=this.getValueByPath(e,s.path),a=this.validateWithRule(o,s,s.path);if(n.push(...a),r.stopOnFirstError&&n.length>0)break}catch(o){n.push({path:s.path,message:`Rule validation failed: ${o}`,rule:"system"})}return{isValid:n.length===0,errors:n,warnings:i}}validateWithRule(e,t,r){let n=[];if(t.required&&(e===void 0||e===null))return n.push({path:r,message:t.message||`Property '${r}' is required`,expected:"required",rule:"required"}),n;if(e===void 0||e===null)return n;if(t.type){let i=Array.isArray(e)?"array":typeof e;if(i!==t.type)n.push({path:r,message:t.message||`Expected type ${t.type}, got ${i}`,expected:t.type,actual:i,rule:"type"})}if(t.min!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i<t.min)n.push({path:r,message:t.message||`Value must be at least ${t.min}`,expected:`>= ${t.min}`,actual:i,rule:"min"})}if(t.max!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i>t.max)n.push({path:r,message:t.message||`Value must not exceed ${t.max}`,expected:`<= ${t.max}`,actual:i,rule:"max"})}if(t.pattern&&typeof e==="string"){if(!t.pattern.test(e))n.push({path:r,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:r,message:t.message||`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"});if(t.validator){let i=t.validator(e);if(i)n.push({path:r,message:t.message||i,rule:"custom"})}return n}getValueByPath(e,t){if(!t)return e;let r=t.split("."),n=e;for(let i of r)if(n&&typeof n==="object"&&i in n)n=n[i];else return;return n}generateRulesFromInterface(e){let t=[],r=e.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let n of r){let[,i,s,o]=n;t.push({path:i,required:!s,type:this.mapTypeScriptType(o)})}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:Ma},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}class os{fileLoader=new Di;envProcessor=new Mi;validator=new ss;async loadConfig(e){let t=Date.now(),{cache:r,performance:n,schema:i,validate:s,...o}=e;try{if(r?.enabled){let c=this.checkCache(o.name||"",o);if(c)return c}let a;try{a=await this.loadConfigurationStrategies(o,!0,r)}catch(c){let f=o.__strictErrorHandling;if(c instanceof Error&&c.name==="ConfigNotFoundError"){if(f)throw c;a={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:[`No configuration file found for "${o.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")),g=c.message.includes("Configuration must export a valid object")||c.message.includes("Configuration file is empty and exports nothing");if(f&&(g||u))throw c;if(l&&(!f||!g))a={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!f)a={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:[`Configuration loading error, using defaults: ${c.message}`]};else throw c}else a={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${c instanceof Error?c.message:String(c)}`]}}if(i||s)await this.validateConfiguration(a.config,i,s,o.name);if(r?.enabled&&a)this.cacheResult(o.name||"",a,r,o);if(n?.enabled){let c={operation:"loadConfig",duration:Date.now()-t,configName:o.name,timestamp:new Date};if(n.onMetrics)n.onMetrics(c);if(n.slowThreshold&&c.duration>n.slowThreshold)ot.warn(`Slow configuration loading detected: ${c.duration}ms for ${o.name}`);a.metrics=c}return a}catch(a){let c=Date.now()-t;throw ot.error(`Configuration loading failed after ${c}ms:`,[a instanceof Error?a:Error(String(a))]),a}}async loadConfigurationStrategies(e,t=!1,r){let{name:n="",alias:i,cwd:s,configDir:o,defaultConfig:a,checkEnv:c=!0,arrayStrategy:f="replace",verbose:u=!1}=e,l=s||Mt.cwd(),g=[],p=await this.loadLocalConfiguration(n,i,l,o,a,f,u,c,r);if(p)return g.push(...this.getLocalSearchPaths(n,i,l,o)),this.finalizeResult(p,g,c,n,u);let v=await this.loadHomeConfiguration(n,i,a,f,u,c);if(v)return g.push(...this.getHomeSearchPaths(n,i)),this.finalizeResult(v,g,c,n,u);let b=await this.loadPackageJsonConfiguration(n,i,l,a,f,u,c);if(b)return g.push(He(l,"package.json")),this.finalizeResult(b,g,c,n,u);if(g.push(...this.getAllSearchPaths(n,i,l,o)),t)throw xt.configNotFound(n,g,i);return{...await this.applyEnvironmentVariables(n,a,c,u),warnings:[`No configuration file found for "${n}"${i?` or alias "${i}"`:""}, using defaults with environment variables`]}}async loadLocalConfiguration(e,t,r,n,i,s,o,a,c){let f=a?yr(e,i,o):i,u=this.getLocalDirectories(r,n);for(let l of u){if(o)ot.info(`Searching for configuration in: ${l}`);let g=this.fileLoader.generateConfigPaths(e,l,t),p=await this.fileLoader.tryLoadFromPaths(g,f,{arrayStrategy:s,verbose:o,cacheTtl:c?.ttl,useCache:!c?.ttl||c.ttl>100});if(p){if(o)ot.success(`Configuration loaded from: ${p.source.path}`);return p}}return null}async loadHomeConfiguration(e,t,r,n,i,s){if(!e)return null;let o=s?yr(e,r,i):r,a=[He(Ht(),".config",e),He(Ht(),".config"),Ht()];for(let c of a){if(i)ot.info(`Checking home directory: ${c}`);let f=this.fileLoader.generateConfigPaths(e,c,t),u=await this.fileLoader.tryLoadFromPaths(f,o,{arrayStrategy:n,verbose:i});if(u){if(i)ot.success(`Configuration loaded from home directory: ${u.source.path}`);return u}}return null}async loadPackageJsonConfiguration(e,t,r,n,i,s,o){let a=o?yr(e,n,s):n;try{let c=He(r,"package.json");if(!jn(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(s)ot.success(`Configuration loaded from package.json: ${l}`);return{config:ns(a,u,i),source:{type:"package.json",path:c,priority:30,timestamp:new Date}}}}catch(c){if(s)ot.warn("Failed to load package.json:",[c instanceof Error?c:Error(String(c))])}return null}async applyEnvironmentVariables(e,t,r,n){if(!r||!e||typeof t!=="object"||t===null||Array.isArray(t))return{config:t,source:{type:"default",priority:10,timestamp:new Date}};return{config:yr(e,t,n),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(e,t,r,n,i){return{config:e.config,source:e.source,path:e.source.path}}async validateConfiguration(e,t,r,n){let i=[];if(r){let s=r(e);if(s)i.push(...s)}if(t){let s=await this.validator.validateConfiguration(e,t);if(!s.isValid)i.push(...s.errors.map((o)=>o.path?`${o.path}: ${o.message}`:o.message))}if(i.length>0)throw xt.configValidation(n||"unknown",i,n)}checkCache(e,t){let r=this.generateCacheKey(e,t);return ir.get(r)||null}cacheResult(e,t,r,n){let i=this.generateCacheKey(e,n);ir.set(i,t,void 0,r.ttl)}generateCacheKey(e,t){let r=[e];if(t.alias)r.push(`alias:${t.alias}`);if(t.cwd)r.push(`cwd:${t.cwd}`);if(t.configDir)r.push(`configDir:${t.configDir}`);if("checkEnv"in t)r.push(`checkEnv:${t.checkEnv}`);return r.join("|")}getLocalDirectories(e,t){return Array.from(new Set([e,He(e,"config"),He(e,".config"),t?He(e,t):void 0].filter(Boolean)))}getAllSearchPaths(e,t,r,n){let i=[];return i.push(...this.getLocalSearchPaths(e,t,r,n)),i.push(...this.getHomeSearchPaths(e,t)),i.push(He(r,"package.json")),i}getLocalSearchPaths(e,t,r,n){let i=this.getLocalDirectories(r,n),s=[];for(let o of i)s.push(...this.fileLoader.generateConfigPaths(e,o,t));return s}getHomeSearchPaths(e,t){if(!e)return[];let r=[He(Ht(),".config",e),He(Ht(),".config"),Ht()],n=[];for(let i of r)n.push(...this.fileLoader.generateConfigPaths(e,i,t));return n}async loadConfigWithResult(e){return this.loadConfig(e)}}function ta(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")),r=e.message.includes("Configuration must export a valid object")||e.message.includes("Configuration file is empty and exports nothing");return t||r}async function zu(e){return vt.loadConfig({...e,__strictErrorHandling:!0})}async function xa(e){let t="defaultConfig"in e&&e.defaultConfig!==void 0?e.defaultConfig:{},r="cache"in e||"performance"in e||"schema"in e||"validate"in e;try{let n;if(r)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 i=n instanceof Error?n.name:"UnknownError",s=n instanceof Error?n.message:String(n);if(!(i==="ConfigNotFoundError"||i==="ConfigLoadError"||i==="ConfigValidationError"||s.includes("config"))&&e.verbose)ot.warn("Unexpected error loading config, using defaults:",[n instanceof Error?n:Error(String(n))]);let o=r?{...e,defaultConfig:t}:{...e,defaultConfig:t,cache:{enabled:!0},performance:{enabled:!1}};if("checkEnv"in e?e.checkEnv!==!1:!0)return(await vt.applyEnvironmentVariables(o.name||"",t,!0,o.verbose||!1))?.config??t;return t}}async function Hu(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(r){if(r instanceof Error&&(r.name==="ConfigNotFoundError"||r.name==="ConfigLoadError"&&ta(r)))return(await vt.applyEnvironmentVariables(e,{},!0,!1)).config;throw r}}try{return(await vt.loadConfig({...e,cwd:e.cwd||Mt.cwd(),cache:{enabled:!0},performance:{enabled:!1}})).config}catch(t){if(t instanceof Error&&(t.name==="ConfigNotFoundError"||t.name==="ConfigLoadError"&&ta(t)))return(await vt.applyEnvironmentVariables(e.name||"",e.defaultConfig||{},e.checkEnv!==!1,e.verbose||!1)).config;throw t}}async function Ju(e,t,r="replace"){let n=new Di;try{let i=await n.loadFromPath(e,t,{arrayStrategy:r,useCache:!1,trackPerformance:!1});return i?i.config:null}catch{return null}}function yr(e,t,r=!1){let n=new Mi,i=e.toUpperCase().replace(/[^A-Z0-9]/g,"_");function s(o,a=[]){let c={...o};for(let[f,u]of Object.entries(o)){let l=[...a,f],g=[`${i}_${l.join("_").toUpperCase()}`,`${i}_${l.map((b)=>b.toUpperCase()).join("")}`,`${i}_${l.map((b)=>b.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],p,v;for(let b of g)if(p=Mt.env[b],p!==void 0){v=b;break}if(p!==void 0&&v)if(typeof u==="boolean")c[f]=["true","1","yes"].includes(p.toLowerCase());else if(typeof u==="number"){let b=Number(p);if(!Number.isNaN(b))c[f]=b}else if(Array.isArray(u))try{c[f]=JSON.parse(p)}catch{c[f]=p.split(",").map((b)=>b.trim())}else c[f]=p;else if(u&&typeof u==="object"&&!Array.isArray(u))c[f]=s(u,l)}return c}return s(t)}function qu(e){let t=He(Mt.cwd(),e.configDir),r=He(Mt.cwd(),e.generatedDir),n=He(r,"config-types.ts");if(!jn(Mo(n)))Nf(Mo(n),{recursive:!0,mode:511});let i=jn(t)?Lf(t).map((o)=>o.replace(/\.(ts|js|mjs|cjs|mts|cts|json)$/,"")).sort():[],s=`// Generated by bunfig v${$h}
106
107
  export type ConfigNames = ${i.length?`'${i.join("' | '")}'`:"string"}
107
- `;Nf(n,s,{mode:438})}function Ju(e){let t=null,r=null,n=()=>{if(!r)r=Aa(e).then((s)=>(t=s,s),(s)=>{let o="defaultConfig"in e?e.defaultConfig:{};if(t=o,"verbose"in e&&e.verbose)st.warn("Config loading failed, using defaults:",[s instanceof Error?s:Error(String(s))]);return o});return r},i="defaultConfig"in e?e.defaultConfig:{};return t=i,n(),new Proxy({},{get(s,o){if(t)return t[o];let a=i[o];return n(),a},has(s,o){return o in(t||i)},ownKeys(){return Object.keys(t||i)},getOwnPropertyDescriptor(s,o){return Object.getOwnPropertyDescriptor(t||i,o)},set(s,o,a){if(!t)t={...i};return t[o]=a,!0}})}function qu(e){let t=Ko(ou.cwd(),e?.configDir||"./config");function r(){if(!nu(t))return[];let i=new Set([".ts",".js",".mjs",".cjs",".mts",".cts",".json"]),s=[".ts",".mts",".cts",".js",".mjs",".cjs",".json"],o=su(t).filter((c)=>i.has(Rn(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 o){let u=Rn(f).toLowerCase(),l=a.get(c);if(!l){a.set(c,f);continue}let g=Rn(l).toLowerCase();if(s.indexOf(u)<s.indexOf(g))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 i=r(),s=i.map((c)=>c.base),o=s.length?s.map((c)=>`'${c}'`).join(" | "):"string",a=i.length?`{
108
- ${i.map((c)=>{let f=Ko(t,c.file).replace(/\\/g,"/");return` '${c.base}': typeof import('${f}').default`}).join(`,
108
+ `;Wf(n,s,{mode:438})}function Yu(e){let t=null,r=null,n=()=>{if(!r)r=xa(e).then((s)=>(t=s,s),(s)=>{let o="defaultConfig"in e?e.defaultConfig:{};if(t=o,"verbose"in e&&e.verbose)ot.warn("Config loading failed, using defaults:",[s instanceof Error?s:Error(String(s))]);return o});return r},i="defaultConfig"in e?e.defaultConfig:{};return t=i,n(),new Proxy({},{get(s,o){if(t)return t[o];let a=i[o];return n(),a},has(s,o){return o in(t||i)},ownKeys(){return Object.keys(t||i)},getOwnPropertyDescriptor(s,o){return Object.getOwnPropertyDescriptor(t||i,o)},set(s,o,a){if(!t)t={...i};return t[o]=a,!0}})}function Zu(e){let t=Ho(lu.cwd(),e?.configDir||"./config");function r(){if(!ou(t))return[];let i=new Set([".ts",".js",".mjs",".cjs",".mts",".cts",".json"]),s=[".ts",".mts",".cts",".js",".mjs",".cjs",".json"],o=au(t).filter((c)=>i.has(kn(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 o){let u=kn(f).toLowerCase(),l=a.get(c);if(!l){a.set(c,f);continue}let g=kn(l).toLowerCase();if(s.indexOf(u)<s.indexOf(g))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 i=r(),s=i.map((c)=>c.base),o=s.length?s.map((c)=>`'${c}'`).join(" | "):"string",a=i.length?`{
109
+ ${i.map((c)=>{let f=Ho(t,c.file).replace(/\\/g,"/");return` '${c.base}': typeof import('${f}').default`}).join(`,
109
110
  `)}
110
111
  }`:"Record<string, any>";return`export type ConfigNames = ${o}
111
112
  export type ConfigByName = ${a}
112
113
  export type Config<N extends ConfigNames> = N extends keyof ConfigByName ? ConfigByName[N] : unknown
113
114
  export type ConfigOf = Config
114
- `}return{name:"bunfig-plugin",setup(i){i.onResolve({filter:/^virtual:bunfig-types$/},(s)=>({path:s.path,namespace:"bunfig-virtual"})),i.onLoad({filter:/^virtual:bunfig-types$/,namespace:"bunfig-virtual"},()=>({contents:n(),loader:"ts"}))}}}function Ah(e,t={}){let r=Ci.cwd();while(r.includes("storage"))r=Ho(r,"..");let n=Ho(r,e||"");if(t?.relative)return lu(Ci.cwd(),n);return n}function Ne(){if(Ct.env.NODE_ENV==="test"||Ct.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function xh(){if(Ct.env.NODE_ENV==="test"||Ct.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof Ct<"u"){let e=Ct.type;if(e==="renderer"||e==="worker")return!1;return!!(Ct.versions&&(Ct.versions.node||Ct.versions.bun))}return!1}class Ia{async format(e){let t=await xh(),r=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:r})}async getMetadata(e){if(e){let{hostname:t}=await import("os");return{pid:tr.pid,hostname:t(),environment:tr.env.NODE_ENV||"development",platform:tr.platform,version:tr.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:tr.env.NODE_ENV||tr.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class Mi{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={...xi},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??he.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let r={...t},n=t.timestamp!==void 0;if(n)delete r.timestamp;if(this.config={...this.config,...r,timestamp:n||this.config.timestamp,level:this.options.level??"info"},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let i=this.generateKeyId(),s=this.generateKey();this.currentKeyId=i,this.keys.set(i,s),this.encryptionKeys.set(i,{key:s,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;let t={debug:0,info:1,success:2,warning:3,error:4},r=this.fingersCrossedConfig.activationLevel??"error";return t[e]>=t[r]}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...Wn,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...Wn};return{...Wn,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:xi.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},r={...t,...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))};if(!r.level||!["debug","info","success","warning","error"].includes(r.level))r.level=t.level;return r}shouldWriteToFile(){return!Ne()&&this.config.writeToFile===!0}async writeToFile(e){let t=(async()=>{let n,i=0,s=3,o=1000;while(i<s)try{try{try{await du(this.config.logDirectory,Yo.F_OK|Yo.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await mu(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:mt.from(e);try{if(!ii(this.currentLogFile))await Mn(this.currentLogFile,"",{mode:420});if(n=qo(this.currentLogFile,"a",420),hu(n,a,{flag:"a"}),Jo(n),n!==void 0)kn(n),n=void 0;if((await Qt(this.currentLogFile)).size===0){if(await Mn(this.currentLogFile,a,{flag:"w",mode:420}),(await Qt(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(i<s-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${i+1}/${s}:`,u);let l=o*2**i;await new Promise((g)=>setTimeout(g,l)),i++;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(i===s-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}i++;let c=o*2**(i-1);await new Promise((f)=>setTimeout(f,c))}})();this.pendingOperations.push(t);let r=this.pendingOperations.length-1;try{await t}catch(n){throw console.error("Debug: [writeToFile] Error in operation:",n),n}finally{this.pendingOperations.splice(r,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 er(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 er(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return er(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(Ne())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,r=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((n)=>{console.error("Error rotating keys:",n)})},r)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let e=this.config.rotation.keyRotation,t=this.generateKeyId(),r=this.generateKey();this.currentKeyId=t,this.keys.set(t,r),this.encryptionKeys.set(t,{key:r,createdAt:new Date});let n=Array.from(this.encryptionKeys.entries()).sort(([,o],[,a])=>a.createdAt.getTime()-o.createdAt.getTime()),i=typeof e.maxKeys==="number"?e.maxKeys:1,s=Math.max(1,i);if(n.length>s)for(let[o]of n.slice(s))this.encryptionKeys.delete(o),this.keys.delete(o)}generateKeyId(){return On(16).toString("hex")}generateKey(){return On(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(),r=On(16),n=cu("aes-256-gcm",t,r),i=mt.isBuffer(e)?e:mt.from(e,"utf8"),s=n.update(i),o=n.final(),a=s.length+o.length,c=n.getAuthTag(),f=mt.allocUnsafe(16+a+16);return r.copy(f,0),s.copy(f,16),o.copy(f,16+s.length),c.copy(f,16+a),{encrypted:f,iv:r}}async compressData(e){return new Promise((t,r)=>{let n=Xo(),i=[];n.on("data",(s)=>i.push(s)),n.on("end",()=>t(mt.from(mt.concat(i)))),n.on("error",r),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(Ne())return;if(!this.shouldWriteToFile())return;let e=await Qt(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 r=this.currentLogFile,n=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let i=await ni(this.config.logDirectory),s=i.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}),o=s.length>0?Number.parseInt(s[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,a=`${r}.${o}`;if(await Qt(r).catch(()=>null))try{if(await Zo(r,a),t.compress)try{let c=`${a}.gz`;await this.compressLogFile(a,c),await si(a)}catch(c){console.error("Error compressing rotated file:",c)}if(s.length===0&&!i.some((c)=>c.endsWith(".log.1")))try{let c=`${r}.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 i=new Date().toISOString().replace(/[:.]/g,"-"),s=r.replace(/\.log$/,`-${i}.log`);if(await Qt(r).catch(()=>null))await Zo(r,s)}if(this.currentLogFile=n,t.maxFiles){let i=(await ni(this.config.logDirectory)).filter((s)=>s.startsWith(this.name)).sort((s,o)=>o.localeCompare(s));for(let s of i.slice(t.maxFiles))await si(er(this.config.logDirectory,s))}}}async compressLogFile(e,t){let r=zo(e),n=uu(t),i=Xo();await yu(r,i,n)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let r of this.logBuffer){let n=await this.formatter.format(r);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()})),ii(this.currentLogFile))try{let e=qo(this.currentLogFile,"r+");Jo(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(!Ne()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let e=(await ni(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await si(er(this.config.logDirectory,t))}catch(r){console.error(`Failed to delete temp file ${t}:`,r)}}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()?se.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||Ne())return!1;let e=typeof he.env.NO_COLOR<"u",t=he.env.FORCE_COLOR==="0";if(e||t)return!1;return!!(typeof he.stderr<"u"&&he.stderr.isTTY||typeof he.stdout<"u"&&he.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:t,icon:r="",tag:n="",message:i,level:s,showTimestamp:o=!0}=e,a=(d)=>d.replace(this.ANSI_PATTERN,"");if(!this.fancy){let d=[];if(o)d.push(t);if(s==="warning")d.push("WARN");else if(s==="error")d.push("ERROR");else if(r)d.push(r.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(n)d.push(n.replace(/[[\]]/g,""));return d.push(i),d.join(" ")}let c=he.stdout.columns||120,f="";if(s==="warning"||s==="error")f=`${r} ${i}`;else if(s==="info"||s==="success")f=`${r} ${n} ${i}`;else f=`${r} ${n} ${se.cyan(i)}`;if(!o)return f.trim();let u=a(f).trim().length,l=a(t).length,g=Math.max(1,c-2-u-l);return`${f.trim()}${" ".repeat(g)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(s,o)=>{let a=Number.parseInt(o,10);return a<t[0].length?String(t[0][a]):s});let r=/%([sdijfo%])/g,n=0,i=e.replace(r,(s,o)=>{if(o==="%")return"%";if(n>=t.length)return s;let a=t[n++];switch(o){case"s":return String(a);case"d":case"i":return Number(a).toString();case"j":case"o":return JSON.stringify(a,null,2);default:return s}});if(n<t.length)i+=` ${t.slice(n).map((s)=>typeof s==="object"?JSON.stringify(s,null,2):String(s)).join(" ")}`;return i}formatMarkdown(e){if(!e)return e;let t=e;return t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,n,i)=>{let s=se.underline(se.blue(n)),o=this.toAbsoluteFilePath(i);if(o&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let a=`file://${encodeURI(o)}`,c="\x1B]8;;",f="\x1B\\";return`\x1B]8;;${a}\x1B\\${s}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${i}\x1B\\${s}\x1B]8;;\x1B\\`;return s}),t=t.replace(/`([^`]+)`/g,(r,n)=>se.bgGray(n)),t=t.replace(/\*\*([^*]+)\*\*/g,(r,n)=>se.bold(n)),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(r,n)=>se.italic(n)),t=t.replace(/(?<!_)_([^_]+)_(?!_)/g,(r,n)=>se.italic(n)),t=t.replace(/~([^~]+)~/g,(r,n)=>se.strikethrough(n)),t}supportsHyperlinks(){if(Ne())return!1;let e=he.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 r=he.env.HOME||"";if(r)t=t.replace(/^~(?=$|\/)/,r)}if(pu(t)||t.startsWith("./")||t.startsWith("../"))t=gu(t);else return null;return ii(t)?t:null}catch{return null}}buildOutputTexts(e){let t=this.shouldStyleConsole()?this.formatMarkdown(e):e,r=e.replace(this.ANSI_PATTERN,"");return{consoleText:t,fileText:r}}async log(e,t,...r){if(!this.shouldLog(e))return;let n=new Date,i=this.formatConsoleTimestamp(n),s=this.formatFileTimestamp(n),o,a;if(t instanceof Error)o=t.message,a=t.stack;else o=this.formatMessage(t,r);let{consoleText:c,fileText:f}=this.buildOutputTexts(o);if(this.shouldStyleConsole()){let l=this.options.showIcons===!1?"":kh[e],g=this.options.showTags!==!1&&this.name?se.gray(this.formatTag(this.name)):"",d;switch(e){case"debug":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:se.gray(c),level:e}),console.error(d);break;case"info":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.warn(d);break;case"success":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:se.green(c),level:e}),console.error(d);break;case"warning":d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.warn(d);break;case"error":if(d=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.error(d),a){let v=a.split(`
115
- `);for(let b of v)if(b.trim()&&!b.includes(o))console.error(this.formatConsoleMessage({timestamp:i,message:se.gray(` ${b}`),level:e,showTimestamp:!1}))}break}}else if(!Ne()){if(console.error(`${s} ${this.environment}.${e.toUpperCase()}: ${o}`),a)console.error(a)}let u=`${s} ${this.environment}.${e.toUpperCase()}: ${f}
115
+ `}return{name:"bunfig-plugin",setup(i){i.onResolve({filter:/^virtual:bunfig-types$/},(s)=>({path:s.path,namespace:"bunfig-virtual"})),i.onLoad({filter:/^virtual:bunfig-types$/,namespace:"bunfig-virtual"},()=>({contents:n(),loader:"ts"}))}}}function xh(e,t={}){let r=vi.cwd();while(r.includes("storage"))r=Jo(r,"..");let n=Jo(r,e||"");if(t?.relative)return fu(vi.cwd(),n);return n}function Fe(){if(wt.env.NODE_ENV==="test"||wt.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Ph(){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 Na{async format(e){let t=await Ph(),r=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:r})}async getMetadata(e){if(e){let{hostname:t}=await import("os");return{pid:rr.pid,hostname:t(),environment:rr.env.NODE_ENV||"development",platform:rr.platform,version:rr.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:rr.env.NODE_ENV||rr.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class Ii{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={...Pi},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new Na,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??me.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let r={...t},n=t.timestamp!==void 0;if(n)delete r.timestamp;if(this.config={...this.config,...r,timestamp:n||this.config.timestamp,level:this.options.level??"info"},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let i=this.generateKeyId(),s=this.generateKey();this.currentKeyId=i,this.keys.set(i,s),this.encryptionKeys.set(i,{key:s,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;let t={debug:0,info:1,success:2,warning:3,error:4},r=this.fingersCrossedConfig.activationLevel??"error";return t[e]>=t[r]}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...Gn,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...Gn};return{...Gn,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:Pi.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},r={...t,...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))};if(!r.level||!["debug","info","success","warning","error"].includes(r.level))r.level=t.level;return r}shouldWriteToFile(){return!Fe()&&this.config.writeToFile===!0}async writeToFile(e){let t=(async()=>{let n,i=0,s=3,o=1000;while(i<s)try{try{try{await pu(this.config.logDirectory,Xo.F_OK|Xo.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await gu(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:pt.from(e);try{if(!si(this.currentLogFile))await In(this.currentLogFile,"",{mode:420});if(n=Zo(this.currentLogFile,"a",420),mu(n,a,{flag:"a"}),Yo(n),n!==void 0)Dn(n),n=void 0;if((await er(this.currentLogFile)).size===0){if(await In(this.currentLogFile,a,{flag:"w",mode:420}),(await er(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(i<s-1){let u=typeof f.message==="string"?f.message:"Unknown error";console.error(`Network error during write attempt ${i+1}/${s}:`,u);let l=o*2**i;await new Promise((g)=>setTimeout(g,l)),i++;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{Dn(n)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(a){if(i===s-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}i++;let c=o*2**(i-1);await new Promise((f)=>setTimeout(f,c))}})();this.pendingOperations.push(t);let r=this.pendingOperations.length-1;try{await t}catch(n){throw console.error("Debug: [writeToFile] Error in operation:",n),n}finally{this.pendingOperations.splice(r,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 tr(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 tr(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return tr(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,r=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((n)=>{console.error("Error rotating keys:",n)})},r)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let e=this.config.rotation.keyRotation,t=this.generateKeyId(),r=this.generateKey();this.currentKeyId=t,this.keys.set(t,r),this.encryptionKeys.set(t,{key:r,createdAt:new Date});let n=Array.from(this.encryptionKeys.entries()).sort(([,o],[,a])=>a.createdAt.getTime()-o.createdAt.getTime()),i=typeof e.maxKeys==="number"?e.maxKeys:1,s=Math.max(1,i);if(n.length>s)for(let[o]of n.slice(s))this.encryptionKeys.delete(o),this.keys.delete(o)}generateKeyId(){return Mn(16).toString("hex")}generateKey(){return Mn(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(),r=Mn(16),n=uu("aes-256-gcm",t,r),i=pt.isBuffer(e)?e:pt.from(e,"utf8"),s=n.update(i),o=n.final(),a=s.length+o.length,c=n.getAuthTag(),f=pt.allocUnsafe(16+a+16);return r.copy(f,0),s.copy(f,16),o.copy(f,16+s.length),c.copy(f,16+a),{encrypted:f,iv:r}}async compressData(e){return new Promise((t,r)=>{let n=ea(),i=[];n.on("data",(s)=>i.push(s)),n.on("end",()=>t(pt.from(pt.concat(i)))),n.on("error",r),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 er(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 r=this.currentLogFile,n=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let i=await oi(this.config.logDirectory),s=i.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}),o=s.length>0?Number.parseInt(s[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,a=`${r}.${o}`;if(await er(r).catch(()=>null))try{if(await Qo(r,a),t.compress)try{let c=`${a}.gz`;await this.compressLogFile(a,c),await ai(a)}catch(c){console.error("Error compressing rotated file:",c)}if(s.length===0&&!i.some((c)=>c.endsWith(".log.1")))try{let c=`${r}.1`;await In(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 i=new Date().toISOString().replace(/[:.]/g,"-"),s=r.replace(/\.log$/,`-${i}.log`);if(await er(r).catch(()=>null))await Qo(r,s)}if(this.currentLogFile=n,t.maxFiles){let i=(await oi(this.config.logDirectory)).filter((s)=>s.startsWith(this.name)).sort((s,o)=>o.localeCompare(s));for(let s of i.slice(t.maxFiles))await ai(tr(this.config.logDirectory,s))}}}async compressLogFile(e,t){let r=qo(e),n=du(t),i=ea();await wu(r,i,n)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let r of this.logBuffer){let n=await this.formatter.format(r);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()})),si(this.currentLogFile))try{let e=Zo(this.currentLogFile,"r+");Yo(e),Dn(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 oi(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of e)try{await ai(tr(this.config.logDirectory,t))}catch(r){console.error(`Failed to delete temp file ${t}:`,r)}}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()?ae.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||Fe())return!1;let e=typeof me.env.NO_COLOR<"u",t=me.env.FORCE_COLOR==="0";if(e||t)return!1;return!!(typeof me.stderr<"u"&&me.stderr.isTTY||typeof me.stdout<"u"&&me.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:t,icon:r="",tag:n="",message:i,level:s,showTimestamp:o=!0}=e,a=(p)=>p.replace(this.ANSI_PATTERN,"");if(!this.fancy){let p=[];if(o)p.push(t);if(s==="warning")p.push("WARN");else if(s==="error")p.push("ERROR");else if(r)p.push(r.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(n)p.push(n.replace(/[[\]]/g,""));return p.push(i),p.join(" ")}let c=me.stdout.columns||120,f="";if(s==="warning"||s==="error")f=`${r} ${i}`;else if(s==="info"||s==="success")f=`${r} ${n} ${i}`;else f=`${r} ${n} ${ae.cyan(i)}`;if(!o)return f.trim();let u=a(f).trim().length,l=a(t).length,g=Math.max(1,c-2-u-l);return`${f.trim()}${" ".repeat(g)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(s,o)=>{let a=Number.parseInt(o,10);return a<t[0].length?String(t[0][a]):s});let r=/%([sdijfo%])/g,n=0,i=e.replace(r,(s,o)=>{if(o==="%")return"%";if(n>=t.length)return s;let a=t[n++];switch(o){case"s":return String(a);case"d":case"i":return Number(a).toString();case"j":case"o":return JSON.stringify(a,null,2);default:return s}});if(n<t.length)i+=` ${t.slice(n).map((s)=>typeof s==="object"?JSON.stringify(s,null,2):String(s)).join(" ")}`;return i}formatMarkdown(e){if(!e)return e;let t=e;return t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,n,i)=>{let s=ae.underline(ae.blue(n)),o=this.toAbsoluteFilePath(i);if(o&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let a=`file://${encodeURI(o)}`,c="\x1B]8;;",f="\x1B\\";return`\x1B]8;;${a}\x1B\\${s}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${i}\x1B\\${s}\x1B]8;;\x1B\\`;return s}),t=t.replace(/`([^`]+)`/g,(r,n)=>ae.bgGray(n)),t=t.replace(/\*\*([^*]+)\*\*/g,(r,n)=>ae.bold(n)),t=t.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(r,n)=>ae.italic(n)),t=t.replace(/(?<!_)_([^_]+)_(?!_)/g,(r,n)=>ae.italic(n)),t=t.replace(/~([^~]+)~/g,(r,n)=>ae.strikethrough(n)),t}supportsHyperlinks(){if(Fe())return!1;let e=me.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 r=me.env.HOME||"";if(r)t=t.replace(/^~(?=$|\/)/,r)}if(yu(t)||t.startsWith("./")||t.startsWith("../"))t=Cu(t);else return null;return si(t)?t:null}catch{return null}}buildOutputTexts(e){let t=this.shouldStyleConsole()?this.formatMarkdown(e):e,r=e.replace(this.ANSI_PATTERN,"");return{consoleText:t,fileText:r}}async log(e,t,...r){if(!this.shouldLog(e))return;let n=new Date,i=this.formatConsoleTimestamp(n),s=this.formatFileTimestamp(n),o,a;if(t instanceof Error)o=t.message,a=t.stack;else o=this.formatMessage(t,r);let{consoleText:c,fileText:f}=this.buildOutputTexts(o);if(this.shouldStyleConsole()){let l=this.options.showIcons===!1?"":Dh[e],g=this.options.showTags!==!1&&this.name?ae.gray(this.formatTag(this.name)):"",p;switch(e){case"debug":p=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:ae.gray(c),level:e}),console.error(p);break;case"info":p=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.warn(p);break;case"success":p=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:ae.green(c),level:e}),console.error(p);break;case"warning":p=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.warn(p);break;case"error":if(p=this.formatConsoleMessage({timestamp:i,icon:l,tag:g,message:c,level:e}),console.error(p),a){let v=a.split(`
116
+ `);for(let b of v)if(b.trim()&&!b.includes(o))console.error(this.formatConsoleMessage({timestamp:i,message:ae.gray(` ${b}`),level:e,showTimestamp:!1}))}break}}else if(!Fe()){if(console.error(`${s} ${this.environment}.${e.toUpperCase()}: ${o}`),a)console.error(a)}let u=`${s} ${this.environment}.${e.toUpperCase()}: ${f}
116
117
  `;if(a)u+=`${a}
117
- `;if(u=u.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(u)}progress(e,t=""){let r={update:(i,s)=>{},finish:(i)=>{},interrupt:(i,s)=>{}};if(!this.enabled)return r;let n=30;if(this.activeProgressBar={total:Math.max(1,e||1),current:0,message:t||"",barLength:n,lastRenderedLine:""},this.shouldStyleConsole()&&!Ne()&&he.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(i,s)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,i),this.activeProgressBar.total),s!==void 0)this.activeProgressBar.message=s;if(this.shouldStyleConsole()&&!Ne()&&he.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(i)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,i)},interrupt:(i,s="info")=>{if(!Ne()&&he.stdout.isTTY)he.stdout.write(`
118
- `);if(this[s==="warning"?"warn":s](i),this.activeProgressBar&&this.shouldStyleConsole()&&!Ne()&&he.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time(e){let t=performance.now();if(this.shouldStyleConsole()){let r=this.options.showTags!==!1&&this.name?se.gray(this.formatTag(this.name)):"",n=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:n,icon:this.options.showIcons===!1?"":se.blue("\u25D0"),tag:r,message:`${se.cyan(e)}...`}))}return async(r)=>{if(!this.enabled)return;let n=performance.now(),i=Math.round(n-t),s=`${e} completed in ${i}ms`,o=new Date,a=this.formatConsoleTimestamp(o),c=`${this.formatFileTimestamp(o)} ${this.environment}.INFO: ${s}`;if(r)c+=` ${JSON.stringify(r)}`;if(c+=`
119
- `,c=c.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let f=this.options.showTags!==!1&&this.name?se.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:a,icon:this.options.showIcons===!1?"":se.green("\u2713"),tag:f,message:`${s}${r?` ${JSON.stringify(r)}`:""}`}))}else if(!Ne())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}`,r=new Mi(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(r),r}createReadStream(){if(Ne())throw Error("createReadStream is not supported in browser environments");if(!ii(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return zo(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 r=this.keys.get(this.currentKeyId);try{let n=mt.isBuffer(e)?e:mt.from(e,"base64"),i=n.subarray(0,16),s=n.subarray(n.length-16),o=n.subarray(16,n.length-16),a=fu("aes-256-gcm",r,i);a.setAuthTag(s);let c=a.update(o),f=a.final(),u=c.length+f.length,l=mt.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 Ne()}isServerMode(){return!Ne()}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,r=this.formatConsoleTimestamp(t),n=this.formatFileTimestamp(t),{consoleText:i,fileText:s}=this.buildOutputTexts(e);if(this.shouldStyleConsole()){let a=i.split(`
120
- `),c=Math.max(...a.map((g)=>g.length))+2,f=`\u250C${"\u2500".repeat(c)}\u2510`,u=`\u2514${"\u2500".repeat(c)}\u2518`,l=a.map((g)=>this.formatConsoleMessage({timestamp:r,message:se.cyan(g),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:r,message:se.cyan(f),showTimestamp:!1})),l.forEach((g)=>console.error(g)),console.error(this.formatConsoleMessage({timestamp:r,message:se.cyan(u),showTimestamp:!1}))}else if(!Ne())console.error(`${n} ${this.environment}.INFO: [BOX] ${s}`);let o=`${n} ${this.environment}.INFO: [BOX] ${s}
121
- `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(o)}async prompt(e){if(Ne())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${se.cyan("?")} ${e} (y/n) `);let r=(n)=>{let i=n.toString().trim().toLowerCase();he.stdin.removeListener("data",r);try{if(typeof he.stdin.setRawMode==="function")he.stdin.setRawMode(!1)}catch{}he.stdin.pause(),console.error(""),t(i==="y"||i==="yes")};try{if(typeof he.stdin.setRawMode==="function")he.stdin.setRawMode(!0)}catch{}he.stdin.resume(),he.stdin.once("data",r)})}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 r=e;if(t&&t.length>0){let o=/%([sdijfo%])/g,a=0;if(r=e.replace(o,(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)r+=` ${t.slice(a).map((c)=>typeof c==="object"?JSON.stringify(c,null,2):String(c)).join(" ")}`}let{consoleText:n,fileText:i}=this.buildOutputTexts(r);if(this.shouldStyleConsole()){let o=this.options.showTags!==!1&&this.name?se.gray(this.formatTag(this.name)):"",a=this.options.showIcons===!1?"":`${se.blue("\u25D0")} `;console.error(`${a}${o} ${se.cyan(n)}`)}let s=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${i}
122
- `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(s)}renderProgressBar(e,t=!1){if(!this.enabled||!this.shouldStyleConsole()||!he.stdout.isTTY)return;let r=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),n=Math.round(e.barLength*r/100),i=e.barLength-n,s=se.green("\u2501".repeat(n)),o=se.gray("\u2501".repeat(i)),a=`[${s}${o}]`,c=`${r}%`.padStart(4),f=e.message?` ${e.message}`:"",u=this.options.showIcons===!1?"":t||r===100?se.green("\u2713"):se.blue("\u25B6"),l=this.options.showTags!==!1&&this.name?` ${se.gray(this.formatTag(this.name))}`:"",g=`\r${u}${l} ${a} ${c}${f}`,d=he.stdout.columns||80,v=" ".repeat(Math.max(0,d-g.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${g}${v}`,he.stdout.write(e.lastRenderedLine),t)he.stdout.write(`
123
- `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||Ne()||!he.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(Ne()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let t=await ni(this.config.logDirectory),r=[];for(let n of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(n):n.startsWith(this.name))||!n.endsWith(".log"))continue;let i=er(this.config.logDirectory,n);if(e.before)try{if((await Qt(i)).mtime>=e.before)continue}catch(s){console.error(`Failed to get stats for file ${i}:`,s);continue}r.push(i)}if(r.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${r.length} log file(s)...`);for(let n of r)try{await si(n),console.warn(`Deleted log file: ${n}`)}catch(i){console.error(`Failed to delete log file ${n}:`,i)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}async function Mh(e,t={}){let{maxRetries:r=3,retryDelay:n=1000,isRetryable:i=()=>!0,fallback:s}=t,o=Error("Unknown error occurred");for(let a=0;a<=r;a++)try{return await e()}catch(c){if(o=c instanceof Error?c:Error(String(c)),a===r||!i(o))break;if(n>0)await new Promise((f)=>setTimeout(f,n))}if(s!==void 0)return s;throw o instanceof Error?o:Error(`Unknown error: ${String(o)}`)}class os{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,r={}){let{prefix:n,useCamelCase:i=!0,useBackwardCompatibility:s=!0,customParsers:o={},verbose:a=!1,trackPerformance:c=!0}=r,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:i,useBackwardCompatibility:s,customParsers:o,verbose:a,configName:e}),{config:l,source:{type:"environment",priority:50,timestamp:new Date}}};if(c)return Zn.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,r,n){for(let[i,s]of Object.entries(e)){let o=[...t,i],a=o.map((u)=>this.formatEnvKey(u,n.useCamelCase)),c=`${r}_${a.join("_")}`,f=n.useBackwardCompatibility?`${r}_${o.map((u)=>u.toUpperCase()).join("_")}`:null;if(n.verbose);if(typeof s==="object"&&s!==null&&!Array.isArray(s))this.processObject(s,o,r,n);else{let u=oi.env[c]||(f?oi.env[f]:void 0);if(u!==void 0){if(n.verbose){let l=oi.env[c]?c:f}try{e[i]=this.parseEnvironmentValue(u,typeof s,c,n.customParsers,n.configName)}catch(l){if(l instanceof ss)throw l;throw ir.envVar(c,u,typeof s,n.configName)}}}}}parseEnvironmentValue(e,t,r,n,i){for(let[s,o]of Object.entries(n))try{return o(e)}catch{continue}for(let s of this.defaultParsers)if(s.canParse(e,t))try{return s.parse(e)}catch{throw ir.envVar(r,e,`${t} (via ${s.name} parser)`,i)}return e}getEnvironmentVariables(e){let t={},r=e.toUpperCase();for(let[n,i]of Object.entries(oi.env))if(n.startsWith(r)&&i!==void 0)t[n]=i;return t}validateEnvironmentVariable(e,t,r){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(r)try{this.parseEnvironmentValue(e,t,r,{})}catch(i){n.push(`Cannot parse value "${t}" as ${r}: ${i}`)}return{isValid:n.length===0,errors:n}}generateEnvVarDocs(e,t,r={}){let{prefix:n,format:i="text"}=r,s=n||this.generateEnvPrefix(e),o=[];switch(this.extractEnvVarInfo(t,[],s,o),i){case"markdown":return this.formatAsMarkdown(o,e);case"json":return JSON.stringify(o,null,2);default:return this.formatAsText(o,e)}}extractEnvVarInfo(e,t,r,n){for(let[i,s]of Object.entries(e)){let o=[...t,i],a=`${r}_${o.map((c)=>this.formatEnvKey(c,!0)).join("_")}`;if(typeof s==="object"&&s!==null&&!Array.isArray(s))this.extractEnvVarInfo(s,o,r,n);else n.push({key:a,type:Array.isArray(s)?"array":typeof s,description:`Configuration for ${o.join(".")}`,example:this.generateExample(s)})}}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 r=`Environment Variables for ${t}:
118
+ `;if(u=u.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(u)}progress(e,t=""){let r={update:(i,s)=>{},finish:(i)=>{},interrupt:(i,s)=>{}};if(!this.enabled)return r;let n=30;if(this.activeProgressBar={total:Math.max(1,e||1),current:0,message:t||"",barLength:n,lastRenderedLine:""},this.shouldStyleConsole()&&!Fe()&&me.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(i,s)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,i),this.activeProgressBar.total),s!==void 0)this.activeProgressBar.message=s;if(this.shouldStyleConsole()&&!Fe()&&me.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(i)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,i)},interrupt:(i,s="info")=>{if(!Fe()&&me.stdout.isTTY)me.stdout.write(`
119
+ `);if(this[s==="warning"?"warn":s](i),this.activeProgressBar&&this.shouldStyleConsole()&&!Fe()&&me.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time(e){let t=performance.now();if(this.shouldStyleConsole()){let r=this.options.showTags!==!1&&this.name?ae.gray(this.formatTag(this.name)):"",n=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:n,icon:this.options.showIcons===!1?"":ae.blue("\u25D0"),tag:r,message:`${ae.cyan(e)}...`}))}return async(r)=>{if(!this.enabled)return;let n=performance.now(),i=Math.round(n-t),s=`${e} completed in ${i}ms`,o=new Date,a=this.formatConsoleTimestamp(o),c=`${this.formatFileTimestamp(o)} ${this.environment}.INFO: ${s}`;if(r)c+=` ${JSON.stringify(r)}`;if(c+=`
120
+ `,c=c.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let f=this.options.showTags!==!1&&this.name?ae.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:a,icon:this.options.showIcons===!1?"":ae.green("\u2713"),tag:f,message:`${s}${r?` ${JSON.stringify(r)}`:""}`}))}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}`,r=new Ii(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(r),r}createReadStream(){if(Fe())throw Error("createReadStream is not supported in browser environments");if(!si(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return qo(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 r=this.keys.get(this.currentKeyId);try{let n=pt.isBuffer(e)?e:pt.from(e,"base64"),i=n.subarray(0,16),s=n.subarray(n.length-16),o=n.subarray(16,n.length-16),a=hu("aes-256-gcm",r,i);a.setAuthTag(s);let c=a.update(o),f=a.final(),u=c.length+f.length,l=pt.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,r=this.formatConsoleTimestamp(t),n=this.formatFileTimestamp(t),{consoleText:i,fileText:s}=this.buildOutputTexts(e);if(this.shouldStyleConsole()){let a=i.split(`
121
+ `),c=Math.max(...a.map((g)=>g.length))+2,f=`\u250C${"\u2500".repeat(c)}\u2510`,u=`\u2514${"\u2500".repeat(c)}\u2518`,l=a.map((g)=>this.formatConsoleMessage({timestamp:r,message:ae.cyan(g),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:r,message:ae.cyan(f),showTimestamp:!1})),l.forEach((g)=>console.error(g)),console.error(this.formatConsoleMessage({timestamp:r,message:ae.cyan(u),showTimestamp:!1}))}else if(!Fe())console.error(`${n} ${this.environment}.INFO: [BOX] ${s}`);let o=`${n} ${this.environment}.INFO: [BOX] ${s}
122
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(o)}async prompt(e){if(Fe())return Promise.resolve(!0);return new Promise((t)=>{console.error(`${ae.cyan("?")} ${e} (y/n) `);let r=(n)=>{let i=n.toString().trim().toLowerCase();me.stdin.removeListener("data",r);try{if(typeof me.stdin.setRawMode==="function")me.stdin.setRawMode(!1)}catch{}me.stdin.pause(),console.error(""),t(i==="y"||i==="yes")};try{if(typeof me.stdin.setRawMode==="function")me.stdin.setRawMode(!0)}catch{}me.stdin.resume(),me.stdin.once("data",r)})}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 r=e;if(t&&t.length>0){let o=/%([sdijfo%])/g,a=0;if(r=e.replace(o,(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)r+=` ${t.slice(a).map((c)=>typeof c==="object"?JSON.stringify(c,null,2):String(c)).join(" ")}`}let{consoleText:n,fileText:i}=this.buildOutputTexts(r);if(this.shouldStyleConsole()){let o=this.options.showTags!==!1&&this.name?ae.gray(this.formatTag(this.name)):"",a=this.options.showIcons===!1?"":`${ae.blue("\u25D0")} `;console.error(`${a}${o} ${ae.cyan(n)}`)}let s=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${i}
123
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(s)}renderProgressBar(e,t=!1){if(!this.enabled||!this.shouldStyleConsole()||!me.stdout.isTTY)return;let r=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),n=Math.round(e.barLength*r/100),i=e.barLength-n,s=ae.green("\u2501".repeat(n)),o=ae.gray("\u2501".repeat(i)),a=`[${s}${o}]`,c=`${r}%`.padStart(4),f=e.message?` ${e.message}`:"",u=this.options.showIcons===!1?"":t||r===100?ae.green("\u2713"):ae.blue("\u25B6"),l=this.options.showTags!==!1&&this.name?` ${ae.gray(this.formatTag(this.name))}`:"",g=`\r${u}${l} ${a} ${c}${f}`,p=me.stdout.columns||80,v=" ".repeat(Math.max(0,p-g.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${g}${v}`,me.stdout.write(e.lastRenderedLine),t)me.stdout.write(`
124
+ `)}finishProgressBar(e,t){if(!this.enabled||!this.fancy||Fe()||!me.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 oi(this.config.logDirectory),r=[];for(let n of t){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(n):n.startsWith(this.name))||!n.endsWith(".log"))continue;let i=tr(this.config.logDirectory,n);if(e.before)try{if((await er(i)).mtime>=e.before)continue}catch(s){console.error(`Failed to get stats for file ${i}:`,s);continue}r.push(i)}if(r.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${r.length} log file(s)...`);for(let n of r)try{await ai(n),console.warn(`Deleted log file: ${n}`)}catch(i){console.error(`Failed to delete log file ${n}:`,i)}console.warn("Log clearing process finished.")}catch(t){console.error("Error during log clearing process:",t)}}}async function Ih(e,t={}){let{maxRetries:r=3,retryDelay:n=1000,isRetryable:i=()=>!0,fallback:s}=t,o=Error("Unknown error occurred");for(let a=0;a<=r;a++)try{return await e()}catch(c){if(o=c instanceof Error?c:Error(String(c)),a===r||!i(o))break;if(n>0)await new Promise((f)=>setTimeout(f,n))}if(s!==void 0)return s;throw o instanceof Error?o:Error(`Unknown error: ${String(o)}`)}class ls{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,r={}){let{prefix:n,useCamelCase:i=!0,useBackwardCompatibility:s=!0,customParsers:o={},verbose:a=!1,trackPerformance:c=!0}=r,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:i,useBackwardCompatibility:s,customParsers:o,verbose:a,configName:e}),{config:l,source:{type:"environment",priority:50,timestamp:new Date}}};if(c)return Qn.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,r,n){for(let[i,s]of Object.entries(e)){let o=[...t,i],a=o.map((u)=>this.formatEnvKey(u,n.useCamelCase)),c=`${r}_${a.join("_")}`,f=n.useBackwardCompatibility?`${r}_${o.map((u)=>u.toUpperCase()).join("_")}`:null;if(n.verbose);if(typeof s==="object"&&s!==null&&!Array.isArray(s))this.processObject(s,o,r,n);else{let u=li.env[c]||(f?li.env[f]:void 0);if(u!==void 0){if(n.verbose){let l=li.env[c]?c:f}try{e[i]=this.parseEnvironmentValue(u,typeof s,c,n.customParsers,n.configName)}catch(l){if(l instanceof as)throw l;throw nr.envVar(c,u,typeof s,n.configName)}}}}}parseEnvironmentValue(e,t,r,n,i){for(let[s,o]of Object.entries(n))try{return o(e)}catch{continue}for(let s of this.defaultParsers)if(s.canParse(e,t))try{return s.parse(e)}catch{throw nr.envVar(r,e,`${t} (via ${s.name} parser)`,i)}return e}getEnvironmentVariables(e){let t={},r=e.toUpperCase();for(let[n,i]of Object.entries(li.env))if(n.startsWith(r)&&i!==void 0)t[n]=i;return t}validateEnvironmentVariable(e,t,r){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(r)try{this.parseEnvironmentValue(e,t,r,{})}catch(i){n.push(`Cannot parse value "${t}" as ${r}: ${i}`)}return{isValid:n.length===0,errors:n}}generateEnvVarDocs(e,t,r={}){let{prefix:n,format:i="text"}=r,s=n||this.generateEnvPrefix(e),o=[];switch(this.extractEnvVarInfo(t,[],s,o),i){case"markdown":return this.formatAsMarkdown(o,e);case"json":return JSON.stringify(o,null,2);default:return this.formatAsText(o,e)}}extractEnvVarInfo(e,t,r,n){for(let[i,s]of Object.entries(e)){let o=[...t,i],a=`${r}_${o.map((c)=>this.formatEnvKey(c,!0)).join("_")}`;if(typeof s==="object"&&s!==null&&!Array.isArray(s))this.extractEnvVarInfo(s,o,r,n);else n.push({key:a,type:Array.isArray(s)?"array":typeof s,description:`Configuration for ${o.join(".")}`,example:this.generateExample(s)})}}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 r=`Environment Variables for ${t}:
124
125
 
125
126
  `;for(let n of e)r+=`${n.key}
126
127
  `,r+=` Type: ${n.type}
@@ -132,71 +133,71 @@ export type ConfigOf = Config
132
133
  `;r+=`| Variable | Type | Description | Example |
133
134
  `,r+=`|----------|------|-------------|----------|
134
135
  `;for(let n of e)r+=`| \`${n.key}\` | ${n.type} | ${n.description} | \`${n.example}\` |
135
- `;return r}}function Dh(e,t,r={}){return Va(e,t,r,new WeakMap)}function Va(e,t,r,n){let{arrayMergeMode:i="replace",skipNullish:s=!1,customMerger:o}=r;if(t===null||t===void 0)return s?e:t;if(o){let a=o(e,t);if(a!==void 0)return a}if(Array.isArray(t)||Array.isArray(e))return Ua(e,t,i,n);if(!it(t)||!it(e))return t;return Lh(e,t,r,n)}function Ua(e,t,r,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(r){case"replace":return t;case"concat":return Ih(e,t);case"smart":return Fh(e,t,n);default:return t}return t}function Ih(e,t){let r=[...t];for(let n of e)if(!r.some((i)=>Yn(i,n)))r.push(n);return r}function Fh(e,t,r){if(t.length===0)return e;if(e.length===0)return t;if(it(t[0])&&it(e[0]))return Nh(e,t,r);if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let i of e)if(!n.includes(i))n.push(i);return n}return t}function Nh(e,t,r){let n=[...t];for(let i of e){if(!it(i)){n.push(i);continue}let s=["id","name","key","path","type"],o=!1;for(let a of s)if(a in i){if(n.find((c)=>it(c)&&(a in c)&&c[a]===i[a])){o=!0;break}}if(!o)n.push(i)}return n}function Lh(e,t,r,n){let i=t;if(it(i)&&n.has(i))return n.get(i);let s={...e};if(it(i))n.set(i,s);for(let o in i){if(!Object.prototype.hasOwnProperty.call(i,o))continue;let a=i[o],c=s[o];if(r.skipNullish&&(a===null||a===void 0))continue;if(a===null||a===void 0){s[o]=a;continue}if(it(a)&&it(c))s[o]=Va(c,a,r,n);else if(Array.isArray(a)||Array.isArray(c))s[o]=Ua(c,a,r.arrayMergeMode||"smart",n);else s[o]=a}return s}function Ka(e,t,r="replace"){return Dh(e,t,{arrayMergeMode:r==="replace"?"replace":"smart",skipNullish:!0})}function Yn(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Yn(e[r],t[r]))return!1;return!0}if(it(e)&&it(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!Yn(e[i],t[i]))return!1}return!0}return!1}function it(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class Ha{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(e,t,r={}){let{arrayStrategy:n="replace",useCache:i=!0,cacheTtl:s,trackPerformance:o=!0,verbose:a=!1}=r;if(i){let f=wi.getWithFileCheck("file",e);if(f){if(a)console.log(`Configuration loaded from cache: ${e}`);return f}}let c=async()=>{if(!ai(e))return null;try{let f=`?t=${Date.now()}`,u=await import(e+f),l=u.default||u,g="default"in u,d=Object.keys(u).length>0;if(!g&&!d)throw new Ti(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof l!=="object"||l===null||Array.isArray(l))throw new Ti(e,Error("Configuration must export a valid object"),"unknown");let v={config:Ka(t,l,n),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(i)wi.setWithFileCheck("file",v,e,s);return v}catch(f){throw f instanceof Error?ir.configLoad(e,f):ir.configLoad(e,Error(String(f)))}};if(o)return Zn.track("loadFromPath",c,{path:e});return c()}async tryLoadFromPaths(e,t,r={}){for(let n of e)try{let i=await this.loadFromPath(n,t,r);if(i)return i}catch(i){if(i instanceof Error&&i.name==="ConfigLoadError")throw i;if(r.verbose)console.warn(`Failed to load config from ${n}:`,i)}return null}generateConfigPaths(e,t,r){let n=this.generateNamePatterns(e,r),i=[];for(let s of n)for(let o of this.extensions)i.push(Dn(t,`${s}${o}`));return i}generateNamePatterns(e,t){let r=[];if(r.push("config",".config"),e)r.push(e,`.${e}.config`,`${e}.config`,`.${e}`);let n=t===void 0?[]:Array.isArray(t)?t:[t];for(let s of n){if(!s)continue;if(r.push(s,`.${s}.config`,`${s}.config`,`.${s}`),e)r.push(`${e}.${s}.config`,`.${e}.${s}.config`)}let i=new Set;return r.filter((s)=>{if(!s||i.has(s))return!1;return i.add(s),!0})}checkFileAccess(e){return Mh(async()=>ai(e),{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,t,r){let n=[];if(!ai(e))return n;if(t||r){let i=this.generateNamePatterns(t||"",r);for(let s of i)for(let o of this.extensions){let a=Dn(e,`${s}${o}`);if(await this.checkFileAccess(a))n.push(a)}}else try{let{readdirSync:i}=await import("fs"),s=i(e);for(let o of s)if(this.looksLikeConfigFile(o)){let a=Dn(e,o);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(!ai(e))return t.push("Configuration file does not exist"),t;let r=await import(e),n=r.default||r;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:i}=await import("fs"),s=i(e,"utf8");JSON.parse(s)}catch(i){t.push(`Invalid JSON syntax: ${i}`)}}catch(r){t.push(`Failed to load configuration file: ${r}`)}return t}async getFileModificationTime(e){try{let{statSync:t}=await import("fs");return t(e).mtime}catch{return null}}async preloadConfigurations(e,t={}){let r=new Map;return await Promise.allSettled(e.map(async(n)=>{try{let i=await this.loadFromPath(n,{},t);if(i)r.set(n,i.config)}catch(i){if(t.verbose)console.warn(`Failed to preload ${n}:`,i)}})),r}}class za{async validateConfiguration(e,t,r={}){let{stopOnFirstError:n=!1,validateRequired:i=!0,validateTypes:s=!0,customRules:o=[],trackPerformance:a=!0,verbose:c=!1}=r,f=async()=>{let u=[],l=[],g={stopOnFirstError:n,validateRequired:i,validateTypes:s,customRules:o,trackPerformance:a,verbose:c};try{if(typeof t==="string")return await this.validateWithSchemaFile(e,t,g);else if(Array.isArray(t))return this.validateWithRules(e,[...t,...o],g);else return this.validateWithJSONSchema(e,t,g)}catch(d){return u.push({path:"",message:`Validation failed: ${d}`,rule:"system"}),{isValid:!1,errors:u,warnings:l}}};if(a)return await Zn.track("validateConfiguration",f);return f()}async validateWithSchemaFile(e,t,r){try{if(!Cu(t))throw new Pi(t,[{path:"",message:"Schema file does not exist"}]);let n=await import(t),i=n.default||n;if(Array.isArray(i))return this.validateWithRules(e,i,r);else return this.validateWithJSONSchema(e,i,r)}catch(n){throw new Pi(t,[{path:"",message:`Failed to load schema: ${n}`}])}}validateWithJSONSchema(e,t,r){let n=[],i=[];return this.validateObjectAgainstSchema(e,t,"",n,i,r),{isValid:n.length===0,errors:n,warnings:i}}validateObjectAgainstSchema(e,t,r,n,i,s){if(s.validateTypes&&t.type){let o=Array.isArray(e)?"array":typeof e,a=Array.isArray(t.type)?t.type:[t.type];if(!a.includes(o)){if(n.push({path:r,message:`Expected type ${a.join(" or ")}, got ${o}`,expected:a.join(" or "),actual:o,rule:"type"}),s.stopOnFirstError)return}}if(t.enum&&!t.enum.includes(e)){if(n.push({path:r,message:`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"}),s.stopOnFirstError)return}if(typeof e==="string"){if(t.minLength!==void 0&&e.length<t.minLength)n.push({path:r,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:r,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:r,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:r,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:r,message:`Value must not exceed ${t.maximum}`,expected:`<= ${t.maximum}`,actual:e,rule:"maximum"})}if(Array.isArray(e)&&t.items)for(let o=0;o<e.length;o++){let a=r?`${r}[${o}]`:`[${o}]`;if(this.validateObjectAgainstSchema(e[o],t.items,a,n,i,s),s.stopOnFirstError&&n.length>0)return}if(e&&typeof e==="object"&&!Array.isArray(e)){let o=e;if(s.validateRequired&&t.required){for(let a of t.required)if(!(a in o)){if(n.push({path:r?`${r}.${a}`:a,message:`Missing required property '${a}'`,expected:"required",rule:"required"}),s.stopOnFirstError)return}}if(t.properties){for(let[a,c]of Object.entries(t.properties))if(a in o){let f=r?`${r}.${a}`:a;if(this.validateObjectAgainstSchema(o[a],c,f,n,i,s),s.stopOnFirstError&&n.length>0)return}}if(t.additionalProperties===!1){let a=new Set(Object.keys(t.properties||{}));for(let c of Object.keys(o))if(!a.has(c))i.push({path:r?`${r}.${c}`:c,message:`Additional property '${c}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(e,t,r){let n=[],i=[];for(let s of t)try{let o=this.getValueByPath(e,s.path),a=this.validateWithRule(o,s,s.path);if(n.push(...a),r.stopOnFirstError&&n.length>0)break}catch(o){n.push({path:s.path,message:`Rule validation failed: ${o}`,rule:"system"})}return{isValid:n.length===0,errors:n,warnings:i}}validateWithRule(e,t,r){let n=[];if(t.required&&(e===void 0||e===null))return n.push({path:r,message:t.message||`Property '${r}' is required`,expected:"required",rule:"required"}),n;if(e===void 0||e===null)return n;if(t.type){let i=Array.isArray(e)?"array":typeof e;if(i!==t.type)n.push({path:r,message:t.message||`Expected type ${t.type}, got ${i}`,expected:t.type,actual:i,rule:"type"})}if(t.min!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i<t.min)n.push({path:r,message:t.message||`Value must be at least ${t.min}`,expected:`>= ${t.min}`,actual:i,rule:"min"})}if(t.max!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i>t.max)n.push({path:r,message:t.message||`Value must not exceed ${t.max}`,expected:`<= ${t.max}`,actual:i,rule:"max"})}if(t.pattern&&typeof e==="string"){if(!t.pattern.test(e))n.push({path:r,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:r,message:t.message||`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"});if(t.validator){let i=t.validator(e);if(i)n.push({path:r,message:t.message||i,rule:"custom"})}return n}getValueByPath(e,t){if(!t)return e;let r=t.split("."),n=e;for(let i of r)if(n&&typeof n==="object"&&i in n)n=n[i];else return;return n}generateRulesFromInterface(e){let t=[],r=e.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let n of r){let[,i,s,o]=n;t.push({path:i,required:!s,type:this.mapTypeScriptType(o)})}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:Wh},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}function Bh(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((r)=>`"${r}"`).join(", ")}`}class Ja{fileLoader=new Ha;envProcessor=new os;validator=new za;async loadConfig(e){let t=Date.now(),{cache:r,performance:n,schema:i,validate:s,...o}=e;try{if(r?.enabled){let c=this.checkCache(o.name||"",o);if(c)return c}let a;try{a=await this.loadConfigurationStrategies(o,!0,r)}catch(c){let f=o.__strictErrorHandling;if(c instanceof Error&&c.name==="ConfigNotFoundError"){if(f)throw c;a={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:[`No configuration file found for "${o.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")),g=c.message.includes("Configuration must export a valid object")||c.message.includes("Configuration file is empty and exports nothing");if(f&&(g||u))throw c;if(l&&(!f||!g))a={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!f)a={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:[`Configuration loading error, using defaults: ${c.message}`]};else throw c}else a={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${c instanceof Error?c.message:String(c)}`]}}if(i||s)await this.validateConfiguration(a.config,i,s,o.name);if(r?.enabled&&a)this.cacheResult(o.name||"",a,r,o);if(n?.enabled){let c={operation:"loadConfig",duration:Date.now()-t,configName:o.name,timestamp:new Date};if(n.onMetrics)n.onMetrics(c);if(n.slowThreshold&&c.duration>n.slowThreshold)pt.warn(`Slow configuration loading detected: ${c.duration}ms for ${o.name}`);a.metrics=c}return a}catch(a){if(a instanceof Error&&a.name==="ConfigNotFoundError")throw a;let c=Date.now()-t;throw pt.error(`Configuration loading failed after ${c}ms:`,[a instanceof Error?a:Error(String(a))]),a}}async loadConfigurationStrategies(e,t=!1,r){let{name:n="",alias:i,cwd:s,configDir:o,defaultConfig:a,checkEnv:c=!0,arrayStrategy:f="replace",verbose:u=!1}=e,l=s||Ri.cwd(),g=[],d=await this.loadLocalConfiguration(n,i,l,o,a,f,u,c,r);if(d)return g.push(...this.getLocalSearchPaths(n,i,l,o)),this.finalizeResult(d,g,c,n,u);let v=await this.loadHomeConfiguration(n,i,a,f,u,c);if(v)return g.push(...this.getHomeSearchPaths(n,i)),this.finalizeResult(v,g,c,n,u);let b=await this.loadPackageJsonConfiguration(n,i,l,a,f,u,c);if(b)return g.push(tt(l,"package.json")),this.finalizeResult(b,g,c,n,u);if(g.push(...this.getAllSearchPaths(n,i,l,o)),t)throw ir.configNotFound(n,g,i);return{...await this.applyEnvironmentVariables(n,a,c,u),warnings:[`No configuration file found for "${n}"${Bh(i)}, using defaults with environment variables`]}}async loadLocalConfiguration(e,t,r,n,i,s,o,a,c){let f=a?ci(e,i,o):i,u=this.getLocalDirectories(r,n);for(let l of u){if(o)pt.info(`Searching for configuration in: ${l}`);let g=this.fileLoader.generateConfigPaths(e,l,t),d=await this.fileLoader.tryLoadFromPaths(g,f,{arrayStrategy:s,verbose:o,cacheTtl:c?.ttl,useCache:!c?.ttl||c.ttl>100});if(d){if(o)pt.success(`Configuration loaded from: ${d.source.path}`);return d}}return null}async loadHomeConfiguration(e,t,r,n,i,s){if(!e)return null;let o=s?ci(e,r,i):r,a=[tt(Kt(),".config",e),tt(Kt(),".config"),Kt()];for(let c of a){if(i)pt.info(`Checking home directory: ${c}`);let f=this.fileLoader.generateConfigPaths(e,c,t),u=await this.fileLoader.tryLoadFromPaths(f,o,{arrayStrategy:n,verbose:i});if(u){if(i)pt.success(`Configuration loaded from home directory: ${u.source.path}`);return u}}return null}async loadPackageJsonConfiguration(e,t,r,n,i,s,o){let a=o?ci(e,n,s):n;try{let c=tt(r,"package.json");if(!Mf(c))return null;let f={};try{f=JSON.parse(Df(c,"utf8"))}catch(g){if(s)pt.warn("Failed to parse package.json:",[g instanceof Error?g:Error(String(g))]);return null}let u=f[e],l=e;if(!u&&t){let g=Array.isArray(t)?t:[t];for(let d of g){if(!d)continue;if(f[d]){u=f[d],l=d;break}}}if(u&&typeof u==="object"&&!Array.isArray(u)){if(s)pt.success(`Configuration loaded from package.json: ${l}`);return{config:Ka(a,u,i),source:{type:"package.json",path:c,priority:30,timestamp:new Date}}}}catch(c){if(s)pt.warn("Failed to load package.json:",[c instanceof Error?c:Error(String(c))])}return null}async applyEnvironmentVariables(e,t,r,n){if(!r||!e||typeof t!=="object"||t===null||Array.isArray(t))return{config:t,source:{type:"default",priority:10,timestamp:new Date}};return{config:ci(e,t,n),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(e,t,r,n,i){return{config:e.config,source:e.source,path:e.source.path}}async validateConfiguration(e,t,r,n){let i=[];if(r){let s=r(e);if(s)i.push(...s)}if(t){let s=await this.validator.validateConfiguration(e,t);if(!s.isValid)i.push(...s.errors.map((o)=>o.path?`${o.path}: ${o.message}`:o.message))}if(i.length>0)throw ir.configValidation(n||"unknown",i,n)}checkCache(e,t){let r=this.generateCacheKey(e,t);return wi.get(r)||null}cacheResult(e,t,r,n){let i=this.generateCacheKey(e,n);wi.set(i,t,void 0,r.ttl)}generateCacheKey(e,t){let r=[e];if(t.alias){let n=Array.isArray(t.alias)?t.alias.join(","):t.alias;r.push(`alias:${n}`)}if(t.cwd)r.push(`cwd:${t.cwd}`);if(t.configDir)r.push(`configDir:${t.configDir}`);if("checkEnv"in t)r.push(`checkEnv:${t.checkEnv}`);return r.join("|")}getLocalDirectories(e,t){return Array.from(new Set([e,tt(e,"config"),tt(e,".config"),t?tt(e,t):void 0].filter(Boolean)))}getAllSearchPaths(e,t,r,n){let i=[];return i.push(...this.getLocalSearchPaths(e,t,r,n)),i.push(...this.getHomeSearchPaths(e,t)),i.push(tt(r,"package.json")),i}getLocalSearchPaths(e,t,r,n){let i=this.getLocalDirectories(r,n),s=[];for(let o of i)s.push(...this.fileLoader.generateConfigPaths(e,o,t));return s}getHomeSearchPaths(e,t){if(!e)return[];let r=[tt(Kt(),".config",e),tt(Kt(),".config"),Kt()],n=[];for(let i of r)n.push(...this.fileLoader.generateConfigPaths(e,i,t));return n}async loadConfigWithResult(e){return this.loadConfig(e)}}function ci(e,t,r=!1){let n=new os,i=e.toUpperCase().replace(/[^A-Z0-9]/g,"_");function s(o,a=[]){let c={...o};for(let[f,u]of Object.entries(o)){let l=[...a,f],g=[`${i}_${l.join("_").toUpperCase()}`,`${i}_${l.map((b)=>b.toUpperCase()).join("")}`,`${i}_${l.map((b)=>b.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],d,v;for(let b of g)if(d=Ri.env[b],d!==void 0){v=b;break}if(d!==void 0&&v)if(typeof u==="boolean")c[f]=["true","1","yes"].includes(d.toLowerCase());else if(typeof u==="number"){let b=Number(d);if(!Number.isNaN(b))c[f]=b}else if(Array.isArray(u))try{c[f]=JSON.parse(d)}catch{c[f]=d.split(",").map((b)=>b.trim())}else c[f]=d;else if(u&&typeof u==="object"&&!Array.isArray(u))c[f]=s(u,l)}return c}return s(t)}var wi,Zn,wu,vu=(e)=>e,bu=(e,t)=>{for(var r in t)wu(e,r,{get:t[r],enumerable:!0,configurable:!0,set:Eu.bind(t,r)})},Su=(e,t)=>()=>(e&&(t=e(e=0)),t),ga,$a,rr,vr,xa,Yu,Zu,ea,ui,_n,Ge,Ce,Xu,ta,Qu,ra,eh,th,In,rh,ia,na,Fn,ih,nh,sh,oh,hi,Ta,ah,je,lh,ch,sa,di,Vn,Fe,te,fh,oa,uh,aa,hh,dh,Nn,mh,la,ca,ph,Ln,gh,yh,Ch,wh,vh,mi,Pa,Eh,bh="0.15.6",Ye,Ai,Cr,Un,Kn,$i,Hn,zn,wr,Jn,qn,$t,Ra,Oa,st,wt,ka,Ma,Sh,$h,Da,xi,Ng,Fa,se,Lg,Th,Wg,Ph,Bg,Gg,fa,jg,Rh,Oh,_g,ua,Vg,Ug,Kg,Hg,zg,Wn,kh,Jg,ot,Na,Ti,La,Wa,ss,Ba,Ga,Pi,ja,_a,ir,Wh,pt,qg,Yg,Zg,Gh,qa;var Ya=ce(()=>{wi=new ma,Zn=new pa,wu=Object.defineProperty;ga={};bu(ga,{withErrorRecovery:()=>wa,tryLoadConfig:()=>Hu,loadConfigWithResult:()=>Uu,loadConfig:()=>Aa,isRetryableError:()=>Wu,isConfigNotFoundError:()=>Lu,isBunfigError:()=>va,globalPerformanceMonitor:()=>vr,globalCache:()=>rr,getEnvOrDefault:()=>Bu,generateConfigTypes:()=>zu,defaultGeneratedDir:()=>Ma,defaultConfigDir:()=>ka,deepMergeWithArrayStrategy:()=>rs,deepMerge:()=>Ea,createLibraryConfig:()=>Ju,config:()=>Ku,bunfigPlugin:()=>qu,applyEnvVarsToConfig:()=>gr,TypeGenerationError:()=>zn,SchemaValidationError:()=>wr,PluginError:()=>qn,PerformanceMonitor:()=>Qn,FileSystemError:()=>Hn,ErrorFactory:()=>$t,EnvVarError:()=>$i,EnvProcessor:()=>Oi,ConfigValidator:()=>is,ConfigValidationError:()=>Un,ConfigNotFoundError:()=>Ai,ConfigMergeError:()=>Kn,ConfigLoader:()=>ns,ConfigLoadError:()=>Cr,ConfigFileLoader:()=>ki,ConfigCache:()=>Xn,CacheUtils:()=>xa,BunfigError:()=>Ye,BrowserConfigError:()=>Jn,ArrayMergeStrategies:()=>Ra});Sh=Su(async()=>{$a=import.meta.require,rr=new Xn,vr=new Qn,xa={createKey:Au,isEquivalent:$u,estimateMemoryUsage:xu},Yu=yi(Gn.cwd(),"config"),Zu=yi(Gn.cwd(),"src/generated"),ea=gi.env.CLARITY_LOG_DIR||Bf(Ru(),"logs"),ui={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},_n=await Ou(),Ge={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"},Ce=Ge,Xu=Ge.red,ta=Ge.green,Qu=Ge.yellow,ra=Ge.blue,eh=Ge.magenta,th=Ge.cyan,In=Ge.white,rh=Ge.gray,ia=Ge.bgRed,na=Ge.bgYellow,Fn=Ge.bold,ih=Ge.dim,nh=Ge.italic,sh=Ge.underline,oh=Ge.reset,hi={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},Ta={debug:"\uD83D\uDD0D",info:ra("\u2139"),success:ta("\u2713"),warning:na(In(Fn(" WARN "))),error:ia(In(Fn(" ERROR ")))},ah=new Ei("stacks"),je=new Ei("bunfig",{showTags:!0}),lh=Ue(yr.cwd(),"config"),ch=Ue(yr.cwd(),"src/generated"),sa=pi.env.CLARITY_LOG_DIR||Lf(Iu(),"logs"),di={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:sa,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},Vn=await Fu(),Fe={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"},te=Fe,fh=Fe.red,oa=Fe.green,uh=Fe.yellow,aa=Fe.blue,hh=Fe.magenta,dh=Fe.cyan,Nn=Fe.white,mh=Fe.gray,la=Fe.bgRed,ca=Fe.bgYellow,ph=Fe.bgGray,Ln=Fe.bold,gh=Fe.dim,yh=Fe.italic,Ch=Fe.underline,wh=Fe.strikethrough,vh=Fe.reset,mi={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},Pa={debug:"\uD83D\uDD0D",info:aa("\u2139"),success:oa("\u2713"),warning:ca(Nn(Ln(" WARN "))),error:la(Nn(Ln(" ERROR ")))},Eh=new Si("stacks"),Ye=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,r])=>`${t}: ${r}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${e}`}},Ai=class extends Ye{code="CONFIG_NOT_FOUND";constructor(e,t,r){let n=r?` or alias "${r}"`:"";super(`Configuration "${e}"${n} not found`,{configName:e,alias:r,searchPaths:t,searchPathCount:t.length})}},Cr=class extends Ye{code="CONFIG_LOAD_ERROR";constructor(e,t,r){super(`Failed to load configuration from "${e}": ${t.message}`,{configPath:e,configName:r,originalError:t.name,originalMessage:t.message});this.cause=t}},Un=class extends Ye{code="CONFIG_VALIDATION_ERROR";constructor(e,t,r){super(`Configuration validation failed for "${e}"`,{configPath:e,configName:r,validationErrors:t,errorCount:t.length})}},Kn=class extends Ye{code="CONFIG_MERGE_ERROR";constructor(e,t,r,n){super(`Failed to merge configuration from "${e}" with "${t}": ${r.message}`,{sourcePath:e,targetPath:t,configName:n,originalError:r.name,originalMessage:r.message});this.cause=r}},$i=class extends Ye{code="ENV_VAR_ERROR";constructor(e,t,r,n){super(`Failed to parse environment variable "${e}" with value "${t}" as ${r}`,{envKey:e,envValue:t,expectedType:r,configName:n})}},Hn=class extends Ye{code="FILE_SYSTEM_ERROR";constructor(e,t,r){super(`File system ${e} failed for "${t}": ${r.message}`,{operation:e,path:t,originalError:r.name,originalMessage:r.message});this.cause=r}},zn=class extends Ye{code="TYPE_GENERATION_ERROR";constructor(e,t,r){super(`Failed to generate types from "${e}" to "${t}": ${r.message}`,{configDir:e,outputPath:t,originalError:r.name,originalMessage:r.message});this.cause=r}},wr=class extends Ye{code="SCHEMA_VALIDATION_ERROR";constructor(e,t,r){super(`Schema validation failed${r?` for config "${r}"`:""}`,{schemaPath:e,configName:r,validationErrors:t,errorCount:t.length})}},Jn=class extends Ye{code="BROWSER_CONFIG_ERROR";constructor(e,t,r,n){super(`Failed to fetch configuration from "${e}": ${t} ${r}`,{endpoint:e,status:t,statusText:r,configName:n})}},qn=class extends Ye{code="PLUGIN_ERROR";constructor(e,t,r){super(`Plugin "${e}" failed during ${t}: ${r.message}`,{pluginName:e,operation:t,originalError:r.name,originalMessage:r.message});this.cause=r}},$t={configNotFound(e,t,r){return new Ai(e,t,r)},configLoad(e,t,r){return new Cr(e,t,r)},configValidation(e,t,r){return new Un(e,t,r)},configMerge(e,t,r,n){return new Kn(e,t,r,n)},envVar(e,t,r,n){return new $i(e,t,r,n)},fileSystem(e,t,r){return new Hn(e,t,r)},typeGeneration(e,t,r){return new zn(e,t,r)},schemaValidation(e,t,r){return new wr(e,t,r)},browserConfig(e,t,r,n){return new Jn(e,t,r,n)},plugin(e,t,r){return new qn(e,t,r)}},Ra={replace:"replace",concat:"concat",smart:"smart"},Oa=/^https?:\/\//,st=new Si("bunfig",{showTags:!0}),wt=new ns,ka=Ke(kt.cwd(),"config"),Ma=Ke(kt.cwd(),"src/generated")});$h=Ci.env.CLARITY_LOG_DIR||au(Ah(),"logs"),Da={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:$h,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},xi={...Da},Ng=(async()=>{try{let{loadConfig:e}=await Sh().then(()=>ga),t=await e({name:"clarity",alias:"logging",defaultConfig:Da,cwd:Ci.cwd()});if(t)Object.assign(xi,t)}catch{}return xi})();Fa={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"},se=Fa,{red:Lg,green:Th,yellow:Wg,blue:Ph,magenta:Bg,cyan:Gg,white:fa,gray:jg,bgRed:Rh,bgYellow:Oh,bgGray:_g,bold:ua,dim:Vg,italic:Ug,underline:Kg,strikethrough:Hg,reset:zg}=Fa,Wn={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},kh={debug:"\uD83D\uDD0D",info:Ph("\u2139"),success:Th("\u2713"),warning:Oh(fa(ua(" WARN "))),error:Rh(fa(ua(" ERROR ")))};Jg=new Mi("stacks");ot=class ot 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,r])=>`${t}: ${r}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${e}`}};Na=class Na extends ot{code="CONFIG_NOT_FOUND";constructor(e,t,r){let n=r===void 0?[]:Array.isArray(r)?r.filter(Boolean):[r],i="";if(n.length===1)i=` or alias "${n[0]}"`;else if(n.length>1)i=` or aliases ${n.map((s)=>`"${s}"`).join(", ")}`;super(`Configuration "${e}"${i} not found`,{configName:e,alias:r,searchPaths:t,searchPathCount:t.length})}};Ti=class Ti extends ot{code="CONFIG_LOAD_ERROR";constructor(e,t,r){super(`Failed to load configuration from "${e}": ${t.message}`,{configPath:e,configName:r,originalError:t.name,originalMessage:t.message});this.cause=t}};La=class La extends ot{code="CONFIG_VALIDATION_ERROR";constructor(e,t,r){super(`Configuration validation failed for "${e}"`,{configPath:e,configName:r,validationErrors:t,errorCount:t.length})}};Wa=class Wa extends ot{code="CONFIG_MERGE_ERROR";constructor(e,t,r,n){super(`Failed to merge configuration from "${e}" with "${t}": ${r.message}`,{sourcePath:e,targetPath:t,configName:n,originalError:r.name,originalMessage:r.message});this.cause=r}};ss=class ss extends ot{code="ENV_VAR_ERROR";constructor(e,t,r,n){super(`Failed to parse environment variable "${e}" with value "${t}" as ${r}`,{envKey:e,envValue:t,expectedType:r,configName:n})}};Ba=class Ba extends ot{code="FILE_SYSTEM_ERROR";constructor(e,t,r){super(`File system ${e} failed for "${t}": ${r.message}`,{operation:e,path:t,originalError:r.name,originalMessage:r.message});this.cause=r}};Ga=class Ga extends ot{code="TYPE_GENERATION_ERROR";constructor(e,t,r){super(`Failed to generate types from "${e}" to "${t}": ${r.message}`,{configDir:e,outputPath:t,originalError:r.name,originalMessage:r.message});this.cause=r}};Pi=class Pi extends ot{code="SCHEMA_VALIDATION_ERROR";constructor(e,t,r){super(`Schema validation failed${r?` for config "${r}"`:""}`,{schemaPath:e,configName:r,validationErrors:t,errorCount:t.length})}};ja=class ja extends ot{code="BROWSER_CONFIG_ERROR";constructor(e,t,r,n){super(`Failed to fetch configuration from "${e}": ${t} ${r}`,{endpoint:e,status:t,statusText:r,configName:n})}};_a=class _a extends ot{code="PLUGIN_ERROR";constructor(e,t,r){super(`Plugin "${e}" failed during ${t}: ${r.message}`,{pluginName:e,operation:t,originalError:r.name,originalMessage:r.message});this.cause=r}};ir={configNotFound(e,t,r){return new Na(e,t,r)},configLoad(e,t,r){return new Ti(e,t,r)},configValidation(e,t,r){return new La(e,t,r)},configMerge(e,t,r,n){return new Wa(e,t,r,n)},envVar(e,t,r,n){return new ss(e,t,r,n)},fileSystem(e,t,r){return new Ba(e,t,r)},typeGeneration(e,t,r){return new Ga(e,t,r)},schemaValidation(e,t,r){return new Pi(e,t,r)},browserConfig(e,t,r,n){return new ja(e,t,r,n)},plugin(e,t,r){return new _a(e,t,r)}};Wh=/^https?:\/\//;pt=new Mi("bunfig",{showTags:!0});qg=new Ja;Yg=tt(Ri.cwd(),"config"),Zg=tt(Ri.cwd(),"src/generated"),Gh={cwd:kf.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},qa=Gh});function Za(e,t,r){let n={file:t,message:"Unknown error",code:Er.UNKNOWN_ERROR};if(e instanceof Error){n.message=e.message,n.stack=e.stack;let i=e.message.match(/\((\d+),(\d+)\)/);if(i)n.location={line:Number.parseInt(i[1],10),column:Number.parseInt(i[2],10)};if(e.message.includes("Cannot find")||e.message.includes("not found"))n.code=Er.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=Er.SYNTAX_ERROR,n.suggestion="Check for syntax errors in your TypeScript code.";else if(e.message.includes("type")&&e.message.includes("cannot"))n.code=Er.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=Er.PARSE_ERROR,n.suggestion="The file contains invalid TypeScript syntax."}else if(typeof e==="string")n.message=e;return n}function Xa(e,t){let r=[],n=e.file;if(e.location)n+=`:${e.location.line}:${e.location.column}`;if(e.code)n+=` [${e.code}]`;if(r.push(n),r.push(` Error: ${e.message}`),t&&e.location){r.push("");let i=t.split(`
136
+ `;return r}}function Fh(e,t,r={}){return Ka(e,t,r,new WeakMap)}function Ka(e,t,r,n){let{arrayMergeMode:i="replace",skipNullish:s=!1,customMerger:o}=r;if(t===null||t===void 0)return s?e:t;if(o){let a=o(e,t);if(a!==void 0)return a}if(Array.isArray(t)||Array.isArray(e))return za(e,t,i,n);if(!nt(t)||!nt(e))return t;return Bh(e,t,r,n)}function za(e,t,r,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(r){case"replace":return t;case"concat":return Nh(e,t);case"smart":return Lh(e,t,n);default:return t}return t}function Nh(e,t){let r=[...t];for(let n of e)if(!r.some((i)=>Xn(i,n)))r.push(n);return r}function Lh(e,t,r){if(t.length===0)return e;if(e.length===0)return t;if(nt(t[0])&&nt(e[0]))return Wh(e,t,r);if(t.every((n)=>typeof n==="string")&&e.every((n)=>typeof n==="string")){let n=[...t];for(let i of e)if(!n.includes(i))n.push(i);return n}return t}function Wh(e,t,r){let n=[...t];for(let i of e){if(!nt(i)){n.push(i);continue}let s=["id","name","key","path","type"],o=!1;for(let a of s)if(a in i){if(n.find((c)=>nt(c)&&(a in c)&&c[a]===i[a])){o=!0;break}}if(!o)n.push(i)}return n}function Bh(e,t,r,n){let i=t;if(nt(i)&&n.has(i))return n.get(i);let s={...e};if(nt(i))n.set(i,s);for(let o in i){if(!Object.prototype.hasOwnProperty.call(i,o))continue;let a=i[o],c=s[o];if(r.skipNullish&&(a===null||a===void 0))continue;if(a===null||a===void 0){s[o]=a;continue}if(nt(a)&&nt(c))s[o]=Ka(c,a,r,n);else if(Array.isArray(a)||Array.isArray(c))s[o]=za(c,a,r.arrayMergeMode||"smart",n);else s[o]=a}return s}function Ha(e,t,r="replace"){return Fh(e,t,{arrayMergeMode:r==="replace"?"replace":"smart",skipNullish:!0})}function Xn(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Xn(e[r],t[r]))return!1;return!0}if(nt(e)&&nt(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!Xn(e[i],t[i]))return!1}return!0}return!1}function nt(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class Ja{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(e,t,r={}){let{arrayStrategy:n="replace",useCache:i=!0,cacheTtl:s,trackPerformance:o=!0,verbose:a=!1}=r;if(i){let f=Ei.getWithFileCheck("file",e);if(f){if(a)console.log(`Configuration loaded from cache: ${e}`);return f}}let c=async()=>{if(!ci(e))return null;try{let f=`?t=${Date.now()}`,u=await import(e+f),l=u.default||u,g="default"in u,p=Object.keys(u).length>0;if(!g&&!p)throw new Ri(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof l!=="object"||l===null||Array.isArray(l))throw new Ri(e,Error("Configuration must export a valid object"),"unknown");let v={config:Ha(t,l,n),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(i)Ei.setWithFileCheck("file",v,e,s);return v}catch(f){throw f instanceof Error?nr.configLoad(e,f):nr.configLoad(e,Error(String(f)))}};if(o)return Qn.track("loadFromPath",c,{path:e});return c()}async tryLoadFromPaths(e,t,r={}){for(let n of e)try{let i=await this.loadFromPath(n,t,r);if(i)return i}catch(i){if(i instanceof Error&&i.name==="ConfigLoadError")throw i;if(r.verbose)console.warn(`Failed to load config from ${n}:`,i)}return null}generateConfigPaths(e,t,r){let n=this.generateNamePatterns(e,r),i=[];for(let s of n)for(let o of this.extensions)i.push(Fn(t,`${s}${o}`));return i}generateNamePatterns(e,t){let r=[];if(r.push("config",".config"),e)r.push(e,`.${e}.config`,`${e}.config`,`.${e}`);let n=t===void 0?[]:Array.isArray(t)?t:[t];for(let s of n){if(!s)continue;if(r.push(s,`.${s}.config`,`${s}.config`,`.${s}`),e)r.push(`${e}.${s}.config`,`.${e}.${s}.config`)}let i=new Set;return r.filter((s)=>{if(!s||i.has(s))return!1;return i.add(s),!0})}checkFileAccess(e){return Ih(async()=>ci(e),{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,t,r){let n=[];if(!ci(e))return n;if(t||r){let i=this.generateNamePatterns(t||"",r);for(let s of i)for(let o of this.extensions){let a=Fn(e,`${s}${o}`);if(await this.checkFileAccess(a))n.push(a)}}else try{let{readdirSync:i}=await import("fs"),s=i(e);for(let o of s)if(this.looksLikeConfigFile(o)){let a=Fn(e,o);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(!ci(e))return t.push("Configuration file does not exist"),t;let r=await import(e),n=r.default||r;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:i}=await import("fs"),s=i(e,"utf8");JSON.parse(s)}catch(i){t.push(`Invalid JSON syntax: ${i}`)}}catch(r){t.push(`Failed to load configuration file: ${r}`)}return t}async getFileModificationTime(e){try{let{statSync:t}=await import("fs");return t(e).mtime}catch{return null}}async preloadConfigurations(e,t={}){let r=new Map;return await Promise.allSettled(e.map(async(n)=>{try{let i=await this.loadFromPath(n,{},t);if(i)r.set(n,i.config)}catch(i){if(t.verbose)console.warn(`Failed to preload ${n}:`,i)}})),r}}class qa{async validateConfiguration(e,t,r={}){let{stopOnFirstError:n=!1,validateRequired:i=!0,validateTypes:s=!0,customRules:o=[],trackPerformance:a=!0,verbose:c=!1}=r,f=async()=>{let u=[],l=[],g={stopOnFirstError:n,validateRequired:i,validateTypes:s,customRules:o,trackPerformance:a,verbose:c};try{if(typeof t==="string")return await this.validateWithSchemaFile(e,t,g);else if(Array.isArray(t))return this.validateWithRules(e,[...t,...o],g);else return this.validateWithJSONSchema(e,t,g)}catch(p){return u.push({path:"",message:`Validation failed: ${p}`,rule:"system"}),{isValid:!1,errors:u,warnings:l}}};if(a)return await Qn.track("validateConfiguration",f);return f()}async validateWithSchemaFile(e,t,r){try{if(!vu(t))throw new Oi(t,[{path:"",message:"Schema file does not exist"}]);let n=await import(t),i=n.default||n;if(Array.isArray(i))return this.validateWithRules(e,i,r);else return this.validateWithJSONSchema(e,i,r)}catch(n){throw new Oi(t,[{path:"",message:`Failed to load schema: ${n}`}])}}validateWithJSONSchema(e,t,r){let n=[],i=[];return this.validateObjectAgainstSchema(e,t,"",n,i,r),{isValid:n.length===0,errors:n,warnings:i}}validateObjectAgainstSchema(e,t,r,n,i,s){if(s.validateTypes&&t.type){let o=Array.isArray(e)?"array":typeof e,a=Array.isArray(t.type)?t.type:[t.type];if(!a.includes(o)){if(n.push({path:r,message:`Expected type ${a.join(" or ")}, got ${o}`,expected:a.join(" or "),actual:o,rule:"type"}),s.stopOnFirstError)return}}if(t.enum&&!t.enum.includes(e)){if(n.push({path:r,message:`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"}),s.stopOnFirstError)return}if(typeof e==="string"){if(t.minLength!==void 0&&e.length<t.minLength)n.push({path:r,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:r,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:r,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:r,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:r,message:`Value must not exceed ${t.maximum}`,expected:`<= ${t.maximum}`,actual:e,rule:"maximum"})}if(Array.isArray(e)&&t.items)for(let o=0;o<e.length;o++){let a=r?`${r}[${o}]`:`[${o}]`;if(this.validateObjectAgainstSchema(e[o],t.items,a,n,i,s),s.stopOnFirstError&&n.length>0)return}if(e&&typeof e==="object"&&!Array.isArray(e)){let o=e;if(s.validateRequired&&t.required){for(let a of t.required)if(!(a in o)){if(n.push({path:r?`${r}.${a}`:a,message:`Missing required property '${a}'`,expected:"required",rule:"required"}),s.stopOnFirstError)return}}if(t.properties){for(let[a,c]of Object.entries(t.properties))if(a in o){let f=r?`${r}.${a}`:a;if(this.validateObjectAgainstSchema(o[a],c,f,n,i,s),s.stopOnFirstError&&n.length>0)return}}if(t.additionalProperties===!1){let a=new Set(Object.keys(t.properties||{}));for(let c of Object.keys(o))if(!a.has(c))i.push({path:r?`${r}.${c}`:c,message:`Additional property '${c}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(e,t,r){let n=[],i=[];for(let s of t)try{let o=this.getValueByPath(e,s.path),a=this.validateWithRule(o,s,s.path);if(n.push(...a),r.stopOnFirstError&&n.length>0)break}catch(o){n.push({path:s.path,message:`Rule validation failed: ${o}`,rule:"system"})}return{isValid:n.length===0,errors:n,warnings:i}}validateWithRule(e,t,r){let n=[];if(t.required&&(e===void 0||e===null))return n.push({path:r,message:t.message||`Property '${r}' is required`,expected:"required",rule:"required"}),n;if(e===void 0||e===null)return n;if(t.type){let i=Array.isArray(e)?"array":typeof e;if(i!==t.type)n.push({path:r,message:t.message||`Expected type ${t.type}, got ${i}`,expected:t.type,actual:i,rule:"type"})}if(t.min!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i<t.min)n.push({path:r,message:t.message||`Value must be at least ${t.min}`,expected:`>= ${t.min}`,actual:i,rule:"min"})}if(t.max!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i>t.max)n.push({path:r,message:t.message||`Value must not exceed ${t.max}`,expected:`<= ${t.max}`,actual:i,rule:"max"})}if(t.pattern&&typeof e==="string"){if(!t.pattern.test(e))n.push({path:r,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:r,message:t.message||`Value must be one of: ${t.enum.join(", ")}`,expected:t.enum.join(", "),actual:e,rule:"enum"});if(t.validator){let i=t.validator(e);if(i)n.push({path:r,message:t.message||i,rule:"custom"})}return n}getValueByPath(e,t){if(!t)return e;let r=t.split("."),n=e;for(let i of r)if(n&&typeof n==="object"&&i in n)n=n[i];else return;return n}generateRulesFromInterface(e){let t=[],r=e.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let n of r){let[,i,s,o]=n;t.push({path:i,required:!s,type:this.mapTypeScriptType(o)})}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:Gh},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}function jh(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((r)=>`"${r}"`).join(", ")}`}class Ya{fileLoader=new Ja;envProcessor=new ls;validator=new qa;async loadConfig(e){let t=Date.now(),{cache:r,performance:n,schema:i,validate:s,...o}=e;try{if(r?.enabled){let c=this.checkCache(o.name||"",o);if(c)return c}let a;try{a=await this.loadConfigurationStrategies(o,!0,r)}catch(c){let f=o.__strictErrorHandling;if(c instanceof Error&&c.name==="ConfigNotFoundError"){if(f)throw c;a={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:[`No configuration file found for "${o.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")),g=c.message.includes("Configuration must export a valid object")||c.message.includes("Configuration file is empty and exports nothing");if(f&&(g||u))throw c;if(l&&(!f||!g))a={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!f)a={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:[`Configuration loading error, using defaults: ${c.message}`]};else throw c}else a={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${c instanceof Error?c.message:String(c)}`]}}if(i||s)await this.validateConfiguration(a.config,i,s,o.name);if(r?.enabled&&a)this.cacheResult(o.name||"",a,r,o);if(n?.enabled){let c={operation:"loadConfig",duration:Date.now()-t,configName:o.name,timestamp:new Date};if(n.onMetrics)n.onMetrics(c);if(n.slowThreshold&&c.duration>n.slowThreshold)gt.warn(`Slow configuration loading detected: ${c.duration}ms for ${o.name}`);a.metrics=c}return a}catch(a){if(a instanceof Error&&a.name==="ConfigNotFoundError")throw a;let c=Date.now()-t;throw gt.error(`Configuration loading failed after ${c}ms:`,[a instanceof Error?a:Error(String(a))]),a}}async loadConfigurationStrategies(e,t=!1,r){let{name:n="",alias:i,cwd:s,configDir:o,defaultConfig:a,checkEnv:c=!0,arrayStrategy:f="replace",verbose:u=!1}=e,l=s||ki.cwd(),g=[],p=await this.loadLocalConfiguration(n,i,l,o,a,f,u,c,r);if(p)return g.push(...this.getLocalSearchPaths(n,i,l,o)),this.finalizeResult(p,g,c,n,u);let v=await this.loadHomeConfiguration(n,i,a,f,u,c);if(v)return g.push(...this.getHomeSearchPaths(n,i)),this.finalizeResult(v,g,c,n,u);let b=await this.loadPackageJsonConfiguration(n,i,l,a,f,u,c);if(b)return g.push(rt(l,"package.json")),this.finalizeResult(b,g,c,n,u);if(g.push(...this.getAllSearchPaths(n,i,l,o)),t)throw nr.configNotFound(n,g,i);return{...await this.applyEnvironmentVariables(n,a,c,u),warnings:[`No configuration file found for "${n}"${jh(i)}, using defaults with environment variables`]}}async loadLocalConfiguration(e,t,r,n,i,s,o,a,c){let f=a?ui(e,i,o):i,u=this.getLocalDirectories(r,n);for(let l of u){if(o)gt.info(`Searching for configuration in: ${l}`);let g=this.fileLoader.generateConfigPaths(e,l,t),p=await this.fileLoader.tryLoadFromPaths(g,f,{arrayStrategy:s,verbose:o,cacheTtl:c?.ttl,useCache:!c?.ttl||c.ttl>100});if(p){if(o)gt.success(`Configuration loaded from: ${p.source.path}`);return p}}return null}async loadHomeConfiguration(e,t,r,n,i,s){if(!e)return null;let o=s?ui(e,r,i):r,a=[rt(zt(),".config",e),rt(zt(),".config"),zt()];for(let c of a){if(i)gt.info(`Checking home directory: ${c}`);let f=this.fileLoader.generateConfigPaths(e,c,t),u=await this.fileLoader.tryLoadFromPaths(f,o,{arrayStrategy:n,verbose:i});if(u){if(i)gt.success(`Configuration loaded from home directory: ${u.source.path}`);return u}}return null}async loadPackageJsonConfiguration(e,t,r,n,i,s,o){let a=o?ui(e,n,s):n;try{let c=rt(r,"package.json");if(!If(c))return null;let f={};try{f=JSON.parse(Ff(c,"utf8"))}catch(g){if(s)gt.warn("Failed to parse package.json:",[g instanceof Error?g:Error(String(g))]);return null}let u=f[e],l=e;if(!u&&t){let g=Array.isArray(t)?t:[t];for(let p of g){if(!p)continue;if(f[p]){u=f[p],l=p;break}}}if(u&&typeof u==="object"&&!Array.isArray(u)){if(s)gt.success(`Configuration loaded from package.json: ${l}`);return{config:Ha(a,u,i),source:{type:"package.json",path:c,priority:30,timestamp:new Date}}}}catch(c){if(s)gt.warn("Failed to load package.json:",[c instanceof Error?c:Error(String(c))])}return null}async applyEnvironmentVariables(e,t,r,n){if(!r||!e||typeof t!=="object"||t===null||Array.isArray(t))return{config:t,source:{type:"default",priority:10,timestamp:new Date}};return{config:ui(e,t,n),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(e,t,r,n,i){return{config:e.config,source:e.source,path:e.source.path}}async validateConfiguration(e,t,r,n){let i=[];if(r){let s=r(e);if(s)i.push(...s)}if(t){let s=await this.validator.validateConfiguration(e,t);if(!s.isValid)i.push(...s.errors.map((o)=>o.path?`${o.path}: ${o.message}`:o.message))}if(i.length>0)throw nr.configValidation(n||"unknown",i,n)}checkCache(e,t){let r=this.generateCacheKey(e,t);return Ei.get(r)||null}cacheResult(e,t,r,n){let i=this.generateCacheKey(e,n);Ei.set(i,t,void 0,r.ttl)}generateCacheKey(e,t){let r=[e];if(t.alias){let n=Array.isArray(t.alias)?t.alias.join(","):t.alias;r.push(`alias:${n}`)}if(t.cwd)r.push(`cwd:${t.cwd}`);if(t.configDir)r.push(`configDir:${t.configDir}`);if("checkEnv"in t)r.push(`checkEnv:${t.checkEnv}`);return r.join("|")}getLocalDirectories(e,t){return Array.from(new Set([e,rt(e,"config"),rt(e,".config"),t?rt(e,t):void 0].filter(Boolean)))}getAllSearchPaths(e,t,r,n){let i=[];return i.push(...this.getLocalSearchPaths(e,t,r,n)),i.push(...this.getHomeSearchPaths(e,t)),i.push(rt(r,"package.json")),i}getLocalSearchPaths(e,t,r,n){let i=this.getLocalDirectories(r,n),s=[];for(let o of i)s.push(...this.fileLoader.generateConfigPaths(e,o,t));return s}getHomeSearchPaths(e,t){if(!e)return[];let r=[rt(zt(),".config",e),rt(zt(),".config"),zt()],n=[];for(let i of r)n.push(...this.fileLoader.generateConfigPaths(e,i,t));return n}async loadConfigWithResult(e){return this.loadConfig(e)}}function ui(e,t,r=!1){let n=new ls,i=e.toUpperCase().replace(/[^A-Z0-9]/g,"_");function s(o,a=[]){let c={...o};for(let[f,u]of Object.entries(o)){let l=[...a,f],g=[`${i}_${l.join("_").toUpperCase()}`,`${i}_${l.map((b)=>b.toUpperCase()).join("")}`,`${i}_${l.map((b)=>b.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],p,v;for(let b of g)if(p=ki.env[b],p!==void 0){v=b;break}if(p!==void 0&&v)if(typeof u==="boolean")c[f]=["true","1","yes"].includes(p.toLowerCase());else if(typeof u==="number"){let b=Number(p);if(!Number.isNaN(b))c[f]=b}else if(Array.isArray(u))try{c[f]=JSON.parse(p)}catch{c[f]=p.split(",").map((b)=>b.trim())}else c[f]=p;else if(u&&typeof u==="object"&&!Array.isArray(u))c[f]=s(u,l)}return c}return s(t)}var Ei,Qn,Eu,bu=(e)=>e,$u=(e,t)=>{for(var r in t)Eu(e,r,{get:t[r],enumerable:!0,configurable:!0,set:Su.bind(t,r)})},Au=(e,t)=>()=>(e&&(t=e(e=0)),t),Ca,Ta,ir,Er,Pa,Xu,Qu,ra,di,Un,Be,ve,eh,ia,th,na,rh,ih,Nn,nh,sa,oa,Ln,sh,oh,ah,lh,mi,Ra,ch,Ge,fh,uh,aa,pi,Kn,Ie,re,hh,la,dh,ca,mh,ph,Wn,gh,fa,ua,yh,Bn,Ch,wh,vh,Eh,bh,gi,Oa,Sh,$h="0.15.6",Ze,xi,wr,zn,Hn,Ti,Jn,qn,vr,Yn,Zn,xt,ka,Ma,ot,vt,Da,Ia,Ah,Th,Fa,Pi,Wg,La,ae,Bg,Rh,Gg,Oh,jg,_g,ha,Vg,kh,Mh,Ug,da,Kg,zg,Hg,Jg,qg,Gn,Dh,Yg,at,Wa,Ri,Ba,Ga,as,ja,_a,Oi,Va,Ua,nr,Gh,gt,Zg,Xg,Qg,_h,Za;var Xa=fe(()=>{Ei=new ga,Qn=new ya,Eu=Object.defineProperty;Ca={};$u(Ca,{withErrorRecovery:()=>Ea,tryLoadConfig:()=>Ju,loadConfigWithResult:()=>zu,loadConfig:()=>xa,isRetryableError:()=>Gu,isConfigNotFoundError:()=>Bu,isBunfigError:()=>ba,globalPerformanceMonitor:()=>Er,globalCache:()=>ir,getEnvOrDefault:()=>ju,generateConfigTypes:()=>qu,defaultGeneratedDir:()=>Ia,defaultConfigDir:()=>Da,deepMergeWithArrayStrategy:()=>ns,deepMerge:()=>Sa,createLibraryConfig:()=>Yu,config:()=>Hu,bunfigPlugin:()=>Zu,applyEnvVarsToConfig:()=>yr,TypeGenerationError:()=>qn,SchemaValidationError:()=>vr,PluginError:()=>Zn,PerformanceMonitor:()=>ts,FileSystemError:()=>Jn,ErrorFactory:()=>xt,EnvVarError:()=>Ti,EnvProcessor:()=>Mi,ConfigValidator:()=>ss,ConfigValidationError:()=>zn,ConfigNotFoundError:()=>xi,ConfigMergeError:()=>Hn,ConfigLoader:()=>os,ConfigLoadError:()=>wr,ConfigFileLoader:()=>Di,ConfigCache:()=>es,CacheUtils:()=>Pa,BunfigError:()=>Ze,BrowserConfigError:()=>Yn,ArrayMergeStrategies:()=>ka});Ah=Au(async()=>{Ta=import.meta.require,ir=new es,Er=new ts,Pa={createKey:xu,isEquivalent:Tu,estimateMemoryUsage:Pu},Xu=wi(_n.cwd(),"config"),Qu=wi(_n.cwd(),"src/generated"),ra=Ci.env.CLARITY_LOG_DIR||jf(ku(),"logs"),di={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:ra,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1},Un=await Mu(),Be={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"},ve=Be,eh=Be.red,ia=Be.green,th=Be.yellow,na=Be.blue,rh=Be.magenta,ih=Be.cyan,Nn=Be.white,nh=Be.gray,sa=Be.bgRed,oa=Be.bgYellow,Ln=Be.bold,sh=Be.dim,oh=Be.italic,ah=Be.underline,lh=Be.reset,mi={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},Ra={debug:"\uD83D\uDD0D",info:na("\u2139"),success:ia("\u2713"),warning:oa(Nn(Ln(" WARN "))),error:sa(Nn(Ln(" ERROR ")))},ch=new Si("stacks"),Ge=new Si("bunfig",{showTags:!0}),fh=ze(Cr.cwd(),"config"),uh=ze(Cr.cwd(),"src/generated"),aa=yi.env.CLARITY_LOG_DIR||Bf(Nu(),"logs"),pi={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:aa,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},Kn=await Lu(),Ie={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"},re=Ie,hh=Ie.red,la=Ie.green,dh=Ie.yellow,ca=Ie.blue,mh=Ie.magenta,ph=Ie.cyan,Wn=Ie.white,gh=Ie.gray,fa=Ie.bgRed,ua=Ie.bgYellow,yh=Ie.bgGray,Bn=Ie.bold,Ch=Ie.dim,wh=Ie.italic,vh=Ie.underline,Eh=Ie.strikethrough,bh=Ie.reset,gi={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},Oa={debug:"\uD83D\uDD0D",info:ca("\u2139"),success:la("\u2713"),warning:ua(Wn(Bn(" WARN "))),error:fa(Wn(Bn(" ERROR ")))},Sh=new Ai("stacks"),Ze=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,r])=>`${t}: ${r}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${e}`}},xi=class extends Ze{code="CONFIG_NOT_FOUND";constructor(e,t,r){let n=r?` or alias "${r}"`:"";super(`Configuration "${e}"${n} not found`,{configName:e,alias:r,searchPaths:t,searchPathCount:t.length})}},wr=class extends Ze{code="CONFIG_LOAD_ERROR";constructor(e,t,r){super(`Failed to load configuration from "${e}": ${t.message}`,{configPath:e,configName:r,originalError:t.name,originalMessage:t.message});this.cause=t}},zn=class extends Ze{code="CONFIG_VALIDATION_ERROR";constructor(e,t,r){super(`Configuration validation failed for "${e}"`,{configPath:e,configName:r,validationErrors:t,errorCount:t.length})}},Hn=class extends Ze{code="CONFIG_MERGE_ERROR";constructor(e,t,r,n){super(`Failed to merge configuration from "${e}" with "${t}": ${r.message}`,{sourcePath:e,targetPath:t,configName:n,originalError:r.name,originalMessage:r.message});this.cause=r}},Ti=class extends Ze{code="ENV_VAR_ERROR";constructor(e,t,r,n){super(`Failed to parse environment variable "${e}" with value "${t}" as ${r}`,{envKey:e,envValue:t,expectedType:r,configName:n})}},Jn=class extends Ze{code="FILE_SYSTEM_ERROR";constructor(e,t,r){super(`File system ${e} failed for "${t}": ${r.message}`,{operation:e,path:t,originalError:r.name,originalMessage:r.message});this.cause=r}},qn=class extends Ze{code="TYPE_GENERATION_ERROR";constructor(e,t,r){super(`Failed to generate types from "${e}" to "${t}": ${r.message}`,{configDir:e,outputPath:t,originalError:r.name,originalMessage:r.message});this.cause=r}},vr=class extends Ze{code="SCHEMA_VALIDATION_ERROR";constructor(e,t,r){super(`Schema validation failed${r?` for config "${r}"`:""}`,{schemaPath:e,configName:r,validationErrors:t,errorCount:t.length})}},Yn=class extends Ze{code="BROWSER_CONFIG_ERROR";constructor(e,t,r,n){super(`Failed to fetch configuration from "${e}": ${t} ${r}`,{endpoint:e,status:t,statusText:r,configName:n})}},Zn=class extends Ze{code="PLUGIN_ERROR";constructor(e,t,r){super(`Plugin "${e}" failed during ${t}: ${r.message}`,{pluginName:e,operation:t,originalError:r.name,originalMessage:r.message});this.cause=r}},xt={configNotFound(e,t,r){return new xi(e,t,r)},configLoad(e,t,r){return new wr(e,t,r)},configValidation(e,t,r){return new zn(e,t,r)},configMerge(e,t,r,n){return new Hn(e,t,r,n)},envVar(e,t,r,n){return new Ti(e,t,r,n)},fileSystem(e,t,r){return new Jn(e,t,r)},typeGeneration(e,t,r){return new qn(e,t,r)},schemaValidation(e,t,r){return new vr(e,t,r)},browserConfig(e,t,r,n){return new Yn(e,t,r,n)},plugin(e,t,r){return new Zn(e,t,r)}},ka={replace:"replace",concat:"concat",smart:"smart"},Ma=/^https?:\/\//,ot=new Ai("bunfig",{showTags:!0}),vt=new os,Da=He(Mt.cwd(),"config"),Ia=He(Mt.cwd(),"src/generated")});Th=vi.env.CLARITY_LOG_DIR||cu(xh(),"logs"),Fa={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:Th,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},Pi={...Fa},Wg=(async()=>{try{let{loadConfig:e}=await Ah().then(()=>Ca),t=await e({name:"clarity",alias:"logging",defaultConfig:Fa,cwd:vi.cwd()});if(t)Object.assign(Pi,t)}catch{}return Pi})();La={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"},ae=La,{red:Bg,green:Rh,yellow:Gg,blue:Oh,magenta:jg,cyan:_g,white:ha,gray:Vg,bgRed:kh,bgYellow:Mh,bgGray:Ug,bold:da,dim:Kg,italic:zg,underline:Hg,strikethrough:Jg,reset:qg}=La,Gn={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},Dh={debug:"\uD83D\uDD0D",info:Oh("\u2139"),success:Rh("\u2713"),warning:Mh(ha(da(" WARN "))),error:kh(ha(da(" ERROR ")))};Yg=new Ii("stacks");at=class at 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,r])=>`${t}: ${r}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${e}`}};Wa=class Wa extends at{code="CONFIG_NOT_FOUND";constructor(e,t,r){let n=r===void 0?[]:Array.isArray(r)?r.filter(Boolean):[r],i="";if(n.length===1)i=` or alias "${n[0]}"`;else if(n.length>1)i=` or aliases ${n.map((s)=>`"${s}"`).join(", ")}`;super(`Configuration "${e}"${i} not found`,{configName:e,alias:r,searchPaths:t,searchPathCount:t.length})}};Ri=class Ri extends at{code="CONFIG_LOAD_ERROR";constructor(e,t,r){super(`Failed to load configuration from "${e}": ${t.message}`,{configPath:e,configName:r,originalError:t.name,originalMessage:t.message});this.cause=t}};Ba=class Ba extends at{code="CONFIG_VALIDATION_ERROR";constructor(e,t,r){super(`Configuration validation failed for "${e}"`,{configPath:e,configName:r,validationErrors:t,errorCount:t.length})}};Ga=class Ga extends at{code="CONFIG_MERGE_ERROR";constructor(e,t,r,n){super(`Failed to merge configuration from "${e}" with "${t}": ${r.message}`,{sourcePath:e,targetPath:t,configName:n,originalError:r.name,originalMessage:r.message});this.cause=r}};as=class as extends at{code="ENV_VAR_ERROR";constructor(e,t,r,n){super(`Failed to parse environment variable "${e}" with value "${t}" as ${r}`,{envKey:e,envValue:t,expectedType:r,configName:n})}};ja=class ja extends at{code="FILE_SYSTEM_ERROR";constructor(e,t,r){super(`File system ${e} failed for "${t}": ${r.message}`,{operation:e,path:t,originalError:r.name,originalMessage:r.message});this.cause=r}};_a=class _a extends at{code="TYPE_GENERATION_ERROR";constructor(e,t,r){super(`Failed to generate types from "${e}" to "${t}": ${r.message}`,{configDir:e,outputPath:t,originalError:r.name,originalMessage:r.message});this.cause=r}};Oi=class Oi extends at{code="SCHEMA_VALIDATION_ERROR";constructor(e,t,r){super(`Schema validation failed${r?` for config "${r}"`:""}`,{schemaPath:e,configName:r,validationErrors:t,errorCount:t.length})}};Va=class Va extends at{code="BROWSER_CONFIG_ERROR";constructor(e,t,r,n){super(`Failed to fetch configuration from "${e}": ${t} ${r}`,{endpoint:e,status:t,statusText:r,configName:n})}};Ua=class Ua extends at{code="PLUGIN_ERROR";constructor(e,t,r){super(`Plugin "${e}" failed during ${t}: ${r.message}`,{pluginName:e,operation:t,originalError:r.name,originalMessage:r.message});this.cause=r}};nr={configNotFound(e,t,r){return new Wa(e,t,r)},configLoad(e,t,r){return new Ri(e,t,r)},configValidation(e,t,r){return new Ba(e,t,r)},configMerge(e,t,r,n){return new Ga(e,t,r,n)},envVar(e,t,r,n){return new as(e,t,r,n)},fileSystem(e,t,r){return new ja(e,t,r)},typeGeneration(e,t,r){return new _a(e,t,r)},schemaValidation(e,t,r){return new Oi(e,t,r)},browserConfig(e,t,r,n){return new Va(e,t,r,n)},plugin(e,t,r){return new Ua(e,t,r)}};Gh=/^https?:\/\//;gt=new Ii("bunfig",{showTags:!0});Zg=new Ya;Xg=rt(ki.cwd(),"config"),Qg=rt(ki.cwd(),"src/generated"),_h={cwd:Df.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},Za=_h});function Qa(e,t,r){let n={file:t,message:"Unknown error",code:br.UNKNOWN_ERROR};if(e instanceof Error){n.message=e.message,n.stack=e.stack;let i=e.message.match(/\((\d+),(\d+)\)/);if(i)n.location={line:Number.parseInt(i[1],10),column:Number.parseInt(i[2],10)};if(e.message.includes("Cannot find")||e.message.includes("not found"))n.code=br.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=br.SYNTAX_ERROR,n.suggestion="Check for syntax errors in your TypeScript code.";else if(e.message.includes("type")&&e.message.includes("cannot"))n.code=br.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=br.PARSE_ERROR,n.suggestion="The file contains invalid TypeScript syntax."}else if(typeof e==="string")n.message=e;return n}function el(e,t){let r=[],n=e.file;if(e.location)n+=`:${e.location.line}:${e.location.column}`;if(e.code)n+=` [${e.code}]`;if(r.push(n),r.push(` Error: ${e.message}`),t&&e.location){r.push("");let i=t.split(`
136
137
  `),s=e.location.line-1;if(s>=0&&s<i.length){let o=Math.max(0,s-1),a=Math.min(i.length-1,s+1);for(let c=o;c<=a;c++){let f=(c+1).toString().padStart(4," "),u=c===s?">":" ";if(r.push(` ${u} ${f} | ${i[c]}`),c===s&&e.location.column>0){let l=" ".repeat(10+e.location.column-1);r.push(` ${l}^`)}}}}if(e.suggestion)r.push(""),r.push(` Suggestion: ${e.suggestion}`);return r.join(`
137
- `)}var Er;var Qa=ce(()=>{Er={PARSE_ERROR:"PARSE_ERROR",SYNTAX_ERROR:"SYNTAX_ERROR",FILE_NOT_FOUND:"FILE_NOT_FOUND",FILE_READ_ERROR:"FILE_READ_ERROR",FILE_WRITE_ERROR:"FILE_WRITE_ERROR",TYPE_INFERENCE_ERROR:"TYPE_INFERENCE_ERROR",UNRESOLVED_TYPE:"UNRESOLVED_TYPE",EXTRACTION_ERROR:"EXTRACTION_ERROR",PROCESSING_ERROR:"PROCESSING_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",INVALID_DECLARATION:"INVALID_DECLARATION",CONFIG_ERROR:"CONFIG_ERROR",INVALID_ENTRYPOINT:"INVALID_ENTRYPOINT",CIRCULAR_DEPENDENCY:"CIRCULAR_DEPENDENCY",TIMEOUT_ERROR:"TIMEOUT_ERROR",NOT_SUPPORTED:"NOT_SUPPORTED",UNKNOWN_ERROR:"UNKNOWN_ERROR"}});async function jh(){if(Di!==null)return Di;try{return xt=await import("prettier"),Di=!0,!0}catch{return Di=!1,!1}}async function _h(e,t){if(!xt)return null;try{if(t&&xt.resolveConfig){let r=await xt.resolveConfig(t);if(r)return r}if(e&&xt.resolveConfig){let r=await xt.resolveConfig(e);if(r)return r}return null}catch{return null}}async function Vh(e,t){if(!xt)throw Error("Prettier is not available");let r={...t,parser:t.parser||"typescript"};return xt.format(e,r)}function Uh(e,t={}){let{indentSize:r=2,useTabs:n=!1,maxLineWidth:i=100,trailingNewline:s=!0,normalizeWhitespace:o=!0,sortImports:a=!0,groupImports:c=!0}=t,f=e,u=n?"\t":" ".repeat(r);if(f.indexOf(`\r
138
+ `)}var br;var tl=fe(()=>{br={PARSE_ERROR:"PARSE_ERROR",SYNTAX_ERROR:"SYNTAX_ERROR",FILE_NOT_FOUND:"FILE_NOT_FOUND",FILE_READ_ERROR:"FILE_READ_ERROR",FILE_WRITE_ERROR:"FILE_WRITE_ERROR",TYPE_INFERENCE_ERROR:"TYPE_INFERENCE_ERROR",UNRESOLVED_TYPE:"UNRESOLVED_TYPE",EXTRACTION_ERROR:"EXTRACTION_ERROR",PROCESSING_ERROR:"PROCESSING_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",INVALID_DECLARATION:"INVALID_DECLARATION",CONFIG_ERROR:"CONFIG_ERROR",INVALID_ENTRYPOINT:"INVALID_ENTRYPOINT",CIRCULAR_DEPENDENCY:"CIRCULAR_DEPENDENCY",TIMEOUT_ERROR:"TIMEOUT_ERROR",NOT_SUPPORTED:"NOT_SUPPORTED",UNKNOWN_ERROR:"UNKNOWN_ERROR"}});async function Vh(){if(Fi!==null)return Fi;try{return Tt=await import("prettier"),Fi=!0,!0}catch{return Fi=!1,!1}}async function Uh(e,t){if(!Tt)return null;try{if(t&&Tt.resolveConfig){let r=await Tt.resolveConfig(t);if(r)return r}if(e&&Tt.resolveConfig){let r=await Tt.resolveConfig(e);if(r)return r}return null}catch{return null}}async function Kh(e,t){if(!Tt)throw Error("Prettier is not available");let r={...t,parser:t.parser||"typescript"};return Tt.format(e,r)}function zh(e,t={}){let{indentSize:r=2,useTabs:n=!1,maxLineWidth:i=100,trailingNewline:s=!0,normalizeWhitespace:o=!0,sortImports:a=!0,groupImports:c=!0}=t,f=e,u=n?"\t":" ".repeat(r);if(f.indexOf(`\r
138
139
  `)!==-1)f=f.replace(/\r\n/g,`
139
140
  `);if(o){if(/[ \t]\n/.test(f)||/[ \t]$/.test(f))f=f.replace(/[ \t]+$/gm,"");if(f.indexOf(`
140
141
 
141
142
 
142
143
  `)!==-1)f=f.replace(/\n{3,}/g,`
143
144
 
144
- `);f=Kh(f,u)}if(a||c)f=Hh(f,{sort:a,group:c});if(i>0)f=Jh(f,i,u);if(s&&!f.endsWith(`
145
+ `);f=Hh(f,u)}if(a||c)f=Jh(f,{sort:a,group:c});if(i>0)f=Yh(f,i,u);if(s&&!f.endsWith(`
145
146
  `))f+=`
146
- `;return f}function Kh(e,t){let r=e.split(`
147
+ `;return f}function Hh(e,t){let r=e.split(`
147
148
  `),n=[];for(let i of r){let s=i.match(/^(\s*)(.*)$/);if(!s){n.push(i);continue}let[,o,a]=s;if(!a){n.push("");continue}let c=o.replace(/\t/g," ").length,f=Math.floor(c/2);n.push(t.repeat(f)+a)}return n.join(`
148
- `)}function Hh(e,t){let r=e.split(`
149
- `),n=[],i=[],s=!1,o=0;for(let c=0;c<r.length;c++){let f=r[c],u=f.match(/^(import\s+(?:type\s+)?.*from\s+['"])([^'"]+)(['"].*)$/);if(u){s=!0,o=c;let l=u[1];n.push({line:f,source:u[2],isType:l.startsWith("import type ")||l.startsWith("import type\t")})}else if(s&&f.trim()==="")continue;else{if(s)s=!1;i.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 zh(c.source,f.source)});let a;if(t.group){let c=[],f=[],u=[],l=[],g=[];for(let d=0;d<n.length;d++){let v=n[d],b=v.source;if(b.charCodeAt(0)===46)g.push(v);else if(b.startsWith("node:"))c.push(v);else if(b.charCodeAt(0)===64)l.push(v);else if(b.includes("/"))u.push(v);else f.push(v)}a=[...c.map((d)=>d.line),...c.length>0&&f.length>0?[""]:[],...f.map((d)=>d.line),...(c.length>0||f.length>0)&&u.length>0?[""]:[],...u.map((d)=>d.line),...l.length>0&&(c.length>0||f.length>0||u.length>0)?[""]:[],...l.map((d)=>d.line),...g.length>0?[""]:[],...g.map((d)=>d.line)]}else a=n.map((c)=>c.line);return[...a,"",...i].join(`
150
- `)}function zh(e,t){let r=e.startsWith("node:"),n=t.startsWith("node:");if(r!==n)return r?-1:1;let i=e.startsWith("."),s=t.startsWith(".");if(i!==s)return i?1:-1;return e.localeCompare(t)}function Jh(e,t,r){let n=e.split(`
151
- `),i=[];for(let s of n){if(s.length<=t){i.push(s);continue}if(s.trimStart().startsWith("import ")){i.push(s);continue}let o=s.match(/^(\s*)/)?.[1]||"",a=o+r,c=Yh(s,o,a);if(c){i.push(...c);continue}if(s.includes("{")&&s.includes("}")){let f=Zh(s,t,o,a);i.push(...f);continue}if(s.includes(" | ")){let f=Xh(s,t,o,a);i.push(...f);continue}i.push(s)}return i.join(`
152
- `)}function Yh(e,t,r){let n=e.match(qh);if(!n)return null;let[,i,s,o,a]=n,c=o.split(",").map((l)=>l.trim()).filter(Boolean);if(c.length<=1)return[e];let f=`${t}${i}${s??""} {`,u=a?`${t}} ${a};`:`${t}};`;return[f,...c.map((l)=>`${r}${l},`),u]}function Zh(e,t,r,n){let i=e.match(/^(\s*)(.*?)(\{)(.+)(\}.*)$/);if(!i)return[e];let[,,s,o,a,c]=i,f=a.split(/;\s*|,\s*/).filter((u)=>u.trim());if(f.length<=1)return[e];return[`${r}${s}${o}`,...f.map((u)=>`${n}${u.trim()};`),`${r}${c.trim()}`]}function Xh(e,t,r,n){let i=e.match(/^(\s*)(.*?=\s*)(.+)$/);if(!i)return[e];let[,,s,o]=i,a=o.split(/\s*\|\s*/).filter((c)=>c.trim());if(a.length<=2)return[e];return[`${r}${s}`,...a.map((c,f)=>`${n}${f>0?"| ":" "}${c.trim()}`)]}async function el(e,t={},r){let n=[];if(t.usePrettier!==!1){if(await jh())try{let i={...await _h(t.prettierConfigPath,r),...t.prettierOptions,parser:"typescript"};return{content:await Vh(e,i),usedPrettier:!0}}catch(i){n.push(`Prettier formatting failed: ${i}. Using built-in formatter.`)}else if(t.usePrettier===!0)n.push("Prettier requested but not available. Using built-in formatter.")}return{content:Uh(e,t.builtIn),usedPrettier:!1,warnings:n.length>0?n:void 0}}var Di=null,xt=null,qh;var tl=ce(()=>{qh=/^\s*(export|import)(\s+type)?\s*\{([^{}]*)\}\s*(from\s*(?:'[^']*'|"[^"]*")(?:\s*(?:with|assert)\s*\{[^{}]*\})?)?\s*;?\s*$/});import{existsSync as Qh,statSync as ed}from"fs";import{dirname as td,extname as rd,isAbsolute as as,resolve as id}from"path";function Ii(e){try{return ed(e).isFile()}catch{return!1}}function Fi(e,t){let r=e.replace(/[?#].*$/,"");if(!(r.startsWith("./")||r.startsWith("../")||r==="."||r==="..")&&!as(r))return{resolved:null,isRelative:!1};let n=td(t),i=as(r)?r:id(n,r);if(Ii(i))return{resolved:i,isRelative:!0};let s=rd(i),o=nd[s];if(o){let a=i.slice(0,-s.length);for(let c of o){let f=a+c;if(Ii(f))return{resolved:f,isRelative:!0}}}for(let a of rl){let c=i+a;if(Ii(c))return{resolved:c,isRelative:!0}}if(Qh(i))for(let a of rl){let c=`${i}/index${a}`;if(Ii(c))return{resolved:c,isRelative:!0}}return{resolved:null,isRelative:!0}}function sd(e){let t=e.length,r="",n=0;while(n<t){let i=e.charCodeAt(n);if(i===34||i===39||i===96){let s=i;r+=e[n++];while(n<t){let o=e.charCodeAt(n),a=e[n++];if(r+=s===96&&o!==s?o===10||o===13?a:" ":a,o===92&&n<t){let c=e[n++];r+=s===96?c===`
153
- `||c==="\r"?c:" ":c;continue}if(o===s)break}continue}if(i===47&&n+1<t){let s=e.charCodeAt(n+1);if(s===47){n+=2;while(n<t&&e.charCodeAt(n)!==10)n++;continue}if(s===42){n+=2;while(n+1<t&&!(e.charCodeAt(n)===42&&e.charCodeAt(n+1)===47))n++;n+=2;continue}}r+=e[n++]}return r}function ls(e,t={}){let r=[],n=sd(e);il.lastIndex=0;let i;while((i=il.exec(n))!==null){let s=!!i[1],o=i[3],a=i[0],c;if(a.includes("* as "))c="export-star-as";else if(a.includes("*"))c="export-star";else c="export-named";r.push({specifier:o,kind:c,isTypeOnly:s})}if(t.includeImports){nl.lastIndex=0;while((i=nl.exec(n))!==null)r.push({specifier:i[3],kind:"import",isTypeOnly:!!i[1]})}return r}async function cs(e,t={}){let r=new Set,n=new Map,i=[],s=[];for(let o of e)if(!r.has(o))r.add(o),s.push(o);while(s.length>0){let o=s.shift(),a;try{a=await ht(o)}catch{continue}let c=ls(a,t);n.set(o,c);for(let f of c){if(!(f.specifier.startsWith(".")||as(f.specifier)))continue;let u=Fi(f.specifier,o);if(u.resolved){if(!r.has(u.resolved))r.add(u.resolved),s.push(u.resolved)}else i.push({from:o,specifier:f.specifier,isTypeOnly:f.isTypeOnly})}}return{reachable:r,reExports:n,unresolved:i}}var rl,nd,il,nl;var sl=ce(()=>{Jr();rl=[".ts",".tsx",".mts",".cts",".vue",".stx",".js",".jsx",".mjs",".cjs",".d.ts",".d.mts",".d.cts"],nd={".js":[".ts",".tsx",".d.ts"],".jsx":[".tsx",".ts",".d.ts"],".mjs":[".mts",".d.mts"],".cjs":[".cts",".d.cts"]};il=/(?:^|[\n;{}])\s*export\s+(type\s+)?(?:\*(?:\s+as\s+\w+)?|\{[^}]*\})\s+from\s+(['"])([^'"]+)\2/g,nl=/(?:^|[\n;{}])\s*import\s+(type\s+)?(?:[^'";\n]+\s+from\s+)?(['"])([^'"]+)\2/g});class Ni{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((r)=>r.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 r of this.plugins)if(r.onStart){let n=await r.onStart(t);if(n)t=n}return this.config=t,t}async runOnBeforeFile(e,t){let r=t;for(let n of this.plugins)if(n.onBeforeFile){let i={filePath:e,sourceCode:t,content:r,config:this.config,log:this.createLogger(n.name)},s=await n.onBeforeFile(i);if(typeof s==="string")r=s}return r}async runOnDeclarations(e,t,r){let n=r;for(let i of this.plugins)if(i.onDeclarations){let s={filePath:e,sourceCode:t,declarations:n,config:this.config,log:this.createLogger(i.name)},o=await i.onDeclarations(s);if(o)n=o}return n}async runOnAfterFile(e,t,r){let n=r;for(let i of this.plugins)if(i.onAfterFile){let s={filePath:e,sourceCode:t,content:n,config:this.config,log:this.createLogger(i.name)},o=await i.onAfterFile(s);if(typeof o==="string")n=o}return n}async runOnEnd(e){for(let t of this.plugins)if(t.onEnd)await t.onEnd(e)}async runOnError(e,t,r){for(let n of this.plugins)if(n.onError){let i={filePath:t,sourceCode:r,config:this.config,log:this.createLogger(n.name)};await n.onError(e,i)}}}function od(e){return e}var gy,yy;var ol=ce(()=>{gy=new Ni;yy=od({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((r)=>r.includes("@internal")))return e.log.debug(`Stripping internal declaration: ${t.name}`),!1}return!0})})});function cl(e,t={}){let{lineEnding:r="lf",trailingNewline:n=!0,maxBlankLines:i=1,trimTrailingWhitespace:s=!0,normalizeIndentation:o=!0,indent:a={style:"spaces",size:2},declarationOrder:c,importGrouping:f,preserveComments:u=!0,insertFinalNewline:l=!0}=t,g=e;if(g=cd(g,r),f?.enabled!==!1)g=md(g,f||{});if(c)g=pd(g,c);if(s)g=fd(g);if(g=ud(g,i),o)g=dd(g,a);if(n||l)g=hd(g);return g}function cd(e,t){let r=e;if(e.indexOf("\r")!==-1){if(e.indexOf(`\r
149
+ `)}function Jh(e,t){let r=e.split(`
150
+ `),n=[],i=[],s=!1,o=0;for(let c=0;c<r.length;c++){let f=r[c],u=f.match(/^(import\s+(?:type\s+)?.*from\s+['"])([^'"]+)(['"].*)$/);if(u){s=!0,o=c;let l=u[1];n.push({line:f,source:u[2],isType:l.startsWith("import type ")||l.startsWith("import type\t")})}else if(s&&f.trim()==="")continue;else{if(s)s=!1;i.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 qh(c.source,f.source)});let a;if(t.group){let c=[],f=[],u=[],l=[],g=[];for(let p=0;p<n.length;p++){let v=n[p],b=v.source;if(b.charCodeAt(0)===46)g.push(v);else if(b.startsWith("node:"))c.push(v);else if(b.charCodeAt(0)===64)l.push(v);else if(b.includes("/"))u.push(v);else f.push(v)}a=[...c.map((p)=>p.line),...c.length>0&&f.length>0?[""]:[],...f.map((p)=>p.line),...(c.length>0||f.length>0)&&u.length>0?[""]:[],...u.map((p)=>p.line),...l.length>0&&(c.length>0||f.length>0||u.length>0)?[""]:[],...l.map((p)=>p.line),...g.length>0?[""]:[],...g.map((p)=>p.line)]}else a=n.map((c)=>c.line);return[...a,"",...i].join(`
151
+ `)}function qh(e,t){let r=e.startsWith("node:"),n=t.startsWith("node:");if(r!==n)return r?-1:1;let i=e.startsWith("."),s=t.startsWith(".");if(i!==s)return i?1:-1;return e.localeCompare(t)}function Yh(e,t,r){let n=e.split(`
152
+ `),i=[];for(let s of n){if(s.length<=t){i.push(s);continue}if(s.trimStart().startsWith("import ")){i.push(s);continue}let o=s.match(/^(\s*)/)?.[1]||"",a=o+r,c=Xh(s,o,a);if(c){i.push(...c);continue}if(s.includes("{")&&s.includes("}")){let f=Qh(s,t,o,a);i.push(...f);continue}if(s.includes(" | ")){let f=ed(s,t,o,a);i.push(...f);continue}i.push(s)}return i.join(`
153
+ `)}function Xh(e,t,r){let n=e.match(Zh);if(!n)return null;let[,i,s,o,a]=n,c=o.split(",").map((l)=>l.trim()).filter(Boolean);if(c.length<=1)return[e];let f=`${t}${i}${s??""} {`,u=a?`${t}} ${a};`:`${t}};`;return[f,...c.map((l)=>`${r}${l},`),u]}function Qh(e,t,r,n){let i=e.match(/^(\s*)(.*?)(\{)(.+)(\}.*)$/);if(!i)return[e];let[,,s,o,a,c]=i,f=a.split(/;\s*|,\s*/).filter((u)=>u.trim());if(f.length<=1)return[e];return[`${r}${s}${o}`,...f.map((u)=>`${n}${u.trim()};`),`${r}${c.trim()}`]}function ed(e,t,r,n){let i=e.match(/^(\s*)(.*?=\s*)(.+)$/);if(!i)return[e];let[,,s,o]=i,a=o.split(/\s*\|\s*/).filter((c)=>c.trim());if(a.length<=2)return[e];return[`${r}${s}`,...a.map((c,f)=>`${n}${f>0?"| ":" "}${c.trim()}`)]}async function rl(e,t={},r){let n=[];if(t.usePrettier!==!1){if(await Vh())try{let i={...await Uh(t.prettierConfigPath,r),...t.prettierOptions,parser:"typescript"};return{content:await Kh(e,i),usedPrettier:!0}}catch(i){n.push(`Prettier formatting failed: ${i}. Using built-in formatter.`)}else if(t.usePrettier===!0)n.push("Prettier requested but not available. Using built-in formatter.")}return{content:zh(e,t.builtIn),usedPrettier:!1,warnings:n.length>0?n:void 0}}var Fi=null,Tt=null,Zh;var il=fe(()=>{Zh=/^\s*(export|import)(\s+type)?\s*\{([^{}]*)\}\s*(from\s*(?:'[^']*'|"[^"]*")(?:\s*(?:with|assert)\s*\{[^{}]*\})?)?\s*;?\s*$/});import{existsSync as td,statSync as rd}from"fs";import{dirname as id,extname as nd,isAbsolute as cs,resolve as sd}from"path";function Ni(e){try{return rd(e).isFile()}catch{return!1}}function Li(e,t){let r=e.replace(/[?#].*$/,"");if(!(r.startsWith("./")||r.startsWith("../")||r==="."||r==="..")&&!cs(r))return{resolved:null,isRelative:!1};let n=id(t),i=cs(r)?r:sd(n,r);if(Ni(i))return{resolved:i,isRelative:!0};let s=nd(i),o=od[s];if(o){let a=i.slice(0,-s.length);for(let c of o){let f=a+c;if(Ni(f))return{resolved:f,isRelative:!0}}}for(let a of nl){let c=i+a;if(Ni(c))return{resolved:c,isRelative:!0}}if(td(i))for(let a of nl){let c=`${i}/index${a}`;if(Ni(c))return{resolved:c,isRelative:!0}}return{resolved:null,isRelative:!0}}function ad(e){let t=e.length,r="",n=0;while(n<t){let i=e.charCodeAt(n);if(i===34||i===39||i===96){let s=i;r+=e[n++];while(n<t){let o=e.charCodeAt(n),a=e[n++];if(r+=s===96&&o!==s?o===10||o===13?a:" ":a,o===92&&n<t){let c=e[n++];r+=s===96?c===`
154
+ `||c==="\r"?c:" ":c;continue}if(o===s)break}continue}if(i===47&&n+1<t){let s=e.charCodeAt(n+1);if(s===47){n+=2;while(n<t&&e.charCodeAt(n)!==10)n++;continue}if(s===42){n+=2;while(n+1<t&&!(e.charCodeAt(n)===42&&e.charCodeAt(n+1)===47))n++;n+=2;continue}}r+=e[n++]}return r}function fs(e,t={}){let r=[],n=ad(e);sl.lastIndex=0;let i;while((i=sl.exec(n))!==null){let s=!!i[1],o=i[3],a=i[0],c;if(a.includes("* as "))c="export-star-as";else if(a.includes("*"))c="export-star";else c="export-named";r.push({specifier:o,kind:c,isTypeOnly:s})}if(t.includeImports){ol.lastIndex=0;while((i=ol.exec(n))!==null)r.push({specifier:i[3],kind:"import",isTypeOnly:!!i[1]})}return r}async function us(e,t={}){let r=new Set,n=new Map,i=[],s=[];for(let o of e)if(!r.has(o))r.add(o),s.push(o);while(s.length>0){let o=s.shift(),a;try{a=await dt(o)}catch{continue}let c=fs(a,t);n.set(o,c);for(let f of c){if(!(f.specifier.startsWith(".")||cs(f.specifier)))continue;let u=Li(f.specifier,o);if(u.resolved){if(!r.has(u.resolved))r.add(u.resolved),s.push(u.resolved)}else i.push({from:o,specifier:f.specifier,isTypeOnly:f.isTypeOnly})}}return{reachable:r,reExports:n,unresolved:i}}var nl,od,sl,ol;var al=fe(()=>{Yr();nl=[".ts",".tsx",".mts",".cts",".vue",".stx",".js",".jsx",".mjs",".cjs",".d.ts",".d.mts",".d.cts"],od={".js":[".ts",".tsx",".d.ts"],".jsx":[".tsx",".ts",".d.ts"],".mjs":[".mts",".d.mts"],".cjs":[".cts",".d.cts"]};sl=/(?:^|[\n;{}])\s*export\s+(type\s+)?(?:\*(?:\s+as\s+\w+)?|\{[^}]*\})\s+from\s+(['"])([^'"]+)\2/g,ol=/(?:^|[\n;{}])\s*import\s+(type\s+)?(?:[^'";\n]+\s+from\s+)?(['"])([^'"]+)\2/g});class Wi{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((r)=>r.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 r of this.plugins)if(r.onStart){let n=await r.onStart(t);if(n)t=n}return this.config=t,t}async runOnBeforeFile(e,t){let r=t;for(let n of this.plugins)if(n.onBeforeFile){let i={filePath:e,sourceCode:t,content:r,config:this.config,log:this.createLogger(n.name)},s=await n.onBeforeFile(i);if(typeof s==="string")r=s}return r}async runOnDeclarations(e,t,r){let n=r;for(let i of this.plugins)if(i.onDeclarations){let s={filePath:e,sourceCode:t,declarations:n,config:this.config,log:this.createLogger(i.name)},o=await i.onDeclarations(s);if(o)n=o}return n}async runOnAfterFile(e,t,r){let n=r;for(let i of this.plugins)if(i.onAfterFile){let s={filePath:e,sourceCode:t,content:n,config:this.config,log:this.createLogger(i.name)},o=await i.onAfterFile(s);if(typeof o==="string")n=o}return n}async runOnEnd(e){for(let t of this.plugins)if(t.onEnd)await t.onEnd(e)}async runOnError(e,t,r){for(let n of this.plugins)if(n.onError){let i={filePath:t,sourceCode:r,config:this.config,log:this.createLogger(n.name)};await n.onError(e,i)}}}function ld(e){return e}var Cy,wy;var ll=fe(()=>{Cy=new Wi;wy=ld({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((r)=>r.includes("@internal")))return e.log.debug(`Stripping internal declaration: ${t.name}`),!1}return!0})})});function ul(e,t={}){let{lineEnding:r="lf",trailingNewline:n=!0,maxBlankLines:i=1,trimTrailingWhitespace:s=!0,normalizeIndentation:o=!0,indent:a={style:"spaces",size:2},declarationOrder:c,importGrouping:f,preserveComments:u=!0,insertFinalNewline:l=!0}=t,g=e;if(g=ud(g,r),f?.enabled!==!1)g=gd(g,f||{});if(c)g=yd(g,c);if(s)g=hd(g);if(g=dd(g,i),o)g=pd(g,a);if(n||l)g=md(g);return g}function ud(e,t){let r=e;if(e.indexOf("\r")!==-1){if(e.indexOf(`\r
154
155
  `)!==-1)r=r.replace(/\r\n/g,`
155
156
  `);if(r.indexOf("\r")!==-1)r=r.replace(/\r/g,`
156
157
  `)}if(t==="crlf")r=r.replace(/\n/g,`\r
157
- `);return r}function fd(e){return e.split(`
158
+ `);return r}function hd(e){return e.split(`
158
159
  `).map((t)=>t.replace(/[\t ]+$/,"")).join(`
159
- `)}function ud(e,t){let r=new RegExp(`\\n{${t+2},}`,"g");return e.replace(r,`
160
- `.repeat(t+1))}function hd(e){return`${e.replace(/\s+$/,"")}
161
- `}function dd(e,t){let{style:r="spaces",size:n=2}=t,i=r==="tabs"?"\t":" ".repeat(n),s=e.split(`
160
+ `)}function dd(e,t){let r=new RegExp(`\\n{${t+2},}`,"g");return e.replace(r,`
161
+ `.repeat(t+1))}function md(e){return`${e.replace(/\s+$/,"")}
162
+ `}function pd(e,t){let{style:r="spaces",size:n=2}=t,i=r==="tabs"?"\t":" ".repeat(n),s=e.split(`
162
163
  `),o=[];for(let a of s){let c=a.match(/^([\t ]*)(.*)$/);if(!c){o.push(a);continue}let[,f,u]=c;if(!u){o.push("");continue}let l=f.replace(/\t/g," "),g=Math.floor(l.length/2);o.push(i.repeat(g)+u)}return o.join(`
163
- `)}function md(e,t){let{groups:r=ld,separateGroups:n=!0,alphabetize:i=!0}=t,s=e.split(`
164
- `),o=[],a=[],c=-1;for(let v=0;v<s.length;v++){let b=s[v],C=al(b);if(C)o.push({line:b,source:C.source,group:C.group,isType:C.isType}),c=v;else if(o.length>0&&b.trim()==="")continue;else if(o.length>0||b.trim()!==""){if(o.length===0||v>c+1)a.push(b)}}if(o.length===0)return e;let f=new Map;for(let v of r)f.set(v,[]);for(let v of o)(f.get(v.group)||f.get("external")||[]).push(v);if(i)for(let[,v]of f)v.sort((b,C)=>{if(b.isType!==C.isType)return b.isType?1:-1;return b.source.localeCompare(C.source)});let u=[],l=null;for(let v of r){let b=f.get(v)||[];if(b.length===0)continue;if(n&&l!==null)u.push("");for(let C of b)u.push(C.line);l=v}let g=s.slice(0,s.findIndex((v)=>al(v)!==null)),d=a;while(d.length>0&&d[0].trim()==="")d.shift();return[...g,...u,"",...d].join(`
165
- `)}function al(e){let t=e.trim(),r=t.match(/^import\s+(type\s+)?.*from\s+['"]([^'"]+)['"]/);if(!r){let s=t.match(/^import\s+['"]([^'"]+)['"]/);if(s)return{source:s[1],group:ll(s[1]),isType:!1};return null}let n=!!r[1],i=r[2];return{source:i,group:n?"type":ll(i),isType:n}}function ll(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 pd(e,t){let{kinds:r=ad,alphabetize:n=!1,groupExports:i=!0}=t,s=e.split(`
166
- `),o=[],a=[],c=[],f=null,u=0,l=!0,g=!1,d=[];for(let C=0;C<s.length;C++){let T=s[C],k=T.trim(),R=u,I=k.startsWith("///"),_=R===0&&!I&&(k.startsWith("//")||k.startsWith("/*"));if(g||_){if(d.push(T),!g&&k.startsWith("/*")&&!k.includes("*/"))g=!0;else if(g&&k.includes("*/"))g=!1;continue}if(R===0&&d.length>0&&k===""){d.push(T);continue}u+=(T.match(/\{/g)||[]).length,u-=(T.match(/\}/g)||[]).length;let L=gd(k);if(l&&L&&L.kind!=="import"&&!k.startsWith("//")&&!k.startsWith("/*"))l=!1;if(l){if(d.length>0){if(L?.kind==="import"||!L)a.push(...d),d.length=0}a.push(T);continue}if(L&&u<=1){if(f)o.push(f);f={lines:d.length>0?[...d,T]:[T],kind:L.kind,name:L.name,isExport:L.isExport},d.length=0}else if(f)f.lines.push(T);else{if(k==="")continue;c.push(T)}}if(f)o.push(f);if(d.length>0)c.push(...d);o.sort((C,T)=>{if(i&&C.isExport!==T.isExport)return C.isExport?-1:1;let k=r.indexOf(C.kind),R=r.indexOf(T.kind),I=k>=0?k:r.length,_=R>=0?R:r.length;if(I!==_)return I-_;if(n)return C.name.localeCompare(T.name);return 0});let v=[...a],b=null;for(let C of o){if(b!==null&&C.kind!==b)v.push("");v.push(...C.lines),b=C.kind}if(c.length>0)v.push(""),v.push(...c);return v.join(`
167
- `)}function gd(e){let t=e.startsWith("export "),r=t?e.slice(7):e;if(e.startsWith("import "))return{kind:"import",name:e.match(/from\s+['"]([^'"]+)['"]/)?.[1]||"",isExport:!1};if(r.startsWith("type ")||r.startsWith("declare type "))return{kind:"type",name:r.match(/type\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("interface ")||r.startsWith("declare interface "))return{kind:"interface",name:r.match(/interface\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("class ")||r.startsWith("abstract class ")||r.startsWith("declare class ")||r.startsWith("declare abstract class "))return{kind:"class",name:r.match(/class\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("enum ")||r.startsWith("const enum ")||r.startsWith("declare enum ")||r.startsWith("declare const enum "))return{kind:"enum",name:r.match(/enum\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("function ")||r.startsWith("async function ")||r.startsWith("declare function ")||r.startsWith("declare async function "))return{kind:"function",name:r.match(/function\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("const ")||r.startsWith("let ")||r.startsWith("var ")||r.startsWith("declare const ")||r.startsWith("declare let ")||r.startsWith("declare var "))return{kind:"variable",name:r.match(/(?:const|let|var)\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("namespace ")||r.startsWith("declare namespace "))return{kind:"namespace",name:r.match(/namespace\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("module ")||r.startsWith("declare module "))return{kind:"module",name:r.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 ad,ld;var fl=ce(()=>{ad=["import","type","interface","enum","class","function","variable","export","module","namespace","unknown"],ld=["builtin","external","scoped","internal","parent","sibling","index","type"]});function Ed(e){switch(e){case"strict":return Cd;case"readonly":return wd;case"simplified":return vd;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 hl{rules;compiled=[];cache=new Map;constructor(e={rules:[]}){if(this.rules=[],e.includeDefaults!==!1)this.rules.push(...yd);if(e.presets)for(let t of e.presets)this.rules.push(...Ed(t));this.rules.push(...e.rules),this.rules.sort((t,r)=>(r.priority||0)-(t.priority||0)),this.recompile()}recompile(){let e=Array(this.rules.length);for(let t=0;t<this.rules.length;t++){let r=this.rules[t],n=typeof r.pattern==="string"?new RegExp(r.pattern.replace(bd,"\\$&"),r.global?"g":""):r.pattern;e[t]={rule:r,regex:n}}this.compiled=e}map(e,t={}){let r=!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(r);if(n!==void 0)return n;let i=e,s=null;for(let o=0;o<this.compiled.length;o++){let{rule:a,regex:c}=this.compiled[o];if(a.condition){if(!s)s={type:e,...t};if(!a.condition(s))continue}if(c.lastIndex=0,c.test(i)){if(c.lastIndex=0,i=i.replace(c,a.replacement),c.lastIndex=0,!a.global)break}}if(this.cache.size>=ul){let o=Math.ceil(ul*0.1),a=0;for(let c of this.cache.keys()){if(a++>=o)break;this.cache.delete(c)}}return this.cache.set(r,i),i}mapAll(e,t={}){return e.map((r)=>this.map(r,{...t,type:r}))}addRule(e){this.rules.push(e),this.rules.sort((t,r)=>(r.priority||0)-(t.priority||0)),this.recompile(),this.cache.clear()}removeRules(e){let t=this.rules.length;return this.rules=this.rules.filter((r)=>{let n=typeof r.pattern==="string"?r.pattern:r.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 Li(e={rules:[]}){return new hl(e)}function dl(e,t,r={}){return e.replace(/:\s*([^;,)\]}]+)/g,(n,i)=>`: ${t.map(i.trim(),r)}`)}var yd,Cd,wd,vd,bd,ul=2048,vy,Ey;var ml=ce(()=>{yd=[{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}],Cd=[{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}],wd=[{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}],vd=[{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}];bd=/[.*+?^${}()|[\]\\]/g;vy=Li({rules:[]}),Ey=Li({rules:[],presets:["strict"]})});var pl;var gl=ce(()=>{pl=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 yl(e,t={strings:!0}){let r="",n=0;while(n<e.length){let i=e.slice(n,n+2);if(i==="//"){let o=e.indexOf(`
164
+ `)}function gd(e,t){let{groups:r=fd,separateGroups:n=!0,alphabetize:i=!0}=t,s=e.split(`
165
+ `),o=[],a=[],c=-1;for(let v=0;v<s.length;v++){let b=s[v],w=cl(b);if(w)o.push({line:b,source:w.source,group:w.group,isType:w.isType}),c=v;else if(o.length>0&&b.trim()==="")continue;else if(o.length>0||b.trim()!==""){if(o.length===0||v>c+1)a.push(b)}}if(o.length===0)return e;let f=new Map;for(let v of r)f.set(v,[]);for(let v of o)(f.get(v.group)||f.get("external")||[]).push(v);if(i)for(let[,v]of f)v.sort((b,w)=>{if(b.isType!==w.isType)return b.isType?1:-1;return b.source.localeCompare(w.source)});let u=[],l=null;for(let v of r){let b=f.get(v)||[];if(b.length===0)continue;if(n&&l!==null)u.push("");for(let w of b)u.push(w.line);l=v}let g=s.slice(0,s.findIndex((v)=>cl(v)!==null)),p=a;while(p.length>0&&p[0].trim()==="")p.shift();return[...g,...u,"",...p].join(`
166
+ `)}function cl(e){let t=e.trim(),r=t.match(/^import\s+(type\s+)?.*from\s+['"]([^'"]+)['"]/);if(!r){let s=t.match(/^import\s+['"]([^'"]+)['"]/);if(s)return{source:s[1],group:fl(s[1]),isType:!1};return null}let n=!!r[1],i=r[2];return{source:i,group:n?"type":fl(i),isType:n}}function fl(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 yd(e,t){let{kinds:r=cd,alphabetize:n=!1,groupExports:i=!0}=t,s=e.split(`
167
+ `),o=[],a=[],c=[],f=null,u=0,l=!0,g=!1,p=[];for(let w=0;w<s.length;w++){let T=s[w],k=T.trim(),R=u,I=k.startsWith("///"),_=R===0&&!I&&(k.startsWith("//")||k.startsWith("/*"));if(g||_){if(p.push(T),!g&&k.startsWith("/*")&&!k.includes("*/"))g=!0;else if(g&&k.includes("*/"))g=!1;continue}if(R===0&&p.length>0&&k===""){p.push(T);continue}u+=(T.match(/\{/g)||[]).length,u-=(T.match(/\}/g)||[]).length;let W=Cd(k);if(l&&W&&W.kind!=="import"&&!k.startsWith("//")&&!k.startsWith("/*"))l=!1;if(l){if(p.length>0){if(W?.kind==="import"||!W)a.push(...p),p.length=0}a.push(T);continue}if(W&&u<=1){if(f)o.push(f);f={lines:p.length>0?[...p,T]:[T],kind:W.kind,name:W.name,isExport:W.isExport},p.length=0}else if(f)f.lines.push(T);else{if(k==="")continue;c.push(T)}}if(f)o.push(f);if(p.length>0)c.push(...p);o.sort((w,T)=>{if(i&&w.isExport!==T.isExport)return w.isExport?-1:1;let k=r.indexOf(w.kind),R=r.indexOf(T.kind),I=k>=0?k:r.length,_=R>=0?R:r.length;if(I!==_)return I-_;if(n)return w.name.localeCompare(T.name);return 0});let v=[...a],b=null;for(let w of o){if(b!==null&&w.kind!==b)v.push("");v.push(...w.lines),b=w.kind}if(c.length>0)v.push(""),v.push(...c);return v.join(`
168
+ `)}function Cd(e){let t=e.startsWith("export "),r=t?e.slice(7):e;if(e.startsWith("import "))return{kind:"import",name:e.match(/from\s+['"]([^'"]+)['"]/)?.[1]||"",isExport:!1};if(r.startsWith("type ")||r.startsWith("declare type "))return{kind:"type",name:r.match(/type\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("interface ")||r.startsWith("declare interface "))return{kind:"interface",name:r.match(/interface\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("class ")||r.startsWith("abstract class ")||r.startsWith("declare class ")||r.startsWith("declare abstract class "))return{kind:"class",name:r.match(/class\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("enum ")||r.startsWith("const enum ")||r.startsWith("declare enum ")||r.startsWith("declare const enum "))return{kind:"enum",name:r.match(/enum\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("function ")||r.startsWith("async function ")||r.startsWith("declare function ")||r.startsWith("declare async function "))return{kind:"function",name:r.match(/function\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("const ")||r.startsWith("let ")||r.startsWith("var ")||r.startsWith("declare const ")||r.startsWith("declare let ")||r.startsWith("declare var "))return{kind:"variable",name:r.match(/(?:const|let|var)\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("namespace ")||r.startsWith("declare namespace "))return{kind:"namespace",name:r.match(/namespace\s+(\w+)/)?.[1]||"",isExport:t};if(r.startsWith("module ")||r.startsWith("declare module "))return{kind:"module",name:r.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 cd,fd;var hl=fe(()=>{cd=["import","type","interface","enum","class","function","variable","export","module","namespace","unknown"],fd=["builtin","external","scoped","internal","parent","sibling","index","type"]});function Sd(e){switch(e){case"strict":return vd;case"readonly":return Ed;case"simplified":return bd;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 ml{rules;compiled=[];cache=new Map;constructor(e={rules:[]}){if(this.rules=[],e.includeDefaults!==!1)this.rules.push(...wd);if(e.presets)for(let t of e.presets)this.rules.push(...Sd(t));this.rules.push(...e.rules),this.rules.sort((t,r)=>(r.priority||0)-(t.priority||0)),this.recompile()}recompile(){let e=Array(this.rules.length);for(let t=0;t<this.rules.length;t++){let r=this.rules[t],n=typeof r.pattern==="string"?new RegExp(r.pattern.replace($d,"\\$&"),r.global?"g":""):r.pattern;e[t]={rule:r,regex:n}}this.compiled=e}map(e,t={}){let r=!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(r);if(n!==void 0)return n;let i=e,s=null;for(let o=0;o<this.compiled.length;o++){let{rule:a,regex:c}=this.compiled[o];if(a.condition){if(!s)s={type:e,...t};if(!a.condition(s))continue}if(c.lastIndex=0,c.test(i)){if(c.lastIndex=0,i=i.replace(c,a.replacement),c.lastIndex=0,!a.global)break}}if(this.cache.size>=dl){let o=Math.ceil(dl*0.1),a=0;for(let c of this.cache.keys()){if(a++>=o)break;this.cache.delete(c)}}return this.cache.set(r,i),i}mapAll(e,t={}){return e.map((r)=>this.map(r,{...t,type:r}))}addRule(e){this.rules.push(e),this.rules.sort((t,r)=>(r.priority||0)-(t.priority||0)),this.recompile(),this.cache.clear()}removeRules(e){let t=this.rules.length;return this.rules=this.rules.filter((r)=>{let n=typeof r.pattern==="string"?r.pattern:r.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 Bi(e={rules:[]}){return new ml(e)}function pl(e,t,r={}){return e.replace(/:\s*([^;,)\]}]+)/g,(n,i)=>`: ${t.map(i.trim(),r)}`)}var wd,vd,Ed,bd,$d,dl=2048,by,Sy;var gl=fe(()=>{wd=[{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}],vd=[{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}],Ed=[{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}],bd=[{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}];$d=/[.*+?^${}()|[\]\\]/g;by=Bi({rules:[]}),Sy=Bi({rules:[],presets:["strict"]})});var yl;var Cl=fe(()=>{yl=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 wl(e,t={strings:!0}){let r="",n=0;while(n<e.length){let i=e.slice(n,n+2);if(i==="//"){let o=e.indexOf(`
168
169
  `,n),a=o===-1?e.length:o;r+=" ".repeat(a-n),n=a;continue}if(i==="/*"){let o=e.indexOf("*/",n+2),a=o===-1?e.length:o+2;for(let c=n;c<a;c++)r+=e[c]===`
169
170
  `?`
170
171
  `:" ";n=a;continue}let s=e[n];if(t.strings&&(s==='"'||s==="'"||s==="`")){let o=s;r+=" ",n++;while(n<e.length){if(e[n]==="\\"){r+=" ",n+=2;continue}if(e[n]===o){r+=" ",n++;break}r+=e[n]===`
171
172
  `?`
172
- `:" ",n++}continue}r+=s,n++}return r}function Ad(e){let t=new Set,r=[/\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 r)for(let i of e.matchAll(n))t.add(i[1]);return t}function $d(e){let t=new Set;for(let r of e.matchAll(/\bimport\s+(?:type\s+)?([\s\S]*?)\s+from\s*['"`]/g)){let n=r[1],i=/\*\s*as\s+([A-Za-z_$][\w$]*)/.exec(n);if(i)t.add(i[1]);let s=n.split("{")[0].replace(/\*\s*as\s+[A-Za-z_$][\w$]*/,"");for(let a of s.split(",")){let c=a.trim();if(/^[A-Za-z_$][\w$]*$/.test(c))t.add(c)}let o=/\{([\s\S]*?)\}/.exec(n);if(o)for(let a of o[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 r of e.matchAll(/\bimport\s*\(\s*['"`][^'"`]*['"`]\s*\)\s*\.\s*([A-Za-z_$][\w$]*)/g))t.add(r[1]);return t}function xd(e){let t=new Set,r=(i)=>{for(let s of i.split(",")){let o=s.trim().split(/\s+|=/)[0]?.trim();if(o&&/^[A-Za-z_$][\w$]*$/.test(o))t.add(o)}},n=/\b(?:type|interface|class|function)\s+[A-Za-z_$][\w$]*\s*<([^<>]*(?:<[^<>]*>[^<>]*)*)>/g;for(let i of e.matchAll(n))r(i[1]);for(let i of e.matchAll(/(?:\b[A-Za-z_$][\w$]*)?\s*<([^<>()]*)>\s*\(/g))r(i[1]);for(let i of e.matchAll(/\binfer\s+([A-Za-z_$][\w$]*)/g))t.add(i[1]);for(let i of e.matchAll(/\[\s*([A-Za-z_$][\w$]*)\s+in\b/g))t.add(i[1]);return t}function Td(e){let t=new Map,r=(i)=>{let s=1;for(let o=0;o<i&&o<e.length;o++)if(e.charCodeAt(o)===10)s++;return s},n=(i,s,o)=>{for(let a of i.matchAll(/\b([A-Z][\w$]*)\b/g)){let c=a[1];if(t.has(c))continue;let f=i.slice(a.index+c.length);if(/^\s*\??:/.test(f))continue;t.set(c,{line:r(s),context:o.trim().slice(0,120)})}};for(let i of e.matchAll(/\btype\s+[A-Za-z_$][\w$]*\s*(?:<[^=]*?>)?\s*=([^;]*)/g))n(i[1],i.index+i[0].indexOf("="),i[0]);for(let i of e.matchAll(/\b(?:extends|implements)\s+([^{;]*)/g))n(i[1],i.index,i[0]);for(let i of e.matchAll(/:\s*([^;,){}\n=]+)/g))n(i[1],i.index,i[0]);for(let i of e.matchAll(/<([^<>()]*)>/g))n(i[1],i.index,i[0]);return t}function Cl(e){let t=yl(e),r=yl(e,{strings:!1}),n=new Set([...Ad(t),...$d(r),...xd(t),...pl,...Sd]),i=[];for(let[s,o]of Td(t)){if(n.has(s))continue;if(new RegExp(`[\\w$]\\s*\\.\\s*${s}\\b`).test(t))continue;i.push({name:s,line:o.line,context:o.context})}return i.sort((s,o)=>s.line-o.line||s.name.localeCompare(o.name))}var Sd;var wl=ce(()=>{gl();Sd=new Set(["This","True","False","Null","Undefined","Void","Never","Any","Unknown","Object","Infinity","NaN"])});function Tt(e,t){let r=1,n=1;for(let i=0;i<t;i++)if(e.charCodeAt(i)===10)r++,n=1;else n++;return{line:r,column:n}}function El(e){let t=[],r=[],n=[],i={")":"(","]":"[","}":"{"},s=0,o=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)r.push({start:a,end:f+2}),a=-1,f++;continue}if(s){if(u===92)f++;else if(u===s)r.push({start:o,end:f+1}),s=0;continue}if(u===47&&l===42){a=f,f++;continue}if(u===47&&l===47){let d=f;while(f<e.length&&e.charCodeAt(f)!==10)f++;r.push({start:d,end:f});continue}if(u===39||u===34||u===96){s=u,o=f;continue}let g=e[f];if(g==="("||g==="["||g==="{")n.push({char:g,offset:f});else if(i[g]){let d=n.pop();if(!d||d.char!==i[g])t.push({...Tt(e,f),message:`Unexpected closing delimiter ${g}`,code:"DTSX1004"})}}if(s)t.push({...Tt(e,o),message:"Unterminated string literal",code:"DTSX1002"});if(a!==-1)t.push({...Tt(e,a),message:"Unterminated block comment",code:"DTSX1003"});for(let f of n)t.push({...Tt(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(r.some((g)=>l.index>=g.start&&l.index<g.end))continue;t.push({...Tt(e,l.index),message:u,code:"DTSX1005"})}for(let f of e.matchAll(/\btype\s*(?=[{=])/g)){if(r.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({...Tt(e,f.index),message:"Declaration name expected",code:"DTSX1005"})}return t.push(...Rd(e,r)),t.sort((f,u)=>f.line-u.line||f.column-u.column)}function Rd(e,t){let r=[],n=(i)=>t.some((s)=>i>=s.start&&i<s.end);for(let i of e.matchAll(/\b(import|export)\s+(?:type\s+)?\{/g)){let s=i.index;if(n(s))continue;let o=s+i[0].length-1,a=-1;for(let u=o+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(o+1,a);if(!c.trim())continue;let f=o+1;for(let u of c.split(",")){let l=u.trim();if(l){let g=f+u.indexOf(l);if(l.includes(";"))r.push({...Tt(e,g),message:`Unexpected ';' in ${i[1]} clause \u2014 specifiers are separated by ','`,code:"DTSX1006"});else if(!Pd.test(l))r.push({...Tt(e,g),message:`Invalid ${i[1]} specifier '${l}'`,code:"DTSX1006"})}f+=u.length+1}}return r}var vl,Pd;var bl=ce(()=>{vl=String.raw`(?:[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*|'[^']*'|"[^"]*")`,Pd=new RegExp(`^(?:type\\s+)?${vl}(?:\\s+as\\s+${vl})?$`,"u")});import{statSync as Od}from"fs";import{readFile as kd,readdir as My}from"fs/promises";import{createRequire as Md}from"module";import{dirname as Dd,isAbsolute as Sl,join as Id,resolve as Al}from"path";import Fd from"process";function us(){return`${String.fromCharCode(47,47,35)} sourceMappingURL=`}async function br(e,t,r="lf"){let n=t.replace(/\r\n/g,`
173
+ `:" ",n++}continue}r+=s,n++}return r}function xd(e){let t=new Set,r=[/\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 r)for(let i of e.matchAll(n))t.add(i[1]);return t}function Td(e){let t=new Set;for(let r of e.matchAll(/\bimport\s+(?:type\s+)?([\s\S]*?)\s+from\s*['"`]/g)){let n=r[1],i=/\*\s*as\s+([A-Za-z_$][\w$]*)/.exec(n);if(i)t.add(i[1]);let s=n.split("{")[0].replace(/\*\s*as\s+[A-Za-z_$][\w$]*/,"");for(let a of s.split(",")){let c=a.trim();if(/^[A-Za-z_$][\w$]*$/.test(c))t.add(c)}let o=/\{([\s\S]*?)\}/.exec(n);if(o)for(let a of o[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 r of e.matchAll(/\bimport\s*\(\s*['"`][^'"`]*['"`]\s*\)\s*\.\s*([A-Za-z_$][\w$]*)/g))t.add(r[1]);return t}function Pd(e){let t=new Set,r=(i)=>{for(let s of i.split(",")){let o=s.trim().split(/\s+|=/)[0]?.trim();if(o&&/^[A-Za-z_$][\w$]*$/.test(o))t.add(o)}},n=/\b(?:type|interface|class|function)\s+[A-Za-z_$][\w$]*\s*<([^<>]*(?:<[^<>]*>[^<>]*)*)>/g;for(let i of e.matchAll(n))r(i[1]);for(let i of e.matchAll(/(?:\b[A-Za-z_$][\w$]*)?\s*<([^<>()]*)>\s*\(/g))r(i[1]);for(let i of e.matchAll(/\binfer\s+([A-Za-z_$][\w$]*)/g))t.add(i[1]);for(let i of e.matchAll(/\[\s*([A-Za-z_$][\w$]*)\s+in\b/g))t.add(i[1]);return t}function Rd(e){let t=new Map,r=(i)=>{let s=1;for(let o=0;o<i&&o<e.length;o++)if(e.charCodeAt(o)===10)s++;return s},n=(i,s,o)=>{for(let a of i.matchAll(/\b([A-Z][\w$]*)\b/g)){let c=a[1];if(t.has(c))continue;let f=i.slice(a.index+c.length);if(/^\s*\??:/.test(f))continue;t.set(c,{line:r(s),context:o.trim().slice(0,120)})}};for(let i of e.matchAll(/\btype\s+[A-Za-z_$][\w$]*\s*(?:<[^=]*?>)?\s*=([^;]*)/g))n(i[1],i.index+i[0].indexOf("="),i[0]);for(let i of e.matchAll(/\b(?:extends|implements)\s+([^{;]*)/g))n(i[1],i.index,i[0]);for(let i of e.matchAll(/:\s*([^;,){}\n=]+)/g))n(i[1],i.index,i[0]);for(let i of e.matchAll(/<([^<>()]*)>/g))n(i[1],i.index,i[0]);return t}function vl(e){let t=wl(e),r=wl(e,{strings:!1}),n=new Set([...xd(t),...Td(r),...Pd(t),...yl,...Ad]),i=[];for(let[s,o]of Rd(t)){if(n.has(s))continue;if(new RegExp(`[\\w$]\\s*\\.\\s*${s}\\b`).test(t))continue;i.push({name:s,line:o.line,context:o.context})}return i.sort((s,o)=>s.line-o.line||s.name.localeCompare(o.name))}var Ad;var El=fe(()=>{Cl();Ad=new Set(["This","True","False","Null","Undefined","Void","Never","Any","Unknown","Object","Infinity","NaN"])});function Pt(e,t){let r=1,n=1;for(let i=0;i<t;i++)if(e.charCodeAt(i)===10)r++,n=1;else n++;return{line:r,column:n}}function Sl(e){let t=[],r=[],n=[],i={")":"(","]":"[","}":"{"},s=0,o=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)r.push({start:a,end:f+2}),a=-1,f++;continue}if(s){if(u===92)f++;else if(u===s)r.push({start:o,end:f+1}),s=0;continue}if(u===47&&l===42){a=f,f++;continue}if(u===47&&l===47){let p=f;while(f<e.length&&e.charCodeAt(f)!==10)f++;r.push({start:p,end:f});continue}if(u===39||u===34||u===96){s=u,o=f;continue}let g=e[f];if(g==="("||g==="["||g==="{")n.push({char:g,offset:f});else if(i[g]){let p=n.pop();if(!p||p.char!==i[g])t.push({...Pt(e,f),message:`Unexpected closing delimiter ${g}`,code:"DTSX1004"})}}if(s)t.push({...Pt(e,o),message:"Unterminated string literal",code:"DTSX1002"});if(a!==-1)t.push({...Pt(e,a),message:"Unterminated block comment",code:"DTSX1003"});for(let f of n)t.push({...Pt(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(r.some((g)=>l.index>=g.start&&l.index<g.end))continue;t.push({...Pt(e,l.index),message:u,code:"DTSX1005"})}for(let f of e.matchAll(/\btype\s*(?=[{=])/g)){if(r.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({...Pt(e,f.index),message:"Declaration name expected",code:"DTSX1005"})}return t.push(...kd(e,r)),t.sort((f,u)=>f.line-u.line||f.column-u.column)}function kd(e,t){let r=[],n=(i)=>t.some((s)=>i>=s.start&&i<s.end);for(let i of e.matchAll(/\b(import|export)\s+(?:type\s+)?\{/g)){let s=i.index;if(n(s))continue;let o=s+i[0].length-1,a=-1;for(let u=o+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(o+1,a);if(!c.trim())continue;let f=o+1;for(let u of c.split(",")){let l=u.trim();if(l){let g=f+u.indexOf(l);if(l.includes(";"))r.push({...Pt(e,g),message:`Unexpected ';' in ${i[1]} clause \u2014 specifiers are separated by ','`,code:"DTSX1006"});else if(!Od.test(l))r.push({...Pt(e,g),message:`Invalid ${i[1]} specifier '${l}'`,code:"DTSX1006"})}f+=u.length+1}}return r}var bl,Od;var $l=fe(()=>{bl=String.raw`(?:[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*|'[^']*'|"[^"]*")`,Od=new RegExp(`^(?:type\\s+)?${bl}(?:\\s+as\\s+${bl})?$`,"u")});import{statSync as Md}from"fs";import{readFile as Dd,readdir as Iy}from"fs/promises";import{createRequire as Id}from"module";import{dirname as Fd,isAbsolute as Al,join as Nd,resolve as xl}from"path";import Ld from"process";function ds(){return`${String.fromCharCode(47,47,35)} sourceMappingURL=`}async function Sr(e,t,r="lf"){let n=t.replace(/\r\n/g,`
173
174
  `);if(!n.endsWith(`
174
175
  `))n+=`
175
176
  `;if(r==="crlf")n=n.replace(/\n/g,`\r
176
- `);await Eo(e,n)}function Nd(e){let t="",r=0,n=0;while(r<e.length){let i=e.charCodeAt(r);if(n){if(t+=e[r],i===92&&r+1<e.length){t+=e[r+1],r+=2;continue}if(i===n)n=0;r++;continue}if(i===34){n=i,t+=e[r++];continue}if(i===47&&e.charCodeAt(r+1)===47){r+=2;while(r<e.length&&e.charCodeAt(r)!==10)r++;continue}if(i===47&&e.charCodeAt(r+1)===42){r+=2;while(r+1<e.length&&!(e.charCodeAt(r)===42&&e.charCodeAt(r+1)===47)){if(e.charCodeAt(r)===10)t+=`
177
- `;r++}r=Math.min(r+2,e.length);continue}if(i===44){let s=r+1;while(s<e.length){while(s<e.length&&e.charCodeAt(s)<=32)s++;if(e.charCodeAt(s)===47&&e.charCodeAt(s+1)===47){s+=2;while(s<e.length&&e.charCodeAt(s)!==10)s++;continue}if(e.charCodeAt(s)===47&&e.charCodeAt(s+1)===42){s+=2;while(s+1<e.length&&!(e.charCodeAt(s)===42&&e.charCodeAt(s+1)===47))s++;s=Math.min(s+2,e.length);continue}break}let o=e.charCodeAt(s);if(o===93||o===125){r++;continue}}t+=e[r++]}return t}function fs(e){let t=[e];if(!e.endsWith(".json"))t.push(`${e}.json`);t.push(Id(e,"tsconfig.json"));for(let r of t)try{if(Od(r).isFile())return r}catch{}return null}function Ld(e,t){if(Sl(e)||e.startsWith("."))return fs(Al(Dd(t),e));let r=Md(t);for(let n of[e,`${e}/tsconfig.json`])try{let i=fs(r.resolve(n));if(i)return i}catch{}return null}async function $l(e,t){let r=fs(e);if(!r||t.has(r))return;t.add(r);let n=await kd(r,"utf8"),i=JSON.parse(Nd(n)),s=typeof i.extends==="string"?[i.extends]:i.extends??[],o;for(let a of s){let c=Ld(a,r);if(!c)continue;let f=await $l(c,t);if(f!==void 0)o=f}return i.compilerOptions?.isolatedDeclarations??o}async function xl(e){try{let t=e?.cwd||Fd.cwd(),r=e?.tsconfigPath||"tsconfig.json",n=Sl(r)?r:Al(t,r);return await $l(n,new Set)??!1}catch{return!1}}function Tl(e,t){let r={isValid:!0,errors:[]};for(let n of El(e))r.errors.push({line:n.line,column:n.column,message:n.message,code:n.code});for(let n of Cl(e))r.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 r.isValid=r.errors.length===0,r}function Pl(e,t,r){if(e===t)return"";let n=e.split(`
177
+ `);await So(e,n)}function Wd(e){let t="",r=0,n=0;while(r<e.length){let i=e.charCodeAt(r);if(n){if(t+=e[r],i===92&&r+1<e.length){t+=e[r+1],r+=2;continue}if(i===n)n=0;r++;continue}if(i===34){n=i,t+=e[r++];continue}if(i===47&&e.charCodeAt(r+1)===47){r+=2;while(r<e.length&&e.charCodeAt(r)!==10)r++;continue}if(i===47&&e.charCodeAt(r+1)===42){r+=2;while(r+1<e.length&&!(e.charCodeAt(r)===42&&e.charCodeAt(r+1)===47)){if(e.charCodeAt(r)===10)t+=`
178
+ `;r++}r=Math.min(r+2,e.length);continue}if(i===44){let s=r+1;while(s<e.length){while(s<e.length&&e.charCodeAt(s)<=32)s++;if(e.charCodeAt(s)===47&&e.charCodeAt(s+1)===47){s+=2;while(s<e.length&&e.charCodeAt(s)!==10)s++;continue}if(e.charCodeAt(s)===47&&e.charCodeAt(s+1)===42){s+=2;while(s+1<e.length&&!(e.charCodeAt(s)===42&&e.charCodeAt(s+1)===47))s++;s=Math.min(s+2,e.length);continue}break}let o=e.charCodeAt(s);if(o===93||o===125){r++;continue}}t+=e[r++]}return t}function hs(e){let t=[e];if(!e.endsWith(".json"))t.push(`${e}.json`);t.push(Nd(e,"tsconfig.json"));for(let r of t)try{if(Md(r).isFile())return r}catch{}return null}function Bd(e,t){if(Al(e)||e.startsWith("."))return hs(xl(Fd(t),e));let r=Id(t);for(let n of[e,`${e}/tsconfig.json`])try{let i=hs(r.resolve(n));if(i)return i}catch{}return null}async function Tl(e,t){let r=hs(e);if(!r||t.has(r))return;t.add(r);let n=await Dd(r,"utf8"),i=JSON.parse(Wd(n)),s=typeof i.extends==="string"?[i.extends]:i.extends??[],o;for(let a of s){let c=Bd(a,r);if(!c)continue;let f=await Tl(c,t);if(f!==void 0)o=f}return i.compilerOptions?.isolatedDeclarations??o}async function Pl(e){try{let t=e?.cwd||Ld.cwd(),r=e?.tsconfigPath||"tsconfig.json",n=Al(r)?r:xl(t,r);return await Tl(n,new Set)??!1}catch{return!1}}function Rl(e,t){let r={isValid:!0,errors:[]};for(let n of Sl(e))r.errors.push({line:n.line,column:n.column,message:n.message,code:n.code});for(let n of vl(e))r.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 r.isValid=r.errors.length===0,r}function Ol(e,t,r){if(e===t)return"";let n=e.split(`
178
179
  `),i=t.split(`
179
- `),s=new Map,o=new Map;for(let u=0;u<n.length;u++)s.set(n[u],(s.get(n[u])??0)+1);for(let u=0;u<i.length;u++)o.set(i[u],(o.get(i[u])??0)+1);let a=[],c=[];for(let[u,l]of s){let g=l-(o.get(u)??0);for(let d=0;d<g;d++)a.push(u)}for(let[u,l]of o){let g=l-(s.get(u)??0);for(let d=0;d<g;d++)c.push(u)}if(a.length===0&&c.length===0)return"";let f=[`--- ${r}`,`+++ ${r}`];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(`
180
- `)}function Rl(e,t,r,n){let i=e.split(`
181
- `),s=[];function o(l){let g="",d=l<0?-l<<1|1:l<<1;do{let v=d&31;if(d>>>=5,d>0)v|=32;g+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[v]}while(d>0);return g}let a=0,c=0,f=0,u=n.split(`
182
- `).length;for(let l=0;l<i.length;l++){if(i[l].trim()===""){s.push("");continue}a=0;let g=Math.min(l,u-1),d=[],v=0-a,b=0,C=g-c,T=0-f;d.push(o(v)+o(b)+o(C)+o(T)),a=0,c=g,f=0,s.push(d.join(","))}return{version:3,file:t,sourceRoot:"",sources:[r],sourcesContent:[n],mappings:s.join(";")}}function Ol(e,t){return`${e}
183
- ${us()}${t}
184
- `}var kl=ce(()=>{Jr();wl();bl()});function vt(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}
180
+ `),s=new Map,o=new Map;for(let u=0;u<n.length;u++)s.set(n[u],(s.get(n[u])??0)+1);for(let u=0;u<i.length;u++)o.set(i[u],(o.get(i[u])??0)+1);let a=[],c=[];for(let[u,l]of s){let g=l-(o.get(u)??0);for(let p=0;p<g;p++)a.push(u)}for(let[u,l]of o){let g=l-(s.get(u)??0);for(let p=0;p<g;p++)c.push(u)}if(a.length===0&&c.length===0)return"";let f=[`--- ${r}`,`+++ ${r}`];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(`
181
+ `)}function kl(e,t,r,n){let i=e.split(`
182
+ `),s=[];function o(l){let g="",p=l<0?-l<<1|1:l<<1;do{let v=p&31;if(p>>>=5,p>0)v|=32;g+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[v]}while(p>0);return g}let a=0,c=0,f=0,u=n.split(`
183
+ `).length;for(let l=0;l<i.length;l++){if(i[l].trim()===""){s.push("");continue}a=0;let g=Math.min(l,u-1),p=[],v=0-a,b=0,w=g-c,T=0-f;p.push(o(v)+o(b)+o(w)+o(T)),a=0,c=g,f=0,s.push(p.join(","))}return{version:3,file:t,sourceRoot:"",sources:[r],sourcesContent:[n],mappings:s.join(";")}}function Ml(e,t){return`${e}
184
+ ${ds()}${t}
185
+ `}var Dl=fe(()=>{Yr();El();$l()});function Et(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}
185
186
  `;return`${n.trim()}
186
187
  `}let r="";for(let n=0;n<e.length;n++){if(n>0)r+=`
187
188
  `;r+=e[n].trim()}return`${r}
188
- `}var Ml=()=>{};function Wd(e){if(e.includes(`
189
+ `}var Il=()=>{};function Gd(e){if(e.includes(`
189
190
  `))return`/**
190
191
  * ${e}
191
192
  */
192
193
  `;return`/** ${e} */
193
- `}function Bd(e){let t=e.indexOf("{");if(t===-1)return-1;let r=e.indexOf("<");if(r===-1||r>t)return t;let n=0,i=!1,s="";for(let o=0;o<e.length;o++){let a=e[o],c=o>0?e[o-1]:"";if(!i&&(a==='"'||a==="'"||a==="`"))i=!0,s=a;else if(i&&a===s&&c!=="\\")i=!1;if(!i){if(a==="<")n++;else if(a===">")n--;else if(a==="{"&&n===0)return o}}return-1}function Gd(e,t=!0){return vt(e.leadingComments,t)+e.text}function Dl(e,t=!0){let r=vt(e.leadingComments,t);if(e.typeAnnotation&&!e.value)return r+e.text;let n="";if(e.isExported)n+="export ";n+="declare ";let i=e.modifiers?.[0]||"const";n+=`${i} `,n+=e.name;let{typeAnnotation:s,value:o}=e;if(o&&o.includes(" satisfies ")){let c=eo(o);if(c)s=c}else if(!s&&o&&o.trim().endsWith("as const"))s=Te(o,!0);else if(!s&&o&&i==="const"){let c=o.trim(),f=c.startsWith("{")||c.startsWith("[");if(f)fn();s=Te(o,!f)}else if(!s&&o)s=Te(o,i==="const");if(!s)s="unknown";let a="";if(t&&o&&!e.typeAnnotation&&!o.trim().endsWith("as const")){let c=o.trim();if(i!=="const"){if((s==="string"||s==="number"||s==="boolean")&&c.length>0)a=`@defaultValue ${c}`}else if(c.startsWith("{")||c.startsWith("[")){let f=un();if(f)if(f.includes(`
194
+ `}function jd(e){let t=e.indexOf("{");if(t===-1)return-1;let r=e.indexOf("<");if(r===-1||r>t)return t;let n=0,i=!1,s="";for(let o=0;o<e.length;o++){let a=e[o],c=o>0?e[o-1]:"";if(!i&&(a==='"'||a==="'"||a==="`"))i=!0,s=a;else if(i&&a===s&&c!=="\\")i=!1;if(!i){if(a==="<")n++;else if(a===">")n--;else if(a==="{"&&n===0)return o}}return-1}function _d(e,t=!0){return Et(e.leadingComments,t)+e.text}function Fl(e,t=!0){let r=Et(e.leadingComments,t);if(e.typeAnnotation&&!e.value)return r+e.text;let n="";if(e.isExported)n+="export ";n+="declare ";let i=e.modifiers?.[0]||"const";n+=`${i} `,n+=e.name;let{typeAnnotation:s,value:o}=e;if(o&&o.includes(" satisfies ")){let c=ro(o);if(c)s=c}else if(!s&&o&&o.trim().endsWith("as const"))s=Te(o,!0);else if(!s&&o&&i==="const"){let c=o.trim(),f=c.startsWith("{")||c.startsWith("[");if(f)hn();s=Te(o,!f)}else if(!s&&o)s=Te(o,i==="const");if(!s)s="unknown";let a="";if(t&&o&&!e.typeAnnotation&&!o.trim().endsWith("as const")){let c=o.trim();if(i!=="const"){if((s==="string"||s==="number"||s==="boolean")&&c.length>0)a=`@defaultValue ${c}`}else if(c.startsWith("{")||c.startsWith("[")){let f=dn();if(f)if(f.includes(`
194
195
  `))a=`@defaultValue
195
196
  * \`\`\`ts
196
197
  ${f.split(`
197
198
  `).map((u)=>` * ${u}`).join(`
198
199
  `)}
199
- * \`\`\``;else a=`@defaultValue \`${f}\``}}else if(t&&o&&e.typeAnnotation&&Qs(e.typeAnnotation)){fn();let c=o.trim(),f=c.endsWith("as const")?c.slice(0,-8).trim():c;Te(f,!1);let u=un();if(u)if(u.includes(`
200
+ * \`\`\``;else a=`@defaultValue \`${f}\``}}else if(t&&o&&e.typeAnnotation&&to(e.typeAnnotation)){hn();let c=o.trim(),f=c.endsWith("as const")?c.slice(0,-8).trim():c;Te(f,!1);let u=dn();if(u)if(u.includes(`
200
201
  `))a=`@defaultValue
201
202
  * \`\`\`ts
202
203
  ${u.split(`
@@ -211,27 +212,27 @@ ${u.split(`
211
212
  * ${c.replace(/^\/\/\s*/,"")}
212
213
  * ${a}
213
214
  */
214
- ${n}`}if(a)return`${Wd(a)}${n}`;return r+n}function jd(e,t=!0){let r=vt(e.leadingComments,t),n=e.text;if(n.startsWith("export declare interface")||n.startsWith("declare interface"))return r+n;let i="";if(e.isExported)i+="export ";if(i+="declare interface ",i+=e.name,e.generics)i+=e.generics;if(e.extends)i+=` extends ${e.extends}`;let s=Bd(e.text);if(s!==-1)i+=` ${e.text.slice(s)}`;else i+=" {}";return r+i}function _d(e,t=!0){let r=vt(e.leadingComments,t);if(e.text.includes("{")&&e.text.includes("}")&&e.text.includes("from"))return r+e.text;let n="";if(e.isExported)n+="export ";if(!e.isExported&&!e.text.includes(" from "))n+="declare ";let i=e.text.indexOf("type ");if(i!==-1){let o=e.text.slice(i),a=o.length;while(a>0&&(o.charCodeAt(a-1)===59||o.charCodeAt(a-1)===32||o.charCodeAt(a-1)===10||o.charCodeAt(a-1)===13))a--;if(a<o.length)o=o.slice(0,a);n+=o}else{if(n+=`type ${e.name}`,e.generics)n+=e.generics;n+=" = any"}let s=n.trimEnd();if(!s.endsWith(";")&&!s.endsWith("}"))n+=";";return r+n}function Vd(e,t=!0){return vt(e.leadingComments,t)+e.text}function Ud(e,t=!0){let r=vt(e.leadingComments,t),n="";if(e.isExported)n+="export ";if(n+="declare ",e.modifiers?.includes("const"))n+="const ";n+="enum ",n+=e.name;let i=e.text.indexOf("{");if(i!==-1)n+=` ${e.text.slice(i)}`;else n+=" {}";return r+n}function Kd(e,t=!0){let r=vt(e.leadingComments,t);if(e.text.startsWith("declare global"))return r+e.text;if(e.source||(e.name.startsWith('"')||e.name.startsWith("'")||e.name.startsWith("`"))){let s="declare module ";s+=e.name;let o=e.text.indexOf("{");if(o!==-1)s+=` ${e.text.slice(o)}`;else s+=" {}";return r+s}let n="";if(e.isExported)n+="export ";if(!e.modifiers?.includes("declare"))n+="declare ";n+="namespace ",n+=e.name;let i=e.text.indexOf("{");if(i!==-1)n+=` ${e.text.slice(i)}`;else n+=" {}";return r+n}function Hd(e){let t=Mt.get(e);if(t)return Mt.delete(e),Mt.set(e,t),t;return null}function Il(e,t){if(Mt.set(e,t),Mt.size>200){let r=0;for(let n of Mt.keys()){if(r++>=20)break;Mt.delete(n)}}}function zd(e){let t=e.indexOf(" from ");if(t===-1)return null;let r=e.slice(t+6).trim(),n=r[0];if(n!=='"'&&n!=="'")return null;let i=r.indexOf(n,1);if(i===-1)return null;let s=r.slice(1,i),o=e.slice(0,t).trim(),a=o.startsWith("import type ");if(o.startsWith("import "))o=o.slice(7).trim();if(o.startsWith("type "))o=o.slice(5).trim();let c=null,f=[],u=!1,l=o.indexOf("{"),g=o.lastIndexOf("}");if(l!==-1&&g!==-1){let d=o.slice(0,l).trim();if(d.endsWith(","))c=d.slice(0,-1).trim()||null;let v=o.slice(l+1,g),b=0;for(let C=0;C<=v.length;C++)if(C===v.length||v.charCodeAt(C)===44){let T=b,k=C;while(T<k&&(v.charCodeAt(T)===32||v.charCodeAt(T)===9||v.charCodeAt(T)===10))T++;while(k>T&&(v.charCodeAt(k-1)===32||v.charCodeAt(k-1)===9||v.charCodeAt(k-1)===10))k--;if(T<k)f.push(v.slice(T,k));b=C+1}}else{let d=o.trim();if(d.startsWith("* as "))c=d.slice(5).trim()||null,u=!0;else c=d||null}return{defaultName:c,namedItems:f,source:s,isTypeOnly:a,isNamespace:u}}function Jd(e){let t=Hd(e);if(t)return t;let r=[],n=e.indexOf(" from ");if(n===-1)return Il(e,r),r;let i=e.slice(0,n).trim();if(i.startsWith("import "))i=i.slice(7).trim();if(i.startsWith("type "))i=i.slice(5).trim();let s=i.indexOf("{"),o=i.lastIndexOf("}");if(s!==-1&&o!==-1){let a=i.slice(0,s).trim();if(a.endsWith(",")){let f=a.slice(0,-1).trim();if(f)r.push(f)}else if(a&&!a.includes(","))r.push(a);let c=i.slice(s+1,o).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)r.push(u)}}else{let a=i.trim();if(a.startsWith("* as ")){let c=a.slice(5).trim();if(c)r.push(c)}else if(a)r.push(a)}return Il(e,r),r}function Xd(e){let t=[],r=0;for(let n=0;n<=e.length;n++)if(n===e.length||e[n]===`
215
- `){let i=r,s=n;while(i<s&&(e[i]===" "||e[i]==="\t"||e[i]==="\r"))i++;while(s>i&&(e[s-1]===" "||e[s-1]==="\t"||e[s-1]==="\r"))s--;let o=e.slice(i,s);if(r=n+1,o.startsWith("///")){if(o.indexOf("<")===-1)continue;if(qd.test(o)||Yd.test(o)||Zd.test(o))t.push(o)}else if(o===""||o.startsWith("//"))continue;else break}return t}function Fl(e,t){throw Error(t||`Unexpected value: ${e}`)}function Qd(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===95||e===36||e>127}function Nl(e){let t=new Set,r=0,n=e.length;while(r<n){let i=e.charCodeAt(r);if(i>=65&&i<=90||i>=97&&i<=122||i===95||i===36||i>127){let s=r;r++;while(r<n&&Qd(e.charCodeAt(r)))r++;t.add(e.substring(s,r))}else r++}return t}function Gl(e,t,r=!0,n=["bun"]){let i="",s=t.sourceCode;if(s){let F=0;while(F<s.length&&(s.charCodeAt(F)===32||s.charCodeAt(F)===9||s.charCodeAt(F)===10||s.charCodeAt(F)===13))F++;if(F<s.length-2&&s.charCodeAt(F)===47&&s.charCodeAt(F+1)===47&&s.charCodeAt(F+2)===47){let U=Xd(s);if(U.length>0)for(let q=0;q<U.length;q++){if(i)i+=`
216
- `;i+=U[q]}}}let o=[],a=[],c=[],f=[],u=[],l=[],g=[],d=[],v=[];for(let F of e){let U=F.kind;switch(U){case"import":o.push(F);break;case"function":a.push(F);break;case"variable":c.push(F);break;case"interface":f.push(F);break;case"type":u.push(F);break;case"class":l.push(F);break;case"enum":g.push(F);break;case"module":d.push(F);break;case"export":v.push(F);break;case"namespace":d.push(F);break;case"unknown":break;default:Fl(U,`Unhandled declaration kind: ${U}`)}}let b=new Set,C=[],T=[],k=[],R=new Set;for(let F of v){let U=vt(F.leadingComments,r);if(F.text.startsWith("export default")){let q=F.text.endsWith(";")?F.text:`${F.text};`;k.push(U+q)}else{let q=F.text.trim();if(!q.endsWith(";"))q+=";";let oe=q.match(em);if(oe){let Z=oe[1],re=0;for(let X=0;X<=Z.length;X++)if(X===Z.length||Z.charCodeAt(X)===44){let Re=re,Oe=X;while(Re<Oe&&Z.charCodeAt(Re)<=32)Re++;while(Oe>Re&&Z.charCodeAt(Oe-1)<=32)Oe--;if(Re<Oe)b.add(Z.slice(Re,Oe));re=X+1}}let H=U+q;if(!R.has(H))if(R.add(H),H.includes("export type"))C.push(H);else T.push(H)}}let I=new Map;if(o.length>0)for(let F of o){let U=Jd(F.text);for(let q of U)I.set(q,F)}let _=new Set;if(f.length>0){let F=[];for(let U of a)if(U.isExported)F.push(U.text);for(let U of l)F.push(U.text);for(let U of u)F.push(U.text);if(F.length>0){let U=Nl(F.join(`
217
- `));for(let q of f)if(U.has(q.name))_.add(q.name)}}let L=[];if(o.length>0){let F=new Set,U=[];for(let H of a)if(H.isExported)U.push(H.text);for(let H of c)if(U.push(H.text),H.typeAnnotation)U.push(H.typeAnnotation);else if(H.isExported&&H.value)U.push(Dl(H,!1));for(let H of f)if(H.isExported||_.has(H.name))U.push(H.text);for(let H of u)U.push(H.text);for(let H of l)U.push(H.text);for(let H of g)U.push(H.text);for(let H of d)U.push(H.text);for(let H of v)U.push(H.text);let q=U.join(`
218
- `);if(q&&I.size>0){let H=Nl(q);for(let Z of I.keys())if(H.has(Z))F.add(Z)}for(let H of b)if(I.has(H))F.add(H);for(let H of o){if(H.isSideEffect){let ae=H.text.trim(),Q=ae.endsWith(";")?ae:`${ae};`;L.push(Q);continue}let Z=zd(H.text);if(!Z)continue;let{defaultName:re,namedItems:X,source:Re,isTypeOnly:Oe,isNamespace:Dt}=Z,ke=re?F.has(re):!1,Me="",ft=0;for(let ae=0;ae<X.length;ae++){let Q=X[ae],It=Q.charCodeAt(0)===116&&Q.startsWith("type ")?Q.slice(5).trim():Q.trim(),nr=It.indexOf(" as ");if(nr!==-1)It=It.slice(nr+4).trim();if(F.has(It)){if(ft>0)Me+=", ";Me+=Q,ft++}}if(ke||ft>0){let ae=Oe?"import type ":"import ";if(ke&&re)if(Dt)ae+=`* as ${re}`;else ae+=ft>0?`${re}, { ${Me} }`:re;else if(ft>0)ae+=`{ ${Me} }`;ae+=` from '${Re}';`,L.push(ae)}}let oe=n.length;if(L.length>1){if(Ll!==n)Ll=n,Wl=n.map((X)=>`from '${X}`),Bl=n.map((X)=>`from "${X}`);let H=Wl,Z=Bl,re=new Map;for(let X of L){let Re=oe;for(let Oe=0;Oe<n.length;Oe++)if(X.includes(H[Oe])||X.includes(Z[Oe])){Re=Oe;break}re.set(X,Re)}L.sort((X,Re)=>{let Oe=re.get(X),Dt=re.get(Re);return Oe!==Dt?Oe-Dt:X.localeCompare(Re)})}}for(let F=0;F<L.length;F++){if(i)i+=`
219
- `;i+=L[F]}for(let F=0;F<C.length;F++){if(i)i+=`
220
- `;i+=C[F]}let P=[a,c,f,u,l,g,d];for(let F=0;F<P.length;F++){let U=P[F];for(let q=0;q<U.length;q++){let oe=U[q],H="",Z=oe.kind;switch(Z){case"function":H=Gd(oe,r);break;case"variable":H=Dl(oe,r);break;case"interface":H=jd(oe,r);break;case"type":H=_d(oe,r);break;case"class":H=Vd(oe,r);break;case"enum":H=Ud(oe,r);break;case"module":case"namespace":H=Kd(oe,r);break;case"import":case"export":case"unknown":break;default:Fl(Z,`Unhandled declaration kind in processor: ${Z}`)}if(H){if(i)i+=`
221
- `;i+=H}}}for(let F=0;F<T.length;F++){if(i)i+=`
215
+ ${n}`}if(a)return`${Gd(a)}${n}`;return r+n}function Vd(e,t=!0){let r=Et(e.leadingComments,t),n=e.text;if(n.startsWith("export declare interface")||n.startsWith("declare interface"))return r+n;let i="";if(e.isExported)i+="export ";if(i+="declare interface ",i+=e.name,e.generics)i+=e.generics;if(e.extends)i+=` extends ${e.extends}`;let s=jd(e.text);if(s!==-1)i+=` ${e.text.slice(s)}`;else i+=" {}";return r+i}function Ud(e,t=!0){let r=Et(e.leadingComments,t);if(e.text.includes("{")&&e.text.includes("}")&&e.text.includes("from"))return r+e.text;let n="";if(e.isExported)n+="export ";if(!e.isExported&&!e.text.includes(" from "))n+="declare ";let i=e.text.indexOf("type ");if(i!==-1){let o=e.text.slice(i),a=o.length;while(a>0&&(o.charCodeAt(a-1)===59||o.charCodeAt(a-1)===32||o.charCodeAt(a-1)===10||o.charCodeAt(a-1)===13))a--;if(a<o.length)o=o.slice(0,a);n+=o}else{if(n+=`type ${e.name}`,e.generics)n+=e.generics;n+=" = any"}let s=n.trimEnd();if(!s.endsWith(";")&&!s.endsWith("}"))n+=";";return r+n}function Kd(e,t=!0){return Et(e.leadingComments,t)+e.text}function zd(e,t=!0){let r=Et(e.leadingComments,t),n="";if(e.isExported)n+="export ";if(n+="declare ",e.modifiers?.includes("const"))n+="const ";n+="enum ",n+=e.name;let i=e.text.indexOf("{");if(i!==-1)n+=` ${e.text.slice(i)}`;else n+=" {}";return r+n}function Hd(e,t=!0){let r=Et(e.leadingComments,t);if(e.text.startsWith("declare global"))return r+e.text;if(e.source||(e.name.startsWith('"')||e.name.startsWith("'")||e.name.startsWith("`"))){let s="declare module ";s+=e.name;let o=e.text.indexOf("{");if(o!==-1)s+=` ${e.text.slice(o)}`;else s+=" {}";return r+s}let n="";if(e.isExported)n+="export ";if(!e.modifiers?.includes("declare"))n+="declare ";n+="namespace ",n+=e.name;let i=e.text.indexOf("{");if(i!==-1)n+=` ${e.text.slice(i)}`;else n+=" {}";return r+n}function Jd(e){let t=Dt.get(e);if(t)return Dt.delete(e),Dt.set(e,t),t;return null}function Nl(e,t){if(Dt.set(e,t),Dt.size>200){let r=0;for(let n of Dt.keys()){if(r++>=20)break;Dt.delete(n)}}}function qd(e){let t=e.indexOf(" from ");if(t===-1)return null;let r=e.slice(t+6).trim(),n=r[0];if(n!=='"'&&n!=="'")return null;let i=r.indexOf(n,1);if(i===-1)return null;let s=r.slice(1,i),o=e.slice(0,t).trim(),a=o.startsWith("import type ");if(o.startsWith("import "))o=o.slice(7).trim();if(o.startsWith("type "))o=o.slice(5).trim();let c=null,f=[],u=!1,l=o.indexOf("{"),g=o.lastIndexOf("}");if(l!==-1&&g!==-1){let p=o.slice(0,l).trim();if(p.endsWith(","))c=p.slice(0,-1).trim()||null;let v=o.slice(l+1,g),b=0;for(let w=0;w<=v.length;w++)if(w===v.length||v.charCodeAt(w)===44){let T=b,k=w;while(T<k&&(v.charCodeAt(T)===32||v.charCodeAt(T)===9||v.charCodeAt(T)===10))T++;while(k>T&&(v.charCodeAt(k-1)===32||v.charCodeAt(k-1)===9||v.charCodeAt(k-1)===10))k--;if(T<k)f.push(v.slice(T,k));b=w+1}}else{let p=o.trim();if(p.startsWith("* as "))c=p.slice(5).trim()||null,u=!0;else c=p||null}return{defaultName:c,namedItems:f,source:s,isTypeOnly:a,isNamespace:u}}function Yd(e){let t=Jd(e);if(t)return t;let r=[],n=e.indexOf(" from ");if(n===-1)return Nl(e,r),r;let i=e.slice(0,n).trim();if(i.startsWith("import "))i=i.slice(7).trim();if(i.startsWith("type "))i=i.slice(5).trim();let s=i.indexOf("{"),o=i.lastIndexOf("}");if(s!==-1&&o!==-1){let a=i.slice(0,s).trim();if(a.endsWith(",")){let f=a.slice(0,-1).trim();if(f)r.push(f)}else if(a&&!a.includes(","))r.push(a);let c=i.slice(s+1,o).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)r.push(u)}}else{let a=i.trim();if(a.startsWith("* as ")){let c=a.slice(5).trim();if(c)r.push(c)}else if(a)r.push(a)}return Nl(e,r),r}function em(e){let t=[],r=0;for(let n=0;n<=e.length;n++)if(n===e.length||e[n]===`
216
+ `){let i=r,s=n;while(i<s&&(e[i]===" "||e[i]==="\t"||e[i]==="\r"))i++;while(s>i&&(e[s-1]===" "||e[s-1]==="\t"||e[s-1]==="\r"))s--;let o=e.slice(i,s);if(r=n+1,o.startsWith("///")){if(o.indexOf("<")===-1)continue;if(Zd.test(o)||Xd.test(o)||Qd.test(o))t.push(o)}else if(o===""||o.startsWith("//"))continue;else break}return t}function Ll(e,t){throw Error(t||`Unexpected value: ${e}`)}function tm(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===95||e===36||e>127}function Wl(e){let t=new Set,r=0,n=e.length;while(r<n){let i=e.charCodeAt(r);if(i>=65&&i<=90||i>=97&&i<=122||i===95||i===36||i>127){let s=r;r++;while(r<n&&tm(e.charCodeAt(r)))r++;t.add(e.substring(s,r))}else r++}return t}function _l(e,t,r=!0,n=["bun"]){let i="",s=t.sourceCode;if(s){let F=0;while(F<s.length&&(s.charCodeAt(F)===32||s.charCodeAt(F)===9||s.charCodeAt(F)===10||s.charCodeAt(F)===13))F++;if(F<s.length-2&&s.charCodeAt(F)===47&&s.charCodeAt(F+1)===47&&s.charCodeAt(F+2)===47){let U=em(s);if(U.length>0)for(let q=0;q<U.length;q++){if(i)i+=`
217
+ `;i+=U[q]}}}let o=[],a=[],c=[],f=[],u=[],l=[],g=[],p=[],v=[];for(let F of e){let U=F.kind;switch(U){case"import":o.push(F);break;case"function":a.push(F);break;case"variable":c.push(F);break;case"interface":f.push(F);break;case"type":u.push(F);break;case"class":l.push(F);break;case"enum":g.push(F);break;case"module":p.push(F);break;case"export":v.push(F);break;case"namespace":p.push(F);break;case"unknown":break;default:Ll(U,`Unhandled declaration kind: ${U}`)}}let b=new Set,w=[],T=[],k=[],R=new Set;for(let F of v){let U=Et(F.leadingComments,r);if(F.text.startsWith("export default")){let q=F.text.endsWith(";")?F.text:`${F.text};`;k.push(U+q)}else{let q=F.text.trim();if(!q.endsWith(";"))q+=";";let le=q.match(rm);if(le){let Z=le[1],ie=0;for(let X=0;X<=Z.length;X++)if(X===Z.length||Z.charCodeAt(X)===44){let Pe=ie,Re=X;while(Pe<Re&&Z.charCodeAt(Pe)<=32)Pe++;while(Re>Pe&&Z.charCodeAt(Re-1)<=32)Re--;if(Pe<Re)b.add(Z.slice(Pe,Re));ie=X+1}}let z=U+q;if(!R.has(z))if(R.add(z),z.includes("export type"))w.push(z);else T.push(z)}}let I=new Map;if(o.length>0)for(let F of o){let U=Yd(F.text);for(let q of U)I.set(q,F)}let _=new Set;if(f.length>0){let F=[];for(let U of a)if(U.isExported)F.push(U.text);for(let U of l)F.push(U.text);for(let U of u)F.push(U.text);if(F.length>0){let U=Wl(F.join(`
218
+ `));for(let q of f)if(U.has(q.name))_.add(q.name)}}let W=[];if(o.length>0){let F=new Set,U=[];for(let z of a)if(z.isExported)U.push(z.text);for(let z of c)if(U.push(z.text),z.typeAnnotation)U.push(z.typeAnnotation);else if(z.isExported&&z.value)U.push(Fl(z,!1));for(let z of f)if(z.isExported||_.has(z.name))U.push(z.text);for(let z of u)U.push(z.text);for(let z of l)U.push(z.text);for(let z of g)U.push(z.text);for(let z of p)U.push(z.text);for(let z of v)U.push(z.text);let q=U.join(`
219
+ `);if(q&&I.size>0){let z=Wl(q);for(let Z of I.keys())if(z.has(Z))F.add(Z)}for(let z of b)if(I.has(z))F.add(z);for(let z of o){if(z.isSideEffect){let ce=z.text.trim(),ee=ce.endsWith(";")?ce:`${ce};`;W.push(ee);continue}let Z=qd(z.text);if(!Z)continue;let{defaultName:ie,namedItems:X,source:Pe,isTypeOnly:Re,isNamespace:It}=Z,Oe=ie?F.has(ie):!1,ke="",ut=0;for(let ce=0;ce<X.length;ce++){let ee=X[ce],Ft=ee.charCodeAt(0)===116&&ee.startsWith("type ")?ee.slice(5).trim():ee.trim(),sr=Ft.indexOf(" as ");if(sr!==-1)Ft=Ft.slice(sr+4).trim();if(F.has(Ft)){if(ut>0)ke+=", ";ke+=ee,ut++}}if(Oe||ut>0){let ce=Re?"import type ":"import ";if(Oe&&ie)if(It)ce+=`* as ${ie}`;else ce+=ut>0?`${ie}, { ${ke} }`:ie;else if(ut>0)ce+=`{ ${ke} }`;ce+=` from '${Pe}';`,W.push(ce)}}let le=n.length;if(W.length>1){if(Bl!==n)Bl=n,Gl=n.map((X)=>`from '${X}`),jl=n.map((X)=>`from "${X}`);let z=Gl,Z=jl,ie=new Map;for(let X of W){let Pe=le;for(let Re=0;Re<n.length;Re++)if(X.includes(z[Re])||X.includes(Z[Re])){Pe=Re;break}ie.set(X,Pe)}W.sort((X,Pe)=>{let Re=ie.get(X),It=ie.get(Pe);return Re!==It?Re-It:X.localeCompare(Pe)})}}for(let F=0;F<W.length;F++){if(i)i+=`
220
+ `;i+=W[F]}for(let F=0;F<w.length;F++){if(i)i+=`
221
+ `;i+=w[F]}let P=[a,c,f,u,l,g,p];for(let F=0;F<P.length;F++){let U=P[F];for(let q=0;q<U.length;q++){let le=U[q],z="",Z=le.kind;switch(Z){case"function":z=_d(le,r);break;case"variable":z=Fl(le,r);break;case"interface":z=Vd(le,r);break;case"type":z=Ud(le,r);break;case"class":z=Kd(le,r);break;case"enum":z=zd(le,r);break;case"module":case"namespace":z=Hd(le,r);break;case"import":case"export":case"unknown":break;default:Ll(Z,`Unhandled declaration kind in processor: ${Z}`)}if(z){if(i)i+=`
222
+ `;i+=z}}}for(let F=0;F<T.length;F++){if(i)i+=`
222
223
  `;i+=T[F]}for(let F=0;F<k.length;F++){if(i)i+=`
223
- `;i+=k[F]}if(!i&&(o.length>0||v.length>0))return"export {};";return i}var Mt,qd,Yd,Zd,em,Ll=null,Wl,Bl;var jl=ce(()=>{Ml();dn();Mt=new Map;qd=/^\/\/\/\s*<reference\s+(?:path|types|lib|no-default-lib)\s*=\s*["'][^"']+["']\s*\/>/,Yd=/^\/\/\/\s*<amd-module\s+name\s*=\s*["'][^"']+["']\s*\/>/,Zd=/^\/\/\/\s*<amd-dependency\s+path\s*=\s*["'][^"']+["']/;em=/export\s+(?:type\s+)?\{\s*([^}]+)\s*\}/,Wl=[],Bl=[]});import{existsSync as _l}from"fs";import{mkdir as hs,readdir as tm,realpath as rm,rm as im}from"fs/promises";import{availableParallelism as nm}from"os";import{basename as Hl,dirname as Ar,extname as sm,isAbsolute as $r,parse as om,relative as Le,resolve as ze}from"path";async function Vl(e,t,r,n,i){let s=Hl(e)||"output.d.ts",o=Le(Ar(e),t),a=`${s}.map`,c=r.lastIndexOf(`
224
- ${us()}`),f=c===-1?r:r.slice(0,c),u=Rl(f,s,o,n),l=`${e}.map`;return await br(l,JSON.stringify(u)),K.debug(` Generated source map: ${Le(i,l)}`),a}async function ps(e){let t=Date.now(),r={...qa,...e};if(r.logLevel)wn(r.logLevel);else if(r.verbose)wn("debug");let n=new Ni;if(r.plugins&&r.plugins.length>0){for(let C of r.plugins)n.register(C),K.debug(`Registered plugin: ${C.name}`);r=await n.runOnStart(r)}if(await lm(r),r.isolatedDeclarations===void 0)r.isolatedDeclarations=await xl(r);let i=r.typeMappings?Li(r.typeMappings):void 0,s=null;if(r.incremental){if(s=new Cn(r),r.clearCache){if(K.debug("Clearing build cache..."),!r.dryRun)s.clear()}else if(s.load()){let C=s.getStats();K.debug(`Loaded build cache with ${C.entries} entries`)}else K.debug("No existing build cache found, starting fresh");if(!r.dryRun)wo(r.cwd)}let o={generationMode:r.isolatedDeclarations?"isolated":"semantic",filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},a=0;if(K.debug("Starting DTS generation..."),K.debug(`Using ${o.generationMode} declaration generation path`),K.debug("Config:",r),r.clean&&!r.dryRun)await fm(r);let c=await dm(r);hm(r,c);let f=c.slice(),u=null;if(r.autoIncludeReExports!==!1&&f.length>0){u=await cs(f,{includeImports:!0});let C=ze(r.cwd,r.root),T=r.exclude||[],k=[];for(let R of u.reachable){if(f.includes(R))continue;if(!ms(R))continue;if(R.endsWith(".d.ts"))continue;if(R.includes("node_modules"))continue;if(!xr(R,C)){K.warn(`Skipping auto-included source outside root: ${Le(r.cwd,R)}`);continue}if(ds(R,T,C))continue;k.push(R)}if(k.length>0)f=[...f,...k],K.debug(`Auto-included ${k.length} file(s) reached via relative re-exports`)}if(mm(f,r),s&&!r.dryRun){let C=s.prune(new Set(f),r.cwd);if(C>0)K.debug(`Pruned ${C} deleted files from cache`)}if(K.debug(`Found ${f.length} TypeScript files`),r.progress&&f.length>0){let C=r.parallel?"parallel":"sequential";K.info(`Processing ${f.length} files (${C})...`)}let l=async(C,T)=>{let k;try{let R=Tr(C,r),I=async(Z)=>{if(!r.diff)return;try{let re=await ht(R),X=Pl(re,Z,Le(r.cwd,R));if(X)K.info(`
225
- ${X}`);else K.debug(`[no changes] ${R}`)}catch{K.info(`[new file] ${Le(r.cwd,R)}`)}},_=(Z)=>{if(!r.validate)return 0;let re=Tl(Z,R);if(re.isValid)return K.debug(`[validation] ${R} - OK`),0;K.warn(`[validation] ${Le(r.cwd,R)} has ${re.errors.length} error(s):`);for(let X of re.errors){let Re=` Line ${X.line}:${X.column}`;if(X.code)Re+=` [${X.code}]`;if(Re+=` - ${X.message}`,K.warn(Re),X.suggestion)K.warn(` Suggestion: ${X.suggestion}`)}return re.errors.length},L=(Z)=>{K.info(`[dry-run] Would generate: ${R}`),K.debug("--- Content preview ---"),K.debug(Z.slice(0,500)+(Z.length>500?`
226
- ...`:"")),K.debug("--- End preview ---")};if(s){let Z=s.getCachedIfValid(C,r.cwd);if(Z){await I(Z);let re=_(Z);if(r.dryRun)L(Z);else{if(await hs(Ar(R),{recursive:!0}),r.declarationMap)k=T??await ht(C),await Vl(R,C,Z,k,r.cwd);await br(R,Z,r.lineEnding)}return K.debug(`[cached] ${Le(r.cwd,R)}`),{success:!0,file:C,declarationCount:0,importCount:0,exportCount:0,cached:!0,validationErrorCount:re}}}k=T??await ht(C);let{content:P,declarationCount:F,importCount:U,exportCount:q}=await ym(C,k,r,n,i),oe=P;if(r.prettier||r.indentStyle||r.indentSize){let Z=await el(oe,{usePrettier:r.prettier,builtIn:{indentSize:r.indentSize||2,useTabs:r.indentStyle==="tabs",normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}},R);oe=Z.content;for(let re of Z.warnings??[])K.warn(`[format] ${re}`)}if(r.declarationMap){let Z=`${Hl(R)||"output.d.ts"}.map`;oe=Ol(oe,Z)}await I(oe);let H=_(oe);if(r.dryRun)L(oe);else{if(await hs(Ar(R),{recursive:!0}),r.declarationMap&&k)await Vl(R,C,oe,k,r.cwd);if(await br(R,oe,r.lineEnding),s&&k)s.update(C,k,oe,r.cwd);K.debug(`Generated: ${R}`)}return{success:!0,file:C,declarationCount:F,importCount:U,exportCount:q,validationErrorCount:H}}catch(R){let I=Za(R,C,k);if(r.plugins&&r.plugins.length>0)await n.runOnError(R instanceof Error?R:Error(String(R)),C,k||"");return{success:!1,file:C,declarationCount:0,importCount:0,exportCount:0,dtsError:I,validationErrorCount:0}}},g=r.parallel||r.parallel!==!1&&f.length>=10,d=Rs(r.concurrency,nm?.()??8),v=new Map;if(g&&f.length>1){let C=f.map(async(T)=>{try{let k=await ht(T);return{file:T,source:k}}catch{return{file:T,source:null}}});for(let T of await Promise.all(C))if(T.source!==null)v.set(T.file,T.source)}let b=(C)=>{if(o.filesProcessed++,C.success){if(C.cached)a++;else o.filesGenerated++,o.declarationsFound+=C.declarationCount,o.importsProcessed+=C.importCount,o.exportsProcessed+=C.exportCount;if(r.validate){if(o.filesValidated++,C.validationErrorCount)o.validationErrors+=C.validationErrorCount}}else if(o.filesFailed++,C.dtsError){o.errors.push(C.dtsError);let T=Xa(C.dtsError);if(r.continueOnError)K.warn(T);else throw K.error(T),Error(C.dtsError.message)}};if(g)for(let C=0;C<f.length;C+=d){let T=f.slice(C,C+d),k=await Promise.all(T.map((R)=>l(R,v.get(R))));for(let R of k)b(R);if(r.progress){let R=Math.round(o.filesProcessed/f.length*100);K.info(`[${o.filesProcessed}/${f.length}] ${R}%`)}}else for(let C of f){let T=await l(C);if(b(T),r.progress){let k=Math.round(o.filesProcessed/f.length*100),R=T.cached?"[cached]":"";K.info(`[${o.filesProcessed}/${f.length}] ${k}% - ${Le(r.cwd,C)} ${R}`)}}if(s&&!r.dryRun)s.save(),K.debug("Saved build cache");if(!r.bundle){let C=[];if(u)for(let T of u.unresolved)C.push({from:T.from,specifier:T.specifier,reason:"missing"});if(r.autoIncludeReExports===!1&&f.length>0){let T=new Set(f);for(let k of f){let R;try{R=await ht(k)}catch{continue}for(let I of ls(R)){if(!I.specifier.startsWith("."))continue;let _=Fi(I.specifier,k);if(!_.resolved)C.push({from:k,specifier:I.specifier,reason:"missing"});else if(!/\.d\.(?:ts|mts|cts)$/.test(_.resolved)&&!T.has(_.resolved))C.push({from:k,specifier:I.specifier,reason:"not-emitted"})}}}if(C.length>0){let T=[];T.push(`Found ${C.length} re-export(s) pointing at siblings that won't be in the output:`);for(let R of C){let I=Le(r.cwd,R.from);if(R.reason==="missing")T.push(` ${I} \u2192 '${R.specifier}' (path not found on disk)`);else T.push(` ${I} \u2192 '${R.specifier}' (resolved but not in entrypoints; set autoIncludeReExports: true or add to entrypoints)`)}let k=T.join(`
227
- `);if(r.failOnUnresolvedReExport)throw Error(k);K.warn(k),K.warn('Generated .d.ts files reference modules that were not emitted \u2014 consumers will see "has no exported member" errors.')}}if(r.bundle&&(o.filesGenerated>0||a>0)&&c.length>0)try{K.debug("Bundling declarations...");let C=new Map,T=async(R)=>{let I=C.get(R);if(I!==void 0)return I;return I=await ht(R),C.set(R,I),I};for(let R of f)await T(R);let k=c.length===1&&!!r.bundleOutput;for(let R of c){let I=await cs([R],{includeImports:!0}),_=new Set;for(let q of I.reachable){if(q.endsWith(".d.ts"))continue;if(q.includes("node_modules"))continue;_.add(q)}let L=f.filter((q)=>_.has(q));if(!L.includes(R))L.push(R);let P=new Map;for(let q of L){let oe=C.get(q)??await T(q);P.set(q,oe)}let F=await uo(L,P,r),U=k?ze(r.cwd,r.outdir,r.bundleOutput):Tr(R,r);if(r.dryRun)K.info(`[dry-run] Would bundle ${F.files.length} files to: ${Le(r.cwd,U)}`);else await hs(Ar(U),{recursive:!0}),await br(U,F.content,r.lineEnding),K.info(`Bundled ${F.files.length} files to: ${Le(r.cwd,U)}`);if(k)break}}catch(C){let T=C instanceof Error?C.message:String(C);K.error(`Bundle failed: ${T}`)}if(o.durationMs=Date.now()-t,r.stats)if(r.outputFormat==="json")console.log(JSON.stringify(o,null,2));else{if(K.info(`
224
+ `;i+=k[F]}if(!i&&(o.length>0||v.length>0))return"export {};";return i}var Dt,Zd,Xd,Qd,rm,Bl=null,Gl,jl;var Vl=fe(()=>{Il();pn();Dt=new Map;Zd=/^\/\/\/\s*<reference\s+(?:path|types|lib|no-default-lib)\s*=\s*["'][^"']+["']\s*\/>/,Xd=/^\/\/\/\s*<amd-module\s+name\s*=\s*["'][^"']+["']\s*\/>/,Qd=/^\/\/\/\s*<amd-dependency\s+path\s*=\s*["'][^"']+["']/;rm=/export\s+(?:type\s+)?\{\s*([^}]+)\s*\}/,Gl=[],jl=[]});import{existsSync as Ul}from"fs";import{mkdir as ms,readdir as im,realpath as nm,rm as sm}from"fs/promises";import{availableParallelism as om}from"os";import{basename as Jl,dirname as Ar,extname as am,isAbsolute as xr,parse as lm,relative as Ne,resolve as Je}from"path";async function Kl(e,t,r,n,i){let s=Jl(e)||"output.d.ts",o=Ne(Ar(e),t),a=`${s}.map`,c=r.lastIndexOf(`
225
+ ${ds()}`),f=c===-1?r:r.slice(0,c),u=kl(f,s,o,n),l=`${e}.map`;return await Sr(l,JSON.stringify(u)),K.debug(` Generated source map: ${Ne(i,l)}`),a}async function ys(e){let t=Date.now(),r={...Za,...e};if(r.logLevel)En(r.logLevel);else if(r.verbose)En("debug");let n=new Wi;if(r.plugins&&r.plugins.length>0){for(let w of r.plugins)n.register(w),K.debug(`Registered plugin: ${w.name}`);r=await n.runOnStart(r)}if(await fm(r),r.isolatedDeclarations===void 0)r.isolatedDeclarations=await Pl(r);let i=r.typeMappings?Bi(r.typeMappings):void 0,s=null;if(r.incremental){if(s=new vn(r),r.clearCache){if(K.debug("Clearing build cache..."),!r.dryRun)s.clear()}else if(s.load()){let w=s.getStats();K.debug(`Loaded build cache with ${w.entries} entries`)}else K.debug("No existing build cache found, starting fresh");if(!r.dryRun)Eo(r.cwd)}let o={generationMode:r.isolatedDeclarations?"isolated":"semantic",filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},a=0;if(K.debug("Starting DTS generation..."),K.debug(`Using ${o.generationMode} declaration generation path`),K.debug("Config:",r),r.clean&&!r.dryRun)await hm(r);let c=await pm(r);mm(r,c);let f=c.slice(),u=null;if(r.autoIncludeReExports!==!1&&f.length>0){u=await us(f,{includeImports:!0});let w=Je(r.cwd,r.root),T=r.exclude||[],k=[];for(let R of u.reachable){if(f.includes(R))continue;if(!gs(R))continue;if(R.endsWith(".d.ts"))continue;if(R.includes("node_modules"))continue;if(!Tr(R,w)){K.warn(`Skipping auto-included source outside root: ${Ne(r.cwd,R)}`);continue}if(ps(R,T,w))continue;k.push(R)}if(k.length>0)f=[...f,...k],K.debug(`Auto-included ${k.length} file(s) reached via relative re-exports`)}if(gm(f,r),s&&!r.dryRun){let w=s.prune(new Set(f),r.cwd);if(w>0)K.debug(`Pruned ${w} deleted files from cache`)}if(K.debug(`Found ${f.length} TypeScript files`),r.progress&&f.length>0){let w=r.parallel?"parallel":"sequential";K.info(`Processing ${f.length} files (${w})...`)}let l=async(w,T)=>{let k;try{let R=Pr(w,r),I=async(Z)=>{if(!r.diff)return;try{let ie=await dt(R),X=Ol(ie,Z,Ne(r.cwd,R));if(X)K.info(`
226
+ ${X}`);else K.debug(`[no changes] ${R}`)}catch{K.info(`[new file] ${Ne(r.cwd,R)}`)}},_=(Z)=>{if(!r.validate)return 0;let ie=Rl(Z,R);if(ie.isValid)return K.debug(`[validation] ${R} - OK`),0;K.warn(`[validation] ${Ne(r.cwd,R)} has ${ie.errors.length} error(s):`);for(let X of ie.errors){let Pe=` Line ${X.line}:${X.column}`;if(X.code)Pe+=` [${X.code}]`;if(Pe+=` - ${X.message}`,K.warn(Pe),X.suggestion)K.warn(` Suggestion: ${X.suggestion}`)}return ie.errors.length},W=(Z)=>{K.info(`[dry-run] Would generate: ${R}`),K.debug("--- Content preview ---"),K.debug(Z.slice(0,500)+(Z.length>500?`
227
+ ...`:"")),K.debug("--- End preview ---")};if(s){let Z=s.getCachedIfValid(w,r.cwd);if(Z){await I(Z);let ie=_(Z);if(r.dryRun)W(Z);else{if(await ms(Ar(R),{recursive:!0}),r.declarationMap)k=T??await dt(w),await Kl(R,w,Z,k,r.cwd);await Sr(R,Z,r.lineEnding)}return K.debug(`[cached] ${Ne(r.cwd,R)}`),{success:!0,file:w,declarationCount:0,importCount:0,exportCount:0,cached:!0,validationErrorCount:ie}}}k=T??await dt(w);let{content:P,declarationCount:F,importCount:U,exportCount:q}=await wm(w,k,r,n,i),le=P;if(r.prettier||r.indentStyle||r.indentSize){let Z=await rl(le,{usePrettier:r.prettier,builtIn:{indentSize:r.indentSize||2,useTabs:r.indentStyle==="tabs",normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}},R);le=Z.content;for(let ie of Z.warnings??[])K.warn(`[format] ${ie}`)}if(r.declarationMap){let Z=`${Jl(R)||"output.d.ts"}.map`;le=Ml(le,Z)}await I(le);let z=_(le);if(r.dryRun)W(le);else{if(await ms(Ar(R),{recursive:!0}),r.declarationMap&&k)await Kl(R,w,le,k,r.cwd);if(await Sr(R,le,r.lineEnding),s&&k)s.update(w,k,le,r.cwd);K.debug(`Generated: ${R}`)}return{success:!0,file:w,declarationCount:F,importCount:U,exportCount:q,validationErrorCount:z}}catch(R){let I=Qa(R,w,k);if(r.plugins&&r.plugins.length>0)await n.runOnError(R instanceof Error?R:Error(String(R)),w,k||"");return{success:!1,file:w,declarationCount:0,importCount:0,exportCount:0,dtsError:I,validationErrorCount:0}}},g=r.parallel||r.parallel!==!1&&f.length>=10,p=ks(r.concurrency,om?.()??8),v=new Map;if(g&&f.length>1){let w=f.map(async(T)=>{try{let k=await dt(T);return{file:T,source:k}}catch{return{file:T,source:null}}});for(let T of await Promise.all(w))if(T.source!==null)v.set(T.file,T.source)}let b=(w)=>{if(o.filesProcessed++,w.success){if(w.cached)a++;else o.filesGenerated++,o.declarationsFound+=w.declarationCount,o.importsProcessed+=w.importCount,o.exportsProcessed+=w.exportCount;if(r.validate){if(o.filesValidated++,w.validationErrorCount)o.validationErrors+=w.validationErrorCount}}else if(o.filesFailed++,w.dtsError){o.errors.push(w.dtsError);let T=el(w.dtsError);if(r.continueOnError)K.warn(T);else throw K.error(T),Error(w.dtsError.message)}};if(g)for(let w=0;w<f.length;w+=p){let T=f.slice(w,w+p),k=await Promise.all(T.map((R)=>l(R,v.get(R))));for(let R of k)b(R);if(r.progress){let R=Math.round(o.filesProcessed/f.length*100);K.info(`[${o.filesProcessed}/${f.length}] ${R}%`)}}else for(let w of f){let T=await l(w);if(b(T),r.progress){let k=Math.round(o.filesProcessed/f.length*100),R=T.cached?"[cached]":"";K.info(`[${o.filesProcessed}/${f.length}] ${k}% - ${Ne(r.cwd,w)} ${R}`)}}if(s&&!r.dryRun)s.save(),K.debug("Saved build cache");if(!r.bundle){let w=[];if(u)for(let T of u.unresolved)w.push({from:T.from,specifier:T.specifier,reason:"missing"});if(r.autoIncludeReExports===!1&&f.length>0){let T=new Set(f);for(let k of f){let R;try{R=await dt(k)}catch{continue}for(let I of fs(R)){if(!I.specifier.startsWith("."))continue;let _=Li(I.specifier,k);if(!_.resolved)w.push({from:k,specifier:I.specifier,reason:"missing"});else if(!/\.d\.(?:ts|mts|cts)$/.test(_.resolved)&&!T.has(_.resolved))w.push({from:k,specifier:I.specifier,reason:"not-emitted"})}}}if(w.length>0){let T=[];T.push(`Found ${w.length} re-export(s) pointing at siblings that won't be in the output:`);for(let R of w){let I=Ne(r.cwd,R.from);if(R.reason==="missing")T.push(` ${I} \u2192 '${R.specifier}' (path not found on disk)`);else T.push(` ${I} \u2192 '${R.specifier}' (resolved but not in entrypoints; set autoIncludeReExports: true or add to entrypoints)`)}let k=T.join(`
228
+ `);if(r.failOnUnresolvedReExport)throw Error(k);K.warn(k),K.warn('Generated .d.ts files reference modules that were not emitted \u2014 consumers will see "has no exported member" errors.')}}if(r.bundle&&(o.filesGenerated>0||a>0)&&c.length>0)try{K.debug("Bundling declarations...");let w=new Map,T=async(R)=>{let I=w.get(R);if(I!==void 0)return I;return I=await dt(R),w.set(R,I),I};for(let R of f)await T(R);let k=c.length===1&&!!r.bundleOutput;for(let R of c){let I=await us([R],{includeImports:!0}),_=new Set;for(let q of I.reachable){if(q.endsWith(".d.ts"))continue;if(q.includes("node_modules"))continue;_.add(q)}let W=f.filter((q)=>_.has(q));if(!W.includes(R))W.push(R);let P=new Map;for(let q of W){let le=w.get(q)??await T(q);P.set(q,le)}let F=await mo(W,P,r),U=k?Je(r.cwd,r.outdir,r.bundleOutput):Pr(R,r);if(r.dryRun)K.info(`[dry-run] Would bundle ${F.files.length} files to: ${Ne(r.cwd,U)}`);else await ms(Ar(U),{recursive:!0}),await Sr(U,F.content,r.lineEnding),K.info(`Bundled ${F.files.length} files to: ${Ne(r.cwd,U)}`);if(k)break}}catch(w){let T=w instanceof Error?w.message:String(w);K.error(`Bundle failed: ${T}`)}if(o.durationMs=Date.now()-t,r.stats)if(r.outputFormat==="json")console.log(JSON.stringify(o,null,2));else{if(K.info(`
228
229
  --- Generation Statistics ---`),K.info(`Files processed: ${o.filesProcessed}`),K.info(`Files generated: ${o.filesGenerated}`),a>0)K.info(`Files cached: ${a}`);if(o.filesFailed>0)K.info(`Files failed: ${o.filesFailed}`);if(K.info(`Declarations found: ${o.declarationsFound}`),K.info(`Imports processed: ${o.importsProcessed}`),K.info(`Exports processed: ${o.exportsProcessed}`),o.filesValidated>0){if(K.info(`Files validated: ${o.filesValidated}`),o.validationErrors>0)K.info(`Validation errors: ${o.validationErrors}`)}if(K.info(`Duration: ${o.durationMs}ms`),o.errors.length>0){K.info(`
229
- Errors:`);for(let C of o.errors){let T=` - ${C.file}`;if(C.location)T+=`:${C.location.line}:${C.location.column}`;if(C.code)T+=` [${C.code}]`;if(T+=`: ${C.message}`,K.info(T),C.suggestion)K.info(` Suggestion: ${C.suggestion}`)}}K.info(`-----------------------------
230
- `)}if(r.plugins&&r.plugins.length>0)await n.runOnEnd(o);return K.debug("DTS generation complete!"),o}async function Ul(e){try{return await rm(e)}catch{return ze(e)}}async function lm(e){let t=ze(e.cwd,e.outdir);if(e.bundle&&e.bundleOutput){if($r(e.bundleOutput))throw Error("bundleOutput must be relative to outdir");let i=ze(t,e.bundleOutput);if(!xr(i,t))throw Error("bundleOutput must stay within outdir")}if(!e.clean||e.dryRun)return;if(t===om(t).root)throw Error("Refusing to clean declarations from the filesystem root");let[r,n]=await Promise.all([Ul(t),Ul(ze(e.cwd,e.root))]);if(xr(n,r))throw Error("Refusing to clean an outdir that contains the source root")}function cm(e){let t=Sr.get(e);if(!t){if(t=new Kl(e),Sr.set(e,t),Sr.size>am){let r=Sr.keys().next().value;if(r!==void 0)Sr.delete(r)}}return t}async function fm(e){let t=ze(e.cwd,e.outdir);async function r(n){let i;try{i=await tm(n,{withFileTypes:!0})}catch{return}await Promise.all(i.map(async(s)=>{let o=ze(n,s.name);if(s.isDirectory()){await r(o);return}if(s.name.endsWith(".d.ts")||s.name.endsWith(".d.mts")||s.name.endsWith(".d.cts")||s.name.endsWith(".d.ts.map")||s.name.endsWith(".d.mts.map")||s.name.endsWith(".d.cts.map"))await im(o,{force:!0})}))}await r(t)}function ds(e,t,r){if(!t||t.length===0)return!1;let n=Le(r,e);for(let i of t){let s=cm(i);if(s.match(n)||s.match(e))return!0}return!1}function hm(e,t){let r=ze(e.cwd,e.root),n=` root: ${r}
230
+ Errors:`);for(let w of o.errors){let T=` - ${w.file}`;if(w.location)T+=`:${w.location.line}:${w.location.column}`;if(w.code)T+=` [${w.code}]`;if(T+=`: ${w.message}`,K.info(T),w.suggestion)K.info(` Suggestion: ${w.suggestion}`)}}K.info(`-----------------------------
231
+ `)}if(r.plugins&&r.plugins.length>0)await n.runOnEnd(o);return K.debug("DTS generation complete!"),o}async function zl(e){try{return await nm(e)}catch{return Je(e)}}async function fm(e){let t=Je(e.cwd,e.outdir);if(e.bundle&&e.bundleOutput){if(xr(e.bundleOutput))throw Error("bundleOutput must be relative to outdir");let i=Je(t,e.bundleOutput);if(!Tr(i,t))throw Error("bundleOutput must stay within outdir")}if(!e.clean||e.dryRun)return;if(t===lm(t).root)throw Error("Refusing to clean declarations from the filesystem root");let[r,n]=await Promise.all([zl(t),zl(Je(e.cwd,e.root))]);if(Tr(n,r))throw Error("Refusing to clean an outdir that contains the source root")}function um(e){let t=$r.get(e);if(!t){if(t=new Hl(e),$r.set(e,t),$r.size>cm){let r=$r.keys().next().value;if(r!==void 0)$r.delete(r)}}return t}async function hm(e){let t=Je(e.cwd,e.outdir);async function r(n){let i;try{i=await im(n,{withFileTypes:!0})}catch{return}await Promise.all(i.map(async(s)=>{let o=Je(n,s.name);if(s.isDirectory()){await r(o);return}if(s.name.endsWith(".d.ts")||s.name.endsWith(".d.mts")||s.name.endsWith(".d.cts")||s.name.endsWith(".d.ts.map")||s.name.endsWith(".d.mts.map")||s.name.endsWith(".d.cts.map"))await sm(o,{force:!0})}))}await r(t)}function ps(e,t,r){if(!t||t.length===0)return!1;let n=Ne(r,e);for(let i of t){let s=um(i);if(s.match(n)||s.match(e))return!0}return!1}function mm(e,t){let r=Je(e.cwd,e.root),n=` root: ${r}
231
232
  entrypoints: ${e.entrypoints.map((s)=>JSON.stringify(s)).join(", ")||"(none)"}
232
233
  `+(e.exclude?.length?` exclude: ${e.exclude.map((s)=>JSON.stringify(s)).join(", ")}
233
- `:"")+"Entrypoints are resolved relative to --root. Pass several by repeating --entrypoints or separating them with commas.";if(t.length===0){if(e.entrypoints.filter((s)=>$r(s)&&_l(s)&&!xr(s,r)).length===e.entrypoints.length)return;throw Error(`No source files matched. Nothing was generated.
234
- ${n}`)}let i=e.entrypoints.filter((s)=>{if(um.test(s))return!1;return!_l($r(s)?s:ze(r,s))});if(i.length>0)throw Error(`Entrypoint${i.length>1?"s":""} not found: ${i.map((s)=>JSON.stringify(s)).join(", ")}
235
- ${n}`)}async function dm(e){let t=[],r=ze(e.cwd,e.root),n=e.exclude||[],i=[...e.entrypoints,...e.include??[]];for(let s of i)if($r(s)&&ms(s)){if(!s.includes("node_modules")){if(!xr(s,r)&&e.outputStructure!=="flat")K.warn(`Skipping entrypoint outside root: ${Le(e.cwd,s)}`);else if(!ds(s,n,r))t.push(s)}}else{let o=new Kl(s);for await(let a of o.scan({cwd:r,absolute:!0,onlyFiles:!0}))if(ms(a)&&!a.includes("node_modules")){if(!ds(a,n,r))t.push(a)}}return[...new Set(t)].sort()}function xr(e,t){let r=Le(t,e);return r!==".."&&!r.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!$r(r)}function mm(e,t){let r=new Map;for(let n of e){let i=Tr(n,t),s=r.get(i);if(s&&s!==n)throw Error(`Output path collision: ${Le(t.cwd,s)} and ${Le(t.cwd,n)} both emit ${Le(t.cwd,i)}`);r.set(i,n)}}function ms(e){return/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/.test(e)&&!/\.d\.(?:ts|mts|cts)$/.test(e)}function Tr(e,t){let r=ze(t.cwd,t.root),n=Le(r,e).replace(/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/,(i)=>{if(i===".mts"||i===".mjs")return".d.mts";if(i===".cts"||i===".cjs")return".d.cts";return".d.ts"});if(t.outputStructure==="mirror")return ze(t.cwd,t.outdir,n);else{let i=n.split("/").pop();return ze(t.cwd,t.outdir,i)}}function pm(e,t,r=""){let n=Le(Ar(e),t).replace(/\\/g,"/");if(n=n.replace(/\.d\.mts$/,"").replace(/\.d\.cts$/,"").replace(/\.d\.ts$/,""),r)n+=r;if(!n.startsWith("."))n=`./${n}`;return n}function gm(e,t,r){let n=Tr(t,r),i=(s)=>{let o=Fi(s,t);if(!o.isRelative||!o.resolved)return s;if(/\.d\.(?:ts|mts|cts)$/.test(o.resolved))return s;let a=s.match(/[?#].*$/)?.[0]??"",c=a?s.slice(0,-a.length):s,f=sm(c),u=/^(?:\.js|\.jsx|\.mjs|\.cjs)$/.test(f)?f:"";return pm(n,Tr(o.resolved,r),u)+a};return e.replace(/\b(from\s*)(['"])(\.{1,2}\/[^'"]+)\2/g,(s,o,a,c)=>`${o}${a}${i(c)}${a}`).replace(/\b(import\s*)(['"])(\.{1,2}\/[^'"]+)\2/g,(s,o,a,c)=>`${o}${a}${i(c)}${a}`).replace(/\b(import\s*\(\s*)(['"])(\.{1,2}\/[^'"]+)\2/g,(s,o,a,c)=>`${o}${a}${i(c)}${a}`)}async function ym(e,t,r,n,i){let s=t;if(n)s=await n.runOnBeforeFile(e,t);let o=Ur(s,e,r.keepComments,r.isolatedDeclarations??!1);if(n)o=await n.runOnDeclarations(e,s,o);let a=0,c=0;for(let u=0;u<o.length;u++){let l=o[u];if(l.kind==="import")a++;if(l.kind==="export"||l.isExported)c++}let f=Gl(o,{filePath:e,sourceCode:s,declarations:o},r.keepComments,r.importOrder);if(f=gm(f,e,r),i)f=dl(f,i,{filePath:e});if(r.normalizeOutput===!0||r.declarationOrder)f=cl(f,{lineEnding:"lf",declarationOrder:r.declarationOrder,indent:{style:r.indentStyle??"spaces",size:r.indentSize??2}});if(n)f=await n.runOnAfterFile(e,s,f);return{content:f,declarationCount:o.length,importCount:a,exportCount:c}}var Kl,am=50,Sr,um;var zl=ce(()=>{Os();pn();mo();vo();Jr();Ya();$o();Qa();tl();sl();ol();fl();ml();kl();jl();({Glob:Kl}=globalThis.Bun);Sr=new Map;um=/[*?[\]{}!]/});var Jl=ce(()=>{zl()});import{createHash as wm}from"crypto";import{existsSync as vm,readFileSync as Em,writeFileSync as bm}from"fs";import{dirname as Sm,join as Am,relative as ql,resolve as Pr,sep as Wi}from"path";import Zl from"process";class Xl{listeners=new Map;on(e,t){let r=this.listeners.get(e)||[];r.push(t),this.listeners.set(e,r)}async emit(e,t){let r={type:e,timestamp:Date.now(),data:t},n=this.listeners.get(e)||[];for(let i of n)await i(r)}}class Ql{manifest;cacheDir;manifestPath;constructor(e,t){this.cacheDir=e,this.manifestPath=Am(e,"manifest.json"),this.manifest=this.loadManifest(t)}loadManifest(e){try{if(vm(this.manifestPath)){let t=JSON.parse(Em(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}=Cm("fs");e(this.cacheDir,{recursive:!0}),bm(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 $m(e){let t={root:e.root,outdir:e.outdir,entrypoints:e.entrypoints,clean:e.clean,tsconfigPath:e.tsconfigPath};return wm("md5").update(JSON.stringify(t)).digest("hex")}function ec(e={}){let{onSuccess:t,onError:r,failOnError:n=!0,incremental:i=!1,cacheDir:s=".dtsx-cache",on:o,timeout:a=60000,continueOnError:c=!1,verbose:f=!1,...u}=e,l=new Xl;if(o){for(let[g,d]of Object.entries(o))if(d)l.on(g,d)}return{name:"bun-plugin-dtsx",async setup(g){let d=Date.now(),v=null,b=0;try{let C=Pm(u,g),T=$m(C);if(C.clean){let _=Pr(C.cwd??Zl.cwd(),C.outdir??"./dist");if(Yl.has(_))C.clean=!1;else Yl.add(_)}if(i)v=new Ql(Pr(s),T);if(await l.emit("start",{type:"start",files:C.entrypoints||[],config:C}),f){if(console.log("[bun-plugin-dtsx] Starting declaration generation..."),i)console.log("[bun-plugin-dtsx] Incremental mode enabled")}let R=await(async()=>new Promise((_,L)=>{let P=setTimeout(()=>{L(new Rr(`Generation timed out after ${a}ms`,"TIMEOUT_ERROR",{timeout:a}))},a);ps(C).then((F)=>{clearTimeout(P),_(F)}).catch((F)=>{clearTimeout(P),L(F)})}))(),I=Date.now()-d;if(v)v.save();if(await l.emit("complete",{type:"complete",stats:R,duration:I,fromCache:b}),f){if(console.log(`[bun-plugin-dtsx] Generation complete in ${I}ms`),b>0)console.log(`[bun-plugin-dtsx] ${b} files served from cache`)}if(t)await t(R)}catch(C){let T=xm(C);if(await l.emit("error",{type:"error",error:T}),r)await r(T);else{if(console.error("[bun-plugin-dtsx] Error generating declarations:"),console.error(` Code: ${T.code}`),console.error(` Message: ${T.message}`),T.context)console.error(` Context: ${JSON.stringify(T.context)}`);if(f&&T.stack)console.error(` Stack: ${T.stack}`)}if(n&&!c)throw T}}}}function xm(e){if(e instanceof Rr)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 Rr(e.message,t,{originalError:e.name},e)}return new Rr(String(e),"GENERATION_ERROR")}function Tm(e){let t=e.map((n)=>Sm(n).split(Wi)),r=t[0];for(let n of t.slice(1)){let i=0;while(i<r.length&&i<n.length&&r[i]===n[i])i++;r=r.slice(0,i)}return r.join(Wi)||Wi}function Pm(e,t){let r=e.cwd||Zl.cwd(),n=t?.config?.entrypoints,i=e.outdir||e.build?.config.outdir||t?.config.outdir||"./dist",s=e.root||e.build?.config.root||t?.config.root;if(!s&&n?.length){let a=Tm(n.map((c)=>Pr(r,c)));s=ql(r,a)||"."}s=s||"./src";let o=e.entrypoints;if(!o)if(n?.length){let a=Pr(r,s),c=[];for(let f of n){let u=Pr(r,f);if(u===a||u.startsWith(a+Wi))c.push(ql(a,u));else console.warn(`[bun-plugin-dtsx] Skipping entrypoint outside root "${s}": ${f}`)}o=c.length?c:["index.ts"]}else o=["index.ts"];return{...e,cwd:r,root:s,entrypoints:o,outdir:i,clean:e.clean??!0,tsconfigPath:e.tsconfigPath}}var Cm,Rr,Yl;var tc=ce(()=>{Jl();Cm=import.meta.require;Rr=class Rr extends Error{code;context;cause;constructor(e,t,r,n){super(e);if(this.name="DtsxPluginError",this.code=t,this.context=r,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}}};Yl=new Set});import{mkdir as Rm,stat as Om}from"fs/promises";import{bold as gs,dim as ys,green as km,italic as rc,log as Mm}from"@stacksjs/cli";import{path as nt}from"@stacksjs/path";import{glob as ic}from"@stacksjs/storage";async function Dm(e){let t=await ic([nt.resolve(e,"dist","**/*.d.ts")],{absolute:!0}),r=new Bun.Transpiler({loader:"ts",target:"bun"});for(let n of t){let i=await Bun.file(n).text();try{r.transformSync(i)}catch(s){throw Error(`Invalid declaration generated at ${n}: ${s instanceof Error?s.message:String(s)}`)}}}async function Im(e){let t=nt.resolve(e,"dist","index.js");if(!await Bun.file(t).exists())return;let r=Bun.spawnSync({cmd:[process.execPath,"-e",`await import(${JSON.stringify(t)})`],stdout:"ignore",stderr:"pipe",env:{...process.env,NODE_ENV:"test"}});if(r.exitCode===0)return;let n=new TextDecoder().decode(r.stderr??new Uint8Array);if(/needs to refer to a top-level declared variable|does not provide an export named|Export named .* not found/i.test(n))throw Error(`Built package at ${t} cannot be imported: ${n.trim().split(`
234
+ `:"")+"Entrypoints are resolved relative to --root. Pass several by repeating --entrypoints or separating them with commas.";if(t.length===0){if(e.entrypoints.filter((s)=>xr(s)&&Ul(s)&&!Tr(s,r)).length===e.entrypoints.length)return;throw Error(`No source files matched. Nothing was generated.
235
+ ${n}`)}let i=e.entrypoints.filter((s)=>{if(dm.test(s))return!1;return!Ul(xr(s)?s:Je(r,s))});if(i.length>0)throw Error(`Entrypoint${i.length>1?"s":""} not found: ${i.map((s)=>JSON.stringify(s)).join(", ")}
236
+ ${n}`)}async function pm(e){let t=[],r=Je(e.cwd,e.root),n=e.exclude||[],i=[...e.entrypoints,...e.include??[]];for(let s of i)if(xr(s)&&gs(s)){if(!s.includes("node_modules")){if(!Tr(s,r)&&e.outputStructure!=="flat")K.warn(`Skipping entrypoint outside root: ${Ne(e.cwd,s)}`);else if(!ps(s,n,r))t.push(s)}}else{let o=new Hl(s);for await(let a of o.scan({cwd:r,absolute:!0,onlyFiles:!0}))if(gs(a)&&!a.includes("node_modules")){if(!ps(a,n,r))t.push(a)}}return[...new Set(t)].sort()}function Tr(e,t){let r=Ne(t,e);return r!==".."&&!r.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!xr(r)}function gm(e,t){let r=new Map;for(let n of e){let i=Pr(n,t),s=r.get(i);if(s&&s!==n)throw Error(`Output path collision: ${Ne(t.cwd,s)} and ${Ne(t.cwd,n)} both emit ${Ne(t.cwd,i)}`);r.set(i,n)}}function gs(e){return/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/.test(e)&&!/\.d\.(?:ts|mts|cts)$/.test(e)}function Pr(e,t){let r=Je(t.cwd,t.root),n=Ne(r,e).replace(/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/,(i)=>{if(i===".mts"||i===".mjs")return".d.mts";if(i===".cts"||i===".cjs")return".d.cts";return".d.ts"});if(t.outputStructure==="mirror")return Je(t.cwd,t.outdir,n);else{let i=n.split("/").pop();return Je(t.cwd,t.outdir,i)}}function ym(e,t,r=""){let n=Ne(Ar(e),t).replace(/\\/g,"/");if(n=n.replace(/\.d\.mts$/,"").replace(/\.d\.cts$/,"").replace(/\.d\.ts$/,""),r)n+=r;if(!n.startsWith("."))n=`./${n}`;return n}function Cm(e,t,r){let n=Pr(t,r),i=(s)=>{let o=Li(s,t);if(!o.isRelative||!o.resolved)return s;if(/\.d\.(?:ts|mts|cts)$/.test(o.resolved))return s;let a=s.match(/[?#].*$/)?.[0]??"",c=a?s.slice(0,-a.length):s,f=am(c),u=/^(?:\.js|\.jsx|\.mjs|\.cjs)$/.test(f)?f:"";return ym(n,Pr(o.resolved,r),u)+a};return e.replace(/\b(from\s*)(['"])(\.{1,2}\/[^'"]+)\2/g,(s,o,a,c)=>`${o}${a}${i(c)}${a}`).replace(/\b(import\s*)(['"])(\.{1,2}\/[^'"]+)\2/g,(s,o,a,c)=>`${o}${a}${i(c)}${a}`).replace(/\b(import\s*\(\s*)(['"])(\.{1,2}\/[^'"]+)\2/g,(s,o,a,c)=>`${o}${a}${i(c)}${a}`)}async function wm(e,t,r,n,i){let s=t;if(n)s=await n.runOnBeforeFile(e,t);let o=zr(s,e,r.keepComments,r.isolatedDeclarations??!1);if(n)o=await n.runOnDeclarations(e,s,o);let a=0,c=0;for(let u=0;u<o.length;u++){let l=o[u];if(l.kind==="import")a++;if(l.kind==="export"||l.isExported)c++}let f=_l(o,{filePath:e,sourceCode:s,declarations:o},r.keepComments,r.importOrder);if(f=Cm(f,e,r),i)f=pl(f,i,{filePath:e});if(r.normalizeOutput===!0||r.declarationOrder)f=ul(f,{lineEnding:"lf",declarationOrder:r.declarationOrder,indent:{style:r.indentStyle??"spaces",size:r.indentSize??2}});if(n)f=await n.runOnAfterFile(e,s,f);return{content:f,declarationCount:o.length,importCount:a,exportCount:c}}var Hl,cm=50,$r,dm;var ql=fe(()=>{Ms();yn();go();bo();Yr();Xa();To();tl();il();al();ll();hl();gl();Dl();Vl();({Glob:Hl}=globalThis.Bun);$r=new Map;dm=/[*?[\]{}!]/});var Yl=fe(()=>{ql()});import{createHash as Em}from"crypto";import{existsSync as bm,readFileSync as Sm,writeFileSync as $m}from"fs";import{dirname as Am,join as xm,relative as Zl,resolve as Rr,sep as Gi}from"path";import Ql from"process";class ec{listeners=new Map;on(e,t){let r=this.listeners.get(e)||[];r.push(t),this.listeners.set(e,r)}async emit(e,t){let r={type:e,timestamp:Date.now(),data:t},n=this.listeners.get(e)||[];for(let i of n)await i(r)}}class tc{manifest;cacheDir;manifestPath;constructor(e,t){this.cacheDir=e,this.manifestPath=xm(e,"manifest.json"),this.manifest=this.loadManifest(t)}loadManifest(e){try{if(bm(this.manifestPath)){let t=JSON.parse(Sm(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}=vm("fs");e(this.cacheDir,{recursive:!0}),$m(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 Tm(e){let t={root:e.root,outdir:e.outdir,entrypoints:e.entrypoints,clean:e.clean,tsconfigPath:e.tsconfigPath};return Em("md5").update(JSON.stringify(t)).digest("hex")}function rc(e={}){let{onSuccess:t,onError:r,failOnError:n=!0,incremental:i=!1,cacheDir:s=".dtsx-cache",on:o,timeout:a=60000,continueOnError:c=!1,verbose:f=!1,...u}=e,l=new ec;if(o){for(let[g,p]of Object.entries(o))if(p)l.on(g,p)}return{name:"bun-plugin-dtsx",async setup(g){let p=Date.now(),v=null,b=0;try{let w=Om(u,g),T=Tm(w);if(w.clean){let _=Rr(w.cwd??Ql.cwd(),w.outdir??"./dist");if(Xl.has(_))w.clean=!1;else Xl.add(_)}if(i)v=new tc(Rr(s),T);if(await l.emit("start",{type:"start",files:w.entrypoints||[],config:w}),f){if(console.log("[bun-plugin-dtsx] Starting declaration generation..."),i)console.log("[bun-plugin-dtsx] Incremental mode enabled")}let R=await(async()=>new Promise((_,W)=>{let P=setTimeout(()=>{W(new Or(`Generation timed out after ${a}ms`,"TIMEOUT_ERROR",{timeout:a}))},a);ys(w).then((F)=>{clearTimeout(P),_(F)}).catch((F)=>{clearTimeout(P),W(F)})}))(),I=Date.now()-p;if(v)v.save();if(await l.emit("complete",{type:"complete",stats:R,duration:I,fromCache:b}),f){if(console.log(`[bun-plugin-dtsx] Generation complete in ${I}ms`),b>0)console.log(`[bun-plugin-dtsx] ${b} files served from cache`)}if(t)await t(R)}catch(w){let T=Pm(w);if(await l.emit("error",{type:"error",error:T}),r)await r(T);else{if(console.error("[bun-plugin-dtsx] Error generating declarations:"),console.error(` Code: ${T.code}`),console.error(` Message: ${T.message}`),T.context)console.error(` Context: ${JSON.stringify(T.context)}`);if(f&&T.stack)console.error(` Stack: ${T.stack}`)}if(n&&!c)throw T}}}}function Pm(e){if(e instanceof Or)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 Or(e.message,t,{originalError:e.name},e)}return new Or(String(e),"GENERATION_ERROR")}function Rm(e){let t=e.map((n)=>Am(n).split(Gi)),r=t[0];for(let n of t.slice(1)){let i=0;while(i<r.length&&i<n.length&&r[i]===n[i])i++;r=r.slice(0,i)}return r.join(Gi)||Gi}function Om(e,t){let r=e.cwd||Ql.cwd(),n=t?.config?.entrypoints,i=e.outdir||e.build?.config.outdir||t?.config.outdir||"./dist",s=e.root||e.build?.config.root||t?.config.root;if(!s&&n?.length){let a=Rm(n.map((c)=>Rr(r,c)));s=Zl(r,a)||"."}s=s||"./src";let o=e.entrypoints;if(!o)if(n?.length){let a=Rr(r,s),c=[];for(let f of n){let u=Rr(r,f);if(u===a||u.startsWith(a+Gi))c.push(Zl(a,u));else console.warn(`[bun-plugin-dtsx] Skipping entrypoint outside root "${s}": ${f}`)}o=c.length?c:["index.ts"]}else o=["index.ts"];return{...e,cwd:r,root:s,entrypoints:o,outdir:i,clean:e.clean??!0,tsconfigPath:e.tsconfigPath}}var vm,Or,Xl;var ic=fe(()=>{Yl();vm=import.meta.require;Or=class Or extends Error{code;context;cause;constructor(e,t,r,n){super(e);if(this.name="DtsxPluginError",this.code=t,this.context=r,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}}};Xl=new Set});import{mkdir as km,stat as Mm}from"fs/promises";import{bold as Cs,dim as ws,green as Dm,italic as nc,log as Im}from"@stacksjs/cli";import{path as st}from"@stacksjs/path";import{glob as sc}from"@stacksjs/storage";async function Fm(e){let t=await sc([st.resolve(e,"dist","**/*.d.ts")],{absolute:!0}),r=new Bun.Transpiler({loader:"ts",target:"bun"});for(let n of t){let i=await Bun.file(n).text();try{r.transformSync(i)}catch(s){throw Error(`Invalid declaration generated at ${n}: ${s instanceof Error?s.message:String(s)}`)}}}async function Nm(e){let t=st.resolve(e,"dist","index.js");if(!await Bun.file(t).exists())return;let r=Bun.spawnSync({cmd:[process.execPath,"-e",`await import(${JSON.stringify(t)})`],stdout:"ignore",stderr:"pipe",env:{...process.env,NODE_ENV:"test"}});if(r.exitCode===0)return;let n=new TextDecoder().decode(r.stderr??new Uint8Array);if(/needs to refer to a top-level declared variable|does not provide an export named|Export named .* not found/i.test(n))throw Error(`Built package at ${t} cannot be imported: ${n.trim().split(`
236
237
  `)[0]}
237
- This is the minified-barrel failure. Build with \`transpilePackage\` instead of a minifying \`Bun.build\`.`)}async function P0(e){let r=Date.now()-e.startTime,n=e.pkgName??`@stacksjs/${nt.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 s=e.result.logs?.[0]||"Unknown build error";throw console.log(s),Error(`Build failed: ${s}`)}await Dm(e.dir),await Im(e.dir);let i=await ic([nt.resolve(e.dir,"dist","**/*")],{absolute:!0});for(let s of i){let o=await Om(s),a;if(o.size<1048576)a=`${(o.size/1024).toFixed(2)}kb`;else a=`${(o.size/1024/1024).toFixed(2)}mb`;let c=nt.relative(e.dir,s).replace("dist/","");console.log(`${gs(ys(`[${a}]`))} ${ys("dist/")}${c}`)}console.log(`${gs(ys(`[${r}ms]`))} Built ${rc(gs(km(n)))}`)}async function R0(e){let t=e.pkgName??`@stacksjs/${nt.basename(e.dir)}`;if(e.styled===!1)console.log(`Building ${t}...`);else Mm.info(`Building ${rc(t)}...`);return{startTime:Date.now()}}async function O0(e){await Promise.resolve().then(() => tc());let r=nt.resolve(e.dir,"src"),n=nt.resolve(e.dir,"dist"),i=(await Array.fromAsync(new Bun.Glob("**/*.ts").scan({cwd:r}))).filter((o)=>!o.endsWith(".d.ts")).filter((o)=>!o.endsWith(".test.ts")&&!o.endsWith(".spec.ts"));await Bun.build({entrypoints:i.map((o)=>nt.resolve(r,o)),outdir:n,root:r,target:"bun",format:"esm",splitting:!1,external:e.external??Fm(),plugins:[ec({root:r,outdir:n})]});let s=new Bun.Transpiler({loader:"ts",target:"bun",minifyWhitespace:!0});for(let o of i){let a=s.transformSync(await Bun.file(nt.resolve(r,o)).text());a=a.replace(/(['"])(\.\.?\/[^'"]+?)\.tsx?\1/g,"$1$2.js$1");let c=nt.resolve(n,o.replace(/\.ts$/,".js"));await Rm(nt.dirname(c),{recursive:!0}),await Bun.write(c,a)}}function Fm(e=[]){let t=[];try{let r=dc("fs"),n=JSON.parse(r.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((r)=>`${r}/*`),"bun-queue","ioredis","localtunnels","localtunnels/*","@craft-native/ts","ts-md","meilisearch","algoliasearch","@opensearch-project/opensearch","*.yaml","*.yml",...e]}export{Fm as frameworkExternal,R0 as intro,P0 as outro,O0 as transpilePackage,Dm as validateDeclarations,Im as validateRuntimeExports};
238
+ This is the minified-barrel failure. Build with \`transpilePackage\` instead of a minifying \`Bun.build\`.`)}async function O0(e){let r=Date.now()-e.startTime,n=e.pkgName??`@stacksjs/${st.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 s=e.result.logs?.[0]||"Unknown build error";throw console.log(s),Error(`Build failed: ${s}`)}await Fm(e.dir),await Nm(e.dir);let i=await sc([st.resolve(e.dir,"dist","**/*")],{absolute:!0});for(let s of i){let o=await Mm(s),a;if(o.size<1048576)a=`${(o.size/1024).toFixed(2)}kb`;else a=`${(o.size/1024/1024).toFixed(2)}mb`;let c=st.relative(e.dir,s).replace("dist/","");console.log(`${Cs(ws(`[${a}]`))} ${ws("dist/")}${c}`)}console.log(`${Cs(ws(`[${r}ms]`))} Built ${nc(Cs(Dm(n)))}`)}async function k0(e){let t=e.pkgName??`@stacksjs/${st.basename(e.dir)}`;if(e.styled===!1)console.log(`Building ${t}...`);else Im.info(`Building ${nc(t)}...`);return{startTime:Date.now()}}async function M0(e){await Promise.resolve().then(() => ic());let r=st.resolve(e.dir,"src"),n=st.resolve(e.dir,"dist"),i=(await Array.fromAsync(new Bun.Glob("**/*.ts").scan({cwd:r}))).filter((o)=>!o.endsWith(".d.ts")).filter((o)=>!o.endsWith(".test.ts")&&!o.endsWith(".spec.ts"));await Bun.build({entrypoints:i.map((o)=>st.resolve(r,o)),outdir:n,root:r,target:"bun",format:"esm",splitting:!1,external:e.external??Lm(),plugins:[rc({root:r,outdir:n})]});let s=new Bun.Transpiler({loader:"ts",target:"bun",minifyWhitespace:!0});for(let o of i){let a=s.transformSync(await Bun.file(st.resolve(r,o)).text());a=a.replace(/(['"])(\.\.?\/[^'"]+?)\.tsx?\1/g,"$1$2.js$1");let c=st.resolve(n,o.replace(/\.ts$/,".js"));await km(st.dirname(c),{recursive:!0}),await Bun.write(c,a)}}function Lm(e=[]){let t=[];try{let r=pc("fs"),n=JSON.parse(r.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((r)=>`${r}/*`),"bun-queue","ioredis","localtunnels","localtunnels/*","@craft-native/ts","ts-md","meilisearch","algoliasearch","@opensearch-project/opensearch","*.yaml","*.yml",...e]}export{Lm as frameworkExternal,k0 as intro,O0 as outro,M0 as transpilePackage,Fm as validateDeclarations,Nm as validateRuntimeExports};