import{__exports as t}from"../../../_virtual/loaders.mjs";import r from"../../../_virtual/_node_fs.mjs";import o from"../../../_virtual/promises.mjs";import e from"../../../_virtual/_node_path.mjs";import i from"../../../_virtual/_node_url.mjs";import{__require as n}from"../../import-fresh/index.mjs";import{__require as s}from"../../parse-json/index.mjs";import a from"../../../_virtual/js-yaml.mjs";import{__require as l}from"../../typescript/lib/typescript.mjs";var u;function d(){return u||(u=1,function(u){var d=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(u,"__esModule",{value:!0}),u.loadTs=u.loadTsSync=u.loadYaml=u.loadJson=u.loadJs=u.loadJsSync=void 0;const m=r,c=o,p=d(e),f=i;let y;u.loadJsSync=function(t){return void 0===y&&(y=n()),y(t)};let _;u.loadJs=async function(t){try{const{href:r}=(0,f.pathToFileURL)(t);return(await import(r)).default}catch(r){try{return(0,u.loadJsSync)(t,"")}catch(t){if("ERR_REQUIRE_ESM"===t.code||t instanceof SyntaxError&&t.toString().includes("Cannot use import statement outside a module"))throw r;throw t}}};let S;u.loadJson=function(t,r){void 0===_&&(_=s());try{return _(r)}catch(r){throw r.message=`JSON Error in ${t}:\n${r.message}`,r}};let g;u.loadYaml=function(t,r){void 0===S&&(S=a);try{return S.load(r)}catch(r){throw r.message=`YAML Error in ${t}:\n${r.message}`,r}};u.loadTsSync=function(t,r){
/* istanbul ignore next -- @preserve */
void 0===g&&(g=l());const o=`${t.slice(0,-2)}cjs`;try{const e=h(p.default.dirname(t))??{};return e.compilerOptions={...e.compilerOptions,module:g.ModuleKind.NodeNext,moduleResolution:g.ModuleResolutionKind.NodeNext,target:g.ScriptTarget.ES2022,noEmit:!1},r=g.transpileModule(r,e).outputText,(0,m.writeFileSync)(o,r),(0,u.loadJsSync)(o,r).default}catch(r){throw r.message=`TypeScript Error in ${t}:\n${r.message}`,r}finally{(0,m.existsSync)(o)&&(0,m.rmSync)(o)}};function h(t){const r=g.findConfigFile(t,t=>g.sys.fileExists(t));if(void 0!==r){const{config:t,error:o}=g.readConfigFile(r,t=>g.sys.readFile(t));if(o)throw new Error(`Error in ${r}: ${o.messageText.toString()}`);return t}}u.loadTs=async function(t,r){void 0===g&&(g=(await import("../../../_virtual/typescript.mjs").then(function(t){return t.t})).default);const o=`${t.slice(0,-2)}mjs`;let e;try{try{const i=h(p.default.dirname(t))??{};i.compilerOptions={...i.compilerOptions,module:g.ModuleKind.ES2022,moduleResolution:g.ModuleResolutionKind.Bundler,target:g.ScriptTarget.ES2022,noEmit:!1},e=g.transpileModule(r,i).outputText,await(0,c.writeFile)(o,e)}catch(r){throw r.message=`TypeScript Error in ${t}:\n${r.message}`,r}return await(0,u.loadJs)(o,e)}finally{(0,m.existsSync)(o)&&await(0,c.rm)(o)}}}(t)),t}export{d as __require};