"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("node:fs"),c=require("node:path"),a=require("node:url"),f=require("js-yaml"),l=require("node:module");var u=typeof document<"u"?document.currentScript:null;function d(t,r){return Buffer.isBuffer(t)&&(t=String(t)),typeof t=="string"?y(t)?a.fileURLToPath(t):c.resolve(r,t):a.fileURLToPath(t)}function y(t){return t.startsWith("file:")||t.startsWith("data:")}function n(t){return!!t&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}function p(){return(Math.random()+1).toString(36).substring(7)}async function m(t){return f.load(await s.promises.readFile(t,"utf8"))}async function w(t){return JSON.parse(await s.promises.readFile(t,"utf8"))}async function S(t,...r){const o=p();let{default:e}=await import(a.pathToFileURL(t).toString()+`?v=${o}`);if(t.endsWith(".cjs")&&typeof e=="object"){const i=Array.isArray(e);if(!n(e)&&!i&&!("default"in e))throw new SyntaxError("Expected module file to be exported as default export");e=i||n(e)?e:e.default}if(typeof e>"u")throw new SyntaxError("Expected module file to be exported as default export");if(n(e))try{return Promise.resolve(e(...r))}catch{return Promise.resolve(e)}else return typeof e=="function"?e(...r):e}async function x(t,r=process.cwd(),...o){const e=d(t,r);switch(c.extname(e)){case".yml":case".yaml":return await m(e);case".json":case"":return await w(e);case".js":case".mjs":case".cjs":return await S(e,...o);default:throw new TypeError(`Unsupported file format: ${e}`)}}function h(t){return f.load(s.readFileSync(t,"utf8"))}function j(t){return JSON.parse(s.readFileSync(t,"utf8"))}function b(t,...r){const o=l.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:u&&u.src||new URL("index.cjs",document.baseURI).href);delete o.cache[o.resolve(t)];let e=o(t);if(typeof e=="object"){const i=Array.isArray(e);if(!n(e)&&!i&&!("default"in e))throw new SyntaxError("Expected module file to be exported as default export");e=i||n(e)?e:e.default}if(typeof e>"u")throw new SyntaxError("Expected module file to be exported as default export");if(n(e))try{return Promise.resolve(e(...r))}catch{return Promise.resolve(e)}else return typeof e=="function"?e(...r):e}function F(t,r=process.cwd(),...o){const e=d(t,r);switch(c.extname(e)){case".yml":case".yaml":return h(e);case".json":case"":return j(e);case".js":case".cjs":return b(e,...o);default:throw new TypeError(`Unsupported file format: ${e}`)}}exports.loadFile=x;exports.loadFileSync=F;