/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
const require_colors = require("./colors.cjs");
const require_print = require("./print.cjs");
//#region ../cli/dist/lib/box.mjs
/*! © 2026 Yahoo, Inc. UDS CLI v0.0.0-development */
/**
* Strips ANSI escape codes from a string to get the visible character length.
*/
function stripAnsi(str) {
	return str.replace(/\x1b\[[0-9;]*m/g, "");
}
/**
* Prints lines inside a bordered box, similar to npm/turbo update notifications.
*
* Example output:
* ╭──────────────────────────────────────────────────────╮
* │                                                      │
* │   Updated UDS rules are available for Cursor and     │
* │   Claude Code. Run `uds editor-rules` to update.     │
* │                                                      │
* ╰──────────────────────────────────────────────────────╯
*/
function printBox(lines) {
	const padding = 3;
	const innerWidth = Math.max(...lines.map((l) => stripAnsi(l).length)) + padding * 2;
	const top = require_colors.yellow(`╭${"─".repeat(innerWidth)}╮`);
	const bottom = require_colors.yellow(`╰${"─".repeat(innerWidth)}╯`);
	const emptyLine = require_colors.yellow("│") + " ".repeat(innerWidth) + require_colors.yellow("│");
	require_print.print("");
	require_print.print(top);
	require_print.print(emptyLine);
	for (const line of lines) {
		const visibleLength = stripAnsi(line).length;
		const rightPad = innerWidth - padding - visibleLength;
		require_print.print(require_colors.yellow("│") + " ".repeat(padding) + line + " ".repeat(rightPad) + require_colors.yellow("│"));
	}
	require_print.print(emptyLine);
	require_print.print(bottom);
	require_print.print("");
}
//#endregion
exports.printBox = printBox;
