/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
const require_colors = require("../../cli/dist/lib/colors.cjs");
const require_print = require("../../cli/dist/lib/print.cjs");
const require_generateTheme_DkTgUwTM = require("./generateTheme-DkTgUwTM.cjs");
let node_path = require("node:path");
node_path = require_runtime.__toESM(node_path, 1);
let node_fs_promises = require("node:fs/promises");
node_fs_promises = require_runtime.__toESM(node_fs_promises, 1);
//#region ../tailwind-v4/dist/cli.js
/*! © 2026 Yahoo, Inc. UDS Tailwind v4 v0.0.0-development */
const ALLOWED_DISABLE_OVERRIDES = new Set([
	"color",
	"border",
	"elevation",
	"font",
	"text",
	"spacing",
	"radius",
	"shadow",
	"breakpoint"
]);
function parseDisableOverride(raw) {
	if (!raw || raw === true) return [];
	const values = String(raw).split(",").map((value) => value.trim()).filter(Boolean);
	for (const value of values) if (!ALLOWED_DISABLE_OVERRIDES.has(value)) throw new Error(`Invalid --disable-override entry '${value}'. Allowed values: ${Array.from(ALLOWED_DISABLE_OVERRIDES).join(", ")}.`);
	return values;
}
function isTruthyFlag(value) {
	if (value === true) return true;
	if (typeof value !== "string") return false;
	const normalized = value.trim().toLowerCase();
	return normalized === "true" || normalized === "1" || normalized === "";
}
function parseColorScheme(raw) {
	if (!raw || raw === true) return "system";
	const value = String(raw).trim().toLowerCase();
	if (value === "class" || value === "system" || value === "light" || value === "dark") return value;
	throw new Error(`Invalid --color-scheme value '${value}'. Allowed: "system", "class", "light", "dark".`);
}
function parseColorMode(raw) {
	if (!raw || raw === true) return "light";
	const value = String(raw).trim().toLowerCase();
	if (value === "light" || value === "dark") return value;
	throw new Error(`Invalid --default-color-mode value '${value}'. Allowed: "light", "dark".`);
}
function showHelp() {
	require_print.print("Usage:\n");
	require_print.print(`  ${require_colors.cyan("uds tailwind-v4 [options]")}\n`);
	require_print.print("Options:\n");
	require_print.print(`  ${require_colors.cyan("--out <path>")}                        Output path (default: dist/uds-theme.css)`);
	require_print.print(`  ${require_colors.cyan("--color-scheme <mode>")}             Color mode strategy: "system" (media query, default), "class" (CSS classes), "light", or "dark"`);
	require_print.print(`  ${require_colors.cyan("--default-color-mode <mode>")}       Default color mode: "light" (default) or "dark"`);
	require_print.print(`  ${require_colors.cyan("--light-mode-class <name>")}         CSS class name for light mode (default: light)`);
	require_print.print(`  ${require_colors.cyan("--dark-mode-class <name>")}          CSS class name for dark mode (default: dark)`);
	require_print.print(`  ${require_colors.cyan("--system-mode-class <name>")}        CSS class name for system mode (default: system)`);
	require_print.print(`  ${require_colors.cyan("--disable-override <list>")}          Comma-separated categories to suppress. Allowed: color, border, elevation, font, text, spacing, radius, shadow, breakpoint`);
	require_print.print(`  ${require_colors.cyan("--skip-fonts")}                       Skip emitting @font-face declarations`);
	require_print.print(`  ${require_colors.cyan("--help, -h")}                         Show this help message\n`);
	require_print.print("Examples:\n");
	require_print.print(`  ${require_colors.gray("uds tailwind-v4")}`);
	require_print.print(`  ${require_colors.gray("uds tailwind-v4 --skip-fonts")}`);
	require_print.print(`  ${require_colors.gray("uds tailwind-v4 --color-scheme system")}`);
	require_print.print(`  ${require_colors.gray("uds tailwind-v4 --color-scheme class")}`);
	require_print.print(`  ${require_colors.gray("uds tailwind-v4 --color-scheme class --dark-mode-class dark2 --light-mode-class light2")}`);
	require_print.print(`  ${require_colors.gray("uds tailwind-v4 --default-color-mode dark")}`);
	require_print.print(`  ${require_colors.gray("uds tailwind-v4 --color-scheme light")}`);
	require_print.print(`  ${require_colors.gray("uds tailwind-v4 --color-scheme dark")}`);
}
function makeTailwindV4ThemeCommand({ getConfig }) {
	return {
		name: "tailwind-v4",
		description: "Generate Tailwind v4 @theme CSS (with optional @font-face declarations)",
		run: async ({ options }) => {
			if (isTruthyFlag(options.help) || isTruthyFlag(options.h)) {
				showHelp();
				return;
			}
			const outputPath = node_path.default.resolve(process.cwd(), String(options.out ?? "dist/uds-theme.css"));
			await node_fs_promises.default.mkdir(node_path.default.dirname(outputPath), { recursive: true });
			const tailwindOptions = {
				disableOverrideTailwindTheme: parseDisableOverride(options["disable-override"]),
				includeFontFace: !isTruthyFlag(options["skip-fonts"]),
				colorScheme: parseColorScheme(options["color-scheme"]),
				defaultColorMode: parseColorMode(options["default-color-mode"]),
				lightModeClass: String(options["light-mode-class"] ?? "light"),
				darkModeClass: String(options["dark-mode-class"] ?? "dark"),
				systemModeClass: String(options["system-mode-class"] ?? "system")
			};
			const { css, warnings } = require_generateTheme_DkTgUwTM.generateThemeResult(await getConfig(), tailwindOptions);
			await node_fs_promises.default.writeFile(outputPath, css, "utf8");
			require_print.print(`✅ Generated Tailwind v4 theme CSS at ${require_colors.cyan(outputPath)}`);
			if (warnings.length > 0) {
				require_print.print(require_colors.yellow(`⚠ ${warnings.length} warnings encountered during theme generation:`));
				for (const warning of warnings.slice(0, 10)) require_print.print(require_colors.yellow(`- ${warning.path}: ${warning.message}`));
				if (warnings.length > 10) require_print.print(require_colors.yellow(`- ...and ${warnings.length - 10} more warnings.`));
			}
		}
	};
}
//#endregion
exports.makeTailwindV4ThemeCommand = makeTailwindV4ThemeCommand;
