"use strict";var c=require("node:module"),F=require("node:fs"),u=require("get-tsconfig"),m=require("./index-CLWE53E9.cjs"),a=require("./is-relative-path-pattern-Cr3_Gkbv.cjs"),T=require("./client-DjommMgI.cjs"),p=require("node:path");const M=s=>{if(s.includes("import")||s.includes("export"))try{return m.parseEsm(s)[3]}catch{return!0}return!1},g=/\.[cm]?tsx?$/,l=process.env.TSX_TSCONFIG_PATH?{path:p.resolve(process.env.TSX_TSCONFIG_PATH),config:u.parseTsconfig(process.env.TSX_TSCONFIG_PATH)}:u.getTsconfig(),E=[".cts",".mts",".ts",".tsx",".jsx"],O=[".js",".cjs",".mjs"],j=l&&u.createFilesMatcher(l),d=Object.assign(Object.create(null),c._extensions),P=d[".js"],h=(s,e)=>{T.parent?.send&&T.parent.send({type:"dependency",path:e});const r=E.some(t=>e.endsWith(t)),o=O.some(t=>e.endsWith(t));if(!r&&!o)return P(s,e);let n=F.readFileSync(e,"utf8");if(e.endsWith(".cjs")){const t=m.transformDynamicImport(e,n);t&&(n=a.shouldApplySourceMap()?a.inlineSourceMap(t):t.code)}else if(r||M(n)){const t=m.transformSync(n,e,{tsconfigRaw:j?.(e)});n=a.shouldApplySourceMap()?a.inlineSourceMap(t):t.code}s._compile(n,e)};[".js",".ts",".tsx",".jsx"].forEach(s=>{d[s]=h}),Object.defineProperty(d,".mjs",{value:h,enumerable:!1});const b=`${p.sep}node_modules${p.sep}`,x=l&&u.createPathsMatcher(l),v=c._resolveFilename.bind(c),S=(s,e,r,o)=>{const n=a.resolveTsPath(s);if(e?.filename&&(g.test(e.filename)||l?.config.compilerOptions?.allowJs)&&n)for(const t of n)try{return v(t,e,r,o)}catch(f){const{code:i}=f;if(i!=="MODULE_NOT_FOUND"&&i!=="ERR_PACKAGE_PATH_NOT_EXPORTED")throw f}},y=(s,e,r,o)=>{const n=s.indexOf("?");if(n!==-1&&(s=s.slice(0,n)),x&&!a.isRelativePathPattern.test(s)&&!e?.filename?.includes(b)){const f=x(s);for(const i of f){const _=S(i,e,r,o);if(_)return _;try{return v(i,e,r,o)}catch{}}}const t=S(s,e,r,o);return t||v(s,e,r,o)},A=()=>{const{sourceMapsEnabled:s}=process,{_extensions:e,_resolveFilename:r}=c;return process.setSourceMapsEnabled(!0),c._extensions=d,c._resolveFilename=y,()=>{s===!1&&process.setSourceMapsEnabled(!1),c._extensions=e,c._resolveFilename=r}};exports.register=A,exports.resolveFilename=y;
