@stacksjs/dtsx 0.9.9 → 0.9.11

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 (113) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +243 -15
  3. package/dist/bin/cli.js +10 -22
  4. package/dist/branded-types.d.ts +150 -0
  5. package/dist/bundler.d.ts +55 -0
  6. package/dist/cache.d.ts +43 -0
  7. package/dist/checker.d.ts +107 -0
  8. package/dist/chunk-1bav913n.js +6 -0
  9. package/dist/chunk-2wbhe1k8.js +2 -0
  10. package/dist/chunk-3d18fhrg.js +3 -0
  11. package/dist/chunk-3g2v2ns2.js +2 -0
  12. package/dist/chunk-3j7r0fxz.js +2 -0
  13. package/dist/chunk-4qpg9xnt.js +3 -0
  14. package/dist/chunk-57agx6g8.js +3 -0
  15. package/dist/chunk-5vqtjws2.js +2 -0
  16. package/dist/chunk-6mwq397e.js +2 -0
  17. package/dist/chunk-6qv7p9sg.js +170 -0
  18. package/dist/chunk-6s7n1gt0.js +2 -0
  19. package/dist/chunk-74j5mydx.js +3 -0
  20. package/dist/chunk-7cpp6v8f.js +2 -0
  21. package/dist/chunk-9a6yn7sv.js +75 -0
  22. package/dist/chunk-axb2kjeq.js +2 -0
  23. package/dist/chunk-begk3j01.js +33 -0
  24. package/dist/chunk-cmenkst5.js +3 -0
  25. package/dist/chunk-d0p3jzwb.js +34 -0
  26. package/dist/chunk-f18nyrrb.js +32 -0
  27. package/dist/chunk-fb4c98h2.js +2 -0
  28. package/dist/chunk-ggmn4a8c.js +4 -0
  29. package/dist/chunk-hrmnrn4p.js +3 -0
  30. package/dist/chunk-j0y71ank.js +2 -0
  31. package/dist/chunk-j6aqdbc4.js +2 -0
  32. package/dist/chunk-jm5ywn4e.js +13 -0
  33. package/dist/chunk-knkfbqze.js +2 -0
  34. package/dist/chunk-n28rjf9h.js +3 -0
  35. package/dist/chunk-p1d09y82.js +449 -0
  36. package/dist/chunk-r1m3q3dj.js +2 -0
  37. package/dist/chunk-r1ywapeb.js +6 -0
  38. package/dist/chunk-rnt0wkrk.js +23 -0
  39. package/dist/chunk-rw6j20e2.js +3 -0
  40. package/dist/chunk-v96rjx7x.js +134 -0
  41. package/dist/chunk-w9abhtgg.js +22 -0
  42. package/dist/chunk-wfevdmvd.js +19 -0
  43. package/dist/chunk-ws2dmfvj.js +2 -0
  44. package/dist/chunk-xnq1xw73.js +15 -0
  45. package/dist/chunk-xyctgc6x.js +102 -0
  46. package/dist/chunk-y3q50bn2.js +2 -0
  47. package/dist/chunk-ywd4k4hn.js +3 -0
  48. package/dist/circular.d.ts +82 -0
  49. package/dist/compat.d.ts +108 -0
  50. package/dist/config.d.ts +33 -3
  51. package/dist/diff.d.ts +82 -0
  52. package/dist/docs.d.ts +97 -0
  53. package/dist/errors.d.ts +113 -0
  54. package/dist/extractor/builders.d.ts +38 -0
  55. package/dist/extractor/cache.d.ts +47 -0
  56. package/dist/extractor/declarations.d.ts +50 -0
  57. package/dist/extractor/directives.d.ts +9 -0
  58. package/dist/extractor/extract.d.ts +10 -0
  59. package/dist/extractor/hash.d.ts +1 -0
  60. package/dist/extractor/helpers.d.ts +39 -0
  61. package/dist/extractor/index.d.ts +70 -0
  62. package/dist/extractor/scanner.d.ts +6 -0
  63. package/dist/extractor.d.ts +3 -4
  64. package/dist/formats.d.ts +50 -0
  65. package/dist/formatter.d.ts +61 -0
  66. package/dist/generator.d.ts +12 -3
  67. package/dist/import-sorter.d.ts +99 -0
  68. package/dist/incremental.d.ts +84 -0
  69. package/dist/index.d.ts +54 -1
  70. package/dist/logger.d.ts +57 -0
  71. package/dist/lsp.d.ts +317 -0
  72. package/dist/memory.d.ts +110 -0
  73. package/dist/merger.d.ts +38 -0
  74. package/dist/optimizer.d.ts +52 -0
  75. package/dist/output-normalizer.d.ts +123 -0
  76. package/dist/parallel-processor.d.ts +63 -0
  77. package/dist/parser.d.ts +24 -15
  78. package/dist/plugins/bun.d.ts +58 -0
  79. package/dist/plugins/esbuild.d.ts +63 -0
  80. package/dist/plugins/index.d.ts +14 -0
  81. package/dist/plugins/tsup.d.ts +53 -0
  82. package/dist/plugins/vite.d.ts +49 -0
  83. package/dist/plugins/webpack.d.ts +66 -0
  84. package/dist/plugins.d.ts +83 -0
  85. package/dist/process-source.d.ts +11 -0
  86. package/dist/processor/cache.d.ts +16 -0
  87. package/dist/processor/comments.d.ts +7 -0
  88. package/dist/processor/declarations.d.ts +37 -0
  89. package/dist/processor/imports.d.ts +65 -0
  90. package/dist/processor/index.d.ts +34 -0
  91. package/dist/processor/type-inference.d.ts +106 -0
  92. package/dist/processor.d.ts +3 -43
  93. package/dist/profiling.d.ts +101 -0
  94. package/dist/security.d.ts +100 -0
  95. package/dist/sourcemap.d.ts +125 -0
  96. package/dist/src/index.js +55 -2
  97. package/dist/src/plugins/bun.js +2 -0
  98. package/dist/src/plugins/esbuild.js +2 -0
  99. package/dist/src/plugins/index.js +2 -0
  100. package/dist/src/plugins/tsup.js +2 -0
  101. package/dist/src/plugins/vite.js +2 -0
  102. package/dist/src/plugins/webpack.js +2 -0
  103. package/dist/tracking.d.ts +89 -0
  104. package/dist/transformers.d.ts +173 -0
  105. package/dist/tree-shaker.d.ts +69 -0
  106. package/dist/type-mappings.d.ts +124 -0
  107. package/dist/types.d.ts +137 -7
  108. package/dist/utils.d.ts +53 -1
  109. package/dist/watcher.d.ts +64 -0
  110. package/dist/worker.d.ts +84 -0
  111. package/dist/workspace.d.ts +62 -0
  112. package/package.json +49 -11
  113. package/dist/chunk-qsyn1k3w.js +0 -504
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Validate that a path is safe and within the allowed root directory
3
+ */
4
+ export declare function validatePath(filePath: string, config?: SecurityConfig): string;
5
+ /**
6
+ * Validate multiple paths
7
+ */
8
+ export declare function validatePaths(filePaths: string[], config?: SecurityConfig): string[];
9
+ /**
10
+ * Check if a path matches any blocked pattern
11
+ */
12
+ export declare function isBlockedPath(filePath: string, config?: SecurityConfig): boolean;
13
+ /**
14
+ * Validate file size
15
+ */
16
+ export declare function validateFileSize(filePath: string, config?: SecurityConfig): Promise<number>;
17
+ /**
18
+ * Check if path is a symbolic link
19
+ */
20
+ export declare function isSymlink(filePath: string): Promise<boolean>;
21
+ /**
22
+ * Validate that a path is not a symlink (or follow it if allowed)
23
+ */
24
+ export declare function validateSymlink(filePath: string, config?: SecurityConfig): Promise<string>;
25
+ /**
26
+ * Full path validation including all security checks
27
+ */
28
+ export declare function validateFilePath(filePath: string, config?: SecurityConfig): Promise<{ path: string, size: number }>;
29
+ /**
30
+ * Validate a batch of files with total size limit
31
+ */
32
+ export declare function validateFileBatch(filePaths: string[], config?: SecurityConfig): Promise<{ paths: string[], totalSize: number }>;
33
+ /**
34
+ * Create a timeout wrapper for async operations
35
+ */
36
+ export declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number, operation?: string): Promise<T>;
37
+ /**
38
+ * Create a secure file processor with all protections
39
+ */
40
+ export declare function createSecureProcessor<T>(processor: (filePath: string) => Promise<T>, config?: SecurityConfig): (filePath: string) => Promise<T>;
41
+ /**
42
+ * Create a secure batch processor
43
+ */
44
+ export declare function createSecureBatchProcessor<T>(processor: (filePaths: string[]) => Promise<T>, config?: SecurityConfig): (filePaths: string[]) => Promise<T>;
45
+ /**
46
+ * Sanitize a filename to prevent path traversal
47
+ */
48
+ export declare function sanitizeFilename(filename: string): string;
49
+ /**
50
+ * Check if a path is safe (doesn't contain traversal sequences)
51
+ */
52
+ export declare function isSafePath(path: string): boolean;
53
+ /**
54
+ * Create security middleware for the generator
55
+ */
56
+ export declare function createSecurityMiddleware(config?: SecurityConfig): {
57
+ validatePath: (filePath: string) => string
58
+ validatePaths: (filePaths: string[]) => string[]
59
+ validateFile: (filePath: string) => Promise<{ path: string, size: number }>
60
+ validateBatch: (filePaths: string[]) => Promise<{ paths: string[], totalSize: number }>
61
+ withTimeout: <T>(promise: Promise<T>, operation?: string) => Promise<T>
62
+ secureProcessor: <T>(processor: (filePath: string) => Promise<T>) => (filePath: string) => Promise<T>
63
+ isBlocked: (filePath: string) => boolean
64
+ getConfig: () => Required<SecurityConfig>
65
+ };
66
+ /**
67
+ * Default security configuration
68
+ */
69
+ export declare const DEFAULT_SECURITY_CONFIG: Required<SecurityConfig>;
70
+ /**
71
+ * Security configuration options
72
+ */
73
+ export declare interface SecurityConfig {
74
+ rootDir?: string
75
+ maxFileSize?: number
76
+ maxTotalSize?: number
77
+ timeout?: number
78
+ followSymlinks?: boolean
79
+ maxFiles?: number
80
+ blockedPatterns?: string[]
81
+ }
82
+ /**
83
+ * Security error codes
84
+ */
85
+ export type SecurityErrorCode = | 'PATH_TRAVERSAL'
86
+ | 'FILE_TOO_LARGE'
87
+ | 'TOTAL_SIZE_EXCEEDED'
88
+ | 'TIMEOUT'
89
+ | 'SYMLINK_NOT_ALLOWED'
90
+ | 'MAX_FILES_EXCEEDED'
91
+ | 'BLOCKED_PATTERN'
92
+ | 'INVALID_PATH';
93
+ /**
94
+ * Security validation error
95
+ */
96
+ export declare class SecurityError extends Error {
97
+ public readonly code: SecurityErrorCode;
98
+ public readonly path?: string;
99
+ constructor(message: string, code: SecurityErrorCode, path?: string);
100
+ }
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Create source map for generated .d.ts content
3
+ */
4
+ export declare function createSourceMap(options: {
5
+ generatedFile: string
6
+ sourceFile: string
7
+ sourceContent?: string
8
+ sourceRoot?: string
9
+ mappings: Array<{
10
+ generatedLine: number
11
+ generatedColumn: number
12
+ originalLine: number
13
+ originalColumn: number
14
+ name?: string
15
+ }>
16
+ }): SourceMapGenerator;
17
+ /**
18
+ * Append source map comment to content
19
+ */
20
+ export declare function appendSourceMapComment(content: string, mapFileName: string): string;
21
+ /**
22
+ * Append inline source map to content
23
+ */
24
+ export declare function appendInlineSourceMap(content: string, generator: SourceMapGenerator, includeContent?: boolean): string;
25
+ /**
26
+ * Write source map file
27
+ */
28
+ export declare function writeSourceMap(mapPath: string, generator: SourceMapGenerator, includeContent?: boolean): Promise<void>;
29
+ /**
30
+ * Read and parse source map file
31
+ */
32
+ export declare function readSourceMap(mapPath: string): Promise<SourceMapConsumer>;
33
+ /**
34
+ * Extract source map from content (inline or reference)
35
+ */
36
+ export declare function extractSourceMap(content: string, filePath: string): Promise<SourceMapConsumer | null>;
37
+ /**
38
+ * Build source mappings from declaration info
39
+ */
40
+ export declare function buildDeclarationMappings(_generatedContent: string, _declarationInfos: Array<{
41
+ name: string
42
+ generatedStart: number
43
+ originalLine: number
44
+ originalColumn: number
45
+ }>): Array<{
46
+ generatedLine: number
47
+ generatedColumn: number
48
+ originalLine: number
49
+ originalColumn: number
50
+ name: string
51
+ }>;
52
+ /**
53
+ * Source map configuration
54
+ */
55
+ export declare interface SourceMapConfig {
56
+ sourceMap?: boolean
57
+ inlineSourceMap?: boolean
58
+ inlineSources?: boolean
59
+ sourceRoot?: string
60
+ mapExtension?: string
61
+ }
62
+ /**
63
+ * Source map v3 format
64
+ */
65
+ export declare interface SourceMapV3 {
66
+ version: 3
67
+ file: string
68
+ sourceRoot?: string
69
+ sources: string[]
70
+ sourcesContent?: (string | null)[]
71
+ names: string[]
72
+ mappings: string
73
+ }
74
+ /**
75
+ * Source position
76
+ */
77
+ export declare interface SourcePosition {
78
+ line: number
79
+ column: number
80
+ }
81
+ /**
82
+ * Mapping entry
83
+ */
84
+ export declare interface Mapping {
85
+ generated: SourcePosition
86
+ original: SourcePosition
87
+ sourceIndex: number
88
+ nameIndex?: number
89
+ }
90
+ /**
91
+ * Source map generator
92
+ */
93
+ export declare class SourceMapGenerator {
94
+ constructor(options: { file: string, sourceRoot?: string });
95
+ addSource(source: string, content?: string): number;
96
+ addName(name: string): number;
97
+ addMapping(mapping: {
98
+ generated: SourcePosition
99
+ original: SourcePosition
100
+ source: string
101
+ name?: string
102
+ }): void;
103
+ generate(includeContent?: boolean): SourceMapV3;
104
+ toString(includeContent?: boolean): string;
105
+ toDataUrl(includeContent?: boolean): string;
106
+ toComment(includeContent?: boolean): string;
107
+ }
108
+ /**
109
+ * Source map consumer for reading source maps
110
+ */
111
+ export declare class SourceMapConsumer {
112
+ constructor(map: SourceMapV3 | string);
113
+ originalPositionFor(generated: SourcePosition): {
114
+ source: string | null
115
+ line: number | null
116
+ column: number | null
117
+ name: string | null
118
+ };
119
+ generatedPositionFor(original: {
120
+ source: string
121
+ line: number
122
+ column: number
123
+ }): SourcePosition | null;
124
+ sourceContentFor(source: string): string | null;
125
+ }
package/dist/src/index.js CHANGED
@@ -1,3 +1,56 @@
1
1
  // @bun
2
- import{a as v,b as R,c as f,d as L,e as b,f as M,g as C,h as g,i as x,j as y,k as S,l as p,m as d,n as u,o as h,p as m,q as r,r as o,s as c}from"../chunk-qsyn1k3w.js";function U(w){return w.replace(/^(\s*\/\*[\s\S]*?\*\/\s*|\s*\/\/.*\n)*/g,"").trim()}function V(w,K){let J=w.substring(0,K).split(`
3
- `),G=[],j=J.length-1,N=!1,D=[];while(j>=0){let z=J[j].trim();if(z.endsWith("*/")&&!N)N=!0,D.unshift(z);else if(z.startsWith("/*")&&N)D.unshift(z),G.unshift(...D),D=[],N=!1;else if(N)D.unshift(z);else if(z.startsWith("//"))G.unshift(z);else if(z.startsWith("*")&&(j>0&&J[j-1].trim().startsWith("/*")))G.unshift(z);else if(z===""&&G.length>0);else if(z!=="")break;j--}return G}function W(w){let K=!1,H="",J=!1;for(let G=0;G<w.length;G++){let j=w[G];if(!J&&!K&&(j==='"'||j==="'"||j==="`"))K=!0,H=j;else if(!J&&K&&j===H)K=!1;else if(j==="\\"&&!J){J=!0;continue}else if(!K&&j==="/"&&G<w.length-1){if(w[G+1]==="/")return w.substring(G)}J=!1}return null}function X(w){return w.map((K)=>{return K})}function Q(w,K,H){let J=0,G=!1,j="",N=!1,D=0;if(!w.startsWith(K))return null;for(D=0;D<w.length;D++){let z=w[D],O=D>0?w[D-1]:"";if(!N&&(z==='"'||z==="'"||z==="`")){if(!G)G=!0,j=z;else if(z===j)G=!1}if(z==="\\"&&!N){N=!0;continue}if(N=!1,!G){if(w.substring(D,D+K.length)===K)J++;else if(w.substring(D,D+H.length)===H){if(J--,J===0)return{content:w.substring(0,D+H.length),rest:w.substring(D+H.length)}}}}return null}function Y(w){let K=U(w).trim(),H=K.match(/^(export\s+)?(async\s+)?function\s*(\*?)\s*([a-zA-Z_$][\w$]*)/);if(!H)return null;let J=[];if(H[1])J.push("export");if(H[2])J.push("async");if(H[3])J.push("generator");let G=H[4],j=K.substring(H[0].length).trim(),N="";if(j.startsWith("<")){let O=Q(j,"<",">");if(O)N=O.content,j=O.rest.trim()}let D="";if(j.startsWith("(")){let O=Q(j,"(",")");if(O)D=O.content.slice(1,-1).trim(),j=O.rest.trim()}let z="void";if(j.startsWith(":")){let O=j.match(/^:\s*([^{;]+)/);if(O)z=O[1].trim()}return{name:G,generics:N,parameters:D,returnType:z,modifiers:J}}function Z(w){return/^\s*export\s+/.test(w)}function _(w){return/^\s*export\s+type\s+/.test(w)}function $(w){let K=U(w).trim(),H=K.match(/^(export\s+)?(const|let|var)\s+([a-zA-Z_$][\w$]*)/);if(!H)return null;let J=H[2],G=H[3],j=K.substring(H[0].length).trim(),N;if(j.startsWith(":")){let z=j.indexOf("=");if(z!==-1)N=j.substring(1,z).trim(),j=j.substring(z).trim();else N=j.substring(1).replace(/;?\s*$/,"").trim(),j=""}let D;if(j.startsWith("="))D=j.substring(1).replace(/;?\s*$/,"").trim();return{kind:J,name:G,typeAnnotation:N,value:D}}export{h as writeToFile,U as removeLeadingComments,M as processVariableDeclaration,g as processTypeDeclaration,d as processModuleDeclaration,C as processInterfaceDeclaration,S as processImportDeclaration,b as processFunctionDeclaration,c as processFile,p as processExportDeclaration,y as processEnumDeclaration,L as processDeclarations,x as processClassDeclaration,$ as parseVariableDeclaration,Y as parseFunctionDeclaration,_ as isTypeOnlyExport,Z as isExportStatement,u as inferNarrowType,m as getAllTypeScriptFiles,o as generate,X as formatComments,W as extractTrailingComment,V as extractLeadingComments,f as extractDeclarations,Q as extractBalancedSymbols,v as defaultConfig,R as config,r as checkIsolatedDeclarations};
2
+ import{a as b9,b as P9,c as x9}from"../chunk-ggmn4a8c.js";import{d as O8,e as A8,f as G8,g as B8,h as z8,i as N8,j as j8,k as R8}from"../chunk-xyctgc6x.js";import{l as m9,m as p9,n as d9,o as c9,p as l9,q as o9,r as s9}from"../chunk-1bav913n.js";import{s as w9,t as I9,u as T9,v as S9,w as k9,x as C9,y as v9}from"../chunk-w9abhtgg.js";import{A as I6,B as T6,C as S6,D as k6,E as C6,F as v6,G as b6,H as P6,z as w6}from"../chunk-jm5ywn4e.js";import{I as f8,J as u8,K as m8,L as p8,M as d8,N as c8,O as l8,P as o8}from"../chunk-d0p3jzwb.js";import{Q as x6,R as y6,S as h6,T as g6,U as f6,V as u6,W as m6,X as p6,Y as d6}from"../chunk-r1ywapeb.js";import{$ as g9,Z as y9,_ as h9,aa as f9,ba as u9}from"../chunk-6qv7p9sg.js";import{$a as h8,Aa as M6,Ba as c6,Ca as l6,Da as o6,Ea as QX,Fa as s6,Ga as a6,Ha as i6,Ia as n6,Ja as r6,Ka as t6,La as F8,Ma as D8,Na as E8,Oa as L8,Pa as M8,Qa as w8,Ra as I8,Sa as T8,Ta as S8,Ua as k8,Va as C8,Wa as v8,Xa as b8,Ya as P8,Za as x8,_a as y8,ab as g8,bb as s8,cb as a8,db as i8,eb as n8,fb as r8,gb as t8,hb as mX,ib as e8,jb as X9,kb as Z9,lb as A9,mb as G9,nb as B9,ob as z9,pb as N9,qb as j9,rb as R9,sb as F9,tb as E9,ua as j6,ub as L9,va as R6,vb as M9,wa as F6,xa as D6,ya as E6,za as L6}from"../chunk-9a6yn7sv.js";import{$b as _6,Ab as v4,Bb as gZ,Cb as fZ,Db as p4,Eb as d4,Fb as c4,Gb as l4,Hb as o4,Ib as s4,Jb as a4,Kb as i4,Lb as n4,Mb as r4,Nb as t4,Ob as e4,Pb as X6,Qb as Z6,Rb as $6,Sb as J6,Tb as Q6,Ub as q6,Vb as Y6,Wb as V6,Xb as W6,Yb as K6,Zb as H6,_b as U6,ac as O6,bc as A6,cc as G6,dc as B6,ec as EX,fc as z6,gc as N6,wb as T4,xb as S4,yb as k4,zb as C4}from"../chunk-wfevdmvd.js";import{hc as SZ}from"../chunk-p1d09y82.js";import{ic as D9}from"../chunk-hrmnrn4p.js";import"../chunk-74j5mydx.js";import"../chunk-rnt0wkrk.js";import{Ac as O9,Bc as LX,oc as uZ,pc as $9,qc as J9,rc as Q9,sc as q9,tc as Y9,uc as V9,vc as W9,wc as K9,xc as H9,yc as U9,zc as _9}from"../chunk-begk3j01.js";import{Ec as b4,Fc as P4,Gc as x4,Hc as y4,Ic as h4,Jc as hZ,Kc as g4,Lc as f4,Mc as u4,Nc as m4}from"../chunk-xnq1xw73.js";import{Oc as V8,Pc as W8,Qc as K8,Rc as H8,Sc as U8,Tc as _8}from"../chunk-f18nyrrb.js";import{$c as Y8,Uc as e6,Vc as X8,Wc as Z8,Xc as $8,Yc as J8,Zc as Q8,_c as q8}from"../chunk-57agx6g8.js";import{ad as TZ,cd as v}from"../chunk-rw6j20e2.js";function C0(X){if(!X||typeof X!=="string")throw Error("Invalid file path: must be a non-empty string");return X}function v0(X){if(!X||typeof X!=="string")throw Error("Invalid directory path: must be a non-empty string");return X}function b0(X){if(!X||typeof X!=="string")throw Error("Invalid glob pattern: must be a non-empty string");return X}function P0(X){if(typeof X!=="string")throw TypeError("Invalid source code: must be a string");return X}function x0(X){if(typeof X!=="string")throw TypeError("Invalid DTS content: must be a string");return X}function y0(X){if(!X||typeof X!=="string")throw Error("Invalid module specifier: must be a non-empty string");return X}function h0(X){if(!X||typeof X!=="string")throw Error("Invalid type name: must be a non-empty string");if(!["string","number","boolean","symbol","bigint","undefined","null","void","never","any","unknown","object"].includes(X)&&!/^[A-Z_$]/.test(X));return X}function g0(X){if(!X||typeof X!=="string")throw Error("Invalid declaration name: must be a non-empty string");return X}function f0(X){if(!X||typeof X!=="string")throw Error("Invalid absolute path: must be a non-empty string");if(!X.startsWith("/")&&!/^[A-Z]:/i.test(X))throw Error("Invalid absolute path: must start with / or drive letter");return X}function u0(X){if(!X||typeof X!=="string")throw Error("Invalid relative path: must be a non-empty string");if(X.startsWith("/")||/^[A-Z]:/i.test(X))throw Error("Invalid relative path: must not be absolute");return X}function m0(X){if(typeof X!=="string")throw TypeError("Invalid JSON string: must be a string");try{JSON.parse(X)}catch{throw Error("Invalid JSON string: must be valid JSON")}return X}function p0(X,Z){return typeof X==="string"||typeof X==="number"}function d0(X){return X}var c0={join(X,...Z){let{join:$}=v("path");return $(X,...Z)},dirname(X){let{dirname:Z}=v("path");return Z(X)},basename(X){let{basename:Z}=v("path");return Z(X)},resolve(...X){let{resolve:Z}=v("path");return Z(...X)},isAbsolute(X){let{isAbsolute:Z}=v("path");return Z(X)},relative(X,Z){let{relative:$}=v("path");return $(X,Z)}};function nX(X,Z){let $=X.length,J=Z.length,Q=Array.from({length:$+1},()=>Array(J+1).fill(0));for(let q=1;q<=$;q++)for(let Y=1;Y<=J;Y++)if(X[q-1]===Z[Y-1])Q[q][Y]=Q[q-1][Y-1]+1;else Q[q][Y]=Math.max(Q[q-1][Y],Q[q][Y-1]);return Q}function rX(X,Z,$,J,Q){let q=[];while(J>0||Q>0)if(J>0&&Q>0&&Z[J-1]===$[Q-1])q.unshift({op:"equal",oldIdx:J-1,newIdx:Q-1,line:Z[J-1]}),J--,Q--;else if(Q>0&&(J===0||X[J][Q-1]>=X[J-1][Q]))q.unshift({op:"add",newIdx:Q-1,line:$[Q-1]}),Q--;else if(J>0)q.unshift({op:"remove",oldIdx:J-1,line:Z[J-1]}),J--;return q}function JX(X,Z){let $=X;if(Z.ignoreWhitespace)$=$.replace(/\s+/g," ").trim();return $}function d(X,Z,$,J={}){let{context:Q=3,ignoreWhitespace:q=!1,ignoreBlankLines:Y=!1}=J,V=X.split(`
3
+ `),W=Z.split(`
4
+ `);if(V[V.length-1]==="")V.pop();if(W[W.length-1]==="")W.pop();let K=V.map((F)=>JX(F,{ignoreWhitespace:q})),U=W.map((F)=>JX(F,{ignoreWhitespace:q})),O=K,H=U,A=V.map((F,w)=>w),_=W.map((F,w)=>w);if(Y)O=[],H=[],A=[],_=[],K.forEach((F,w)=>{if(F.trim())O.push(F),A.push(w)}),U.forEach((F,w)=>{if(F.trim())H.push(F),_.push(w)});let G=nX(O,H),B=rX(G,O,H,O.length,H.length),z=B.every((F)=>F.op==="equal"),j=0,N=0,R=0;for(let F of B)if(F.op==="add")j++;else if(F.op==="remove")N++;else R++;let k=tX(B,V,W,A,_,Q);return{filePath:$,identical:z,hunks:k,stats:{additions:j,deletions:N,unchanged:R},oldContent:X,newContent:Z}}function tX(X,Z,$,J,Q,q){let Y=[],V=[];if(X.forEach((U,O)=>{if(U.op!=="equal")V.push(O)}),V.length===0)return Y;let W=[],K=[V[0]];for(let U=1;U<V.length;U++)if(V[U]-V[U-1]<=q*2+1)K.push(V[U]);else W.push(K),K=[V[U]];W.push(K);for(let U of W){let O=Math.max(0,U[0]-q),H=Math.min(X.length-1,U[U.length-1]+q),A=X.slice(O,H+1),_=[],G=1,B=1,z=0,j=0;for(let N=0;N<O;N++){let R=X[N];if(R.op==="equal"||R.op==="remove")G++;if(R.op==="equal"||R.op==="add")B++}for(let N of A)if(N.op==="equal")_.push(` ${N.line}`),z++,j++;else if(N.op==="remove")_.push(`-${N.line}`),z++;else if(N.op==="add")_.push(`+${N.line}`),j++;Y.push({operation:"equal",lines:_,oldStart:G,oldCount:z,newStart:B,newCount:j})}return Y}function s0(X){if(X.identical)return"";let Z=[];Z.push(`--- a/${X.filePath}`),Z.push(`+++ b/${X.filePath}`);for(let $ of X.hunks)Z.push(`@@ -${$.oldStart},${$.oldCount} +${$.newStart},${$.newCount} @@`),Z.push(...$.lines);return Z.join(`
5
+ `)}function eX(X){if(X.identical)return`\x1B[32m\u2713 ${X.filePath} (unchanged)\x1B[0m`;let Z=[],$=`+${X.stats.additions} -${X.stats.deletions}`;Z.push(`\x1B[1m${X.filePath}\x1B[0m \x1B[90m(${$})\x1B[0m`),Z.push("");for(let J of X.hunks){Z.push(`\x1B[36m@@ -${J.oldStart},${J.oldCount} +${J.newStart},${J.newCount} @@\x1B[0m`);for(let Q of J.lines)if(Q.startsWith("+"))Z.push(`\x1B[32m${Q}\x1B[0m`);else if(Q.startsWith("-"))Z.push(`\x1B[31m${Q}\x1B[0m`);else Z.push(`\x1B[90m${Q}\x1B[0m`);Z.push("")}return Z.join(`
6
+ `)}function a0(X){if(X.identical)return`${X.filePath}: unchanged`;return`${X.filePath}: +${X.stats.additions} -${X.stats.deletions} lines`}async function XZ(X,Z,$={}){let J="";try{let Q=QX(X);if(await Q.exists())J=await Q.text();else if(!$.treatMissingAsEmpty)return d("",Z,X,$)}catch{if(!$.treatMissingAsEmpty)return d("",Z,X,$)}return d(J,Z,X,$)}async function i0(X,Z={}){let $=new Map;for(let[J,Q]of X){let q=await XZ(J,Q,Z);$.set(J,q)}return $}function ZZ(X){let Z=0,$=0,J=0,Q=0,q=0;for(let Y of X.values())if(Y.identical)$++;else if(Z++,J+=Y.stats.additions,Q+=Y.stats.deletions,!Y.oldContent)q++;return{totalFiles:X.size,changedFiles:Z,unchangedFiles:$,totalAdditions:J,totalDeletions:Q,newFiles:q}}function $Z(X){console.log(eX(X))}function n0(X,Z=!1){for(let J of X.values()){if(J.identical&&!Z)continue;$Z(J)}let $=ZZ(X);if(console.log(""),console.log(`\x1B[1mSummary:\x1B[0m ${$.totalFiles} files, ${$.changedFiles} changed, ${$.unchangedFiles} unchanged`),$.changedFiles>0)console.log(` \x1B[32m+${$.totalAdditions}\x1B[0m \x1B[31m-${$.totalDeletions}\x1B[0m lines`);if($.newFiles>0)console.log(` ${$.newFiles} new files`)}var YX=["builtin","external","internal","parent","sibling","index","type","unknown"];function VX(X){let Z=X.match(/^(import\s+)(type\s+)?(.+?)\s+from\s+["']([^"']+)["']/);if(!Z){let O=X.match(/^import\s+['"]([^'"]+)['"]/);if(O)return{statement:X,source:O[1],isTypeOnly:!1,group:c(O[1]),specifiers:[]};return null}let[,,$,J,Q]=Z,q=!!$,Y,V,W=[],K=J.trim(),U=K.match(/^\*\s+as\s+(\w+)$/);if(U)V=U[1];else if(K.includes("{")){let O=K.match(/^(\w+)\s*,/);if(O)Y=O[1];let H=K.match(/\{([^}]+)\}/);if(H){let A=H[1].split(",").map((_)=>_.trim()).filter(Boolean);W.push(...A)}}else if(/^\w+$/.test(K))Y=K;else{let O=K.match(/\{([^}]+)\}/);if(O){let H=O[1].split(",").map((A)=>A.trim()).filter(Boolean);W.push(...H)}}return{statement:X,source:Q,isTypeOnly:q,group:c(Q,q),specifiers:W,defaultImport:Y,namespaceImport:V}}function c(X,Z=!1){if(Z)return"type";if(X.startsWith("node:")||JZ(X))return"builtin";if(X.startsWith("./"))return"sibling";if(X.startsWith("../"))return"parent";if(X==="."||X==="./index")return"index";if(X.startsWith("@/")||X.startsWith("~/")||X.startsWith("#"))return"internal";if(X.startsWith("@")||/^[a-z]/.test(X))return"external";return"unknown"}function JZ(X){return["assert","buffer","child_process","cluster","console","constants","crypto","dgram","dns","domain","events","fs","http","https","module","net","os","path","perf_hooks","process","punycode","querystring","readline","repl","stream","string_decoder","sys","timers","tls","tty","url","util","v8","vm","wasi","worker_threads","zlib"].includes(X)}function WX(X,Z={}){let{order:$=[],groupByType:J=!0,groups:Q=YX,alphabetize:q=!0,caseInsensitive:Y=!0,typeImportsLast:V=!1,separateTypeImports:W=!1}=Z,K=[];for(let O of X){let H=VX(O);if(H)K.push(H);else K.push({statement:O,source:"",isTypeOnly:!1,group:"unknown",specifiers:[]})}let U=(O,H)=>{if($.length>0){let A=qX(O.source,$),_=qX(H.source,$);if(A!==_)return A-_}if(J){let A=Q.indexOf(O.group),_=Q.indexOf(H.group),G=A>=0?A:Q.length,B=_>=0?_:Q.length;if(G!==B)return G-B}if(V&&O.isTypeOnly!==H.isTypeOnly)return O.isTypeOnly?1:-1;if(q){let A=Y?O.source.toLowerCase():O.source,_=Y?H.source.toLowerCase():H.source;return A.localeCompare(_)}return 0};if(K.sort(U),J){let O=[],H=null;for(let A of K){if(H!==null&&A.group!==H){let _=Q.indexOf(H),G=Q.indexOf(A.group);if(_>=0&&G>=0&&_!==G)O.push("")}O.push(A.statement),H=A.group}return O}return K.map((O)=>O.statement)}function qX(X,Z){for(let $=0;$<Z.length;$++){let J=Z[$];if(J.startsWith("^"))try{if(new RegExp(J).test(X))return $}catch{if(X.startsWith(J.slice(1)))return $}else if(X.startsWith(J)||X.includes(`/${J}`))return $}return Z.length}function QZ(X,Z={}){let $=X.split(`
7
+ `),J=[],Q=[],q=-1;for(let K=0;K<$.length;K++){let U=$[K].trim();if(U.startsWith("import "))J.push($[K]),Q.push(K),q=K;else if(J.length>0&&U==="")continue;else if(J.length>0&&!U.startsWith("import "))break}if(J.length===0)return X;let Y=WX(J,Z),V=$.slice(0,Q[0]),W=$.slice(q+1);while(W.length>0&&W[0].trim()==="")W.shift();return[...V,...Y,"",...W].join(`
8
+ `)}function t0(X={}){return{sort:(Z)=>WX(Z,X),sortContent:(Z)=>QZ(Z,X),parse:VX,detectGroup:c}}var e0={default:{groupByType:!0,groups:YX,alphabetize:!0,caseInsensitive:!0},node:{order:["node:"],groupByType:!0,groups:["builtin","external","internal","parent","sibling","index"],alphabetize:!0},bun:{order:["bun","node:"],groupByType:!0,groups:["builtin","external","internal","parent","sibling","index"],alphabetize:!0},typeSeparated:{groupByType:!0,groups:["builtin","external","internal","parent","sibling","index","type"],separateTypeImports:!0,alphabetize:!0},alphabetical:{groupByType:!1,alphabetize:!0,caseInsensitive:!0},none:{groupByType:!1,alphabetize:!1}};import{createHash as KX}from"crypto";import{mkdir as qZ,readFile as HX,stat as l,writeFile as YZ}from"fs/promises";import{dirname as VZ,join as b}from"path";var g="1.0.0",WZ=".dtsx-cache",UX="manifest.json";class KZ{config;manifest=null;dirty=!1;stats={totalEntries:0,hits:0,misses:0,hitRatio:0,sizeBytes:0,timeSavedMs:0};constructor(X={}){this.config={enabled:X.enabled??!0,cacheDir:X.cacheDir??WZ,format:X.format??"json",maxAge:X.maxAge??86400000,force:X.force??!1,validateCache:X.validateCache??!0}}async init(){if(!this.config.enabled)return;try{await qZ(this.config.cacheDir,{recursive:!0}),await this.loadManifest()}catch{this.manifest={version:g,entries:{},createdAt:Date.now(),updatedAt:Date.now()}}}async loadManifest(){let X=b(this.config.cacheDir,UX);try{let Z=await HX(X,"utf-8");if(this.manifest=JSON.parse(Z),this.manifest.version!==g){await this.clear();return}this.stats.totalEntries=Object.keys(this.manifest.entries).length}catch{this.manifest={version:g,entries:{},createdAt:Date.now(),updatedAt:Date.now()}}}async save(){if(!this.config.enabled||!this.manifest||!this.dirty)return;let X=b(this.config.cacheDir,UX);this.manifest.updatedAt=Date.now(),await YZ(X,JSON.stringify(this.manifest,null,2)),this.dirty=!1}async get(X,Z){if(!this.config.enabled||!this.manifest||this.config.force)return this.stats.misses++,null;let $=this.manifest.entries[X];if(!$)return this.stats.misses++,null;if($.configHash!==Z)return this.stats.misses++,null;if(Date.now()-$.cachedAt>this.config.maxAge)return this.stats.misses++,delete this.manifest.entries[X],this.dirty=!0,null;if(this.config.validateCache)try{let Q=(await l(X)).mtimeMs;if(Q!==$.mtime){let q=await HX(X,"utf-8");if(this.hashContent(q)!==$.hash)return this.stats.misses++,null;$.mtime=Q,this.dirty=!0}}catch{return this.stats.misses++,delete this.manifest.entries[X],this.dirty=!0,null}for(let J of $.dependencies){let Q=this.manifest.entries[J];if(Q)try{if((await l(J)).mtimeMs!==Q.mtime)return this.stats.misses++,null}catch{return this.stats.misses++,null}}return this.stats.hits++,this.stats.timeSavedMs+=50,this.updateHitRatio(),$}async set(X,Z,$,J,Q,q){if(!this.config.enabled||!this.manifest)return;let Y=Date.now();try{Y=(await l(X)).mtimeMs}catch{}let V={filePath:X,hash:this.hashContent(Z),mtime:Y,declarations:$,dtsContent:J,dependencies:Q,cachedAt:Date.now(),configHash:q};this.manifest.entries[X]=V,this.stats.totalEntries=Object.keys(this.manifest.entries).length,this.dirty=!0}invalidate(X){if(!this.manifest)return;delete this.manifest.entries[X],this.dirty=!0;for(let[Z,$]of Object.entries(this.manifest.entries))if($.dependencies.includes(X))delete this.manifest.entries[Z]}async clear(){this.manifest={version:g,entries:{},createdAt:Date.now(),updatedAt:Date.now()},this.stats={totalEntries:0,hits:0,misses:0,hitRatio:0,sizeBytes:0,timeSavedMs:0},this.dirty=!0,await this.save()}getStats(){return{...this.stats}}hashContent(X){return KX("sha256").update(X).digest("hex").slice(0,16)}updateHitRatio(){let X=this.stats.hits+this.stats.misses;this.stats.hitRatio=X>0?this.stats.hits/X:0}static hashConfig(X){let Z={outdir:X.outdir,clean:X.clean,tsconfigPath:X.tsconfigPath};return KX("sha256").update(JSON.stringify(Z)).digest("hex").slice(0,16)}}function Q1(X,Z){let $=[],J=[],Q=[];return{async needsRebuild(q){return await X.get(q,Z)===null},async getCachedDeclarations(q){let Y=await X.get(q,Z);if(Y)return J.push(q),Y.declarations;return null},async getCachedDts(q){let Y=await X.get(q,Z);if(Y)return Y.dtsContent;return null},async cacheResult(q,Y,V,W,K=[]){await X.set(q,Y,V,W,K,Z),$.push(q)},skip(q){Q.push(q)},getResult(){return{rebuilt:$,cached:J,skipped:Q,stats:X.getStats()}},async save(){await X.save()}}}async function q1(X,Z=604800000){let $=X.getStats();if($.totalEntries>1000)return await X.clear(),$.totalEntries;return 0}function Y1(X){let Z=[];return Z.push("Incremental Build Results:"),Z.push(` Rebuilt: ${X.rebuilt.length} files`),Z.push(` From cache: ${X.cached.length} files`),Z.push(` Skipped: ${X.skipped.length} files`),Z.push(""),Z.push("Cache Statistics:"),Z.push(` Total entries: ${X.stats.totalEntries}`),Z.push(` Hit ratio: ${(X.stats.hitRatio*100).toFixed(1)}%`),Z.push(` Time saved: ~${X.stats.timeSavedMs}ms`),Z.join(`
9
+ `)}function V1(X,Z){let $=[],J=/import\s+(?:type\s+)?(?:.+(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])from\s+)?['"]([^'"]+)['"]/g,Q;while((Q=J.exec(X))!==null){let q=Q[1];if(q.startsWith(".")){let Y=b(VZ(Z),q);$.push(Y),$.push(`${Y}.ts`),$.push(`${Y}.tsx`),$.push(b(Y,"index.ts")),$.push(b(Y,"index.tsx"))}}return $}import{createReadStream as HZ,createWriteStream as UZ,statSync as _Z}from"fs";import{createInterface as OZ}from"readline";class _X{config;profiles=[];cleanupTimer=null;constructor(X={}){this.config={maxMemoryMB:X.maxMemoryMB??512,chunkSize:X.chunkSize??65536,aggressiveGC:X.aggressiveGC??!0,maxDeclarationsInMemory:X.maxDeclarationsInMemory??1e4,profile:X.profile??!1,cleanupInterval:X.cleanupInterval??5000}}startMonitoring(){if(this.cleanupTimer=setInterval(()=>{this.checkMemoryAndCleanup()},this.config.cleanupInterval),this.cleanupTimer&&typeof this.cleanupTimer==="object"&&"unref"in this.cleanupTimer)this.cleanupTimer.unref()}stopMonitoring(){if(this.cleanupTimer)clearInterval(this.cleanupTimer),this.cleanupTimer=null}checkMemoryAndCleanup(){if(this.getMemoryStats().heapUsedMB>this.config.maxMemoryMB)this.triggerCleanup()}triggerCleanup(){if(this.config.aggressiveGC&&global.gc)global.gc()}getMemoryStats(){let X=process.memoryUsage();return{heapUsed:X.heapUsed,heapTotal:X.heapTotal,external:X.external,arrayBuffers:X.arrayBuffers,rss:X.rss,heapUsedMB:Math.ceil(X.heapUsed/1024/1024),percentUsed:Math.min(100,Math.round(X.heapUsed/X.heapTotal*100))}}async profile(X,Z){if(!this.config.profile)return Z();let $=this.getMemoryStats(),J=Date.now();try{return await Z()}finally{let Q=this.getMemoryStats(),q=Date.now()-J;this.profiles.push({timestamp:Date.now(),operation:X,memoryBefore:$,memoryAfter:Q,duration:q})}}getProfiles(){return[...this.profiles]}clearProfiles(){this.profiles=[]}async*streamFile(X){let Z=HZ(X,{encoding:"utf-8",highWaterMark:this.config.chunkSize}),$=OZ({input:Z,crlfDelay:1/0});for await(let J of $)yield J}async processFileInChunks(X,Z,$=1000){let J=[],Q=[];for await(let q of this.streamFile(X))if(Q.push(q),Q.length>=$){let Y=await Z(Q);J.push(...Y),Q=[],this.checkMemoryAndCleanup()}if(Q.length>0){let q=await Z(Q);J.push(...q)}return J}async streamWrite(X,Z){let $=UZ(X,{encoding:"utf-8"});return new Promise((J,Q)=>{let q=async()=>{try{for await(let Y of Z)if(!$.write(Y))await new Promise((W)=>$.once("drain",()=>W()));$.end(),$.once("finish",J)}catch(Y){Q(Y)}};$.once("error",Q),q()})}}class AZ{declarations=new Map;registry=new FinalizationRegistry((X)=>{this.declarations.delete(X)});maxSize;constructor(X=1e4){this.maxSize=X}add(X,Z){if(this.declarations.size>=this.maxSize)this.evictOldest();let $=new WeakRef(Z);this.declarations.set(X,$),this.registry.register(Z,X)}get(X){return this.declarations.get(X)?.deref()}has(X){return this.declarations.get(X)?.deref()!==void 0}delete(X){this.declarations.delete(X)}clear(){this.declarations.clear()}get size(){return this.declarations.size}evictOldest(){let X=Math.ceil(this.maxSize*0.2),Z=Array.from(this.declarations.keys());for(let $=0;$<X&&$<Z.length;$++)this.declarations.delete(Z[$])}}class GZ{value=null;loaded=!1;loader;constructor(X){this.loader=X}async get(){if(!this.loaded)this.value=await this.loader(),this.loaded=!0;return this.value}isLoaded(){return this.loaded}unload(){this.value=null,this.loaded=!1}}class BZ{strings=new Map;maxSize;constructor(X=50000){this.maxSize=X}intern(X){if(X.length>100)return X;let Z=this.strings.get(X);if(Z!==void 0)return Z;if(this.strings.size>=this.maxSize){let $=Array.from(this.strings.keys());for(let J=0;J<$.length/2;J++)this.strings.delete($[J])}return this.strings.set(X,X),X}get size(){return this.strings.size}clear(){this.strings.clear()}}class zZ{pool=[];factory;reset;maxSize;constructor(X,Z,$=1000){this.factory=X,this.reset=Z,this.maxSize=$}acquire(){if(this.pool.length>0)return this.pool.pop();return this.factory()}release(X){if(this.pool.length<this.maxSize)this.reset(X),this.pool.push(X)}get size(){return this.pool.length}clear(){this.pool=[]}}function U1(X,Z={}){return{...X,memory:{maxMemoryMB:Z.maxMemoryMB??512,chunkSize:Z.chunkSize??65536,aggressiveGC:Z.aggressiveGC??!0,maxDeclarationsInMemory:Z.maxDeclarationsInMemory??1e4,profile:Z.profile??!1,cleanupInterval:Z.cleanupInterval??5000}}}function _1(X){let $=_Z(X).size/1024/1024,J=$*4,Q=65536;if($>10)Q=32768;if($>50)Q=16384;return{fileSizeMB:Math.round($*100)/100,estimatedMemoryMB:Math.round(J*100)/100,recommendedChunkSize:Q}}function O1(X){return[`Heap: ${X.heapUsedMB}MB / ${Math.round(X.heapTotal/1024/1024)}MB (${X.percentUsed}%)`,`RSS: ${Math.round(X.rss/1024/1024)}MB`,`External: ${Math.round(X.external/1024/1024)}MB`].join(" | ")}function A1(X={}){return new _X(X)}function B1(X,Z={}){let{mergeInterfaces:$=!0,mergeNamespaces:J=!0,mergeTypes:Q=!1,mergeEnums:q=!0,deduplicateIdentical:Y=!0,conflictStrategy:V="last",preserveAllComments:W=!0}=Z,K=[],U=0,O=new Map;for(let _ of X){let G=`${_.kind}:${_.name}`,B=O.get(G)||[];B.push(_),O.set(G,B)}let H=[],A=new Set;for(let _ of X){let G=`${_.kind}:${_.name}`;if(A.has(G))continue;A.add(G);let B=O.get(G);if(B.length===1){H.push(_);continue}if(!(_.kind==="interface"&&$||_.kind==="module"&&J||_.kind==="type"&&Q||_.kind==="enum"&&q)){H.push(...B);continue}let j=B;if(Y)j=NZ(B);if(j.length===1){H.push(j[0]);continue}let N;switch(_.kind){case"interface":N=RZ(j,V,W);break;case"module":N=FZ(j,V,W);break;case"enum":N=DZ(j,V,W);break;case"type":N=EZ(j,V,W);break;default:N=j[0]}H.push(N),U+=j.length-1,K.push({name:_.name,kind:_.kind,sourceCount:j.length,memberCount:N.members?.length||0})}return{declarations:H,mergedCount:U,merges:K}}function NZ(X){let Z=new Map;for(let $ of X){let J=jZ($.text);if(!Z.has(J))Z.set(J,$);else{let Q=Z.get(J);if(($.leadingComments?.length||0)>(Q.leadingComments?.length||0))Z.set(J,$)}}return Array.from(Z.values())}function jZ(X){return X.replace(/\s+/g," ").replace(/;\s*/g,";").trim()}function RZ(X,Z,$){let J=X[0],Q=new Map,q=[];for(let _ of X){if($&&_.leadingComments){for(let G of _.leadingComments)if(!q.includes(G))q.push(G)}if(_.members)for(let G of _.members)if(!Q.get(G.name))Q.set(G.name,G);else switch(Z){case"first":break;case"last":Q.set(G.name,G);break;case"error":throw Error(`Conflicting member '${G.name}' in interface '${J.name}'`)}}let Y=Array.from(Q.values()),V=Y.map((_)=>` ${_.text}`).join(`
10
+ `),W=J.generics||"",K=J.extends||"",U=new Set;for(let _ of X)if(_.extends){let G=_.extends.replace("extends","").trim().split(",");for(let B of G)U.add(B.trim())}if(U.size>0)K=`extends ${Array.from(U).join(", ")}`;let O=J.isExported?"export ":"",H=J.modifiers?.includes("declare")?"declare ":"",A=`${O}${H}interface ${J.name}${W} ${K} {
11
+ ${V}
12
+ }`;return{...J,members:Y,leadingComments:q.length>0?q:J.leadingComments,text:A.replace(/\s+\{/," {").replace(/\{\s*\n\s*\n/,`{
13
+ `),extends:K||void 0}}function FZ(X,Z,$){let J=X[0],Q=new Map,q=[];for(let O of X){if($&&O.leadingComments){for(let H of O.leadingComments)if(!q.includes(H))q.push(H)}if(O.members)for(let H of O.members){let A=`${H.kind}:${H.name}`;if(!Q.get(A))Q.set(A,H);else switch(Z){case"first":break;case"last":Q.set(A,H);break;case"error":throw Error(`Conflicting member '${H.name}' in namespace '${J.name}'`)}}}let Y=Array.from(Q.values()),V=Y.map((O)=>` ${O.text}`).join(`
14
+ `),W=J.isExported?"export ":"",K=J.modifiers?.includes("declare")?"declare ":"",U=`${W}${K}namespace ${J.name} {
15
+ ${V}
16
+ }`;return{...J,members:Y,leadingComments:q.length>0?q:J.leadingComments,text:U}}function DZ(X,Z,$){let J=X[0],Q=new Map,q=[];for(let H of X){if($&&H.leadingComments){for(let A of H.leadingComments)if(!q.includes(A))q.push(A)}if(H.members)for(let A of H.members)if(!Q.get(A.name))Q.set(A.name,A);else switch(Z){case"first":break;case"last":Q.set(A.name,A);break;case"error":throw Error(`Conflicting member '${A.name}' in enum '${J.name}'`)}}let Y=Array.from(Q.values()),V=Y.map((H)=>` ${H.name}${H.value!==void 0?` = ${H.value}`:""}`).join(`,
17
+ `),W=J.isExported?"export ":"",K=J.modifiers?.includes("declare")?"declare ":"",U=J.modifiers?.includes("const")?"const ":"",O=`${W}${K}${U}enum ${J.name} {
18
+ ${V}
19
+ }`;return{...J,members:Y,leadingComments:q.length>0?q:J.leadingComments,text:O}}function EZ(X,Z,$){let J=X[0],Q=[],q=[];for(let U of X){if($&&U.leadingComments){for(let O of U.leadingComments)if(!Q.includes(O))Q.push(O)}if(U.typeAnnotation){if(!q.includes(U.typeAnnotation))q.push(U.typeAnnotation)}}if(q.length<=1)return{...J,leadingComments:Q.length>0?Q:J.leadingComments};let Y=q.join(" | "),V=J.isExported?"export ":"",W=J.generics||"",K=`${V}type ${J.name}${W} = ${Y}`;return{...J,typeAnnotation:Y,leadingComments:Q.length>0?Q:J.leadingComments,text:K}}function z1(X,Z={}){let $=X.split(`
20
+ `),J=new Map,Q=null,q=0;for(let K=0;K<$.length;K++){let U=$[K],O=U.match(/^(export\s+)?(declare\s+)?interface\s+(\w+)/);if(O&&!Q){Q={name:O[3],start:K,lines:[U]},q=(U.match(/\{/g)||[]).length-(U.match(/\}/g)||[]).length;continue}if(Q){if(Q.lines.push(U),q+=(U.match(/\{/g)||[]).length-(U.match(/\}/g)||[]).length,q<=0){let H=J.get(Q.name)||[];H.push({start:Q.start,end:K,content:Q.lines}),J.set(Q.name,H),Q=null,q=0}}}let Y=Array.from(J.entries()).filter(([,K])=>K.length>1);if(Y.length===0)return X;let V=[...$],W=new Set;for(let[K,U]of Y){if(U.length<=1)continue;let[O,...H]=U,A=[],_=new Set;for(let z of U)for(let j of z.content){let N=j.trim();if(N.startsWith("interface")||N.startsWith("export")||N==="{"||N==="}")continue;if(N&&!_.has(N))_.add(N),A.push(j)}for(let z of H)for(let j=z.start;j<=z.end;j++)W.add(j);let G=O.content[0],B=[G.endsWith("{")?G:`${G} {`,...A,"}"];for(let z=O.start;z<=O.end;z++)W.add(z);V[O.start]=B.join(`
21
+ `)}return V.filter((K,U)=>!W.has(U)||V[U].includes("interface")).join(`
22
+ `).replace(/\n{3,}/g,`
23
+
24
+ `)}var GX=["import","type","interface","enum","class","function","variable","export","module","namespace","unknown"],LZ=["builtin","external","scoped","internal","parent","sibling","index","type"];function MZ(X,Z={}){let{lineEnding:$="lf",trailingNewline:J=!0,maxBlankLines:Q=1,trimTrailingWhitespace:q=!0,normalizeIndentation:Y=!0,indent:V={style:"spaces",size:2},declarationOrder:W,importGrouping:K,preserveComments:U=!0,insertFinalNewline:O=!0}=Z,H=X;if(H=BX(H,$),K?.enabled!==!1)H=RX(H,K||{});if(W)H=FX(H,W);if(q)H=zX(H);if(H=NX(H,Q),Y)H=wZ(H,V);if(J||O)H=jX(H);return H}function BX(X,Z){let $=X.replace(/\r\n/g,`
25
+ `).replace(/\r/g,`
26
+ `);if(Z==="crlf")$=$.replace(/\n/g,`\r
27
+ `);return $}function j1(X){let Z=(X.match(/\r\n/g)||[]).length,$=(X.match(/(?<!\r)\n/g)||[]).length;if(Z>$)return"crlf";return"lf"}function zX(X){return X.split(`
28
+ `).map((Z)=>Z.replace(/[\t ]+$/,"")).join(`
29
+ `)}function NX(X,Z){let $=new RegExp(`\\n{${Z+2},}`,"g");return X.replace($,`
30
+ `.repeat(Z+1))}function jX(X){return`${X.replace(/\s+$/,"")}
31
+ `}function wZ(X,Z){let{style:$="spaces",size:J=2}=Z,Q=$==="tabs"?"\t":" ".repeat(J),q=X.split(`
32
+ `),Y=[];for(let V of q){let W=V.match(/^([\t ]*)(.*)$/);if(!W){Y.push(V);continue}let[,K,U]=W;if(!U){Y.push("");continue}let O=K.replace(/\t/g," "),H=Math.floor(O.length/2);Y.push(Q.repeat(H)+U)}return Y.join(`
33
+ `)}function RX(X,Z){let{groups:$=LZ,separateGroups:J=!0,alphabetize:Q=!0}=Z,q=X.split(`
34
+ `),Y=[],V=[],W=-1;for(let _=0;_<q.length;_++){let G=q[_],B=OX(G);if(B)Y.push({line:G,source:B.source,group:B.group,isType:B.isType}),W=_;else if(Y.length>0&&G.trim()==="")continue;else if(Y.length>0||G.trim()!==""){if(Y.length===0||_>W+1)V.push(G)}}if(Y.length===0)return X;let K=new Map;for(let _ of $)K.set(_,[]);for(let _ of Y)(K.get(_.group)||K.get("external")||[]).push(_);if(Q)for(let[,_]of K)_.sort((G,B)=>{if(G.isType!==B.isType)return G.isType?1:-1;return G.source.localeCompare(B.source)});let U=[],O=null;for(let _ of $){let G=K.get(_)||[];if(G.length===0)continue;if(J&&O!==null)U.push("");for(let B of G)U.push(B.line);O=_}let H=q.slice(0,q.findIndex((_)=>OX(_)!==null)),A=V;while(A.length>0&&A[0].trim()==="")A.shift();return[...H,...U,"",...A].join(`
35
+ `)}function OX(X){let Z=X.trim(),$=Z.match(/^import\s+(type\s+)?.*from\s+['"]([^'"]+)['"]/);if(!$){let q=Z.match(/^import\s+['"]([^'"]+)['"]/);if(q)return{source:q[1],group:AX(q[1]),isType:!1};return null}let J=!!$[1],Q=$[2];return{source:Q,group:J?"type":AX(Q),isType:J}}function AX(X){if(X.startsWith("node:"))return"builtin";let Z=["assert","buffer","child_process","cluster","crypto","dgram","dns","events","fs","http","https","net","os","path","querystring","readline","stream","url","util","zlib"];if(Z.includes(X)||Z.includes(X.split("/")[0]))return"builtin";if(X==="."||X==="./index"||X==="./index.js"||X==="./index.ts")return"index";if(X.startsWith("./"))return"sibling";if(X.startsWith("../"))return"parent";if(X.startsWith("@/")||X.startsWith("~/")||X.startsWith("#"))return"internal";if(X.startsWith("@"))return"scoped";return"external"}function FX(X,Z){let{kinds:$=GX,alphabetize:J=!1,groupExports:Q=!0}=Z,q=X.split(`
36
+ `),Y=[],V=[],W=[],K=null,U=0,O=!0;for(let _=0;_<q.length;_++){let G=q[_],B=G.trim();U+=(G.match(/\{/g)||[]).length,U-=(G.match(/\}/g)||[]).length;let z=IZ(B);if(O&&z&&z.kind!=="import"&&!B.startsWith("//")&&!B.startsWith("/*"))O=!1;if(O){V.push(G);continue}if(z&&U<=1){if(K)Y.push(K);K={lines:[G],kind:z.kind,name:z.name,isExport:z.isExport}}else if(K)K.lines.push(G);else{if(B==="")continue;W.push(G)}}if(K)Y.push(K);Y.sort((_,G)=>{if(Q&&_.isExport!==G.isExport)return _.isExport?-1:1;let B=$.indexOf(_.kind),z=$.indexOf(G.kind),j=B>=0?B:$.length,N=z>=0?z:$.length;if(j!==N)return j-N;if(J)return _.name.localeCompare(G.name);return 0});let H=[...V],A=null;for(let _ of Y){if(A!==null&&_.kind!==A)H.push("");H.push(..._.lines),A=_.kind}if(W.length>0)H.push(""),H.push(...W);return H.join(`
37
+ `)}function IZ(X){let Z=X.startsWith("export "),$=Z?X.slice(7):X;if(X.startsWith("import "))return{kind:"import",name:X.match(/from\s+['"]([^'"]+)['"]/)?.[1]||"",isExport:!1};if($.startsWith("type ")||$.startsWith("declare type "))return{kind:"type",name:$.match(/type\s+(\w+)/)?.[1]||"",isExport:Z};if($.startsWith("interface ")||$.startsWith("declare interface "))return{kind:"interface",name:$.match(/interface\s+(\w+)/)?.[1]||"",isExport:Z};if($.startsWith("class ")||$.startsWith("abstract class ")||$.startsWith("declare class ")||$.startsWith("declare abstract class "))return{kind:"class",name:$.match(/class\s+(\w+)/)?.[1]||"",isExport:Z};if($.startsWith("enum ")||$.startsWith("const enum ")||$.startsWith("declare enum ")||$.startsWith("declare const enum "))return{kind:"enum",name:$.match(/enum\s+(\w+)/)?.[1]||"",isExport:Z};if($.startsWith("function ")||$.startsWith("async function ")||$.startsWith("declare function ")||$.startsWith("declare async function "))return{kind:"function",name:$.match(/function\s+(\w+)/)?.[1]||"",isExport:Z};if($.startsWith("const ")||$.startsWith("let ")||$.startsWith("var ")||$.startsWith("declare const ")||$.startsWith("declare let ")||$.startsWith("declare var "))return{kind:"variable",name:$.match(/(?:const|let|var)\s+(\w+)/)?.[1]||"",isExport:Z};if($.startsWith("namespace ")||$.startsWith("declare namespace "))return{kind:"namespace",name:$.match(/namespace\s+(\w+)/)?.[1]||"",isExport:Z};if($.startsWith("module ")||$.startsWith("declare module "))return{kind:"module",name:$.match(/module\s+['"]?(\w+)['"]?/)?.[1]||"",isExport:Z};if(X.startsWith("export {")||X.startsWith("export *")||X.startsWith("export type {"))return{kind:"export",name:"",isExport:!0};return null}function R1(X){let Z=X.split(`
38
+ `),$=[];for(let J=0;J<Z.length;J++){let Q=Z[J],q=Q.trim();if(q.startsWith("/**")||q.startsWith("*")||q.startsWith("*/")){$.push(Q);continue}if(q.startsWith("//")){$.push(Q);continue}if(q.startsWith("/*")||q.endsWith("*/")){$.push(Q);continue}$.push(Q)}return $.join(`
39
+ `)}function F1(X={}){return{normalize:(Z)=>MZ(Z,X),normalizeLineEndings:(Z)=>BX(Z,X.lineEnding||"lf"),removeTrailingWhitespace:zX,normalizeBlankLines:(Z)=>NX(Z,X.maxBlankLines||1),ensureTrailingNewline:jX,processImports:(Z)=>RX(Z,X.importGrouping||{}),orderDeclarations:(Z)=>FX(Z,X.declarationOrder||{})}}var D1={default:{lineEnding:"lf",trailingNewline:!0,maxBlankLines:1,trimTrailingWhitespace:!0,normalizeIndentation:!0,indent:{style:"spaces",size:2},importGrouping:{enabled:!0,separateGroups:!0,alphabetize:!0}},minimal:{lineEnding:"lf",trailingNewline:!0,maxBlankLines:2,trimTrailingWhitespace:!0,normalizeIndentation:!1,importGrouping:{enabled:!1}},strict:{lineEnding:"lf",trailingNewline:!0,maxBlankLines:1,trimTrailingWhitespace:!0,normalizeIndentation:!0,indent:{style:"spaces",size:2},importGrouping:{enabled:!0,separateGroups:!0,alphabetize:!0},declarationOrder:{kinds:GX,alphabetize:!0,groupExports:!0}},windows:{lineEnding:"crlf",trailingNewline:!0,maxBlankLines:1,trimTrailingWhitespace:!0,normalizeIndentation:!0,indent:{style:"spaces",size:2},importGrouping:{enabled:!0,separateGroups:!0,alphabetize:!0}},tabs:{lineEnding:"lf",trailingNewline:!0,maxBlankLines:1,trimTrailingWhitespace:!0,normalizeIndentation:!0,indent:{style:"tabs",size:1},importGrouping:{enabled:!0,separateGroups:!0,alphabetize:!0}}};var T=TZ(SZ(),1);import{readFile as MX}from"fs/promises";import{dirname as kZ,resolve as wX}from"path";async function CZ(X,Z=process.cwd()){let $=new Map;for(let J of X){let Q=wX(Z,J),q=await vZ(Q,Z);$.set(Q,{path:Q,dependencies:q,dependents:new Set,state:"pending"})}for(let[J,Q]of $)for(let q of Q.dependencies){let Y=$.get(q);if(Y)Y.dependents.add(J)}return $}async function vZ(X,Z){let $=new Set;try{let Y=function(V){if(T.default.isImportDeclaration(V)){let W=V.moduleSpecifier;if(T.default.isStringLiteral(W)){let K=W.text;if(K.startsWith(".")||K.startsWith("/")){let U=DX(K,q,Z);if(U)$.add(U)}}}else if(T.default.isExportDeclaration(V)&&V.moduleSpecifier){if(T.default.isStringLiteral(V.moduleSpecifier)){let W=V.moduleSpecifier.text;if(W.startsWith(".")||W.startsWith("/")){let K=DX(W,q,Z);if(K)$.add(K)}}}T.default.forEachChild(V,Y)},J=await MX(X,"utf-8"),Q=T.default.createSourceFile(X,J,T.default.ScriptTarget.Latest,!0,T.default.ScriptKind.TS),q=kZ(X);Y(Q)}catch{}return $}function DX(X,Z,$){let J=[".ts",".tsx",".d.ts","/index.ts","/index.tsx"],Q=wX(Z,X);for(let q of J){let Y=Q+q;if(!Y.includes("node_modules"))return Y}if(X.endsWith(".ts")||X.endsWith(".tsx"))return Q;return null}function bZ(X){let Z=[];for(let[$,J]of X){if(J.state!=="pending")continue;let Q=!0;for(let q of J.dependencies){let Y=X.get(q);if(Y&&Y.state!=="completed"){Q=!1;break}}if(Q)Z.push($)}return Z}async function PZ(X,Z={}){let $=await MX(X,"utf-8"),J=EX($,X,Z.keepComments??!0);return LX(J,{filePath:X,sourceCode:$,declarations:J})}async function T1(X,Z={}){let $=performance.now(),{maxConcurrency:J=4,rootDir:Q=process.cwd(),config:q={},onProgress:Y,onError:V}=Z,W=await CZ(X,Q),K=new Map,U=new Map,O=[],H=0,A=0,_=0,G=W.size;while(_<G){let B=bZ(W);if(B.length===0){let N=[...W.values()].filter((R)=>R.state==="pending");if(N.length>0)for(let R of N)R.state="failed",R.error=Error("Circular dependency detected or dependency failed"),U.set(R.path,R.error),_++;break}let z=B.slice(0,J-A);for(let N of z){let R=W.get(N);R.state="processing",A++}H=Math.max(H,A);let j=z.map(async(N)=>{let R=W.get(N),k=performance.now();try{let F=await PZ(N,q);R.state="completed",R.result=F,R.duration=performance.now()-k,K.set(N,F),O.push(N)}catch(F){if(R.state="failed",R.error=F instanceof Error?F:Error(String(F)),R.duration=performance.now()-k,U.set(N,R.error),V&&!V(N,R.error))throw Error("Processing aborted by error handler")}finally{A--,_++,Y?.(_,G,N)}});await Promise.all(j)}return{success:K,failed:U,totalTimeMs:performance.now()-$,maxConcurrent:H,processingOrder:O}}function S1(X){let Z=[],$=new Set,J=new Set;function Q(q){if($.has(q))return;if(J.has(q))return;J.add(q);let Y=X.get(q);if(Y){for(let V of Y.dependencies)if(X.has(V))Q(V)}J.delete(q),$.add(q),Z.push(q)}for(let q of X.keys())Q(q);return Z}function xZ(X){let Z=[];for(let[$,J]of X){let Q=!1;for(let q of J.dependencies)if(X.has(q)){Q=!0;break}if(!Q)Z.push($)}return Z}function yZ(X){let Z=[],$=new Set;while($.size<X.size){let J=[];for(let[Q,q]of X){if($.has(Q))continue;let Y=!0;for(let V of q.dependencies)if(X.has(V)&&!$.has(V)){Y=!1;break}if(Y)J.push(Q)}if(J.length===0){for(let Q of X.keys())if(!$.has(Q))J.push(Q)}for(let Q of J)$.add(Q);Z.push(J)}return Z}function k1(X){let Z=yZ(X),$=xZ(X),J=Math.max(...Z.map((q)=>q.length)),Q=X.size/Z.length;return{totalFiles:X.size,independentFiles:$.length,maxParallelism:J,levels:Z.length,estimatedSpeedup:Q}}function TX(X){let Z=X,$=!0;while($){$=!1;let J=Z.trimStart();if(J.startsWith("/*")){let Q=J.indexOf("*/",2);if(Q!==-1){Z=J.slice(Q+2),$=!0;continue}}if(J.startsWith("//")){let Q=J.indexOf(`
40
+ `);if(Q!==-1)Z=J.slice(Q+1),$=!0;else Z="",$=!0}}return Z.trim()}function v1(X,Z){let J=X.substring(0,Z).split(`
41
+ `),Q=[],q=J.length-1,Y=!1,V=[];while(q>=0){let W=J[q].trim();if(W.endsWith("*/")&&!Y)Y=!0,V.unshift(W);else if(W.startsWith("/*")&&Y)V.unshift(W),Q.unshift(...V),V=[],Y=!1;else if(Y)V.unshift(W);else if(W.startsWith("//"))Q.unshift(W);else if(W.startsWith("*")&&(q>0&&J[q-1].trim().startsWith("/*")))Q.unshift(W);else if(W===""&&Q.length>0);else if(W!=="")break;q--}return Q}function b1(X){let Z=!1,$="",J=!1;for(let Q=0;Q<X.length;Q++){let q=X[Q];if(!J&&!Z&&(q==='"'||q==="'"||q==="`"))Z=!0,$=q;else if(!J&&Z&&q===$)Z=!1;else if(q==="\\"&&!J){J=!0;continue}else if(!Z&&q==="/"&&Q<X.length-1){if(X[Q+1]==="/")return X.substring(Q)}J=!1}return null}function IX(X,Z,$){let J=0,Q=!1,q="",Y=!1;if(!X.startsWith(Z))return null;for(let V=0;V<X.length;V++){let W=X[V];if(!Y&&(W==='"'||W==="'"||W==="`")){if(!Q)Q=!0,q=W;else if(W===q)Q=!1}if(W==="\\"&&!Y){Y=!0;continue}if(Y=!1,!Q){if(X.substring(V,V+Z.length)===Z)J++;else if(X.substring(V,V+$.length)===$){if(J--,J===0)return{content:X.substring(0,V+$.length),rest:X.substring(V+$.length)}}}}return null}function P1(X){let Z=TX(X).trim(),$=Z.match(/^(export\s+)?(async\s+)?function\s*(\*?)([a-zA-Z_$][\w$]*)/);if(!$)return null;let J=[];if($[1])J.push("export");if($[2])J.push("async");if($[3])J.push("generator");let Q=$[4],q=Z.substring($[0].length).trim(),Y="";if(q.startsWith("<")){let K=IX(q,"<",">");if(K)Y=K.content,q=K.rest.trim()}let V="";if(q.startsWith("(")){let K=IX(q,"(",")");if(K)V=K.content.slice(1,-1).trim(),q=K.rest.trim()}let W="void";if(q.startsWith(":")){let K=q.match(/^:\s*([^{;]+)/);if(K)W=K[1].trim()}return{name:Q,generics:Y,parameters:V,returnType:W,modifiers:J}}function x1(X){return/^\s*export\s+/.test(X)}function y1(X){return/^\s*export\s+type\s+/.test(X)}function h1(X){let Z=TX(X).trim(),$=Z.match(/^(export\s+)?(const|let|var)\s+([a-zA-Z_$][\w$]*)/);if(!$)return null;let J=$[2],Q=$[3],q=Z.substring($[0].length).trim(),Y;if(q.startsWith(":")){let W=q.indexOf("=");if(W!==-1)Y=q.substring(1,W).trim(),q=q.substring(W).trim();else Y=q.substring(1).replace(/;?\s*$/,"").trim(),q=""}let V;if(q.startsWith("="))V=q.substring(1).replace(/;?\s*$/,"").trim();return{kind:J,name:Q,typeAnnotation:Y,value:V}}class kX{config;memorySamples=[];cpuSamples=[];ioOperations=[];startTime=0;memoryInterval=null;cpuInterval=null;lastCpuUsage=null;isRunning=!1;constructor(X={}){this.config={memory:X.memory??!1,memoryLimit:X.memoryLimit??1024,cpu:X.cpu??!1,samplingInterval:X.samplingInterval??100,io:X.io??!1,trackOperations:X.trackOperations??["read","write"],outputFile:X.outputFile??""}}start(){if(this.isRunning)return;if(this.isRunning=!0,this.startTime=Date.now(),this.memorySamples=[],this.cpuSamples=[],this.ioOperations=[],this.lastCpuUsage=null,this.config.memory)this.sampleMemory(),this.memoryInterval=setInterval(()=>this.sampleMemory(),this.config.samplingInterval);if(this.config.cpu)this.sampleCpu(),this.cpuInterval=setInterval(()=>this.sampleCpu(),this.config.samplingInterval)}stop(){if(!this.isRunning)return;if(this.isRunning=!1,this.memoryInterval)clearInterval(this.memoryInterval),this.memoryInterval=null;if(this.cpuInterval)clearInterval(this.cpuInterval),this.cpuInterval=null}sampleMemory(){let X=SX();this.memorySamples.push(X)}sampleCpu(){let X=mZ();if(this.lastCpuUsage){let Z={timestamp:Date.now(),user:X.user-this.lastCpuUsage.user,system:X.system-this.lastCpuUsage.system,total:X.user-this.lastCpuUsage.user+(X.system-this.lastCpuUsage.system)};this.cpuSamples.push(Z)}this.lastCpuUsage=X}recordIo(X,Z,$,J){if(!this.config.io)return;if(!this.config.trackOperations.includes(X))return;this.ioOperations.push({timestamp:Date.now(),operation:X,path:Z,size:$,durationMs:J})}getResults(){let X=Date.now(),Z=[],$=this.memorySamples[0]||SX(),J=0;for(let A of this.memorySamples){if(J+=A.heapUsed,A.heapUsed>$.heapUsed)$=A;let _=A.heapUsed/1048576;if(_>this.config.memoryLimit)Z.push(`Memory limit exceeded at ${new Date(A.timestamp).toISOString()}: ${_.toFixed(2)}MB > ${this.config.memoryLimit}MB`)}let Q=this.memorySamples.length>0?J/this.memorySamples.length:0,q=0,Y=0;for(let A of this.cpuSamples)q+=A.user,Y+=A.system;let V=0,W=0,K=0,U=0,O=0,H=0;for(let A of this.ioOperations)if(A.operation==="read")V++,K+=A.size,O+=A.durationMs;else W++,U+=A.size,H+=A.durationMs;return{startTime:this.startTime,endTime:X,durationMs:X-this.startTime,memory:{samples:this.memorySamples,peak:$,average:{timestamp:0,heapUsed:Q,heapTotal:0,external:0,arrayBuffers:0,rss:0},warnings:Z},cpu:{samples:this.cpuSamples,totalUser:q,totalSystem:Y},io:{operations:this.ioOperations,totalReads:V,totalWrites:W,totalReadBytes:K,totalWriteBytes:U,totalReadMs:O,totalWriteMs:H}}}formatResults(){let X=this.getResults(),Z=["=== Profiling Results ===",""];if(Z.push(`Duration: ${X.durationMs}ms`),Z.push(""),this.config.memory){if(Z.push("Memory:"),Z.push(` Samples: ${X.memory.samples.length}`),Z.push(` Peak heap: ${f(X.memory.peak.heapUsed)}`),Z.push(` Average heap: ${f(X.memory.average.heapUsed)}`),X.memory.warnings.length>0){Z.push(" Warnings:");for(let $ of X.memory.warnings)Z.push(` - ${$}`)}Z.push("")}if(this.config.cpu)Z.push("CPU:"),Z.push(` Samples: ${X.cpu.samples.length}`),Z.push(` Total user time: ${(X.cpu.totalUser/1000).toFixed(2)}ms`),Z.push(` Total system time: ${(X.cpu.totalSystem/1000).toFixed(2)}ms`),Z.push("");if(this.config.io)Z.push("I/O:"),Z.push(` Total reads: ${X.io.totalReads}`),Z.push(` Total writes: ${X.io.totalWrites}`),Z.push(` Total read: ${f(X.io.totalReadBytes)} in ${X.io.totalReadMs.toFixed(2)}ms`),Z.push(` Total write: ${f(X.io.totalWriteBytes)} in ${X.io.totalWriteMs.toFixed(2)}ms`),Z.push("");return Z.join(`
42
+ `)}async writeResults(){if(!this.config.outputFile)return;let X=this.getResults(),Z=JSON.stringify(X,null,2);try{await(await import("fs/promises")).writeFile(this.config.outputFile,Z,"utf-8")}catch{await Bun.write(this.config.outputFile,Z)}}}function SX(){if(typeof process<"u"&&process.memoryUsage){let X=process.memoryUsage();return{timestamp:Date.now(),heapUsed:X.heapUsed,heapTotal:X.heapTotal,external:X.external,arrayBuffers:X.arrayBuffers||0,rss:X.rss}}return{timestamp:Date.now(),heapUsed:0,heapTotal:0,external:0,arrayBuffers:0,rss:0}}function mZ(){if(typeof process<"u"&&process.cpuUsage){let X=process.cpuUsage();return{user:X.user,system:X.system}}return{user:0,system:0}}function f(X){if(X===0)return"0 B";let Z=["B","KB","MB","GB"],$=1024,J=Math.floor(Math.log(X)/Math.log($));return`${Number.parseFloat((X/$**J).toFixed(2))} ${Z[J]}`}function pZ(X){return new kX(X)}async function p1(X,Z){let $=pZ({memory:!0,cpu:!0,...Z});$.start();try{return{result:await X(),profile:$.getResults()}}finally{$.stop()}}function d1(X){return{async read(Z,$){let J=Date.now();try{let Q=await $(),q=typeof Q==="string"?Q.length:0;return X.recordIo("read",Z,q,Date.now()-J),Q}catch(Q){throw X.recordIo("read",Z,0,Date.now()-J),Q}},async write(Z,$,J){let Q=Date.now();try{await $(),X.recordIo("write",Z,J,Date.now()-Q)}catch(q){throw X.recordIo("write",Z,0,Date.now()-Q),q}}}}class CX{marks=new Map;durations=new Map;mark(X){this.marks.set(X,performance.now())}measure(X,Z){let $=this.marks.get(Z);if($===void 0)throw Error(`Mark "${Z}" not found`);let J=performance.now()-$,Q=this.durations.get(X)||[];return Q.push(J),this.durations.set(X,Q),J}getDurations(X){return this.durations.get(X)||[]}getAverage(X){let Z=this.getDurations(X);if(Z.length===0)return 0;return Z.reduce(($,J)=>$+J,0)/Z.length}getSummary(){let X=new Map;for(let[Z,$]of this.durations)X.set(Z,{count:$.length,total:$.reduce((J,Q)=>J+Q,0),average:$.reduce((J,Q)=>J+Q,0)/$.length,min:Math.min(...$),max:Math.max(...$)});return X}clear(){this.marks.clear(),this.durations.clear()}}function c1(){return new CX}import{lstat as dZ,realpath as cZ,stat as lZ}from"fs/promises";import{isAbsolute as o,normalize as bX,relative as oZ,resolve as vX}from"path";var S={rootDir:process.cwd(),maxFileSize:10485760,maxTotalSize:104857600,timeout:30000,followSymlinks:!1,maxFiles:1e4,blockedPatterns:["**/.git/**","**/node_modules/**","**/.env*","**/secrets/**","**/*.key","**/*.pem"]};class I extends Error{code;path;constructor(X,Z,$){super(X);this.code=Z;this.path=$;this.name="SecurityError"}}function m(X,Z={}){let{rootDir:$=process.cwd()}=Z,J=bX(X),Q=o(J)?J:vX($,J),q=vX(Q),Y=oZ($,q);if(Y.startsWith("..")||o(Y))throw new I(`Path traversal detected: "${X}" resolves outside root directory`,"PATH_TRAVERSAL",X);return q}function sZ(X,Z={}){return X.map(($)=>m($,Z))}function PX(X,Z={}){let $=Z.blockedPatterns||S.blockedPatterns;for(let J of $)if(aZ(X,J))return!0;return!1}function aZ(X,Z){let $=X.replace(/\\/g,"/"),J=Z.replace(/\*\*/g,"<<GLOBSTAR>>").replace(/\*/g,"<<STAR>>").replace(/\?/g,"<<QUESTION>>");return J=J.replace(/[.+^${}()|[\]\\]/g,"\\$&"),J=J.replace(/^<<GLOBSTAR>>\//,"(.*\\/)?"),J=J.replace(/\/<<GLOBSTAR>>$/,"(\\/.*)?"),J=J.replace(/\/<<GLOBSTAR>>\//g,"(\\/.*)?\\/"),J=J.replace(/<<GLOBSTAR>>/g,".*"),J=J.replace(/<<STAR>>/g,"[^/]*"),J=J.replace(/<<QUESTION>>/g,"[^/]"),new RegExp(`^${J}$`).test($)}async function iZ(X,Z={}){let $=Z.maxFileSize??S.maxFileSize;try{let J=await lZ(X);if(J.size>$)throw new I(`File too large: "${X}" is ${u(J.size)}, max is ${u($)}`,"FILE_TOO_LARGE",X);return J.size}catch(J){if(J instanceof I)throw J;throw new I(`Failed to check file size: ${X}`,"INVALID_PATH",X)}}async function nZ(X){try{return(await dZ(X)).isSymbolicLink()}catch{return!1}}async function rZ(X,Z={}){let $=Z.followSymlinks??S.followSymlinks;if(await nZ(X)){if(!$)throw new I(`Symbolic links not allowed: "${X}"`,"SYMLINK_NOT_ALLOWED",X);let J=await cZ(X);return m(J,Z)}return X}async function s(X,Z={}){let $=m(X,Z);if(PX($,Z))throw new I(`Path matches blocked pattern: "${X}"`,"BLOCKED_PATTERN",X);let J=await rZ($,Z),Q=await iZ(J,Z);return{path:J,size:Q}}async function xX(X,Z={}){let $=Z.maxFiles??S.maxFiles,J=Z.maxTotalSize??S.maxTotalSize;if(X.length>$)throw new I(`Too many files: ${X.length} exceeds maximum of ${$}`,"MAX_FILES_EXCEEDED");let Q=[],q=0;for(let Y of X){let V=await s(Y,Z);if(Q.push(V.path),q+=V.size,q>J)throw new I(`Total size exceeded: ${u(q)} exceeds maximum of ${u(J)}`,"TOTAL_SIZE_EXCEEDED")}return{paths:Q,totalSize:q}}function a(X,Z,$="Operation"){return new Promise((J,Q)=>{let q=setTimeout(()=>{Q(new I(`${$} timed out after ${Z}ms`,"TIMEOUT"))},Z);X.then((Y)=>{clearTimeout(q),J(Y)}).catch((Y)=>{clearTimeout(q),Q(Y)})})}function tZ(X,Z={}){let $=Z.timeout??S.timeout;return async(J)=>{let{path:Q}=await s(J,Z);return a(X(Q),$,`Processing ${J}`)}}function a1(X,Z={}){let $=Z.timeout??S.timeout;return async(J)=>{let{paths:Q}=await xX(J,Z);return a(X(Q),$,`Processing ${J.length} files`)}}function i1(X){let Z=X.replace(/\\/g,"/").replace(/\0/g,"").replace(/^\/+/,"").replace(/^[A-Z]:/i,""),$="";while($!==Z)$=Z,Z=Z.replace(/\.\.\/|\.\.$/g,"").replace(/\/+/g,"/");return Z.replace(/^\/+|\/+$/g,"")}function n1(X){if(X.includes("\x00"))return!1;if(bX(X).includes(".."))return!1;if(o(X)&&!X.startsWith(process.cwd()))return!1;return!0}function u(X){if(X===0)return"0 B";let Z=["B","KB","MB","GB"],$=1024,J=Math.floor(Math.log(X)/Math.log($));return`${Number.parseFloat((X/$**J).toFixed(2))} ${Z[J]}`}function r1(X={}){let Z={...S,...X};return{validatePath:($)=>m($,Z),validatePaths:($)=>sZ($,Z),validateFile:($)=>s($,Z),validateBatch:($)=>xX($,Z),withTimeout:($,J)=>a($,Z.timeout,J),secureProcessor:($)=>tZ($,Z),isBlocked:($)=>PX($,Z),getConfig:()=>Z}}import{readFile as eZ,writeFile as X0}from"fs/promises";import{basename as Z0,dirname as yX,relative as $0,resolve as J0}from"path";class hX{file;sourceRoot;sources=[];sourcesContent=[];names=[];mappings=[];sourceIndexMap=new Map;nameIndexMap=new Map;constructor(X){this.file=X.file,this.sourceRoot=X.sourceRoot}addSource(X,Z){let $=this.sourceIndexMap.get(X);if($===void 0)$=this.sources.length,this.sources.push(X),this.sourcesContent.push(Z??null),this.sourceIndexMap.set(X,$);else if(Z&&!this.sourcesContent[$])this.sourcesContent[$]=Z;return $}addName(X){let Z=this.nameIndexMap.get(X);if(Z===void 0)Z=this.names.length,this.names.push(X),this.nameIndexMap.set(X,Z);return Z}addMapping(X){let Z=this.addSource(X.source),$;if(X.name)$=this.addName(X.name);this.mappings.push({generated:X.generated,original:X.original,sourceIndex:Z,nameIndex:$})}generate(X=!1){this.mappings.sort(($,J)=>{if($.generated.line!==J.generated.line)return $.generated.line-J.generated.line;return $.generated.column-J.generated.column});let Z={version:3,file:this.file,sources:this.sources,names:this.names,mappings:this.encodeMappings()};if(this.sourceRoot)Z.sourceRoot=this.sourceRoot;if(X)Z.sourcesContent=this.sourcesContent;return Z}encodeMappings(){let X=[],Z=0,$=0,J=0,Q=0,q=0,Y=0,V=[];for(let W of this.mappings){while(Z<W.generated.line)X.push(V.join(",")),V=[],Z++,$=0;let K=[];if(K.push(W.generated.column-$),$=W.generated.column,K.push(W.sourceIndex-J),J=W.sourceIndex,K.push(W.original.line-Q),Q=W.original.line,K.push(W.original.column-q),q=W.original.column,W.nameIndex!==void 0)K.push(W.nameIndex-Y),Y=W.nameIndex;V.push(Q0(K))}return X.push(V.join(",")),X.join(";")}toString(X=!1){return JSON.stringify(this.generate(X))}toDataUrl(X=!1){let Z=this.toString(X);return`data:application/json;charset=utf-8;base64,${Buffer.from(Z).toString("base64")}`}toComment(X=!1){return`//# sourceMappingURL=${this.toDataUrl(X)}`}}class i{map;decodedMappings=null;constructor(X){this.map=typeof X==="string"?JSON.parse(X):X}originalPositionFor(X){let Z=this.getMappings(),$=0,J=Z.length-1,Q=null;while($<=J){let q=Math.floor(($+J)/2),Y=Z[q];if(Y.generated.line===X.line)if(Y.generated.column===X.column){Q=Y;break}else if(Y.generated.column<X.column)Q=Y,$=q+1;else J=q-1;else if(Y.generated.line<X.line)$=q+1;else J=q-1}if(!Q)return{source:null,line:null,column:null,name:null};return{source:this.map.sources[Q.sourceIndex]||null,line:Q.original.line,column:Q.original.column,name:Q.nameIndex!==void 0?this.map.names[Q.nameIndex]:null}}generatedPositionFor(X){let Z=this.map.sources.indexOf(X.source);if(Z===-1)return null;let $=this.getMappings();for(let J of $)if(J.sourceIndex===Z&&J.original.line===X.line&&J.original.column<=X.column)return J.generated;return null}getMappings(){if(!this.decodedMappings)this.decodedMappings=Y0(this.map.mappings);return this.decodedMappings}sourceContentFor(X){let Z=this.map.sources.indexOf(X);if(Z===-1||!this.map.sourcesContent)return null;return this.map.sourcesContent[Z]}}function Q0(X){return X.map(q0).join("")}function q0(X){let q="",Y=X<0?-X<<1|1:X<<1;do{let V=Y&31;if(Y>>>=5,Y>0)V|=32;q+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[V]}while(Y>0);return q}function Y0(X){let Z=[],$="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",J=0,Q=0,q=0,Y=0,V=0,W=0,K=X.split(";");for(let U of K){if(Q=0,U){let O=U.split(",");for(let H of O){if(!H)continue;let A=V0(H,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");if(A.length>=1)Q+=A[0];if(A.length>=4){q+=A[1],Y+=A[2],V+=A[3];let _={generated:{line:J,column:Q},original:{line:Y,column:V},sourceIndex:q};if(A.length>=5)W+=A[4],_.nameIndex=W;Z.push(_)}}}J++}return Z}function V0(X,Z){let J=[],Q=0,q=0;for(let Y of X){let V=Z.indexOf(Y);if(V===-1)continue;let W=V&32;if(q+=(V&31)<<Q,W)Q+=5;else{let K=q&1;q>>=1,J.push(K?-q:q),q=0,Q=0}}return J}function Z3(X){let Z=new hX({file:Z0(X.generatedFile),sourceRoot:X.sourceRoot}),$=$0(yX(X.generatedFile),X.sourceFile);Z.addSource($,X.sourceContent);for(let J of X.mappings)Z.addMapping({generated:{line:J.generatedLine,column:J.generatedColumn},original:{line:J.originalLine,column:J.originalColumn},source:$,name:J.name});return Z}function $3(X,Z){return`${X}
43
+ //# sourceMappingURL=${Z}`}function J3(X,Z,$=!1){return`${X}
44
+ ${Z.toComment($)}`}async function Q3(X,Z,$=!1){await X0(X,Z.toString($))}async function W0(X){let Z=await eZ(X,"utf-8");return new i(Z)}async function q3(X,Z){let $=X.match(/\/\/# sourceMappingURL=data:application\/json[^,]+,(\S+)/);if($){let Q=$[1],q=Buffer.from(Q,"base64").toString("utf-8");return new i(q)}let J=X.match(/\/\/# sourceMappingURL=(.+)$/);if(J){let Q=J0(yX(Z),J[1].trim());try{return await W0(Q)}catch{return null}}return null}function Y3(X,Z){let $=X,J=Z,Q=$.split(`
45
+ `),q=[],Y=0,V=0;for(let W of J){while(Y+Q[V].length+1<=W.generatedStart&&V<Q.length-1)Y+=Q[V].length+1,V++;let K=W.generatedStart-Y;q.push({generatedLine:V,generatedColumn:Math.max(0,K),originalLine:W.originalLine,originalColumn:W.originalColumn,name:W.name})}return q}class gX{config;types=new Map;imports=new Map;relationships=[];usageMap=new Map;constructor(X={}){this.config={types:!1,relationships:!1,usage:!1,imports:!1,importUsage:!1,importRelationships:!1,...X}}trackType(X,Z){if(!this.config.types)return;if(["interface","type","class","enum"].includes(X.kind)){if(this.types.get(X.name))return;let J={name:X.name,kind:X.kind,file:Z,usedBy:new Set,references:new Set,extendsFrom:X.extends?[X.extends]:void 0,implementsFrom:X.implements};if(this.types.set(X.name,J),this.config.relationships){if(X.extends)this.relationships.push({from:X.name,to:X.extends,kind:"extends",file:Z});if(X.implements)for(let Q of X.implements)this.relationships.push({from:X.name,to:Q,kind:"implements",file:Z})}}}trackTypeUsage(X,Z,$){if(!this.config.usage)return;let J=this.types.get(X);if(J)J.usedBy.add(Z);let Q=this.usageMap.get(X)||new Set;if(Q.add(`${$}:${Z}`),this.usageMap.set(X,Q),this.config.relationships)this.relationships.push({from:Z,to:X,kind:"uses",file:$})}trackImport(X,Z,$,J){if(!this.config.imports)return;let Q={source:X,specifiers:Z,isTypeOnly:$,file:J,usedSpecifiers:new Set,unusedSpecifiers:new Set(Z)},q=this.imports.get(J)||[];q.push(Q),this.imports.set(J,q)}trackImportUsage(X,Z){if(!this.config.importUsage)return;let $=this.imports.get(Z);if(!$)return;for(let J of $)if(J.specifiers.includes(X))J.usedSpecifiers.add(X),J.unusedSpecifiers.delete(X)}trackTypeReference(X,Z){if(!this.config.types)return;let $=this.types.get(X);if($)$.references.add(Z)}getResults(){let X=[],Z=[];for(let[Q,q]of this.types)if(q.usedBy.size===0&&q.references.size===0)X.push(Q);for(let Q of this.imports.values())for(let q of Q)if(q.unusedSpecifiers.size===q.specifiers.length)Z.push(q);let $=this.detectCircularReferences(),J={totalTypes:this.types.size,usedTypes:this.types.size-X.length,unusedTypes:X.length,totalImports:Array.from(this.imports.values()).flat().length,usedImports:Array.from(this.imports.values()).flat().filter((Q)=>Q.usedSpecifiers.size>0).length,unusedImports:Z.length,totalRelationships:this.relationships.length,circularDependencies:$.length};return{types:this.types,imports:this.imports,relationships:this.relationships,unusedTypes:X,unusedImports:Z,circularReferences:$,statistics:J}}detectCircularReferences(){let X=[],Z=new Set,$=[],J=(Q)=>{if($.includes(Q)){let Y=$.indexOf(Q);X.push($.slice(Y));return}if(Z.has(Q))return;Z.add(Q),$.push(Q);let q=this.relationships.filter((Y)=>Y.from===Q&&(Y.kind==="extends"||Y.kind==="implements"||Y.kind==="references")).map((Y)=>Y.to);for(let Y of q)J(Y);$.pop()};for(let Q of this.types.keys())J(Q);return X}clear(){this.types.clear(),this.imports.clear(),this.relationships=[],this.usageMap.clear()}formatResults(){let X=this.getResults(),Z=["=== Tracking Results ===",""];if(Z.push("Statistics:"),Z.push(` Total types: ${X.statistics.totalTypes}`),Z.push(` Used types: ${X.statistics.usedTypes}`),Z.push(` Unused types: ${X.statistics.unusedTypes}`),Z.push(` Total imports: ${X.statistics.totalImports}`),Z.push(` Used imports: ${X.statistics.usedImports}`),Z.push(` Unused imports: ${X.statistics.unusedImports}`),Z.push(` Type relationships: ${X.statistics.totalRelationships}`),Z.push(` Circular dependencies: ${X.statistics.circularDependencies}`),Z.push(""),X.unusedTypes.length>0){Z.push("Unused types:");for(let $ of X.unusedTypes){let J=X.types.get($);Z.push(` - ${$} (${J?.kind}) in ${J?.file}`)}Z.push("")}if(X.unusedImports.length>0){Z.push("Unused imports:");for(let $ of X.unusedImports)Z.push(` - ${$.source} in ${$.file}`),Z.push(` Specifiers: ${Array.from($.unusedSpecifiers).join(", ")}`);Z.push("")}if(X.circularReferences.length>0){Z.push("Circular references:");for(let $ of X.circularReferences)Z.push(` - ${$.join(" -> ")} -> ${$[0]}`);Z.push("")}return Z.join(`
46
+ `)}}function fX(X){return new gX(X)}function uX(X,Z,$){for(let J of X){if($.trackType(J,Z),J.typeAnnotation){let Q=K0(J.typeAnnotation);for(let q of Q)$.trackTypeUsage(q,J.name,Z)}if(J.extends)$.trackTypeUsage(J.extends,J.name,Z);if(J.implements)for(let Q of J.implements)$.trackTypeUsage(Q,J.name,Z);if(J.kind==="import"&&J.source&&J.specifiers)$.trackImport(J.source,J.specifiers.map((Q)=>Q.name),J.isTypeOnly||!1,Z)}}function K0(X){let Z=[],$=new Set(["string","number","boolean","any","unknown","void","never","null","undefined","object","symbol","bigint","true","false","readonly","keyof","typeof","infer","extends","in","out"]),J=/\b([A-Z]\w*)\b/g,Q;while((Q=J.exec(X))!==null){let q=Q[1];if(!$.has(q.toLowerCase())&&!Z.includes(q))Z.push(q)}return Z}function W3(X,Z){let $=fX({imports:!0,importUsage:!0,importRelationships:!0,...Z});for(let[J,Q]of X)uX(Q,J,$);return $.getResults()}function K3(X,Z){let $=fX({types:!0,relationships:!0,usage:!0,...Z});for(let[J,Q]of X)uX(Q,J,$);return $.getResults()}function H0(X,Z,$,J={}){return{kind:X,name:Z,text:$,isExported:J.isExported??!1,...J}}function U0(X){return JSON.parse(JSON.stringify(X))}function pX(X,Z,$=null){for(let J of X){Z.enter?.(J,$);let Q=Z[J.kind];if(Q)Q(J,$);if(J.members&&J.members.length>0)pX(J.members,Z,J);Z.leave?.(J,$)}}function _3(X,Z){let $=[];return pX(X,{enter:(J)=>{if(Z(J))$.push(J)}}),$}async function _0(X,Z,$){let J=[],Q=X.length;for(let q=0;q<X.length;q++){let Y=X[q],V={...$,index:q,total:Q,allDeclarations:X},W=await Z(Y,V);if(W===null)continue;else if(W===void 0)J.push(Y);else if(Array.isArray(W))J.push(...W);else J.push(W)}return J}function O3(...X){return async(Z,$)=>{let J=Z;for(let Q of X){if(J===null)return null;if(Array.isArray(J)){let q=[];for(let Y of J){let V=await Q(Y,$);if(V===null)continue;if(V===void 0)q.push(Y);else if(Array.isArray(V))q.push(...V);else q.push(V)}J=q.length>0?q:null}else{let q=await Q(J,$);if(q===null)J=null;else if(q===void 0);else J=q}}return J}}function P(X,Z){let $=new Set(Array.isArray(X)?X:[X]);return async(J,Q)=>{if($.has(J.kind))return Z(J,Q);return}}function A3(X,Z){return async($,J)=>{if(X($))return Z($,J);return}}function p(X){let Z={createDeclaration:H0,cloneDeclaration:U0,modifyText:($,J)=>({...$,text:J}),addModifier:($,J)=>({...$,modifiers:[...$.modifiers||[],J]}),removeModifier:($,J)=>({...$,modifiers:($.modifiers||[]).filter((Q)=>Q!==J)})};return mX({name:X.name,version:X.version,description:X.description,onBeforeFile:X.beforeParse?async($)=>{return X.beforeParse($.content,{filePath:$.filePath,phase:"before"})}:void 0,onDeclarations:X.transform?async($)=>{return _0($.declarations,X.transform,{filePath:$.filePath,sourceCode:$.sourceCode,...Z})}:void 0,onAfterFile:X.afterGenerate?async($)=>{return X.afterGenerate($.content,{filePath:$.filePath,phase:"after"})}:void 0})}function G3(X,Z){let $=typeof X==="string"?new RegExp(X):X;return(J)=>{if($.test(J.name)){let Q=typeof Z==="function"?Z(J.name,J):J.name.replace($,Z),q=J.text.replace(new RegExp(`\\b${x(J.name)}\\b`),Q);return{...J,name:Q,text:q}}return}}function O0(X,Z){return($)=>{if($.kind==="import")return;if(Z&&!Z($))return;let J=`${X}${$.name}`,Q=$.text.replace(new RegExp(`\\b${x($.name)}\\b`),J);return{...$,name:J,text:Q}}}function B3(X,Z){return($)=>{if($.kind==="import")return;if(Z&&!Z($))return;let J=`${$.name}${X}`,Q=$.text.replace(new RegExp(`\\b${x($.name)}\\b`),J);return{...$,name:J,text:Q}}}function A0(X){let Z=typeof X==="function"?X:($)=>{return(typeof X==="string"?new RegExp(X):X).test($.name)};return($)=>{if(Z($))return null;return}}function z3(X){return(Z)=>{let $=X(Z);if(!$)return;let Q=(Array.isArray($)?$:[$]).map((q)=>{if(q.startsWith("/**"))return q;if(q.startsWith("/*"))return q;return`/** ${q} */`});return{...Z,leadingComments:[...Z.leadingComments||[],...Q]}}}function N3(X){return(Z)=>{if(!Z.typeAnnotation)return;let $=X(Z.typeAnnotation,Z);if($===null)return null;if($===void 0)return;let J=Z.text.replace(new RegExp(`:[ ]*${x(Z.typeAnnotation)}`),`: ${$}`);return{...Z,typeAnnotation:$,text:J}}}function j3(X){return P("function",(Z)=>{if(!Z.returnType)return;let $=X(Z.returnType,Z);if($===null)return null;if($===void 0)return;let J=Z.text.replace(new RegExp(`\\):[ ]*${x(Z.returnType)}`),`): ${$}`);return{...Z,returnType:$,text:J}})}function R3(X){return P(["function","class"],(Z)=>{if(!Z.parameters)return;let $=X(Z.parameters,Z);if($===null)return null;if($===void 0)return;let J=$.map((q)=>{let Y="";if(q.rest)Y+="...";if(Y+=q.name,q.optional)Y+="?";if(q.type)Y+=`: ${q.type}`;if(q.defaultValue)Y+=` = ${q.defaultValue}`;return Y}).join(", "),Q=Z.text.replace(/\([^)]*\)/,`(${J})`);return{...Z,parameters:$,text:Q}})}function G0(X,Z){return($)=>{if(Z&&!Z($))return;if($.modifiers?.includes(X))return;let J=[...$.modifiers||[],X],Q=$.text;if(!Q.includes(X)){let q=["function","class","interface","type","enum","const","let","var"];for(let Y of q){let V=Q.indexOf(Y);if(V>=0){Q=`${Q.slice(0,V)}${X} ${Q.slice(V)}`;break}}}return{...$,modifiers:J,text:Q}}}var B0=P(["interface","type"],(X)=>{let Z=X.text.replace(/(\n\s*)(\w+)(\??:\s)/g,"$1readonly $2$3");if(Z===X.text)return;return{...X,text:Z}}),F3=P(["interface","type"],(X)=>{let Z=X.text.replace(/(\w+)\?:/g,"$1:");if(Z===X.text)return;return{...X,text:Z}}),D3=P(["interface","type"],(X)=>{let Z=X.text.replace(/(\w+)(?<!\?):/g,"$1?:");if(Z===X.text)return;return{...X,text:Z}});function E3(X){let Z=new RegExp(`@(${X.join("|")})\\b[^@]*`,"g");return($)=>{if(!$.leadingComments?.length)return;let J=$.leadingComments.map((q)=>{return q.replace(Z,"").replace(/\n\s*\*\s*\n/g,`
47
+ `)});if(!J.some((q,Y)=>q!==$.leadingComments[Y]))return;return{...$,leadingComments:J}}}function L3(X,Z){return($)=>{if(Z&&!Z($))return;if(!$.typeAnnotation)return;let J=`${X}<${$.typeAnnotation}>`,Q=$.text.replace($.typeAnnotation,J);return{...$,typeAnnotation:J,text:Q}}}var M3=p({name:"readonly",version:"1.0.0",description:"Makes all interface properties readonly",transform:B0}),w3=p({name:"strip-private",version:"1.0.0",description:"Strips @internal, @private, and @hidden declarations",transform:A0((X)=>{if(!X.leadingComments)return!1;return X.leadingComments.some((Z)=>/@(internal|private|hidden)\b/.test(Z))})}),I3=p({name:"declare",version:"1.0.0",description:"Adds declare keyword to all declarations",transform:G0("declare",(X)=>X.kind!=="import")});function T3(X){return p({name:`namespace-prefix-${X}`,version:"1.0.0",description:`Prefixes exported declarations with ${X}`,transform:O0(`${X}_`,(Z)=>Z.isExported&&Z.kind!=="import")})}function x(X){return X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r(X,Z={}){let{entryPoints:$,keepExported:J=!0,keep:Q=[],remove:q=[],shakableKinds:Y=["type","interface"],debug:V=!1}=Z,W=V?console.log.bind(console,"[tree-shake]"):()=>{},K=new Map;for(let z of X)K.set(z.name,z);let U=t(X);W("Dependency graph:",Object.fromEntries(Array.from(U.entries()).map(([z,j])=>[z,Array.from(j)])));let O=new Set;if($&&$.length>0){for(let z of $)if(K.has(z))O.add(z)}else for(let z of X){if(J&&z.isExported){O.add(z.name);continue}if(n(z.name,Q)){O.add(z.name);continue}if(!Y.includes(z.kind))O.add(z.name)}for(let z of X)if(n(z.name,Q))O.add(z.name);W("Entry points:",Array.from(O));let H=dX(O,U);W("Reachable:",Array.from(H));let A=new Set,_=[];for(let z of X){let j=z.name;if(H.has(j)){A.add(j);continue}if(n(j,q)){_.push(j);continue}if(!Y.includes(z.kind)){A.add(j);continue}_.push(j)}W("Keeping:",Array.from(A)),W("Removing:",_);let G=X.filter((z)=>A.has(z.name)),B={totalBefore:X.length,totalAfter:G.length,removedCount:_.length,reductionPercent:X.length>0?Math.round(_.length/X.length*100):0};return{declarations:G,removed:_,dependencyGraph:U,stats:B}}function t(X){let Z=new Map,$=new Set(X.map((J)=>J.name));for(let J of X){let Q=new Set,q=e(J);for(let Y of q)if($.has(Y)&&Y!==J.name)Q.add(Y);Z.set(J.name,Q)}return Z}function e(X){let Z=new Set;if(X.typeAnnotation)y(X.typeAnnotation,Z);if(X.extends)y(X.extends,Z);if(X.text)z0(X.text,Z);if(X.members)for(let $ of X.members){let J=e($);for(let Q of J)Z.add(Q)}if(X.parameters){for(let $ of X.parameters)if($.type)y($.type,Z)}if(X.returnType)y(X.returnType,Z);return Z}function y(X,Z){let $=new Set(["string","number","boolean","object","any","unknown","never","void","null","undefined","symbol","bigint","true","false","Array","Object","String","Number","Boolean","Function","Symbol","Promise","Map","Set","WeakMap","WeakSet","Record","Partial","Required","Readonly","Pick","Omit","Exclude","Extract","NonNullable","Parameters","ReturnType","InstanceType","ConstructorParameters","ThisParameterType","OmitThisParameter","ThisType","Uppercase","Lowercase","Capitalize","Uncapitalize","Awaited","keyof","typeof","infer","extends","readonly","const","new"]),J=/\b([A-Z]\w*)\b/g,Q;while((Q=J.exec(X))!==null){let q=Q[1];if(!$.has(q))Z.add(q)}}function z0(X,Z){y(X,Z)}function dX(X,Z){let $=new Set,J=Array.from(X);while(J.length>0){let Q=J.shift();if($.has(Q))continue;$.add(Q);let q=Z.get(Q);if(q){for(let Y of q)if(!$.has(Y))J.push(Y)}}return $}function n(X,Z){for(let $ of Z)if(typeof $==="string"){if($.includes("*")){if(new RegExp(`^${$.replace(/\*/g,".*").replace(/\?/g,".")}$`).test(X))return!0}else if(X===$)return!0}else if($.test(X))return!0;return!1}function N0(X,Z={}){let $=X.split(`
48
+ `),J=[],Q=null;for(let U=0;U<$.length;U++){let O=$[U],H=O.trim();if(!Q&&(H===""||H.startsWith("//")))continue;if(!Q){let A=H.match(/^(export\s+)?(declare\s+)?(interface|type|enum|class|function|const|let|var)\s+(\w+)/);if(A){let[,_,,G,B]=A;if(Q={name:B,kind:G,isExported:!!_,start:U,lines:[O],braceCount:0},Q.braceCount+=(O.match(/\{/g)||[]).length,Q.braceCount-=(O.match(/\}/g)||[]).length,Q.braceCount===0&&(H.endsWith(";")||!H.includes("{")))J.push({name:Q.name,kind:Q.kind,isExported:Q.isExported,start:Q.start,end:U,text:Q.lines.join(`
49
+ `)}),Q=null;continue}}if(Q){if(Q.lines.push(O),Q.braceCount+=(O.match(/\{/g)||[]).length,Q.braceCount-=(O.match(/\}/g)||[]).length,Q.braceCount<=0&&(H.endsWith("}")||H.endsWith(";")))J.push({name:Q.name,kind:Q.kind,isExported:Q.isExported,start:Q.start,end:U,text:Q.lines.join(`
50
+ `)}),Q=null}}if(J.length===0)return{content:X,removed:[]};let q=J.map((U)=>({name:U.name,kind:U.kind,isExported:U.isExported,text:U.text})),Y=r(q,Z),V=new Set(Y.declarations.map((U)=>U.name)),W=new Set;for(let U of J)if(!V.has(U.name))for(let O=U.start;O<=U.end;O++)W.add(O);return{content:$.filter((U,O)=>!W.has(O)).join(`
51
+ `).replace(/\n{3,}/g,`
52
+
53
+ `),removed:Y.removed}}function j0(X,Z={}){return r(X,{...Z,debug:!1}).removed}function R0(X,Z){let $=t(Z),J=$.get(X)||new Set,Q=dX(new Set([X]),$);Q.delete(X);let q=[];for(let[Y,V]of $)if(Y!==X&&V.has(X))q.push(Y);return{directDependencies:Array.from(J),transitiveDependencies:Array.from(Q),dependents:q}}function k3(X={}){return{shake:(Z)=>r(Z,X),shakeContent:(Z)=>N0(Z,X),findUnused:(Z)=>j0(Z,X),analyzeDependencies:(Z,$)=>R0(Z,$),buildGraph:t,extractRefs:e}}var F0=[{pattern:/^Promise<void>$/,replacement:"Promise<void>",priority:-1},{pattern:/^Record<string,\s*any>$/,replacement:"Record<string, unknown>",priority:0},{pattern:/^Array<([^<>]+)>$/,replacement:"$1[]",priority:0}],D0=[{pattern:/\bany\b/,replacement:"unknown",global:!0,priority:10},{pattern:/^object$/,replacement:"Record<string, unknown>",priority:10},{pattern:/^Function$/,replacement:"(...args: unknown[]) => unknown",priority:10}],E0=[{pattern:/^(\w+)\[\]$/,replacement:"readonly $1[]",priority:5},{pattern:/^Array<(.+)>$/,replacement:"ReadonlyArray<$1>",priority:5},{pattern:/^Map<(.+),\s*(.+)>$/,replacement:"ReadonlyMap<$1, $2>",priority:5},{pattern:/^Set<(.+)>$/,replacement:"ReadonlySet<$1>",priority:5}],L0=[{pattern:/^Partial<Partial<(.+)>>$/,replacement:"Partial<$1>",priority:5},{pattern:/^Required<Required<(.+)>>$/,replacement:"Required<$1>",priority:5},{pattern:/^Pick<Omit<(.+),\s*(.+)>,\s*(.+)>$/,replacement:"Pick<$1, $3>",priority:5}];function M0(X){switch(X){case"strict":return D0;case"readonly":return E0;case"simplified":return L0;case"nullable":return[{pattern:/^(.+)\s*\|\s*undefined$/,replacement:"$1 | undefined",priority:5}];case"branded":return[{pattern:/^string$/,replacement:"string",condition:(Z)=>Z.declarationKind==="variable"&&(Z.declarationName?.includes("path")??!1),priority:5}];default:return[]}}class cX{rules;cache=new Map;constructor(X={rules:[]}){if(this.rules=[],X.includeDefaults!==!1)this.rules.push(...F0);if(X.presets)for(let Z of X.presets)this.rules.push(...M0(Z));this.rules.push(...X.rules),this.rules.sort((Z,$)=>($.priority||0)-(Z.priority||0))}map(X,Z={}){let $=`${X}:${JSON.stringify(Z)}`,J=this.cache.get($);if(J!==void 0)return J;let Q=X,q={type:X,...Z};for(let Y of this.rules){if(Y.condition&&!Y.condition(q))continue;let V=typeof Y.pattern==="string"?new RegExp(Y.pattern.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Y.global?"g":""):Y.pattern;if(V.test(Q)){if(Q=Q.replace(V,Y.replacement),!Y.global)break}}return this.cache.set($,Q),Q}mapAll(X,Z={}){return X.map(($)=>this.map($,{...Z,type:$}))}addRule(X){this.rules.push(X),this.rules.sort((Z,$)=>($.priority||0)-(Z.priority||0)),this.cache.clear()}removeRules(X){let Z=this.rules.length;return this.rules=this.rules.filter(($)=>{let J=typeof $.pattern==="string"?$.pattern:$.pattern.source;return typeof X==="string"?J!==X:!X.test(J)}),this.cache.clear(),Z-this.rules.length}clearCache(){this.cache.clear()}getRules(){return this.rules}}function lX(X={rules:[]}){return new cX(X)}var v3=lX({rules:[]}),b3=lX({rules:[],presets:["strict"]});function P3(X,Z,$={}){return X.replace(/:\s*([^;,)\]}]+)/g,(J,Q)=>{return`: ${Z.map(Q.trim(),$)}`})}var x3={makeReadonly:(X)=>{if(X.endsWith("[]"))return`readonly ${X}`;if(X.startsWith("Array<"))return X.replace("Array<","ReadonlyArray<");return X},makeNullable:(X)=>{if(X.includes("| null")||X.includes("| undefined"))return X;return`${X} | null`},makeOptional:(X)=>{if(X.includes("| undefined"))return X;return`${X} | undefined`},makeRequired:(X)=>{return X.replace(/\s*\|\s*null/g,"").replace(/\s*\|\s*undefined/g,"").trim()},promisify:(X)=>{if(X.startsWith("Promise<"))return X;return`Promise<${X}>`},unpromisify:(X)=>{let Z=X.match(/^Promise<(.+)>$/);return Z?Z[1]:X},arrayify:(X)=>{if(X.endsWith("[]")||X.startsWith("Array<"))return X;return`${X}[]`},unarrayify:(X)=>{if(X.endsWith("[]"))return X.slice(0,-2);let Z=X.match(/^(?:Readonly)?Array<(.+)>$/);return Z?Z[1]:X}};import{watch as w0}from"fs";import{readdir as I0,stat as T0}from"fs/promises";import{join as oX,relative as XX}from"path";function S0(X,Z){let{root:$,include:J=["**/*.ts","**/*.tsx"],exclude:Q=["**/node_modules/**","**/*.d.ts","**/dist/**"],debounce:q=100,initialBuild:Y=!0,clearScreen:V=!1,onChange:W,onBuildStart:K,onBuildComplete:U,onError:O}=X,H=[],A=new Set,_=!1,G=new Map,B=null,z=!1;function j(L){let E=XX($,L);for(let M of Q)if(N(E,M))return!1;for(let M of J)if(N(E,M))return!0;return!1}function N(L,E){let M=E.replace(/\./g,"\\.").replace(/\*\*/g,"{{DOUBLESTAR}}").replace(/\*/g,"[^/]*").replace(/\{\{DOUBLESTAR\}\}/g,".*").replace(/\?/g,".");return new RegExp(`^${M}$`).test(L.replace(/\\/g,"/"))}async function R(){if(z||G.size===0)return;z=!0;let L=Array.from(G.values());G.clear();try{for(let D of L)await W?.(D);if(V)console.clear();await K?.();let E=L.filter((D)=>D.type!=="unlink").map((D)=>D.path),M=await Z(E.length>0?E:void 0);await U?.(M)}catch(E){await O?.(E)}finally{if(z=!1,G.size>0)k()}}function k(){if(B)clearTimeout(B);B=setTimeout(()=>{B=null,R()},q)}function F(L,E,M){if(!E||!_)return;let D=oX(M,E);if(!j(D))return;let C={type:L==="rename"?"add":"change",path:D,relativePath:XX($,D)};T0(D).then(()=>{A.add(D)}).catch(()=>{C.type="unlink",A.delete(D)}).finally(()=>{G.set(D,C),k()})}async function w(L){let E=[L];try{let M=await I0(L,{withFileTypes:!0});for(let D of M)if(D.isDirectory()){let C=oX(L,D.name),ZX=XX($,C),$X=!1;for(let h of Q)if(N(ZX,h)||N(`${ZX}/`,h)){$X=!0;break}if(!$X){let h=await w(C);E.push(...h)}}}catch{}return E}async function sX(){if(_)return;_=!0;let L=await w($);for(let E of L)try{let M=w0(E,{persistent:!0},(D,C)=>{F(D,C,E)});M.on("error",(D)=>{O?.(D)}),H.push(M)}catch(M){await O?.(M)}if(Y){await K?.();let E=await Z();await U?.(E)}}function aX(){if(_=!1,B)clearTimeout(B),B=null;for(let L of H)L.close();H.length=0,A.clear(),G.clear()}async function iX(){await K?.();let L=await Z();return await U?.(L),L}return{start:sX,stop:aX,rebuild:iX,isWatching:()=>_,getWatchedFiles:()=>Array.from(A)}}async function u3(X,Z){let $=async(Q)=>{let q=Date.now();try{let Y=await Z(X);return{success:Y.errors.length===0,duration:Date.now()-q,filesProcessed:Y.filesProcessed,errors:Y.errors}}catch(Y){return{success:!1,duration:Date.now()-q,filesProcessed:0,errors:[Y.message]}}},J=S0({root:X.root||X.cwd||process.cwd(),include:X.include,exclude:X.exclude,debounce:X.debounce,initialBuild:X.initialBuild,clearScreen:X.clearScreen,onChange:X.onChange,onBuildStart:X.onBuildStart,onBuildComplete:X.onBuildComplete,onError:X.onError},$);return await J.start(),J}function k0(X){let Z=X.success?"\u2713":"\u2717",$=`${X.duration}ms`;if(X.success)return`${Z} Built ${X.filesProcessed} file(s) in ${$}`;else return`${Z} Build failed in ${$}
54
+ ${X.errors.map((J)=>` - ${J}`).join(`
55
+ `)}`}function m3(){return{onChange:(X)=>{let Z=X.type==="add"?"+":X.type==="unlink"?"-":"~";console.log(`[${Z}] ${X.relativePath}`)},onBuildStart:()=>{console.log(`
56
+ Rebuilding...`)},onBuildComplete:(X)=>{console.log(k0(X))},onError:(X)=>{console.error(`Error: ${X.message}`)}}}export{G9 as writeToFile,r6 as writeTextFile,Q3 as writeSourceMap,s6 as write,b8 as wrapError,a as withTimeout,u3 as watchAndGenerate,M9 as watch,pX as walkDeclarations,rZ as validateSymlink,sZ as validatePaths,m as validatePath,P6 as validateGeneratedDeclarations,iZ as validateFileSize,s as validateFilePath,xX as validateFileBatch,N9 as validateDtsContent,T6 as validateDeclarations,d0 as unwrap,b6 as typeCheckWithConfig,I6 as typeCheck,N0 as treeShakeContent,r as treeShake,uX as trackDeclarations,u8 as toZod,d8 as toYup,m8 as toValibot,f8 as toJsonSchema,p8 as toIoTs,c8 as toArkType,g8 as summarizeErrors,ZZ as summarizeDiffs,w3 as stripPrivatePlugin,e8 as stripInternalPlugin,D0 as strictTypeMappings,b3 as strictTypeMapper,C9 as startLSPServer,a6 as spawnProcess,p9 as sortProjectsByDependencies,QZ as sortImportsInContent,WX as sortImports,L0 as simplifiedTypeMappings,C4 as shouldUseAsyncParsing,o4 as shouldIncludeNonExportedInterface,l4 as shouldIncludeNonExportedFunction,q8 as setTimestamps,Q8 as setLogPrefix,$8 as setLogLevel,Z8 as scopedLogger,i1 as sanitizeFilename,o6 as runtime,o9 as resolveWorkspacePatterns,E6 as resolveEntryFiles,K8 as resetConfig,F3 as requiredTransformer,zX as removeTrailingWhitespace,TX as removeLeadingComments,E0 as readonlyTypeMappings,B0 as readonlyTransformer,M3 as readonlyPlugin,i6 as readTextFile,W0 as readSourceMap,n8 as quickFormat,q1 as pruneCache,p1 as profileExecution,J9 as processVariableDeclaration,q9 as processTypeDeclaration,D9 as processSource,H9 as processModuleDeclaration,Q9 as processInterfaceDeclaration,T1 as processInParallel,RX as processImports,W9 as processImportDeclaration,$9 as processFunctionDeclaration,L9 as processFile,K9 as processExportDeclaration,V9 as processEnumDeclaration,LX as processDeclarations,Y9 as processClassDeclaration,n0 as printDiffs,$Z as printDiff,e0 as presets,R1 as preserveCommentFormatting,t8 as pluginManager,h1 as parseVariableDeclaration,O8 as parseJSDoc,_9 as parseImportStatement,VX as parseImport,P1 as parseFunctionDeclaration,y4 as parseArrayElements,g9 as parallelProcess,FX as orderDeclarations,D3 as optionalTransformer,P9 as optimizeFile,b9 as optimizeDeclarations,Y8 as nullLogger,D1 as normalizerPresets,MZ as normalizeOutput,BX as normalizeLineEndings,wZ as normalizeIndent,NX as normalizeBlankLines,x9 as minifyDts,z1 as mergeDeclarationsInContent,B1 as mergeDeclarations,_0 as mapDeclarations,X8 as logger,w6 as loadCompilerOptions,y1 as isTypeOnlyExport,nZ as isSymlink,n1 as isSafePath,k8 as isParseError,l6 as isNode,f4 as isGenericType,C8 as isFileError,x1 as isExportStatement,S8 as isDtsxError,v8 as isConfigError,c6 as isBun,s4 as isBuiltInType,p0 as isBranded,PX as isBlockedPath,h4 as inferObjectType,P4 as inferNarrowTypeInUnion,b4 as inferNarrowType,g4 as inferFunctionType,x4 as inferArrayType,d4 as hasExportModifier,c4 as hasAsyncModifier,k6 as getTypeAtPosition,S1 as getTopologicalOrder,T4 as getSourceFileCacheSize,S4 as getSourceFileAsync,t6 as getRuntimeInfo,C6 as getQuickInfo,yZ as getProcessingLevels,M0 as getPresetMappings,v4 as getPendingParseCount,p4 as getParameterName,gZ as getNodeText,J8 as getLogLevel,P8 as getLocationFromOffset,t4 as getInterfaceBody,f6 as getGraphSummary,o8 as getFormatExtension,W8 as getConfig,B9 as getAllTypeScriptFiles,d9 as generateWorkspace,N8 as generateTypeDocJSON,c9 as generateMonorepo,G8 as generateMarkdown,z8 as generateJSON,B8 as generateHTML,s9 as generateFromPackageWorkspaces,j8 as generateDocs,R9 as generateDeclarationMap,E9 as generate,k0 as formatWatchResult,s0 as formatUnifiedDiff,v6 as formatTypeCheckResults,O1 as formatMemoryStats,Y1 as formatIncrementalResult,a8 as formatFiles,x8 as formatErrorWithContext,h8 as formatDtsError,s8 as formatDts,a0 as formatDiffSummary,uZ as formatComments,eX as formatColoredDiff,g6 as formatCircularAnalysis,j0 as findUnusedDeclarations,A6 as findReferencedTypes,hZ as findMatchingBracket,xZ as findIndependentFiles,_3 as findDeclarations,u6 as findAllDependents,m6 as findAllDependencies,A3 as filterByPredicate,P as filterByKind,n6 as fileExists,QX as file,W6 as extractVariableStatement,a4 as extractTypesFromModuleText,e as extractTypeReferences,H6 as extractTypeAliasDeclaration,m4 as extractTripleSlashDirectives,b1 as extractTrailingComment,q3 as extractSourceMap,u4 as extractSatisfiesType,G6 as extractReferencedTypeDeclarations,O6 as extractModuleDeclaration,fZ as extractLeadingCommentsFromNode,v1 as extractLeadingComments,fZ as extractJSDocComments,K6 as extractInterfaceDeclaration,Q6 as extractImportDeclaration,V6 as extractFunctionDeclaration,q6 as extractExportDeclaration,Y6 as extractExportAssignment,_6 as extractEnumDeclaration,A8 as extractDocumentation,V1 as extractDependencies,z6 as extractDeclarationsAsync,EX as extractDeclarations,U6 as extractClassDeclaration,IX as extractBalancedSymbols,O9 as extractAllImportedItems,d6 as exportGraphAsJson,p6 as exportGraphAsDot,_1 as estimateMemoryUsage,jX as ensureTrailingNewline,M6 as ensureGitignore,m9 as discoverWorkspaceProjects,l9 as discoverWorkspaceFromPackageJson,i0 as diffFiles,XZ as diffFile,j1 as detectLineEnding,c as detectGroup,y6 as detectCircularDependencies,mX as definePlugin,U8 as defineConfigAsync,H8 as defineConfig,F0 as defaultTypeMappings,v3 as defaultTypeMapper,V8 as defaultConfig,I3 as declarePlugin,L3 as createWrapTypeTransformer,h9 as createWorkerPool,S0 as createWatcher,m3 as createWatchLogger,N3 as createTypeTransformer,lX as createTypeMapper,k3 as createTreeShaker,p as createTransformerPlugin,fX as createTracker,c1 as createTimer,B3 as createSuffixTransformer,E3 as createStripTagsTransformer,A1 as createStreamingProcessor,Z3 as createSourceMap,r1 as createSecurityMiddleware,tZ as createSecureProcessor,a1 as createSecureBatchProcessor,j3 as createReturnTypeTransformer,G3 as createRenameTransformer,A0 as createRemoveTransformer,pZ as createProfiler,d1 as createProfiledIo,O0 as createPrefixTransformer,R3 as createParameterTransformer,F1 as createOutputNormalizer,T3 as createNamespacePrefixPlugin,G0 as createModifierTransformer,U1 as createMemoryOptimizedConfig,e6 as createLogger,z3 as createJSDocTransformer,Q1 as createIncrementalBuilder,t0 as createImportSorter,i8 as createFormatter,Z9 as createFilterPlugin,v9 as createFileWatcher,y8 as createDtsError,R8 as createDocsGenerator,j9 as createDiff,H0 as createDeclaration,D6 as createBundler,X9 as createBannerPlugin,l8 as convertToFormat,_8 as config,d as computeDiff,O3 as composeTransformers,U0 as cloneDeclaration,B6 as clearSourceFileCache,U9 as clearProcessorCaches,z9 as checkIsolatedDeclarationsConfig,S6 as checkIsolatedDeclarations,u9 as calculateOptimalBatchSize,R6 as bundleDtsFiles,j6 as bundleDeclarations,F6 as bundleAndWrite,n4 as buildVariableDeclaration,e4 as buildTypeDeclaration,CZ as buildProcessingGraph,$6 as buildModuleDeclaration,J6 as buildModuleBody,r4 as buildInterfaceDeclaration,i4 as buildFunctionSignature,x6 as buildDependencyGraph,Y3 as buildDeclarationMappings,t as buildDeclarationDependencyGraph,X6 as buildClassDeclaration,Z6 as buildClassBody,k4 as batchParseSourceFiles,f9 as batchFiles,N6 as batchExtractDeclarations,A9 as assertNever,h0 as asTypeName,P0 as asSourceCode,u0 as asRelativePath,y0 as asModuleSpecifier,m0 as asJsonString,b0 as asGlobPattern,C0 as asFilePath,x0 as asDtsContent,v0 as asDirectoryPath,g0 as asDeclarationName,f0 as asAbsolutePath,P3 as applyTypeMappings,$3 as appendSourceMapComment,J3 as appendInlineSourceMap,K3 as analyzeTypes,k1 as analyzeParallelizationPotential,W3 as analyzeImports,R0 as analyzeDependencies,h6 as analyzeCircularDependencies,F9 as addSourceMapComment,y9 as WorkerPool,x3 as TypeTransformers,cX as TypeMapper,gX as Tracker,CX as Timer,I9 as SymbolKind,BZ as StringInterner,_X as StreamingProcessor,hX as SourceMapGenerator,i as SourceMapConsumer,I as SecurityError,kX as Profiler,M8 as ProcessingError,r8 as PluginManager,E8 as ParseError,zZ as ObjectPool,w9 as LspDiagnosticSeverity,GZ as LazyLoader,KZ as IncrementalCache,w8 as FileError,L8 as ExtractionError,F8 as ErrorCodes,k9 as DtsxLanguageServer,D8 as DtsxError,S9 as DocumentHighlightKind,AZ as DeclarationPool,S as DEFAULT_SECURITY_CONFIG,LZ as DEFAULT_IMPORT_GROUP_ORDER,YX as DEFAULT_GROUP_ORDER,GX as DEFAULT_DECLARATION_ORDER,I8 as ConfigError,T9 as CompletionItemKind,T8 as CircularDependencyError,L6 as BuildCache,c0 as BrandedPath};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{fa as a,ga as b,ha as c}from"../../chunk-n28rjf9h.js";import"../../chunk-9a6yn7sv.js";import"../../chunk-wfevdmvd.js";import"../../chunk-p1d09y82.js";import"../../chunk-hrmnrn4p.js";import"../../chunk-74j5mydx.js";import"../../chunk-rnt0wkrk.js";import"../../chunk-begk3j01.js";import"../../chunk-xnq1xw73.js";import"../../chunk-f18nyrrb.js";import"../../chunk-57agx6g8.js";import"../../chunk-rw6j20e2.js";export{a as dts,c as default,b as bunDts};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ia as a,ja as b,ka as c,la as d}from"../../chunk-ywd4k4hn.js";import"../../chunk-9a6yn7sv.js";import"../../chunk-wfevdmvd.js";import"../../chunk-p1d09y82.js";import"../../chunk-hrmnrn4p.js";import"../../chunk-74j5mydx.js";import"../../chunk-rnt0wkrk.js";import"../../chunk-begk3j01.js";import"../../chunk-xnq1xw73.js";import"../../chunk-f18nyrrb.js";import"../../chunk-57agx6g8.js";import"../../chunk-rw6j20e2.js";export{b as esbuildDts,a as dtsx,c as dts,d as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ca as s}from"../../chunk-cmenkst5.js";import{fa as t}from"../../chunk-n28rjf9h.js";import{ia as i,ka as p}from"../../chunk-ywd4k4hn.js";import{ma as e,oa as u}from"../../chunk-3d18fhrg.js";import{qa as l,ra as a,sa as n}from"../../chunk-4qpg9xnt.js";import"../../chunk-9a6yn7sv.js";import"../../chunk-wfevdmvd.js";import"../../chunk-p1d09y82.js";import"../../chunk-hrmnrn4p.js";import"../../chunk-74j5mydx.js";import"../../chunk-rnt0wkrk.js";import"../../chunk-begk3j01.js";import"../../chunk-xnq1xw73.js";import"../../chunk-f18nyrrb.js";import"../../chunk-57agx6g8.js";import"../../chunk-rw6j20e2.js";export{n as webpackPlugin,a as webpackDts,s as viteDts,s as vite,u as tsupPlugin,e as tsupDts,e as tsup,p as esbuildPlugin,i as esbuildDts,i as esbuild,t as bunDts,t as bun,l as DtsxWebpackPlugin};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ma as a,na as b,oa as c,pa as d}from"../../chunk-3d18fhrg.js";import"../../chunk-9a6yn7sv.js";import"../../chunk-wfevdmvd.js";import"../../chunk-p1d09y82.js";import"../../chunk-hrmnrn4p.js";import"../../chunk-74j5mydx.js";import"../../chunk-rnt0wkrk.js";import"../../chunk-begk3j01.js";import"../../chunk-xnq1xw73.js";import"../../chunk-f18nyrrb.js";import"../../chunk-57agx6g8.js";import"../../chunk-rw6j20e2.js";export{b as tsupDts,a as dtsxPlugin,c as dts,d as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ca as a,da as b,ea as c}from"../../chunk-cmenkst5.js";import"../../chunk-9a6yn7sv.js";import"../../chunk-wfevdmvd.js";import"../../chunk-p1d09y82.js";import"../../chunk-hrmnrn4p.js";import"../../chunk-74j5mydx.js";import"../../chunk-rnt0wkrk.js";import"../../chunk-begk3j01.js";import"../../chunk-xnq1xw73.js";import"../../chunk-f18nyrrb.js";import"../../chunk-57agx6g8.js";import"../../chunk-rw6j20e2.js";export{b as viteDts,a as dts,c as default};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{qa as a,ra as b,sa as c,ta as d}from"../../chunk-4qpg9xnt.js";import"../../chunk-9a6yn7sv.js";import"../../chunk-wfevdmvd.js";import"../../chunk-p1d09y82.js";import"../../chunk-hrmnrn4p.js";import"../../chunk-74j5mydx.js";import"../../chunk-rnt0wkrk.js";import"../../chunk-begk3j01.js";import"../../chunk-xnq1xw73.js";import"../../chunk-f18nyrrb.js";import"../../chunk-57agx6g8.js";import"../../chunk-rw6j20e2.js";export{b as dtsxWebpack,c as dts,d as default,a as DtsxWebpackPlugin};
@@ -0,0 +1,89 @@
1
+ import type { Declaration, TrackingConfig } from './types';
2
+ /**
3
+ * Create a new tracker instance
4
+ */
5
+ export declare function createTracker(config?: TrackingConfig): Tracker;
6
+ /**
7
+ * Track declarations from a file
8
+ */
9
+ export declare function trackDeclarations(declarations: Declaration[], file: string, tracker: Tracker): void;
10
+ /**
11
+ * Analyze imports for a set of files
12
+ */
13
+ export declare function analyzeImports(fileDeclarations: Map<string, Declaration[]>, config?: TrackingConfig): TrackingResults;
14
+ /**
15
+ * Analyze types for a set of files
16
+ */
17
+ export declare function analyzeTypes(fileDeclarations: Map<string, Declaration[]>, config?: TrackingConfig): TrackingResults;
18
+ /**
19
+ * Type information tracked during processing
20
+ */
21
+ export declare interface TrackedType {
22
+ name: string
23
+ kind: 'interface' | 'type' | 'class' | 'enum'
24
+ file: string
25
+ line?: number
26
+ usedBy: Set<string>
27
+ references: Set<string>
28
+ extendsFrom?: string[]
29
+ implementsFrom?: string[]
30
+ }
31
+ /**
32
+ * Import information tracked during processing
33
+ */
34
+ export declare interface TrackedImport {
35
+ source: string
36
+ specifiers: string[]
37
+ isTypeOnly: boolean
38
+ file: string
39
+ usedSpecifiers: Set<string>
40
+ unusedSpecifiers: Set<string>
41
+ }
42
+ /**
43
+ * Type relationship information
44
+ */
45
+ export declare interface TypeRelationship {
46
+ from: string
47
+ to: string
48
+ kind: 'extends' | 'implements' | 'references' | 'uses'
49
+ file: string
50
+ }
51
+ /**
52
+ * Tracking results from analysis
53
+ */
54
+ export declare interface TrackingResults {
55
+ types: Map<string, TrackedType>
56
+ imports: Map<string, TrackedImport[]>
57
+ relationships: TypeRelationship[]
58
+ unusedTypes: string[]
59
+ unusedImports: TrackedImport[]
60
+ circularReferences: string[][]
61
+ statistics: TrackingStatistics
62
+ }
63
+ /**
64
+ * Tracking statistics
65
+ */
66
+ export declare interface TrackingStatistics {
67
+ totalTypes: number
68
+ usedTypes: number
69
+ unusedTypes: number
70
+ totalImports: number
71
+ usedImports: number
72
+ unusedImports: number
73
+ totalRelationships: number
74
+ circularDependencies: number
75
+ }
76
+ /**
77
+ * Tracker class for collecting type and import information
78
+ */
79
+ export declare class Tracker {
80
+ constructor(config?: TrackingConfig);
81
+ trackType(decl: Declaration, file: string): void;
82
+ trackTypeUsage(typeName: string, usedBy: string, file: string): void;
83
+ trackImport(source: string, specifiers: string[], isTypeOnly: boolean, file: string): void;
84
+ trackImportUsage(specifier: string, file: string): void;
85
+ trackTypeReference(typeName: string, file: string): void;
86
+ getResults(): TrackingResults;
87
+ clear(): void;
88
+ formatResults(): string;
89
+ }