"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var ae=require("path"),ge=require("fs"),me=require("module"),ke=require("resolve-pkg-maps");function V(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var c=V(ae),M=V(ge),be=V(me);function _(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}const y=e=>{const l=M.default[e];return function(i,...n){const t=`${e}:${n.join(":")}`;let o=i==null?void 0:i.get(t);return o===void 0&&(o=Reflect.apply(l,M.default,n),i==null||i.set(t,o)),o}},$=y("existsSync"),ve=y("realpathSync"),Te=y("readFileSync"),P=y("statSync"),Y=(e,l,i)=>{for(;;){const n=c.default.posix.join(e,l);if($(i,n))return n;const t=c.default.dirname(e);if(t===e)return;e=t}},S=/^\.{1,2}(\/.*)?$/,W=e=>{const l=_(e);return S.test(l)?l:`./${l}`};function we(e,l=!1){const i=e.length;let n=0,t="",o=0,s=16,p=0,f=0,b=0,g=0,v=0;function L(u,a){let r=0,A=0;for(;r=48&&O<=57)A=A*16+O-48;else if(O>=65&&O<=70)A=A*16+O-65+10;else if(O>=97&&O<=102)A=A*16+O-97+10;else break;n++,r++}return r=i){u+=e.substring(a,n),v=2;break}const r=e.charCodeAt(n);if(r===34){u+=e.substring(a,n),n++;break}if(r===92){if(u+=e.substring(a,n),n++,n>=i){v=2;break}switch(e.charCodeAt(n++)){case 34:u+='"';break;case 92:u+="\\";break;case 47:u+="/";break;case 98:u+="\b";break;case 102:u+="\f";break;case 110:u+=` `;break;case 114:u+="\r";break;case 116:u+=" ";break;case 117:const O=L(4,!0);O>=0?u+=String.fromCharCode(O):v=4;break;default:v=5}a=n;continue}if(r>=0&&r<=31)if(N(r)){u+=e.substring(a,n),v=2;break}else v=6;n++}return u}function j(){if(t="",v=0,o=n,f=p,g=b,n>=i)return o=i,s=17;let u=e.charCodeAt(n);if(J(u)){do n++,t+=String.fromCharCode(u),u=e.charCodeAt(n);while(J(u));return s=15}if(N(u))return n++,t+=String.fromCharCode(u),u===13&&e.charCodeAt(n)===10&&(n++,t+=` `),p++,b=n,s=14;switch(u){case 123:return n++,s=1;case 125:return n++,s=2;case 91:return n++,s=3;case 93:return n++,s=4;case 58:return n++,s=6;case 44:return n++,s=5;case 34:return n++,t=k(),s=10;case 47:const a=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n=12&&u<=15);return u}return{setPosition:T,getPosition:()=>n,scan:l?B:j,getToken:()=>s,getTokenValue:()=>t,getTokenOffset:()=>o,getTokenLength:()=>n-o,getTokenStartLine:()=>f,getTokenStartCharacter:()=>o-g,getTokenError:()=>v}}function J(e){return e===32||e===9}function N(e){return e===10||e===13}function F(e){return e>=48&&e<=57}var Z;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"})(Z||(Z={}));var x;(function(e){e.DEFAULT={allowTrailingComma:!1}})(x||(x={}));function Oe(e,l=[],i=x.DEFAULT){let n=null,t=[];const o=[];function s(f){Array.isArray(t)?t.push(f):n!==null&&(t[n]=f)}return de(e,{onObjectBegin:()=>{const f={};s(f),o.push(t),t=f,n=null},onObjectProperty:f=>{n=f},onObjectEnd:()=>{t=o.pop()},onArrayBegin:()=>{const f=[];s(f),o.push(t),t=f,n=null},onArrayEnd:()=>{t=o.pop()},onLiteralValue:s,onError:(f,b,g)=>{l.push({error:f,offset:b,length:g})}},i),t[0]}function de(e,l,i=x.DEFAULT){const n=we(e,!1),t=[];function o(m){return m?()=>m(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function s(m){return m?()=>m(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>t.slice()):()=>!0}function p(m){return m?d=>m(d,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function f(m){return m?d=>m(d,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>t.slice()):()=>!0}const b=s(l.onObjectBegin),g=f(l.onObjectProperty),v=o(l.onObjectEnd),L=s(l.onArrayBegin),T=o(l.onArrayEnd),w=f(l.onLiteralValue),k=p(l.onSeparator),j=o(l.onComment),E=p(l.onError),B=i&&i.disallowComments,u=i&&i.allowTrailingComma;function a(){for(;;){const m=n.scan();switch(n.getTokenError()){case 4:r(14);break;case 5:r(15);break;case 3:r(13);break;case 1:B||r(11);break;case 2:r(12);break;case 6:r(16);break}switch(m){case 12:case 13:B?r(10):j();break;case 16:r(1);break;case 15:case 14:break;default:return m}}}function r(m,d=[],X=[]){if(E(m),d.length+X.length>0){let U=n.getToken();for(;U!==17;){if(d.indexOf(U)!==-1){a();break}else if(X.indexOf(U)!==-1)break;U=a()}}}function A(m){const d=n.getTokenValue();return m?w(d):(g(d),t.push(d)),a(),!0}function O(){switch(n.getToken()){case 11:const m=n.getTokenValue();let d=Number(m);isNaN(d)&&(r(2),d=0),w(d);break;case 7:w(null);break;case 8:w(!0);break;case 9:w(!1);break;default:return!1}return a(),!0}function re(){return n.getToken()!==10?(r(3,[],[2,5]),!1):(A(!1),n.getToken()===6?(k(":"),a(),h()||r(4,[],[2,5])):r(5,[],[2,5]),t.pop(),!0)}function ce(){b(),a();let m=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(m||r(4,[],[]),k(","),a(),n.getToken()===2&&u)break}else m&&r(6,[],[]);re()||r(4,[],[2,5]),m=!0}return v(),n.getToken()!==2?r(7,[2],[]):a(),!0}function pe(){L(),a();let m=!0,d=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(d||r(4,[],[]),k(","),a(),n.getToken()===4&&u)break}else d&&r(6,[],[]);m?(t.push(0),m=!1):t[t.length-1]++,h()||r(4,[],[4,5]),d=!0}return T(),m||t.pop(),n.getToken()!==4?r(8,[4],[]):a(),!0}function h(){switch(n.getToken()){case 3:return pe();case 1:return ce();case 10:return A(!0);default:return O()}}return a(),n.getToken()===17?i.allowEmptyContent?!0:(r(4,[],[]),!1):h()?(n.getToken()!==17&&r(9,[],[]),!0):(r(4,[],[]),!1)}var K;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(K||(K={}));var C;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(C||(C={}));const je=Oe;var ee;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(ee||(ee={}));const ne=(e,l)=>je(Te(l,e,"utf8")),Ae=()=>{const{findPnpApi:e}=be.default;return e&&e(process.cwd())},R=(e,l,i,n)=>{const t=`resolveFromPackageJsonPath:${e}:${l}:${i}`;if(n!=null&&n.has(t))return n.get(t);const o=ne(e,n);if(!o)return;let s=l||"tsconfig.json";if(!i&&o.exports)try{const[p]=ke.resolveExports(o.exports,l,["require","types"]);s=p}catch{return!1}else!l&&o.tsconfig&&(s=o.tsconfig);return s=c.default.join(e,"..",s),n==null||n.set(t,s),s},G="package.json",z="tsconfig.json",_e=(e,l,i)=>{let n=e;if(e===".."&&(n=c.default.join(n,z)),e[0]==="."&&(n=c.default.resolve(l,n)),c.default.isAbsolute(n)){if($(i,n)){if(P(i,n).isFile())return n}else if(!n.endsWith(".json")){const T=`${n}.json`;if($(i,T))return T}return}const[t,...o]=e.split("/"),s=t[0]==="@"?`${t}/${o.shift()}`:t,p=o.join("/"),f=Ae();if(f){const{resolveRequest:T}=f;try{if(s===e){const w=T(c.default.join(s,G),l);if(w){const k=R(w,p,!1,i);if(k&&$(i,k))return k}}else{let w;try{w=T(e,l,{extensions:[".json"]})}catch{w=T(c.default.join(e,z),l)}if(w)return w}}catch{}}const b=Y(l,c.default.join("node_modules",s),i);if(!b||!P(i,b).isDirectory())return;const g=c.default.join(b,G);if($(i,g)){const T=R(g,p,!1,i);if(T===!1)return;if(T&&$(i,T)&&P(i,T).isFile())return T}const v=c.default.join(b,p),L=v.endsWith(".json");if(!L){const T=`${v}.json`;if($(i,T))return T}if($(i,v)){if(P(i,v).isDirectory()){const T=c.default.join(v,G);if($(i,T)){const k=R(T,"",!0,i);if(k&&$(i,k))return k}const w=c.default.join(v,z);if($(i,w))return w}else if(L)return v}},$e=(e,l,i,n)=>{const t=_e(e,l,n);if(!t)throw new Error(`File '${e}' not found.`);if(i.has(t))throw new Error(`Circularity detected while resolving configuration: ${t}`);i.add(t);const o=c.default.dirname(t),s=te(t,n,i);delete s.references;const{compilerOptions:p}=s;if(p){const f=["baseUrl","outDir"];for(const b of f){const g=p[b];g&&(p[b]=_(c.default.relative(l,c.default.join(o,g)))||"./")}}return s.files&&(s.files=s.files.map(f=>_(c.default.relative(l,c.default.join(o,f))))),s.include&&(s.include=s.include.map(f=>_(c.default.relative(l,c.default.join(o,f))))),s.exclude&&(s.exclude=s.exclude.map(f=>_(c.default.relative(l,c.default.join(o,f))))),s},te=(e,l,i=new Set)=>{let n;try{n=ve(l,e)}catch{throw new Error(`Cannot resolve tsconfig at path: ${e}`)}let t=ne(n,l)||{};if(typeof t!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${e}`);const o=c.default.dirname(n);if(t.extends){const s=Array.isArray(t.extends)?t.extends:[t.extends];delete t.extends;for(const p of s.reverse()){const f=$e(p,o,i,l),b={...f,...t,compilerOptions:{...f.compilerOptions,...t.compilerOptions}};f.watchOptions&&(b.watchOptions={...f.watchOptions,...t.watchOptions}),t=b}}if(t.compilerOptions){const{compilerOptions:s}=t,p=["baseUrl","rootDir"];for(const b of p){const g=s[b];if(g){const v=c.default.resolve(o,g),L=W(c.default.relative(o,v));s[b]=L}}const{outDir:f}=s;f&&(Array.isArray(t.exclude)||(t.exclude=[]),t.exclude.includes(f)||t.exclude.push(f),s.outDir=W(f))}else t.compilerOptions={};if(t.files&&(t.files=t.files.map(W)),t.include&&(t.include=t.include.map(_)),t.watchOptions){const{watchOptions:s}=t;s.excludeDirectories&&(s.excludeDirectories=s.excludeDirectories.map(p=>_(c.default.resolve(o,p))))}return t},ie=(e,l=new Map)=>te(e,l),Le=(e=process.cwd(),l="tsconfig.json",i=new Map)=>{const n=Y(_(e),l,i);if(!n)return null;const t=ie(n,i);return{path:n,config:t}},Ee=/\*/g,le=(e,l)=>{const i=e.match(Ee);if(i&&i.length>1)throw new Error(l)},Be=e=>{if(e.includes("*")){const[l,i]=e.split("*");return{prefix:l,suffix:i}}return e},Fe=({prefix:e,suffix:l},i)=>i.startsWith(e)&&i.endsWith(l),Ne=(e,l,i)=>Object.entries(e).map(([n,t])=>(le(n,`Pattern '${n}' can have at most one '*' character.`),{pattern:Be(n),substitutions:t.map(o=>{if(le(o,`Substitution '${o}' in pattern '${n}' can have at most one '*' character.`),!l&&!S.test(o))throw new Error("Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?");return c.default.resolve(i,o)})})),Ue=e=>{if(!e.config.compilerOptions)return null;const{baseUrl:l,paths:i}=e.config.compilerOptions;if(!l&&!i)return null;const n=c.default.resolve(c.default.dirname(e.path),l||"."),t=i?Ne(i,l,n):[];return o=>{if(S.test(o))return[];const s=[];for(const g of t){if(g.pattern===o)return g.substitutions.map(_);typeof g.pattern!="string"&&s.push(g)}let p,f=-1;for(const g of s)Fe(g.pattern,o)&&g.pattern.prefix.length>f&&(f=g.pattern.prefix.length,p=g);if(!p)return l?[_(c.default.join(n,o))]:[];const b=o.slice(p.pattern.prefix.length,o.length-p.pattern.suffix.length);return p.substitutions.map(g=>_(g.replace("*",b)))}},se=e=>{let l="";for(let i=0;iMath.floor(Math.random()*26),Ie=e=>Array.from({length:e},()=>String.fromCodePoint(xe()+(Math.random()>.5?ye:Pe))).join(""),De=(e=M.default)=>{const l=process.execPath;if(e.existsSync(l))return!e.existsSync(se(l));const i=`/${Ie(10)}`;e.writeFileSync(i,"");const n=!e.existsSync(se(i));return e.unlinkSync(i),n},{join:I}=c.default.posix,Q={ts:[".ts",".tsx",".d.ts"],cts:[".cts",".d.cts"],mts:[".mts",".d.mts"]},he=e=>{const l=[...Q.ts],i=[...Q.cts],n=[...Q.mts];return e!=null&&e.allowJs&&(l.push(".js",".jsx"),i.push(".cjs"),n.push(".mjs")),[...l,...i,...n]},Ve=e=>{const l=[];if(!e)return l;const{outDir:i,declarationDir:n}=e;return i&&l.push(i),n&&l.push(n),l},oe=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Me=["node_modules","bower_components","jspm_packages"],H=`(?!(${Me.join("|")})(/|$))`,Se=/(?:^|\/)[^.*?]+$/,ue="**/*",D="[^/]",q="[^./]",fe=process.platform==="win32",We=({config:e,path:l},i=De())=>{if("extends"in e)throw new Error("tsconfig#extends must be resolved. Use getTsconfig or parseTsconfig to resolve it.");if(!c.default.isAbsolute(l))throw new Error("The tsconfig path must be absolute");fe&&(l=_(l));const n=c.default.dirname(l),{files:t,include:o,exclude:s,compilerOptions:p}=e,f=t==null?void 0:t.map(k=>I(n,k)),b=he(p),g=i?"":"i",L=(s||Ve(p)).map(k=>{const j=I(n,k),E=oe(j).replace(/\\\*\\\*\//g,"(.+/)?").replace(/\\\*/g,`${D}*`).replace(/\\\?/g,D);return new RegExp(`^${E}($|/)`,g)}),T=t||o?o:[ue],w=T?T.map(k=>{let j=I(n,k);Se.test(j)&&(j=I(j,ue));const E=oe(j).replace(/\/\\\*\\\*/g,`(/${H}${q}${D}*)*?`).replace(/(\/)?\\\*/g,(B,u)=>{const a=`(${q}|(\\.(?!min\\.js$))?)*`;return u?`/${H}${q}${a}`:a}).replace(/(\/)?\\\?/g,(B,u)=>{const a=D;return u?`/${H}${a}`:a});return new RegExp(`^${E}$`,g)}):void 0;return k=>{if(!c.default.isAbsolute(k))throw new Error("filePath must be absolute");if(fe&&(k=_(k)),f!=null&&f.includes(k))return e;if(!(!b.some(j=>k.endsWith(j))||L.some(j=>j.test(k)))&&w&&w.some(j=>j.test(k)))return e}};exports.createFilesMatcher=We,exports.createPathsMatcher=Ue,exports.getTsconfig=Le,exports.parseTsconfig=ie;