/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
import { defaultTokensConfig } from "../defaultTokensConfig.js";
import { variants } from "../styles/variants.js";
import { run } from "./dist/cli.js";
import { makeCSSCommand } from "../css/dist/commands/css.js";
import { makeTailwindV4ThemeCommand } from "../tailwind-v4/dist/cli.js";
import package_default from "../uds/package.js";
import { makePurgeCommand } from "./commands/purge.js";
import { syncCommand } from "./commands/sync.js";
import { versionCommand } from "./commands/version.js";
import path from "node:path";
import { pathToFileURL } from "node:url";
//#region src/cli/runner.ts
const getPurgeContext = async () => {
	const componentData = await import("../uds/generated/componentData.js");
	return {
		variants,
		packageJson: package_default,
		generatedPurgeCssData: await import("../uds/generated/tailwindPurge.js"),
		autoVariants: (await import("../automated-config/dist/generated/autoVariants.js")).autoVariants,
		componentData
	};
};
const purgeCommand = {
	name: "purge",
	description: "Purge unused CSS",
	run: async (props) => {
		await makePurgeCommand(getPurgeContext).run(props);
	}
};
const cssCommand = makeCSSCommand(async () => {
	const componentData = await import("../uds/generated/componentData.js");
	return {
		variants,
		autoVariants: (await import("../automated-config/dist/generated/autoVariants.js")).autoVariants,
		componentData
	};
});
const getTailwindV4Config = async () => {
	for (const candidatePath of ["uds.config.ts", "uds.config.js"]) try {
		const loaded = await import(pathToFileURL(path.resolve(process.cwd(), candidatePath)).href);
		if (loaded.config) return loaded.config;
	} catch {}
	return defaultTokensConfig;
};
run([
	versionCommand,
	purgeCommand,
	cssCommand,
	makeTailwindV4ThemeCommand({ getConfig: getTailwindV4Config }),
	syncCommand
]);
//#endregion
