//#region src/border-beam/util.ts
const MAX_BEAM_COLOR_STOP_PERCENT = 70;
function getLinearGradient(...colorStops) {
	return `linear-gradient(to left, ${colorStops.join(", ")}, transparent)`;
}
function normalizeBorderBeamColor(value) {
	return typeof value === "string" ? [{
		color: value,
		percent: 0
	}] : value ?? [];
}
function fillGradientEnd(items) {
	const lastItem = items[items.length - 1];
	if (!lastItem || lastItem.percent === 100) return items;
	return [...items, {
		...lastItem,
		percent: 100
	}];
}
function getMappedBeamColorStopPercent(percent) {
	return Number((Math.min(Math.max(percent, 0), 100) / 100 * MAX_BEAM_COLOR_STOP_PERCENT).toFixed(2));
}
function normalizeGradientItems(items) {
	return fillGradientEnd(items).map((item) => ({
		...item,
		percent: getMappedBeamColorStopPercent(item.percent)
	}));
}
function getBorderBeamGradient(value) {
	const normalizedStops = normalizeGradientItems(normalizeBorderBeamColor(value));
	return normalizedStops.length ? getLinearGradient(...normalizedStops.map((item) => `${item.color} ${item.percent}%`)) : void 0;
}

//#endregion
export { MAX_BEAM_COLOR_STOP_PERCENT, getBorderBeamGradient };