/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
const require_analytics = require("./utils/analytics.cjs");
const require_args = require("./lib/args.cjs");
const require_colors = require("./lib/colors.cjs");
const require_print = require("./lib/print.cjs");
const require_getCommandHelp = require("./utils/getCommandHelp.cjs");
const require_codemod = require("./commands/codemod/codemod.cjs");
const require_editor_rules = require("./commands/editor-rules.cjs");
//#region ../cli/dist/cli.mjs
/*! © 2026 Yahoo, Inc. UDS CLI v0.0.0-development */
/**
* UDS CLI - Universal Design System Command Line Interface
*
* This is the main entry point for the CLI. It uses manual argument parsing
* (no external framework) following the packages/mobile pattern.
*/
const { positional, options } = require_args.parseArgs(process.argv.slice(2));
const command = positional[0];
const banner = `
█ █ █▀▄ ▄▀▀   ▄▀▀ █   █
▀▄█ █▄▀ ▄██   ▀▄▄ █▄▄ █
Universal Design System
`.trim();
const LOCAL_COMMANDS = [{
	name: "codemod",
	description: "Apply a codemod",
	run: (props) => require_codemod.codemod_default.run({
		...props,
		first: positional[1]
	})
}, {
	name: "editor-rules",
	description: "🎯 Generate editor rules for various code editors and AI tools",
	aliases: ["rules", "editor"],
	run: require_editor_rules.editor_rules_default.run
}];
function showHelp(commands) {
	const widest = Math.max(...commands.map((c) => c.name.length)) + 4;
	const subcommandWidest = Math.max(...require_getCommandHelp.CODEMOD_SUBCOMMANDS.map((c) => c.name.length)) + 4;
	require_print.print(`\n${require_colors.green(banner)}\n`);
	require_print.print(`${require_colors.magenta("Usage:")} ${require_colors.white("uds <command> [options]")}\n`);
	require_print.print(`${require_colors.magenta("Commands:")}`);
	for (const cmd of commands) {
		require_print.print(`  ${require_colors.cyan(cmd.name.padEnd(widest))} ${require_colors.gray(cmd.description)}`);
		if (cmd.name === "codemod") for (const sub of require_getCommandHelp.CODEMOD_SUBCOMMANDS) require_print.print(`      ${require_colors.cyan(sub.name.padEnd(subcommandWidest))} ${require_colors.gray(sub.description)}`);
	}
	require_print.print("");
}
async function run(externalCommands) {
	const commands = [...LOCAL_COMMANDS, ...externalCommands];
	const helpCommands = commands.filter((c) => c.tag !== "hidden");
	const showHelpForCommands = () => showHelp(helpCommands);
	const props = {
		name: "uds",
		commandPath: positional.slice(0, 1),
		first: positional[1],
		second: positional[2],
		third: positional[3],
		options
	};
	if (command === "help" || command === "--help" || command === "-h" || !command) {
		showHelpForCommands();
		return;
	}
	const commandDefinition = commands.find((c) => c.name === command || c.aliases?.includes(command));
	if (!commandDefinition) {
		require_print.print(require_colors.red(`Unknown command: ${command}`));
		await require_analytics.trackEvent("unknown_cmd", { cmd: command });
		showHelpForCommands();
		process.exitCode = 1;
		return;
	}
	await commandDefinition.run(props);
}
//#endregion
exports.run = run;
