"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../_virtual/_rolldown/runtime.js');
const require_primordials_math = require('../primordials/math.js');
let src_external_yoctocolors_cjs = require("../external/yoctocolors-cjs");
src_external_yoctocolors_cjs = require_runtime.__toESM(src_external_yoctocolors_cjs);

//#region src/spinner/format.ts
/**
* @file Stateless helpers shared by `spinner/*` modules — the `ciSpinner`
*   constant for non-interactive output, the `COLOR_INHERIT` sentinel for
*   shimmer color references, plus pure formatters (`desc`, `formatProgress`,
*   `normalizeText`, `renderProgressBar`) used by both the factory and the
*   `withSpinner*` wrappers.
*/
/**
* Sentinel value indicating the shimmer should track the spinner's current
* color rather than holding its own palette reference.
*/
const COLOR_INHERIT = "inherit";
/**
* Minimal spinner style for CI environments. Uses empty frame and max interval
* to effectively disable animation in CI.
*/
const ciSpinner = {
	frames: [""],
	interval: 2147483647
};
/**
* Create a property descriptor for defining non-enumerable properties. Used for
* adding aliased methods to the Spinner prototype.
*
* @param value - Value for the property.
*
* @returns Property descriptor object
*/
function desc(value) {
	return {
		__proto__: null,
		configurable: true,
		value,
		writable: true
	};
}
/**
* Format progress information as a visual progress bar with percentage and
* count.
*
* @example
*   '███████░░░░░░░░░░░░░ 35% (7/20 files)'
*
* @param progress - Progress tracking information.
*
* @returns Formatted string with colored progress bar, percentage, and count
*/
function formatProgress(progress) {
	const { current, total, unit } = progress;
	/* c8 ignore next */
	const percentage = total === 0 ? 0 : require_primordials_math.MathRound(current / total * 100);
	return `${renderProgressBar(percentage)} ${percentage}% (${unit ? `${current}/${total} ${unit}` : `${current}/${total}`})`;
}
/**
* Normalize text input by trimming leading whitespace. Non-string values are
* converted to empty string.
*
* @param value - Text to normalize.
*
* @returns Normalized string with leading whitespace removed
*/
function normalizeText(value) {
	/* c8 ignore next */
	return typeof value === "string" ? value.trimStart() : "";
}
/**
* Render a progress bar using block characters (█ for filled, ░ for empty).
*
* @default width=20
*
* @param percentage - Progress percentage (0-100)
* @param width - Total width of progress bar in characters.
*
* @returns Colored progress bar string
*/
function renderProgressBar(percentage, width = 20) {
	const filled = require_primordials_math.MathMax(0, Math.min(width, Math.round(percentage / 100 * width)));
	const empty = require_primordials_math.MathMax(0, width - filled);
	const bar = "█".repeat(filled) + "░".repeat(empty);
	return src_external_yoctocolors_cjs.default.cyan(bar);
}

//#endregion
exports.COLOR_INHERIT = COLOR_INHERIT;
exports.ciSpinner = ciSpinner;
exports.desc = desc;
exports.formatProgress = formatProgress;
exports.normalizeText = normalizeText;
exports.renderProgressBar = renderProgressBar;