/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
import { clamp } from "lodash-es";
//#region ../tailwind-internal/dist/utils/opacity.js
/*! © 2026 Yahoo, Inc. UDS Tailwind Internal v0.0.0-development */
/**
* Converts a number or string to a valid OpacityStep.
*
* Converts a number or string to a valid OpacityStep by:
* - Parsing the value as an integer
* - Clamping between 0 and 100
* - Returning as a string in the format expected by OpacityStep
*
* @param opacity - The opacity value (number or string)
* @returns A valid OpacityStep string clamped between 0-100
* @throws {Error} If opacity is undefined, null, or cannot be parsed as a number
*/
function parseOpacityStep(opacity) {
	if (opacity === void 0 || opacity === null) throw new Error(`Invalid opacity value: ${opacity}`);
	const parsed = typeof opacity === "number" ? opacity : parseInt(opacity, 10);
	if (isNaN(parsed)) throw new Error(`Invalid opacity value: cannot parse "${opacity}" as a number`);
	return clamp(parsed, 0, 100).toString();
}
//#endregion
export { parseOpacityStep };
