@dtsx/dtsx 0.0.0-stage → 0.11.37

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 (276) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +442 -2
  3. package/dist/bin/cli.d.ts +1 -0
  4. package/dist/bin/cli.js +12 -0
  5. package/dist/chunk-0azm93j9.js +31 -0
  6. package/dist/chunk-0ke9xh7t.js +4 -0
  7. package/dist/chunk-1bpv3tck.js +10 -0
  8. package/dist/chunk-1e10w914.js +18 -0
  9. package/dist/chunk-1h6ycqza.js +6 -0
  10. package/dist/chunk-1j6092xz.js +7 -0
  11. package/dist/chunk-1pz7zxhc.js +3 -0
  12. package/dist/chunk-25vyhfzh.js +3 -0
  13. package/dist/chunk-2kwjbk55.js +3 -0
  14. package/dist/chunk-437g8zz6.js +177 -0
  15. package/dist/chunk-4f2mwn7p.js +5 -0
  16. package/dist/chunk-5hyv43ps.js +12 -0
  17. package/dist/chunk-5n0tfrpc.js +6 -0
  18. package/dist/chunk-60ssvwc8.js +4 -0
  19. package/dist/chunk-69dbf6de.js +3 -0
  20. package/dist/chunk-7610h2tf.js +3 -0
  21. package/dist/chunk-79nv7twc.js +14 -0
  22. package/dist/chunk-853ftm92.js +8 -0
  23. package/dist/chunk-90aptjh6.js +24 -0
  24. package/dist/chunk-acyj1dev.js +18 -0
  25. package/dist/chunk-asws39qs.js +31 -0
  26. package/dist/chunk-aw48mk3t.js +3 -0
  27. package/dist/chunk-bdxq6500.js +4 -0
  28. package/dist/chunk-bqabznps.js +7 -0
  29. package/dist/chunk-cen2t56g.js +3 -0
  30. package/dist/chunk-ckq8g1ck.js +4 -0
  31. package/dist/chunk-cs4gwz1k.js +27 -0
  32. package/dist/chunk-d43bpfk6.js +3 -0
  33. package/dist/chunk-dfye109x.js +3 -0
  34. package/dist/chunk-dv5hhg1a.js +3 -0
  35. package/dist/chunk-ezbp8tss.js +10 -0
  36. package/dist/chunk-fgbdm1y6.js +6 -0
  37. package/dist/chunk-fy97syc2.js +3 -0
  38. package/dist/chunk-g9d5r6a8.js +3 -0
  39. package/dist/chunk-ggbahdr2.js +4 -0
  40. package/dist/chunk-gpq2kggq.js +3 -0
  41. package/dist/chunk-gs7wfk8b.js +2 -0
  42. package/dist/chunk-gsb3ty07.js +3 -0
  43. package/dist/chunk-gsv5yc32.js +6 -0
  44. package/dist/chunk-h7k9wamx.js +3 -0
  45. package/dist/chunk-j6pfxvy8.js +3 -0
  46. package/dist/chunk-km8t8gqg.js +3 -0
  47. package/dist/chunk-knrtwppp.js +102 -0
  48. package/dist/chunk-m1khpcqb.js +3 -0
  49. package/dist/chunk-mt9219xc.js +7 -0
  50. package/dist/chunk-n2nyd0ck.js +3 -0
  51. package/dist/chunk-n37yj3xv.js +8 -0
  52. package/dist/chunk-n3p7wedp.js +3 -0
  53. package/dist/chunk-n6nw7sn2.js +7 -0
  54. package/dist/chunk-n94729d9.js +3 -0
  55. package/dist/chunk-nchp0pqa.js +3 -0
  56. package/dist/chunk-nn9tpxx3.js +3 -0
  57. package/dist/chunk-p2qz2nk2.js +3 -0
  58. package/dist/chunk-p7w9ydhe.js +9 -0
  59. package/dist/chunk-pga5m4wm.js +3 -0
  60. package/dist/chunk-psrgw9f8.js +19 -0
  61. package/dist/chunk-py7pj8aj.js +5 -0
  62. package/dist/chunk-pzedkn7z.js +4 -0
  63. package/dist/chunk-q0hn0ymb.js +6 -0
  64. package/dist/chunk-qnf4byak.js +3 -0
  65. package/dist/chunk-r4s18nn5.js +3 -0
  66. package/dist/chunk-r4zkf9ag.js +3 -0
  67. package/dist/chunk-rdzfdjkb.js +7 -0
  68. package/dist/chunk-rmdwvzgn.js +3 -0
  69. package/dist/chunk-s0mvstt0.js +3 -0
  70. package/dist/chunk-s6c98nad.js +29 -0
  71. package/dist/chunk-sjneg7p7.js +34 -0
  72. package/dist/chunk-sq34kkhy.js +3 -0
  73. package/dist/chunk-srg5qhch.js +22 -0
  74. package/dist/chunk-strqhcqs.js +3 -0
  75. package/dist/chunk-t1jtn2r0.js +10 -0
  76. package/dist/chunk-ttc5pr8y.js +37 -0
  77. package/dist/chunk-v44crx69.js +62 -0
  78. package/dist/chunk-v6fwy63g.js +3 -0
  79. package/dist/chunk-vae5wxar.js +3 -0
  80. package/dist/chunk-vtskg4r2.js +4 -0
  81. package/dist/chunk-w9av39jy.js +3 -0
  82. package/dist/chunk-wnk9yjw2.js +3 -0
  83. package/dist/chunk-wrnz0e76.js +4 -0
  84. package/dist/chunk-wzcwctba.js +9 -0
  85. package/dist/chunk-xb92nrsm.js +3 -0
  86. package/dist/chunk-xr1h3tv2.js +8 -0
  87. package/dist/chunk-xsf941gw.js +3 -0
  88. package/dist/chunk-z4mvkazp.js +21 -0
  89. package/dist/chunk-zq93f8ca.js +5 -0
  90. package/dist/src/augmentation-graph.d.ts +11 -0
  91. package/dist/src/augmentation-graph.js +2 -0
  92. package/dist/src/binding-patterns.d.ts +18 -0
  93. package/dist/src/binding-patterns.js +2 -0
  94. package/dist/src/branded-types.d.ts +159 -0
  95. package/dist/src/branded-types.js +2 -0
  96. package/dist/src/bundle-linker.d.ts +38 -0
  97. package/dist/src/bundle-linker.js +2 -0
  98. package/dist/src/bundler.d.ts +55 -0
  99. package/dist/src/bundler.js +2 -0
  100. package/dist/src/cache.d.ts +53 -0
  101. package/dist/src/cache.js +2 -0
  102. package/dist/src/call-signatures.d.ts +1 -0
  103. package/dist/src/call-signatures.js +2 -0
  104. package/dist/src/checker.d.ts +107 -0
  105. package/dist/src/circular.d.ts +82 -0
  106. package/dist/src/circular.js +2 -0
  107. package/dist/src/compat.d.ts +114 -0
  108. package/dist/src/compat.js +2 -0
  109. package/dist/src/computed-keys.d.ts +12 -0
  110. package/dist/src/computed-keys.js +2 -0
  111. package/dist/src/concurrency.d.ts +4 -0
  112. package/dist/src/concurrency.js +2 -0
  113. package/dist/src/config.d.ts +35 -0
  114. package/dist/src/config.js +2 -0
  115. package/dist/src/dangling-refs.d.ts +11 -0
  116. package/dist/src/dangling-refs.js +2 -0
  117. package/dist/src/declaration-project.d.ts +33 -0
  118. package/dist/src/declaration-project.js +2 -0
  119. package/dist/src/declaration-publication.d.ts +15 -0
  120. package/dist/src/declaration-publication.js +2 -0
  121. package/dist/src/declaration-references.d.ts +19 -0
  122. package/dist/src/declaration-references.js +2 -0
  123. package/dist/src/diff.d.ts +82 -0
  124. package/dist/src/diff.js +2 -0
  125. package/dist/src/docs.d.ts +97 -0
  126. package/dist/src/docs.js +2 -0
  127. package/dist/src/enum-declarations.d.ts +6 -0
  128. package/dist/src/enum-declarations.js +2 -0
  129. package/dist/src/errors.d.ts +113 -0
  130. package/dist/src/errors.js +2 -0
  131. package/dist/src/extractor/directives.d.ts +5 -0
  132. package/dist/src/extractor/directives.js +2 -0
  133. package/dist/src/extractor/extract.d.ts +10 -0
  134. package/dist/src/extractor/extract.js +2 -0
  135. package/dist/src/extractor/hash.d.ts +1 -0
  136. package/dist/src/extractor/hash.js +2 -0
  137. package/dist/src/extractor/scanner.d.ts +32 -0
  138. package/dist/src/extractor/scanner.js +2 -0
  139. package/dist/src/extractor.d.ts +5 -0
  140. package/dist/src/extractor.js +2 -0
  141. package/dist/src/formats.d.ts +50 -0
  142. package/dist/src/formats.js +2 -0
  143. package/dist/src/formatter.d.ts +61 -0
  144. package/dist/src/formatter.js +2 -0
  145. package/dist/src/function-properties.d.ts +3 -0
  146. package/dist/src/function-properties.js +2 -0
  147. package/dist/src/generator.d.ts +18 -0
  148. package/dist/src/generator.js +2 -0
  149. package/dist/src/global-types.d.ts +17 -0
  150. package/dist/src/global-types.js +2 -0
  151. package/dist/src/import-sorter.d.ts +99 -0
  152. package/dist/src/import-sorter.js +2 -0
  153. package/dist/src/incremental.d.ts +103 -0
  154. package/dist/src/incremental.js +2 -0
  155. package/dist/src/index.d.ts +62 -0
  156. package/dist/src/index.js +2 -0
  157. package/dist/src/inferred-imports.d.ts +4 -0
  158. package/dist/src/inferred-imports.js +2 -0
  159. package/dist/src/json-config.d.ts +2 -0
  160. package/dist/src/json-config.js +2 -0
  161. package/dist/src/lexical.d.ts +6 -0
  162. package/dist/src/lexical.js +2 -0
  163. package/dist/src/logger.d.ts +57 -0
  164. package/dist/src/logger.js +2 -0
  165. package/dist/src/lsp.d.ts +333 -0
  166. package/dist/src/lsp.js +2 -0
  167. package/dist/src/memory.d.ts +127 -0
  168. package/dist/src/memory.js +2 -0
  169. package/dist/src/merger.d.ts +38 -0
  170. package/dist/src/merger.js +2 -0
  171. package/dist/src/module-graph.d.ts +70 -0
  172. package/dist/src/module-graph.js +2 -0
  173. package/dist/src/module-references.d.ts +30 -0
  174. package/dist/src/module-references.js +2 -0
  175. package/dist/src/native-checker.d.ts +55 -0
  176. package/dist/src/native-checker.js +2 -0
  177. package/dist/src/native-engine.d.ts +16 -0
  178. package/dist/src/native-engine.js +2 -0
  179. package/dist/src/native-extractor.d.ts +9 -0
  180. package/dist/src/native-extractor.js +2 -0
  181. package/dist/src/native-generation.d.ts +20 -0
  182. package/dist/src/native-generation.js +2 -0
  183. package/dist/src/native-project.d.ts +35 -0
  184. package/dist/src/native-project.js +2 -0
  185. package/dist/src/optimizer.d.ts +56 -0
  186. package/dist/src/optimizer.js +2 -0
  187. package/dist/src/output-normalizer.d.ts +123 -0
  188. package/dist/src/output-normalizer.js +2 -0
  189. package/dist/src/parallel-processor.d.ts +63 -0
  190. package/dist/src/parallel-processor.js +2 -0
  191. package/dist/src/parameters.d.ts +5 -0
  192. package/dist/src/parameters.js +2 -0
  193. package/dist/src/parser.d.ts +68 -0
  194. package/dist/src/parser.js +2 -0
  195. package/dist/src/plugins/bun.d.ts +58 -0
  196. package/dist/src/plugins/bun.js +2 -0
  197. package/dist/src/plugins/esbuild.d.ts +63 -0
  198. package/dist/src/plugins/esbuild.js +2 -0
  199. package/dist/src/plugins/index.d.ts +16 -0
  200. package/dist/src/plugins/index.js +2 -0
  201. package/dist/src/plugins/tsdown.d.ts +30 -0
  202. package/dist/src/plugins/tsdown.js +2 -0
  203. package/dist/src/plugins/tsup.d.ts +53 -0
  204. package/dist/src/plugins/tsup.js +2 -0
  205. package/dist/src/plugins/vite.d.ts +49 -0
  206. package/dist/src/plugins/vite.js +2 -0
  207. package/dist/src/plugins/webpack.d.ts +69 -0
  208. package/dist/src/plugins/webpack.js +2 -0
  209. package/dist/src/plugins.d.ts +88 -0
  210. package/dist/src/plugins.js +2 -0
  211. package/dist/src/process-source.d.ts +28 -0
  212. package/dist/src/process-source.js +2 -0
  213. package/dist/src/processor/cache.d.ts +18 -0
  214. package/dist/src/processor/cache.js +2 -0
  215. package/dist/src/processor/comments.d.ts +9 -0
  216. package/dist/src/processor/comments.js +2 -0
  217. package/dist/src/processor/declarations.d.ts +37 -0
  218. package/dist/src/processor/declarations.js +2 -0
  219. package/dist/src/processor/import-usage.d.ts +6 -0
  220. package/dist/src/processor/import-usage.js +2 -0
  221. package/dist/src/processor/imports.d.ts +68 -0
  222. package/dist/src/processor/imports.js +2 -0
  223. package/dist/src/processor/index.d.ts +33 -0
  224. package/dist/src/processor/index.js +2 -0
  225. package/dist/src/processor/type-inference.d.ts +116 -0
  226. package/dist/src/processor/type-inference.js +2 -0
  227. package/dist/src/processor.d.ts +5 -0
  228. package/dist/src/processor.js +2 -0
  229. package/dist/src/profiling.d.ts +114 -0
  230. package/dist/src/profiling.js +2 -0
  231. package/dist/src/return-type-scope.d.ts +3 -0
  232. package/dist/src/return-type-scope.js +2 -0
  233. package/dist/src/security.d.ts +100 -0
  234. package/dist/src/security.js +2 -0
  235. package/dist/src/source-cache.d.ts +16 -0
  236. package/dist/src/source-cache.js +2 -0
  237. package/dist/src/sourcemap.d.ts +137 -0
  238. package/dist/src/sourcemap.js +2 -0
  239. package/dist/src/stx.d.ts +20 -0
  240. package/dist/src/stx.js +2 -0
  241. package/dist/src/syntax-validator.d.ts +7 -0
  242. package/dist/src/syntax-validator.js +2 -0
  243. package/dist/src/tracking.d.ts +95 -0
  244. package/dist/src/tracking.js +2 -0
  245. package/dist/src/transformers.d.ts +188 -0
  246. package/dist/src/transformers.js +2 -0
  247. package/dist/src/tree-shaker.d.ts +69 -0
  248. package/dist/src/tree-shaker.js +2 -0
  249. package/dist/src/tsconfig.d.ts +8 -0
  250. package/dist/src/tsconfig.js +2 -0
  251. package/dist/src/type-mappings.d.ts +145 -0
  252. package/dist/src/type-mappings.js +2 -0
  253. package/dist/src/types.d.ts +230 -0
  254. package/dist/src/types.js +1 -0
  255. package/dist/src/utils.d.ts +63 -0
  256. package/dist/src/utils.js +2 -0
  257. package/dist/src/value-inference.d.ts +6 -0
  258. package/dist/src/value-inference.js +2 -0
  259. package/dist/src/vue.d.ts +108 -0
  260. package/dist/src/vue.js +2 -0
  261. package/dist/src/watcher.d.ts +64 -0
  262. package/dist/src/watcher.js +2 -0
  263. package/dist/src/worker-thread.d.ts +1 -0
  264. package/dist/src/worker-thread.js +2 -0
  265. package/dist/src/worker.d.ts +98 -0
  266. package/dist/src/worker.js +2 -0
  267. package/dist/src/workspace.d.ts +62 -0
  268. package/dist/src/workspace.js +2 -0
  269. package/native/README.md +6 -0
  270. package/native/darwin-arm64/libzig-dtsx.dylib +0 -0
  271. package/native/darwin-x64/libzig-dtsx.dylib +0 -0
  272. package/native/freebsd-x64/libzig-dtsx.so +0 -0
  273. package/native/linux-arm64/libzig-dtsx.so +0 -0
  274. package/native/linux-x64/libzig-dtsx.so +0 -0
  275. package/native/windows-x64/zig-dtsx.dll +0 -0
  276. package/package.json +120 -4
@@ -0,0 +1,18 @@
1
+ // @bun
2
+ function Go(m,b={}){let{mergeInterfaces:c=!0,mergeNamespaces:e=!0,mergeTypes:n=!1,mergeEnums:l=!0,deduplicateIdentical:g=!0,conflictStrategy:d="last",preserveAllComments:h=!0}=b,u=[],r=0,f=new Map,o=[];for(let i of m){let a=`${i.kind}:${i.name}`,s=f.get(a);if(!s)s=[],f.set(a,s),o.push(a);s.push(i)}let t=[];for(let i of o){let a=f.get(i),s=a[0];if(a.length===1){t.push(s);continue}if(!(s.kind==="interface"&&c||s.kind==="module"&&e||s.kind==="type"&&n||s.kind==="enum"&&l)){t.push(...a);continue}let p=a;if(g)p=y(a);if(p.length===1){t.push(p[0]);continue}let x;switch(s.kind){case"interface":x=k(p,d,h);break;case"module":x=w(p,d,h);break;case"enum":x=M(p,d,h);break;case"type":x=A(p,d,h);break;default:x=p[0]}t.push(x),r+=p.length-1,u.push({name:s.name,kind:s.kind,sourceCount:p.length,memberCount:x.members?.length||0})}return{declarations:t,mergedCount:r,merges:u}}function y(m){let b=new Map;for(let c of m){let e=D(c.text);if(!b.has(e))b.set(e,c);else{let n=b.get(e);if((c.leadingComments?.length||0)>(n.leadingComments?.length||0))b.set(e,c)}}return Array.from(b.values())}function D(m){return m.replace(/\s+/g," ").replace(/;\s*/g,";").trim()}function k(m,b,c){let e=m[0],n=new Map,l=[],g=c?new Set:null;for(let a of m){if(c&&a.leadingComments&&g){for(let s of a.leadingComments)if(!g.has(s))g.add(s),l.push(s)}if(a.members)for(let s of a.members)if(!n.get(s.name))n.set(s.name,s);else switch(b){case"first":break;case"last":n.set(s.name,s);break;case"error":throw Error(`Conflicting member '${s.name}' in interface '${e.name}'`)}}let d=Array.from(n.values()),h=d.map((a)=>` ${a.text}`).join(`
3
+ `),u=e.generics||"",r=e.extends||"",f=new Set;for(let a of m)if(a.extends){let s=a.extends.split(",");for(let C of s){let p=C.trim();if(p)f.add(p)}}if(f.size>0)r=`extends ${Array.from(f).join(", ")}`;let o=e.isExported?"export ":"",t=e.modifiers?.includes("declare")?"declare ":"",i=`${o}${t}interface ${e.name}${u} ${r} {
4
+ ${h}
5
+ }`;return{...e,members:d,leadingComments:l.length>0?l:e.leadingComments,text:i.replace(/\s+\{/," {").replace(/\{\s*\n\s*\n/,`{
6
+ `),extends:r||void 0}}function w(m,b,c){let e=m[0],n=new Map,l=[],g=c?new Set:null;for(let o of m){if(c&&o.leadingComments&&g){for(let t of o.leadingComments)if(!g.has(t))g.add(t),l.push(t)}if(o.members)for(let t of o.members){let i=`${t.kind}:${t.name}`;if(!n.get(i))n.set(i,t);else switch(b){case"first":break;case"last":n.set(i,t);break;case"error":throw Error(`Conflicting member '${t.name}' in namespace '${e.name}'`)}}}let d=Array.from(n.values()),h=d.map((o)=>` ${o.text}`).join(`
7
+ `),u=e.isExported?"export ":"",r=e.modifiers?.includes("declare")?"declare ":"",f=`${u}${r}namespace ${e.name} {
8
+ ${h}
9
+ }`;return{...e,members:d,leadingComments:l.length>0?l:e.leadingComments,text:f}}function M(m,b,c){let e=m[0],n=new Map,l=[],g=c?new Set:null;for(let t of m){if(c&&t.leadingComments&&g){for(let i of t.leadingComments)if(!g.has(i))g.add(i),l.push(i)}if(t.members)for(let i of t.members)if(!n.get(i.name))n.set(i.name,i);else switch(b){case"first":break;case"last":n.set(i.name,i);break;case"error":throw Error(`Conflicting member '${i.name}' in enum '${e.name}'`)}}let d=Array.from(n.values()),h=d.map((t)=>` ${t.name}${t.value!==void 0?` = ${t.value}`:""}`).join(`,
10
+ `),u=e.isExported?"export ":"",r=e.modifiers?.includes("declare")?"declare ":"",f=e.modifiers?.includes("const")?"const ":"",o=`${u}${r}${f}enum ${e.name} {
11
+ ${h}
12
+ }`;return{...e,members:d,leadingComments:l.length>0?l:e.leadingComments,text:o}}function A(m,b,c){let e=m[0],n=[],l=c?new Set:null,g=[],d=new Set;for(let o of m){if(c&&o.leadingComments&&l){for(let t of o.leadingComments)if(!l.has(t))l.add(t),n.push(t)}if(o.typeAnnotation&&!d.has(o.typeAnnotation))d.add(o.typeAnnotation),g.push(o.typeAnnotation)}if(g.length<=1)return{...e,leadingComments:n.length>0?n:e.leadingComments};let h=g.join(" | "),u=e.isExported?"export ":"",r=e.generics||"",f=`${u}type ${e.name}${r} = ${h}`;return{...e,typeAnnotation:h,leadingComments:n.length>0?n:e.leadingComments,text:f}}function Vo(m,b={}){let c=m.split(`
13
+ `),e=new Map,n=null,l=0;for(let u=0;u<c.length;u++){let r=c[u],f=r.match(/^(export\s+)?(declare\s+)?interface\s+(\w+)/);if(f&&!n){n={name:f[3],start:u,lines:[r]},l=(r.match(/\{/g)||[]).length-(r.match(/\}/g)||[]).length;continue}if(n){if(n.lines.push(r),l+=(r.match(/\{/g)||[]).length-(r.match(/\}/g)||[]).length,l<=0){let o=e.get(n.name)||[];o.push({start:n.start,end:u,content:n.lines}),e.set(n.name,o),n=null,l=0}}}let g=Array.from(e.entries()).filter(([,u])=>u.length>1);if(g.length===0)return m;let d=[...c],h=new Set;for(let[u,r]of g){if(r.length<=1)continue;let[f,...o]=r,t=[],i=new Set;for(let C of r)for(let p of C.content){let x=p.trim();if(x.startsWith("interface")||x.startsWith("export")||x==="{"||x==="}")continue;if(x&&!i.has(x))i.add(x),t.push(p)}for(let C of o)for(let p=C.start;p<=C.end;p++)h.add(p);let a=f.content[0],s=[a.endsWith("{")?a:`${a} {`,...t,"}"];for(let C=f.start;C<=f.end;C++)h.add(C);d[f.start]=s.join(`
14
+ `)}return d.filter((u,r)=>!h.has(r)||d[r].includes("interface")).join(`
15
+ `).replace(/\n{3,}/g,`
16
+
17
+ `)}
18
+ export{Go,Vo};
@@ -0,0 +1,6 @@
1
+ // @bun
2
+ import{r}from"./chunk-qnf4byak.js";import{be}from"./chunk-vae5wxar.js";import{readFileSync as u}from"fs";import{readFile as p}from"fs/promises";import{resolve as g}from"path";function m(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/^\s*\/\/.*$/gm,"").replace(/,\s*([}\]])/g,"$1")}function vs(t,e){try{return{...JSON.parse(m(u(t,"utf8"))).compilerOptions,...e}}catch(s){throw Error(`Error reading tsconfig.json: ${s instanceof Error?s.message:String(s)}`)}}function f(t,e){let s=e.declarationsOnly?t.filter((o)=>o.endsWith(".d.ts")):t;if(e.include?.length){let o=e.include.map((n)=>new RegExp(n.replace(/\*/g,".*")));s=s.filter((n)=>o.some((i)=>i.test(n)))}if(e.exclude?.length){let o=e.exclude.map((n)=>new RegExp(n.replace(/\*/g,".*")));s=s.filter((n)=>!o.some((i)=>i.test(n)))}return s}async function lt(t,e={}){let s=performance.now(),o=f(t,e),n=[];for(let a of o)try{let c=await p(a,"utf8");for(let l of be(c))n.push({file:a,line:l.line,column:l.column,message:l.message,code:Number(l.code.slice(4)),severity:"error",category:"Error"})}catch(c){n.push({file:a,line:0,column:0,message:c instanceof Error?c.message:String(c),code:1000,severity:"error",category:"Error"})}let i=e.maxErrors?n.slice(0,e.maxErrors):n;return{success:i.length===0,diagnostics:i,errorCount:i.length,warningCount:0,infoCount:0,filesChecked:o,durationMs:performance.now()-s}}function Ar(t,e={}){return lt(t,{...e,declarationsOnly:!0})}async function Ss(t){let e=new Map;for(let s of t){let o=await p(s,"utf8").catch(()=>""),n=[];for(let i of r(o,s,!1,!0))if(i.isExported&&i.kind==="function"&&!i.returnType)n.push({line:1,column:1,message:"Exported function requires an explicit return type",declarationName:i.name,missingAnnotation:"return"});e.set(s,{compatible:n.length===0,issues:n})}return e}function d(t,e,s){let o=t.split(`
3
+ `);if(e<1||e>o.length||s<1||s>o[e-1].length+1)return null;let n=s-1;for(let i=0;i<e-1;i++)n+=o[i].length+1;return n}function Pr(t,e,s){try{let o=u(t,"utf8"),n=d(o,e,s);if(n===null)return null;let i=r(o,t,!1).find((a)=>n>=(a.start??0)&&n<=(a.end??o.length));return i?.typeAnnotation??i?.returnType??i?.text??null}catch{return null}}function $s(t,e,s){let o=Pr(t,e,s);return o?{type:o}:null}function Es(t){if(t.success)return`\u2713 Type check passed (${t.filesChecked.length} files checked in ${t.durationMs}ms)`;return["\u2717 Type check failed",` ${t.errorCount} error(s), ${t.warningCount} warning(s)`,...t.diagnostics.map((e)=>`\u2717 ${e.file}:${e.line}:${e.column}
4
+ ${e.message}`)].join(`
5
+ `)}function ks(t){return lt(t.entrypoints.map((e)=>g(t.cwd,e)),{tsconfigPath:t.tsconfigPath,rootDir:t.root})}async function Ts(t,e){let o=(await Promise.all([lt(t),Ar(e)])).flatMap((n)=>n.diagnostics).map((n)=>({sourceName:n.file,sourceType:n.message,dtsType:"<invalid>"}));return{valid:o.length===0,mismatches:o}}
6
+ export{vs,lt,Ar,Ss,Pr,$s,Es,ks,Ts};
@@ -0,0 +1,7 @@
1
+ // @bun
2
+ import{c,i,Oe,ce}from"./chunk-zq93f8ca.js";function t(s){let r=[],a=s.length,e=0;function n(){let l=e++;while(e<a){let u=s.charCodeAt(e);if(u===92)e+=2;else if(u===96){r.push({start:l,end:++e,kind:"literal"});return}else if(u===36&&s.charCodeAt(e+1)===123)r.push({start:l,end:e+1,kind:"literal"}),r.push({start:e+1,end:e+2,kind:"punctuation"}),e+=2,g(!0),l=e;else e++}r.push({start:l,end:e,kind:"literal"})}function g(l=!1){let u=0;while(e<a){let y=e,p=s.charCodeAt(e);if(p===32||p>=9&&p<=13||p>127&&/\s/.test(s[e])){e++;continue}if(p===47){let w=s.charCodeAt(e+1);if(w===47){let b=s.indexOf(`
3
+ `,e+2);e=b===-1?a:b+1;continue}if(w===42){let b=s.indexOf("*/",e+2);e=b===-1?a:b+2;continue}if(Oe(s,e)){e=ce(s,e),r.push({start:y,end:e,kind:"literal"});continue}}else if(p===96){n();continue}else if(p===34||p===39){e++;let w=!1;while(e<a){let b=s.charCodeAt(e++);if(b===92)e++;else if(b===p){w=!0;break}}r.push({start:y,end:Math.min(e,a),kind:w?"quoted":"literal"});continue}else if(c(p)){while(i(s.charCodeAt(++e)));r.push({start:y,end:e,kind:"word"});continue}if(r.push({start:y,end:++e,kind:"punctuation"}),l){if(p===123)u++;else if(p===125){if(u===0)return;u--}}}}return g(),r}var C,M=[];function F(s){if(s!==C)M=t(s),C=s;return M}function Jn(){C=void 0,M=[]}function d(s){let r="",a=s.length-1;for(let e=1;e<a;e++){if(s[e]!=="\\"){r+=s[e];continue}let n=s[++e];if(e>=a)return;switch(n){case`
4
+ `:break;case"\r":if(s[e+1]===`
5
+ `)e++;break;case"n":r+=`
6
+ `;break;case"r":r+="\r";break;case"t":r+="\t";break;case"b":r+="\b";break;case"f":r+="\f";break;case"v":r+="\v";break;case"0":if(/\d/.test(s[e+1]??""))return;r+="\x00";break;case"x":case"u":{let g=n==="u"&&s[e+1]==="{",l=e+(g?2:1),u=g?s.indexOf("}",l):l+(n==="x"?2:4),y=s.slice(l,u);if(u<l||u>a||!/^[\da-f]+$/i.test(y)||g&&y.length>6)return;let p=Number.parseInt(y,16);if(p>1114111)return;r+=String.fromCodePoint(p),e=g?u:u-1;break}default:if(/\d/.test(n))return;r+=n}}return r}function x(s,r){let a=r;for(let e of s){let n=e.charCodeAt(0);if(e===r||e==="\\")a+=`\\${e}`;else if(n<32||n===8232||n===8233||e.length===1&&n>=55296&&n<=57343)a+=`\\u${n.toString(16).padStart(4,"0")}`;else a+=e}return a+r}function Me(s){let r=t(s),a=(u)=>r[u]?s.slice(r[u].start,r[u].end):"";if(a(0)!=="import")return;let e=a(1)==="type"&&a(2)!=="=",n=e?2:1;if(r[n]?.kind!=="word"||a(n+1)!=="="||a(n+2)!=="require"||a(n+3)!=="("||r[n+4]?.kind!=="quoted"||a(n+5)!==")")return;let g=n+6;if(r.length!==g&&!(r.length===g+1&&a(g)===";"))return;let l=d(a(n+4));if(l===void 0)return;return{name:a(n),source:l,isTypeOnly:e,end:r[r.length-1].end}}function m(s){let r=t(s),a=[],e=new Set,n=(o)=>o>=0&&o<r.length?s.slice(r[o].start,r[o].end):"",g=(o)=>r[o]?.kind==="quoted",l=(o)=>r[o]?.kind==="word",u=[],y=!1,p=0;if(s.includes("declare")&&s.includes("module"))for(let o=0;o<r.length;o++){let k=n(o);if(p===0&&l(o)&&n(o-1)!=="."&&n(o-1)!=="#"){if(k==="export"||k==="import"&&n(o+1)!=="("&&n(o+1)!==".")y=!0;if(k==="declare"&&n(o+1)==="module"&&g(o+2)&&n(o+3)==="{")u.push(o+2)}if(k==="{"||k==="("||k==="[")p++;else if(k==="}"||k===")"||k==="]")p--}function w(o,k=!1){if(n(o)==="*"){if(n(o+1)==="as")return l(o+2)||k&&g(o+2)?o+3:-1;return k?o+1:-1}if(n(o)!=="{")return-1;let f=1;for(let h=o+1;h<r.length;h++)if(n(h)==="{")f++;else if(n(h)==="}"&&--f===0)return h+1;else if(r[h].kind==="literal"||n(h)===";")return-1;return-1}function b(o,k,f,h){let S=r[o];if(!S||S.kind!=="quoted"||e.has(S.start))return;let T=d(s.slice(S.start,S.end));if(T===void 0)return;e.add(S.start),a.push({specifier:T,kind:k,isTypeOnly:f,category:h,start:S.start,end:S.end})}for(let o=0;o<r.length;o++){if(!l(o)||n(o-1)==="."||n(o-1)==="#")continue;let k=n(o),f=o+1;if(k==="export"){let h=n(f)==="type";if(h)f++;let S=n(f)==="*"?n(f+1)==="as"?"export-star-as":"export-star":"export-named",T=w(f,!0);if(T>=0&&n(T)==="from")b(T+1,S,h,"export")}else if(k==="import"){if(g(f)){b(f,"import",!1,"static-import");continue}if(n(f)==="("){if(n(f+2)===")"||n(f+2)===",")b(f+1,"import",!1,"import-type");continue}let h=n(f)==="type"&&n(f+1)!=="from"&&n(f+1)!=="="&&n(f+1)!==",";if(h)f++;if(l(f)){if(f++,n(f)==="="){if(n(f+1)==="require"&&n(f+2)==="("&&n(f+4)===")")b(f+3,"import",h,"static-import");continue}if(n(f)===",")f=w(f+1)}else f=w(f);if(f>=0&&n(f)==="from")b(f+1,"import",h,"static-import")}}if(y&&u.length){for(let o of u)b(o,"import",!0,"augmentation");a.sort((o,k)=>o.start-k.start)}return a}
7
+ export{t,F,Jn,d,x,Me,m};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{B}from"./chunk-pga5m4wm.js";import{p}from"./chunk-v6fwy63g.js";var f=100,c=new Map,a=new Map,u=new Map,g=0;function d(e,n,t){let r={fileName:e,text:n};c.delete(e),c.set(e,{file:r,hash:t});while(c.size>f){let s=c.keys().next().value;if(s===void 0)break;c.delete(s)}return r}function b(e,n,t){return u.set(e,(u.get(e)??0)+1),d(e,n,t)}function wt(e,n,t=p(n)){let r=c.get(e);if(r?.hash===t)return c.delete(e),c.set(e,r),r.file;return b(e,n,t)}async function Y(e,n,t={}){let r=p(n);if(c.get(e)?.hash===r)return wt(e,n,r);let o=`${e}\x00${String(r)}`,i=a.get(o);if(i)return i;let h=(u.get(e)??0)+1;u.set(e,h);let m=g,l;return l=Promise.resolve().then(async()=>{try{if(n.length>=(t.asyncThreshold??1e5))await new Promise((y)=>setTimeout(y,Math.max(0,t.yieldInterval??0)));if(m===g&&u.get(e)===h)return d(e,n,r);return{fileName:e,text:n}}finally{if(a.get(o)===l)a.delete(o)}}),a.set(o,l),l}async function bn(e,n={}){let t=new Map,r=B(n.concurrency,4);for(let s=0;s<e.length;s+=r){let o=await Promise.all(e.slice(s,s+r).map(async(i)=>({path:i.filePath,file:await Y(i.filePath,i.sourceCode,n)})));for(let i of o)t.set(i.path,i.file)}return t}function wn(){g++,c.clear(),a.clear(),u.clear()}function xn(){return c.size}function Cn(){return a.size}function vn(e,n={}){return e.length>=(n.asyncThreshold??1e5)}
3
+ export{wt,Y,bn,wn,xn,Cn,vn};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{R,M}from"./chunk-z4mvkazp.js";import{A,P}from"./chunk-mt9219xc.js";import{Jn}from"./chunk-1j6092xz.js";import{p}from"./chunk-v6fwy63g.js";import{k,D}from"./chunk-ttc5pr8y.js";var y=100,h=0,s=new Map;function xe(n,a,c=!0,i=!1,l){if(R(a))n=M(n);else if(A(a))n=P(n);let f=p(n),m=`${a}:${c?1:0}:${i?1:0}:${JSON.stringify([...l??[]].sort())}`,r=s.get(m);if(r&&r.contentHash===f)return r.lastAccess=++h,r.declarations;let g=i?k(n,a,c):D(n,a,c,l);if(s.set(m,{declarations:g,contentHash:f,lastAccess:++h}),s.size>y){let S=Math.max(1,Math.ceil(s.size*0.1)),e=[];for(let[t,o]of s)e.push([t,o.lastAccess]);e.sort((t,o)=>t[1]-o[1]);for(let t=0;t<S&&t<e.length;t++)s.delete(e[t][0])}return g}function Sn(){s.clear(),Jn()}
3
+ export{xe,Sn};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{t}from"./chunk-1j6092xz.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 Hn(n){let s=[];return y(j(n),s),s}function Kn(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{Hn,Kn};
@@ -0,0 +1,177 @@
1
+ // @bun
2
+ import{e}from"./chunk-km8t8gqg.js";import{existsSync as h}from"fs";import{cpus as u}from"os";import{resolve as l}from"path";import{fileURLToPath as k}from"url";import{Worker as c}from"worker_threads";var __dirname="/Users/chris/Code/Tools/dtsx/packages/dtsx/src",a;function f(){if(a!==void 0)return a;a=null;for(let t of["./worker-thread.js","./worker-thread.ts","./src/worker-thread.js","./src/worker-thread.ts"]){let r=new URL(t,import.meta.url);try{if(h(k(r))){a=r;break}}catch{}}return a}class Lt{workers=[];taskQueue=[];config;stats={totalTasks:0,completedTasks:0,failedTasks:0,averageDuration:0,activeWorkers:0,idleWorkers:0};isShuttingDown=!1;idleCheckInterval=null;constructor(t={}){let r=t.maxWorkers??Math.max(1,u().length-1);this.config={maxWorkers:r,taskTimeout:t.taskTimeout??30000,recycleAfter:t.recycleAfter??100,idleTimeout:t.idleTimeout??1e4,initialWorkers:t.initialWorkers??Math.min(2,r)}}async init(){let t=Math.min(this.config.initialWorkers,this.config.maxWorkers);for(let r=0;r<t;r++)this.createWorker();if(this.config.idleTimeout>0){if(this.idleCheckInterval=setInterval(()=>{this.checkIdleWorkers()},5000),this.idleCheckInterval&&typeof this.idleCheckInterval==="object"&&"unref"in this.idleCheckInterval)this.idleCheckInterval.unref()}}createWorker(){let t=`
3
+ const { parentPort } = require('worker_threads');
4
+ const bun = typeof Bun !== 'undefined' ? Bun : null;
5
+ const fs = bun ? null : require('node:fs');
6
+
7
+ const libsPromise = (async () => {
8
+ const { extractDeclarations } = await import('${l(__dirname,"extractor.js")}');
9
+ const { processDeclarations } = await import('${l(__dirname,"processor.js")}');
10
+ return { extractDeclarations, processDeclarations };
11
+ })();
12
+
13
+ // Dynamic import for ESM compatibility
14
+ async function processTask(task) {
15
+ const startTime = Date.now();
16
+
17
+ try {
18
+ const { extractDeclarations, processDeclarations } = await libsPromise;
19
+
20
+ const keepComments = task.config?.keepComments;
21
+ const isolatedDeclarations = task.config?.isolatedDeclarations;
22
+ const importOrder = task.config?.importOrder;
23
+
24
+ if (task.type === 'process-batch') {
25
+ const filePaths = task.filePaths;
26
+ const outPaths = task.outPaths;
27
+ const files = filePaths ? null : (task.files || []);
28
+ const fileCount = filePaths ? filePaths.length : files.length;
29
+ const writeOutput = task.writeOutput === true;
30
+ const results = writeOutput ? null : new Array(fileCount);
31
+ let errorResults = null;
32
+
33
+ let sources = task.sources;
34
+ if (!sources && fileCount > 0) {
35
+ const readPromises = new Array(fileCount);
36
+ for (let i = 0; i < fileCount; i++) {
37
+ const file = files ? files[i] : null;
38
+ const sourceCode = file ? file.sourceCode : undefined;
39
+ const filePath = filePaths ? filePaths[i] : file.filePath;
40
+ if (sourceCode != null) {
41
+ readPromises[i] = Promise.resolve(sourceCode);
42
+ }
43
+ else if (bun) {
44
+ readPromises[i] = bun.file(filePath).text();
45
+ }
46
+ else {
47
+ readPromises[i] = Promise.resolve(fs.readFileSync(filePath, 'utf-8'));
48
+ }
49
+ }
50
+ sources = await Promise.all(readPromises);
51
+ }
52
+
53
+ const ctx = { filePath: '', sourceCode: '', declarations: [] };
54
+ const writePromises = writeOutput && bun ? new Array(fileCount) : null;
55
+ let success = true;
56
+
57
+ for (let i = 0; i < fileCount; i++) {
58
+ const file = files ? files[i] : null;
59
+ const filePath = filePaths ? filePaths[i] : file.filePath;
60
+ const outPath = outPaths ? outPaths[i] : (file ? file.outPath : undefined);
61
+ try {
62
+ const sourceCode = sources ? sources[i] : (file?.sourceCode || '');
63
+ const declarations = extractDeclarations(sourceCode, filePath, keepComments, isolatedDeclarations);
64
+ ctx.filePath = filePath;
65
+ ctx.sourceCode = sourceCode;
66
+ ctx.declarations = declarations;
67
+ const content = processDeclarations(declarations, ctx, keepComments ?? true, importOrder);
68
+
69
+ if (writeOutput) {
70
+ if (!outPath) {
71
+ throw new Error(\`Missing outPath for \${filePath}\`);
72
+ }
73
+ if (bun) {
74
+ writePromises[i] = bun.write(outPath, content);
75
+ }
76
+ else {
77
+ fs.writeFileSync(outPath, content);
78
+ }
79
+ }
80
+ else if (results) {
81
+ results[i] = {
82
+ filePath,
83
+ success: true,
84
+ content,
85
+ declarations,
86
+ };
87
+ }
88
+ }
89
+ catch (error) {
90
+ const message = error && error.message ? error.message : String(error);
91
+ if (writeOutput) {
92
+ if (!errorResults) {
93
+ errorResults = [];
94
+ }
95
+ errorResults.push({
96
+ filePath,
97
+ success: false,
98
+ error: message,
99
+ });
100
+ }
101
+ else if (results) {
102
+ results[i] = {
103
+ filePath,
104
+ success: false,
105
+ error: message,
106
+ };
107
+ }
108
+ success = false;
109
+ }
110
+ }
111
+
112
+ if (writePromises) {
113
+ await Promise.all(writePromises);
114
+ }
115
+
116
+ const errorMessage = errorResults?.length
117
+ ? \`\${errorResults[0].filePath}: \${errorResults[0].error || 'Worker batch failed'}\`
118
+ : undefined;
119
+
120
+ return {
121
+ id: task.id,
122
+ success,
123
+ filePath: task.filePath,
124
+ batchResults: writeOutput ? errorResults || undefined : results,
125
+ error: errorMessage,
126
+ duration: Date.now() - startTime,
127
+ };
128
+ }
129
+
130
+ if (task.type === 'extract') {
131
+ const declarations = extractDeclarations(task.sourceCode, task.filePath, keepComments, isolatedDeclarations);
132
+ return {
133
+ id: task.id,
134
+ success: true,
135
+ filePath: task.filePath,
136
+ declarations,
137
+ duration: Date.now() - startTime,
138
+ };
139
+ }
140
+
141
+ if (task.type === 'process') {
142
+ const declarations = extractDeclarations(task.sourceCode, task.filePath, keepComments, isolatedDeclarations);
143
+ const content = processDeclarations(declarations, {
144
+ filePath: task.filePath,
145
+ sourceCode: task.sourceCode,
146
+ declarations,
147
+ }, keepComments ?? true, importOrder);
148
+
149
+ return {
150
+ id: task.id,
151
+ success: true,
152
+ filePath: task.filePath,
153
+ content,
154
+ declarations,
155
+ duration: Date.now() - startTime,
156
+ };
157
+ }
158
+
159
+ throw new Error(\`Unknown task type: \${task.type}\`);
160
+ }
161
+ catch (error) {
162
+ return {
163
+ id: task.id,
164
+ success: false,
165
+ filePath: task.filePath,
166
+ error: error.message,
167
+ duration: Date.now() - startTime,
168
+ };
169
+ }
170
+ }
171
+
172
+ parentPort.on('message', async (task) => {
173
+ const result = await processTask(task);
174
+ parentPort.postMessage(result);
175
+ });
176
+ `,r=f(),o=r?new c(k(r)):new c(t,{eval:!0}),s={worker:o,busy:!1,taskCount:0,lastActive:Date.now(),currentTask:null};return o.on("message",(i)=>{this.handleWorkerResult(s,i)}),o.on("error",(i)=>{e.error("Worker error:",i),this.handleWorkerError(s,i)}),o.on("exit",(i)=>{if(i!==0&&!this.isShuttingDown)e.error(`Worker exited with code ${i}`),this.removeWorker(s)}),this.workers.push(s),this.updateStats(),s}handleWorkerResult(t,r){if(t.busy=!1,t.taskCount++,t.lastActive=Date.now(),t.currentTask&&t.currentTask.id===r.id){clearTimeout(t.currentTask.timeout);let{resolve:s}=t.currentTask;t.currentTask=null,s(r)}if(r.success)this.stats.completedTasks++;else this.stats.failedTasks++;let o=this.stats.averageDuration*(this.stats.completedTasks+this.stats.failedTasks-1)+r.duration;if(this.stats.averageDuration=o/(this.stats.completedTasks+this.stats.failedTasks),this.updateStats(),t.taskCount>=this.config.recycleAfter)this.recycleWorker(t);this.processQueue()}handleWorkerError(t,r){if(t.busy=!1,t.currentTask){clearTimeout(t.currentTask.timeout);let{reject:o}=t.currentTask;t.currentTask=null,o(r)}this.stats.failedTasks++,this.updateStats(),this.recycleWorker(t),this.processQueue()}removeWorker(t){let r=this.workers.indexOf(t);if(r!==-1)this.workers.splice(r,1),t.worker.terminate();this.updateStats()}recycleWorker(t){if(this.removeWorker(t),!this.isShuttingDown&&this.workers.length<this.config.maxWorkers)this.createWorker()}checkIdleWorkers(){let t=Date.now(),r=1;for(let o=this.workers.length-1;o>=0;o--){let s=this.workers[o];if(!s.busy&&t-s.lastActive>this.config.idleTimeout&&this.workers.length>1)this.removeWorker(s)}}processQueue(){while(this.taskQueue.length>0){let t;for(let n=0;n<this.workers.length;n++)if(!this.workers[n].busy){t=this.workers[n];break}if(!t&&this.workers.length<this.config.maxWorkers)t=this.createWorker();if(!t)return;let{task:r,resolve:o,reject:s}=this.taskQueue.shift();t.busy=!0,t.lastActive=Date.now();let i=setTimeout(()=>{if(t.currentTask?.id===r.id)t.currentTask=null;s(Error(`Task ${r.id} timed out`)),this.recycleWorker(t)},this.config.taskTimeout);t.currentTask={id:r.id,resolve:o,reject:s,timeout:i},t.worker.postMessage(r),this.updateStats()}}async submit(t){return this.stats.totalTasks++,new Promise((r,o)=>{this.taskQueue.push({task:t,resolve:r,reject:o}),this.processQueue()})}async processFiles(t,r={}){let o=t.map((s,i)=>({id:`task-${i}-${Date.now()}`,type:"process",filePath:s.path,sourceCode:s.content,config:r}));return Promise.all(o.map((s)=>this.submit(s)))}updateStats(){let t=0;for(let r=0;r<this.workers.length;r++)if(this.workers[r].busy)t++;this.stats.activeWorkers=t,this.stats.idleWorkers=this.workers.length-t}getStats(){return{...this.stats}}async shutdown(){if(this.isShuttingDown=!0,this.idleCheckInterval)clearInterval(this.idleCheckInterval);while(this.taskQueue.length>0||this.workers.some((t)=>t.busy))await new Promise((t)=>setTimeout(t,100));await Promise.all(this.workers.map((t)=>t.worker.terminate())),this.workers=[]}}function er(t={}){return new Lt(t)}async function Ei(t,r={},o={}){let s=er(o);await s.init();try{return await s.processFiles(t,r)}finally{await s.shutdown()}}function ki(t,r){let o=[];for(let s=0;s<t.length;s+=r)o.push(t.slice(s,s+r));return o}function Ti(t,r=u().length){if(t<=r)return 1;let s=r*3;return Math.max(1,Math.ceil(t/s))}
177
+ export{Lt,er,Ei,ki,Ti};
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ function ms(e,i){return e.getText?.()??i.slice(e.pos??0,e.end??i.length)}function gs(e){return e.getFullText?.().match(/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g)??[]}function Jt(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 hs(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 ys(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 Yt(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 bs(e){let i=Jt(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=Yt(t,"<",">");if(o)u=o.content,t=o.rest.trim()}let a="";if(t.startsWith("(")){let o=Yt(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 ws(e){return/^\s*export\s+/.test(e)}function xs(e){return/^\s*export\s+type\s+/.test(e)}function Cs(e){let i=Jt(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{ms,gs,Jt,hs,ys,Yt,bs,ws,xs,Cs};
@@ -0,0 +1,12 @@
1
+ // @bun
2
+ var w=Object.defineProperty;var O=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var M=(e,t,s)=>{for(var o in t)w(e,o,{get:t[o],set:s[o],enumerable:!0,configurable:!0})};var h=O(function(R,P){P.exports={name:"typescript",version:"7.0.2",license:"Apache-2.0",author:"Microsoft Corp.",homepage:"https://www.typescriptlang.org/",description:"TypeScript is a language for application scale JavaScript development",keywords:["TypeScript","Microsoft","compiler","language","javascript"],bugs:{url:"https://github.com/microsoft/TypeScript/issues"},repository:{type:"git",url:"https://github.com/microsoft/TypeScript.git"},type:"module",preferUnplugged:!0,engines:{node:">=16.20.0"},files:["bin","lib","dist","vendor","NOTICE.txt"],bin:{tsc:"./bin/tsc"},exports:{"./package.json":"./package.json",".":"./lib/version.cjs","./unstable/sync":"./dist/api/sync/api.js","./unstable/async":"./dist/api/async/api.js","./unstable/fs":"./dist/api/fs.js","./unstable/proto":"./dist/api/proto.js","./unstable/ast":"./dist/ast/index.js","./unstable/ast/is":"./dist/ast/is.js","./unstable/ast/factory":"./dist/ast/factory.generated.js","./unstable/ast/utils":"./dist/ast/utils.js","./unstable/ast/scanner":"./dist/ast/scanner.js","./unstable/ast/visitor":"./dist/ast/visitor.js","./unstable/ast/clone":"./dist/ast/clone.js"},imports:{"#getExePath":"./lib/getExePath.js","#enums/*":{types:"./dist/enums/*.enum.d.ts",default:"./dist/enums/*.js"},"#vscode-jsonrpc/node":"./vendor/vscode-jsonrpc/lib/node/main.js"},gitHead:"2bd066d87f5bafd315be9f40889d0a60b9e58e0b",publishConfig:{access:"public",tag:"latest"},optionalDependencies:{"@typescript/typescript-win32-x64":"7.0.2","@typescript/typescript-win32-arm64":"7.0.2","@typescript/typescript-linux-x64":"7.0.2","@typescript/typescript-linux-arm":"7.0.2","@typescript/typescript-linux-arm64":"7.0.2","@typescript/typescript-darwin-x64":"7.0.2","@typescript/typescript-darwin-arm64":"7.0.2","@typescript/typescript-aix-ppc64":"7.0.2","@typescript/typescript-freebsd-arm64":"7.0.2","@typescript/typescript-freebsd-x64":"7.0.2","@typescript/typescript-linux-loong64":"7.0.2","@typescript/typescript-linux-mips64el":"7.0.2","@typescript/typescript-linux-ppc64":"7.0.2","@typescript/typescript-linux-riscv64":"7.0.2","@typescript/typescript-linux-s390x":"7.0.2","@typescript/typescript-netbsd-arm64":"7.0.2","@typescript/typescript-netbsd-x64":"7.0.2","@typescript/typescript-openbsd-arm64":"7.0.2","@typescript/typescript-openbsd-x64":"7.0.2","@typescript/typescript-sunos-x64":"7.0.2"}}});var r={};M(r,{version:()=>C,versionMajorMinor:()=>x},{version:(F)=>C=F,versionMajorMinor:(F)=>x=F});import{dirname as A,resolve as K}from"path";var{version:L}=h();var C=L,x="7.0";function E(){if(typeof r?.sys<"u"&&typeof r?.createProgram==="function")return;let e=r?.version,t=e?`found ${e}`:"none resolved";throw TypeError(`Type checking needs the TypeScript 5.x compiler API, but ${t}. TypeScript 7 (the native port) does not expose \`ts.sys\` or \`ts.createProgram\`. `+"Install typescript@^5 to use `dtsx check`, or drop the flag \u2014 generation and "+"declaration validation both work without it.")}function k(e,t){E();let s=r.readConfigFile(e,r.sys.readFile);if(s.error)throw Error(`Error reading tsconfig.json: ${b(s.error)}`);let o=r.parseJsonConfigFileContent(s.config,r.sys,A(e));if(o.errors.length>0){let i=o.errors.map(b).join(`
3
+ `);throw Error(`Error parsing tsconfig.json:
4
+ ${i}`)}return{...o.options,...t}}function b(e){if(e.file&&e.start!==void 0){let{line:t,character:s}=e.file.getLineAndCharacterOfPosition(e.start),o=r.flattenDiagnosticMessageText(e.messageText,`
5
+ `);return`${e.file.fileName}(${t+1},${s+1}): ${o}`}return r.flattenDiagnosticMessageText(e.messageText,`
6
+ `)}function S(e){switch(e){case r.DiagnosticCategory.Error:return"error";case r.DiagnosticCategory.Warning:return"warning";case r.DiagnosticCategory.Suggestion:return"hint";case r.DiagnosticCategory.Message:default:return"info"}}function T(e){switch(e){case r.DiagnosticCategory.Error:return"Error";case r.DiagnosticCategory.Warning:return"Warning";case r.DiagnosticCategory.Suggestion:return"Suggestion";case r.DiagnosticCategory.Message:return"Message";default:return"Unknown"}}var D=new WeakMap;function N(e){let t=r.flattenDiagnosticMessageText(e.messageText,`
7
+ `);if(e.file&&e.start!==void 0){let{line:s,character:o}=e.file.getLineAndCharacterOfPosition(e.start),i=e.file,c;if(e.length){let g=s,a=e.start+e.length,{line:p}=i.getLineAndCharacterOfPosition(a),l=D.get(i);if(!l)l=i.text.split(`
8
+ `),D.set(i,l);let d=Math.max(0,g-1),n=Math.min(l.length,p+2);c=l.slice(d,n).join(`
9
+ `)}return{file:i.fileName,line:s+1,column:o+1,message:t,code:e.code,severity:S(e.category),source:c,category:T(e.category)}}return{file:"<unknown>",line:0,column:0,message:t,code:e.code,severity:S(e.category),category:T(e.category)}}function v(e,t){let s=r.createCompilerHost(t);return r.createProgram(e,t,s)}async function B(e,t={}){E();let s=Date.now(),o;if(t.tsconfigPath)o=k(t.tsconfigPath,t.compilerOptions);else o={target:r.ScriptTarget.ESNext,module:r.ModuleKind.ESNext,moduleResolution:r.ModuleResolutionKind.Bundler,strict:t.strict??!0,skipLibCheck:t.skipLibCheck??!0,noEmit:!0,declaration:!0,...t.compilerOptions};let i=e;if(t.declarationsOnly)i=e.filter((n)=>n.endsWith(".d.ts"));if(t.include?.length){let n=t.include.map((u)=>new RegExp(u.replace(/\*/g,".*")));i=i.filter((u)=>n.some((y)=>y.test(u)))}if(t.exclude?.length){let n=t.exclude.map((u)=>new RegExp(u.replace(/\*/g,".*")));i=i.filter((u)=>!n.some((y)=>y.test(u)))}let c=v(i,o),a=[...c.getConfigFileParsingDiagnostics(),...c.getSyntacticDiagnostics(),...c.getSemanticDiagnostics(),...c.getDeclarationDiagnostics()].map(N);if(t.maxErrors&&a.length>t.maxErrors)a=a.slice(0,t.maxErrors);let p=a.filter((n)=>n.severity==="error").length,l=a.filter((n)=>n.severity==="warning").length,d=a.filter((n)=>n.severity==="info"||n.severity==="hint").length;if(t.warningsAsErrors)a=a.map((n)=>n.severity==="warning"?{...n,severity:"error"}:n),p+=l;return{success:p===0,diagnostics:a,errorCount:p,warningCount:t.warningsAsErrors?0:l,infoCount:d,filesChecked:i,durationMs:Date.now()-s}}async function z(e,t){let s=new Map,i={...t?k(t):{target:r.ScriptTarget.ESNext,module:r.ModuleKind.ESNext,moduleResolution:r.ModuleResolutionKind.Bundler},isolatedDeclarations:!0,declaration:!0,noEmit:!0},c=v(e,i);for(let g of e){let a=c.getSourceFile(g);if(!a){s.set(g,{compatible:!0,issues:[]});continue}let p=[],d=[...c.getSyntacticDiagnostics(a),...c.getSemanticDiagnostics(a)].filter((n)=>n.code>=9006&&n.code<=9099);for(let n of d)if(n.start!==void 0){let{line:u,character:y}=a.getLineAndCharacterOfPosition(n.start),m=r.flattenDiagnosticMessageText(n.messageText,`
10
+ `),f;if(m.includes("return type"))f="return";else if(m.includes("parameter"))f="parameter";else if(m.includes("variable"))f="variable";else if(m.includes("property"))f="property";p.push({line:u+1,column:y+1,message:m,missingAnnotation:f})}s.set(g,{compatible:p.length===0,issues:p})}return s}function G(e){let t=[];if(e.success)t.push(`\u2713 Type check passed (${e.filesChecked.length} files checked in ${e.durationMs}ms)`);else{t.push("\u2717 Type check failed"),t.push(` ${e.errorCount} error(s), ${e.warningCount} warning(s)`),t.push("");for(let s of e.diagnostics){let o=s.severity==="error"?"\u2717":s.severity==="warning"?"\u26A0":"\u2139";if(t.push(`${o} ${s.file}:${s.line}:${s.column}`),t.push(` ${s.message}`),s.source){let i=s.source.split(`
11
+ `);for(let c of i)t.push(` \u2502 ${c}`)}if(s.suggestion)t.push(` \uD83D\uDCA1 ${s.suggestion}`);t.push("")}}return t.join(`
12
+ `)}export{z as checkIsolatedDeclarations,G as formatTypeCheckResults,B as typeCheck};
@@ -0,0 +1,6 @@
1
+ // @bun
2
+ import{e,I}from"./chunk-km8t8gqg.js";import{Re}from"./chunk-pzedkn7z.js";import{s}from"./chunk-0azm93j9.js";import{existsSync as u,readFileSync as w}from"fs";import{dirname as W,join as d,resolve as v}from"path";async function Hr(i){let c=[],n=new Set;async function t(a,f){let o=v(a);if(n.has(o))return;if(n.add(o),!u(o)){e.warn(`tsconfig not found: ${o}`);return}try{let p=w(o,"utf-8"),r=JSON.parse(Re(p)),l=W(o),g=P(l,f),m=[];if(r.references)for(let y of r.references){let h=v(l,y.path),C=u(d(h,"tsconfig.json"))?d(h,"tsconfig.json"):h;await t(C,g);let G=P(W(C),g);m.push(G)}let j="./src";if(r.compilerOptions?.rootDir)j=r.compilerOptions.rootDir;else if(r.include&&r.include.length>0){if(r.include[0].startsWith("src/"))j="./src"}let k="./dist";if(r.compilerOptions?.outDir)k=r.compilerOptions.outDir;else if(r.compilerOptions?.declarationDir)k=r.compilerOptions.declarationDir;c.push({name:g,root:l,tsconfigPath:o,references:m,config:{root:j,outdir:k}})}catch(p){let r=p instanceof Error?p.message:String(p);e.warn(`Failed to parse ${o}: ${r}`)}}return await t(i),c}function P(i,c){let n=d(i,"package.json");if(u(n))try{let a=w(n,"utf-8"),f=JSON.parse(a);if(f.name)return f.name}catch{}let t=i.split("/").pop()||"unknown";return c?`${c}/${t}`:t}function Kr(i){let c=new Map(i.map((o)=>[o.name,o])),n=[],t=new Set,a=new Set;function f(o){if(t.has(o))return;if(a.has(o)){e.warn(`Circular dependency detected involving: ${o}`);return}a.add(o);let p=c.get(o);if(p){for(let r of p.references)f(r);n.push(p)}a.delete(o),t.add(o)}for(let o of i)f(o.name);return n}async function nn(i){let c=Date.now(),n=Kr(i.projects);e.info(`Generating declarations for ${n.length} projects...`);let t=[],a=!0;for(let r of n){e.info(`
3
+ [${r.name}] Generating...`);try{let l={...i.sharedConfig,...r.config,cwd:r.root,tsconfigPath:r.tsconfigPath},g=await s(l),m=g.filesFailed===0;if(!m)a=!1;t.push({name:r.name,stats:g,success:m}),e.info(`[${r.name}] Generated ${g.filesGenerated} files`)}catch(l){a=!1;let g=l instanceof Error?l.message:String(l);t.push({name:r.name,stats:{generationMode:r.config?.isolatedDeclarations||i.sharedConfig?.isolatedDeclarations?"isolated":"semantic",filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},success:!1,error:g}),e.error(`[${r.name}] Failed: ${g}`)}}let f=Date.now()-c,o=t.filter((r)=>r.success).length,p=t.length-o;if(e.info(`
4
+ --- Workspace Generation Summary ---`),e.info(`Projects processed: ${t.length}`),e.info(`Successful: ${o}`),p>0)e.info(`Failed: ${p}`);return e.info(`Total duration: ${f}ms`),e.info(`------------------------------------
5
+ `),{success:a,projects:t,durationMs:f}}async function oo(i,c){if(c?.logLevel)I(c.logLevel);let n=d(i,"tsconfig.json");if(!u(n))throw Error(`Root tsconfig.json not found at: ${n}`);e.info("Discovering workspace projects...");let t=await Hr(n);if(t.length===0)return e.warn("No projects found in workspace"),{success:!0,projects:[],durationMs:0};return e.info(`Found ${t.length} projects`),nn({root:i,projects:t,sharedConfig:c})}async function qr(i){let c=d(i,"package.json");if(!u(c))return[];try{let n=w(c,"utf-8"),t=JSON.parse(n),a=[];if(Array.isArray(t.workspaces))a=t.workspaces;else if(t.workspaces?.packages)a=t.workspaces.packages;return a}catch{return[]}}async function Jr(i,c){let{Glob:n}=await Promise.resolve(globalThis.Bun),t=[];for(let a of c){let f=new n(a);for await(let o of f.scan({cwd:i,absolute:!0,onlyFiles:!1})){let p=d(o,"package.json");if(u(p))t.push(o)}}return t}async function ao(i,c){if(c?.logLevel)I(c.logLevel);let n=await qr(i);if(n.length===0)return e.warn("No workspace patterns found in package.json"),{success:!0,projects:[],durationMs:0};e.info(`Found workspace patterns: ${n.join(", ")}`);let t=await Jr(i,n);if(t.length===0)return e.warn("No projects found matching workspace patterns"),{success:!0,projects:[],durationMs:0};e.info(`Found ${t.length} workspace packages`);let a=t.map((f)=>{let o=d(f,"tsconfig.json");return{name:P(f),root:f,tsconfigPath:u(o)?o:"",references:[]}});return nn({root:i,projects:a,sharedConfig:c})}
6
+ export{Hr,Kr,nn,oo,qr,Jr,ao};
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ var r=/^\/\/\/\s*<reference\s+(?:path|types|lib|no-default-lib)\s*=\s*["'][^"']+["']\s*\/>/,E=/^\/\/\/\s*<amd-module\s+name\s*=\s*["'][^"']+["']\s*\/>/,f=/^\/\/\/\s*<amd-dependency\s+path\s*=\s*["'][^"']+["']/;function hn(t){let l=[],a=0;for(let e=0;e<=t.length;e++)if(e===t.length||t[e]===`
3
+ `){let n=a,i=e;while(n<i&&(t[n]===" "||t[n]==="\t"||t[n]==="\r"))n++;while(i>n&&(t[i-1]===" "||t[i-1]==="\t"||t[i-1]==="\r"))i--;let s=t.slice(n,i);if(a=e+1,s.startsWith("///")){if(s.indexOf("<")===-1)continue;if(r.test(s)||E.test(s)||f.test(s))l.push(s)}else if(s===""||s.startsWith("//"))continue;else break}return l}
4
+ export{hn};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{t}from"./chunk-1j6092xz.js";function q(r,i){if(i.kind!=="punctuation")return 0;let u=r.slice(i.start,i.end);if("([{<".includes(u))return 1;if(")]}".includes(u)||u===">"&&r[i.start-1]!=="=")return-1;return 0}function Ae(r){if(!r.includes("?"))return r;let i=r.trim(),u=i.startsWith("(")&&i.endsWith(")"),c=r.indexOf(i)+(u?1:0),o=u?i.slice(1,-1):i,a=[[]],x=0;for(let n of t(o)){if(n.kind==="punctuation"&&o[n.start]===","&&x===0)a.push([]);else a[a.length-1].push(n);x+=q(o,n)}let g=a.map((n)=>{let e=0,s=-1;for(let[T,p]of n.entries()){if(e===0&&p.kind==="punctuation"&&o[p.start]===":"){s=T;break}e+=q(o,p)}let d=s>0&&o[n[s-1].start]==="?"?n[s-1]:void 0,b=n[0]?o.slice(n[0].start,n[0].end):"",m=n[0]&&o.startsWith("...",n[0].start);return{tokens:n,colon:s,question:d,required:n.length>0&&!d&&!m&&b!=="this"}}),y=-1;for(let[n,e]of g.entries())if(e.required)y=n;let f=[];for(let[n,e]of g.entries()){if(n>=y||!e.question||e.colon<0)continue;let s=e.tokens[e.colon+1],d=e.tokens.at(-1);if(!s||!d)continue;f.push({start:c+e.question.start,end:c+e.question.end,text:""},{start:c+s.start,end:c+s.start,text:"("},{start:c+d.end,end:c+d.end,text:") | undefined"})}if(!f.length)return r;let l=[],h=0;for(let n of f)l.push(r.slice(h,n.start),n.text),h=n.end;return l.push(r.slice(h)),l.join("")}
3
+ export{Ae};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{s}from"./chunk-0azm93j9.js";class Le{options;generateOptions;constructor(t={}){let{onCompile:r=!1,afterEmit:e=!0,onWatchRun:n=!1,onGenerated:o,onError:i,...a}=t;this.options={onCompile:r,afterEmit:e,onWatchRun:n,onGenerated:o,onError:i},this.generateOptions=a}apply(t){if(!this.generateOptions.outdir&&t.options.output?.path)this.generateOptions.outdir=t.options.output.path;if(!this.generateOptions.cwd&&t.options.context)this.generateOptions.cwd=t.options.context;if(!this.generateOptions.entrypoints&&t.options.entry){let e=t.options.entry;if(typeof e==="string")this.generateOptions.entrypoints=[e];else if(Array.isArray(e))this.generateOptions.entrypoints=e;else if(typeof e==="object"&&e!==null){let n=[];for(let o of Object.values(e))if(typeof o==="string")n.push(o);else if(Array.isArray(o))n.push(...o.filter((i)=>typeof i==="string"));else if(typeof o==="object"&&o!==null&&"import"in o){let i=o.import;if(typeof i==="string")n.push(i);else if(Array.isArray(i))n.push(...i)}if(n.length>0)this.generateOptions.entrypoints=n}}if(this.options.onCompile)t.hooks.compile.tap("DtsxWebpackPlugin",()=>{this.runGenerate()});if(this.options.afterEmit)t.hooks.afterEmit.tapAsync("DtsxWebpackPlugin",async(e,n)=>{await this.runGenerate(),n()});if(this.options.onWatchRun)t.hooks.watchRun.tapAsync("DtsxWebpackPlugin",async(e,n)=>{await this.runGenerate(),n()})}async runGenerate(){try{let t=await s(this.generateOptions);this.options.onGenerated?.(t)}catch(t){let r=t instanceof Error?t:Error(String(t));if(this.options.onError?.(r),!this.options.onError)console.error("[dtsx] Generation failed:",r.message)}}}function It(t={}){return new Le(t)}var Xn=It,ba=Le;
3
+ export{Le,It,Xn,ba};
@@ -0,0 +1,14 @@
1
+ // @bun
2
+ import{tt}from"./chunk-dfye109x.js";import{S}from"./chunk-v44crx69.js";import{pn}from"./chunk-n37yj3xv.js";import{be}from"./chunk-vae5wxar.js";import{oe}from"./chunk-rmdwvzgn.js";import y from"process";import{readdir as v}from"fs/promises";import{join as C,resolve as D}from"path";function Ve(){return`${String.fromCharCode(47,47,35)} sourceMappingURL=`}function $o(n,r){throw Error(r||`Unexpected value: ${n}`)}async function _(n,r,o="lf"){let t=r.replace(/\r\n/g,`
3
+ `);if(!t.endsWith(`
4
+ `))t+=`
5
+ `;if(o==="crlf")t=t.replace(/\n/g,`\r
6
+ `);if(await tt(n,t)!==Buffer.byteLength(t,"utf8"))throw Error(`Incomplete declaration write: ${n}`)}async function si(n){let r=n??S.root,o=await v(r,{withFileTypes:!0});return(await Promise.all(o.map((i)=>{let c=C(r,i.name);return i.isDirectory()?si(c):c}))).flat(1/0).filter((i)=>{if(typeof i!=="string")return!1;return/\.(?:ts|tsx|mts|cts)$/.test(i)&&!/\.d\.(?:ts|mts|cts)$/.test(i)})}async function q(n){try{let r=n?.cwd||y.cwd();return(await oe(D(r,n?.tsconfigPath||"tsconfig.json"),{allowCircular:!0}))?.isolatedDeclarations??!1}catch{return!1}}function mt(n,r){let o={isValid:!0,errors:[]};for(let t of be(n))o.errors.push({line:t.line,column:t.column,message:t.message,code:t.code});for(let t of pn(n))o.errors.push({line:t.line,column:1,message:`'${t.name}' is used but never declared or imported here, so it resolves to an error type for anything consuming this file. It is most likely an ambient global in the source project \u2014 import it explicitly. Referenced by: ${t.context}`,code:"dangling-type-reference"});return o.isValid=o.errors.length===0,o}function gt(n,r,o){if(n===r)return"";let t=n.split(`
7
+ `),i=r.split(`
8
+ `),c=new Map,a=new Map;for(let e=0;e<t.length;e++)c.set(t[e],(c.get(t[e])??0)+1);for(let e=0;e<i.length;e++)a.set(i[e],(a.get(i[e])??0)+1);let g=[],u=[];for(let[e,s]of c){let m=s-(a.get(e)??0);for(let l=0;l<m;l++)g.push(e)}for(let[e,s]of a){let m=s-(c.get(e)??0);for(let l=0;l<m;l++)u.push(e)}if(g.length===0&&u.length===0)return"";let p=[`--- ${o}`,`+++ ${o}`];for(let e=0;e<g.length;e++)p.push(`- ${g[e]}`);for(let e=0;e<u.length;e++)p.push(`+ ${u[e]}`);return p.join(`
9
+ `)}function ht(n,r,o,t){let i=n.split(`
10
+ `),c=[];function a(s){let l="",f=s<0?-s<<1|1:s<<1;do{let d=f&31;if(f>>>=5,f>0)d|=32;l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[d]}while(f>0);return l}let g=0,u=0,p=0,e=t.split(`
11
+ `).length;for(let s=0;s<i.length;s++){if(i[s].trim()===""){c.push("");continue}g=0;let l=Math.min(s,e-1),f=[],d=0-g,h=0,w=l-u,x=0-p;f.push(a(d)+a(h)+a(w)+a(x)),g=0,u=l,p=0,c.push(f.join(","))}return{version:3,file:r,sourceRoot:"",sources:[o],sourcesContent:[t],mappings:c.join(";")}}function yt(n,r){return`${n}
12
+ ${Ve()}${r}
13
+ `}
14
+ export{Ve,$o,_,si,q,mt,gt,ht,yt};
@@ -0,0 +1,8 @@
1
+ // @bun
2
+ import{he}from"./chunk-xb92nrsm.js";import{e}from"./chunk-km8t8gqg.js";import{De,V}from"./chunk-d43bpfk6.js";import{existsSync as S}from"fs";import{basename as D,dirname as M,extname as R,isAbsolute as b,relative as p,resolve as m}from"path";var{Glob:j}=globalThis.Bun;async function me(r,o){let s=await N(r);F(r,s);let n=s.slice(),a=await(o?o():De(r)),t=null;if(r.autoIncludeReExports!==!1&&n.length>0){t=await V(n,{includeImports:!0,resolveSpecifier:a});let l=m(r.cwd,r.root),u=r.exclude||[],f=[];for(let c of t.reachable){if(n.includes(c))continue;if(!x(c))continue;if(c.endsWith(".d.ts"))continue;if(c.includes("node_modules"))continue;let E=r.outputStructure==="flat"&&s.some((O)=>a.isPackageLocal?.(O,c));if(!v(c,l)&&!E){e.warn(`Skipping auto-included source outside root: ${p(r.cwd,c)}`);continue}if(J(c,u,l))continue;f.push(c)}if(f.length>0)n=[...n,...f],e.debug(`Auto-included ${f.length} file(s) reached via relative re-exports`)}let i=A(n,r),d=t??await V(n,{includeImports:!0,resolveSpecifier:a}),g=await he([...d.sources.keys()],a,r.isolatedDeclarations??!1,d.sources),h=new Set(n);for(let[l,u]of g){if(!h.has(l))continue;for(let f of u){let c=a(f,l).resolved;if(c&&!h.has(c))throw Error(`Module augmentation import ${JSON.stringify(f)} from ${l} requires a source not emitted by this package build: ${c}`)}}let y=[...g].map(([l,u])=>[l,[...u].sort()]).sort(([l],[u])=>l.localeCompare(u));return Object.freeze({entryFiles:Object.freeze(s),files:Object.freeze(n),outputBySource:i,resolver:a,reachability:t,augmentationImports:g,getResolutionFingerprint:()=>JSON.stringify({resolution:a.cacheKey?.(n),augmentations:y})})}var P=50,w=new Map;function k(r){let o=w.get(r);if(!o){if(o=new j(r),w.set(r,o),w.size>P){let s=w.keys().next().value;if(s!==void 0)w.delete(s)}}return o}function J(r,o,s){if(!o||o.length===0)return!1;let n=p(s,r);for(let a of o){let t=k(a);if(t.match(n)||t.match(r))return!0}return!1}var C=/[*?[\]{}!]/;function F(r,o){let s=m(r.cwd,r.root),n=` root: ${s}
3
+ entrypoints: ${r.entrypoints.map((t)=>JSON.stringify(t)).join(", ")||"(none)"}
4
+ `+(r.exclude?.length?` exclude: ${r.exclude.map((t)=>JSON.stringify(t)).join(", ")}
5
+ `:"")+"Entrypoints are resolved relative to --root. Pass several by repeating --entrypoints or separating them with commas.";if(o.length===0){if(r.entrypoints.filter((i)=>b(i)&&S(i)&&!v(i,s)).length===r.entrypoints.length)return;throw Error(`No source files matched. Nothing was generated.
6
+ ${n}`)}let a=r.entrypoints.filter((t)=>{if(C.test(t))return!1;return!S(b(t)?t:m(s,t))});if(a.length>0)throw Error(`Entrypoint${a.length>1?"s":""} not found: ${a.map((t)=>JSON.stringify(t)).join(", ")}
7
+ ${n}`)}async function N(r){let o=[],s=m(r.cwd,r.root),n=r.exclude||[],a=[...r.entrypoints,...r.include??[]];for(let t of a)if(b(t)&&x(t)){if(!t.includes("node_modules")){if(!v(t,s)&&r.outputStructure!=="flat")e.warn(`Skipping entrypoint outside root: ${p(r.cwd,t)}`);else if(!J(t,n,s))o.push(t)}}else{let i=new j(t);for await(let d of i.scan({cwd:s,absolute:!0,onlyFiles:!0}))if(x(d)&&!d.includes("node_modules")){if(!J(d,n,s))o.push(d)}}return[...new Set(o.map((t)=>m(t)))].sort()}function v(r,o){let s=p(o,r);return s!==".."&&!s.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!b(s)}function A(r,o){let s=new Map,n=new Map;for(let a of r){let t=G(a,o),i=s.get(t);if(i&&i!==a)throw Error(`Output path collision: ${p(o.cwd,i)} and ${p(o.cwd,a)} both emit ${p(o.cwd,t)}`);s.set(t,a),n.set(a,t)}return n}function x(r){return/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/.test(r)&&!/\.d\.(?:ts|mts|cts)$/.test(r)}function G(r,o){let s=m(o.cwd,o.root),n=p(s,r),a=/\.d\.(?:ts|mts|cts)$/.test(n)?n:n.replace(/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/,(t)=>{if(t===".mts"||t===".mjs")return".d.mts";if(t===".cts"||t===".cjs")return".d.cts";return".d.ts"});if(o.outputStructure==="mirror")return m(o.cwd,o.outdir,a);else{let t=D(a);return m(o.cwd,o.outdir,t)}}function Eo(r,o,s=""){let n=p(M(r),o).replace(/\\/g,"/");if(n=n.replace(/\.d\.mts$/,"").replace(/\.d\.cts$/,"").replace(/\.d\.ts$/,""),s)n+=s;if(!n.startsWith("."))n=`./${n}`;return n}function ge(r,o,s,n){let a=G(r,o);return(t)=>{let i=s(t,r);if(!i.isRelative||!i.resolved)return{kind:"unchanged",reason:i.isRelative?"unresolved":"external",specifier:t,emittedSpecifier:t};if(/\.d\.(?:ts|mts|cts)$/.test(i.resolved)){if(o.moduleSpecifierMode!=="node")return{kind:"unchanged",reason:"preserved-declaration",specifier:t,emittedSpecifier:t};if(n&&!n.has(i.resolved))throw Error(`Local declaration ${JSON.stringify(t)} from ${r} targets an authored declaration not emitted by this package build: ${i.resolved}. Declaration-only dependencies must be delivered with the package before this importer can be emitted.`)}if(i.isAlias&&n&&!n.has(i.resolved))throw Error(`Local alias ${JSON.stringify(t)} from ${r} targets a declaration excluded from this package build: ${i.resolved}`);if(n&&!n.has(i.resolved)&&J(i.resolved,o.exclude??[],m(o.cwd,o.root)))throw Error(`Local reference ${JSON.stringify(t)} from ${r} targets a source excluded from this package build: ${i.resolved}`);let d=i.isAlias?i.suffix??"":t.match(/[?#].*$/)?.[0]??"",g=d?t.slice(0,-d.length):t,h=R(g),y=/^(?:\.js|\.jsx|\.mjs|\.cjs)$/.test(h)?h:"";if(!y&&o.moduleSpecifierMode==="node"){let u=R(i.resolved);y=u===".mts"||u===".mjs"?".mjs":u===".cts"||u===".cjs"?".cjs":".js"}let l=G(i.resolved,o);return{kind:"local",specifier:t,resolvedSource:i.resolved,declarationOutput:l,emittedSpecifier:Eo(a,l,y)+d}}}
8
+ export{me,J,v,G,Eo,ge};
@@ -0,0 +1,24 @@
1
+ // @bun
2
+ import{t}from"./chunk-1j6092xz.js";import{jn,_n,Gn}from"./chunk-n2nyd0ck.js";import{Ae}from"./chunk-69dbf6de.js";import{Te}from"./chunk-rdzfdjkb.js";var Q=20,Y=!1,M=null;function _(e){return mt(e).replace(/\n[ \t]*(?=\n)/g,"")}function mt(e){if(e.indexOf("/*")===-1)return e.trim();let r=[],s=0,i=0,l=e.length;while(i<l)if(e.charCodeAt(i)===47&&i+1<l&&e.charCodeAt(i+1)===42){if(i>s)r.push(e.substring(s,i));i+=2;while(i<l-1){if(e.charCodeAt(i)===42&&e.charCodeAt(i+1)===47){i+=2;break}i++}s=i}else i++;if(s<l)r.push(e.substring(s));return r.join("").trim()}function Pt(){Y=!0,M=null}function Dt(){Y=!1;let e=M;return M=null,e}function it(e){let c=e.length;if(c===0)return!1;let r=0;if(e.charCodeAt(r)===45)r++;if(r>=c)return!1;let s=r;while(r<c&&e.charCodeAt(r)>=48&&e.charCodeAt(r)<=57)r++;if(r===s)return!1;if(r<c&&e.charCodeAt(r)===46){r++;let i=r;while(r<c&&e.charCodeAt(r)>=48&&e.charCodeAt(r)<=57)r++;if(r===i)return!1}return r===c}function xt(e){for(let c=0,r=e.length-1;c<r;c++){let s=e.charCodeAt(c);if(s<48||s>57)return!1}return!0}function Z(e,c){let r=0,s=0;while((s=e.indexOf(c,s))!==-1)r++,s+=c.length;return r}function lt(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 z(e){let c=e.trim();if(c.length<3||c.charCodeAt(0)!==60)return!1;if(c.startsWith("<>"))return c.endsWith("</>");let r=c.charCodeAt(1);if(!(r>=65&&r<=90||r>=97&&r<=122||r===36||r===95))return!1;let i=2;while(i<c.length&&lt(c.charCodeAt(i)))i++;let l=c.slice(1,i),f=c.charCodeAt(i);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&&lt(c.charCodeAt(a)))a++;return c.slice(u+2,a)===l&&c.charCodeAt(a)===62&&a===c.length-1}function X(e){let c=e.length,r=!1;for(let f=1;f<c;f++)if(e.charCodeAt(f)<=32&&e.charCodeAt(f-1)<=32){r=!0;break}if(!r)for(let f=0;f<c;f++){let u=e.charCodeAt(f);if(u===10||u===13||u===9){r=!0;break}}if(!r)return e;let s=[],i=-1,l=!1;for(let f=0;f<c;f++)if(e.charCodeAt(f)<=32){if(!l){if(i>=0)s.push(e.substring(i,f));s.push(" "),l=!0,i=-1}}else{if(l||i<0)i=f;l=!1}if(i>=0)s.push(e.substring(i));return s.join("")}function n(e,c=!1,r=!1,s=0,i){if(!e||typeof e!=="string")return"unknown";if(s>=Q)return"unknown";let l=e.trim();if(z(l))return"JSX.Element";if(l.startsWith("BigInt("))return"bigint";if(l.startsWith("Symbol.for("))return"symbol";if(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 u=$t(l);if(u!==null){if(u==="string"||!c)return"string";return u}}if(it(l)){if(!c)return"number";return 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 $e(l,c,s+1,i);if(l.startsWith("{")&&l.endsWith("}"))return Ze(l,c,s+1,i);if(l.startsWith("class ")||l.startsWith("class{"))return Kt(l);if(l.startsWith("new "))return Bt(l);if(l.endsWith("as const")){let u=l.slice(0,-8).trim();if(u.startsWith("[")&&u.endsWith("]")){let a=u.slice(1,-1).trim();if(!a)return"readonly []";let h=re(a),p=[];for(let y=0;y<h.length;y++){let A=h[y].trim();if(A.startsWith("...")){let m=A.slice(3).trim();if(F(m))p.push(`...typeof ${m}`);else{let g=n(m,!0,!1,s+1,i);p.push(g.startsWith("readonly [")||g.endsWith("[]")?`...${g}`:"...unknown[]")}}else p.push(n(A,!0,!1,s+1,i))}return`readonly [${p.join(", ")}]`}return n(u,!0,r,s+1,i)}if(q(l)!==-1||l.startsWith("function")||l.startsWith("async"))return Qe(l,r,s,c);if(l.startsWith("`")&&l.endsWith("`"))return Nt(l,c);if(l.startsWith("Promise."))return yt(l,c,s,i);if(l.startsWith("await "))return"unknown";if(l.startsWith("typeof ")&&U(l.slice(7)))return"string";if(l.startsWith("void ")&&U(l.slice(5)))return"undefined";if(l.startsWith("delete ")&&U(l.slice(7)))return"boolean";if(l.charCodeAt(l.length-1)===110&&l.length>1&&xt(l)){if(c)return l;return"bigint"}if(l.startsWith("Symbol(")||l==="Symbol.for")return"symbol";let f=Ee(l);if(f!==null)return f;if(pt(l))return"boolean";if(St(l))return"number";return"unknown"}function ft(e){let c=e.charCodeAt(0);if(c!==39&&c!==34)return!1;return B(e,0,c)===e.length}function $t(e){if(ft(e))return e;let c=bt(e);if(c.length<2)return null;let r=!1,s=!0,i="";for(let l of c){let f=l.trim();if(ft(f))r=!0,i+=Tt(f);else s=!1}if(s)return kt(i);if(r)return"string";return null}function bt(e){let c=[],r=0,s=0,i=0;while(i<e.length){let l=e.charCodeAt(i);if(l===39||l===34||l===96){i=B(e,i,l);continue}if(l===40||l===91||l===123)r++;else if(l===41||l===93||l===125)r--;else if(l===43&&r===0)c.push(e.slice(s,i)),s=i+1;i++}return c.push(e.slice(s)),c}function Tt(e){return e.slice(1,-1).replace(/\\(.)/g,(r,s)=>{if(s==="n")return`
4
+ `;if(s==="t")return"\t";if(s==="r")return"\r";if(s==="0")return"\x00";return s})}function kt(e){return`'${e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`}function St(e){if(e==="")return!1;let c=!1,r=!1;for(let s=0;s<e.length;s++){let i=e.charCodeAt(s);if(i>=48&&i<=57){c=!0;continue}if(i===43||i===45||i===42||i===47||i===37){r=!0;continue}if(i===46||i===40||i===41||i<=32)continue;return!1}return c&&r}function pt(e){let c=0;for(let r=0;r<e.length;r++){let s=e.charCodeAt(r);if(s===34||s===39||s===96){r=B(e,r,s)-1;continue}if(s===40||s===91||s===123){c++;continue}if(s===41||s===93||s===125){c--;continue}if(c!==0)continue;if(e.startsWith("===",r)||e.startsWith("!==",r)||e.startsWith("==",r)||e.startsWith("!=",r)||e.startsWith(">=",r)||e.startsWith("<=",r))return!0;if((s===62||s===60)&&e.charCodeAt(r-1)!==61&&e.charCodeAt(r+1)!==61)return!0}return!1}function Rt(e,c=!1,r=0,s){return n(e,c,!0,r,s)}function O(e,c=!1,r="",s,i){let l=v(r,s),f=[],u=!1,a=0;while(a<e.length){let p=e.charCodeAt(a);if(p===34||p===39||p===96){a=B(e,a,p);continue}if(p===47&&e.charCodeAt(a+1)===47){a+=2;while(a<e.length&&e.charCodeAt(a)!==10&&e.charCodeAt(a)!==13)a++;continue}if(p===47&&e.charCodeAt(a+1)===42){let A=e.indexOf("*/",a+2);a=A===-1?e.length:A+2;continue}if(e.startsWith("function",a)&&G(e,a,8)||e.startsWith("class",a)&&G(e,a,5)){let A=jt(e,a);if(A!==-1){a=H(e,A);continue}}if(p===61&&e.charCodeAt(a+1)===62){let A=At(e,a+2);if(e.charCodeAt(A)===123){a=H(e,A);continue}}if(e.startsWith("return",a)&&(a===0||!R(e.charCodeAt(a-1)))&&!R(e.charCodeAt(a+6))){a+=6;let A=!1;while(a<e.length&&e.charCodeAt(a)<=32){let x=e.charCodeAt(a);if(x===10||x===13)A=!0;a++}if(A||a>=e.length||e.charCodeAt(a)===59||e.charCodeAt(a)===125){u=!0;continue}let m=a,g=0,C=0,d=0;while(a<e.length){let x=e.charCodeAt(a);if(x===34||x===39||x===96){a=B(e,a,x);continue}if(x===47&&e.charCodeAt(a+1)===47){if(g===0&&C===0&&d===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)g++;else if(x===41)g--;else if(x===91)C++;else if(x===93)C--;else if(x===123)d++;else if(x===125){if(d===0&&g===0&&C===0)break;d--}else if(x===59&&g===0&&C===0&&d===0)break;else if((x===10||x===13)&&g===0&&C===0&&d===0){let T=a+1;while(T<e.length&&e.charCodeAt(T)<=32)T++;if(e.startsWith("return",T)&&!R(e.charCodeAt(T+6)))break}a++}let w=e.slice(m,a).trim(),b=_(K(w,l,s,i,m));if(!f.includes(b))f.push(b);continue}a++}if(u&&!f.includes("undefined"))f.push("undefined");let h=f.includes("unknown")?"unknown":f.length===0?"void":Ct(f);return c&&!h.startsWith("Promise<")?`Promise<${h}>`:h}function v(e,c){let r=new Map,s=e.startsWith("(")&&e.endsWith(")")?e.slice(1,-1):e,i=t(s),l=0,f=0,u=[];for(let a of i){let h=s.slice(a.start,a.end);if(h===","&&f===0)u.push(s.slice(l,a.start)),l=a.end;if(["(","[","{","<"].includes(h))f++;else if([")","]","}"].includes(h)||h===">"&&s[a.start-1]!=="=")f--}u.push(s.slice(l));for(let a of u){let h=t(a),p=-1,y=-1,A=0;for(let C of h){let d=a.slice(C.start,C.end);if(A===0&&d===":"&&p===-1)p=C.start;if(A===0&&d==="="&&a[C.end]!==">"){y=C.start;break}if(["(","[","{","<"].includes(d))A++;else if([")","]","}"].includes(d)||d===">"&&a[C.start-1]!=="=")A--}let m=a.slice(0,p!==-1?p:y!==-1?y:void 0).trim().replace(/^\.\.\./,"").replace(/\?$/,"");if(!J(m))continue;let g=p!==-1?a.slice(p+1,y!==-1?y:void 0).trim():"";if(!g&&y!==-1){let C=a.slice(y+1).trim();g=c?.(C)??n(C,!1)}if(g){if(y===-1&&a.slice(0,p).trim().endsWith("?"))g=`(${g}) | undefined`;r.set(m,g)}}return r}function Ot(e,c){if(e=e.trim(),!e.startsWith("{")||!e.endsWith("}"))return;let r=e.slice(1,-1),s=t(r),i=0,l=0;for(let f=0;f<=s.length;f++){let u=s[f],a=u?r.slice(u.start,u.end):";";if(l===0&&(a===";"||a===",")){let h=r.slice(i,u?.start).trim(),p=h.indexOf(":");if(p!==-1&&h.slice(0,p).trim()===c)return h.slice(p+1).trim();i=u?.end??r.length}if(["(","[","{","<"].includes(a))l++;else if([")","]","}"].includes(a)||a===">"&&u&&r[u.start-1]!=="=")l--}return}function K(e,c,r,s,i=0,l=0){if(l>=Q)return"unknown";let f=e.trim();while(st(f))f=f.slice(1,-1).trim();let u=r?.(f);if(u)return u;if(z(f))return"JSX.Element";if(f.startsWith("await ")){let d=K(f.slice(6),c,r,s,i,l+1);return d.startsWith("Promise<")&&d.endsWith(">")?d.slice(8,-1):d}if(c.has(f))return c.get(f);let a=/^([\w$]+)\.([\w$]+)$/.exec(f);if(a){let d=c.get(a[1]),w=d&&Ot(d,a[2]);if(w)return w}if(f.startsWith("!"))return"boolean";if(f.startsWith("fetch("))return"Promise<Response>";if(Et(f))return n(f,!1);let h=Mt(f);if(h){let d=K(h.whenTrue,c,r,s,i,l+1),w=K(h.whenFalse,c,r,s,i,l+1);return d===w?d:Ct([d,w])}let p=It(f);if(p&&s)return s(p,i);if(pt(f))return"boolean";let y=0;for(let d=f.length-1;d>=0;d--){let w=f.charCodeAt(d);if(w===41||w===93||w===125)y++;else if(w===40||w===91||w===123)y--;else if(y===0&&(w===43||w===45||w===42||w===47||w===37)){let b=K(f.slice(0,d),c,r,s,i,l+1),x=K(f.slice(d+1),c,r,s,i,l+1);if(w===43&&(b==="string"||x==="string"))return"string";if(b==="number"&&x==="number")return"number";break}}let A=f.startsWith("{")&&f.endsWith("}")?Ze(f,!1,l+1,void 0,(d)=>K(d,c,r,s,i,l+1)):n(f,!1),m=t(A),g="",C=0;for(let d=0;d<m.length;d++){let w=m[d];if(w.kind!=="word"||A.slice(w.start,w.end)!=="typeof")continue;let b=m[d+1];if(!b||b.kind!=="word")continue;let x=c.get(A.slice(b.start,b.end)),T=!x,k=w.start,S=b.end,E=d;d++;while(m[d+1]&&A.slice(m[d+1].start,m[d+1].end)==="."&&m[d+2]?.kind==="word"){let L=m[d+2];if(!T)x=`(${x})["${A.slice(L.start,L.end)}"]`;S=L.end,d+=2}if(T&&E>=2&&A.slice(m[E-2].start,m[E-2].end)==="ReturnType"&&A.slice(m[E-1].start,m[E-1].end)==="<"&&m[d+1]&&A.slice(m[d+1].start,m[d+1].end)===">")k=m[E-2].start,S=m[++d].end;g+=A.slice(C,k)+(x??"unknown"),C=S}return g+A.slice(C)}function It(e){let c=t(e),r=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))r++;else if([")","]","}"].includes(u))r--;else if(!r&&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 i=e.slice(c[s].end).trim();if(i==="const")return;r=0;for(let l of c.slice(s+1)){if(l.kind!=="punctuation")continue;let f=e.slice(l.start,l.end);if(["(","[","{","<"].includes(f))r++;else if([")","]","}",">"].includes(f))r--;else if(!r&&["+","-","*","/","%","=","!",";"].includes(f))return}return i}function Ct(e){return e.map((c)=>e.length>1&&q(c)!==-1?`(${c})`:c).join(" | ")}function at(e){let c=0;while(c<e.length){let i=e.charCodeAt(c);if(i<=32)c++;else if(i===47&&e.charCodeAt(c+1)===47){c+=2;while(c<e.length&&e.charCodeAt(c)!==10&&e.charCodeAt(c)!==13)c++}else if(i===47&&e.charCodeAt(c+1)===42){let l=e.indexOf("*/",c+2);c=l===-1?e.length:l+2}else break}let r=c,s=c;while(s<e.length){let i=e.charCodeAt(s);if(i===34||i===39||i===96){s=B(e,s,i),r=s;continue}if(i===92){s=Math.min(s+2,e.length),r=s;continue}if(i===47&&e.charCodeAt(s+1)===47){while(s<e.length&&e.charCodeAt(s)!==10&&e.charCodeAt(s)!==13)s++;continue}if(i===47&&e.charCodeAt(s+1)===42){let l=e.indexOf("*/",s+2);s=l===-1?e.length:l+2;continue}if(s++,i>32)r=s}return e.slice(c,r)}function U(e){let c=0;for(let r=0;r<e.length;r++){let s=e[r];if(s==="'"||s==='"'||s==="`"){let i=r+1;while(i<e.length&&e[i]!==s){if(e[i]==="\\")i++;i++}r=i;continue}if(s==="("||s==="["||s==="{")c++;else if(s===")"||s==="]"||s==="}")c--;else if(c!==0)continue;else if(s==="?"){if(e[r+1]!==".")return!1}else if("=!<>&|+-*/%,:".includes(s))return!1;else if(s===" "||s==="\t"||s===`
5
+ `||s==="\r"){let i=e.slice(r).trimStart();if(i&&i[0]!=="."&&i[0]!=="?"&&i[0]!=="("&&i[0]!=="[")return!1}}return!0}function Et(e){if(e.startsWith("function")&&G(e,0,8))return!0;let c=q(e);if(c===-1)return!1;let r=e.slice(0,c).trim();if(r.startsWith("async")&&G(r,0,5))r=r.slice(5).trim();if(r.startsWith("<")){let i=o(r,0,"<",">");if(i===-1)return!1;r=r.slice(i+1).trim()}if(r.startsWith("(")){let i=o(r,0,"(",")");if(i===-1)return!1;let l=r.slice(i+1).trim();if(l&&!l.startsWith(":"))return!1}let s=rt(r);return st(s.params)||J(s.params)}function st(e){if(!e.startsWith("(")||!e.endsWith(")"))return!1;let c=0;for(let r=0;r<e.length;r++){let s=e.charCodeAt(r);if(s===40)c++;else if(s===41&&--c===0)return r===e.length-1}return!1}function Mt(e){let c=0,r=-1;for(let s=0;s<e.length;s++){let i=e.charCodeAt(s);if(i===34||i===39||i===96){s=B(e,s,i)-1;continue}if(i===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(i===40||i===91||i===123)c++;else if(i===41||i===93||i===125)c--;else if(i===63&&c===0&&e.charCodeAt(s+1)!==63)r=s;else if(i===58&&c===0&&r!==-1)return{whenTrue:at(e.slice(r+1,s)),whenFalse:at(e.slice(s+1))}}return null}function G(e,c,r){return(c===0||!R(e.charCodeAt(c-1)))&&!R(e.charCodeAt(c+r))}function At(e,c){let r=c;while(r<e.length){if(e.charCodeAt(r)<=32){r++;continue}if(e.startsWith("//",r)){while(r<e.length&&e.charCodeAt(r)!==10&&e.charCodeAt(r)!==13)r++;continue}if(e.startsWith("/*",r)){let s=e.indexOf("*/",r+2);r=s<0?e.length:s+2;continue}break}return r}function jt(e,c){let r=0,s=0,i=0,l=!1,f=!1;for(let u=c;u<e.length;u++){if(u=At(e,u),u>=e.length)break;let a=e.charCodeAt(u);if(a===34||a===39||a===96){u=B(e,u,a)-1,f=!1;continue}if(R(a)||a>=128){let h=u;while(u+1<e.length&&(R(e.charCodeAt(u+1))||e.charCodeAt(u+1)>=128))u++;f=l&&["keyof","typeof","readonly","unique","new","abstract","infer","extends"].includes(e.slice(h,u+1));continue}if(a===61&&e.charCodeAt(u+1)===62){u++,f=l;continue}if(a===40)r++;else if(a===41)r--,f=!1;else if(a===91)s++;else if(a===93)s--,f=!1;else if(a===60&&r===0&&s===0)i++;else if(a===62&&i>0&&r===0&&s===0)i--,f=!1;else if(a===123)if(r||s||i||l&&f)u=H(e,u)-1,f=!1;else return u;else if(r===0&&s===0&&i===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 H(e,c){let r=1,s=c+1;while(s<e.length&&r>0){let i=e.charCodeAt(s);if(i===34||i===39||i===96){s=B(e,s,i);continue}if(i===47&&e.charCodeAt(s+1)===47){s+=2;while(s<e.length&&e.charCodeAt(s)!==10&&e.charCodeAt(s)!==13)s++;continue}if(i===47&&e.charCodeAt(s+1)===42){let l=e.indexOf("*/",s+2);s=l===-1?e.length:l+2;continue}if(i===123)r++;else if(i===125)r--;s++}return s}function B(e,c,r){let s=c+1;while(s<e.length){let i=e.charCodeAt(s);if(i===92){s+=2;continue}if(r===96&&i===36&&e.charCodeAt(s+1)===123){s=H(e,s+1);continue}if(s++,i===r)break}return s}function Nt(e,c){if(e.includes(".raw`")||e.includes("String.raw`"))return"string";if(!c||e.includes("${")||e.includes(`
6
+ `)||e.includes("\r"))return"string";return e}function Bt(e){let c=4;while(c<e.length&&e.charCodeAt(c)<=32)c++;let r=c,s=e.charCodeAt(c);if(s<65||s>90)return"unknown";while(c<e.length&&(R(e.charCodeAt(c))||e.charCodeAt(c)===46))c++;if(c===r)return"unknown";let i=e.slice(r,c);{let l=e.slice(c),f=l;if(l.startsWith("<")){let a=0,h=-1;for(let p=0;p<l.length;p++)if(l[p]==="<")a++;else if(l[p]===">"){if(a--,a===0){h=p;break}}if(h!==-1){let p=l.slice(0,h+1);f=l.slice(h+1);let y=f.indexOf("(");if(y!==-1){let A=0,m=-1;for(let g=y;g<f.length;g++)if(f[g]==="(")A++;else if(f[g]===")"){if(A--,A===0){m=g;break}}if(m!==-1){if(f.slice(m+1).trimStart().startsWith("."))return"unknown"}}return`${i}${p}`}}let u=f.indexOf("(");if(u!==-1){let a=0,h=-1;for(let p=u;p<f.length;p++)if(f[p]==="(")a++;else if(f[p]===")"){if(a--,a===0){h=p;break}}if(h!==-1){if(f.slice(h+1).trimStart().startsWith("."))return"unknown"}}switch(i){case"Date":return"Date";case"Map":return"Map<any, any>";case"Set":return"Set<any>";case"WeakMap":return"WeakMap<any, any>";case"WeakSet":return"WeakSet<any>";case"RegExp":return"RegExp";case"Error":return"Error";case"Array":return"any[]";case"Object":return"object";case"Function":return"Function";case"Promise":return"Promise<any>";default:return i}}return"unknown"}function Kt(e){return"{ new (...args: any[]): any }"}function yt(e,c,r=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,r+1,s)}>`}return"Promise<unknown>"}if(e.startsWith("Promise.reject("))return"Promise<never>";if(e.startsWith("Promise.all(")){let i=e.indexOf("[",12),l=e.lastIndexOf("]");if(i!==-1&&l>i){let f=e.slice(i+1,l).trim(),u=re(f),a=[];for(let h=0;h<u.length;h++){let p=u[h].trim();if(p.startsWith("Promise.resolve(")){let y=yt(p,c,r+1,s),A=y.indexOf("<"),m=y.lastIndexOf(">");a.push(A!==-1&&m>A?y.slice(A+1,m):"unknown")}else a.push(n(p,c,!1,r+1,s))}return`Promise<[${a.join(", ")}]>`}return"Promise<unknown[]>"}return"Promise<unknown>"}function $e(e,c,r=0,s){let i=e.slice(1,-1).trim();if(!i)return"never[]";if(r>=Q)return"unknown[]";let l=re(i),f=!1;for(let m=0;m<l.length;m++){let g=l[m],C=g.length;while(C>0&&g.charCodeAt(C-1)<=32)C--;if(C>=8&&g.slice(C-8,C)==="as const"){f=!0;break}}if(f){let m=[];for(let g=0;g<l.length;g++){let C=l[g].trim();if(C.endsWith("as const")){let d=C.slice(0,-8).trim();if(d.startsWith("[")&&d.endsWith("]")){let w=d.slice(1,-1).trim(),b=re(w),x=[];for(let T=0;T<b.length;T++)x.push(n(b[T].trim(),!0,!1,r+1,s));m.push(`readonly [${x.join(", ")}]`)}else m.push(n(d,!0,!1,r+1,s))}else if(C.startsWith("[")&&C.endsWith("]"))m.push($e(C,!0,r+1,s));else m.push(n(C,!0,!1,r+1,s))}return`readonly [
7
+ ${m.join(` |
8
+ `)}
9
+ ]`}let u=Y&&!c,a=[],h=[];for(let m of l){let g=m.trim(),C=M;if(M=null,g.startsWith("...")){let d=g.slice(3).trim(),w=n(d,!1,!1,r+1,s);if(w.endsWith("[]"))a.push(w.slice(0,-2));else if(w.startsWith("readonly [")&&w.endsWith("]"))a.push(w.slice(10,-1));else if(F(d))a.push(`(typeof ${d})[number]`);else a.push("unknown")}else if(g.startsWith("[")&&g.endsWith("]"))a.push($e(g,c,r+1,s));else a.push(Rt(g,c,r+1,s));if(u)h.push(M);M=C}if(u)if(et(e))M=X(e);else{let m=[];for(let g=0;g<l.length;g++){let C=l[g].trim();if(C.endsWith("as const"))continue;if(tt(C)||C==="null"||C==="undefined")m.push(C);else if(C.startsWith("[")&&et(C))m.push(X(C));else if(C.startsWith("{")){if(h[g])m.push(h[g])}else{let d=n(C,!1,!1,0,s);if(d!=="unknown")m.push(d)}}if(m.length>0)M=`[${m.join(", ")}]`}if(c)return`readonly [${a.join(", ")}]`;let p=new Set,y=[],A=!0;for(let m of a){if(!p.has(m))p.add(m),y.push(m);if(A){if(!(it(m)||m==="true"||m==="false"||m.charCodeAt(0)===34&&m.charCodeAt(m.length-1)===34||m.charCodeAt(0)===39&&m.charCodeAt(m.length-1)===39))A=!1}}if(A&&a.length<=10)return`readonly [${a.join(", ")}]`;if(y.length===1)return`${y[0]}[]`;return`(${y.join(" | ")})[]`}function re(e){let c=[],r=0,s=!1,i=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===i)s=!1;f=u+1;continue}if(a===47&&e.charCodeAt(u+1)===47){let h=e.indexOf(`
10
+ `,u+2);u=(h===-1?e.length:h)-1;continue}if(a===47&&e.charCodeAt(u+1)===42){let h=e.indexOf("*/",u+2);u=(h===-1?e.length:h+2)-1;continue}if(a===32||a===9||a===10||a===13)continue;if(a===44&&r===0){if(l!==-1)c.push(e.slice(l,f));l=-1;continue}if(a===34||a===39||a===96)s=!0,i=a;else if(a===91||a===123||a===40)r++;else if(a===93||a===125||a===41)r--;if(l===-1)l=u;f=u+1}if(l!==-1)c.push(e.slice(l,f));return c}function tt(e){if(it(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 et(e){let c=!1,r=0,s=e.length;for(let i=0;i<s;i++){let l=e.charCodeAt(i);if(c){if(l===92){i++;continue}if(l===r)c=!1;continue}if(l===34||l===39||l===96){c=!0,r=l;continue}if(l===61&&i+1<s&&e.charCodeAt(i+1)===62)return!1;if(l===47&&(e.charCodeAt(i+1)===47||e.charCodeAt(i+1)===42))return!1;if(l>=97&&l<=122){let f=i;while(i<s&&(e.charCodeAt(i)>=97&&e.charCodeAt(i)<=122||e.charCodeAt(i)>=65&&e.charCodeAt(i)<=90||e.charCodeAt(i)>=48&&e.charCodeAt(i)<=57||e.charCodeAt(i)===95||e.charCodeAt(i)===36))i++;let u=e.slice(f,i);if(u==="new"||u==="async"||u==="await"||u==="function"||u==="yield"||u==="console"||u==="process")return!1;let a=i;while(a<s&&e.charCodeAt(a)<=32)a++;if(a<s&&e.charCodeAt(a)===40)return!1;i--}}return!0}function Ze(e,c,r=0,s,i){let l=e.slice(1,-1).trim();if(!l)return"{}";if(r>=Q)return"Record<string, unknown>";let f=Gt(l),u=new Set(f.flatMap(([d])=>{let w=dt(nt(d).key);return w?.kind==="get"?[w.name]:[]})),a=[],h=[],p=[],y=!1,A=Y&&!c,m=[];for(let[d,w]of f){let{comments:b,key:x}=nt(d),T=b?`${b}
11
+ `:"",k=dt(x);if(k&&Gn(k.name))continue;let S=x,E=!1;if(x==="..."){let I=w.trim(),N=F(I)?`typeof ${I}`:n(I,c,!1,r+1,s);if(N!=="unknown")h.push(N);if(A&&(F(I)||I.startsWith("{")))m.push(`...${X(I)}`);continue}let L=M;M=null;let P,D=w.trim();if(D===x&&J(D))P=(c?void 0:s?.mutableBindingTypes?.get(D))??`typeof ${D}`;else if(Xt(D)){E=!0;let I=Ht(x);if(I){S=I.name;let N="";if(D.startsWith("async "))N="async ";if(D.charCodeAt(N.length)===42)N+="*";P=gt(I.name,N+I.typeParams+D.slice(N.length))}else P=gt(x,D)}else{if(P=i?.(w)??n(w,c,!1,r+1,s),P==="unknown"&&F(D))P=(c?void 0:s?.mutableBindingTypes?.get(D))??`typeof ${D}`;if(P.includes("=>")||P.includes("function")||P.includes("async"))P=ut(P)}let ct=M;M=L;let Wt=S,j=w.trim(),V=jn(S,s);if(!_n(k?.name??S,s)&&!(k?.kind==="set"&&u.has(k.name)))p.push(k?zt(k.kind,P):P);if(V&&"index"in V)y=!0;else{if(V&&"name"in V)S=V.name;if(k){let I=Jt(k.kind,k.name,P);if(I){a.push(`${T}${I}`);continue}}if(!c&&Lt(P)&&tt(j))a.push(`${T}/** @defaultValue ${Te(j)} */
12
+ ${S}: ${P}`);else a.push(`${T}${c?"readonly ":""}${S}: ${P}`)}if(A){let I=mt(Wt);if(j.endsWith("as const"));else if(tt(j))m.push(`${I}: ${j}`);else if(j.startsWith("[")&&et(j))m.push(`${I}: ${X(j)}`);else if(j.startsWith("{")){if(ct)m.push(`${I}: ${ct}`)}else if(E)m.push(`${I}: ${_(ut(P))}`);else if(!j.startsWith("[")&&(j.includes("=>")||j.startsWith("function")||j.startsWith("async"))){let N=Qe(j,!1,0,!0);m.push(`${I}: ${_(N)}`)}}}if(A&&m.length>0){let d=r>0?(r-1)/2:0,w=`{ ${m.join(", ")} }`;if(w.length<=80)M=w;else{let b=" ".repeat((d+1)*2),x=" ".repeat(d*2);M=`{
13
+ ${b}${m.join(`,
14
+ ${b}`)}
15
+ ${x}}`}}if(y&&h.length===0){let d=[...new Set(p)].map((w)=>w.includes("=>")||w.includes(" & ")?`(${w})`:w);a.unshift(`${c?"readonly ":""}[x: string]: ${d.join(" | ")}`)}let g=a.length>0?`{
16
+ ${a.join(`;
17
+ `)}
18
+ }`:"{}";if(h.length===0)return g;let C=h[0];for(let d=1;d<h.length;d++)C=`Omit<${C}, keyof ${h[d]}> & ${h[d]}`;return a.length>0?`Omit<${C}, keyof ${g}> & ${g}`:C}function J(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 r=1;r<e.length;r++)if(!R(e.charCodeAt(r)))return!1;return!0}function F(e){let c=e.split(".");return c.length>0&&c.every(J)}function Ft(e){let c=!1,r="";for(let s=0;s<e.length;s++){let i=e[s];if(c){if(i==="\\")s++;else if(i===r)c=!1;continue}if(i==='"'||i==="'"||i==="`"){c=!0,r=i;continue}if(i==="(")return s;if(i==="<"){let l=o(e,s,"<",">");if(l!==-1)s=l}}return-1}function Ee(e){if(e.length<3||!e.endsWith(")"))return null;let c=Ft(e);if(c===-1||o(e,c,"(",")")!==e.length-1)return null;let r=e.slice(0,c).trim(),s=!1;if(r.endsWith("?."))s=!0,r=r.slice(0,-2).trim();let i=r,l=!1,f=r.indexOf("<");if(f!==-1){if(o(r,f,"<",">")!==r.length-1)return null;i=r.slice(0,f).trim(),l=!0}if(!F(i))return null;let u=e.slice(c+1,-1).trim(),a=q(u)!==-1||u.startsWith("function")||u.startsWith("async function"),h=F(u),p=!a&&u.endsWith(")")&&Ee(u)!==null,y=i.indexOf(".");if(y!==-1){if(i.indexOf(".",y+1)!==-1)return null}else if(!l&&!s&&!a&&!h&&!p)return null;let A=`ReturnType<typeof ${r}>`;return s?`${A} | undefined`:A}function ut(e){let r=e.split(`
19
+ `).map((p)=>wt(p)).join(`
20
+ `),s=r.indexOf("async");if(s!==-1){let p=s>0?r.charCodeAt(s-1):32,y=s+5<r.length?r.charCodeAt(s+5):32;if(!R(p)&&!R(y))r=(r.slice(0,s)+r.slice(s+5)).trim()}let i=r.indexOf("(");if(i!==-1){let p=o(r,i,"(",")");if(p!==-1){let y=r.slice(i,p+1),A=ie(y);r=r.slice(0,i)+A+r.slice(p+1)}}let l=r.length,f="",u=[],a=!1,h=!1;for(let p=0;p<l;p++){let y=r.charCodeAt(p);if(y===123||y===40)u.push(y);else if(y===125||y===41)u.pop();if(y<=32){if(a=!0,y===10||y===13)h=!0;continue}if(a&&f.length>0){let m=(u.length>0?u[u.length-1]:0)===123;if(h&&m){let g=f.charCodeAt(f.length-1),C=g===59||g===44||g===123||y===125,d=f.length>=2&&f.charCodeAt(f.length-1)===47&&f.charCodeAt(f.length-2)===42;if(!C&&!d)f+="; ";else f+=" "}else f+=" "}a=!1,h=!1,f+=r[p]}return f.trim()}function R(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===95||e===36}function ie(e){let c=e.trim(),r,s=!1;if(c.startsWith("(")&&c.endsWith(")"))r=c.slice(1,-1),s=!0;else r=c;let i=r.trim();if(!i)return s?"()":"";let l=!1;{let g=0;for(let C=0;C<i.length;C++){let d=i.charCodeAt(C);if(d===40||d===60||d===91||d===123)g++;else if(d===41||d===93||d===125||d===62&&i.charCodeAt(C-1)!==61)g--;else if(g===0&&d===61){let w=C>0?i.charCodeAt(C-1):0,b=C+1<i.length?i.charCodeAt(C+1):0;if(w!==61&&w!==33&&w!==60&&w!==62&&b!==61&&b!==62){l=!0;break}}}}if(!l)return c;let f=[],u=[],a=0,h=0,p=!1,y=0;for(let g=0;g<=i.length;g++){if(g===i.length){f.push(i.slice(a));break}let C=i.charCodeAt(g);if(p){if(C===92){g++;continue}if(C===y)p=!1;continue}if(C===47&&g+1<i.length){let d=i.charCodeAt(g+1);if(d===42){g+=2;while(g+1<i.length&&!(i.charCodeAt(g)===42&&i.charCodeAt(g+1)===47))g++;g++;continue}if(d===47){while(g<i.length&&i.charCodeAt(g)!==10)g++;continue}}if(C===39||C===34||C===96){p=!0,y=C;continue}if(C===40||C===60||C===91||C===123)h++;else if(C===41||C===93||C===125||C===62&&i.charCodeAt(g-1)!==61)h--;else if(C===44&&h===0){f.push(i.slice(a,g));let d=",",w=g+1;while(w<i.length&&i.charCodeAt(w)<=32)d+=i[w],w++;u.push(d),a=w}}let A=[];for(let g of f){let C=g.trim();if(!C){A.push(g);continue}if(C.startsWith("//"))continue;let d=wt(C),w=g.slice(0,g.length-g.trimStart().length);A.push(w+qt(d))}let m=A[0]||"";for(let g=1;g<A.length;g++)m+=(u[g-1]||", ")+A[g];return Ae(s?`(${m})`:m)}function wt(e){let c=!1,r=0;for(let s=0;s<e.length-1;s++){let i=e.charCodeAt(s);if(c){if(i===92){s++;continue}if(i===r)c=!1;continue}if(i===39||i===34||i===96){c=!0,r=i;continue}if(i===47&&e.charCodeAt(s+1)===47)return e.slice(0,s).trimEnd()}return e}function qt(e){if(e.startsWith("..."))return e;let c=-1,r=-1,s=0,i=!1,l=0;for(let u=0;u<e.length;u++){let a=e.charCodeAt(u);if(i){if(a===92){u++;continue}if(a===l)i=!1;continue}if(a===47&&u+1<e.length){let h=e.charCodeAt(u+1);if(h===42){u+=2;while(u+1<e.length&&!(e.charCodeAt(u)===42&&e.charCodeAt(u+1)===47))u++;u++;continue}if(h===47){while(u<e.length&&e.charCodeAt(u)!==10)u++;continue}}if(a===39||a===34||a===96){i=!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&&r===-1&&(u===0||e.charCodeAt(u-1)!==61)&&(u+1>=e.length||e.charCodeAt(u+1)!==61&&e.charCodeAt(u+1)!==62))r=u}}let f=r!==-1;if(c!==-1&&(r===-1||c<r)){let u=e.slice(0,c).trim(),a=r!==-1?e.slice(c+1,r).trim():e.slice(c+1).trim(),h=f&&!u.endsWith("?")?"?":"";return`${u}${h}: ${a}`}else if(r!==-1){let u=e.slice(0,r).trim(),a=!u.endsWith("?")?"?":"",h=e.slice(r+1).trim(),p="unknown";if(h==="true"||h==="false")p="boolean";else if(/^-?\d+(\.\d+)?$/.test(h))p="number";else if(h.startsWith("'")&&h.endsWith("'")||h.startsWith('"')&&h.endsWith('"'))p="string";else if(h.startsWith("["))p="unknown[]";else if(h.startsWith("{"))p="Record<string, unknown>";return`${u}${a}: ${p}`}return e}function Vt(e){let c=0,r=e.length;while(c<r){while(c<r&&(e.charCodeAt(c)===32||e.charCodeAt(c)===9||e.charCodeAt(c)===10||e.charCodeAt(c)===13))c++;if(c+1<r&&e.charCodeAt(c)===47&&e.charCodeAt(c+1)===42){c+=2;while(c+1<r&&!(e.charCodeAt(c)===42&&e.charCodeAt(c+1)===47))c++;c+=2;continue}break}return c}function nt(e){let c=[],r=0,s=e.length;while(r<s){while(r<s&&e.charCodeAt(r)<=32)r++;if(r+1>=s||e.charCodeAt(r)!==47||e.charCodeAt(r+1)!==42)break;let i=r;r+=2;while(r+1<s&&!(e.charCodeAt(r)===42&&e.charCodeAt(r+1)===47))r++;r=Math.min(r+2,s),c.push(e.slice(i,r).trim())}return{comments:c.join(`
21
+ `),key:e.slice(r).trim()}}function Gt(e){let c=[],r="",s="",i=0,l=!1,f="",u=!0,a=!1,h=0,p=!1,y=!1,A=0,m=!1,g=!1;for(let C=0;C<e.length;C++){let d=e.charCodeAt(C),w=C>0?e.charCodeAt(C-1):0,b=C<e.length-1?e.charCodeAt(C+1):0;if(!l&&!a&&d===47&&b===47){r=r.replace(/[ \t]+$/,""),C+=2;while(C<e.length&&e.charCodeAt(C)!==10)C++;C--;continue}if(!l&&!a&&d===47&&b===42){a=!0,h=1,r+="/*",C++;continue}else if(a&&d===42&&b===47){if(h--,r+="*/",C++,h===0)a=!1;continue}else if(a&&d===47&&b===42){h++,r+="/*",C++;continue}let x=e[C];if(!l&&!a&&(d===34||d===39||d===96))l=!0,f=x,r+=x;else if(l&&x===f&&w!==92)l=!1,r+=x;else if(!l&&!a)if(d===40&&i===0&&u&&A===0){s=r.trim();let T=Vt(s),k=T>0?s.slice(0,T):"",S=s.slice(T),E="";if(S.startsWith("async ")||S.startsWith("async\t")||S.startsWith(`async
22
+ `))S=S.slice(6).trimStart(),E="async ";if(S.startsWith("*"))S=S.slice(1).trimStart(),E+="*";s=k+S,r=E+x,u=!1,m=!0,g=!1,i=1}else if(d===123||d===91||d===40){if(i++,r+=x,g&&d===123)g=!1}else if(d===125||d===93||d===41){if(i--,r+=x,d===41&&i===0&&!u&&!m)p=!0;if(m){if(d===41&&i===0&&!g)g=!0;else if(d===125&&i===0)m=!1,g=!1}}else if(d===58&&i===0&&u&&A===0)s=r.trim(),r="",u=!1;else if(d===58&&i===0&&p)y=!0,r+=x;else if(d===60&&y)A++,r+=x;else if(d===60&&u&&i===0)A++,r+=x;else if(d===62&&A>0&&w!==61)A--,r+=x;else if(d===61&&b===62&&y&&A===0)y=!1,p=!1,r+=x;else if(d===44&&i===0&&A===0&&!g){if(s&&r.trim()){let T=r.trim();c.push([s,T])}else if(u&&r.trim())ht(c,r.trim());r="",s="",u=!0,p=!1,y=!1,A=0}else r+=x;else r+=x}if(s&&r.trim()){let C=r.trim();c.push([s,C])}else if(u&&r.trim())ht(c,r.trim());return c}function ht(e,c){let{comments:r,key:s}=nt(c);if(J(s))e.push([r?`${r}
23
+ ${s}`:s,s]);else if(s.startsWith("...")&&s.length>3)e.push(["...",s.slice(3).trim()])}function dt(e){let c=e.trim();if(c.startsWith("get ")&&c.length>4){let r=c.slice(4).trim();if(r)return{kind:"get",name:r}}if(c.startsWith("set ")&&c.length>4){let r=c.slice(4).trim();if(r)return{kind:"set",name:r}}return null}function Jt(e,c,r){let s=r.trim();if(s.charCodeAt(0)!==40)return null;let i=o(s,0,"(",")");if(i===-1)return null;let l=s.slice(1,i).trim(),f=s.slice(i+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 zt(e,c){let r=c.trim(),s=o(r,0,"(",")");if(!r.startsWith("(")||s===-1)return"unknown";if(e==="get"){let u=r.slice(s+1).trim();return u.startsWith("=>")?u.slice(2).trim():"unknown"}let i=r.slice(1,s).trim(),l=i.startsWith("{")?o(i,0,"{","}"):i.startsWith("[")?o(i,0,"[","]"):0,f=i.indexOf(":",Math.max(0,l));return f===-1?"unknown":i.slice(f+1).trim()}function Xt(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 r=0;for(let s=0;s<c.length;s++){let i=c.charCodeAt(s);if(i===40)r++;else if(i===41){if(r--,r===0){let l=c.slice(s+1).trimStart();if(l.startsWith("{"))return!0;if(l.startsWith(":")){let f=ot(l,1);if(f?.kind==="arrow")return!1;if(f?.kind==="body")return!0}return!1}}}return!1}function Ht(e){let c=e.trimEnd();if(!c.endsWith(">"))return null;let r=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;r++}else if(f===60){if(r--,r===0){s=l;break}}}if(s===-1)return null;let i=c.slice(0,s).trimEnd();if(!i)return null;return{name:i,typeParams:c.slice(s)}}function gt(e,c){let r=c.trimStart(),s=!1,i=!1;if(r.startsWith("async ")||r.startsWith("async\t"))s=!0,r=r.slice(5).trimStart();if(r.startsWith("*"))i=!0,r=r.slice(1).trimStart();let l="";if(r.charCodeAt(0)===60){let A=0,m=-1;for(let g=0;g<r.length;g++)if(r.charCodeAt(g)===60)A++;else if(r.charCodeAt(g)===62&&!(g>0&&r.charCodeAt(g-1)===61)){if(A--,A===0){m=g;break}}if(m!==-1)l=r.slice(0,m+1),r=r.slice(m+1).trimStart()}let f=r.indexOf("("),u=o(r,f,"(",")");if(f===-1||u===-1)return"() => unknown";let a=r.slice(f,u+1),h="unknown",p=r.slice(u+1).trimStart();if(p.charCodeAt(0)===58){let A=p.slice(1),m=ot(A,0);if(m)h=A.slice(0,m.index).trim();else h=A.trim()}if(h==="unknown"&&!i&&p.charCodeAt(0)===123){let A=o(p,0,"{","}");if(A!==-1){let m=O(p.slice(1,A),s,a);if(m!=="unknown"&&m!=="Promise<unknown>")h=s&&m.startsWith("Promise<")?m.slice(8,-1):m;else if(s)h="Promise<unknown>"}}if(h==="unknown"){if(s&&i)h="AsyncGenerator<unknown, void, unknown>";else if(i)h="Generator<unknown, void, unknown>";else if(s)h="Promise<void>"}else if(s&&!h.startsWith("Promise<")&&!h.startsWith("AsyncGenerator<"))h=`Promise<${h}>`;let y=ie(a);return`${l}${y} => ${h}`}function ot(e,c){let r=0,s=0,i=0,l=0,f=!1,u=0;for(let a=c;a<e.length;a++){let h=e.charCodeAt(a);if(f){if(h===92)a++;else if(h===u)f=!1;continue}if(h===34||h===39||h===96){f=!0,u=h;continue}if(h===40)r++;else if(h===41&&r>0)r--;else if(h===91)s++;else if(h===93&&s>0)s--;else if(h===60)i++;else if(h===62&&i>0&&e.charCodeAt(a-1)!==61)i--;else if(h===125&&l>0)l--;else if(h===123){let p=r>0||s>0||i>0||l>0,y=e.slice(c,a).trimEnd(),A=y.charCodeAt(y.length-1),m=y.length===0||A===38||A===124||A===40||A===44||A===58||A===61||A===91;if(p||m)l++;else return{index:a,kind:"body"}}else if(h===61&&a+1<e.length&&e.charCodeAt(a+1)===62&&r===0&&s===0&&i===0&&l===0)return{index:a,kind:"arrow"}}return null}function o(e,c,r,s){let i=0;for(let l=c;l<e.length;l++)if(e[l]===r)i++;else if(e[l]===s){if(s===">"&&l>0&&e[l-1]==="=")continue;if(i--,i===0)return l}return-1}function q(e){let c=0,r=0,s=!1,i="";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,i=f;else if(s&&f===i&&a!=="\\")s=!1;if(!s){if(f==="<"){let h=o(e,l,"<",">");if(h!==-1){l=h;continue}}if(f==="(")c++;else if(f===")")c--;else if(f==="[")r++;else if(f==="]")r--;if(f==="="&&u===">"&&c===0&&r===0)return l}}return-1}function Qe(e,c=!1,r=0,s=!0){let i=e.trim();if(i.length>200&&Z(i,"=>")>2&&Z(i,"<")>5&&!i.startsWith("function"))return c?"((...args: any[]) => any)":"(...args: any[]) => any";if(i.startsWith("async ")&&i.includes("=>")){let f=i.slice(5).trim(),u=q(f);if(u===-1)return c?"(() => Promise<unknown>)":"() => Promise<unknown>";let a=f.substring(0,u).trim(),h=f.substring(u+2).trim(),p=rt(a),{params:y,returnType:A}=p;if(y=ie(y),y==="()"||y==="")y="()";else if(!y.startsWith("("))y=`(${y})`;let m=A;if(m);else if(h.startsWith("{"))m=O(h.slice(1,h.endsWith("}")?-1:void 0),!0,p.params);else m=K(h,v(p.params));let g=`${y} => ${A||m.startsWith("Promise<")?m:`Promise<${m}>`}`;return c?`(${g})`:g}if(i.includes("=>")){let f="",u=i;if(i.startsWith("<")){let d=o(i,0,"<",">");if(d!==-1)f=i.substring(0,d+1),u=i.substring(d+1).trim()}let a=q(u);if(a===-1)return c?"(() => unknown)":"() => unknown";let h=u.substring(0,a).trim(),p=u.substring(a+2).trim(),y=rt(h),{params:A,returnType:m}=y;if(A=ie(A),A==="()"||A==="")A="()";else if(!A.startsWith("("))A=`(${A})`;let g="unknown";if(m)g=m;else if(p.startsWith("{"))g=O(p.slice(1,p.endsWith("}")?-1:void 0),!1,y.params);else if(z(p)||st(p)&&z(p.slice(1,-1).trim()))g="JSX.Element";else if(p.includes("=>")){let d=p.trimStart(),w=d.indexOf("("),b=w!==-1?o(d,w,"(",")"):-1,x=b!==-1?d.indexOf("=>",b):-1;if(w===0&&b!==-1&&x!==-1){let T=d.substring(w+1,b).trim(),k=ie(T);if(f.includes("T")&&k.includes("T"))g=`(${k}) => T`;else g=`(${k}) => any`}else g="any"}else g=K(p,v(y.params));let C=`${f}${A} => ${g}`;return c?`(${C})`:C}if(i.startsWith("function")){let f=8,u=i.length;while(f<u&&i.charCodeAt(f)<=32)f++;let a=!1;if(f<u&&i.charCodeAt(f)===42){a=!0,f++;while(f<u&&i.charCodeAt(f)<=32)f++}let h="";if(f<u&&i.charCodeAt(f)===60){let A=f,m=1;f++;while(f<u&&m>0){let g=i.charCodeAt(f);if(g===60)m++;else if(g===62&&i.charCodeAt(f-1)!==61)m--;f++}h=i.substring(A,f);while(f<u&&i.charCodeAt(f)<=32)f++}let p=i.indexOf("(",f);if(p!==-1){let A=1,m=p+1;while(m<u&&A>0){let x=i.charCodeAt(m);if(x===40)A++;else if(x===41)A--;m++}let g=i.substring(p+1,m-1).trim(),C=g?ie(`(${g})`):"()";if(a){let x=i.substring(m).trim(),T=x.indexOf("Generator<");if(T!==-1){let S=T+10,E=x.indexOf(">",S);if(E!==-1){let L=x.substring(S,E),P=`${h}${C} => Generator<${L}>`;return c?`(${P})`:P}}let k=`${h}${C} => Generator<any, any, any>`;return c?`(${k})`:k}let d="unknown",w=i.substring(m).trimStart();if(w.charCodeAt(0)===58){let x=w.slice(1),T=ot(x,0),k=(T?x.slice(0,T.index):x).trim();if(k)d=k}let b=`${h}${C} => ${d}`;return c?`(${b})`:b}let y="(...args: any[]) => unknown";return c?`(${y})`:y}if(i.includes("=>")&&i.includes("(")&&i.includes(")")){if(i.length>100||Z(i,"=>")>2){let f="";if(i.charCodeAt(0)===60){let y=o(i,0,"<",">");if(y!==-1)f=i.substring(0,y+1)}let u=i.indexOf("("),a=u!==-1?o(i,u,"(",")"):-1,h=u!==-1&&a!==-1?i.substring(u,a+1):"(...args: any[])";h=ie(h);let p=`${f}${h} => any`;return c?`(${p})`:p}return c?`(${i})`:i}let l="() => unknown";return c?`(${l})`:l}function rt(e){let c=e.trim();if(!c.startsWith("("))return{params:c,returnType:""};let r=o(c,0,"(",")");if(r===-1)return{params:c,returnType:""};let s=c.slice(r+1).trim();return{params:c.slice(0,r+1),returnType:s.startsWith(":")?s.slice(1).trim():""}}function ke(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 W(e){let c=-1,r=0;for(let i=0;i<e.length;i++){let l=e.charCodeAt(i);if(l===34||l===39||l===96){i=B(e,i,l)-1;continue}if(l===47&&e.charCodeAt(i+1)===47){while(i<e.length&&e.charCodeAt(i)!==10)i++;continue}if(l===47&&e.charCodeAt(i+1)===42){let f=e.indexOf("*/",i+2);i=f===-1?e.length:f+1;continue}if(l===47){let f=i-1;while(f>=0&&e.charCodeAt(f)<=32)f--;if(f<0||"([{:;,=!?&|+*-~>".includes(e[f])){let u=!1;for(i++;i<e.length;i++){let a=e.charCodeAt(i);if(a===92)i++;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)r++;else if(l===41||l===93||l===125)r--;else if(r===0&&e.startsWith("satisfies",i)&&G(e,i,9)&&e[i-1]!==".")c=i}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 Ta(e){let c=e.trim(),r=c.match(/^\{\s*\[(\w+)\s+in\s+(.+?)\](\?)?\s*:\s*(.+)\s*\}$/);if(r){let[,l,f,u,a]=r;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 i=c.match(/^\{\s*(-?readonly\s+)?\[(\w+)\s+in\s+(.+?)\](-?\?)?\s*:\s*(.+)\s*\}$/);if(i){let[,l,f,u,a,h]=i;return`{ ${l?`${l.trim()} `:""}[${f} in ${u}]${a||""}: ${h} }`}return null}function Aa(e){let c=e.trim(),r=c.indexOf(" extends ");if(r===-1)return null;let s=c.slice(r+9),i=Qt(s);if(i===-1)return null;let l=Yt(s,i);if(l===-1)return null;let f=c.slice(0,r).trim(),u=s.slice(0,i).trim(),a=s.slice(i+1,l).trim(),h=s.slice(l+1).trim();return`${f} extends ${u} ? ${a} : ${h}`}function Qt(e){let c=0,r=!1,s="";for(let i=0;i<e.length;i++){let l=e[i],f=i>0?e[i-1]:"";if(!r&&(l==='"'||l==="'"||l==="`"))r=!0,s=l;else if(r&&l===s&&f!=="\\")r=!1;if(!r){if(l==="<"||l==="("||l==="["||l==="{")c++;if(l===">"||l===")"||l==="]"||l==="}")c--;if(l==="?"&&c===0)return i}}return-1}function Yt(e,c){let r=0,s=!1,i="";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,i=f;else if(s&&f===i&&u!=="\\")s=!1;if(!s){if(f==="<"||f==="("||f==="["||f==="{")r++;if(f===">"||f===")"||f==="]"||f==="}")r--;if(f==="?"&&r===0)r++;if(f===":"&&r===0)return l;if(f===":"&&r>0)r--}}return-1}function Pa(e){let c=e.trim();if(!c.startsWith("`")||!c.endsWith("`"))return null;let r=c.slice(1,-1);if(!r.includes("${"))return c;let s=[],i="",l=0;while(l<r.length)if(r[l]==="$"&&r[l+1]==="{"){if(i)s.push(`"${i}"`),i="";let f=1,u="";l+=2;while(l<r.length&&f>0){if(r[l]==="{")f++;if(r[l]==="}")f--;if(f>0)u+=r[l];l++}s.push(u.trim())}else i+=r[l],l++;if(i)s.push(`"${i}"`);return c}function Da(e){let c=[],r=/infer\s+(\w+)/g,s;while((s=r.exec(e))!==null)c.push(s[1]);return c}function Ra(e){let r=e.trim(),s=r.indexOf("[");if(s!==-1){if(r.indexOf(" in ",s)!==-1)return!0}let i=r.indexOf(" extends ");if(i!==-1){let f=r.indexOf(" ? ",i);if(f!==-1&&r.indexOf(" : ",f)!==-1)return!0}if(r.charCodeAt(0)===96&&r.charCodeAt(r.length-1)===96){if(r.indexOf("${")!==-1)return!0}let l=r.indexOf("infer ");if(l!==-1){if(l===0||!R(r.charCodeAt(l-1)))return!0}return!1}function Ma(e,c=3){let r=e.trim(),s=0,i=0;for(let l of r){if(l==="<"||l==="("||l==="["||l==="{")s++,i=Math.max(i,s);if(l===">"||l===")"||l==="]"||l==="}")s--}if(i>c){let l=r.match(/^(\w+)</);if(l)return`${l[1]}<any>`;return"unknown"}return r}function Oa(e){let r=e.trim().match(/^(\w+)<(.+)>$/);if(!r)return null;let s=r[1],i=r[2],l=ea(i);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 ea(e){let c=[],r="",s=0,i=!1,l="";for(let f=0;f<e.length;f++){let u=e[f],a=f>0?e[f-1]:"";if(!i&&(u==='"'||u==="'"||u==="`"))i=!0,l=u;else if(i&&u===l&&a!=="\\")i=!1;if(!i){if(u==="<"||u==="("||u==="["||u==="{")s++;if(u===">"||u===")"||u==="]"||u==="}")s--;if(u===","&&s===0){c.push(r.trim()),r="";continue}}r+=u}if(r.trim())c.push(r.trim());return c}function Ia(e){let c=e.trim();if(c.startsWith("keyof "))return c;return null}function Fa(e){let c=e.trim();if(c.startsWith("typeof "))return c;return null}function La(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 r=c.indexOf("[");if(r<=0)return!1;for(let s=0;s<r;s++){let i=c.charCodeAt(s);if(!R(i)&&i!==46)return!1}return!0}
24
+ export{Pt,Dt,n,Rt,O,$e,re,Ze,Ee,ie,o,Qe,ke,W,Ta,Aa,Pa,Da,Ra,Ma,Oa,ea,Ia,Fa,La};
@@ -0,0 +1,18 @@
1
+ // @bun
2
+ var d=null,m=null;async function P(){if(d!==null)return d;try{return m=await import("prettier"),d=!0,!0}catch{return d=!1,!1}}async function y(r,e){if(!m)return null;try{if(e&&m.resolveConfig){let n=await m.resolveConfig(e);if(n)return n}if(r&&m.resolveConfig){let n=await m.resolveConfig(r);if(n)return n}return null}catch{return null}}async function w(r,e){if(!m)throw Error("Prettier is not available");let n={...e,parser:e.parser||"typescript"};return m.format(r,n)}function C(r,e={}){let{indentSize:n=2,useTabs:s=!1,maxLineWidth:a=100,trailingNewline:i=!0,normalizeWhitespace:u=!0,sortImports:l=!0,groupImports:o=!0}=e,t=r,p=s?"\t":" ".repeat(n);if(t.indexOf(`\r
3
+ `)!==-1)t=t.replace(/\r\n/g,`
4
+ `);if(u){if(/[ \t]\n/.test(t)||/[ \t]$/.test(t))t=t.replace(/[ \t]+$/gm,"");if(t.indexOf(`
5
+
6
+
7
+ `)!==-1)t=t.replace(/\n{3,}/g,`
8
+
9
+ `);t=I(t,p)}if(l||o)t=x(t,{sort:l,group:o});if(a>0)t=W(t,a,p);if(i&&!t.endsWith(`
10
+ `))t+=`
11
+ `;return t}function I(r,e){let n=r.split(`
12
+ `),s=[];for(let a of n){let i=a.match(/^(\s*)(.*)$/);if(!i){s.push(a);continue}let[,u,l]=i;if(!l){s.push("");continue}let o=u.replace(/\t/g," ").length,t=Math.floor(o/2);s.push(e.repeat(t)+l)}return s.join(`
13
+ `)}function x(r,e){let n=r.split(`
14
+ `),s=[],a=[],i=!1,u=0;for(let o=0;o<n.length;o++){let t=n[o],p=t.match(/^(import\s+(?:type\s+)?.*from\s+['"])([^'"]+)(['"].*)$/);if(p){i=!0,u=o;let c=p[1];s.push({line:t,source:p[2],isType:c.startsWith("import type ")||c.startsWith("import type\t")})}else if(i&&t.trim()==="")continue;else{if(i)i=!1;a.push(t)}}if(s.length===0)return r;if(e.sort)s.sort((o,t)=>{if(o.isType!==t.isType)return o.isType?1:-1;return M(o.source,t.source)});let l;if(e.group){let o=[],t=[],p=[],c=[],b=[];for(let f=0;f<s.length;f++){let g=s[f],h=g.source;if(h.charCodeAt(0)===46)b.push(g);else if(h.startsWith("node:"))o.push(g);else if(h.charCodeAt(0)===64)c.push(g);else if(h.includes("/"))p.push(g);else t.push(g)}l=[...o.map((f)=>f.line),...o.length>0&&t.length>0?[""]:[],...t.map((f)=>f.line),...(o.length>0||t.length>0)&&p.length>0?[""]:[],...p.map((f)=>f.line),...c.length>0&&(o.length>0||t.length>0||p.length>0)?[""]:[],...c.map((f)=>f.line),...b.length>0?[""]:[],...b.map((f)=>f.line)]}else l=s.map((o)=>o.line);return[...l,"",...a].join(`
15
+ `)}function M(r,e){let n=r.startsWith("node:"),s=e.startsWith("node:");if(n!==s)return n?-1:1;let a=r.startsWith("."),i=e.startsWith(".");if(a!==i)return a?1:-1;return r.localeCompare(e)}function W(r,e,n){let s=r.split(`
16
+ `),a=[];for(let i of s){if(i.length<=e){a.push(i);continue}if(i.trimStart().startsWith("import ")){a.push(i);continue}let u=i.match(/^(\s*)/)?.[1]||"",l=u+n,o=O(i,u,l);if(o){a.push(...o);continue}if(i.includes("{")&&i.includes("}")){let t=v(i,e,u,l);a.push(...t);continue}if(i.includes(" | ")){let t=R(i,e,u,l);a.push(...t);continue}a.push(i)}return a.join(`
17
+ `)}var F=/^\s*(export|import)(\s+type)?\s*\{([^{}]*)\}\s*(from\s*(?:'[^']*'|"[^"]*")(?:\s*(?:with|assert)\s*\{[^{}]*\})?)?\s*;?\s*$/;function O(r,e,n){let s=r.match(F);if(!s)return null;let[,a,i,u,l]=s,o=u.split(",").map((c)=>c.trim()).filter(Boolean);if(o.length<=1)return[r];let t=`${e}${a}${i??""} {`,p=l?`${e}} ${l};`:`${e}};`;return[t,...o.map((c)=>`${n}${c},`),p]}function v(r,e,n,s){let a=r.match(/^(\s*)(.*?)(\{)(.+)(\}.*)$/);if(!a)return[r];let[,,i,u,l,o]=a,t=l.split(/;\s*|,\s*/).filter((c)=>c.trim());if(t.length<=1)return[r];return[`${n}${i}${u}`,...t.map((c)=>`${s}${c.trim()};`),`${n}${o.trim()}`]}function R(r,e,n,s){let a=r.match(/^(\s*)(.*?=\s*)(.+)$/);if(!a)return[r];let[,,i,u]=a,l=u.split(/\s*\|\s*/).filter((t)=>t.trim());if(l.length<=2)return[r];return[`${n}${i}`,...l.map((t,p)=>`${s}${p>0?"| ":" "}${t.trim()}`)]}async function z(r,e={},n){let s=[];if(e.usePrettier!==!1){if(await P())try{let l={...await y(e.prettierConfigPath,n),...e.prettierOptions,parser:"typescript"};return{content:await w(r,l),usedPrettier:!0}}catch(u){s.push(`Prettier formatting failed: ${u}. Using built-in formatter.`)}else if(e.usePrettier===!0)s.push("Prettier requested but not available. Using built-in formatter.")}return{content:C(r,e.builtIn),usedPrettier:!1,warnings:s.length>0?s:void 0}}async function ri(r,e={}){let n=new Map;for(let[s,a]of r){let i=await z(a,e,s);n.set(s,i)}return n}function bo(r={}){return{format:(e,n)=>z(e,r,n),formatMany:(e)=>ri(e,r)}}async function wo(r){return(await z(r,{usePrettier:!0,builtIn:{indentSize:2,normalizeWhitespace:!0,sortImports:!0,trailingNewline:!0}})).content}
18
+ export{z,ri,bo,wo};