/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-d4ad2ea | Cube Dev Team */
//#region src/components/content/Layout/utils.ts
/**
* Clamps a size value within min/max constraints.
* Handles both number and string constraint values (only numbers are applied).
*/
function clampSize(value, minSize, maxSize, naturalMax) {
	let result = value;
	let effectiveMax;
	if (typeof maxSize === "number") effectiveMax = maxSize;
	if (naturalMax != null && naturalMax >= 0) effectiveMax = effectiveMax != null ? Math.min(effectiveMax, naturalMax) : naturalMax;
	if (effectiveMax != null) result = Math.min(effectiveMax, result);
	if (typeof minSize === "number") result = Math.max(minSize, result);
	return Math.max(result, 0);
}
const OPPOSITE_SIDES = {
	left: "right",
	right: "left",
	top: "bottom",
	bottom: "top"
};
function getOppositeSide(side) {
	return OPPOSITE_SIDES[side];
}
/**
* Resolves a CSS size value (string or number) to pixels.
* Supports `px` values and percentages (resolved against containerSize).
* Returns undefined for values that can't be resolved in JS (e.g. `50vw`, `min(...)`, etc.).
*/
function resolveCssSize(value, containerSize) {
	if (value == null) return void 0;
	if (typeof value === "number") return value;
	const trimmed = value.trim();
	if (trimmed.endsWith("px")) {
		const num = parseFloat(trimmed);
		return Number.isFinite(num) ? num : void 0;
	}
	if (trimmed.endsWith("%")) {
		const percent = parseFloat(trimmed);
		return Number.isFinite(percent) ? percent / 100 * containerSize : void 0;
	}
	const num = parseFloat(trimmed);
	if (String(num) === trimmed && Number.isFinite(num)) return num;
}

//#endregion
export { clampSize, getOppositeSide, resolveCssSize };
//# sourceMappingURL=utils.js.map