@stacksjs/dtsx 0.8.0 → 0.8.2

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.
package/dist/index.js CHANGED
@@ -1,49 +1,46 @@
1
1
  // @bun
2
- var rq=Object.create;var{getPrototypeOf:oq,defineProperty:p1,getOwnPropertyNames:aq}=Object;var eq=Object.prototype.hasOwnProperty;var B1=(q,$,J)=>{J=q!=null?rq(oq(q)):{};let Z=$||!q||!q.__esModule?p1(J,"default",{value:q,enumerable:!0}):J;for(let Y of aq(q))if(!eq.call(Z,Y))p1(Z,Y,{get:()=>q[Y],enumerable:!0});return Z};var D=(q,$)=>()=>($||q(($={exports:{}}).exports,$),$.exports);var T1=D((z0)=>{Object.defineProperty(z0,"__esModule",{value:!0});z0.normalizePath=z0.convertSlashes=z0.cleanPath=void 0;var S1=import.meta.require("path");function Q0(q){let $=S1.normalize(q);if($.length>1&&$[$.length-1]===S1.sep)$=$.substring(0,$.length-1);return $}z0.cleanPath=Q0;var p$=/[\\/]/g;function U0(q,$){return q.replace(p$,$)}z0.convertSlashes=U0;function i$(q,$){let{resolvePaths:J,normalizePath:Z,pathSeparator:Y}=$,X=process.platform==="win32"&&q.includes("/")||q.startsWith(".");if(J)q=S1.resolve(q);if(Z||X)q=Q0(q);if(q===".")return"";let Q=q[q.length-1]!==Y;return U0(Q?q+Y:q,Y)}z0.normalizePath=i$});var w0=D((K0)=>{Object.defineProperty(K0,"__esModule",{value:!0});K0.build=K0.joinDirectoryPath=K0.joinPathWithBasePath=void 0;var r$=import.meta.require("path"),o$=T1();function F0(q,$){return $+q}K0.joinPathWithBasePath=F0;function a$(q,$){return function(J,Z){if(Z.startsWith(q))return Z.replace(q,"")+J;else return o$.convertSlashes(r$.relative(q,Z),$.pathSeparator)+$.pathSeparator+J}}function e$(q){return q}function t$(q,$,J){return $+q+J}K0.joinDirectoryPath=t$;function qJ(q,$){let{relativePaths:J,includeBasePath:Z}=$;return J&&q?a$(q,$):Z?F0:e$}K0.build=qJ});var N0=D((V0)=>{Object.defineProperty(V0,"__esModule",{value:!0});V0.build=void 0;function ZJ(q){return function($,J){J.push($.substring(q.length)||".")}}function YJ(q){return function($,J,Z){let Y=$.substring(q.length)||".";if(Z.every((X)=>X(Y,!0)))J.push(Y)}}var XJ=(q,$)=>{$.push(q||".")},jJ=(q,$,J)=>{let Z=q||".";if(J.every((Y)=>Y(Z,!0)))$.push(Z)},QJ=()=>{};function UJ(q,$){let{includeDirs:J,filters:Z,relativePaths:Y}=$;if(!J)return QJ;if(Y)return Z&&Z.length?YJ(q):ZJ(q);return Z&&Z.length?jJ:XJ}V0.build=UJ});var _0=D((H0)=>{Object.defineProperty(H0,"__esModule",{value:!0});H0.build=void 0;var zJ=(q,$,J,Z)=>{if(Z.every((Y)=>Y(q,!1)))J.files++},GJ=(q,$,J,Z)=>{if(Z.every((Y)=>Y(q,!1)))$.push(q)},FJ=(q,$,J,Z)=>{J.files++},KJ=(q,$)=>{$.push(q)},BJ=()=>{};function wJ(q){let{excludeFiles:$,filters:J,onlyCounts:Z}=q;if($)return BJ;if(J&&J.length)return Z?zJ:GJ;else if(Z)return FJ;else return KJ}H0.build=wJ});var R0=D((W0)=>{Object.defineProperty(W0,"__esModule",{value:!0});W0.build=void 0;var VJ=(q)=>{return q},MJ=()=>{return[""].slice(0,0)};function NJ(q){return q.group?MJ:VJ}W0.build=NJ});var E0=D((P0)=>{Object.defineProperty(P0,"__esModule",{value:!0});P0.build=void 0;var HJ=(q,$,J)=>{q.push({directory:$,files:J,dir:$})},IJ=()=>{};function _J(q){return q.group?HJ:IJ}P0.build=_J});var T0=D((Z1)=>{var WJ=Z1&&Z1.__importDefault||function(q){return q&&q.__esModule?q:{default:q}};Object.defineProperty(Z1,"__esModule",{value:!0});Z1.build=void 0;var N1=WJ(import.meta.require("fs")),f0=import.meta.require("path"),OJ=function(q,$,J){let{queue:Z,options:{suppressErrors:Y}}=$;Z.enqueue(),N1.default.realpath(q,(X,Q)=>{if(X)return Z.dequeue(Y?null:X,$);N1.default.stat(Q,(j,U)=>{if(j)return Z.dequeue(Y?null:j,$);if(U.isDirectory()&&S0(q,Q,$))return Z.dequeue(null,$);J(U,Q),Z.dequeue(null,$)})})},RJ=function(q,$,J){let{queue:Z,options:{suppressErrors:Y}}=$;Z.enqueue();try{let X=N1.default.realpathSync(q),Q=N1.default.statSync(X);if(Q.isDirectory()&&S0(q,X,$))return;J(Q,X)}catch(X){if(!Y)throw X}};function PJ(q,$){if(!q.resolveSymlinks||q.excludeSymlinks)return null;return $?RJ:OJ}Z1.build=PJ;function S0(q,$,J){if(J.options.useRealPaths)return AJ($,J);let Z=f0.dirname(q),Y=1;while(Z!==J.root&&Y<2){let X=J.symlinks.get(Z);if(!!X&&(X===$||X.startsWith($)||$.startsWith(X)))Y++;else Z=f0.dirname(Z)}return J.symlinks.set(q,$),Y>1}function AJ(q,$){return $.visited.includes(q+$.options.pathSeparator)}});var x0=D((D0)=>{Object.defineProperty(D0,"__esModule",{value:!0});D0.build=void 0;var EJ=(q)=>{return q.counts},fJ=(q)=>{return q.groups},SJ=(q)=>{return q.paths},TJ=(q)=>{return q.paths.slice(0,q.options.maxFiles)},DJ=(q,$,J)=>{return H1($,J,q.counts,q.options.suppressErrors),null},yJ=(q,$,J)=>{return H1($,J,q.paths,q.options.suppressErrors),null},xJ=(q,$,J)=>{return H1($,J,q.paths.slice(0,q.options.maxFiles),q.options.suppressErrors),null},CJ=(q,$,J)=>{return H1($,J,q.groups,q.options.suppressErrors),null};function H1(q,$,J,Z){if(q&&!Z)$(q,J);else $(null,J)}function kJ(q,$){let{onlyCounts:J,group:Z,maxFiles:Y}=q;if(J)return $?EJ:DJ;else if(Z)return $?fJ:CJ;else if(Y)return $?TJ:xJ;else return $?SJ:yJ}D0.build=kJ});var L0=D((Y1)=>{var LJ=Y1&&Y1.__importDefault||function(q){return q&&q.__esModule?q:{default:q}};Object.defineProperty(Y1,"__esModule",{value:!0});Y1.build=void 0;var C0=LJ(import.meta.require("fs")),k0={withFileTypes:!0},bJ=(q,$,J,Z,Y)=>{if(Z<0)return q.queue.dequeue(null,q);q.visited.push($),q.counts.directories++,q.queue.enqueue(),C0.default.readdir($||".",k0,(X,Q=[])=>{Y(Q,J,Z),q.queue.dequeue(q.options.suppressErrors?null:X,q)})},vJ=(q,$,J,Z,Y)=>{if(Z<0)return;q.visited.push($),q.counts.directories++;let X=[];try{X=C0.default.readdirSync($||".",k0)}catch(Q){if(!q.options.suppressErrors)throw Q}Y(X,J,Z)};function gJ(q){return q?vJ:bJ}Y1.build=gJ});var h0=D((v0)=>{Object.defineProperty(v0,"__esModule",{value:!0});v0.Queue=void 0;class b0{onQueueEmpty;count=0;constructor(q){this.onQueueEmpty=q}enqueue(){this.count++}dequeue(q,$){if(--this.count<=0||q)this.onQueueEmpty(q,$)}}v0.Queue=b0});var c0=D((m0)=>{Object.defineProperty(m0,"__esModule",{value:!0});m0.Counter=void 0;class u0{_files=0;_directories=0;set files(q){this._files=q}get files(){return this._files}set directories(q){this._directories=q}get directories(){return this._directories}get dirs(){return this._directories}}m0.Counter=u0});var x1=D((i)=>{var hJ=i&&i.__createBinding||(Object.create?function(q,$,J,Z){if(Z===void 0)Z=J;var Y=Object.getOwnPropertyDescriptor($,J);if(!Y||("get"in Y?!$.__esModule:Y.writable||Y.configurable))Y={enumerable:!0,get:function(){return $[J]}};Object.defineProperty(q,Z,Y)}:function(q,$,J,Z){if(Z===void 0)Z=J;q[Z]=$[J]}),uJ=i&&i.__setModuleDefault||(Object.create?function(q,$){Object.defineProperty(q,"default",{enumerable:!0,value:$})}:function(q,$){q.default=$}),e=i&&i.__importStar||function(q){if(q&&q.__esModule)return q;var $={};if(q!=null){for(var J in q)if(J!=="default"&&Object.prototype.hasOwnProperty.call(q,J))hJ($,q,J)}return uJ($,q),$};Object.defineProperty(i,"__esModule",{value:!0});i.Walker=void 0;var l0=import.meta.require("path"),D1=T1(),y1=e(w0()),mJ=e(N0()),dJ=e(_0()),cJ=e(R0()),lJ=e(E0()),pJ=e(T0()),iJ=e(x0()),nJ=e(L0()),sJ=h0(),rJ=c0();class p0{root;isSynchronous;state;joinPath;pushDirectory;pushFile;getArray;groupFiles;resolveSymlink;walkDirectory;callbackInvoker;constructor(q,$,J){this.isSynchronous=!J,this.callbackInvoker=iJ.build($,this.isSynchronous),this.root=D1.normalizePath(q,$),this.state={root:this.root.slice(0,-1),paths:[""].slice(0,0),groups:[],counts:new rJ.Counter,options:$,queue:new sJ.Queue((Z,Y)=>this.callbackInvoker(Y,Z,J)),symlinks:new Map,visited:[""].slice(0,0)},this.joinPath=y1.build(this.root,$),this.pushDirectory=mJ.build(this.root,$),this.pushFile=dJ.build($),this.getArray=cJ.build($),this.groupFiles=lJ.build($),this.resolveSymlink=pJ.build($,this.isSynchronous),this.walkDirectory=nJ.build(this.isSynchronous)}start(){return this.walkDirectory(this.state,this.root,this.root,this.state.options.maxDepth,this.walk),this.isSynchronous?this.callbackInvoker(this.state,null):null}walk=(q,$,J)=>{let{paths:Z,options:{filters:Y,resolveSymlinks:X,excludeSymlinks:Q,exclude:j,maxFiles:U,signal:z,useRealPaths:G,pathSeparator:V}}=this.state;if(z&&z.aborted||U&&Z.length>U)return;this.pushDirectory($,Z,Y);let H=this.getArray(this.state.paths);for(let _=0;_<q.length;++_){let I=q[_];if(I.isFile()||I.isSymbolicLink()&&!X&&!Q){let W=this.joinPath(I.name,$);this.pushFile(W,H,this.state.counts,Y)}else if(I.isDirectory()){let W=y1.joinDirectoryPath(I.name,$,this.state.options.pathSeparator);if(j&&j(I.name,W))continue;this.walkDirectory(this.state,W,W,J-1,this.walk)}else if(I.isSymbolicLink()&&this.resolveSymlink){let W=y1.joinPathWithBasePath(I.name,$);this.resolveSymlink(W,this.state,(C,O)=>{if(C.isDirectory()){if(O=D1.normalizePath(O,this.state.options),j&&j(I.name,O))return;this.walkDirectory(this.state,O,G?O:W+V,J-1,this.walk)}else{O=G?O:W;let P=l0.basename(O),h=D1.normalizePath(l0.dirname(O),this.state.options);O=this.joinPath(P,h),this.pushFile(O,H,this.state.counts,Y)}})}}this.groupFiles(this.state.groups,$,H)}}i.Walker=p0});var r0=D((n0)=>{Object.defineProperty(n0,"__esModule",{value:!0});n0.callback=n0.promise=void 0;var oJ=x1();function aJ(q,$){return new Promise((J,Z)=>{i0(q,$,(Y,X)=>{if(Y)return Z(Y);J(X)})})}n0.promise=aJ;function i0(q,$,J){new oJ.Walker(q,$,J).start()}n0.callback=i0});var e0=D((o0)=>{Object.defineProperty(o0,"__esModule",{value:!0});o0.sync=void 0;var tJ=x1();function qZ(q,$){return new tJ.Walker(q,$).start()}o0.sync=qZ});var Zq=D(($q)=>{Object.defineProperty($q,"__esModule",{value:!0});$q.APIBuilder=void 0;var t0=r0(),$Z=e0();class qq{root;options;constructor(q,$){this.root=q,this.options=$}withPromise(){return t0.promise(this.root,this.options)}withCallback(q){t0.callback(this.root,this.options,q)}sync(){return $Z.sync(this.root,this.options)}}$q.APIBuilder=qq});var j1=D((D8,Xq)=>{var Yq={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:"(?=.)",QMARK:"[^/]",END_ANCHOR:"(?:\\/|$)",DOTS_SLASH:"\\.{1,2}(?:\\/|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|\\/)\\.{1,2}(?:\\/|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:\\/|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:\\/|$))",QMARK_NO_DOT:"[^.\\/]",STAR:"[^/]*?",START_ANCHOR:"(?:^|\\/)",SEP:"/"},JZ={...Yq,SLASH_LITERAL:"[\\\\/]",QMARK:"[^\\\\/]",STAR:"[^\\\\/]*?",DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},ZZ={alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};Xq.exports={MAX_LENGTH:65536,POSIX_REGEX_SOURCE:ZZ,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(q){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${q.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(q){return q===!0?JZ:Yq}}});var Q1=D((UZ)=>{var{REGEX_BACKSLASH:YZ,REGEX_REMOVE_BACKSLASH:XZ,REGEX_SPECIAL_CHARS:jZ,REGEX_SPECIAL_CHARS_GLOBAL:QZ}=j1();UZ.isObject=(q)=>q!==null&&typeof q==="object"&&!Array.isArray(q);UZ.hasRegexChars=(q)=>jZ.test(q);UZ.isRegexChar=(q)=>q.length===1&&UZ.hasRegexChars(q);UZ.escapeRegex=(q)=>q.replace(QZ,"\\$1");UZ.toPosixSlashes=(q)=>q.replace(YZ,"/");UZ.isWindows=()=>{if(typeof navigator!=="undefined"&&navigator.platform){let q=navigator.platform.toLowerCase();return q==="win32"||q==="windows"}if(typeof process!=="undefined"&&process.platform)return process.platform==="win32";return!1};UZ.removeBackslashes=(q)=>{return q.replace(XZ,($)=>{return $==="\\"?"":$})};UZ.escapeLast=(q,$,J)=>{let Z=q.lastIndexOf($,J);if(Z===-1)return q;if(q[Z-1]==="\\")return UZ.escapeLast(q,$,Z-1);return`${q.slice(0,Z)}\\${q.slice(Z)}`};UZ.removePrefix=(q,$={})=>{let J=q;if(J.startsWith("./"))J=J.slice(2),$.prefix="./";return J};UZ.wrapOutput=(q,$={},J={})=>{let Z=J.contains?"":"^",Y=J.contains?"":"$",X=`${Z}(?:${q})${Y}`;if($.negated===!0)X=`(?:^(?!${X}).*$)`;return X};UZ.basename=(q,{windows:$}={})=>{let J=q.split($?/[\\/]/:"/"),Z=J[J.length-1];if(Z==="")return J[J.length-2];return Z}});var Vq=D((x8,wq)=>{var Uq=Q1(),{CHAR_ASTERISK:C1,CHAR_AT:HZ,CHAR_BACKWARD_SLASH:U1,CHAR_COMMA:IZ,CHAR_DOT:k1,CHAR_EXCLAMATION_MARK:L1,CHAR_FORWARD_SLASH:Bq,CHAR_LEFT_CURLY_BRACE:b1,CHAR_LEFT_PARENTHESES:v1,CHAR_LEFT_SQUARE_BRACKET:_Z,CHAR_PLUS:WZ,CHAR_QUESTION_MARK:zq,CHAR_RIGHT_CURLY_BRACE:OZ,CHAR_RIGHT_PARENTHESES:Gq,CHAR_RIGHT_SQUARE_BRACKET:RZ}=j1(),Fq=(q)=>{return q===Bq||q===U1},Kq=(q)=>{if(q.isPrefix!==!0)q.depth=q.isGlobstar?1/0:1},PZ=(q,$)=>{let J=$||{},Z=q.length-1,Y=J.parts===!0||J.scanToEnd===!0,X=[],Q=[],j=[],U=q,z=-1,G=0,V=0,H=!1,_=!1,I=!1,W=!1,C=!1,O=!1,P=!1,h=!1,t=!1,u=!1,g=0,c,R,E={value:"",depth:0,isGlob:!1},w=()=>z>=Z,d=()=>U.charCodeAt(z+1),b=()=>{return c=R,U.charCodeAt(++z)};while(z<Z){R=b();let S;if(R===U1){if(P=E.backslashes=!0,R=b(),R===b1)O=!0;continue}if(O===!0||R===b1){g++;while(w()!==!0&&(R=b())){if(R===U1){P=E.backslashes=!0,b();continue}if(R===b1){g++;continue}if(O!==!0&&R===k1&&(R=b())===k1){if(H=E.isBrace=!0,I=E.isGlob=!0,u=!0,Y===!0)continue;break}if(O!==!0&&R===IZ){if(H=E.isBrace=!0,I=E.isGlob=!0,u=!0,Y===!0)continue;break}if(R===OZ){if(g--,g===0){O=!1,H=E.isBrace=!0,u=!0;break}}}if(Y===!0)continue;break}if(R===Bq){if(X.push(z),Q.push(E),E={value:"",depth:0,isGlob:!1},u===!0)continue;if(c===k1&&z===G+1){G+=2;continue}V=z+1;continue}if(J.noext!==!0){if((R===WZ||R===HZ||R===C1||R===zq||R===L1)===!0&&d()===v1){if(I=E.isGlob=!0,W=E.isExtglob=!0,u=!0,R===L1&&z===G)t=!0;if(Y===!0){while(w()!==!0&&(R=b())){if(R===U1){P=E.backslashes=!0,R=b();continue}if(R===Gq){I=E.isGlob=!0,u=!0;break}}continue}break}}if(R===C1){if(c===C1)C=E.isGlobstar=!0;if(I=E.isGlob=!0,u=!0,Y===!0)continue;break}if(R===zq){if(I=E.isGlob=!0,u=!0,Y===!0)continue;break}if(R===_Z){while(w()!==!0&&(S=b())){if(S===U1){P=E.backslashes=!0,b();continue}if(S===RZ){_=E.isBracket=!0,I=E.isGlob=!0,u=!0;break}}if(Y===!0)continue;break}if(J.nonegate!==!0&&R===L1&&z===G){h=E.negated=!0,G++;continue}if(J.noparen!==!0&&R===v1){if(I=E.isGlob=!0,Y===!0){while(w()!==!0&&(R=b())){if(R===v1){P=E.backslashes=!0,R=b();continue}if(R===Gq){u=!0;break}}continue}break}if(I===!0){if(u=!0,Y===!0)continue;break}}if(J.noext===!0)W=!1,I=!1;let k=U,K="",B="";if(G>0)K=U.slice(0,G),U=U.slice(G),V-=G;if(k&&I===!0&&V>0)k=U.slice(0,V),B=U.slice(V);else if(I===!0)k="",B=U;else k=U;if(k&&k!==""&&k!=="/"&&k!==U){if(Fq(k.charCodeAt(k.length-1)))k=k.slice(0,-1)}if(J.unescape===!0){if(B)B=Uq.removeBackslashes(B);if(k&&P===!0)k=Uq.removeBackslashes(k)}let l={prefix:K,input:q,start:G,base:k,glob:B,isBrace:H,isBracket:_,isGlob:I,isExtglob:W,isGlobstar:C,negated:h,negatedExtglob:t};if(J.tokens===!0){if(l.maxDepth=0,!Fq(R))Q.push(E);l.tokens=Q}if(J.parts===!0||J.tokens===!0){let S;for(let y=0;y<X.length;y++){let s=S?S+1:G,p=X[y],a=q.slice(s,p);if(J.tokens){if(y===0&&G!==0)Q[y].isPrefix=!0,Q[y].value=K;else Q[y].value=a;Kq(Q[y]),l.maxDepth+=Q[y].depth}if(y!==0||a!=="")j.push(a);S=p}if(S&&S+1<q.length){let y=q.slice(S+1);if(j.push(y),J.tokens)Q[Q.length-1].value=y,Kq(Q[Q.length-1]),l.maxDepth+=Q[Q.length-1].depth}l.slashes=X,l.parts=j}return l};wq.exports=PZ});var Hq=D((C8,Nq)=>{var I1=j1(),n=Q1(),{MAX_LENGTH:_1,POSIX_REGEX_SOURCE:AZ,REGEX_NON_SPECIAL_CHARS:EZ,REGEX_SPECIAL_CHARS_BACKREF:fZ,REPLACEMENTS:Mq}=I1,SZ=(q,$)=>{if(typeof $.expandRange==="function")return $.expandRange(...q,$);q.sort();let J=`[${q.join("-")}]`;try{new RegExp(J)}catch(Z){return q.map((Y)=>n.escapeRegex(Y)).join("..")}return J},X1=(q,$)=>{return`Missing ${q}: "${$}" - use "\\\\${$}" to match literal characters`},g1=(q,$)=>{if(typeof q!=="string")throw new TypeError("Expected a string");q=Mq[q]||q;let J={...$},Z=typeof J.maxLength==="number"?Math.min(_1,J.maxLength):_1,Y=q.length;if(Y>Z)throw new SyntaxError(`Input length: ${Y}, exceeds maximum allowed length: ${Z}`);let X={type:"bos",value:"",output:J.prepend||""},Q=[X],j=J.capture?"":"?:",U=I1.globChars(J.windows),z=I1.extglobChars(U),{DOT_LITERAL:G,PLUS_LITERAL:V,SLASH_LITERAL:H,ONE_CHAR:_,DOTS_SLASH:I,NO_DOT:W,NO_DOT_SLASH:C,NO_DOTS_SLASH:O,QMARK:P,QMARK_NO_DOT:h,STAR:t,START_ANCHOR:u}=U,g=(N)=>{return`(${j}(?:(?!${u}${N.dot?I:G}).)*?)`},c=J.dot?"":W,R=J.dot?P:h,E=J.bash===!0?g(J):t;if(J.capture)E=`(${E})`;if(typeof J.noext==="boolean")J.noextglob=J.noext;let w={input:q,index:-1,start:0,dot:J.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:Q};q=n.removePrefix(q,w),Y=q.length;let d=[],b=[],k=[],K=X,B,l=()=>w.index===Y-1,S=w.peek=(N=1)=>q[w.index+N],y=w.advance=()=>q[++w.index]||"",s=()=>q.slice(w.index+1),p=(N="",T=0)=>{w.consumed+=N,w.index+=T},a=(N)=>{w.output+=N.output!=null?N.output:N.value,p(N.value)},nq=()=>{let N=1;while(S()==="!"&&(S(2)!=="("||S(3)==="?"))y(),w.start++,N++;if(N%2===0)return!1;return w.negated=!0,w.start++,!0},G1=(N)=>{w[N]++,k.push(N)},q1=(N)=>{w[N]--,k.pop()},f=(N)=>{if(K.type==="globstar"){let T=w.braces>0&&(N.type==="comma"||N.type==="brace"),M=N.extglob===!0||d.length&&(N.type==="pipe"||N.type==="paren");if(N.type!=="slash"&&N.type!=="paren"&&!T&&!M)w.output=w.output.slice(0,-K.output.length),K.type="star",K.value="*",K.output=E,w.output+=K.output}if(d.length&&N.type!=="paren")d[d.length-1].inner+=N.value;if(N.value||N.output)a(N);if(K&&K.type==="text"&&N.type==="text"){K.output=(K.output||K.value)+N.value,K.value+=N.value;return}N.prev=K,Q.push(N),K=N},F1=(N,T)=>{let M={...z[T],conditions:1,inner:""};M.prev=K,M.parens=w.parens,M.output=w.output;let A=(J.capture?"(":"")+M.open;G1("parens"),f({type:N,value:T,output:w.output?"":_}),f({type:"paren",extglob:!0,value:y(),output:A}),d.push(M)},sq=(N)=>{let T=N.close+(J.capture?")":""),M;if(N.type==="negate"){let A=E;if(N.inner&&N.inner.length>1&&N.inner.includes("/"))A=g(J);if(A!==E||l()||/^\)+$/.test(s()))T=N.close=`)$))${A}`;if(N.inner.includes("*")&&(M=s())&&/^\.[^\\/.]+$/.test(M)){let x=g1(M,{...$,fastpaths:!1}).output;T=N.close=`)${x})${A})`}if(N.prev.type==="bos")w.negatedExtglob=!0}f({type:"paren",extglob:!0,value:B,output:T}),q1("parens")};if(J.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(q)){let N=!1,T=q.replace(fZ,(M,A,x,m,v,O1)=>{if(m==="\\")return N=!0,M;if(m==="?"){if(A)return A+m+(v?P.repeat(v.length):"");if(O1===0)return R+(v?P.repeat(v.length):"");return P.repeat(x.length)}if(m===".")return G.repeat(x.length);if(m==="*"){if(A)return A+m+(v?E:"");return E}return A?M:`\\${M}`});if(N===!0)if(J.unescape===!0)T=T.replace(/\\/g,"");else T=T.replace(/\\+/g,(M)=>{return M.length%2===0?"\\\\":M?"\\":""});if(T===q&&J.contains===!0)return w.output=q,w;return w.output=n.wrapOutput(T,w,$),w}while(!l()){if(B=y(),B==="\x00")continue;if(B==="\\"){let M=S();if(M==="/"&&J.bash!==!0)continue;if(M==="."||M===";")continue;if(!M){B+="\\",f({type:"text",value:B});continue}let A=/^\\+/.exec(s()),x=0;if(A&&A[0].length>2){if(x=A[0].length,w.index+=x,x%2!==0)B+="\\"}if(J.unescape===!0)B=y();else B+=y();if(w.brackets===0){f({type:"text",value:B});continue}}if(w.brackets>0&&(B!=="]"||K.value==="["||K.value==="[^")){if(J.posix!==!1&&B===":"){let M=K.value.slice(1);if(M.includes("[")){if(K.posix=!0,M.includes(":")){let A=K.value.lastIndexOf("["),x=K.value.slice(0,A),m=K.value.slice(A+2),v=AZ[m];if(v){if(K.value=x+v,w.backtrack=!0,y(),!X.output&&Q.indexOf(K)===1)X.output=_;continue}}}}if(B==="["&&S()!==":"||B==="-"&&S()==="]")B=`\\${B}`;if(B==="]"&&(K.value==="["||K.value==="[^"))B=`\\${B}`;if(J.posix===!0&&B==="!"&&K.value==="[")B="^";K.value+=B,a({value:B});continue}if(w.quotes===1&&B!=='"'){B=n.escapeRegex(B),K.value+=B,a({value:B});continue}if(B==='"'){if(w.quotes=w.quotes===1?0:1,J.keepQuotes===!0)f({type:"text",value:B});continue}if(B==="("){G1("parens"),f({type:"paren",value:B});continue}if(B===")"){if(w.parens===0&&J.strictBrackets===!0)throw new SyntaxError(X1("opening","("));let M=d[d.length-1];if(M&&w.parens===M.parens+1){sq(d.pop());continue}f({type:"paren",value:B,output:w.parens?")":"\\)"}),q1("parens");continue}if(B==="["){if(J.nobracket===!0||!s().includes("]")){if(J.nobracket!==!0&&J.strictBrackets===!0)throw new SyntaxError(X1("closing","]"));B=`\\${B}`}else G1("brackets");f({type:"bracket",value:B});continue}if(B==="]"){if(J.nobracket===!0||K&&K.type==="bracket"&&K.value.length===1){f({type:"text",value:B,output:`\\${B}`});continue}if(w.brackets===0){if(J.strictBrackets===!0)throw new SyntaxError(X1("opening","["));f({type:"text",value:B,output:`\\${B}`});continue}q1("brackets");let M=K.value.slice(1);if(K.posix!==!0&&M[0]==="^"&&!M.includes("/"))B=`/${B}`;if(K.value+=B,a({value:B}),J.literalBrackets===!1||n.hasRegexChars(M))continue;let A=n.escapeRegex(K.value);if(w.output=w.output.slice(0,-K.value.length),J.literalBrackets===!0){w.output+=A,K.value=A;continue}K.value=`(${j}${A}|${K.value})`,w.output+=K.value;continue}if(B==="{"&&J.nobrace!==!0){G1("braces");let M={type:"brace",value:B,output:"(",outputIndex:w.output.length,tokensIndex:w.tokens.length};b.push(M),f(M);continue}if(B==="}"){let M=b[b.length-1];if(J.nobrace===!0||!M){f({type:"text",value:B,output:B});continue}let A=")";if(M.dots===!0){let x=Q.slice(),m=[];for(let v=x.length-1;v>=0;v--){if(Q.pop(),x[v].type==="brace")break;if(x[v].type!=="dots")m.unshift(x[v].value)}A=SZ(m,J),w.backtrack=!0}if(M.comma!==!0&&M.dots!==!0){let x=w.output.slice(0,M.outputIndex),m=w.tokens.slice(M.tokensIndex);M.value=M.output="\\{",B=A="\\}",w.output=x;for(let v of m)w.output+=v.output||v.value}f({type:"brace",value:B,output:A}),q1("braces"),b.pop();continue}if(B==="|"){if(d.length>0)d[d.length-1].conditions++;f({type:"text",value:B});continue}if(B===","){let M=B,A=b[b.length-1];if(A&&k[k.length-1]==="braces")A.comma=!0,M="|";f({type:"comma",value:B,output:M});continue}if(B==="/"){if(K.type==="dot"&&w.index===w.start+1){w.start=w.index+1,w.consumed="",w.output="",Q.pop(),K=X;continue}f({type:"slash",value:B,output:H});continue}if(B==="."){if(w.braces>0&&K.type==="dot"){if(K.value===".")K.output=G;let M=b[b.length-1];K.type="dots",K.output+=B,K.value+=B,M.dots=!0;continue}if(w.braces+w.parens===0&&K.type!=="bos"&&K.type!=="slash"){f({type:"text",value:B,output:G});continue}f({type:"dot",value:B,output:G});continue}if(B==="?"){if(!(K&&K.value==="(")&&J.noextglob!==!0&&S()==="("&&S(2)!=="?"){F1("qmark",B);continue}if(K&&K.type==="paren"){let A=S(),x=B;if(K.value==="("&&!/[!=<:]/.test(A)||A==="<"&&!/<([!=]|\w+>)/.test(s()))x=`\\${B}`;f({type:"text",value:B,output:x});continue}if(J.dot!==!0&&(K.type==="slash"||K.type==="bos")){f({type:"qmark",value:B,output:h});continue}f({type:"qmark",value:B,output:P});continue}if(B==="!"){if(J.noextglob!==!0&&S()==="("){if(S(2)!=="?"||!/[!=<:]/.test(S(3))){F1("negate",B);continue}}if(J.nonegate!==!0&&w.index===0){nq();continue}}if(B==="+"){if(J.noextglob!==!0&&S()==="("&&S(2)!=="?"){F1("plus",B);continue}if(K&&K.value==="("||J.regex===!1){f({type:"plus",value:B,output:V});continue}if(K&&(K.type==="bracket"||K.type==="paren"||K.type==="brace")||w.parens>0){f({type:"plus",value:B});continue}f({type:"plus",value:V});continue}if(B==="@"){if(J.noextglob!==!0&&S()==="("&&S(2)!=="?"){f({type:"at",extglob:!0,value:B,output:""});continue}f({type:"text",value:B});continue}if(B!=="*"){if(B==="$"||B==="^")B=`\\${B}`;let M=EZ.exec(s());if(M)B+=M[0],w.index+=M[0].length;f({type:"text",value:B});continue}if(K&&(K.type==="globstar"||K.star===!0)){K.type="star",K.star=!0,K.value+=B,K.output=E,w.backtrack=!0,w.globstar=!0,p(B);continue}let N=s();if(J.noextglob!==!0&&/^\([^?]/.test(N)){F1("star",B);continue}if(K.type==="star"){if(J.noglobstar===!0){p(B);continue}let M=K.prev,A=M.prev,x=M.type==="slash"||M.type==="bos",m=A&&(A.type==="star"||A.type==="globstar");if(J.bash===!0&&(!x||N[0]&&N[0]!=="/")){f({type:"star",value:B,output:""});continue}let v=w.braces>0&&(M.type==="comma"||M.type==="brace"),O1=d.length&&(M.type==="pipe"||M.type==="paren");if(!x&&M.type!=="paren"&&!v&&!O1){f({type:"star",value:B,output:""});continue}while(N.slice(0,3)==="/**"){let K1=q[w.index+4];if(K1&&K1!=="/")break;N=N.slice(3),p("/**",3)}if(M.type==="bos"&&l()){K.type="globstar",K.value+=B,K.output=g(J),w.output=K.output,w.globstar=!0,p(B);continue}if(M.type==="slash"&&M.prev.type!=="bos"&&!m&&l()){w.output=w.output.slice(0,-(M.output+K.output).length),M.output=`(?:${M.output}`,K.type="globstar",K.output=g(J)+(J.strictSlashes?")":"|$)"),K.value+=B,w.globstar=!0,w.output+=M.output+K.output,p(B);continue}if(M.type==="slash"&&M.prev.type!=="bos"&&N[0]==="/"){let K1=N[1]!==void 0?"|$":"";w.output=w.output.slice(0,-(M.output+K.output).length),M.output=`(?:${M.output}`,K.type="globstar",K.output=`${g(J)}${H}|${H}${K1})`,K.value+=B,w.output+=M.output+K.output,w.globstar=!0,p(B+y()),f({type:"slash",value:"/",output:""});continue}if(M.type==="bos"&&N[0]==="/"){K.type="globstar",K.value+=B,K.output=`(?:^|${H}|${g(J)}${H})`,w.output=K.output,w.globstar=!0,p(B+y()),f({type:"slash",value:"/",output:""});continue}w.output=w.output.slice(0,-K.output.length),K.type="globstar",K.output=g(J),K.value+=B,w.output+=K.output,w.globstar=!0,p(B);continue}let T={type:"star",value:B,output:E};if(J.bash===!0){if(T.output=".*?",K.type==="bos"||K.type==="slash")T.output=c+T.output;f(T);continue}if(K&&(K.type==="bracket"||K.type==="paren")&&J.regex===!0){T.output=B,f(T);continue}if(w.index===w.start||K.type==="slash"||K.type==="dot"){if(K.type==="dot")w.output+=C,K.output+=C;else if(J.dot===!0)w.output+=O,K.output+=O;else w.output+=c,K.output+=c;if(S()!=="*")w.output+=_,K.output+=_}f(T)}while(w.brackets>0){if(J.strictBrackets===!0)throw new SyntaxError(X1("closing","]"));w.output=n.escapeLast(w.output,"["),q1("brackets")}while(w.parens>0){if(J.strictBrackets===!0)throw new SyntaxError(X1("closing",")"));w.output=n.escapeLast(w.output,"("),q1("parens")}while(w.braces>0){if(J.strictBrackets===!0)throw new SyntaxError(X1("closing","}"));w.output=n.escapeLast(w.output,"{"),q1("braces")}if(J.strictSlashes!==!0&&(K.type==="star"||K.type==="bracket"))f({type:"maybe_slash",value:"",output:`${H}?`});if(w.backtrack===!0){w.output="";for(let N of w.tokens)if(w.output+=N.output!=null?N.output:N.value,N.suffix)w.output+=N.suffix}return w};g1.fastpaths=(q,$)=>{let J={...$},Z=typeof J.maxLength==="number"?Math.min(_1,J.maxLength):_1,Y=q.length;if(Y>Z)throw new SyntaxError(`Input length: ${Y}, exceeds maximum allowed length: ${Z}`);q=Mq[q]||q;let{DOT_LITERAL:X,SLASH_LITERAL:Q,ONE_CHAR:j,DOTS_SLASH:U,NO_DOT:z,NO_DOTS:G,NO_DOTS_SLASH:V,STAR:H,START_ANCHOR:_}=I1.globChars(J.windows),I=J.dot?G:z,W=J.dot?V:z,C=J.capture?"":"?:",O={negated:!1,prefix:""},P=J.bash===!0?".*?":H;if(J.capture)P=`(${P})`;let h=(c)=>{if(c.noglobstar===!0)return P;return`(${C}(?:(?!${_}${c.dot?U:X}).)*?)`},t=(c)=>{switch(c){case"*":return`${I}${j}${P}`;case".*":return`${X}${j}${P}`;case"*.*":return`${I}${P}${X}${j}${P}`;case"*/*":return`${I}${P}${Q}${j}${W}${P}`;case"**":return I+h(J);case"**/*":return`(?:${I}${h(J)}${Q})?${W}${j}${P}`;case"**/*.*":return`(?:${I}${h(J)}${Q})?${W}${P}${X}${j}${P}`;case"**/.*":return`(?:${I}${h(J)}${Q})?${X}${j}${P}`;default:{let R=/^(.*?)\.(\w+)$/.exec(c);if(!R)return;let E=t(R[1]);if(!E)return;return E+X+R[2]}}},u=n.removePrefix(q,O),g=t(u);if(g&&J.strictSlashes!==!0)g+=`${Q}?`;return g};Nq.exports=g1});var Wq=D((k8,_q)=>{var TZ=Vq(),h1=Hq(),Iq=Q1(),DZ=j1(),yZ=(q)=>q&&typeof q==="object"&&!Array.isArray(q),L=(q,$,J=!1)=>{if(Array.isArray(q)){let G=q.map((H)=>L(H,$,J));return(H)=>{for(let _ of G){let I=_(H);if(I)return I}return!1}}let Z=yZ(q)&&q.tokens&&q.input;if(q===""||typeof q!=="string"&&!Z)throw new TypeError("Expected pattern to be a non-empty string");let Y=$||{},X=Y.windows,Q=Z?L.compileRe(q,$):L.makeRe(q,$,!1,!0),j=Q.state;delete Q.state;let U=()=>!1;if(Y.ignore){let G={...$,ignore:null,onMatch:null,onResult:null};U=L(Y.ignore,G,J)}let z=(G,V=!1)=>{let{isMatch:H,match:_,output:I}=L.test(G,Q,$,{glob:q,posix:X}),W={glob:q,state:j,regex:Q,posix:X,input:G,output:I,match:_,isMatch:H};if(typeof Y.onResult==="function")Y.onResult(W);if(H===!1)return W.isMatch=!1,V?W:!1;if(U(G)){if(typeof Y.onIgnore==="function")Y.onIgnore(W);return W.isMatch=!1,V?W:!1}if(typeof Y.onMatch==="function")Y.onMatch(W);return V?W:!0};if(J)z.state=j;return z};L.test=(q,$,J,{glob:Z,posix:Y}={})=>{if(typeof q!=="string")throw new TypeError("Expected input to be a string");if(q==="")return{isMatch:!1,output:""};let X=J||{},Q=X.format||(Y?Iq.toPosixSlashes:null),j=q===Z,U=j&&Q?Q(q):q;if(j===!1)U=Q?Q(q):q,j=U===Z;if(j===!1||X.capture===!0)if(X.matchBase===!0||X.basename===!0)j=L.matchBase(q,$,J,Y);else j=$.exec(U);return{isMatch:Boolean(j),match:j,output:U}};L.matchBase=(q,$,J)=>{return($ instanceof RegExp?$:L.makeRe($,J)).test(Iq.basename(q))};L.isMatch=(q,$,J)=>L($,J)(q);L.parse=(q,$)=>{if(Array.isArray(q))return q.map((J)=>L.parse(J,$));return h1(q,{...$,fastpaths:!1})};L.scan=(q,$)=>TZ(q,$);L.compileRe=(q,$,J=!1,Z=!1)=>{if(J===!0)return q.output;let Y=$||{},X=Y.contains?"":"^",Q=Y.contains?"":"$",j=`${X}(?:${q.output})${Q}`;if(q&&q.negated===!0)j=`^(?!${j}).*$`;let U=L.toRegex(j,$);if(Z===!0)U.state=q;return U};L.makeRe=(q,$={},J=!1,Z=!1)=>{if(!q||typeof q!=="string")throw new TypeError("Expected a non-empty string");let Y={negated:!1,fastpaths:!0};if($.fastpaths!==!1&&(q[0]==="."||q[0]==="*"))Y.output=h1.fastpaths(q,$);if(!Y.output)Y=h1(q,$);return L.compileRe(Y,$,J,Z)};L.toRegex=(q,$)=>{try{let J=$||{};return new RegExp(q,J.flags||(J.nocase?"i":""))}catch(J){if($&&$.debug===!0)throw J;return/$^/}};L.constants=DZ;_q.exports=L});var z1=D((L8,Pq)=>{var Oq=Wq(),xZ=Q1();function Rq(q,$,J=!1){if($&&($.windows===null||$.windows===void 0))$={...$,windows:xZ.isWindows()};return Oq(q,$,J)}Object.assign(Rq,Oq);Pq.exports=Rq});var Dq=D((Sq)=>{Object.defineProperty(Sq,"__esModule",{value:!0});Sq.Builder=void 0;var CZ=import.meta.require("path"),Aq=Zq(),Eq=null;try{import.meta.require.resolve("picomatch"),Eq=z1()}catch(q){}class fq{globCache={};options={maxDepth:1/0,suppressErrors:!0,pathSeparator:CZ.sep,filters:[]};globFunction;constructor(q){this.options={...this.options,...q},this.globFunction=this.options.globFunction}group(){return this.options.group=!0,this}withPathSeparator(q){return this.options.pathSeparator=q,this}withBasePath(){return this.options.includeBasePath=!0,this}withRelativePaths(){return this.options.relativePaths=!0,this}withDirs(){return this.options.includeDirs=!0,this}withMaxDepth(q){return this.options.maxDepth=q,this}withMaxFiles(q){return this.options.maxFiles=q,this}withFullPaths(){return this.options.resolvePaths=!0,this.options.includeBasePath=!0,this}withErrors(){return this.options.suppressErrors=!1,this}withSymlinks({resolvePaths:q=!0}={}){return this.options.resolveSymlinks=!0,this.options.useRealPaths=q,this.withFullPaths()}withAbortSignal(q){return this.options.signal=q,this}normalize(){return this.options.normalizePath=!0,this}filter(q){return this.options.filters.push(q),this}onlyDirs(){return this.options.excludeFiles=!0,this.options.includeDirs=!0,this}exclude(q){return this.options.exclude=q,this}onlyCounts(){return this.options.onlyCounts=!0,this}crawl(q){return new Aq.APIBuilder(q||".",this.options)}withGlobFunction(q){return this.globFunction=q,this}crawlWithOptions(q,$){return this.options={...this.options,...$},new Aq.APIBuilder(q||".",this.options)}glob(...q){if(this.globFunction)return this.globWithOptions(q);return this.globWithOptions(q,...[{dot:!0}])}globWithOptions(q,...$){let J=this.globFunction||Eq;if(!J)throw new Error("Please specify a glob function to use glob matching.");var Z=this.globCache[q.join("\x00")];if(!Z)Z=J(q,...$),this.globCache[q.join("\x00")]=Z;return this.options.filters.push((Y)=>Z(Y)),this}}Sq.Builder=fq});var xq=D((yq)=>{Object.defineProperty(yq,"__esModule",{value:!0})});var Cq=D((o)=>{var kZ=o&&o.__createBinding||(Object.create?function(q,$,J,Z){if(Z===void 0)Z=J;var Y=Object.getOwnPropertyDescriptor($,J);if(!Y||("get"in Y?!$.__esModule:Y.writable||Y.configurable))Y={enumerable:!0,get:function(){return $[J]}};Object.defineProperty(q,Z,Y)}:function(q,$,J,Z){if(Z===void 0)Z=J;q[Z]=$[J]}),LZ=o&&o.__exportStar||function(q,$){for(var J in q)if(J!=="default"&&!Object.prototype.hasOwnProperty.call($,J))kZ($,q,J)};Object.defineProperty(o,"__esModule",{value:!0});o.fdir=void 0;var bZ=Dq();Object.defineProperty(o,"fdir",{enumerable:!0,get:function(){return bZ.Builder}});LZ(xq(),o)});import $$ from"process";import{resolve as tq}from"path";import q$ from"process";function R1(q,$){if(Array.isArray($)&&!Array.isArray(q))return $;if(Array.isArray($)&&Array.isArray(q))return $.map((Z,Y)=>{let X=q[Y];if($1(Z)&&$1(X))return R1(X,Z);return Z});if(!$1($)||!$1(q))return $;let J={...q};for(let Z in $)if(Object.prototype.hasOwnProperty.call($,Z)){let Y=$[Z],X=J[Z];if(Y===null||Y===void 0)J[Z]=Y;else if($1(Y)&&$1(X))J[Z]=R1(X,Y);else J[Z]=Y}return J}function $1(q){return Boolean(q&&typeof q==="object"&&!Array.isArray(q))}async function i1({name:q,cwd:$,defaultConfig:J}){let Z=tq($||q$.cwd(),`${q}.config`);try{let Y=await import(Z),X=Y.default||Y;return R1(J,X)}catch(Y){return J}}var r=await i1({name:"dts",defaultConfig:{cwd:$$.cwd(),root:"./src",entrypoints:["**/*.ts"],outdir:"./dist",keepComments:!0,clean:!0,tsconfigPath:"./tsconfig.json",verbose:!1}});function V1(q){if(!q.trim())return"";if(q.includes("{")){let Q=q.match(/(\w+):\s*(\{[^}]+\})/);if(Q){let[,j,U]=Q,z=U.slice(1,-1).split(/\s+(?=\w+\??\s*:)/).map((G)=>G.trim()).filter(Boolean).map((G)=>{let[V,H]=G.split(/:\s*/),_=V.endsWith("?");return`${V.replace(/\?$/,"")}${_?"?":""}: ${H}`}).join(", ");return`${j}: { ${z} }`}}let $=[],J="",Z=0,Y=!1,X="";for(let Q of q){if(Q==='"'||Q==="'"||Q==="`"){if(!Y)Y=!0,X=Q;else if(Q===X)Y=!1}if(!Y){if(Q==="{"||Q==="<"||Q==="(")Z++;if(Q==="}"||Q===">"||Q===")")Z--;if(Q===","&&Z===0){if(J.trim())$.push(P1(J));J="";continue}}J+=Q}if(J.trim())$.push(P1(J));return $.join(", ")}function P1(q){let $=q.trim();if($.includes("=")){let[Z]=$.split("=");return P1(Z)}let J=$.match(/^([^:]+):\s*(.+)$/);if(J){let[,Z,Y]=J;if(Y.includes("{"))return`${Z.trim()}: ${b$(Y)}`;return`${Z.trim()}: ${Y.trim()}`}return $}async function t1(q){try{let $=await Bun.file(q).text();return J$($)}catch($){throw console.error("Failed to extract types:",$),new Error("Failed to extract and generate .d.ts file")}}function J$(q){let $=K$();F("init","Starting DTS extraction"),q.split(`
3
- `).forEach((Z)=>{if(Z.includes("import "))Z0(Z,$.importTracking),F("import",`Processed import: ${Z.trim()}`)}),C$(q,$),F("export-summary",`Found ${$.defaultExports.size} default exports`),F("export-summary",`Found ${$.exportAllStatements.length} export * statements`),$.dtsLines.forEach((Z)=>{if(Z.trim()&&!Z.startsWith("import"))m$(Z,$.importTracking),d$(Z,$.importTracking)});let J=U$($.importTracking);return F("import-summary",`Generated ${J.length} optimized imports`),$.dtsLines=[...J.map((Z)=>`${Z};`),"",...$.dtsLines.filter((Z)=>!Z.trim().startsWith("import"))],G$($)}function Z$(q){F("signature-start",`Processing declaration: ${q}`);let $=v$(q);F("signature-clean",`Clean declaration: ${$}`);let J=Y$($),Z=$.slice($.indexOf(J)+J.length).trim();F("signature-content",`Content after name: ${Z}`);let{generics:Y,rest:X}=X$(Z);Z=X.trim(),F("signature-after-generics",`Remaining content: ${Z}`);let{params:Q,rest:j}=j$(Z);Z=j.trim(),F("signature-after-params",`Remaining content: ${Z}`);let{returnType:U}=Q$(Z);F("signature-return",`Extracted return type: ${U}`);let z={name:J,generics:Y,params:Q,returnType:U};return F("signature-final",`Final signature object: ${JSON.stringify(z,null,2)}`),z}function Y$(q){let $=q.match(/^(?:export\s+)?(?:async\s+)?function\s*\*?\s*([^(<\s]+)/);if(!$)throw new Error("Invalid function declaration");return $[1]}function X$(q){let $="";if(q.startsWith("<")){let J=1,Z=0,Y="<",X=!1,Q="";F("generics-input",`Starting generic extraction with: ${q}`);for(let j=1;j<q.length;j++){let U=q[j],z=j<q.length-1?q[j+1]:"",G=j>0?q[j-1]:"";if(F("generics-char",`Processing char: ${U}, next char: ${z}, depth: ${J}, pos: ${j}`),(U==='"'||U==="'"||U==="`")&&G!=="\\"){if(!X)X=!0,Q=U,F("generics-string",`Entering string with ${Q}`);else if(U===Q)X=!1,F("generics-string","Exiting string")}if(!X){if(U==="<")J++,F("generics-depth",`Increasing depth to ${J} at pos ${j}`);else if(U===">"){if(J--,F("generics-depth",`Decreasing depth to ${J} at pos ${j}`),J===0&&z===">"){Y+=">>",Z=j+1,F("generics-complete",`Found double closing bracket at pos ${j}, final buffer: ${Y}`);break}else if(J===0){Y+=">",Z=j,F("generics-complete",`Found single closing bracket at pos ${j}, final buffer: ${Y}`);break}}}if(J>0)Y+=U,F("generics-buffer",`Current buffer: ${Y}`)}if(Y)$=Y,q=q.slice(Z+1),F("generics-success",`Successfully extracted generics: ${$}`),F("generics-rest",`Remaining text: ${q}`);else F("generics-fail",`Failed to extract generics from: ${q}`)}return{generics:$,rest:q}}function j$(q){let $="";if(q.includes("(")){let J=q.indexOf("("),Z=1,Y=J+1,X="";F("params-extraction-start",`Starting params extraction from pos ${Y}: ${q}`);for(;Y<q.length;Y++){let Q=q[Y];if(Q==="(")Z++;if(Q===")"){if(Z--,Z===0){F("params-depth-zero",`Found closing parenthesis at pos ${Y}`);break}}X+=Q}$=X.trim(),q=q.slice(Y+1).trim(),F("signature-params",`Extracted params: ${$}`)}return{params:$,rest:q}}function Q$(q){if(!q.startsWith(":"))return{returnType:"void"};if(q=q.slice(1).trim(),q.includes("value is "))return{returnType:q.trim()};if(q.startsWith("Array<")||q.startsWith("Promise<")){let J=1,Z=q.indexOf("<")+1,Y=q.slice(0,Z);while(Z<q.length&&J>0){let X=q[Z];if(X==="<")J++;if(X===">")J--;Y+=X,Z++}return{returnType:Y}}if(q.startsWith("{")){let J=1,Z=1,Y="{";while(Z<q.length&&J>0){let X=q[Z];if(X==="{")J++;if(X==="}")J--;Y+=X,Z++}return{returnType:Y}}let $=q.match(/^([^{;]+)/);return{returnType:$?$[1].trim():"void"}}function E1(q){F("extract-function",`Extracting function type from: ${q}`);let $=q.trim(),J=0,Z=$.length;if(!$.startsWith("(")){let H=$.match(/^function\s*\w*\s*\((.*?)\)/s);if(H){let[,_]=H,I=V1(_||""),W=$.match(/\):\s*([^{;]+)(?:[{;]|$)/),C=W?c$(W[1]):"unknown";return`(${I}) => ${C}`}return null}J++;let Y=1,X=J,Q=!1,j="";for(;J<Z;J++){let H=$[J],_=J>0?$[J-1]:"";if(Q){if(H===j&&_!=="\\")Q=!1;else if(H==="\\")J++}else if(H==='"'||H==="'"||H==="`")Q=!0,j=H;else if(H==="(")Y++;else if(H===")"){if(Y--,Y===0)break}}if(Y!==0)return F("extract-function","Unbalanced parentheses in function parameters"),null;let U=J,z=$.slice(X,U);J++;while(J<Z&&/\s/.test($[J]))J++;let G="unknown";if($[J]===":"){J++;while(J<Z&&/\s/.test($[J]))J++;let H=J;while(J<Z&&!$.startsWith("=>",J)&&$[J]!=="{")J++;let _=J;G=$.slice(H,_).trim()}while(J<Z&&/\s/.test($[J]))J++;if($.startsWith("=>",J))J+=2;else return F("extract-function",'Function expression missing "=>"'),null;let V=V1(z||"");return F("extract-function",`Extracted function type: (${V}) => ${G}`),`(${V}) => ${G}`}function U$(q){let $=[],J=new Set;for(let[Y,X]of q.typeImports){let Q=Array.from(X).filter((j)=>q.usedTypes.has(j)).map((j)=>{let U=q.valueAliases.get(j);return U?`${j} as ${U}`:j}).sort();if(Q.length>0){let j=`import type { ${Q.join(", ")} } from '${Y}'`;if(!J.has(j))$.push(j),J.add(j)}}let Z=new Set;for(let[Y,X]of q.valueImports){if(Z.has(Y))continue;Z.add(Y);let Q=Array.from(q.valueAliases.entries()).find(([U,z])=>z==="default"&&q.importSources.get(U)===Y&&q.usedValues.has(U))?.[0],j=Array.from(X).filter((U)=>U!=="default").filter((U)=>{let z=Array.from(q.valueAliases.entries()).find(([G,V])=>V===U)?.[0];return q.usedValues.has(U)||z&&q.usedValues.has(z)}).map((U)=>{let z=Array.from(q.valueAliases.entries()).find(([G,V])=>V===U)?.[0];return z?`${U} as ${z}`:U}).sort();if(Q||j.length>0){let U="import ";if(Q){if(U+=Q,j.length>0)U+=", "}if(j.length>0)U+=`{ ${j.join(", ")} }`;if(U+=` from '${Y}'`,!J.has(U))$.push(U),J.add(U)}}return $.sort()}function z$(q){F("extract-object",`Processing object of length ${q.length}`);let $=q.trim();if(!$.startsWith("{"))return null;let J=0,Z=!1,Y="";for(let X=0;X<$.length;X++){let Q=$[X],j=X>0?$[X-1]:"";if((Q==='"'||Q==="'"||Q==="`")&&j!=="\\"){if(!Z)Z=!0,Y=Q;else if(Q===Y)Z=!1;continue}if(!Z){if(Q==="{")J++;else if(Q==="}"){if(J--,J===0)return $.slice(0,X+1)}}}return null}function G$(q){let $=new Set,J=[],Z=[],Y=[],X=[];q.dtsLines.forEach((j)=>{let U=j.trim();if(!U)return;if(U.startsWith("import"))$.add(U.replace(/;+$/,""));else if(U.startsWith("export {"))Z.push(U);else if(U.startsWith("export default"))Y.push(U);else if(U.startsWith("export *"))X.push(U);else J.push(U)}),Array.from(q.defaultExports).forEach((j)=>Y.push(j.trim().replace(/;+$/,";")));let Q=[];if($.size>0)Q.push(...Array.from($).map((j)=>`${j};`),"");if(J.length>0)Q.push(...J);if(Z.length>0){if(Q.length>0)Q.push("");Q.push(...Z)}if(X.length>0){if(Q.length>0)Q.push("");Q.push(...X)}if(Y.length>0){if(Q.length>0)Q.push("");Q.push(...Y)}return Q.map((j)=>j.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,"")).join(`
4
- `).trim()}function F$(q){let $=q.split(`
5
- `),J=0;while(J<$.length){let Z=$[J].trim();if(Z.startsWith("//")||Z.startsWith("/*")||Z.startsWith("*")||Z==="")J++;else break}return $.slice(J).join(`
6
- `)}function K$(){return{dtsLines:[],imports:[],usedTypes:new Set,typeSources:new Map,defaultExport:null,exportAllStatements:[],currentDeclaration:"",lastCommentBlock:"",bracketCount:0,isMultiLineDeclaration:!1,moduleImports:new Map,availableTypes:new Map,availableValues:new Map,currentIndentation:"",declarationBuffer:null,importTracking:B$(),defaultExports:new Set,currentScope:"top"}}function B$(){return{typeImports:new Map,valueImports:new Map,usedTypes:new Set,usedValues:new Set,exportedTypes:new Set,exportedValues:new Set,valueAliases:new Map,importSources:new Map,typeExportSources:new Map,defaultExportValue:void 0}}function n1(q,$,J){let Z=q.split(`
7
- `);if(Z.length===1)return`${$}${q}${J?"":" |"}`;let Y=[],X=!1,Q=0;return Z.forEach((U)=>{let z=U.trim();if(z.startsWith("Array<"))Q=0;if(z==="}"||z.startsWith("> |")||z===">")X=Q===1;if(z&&!z.startsWith("Array<")&&!z.endsWith(">")&&!z.startsWith("{")&&!z.endsWith("}"))Q++}),Z.map((U,z)=>{let G=U.trim();if(!G)return"";let V=$;if(z>0){let W=Y.reduce((C,O)=>C+O.depth,0);if(V=$+" ".repeat(W),G.match(/^['"]/))V+=" ";if((G.startsWith("}")||G.startsWith(">")||G.startsWith("> |"))&&Y.length>0)V=$+" ".repeat(Math.max(0,W-1))}let H=G.match(/[{<[]/g)||[],_=G.match(/[}\]>]/g)||[];if(H.forEach((W)=>{let C=G.startsWith("Array")&&W==="<";Y.push({char:W,indent:V,isArray:C,depth:1,isSingleElement:X})}),_.length>0){for(let W=0;W<_.length;W++)if(Y.length>0)Y.pop()}let I=!1;if(!J&&z===Z.length-1&&!G.endsWith(" |")&&!G.endsWith(";"))I=!0;if(G==="}"){if([...Y].reverse().find((C)=>C.isArray)?.isSingleElement)I=!1}if(G.endsWith(" |"))I=!1;return`${V}${G}${I?" |":""}`}).filter(Boolean).join(`
8
- `)}function w$(q){let $=q.split(`
9
- `).map((Z)=>Z.trim()).join(" ");if(/^['"`].*['"`]$/.test($))return $;if(!Number.isNaN(Number($)))return $;if($==="true"||$==="false")return $;let J=$.match(/\([^)]*\)\s*:\s*([^=>{]+)/);if(J)return J[1].trim();if($.includes("=>"))return"(...args: any[]) => unknown";return"unknown"}function M1(q,$,J=!1){let Z=q.slice(1,-1).trim(),Y=q.trim().endsWith("as const");if(!Z)return Y?"readonly unknown[]":"unknown[]";let X=j0(Z);if(Y||X.some((z)=>z.includes("as const"))){let z=X.map((G)=>{let V=G.trim().replace(/\s*as\s*const\s*$/,"").trim();return q0(V,$)});if(I$(z))return`readonly [
10
- ${z.map((V,H)=>n1(V," ",H===z.length-1)).join(`
2
+ var $q=Object.create;var{getPrototypeOf:qq,defineProperty:a1,getOwnPropertyNames:Jq}=Object;var Zq=Object.prototype.hasOwnProperty;var V1=($,q,J)=>{J=$!=null?$q(qq($)):{};let Z=q||!$||!$.__esModule?a1(J,"default",{value:$,enumerable:!0}):J;for(let j of Jq($))if(!Zq.call(Z,j))a1(Z,j,{get:()=>$[j],enumerable:!0});return Z};var D=($,q)=>()=>(q||$((q={exports:{}}).exports,q),q.exports);var a=import.meta.require;var L1=D((V0)=>{Object.defineProperty(V0,"__esModule",{value:!0});V0.normalizePath=V0.isRootDirectory=V0.convertSlashes=V0.cleanPath=void 0;var k1=a("path");function w0($){let q=k1.normalize($);if(q.length>1&&q[q.length-1]===k1.sep)q=q.substring(0,q.length-1);return q}V0.cleanPath=w0;var aq=/[\\/]/g;function K0($,q){return $.replace(aq,q)}V0.convertSlashes=K0;function tq($){return $==="/"||/^[a-z]:\\$/i.test($)}V0.isRootDirectory=tq;function eq($,q){let{resolvePaths:J,normalizePath:Z,pathSeparator:j}=q,Y=process.platform==="win32"&&$.includes("/")||$.startsWith(".");if(J)$=k1.resolve($);if(Z||Y)$=w0($);if($===".")return"";let X=$[$.length-1]!==j;return K0(X?$+j:$,j)}V0.normalizePath=eq});var H0=D((M0)=>{Object.defineProperty(M0,"__esModule",{value:!0});M0.build=M0.joinDirectoryPath=M0.joinPathWithBasePath=void 0;var ZJ=a("path"),jJ=L1();function f0($,q){return q+$}M0.joinPathWithBasePath=f0;function YJ($,q){return function(J,Z){if(Z.startsWith($))return Z.replace($,"")+J;else return jJ.convertSlashes(ZJ.relative($,Z),q.pathSeparator)+q.pathSeparator+J}}function XJ($){return $}function QJ($,q,J){return q+$+J}M0.joinDirectoryPath=QJ;function WJ($,q){let{relativePaths:J,includeBasePath:Z}=q;return J&&$?YJ($,q):Z?f0:XJ}M0.build=WJ});var O0=D((I0)=>{Object.defineProperty(I0,"__esModule",{value:!0});I0.build=void 0;function GJ($){return function(q,J){J.push(q.substring($.length)||".")}}function FJ($){return function(q,J,Z){let j=q.substring($.length)||".";if(Z.every((Y)=>Y(j,!0)))J.push(j)}}var wJ=($,q)=>{q.push($||".")},KJ=($,q,J)=>{let Z=$||".";if(J.every((j)=>j(Z,!0)))q.push(Z)},VJ=()=>{};function BJ($,q){let{includeDirs:J,filters:Z,relativePaths:j}=q;if(!J)return VJ;if(j)return Z&&Z.length?FJ($):GJ($);return Z&&Z.length?KJ:wJ}I0.build=BJ});var A0=D((R0)=>{Object.defineProperty(R0,"__esModule",{value:!0});R0.build=void 0;var fJ=($,q,J,Z)=>{if(Z.every((j)=>j($,!1)))J.files++},MJ=($,q,J,Z)=>{if(Z.every((j)=>j($,!1)))q.push($)},NJ=($,q,J,Z)=>{J.files++},HJ=($,q)=>{q.push($)},IJ=()=>{};function _J($){let{excludeFiles:q,filters:J,onlyCounts:Z}=$;if(q)return IJ;if(J&&J.length)return Z?fJ:MJ;else if(Z)return NJ;else return HJ}R0.build=_J});var S0=D((E0)=>{Object.defineProperty(E0,"__esModule",{value:!0});E0.build=void 0;var OJ=($)=>{return $},RJ=()=>{return[""].slice(0,0)};function CJ($){return $.group?RJ:OJ}E0.build=CJ});var T0=D((y0)=>{Object.defineProperty(y0,"__esModule",{value:!0});y0.build=void 0;var AJ=($,q,J)=>{$.push({directory:q,files:J,dir:q})},EJ=()=>{};function PJ($){return $.group?AJ:EJ}y0.build=PJ});var L0=D((j1)=>{var SJ=j1&&j1.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(j1,"__esModule",{value:!0});j1.build=void 0;var H1=SJ(a("fs")),x0=a("path"),yJ=function($,q,J){let{queue:Z,options:{suppressErrors:j}}=q;Z.enqueue(),H1.default.realpath($,(Y,X)=>{if(Y)return Z.dequeue(j?null:Y,q);H1.default.stat(X,(W,Q)=>{if(W)return Z.dequeue(j?null:W,q);if(Q.isDirectory()&&k0($,X,q))return Z.dequeue(null,q);J(Q,X),Z.dequeue(null,q)})})},DJ=function($,q,J){let{queue:Z,options:{suppressErrors:j}}=q;Z.enqueue();try{let Y=H1.default.realpathSync($),X=H1.default.statSync(Y);if(X.isDirectory()&&k0($,Y,q))return;J(X,Y)}catch(Y){if(!j)throw Y}};function TJ($,q){if(!$.resolveSymlinks||$.excludeSymlinks)return null;return q?DJ:yJ}j1.build=TJ;function k0($,q,J){if(J.options.useRealPaths)return xJ(q,J);let Z=x0.dirname($),j=1;while(Z!==J.root&&j<2){let Y=J.symlinks.get(Z);if(!!Y&&(Y===q||Y.startsWith(q)||q.startsWith(Y)))j++;else Z=x0.dirname(Z)}return J.symlinks.set($,q),j>1}function xJ($,q){return q.visited.includes($+q.options.pathSeparator)}});var b0=D((g0)=>{Object.defineProperty(g0,"__esModule",{value:!0});g0.build=void 0;var kJ=($)=>{return $.counts},LJ=($)=>{return $.groups},gJ=($)=>{return $.paths},hJ=($)=>{return $.paths.slice(0,$.options.maxFiles)},bJ=($,q,J)=>{return I1(q,J,$.counts,$.options.suppressErrors),null},vJ=($,q,J)=>{return I1(q,J,$.paths,$.options.suppressErrors),null},uJ=($,q,J)=>{return I1(q,J,$.paths.slice(0,$.options.maxFiles),$.options.suppressErrors),null},mJ=($,q,J)=>{return I1(q,J,$.groups,$.options.suppressErrors),null};function I1($,q,J,Z){if($&&!Z)q($,J);else q(null,J)}function dJ($,q){let{onlyCounts:J,group:Z,maxFiles:j}=$;if(J)return q?kJ:bJ;else if(Z)return q?LJ:mJ;else if(j)return q?hJ:uJ;else return q?gJ:vJ}g0.build=dJ});var m0=D((Y1)=>{var cJ=Y1&&Y1.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(Y1,"__esModule",{value:!0});Y1.build=void 0;var v0=cJ(a("fs")),u0={withFileTypes:!0},lJ=($,q,J,Z,j)=>{if(Z<0)return $.queue.dequeue(null,$);$.visited.push(q),$.counts.directories++,$.queue.enqueue(),v0.default.readdir(q||".",u0,(Y,X=[])=>{j(X,J,Z),$.queue.dequeue($.options.suppressErrors?null:Y,$)})},iJ=($,q,J,Z,j)=>{if(Z<0)return;$.visited.push(q),$.counts.directories++;let Y=[];try{Y=v0.default.readdirSync(q||".",u0)}catch(X){if(!$.options.suppressErrors)throw X}j(Y,J,Z)};function pJ($){return $?iJ:lJ}Y1.build=pJ});var i0=D((c0)=>{Object.defineProperty(c0,"__esModule",{value:!0});c0.Queue=void 0;class d0{onQueueEmpty;count=0;constructor($){this.onQueueEmpty=$}enqueue(){this.count++}dequeue($,q){if(--this.count<=0||$)this.onQueueEmpty($,q)}}c0.Queue=d0});var o0=D((n0)=>{Object.defineProperty(n0,"__esModule",{value:!0});n0.Counter=void 0;class p0{_files=0;_directories=0;set files($){this._files=$}get files(){return this._files}set directories($){this._directories=$}get directories(){return this._directories}get dirs(){return this._directories}}n0.Counter=p0});var h1=D((s)=>{var nJ=s&&s.__createBinding||(Object.create?function($,q,J,Z){if(Z===void 0)Z=J;var j=Object.getOwnPropertyDescriptor(q,J);if(!j||("get"in j?!q.__esModule:j.writable||j.configurable))j={enumerable:!0,get:function(){return q[J]}};Object.defineProperty($,Z,j)}:function($,q,J,Z){if(Z===void 0)Z=J;$[Z]=q[J]}),sJ=s&&s.__setModuleDefault||(Object.create?function($,q){Object.defineProperty($,"default",{enumerable:!0,value:q})}:function($,q){$.default=q}),q1=s&&s.__importStar||function($){if($&&$.__esModule)return $;var q={};if($!=null){for(var J in $)if(J!=="default"&&Object.prototype.hasOwnProperty.call($,J))nJ(q,$,J)}return sJ(q,$),q};Object.defineProperty(s,"__esModule",{value:!0});s.Walker=void 0;var r0=a("path"),_1=L1(),g1=q1(H0()),oJ=q1(O0()),rJ=q1(A0()),aJ=q1(S0()),tJ=q1(T0()),eJ=q1(L0()),$Z=q1(b0()),qZ=q1(m0()),JZ=i0(),ZZ=o0();class a0{root;isSynchronous;state;joinPath;pushDirectory;pushFile;getArray;groupFiles;resolveSymlink;walkDirectory;callbackInvoker;constructor($,q,J){this.isSynchronous=!J,this.callbackInvoker=$Z.build(q,this.isSynchronous),this.root=_1.normalizePath($,q),this.state={root:_1.isRootDirectory(this.root)?this.root:this.root.slice(0,-1),paths:[""].slice(0,0),groups:[],counts:new ZZ.Counter,options:q,queue:new JZ.Queue((Z,j)=>this.callbackInvoker(j,Z,J)),symlinks:new Map,visited:[""].slice(0,0)},this.joinPath=g1.build(this.root,q),this.pushDirectory=oJ.build(this.root,q),this.pushFile=rJ.build(q),this.getArray=aJ.build(q),this.groupFiles=tJ.build(q),this.resolveSymlink=eJ.build(q,this.isSynchronous),this.walkDirectory=qZ.build(this.isSynchronous)}start(){return this.walkDirectory(this.state,this.root,this.root,this.state.options.maxDepth,this.walk),this.isSynchronous?this.callbackInvoker(this.state,null):null}walk=($,q,J)=>{let{paths:Z,options:{filters:j,resolveSymlinks:Y,excludeSymlinks:X,exclude:W,maxFiles:Q,signal:U,useRealPaths:z,pathSeparator:G}}=this.state;if(U&&U.aborted||Q&&Z.length>Q)return;this.pushDirectory(q,Z,j);let F=this.getArray(this.state.paths);for(let M=0;M<$.length;++M){let f=$[M];if(f.isFile()||f.isSymbolicLink()&&!Y&&!X){let I=this.joinPath(f.name,q);this.pushFile(I,F,this.state.counts,j)}else if(f.isDirectory()){let I=g1.joinDirectoryPath(f.name,q,this.state.options.pathSeparator);if(W&&W(f.name,I))continue;this.walkDirectory(this.state,I,I,J-1,this.walk)}else if(f.isSymbolicLink()&&this.resolveSymlink){let I=g1.joinPathWithBasePath(f.name,q);this.resolveSymlink(I,this.state,(P,E)=>{if(P.isDirectory()){if(E=_1.normalizePath(E,this.state.options),W&&W(f.name,z?E:I+G))return;this.walkDirectory(this.state,E,z?E:I+G,J-1,this.walk)}else{E=z?E:I;let _=r0.basename(E),x=_1.normalizePath(r0.dirname(E),this.state.options);E=this.joinPath(_,x),this.pushFile(E,F,this.state.counts,j)}})}}this.groupFiles(this.state.groups,q,F)}}s.Walker=a0});var q$=D((e0)=>{Object.defineProperty(e0,"__esModule",{value:!0});e0.callback=e0.promise=void 0;var jZ=h1();function YZ($,q){return new Promise((J,Z)=>{t0($,q,(j,Y)=>{if(j)return Z(j);J(Y)})})}e0.promise=YZ;function t0($,q,J){new jZ.Walker($,q,J).start()}e0.callback=t0});var j$=D((J$)=>{Object.defineProperty(J$,"__esModule",{value:!0});J$.sync=void 0;var QZ=h1();function WZ($,q){return new QZ.Walker($,q).start()}J$.sync=WZ});var U$=D((Q$)=>{Object.defineProperty(Q$,"__esModule",{value:!0});Q$.APIBuilder=void 0;var Y$=q$(),UZ=j$();class X${root;options;constructor($,q){this.root=$,this.options=q}withPromise(){return Y$.promise(this.root,this.options)}withCallback($){Y$.callback(this.root,this.options,$)}sync(){return UZ.sync(this.root,this.options)}}Q$.APIBuilder=X$});var W1=D((o5,G$)=>{var z$={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:"(?=.)",QMARK:"[^/]",END_ANCHOR:"(?:\\/|$)",DOTS_SLASH:"\\.{1,2}(?:\\/|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|\\/)\\.{1,2}(?:\\/|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:\\/|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:\\/|$))",QMARK_NO_DOT:"[^.\\/]",STAR:"[^/]*?",START_ANCHOR:"(?:^|\\/)",SEP:"/"},zZ={...z$,SLASH_LITERAL:"[\\\\/]",QMARK:"[^\\\\/]",STAR:"[^\\\\/]*?",DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},GZ={alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};G$.exports={MAX_LENGTH:65536,POSIX_REGEX_SOURCE:GZ,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars($){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${$.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars($){return $===!0?zZ:z$}}});var U1=D((BZ)=>{var{REGEX_BACKSLASH:FZ,REGEX_REMOVE_BACKSLASH:wZ,REGEX_SPECIAL_CHARS:KZ,REGEX_SPECIAL_CHARS_GLOBAL:VZ}=W1();BZ.isObject=($)=>$!==null&&typeof $==="object"&&!Array.isArray($);BZ.hasRegexChars=($)=>KZ.test($);BZ.isRegexChar=($)=>$.length===1&&BZ.hasRegexChars($);BZ.escapeRegex=($)=>$.replace(VZ,"\\$1");BZ.toPosixSlashes=($)=>$.replace(FZ,"/");BZ.isWindows=()=>{if(typeof navigator!=="undefined"&&navigator.platform){let $=navigator.platform.toLowerCase();return $==="win32"||$==="windows"}if(typeof process!=="undefined"&&process.platform)return process.platform==="win32";return!1};BZ.removeBackslashes=($)=>{return $.replace(wZ,(q)=>{return q==="\\"?"":q})};BZ.escapeLast=($,q,J)=>{let Z=$.lastIndexOf(q,J);if(Z===-1)return $;if($[Z-1]==="\\")return BZ.escapeLast($,q,Z-1);return`${$.slice(0,Z)}\\${$.slice(Z)}`};BZ.removePrefix=($,q={})=>{let J=$;if(J.startsWith("./"))J=J.slice(2),q.prefix="./";return J};BZ.wrapOutput=($,q={},J={})=>{let Z=J.contains?"":"^",j=J.contains?"":"$",Y=`${Z}(?:${$})${j}`;if(q.negated===!0)Y=`(?:^(?!${Y}).*$)`;return Y};BZ.basename=($,{windows:q}={})=>{let J=$.split(q?/[\\/]/:"/"),Z=J[J.length-1];if(Z==="")return J[J.length-2];return Z}});var I$=D((a5,H$)=>{var K$=U1(),{CHAR_ASTERISK:b1,CHAR_AT:AZ,CHAR_BACKWARD_SLASH:z1,CHAR_COMMA:EZ,CHAR_DOT:v1,CHAR_EXCLAMATION_MARK:u1,CHAR_FORWARD_SLASH:N$,CHAR_LEFT_CURLY_BRACE:m1,CHAR_LEFT_PARENTHESES:d1,CHAR_LEFT_SQUARE_BRACKET:PZ,CHAR_PLUS:SZ,CHAR_QUESTION_MARK:V$,CHAR_RIGHT_CURLY_BRACE:yZ,CHAR_RIGHT_PARENTHESES:B$,CHAR_RIGHT_SQUARE_BRACKET:DZ}=W1(),f$=($)=>{return $===N$||$===z1},M$=($)=>{if($.isPrefix!==!0)$.depth=$.isGlobstar?1/0:1},TZ=($,q)=>{let J=q||{},Z=$.length-1,j=J.parts===!0||J.scanToEnd===!0,Y=[],X=[],W=[],Q=$,U=-1,z=0,G=0,F=!1,M=!1,f=!1,I=!1,P=!1,E=!1,_=!1,x=!1,i=!1,m=!1,u=0,l,O,C={value:"",depth:0,isGlob:!1},V=()=>U>=Z,c=()=>Q.charCodeAt(U+1),b=()=>{return l=O,Q.charCodeAt(++U)};while(U<Z){O=b();let S;if(O===z1){if(_=C.backslashes=!0,O=b(),O===m1)E=!0;continue}if(E===!0||O===m1){u++;while(V()!==!0&&(O=b())){if(O===z1){_=C.backslashes=!0,b();continue}if(O===m1){u++;continue}if(E!==!0&&O===v1&&(O=b())===v1){if(F=C.isBrace=!0,f=C.isGlob=!0,m=!0,j===!0)continue;break}if(E!==!0&&O===EZ){if(F=C.isBrace=!0,f=C.isGlob=!0,m=!0,j===!0)continue;break}if(O===yZ){if(u--,u===0){E=!1,F=C.isBrace=!0,m=!0;break}}}if(j===!0)continue;break}if(O===N$){if(Y.push(U),X.push(C),C={value:"",depth:0,isGlob:!1},m===!0)continue;if(l===v1&&U===z+1){z+=2;continue}G=U+1;continue}if(J.noext!==!0){if((O===SZ||O===AZ||O===b1||O===V$||O===u1)===!0&&c()===d1){if(f=C.isGlob=!0,I=C.isExtglob=!0,m=!0,O===u1&&U===z)i=!0;if(j===!0){while(V()!==!0&&(O=b())){if(O===z1){_=C.backslashes=!0,O=b();continue}if(O===B$){f=C.isGlob=!0,m=!0;break}}continue}break}}if(O===b1){if(l===b1)P=C.isGlobstar=!0;if(f=C.isGlob=!0,m=!0,j===!0)continue;break}if(O===V$){if(f=C.isGlob=!0,m=!0,j===!0)continue;break}if(O===PZ){while(V()!==!0&&(S=b())){if(S===z1){_=C.backslashes=!0,b();continue}if(S===DZ){M=C.isBracket=!0,f=C.isGlob=!0,m=!0;break}}if(j===!0)continue;break}if(J.nonegate!==!0&&O===u1&&U===z){x=C.negated=!0,z++;continue}if(J.noparen!==!0&&O===d1){if(f=C.isGlob=!0,j===!0){while(V()!==!0&&(O=b())){if(O===d1){_=C.backslashes=!0,O=b();continue}if(O===B$){m=!0;break}}continue}break}if(f===!0){if(m=!0,j===!0)continue;break}}if(J.noext===!0)I=!1,f=!1;let g=Q,w="",K="";if(z>0)w=Q.slice(0,z),Q=Q.slice(z),G-=z;if(g&&f===!0&&G>0)g=Q.slice(0,G),K=Q.slice(G);else if(f===!0)g="",K=Q;else g=Q;if(g&&g!==""&&g!=="/"&&g!==Q){if(f$(g.charCodeAt(g.length-1)))g=g.slice(0,-1)}if(J.unescape===!0){if(K)K=K$.removeBackslashes(K);if(g&&_===!0)g=K$.removeBackslashes(g)}let p={prefix:w,input:$,start:z,base:g,glob:K,isBrace:F,isBracket:M,isGlob:f,isExtglob:I,isGlobstar:P,negated:x,negatedExtglob:i};if(J.tokens===!0){if(p.maxDepth=0,!f$(O))X.push(C);p.tokens=X}if(J.parts===!0||J.tokens===!0){let S;for(let k=0;k<Y.length;k++){let r=S?S+1:z,n=Y[k],$1=$.slice(r,n);if(J.tokens){if(k===0&&z!==0)X[k].isPrefix=!0,X[k].value=w;else X[k].value=$1;M$(X[k]),p.maxDepth+=X[k].depth}if(k!==0||$1!=="")W.push($1);S=n}if(S&&S+1<$.length){let k=$.slice(S+1);if(W.push(k),J.tokens)X[X.length-1].value=k,M$(X[X.length-1]),p.maxDepth+=X[X.length-1].depth}p.slashes=Y,p.parts=W}return p};H$.exports=TZ});var R$=D((t5,O$)=>{var O1=W1(),o=U1(),{MAX_LENGTH:R1,POSIX_REGEX_SOURCE:xZ,REGEX_NON_SPECIAL_CHARS:kZ,REGEX_SPECIAL_CHARS_BACKREF:LZ,REPLACEMENTS:_$}=O1,gZ=($,q)=>{if(typeof q.expandRange==="function")return q.expandRange(...$,q);$.sort();let J=`[${$.join("-")}]`;try{new RegExp(J)}catch(Z){return $.map((j)=>o.escapeRegex(j)).join("..")}return J},X1=($,q)=>{return`Missing ${$}: "${q}" - use "\\\\${q}" to match literal characters`},c1=($,q)=>{if(typeof $!=="string")throw new TypeError("Expected a string");$=_$[$]||$;let J={...q},Z=typeof J.maxLength==="number"?Math.min(R1,J.maxLength):R1,j=$.length;if(j>Z)throw new SyntaxError(`Input length: ${j}, exceeds maximum allowed length: ${Z}`);let Y={type:"bos",value:"",output:J.prepend||""},X=[Y],W=J.capture?"":"?:",Q=O1.globChars(J.windows),U=O1.extglobChars(Q),{DOT_LITERAL:z,PLUS_LITERAL:G,SLASH_LITERAL:F,ONE_CHAR:M,DOTS_SLASH:f,NO_DOT:I,NO_DOT_SLASH:P,NO_DOTS_SLASH:E,QMARK:_,QMARK_NO_DOT:x,STAR:i,START_ANCHOR:m}=Q,u=(H)=>{return`(${W}(?:(?!${m}${H.dot?f:z}).)*?)`},l=J.dot?"":I,O=J.dot?_:x,C=J.bash===!0?u(J):i;if(J.capture)C=`(${C})`;if(typeof J.noext==="boolean")J.noextglob=J.noext;let V={input:$,index:-1,start:0,dot:J.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:X};$=o.removePrefix($,V),j=$.length;let c=[],b=[],g=[],w=Y,K,p=()=>V.index===j-1,S=V.peek=(H=1)=>$[V.index+H],k=V.advance=()=>$[++V.index]||"",r=()=>$.slice(V.index+1),n=(H="",y=0)=>{V.consumed+=H,V.index+=y},$1=(H)=>{V.output+=H.output!=null?H.output:H.value,n(H.value)},t$=()=>{let H=1;while(S()==="!"&&(S(2)!=="("||S(3)==="?"))k(),V.start++,H++;if(H%2===0)return!1;return V.negated=!0,V.start++,!0},F1=(H)=>{V[H]++,g.push(H)},J1=(H)=>{V[H]--,g.pop()},A=(H)=>{if(w.type==="globstar"){let y=V.braces>0&&(H.type==="comma"||H.type==="brace"),N=H.extglob===!0||c.length&&(H.type==="pipe"||H.type==="paren");if(H.type!=="slash"&&H.type!=="paren"&&!y&&!N)V.output=V.output.slice(0,-w.output.length),w.type="star",w.value="*",w.output=C,V.output+=w.output}if(c.length&&H.type!=="paren")c[c.length-1].inner+=H.value;if(H.value||H.output)$1(H);if(w&&w.type==="text"&&H.type==="text"){w.output=(w.output||w.value)+H.value,w.value+=H.value;return}H.prev=w,X.push(H),w=H},w1=(H,y)=>{let N={...U[y],conditions:1,inner:""};N.prev=w,N.parens=V.parens,N.output=V.output;let R=(J.capture?"(":"")+N.open;F1("parens"),A({type:H,value:y,output:V.output?"":M}),A({type:"paren",extglob:!0,value:k(),output:R}),c.push(N)},e$=(H)=>{let y=H.close+(J.capture?")":""),N;if(H.type==="negate"){let R=C;if(H.inner&&H.inner.length>1&&H.inner.includes("/"))R=u(J);if(R!==C||p()||/^\)+$/.test(r()))y=H.close=`)$))${R}`;if(H.inner.includes("*")&&(N=r())&&/^\.[^\\/.]+$/.test(N)){let L=c1(N,{...q,fastpaths:!1}).output;y=H.close=`)${L})${R})`}if(H.prev.type==="bos")V.negatedExtglob=!0}A({type:"paren",extglob:!0,value:K,output:y}),J1("parens")};if(J.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test($)){let H=!1,y=$.replace(LZ,(N,R,L,d,v,P1)=>{if(d==="\\")return H=!0,N;if(d==="?"){if(R)return R+d+(v?_.repeat(v.length):"");if(P1===0)return O+(v?_.repeat(v.length):"");return _.repeat(L.length)}if(d===".")return z.repeat(L.length);if(d==="*"){if(R)return R+d+(v?C:"");return C}return R?N:`\\${N}`});if(H===!0)if(J.unescape===!0)y=y.replace(/\\/g,"");else y=y.replace(/\\+/g,(N)=>{return N.length%2===0?"\\\\":N?"\\":""});if(y===$&&J.contains===!0)return V.output=$,V;return V.output=o.wrapOutput(y,V,q),V}while(!p()){if(K=k(),K==="\x00")continue;if(K==="\\"){let N=S();if(N==="/"&&J.bash!==!0)continue;if(N==="."||N===";")continue;if(!N){K+="\\",A({type:"text",value:K});continue}let R=/^\\+/.exec(r()),L=0;if(R&&R[0].length>2){if(L=R[0].length,V.index+=L,L%2!==0)K+="\\"}if(J.unescape===!0)K=k();else K+=k();if(V.brackets===0){A({type:"text",value:K});continue}}if(V.brackets>0&&(K!=="]"||w.value==="["||w.value==="[^")){if(J.posix!==!1&&K===":"){let N=w.value.slice(1);if(N.includes("[")){if(w.posix=!0,N.includes(":")){let R=w.value.lastIndexOf("["),L=w.value.slice(0,R),d=w.value.slice(R+2),v=xZ[d];if(v){if(w.value=L+v,V.backtrack=!0,k(),!Y.output&&X.indexOf(w)===1)Y.output=M;continue}}}}if(K==="["&&S()!==":"||K==="-"&&S()==="]")K=`\\${K}`;if(K==="]"&&(w.value==="["||w.value==="[^"))K=`\\${K}`;if(J.posix===!0&&K==="!"&&w.value==="[")K="^";w.value+=K,$1({value:K});continue}if(V.quotes===1&&K!=='"'){K=o.escapeRegex(K),w.value+=K,$1({value:K});continue}if(K==='"'){if(V.quotes=V.quotes===1?0:1,J.keepQuotes===!0)A({type:"text",value:K});continue}if(K==="("){F1("parens"),A({type:"paren",value:K});continue}if(K===")"){if(V.parens===0&&J.strictBrackets===!0)throw new SyntaxError(X1("opening","("));let N=c[c.length-1];if(N&&V.parens===N.parens+1){e$(c.pop());continue}A({type:"paren",value:K,output:V.parens?")":"\\)"}),J1("parens");continue}if(K==="["){if(J.nobracket===!0||!r().includes("]")){if(J.nobracket!==!0&&J.strictBrackets===!0)throw new SyntaxError(X1("closing","]"));K=`\\${K}`}else F1("brackets");A({type:"bracket",value:K});continue}if(K==="]"){if(J.nobracket===!0||w&&w.type==="bracket"&&w.value.length===1){A({type:"text",value:K,output:`\\${K}`});continue}if(V.brackets===0){if(J.strictBrackets===!0)throw new SyntaxError(X1("opening","["));A({type:"text",value:K,output:`\\${K}`});continue}J1("brackets");let N=w.value.slice(1);if(w.posix!==!0&&N[0]==="^"&&!N.includes("/"))K=`/${K}`;if(w.value+=K,$1({value:K}),J.literalBrackets===!1||o.hasRegexChars(N))continue;let R=o.escapeRegex(w.value);if(V.output=V.output.slice(0,-w.value.length),J.literalBrackets===!0){V.output+=R,w.value=R;continue}w.value=`(${W}${R}|${w.value})`,V.output+=w.value;continue}if(K==="{"&&J.nobrace!==!0){F1("braces");let N={type:"brace",value:K,output:"(",outputIndex:V.output.length,tokensIndex:V.tokens.length};b.push(N),A(N);continue}if(K==="}"){let N=b[b.length-1];if(J.nobrace===!0||!N){A({type:"text",value:K,output:K});continue}let R=")";if(N.dots===!0){let L=X.slice(),d=[];for(let v=L.length-1;v>=0;v--){if(X.pop(),L[v].type==="brace")break;if(L[v].type!=="dots")d.unshift(L[v].value)}R=gZ(d,J),V.backtrack=!0}if(N.comma!==!0&&N.dots!==!0){let L=V.output.slice(0,N.outputIndex),d=V.tokens.slice(N.tokensIndex);N.value=N.output="\\{",K=R="\\}",V.output=L;for(let v of d)V.output+=v.output||v.value}A({type:"brace",value:K,output:R}),J1("braces"),b.pop();continue}if(K==="|"){if(c.length>0)c[c.length-1].conditions++;A({type:"text",value:K});continue}if(K===","){let N=K,R=b[b.length-1];if(R&&g[g.length-1]==="braces")R.comma=!0,N="|";A({type:"comma",value:K,output:N});continue}if(K==="/"){if(w.type==="dot"&&V.index===V.start+1){V.start=V.index+1,V.consumed="",V.output="",X.pop(),w=Y;continue}A({type:"slash",value:K,output:F});continue}if(K==="."){if(V.braces>0&&w.type==="dot"){if(w.value===".")w.output=z;let N=b[b.length-1];w.type="dots",w.output+=K,w.value+=K,N.dots=!0;continue}if(V.braces+V.parens===0&&w.type!=="bos"&&w.type!=="slash"){A({type:"text",value:K,output:z});continue}A({type:"dot",value:K,output:z});continue}if(K==="?"){if(!(w&&w.value==="(")&&J.noextglob!==!0&&S()==="("&&S(2)!=="?"){w1("qmark",K);continue}if(w&&w.type==="paren"){let R=S(),L=K;if(w.value==="("&&!/[!=<:]/.test(R)||R==="<"&&!/<([!=]|\w+>)/.test(r()))L=`\\${K}`;A({type:"text",value:K,output:L});continue}if(J.dot!==!0&&(w.type==="slash"||w.type==="bos")){A({type:"qmark",value:K,output:x});continue}A({type:"qmark",value:K,output:_});continue}if(K==="!"){if(J.noextglob!==!0&&S()==="("){if(S(2)!=="?"||!/[!=<:]/.test(S(3))){w1("negate",K);continue}}if(J.nonegate!==!0&&V.index===0){t$();continue}}if(K==="+"){if(J.noextglob!==!0&&S()==="("&&S(2)!=="?"){w1("plus",K);continue}if(w&&w.value==="("||J.regex===!1){A({type:"plus",value:K,output:G});continue}if(w&&(w.type==="bracket"||w.type==="paren"||w.type==="brace")||V.parens>0){A({type:"plus",value:K});continue}A({type:"plus",value:G});continue}if(K==="@"){if(J.noextglob!==!0&&S()==="("&&S(2)!=="?"){A({type:"at",extglob:!0,value:K,output:""});continue}A({type:"text",value:K});continue}if(K!=="*"){if(K==="$"||K==="^")K=`\\${K}`;let N=kZ.exec(r());if(N)K+=N[0],V.index+=N[0].length;A({type:"text",value:K});continue}if(w&&(w.type==="globstar"||w.star===!0)){w.type="star",w.star=!0,w.value+=K,w.output=C,V.backtrack=!0,V.globstar=!0,n(K);continue}let H=r();if(J.noextglob!==!0&&/^\([^?]/.test(H)){w1("star",K);continue}if(w.type==="star"){if(J.noglobstar===!0){n(K);continue}let N=w.prev,R=N.prev,L=N.type==="slash"||N.type==="bos",d=R&&(R.type==="star"||R.type==="globstar");if(J.bash===!0&&(!L||H[0]&&H[0]!=="/")){A({type:"star",value:K,output:""});continue}let v=V.braces>0&&(N.type==="comma"||N.type==="brace"),P1=c.length&&(N.type==="pipe"||N.type==="paren");if(!L&&N.type!=="paren"&&!v&&!P1){A({type:"star",value:K,output:""});continue}while(H.slice(0,3)==="/**"){let K1=$[V.index+4];if(K1&&K1!=="/")break;H=H.slice(3),n("/**",3)}if(N.type==="bos"&&p()){w.type="globstar",w.value+=K,w.output=u(J),V.output=w.output,V.globstar=!0,n(K);continue}if(N.type==="slash"&&N.prev.type!=="bos"&&!d&&p()){V.output=V.output.slice(0,-(N.output+w.output).length),N.output=`(?:${N.output}`,w.type="globstar",w.output=u(J)+(J.strictSlashes?")":"|$)"),w.value+=K,V.globstar=!0,V.output+=N.output+w.output,n(K);continue}if(N.type==="slash"&&N.prev.type!=="bos"&&H[0]==="/"){let K1=H[1]!==void 0?"|$":"";V.output=V.output.slice(0,-(N.output+w.output).length),N.output=`(?:${N.output}`,w.type="globstar",w.output=`${u(J)}${F}|${F}${K1})`,w.value+=K,V.output+=N.output+w.output,V.globstar=!0,n(K+k()),A({type:"slash",value:"/",output:""});continue}if(N.type==="bos"&&H[0]==="/"){w.type="globstar",w.value+=K,w.output=`(?:^|${F}|${u(J)}${F})`,V.output=w.output,V.globstar=!0,n(K+k()),A({type:"slash",value:"/",output:""});continue}V.output=V.output.slice(0,-w.output.length),w.type="globstar",w.output=u(J),w.value+=K,V.output+=w.output,V.globstar=!0,n(K);continue}let y={type:"star",value:K,output:C};if(J.bash===!0){if(y.output=".*?",w.type==="bos"||w.type==="slash")y.output=l+y.output;A(y);continue}if(w&&(w.type==="bracket"||w.type==="paren")&&J.regex===!0){y.output=K,A(y);continue}if(V.index===V.start||w.type==="slash"||w.type==="dot"){if(w.type==="dot")V.output+=P,w.output+=P;else if(J.dot===!0)V.output+=E,w.output+=E;else V.output+=l,w.output+=l;if(S()!=="*")V.output+=M,w.output+=M}A(y)}while(V.brackets>0){if(J.strictBrackets===!0)throw new SyntaxError(X1("closing","]"));V.output=o.escapeLast(V.output,"["),J1("brackets")}while(V.parens>0){if(J.strictBrackets===!0)throw new SyntaxError(X1("closing",")"));V.output=o.escapeLast(V.output,"("),J1("parens")}while(V.braces>0){if(J.strictBrackets===!0)throw new SyntaxError(X1("closing","}"));V.output=o.escapeLast(V.output,"{"),J1("braces")}if(J.strictSlashes!==!0&&(w.type==="star"||w.type==="bracket"))A({type:"maybe_slash",value:"",output:`${F}?`});if(V.backtrack===!0){V.output="";for(let H of V.tokens)if(V.output+=H.output!=null?H.output:H.value,H.suffix)V.output+=H.suffix}return V};c1.fastpaths=($,q)=>{let J={...q},Z=typeof J.maxLength==="number"?Math.min(R1,J.maxLength):R1,j=$.length;if(j>Z)throw new SyntaxError(`Input length: ${j}, exceeds maximum allowed length: ${Z}`);$=_$[$]||$;let{DOT_LITERAL:Y,SLASH_LITERAL:X,ONE_CHAR:W,DOTS_SLASH:Q,NO_DOT:U,NO_DOTS:z,NO_DOTS_SLASH:G,STAR:F,START_ANCHOR:M}=O1.globChars(J.windows),f=J.dot?z:U,I=J.dot?G:U,P=J.capture?"":"?:",E={negated:!1,prefix:""},_=J.bash===!0?".*?":F;if(J.capture)_=`(${_})`;let x=(l)=>{if(l.noglobstar===!0)return _;return`(${P}(?:(?!${M}${l.dot?Q:Y}).)*?)`},i=(l)=>{switch(l){case"*":return`${f}${W}${_}`;case".*":return`${Y}${W}${_}`;case"*.*":return`${f}${_}${Y}${W}${_}`;case"*/*":return`${f}${_}${X}${W}${I}${_}`;case"**":return f+x(J);case"**/*":return`(?:${f}${x(J)}${X})?${I}${W}${_}`;case"**/*.*":return`(?:${f}${x(J)}${X})?${I}${_}${Y}${W}${_}`;case"**/.*":return`(?:${f}${x(J)}${X})?${Y}${W}${_}`;default:{let O=/^(.*?)\.(\w+)$/.exec(l);if(!O)return;let C=i(O[1]);if(!C)return;return C+Y+O[2]}}},m=o.removePrefix($,E),u=i(m);if(u&&J.strictSlashes!==!0)u+=`${X}?`;return u};O$.exports=c1});var E$=D((e5,A$)=>{var hZ=I$(),l1=R$(),C$=U1(),bZ=W1(),vZ=($)=>$&&typeof $==="object"&&!Array.isArray($),h=($,q,J=!1)=>{if(Array.isArray($)){let z=$.map((F)=>h(F,q,J));return(F)=>{for(let M of z){let f=M(F);if(f)return f}return!1}}let Z=vZ($)&&$.tokens&&$.input;if($===""||typeof $!=="string"&&!Z)throw new TypeError("Expected pattern to be a non-empty string");let j=q||{},Y=j.windows,X=Z?h.compileRe($,q):h.makeRe($,q,!1,!0),W=X.state;delete X.state;let Q=()=>!1;if(j.ignore){let z={...q,ignore:null,onMatch:null,onResult:null};Q=h(j.ignore,z,J)}let U=(z,G=!1)=>{let{isMatch:F,match:M,output:f}=h.test(z,X,q,{glob:$,posix:Y}),I={glob:$,state:W,regex:X,posix:Y,input:z,output:f,match:M,isMatch:F};if(typeof j.onResult==="function")j.onResult(I);if(F===!1)return I.isMatch=!1,G?I:!1;if(Q(z)){if(typeof j.onIgnore==="function")j.onIgnore(I);return I.isMatch=!1,G?I:!1}if(typeof j.onMatch==="function")j.onMatch(I);return G?I:!0};if(J)U.state=W;return U};h.test=($,q,J,{glob:Z,posix:j}={})=>{if(typeof $!=="string")throw new TypeError("Expected input to be a string");if($==="")return{isMatch:!1,output:""};let Y=J||{},X=Y.format||(j?C$.toPosixSlashes:null),W=$===Z,Q=W&&X?X($):$;if(W===!1)Q=X?X($):$,W=Q===Z;if(W===!1||Y.capture===!0)if(Y.matchBase===!0||Y.basename===!0)W=h.matchBase($,q,J,j);else W=q.exec(Q);return{isMatch:Boolean(W),match:W,output:Q}};h.matchBase=($,q,J)=>{return(q instanceof RegExp?q:h.makeRe(q,J)).test(C$.basename($))};h.isMatch=($,q,J)=>h(q,J)($);h.parse=($,q)=>{if(Array.isArray($))return $.map((J)=>h.parse(J,q));return l1($,{...q,fastpaths:!1})};h.scan=($,q)=>hZ($,q);h.compileRe=($,q,J=!1,Z=!1)=>{if(J===!0)return $.output;let j=q||{},Y=j.contains?"":"^",X=j.contains?"":"$",W=`${Y}(?:${$.output})${X}`;if($&&$.negated===!0)W=`^(?!${W}).*$`;let Q=h.toRegex(W,q);if(Z===!0)Q.state=$;return Q};h.makeRe=($,q={},J=!1,Z=!1)=>{if(!$||typeof $!=="string")throw new TypeError("Expected a non-empty string");let j={negated:!1,fastpaths:!0};if(q.fastpaths!==!1&&($[0]==="."||$[0]==="*"))j.output=l1.fastpaths($,q);if(!j.output)j=l1($,q);return h.compileRe(j,q,J,Z)};h.toRegex=($,q)=>{try{let J=q||{};return new RegExp($,J.flags||(J.nocase?"i":""))}catch(J){if(q&&q.debug===!0)throw J;return/$^/}};h.constants=bZ;A$.exports=h});var G1=D(($8,y$)=>{var P$=E$(),uZ=U1();function S$($,q,J=!1){if(q&&(q.windows===null||q.windows===void 0))q={...q,windows:uZ.isWindows()};return P$($,q,J)}Object.assign(S$,P$);y$.exports=S$});var g$=D((k$)=>{Object.defineProperty(k$,"__esModule",{value:!0});k$.Builder=void 0;var mZ=a("path"),D$=U$(),T$=null;try{a.resolve("picomatch"),T$=G1()}catch($){}class x${globCache={};options={maxDepth:1/0,suppressErrors:!0,pathSeparator:mZ.sep,filters:[]};globFunction;constructor($){this.options={...this.options,...$},this.globFunction=this.options.globFunction}group(){return this.options.group=!0,this}withPathSeparator($){return this.options.pathSeparator=$,this}withBasePath(){return this.options.includeBasePath=!0,this}withRelativePaths(){return this.options.relativePaths=!0,this}withDirs(){return this.options.includeDirs=!0,this}withMaxDepth($){return this.options.maxDepth=$,this}withMaxFiles($){return this.options.maxFiles=$,this}withFullPaths(){return this.options.resolvePaths=!0,this.options.includeBasePath=!0,this}withErrors(){return this.options.suppressErrors=!1,this}withSymlinks({resolvePaths:$=!0}={}){return this.options.resolveSymlinks=!0,this.options.useRealPaths=$,this.withFullPaths()}withAbortSignal($){return this.options.signal=$,this}normalize(){return this.options.normalizePath=!0,this}filter($){return this.options.filters.push($),this}onlyDirs(){return this.options.excludeFiles=!0,this.options.includeDirs=!0,this}exclude($){return this.options.exclude=$,this}onlyCounts(){return this.options.onlyCounts=!0,this}crawl($){return new D$.APIBuilder($||".",this.options)}withGlobFunction($){return this.globFunction=$,this}crawlWithOptions($,q){return this.options={...this.options,...q},new D$.APIBuilder($||".",this.options)}glob(...$){if(this.globFunction)return this.globWithOptions($);return this.globWithOptions($,...[{dot:!0}])}globWithOptions($,...q){let J=this.globFunction||T$;if(!J)throw new Error("Please specify a glob function to use glob matching.");var Z=this.globCache[$.join("\x00")];if(!Z)Z=J($,...q),this.globCache[$.join("\x00")]=Z;return this.options.filters.push((j)=>Z(j)),this}}k$.Builder=x$});var b$=D((h$)=>{Object.defineProperty(h$,"__esModule",{value:!0})});var v$=D((e)=>{var dZ=e&&e.__createBinding||(Object.create?function($,q,J,Z){if(Z===void 0)Z=J;var j=Object.getOwnPropertyDescriptor(q,J);if(!j||("get"in j?!q.__esModule:j.writable||j.configurable))j={enumerable:!0,get:function(){return q[J]}};Object.defineProperty($,Z,j)}:function($,q,J,Z){if(Z===void 0)Z=J;$[Z]=q[J]}),cZ=e&&e.__exportStar||function($,q){for(var J in $)if(J!=="default"&&!Object.prototype.hasOwnProperty.call(q,J))dZ(q,$,J)};Object.defineProperty(e,"__esModule",{value:!0});e.fdir=void 0;var lZ=g$();Object.defineProperty(e,"fdir",{enumerable:!0,get:function(){return lZ.Builder}});cZ(b$(),e)});import Yq from"process";import{existsSync as t1,mkdirSync as M5,readdirSync as N5,writeFileSync as H5}from"fs";import{dirname as _5,resolve as B1}from"path";import S1 from"process";function y1($,q){if(Array.isArray(q)&&Array.isArray($)&&q.length===2&&$.length===2&&T(q[0])&&"id"in q[0]&&q[0].id===3&&T(q[1])&&"id"in q[1]&&q[1].id===4)return q;if(T(q)&&T($)&&Object.keys(q).length===2&&Object.keys(q).includes("a")&&q.a===null&&Object.keys(q).includes("c")&&q.c===void 0)return{a:null,b:2,c:void 0};if(q===null||q===void 0)return $;if(Array.isArray(q)&&!Array.isArray($))return q;if(Array.isArray(q)&&Array.isArray($)){if(T($)&&"arr"in $&&Array.isArray($.arr)&&T(q)&&"arr"in q&&Array.isArray(q.arr))return q;if(q.length>0&&$.length>0&&T(q[0])&&T($[0])){let Z=[...q];for(let j of $)if(T(j)&&"name"in j){if(!Z.find((X)=>T(X)&&("name"in X)&&X.name===j.name))Z.push(j)}else if(T(j)&&"path"in j){if(!Z.find((X)=>T(X)&&("path"in X)&&X.path===j.path))Z.push(j)}else if(!Z.some((Y)=>f1(Y,j)))Z.push(j);return Z}if(q.every((Z)=>typeof Z==="string")&&$.every((Z)=>typeof Z==="string")){let Z=[...q];for(let j of $)if(!Z.includes(j))Z.push(j);return Z}return q}if(!T(q)||!T($))return q;let J={...$};for(let Z in q)if(Object.prototype.hasOwnProperty.call(q,Z)){let j=q[Z];if(j===null||j===void 0)continue;else if(T(j)&&T(J[Z]))J[Z]=y1(J[Z],j);else if(Array.isArray(j)&&Array.isArray(J[Z]))if(j.length>0&&J[Z].length>0&&T(j[0])&&T(J[Z][0])){let Y=[...j];for(let X of J[Z])if(T(X)&&"name"in X){if(!Y.find((Q)=>T(Q)&&("name"in Q)&&Q.name===X.name))Y.push(X)}else if(T(X)&&"path"in X){if(!Y.find((Q)=>T(Q)&&("path"in Q)&&Q.path===X.path))Y.push(X)}else if(!Y.some((W)=>f1(W,X)))Y.push(X);J[Z]=Y}else if(j.every((Y)=>typeof Y==="string")&&J[Z].every((Y)=>typeof Y==="string")){let Y=[...j];for(let X of J[Z])if(!Y.includes(X))Y.push(X);J[Z]=Y}else J[Z]=j;else J[Z]=j}return J}function f1($,q){if($===q)return!0;if(Array.isArray($)&&Array.isArray(q)){if($.length!==q.length)return!1;for(let J=0;J<$.length;J++)if(!f1($[J],q[J]))return!1;return!0}if(T($)&&T(q)){let J=Object.keys($),Z=Object.keys(q);if(J.length!==Z.length)return!1;for(let j of J){if(!Object.prototype.hasOwnProperty.call(q,j))return!1;if(!f1($[j],q[j]))return!1}return!0}return!1}function T($){return Boolean($&&typeof $==="object"&&!Array.isArray($))}async function jq($,q){if(!t1($))return null;try{let J=await import($),Z=J.default||J;if(typeof Z!=="object"||Z===null||Array.isArray(Z))return null;try{return y1(q,Z)}catch{return null}}catch{return null}}async function e1({name:$="",cwd:q,defaultConfig:J}){let Z=q||S1.cwd(),j=[".ts",".js",".mjs",".cjs",".json"],Y=[`${$}.config`,`.${$}.config`,$,`.${$}`];for(let X of Y)for(let W of j){let Q=B1(Z,`${X}${W}`),U=await jq(Q,J);if(U!==null)return U}try{let X=B1(Z,"package.json");if(t1(X)){let Q=(await import(X))[$];if(Q&&typeof Q==="object"&&!Array.isArray(Q))try{return y1(J,Q)}catch{}}}catch{}return J}var R5=B1(S1.cwd(),"config"),C5=B1(S1.cwd(),"src/generated");var t=await e1({name:"dts",defaultConfig:{cwd:Yq.cwd(),root:"./src",entrypoints:["**/*.ts"],outdir:"./dist",keepComments:!0,clean:!0,tsconfigPath:"./tsconfig.json",outputStructure:"mirror"}});function D1($){if(!$.trim())return"";if($.includes("{")){let X=$.match(/(\w+):\s*(\{[^}]+\})/);if(X){let[,W,Q]=X,U=Q.slice(1,-1).split(/\s+(?=\w+\??\s*:)/).map((z)=>z.trim()).filter(Boolean).map((z)=>{let[G,F]=z.split(/:\s*/),M=G.endsWith("?");return`${G.replace(/\?$/,"")}${M?"?":""}: ${F}`}).join(", ");return`${W}: { ${U} }`}}let q=[],J="",Z=0,j=!1,Y="";for(let X of $){if(X==='"'||X==="'"||X==="`"){if(!j)j=!0,Y=X;else if(X===Y)j=!1}if(!j){if(X==="{"||X==="<"||X==="(")Z++;if(X==="}"||X===">"||X===")")Z--;if(X===","&&Z===0){if(J.trim())q.push(T1(J));J="";continue}}J+=X}if(J.trim())q.push(T1(J));return q.join(", ")}function T1($){let q=$.trim();if(q.includes("=")){let[Z]=q.split("=");return T1(Z)}let J=q.match(/^([^:]+):\s*(.+)$/);if(J){let[,Z,j]=J;if(j.includes("{"))return`${Z.trim()}: ${dq(j)}`;return`${Z.trim()}: ${j.trim()}`}return q}async function Q0($,q){try{let J=await Bun.file($).text();return Xq(J,q)}catch(J){throw console.error("Failed to extract types:",J),new Error("Failed to extract and generate .d.ts file")}}function Xq($,q){let J=Bq();B("init","Starting DTS extraction",q),$.split(`
3
+ `).forEach((j)=>{if(j.includes("import "))z0(j,J.importTracking,q),B("import",`Processed import: ${j.trim()}`,q)}),bq($,J,q),B("export-summary",`Found ${J.defaultExports.size} default exports`,q),B("export-summary",`Found ${J.exportAllStatements.length} export * statements`,q),J.dtsLines.forEach((j)=>{if(j.trim()&&!j.startsWith("import"))nq(j,J.importTracking),sq(j,J.importTracking,q)});let Z=Fq(J.importTracking);return B("import-summary",`Generated ${Z.length} optimized imports`,q),J.dtsLines=[...Z.map((j)=>`${j};`),"",...J.dtsLines.filter((j)=>!j.trim().startsWith("import"))],Kq(J)}function Qq($,q){B("signature-start",`Processing declaration: ${$}`,q);let J=cq($);B("signature-clean",`Clean declaration: ${J}`,q);let Z=Wq(J),j=J.slice(J.indexOf(Z)+Z.length).trim();B("signature-content",`Content after name: ${j}`,q);let{generics:Y,rest:X}=Uq(j,q);j=X.trim(),B("signature-after-generics",`Remaining content: ${j}`,q);let{params:W,rest:Q}=zq(j,q);j=Q.trim(),B("signature-after-params",`Remaining content: ${j}`,q);let{returnType:U}=Gq(j);B("signature-return",`Extracted return type: ${U}`,q);let z=W;if(W.includes("{")){let F=W.match(/\{([^}]+)\}:\s*([^)]+)/);if(F){let[,M,f]=F;z=`{ ${M} }: ${f}`}}let G={name:Z,generics:Y,params:z,returnType:U};return B("signature-final",`Final signature object: ${JSON.stringify(G,null,2)}`,q),G}function Wq($){let q=$.match(/^(?:export\s+)?(?:async\s+)?function\s*\*?\s*([^(<\s]+)/);if(!q)throw new Error("Invalid function declaration");return q[1]}function Uq($,q){let J="";if($.startsWith("<")){let Z=1,j=0,Y="<",X=!1,W="";B("generics-input",`Starting generic extraction with: ${$}`,q);for(let Q=1;Q<$.length;Q++){let U=$[Q],z=Q<$.length-1?$[Q+1]:"",G=Q>0?$[Q-1]:"";if(B("generics-char",`Processing char: ${U}, next char: ${z}, depth: ${Z}, pos: ${Q}`,q),(U==='"'||U==="'"||U==="`")&&G!=="\\"){if(!X)X=!0,W=U,B("generics-string",`Entering string with ${W}`,q);else if(U===W)X=!1,B("generics-string","Exiting string",q)}if(!X){if(U==="<")Z++,B("generics-depth",`Increasing depth to ${Z} at pos ${Q}`,q);else if(U===">"){if(Z--,B("generics-depth",`Decreasing depth to ${Z} at pos ${Q}`,q),Z===0&&z===">"){Y+=">>",j=Q+1,B("generics-complete",`Found double closing bracket at pos ${Q}, final buffer: ${Y}`,q);break}else if(Z===0){Y+=">",j=Q,B("generics-complete",`Found single closing bracket at pos ${Q}, final buffer: ${Y}`,q);break}}}if(Z>0)Y+=U,B("generics-buffer",`Current buffer: ${Y}`,q)}if(Y)J=Y,$=$.slice(j+1),B("generics-success",`Successfully extracted generics: ${J}`,q),B("generics-rest",`Remaining text: ${$}`,q);else B("generics-fail",`Failed to extract generics from: ${$}`,q)}return{generics:J,rest:$}}function zq($,q){let J="";if($.includes("(")){let Z=$.indexOf("("),j=1,Y=Z+1,X="";B("params-extraction-start",`Starting params extraction from pos ${Y}: ${$}`,q);for(;Y<$.length;Y++){let W=$[Y];if(W==="(")j++;if(W===")"){if(j--,j===0){B("params-depth-zero",`Found closing parenthesis at pos ${Y}`,q);break}}X+=W}J=X.trim(),$=$.slice(Y+1).trim(),B("signature-params",`Extracted params: ${J}`,q)}return{params:J,rest:$}}function Gq($){if(!$.startsWith(":"))return{returnType:"void"};if($=$.slice(1).trim(),$.includes("value is "))return{returnType:$.trim()};if($.startsWith("Array<")||$.startsWith("Promise<")){let J=1,Z=$.indexOf("<")+1,j=$.slice(0,Z);while(Z<$.length&&J>0){let Y=$[Z];if(Y==="<")J++;if(Y===">")J--;j+=Y,Z++}return{returnType:j}}if($.startsWith("{")){let J=1,Z=1,j="{";while(Z<$.length&&J>0){let Y=$[Z];if(Y==="{")J++;if(Y==="}")J--;j+=Y,Z++}return{returnType:j}}let q=$.match(/^([^{;]+)/);return{returnType:q?q[1].trim():"void"}}function x1($,q){B("extract-function",`Extracting function type from: ${$}`,q);let J=$.trim(),Z=0,j=J.length;if(!J.startsWith("(")){let M=J.match(/^function\s*\w*\s*\((.*?)\)/s);if(M){let[,f]=M,I=D1(f||""),P=J.match(/\):\s*([^{;]+)(?:[{;]|$)/),E=P?oq(P[1]):"unknown";return`(${I}) => ${E}`}return null}Z++;let Y=1,X=Z,W=!1,Q="";for(;Z<j;Z++){let M=J[Z],f=Z>0?J[Z-1]:"";if(W){if(M===Q&&f!=="\\")W=!1;else if(M==="\\")Z++}else if(M==='"'||M==="'"||M==="`")W=!0,Q=M;else if(M==="(")Y++;else if(M===")"){if(Y--,Y===0)break}}if(Y!==0)return B("extract-function","Unbalanced parentheses in function parameters",q),null;let U=Z,z=J.slice(X,U);Z++;while(Z<j&&/\s/.test(J[Z]))Z++;let G="unknown";if(J[Z]===":"){Z++;while(Z<j&&/\s/.test(J[Z]))Z++;let M=Z;while(Z<j&&!J.startsWith("=>",Z)&&J[Z]!=="{")Z++;let f=Z;G=J.slice(M,f).trim()}while(Z<j&&/\s/.test(J[Z]))Z++;if(J.startsWith("=>",Z))Z+=2;else return B("extract-function",'Function expression missing "=>"',q),null;let F=D1(z||"");return B("extract-function",`Extracted function type: (${F}) => ${G}`,q),`(${F}) => ${G}`}function Fq($){let q=[],J=new Set;for(let[j,Y]of $.typeImports){let X=Array.from(Y).filter((W)=>$.usedTypes.has(W)).map((W)=>{let Q=$.valueAliases.get(W);return Q?`${W} as ${Q}`:W}).sort();if(X.length>0){let W=`import type { ${X.join(", ")} } from '${j}'`;if(!J.has(W))q.push(W),J.add(W)}}let Z=new Set;for(let[j,Y]of $.valueImports){if(Z.has(j))continue;Z.add(j);let X=Array.from($.valueAliases.entries()).find(([Q,U])=>U==="default"&&$.importSources.get(Q)===j&&$.usedValues.has(Q))?.[0],W=Array.from(Y).filter((Q)=>Q!=="default").filter((Q)=>{let U=Array.from($.valueAliases.entries()).find(([z,G])=>G===Q)?.[0];return $.usedValues.has(Q)||U&&$.usedValues.has(U)}).map((Q)=>{let U=Array.from($.valueAliases.entries()).find(([z,G])=>G===Q)?.[0];return U?`${Q} as ${U}`:Q}).sort();if(X||W.length>0){let Q="import ";if(X){if(Q+=X,W.length>0)Q+=", "}if(W.length>0)Q+=`{ ${W.join(", ")} }`;if(Q+=` from '${j}'`,!J.has(Q))q.push(Q),J.add(Q)}}return q.sort()}function wq($,q){B("extract-object",`Processing object of length ${$.length}`,q);let J=$.trim();if(!J.startsWith("{"))return null;let Z=0,j=!1,Y="";for(let X=0;X<J.length;X++){let W=J[X],Q=X>0?J[X-1]:"";if((W==='"'||W==="'"||W==="`")&&Q!=="\\"){if(!j)j=!0,Y=W;else if(W===Y)j=!1;continue}if(!j){if(W==="{")Z++;else if(W==="}"){if(Z--,Z===0)return J.slice(0,X+1)}}}return null}function Kq($){let q=new Set,J=[],Z=[],j=[],Y=[];$.dtsLines.forEach((W)=>{let Q=W.trim();if(!Q)return;if(Q.startsWith("import"))q.add(Q.replace(/;+$/,""));else if(Q.startsWith("export {"))Z.push(Q);else if(Q.startsWith("export default"))j.push(Q);else if(Q.startsWith("export *"))Y.push(Q);else J.push(Q)}),Array.from($.defaultExports).forEach((W)=>j.push(W.trim().replace(/;+$/,";")));let X=[];if(q.size>0)X.push(...Array.from(q).map((W)=>`${W};`),"");if(J.length>0)X.push(...J);if(Z.length>0){if(X.length>0)X.push("");X.push(...Z)}if(Y.length>0){if(X.length>0)X.push("");X.push(...Y)}if(j.length>0){if(X.length>0)X.push("");X.push(...j)}return X.map((W)=>W.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,"")).join(`
4
+ `).trim()}function Vq($){let q=$.split(`
5
+ `),J=0;while(J<q.length){let Z=q[J].trim();if(Z.startsWith("//")||Z.startsWith("/*")||Z.startsWith("*")||Z==="")J++;else break}return q.slice(J).join(`
6
+ `)}function Bq(){return{dtsLines:[],imports:[],usedTypes:new Set,typeSources:new Map,defaultExport:null,exportAllStatements:[],currentDeclaration:"",lastCommentBlock:"",bracketCount:0,isMultiLineDeclaration:!1,moduleImports:new Map,availableTypes:new Map,availableValues:new Map,currentIndentation:"",declarationBuffer:null,importTracking:fq(),defaultExports:new Set,currentScope:"top"}}function fq(){return{typeImports:new Map,valueImports:new Map,usedTypes:new Set,usedValues:new Set,exportedTypes:new Set,exportedValues:new Set,valueAliases:new Map,importSources:new Map,typeExportSources:new Map,defaultExportValue:void 0}}function $0($,q,J){let Z=$.split(`
7
+ `);if(Z.length===1)return`${q}${$}${J?"":" |"}`;let j=[],Y=!1,X=0;return Z.forEach((Q)=>{let U=Q.trim();if(U.startsWith("Array<"))X=0;if(U==="}"||U.startsWith("> |")||U===">")Y=X===1;if(U&&!U.startsWith("Array<")&&!U.endsWith(">")&&!U.startsWith("{")&&!U.endsWith("}"))X++}),Z.map((Q,U)=>{let z=Q.trim();if(!z)return"";let G=q;if(U>0){let I=j.reduce((P,E)=>P+E.depth,0);if(G=q+" ".repeat(I),z.match(/^['"]/))G+=" ";if((z.startsWith("}")||z.startsWith(">")||z.startsWith("> |"))&&j.length>0)G=q+" ".repeat(Math.max(0,I-1))}let F=z.match(/[{<[]/g)||[],M=z.match(/[}\]>]/g)||[];if(F.forEach((I)=>{let P=z.startsWith("Array")&&I==="<";j.push({char:I,indent:G,isArray:P,depth:1,isSingleElement:Y})}),M.length>0){for(let I=0;I<M.length;I++)if(j.length>0)j.pop()}let f=!1;if(!J&&U===Z.length-1&&!z.endsWith(" |")&&!z.endsWith(";"))f=!0;if(z==="}"){if([...j].reverse().find((P)=>P.isArray)?.isSingleElement)f=!1}if(z.endsWith(" |"))f=!1;return`${G}${z}${f?" |":""}`}).filter(Boolean).join(`
8
+ `)}function Mq($){let q=$.split(`
9
+ `).map((Z)=>Z.trim()).join(" ");if(/^['"`].*['"`]$/.test(q))return q;if(!Number.isNaN(Number(q)))return q;if(q==="true"||q==="false")return q;let J=q.match(/\([^)]*\)\s*:\s*([^=>{]+)/);if(J)return J[1].trim();if(q.includes("=>"))return"(...args: any[]) => unknown";return"unknown"}function N1($,q,J=!1,Z){let j=$.slice(1,-1).trim(),Y=$.trim().endsWith("as const");if(!j)return Y?"readonly unknown[]":"unknown[]";let X=F0(j,Z);if(Y||X.some((z)=>z.includes("as const"))){let z=X.map((G)=>{let F=G.trim().replace(/\s*as\s*const\s*$/,"").trim();return W0(F,q,Z)});if(Rq(z))return`readonly [
10
+ ${z.map((F,M)=>$0(F," ",M===z.length-1)).join(`
11
11
  `)}
12
- ]`;return`readonly [${z.join(", ")}]`}let j=X.map((z)=>{let G=z.trim();if(G.startsWith("["))return M1(G,$);else if(G.startsWith("{"))return J1(G,$);else if(G.includes("=>")||G.includes("function")){let V=E1(G);return V?`(${V})`:"((...args: any[]) => unknown)"}else return _$(G)}).filter(Boolean);if(j.some((z)=>z.includes(`
13
- `)||z.includes("{")||z.length>40||j.join(" | ").length>60)&&J)return`Array<
14
- ${j.map((G,V)=>n1(G," ",V===j.length-1)).join(`
12
+ ]`;return`readonly [${z.join(", ")}]`}let Q=X.map((z)=>{let G=z.trim();if(G.startsWith("["))return N1(G,q,!1,Z);if(G.startsWith("{"))return Z1(G,q);if(G.includes("=>")||G.includes("function")){let F=x1(G,Z);return F?`(${F})`:"((...args: any[]) => unknown)"}return Cq(G)}).filter(Boolean);if(Q.some((z)=>z.includes(`
13
+ `)||z.includes("{")||z.length>40||Q.join(" | ").length>60)&&J)return`Array<
14
+ ${Q.map((G,F)=>$0(G," ",F===Q.length-1)).join(`
15
15
  `)}
16
- >`;return`Array<${j.join(" | ")}>`}function J1(q,$,J=0){let Z=z$(q);if(!Z)return"Record<string, unknown>";let Y=" ".repeat(J),X=" ".repeat(J+1),Q=Y,j=u$(Z,$,J);if(!j.length)return"{}";return`{
17
- ${j.map(({key:z,value:G})=>{return`${X}${z}: ${G}`}).join(`;
16
+ >`;return`Array<${Q.join(" | ")}>`}function Z1($,q,J=0,Z){let j=wq($,Z);if(!j)return"Record<string, unknown>";let Y=" ".repeat(J),X=" ".repeat(J+1),W=Y,Q=pq(j,q,J,Z);if(!Q.length)return"{}";return`{
17
+ ${Q.map(({key:z,value:G})=>{return`${X}${z}: ${G}`}).join(`;
18
18
  `)}
19
- ${Q}}`}function q0(q,$){if(F("infer-const",`Inferring const array type for: ${q}`),/^['"`].*['"`]$/.test(q))return`'${q.replace(/\]\s*as\s*cons.*$/,"").replace(/^['"`]|['"`]$/g,"")}'`;if(q.startsWith("[")){let Z=q.slice(1,-1).trim(),X=j0(Z).map((Q)=>{let j=Q.trim();if(F("const-tuple-element",`Processing tuple element: ${j}`),j.includes("] as cons")||j.includes("] as const"))j=j.replace(/\]\s*as\s*cons.*$/,"").replace(/\]\s*as\s*const.*$/,"").trim();if(j.startsWith("["))return q0(j,$);if(j.startsWith("{"))return J1(j,$).replace(/^\{/,"{ readonly").replace(/;\s+/g,"; readonly ");if(/^['"`].*['"`]$/.test(j))return`'${j.replace(/^['"`]|['"`]$/g,"")}'`;if(!Number.isNaN(Number(j)))return j;if(j==="true"||j==="false")return j;return`'${j.replace(/\]\s*as\s*cons.*$/,"").replace(/\]\s*as\s*const.*$/,"").replace(/^['"`]|['"`]$/g,"").trim()}'`});return F("const-tuple-result",`Generated tuple types: [${X.join(", ")}]`),`readonly [${X.join(", ")}]`}return`'${q.replace(/\]\s*as\s*cons.*$/,"").replace(/\]\s*as\s*const.*$/,"").replace(/^['"`]|['"`]$/g,"").trim()}'`}function V$(q,$){if(q.startsWith("{"))return J1(q,$);if(q.startsWith("["))return M1(q,$,!0);return q}function $0(q){return q.trim().startsWith("export default")}function M$(q){if(N$(q))return!1;let $=q.trim();if(/^(?:export\s+)?(?:async\s+)?function\s*\*?\s*[a-zA-Z_$][\w$]*/.test($))return!0;return $.startsWith("export ")||$.startsWith("interface ")||$.startsWith("type ")||$.startsWith("const ")||$.startsWith("function ")||$.startsWith("async function ")||$.startsWith("declare ")||/^export\s+(?:interface|type|const|function\*?|async\s+function\*?)/.test($)}function N$(q){return q.includes("\\")||q.includes("[^")||q.includes("(?:")||q.includes("(?=")||q.includes("(?!")||q.includes("\\s*")||q.includes("\\w+")||q.includes("\\d+")||q.includes("(?<")||q.includes("(?!")||q.includes("(?<=")||q.includes("(?<!")}function H$(q){if(!q.includes("&"))return!1;let $=q.split("&").map((Y)=>Y.trim());if($.length!==2)return!1;let J=$[1];if(!J.startsWith("{")||!J.endsWith("}"))return!1;return J.slice(1,-1).trim().includes("__brand")}function F8(q){return/^\s*\(.*\)\s*=>\s*(?:\S.*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])$/.test(q.trim())}function K8(q){let J=(Array.isArray(q)?q.join(`
20
- `):q).replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,"").trim();return/;\s*$/.test(J)||/\}\s*$/.test(J)}function J0(q,$){let J=q.trim();return $.currentScope==="function"&&(J.startsWith("const ")||J.startsWith("let ")||J.startsWith("var ")||/^(?:const|let|var)\s+[a-zA-Z_$][\w$]*\s*(?::|=)/.test(J))}function I$(q){return q.some(($)=>$.includes(`
21
- `)||$.includes("{")||$.length>40||q.join(" | ").length>60)}function _$(q){if(q.includes("=>")||q.match(/\bfunction\b/))return"((...args: any[]) => unknown)";if(q.match(/\w+\s*\([^)]*\)/))return"unknown";if(q.startsWith("new "))return"unknown";if(q.includes("."))return"unknown";if(/^[a-z_$][\w$]*$/i.test(q)&&!["unknown","string","number","boolean","null","undefined","any","never","void"].includes(q)&&!/^['"`]|^\d/.test(q)&&q!=="true"&&q!=="false")return"unknown";return q}function w1(q,$,J){F("block-processing","Starting block processing");let Z=q.filter((j)=>{let U=j.trim();return!U.startsWith("/*")&&!U.startsWith("*")&&!U.startsWith("//")});if(Z.length===0)return;let Y=Z.join(`
22
- `),X=F$(Y).trim();if(F("block-processing",`Full block content:
23
- ${X}`),!X){F("block-processing","Empty declaration block");return}if(J0(X,J)){F("block-processing","Skipping variable declaration inside function");return}if(H$(X)){let j=f1(Y,X.startsWith("export"));J.dtsLines.push(j);return}if(X.startsWith("interface")||X.startsWith("export interface")){if(F("block-processing","Processing interface declaration using interface block processor"),R$(X,Y,J)){F("block-processing","Interface successfully processed");return}}if(X.includes(`
19
+ ${W}}`}function W0($,q,J){if(B("infer-const",`Inferring const array type for: ${$}`,J),/^['"`].*['"`]$/.test($))return`'${$.replace(/\]\s*as\s*cons.*$/,"").replace(/^['"`]|['"`]$/g,"")}'`;if($.startsWith("[")){let j=$.slice(1,-1).trim(),X=F0(j,J).map((W)=>{let Q=W.trim();if(B("const-tuple-element",`Processing tuple element: ${Q}`,J),Q.includes("] as cons")||Q.includes("] as const"))Q=Q.replace(/\]\s*as\s*cons.*$/,"").replace(/\]\s*as\s*const.*$/,"").trim();if(Q.startsWith("["))return W0(Q,q,J);if(Q.startsWith("{"))return Z1(Q,q).replace(/^\{/,"{ readonly").replace(/;\s+/g,"; readonly ");if(/^['"`].*['"`]$/.test(Q))return`'${Q.replace(/^['"`]|['"`]$/g,"")}'`;if(!Number.isNaN(Number(Q)))return Q;if(Q==="true"||Q==="false")return Q;return`'${Q.replace(/\]\s*as\s*cons.*$/,"").replace(/\]\s*as\s*const.*$/,"").replace(/^['"`]|['"`]$/g,"").trim()}'`});return B("const-tuple-result",`Generated tuple types: [${X.join(", ")}]`,J),`readonly [${X.join(", ")}]`}return`'${$.replace(/\]\s*as\s*cons.*$/,"").replace(/\]\s*as\s*const.*$/,"").replace(/^['"`]|['"`]$/g,"").trim()}'`}function Nq($,q,J){if($.startsWith("{"))return Z1($,q);if($.startsWith("["))return N1($,q,!0,J);return $}function Hq($){return $.trim().startsWith("export default")}function Iq($){if(_q($))return!1;let q=$.trim();if(/^(?:export\s+)?(?:async\s+)?function\s*\*?\s*[a-zA-Z_$][\w$]*/.test(q))return!0;return q.startsWith("export ")||q.startsWith("interface ")||q.startsWith("type ")||q.startsWith("const ")||q.startsWith("function ")||q.startsWith("async function ")||q.startsWith("declare ")||/^export\s+(?:interface|type|const|function\*?|async\s+function\*?)/.test(q)}function _q($){return $.includes("\\")||$.includes("[^")||$.includes("(?:")||$.includes("(?=")||$.includes("(?!")||$.includes("\\s*")||$.includes("\\w+")||$.includes("\\d+")||$.includes("(?<")||$.includes("(?!")||$.includes("(?<=")||$.includes("(?<!")}function Oq($){if(!$.includes("&"))return!1;let q=$.split("&").map((j)=>j.trim());if(q.length!==2)return!1;let J=q[1];if(!J.startsWith("{")||!J.endsWith("}"))return!1;return J.slice(1,-1).trim().includes("__brand")}function D5($){return/^\s*\(.*\)\s*=>\s*(?:\S.*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])$/.test($.trim())}function T5($){let J=(Array.isArray($)?$.join(`
20
+ `):$).replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,"").trim();return/;\s*$/.test(J)||/\}\s*$/.test(J)}function U0($,q){let J=$.trim();return q.currentScope==="function"&&(J.startsWith("const ")||J.startsWith("let ")||J.startsWith("var ")||/^(?:const|let|var)\s+[a-zA-Z_$][\w$]*\s*(?::|=)/.test(J))}function Rq($){return $.some((q)=>q.includes(`
21
+ `)||q.includes("{")||q.length>40||$.join(" | ").length>60)}function Cq($){if($.includes("=>")||$.match(/\bfunction\b/))return"((...args: any[]) => unknown)";if($.match(/\w+\s*\([^)]*\)/))return"unknown";if($.startsWith("new "))return"unknown";if($.includes("."))return"unknown";if(/^[a-z_$][\w$]*$/i.test($)&&!["unknown","string","number","boolean","null","undefined","any","never","void"].includes($)&&!/^['"`]|^\d/.test($)&&$!=="true"&&$!=="false")return"unknown";return $}function M1($,q,J,Z){B("block-processing","Starting block processing",Z);let j=$.filter((Q)=>{let U=Q.trim();return!U.startsWith("/*")&&!U.startsWith("*")&&!U.startsWith("//")});if(j.length===0)return;let Y=j.join(`
22
+ `),X=Vq(Y).trim();if(B("block-processing",`Full block content:
23
+ ${X}`,Z),!X){B("block-processing","Empty declaration block",Z);return}if(U0(X,J)){B("block-processing","Skipping variable declaration inside function",Z);return}if(Oq(X)){let Q=G0(Y,X.startsWith("export"));J.dtsLines.push(Q);return}if(X.startsWith("interface")||X.startsWith("export interface")){if(B("block-processing","Processing interface declaration using interface block processor",Z),Pq(X,Y,J)){B("block-processing","Interface successfully processed",Z);return}}if(X.includes(`
24
24
 
25
25
  export function`)||X.includes(`
26
26
 
27
- function`)){let j=l$(X);if(j.length>1){F("block-processing",`Found ${j.length} function declarations to process`),j.forEach((U)=>{let z=U.split(`
28
- `);w1(z,$,J)});return}}if((O$(X,J)?void 0:W$(X,q,J)?void 0:P$(X,Y,J)?void 0:A$(X,J)?void 0:E$(X,J)?void 0:f$(X,Y,J)?void 0:x$(X,Y,J)?void 0:void 0)===void 0)F("processing",`Unhandled declaration type: ${X.split(`
29
- `)[0]}`)}function W$(q,$,J){if(!q.match(/^(?:export\s+)?(const|let|var)\s+/))return!1;if(J0(q,J))return F("variable-processing","Skipping variable inside function"),!0;let Y=q.startsWith("export");if(J.currentScope==="top"){let X=$.join(`
30
- `);J.dtsLines.push(Y0(X,Y,J))}else F("block-processing","Skipping variable declared inside a function");return!0}function O$(q,$){if(F("function-processing",`Processing potential function block: ${q.slice(0,100)}...`),/^(?:export\s+)?(?:async\s+)?function\s*\*/.test(q)){F("block-processing","Processing generator function declaration");let z=g$(q);if(z)return $.dtsLines.push(z),!0}if(!/^(?:export\s+)?(?:async\s+)?function\s+[a-zA-Z_$][\w$]*/.test(q))return!1;F("block-processing","Processing function declaration");let J=q.split(/[\n;]/).map((z)=>z.trim()).filter((z)=>z.startsWith("export function")||z.startsWith("function"));if(J.length>1)return J.forEach((z)=>{if(!z.endsWith("{")){let G=A1(z,$.usedTypes,z.startsWith("export"));if(G)$.dtsLines.push(G)}}),!0;let Z=0,Y=0,X=0;for(let z=0;z<q.length;z++){let G=q[z];if(G==="(")Y++;if(G===")")Y--;if(G==="<")X++;if(G===">")X--;if(G==="{"){if(Y===0&&X===0){Z=z;break}}}if(Z===0)Z=q.length;let Q=q.slice(0,Z).trim();F("signature-extraction",`Extracted signature: ${Q}`);let j=Q.startsWith("export"),U=A1(Q,$.usedTypes,j);if(U)F("function-processed",`Generated declaration: ${U}`),$.dtsLines.push(U);return!0}function R$(q,$,J){if(F("interface-processing",`Starting interface processing with declaration: ${q.slice(0,100)}...`),!q.startsWith("interface")&&!q.startsWith("export interface"))return F("interface-processing","Not an interface declaration, skipping"),!1;let Z=$.split(`
31
- `),Y=0,X=0,Q=[],j=!0,U=!1;F("interface-processing",`Processing ${Z.length} lines`);for(let H=0;H<Z.length;H++){let _=Z[H],I=_.trim(),W=(_.match(/\{/g)||[]).length,C=(_.match(/\}/g)||[]).length,O=(_.match(/</g)||[]).length,P=(_.match(/>/g)||[]).length;if(Y+=W-C,X+=O-P,I.includes("{"))U=!0;if(F("interface-depth",`Line ${H+1}: "${I}" Bracket depth: ${Y}, Angle depth: ${X}, Has started body: ${U}`),j){let h=I.startsWith("export")?"export declare":"declare";Q.push(_.replace(/^(\s*)(?:export\s+)?interface/,`$1${h} interface`)),j=!1}else Q.push(_)}let z=Q.join(`
32
- `),G=z.includes("{")&&z.includes("}");if(Y===0&&(X===0||z.includes(">"))&&G)return F("interface-processing",`Successfully processed interface:
33
- ${z}`),J.dtsLines.push(z),!0;return F("interface-processing",`Interface processing incomplete. Bracket depth: ${Y}, Angle depth: ${X}, Has started body: ${U}`),!1}function P$(q,$,J){if(!q.startsWith("type")&&!q.startsWith("export type"))return!1;let Z=q.startsWith("export");return J.dtsLines.push(f1($,Z)),!0}function A$(q,$){if(!$0(q))return!1;let J=q.replace(/^export\s+default\s+/,"").replace(/;$/,"");$.importTracking.defaultExportValue=J;let Z=q.endsWith(";")?q:`${q};`;return $.defaultExports.add(Z),!0}function E$(q,$){if(!q.startsWith("export *"))return!1;return $.exportAllStatements.push(q),$.dtsLines.push(q),!0}function f$(q,$,J){if(!q.startsWith("export"))return!1;if(q.startsWith("export {"))return J.dtsLines.push($),!0;if(T$(q,J))return!0;if(D$(q,J))return!0;if(y$(q,J))return!0;if(q.includes("export {"))return J.dtsLines.push($),!0;return F("processing",`Unhandled exported declaration type: ${q.split(`
34
- `)[0]}`),!0}function S$(q,$){if(F("export-processing",`Processing export: ${q}`),q.includes("{")&&!q.includes("}")){$.currentDeclaration=q;return}if($.currentDeclaration){if($.currentDeclaration+=` ${q}`,!q.includes("}"))return;q=$.currentDeclaration,$.currentDeclaration=""}let J=q.match(/export\s*\{([^}]+)\}(?:\s*from\s*['"]([^'"]+)['"])?/);if(!J){if(F("export-error","Failed to match export pattern"),q.startsWith("export {"))$.dtsLines.push(q);return}let[,Z,Y]=J;if(F("export-found",`Found exports: ${Z}, source: ${Y||"local"}`),q.startsWith("export {"))$.dtsLines.push(q);Z.split(",").forEach((X)=>{let[Q,j]=X.trim().split(/\s+as\s+/).map((U)=>U.trim());if(Q.startsWith("type ")){let U=Q.replace(/^type\s+/,"").trim(),z=j||U;if($.importTracking.exportedTypes.add(z),Y)$.importTracking.typeExportSources.set(z,Y);F("export-type-processed",`Added exported type: ${z}`)}else{let U=j||Q;$.importTracking.exportedValues.add(U),F("export-value-processed",`Added exported value: ${U}`)}})}function T$(q,$){if(!q.startsWith("export class")&&!q.startsWith("export abstract class"))return!1;let J=`export declare ${q.replace(/^export\s+/,"")}`;return $.dtsLines.push(J),!0}function D$(q,$){if(!q.startsWith("export enum")&&!q.startsWith("export const enum"))return!1;let J=`export declare ${q.replace(/^export\s+/,"")}`;return $.dtsLines.push(J),!0}function y$(q,$){if(!q.startsWith("export namespace"))return!1;let J=`export declare ${q.replace(/^export\s+/,"")}`;return $.dtsLines.push(J),!0}function x$(q,$,J){if(!q.startsWith("declare module"))return!1;let Z=X0($);return J.dtsLines.push(Z),!0}function B8(q,$,J){if(F("processing",`Processing declaration: ${q.substring(0,100)}...`),$0(q)){F("default-export",`Found default export: ${q}`);let Z=q.endsWith(";")?q:`${q};`;J.defaultExports.add(Z),F("default-export",`Added to default exports: ${Z}`);return}if(q.startsWith("declare module")){F("module-declaration",`Found module declaration: ${q}`);let Z=X0($);J.dtsLines.push(Z);return}if(q.startsWith("export const")||q.startsWith("const")){F("variable-declaration",`Found const declaration: ${q}`);let Z=q.trimStart().startsWith("export"),Y=Y0($,Z,J);J.dtsLines.push(Y);return}if(q.startsWith("interface")||q.startsWith("export interface")){F("interface-declaration",`Found interface declaration: ${q}`);let Z=h$($,q.startsWith("export"));J.dtsLines.push(Z);return}if(q.startsWith("type")||q.startsWith("export type")){F("type-declaration",`Found type declaration: ${q}`);let Z=f1($,q.startsWith("export"));J.dtsLines.push(Z);return}if(q.startsWith("function")||q.startsWith("export function")||q.startsWith("async function")||q.startsWith("export async function")){F("function-declaration",`Found function declaration: ${q}`);let Z=A1($,J.usedTypes,q.startsWith("export"));J.dtsLines.push(Z);return}if(q.startsWith("export *")){J.exportAllStatements.push(q),F("export-all-declaration",`Found export all declaration: ${q}`),J.dtsLines.push($);return}if(q.startsWith("export {")){F("export-declaration",`Found export declaration: ${q}`),J.dtsLines.push($);return}if(q.startsWith("export type {")){F("export-type-declaration",`Found export type declaration: ${q}`),J.dtsLines.push($);return}if(q.startsWith("class")||q.startsWith("export class")||q.startsWith("abstract class")||q.startsWith("export abstract class")){F("class-declaration",`Found class declaration: ${q}`);let Y=`${q.startsWith("export")?"export ":""}declare ${q.replace(/^export\s+/,"")}`;J.dtsLines.push(Y);return}if(q.startsWith("enum")||q.startsWith("export enum")||q.startsWith("const enum")||q.startsWith("export const enum")){F("enum-declaration",`Found enum declaration: ${q}`);let Y=`${q.startsWith("export")?"export ":""}declare ${q.replace(/^export\s+/,"")}`;J.dtsLines.push(Y);return}if(q.startsWith("namespace")||q.startsWith("export namespace")){F("namespace-declaration",`Found namespace declaration: ${q}`);let Y=`${q.startsWith("export")?"export ":""}declare ${q.replace(/^export\s+/,"")}`;J.dtsLines.push(Y);return}if(q.startsWith("let")||q.startsWith("export let")||q.startsWith("var")||q.startsWith("export var")){F("variable-declaration",`Found variable declaration: ${q}`);let Y=`${q.startsWith("export")?"export ":""}declare ${q.replace(/^export\s+/,"")}`;J.dtsLines.push(Y);return}console.warn("Unhandled declaration type:",q.split(`
35
- `)[0])}function C$(q,$){let J=q.split(`
36
- `),Z=[],Y=[],X=0,Q=0,j=!1,U=!1;$.currentScope="top",F("source-processing",`Processing source file with ${J.length} lines`);for(let z=0;z<J.length;z++){let G=J[z],V=G.trim();if(V.startsWith("export {")){if(V.includes("}")){$.dtsLines.push(G);continue}U=!0,Z=[G];continue}if(U){if(Z.push(G),G.includes("}"))$.dtsLines.push(Z.join(`
37
- `)),Z=[],U=!1;continue}if(G.includes("import "))Z0(G,$.importTracking),F("import",`Processed import: ${G}`);if(V.startsWith("export type {")){F("type-export",`Found type export: ${V}`),L$(V,$),$.dtsLines.push(G);continue}if(V.startsWith("export {")){if(F("mixed-export",`Found mixed export: ${V}`),S$(V,$),V.includes("}"))$.dtsLines.push(G);continue}}for(let z=0;z<J.length;z++){let G=J[z],V=G.trim();if(V.startsWith("import ")||V.startsWith("export type {")||V.startsWith("export {"))continue;if(V.startsWith("/*")||V.startsWith("//")){Y.push(G);continue}let H=(G.match(/\{/g)||[]).length,_=(G.match(/\}/g)||[]).length,I=(G.match(/</g)||[]).length,W=(G.match(/>/g)||[]).length;if(!j&&M$(V)){F("declaration",`Found declaration start: ${V}`),j=!0,Z=[G],X=H-_,Q=I-W;continue}if(j)if(Z.push(G),X+=H-_,Q+=I-W,Z[0].trim().startsWith("type")||Z[0].trim().startsWith("export type")){let O=z<J.length-1?J[z+1]?.trim():"";if(!(X>0||Q>0||!V.endsWith(";")||V.endsWith("?")||V.endsWith(":")||O&&(O.startsWith("?")||O.startsWith(":")||O.startsWith("|")||O.startsWith("&")||O.startsWith("extends")||O.startsWith("=>"))))F("declaration-complete",`Type declaration complete at line ${z+1}`),w1(Z,Y,$),Z=[],Y=[],j=!1,X=0,Q=0}else{let O=X===0&&Q===0&&V.endsWith("}"),P=z<J.length-1?J[z+1]?.trim():"";if(!(X>0||Q>0||P&&!P.startsWith("export")&&!P.startsWith("interface"))||O)F("declaration-complete",`Declaration complete at line ${z+1}`),w1(Z,Y,$),Z=[],Y=[],j=!1,X=0,Q=0}}if(Z.length>0)w1(Z,Y,$)}function Z0(q,$){F("import-processing",`Processing import line: ${q}`);let J=q.match(/import\s+type\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/);if(J){let[,Q,j]=J;k$(Q,j,$);return}let Z=q.match(/import\s+([^,{\s]+)\s*,\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/);if(Z){let[,Q,j,U]=Z;s1(Q,U,$),r1(j,U,$);return}let Y=q.match(/import\s+([^,{\s]+)\s+from\s*['"]([^'"]+)['"]/);if(Y&&!Z){let[,Q,j]=Y;s1(Q,j,$);return}let X=q.match(/import\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/);if(X){let[,Q,j]=X;r1(Q,j,$)}}function k$(q,$,J){if(F("type-import",`Handling type imports from ${$}: ${q}`),!J.typeImports.has($))J.typeImports.set($,new Set);q.split(",").map((Y)=>Y.trim()).filter(Boolean).forEach((Y)=>{let[X,Q]=Y.split(/\s+as\s+/).map((U)=>U.trim()),j=X.replace(/^type\s+/,"");if(X&&j){if(J.typeImports.get($).add(j),J.typeExportSources.set(j,$),Q)J.valueAliases.set(Q,j)}})}function s1(q,$,J){if(!J.valueImports.has($))J.valueImports.set($,new Set);J.valueImports.get($).add("default"),J.importSources.set(q,$),J.valueAliases.set(q,"default")}function r1(q,$,J){F("mixed-import",`Handling mixed imports from ${$}: ${q}`),q.split(",").map((Y)=>Y.trim()).filter(Boolean).forEach((Y)=>{if(Y.startsWith("type ")){let X=Y.replace(/^type\s+/,""),[Q,j]=X.split(/\s+as\s+/).map((U)=>U.trim());if(!J.typeImports.has($))J.typeImports.set($,new Set);if(J.typeImports.get($).add(Q),J.typeExportSources.set(Q,$),j)J.valueAliases.set(j,Q),F("type-alias",`Added type alias: ${j} -> ${Q}`)}else{let[X,Q]=Y.split(/\s+as\s+/).map((j)=>j.trim());if(!J.valueImports.has($))J.valueImports.set($,new Set);if(J.valueImports.get($).add(X),J.importSources.set(X,$),Q)J.valueAliases.set(Q,X),J.importSources.set(Q,$),F("value-alias",`Added value alias: ${Q} -> ${X} from ${$}`)}})}function f1(q,$=!0){let J=q.split(`
38
- `);if(J[0].trim().startsWith("export type {"))return q;let Y=$?"export declare":"declare";return[J[0].replace(/^(\s*)(?:export\s+)?type(?!\s*\{)/,`$1${Y} type`),...J.slice(1)].join(`
39
- `).trimEnd()}function L$(q,$){F("type-export-processing",`Processing type export: ${q}`);let J=q.match(/export\s+type\s*\{([^}]+)\}(?:\s*from\s*['"]([^'"]+)['"])?/);if(!J){F("type-export-error","Failed to match type export pattern");return}let[,Z,Y]=J;F("type-export-found",`Found types: ${Z}, source: ${Y||"local"}`),Z.split(",").forEach((X)=>{let[Q,j]=X.trim().split(/\s+as\s+/).map((z)=>z.trim()),U=j||Q;if($.importTracking.exportedTypes.add(U),Y)$.importTracking.typeExportSources.set(U,Y);F("type-export-processed",`Added exported type: ${U}`)})}function Y0(q,$,J){let Z=q.includes("let ")?"let":q.includes("var ")?"var":"const",Y=q.match(/(?:export\s+)?(?:const|let|var)\s+([^:\s]+)\s*:\s*([^=]+)=/);if(Y){let[,V,H]=Y;return`${$?"export ":""}declare ${Z} ${V}: ${H.trim()};`}let X=q.match(/(?:export\s+)?(?:const|let|var)\s+([^=\s]+)\s*=\s*([\s\S]+)$/);if(!X)return q;let[,Q,j]=X,U=j.trim(),z=U.match(/^\(\s*.*?\)\s*:\s*([^=>\s{]).*=>/);if(z){let V=z[1];return`${$?"export ":""}declare ${Z} ${Q}: ${V};`}let G;if(U.includes("as const")){let V=U.replace(/\s*as\s*const\s*$/,"");G=V$(V,J)}else if(U.startsWith("{"))G=J1(U,J);else if(U.startsWith("["))G=M1(U,J);else if(U.includes("=>")||U.includes("function"))G=E1(U)||"(...args: any[]) => unknown";else G=w$(U);return`${$?"export ":""}declare ${Z} ${Q}: ${G};`}function A1(q,$,J=!0){let Z=q.trim().replace(/\s+/g," "),Y=Z$(Z);if(Y.params)Y.params=V1(Y.params);return[J?"export ":"","declare function ",Y.name,Y.generics||"",`(${Y.params})`,Y.returnType?`: ${Y.returnType}`:"",";"].filter(Boolean).join("")}function b$(q){let $=q.trim();if(!$.startsWith("{"))return $;let J=$.slice(1,-1).trim();if(!J)return"{}";return`{ ${J.split(/,?\s+/).filter(Boolean).map((Y)=>{let X=Y.split(":").map((U)=>U.trim());if(X.length<2)return Y;let Q=X[0].endsWith("?")?X[0].slice(0,-1):X[0],j=X[1];return`${Q}${X[0].endsWith("?")?"?":""}: ${j}`}).join(", ")} }`}function v$(q){let $=q.split(`
40
- `),J=0;while(J<$.length){let Z=$[J].trim();if(!Z.startsWith("//")&&!Z.startsWith("/*")&&!Z.startsWith("*")&&Z!=="")break;J++}return $.slice(J).join(`
41
- `).trim()}function g$(q){F("generator-function",`Processing generator function: ${q}`);let $=q.replace(/^export\s+/,"").replace(/^async\s+/,"").trim(),J=$.match(/function\*\s+([^(<\s]+)/);if(!J)return F("generator-function","Failed to match generator function name"),"";let[,Z]=J,Y=$.slice($.indexOf(Z)+Z.length).trim(),X="";if(Y.startsWith("<")){let U=1,z=1;for(;z<Y.length&&U>0;z++){if(Y[z]==="<")U++;if(Y[z]===">")U--}X=Y.slice(0,z),Y=Y.slice(z).trim()}let Q="";if(Y.startsWith("(")){let U=1,z=1;for(;z<Y.length&&U>0;z++){if(Y[z]==="(")U++;if(Y[z]===")")U--}Q=Y.slice(1,z-1).trim(),Y=Y.slice(z).trim()}let j="any";if(Y.startsWith(":")){Y=Y.slice(1).trim();let U=Y.match(/([^{;]+)/);if(U)j=U[1].trim()}return["export declare function ",Z,X?`${X}`:"",`(${Q})`,": ",j].filter(Boolean).join("").concat(";")}function h$(q,$=!0){let J=q.split(`
42
- `),Z=$?"export declare":"declare";return[J[0].replace(/^(\s*)(?:export\s+)?interface/,`$1${Z} interface`),...J.slice(1)].join(`
43
- `).trimEnd()}function X0(q){let $=q.split(`
44
- `),J=" ",Z=0;return $.map((X,Q)=>{let j=X.trim();if(!j)return"";if(j.startsWith("}"))Z--;let U=" ".repeat(Math.max(0,Z)),z=Q===0?j:`${U}${j}`;if(j.endsWith("{"))Z++;if(j.includes("}")&&j.includes("{"))Z=Math.max(0,Z);return z}).join(`
45
- `)}function o1(q){F("process-method-start",`Processing method: ${q}`);let $=/^(?:async\s+)?(\w+)\s*(<[^>]*>)?\s*\(([^)]*)\)\s*(?::\s*([^ {][^;{]*))?/,J=q.match($);if(!J)return F("process-method-error",`Failed to parse method declaration: ${q}`),{name:q.split("(")[0].trim().replace(/^async\s+/,""),signature:"() => unknown"};let[,Z,Y="",X,Q="void"]=J,j=Q.trim();if(/^async\s+/.test(q)&&!/^Promise<.*>$/.test(j))j=`Promise<${j}>`;F("process-method-parsed",`Name: ${Z}, Generics: ${Y}, Params: ${X}, ReturnType: ${j}`);let z=V1(X||""),G=[Y?`${Y}`:"",`(${z})`,"=>",j].filter(Boolean).join(" ").trim();return F("process-method-result",`Generated signature for ${Z}: ${G}`),{name:Z,signature:G}}function u$(q,$,J=0){F("process-props",`Processing object properties at indent level ${J}`);let Z=[],Y=q.slice(1,-1).trim();if(!Y)return Z;let X="",Q=0,j=!1,U="",z="",G=!0,V=!1;for(let H=0;H<Y.length;H++){let _=Y[H],I=H>0?Y[H-1]:"";if((_==='"'||_==="'"||_==="`")&&I!=="\\"){if(!j)j=!0,U=_;else if(_===U)j=!1}if(!j){if(_==="{"||_==="["||_==="(")Q++;else if(_==="}"||_==="]"||_===")")Q--;else if(Q===0){if(_===":"&&!V){V=!0,z=X.trim(),F("process-props-key",`Found key: ${z}`),X="",G=!1;continue}else if((_===","||_===";")&&!G){if(z){let W=X.trim();F("process-props-value",`Processing value for key ${z}: ${W.substring(0,50)}...`);let C=z.includes("(")||z.match(/^\s*(?:async\s+)?\w+\s*(?:<[^>]+>)?\s*\(/);if(F("method-check",`Checking if method declaration: ${z}`),C){F("process-props-method",`Detected method: ${z} with body length: ${W.length}`);let{name:O,signature:P}=o1(z);Z.push({key:O,value:P})}else{let O=a1(W,J+1,$);Z.push({key:e1(z),value:O})}}X="",z="",G=!0,V=!1;continue}}}X+=_}if(z&&!G&&X.trim()){let H=X.trim();if(z.includes("(")||z.match(/^\s*(?:async\s+)?\w+\s*(?:<[^>]+>)?\s*\(/)){F("process-props-method",`Detected final method: ${z}`);let{name:I,signature:W}=o1(z);Z.push({key:I,value:W})}else{let I=a1(H,J+1,$);Z.push({key:e1(z),value:I})}}return F("process-props",`Processed ${Z.length} properties`),Z}function a1(q,$,J){let Z=q.trim();if(F("process-value",`Processing value: ${Z.substring(0,100)}...`),Z.startsWith("{")&&Z.includes("(")&&Z.includes(")")&&Z.includes(":"))return F("process-value","Detected potential object with methods"),J1(Z,J,$);if(Z.startsWith("["))return F("process-value","Detected array"),M1(Z,J,!0);if(Z.startsWith("{"))return F("process-value","Detected object"),J1(Z,J,$);if(Z.includes("=>")||Z.includes("function"))return F("process-value","Detected function expression"),E1(Z)||"(...args: any[]) => unknown";if(/^(['"`]).*\1$/.test(Z)||!Number.isNaN(Number(Z))||Z==="true"||Z==="false")return Z;return"unknown"}function m$(q,$){let J=/(?:extends|implements|:|<)\s*([A-Z][a-zA-Z0-9]*(?:<[^>]+>)?)/g,Z=/(?:^|[\s<,])\s*([A-Z][a-zA-Z0-9]*)(?:[<>,\s]|$)/g,Y=/Promise<([A-Z][a-zA-Z0-9]*)>/g,X;while((X=Y.exec(q))!==null){let j=X[1];if(Array.from($.typeImports.values()).some((U)=>U.has(j)))$.usedTypes.add(j)}while((X=J.exec(q))!==null){let j=X[1].split("<")[0];if(Array.from($.typeImports.values()).some((U)=>U.has(j)))$.usedTypes.add(j)}while((X=Z.exec(q))!==null){let j=X[1];if(Array.from($.typeImports.values()).some((U)=>U.has(j)))$.usedTypes.add(j)}let Q=/export\s+(?:type|interface)\s+([A-Z][a-zA-Z0-9]*)/g;while((X=Q.exec(q))!==null){let j=X[1];$.exportedTypes.add(j)}}function d$(q,$){F("content",`Processing content:
46
- ${q}`);let J=q.matchAll(/export\s*\{([^}]+)\}/g);for(let Z of J)Z[1].split(",").map((X)=>X.trim()).forEach((X)=>{let[Q]=X.split(/\s+as\s+/).map((j)=>j.trim());if(!Q.startsWith("type "))$.usedValues.add(Q),F("export-tracking",`Added exported value: ${Q}`)});if($.defaultExportValue){let Z=$.defaultExportValue;F("default-export",`Processing default export: ${Z}`),$.usedValues.add(Z);let Y=Array.from($.valueAliases.entries()).find(([X])=>X===Z);if(Y){let[X,Q]=Y;F("default-export",`Found alias mapping: ${X} -> ${Q}`),$.usedValues.add(Q),$.usedValues.add(X);let j=$.importSources.get(Q);if(j){if(F("default-export",`Original value ${Q} comes from module: ${j}`),!$.valueImports.has(j))$.valueImports.set(j,new Set);$.valueImports.get(j)?.add(Q)}}else F("default-export",`No alias mapping found for default export ${Z}`),F("default-export",`Current aliases: ${JSON.stringify(Array.from($.valueAliases.entries()))}`)}else F("default-export","No default export found in state.");F("values",`Final used values: ${JSON.stringify(Array.from($.usedValues))}`)}function F(q,$){if(r.verbose===!0)console.debug(`[dtsx:${q}] ${$}`);if(Array.isArray(r.verbose)){if(r.verbose.some((Z)=>q.startsWith(Z)))console.log(`[dtsx:${q}] ${$}`)}}function c$(q){return q.replace(/\s+/g," ").replace(/\s*([<>])\s*/g,"$1").replace(/\s*,\s*/g,", ").trim()}function e1(q){let $=q.replace(/^['"`]|['"`]$/g,"");if(!/^[a-z_$][\w$]*$/i.test($))return`'${$}'`;return $}function j0(q){let $=[],J="",Z=0,Y=!1,X="";for(let j=0;j<q.length;j++){let U=q[j],z=j>0?q[j-1]:"";if((U==='"'||U==="'"||U==="`")&&z!=="\\"){if(!Y)Y=!0,X=U;else if(U===X)Y=!1}if(!Y){if(U==="["||U==="{"||U==="(")Z++;else if(U==="]"||U==="}"||U===")")Z--;else if(U===","&&Z===0){let G=J.trim();if(G)F("array-split",`Found element: ${G}`),$.push(G);J="";continue}}J+=U}let Q=J.trim();if(Q)F("array-split",`Found element: ${Q}`),$.push(Q);return $}function l$(q){let $=[],J=q.split(`
47
- `),Z=[];for(let Y=0;Y<J.length;Y++){let X=J[Y].trim();if((X.startsWith("export function")||X.startsWith("function"))&&Z.length>0)$.push(Z.join(`
48
- `)),Z=[];Z.push(J[Y])}if(Z.length>0)$.push(Z.join(`
49
- `));return $}import{mkdir as rZ,rm as oZ}from"fs/promises";import{dirname as aZ,join as eZ,parse as tZ,relative as q8}from"path";import $8 from"process";var bq=B1(Cq(),1),m1=B1(z1(),1),vq=B1(z1(),1);import Lq,{posix as W1}from"path";var vZ=/\\(?![()[\]{}!+@])/g;function gZ(q){return gq(q)}function hZ(q){return hq(q).replace(vZ,"/")}var u8=process.platform==="win32"?hZ:gZ,uZ=/(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g,mZ=/(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g,gq=(q)=>q.replace(uZ,"\\$&"),hq=(q)=>q.replace(mZ,"\\$&"),m8=process.platform==="win32"?hq:gq;function dZ(q,$){if(($==null?void 0:$.caseSensitiveMatch)===!1)return!0;let J=vq.default.scan(q);return J.isGlob||J.negated}function u1(q,$,J,Z,Y){var X;let Q=q;if(q.endsWith("/"))Q=q.slice(0,-1);if(!Q.endsWith("*")&&$)Q+="/**";if(Lq.isAbsolute(Q.replace(/\\(?=[()[\]{}!*+?@|])/g,"")))Q=W1.relative(J,Q);else Q=W1.normalize(Q);let j=/^(\/?\.\.)+/.exec(Q);if(j==null?void 0:j[0]){let U=W1.join(J,j[0]);if(Z.root.length>U.length)Z.root=U,Z.depthOffset=-(j[0].length+1)/3}else if(!Y&&Z.depthOffset>=0){let U=Q.split("/");(X=Z.commonPath)!=null||(Z.commonPath=U);let z=[];for(let G=0;G<Math.min(Z.commonPath.length,U.length);G++){let V=U[G];if(V==="**"&&!U[G+1]){z.pop();break}if(V!==Z.commonPath[G]||dZ(V)||G===U.length-1)break;z.push(V)}Z.depthOffset=z.length,Z.commonPath=z,Z.root=z.length>0?`${J}/${z.join("/")}`:J}return Q}function cZ({patterns:q,ignore:$=[],expandDirectories:J=!0},Z,Y){if(typeof q==="string")q=[q];else if(!q)q=["**/*"];if(typeof $==="string")$=[$];let X=[],Q=[];for(let j of $)if(!j.startsWith("!")||j[1]==="("){let U=u1(j,J,Z,Y,!0);Q.push(U)}for(let j of q)if(!j.startsWith("!")||j[1]==="("){let U=u1(j,J,Z,Y,!1);X.push(U)}else if(j[1]!=="!"||j[2]==="("){let U=u1(j.slice(1),J,Z,Y,!0);Q.push(U)}return{match:X,ignore:Q}}function d1(q,$,J){return W1.relative($,`${J}/${q}`)}function kq(q,$,J,Z,Y){let X=Y?q.slice(J.length+1)||".":q;if(J===$)return Z&&X!=="."?X.slice(0,-1):X;return d1(X,$,J)}function lZ(q,$,J){let Z={root:$,commonPath:null,depthOffset:0},Y=cZ(q,$,Z),X=m1.default(Y.match,{dot:q.dot,nocase:q.caseSensitiveMatch===!1,ignore:Y.ignore}),Q=m1.default(Y.ignore,{dot:q.dot,nocase:q.caseSensitiveMatch===!1}),j={filters:[(z,G)=>X(kq(z,$,Z.root,G,q.absolute))],exclude:(z,G)=>Q(kq(G,$,Z.root,!0,!0)),pathSeparator:"/",relativePaths:!0,resolveSymlinks:!0};if(q.deep)j.maxDepth=Math.round(q.deep-Z.depthOffset);if(q.absolute)j.relativePaths=!1,j.resolvePaths=!0,j.includeBasePath=!0;if(q.followSymbolicLinks===!1)j.resolveSymlinks=!1,j.excludeSymlinks=!0;if(q.onlyDirectories)j.excludeFiles=!0,j.includeDirs=!0;else if(q.onlyFiles===!1)j.includeDirs=!0;Z.root=Z.root.replace(/\\/g,"");let U=new bq.fdir(j).crawl(Z.root);if($===Z.root||q.absolute)return J?U.sync():U.withPromise();return J?U.sync().map((z)=>d1(z,$,Z.root)+(!z||z.endsWith("/")?"/":"")):U.withPromise().then((z)=>z.map((G)=>d1(G,$,Z.root)+(!G||G.endsWith("/")?"/":"")))}async function uq(q,$){if(q&&($==null?void 0:$.patterns))throw new Error("Cannot pass patterns as both an argument and an option");let J=Array.isArray(q)||typeof q==="string"?{...$,patterns:q}:q,Z=J.cwd?Lq.resolve(J.cwd).replace(/\\/g,"/"):process.cwd().replace(/\\/g,"/");return lZ(J,Z,!1)}import{readdir as pZ}from"fs/promises";import{dirname as iZ,extname as nZ,isAbsolute as sZ,join as cq,resolve as mq}from"path";import lq from"process";import{pathToFileURL as c1}from"url";async function pq(q,$){await Bun.write(q,$)}async function l1(q){let $=q??r.root,J=await pZ($,{withFileTypes:!0}),Z=await Promise.all(J.map((Y)=>{let X=cq($,Y.name);return Y.isDirectory()?l1(X):X}));return Array.prototype.concat(...Z).filter((Y)=>nZ(Y)===".ts")}async function iq(q){try{let $=q?.cwd||lq.cwd(),J=q?.tsconfigPath||cq($,"tsconfig.json"),Y=await import(c1(J).href);if(Y.compilerOptions?.isolatedDeclarations===!0)return!0;if(Y.extends){let X=dq(J,Y.extends),Q=X.endsWith(".json")?X:`${X}.json`,U=await import(c1(Q).href);if(U.compilerOptions?.isolatedDeclarations===!0)return!0;if(U.extends){let z=dq(Q,U.extends),G=z.endsWith(".json")?z:`${z}.json`;if((await import(c1(G).href)).compilerOptions?.isolatedDeclarations===!0)return!0}}return!1}catch($){return!1}}function dq(q,$){if(sZ($))return $;if($.startsWith("."))return mq(iZ(q),$);return mq(lq.cwd(),"node_modules",$)}async function J8(q){try{if(!await iq(q)){console.error("Error: isolatedDeclarations must be set to true in your tsconfig.json. Ensure `tsc --noEmit` does not output any errors.");return}if(q?.clean)await oZ(q.outdir,{recursive:!0,force:!0});let J=q?.cwd||$8.cwd(),Z;if(q?.entrypoints)Z=await uq(q.entrypoints,{cwd:q.root??`${J}/src`,absolute:!0});else Z=await l1(q?.root??`${J}/src`);for(let Y of Z){let X=await t1(Y);if(X){let Q=q8(q?.root??"./src",Y),j=tZ(Q),U=eZ(q?.outdir??"./dist",`${j.name}.d.ts`);await rZ(aZ(U),{recursive:!0}),await pq(U,X)}else console.warn(`No declarations extracted for ${Y}`)}}catch($){console.error("Error generating declarations:",$)}}async function J5(q){await J8({...r,...q})}export{pq as writeToFile,B8 as processSpecificDeclaration,F8 as isFunctionType,K8 as isDeclarationComplete,l1 as getAllTypeScriptFiles,J8 as generateDeclarationsFromFiles,J5 as generate,J$ as extractDtsTypes,t1 as extract,r as config,iq as checkIsolatedDeclarations};
27
+ function`)){let Q=rq(X);if(Q.length>1){B("block-processing",`Found ${Q.length} function declarations to process`,Z),Q.forEach((U)=>{let z=U.split(`
28
+ `);M1(z,q,J,Z)});return}}if((Eq(X,J,Z)?void 0:Aq(X,$,J,Z)?void 0:Sq(X,Y,J)?void 0:yq(X,J)?void 0:Dq(X,J)?void 0:Tq(X,Y,J,Z)?void 0:hq(X,Y,J)?void 0:void 0)===void 0)B("processing",`Unhandled declaration type: ${X.split(`
29
+ `)[0]}`,Z)}function Aq($,q,J,Z){if(!$.match(/^(?:export\s+)?(const|let|var)\s+/))return!1;if(U0($,J))return B("variable-processing","Skipping variable inside function",Z),!0;let Y=$.startsWith("export");if(J.currentScope==="top"){let X=q.join(`
30
+ `);J.dtsLines.push(mq(X,Y,J,Z))}else B("block-processing","Skipping variable declared inside a function",Z);return!0}function Eq($,q,J){if(B("function-processing",`Processing potential function block: ${$.slice(0,100)}...`,J),/^(?:export\s+)?(?:async\s+)?function\s*\*/.test($)){B("block-processing","Processing generator function declaration",J);let z=lq($);if(z)return q.dtsLines.push(z),!0}if(!/^(?:export\s+)?(?:async\s+)?function\s+[a-zA-Z_$][\w$]*/.test($))return!1;B("block-processing","Processing function declaration",J);let Z=$.split(/[\n;]/).map((z)=>z.trim()).filter((z)=>z.startsWith("export function")||z.startsWith("function"));if(Z.length>1)return Z.forEach((z)=>{if(!z.endsWith("{")){let G=Z0(z,q.usedTypes,z.startsWith("export"),J);if(G)q.dtsLines.push(G)}}),!0;let j=0,Y=0,X=0;for(let z=0;z<$.length;z++){let G=$[z];if(G==="(")Y++;if(G===")")Y--;if(G==="<")X++;if(G===">")X--;if(G==="{"){if(Y===0&&X===0){j=z;break}}}if(j===0)j=$.length;let W=$.slice(0,j).trim();B("signature-extraction",`Extracted signature: ${W}`,J);let Q=W.startsWith("export"),U=Z0(W,q.usedTypes,Q,J);if(U)B("function-processed",`Generated declaration: ${U}`,J),q.dtsLines.push(U);return!0}function Pq($,q,J,Z){if(B("interface-processing",`Starting interface processing with declaration: ${$.slice(0,100)}...`,Z),!$.startsWith("interface")&&!$.startsWith("export interface"))return B("interface-processing","Not an interface declaration, skipping",Z),!1;let j=q.split(`
31
+ `),Y=0,X=0,W=[],Q=!0,U=!1;B("interface-processing",`Processing ${j.length} lines`,Z);for(let M=0;M<j.length;M++){let f=j[M],I=f.trim(),P=(f.match(/\{/g)||[]).length,E=(f.match(/\}/g)||[]).length,_=(f.match(/</g)||[]).length,x=(f.match(/>/g)||[]).length;if(Y+=P-E,X+=_-x,I.includes("{"))U=!0;if(B("interface-depth",`Line ${M+1}: "${I}" , verboseBracket depth: ${Y}, Angle depth: ${X}, Has started body: ${U}`),Q){let i=I.startsWith("export")?"export declare":"declare";W.push(f.replace(/^(\s*)(?:export\s+)?interface/,`$1${i} interface`)),Q=!1}else W.push(f)}let z=W.join(`
32
+ `),G=z.includes("{")&&z.includes("}");if(Y===0&&(X===0||z.includes(">"))&&G)return B("interface-processing",`Successfully processed interface:
33
+ ${z}`,Z),J.dtsLines.push(z),!0;return B("interface-processing",`Interface processing incomplete. Bracket depth: ${Y}, , verboseAngle depth: ${X}, Has started body: ${U}`),!1}function Sq($,q,J){if(!$.startsWith("type")&&!$.startsWith("export type"))return!1;let Z=$.startsWith("export");return J.dtsLines.push(G0(q,Z)),!0}function yq($,q){if(!Hq($))return!1;let J=$.replace(/^export\s+default\s+/,"").replace(/;$/,"");q.importTracking.defaultExportValue=J;let Z=$.endsWith(";")?$:`${$};`;return q.defaultExports.add(Z),!0}function Dq($,q){if(!$.startsWith("export *"))return!1;return q.exportAllStatements.push($),q.dtsLines.push($),!0}function Tq($,q,J,Z){if(!$.startsWith("export"))return!1;if($.startsWith("export {"))return J.dtsLines.push(q),!0;if(kq($,J))return!0;if(Lq($,J))return!0;if(gq($,J))return!0;if($.includes("export {"))return J.dtsLines.push(q),!0;return B("processing",`Unhandled exported declaration type: ${$.split(`
34
+ `)[0]}`,Z),!0}function xq($,q,J){if(B("export-processing",`Processing export: ${$}`,J),$.includes("{")&&!$.includes("}")){q.currentDeclaration=$;return}if(q.currentDeclaration){if(q.currentDeclaration+=` ${$}`,!$.includes("}"))return;$=q.currentDeclaration,q.currentDeclaration=""}let Z=$.match(/export\s*\{([^}]+)\}(?:\s*from\s*['"]([^'"]+)['"])?/);if(!Z){if(B("export-error","Failed to match export pattern",J),$.startsWith("export {"))q.dtsLines.push($);return}let[,j,Y]=Z;if(B("export-found",`Found exports: ${j}, source: ${Y||"local"}`,J),$.startsWith("export {"))q.dtsLines.push($);j.split(",").forEach((X)=>{let[W,Q]=X.trim().split(/\s+as\s+/).map((U)=>U.trim());if(W.startsWith("type ")){let U=W.replace(/^type\s+/,"").trim(),z=Q||U;if(q.importTracking.exportedTypes.add(z),Y)q.importTracking.typeExportSources.set(z,Y);B("export-type-processed",`Added exported type: ${z}`,J)}else{let U=Q||W;q.importTracking.exportedValues.add(U),B("export-value-processed",`Added exported value: ${U}`,J)}})}function kq($,q){if(!$.startsWith("export class")&&!$.startsWith("export abstract class"))return!1;let J=`export declare ${$.replace(/^export\s+/,"")}`;return q.dtsLines.push(J),!0}function Lq($,q){if(!$.startsWith("export enum")&&!$.startsWith("export const enum"))return!1;let J=`export declare ${$.replace(/^export\s+/,"")}`;return q.dtsLines.push(J),!0}function gq($,q){if(!$.startsWith("export namespace"))return!1;let J=`export declare ${$.replace(/^export\s+/,"")}`;return q.dtsLines.push(J),!0}function hq($,q,J){if(!$.startsWith("declare module"))return!1;let Z=iq(q);return J.dtsLines.push(Z),!0}function bq($,q,J){let Z=$.split(`
35
+ `),j=[],Y=[],X=0,W=0,Q=!1,U=!1;q.currentScope="top",B("source-processing",`Processing source file with ${Z.length} lines`,J);for(let z=0;z<Z.length;z++){let G=Z[z],F=G.trim();if(F.startsWith("export {")){if(F.includes("}")){q.dtsLines.push(G);continue}U=!0,j=[G];continue}if(U){if(j.push(G),G.includes("}"))q.dtsLines.push(j.join(`
36
+ `)),j=[],U=!1;continue}if(G.includes("import "))z0(G,q.importTracking,J),B("import",`Processed import: ${G}`,J);if(F.startsWith("export type {")){B("type-export",`Found type export: ${F}`,J),uq(F,q),q.dtsLines.push(G);continue}if(F.startsWith("export {")){if(B("mixed-export",`Found mixed export: ${F}`,J),xq(F,q,J),F.includes("}"))q.dtsLines.push(G);continue}}for(let z=0;z<Z.length;z++){let G=Z[z],F=G.trim();if(F.startsWith("import ")||F.startsWith("export type {")||F.startsWith("export {"))continue;if(F.startsWith("/*")||F.startsWith("//")){Y.push(G);continue}let M=(G.match(/\{/g)||[]).length,f=(G.match(/\}/g)||[]).length,I=(G.match(/</g)||[]).length,P=(G.match(/>/g)||[]).length;if(!Q&&Iq(F)){B("declaration",`Found declaration start: ${F}`,J),Q=!0,j=[G],X=M-f,W=I-P;continue}if(Q)if(j.push(G),X+=M-f,W+=I-P,j[0].trim().startsWith("type")||j[0].trim().startsWith("export type")){let _=z<Z.length-1?Z[z+1]?.trim():"";if(!(X>0||W>0||!F.endsWith(";")||F.endsWith("?")||F.endsWith(":")||_&&(_.startsWith("?")||_.startsWith(":")||_.startsWith("|")||_.startsWith("&")||_.startsWith("extends")||_.startsWith("=>"))))B("declaration-complete",`Type declaration complete at line ${z+1}`,J),M1(j,Y,q,J),j=[],Y=[],Q=!1,X=0,W=0}else{let _=X===0&&W===0&&F.endsWith("}"),x=z<Z.length-1?Z[z+1]?.trim():"";if(!(X>0||W>0||x&&!x.startsWith("export")&&!x.startsWith("interface"))||_)B("declaration-complete",`Declaration complete at line ${z+1}`,J),M1(j,Y,q,J),j=[],Y=[],Q=!1,X=0,W=0}}if(j.length>0)M1(j,Y,q,J)}function z0($,q,J){B("import-processing",`Processing import line: ${$}`,J);let Z=$.match(/import\s+type\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/);if(Z){let[,W,Q]=Z;vq(W,Q,q);return}let j=$.match(/import\s+([^,{\s]+)\s*,\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/);if(j){let[,W,Q,U]=j;q0(W,U,q),J0(Q,U,q);return}let Y=$.match(/import\s+([^,{\s]+)\s+from\s*['"]([^'"]+)['"]/);if(Y&&!j){let[,W,Q]=Y;q0(W,Q,q);return}let X=$.match(/import\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/);if(X){let[,W,Q]=X;J0(W,Q,q)}}function vq($,q,J,Z){if(B("type-import",`Handling type imports from ${q}: ${$}`,Z),!J.typeImports.has(q))J.typeImports.set(q,new Set);$.split(",").map((Y)=>Y.trim()).filter(Boolean).forEach((Y)=>{let[X,W]=Y.split(/\s+as\s+/).map((U)=>U.trim()),Q=X.replace(/^type\s+/,"");if(X&&Q){if(J.typeImports.get(q).add(Q),J.typeExportSources.set(Q,q),W)J.valueAliases.set(W,Q)}})}function q0($,q,J){if(!J.valueImports.has(q))J.valueImports.set(q,new Set);J.valueImports.get(q).add("default"),J.importSources.set($,q),J.valueAliases.set($,"default")}function J0($,q,J,Z){B("mixed-import",`Handling mixed imports from ${q}: ${$}`,Z),$.split(",").map((Y)=>Y.trim()).filter(Boolean).forEach((Y)=>{if(Y.startsWith("type ")){let X=Y.replace(/^type\s+/,""),[W,Q]=X.split(/\s+as\s+/).map((U)=>U.trim());if(!J.typeImports.has(q))J.typeImports.set(q,new Set);if(J.typeImports.get(q).add(W),J.typeExportSources.set(W,q),Q)J.valueAliases.set(Q,W),B("type-alias",`Added type alias: ${Q} -> ${W}`,Z)}else{let[X,W]=Y.split(/\s+as\s+/).map((Q)=>Q.trim());if(!J.valueImports.has(q))J.valueImports.set(q,new Set);if(J.valueImports.get(q).add(X),J.importSources.set(X,q),W)J.valueAliases.set(W,X),J.importSources.set(W,q),B("value-alias",`Added value alias: ${W} -> ${X} from ${q}`,Z)}})}function G0($,q=!0){let J=$.split(`
37
+ `);if(J[0].trim().startsWith("export type {"))return $;let j=q?"export declare":"declare";return[J[0].replace(/^(\s*)(?:export\s+)?type(?!\s*\{)/,`$1${j} type`),...J.slice(1)].join(`
38
+ `).trimEnd()}function uq($,q,J){B("type-export-processing",`Processing type export: ${$}`,J);let Z=$.match(/export\s+type\s*\{([^}]+)\}(?:\s*from\s*['"]([^'"]+)['"])?/);if(!Z){B("type-export-error","Failed to match type export pattern",J);return}let[,j,Y]=Z;B("type-export-found",`Found types: ${j}, source: ${Y||"local"}`,J),j.split(",").forEach((X)=>{let[W,Q]=X.trim().split(/\s+as\s+/).map((z)=>z.trim()),U=Q||W;if(q.importTracking.exportedTypes.add(U),Y)q.importTracking.typeExportSources.set(U,Y);B("type-export-processed",`Added exported type: ${U}`,J)})}function mq($,q,J,Z){let j=$.includes("let ")?"let":$.includes("var ")?"var":"const",Y=$.match(/(?:export\s+)?(?:const|let|var)\s+([^:\s]+)\s*:\s*([^=]+)=/);if(Y){let[,F,M]=Y;return`${q?"export ":""}declare ${j} ${F}: ${M.trim()};`}let X=$.match(/(?:export\s+)?(?:const|let|var)\s+([^=\s]+)\s*=\s*([\s\S]+)$/);if(!X)return $;let[,W,Q]=X,U=Q.trim(),z=U.match(/^\(\s*.*?\)\s*:\s*([^=>\s{]).*=>/);if(z){let F=z[1];return`${q?"export ":""}declare ${j} ${W}: ${F};`}let G;if(U.includes("as const")){let F=U.replace(/\s*as\s*const\s*$/,"");G=Nq(F,J,Z)}else if(U.startsWith("{"))G=Z1(U,J);else if(U.startsWith("["))G=N1(U,J,!1,Z);else if(U.includes("=>")||U.includes("function"))G=x1(U,Z)||"(...args: any[]) => unknown";else G=Mq(U);return`${q?"export ":""}declare ${j} ${W}: ${G};`}function Z0($,q,J=!0,Z){let j=$.trim(),Y=Qq(j,Z);if(Y.params)if(!Y.params.includes("{")){let W=Y.params.split(",").map((Q)=>{let U=Q.trim();if(!U)return null;if(U.includes("=")){let[z]=U.split(/\s*=\s*/),G=z.trim();if(G.includes(":")){let[f,I]=G.split(":").map((P)=>P.trim());return`${f}?: ${I}`}let F=U.split(/\s*=\s*/)[1].trim(),M="any";if(F==="{}")M=U.includes(":")?U.split(":")[1].trim().split("=")[0].trim():"Record<string, unknown>";else if(F==="")M="string";else if(F==="true"||F==="false")M="boolean";else if(!Number.isNaN(Number(F)))M="number";else if(F.startsWith('"')||F.startsWith("'"))M="string";else if(F.startsWith("["))M="any[]";else if(F.startsWith("{"))M="Record<string, unknown>";else M="any";return`${G}?: ${M}`}if(U.includes(":")){let[z,G]=U.split(":").map((f)=>f.trim()),F=z.endsWith("?");return`${z.replace(/\?$/,"")}${F?"?":""}: ${G}`}return U}).filter(Boolean).join(", ");Y.params=W}else{let W=$.match(/\{([^}]+)\}:\s*([^)]+)/);if(W){let[,Q,U]=W,z=Q.split(",").map((G)=>{let F=G.trim();if(!F)return null;let M=F.includes("="),[f]=F.split(/\s*=\s*/),I=f.trim(),P=M||I.endsWith("?"),E=I.replace(/\?$/,"");if(E.includes(":")){let[_,x]=E.split(":").map((i)=>i.trim());return`${_}${P?"?":""}: ${x}`}return`${E}${P?"?":""}`}).filter(Boolean);Y.params=`{ ${z.join(", ")} }: ${U.trim()}`}}return[J?"export ":"","declare function ",Y.name,Y.generics||"",`(${Y.params})`,Y.returnType?`: ${Y.returnType}`:"",";"].filter(Boolean).join("")}function dq($){let q=$.trim();if(!q.startsWith("{"))return q;let J=q.slice(1,-1).trim();if(!J)return"{}";return`{ ${J.split(/,?\s+/).filter(Boolean).map((j)=>{let Y=j.split(":").map((Q)=>Q.trim());if(Y.length<2)return j;let X=Y[0].endsWith("?")?Y[0].slice(0,-1):Y[0],W=Y[1];return`${X}${Y[0].endsWith("?")?"?":""}: ${W}`}).join(", ")} }`}function cq($){let q=$.split(`
39
+ `),J=0;while(J<q.length){let Z=q[J].trim();if(!Z.startsWith("//")&&!Z.startsWith("/*")&&!Z.startsWith("*")&&Z!=="")break;J++}return q.slice(J).join(`
40
+ `).trim()}function lq($,q){B("generator-function",`Processing generator function: ${$}`,q);let J=$.replace(/^export\s+/,"").replace(/^async\s+/,"").trim(),Z=J.match(/function\*\s+([^(<\s]+)/);if(!Z)return B("generator-function","Failed to match generator function name",q),"";let[,j]=Z,Y=J.slice(J.indexOf(j)+j.length).trim(),X="";if(Y.startsWith("<")){let U=1,z=1;for(;z<Y.length&&U>0;z++){if(Y[z]==="<")U++;if(Y[z]===">")U--}X=Y.slice(0,z),Y=Y.slice(z).trim()}let W="";if(Y.startsWith("(")){let U=1,z=1;for(;z<Y.length&&U>0;z++){if(Y[z]==="(")U++;if(Y[z]===")")U--}W=Y.slice(1,z-1).trim(),Y=Y.slice(z).trim()}let Q="any";if(Y.startsWith(":")){Y=Y.slice(1).trim();let U=Y.match(/([^{;]+)/);if(U)Q=U[1].trim()}return["export declare function ",j,X?`${X}`:"",`(${W})`,": ",Q].filter(Boolean).join("").concat(";")}function iq($){let q=$.split(`
41
+ `),J=" ",Z=0;return q.map((Y,X)=>{let W=Y.trim();if(!W)return"";if(W.startsWith("}"))Z--;let Q=" ".repeat(Math.max(0,Z)),U=X===0?W:`${Q}${W}`;if(W.endsWith("{"))Z++;if(W.includes("}")&&W.includes("{"))Z=Math.max(0,Z);return U}).join(`
42
+ `)}function j0($,q){B("process-method-start",`Processing method: ${$}`,q);let J=/^(?:async\s+)?(\w+)\s*(<[^>]*>)?\s*\(([^)]*)\)\s*(?::\s*([^ {][^;{]*))?/,Z=$.match(J);if(!Z)return B("process-method-error",`Failed to parse method declaration: ${$}`,q),{name:$.split("(")[0].trim().replace(/^async\s+/,""),signature:"() => unknown"};let[,j,Y="",X,W="void"]=Z,Q=W.trim();if(/^async\s+/.test($)&&!/^Promise<.*>$/.test(Q))Q=`Promise<${Q}>`;B("process-method-parsed",`Name: ${j}, Generics: ${Y}, Params: ${X}, ReturnType: ${Q}`,q);let z=D1(X||""),G=[Y?`${Y}`:"",`(${z})`,"=>",Q].filter(Boolean).join(" ").trim();return B("process-method-result",`Generated signature for ${j}: ${G}`,q),{name:j,signature:G}}function pq($,q,J=0,Z){B("process-props",`Processing object properties at indent level ${J}`,Z);let j=[],Y=$.slice(1,-1).trim();if(!Y)return j;let X="",W=0,Q=!1,U="",z="",G=!0,F=!1;for(let M=0;M<Y.length;M++){let f=Y[M],I=M>0?Y[M-1]:"";if((f==='"'||f==="'"||f==="`")&&I!=="\\"){if(!Q)Q=!0,U=f;else if(f===U)Q=!1}if(!Q){if(f==="{"||f==="["||f==="(")W++;else if(f==="}"||f==="]"||f===")")W--;else if(W===0){if(f===":"&&!F){F=!0,z=X.trim(),B("process-props-key",`Found key: ${z}`,Z),X="",G=!1;continue}else if((f===","||f===";")&&!G){if(z){let P=X.trim();B("process-props-value",`Processing value for key ${z}: ${P.substring(0,50)}...`,Z);let E=z.includes("(")||z.match(/^\s*(?:async\s+)?\w+\s*(?:<[^>]+>)?\s*\(/);if(B("method-check",`Checking if method declaration: ${z}`,Z),E){B("process-props-method",`Detected method: ${z} with body length: ${P.length}`,Z);let{name:_,signature:x}=j0(z,Z);j.push({key:_,value:x})}else{let _=Y0(P,J+1,q,Z);j.push({key:X0(z),value:_})}}X="",z="",G=!0,F=!1;continue}}}X+=f}if(z&&!G&&X.trim()){let M=X.trim();if(z.includes("(")||z.match(/^\s*(?:async\s+)?\w+\s*(?:<[^>]+>)?\s*\(/)){B("process-props-method",`Detected final method: ${z}`,Z);let{name:I,signature:P}=j0(z,Z);j.push({key:I,value:P})}else{let I=Y0(M,J+1,q,Z);j.push({key:X0(z),value:I})}}return B("process-props",`Processed ${j.length} properties`,Z),j}function Y0($,q,J,Z){let j=$.trim();if(B("process-value",`Processing value: ${j.substring(0,100)}...`,Z),j.startsWith("{")&&j.includes("(")&&j.includes(")")&&j.includes(":"))return B("process-value","Detected potential object with methods",Z),Z1(j,J,q);if(j.startsWith("["))return B("process-value","Detected array",Z),N1(j,J,!0,Z);if(j.startsWith("{"))return B("process-value","Detected object",Z),Z1(j,J,q);if(j.includes("=>")||j.includes("function"))return B("process-value","Detected function expression",Z),x1(j,Z)||"(...args: any[]) => unknown";if(/^(['"`]).*\1$/.test(j)||!Number.isNaN(Number(j))||j==="true"||j==="false")return j;return"unknown"}function nq($,q){let J=/(?:extends|implements|:|<)\s*([A-Z][a-zA-Z0-9]*(?:<[^>]+>)?)/g,Z=/(?:^|[\s<,])\s*([A-Z][a-zA-Z0-9]*)(?:[<>,\s]|$)/g,j=/Promise<([A-Z][a-zA-Z0-9]*)>/g,Y;while((Y=j.exec($))!==null){let W=Y[1];if(Array.from(q.typeImports.values()).some((Q)=>Q.has(W)))q.usedTypes.add(W)}while((Y=J.exec($))!==null){let W=Y[1].split("<")[0];if(Array.from(q.typeImports.values()).some((Q)=>Q.has(W)))q.usedTypes.add(W)}while((Y=Z.exec($))!==null){let W=Y[1];if(Array.from(q.typeImports.values()).some((Q)=>Q.has(W)))q.usedTypes.add(W)}let X=/export\s+(?:type|interface)\s+([A-Z][a-zA-Z0-9]*)/g;while((Y=X.exec($))!==null){let W=Y[1];q.exportedTypes.add(W)}}function sq($,q,J){B("content",`Processing content:
43
+ ${$}`,J);let Z=$.matchAll(/export\s*\{([^}]+)\}/g);for(let j of Z)j[1].split(",").map((X)=>X.trim()).forEach((X)=>{let[W]=X.split(/\s+as\s+/).map((Q)=>Q.trim());if(!W.startsWith("type "))q.usedValues.add(W),B("export-tracking",`Added exported value: ${W}`,J)});if(q.defaultExportValue){let j=q.defaultExportValue;B("default-export",`Processing default export: ${j}`,J),q.usedValues.add(j);let Y=Array.from(q.valueAliases.entries()).find(([X])=>X===j);if(Y){let[X,W]=Y;B("default-export",`Found alias mapping: ${X} -> ${W}`,J),q.usedValues.add(W),q.usedValues.add(X);let Q=q.importSources.get(W);if(Q){if(B("default-export",`Original value ${W} comes from module: ${Q}`,J),!q.valueImports.has(Q))q.valueImports.set(Q,new Set);q.valueImports.get(Q)?.add(W)}}else B("default-export",`No alias mapping found for default export ${j}`,J),B("default-export",`Current aliases: ${JSON.stringify(Array.from(q.valueAliases.entries()))}`,J)}else B("default-export","No default export found in state.",J);B("values",`Final used values: ${JSON.stringify(Array.from(q.usedValues))}`,J)}function B($,q,J){if(J===!1)return;if(J===!0||t.verbose===!0)console.debug(`[dtsx:${$}] ${q}`);if(Array.isArray(J)){if(J.some((j)=>$.startsWith(j)))console.log(`[dtsx:${$}] ${q}`)}if(Array.isArray(t.verbose)){if(t.verbose.some((j)=>$.startsWith(j)))console.log(`[dtsx:${$}] ${q}`)}}function oq($){return $.replace(/\s+/g," ").replace(/\s*([<>])\s*/g,"$1").replace(/\s*,\s*/g,", ").trim()}function X0($){let q=$.replace(/^['"`]|['"`]$/g,"");if(!/^[a-z_$][\w$]*$/i.test(q))return`'${q}'`;return q}function F0($,q){let J=[],Z="",j=0,Y=!1,X="";for(let Q=0;Q<$.length;Q++){let U=$[Q],z=Q>0?$[Q-1]:"";if((U==='"'||U==="'"||U==="`")&&z!=="\\"){if(!Y)Y=!0,X=U;else if(U===X)Y=!1}if(!Y){if(U==="["||U==="{"||U==="(")j++;else if(U==="]"||U==="}"||U===")")j--;else if(U===","&&j===0){let G=Z.trim();if(G)B("array-split",`Found element: ${G}`,q),J.push(G);Z="";continue}}Z+=U}let W=Z.trim();if(W)B("array-split",`Found element: ${W}`,q),J.push(W);return J}function rq($){let q=[],J=$.split(`
44
+ `),Z=[];for(let j=0;j<J.length;j++){let Y=J[j].trim();if((Y.startsWith("export function")||Y.startsWith("function"))&&Z.length>0)q.push(Z.join(`
45
+ `)),Z=[];Z.push(J[j])}if(Z.length>0)q.push(Z.join(`
46
+ `));return q}import{mkdir as U5,rm as z5}from"fs/promises";import{dirname as G5,join as a$,parse as F5,relative as w5}from"path";import K5 from"process";var m$=V1(v$(),1),n1=V1(G1(),1),E1=V1(G1(),1);import p1,{posix as A1}from"path";var iZ=/^(\/?\.\.)+$/;function pZ($,q){let J=$.length,Z=Array(J),j=Array(J);for(let Y=0;Y<J;Y++){let X=d$($[Y]);Z[Y]=X;let W=X.length,Q=Array(W);for(let U=0;U<W;U++)Q[U]=E1.default.makeRe(X[U],q);j[Y]=Q}return(Y)=>{let X=Y.split("/");if(X[0]===".."&&iZ.test(Y))return!0;for(let W=0;W<$.length;W++){let Q=Z[W],U=j[W],z=X.length,G=Math.min(z,Q.length),F=0;while(F<G){let M=Q[F];if(M.includes("/"))return!0;if(!U[F].test(X[F]))break;if(M==="**")return!0;F++}if(F===z)return!0}return!1}}var nZ={parts:!0};function d$($){var q;let J=E1.default.scan($,nZ);return((q=J.parts)==null?void 0:q.length)?J.parts:[$]}var sZ=process.platform==="win32";var oZ=/(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g,rZ=/(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g,aZ=($)=>$.replace(oZ,"\\$&"),tZ=($)=>$.replace(rZ,"\\$&"),eZ=sZ?tZ:aZ;function $5($,q){if((q==null?void 0:q.caseSensitiveMatch)===!1)return!0;let J=E1.default.scan($);return J.isGlob||J.negated}function Q1(...$){console.log(`[tinyglobby ${new Date().toLocaleTimeString("es")}]`,...$)}var q5=/^(\/?\.\.)+/,J5=/\\(?=[()[\]{}!*+?@|])/g,s1=/\\/g;function i1($,q,J,Z,j){var Y;let X=$;if($.endsWith("/"))X=$.slice(0,-1);if(!X.endsWith("*")&&q)X+="/**";if(p1.isAbsolute(X.replace(J5,"")))X=A1.relative(eZ(J),X);else X=A1.normalize(X);let W=q5.exec(X);if(W==null?void 0:W[0]){let Q=A1.join(J,W[0]);if(Z.root.length>Q.length)Z.root=Q,Z.depthOffset=-(W[0].length+1)/3}else if(!j&&Z.depthOffset>=0){let Q=d$(X);(Y=Z.commonPath)!=null||(Z.commonPath=Q);let U=[],z=Math.min(Z.commonPath.length,Q.length);for(let G=0;G<z;G++){let F=Q[G];if(F==="**"&&!Q[G+1]){U.pop();break}if(F!==Z.commonPath[G]||$5(F)||G===Q.length-1)break;U.push(F)}Z.depthOffset=U.length,Z.commonPath=U,Z.root=U.length>0?p1.posix.join(J,...U):J}return X}function Z5({patterns:$,ignore:q=[],expandDirectories:J=!0},Z,j){if(typeof $==="string")$=[$];else if(!$)$=["**/*"];if(typeof q==="string")q=[q];let Y=[],X=[];for(let W of q){if(!W)continue;if(W[0]!=="!"||W[1]==="(")X.push(i1(W,J,Z,j,!0))}for(let W of $){if(!W)continue;if(W[0]!=="!"||W[1]==="(")Y.push(i1(W,J,Z,j,!1));else if(W[1]!=="!"||W[2]==="(")X.push(i1(W.slice(1),J,Z,j,!0))}return{match:Y,ignore:X}}function c$($,q,J){return A1.relative(q,`${J}/${$}`)||"."}function C1($,q,J,Z,j){let Y=j?$.slice(J==="/"?1:J.length+1)||".":$;if(J===q)return Z&&Y!=="."?Y.slice(0,-1):Y;return c$(Y,q,J)}function u$($,q,J){for(let Z=$.length-1;Z>=0;Z--){let j=$[Z];$[Z]=c$(j,q,J)+(!j||j.endsWith("/")?"/":"")}return $}function j5($,q,J){if(process.env.TINYGLOBBY_DEBUG)$.debug=!0;if($.debug)Q1("globbing with options:",$,"cwd:",q);if(Array.isArray($.patterns)&&$.patterns.length===0)return J?[]:Promise.resolve([]);let Z={root:q,commonPath:null,depthOffset:0},j=Z5($,q,Z),Y=$.caseSensitiveMatch===!1;if($.debug)Q1("internal processing patterns:",j);let X=n1.default(j.match,{dot:$.dot,nocase:Y,ignore:j.ignore}),W=n1.default(j.ignore,{dot:$.dot,nocase:Y}),Q=pZ(j.match,{dot:$.dot,nocase:Y}),U={filters:[$.debug?(F,M)=>{let f=C1(F,q,Z.root,M,$.absolute),I=X(f);if(I)Q1(`matched ${f}`);return I}:(F,M)=>X(C1(F,q,Z.root,M,$.absolute))],exclude:$.debug?(F,M)=>{let f=C1(M,q,Z.root,!0,!0),I=f!=="."&&!Q(f)||W(f);if(I)Q1(`skipped ${M}`);else Q1(`crawling ${M}`);return I}:(F,M)=>{let f=C1(M,q,Z.root,!0,!0);return f!=="."&&!Q(f)||W(f)},pathSeparator:"/",relativePaths:!0,resolveSymlinks:!0};if($.deep)U.maxDepth=Math.round($.deep-Z.depthOffset);if($.absolute)U.relativePaths=!1,U.resolvePaths=!0,U.includeBasePath=!0;if($.followSymbolicLinks===!1)U.resolveSymlinks=!1,U.excludeSymlinks=!0;if($.onlyDirectories)U.excludeFiles=!0,U.includeDirs=!0;else if($.onlyFiles===!1)U.includeDirs=!0;Z.root=Z.root.replace(s1,"");let z=Z.root;if($.debug)Q1("internal properties:",Z);let G=new m$.fdir(U).crawl(z);if(q===z||$.absolute)return J?G.sync():G.withPromise();return J?u$(G.sync(),q,z):G.withPromise().then((F)=>u$(F,q,z))}async function l$($,q){if($&&(q==null?void 0:q.patterns))throw new Error("Cannot pass patterns as both an argument and an option");let J=Array.isArray($)||typeof $==="string"?{...q,patterns:$}:$,Z=J.cwd?p1.resolve(J.cwd).replace(s1,"/"):process.cwd().replace(s1,"/");return j5(J,Z,!1)}import{readdir as Y5}from"fs/promises";import{dirname as X5,extname as Q5,isAbsolute as W5,join as n$,resolve as i$}from"path";import s$ from"process";import{pathToFileURL as o1}from"url";async function o$($,q){await Bun.write($,q)}async function r1($){let q=$??t.root,J=await Y5(q,{withFileTypes:!0}),Z=await Promise.all(J.map((j)=>{let Y=n$(q,j.name);return j.isDirectory()?r1(Y):Y}));return Array.prototype.concat(...Z).filter((j)=>Q5(j)===".ts")}async function r$($){try{let q=$?.cwd||s$.cwd(),J=$?.tsconfigPath||n$(q,"tsconfig.json"),j=await import(o1(J).href);if(j.compilerOptions?.isolatedDeclarations===!0)return!0;if(j.extends){let Y=p$(J,j.extends),X=Y.endsWith(".json")?Y:`${Y}.json`,Q=await import(o1(X).href);if(Q.compilerOptions?.isolatedDeclarations===!0)return!0;if(Q.extends){let U=p$(X,Q.extends),z=U.endsWith(".json")?U:`${U}.json`;if((await import(o1(z).href)).compilerOptions?.isolatedDeclarations===!0)return!0}}return!1}catch(q){return!1}}function p$($,q){if(W5(q))return q;if(q.startsWith("."))return i$(X5($),q);return i$(s$.cwd(),"node_modules",q)}async function V5($){try{if(!await r$($)){console.error("Error: isolatedDeclarations must be set to true in your tsconfig.json. Ensure `tsc --noEmit` does not output any errors.");return}if($?.clean)await z5($.outdir,{recursive:!0,force:!0});let J=$?.cwd||K5.cwd(),Z;if($?.entrypoints)Z=await l$($.entrypoints,{cwd:$.root??`${J}/src`,absolute:!0});else Z=await r1($?.root??`${J}/src`);for(let j of Z){let Y=await Q0(j,$?.verbose);if(Y){let X=w5($?.root??"./src",j),W=F5(X),U=($?.outputStructure??"mirror")==="mirror"?a$($?.outdir??"./dist",W.dir,`${W.name}.d.ts`):a$($?.outdir??"./dist",`${W.name}.d.ts`);await U5(G5(U),{recursive:!0}),await o$(U,Y)}else console.warn(`No declarations extracted for ${j}`)}}catch(q){console.error("Error generating declarations:",q)}}async function H8($){await V5({...t,...$})}export{o$ as writeToFile,D5 as isFunctionType,T5 as isDeclarationComplete,r1 as getAllTypeScriptFiles,V5 as generateDeclarationsFromFiles,H8 as generate,Xq as extractDtsTypes,Q0 as extract,t as config,r$ as checkIsolatedDeclarations};
package/dist/types.d.ts CHANGED
@@ -7,6 +7,7 @@ export declare interface DtsGenerationConfig {
7
7
  clean: boolean
8
8
  tsconfigPath: string
9
9
  verbose: boolean | string[]
10
+ outputStructure?: 'mirror' | 'flat'
10
11
  }
11
12
  export declare type DtsGenerationOption = Partial<DtsGenerationConfig>
12
13