@dtsx/dtsx 0.11.44 → 0.11.46

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 (213) hide show
  1. package/dist/bin/cli.js +1 -1
  2. package/dist/{chunk-g19c3m7s.js → chunk-013mp499.js} +2 -2
  3. package/dist/chunk-0af0hsfc.js +5 -0
  4. package/dist/{chunk-c8s4d7qk.js → chunk-0gwj2fct.js} +6 -6
  5. package/dist/{chunk-ns44qxdd.js → chunk-0kvy1dh8.js} +4 -4
  6. package/dist/{chunk-59jw51gg.js → chunk-0nw1w523.js} +5 -5
  7. package/dist/{chunk-an5ra7tr.js → chunk-1xgcs6aq.js} +4 -4
  8. package/dist/{chunk-vxghzchm.js → chunk-1y19tmb0.js} +3 -3
  9. package/dist/{chunk-ka22zwye.js → chunk-1z9550gn.js} +8 -8
  10. package/dist/{chunk-mhyqvwcg.js → chunk-290jpwny.js} +3 -3
  11. package/dist/{chunk-vv8e8pa3.js → chunk-2h5p8n7w.js} +2 -2
  12. package/dist/{chunk-cgaw8fsn.js → chunk-2wxgt73q.js} +3 -3
  13. package/dist/{chunk-cjhmmqxd.js → chunk-2xp48sa2.js} +2 -2
  14. package/dist/{chunk-65d3dga1.js → chunk-4kn7y9ns.js} +3 -3
  15. package/dist/chunk-4mrq1jdn.js +3 -0
  16. package/dist/{chunk-th9tcxga.js → chunk-587w6ktw.js} +2 -2
  17. package/dist/{chunk-vz4fc70e.js → chunk-5cgpcdsb.js} +3 -3
  18. package/dist/chunk-6bmr0e81.js +14 -0
  19. package/dist/{chunk-yqvn592m.js → chunk-6m8f0y7w.js} +2 -2
  20. package/dist/{chunk-mfp35a3b.js → chunk-8ab8793q.js} +14 -14
  21. package/dist/{chunk-mjzee617.js → chunk-8gksa73c.js} +17 -17
  22. package/dist/chunk-8qpzh9yc.js +4 -0
  23. package/dist/chunk-986k5306.js +3 -0
  24. package/dist/{chunk-njqzhkzy.js → chunk-9kfzjkd1.js} +10 -10
  25. package/dist/chunk-a0900w7b.js +3 -0
  26. package/dist/{chunk-9etacmfx.js → chunk-a8djrg2n.js} +3 -3
  27. package/dist/{chunk-2y5b6hdw.js → chunk-ac95p5v4.js} +6 -6
  28. package/dist/{chunk-s7k223zx.js → chunk-c7dw612y.js} +2 -2
  29. package/dist/{chunk-ptbd3dac.js → chunk-dhzr60ge.js} +2 -2
  30. package/dist/{chunk-der2ssgq.js → chunk-dpd2b7dd.js} +2 -2
  31. package/dist/{chunk-eptz3q7r.js → chunk-dw84pjmf.js} +4 -4
  32. package/dist/chunk-ehpz5rg3.js +31 -0
  33. package/dist/chunk-em9pz9s0.js +3 -0
  34. package/dist/{chunk-932kxt70.js → chunk-g2191y9b.js} +4 -4
  35. package/dist/{chunk-xgf6djk3.js → chunk-g9emajpc.js} +2 -2
  36. package/dist/{chunk-4hkf7dda.js → chunk-g9kqk7y0.js} +4 -4
  37. package/dist/{chunk-6mryvpxj.js → chunk-ga769zw5.js} +5 -5
  38. package/dist/{chunk-9qv34ymq.js → chunk-gqk2s9wt.js} +2 -2
  39. package/dist/{chunk-dzdwc2fh.js → chunk-gsvb5wey.js} +2 -2
  40. package/dist/chunk-h7tsf2qg.js +40 -0
  41. package/dist/chunk-hbe5sg17.js +3 -0
  42. package/dist/chunk-hcf0hd85.js +3 -0
  43. package/dist/{chunk-3rwbf45t.js → chunk-hgg4aqvf.js} +2 -2
  44. package/dist/{chunk-g4rmn34j.js → chunk-j0y149qx.js} +2 -2
  45. package/dist/chunk-j32xn94r.js +3 -0
  46. package/dist/chunk-jtq24yb8.js +3 -0
  47. package/dist/{chunk-5aqwt0a0.js → chunk-jwcw24cc.js} +4 -4
  48. package/dist/{chunk-cynfv4dt.js → chunk-k0exaspt.js} +3 -3
  49. package/dist/chunk-k472ve44.js +3 -0
  50. package/dist/chunk-k75z3nef.js +3 -0
  51. package/dist/chunk-kcbbz8t7.js +37 -0
  52. package/dist/{chunk-m3y5knzq.js → chunk-kcfc6zg6.js} +5 -5
  53. package/dist/{chunk-8v43ne8p.js → chunk-kdqckf54.js} +3 -3
  54. package/dist/{chunk-7x9tawkf.js → chunk-kp6qv2fb.js} +2 -2
  55. package/dist/{chunk-vgyjw95e.js → chunk-ktt2m4eh.js} +4 -4
  56. package/dist/{chunk-jbxb317g.js → chunk-nmjxxcvg.js} +6 -6
  57. package/dist/{chunk-hnckev96.js → chunk-nxqap7nx.js} +4 -4
  58. package/dist/chunk-pjqd38w1.js +8 -0
  59. package/dist/{chunk-gma09qy6.js → chunk-pp9aevcb.js} +2 -2
  60. package/dist/{chunk-9hjd6p38.js → chunk-qmg1535a.js} +2 -2
  61. package/dist/chunk-rdb7j1d6.js +3 -0
  62. package/dist/{chunk-qevb6d6j.js → chunk-rkpwmkrm.js} +2 -2
  63. package/dist/{chunk-zp93zcn5.js → chunk-rnvqc8st.js} +2 -2
  64. package/dist/{chunk-sqnhxtbk.js → chunk-rwdcmcx3.js} +3 -3
  65. package/dist/{chunk-7ez7gynw.js → chunk-ry1c863d.js} +2 -2
  66. package/dist/{chunk-6pr23q72.js → chunk-s9e2a0t7.js} +2 -2
  67. package/dist/{chunk-k5wz43yh.js → chunk-srfpcjtn.js} +2 -2
  68. package/dist/{chunk-rka9z03a.js → chunk-swmftav9.js} +4 -4
  69. package/dist/chunk-t03y036d.js +3 -0
  70. package/dist/{chunk-h1xwd278.js → chunk-t7jvkq9j.js} +2 -2
  71. package/dist/{chunk-q45jkpya.js → chunk-t89jepjk.js} +2 -2
  72. package/dist/{chunk-7krb9b1s.js → chunk-thzkm86y.js} +2 -2
  73. package/dist/chunk-trvp818c.js +4 -0
  74. package/dist/chunk-tsbthwf0.js +7 -0
  75. package/dist/chunk-v4z6808c.js +3 -0
  76. package/dist/chunk-vdhzc40m.js +10 -0
  77. package/dist/{chunk-2d3nbfth.js → chunk-wrjrwren.js} +2 -2
  78. package/dist/{chunk-ehgnwdn9.js → chunk-x6ddycvm.js} +2 -2
  79. package/dist/{chunk-d0aqaj02.js → chunk-xg8yhpe6.js} +2 -2
  80. package/dist/{chunk-3shq1bjr.js → chunk-xm63aee8.js} +2 -2
  81. package/dist/chunk-y1xq2hm4.js +3 -0
  82. package/dist/{chunk-3eb0gc0y.js → chunk-yaej6q2v.js} +1 -1
  83. package/dist/{chunk-waan03ga.js → chunk-yapmefw7.js} +11 -11
  84. package/dist/chunk-z0aa0gd8.js +3 -0
  85. package/dist/{chunk-0cynxv6w.js → chunk-zaka2jk1.js} +2 -2
  86. package/dist/src/augmentation-graph.js +1 -1
  87. package/dist/src/binding-patterns.js +1 -1
  88. package/dist/src/branded-types.js +1 -1
  89. package/dist/src/bundle-linker.js +1 -1
  90. package/dist/src/bundler.js +1 -1
  91. package/dist/src/cache.js +1 -1
  92. package/dist/src/call-signatures.js +1 -1
  93. package/dist/src/circular.js +1 -1
  94. package/dist/src/compat.d.ts +0 -29
  95. package/dist/src/compat.js +1 -1
  96. package/dist/src/computed-keys.js +1 -1
  97. package/dist/src/concurrency.js +1 -1
  98. package/dist/src/config.js +1 -1
  99. package/dist/src/dangling-refs.js +1 -1
  100. package/dist/src/declaration-project.js +1 -1
  101. package/dist/src/declaration-publication.js +1 -1
  102. package/dist/src/declaration-references.js +1 -1
  103. package/dist/src/diff.js +1 -1
  104. package/dist/src/docs.js +1 -1
  105. package/dist/src/enum-declarations.js +1 -1
  106. package/dist/src/errors.js +1 -1
  107. package/dist/src/extractor/directives.js +1 -1
  108. package/dist/src/extractor/extract.d.ts +1 -1
  109. package/dist/src/extractor/extract.js +1 -1
  110. package/dist/src/extractor/scanner.d.ts +4 -17
  111. package/dist/src/extractor/scanner.js +1 -1
  112. package/dist/src/extractor.js +1 -1
  113. package/dist/src/formats.js +1 -1
  114. package/dist/src/formatter.js +1 -1
  115. package/dist/src/function-properties.js +1 -1
  116. package/dist/src/generator.js +1 -1
  117. package/dist/src/global-types.js +1 -1
  118. package/dist/src/import-sorter.js +1 -1
  119. package/dist/src/incremental.js +1 -1
  120. package/dist/src/index.js +1 -1
  121. package/dist/src/inferred-imports.js +1 -1
  122. package/dist/src/initializer-type-spans.d.ts +7 -0
  123. package/dist/src/initializer-type-spans.js +2 -0
  124. package/dist/src/json-config.js +1 -1
  125. package/dist/src/lexical.d.ts +8 -1
  126. package/dist/src/lexical.js +1 -1
  127. package/dist/src/logger.js +1 -1
  128. package/dist/src/lsp.js +1 -1
  129. package/dist/src/memory.js +1 -1
  130. package/dist/src/merger.js +1 -1
  131. package/dist/src/module-graph.js +1 -1
  132. package/dist/src/module-references.js +1 -1
  133. package/dist/src/native-checker.js +1 -1
  134. package/dist/src/native-engine.js +1 -1
  135. package/dist/src/native-extractor.js +1 -1
  136. package/dist/src/native-generation.js +1 -1
  137. package/dist/src/native-project.js +1 -1
  138. package/dist/src/numeric-literals.d.ts +9 -0
  139. package/dist/src/numeric-literals.js +2 -0
  140. package/dist/src/optimizer.d.ts +0 -14
  141. package/dist/src/optimizer.js +1 -1
  142. package/dist/src/output-normalizer.js +1 -1
  143. package/dist/src/parallel-processor.js +1 -1
  144. package/dist/src/parameters.js +1 -1
  145. package/dist/src/parser.js +1 -1
  146. package/dist/src/plugins/bun.js +1 -1
  147. package/dist/src/plugins/esbuild.js +1 -1
  148. package/dist/src/plugins/index.js +1 -1
  149. package/dist/src/plugins/tsdown.js +1 -1
  150. package/dist/src/plugins/tsup.js +1 -1
  151. package/dist/src/plugins/vite.js +1 -1
  152. package/dist/src/plugins/webpack.js +1 -1
  153. package/dist/src/plugins.js +1 -1
  154. package/dist/src/process-source.d.ts +1 -1
  155. package/dist/src/process-source.js +1 -1
  156. package/dist/src/processor/cache.js +1 -1
  157. package/dist/src/processor/comments.js +1 -1
  158. package/dist/src/processor/declarations.js +1 -1
  159. package/dist/src/processor/import-usage.js +1 -1
  160. package/dist/src/processor/imports.js +1 -1
  161. package/dist/src/processor/index.js +1 -1
  162. package/dist/src/processor/type-inference.d.ts +6 -9
  163. package/dist/src/processor/type-inference.js +1 -1
  164. package/dist/src/processor.js +1 -1
  165. package/dist/src/profiling.js +1 -1
  166. package/dist/src/return-type-scope.js +1 -1
  167. package/dist/src/security.js +1 -1
  168. package/dist/src/source-cache.js +1 -1
  169. package/dist/src/sourcemap.js +1 -1
  170. package/dist/src/stx.js +1 -1
  171. package/dist/src/syntax-validator.js +1 -1
  172. package/dist/src/tracking.js +1 -1
  173. package/dist/src/transformers.js +1 -1
  174. package/dist/src/tree-shaker.js +1 -1
  175. package/dist/src/tsconfig.js +1 -1
  176. package/dist/src/type-mappings.js +1 -1
  177. package/dist/src/utils.js +1 -1
  178. package/dist/src/value-inference.js +1 -1
  179. package/dist/src/vue.js +1 -1
  180. package/dist/src/watcher.js +1 -1
  181. package/dist/src/worker-thread.js +1 -1
  182. package/dist/src/worker.js +1 -1
  183. package/dist/src/workspace.js +1 -1
  184. package/native/darwin-arm64/libzig-dtsx.dylib +0 -0
  185. package/native/darwin-x64/libzig-dtsx.dylib +0 -0
  186. package/native/freebsd-x64/libzig-dtsx.so +0 -0
  187. package/native/linux-arm64/libzig-dtsx.so +0 -0
  188. package/native/linux-x64/libzig-dtsx.so +0 -0
  189. package/native/windows-x64/zig-dtsx.dll +0 -0
  190. package/package.json +1 -1
  191. package/dist/chunk-1hz6j7bq.js +0 -37
  192. package/dist/chunk-3v0yh5dk.js +0 -3
  193. package/dist/chunk-4ece5g8t.js +0 -3
  194. package/dist/chunk-86xvq8km.js +0 -4
  195. package/dist/chunk-90f37xen.js +0 -3
  196. package/dist/chunk-976r899s.js +0 -10
  197. package/dist/chunk-anvhqbw8.js +0 -3
  198. package/dist/chunk-btmc3e8d.js +0 -3
  199. package/dist/chunk-d68r83t9.js +0 -3
  200. package/dist/chunk-erymqkk3.js +0 -14
  201. package/dist/chunk-hwgxwgsh.js +0 -4
  202. package/dist/chunk-hyszyzq2.js +0 -3
  203. package/dist/chunk-m2kzh519.js +0 -3
  204. package/dist/chunk-madfh88z.js +0 -3
  205. package/dist/chunk-mhz6xe61.js +0 -7
  206. package/dist/chunk-nek63555.js +0 -3
  207. package/dist/chunk-nxk4h5hy.js +0 -3
  208. package/dist/chunk-q4ebd4qe.js +0 -8
  209. package/dist/chunk-v3n9zzhm.js +0 -5
  210. package/dist/chunk-x1j88x37.js +0 -38
  211. package/dist/chunk-xa9vcbjj.js +0 -3
  212. package/dist/chunk-xb2nr89a.js +0 -3
  213. package/dist/chunk-ykrdzatr.js +0 -31
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{createReadStream as l,createWriteStream as c,statSync as m}from"fs";import{createInterface as u}from"readline";class Xt{config;profiles=[];cleanupTimer=null;constructor(e={}){this.config={maxMemoryMB:e.maxMemoryMB??512,chunkSize:e.chunkSize??65536,aggressiveGC:e.aggressiveGC??!0,maxDeclarationsInMemory:e.maxDeclarationsInMemory??1e4,profile:e.profile??!1,cleanupInterval:e.cleanupInterval??5000}}startMonitoring(){if(this.cleanupTimer=setInterval(()=>{this.checkMemoryAndCleanup()},this.config.cleanupInterval),this.cleanupTimer&&typeof this.cleanupTimer==="object"&&"unref"in this.cleanupTimer)this.cleanupTimer.unref()}stopMonitoring(){if(this.cleanupTimer)clearInterval(this.cleanupTimer),this.cleanupTimer=null}checkMemoryAndCleanup(){if(this.getMemoryStats().heapUsedMB>this.config.maxMemoryMB)this.triggerCleanup()}triggerCleanup(){if(this.config.aggressiveGC&&global.gc)global.gc()}getMemoryStats(){let e=process.memoryUsage();return{heapUsed:e.heapUsed,heapTotal:e.heapTotal,external:e.external,arrayBuffers:e.arrayBuffers,rss:e.rss,heapUsedMB:Math.ceil(e.heapUsed/1024/1024),percentUsed:Math.min(100,Math.round(e.heapUsed/e.heapTotal*100))}}async profile(e,t){if(!this.config.profile)return t();let r=this.getMemoryStats(),i=Date.now();try{return await t()}finally{let n=this.getMemoryStats(),s=Date.now()-i;this.profiles.push({timestamp:Date.now(),operation:e,memoryBefore:r,memoryAfter:n,duration:s})}}getProfiles(){return[...this.profiles]}clearProfiles(){this.profiles=[]}async*streamFile(e){let t=l(e,{encoding:"utf-8",highWaterMark:this.config.chunkSize}),r=u({input:t,crlfDelay:1/0});for await(let i of r)yield i}async processFileInChunks(e,t,r=1000){let i=[],n=[];for await(let s of this.streamFile(e))if(n.push(s),n.length>=r){let a=await t(n);i.push(...a),n=[],this.checkMemoryAndCleanup()}if(n.length>0){let s=await t(n);i.push(...s)}return i}async streamWrite(e,t){let r=c(e,{encoding:"utf-8"});return new Promise((i,n)=>{let s=async()=>{try{for await(let a of t)if(!r.write(a))await new Promise((o)=>r.once("drain",()=>o()));r.end(),r.once("finish",i)}catch(a){n(a)}};r.once("error",n),s()})}}class Er{declarations=new Map;registry=new FinalizationRegistry((e)=>{this.declarations.delete(e)});maxSize;constructor(e=1e4){this.maxSize=e}add(e,t){if(this.declarations.size>=this.maxSize)this.evictOldest();let r=new WeakRef(t);this.declarations.set(e,r),this.registry.register(t,e)}get(e){return this.declarations.get(e)?.deref()}has(e){return this.declarations.get(e)?.deref()!==void 0}delete(e){this.declarations.delete(e)}clear(){this.declarations.clear()}get size(){return this.declarations.size}evictOldest(){let e=Math.ceil(this.maxSize*0.2),t=Array.from(this.declarations.keys());for(let r=0;r<e&&r<t.length;r++)this.declarations.delete(t[r])}}class kr{value=null;loaded=!1;loader;constructor(e){this.loader=e}async get(){if(!this.loaded)this.value=await this.loader(),this.loaded=!0;return this.value}isLoaded(){return this.loaded}unload(){this.value=null,this.loaded=!1}}class Tr{strings=new Map;maxSize;constructor(e=50000){this.maxSize=e}intern(e){if(e.length>100)return e;let t=this.strings.get(e);if(t!==void 0)return t;if(this.strings.size>=this.maxSize){let r=Array.from(this.strings.keys());for(let i=0;i<r.length/2;i++)this.strings.delete(r[i])}return this.strings.set(e,e),e}get size(){return this.strings.size}clear(){this.strings.clear()}}class Ar{pool=[];factory;reset;maxSize;constructor(e,t,r=1000){this.factory=e,this.reset=t,this.maxSize=r}acquire(){if(this.pool.length>0)return this.pool.pop();return this.factory()}release(e){if(this.pool.length<this.maxSize)this.reset(e),this.pool.push(e)}get size(){return this.pool.length}clear(){this.pool=[]}}function vs(e,t={}){return{...e,memory:{maxMemoryMB:t.maxMemoryMB??512,chunkSize:t.chunkSize??65536,aggressiveGC:t.aggressiveGC??!0,maxDeclarationsInMemory:t.maxDeclarationsInMemory??1e4,profile:t.profile??!1,cleanupInterval:t.cleanupInterval??5000}}}function Ss(e){let r=m(e).size/1024/1024,i=r*4,n=65536;if(r>10)n=32768;if(r>50)n=16384;return{fileSizeMB:Math.round(r*100)/100,estimatedMemoryMB:Math.round(i*100)/100,recommendedChunkSize:n}}function $s(e){return[`Heap: ${e.heapUsedMB}MB / ${Math.round(e.heapTotal/1024/1024)}MB (${e.percentUsed}%)`,`RSS: ${Math.round(e.rss/1024/1024)}MB`,`External: ${Math.round(e.external/1024/1024)}MB`].join(" | ")}function Es(e={}){return new Xt(e)}
3
- export{Xt,Er,kr,Tr,Ar,vs,Ss,$s,Es};
2
+ import{createReadStream as l,createWriteStream as c,statSync as m}from"fs";import{createInterface as u}from"readline";class nn{config;profiles=[];cleanupTimer=null;constructor(e={}){this.config={maxMemoryMB:e.maxMemoryMB??512,chunkSize:e.chunkSize??65536,aggressiveGC:e.aggressiveGC??!0,maxDeclarationsInMemory:e.maxDeclarationsInMemory??1e4,profile:e.profile??!1,cleanupInterval:e.cleanupInterval??5000}}startMonitoring(){if(this.cleanupTimer=setInterval(()=>{this.checkMemoryAndCleanup()},this.config.cleanupInterval),this.cleanupTimer&&typeof this.cleanupTimer==="object"&&"unref"in this.cleanupTimer)this.cleanupTimer.unref()}stopMonitoring(){if(this.cleanupTimer)clearInterval(this.cleanupTimer),this.cleanupTimer=null}checkMemoryAndCleanup(){if(this.getMemoryStats().heapUsedMB>this.config.maxMemoryMB)this.triggerCleanup()}triggerCleanup(){if(this.config.aggressiveGC&&global.gc)global.gc()}getMemoryStats(){let e=process.memoryUsage();return{heapUsed:e.heapUsed,heapTotal:e.heapTotal,external:e.external,arrayBuffers:e.arrayBuffers,rss:e.rss,heapUsedMB:Math.ceil(e.heapUsed/1024/1024),percentUsed:Math.min(100,Math.round(e.heapUsed/e.heapTotal*100))}}async profile(e,t){if(!this.config.profile)return t();let r=this.getMemoryStats(),i=Date.now();try{return await t()}finally{let n=this.getMemoryStats(),s=Date.now()-i;this.profiles.push({timestamp:Date.now(),operation:e,memoryBefore:r,memoryAfter:n,duration:s})}}getProfiles(){return[...this.profiles]}clearProfiles(){this.profiles=[]}async*streamFile(e){let t=l(e,{encoding:"utf-8",highWaterMark:this.config.chunkSize}),r=u({input:t,crlfDelay:1/0});for await(let i of r)yield i}async processFileInChunks(e,t,r=1000){let i=[],n=[];for await(let s of this.streamFile(e))if(n.push(s),n.length>=r){let a=await t(n);i.push(...a),n=[],this.checkMemoryAndCleanup()}if(n.length>0){let s=await t(n);i.push(...s)}return i}async streamWrite(e,t){let r=c(e,{encoding:"utf-8"});return new Promise((i,n)=>{let s=async()=>{try{for await(let a of t)if(!r.write(a))await new Promise((o)=>r.once("drain",()=>o()));r.end(),r.once("finish",i)}catch(a){n(a)}};r.once("error",n),s()})}}class Dr{declarations=new Map;registry=new FinalizationRegistry((e)=>{this.declarations.delete(e)});maxSize;constructor(e=1e4){this.maxSize=e}add(e,t){if(this.declarations.size>=this.maxSize)this.evictOldest();let r=new WeakRef(t);this.declarations.set(e,r),this.registry.register(t,e)}get(e){return this.declarations.get(e)?.deref()}has(e){return this.declarations.get(e)?.deref()!==void 0}delete(e){this.declarations.delete(e)}clear(){this.declarations.clear()}get size(){return this.declarations.size}evictOldest(){let e=Math.ceil(this.maxSize*0.2),t=Array.from(this.declarations.keys());for(let r=0;r<e&&r<t.length;r++)this.declarations.delete(t[r])}}class Rr{value=null;loaded=!1;loader;constructor(e){this.loader=e}async get(){if(!this.loaded)this.value=await this.loader(),this.loaded=!0;return this.value}isLoaded(){return this.loaded}unload(){this.value=null,this.loaded=!1}}class Mr{strings=new Map;maxSize;constructor(e=50000){this.maxSize=e}intern(e){if(e.length>100)return e;let t=this.strings.get(e);if(t!==void 0)return t;if(this.strings.size>=this.maxSize){let r=Array.from(this.strings.keys());for(let i=0;i<r.length/2;i++)this.strings.delete(r[i])}return this.strings.set(e,e),e}get size(){return this.strings.size}clear(){this.strings.clear()}}class Or{pool=[];factory;reset;maxSize;constructor(e,t,r=1000){this.factory=e,this.reset=t,this.maxSize=r}acquire(){if(this.pool.length>0)return this.pool.pop();return this.factory()}release(e){if(this.pool.length<this.maxSize)this.reset(e),this.pool.push(e)}get size(){return this.pool.length}clear(){this.pool=[]}}function Ts(e,t={}){return{...e,memory:{maxMemoryMB:t.maxMemoryMB??512,chunkSize:t.chunkSize??65536,aggressiveGC:t.aggressiveGC??!0,maxDeclarationsInMemory:t.maxDeclarationsInMemory??1e4,profile:t.profile??!1,cleanupInterval:t.cleanupInterval??5000}}}function As(e){let r=m(e).size/1024/1024,i=r*4,n=65536;if(r>10)n=32768;if(r>50)n=16384;return{fileSizeMB:Math.round(r*100)/100,estimatedMemoryMB:Math.round(i*100)/100,recommendedChunkSize:n}}function Ps(e){return[`Heap: ${e.heapUsedMB}MB / ${Math.round(e.heapTotal/1024/1024)}MB (${e.percentUsed}%)`,`RSS: ${Math.round(e.rss/1024/1024)}MB`,`External: ${Math.round(e.external/1024/1024)}MB`].join(" | ")}function Ds(e={}){return new nn(e)}
3
+ export{nn,Dr,Rr,Mr,Or,Ts,As,Ps,Ds};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{t}from"./chunk-mhz6xe61.js";function j(n){let s=t(n),r=(e)=>s[e]?n.slice(s[e].start,s[e].end):"",d=new Map,k=[];for(let e=0;e<s.length;e++)if(["(","[","{"].includes(r(e)))k.push(e);else if([")","]","}"].includes(r(e))){let i=k.pop();if(i===void 0||!["()","[]","{}"].includes(r(i)+r(e)))throw Error("Unbalanced binding pattern");d.set(i,e)}if(k.length)throw Error("Unbalanced binding pattern");for(let e=0;e<s.length;e++){if(r(e)!=="<")continue;let i=["=",",","(",":","?","[","{"].includes(r(e-1)),f=1;for(let a=e+1;a<s.length;a++){if(r(a)==="="&&r(a+1)!==">"&&f===1&&!i)break;if(r(a)==="<")f++;else if(r(a)===">"&&r(a-1)!=="="&&--f===0){if(a+1===s.length||["(","[",".",",","}","]",")","?",":",";","=",">"].includes(r(a+1)))d.set(e,a);break}let u=d.get(a);if(u!==void 0)a=u}}let g=(e,i)=>({text:e<i?n.slice(s[e].start,s[i-1].end):"",offset:s[e]?.start??n.length}),w=(e,i,f)=>{for(let a=e;a<i;a++){if(r(a)===f)return a;let u=d.get(a);if(u!==void 0)a=u}return},b=(e,i)=>{let f=w(e,i,"="),a=f===void 0?void 0:g(f+1,i);if(f!==void 0)i=f;if(e+1===i&&s[e]?.kind==="word")return{kind:"name",name:r(e),defaultValue:a};let u=r(e)==="{"?"object":r(e)==="["?"array":void 0;if(!u||d.get(e)!==i-1)throw Error(`Invalid binding target: ${g(e,i).text}`);let m=[],o=e+1;while(o<i-1){let h=w(o,i-1,","),p=h??i-1;if(o===p)m.push(void 0);else if(r(o)==="."&&r(o+1)==="."&&r(o+2)===".")m.push({rest:!0,target:b(o+3,p)});else if(u==="array")m.push({rest:!1,target:b(o,p)});else if(r(o)==="["){let c=d.get(o);if(c===void 0||r(c+1)!==":")throw Error("Computed binding needs a target");m.push({computed:g(o+1,c),rest:!1,target:b(c+2,p)})}else{let c=o+1;if(s[o].kind!=="word"&&s[o].kind!=="quoted")while(c<p&&r(c)!==":")c++;let l=r(c)===":";if(!l&&s[o].kind!=="word")throw Error("Invalid object binding key");m.push({key:g(o,l?c:o+1).text,rest:!1,target:b(l?c+1:o,p)})}if(h===void 0)break;o=h+1}return{kind:u,elements:m,defaultValue:a}};return b(0,s.length)}function y(n,s){if(n.kind==="name")s.push(n.name);else for(let r of n.elements)if(r)y(r.target,s)}function Ne(n){let s=[];return y(j(n),s),s}function rr(n){let s=j(n.pattern),r=[];if(y(s,r),!r.length)return[];let d=[n.root],k=!1,g={start:n.root.start,end:n.root.end},w=(e,i)=>{let f=n.allocateName();return d.push({kind:"variable",name:f,text:`declare ${i} ${f}: unknown;`,value:e.text,initializerStart:n.patternOffset+e.offset,modifiers:[i],isExported:!1,...g}),f},b=(e,i)=>{if(e.defaultValue){let l=w(e.defaultValue,n.kind),x=n.allocateName();i=`(${i}) extends infer ${x} ? ${x} extends undefined ? typeof ${l} : ${x} : never`}if(e.kind==="name"){let l=k?void 0:n.comments;k=!0,d.push({kind:"variable",name:e.name,text:`${n.exported?"export ":""}declare ${n.kind} ${e.name}: ${i};`,typeAnnotation:i,modifiers:[n.kind],isExported:n.exported,leadingComments:l,...g});return}let f=e.elements,a=[],u=[],m=[];for(let l of f){if(!l){a.push("");continue}let x=n.allocateName(),E=l.key;if(l.computed)E=`[${w(l.computed,"const")}]`;a.push(l.rest?`...${x}`:e.kind==="object"?`${E}: ${x}`:x),u.push({target:l.target,index:m.length}),m.push(`typeof ${x}`)}let o=n.allocateName(),h=n.allocateName(),p=n.allocateName(),c=e.kind==="object"?`{ ${a.join(", ")} }`:`[${a.join(", ")}]`;d.push({kind:"function",name:o,text:`declare function ${o}(${c}: ${i}): [${m.join(", ")}];`,isExported:!1,...g}),d.push({kind:"type",name:h,text:`type ${h} = (typeof ${o}) extends (...args: never[]) => infer ${p} ? ${p} : never;`,isExported:!1,...g});for(let l of u)b(l.target,`${h}[${l.index}]`)};return b(s,`typeof ${n.root.name}`),d}
3
- export{Ne,rr};
2
+ import{t}from"./chunk-tsbthwf0.js";function j(n){let s=t(n),r=(e)=>s[e]?n.slice(s[e].start,s[e].end):"",d=new Map,k=[];for(let e=0;e<s.length;e++)if(["(","[","{"].includes(r(e)))k.push(e);else if([")","]","}"].includes(r(e))){let i=k.pop();if(i===void 0||!["()","[]","{}"].includes(r(i)+r(e)))throw Error("Unbalanced binding pattern");d.set(i,e)}if(k.length)throw Error("Unbalanced binding pattern");for(let e=0;e<s.length;e++){if(r(e)!=="<")continue;let i=["=",",","(",":","?","[","{"].includes(r(e-1)),f=1;for(let a=e+1;a<s.length;a++){if(r(a)==="="&&r(a+1)!==">"&&f===1&&!i)break;if(r(a)==="<")f++;else if(r(a)===">"&&r(a-1)!=="="&&--f===0){if(a+1===s.length||["(","[",".",",","}","]",")","?",":",";","=",">"].includes(r(a+1)))d.set(e,a);break}let u=d.get(a);if(u!==void 0)a=u}}let g=(e,i)=>({text:e<i?n.slice(s[e].start,s[i-1].end):"",offset:s[e]?.start??n.length}),w=(e,i,f)=>{for(let a=e;a<i;a++){if(r(a)===f)return a;let u=d.get(a);if(u!==void 0)a=u}return},b=(e,i)=>{let f=w(e,i,"="),a=f===void 0?void 0:g(f+1,i);if(f!==void 0)i=f;if(e+1===i&&s[e]?.kind==="word")return{kind:"name",name:r(e),defaultValue:a};let u=r(e)==="{"?"object":r(e)==="["?"array":void 0;if(!u||d.get(e)!==i-1)throw Error(`Invalid binding target: ${g(e,i).text}`);let m=[],o=e+1;while(o<i-1){let h=w(o,i-1,","),p=h??i-1;if(o===p)m.push(void 0);else if(r(o)==="."&&r(o+1)==="."&&r(o+2)===".")m.push({rest:!0,target:b(o+3,p)});else if(u==="array")m.push({rest:!1,target:b(o,p)});else if(r(o)==="["){let c=d.get(o);if(c===void 0||r(c+1)!==":")throw Error("Computed binding needs a target");m.push({computed:g(o+1,c),rest:!1,target:b(c+2,p)})}else{let c=o+1;if(s[o].kind!=="word"&&s[o].kind!=="quoted")while(c<p&&r(c)!==":")c++;let l=r(c)===":";if(!l&&s[o].kind!=="word")throw Error("Invalid object binding key");m.push({key:g(o,l?c:o+1).text,rest:!1,target:b(l?c+1:o,p)})}if(h===void 0)break;o=h+1}return{kind:u,elements:m,defaultValue:a}};return b(0,s.length)}function y(n,s){if(n.kind==="name")s.push(n.name);else for(let r of n.elements)if(r)y(r.target,s)}function Ge(n){let s=[];return y(j(n),s),s}function cr(n){let s=j(n.pattern),r=[];if(y(s,r),!r.length)return[];let d=[n.root],k=!1,g={start:n.root.start,end:n.root.end},w=(e,i)=>{let f=n.allocateName();return d.push({kind:"variable",name:f,text:`declare ${i} ${f}: unknown;`,value:e.text,initializerStart:n.patternOffset+e.offset,modifiers:[i],isExported:!1,...g}),f},b=(e,i)=>{if(e.defaultValue){let l=w(e.defaultValue,n.kind),x=n.allocateName();i=`(${i}) extends infer ${x} ? ${x} extends undefined ? typeof ${l} : ${x} : never`}if(e.kind==="name"){let l=k?void 0:n.comments;k=!0,d.push({kind:"variable",name:e.name,text:`${n.exported?"export ":""}declare ${n.kind} ${e.name}: ${i};`,typeAnnotation:i,modifiers:[n.kind],isExported:n.exported,leadingComments:l,...g});return}let f=e.elements,a=[],u=[],m=[];for(let l of f){if(!l){a.push("");continue}let x=n.allocateName(),E=l.key;if(l.computed)E=`[${w(l.computed,"const")}]`;a.push(l.rest?`...${x}`:e.kind==="object"?`${E}: ${x}`:x),u.push({target:l.target,index:m.length}),m.push(`typeof ${x}`)}let o=n.allocateName(),h=n.allocateName(),p=n.allocateName(),c=e.kind==="object"?`{ ${a.join(", ")} }`:`[${a.join(", ")}]`;d.push({kind:"function",name:o,text:`declare function ${o}(${c}: ${i}): [${m.join(", ")}];`,isExported:!1,...g}),d.push({kind:"type",name:h,text:`type ${h} = (typeof ${o}) extends (...args: never[]) => infer ${p} ? ${p} : never;`,isExported:!1,...g});for(let l of u)b(l.target,`${h}[${l.index}]`)};return b(s,`typeof ${n.root.name}`),d}
3
+ export{Ge,cr};
@@ -0,0 +1,40 @@
1
+ // @bun
2
+ import{R,S}from"./chunk-0af0hsfc.js";import{t}from"./chunk-tsbthwf0.js";import{Ge}from"./chunk-gsvb5wey.js";import{sr,or,ar}from"./chunk-xg8yhpe6.js";import{g,ee,K}from"./chunk-986k5306.js";import{H}from"./chunk-z0aa0gd8.js";import{_e,we,je}from"./chunk-c7dw612y.js";import{be}from"./chunk-587w6ktw.js";var lt=20,ft=!1,L=null;function ht(e){return Ot(e).replace(/\n[ \t]*(?=\n)/g,"")}function Ot(e){if(e.indexOf("/*")===-1)return e.trim();let i=[],s=0,r=0,l=e.length;while(r<l)if(e.charCodeAt(r)===47&&r+1<l&&e.charCodeAt(r+1)===42){if(r>s)i.push(e.substring(s,r));r+=2;while(r<l-1){if(e.charCodeAt(r)===42&&e.charCodeAt(r+1)===47){r+=2;break}r++}s=r}else r++;if(s<l)i.push(e.substring(s));return i.join("").trim()}function Vt(){ft=!0,L=null}function Ut(){ft=!1;let e=L;return L=null,e}function ut(e,c){let i=0,s=0;while((s=e.indexOf(c,s))!==-1)i++,s+=c.length;return i}function wt(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===36||e===95||e===46||e===58||e===45}function rt(e){let c=e.trim();if(c.length<3||c.charCodeAt(0)!==60)return!1;if(c.startsWith("<>"))return c.endsWith("</>");let i=c.charCodeAt(1);if(!(i>=65&&i<=90||i>=97&&i<=122||i===36||i===95))return!1;let r=2;while(r<c.length&&wt(c.charCodeAt(r)))r++;let l=c.slice(1,r),f=c.charCodeAt(r);if(f>32&&f!==62&&f!==47)return!1;if(c.endsWith("/>"))return!0;let u=c.lastIndexOf("</");if(u===-1)return!1;let a=u+2;while(a<c.length&&wt(c.charCodeAt(a)))a++;return c.slice(u+2,a)===l&&c.charCodeAt(a)===62&&a===c.length-1}function it(e){let c=e.length,i=!1;for(let f=1;f<c;f++)if(e.charCodeAt(f)<=32&&e.charCodeAt(f-1)<=32){i=!0;break}if(!i)for(let f=0;f<c;f++){let u=e.charCodeAt(f);if(u===10||u===13||u===9){i=!0;break}}if(!i)return e;let s=[],r=-1,l=!1;for(let f=0;f<c;f++)if(e.charCodeAt(f)<=32){if(!l){if(r>=0)s.push(e.substring(r,f));s.push(" "),l=!0,r=-1}}else{if(l||r<0)r=f;l=!1}if(r>=0)s.push(e.substring(r));return s.join("")}function n(e,c=!1,i=!1,s=0,r){if(!e||typeof e!=="string")return"unknown";if(s>=lt)return"unknown";let l=e.trim();if(rt(l))return"JSX.Element";let f=jt(l);if(f)return f;if(l.startsWith("BigInt("))return"bigint";if(l.startsWith("Symbol.for("))return"symbol";if(!(l.startsWith("[")&&l.endsWith("]")||l.startsWith("{")&&l.endsWith("}"))&&(l.includes(".raw`")||l.includes("String.raw`")))return"string";if(l.startsWith("`")&&l.endsWith("`")){if(!c||l.includes("${")||l.includes(`
3
+ `)||l.includes("\r"))return"string";return l}if(l.charCodeAt(0)===39||l.charCodeAt(0)===34){let d=Bt(l);if(d!==null){if(d==="string"||!c)return"string";return d}}if(g(l)){if(!c)return"number";return K(l)}if(l==="true"||l==="false"){if(!c)return"boolean";return l}if(l==="null")return"null";if(l==="undefined")return"undefined";if(l.startsWith("[")&&l.endsWith("]"))return Be(l,c,s+1,r);if(l.startsWith("{")&&l.endsWith("}"))return dt(l,c,s+1,r);if(l.startsWith("class ")||l.startsWith("class{"))return oe(l);if(l.startsWith("new "))return Ht(l);if(l.endsWith("as const")){let d=l.slice(0,-8).trim();if(d.startsWith("[")&&d.endsWith("]")){let y=d.slice(1,-1).trim();if(!y)return"readonly []";let b=Q(y),C=[];for(let p=0;p<b.length;p++){let m=b[p].trim();if(m.startsWith("...")){let h=m.slice(3).trim();if(J(h))C.push(`...typeof ${h}`);else{let A=n(h,!0,!1,s+1,r);C.push(A.startsWith("readonly [")||A.endsWith("[]")?`...${A}`:"...unknown[]")}}else C.push(n(m,!0,!1,s+1,r))}return`readonly [${C.join(", ")}]`}return n(d,!0,i,s+1,r)}if(X(l)!==-1||l.startsWith("function")||l.startsWith("async"))return pt(l,i,s,c);if(l.startsWith("`")&&l.endsWith("`"))return se(l,c);if(l.startsWith("Promise."))return Nt(l,c,s,r);if(l.startsWith("await "))return"unknown";if(l.startsWith("typeof ")&&nt(l.slice(7)))return"string";if(l.startsWith("void ")&&nt(l.slice(5)))return"undefined";if(l.startsWith("delete ")&&nt(l.slice(7)))return"boolean";if(ee(l)){if(c)return K(l);return"bigint"}if(l.startsWith("Symbol(")||l==="Symbol.for")return"symbol";let a=U(l);if(a!==null)return a;if(Pt(l))return"boolean";if(Gt(l))return"number";return"unknown"}function $t(e){let c=e.charCodeAt(0);if(c!==39&&c!==34)return!1;return G(e,0,c)===e.length}function Bt(e){if($t(e))return e;let c=Dt(e);if(c.length<2)return null;let i=!1,s=!0,r="";for(let l of c){let f=l.trim();if($t(f))i=!0,r+=Ft(f);else s=!1}if(s)return qt(r);if(i)return"string";return null}function Dt(e){let c=[],i=0,s=0,r=0;while(r<e.length){let l=e.charCodeAt(r);if(l===39||l===34||l===96){r=G(e,r,l);continue}if(l===40||l===91||l===123)i++;else if(l===41||l===93||l===125)i--;else if(l===43&&i===0)c.push(e.slice(s,r)),s=r+1;r++}return c.push(e.slice(s)),c}function Ft(e){return e.slice(1,-1).replace(/\\(.)/g,(i,s)=>{if(s==="n")return`
4
+ `;if(s==="t")return"\t";if(s==="r")return"\r";if(s==="0")return"\x00";return s})}function qt(e){return`'${e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function Gt(e){if(e==="")return!1;let c=!1,i=!1;for(let s=0;s<e.length;s++){let r=e.charCodeAt(s);if(r>=48&&r<=57){c=!0;continue}if(r===43||r===45||r===42||r===47||r===37){i=!0;continue}if(r===60||r===62){let l=s+1;while(l<e.length&&e.charCodeAt(l)===r)l++;let f=l-s;if(f!==2&&!(r===62&&f===3))return!1;i=!0,s=l-1;continue}if(r===46||r===40||r===41||r<=32)continue;return!1}return c&&i}function Pt(e){let c=0,i;for(let s=0;s<e.length;s++){let r=e.charCodeAt(s);if(r===34||r===39||r===96){s=G(e,s,r)-1;continue}if(r===47){if(e[s+1]==="/"){let l=e.indexOf(`
5
+ `,s+2);s=l===-1?e.length:l;continue}if(e[s+1]==="*"){let l=e.indexOf("*/",s+2);s=l===-1?e.length:l+1;continue}if(R(e,s)){s=S(e,s)-1;continue}}if(r===40||r===91||r===123){c++;continue}if(r===41||r===93||r===125){c--;continue}if(c!==0)continue;if(r===60){i??=H(e);let l=i(s,0);if(l){s=l.end-1;continue}}if(e.startsWith("===",s)||e.startsWith("!==",s)||e.startsWith("==",s)||e.startsWith("!=",s)||e.startsWith(">=",s)||e.startsWith("<=",s))return!0;if((r===62||r===60)&&e.charCodeAt(s+1)===r){while(e.charCodeAt(s+1)===r)s++;continue}if((r===62||r===60)&&e.charCodeAt(s-1)!==61&&e.charCodeAt(s+1)!==61)return!0}return!1}function zt(e,c=!1,i=0,s){return n(e,c,!0,i,s)}function B(e,c=!1,i="",s,r){let l=gt(i,s),f=[],u=!1,a=0;while(a<e.length){let y=e.charCodeAt(a);if(y===34||y===39||y===96){a=G(e,a,y);continue}if(y===47&&e.charCodeAt(a+1)===47){a+=2;while(a<e.length&&e.charCodeAt(a)!==10&&e.charCodeAt(a)!==13)a++;continue}if(y===47&&e.charCodeAt(a+1)===42){let C=e.indexOf("*/",a+2);a=C===-1?e.length:C+2;continue}if(e.startsWith("function",a)&&et(e,a,8)||e.startsWith("class",a)&&et(e,a,5)){let C=ie(e,a);if(C!==-1){a=ot(e,C);continue}}if(y===61&&e.charCodeAt(a+1)===62){let C=Mt(e,a+2);if(e.charCodeAt(C)===123){a=ot(e,C);continue}}if(e.startsWith("return",a)&&(a===0||!D(e.charCodeAt(a-1)))&&!D(e.charCodeAt(a+6))){a+=6;let C=!1;while(a<e.length&&e.charCodeAt(a)<=32){let x=e.charCodeAt(a);if(x===10||x===13)C=!0;a++}if(C||a>=e.length||e.charCodeAt(a)===59||e.charCodeAt(a)===125){u=!0;continue}let p=a,m=0,h=0,A=0;while(a<e.length){let x=e.charCodeAt(a);if(x===34||x===39||x===96){a=G(e,a,x);continue}if(x===47&&e.charCodeAt(a+1)===47){if(m===0&&h===0&&A===0)break;while(a<e.length&&e.charCodeAt(a)!==10&&e.charCodeAt(a)!==13)a++;continue}if(x===47&&e.charCodeAt(a+1)===42){let T=e.indexOf("*/",a+2);a=T===-1?e.length:T+2;continue}if(x===40)m++;else if(x===41)m--;else if(x===91)h++;else if(x===93)h--;else if(x===123)A++;else if(x===125){if(A===0&&m===0&&h===0)break;A--}else if(x===59&&m===0&&h===0&&A===0)break;else if((x===10||x===13)&&m===0&&h===0&&A===0){let T=a+1;while(T<e.length&&e.charCodeAt(T)<=32)T++;if(e.startsWith("return",T)&&!D(e.charCodeAt(T+6)))break}a++}let k=e.slice(p,a).trim(),w=ht(_(k,l,s,r,p));if(!f.includes(w))f.push(w);continue}a++}if(u&&!f.includes("undefined"))f.push("undefined");let d=f.includes("unknown")?"unknown":f.length===0?"void":Et(f);return c&&!d.startsWith("Promise<")?`Promise<${d}>`:d}function gt(e,c){let i=new Map,s=e.startsWith("(")&&e.endsWith(")")?e.slice(1,-1):e,r=t(s),l=0,f=0,u=[];for(let a of r){let d=s.slice(a.start,a.end);if(d===","&&f===0)u.push(s.slice(l,a.start)),l=a.end;if(["(","[","{","<"].includes(d))f++;else if([")","]","}"].includes(d)||d===">"&&s[a.start-1]!=="=")f--}u.push(s.slice(l));for(let a of u){let d=t(a),y=-1,b=-1,C=0;for(let A of d){let k=a.slice(A.start,A.end);if(C===0&&k===":"&&y===-1)y=A.start;if(C===0&&k==="="&&a[A.end]!==">"){b=A.start;break}if(["(","[","{","<"].includes(k))C++;else if([")","]","}"].includes(k)||k===">"&&a[A.start-1]!=="=")C--}let p=a.slice(0,y!==-1?y:b!==-1?b:void 0).trim().replace(/^\.\.\./,"").replace(/\?$/,""),m=y===-1&&b!==-1&&!a.trim().startsWith("...")?we(p,a.slice(b+1)):null;if(m){for(let A of m)i.set(A.alias,c?.(A.value)??n(A.value,!1));continue}if(!Z(p)){if(p.startsWith("{")||p.startsWith("["))for(let A of Ge(p))i.set(A,"unknown");continue}let h=y!==-1?a.slice(y+1,b!==-1?b:void 0).trim():"";if(!h&&b!==-1){let A=a.slice(b+1).trim();h=c?.(A)??n(A,!1)}if(h){if(b===-1&&a.slice(0,y).trim().endsWith("?"))h=`(${h}) | undefined`;i.set(p,h)}else i.set(p,"unknown")}return i}var Wt={string:{at:"string | undefined",charAt:"string",charCodeAt:"number",codePointAt:"number | undefined",concat:"string",endsWith:"boolean",includes:"boolean",indexOf:"number",lastIndexOf:"number",localeCompare:"number",normalize:"string",padEnd:"string",padStart:"string",repeat:"string",replace:"string",replaceAll:"string",search:"number",slice:"string",split:"string[]",startsWith:"boolean",substring:"string",toLocaleLowerCase:"string",toLocaleUpperCase:"string",toLowerCase:"string",toString:"string",toUpperCase:"string",trim:"string",trimEnd:"string",trimStart:"string",valueOf:"string"},number:{toExponential:"string",toFixed:"string",toLocaleString:"string",toPrecision:"string",toString:"string",valueOf:"number"},bigint:{toLocaleString:"string",toString:"string",valueOf:"bigint"},boolean:{toString:"string",valueOf:"boolean"}};function Sa(e,c){let i=Object.hasOwn(Wt,e)?Wt[e]:void 0;return i&&Object.hasOwn(i,c)?i[c]:void 0}function W(e){return e.includes(`
6
+ `)?e.replaceAll(`
7
+ `,`
8
+ `):e}function Jt(e,c){if(e=e.trim(),!e.startsWith("{")||!e.endsWith("}"))return;let i=e.slice(1,-1),s=t(i),r=0,l=0;for(let f=0;f<=s.length;f++){let u=s[f],a=u?i.slice(u.start,u.end):";";if(l===0&&(a===";"||a===",")){let d=i.slice(r,u?.start).trim(),y=d.indexOf(":");if(y!==-1&&d.slice(0,y).trim()===c)return d.slice(y+1).trim();r=u?.end??i.length}if(["(","[","{","<"].includes(a))l++;else if([")","]","}"].includes(a)||a===">"&&u&&i[u.start-1]!=="=")l--}return}function _(e,c,i,s,r=0,l=0){if(l>=lt)return"unknown";let f=e.trim();while(at(f))f=f.slice(1,-1).trim();let u=i?.(f);if(u)return u;if(rt(f))return"JSX.Element";if(f.startsWith("await ")){let w=_(f.slice(6),c,i,s,r,l+1);return w.startsWith("Promise<")&&w.endsWith(">")?w.slice(8,-1):w}if(c.has(f))return c.get(f);let a=/^([\w$]+)\.([\w$]+(?:\.[\w$]+)*)$/.exec(f),d;if(a){let w=c.get(a[1]),x=w&&Jt(w,a[2]);if(x)return x;if(w)d=`typeof ${f}`}if(f.startsWith("!"))return"boolean";if(f.startsWith("fetch("))return"Promise<Response>";if(re(f))return n(f,!1);let y=Rt(f);if(y){let w=_(y.whenTrue,c,i,s,r,l+1),x=_(y.whenFalse,c,i,s,r,l+1);return w===x?w:Et([w,x])}for(let w of["??","||","&&"]){let x=It(f,w);if(x!==-1){let T=_(f.slice(0,x),c,i,s,r,l+1),O=_(f.slice(x+w.length),c,i,s,r,l+1);return vt(T,O,w)}}let b=Qt(f);if(b&&s)return s(b,r);let C=jt(f);if(C)return s?s(C,r):C;if(Pt(f))return"boolean";let p=0;for(let w=f.length-1;w>=0;w--){let x=f.charCodeAt(w);if(x===41||x===93||x===125)p++;else if(x===40||x===91||x===123)p--;else if(p===0&&(x===43||x===45||x===42||x===47||x===37)){let T=_(f.slice(0,w),c,i,s,r,l+1),O=_(f.slice(w+1),c,i,s,r,l+1);if(x===43&&(T==="string"||O==="string"))return"string";if(T==="number"&&O==="number")return"number";break}}if(f.startsWith("[")&&f.endsWith("]")){let w=Q(f.slice(1,-1));if(w.some((x)=>x.trim().startsWith("..."))){let x=w.map((T)=>{let O=T.trim();if(!O)return"undefined";let P=O.startsWith("..."),M=_(P?O.slice(3):O,c,i,s,r,l+1);return P?`(NonNullable<${M}> extends Iterable<infer Element> ? Element : never)`:M});return`(${[...new Set(x)].join(" | ")||"never"})[]`}}let m=d??(f.startsWith("{")&&f.endsWith("}")?dt(f,!1,l+1,void 0,(w)=>_(w,c,i,s,r,l+1)):n(f,!1));if(m==="unknown"&&Z(f)&&s)return s(`typeof ${f}`,r);let h=t(m),A="",k=0;for(let w=0;w<h.length;w++){let x=h[w];if(x.kind!=="word"||m.slice(x.start,x.end)!=="typeof")continue;let T=h[w+1];if(!T||T.kind!=="word")continue;let O=c.get(m.slice(T.start,T.end)),P=O,M=!O,V=x.start,F=T.end,I=w,N=[];w++;while(h[w+1]&&m.slice(h[w+1].start,h[w+1].end)==="."&&h[w+2]?.kind==="word"){let E=h[w+2];if(N.push(m.slice(E.start,E.end)),!M)O=`(${O})["${m.slice(E.start,E.end)}"]`;F=E.end,w+=2}let v=I>=2&&m.slice(h[I-2].start,h[I-2].end)==="ReturnType"&&m.slice(h[I-1].start,h[I-1].end)==="<"&&h[w+1]&&m.slice(h[w+1].start,h[w+1].end)===">",Y=P&&v&&N.length===1?Sa(P.trim(),N[0]):void 0;if(Y){V=h[I-2].start,F=h[++w].end;let E=V===0&&F===m.length;A+=m.slice(k,V)+(E||!Y.includes("|")?Y:`(${Y})`),k=F;continue}if(M&&v)V=h[I-2].start,F=h[++w].end;A+=m.slice(k,V)+(O??"unknown"),k=F}return A+m.slice(k)}function Qt(e){let c=t(e),i=0,s=-1;for(let l=0;l<c.length;l++){let f=c[l],u=e.slice(f.start,f.end);if(f.kind!=="punctuation"&&f.kind!=="word")continue;if(["(","[","{"].includes(u))i++;else if([")","]","}"].includes(u))i--;else if(!i&&u==="as"&&l>0&&e.slice(c[l-1].start,c[l-1].end)!==".")s=l}if(s===-1||s+1===c.length)return;let r=e.slice(c[s].end).trim();if(r==="const")return;i=0;for(let l of c.slice(s+1)){if(l.kind!=="punctuation")continue;let f=e.slice(l.start,l.end);if(!i&&["??","||","&&"].some((u)=>e.startsWith(u,l.start)))return;if(["(","[","{","<"].includes(f))i++;else if([")","]","}",">"].includes(f))i--;else if(!i&&["+","-","*","/","%","=","!",";"].includes(f))return}return r}function It(e,c){let i=0;for(let s of t(e)){if(s.kind!=="punctuation")continue;let r=e.slice(s.start,s.end);if(["(","[","{"].includes(r))i++;else if([")","]","}"].includes(r))i--;if(!i&&e.startsWith(c,s.start))return s.start}return-1}function Xt(e){if(e.includes("=>"))return null;let c=[],i=0,s=0;for(let r=0;r<=e.length;r++){let l=r===e.length?"|":e[r];if(l==="'"||l==='"'||l==="`"){r++;while(r<e.length&&e[r]!==l)r+=e[r]==="\\"?2:1;if(r>=e.length)return null}else if(l==="("||l==="["||l==="{"||l==="<")i++;else if(l===")"||l==="]"||l==="}"||l===">")i--;else if(l==="|"&&i===0){let f=e.slice(s,r).trim();if(f)c.push(f);s=r+1}if(i<0)return null}return i===0?c:null}function Yt(e,c){let i=Xt(c);if(!i)return`${e} | ${c}`;let s=[];for(let d of[e,...i]){if(d==="unknown")return"unknown";if(!s.includes(d))s.push(d)}let r=s.includes("boolean")||s.includes("true")&&s.includes("false"),l=s.includes("string"),f=s.includes("number"),u=[],a=!1;for(let d of s)if(r&&(d==="true"||d==="false"||d==="boolean")){if(!a)u.push("boolean");a=!0}else if(l&&Zt(d))continue;else if(f&&/^-?\d+(?:\.\d+)?$/.test(d))continue;else u.push(d);return u.join(" | ")}function Zt(e){let c=e[0];return e.length>=2&&(c==="'"||c==='"')&&e.endsWith(c)&&!e.slice(1,-1).includes(c)}function vt(e,c,i){let s=X(c)!==-1?`(${c.trim()})`:c;if(e.trim()==="unknown")return i==="&&"||s.trim()==="unknown"?"unknown":`{} | ${s}`;let r=e.trim();if(r==="boolean"||r==="string"||r==="number"){if(i==="??")return r;return Yt(i==="||"?r==="boolean"?"true":r:r==="boolean"?"false":r==="string"?"''":"0",s)}let l="false | 0 | 0n | '' | null | undefined";if(i==="??")return`([${e}] extends [NonNullable<${e}>] ? ${e} : NonNullable<${e}> | ${s})`;if(i==="||")return`([${e}] extends [object] ? ${e} : [Exclude<${e}, object> & (${l})] extends [never] ? ${e} : Exclude<NonNullable<${e}>, ${l}> | ${s})`;return`([${e}] extends [object] ? ${s} : [${e}] extends [${l}] ? ${e} : unknown extends (${e}) ? ${e} : (Exclude<${e}, object> & (${l})) | ${s})`}function te(e){let c=`(NonNullable<${e}> extends infer __dtsx_spread_value ? { -readonly [__dtsx_spread_key in keyof __dtsx_spread_value]: __dtsx_spread_value[__dtsx_spread_key] } : never)`,i=`(NonNullable<${e}> extends infer __dtsx_spread_value ? { -readonly [__dtsx_spread_key in keyof __dtsx_spread_value]?: __dtsx_spread_value[__dtsx_spread_key] } : never)`;return`([${e}] extends [null | undefined] ? {} : [${e}] extends [NonNullable<${e}>] ? ${c} : ${i})`}function ne(e,c){let i=e.trim();while(at(i))i=i.slice(1,-1).trim();let s=It(i,"??");if(s!==-1&&i.slice(s+2).trim()==="{}")return te(c(i.slice(0,s)));let r=Rt(i);if(r){if(r.whenFalse.trim()==="{}")return`Partial<${c(r.whenTrue)}>`;if(r.whenTrue.trim()==="{}")return`Partial<${c(r.whenFalse)}>`}return c(i)}function Et(e){return e.map((c)=>e.length>1&&X(c)!==-1?`(${c})`:c).join(" | ")}function st(e){let c=0;while(c<e.length){let r=e.charCodeAt(c);if(r<=32)c++;else if(r===47&&e.charCodeAt(c+1)===47){c+=2;while(c<e.length&&e.charCodeAt(c)!==10&&e.charCodeAt(c)!==13)c++}else if(r===47&&e.charCodeAt(c+1)===42){let l=e.indexOf("*/",c+2);c=l===-1?e.length:l+2}else break}let i=c,s=c;while(s<e.length){let r=e.charCodeAt(s);if(r===34||r===39||r===96){s=G(e,s,r),i=s;continue}if(r===92){s=Math.min(s+2,e.length),i=s;continue}if(r===47&&e.charCodeAt(s+1)===47){while(s<e.length&&e.charCodeAt(s)!==10&&e.charCodeAt(s)!==13)s++;continue}if(r===47&&e.charCodeAt(s+1)===42){let l=e.indexOf("*/",s+2);s=l===-1?e.length:l+2;continue}if(s++,r>32)i=s}return e.slice(c,i)}function jt(e){if(!e.startsWith("<"))return;let c=H(e)(0,0);if(!c||c.parameters||c.completeOperand||!e.slice(c.end).trim()||!nt(e.slice(c.end).trim()))return;return e.slice(1,c.end-1).trim()}function nt(e){e=st(e);let c=0,i;for(let s=0;s<e.length;s++){let r=e[s];if(r==="'"||r==='"'||r==="`"){let l=s+1;while(l<e.length&&e[l]!==r){if(e[l]==="\\")l++;l++}s=l;continue}if(r==="/"){if(e[s+1]==="/"){let l=e.indexOf(`
9
+ `,s+2);s=l===-1?e.length:l;continue}if(e[s+1]==="*"){let l=e.indexOf("*/",s+2);s=l===-1?e.length:l+1;continue}if(R(e,s)){s=S(e,s)-1;continue}}if(r==="<"&&c===0){i??=H(e);let l=i(s,0);if(l){s=l.end-1;continue}}if(r==="("||r==="["||r==="{")c++;else if(r===")"||r==="]"||r==="}")c--;else if(c!==0)continue;else if(r==="?"){if(e[s+1]!==".")return!1}else if("=!<>&|+-*/%,:".includes(r))return!1;else if(r===" "||r==="\t"||r===`
10
+ `||r==="\r"){let l=e.slice(s).trimStart(),f=/[A-Za-z]+$/.exec(st(e.slice(0,s)))?.[0];if(s=e.length-l.length-1,f&&["new","void","typeof","delete","await","yield"].includes(f))continue;if(l&&l[0]!=="."&&l[0]!=="?"&&l[0]!=="("&&l[0]!=="[")return!1}}return!0}function re(e){if(e.startsWith("function")&&et(e,0,8))return!0;let c=X(e);if(c===-1)return!1;let i=e.slice(0,c).trim();if(i.startsWith("async")&&et(i,0,5))i=i.slice(5).trim();if(i.startsWith("<")){let r=o(i,0,"<",">");if(r===-1)return!1;i=i.slice(r+1).trim()}if(i.startsWith("(")){let r=o(i,0,"(",")");if(r===-1)return!1;let l=i.slice(r+1).trim();if(l&&!l.startsWith(":"))return!1}let s=Ct(i);return at(s.params)||Z(s.params)}function at(e){if(!e.startsWith("(")||!e.endsWith(")"))return!1;let c=0;for(let i=0;i<e.length;i++){let s=e.charCodeAt(i);if(s===40)c++;else if(s===41&&--c===0)return i===e.length-1}return!1}function Rt(e){let c=0,i=-1;for(let s=0;s<e.length;s++){let r=e.charCodeAt(s);if(r===34||r===39||r===96){s=G(e,s,r)-1;continue}if(r===47&&(e.charCodeAt(s+1)===47||e.charCodeAt(s+1)===42)){if(e.charCodeAt(s+1)===47)while(s+1<e.length&&e.charCodeAt(s+1)!==10&&e.charCodeAt(s+1)!==13)s++;else{let l=e.indexOf("*/",s+2);s=l===-1?e.length:l+1}continue}if(r===40||r===91||r===123)c++;else if(r===41||r===93||r===125)c--;else if(r===63&&c===0&&e.charCodeAt(s+1)!==63)i=s;else if(r===58&&c===0&&i!==-1)return{whenTrue:st(e.slice(i+1,s)),whenFalse:st(e.slice(s+1))}}return null}function et(e,c,i){return(c===0||!D(e.charCodeAt(c-1)))&&!D(e.charCodeAt(c+i))}function Mt(e,c){let i=c;while(i<e.length){if(e.charCodeAt(i)<=32){i++;continue}if(e.startsWith("//",i)){while(i<e.length&&e.charCodeAt(i)!==10&&e.charCodeAt(i)!==13)i++;continue}if(e.startsWith("/*",i)){let s=e.indexOf("*/",i+2);i=s<0?e.length:s+2;continue}break}return i}function ie(e,c){let i=0,s=0,r=0,l=!1,f=!1;for(let u=c;u<e.length;u++){if(u=Mt(e,u),u>=e.length)break;let a=e.charCodeAt(u);if(a===34||a===39||a===96){u=G(e,u,a)-1,f=!1;continue}if(D(a)||a>=128){let d=u;while(u+1<e.length&&(D(e.charCodeAt(u+1))||e.charCodeAt(u+1)>=128))u++;f=l&&["keyof","typeof","readonly","unique","new","abstract","infer","extends"].includes(e.slice(d,u+1));continue}if(a===61&&e.charCodeAt(u+1)===62){u++,f=l;continue}if(a===40)i++;else if(a===41)i--,f=!1;else if(a===91)s++;else if(a===93)s--,f=!1;else if(a===60&&i===0&&s===0)r++;else if(a===62&&r>0&&i===0&&s===0)r--,f=!1;else if(a===123)if(i||s||r||l&&f)u=ot(e,u)-1,f=!1;else return u;else if(i===0&&s===0&&r===0){if(a===58)l=!0,f=!0;else if(l&&[124,38,63].includes(a))f=!0;else if(a===59)return-1}}return-1}function ot(e,c){let i=1,s=c+1;while(s<e.length&&i>0){let r=e.charCodeAt(s);if(r===34||r===39||r===96){s=G(e,s,r);continue}if(r===47&&e.charCodeAt(s+1)===47){s+=2;while(s<e.length&&e.charCodeAt(s)!==10&&e.charCodeAt(s)!==13)s++;continue}if(r===47&&e.charCodeAt(s+1)===42){let l=e.indexOf("*/",s+2);s=l===-1?e.length:l+2;continue}if(r===123)i++;else if(r===125)i--;s++}return s}function G(e,c,i){let s=c+1;while(s<e.length){let r=e.charCodeAt(s);if(r===92){s+=2;continue}if(i===96&&r===36&&e.charCodeAt(s+1)===123){s=ot(e,s+1);continue}if(s++,r===i)break}return s}function se(e,c){if(e.includes(".raw`")||e.includes("String.raw`"))return"string";if(!c||e.includes("${")||e.includes(`
11
+ `)||e.includes("\r"))return"string";return e}function Ht(e,c){let i=t(e),s=(a)=>i[a]?e.slice(i[a].start,i[a].end):"";if(s(0)!=="new"||i[1]?.kind!=="word"||["class","function","new","super"].includes(s(1)))return"unknown";let r=2,l=[s(1)];while(s(r)==="."&&i[r+1]?.kind==="word")l.push(s(r+1)),r+=2;let f=l.join(".");if(!c&&(f.charCodeAt(0)<65||f.charCodeAt(0)>90))return"unknown";let u="";if(s(r)==="<"){let a=i[r].start,d=H(e)(a,0);if(!d||!d.completeOperand||d.parameters)return"unknown";u=e.slice(a,d.end);while(r<i.length&&i[r].start<d.end)r++}if(r<i.length){if(s(r)!=="(")return"unknown";let a=0,d=!1;for(;r<i.length;r++)if(s(r)==="(")a++;else if(s(r)===")"&&--a===0){d=r===i.length-1;break}if(!d)return"unknown"}if(c)return c(f)?f+u:`InstanceType<typeof ${f}${u}>`;if(u)return f+u;switch(f){case"Map":return"Map<any, any>";case"Set":return"Set<any>";case"WeakMap":return"WeakMap<any, any>";case"WeakSet":return"WeakSet<any>";case"Array":return"any[]";case"Object":return"object";case"Promise":return"Promise<any>";default:return f}}function oe(e){return"{ new (...args: any[]): any }"}function Nt(e,c,i=0,s){if(e.startsWith("Promise.resolve(")){let l=e.indexOf(")",16);if(l!==-1){let f=e.slice(16,l).trim();if(f)return`Promise<${n(f,c,!1,i+1,s)}>`}return"Promise<unknown>"}if(e.startsWith("Promise.reject("))return"Promise<never>";if(e.startsWith("Promise.all(")){let r=e.indexOf("[",12),l=e.lastIndexOf("]");if(r!==-1&&l>r){let f=e.slice(r+1,l).trim(),u=Q(f),a=[];for(let d=0;d<u.length;d++){let y=u[d].trim();if(y.startsWith("Promise.resolve(")){let b=Nt(y,c,i+1,s),C=b.indexOf("<"),p=b.lastIndexOf(">");a.push(C!==-1&&p>C?b.slice(C+1,p):"unknown")}else a.push(n(y,c,!1,i+1,s))}return`Promise<[${a.join(", ")}]>`}return"Promise<unknown[]>"}return"Promise<unknown>"}function Be(e,c,i=0,s){let r=e.slice(1,-1).trim();if(!r)return"never[]";if(i>=lt)return"unknown[]";let l=Q(r),f=!1;for(let p=0;p<l.length;p++){let m=l[p],h=m.length;while(h>0&&m.charCodeAt(h-1)<=32)h--;if(h>=8&&m.slice(h-8,h)==="as const"){f=!0;break}}if(f){let p=[];for(let m=0;m<l.length;m++){let h=l[m].trim();if(h.endsWith("as const")){let A=h.slice(0,-8).trim();if(A.startsWith("[")&&A.endsWith("]")){let k=A.slice(1,-1).trim(),w=Q(k),x=[];for(let T=0;T<w.length;T++)x.push(n(w[T].trim(),!0,!1,i+1,s));p.push(`readonly [${x.join(", ")}]`)}else p.push(n(A,!0,!1,i+1,s))}else if(h.startsWith("[")&&h.endsWith("]"))p.push(Be(h,!0,i+1,s));else p.push(n(h,!0,!1,i+1,s))}return`readonly [
12
+ ${p.join(` |
13
+ `)}
14
+ ]`}let u=ft&&!c,a=[],d=[];for(let p of l){let m=p.trim(),h=L;if(L=null,m.startsWith("...")){let A=m.slice(3).trim(),k=n(A,!1,!1,i+1,s);if(k.endsWith("[]"))a.push(k.slice(0,-2));else if(k.startsWith("readonly [")&&k.endsWith("]"))a.push(k.slice(10,-1));else if(J(A))a.push(`(typeof ${A})[number]`);else a.push("unknown")}else if(m.startsWith("[")&&m.endsWith("]"))a.push(Be(m,c,i+1,s));else a.push(zt(m,c,i+1,s));if(u)d.push(L);L=h}if(u)if(mt(e))L=it(e);else{let p=[];for(let m=0;m<l.length;m++){let h=l[m].trim();if(h.endsWith("as const"))continue;if(ct(h)||h==="null"||h==="undefined")p.push(h);else if(h.startsWith("[")&&mt(h))p.push(it(h));else if(h.startsWith("{")){if(d[m])p.push(d[m])}else{let A=n(h,!1,!1,0,s);if(A!=="unknown")p.push(A)}}if(p.length>0)L=`[${p.join(", ")}]`}if(c)return`readonly [${a.join(", ")}]`;let y=new Set,b=[],C=!0;for(let p of a){if(!y.has(p))y.add(p),b.push(p);if(C){if(!(g(p)||p==="true"||p==="false"||p.charCodeAt(0)===34&&p.charCodeAt(p.length-1)===34||p.charCodeAt(0)===39&&p.charCodeAt(p.length-1)===39))C=!1}}if(C&&a.length<=10)return`readonly [${a.join(", ")}]`;if(b.length===1)return`${b[0]}[]`;return`(${b.join(" | ")})[]`}function Q(e){let c=[],i=0,s=!1,r=0,l=-1,f=0;for(let u=0;u<e.length;u++){let a=e.charCodeAt(u);if(s){if(a===92)u++;else if(a===r)s=!1;f=u+1;continue}if(a===47&&e.charCodeAt(u+1)===47){let d=e.indexOf(`
15
+ `,u+2);u=(d===-1?e.length:d)-1;continue}if(a===47&&e.charCodeAt(u+1)===42){let d=e.indexOf("*/",u+2);u=(d===-1?e.length:d+2)-1;continue}if(a===32||a===9||a===10||a===13)continue;if(a===44&&i===0){if(l!==-1)c.push(e.slice(l,f));l=-1;continue}if(a===34||a===39||a===96)s=!0,r=a;else if(a===91||a===123||a===40)i++;else if(a===93||a===125||a===41)i--;if(l===-1)l=u;f=u+1}if(l!==-1)c.push(e.slice(l,f));return c}function ct(e){if(g(e))return!0;if(e==="true"||e==="false")return!0;if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return!0;return!1}function Lt(e){return e==="number"||e==="string"||e==="boolean"}function rr(e){let c=[],i=0;while(i<e.length){while(i<e.length&&e.charCodeAt(i)<=32)i++;if(e.startsWith("/*",i)){let s=e.indexOf("*/",i+2);if(s===-1)break;c.push(e.slice(i,s+2)),i=s+2}else if(e.startsWith("//",i)){let s=i;while(s<e.length&&e.charCodeAt(s)!==10&&e.charCodeAt(s)!==13)s++;c.push(e.slice(i,s).trimEnd()),i=s}else break}return c}function Kt(e,c,i){let s=c.trim();if(!Lt(i)||!ct(s))return"";let r=(e??[]).map((f)=>f.trim()).filter((f)=>f.startsWith("/**")||f.startsWith("//")).join(`
16
+ `),l;if(r.includes("@defaultValue"))l=r;else{let f=`@defaultValue ${be(s)}`;if(!r)l=`/** ${f} */`;else{let u=r.lastIndexOf("*/");if(u!==-1){let a=r.slice(0,u).trimEnd();if(a.startsWith("/** ")&&!a.includes(`
17
+ `))a=`/**
18
+ * ${a.slice(4)}`;l=`${a}
19
+ * ${f}
20
+ */`}else l=`/**
21
+ * ${r.startsWith("// ")?r.slice(3):r.startsWith("//")?r.slice(2):r}
22
+ * ${f}
23
+ */`}}return l.split(`
24
+ `).map((f)=>{let u=f.trim();if(!u)return"";return u.startsWith("*")?` ${u}`:` ${u}`}).join(`
25
+ `)+`
26
+ `}function mt(e){let c=!1,i=0,s=e.length;for(let r=0;r<s;r++){let l=e.charCodeAt(r);if(c){if(l===92){r++;continue}if(l===i)c=!1;continue}if(l===34||l===39||l===96){c=!0,i=l;continue}if(l===61&&r+1<s&&e.charCodeAt(r+1)===62)return!1;if(l===47&&(e.charCodeAt(r+1)===47||e.charCodeAt(r+1)===42))return!1;if(l>=97&&l<=122){let f=r;while(r<s&&(e.charCodeAt(r)>=97&&e.charCodeAt(r)<=122||e.charCodeAt(r)>=65&&e.charCodeAt(r)<=90||e.charCodeAt(r)>=48&&e.charCodeAt(r)<=57||e.charCodeAt(r)===95||e.charCodeAt(r)===36))r++;let u=e.slice(f,r);if(u==="new"||u==="async"||u==="await"||u==="function"||u==="yield"||u==="console"||u==="process")return!1;let a=r;while(a<s&&e.charCodeAt(a)<=32)a++;if(a<s&&e.charCodeAt(a)===40)return!1;r--}}return!0}function dt(e,c,i=0,s,r){let l=e.slice(1,-1).trim();if(!l)return"{}";if(i>=lt)return"Record<string, unknown>";let f=ae(l),u=new Set(f.flatMap(([k])=>{let w=Tt(At(k).key);return w?.kind==="get"?[w.name]:[]})),a=[],d=[],y=[],b=!1,C=ft&&!c,p=[],m=0;for(let[k,w]of f){let{comments:x,key:T}=At(k),O=x?`${x}
27
+ `:"",P=Tt(T);if(P&&ar(P.name))continue;let M=T,V=!1;if(T==="..."){let j=w.trim(),q=r?ne(j,r):J(j)?`typeof ${j}`:n(j,c,!1,i+1,s);if(q!=="unknown")d.push(q);if(C&&(J(j)||j.startsWith("{")))p.push(`...${it(j)}`);continue}let F=L;L=null;let I,N=w.trim();if(N===T&&Z(N))I=r?.(w)??(c?void 0:s?.mutableBindingTypes?.get(N))??`typeof ${N}`;else if(he(N)){V=!0;let j=ge(T);if(j){M=j.name;let q="";if(N.startsWith("async "))q="async ";if(N.charCodeAt(q.length)===42)q+="*";I=St(j.name,q+j.typeParams+N.slice(q.length))}else I=St(T,N)}else{if(I=r?.(w)??n(w,c,!1,i+1,s),I==="unknown"&&J(N))I=(c?void 0:s?.mutableBindingTypes?.get(N))??`typeof ${N}`;if(I.includes("=>")||I.includes("function")||I.includes("async"))I=xt(I)}let v=L;L=F;let Y=M,E=w.trim(),tt=sr(M,s);if(!or(P?.name??M,s)&&!(P?.kind==="set"&&u.has(P.name)))y.push(P?de(P.kind,I):I);if(tt&&"index"in tt)b=!0;else{if(tt&&"name"in tt)M=tt.name;if(P){let j=ue(P.kind,P.name,I);if(j){a.push(`${O}${W(j)}`);continue}}if(!c&&Lt(I)&&ct(E))a.push(`${O}/** @defaultValue ${be(E)} */
28
+ ${M}: ${W(I)}`);else a.push(`${O}${c?"readonly ":""}${M}: ${W(I)}`)}if(C){let j=Ot(Y);if(E.endsWith("as const"));else if(ct(E))p.push(`${j}: ${E}`);else if(E.startsWith("[")&&mt(E))p.push(`${j}: ${it(E)}`);else if(E.startsWith("{")){if(v)p.push(`${j}: ${v}`)}else if(V)p.push(`${j}: ${ht(xt(I))}`),m++;else if(!E.startsWith("[")&&(E.includes("=>")||E.startsWith("function")||E.startsWith("async"))){let q=pt(E,!1,0,!0);p.push(`${j}: ${ht(q)}`),m++}}}if(C&&p.length>m){let k=i>0?(i-1)/2:0,w=`{ ${p.join(", ")} }`;if(w.length<=80)L=w;else{let x=" ".repeat((k+1)*2),T=" ".repeat(k*2);L=`{
29
+ ${x}${p.join(`,
30
+ ${x}`)}
31
+ ${T}}`}}if(b&&d.length===0){let k=[...new Set(y)].map((w)=>w.includes("=>")||w.includes(" & ")?`(${w})`:w);a.unshift(`${c?"readonly ":""}[x: string]: ${W(k.join(" | "))}`)}let h=a.length>0?`{
32
+ ${a.join(`;
33
+ `)}
34
+ }`:"{}";if(d.length===0)return h;let A=d[0];for(let k=1;k<d.length;k++)A=`Omit<${A}, keyof ${d[k]}> & ${d[k]}`;return a.length>0?`Omit<${A}, keyof ${h}> & ${h}`:A}function Z(e){if(!e)return!1;let c=e.charCodeAt(0);if(!(c>=65&&c<=90||c>=97&&c<=122||c===95||c===36||c>127))return!1;for(let i=1;i<e.length;i++)if(!D(e.charCodeAt(i)))return!1;return!0}function J(e){let c=e.split(".");return c.length>0&&c.every(Z)}function ce(e){let c=!1,i="";for(let s=0;s<e.length;s++){let r=e[s];if(c){if(r==="\\")s++;else if(r===i)c=!1;continue}if(r==='"'||r==="'"||r==="`"){c=!0,i=r;continue}if(r==="(")return s;if(r==="<"){let l=o(e,s,"<",">");if(l!==-1)s=l}}return-1}function U(e){if(e.length<3||!e.endsWith(")"))return null;let c=ce(e);if(c===-1||o(e,c,"(",")")!==e.length-1)return null;let i=e.slice(0,c).trim(),s=!1;if(i.endsWith("?."))s=!0,i=i.slice(0,-2).trim();let r=i,l=!1,f=i.indexOf("<");if(f!==-1){if(o(i,f,"<",">")!==i.length-1)return null;r=i.slice(0,f).trim(),l=!0}if(r.endsWith("?.")){s=!0;let p=i.slice(r.length);r=r.slice(0,-2).trim(),i=r+p}if(!J(r))return null;let u=e.slice(c+1,-1).trim(),a=X(u)!==-1||u.startsWith("function")||u.startsWith("async function"),d=J(u),y=!a&&u.endsWith(")")&&U(u)!==null,b=r.indexOf(".");if(b!==-1){if(r.indexOf(".",b+1)!==-1)return null}else if(!l&&!s&&!a&&!d&&!y)return null;let C=`ReturnType<typeof ${i}>`;return s?`ReturnType<NonNullable<typeof ${i}>> | (null extends typeof ${r} ? undefined : undefined extends typeof ${r} ? undefined : never)`:C}function xt(e){let i=e.split(`
35
+ `).map((y)=>_t(y)).join(`
36
+ `),s=i.indexOf("async");if(s!==-1){let y=s>0?i.charCodeAt(s-1):32,b=s+5<i.length?i.charCodeAt(s+5):32;if(!D(y)&&!D(b))i=(i.slice(0,s)+i.slice(s+5)).trim()}let r=i.indexOf("(");if(r!==-1){let y=o(i,r,"(",")");if(y!==-1){let b=i.slice(r,y+1),C=ye(b);i=i.slice(0,r)+C+i.slice(y+1)}}let l=i.length,f="",u=[],a=!1,d=!1;for(let y=0;y<l;y++){let b=i.charCodeAt(y);if(b===123||b===40)u.push(b);else if(b===125||b===41)u.pop();if(b<=32){if(a=!0,b===10||b===13)d=!0;continue}if(a&&f.length>0){let p=(u.length>0?u[u.length-1]:0)===123;if(d&&p){let m=f.charCodeAt(f.length-1),h=m===59||m===44||m===123||b===125,A=f.length>=2&&f.charCodeAt(f.length-1)===47&&f.charCodeAt(f.length-2)===42;if(!h&&!A)f+="; ";else f+=" "}else f+=" "}a=!1,d=!1,f+=i[y]}return f.trim()}function D(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===95||e===36}function ye(e){let c=e.trim(),i,s=!1;if(c.startsWith("(")&&c.endsWith(")"))i=c.slice(1,-1),s=!0;else i=c;let r=i.trim();if(!r)return s?"()":"";let l=!1;{let m=0;for(let h=0;h<r.length;h++){let A=r.charCodeAt(h);if(A===40||A===60||A===91||A===123)m++;else if(A===41||A===93||A===125||A===62&&r.charCodeAt(h-1)!==61)m--;else if(m===0&&A===61){let k=h>0?r.charCodeAt(h-1):0,w=h+1<r.length?r.charCodeAt(h+1):0;if(k!==61&&k!==33&&k!==60&&k!==62&&w!==61&&w!==62){l=!0;break}}}}if(!l)return c;let f=[],u=[],a=0,d=0,y=!1,b=0;for(let m=0;m<=r.length;m++){if(m===r.length){f.push(r.slice(a));break}let h=r.charCodeAt(m);if(y){if(h===92){m++;continue}if(h===b)y=!1;continue}if(h===47&&m+1<r.length){let A=r.charCodeAt(m+1);if(A===42){m+=2;while(m+1<r.length&&!(r.charCodeAt(m)===42&&r.charCodeAt(m+1)===47))m++;m++;continue}if(A===47){while(m<r.length&&r.charCodeAt(m)!==10)m++;continue}}if(h===39||h===34||h===96){y=!0,b=h;continue}if(h===40||h===60||h===91||h===123)d++;else if(h===41||h===93||h===125||h===62&&r.charCodeAt(m-1)!==61)d--;else if(h===44&&d===0){f.push(r.slice(a,m));let A=",",k=m+1;while(k<r.length&&r.charCodeAt(k)<=32)A+=r[k],k++;u.push(A),a=k}}let C=[];for(let m of f){let h=m.trim();if(!h){C.push(m);continue}if(h.startsWith("//"))continue;let A=_t(h),k=m.slice(0,m.length-m.trimStart().length);C.push(k+le(A))}let p=C[0]||"";for(let m=1;m<C.length;m++)p+=(u[m-1]||", ")+C[m];return _e(s?`(${p})`:p)}function _t(e){let c=!1,i=0;for(let s=0;s<e.length-1;s++){let r=e.charCodeAt(s);if(c){if(r===92){s++;continue}if(r===i)c=!1;continue}if(r===39||r===34||r===96){c=!0,i=r;continue}if(r===47&&e.charCodeAt(s+1)===47)return e.slice(0,s).trimEnd()}return e}function le(e){if(e.startsWith("..."))return e;let c=-1,i=-1,s=0,r=!1,l=0;for(let u=0;u<e.length;u++){let a=e.charCodeAt(u);if(r){if(a===92){u++;continue}if(a===l)r=!1;continue}if(a===47&&u+1<e.length){let d=e.charCodeAt(u+1);if(d===42){u+=2;while(u+1<e.length&&!(e.charCodeAt(u)===42&&e.charCodeAt(u+1)===47))u++;u++;continue}if(d===47){while(u<e.length&&e.charCodeAt(u)!==10)u++;continue}}if(a===39||a===34||a===96){r=!0,l=a;continue}if(a===40||a===60||a===91||a===123)s++;else if(a===41||a===93||a===125||a===62&&e.charCodeAt(u-1)!==61)s--;else if(s===0){if(a===58&&c===-1)c=u;else if(a===61&&i===-1&&(u===0||e.charCodeAt(u-1)!==61)&&(u+1>=e.length||e.charCodeAt(u+1)!==61&&e.charCodeAt(u+1)!==62))i=u}}let f=i!==-1;if(c!==-1&&(i===-1||c<i)){let u=e.slice(0,c).trim(),a=i!==-1?e.slice(c+1,i).trim():e.slice(c+1).trim(),d=f&&!u.endsWith("?")?"?":"";return`${u}${d}: ${a}`}else if(i!==-1){let u=e.slice(0,i).trim(),a=we(u,e.slice(i+1));if(a)return je(a,bt);let d=!u.endsWith("?")?"?":"";return`${u}${d}: ${bt(e.slice(i+1))}`}return e}function bt(e){let c=e.trim();if(c==="true"||c==="false")return"boolean";if(g(c))return"number";if(c.startsWith("'")&&c.endsWith("'")||c.startsWith('"')&&c.endsWith('"'))return"string";if(c.startsWith("["))return"unknown[]";if(c.startsWith("{"))return"Record<string, unknown>";return"unknown"}function fe(e){let c=0,i=e.length;while(c<i){while(c<i&&(e.charCodeAt(c)===32||e.charCodeAt(c)===9||e.charCodeAt(c)===10||e.charCodeAt(c)===13))c++;if(c+1<i&&e.charCodeAt(c)===47&&e.charCodeAt(c+1)===42){c+=2;while(c+1<i&&!(e.charCodeAt(c)===42&&e.charCodeAt(c+1)===47))c++;c+=2;continue}break}return c}function At(e){let c=[],i=0,s=e.length;while(i<s){while(i<s&&e.charCodeAt(i)<=32)i++;if(i+1>=s||e.charCodeAt(i)!==47||e.charCodeAt(i+1)!==42)break;let r=i;i+=2;while(i+1<s&&!(e.charCodeAt(i)===42&&e.charCodeAt(i+1)===47))i++;i=Math.min(i+2,s),c.push(e.slice(r,i).trim())}return{comments:c.join(`
37
+ `),key:e.slice(i).trim()}}function ae(e){let c=[],i="",s="",r=0,l=!1,f="",u=!0,a=!1,d=0,y=!1,b=!1,C=0,p=!1,m=!1;for(let h=0;h<e.length;h++){let A=e.charCodeAt(h),k=h>0?e.charCodeAt(h-1):0,w=h<e.length-1?e.charCodeAt(h+1):0;if(!l&&!a&&A===47&&w===47){i=i.replace(/[ \t]+$/,""),h+=2;while(h<e.length&&e.charCodeAt(h)!==10)h++;h--;continue}if(!l&&!a&&A===47&&w===42){a=!0,d=1,i+="/*",h++;continue}else if(a&&A===42&&w===47){if(d--,i+="*/",h++,d===0)a=!1;continue}else if(a&&A===47&&w===42){d++,i+="/*",h++;continue}let x=e[h];if(!l&&!a&&(A===34||A===39||A===96))l=!0,f=x,i+=x;else if(l&&x===f&&k!==92)l=!1,i+=x;else if(!l&&!a)if(A===46&&w===46&&e.charCodeAt(h+2)===46&&r===0&&u)s=`${i.trim()}...`,i="",u=!1,p=!1,h+=2;else if(A===40&&r===0&&u&&C===0){s=i.trim();let T=fe(s),O=T>0?s.slice(0,T):"",P=s.slice(T),M="";if(P.startsWith("async ")||P.startsWith("async\t")||P.startsWith(`async
38
+ `))P=P.slice(6).trimStart(),M="async ";if(P.startsWith("*"))P=P.slice(1).trimStart(),M+="*";s=O+P,i=M+x,u=!1,p=!0,m=!1,r=1}else if(A===123||A===91||A===40){if(r++,i+=x,m&&A===123)m=!1}else if(A===125||A===93||A===41){if(r--,i+=x,A===41&&r===0&&!u&&!p)y=!0;if(p){if(A===41&&r===0&&!m)m=!0;else if(A===125&&r===0)p=!1,m=!1}}else if(A===58&&r===0&&u&&C===0)s=i.trim(),i="",u=!1;else if(A===58&&r===0&&y)b=!0,i+=x;else if(A===60&&b)C++,i+=x;else if(A===60&&u&&r===0)C++,i+=x;else if(A===62&&C>0&&k!==61)C--,i+=x;else if(A===61&&w===62&&b&&C===0)b=!1,y=!1,i+=x;else if(A===44&&r===0&&C===0&&!m){if(s&&i.trim()){let T=i.trim();c.push([s,T])}else if(u&&i.trim())kt(c,i.trim());i="",s="",u=!0,y=!1,b=!1,C=0}else i+=x;else i+=x}if(s&&i.trim()){let h=i.trim();c.push([s,h])}else if(u&&i.trim())kt(c,i.trim());return c}function kt(e,c){let{comments:i,key:s}=At(c);if(Z(s))e.push([i?`${i}
39
+ ${s}`:s,s]);else if(s.startsWith("...")&&s.length>3)e.push(["...",s.slice(3).trim()])}function Tt(e){let c=e.trim();if(c.startsWith("get ")&&c.length>4){let i=c.slice(4).trim();if(i)return{kind:"get",name:i}}if(c.startsWith("set ")&&c.length>4){let i=c.slice(4).trim();if(i)return{kind:"set",name:i}}return null}function ue(e,c,i){let s=i.trim();if(s.charCodeAt(0)!==40)return null;let r=o(s,0,"(",")");if(r===-1)return null;let l=s.slice(1,r).trim(),f=s.slice(r+1).trimStart();if(!f.startsWith("=>"))return null;let u=f.slice(2).trim();if(e==="get")return`get ${c}(): ${u||"unknown"}`;return`set ${c}(${l})`}function de(e,c){let i=c.trim(),s=o(i,0,"(",")");if(!i.startsWith("(")||s===-1)return"unknown";if(e==="get"){let u=i.slice(s+1).trim();return u.startsWith("=>")?u.slice(2).trim():"unknown"}let r=i.slice(1,s).trim(),l=r.startsWith("{")?o(r,0,"{","}"):r.startsWith("[")?o(r,0,"[","]"):0,f=r.indexOf(":",Math.max(0,l));return f===-1?"unknown":r.slice(f+1).trim()}function he(e){let c=e;if(c.startsWith("async ")||c.startsWith("async\t"))c=c.slice(5).trimStart();if(c.startsWith("*"))c=c.slice(1).trimStart();if(!c.startsWith("("))return!1;let i=0;for(let s=0;s<c.length;s++){let r=c.charCodeAt(s);if(r===40)i++;else if(r===41){if(i--,i===0){let l=c.slice(s+1).trimStart();if(l.startsWith("{"))return!0;if(l.startsWith(":")){let f=yt(l,1);if(f?.kind==="arrow")return!1;if(f?.kind==="body")return!0}return!1}}}return!1}function ge(e){let c=e.trimEnd();if(!c.endsWith(">"))return null;let i=0,s=-1;for(let l=c.length-1;l>=0;l--){let f=c.charCodeAt(l);if(f===62){if(l>0&&c.charCodeAt(l-1)===61)continue;i++}else if(f===60){if(i--,i===0){s=l;break}}}if(s===-1)return null;let r=c.slice(0,s).trimEnd();if(!r)return null;return{name:r,typeParams:c.slice(s)}}function St(e,c){let i=c.trimStart(),s=!1,r=!1;if(i.startsWith("async ")||i.startsWith("async\t"))s=!0,i=i.slice(5).trimStart();if(i.startsWith("*"))r=!0,i=i.slice(1).trimStart();let l="";if(i.charCodeAt(0)===60){let C=0,p=-1;for(let m=0;m<i.length;m++)if(i.charCodeAt(m)===60)C++;else if(i.charCodeAt(m)===62&&!(m>0&&i.charCodeAt(m-1)===61)){if(C--,C===0){p=m;break}}if(p!==-1)l=i.slice(0,p+1),i=i.slice(p+1).trimStart()}let f=i.indexOf("("),u=o(i,f,"(",")");if(f===-1||u===-1)return"() => unknown";let a=i.slice(f,u+1),d="unknown",y=i.slice(u+1).trimStart();if(y.charCodeAt(0)===58){let C=y.slice(1),p=yt(C,0);if(p)d=C.slice(0,p.index).trim();else d=C.trim()}if(d==="unknown"&&!r&&y.charCodeAt(0)===123){let C=o(y,0,"{","}");if(C!==-1){let p=B(y.slice(1,C),s,a);if(p!=="unknown"&&p!=="Promise<unknown>")d=s&&p.startsWith("Promise<")?p.slice(8,-1):p;else if(s)d="Promise<unknown>"}}if(d==="unknown"){if(s&&r)d="AsyncGenerator<unknown, void, unknown>";else if(r)d="Generator<unknown, void, unknown>";else if(s)d="Promise<void>"}else if(s&&!d.startsWith("Promise<")&&!d.startsWith("AsyncGenerator<"))d=`Promise<${d}>`;let b=ye(a);return`${l}${b} => ${d}`}function yt(e,c){let i=0,s=0,r=0,l=0,f=!1,u=0;for(let a=c;a<e.length;a++){let d=e.charCodeAt(a);if(f){if(d===92)a++;else if(d===u)f=!1;continue}if(d===34||d===39||d===96){f=!0,u=d;continue}if(d===40)i++;else if(d===41&&i>0)i--;else if(d===91)s++;else if(d===93&&s>0)s--;else if(d===60)r++;else if(d===62&&r>0&&e.charCodeAt(a-1)!==61)r--;else if(d===125&&l>0)l--;else if(d===123){let y=i>0||s>0||r>0||l>0,b=e.slice(c,a).trimEnd(),C=b.charCodeAt(b.length-1),p=b.length===0||C===38||C===124||C===40||C===44||C===58||C===61||C===91;if(y||p)l++;else return{index:a,kind:"body"}}else if(d===61&&a+1<e.length&&e.charCodeAt(a+1)===62&&i===0&&s===0&&r===0&&l===0)return{index:a,kind:"arrow"}}return null}function o(e,c,i,s){let r=0;for(let l=c;l<e.length;l++)if(e[l]===i)r++;else if(e[l]===s){if(s===">"&&l>0&&e[l-1]==="=")continue;if(r--,r===0)return l}return-1}function X(e){let c=0,i=0,s=!1,r="";for(let l=0;l<e.length-1;l++){let f=e[l],u=e[l+1],a=l>0?e[l-1]:"";if(!s&&(f==='"'||f==="'"||f==="`"))s=!0,r=f;else if(s&&f===r&&a!=="\\")s=!1;if(!s){if(f==="<"){let d=o(e,l,"<",">");if(d!==-1){l=d;continue}}if(f==="(")c++;else if(f===")")c--;else if(f==="[")i++;else if(f==="]")i--;if(f==="="&&u===">"&&c===0&&i===0)return l}}return-1}function pt(e,c=!1,i=0,s=!0){let r=e.trim();if(r.length>200&&ut(r,"=>")>2&&ut(r,"<")>5&&!r.startsWith("function"))return c?"((...args: any[]) => any)":"(...args: any[]) => any";if(r.startsWith("async ")&&r.includes("=>")){let f=r.slice(5).trim(),u=X(f);if(u===-1)return c?"(() => Promise<unknown>)":"() => Promise<unknown>";let a=f.substring(0,u).trim(),d=f.substring(u+2).trim(),y=Ct(a),{params:b,returnType:C}=y;if(b=ye(b),b==="()"||b==="")b="()";else if(!b.startsWith("("))b=`(${b})`;let p=C;if(p);else if(d.startsWith("{"))p=B(d.slice(1,d.endsWith("}")?-1:void 0),!0,y.params);else p=_(d,gt(y.params));let m=`${b} => ${C||p.startsWith("Promise<")?p:`Promise<${p}>`}`;return c?`(${m})`:m}if(r.includes("=>")){let f="",u=r;if(r.startsWith("<")){let A=o(r,0,"<",">");if(A!==-1)f=r.substring(0,A+1),u=r.substring(A+1).trim()}let a=X(u);if(a===-1)return c?"(() => unknown)":"() => unknown";let d=u.substring(0,a).trim(),y=u.substring(a+2).trim(),b=Ct(d),{params:C,returnType:p}=b;if(C=ye(C),C==="()"||C==="")C="()";else if(!C.startsWith("("))C=`(${C})`;let m="unknown";if(p)m=p;else if(y.startsWith("{"))m=B(y.slice(1,y.endsWith("}")?-1:void 0),!1,b.params);else if(rt(y)||at(y)&&rt(y.slice(1,-1).trim()))m="JSX.Element";else if(y.includes("=>")){let A=y.trimStart(),k=A.indexOf("("),w=k!==-1?o(A,k,"(",")"):-1,x=w!==-1?A.indexOf("=>",w):-1;if(k===0&&w!==-1&&x!==-1){let T=A.substring(k+1,w).trim(),O=ye(T);if(f.includes("T")&&O.includes("T"))m=`(${O}) => T`;else m=`(${O}) => any`}else m="any"}else m=_(y,gt(b.params));let h=`${f}${C} => ${m}`;return c?`(${h})`:h}if(r.startsWith("function")){let f=8,u=r.length;while(f<u&&r.charCodeAt(f)<=32)f++;let a=!1;if(f<u&&r.charCodeAt(f)===42){a=!0,f++;while(f<u&&r.charCodeAt(f)<=32)f++}let d="";if(f<u&&r.charCodeAt(f)===60){let C=f,p=1;f++;while(f<u&&p>0){let m=r.charCodeAt(f);if(m===60)p++;else if(m===62&&r.charCodeAt(f-1)!==61)p--;f++}d=r.substring(C,f);while(f<u&&r.charCodeAt(f)<=32)f++}let y=r.indexOf("(",f);if(y!==-1){let C=1,p=y+1;while(p<u&&C>0){let x=r.charCodeAt(p);if(x===40)C++;else if(x===41)C--;p++}let m=r.substring(y+1,p-1).trim(),h=m?ye(`(${m})`):"()";if(a){let x=r.substring(p).trim(),T=x.indexOf("Generator<");if(T!==-1){let P=T+10,M=x.indexOf(">",P);if(M!==-1){let V=x.substring(P,M),F=`${d}${h} => Generator<${V}>`;return c?`(${F})`:F}}let O=`${d}${h} => Generator<any, any, any>`;return c?`(${O})`:O}let A="unknown",k=r.substring(p).trimStart();if(k.charCodeAt(0)===58){let x=k.slice(1),T=yt(x,0),O=(T?x.slice(0,T.index):x).trim();if(O)A=O}let w=`${d}${h} => ${A}`;return c?`(${w})`:w}let b="(...args: any[]) => unknown";return c?`(${b})`:b}if(r.includes("=>")&&r.includes("(")&&r.includes(")")){if(r.length>100||ut(r,"=>")>2){let f="";if(r.charCodeAt(0)===60){let b=o(r,0,"<",">");if(b!==-1)f=r.substring(0,b+1)}let u=r.indexOf("("),a=u!==-1?o(r,u,"(",")"):-1,d=u!==-1&&a!==-1?r.substring(u,a+1):"(...args: any[])";d=ye(d);let y=`${f}${d} => any`;return c?`(${y})`:y}return c?`(${r})`:r}let l="() => unknown";return c?`(${l})`:l}function Ct(e){let c=e.trim();if(!c.startsWith("("))return{params:c,returnType:""};let i=o(c,0,"(",")");if(i===-1)return{params:c,returnType:""};let s=c.slice(i+1).trim();return{params:c.slice(0,i+1),returnType:s.startsWith(":")?s.slice(1).trim():""}}function We(e){let c=e.trim();if(c==="any"||c==="object"||c==="unknown")return!0;if(c.startsWith("Record<")&&c.endsWith(">"))return!0;if(c.startsWith("Array<")&&c.endsWith(">"))return!0;if(/^\{\s*\[[^\]]*\]:\s*(any|string|number|unknown)\s*\}$/.test(c))return!0;return!1}function z(e){let c=-1,i=0;for(let r=0;r<e.length;r++){let l=e.charCodeAt(r);if(l===34||l===39||l===96){r=G(e,r,l)-1;continue}if(l===47&&e.charCodeAt(r+1)===47){while(r<e.length&&e.charCodeAt(r)!==10)r++;continue}if(l===47&&e.charCodeAt(r+1)===42){let f=e.indexOf("*/",r+2);r=f===-1?e.length:f+1;continue}if(l===47){let f=r-1;while(f>=0&&e.charCodeAt(f)<=32)f--;if(f<0||"([{:;,=!?&|+*-~>".includes(e[f])){let u=!1;for(r++;r<e.length;r++){let a=e.charCodeAt(r);if(a===92)r++;else if(a===91)u=!0;else if(a===93)u=!1;else if(a===47&&!u)break}continue}}if(l===40||l===91||l===123)i++;else if(l===41||l===93||l===125)i--;else if(i===0&&e.startsWith("satisfies",r)&&et(e,r,9)&&e[r-1]!==".")c=r}if(c===-1)return null;let s=e.slice(c+9).trim();if(s.endsWith(";"))s=s.slice(0,-1).trim();return s||null}function Va(e){let c=e.trim(),i=c.match(/^\{\s*\[(\w+)\s+in\s+(.+?)\](\?)?\s*:\s*(.+)\s*\}$/);if(i){let[,l,f,u,a]=i;return`{ [${l} in ${f}]${u?"?":""}: ${a} }`}let s=c.match(/^\{\s*readonly\s+\[(\w+)\s+in\s+(.+?)\](\?)?\s*:\s*(.+)\s*\}$/);if(s){let[,l,f,u,a]=s;return`{ readonly [${l} in ${f}]${u?"?":""}: ${a} }`}let r=c.match(/^\{\s*(-?readonly\s+)?\[(\w+)\s+in\s+(.+?)\](-?\?)?\s*:\s*(.+)\s*\}$/);if(r){let[,l,f,u,a,d]=r;return`{ ${l?`${l.trim()} `:""}[${f} in ${u}]${a||""}: ${d} }`}return null}function Ua(e){let c=e.trim(),i=c.indexOf(" extends ");if(i===-1)return null;let s=c.slice(i+9),r=me(s);if(r===-1)return null;let l=pe(s,r);if(l===-1)return null;let f=c.slice(0,i).trim(),u=s.slice(0,r).trim(),a=s.slice(r+1,l).trim(),d=s.slice(l+1).trim();return`${f} extends ${u} ? ${a} : ${d}`}function me(e){let c=0,i=!1,s="";for(let r=0;r<e.length;r++){let l=e[r],f=r>0?e[r-1]:"";if(!i&&(l==='"'||l==="'"||l==="`"))i=!0,s=l;else if(i&&l===s&&f!=="\\")i=!1;if(!i){if(l==="<"||l==="("||l==="["||l==="{")c++;if(l===">"||l===")"||l==="]"||l==="}")c--;if(l==="?"&&c===0)return r}}return-1}function pe(e,c){let i=0,s=!1,r="";for(let l=c+1;l<e.length;l++){let f=e[l],u=l>0?e[l-1]:"";if(!s&&(f==='"'||f==="'"||f==="`"))s=!0,r=f;else if(s&&f===r&&u!=="\\")s=!1;if(!s){if(f==="<"||f==="("||f==="["||f==="{")i++;if(f===">"||f===")"||f==="]"||f==="}")i--;if(f==="?"&&i===0)i++;if(f===":"&&i===0)return l;if(f===":"&&i>0)i--}}return-1}function za(e){let c=e.trim();if(!c.startsWith("`")||!c.endsWith("`"))return null;let i=c.slice(1,-1);if(!i.includes("${"))return c;let s=[],r="",l=0;while(l<i.length)if(i[l]==="$"&&i[l+1]==="{"){if(r)s.push(`"${r}"`),r="";let f=1,u="";l+=2;while(l<i.length&&f>0){if(i[l]==="{")f++;if(i[l]==="}")f--;if(f>0)u+=i[l];l++}s.push(u.trim())}else r+=i[l],l++;if(r)s.push(`"${r}"`);return c}function Ha(e){let c=[],i=/infer\s+(\w+)/g,s;while((s=i.exec(e))!==null)c.push(s[1]);return c}function Ka(e){let i=e.trim(),s=i.indexOf("[");if(s!==-1){if(i.indexOf(" in ",s)!==-1)return!0}let r=i.indexOf(" extends ");if(r!==-1){let f=i.indexOf(" ? ",r);if(f!==-1&&i.indexOf(" : ",f)!==-1)return!0}if(i.charCodeAt(0)===96&&i.charCodeAt(i.length-1)===96){if(i.indexOf("${")!==-1)return!0}let l=i.indexOf("infer ");if(l!==-1){if(l===0||!D(i.charCodeAt(l-1)))return!0}return!1}function qa(e,c=3){let i=e.trim(),s=0,r=0;for(let l of i){if(l==="<"||l==="("||l==="["||l==="{")s++,r=Math.max(r,s);if(l===">"||l===")"||l==="]"||l==="}")s--}if(r>c){let l=i.match(/^(\w+)</);if(l)return`${l[1]}<any>`;return"unknown"}return i}function Ja(e){let i=e.trim().match(/^(\w+)<(.+)>$/);if(!i)return null;let s=i[1],r=i[2],l=$a(r);if(["Partial","Required","Readonly","Pick","Omit","Record","Exclude","Extract","NonNullable","ReturnType","Parameters","ConstructorParameters","InstanceType","ThisParameterType","OmitThisParameter","ThisType","Uppercase","Lowercase","Capitalize","Uncapitalize","Awaited","NoInfer"].includes(s))return{name:s,params:l};return null}function $a(e){let c=[],i="",s=0,r=!1,l="";for(let f=0;f<e.length;f++){let u=e[f],a=f>0?e[f-1]:"";if(!r&&(u==='"'||u==="'"||u==="`"))r=!0,l=u;else if(r&&u===l&&a!=="\\")r=!1;if(!r){if(u==="<"||u==="("||u==="["||u==="{")s++;if(u===">"||u===")"||u==="]"||u==="}")s--;if(u===","&&s===0){c.push(i.trim()),i="";continue}}i+=u}if(i.trim())c.push(i.trim());return c}function Ya(e){let c=e.trim();if(c.startsWith("keyof "))return c;return null}function Xa(e){let c=e.trim();if(c.startsWith("typeof "))return c;return null}function Za(e){let c=e.trim();if(c.length===0||c.charCodeAt(0)===91)return!1;if(c.charCodeAt(c.length-1)!==93)return!1;let i=c.indexOf("[");if(i<=0)return!1;for(let s=0;s<i;s++){let r=c.charCodeAt(s);if(!D(r)&&r!==46)return!1}return!0}
40
+ export{Vt,Ut,n,zt,B,Sa,W,Ht,Be,Q,rr,Kt,dt,U,ye,o,pt,We,z,Va,Ua,za,Ha,Ka,qa,Ja,$a,Ya,Xa,Za};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{a,i}from"./chunk-0af0hsfc.js";import{t,m}from"./chunk-tsbthwf0.js";import{ft,Gt}from"./chunk-t89jepjk.js";import{w}from"./chunk-k75z3nef.js";import{n,U}from"./chunk-h7tsf2qg.js";function F(g,k){let D=(B)=>t(B).map((y)=>B.slice(y.start,y.end)).join("");return D(g)===D(k)}function fe(g){if(["number","string","boolean","bigint","symbol","undefined","null"].includes(g))return g;let k=n(g,!1);return["number","string","boolean","bigint","undefined","null"].includes(k)?k:void 0}function de(g,k){if(F(g,k))return g;let D=fe(k);if(!D)return;let B=t(g),y=0,S=0,E=[];for(let T of B){let v=g.slice(T.start,T.end);if(v==="("||v==="["||v==="{"||v==="<")y++;else if(v===")"||v==="]"||v==="}"||v===">")y--;else if(v==="|"&&y===0)E.push(g.slice(S,T.start).trim()),S=T.end}E.push(g.slice(S).trim());let R=E.find((T)=>F(T,k));if(R)return R;if(E.includes(D))return D==="boolean"&&(k==="true"||k==="false")?k:D;return}function Jn(g,k,D,B=new Set){let y=new Map,S=[],E=new Set;for(let e of[...k,...D.values()]){if(E.has(e))continue;if(E.add(e),S.push(e),e.kind==="import")for(let o of w(e.text))y.set(o,{declared:`typeof ${o}`,flow:`typeof ${o}`,unresolved:!1});else if(["function","class","enum"].includes(e.kind))y.set(e.name,{declared:`typeof ${e.name}`,flow:`typeof ${e.name}`,unresolved:!1});else if(e.kind==="variable")y.set(e.name,{declared:e.typeAnnotation,unresolved:!1})}S.sort((e,o)=>(e.start??0)-(o.start??0));let R=new Set(S.filter((e)=>e.kind==="function"&&!e.generics).map((e)=>e.name));for(let e of B)R.add(e);let T=new Map,v=(e)=>{if(e=e.trimStart(),T.has(e))return T.get(e);if(T.set(e,void 0),!a(e.charCodeAt(0)))return;let o=1;while(i(e.charCodeAt(o)))o++;if(!R.has(e.slice(0,o)))return;let r=t(e);if(r[0]?.kind!=="word"||!r[1]||e.slice(r[1].start,r[1].end)!=="(")return;let d=1;for(let s=2;s<r.length;s++){let l=e.slice(r[s].start,r[s].end);if(l==="(")d++;else if(l===")"&&--d===0){let c=s===r.length-1?e.slice(r[0].start,r[0].end):void 0;return T.set(e,c),c}}return},_=new Set(S.filter((e)=>e.kind==="variable"&&!e.typeAnnotation&&typeof e.value==="string").map((e)=>v(e.value)).filter((e)=>e!==void 0)).size?m(g):void 0,H=new Map;if(_){let e=0;for(let o=0;o<_.length;o++){let r=g.slice(_[o].start,_[o].end);if(e===0&&r==="function"){let d=_[o+1],s=d&&g.slice(d.start,d.end)==="*"?_[o+2]:d;if(s?.kind==="word"){let l=g.slice(s.start,s.end);H.set(l,(H.get(l)??0)+1)}}if(["{","(","["].includes(r))e++;else if(["}",")","]"].includes(r))e--}}let W=new Map;for(let e of S)if(e.kind==="function"&&!e.generics&&H.get(e.name)===1)W.set(e.name,e);for(let e of B){let o=S.find((r)=>r.kind==="import"&&w(r.text).includes(e));if(o)W.set(e,o)}let I="__dtsx_call_result";while(g.includes(I))I+="_";let X=(e)=>`(typeof ${e}) extends (...args: never[]) => infer ${I} ? ${I} : never`,G=new Map,L=!1;for(let e of S){if(e.kind!=="variable"||e.typeAnnotation||typeof e.value!=="string")continue;let o=U(e.value);if(o&&n(e.value,!1)===o)e.inferredType=o,e.text=`${e.isExported?"export ":""}declare ${e.modifiers?.[0]??"const"} ${e.name}: ${o};`;let r=v(e.value);if(r&&W.has(r))G.set(e,X(r)),y.get(e.name).active=!0,y.get(r).active=!0,L=!0;if(e.modifiers?.[0]!=="const")continue;let d=ft(e.value);if(!d||d===e.name||!y.has(d))continue;y.get(d).active=!0,y.get(e.name).active=!0,L=!0}if(!L)return;let u=_??m(g),f=(e)=>u[e]?g.slice(u[e].start,u[e].end):"",b=new Map,z=new Map,J=new Set,N=new Set,Q=new Set,Y=new Map,j=[];for(let e=0;e<u.length;e++){let o=f(e),r=j.at(-1);if(r!==void 0)z.set(e,r);if(o==="{"&&["=","(","[",",",":","?","return","yield"].includes(f(e-1)))J.add(e);if(["(","[","{"].includes(o))j.push(e);else if([")","]","}"].includes(o)){let d=j.at(-1);if(d!==void 0&&["()","[]","{}"].includes(f(d)+o))j.pop(),b.set(d,e)}}let Z=new Map;for(let e=0;e<u.length;){if(u[e].kind!=="punctuation"){e++;continue}let r=[">>>=","**=","&&=","||=","??=","<<=",">>=","===","!==",">>>","**","&&","||","??","<<",">>","=>","==","!=","<=",">=","++","--","+=","-=","*=","/=","%=","&=","|=","^=","="].find((s)=>g.startsWith(s,u[e].start))??f(e);Z.set(e,r);let d=u[e].start+r.length;do e++;while(e<u.length&&u[e].start<d)}for(let e=0;e<u.length;e++){let o=te(e);if(o!==void 0)N.add(o)}for(let e of N)ce(e);let h=0;function ee(e){let o=ft(e);if(o){let l=y.get(o);return{type:l?.flow,unresolved:l?.unresolved??!1}}let r=v(e),d=r?W.get(r):void 0;if(d)return{type:d.returnType&&fe(d.returnType)?d.returnType:X(r),unresolved:!1};let s=n(e,!0);return{type:s==="unknown"?void 0:s,unresolved:!1}}function M(e){return Z.get(e)??""}function P(e){if(u[e]?.kind!=="word"||Q.has(e)||f(e-1)==="."||f(e-1)==="#"&&f(e-2)===".")return;let o=y.get(f(e));if(!o?.active)return;let r=M(e+1);if(["=","+=","-=","*=","/=","%=","**=","<<=",">>=",">>>=","&=","|=","^=","&&=","||=","??="].includes(r))return{binding:o,operator:r};if(["++","--"].includes(r)&&!/[\r\n]/.test(g.slice(u[e].end,u[e+1].start)))return{binding:o,operator:r};if(e>=2&&["++","--"].includes(M(e-2))){let d=u[e-3],s=d&&(d.kind==="word"||d.kind==="quoted"||[")","]"].includes(f(e-3)));if(!d||!s||/[\r\n;]/.test(g.slice(d.end,u[e-2].start)))return{binding:o,operator:M(e-2)}}return}function ne(e){let o=P(e);return o?.operator==="="?o.binding:void 0}function te(e){if(u[e]?.kind!=="word"||f(e)!=="class"||f(e-1)==="."||["(",":","="].includes(f(e+1)))return;let o=e+1,r=0;while(o<u.length){let d=f(o);if(d==="{"&&r===0)return o;if(d==="class"){let s=te(o);if(s!==void 0){o=(b.get(s)??s)+1;continue}}if(d==="function"){let s=oe(o,u.length);if(s){o=s.end;continue}}if(d==="<")r++;else if(d===">"&&M(o-1)!=="=>"&&r>0)r--;if(d===";")break;o=(b.get(o)??o)+1}return}function ie(e,o,r){let d=e,s=!1,l=r?["public","protected","private","static","abstract","override","declare","readonly","accessor","async","get","set"]:["async","get","set"];while(l.includes(f(d))&&!["(","<","?","!",":","=",";","}"].includes(f(d+1))){if(f(d)==="static")s=!0;d++}if(f(d)==="*")d++;if(r&&f(d)==="#")d++;if(f(d)==="["){let p=b.get(d);return p===void 0?void 0:{next:p+1,isStatic:s}}if(u[d]?.kind==="word"||u[d]?.kind==="quoted")return{next:d+1,isStatic:s};let c=d+1;while(c<o&&u[c-1].end===u[c].start&&!["(","<","?","!",":","=",";","}","[","{",","].includes(f(c)))c++;if(d<o&&n(g.slice(u[d].start,u[c-1].end),!1)==="number")return{next:c,isStatic:s};return}function V(e,o,r){let d=ie(e,o,r);if(!d)return;let s=d.next;if(r&&["?","!"].includes(f(s)))s++;if(f(s)==="<"){let l=1;s++;while(s<o&&l>0){if(f(s)==="<")l++;else if(f(s)===">"&&M(s-1)!=="=>")l--;s=(b.get(s)??s)+1}if(l!==0)return}return s}function re(e,o,r){return V(e,o,r)===o}function ae(e,o){let r=0,d=-1;for(let s=e;s<o;s=(b.get(s)??s)+1)if(f(s)==="<"&&(r>0||s>e&&(u[s-1].kind==="word"||[")","]"].includes(f(s-1))))){if(r===0)d=s;r++}else if(f(s)===">"&&M(s-1)!=="=>"&&r>0){if(r--,s===o-1&&r===0)return d<s-1}return!1}function le(e,o){if(f(e)==="static"&&f(e+1)==="{")return!0;let r=V(e,o,!0);return r!==void 0&&(r===o||["(",":","=",";","}"].includes(f(r)))}function q(e,o,r=!1){let d=b.get(o)??u.length,s=e;while(s<d){if(f(s)===";"||r&&M(s)==="=")return s;if(s>e&&z.get(s)===o&&/[\r\n]/.test(g.slice(u[s-1].end,u[s].start))){let l=f(s-1),p=!(l===">"&&ae(e,s)&&le(s,d))&&["+","-","*","/","%","=","<",">","&","|","^","!","~","?",":",",",".","(","[","{","as","in","of","new","typeof","keyof","extends","instanceof","satisfies","await","yield","void"].includes(l),A=[".","?",":",")","]","}",",","+","-","*","/","%","<",">","=","&","|","^","`","(","[","as","satisfies","instanceof","in"].includes(f(s));if(!p&&!A)return s}s=(b.get(s)??s)+1}return d}function K(e,o){for(let r=e;r<o;r++){if(f(r)==="["&&b.has(r)){r=b.get(r);continue}if(u[r].kind==="word")Q.add(r)}}function ce(e){let o=b.get(e)??u.length,r=e+1;while(r<o){if(f(r)===";"){r++;continue}if(f(r)==="static"&&f(r+1)==="{"){r=(b.get(r+1)??r+1)+1;continue}let d=ie(r,o,!0);if(!d){r++;continue}let s=V(r,o,!0);if(s===void 0){r++;continue}if(K(r,s),f(s)==="("){let c=b.get(s),p=c===void 0?void 0:se(c,o);if(p!==void 0){r=(b.get(p)??p)+1;continue}}let l=s;if(f(l)===":")l=q(l+1,e,!0);if(M(l)==="="){K(r,l+1);let c=l+1,p=q(c,e);if(!d.isStatic&&p>c)Y.set(c,p);r=p}else{let c=q(s,e);K(r,c),r=Math.max(r+1,c)}}}function ue(e){let o=z.get(e);if(o===void 0)return!1;let r=N.has(o);if(!r&&!J.has(o))return!1;if(re(o+1,e,r))return!0;for(let d=o+1;d<e;d++){let s=z.get(d),l=z.get(d)===o&&(f(d)===","||r&&f(d)===";"),c=r&&f(d)==="}"&&s!==void 0&&z.get(s)===o,p=r&&z.get(d+1)===o&&/[\r\n]/.test(g.slice(u[d].end,u[d+1].start));if((l||c||p)&&re(d+1,e,r))return!0}return!1}function se(e,o){let r=e+1,d=f(r)===":"?r+1:void 0;while(r<o){if(f(r)==="{"&&(d===void 0||!Gt(g.slice(u[d].start,u[r].start))))return r;if(d===void 0)return;r=(b.get(r)??r)+1}return}function oe(e,o){let r=-1;if(f(e)==="("){let s=b.get(e);if(s!==void 0&&ue(e))r=se(s,o)??-1;else if(s!==void 0&&M(s+1)==="=>")r=s+3;else if(s!==void 0&&f(s+1)===":"){let l=s+2;while(l<o&&f(l)!==";"){if(M(l)==="=>"){r=l+2;break}l=(b.get(l)??l)+1}}}else if(u[e]?.kind==="word"&&M(e+1)==="=>")r=e+3;else if(f(e)==="function"){let s=e+1;while(s<o&&f(s)!=="(")s=(b.get(s)??s)+1;let l=b.get(s);if(l===void 0)return;r=l+1;let c=f(r)===":"?r+1:void 0;while(r<o){if(f(r)==="{"&&(c===void 0||!Gt(g.slice(u[c].start,u[r].start))))break;r=(b.get(r)??r)+1}}if(r<0||r>=o)return;if(f(r)==="{")return{start:e,end:(b.get(r)??o-1)+1};let d=r;while(d<o&&![",",";",")","]","}"].includes(f(d)))d=(b.get(d)??d)+1;return{start:e,end:d}}function x(e,o,r=!0){for(let d=e;d<o;d++){let s=Y.get(d);if(s!==void 0){d=Math.min(s,o)-1;continue}let l=r?oe(d,o):void 0;if(l){let p=l.end;while(f(p)===")")p++;if(f(p)==="("||f(p)==="."&&["call","apply"].includes(f(p+1))&&f(p+2)==="(")x(l.start,l.end,!1);d=l.end-1;continue}let c=P(d);if(c)c.binding.flow=void 0,c.binding.unresolved=!0}}function ge(e){let o=!1;while(h<u.length&&u[h].start<e){let r=f(h);if(["if","else","for","while","do","switch","try","catch","finally","with"].includes(r))o=!0;if(r===";")o=!1;if(r==="("||r==="{"||r==="["){let c=b.get(h)??h+1;while(c<u.length&&u[c].start>=e)c--;if(x(h+1,c),h=c+1,r==="{")o=!1;continue}let d=ne(h);if(d){let l=h+2,c=l,p=[];while(c<u.length&&u[c].start<e){let C=f(c);if(p.length===0&&(C===";"||c>l&&/[\r\n]/.test(g.slice(u[c-1].end,u[c].start))&&(ne(c)||["if","for","while","switch","try","do","return","throw"].includes(C))))break;if(C==="("||C==="{"||C==="[")p.push(C==="("?")":C==="{"?"}":"]");else if(C===p.at(-1))p.pop();c++}let A=c>l?g.slice(u[l].start,u[c-1].end):"";x(l,c);let O=ee(A);d.flow=!o&&O.type?d.declared?de(d.declared,O.type):O.type:void 0,d.unresolved=o||O.unresolved||!d.flow,h=c;continue}let s=P(h);if(s)s.binding.flow=void 0,s.binding.unresolved=!0;h++}}for(let e of S){ge(e.start??0);let o=h;while(h<u.length&&u[h].start<(e.end??0))h++;if(e.kind!=="variable")continue;if(e.initializerStart!==void 0){let A=o;while(A<h&&u[A].start<e.initializerStart)A++;x(A,h)}let r=y.get(e.name);if(!r.active)continue;let d=typeof e.value==="string"?e.value:"";if(!d){r.flow=r.declared;continue}let s=ee(d),l=ft(d),c=l?y.get(l):void 0,p=G.get(e);if(p)e.inferredType=p;else if(!e.typeAnnotation&&e.modifiers?.[0]==="const"&&l&&l!==e.name&&c){if(s.unresolved)e.inferenceError="DTSX_UNSUPPORTED_VALUE_FLOW";else if(s.type)e.inferredType=c.declared&&F(c.declared,s.type)?`typeof ${l}`:s.type}if(e.inferredType)e.text=`${e.isExported?"export ":""}declare ${e.modifiers?.[0]??"const"} ${e.name}: ${e.inferredType};`;if(e.typeAnnotation)r.flow=s.type?de(e.typeAnnotation,s.type)??e.typeAnnotation:e.typeAnnotation;else if(e.inferredType)r.declared=e.inferredType,r.flow=e.inferredType;else{let A=e.modifiers?.[0]==="const",O=d.trim().startsWith("{")||d.trim().startsWith("["),C=n(d,A&&!O);r.declared=C==="unknown"?void 0:C,r.flow=r.declared}r.unresolved=s.unresolved}}
3
+ export{Jn};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{T}from"./chunk-0nw1w523.js";import{Y}from"./chunk-6bmr0e81.js";import{chmod as G,lstat as P,mkdir as y,readdir as j,realpath as q,rename as D,rm as R,rmdir as L,stat as A,writeFile as W}from"fs/promises";import{basename as _,dirname as m,isAbsolute as M,parse as B,relative as F,resolve as l}from"path";function f(a,e){return a instanceof Error&&"code"in a&&a.code===e}async function w(a){try{return await P(a)}catch(e){if(f(e,"ENOENT"))return;throw e}}async function g(a){let e=l(a);try{return await q(e)}catch(n){if(!f(n,"ENOENT")||m(e)===e)throw n;return l(await g(m(e)),_(e))}}async function ne(a){let e=l(a.cwd,a.outdir);if(a.bundle&&a.bundleOutput){if(M(a.bundleOutput))throw Error("bundleOutput must be relative to outdir");if(!T(l(e,a.bundleOutput),e))throw Error("bundleOutput must stay within outdir")}if(!a.clean||a.dryRun)return;if(e===B(e).root)throw Error("Refusing to clean declarations from the filesystem root");let[n,r]=await Promise.all([g(e),g(l(a.cwd,a.root))]);if(T(r,n))throw Error("Refusing to clean an outdir that contains the source root")}function z(a){return[".d.ts",".d.mts",".d.cts",".d.ts.map",".d.mts.map",".d.cts.map"].some((e)=>a.endsWith(e))}function k(a,e){return a.dev===e.dev&&a.ino===e.ino}async function S(a,e){try{if(!(await A(a)).isDirectory())throw Error(`Declaration output parent is not a directory: ${a}`);return}catch(r){if(!f(r,"ENOENT"))throw r}let n=m(a);if(n===a)throw Error(`Cannot create declaration output directory: ${a}`);await S(n,e);try{await y(a),e.push(a)}catch(r){if(!f(r,"EEXIST")||!(await A(a)).isDirectory())throw r}}async function X(a,e,n){for(let r of(await j(a,{withFileTypes:!0})).sort((s,p)=>s.name.localeCompare(p.name))){let s=l(a,r.name);if(s===e)continue;if(r.isDirectory())await X(s,e,n);else if(z(r.name)){let p=await w(s);if(!p)throw Error(`Declaration output changed during inventory: ${s}`);n.set(s,p)}}}function O(a,e,n,r,s){return Object.assign(AggregateError(e,a),{code:"DTSX_PUBLICATION_FAILED",phase:n,recoveryDirectory:r,outputsCommitted:s})}async function $e(a,e){if(a.dryRun||e.size===0&&!a.clean)return;await ne(a);let n=l(a.cwd,a.outdir);if(e.size===0&&!await w(n))return;let r=l(n,".dtsx-publication"),s=new Map;for(let[o,c]of e){let t=l(o);if(!M(o)||t===n||!T(t,n)||T(t,r)||!z(t))throw Error(`Invalid declaration publication target: ${o}`);if(s.has(t))throw Error(`Duplicate declaration publication target: ${o}`);s.set(t,c)}let p=[],x=[],I=[],b=!1,E,d,C=!1;async function h(o,c){let t=await g(m(o));if(!T(t,c))throw Error(`Declaration publication parent escapes outdir: ${o}`);if(T(t,l(c,".dtsx-publication")))throw Error(`Declaration publication target overlaps its transaction directory: ${o}`)}async function N(){if(!b)return;if(!E)throw Error(`Cannot verify declaration publication ownership: ${r}`);let o=await w(r);if(!o||!k(o,E))throw Error(`Declaration publication ownership changed: ${r}`);if(d&&await g(r)!==l(d,".dtsx-publication"))throw Error(`Declaration publication location changed: ${r}`);await R(r,{recursive:!0})}try{await S(n,p);try{await y(r)}catch(t){if(f(t,"EEXIST"))throw Error(`Declaration publication is active or requires recovery at ${r}`,{cause:t});throw t}b=!0,E=await P(r),d=await g(n);let o=new Map;if(a.clean)await X(n,r,o);for(let t of s.keys()){await h(t,d);let i=await w(t);if(i&&!i.isFile())throw Error(`Declaration publication target is not a regular file: ${t}`);if(i)o.set(t,i)}for(let t of o.keys())await h(t,d);await y(l(r,"staged")),await y(l(r,"backups"));let c=new Map;for(let t of new Set([...o.keys(),...s.keys()])){let i=c.size.toString();c.set(t,{path:t,existing:o.get(t),backup:l(r,"backups",i),staged:s.has(t)?l(r,"staged",i):void 0})}await W(l(r,"manifest.json"),JSON.stringify({version:1,outdir:n,targets:[...c.values()].map((t)=>({path:F(n,t.path),backup:F(r,t.backup),hadPrevious:!!t.existing}))}));for(let[t,i]of s){let u=c.get(t),v=u.staged;if(await Y(v,i.content,i.lineEnding),!a.clean&&u.existing)await G(v,u.existing.mode&511);u.stagedIdentity=await P(v)}for(let t of c.values()){if(!t.existing)continue;await h(t.path,d);let i=await w(t.path);if(!i||!k(i,t.existing))throw Error(`Declaration output changed before commit: ${t.path}`);await D(t.path,t.backup),x.push(t)}for(let t of c.values()){if(!t.staged||!t.stagedIdentity)continue;if(await h(t.path,d),await S(m(t.path),p),await h(t.path,d),await w(t.path))throw Error(`Declaration output appeared during commit: ${t.path}`);await D(t.staged,t.path),I.push({path:t.path,identity:t.stagedIdentity})}C=!0;try{await N()}catch(t){throw O(`Declaration outputs committed, but transaction cleanup failed at ${r}`,[t],"finalize",r,!0)}}catch(o){if(C)throw o;let c=[];for(let i of I.toReversed())try{if(d)await h(i.path,d);let u=await w(i.path);if(!u)continue;if(!k(u,i.identity))throw Error(`Installed declaration changed before rollback: ${i.path}`);await R(i.path)}catch(u){c.push(u)}for(let i of x.toReversed())try{if(d)await h(i.path,d);if(await w(i.path))throw Error(`Cannot restore declaration over an existing path: ${i.path}`);await D(i.backup,i.path)}catch(u){c.push(u)}if(c.length>0)throw O(`Declaration rollback failed; recovery data retained at ${r}`,[o,...c],"rollback",r,!1);let t=[];try{await N()}catch(i){t.push(i)}for(let i of p.toReversed())try{await L(i)}catch(u){if(!f(u,"ENOENT")&&!f(u,"ENOTEMPTY")&&!f(u,"EEXIST"))t.push(u)}if(t.length>0)throw O(`Prior declarations retained, but publication cleanup failed at ${r}`,[o,...t],"cleanup",b?r:void 0,!1);throw o}}
3
+ export{ne,$e};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- function d(n,c){let o=1,l=1;for(let i=0;i<c;i++)if(n.charCodeAt(i)===10)o++,l=1;else l++;return{line:o,column:l}}function we(n){let c=[],o=[],l=[],i={")":"(","]":"[","}":"{"},r=0,m=0,f=-1;for(let e=0;e<n.length;e++){let t=n.charCodeAt(e),s=n.charCodeAt(e+1);if(f!==-1){if(t===42&&s===47)o.push({start:f,end:e+2}),f=-1,e++;continue}if(r){if(t===92)e++;else if(t===r)o.push({start:m,end:e+1}),r=0;continue}if(t===47&&s===42){f=e,e++;continue}if(t===47&&s===47){let u=e;while(e<n.length&&n.charCodeAt(e)!==10)e++;o.push({start:u,end:e});continue}if(t===39||t===34||t===96){r=t,m=e;continue}let a=n[e];if(a==="("||a==="["||a==="{")l.push({char:a,offset:e});else if(i[a]){let u=l.pop();if(!u||u.char!==i[a])c.push({...d(n,e),message:`Unexpected closing delimiter ${a}`,code:"DTSX1004"})}}if(r)c.push({...d(n,m),message:"Unterminated string literal",code:"DTSX1002"});if(f!==-1)c.push({...d(n,f),message:"Unterminated block comment",code:"DTSX1003"});for(let e of l)c.push({...d(n,e.offset),message:`Unclosed delimiter ${e.char}`,code:"DTSX1001"});let p=[[/\b(?:interface|class|enum)\s*(?=[{=])/g,"Declaration name expected"],[/\bfunction\s*(?=\()/g,"Function name expected"],[/\(\s*:/g,"Parameter name expected"]];for(let[e,t]of p)for(let s of n.matchAll(e)){if(o.some((a)=>s.index>=a.start&&s.index<a.end))continue;c.push({...d(n,s.index),message:t,code:"DTSX1005"})}for(let e of n.matchAll(/\btype\s*(?=[{=])/g)){if(o.some((s)=>e.index>=s.start&&e.index<s.end))continue;let t=n.slice(0,e.index).trimEnd();if(t.endsWith("import")||t.endsWith("export"))continue;c.push({...d(n,e.index),message:"Declaration name expected",code:"DTSX1005"})}return c.push(...g(n,o)),c.sort((e,t)=>e.line-t.line||e.column-t.column)}var h=String.raw`(?:[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*|'[^']*'|"[^"]*")`,x=new RegExp(`^(?:type\\s+)?${h}(?:\\s+as\\s+${h})?$`,"u");function g(n,c){let o=[],l=(i)=>c.some((r)=>i>=r.start&&i<r.end);for(let i of n.matchAll(/\b(import|export)\s+(?:type\s+)?\{/g)){let r=i.index;if(l(r))continue;let m=r+i[0].length-1,f=-1;for(let t=m+1;t<n.length;t++){if(l(t))continue;let s=n[t];if(s==="{"){f=-2;break}if(s==="}"){f=t;break}}if(f<0)continue;let p=n.slice(m+1,f);if(!p.trim())continue;let e=m+1;for(let t of p.split(",")){let s=t.trim();if(s){let a=e+t.indexOf(s);if(s.includes(";"))o.push({...d(n,a),message:`Unexpected ';' in ${i[1]} clause \u2014 specifiers are separated by ','`,code:"DTSX1006"});else if(!x.test(s))o.push({...d(n,a),message:`Invalid ${i[1]} specifier '${s}'`,code:"DTSX1006"})}e+=t.length+1}}return o}
3
- export{we};
2
+ function d(n,c){let o=1,l=1;for(let i=0;i<c;i++)if(n.charCodeAt(i)===10)o++,l=1;else l++;return{line:o,column:l}}function ke(n){let c=[],o=[],l=[],i={")":"(","]":"[","}":"{"},r=0,m=0,f=-1;for(let e=0;e<n.length;e++){let t=n.charCodeAt(e),s=n.charCodeAt(e+1);if(f!==-1){if(t===42&&s===47)o.push({start:f,end:e+2}),f=-1,e++;continue}if(r){if(t===92)e++;else if(t===r)o.push({start:m,end:e+1}),r=0;continue}if(t===47&&s===42){f=e,e++;continue}if(t===47&&s===47){let u=e;while(e<n.length&&n.charCodeAt(e)!==10)e++;o.push({start:u,end:e});continue}if(t===39||t===34||t===96){r=t,m=e;continue}let a=n[e];if(a==="("||a==="["||a==="{")l.push({char:a,offset:e});else if(i[a]){let u=l.pop();if(!u||u.char!==i[a])c.push({...d(n,e),message:`Unexpected closing delimiter ${a}`,code:"DTSX1004"})}}if(r)c.push({...d(n,m),message:"Unterminated string literal",code:"DTSX1002"});if(f!==-1)c.push({...d(n,f),message:"Unterminated block comment",code:"DTSX1003"});for(let e of l)c.push({...d(n,e.offset),message:`Unclosed delimiter ${e.char}`,code:"DTSX1001"});let p=[[/\b(?:interface|class|enum)\s*(?=[{=])/g,"Declaration name expected"],[/\bfunction\s*(?=\()/g,"Function name expected"],[/\(\s*:/g,"Parameter name expected"]];for(let[e,t]of p)for(let s of n.matchAll(e)){if(o.some((a)=>s.index>=a.start&&s.index<a.end))continue;c.push({...d(n,s.index),message:t,code:"DTSX1005"})}for(let e of n.matchAll(/\btype\s*(?=[{=])/g)){if(o.some((s)=>e.index>=s.start&&e.index<s.end))continue;let t=n.slice(0,e.index).trimEnd();if(t.endsWith("import")||t.endsWith("export"))continue;c.push({...d(n,e.index),message:"Declaration name expected",code:"DTSX1005"})}return c.push(...g(n,o)),c.sort((e,t)=>e.line-t.line||e.column-t.column)}var h=String.raw`(?:[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*|'[^']*'|"[^"]*")`,x=new RegExp(`^(?:type\\s+)?${h}(?:\\s+as\\s+${h})?$`,"u");function g(n,c){let o=[],l=(i)=>c.some((r)=>i>=r.start&&i<r.end);for(let i of n.matchAll(/\b(import|export)\s+(?:type\s+)?\{/g)){let r=i.index;if(l(r))continue;let m=r+i[0].length-1,f=-1;for(let t=m+1;t<n.length;t++){if(l(t))continue;let s=n[t];if(s==="{"){f=-2;break}if(s==="}"){f=t;break}}if(f<0)continue;let p=n.slice(m+1,f);if(!p.trim())continue;let e=m+1;for(let t of p.split(",")){let s=t.trim();if(s){let a=e+t.indexOf(s);if(s.includes(";"))o.push({...d(n,a),message:`Unexpected ';' in ${i[1]} clause \u2014 specifiers are separated by ','`,code:"DTSX1006"});else if(!x.test(s))o.push({...d(n,a),message:`Invalid ${i[1]} specifier '${s}'`,code:"DTSX1006"})}e+=t.length+1}}return o}
3
+ export{ke};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- var pi=[{pattern:/^Promise<void>$/,replacement:"Promise<void>",priority:-1},{pattern:/^Record<string,\s*any>$/,replacement:"Record<string, unknown>",priority:0},{pattern:/^Array<([^<>]+)>$/,replacement:"$1[]",priority:0}],mi=[{pattern:/\bany\b/,replacement:"unknown",global:!0,priority:10},{pattern:/^object$/,replacement:"Record<string, unknown>",priority:10},{pattern:/^Function$/,replacement:"(...args: unknown[]) => unknown",priority:10}],gi=[{pattern:/^(\w+)\[\]$/,replacement:"readonly $1[]",priority:5},{pattern:/^Array<(.+)>$/,replacement:"ReadonlyArray<$1>",priority:5},{pattern:/^Map<(.+),\s*(.+)>$/,replacement:"ReadonlyMap<$1, $2>",priority:5},{pattern:/^Set<(.+)>$/,replacement:"ReadonlySet<$1>",priority:5}],hi=[{pattern:/^Partial<Partial<(.+)>>$/,replacement:"Partial<$1>",priority:5},{pattern:/^Required<Required<(.+)>>$/,replacement:"Required<$1>",priority:5},{pattern:/^Pick<Omit<(.+),\s*(.+)>,\s*(.+)>$/,replacement:"Pick<$1, $3>",priority:5}];function yi(e){switch(e){case"strict":return mi;case"readonly":return gi;case"simplified":return hi;case"nullable":return[{pattern:/^(.+)\s*\|\s*undefined$/,replacement:"$1 | undefined",priority:5}];case"branded":return[{pattern:/^string$/,replacement:"string",condition:(r)=>r.declarationKind==="variable"&&(r.declarationName?.includes("path")??!1),priority:5}];default:return[]}}var u=/[.*+?^${}()|[\]\\]/g,c=2048;class kn{rules;compiled=[];cache=new Map;constructor(e={rules:[]}){if(this.rules=[],e.includeDefaults!==!1)this.rules.push(...pi);if(e.presets)for(let r of e.presets)this.rules.push(...yi(r));this.rules.push(...e.rules),this.rules.sort((r,t)=>(t.priority||0)-(r.priority||0)),this.recompile()}recompile(){let e=Array(this.rules.length);for(let r=0;r<this.rules.length;r++){let t=this.rules[r],i=typeof t.pattern==="string"?new RegExp(t.pattern.replace(u,"\\$&"),t.global?"g":""):t.pattern;e[r]={rule:t,regex:i}}this.compiled=e}map(e,r={}){let i=!r.declarationName&&!r.declarationKind&&!r.filePath&&!r.isReturnType&&!r.isParameterType&&!r.isPropertyType?e:`${e}\x00${r.declarationName??""}\x00${r.declarationKind??""}\x00${r.filePath??""}\x00${r.isReturnType?"r":""}${r.isParameterType?"p":""}${r.isPropertyType?"P":""}`,l=this.cache.get(i);if(l!==void 0)return l;let a=e,o=null;for(let s=0;s<this.compiled.length;s++){let{rule:p,regex:n}=this.compiled[s];if(p.condition){if(!o)o={type:e,...r};if(!p.condition(o))continue}if(n.lastIndex=0,n.test(a)){if(n.lastIndex=0,a=a.replace(n,p.replacement),n.lastIndex=0,!p.global)break}}if(this.cache.size>=c){let s=Math.ceil(c*0.1),p=0;for(let n of this.cache.keys()){if(p++>=s)break;this.cache.delete(n)}}return this.cache.set(i,a),a}mapAll(e,r={}){return e.map((t)=>this.map(t,{...r,type:t}))}addRule(e){this.rules.push(e),this.rules.sort((r,t)=>(t.priority||0)-(r.priority||0)),this.recompile(),this.cache.clear()}removeRules(e){let r=this.rules.length;return this.rules=this.rules.filter((t)=>{let i=typeof t.pattern==="string"?t.pattern:t.pattern.source;if(e instanceof RegExp)e.lastIndex=0;return typeof e==="string"?i!==e:!e.test(i)}),this.recompile(),this.cache.clear(),r-this.rules.length}clearCache(){this.cache.clear()}getRules(){return this.rules}}function Z(e={rules:[]}){return new kn(e)}var Do=Z({rules:[]}),Po=Z({rules:[],presets:["strict"]});function Tt(e,r,t={}){return e.replace(/:\s*([^;,)\]}]+)/g,(i,l)=>`: ${r.map(l.trim(),t)}`)}var Ro={makeReadonly:(e)=>{if(e.endsWith("[]"))return`readonly ${e}`;if(e.startsWith("Array<"))return e.replace("Array<","ReadonlyArray<");return e},makeNullable:(e)=>{if(e.includes("| null")||e.includes("| undefined"))return e;return`${e} | null`},makeOptional:(e)=>{if(e.includes("| undefined"))return e;return`${e} | undefined`},makeRequired:(e)=>e.replace(/\s*\|\s*null/g,"").replace(/\s*\|\s*undefined/g,"").trim(),promisify:(e)=>{if(e.startsWith("Promise<"))return e;return`Promise<${e}>`},unpromisify:(e)=>{let r=e.match(/^Promise<(.+)>$/);return r?r[1]:e},arrayify:(e)=>{if(e.endsWith("[]")||e.startsWith("Array<"))return e;return`${e}[]`},unarrayify:(e)=>{if(e.endsWith("[]"))return e.slice(0,-2);let r=e.match(/^(?:Readonly)?Array<(.+)>$/);return r?r[1]:e}};
3
- export{pi,mi,gi,hi,yi,kn,Z,Do,Po,Tt,Ro};
2
+ var bi=[{pattern:/^Promise<void>$/,replacement:"Promise<void>",priority:-1},{pattern:/^Record<string,\s*any>$/,replacement:"Record<string, unknown>",priority:0},{pattern:/^Array<([^<>]+)>$/,replacement:"$1[]",priority:0}],wi=[{pattern:/\bany\b/,replacement:"unknown",global:!0,priority:10},{pattern:/^object$/,replacement:"Record<string, unknown>",priority:10},{pattern:/^Function$/,replacement:"(...args: unknown[]) => unknown",priority:10}],xi=[{pattern:/^(\w+)\[\]$/,replacement:"readonly $1[]",priority:5},{pattern:/^Array<(.+)>$/,replacement:"ReadonlyArray<$1>",priority:5},{pattern:/^Map<(.+),\s*(.+)>$/,replacement:"ReadonlyMap<$1, $2>",priority:5},{pattern:/^Set<(.+)>$/,replacement:"ReadonlySet<$1>",priority:5}],Ci=[{pattern:/^Partial<Partial<(.+)>>$/,replacement:"Partial<$1>",priority:5},{pattern:/^Required<Required<(.+)>>$/,replacement:"Required<$1>",priority:5},{pattern:/^Pick<Omit<(.+),\s*(.+)>,\s*(.+)>$/,replacement:"Pick<$1, $3>",priority:5}];function vi(e){switch(e){case"strict":return wi;case"readonly":return xi;case"simplified":return Ci;case"nullable":return[{pattern:/^(.+)\s*\|\s*undefined$/,replacement:"$1 | undefined",priority:5}];case"branded":return[{pattern:/^string$/,replacement:"string",condition:(r)=>r.declarationKind==="variable"&&(r.declarationName?.includes("path")??!1),priority:5}];default:return[]}}var u=/[.*+?^${}()|[\]\\]/g,c=2048;class Rn{rules;compiled=[];cache=new Map;constructor(e={rules:[]}){if(this.rules=[],e.includeDefaults!==!1)this.rules.push(...bi);if(e.presets)for(let r of e.presets)this.rules.push(...vi(r));this.rules.push(...e.rules),this.rules.sort((r,t)=>(t.priority||0)-(r.priority||0)),this.recompile()}recompile(){let e=Array(this.rules.length);for(let r=0;r<this.rules.length;r++){let t=this.rules[r],i=typeof t.pattern==="string"?new RegExp(t.pattern.replace(u,"\\$&"),t.global?"g":""):t.pattern;e[r]={rule:t,regex:i}}this.compiled=e}map(e,r={}){let i=!r.declarationName&&!r.declarationKind&&!r.filePath&&!r.isReturnType&&!r.isParameterType&&!r.isPropertyType?e:`${e}\x00${r.declarationName??""}\x00${r.declarationKind??""}\x00${r.filePath??""}\x00${r.isReturnType?"r":""}${r.isParameterType?"p":""}${r.isPropertyType?"P":""}`,l=this.cache.get(i);if(l!==void 0)return l;let a=e,o=null;for(let s=0;s<this.compiled.length;s++){let{rule:p,regex:n}=this.compiled[s];if(p.condition){if(!o)o={type:e,...r};if(!p.condition(o))continue}if(n.lastIndex=0,n.test(a)){if(n.lastIndex=0,a=a.replace(n,p.replacement),n.lastIndex=0,!p.global)break}}if(this.cache.size>=c){let s=Math.ceil(c*0.1),p=0;for(let n of this.cache.keys()){if(p++>=s)break;this.cache.delete(n)}}return this.cache.set(i,a),a}mapAll(e,r={}){return e.map((t)=>this.map(t,{...r,type:t}))}addRule(e){this.rules.push(e),this.rules.sort((r,t)=>(t.priority||0)-(r.priority||0)),this.recompile(),this.cache.clear()}removeRules(e){let r=this.rules.length;return this.rules=this.rules.filter((t)=>{let i=typeof t.pattern==="string"?t.pattern:t.pattern.source;if(e instanceof RegExp)e.lastIndex=0;return typeof e==="string"?i!==e:!e.test(i)}),this.recompile(),this.cache.clear(),r-this.rules.length}clearCache(){this.cache.clear()}getRules(){return this.rules}}function ie(e={rules:[]}){return new Rn(e)}var Io=ie({rules:[]}),Lo=ie({rules:[],presets:["strict"]});function Rt(e,r,t={}){return e.replace(/:\s*([^;,)\]}]+)/g,(i,l)=>`: ${r.map(l.trim(),t)}`)}var No={makeReadonly:(e)=>{if(e.endsWith("[]"))return`readonly ${e}`;if(e.startsWith("Array<"))return e.replace("Array<","ReadonlyArray<");return e},makeNullable:(e)=>{if(e.includes("| null")||e.includes("| undefined"))return e;return`${e} | null`},makeOptional:(e)=>{if(e.includes("| undefined"))return e;return`${e} | undefined`},makeRequired:(e)=>e.replace(/\s*\|\s*null/g,"").replace(/\s*\|\s*undefined/g,"").trim(),promisify:(e)=>{if(e.startsWith("Promise<"))return e;return`Promise<${e}>`},unpromisify:(e)=>{let r=e.match(/^Promise<(.+)>$/);return r?r[1]:e},arrayify:(e)=>{if(e.endsWith("[]")||e.startsWith("Array<"))return e;return`${e}[]`},unarrayify:(e)=>{if(e.endsWith("[]"))return e.slice(0,-2);let r=e.match(/^(?:Readonly)?Array<(.+)>$/);return r?r[1]:e}};
3
+ export{bi,wi,xi,Ci,vi,Rn,ie,Io,Lo,Rt,No};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{t,d,v}from"./chunk-tsbthwf0.js";import{C}from"./chunk-xg8yhpe6.js";function q(n){return typeof n==="string"?v(n,"'"):String(n)}function va(n,y,m=new Map){let o=t(n),e=new Map(m),i=new Map,f=[],c=1,p=0,A=0;for(let r=1;r<o.length;r++){let w=o[r],K=n.slice(w.start,w.end);if(w.kind==="punctuation"&&p===0&&(K===","||K==="}")){let l=o.slice(c,r),a=l[0];if(a){let u=a.kind==="quoted"?d(n.slice(a.start,a.end)):n.slice(a.start,a.end),h=l.findIndex((g)=>g.kind==="punctuation"&&n[g.start]==="="),s=A;if(h>=0){let g=l.slice(h+1),b="",S=l[h].end;for(let x=0;x+2<g.length;x++){let[M,E,B]=g.slice(x,x+3);if(M.kind!=="word"||B.kind!=="word"||n.slice(E.start,E.end)!==".")continue;let D=e.get(`${n.slice(M.start,M.end)}.${n.slice(B.start,B.end)}`);if(D===void 0||typeof D==="object")continue;b+=n.slice(S,M.start)+q(D),S=B.end,x+=2}b+=n.slice(S,l.at(-1).end),s=C(b,e),f.push({start:l[h].start,end:l.at(-1).end,text:s===void 0?"":`= ${q(s)}`})}else if(s!==void 0)f.push({start:a.end,end:a.end,text:` = ${q(s)}`});if(A=typeof s==="number"?s+1:void 0,u!==void 0){if(e.delete(u),e.delete(`${y}.${u}`),s!==void 0)i.set(u,s),e.set(u,s),e.set(`${y}.${u}`,s)}}c=r+1}else if(w.kind==="punctuation"){if("([{".includes(K))p++;else if(")]}".includes(K))p--}}let k=n;for(let r of f.reverse())k=k.slice(0,r.start)+r.text+k.slice(r.end);return{body:k,members:i}}function Hn(n,y){let m=[...new Set([...n,...y.values()])];if(!m.some((e)=>e.kind==="enum"))return;m.sort((e,i)=>(e.start??0)-(i.start??0));let o=new Map;for(let e of m)if(e.kind==="enum"){let i=e.text.indexOf("{");if(i<0)continue;if(t(e.text.slice(0,i)).some((c)=>e.text.slice(c.start,c.end)==="declare"))continue;let f=va(e.text.slice(i),e.name,o);e.text=e.text.slice(0,i)+f.body;for(let[c,p]of f.members)o.set(`${e.name}.${c}`,p)}else if(e.kind==="variable"&&e.modifiers?.[0]==="const"&&!e.typeAnnotation&&!e.modifiers.includes("const assertion")&&typeof e.value==="string"){let i=C(e.value,o);if(i!==void 0)o.set(e.name,i)}}
3
+ export{va,Hn};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{u}from"./chunk-2h5p8n7w.js";import{e}from"./chunk-qmg1535a.js";import{v,h}from"./chunk-tsbthwf0.js";import{ce}from"./chunk-x6ddycvm.js";import{existsSync as T,readFileSync as N,realpathSync as w,statSync as q}from"fs";import{builtinModules as X}from"module";import{dirname as I,extname as F,isAbsolute as A,join as J,relative as U,resolve as O}from"path";var B=[".ts",".tsx",".mts",".cts",".vue",".stx",".js",".jsx",".mjs",".cjs",".d.ts",".d.mts",".d.cts"],V={".js":[".ts",".tsx",".d.ts"],".jsx":[".tsx",".ts",".d.ts"],".mjs":[".mts",".d.mts"],".cjs":[".cts",".d.cts"]};function k(t){try{return q(t).isFile()}catch{return!1}}function ae(t,i){let s=t.replace(/[?#].*$/,"");if(!(s.startsWith("./")||s.startsWith("../")||s==="."||s==="..")&&!A(s))return{resolved:null,isRelative:!1};let a=I(i),c=O(a,s);if(k(c))return{resolved:c,isRelative:!0};let p=F(c),d=V[p];if(d){let f=c.slice(0,-p.length);for(let r of d){let o=f+r;if(k(o))return{resolved:o,isRelative:!0}}}for(let f of B){let r=c+f;if(k(r))return{resolved:r,isRelative:!0}}if(T(c))for(let f of B){let r=J(c,`index${f}`);if(k(r))return{resolved:r,isRelative:!0}}return{resolved:null,isRelative:!0}}function C(t,i){let s=t.indexOf("*");return s===-1?i===t:i.startsWith(t.slice(0,s))&&i.endsWith(t.slice(s+1))&&i.length>=t.length-1}function K(t,i){if(Object.hasOwn(t,i))return t[i]!==null;let s=Object.keys(t).filter((l)=>l.includes("*")&&C(l,i)).sort((l,a)=>a.indexOf("*")-l.indexOf("*")||a.length-l.length)[0];return s!==void 0&&t[s]!==null}function D(t,i){if(!t.name||i!==t.name&&!i.startsWith(`${t.name}/`))return!1;if(t.exports===void 0)return!0;let s=i===t.name?".":`.${i.slice(t.name.length)}`;if(typeof t.exports==="string"||Array.isArray(t.exports))return s===".";if(!t.exports||typeof t.exports!=="object")return!1;let l=t.exports;if(!Object.keys(l).some((c)=>c.startsWith(".")))return s===".";return K(l,s)}function W(t,i){let s=U(t,i);return s!==".."&&!s.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!A(s)}async function Oe(t){let i=await ce(O(t.cwd,t.tsconfigPath||"tsconfig.json")),s=Object.entries(i?.paths??{});if(s.length===0){let r=(o,n)=>ae(o,n);return r.cacheKey=(o)=>JSON.stringify(o.map((n)=>({file:n,references:P(N(n,"utf8"),{includeImports:!0}).map((g)=>({specifier:g.specifier,resolution:r(g.specifier,n)}))}))),r}let l=i?.baseUrl??i?.pathsBasePath??t.cwd,a=O(t.cwd,t.root),c=new Map,p=new Set([...X,"bun"]),d=(r)=>{let o=I(r),n=[];while(!0){if(c.has(o)){let x=c.get(o);for(let b of n)c.set(b,x);return x}n.push(o);let g=J(o,"package.json");if(T(g)){let b={...JSON.parse(N(g,"utf8")),directory:w(o)};for(let E of n)c.set(E,b);return b}let m=I(o);if(m===o)return;o=m}},f=(r,o)=>{if(r.startsWith(".")||A(r))return ae(r,o);if(r.startsWith("node:")||r.startsWith("bun:")||p.has(r))return{resolved:null,isRelative:!1};let n=d(o),g=r.startsWith("@")?/^@[^/]+\/[^/]+/.exec(r)?.[0]:r.split("/")[0];if(n&&(D(n,r)||K(n.imports??{},r)||g&&[n.dependencies,n.devDependencies,n.peerDependencies,n.optionalDependencies].some((R)=>Object.hasOwn(R??{},g))))return{resolved:null,isRelative:!1};let m=s.filter(([R])=>C(R,r)).sort(([R],[S])=>{if(!R.includes("*"))return-1;if(!S.includes("*"))return 1;return S.indexOf("*")-R.indexOf("*")})[0];if(!m)return{resolved:null,isRelative:!1};let[x,b]=m,E=x.indexOf("*"),L=E===-1?"":r.slice(E,r.length-(x.length-E-1));for(let R of b){let S=O(l,R.replace("*",L)),M=d(S);if(M&&D(M,r)&&!M.private&&M.directory!==n?.directory)return{resolved:null,isRelative:!1};let j=ae(S,o);if(!j.resolved)continue;let y=w(j.resolved),_=t.outputStructure==="flat"||T(a)&&W(w(a),y);if(!n||!W(n.directory,y)||!_||d(y)?.directory!==n.directory||/\.d\.(?:ts|mts|cts)$/.test(y))throw Error(`Local alias ${JSON.stringify(r)} from ${o} resolves outside its emitted package source: ${y}`);return e.debug(`Resolved local declaration alias ${r} from ${o} to ${y}`),{resolved:t.outputStructure==="flat"?j.resolved:O(a,U(w(a),y)),isRelative:!0,isAlias:!0,suffix:S.match(/[?#].*$/)?.[0]??""}}throw Error(`Cannot resolve local alias ${JSON.stringify(r)} from ${o} using ${t.tsconfigPath||"tsconfig.json"} (${JSON.stringify(x)})`)};return f.isPackageLocal=(r,o)=>{let n=d(r);return!!n&&d(o)?.directory===n.directory&&W(n.directory,w(o))},f.cacheKey=(r)=>{let o=r.map((g)=>({file:g,references:P(N(g,"utf8"),{includeImports:!0}).map((m)=>({specifier:m.specifier,resolution:f(m.specifier,g)}))})),n=[...new Set(c.values())].filter((g)=>g!==void 0).sort((g,m)=>g.directory.localeCompare(m.directory));return JSON.stringify({root:a,compilerOptions:i,packages:n,edges:o})},f}function P(t,i={}){let s=h(t);return(i.includeImports?["export","static-import","import-type","augmentation"]:["export"]).flatMap((a)=>s.filter((c)=>c.category===a).map(({specifier:c,kind:p,isTypeOnly:d})=>({specifier:c,kind:p,isTypeOnly:d})))}function Fn(t,i){let s=[];for(let a of h(t)){let c=i(a.specifier);if(c!==a.specifier)s.push({start:a.start,end:a.end,value:v(c,t[a.start])})}let l=t;for(let a of s.reverse())l=l.slice(0,a.start)+a.value+l.slice(a.end);return l}async function Z(t,i={}){let s=new Set,l=new Map,a=[],c=new Map,p=[];for(let d of t){let f=O(d);if(!s.has(f))s.add(f),p.push(f)}while(p.length>0){let d=p.shift(),f;try{f=await u(d)}catch{continue}c.set(d,f);let r=P(f,i);l.set(d,r);for(let o of r){let n=(i.resolveSpecifier??ae)(o.specifier,d);if(!n.isRelative)continue;if(n.resolved){if(!s.has(n.resolved))s.add(n.resolved),p.push(n.resolved)}else a.push({from:d,specifier:o.specifier,isTypeOnly:o.isTypeOnly})}}return{reachable:s,reExports:l,unresolved:a,sources:c}}
3
+ export{ae,Oe,P,Fn,Z};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- function Hs(e,i){return e.getText?.()??i.slice(e.pos??0,e.end??i.length)}function Ks(e){return e.getFullText?.().match(/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g)??[]}function cn(e){let i=e,s=!0;while(s){s=!1;let n=i.trimStart();if(n.startsWith("/*")){let r=n.indexOf("*/",2);if(r!==-1){i=n.slice(r+2),s=!0;continue}}if(n.startsWith("//")){let r=n.indexOf(`
3
- `);if(r!==-1)i=n.slice(r+1),s=!0;else i="",s=!0}}return i.trim()}function qs(e,i){let n=e.substring(0,i).split(`
4
- `),r=[],t=n.length-1,u=!1,a=[];while(t>=0){let l=n[t].trim();if(l.endsWith("*/")&&!u)u=!0,a.unshift(l);else if(l.startsWith("/*")&&u)a.unshift(l),r.unshift(...a),a=[],u=!1;else if(u)a.unshift(l);else if(l.startsWith("//"))r.unshift(l);else if(l.startsWith("*")&&(t>0&&n[t-1].trim().startsWith("/*")))r.unshift(l);else if(l===""&&r.length>0);else if(l!=="")break;t--}return r}function Js(e){let i=!1,s="",n=!1;for(let r=0;r<e.length;r++){let t=e[r];if(!n&&!i&&(t==='"'||t==="'"||t==="`"))i=!0,s=t;else if(!n&&i&&t===s)i=!1;else if(t==="\\"&&!n){n=!0;continue}else if(!i&&t==="/"&&r<e.length-1){if(e[r+1]==="/")return e.substring(r)}n=!1}return null}function ln(e,i,s){let n=0,r=!1,t="",u=!1;if(!e.startsWith(i))return null;for(let a=0;a<e.length;a++){let l=e[a];if(!u&&(l==='"'||l==="'"||l==="`")){if(!r)r=!0,t=l;else if(l===t)r=!1}if(l==="\\"&&!u){u=!0;continue}if(u=!1,!r){if(e.substring(a,a+i.length)===i)n++;else if(e.substring(a,a+s.length)===s){if(n--,n===0)return{content:e.substring(0,a+s.length),rest:e.substring(a+s.length)}}}}return null}function Ys(e){let i=cn(e).trim(),s=i.match(/^(export\s+)?(async\s+)?function\s*(\*?)([a-zA-Z_$][\w$]*)/);if(!s)return null;let n=[];if(s[1])n.push("export");if(s[2])n.push("async");if(s[3])n.push("generator");let r=s[4],t=i.substring(s[0].length).trim(),u="";if(t.startsWith("<")){let o=ln(t,"<",">");if(o)u=o.content,t=o.rest.trim()}let a="";if(t.startsWith("(")){let o=ln(t,"(",")");if(o)a=o.content.slice(1,-1).trim(),t=o.rest.trim()}let l="void";if(t.startsWith(":")){let o=t.match(/^:\s*([^{;]+)/);if(o)l=o[1].trim()}return{name:r,generics:u,parameters:a,returnType:l,modifiers:n}}function Xs(e){return/^\s*export\s+/.test(e)}function Zs(e){return/^\s*export\s+type\s+/.test(e)}function Qs(e){let i=cn(e).trim(),s=i.match(/^(export\s+)?(const|let|var)\s+([a-zA-Z_$][\w$]*)/);if(!s)return null;let n=s[2],r=s[3],t=i.substring(s[0].length).trim(),u;if(t.startsWith(":")){let l=t.indexOf("=");if(l!==-1)u=t.substring(1,l).trim(),t=t.substring(l).trim();else u=t.substring(1).replace(/;?\s*$/,"").trim(),t=""}let a;if(t.startsWith("="))a=t.substring(1).replace(/;?\s*$/,"").trim();return{kind:n,name:r,typeAnnotation:u,value:a}}
5
- export{Hs,Ks,cn,qs,Js,ln,Ys,Xs,Zs,Qs};
2
+ function Xs(e,i){return e.getText?.()??i.slice(e.pos??0,e.end??i.length)}function Zs(e){return e.getFullText?.().match(/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g)??[]}function pn(e){let i=e,s=!0;while(s){s=!1;let n=i.trimStart();if(n.startsWith("/*")){let r=n.indexOf("*/",2);if(r!==-1){i=n.slice(r+2),s=!0;continue}}if(n.startsWith("//")){let r=n.indexOf(`
3
+ `);if(r!==-1)i=n.slice(r+1),s=!0;else i="",s=!0}}return i.trim()}function Qs(e,i){let n=e.substring(0,i).split(`
4
+ `),r=[],t=n.length-1,u=!1,a=[];while(t>=0){let l=n[t].trim();if(l.endsWith("*/")&&!u)u=!0,a.unshift(l);else if(l.startsWith("/*")&&u)a.unshift(l),r.unshift(...a),a=[],u=!1;else if(u)a.unshift(l);else if(l.startsWith("//"))r.unshift(l);else if(l.startsWith("*")&&(t>0&&n[t-1].trim().startsWith("/*")))r.unshift(l);else if(l===""&&r.length>0);else if(l!=="")break;t--}return r}function eo(e){let i=!1,s="",n=!1;for(let r=0;r<e.length;r++){let t=e[r];if(!n&&!i&&(t==='"'||t==="'"||t==="`"))i=!0,s=t;else if(!n&&i&&t===s)i=!1;else if(t==="\\"&&!n){n=!0;continue}else if(!i&&t==="/"&&r<e.length-1){if(e[r+1]==="/")return e.substring(r)}n=!1}return null}function mn(e,i,s){let n=0,r=!1,t="",u=!1;if(!e.startsWith(i))return null;for(let a=0;a<e.length;a++){let l=e[a];if(!u&&(l==='"'||l==="'"||l==="`")){if(!r)r=!0,t=l;else if(l===t)r=!1}if(l==="\\"&&!u){u=!0;continue}if(u=!1,!r){if(e.substring(a,a+i.length)===i)n++;else if(e.substring(a,a+s.length)===s){if(n--,n===0)return{content:e.substring(0,a+s.length),rest:e.substring(a+s.length)}}}}return null}function to(e){let i=pn(e).trim(),s=i.match(/^(export\s+)?(async\s+)?function\s*(\*?)([a-zA-Z_$][\w$]*)/);if(!s)return null;let n=[];if(s[1])n.push("export");if(s[2])n.push("async");if(s[3])n.push("generator");let r=s[4],t=i.substring(s[0].length).trim(),u="";if(t.startsWith("<")){let o=mn(t,"<",">");if(o)u=o.content,t=o.rest.trim()}let a="";if(t.startsWith("(")){let o=mn(t,"(",")");if(o)a=o.content.slice(1,-1).trim(),t=o.rest.trim()}let l="void";if(t.startsWith(":")){let o=t.match(/^:\s*([^{;]+)/);if(o)l=o[1].trim()}return{name:r,generics:u,parameters:a,returnType:l,modifiers:n}}function no(e){return/^\s*export\s+/.test(e)}function ro(e){return/^\s*export\s+type\s+/.test(e)}function io(e){let i=pn(e).trim(),s=i.match(/^(export\s+)?(const|let|var)\s+([a-zA-Z_$][\w$]*)/);if(!s)return null;let n=s[2],r=s[3],t=i.substring(s[0].length).trim(),u;if(t.startsWith(":")){let l=t.indexOf("=");if(l!==-1)u=t.substring(1,l).trim(),t=t.substring(l).trim();else u=t.substring(1).replace(/;?\s*$/,"").trim(),t=""}let a;if(t.startsWith("="))a=t.substring(1).replace(/;?\s*$/,"").trim();return{kind:n,name:r,typeAnnotation:u,value:a}}
5
+ export{Xs,Zs,pn,Qs,eo,mn,to,no,ro,io};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- class Kt{config;types=new Map;imports=new Map;relationships=[];usageMap=new Map;constructor(e={}){this.config={types:!1,relationships:!1,usage:!1,imports:!1,importUsage:!1,importRelationships:!1,...e}}trackType(e,s){if(!this.config.types)return;if(["interface","type","class","enum"].includes(e.kind)){if(this.types.get(e.name))return;let i={name:e.name,kind:e.kind,file:s,usedBy:new Set,references:new Set,extendsFrom:e.extends?[e.extends]:void 0,implementsFrom:e.implements};if(this.types.set(e.name,i),this.config.relationships){if(e.extends)this.relationships.push({from:e.name,to:e.extends,kind:"extends",file:s});if(e.implements)for(let n of e.implements)this.relationships.push({from:e.name,to:n,kind:"implements",file:s})}}}trackTypeUsage(e,s,t){if(!this.config.usage)return;let i=this.types.get(e);if(i)i.usedBy.add(s);let n=this.usageMap.get(e)||new Set;if(n.add(`${t}:${s}`),this.usageMap.set(e,n),this.config.relationships)this.relationships.push({from:s,to:e,kind:"uses",file:t})}trackImport(e,s,t,i){if(!this.config.imports)return;let n={source:e,specifiers:s,isTypeOnly:t,file:i,usedSpecifiers:new Set,unusedSpecifiers:new Set(s)},r=this.imports.get(i)||[];r.push(n),this.imports.set(i,r)}trackImportUsage(e,s){if(!this.config.importUsage)return;let t=this.imports.get(s);if(!t)return;for(let i of t)if(i.specifiers.includes(e))i.usedSpecifiers.add(e),i.unusedSpecifiers.delete(e)}trackTypeReference(e,s){if(!this.config.types)return;let t=this.types.get(e);if(t)t.references.add(s)}getResults(){let e=[],s=[];for(let[n,r]of this.types)if(r.usedBy.size===0&&r.references.size===0)e.push(n);for(let n of this.imports.values())for(let r of n)if(r.unusedSpecifiers.size===r.specifiers.length)s.push(r);let t=this.detectCircularReferences(),i={totalTypes:this.types.size,usedTypes:this.types.size-e.length,unusedTypes:e.length,totalImports:Array.from(this.imports.values()).flat().length,usedImports:Array.from(this.imports.values()).flat().filter((n)=>n.usedSpecifiers.size>0).length,unusedImports:s.length,totalRelationships:this.relationships.length,circularDependencies:t.length};return{types:this.types,imports:this.imports,relationships:this.relationships,unusedTypes:e,unusedImports:s,circularReferences:t,statistics:i}}detectCircularReferences(){let e=[],s=new Set,t=[],i=(n)=>{if(t.includes(n)){let o=t.indexOf(n);e.push(t.slice(o));return}if(s.has(n))return;s.add(n),t.push(n);let r=this.relationships.filter((o)=>o.from===n&&(o.kind==="extends"||o.kind==="implements"||o.kind==="references")).map((o)=>o.to);for(let o of r)i(o);t.pop()};for(let n of this.types.keys())i(n);return e}clear(){this.types.clear(),this.imports.clear(),this.relationships=[],this.usageMap.clear()}formatResults(){let e=this.getResults(),s=["=== Tracking Results ===",""];if(s.push("Statistics:"),s.push(` Total types: ${e.statistics.totalTypes}`),s.push(` Used types: ${e.statistics.usedTypes}`),s.push(` Unused types: ${e.statistics.unusedTypes}`),s.push(` Total imports: ${e.statistics.totalImports}`),s.push(` Used imports: ${e.statistics.usedImports}`),s.push(` Unused imports: ${e.statistics.unusedImports}`),s.push(` Type relationships: ${e.statistics.totalRelationships}`),s.push(` Circular dependencies: ${e.statistics.circularDependencies}`),s.push(""),e.unusedTypes.length>0){s.push("Unused types:");for(let t of e.unusedTypes){let i=e.types.get(t);s.push(` - ${t} (${i?.kind}) in ${i?.file}`)}s.push("")}if(e.unusedImports.length>0){s.push("Unused imports:");for(let t of e.unusedImports)s.push(` - ${t.source} in ${t.file}`),s.push(` Specifiers: ${Array.from(t.unusedSpecifiers).join(", ")}`);s.push("")}if(e.circularReferences.length>0){s.push("Circular references:");for(let t of e.circularReferences)s.push(` - ${t.join(" -> ")} -> ${t[0]}`);s.push("")}return s.join(`
3
- `)}}function qt(e){return new Kt(e)}function Jt(e,s,t){for(let i of e){if(t.trackType(i,s),i.typeAnnotation){let n=p(i.typeAnnotation);for(let r of n)t.trackTypeUsage(r,i.name,s)}if(i.extends)t.trackTypeUsage(i.extends,i.name,s);if(i.implements)for(let n of i.implements)t.trackTypeUsage(n,i.name,s);if(i.kind==="import"&&i.source&&i.specifiers)t.trackImport(i.source,i.specifiers.map((n)=>n.name),i.isTypeOnly||!1,s)}}function p(e){let s=[],t=new Set(["string","number","boolean","any","unknown","void","never","null","undefined","object","symbol","bigint","true","false","readonly","keyof","typeof","infer","extends","in","out"]),i=/\b([A-Z]\w*)\b/g,n;while((n=i.exec(e))!==null){let r=n[1];if(!t.has(r.toLowerCase())&&!s.includes(r))s.push(r)}return s}function us(e,s){let t=qt({imports:!0,importUsage:!0,importRelationships:!0,...s});for(let[i,n]of e)Jt(n,i,t);return t.getResults()}function fs(e,s){let t=qt({types:!0,relationships:!0,usage:!0,...s});for(let[i,n]of e)Jt(n,i,t);return t.getResults()}
4
- export{Kt,qt,Jt,us,fs};
2
+ class Yt{config;types=new Map;imports=new Map;relationships=[];usageMap=new Map;constructor(e={}){this.config={types:!1,relationships:!1,usage:!1,imports:!1,importUsage:!1,importRelationships:!1,...e}}trackType(e,s){if(!this.config.types)return;if(["interface","type","class","enum"].includes(e.kind)){if(this.types.get(e.name))return;let i={name:e.name,kind:e.kind,file:s,usedBy:new Set,references:new Set,extendsFrom:e.extends?[e.extends]:void 0,implementsFrom:e.implements};if(this.types.set(e.name,i),this.config.relationships){if(e.extends)this.relationships.push({from:e.name,to:e.extends,kind:"extends",file:s});if(e.implements)for(let n of e.implements)this.relationships.push({from:e.name,to:n,kind:"implements",file:s})}}}trackTypeUsage(e,s,t){if(!this.config.usage)return;let i=this.types.get(e);if(i)i.usedBy.add(s);let n=this.usageMap.get(e)||new Set;if(n.add(`${t}:${s}`),this.usageMap.set(e,n),this.config.relationships)this.relationships.push({from:s,to:e,kind:"uses",file:t})}trackImport(e,s,t,i){if(!this.config.imports)return;let n={source:e,specifiers:s,isTypeOnly:t,file:i,usedSpecifiers:new Set,unusedSpecifiers:new Set(s)},r=this.imports.get(i)||[];r.push(n),this.imports.set(i,r)}trackImportUsage(e,s){if(!this.config.importUsage)return;let t=this.imports.get(s);if(!t)return;for(let i of t)if(i.specifiers.includes(e))i.usedSpecifiers.add(e),i.unusedSpecifiers.delete(e)}trackTypeReference(e,s){if(!this.config.types)return;let t=this.types.get(e);if(t)t.references.add(s)}getResults(){let e=[],s=[];for(let[n,r]of this.types)if(r.usedBy.size===0&&r.references.size===0)e.push(n);for(let n of this.imports.values())for(let r of n)if(r.unusedSpecifiers.size===r.specifiers.length)s.push(r);let t=this.detectCircularReferences(),i={totalTypes:this.types.size,usedTypes:this.types.size-e.length,unusedTypes:e.length,totalImports:Array.from(this.imports.values()).flat().length,usedImports:Array.from(this.imports.values()).flat().filter((n)=>n.usedSpecifiers.size>0).length,unusedImports:s.length,totalRelationships:this.relationships.length,circularDependencies:t.length};return{types:this.types,imports:this.imports,relationships:this.relationships,unusedTypes:e,unusedImports:s,circularReferences:t,statistics:i}}detectCircularReferences(){let e=[],s=new Set,t=[],i=(n)=>{if(t.includes(n)){let o=t.indexOf(n);e.push(t.slice(o));return}if(s.has(n))return;s.add(n),t.push(n);let r=this.relationships.filter((o)=>o.from===n&&(o.kind==="extends"||o.kind==="implements"||o.kind==="references")).map((o)=>o.to);for(let o of r)i(o);t.pop()};for(let n of this.types.keys())i(n);return e}clear(){this.types.clear(),this.imports.clear(),this.relationships=[],this.usageMap.clear()}formatResults(){let e=this.getResults(),s=["=== Tracking Results ===",""];if(s.push("Statistics:"),s.push(` Total types: ${e.statistics.totalTypes}`),s.push(` Used types: ${e.statistics.usedTypes}`),s.push(` Unused types: ${e.statistics.unusedTypes}`),s.push(` Total imports: ${e.statistics.totalImports}`),s.push(` Used imports: ${e.statistics.usedImports}`),s.push(` Unused imports: ${e.statistics.unusedImports}`),s.push(` Type relationships: ${e.statistics.totalRelationships}`),s.push(` Circular dependencies: ${e.statistics.circularDependencies}`),s.push(""),e.unusedTypes.length>0){s.push("Unused types:");for(let t of e.unusedTypes){let i=e.types.get(t);s.push(` - ${t} (${i?.kind}) in ${i?.file}`)}s.push("")}if(e.unusedImports.length>0){s.push("Unused imports:");for(let t of e.unusedImports)s.push(` - ${t.source} in ${t.file}`),s.push(` Specifiers: ${Array.from(t.unusedSpecifiers).join(", ")}`);s.push("")}if(e.circularReferences.length>0){s.push("Circular references:");for(let t of e.circularReferences)s.push(` - ${t.join(" -> ")} -> ${t[0]}`);s.push("")}return s.join(`
3
+ `)}}function Xt(e){return new Yt(e)}function Zt(e,s,t){for(let i of e){if(t.trackType(i,s),i.typeAnnotation){let n=p(i.typeAnnotation);for(let r of n)t.trackTypeUsage(r,i.name,s)}if(i.extends)t.trackTypeUsage(i.extends,i.name,s);if(i.implements)for(let n of i.implements)t.trackTypeUsage(n,i.name,s);if(i.kind==="import"&&i.source&&i.specifiers)t.trackImport(i.source,i.specifiers.map((n)=>n.name),i.isTypeOnly||!1,s)}}function p(e){let s=[],t=new Set(["string","number","boolean","any","unknown","void","never","null","undefined","object","symbol","bigint","true","false","readonly","keyof","typeof","infer","extends","in","out"]),i=/\b([A-Z]\w*)\b/g,n;while((n=i.exec(e))!==null){let r=n[1];if(!t.has(r.toLowerCase())&&!s.includes(r))s.push(r)}return s}function is(e,s){let t=Xt({imports:!0,importUsage:!0,importRelationships:!0,...s});for(let[i,n]of e)Zt(n,i,t);return t.getResults()}function ss(e,s){let t=Xt({types:!0,relationships:!0,usage:!0,...s});for(let[i,n]of e)Zt(n,i,t);return t.getResults()}
4
+ export{Yt,Xt,Zt,is,ss};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{Ve}from"./chunk-wrjrwren.js";import{D}from"./chunk-kcbbz8t7.js";import{x}from"./chunk-k75z3nef.js";function In(i,r){let n=new Set;for(let e of D(i,"imports.ts",!1)){if(e.kind!=="import")continue;let t=x(e.text),a=t&&r.get(t.source);if(!t||t.isTypeOnly||!a)continue;let s=rt(a);for(let o of t.namedItems)if(!o.isTypeOnly&&s.some((m)=>m.name===o.originalName))n.add(o.name);if(t.defaultName&&s.some((o)=>o.isDefault))n.add(t.defaultName)}return n}function rt(i){let r=D(i,"dependency.ts",!1).filter((n)=>n.kind==="function");return r.filter((n)=>n.isExported&&!n.generics&&r.filter((e)=>e.name===n.name).length===1&&Ve(i,n.name)===1).map((n)=>({name:n.name,isDefault:Boolean(n.isDefault)})).sort((n,e)=>n.name.localeCompare(e.name))}
3
+ export{In,rt};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{t,v,Ue,h}from"./chunk-tsbthwf0.js";import{Xn,Zn}from"./chunk-013mp499.js";function q(n){return h(n).find((e)=>e.category==="static-import")}function C(n){return t(n).map((e)=>n.slice(e.start,e.end)).join(" ")}function S(n){let e=q(n);return e?n.lastIndexOf(" from ",e.start):-1}function Fe(n){let e=q(n);return e?v(e.specifier,"'"):void 0}function Yn(n){let e=x(n);if(!e)return null;return{defaultName:e.defaultName??e.namespaceName,namedItems:e.namedItems.map((r)=>`${!e.isTypeOnly&&r.isTypeOnly?"type ":""}${r.originalName===r.name?r.name:`${r.originalName} as ${r.name}`}`),source:e.source,isTypeOnly:e.isTypeOnly,isNamespace:e.isNamespace,namespaceName:e.namespaceName,isImportEquals:e.isImportEquals}}function w(n){let e=Xn(n);if(e)return e;let r=x(n),u=r?[r.defaultName,r.namespaceName,...r.namedItems.map((a)=>a.name)].filter((a)=>a!==null):[];return Zn(n,u),u}function W(n){let e=[],r=0;for(let a of t(n)){if(a.kind!=="punctuation"||n.slice(a.start,a.end)!==",")continue;let s=n.slice(r,a.start).trim();if(s)e.push(s);r=a.end}let u=n.slice(r).trim();if(u)e.push(u);return e}function x(n){n=C(n);let e=Ue(n);if(e)return{defaultName:e.name,namedItems:[],source:e.source,isTypeOnly:e.isTypeOnly,isNamespace:!1,namespaceName:null,isImportEquals:!0};let r=S(n);if(r===-1)return null;let u=q(n);if(!u)return null;let a=u.specifier,s=n.slice(0,r).trim(),p=u.isTypeOnly;if(s.startsWith("import "))s=s.slice(7).trim();if(p&&s.startsWith("type "))s=s.slice(5).trim();let f=null,o=[],i=!1,m=null,c=s.includes("{")?-1:s.indexOf("* as ");if(c!==-1)return i=!0,m=s.slice(c+5).trim(),f=s.slice(0,c).trim().replace(/,$/,"").trim()||null,{defaultName:f,namedItems:[],source:a,isTypeOnly:p,isNamespace:i,namespaceName:m};let l=s.indexOf("{"),d=s.lastIndexOf("}");if(l!==-1&&d!==-1){let g=s.slice(0,l).trim();if(g.endsWith(","))f=g.slice(0,-1).trim()||null;let I=s.slice(l+1,d),D=W(I);for(let N of D){let T=Ii(N),y=T?N.slice(5).trim():N,O=y.lastIndexOf(" as "),b,E;if(O!==-1)E=y.slice(0,O).trim(),b=y.slice(O+4).trim();else b=y,E=y;o.push({name:b,originalName:E,isTypeOnly:p||T,isDefault:!1})}}else f=s.trim()||null;return{defaultName:f,namedItems:o,source:a,isTypeOnly:p,isNamespace:i,namespaceName:m}}function Wa(n){let e=n.trim();if(e.startsWith("export default "))return{namedItems:[],source:null,isTypeOnly:!1,isNamespace:!1,isDefault:!0};let r=e.startsWith("export type ");if(e.startsWith("export "))e=e.slice(7).trim();if(r&&e.startsWith("type "))e=e.slice(5).trim();if(e.startsWith("* from ")||e.startsWith("* as ")){let m=e.indexOf(" from "),c=null;if(m!==-1){let l=e.slice(m+6).trim(),d=l[0];if(d==='"'||d==="'"){let g=l.indexOf(d,1);if(g!==-1)c=l.slice(1,g)}}return{namedItems:[],source:c,isTypeOnly:r,isNamespace:!0,isDefault:!1}}let u=e.indexOf("{"),a=e.lastIndexOf("}");if(u===-1||a===-1)return null;let s=null,p=e.indexOf(" from ",a);if(p!==-1){let m=e.slice(p+6).trim(),c=m[0];if(c==='"'||c==="'"){let l=m.indexOf(c,1);if(l!==-1)s=m.slice(1,l)}}let f=[],o=e.slice(u+1,a),i=[];{let m=0;for(let c=0;c<=o.length;c++)if(c===o.length||o.charCodeAt(c)===44){let l=m,d=c;while(l<d&&o.charCodeAt(l)<=32)l++;while(d>l&&o.charCodeAt(d-1)<=32)d--;if(l<d)i.push(o.slice(l,d));m=c+1}}for(let m of i){let c=Ii(m),l=c?m.slice(5).trim():m,d=l.lastIndexOf(" as "),g,I;if(d!==-1)I=l.slice(0,d).trim(),g=l.slice(d+4).trim();else g=l,I=l;f.push({name:g,originalName:I,isTypeOnly:r||c,isDefault:!1})}return{namedItems:f,source:s,isTypeOnly:r,isNamespace:!1,isDefault:!1}}function Ii(n){let e=t(n),r=e[0];if(!r||r.kind!=="word"||n.slice(r.start,r.end)!=="type"||e.length<2)return!1;return!(e.length===3&&n.slice(e[1].start,e[1].end)==="as")}function _a(n){let e=x(n);if(!e||e.isTypeOnly||e.isImportEquals)return n;if(e.namedItems.every((r)=>r.isTypeOnly))return n.replace(/^import\s+/,"import type ");return n}function ja(n){let e=new Map,r=[];for(let a of n){let s=x(a);if(!s)continue;if(s.isImportEquals||s.isNamespace){r.push(a);continue}let p=Fe(a);if(!p)throw Error("Cannot locate a grammatical module literal in the import declaration");let f=e.get(s.source)||{types:[],values:[],defaultName:null,sourceLiteral:p};if(s.defaultName)f.defaultName=s.defaultName;for(let o of s.namedItems)if(o.isTypeOnly)f.types.push(o);else f.values.push(o);e.set(s.source,f)}let u=r;for(let{types:a,values:s,defaultName:p,sourceLiteral:f}of e.values())if(a.length===0&&s.length===0&&p)u.push(`import ${p} from ${f};`);else if(a.length>0&&s.length===0&&!p){let o=a.map((i)=>i.originalName===i.name?i.name:`${i.originalName} as ${i.name}`);u.push(`import type { ${o.join(", ")} } from ${f};`)}else if(s.length>0&&a.length===0&&!p){let o=s.map((i)=>i.originalName===i.name?i.name:`${i.originalName} as ${i.name}`);u.push(`import { ${o.join(", ")} } from ${f};`)}else{let o=[];for(let i of a){let m=i.originalName===i.name?i.name:`${i.originalName} as ${i.name}`;o.push(`type ${m}`)}for(let i of s){let m=i.originalName===i.name?i.name:`${i.originalName} as ${i.name}`;o.push(m)}if(p)u.push(`import ${p}, { ${o.join(", ")} } from ${f};`);else u.push(`import { ${o.join(", ")} } from ${f};`)}return u}
3
+ export{Fe,Yn,w,x,Wa,Ii,_a,ja};