var Kt=Object.defineProperty;var i=(t,r)=>Kt(t,"name",{value:r,configurable:!0});import Dt from"node:crypto";import j from"node:module";import{MessageChannel as Yt}from"node:worker_threads";import{i as F,e as k,b as Zt,m as kt}from"./temporary-directory-Du7LpLp9.mjs";import{l as ht,a as gt,g as te,b as ee,d as B,e as u,f as tt,h as v,j as A,p as yt,k as y,m as re,n as se,o as et,q,s as Pt,w as St,u as Ut,v as Q,x as W,y as vt,z as ne}from"./require-CBjy4Foe.mjs";import{pathToFileURL as S,fileURLToPath as w}from"node:url";import{readFileSync as oe,existsSync as ae}from"node:fs";import{readFile as ie}from"node:fs/promises";import{p as ce,i as Rt,a as H,b as me,c as wt,t as It,r as rt}from"./index-DE3OBZuV.mjs";import U from"node:path";const de=i(()=>({active:!0,parsedTsconfig:void 0}),"createDefaultData"),Tt=i(t=>{const r={active:!0,namespace:t?.namespace,onImport:t?.onImport,parsedTsconfig:void 0,port:t?.port,tsconfig:t?.tsconfig};return t?.tsconfig!==!1&&(r.parsedTsconfig=ht(t?.tsconfig??process.env.TSX_TSCONFIG_PATH)),r},"createData"),le=i(t=>async r=>{if(!r)throw new Error(`tsx must be loaded with --import instead of --loader The --loader flag was deprecated in Node v20.6.0 and v18.19.0`);Object.assign(t,Tt(r)),r.port&&r.port.on("message",e=>{e==="deactivate"&&(t.active=!1,r.port.postMessage({type:"deactivated"}))})},"createInitialize"),ue=i(t=>()=>(t.parsedTsconfig=ht(process.env.TSX_TSCONFIG_PATH),"process.setSourceMapsEnabled(true);"),"createGlobalPreload"),fe=i(t=>{const{pathname:r}=new URL(t),e=U.extname(r);if(e===".mts"||e===".mjs")return"module";if(e===".cts"||e===".cjs")return"commonjs";if(e===".js"||gt.includes(e))return ee(t)},"getFormatFromFileUrl"),pe=i(t=>{const{pathname:r}=new URL(t),e=U.extname(r);if(e===".mts"||e===".mjs")return"module";if(e===".cts"||e===".cjs")return"commonjs";if(e===".js"||gt.includes(e))return te(t)},"getFormatFromFileUrlSync"),st="tsx-namespace",I=`${st}=`,O="tsx-commonjs-export-preparse",he=`${O}=1`,E="tsx-commonjs-virtual-query",$=new Map,ge=/^data:/i,T=i(t=>ge.test(t),"isDataUrl"),nt=i((t,r)=>t.slice(1).split("&").filter(e=>e&&r.every(s=>!e.startsWith(s))).join("&"),"getQueryWithoutParameters"),G=i((t,r)=>{const e=nt(t,r);return e?`?${e}`:""},"getSearchWithoutParameters"),ye=i(t=>t.replaceAll(/\/\*[\s\S]*?\*\/|\/\/[^\n\r]*/g,""),"stripComments"),Pe=i(t=>{const r=ye(t);if(/^\s*export\s*\*/.test(r))return"named";if(/^\s*import\s*\*\s*as\s+[\w$]+/.test(r))return"namespace";const e=r.match(/\{([^}]*)\}/)?.[1];if(e)return e.split(",").some(s=>{const n=s.trim().split(/\s+as\s+/)[0];return!!(n&&n!=="default")})?"named":void 0},"getCommonJsImportBinding"),Se=i((t,r,e)=>{const s=$.get(t);if(!s)return!1;try{const[n]=ce(s);return n.some(o=>{if(o.d!==-1||o.n!==r)return!1;const c=Pe(s.slice(o.ss,o.s));return c==="named"||e&&c==="namespace"})}catch{return!1}},"parentImportsCommonJsExports"),R=i(t=>{const r=t.indexOf("?"),e=t.indexOf("#");if(T(t)){if(e===-1)return;const s=t.slice(e+1),n=s.lastIndexOf("&"),o=s.slice(n+1);return o.startsWith(I)?o.slice(I.length):void 0}if(!(r===-1||e!==-1&&et==="commonjs"||t==="commonjs-typescript","isCommonJsFormat"),Et=i(t=>t==="module-typescript"||t==="typescript","isModuleTypeScriptFormat"),Ue=F(k),ve=[`${E}=`],x=[`${O}=`,`${E}=`],L=i((t,r)=>r.parsedTsconfig&&se(r.parsedTsconfig,t)?r.parsedTsconfig.config:void 0,"getTsconfigRaw"),ot=i((t,r)=>{const e=r?`${t}?namespace=${encodeURIComponent(r)}`:S(t).toString();return`require = require("node:module").createRequire(${JSON.stringify(e)});`},"getCjsRequireBanner"),Re=i(t=>{if(!t.searchParams.has(E))return;const{pathname:r}=t,e=r.toLowerCase().lastIndexOf("%3f");if(e===-1)return;const s=new URL(t);return s.pathname=r.slice(0,e),s.search="",w(s)},"getFilePathFromVirtualQuery"),at=i(t=>{const r=t.startsWith(y)?new URL(t):void 0,e=r?w(r):t,s=r&&Re(r),n=s||e,o=r&&s?S(n).toString()+G(r.search,ve):t;return{fileUrl:r,filePath:n,loadUrl:o}},"getFileLoadContext"),Ft=i((t,r)=>{if(!r?.search)return t;const e=G(r.search,x);return e?S(t).toString()+e:t},"getTransformPath"),Wt=i((t,r,e)=>{const s=[...r?nt(r.search,[I,...x]).split("&").filter(Boolean):[],...e?[`namespace=${encodeURIComponent(e)}`]:[]].join("&");return s?`${t}?${s}`:t},"getFilePathWithQuery"),we=new TextDecoder,Ot=i(t=>typeof t=="string"?t:we.decode(t),"decodeSource"),Ie=i((t,r)=>{const e=new URL(r),s=r.startsWith(y)?at(r).filePath:void 0;if(T(r)){if(t.namespace){const o=`${I}${t.namespace}`;e.hash===`#${o}`?e.hash="":e.hash.endsWith(`&${o}`)&&(e.hash=e.hash.slice(0,-o.length-1))}}else e.searchParams.delete("tsx-namespace"),e.searchParams.delete(O),e.searchParams.delete(E);s&&(e.pathname=new URL(S(s)).pathname);const n=e.toString();return t.port&&t.port.postMessage({type:"load",url:n}),t.onImport?.(n),n},"notifyLoad"),$t=i((t,r)=>{if(!t.active)return!1;const e=R(r);if(t.namespace!==e)return!1;const s=Ie(t,r);return yt.send&&yt.send({type:"dependency",path:s}),!0},"prepareLoad"),Ct=i((t,r)=>{if(!re.test(t))return r;const e=r[Lt];return e?.type?r:{...r,[Lt]:{...e,type:"json"}}},"prepareJsonAttributes"),it=i(({conditions:t})=>t?.includes("require")===!0&&!t.includes("import"),"isCommonJsRequireContext$1"),Te=i(t=>{const r=i(async(e,s,n)=>{if(!$t(t,e))return n(e,s);const o=R(e),{fileUrl:c,filePath:a,loadUrl:l}=at(e),f=Ct(l,s),d=await n(l,f);u(3,"loaded by next loader",{url:e,loadUrl:l,loaded:d});const h=c?.searchParams.has(O)===!0,m=d.format,g=c?new URL(S(a)):void 0;if(g&&c&&(g.search=G(c.search,x)),jt(m)&&c&&d.responseURL?.startsWith("file:")&&!a.endsWith(".cjs")){const P=await ie(S(a),"utf8"),M=Rt(P);if(m==="commonjs-typescript"||!a.endsWith(".js")||M){if(!Ue){if(h&&M&&et.test(a)){const _=await It(P,a,{define:{"import.meta.url":JSON.stringify(g.toString())},tsconfigRaw:L(a,t)});return $.set(e,_.code),{format:"module",source:v(_)}}return d}if(!o&&!h&&!a.endsWith(".cts"))return d;const ft=!!(o||h||G(c.search,x)),pt=H(P,Ft(a,c),{cjsBanner:ft?ot(a,o):void 0,tsconfigRaw:L(a,t)});if(d.format="commonjs",d.source=v(pt),ft){const _=Wt(a,c,o);d.responseURL=`data:text/javascript,${encodeURIComponent(pt.code)}?filePath=${encodeURIComponent(_)}`}return u(3,"returning CJS export annotation",d),d}}if(!d.source)return d;const p=Ot(d.source),N=m==="json"&&!it(s);if(m==="commonjs-typescript"){const P=H(p,a,{tsconfigRaw:L(a,t)});return{...d,format:"commonjs",source:v(P)}}if(N||Et(m)||A.test(e)){const P=await It(p,a,{tsconfigRaw:L(a,t)});return $.set(e,P.code),{format:"module",source:v(P)}}if(d.format==="module"){const P=wt(a,p);P?(d.source=v(P),$.set(e,P.code)):$.set(e,p)}return d},"load");return B?async(e,s,n)=>{u(2,"load",{url:e,context:s});const o=await r(e,s,n);return u(1,"loaded",{url:e,result:o}),o}:r},"createLoad"),Le=i(t=>{const r=i((e,s,n)=>{if(it(s)&&tt()||!$t(t,e))return n(e,s);const o=R(e),{fileUrl:c,filePath:a,loadUrl:l}=at(e),f=Ct(l,s),d=n(l,f);u(3,"loaded by next loader",{url:e,loadUrl:l,loaded:d});const h=d.format;if(jt(h)&&F(k)&&d.responseURL?.startsWith("file:")&&!a.endsWith(".cjs")){const p=oe(S(a),"utf8");if(h==="commonjs-typescript"||!a.endsWith(".js")||Rt(p)){const N=!o&&tt(),P=H(p,Ft(a,c),{cjsBanner:o?ot(a,o):void 0,tsconfigRaw:L(a,t)}),M=Wt(a,c,o);return d.format="commonjs",d.shouldBeReloadedByCJSLoader=N,d.source=v(P),N||(d.responseURL=`data:text/javascript,${encodeURIComponent(P.code)}?filePath=${encodeURIComponent(M)}`),u(3,"returning CJS export annotation",d),d}}if(!d.source)return d;const m=Ot(d.source),g=h==="json"&&!it(s);if(h==="commonjs-typescript"){const p=H(m,a,{cjsBanner:o?ot(a,o):void 0,tsconfigRaw:L(a,t)});return{...d,format:"commonjs",shouldBeReloadedByCJSLoader:!1,source:v(p)}}if(g||Et(h)||A.test(e)){const p=me(m,a,{tsconfigRaw:L(a,t)});return{format:"module",source:v(p)}}if(d.format==="module"){const p=wt(a,m);p&&(d.source=v(p))}return d},"load");return B?(e,s,n)=>{u(2,"loadSync",{url:e,context:s});const o=r(e,s,n);return u(1,"loadedSync",{url:e,result:o}),o}:r},"createLoadSync"),je=i(t=>{if(q(t)||t.startsWith("#")||t.includes(":"))return!1;const r=t.split("/"),e=r[0]?.startsWith("@")?2:1;return r.length>e&&r.slice(0,e).every(Boolean)},"isBarePackageSubpath"),Ee=i(t=>{const r=t.lastIndexOf(Pt);if(r===-1)return;const s=t.slice(r+Pt.length).split(U.sep),n=s[0]?.startsWith("@")?2:1;if(!(s.length<=n||!s[n-1]))return U.join(t.slice(0,r),"node_modules",...s.slice(0,n))},"getPackageDirectory"),bt=i((t,r)=>{if(!je(t)||!r.startsWith(y))return;const e=w(r),s=Ee(e);if(!s)return;const o=rt(U.join(s,"package.json"))?.exports;if(o!=null)return{kind:"root-exports"};const c=rt(U.join(e,"package.json"));return typeof c?.main!="string"||!c.main?{kind:"legacy-directory"}:{kind:"legacy-directory",mainUrl:S(U.resolve(e,c.main)).toString()}},"getPackageSubpathDirectoryInfo"),Fe=F(k),Jt=/^(?:[a-z][\d+.a-z-]*:\/\/|data:|file:|node:)/i,Nt=i(t=>!q(t)&&!Jt.test(t),"isTsconfigPathAliasSpecifier"),z=i(t=>{if(t.url)return t.url;const r=t.message.match(/^Cannot find module '([^']+)'/);if(r){const[,s]=r;return s}const e=t.message.match(/^Cannot find package '([^']+)'/);if(e){const[,s]=e;if(!U.isAbsolute(s))return;const n=S(s);if(n.pathname.endsWith("/")&&(n.pathname+="package.json"),n.pathname.endsWith("/package.json")){const o=rt(n);if(o?.main)return new URL(o.main,n).toString()}else return n.toString()}},"getMissingPathFromNotFound"),C=i(t=>t==="ERR_MODULE_NOT_FOUND"||t==="MODULE_NOT_FOUND","isModuleNotFound"),X=i(t=>t instanceof Error&&(C(t.code)||t.code==="ERR_UNSUPPORTED_DIR_IMPORT"),"isDirectoryEntryMiss"),V=i(t=>t.conditions.includes("require")&&!t.conditions.includes("import"),"isCommonJsRequireContext"),ct=i(t=>{const r=t.indexOf("?"),e=t.indexOf("#");return r===-1?e:e===-1?r:Math.min(r,e)},"getUrlMetadataIndex"),Mt=i((t,r)=>r||!q(t)&&!Jt.test(t)?t.indexOf("?"):ct(t),"getSpecifierMetadataIndex"),_t=i(t=>{if(t?.startsWith(y))return w(new URL(t))},"getParentFilePath"),We=i(t=>{if(!t)return!1;const r=_t(t);if(r)return A.test(r);const e=ct(t);return A.test(e===-1?t:t.slice(0,e))},"isTypeScriptParent"),b=i(t=>{const r=_t(t);return r!==void 0&&Ut(r)},"isParentDependency"),Bt=i(t=>U.extname(new URL(t).pathname)===".js"&&Ut(w(t)),"isImplicitJavaScriptDependency"),At=i((t,r)=>We(t)||r&&!b(t),"resolvesTsExtensions"),Oe=i((t,r)=>{const e=ct(t),s=e===-1?t:t.slice(0,e);try{if(s.startsWith(y))return w(s);if(U.isAbsolute(s))return s;if(W(s)&&r?.startsWith(y))return w(new URL(s,r))}catch{}},"getProbeFilePath"),qt=i((t,r)=>{const e=Oe(t,r);return e!==void 0&&!ae(e)},"candidateDoesntExist"),K=i(async(t,r,e,s)=>{const n=vt(t);if(u(3,"resolveExtensions",{url:t,context:r,throwError:s,tryPaths:n}),!n)return;let o;for(const c of n)if(!qt(c,r.parentURL))try{return await e(c,r)}catch(a){const{code:l}=a;if(!C(l)&&l!=="ERR_PACKAGE_PATH_NOT_EXPORTED")throw a;o=a}if(s){if(o===void 0)return e(n[0],r);throw o}},"resolveExtensions"),J=i((t,r,e,s)=>{const n=vt(t);if(u(3,"resolveExtensionsSync",{url:t,context:r,throwError:s,tryPaths:n}),!n)return;let o;for(const c of n)if(!qt(c,r.parentURL))try{return e(c,r)}catch(a){const{code:l}=a;if(!C(l)&&l!=="ERR_PACKAGE_PATH_NOT_EXPORTED")throw a;o=a}if(s){if(o===void 0)return e(n[0],r);throw o}},"resolveExtensionsSync"),$e=i(async(t,r,e,s)=>{const n=s.parsedTsconfig?.config.compilerOptions?.allowJs??!1,o=At(r.parentURL,n);if(u(3,"resolveBase",{specifier:t,context:r,specifierStartsWithFileUrl:t.startsWith(y),isRelativePath:W(t),resolveTsExtensions:o,allowJs:n}),(t.startsWith(y)||W(t))&&o){const c=await K(t,r,e,void 0);if(u(3,"resolveBase resolved",{specifier:t,context:r,resolved:c}),c)return c}try{return await e(t,r)}catch(c){if(u(3,"resolveBase error",{specifier:t,context:r,error:c}),c instanceof Error){const a=c;if(C(a.code)){const l=z(a);if(l){const f=await K(l,r,e,void 0);if(f)return f}}}throw c}},"resolveBase"),mt=i((t,r,e,s)=>{const n=s.parsedTsconfig?.config.compilerOptions?.allowJs??!1,o=At(r.parentURL,n);if(u(3,"resolveBaseSync",{specifier:t,context:r,specifierStartsWithFileUrl:t.startsWith(y),isRelativePath:W(t),resolveTsExtensions:o,allowJs:n}),(t.startsWith(y)||W(t))&&o){const c=J(t,r,e,void 0);if(u(3,"resolveBaseSync resolved",{specifier:t,context:r,resolved:c}),c)return c}try{return e(t,r)}catch(c){if(u(3,"resolveBaseSync error",{specifier:t,context:r,error:c}),c instanceof Error){const a=c;if(C(a.code)){const l=z(a);if(l){const f=J(l,r,e,void 0);if(f)return f}}}throw c}},"resolveBaseSync"),dt=i(async(t,r,e,s)=>{if(u(3,"resolveDirectory",{specifier:t,context:r,isDirectory:Q.test(t)}),(t==="."||t===".."||t.endsWith("/.."))&&(t+="/"),Q.test(t)){const n=new URL(t,r.parentURL);return n.pathname=U.join(n.pathname,"index"),await K(n.toString(),r,e,!0)}try{return await $e(t,r,e,s)}catch(n){if(n instanceof Error){u(3,"resolveDirectory error",{specifier:t,context:r,error:n});const o=n;if(o.code==="ERR_UNSUPPORTED_DIR_IMPORT"){const c=z(o);if(c){if(t.startsWith("#"))throw n;const a=bt(t,c);if(a?.kind==="root-exports")throw n;if(a?.mainUrl){try{return await e(a.mainUrl,r)}catch(d){if(!X(d))throw d}try{return await dt(a.mainUrl,r,e,s)}catch(d){if(!X(d))throw d}}const l=`${c}/index`,f=await K(l,r,e);if(f)return f}}}throw n}},"resolveDirectory"),lt=i((t,r,e,s)=>{if(u(3,"resolveDirectorySync",{specifier:t,context:r,isDirectory:Q.test(t)}),(t==="."||t===".."||t.endsWith("/.."))&&(t+="/"),Q.test(t)){const n=V(r);if(n&&!q(t))return mt(t,r,e,s);const o=new URL(t,r.parentURL);return o.pathname=U.join(o.pathname,"index"),n?J(w(o),r,e,!1)??mt(t,r,e,s):J(o.toString(),r,e,!0)}try{return mt(t,r,e,s)}catch(n){if(n instanceof Error){u(3,"resolveDirectorySync error",{specifier:t,context:r,error:n});const o=n;if(o.code==="ERR_UNSUPPORTED_DIR_IMPORT"){const c=z(o);if(c){if(t.startsWith("#"))throw n;const a=bt(t,c);if(a?.kind==="root-exports")throw n;if(a?.mainUrl){try{return e(a.mainUrl,r)}catch(d){if(!X(d))throw d}try{return lt(a.mainUrl,r,e,s)}catch(d){if(!X(d))throw d}}const l=`${c}/index`,f=J(l,r,e);if(f)return f}}}throw n}},"resolveDirectorySync"),Ce=i(async(t,r,e,s)=>{const n=Nt(t);if(u(3,"resolveTsPaths",{specifier:t,context:r,tsconfigPathAliasSpecifier:n,tsconfig:s.parsedTsconfig,fromNodeModules:b(r.parentURL)}),n&&s.parsedTsconfig&&!b(r.parentURL)){const o=St(s.parsedTsconfig,t);u(3,"resolveTsPaths",{possiblePaths:o});for(const c of o)try{return await dt(S(c).toString(),r,e,s)}catch{}}return dt(t,r,e,s)},"resolveTsPaths"),be=i((t,r,e,s)=>{const n=Nt(t);if(u(3,"resolveTsPathsSync",{specifier:t,context:r,tsconfigPathAliasSpecifier:n,tsconfig:s.parsedTsconfig,fromNodeModules:b(r.parentURL)}),n&&s.parsedTsconfig&&!b(r.parentURL)){const o=St(s.parsedTsconfig,t);u(3,"resolveTsPathsSync",{possiblePaths:o});for(const c of o)try{return lt(S(c).toString(),r,e,s)}catch{}}return lt(t,r,e,s)},"resolveTsPathsSync"),D="tsx://",ut=i((t,r)=>{const e=t.indexOf("#"),s=e===-1?t:t.slice(0,e),n=e===-1?"":t.slice(e);return`${s}${s.includes("?")?"&":"?"}${r}${n}`},"addQuery"),Y=i((t,r)=>T(t)?`${t}${t.includes("#")?"&":"#"}${I}${r}`:ut(t,`${I}${r}`),"addNamespace"),Qt=i((t,r)=>{const e=r.indexOf("#"),s=r[0]==="?"?r.slice(1,e===-1?void 0:e):"",n=e===-1?"":r.slice(e),o=t.indexOf("#"),c=o===-1?t:t.slice(0,o),a=o===-1?"":t.slice(o),l=s?ut(c,s):c;return new URL(`${l}${n||a}`).toString()},"mergeUrlMetadata"),Z=i((t,r)=>{if(r===void 0)return t;const e=new URL(t);if(e.searchParams.has(E))return t;const s=e.pathname.toLowerCase().lastIndexOf("%3f");if(s===-1)return t;const n=e.pathname.slice(s+3);if(n.includes("/"))return t;const o=new URLSearchParams(n.replaceAll("%25","%"));return o.get("namespace")!==r?t:(o.delete("namespace"),o.set(st,r),e.pathname=e.pathname.slice(0,s),e.search=o.toString(),e.toString())},"restoreCjsBridgeNamespace"),Ht=i((t,r,e)=>{if(r!=="commonjs"||!t.startsWith(y)||!et.test(t))return t;const s=new URL(t),n=[nt(s.search,[I]),...e?[`namespace=${encodeURIComponent(e)}`]:[]].filter(Boolean).join("&");return n?(s.pathname+=`%3F${n}`,s.searchParams.set(E,"1"),s.toString()):t},"preserveCommonJsQueryIdentity"),Je=i(t=>{const r=i(async(e,s,n)=>{if(!t.active||e.startsWith("node:"))return n(e,s);e.startsWith(y)&&(e=Z(e,t.namespace));const{parentURL:o}=s;o?.startsWith(y)&&(s.parentURL=Z(o,t.namespace));const c=s.parentURL&&R(s.parentURL);let a=T(e)?c:R(e)??c;if(t.namespace){let p;if(e.startsWith(D)){try{p=JSON.parse(e.slice(D.length))}catch{}p?.namespace&&(a=p.namespace)}if(t.namespace!==a)return n(e,s);p&&(e=p.specifier,s.parentURL=p.parentURL)}if(T(e)){const p=await n(e,s);return t.namespace?{...p,url:Y(p.url,t.namespace)}:p}const l=Mt(e,V(s)),f=l===-1?e:e.slice(0,l),d=l===-1?"":e.slice(l),h=await Ce(f,s,n,t);if(u(2,"nextResolve",{resolved:h}),h.format==="builtin"||h.url.startsWith("node:"))return h;const m={...h};m.url.startsWith(y)&&(m.format==="module-typescript"?m.format="module":m.format==="commonjs-typescript"?m.format="commonjs":!m.format&&!Bt(m.url)&&(m.format=await fe(m.url),u(2,"getFormatFromFileUrl",{resolved:m,format:m.format}))),d&&(m.url=Qt(m.url,d));const g=s.parentURL&&m.format==="commonjs"&&et.test(m.url)&&(new URL(s.parentURL).searchParams.has(O)||Se(s.parentURL,e,Fe));return a&&R(m.url)===void 0&&(m.url=Y(m.url,a)),g&&(m.url=ut(m.url,he)),(a||g)&&(m.url=Ht(m.url,m.format,a)),m},"resolve");return B?async(e,s,n)=>{u(2,"resolve",{specifier:e,context:s});const o=await r(e,s,n);return u(1,"resolved",{specifier:e,context:s,result:o}),o}:r},"createResolve"),Ne=i(t=>{const r=i((e,s,n)=>{if(!t.active||e.startsWith("node:")||V(s)&&tt())return n(e,s);e.startsWith(y)&&(e=Z(e,t.namespace));const{parentURL:o}=s;o?.startsWith(y)&&(s.parentURL=Z(o,t.namespace));const c=s.parentURL&&R(s.parentURL);let a=T(e)?c:R(e)??c;if(t.namespace){let g;if(e.startsWith(D)){try{g=JSON.parse(e.slice(D.length))}catch{}g?.namespace&&(a=g.namespace)}if(t.namespace!==a)return n(e,s);g&&(e=g.specifier,s.parentURL=g.parentURL)}if(T(e)){const g=n(e,s);return t.namespace?{...g,url:Y(g.url,t.namespace)}:g}const l=Mt(e,V(s)),f=l===-1?e:e.slice(0,l),d=l===-1?"":e.slice(l),h=be(f,s,n,t);if(u(2,"nextResolve",{resolved:h}),h.format==="builtin"||h.url.startsWith("node:"))return h;const m={...h};return m.url.startsWith(y)&&(m.format==="module-typescript"?m.format="module":m.format==="commonjs-typescript"?m.format="commonjs":!m.format&&!Bt(m.url)&&(m.format=pe(m.url),u(2,"getFormatFromFileUrlSync",{resolved:m,format:m.format}))),d&&(m.url=Qt(m.url,d)),a&&R(m.url)===void 0&&(m.url=Y(m.url,a)),m.url=Ht(m.url,m.format,a),m},"resolve");return B?(e,s,n)=>{u(2,"resolveSync",{specifier:e,context:s});const o=r(e,s,n);return u(1,"resolvedSync",{specifier:e,context:s,result:o}),o}:r},"createResolveSync"),Gt=i(t=>(r,e)=>{if(!e)throw new Error("The current file path (import.meta.url) must be provided in the second argument of tsImport()");const s=e.startsWith(y)?e:S(e).toString();return import(`tsx://${JSON.stringify({specifier:r,parentURL:s,namespace:t})}`)},"createScopedImport");let xt=!1;const Me=i(t=>{const r=[];for(let e=0;e[...(process.env.NODE_OPTIONS??"").matchAll(/(?:^|\s)--import(?:=|\s+)(\S+)/g)].map(([,t])=>t),"collectNodeOptionsImportSpecifiers"),zt=[new URL("loader.mjs",import.meta.url).toString(),new URL("esm/index.mjs",import.meta.url).toString()],Be=new Set(["tsx","tsx/esm",...zt,...zt.map(t=>decodeURI(new URL(t).pathname))]),Ae=i(t=>Be.has(t),"isTsxImport"),Xt=i(t=>/\.(?:[cm]?ts|tsx)(?:[?#].*)?$/.test(t),"isTypeScriptImport"),qe=i(()=>{const t=Me(process.execArgv),r=t.findIndex(Ae);return r>0&&t.slice(0,r).some(Xt)},"hasCliTypeScriptPreload"),Qe=_e().some(Xt)||qe(),Vt=typeof j.registerHooks=="function"&&F(kt)&&!Qe,He=i(t=>{if(!j.register&&!Vt)throw new Error(`This version of Node.js (${process.version}) does not support module.register(). Please upgrade to Node v18.19 or v20.6 and above.`);if(!xt){const{_resolveFilename:a}=j;j._resolveFilename=(l,...f)=>a(ne(l),...f),xt=!0}const{sourceMapsEnabled:r}=process;if(process.setSourceMapsEnabled(!0),Vt){const a=Tt({namespace:t?.namespace,onImport:t?.onImport,tsconfig:t?.tsconfig}),l=j.registerHooks({load:Le(a),resolve:Ne(a)}),f=i((async()=>{a.active=!1,l.deregister(),r===!1&&process.setSourceMapsEnabled(!1)}),"unregister2");return t?.namespace&&(f.import=Gt(t.namespace),f.unregister=f),f}const{port1:e,port2:s}=new Yt;j.register(`./esm/index.mjs?${Dt.randomUUID()}`,{parentURL:import.meta.url,data:{port:s,namespace:t?.namespace,tsconfig:t?.tsconfig},transferList:[s]});const n=t?.onImport,o=n&&(a=>{a.type==="load"&&n(a.url)});o&&(e.on("message",o),e.unref());const c=i(()=>(r===!1&&process.setSourceMapsEnabled(!1),o&&e.off("message",o),e.postMessage("deactivate"),new Promise(a=>{const l=i(f=>{f.type==="deactivated"&&(a(),e.off("message",l))},"onDeactivated");e.on("message",l)})),"unregister");return t?.namespace&&(c.import=Gt(t.namespace),c.unregister=c),c},"register");export{le as a,Te as b,ue as c,Je as d,de as e,He as r};