import { createJiti } from "../../../../../jiti@2.4.2/node_modules/jiti/lib/jiti.mjs";
import { resolveSchema } from "../shared/untyped.BTwOq8Jl.mjs";
import { babelPluginUntyped } from "./babel.mjs";
import { defu } from "defu";

//#region ../../node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/loader.mjs
async function loadSchema(entryPath, options = {}) {
	let rawSchema = await createJiti(options.cwd || process.cwd(), defu(options.jiti, {
		interopDefault: true,
		transformOptions: { babel: { plugins: [[babelPluginUntyped, { experimentalFunctions: true }]] } }
	})).import(entryPath);
	const rawSchemaKeys = Object.keys(rawSchema);
	if (rawSchemaKeys.length === 1 && rawSchemaKeys[0] === "default") rawSchema = rawSchema.default;
	return await resolveSchema(rawSchema, options.defaults, { ignoreDefaults: options.ignoreDefaults });
}

//#endregion
export { loadSchema };