@stacksjs/dtsx 0.9.12 → 0.9.14

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 (87) hide show
  1. package/README.md +5 -3
  2. package/dist/bin/cli.js +6 -6
  3. package/dist/branded-types.d.ts +10 -18
  4. package/dist/chunk-1bge31tv.js +2 -0
  5. package/dist/chunk-27nzyfdd.js +2 -0
  6. package/dist/chunk-285mqzvx.js +16 -0
  7. package/dist/chunk-2n1bbm2c.js +448 -0
  8. package/dist/chunk-3w5aqasc.js +33 -0
  9. package/dist/chunk-3xqchdwd.js +2 -0
  10. package/dist/chunk-7tyhhk7c.js +2 -0
  11. package/dist/chunk-8kz02py2.js +2 -0
  12. package/dist/{chunk-xe1z54pq.js → chunk-abhx1v3w.js} +1 -1
  13. package/dist/chunk-ayvw3402.js +2 -0
  14. package/dist/chunk-cbz06k9p.js +2 -0
  15. package/dist/chunk-d1xj2pjv.js +24 -0
  16. package/dist/chunk-dk914hsr.js +2 -0
  17. package/dist/chunk-dzgms5s6.js +80 -0
  18. package/dist/{chunk-91gpfz27.js → chunk-enqtx6te.js} +1 -1
  19. package/dist/{chunk-57agx6g8.js → chunk-gssantc8.js} +1 -1
  20. package/dist/chunk-j1zrbs2z.js +2 -0
  21. package/dist/{chunk-20kdv9bh.js → chunk-j8zksbkn.js} +1 -1
  22. package/dist/chunk-mcdb3q06.js +3 -0
  23. package/dist/{chunk-7vj8vtzh.js → chunk-mwfja9e3.js} +1 -1
  24. package/dist/{chunk-jm5ywn4e.js → chunk-mxam9312.js} +8 -8
  25. package/dist/chunk-nf54b52t.js +6 -0
  26. package/dist/{chunk-kge8a5vc.js → chunk-p50ms07x.js} +1 -1
  27. package/dist/{chunk-p09jmjq8.js → chunk-pj8142by.js} +1 -1
  28. package/dist/chunk-pt2txw6z.js +2 -0
  29. package/dist/chunk-r6v1qdqb.js +6 -0
  30. package/dist/chunk-rsv17jh8.js +3 -0
  31. package/dist/{chunk-7cpp6v8f.js → chunk-sw3m29sw.js} +1 -1
  32. package/dist/chunk-thhd43x5.js +19 -0
  33. package/dist/{chunk-3j7r0fxz.js → chunk-tne5n3h1.js} +1 -1
  34. package/dist/{chunk-v96rjx7x.js → chunk-trm0gptj.js} +1 -1
  35. package/dist/{chunk-jddkdjap.js → chunk-vgm83r4p.js} +1 -1
  36. package/dist/chunk-vpjw38x7.js +34 -0
  37. package/dist/chunk-wzq881r8.js +4 -0
  38. package/dist/chunk-x4v9kajr.js +3 -0
  39. package/dist/{chunk-8j312sjx.js → chunk-xmje6xfw.js} +1 -1
  40. package/dist/{chunk-3g2v2ns2.js → chunk-xtee8g1a.js} +1 -1
  41. package/dist/{chunk-fjjs2r77.js → chunk-y6m8mmyg.js} +1 -1
  42. package/dist/{chunk-6qv7p9sg.js → chunk-zf17s33e.js} +18 -11
  43. package/dist/compat.d.ts +5 -2
  44. package/dist/extractor/cache.d.ts +6 -2
  45. package/dist/extractor/directives.d.ts +0 -4
  46. package/dist/generator.d.ts +1 -1
  47. package/dist/logger.d.ts +4 -0
  48. package/dist/optimizer.d.ts +4 -0
  49. package/dist/process-source.d.ts +1 -0
  50. package/dist/processor/cache.d.ts +4 -2
  51. package/dist/processor/imports.d.ts +1 -0
  52. package/dist/src/index.js +52 -51
  53. package/dist/src/plugins/bun.js +1 -1
  54. package/dist/src/plugins/esbuild.js +1 -1
  55. package/dist/src/plugins/index.js +1 -1
  56. package/dist/src/plugins/tsup.js +1 -1
  57. package/dist/src/plugins/vite.js +1 -1
  58. package/dist/src/plugins/webpack.js +1 -1
  59. package/dist/transformers.d.ts +16 -1
  60. package/dist/type-mappings.d.ts +32 -16
  61. package/dist/types.d.ts +2 -0
  62. package/package.json +3 -3
  63. package/dist/chunk-0fhq2wva.js +0 -17
  64. package/dist/chunk-1e5c83wa.js +0 -2
  65. package/dist/chunk-1vc477cq.js +0 -2
  66. package/dist/chunk-2w3g3g00.js +0 -19
  67. package/dist/chunk-5fveksya.js +0 -6
  68. package/dist/chunk-6s7n1gt0.js +0 -2
  69. package/dist/chunk-7p1sfeeg.js +0 -2
  70. package/dist/chunk-8dx98fd5.js +0 -75
  71. package/dist/chunk-97pgeywh.js +0 -33
  72. package/dist/chunk-bzsvvb81.js +0 -2
  73. package/dist/chunk-d9my0n30.js +0 -2
  74. package/dist/chunk-efkpkyz9.js +0 -4
  75. package/dist/chunk-f18nyrrb.js +0 -32
  76. package/dist/chunk-gpxdn99a.js +0 -3
  77. package/dist/chunk-j40mkvfg.js +0 -2
  78. package/dist/chunk-kpp6ajgg.js +0 -2
  79. package/dist/chunk-me2ae6f0.js +0 -23
  80. package/dist/chunk-p1d09y82.js +0 -449
  81. package/dist/chunk-qn0xktfx.js +0 -3
  82. package/dist/chunk-r1m3q3dj.js +0 -2
  83. package/dist/chunk-r1ywapeb.js +0 -6
  84. package/dist/chunk-rw6j20e2.js +0 -3
  85. package/dist/chunk-zsznaama.js +0 -2
  86. package/dist/extractor/extract.d.ts +0 -10
  87. package/dist/extractor/scanner.d.ts +0 -6
@@ -0,0 +1,33 @@
1
+ // @bun
2
+ import{Wc as UX}from"./chunk-gssantc8.js";import{dd as d}from"./chunk-mcdb3q06.js";import{existsSync as IY}from"fs";import{resolve as jY}from"path";import WX from"process";import{pathToFileURL as wY}from"url";import{existsSync as OQ,statSync as TQ}from"fs";import{join as jX,relative as wX,resolve as NQ}from"path";import r from"process";import{Buffer as V}from"buffer";import{createCipheriv as KX,createDecipheriv as LX,randomBytes as JQ}from"crypto";import{closeSync as HQ,createReadStream as CQ,createWriteStream as MX,existsSync as l,fsyncSync as kQ,openSync as xQ,writeFileSync as FX}from"fs";import{access as DX,constants as PQ,mkdir as VX,readdir as n,rename as bQ,stat as C,unlink as i,writeFile as UQ}from"fs/promises";import{isAbsolute as SX,join as k,resolve as EX}from"path";import B from"process";import{pipeline as OX}from"stream/promises";import{createGzip as yQ}from"zlib";import x from"process";import S from"process";import s from"process";import{existsSync as o}from"fs";import{resolve as GQ}from"path";import{existsSync as eX}from"fs";import{existsSync as LQ,mkdirSync as QY,readdirSync as XY,readFileSync as YY,writeFileSync as ZY}from"fs";import{homedir as P}from"os";import{dirname as pQ,resolve as K}from"path";import N from"process";import{existsSync as GY,readdirSync as zY}from"fs";import{extname as zQ,resolve as uQ}from"path";import _Y from"process";var AX=Object.defineProperty,qX=(Q)=>Q;function GX(Q,X){this[Q]=qX.bind(null,X)}var zX=(Q,X)=>{for(var Y in X)AX(Q,Y,{get:X[Y],enumerable:!0,configurable:!0,set:GX.bind(X,Y)})},O=(Q,X)=>()=>(Q&&(X=Q(Q=0)),X),_X=import.meta.require;class MQ{cache=new Map;totalHits=0;totalMisses=0;options;constructor(Q={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...Q}}generateKey(Q,X){let Y=X?`:${X}`:"";return`${this.options.keyPrefix}${Q}${Y}`}isExpired(Q){return Date.now()-Q.timestamp.getTime()>Q.ttl}estimateSize(Q){try{return JSON.stringify(Q).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let Q=Array.from(this.cache.entries()).sort(([,Y],[,Z])=>Y.timestamp.getTime()-Z.timestamp.getTime()),X=Q.length-this.options.maxSize+1;for(let Y=0;Y<X;Y++)this.cache.delete(Q[Y][0])}set(Q,X,Y,Z){if(!this.options.enabled)return;let $=this.generateKey(Q,Y),J=Z??this.options.ttl,H=this.estimateSize(X);this.cache.set($,{value:X,timestamp:new Date,ttl:J,hits:0,size:H}),this.evictIfNeeded()}get(Q,X){if(!this.options.enabled){this.totalMisses++;return}let Y=this.generateKey(Q,X),Z=this.cache.get(Y);if(!Z){this.totalMisses++;return}if(this.isExpired(Z)){this.cache.delete(Y),this.totalMisses++;return}return Z.hits++,this.totalHits++,Z.value}isFileModified(Q,X){try{if(!OQ(Q))return!0;return TQ(Q).mtime>X}catch{return!0}}getWithFileCheck(Q,X){let Y=this.get(Q,X);if(!Y)return;if(this.isFileModified(X,Y.fileTimestamp)){this.delete(Q,X);return}return Y.value}setWithFileCheck(Q,X,Y,Z){try{let $=OQ(Y)?TQ(Y):null,J=$?$.mtime:new Date;this.set(Q,{value:X,fileTimestamp:J},Y,Z)}catch{this.set(Q,X,Y,Z)}}delete(Q,X){let Y=this.generateKey(Q,X);return this.cache.delete(Y)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let Q=0;for(let[X,Y]of this.cache.entries())if(this.isExpired(Y))this.cache.delete(X),Q++;return Q}getStats(){let Q=Array.from(this.cache.values()),X=Q.reduce((Z,$)=>Z+$.size,0),Y=Q.map((Z)=>Z.timestamp).sort();return{size:X,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:Y[0],newestEntry:Y[Y.length-1]}}export(){let Q={};for(let[X,Y]of this.cache.entries())Q[X]={value:Y.value,timestamp:Y.timestamp.toISOString(),ttl:Y.ttl,hits:Y.hits,size:Y.size};return Q}import(Q){this.cache.clear();for(let[X,Y]of Object.entries(Q))if(typeof Y==="object"&&Y!==null){let Z=Y;this.cache.set(X,{value:Z.value,timestamp:new Date(Z.timestamp),ttl:Z.ttl,hits:Z.hits,size:Z.size})}}}class FQ{metrics=[];maxMetrics=1000;async track(Q,X,Y={}){let Z=performance.now(),$=new Date;try{let J=await X(),H=performance.now()-Z;return this.recordMetric({operation:Q,duration:H,timestamp:$,...Y}),J}catch(J){let H=performance.now()-Z;throw this.recordMetric({operation:`${Q}:error`,duration:H,timestamp:$,...Y}),J}}recordMetric(Q){if(this.metrics.push(Q),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(Q){let X=Q?this.metrics.filter(($)=>$.operation===Q):this.metrics;if(X.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let Y=X.map(($)=>$.duration),Z=Y.reduce(($,J)=>$+J,0);return{count:X.length,averageDuration:Z/X.length,minDuration:Math.min(...Y),maxDuration:Math.max(...Y),totalDuration:Z,recentMetrics:X.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(Q){return this.metrics.filter((X)=>X.duration>Q)}}function BX(Q,X={}){let Z=Object.keys(X).sort().map(($)=>`${$}:${X[$]}`).join("|");return Z?`${Q}:${Z}`:Q}function RX(Q,X){try{return JSON.stringify(Q)===JSON.stringify(X)}catch{return Q===X}}function IX(Q){return Q.getStats().size*2}var b,p,cQ,g=O(()=>{b=new MQ,p=new FQ,cQ={createKey:BX,isEquivalent:RX,estimateMemoryUsage:IX}});function TX(Q,X={}){let Y=r.cwd();while(Y.includes("storage"))Y=NQ(Y,"..");let Z=NQ(Y,Q||"");if(X?.relative)return wX(r.cwd(),Z);return Z}function j(){if(S.env.NODE_ENV==="test"||S.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function NX(){if(S.env.NODE_ENV==="test"||S.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof S<"u"){let Q=S.type;if(Q==="renderer"||Q==="worker")return!1;return!!(S.versions&&(S.versions.node||S.versions.bun))}return!1}class lQ{async format(Q){let X=await NX(),Y=await this.getMetadata(X);return JSON.stringify({timestamp:Q.timestamp.toISOString(),level:Q.level,name:Q.name,message:Q.message,metadata:Y})}async getMetadata(Q){if(Q){let{hostname:X}=await import("os");return{pid:x.pid,hostname:X(),environment:x.env.NODE_ENV||"development",platform:x.platform,version:x.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:x.env.NODE_ENV||x.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class QQ{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(Q,X={}){this.name=Q,this.config={...h},this.options=this.normalizeOptions(X),this.formatter=this.options.formatter||new lQ,this.enabled=X.enabled??!0,this.fancy=X.fancy??!0,this.tagFormat=X.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=X.timestampPosition??"right",this.environment=X.environment??B.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(X);let Y={...X},Z=X.timestamp!==void 0;if(Z)delete Y.timestamp;if(this.config={...this.config,...Y,timestamp:Z||this.config.timestamp,level:this.options.level??"info"},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let $=this.generateKeyId(),J=this.generateKey();this.currentKeyId=$,this.keys.set($,J),this.encryptionKeys.set($,{key:J,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed(Q){if(!this.fingersCrossedConfig)return!1;let X={debug:0,info:1,success:2,warning:3,error:4},Y=this.fingersCrossedConfig.activationLevel??"error";return X[Q]>=X[Y]}initializeFingersCrossedConfig(Q){if(!Q.fingersCrossedEnabled&&Q.fingersCrossed)return{...t,...Q.fingersCrossed};if(!Q.fingersCrossedEnabled)return null;if(!Q.fingersCrossed)return{...t};return{...t,...Q.fingersCrossed}}normalizeOptions(Q){let X={format:"json",level:"info",logDirectory:h.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},Y={...X,...Object.fromEntries(Object.entries(Q).filter(([,Z])=>Z!==void 0))};if(!Y.level||!["debug","info","success","warning","error"].includes(Y.level))Y.level=X.level;return Y}shouldWriteToFile(){return!j()&&this.config.writeToFile===!0}async writeToFile(Q){let Y=(async()=>{let $,J=0,H=3,W=1000;while(J<H)try{try{try{await DX(this.config.logDirectory,PQ.F_OK|PQ.W_OK)}catch(A){if(A instanceof Error&&"code"in A)if(A.code==="ENOENT")await VX(this.config.logDirectory,{recursive:!0,mode:493});else if(A.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw A;else throw A}}catch(A){throw console.error("Debug: [writeToFile] Failed to create log directory:",A),A}let U=this.validateEncryptionConfig()?(await this.encrypt(Q)).encrypted:V.from(Q);try{if(!l(this.currentLogFile))await UQ(this.currentLogFile,"",{mode:420});if($=xQ(this.currentLogFile,"a",420),FX($,U,{flag:"a"}),kQ($),$!==void 0)HQ($),$=void 0;if((await C(this.currentLogFile)).size===0){if(await UQ(this.currentLogFile,U,{flag:"w",mode:420}),(await C(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(A){let q=A;if(q.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(q.code)){if(J<H-1){let G=typeof q.message==="string"?q.message:"Unknown error";console.error(`Network error during write attempt ${J+1}/${H}:`,G);let z=W*2**J;await new Promise((_)=>setTimeout(_,z)),J++;continue}}if(q?.code&&["ENOSPC","EDQUOT"].includes(q.code))throw Error(`Disk quota exceeded or no space left on device: ${q.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",q),q}finally{if($!==void 0)try{HQ($)}catch(A){console.error("Debug: [writeToFile] Error closing file descriptor:",A)}}}catch(U){if(J===H-1){let q=U,G=typeof q.message==="string"?q.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",G),U}J++;let A=W*2**(J-1);await new Promise((q)=>setTimeout(q,A))}})();this.pendingOperations.push(Y);let Z=this.pendingOperations.length-1;try{await Y}catch($){throw console.error("Debug: [writeToFile] Error in operation:",$),$}finally{this.pendingOperations.splice(Z,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 k(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 k(this.config.logDirectory,`${this.name}.log`);let Q=new Date().toISOString().split("T")[0];return k(this.config.logDirectory,`${this.name}-${Q}.log`)}setupRotation(){if(j())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let Q=this.config.rotation,X;switch(Q.frequency){case"daily":X=86400000;break;case"weekly":X=604800000;break;case"monthly":X=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},X)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let X=this.config.rotation.keyRotation;if(!X?.enabled)return;let Y=typeof X.interval==="number"?X.interval:60,Z=Math.max(Y,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch(($)=>{console.error("Error rotating keys:",$)})},Z)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let X=this.config.rotation.keyRotation,Y=this.generateKeyId(),Z=this.generateKey();this.currentKeyId=Y,this.keys.set(Y,Z),this.encryptionKeys.set(Y,{key:Z,createdAt:new Date});let $=Array.from(this.encryptionKeys.entries()).sort(([,W],[,U])=>U.createdAt.getTime()-W.createdAt.getTime()),J=typeof X.maxKeys==="number"?X.maxKeys:1,H=Math.max(1,J);if($.length>H)for(let[W]of $.slice(H))this.encryptionKeys.delete(W),this.keys.delete(W)}generateKeyId(){return JQ(16).toString("hex")}generateKey(){return JQ(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let Q=this.keys.get(this.currentKeyId);if(!Q)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:Q,id:this.currentKeyId}}encrypt(Q){let{key:X}=this.getCurrentKey(),Y=JQ(16),Z=KX("aes-256-gcm",X,Y),$=V.isBuffer(Q)?Q:V.from(Q,"utf8"),J=Z.update($),H=Z.final(),W=J.length+H.length,U=Z.getAuthTag(),A=V.allocUnsafe(16+W+16);return Y.copy(A,0),J.copy(A,16),H.copy(A,16+J.length),U.copy(A,16+W),{encrypted:A,iv:Y}}async compressData(Q){return new Promise((X,Y)=>{let Z=yQ(),$=[];Z.on("data",(J)=>$.push(J)),Z.on("end",()=>X(V.from(V.concat($)))),Z.on("error",Y),Z.write(Q),Z.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let Q={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let X=this.config.rotation.encrypt;return{...Q,...X}}return Q}async rotateLog(){if(j())return;if(!this.shouldWriteToFile())return;let Q=await C(this.currentLogFile).catch(()=>null);if(!Q)return;let X=this.config.rotation;if(typeof X==="boolean")return;if(X.maxSize&&Q.size>=X.maxSize){let Y=this.currentLogFile,Z=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let $=await n(this.config.logDirectory),J=$.filter((U)=>U.startsWith(this.name)&&/\.log\.\d+$/.test(U)).sort((U,A)=>{let q=Number.parseInt(U.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(A.match(/\.log\.(\d+)$/)?.[1]||"0")-q}),H=J.length>0?Number.parseInt(J[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,W=`${Y}.${H}`;if(await C(Y).catch(()=>null))try{if(await bQ(Y,W),X.compress)try{let U=`${W}.gz`;await this.compressLogFile(W,U),await i(W)}catch(U){console.error("Error compressing rotated file:",U)}if(J.length===0&&!$.some((U)=>U.endsWith(".log.1")))try{let U=`${Y}.1`;await UQ(U,"")}catch(U){console.error("Error creating backup file:",U)}}catch(U){console.error(`Error during rotation: ${U instanceof Error?U.message:String(U)}`)}}else{let $=new Date().toISOString().replace(/[:.]/g,"-"),J=Y.replace(/\.log$/,`-${$}.log`);if(await C(Y).catch(()=>null))await bQ(Y,J)}if(this.currentLogFile=Z,X.maxFiles){let J=(await n(this.config.logDirectory)).filter((H)=>H.startsWith(this.name)).sort((H,W)=>W.localeCompare(H));for(let H of J.slice(X.maxFiles))await i(k(this.config.logDirectory,H))}}}async compressLogFile(Q,X){let Y=CQ(Q),Z=MX(X),$=yQ();await OX(Y,$,Z)}async handleFingersCrossedBuffer(Q,X){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(Q)&&!this.isActivated){this.isActivated=!0;for(let Y of this.logBuffer){let Z=await this.formatter.format(Y);if(this.shouldWriteToFile())await this.writeToFile(Z);console.log(Z)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(X);console.log(X)}}shouldLog(Q){if(!this.enabled)return!1;let X={debug:0,info:1,success:2,warning:3,error:4};return X[Q]>=X[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((Q)=>{if(Q instanceof Promise)return Q.catch((X)=>{console.error("Error in pending write operation:",X)});return Promise.resolve()})),l(this.currentLogFile))try{let Q=xQ(this.currentLogFile,"r+");kQ(Q),HQ(Q)}catch(Q){console.error(`Error flushing file: ${Q}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let Q of this.pendingOperations)if(typeof Q.cancel==="function")Q.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(Q){console.error("Error waiting for pending operations:",Q)}if(!j()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let X=(await n(this.config.logDirectory)).filter((Y)=>(Y.includes("temp")||Y.includes(".tmp"))&&Y.includes(this.name));for(let Y of X)try{await i(k(this.config.logDirectory,Y))}catch(Z){console.error(`Failed to delete temp file ${Y}:`,Z)}}catch(Q){console.error("Error cleaning up temporary files:",Q)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(Q){if(!Q)return"";return`${this.tagFormat.prefix}${Q}${this.tagFormat.suffix}`}formatFileTimestamp(Q){return`[${Q.toISOString()}]`}formatConsoleTimestamp(Q){return this.shouldStyleConsole()?R.gray(Q.toLocaleTimeString()):Q.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||j())return!1;let Q=typeof B.env.NO_COLOR<"u",X=B.env.FORCE_COLOR==="0";if(Q||X)return!1;return!!(typeof B.stderr<"u"&&B.stderr.isTTY||typeof B.stdout<"u"&&B.stdout.isTTY)}formatConsoleMessage(Q){let{timestamp:X,icon:Y="",tag:Z="",message:$,level:J,showTimestamp:H=!0}=Q,W=(_)=>_.replace(this.ANSI_PATTERN,"");if(!this.fancy){let _=[];if(H)_.push(X);if(J==="warning")_.push("WARN");else if(J==="error")_.push("ERROR");else if(Y)_.push(Y.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(Z)_.push(Z.replace(/[[\]]/g,""));return _.push($),_.join(" ")}let U=B.stdout.columns||120,A="";if(J==="warning"||J==="error")A=`${Y} ${$}`;else if(J==="info"||J==="success")A=`${Y} ${Z} ${$}`;else A=`${Y} ${Z} ${R.cyan($)}`;if(!H)return A.trim();let q=W(A).trim().length,G=W(X).length,z=Math.max(1,U-2-q-G);return`${A.trim()}${" ".repeat(z)}${X}`}formatMessage(Q,X){if(X.length===1&&Array.isArray(X[0]))return Q.replace(/\{(\d+)\}/g,(J,H)=>{let W=Number.parseInt(H,10);return W<X[0].length?String(X[0][W]):J});let Y=/%([sdijfo%])/g,Z=0,$=Q.replace(Y,(J,H)=>{if(H==="%")return"%";if(Z>=X.length)return J;let W=X[Z++];switch(H){case"s":return String(W);case"d":case"i":return Number(W).toString();case"j":case"o":return JSON.stringify(W,null,2);default:return J}});if(Z<X.length)$+=` ${X.slice(Z).map((J)=>typeof J==="object"?JSON.stringify(J,null,2):String(J)).join(" ")}`;return $}formatMarkdown(Q){if(!Q)return Q;let X=Q;return X=X.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(Y,Z,$)=>{let J=R.underline(R.blue(Z)),H=this.toAbsoluteFilePath($);if(H&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let W=`file://${encodeURI(H)}`,U="\x1B]8;;",A="\x1B\\";return`\x1B]8;;${W}\x1B\\${J}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${$}\x1B\\${J}\x1B]8;;\x1B\\`;return J}),X=X.replace(/`([^`]+)`/g,(Y,Z)=>R.bgGray(Z)),X=X.replace(/\*\*([^*]+)\*\*/g,(Y,Z)=>R.bold(Z)),X=X.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(Y,Z)=>R.italic(Z)),X=X.replace(/(?<!_)_([^_]+)_(?!_)/g,(Y,Z)=>R.italic(Z)),X=X.replace(/~([^~]+)~/g,(Y,Z)=>R.strikethrough(Z)),X}supportsHyperlinks(){if(j())return!1;let Q=B.env;if(!Q)return!1;if(Q.TERM_PROGRAM==="iTerm.app"||Q.TERM_PROGRAM==="vscode"||Q.TERM_PROGRAM==="WezTerm")return!0;if(Q.WT_SESSION)return!0;if(Q.TERM==="xterm-kitty")return!0;let X=Q.VTE_VERSION?Number.parseInt(Q.VTE_VERSION,10):0;if(!Number.isNaN(X)&&X>=5000)return!0;return!1}toAbsoluteFilePath(Q){try{let X=Q;if(X.startsWith("file://"))X=X.replace(/^file:\/\//,"");if(X.startsWith("~")){let Y=B.env.HOME||"";if(Y)X=X.replace(/^~(?=$|\/)/,Y)}if(SX(X)||X.startsWith("./")||X.startsWith("../"))X=EX(X);else return null;return l(X)?X:null}catch{return null}}buildOutputTexts(Q){let X=this.shouldStyleConsole()?this.formatMarkdown(Q):Q,Y=Q.replace(this.ANSI_PATTERN,"");return{consoleText:X,fileText:Y}}async log(Q,X,...Y){if(!this.shouldLog(Q))return;let Z=new Date,$=this.formatConsoleTimestamp(Z),J=this.formatFileTimestamp(Z),H,W;if(X instanceof Error)H=X.message,W=X.stack;else H=this.formatMessage(X,Y);let{consoleText:U,fileText:A}=this.buildOutputTexts(H);if(this.shouldStyleConsole()){let G=this.options.showIcons===!1?"":nQ[Q],z=this.options.showTags!==!1&&this.name?R.gray(this.formatTag(this.name)):"",_;switch(Q){case"debug":_=this.formatConsoleMessage({timestamp:$,icon:G,tag:z,message:R.gray(U),level:Q}),console.error(_);break;case"info":_=this.formatConsoleMessage({timestamp:$,icon:G,tag:z,message:U,level:Q}),console.warn(_);break;case"success":_=this.formatConsoleMessage({timestamp:$,icon:G,tag:z,message:R.green(U),level:Q}),console.error(_);break;case"warning":_=this.formatConsoleMessage({timestamp:$,icon:G,tag:z,message:U,level:Q}),console.warn(_);break;case"error":if(_=this.formatConsoleMessage({timestamp:$,icon:G,tag:z,message:U,level:Q}),console.error(_),W){let D=W.split(`
3
+ `);for(let I of D)if(I.trim()&&!I.includes(H))console.error(this.formatConsoleMessage({timestamp:$,message:R.gray(` ${I}`),level:Q,showTimestamp:!1}))}break}}else if(!j()){if(console.error(`${J} ${this.environment}.${Q.toUpperCase()}: ${H}`),W)console.error(W)}let q=`${J} ${this.environment}.${Q.toUpperCase()}: ${A}
4
+ `;if(W)q+=`${W}
5
+ `;if(q=q.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(q)}progress(Q,X=""){let Y={update:(W,U)=>{},finish:(W)=>{},interrupt:(W,U)=>{}};if(!this.enabled)return Y;let Z=30;if(this.activeProgressBar={total:Math.max(1,Q||1),current:0,message:X||"",barLength:Z,lastRenderedLine:""},this.shouldStyleConsole()&&!j()&&B.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(W,U)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,W),this.activeProgressBar.total),U!==void 0)this.activeProgressBar.message=U;if(this.shouldStyleConsole()&&!j()&&B.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(W)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,W)},interrupt:(W,U="info")=>{if(!j()&&B.stdout.isTTY)B.stdout.write(`
6
+ `);if(this[U==="warning"?"warn":U](W),this.activeProgressBar&&this.shouldStyleConsole()&&!j()&&B.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time(Q){let X=performance.now();if(this.shouldStyleConsole()){let Y=this.options.showTags!==!1&&this.name?R.gray(this.formatTag(this.name)):"",Z=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:Z,icon:this.options.showIcons===!1?"":R.blue("\u25D0"),tag:Y,message:`${R.cyan(Q)}...`}))}return async(Y)=>{if(!this.enabled)return;let Z=performance.now(),$=Math.round(Z-X),J=`${Q} completed in ${$}ms`,H=new Date,W=this.formatConsoleTimestamp(H),A=`${this.formatFileTimestamp(H)} ${this.environment}.INFO: ${J}`;if(Y)A+=` ${JSON.stringify(Y)}`;if(A+=`
7
+ `,A=A.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let q=this.options.showTags!==!1&&this.name?R.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:W,icon:this.options.showIcons===!1?"":R.green("\u2713"),tag:q,message:`${J}${Y?` ${JSON.stringify(Y)}`:""}`}))}else if(!j())console.error(A.trim());if(this.shouldWriteToFile())await this.writeToFile(A)}}async debug(Q,...X){await this.log("debug",Q,...X)}async info(Q,...X){await this.log("info",Q,...X)}async success(Q,...X){await this.log("success",Q,...X)}async warn(Q,...X){await this.log("warning",Q,...X)}async error(Q,...X){await this.log("error",Q,...X)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let Q=this.config.rotation,{encrypt:X}=Q;return!!X}async only(Q){if(!this.enabled)return;return await Q()}isEnabled(){return this.enabled}setEnabled(Q){this.enabled=Q}extend(Q){let X=`${this.name}:${Q}`,Y=new QQ(X,{...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(Y),Y}createReadStream(){if(j())throw Error("createReadStream is not supported in browser environments");if(!l(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return CQ(this.currentLogFile,{encoding:"utf8"})}async decrypt(Q){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let X=this.config.rotation;if(!X.encrypt||typeof X.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let Y=this.keys.get(this.currentKeyId);try{let Z=V.isBuffer(Q)?Q:V.from(Q,"base64"),$=Z.subarray(0,16),J=Z.subarray(Z.length-16),H=Z.subarray(16,Z.length-16),W=LX("aes-256-gcm",Y,$);W.setAuthTag(J);let U=W.update(H),A=W.final(),q=U.length+A.length,G=V.allocUnsafe(q);return U.copy(G,0),A.copy(G,U.length),G.toString("utf8")}catch(Z){throw Error(`Decryption failed: ${Z instanceof Error?Z.message:String(Z)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return j()}isServerMode(){return!j()}setTestEncryptionKey(Q,X){this.currentKeyId=Q,this.keys.set(Q,X)}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(Q){if(!this.enabled)return;let X=new Date,Y=this.formatConsoleTimestamp(X),Z=this.formatFileTimestamp(X),{consoleText:$,fileText:J}=this.buildOutputTexts(Q);if(this.shouldStyleConsole()){let W=$.split(`
8
+ `),U=Math.max(...W.map((z)=>z.length))+2,A=`\u250C${"\u2500".repeat(U)}\u2510`,q=`\u2514${"\u2500".repeat(U)}\u2518`,G=W.map((z)=>{return this.formatConsoleMessage({timestamp:Y,message:R.cyan(z),showTimestamp:!1})});console.error(this.formatConsoleMessage({timestamp:Y,message:R.cyan(A),showTimestamp:!1})),G.forEach((z)=>console.error(z)),console.error(this.formatConsoleMessage({timestamp:Y,message:R.cyan(q),showTimestamp:!1}))}else if(!j())console.error(`${Z} ${this.environment}.INFO: [BOX] ${J}`);let H=`${Z} ${this.environment}.INFO: [BOX] ${J}
9
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(H)}async prompt(Q){if(j())return Promise.resolve(!0);return new Promise((X)=>{console.error(`${R.cyan("?")} ${Q} (y/n) `);let Y=(Z)=>{let $=Z.toString().trim().toLowerCase();B.stdin.removeListener("data",Y);try{if(typeof B.stdin.setRawMode==="function")B.stdin.setRawMode(!1)}catch{}B.stdin.pause(),console.error(""),X($==="y"||$==="yes")};try{if(typeof B.stdin.setRawMode==="function")B.stdin.setRawMode(!0)}catch{}B.stdin.resume(),B.stdin.once("data",Y)})}setFancy(Q){this.fancy=Q}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start(Q,...X){if(!this.enabled)return;let Y=Q;if(X&&X.length>0){let U=/%([sdijfo%])/g,A=0;if(Y=Q.replace(U,(q,G)=>{if(G==="%")return"%";if(A>=X.length)return q;let z=X[A++];switch(G){case"s":return String(z);case"d":case"i":return Number(z).toString();case"j":case"o":return JSON.stringify(z,null,2);default:return q}}),A<X.length)Y+=` ${X.slice(A).map((q)=>typeof q==="object"?JSON.stringify(q,null,2):String(q)).join(" ")}`}let{consoleText:Z,fileText:$}=this.buildOutputTexts(Y);if(this.shouldStyleConsole()){let U=this.options.showTags!==!1&&this.name?R.gray(this.formatTag(this.name)):"",A=this.options.showIcons===!1?"":`${R.blue("\u25D0")} `;console.error(`${A}${U} ${R.cyan(Z)}`)}let W=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${$}
10
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(W)}renderProgressBar(Q,X=!1){if(!this.enabled||!this.shouldStyleConsole()||!B.stdout.isTTY)return;let Y=Math.min(100,Math.max(0,Math.round(Q.current/Q.total*100))),Z=Math.round(Q.barLength*Y/100),$=Q.barLength-Z,J=R.green("\u2501".repeat(Z)),H=R.gray("\u2501".repeat($)),W=`[${J}${H}]`,U=`${Y}%`.padStart(4),A=Q.message?` ${Q.message}`:"",q=this.options.showIcons===!1?"":X||Y===100?R.green("\u2713"):R.blue("\u25B6"),G=this.options.showTags!==!1&&this.name?` ${R.gray(this.formatTag(this.name))}`:"",z=`\r${q}${G} ${W} ${U}${A}`,_=B.stdout.columns||80,D=" ".repeat(Math.max(0,_-z.replace(this.ANSI_PATTERN,"").length));if(Q.lastRenderedLine=`${z}${D}`,B.stdout.write(Q.lastRenderedLine),X)B.stdout.write(`
11
+ `)}finishProgressBar(Q,X){if(!this.enabled||!this.fancy||j()||!B.stdout.isTTY){this.activeProgressBar=null;return}if(Q.current<Q.total)Q.current=Q.total;if(X)Q.message=X;this.renderProgressBar(Q,!0),this.activeProgressBar=null}async clear(Q={}){if(j()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let X=await n(this.config.logDirectory),Y=[];for(let Z of X){if(!(Q.name?new RegExp(Q.name.replace("*",".*")).test(Z):Z.startsWith(this.name))||!Z.endsWith(".log"))continue;let J=k(this.config.logDirectory,Z);if(Q.before)try{if((await C(J)).mtime>=Q.before)continue}catch(H){console.error(`Failed to get stats for file ${J}:`,H);continue}Y.push(J)}if(Y.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${Y.length} log file(s)...`);for(let Z of Y)try{await i(Z),console.warn(`Deleted log file: ${Z}`)}catch($){console.error(`Failed to delete log file ${Z}:`,$)}console.warn("Log clearing process finished.")}catch(X){console.error("Error during log clearing process:",X)}}}var vQ,WQ,h,CX,w,R,kX,dQ,xX,hQ,PX,bX,AQ,yX,fQ,mQ,vX,qQ,dX,hX,fX,mX,pX,t,nQ,gX,uX=O(()=>{vQ=r.env.CLARITY_LOG_DIR||jX(TX(),"logs"),WQ={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:vQ,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},h={...WQ},CX=(async()=>{try{let{loadConfig:Q}=await Promise.resolve().then(()=>(HX(),JX)),X=await Q({name:"clarity",alias:"logging",defaultConfig:WQ,cwd:r.cwd()});if(X)Object.assign(h,X)}catch{}return h})(),w={red:(Q)=>`\x1B[31m${Q}\x1B[0m`,green:(Q)=>`\x1B[32m${Q}\x1B[0m`,yellow:(Q)=>`\x1B[33m${Q}\x1B[0m`,blue:(Q)=>`\x1B[34m${Q}\x1B[0m`,magenta:(Q)=>`\x1B[35m${Q}\x1B[0m`,cyan:(Q)=>`\x1B[36m${Q}\x1B[0m`,white:(Q)=>`\x1B[37m${Q}\x1B[0m`,gray:(Q)=>`\x1B[90m${Q}\x1B[0m`,bgRed:(Q)=>`\x1B[41m${Q}\x1B[0m`,bgYellow:(Q)=>`\x1B[43m${Q}\x1B[0m`,bgGray:(Q)=>`\x1B[100m${Q}\x1B[0m`,bold:(Q)=>`\x1B[1m${Q}\x1B[0m`,dim:(Q)=>`\x1B[2m${Q}\x1B[0m`,italic:(Q)=>`\x1B[3m${Q}\x1B[0m`,underline:(Q)=>`\x1B[4m${Q}\x1B[0m`,strikethrough:(Q)=>`\x1B[9m${Q}\x1B[0m`,reset:"\x1B[0m"},R=w,kX=w.red,dQ=w.green,xX=w.yellow,hQ=w.blue,PX=w.magenta,bX=w.cyan,AQ=w.white,yX=w.gray,fQ=w.bgRed,mQ=w.bgYellow,vX=w.bgGray,qQ=w.bold,dX=w.dim,hX=w.italic,fX=w.underline,mX=w.strikethrough,pX=w.reset,t={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},nQ={debug:"\uD83D\uDD0D",info:hQ("\u2139"),success:dQ("\u2713"),warning:mQ(AQ(qQ(" WARN "))),error:fQ(AQ(qQ(" ERROR ")))},gX=new QQ("stacks")}),cX="0.15.8",lX=()=>{};async function iQ(Q,X={}){let{maxRetries:Y=3,retryDelay:Z=1000,isRetryable:$=()=>!0,fallback:J}=X,H=Error("Unknown error occurred");for(let W=0;W<=Y;W++)try{return await Q()}catch(U){if(H=U instanceof Error?U:Error(String(U)),W===Y||!$(H))break;if(Z>0)await new Promise((A)=>setTimeout(A,Z))}if(J!==void 0)return J;throw H instanceof Error?H:Error(`Unknown error: ${String(H)}`)}function sQ(Q){return Q instanceof L}function nX(Q){return Q instanceof a}function iX(Q){if(sQ(Q))return Q.code==="FILE_SYSTEM_ERROR"||Q.code==="BROWSER_CONFIG_ERROR";return["ENOENT","EACCES","EMFILE","ENFILE","EBUSY","network","timeout","connection"].some((Y)=>Q.message.toLowerCase().includes(Y.toLowerCase()))}var L,a,f,_Q,BQ,e,RQ,IQ,m,jQ,wQ,T,y=O(()=>{L=class extends Error{timestamp;context;constructor(X,Y={}){super(X);if(this.name=this.constructor.name,this.timestamp=new Date,this.context=Y,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 X=Object.keys(this.context).length>0?` (${Object.entries(this.context).map(([Y,Z])=>`${Y}: ${Z}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${X}`}},a=class extends L{code="CONFIG_NOT_FOUND";constructor(X,Y,Z){let $=Z===void 0?[]:Array.isArray(Z)?Z.filter(Boolean):[Z],J="";if($.length===1)J=` or alias "${$[0]}"`;else if($.length>1)J=` or aliases ${$.map((H)=>`"${H}"`).join(", ")}`;super(`Configuration "${X}"${J} not found`,{configName:X,alias:Z,searchPaths:Y,searchPathCount:Y.length})}},f=class extends L{code="CONFIG_LOAD_ERROR";constructor(X,Y,Z){super(`Failed to load configuration from "${X}": ${Y.message}`,{configPath:X,configName:Z,originalError:Y.name,originalMessage:Y.message});this.cause=Y}},_Q=class extends L{code="CONFIG_VALIDATION_ERROR";constructor(X,Y,Z){super(`Configuration validation failed for "${X}"`,{configPath:X,configName:Z,validationErrors:Y,errorCount:Y.length})}},BQ=class extends L{code="CONFIG_MERGE_ERROR";constructor(X,Y,Z,$){super(`Failed to merge configuration from "${X}" with "${Y}": ${Z.message}`,{sourcePath:X,targetPath:Y,configName:$,originalError:Z.name,originalMessage:Z.message});this.cause=Z}},e=class extends L{code="ENV_VAR_ERROR";constructor(X,Y,Z,$){super(`Failed to parse environment variable "${X}" with value "${Y}" as ${Z}`,{envKey:X,envValue:Y,expectedType:Z,configName:$})}},RQ=class extends L{code="FILE_SYSTEM_ERROR";constructor(X,Y,Z){super(`File system ${X} failed for "${Y}": ${Z.message}`,{operation:X,path:Y,originalError:Z.name,originalMessage:Z.message});this.cause=Z}},IQ=class extends L{code="TYPE_GENERATION_ERROR";constructor(X,Y,Z){super(`Failed to generate types from "${X}" to "${Y}": ${Z.message}`,{configDir:X,outputPath:Y,originalError:Z.name,originalMessage:Z.message});this.cause=Z}},m=class extends L{code="SCHEMA_VALIDATION_ERROR";constructor(X,Y,Z){super(`Schema validation failed${Z?` for config "${Z}"`:""}`,{schemaPath:X,configName:Z,validationErrors:Y,errorCount:Y.length})}},jQ=class extends L{code="BROWSER_CONFIG_ERROR";constructor(X,Y,Z,$){super(`Failed to fetch configuration from "${X}": ${Y} ${Z}`,{endpoint:X,status:Y,statusText:Z,configName:$})}},wQ=class extends L{code="PLUGIN_ERROR";constructor(X,Y,Z){super(`Plugin "${X}" failed during ${Y}: ${Z.message}`,{pluginName:X,operation:Y,originalError:Z.name,originalMessage:Z.message});this.cause=Z}},T={configNotFound(Q,X,Y){return new a(Q,X,Y)},configLoad(Q,X,Y){return new f(Q,X,Y)},configValidation(Q,X,Y){return new _Q(Q,X,Y)},configMerge(Q,X,Y,Z){return new BQ(Q,X,Y,Z)},envVar(Q,X,Y,Z){return new e(Q,X,Y,Z)},fileSystem(Q,X,Y){return new RQ(Q,X,Y)},typeGeneration(Q,X,Y){return new IQ(Q,X,Y)},schemaValidation(Q,X,Y){return new m(Q,X,Y)},browserConfig(Q,X,Y,Z){return new jQ(Q,X,Y,Z)},plugin(Q,X,Y){return new wQ(Q,X,Y)}}});class XQ{defaultParsers;constructor(){this.defaultParsers=[{name:"boolean",canParse:(Q,X)=>X==="boolean"||["true","false","1","0","yes","no"].includes(Q.toLowerCase()),parse:(Q)=>{let X=Q.toLowerCase();return["true","1","yes"].includes(X)}},{name:"number",canParse:(Q,X)=>X==="number"||!Number.isNaN(Number(Q))&&!Number.isNaN(Number.parseFloat(Q)),parse:(Q)=>{let X=Number(Q);if(Number.isNaN(X))throw TypeError(`Cannot parse "${Q}" as number`);return X}},{name:"array",canParse:(Q,X)=>X==="array"||Q.startsWith("[")||Q.includes(","),parse:(Q)=>{try{let X=JSON.parse(Q);if(Array.isArray(X))return X}catch{}return Q.split(",").map((X)=>X.trim())}},{name:"json",canParse:(Q,X)=>X==="object"||(Q.startsWith("{")&&Q.endsWith("}")||Q.startsWith("[")&&Q.endsWith("]")),parse:(Q)=>{try{return JSON.parse(Q)}catch(X){throw Error(`Cannot parse "${Q}" as JSON: ${X}`)}}}]}async applyEnvironmentVariables(Q,X,Y={}){let{prefix:Z,useCamelCase:$=!0,useBackwardCompatibility:J=!0,customParsers:H={},verbose:W=!1,trackPerformance:U=!0}=Y,A=async()=>{if(!Q)return{config:X,source:{type:"environment",priority:50,timestamp:new Date}};let q=Z||this.generateEnvPrefix(Q),G={...X};return this.processObject(G,[],q,{useCamelCase:$,useBackwardCompatibility:J,customParsers:H,verbose:W,configName:Q}),{config:G,source:{type:"environment",priority:50,timestamp:new Date}}};if(U)return p.track("applyEnvironmentVariables",A,{configName:Q});return A()}generateEnvPrefix(Q){return Q.toUpperCase().replace(/-/g,"_")}formatEnvKey(Q,X){if(!X)return Q.toUpperCase();return Q.replace(/([A-Z])/g,"_$1").toUpperCase()}processObject(Q,X,Y,Z){for(let[$,J]of Object.entries(Q)){let H=[...X,$],W=H.map((q)=>this.formatEnvKey(q,Z.useCamelCase)),U=`${Y}_${W.join("_")}`,A=Z.useBackwardCompatibility?`${Y}_${H.map((q)=>q.toUpperCase()).join("_")}`:null;if(Z.verbose);if(typeof J==="object"&&J!==null&&!Array.isArray(J))this.processObject(J,H,Y,Z);else{let q=s.env[U]||(A?s.env[A]:void 0);if(q!==void 0){if(Z.verbose){let G=s.env[U]?U:A}try{Q[$]=this.parseEnvironmentValue(q,typeof J,U,Z.customParsers,Z.configName)}catch(G){if(G instanceof e)throw G;throw T.envVar(U,q,typeof J,Z.configName)}}}}}parseEnvironmentValue(Q,X,Y,Z,$){for(let[J,H]of Object.entries(Z))try{return H(Q)}catch{continue}for(let J of this.defaultParsers)if(J.canParse(Q,X))try{return J.parse(Q)}catch{throw T.envVar(Y,Q,`${X} (via ${J.name} parser)`,$)}return Q}getEnvironmentVariables(Q){let X={},Y=Q.toUpperCase();for(let[Z,$]of Object.entries(s.env))if(Z.startsWith(Y)&&$!==void 0)X[Z]=$;return X}validateEnvironmentVariable(Q,X,Y){let Z=[];if(!/^[A-Z_][A-Z0-9_]*$/.test(Q))Z.push(`Environment variable key "${Q}" should only contain uppercase letters, numbers, and underscores`);if(Y)try{this.parseEnvironmentValue(Q,X,Y,{})}catch($){Z.push(`Cannot parse value "${X}" as ${Y}: ${$}`)}return{isValid:Z.length===0,errors:Z}}generateEnvVarDocs(Q,X,Y={}){let{prefix:Z,format:$="text"}=Y,J=Z||this.generateEnvPrefix(Q),H=[];switch(this.extractEnvVarInfo(X,[],J,H),$){case"markdown":return this.formatAsMarkdown(H,Q);case"json":return JSON.stringify(H,null,2);default:return this.formatAsText(H,Q)}}extractEnvVarInfo(Q,X,Y,Z){for(let[$,J]of Object.entries(Q)){let H=[...X,$],W=`${Y}_${H.map((U)=>this.formatEnvKey(U,!0)).join("_")}`;if(typeof J==="object"&&J!==null&&!Array.isArray(J))this.extractEnvVarInfo(J,H,Y,Z);else Z.push({key:W,type:Array.isArray(J)?"array":typeof J,description:`Configuration for ${H.join(".")}`,example:this.generateExample(J)})}}generateExample(Q){if(Array.isArray(Q))return JSON.stringify(Q);if(typeof Q==="object"&&Q!==null)return JSON.stringify(Q);return String(Q)}formatAsText(Q,X){let Y=`Environment Variables for ${X}:
12
+
13
+ `;for(let Z of Q)Y+=`${Z.key}
14
+ `,Y+=` Type: ${Z.type}
15
+ `,Y+=` Description: ${Z.description}
16
+ `,Y+=` Example: ${Z.example}
17
+
18
+ `;return Y}formatAsMarkdown(Q,X){let Y=`# Environment Variables for ${X}
19
+
20
+ `;Y+=`| Variable | Type | Description | Example |
21
+ `,Y+=`|----------|------|-------------|----------|
22
+ `;for(let Z of Q)Y+=`| \`${Z.key}\` | ${Z.type} | ${Z.description} | \`${Z.example}\` |
23
+ `;return Y}}var oQ=O(()=>{g(),y()});function sX(Q,X){let Y=_X("process");if(typeof Y>"u"||!Y.env)return X;let Z=Y.env[Q];return Z!==void 0?Z:X}function tQ(Q,X,Y={}){return rQ(Q,X,Y,new WeakMap)}function rQ(Q,X,Y,Z){let{arrayMergeMode:$="replace",skipNullish:J=!1,customMerger:H}=Y;if(X===null||X===void 0)return J?Q:X;if(H){let W=H(Q,X);if(W!==void 0)return W}if(Array.isArray(X)||Array.isArray(Q))return aQ(Q,X,$,Z);if(!F(X)||!F(Q))return X;return aX(Q,X,Y,Z)}function aQ(Q,X,Y,Z){if(Array.isArray(X)&&!Array.isArray(Q))return X;if(Array.isArray(Q)&&!Array.isArray(X))return X;if(Array.isArray(X)&&Array.isArray(Q))switch(Y){case"replace":return X;case"concat":return oX(Q,X);case"smart":return tX(Q,X,Z);default:return X}return X}function oX(Q,X){let Y=[...X];for(let Z of Q)if(!Y.some(($)=>KQ($,Z)))Y.push(Z);return Y}function tX(Q,X,Y){if(X.length===0)return Q;if(Q.length===0)return X;if(F(X[0])&&F(Q[0]))return rX(Q,X,Y);if(X.every((Z)=>typeof Z==="string")&&Q.every((Z)=>typeof Z==="string")){let Z=[...X];for(let $ of Q)if(!Z.includes($))Z.push($);return Z}return X}function rX(Q,X,Y){let Z=[...X];for(let $ of Q){if(!F($)){Z.push($);continue}let J=["id","name","key","path","type"],H=!1;for(let W of J)if(W in $){if(Z.find((A)=>F(A)&&(W in A)&&A[W]===$[W])){H=!0;break}}if(!H)Z.push($)}return Z}function aX(Q,X,Y,Z){let $=X;if(F($)&&Z.has($))return Z.get($);let J={...Q};if(F($))Z.set($,J);for(let H in $){if(!Object.prototype.hasOwnProperty.call($,H))continue;let W=$[H],U=J[H];if(Y.skipNullish&&(W===null||W===void 0))continue;if(W===null||W===void 0){J[H]=W;continue}if(F(W)&&F(U))J[H]=rQ(U,W,Y,Z);else if(Array.isArray(W)||Array.isArray(U))J[H]=aQ(U,W,Y.arrayMergeMode||"smart",Z);else J[H]=W}return J}function DQ(Q,X,Y="replace"){return tQ(Q,X,{arrayMergeMode:Y==="replace"?"replace":"smart",skipNullish:!0})}function KQ(Q,X){if(Q===X)return!0;if(Array.isArray(Q)&&Array.isArray(X)){if(Q.length!==X.length)return!1;for(let Y=0;Y<Q.length;Y++)if(!KQ(Q[Y],X[Y]))return!1;return!0}if(F(Q)&&F(X)){let Y=Object.keys(Q),Z=Object.keys(X);if(Y.length!==Z.length)return!1;for(let $ of Y){if(!Object.prototype.hasOwnProperty.call(X,$))return!1;if(!KQ(Q[$],X[$]))return!1}return!0}return!1}function F(Q){return Boolean(Q&&typeof Q==="object"&&!Array.isArray(Q))}var eQ,VQ=O(()=>{eQ={replace:"replace",concat:"concat",smart:"smart"}});class YQ{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(Q,X,Y={}){let{arrayStrategy:Z="replace",useCache:$=!0,cacheTtl:J,trackPerformance:H=!0,verbose:W=!1}=Y;if($){let A=b.getWithFileCheck("file",Q);if(A){if(W)console.log(`Configuration loaded from cache: ${Q}`);return A}}let U=async()=>{if(!o(Q))return null;try{let A=`?t=${Date.now()}`,q=await import(Q+A),G=q.default||q,z="default"in q,_=Object.keys(q).length>0;if(!z&&!_)throw new f(Q,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof G!=="object"||G===null||Array.isArray(G))throw new f(Q,Error("Configuration must export a valid object"),"unknown");let $Q={config:DQ(X,G,Z),source:{type:"file",path:Q,priority:100,timestamp:new Date}};if($)b.setWithFileCheck("file",$Q,Q,J);return $Q}catch(A){throw A instanceof Error?T.configLoad(Q,A):T.configLoad(Q,Error(String(A)))}};if(H)return p.track("loadFromPath",U,{path:Q});return U()}async tryLoadFromPaths(Q,X,Y={}){for(let Z of Q)try{let $=await this.loadFromPath(Z,X,Y);if($)return $}catch($){if($ instanceof Error&&$.name==="ConfigLoadError")throw $;if(Y.verbose)console.warn(`Failed to load config from ${Z}:`,$)}return null}generateConfigPaths(Q,X,Y){let Z=this.generateNamePatterns(Q,Y),$=[];for(let J of Z)for(let H of this.extensions)$.push(GQ(X,`${J}${H}`));return $}generateNamePatterns(Q,X){let Y=[];if(Y.push("config",".config"),Q)Y.push(Q,`.${Q}.config`,`${Q}.config`,`.${Q}`);let Z=X===void 0?[]:Array.isArray(X)?X:[X];for(let J of Z){if(!J)continue;if(Y.push(J,`.${J}.config`,`${J}.config`,`.${J}`),Q)Y.push(`${Q}.${J}.config`,`.${Q}.${J}.config`)}let $=new Set;return Y.filter((J)=>{if(!J||$.has(J))return!1;return $.add(J),!0})}checkFileAccess(Q){return iQ(async()=>{return o(Q)},{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(Q,X,Y){let Z=[];if(!o(Q))return Z;if(X||Y){let $=this.generateNamePatterns(X||"",Y);for(let J of $)for(let H of this.extensions){let W=GQ(Q,`${J}${H}`);if(await this.checkFileAccess(W))Z.push(W)}}else try{let{readdirSync:$}=await import("fs"),J=$(Q);for(let H of J)if(this.looksLikeConfigFile(H)){let W=GQ(Q,H);if(await this.checkFileAccess(W))Z.push(W)}}catch{return[]}return Z}looksLikeConfigFile(Q){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((Y)=>Y.test(Q))}async validateConfigFile(Q){let X=[];try{if(!o(Q))return X.push("Configuration file does not exist"),X;let Y=await import(Q),Z=Y.default||Y;if(Z===void 0)X.push("Configuration file must export a default value or named exports");else if(typeof Z!=="object"||Z===null)X.push("Configuration must be an object");else if(Array.isArray(Z))X.push("Configuration cannot be an array at the root level");if(Q.endsWith(".json"))try{let{readFileSync:$}=await import("fs"),J=$(Q,"utf8");JSON.parse(J)}catch($){X.push(`Invalid JSON syntax: ${$}`)}}catch(Y){X.push(`Failed to load configuration file: ${Y}`)}return X}async getFileModificationTime(Q){try{let{statSync:X}=await import("fs");return X(Q).mtime}catch{return null}}async preloadConfigurations(Q,X={}){let Y=new Map;return await Promise.allSettled(Q.map(async(Z)=>{try{let $=await this.loadFromPath(Z,{},X);if($)Y.set(Z,$.config)}catch($){if(X.verbose)console.warn(`Failed to preload ${Z}:`,$)}})),Y}}var QX=O(()=>{g(),y(),VQ()});class SQ{async validateConfiguration(Q,X,Y={}){let{stopOnFirstError:Z=!1,validateRequired:$=!0,validateTypes:J=!0,customRules:H=[],trackPerformance:W=!0,verbose:U=!1}=Y,A=async()=>{let q=[],G=[],z={stopOnFirstError:Z,validateRequired:$,validateTypes:J,customRules:H,trackPerformance:W,verbose:U};try{if(typeof X==="string")return await this.validateWithSchemaFile(Q,X,z);else if(Array.isArray(X))return this.validateWithRules(Q,[...X,...H],z);else return this.validateWithJSONSchema(Q,X,z)}catch(_){return q.push({path:"",message:`Validation failed: ${_}`,rule:"system"}),{isValid:!1,errors:q,warnings:G}}};if(W)return await p.track("validateConfiguration",A);return A()}async validateWithSchemaFile(Q,X,Y){try{if(!eX(X))throw new m(X,[{path:"",message:"Schema file does not exist"}]);let Z=await import(X),$=Z.default||Z;if(Array.isArray($))return this.validateWithRules(Q,$,Y);else return this.validateWithJSONSchema(Q,$,Y)}catch(Z){throw new m(X,[{path:"",message:`Failed to load schema: ${Z}`}])}}validateWithJSONSchema(Q,X,Y){let Z=[],$=[];return this.validateObjectAgainstSchema(Q,X,"",Z,$,Y),{isValid:Z.length===0,errors:Z,warnings:$}}validateObjectAgainstSchema(Q,X,Y,Z,$,J){if(J.validateTypes&&X.type){let H=Array.isArray(Q)?"array":typeof Q,W=Array.isArray(X.type)?X.type:[X.type];if(!W.includes(H)){if(Z.push({path:Y,message:`Expected type ${W.join(" or ")}, got ${H}`,expected:W.join(" or "),actual:H,rule:"type"}),J.stopOnFirstError)return}}if(X.enum&&!X.enum.includes(Q)){if(Z.push({path:Y,message:`Value must be one of: ${X.enum.join(", ")}`,expected:X.enum.join(", "),actual:Q,rule:"enum"}),J.stopOnFirstError)return}if(typeof Q==="string"){if(X.minLength!==void 0&&Q.length<X.minLength)Z.push({path:Y,message:`String length must be at least ${X.minLength}`,expected:`>= ${X.minLength}`,actual:Q.length,rule:"minLength"});if(X.maxLength!==void 0&&Q.length>X.maxLength)Z.push({path:Y,message:`String length must not exceed ${X.maxLength}`,expected:`<= ${X.maxLength}`,actual:Q.length,rule:"maxLength"});if(X.pattern){if(!new RegExp(X.pattern).test(Q))Z.push({path:Y,message:`String does not match pattern ${X.pattern}`,expected:X.pattern,actual:Q,rule:"pattern"})}}if(typeof Q==="number"){if(X.minimum!==void 0&&Q<X.minimum)Z.push({path:Y,message:`Value must be at least ${X.minimum}`,expected:`>= ${X.minimum}`,actual:Q,rule:"minimum"});if(X.maximum!==void 0&&Q>X.maximum)Z.push({path:Y,message:`Value must not exceed ${X.maximum}`,expected:`<= ${X.maximum}`,actual:Q,rule:"maximum"})}if(Array.isArray(Q)&&X.items)for(let H=0;H<Q.length;H++){let W=Y?`${Y}[${H}]`:`[${H}]`;if(this.validateObjectAgainstSchema(Q[H],X.items,W,Z,$,J),J.stopOnFirstError&&Z.length>0)return}if(Q&&typeof Q==="object"&&!Array.isArray(Q)){let H=Q;if(J.validateRequired&&X.required){for(let W of X.required)if(!(W in H)){if(Z.push({path:Y?`${Y}.${W}`:W,message:`Missing required property '${W}'`,expected:"required",rule:"required"}),J.stopOnFirstError)return}}if(X.properties){for(let[W,U]of Object.entries(X.properties))if(W in H){let A=Y?`${Y}.${W}`:W;if(this.validateObjectAgainstSchema(H[W],U,A,Z,$,J),J.stopOnFirstError&&Z.length>0)return}}if(X.additionalProperties===!1){let W=new Set(Object.keys(X.properties||{}));for(let U of Object.keys(H))if(!W.has(U))$.push({path:Y?`${Y}.${U}`:U,message:`Additional property '${U}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(Q,X,Y){let Z=[],$=[];for(let J of X)try{let H=this.getValueByPath(Q,J.path),W=this.validateWithRule(H,J,J.path);if(Z.push(...W),Y.stopOnFirstError&&Z.length>0)break}catch(H){Z.push({path:J.path,message:`Rule validation failed: ${H}`,rule:"system"})}return{isValid:Z.length===0,errors:Z,warnings:$}}validateWithRule(Q,X,Y){let Z=[];if(X.required&&(Q===void 0||Q===null))return Z.push({path:Y,message:X.message||`Property '${Y}' is required`,expected:"required",rule:"required"}),Z;if(Q===void 0||Q===null)return Z;if(X.type){let $=Array.isArray(Q)?"array":typeof Q;if($!==X.type)Z.push({path:Y,message:X.message||`Expected type ${X.type}, got ${$}`,expected:X.type,actual:$,rule:"type"})}if(X.min!==void 0){let $=Array.isArray(Q)?Q.length:typeof Q==="string"?Q.length:typeof Q==="number"?Q:0;if($<X.min)Z.push({path:Y,message:X.message||`Value must be at least ${X.min}`,expected:`>= ${X.min}`,actual:$,rule:"min"})}if(X.max!==void 0){let $=Array.isArray(Q)?Q.length:typeof Q==="string"?Q.length:typeof Q==="number"?Q:0;if($>X.max)Z.push({path:Y,message:X.message||`Value must not exceed ${X.max}`,expected:`<= ${X.max}`,actual:$,rule:"max"})}if(X.pattern&&typeof Q==="string"){if(!X.pattern.test(Q))Z.push({path:Y,message:X.message||`Value does not match pattern ${X.pattern}`,expected:X.pattern.toString(),actual:Q,rule:"pattern"})}if(X.enum&&!X.enum.includes(Q))Z.push({path:Y,message:X.message||`Value must be one of: ${X.enum.join(", ")}`,expected:X.enum.join(", "),actual:Q,rule:"enum"});if(X.validator){let $=X.validator(Q);if($)Z.push({path:Y,message:X.message||$,rule:"custom"})}return Z}getValueByPath(Q,X){if(!X)return Q;let Y=X.split("."),Z=Q;for(let $ of Y)if(Z&&typeof Z==="object"&&$ in Z)Z=Z[$];else return;return Z}generateRulesFromInterface(Q){let X=[],Y=Q.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let Z of Y){let[,$,J,H]=Z;X.push({path:$,required:!J,type:this.mapTypeScriptType(H)})}return X}mapTypeScriptType(Q){switch(Q.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:XX},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}var XX,YX=O(()=>{g(),y(),XX=/^https?:\/\//});function $Y(Q){if(!Q)return"";let X=Array.isArray(Q)?Q.filter(Boolean):[Q];if(X.length===0)return"";if(X.length===1)return` or alias "${X[0]}"`;return` or aliases ${X.map((Y)=>`"${Y}"`).join(", ")}`}class EQ{fileLoader=new YQ;envProcessor=new XQ;validator=new SQ;async loadConfig(Q){let X=Date.now(),{cache:Y,performance:Z,schema:$,validate:J,...H}=Q;try{if(Y?.enabled){let U=this.checkCache(H.name||"",H);if(U)return U}let W;try{W=await this.loadConfigurationStrategies(H,!0,Y)}catch(U){let A=H.__strictErrorHandling;if(U instanceof Error&&U.name==="ConfigNotFoundError"){if(A)throw U;W={...await this.applyEnvironmentVariables(H.name||"",H.defaultConfig,H.checkEnv!==!1,H.verbose||!1),warnings:[`No configuration file found for "${H.name||"config"}", using defaults with environment variables`]}}else if(U instanceof Error&&U.name==="ConfigLoadError"){let q=U.message.includes("EACCES")||U.message.includes("EPERM")||U.message.includes("permission denied"),G=!q&&(U.message.includes("syntax")||U.message.includes("Expected")||U.message.includes("Unexpected")||U.message.includes("BuildMessage")||U.message.includes("errors building")),z=U.message.includes("Configuration must export a valid object")||U.message.includes("Configuration file is empty and exports nothing");if(A&&(z||q))throw U;if(G&&(!A||!z))W={...await this.applyEnvironmentVariables(H.name||"",H.defaultConfig,H.checkEnv!==!1,H.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!A)W={...await this.applyEnvironmentVariables(H.name||"",H.defaultConfig,H.checkEnv!==!1,H.verbose||!1),warnings:[`Configuration loading error, using defaults: ${U.message}`]};else throw U}else W={...await this.applyEnvironmentVariables(H.name||"",H.defaultConfig,H.checkEnv!==!1,H.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${U instanceof Error?U.message:String(U)}`]}}if($||J)await this.validateConfiguration(W.config,$,J,H.name);if(Y?.enabled&&W)this.cacheResult(H.name||"",W,Y,H);if(Z?.enabled){let U={operation:"loadConfig",duration:Date.now()-X,configName:H.name,timestamp:new Date};if(Z.onMetrics)Z.onMetrics(U);if(Z.slowThreshold&&U.duration>Z.slowThreshold)M.warn(`Slow configuration loading detected: ${U.duration}ms for ${H.name}`);W.metrics=U}return W}catch(W){let U=Date.now()-X;throw M.error(`Configuration loading failed after ${U}ms:`,[W instanceof Error?W:Error(String(W))]),W}}async loadConfigurationStrategies(Q,X=!1,Y){let{name:Z="",alias:$,cwd:J,configDir:H,defaultConfig:W,checkEnv:U=!0,arrayStrategy:A="replace",verbose:q=!1}=Q,G=J||N.cwd(),z=[],_=await this.loadLocalConfiguration(Z,$,G,H,W,A,q,U,Y);if(_)return z.push(...this.getLocalSearchPaths(Z,$,G,H)),this.finalizeResult(_,z,U,Z,q);let D=await this.loadHomeConfiguration(Z,$,W,A,q,U);if(D)return z.push(...this.getHomeSearchPaths(Z,$)),this.finalizeResult(D,z,U,Z,q);let I=await this.loadPackageJsonConfiguration(Z,$,G,W,A,q,U);if(I)return z.push(K(G,"package.json")),this.finalizeResult(I,z,U,Z,q);if(z.push(...this.getAllSearchPaths(Z,$,G,H)),X)throw T.configNotFound(Z,z,$);return{...await this.applyEnvironmentVariables(Z,W,U,q),warnings:[`No configuration file found for "${Z}"${$Y($)}, using defaults with environment variables`]}}async loadLocalConfiguration(Q,X,Y,Z,$,J,H,W,U){let A=W?v(Q,$,H):$,q=this.getLocalDirectories(Y,Z);for(let G of q){if(H)M.info(`Searching for configuration in: ${G}`);let z=this.fileLoader.generateConfigPaths(Q,G,X),_=await this.fileLoader.tryLoadFromPaths(z,A,{arrayStrategy:J,verbose:H,cacheTtl:U?.ttl,useCache:!U?.ttl||U.ttl>100});if(_){if(H)M.success(`Configuration loaded from: ${_.source.path}`);return _}}return null}async loadHomeConfiguration(Q,X,Y,Z,$,J){if(!Q)return null;let H=J?v(Q,Y,$):Y,W=[K(P(),".config",Q),K(P(),".config"),P()];for(let U of W){if($)M.info(`Checking home directory: ${U}`);let A=this.fileLoader.generateConfigPaths(Q,U,X),q=await this.fileLoader.tryLoadFromPaths(A,H,{arrayStrategy:Z,verbose:$});if(q){if($)M.success(`Configuration loaded from home directory: ${q.source.path}`);return q}}return null}async loadPackageJsonConfiguration(Q,X,Y,Z,$,J,H){let W=H?v(Q,Z,J):Z;try{let U=K(Y,"package.json");if(!LQ(U))return null;let A={};try{A=JSON.parse(YY(U,"utf8"))}catch(z){if(J)M.warn("Failed to parse package.json:",[z instanceof Error?z:Error(String(z))]);return null}let q=A[Q],G=Q;if(!q&&X){let z=Array.isArray(X)?X:[X];for(let _ of z){if(!_)continue;if(A[_]){q=A[_],G=_;break}}}if(q&&typeof q==="object"&&!Array.isArray(q)){if(J)M.success(`Configuration loaded from package.json: ${G}`);return{config:DQ(W,q,$),source:{type:"package.json",path:U,priority:30,timestamp:new Date}}}}catch(U){if(J)M.warn("Failed to load package.json:",[U instanceof Error?U:Error(String(U))])}return null}async applyEnvironmentVariables(Q,X,Y,Z){if(!Y||!Q||typeof X!=="object"||X===null||Array.isArray(X))return{config:X,source:{type:"default",priority:10,timestamp:new Date}};return{config:v(Q,X,Z),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(Q,X,Y,Z,$){return{config:Q.config,source:Q.source,path:Q.source.path}}async validateConfiguration(Q,X,Y,Z){let $=[];if(Y){let J=Y(Q);if(J)$.push(...J)}if(X){let J=await this.validator.validateConfiguration(Q,X);if(!J.isValid)$.push(...J.errors.map((H)=>H.path?`${H.path}: ${H.message}`:H.message))}if($.length>0)throw T.configValidation(Z||"unknown",$,Z)}checkCache(Q,X){let Y=this.generateCacheKey(Q,X);return b.get(Y)||null}cacheResult(Q,X,Y,Z){let $=this.generateCacheKey(Q,Z);b.set($,X,void 0,Y.ttl)}generateCacheKey(Q,X){let Y=[Q];if(X.alias){let Z=Array.isArray(X.alias)?X.alias.join(","):X.alias;Y.push(`alias:${Z}`)}if(X.cwd)Y.push(`cwd:${X.cwd}`);if(X.configDir)Y.push(`configDir:${X.configDir}`);if("checkEnv"in X)Y.push(`checkEnv:${X.checkEnv}`);return Y.join("|")}getLocalDirectories(Q,X){return Array.from(new Set([Q,K(Q,"config"),K(Q,".config"),X?K(Q,X):void 0].filter(Boolean)))}getAllSearchPaths(Q,X,Y,Z){let $=[];return $.push(...this.getLocalSearchPaths(Q,X,Y,Z)),$.push(...this.getHomeSearchPaths(Q,X)),$.push(K(Y,"package.json")),$}getLocalSearchPaths(Q,X,Y,Z){let $=this.getLocalDirectories(Y,Z),J=[];for(let H of $)J.push(...this.fileLoader.generateConfigPaths(Q,H,X));return J}getHomeSearchPaths(Q,X){if(!Q)return[];let Y=[K(P(),".config",Q),K(P(),".config"),P()],Z=[];for(let $ of Y)Z.push(...this.fileLoader.generateConfigPaths(Q,$,X));return Z}async loadConfigWithResult(Q){return this.loadConfig(Q)}}function gQ(Q){let Y=!(Q.message.includes("EACCES")||Q.message.includes("EPERM")||Q.message.includes("permission denied"))&&(Q.message.includes("syntax")||Q.message.includes("Expected")||Q.message.includes("Unexpected")||Q.message.includes("BuildMessage")),Z=Q.message.includes("Configuration must export a valid object")||Q.message.includes("Configuration file is empty and exports nothing");return Y||Z}async function JY(Q){return E.loadConfig({...Q,__strictErrorHandling:!0})}async function ZQ(Q){let X="defaultConfig"in Q&&Q.defaultConfig!==void 0?Q.defaultConfig:{},Y="cache"in Q||"performance"in Q||"schema"in Q||"validate"in Q;try{let Z;if(Y)Z=await E.loadConfig(Q);else Z=await E.loadConfig({...Q,defaultConfig:X,cache:{enabled:!0},performance:{enabled:!1}});return Z?.config??X}catch(Z){let $=Z instanceof Error?Z.name:"UnknownError",J=Z instanceof Error?Z.message:String(Z);if(!($==="ConfigNotFoundError"||$==="ConfigLoadError"||$==="ConfigValidationError"||J.includes("config"))&&Q.verbose)M.warn("Unexpected error loading config, using defaults:",[Z instanceof Error?Z:Error(String(Z))]);let W=Y?{...Q,defaultConfig:X}:{...Q,defaultConfig:X,cache:{enabled:!0},performance:{enabled:!1}};if("checkEnv"in Q?Q.checkEnv!==!1:!0)return(await E.applyEnvironmentVariables(W.name||"",X,!0,W.verbose||!1))?.config??X;return X}}async function HY(Q={defaultConfig:{}}){if(typeof Q==="string"){let{cwd:X}=await import("process");try{return(await E.loadConfig({name:Q,cwd:X(),generatedDir:"./generated",configDir:"./config",defaultConfig:{},checkEnv:!0,arrayStrategy:"replace"})).config}catch(Y){if(Y instanceof Error&&(Y.name==="ConfigNotFoundError"||Y.name==="ConfigLoadError"&&gQ(Y)))return(await E.applyEnvironmentVariables(Q,{},!0,!1)).config;throw Y}}try{return(await E.loadConfig({...Q,cwd:Q.cwd||N.cwd(),cache:{enabled:!0},performance:{enabled:!1}})).config}catch(X){if(X instanceof Error&&(X.name==="ConfigNotFoundError"||X.name==="ConfigLoadError"&&gQ(X)))return(await E.applyEnvironmentVariables(Q.name||"",Q.defaultConfig||{},Q.checkEnv!==!1,Q.verbose||!1)).config;throw X}}async function UY(Q,X,Y="replace"){let Z=new YQ;try{let $=await Z.loadFromPath(Q,X,{arrayStrategy:Y,useCache:!1,trackPerformance:!1});return $?$.config:null}catch{return null}}function v(Q,X,Y=!1){let Z=new XQ,$=Q.toUpperCase().replace(/[^A-Z0-9]/g,"_");function J(H,W=[]){let U={...H};for(let[A,q]of Object.entries(H)){let G=[...W,A],z=[`${$}_${G.join("_").toUpperCase()}`,`${$}_${G.map((I)=>I.toUpperCase()).join("")}`,`${$}_${G.map((I)=>I.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],_,D;for(let I of z)if(_=N.env[I],_!==void 0){D=I;break}if(_!==void 0&&D)if(typeof q==="boolean")U[A]=["true","1","yes"].includes(_.toLowerCase());else if(typeof q==="number"){let I=Number(_);if(!Number.isNaN(I))U[A]=I}else if(Array.isArray(q))try{U[A]=JSON.parse(_)}catch{U[A]=_.split(",").map((I)=>I.trim())}else U[A]=_;else if(q&&typeof q==="object"&&!Array.isArray(q))U[A]=J(q,G)}return U}return J(X)}function WY(Q){let X=K(N.cwd(),Q.configDir),Y=K(N.cwd(),Q.generatedDir),Z=K(Y,"config-types.ts");if(!LQ(pQ(Z)))QY(pQ(Z),{recursive:!0,mode:511});let $=LQ(X)?XY(X).map((H)=>H.replace(/\.(ts|js|mjs|cjs|mts|cts|json)$/,"")).sort():[],J=`// Generated by bunfig v${cX}
24
+ export type ConfigNames = ${$.length?`'${$.join("' | '")}'`:"string"}
25
+ `;ZY(Z,J,{mode:438})}function AY(Q){let X=null,Y=null,Z=()=>{if(!Y)Y=ZQ(Q).then((J)=>{return X=J,J},(J)=>{let H="defaultConfig"in Q?Q.defaultConfig:{};if(X=H,"verbose"in Q&&Q.verbose)M.warn("Config loading failed, using defaults:",[J instanceof Error?J:Error(String(J))]);return H});return Y},$="defaultConfig"in Q?Q.defaultConfig:{};return X=$,Z(),new Proxy({},{get(J,H){if(X)return X[H];let W=$[H];return Z(),W},has(J,H){return H in(X||$)},ownKeys(){return Object.keys(X||$)},getOwnPropertyDescriptor(J,H){return Object.getOwnPropertyDescriptor(X||$,H)},set(J,H,W){if(!X)X={...$};return X[H]=W,!0}})}var M,E,ZX,$X,qY=O(()=>{uX(),lX(),g(),y(),oQ(),QX(),YX(),VQ(),M=new QQ("bunfig",{showTags:!0}),E=new EQ,ZX=K(N.cwd(),"config"),$X=K(N.cwd(),"src/generated")});function BY(Q){let X=uQ(_Y.cwd(),Q?.configDir||"./config");function Y(){if(!GY(X))return[];let $=new Set([".ts",".js",".mjs",".cjs",".mts",".cts",".json"]),J=[".ts",".mts",".cts",".js",".mjs",".cjs",".json"],H=zY(X).filter((U)=>$.has(zQ(U))).map((U)=>({base:U.replace(/\.(?:ts|js|mjs|cjs|mts|cts|json)$/i,""),file:U})),W=new Map;for(let{base:U,file:A}of H){let q=zQ(A).toLowerCase(),G=W.get(U);if(!G){W.set(U,A);continue}let z=zQ(G).toLowerCase();if(J.indexOf(q)<J.indexOf(z))W.set(U,A)}return Array.from(W.entries()).map(([U,A])=>({base:U,file:A})).sort((U,A)=>U.base.localeCompare(A.base))}function Z(){let $=Y(),J=$.map((A)=>A.base),H=J.length?J.map((A)=>`'${A}'`).join(" | "):"string",W=$.length?`{
26
+ ${$.map((A)=>{let q=uQ(X,A.file).replace(/\\/g,"/");return` '${A.base}': typeof import('${q}').default`}).join(`,
27
+ `)}
28
+ }`:"Record<string, any>";return`export type ConfigNames = ${H}
29
+ export type ConfigByName = ${W}
30
+ export type Config<N extends ConfigNames> = N extends keyof ConfigByName ? ConfigByName[N] : unknown
31
+ export type ConfigOf = Config
32
+ `}return{name:"bunfig-plugin",setup($){$.onResolve({filter:/^virtual:bunfig-types$/},(J)=>{return{path:J.path,namespace:"bunfig-virtual"}}),$.onLoad({filter:/^virtual:bunfig-types$/,namespace:"bunfig-virtual"},()=>{return{contents:Z(),loader:"ts"}})}}}var RY=()=>{},JX={};zX(JX,{withErrorRecovery:()=>iQ,tryLoadConfig:()=>UY,loadConfigWithResult:()=>JY,loadConfig:()=>ZQ,isRetryableError:()=>iX,isConfigNotFoundError:()=>nX,isBunfigError:()=>sQ,globalPerformanceMonitor:()=>p,globalCache:()=>b,getEnvOrDefault:()=>sX,generateConfigTypes:()=>WY,defaultGeneratedDir:()=>$X,defaultConfigDir:()=>ZX,deepMergeWithArrayStrategy:()=>DQ,deepMerge:()=>tQ,createLibraryConfig:()=>AY,config:()=>HY,bunfigPlugin:()=>BY,applyEnvVarsToConfig:()=>v,TypeGenerationError:()=>IQ,SchemaValidationError:()=>m,PluginError:()=>wQ,PerformanceMonitor:()=>FQ,FileSystemError:()=>RQ,ErrorFactory:()=>T,EnvVarError:()=>e,EnvProcessor:()=>XQ,ConfigValidator:()=>SQ,ConfigValidationError:()=>_Q,ConfigNotFoundError:()=>a,ConfigMergeError:()=>BQ,ConfigLoader:()=>EQ,ConfigLoadError:()=>f,ConfigFileLoader:()=>YQ,ConfigCache:()=>MQ,CacheUtils:()=>cQ,BunfigError:()=>L,BrowserConfigError:()=>jQ,ArrayMergeStrategies:()=>eQ});var HX=O(()=>{qY(),y(),g(),y(),RY(),oQ(),QX(),YX(),VQ()});HX();var c={cwd:WX.cwd(),root:"./src",entrypoints:["**/*.ts"],outdir:"./dist",keepComments:!0,clean:!0,tsconfigPath:"./tsconfig.json",outputStructure:"mirror",verbose:!1,importOrder:["bun"],declarationMap:!1},KY=["dtsx.config.ts","dtsx.config.js","dtsx.config.mjs","dtsx.config.mts","dts.config.ts","dts.config.js"];async function LY(Q=WX.cwd()){for(let X of KY){let Y=jY(Q,X);if(IY(Y))try{let $=await import(wY(Y).href),J=$.default||$.config||$,H=typeof J==="function"?await J():J;return{...c,...H,cwd:Q}}catch(Z){let $=Z instanceof Error?Z.message:String(Z);UX.warn(`Failed to load config from ${X}: ${$}`)}}return null}var u=null;async function aY(Q){if(!u){let X=await LY(Q);if(X)u=X;else u=await ZQ({name:"dts",defaultConfig:c})}return u}function eY(){u=null}function QZ(Q){return{...c,...Q}}function XZ(Q){return async()=>{let X=await Q();return{...c,...X}}}var YZ=c;
33
+ export{c as Pc,aY as Qc,eY as Rc,QZ as Sc,XZ as Tc,YZ as Uc};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{$ as c,Z as a,_ as b,aa as d,ba as e}from"./chunk-zf17s33e.js";import"./chunk-gssantc8.js";import"./chunk-mcdb3q06.js";export{c as parallelProcess,b as createWorkerPool,e as calculateOptimalBatchSize,d as batchFiles,a as WorkerPool};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{s as a,t as b,u as c,v as d,w as e,x as f,y as g}from"./chunk-vgm83r4p.js";import"./chunk-thhd43x5.js";import"./chunk-2n1bbm2c.js";import"./chunk-rsv17jh8.js";import"./chunk-d1xj2pjv.js";import"./chunk-vpjw38x7.js";import"./chunk-285mqzvx.js";import"./chunk-mcdb3q06.js";export{f as startLSPServer,g as createFileWatcher,b as SymbolKind,a as LspDiagnosticSeverity,e as DtsxLanguageServer,d as DocumentHighlightKind,c as CompletionItemKind};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h}from"./chunk-j8zksbkn.js";import"./chunk-thhd43x5.js";import"./chunk-2n1bbm2c.js";import"./chunk-rsv17jh8.js";import"./chunk-d1xj2pjv.js";import"./chunk-285mqzvx.js";import"./chunk-gssantc8.js";import"./chunk-mcdb3q06.js";export{a as parseJSDoc,f as generateTypeDocJSON,c as generateMarkdown,e as generateJSON,d as generateHTML,g as generateDocs,b as extractDocumentation,h as createDocsGenerator};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{tb as K}from"./chunk-8dx98fd5.js";function L(N={}){let{buildStart:P=!0,buildEnd:Q=!1,writeBundle:T=!1,modes:y,onGenerated:U,onError:H,...W}=N,I="production",z=async()=>{try{let q=await K(W);U?.(q)}catch(q){let J=q instanceof Error?q:Error(String(q));if(H?.(J),!H)console.error("[dtsx] Generation failed:",J.message)}},F=()=>{if(!y||y.length===0)return!0;return y.includes(I)};return{name:"dtsx",apply(q){return I=q.mode,!0},async buildStart(){if(P&&F())await z()},async buildEnd(){if(Q&&F())await z()},async writeBundle(){if(T&&F())await z()}}}var Y=L,_=L;
2
+ import{tb as K}from"./chunk-dzgms5s6.js";function L(N={}){let{buildStart:P=!0,buildEnd:Q=!1,writeBundle:T=!1,modes:y,onGenerated:U,onError:H,...W}=N,I="production",z=async()=>{try{let q=await K(W);U?.(q)}catch(q){let J=q instanceof Error?q:Error(String(q));if(H?.(J),!H)console.error("[dtsx] Generation failed:",J.message)}},F=()=>{if(!y||y.length===0)return!0;return y.includes(I)};return{name:"dtsx",apply(q){return I=q.mode,!0},async buildStart(){if(P&&F())await z()},async buildEnd(){if(Q&&F())await z()},async writeBundle(){if(T&&F())await z()}}}var Y=L,_=L;
3
3
  export{L as ca,Y as da,_ as ea};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Pc as a,Qc as b,Rc as c,Sc as d,Tc as e,Uc as f}from"./chunk-3w5aqasc.js";import"./chunk-gssantc8.js";import"./chunk-mcdb3q06.js";export{c as resetConfig,b as getConfig,e as defineConfigAsync,d as defineConfig,a as defaultConfig,f as config};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{tb as c,ub as d,vb as e}from"./chunk-dzgms5s6.js";import"./chunk-thhd43x5.js";import"./chunk-2n1bbm2c.js";import{ic as a,jc as b}from"./chunk-x4v9kajr.js";import"./chunk-rsv17jh8.js";import"./chunk-d1xj2pjv.js";import"./chunk-vpjw38x7.js";import"./chunk-285mqzvx.js";import"./chunk-3w5aqasc.js";import"./chunk-gssantc8.js";import"./chunk-mcdb3q06.js";export{e as watch,a as processSource,d as processFile,c as generate,b as clearResultCache};
@@ -0,0 +1,24 @@
1
+ // @bun
2
+ function y(M){return M===32||M===9||M===10||M===13}function Bj(M){return M>=65&&M<=90||M>=97&&M<=122||M===95||M===36||M>127}function W(M){return Bj(M)||M>=48&&M<=57}function hj(M){if(M.charCodeAt(0)===82&&M.startsWith("Record<"))return!0;if(M.charCodeAt(0)===65&&M.startsWith("Array<"))return!0;if(M.charCodeAt(0)===123&&M.includes("[")&&M.includes("]:"))return!0;if(M==="any"||M==="object"||M==="unknown")return!0;return!1}var qj=["public","protected","private","readonly","override"];function mj(M,jj,T=!0,l=!1){let Z=M,c=T,b=l,K=Z.length,L=[],P=new Map,x=new Set,j=0;if(j<K&&Z.charCodeAt(j)===65279)j++;function w(J,H){if(J<H){let U=Z.charCodeAt(J),X=Z.charCodeAt(H-1);if(U!==32&&U!==9&&U!==10&&U!==13&&X!==32&&X!==9&&X!==10&&X!==13)return Z.slice(J,H)}while(J<H&&y(Z.charCodeAt(J)))J++;while(H>J&&y(Z.charCodeAt(H-1)))H--;return Z.slice(J,H)}function O(){if(j>=K)return;let J=Z.charCodeAt(j);if(J!==32&&J!==9&&J!==10&&J!==13&&J!==47)return;while(j<K){let H=Z.charCodeAt(j);if(H===32||H===9||H===10||H===13){j++;continue}if(H===47&&j+1<K){let U=Z.charCodeAt(j+1);if(U===47){let X=Z.indexOf(`
3
+ `,j+2);j=X===-1?K:X+1;continue}if(U===42){let X=Z.indexOf("*/",j+2);j=X===-1?K:X+2;continue}}break}}function Ij(J){let H=J.length,U=0,X=H;for(let Y=0;Y<H;Y++){let $=J.charCodeAt(Y);if(U){if($===92){Y++;continue}if($===U)U=0;continue}if($===39||$===34||$===96){U=$;continue}if($===47&&Y+1<H){let F=J.charCodeAt(Y+1);if(F===47){X=Y;while(X>0&&(J.charCodeAt(X-1)===32||J.charCodeAt(X-1)===9))X--;return J.slice(0,X)}if(F===42){let N=J.indexOf("*/",Y+2);if(N!==-1){J=`${J.slice(0,Y)} ${J.slice(N+2)}`,Y--;continue}}}}X=H;while(X>0&&(J.charCodeAt(X-1)===32||J.charCodeAt(X-1)===9||J.charCodeAt(X-1)===13))X--;return X<H?J.slice(0,X):J}function h(J){j++;let H=J===39?"'":'"';while(j<K){let U=Z.indexOf(H,j);if(U===-1){j=K;return}let X=0,Y=U-1;while(Y>=0&&Z.charCodeAt(Y)===92)X++,Y--;if(X%2===0){j=U+1;return}j=U+1}}function s(){j++;let J=[];while(j<K){let H=Z.charCodeAt(j);if(J.length===0){if(H===92){j+=2;continue}if(H===96){j++;return}if(H===36&&j+1<K&&Z.charCodeAt(j+1)===123){j+=2,J.push(0);continue}j++;continue}if(H===39||H===34){h(H);continue}if(H===96){s();continue}if(H===47&&j+1<K){let U=Z.charCodeAt(j+1);if(U===47){let X=Z.indexOf(`
4
+ `,j+2);j=X===-1?K:X+1;continue}if(U===42){let X=Z.indexOf("*/",j+2);j=X===-1?K:X+2;continue}j++;continue}if(H===123){J[J.length-1]++,j++;continue}if(H===125){let U=J[J.length-1];if(U===0){J.pop(),j++;continue}J[J.length-1]=U-1,j++;continue}j++}}function E(){let J=Z.charCodeAt(j);if(J===39||J===34)return h(J),!0;if(J===96)return s(),!0;if(J===47&&j+1<K){let H=Z.charCodeAt(j+1);if(H===47){let U=Z.indexOf(`
5
+ `,j+2);return j=U===-1?K:U+1,!0}if(H===42){let U=Z.indexOf("*/",j+2);return j=U===-1?K:U+2,!0}if(fj())return Ej(),!0}return!1}function fj(){let J=j-1;while(J>=0&&(Z.charCodeAt(J)===32||Z.charCodeAt(J)===9||Z.charCodeAt(J)===10||Z.charCodeAt(J)===13))J--;if(J<0)return!0;let H=Z.charCodeAt(J);if(H===61||H===40||H===91||H===33||H===38||H===124||H===63||H===58||H===44||H===59||H===123||H===125||H===94||H===126||H===43||H===45||H===42||H===37||H===60||H===62)return!0;if(W(H)){let U=J;while(U>=0&&W(Z.charCodeAt(U)))U--;let X=Z.slice(U+1,J+1);if(X==="return"||X==="typeof"||X==="void"||X==="delete"||X==="throw"||X==="new"||X==="in"||X==="of"||X==="case"||X==="instanceof"||X==="yield"||X==="await")return!0}return!1}function Ej(){j++;let J=!1;while(j<K){let H=Z.charCodeAt(j);if(H===92){j+=2;continue}if(J){if(H===93)J=!1;j++;continue}if(H===91){J=!0,j++;continue}if(H===47){j++;break}if(H===10||H===13)break;j++}while(j<K&&W(Z.charCodeAt(j)))j++}function f(){let J=j;while(j<K&&W(Z.charCodeAt(j)))j++;return Z.slice(J,j)}function z(J){if(j+J.length>K)return!1;for(let H=0;H<J.length;H++)if(Z.charCodeAt(j+H)!==J.charCodeAt(H))return!1;if(j+J.length<K&&W(Z.charCodeAt(j+J.length)))return!1;return!0}function Hj(J){let H=j+J;while(H<K){let U=Z.charCodeAt(H);if(U===32||U===9||U===10||U===13){H++;continue}return U!==46&&U!==61}return!1}function yj(){if(j>=K)return!1;switch(Z.charCodeAt(j)){case 101:return z("export")||z("enum");case 105:return z("import")||z("interface");case 102:return z("function");case 99:return z("class")||z("const");case 116:return z("type");case 108:return z("let");case 118:return z("var");case 100:return z("declare")||z("default");case 109:return z("module");case 110:return z("namespace");case 97:return z("abstract")||z("async");default:return!1}}function p(){let J=Z.charCodeAt(j);if(J!==10&&J!==13)return!1;let H=j;if(j++,J===13&&j<K&&Z.charCodeAt(j)===10)j++;while(j<K){let X=Z.charCodeAt(j);if(X===32||X===9||X===13||X===10){j++;continue}if(X===47&&j+1<K){let Y=Z.charCodeAt(j+1);if(Y===47){let $=Z.indexOf(`
6
+ `,j+2);j=$===-1?K:$+1;continue}if(Y===42){let $=Z.indexOf("*/",j+2);j=$===-1?K:$+2;continue}}break}let U=j>=K||yj()||Z.charCodeAt(j)===125;return j=H,U}function t(){let J=Z.charCodeAt(j);if(J!==10&&J!==13)return!1;let H=j;if(j++,J===13&&j<K&&Z.charCodeAt(j)===10)j++;while(j<K){let X=Z.charCodeAt(j);if(X===32||X===9||X===13||X===10){j++;continue}if(X===47&&j+1<K&&Z.charCodeAt(j+1)===47){let Y=Z.indexOf(`
7
+ `,j+2);j=Y===-1?K:Y+1;continue}break}if(j>=K)return j=H,!0;let U=Z.charCodeAt(j);if(U===124||U===38||U===46||U===63||U===58)return j=H,!1;if(z("extends")||z("keyof")||z("typeof")||z("infer")||z("is")||z("as")||z("in"))return j=H,!1;return j=H,!0}let Aj=/[{}'"`\/]/g,Tj=/[()'"`\/]/g,kj=/[[\]'"`\/]/g,Cj=/[<>'"`\/]/g;function A(J,H){let U=1;j++;let X=J===123?Aj:J===40?Tj:J===91?kj:Cj;X.lastIndex=j;let Y;while((Y=X.exec(Z))!==null){let $=Y.index,F=Z.charCodeAt($);if(F===39||F===34){j=$,h(F),X.lastIndex=j;continue}if(F===96){j=$,s(),X.lastIndex=j;continue}if(F===47){if(j=$,E()){X.lastIndex=j;continue}X.lastIndex=$+1;continue}if(F===J)U++;else if(F===H){if(H===62&&$>0&&Z.charCodeAt($-1)===61){X.lastIndex=$+1;continue}if(U--,U===0)return j=$+1,j}X.lastIndex=$+1}return j=K,j}function S(){return j>0&&Z.charCodeAt(j-1)===61}function Xj(){return j+1<K&&Z.charCodeAt(j+1)===62}let k=/[{};'"`\/\n\r()[\]]/g;function I(){let J=0,H=0,U=0;k.lastIndex=j;let X;while((X=k.exec(Z))!==null){let Y=X.index,$=Z.charCodeAt(Y);if($===39||$===34){j=Y,h($),k.lastIndex=j;continue}if($===96){j=Y,s(),k.lastIndex=j;continue}if($===47){if(j=Y,E()){k.lastIndex=j;continue}k.lastIndex=Y+1;continue}if($===40){H++,k.lastIndex=Y+1;continue}if($===41){H--,k.lastIndex=Y+1;continue}if($===91){U++,k.lastIndex=Y+1;continue}if($===93){U--,k.lastIndex=Y+1;continue}if($===123){J++,k.lastIndex=Y+1;continue}if($===125){if(J--,J<=0&&H<=0&&U<=0){j=Y+1;return}k.lastIndex=Y+1;continue}if($===59&&J===0&&H===0&&U===0){j=Y+1;return}if(($===10||$===13)&&J===0&&H===0&&U===0){if(j=Y,p())return}k.lastIndex=Y+1}j=K}function Nj(){A(123,125);while(j<K&&y(Z.charCodeAt(j)))j++;if(z("from")){j+=4;while(j<K&&y(Z.charCodeAt(j)))j++;if(j<K){let J=Z.charCodeAt(j);if(J===39||J===34)h(J)}}while(j<K&&(Z.charCodeAt(j)===32||Z.charCodeAt(j)===9))j++;if(j<K&&Z.charCodeAt(j)===59)j++}function Rj(){j++;while(j<K&&y(Z.charCodeAt(j)))j++;if(z("as")){j+=2;while(j<K&&y(Z.charCodeAt(j)))j++;f();while(j<K&&y(Z.charCodeAt(j)))j++}if(z("from")){j+=4;while(j<K&&y(Z.charCodeAt(j)))j++;if(j<K){let J=Z.charCodeAt(j);if(J===39||J===34)h(J)}}while(j<K&&(Z.charCodeAt(j)===32||Z.charCodeAt(j)===9))j++;if(j<K&&Z.charCodeAt(j)===59)j++}function Jj(J){let H=J.indexOf("from ");if(H===-1)return;let U=H+5;while(U<J.length&&(J.charCodeAt(U)===32||J.charCodeAt(U)===9))U++;if(U>=J.length)return;let X=J.charCodeAt(U);if(X!==39&&X!==34)return;let Y=J.indexOf(J[U],U+1);if(Y===-1)return;return J.slice(U+1,Y)}function C(J){if(!c)return;let H=J-1;while(H>=0&&y(Z.charCodeAt(H)))H--;if(H<0)return;let U=[],X=!1;while(H>=0){if(H>=1&&Z.charCodeAt(H)===47&&Z.charCodeAt(H-1)===42){let F=Z.lastIndexOf("/*",H-2);if(F>=0){U.push(Z.slice(F,H+1)),X=!0,H=F-1;while(H>=0&&y(Z.charCodeAt(H)))H--;continue}break}let Y=H;while(Y>0&&Z.charCodeAt(Y-1)!==10)Y--;let $=w(Y,H+1);if($.startsWith("//")){if(X)break;let F=[$];H=Y-1;while(H>=0&&(Z.charCodeAt(H)===10||Z.charCodeAt(H)===13))H--;while(H>=0){let N=H;while(N>0&&Z.charCodeAt(N-1)!==10)N--;let V=w(N,H+1);if(V.startsWith("//")){F.push(V),H=N-1;while(H>=0&&(Z.charCodeAt(H)===10||Z.charCodeAt(H)===13))H--}else if(V===""){H=N-1;while(H>=0&&(Z.charCodeAt(H)===10||Z.charCodeAt(H)===13))H--}else break}F.reverse(),U.push(F.join(`
8
+ `));continue}break}if(U.length===0)return;return U.reverse(),U}function Sj(J){let H=J,U=!1;while(j<K){let V=Z.charCodeAt(j);if(V===59){j++;break}if(V===39||V===34){h(V),U=!0;while(j<K&&(Z.charCodeAt(j)===32||Z.charCodeAt(j)===9))j++;if(j<K&&Z.charCodeAt(j)===59)j++;break}if(V===10&&U)break;j++}let X=w(H,j),Y=X.charCodeAt(7)===116&&(X.startsWith("import type ")||X.startsWith("import type{")),$=!1;{let V=6;while(V<X.length&&(X.charCodeAt(V)===32||X.charCodeAt(V)===9))V++;if(V<X.length&&X.charCodeAt(V)===116&&X.startsWith("type",V)){V+=4;while(V<X.length&&(X.charCodeAt(V)===32||X.charCodeAt(V)===9))V++}if(V<X.length){let Q=X.charCodeAt(V);$=Q===39||Q===34}}let F="";{let V=X.indexOf("from ");if(V!==-1){let Q=V+5;while(Q<X.length&&(X.charCodeAt(Q)===32||X.charCodeAt(Q)===9))Q++;if(Q<X.length){let G=X.charCodeAt(Q);if(G===39||G===34){let B=X.indexOf(String.fromCharCode(G),Q+1);if(B!==-1)F=X.slice(Q+1,B)}}}else if($){let Q=6;while(Q<X.length&&X.charCodeAt(Q)!==39&&X.charCodeAt(Q)!==34)Q++;if(Q<X.length){let G=X.charCodeAt(Q),B=X.indexOf(String.fromCharCode(G),Q+1);if(B!==-1)F=X.slice(Q+1,B)}}}let N=C(H);return{kind:"import",name:"",text:X,isExported:!1,isTypeOnly:Y,isSideEffect:$,source:F,leadingComments:N,start:H,end:j}}function Yj(){let J=j;return A(123,125),Z.slice(J,j)}function _j(J){let H=J.indexOf("(");if(H===-1)return J;let U=J.slice(H);if(U.indexOf("=")===-1)return J;let X=!1;for(let V=0;V<U.length;V++)if(U.charCodeAt(V)===61){let G=V>0?U.charCodeAt(V-1):0,B=V+1<U.length?U.charCodeAt(V+1):0;if(G!==61&&G!==33&&G!==60&&G!==62&&B!==61&&B!==62){X=!0;break}}if(!X)return J;let Y=0,$=-1;for(let V=H;V<J.length;V++){let Q=J.charCodeAt(V);if(Q===40)Y++;else if(Q===41){if(Y--,Y===0){$=V;break}}}if($===-1)return J;let F=J.slice(H,$+1),N=n(F);return J.slice(0,H)+N+J.slice($+1)}function gj(J){let H=J.indexOf("//")!==-1||J.indexOf("/*")!==-1,U=J.split(`
9
+ `),X=[],Y=[],$=[],F=!1,N=1/0;for(let G=0;G<U.length;G++){let B=U[G];if(H){if(F){if(B.includes("*/"))F=!1;continue}let _=B.trim();if(_.length===0)continue;let R=_.charCodeAt(0);if(R===47){let v=_.charCodeAt(1);if(v===47)continue;if(v===42){if(!_.includes("*/"))F=!0;continue}}if(R===42)continue;let q=Ij(B);if(q.charCodeAt(q.length-1)===59)q=q.slice(0,-1);q=_j(q);let g=q.trim();if(!g)continue;X.push(q),Y.push(g);let D=0;while(D<q.length&&y(q.charCodeAt(D)))D++;if(g!=="{"&&g!=="}"){if(D<N)N=D}$.push(D)}else{let _=B.length;while(_>0&&(B.charCodeAt(_-1)===32||B.charCodeAt(_-1)===9||B.charCodeAt(_-1)===13))_--;if(_===0)continue;let R=_<B.length?B.slice(0,_):B;if(R.charCodeAt(R.length-1)===59)R=R.slice(0,-1);R=_j(R);let q=R.trim();if(!q)continue;X.push(R),Y.push(q);let g=0;while(g<R.length&&y(R.charCodeAt(g)))g++;if(q!=="{"&&q!=="}"){if(g<N)N=g}$.push(g)}}if(X.length===0)return"{}";if(N===1/0||N<=2)return X.join(`
10
+ `);let V=N-2,Q=Array(X.length);for(let G=0;G<X.length;G++){let B=Y[G];if(B==="{"){Q[G]=B;continue}let _=$[G];if(_>N)Q[G]=X[G];else if(_===N&&(B.charCodeAt(0)===125||B.charCodeAt(0)===93||B.charCodeAt(0)===41))Q[G]=X[G];else{let R=Math.max(0,_-V);Q[G]=" ".repeat(R)+B}}return Q.join(`
11
+ `)}function u(){if(j>=K||Z.charCodeAt(j)!==60)return"";let J=j;A(60,62);let H=Z.slice(J,j);if(H.includes(`
12
+ `)){let U="",X=!1;for(let Y=0;Y<H.length;Y++){let $=H.charCodeAt(Y);if($===32||$===9||$===10||$===13){if(!X&&U.length>0)U+=" ",X=!0}else U+=H[Y],X=!1}if(U.charCodeAt(1)===32)U=`<${U.slice(2)}`;if(U.charCodeAt(U.length-2)===32)U=`${U.slice(0,-2)}>`;return U}return H}function m(){if(j>=K||Z.charCodeAt(j)!==40)return"()";let J=j;return A(40,41),Z.slice(J,j)}function n(J){let H=J.slice(1,-1).trim();if(!H)return"()";if(J.indexOf(`
13
+ `)===-1&&H.indexOf(":")!==-1&&H.indexOf("{")===-1&&H.indexOf("[")===-1&&H.indexOf("=")===-1&&H.indexOf("@")===-1&&H.indexOf("...")===-1){let V=0,Q=0,G=0;for(let B=0;B<H.length;B++){let _=H.charCodeAt(B);if(_===40||_===60||_===123)G++;else if(_===41||_===62||_===125)G--;else if(G===0){if(_===58)V++;else if(_===44)Q++}}if(V>=Q+1){let B=!1;for(let _=0;_<qj.length;_++){let R=qj[_],q=H.indexOf(R);if(q!==-1){let g=q+R.length;if((q===0||!W(H.charCodeAt(q-1)))&&(g>=H.length||!W(H.charCodeAt(g)))){B=!0;break}}}if(!B)return J}}let U=[],X=0,Y=0,$=!1,F=0;for(let V=0;V<=H.length;V++){if(V===H.length){U.push(H.slice(X).trim());break}let Q=H.charCodeAt(V);if($){if(Q===92){V++;continue}if(Q===F)$=!1;continue}if(Q===39||Q===34||Q===96){$=!0,F=Q;continue}if(Q===40||Q===123||Q===91||Q===60)Y++;else if(Q===41||Q===125||Q===93||Q===62&&!(V>0&&H.charCodeAt(V-1)===61))Y--;else if(Q===44&&Y===0)U.push(H.slice(X,V).trim()),X=V+1}let N=[];for(let V of U){if(!V)continue;let Q=V.trim();if(Q.startsWith("//")||Q.startsWith("/*"))continue;let G=V;{let B=!1,_=0;for(let R=0;R<G.length-1;R++){let q=G.charCodeAt(R);if(B){if(q===92){R++;continue}if(q===_)B=!1;continue}if(q===39||q===34||q===96){B=!0,_=q;continue}if(q===47&&G.charCodeAt(R+1)===47){G=G.slice(0,R).trimEnd();break}}}if(!G.trim())continue;N.push(Lj(G))}return`(${N.join(", ")})`}function Wj(J){if(!J.startsWith("{")&&!J.startsWith("["))return J;let H="",U=0,X=0,Y=!1,$=0;while(U<J.length){let F=J.charCodeAt(U);if(Y){if(F===92&&U+1<J.length){H+=J[U]+J[U+1],U+=2;continue}if(F===$)Y=!1;H+=J[U],U++;continue}if(F===39||F===34||F===96){Y=!0,$=F,H+=J[U],U++;continue}if(F===123||F===91||F===40)X++;else if(F===125||F===93||F===41)X--;if(X>=1&&F===61&&(U+1>=J.length||J.charCodeAt(U+1)!==61&&J.charCodeAt(U+1)!==62)){while(H.length>0&&(H[H.length-1]===" "||H[H.length-1]==="\t"||H[H.length-1]===`
14
+ `))H=H.slice(0,-1);U++;let N=0;while(U<J.length){let V=J.charCodeAt(U);if(V===39||V===34||V===96){let Q=V;U++;while(U<J.length){if(J.charCodeAt(U)===92){U+=2;continue}if(J.charCodeAt(U)===Q){U++;break}U++}continue}if(V===123||V===91||V===40)N++;else if(V===125||V===93||V===41){if(N===0)break;N--}else if(V===44&&N===0)break;U++}continue}if(X===1&&F===46&&U+2<J.length&&J.charCodeAt(U+1)===46&&J.charCodeAt(U+2)===46){U+=3;continue}H+=J[U],U++}return H}function Lj(J){let H=J.trim(),U=H.startsWith("...");if(U)H=H.slice(3).trim();while(H.startsWith("@")){let q=1;while(q<H.length&&W(H.charCodeAt(q)))q++;if(q<H.length&&H.charCodeAt(q)===40){let g=1;q++;while(q<H.length&&g>0){if(H.charCodeAt(q)===40)g++;else if(H.charCodeAt(q)===41)g--;q++}}H=H.slice(q).trim()}let X=!0;while(X){X=!1;for(let q of qj)if(H.startsWith(q)&&H.length>q.length&&!W(H.charCodeAt(q.length))){let g=H.slice(q.length).trim();if(g.charCodeAt(0)===58||g.charCodeAt(0)===63&&g.length>1&&g.charCodeAt(1)===58)break;H=g,X=!0;break}}let Y=-1,$=-1,F=0,N=!1,V=0;for(let q=0;q<H.length;q++){let g=H.charCodeAt(q);if(N){if(g===92){q++;continue}if(g===V)N=!1;continue}if(g===39||g===34||g===96){N=!0,V=g;continue}if(g===40||g===123||g===91||g===60)F++;else if(g===41||g===125||g===93||g===62&&!(q>0&&H.charCodeAt(q-1)===61))F--;else if(F===0){if(g===58&&Y===-1)Y=q;else if(g===61&&$===-1&&(q===0||H.charCodeAt(q-1)!==61)&&(q+1>=H.length||H.charCodeAt(q+1)!==61&&H.charCodeAt(q+1)!==62))$=q}}let Q,G,B=$!==-1;if(Y!==-1&&($===-1||Y<$))if(Q=H.slice(0,Y).trim(),$!==-1)G=H.slice(Y+1,$).trim();else G=H.slice(Y+1).trim();else if($!==-1)Q=H.slice(0,$).trim(),G=Zj(H.slice($+1).trim());else Q=H,G="unknown";if(Q=Wj(Q),(Q.startsWith("{")||Q.startsWith("["))&&Q.includes(`
15
+ `)){let q=Q.replace(/\s*\n\s*/g," ").replace(/\s+/g," ");if(q.length<=40)Q=q;else Q=Q.split(`
16
+ `).map((D)=>{let v=D.trim();if(!v)return"";if(v==="{"||v==="}"||v==="["||v==="]"||v.startsWith("}")||v.startsWith("]"))return v;return` ${v}`}).join(`
17
+ `)}let _=Q.endsWith("?")||B;if(Q.endsWith("?"))Q=Q.slice(0,-1).trim();let R=_&&!U?"?":"";if(U)return`...${Q}: ${G}`;return`${Q}${R}: ${G}`}function Mj(J){let H=0;if(H<J.length&&J.charCodeAt(H)===45)H++;if(H>=J.length)return!1;let U=J.charCodeAt(H);if(U<48||U>57)return!1;while(H<J.length&&J.charCodeAt(H)>=48&&J.charCodeAt(H)<=57)H++;if(H<J.length&&J.charCodeAt(H)===46){if(H++,H>=J.length||J.charCodeAt(H)<48||J.charCodeAt(H)>57)return!1;while(H<J.length&&J.charCodeAt(H)>=48&&J.charCodeAt(H)<=57)H++}return H===J.length}function Zj(J){let H=J.trim();if(H==="true"||H==="false")return"boolean";if(Mj(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 $j(J){let H=J.trim();if(H==="true"||H==="false")return H;if(Mj(H))return H;if(H.startsWith("'")&&H.endsWith("'")||H.startsWith('"')&&H.endsWith('"'))return H;return"unknown"}function Qj(J){if(J.endsWith("as const"))return null;let H=0,U=-1;for(let Y=0;Y<J.length;Y++){let $=J.charCodeAt(Y);if($===123||$===91||$===40)H++;else if($===125||$===93||$===41)H--;else if(H===0&&$===32&&Y+4<=J.length&&J.substring(Y,Y+4)===" as ")U=Y}if(U===-1)return null;return J.slice(U+4).trim()||null}function e(){if(O(),j<K&&Z.charCodeAt(j)===58){j++,O();let J=j,H=0;while(j<K){if(E())continue;let U=Z.charCodeAt(j);if(U===40||U===91||U===60)H++;else if(U===41||U===93||U===62&&!S())H--;else if(U===123)if(H>0)H++;else{let X=w(J,j),Y=($)=>{let F=X.length-$.length;return F>=0&&X.endsWith($)&&(F===0||!W(X.charCodeAt(F-1)))};if(X.length===0||X.endsWith("|")||X.endsWith("&")||Y("is")||Y("extends"))H++;else break}else if(U===125){if(H===0)break;H--}else if(H===0&&U===59)break;if(H===0&&t())break;j++}return w(J,j)}return""}function d(J,H,U,X){j+=8,O();let Y=j<K&&Z.charCodeAt(j)===42;if(Y)j++,O();let $=f();if(!$&&!X)return null;O();let F=u();O();let N=m();O();let V=e();if(!V)if(U&&Y)V="AsyncGenerator<unknown, void, unknown>";else if(Y)V="Generator<unknown, void, unknown>";else if(U)V="Promise<void>";else V="void";O();let Q=!1;if(j<K&&Z.charCodeAt(j)===123)Q=!0,A(123,125);else if(j<K&&Z.charCodeAt(j)===59)j++;let G=n(N),B=`${H?"export ":""}declare function ${$||"default"}${F}${G}: ${V};`,_=C(J);if(Q)x.add(L.length);return{kind:"function",name:$||"default",text:B,isExported:H,isDefault:X,isAsync:U,isGenerator:Y,returnType:V,generics:F||void 0,leadingComments:_,start:J,end:j}}function r(J,H,U){j+=H.length,O();let X=[];do{if(O(),j>=K)break;let Y=Z.charCodeAt(j);if(Y===123||Y===91)return I(),X;let $=f();if(!$)return I(),X;O();let F,N,V=!1;if(j<K&&Z.charCodeAt(j)===58){j++,O();let B=j,_=0;while(j<K){if(E())continue;let R=Z.charCodeAt(j);if(R===40||R===123||R===91||R===60)_++;else if(R===41||R===125||R===93||R===62&&!S())_--;else if(_===0&&(R===59||R===44))break;else if(_===0&&R===61&&!Xj())break;if(_===0&&p())break;j++}F=w(B,j)}if(j<K&&Z.charCodeAt(j)===61)if(b&&F&&!hj(F))I();else{j++,O();let B=j,_=0,R=0;while(j<K){if(E())continue;let q=Z.charCodeAt(j);if(q===40||q===123||q===91)_++;else if(q===41||q===125||q===93)_--;else if(q===60&&_===0){if(j+1>=K||Z.charCodeAt(j+1)!==61)R++}else if(q===62&&_===0&&!S()){if(R>0&&(j+1>=K||Z.charCodeAt(j+1)!==61))R--}else if(_===0&&R===0&&(q===59||q===44))break;if(_===0&&R===0&&p())break;j++}if(N=w(B,j),N.endsWith(" as const")||N==="const"){if(V=!0,!F){let q=N.endsWith(" as const")?N.slice(0,-9).trim():N,g=$j(q);F=g!=="unknown"?g:void 0}}else if(!F){let q=Qj(N);if(q)F=q}}if(j<K){let B=Z.charCodeAt(j);if(B===44){j++;continue}if(B===59)j++}let Q=C(J),G=`${U?"export ":""}declare ${H} ${$}: ${F||"unknown"};`;X.push({kind:"variable",name:$,text:G,isExported:U,typeAnnotation:F,value:N,modifiers:V?[H,"const assertion"]:[H],leadingComments:Q,start:J,end:j});break}while(j<K);return X}function Kj(J,H){j+=9,O();let U=f();O();let X=u();O();let Y="";if(z("extends")){j+=7,O();let Q=j,G=0;while(j<K){if(E())continue;let B=Z.charCodeAt(j);if(B===60)G++;else if(B===62&&!S())G--;else if(B===123&&G===0)break;j++}Y=w(Q,j)}O();let $=j<K&&Z.charCodeAt(j)===123?Yj():"{}",F=gj($),N=`${H?"export ":""}declare interface ${U}${X}${Y?` extends ${Y}`:""} ${F}`,V=C(J);return{kind:"interface",name:U,text:N,isExported:H,extends:Y||void 0,generics:X||void 0,leadingComments:V,start:J,end:j}}function Vj(J,H){j+=4,O();let U=f();O();let X=u();if(O(),j<K&&Z.charCodeAt(j)===61)j++;O();let Y=j,$=0;while(j<K){if(E())continue;let Q=Z.charCodeAt(j);if(Q===40||Q===123||Q===91||Q===60)$++;else if(Q===41||Q===125||Q===93||Q===62&&!S())$--;else if($===0&&Q===59)break;if($===0&&p())break;j++}let F=w(Y,j);if(j<K&&Z.charCodeAt(j)===59)j++;let N=`${H?"export ":""}type ${U}${X} = ${F}`,V=C(J);return{kind:"type",name:U,text:N,isExported:H,generics:X||void 0,leadingComments:V,start:J,end:j}}function i(J,H,U){j+=4,O();let X=f();O();let Y=j;if(j<K&&Z.charCodeAt(j)===123)A(123,125);let $=w(J,j),F=C(J);return{kind:"enum",name:X,text:$,isExported:H,modifiers:U?["const"]:void 0,leadingComments:F,start:J,end:j}}function a(J,H,U){j+=5,O();let X=f()||"AnonymousClass";O();let Y=u();O();let $="";if(z("extends")){j+=7,O();let G=j,B=0;while(j<K){if(E())continue;let _=Z.charCodeAt(j);if(_===60)B++;else if(_===62&&!S())B--;else if(B===0&&(_===123||z("implements")))break;j++}$=w(G,j)}let F;if(z("implements")){j+=10,O();let G=j,B=0;while(j<K){if(E())continue;let R=Z.charCodeAt(j);if(R===60)B++;else if(R===62&&!S())B--;else if(B===0&&R===123)break;j++}let _=w(G,j);if(_)F=_.split(",").map((R)=>R.trim())}O();let N=zj(),V=`${H?"export ":""}declare ${U?"abstract ":""}class ${X}${Y}${$?` extends ${$}`:""}${F&&F.length>0?` implements ${F.join(", ")}`:""} ${N}`,Q=C(J);return{kind:"class",name:X,text:V,isExported:H,extends:$||void 0,implements:F,generics:Y||void 0,modifiers:U?["abstract"]:void 0,leadingComments:Q,start:J,end:j}}function zj(){if(j>=K||Z.charCodeAt(j)!==123)return"{}";j++;let J=[];while(j<K){if(O(),j>=K)break;if(Z.charCodeAt(j)===125){j++;break}if(Z.charCodeAt(j)===59){j++;continue}if(z("static")&&Dj("static")===123){j+=6,O(),A(123,125);continue}let H=!1,U=!1,X=!1,Y=!1,$=!1,F=!1,N=!1,V=!1,Q=!0;while(Q){if(O(),z("private")){H=!0,j+=7;continue}if(z("protected")){U=!0,j+=9;continue}if(z("public")){j+=6;continue}if(z("static")){X=!0,j+=6;continue}if(z("abstract")){Y=!0,j+=8;continue}if(z("readonly")){$=!0,j+=8;continue}if(z("override")){F=!0,j+=8;continue}if(z("accessor")){N=!0,j+=8;continue}if(z("async")){V=!0,j+=5;continue}if(z("declare")){j+=7;continue}break}if(O(),j>=K||Z.charCodeAt(j)===125)break;if(Z.charCodeAt(j)===35)H=!0;if(H){Fj();continue}let G=" ";if(U)G+="protected ";if(X)G+="static ";if(Y)G+="abstract ";if($)G+="readonly ";if(z("constructor")){j+=11,O();let B=m();if(O(),uj(B,J),j<K&&Z.charCodeAt(j)===123)A(123,125);else if(j<K&&Z.charCodeAt(j)===59)j++;let _=n(B);J.push(` constructor${_};`)}else if(z("get"))if(j+=3,O(),j<K&&(Bj(Z.charCodeAt(j))||Z.charCodeAt(j)===91||Z.charCodeAt(j)===35)){let B=Oj();if(B.startsWith("#")){if(O(),j<K&&Z.charCodeAt(j)===40)m();if(O(),e(),O(),j<K&&Z.charCodeAt(j)===123)A(123,125);else if(j<K&&Z.charCodeAt(j)===59)j++;continue}O(),m(),O();let _=e()||"unknown";if(O(),j<K&&Z.charCodeAt(j)===123)A(123,125);else if(j<K&&Z.charCodeAt(j)===59)j++;J.push(`${G}get ${B}(): ${_};`)}else Pj("get",G,X,$,V,J);else if(z("set"))if(j+=3,O(),j<K&&(Bj(Z.charCodeAt(j))||Z.charCodeAt(j)===91||Z.charCodeAt(j)===35)){let B=Oj();if(B.startsWith("#")){if(O(),j<K&&Z.charCodeAt(j)===40)m();if(O(),j<K&&Z.charCodeAt(j)===123)A(123,125);else if(j<K&&Z.charCodeAt(j)===59)j++;continue}O();let _=m();if(O(),j<K&&Z.charCodeAt(j)===123)A(123,125);else if(j<K&&Z.charCodeAt(j)===59)j++;let R=n(_);J.push(`${G}set ${B}${R};`)}else Pj("set",G,X,$,V,J);else{let B=Z.charCodeAt(j)===42;if(B)j++,O();let _=Oj();if(!_){Fj();continue}bj(_,G,X,$,B,Y,V,J)}}return`{
18
+ ${J.join(`
19
+ `)}
20
+ }`}function Oj(){if(j>=K)return"";let J=Z.charCodeAt(j);if(J===91){let H=j;return A(91,93),Z.slice(H,j)}if(J===35)return j++,`#${f()}`;return f()}function Dj(J){let H=j+J.length;while(H<K&&y(Z.charCodeAt(H)))H++;return H<K?Z.charCodeAt(H):0}function Fj(){let J=0;while(j<K){if(E())continue;let H=Z.charCodeAt(j);if(H===123||H===40)J++;else if(H===125||H===41){if(J===0)return;J--}else if(H===59&&J===0){j++;return}if(J===0&&t())return;j++}}function Pj(J,H,U,X,Y,$){bj(J,H,U,X,!1,!1,Y,$)}function bj(J,H,U,X,Y,$,F,N){if(O(),j>=K)return;let V=Z.charCodeAt(j),Q=!1;if(V===63)Q=!0,j++,O();if(j<K&&Z.charCodeAt(j)===33)j++,O();let G=j<K?Z.charCodeAt(j):0;if(G===40||G===60){let B=G===60?u():"";O();let _=m();O();let R=e();if(!R)if(F&&Y)R="AsyncGenerator<unknown, void, unknown>";else if(Y)R="Generator<unknown, void, unknown>";else if(F)R="Promise<void>";else R="void";if(O(),j<K&&Z.charCodeAt(j)===123)A(123,125);else if(j<K&&Z.charCodeAt(j)===59)j++;let q=n(_),g=Q?"?":"",D=Y?"*":"";N.push(`${H}${D}${J}${g}${B}${q}: ${R};`)}else if(G===58||G===61||G===59||G===125||G===10||G===13){let B="";if(G===58){j++,O();let q=j,g=0;while(j<K){if(E())continue;let D=Z.charCodeAt(j);if(D===40||D===123||D===91||D===60)g++;else if(D===41||D===125||D===93||D===62&&!S()){if(g===0)break;g--}else if(g===0&&(D===59||D===44))break;else if(g===0&&D===61&&!Xj())break;if(g===0&&t())break;j++}B=w(q,j)}let _="";if(j<K&&Z.charCodeAt(j)===61)if(b&&B){j++;let q=0;while(j<K){if(E())continue;let g=Z.charCodeAt(j);if(g===40||g===123||g===91)q++;else if(g===41||g===125||g===93){if(q===0&&g===125)break;q--}else if(q===0&&g===59)break;if(q===0&&t())break;j++}}else{j++,O();let q=j,g=0;while(j<K){if(E())continue;let D=Z.charCodeAt(j);if(D===40||D===123||D===91)g++;else if(D===41||D===125||D===93){if(g===0&&D===125)break;g--}else if(g===0&&D===59)break;if(g===0&&t())break;j++}_=w(q,j)}if(j<K&&Z.charCodeAt(j)===59)j++;if(!B)if(_){let q=Qj(_);if(q)B=q;else B=U&&X?$j(_):Zj(_)}else B="unknown";let R=Q?"?":"";N.push(`${H}${J}${R}: ${B};`)}else Fj()}function uj(J,H){let U=J.slice(1,-1).trim();if(!U)return;let X=[],Y=0,$=0,F=!1,N=0;for(let V=0;V<=U.length;V++){if(V===U.length){X.push(U.slice(Y).trim());break}let Q=U.charCodeAt(V);if(F){if(Q===92){V++;continue}if(Q===N)F=!1;continue}if(Q===39||Q===34||Q===96){F=!0,N=Q;continue}if(Q===40||Q===123||Q===91||Q===60)$++;else if(Q===41||Q===125||Q===93||Q===62&&!(V>0&&U.charCodeAt(V-1)===61))$--;else if(Q===44&&$===0)X.push(U.slice(Y,V).trim()),Y=V+1}for(let V of X){let Q=V.startsWith("public ")||V.startsWith("public\t"),G=V.startsWith("protected ")||V.startsWith("protected\t"),B=V.startsWith("private ")||V.startsWith("private\t"),_=V.includes("readonly ");if(!Q&&!G&&!B&&!_)continue;if(B)continue;let R=V,q=[];if(Q){let v=6;while(v<R.length&&y(R.charCodeAt(v)))v++;R=R.slice(v),q.push("public")}if(G){let v=9;while(v<R.length&&y(R.charCodeAt(v)))v++;R=R.slice(v),q.push("protected")}if(_){let v=R.indexOf("readonly ");if(v!==-1){let Uj=v+8;while(Uj<R.length&&y(R.charCodeAt(Uj)))Uj++;R=R.slice(0,v)+R.slice(Uj)}q.push("readonly")}let g=q.length>0?`${q.join(" ")} `:"",D=Lj(R);H.push(` ${g}${D};`)}}function Gj(J=" "){if(j>=K||Z.charCodeAt(j)!==123)return"{}";j++;let H=[];while(j<K){if(O(),j>=K)break;if(Z.charCodeAt(j)===125){j++;break}if(Z.charCodeAt(j)===59){j++;continue}let U=!1;if(z("export"))U=!0,j+=6,O();if(z("declare"))j+=7,O();let X=U?"export ":"";if(z("function")||z("async")&&xj("async","function")){let Y=!1;if(z("async"))Y=!0,j+=5,O();if(j+=8,O(),j<K&&Z.charCodeAt(j)===42)j++,O();let F=f();O();let N=u();O();let V=m();O();let Q=e();if(!Q)Q=Y?"Promise<void>":"void";if(O(),j<K&&Z.charCodeAt(j)===123)A(123,125);else if(j<K&&Z.charCodeAt(j)===59)j++;let G=n(V);H.push(`${J}${X}function ${F}${N}${G}: ${Q};`)}else if(z("const")||z("let")||z("var")){let Y=z("const")?"const":z("let")?"let":"var";j+=Y.length,O();let $=f();if(!$){I();continue}O();let F="";if(j<K&&Z.charCodeAt(j)===58){j++,O();let V=j,Q=0;while(j<K){if(E())continue;let G=Z.charCodeAt(j);if(G===40||G===123||G===91||G===60)Q++;else if(G===41||G===125||G===93||G===62&&!S())Q--;else if(Q===0&&(G===59||G===44))break;else if(Q===0&&G===61&&!Xj())break;if(Q===0&&p())break;j++}F=w(V,j)}let N="";if(j<K&&Z.charCodeAt(j)===61){j++,O();let V=j,Q=0;while(j<K){if(E())continue;let G=Z.charCodeAt(j);if(G===40||G===123||G===91||G===60)Q++;else if(G===41||G===125||G===93||G===62&&!S())Q--;else if(Q===0&&(G===59||G===44))break;if(Q===0&&p())break;j++}N=w(V,j)}if(j<K&&Z.charCodeAt(j)===59)j++;if(!F&&N){let V=Qj(N);if(V)F=V;else if(Y==="const")F=$j(N);else F=Zj(N)}if(!F)F="unknown";H.push(`${J}${X}${Y} ${$}: ${F};`)}else if(z("interface")){j+=9,O();let Y=f();O();let $=u();O();let F="";if(z("extends")){let V=j;while(j<K&&Z.charCodeAt(j)!==123){if(E())continue;j++}F=Z.slice(V,j)}let N=gj(Yj());H.push(`${J}${X}interface ${Y}${$}${F} ${N}`)}else if(z("type")){j+=4,O();let Y=f();O();let $=u();if(O(),j<K&&Z.charCodeAt(j)===61){j++,O();let F=j,N=0;while(j<K){if(E())continue;let Q=Z.charCodeAt(j);if(Q===40||Q===123||Q===91||Q===60)N++;else if(Q===41||Q===125||Q===93||Q===62&&!S())N--;else if(N===0&&Q===59)break;if(N===0&&p())break;j++}let V=w(F,j);if(j<K&&Z.charCodeAt(j)===59)j++;H.push(`${J}${X}type ${Y}${$} = ${V}`)}}else if(z("class")){j+=5,O();let Y=f();O();let $=u();O();let F=j;while(j<K&&Z.charCodeAt(j)!==123){if(E())continue;j++}let N=w(F,j),V=N?` ${N}`:"",Q=zj();H.push(`${J}${X}class ${Y}${$}${V} ${Q}`)}else if(z("enum")){j+=4,O();let Y=f();O();let $=Yj();H.push(`${J}${X}enum ${Y} ${$}`)}else if(z("namespace")||z("module")){let Y=z("namespace")?"namespace":"module";j+=Y.length,O();let $=f();O();let F=Gj(J);H.push(`${J}${X}${Y} ${$} ${F}`)}else if(z("abstract"))if(j+=8,O(),z("class")){j+=5,O();let Y=f();O();let $=u();O();let F=j;while(j<K&&Z.charCodeAt(j)!==123){if(E())continue;j++}let N=w(F,j),V=N?` ${N}`:"",Q=zj();H.push(`${J}${X}abstract class ${Y}${$}${V} ${Q}`)}else I();else if(U&&z("default")){j+=7,O();let Y=j;I();let $=w(Y,j);if($.charCodeAt($.length-1)===59)$=$.slice(0,-1);if($)H.push(`${J}export default ${$};`)}else if(!U&&(Z.charCodeAt(j)===39||Z.charCodeAt(j)===34||Z.charCodeAt(j)===96))I();else I()}if(H.length===0)return"{}";return`{
21
+ ${H.join(`
22
+ `)}
23
+ }`}function xj(J,H){let U=j+J.length;while(U<K&&y(Z.charCodeAt(U)))U++;for(let X=0;X<H.length;X++)if(U+X>=K||Z.charCodeAt(U+X)!==H.charCodeAt(X))return!1;return U+H.length>=K||!W(Z.charCodeAt(U+H.length))}function o(J,H,U){j+=U.length,O();let X="",Y=Z.charCodeAt(j);if(Y===39||Y===34){let Q=j;h(Y),X=Z.slice(Q,j)}else{X=f();while(j<K&&Z.charCodeAt(j)===46)j++,X+=`.${f()}`}O();let $=j<K&&Z.charCodeAt(j)===123?Gj():"{}",F=`${H?"export ":""}declare ${U} ${X} ${$}`,N=C(J),V=X.startsWith("'")||X.startsWith('"');return{kind:"module",name:X,text:F,isExported:H,source:V?X.slice(1,-1):void 0,leadingComments:N,start:J,end:j}}while(j<K){if(O(),j>=K)break;let J=j,H=Z.charCodeAt(j);if(H===105&&z("import"))L.push(Sj(J));else if(H===101&&z("export")){j+=6,O();let U=Z.charCodeAt(j);if(U===100&&z("default")){j+=7,O();let X=Z.charCodeAt(j);if(X===102&&z("function")){let Y=d(J,!0,!1,!0);if(Y)L.push(Y)}else if(X===97&&z("async")&&Dj("async")!==59)if(j+=5,O(),z("function")){let Y=d(J,!0,!0,!0);if(Y)L.push(Y)}else{I();let Y=w(J,j);L.push({kind:"export",name:"default",text:Y,isExported:!0,isTypeOnly:!1,start:J,end:j})}else if(X===99&&z("class")){let Y=a(J,!0,!1);L.push(Y)}else if(X===97&&z("abstract")){if(j+=8,O(),z("class")){let Y=a(J,!0,!0);L.push(Y)}}else{I();let Y=w(J,j),$=C(J);L.push({kind:"export",name:"default",text:Y,isExported:!0,isTypeOnly:!1,leadingComments:$,start:J,end:j})}}else if(U===116&&z("type")){let X=j;if(j+=4,O(),j<K&&Z.charCodeAt(j)===123){Nj();let Y=w(J,j),$=C(J);L.push({kind:"export",name:"",text:Y,isExported:!0,isTypeOnly:!0,source:Jj(Y),leadingComments:$,start:J,end:j})}else if(j<K&&Z.charCodeAt(j)===42){Rj();let Y=w(J,j);L.push({kind:"export",name:"",text:Y,isExported:!0,isTypeOnly:!0,source:Jj(Y),start:J,end:j})}else{j=X;let Y=Vj(J,!0);L.push(Y)}}else if(U===105&&z("interface")){let X=Kj(J,!0);L.push(X)}else if(U===102&&z("function")){let X=d(J,!0,!1,!1);if(X)L.push(X)}else if(U===97&&z("async"))if(j+=5,O(),z("function")){let X=d(J,!0,!0,!1);if(X)L.push(X)}else I();else if(U===99)if(z("class")){let X=a(J,!0,!1);L.push(X)}else if(z("const")){let X=j;if(j+=5,O(),z("enum")){j=X+5,O();let Y=i(J,!0,!0);L.push(Y)}else{j=X;let Y=r(J,"const",!0);for(let $=0;$<Y.length;$++)L.push(Y[$])}}else I();else if(U===97&&z("abstract")){if(j+=8,O(),z("class")){let X=a(J,!0,!0);L.push(X)}}else if(U===108&&z("let")){let X=r(J,"let",!0);for(let Y=0;Y<X.length;Y++)L.push(X[Y])}else if(U===118&&z("var")){let X=r(J,"var",!0);for(let Y=0;Y<X.length;Y++)L.push(X[Y])}else if(U===101&&z("enum")){let X=i(J,!0,!1);L.push(X)}else if(U===100&&z("declare"))j+=7,O(),wj(J,!0);else if(U===110&&z("namespace")&&Hj(9)){let X=o(J,!0,"namespace");L.push(X)}else if(U===109&&z("module")&&Hj(6)){let X=o(J,!0,"module");L.push(X)}else if(U===123){Nj();let X=w(J,j),Y=X.includes("export type"),$=C(J);L.push({kind:"export",name:"",text:X,isExported:!0,isTypeOnly:Y,source:Jj(X),leadingComments:$,start:J,end:j})}else if(U===42){Rj();let X=w(J,j),Y=C(J);L.push({kind:"export",name:"",text:X,isExported:!0,isTypeOnly:!1,source:Jj(X),leadingComments:Y,start:J,end:j})}else{I();let X=w(J,j);if(X)L.push({kind:"export",name:"",text:X,isExported:!0,start:J,end:j})}}else if(H===100&&z("declare"))j+=7,O(),wj(J,!1);else if(H===105&&z("interface")){let U=Kj(J,!1);P.set(U.name,U)}else if(H===116&&z("type")){let U=Vj(J,!1);P.set(U.name,U),L.push(U)}else if(H===102&&z("function")){let U=d(J,!1,!1,!1);if(U)P.set(U.name,U);else I()}else if(H===97)if(z("async")){let U=j;if(j+=5,O(),z("function")){let X=d(J,!1,!0,!1);if(X)P.set(X.name,X);else j=U,I()}else j=U,I()}else if(z("abstract"))if(j+=8,O(),z("class")){let U=a(J,!1,!1);P.set(U.name,U),L.push(U)}else I();else j++,I();else if(H===99)if(z("class")){let U=a(J,!1,!1);P.set(U.name,U),L.push(U)}else if(z("const")){let U=j;if(j+=5,O(),z("enum")){j=U+5,O();let X=i(J,!1,!0);P.set(X.name,X),L.push(X)}else{j=U;let X=r(J,"const",!1);for(let Y=0;Y<X.length;Y++)P.set(X[Y].name,X[Y])}}else j++,I();else if(H===101&&z("enum")){let U=i(J,!1,!1);P.set(U.name,U),L.push(U)}else if(H===108&&z("let"))I();else if(H===118&&z("var"))I();else if(H===109&&z("module")&&Hj(6)){let U=o(J,!1,"module");L.push(U)}else if(H===110&&z("namespace")&&Hj(9)){let U=o(J,!1,"namespace");L.push(U)}else{let U=Z.charCodeAt(j);if(U===39||U===34){if(h(U),j<K&&Z.charCodeAt(j)===59)j++}else if(U===96){if(s(),j<K&&Z.charCodeAt(j)===59)j++}else if(U===64){if(j++,f(),O(),j<K&&Z.charCodeAt(j)===46)j++,f(),O();if(j<K&&Z.charCodeAt(j)===40)A(40,41)}else j++,I()}}if(P.size>0)lj(L,P);if(x.size>0){let J=new Map;for(let U of L)if(U.kind==="function")J.set(U.name,(J.get(U.name)||0)+1);let H=new Set;for(let[U,X]of J)if(X>1)H.add(U);if(H.size>0){let U=new Set;for(let X of H)for(let Y=L.length-1;Y>=0;Y--)if(L[Y].kind==="function"&&L[Y].name===X&&x.has(Y)){U.add(Y);break}if(U.size>0){let X=[...U].sort((Y,$)=>$-Y);for(let Y of X)L.splice(Y,1)}}}return L;function wj(J,H){if(z("function")){let U=d(J,H,!1,!1);if(U)L.push(U)}else if(z("async")){if(j+=5,O(),z("function")){let U=d(J,H,!0,!1);if(U)L.push(U)}}else if(z("class")){let U=a(J,H,!1);L.push(U)}else if(z("abstract")){if(j+=8,O(),z("class")){let U=a(J,H,!0);L.push(U)}}else if(z("interface")){let U=Kj(J,H);L.push(U)}else if(z("type")){let U=Vj(J,H);L.push(U)}else if(z("enum")){let U=i(J,H,!1);L.push(U)}else if(z("const")){let U=j;if(j+=5,O(),z("enum")){j=U+5,O();let X=i(J,H,!0);L.push(X)}else if(H){j=U;let X=r(J,"const",!0);for(let Y=0;Y<X.length;Y++)L.push(X[Y])}else I()}else if(z("let")||z("var"))if(H){let U=z("let")?"let":"var",X=r(J,U,!0);for(let Y=0;Y<X.length;Y++)L.push(X[Y])}else I();else if(z("module")){let U=o(J,H,"module");L.push(U)}else if(z("namespace")){let U=o(J,H,"namespace");L.push(U)}else if(z("global")){j+=6,O();let X=`declare global ${j<K&&Z.charCodeAt(j)===123?Gj():"{}"}`,Y=C(J);L.push({kind:"module",name:"global",text:X,isExported:!1,leadingComments:Y,start:J,end:j})}else I()}}function vj(M,jj){let T=0,l=M.length;while(T<l){let Z=M.charCodeAt(T);if(Z>=65&&Z<=90||Z>=97&&Z<=122||Z===95||Z===36||Z>127){let c=T;T++;while(T<l){let b=M.charCodeAt(T);if(b>=65&&b<=90||b>=97&&b<=122||b>=48&&b<=57||b===95||b===36||b>127)T++;else break}jj.add(M.substring(c,T))}else T++}}function lj(M,jj){let T=new Set,l=new Set;for(let b of M)l.add(b.name);let Z=new Set,c=[];for(let b=0;b<M.length;b++)if(M[b].kind!=="import")c.push(M[b].text),vj(M[b].text,Z);for(;;){let b=[];for(let[P,x]of jj){if(T.has(P))continue;if(Z.has(P)){if(!l.has(P))b.push(x),l.add(P);T.add(P)}}if(b.length===0)break;b.sort((P,x)=>(P.start??1/0)-(x.start??1/0));let K=[],L=0;for(let P=0;P<M.length;P++){let x=M[P].start??1/0;while(L<b.length&&(b[L].start??1/0)<=x)K.push(b[L++]);K.push(M[P])}while(L<b.length)K.push(b[L++]);M.length=0;for(let P=0;P<K.length;P++)M.push(K[P]);for(let P of b)if(P.kind!=="import")c.push(P.text),vj(P.text,Z)}}
24
+ export{mj as oc};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./chunk-mcdb3q06.js";var e="@stacksjs/dtsx",i="module",n="0.9.14",r=!0,o="A modern, fast .d.ts generation tool, powered by Bun.",u="Chris Breuer <chris@stacksjs.org>",c="MIT",p="https://github.com/stacksjs/dtsx#readme",d={type:"git",url:"git+https://github.com/stacksjs/dtsx.git"},a={url:"https://github.com/stacksjs/dtsx/issues"},b=["dts","generation","isolated declarations","development","bun","stacks","typescript","javascript"],m={".":{import:"./dist/index.js"},"./*":{import:"./dist/*"}},l="./dist/index.js",g="./dist/index.d.ts",x={dtsx:"./dist/cli.js"},k=["dist"],h={benchmark:"bun benchmark/index.ts",build:"bun --filter './packages/dtsx' build",test:"bun test",lint:"bunx --bun pickier .","lint:fix":"bunx --bun pickier . --fix",format:"bunx --bun pickier . --format","format:fix":"bunx --bun pickier . --format --write",changelog:"bunx logsmith --verbose","changelog:generate":"bunx logsmith --output CHANGELOG.md",release:"bun --bun run changelog:generate && bunx --bun bumpx prompt --recursive",typecheck:"bunx tsc --noEmit","dev:docs":"bun --bun vitepress dev docs","build:docs":"bun --bun vitepress build docs","preview:docs":"bun --bun vitepress preview docs"},v={"@stacksjs/bumpx":"^0.2.4","@stacksjs/bunpress":"^0.1.4","@stacksjs/clapp":"^0.2.0",pickier:"^0.1.20","@stacksjs/gitlint":"^0.1.5","@stacksjs/logsmith":"^0.2.1","@types/bun":"^1.3.11","@typescript/native-preview":"^7.0.0-dev.20260311.1","buddy-bot":"^0.9.18","bun-git-hooks":"^0.3.1","bun-plugin-dtsx":"workspace:*",mitata:"^1.0.34","oxc-transform":"^0.121.0",typescript:"^5.9.3"},j=["packages/*"],y={name:e,type:i,version:n,private:r,description:o,author:u,license:c,homepage:p,repository:d,bugs:a,keywords:b,exports:m,module:l,types:g,bin:x,files:k,scripts:h,devDependencies:v,workspaces:j,"git-hooks":{"pre-commit":{"staged-lint":{"*.{js,ts,json,yaml,yml,md}":"bunx --bun pickier lint --fix"}},"commit-msg":"bunx gitlint --edit .git/COMMIT_EDITMSG"}};export{j as workspaces,n as version,g as types,i as type,h as scripts,d as repository,r as private,e as name,l as module,c as license,b as keywords,p as homepage,k as files,m as exports,v as devDependencies,o as description,y as default,a as bugs,x as bin,u as author};
@@ -0,0 +1,80 @@
1
+ // @bun
2
+ import{ec as l}from"./chunk-thhd43x5.js";import{hc as CY}from"./chunk-2n1bbm2c.js";import{lc as UJ}from"./chunk-rsv17jh8.js";import{Cc as iJ}from"./chunk-vpjw38x7.js";import{Uc as f}from"./chunk-3w5aqasc.js";import{Wc as K,Yc as r}from"./chunk-gssantc8.js";import{bd as xY,dd as AY}from"./chunk-mcdb3q06.js";var{Glob:oJ}=globalThis.Bun;import{mkdir as o}from"fs/promises";import{availableParallelism as dY}from"os";import{dirname as u,relative as v,resolve as x}from"path";import{existsSync as ZJ,mkdirSync as JY,readFileSync as YY,writeFileSync as $Y}from"fs";import{dirname as ZY,relative as QY,resolve as UY}from"path";async function TJ(J,Y,$){let Z=new Map,Q=[],U=new Set,X=0,H=0,j=0,G=[];for(let q of J){let B=Y.get(q);if(!B)continue;G.push({file:q,decls:l(B,q,$.keepComments)})}for(let{file:q,decls:B}of G){X+=B.length;for(let k of B)if(k.kind==="import"){H++;let R=k.source||"";if(R.startsWith("."))continue;if(!Z.has(R))Z.set(R,{source:R,specifiers:new Map,isTypeOnly:k.isTypeOnly||!1,isSideEffect:k.isSideEffect||!1});let L=Z.get(R);if(k.specifiers)for(let w of k.specifiers){let S=w.alias||w.name;if(!L.specifiers.has(S))L.specifiers.set(S,{name:w.name,alias:w.alias,isType:w.isType||!1})}if(!k.isTypeOnly)L.isTypeOnly=!1}else if(k.isExported||k.kind==="export"){if(j++,k.kind==="export"&&k.source&&(k.source.startsWith(".")||k.source.startsWith("/")))continue;if(k.name&&U.has(k.name))continue;if(k.name)U.add(k.name);Q.push({declaration:k,file:q})}}let z=[];z.push("/**"),z.push(" * Bundled TypeScript declarations"),z.push(` * Generated from ${J.length} source files`),z.push(" */"),z.push("");let A=$.importOrder||["bun"],N=Array.from(Z.values()),_=Array(N.length);for(let q=0;q<N.length;q++){let B=N[q].source,k=A.length;for(let R=0;R<A.length;R++)if(B.startsWith(A[R])){k=R;break}_[q]=k}let T=N.map((q,B)=>B);T.sort((q,B)=>{let k=_[q],R=_[B];if(k!==R)return k-R;return N[q].source.localeCompare(N[B].source)});let V=T.map((q)=>N[q]);for(let q of V)if(q.isSideEffect)z.push(`import '${q.source}';`);else if(q.specifiers.size>0){let k=Array.from(q.specifiers.values()).map((L)=>{let w=L.isType?"type ":"";return L.alias?`${w}${L.name} as ${L.alias}`:`${w}${L.name}`}),R=q.isTypeOnly?"type ":"";z.push(`import ${R}{ ${k.join(", ")} } from '${q.source}';`)}if(V.length>0)z.push("");let W=new Map;for(let{declaration:q,file:B}of Q){if(!W.has(B))W.set(B,[]);W.get(B).push(q)}for(let[q,B]of W){let k=QY($.cwd,q);z.push(`// From: ${k}`);for(let R of B){if($.keepComments&&R.leadingComments)for(let L of R.leadingComments)z.push(L);z.push(RJ(R))}z.push("")}let O=z.join(`
3
+ `);return{content:O,files:J,declarationCount:X,importCount:H,exportCount:j,size:Buffer.byteLength(O,"utf8"),warnings:[]}}function RJ(J){if(J.text){let $=J.text.trim();if(J.isExported&&!$.startsWith("export"))$=`export ${$}`;if(!$.endsWith(";")&&!$.endsWith("}"))$+=";";return $}let Y=[];if(J.isExported)Y.push("export");if(J.isDefault)Y.push("default");switch(J.kind){case"function":if(Y.push("declare function"),Y.push(J.name),J.generics)Y.push(J.generics);if(Y.push(`(${XY(J.parameters)})`),J.returnType)Y.push(`: ${J.returnType}`);break;case"variable":if(Y.push("declare const"),Y.push(J.name),J.typeAnnotation)Y.push(`: ${J.typeAnnotation}`);break;case"interface":if(Y.push("interface"),Y.push(J.name),J.generics)Y.push(J.generics);if(J.extends)Y.push(`extends ${J.extends}`);if(Y.push("{"),J.members)for(let $ of J.members)Y.push(` ${$.name}${$.typeAnnotation?`: ${$.typeAnnotation}`:""};`);Y.push("}");break;case"type":if(Y.push("type"),Y.push(J.name),J.generics)Y.push(J.generics);Y.push("="),Y.push(J.typeAnnotation||"unknown");break;case"class":if(Y.push("declare class"),Y.push(J.name),J.generics)Y.push(J.generics);if(J.extends)Y.push(`extends ${J.extends}`);if(J.implements&&J.implements.length>0)Y.push(`implements ${J.implements.join(", ")}`);if(Y.push("{"),J.members)for(let $ of J.members)Y.push(` ${RJ($)}`);Y.push("}");break;case"enum":if(Y.push("declare enum"),Y.push(J.name),Y.push("{"),J.members){let $=J.members.map((Z)=>Z.value!==void 0?`${Z.name} = ${Z.value}`:Z.name);Y.push(` ${$.join(`,
4
+ `)}`)}Y.push("}");break;default:return J.text||""}return Y.join(" ")}function XY(J){if(!J||J.length===0)return"";return J.map((Y)=>{let $="";if(Y.rest)$+="...";if($+=Y.name,Y.optional)$+="?";if(Y.type)$+=`: ${Y.type}`;if(Y.defaultValue)$+=` = ${Y.defaultValue}`;return $}).join(", ")}async function LJ(J,Y={}){let $=[],Z=new Map,Q=[],U=[],X=new Set,H=0,j=0,G=0;for(let _ of J){if(!ZJ(_)){$.push(`File not found: ${_}`);continue}let T=YY(_,"utf-8");U.push(_);let V=T.split(`
5
+ `),W=[],O=0,q=!1;for(let B of V){let k=B.trim();if(!k&&!q)continue;if(k.startsWith("import ")){j++;let L=k.match(/import\s+(type\s+)?(?:\{([^}]+)\}|(\w+)|\*\s+as\s+(\w+))\s+from\s+['"]([^'"]+)['"]/);if(L){let[,w,S,M,F,D]=L;if(Y.externals?.some((C)=>D.startsWith(C))){Q.push(k);continue}if(D.startsWith("."))continue;if(!Z.has(D))Z.set(D,{source:D,specifiers:new Map,isTypeOnly:!!w,isSideEffect:!1});let p=Z.get(D);if(S){let C=S.split(",").map((e)=>e.trim());for(let e of C){let[JJ,YJ]=e.split(/\s+as\s+/).map((eJ)=>eJ.trim()),NJ=JJ.startsWith("type "),$J=NJ?JJ.replace("type ",""):JJ;p.specifiers.set(YJ||$J,{name:$J,alias:YJ!==$J?YJ:void 0,isType:NJ})}}if(!w)p.isTypeOnly=!1}continue}if(/^(export\s+)?(declare\s+)?(interface|type|class|function|const|let|var|enum|namespace|module)\s/.test(k)){if(q=!0,W=[B],O=(B.match(/\{/g)||[]).length-(B.match(/\}/g)||[]).length,O===0&&(k.endsWith(";")||!k.includes("{"))){let L=c(k);if(!X.has(L)||!Y.mergeDuplicates){if(X.add(L),Q.push(B),H++,k.startsWith("export"))G++}q=!1,W=[]}}else if(q){if(W.push(B),O+=(B.match(/\{/g)||[]).length-(B.match(/\}/g)||[]).length,O<=0){let L=W.join(`
6
+ `),w=c(W[0]);if(!X.has(w)||!Y.mergeDuplicates){if(X.add(w),Q.push(L),H++,W[0].trim().startsWith("export"))G++}q=!1,W=[]}}else if(k.startsWith("export ")&&!k.includes("declare"))Q.push(B),G++}}let z=[];if(Y.banner)z.push(Y.banner),z.push("");if(Y.includeReferences&&Y.references){for(let _ of Y.references)z.push(`/// <reference types="${_}" />`);z.push("")}let A=Array.from(Z.values()).sort((_,T)=>_.source.localeCompare(T.source));for(let _ of A)if(_.specifiers.size>0){let V=Array.from(_.specifiers.values()).map((O)=>{let q=O.isType?"type ":"";return O.alias?`${q}${O.name} as ${O.alias}`:`${q}${O.name}`}),W=_.isTypeOnly?"type ":"";z.push(`import ${W}{ ${V.join(", ")} } from '${_.source}';`)}if(A.length>0)z.push("");if(Y.ambient&&Y.moduleName){z.push(`declare module '${Y.moduleName}' {`);for(let _ of Q){let T=_.split(`
7
+ `).map((V)=>` ${V.replace(/^(\s*)(export\s+)?declare\s+/,"$1$2")}`).join(`
8
+ `);z.push(T)}z.push("}")}else{if(Y.sortDeclarations)Q.sort((_,T)=>{let V=c(_),W=c(T);return V.localeCompare(W)});for(let _ of Q)z.push(_)}if(Y.footer)z.push(""),z.push(Y.footer);let N=z.join(`
9
+ `);return{content:N,files:U,declarationCount:H,importCount:j,exportCount:G,size:Buffer.byteLength(N,"utf-8"),warnings:$}}function c(J){let Y=J.match(/(interface|type|class|function|const|let|var|enum|namespace|module)\s+(\w+)/);return Y?`${Y[1]}:${Y[2]}`:J.trim()}async function qY(J,Y,$={}){let Z=await LJ(J,$),Q=ZY(Y);if(!ZJ(Q))JY(Q,{recursive:!0});return $Y(Y,Z.content),Z}function iY(J={}){return{bundle:(Y)=>LJ(Y,J),bundleAndWrite:(Y,$)=>qY(Y,$,{...J,output:$})}}async function oY(J,Y=process.cwd()){let $=Array.isArray(J)?J:[J],Z=[];for(let Q of $){if(Q.includes("*"))continue;let U=UY(Y,Q);if(ZJ(U))Z.push(U)}return Z}import{existsSync as s,mkdirSync as zY,readFileSync as XJ,rmSync as VY,statSync as MJ,writeFileSync as wJ}from"fs";import{join as SJ,relative as a,resolve as jY}from"path";var QJ=1,qJ=".dtsx-cache",GY="manifest.json";class zJ{cacheDir;manifestPath;manifest=null;configHash;constructor(J){this.cacheDir=jY(J.cwd,qJ),this.manifestPath=SJ(this.cacheDir,GY),this.configHash=this.hashConfig(J)}hashConfig(J){let Y={keepComments:J.keepComments,importOrder:J.importOrder,outputStructure:J.outputStructure};return String(UJ(JSON.stringify(Y)))}hashString(J){return String(UJ(J))}load(){try{if(!s(this.manifestPath))return!1;let J=XJ(this.manifestPath,"utf-8"),Y=JSON.parse(J);if(Y.version!==QJ)return!1;if(Y.configHash!==this.configHash)return!1;return this.manifest=Y,!0}catch{return!1}}save(){if(!this.manifest)this.manifest={version:QJ,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};if(this.manifest.updatedAt=Date.now(),!s(this.cacheDir))zY(this.cacheDir,{recursive:!0});wJ(this.manifestPath,JSON.stringify(this.manifest,null,2))}needsRegeneration(J,Y){return this.getCachedIfValid(J,Y)===null}getCached(J,Y){return this.getCachedIfValid(J,Y)}getCachedIfValid(J,Y){if(!this.manifest)return null;let $=a(Y,J),Z=this.manifest.entries[$];if(!Z)return null;try{let U=MJ(J).mtimeMs;if(U>Z.sourceMtime){let X=XJ(J,"utf-8");if(this.hashString(X)!==Z.sourceHash)return null;Z.sourceMtime=U}return Z.dtsContent}catch{return null}}update(J,Y,$,Z){if(!this.manifest)this.manifest={version:QJ,configHash:this.configHash,entries:{},createdAt:Date.now(),updatedAt:Date.now()};let Q=a(Z,J),U;try{U=MJ(J).mtimeMs}catch{U=Date.now()}this.manifest.entries[Q]={sourcePath:Q,sourceHash:this.hashString(Y),sourceMtime:U,dtsContent:$,dtsHash:this.hashString($),generatedAt:Date.now(),configHash:this.configHash}}remove(J,Y){if(!this.manifest)return;let $=a(Y,J);delete this.manifest.entries[$]}clear(){this.manifest=null;try{if(s(this.manifestPath))VY(this.cacheDir,{recursive:!0,force:!0})}catch{}}getStats(){if(!this.manifest)return{entries:0,size:0};let J=Object.keys(this.manifest.entries).length,Y=0;for(let $ of Object.values(this.manifest.entries))Y+=$.dtsContent.length;return{entries:J,size:Y}}prune(J,Y){if(!this.manifest)return 0;let $=0,Z=new Set(Array.from(J).map((Q)=>a(Y,Q)));for(let Q of Object.keys(this.manifest.entries))if(!Z.has(Q))delete this.manifest.entries[Q],$++;return $}}function FJ(J){let Y=SJ(J,".gitignore");try{let $="";if(s(Y))$=XJ(Y,"utf-8");if(!$.includes(qJ)){let Z=`${$.trimEnd()}
10
+
11
+ # dtsx cache
12
+ ${qJ}/
13
+ `;wJ(Y,Z)}}catch{}}import{spawn as HY}from"child_process";import{readFile as VJ,stat as DJ,writeFile as WY}from"fs/promises";var I=typeof globalThis.Bun<"u",Q0=!I&&typeof process<"u"&&!!process.versions?.node,U0=I?"bun":"node";class vJ{name;_size=-1;constructor(J){this.name=J}async exists(){try{return await DJ(this.name),!0}catch{return!1}}async text(){return VJ(this.name,"utf-8")}async arrayBuffer(){let J=await VJ(this.name);return J.buffer.slice(J.byteOffset,J.byteOffset+J.byteLength)}get size(){if(this._size===-1)return-1;return this._size}}class IJ{pid;stdout;stderr;stdin;exited;process;constructor(J){this.process=J,this.pid=J.pid??0,this.stdout=J.stdout,this.stderr=J.stderr,this.stdin=J.stdin,this.exited=new Promise((Y)=>{J.on("exit",($)=>{Y($??0)}),J.on("error",()=>{Y(1)})})}kill(J){this.process.kill(J)}ref(){this.process.ref()}unref(){this.process.unref()}}function EJ(J){if(I)return globalThis.Bun.file(J);return new vJ(J)}async function jJ(J,Y){if(I)return globalThis.Bun.write(J,Y);let $=typeof Y==="string"?Y:Y instanceof ArrayBuffer?Buffer.from(Y):Y;return await WY(J,$),typeof Y==="string"?Buffer.byteLength(Y):Y.byteLength}function yJ(J,Y={}){if(I)return globalThis.Bun.spawn(J,Y);let $=Array.isArray(J)?J:[J],[Z,...Q]=$,U={cwd:Y.cwd,env:Y.env,stdio:[Y.stdin??"pipe",Y.stdout??"pipe",Y.stderr??"pipe"]},X=HY(Z,Q,U);return new IJ(X)}async function y(J){if(I)return globalThis.Bun.file(J).text();return VJ(J,"utf-8")}async function X0(J){if(I)return globalThis.Bun.file(J).exists();try{return await DJ(J),!0}catch{return!1}}async function q0(J,Y){await jJ(J,Y)}function z0(){if(I)return{name:"bun",version:globalThis.Bun.version,isBun:!0,isNode:!1};return{name:"node",version:process.versions.node,isBun:!1,isNode:!0}}var m={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"};class E extends Error{code;context;constructor(J,Y="UNKNOWN_ERROR",$){super(J);if(this.name="DtsxError",this.code=Y,this.context=$,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toString(){let J=`${this.name} [${this.code}]: ${this.message}`;if(this.context)J+=`
14
+ Context: ${JSON.stringify(this.context,null,2)}`;return J}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}}class bJ extends E{filePath;line;column;constructor(J,Y,$){super(J,"PARSE_ERROR",{filePath:Y,line:$?.line,column:$?.column});if(this.name="ParseError",this.filePath=Y,this.line=$?.line,this.column=$?.column,$?.cause)this.cause=$.cause}get locationString(){if(this.line!==void 0&&this.column!==void 0)return`${this.filePath}:${this.line}:${this.column}`;return this.line!==void 0?`${this.filePath}:${this.line}`:this.filePath}}class KY extends E{filePath;declarationKind;constructor(J,Y,$,Z){super(J,"EXTRACTION_ERROR",{filePath:Y,declarationKind:$});if(this.name="ExtractionError",this.filePath=Y,this.declarationKind=$,Z)this.cause=Z}}class _Y extends E{declarationName;constructor(J,Y,$){super(J,"PROCESSING_ERROR",{declarationName:Y});if(this.name="ProcessingError",this.declarationName=Y,$)this.cause=$}}class xJ extends E{filePath;operation;constructor(J,Y,$,Z){super(J,$==="read"?"FILE_READ_ERROR":"FILE_WRITE_ERROR",{filePath:Y,operation:$});if(this.name="FileError",this.filePath=Y,this.operation=$,Z)this.cause=Z}}class CJ extends E{configPath;invalidKey;constructor(J,Y){super(J,"CONFIG_ERROR",{configPath:Y?.configPath,invalidKey:Y?.invalidKey});if(this.name="ConfigError",this.configPath=Y?.configPath,this.invalidKey=Y?.invalidKey,Y?.cause)this.cause=Y.cause}}class BY extends E{cycle;constructor(J){super(`Circular dependency detected: ${J.join(" -> ")}`,"CIRCULAR_DEPENDENCY",{cycle:J});this.name="CircularDependencyError",this.cycle=J}}function j0(J){return J instanceof E}function G0(J){return J instanceof bJ}function H0(J){return J instanceof xJ}function W0(J){return J instanceof CJ}function K0(J,Y="UNKNOWN_ERROR",$){if(J instanceof E)return J;let Z=$||(J instanceof Error?J.message:String(J)),Q=new E(Z,Y);if(J instanceof Error)Q.cause=J;return Q}function _0(J,Y){let $=1,Z=1,Q=0;for(let U of J){if(Q>=Y)break;if(U===`
15
+ `)$++,Z=1;else Z++;Q++}return{line:$,column:Z,offset:Y}}function B0(J,Y,$,Z){let Q=J.split(`
16
+ `),U=Y.line-1,X=[];if(Z)X.push(`${Z}:${Y.line}:${Y.column}`);else X.push(`Line ${Y.line}, Column ${Y.column}`);X.push(`Error: ${$}`),X.push("");let H=Math.max(0,U-1),j=Math.min(Q.length-1,U+1);for(let G=H;G<=j;G++){let z=(G+1).toString().padStart(4," "),A=G===U?">":" ";if(X.push(`${A} ${z} | ${Q[G]}`),G===U){let N=" ".repeat(8+Y.column-1);X.push(`${N}^`)}}return X.join(`
17
+ `)}function GJ(J,Y,$){let Z={file:Y,message:"Unknown error",code:m.UNKNOWN_ERROR};if(J instanceof Error){Z.message=J.message,Z.stack=J.stack;let Q=J.message.match(/\((\d+),(\d+)\)/);if(Q)Z.location={line:Number.parseInt(Q[1],10),column:Number.parseInt(Q[2],10)};if(J.message.includes("Cannot find")||J.message.includes("not found"))Z.code=m.FILE_NOT_FOUND,Z.suggestion="Check that the file path is correct and the file exists.";else if(J.message.includes("syntax")||J.message.includes("Unexpected token"))Z.code=m.SYNTAX_ERROR,Z.suggestion="Check for syntax errors in your TypeScript code.";else if(J.message.includes("type")&&J.message.includes("cannot"))Z.code=m.TYPE_INFERENCE_ERROR,Z.suggestion="Add explicit type annotations to help with type inference.";else if(J.message.includes("parse")||J.message.includes("Parse"))Z.code=m.PARSE_ERROR,Z.suggestion="The file contains invalid TypeScript syntax."}else if(typeof J==="string")Z.message=J;return Z}function PJ(J,Y){let $=[],Z=J.file;if(J.location)Z+=`:${J.location.line}:${J.location.column}`;if(J.code)Z+=` [${J.code}]`;if($.push(Z),$.push(` Error: ${J.message}`),Y&&J.location){$.push("");let Q=Y.split(`
18
+ `),U=J.location.line-1;if(U>=0&&U<Q.length){let X=Math.max(0,U-1),H=Math.min(Q.length-1,U+1);for(let j=X;j<=H;j++){let G=(j+1).toString().padStart(4," "),z=j===U?">":" ";if($.push(` ${z} ${G} | ${Q[j]}`),j===U&&J.location.column>0){let A=" ".repeat(10+J.location.column-1);$.push(` ${A}^`)}}}}if(J.suggestion)$.push(""),$.push(` Suggestion: ${J.suggestion}`);return $.join(`
19
+ `)}function A0(J){if(J.length===0)return"No errors";let Y=new Map;for(let Z of J){let Q=Z.code||"UNKNOWN";Y.set(Q,(Y.get(Q)||0)+1)}let $=[`${J.length} error(s) found:`];for(let[Z,Q]of Y.entries())$.push(` - ${Z}: ${Q}`);return $.join(`
20
+ `)}var n=null,b=null;async function OY(){if(n!==null)return n;try{return b=await import("prettier"),n=!0,!0}catch{return n=!1,!1}}async function kY(J,Y){if(!b)return null;try{if(Y&&b.resolveConfig){let $=await b.resolveConfig(Y);if($)return $}if(J&&b.resolveConfig){let $=await b.resolveConfig(J);if($)return $}return null}catch{return null}}async function NY(J,Y){if(!b)throw Error("Prettier is not available");let $={...Y,parser:Y.parser||"typescript"};return b.format(J,$)}function TY(J,Y={}){let{indentSize:$=2,useTabs:Z=!1,maxLineWidth:Q=100,trailingNewline:U=!0,normalizeWhitespace:X=!0,sortImports:H=!0,groupImports:j=!0}=Y,G=J,z=Z?"\t":" ".repeat($);if(G.indexOf(`\r
21
+ `)!==-1)G=G.replace(/\r\n/g,`
22
+ `);if(X){if(/[ \t]\n/.test(G)||/[ \t]$/.test(G))G=G.replace(/[ \t]+$/gm,"");if(G.indexOf(`
23
+
24
+
25
+ `)!==-1)G=G.replace(/\n{3,}/g,`
26
+
27
+ `);G=RY(G,z)}if(H||j)G=LY(G,{sort:H,group:j});if(Q>0)G=wY(G,Q,z);if(U&&!G.endsWith(`
28
+ `))G+=`
29
+ `;return G}function RY(J,Y){let $=J.split(`
30
+ `),Z=[];for(let Q of $){let U=Q.match(/^(\s*)(.*)$/);if(!U){Z.push(Q);continue}let[,X,H]=U;if(!H){Z.push("");continue}let j=X.replace(/\t/g," ").length,G=Math.floor(j/2);Z.push(Y.repeat(G)+H)}return Z.join(`
31
+ `)}function LY(J,Y){let $=J.split(`
32
+ `),Z=[],Q=[],U=!1,X=0;for(let j=0;j<$.length;j++){let G=$[j],z=G.match(/^(import\s+(?:type\s+)?.*from\s+['"])([^'"]+)(['"].*)$/);if(z){U=!0,X=j;let A=z[1];Z.push({line:G,source:z[2],isType:A.startsWith("import type ")||A.startsWith("import type\t")})}else if(U&&G.trim()==="")continue;else{if(U)U=!1;Q.push(G)}}if(Z.length===0)return J;if(Y.sort)Z.sort((j,G)=>{if(j.isType!==G.isType)return j.isType?1:-1;return MY(j.source,G.source)});let H;if(Y.group){let j=[],G=[],z=[],A=[],N=[];for(let _=0;_<Z.length;_++){let T=Z[_],V=T.source;if(V.charCodeAt(0)===46)N.push(T);else if(V.startsWith("node:"))j.push(T);else if(V.charCodeAt(0)===64)A.push(T);else if(V.includes("/"))z.push(T);else G.push(T)}H=[...j.map((_)=>_.line),...j.length>0&&G.length>0?[""]:[],...G.map((_)=>_.line),...(j.length>0||G.length>0)&&z.length>0?[""]:[],...z.map((_)=>_.line),...A.length>0&&(j.length>0||G.length>0||z.length>0)?[""]:[],...A.map((_)=>_.line),...N.length>0?[""]:[],...N.map((_)=>_.line)]}else H=Z.map((j)=>j.line);return[...H,"",...Q].join(`
33
+ `)}function MY(J,Y){let $=J.startsWith("node:"),Z=Y.startsWith("node:");if($!==Z)return $?-1:1;let Q=J.startsWith("."),U=Y.startsWith(".");if(Q!==U)return Q?1:-1;return J.localeCompare(Y)}function wY(J,Y,$){let Z=J.split(`
34
+ `),Q=[];for(let U of Z){if(U.length<=Y){Q.push(U);continue}if(U.trimStart().startsWith("import ")){Q.push(U);continue}let X=U.match(/^(\s*)/)?.[1]||"",H=X+$;if(U.includes("{")&&U.includes("}")){let j=SY(U,Y,X,H);Q.push(...j);continue}if(U.includes(" | ")){let j=FY(U,Y,X,H);Q.push(...j);continue}Q.push(U)}return Q.join(`
35
+ `)}function SY(J,Y,$,Z){let Q=J.match(/^(\s*)(.*?)(\{)(.+)(\}.*)$/);if(!Q)return[J];let[,,U,X,H,j]=Q,G=H.split(/;\s*|,\s*/).filter((A)=>A.trim());if(G.length<=1)return[J];return[`${$}${U}${X}`,...G.map((A)=>`${Z}${A.trim()};`),`${$}${j.trim()}`]}function FY(J,Y,$,Z){let Q=J.match(/^(\s*)(.*?=\s*)(.+)$/);if(!Q)return[J];let[,,U,X]=Q,H=X.split(/\s*\|\s*/).filter((G)=>G.trim());if(H.length<=2)return[J];return[`${$}${U}`,...H.map((G,z)=>`${Z}${z>0?"| ":" "}${G.trim()}`)]}async function g(J,Y={},$){let Z=[];if(Y.usePrettier!==!1){if(await OY())try{let H={...await kY(Y.prettierConfigPath,$),...Y.prettierOptions,parser:"typescript"};return{content:await NY(J,H),usedPrettier:!0}}catch(X){Z.push(`Prettier formatting failed: ${X}. Using built-in formatter.`)}else if(Y.usePrettier===!0)Z.push("Prettier requested but not available. Using built-in formatter.")}return{content:TY(J,Y.builtIn),usedPrettier:!1,warnings:Z.length>0?Z:void 0}}async function DY(J,Y={}){let $=new Map;for(let[Z,Q]of J){let U=await g(Q,Y,Z);$.set(Z,U)}return $}function k0(J={}){return{format:(Y,$)=>g(Y,J,$),formatMany:(Y)=>DY(Y,J)}}async function N0(J){return(await g(J,{usePrettier:!0,builtIn:{indentSize:2,normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}})).content}import{existsSync as vY,statSync as IY}from"fs";import{dirname as EY,isAbsolute as WJ,resolve as yY}from"path";var hJ=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".d.ts"];function HJ(J){try{return IY(J).isFile()}catch{return!1}}function KJ(J,Y){if(!(J.startsWith("./")||J.startsWith("../")||J==="."||J==="..")&&!WJ(J))return{resolved:null,isRelative:!1};let Z=EY(Y),Q=WJ(J)?J:yY(Z,J);if(HJ(Q))return{resolved:Q,isRelative:!0};for(let U of hJ){let X=Q+U;if(HJ(X))return{resolved:X,isRelative:!0}}if(vY(Q))for(let U of hJ){let X=`${Q}/index${U}`;if(HJ(X))return{resolved:X,isRelative:!0}}return{resolved:null,isRelative:!0}}function bY(J){let Y=J.length,$="",Z=0;while(Z<Y){let Q=J.charCodeAt(Z);if(Q===34||Q===39||Q===96){let U=Q;$+=J[Z++];while(Z<Y){let X=J.charCodeAt(Z);if($+=J[Z++],X===92&&Z<Y){$+=J[Z++];continue}if(X===U)break}continue}if(Q===47&&Z+1<Y){let U=J.charCodeAt(Z+1);if(U===47){Z+=2;while(Z<Y&&J.charCodeAt(Z)!==10)Z++;continue}if(U===42){Z+=2;while(Z+1<Y&&!(J.charCodeAt(Z)===42&&J.charCodeAt(Z+1)===47))Z++;Z+=2;continue}}$+=J[Z++]}return $}var mJ=/(?:^|[\n;{}])\s*export\s+(type\s+)?(?:\*(?:\s+as\s+\w+)?|\{[^}]*\})\s+from\s+(['"])([^'"]+)\2/g,gJ=/(?:^|[\n;{}])\s*import\s+(type\s+)?(?:[^'";\n]+\s+from\s+)?(['"])([^'"]+)\2/g;function _J(J,Y={}){let $=[],Z=bY(J);mJ.lastIndex=0;let Q;while((Q=mJ.exec(Z))!==null){let U=!!Q[1],X=Q[3],H=Q[0],j;if(H.includes("* as "))j="export-star-as";else if(H.includes("*"))j="export-star";else j="export-named";$.push({specifier:X,kind:j,isTypeOnly:U})}if(Y.includeImports){gJ.lastIndex=0;while((Q=gJ.exec(Z))!==null)$.push({specifier:Q[3],kind:"import",isTypeOnly:!!Q[1]})}return $}async function BJ(J,Y={}){let $=new Set,Z=new Map,Q=[],U=[];for(let X of J)if(!$.has(X))$.add(X),U.push(X);while(U.length>0){let X=U.shift(),H;try{H=await y(X)}catch{continue}let j=_J(H,Y);Z.set(X,j);for(let G of j){if(!(G.specifier.startsWith(".")||WJ(G.specifier)))continue;let z=KJ(G.specifier,X);if(z.resolved){if(!$.has(z.resolved))$.add(z.resolved),U.push(z.resolved)}else Q.push({from:X,specifier:G.specifier,isTypeOnly:G.isTypeOnly})}}return{reachable:$,reExports:Z,unresolved:Q}}class i{plugins=[];config=null;register(J){if(this.plugins.some((Y)=>Y.name===J.name))throw Error(`Plugin "${J.name}" is already registered`);this.plugins.push(J)}unregister(J){let Y=this.plugins.findIndex(($)=>$.name===J);if(Y>=0)return this.plugins.splice(Y,1),!0;return!1}getPlugins(){return this.plugins}createLogger(J){return{debug:(Y)=>console.debug(`[${J}] ${Y}`),info:(Y)=>console.info(`[${J}] ${Y}`),warn:(Y)=>console.warn(`[${J}] ${Y}`),error:(Y)=>console.error(`[${J}] ${Y}`)}}async runOnStart(J){let Y=J;for(let $ of this.plugins)if($.onStart){let Z=await $.onStart(Y);if(Z)Y=Z}return this.config=Y,Y}async runOnBeforeFile(J,Y){let $=Y;for(let Z of this.plugins)if(Z.onBeforeFile){let Q={filePath:J,sourceCode:Y,content:$,config:this.config,log:this.createLogger(Z.name)},U=await Z.onBeforeFile(Q);if(typeof U==="string")$=U}return $}async runOnDeclarations(J,Y,$){let Z=$;for(let Q of this.plugins)if(Q.onDeclarations){let U={filePath:J,sourceCode:Y,declarations:Z,config:this.config,log:this.createLogger(Q.name)},X=await Q.onDeclarations(U);if(X)Z=X}return Z}async runOnAfterFile(J,Y,$){let Z=$;for(let Q of this.plugins)if(Q.onAfterFile){let U={filePath:J,sourceCode:Y,content:Z,config:this.config,log:this.createLogger(Q.name)},X=await Q.onAfterFile(U);if(typeof X==="string")Z=X}return Z}async runOnEnd(J){for(let Y of this.plugins)if(Y.onEnd)await Y.onEnd(J)}async runOnError(J,Y,$){for(let Z of this.plugins)if(Z.onError){let Q={filePath:Y,sourceCode:$,config:this.config,log:this.createLogger(Z.name)};await Z.onError(J,Q)}}}var S0=new i;function AJ(J){return J}var F0=AJ({name:"strip-internal",version:"1.0.0",description:"Removes declarations marked with @internal",onDeclarations:(J)=>{return J.declarations.filter((Y)=>{if(Y.leadingComments){if(Y.leadingComments.some((Z)=>Z.includes("@internal")))return J.log.debug(`Stripping internal declaration: ${Y.name}`),!1}return!0})}});function D0(J){return AJ({name:"banner",version:"1.0.0",description:"Adds a banner comment to generated files",onAfterFile:(Y)=>{return`/**
36
+ * ${J.split(`
37
+ `).join(`
38
+ * `)}
39
+ */
40
+
41
+ `+Y.content}})}function v0(J){return AJ({name:"filter",version:"1.0.0",description:"Filters declarations by name",onDeclarations:(Y)=>{return Y.declarations.filter(($)=>{if($.kind==="import")return!0;return J($.name)})}})}var P=xY(CY(),1);import{readdir as PY}from"fs/promises";import{dirname as hY,extname as mY,isAbsolute as gY,join as uJ,resolve as fJ}from"path";import pJ from"process";import{pathToFileURL as OJ}from"url";function h0(J,Y){throw Error(Y||`Unexpected value: ${J}`)}async function h(J,Y){let $=Y.replace(/\r\n/g,`
42
+ `);if(!$.endsWith(`
43
+ `))$+=`
44
+ `;await jJ(J,$)}async function fY(J){let Y=J??f.root,$=await PY(Y,{withFileTypes:!0});return(await Promise.all($.map((Q)=>{let U=uJ(Y,Q.name);return Q.isDirectory()?fY(U):U}))).flat(1/0).filter((Q)=>typeof Q==="string"&&mY(Q)===".ts")}async function cJ(J){try{let Y=J?.cwd||pJ.cwd(),$=J?.tsconfigPath||uJ(Y,"tsconfig.json"),Q=await import(OJ($).href);if(Q.compilerOptions?.isolatedDeclarations===!0)return!0;if(Q.extends){let U=dJ($,Q.extends),X=U.endsWith(".json")?U:`${U}.json`,j=await import(OJ(X).href);if(j.compilerOptions?.isolatedDeclarations===!0)return!0;if(j.extends){let G=dJ(X,j.extends),z=G.endsWith(".json")?G:`${G}.json`;if((await import(OJ(z).href)).compilerOptions?.isolatedDeclarations===!0)return!0}}return!1}catch{return!1}}function lJ(J,Y){let $={isValid:!0,errors:[]},Z=P.default.createSourceFile(Y,J,P.default.ScriptTarget.Latest,!0,P.default.ScriptKind.TS),Q={getSourceFile:(H)=>{if(H===Y)return Z;return},getDefaultLibFileName:()=>"lib.d.ts",writeFile:()=>{},getCurrentDirectory:()=>"",getCanonicalFileName:(H)=>H,useCaseSensitiveFileNames:()=>!0,getNewLine:()=>`
45
+ `,fileExists:(H)=>H===Y,readFile:()=>{return}},X=[...P.default.createProgram({rootNames:[Y],options:{noEmit:!0,declaration:!0,skipLibCheck:!0,noLib:!0},host:Q}).getSyntacticDiagnostics(Z)];for(let H of X){let j=P.default.flattenDiagnosticMessageText(H.messageText,`
46
+ `),G=`TS${H.code}`,z;switch(H.code){case 1005:z="Add a semicolon at the end of the statement.";break;case 1109:z="Check for missing or malformed expressions.";break;case 1128:z="Ensure proper declaration syntax is used.";break;case 2304:z="Import or declare the missing type/value.";break;case 2307:z="Check that the module exists and is installed.";break;case 2322:z="Check type compatibility between the values.";break;case 2339:z="Add the missing property to the type definition.";break;case 2345:z="Check the argument types match the expected parameters.";break}if(H.file&&H.start!==void 0){let{line:A,character:N}=H.file.getLineAndCharacterOfPosition(H.start);$.errors.push({line:A+1,column:N+1,message:j,code:G,suggestion:z})}else $.errors.push({line:0,column:0,message:j,code:G,suggestion:z})}return $.isValid=$.errors.length===0,$}function aJ(J,Y,$){if(J===Y)return"";let Z=J.split(`
47
+ `),Q=Y.split(`
48
+ `),U=new Map,X=new Map;for(let z=0;z<Z.length;z++)U.set(Z[z],(U.get(Z[z])??0)+1);for(let z=0;z<Q.length;z++)X.set(Q[z],(X.get(Q[z])??0)+1);let H=[],j=[];for(let[z,A]of U){let N=A-(X.get(z)??0);for(let _=0;_<N;_++)H.push(z)}for(let[z,A]of X){let N=A-(U.get(z)??0);for(let _=0;_<N;_++)j.push(z)}if(H.length===0&&j.length===0)return"";let G=[`--- ${$}`,`+++ ${$}`];for(let z=0;z<H.length;z++)G.push(`- ${H[z]}`);for(let z=0;z<j.length;z++)G.push(`+ ${j[z]}`);return G.join(`
49
+ `)}function dJ(J,Y){if(gY(Y))return Y;if(Y.startsWith("."))return fJ(hY(J),Y);return fJ(pJ.cwd(),"node_modules",Y)}function sJ(J,Y,$,Z){let Q=J.split(`
50
+ `),U=[];function X(A){let _="",T=A<0?-A<<1|1:A<<1;do{let V=T&31;if(T>>>=5,T>0)V|=32;_+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[V]}while(T>0);return _}let H=0,j=0,G=0,z=Z.split(`
51
+ `).length;for(let A=0;A<Q.length;A++){if(Q[A].trim()===""){U.push("");continue}H=0;let _=Math.min(A,z-1),T=[],V=0-H,W=0,O=_-j,q=0-G;T.push(X(V)+X(W)+X(O)+X(q)),H=0,j=_,G=0,U.push(T.join(","))}return{version:3,file:Y,sourceRoot:"",sources:[$],sourcesContent:[Z],mappings:U.join(";")}}function nJ(J,Y){return`${J}
52
+ //# sourceMappingURL=${Y}
53
+ `}async function uY(J){let Y=Date.now(),$={...f,...J};if($.logLevel)r($.logLevel);else if($.verbose)r("debug");let Z=new i;if($.plugins&&$.plugins.length>0){for(let V of $.plugins)Z.register(V),K.debug(`Registered plugin: ${V.name}`);$=await Z.runOnStart($)}if($.isolatedDeclarations===void 0)$.isolatedDeclarations=await cJ($);let Q=null;if($.incremental){if(Q=new zJ($),$.clearCache)K.debug("Clearing build cache..."),Q.clear();else if(Q.load()){let W=Q.getStats();K.debug(`Loaded build cache with ${W.entries} entries`)}else K.debug("No existing build cache found, starting fresh");FJ($.cwd)}let U={filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},X=0;K.debug("Starting DTS generation..."),K.debug("Config:",$);let H=await lY($),j=H.slice(),G=null;if($.autoIncludeReExports!==!1&&j.length>0){G=await BJ(j);let V=x($.cwd,$.root),W=$.exclude||[],O=[];for(let q of G.reachable){if(j.includes(q))continue;if(q.endsWith(".d.ts"))continue;if(q.includes("node_modules"))continue;if(t(q,W,V))continue;O.push(q)}if(O.length>0)j=[...j,...O],K.debug(`Auto-included ${O.length} file(s) reached via relative re-exports`)}if(Q){let V=Q.prune(new Set(j),$.cwd);if(V>0)K.debug(`Pruned ${V} deleted files from cache`)}if(K.debug(`Found ${j.length} TypeScript files`),$.progress&&j.length>0){let V=$.parallel?"parallel":"sequential";K.info(`Processing ${j.length} files (${V})...`)}let z=async(V,W)=>{let O;try{let q=kJ(V,$);if(Q){let S=Q.getCachedIfValid(V,$.cwd);if(S)return await o(u(q),{recursive:!0}),await h(q,S),K.debug(`[cached] ${v($.cwd,q)}`),{success:!0,file:V,declarationCount:0,importCount:0,exportCount:0,cached:!0,validationErrorCount:0}}O=W??await y(V);let{content:B,declarationCount:k,importCount:R,exportCount:L}=await tJ(V,O,$,Z),w=0;if($.dryRun)K.info(`[dry-run] Would generate: ${q}`),K.debug("--- Content preview ---"),K.debug(B.slice(0,500)+(B.length>500?`
54
+ ...`:"")),K.debug("--- End preview ---");else{if($.diff)try{let M=await y(q),F=aJ(M,B,v($.cwd,q));if(F)K.info(`
55
+ ${F}`);else K.debug(`[no changes] ${q}`)}catch{K.info(`[new file] ${v($.cwd,q)}`)}await o(u(q),{recursive:!0});let S=B;if($.declarationMap&&O){let M=q.split("/").pop()||"output.d.ts",F=v(u(q),V),D=`${M}.map`,p=sJ(B,M,F,O),C=`${q}.map`;await h(C,JSON.stringify(p)),S=nJ(B,D),K.debug(` Generated source map: ${v($.cwd,C)}`)}if($.prettier||$.indentStyle||$.indentSize){let M=await g(S,{usePrettier:$.prettier,builtIn:{indentSize:$.indentSize||2,useTabs:$.indentStyle==="tabs",normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}},q);if(S=M.content,M.warnings?.length)for(let F of M.warnings)K.warn(`[format] ${F}`)}if(await h(q,S),Q&&O)Q.update(V,O,S,$.cwd);if($.validate){let M=lJ(B,q);if(!M.isValid){w=M.errors.length,K.warn(`[validation] ${v($.cwd,q)} has ${M.errors.length} error(s):`);for(let F of M.errors){let D=` Line ${F.line}:${F.column}`;if(F.code)D+=` [${F.code}]`;if(D+=` - ${F.message}`,K.warn(D),F.suggestion)K.warn(` Suggestion: ${F.suggestion}`)}}else K.debug(`[validation] ${q} - OK`)}K.debug(`Generated: ${q}`)}return{success:!0,file:V,declarationCount:k,importCount:R,exportCount:L,validationErrorCount:w}}catch(q){let B=GJ(q,V,O);if($.plugins&&$.plugins.length>0)await Z.runOnError(q instanceof Error?q:Error(String(q)),V,O||"");return{success:!1,file:V,declarationCount:0,importCount:0,exportCount:0,dtsError:B,validationErrorCount:0}}},A=$.parallel||$.parallel!==!1&&j.length>=10,N=$.concurrency||(dY?.()??8),_=new Map;if(A&&j.length>1){let V=j.map(async(W)=>{try{let O=await y(W);return{file:W,source:O}}catch{return{file:W,source:null}}});for(let W of await Promise.all(V))if(W.source!==null)_.set(W.file,W.source)}let T=(V)=>{if(U.filesProcessed++,V.success){if(V.cached)X++;else U.filesGenerated++,U.declarationsFound+=V.declarationCount,U.importsProcessed+=V.importCount,U.exportsProcessed+=V.exportCount;if($.validate){if(U.filesValidated++,V.validationErrorCount)U.validationErrors+=V.validationErrorCount}}else if(U.filesFailed++,V.dtsError){U.errors.push(V.dtsError);let W=PJ(V.dtsError);if($.continueOnError)K.warn(W);else throw K.error(W),Error(V.dtsError.message)}};if(A)for(let V=0;V<j.length;V+=N){let W=j.slice(V,V+N),O=await Promise.all(W.map((q)=>z(q,_.get(q))));for(let q of O)T(q);if($.progress){let q=Math.round(U.filesProcessed/j.length*100);K.info(`[${U.filesProcessed}/${j.length}] ${q}%`)}}else for(let V of j){let W=await z(V);if(T(W),$.progress){let O=Math.round(U.filesProcessed/j.length*100),q=W.cached?"[cached]":"";K.info(`[${U.filesProcessed}/${j.length}] ${O}% - ${v($.cwd,V)} ${q}`)}}if(Q)Q.save(),K.debug("Saved build cache");if(!$.bundle){let V=[];if(G)for(let W of G.unresolved)V.push({from:W.from,specifier:W.specifier,reason:"missing"});if($.autoIncludeReExports===!1&&j.length>0){let W=new Set(j);for(let O of j){let q;try{q=await y(O)}catch{continue}for(let B of _J(q)){if(!B.specifier.startsWith("."))continue;let k=KJ(B.specifier,O);if(!k.resolved)V.push({from:O,specifier:B.specifier,reason:"missing"});else if(!W.has(k.resolved))V.push({from:O,specifier:B.specifier,reason:"not-emitted"})}}}if(V.length>0){let W=[];W.push(`Found ${V.length} re-export(s) pointing at siblings that won't be in the output:`);for(let q of V){let B=v($.cwd,q.from);if(q.reason==="missing")W.push(` ${B} \u2192 '${q.specifier}' (path not found on disk)`);else W.push(` ${B} \u2192 '${q.specifier}' (resolved but not in entrypoints; set autoIncludeReExports: true or add to entrypoints)`)}let O=W.join(`
56
+ `);if($.failOnUnresolvedReExport)throw Error(O);K.warn(O),K.warn('Generated .d.ts files reference modules that were not emitted \u2014 consumers will see "has no exported member" errors.')}}if($.bundle&&(U.filesGenerated>0||X>0)&&H.length>0)try{K.debug("Bundling declarations...");let V=new Map,W=async(q)=>{let B=V.get(q);if(B!==void 0)return B;return B=await y(q),V.set(q,B),B};for(let q of j)await W(q);let O=H.length===1&&!!$.bundleOutput;for(let q of H){let B=await BJ([q],{includeImports:!0}),k=new Set;for(let M of B.reachable){if(M.endsWith(".d.ts"))continue;if(M.includes("node_modules"))continue;k.add(M)}let R=j.filter((M)=>k.has(M));if(!R.includes(q))R.push(q);let L=new Map;for(let M of R){let F=V.get(M)??await W(M);L.set(M,F)}let w=await TJ(R,L,$),S=O?x($.cwd,$.outdir,$.bundleOutput):kJ(q,$);if(await o(u(S),{recursive:!0}),await h(S,w.content),K.info(`Bundled ${w.files.length} files to: ${v($.cwd,S)}`),O)break}}catch(V){let W=V instanceof Error?V.message:String(V);K.error(`Bundle failed: ${W}`)}if(U.durationMs=Date.now()-Y,$.stats)if($.outputFormat==="json")console.log(JSON.stringify(U,null,2));else{if(K.info(`
57
+ --- Generation Statistics ---`),K.info(`Files processed: ${U.filesProcessed}`),K.info(`Files generated: ${U.filesGenerated}`),X>0)K.info(`Files cached: ${X}`);if(U.filesFailed>0)K.info(`Files failed: ${U.filesFailed}`);if(K.info(`Declarations found: ${U.declarationsFound}`),K.info(`Imports processed: ${U.importsProcessed}`),K.info(`Exports processed: ${U.exportsProcessed}`),U.filesValidated>0){if(K.info(`Files validated: ${U.filesValidated}`),U.validationErrors>0)K.info(`Validation errors: ${U.validationErrors}`)}if(K.info(`Duration: ${U.durationMs}ms`),U.errors.length>0){K.info(`
58
+ Errors:`);for(let V of U.errors){let W=` - ${V.file}`;if(V.location)W+=`:${V.location.line}:${V.location.column}`;if(V.code)W+=` [${V.code}]`;if(W+=`: ${V.message}`,K.info(W),V.suggestion)K.info(` Suggestion: ${V.suggestion}`)}}K.info(`-----------------------------
59
+ `)}if($.plugins&&$.plugins.length>0)await Z.runOnEnd(U);return K.debug("DTS generation complete!"),U}var pY=50,d=new Map;function cY(J){let Y=d.get(J);if(!Y){if(Y=new oJ(J),d.set(J,Y),d.size>pY){let $=d.keys().next().value;if($!==void 0)d.delete($)}}return Y}function t(J,Y,$){if(!Y||Y.length===0)return!1;let Z=v($,J);for(let Q of Y){let U=cY(Q);if(U.match(Z)||U.match(J))return!0}return!1}async function lY(J){let Y=[],$=x(J.cwd,J.root),Z=J.exclude||[];for(let Q of J.entrypoints)if(Q.startsWith("/")&&Q.endsWith(".ts")){if(!Q.endsWith(".d.ts")&&!Q.includes("node_modules")){if(!t(Q,Z,$))Y.push(Q)}}else{let U=new oJ(Q);for await(let X of U.scan({cwd:$,absolute:!0,onlyFiles:!0}))if(!X.endsWith(".d.ts")&&!X.includes("node_modules")){if(!t(X,Z,$))Y.push(X)}}return[...new Set(Y)]}function kJ(J,Y){let $=x(Y.cwd,Y.root),Q=v($,J).replace(/\.(m?tsx?|cts)$/,(U)=>{if(U===".mts")return".d.mts";if(U===".cts")return".d.cts";return".d.ts"});if(Y.outputStructure==="mirror")return x(Y.cwd,Y.outdir,Q);else{let U=Q.split("/").pop();return x(Y.cwd,Y.outdir,U)}}async function Z1(J,Y){return(await rJ(J,Y)).content}async function rJ(J,Y,$){let Z=await y(J);return tJ(J,Z,Y,$)}async function tJ(J,Y,$,Z){let Q=Y;if(Z)Q=await Z.runOnBeforeFile(J,Y);let U=l(Q,J,$.keepComments,$.isolatedDeclarations??!1);if(Z)U=await Z.runOnDeclarations(J,Q,U);let X=0,H=0;for(let z=0;z<U.length;z++){let A=U[z];if(A.kind==="import")X++;if(A.kind==="export"||A.isExported)H++}let G=iJ(U,{filePath:J,sourceCode:Q,declarations:U},$.keepComments,$.importOrder);if(Z)G=await Z.runOnAfterFile(J,Q,G);return{content:G,declarationCount:U.length,importCount:X,exportCount:H}}async function Q1(J){let Y={...f,...J};if(Y.logLevel)r(Y.logLevel);let $=x(Y.cwd,Y.root),Z=150,Q=5,U=1e4,X={pendingChanges:new Set,debounceTimer:null,isProcessing:!1,errorCount:0,lastErrorTime:0};K.info(`Watching for changes in ${$}...`),K.info(`Press Ctrl+C to stop
60
+ `);try{await uY(Y),K.info(`[watch] Initial generation complete
61
+ `)}catch(A){let N=A instanceof Error?A.message:String(A);K.error(`[watch] Initial generation failed: ${N}`),K.info(`[watch] Continuing to watch for changes...
62
+ `)}async function H(){if(X.isProcessing||X.pendingChanges.size===0)return;let A=Date.now();if(X.errorCount>=Q){if(A-X.lastErrorTime<U){K.warn(`[watch] Too many errors, pausing for ${Math.ceil((U-(A-X.lastErrorTime))/1000)}s...`);return}X.errorCount=0}X.isProcessing=!0;let N=Array.from(X.pendingChanges);X.pendingChanges.clear();let _=new Date().toLocaleTimeString();if(N.length===1)K.info(`
63
+ [${_}] File changed: ${N[0]}`);else K.info(`
64
+ [${_}] ${N.length} files changed`);let T=0,V=0;for(let W of N){let O=x($,W);try{let q=Y.exclude||[];if(t(O,q,$)){K.debug(` Skipping excluded file: ${W}`);continue}if(!await EJ(O).exists()){K.debug(` Skipping deleted file: ${W}`);continue}let k=kJ(O,Y),{content:R}=await rJ(O,Y);await o(u(k),{recursive:!0}),await h(k,R),K.info(` \u2713 ${v(Y.cwd,k)}`),T++}catch(q){V++,X.errorCount++,X.lastErrorTime=Date.now();let B=GJ(q,O);if(K.error(` \u2717 ${W}: ${B.message}`),B.suggestion)K.error(` Suggestion: ${B.suggestion}`)}}if(N.length>1)K.info(` Done: ${T} generated, ${V} failed`);if(V===0)X.errorCount=0;if(X.isProcessing=!1,X.pendingChanges.size>0)X.debounceTimer=setTimeout(H,Z)}function j(A){if(X.pendingChanges.add(A),X.debounceTimer)clearTimeout(X.debounceTimer);X.debounceTimer=setTimeout(H,Z)}let z=yJ([I?"bun":"node","-e",`
65
+ const fs = require('fs');
66
+
67
+ const rootPath = '${$}';
68
+
69
+ fs.watch(rootPath, { recursive: true }, (eventType, filename) => {
70
+ if (filename && filename.endsWith('.ts') && !filename.endsWith('.d.ts')) {
71
+ console.log(\`CHANGED:\${filename}\`);
72
+ }
73
+ });
74
+
75
+ // Keep process alive
76
+ setInterval(() => {}, 1000);
77
+ `],{stdout:"pipe",stderr:"inherit"});if(I){let A=z.stdout.getReader(),N=new TextDecoder,_="";while(!0){let{done:T,value:V}=await A.read();if(T)break;_+=N.decode(V,{stream:!0});let W=_.split(`
78
+ `);_=W.pop()||"";for(let O of W)if(O.startsWith("CHANGED:")){let q=O.slice(8);j(q)}}}else{let A=z.stdout,N="";A.on("data",(_)=>{N+=_.toString();let T=N.split(`
79
+ `);N=T.pop()||"";for(let V of T)if(V.startsWith("CHANGED:")){let W=V.slice(8);j(W)}}),await z.exited}}
80
+ export{TJ as ua,LJ as va,qY as wa,iY as xa,oY as ya,zJ as za,FJ as Aa,I as Ba,Q0 as Ca,U0 as Da,EJ as Ea,jJ as Fa,yJ as Ga,y as Ha,X0 as Ia,q0 as Ja,z0 as Ka,m as La,E as Ma,bJ as Na,KY as Oa,_Y as Pa,xJ as Qa,CJ as Ra,BY as Sa,j0 as Ta,G0 as Ua,H0 as Va,W0 as Wa,K0 as Xa,_0 as Ya,B0 as Za,GJ as _a,PJ as $a,A0 as ab,g as bb,DY as cb,k0 as db,N0 as eb,i as fb,S0 as gb,AJ as hb,F0 as ib,D0 as jb,v0 as kb,h0 as lb,h as mb,fY as nb,cJ as ob,lJ as pb,aJ as qb,sJ as rb,nJ as sb,uY as tb,Z1 as ub,Q1 as vb};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{tb as I}from"./chunk-8dx98fd5.js";function z(J={}){let{onBuildStart:K=!1,onBuildEnd:L=!0,onGenerated:M,onError:C,...N}=J,w,q,F=async()=>{let j={...N};if(!j.outdir&&w)j.outdir=w;if(!j.entrypoints&&q)j.entrypoints=q;try{let k=await I(j);M?.(k)}catch(k){let H=k instanceof Error?k:Error(String(k));if(C?.(H),!C)console.error("[dtsx] Generation failed:",H.message)}};return{name:"dtsx",esbuildOptions(j){if(j.outdir&&typeof j.outdir==="string")w=j.outdir;if(j.entryPoints){if(Array.isArray(j.entryPoints))q=j.entryPoints;else if(typeof j.entryPoints==="object")q=Object.values(j.entryPoints)}},async buildStart(){if(K)await F()},async buildEnd(j){if(L)await F()}}}var R=z,T=z,V=z;
2
+ import{tb as I}from"./chunk-dzgms5s6.js";function z(J={}){let{onBuildStart:K=!1,onBuildEnd:L=!0,onGenerated:M,onError:C,...N}=J,w,q,F=async()=>{let j={...N};if(!j.outdir&&w)j.outdir=w;if(!j.entrypoints&&q)j.entrypoints=q;try{let k=await I(j);M?.(k)}catch(k){let H=k instanceof Error?k:Error(String(k));if(C?.(H),!C)console.error("[dtsx] Generation failed:",H.message)}};return{name:"dtsx",esbuildOptions(j){if(j.outdir&&typeof j.outdir==="string")w=j.outdir;if(j.entryPoints){if(Array.isArray(j.entryPoints))q=j.entryPoints;else if(typeof j.entryPoints==="object")q=Object.values(j.entryPoints)}},async buildStart(){if(K)await F()},async buildEnd(j){if(L)await F()}}}var R=z,T=z,V=z;
3
3
  export{z as ma,R as na,T as oa,V as pa};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  var K={debug:0,info:1,warn:2,error:3,silent:4},B="info",F="[dtsx]",I=!1,H=null;function y(j){return K[j]>=K[B]}function Q(){if(!I)return"";return`[${new Date().toISOString().slice(11,23)}] `}function S(j,C){let k=Q();if(j||k)return[`${k}${j}`,...C];return C}function z(j,C,k){let q=S(C,k);if(H){H(j,...q);return}switch(j){case"debug":console.debug(...q);break;case"info":console.log(...q);break;case"warn":console.warn(...q);break;case"error":console.error(...q);break}}function J(j){return{debug:(...k)=>{if(y("debug"))z("debug",j,k)},info:(...k)=>{if(y("info"))z("info",j,k)},warn:(...k)=>{if(y("warn"))z("warn",j,k)},error:(...k)=>{if(y("error"))z("error",j,k)},setLevel:(k)=>{B=k},getLevel:()=>B,child:(k)=>{let q=j?`${j}:${k}`:`[${k}]`;return J(q)},time:(k)=>{let q=performance.now();return()=>{let M=performance.now()-q;if(y("debug"))z("debug",j,[`${k}: ${M.toFixed(2)}ms`])}},progress:(k)=>{if(y("info"))if(typeof process<"u"&&process.stdout?.isTTY)process.stdout.write(`\r${j} ${k}`);else z("info",j,[k])}}}function Y(j={}){if(j.level)B=j.level;if(j.prefix!==void 0)F=j.prefix;if(j.timestamps!==void 0)I=j.timestamps;if(j.output)H=j.output;return J(F)}var U=J(F);function Z(j){return U.child(j)}function $(j){B=j}function N(){return B}function D(j){F=j}function G(j){I=j}var X={debug:()=>{},info:()=>{},warn:()=>{},error:()=>{},setLevel:()=>{},getLevel:()=>"silent",child:()=>X,time:()=>()=>{},progress:()=>{}};
3
- export{Y as Uc,U as Vc,Z as Wc,$ as Xc,N as Yc,D as Zc,G as _c,X as $c};
3
+ export{Y as Vc,U as Wc,Z as Xc,$ as Yc,N as Zc,D as _c,G as $c,X as ad};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{l as a,m as b,n as c,o as d,p as e,q as f,r as g}from"./chunk-r6v1qdqb.js";import"./chunk-dzgms5s6.js";import"./chunk-thhd43x5.js";import"./chunk-2n1bbm2c.js";import"./chunk-x4v9kajr.js";import"./chunk-rsv17jh8.js";import"./chunk-d1xj2pjv.js";import"./chunk-vpjw38x7.js";import"./chunk-285mqzvx.js";import"./chunk-3w5aqasc.js";import"./chunk-gssantc8.js";import"./chunk-mcdb3q06.js";export{b as sortProjectsByDependencies,f as resolveWorkspacePatterns,c as generateWorkspace,d as generateMonorepo,g as generateFromPackageWorkspaces,a as discoverWorkspaceProjects,e as discoverWorkspaceFromPackageJson};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{ec as K}from"./chunk-2w3g3g00.js";import{Vc as _}from"./chunk-57agx6g8.js";import{existsSync as j,mkdirSync as w,readFileSync as b,writeFileSync as V}from"fs";import{basename as H,join as R}from"path";function N(q){let z={description:"",params:[],examples:[],tags:{},see:[],throws:[]};if(!q||q.length===0)return z;for(let A of q){let G=A.replace(/^\/\*\*/,"").replace(/\*\/$/,"").split(`
2
+ import{ec as K}from"./chunk-thhd43x5.js";import{Wc as _}from"./chunk-gssantc8.js";import{existsSync as j,mkdirSync as w,readFileSync as b,writeFileSync as V}from"fs";import{basename as H,join as R}from"path";function N(q){let z={description:"",params:[],examples:[],tags:{},see:[],throws:[]};if(!q||q.length===0)return z;for(let A of q){let G=A.replace(/^\/\*\*/,"").replace(/\*\/$/,"").split(`
3
3
  `).map((X)=>X.replace(/^\s*\*\s?/,"")).join(`
4
4
  `).trim(),Q=G.search(/@\w+/);if(Q===-1){z.description=G;continue}else if(Q>0)z.description=G.slice(0,Q).trim(),G=G.slice(Q);let U=/@(\w+)(?:\s+\{([^}]+)\})?\s*([^\n@]*(?:\n(?!@)[^\n@]*)*)/g,W;while((W=U.exec(G))!==null){let[,X,Y,Z]=W,$=Z.trim();switch(X){case"param":{let v=$.match(/^(\[)?(\w+)\]?\s*(?:-\s*)?(.*)/);if(v)z.params.push({name:v[2],type:Y,description:v[3].trim(),optional:!!v[1]});break}case"returns":case"return":z.returns={type:Y,description:$};break;case"example":z.examples.push($);break;case"deprecated":z.deprecated=$||"Deprecated";break;case"since":z.since=$;break;case"see":z.see.push($);break;case"throws":case"throw":z.throws.push({type:Y,description:$});break;case"category":z.category=$;break;default:if(!z.tags[X])z.tags[X]=[];z.tags[X].push($)}}}return z}function M(q,z){let A=N(q.leadingComments),G="";switch(q.kind){case"function":G=h(q);break;case"variable":G=T(q);break;case"interface":G=F(q);break;case"type":G=S(q);break;case"class":G=k(q);break;case"enum":G=x(q);break;default:G=q.text||q.name}let Q={name:q.name,kind:q.kind,signature:G,jsdoc:A,isExported:q.isExported,isDefault:q.isDefault,sourceFile:z};if(q.members&&q.members.length>0)Q.members=q.members.map((U)=>M(U,z));return Q}function h(q){let z=[];if(q.isExported)z.push("export");if(q.isDefault)z.push("default");if(z.push("function"),z.push(q.name),q.generics)z.push(q.generics);if(q.parameters){let A=q.parameters.map((G)=>{let Q="";if(G.rest)Q+="...";if(Q+=G.name,G.optional)Q+="?";if(G.type)Q+=`: ${G.type}`;return Q}).join(", ");z.push(`(${A})`)}else z.push("()");if(q.returnType)z.push(`: ${q.returnType}`);return z.join(" ").replace(/\s+/g," ")}function T(q){let z=[];if(q.isExported)z.push("export");if(z.push("const"),z.push(q.name),q.typeAnnotation)z.push(`: ${q.typeAnnotation}`);return z.join(" ")}function F(q){let z=[];if(q.isExported)z.push("export");if(z.push("interface"),z.push(q.name),q.generics)z.push(q.generics);if(q.extends)z.push(`extends ${q.extends}`);return z.join(" ")}function S(q){let z=[];if(q.isExported)z.push("export");if(z.push("type"),z.push(q.name),q.generics)z.push(q.generics);if(z.push("="),q.typeAnnotation)z.push(q.typeAnnotation);return z.join(" ")}function k(q){let z=[];if(q.isExported)z.push("export");if(q.isDefault)z.push("default");if(z.push("class"),z.push(q.name),q.generics)z.push(q.generics);if(q.extends)z.push(`extends ${q.extends}`);if(q.implements&&q.implements.length>0)z.push(`implements ${q.implements.join(", ")}`);return z.join(" ")}function x(q){let z=[];if(q.isExported)z.push("export");return z.push("enum"),z.push(q.name),z.join(" ")}async function P(q,z={}){let A=[],G=new Map;for(let Q of q){if(!j(Q)){_.warn(`File not found: ${Q}`);continue}let U=b(Q,"utf-8"),W=K(U,Q,!0);for(let X of W){if(X.kind==="import")continue;if(!z.includePrivate&&X.name.startsWith("_"))continue;if(!z.includeInternal&&X.leadingComments?.some((Z)=>Z.includes("@internal")))continue;let Y=M(X,Q);if(A.push(Y),z.groupByCategory&&Y.jsdoc.category){let Z=Y.jsdoc.category;if(!G.has(Z))G.set(Z,[]);G.get(Z).push(Y)}}}return{title:z.title||"API Documentation",description:z.description,entries:A,categories:G,generatedAt:new Date}}function B(q,z={}){let A=[];if(A.push(`# ${q.title}`),A.push(""),q.description)A.push(q.description),A.push("");if(A.push(`> Generated on ${q.generatedAt.toISOString()}`),A.push(""),A.push("## Table of Contents"),A.push(""),z.groupByCategory&&q.categories.size>0)for(let G of q.categories.keys())A.push(`- [${G}](#${E(G)})`);else{let G=I(q.entries);for(let[Q,U]of G)if(U.length>0)A.push(`- [${O(Q)}](#${E(O(Q))})`)}if(A.push(""),z.groupByCategory&&q.categories.size>0)for(let[G,Q]of q.categories){A.push(`## ${G}`),A.push("");for(let U of Q)A.push(...L(U,z))}else{let G=I(q.entries);for(let[Q,U]of G)if(U.length>0){A.push(`## ${O(Q)}`),A.push("");for(let W of U)A.push(...L(W,z))}}return A.join(`
5
5
  `)}function L(q,z){let A=[];if(A.push(`### ${q.name}`),A.push(""),q.jsdoc.deprecated)A.push(`> **Deprecated:** ${q.jsdoc.deprecated}`),A.push("");if(A.push("```typescript"),A.push(q.signature),A.push("```"),A.push(""),q.jsdoc.description)A.push(q.jsdoc.description),A.push("");if(q.jsdoc.params.length>0){A.push("**Parameters:**"),A.push(""),A.push("| Name | Type | Description |"),A.push("|------|------|-------------|");for(let G of q.jsdoc.params){let Q=G.optional?" (optional)":"",U=G.type||"any";A.push(`| \`${G.name}\`${Q} | \`${U}\` | ${G.description} |`)}A.push("")}if(q.jsdoc.returns){A.push("**Returns:**"),A.push("");let G=q.jsdoc.returns.type?`\`${q.jsdoc.returns.type}\``:"";A.push(`${G} ${q.jsdoc.returns.description}`),A.push("")}if(q.jsdoc.throws.length>0){A.push("**Throws:**"),A.push("");for(let G of q.jsdoc.throws){let Q=G.type?`\`${G.type}\``:"";A.push(`- ${Q} ${G.description}`)}A.push("")}if(q.jsdoc.examples.length>0){A.push("**Examples:**"),A.push("");for(let G of q.jsdoc.examples)A.push("```typescript"),A.push(G),A.push("```"),A.push("")}if(q.jsdoc.see.length>0){A.push("**See also:**"),A.push("");for(let G of q.jsdoc.see)A.push(`- ${G}`);A.push("")}if(q.jsdoc.since)A.push(`*Since: ${q.jsdoc.since}*`),A.push("");if(z.includeSourceLinks&&q.sourceFile){let G=q.sourceFile;if(z.sourceBaseUrl)A.push(`[Source](${z.sourceBaseUrl}/${G})`);else A.push(`*Source: ${G}*`);A.push("")}if(q.members&&q.members.length>0){A.push("**Members:**"),A.push("");for(let G of q.members)if(A.push(`#### ${G.name}`),A.push(""),A.push("```typescript"),A.push(G.signature),A.push("```"),A.push(""),G.jsdoc.description)A.push(G.jsdoc.description),A.push("")}return A.push("---"),A.push(""),A}function C(q,z={}){let A=B(q,z);return`<!DOCTYPE html>
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ var j=Object.create;var{getPrototypeOf:k,defineProperty:i,getOwnPropertyNames:l}=Object;var m=Object.prototype.hasOwnProperty;function n(a){return this[a]}var o,p,q=(a,b,d)=>{var f=a!=null&&typeof a==="object";if(f){var g=b?o??=new WeakMap:p??=new WeakMap,h=g.get(a);if(h)return h}d=a!=null?j(k(a)):{};let c=b||!a||!a.__esModule?i(d,"default",{value:a,enumerable:!0}):d;for(let e of l(a))if(!m.call(c,e))i(c,e,{get:n.bind(a,e),enumerable:!0});if(f)g.set(a,c);return c};var r=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var s=import.meta.require;
3
+ export{q as bd,r as cd,s as dd};